@oh-my-pi/pi-coding-agent 15.13.2 → 16.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -0
- package/dist/cli.js +587 -499
- package/dist/types/advisor/__tests__/advisor.test.d.ts +1 -0
- package/dist/types/advisor/advise-tool.d.ts +58 -0
- package/dist/types/advisor/index.d.ts +3 -0
- package/dist/types/advisor/runtime.d.ts +52 -0
- package/dist/types/advisor/watchdog.d.ts +5 -0
- package/dist/types/config/model-roles.d.ts +1 -1
- package/dist/types/config/settings-schema.d.ts +75 -5
- package/dist/types/eval/js/context-manager.d.ts +15 -0
- package/dist/types/modes/components/advisor-message.d.ts +9 -0
- package/dist/types/modes/components/assistant-message.d.ts +1 -0
- package/dist/types/modes/controllers/command-controller.d.ts +3 -1
- package/dist/types/modes/interactive-mode.d.ts +4 -1
- package/dist/types/modes/types.d.ts +9 -1
- package/dist/types/sdk.d.ts +3 -3
- package/dist/types/session/agent-session.d.ts +71 -2
- package/dist/types/session/session-history-format.d.ts +4 -0
- package/dist/types/session/unexpected-stop-classifier.d.ts +13 -0
- package/dist/types/session/yield-queue.d.ts +2 -0
- package/dist/types/stt/asr-client.d.ts +1 -1
- package/dist/types/tiny/title-client.d.ts +1 -1
- package/dist/types/tools/job.d.ts +1 -0
- package/dist/types/tools/path-utils.d.ts +1 -0
- package/dist/types/tools/report-tool-issue.d.ts +0 -1
- package/dist/types/tts/tts-client.d.ts +1 -1
- package/dist/types/utils/thinking-display.d.ts +1 -17
- package/package.json +13 -13
- package/src/advisor/__tests__/advisor.test.ts +586 -0
- package/src/advisor/advise-tool.ts +87 -0
- package/src/advisor/index.ts +3 -0
- package/src/advisor/runtime.ts +248 -0
- package/src/advisor/watchdog.ts +83 -0
- package/src/cli.ts +25 -12
- package/src/config/model-registry.ts +6 -2
- package/src/config/model-roles.ts +13 -1
- package/src/config/settings-schema.ts +67 -5
- package/src/eval/__tests__/agent-bridge.test.ts +106 -46
- package/src/eval/__tests__/js-context-manager.test.ts +12 -2
- package/src/eval/js/context-manager.ts +40 -3
- package/src/eval/js/worker-entry.ts +7 -0
- package/src/export/html/template.js +18 -22
- package/src/internal-urls/docs-index.generated.ts +8 -5
- package/src/main.ts +19 -5
- package/src/modes/acp/acp-agent.ts +2 -2
- package/src/modes/acp/acp-event-mapper.ts +2 -2
- package/src/modes/components/advisor-message.ts +99 -0
- package/src/modes/components/agent-hub.ts +38 -7
- package/src/modes/components/assistant-message.ts +110 -15
- package/src/modes/components/snapcompact-shape-preview-doc.md +2 -2
- package/src/modes/components/snapcompact-shape-preview.ts +2 -2
- package/src/modes/components/status-line/segments.ts +20 -7
- package/src/modes/components/tree-selector.ts +3 -2
- package/src/modes/controllers/command-controller.ts +69 -2
- package/src/modes/controllers/event-controller.ts +3 -3
- package/src/modes/controllers/input-controller.ts +7 -1
- package/src/modes/controllers/streaming-reveal.ts +4 -4
- package/src/modes/interactive-mode.ts +14 -2
- package/src/modes/types.ts +9 -1
- package/src/modes/utils/ui-helpers.ts +12 -3
- package/src/prompts/advisor/advise-tool.md +1 -0
- package/src/prompts/advisor/system.md +31 -0
- package/src/prompts/agents/oracle.md +0 -1
- package/src/prompts/agents/reviewer.md +0 -1
- package/src/prompts/system/unexpected-stop-classifier.md +17 -0
- package/src/prompts/system/unexpected-stop-retry.md +4 -0
- package/src/sdk.ts +52 -13
- package/src/session/agent-session.ts +722 -21
- package/src/session/session-dump-format.ts +15 -142
- package/src/session/session-history-format.ts +30 -11
- package/src/session/unexpected-stop-classifier.ts +129 -0
- package/src/session/yield-queue.ts +5 -1
- package/src/slash-commands/builtin-registry.ts +102 -4
- package/src/stt/asr-client.ts +1 -1
- package/src/system-prompt.ts +1 -1
- package/src/tiny/title-client.ts +1 -1
- package/src/tools/browser/tab-supervisor.ts +1 -1
- package/src/tools/browser/tab-worker-entry.ts +12 -4
- package/src/tools/job.ts +1 -0
- package/src/tools/path-utils.ts +33 -2
- package/src/tools/report-tool-issue.ts +2 -7
- package/src/tts/tts-client.ts +1 -1
- package/src/utils/thinking-display.ts +8 -34
- package/src/web/scrapers/docs-rs.ts +2 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core";
|
|
2
|
+
import { z } from "zod/v4";
|
|
3
|
+
declare const adviseSchema: z.ZodObject<{
|
|
4
|
+
note: z.ZodString;
|
|
5
|
+
severity: z.ZodOptional<z.ZodEnum<{
|
|
6
|
+
blocker: "blocker";
|
|
7
|
+
concern: "concern";
|
|
8
|
+
nit: "nit";
|
|
9
|
+
}>>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
export type AdviseParams = z.infer<typeof adviseSchema>;
|
|
12
|
+
export type AdvisorSeverity = "nit" | "concern" | "blocker";
|
|
13
|
+
export interface AdviseDetails {
|
|
14
|
+
note: string;
|
|
15
|
+
severity?: AdvisorSeverity;
|
|
16
|
+
}
|
|
17
|
+
/** One queued advice note. */
|
|
18
|
+
export interface AdvisorNote {
|
|
19
|
+
note: string;
|
|
20
|
+
severity?: AdvisorSeverity;
|
|
21
|
+
}
|
|
22
|
+
/** Details payload on the batched `advisor` custom message rendered in the transcript. */
|
|
23
|
+
export interface AdvisorMessageDetails {
|
|
24
|
+
notes: AdvisorNote[];
|
|
25
|
+
}
|
|
26
|
+
/** Render one advisor card body from a batch of notes (prefix + one bullet per note). */
|
|
27
|
+
export declare function formatAdvisorBatchContent(notes: readonly AdvisorNote[]): string;
|
|
28
|
+
/**
|
|
29
|
+
* Whether advice at this severity should interrupt the running agent (delivered
|
|
30
|
+
* via the steering channel, aborting in-flight tools) rather than ride the
|
|
31
|
+
* non-interrupting aside queue that lands at the next step boundary. `concern`
|
|
32
|
+
* and `blocker` interrupt; a plain `nit` queues.
|
|
33
|
+
*/
|
|
34
|
+
export declare function isInterruptingSeverity(severity: AdvisorSeverity | undefined): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Side-effect-free investigation tools handed to the advisor agent so it can
|
|
37
|
+
* inspect the workspace before weighing in. Names match the primary session's
|
|
38
|
+
* tool instances, which the advisor reuses.
|
|
39
|
+
*/
|
|
40
|
+
export declare const ADVISOR_READONLY_TOOL_NAMES: ReadonlySet<string>;
|
|
41
|
+
export declare class AdviseTool implements AgentTool<typeof adviseSchema, AdviseDetails> {
|
|
42
|
+
private readonly onAdvice;
|
|
43
|
+
readonly name = "advise";
|
|
44
|
+
readonly label = "Advise";
|
|
45
|
+
readonly description: string;
|
|
46
|
+
readonly parameters: z.ZodObject<{
|
|
47
|
+
note: z.ZodString;
|
|
48
|
+
severity: z.ZodOptional<z.ZodEnum<{
|
|
49
|
+
blocker: "blocker";
|
|
50
|
+
concern: "concern";
|
|
51
|
+
nit: "nit";
|
|
52
|
+
}>>;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
readonly intent: "omit";
|
|
55
|
+
constructor(onAdvice: (note: string, severity?: AdviseDetails["severity"]) => void);
|
|
56
|
+
execute(_toolCallId: string, args: AdviseParams, _signal?: AbortSignal, _onUpdate?: AgentToolUpdateCallback<AdviseDetails>, _context?: AgentToolContext): Promise<AgentToolResult<AdviseDetails>>;
|
|
57
|
+
}
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { AgentMessage } from "@oh-my-pi/pi-agent-core";
|
|
2
|
+
/** Minimal slice of `Agent` the runtime drives — satisfied by pi-agent-core `Agent`. */
|
|
3
|
+
export interface AdvisorAgent {
|
|
4
|
+
prompt(input: string): Promise<void>;
|
|
5
|
+
abort(reason?: unknown): void;
|
|
6
|
+
reset(): void;
|
|
7
|
+
readonly state: {
|
|
8
|
+
messages: AgentMessage[];
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export interface AdvisorRuntimeHost {
|
|
12
|
+
/** Live primary transcript (use `agent.state.messages`). */
|
|
13
|
+
snapshotMessages(): AgentMessage[];
|
|
14
|
+
/** Surface one advice note to the primary (enqueues into the session YieldQueue). */
|
|
15
|
+
enqueueAdvice(note: string, severity?: "nit" | "concern" | "blocker"): void;
|
|
16
|
+
/**
|
|
17
|
+
* Pre-prompt context maintenance for the advisor's own append-only context.
|
|
18
|
+
* Promotes the advisor model to a larger sibling when its context nears the
|
|
19
|
+
* window (mirroring the primary's promote-first policy) and resolves `true`
|
|
20
|
+
* when the advisor should re-prime — reset and replay the current
|
|
21
|
+
* primary-bounded transcript — because promotion did not free enough room.
|
|
22
|
+
* Optional: hosts that omit it get no maintenance (context only shrinks when
|
|
23
|
+
* the primary's next compaction triggers {@link AdvisorRuntime.reset}).
|
|
24
|
+
*/
|
|
25
|
+
maintainContext?(incomingTokens: number): Promise<boolean>;
|
|
26
|
+
}
|
|
27
|
+
export declare class AdvisorRuntime {
|
|
28
|
+
#private;
|
|
29
|
+
private readonly agent;
|
|
30
|
+
private readonly host;
|
|
31
|
+
private readonly retryDelayMs;
|
|
32
|
+
disposed: boolean;
|
|
33
|
+
constructor(agent: AdvisorAgent, host: AdvisorRuntimeHost, retryDelayMs?: number);
|
|
34
|
+
get backlog(): number;
|
|
35
|
+
onTurnEnd(messages?: AgentMessage[]): void;
|
|
36
|
+
waitForCatchup(maxMs: number, threshold: number, signal?: AbortSignal): Promise<void>;
|
|
37
|
+
dispose(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Re-prime the advisor after a history rewrite (compaction, session
|
|
40
|
+
* switch/resume, branch). Clears the advisor's own (non-persisted) context
|
|
41
|
+
* and rewinds the cursor to 0 so the NEXT turn replays the full current —
|
|
42
|
+
* post-compaction — transcript, giving the advisor fresh context instead of
|
|
43
|
+
* leaving it blind to everything before the rewrite.
|
|
44
|
+
*/
|
|
45
|
+
reset(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Seed the cursor to the current transcript length when the advisor is enabled
|
|
48
|
+
* mid-session. Prevents the next turn from replaying the entire history to the
|
|
49
|
+
* advisor (which would be expensive and likely stale).
|
|
50
|
+
*/
|
|
51
|
+
seedTo(count: number): void;
|
|
52
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discover and load WATCHDOG.md files walking up from cwd, project .omp folder, and user agent dir.
|
|
3
|
+
* Returns formatted watchdog file blocks ready to be appended to the advisor system prompt.
|
|
4
|
+
*/
|
|
5
|
+
export declare function discoverWatchdogFiles(cwd: string, agentDir?: string): Promise<string[]>;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { type ThemeColor } from "../modes/theme/theme";
|
|
5
5
|
import type { Settings } from "./settings";
|
|
6
|
-
export type ModelRole = "default" | "smol" | "slow" | "vision" | "plan" | "designer" | "commit" | "title" | "task";
|
|
6
|
+
export type ModelRole = "default" | "smol" | "slow" | "vision" | "plan" | "designer" | "commit" | "title" | "task" | "advisor";
|
|
7
7
|
export interface ModelRoleInfo {
|
|
8
8
|
tag?: string;
|
|
9
9
|
name: string;
|
|
@@ -177,6 +177,37 @@ export declare const SETTINGS_SCHEMA: {
|
|
|
177
177
|
readonly description: "Keep the display from idle-sleeping while a session is open (caffeinate -d)";
|
|
178
178
|
};
|
|
179
179
|
};
|
|
180
|
+
readonly "advisor.enabled": {
|
|
181
|
+
readonly type: "boolean";
|
|
182
|
+
readonly default: false;
|
|
183
|
+
readonly ui: {
|
|
184
|
+
readonly tab: "model";
|
|
185
|
+
readonly group: "Advisor";
|
|
186
|
+
readonly label: "Enable Advisor";
|
|
187
|
+
readonly description: "Pair a second model (assigned to the 'advisor' role) that passively reviews each turn and injects notes.";
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
readonly "advisor.subagents": {
|
|
191
|
+
readonly type: "boolean";
|
|
192
|
+
readonly default: false;
|
|
193
|
+
readonly ui: {
|
|
194
|
+
readonly tab: "model";
|
|
195
|
+
readonly group: "Advisor";
|
|
196
|
+
readonly label: "Advisor for Subagents";
|
|
197
|
+
readonly description: "Also enable the advisor on spawned task/eval subagents.";
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
readonly "advisor.syncBacklog": {
|
|
201
|
+
readonly type: "enum";
|
|
202
|
+
readonly values: readonly ["off", "1", "3", "5"];
|
|
203
|
+
readonly default: "off";
|
|
204
|
+
readonly ui: {
|
|
205
|
+
readonly tab: "model";
|
|
206
|
+
readonly group: "Advisor";
|
|
207
|
+
readonly label: "Advisor Sync Backlog";
|
|
208
|
+
readonly description: "Pause the main agent for up to 30 seconds if the advisor falls behind by this many turns. Off disables catch-up delays.";
|
|
209
|
+
};
|
|
210
|
+
};
|
|
180
211
|
readonly shellPath: {
|
|
181
212
|
readonly type: "string";
|
|
182
213
|
readonly default: undefined;
|
|
@@ -1843,13 +1874,13 @@ export declare const SETTINGS_SCHEMA: {
|
|
|
1843
1874
|
};
|
|
1844
1875
|
readonly "tools.format": {
|
|
1845
1876
|
readonly type: "enum";
|
|
1846
|
-
readonly values: readonly ["auto", "native", "glm", "hermes", "kimi", "xml", "anthropic", "deepseek", "harmony", "pi", "qwen3"];
|
|
1877
|
+
readonly values: readonly ["auto", "native", "glm", "hermes", "kimi", "xml", "anthropic", "deepseek", "harmony", "pi", "qwen3", "gemini", "gemma"];
|
|
1847
1878
|
readonly default: "auto";
|
|
1848
1879
|
readonly ui: {
|
|
1849
1880
|
readonly tab: "context";
|
|
1850
1881
|
readonly group: "Experimental";
|
|
1851
|
-
readonly label: "Tool
|
|
1852
|
-
readonly description: "Controls how tools are exposed to the model. Auto uses native tool calls unless the selected model is marked as not supporting
|
|
1882
|
+
readonly label: "Tool Calling Mode";
|
|
1883
|
+
readonly description: "Controls how tools are exposed to the model. Auto uses provider-native tool calls unless the selected model is marked as not supporting them, then falls back to the GLM owned dialect. Native forces provider-native tools; the other values force the named owned dialect. Applies on session start.";
|
|
1853
1884
|
readonly options: readonly [{
|
|
1854
1885
|
readonly value: "auto";
|
|
1855
1886
|
readonly label: "Auto";
|
|
@@ -1889,11 +1920,19 @@ export declare const SETTINGS_SCHEMA: {
|
|
|
1889
1920
|
}, {
|
|
1890
1921
|
readonly value: "pi";
|
|
1891
1922
|
readonly label: "Pi";
|
|
1892
|
-
readonly description: "Use Pi
|
|
1923
|
+
readonly description: "Use the Pi owned dialect.";
|
|
1893
1924
|
}, {
|
|
1894
1925
|
readonly value: "qwen3";
|
|
1895
1926
|
readonly label: "Qwen3";
|
|
1896
|
-
readonly description: "Use Qwen3
|
|
1927
|
+
readonly description: "Use the Qwen3 owned dialect.";
|
|
1928
|
+
}, {
|
|
1929
|
+
readonly value: "gemini";
|
|
1930
|
+
readonly label: "Gemini";
|
|
1931
|
+
readonly description: "Use the Gemini owned dialect.";
|
|
1932
|
+
}, {
|
|
1933
|
+
readonly value: "gemma";
|
|
1934
|
+
readonly label: "Gemma";
|
|
1935
|
+
readonly description: "Use the Gemma owned dialect.";
|
|
1897
1936
|
}];
|
|
1898
1937
|
};
|
|
1899
1938
|
};
|
|
@@ -4416,6 +4455,37 @@ export declare const SETTINGS_SCHEMA: {
|
|
|
4416
4455
|
})[];
|
|
4417
4456
|
};
|
|
4418
4457
|
};
|
|
4458
|
+
readonly "features.unexpectedStopDetection": {
|
|
4459
|
+
readonly type: "boolean";
|
|
4460
|
+
readonly default: false;
|
|
4461
|
+
readonly ui: {
|
|
4462
|
+
readonly tab: "interaction";
|
|
4463
|
+
readonly group: "Agent";
|
|
4464
|
+
readonly label: "Detect unexpected stops";
|
|
4465
|
+
readonly description: "Use a small model to detect when the assistant says it will continue but stops without tool calls; automatically prompt it to continue.";
|
|
4466
|
+
};
|
|
4467
|
+
};
|
|
4468
|
+
readonly "providers.unexpectedStopModel": {
|
|
4469
|
+
readonly type: "enum";
|
|
4470
|
+
readonly values: readonly ["online", "qwen3-1.7b", "gemma-3-1b", "qwen2.5-1.5b", "lfm2-1.2b"];
|
|
4471
|
+
readonly default: "online";
|
|
4472
|
+
readonly ui: {
|
|
4473
|
+
readonly tab: "providers";
|
|
4474
|
+
readonly group: "Tiny Model";
|
|
4475
|
+
readonly label: "Unexpected Stop Model";
|
|
4476
|
+
readonly description: "Classifier for unexpected-stop detection: online smol by default, or a local on-device model.";
|
|
4477
|
+
readonly condition: "unexpectedStopDetection";
|
|
4478
|
+
readonly options: ({
|
|
4479
|
+
value: "online";
|
|
4480
|
+
label: string;
|
|
4481
|
+
description: string;
|
|
4482
|
+
} | {
|
|
4483
|
+
value: "gemma-3-1b" | "lfm2-1.2b" | "qwen2.5-1.5b" | "qwen3-1.7b";
|
|
4484
|
+
label: "Gemma 3 1B" | "LFM2 1.2B" | "Qwen2.5 1.5B" | "Qwen3 1.7B";
|
|
4485
|
+
description: "Best consolidation/dedup; lighter footprint, but leaks small talk during extraction." | "Best extraction granularity (atomic facts); weaker consolidation." | "Fastest load; solid all-rounder, slightly noisier extraction labels." | "Recommended; most disciplined extraction (ignores chit-chat), good consolidation, about 1.1 GB cached.";
|
|
4486
|
+
})[];
|
|
4487
|
+
};
|
|
4488
|
+
};
|
|
4419
4489
|
readonly "providers.kimiApiFormat": {
|
|
4420
4490
|
readonly type: "enum";
|
|
4421
4491
|
readonly values: readonly ["openai", "anthropic"];
|
|
@@ -7,6 +7,12 @@ export interface VmRunState {
|
|
|
7
7
|
onText?: (chunk: string) => void;
|
|
8
8
|
onDisplay?: (output: JsDisplayOutput) => void;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Test-only seam: override the graceful-close grace period (ms). Returns the
|
|
12
|
+
* previous value so callers can restore it. Production always uses
|
|
13
|
+
* {@link WORKER_CLOSE_TIMEOUT_MS}; never call this outside tests.
|
|
14
|
+
*/
|
|
15
|
+
export declare function setWorkerCloseTimeoutMsForTests(ms: number): number;
|
|
10
16
|
export declare function executeInVmContext(options: {
|
|
11
17
|
sessionKey: string;
|
|
12
18
|
sessionId: string;
|
|
@@ -23,3 +29,12 @@ export declare function executeInVmContext(options: {
|
|
|
23
29
|
}>;
|
|
24
30
|
export declare function resetVmContext(sessionKey: string): Promise<void>;
|
|
25
31
|
export declare function disposeAllVmContexts(): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Smoke probe: spawn the JS eval worker through the worker-host entry and prove
|
|
34
|
+
* it answers the `init` handshake on a real worker thread (not the inline
|
|
35
|
+
* fallback). Catches the silent worker-load and init-message-drop regressions
|
|
36
|
+
* that otherwise strand every cell on the init timeout in a distribution build —
|
|
37
|
+
* the failure mode that motivated `installWorkerInbox`. Wired into
|
|
38
|
+
* `omp --smoke-test` so binary / source / tarball installs all exercise it.
|
|
39
|
+
*/
|
|
40
|
+
export declare function smokeTestJsEvalWorker(): Promise<void>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Component } from "@oh-my-pi/pi-tui";
|
|
2
|
+
import type { AdvisorMessageDetails } from "../../advisor";
|
|
3
|
+
import type { Theme } from "../theme/theme";
|
|
4
|
+
/**
|
|
5
|
+
* Display-only transcript card for advisor notes injected into the primary
|
|
6
|
+
* session. Mirrors the IRC card's glyph + quote-border conventions so passive
|
|
7
|
+
* advice reads as a distinct, non-interrupting aside rather than a user turn.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createAdvisorMessageCard(details: AdvisorMessageDetails | undefined, getExpanded: () => boolean, uiTheme: Theme): Component;
|
|
@@ -13,6 +13,7 @@ export declare class AssistantMessageComponent extends Container {
|
|
|
13
13
|
constructor(message?: AssistantMessage, hideThinkingBlock?: boolean, onImageUpdate?: (() => void) | undefined, thinkingRenderers?: readonly AssistantThinkingRenderer[], imageBudget?: ImageBudget | undefined);
|
|
14
14
|
invalidate(): void;
|
|
15
15
|
setHideThinkingBlock(hide: boolean): void;
|
|
16
|
+
dispose(): void;
|
|
16
17
|
/**
|
|
17
18
|
* Toggle suppression of the inline `Error: …` line while the same error is
|
|
18
19
|
* pinned in the banner above the editor. Re-renders so the change is visible.
|
|
@@ -10,10 +10,12 @@ export declare class CommandController {
|
|
|
10
10
|
constructor(ctx: InteractiveModeContext);
|
|
11
11
|
openInBrowser(urlOrPath: string): void;
|
|
12
12
|
handleExportCommand(text: string): Promise<void>;
|
|
13
|
-
handleDumpCommand(): void;
|
|
13
|
+
handleDumpCommand(isRaw?: boolean): void;
|
|
14
|
+
handleAdvisorDumpCommand(isRaw?: boolean): void;
|
|
14
15
|
handleDebugTranscriptCommand(): Promise<void>;
|
|
15
16
|
handleShareCommand(): Promise<void>;
|
|
16
17
|
handleSessionCommand(): Promise<void>;
|
|
18
|
+
handleAdvisorStatusCommand(): Promise<void>;
|
|
17
19
|
handleJobsCommand(): Promise<void>;
|
|
18
20
|
handleUsageCommand(reports?: UsageReport[] | null): Promise<void>;
|
|
19
21
|
handleChangelogCommand(showFull?: boolean): Promise<void>;
|
|
@@ -186,6 +186,7 @@ export declare class InteractiveMode implements InteractiveModeContext {
|
|
|
186
186
|
imageLinks?: (string | undefined)[];
|
|
187
187
|
customType?: string;
|
|
188
188
|
display?: boolean;
|
|
189
|
+
streamingBehavior?: "steer" | "followUp";
|
|
189
190
|
}): SubmittedUserInput;
|
|
190
191
|
cancelPendingSubmission(): boolean;
|
|
191
192
|
markPendingSubmissionStarted(input: SubmittedUserInput): boolean;
|
|
@@ -267,11 +268,13 @@ export declare class InteractiveMode implements InteractiveModeContext {
|
|
|
267
268
|
findLastAssistantMessage(): AssistantMessage | undefined;
|
|
268
269
|
extractAssistantText(message: AssistantMessage): string;
|
|
269
270
|
handleExportCommand(text: string): Promise<void>;
|
|
270
|
-
handleDumpCommand(): void;
|
|
271
|
+
handleDumpCommand(isRaw?: boolean): void;
|
|
272
|
+
handleAdvisorDumpCommand(isRaw?: boolean): void;
|
|
271
273
|
handleDebugTranscriptCommand(): Promise<void>;
|
|
272
274
|
handleShareCommand(): Promise<void>;
|
|
273
275
|
handleTodoCommand(args: string): Promise<void>;
|
|
274
276
|
handleSessionCommand(): Promise<void>;
|
|
277
|
+
handleAdvisorStatusCommand(): Promise<void>;
|
|
275
278
|
handleJobsCommand(): Promise<void>;
|
|
276
279
|
handleUsageCommand(reports?: UsageReport[] | null): Promise<void>;
|
|
277
280
|
handleChangelogCommand(showFull?: boolean): Promise<void>;
|
|
@@ -46,6 +46,11 @@ export type SubmittedUserInput = {
|
|
|
46
46
|
* turn. Used by the `c`/`.` continue shortcut. */
|
|
47
47
|
synthetic?: boolean;
|
|
48
48
|
display?: boolean;
|
|
49
|
+
/** Queue intent if the session is (or becomes) busy when this submission is
|
|
50
|
+
* dispatched: "steer" (interrupt the active turn) or "followUp" (process after
|
|
51
|
+
* it). Normal user Enter carries "steer" to match the streaming-branch Enter;
|
|
52
|
+
* background/continuation submits omit it and default to "followUp". */
|
|
53
|
+
streamingBehavior?: "steer" | "followUp";
|
|
49
54
|
cancelled: boolean;
|
|
50
55
|
started: boolean;
|
|
51
56
|
};
|
|
@@ -199,6 +204,7 @@ export interface InteractiveModeContext {
|
|
|
199
204
|
imageLinks?: (string | undefined)[];
|
|
200
205
|
customType?: string;
|
|
201
206
|
display?: boolean;
|
|
207
|
+
streamingBehavior?: "steer" | "followUp";
|
|
202
208
|
}): SubmittedUserInput;
|
|
203
209
|
cancelPendingSubmission(): boolean;
|
|
204
210
|
markPendingSubmissionStarted(input: SubmittedUserInput): boolean;
|
|
@@ -244,13 +250,15 @@ export interface InteractiveModeContext {
|
|
|
244
250
|
handleShareCommand(): Promise<void>;
|
|
245
251
|
handleTodoCommand(args: string): Promise<void>;
|
|
246
252
|
handleSessionCommand(): Promise<void>;
|
|
253
|
+
handleAdvisorStatusCommand(): Promise<void>;
|
|
247
254
|
handleJobsCommand(): Promise<void>;
|
|
248
255
|
handleUsageCommand(reports?: UsageReport[] | null): Promise<void>;
|
|
249
256
|
handleChangelogCommand(showFull?: boolean): Promise<void>;
|
|
250
257
|
handleHotkeysCommand(): void;
|
|
251
258
|
handleToolsCommand(): void;
|
|
252
259
|
handleContextCommand(): void;
|
|
253
|
-
handleDumpCommand(): void;
|
|
260
|
+
handleDumpCommand(isRaw?: boolean): void;
|
|
261
|
+
handleAdvisorDumpCommand(isRaw?: boolean): void;
|
|
254
262
|
handleDebugTranscriptCommand(): Promise<void>;
|
|
255
263
|
handleClearCommand(): Promise<void>;
|
|
256
264
|
handleFreshCommand(): Promise<void>;
|
package/dist/types/sdk.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type AgentTelemetryConfig, type ThinkingLevel } from "@oh-my-pi/pi-agent-core";
|
|
2
2
|
import { type Model } from "@oh-my-pi/pi-ai";
|
|
3
|
-
import type {
|
|
3
|
+
import type { Dialect } from "@oh-my-pi/pi-ai/dialect";
|
|
4
4
|
import { type Rule } from "./capability/rule";
|
|
5
5
|
import { ModelRegistry } from "./config/model-registry";
|
|
6
6
|
import { type PromptTemplate } from "./config/prompt-templates";
|
|
@@ -184,8 +184,8 @@ export interface CreateAgentSessionResult {
|
|
|
184
184
|
/** Shared event bus for tool/extension communication */
|
|
185
185
|
eventBus: EventBus;
|
|
186
186
|
}
|
|
187
|
-
export type
|
|
188
|
-
export declare function
|
|
187
|
+
export type DialectFormat = "auto" | "native" | Dialect;
|
|
188
|
+
export declare function resolveDialect(format: DialectFormat, model: Pick<Model, "supportsTools"> | undefined): Dialect | undefined;
|
|
189
189
|
export type { PromptTemplate } from "./config/prompt-templates";
|
|
190
190
|
export { Settings, type SkillsSettings } from "./config/settings";
|
|
191
191
|
export type { CustomCommand, CustomCommandFactory } from "./extensibility/custom-commands/types";
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* Modes use this class and add their own I/O layer on top.
|
|
14
14
|
*/
|
|
15
15
|
import type { InMemorySnapshotStore } from "@oh-my-pi/hashline";
|
|
16
|
-
import {
|
|
16
|
+
import { Agent, type AgentEvent, type AgentMessage, type AgentState, type AgentTool, ThinkingLevel } from "@oh-my-pi/pi-agent-core";
|
|
17
17
|
import { type CompactionResult, type ShakeConfig } from "@oh-my-pi/pi-agent-core/compaction";
|
|
18
18
|
import type { AssistantMessage, ImageContent, Message, MessageAttribution, Model, ProviderSessionState, ResetCreditAccountStatus, ResetCreditRedeemOutcome, ResetCreditTarget, ServiceTier, SimpleStreamOptions, TextContent, ToolChoice, UsageReport } from "@oh-my-pi/pi-ai";
|
|
19
19
|
import { Effort } from "@oh-my-pi/pi-ai";
|
|
@@ -228,6 +228,15 @@ export interface AgentSessionConfig {
|
|
|
228
228
|
* so that credential sticky selection is consistent with the session's streaming calls.
|
|
229
229
|
*/
|
|
230
230
|
providerSessionId?: string;
|
|
231
|
+
/**
|
|
232
|
+
* Hard-isolated read-only tools (read/search/find) for the advisor agent,
|
|
233
|
+
* pre-built in `createAgentSession` against a distinct `ToolSession` so the
|
|
234
|
+
* advisor's reads never share the primary's snapshot/seen-lines/conflict
|
|
235
|
+
* caches. Undefined when the advisor is disabled.
|
|
236
|
+
*/
|
|
237
|
+
advisorReadOnlyTools?: AgentTool[];
|
|
238
|
+
/** Preloaded watchdog prompt content for the advisor. */
|
|
239
|
+
advisorWatchdogPrompt?: string;
|
|
231
240
|
}
|
|
232
241
|
/** Options for AgentSession.prompt() */
|
|
233
242
|
export interface PromptOptions {
|
|
@@ -301,6 +310,27 @@ export interface SessionStats {
|
|
|
301
310
|
premiumRequests: number;
|
|
302
311
|
cost: number;
|
|
303
312
|
}
|
|
313
|
+
/** Advisor statistics for /advisor status command. */
|
|
314
|
+
export interface AdvisorStats {
|
|
315
|
+
configured: boolean;
|
|
316
|
+
active: boolean;
|
|
317
|
+
model?: Model;
|
|
318
|
+
contextWindow: number;
|
|
319
|
+
contextTokens: number;
|
|
320
|
+
tokens: {
|
|
321
|
+
input: number;
|
|
322
|
+
output: number;
|
|
323
|
+
cacheRead: number;
|
|
324
|
+
cacheWrite: number;
|
|
325
|
+
total: number;
|
|
326
|
+
};
|
|
327
|
+
cost: number;
|
|
328
|
+
messages: {
|
|
329
|
+
user: number;
|
|
330
|
+
assistant: number;
|
|
331
|
+
total: number;
|
|
332
|
+
};
|
|
333
|
+
}
|
|
304
334
|
export interface FreshSessionResult {
|
|
305
335
|
previousSessionId: string;
|
|
306
336
|
sessionId: string;
|
|
@@ -1095,7 +1125,46 @@ export declare class AgentSession {
|
|
|
1095
1125
|
* Format the entire session as plain text for clipboard export.
|
|
1096
1126
|
* Includes user messages, assistant text, thinking blocks, tool calls, and tool results.
|
|
1097
1127
|
*/
|
|
1098
|
-
formatSessionAsText(
|
|
1128
|
+
formatSessionAsText(options?: {
|
|
1129
|
+
compact?: boolean;
|
|
1130
|
+
}): string;
|
|
1131
|
+
/**
|
|
1132
|
+
* Enable or disable the advisor for this session. The setting is persisted,
|
|
1133
|
+
* and the runtime is started or stopped to match.
|
|
1134
|
+
*
|
|
1135
|
+
* @returns true when the advisor is actively running after the call.
|
|
1136
|
+
*/
|
|
1137
|
+
setAdvisorEnabled(enabled: boolean): boolean;
|
|
1138
|
+
/**
|
|
1139
|
+
* Toggle the advisor setting and start/stop the runtime accordingly.
|
|
1140
|
+
*
|
|
1141
|
+
* @returns true when the advisor is actively running after the call.
|
|
1142
|
+
*/
|
|
1143
|
+
toggleAdvisorEnabled(): boolean;
|
|
1144
|
+
/**
|
|
1145
|
+
* Whether a live advisor agent is attached to this session. True only when
|
|
1146
|
+
* `advisor.enabled` is set AND a model resolved for the `advisor` role AND
|
|
1147
|
+
* the advisor applies to this agent kind — i.e. the actual runtime exists,
|
|
1148
|
+
* not merely the setting. Drives the status-line badge and `/dump advisor`.
|
|
1149
|
+
*/
|
|
1150
|
+
isAdvisorActive(): boolean;
|
|
1151
|
+
/**
|
|
1152
|
+
* Return structured advisor stats for the status command and TUI panel.
|
|
1153
|
+
*/
|
|
1154
|
+
getAdvisorStats(): AdvisorStats;
|
|
1155
|
+
/**
|
|
1156
|
+
* Format a concise advisor status line for ACP/text output.
|
|
1157
|
+
*/
|
|
1158
|
+
formatAdvisorStatus(): string;
|
|
1159
|
+
/**
|
|
1160
|
+
* Format the advisor agent's own transcript (its system prompt, config,
|
|
1161
|
+
* tools, and the markdown deltas it received plus its thinking/advise/read
|
|
1162
|
+
* calls) as plain text — the advisor-side equivalent of
|
|
1163
|
+
* {@link formatSessionAsText}. Returns null when no advisor is active.
|
|
1164
|
+
*/
|
|
1165
|
+
formatAdvisorHistoryAsText(options?: {
|
|
1166
|
+
compact?: boolean;
|
|
1167
|
+
}): string | null;
|
|
1099
1168
|
/**
|
|
1100
1169
|
* Check if extensions have handlers for a specific event type.
|
|
1101
1170
|
*/
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export interface HistoryFormatOptions {
|
|
2
2
|
/** Optional H1 prepended to the transcript. */
|
|
3
3
|
title?: string;
|
|
4
|
+
/** Render assistant thinking blocks (default: elided). */
|
|
5
|
+
includeThinking?: boolean;
|
|
6
|
+
/** Render tool intent comment before tool call lines. */
|
|
7
|
+
includeToolIntent?: boolean;
|
|
4
8
|
}
|
|
5
9
|
/**
|
|
6
10
|
* Format a session's message array as a concise markdown transcript.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type AssistantMessage } from "@oh-my-pi/pi-ai";
|
|
2
|
+
import type { ModelRegistry } from "../config/model-registry";
|
|
3
|
+
import type { Settings } from "../config/settings";
|
|
4
|
+
export interface ClassifyUnexpectedStopDeps {
|
|
5
|
+
settings: Settings;
|
|
6
|
+
registry: ModelRegistry;
|
|
7
|
+
sessionId: string;
|
|
8
|
+
metadataResolver?: (provider: string) => Record<string, unknown> | undefined;
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
}
|
|
11
|
+
export declare function isUnexpectedStopCandidate(message: AssistantMessage): boolean;
|
|
12
|
+
export declare function classifyUnexpectedStop(text: string, deps: ClassifyUnexpectedStopDeps): Promise<boolean | undefined>;
|
|
13
|
+
export declare function parseUnexpectedStopClassification(text: string): boolean | undefined;
|
|
@@ -4,6 +4,8 @@ export interface YieldDispatcher<P> {
|
|
|
4
4
|
isStale?(entry: P): boolean;
|
|
5
5
|
/** Produce one batched AgentMessage from non-stale entries. Return null to skip. */
|
|
6
6
|
build(survivors: P[]): AgentMessage | null;
|
|
7
|
+
/** If true, entries for this kind are drained only by {@link drainLazy} and never trigger the idle flush. */
|
|
8
|
+
skipIdleFlush?: boolean;
|
|
7
9
|
}
|
|
8
10
|
export interface YieldQueueOptions {
|
|
9
11
|
isStreaming: () => boolean;
|
|
@@ -43,7 +43,7 @@ export interface SttStreamOptions {
|
|
|
43
43
|
* Hidden subcommand on the main CLI that boots the speech-recognition worker in
|
|
44
44
|
* the spawned subprocess. Kept in sync with the dispatch in `cli.ts`.
|
|
45
45
|
*/
|
|
46
|
-
export declare const STT_WORKER_ARG = "
|
|
46
|
+
export declare const STT_WORKER_ARG = "__omp_worker_stt";
|
|
47
47
|
interface SpawnedSubprocess {
|
|
48
48
|
proc: Subprocess<"ignore", "ignore", "ignore">;
|
|
49
49
|
inbound: Set<(message: SttWorkerOutbound) => void>;
|
|
@@ -32,7 +32,7 @@ export interface TinyTitleGenerateOptions {
|
|
|
32
32
|
* Hidden subcommand on the main CLI that boots the tiny-model worker in the
|
|
33
33
|
* spawned subprocess. Kept in sync with the dispatch in `cli.ts`.
|
|
34
34
|
*/
|
|
35
|
-
export declare const TINY_WORKER_ARG = "
|
|
35
|
+
export declare const TINY_WORKER_ARG = "__omp_worker_tiny_inference";
|
|
36
36
|
/**
|
|
37
37
|
* Decide which `PI_TINY_DEVICE` / `PI_TINY_DTYPE` vars to overlay onto the worker
|
|
38
38
|
* env. A present env var wins (left untouched); otherwise the mapped persisted
|
|
@@ -48,6 +48,7 @@ export declare class JobTool implements AgentTool<typeof jobSchema, JobToolDetai
|
|
|
48
48
|
list: z.ZodOptional<z.ZodBoolean>;
|
|
49
49
|
}, z.core.$strip>;
|
|
50
50
|
readonly strict = true;
|
|
51
|
+
readonly interruptible = true;
|
|
51
52
|
readonly loadMode = "discoverable";
|
|
52
53
|
constructor(session: ToolSession);
|
|
53
54
|
execute(_toolCallId: string, params: JobParams, signal?: AbortSignal, onUpdate?: AgentToolUpdateCallback<JobToolDetails>, _context?: AgentToolContext): Promise<AgentToolResult<JobToolDetails>>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type LocalProtocolOptions } from "../internal-urls";
|
|
2
2
|
export declare function expandTilde(filePath: string, home?: string): string;
|
|
3
3
|
export declare function expandPath(filePath: string): string;
|
|
4
|
+
export declare function normalizeWindowsDriveAliasPath(filePath: string, platform?: NodeJS.Platform): string;
|
|
4
5
|
/**
|
|
5
6
|
* Inclusive line range describing one selector segment (e.g. `50-100`,
|
|
6
7
|
* `301-`, or `50+10`). `endLine` is `undefined` for open-ended ranges.
|
|
@@ -66,7 +66,6 @@ export declare function __resetAutoQaConsentForTests(): void;
|
|
|
66
66
|
* permanently locked into the false branch.
|
|
67
67
|
*/
|
|
68
68
|
export declare function resolveAutoQaConsent(settings: Settings | undefined): Promise<boolean>;
|
|
69
|
-
export declare function getAutoQaDbPath(): string;
|
|
70
69
|
/**
|
|
71
70
|
* Open (or return the cached handle for) the auto-QA SQLite database at
|
|
72
71
|
* `~/.omp/agent/autoqa.db`. Idempotently runs schema creation, the
|
|
@@ -54,7 +54,7 @@ export interface TtsStreamHandle {
|
|
|
54
54
|
* Hidden subcommand on the main CLI that boots the TTS worker in the spawned
|
|
55
55
|
* subprocess. Kept in sync with the dispatch in `cli.ts` (Main-owned).
|
|
56
56
|
*/
|
|
57
|
-
export declare const TTS_WORKER_ARG = "
|
|
57
|
+
export declare const TTS_WORKER_ARG = "__omp_worker_tts";
|
|
58
58
|
interface SpawnedSubprocess {
|
|
59
59
|
proc: Subprocess<"ignore", "ignore", "ignore">;
|
|
60
60
|
inbound: Set<(message: TtsWorkerOutbound) => void>;
|
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
type AssistantContentBlock = AssistantMessage["content"][number];
|
|
3
|
-
type ThinkingBlock = Extract<AssistantContentBlock, {
|
|
4
|
-
type: "thinking";
|
|
5
|
-
}>;
|
|
6
|
-
/**
|
|
7
|
-
* Returns the operator-visible thinking text for a block.
|
|
8
|
-
*
|
|
9
|
-
* Some OpenAI-compatible reasoning gateways require a non-empty
|
|
10
|
-
* `reasoning_content` field on historical assistant tool-call turns even when
|
|
11
|
-
* the model did not emit any reasoning. The provider adapter uses a single dot
|
|
12
|
-
* as the wire-only placeholder those gateways accept; if that value is later
|
|
13
|
-
* replayed or echoed as a thinking block, it should not render as model thought.
|
|
14
|
-
*/
|
|
15
|
-
export declare function getVisibleThinkingText(block: ThinkingBlock): string;
|
|
16
|
-
export declare function hasVisibleThinking(block: ThinkingBlock): boolean;
|
|
17
|
-
export {};
|
|
1
|
+
export declare function canonicalizeMessage(text: string | null | undefined): string;
|