File size: 1,082 Bytes
f500658 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | import { defineFacet } from "@earendil-works/chord";
import { AgentController, PresentationUI, SlashCommands } from "@earendil-works/pi-coding-agent/experimental/plugin";
import { ExampleFacetService } from "./contract.ts";
export default defineFacet({
id: "@earendil-works/pi-example-plugin/tui",
setup(env) {
const example = env.use(ExampleFacetService);
const commands = env.use(SlashCommands);
const controller = env.use(AgentController);
const ui = env.use(PresentationUI);
env.onActivate(() => {
env.own(
commands.replace({
name: "hello",
description: "Call the bundled Session worker facet",
argumentHint: "<name>",
async run(args, context) {
const message = args.length === 0 ? "from the TUI" : args;
const reply = await example.greet({ name: message }, context);
ui.showStatus(
`We got this: ${reply.message} Worker activations: ${reply.workerActivations}.`,
context,
);
return controller.prompt({ message: `pong: ${message}`, images: null }, context);
},
}),
);
});
},
});
|