mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 21:03:19 +00:00
12 examples showing increasing levels of customization: - 01-minimal: all defaults - 02-custom-model: model and thinking level - 03-custom-prompt: replace or modify prompt - 04-skills: discover, filter, merge skills - 05-tools: built-in tools, custom tools - 06-hooks: logging, blocking, result modification - 07-context-files: AGENTS.md files - 08-slash-commands: file-based commands - 09-api-keys-and-oauth: API key resolution, OAuth config - 10-settings: compaction, retry, terminal settings - 11-sessions: persistence options - 12-full-control: replace everything Also exports FileSlashCommand type from index.ts
22 lines
621 B
TypeScript
22 lines
621 B
TypeScript
/**
|
|
* Minimal SDK Usage
|
|
*
|
|
* Uses all defaults: discovers skills, hooks, tools, context files
|
|
* from cwd and ~/.pi/agent. Model chosen from settings or first available.
|
|
*/
|
|
|
|
import { createAgentSession } from "../../src/index.js";
|
|
|
|
const { session } = await createAgentSession();
|
|
|
|
session.subscribe((event) => {
|
|
if (event.type === "message_update" && event.assistantMessageEvent.type === "text_delta") {
|
|
process.stdout.write(event.assistantMessageEvent.delta);
|
|
}
|
|
});
|
|
|
|
await session.prompt("What files are in the current directory?");
|
|
session.state.messages.forEach((msg) => {
|
|
console.log(msg);
|
|
});
|
|
console.log();
|