Fix sdk.md and rpc.md to match actual API

- Remove incorrect prompt(AppMessage) overload
- Change AppMessage to AgentMessage
- Change null to undefined for optional returns
- sendHookMessage returns Promise<void>
- Update rpc.md for entryId change
This commit is contained in:
Mario Zechner 2025-12-31 13:50:01 +01:00
parent 8fb936853b
commit ee64d29487
2 changed files with 9 additions and 10 deletions

View file

@ -491,7 +491,7 @@ If a hook cancelled the switch:
Create a new branch from a previous user message. Can be cancelled by a `before_branch` hook. Returns the text of the message being branched from. Create a new branch from a previous user message. Can be cancelled by a `before_branch` hook. Returns the text of the message being branched from.
```json ```json
{"type": "branch", "entryIndex": 2} {"type": "branch", "entryId": "abc123"}
``` ```
Response: Response:
@ -530,8 +530,8 @@ Response:
"success": true, "success": true,
"data": { "data": {
"messages": [ "messages": [
{"entryIndex": 0, "text": "First prompt..."}, {"entryId": "abc123", "text": "First prompt..."},
{"entryIndex": 2, "text": "Second prompt..."} {"entryId": "def456", "text": "Second prompt..."}
] ]
} }
} }

View file

@ -78,7 +78,6 @@ The session manages the agent lifecycle, message history, and event streaming.
interface AgentSession { interface AgentSession {
// Send a prompt and wait for completion // Send a prompt and wait for completion
prompt(text: string, options?: PromptOptions): Promise<void>; prompt(text: string, options?: PromptOptions): Promise<void>;
prompt(message: AppMessage): Promise<void>; // For HookMessage, etc.
// Subscribe to events (returns unsubscribe function) // Subscribe to events (returns unsubscribe function)
subscribe(listener: (event: AgentSessionEvent) => void): () => void; subscribe(listener: (event: AgentSessionEvent) => void): () => void;
@ -90,14 +89,14 @@ interface AgentSession {
// Model control // Model control
setModel(model: Model): Promise<void>; setModel(model: Model): Promise<void>;
setThinkingLevel(level: ThinkingLevel): void; setThinkingLevel(level: ThinkingLevel): void;
cycleModel(): Promise<ModelCycleResult | null>; cycleModel(): Promise<ModelCycleResult | undefined>;
cycleThinkingLevel(): ThinkingLevel | null; cycleThinkingLevel(): ThinkingLevel | undefined;
// State access // State access
agent: Agent; agent: Agent;
model: Model | null; model: Model | undefined;
thinkingLevel: ThinkingLevel; thinkingLevel: ThinkingLevel;
messages: AppMessage[]; messages: AgentMessage[];
isStreaming: boolean; isStreaming: boolean;
// Session management // Session management
@ -109,7 +108,7 @@ interface AgentSession {
navigateTree(targetId: string, options?: { summarize?: boolean }): Promise<{ editorText?: string; cancelled: boolean }>; // In-place navigation navigateTree(targetId: string, options?: { summarize?: boolean }): Promise<{ editorText?: string; cancelled: boolean }>; // In-place navigation
// Hook message injection // Hook message injection
sendHookMessage(message: HookMessage, triggerTurn?: boolean): void; sendHookMessage(message: HookMessage, triggerTurn?: boolean): Promise<void>;
// Compaction // Compaction
compact(customInstructions?: string): Promise<CompactionResult>; compact(customInstructions?: string): Promise<CompactionResult>;
@ -131,7 +130,7 @@ The `Agent` class (from `@mariozechner/pi-agent-core`) handles the core LLM inte
// Access current state // Access current state
const state = session.agent.state; const state = session.agent.state;
// state.messages: AppMessage[] - conversation history // state.messages: AgentMessage[] - conversation history
// state.model: Model - current model // state.model: Model - current model
// state.thinkingLevel: ThinkingLevel - current thinking level // state.thinkingLevel: ThinkingLevel - current thinking level
// state.systemPrompt: string - system prompt // state.systemPrompt: string - system prompt