Build extensible agent harness with interactive chat loop

This commit is contained in:
Adolfo Reyna
2026-05-15 14:17:07 -04:00
commit d8d79efe83
16 changed files with 1398 additions and 0 deletions

42
extensions/example.ts Normal file
View File

@@ -0,0 +1,42 @@
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;