@oh-my-pi/pi-coding-agent 17.0.9 → 17.1.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 +54 -0
- package/README.md +1 -1
- package/dist/cli.js +4659 -4261
- package/dist/types/async/job-manager.d.ts +37 -1
- package/dist/types/cli/args.d.ts +2 -0
- package/dist/types/cli/bench-cli.d.ts +41 -0
- package/dist/types/commands/bench.d.ts +15 -3
- package/dist/types/commands/launch.d.ts +4 -0
- package/dist/types/config/model-registry.d.ts +3 -1
- package/dist/types/config/models-config-schema.d.ts +18 -6
- package/dist/types/config/models-config.d.ts +14 -5
- package/dist/types/config/provider-globals.d.ts +2 -2
- package/dist/types/config/service-tier.d.ts +5 -1
- package/dist/types/config/settings-schema.d.ts +316 -47
- package/dist/types/config/settings.d.ts +7 -0
- package/dist/types/dap/client.d.ts +20 -0
- package/dist/types/exec/bash-executor.d.ts +38 -0
- package/dist/types/exec/direnv.d.ts +33 -0
- package/dist/types/export/html/args.d.ts +15 -0
- package/dist/types/export/html/index.d.ts +11 -26
- package/dist/types/export/html/web-palette.d.ts +55 -116
- package/dist/types/extensibility/extensions/loader.d.ts +3 -0
- package/dist/types/extensibility/extensions/types.d.ts +17 -2
- package/dist/types/extensibility/plugins/legacy-pi-compat.d.ts +13 -0
- package/dist/types/live/controller.d.ts +40 -0
- package/dist/types/live/protocol.d.ts +85 -0
- package/dist/types/live/protocol.test.d.ts +1 -0
- package/dist/types/live/transport.d.ts +48 -0
- package/dist/types/live/visualizer.d.ts +33 -0
- package/dist/types/lsp/client.d.ts +16 -1
- package/dist/types/mcp/config-writer.test.d.ts +1 -0
- package/dist/types/mcp/oauth-discovery.d.ts +2 -0
- package/dist/types/mcp/smithery-auth.d.ts +1 -1
- package/dist/types/mcp/smithery-auth.test.d.ts +1 -0
- package/dist/types/memory-backend/tool-names.d.ts +2 -0
- package/dist/types/modes/components/login-dialog.d.ts +2 -2
- package/dist/types/modes/components/plan-review-overlay.d.ts +26 -0
- package/dist/types/modes/components/settings-defs.d.ts +7 -1
- package/dist/types/modes/components/status-line/component.jj-cache.test.d.ts +1 -0
- package/dist/types/modes/components/tool-execution.d.ts +9 -1
- package/dist/types/modes/controllers/command-controller.d.ts +1 -1
- package/dist/types/modes/controllers/event-controller.d.ts +6 -1
- package/dist/types/modes/controllers/live-command-controller.d.ts +14 -0
- package/dist/types/modes/interactive-mode.d.ts +5 -0
- package/dist/types/modes/theme/theme.d.ts +1 -1
- package/dist/types/modes/types.d.ts +3 -1
- package/dist/types/modes/utils/context-usage.d.ts +12 -2
- package/dist/types/plan-mode/plan-files.d.ts +10 -0
- package/dist/types/registry/agent-lifecycle.d.ts +21 -9
- package/dist/types/registry/agent-registry.d.ts +11 -4
- package/dist/types/sdk.d.ts +15 -1
- package/dist/types/secrets/index.d.ts +15 -2
- package/dist/types/secrets/obfuscator.d.ts +113 -15
- package/dist/types/session/acp-permission-gate.d.ts +19 -0
- package/dist/types/session/agent-session-events.d.ts +84 -0
- package/dist/types/session/agent-session-types.d.ts +314 -0
- package/dist/types/session/agent-session.d.ts +118 -755
- package/dist/types/session/async-job-delivery.d.ts +28 -0
- package/dist/types/session/bash-runner.d.ts +75 -0
- package/dist/types/session/blob-store.d.ts +11 -1
- package/dist/types/session/blob-store.test.d.ts +1 -0
- package/dist/types/session/checkpoint-entries.d.ts +28 -0
- package/dist/types/session/eval-runner.d.ts +49 -0
- package/dist/types/session/irc-bridge.d.ts +46 -0
- package/dist/types/session/messages.d.ts +22 -0
- package/dist/types/session/model-controls.d.ts +180 -0
- package/dist/types/session/prewalk.d.ts +46 -0
- package/dist/types/session/queued-messages.d.ts +22 -0
- package/dist/types/session/redis-session-storage.d.ts +1 -0
- package/dist/types/session/retry-fallback-chains.d.ts +74 -0
- package/dist/types/session/role-models.d.ts +15 -0
- package/dist/types/session/session-advisors.d.ts +228 -0
- package/dist/types/session/session-entries.d.ts +8 -0
- package/dist/types/session/session-handoff.d.ts +70 -0
- package/dist/types/session/session-history-format.d.ts +6 -1
- package/dist/types/session/session-maintenance.d.ts +246 -0
- package/dist/types/session/session-manager.d.ts +41 -0
- package/dist/types/session/session-memory.d.ts +56 -0
- package/dist/types/session/session-provider-boundary.d.ts +62 -0
- package/dist/types/session/session-stats.d.ts +48 -0
- package/dist/types/session/session-tools.d.ts +143 -0
- package/dist/types/session/session-workspace.d.ts +32 -0
- package/dist/types/session/stream-guards.d.ts +44 -0
- package/dist/types/session/todo-tracker.d.ts +56 -0
- package/dist/types/session/ttsr-coordinator.d.ts +51 -0
- package/dist/types/session/turn-recovery.d.ts +225 -0
- package/dist/types/system-prompt.d.ts +2 -0
- package/dist/types/task/executor.d.ts +4 -1
- package/dist/types/task/output-manager.d.ts +3 -1
- package/dist/types/tools/approval.d.ts +1 -0
- package/dist/types/tools/browser/launch.d.ts +5 -0
- package/dist/types/tools/image-gen.d.ts +4 -4
- package/dist/types/tools/image-providers.d.ts +38 -0
- package/dist/types/tools/index.d.ts +5 -0
- package/dist/types/tools/path-utils.d.ts +8 -0
- package/dist/types/tools/todo.d.ts +10 -4
- package/dist/types/tools/xdev.d.ts +5 -1
- package/dist/types/tts/streaming-player.d.ts +14 -0
- package/dist/types/tts/vocalizer.d.ts +5 -0
- package/dist/types/utils/jj.d.ts +29 -0
- package/dist/types/utils/lang-from-path.d.ts +1 -0
- package/dist/types/utils/title-generator.d.ts +30 -0
- package/dist/types/vibe/runtime.d.ts +36 -8
- package/dist/types/web/search/index.d.ts +1 -1
- package/dist/types/web/search/provider.d.ts +15 -5
- package/dist/types/web/search/types.d.ts +94 -0
- package/package.json +12 -12
- package/scripts/generate-share-viewer.ts +4 -6
- package/src/advisor/__tests__/advisor.test.ts +643 -0
- package/src/advisor/runtime.ts +144 -43
- package/src/async/job-manager.ts +90 -2
- package/src/cli/args.ts +2 -0
- package/src/cli/auth-gateway-cli.ts +18 -3
- package/src/cli/bench-cli.ts +395 -29
- package/src/cli/flag-tables.ts +3 -0
- package/src/cli/gc-cli.ts +2 -2
- package/src/cli/usage-cli.ts +10 -1
- package/src/collab/host.ts +3 -2
- package/src/commands/bench.ts +18 -4
- package/src/commands/launch.ts +4 -0
- package/src/config/model-registry.ts +10 -2
- package/src/config/models-config-schema.ts +15 -4
- package/src/config/provider-globals.ts +9 -9
- package/src/config/service-tier.ts +26 -1
- package/src/config/settings-schema.ts +209 -51
- package/src/config/settings.ts +81 -2
- package/src/dap/client.ts +37 -4
- package/src/edit/index.ts +49 -12
- package/src/eval/py/executor.ts +103 -33
- package/src/exec/bash-executor.ts +89 -6
- package/src/exec/direnv.ts +145 -0
- package/src/export/html/args.ts +20 -0
- package/src/export/html/index.ts +45 -47
- package/src/export/html/template.css +19 -1
- package/src/export/html/template.html +6 -0
- package/src/export/html/template.js +21 -0
- package/src/export/html/tool-views.generated.js +31 -31
- package/src/export/html/web-palette.ts +116 -132
- package/src/export/share.ts +249 -49
- package/src/extensibility/extensions/loader.ts +29 -1
- package/src/extensibility/extensions/runner.ts +6 -0
- package/src/extensibility/extensions/types.ts +33 -2
- package/src/extensibility/plugins/legacy-pi-compat.ts +19 -1
- package/src/hindsight/state.ts +64 -6
- package/src/internal-urls/local-protocol.ts +2 -1
- package/src/internal-urls/memory-protocol.ts +2 -2
- package/src/internal-urls/skill-protocol.ts +2 -2
- package/src/internal-urls/ssh-protocol.ts +2 -1
- package/src/internal-urls/vault-protocol.ts +2 -1
- package/src/live/audio-worklet.txt +59 -0
- package/src/live/browser-runtime.txt +221 -0
- package/src/live/controller.ts +464 -0
- package/src/live/prompts/agent-final-message.md +3 -0
- package/src/live/prompts/live-instructions.md +23 -0
- package/src/live/protocol.test.ts +140 -0
- package/src/live/protocol.ts +233 -0
- package/src/live/transport.ts +490 -0
- package/src/live/visualizer.ts +234 -0
- package/src/lsp/client.ts +29 -9
- package/src/lsp/index.ts +19 -4
- package/src/main.ts +8 -1
- package/src/mcp/config-writer.test.ts +43 -0
- package/src/mcp/config-writer.ts +109 -82
- package/src/mcp/oauth-discovery.ts +10 -2
- package/src/mcp/smithery-auth.test.ts +29 -0
- package/src/mcp/smithery-auth.ts +3 -2
- package/src/memories/index.ts +40 -20
- package/src/memory-backend/tool-names.ts +2 -0
- package/src/mnemopi/backend.ts +24 -7
- package/src/modes/acp/acp-agent.ts +56 -10
- package/src/modes/acp/acp-event-mapper.ts +8 -1
- package/src/modes/components/agent-hub.ts +1 -1
- package/src/modes/components/login-dialog.ts +14 -4
- package/src/modes/components/plan-review-overlay.ts +350 -35
- package/src/modes/components/settings-defs.ts +23 -1
- package/src/modes/components/settings-selector.ts +169 -1
- package/src/modes/components/status-line/component.jj-cache.test.ts +229 -0
- package/src/modes/components/status-line/component.ts +123 -2
- package/src/modes/components/tool-execution.ts +11 -2
- package/src/modes/controllers/command-controller.ts +56 -15
- package/src/modes/controllers/event-controller.ts +111 -16
- package/src/modes/controllers/extension-ui-controller.test.ts +1 -0
- package/src/modes/controllers/extension-ui-controller.ts +20 -4
- package/src/modes/controllers/live-command-controller.ts +178 -0
- package/src/modes/controllers/mcp-command-controller.ts +10 -1
- package/src/modes/controllers/omfg-controller.ts +44 -40
- package/src/modes/controllers/selector-controller.ts +18 -10
- package/src/modes/controllers/session-focus-controller.ts +6 -1
- package/src/modes/interactive-mode.ts +157 -38
- package/src/modes/runtime-init.ts +2 -0
- package/src/modes/setup-wizard/scenes/web-search.ts +17 -9
- package/src/modes/theme/theme.ts +1 -1
- package/src/modes/types.ts +3 -1
- package/src/modes/utils/context-usage.ts +23 -7
- package/src/modes/utils/ui-helpers.ts +10 -5
- package/src/plan-mode/plan-files.ts +40 -0
- package/src/prompts/bench/cache-prefix-chunk.md +1 -0
- package/src/prompts/bench/cache-prefix.md +3 -0
- package/src/prompts/bench/cache-suffix.md +1 -0
- package/src/prompts/system/custom-system-prompt.md +1 -1
- package/src/prompts/system/project-prompt.md +8 -1
- package/src/prompts/system/subagent-async-pending.md +6 -0
- package/src/prompts/system/system-prompt.md +1 -1
- package/src/prompts/system/workflow-notice.md +48 -40
- package/src/prompts/system/xdev-mount-notice.md +4 -0
- package/src/prompts/tools/todo.md +3 -1
- package/src/registry/agent-lifecycle.ts +116 -46
- package/src/registry/agent-registry.ts +35 -8
- package/src/registry/persisted-agents.ts +26 -2
- package/src/sdk.ts +210 -136
- package/src/secrets/index.ts +127 -4
- package/src/secrets/obfuscator.ts +2328 -105
- package/src/session/acp-permission-gate.ts +165 -0
- package/src/session/agent-session-error-log.test.ts +1 -1
- package/src/session/agent-session-events.ts +66 -0
- package/src/session/agent-session-types.ts +334 -0
- package/src/session/agent-session.ts +1892 -12226
- package/src/session/artifacts.ts +6 -5
- package/src/session/async-job-delivery.ts +74 -0
- package/src/session/bash-runner.ts +326 -0
- package/src/session/blob-store.test.ts +56 -0
- package/src/session/blob-store.ts +18 -2
- package/src/session/checkpoint-entries.ts +81 -0
- package/src/session/eval-runner.ts +212 -0
- package/src/session/indexed-session-storage.ts +9 -2
- package/src/session/irc-bridge.ts +203 -0
- package/src/session/messages.ts +263 -1
- package/src/session/model-controls.ts +714 -0
- package/src/session/prewalk.ts +252 -0
- package/src/session/queued-messages.ts +93 -0
- package/src/session/redis-session-storage.ts +51 -11
- package/src/session/retry-fallback-chains.ts +455 -0
- package/src/session/role-models.ts +85 -0
- package/src/session/session-advisors.ts +1679 -0
- package/src/session/session-context.ts +6 -3
- package/src/session/session-entries.ts +8 -0
- package/src/session/session-handoff.ts +308 -0
- package/src/session/session-history-format.ts +20 -9
- package/src/session/session-loader.ts +0 -46
- package/src/session/session-maintenance.ts +2983 -0
- package/src/session/session-manager.ts +390 -30
- package/src/session/session-memory.ts +222 -0
- package/src/session/session-provider-boundary.ts +307 -0
- package/src/session/session-stats.ts +293 -0
- package/src/session/session-tools.ts +943 -0
- package/src/session/session-workspace.ts +53 -0
- package/src/session/stream-guards.ts +417 -0
- package/src/session/todo-tracker.ts +380 -0
- package/src/session/ttsr-coordinator.ts +496 -0
- package/src/session/turn-recovery.ts +1629 -0
- package/src/slash-commands/builtin-registry.ts +92 -11
- package/src/slash-commands/helpers/usage-report.ts +22 -3
- package/src/system-prompt.ts +41 -17
- package/src/task/executor.ts +285 -70
- package/src/task/index.ts +98 -105
- package/src/task/output-manager.ts +25 -3
- package/src/task/persisted-revive.ts +4 -3
- package/src/task/structured-subagent.ts +1 -0
- package/src/tools/approval.ts +55 -10
- package/src/tools/bash-interactive.ts +26 -0
- package/src/tools/bash-skill-urls.ts +28 -2
- package/src/tools/bash.ts +339 -123
- package/src/tools/browser/launch.ts +9 -1
- package/src/tools/browser/tab-supervisor.ts +8 -5
- package/src/tools/browser.ts +94 -47
- package/src/tools/image-gen.ts +20 -28
- package/src/tools/image-providers.ts +50 -0
- package/src/tools/index.ts +9 -0
- package/src/tools/path-utils.ts +49 -2
- package/src/tools/read.ts +156 -88
- package/src/tools/renderers.ts +7 -1
- package/src/tools/todo.ts +101 -11
- package/src/tools/vibe.ts +1 -2
- package/src/tools/write.ts +51 -1
- package/src/tools/xdev.ts +67 -3
- package/src/tts/streaming-player.ts +62 -4
- package/src/tts/vocalizer.ts +18 -1
- package/src/utils/jj.ts +125 -4
- package/src/utils/lang-from-path.ts +7 -0
- package/src/utils/title-generator.ts +137 -1
- package/src/vibe/runtime.ts +852 -72
- package/src/web/search/index.ts +3 -6
- package/src/web/search/provider.ts +31 -16
- package/src/web/search/providers/xai.ts +7 -1
- package/src/web/search/types.ts +3 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { AgentEvent, ThinkingLevel } from "@oh-my-pi/pi-agent-core";
|
|
2
|
+
import type { CompactionResult } from "@oh-my-pi/pi-agent-core/compaction";
|
|
3
|
+
import type { Effort } from "@oh-my-pi/pi-ai";
|
|
4
|
+
import type { Rule } from "../capability/rule.js";
|
|
5
|
+
import type { RecoveredRetryError } from "../extensibility/shared-events.js";
|
|
6
|
+
import type { Goal, GoalModeState } from "../goals/state.js";
|
|
7
|
+
import type { ConfiguredThinkingLevel } from "../thinking.js";
|
|
8
|
+
import type { TodoItem } from "../tools/todo.js";
|
|
9
|
+
import type { CustomMessage } from "./messages.js";
|
|
10
|
+
/** Session-specific events that extend the core AgentEvent. */
|
|
11
|
+
export type AgentSessionEvent = Exclude<AgentEvent, {
|
|
12
|
+
type: "agent_end";
|
|
13
|
+
}> | (Extract<AgentEvent, {
|
|
14
|
+
type: "agent_end";
|
|
15
|
+
}> & {
|
|
16
|
+
/** False when an async delivery will resume the session before its true final settle. */
|
|
17
|
+
isTerminal?: boolean;
|
|
18
|
+
}) | {
|
|
19
|
+
type: "auto_compaction_start";
|
|
20
|
+
reason: "threshold" | "overflow" | "idle" | "incomplete";
|
|
21
|
+
action: "context-full" | "handoff" | "shake" | "snapcompact";
|
|
22
|
+
} | {
|
|
23
|
+
type: "auto_compaction_end";
|
|
24
|
+
action: "context-full" | "handoff" | "shake" | "snapcompact";
|
|
25
|
+
result: CompactionResult | undefined;
|
|
26
|
+
aborted: boolean;
|
|
27
|
+
willRetry: boolean;
|
|
28
|
+
errorMessage?: string;
|
|
29
|
+
/** True when compaction was skipped for a benign reason. */
|
|
30
|
+
skipped?: boolean;
|
|
31
|
+
} | {
|
|
32
|
+
type: "auto_retry_start";
|
|
33
|
+
attempt: number;
|
|
34
|
+
maxAttempts: number;
|
|
35
|
+
delayMs: number;
|
|
36
|
+
errorMessage: string;
|
|
37
|
+
errorId?: number;
|
|
38
|
+
} | {
|
|
39
|
+
type: "auto_retry_end";
|
|
40
|
+
success: boolean;
|
|
41
|
+
attempt: number;
|
|
42
|
+
finalError?: string;
|
|
43
|
+
recoveredErrors?: RecoveredRetryError[];
|
|
44
|
+
} | {
|
|
45
|
+
type: "retry_fallback_applied";
|
|
46
|
+
from: string;
|
|
47
|
+
to: string;
|
|
48
|
+
role: string;
|
|
49
|
+
} | {
|
|
50
|
+
type: "retry_fallback_succeeded";
|
|
51
|
+
model: string;
|
|
52
|
+
role: string;
|
|
53
|
+
} | {
|
|
54
|
+
type: "ttsr_triggered";
|
|
55
|
+
rules: Rule[];
|
|
56
|
+
} | {
|
|
57
|
+
type: "todo_reminder";
|
|
58
|
+
todos: TodoItem[];
|
|
59
|
+
attempt: number;
|
|
60
|
+
maxAttempts: number;
|
|
61
|
+
} | {
|
|
62
|
+
type: "todo_auto_clear";
|
|
63
|
+
} | {
|
|
64
|
+
type: "irc_message";
|
|
65
|
+
message: CustomMessage;
|
|
66
|
+
} | {
|
|
67
|
+
type: "notice";
|
|
68
|
+
level: "info" | "warning" | "error";
|
|
69
|
+
message: string;
|
|
70
|
+
source?: string;
|
|
71
|
+
} | {
|
|
72
|
+
type: "thinking_level_changed";
|
|
73
|
+
thinkingLevel: ThinkingLevel | undefined;
|
|
74
|
+
/** The user-configured selector when it differs from the effective level. */
|
|
75
|
+
configured?: ConfiguredThinkingLevel;
|
|
76
|
+
/** The level `auto` resolved to this turn, once classified. */
|
|
77
|
+
resolved?: Effort;
|
|
78
|
+
} | {
|
|
79
|
+
type: "goal_updated";
|
|
80
|
+
goal: Goal | null;
|
|
81
|
+
state?: GoalModeState;
|
|
82
|
+
};
|
|
83
|
+
/** Listener function for agent session events. */
|
|
84
|
+
export type AgentSessionEventListener = (event: AgentSessionEvent) => void;
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import type { Agent, AgentMessage, AgentTool, StreamFn, ThinkingLevel } from "@oh-my-pi/pi-agent-core";
|
|
2
|
+
import type { Context, ImageContent, Message, MessageAttribution, Model, ServiceTierByFamily, SimpleStreamOptions, ToolChoice } from "@oh-my-pi/pi-ai";
|
|
3
|
+
import type { postmortem } from "@oh-my-pi/pi-utils";
|
|
4
|
+
import type { AdvisorConfig } from "../advisor/index.js";
|
|
5
|
+
import type { AsyncJob, AsyncJobDeliveryState, AsyncJobManager } from "../async/index.js";
|
|
6
|
+
import type { ModelRegistry } from "../config/model-registry.js";
|
|
7
|
+
import type { PromptTemplate } from "../config/prompt-templates.js";
|
|
8
|
+
import type { Settings, SkillsSettings } from "../config/settings.js";
|
|
9
|
+
import type { RawSseDebugBuffer } from "../debug/raw-sse-buffer.js";
|
|
10
|
+
import type { TtsrManager } from "../export/ttsr.js";
|
|
11
|
+
import type { LoadedCustomCommand } from "../extensibility/custom-commands/index.js";
|
|
12
|
+
import type { ExtensionRunner } from "../extensibility/extensions/index.js";
|
|
13
|
+
import type { ContextUsage } from "../extensibility/extensions/types.js";
|
|
14
|
+
import type { Skill, SkillWarning } from "../extensibility/skills.js";
|
|
15
|
+
import type { FileSlashCommand } from "../extensibility/slash-commands.js";
|
|
16
|
+
import type { SecretObfuscator } from "../secrets/obfuscator.js";
|
|
17
|
+
import type { ConfiguredThinkingLevel } from "../thinking.js";
|
|
18
|
+
import type { XdevRegistry } from "../tools/xdev.js";
|
|
19
|
+
import type { SessionManager } from "./session-manager.js";
|
|
20
|
+
/** Maximum time the interactive shutdown path waits for Mnemopi consolidation. */
|
|
21
|
+
export declare const SHUTDOWN_CONSOLIDATE_BUDGET_MS = 1500;
|
|
22
|
+
/** Options controlling session disposal. */
|
|
23
|
+
export interface AgentSessionDisposeOptions {
|
|
24
|
+
mnemopiConsolidateTimeoutMs?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Postmortem reason that triggered this dispose (signal/fatal teardown
|
|
27
|
+
* paths). When set, the persisted `session_exit` diagnostic records it
|
|
28
|
+
* instead of the generic `"dispose"` used for normal programmatic disposal
|
|
29
|
+
* (`/quit`, test teardown, subagent completion).
|
|
30
|
+
*/
|
|
31
|
+
reason?: postmortem.Reason;
|
|
32
|
+
}
|
|
33
|
+
/** Listener notified when command metadata changes. */
|
|
34
|
+
export type CommandMetadataChangedListener = () => void | Promise<void>;
|
|
35
|
+
/** Public summary of an asynchronous job. */
|
|
36
|
+
export type AsyncJobSnapshotItem = Pick<AsyncJob, "id" | "type" | "status" | "label" | "startTime">;
|
|
37
|
+
/** Snapshot of running, recent, and pending-delivery asynchronous jobs. */
|
|
38
|
+
export interface AsyncJobSnapshot {
|
|
39
|
+
running: AsyncJobSnapshotItem[];
|
|
40
|
+
recent: AsyncJobSnapshotItem[];
|
|
41
|
+
delivery: AsyncJobDeliveryState;
|
|
42
|
+
}
|
|
43
|
+
export type { ShakeMode, ShakeResult } from "./shake-types.js";
|
|
44
|
+
/**
|
|
45
|
+
* Prewalk switches an active session one-way from its starting model to a
|
|
46
|
+
* fast/cheap target after implementation begins.
|
|
47
|
+
*/
|
|
48
|
+
export interface Prewalk {
|
|
49
|
+
target: Model;
|
|
50
|
+
thinkingLevel?: ConfiguredThinkingLevel;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* PlanYolo starts in read-only plan mode, auto-approves the proposal, then
|
|
54
|
+
* switches to a target model for implementation.
|
|
55
|
+
*/
|
|
56
|
+
export interface PlanYolo {
|
|
57
|
+
target: Model;
|
|
58
|
+
thinkingLevel?: ConfiguredThinkingLevel;
|
|
59
|
+
}
|
|
60
|
+
/** Details shown when confirming a usage-reserve-triggered model fallback. */
|
|
61
|
+
export interface UsageFallbackConfirmation {
|
|
62
|
+
from: string;
|
|
63
|
+
to: string;
|
|
64
|
+
remainingPercent: number | undefined;
|
|
65
|
+
}
|
|
66
|
+
/** Identifies a retry fallback chain already entered during startup model resolution. */
|
|
67
|
+
export interface InitialRetryFallbackState {
|
|
68
|
+
/** Role whose configured primary was unavailable. */
|
|
69
|
+
role: string;
|
|
70
|
+
/** Configured primary selector retained for restoration when it becomes available. */
|
|
71
|
+
originalSelector: string;
|
|
72
|
+
/** Thinking selector configured for the unavailable primary. */
|
|
73
|
+
originalThinkingLevel: ConfiguredThinkingLevel | undefined;
|
|
74
|
+
/** Prevent cooldown restoration when startup selected this fallback from live usage health. */
|
|
75
|
+
pinned?: boolean;
|
|
76
|
+
}
|
|
77
|
+
/** Dependencies and initial state used to construct an AgentSession. */
|
|
78
|
+
export interface AgentSessionConfig {
|
|
79
|
+
agent: Agent;
|
|
80
|
+
sessionManager: SessionManager;
|
|
81
|
+
settings: Settings;
|
|
82
|
+
/** Whether the caller explicitly requested yolo/auto-approve behavior for this session. */
|
|
83
|
+
autoApprove?: boolean;
|
|
84
|
+
/** Models to cycle through with Ctrl+P (from --models flag). */
|
|
85
|
+
scopedModels?: Array<{
|
|
86
|
+
model: Model;
|
|
87
|
+
thinkingLevel?: ThinkingLevel;
|
|
88
|
+
}>;
|
|
89
|
+
/** Initial session thinking selector. */
|
|
90
|
+
thinkingLevel?: ConfiguredThinkingLevel;
|
|
91
|
+
/** Retry chain ownership when startup selected one of its fallback entries. */
|
|
92
|
+
initialRetryFallback?: InitialRetryFallbackState;
|
|
93
|
+
/** Prewalk from the starting model to a fast/cheap target after implementation begins. */
|
|
94
|
+
prewalk?: Prewalk;
|
|
95
|
+
/** Force read-only plan mode at start, auto-approve, then switch to the target. */
|
|
96
|
+
planYolo?: PlanYolo;
|
|
97
|
+
/** Initial per-family service tiers for the live session. */
|
|
98
|
+
serviceTierByFamily?: ServiceTierByFamily;
|
|
99
|
+
/** Prompt templates for expansion. */
|
|
100
|
+
promptTemplates?: PromptTemplate[];
|
|
101
|
+
/** File-based slash commands for expansion. */
|
|
102
|
+
slashCommands?: FileSlashCommand[];
|
|
103
|
+
/** Extension runner created with wrapped tools. */
|
|
104
|
+
extensionRunner?: ExtensionRunner;
|
|
105
|
+
/** Loaded skills already discovered by the SDK. */
|
|
106
|
+
skills?: Skill[];
|
|
107
|
+
/** Skill loading warnings already captured by the SDK. */
|
|
108
|
+
skillWarnings?: SkillWarning[];
|
|
109
|
+
/** Whether runtime reloads may rediscover disk-backed skills. */
|
|
110
|
+
skillsReloadable?: boolean;
|
|
111
|
+
/** Custom TypeScript slash commands. */
|
|
112
|
+
customCommands?: LoadedCustomCommand[];
|
|
113
|
+
skillsSettings?: SkillsSettings;
|
|
114
|
+
/** Agent directory used when changing memory backends in a live session. */
|
|
115
|
+
memoryAgentDir?: string;
|
|
116
|
+
/** Recursion depth used to suppress live backend replacement in subagents. */
|
|
117
|
+
memoryTaskDepth?: number;
|
|
118
|
+
/** Creates built-in memory tools for the current backend. */
|
|
119
|
+
createMemoryTools?: () => Promise<AgentTool[]>;
|
|
120
|
+
/** Model registry for API key resolution and model discovery. */
|
|
121
|
+
modelRegistry: ModelRegistry;
|
|
122
|
+
/** Tool registry for LSP and settings. */
|
|
123
|
+
toolRegistry?: Map<string, AgentTool>;
|
|
124
|
+
/** Creates tools registered only while vibe mode is active. */
|
|
125
|
+
createVibeTools?: () => AgentTool[];
|
|
126
|
+
/** Names whose current registry entry is the built-in implementation. */
|
|
127
|
+
builtInToolNames?: Iterable<string>;
|
|
128
|
+
/** Updates tool-session predicates from the live active tool set. */
|
|
129
|
+
setActiveToolNames?: (names: Iterable<string>) => void;
|
|
130
|
+
/** Registers the write transport when runtime xdev mounts first need it. */
|
|
131
|
+
ensureWriteRegistered?: () => Promise<boolean>;
|
|
132
|
+
/** Current session pre-LLM message transform pipeline. */
|
|
133
|
+
transformContext?: (messages: AgentMessage[], signal?: AbortSignal) => AgentMessage[] | Promise<AgentMessage[]>;
|
|
134
|
+
/** Provider request transform applied after message conversion. */
|
|
135
|
+
transformProviderContext?: (context: Context, model: Model) => Context | Promise<Context>;
|
|
136
|
+
/** Stream wrapper for side-channel requests. */
|
|
137
|
+
sideStreamFn?: StreamFn;
|
|
138
|
+
/** Stream wrapper for advisor requests. */
|
|
139
|
+
advisorStreamFn?: StreamFn;
|
|
140
|
+
/** Prefer websocket transport for OpenAI Codex requests when supported. */
|
|
141
|
+
preferWebsockets?: boolean;
|
|
142
|
+
/** Provider payload hook used by the active session request path. */
|
|
143
|
+
onPayload?: SimpleStreamOptions["onPayload"];
|
|
144
|
+
/** Provider response hook used by the active session request path. */
|
|
145
|
+
onResponse?: SimpleStreamOptions["onResponse"];
|
|
146
|
+
/** Raw SSE hook used by the active session request path. */
|
|
147
|
+
onSseEvent?: SimpleStreamOptions["onSseEvent"];
|
|
148
|
+
/** Per-session raw SSE diagnostic buffer. */
|
|
149
|
+
rawSseDebugBuffer?: RawSseDebugBuffer;
|
|
150
|
+
/** Current session message-to-LLM conversion pipeline. */
|
|
151
|
+
convertToLlm?: (messages: AgentMessage[]) => Message[] | Promise<Message[]>;
|
|
152
|
+
/** System prompt builder that can consider tool availability. */
|
|
153
|
+
rebuildSystemPrompt?: (toolNames: string[], tools: Map<string, AgentTool>) => Promise<{
|
|
154
|
+
systemPrompt: string[];
|
|
155
|
+
}>;
|
|
156
|
+
/** Local calendar date provider used by prompt-cache invalidation. */
|
|
157
|
+
getLocalCalendarDate?: () => string;
|
|
158
|
+
/** Tools mounted under `xd://`, for `/tools` display. */
|
|
159
|
+
getXdevToolEntries?: () => Array<{
|
|
160
|
+
name: string;
|
|
161
|
+
summary: string;
|
|
162
|
+
}>;
|
|
163
|
+
/** Session-owned `xd://` registry. */
|
|
164
|
+
xdevRegistry?: XdevRegistry;
|
|
165
|
+
/** Discoverable tools mounted under `xd://` in the initial enabled set. */
|
|
166
|
+
initialMountedXdevToolNames?: string[];
|
|
167
|
+
/** Names pinned top-level during runtime repartitioning. */
|
|
168
|
+
presentationPinnedToolNames?: ReadonlySet<string>;
|
|
169
|
+
/** Accessor for live MCP server instructions. */
|
|
170
|
+
getMcpServerInstructions?: () => Map<string, string> | undefined;
|
|
171
|
+
/** Time-traveling stream-rule manager. */
|
|
172
|
+
ttsrManager?: TtsrManager;
|
|
173
|
+
/** Secret obfuscator for provider and edit content. */
|
|
174
|
+
obfuscator?: SecretObfuscator;
|
|
175
|
+
/** Inherited eval executor session id from a parent agent. */
|
|
176
|
+
parentEvalSessionId?: string;
|
|
177
|
+
/** Logical owner for retained eval kernels created by this session. */
|
|
178
|
+
evalKernelOwnerId?: string;
|
|
179
|
+
/** Async job manager owned and disposed by this session. */
|
|
180
|
+
ownedAsyncJobManager?: AsyncJobManager;
|
|
181
|
+
/** Async job manager visible to this session. */
|
|
182
|
+
asyncJobManager?: AsyncJobManager;
|
|
183
|
+
/** Registry identity used for IRC routing. */
|
|
184
|
+
agentId?: string;
|
|
185
|
+
/** Whether this is a top-level or subagent session. */
|
|
186
|
+
agentKind?: "main" | "sub";
|
|
187
|
+
/** Provider-facing session ID override. */
|
|
188
|
+
providerSessionId?: string;
|
|
189
|
+
/** Whether the provider prompt-cache key was explicit or fork-inherited. */
|
|
190
|
+
providerPromptCacheKeySource?: "explicit" | "fork";
|
|
191
|
+
/** Full advisor toolset built against an advisor-scoped tool session. */
|
|
192
|
+
advisorTools?: AgentTool[];
|
|
193
|
+
/** Preloaded watchdog prompt content for the advisor. */
|
|
194
|
+
advisorWatchdogPrompt?: string;
|
|
195
|
+
/** Shared advisor instructions loaded from WATCHDOG.yml. */
|
|
196
|
+
advisorSharedInstructions?: string;
|
|
197
|
+
/** Project context rendered for advisor sessions. */
|
|
198
|
+
advisorContextPrompt?: string;
|
|
199
|
+
/** Advisors discovered from WATCHDOG.yml. */
|
|
200
|
+
advisorConfigs?: AdvisorConfig[];
|
|
201
|
+
/** Strip tool descriptions from provider-bound side-request tool specs. */
|
|
202
|
+
pruneToolDescriptions?: boolean;
|
|
203
|
+
/** Disconnect the MCP manager owned by this session during disposal. */
|
|
204
|
+
disconnectOwnedMcpManager?: () => Promise<void>;
|
|
205
|
+
/** System prompt used by automatic session-title generation. */
|
|
206
|
+
titleSystemPrompt?: string;
|
|
207
|
+
}
|
|
208
|
+
/** Options for AgentSession.prompt(). */
|
|
209
|
+
export interface PromptOptions {
|
|
210
|
+
/** Whether to expand file-based prompt templates (default: true). */
|
|
211
|
+
expandPromptTemplates?: boolean;
|
|
212
|
+
/** Image attachments. */
|
|
213
|
+
images?: ImageContent[];
|
|
214
|
+
/** Queue behavior while streaming. */
|
|
215
|
+
streamingBehavior?: "steer" | "followUp";
|
|
216
|
+
/** Optional tool choice override for the next LLM call. */
|
|
217
|
+
toolChoice?: ToolChoice;
|
|
218
|
+
/** Send as a developer/system message instead of user. */
|
|
219
|
+
synthetic?: boolean;
|
|
220
|
+
/** Whether this prompt is a deliberate user action. */
|
|
221
|
+
userInitiated?: boolean;
|
|
222
|
+
/** Explicit billing/initiator attribution. */
|
|
223
|
+
attribution?: MessageAttribution;
|
|
224
|
+
/** Skip pre-send compaction checks for this prompt. */
|
|
225
|
+
skipCompactionCheck?: boolean;
|
|
226
|
+
}
|
|
227
|
+
/** Options for AgentSession.followUp(). */
|
|
228
|
+
export interface FollowUpOptions {
|
|
229
|
+
/** Enqueue as a hidden developer message instead of a user follow-up. */
|
|
230
|
+
synthetic?: boolean;
|
|
231
|
+
/** Whether to expand file-based prompt templates (default: true). */
|
|
232
|
+
expandPromptTemplates?: boolean;
|
|
233
|
+
/** Explicit billing/initiator attribution. */
|
|
234
|
+
attribution?: MessageAttribution;
|
|
235
|
+
}
|
|
236
|
+
/** Result from a handoff operation. */
|
|
237
|
+
export interface HandoffResult {
|
|
238
|
+
document: string;
|
|
239
|
+
savedPath?: string;
|
|
240
|
+
}
|
|
241
|
+
/** Options controlling handoff generation. */
|
|
242
|
+
export interface SessionHandoffOptions {
|
|
243
|
+
autoTriggered?: boolean;
|
|
244
|
+
signal?: AbortSignal;
|
|
245
|
+
onSwitchCancelled?: () => void;
|
|
246
|
+
}
|
|
247
|
+
/** Result from cycleModel(). */
|
|
248
|
+
export interface ModelCycleResult {
|
|
249
|
+
model: Model;
|
|
250
|
+
thinkingLevel: ThinkingLevel | undefined;
|
|
251
|
+
/** Whether cycling through scoped models or all available models. */
|
|
252
|
+
isScoped: boolean;
|
|
253
|
+
}
|
|
254
|
+
/** Result from cycleRoleModels(). */
|
|
255
|
+
export interface RoleModelCycleResult {
|
|
256
|
+
model: Model;
|
|
257
|
+
thinkingLevel: ThinkingLevel | undefined;
|
|
258
|
+
role: string;
|
|
259
|
+
}
|
|
260
|
+
/** A configured role resolved to a concrete model. */
|
|
261
|
+
export interface ResolvedRoleModel {
|
|
262
|
+
role: string;
|
|
263
|
+
model: Model;
|
|
264
|
+
thinkingLevel?: ConfiguredThinkingLevel;
|
|
265
|
+
explicitThinkingLevel: boolean;
|
|
266
|
+
}
|
|
267
|
+
/** Resolvable role models and the currently active index. */
|
|
268
|
+
export interface RoleModelCycle {
|
|
269
|
+
models: ResolvedRoleModel[];
|
|
270
|
+
currentIndex: number;
|
|
271
|
+
}
|
|
272
|
+
/** Token breakdown for the current provider context. */
|
|
273
|
+
export interface ContextUsageBreakdown {
|
|
274
|
+
contextWindow: number;
|
|
275
|
+
anchored: boolean;
|
|
276
|
+
usedTokens: number;
|
|
277
|
+
systemPromptTokens: number;
|
|
278
|
+
systemToolsTokens: number;
|
|
279
|
+
systemContextTokens: number;
|
|
280
|
+
skillsTokens: number;
|
|
281
|
+
messagesTokens: number;
|
|
282
|
+
}
|
|
283
|
+
/** Session statistics for the `/session` command. */
|
|
284
|
+
export interface SessionStats {
|
|
285
|
+
sessionFile: string | undefined;
|
|
286
|
+
sessionId: string;
|
|
287
|
+
userMessages: number;
|
|
288
|
+
assistantMessages: number;
|
|
289
|
+
toolCalls: number;
|
|
290
|
+
toolResults: number;
|
|
291
|
+
totalMessages: number;
|
|
292
|
+
tokens: {
|
|
293
|
+
input: number;
|
|
294
|
+
output: number;
|
|
295
|
+
reasoning: number;
|
|
296
|
+
cacheRead: number;
|
|
297
|
+
cacheWrite: number;
|
|
298
|
+
total: number;
|
|
299
|
+
};
|
|
300
|
+
premiumRequests: number;
|
|
301
|
+
cost: number;
|
|
302
|
+
contextUsage?: ContextUsage;
|
|
303
|
+
}
|
|
304
|
+
/** IDs for a newly created session and the session it replaced. */
|
|
305
|
+
export interface FreshSessionResult {
|
|
306
|
+
previousSessionId: string;
|
|
307
|
+
sessionId: string;
|
|
308
|
+
closedProviderSessions: number;
|
|
309
|
+
}
|
|
310
|
+
/** Queued user content restored to the editor. */
|
|
311
|
+
export type RestoredQueuedMessage = {
|
|
312
|
+
text: string;
|
|
313
|
+
images?: ImageContent[];
|
|
314
|
+
};
|