@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,56 @@
|
|
|
1
|
+
/** Session memory backend lifecycle and transcript resets. */
|
|
2
|
+
import type { Agent, AgentTool } from "@oh-my-pi/pi-agent-core";
|
|
3
|
+
import type { ModelRegistry } from "../config/model-registry.js";
|
|
4
|
+
import type { Settings } from "../config/settings.js";
|
|
5
|
+
import type { HindsightSessionState } from "../hindsight/state.js";
|
|
6
|
+
import type { MemoryBackendStartOptions } from "../memory-backend/types.js";
|
|
7
|
+
import type { MnemopiSessionState } from "../mnemopi/state.js";
|
|
8
|
+
/** Capabilities borrowed from the owning AgentSession. */
|
|
9
|
+
export interface SessionMemoryHost {
|
|
10
|
+
agent: Agent;
|
|
11
|
+
settings: Settings;
|
|
12
|
+
modelRegistry: ModelRegistry;
|
|
13
|
+
isDisposed(): boolean;
|
|
14
|
+
memoryBackendSession(): MemoryBackendStartOptions["session"];
|
|
15
|
+
getHindsightSessionState(): HindsightSessionState | undefined;
|
|
16
|
+
setHindsightSessionState(state: HindsightSessionState | undefined): void;
|
|
17
|
+
getMnemopiSessionState(): MnemopiSessionState | undefined;
|
|
18
|
+
takeMnemopiSessionState(): MnemopiSessionState | undefined;
|
|
19
|
+
setBaseSystemPrompt(prompt: string[]): void;
|
|
20
|
+
refreshBaseSystemPrompt(): Promise<void>;
|
|
21
|
+
replaceMemoryTools(tools: AgentTool[]): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
/** Owns memory backend transitions and transcript-scoped memory state. */
|
|
24
|
+
export declare class SessionMemory {
|
|
25
|
+
#private;
|
|
26
|
+
constructor(host: SessionMemoryHost, options: {
|
|
27
|
+
memoryAgentDir?: string;
|
|
28
|
+
memoryTaskDepth?: number;
|
|
29
|
+
createMemoryTools?: () => Promise<AgentTool[]>;
|
|
30
|
+
});
|
|
31
|
+
/** Current serialized backend transition, used by prompt and disposal drains. */
|
|
32
|
+
get transition(): Promise<void>;
|
|
33
|
+
/** Base prompt captured before a per-turn memory promotion. */
|
|
34
|
+
get promotionSnapshot(): string[] | undefined;
|
|
35
|
+
/** Clears the per-turn memory promotion after a canonical prompt rebuild. */
|
|
36
|
+
clearPromotionSnapshot(): void;
|
|
37
|
+
/** Captures the canonical prompt before the first per-turn memory promotion. */
|
|
38
|
+
capturePromotionSnapshot(prompt: string[]): void;
|
|
39
|
+
/** Restores a promotion snapshot while rolling back a failed session switch. */
|
|
40
|
+
restorePromotionSnapshot(prompt: string[] | undefined): void;
|
|
41
|
+
/** Rekeys every active memory backend to the current provider session. */
|
|
42
|
+
rekeyForCurrentSessionId(): void;
|
|
43
|
+
/** Resets transcript-scoped memory counters and removes a promoted prompt. */
|
|
44
|
+
resetContextForNewTranscript(): Promise<void>;
|
|
45
|
+
/** Cancel the local rollout-memory startup owned by this session. */
|
|
46
|
+
cancelLocalMemoryStartup(): void;
|
|
47
|
+
/** Start a new local rollout-memory generation and cancel its predecessor. */
|
|
48
|
+
beginLocalMemoryStartup(): AbortSignal;
|
|
49
|
+
/** Release the local startup slot if `signal` still owns it. */
|
|
50
|
+
endLocalMemoryStartup(signal: AbortSignal): void;
|
|
51
|
+
/**
|
|
52
|
+
* Apply the selected memory backend to runtime state, tools, and prompt.
|
|
53
|
+
* Concurrent settings changes run in order and settle before the next turn.
|
|
54
|
+
*/
|
|
55
|
+
applyMemoryBackend(): Promise<void>;
|
|
56
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/** Provider-facing message, image, secret, and stream normalization for a session. */
|
|
2
|
+
import type { Agent, AgentMessage } from "@oh-my-pi/pi-agent-core";
|
|
3
|
+
import type { CompactionPreparation } from "@oh-my-pi/pi-agent-core/compaction";
|
|
4
|
+
import type { ImageContent, Message, Model, SimpleStreamOptions } from "@oh-my-pi/pi-ai";
|
|
5
|
+
import type { ModelRegistry } from "../config/model-registry.js";
|
|
6
|
+
import type { Settings } from "../config/settings.js";
|
|
7
|
+
import type { LocalProtocolOptions } from "../internal-urls/index.js";
|
|
8
|
+
import { type SecretObfuscator } from "../secrets/obfuscator.js";
|
|
9
|
+
import { type CustomMessage } from "./messages.js";
|
|
10
|
+
import type { BuildSessionContextOptions, SessionContext } from "./session-context.js";
|
|
11
|
+
import type { SessionManager } from "./session-manager.js";
|
|
12
|
+
/** Capabilities borrowed from the owning AgentSession. */
|
|
13
|
+
export interface SessionProviderBoundaryHost {
|
|
14
|
+
agent: Agent;
|
|
15
|
+
sessionManager: SessionManager;
|
|
16
|
+
settings: Settings;
|
|
17
|
+
modelRegistry: ModelRegistry;
|
|
18
|
+
model(): Model | undefined;
|
|
19
|
+
sessionId(): string;
|
|
20
|
+
localProtocolOptions(): LocalProtocolOptions;
|
|
21
|
+
transformContext(messages: AgentMessage[], signal?: AbortSignal): AgentMessage[] | Promise<AgentMessage[]>;
|
|
22
|
+
convertToLlm(messages: AgentMessage[]): Message[] | Promise<Message[]>;
|
|
23
|
+
onPayload: SimpleStreamOptions["onPayload"] | undefined;
|
|
24
|
+
onResponse: SimpleStreamOptions["onResponse"] | undefined;
|
|
25
|
+
onSseEvent: SimpleStreamOptions["onSseEvent"] | undefined;
|
|
26
|
+
obfuscator: SecretObfuscator | undefined;
|
|
27
|
+
}
|
|
28
|
+
/** Owns the transformations at the session/provider boundary. */
|
|
29
|
+
export declare class SessionProviderBoundary {
|
|
30
|
+
#private;
|
|
31
|
+
constructor(host: SessionProviderBoundaryHost);
|
|
32
|
+
/** Latest image attachments addressable by tools as `Image #N` or `attachment://N`. */
|
|
33
|
+
getImageAttachments(): {
|
|
34
|
+
label: string;
|
|
35
|
+
uri: string;
|
|
36
|
+
image: ImageContent;
|
|
37
|
+
}[];
|
|
38
|
+
/** Builds the current deobfuscated context for agent display and replay. */
|
|
39
|
+
buildDisplaySessionContext(): SessionContext;
|
|
40
|
+
/** Builds the full display-only transcript context. */
|
|
41
|
+
buildTranscriptSessionContext(options?: Pick<BuildSessionContextOptions, "collapseCompactedHistory" | "keepDanglingToolCalls">): SessionContext;
|
|
42
|
+
/** Obfuscates optional plaintext before a provider request. */
|
|
43
|
+
obfuscateText(text: string | undefined): string | undefined;
|
|
44
|
+
/** Obfuscates summaries and snapcompact plaintext carried into compaction. */
|
|
45
|
+
obfuscateCompactionPreparation(preparation: CompactionPreparation): CompactionPreparation;
|
|
46
|
+
/** Deobfuscates provider text before exposing it to the session. */
|
|
47
|
+
deobfuscateText(text: string): string;
|
|
48
|
+
/** Deobfuscates a streamed delta and removes an incomplete secret placeholder suffix. */
|
|
49
|
+
deobfuscateDelta(text: string): string;
|
|
50
|
+
/** Converts side-request messages through the session's secret boundary. */
|
|
51
|
+
convertToLlmForSideRequest(messages: AgentMessage[]): Message[];
|
|
52
|
+
/** Converts session messages using the configured pre-LLM pipeline. */
|
|
53
|
+
convertMessagesToLlm(messages: AgentMessage[], signal?: AbortSignal): Promise<Message[]>;
|
|
54
|
+
/** Applies session-level stream hooks and provider defaults to a side request. */
|
|
55
|
+
prepareSimpleStreamOptions(options: SimpleStreamOptions, provider?: string): SimpleStreamOptions;
|
|
56
|
+
/** Normalizes image payloads for the active model. */
|
|
57
|
+
normalizeImagesForModel(images: ImageContent[] | undefined): Promise<ImageContent[] | undefined>;
|
|
58
|
+
/** Builds a hidden vision-model description for attachments sent to a text-only model. */
|
|
59
|
+
buildImageDescriptionNotice(normalizedImages: ImageContent[], signal?: AbortSignal): Promise<CustomMessage | undefined>;
|
|
60
|
+
/** Normalizes every image embedded in an agent message. */
|
|
61
|
+
normalizeAgentMessageImages<T extends AgentMessage>(message: T): Promise<T>;
|
|
62
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Agent, AgentMessage } from "@oh-my-pi/pi-agent-core";
|
|
2
|
+
import type { Model, ProviderResponseMetadata } from "@oh-my-pi/pi-ai";
|
|
3
|
+
import type { ModelRegistry } from "../config/model-registry.js";
|
|
4
|
+
import type { ContextUsage } from "../extensibility/extensions/types.js";
|
|
5
|
+
import { type NonMessageTokenSource } from "../modes/utils/context-usage.js";
|
|
6
|
+
import type { ContextUsageBreakdown, SessionStats } from "./agent-session-types.js";
|
|
7
|
+
import type { SessionManager } from "./session-manager.js";
|
|
8
|
+
interface PendingContextSnapshot {
|
|
9
|
+
promptTokens: number;
|
|
10
|
+
nonMessageTokens: number;
|
|
11
|
+
cutoffCount: number;
|
|
12
|
+
}
|
|
13
|
+
/** Capabilities the stats tracker borrows from its owning session. */
|
|
14
|
+
export interface SessionStatsTrackerHost {
|
|
15
|
+
session: NonMessageTokenSource;
|
|
16
|
+
agent: Agent;
|
|
17
|
+
sessionManager: SessionManager;
|
|
18
|
+
modelRegistry: ModelRegistry;
|
|
19
|
+
model(): Model | undefined;
|
|
20
|
+
sessionId(): string;
|
|
21
|
+
}
|
|
22
|
+
/** Computes session totals and tracks the in-flight context estimate. */
|
|
23
|
+
export declare class SessionStatsTracker {
|
|
24
|
+
#private;
|
|
25
|
+
constructor(host: SessionStatsTrackerHost);
|
|
26
|
+
/** Returns aggregate message, token, and cost statistics for the session. */
|
|
27
|
+
getSessionStats(): SessionStats;
|
|
28
|
+
/** Returns the current provider-context token breakdown. */
|
|
29
|
+
getContextBreakdown(options?: {
|
|
30
|
+
contextWindow?: number;
|
|
31
|
+
pendingMessages?: AgentMessage[];
|
|
32
|
+
}): ContextUsageBreakdown | undefined;
|
|
33
|
+
/** Returns current context tokens, capacity, and percentage. */
|
|
34
|
+
getContextUsage(options?: {
|
|
35
|
+
contextWindow?: number;
|
|
36
|
+
}): ContextUsage | undefined;
|
|
37
|
+
/** Monotonic revision for in-flight context snapshot changes. */
|
|
38
|
+
get revision(): number;
|
|
39
|
+
/** Non-message token count captured for the active provider request. */
|
|
40
|
+
get pendingNonMessageTokens(): number | undefined;
|
|
41
|
+
/** Sets or clears the in-flight context snapshot. */
|
|
42
|
+
setPendingSnapshot(snapshot: PendingContextSnapshot | undefined): void;
|
|
43
|
+
/** Recomputes an in-flight snapshot after history is compacted or rewritten. */
|
|
44
|
+
rebaseAfterCompaction(): void;
|
|
45
|
+
/** Records provider usage headers against the active session account. */
|
|
46
|
+
ingestProviderUsageHeaders(response: ProviderResponseMetadata, model?: Model): void;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import type { Agent, AgentTool } from "@oh-my-pi/pi-agent-core";
|
|
2
|
+
import type { Model } from "@oh-my-pi/pi-ai";
|
|
3
|
+
import type { ModelRegistry } from "../config/model-registry.js";
|
|
4
|
+
import type { Settings, SkillsSettings } from "../config/settings.js";
|
|
5
|
+
import type { CustomTool } from "../extensibility/custom-tools/types.js";
|
|
6
|
+
import type { ExtensionRunner } from "../extensibility/extensions/index.js";
|
|
7
|
+
import { type Skill, type SkillWarning } from "../extensibility/skills.js";
|
|
8
|
+
import type { LocalProtocolOptions } from "../internal-urls/index.js";
|
|
9
|
+
import type { MemoryBackendStartOptions } from "../memory-backend/types.js";
|
|
10
|
+
import { type XdevRegistry } from "../tools/xdev.js";
|
|
11
|
+
import { type EditMode } from "../utils/edit-mode.js";
|
|
12
|
+
import type { ClientBridge } from "./client-bridge.js";
|
|
13
|
+
import type { CustomMessage } from "./messages.js";
|
|
14
|
+
import type { SessionManager } from "./session-manager.js";
|
|
15
|
+
/** Capabilities borrowed from the owning AgentSession. */
|
|
16
|
+
export interface SessionToolsHost {
|
|
17
|
+
agent: Agent;
|
|
18
|
+
sessionManager: SessionManager;
|
|
19
|
+
settings: Settings;
|
|
20
|
+
modelRegistry: ModelRegistry;
|
|
21
|
+
extensionRunner(): ExtensionRunner | undefined;
|
|
22
|
+
clientBridge(): ClientBridge | undefined;
|
|
23
|
+
agentKind(): "main" | "sub";
|
|
24
|
+
isDisposed(): boolean;
|
|
25
|
+
isStreaming(): boolean;
|
|
26
|
+
queuedMessageCount(): number;
|
|
27
|
+
planModeEnabled(): boolean;
|
|
28
|
+
model(): Model | undefined;
|
|
29
|
+
memoryBackendSession(): MemoryBackendStartOptions["session"];
|
|
30
|
+
clearInheritedProviderPromptCacheKey(): void;
|
|
31
|
+
clearMemoryPromotionSnapshot(): void;
|
|
32
|
+
captureMemoryPromotionSnapshot(prompt: string[]): void;
|
|
33
|
+
emitNotice(level: "info" | "warning" | "error", message: string, source?: string): void;
|
|
34
|
+
notifyCommandMetadataChanged(): void;
|
|
35
|
+
localProtocolOptions(): LocalProtocolOptions;
|
|
36
|
+
}
|
|
37
|
+
interface SessionToolsOptions {
|
|
38
|
+
autoApprove?: boolean;
|
|
39
|
+
toolRegistry?: Map<string, AgentTool>;
|
|
40
|
+
createVibeTools?: () => AgentTool[];
|
|
41
|
+
builtInToolNames?: Iterable<string>;
|
|
42
|
+
presentationPinnedToolNames?: ReadonlySet<string>;
|
|
43
|
+
ensureWriteRegistered?: () => Promise<boolean>;
|
|
44
|
+
rebuildSystemPrompt?: (toolNames: string[], tools: Map<string, AgentTool>) => Promise<{
|
|
45
|
+
systemPrompt: string[];
|
|
46
|
+
}>;
|
|
47
|
+
getLocalCalendarDate?: () => string;
|
|
48
|
+
getMcpServerInstructions?: () => Map<string, string> | undefined;
|
|
49
|
+
xdevRegistry?: XdevRegistry;
|
|
50
|
+
initialMountedXdevToolNames?: string[];
|
|
51
|
+
setActiveToolNames?: (names: Iterable<string>) => void;
|
|
52
|
+
baseSystemPrompt: string[];
|
|
53
|
+
skills?: Skill[];
|
|
54
|
+
skillWarnings?: SkillWarning[];
|
|
55
|
+
skillsSettings?: SkillsSettings;
|
|
56
|
+
skillsReloadable?: boolean;
|
|
57
|
+
}
|
|
58
|
+
/** Owns tool registration, presentation, prompt rebuilding, skills, and permissions. */
|
|
59
|
+
export declare class SessionTools {
|
|
60
|
+
#private;
|
|
61
|
+
constructor(host: SessionToolsHost, options: SessionToolsOptions);
|
|
62
|
+
/** Mutable registry shared with controller hosts that inspect available tools. */
|
|
63
|
+
get registry(): Map<string, AgentTool>;
|
|
64
|
+
/** Current stable base system prompt. */
|
|
65
|
+
get baseSystemPrompt(): string[];
|
|
66
|
+
/** Replaces the controller-owned base prompt without applying it to the agent. */
|
|
67
|
+
setBaseSystemPrompt(prompt: string[]): void;
|
|
68
|
+
/** Skills currently rendered into the system prompt. */
|
|
69
|
+
get skills(): Skill[];
|
|
70
|
+
/** Diagnostics produced while loading the current skills. */
|
|
71
|
+
get skillWarnings(): SkillWarning[];
|
|
72
|
+
/** Settings snapshot used for the current skill discovery. */
|
|
73
|
+
get skillsSettings(): SkillsSettings | undefined;
|
|
74
|
+
/** Drops cached per-session ACP `allow_always`/`reject_always` decisions. */
|
|
75
|
+
clearAcpPermissionDecisions(): void;
|
|
76
|
+
/** Re-wraps active and mounted tools after the ACP client changes. */
|
|
77
|
+
refreshAcpPermissionGates(): void;
|
|
78
|
+
/** Names of tools currently exposed at the top level. */
|
|
79
|
+
getActiveToolNames(): string[];
|
|
80
|
+
/** Enabled top-level and discoverable tool names. */
|
|
81
|
+
getEnabledToolNames(): string[];
|
|
82
|
+
/** Names of dynamic tools mounted under `xd://`. */
|
|
83
|
+
getMountedXdevToolNames(): string[];
|
|
84
|
+
/** Whether the edit tool is registered. */
|
|
85
|
+
get hasEditTool(): boolean;
|
|
86
|
+
/** Looks up a registered tool by name. */
|
|
87
|
+
getToolByName(name: string): AgentTool | undefined;
|
|
88
|
+
/** Whether a registry entry came from a built-in factory. */
|
|
89
|
+
hasBuiltInTool(name: string): boolean;
|
|
90
|
+
/** Names of every registered tool. */
|
|
91
|
+
getAllToolNames(): string[];
|
|
92
|
+
/** Installs and activates the ephemeral vibe tool set. */
|
|
93
|
+
activateVibeTools(baseToolNames: string[]): Promise<void>;
|
|
94
|
+
/** Uninstalls vibe tools and activates the replacement set. */
|
|
95
|
+
deactivateVibeTools(nextToolNames: string[]): Promise<void>;
|
|
96
|
+
/** Removes vibe tools without restoring a source-session snapshot. */
|
|
97
|
+
removeVibeToolsPreservingActive(): Promise<void>;
|
|
98
|
+
/** Resolves the edit mode for the active model and settings. */
|
|
99
|
+
resolveActiveEditMode(): EditMode;
|
|
100
|
+
/** Rebuilds model-dependent tool prompts after a model change. */
|
|
101
|
+
syncAfterModelChange(previousEditMode: EditMode): Promise<void>;
|
|
102
|
+
/** Enabled MCP tools in their current presentation partition. */
|
|
103
|
+
getSelectedMCPToolNames(): string[];
|
|
104
|
+
/** Applies an enabled tool set and reconciles its `xd://` partition. */
|
|
105
|
+
applyActiveToolsByName(toolNames: string[]): Promise<void>;
|
|
106
|
+
/** Consumes the hidden notice for unannounced `xd://` mount changes. */
|
|
107
|
+
takePendingXdevMountNotice(): CustomMessage | undefined;
|
|
108
|
+
/** Rediscovers reloadable skills and refreshes prompt metadata. */
|
|
109
|
+
refreshSkills(): Promise<void>;
|
|
110
|
+
/** Selects enabled tools, ignoring names absent from the registry. */
|
|
111
|
+
setActiveToolsByName(toolNames: string[]): Promise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Restore an enabled tool set with its exact top-level versus `xd://` partition.
|
|
114
|
+
*
|
|
115
|
+
* Both inputs are required because {@link setActiveToolsByName} only receives the
|
|
116
|
+
* enabled name list and classifies mounts from the current `#mountedXdevToolNames`.
|
|
117
|
+
* Rollback/restore callers must pass the snapshotted mounted subset so names that
|
|
118
|
+
* were top-level stay pinned (`#runtimeSelectedToolNames`) and names that were under
|
|
119
|
+
* `xd://` remain mount-eligible, even when the live mount set has drifted.
|
|
120
|
+
*
|
|
121
|
+
* Names outside `mountedToolNames` are pinned top-level for this application;
|
|
122
|
+
* names in the mounted subset remain eligible for xdev mounting. Delegates the
|
|
123
|
+
* actual apply through {@link applyActiveToolsByName} and restores the prior runtime
|
|
124
|
+
* selection if that apply throws.
|
|
125
|
+
*/
|
|
126
|
+
setActiveToolPresentation(toolNames: string[], mountedToolNames: string[]): Promise<void>;
|
|
127
|
+
/** Replaces memory-backend tools while preserving unrelated selections. */
|
|
128
|
+
replaceMemoryTools(tools: AgentTool[]): Promise<void>;
|
|
129
|
+
/** Rebuilds the stable base prompt for the current tools and model. */
|
|
130
|
+
refreshBaseSystemPrompt(): Promise<void>;
|
|
131
|
+
/** Applies one-turn memory prompt injection before an agent run. */
|
|
132
|
+
buildSystemPromptForAgentStart(promptText: string): Promise<string[]>;
|
|
133
|
+
/**
|
|
134
|
+
* Replace MCP tools in the registry and enable them immediately. Every
|
|
135
|
+
* connected MCP tool becomes available (mounted under `xd://` when that
|
|
136
|
+
* transport is active, else top-level). Lets `/mcp add/remove/reauth` take
|
|
137
|
+
* effect without restarting the session.
|
|
138
|
+
*/
|
|
139
|
+
refreshMCPTools(mcpTools: CustomTool[]): Promise<void>;
|
|
140
|
+
/** Replaces RPC host-owned tools and refreshes the active set before the next model call. */
|
|
141
|
+
refreshRpcHostTools(rpcTools: AgentTool[]): Promise<void>;
|
|
142
|
+
}
|
|
143
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filesystem workspace of a session: one current/default directory plus a
|
|
3
|
+
* non-empty ordered list of workspace directories.
|
|
4
|
+
*
|
|
5
|
+
* `cwd` remains the default directory for relative-path resolution and
|
|
6
|
+
* backward compatibility. `directories` always contains `cwd` first, followed
|
|
7
|
+
* by any additional directories in their supplied order (deduplicated).
|
|
8
|
+
* Directory order is stable but carries no semantic hierarchy.
|
|
9
|
+
*
|
|
10
|
+
* Workspace directories come from the platform (ACP/editor), CLI, or config —
|
|
11
|
+
* never from filesystem walk-up discovery.
|
|
12
|
+
*/
|
|
13
|
+
export interface SessionWorkspace {
|
|
14
|
+
/** Current/default directory for compatibility and relative path resolution. */
|
|
15
|
+
cwd: string;
|
|
16
|
+
/** Non-empty ordered list of absolute normalized directories; `cwd` is always first. */
|
|
17
|
+
directories: string[];
|
|
18
|
+
}
|
|
19
|
+
/** Expand a leading `~`/`~/` and resolve to an absolute path (relative input resolves against `base`). */
|
|
20
|
+
export declare function normalizeWorkspaceDirectory(directory: string, base?: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Build a normalized {@link SessionWorkspace} from a cwd and optional
|
|
23
|
+
* additional directories. Additional entries are normalized (relative entries
|
|
24
|
+
* resolve against the normalized cwd), deduplicated, and appended after `cwd`
|
|
25
|
+
* preserving their supplied order.
|
|
26
|
+
*/
|
|
27
|
+
export declare function normalizeSessionWorkspace(args: {
|
|
28
|
+
cwd: string;
|
|
29
|
+
directories?: string[];
|
|
30
|
+
}): SessionWorkspace;
|
|
31
|
+
/** The workspace directories beyond `cwd`, in order (ACP `additionalDirectories` shape). */
|
|
32
|
+
export declare function additionalWorkspaceDirectories(workspace: SessionWorkspace): string[];
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Agent, AgentEvent, AgentMessage, AgentTurnEndContext } from "@oh-my-pi/pi-agent-core";
|
|
2
|
+
import type { AssistantMessage, AssistantMessageEvent, Model } from "@oh-my-pi/pi-ai";
|
|
3
|
+
import type { Settings } from "../config/settings.js";
|
|
4
|
+
import { type LocalProtocolOptions } from "../internal-urls/index.js";
|
|
5
|
+
import type { SecretObfuscator } from "../secrets/obfuscator.js";
|
|
6
|
+
import type { SessionManager } from "./session-manager.js";
|
|
7
|
+
/** Capabilities borrowed by the session's streaming and loop guards. */
|
|
8
|
+
export interface StreamGuardsHost {
|
|
9
|
+
agent: Agent;
|
|
10
|
+
settings: Settings;
|
|
11
|
+
sessionManager: SessionManager;
|
|
12
|
+
obfuscator: SecretObfuscator | undefined;
|
|
13
|
+
model(): Model | undefined;
|
|
14
|
+
isDisposed(): boolean;
|
|
15
|
+
promptGeneration(): number;
|
|
16
|
+
localProtocolOptions(): LocalProtocolOptions;
|
|
17
|
+
emitNotice(level: "info" | "warning" | "error", message: string, source?: string): void;
|
|
18
|
+
schedulePostPromptTask(task: (signal: AbortSignal) => Promise<void>): void;
|
|
19
|
+
discardAssistantTurn(message: AssistantMessage): void;
|
|
20
|
+
}
|
|
21
|
+
/** Guards streamed edit calls against generated files and invalid patch previews. */
|
|
22
|
+
export declare class StreamingEditGuard {
|
|
23
|
+
#private;
|
|
24
|
+
constructor(host: StreamGuardsHost);
|
|
25
|
+
/** Whether the current turn was aborted by streaming edit validation. */
|
|
26
|
+
get abortTriggered(): boolean;
|
|
27
|
+
/** Clears all turn-scoped streaming edit state. */
|
|
28
|
+
reset(): void;
|
|
29
|
+
/** Pre-caches and validates a streamed edit as its arguments arrive. */
|
|
30
|
+
preCache(event: AgentEvent): void;
|
|
31
|
+
/** Invalidates cached source text after an edit tool result lands. */
|
|
32
|
+
invalidate(filePath: string): void;
|
|
33
|
+
/** Aborts a streamed edit whose completed patch preview cannot apply. */
|
|
34
|
+
maybeAbort(event: AgentEvent): void;
|
|
35
|
+
}
|
|
36
|
+
/** Detects cross-turn tool loops and Gemini reasoning-header runaways. */
|
|
37
|
+
export declare class LoopGuards {
|
|
38
|
+
#private;
|
|
39
|
+
constructor(host: StreamGuardsHost);
|
|
40
|
+
/** Records a completed turn and injects a redirect when calls repeat. */
|
|
41
|
+
recordTurn(messages: AgentMessage[], context: AgentTurnEndContext | undefined): void;
|
|
42
|
+
/** Feeds a streamed assistant event to the Gemini header-runaway detector. */
|
|
43
|
+
onAssistantEvent(message: AssistantMessage, event: AssistantMessageEvent): void;
|
|
44
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Agent, AgentMessage, AgentTool } from "@oh-my-pi/pi-agent-core";
|
|
2
|
+
import type { AssistantMessage, Model, ToolChoice } from "@oh-my-pi/pi-ai";
|
|
3
|
+
import type { Settings } from "../config/settings.js";
|
|
4
|
+
import { type TodoPhase } from "../tools/todo.js";
|
|
5
|
+
import type { AgentSessionEvent } from "./agent-session-events.js";
|
|
6
|
+
import type { SessionManager } from "./session-manager.js";
|
|
7
|
+
/** Capabilities the todo tracker borrows from its owning session. */
|
|
8
|
+
export interface TodoTrackerHost {
|
|
9
|
+
agent: Agent;
|
|
10
|
+
sessionManager: SessionManager;
|
|
11
|
+
settings: Settings;
|
|
12
|
+
model(): Model | undefined;
|
|
13
|
+
agentKind(): "main" | "sub";
|
|
14
|
+
emitSessionEvent(event: AgentSessionEvent): Promise<void>;
|
|
15
|
+
scheduleAgentContinue(options: {
|
|
16
|
+
generation?: number;
|
|
17
|
+
}): void;
|
|
18
|
+
promptGeneration(): number;
|
|
19
|
+
hasPendingAsyncWake(): boolean;
|
|
20
|
+
getActiveToolNames(): string[];
|
|
21
|
+
toolRegistry(): Map<string, AgentTool>;
|
|
22
|
+
planModeEnabled(): boolean;
|
|
23
|
+
consumeLastServedToolChoiceLabel(): string | undefined;
|
|
24
|
+
}
|
|
25
|
+
/** Owns canonical todo state, eager preludes, and completion reminders. */
|
|
26
|
+
export declare class TodoTracker {
|
|
27
|
+
#private;
|
|
28
|
+
constructor(host: TodoTrackerHost);
|
|
29
|
+
/** Returns a defensive clone of the current todo phases. */
|
|
30
|
+
get phases(): TodoPhase[];
|
|
31
|
+
/** Replaces todo phases with a defensive clone. */
|
|
32
|
+
setPhases(phases: TodoPhase[]): void;
|
|
33
|
+
/** Rehydrates todo phases from the current transcript branch. */
|
|
34
|
+
syncFromBranch(): void;
|
|
35
|
+
/** Returns a defensive clone suitable for snapshots and branch state. */
|
|
36
|
+
clonePhases(phases: TodoPhase[]): TodoPhase[];
|
|
37
|
+
/** Resets per-prompt reminder and mutation budgets. */
|
|
38
|
+
resetCycle(): void;
|
|
39
|
+
/** Records a completed tool result before asynchronous event processing begins. */
|
|
40
|
+
onToolResult(toolName: string, isError: boolean): void;
|
|
41
|
+
/** Detects whether a successful todo result came from an init operation. */
|
|
42
|
+
onTodoResultDetails(details: Record<string, unknown>, toolCallId: string | undefined): boolean;
|
|
43
|
+
/** Builds the first-turn eager todo prelude and optional forced tool choice. */
|
|
44
|
+
createEagerTodoPrelude(promptText: string | undefined): {
|
|
45
|
+
message: AgentMessage;
|
|
46
|
+
toolChoice?: ToolChoice;
|
|
47
|
+
} | undefined;
|
|
48
|
+
/** Builds the first-turn eager task-delegation prelude. */
|
|
49
|
+
createEagerTaskPrelude(promptText: string | undefined): AgentMessage | undefined;
|
|
50
|
+
/** Builds reminder-only eager preludes after compaction. */
|
|
51
|
+
buildPostCompactionEagerNudges(): AgentMessage[];
|
|
52
|
+
/** Checks a terminal assistant turn and schedules continuation for incomplete todos. */
|
|
53
|
+
checkCompletion(message: AssistantMessage): Promise<boolean>;
|
|
54
|
+
/** Takes the next hidden mid-run reconciliation nudge, if its budget and guards allow. */
|
|
55
|
+
takeMidRunNudge(): AgentMessage | null;
|
|
56
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type AfterToolCallContext, type AfterToolCallResult, type Agent, type AgentEvent } from "@oh-my-pi/pi-agent-core";
|
|
2
|
+
import type { AssistantMessage } from "@oh-my-pi/pi-ai";
|
|
3
|
+
import type { Settings } from "../config/settings.js";
|
|
4
|
+
import type { TtsrManager } from "../export/ttsr.js";
|
|
5
|
+
import type { AgentSessionEvent } from "./agent-session-events.js";
|
|
6
|
+
import type { SessionManager } from "./session-manager.js";
|
|
7
|
+
interface TtsrContinueOptions {
|
|
8
|
+
delayMs?: number;
|
|
9
|
+
generation?: number;
|
|
10
|
+
shouldContinue?: () => boolean;
|
|
11
|
+
onSkip?: () => void;
|
|
12
|
+
onError?: () => void;
|
|
13
|
+
}
|
|
14
|
+
/** Capabilities the TTSR coordinator borrows from its owning session. */
|
|
15
|
+
export interface TtsrCoordinatorHost {
|
|
16
|
+
agent: Agent;
|
|
17
|
+
sessionManager: SessionManager;
|
|
18
|
+
settings: Settings;
|
|
19
|
+
emitSessionEvent(event: AgentSessionEvent): Promise<void>;
|
|
20
|
+
schedulePostPromptTask(task: (signal: AbortSignal) => Promise<void>, options?: {
|
|
21
|
+
delayMs?: number;
|
|
22
|
+
}): void;
|
|
23
|
+
scheduleAgentContinue(options: TtsrContinueOptions): void;
|
|
24
|
+
promptGeneration(): number;
|
|
25
|
+
}
|
|
26
|
+
/** Coordinates TTSR stream matching, interruption, injection, and resume gates. */
|
|
27
|
+
export declare class TtsrCoordinator {
|
|
28
|
+
#private;
|
|
29
|
+
constructor(host: TtsrCoordinatorHost, manager: TtsrManager | undefined);
|
|
30
|
+
/** Configured TTSR manager, when stream rules are enabled. */
|
|
31
|
+
get manager(): TtsrManager | undefined;
|
|
32
|
+
/** Whether a TTSR-triggered stream abort is awaiting its continuation. */
|
|
33
|
+
get abortPending(): boolean;
|
|
34
|
+
/** Current resume gate awaited by post-prompt recovery. */
|
|
35
|
+
get resumeGate(): Promise<void> | undefined;
|
|
36
|
+
/** Resets stream buffers at turn start. */
|
|
37
|
+
onTurnStart(): void;
|
|
38
|
+
/** Advances repeat-after-gap tracking at turn end. */
|
|
39
|
+
onTurnEnd(): void;
|
|
40
|
+
/** Checks one streamed message update and reports whether TTSR consumed it by aborting. */
|
|
41
|
+
checkMessageUpdate(event: AgentEvent): Promise<boolean>;
|
|
42
|
+
/** Settles the previous resume gate and queues any deferred injection. */
|
|
43
|
+
onAssistantMessageEnd(message: AssistantMessage): void;
|
|
44
|
+
/** Marks names persisted with a delivered TTSR injection as injected. */
|
|
45
|
+
markInjectedFromDetails(details: unknown): void;
|
|
46
|
+
/** Folds per-tool reminders into the matched tool's result. */
|
|
47
|
+
afterToolCall(ctx: AfterToolCallContext): AfterToolCallResult | undefined;
|
|
48
|
+
/** Resolves and clears the current resume gate. */
|
|
49
|
+
resolveResume(): void;
|
|
50
|
+
}
|
|
51
|
+
export {};
|