Squashed 'third_party/pi/' content from commit d981de122
git-subtree-dir: third_party/pi git-subtree-split: d981de1229ef899957bbe968bc8dcda02a21f477
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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);
|
||||
},
|
||||
}),
|
||||
);
|
||||
});
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user