Files
AI-Harness-Basic/extensions/example.ts

43 lines
978 B
TypeScript

import type { Extension } from "../src/types.js";
const exampleExtension: Extension = async ({
registerTool,
registerCommand,
on,
addSystemPrompt
}) => {
await registerTool({
name: "echo",
description: "Echo text back exactly as provided.",
parameters: {
type: "object",
properties: {
text: { type: "string" }
},
required: ["text"],
additionalProperties: false
},
execute(input: { text: string }) {
return input.text;
}
});
await registerCommand({
name: "tools",
description: "Show tools registered by the example extension.",
execute() {
return "Example extension tools: echo";
}
});
addSystemPrompt("The echo tool is available when exact repetition is useful.");
on("tool.call.completed", ({ tool }) => {
if (tool === "echo") {
// Placeholder for extension-side behavior such as metrics or persistence.
}
});
};
export default exampleExtension;