@averyyy/pi-coding-agent 0.84.4-piclient.2 → 0.85.1-piclient.2
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 +76 -1
- package/README.md +1 -1
- package/dist/bun/cli.d.ts +3 -1
- package/dist/bun/cli.d.ts.map +1 -1
- package/dist/bun/cli.js +3 -9
- package/dist/bun/cli.js.map +1 -1
- package/dist/bun/runtime-setup.d.ts +2 -0
- package/dist/bun/runtime-setup.d.ts.map +1 -0
- package/dist/bun/runtime-setup.js +9 -0
- package/dist/bun/runtime-setup.js.map +1 -0
- package/dist/bun/sandbox-env-setup.d.ts +2 -0
- package/dist/bun/sandbox-env-setup.d.ts.map +1 -0
- package/dist/bun/sandbox-env-setup.js +4 -0
- package/dist/bun/sandbox-env-setup.js.map +1 -0
- package/dist/bundle/chunks/anthropic-messages-VWZZOSJQ.js +6 -0
- package/dist/bundle/chunks/{azure-openai-responses-B2RCCN5N.js → azure-openai-responses-B467Y57F.js} +1 -1
- package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
- package/dist/bundle/chunks/{chunk-LRBSW3NQ.js → chunk-6WPJTKUF.js} +2 -2
- package/dist/bundle/chunks/chunk-7ZC4UXSL.js +2 -0
- package/dist/bundle/chunks/chunk-CLNPYIDP.js +42 -0
- package/dist/bundle/chunks/{chunk-MNAIPA3J.js → chunk-IDDQWTHI.js} +1 -1
- package/dist/bundle/chunks/{chunk-2KVJKXS2.js → chunk-U6ZMQKGD.js} +1 -1
- package/dist/bundle/chunks/chunk-USJZMAIR.js +2 -0
- package/dist/bundle/chunks/chunk-YGXEFPSS.js +1639 -0
- package/dist/bundle/chunks/github-copilot.js +1 -1
- package/dist/bundle/chunks/{google-generative-ai-YMUPJBKR.js → google-generative-ai-Q2K7FBDI.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-MPWMV4OF.js → google-vertex-7UJBF4S7.js} +1 -1
- package/dist/bundle/chunks/image-resize-worker.js +1 -1
- package/dist/bundle/chunks/{mistral-conversations-Q3AWZJAZ.js → mistral-conversations-4M6BZBX6.js} +1 -1
- package/dist/bundle/chunks/node-KG362ECQ.js +16 -0
- package/dist/bundle/chunks/node-TWVVAGPO.js +2 -0
- package/dist/bundle/chunks/openai-codex-responses-MERYAUSE.js +10 -0
- package/dist/bundle/chunks/{openai-completions-ERMU2SS7.js → openai-completions-EKZT2IH2.js} +3 -3
- package/dist/bundle/chunks/openai-responses-YZ6M7S4X.js +2 -0
- package/dist/bundle/chunks/{pi-messages-TPFH44NP.js → pi-messages-PML4SPVJ.js} +1 -1
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js +2 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/setup.d.ts +2 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli/setup.js +12 -0
- package/dist/cli/setup.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +2 -15
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +15 -7
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session.d.ts +2 -12
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +18 -100
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +1 -1
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +1 -2
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/types.d.ts +8 -2
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +2 -0
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/keybindings.d.ts +5 -0
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +4 -0
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/messages.d.ts +1 -1
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-config.d.ts +15 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +3 -0
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-runtime.d.ts +1 -0
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +5 -2
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +8 -2
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/session-manager.d.ts +3 -2
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +40 -13
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +4 -2
- package/dist/core/skills.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +8 -9
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +6 -6
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts +1 -12
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +5 -163
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +4 -55
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +4 -60
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +4 -49
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +4 -120
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/renderers/bash.d.ts +12 -0
- package/dist/core/tools/renderers/bash.d.ts.map +1 -0
- package/dist/core/tools/renderers/bash.js +130 -0
- package/dist/core/tools/renderers/bash.js.map +1 -0
- package/dist/core/tools/renderers/edit.d.ts +23 -0
- package/dist/core/tools/renderers/edit.d.ts.map +1 -0
- package/dist/core/tools/renderers/edit.js +167 -0
- package/dist/core/tools/renderers/edit.js.map +1 -0
- package/dist/core/tools/renderers/find.d.ts +10 -0
- package/dist/core/tools/renderers/find.d.ts.map +1 -0
- package/dist/core/tools/renderers/find.js +64 -0
- package/dist/core/tools/renderers/find.js.map +1 -0
- package/dist/core/tools/renderers/grep.d.ts +10 -0
- package/dist/core/tools/renderers/grep.d.ts.map +1 -0
- package/dist/core/tools/renderers/grep.js +69 -0
- package/dist/core/tools/renderers/grep.js.map +1 -0
- package/dist/core/tools/renderers/index.d.ts +28 -0
- package/dist/core/tools/renderers/index.d.ts.map +1 -0
- package/dist/core/tools/renderers/index.js +47 -0
- package/dist/core/tools/renderers/index.js.map +1 -0
- package/dist/core/tools/renderers/ls.d.ts +10 -0
- package/dist/core/tools/renderers/ls.d.ts.map +1 -0
- package/dist/core/tools/renderers/ls.js +58 -0
- package/dist/core/tools/renderers/ls.js.map +1 -0
- package/dist/core/tools/renderers/read.d.ts +11 -0
- package/dist/core/tools/renderers/read.d.ts.map +1 -0
- package/dist/core/tools/renderers/read.js +129 -0
- package/dist/core/tools/renderers/read.js.map +1 -0
- package/dist/core/tools/renderers/write.d.ts +10 -0
- package/dist/core/tools/renderers/write.d.ts.map +1 -0
- package/dist/core/tools/renderers/write.js +153 -0
- package/dist/core/tools/renderers/write.js.map +1 -0
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +5 -146
- package/dist/core/tools/write.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +4 -1
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/chat-viewport.d.ts +20 -0
- package/dist/modes/interactive/chat-viewport.d.ts.map +1 -0
- package/dist/modes/interactive/chat-viewport.js +28 -0
- package/dist/modes/interactive/chat-viewport.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +18 -10
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +10 -1
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +39 -1
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -1
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +10 -19
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +21 -23
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +14 -10
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +3 -1
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +10 -3
- package/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +6 -6
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +21 -4
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +35 -33
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/trust-selector.js +2 -2
- package/dist/modes/interactive/components/trust-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +8 -15
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +95 -80
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/session-share.d.ts.map +1 -1
- package/dist/modes/interactive/session-share.js +8 -12
- package/dist/modes/interactive/session-share.js.map +1 -1
- package/dist/modes/interactive/theme/dark.json +2 -1
- package/dist/modes/interactive/theme/light.json +2 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts +1 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.js +5 -0
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
- package/dist/modes/interactive/theme/theme-json.d.ts +84 -0
- package/dist/modes/interactive/theme/theme-json.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-json.js +130 -0
- package/dist/modes/interactive/theme/theme-json.js.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.json +6 -2
- package/dist/modes/interactive/theme/theme.d.ts +14 -5
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +18 -119
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/interactive/tui-renderer.d.ts +21 -0
- package/dist/modes/interactive/tui-renderer.d.ts.map +1 -0
- package/dist/modes/interactive/tui-renderer.js +66 -0
- package/dist/modes/interactive/tui-renderer.js.map +1 -0
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js +2 -3
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/tools-manager.d.ts +1 -0
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +41 -19
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/containerization.md +45 -0
- package/docs/development.md +19 -0
- package/docs/environment-variables.md +2 -0
- package/docs/extensions.md +5 -2
- package/docs/keybindings.md +5 -2
- package/docs/models.md +4 -1
- package/docs/rpc.md +1 -1
- package/docs/sdk.md +5 -0
- package/docs/settings.md +5 -5
- package/docs/skills.md +1 -1
- package/docs/terminal-setup.md +15 -0
- package/docs/themes.md +8 -6
- package/docs/tui.md +20 -1
- package/examples/README.md +3 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/dynamic-resources/dynamic.json +2 -0
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/plugins/pi-example-plugin/README.md +38 -0
- package/examples/plugins/pi-example-plugin/package.json +10 -0
- package/examples/plugins/pi-example-plugin/src/contract.ts +13 -0
- package/examples/plugins/pi-example-plugin/src/session.ts +23 -0
- package/examples/plugins/pi-example-plugin/src/tui.ts +31 -0
- package/package.json +15 -8
- package/dist/bun/register-bedrock.d.ts +0 -2
- package/dist/bun/register-bedrock.d.ts.map +0 -1
- package/dist/bun/register-bedrock.js +0 -4
- package/dist/bun/register-bedrock.js.map +0 -1
- package/dist/bundle/chunks/anthropic-messages-JWX2WP65.js +0 -45
- package/dist/bundle/chunks/chunk-JUUC5AZY.js +0 -2
- package/dist/bundle/chunks/chunk-WJEX5SB4.js +0 -1632
- package/dist/bundle/chunks/openai-codex-responses-MJHX7NXI.js +0 -8
- package/dist/bundle/chunks/openai-responses-CP4VKB27.js +0 -2
- package/dist/bundle/client.js +0 -2
- package/dist/cli/experimental/auth.d.ts +0 -16
- package/dist/cli/experimental/auth.d.ts.map +0 -1
- package/dist/cli/experimental/auth.js +0 -13
- package/dist/cli/experimental/auth.js.map +0 -1
- package/dist/cli/experimental/cli.d.ts +0 -6
- package/dist/cli/experimental/cli.d.ts.map +0 -1
- package/dist/cli/experimental/cli.js +0 -5
- package/dist/cli/experimental/cli.js.map +0 -1
- package/dist/cli/experimental/command-options.d.ts +0 -17
- package/dist/cli/experimental/command-options.d.ts.map +0 -1
- package/dist/cli/experimental/command-options.js +0 -35
- package/dist/cli/experimental/command-options.js.map +0 -1
- package/dist/cli/experimental/command.d.ts +0 -63
- package/dist/cli/experimental/command.d.ts.map +0 -1
- package/dist/cli/experimental/command.js +0 -130
- package/dist/cli/experimental/command.js.map +0 -1
- package/dist/cli/experimental/commands/client.d.ts +0 -13
- package/dist/cli/experimental/commands/client.d.ts.map +0 -1
- package/dist/cli/experimental/commands/client.js +0 -25
- package/dist/cli/experimental/commands/client.js.map +0 -1
- package/dist/cli/experimental/commands/pi.d.ts +0 -15
- package/dist/cli/experimental/commands/pi.d.ts.map +0 -1
- package/dist/cli/experimental/commands/pi.js +0 -28
- package/dist/cli/experimental/commands/pi.js.map +0 -1
- package/dist/cli/experimental/commands/server.d.ts +0 -13
- package/dist/cli/experimental/commands/server.d.ts.map +0 -1
- package/dist/cli/experimental/commands/server.js +0 -25
- package/dist/cli/experimental/commands/server.js.map +0 -1
- package/dist/cli/experimental/transport-address.d.ts +0 -10
- package/dist/cli/experimental/transport-address.d.ts.map +0 -1
- package/dist/cli/experimental/transport-address.js +0 -38
- package/dist/cli/experimental/transport-address.js.map +0 -1
- package/dist/client/index.d.ts +0 -3
- package/dist/client/index.d.ts.map +0 -1
- package/dist/client/index.js +0 -3
- package/dist/client/index.js.map +0 -1
- package/dist/client/remote-session.d.ts +0 -53
- package/dist/client/remote-session.d.ts.map +0 -1
- package/dist/client/remote-session.js +0 -340
- package/dist/client/remote-session.js.map +0 -1
- package/dist/client/transcript.d.ts +0 -12
- package/dist/client/transcript.d.ts.map +0 -1
- package/dist/client/transcript.js +0 -98
- package/dist/client/transcript.js.map +0 -1
- package/dist/server/create-harness.d.ts +0 -26
- package/dist/server/create-harness.d.ts.map +0 -1
- package/dist/server/create-harness.js +0 -106
- package/dist/server/create-harness.js.map +0 -1
|
@@ -74,9 +74,6 @@ function estimateMessagesTokens(messages) {
|
|
|
74
74
|
// ============================================================================
|
|
75
75
|
const INTRA_TURN_COMPACTION_MARKER_TYPE = "pi:intra-turn-compaction";
|
|
76
76
|
const INTRA_TURN_COMPACTION_MARKER_TEXT = "Continue from the compaction summary above. The previous tool loop was compacted before the next provider request; use the summary's Operational State, file lists, failures, last command, and next steps.";
|
|
77
|
-
const VALIDATION_HINT_MESSAGE_TYPE = "pi:validation-hint";
|
|
78
|
-
const VALIDATION_HINT_FILE_LIMIT = 12;
|
|
79
|
-
const VALIDATION_HINT_FAILURE_CHAR_LIMIT = 1200;
|
|
80
77
|
const AUTO_SESSION_NAME_INPUT_CHAR_LIMIT = 4000;
|
|
81
78
|
const AUTO_SESSION_NAME_MAX_CHARS = 80;
|
|
82
79
|
const AUTO_SESSION_NAME_PROMPT = "Name this coding session from the transcript below. Return only a concise title, in the user's language when clear. No quotes, no markdown, no explanation. Do not call tools.";
|
|
@@ -86,12 +83,6 @@ function isPiServerMode() {
|
|
|
86
83
|
function toProviderReasoning(thinkingLevel) {
|
|
87
84
|
return thinkingLevel === "off" ? undefined : thinkingLevel;
|
|
88
85
|
}
|
|
89
|
-
function getStringField(input, key) {
|
|
90
|
-
if (!input || typeof input !== "object" || Array.isArray(input))
|
|
91
|
-
return undefined;
|
|
92
|
-
const value = input[key];
|
|
93
|
-
return typeof value === "string" && value.trim().length > 0 ? value : undefined;
|
|
94
|
-
}
|
|
95
86
|
function getPiServerFailurePhase(message) {
|
|
96
87
|
for (const diagnostic of message.diagnostics ?? []) {
|
|
97
88
|
if (diagnostic.type !== "pi_server_failure")
|
|
@@ -112,19 +103,6 @@ function getPiServerFailureRetryable(message) {
|
|
|
112
103
|
}
|
|
113
104
|
return undefined;
|
|
114
105
|
}
|
|
115
|
-
function toolTextContent(content) {
|
|
116
|
-
return content
|
|
117
|
-
.filter((part) => part.type === "text")
|
|
118
|
-
.map((part) => part.text)
|
|
119
|
-
.join("\n")
|
|
120
|
-
.trim();
|
|
121
|
-
}
|
|
122
|
-
function compactValidationSummary(text) {
|
|
123
|
-
const trimmed = text.trim();
|
|
124
|
-
if (trimmed.length <= VALIDATION_HINT_FAILURE_CHAR_LIMIT)
|
|
125
|
-
return trimmed;
|
|
126
|
-
return `...${trimmed.slice(trimmed.length - VALIDATION_HINT_FAILURE_CHAR_LIMIT + 3)}`;
|
|
127
|
-
}
|
|
128
106
|
function messageTextContent(message) {
|
|
129
107
|
if (!("content" in message))
|
|
130
108
|
return "";
|
|
@@ -195,8 +173,6 @@ export class AgentSession {
|
|
|
195
173
|
// Bash execution state
|
|
196
174
|
_bashAbortControllers = new Set();
|
|
197
175
|
_pendingBashMessages = [];
|
|
198
|
-
_validationModifiedFiles = new Set();
|
|
199
|
-
_validationFailure = undefined;
|
|
200
176
|
// Extension system
|
|
201
177
|
_extensionRunner;
|
|
202
178
|
_turnIndex = 0;
|
|
@@ -320,71 +296,6 @@ export class AgentSession {
|
|
|
320
296
|
return { model };
|
|
321
297
|
}
|
|
322
298
|
}
|
|
323
|
-
_resetValidationHintState() {
|
|
324
|
-
this._validationModifiedFiles.clear();
|
|
325
|
-
this._validationFailure = undefined;
|
|
326
|
-
}
|
|
327
|
-
_recordValidationToolResult(toolName, input, content, isError) {
|
|
328
|
-
if ((toolName === "edit" || toolName === "write") && !isError) {
|
|
329
|
-
const path = getStringField(input, "path") ?? getStringField(input, "file_path");
|
|
330
|
-
if (path) {
|
|
331
|
-
this._validationModifiedFiles.add(path);
|
|
332
|
-
}
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
if (toolName !== "bash") {
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
const command = getStringField(input, "command");
|
|
339
|
-
if (!command) {
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
342
|
-
if (isError) {
|
|
343
|
-
this._validationFailure = {
|
|
344
|
-
command,
|
|
345
|
-
summary: compactValidationSummary(toolTextContent(content)),
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
else if (this._validationFailure?.command === command) {
|
|
349
|
-
this._resetValidationHintState();
|
|
350
|
-
}
|
|
351
|
-
else if (!this._validationFailure) {
|
|
352
|
-
this._validationModifiedFiles.clear();
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
_createValidationHintMessage() {
|
|
356
|
-
const modifiedFiles = Array.from(this._validationModifiedFiles).slice(-VALIDATION_HINT_FILE_LIMIT);
|
|
357
|
-
if (modifiedFiles.length === 0 && !this._validationFailure) {
|
|
358
|
-
return undefined;
|
|
359
|
-
}
|
|
360
|
-
const lines = ["<validation-hint>"];
|
|
361
|
-
if (modifiedFiles.length > 0) {
|
|
362
|
-
lines.push("Recent modified files:", ...modifiedFiles.map((file) => `- ${file}`));
|
|
363
|
-
}
|
|
364
|
-
if (this._validationFailure) {
|
|
365
|
-
lines.push("Recent failed command:", this._validationFailure.command, "Failure summary:", this._validationFailure.summary || "(no output)", "Suggested next validation command:", this._validationFailure.command);
|
|
366
|
-
}
|
|
367
|
-
else {
|
|
368
|
-
lines.push("Suggested next step:", "Run the smallest project validation that covers the modified files.");
|
|
369
|
-
}
|
|
370
|
-
lines.push("Inspect failures, fix the root cause, then rerun validation before finalizing.", "</validation-hint>");
|
|
371
|
-
return {
|
|
372
|
-
role: "custom",
|
|
373
|
-
customType: VALIDATION_HINT_MESSAGE_TYPE,
|
|
374
|
-
content: [{ type: "text", text: lines.join("\n") }],
|
|
375
|
-
display: false,
|
|
376
|
-
details: { modifiedFiles, failedCommand: this._validationFailure?.command },
|
|
377
|
-
timestamp: Date.now(),
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
_withValidationHint(context) {
|
|
381
|
-
const messages = context.messages.filter((message) => !(message.role === "custom" && message.customType === VALIDATION_HINT_MESSAGE_TYPE));
|
|
382
|
-
const hint = this._createValidationHintMessage();
|
|
383
|
-
return {
|
|
384
|
-
...context,
|
|
385
|
-
messages: hint ? [...messages, hint] : messages,
|
|
386
|
-
};
|
|
387
|
-
}
|
|
388
299
|
/**
|
|
389
300
|
* Install tool hooks once on the Agent instance.
|
|
390
301
|
*
|
|
@@ -433,8 +344,6 @@ export class AgentSession {
|
|
|
433
344
|
const normalizedContent = await normalizeToolResultImages(content, {
|
|
434
345
|
autoResizeImages: this.settingsManager.getImageAutoResize(),
|
|
435
346
|
});
|
|
436
|
-
const finalIsError = hookResult?.isError ?? isError;
|
|
437
|
-
this._recordValidationToolResult(toolCall.name, args, normalizedContent, finalIsError);
|
|
438
347
|
if (!hookResult && normalizedContent === content) {
|
|
439
348
|
return undefined;
|
|
440
349
|
}
|
|
@@ -458,11 +367,11 @@ export class AgentSession {
|
|
|
458
367
|
const previousContext = previousSnapshot?.context ?? nextTurn.context;
|
|
459
368
|
return {
|
|
460
369
|
...previousSnapshot,
|
|
461
|
-
context:
|
|
370
|
+
context: {
|
|
462
371
|
...previousContext,
|
|
463
372
|
systemPrompt: this._systemPromptOverride ?? this._baseSystemPrompt,
|
|
464
373
|
tools: this.agent.state.tools.slice(),
|
|
465
|
-
}
|
|
374
|
+
},
|
|
466
375
|
model: this.agent.state.model,
|
|
467
376
|
thinkingLevel: this.agent.state.thinkingLevel,
|
|
468
377
|
};
|
|
@@ -498,7 +407,7 @@ export class AgentSession {
|
|
|
498
407
|
return this._idleWaitPromise;
|
|
499
408
|
}
|
|
500
409
|
_resolveIdleWaitIfIdle() {
|
|
501
|
-
if (this.
|
|
410
|
+
if (!this.isIdle || !this._resolveIdleWait) {
|
|
502
411
|
return;
|
|
503
412
|
}
|
|
504
413
|
const resolve = this._resolveIdleWait;
|
|
@@ -834,9 +743,9 @@ export class AgentSession {
|
|
|
834
743
|
get isStreaming() {
|
|
835
744
|
return this._isAgentRunActive;
|
|
836
745
|
}
|
|
837
|
-
/** Whether the session has no active agent run,
|
|
746
|
+
/** Whether the session has no active agent run, compaction, branch summary, retry, or queued continuation. */
|
|
838
747
|
get isIdle() {
|
|
839
|
-
return !this._isAgentRunActive;
|
|
748
|
+
return !this._isAgentRunActive && !this.isCompacting;
|
|
840
749
|
}
|
|
841
750
|
/** Current effective system prompt (includes any per-turn extension modifications) */
|
|
842
751
|
get systemPrompt() {
|
|
@@ -988,7 +897,6 @@ export class AgentSession {
|
|
|
988
897
|
// Prompting
|
|
989
898
|
// =========================================================================
|
|
990
899
|
async _runAgentPrompt(messages) {
|
|
991
|
-
this._resetValidationHintState();
|
|
992
900
|
this._isAgentRunActive = true;
|
|
993
901
|
try {
|
|
994
902
|
await this.agent.prompt(messages);
|
|
@@ -1528,6 +1436,8 @@ export class AgentSession {
|
|
|
1528
1436
|
*/
|
|
1529
1437
|
async abort() {
|
|
1530
1438
|
this.abortRetry();
|
|
1439
|
+
this.abortCompaction();
|
|
1440
|
+
this.abortBranchSummary();
|
|
1531
1441
|
this.agent.abort();
|
|
1532
1442
|
await this.waitForIdle();
|
|
1533
1443
|
}
|
|
@@ -1784,6 +1694,10 @@ export class AgentSession {
|
|
|
1784
1694
|
}
|
|
1785
1695
|
return compactionResult;
|
|
1786
1696
|
}
|
|
1697
|
+
_clearManualCompactionState() {
|
|
1698
|
+
this._compactionAbortController = undefined;
|
|
1699
|
+
this._resolveIdleWaitIfIdle();
|
|
1700
|
+
}
|
|
1787
1701
|
/**
|
|
1788
1702
|
* Manually compact the session context.
|
|
1789
1703
|
* Aborts current agent operation first.
|
|
@@ -1907,7 +1821,7 @@ export class AgentSession {
|
|
|
1907
1821
|
details,
|
|
1908
1822
|
};
|
|
1909
1823
|
// compaction_end listeners may submit queued prompts, so expose idle state before notifying them.
|
|
1910
|
-
this.
|
|
1824
|
+
this._clearManualCompactionState();
|
|
1911
1825
|
this._emit({
|
|
1912
1826
|
type: "compaction_end",
|
|
1913
1827
|
reason: "manual",
|
|
@@ -1921,18 +1835,20 @@ export class AgentSession {
|
|
|
1921
1835
|
const message = error instanceof Error ? error.message : String(error);
|
|
1922
1836
|
const aborted = message === "Compaction cancelled" || (error instanceof Error && error.name === "AbortError");
|
|
1923
1837
|
this._compactionAbortController = undefined;
|
|
1838
|
+
const errorMessage = aborted ? undefined : `Compaction failed: ${message}`;
|
|
1839
|
+
this._clearManualCompactionState();
|
|
1924
1840
|
this._emit({
|
|
1925
1841
|
type: "compaction_end",
|
|
1926
1842
|
reason: "manual",
|
|
1927
1843
|
result: undefined,
|
|
1928
1844
|
aborted,
|
|
1929
1845
|
willRetry: false,
|
|
1930
|
-
errorMessage
|
|
1846
|
+
errorMessage,
|
|
1931
1847
|
});
|
|
1932
1848
|
throw error;
|
|
1933
1849
|
}
|
|
1934
1850
|
finally {
|
|
1935
|
-
this.
|
|
1851
|
+
this._clearManualCompactionState();
|
|
1936
1852
|
}
|
|
1937
1853
|
}
|
|
1938
1854
|
/**
|
|
@@ -2239,6 +2155,7 @@ export class AgentSession {
|
|
|
2239
2155
|
}
|
|
2240
2156
|
finally {
|
|
2241
2157
|
this._autoCompactionAbortController = undefined;
|
|
2158
|
+
this._resolveIdleWaitIfIdle();
|
|
2242
2159
|
}
|
|
2243
2160
|
}
|
|
2244
2161
|
/**
|
|
@@ -3060,6 +2977,7 @@ export class AgentSession {
|
|
|
3060
2977
|
}
|
|
3061
2978
|
finally {
|
|
3062
2979
|
this._branchSummaryAbortController = undefined;
|
|
2980
|
+
this._resolveIdleWaitIfIdle();
|
|
3063
2981
|
}
|
|
3064
2982
|
}
|
|
3065
2983
|
/**
|