@code-yeongyu/senpi 2026.7.22-2 → 2026.7.23
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 +20 -0
- package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/index.js +14 -6
- package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/openai-remote-convert.d.ts +26 -0
- package/dist/core/extensions/builtin/compaction/openai-remote-convert.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/openai-remote-convert.js +194 -0
- package/dist/core/extensions/builtin/compaction/openai-remote-convert.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/openai-remote-model.d.ts +22 -0
- package/dist/core/extensions/builtin/compaction/openai-remote-model.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/openai-remote-model.js +92 -0
- package/dist/core/extensions/builtin/compaction/openai-remote-model.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/openai-remote-schema.d.ts +92 -0
- package/dist/core/extensions/builtin/compaction/openai-remote-schema.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/openai-remote-schema.js +56 -0
- package/dist/core/extensions/builtin/compaction/openai-remote-schema.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/openai-remote.d.ts +7 -84
- package/dist/core/extensions/builtin/compaction/openai-remote.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/openai-remote.js +55 -271
- package/dist/core/extensions/builtin/compaction/openai-remote.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.2.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.2.js +3 -0
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.2.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.3-codex.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.3-codex.js +3 -0
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.3-codex.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.4.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.4.js +3 -0
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.4.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.js +3 -0
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js +3 -0
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.js +3 -0
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-eval-routing.d.ts +3 -0
- package/dist/core/extensions/builtin/prompt-preset/gpt-eval-routing.d.ts.map +1 -0
- package/dist/core/extensions/builtin/prompt-preset/gpt-eval-routing.js +6 -0
- package/dist/core/extensions/builtin/prompt-preset/gpt-eval-routing.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +34 -4
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/tool-progress.js +1 -1
- package/dist/modes/interactive/tool-progress.js.map +1 -1
- package/dist/utils/duration.d.ts +2 -0
- package/dist/utils/duration.d.ts.map +1 -0
- package/dist/utils/duration.js +16 -0
- package/dist/utils/duration.js.map +1 -0
- package/docs/session-format.md +4 -0
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +14 -0
- package/node_modules/@code-yeongyu/senpi-codemode/README.md +15 -6
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +3 -3
- package/node_modules/@code-yeongyu/senpi-codemode/src/codemode/runtime.ts +258 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/codemode/tools.ts +106 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/extension/runtime-factory.ts +114 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/extension/session-manager-proxy.ts +116 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/index.ts +73 -204
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/worker-runtime.js +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +34 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +20 -0
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/google-vertex.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.d.ts +8 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.d.ts +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.d.ts +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.d.ts +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/package.json +1 -1
- package/node_modules/@earendil-works/pi-pty/package.json +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/package.json +6 -6
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Container, Markdown, Spacer, Text } from "@earendil-works/pi-tui";
|
|
2
|
+
import { formatDuration } from "../../../utils/duration.js";
|
|
2
3
|
import { formatProviderNativeBody, formatProviderNativeSummary } from "../../provider-native-rendering.js";
|
|
3
4
|
import { getMarkdownTheme, theme } from "../theme/theme.js";
|
|
4
5
|
import { createBoundedRenderSignature } from "./render-signature.js";
|
|
@@ -111,10 +112,26 @@ export class AssistantMessageComponent extends Container {
|
|
|
111
112
|
}
|
|
112
113
|
case "thinking": {
|
|
113
114
|
const thinkingBlocks = [];
|
|
115
|
+
let hasTiming = false;
|
|
116
|
+
let isDone = true;
|
|
117
|
+
let minStart = Number.POSITIVE_INFINITY;
|
|
118
|
+
let maxEnd = Number.NEGATIVE_INFINITY;
|
|
114
119
|
for (; i < message.content.length; i++) {
|
|
115
120
|
const thinkingContent = message.content[i];
|
|
116
121
|
if (thinkingContent.type !== "thinking")
|
|
117
122
|
break;
|
|
123
|
+
const startedAt = thinkingContent.startedAt;
|
|
124
|
+
if (startedAt !== undefined) {
|
|
125
|
+
hasTiming = true;
|
|
126
|
+
minStart = Math.min(minStart, startedAt);
|
|
127
|
+
const endedAt = thinkingContent.endedAt;
|
|
128
|
+
if (endedAt === undefined) {
|
|
129
|
+
isDone = false;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
maxEnd = Math.max(maxEnd, endedAt);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
118
135
|
const thinking = thinkingContent.thinking.trim();
|
|
119
136
|
if (thinking)
|
|
120
137
|
thinkingBlocks.push(thinking);
|
|
@@ -122,10 +139,23 @@ export class AssistantMessageComponent extends Container {
|
|
|
122
139
|
i--;
|
|
123
140
|
if (thinkingBlocks.length === 0)
|
|
124
141
|
break;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
142
|
+
if (!hasTiming) {
|
|
143
|
+
const text = this.hideThinkingBlock
|
|
144
|
+
? theme.italic(theme.fg("thinkingText", this.hiddenThinkingLabel))
|
|
145
|
+
: thinkingBlocks.join("\n\n");
|
|
146
|
+
descriptors.push({ kind: this.hideThinkingBlock ? "thinking-label" : "thinking-md", text });
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
const label = isDone
|
|
150
|
+
? theme.italic(theme.fg("thinkingText", `Thought: ${formatDuration(Math.max(0, maxEnd - minStart))}`))
|
|
151
|
+
: theme.italic(theme.fg("thinkingText", this.hiddenThinkingLabel));
|
|
152
|
+
if (this.hideThinkingBlock) {
|
|
153
|
+
descriptors.push({ kind: "thinking-label", text: label });
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
descriptors.push({ kind: "thinking-label", text: label }, { kind: "thinking-md", text: thinkingBlocks.join("\n\n") });
|
|
157
|
+
}
|
|
158
|
+
}
|
|
129
159
|
if (message.content.slice(i + 1).some((following) => isVisibleContent(following, false)))
|
|
130
160
|
descriptors.push(SPACER_DESCRIPTOR);
|
|
131
161
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistant-message.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/assistant-message.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,SAAS,EAAE,QAAQ,EAAsB,MAAM,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC/G,OAAO,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AAC3G,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAErE,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAC3C,MAAM,eAAe,GAAG,gBAAgB,CAAC;AACzC,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAO3C,MAAM,iBAAiB,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAsC,CAAC;AAE3F,SAAS,WAAW,CAAC,KAAY;IAChC,MAAM,IAAI,SAAS,CAAC,wCAAwC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,gBAAgB,CAAC,OAA4C,EAAE,qBAA8B;IACrG,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACtB,KAAK,MAAM;YACV,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QACrC,KAAK,UAAU;YACd,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;QACzC,KAAK,gBAAgB;YACpB,OAAO,qBAAqB,CAAC;QAC9B,KAAK,UAAU;YACd,OAAO,KAAK,CAAC;QACd;YACC,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;AACF,CAAC;AAED,MAAM,OAAO,yBAA0B,SAAQ,SAAS;IAavD,YACC,OAA0B,EAC1B,iBAAiB,GAAG,KAAK,EACzB,aAAa,GAAkB,gBAA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C;QACtC,CAAC;IACF,CAAC;IAEO,sBAAsB,CAAC,OAAyB;QACvD,OAAO,4BAA4B,CAAC;YACnC,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;YAC7C,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,UAAU,EAAE,OAAO,CAAC,UAAU;SAC9B,CAAC,CAAC;IACJ,CAAC;IAEO,WAAW,CAAC,KAAa,EAAE,SAAiB,EAAE,KAAe;QACpE,IAAI,CAAC,WAAW,GAAG,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IAC5D,CAAC;IAEO,cAAc;QACrB,IAAI,CAAC,IAAI,CAAC,WAAW;YAAE,OAAO;QAC9B,IAAI,CAAC,oBAAoB,GAAG,SAAS,CAAC;QACtC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACtC,CAAC;CACD","sourcesContent":["import type { AssistantMessage } from \"@earendil-works/pi-ai\";\nimport { type Component, Container, Markdown, type MarkdownTheme, Spacer, Text } from \"@earendil-works/pi-tui\";\nimport { formatProviderNativeBody, formatProviderNativeSummary } from \"../../provider-native-rendering.ts\";\nimport { getMarkdownTheme, theme } from \"../theme/theme.ts\";\nimport { createBoundedRenderSignature } from \"./render-signature.ts\";\n\nconst OSC133_ZONE_START = \"\\x1b]133;A\\x07\";\nconst OSC133_ZONE_END = \"\\x1b]133;B\\x07\";\nconst OSC133_ZONE_FINAL = \"\\x1b]133;C\\x07\";\n\ntype MarkdownDescriptorKind = \"text-md\" | \"thinking-md\";\ntype TextDescriptorKind = \"thinking-label\" | \"provider-native-summary\" | \"provider-native-body\" | \"error-text\";\ntype RenderDescriptorKind = \"spacer\" | MarkdownDescriptorKind | TextDescriptorKind;\ntype RenderDescriptor = { readonly kind: RenderDescriptorKind; readonly text: string };\n\nconst SPACER_DESCRIPTOR = { kind: \"spacer\", text: \"\" } as const satisfies RenderDescriptor;\n\nfunction assertNever(value: never): never {\n\tthrow new TypeError(`Unexpected assistant render variant: ${String(value)}`);\n}\n\nfunction isVisibleContent(content: AssistantMessage[\"content\"][number], providerNativeVisible: boolean): boolean {\n\tswitch (content.type) {\n\t\tcase \"text\":\n\t\t\treturn Boolean(content.text.trim());\n\t\tcase \"thinking\":\n\t\t\treturn Boolean(content.thinking.trim());\n\t\tcase \"providerNative\":\n\t\t\treturn providerNativeVisible;\n\t\tcase \"toolCall\":\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn assertNever(content);\n\t}\n}\n\nexport class AssistantMessageComponent extends Container {\n\tprivate renderCache?: { readonly lines: string[]; readonly signature: string; readonly width: number };\n\tprivate contentContainer: Container;\n\tprivate hideThinkingBlock: boolean;\n\tprivate markdownTheme: MarkdownTheme;\n\tprivate hiddenThinkingLabel: string;\n\tprivate outputPad: number;\n\tprivate lastMessage?: AssistantMessage;\n\tprivate lastMessageSignature?: string;\n\tprivate renderDescriptors: readonly RenderDescriptor[] = [];\n\tprivate hasToolCalls = false;\n\tprivate expanded = false;\n\n\tconstructor(\n\t\tmessage?: AssistantMessage,\n\t\thideThinkingBlock = false,\n\t\tmarkdownTheme: MarkdownTheme = getMarkdownTheme(),\n\t\thiddenThinkingLabel = \"Thinking...\",\n\t\toutputPad = 1,\n\t) {\n\t\tsuper();\n\n\t\tthis.hideThinkingBlock = hideThinkingBlock;\n\t\tthis.markdownTheme = markdownTheme;\n\t\tthis.hiddenThinkingLabel = hiddenThinkingLabel;\n\t\tthis.outputPad = outputPad;\n\n\t\t// Container for text/thinking content\n\t\tthis.contentContainer = new Container();\n\t\tthis.addChild(this.contentContainer);\n\n\t\tif (message) this.updateContent(message);\n\t}\n\n\toverride invalidate(): void {\n\t\tthis.renderCache = undefined;\n\t\tsuper.invalidate();\n\t\tthis.renderDescriptors = [];\n\t\tthis.refreshContent();\n\t}\n\n\tsetHideThinkingBlock(hide: boolean): void {\n\t\tif (this.hideThinkingBlock === hide) return;\n\t\tthis.hideThinkingBlock = hide;\n\t\tthis.refreshContent();\n\t}\n\n\tsetHiddenThinkingLabel(label: string): void {\n\t\tif (this.hiddenThinkingLabel === label) return;\n\t\tthis.hiddenThinkingLabel = label;\n\t\tthis.refreshContent();\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tif (this.expanded === expanded) return;\n\t\tthis.expanded = expanded;\n\t\tthis.refreshContent();\n\t}\n\n\tsetOutputPad(padding: number): void {\n\t\tthis.outputPad = padding;\n\t\tthis.renderDescriptors = [];\n\t\tthis.refreshContent();\n\t}\n\n\toverride render(width: number): string[] {\n\t\tconst signature = this.lastMessageSignature ?? \"\";\n\t\tif (this.renderCache?.width === width && this.renderCache.signature === signature) {\n\t\t\treturn [...this.renderCache.lines];\n\t\t}\n\n\t\tconst lines = super.render(width);\n\t\tif (this.hasToolCalls || lines.length === 0) {\n\t\t\tthis.cacheRender(width, signature, lines);\n\t\t\treturn lines;\n\t\t}\n\n\t\tlines[0] = OSC133_ZONE_START + lines[0];\n\t\tlines[lines.length - 1] = OSC133_ZONE_END + OSC133_ZONE_FINAL + lines[lines.length - 1];\n\t\tthis.cacheRender(width, signature, lines);\n\t\treturn lines;\n\t}\n\n\tupdateContent(message: AssistantMessage): void {\n\t\tconst previousMessage = this.lastMessage;\n\t\tthis.lastMessage = message;\n\t\tconst messageSignature = this.createMessageSignature(message);\n\t\tif (previousMessage === message && this.lastMessageSignature === messageSignature) {\n\t\t\treturn;\n\t\t}\n\t\tthis.lastMessageSignature = messageSignature;\n\t\tthis.renderCache = undefined;\n\t\tthis.hasToolCalls = message.content.some((content) => content.type === \"toolCall\");\n\t\tconst descriptors = this.createRenderDescriptors(message);\n\t\tthis.reconcileRenderDescriptors(descriptors);\n\t}\n\n\tprivate createRenderDescriptors(message: AssistantMessage): readonly RenderDescriptor[] {\n\t\tconst descriptors: RenderDescriptor[] = [];\n\t\tif (message.content.some((content) => isVisibleContent(content, true))) descriptors.push(SPACER_DESCRIPTOR);\n\t\tfor (let i = 0; i < message.content.length; i++) {\n\t\t\tconst content = message.content[i];\n\t\t\tswitch (content.type) {\n\t\t\t\tcase \"text\": {\n\t\t\t\t\tconst text = content.text.trim();\n\t\t\t\t\tif (text) descriptors.push({ kind: \"text-md\", text });\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"thinking\": {\n\t\t\t\t\tconst thinkingBlocks: string[] = [];\n\t\t\t\t\tfor (; i < message.content.length; i++) {\n\t\t\t\t\t\tconst thinkingContent = message.content[i];\n\t\t\t\t\t\tif (thinkingContent.type !== \"thinking\") break;\n\t\t\t\t\t\tconst thinking = thinkingContent.thinking.trim();\n\t\t\t\t\t\tif (thinking) thinkingBlocks.push(thinking);\n\t\t\t\t\t}\n\t\t\t\t\ti--;\n\t\t\t\t\tif (thinkingBlocks.length === 0) break;\n\t\t\t\t\tconst text = this.hideThinkingBlock\n\t\t\t\t\t\t? theme.italic(theme.fg(\"thinkingText\", this.hiddenThinkingLabel))\n\t\t\t\t\t\t: thinkingBlocks.join(\"\\n\\n\");\n\t\t\t\t\tdescriptors.push({ kind: this.hideThinkingBlock ? \"thinking-label\" : \"thinking-md\", text });\n\t\t\t\t\tif (message.content.slice(i + 1).some((following) => isVisibleContent(following, false)))\n\t\t\t\t\t\tdescriptors.push(SPACER_DESCRIPTOR);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"providerNative\":\n\t\t\t\t\tdescriptors.push(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkind: \"provider-native-summary\",\n\t\t\t\t\t\t\ttext: theme.fg(\"muted\", formatProviderNativeSummary(message, content, this.expanded)),\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkind: \"provider-native-body\",\n\t\t\t\t\t\t\ttext: theme.fg(\"dim\", formatProviderNativeBody(content, this.expanded)),\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\tif (message.content.slice(i + 1).some((following) => isVisibleContent(following, true)))\n\t\t\t\t\t\tdescriptors.push(SPACER_DESCRIPTOR);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"toolCall\":\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tassertNever(content);\n\t\t\t}\n\t\t}\n\t\tconst addError = (text: string): void => {\n\t\t\tdescriptors.push(SPACER_DESCRIPTOR, { kind: \"error-text\", text: theme.fg(\"error\", text) });\n\t\t};\n\t\tswitch (message.stopReason) {\n\t\t\tcase \"length\":\n\t\t\t\taddError(\n\t\t\t\t\t\"Error: Model stopped because it reached the maximum output token limit. The response may be incomplete.\",\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase \"aborted\": {\n\t\t\t\tif (this.hasToolCalls) break;\n\t\t\t\tconst abortMessage =\n\t\t\t\t\tmessage.errorMessage && message.errorMessage !== \"Request was aborted\"\n\t\t\t\t\t\t? message.errorMessage\n\t\t\t\t\t\t: \"Operation aborted\";\n\t\t\t\taddError(abortMessage);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"error\":\n\t\t\t\tif (!this.hasToolCalls) addError(`Error: ${message.errorMessage || \"Unknown error\"}`);\n\t\t\t\tbreak;\n\t\t\tcase \"stop\":\n\t\t\tcase \"toolUse\":\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tassertNever(message.stopReason);\n\t\t}\n\t\treturn descriptors;\n\t}\n\n\tprivate reconcileRenderDescriptors(descriptors: readonly RenderDescriptor[]): void {\n\t\tlet divergentIndex = 0;\n\t\tconst sharedLength = Math.min(this.renderDescriptors.length, descriptors.length);\n\t\twhile (divergentIndex < sharedLength) {\n\t\t\tconst previous = this.renderDescriptors[divergentIndex];\n\t\t\tconst next = descriptors[divergentIndex];\n\t\t\tconst child = this.contentContainer.children[divergentIndex];\n\t\t\tif (!previous || !next || !child || previous.kind !== next.kind) break;\n\t\t\tif (previous.text !== next.text) {\n\t\t\t\tif ((next.kind === \"text-md\" || next.kind === \"thinking-md\") && child instanceof Markdown) {\n\t\t\t\t\tchild.setText(next.text);\n\t\t\t\t} else break;\n\t\t\t}\n\t\t\tdivergentIndex++;\n\t\t}\n\t\tfor (const child of this.contentContainer.children.splice(divergentIndex)) child.dispose?.();\n\t\tfor (const descriptor of descriptors.slice(divergentIndex))\n\t\t\tthis.contentContainer.addChild(this.createRenderChild(descriptor));\n\t\tthis.renderDescriptors = descriptors;\n\t}\n\n\tprivate createRenderChild(descriptor: RenderDescriptor): Component {\n\t\tswitch (descriptor.kind) {\n\t\t\tcase \"spacer\":\n\t\t\t\treturn new Spacer(1);\n\t\t\tcase \"text-md\":\n\t\t\t\treturn new Markdown(descriptor.text, this.outputPad, 0, this.markdownTheme);\n\t\t\tcase \"thinking-md\":\n\t\t\t\treturn new Markdown(descriptor.text, this.outputPad, 0, this.markdownTheme, {\n\t\t\t\t\tcolor: (text: string) => theme.fg(\"thinkingText\", text),\n\t\t\t\t\titalic: true,\n\t\t\t\t});\n\t\t\tcase \"thinking-label\":\n\t\t\tcase \"error-text\":\n\t\t\t\treturn new Text(descriptor.text, this.outputPad, 0);\n\t\t\tcase \"provider-native-summary\":\n\t\t\t\treturn new Text(descriptor.text, 1, 0);\n\t\t\tcase \"provider-native-body\":\n\t\t\t\treturn new Text(descriptor.text, 3, 0);\n\t\t\tdefault:\n\t\t\t\treturn assertNever(descriptor.kind);\n\t\t}\n\t}\n\n\tprivate createMessageSignature(message: AssistantMessage): string {\n\t\treturn createBoundedRenderSignature({\n\t\t\tcontent: message.content,\n\t\t\thiddenThinkingLabel: this.hiddenThinkingLabel,\n\t\t\thideThinkingBlock: this.hideThinkingBlock,\n\t\t\terrorMessage: message.errorMessage,\n\t\t\tstopReason: message.stopReason,\n\t\t});\n\t}\n\n\tprivate cacheRender(width: number, signature: string, lines: string[]): void {\n\t\tthis.renderCache = { lines: [...lines], signature, width };\n\t}\n\n\tprivate refreshContent(): void {\n\t\tif (!this.lastMessage) return;\n\t\tthis.lastMessageSignature = undefined;\n\t\tthis.updateContent(this.lastMessage);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"assistant-message.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/assistant-message.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,SAAS,EAAE,QAAQ,EAAsB,MAAM,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC/G,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AAC3G,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAErE,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAC3C,MAAM,eAAe,GAAG,gBAAgB,CAAC;AACzC,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAO3C,MAAM,iBAAiB,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAsC,CAAC;AAE3F,SAAS,WAAW,CAAC,KAAY;IAChC,MAAM,IAAI,SAAS,CAAC,wCAAwC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,gBAAgB,CAAC,OAA4C,EAAE,qBAA8B;IACrG,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACtB,KAAK,MAAM;YACV,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QACrC,KAAK,UAAU;YACd,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;QACzC,KAAK,gBAAgB;YACpB,OAAO,qBAAqB,CAAC;QAC9B,KAAK,UAAU;YACd,OAAO,KAAK,CAAC;QACd;YACC,OAAO,WAAW,CAAC,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,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;YACrD,KAAK,yBAAyB;gBAC7B,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YACxC,KAAK,sBAAsB;gBAC1B,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YACxC;gBACC,OAAO,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACtC,CAAC;IACF,CAAC;IAEO,sBAAsB,CAAC,OAAyB;QACvD,OAAO,4BAA4B,CAAC;YACnC,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;YAC7C,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,UAAU,EAAE,OAAO,CAAC,UAAU;SAC9B,CAAC,CAAC;IACJ,CAAC;IAEO,WAAW,CAAC,KAAa,EAAE,SAAiB,EAAE,KAAe;QACpE,IAAI,CAAC,WAAW,GAAG,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IAC5D,CAAC;IAEO,cAAc;QACrB,IAAI,CAAC,IAAI,CAAC,WAAW;YAAE,OAAO;QAC9B,IAAI,CAAC,oBAAoB,GAAG,SAAS,CAAC;QACtC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACtC,CAAC;CACD","sourcesContent":["import type { AssistantMessage } from \"@earendil-works/pi-ai\";\nimport { type Component, Container, Markdown, type MarkdownTheme, Spacer, Text } from \"@earendil-works/pi-tui\";\nimport { formatDuration } from \"../../../utils/duration.ts\";\nimport { formatProviderNativeBody, formatProviderNativeSummary } from \"../../provider-native-rendering.ts\";\nimport { getMarkdownTheme, theme } from \"../theme/theme.ts\";\nimport { createBoundedRenderSignature } from \"./render-signature.ts\";\n\nconst OSC133_ZONE_START = \"\\x1b]133;A\\x07\";\nconst OSC133_ZONE_END = \"\\x1b]133;B\\x07\";\nconst OSC133_ZONE_FINAL = \"\\x1b]133;C\\x07\";\n\ntype MarkdownDescriptorKind = \"text-md\" | \"thinking-md\";\ntype TextDescriptorKind = \"thinking-label\" | \"provider-native-summary\" | \"provider-native-body\" | \"error-text\";\ntype RenderDescriptorKind = \"spacer\" | MarkdownDescriptorKind | TextDescriptorKind;\ntype RenderDescriptor = { readonly kind: RenderDescriptorKind; readonly text: string };\n\nconst SPACER_DESCRIPTOR = { kind: \"spacer\", text: \"\" } as const satisfies RenderDescriptor;\n\nfunction assertNever(value: never): never {\n\tthrow new TypeError(`Unexpected assistant render variant: ${String(value)}`);\n}\n\nfunction isVisibleContent(content: AssistantMessage[\"content\"][number], providerNativeVisible: boolean): boolean {\n\tswitch (content.type) {\n\t\tcase \"text\":\n\t\t\treturn Boolean(content.text.trim());\n\t\tcase \"thinking\":\n\t\t\treturn Boolean(content.thinking.trim());\n\t\tcase \"providerNative\":\n\t\t\treturn providerNativeVisible;\n\t\tcase \"toolCall\":\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn assertNever(content);\n\t}\n}\n\nexport class AssistantMessageComponent extends Container {\n\tprivate renderCache?: { readonly lines: string[]; readonly signature: string; readonly width: number };\n\tprivate contentContainer: Container;\n\tprivate hideThinkingBlock: boolean;\n\tprivate markdownTheme: MarkdownTheme;\n\tprivate hiddenThinkingLabel: string;\n\tprivate outputPad: number;\n\tprivate lastMessage?: AssistantMessage;\n\tprivate lastMessageSignature?: string;\n\tprivate renderDescriptors: readonly RenderDescriptor[] = [];\n\tprivate hasToolCalls = false;\n\tprivate expanded = false;\n\n\tconstructor(\n\t\tmessage?: AssistantMessage,\n\t\thideThinkingBlock = false,\n\t\tmarkdownTheme: MarkdownTheme = getMarkdownTheme(),\n\t\thiddenThinkingLabel = \"Thinking...\",\n\t\toutputPad = 1,\n\t) {\n\t\tsuper();\n\n\t\tthis.hideThinkingBlock = hideThinkingBlock;\n\t\tthis.markdownTheme = markdownTheme;\n\t\tthis.hiddenThinkingLabel = hiddenThinkingLabel;\n\t\tthis.outputPad = outputPad;\n\n\t\t// Container for text/thinking content\n\t\tthis.contentContainer = new Container();\n\t\tthis.addChild(this.contentContainer);\n\n\t\tif (message) this.updateContent(message);\n\t}\n\n\toverride invalidate(): void {\n\t\tthis.renderCache = undefined;\n\t\tsuper.invalidate();\n\t\tthis.renderDescriptors = [];\n\t\tthis.refreshContent();\n\t}\n\n\tsetHideThinkingBlock(hide: boolean): void {\n\t\tif (this.hideThinkingBlock === hide) return;\n\t\tthis.hideThinkingBlock = hide;\n\t\tthis.refreshContent();\n\t}\n\n\tsetHiddenThinkingLabel(label: string): void {\n\t\tif (this.hiddenThinkingLabel === label) return;\n\t\tthis.hiddenThinkingLabel = label;\n\t\tthis.refreshContent();\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tif (this.expanded === expanded) return;\n\t\tthis.expanded = expanded;\n\t\tthis.refreshContent();\n\t}\n\n\tsetOutputPad(padding: number): void {\n\t\tthis.outputPad = padding;\n\t\tthis.renderDescriptors = [];\n\t\tthis.refreshContent();\n\t}\n\n\toverride render(width: number): string[] {\n\t\tconst signature = this.lastMessageSignature ?? \"\";\n\t\tif (this.renderCache?.width === width && this.renderCache.signature === signature) {\n\t\t\treturn [...this.renderCache.lines];\n\t\t}\n\n\t\tconst lines = super.render(width);\n\t\tif (this.hasToolCalls || lines.length === 0) {\n\t\t\tthis.cacheRender(width, signature, lines);\n\t\t\treturn lines;\n\t\t}\n\n\t\tlines[0] = OSC133_ZONE_START + lines[0];\n\t\tlines[lines.length - 1] = OSC133_ZONE_END + OSC133_ZONE_FINAL + lines[lines.length - 1];\n\t\tthis.cacheRender(width, signature, lines);\n\t\treturn lines;\n\t}\n\n\tupdateContent(message: AssistantMessage): void {\n\t\tconst previousMessage = this.lastMessage;\n\t\tthis.lastMessage = message;\n\t\tconst messageSignature = this.createMessageSignature(message);\n\t\tif (previousMessage === message && this.lastMessageSignature === messageSignature) {\n\t\t\treturn;\n\t\t}\n\t\tthis.lastMessageSignature = messageSignature;\n\t\tthis.renderCache = undefined;\n\t\tthis.hasToolCalls = message.content.some((content) => content.type === \"toolCall\");\n\t\tconst descriptors = this.createRenderDescriptors(message);\n\t\tthis.reconcileRenderDescriptors(descriptors);\n\t}\n\n\tprivate createRenderDescriptors(message: AssistantMessage): readonly RenderDescriptor[] {\n\t\tconst descriptors: RenderDescriptor[] = [];\n\t\tif (message.content.some((content) => isVisibleContent(content, true))) descriptors.push(SPACER_DESCRIPTOR);\n\t\tfor (let i = 0; i < message.content.length; i++) {\n\t\t\tconst content = message.content[i];\n\t\t\tswitch (content.type) {\n\t\t\t\tcase \"text\": {\n\t\t\t\t\tconst text = content.text.trim();\n\t\t\t\t\tif (text) descriptors.push({ kind: \"text-md\", text });\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"thinking\": {\n\t\t\t\t\tconst thinkingBlocks: string[] = [];\n\t\t\t\t\tlet hasTiming = false;\n\t\t\t\t\tlet isDone = true;\n\t\t\t\t\tlet minStart = Number.POSITIVE_INFINITY;\n\t\t\t\t\tlet maxEnd = Number.NEGATIVE_INFINITY;\n\t\t\t\t\tfor (; i < message.content.length; i++) {\n\t\t\t\t\t\tconst thinkingContent = message.content[i];\n\t\t\t\t\t\tif (thinkingContent.type !== \"thinking\") break;\n\t\t\t\t\t\tconst startedAt = thinkingContent.startedAt;\n\t\t\t\t\t\tif (startedAt !== undefined) {\n\t\t\t\t\t\t\thasTiming = true;\n\t\t\t\t\t\t\tminStart = Math.min(minStart, startedAt);\n\t\t\t\t\t\t\tconst endedAt = thinkingContent.endedAt;\n\t\t\t\t\t\t\tif (endedAt === undefined) {\n\t\t\t\t\t\t\t\tisDone = false;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tmaxEnd = Math.max(maxEnd, endedAt);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst thinking = thinkingContent.thinking.trim();\n\t\t\t\t\t\tif (thinking) thinkingBlocks.push(thinking);\n\t\t\t\t\t}\n\t\t\t\t\ti--;\n\t\t\t\t\tif (thinkingBlocks.length === 0) break;\n\t\t\t\t\tif (!hasTiming) {\n\t\t\t\t\t\tconst text = this.hideThinkingBlock\n\t\t\t\t\t\t\t? theme.italic(theme.fg(\"thinkingText\", this.hiddenThinkingLabel))\n\t\t\t\t\t\t\t: thinkingBlocks.join(\"\\n\\n\");\n\t\t\t\t\t\tdescriptors.push({ kind: this.hideThinkingBlock ? \"thinking-label\" : \"thinking-md\", text });\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst label = isDone\n\t\t\t\t\t\t\t? theme.italic(\n\t\t\t\t\t\t\t\t\ttheme.fg(\"thinkingText\", `Thought: ${formatDuration(Math.max(0, maxEnd - minStart))}`),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: theme.italic(theme.fg(\"thinkingText\", this.hiddenThinkingLabel));\n\t\t\t\t\t\tif (this.hideThinkingBlock) {\n\t\t\t\t\t\t\tdescriptors.push({ kind: \"thinking-label\", text: label });\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdescriptors.push(\n\t\t\t\t\t\t\t\t{ kind: \"thinking-label\", text: label },\n\t\t\t\t\t\t\t\t{ kind: \"thinking-md\", text: thinkingBlocks.join(\"\\n\\n\") },\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (message.content.slice(i + 1).some((following) => isVisibleContent(following, false)))\n\t\t\t\t\t\tdescriptors.push(SPACER_DESCRIPTOR);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"providerNative\":\n\t\t\t\t\tdescriptors.push(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkind: \"provider-native-summary\",\n\t\t\t\t\t\t\ttext: theme.fg(\"muted\", formatProviderNativeSummary(message, content, this.expanded)),\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkind: \"provider-native-body\",\n\t\t\t\t\t\t\ttext: theme.fg(\"dim\", formatProviderNativeBody(content, this.expanded)),\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\tif (message.content.slice(i + 1).some((following) => isVisibleContent(following, true)))\n\t\t\t\t\t\tdescriptors.push(SPACER_DESCRIPTOR);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"toolCall\":\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tassertNever(content);\n\t\t\t}\n\t\t}\n\t\tconst addError = (text: string): void => {\n\t\t\tdescriptors.push(SPACER_DESCRIPTOR, { kind: \"error-text\", text: theme.fg(\"error\", text) });\n\t\t};\n\t\tswitch (message.stopReason) {\n\t\t\tcase \"length\":\n\t\t\t\taddError(\n\t\t\t\t\t\"Error: Model stopped because it reached the maximum output token limit. The response may be incomplete.\",\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase \"aborted\": {\n\t\t\t\tif (this.hasToolCalls) break;\n\t\t\t\tconst abortMessage =\n\t\t\t\t\tmessage.errorMessage && message.errorMessage !== \"Request was aborted\"\n\t\t\t\t\t\t? message.errorMessage\n\t\t\t\t\t\t: \"Operation aborted\";\n\t\t\t\taddError(abortMessage);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"error\":\n\t\t\t\tif (!this.hasToolCalls) addError(`Error: ${message.errorMessage || \"Unknown error\"}`);\n\t\t\t\tbreak;\n\t\t\tcase \"stop\":\n\t\t\tcase \"toolUse\":\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tassertNever(message.stopReason);\n\t\t}\n\t\treturn descriptors;\n\t}\n\n\tprivate reconcileRenderDescriptors(descriptors: readonly RenderDescriptor[]): void {\n\t\tlet divergentIndex = 0;\n\t\tconst sharedLength = Math.min(this.renderDescriptors.length, descriptors.length);\n\t\twhile (divergentIndex < sharedLength) {\n\t\t\tconst previous = this.renderDescriptors[divergentIndex];\n\t\t\tconst next = descriptors[divergentIndex];\n\t\t\tconst child = this.contentContainer.children[divergentIndex];\n\t\t\tif (!previous || !next || !child || previous.kind !== next.kind) break;\n\t\t\tif (previous.text !== next.text) {\n\t\t\t\tif ((next.kind === \"text-md\" || next.kind === \"thinking-md\") && child instanceof Markdown) {\n\t\t\t\t\tchild.setText(next.text);\n\t\t\t\t} else break;\n\t\t\t}\n\t\t\tdivergentIndex++;\n\t\t}\n\t\tfor (const child of this.contentContainer.children.splice(divergentIndex)) child.dispose?.();\n\t\tfor (const descriptor of descriptors.slice(divergentIndex))\n\t\t\tthis.contentContainer.addChild(this.createRenderChild(descriptor));\n\t\tthis.renderDescriptors = descriptors;\n\t}\n\n\tprivate createRenderChild(descriptor: RenderDescriptor): Component {\n\t\tswitch (descriptor.kind) {\n\t\t\tcase \"spacer\":\n\t\t\t\treturn new Spacer(1);\n\t\t\tcase \"text-md\":\n\t\t\t\treturn new Markdown(descriptor.text, this.outputPad, 0, this.markdownTheme);\n\t\t\tcase \"thinking-md\":\n\t\t\t\treturn new Markdown(descriptor.text, this.outputPad, 0, this.markdownTheme, {\n\t\t\t\t\tcolor: (text: string) => theme.fg(\"thinkingText\", text),\n\t\t\t\t\titalic: true,\n\t\t\t\t});\n\t\t\tcase \"thinking-label\":\n\t\t\tcase \"error-text\":\n\t\t\t\treturn new Text(descriptor.text, this.outputPad, 0);\n\t\t\tcase \"provider-native-summary\":\n\t\t\t\treturn new Text(descriptor.text, 1, 0);\n\t\t\tcase \"provider-native-body\":\n\t\t\t\treturn new Text(descriptor.text, 3, 0);\n\t\t\tdefault:\n\t\t\t\treturn assertNever(descriptor.kind);\n\t\t}\n\t}\n\n\tprivate createMessageSignature(message: AssistantMessage): string {\n\t\treturn createBoundedRenderSignature({\n\t\t\tcontent: message.content,\n\t\t\thiddenThinkingLabel: this.hiddenThinkingLabel,\n\t\t\thideThinkingBlock: this.hideThinkingBlock,\n\t\t\terrorMessage: message.errorMessage,\n\t\t\tstopReason: message.stopReason,\n\t\t});\n\t}\n\n\tprivate cacheRender(width: number, signature: string, lines: string[]): void {\n\t\tthis.renderCache = { lines: [...lines], signature, width };\n\t}\n\n\tprivate refreshContent(): void {\n\t\tif (!this.lastMessage) return;\n\t\tthis.lastMessageSignature = undefined;\n\t\tthis.updateContent(this.lastMessage);\n\t}\n}\n"]}
|
|
@@ -20,7 +20,7 @@ export function readToolProgress(details) {
|
|
|
20
20
|
export function formatToolProgressLine(progress, now, spinnerFrame) {
|
|
21
21
|
const activity = progress.activity || "working";
|
|
22
22
|
const elapsed = formatWorkingElapsedSeconds((now - progress.startedAt) / 1_000);
|
|
23
|
-
const maxWait = progress.maxWaitMs === undefined ? "" : ` / max ${
|
|
23
|
+
const maxWait = progress.maxWaitMs === undefined ? "" : ` / max ${formatWorkingElapsedSeconds(progress.maxWaitMs / 1_000)}`;
|
|
24
24
|
const spinner = TOOL_PROGRESS_SPINNER_FRAMES[(spinnerFrame ?? 0) % TOOL_PROGRESS_SPINNER_FRAMES.length] ??
|
|
25
25
|
TOOL_PROGRESS_SPINNER_FRAMES[0];
|
|
26
26
|
return `${spinner} ${activity} · ${elapsed}${maxWait}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-progress.js","sourceRoot":"","sources":["../../../src/modes/interactive/tool-progress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAElE,MAAM,4BAA4B,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAU,CAAC;AAQjG,MAAM,UAAU,gBAAgB,CAAC,OAAgB;IAChD,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,UA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\", \"⠏\"] as const;\n\nexport interface ToolProgressDetails {\n\treadonly activity?: string;\n\treadonly startedAt: number;\n\treadonly maxWaitMs?: number;\n}\n\nexport function readToolProgress(details: unknown): ToolProgressDetails | undefined {\n\tif (typeof details !== \"object\" || details === null || !(\"progress\" in details)) return undefined;\n\tconst progress = details.progress;\n\tif (typeof progress !== \"object\" || progress === null || !(\"startedAt\" in progress)) return undefined;\n\tif (typeof progress.startedAt !== \"number\" || !Number.isFinite(progress.startedAt)) return undefined;\n\tif (\"activity\" in progress && typeof progress.activity !== \"string\") return undefined;\n\tif (\"maxWaitMs\" in progress && (typeof progress.maxWaitMs !== \"number\" || !Number.isFinite(progress.maxWaitMs))) {\n\t\treturn undefined;\n\t}\n\tconst activity = \"activity\" in progress && typeof progress.activity === \"string\" ? progress.activity : undefined;\n\tconst maxWaitMs = \"maxWaitMs\" in progress && typeof progress.maxWaitMs === \"number\" ? progress.maxWaitMs : undefined;\n\treturn { activity, startedAt: progress.startedAt, maxWaitMs };\n}\n\nexport function formatToolProgressLine(progress: ToolProgressDetails, now: number, spinnerFrame?: number): string {\n\tconst activity = progress.activity || \"working\";\n\tconst elapsed = formatWorkingElapsedSeconds((now - progress.startedAt) / 1_000);\n\tconst maxWait =\n\t\tprogress.maxWaitMs === undefined ? \"\" : ` / max ${formatWorkingElapsedSeconds(progress.maxWaitMs / 1_000)}`;\n\tconst spinner =\n\t\tTOOL_PROGRESS_SPINNER_FRAMES[(spinnerFrame ?? 0) % TOOL_PROGRESS_SPINNER_FRAMES.length] ??\n\t\tTOOL_PROGRESS_SPINNER_FRAMES[0];\n\treturn `${spinner} ${activity} · ${elapsed}${maxWait}`;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../src/utils/duration.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAcjD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function formatDuration(ms) {
|
|
2
|
+
if (ms < 1000) {
|
|
3
|
+
return `${ms}ms`;
|
|
4
|
+
}
|
|
5
|
+
if (ms < 60000) {
|
|
6
|
+
return `${(ms / 1000).toFixed(1)}s`;
|
|
7
|
+
}
|
|
8
|
+
if (ms < 3_600_000) {
|
|
9
|
+
return `${Math.floor(ms / 60000)}m ${Math.floor((ms % 60000) / 1000)}s`;
|
|
10
|
+
}
|
|
11
|
+
if (ms < 86_400_000) {
|
|
12
|
+
return `${Math.floor(ms / 3_600_000)}h ${Math.floor((ms % 3_600_000) / 60000)}m`;
|
|
13
|
+
}
|
|
14
|
+
return `${Math.floor(ms / 86_400_000)}d ${Math.floor((ms % 86_400_000) / 3_600_000)}h`;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=duration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duration.js","sourceRoot":"","sources":["../../src/utils/duration.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,cAAc,CAAC,EAAU;IACxC,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;QACf,OAAO,GAAG,EAAE,IAAI,CAAC;IAClB,CAAC;IACD,IAAI,EAAE,GAAG,KAAK,EAAE,CAAC;QAChB,OAAO,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IACrC,CAAC;IACD,IAAI,EAAE,GAAG,SAAS,EAAE,CAAC;QACpB,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC;IACzE,CAAC;IACD,IAAI,EAAE,GAAG,UAAU,EAAE,CAAC;QACrB,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,SAAS,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC;IAClF,CAAC;IACD,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,UAAU,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,UAAU,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC;AACxF,CAAC","sourcesContent":["export function formatDuration(ms: number): string {\n\tif (ms < 1000) {\n\t\treturn `${ms}ms`;\n\t}\n\tif (ms < 60000) {\n\t\treturn `${(ms / 1000).toFixed(1)}s`;\n\t}\n\tif (ms < 3_600_000) {\n\t\treturn `${Math.floor(ms / 60000)}m ${Math.floor((ms % 60000) / 1000)}s`;\n\t}\n\tif (ms < 86_400_000) {\n\t\treturn `${Math.floor(ms / 3_600_000)}h ${Math.floor((ms % 3_600_000) / 60000)}m`;\n\t}\n\treturn `${Math.floor(ms / 86_400_000)}d ${Math.floor((ms % 86_400_000) / 3_600_000)}h`;\n}\n"]}
|
package/docs/session-format.md
CHANGED
|
@@ -59,8 +59,12 @@ interface ImageContent {
|
|
|
59
59
|
interface ThinkingContent {
|
|
60
60
|
type: "thinking";
|
|
61
61
|
thinking: string;
|
|
62
|
+
startedAt?: number; // Unix epoch milliseconds
|
|
63
|
+
endedAt?: number; // Unix epoch milliseconds
|
|
62
64
|
}
|
|
63
65
|
|
|
66
|
+
`startedAt` and `endedAt` are optional epoch milliseconds stamped by the agent loop at stream-event receipt on a best-effort basis. They are absent on pre-feature sessions and on messages not produced through the agent loop. Renderers must treat their absence as "no timing available".
|
|
67
|
+
|
|
64
68
|
interface ToolCall {
|
|
65
69
|
type: "toolCall";
|
|
66
70
|
id: string;
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2026.7.23] - 2026-07-23
|
|
4
|
+
|
|
5
|
+
### Breaking Changes
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Added the GPT-only Code Mode runtime with `exec` and `wait` tools, plus model-aware GPT eval routing ([#301](https://github.com/code-yeongyu/senpi/pull/301)).
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
### Removed
|
|
16
|
+
|
|
3
17
|
## [2026.7.22-2] - 2026-07-22
|
|
4
18
|
|
|
5
19
|
### Breaking Changes
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# @code-yeongyu/senpi-codemode
|
|
2
2
|
|
|
3
|
-
`@code-yeongyu/senpi-codemode` is Senpi's source-only
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
`@code-yeongyu/senpi-codemode` is Senpi's source-only Code Mode extension. It
|
|
4
|
+
registers persistent-kernel `eval` for every eligible model and GPT-only
|
|
5
|
+
`exec`/`wait` cells for bounded JavaScript orchestration. `eval` owns one
|
|
6
|
+
persistent kernel per enabled language and re-registers at session start after
|
|
7
|
+
configuration, interpreter availability, and active task-tool names are known.
|
|
7
8
|
|
|
8
9
|
## Capabilities
|
|
9
10
|
|
|
@@ -19,6 +20,8 @@ interpreter availability, and active task-tool names are known.
|
|
|
19
20
|
fallbacks.
|
|
20
21
|
- JavaScript import rewriting for supported local modules and package imports
|
|
21
22
|
in the persistent Node.js worker.
|
|
23
|
+
- GPT Code Mode `exec`/`wait` cells use fresh JavaScript workers, can compose
|
|
24
|
+
active tools through `tools.<name>(args)`, and never replace `eval`.
|
|
22
25
|
|
|
23
26
|
## Kernels
|
|
24
27
|
|
|
@@ -93,7 +96,7 @@ options object and asynchronous helpers are `await`-able.
|
|
|
93
96
|
| `read(path, offset?, limit?)` | Reads text with 1-indexed line slicing. `local://` paths resolve under the session artifact root. |
|
|
94
97
|
| `write(path, content)` | Creates parent directories and writes text. `local://` paths persist in the session artifact root. |
|
|
95
98
|
| `env(key?, value?)` | Reads all kernel environment values, one value, or sets one value. |
|
|
96
|
-
| `tool.<name>(args)` | Invokes an active Senpi tool through the normal `pi.executeTool` pipeline. |
|
|
99
|
+
| `tool.<name>(args)` / `tools.<name>(args)` | Invokes an active Senpi tool through the normal `pi.executeTool` pipeline. `tools` is the GPT Code Mode spelling. |
|
|
97
100
|
| `completion(prompt, model?, system?, schema?)` | Requests a one-shot host completion; `schema` asks the host to parse structured output. |
|
|
98
101
|
| `agent(prompt, ...)` | Delegates to the configured active `taskTools.task` tool. Supports background handles and structured JSON results. |
|
|
99
102
|
| `output(ids, format?, offset?, limit?)` | Delegates transcript retrieval to the configured active `taskTools.output` tool. |
|
|
@@ -136,6 +139,12 @@ Session generations fence retired kernels and callbacks; each cell settles once
|
|
|
136
139
|
across completion, errors, cancellation, timeout, bridge failure, or a kernel
|
|
137
140
|
crash.
|
|
138
141
|
|
|
142
|
+
GPT Code Mode is not an additional sandbox: it uses the same Node worker trust
|
|
143
|
+
boundary as JavaScript `eval`. Its separate cell lifecycle exists so a yielded
|
|
144
|
+
`exec` can be observed or terminated with `wait` without affecting persistent
|
|
145
|
+
`eval` kernels. `eval`, `exec`, and `wait` are excluded from the nested tool
|
|
146
|
+
namespace to prevent recursive Code Mode execution.
|
|
147
|
+
|
|
139
148
|
## Validation
|
|
140
149
|
|
|
141
150
|
```bash
|
|
@@ -148,5 +157,5 @@ npm run check
|
|
|
148
157
|
|
|
149
158
|
Direct real-surface QA drivers live in `scripts/qa-*.ts`: kernel cells
|
|
150
159
|
(`qa-py-cell.ts`, `qa-js-cell.ts`, `qa-rb-cell.ts`, `qa-jl-cell.ts`), end-to-end
|
|
151
|
-
extension execution (`qa-e2e-eval.ts`), and renderer output
|
|
160
|
+
extension execution (`qa-e2e-eval.ts`, `qa-gpt-code-mode.ts`), and renderer output
|
|
152
161
|
(`qa-render-dump.ts`).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-yeongyu/senpi-codemode",
|
|
3
|
-
"version": "2026.7.
|
|
3
|
+
"version": "2026.7.23",
|
|
4
4
|
"description": "Source-only senpi extension package for codemode evaluation tools",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@babel/parser": "7.29.7",
|
|
33
|
-
"@earendil-works/pi-ai": "^2026.7.
|
|
33
|
+
"@earendil-works/pi-ai": "^2026.7.23",
|
|
34
34
|
"typebox": "1.1.38"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@code-yeongyu/senpi": "*"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@code-yeongyu/senpi": "2026.7.
|
|
40
|
+
"@code-yeongyu/senpi": "2026.7.23"
|
|
41
41
|
},
|
|
42
42
|
"keywords": [
|
|
43
43
|
"senpi",
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import type { KernelToHostMessage } from "../bridge/protocol.ts";
|
|
2
|
+
import type { AgentExecuteTool } from "../bridges/agent-bridge.ts";
|
|
3
|
+
import { JavaScriptKernel } from "../kernels/js/context-manager.ts";
|
|
4
|
+
import { marshalToolResult } from "../tool/image.ts";
|
|
5
|
+
|
|
6
|
+
const MAX_ACTIVE_CELLS = 4;
|
|
7
|
+
const MAX_PENDING_OUTPUT_CHARS = 100_000;
|
|
8
|
+
const MAX_TERMINAL_ERROR_CHARS = 4_096;
|
|
9
|
+
const RECURSIVE_TOOLS = new Set(["eval", "exec", "wait"]);
|
|
10
|
+
|
|
11
|
+
export type CodeModeCellState = "yielded" | "result" | "terminated" | "error" | "missing";
|
|
12
|
+
|
|
13
|
+
export interface CodeModeObservation {
|
|
14
|
+
readonly cellId: string;
|
|
15
|
+
readonly state: CodeModeCellState;
|
|
16
|
+
readonly output: string;
|
|
17
|
+
readonly error?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface CodeModeRuntimeOptions {
|
|
21
|
+
readonly sessionId: string;
|
|
22
|
+
readonly cwd: string;
|
|
23
|
+
readonly parallelPoolWidth: number;
|
|
24
|
+
readonly executeTool: AgentExecuteTool;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export class CodeModeCapacityError extends Error {
|
|
28
|
+
readonly name = "CodeModeCapacityError";
|
|
29
|
+
|
|
30
|
+
constructor() {
|
|
31
|
+
super(`Code Mode supports at most ${MAX_ACTIVE_CELLS} active cells`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class CodeModeSessionRuntime {
|
|
36
|
+
readonly #options: CodeModeRuntimeOptions;
|
|
37
|
+
readonly #cells = new Map<string, CodeModeCell>();
|
|
38
|
+
#nextCell = 0;
|
|
39
|
+
#disposed = false;
|
|
40
|
+
|
|
41
|
+
constructor(options: CodeModeRuntimeOptions) {
|
|
42
|
+
this.#options = options;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async execute(code: string, yieldTimeMs: number, signal: AbortSignal | undefined): Promise<CodeModeObservation> {
|
|
46
|
+
this.#assertActive();
|
|
47
|
+
const cellId = `exec-${++this.#nextCell}`;
|
|
48
|
+
if (signal?.aborted) return { cellId, state: "terminated", output: "" };
|
|
49
|
+
if (this.#cells.size >= MAX_ACTIVE_CELLS) throw new CodeModeCapacityError();
|
|
50
|
+
const cell = new CodeModeCell(cellId, this.#options);
|
|
51
|
+
this.#cells.set(cellId, cell);
|
|
52
|
+
cell.start(code);
|
|
53
|
+
const observation = await cell.observe(yieldTimeMs, signal);
|
|
54
|
+
this.#releaseIfTerminal(observation);
|
|
55
|
+
return observation;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async wait(
|
|
59
|
+
cellId: string,
|
|
60
|
+
yieldTimeMs: number,
|
|
61
|
+
terminate: boolean,
|
|
62
|
+
signal: AbortSignal | undefined,
|
|
63
|
+
): Promise<CodeModeObservation> {
|
|
64
|
+
const cell = this.#cells.get(cellId);
|
|
65
|
+
if (cell === undefined) return { cellId, state: "missing", output: "" };
|
|
66
|
+
const observation = terminate ? await cell.terminate() : await cell.observe(yieldTimeMs, signal);
|
|
67
|
+
this.#releaseIfTerminal(observation);
|
|
68
|
+
return observation;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async dispose(): Promise<void> {
|
|
72
|
+
if (this.#disposed) return;
|
|
73
|
+
this.#disposed = true;
|
|
74
|
+
const cells = [...this.#cells.values()];
|
|
75
|
+
this.#cells.clear();
|
|
76
|
+
await Promise.all(cells.map((cell) => cell.terminate()));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
#releaseIfTerminal(observation: CodeModeObservation): void {
|
|
80
|
+
if (observation.state !== "yielded") this.#cells.delete(observation.cellId);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
#assertActive(): void {
|
|
84
|
+
if (this.#disposed) throw new Error("Code Mode session has been disposed");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
class CodeModeCell {
|
|
89
|
+
readonly #id: string;
|
|
90
|
+
readonly #options: CodeModeRuntimeOptions;
|
|
91
|
+
readonly #kernel: JavaScriptKernel;
|
|
92
|
+
readonly #abort = new AbortController();
|
|
93
|
+
#output = "";
|
|
94
|
+
#outputTruncated = false;
|
|
95
|
+
#completion: Promise<void> | undefined;
|
|
96
|
+
#state: "running" | "result" | "terminated" | "error" = "running";
|
|
97
|
+
#error: string | undefined;
|
|
98
|
+
|
|
99
|
+
constructor(id: string, options: CodeModeRuntimeOptions) {
|
|
100
|
+
this.#id = id;
|
|
101
|
+
this.#options = options;
|
|
102
|
+
this.#kernel = new JavaScriptKernel({
|
|
103
|
+
sessionId: `${options.sessionId}:${id}`,
|
|
104
|
+
cwd: options.cwd,
|
|
105
|
+
parallelPoolWidth: options.parallelPoolWidth,
|
|
106
|
+
onMessage: (message) => this.#handleMessage(message),
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
start(code: string): void {
|
|
111
|
+
this.#completion = this.#kernel
|
|
112
|
+
.run({ cellId: this.#id, code })
|
|
113
|
+
.then((result) => {
|
|
114
|
+
if (this.#state !== "running") return;
|
|
115
|
+
if (result.ok) {
|
|
116
|
+
this.#state = "result";
|
|
117
|
+
if (result.valueRepr) this.#appendOutput(`${result.valueRepr}\n`);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
this.#state = "error";
|
|
121
|
+
this.#error = truncateTerminalError(result.error.message);
|
|
122
|
+
})
|
|
123
|
+
.catch((error: unknown) => {
|
|
124
|
+
if (this.#state !== "running") return;
|
|
125
|
+
this.#state = "error";
|
|
126
|
+
this.#error = truncateTerminalError(error instanceof Error ? error.message : String(error));
|
|
127
|
+
})
|
|
128
|
+
.finally(async () => {
|
|
129
|
+
if (this.#state !== "running") await this.#kernel.close();
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
async observe(yieldTimeMs: number, signal: AbortSignal | undefined): Promise<CodeModeObservation> {
|
|
134
|
+
if (signal?.aborted) return await this.terminate();
|
|
135
|
+
if (this.#state !== "running") return this.#observation();
|
|
136
|
+
const completion = this.#completion;
|
|
137
|
+
if (completion === undefined) throw new Error("Code Mode cell has not started");
|
|
138
|
+
const timeout = Math.max(1, Math.trunc(yieldTimeMs));
|
|
139
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
140
|
+
let abortListener: (() => void) | undefined;
|
|
141
|
+
const timedOut = new Promise<"yielded">((resolve) => {
|
|
142
|
+
timer = setTimeout(() => resolve("yielded"), timeout);
|
|
143
|
+
});
|
|
144
|
+
const completed = completion.then(() => "completed" as const);
|
|
145
|
+
const aborted = new Promise<"aborted">((resolve) => {
|
|
146
|
+
if (!signal) return;
|
|
147
|
+
abortListener = () => resolve("aborted");
|
|
148
|
+
signal.addEventListener("abort", abortListener, { once: true });
|
|
149
|
+
});
|
|
150
|
+
try {
|
|
151
|
+
const outcome = await Promise.race([completed, timedOut, aborted]);
|
|
152
|
+
if (outcome === "aborted") return await this.terminate();
|
|
153
|
+
return this.#observation();
|
|
154
|
+
} finally {
|
|
155
|
+
if (timer !== undefined) clearTimeout(timer);
|
|
156
|
+
if (abortListener && signal) signal.removeEventListener("abort", abortListener);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
async terminate(): Promise<CodeModeObservation> {
|
|
161
|
+
if (this.#state === "terminated") return this.#observation();
|
|
162
|
+
if (this.#state === "result" || this.#state === "error") return this.#observation();
|
|
163
|
+
this.#state = "terminated";
|
|
164
|
+
this.#abort.abort(new Error("Code Mode cell terminated"));
|
|
165
|
+
try {
|
|
166
|
+
await this.#kernel.interrupt("Code Mode cell terminated");
|
|
167
|
+
} finally {
|
|
168
|
+
await this.#kernel.close();
|
|
169
|
+
}
|
|
170
|
+
return this.#observation();
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
#handleMessage(message: KernelToHostMessage): void {
|
|
174
|
+
if (message.type === "text") {
|
|
175
|
+
this.#appendOutput(message.data);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
if (message.type === "display") {
|
|
179
|
+
this.#appendOutput(`[display ${message.mimeType}]\n`);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (message.type === "tool-call") void this.#invokeTool(message);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
async #invokeTool(message: Extract<KernelToHostMessage, { type: "tool-call" }>): Promise<void> {
|
|
186
|
+
if (RECURSIVE_TOOLS.has(message.toolName)) {
|
|
187
|
+
this.#kernel.deliverToolReply({
|
|
188
|
+
type: "tool-reply",
|
|
189
|
+
callId: message.callId,
|
|
190
|
+
ok: false,
|
|
191
|
+
error: { message: `recursive Code Mode tool "${message.toolName}" is not allowed` },
|
|
192
|
+
});
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (this.#options.executeTool.isToolAvailable?.(message.toolName) === false) {
|
|
196
|
+
this.#kernel.deliverToolReply({
|
|
197
|
+
type: "tool-reply",
|
|
198
|
+
callId: message.callId,
|
|
199
|
+
ok: false,
|
|
200
|
+
error: { message: `nested tool "${message.toolName}" is not active` },
|
|
201
|
+
});
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
try {
|
|
205
|
+
const result = await this.#options.executeTool(message.toolName, message.args, { signal: this.#abort.signal });
|
|
206
|
+
this.#kernel.deliverToolReply({
|
|
207
|
+
type: "tool-reply",
|
|
208
|
+
callId: message.callId,
|
|
209
|
+
ok: true,
|
|
210
|
+
value: marshalToolResult(result),
|
|
211
|
+
});
|
|
212
|
+
} catch (error) {
|
|
213
|
+
this.#kernel.deliverToolReply({
|
|
214
|
+
type: "tool-reply",
|
|
215
|
+
callId: message.callId,
|
|
216
|
+
ok: false,
|
|
217
|
+
error: { message: error instanceof Error ? error.message : String(error) },
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
#observation(): CodeModeObservation {
|
|
223
|
+
let output = this.#output;
|
|
224
|
+
this.#output = "";
|
|
225
|
+
if (this.#outputTruncated) {
|
|
226
|
+
output += "\n[output truncated]\n";
|
|
227
|
+
this.#outputTruncated = false;
|
|
228
|
+
}
|
|
229
|
+
if (this.#state === "running") return { cellId: this.#id, state: "yielded", output };
|
|
230
|
+
if (this.#state === "terminated") return { cellId: this.#id, state: "terminated", output };
|
|
231
|
+
if (this.#state === "error") {
|
|
232
|
+
const error = this.#error ?? "Code Mode cell failed";
|
|
233
|
+
if (output !== "") output += output.endsWith("\n") ? error : `\n${error}`;
|
|
234
|
+
else output = error;
|
|
235
|
+
return { cellId: this.#id, state: "error", output, error };
|
|
236
|
+
}
|
|
237
|
+
return { cellId: this.#id, state: "result", output };
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
#appendOutput(value: string): void {
|
|
241
|
+
const remaining = MAX_PENDING_OUTPUT_CHARS - this.#output.length;
|
|
242
|
+
if (remaining <= 0) {
|
|
243
|
+
this.#outputTruncated = true;
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
if (value.length > remaining) {
|
|
247
|
+
this.#output += value.slice(0, remaining);
|
|
248
|
+
this.#outputTruncated = true;
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
this.#output += value;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function truncateTerminalError(message: string): string {
|
|
256
|
+
if (message.length <= MAX_TERMINAL_ERROR_CHARS) return message;
|
|
257
|
+
return `${message.slice(0, MAX_TERMINAL_ERROR_CHARS)}\n[error truncated]`;
|
|
258
|
+
}
|