@oh-my-pi/pi-coding-agent 17.0.9 → 17.1.1
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 +78 -0
- package/README.md +1 -1
- package/dist/cli.js +4685 -4614
- 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 +374 -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/legacy-pi-coding-agent-shim.d.ts +3 -0
- package/dist/types/extensibility/plugins/legacy-pi-compat.d.ts +13 -0
- package/dist/types/live/attestation.d.ts +2 -0
- package/dist/types/live/controller.d.ts +48 -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 +35 -0
- package/dist/types/live/visualizer.d.ts +30 -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/assistant-message.d.ts +1 -0
- package/dist/types/modes/components/custom-message.d.ts +1 -1
- package/dist/types/modes/components/login-dialog.d.ts +2 -2
- package/dist/types/modes/components/message-frame.d.ts +8 -4
- package/dist/types/modes/components/plan-review-overlay.d.ts +26 -0
- package/dist/types/modes/components/session-account-selector.d.ts +11 -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/controllers/selector-controller.d.ts +1 -0
- package/dist/types/modes/interactive-mode.d.ts +6 -0
- package/dist/types/modes/theme/theme.d.ts +1 -1
- package/dist/types/modes/types.d.ts +4 -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 +321 -0
- package/dist/types/session/agent-session.d.ts +135 -753
- package/dist/types/session/async-job-delivery.d.ts +28 -0
- package/dist/types/session/auth-storage.d.ts +1 -1
- 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 +51 -0
- package/dist/types/session/irc-bridge.d.ts +46 -0
- package/dist/types/session/messages.d.ts +24 -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 +158 -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/streaming-output.d.ts +8 -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/slash-commands/helpers/session-pin.d.ts +9 -0
- package/dist/types/stt/index.d.ts +0 -2
- package/dist/types/stt/stt-controller.d.ts +7 -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/tiny/title-client.d.ts +10 -0
- package/dist/types/tools/approval.d.ts +1 -0
- package/dist/types/tools/browser/launch.d.ts +5 -0
- package/dist/types/tools/builtin-names.d.ts +1 -1
- package/dist/types/tools/computer/protocol.d.ts +43 -0
- package/dist/types/tools/computer/supervisor.d.ts +32 -0
- package/dist/types/tools/computer/worker-entry.d.ts +1 -0
- package/dist/types/tools/computer/worker.d.ts +15 -0
- package/dist/types/tools/computer-renderer.d.ts +22 -0
- package/dist/types/tools/computer.d.ts +71 -0
- package/dist/types/tools/context.d.ts +2 -0
- package/dist/types/tools/default-renderer.d.ts +21 -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 +7 -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 +10 -29
- 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/utils/tools-manager.d.ts +1 -2
- 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 +3 -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/setup-cli.ts +2 -14
- package/src/cli/usage-cli.ts +10 -1
- package/src/cli.ts +8 -0
- 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 +16 -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 +270 -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/executor-base.ts +1 -0
- package/src/eval/js/executor.ts +2 -0
- package/src/eval/py/executor.ts +103 -33
- package/src/exec/bash-executor.ts +90 -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/extensions/wrapper.ts +68 -12
- package/src/extensibility/legacy-pi-coding-agent-shim.ts +7 -1
- 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/attestation.ts +91 -0
- package/src/live/controller.ts +517 -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 +422 -0
- package/src/live/visualizer.ts +214 -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/assistant-message.ts +7 -2
- package/src/modes/components/custom-message.ts +4 -1
- package/src/modes/components/login-dialog.ts +14 -4
- package/src/modes/components/message-frame.ts +14 -8
- package/src/modes/components/plan-review-overlay.ts +350 -35
- package/src/modes/components/session-account-selector.ts +62 -0
- 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 +28 -112
- 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/input-controller.ts +47 -39
- package/src/modes/controllers/live-command-controller.ts +255 -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 +80 -10
- package/src/modes/controllers/session-focus-controller.ts +6 -1
- package/src/modes/interactive-mode.ts +176 -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 +4 -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/computer-safety.md +14 -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/computer.md +26 -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 +215 -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 +343 -0
- package/src/session/agent-session.ts +1940 -12218
- package/src/session/artifacts.ts +6 -5
- package/src/session/async-job-delivery.ts +74 -0
- package/src/session/auth-storage.ts +1 -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 +217 -0
- package/src/session/indexed-session-storage.ts +9 -2
- package/src/session/irc-bridge.ts +203 -0
- package/src/session/messages.ts +266 -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 +980 -0
- package/src/session/session-workspace.ts +53 -0
- package/src/session/stream-guards.ts +417 -0
- package/src/session/streaming-output.ts +52 -5
- 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 +257 -20
- package/src/slash-commands/helpers/session-pin.ts +44 -0
- package/src/slash-commands/helpers/usage-report.ts +22 -3
- package/src/stt/downloader.ts +0 -2
- package/src/stt/index.ts +0 -2
- package/src/stt/stt-controller.ts +57 -146
- package/src/system-prompt.ts +45 -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/tiny/title-client.ts +22 -0
- package/src/tools/approval.ts +55 -10
- package/src/tools/bash-interactive.ts +116 -86
- 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/builtin-names.ts +1 -0
- package/src/tools/computer/protocol.ts +28 -0
- package/src/tools/computer/supervisor.ts +258 -0
- package/src/tools/computer/worker-entry.ts +25 -0
- package/src/tools/computer/worker.ts +135 -0
- package/src/tools/computer-renderer.ts +108 -0
- package/src/tools/computer.ts +433 -0
- package/src/tools/context.ts +2 -0
- package/src/tools/default-renderer.ts +139 -0
- package/src/tools/essential-tools.ts +1 -0
- package/src/tools/image-gen.ts +20 -28
- package/src/tools/image-providers.ts +50 -0
- package/src/tools/index.ts +14 -0
- package/src/tools/path-utils.ts +49 -2
- package/src/tools/read.ts +156 -88
- package/src/tools/renderers.ts +9 -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 +121 -29
- package/src/tts/streaming-player.ts +82 -283
- package/src/tts/vocalizer.ts +18 -1
- package/src/utils/clipboard.ts +1 -30
- package/src/utils/jj.ts +125 -4
- package/src/utils/lang-from-path.ts +7 -0
- package/src/utils/mac-file-urls.applescript +37 -0
- package/src/utils/title-generator.ts +137 -1
- package/src/utils/tool-choice.ts +14 -0
- package/src/utils/tools-manager.ts +1 -19
- 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
- package/dist/types/stt/recorder.d.ts +0 -30
- package/dist/types/stt/transcriber.d.ts +0 -14
- package/dist/types/stt/wav.d.ts +0 -29
- package/dist/types/tts/player.d.ts +0 -32
- package/src/stt/recorder.ts +0 -551
- package/src/stt/transcriber.ts +0 -60
- package/src/stt/wav.ts +0 -173
- package/src/tts/player.ts +0 -137
|
@@ -7,6 +7,7 @@ export interface SecretEntry {
|
|
|
7
7
|
mode?: "obfuscate" | "replace";
|
|
8
8
|
replacement?: string;
|
|
9
9
|
flags?: string;
|
|
10
|
+
friendlyName?: string;
|
|
10
11
|
}
|
|
11
12
|
export type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
12
13
|
[key: string]: JsonValue | undefined;
|
|
@@ -14,14 +15,105 @@ export type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
|
14
15
|
export type JsonRecord = {
|
|
15
16
|
[key: string]: JsonValue | undefined;
|
|
16
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* Whether a default (no custom `replacement`) replace-mode regex can never
|
|
20
|
+
* safely redact a 1-2 char match: `findNonMatchingReplacement`'s bounded
|
|
21
|
+
* search — the same search `#generateRegexReplacement` runs at match time —
|
|
22
|
+
* finds no candidate the regex fails to re-match. This holds independent of
|
|
23
|
+
* any actual per-install key: the search already exhausts every character in
|
|
24
|
+
* `REPLACEMENT_CHARS` (the alphabet `buildKeyedReplacementRun` draws its
|
|
25
|
+
* fallback marker from) plus punctuation and whitespace, so if none of those
|
|
26
|
+
* escape the regex, no key-derived marker drawn from the same alphabet can
|
|
27
|
+
* either — the marker is guaranteed to re-match too, making every such match
|
|
28
|
+
* unresolvable: the fallback could only ever emit the raw matched text
|
|
29
|
+
* unchanged. Probed with a value (`"\0".repeat(length)`) the bounded search
|
|
30
|
+
* never treats as a real candidate, so the result depends only on the
|
|
31
|
+
* regex's own matching behavior, not on this specific probe.
|
|
32
|
+
*/
|
|
33
|
+
export declare function regexHasUnresolvableShortMatchFallback(regex: RegExp): boolean;
|
|
34
|
+
export declare const MIN_OBFUSCATE_SECRET_LEN = 8;
|
|
35
|
+
/** Normalize a friendly name into the model-visible placeholder prefix. */
|
|
36
|
+
export declare function sanitizeSecretFriendlyName(name: string): string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Whether an entry needs the persisted placeholder key: either because it can
|
|
39
|
+
* produce a reversible (keyed) obfuscate-mode placeholder, or because a default
|
|
40
|
+
* (no custom `replacement`) replace-mode regex can reach
|
|
41
|
+
* `#generateRegexReplacement`'s key-derived idempotent fallback marker (see
|
|
42
|
+
* `#generateReplacement`) when every same-length candidate re-matches a
|
|
43
|
+
* pathological match-everything config (e.g. `[\s\S]{8}`). That fallback depends
|
|
44
|
+
* on the persisted per-install key — not just length — to stay a fixed point
|
|
45
|
+
* across a process restart; without a persisted key, a fresh install falls back
|
|
46
|
+
* to a process-random key (`defaultPlaceholderKey()`), so the fallback marker
|
|
47
|
+
* would churn across restarts even though the algorithm itself is stable. A
|
|
48
|
+
* regex WITH a custom `replacement` never reaches that fallback (it always emits
|
|
49
|
+
* the literal configured string), and a plain replace secret's replacement is
|
|
50
|
+
* pure content-hash (`#generateSecretReplacement`), so neither needs the key.
|
|
51
|
+
* Short plain obfuscate entries are toned down (never placeheld), so they must
|
|
52
|
+
* NOT force key creation: otherwise a `secret-placeholder.key` file is written
|
|
53
|
+
* and persisted for a config that ends up with no active secrets, leaving the
|
|
54
|
+
* key readable via a tool and reusable for later placeholders.
|
|
55
|
+
*/
|
|
56
|
+
export declare function secretEntryNeedsPlaceholderKey(entry: SecretEntry): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Whether a SET of entries needs the persisted placeholder key. `obfuscate()`
|
|
59
|
+
* applies plain replace-mode mappings before the plain-obfuscate pass, so a plain
|
|
60
|
+
* obfuscate entry only emits a reversible (keyed) placeholder when its content can
|
|
61
|
+
* still appear AFTER the replace phase. When no obfuscate entry can ever produce a
|
|
62
|
+
* placeholder, the persisted key must NOT be required/created — otherwise an
|
|
63
|
+
* effectively replace-only secret set still writes `secret-placeholder.key` and
|
|
64
|
+
* fails startup when the agent config dir is unwritable.
|
|
65
|
+
*
|
|
66
|
+
* The decision models the replace phase as the obfuscator actually runs it:
|
|
67
|
+
* replace mappings are content-keyed (later duplicate wins) and applied in
|
|
68
|
+
* descending content-length order; for a fresh probe (no prior placeholders) that
|
|
69
|
+
* phase is plain sequential substring replacement. A plain obfuscate entry needs
|
|
70
|
+
* the key when its content survives that simulated phase (direct typing) OR when
|
|
71
|
+
* any effective replacement can form the content via tiling — a substring,
|
|
72
|
+
* wholesale superstring, or prefix/suffix border that joins with surrounding
|
|
73
|
+
* passthrough bytes (see `replacementCanFormContent`). This covers direct
|
|
74
|
+
* shadowing (`SECRET -> safe`), reintroduction, duplicate ordering, transitive
|
|
75
|
+
* chains, and context-joined fragments uniformly. Default (omitted) replacements
|
|
76
|
+
* are deterministic, length-preserving, and distinct, so a same-content shadow
|
|
77
|
+
* with no other interacting replacement stays key-free.
|
|
78
|
+
* Replacement outputs are themselves rewritten by every later (shorter-content)
|
|
79
|
+
* replacement before the plain-obfuscate pass sees them, so a fragment that a
|
|
80
|
+
* subsequent replacement erases (`AA -> SEC` then `S -> X` turns every `SEC` into
|
|
81
|
+
* `XEC`) no longer forces the key. Surrounding bytes stay modeled as arbitrary
|
|
82
|
+
* passthrough, so testing the surviving fragment only drops false positives and
|
|
83
|
+
* never under-approximates a real key need.
|
|
84
|
+
*/
|
|
85
|
+
export declare function secretEntriesNeedPlaceholderKey(entries: SecretEntry[]): boolean;
|
|
86
|
+
export declare function stripPendingSecretPlaceholderSuffix(text: string): string;
|
|
17
87
|
export declare class SecretObfuscator {
|
|
18
88
|
#private;
|
|
19
|
-
constructor(entries: SecretEntry[]);
|
|
89
|
+
constructor(entries: SecretEntry[], key?: string);
|
|
20
90
|
hasSecrets(): boolean;
|
|
91
|
+
/** Whether stored-session restoration can resolve keyed or legacy placeholders. */
|
|
92
|
+
hasStoredSecrets(): boolean;
|
|
21
93
|
/** Obfuscate all secrets in text. Bidirectional placeholders for obfuscate mode, one-way for replace. */
|
|
22
|
-
obfuscate(text: string): string;
|
|
23
|
-
/**
|
|
94
|
+
obfuscate(text: string, sharedRegexSecretValues?: ReadonlySet<string>): string;
|
|
95
|
+
/**
|
|
96
|
+
* Deobfuscate keyed placeholders back to original secrets for LIVE paths
|
|
97
|
+
* (provider output, tool-call arguments). Replace-mode is NOT reversed, and
|
|
98
|
+
* legacy index-derived aliases are intentionally ignored so a prompt-injected
|
|
99
|
+
* model cannot synthesize one to recover a secret.
|
|
100
|
+
*/
|
|
24
101
|
deobfuscate(text: string): string;
|
|
102
|
+
/**
|
|
103
|
+
* Deobfuscate stored session content for replay/display. Identical to
|
|
104
|
+
* {@link deobfuscate} but additionally honors legacy index-derived aliases so
|
|
105
|
+
* sessions persisted before keyed placeholders still resume correctly. Use
|
|
106
|
+
* only for trusted on-disk session content, never for live model output.
|
|
107
|
+
*/
|
|
108
|
+
deobfuscateStored(text: string): string;
|
|
109
|
+
/** Deep-walk an object, deobfuscating string values for LIVE paths (keyed placeholders only). */
|
|
110
|
+
deobfuscateObject<T>(obj: T): T;
|
|
111
|
+
/** Deep-walk stored session content, deobfuscating string values incl. legacy aliases. */
|
|
112
|
+
deobfuscateStoredObject<T>(obj: T): T;
|
|
113
|
+
/** Deep-walk an object, obfuscating all string values. */
|
|
114
|
+
obfuscateObject<T>(obj: T): T;
|
|
115
|
+
collectRegexSecretValuesForObfuscation(text: string): Set<string>;
|
|
116
|
+
stripUnsafeFriendlyPlaceholderPrefixes(text: string, sharedRegexSecretValues: ReadonlySet<string>): string;
|
|
25
117
|
}
|
|
26
118
|
/**
|
|
27
119
|
* Restore secret placeholders for local display. Only message kinds the model
|
|
@@ -30,30 +122,36 @@ export declare class SecretObfuscator {
|
|
|
30
122
|
* tool-result messages are persisted with their literal text, so a literal
|
|
31
123
|
* `#ABCD#` the operator typed must survive untouched; those roles are never
|
|
32
124
|
* walked.
|
|
125
|
+
*
|
|
126
|
+
* Legacy index-derived aliases (`#XXXX#`) are unkeyed and trivially guessable,
|
|
127
|
+
* so a prompt-injected model can plant one in any record it influences. Every
|
|
128
|
+
* agent-feeding path (resume, history rewrite, branch switch) therefore restores
|
|
129
|
+
* keyed placeholders ONLY (`allowLegacyAliases` false), leaving legacy tokens
|
|
130
|
+
* inert; display-only transcripts that are never re-obfuscated opt in via
|
|
131
|
+
* `allowLegacyAliases`.
|
|
33
132
|
*/
|
|
34
|
-
export declare function deobfuscateSessionContext(sessionContext: SessionContext, obfuscator: SecretObfuscator | undefined): SessionContext;
|
|
35
|
-
export declare function deobfuscateAgentMessages(obfuscator: SecretObfuscator, messages: AgentMessage[]): AgentMessage[];
|
|
133
|
+
export declare function deobfuscateSessionContext(sessionContext: SessionContext, obfuscator: SecretObfuscator | undefined, allowLegacyAliases?: boolean): SessionContext;
|
|
134
|
+
export declare function deobfuscateAgentMessages(obfuscator: SecretObfuscator, messages: AgentMessage[], allowLegacyAliases?: boolean): AgentMessage[];
|
|
36
135
|
/**
|
|
37
136
|
* Restore placeholders in assistant content: visible text and tool-call
|
|
38
137
|
* arguments/intent/rawBlock. Thinking and signatures are opaque
|
|
39
138
|
* provider-replay/hidden-reasoning data and pass through byte-identical.
|
|
40
139
|
*/
|
|
41
|
-
export declare function deobfuscateAssistantContent(obfuscator: SecretObfuscator, content: AssistantMessage["content"]): AssistantMessage["content"];
|
|
140
|
+
export declare function deobfuscateAssistantContent(obfuscator: SecretObfuscator, content: AssistantMessage["content"], allowLegacyAliases?: boolean): AssistantMessage["content"];
|
|
42
141
|
/**
|
|
43
142
|
* Restore placeholders inside a tool call's arguments. Arguments are arbitrary
|
|
44
143
|
* model-authored JSON, so tool-call arguments are the ONLY place a recursive
|
|
45
144
|
* JSON walk runs.
|
|
46
145
|
*/
|
|
47
|
-
export declare function deobfuscateToolArguments(obfuscator: SecretObfuscator, args: Record<string, unknown
|
|
146
|
+
export declare function deobfuscateToolArguments(obfuscator: SecretObfuscator, args: Record<string, unknown>, allowLegacyAliases?: boolean): Record<string, unknown>;
|
|
48
147
|
/** Redact secrets inside a tool call's arguments (same JSON-walk exception as {@link deobfuscateToolArguments}). */
|
|
49
|
-
export declare function obfuscateToolArguments(obfuscator: SecretObfuscator, args: Record<string, unknown>): Record<string, unknown>;
|
|
50
|
-
/**
|
|
51
|
-
* Redact secrets from outbound messages.
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* bytes are never walked.
|
|
148
|
+
export declare function obfuscateToolArguments(obfuscator: SecretObfuscator, args: Record<string, unknown>, sharedRegexSecretValues?: ReadonlySet<string>): Record<string, unknown>;
|
|
149
|
+
/**
|
|
150
|
+
* Redact secrets from outbound messages. User messages, tool results, and
|
|
151
|
+
* user-authored developer messages (e.g. `@file` mentions) are obfuscated.
|
|
152
|
+
* Assistant replay content is re-obfuscated too, because session restoration
|
|
153
|
+
* expands keyed placeholders locally before the next provider request. Inline
|
|
154
|
+
* image bytes are never walked.
|
|
57
155
|
*/
|
|
58
156
|
export declare function obfuscateMessages(obfuscator: SecretObfuscator, messages: Message[]): Message[];
|
|
59
157
|
/**
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ClientBridgePermissionOption } from "./client-bridge.js";
|
|
2
|
+
/** Tools that require user permission before execution when an ACP client is connected. */
|
|
3
|
+
export declare const PERMISSION_REQUIRED_TOOLS: Record<string, true>;
|
|
4
|
+
/** Permission options presented to the client on each gated tool call. */
|
|
5
|
+
export declare const PERMISSION_OPTIONS: ClientBridgePermissionOption[];
|
|
6
|
+
/** Permission options indexed by their wire identifiers; unknown IDs miss and fail closed. */
|
|
7
|
+
export declare const PERMISSION_OPTIONS_BY_ID: Map<string, ClientBridgePermissionOption>;
|
|
8
|
+
/** Describes the permission prompt required for a destructive tool call. */
|
|
9
|
+
export declare function getPermissionIntent(toolName: string, args: unknown): {
|
|
10
|
+
toolName: string;
|
|
11
|
+
title: string;
|
|
12
|
+
paths?: string[];
|
|
13
|
+
cacheKey: string;
|
|
14
|
+
} | undefined;
|
|
15
|
+
/** Converts tool path arguments into absolute ACP editor locations. */
|
|
16
|
+
export declare function extractPermissionLocations(args: unknown, cwd: string, explicitPaths?: string[]): {
|
|
17
|
+
path: string;
|
|
18
|
+
line?: number;
|
|
19
|
+
}[];
|
|
@@ -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,321 @@
|
|
|
1
|
+
import type { Agent, AgentMessage, AgentTool, StreamFn, ThinkingLevel } from "@oh-my-pi/pi-agent-core";
|
|
2
|
+
import type { Context, ImageContent, Message, MessageAttribution, Model, OAuthAccountSummary, 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
|
+
/** Creates the built-in `computer` tool for session-scoped runtime enablement (see {@link AgentSession.setComputerToolEnabled}). */
|
|
121
|
+
createComputerTool?: () => Promise<AgentTool | null>;
|
|
122
|
+
/** Model registry for API key resolution and model discovery. */
|
|
123
|
+
modelRegistry: ModelRegistry;
|
|
124
|
+
/** Tool registry for LSP and settings. */
|
|
125
|
+
toolRegistry?: Map<string, AgentTool>;
|
|
126
|
+
/** Creates tools registered only while vibe mode is active. */
|
|
127
|
+
createVibeTools?: () => AgentTool[];
|
|
128
|
+
/** Names whose current registry entry is the built-in implementation. */
|
|
129
|
+
builtInToolNames?: Iterable<string>;
|
|
130
|
+
/** Updates tool-session predicates from the live active tool set. */
|
|
131
|
+
setActiveToolNames?: (names: Iterable<string>) => void;
|
|
132
|
+
/** Registers the write transport when runtime xdev mounts first need it. */
|
|
133
|
+
ensureWriteRegistered?: () => Promise<boolean>;
|
|
134
|
+
/** Current session pre-LLM message transform pipeline. */
|
|
135
|
+
transformContext?: (messages: AgentMessage[], signal?: AbortSignal) => AgentMessage[] | Promise<AgentMessage[]>;
|
|
136
|
+
/** Provider request transform applied after message conversion. */
|
|
137
|
+
transformProviderContext?: (context: Context, model: Model) => Context | Promise<Context>;
|
|
138
|
+
/** Stream wrapper for side-channel requests. */
|
|
139
|
+
sideStreamFn?: StreamFn;
|
|
140
|
+
/** Stream wrapper for advisor requests. */
|
|
141
|
+
advisorStreamFn?: StreamFn;
|
|
142
|
+
/** Prefer websocket transport for OpenAI Codex requests when supported. */
|
|
143
|
+
preferWebsockets?: boolean;
|
|
144
|
+
/** Provider payload hook used by the active session request path. */
|
|
145
|
+
onPayload?: SimpleStreamOptions["onPayload"];
|
|
146
|
+
/** Provider response hook used by the active session request path. */
|
|
147
|
+
onResponse?: SimpleStreamOptions["onResponse"];
|
|
148
|
+
/** Raw SSE hook used by the active session request path. */
|
|
149
|
+
onSseEvent?: SimpleStreamOptions["onSseEvent"];
|
|
150
|
+
/** Per-session raw SSE diagnostic buffer. */
|
|
151
|
+
rawSseDebugBuffer?: RawSseDebugBuffer;
|
|
152
|
+
/** Current session message-to-LLM conversion pipeline. */
|
|
153
|
+
convertToLlm?: (messages: AgentMessage[]) => Message[] | Promise<Message[]>;
|
|
154
|
+
/** System prompt builder that can consider tool availability. */
|
|
155
|
+
rebuildSystemPrompt?: (toolNames: string[], tools: Map<string, AgentTool>) => Promise<{
|
|
156
|
+
systemPrompt: string[];
|
|
157
|
+
}>;
|
|
158
|
+
/** Local calendar date provider used by prompt-cache invalidation. */
|
|
159
|
+
getLocalCalendarDate?: () => string;
|
|
160
|
+
/** Tools mounted under `xd://`, for `/tools` display. */
|
|
161
|
+
getXdevToolEntries?: () => Array<{
|
|
162
|
+
name: string;
|
|
163
|
+
summary: string;
|
|
164
|
+
}>;
|
|
165
|
+
/** Session-owned `xd://` registry. */
|
|
166
|
+
xdevRegistry?: XdevRegistry;
|
|
167
|
+
/** Discoverable tools mounted under `xd://` in the initial enabled set. */
|
|
168
|
+
initialMountedXdevToolNames?: string[];
|
|
169
|
+
/** Names pinned top-level during runtime repartitioning. */
|
|
170
|
+
presentationPinnedToolNames?: ReadonlySet<string>;
|
|
171
|
+
/** Accessor for live MCP server instructions. */
|
|
172
|
+
getMcpServerInstructions?: () => Map<string, string> | undefined;
|
|
173
|
+
/** Time-traveling stream-rule manager. */
|
|
174
|
+
ttsrManager?: TtsrManager;
|
|
175
|
+
/** Secret obfuscator for provider and edit content. */
|
|
176
|
+
obfuscator?: SecretObfuscator;
|
|
177
|
+
/** Inherited eval executor session id from a parent agent. */
|
|
178
|
+
parentEvalSessionId?: string;
|
|
179
|
+
/** Logical owner for retained eval kernels created by this session. */
|
|
180
|
+
evalKernelOwnerId?: string;
|
|
181
|
+
/** Async job manager owned and disposed by this session. */
|
|
182
|
+
ownedAsyncJobManager?: AsyncJobManager;
|
|
183
|
+
/** Async job manager visible to this session. */
|
|
184
|
+
asyncJobManager?: AsyncJobManager;
|
|
185
|
+
/** Registry identity used for IRC routing. */
|
|
186
|
+
agentId?: string;
|
|
187
|
+
/** Whether this is a top-level or subagent session. */
|
|
188
|
+
agentKind?: "main" | "sub";
|
|
189
|
+
/** Provider-facing session ID override. */
|
|
190
|
+
providerSessionId?: string;
|
|
191
|
+
/** Whether the provider prompt-cache key was explicit or fork-inherited. */
|
|
192
|
+
providerPromptCacheKeySource?: "explicit" | "fork";
|
|
193
|
+
/** Full advisor toolset built against an advisor-scoped tool session. */
|
|
194
|
+
advisorTools?: AgentTool[];
|
|
195
|
+
/** Preloaded watchdog prompt content for the advisor. */
|
|
196
|
+
advisorWatchdogPrompt?: string;
|
|
197
|
+
/** Shared advisor instructions loaded from WATCHDOG.yml. */
|
|
198
|
+
advisorSharedInstructions?: string;
|
|
199
|
+
/** Project context rendered for advisor sessions. */
|
|
200
|
+
advisorContextPrompt?: string;
|
|
201
|
+
/** Advisors discovered from WATCHDOG.yml. */
|
|
202
|
+
advisorConfigs?: AdvisorConfig[];
|
|
203
|
+
/** Strip tool descriptions from provider-bound side-request tool specs. */
|
|
204
|
+
pruneToolDescriptions?: boolean;
|
|
205
|
+
/** Disconnect the MCP manager owned by this session during disposal. */
|
|
206
|
+
disconnectOwnedMcpManager?: () => Promise<void>;
|
|
207
|
+
/** System prompt used by automatic session-title generation. */
|
|
208
|
+
titleSystemPrompt?: string;
|
|
209
|
+
}
|
|
210
|
+
/** Options for AgentSession.prompt(). */
|
|
211
|
+
export interface PromptOptions {
|
|
212
|
+
/** Whether to expand file-based prompt templates (default: true). */
|
|
213
|
+
expandPromptTemplates?: boolean;
|
|
214
|
+
/** Image attachments. */
|
|
215
|
+
images?: ImageContent[];
|
|
216
|
+
/** Queue behavior while streaming. */
|
|
217
|
+
streamingBehavior?: "steer" | "followUp";
|
|
218
|
+
/** Optional tool choice override for the next LLM call. */
|
|
219
|
+
toolChoice?: ToolChoice;
|
|
220
|
+
/** Send as a developer/system message instead of user. */
|
|
221
|
+
synthetic?: boolean;
|
|
222
|
+
/** Whether this prompt is a deliberate user action. */
|
|
223
|
+
userInitiated?: boolean;
|
|
224
|
+
/** Explicit billing/initiator attribution. */
|
|
225
|
+
attribution?: MessageAttribution;
|
|
226
|
+
/** Skip pre-send compaction checks for this prompt. */
|
|
227
|
+
skipCompactionCheck?: boolean;
|
|
228
|
+
}
|
|
229
|
+
/** Options for AgentSession.followUp(). */
|
|
230
|
+
export interface FollowUpOptions {
|
|
231
|
+
/** Enqueue as a hidden developer message instead of a user follow-up. */
|
|
232
|
+
synthetic?: boolean;
|
|
233
|
+
/** Whether to expand file-based prompt templates (default: true). */
|
|
234
|
+
expandPromptTemplates?: boolean;
|
|
235
|
+
/** Explicit billing/initiator attribution. */
|
|
236
|
+
attribution?: MessageAttribution;
|
|
237
|
+
}
|
|
238
|
+
/** Result from a handoff operation. */
|
|
239
|
+
export interface HandoffResult {
|
|
240
|
+
document: string;
|
|
241
|
+
savedPath?: string;
|
|
242
|
+
}
|
|
243
|
+
/** Options controlling handoff generation. */
|
|
244
|
+
export interface SessionHandoffOptions {
|
|
245
|
+
autoTriggered?: boolean;
|
|
246
|
+
signal?: AbortSignal;
|
|
247
|
+
onSwitchCancelled?: () => void;
|
|
248
|
+
}
|
|
249
|
+
/** Result from cycleModel(). */
|
|
250
|
+
export interface ModelCycleResult {
|
|
251
|
+
model: Model;
|
|
252
|
+
thinkingLevel: ThinkingLevel | undefined;
|
|
253
|
+
/** Whether cycling through scoped models or all available models. */
|
|
254
|
+
isScoped: boolean;
|
|
255
|
+
}
|
|
256
|
+
/** Result from cycleRoleModels(). */
|
|
257
|
+
export interface RoleModelCycleResult {
|
|
258
|
+
model: Model;
|
|
259
|
+
thinkingLevel: ThinkingLevel | undefined;
|
|
260
|
+
role: string;
|
|
261
|
+
}
|
|
262
|
+
/** A configured role resolved to a concrete model. */
|
|
263
|
+
export interface ResolvedRoleModel {
|
|
264
|
+
role: string;
|
|
265
|
+
model: Model;
|
|
266
|
+
thinkingLevel?: ConfiguredThinkingLevel;
|
|
267
|
+
explicitThinkingLevel: boolean;
|
|
268
|
+
}
|
|
269
|
+
/** Resolvable role models and the currently active index. */
|
|
270
|
+
export interface RoleModelCycle {
|
|
271
|
+
models: ResolvedRoleModel[];
|
|
272
|
+
currentIndex: number;
|
|
273
|
+
}
|
|
274
|
+
/** Token breakdown for the current provider context. */
|
|
275
|
+
export interface ContextUsageBreakdown {
|
|
276
|
+
contextWindow: number;
|
|
277
|
+
anchored: boolean;
|
|
278
|
+
usedTokens: number;
|
|
279
|
+
systemPromptTokens: number;
|
|
280
|
+
systemToolsTokens: number;
|
|
281
|
+
systemContextTokens: number;
|
|
282
|
+
skillsTokens: number;
|
|
283
|
+
messagesTokens: number;
|
|
284
|
+
}
|
|
285
|
+
/** Session statistics for the `/session` command. */
|
|
286
|
+
export interface SessionStats {
|
|
287
|
+
sessionFile: string | undefined;
|
|
288
|
+
sessionId: string;
|
|
289
|
+
userMessages: number;
|
|
290
|
+
assistantMessages: number;
|
|
291
|
+
toolCalls: number;
|
|
292
|
+
toolResults: number;
|
|
293
|
+
totalMessages: number;
|
|
294
|
+
tokens: {
|
|
295
|
+
input: number;
|
|
296
|
+
output: number;
|
|
297
|
+
reasoning: number;
|
|
298
|
+
cacheRead: number;
|
|
299
|
+
cacheWrite: number;
|
|
300
|
+
total: number;
|
|
301
|
+
};
|
|
302
|
+
premiumRequests: number;
|
|
303
|
+
cost: number;
|
|
304
|
+
contextUsage?: ContextUsage;
|
|
305
|
+
}
|
|
306
|
+
/** Stored OAuth accounts available to the current model provider. */
|
|
307
|
+
export interface SessionOAuthAccountList {
|
|
308
|
+
provider: string;
|
|
309
|
+
accounts: OAuthAccountSummary[];
|
|
310
|
+
}
|
|
311
|
+
/** IDs for a newly created session and the session it replaced. */
|
|
312
|
+
export interface FreshSessionResult {
|
|
313
|
+
previousSessionId: string;
|
|
314
|
+
sessionId: string;
|
|
315
|
+
closedProviderSessions: number;
|
|
316
|
+
}
|
|
317
|
+
/** Queued user content restored to the editor. */
|
|
318
|
+
export type RestoredQueuedMessage = {
|
|
319
|
+
text: string;
|
|
320
|
+
images?: ImageContent[];
|
|
321
|
+
};
|