mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 17:00:59 +00:00
feat(coding-agent): export run mode utilities with options interfaces
- Add PrintModeOptions interface, update runPrintMode signature - Export InteractiveMode, InteractiveModeOptions, runPrintMode, PrintModeOptions, runRpcMode from main package - Document run modes in docs/sdk.md with usage examples - Update CHANGELOG
This commit is contained in:
parent
5d39074a35
commit
e483521075
6 changed files with 94 additions and 16 deletions
|
|
@ -202,6 +202,14 @@ export {
|
|||
} from "./core/tools/index.js";
|
||||
// Main entry point
|
||||
export { main } from "./main.js";
|
||||
// Run modes for programmatic SDK usage
|
||||
export {
|
||||
InteractiveMode,
|
||||
type InteractiveModeOptions,
|
||||
type PrintModeOptions,
|
||||
runPrintMode,
|
||||
runRpcMode,
|
||||
} from "./modes/index.js";
|
||||
// UI components for extensions
|
||||
export {
|
||||
ArminComponent,
|
||||
|
|
|
|||
|
|
@ -380,7 +380,12 @@ export async function main(args: string[]) {
|
|||
});
|
||||
await mode.run();
|
||||
} else {
|
||||
await runPrintMode(session, mode, parsed.messages, initialMessage, initialImages);
|
||||
await runPrintMode(session, {
|
||||
mode,
|
||||
messages: parsed.messages,
|
||||
initialMessage,
|
||||
initialImages,
|
||||
});
|
||||
stopThemeWatcher();
|
||||
if (process.stdout.writableLength > 0) {
|
||||
await new Promise<void>((resolve) => process.stdout.once("drain", resolve));
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
|
||||
export { InteractiveMode, type InteractiveModeOptions } from "./interactive/interactive-mode.js";
|
||||
export { runPrintMode } from "./print-mode.js";
|
||||
export { type PrintModeOptions, runPrintMode } from "./print-mode.js";
|
||||
export { type ModelInfo, RpcClient, type RpcClientOptions, type RpcEventListener } from "./rpc/rpc-client.js";
|
||||
export { runRpcMode } from "./rpc/rpc-mode.js";
|
||||
export type { RpcCommand, RpcResponse, RpcSessionState } from "./rpc/rpc-types.js";
|
||||
|
|
|
|||
|
|
@ -9,23 +9,26 @@
|
|||
import type { AssistantMessage, ImageContent } from "@mariozechner/pi-ai";
|
||||
import type { AgentSession } from "../core/agent-session.js";
|
||||
|
||||
/**
|
||||
* Options for print mode.
|
||||
*/
|
||||
export interface PrintModeOptions {
|
||||
/** Output mode: "text" for final response only, "json" for all events */
|
||||
mode: "text" | "json";
|
||||
/** Array of additional prompts to send after initialMessage */
|
||||
messages?: string[];
|
||||
/** First message to send (may contain @file content) */
|
||||
initialMessage?: string;
|
||||
/** Images to attach to the initial message */
|
||||
initialImages?: ImageContent[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Run in print (single-shot) mode.
|
||||
* Sends prompts to the agent and outputs the result.
|
||||
*
|
||||
* @param session The agent session
|
||||
* @param mode Output mode: "text" for final response only, "json" for all events
|
||||
* @param messages Array of prompts to send
|
||||
* @param initialMessage Optional first message (may contain @file content)
|
||||
* @param initialImages Optional images for the initial message
|
||||
*/
|
||||
export async function runPrintMode(
|
||||
session: AgentSession,
|
||||
mode: "text" | "json",
|
||||
messages: string[],
|
||||
initialMessage?: string,
|
||||
initialImages?: ImageContent[],
|
||||
): Promise<void> {
|
||||
export async function runPrintMode(session: AgentSession, options: PrintModeOptions): Promise<void> {
|
||||
const { mode, messages = [], initialMessage, initialImages } = options;
|
||||
// Set up extensions for print mode (no UI, no command context)
|
||||
const extensionRunner = session.extensionRunner;
|
||||
if (extensionRunner) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue