git-subtree-dir: third_party/pi git-subtree-split: d981de1229ef899957bbe968bc8dcda02a21f477
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
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);
|
|
},
|
|
}),
|
|
);
|
|
});
|
|
},
|
|
});
|