@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-remote.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/openai-remote.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAK5D,MAAM,CAAC,MAAM,+BAA+B,GAAG,mCAAmC,CAAC;AACnF,MAAM,CAAC,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAsLzD,MAAM,mCAAmC,GAAG,MAAM,CAAC;AACnD,MAAM,gCAAgC,GAAG,2BAA2B,CAAC;AAErE,SAAS,QAAQ,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC7E,CAAC;AAED,SAAS,eAAe,CAAC,KAAyB;IACjD,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,SAAS,CAAC;IAC9C,IAAI,CAAC;QACJ,MAAM,MAAM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AgB,EAAE,GAAG,mBAAmB,CAAC,CAAC;IACpH,IAAI,EAAE,CAAC;QACN,OAAO,EAAE,CAAC;QACV,MAAM,EAAE,0BAA0B;QAClC,KAAK,EAAE,kCAAkC;QACzC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE;QACzB,iBAAiB,EAAE,MAAM,CAAC,OAAO;QACjC,cAAc,EAAE,KAAK,CAAC,MAAM;KAC5B,CAAC,CAAC;IACH,OAAO,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["import type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type {\n\tApi,\n\tAssistantMessage,\n\tContext,\n\tImageContent,\n\tModel,\n\tSimpleStreamOptions,\n\tTextContent,\n\tToolCall,\n} from \"@earendil-works/pi-ai\";\nimport { streamSimple } from \"@earendil-works/pi-ai/compat\";\nimport type { CompactionResult } from \"../../../compaction/index.ts\";\nimport type { SessionEntry } from \"../../../session-manager.ts\";\nimport type { ServiceTier, SessionBeforeCompactEvent } from \"../../types.ts\";\n\nexport const OPENAI_REMOTE_COMPACTION_SCHEMA = \"senpi.compaction.openai-remote.v1\";\nexport const SENPI_COMPACTION_EVENT = \"senpi:compaction\";\n\ntype OpenAiInputText = { type: \"input_text\"; text: string };\ntype OpenAiInputImage = { type: \"input_image\"; detail: \"auto\"; image_url: string };\ntype OpenAiInputContent = OpenAiInputText | OpenAiInputImage;\ntype OpenAiOutputText = { type: \"output_text\"; text: string; annotations: [] };\ntype OpenAiMessageInputItem = {\n\ttype?: \"message\";\n\tid?: string;\n\trole: \"user\" | \"system\" | \"developer\";\n\tcontent: string | OpenAiInputContent[];\n\tstatus?: \"in_progress\" | \"completed\" | \"incomplete\";\n};\ntype OpenAiAssistantMessageItem = {\n\ttype: \"message\";\n\tid: string;\n\trole: \"assistant\";\n\tstatus: \"completed\";\n\tcontent: OpenAiOutputText[];\n\tphase?: \"commentary\" | \"final_answer\";\n};\ntype OpenAiFunctionCallItem = {\n\ttype: \"function_call\";\n\tid?: string;\n\tcall_id: string;\n\tname: string;\n\targuments: string;\n};\ntype OpenAiFunctionCallOutputItem = {\n\ttype: \"function_call_output\";\n\tcall_id: string;\n\toutput: string;\n};\ntype OpenAiRemoteTransport = \"websocket\" | \"compact-endpoint\";\ntype OpenAiCompactionItem = {\n\ttype: \"compaction\";\n\tencrypted_content: string;\n\tid?: string | null;\n\tcreated_by?: string;\n};\ntype OpenAiContextCompactionItem = {\n\ttype: \"context_compaction\";\n\tencrypted_content: string;\n\tid?: string | null;\n\tcreated_by?: string;\n};\ntype OpenAiContextCompactionTriggerItem = {\n\ttype: \"context_compaction\";\n};\ntype OpenAiProviderNativeItem = Record<string, unknown> & { type: string };\nexport type OpenAiRemoteInputItem =\n\t| OpenAiMessageInputItem\n\t| OpenAiAssistantMessageItem\n\t| OpenAiFunctionCallItem\n\t| OpenAiFunctionCallOutputItem\n\t| OpenAiCompactionItem\n\t| OpenAiContextCompactionItem\n\t| OpenAiProviderNativeItem;\n\ntype OpenAiCompactBody = {\n\tmodel: string;\n\tinput: OpenAiRemoteInputItem[];\n\tinstructions?: string;\n\tprompt_cache_key?: string;\n\tservice_tier?: ServiceTier;\n};\n\nexport type OpenAiRemoteCompactionDetails = {\n\tschema: typeof OPENAI_REMOTE_COMPACTION_SCHEMA;\n\tmode: \"openai-remote\";\n\tprovider: \"openai\";\n\tapi: \"openai-responses\";\n\ttransport: OpenAiRemoteTransport;\n\tmodelId: string;\n\tresponseId: string;\n\tcreatedAt: number;\n\trequestInputItemCount: number;\n\tretainedInputItemCount: number;\n\treplacementInput: OpenAiRemoteInputItem[];\n\tusage?: Record<string, unknown>;\n};\n\nexport type OpenAiRemoteCompactionRequest = {\n\tbody: OpenAiCompactBody;\n\tinputItemCount: number;\n\ttokensBefore: number;\n};\n\nexport type OpenAiRemoteCompactionResult = CompactionResult<OpenAiRemoteCompactionDetails> & {\n\tdetails: OpenAiRemoteCompactionDetails;\n};\n\ntype OpenAiCompactedResponse = {\n\tid: string;\n\tcreated_at: number;\n\tobject: \"response.compaction\";\n\toutput: OpenAiRemoteInputItem[];\n\tusage?: Record<string, unknown>;\n};\n\ntype OpenAiResponsesStream = {\n\tresult(): Promise<AssistantMessage>;\n};\n\ntype OpenAiResponsesStreamRunner = (\n\tmodel: Model<\"openai-responses\">,\n\tcontext: Context,\n\toptions: SimpleStreamOptions,\n) => OpenAiResponsesStream;\n\ntype OpenAiRemoteCompactionDependencies = {\n\tfetch?: typeof fetch;\n\tnow?: () => number;\n\tremoteTimeoutMs?: number;\n\tstreamRunner?: OpenAiResponsesStreamRunner;\n};\n\ntype OpenAiRemoteCompactionContext = {\n\tgetSystemPrompt(): string;\n\tmodel: Model<Api> | undefined;\n\tmodelRegistry: {\n\t\tgetApiKeyAndHeaders(model: Model<Api>): Promise<\n\t\t\t| {\n\t\t\t\t\tok: true;\n\t\t\t\t\tapiKey?: string;\n\t\t\t\t\theaders?: Record<string, string>;\n\t\t\t\t\textraBody?: Record<string, unknown>;\n\t\t\t\t\tupstreamModelId?: string;\n\t\t\t\t\tserviceTier?: ServiceTier;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tok: false;\n\t\t\t\t\terror: string;\n\t\t\t }\n\t\t>;\n\t};\n\tserviceTier: ServiceTier | undefined;\n\tsessionManager: {\n\t\tgetSessionId(): string;\n\t};\n};\n\ntype OpenAiRemoteCompactionEvent =\n\t| {\n\t\t\tversion: 1;\n\t\t\taction: \"remote_started\";\n\t\t\troute: \"builtin.compaction.openai_remote\";\n\t\t\trequestId: string;\n\t\t\tmodelId: string;\n\t\t\tinputItemCount: number;\n\t\t\ttransport: OpenAiRemoteTransport;\n\t }\n\t| {\n\t\t\tversion: 1;\n\t\t\taction: \"remote_completed\";\n\t\t\troute: \"builtin.compaction.openai_remote\";\n\t\t\trequestId: string;\n\t\t\tmodelId: string;\n\t\t\tresponseId: string;\n\t\t\tretainedInputItemCount: number;\n\t\t\ttransport: OpenAiRemoteTransport;\n\t }\n\t| {\n\t\t\tversion: 1;\n\t\t\taction: \"remote_fallback\";\n\t\t\troute: \"builtin.compaction.openai_remote\";\n\t\t\trequestId: string;\n\t\t\tmodelId?: string;\n\t\t\treason: string;\n\t\t\ttransport?: OpenAiRemoteTransport;\n\t }\n\t| {\n\t\t\tversion: 1;\n\t\t\taction: \"remote_payload_rewritten\";\n\t\t\troute: \"builtin.compaction.openai_remote\";\n\t\t\tmodelId: string;\n\t\t\tcompactionEntryId: string;\n\t\t\tinputItemCount: number;\n\t };\n\ntype EmitCompactionEvent = (event: OpenAiRemoteCompactionEvent) => void;\n\nconst OPENAI_REMOTE_COMPACTION_TIMEOUT_MS = 15_000;\nconst REMOTE_COMPACTION_TIMEOUT_REASON = \"remote-compaction-timeout\";\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction parseJsonRecord(value: string | undefined): Record<string, unknown> | undefined {\n\tif (!value?.startsWith(\"{\")) return undefined;\n\ttry {\n\t\tconst parsed: unknown = JSON.parse(value);\n\t\treturn isRecord(parsed) ? parsed : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction parseTextSignature(\n\tsignature: string | undefined,\n): { id: string; phase?: \"commentary\" | \"final_answer\" } | undefined {\n\tif (!signature) return undefined;\n\tconst parsed = parseJsonRecord(signature);\n\tif (parsed?.v === 1 && typeof parsed.id === \"string\") {\n\t\tif (parsed.phase === \"commentary\" || parsed.phase === \"final_answer\") {\n\t\t\treturn { id: parsed.id, phase: parsed.phase };\n\t\t}\n\t\treturn { id: parsed.id };\n\t}\n\treturn { id: signature };\n}\n\nfunction isOpenAiResponsesModel(model: Model<Api> | undefined): model is Model<\"openai-responses\"> {\n\treturn model?.provider === \"openai\" && model.api === \"openai-responses\";\n}\n\nfunction supportsOpenAiResponsesWebSocket(model: Model<\"openai-responses\">): boolean {\n\tif (model.compat?.supportsWebSocket !== undefined) return model.compat.supportsWebSocket;\n\ttry {\n\t\treturn new URL(model.baseUrl || \"https://api.openai.com/v1\").hostname === \"api.openai.com\";\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction toolResultText(content: string | TextContent[] | (TextContent | ImageContent)[]): string | undefined {\n\tif (typeof content === \"string\") return content;\n\tconst parts: string[] = [];\n\tfor (const block of content) {\n\t\tif (block.type !== \"text\") return undefined;\n\t\tparts.push(block.text);\n\t}\n\treturn parts.join(\"\\n\");\n}\n\nfunction convertUserContent(content: string | (TextContent | ImageContent)[]): OpenAiInputContent[] {\n\tif (typeof content === \"string\") return [{ type: \"input_text\", text: content }];\n\treturn content.map((block): OpenAiInputContent => {\n\t\tif (block.type === \"text\") return { type: \"input_text\", text: block.text };\n\t\treturn {\n\t\t\ttype: \"input_image\",\n\t\t\tdetail: \"auto\",\n\t\t\timage_url: `data:${block.mimeType};base64,${block.data}`,\n\t\t};\n\t});\n}\n\nfunction providerNativeItem(raw: unknown): OpenAiProviderNativeItem | undefined {\n\tif (!isRecord(raw) || typeof raw.type !== \"string\") return undefined;\n\treturn { ...raw, type: raw.type };\n}\n\nfunction convertThinking(block: { thinkingSignature?: string }): OpenAiProviderNativeItem | undefined {\n\tconst parsed = parseJsonRecord(block.thinkingSignature);\n\tif (parsed?.type !== \"reasoning\") return undefined;\n\treturn { ...parsed, type: \"reasoning\" };\n}\n\nfunction convertTextBlock(block: TextContent, messageIndex: number): OpenAiAssistantMessageItem {\n\tconst signature = parseTextSignature(block.textSignature);\n\tconst item = {\n\t\ttype: \"message\",\n\t\trole: \"assistant\",\n\t\tstatus: \"completed\",\n\t\tid: signature?.id ?? `msg_${messageIndex}`,\n\t\tcontent: [{ type: \"output_text\", text: block.text, annotations: [] }],\n\t\t...(signature?.phase ? { phase: signature.phase } : {}),\n\t} satisfies OpenAiAssistantMessageItem;\n\treturn item;\n}\n\nfunction convertToolCall(block: ToolCall): OpenAiFunctionCallItem {\n\tconst [callId = block.id, itemId] = block.id.split(\"|\");\n\treturn {\n\t\ttype: \"function_call\",\n\t\t// The Responses API rejects item ids not beginning with \"fc\"; custom tool\n\t\t// calls carry the \"<call_id>|custom\" sentinel, not a server-issued id.\n\t\t...(itemId?.startsWith(\"fc\") ? { id: itemId } : {}),\n\t\tcall_id: callId,\n\t\tname: block.name,\n\t\targuments: JSON.stringify(block.arguments ?? {}),\n\t};\n}\n\nfunction isSameOpenAiResponsesAssistant(message: AssistantMessage): boolean {\n\treturn message.provider === \"openai\" && message.api === \"openai-responses\";\n}\n\nfunction convertAssistantMessage(message: AssistantMessage, messageIndex: number): OpenAiRemoteInputItem[] | undefined {\n\tif (!isSameOpenAiResponsesAssistant(message)) return undefined;\n\n\tconst items: OpenAiRemoteInputItem[] = [];\n\tfor (const block of message.content) {\n\t\tswitch (block.type) {\n\t\t\tcase \"text\":\n\t\t\t\titems.push(convertTextBlock(block, messageIndex));\n\t\t\t\tbreak;\n\t\t\tcase \"thinking\": {\n\t\t\t\tconst reasoning = convertThinking(block);\n\t\t\t\tif (!reasoning) return undefined;\n\t\t\t\titems.push(reasoning);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"toolCall\":\n\t\t\t\titems.push(convertToolCall(block));\n\t\t\t\tbreak;\n\t\t\tcase \"providerNative\": {\n\t\t\t\tconst item = providerNativeItem(block.raw);\n\t\t\t\tif (!item) return undefined;\n\t\t\t\titems.push(item);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\treturn items.length > 0 ? items : undefined;\n}\n\nfunction convertAgentMessage(message: AgentMessage, messageIndex: number): OpenAiRemoteInputItem[] | undefined {\n\tswitch (message.role) {\n\t\tcase \"user\":\n\t\t\treturn [{ role: \"user\", content: convertUserContent(message.content) }];\n\t\tcase \"assistant\":\n\t\t\treturn convertAssistantMessage(message, messageIndex);\n\t\tcase \"toolResult\": {\n\t\t\tconst [callId = message.toolCallId] = message.toolCallId.split(\"|\");\n\t\t\tconst output = toolResultText(message.content);\n\t\t\tif (output === undefined) return undefined;\n\t\t\treturn [{ type: \"function_call_output\", call_id: callId, output }];\n\t\t}\n\t\tcase \"bashExecution\":\n\t\tcase \"branchSummary\":\n\t\tcase \"compactionSummary\":\n\t\tcase \"custom\":\n\t\t\treturn undefined;\n\t\tdefault: {\n\t\t\tconst exhaustive: never = message;\n\t\t\treturn exhaustive;\n\t\t}\n\t}\n}\n\nfunction detailsFromEntry(entry: SessionEntry): OpenAiRemoteCompactionDetails | undefined {\n\tif (entry.type !== \"compaction\") return undefined;\n\treturn getOpenAiRemoteCompactionDetails(entry.details);\n}\n\nexport function getOpenAiRemoteCompactionDetails(value: unknown): OpenAiRemoteCompactionDetails | undefined {\n\tif (!isRecord(value)) return undefined;\n\tif (value.schema !== OPENAI_REMOTE_COMPACTION_SCHEMA || value.mode !== \"openai-remote\") return undefined;\n\tif (value.provider !== \"openai\" || value.api !== \"openai-responses\") return undefined;\n\tif (typeof value.modelId !== \"string\" || typeof value.responseId !== \"string\") return undefined;\n\tif (typeof value.createdAt !== \"number\") return undefined;\n\tif (typeof value.requestInputItemCount !== \"number\" || typeof value.retainedInputItemCount !== \"number\") {\n\t\treturn undefined;\n\t}\n\tif (!Array.isArray(value.replacementInput)) return undefined;\n\treturn {\n\t\tschema: OPENAI_REMOTE_COMPACTION_SCHEMA,\n\t\tmode: \"openai-remote\",\n\t\tprovider: \"openai\",\n\t\tapi: \"openai-responses\",\n\t\ttransport: value.transport === \"websocket\" ? \"websocket\" : \"compact-endpoint\",\n\t\tmodelId: value.modelId,\n\t\tresponseId: value.responseId,\n\t\tcreatedAt: value.createdAt,\n\t\trequestInputItemCount: value.requestInputItemCount,\n\t\tretainedInputItemCount: value.retainedInputItemCount,\n\t\treplacementInput: value.replacementInput.filter((item): item is OpenAiRemoteInputItem => isRecord(item)),\n\t\t...(isRecord(value.usage) ? { usage: value.usage } : {}),\n\t};\n}\n\nfunction convertBranchEntries(entries: SessionEntry[]): OpenAiRemoteInputItem[] | undefined {\n\tconst items: OpenAiRemoteInputItem[] = [];\n\tlet messageIndex = 0;\n\tfor (const entry of entries) {\n\t\tswitch (entry.type) {\n\t\t\tcase \"message\": {\n\t\t\t\tconst converted = convertAgentMessage(entry.message, messageIndex);\n\t\t\t\tif (!converted) return undefined;\n\t\t\t\titems.push(...converted);\n\t\t\t\tmessageIndex++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"compaction\": {\n\t\t\t\tconst details = detailsFromEntry(entry);\n\t\t\t\tif (!details) return undefined;\n\t\t\t\titems.push(...details.replacementInput);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"branch_summary\":\n\t\t\tcase \"custom_message\":\n\t\t\t\treturn undefined;\n\t\t\tcase \"thinking_level_change\":\n\t\t\tcase \"model_change\":\n\t\t\tcase \"custom\":\n\t\t\tcase \"label\":\n\t\t\tcase \"session_info\":\n\t\t\t\tbreak;\n\t\t}\n\t}\n\treturn items;\n}\n\nexport function createOpenAiRemoteCompactionRequest(options: {\n\tmodel: Model<Api> | undefined;\n\tsystemPrompt: string;\n\tbranchEntries: SessionEntry[];\n\ttokensBefore: number;\n\tpromptCacheKey?: string;\n\tserviceTier?: ServiceTier;\n}): OpenAiRemoteCompactionRequest | undefined {\n\tif (!isOpenAiResponsesModel(options.model)) return undefined;\n\tconst input = convertBranchEntries(options.branchEntries);\n\tif (!input || input.length === 0) return undefined;\n\treturn {\n\t\tbody: {\n\t\t\tmodel: options.model.id,\n\t\t\tinput,\n\t\t\t...(options.systemPrompt ? { instructions: options.systemPrompt } : {}),\n\t\t\t...(options.promptCacheKey ? { prompt_cache_key: options.promptCacheKey } : {}),\n\t\t\t...(options.serviceTier ? { service_tier: options.serviceTier } : {}),\n\t\t},\n\t\tinputItemCount: input.length,\n\t\ttokensBefore: options.tokensBefore,\n\t};\n}\n\nfunction isOpenAiCompactionItem(item: OpenAiRemoteInputItem): item is OpenAiCompactionItem {\n\treturn item.type === \"compaction\" && typeof item.encrypted_content === \"string\";\n}\n\nfunction isOpenAiContextCompactionItem(item: OpenAiRemoteInputItem): item is OpenAiContextCompactionItem {\n\treturn item.type === \"context_compaction\" && typeof item.encrypted_content === \"string\";\n}\n\nfunction isOpenAiRemoteCompactionOutputItem(\n\titem: OpenAiRemoteInputItem,\n): item is OpenAiCompactionItem | OpenAiContextCompactionItem {\n\treturn isOpenAiCompactionItem(item) || isOpenAiContextCompactionItem(item);\n}\n\nfunction isRetainedRemoteOutputItem(item: OpenAiRemoteInputItem): boolean {\n\tif (isOpenAiRemoteCompactionOutputItem(item)) return true;\n\treturn item.type === \"message\" && (item.role === \"user\" || item.role === \"system\" || item.role === \"developer\");\n}\n\nfunction isRetainedResponsesStreamInputItem(item: OpenAiRemoteInputItem): boolean {\n\tif (item.type === \"message\") return item.role === \"user\";\n\treturn \"role\" in item && item.role === \"user\";\n}\n\nfunction isOpenAiCompactedResponse(value: unknown): value is OpenAiCompactedResponse {\n\tif (!isRecord(value)) return false;\n\tif (value.object !== \"response.compaction\" || typeof value.id !== \"string\" || typeof value.created_at !== \"number\") {\n\t\treturn false;\n\t}\n\treturn Array.isArray(value.output);\n}\n\nexport function buildOpenAiRemoteCompactionResult(options: {\n\tmodel: Model<\"openai-responses\">;\n\tfirstKeptEntryId: string;\n\ttokensBefore: number;\n\trequestInputItemCount: number;\n\tresponse: OpenAiCompactedResponse;\n}): OpenAiRemoteCompactionResult {\n\tconst replacementInput = options.response.output.filter(isRetainedRemoteOutputItem);\n\tconst compactionItem = replacementInput.find(isOpenAiRemoteCompactionOutputItem);\n\tif (!compactionItem) {\n\t\tthrow new Error(\"OpenAI remote compaction did not return a compaction item\");\n\t}\n\n\tconst details = {\n\t\tschema: OPENAI_REMOTE_COMPACTION_SCHEMA,\n\t\tmode: \"openai-remote\",\n\t\tprovider: \"openai\",\n\t\tapi: \"openai-responses\",\n\t\ttransport: \"compact-endpoint\",\n\t\tmodelId: options.model.id,\n\t\tresponseId: options.response.id,\n\t\tcreatedAt: options.response.created_at,\n\t\trequestInputItemCount: options.requestInputItemCount,\n\t\tretainedInputItemCount: replacementInput.length,\n\t\treplacementInput,\n\t\t...(options.response.usage ? { usage: options.response.usage } : {}),\n\t} satisfies OpenAiRemoteCompactionDetails;\n\n\treturn {\n\t\tsummary: [\n\t\t\t\"OpenAI remote compaction checkpoint.\",\n\t\t\t`Native /v1/responses/compact replay is active for ${replacementInput.length.toLocaleString()} retained item(s).`,\n\t\t\t`Original OpenAI input items compacted: ${options.requestInputItemCount.toLocaleString()}.`,\n\t\t].join(\"\\n\"),\n\t\tfirstKeptEntryId: options.firstKeptEntryId,\n\t\ttokensBefore: options.tokensBefore,\n\t\tdetails,\n\t};\n}\n\nfunction compactEndpointUrl(model: Model<\"openai-responses\">): string {\n\tconst baseUrl = model.baseUrl || \"https://api.openai.com/v1\";\n\treturn new URL(\"responses/compact\", baseUrl.endsWith(\"/\") ? baseUrl : `${baseUrl}/`).toString();\n}\n\nfunction createHeaders(auth: { apiKey?: string; headers?: Record<string, string> }): Headers | undefined {\n\tconst headers = new Headers(auth.headers);\n\theaders.set(\"content-type\", \"application/json\");\n\tif (!headers.has(\"authorization\") && auth.apiKey) {\n\t\theaders.set(\"authorization\", `Bearer ${auth.apiKey}`);\n\t}\n\treturn headers.has(\"authorization\") ? headers : undefined;\n}\n\nasync function runWithRemoteTimeout<T>(options: {\n\tsignal: AbortSignal;\n\ttimeoutMs: number;\n\trun: (signal: AbortSignal) => Promise<T>;\n\tonTimeout: () => void;\n}): Promise<T | undefined> {\n\tif (options.signal.aborted) {\n\t\tthrow new Error(\"Request was aborted\");\n\t}\n\n\tconst controller = new AbortController();\n\tlet timedOut = false;\n\tconst abortFromSource = () => controller.abort();\n\toptions.signal.addEventListener(\"abort\", abortFromSource, { once: true });\n\n\tlet timeout: ReturnType<typeof setTimeout> | undefined;\n\tconst timeoutPromise = new Promise<\"timeout\">((resolve) => {\n\t\ttimeout = setTimeout(() => {\n\t\t\ttimedOut = true;\n\t\t\tcontroller.abort();\n\t\t\tresolve(\"timeout\");\n\t\t}, options.timeoutMs);\n\t\tconst unref = timeout.unref;\n\t\tif (unref) unref.call(timeout);\n\t});\n\n\tconst operation = options.run(controller.signal);\n\ttry {\n\t\tconst result = await Promise.race([operation, timeoutPromise]);\n\t\tif (result === \"timeout\") {\n\t\t\toptions.onTimeout();\n\t\t\toperation.catch(() => undefined);\n\t\t\treturn undefined;\n\t\t}\n\t\treturn result;\n\t} catch (error) {\n\t\tif (timedOut && !options.signal.aborted) {\n\t\t\toptions.onTimeout();\n\t\t\treturn undefined;\n\t\t}\n\t\tthrow error;\n\t} finally {\n\t\tif (timeout) clearTimeout(timeout);\n\t\toptions.signal.removeEventListener(\"abort\", abortFromSource);\n\t}\n}\n\nfunction createOpenAiResponsesStreamCompactionInput(request: OpenAiRemoteCompactionRequest): OpenAiRemoteInputItem[] {\n\treturn [...request.body.input, { type: \"context_compaction\" } satisfies OpenAiContextCompactionTriggerItem];\n}\n\nexport function createOpenAiResponsesStreamCompactionPayload(\n\tpayload: unknown,\n\trequest: OpenAiRemoteCompactionRequest,\n): unknown | undefined {\n\tif (!isRecord(payload)) return undefined;\n\treturn {\n\t\t...payload,\n\t\tmodel: request.body.model,\n\t\tinput: [...leadingPromptMessages(payload.input), ...createOpenAiResponsesStreamCompactionInput(request)],\n\t\t...(request.body.prompt_cache_key ? { prompt_cache_key: request.body.prompt_cache_key } : {}),\n\t\t...(request.body.service_tier ? { service_tier: request.body.service_tier } : {}),\n\t};\n}\n\nfunction findResponsesStreamCompactionOutput(message: AssistantMessage): OpenAiContextCompactionItem | undefined {\n\tfor (const block of message.content) {\n\t\tif (block.type !== \"providerNative\") continue;\n\t\tconst item = providerNativeItem(block.raw);\n\t\tif (item && isOpenAiContextCompactionItem(item)) return item;\n\t}\n\treturn undefined;\n}\n\nfunction usageRecordFromAssistant(message: AssistantMessage): Record<string, unknown> {\n\treturn {\n\t\tinput: message.usage.input,\n\t\toutput: message.usage.output,\n\t\tcacheRead: message.usage.cacheRead,\n\t\tcacheWrite: message.usage.cacheWrite,\n\t\ttotalTokens: message.usage.totalTokens,\n\t};\n}\n\nexport function buildOpenAiResponsesStreamCompactionResult(options: {\n\tmodel: Model<\"openai-responses\">;\n\tfirstKeptEntryId: string;\n\ttokensBefore: number;\n\trequestInput: OpenAiRemoteInputItem[];\n\tresponse: AssistantMessage;\n\tnow: () => number;\n}): OpenAiRemoteCompactionResult {\n\tconst compactionItem = findResponsesStreamCompactionOutput(options.response);\n\tif (!compactionItem) {\n\t\tthrow new Error(\"OpenAI Responses stream compaction did not return a context_compaction item\");\n\t}\n\n\tconst retainedInput = options.requestInput.filter(isRetainedResponsesStreamInputItem);\n\tconst replacementInput = [...retainedInput, compactionItem];\n\tconst details = {\n\t\tschema: OPENAI_REMOTE_COMPACTION_SCHEMA,\n\t\tmode: \"openai-remote\",\n\t\tprovider: \"openai\",\n\t\tapi: \"openai-responses\",\n\t\ttransport: \"websocket\",\n\t\tmodelId: options.model.id,\n\t\tresponseId: options.response.responseId ?? `response-${options.now()}`,\n\t\tcreatedAt: Math.floor(options.response.timestamp / 1000),\n\t\trequestInputItemCount: options.requestInput.length,\n\t\tretainedInputItemCount: replacementInput.length,\n\t\treplacementInput,\n\t\tusage: usageRecordFromAssistant(options.response),\n\t} satisfies OpenAiRemoteCompactionDetails;\n\n\treturn {\n\t\tsummary: [\n\t\t\t\"OpenAI remote compaction checkpoint.\",\n\t\t\t`Native Responses WebSocket replay is active for ${replacementInput.length.toLocaleString()} retained item(s).`,\n\t\t\t`Original OpenAI input items compacted: ${options.requestInput.length.toLocaleString()}.`,\n\t\t].join(\"\\n\"),\n\t\tfirstKeptEntryId: options.firstKeptEntryId,\n\t\ttokensBefore: options.tokensBefore,\n\t\tdetails,\n\t};\n}\n\nasync function runOpenAiResponsesStreamCompaction(options: {\n\tmodel: Model<\"openai-responses\">;\n\tauth: { apiKey?: string; headers?: Record<string, string>; extraBody?: Record<string, unknown> };\n\tfirstKeptEntryId: string;\n\tnow: () => number;\n\trequest: OpenAiRemoteCompactionRequest;\n\tsignal: AbortSignal;\n\tstreamRunner: OpenAiResponsesStreamRunner;\n\tsystemPrompt: string;\n}): Promise<OpenAiRemoteCompactionResult | undefined> {\n\tconst stream = options.streamRunner(\n\t\toptions.model,\n\t\t{ systemPrompt: options.systemPrompt, messages: [] },\n\t\t{\n\t\t\tapiKey: options.auth.apiKey,\n\t\t\tcacheRetention: \"short\",\n\t\t\textraBody: options.auth.extraBody,\n\t\t\theaders: options.auth.headers,\n\t\t\tonPayload: (payload) => {\n\t\t\t\tconst rewritten = createOpenAiResponsesStreamCompactionPayload(payload, options.request);\n\t\t\t\tif (!isRecord(rewritten) || !Array.isArray(rewritten.input)) {\n\t\t\t\t\tthrow new Error(\"Unable to build OpenAI Responses stream compaction payload\");\n\t\t\t\t}\n\t\t\t\treturn rewritten;\n\t\t\t},\n\t\t\tsessionId: options.request.body.prompt_cache_key,\n\t\t\tsignal: options.signal,\n\t\t\ttransport: \"websocket\",\n\t\t},\n\t);\n\tconst response = await stream.result();\n\tif (response.stopReason === \"error\" || response.stopReason === \"aborted\") {\n\t\treturn undefined;\n\t}\n\treturn buildOpenAiResponsesStreamCompactionResult({\n\t\tmodel: options.model,\n\t\tfirstKeptEntryId: options.firstKeptEntryId,\n\t\ttokensBefore: options.request.tokensBefore,\n\t\trequestInput: options.request.body.input,\n\t\tresponse,\n\t\tnow: options.now,\n\t});\n}\n\nasync function runOpenAiCompactEndpointCompaction(options: {\n\tfetchImpl: typeof fetch;\n\theaders: Headers;\n\tmodel: Model<\"openai-responses\">;\n\trequest: OpenAiRemoteCompactionRequest;\n\trequestId: string;\n\tsignal: AbortSignal;\n\tfirstKeptEntryId: string;\n\temit?: EmitCompactionEvent;\n}): Promise<OpenAiRemoteCompactionResult | undefined> {\n\toptions.emit?.({\n\t\tversion: 1,\n\t\taction: \"remote_started\",\n\t\troute: \"builtin.compaction.openai_remote\",\n\t\trequestId: options.requestId,\n\t\tmodelId: options.model.id,\n\t\tinputItemCount: options.request.inputItemCount,\n\t\ttransport: \"compact-endpoint\",\n\t});\n\n\tlet response: Response;\n\ttry {\n\t\tresponse = await options.fetchImpl(compactEndpointUrl(options.model), {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: options.headers,\n\t\t\tbody: JSON.stringify(options.request.body),\n\t\t\tsignal: options.signal,\n\t\t});\n\t} catch (error) {\n\t\tif (options.signal.aborted) throw error;\n\t\toptions.emit?.({\n\t\t\tversion: 1,\n\t\t\taction: \"remote_fallback\",\n\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\trequestId: options.requestId,\n\t\t\tmodelId: options.model.id,\n\t\t\treason: error instanceof Error ? error.message : String(error),\n\t\t\ttransport: \"compact-endpoint\",\n\t\t});\n\t\treturn undefined;\n\t}\n\n\tif (!response.ok) {\n\t\toptions.emit?.({\n\t\t\tversion: 1,\n\t\t\taction: \"remote_fallback\",\n\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\trequestId: options.requestId,\n\t\t\tmodelId: options.model.id,\n\t\t\treason: `HTTP ${response.status}`,\n\t\t\ttransport: \"compact-endpoint\",\n\t\t});\n\t\treturn undefined;\n\t}\n\n\tlet payload: unknown;\n\ttry {\n\t\tpayload = await response.json();\n\t} catch (error) {\n\t\toptions.emit?.({\n\t\t\tversion: 1,\n\t\t\taction: \"remote_fallback\",\n\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\trequestId: options.requestId,\n\t\t\tmodelId: options.model.id,\n\t\t\treason: error instanceof Error ? error.message : String(error),\n\t\t\ttransport: \"compact-endpoint\",\n\t\t});\n\t\treturn undefined;\n\t}\n\tif (!isOpenAiCompactedResponse(payload)) {\n\t\toptions.emit?.({\n\t\t\tversion: 1,\n\t\t\taction: \"remote_fallback\",\n\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\trequestId: options.requestId,\n\t\t\tmodelId: options.model.id,\n\t\t\treason: \"invalid-compact-response\",\n\t\t\ttransport: \"compact-endpoint\",\n\t\t});\n\t\treturn undefined;\n\t}\n\n\tlet result: OpenAiRemoteCompactionResult;\n\ttry {\n\t\tresult = buildOpenAiRemoteCompactionResult({\n\t\t\tmodel: options.model,\n\t\t\tfirstKeptEntryId: options.firstKeptEntryId,\n\t\t\ttokensBefore: options.request.tokensBefore,\n\t\t\trequestInputItemCount: options.request.inputItemCount,\n\t\t\tresponse: payload,\n\t\t});\n\t} catch (error) {\n\t\toptions.emit?.({\n\t\t\tversion: 1,\n\t\t\taction: \"remote_fallback\",\n\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\trequestId: options.requestId,\n\t\t\tmodelId: options.model.id,\n\t\t\treason: error instanceof Error ? error.message : String(error),\n\t\t\ttransport: \"compact-endpoint\",\n\t\t});\n\t\treturn undefined;\n\t}\n\toptions.emit?.({\n\t\tversion: 1,\n\t\taction: \"remote_completed\",\n\t\troute: \"builtin.compaction.openai_remote\",\n\t\trequestId: options.requestId,\n\t\tmodelId: options.model.id,\n\t\tresponseId: payload.id,\n\t\tretainedInputItemCount: result.details.retainedInputItemCount,\n\t\ttransport: \"compact-endpoint\",\n\t});\n\treturn result;\n}\n\nexport async function runOpenAiRemoteCompaction(\n\tctx: OpenAiRemoteCompactionContext,\n\tevent: SessionBeforeCompactEvent,\n\temit?: EmitCompactionEvent,\n\tdependencies: OpenAiRemoteCompactionDependencies = {},\n): Promise<OpenAiRemoteCompactionResult | undefined> {\n\tconst model = ctx.model;\n\tif (!isOpenAiResponsesModel(model) || event.reason === \"branch\") {\n\t\temit?.({\n\t\t\tversion: 1,\n\t\t\taction: \"remote_fallback\",\n\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\trequestId: event.requestId,\n\t\t\tmodelId: model?.id,\n\t\t\treason: event.reason === \"branch\" ? \"branch-compaction\" : \"not-openai-responses\",\n\t\t});\n\t\treturn undefined;\n\t}\n\n\tconst auth = await ctx.modelRegistry.getApiKeyAndHeaders(model);\n\tif (!auth.ok) {\n\t\temit?.({\n\t\t\tversion: 1,\n\t\t\taction: \"remote_fallback\",\n\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\trequestId: event.requestId,\n\t\t\tmodelId: model.id,\n\t\t\treason: auth.error,\n\t\t});\n\t\treturn undefined;\n\t}\n\n\tconst requestModel = auth.upstreamModelId ? { ...model, id: auth.upstreamModelId } : model;\n\tconst serviceTier = ctx.serviceTier ?? auth.serviceTier;\n\tconst request = createOpenAiRemoteCompactionRequest({\n\t\tmodel: requestModel,\n\t\tsystemPrompt: ctx.getSystemPrompt(),\n\t\tbranchEntries: event.branchEntries,\n\t\ttokensBefore: event.preparation.tokensBefore,\n\t\tpromptCacheKey: ctx.sessionManager.getSessionId(),\n\t\tserviceTier,\n\t});\n\tif (!request) {\n\t\temit?.({\n\t\t\tversion: 1,\n\t\t\taction: \"remote_fallback\",\n\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\trequestId: event.requestId,\n\t\t\tmodelId: model.id,\n\t\t\treason: \"session-not-openai-native\",\n\t\t});\n\t\treturn undefined;\n\t}\n\tconst remoteTimeoutMs = dependencies.remoteTimeoutMs ?? OPENAI_REMOTE_COMPACTION_TIMEOUT_MS;\n\n\tif (supportsOpenAiResponsesWebSocket(requestModel)) {\n\t\temit?.({\n\t\t\tversion: 1,\n\t\t\taction: \"remote_started\",\n\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\trequestId: event.requestId,\n\t\t\tmodelId: requestModel.id,\n\t\t\tinputItemCount: request.inputItemCount,\n\t\t\ttransport: \"websocket\",\n\t\t});\n\t\ttry {\n\t\t\tconst result = await runWithRemoteTimeout({\n\t\t\t\tsignal: event.signal,\n\t\t\t\ttimeoutMs: remoteTimeoutMs,\n\t\t\t\tonTimeout: () =>\n\t\t\t\t\temit?.({\n\t\t\t\t\t\tversion: 1,\n\t\t\t\t\t\taction: \"remote_fallback\",\n\t\t\t\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\t\t\t\trequestId: event.requestId,\n\t\t\t\t\t\tmodelId: requestModel.id,\n\t\t\t\t\t\treason: REMOTE_COMPACTION_TIMEOUT_REASON,\n\t\t\t\t\t\ttransport: \"websocket\",\n\t\t\t\t\t}),\n\t\t\t\trun: (signal) =>\n\t\t\t\t\trunOpenAiResponsesStreamCompaction({\n\t\t\t\t\t\tmodel: requestModel,\n\t\t\t\t\t\tauth,\n\t\t\t\t\t\tfirstKeptEntryId: event.preparation.firstKeptEntryId,\n\t\t\t\t\t\tnow: dependencies.now ?? Date.now,\n\t\t\t\t\t\trequest,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\tstreamRunner:\n\t\t\t\t\t\t\tdependencies.streamRunner ??\n\t\t\t\t\t\t\t((streamModel, context, options) => streamSimple(streamModel, context, options)),\n\t\t\t\t\t\tsystemPrompt: ctx.getSystemPrompt(),\n\t\t\t\t\t}),\n\t\t\t});\n\t\t\tif (result) {\n\t\t\t\temit?.({\n\t\t\t\t\tversion: 1,\n\t\t\t\t\taction: \"remote_completed\",\n\t\t\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\t\t\trequestId: event.requestId,\n\t\t\t\t\tmodelId: requestModel.id,\n\t\t\t\t\tresponseId: result.details.responseId,\n\t\t\t\t\tretainedInputItemCount: result.details.retainedInputItemCount,\n\t\t\t\t\ttransport: \"websocket\",\n\t\t\t\t});\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\temit?.({\n\t\t\t\tversion: 1,\n\t\t\t\taction: \"remote_fallback\",\n\t\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\t\trequestId: event.requestId,\n\t\t\t\tmodelId: requestModel.id,\n\t\t\t\treason: \"websocket-compaction-no-result\",\n\t\t\t\ttransport: \"websocket\",\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (event.signal.aborted) throw error;\n\t\t\temit?.({\n\t\t\t\tversion: 1,\n\t\t\t\taction: \"remote_fallback\",\n\t\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\t\trequestId: event.requestId,\n\t\t\t\tmodelId: requestModel.id,\n\t\t\t\treason: error instanceof Error ? error.message : String(error),\n\t\t\t\ttransport: \"websocket\",\n\t\t\t});\n\t\t}\n\t}\n\n\tconst headers = createHeaders(auth);\n\tif (!headers) {\n\t\temit?.({\n\t\t\tversion: 1,\n\t\t\taction: \"remote_fallback\",\n\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\trequestId: event.requestId,\n\t\t\tmodelId: model.id,\n\t\t\treason: \"missing-openai-auth\",\n\t\t});\n\t\treturn undefined;\n\t}\n\n\treturn runWithRemoteTimeout({\n\t\tsignal: event.signal,\n\t\ttimeoutMs: remoteTimeoutMs,\n\t\tonTimeout: () =>\n\t\t\temit?.({\n\t\t\t\tversion: 1,\n\t\t\t\taction: \"remote_fallback\",\n\t\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\t\trequestId: event.requestId,\n\t\t\t\tmodelId: requestModel.id,\n\t\t\t\treason: REMOTE_COMPACTION_TIMEOUT_REASON,\n\t\t\t\ttransport: \"compact-endpoint\",\n\t\t\t}),\n\t\trun: (signal) =>\n\t\t\trunOpenAiCompactEndpointCompaction({\n\t\t\t\tfetchImpl: dependencies.fetch ?? fetch,\n\t\t\t\theaders,\n\t\t\t\tmodel: requestModel,\n\t\t\t\trequest,\n\t\t\t\trequestId: event.requestId,\n\t\t\t\tsignal,\n\t\t\t\tfirstKeptEntryId: event.preparation.firstKeptEntryId,\n\t\t\t\temit,\n\t\t\t}),\n\t});\n}\n\nfunction latestRemoteCompaction(\n\tentries: SessionEntry[],\n): { entryId: string; index: number; details: OpenAiRemoteCompactionDetails } | undefined {\n\tfor (let index = entries.length - 1; index >= 0; index--) {\n\t\tconst entry = entries[index];\n\t\tif (entry?.type !== \"compaction\") continue;\n\t\tconst details = getOpenAiRemoteCompactionDetails(entry.details);\n\t\tif (details) return { entryId: entry.id, index, details };\n\t\treturn undefined;\n\t}\n\treturn undefined;\n}\n\nfunction leadingPromptMessages(input: unknown): OpenAiRemoteInputItem[] {\n\tif (!Array.isArray(input)) return [];\n\tconst result: OpenAiRemoteInputItem[] = [];\n\tfor (const item of input) {\n\t\tif (!isRecord(item)) break;\n\t\tconst role = item.role;\n\t\tif (role !== \"system\" && role !== \"developer\") break;\n\t\tresult.push(providerNativeItem(item) ?? { role, content: typeof item.content === \"string\" ? item.content : [] });\n\t}\n\treturn result;\n}\n\nexport function rewriteOpenAiPayloadWithRemoteCompaction(\n\tpayload: unknown,\n\toptions: { model: Model<Api> | undefined; branchEntries: SessionEntry[] },\n\temit?: EmitCompactionEvent,\n): unknown | undefined {\n\tif (!isOpenAiResponsesModel(options.model) || !isRecord(payload)) return undefined;\n\tconst remote = latestRemoteCompaction(options.branchEntries);\n\tif (!remote) return undefined;\n\n\tconst postCompactionItems = convertBranchEntries(options.branchEntries.slice(remote.index + 1));\n\tif (!postCompactionItems) return undefined;\n\n\tconst input = [...leadingPromptMessages(payload.input), ...remote.details.replacementInput, ...postCompactionItems];\n\temit?.({\n\t\tversion: 1,\n\t\taction: \"remote_payload_rewritten\",\n\t\troute: \"builtin.compaction.openai_remote\",\n\t\tmodelId: options.model.id,\n\t\tcompactionEntryId: remote.entryId,\n\t\tinputItemCount: input.length,\n\t});\n\treturn { ...payload, input };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"openai-remote.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/openai-remote.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAY5D,OAAO,EACN,oBAAoB,EACpB,sBAAsB,EACtB,gCAAgC,EAChC,6BAA6B,EAC7B,kCAAkC,EAClC,QAAQ,EACR,0BAA0B,EAC1B,kCAAkC,EAClC,+BAA+B,EAC/B,kBAAkB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACN,mCAAmC,EACnC,6BAA6B,EAC7B,qCAAqC,EAErC,kCAAkC,EAClC,iCAAiC,EACjC,8BAA8B,GAC9B,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EAAE,gCAAgC,EAAE,+BAA+B,EAAE,MAAM,4BAA4B,CAAC;AA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,IAA0B;IAE1B,IAAI,CAAC,6BAA6B,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,SAAS,CAAC;IAC1F,MAAM,MAAM,GAAG,sBAAsB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAC7D,IAAI,CAAC,MAAM,IAAI,CAAC,qCAAqC,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC;QAAE,OAAO,SAAS,CAAC;IAEvG,MAAM,mBAAmB,GAAG,oBAAoB,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/G,8EAA8E;IAC9E,4EAA4E;IAC5E,MAAM,YAAY,GAAG,sBAAsB,CAAC,OAAO,CAAC,eAAe,IAAI,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAE1F,MAAM,KAAK,GAAG;QACb,GAAG,qBAAqB,CAAC,OAAO,CAAC,KAAK,CAAC;QACvC,GAAG,MAAM,CAAC,OAAO,CAAC,gBAAgB;QAClC,GAAG,mBAAmB;QACtB,GAAG,YAAY;KACf,CAAC;IACF,IAAI,EAAE,CAAC;QACN,OAAO,EAAE,CAAC;QACV,MAAM,EAAE,0BAA0B;QAClC,KAAK,EAAE,kCAAkC;QACzC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE;QACzB,iBAAiB,EAAE,MAAM,CAAC,OAAO;QACjC,cAAc,EAAE,KAAK,CAAC,MAAM;KAC5B,CAAC,CAAC;IACH,OAAO,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["import type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { Api, AssistantMessage, Context, Model, SimpleStreamOptions } from \"@earendil-works/pi-ai\";\nimport { streamSimple } from \"@earendil-works/pi-ai/compat\";\nimport type { CompactionResult } from \"../../../compaction/index.ts\";\nimport type { SessionEntry } from \"../../../session-manager.ts\";\nimport type { ServiceTier, SessionBeforeCompactEvent } from \"../../types.ts\";\nimport type {\n\tOpenAiCompactBody,\n\tOpenAiContextCompactionItem,\n\tOpenAiContextCompactionTriggerItem,\n\tOpenAiRemoteCompactionDetails,\n\tOpenAiRemoteInputItem,\n\tOpenAiRemoteTransport,\n} from \"./openai-remote-convert.ts\";\nimport {\n\tconvertBranchEntries,\n\tconvertPendingMessages,\n\tgetOpenAiRemoteCompactionDetails,\n\tisOpenAiContextCompactionItem,\n\tisOpenAiRemoteCompactionOutputItem,\n\tisRecord,\n\tisRetainedRemoteOutputItem,\n\tisRetainedResponsesStreamInputItem,\n\tOPENAI_REMOTE_COMPACTION_SCHEMA,\n\tproviderNativeItem,\n} from \"./openai-remote-convert.ts\";\nimport {\n\tcreateOpenAiRemoteCompactionHeaders,\n\tisOpenAiRemoteCompactionModel,\n\tmatchesOpenAiRemoteCompactionIdentity,\n\ttype OpenAiRemoteCompactionModel,\n\topenAiRemoteCompactionEndpointPath,\n\topenAiRemoteCompactionEndpointUrl,\n\topenAiRemoteCompactionIdentity,\n} from \"./openai-remote-model.ts\";\n\nexport type {\n\tOpenAiRemoteCompactionDetails,\n\tOpenAiRemoteInputItem,\n} from \"./openai-remote-convert.ts\";\nexport { getOpenAiRemoteCompactionDetails, OPENAI_REMOTE_COMPACTION_SCHEMA } from \"./openai-remote-convert.ts\";\n\nexport const SENPI_COMPACTION_EVENT = \"senpi:compaction\";\n\nexport type OpenAiRemoteCompactionRequest = {\n\tbody: OpenAiCompactBody;\n\tinputItemCount: number;\n\ttokensBefore: number;\n};\n\nexport type OpenAiRemoteCompactionResult = CompactionResult<OpenAiRemoteCompactionDetails> & {\n\tdetails: OpenAiRemoteCompactionDetails;\n};\n\ntype OpenAiCompactedResponse = {\n\tid: string;\n\tcreated_at: number;\n\tobject: \"response.compaction\";\n\toutput: OpenAiRemoteInputItem[];\n\tusage?: Record<string, unknown>;\n};\n\ntype OpenAiResponsesStream = {\n\tresult(): Promise<AssistantMessage>;\n};\n\ntype OpenAiResponsesStreamRunner = (\n\tmodel: Model<\"openai-responses\">,\n\tcontext: Context,\n\toptions: SimpleStreamOptions,\n) => OpenAiResponsesStream;\n\ntype OpenAiRemoteCompactionDependencies = {\n\tfetch?: typeof fetch;\n\tnow?: () => number;\n\tremoteTimeoutMs?: number;\n\tstreamRunner?: OpenAiResponsesStreamRunner;\n};\n\ntype OpenAiRemoteCompactionContext = {\n\tgetSystemPrompt(): string;\n\tmodel: Model<Api> | undefined;\n\tmodelRegistry: {\n\t\tgetApiKeyAndHeaders(model: Model<Api>): Promise<\n\t\t\t| {\n\t\t\t\t\tok: true;\n\t\t\t\t\tapiKey?: string;\n\t\t\t\t\theaders?: Record<string, string>;\n\t\t\t\t\textraBody?: Record<string, unknown>;\n\t\t\t\t\tupstreamModelId?: string;\n\t\t\t\t\tserviceTier?: ServiceTier;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tok: false;\n\t\t\t\t\terror: string;\n\t\t\t }\n\t\t>;\n\t};\n\tserviceTier: ServiceTier | undefined;\n\tsessionManager: {\n\t\tgetSessionId(): string;\n\t};\n};\n\ntype OpenAiRemoteCompactionEvent =\n\t| {\n\t\t\tversion: 1;\n\t\t\taction: \"remote_started\";\n\t\t\troute: \"builtin.compaction.openai_remote\";\n\t\t\trequestId: string;\n\t\t\tmodelId: string;\n\t\t\tinputItemCount: number;\n\t\t\ttransport: OpenAiRemoteTransport;\n\t }\n\t| {\n\t\t\tversion: 1;\n\t\t\taction: \"remote_completed\";\n\t\t\troute: \"builtin.compaction.openai_remote\";\n\t\t\trequestId: string;\n\t\t\tmodelId: string;\n\t\t\tresponseId: string;\n\t\t\tretainedInputItemCount: number;\n\t\t\ttransport: OpenAiRemoteTransport;\n\t }\n\t| {\n\t\t\tversion: 1;\n\t\t\taction: \"remote_fallback\";\n\t\t\troute: \"builtin.compaction.openai_remote\";\n\t\t\trequestId: string;\n\t\t\tmodelId?: string;\n\t\t\treason: string;\n\t\t\ttransport?: OpenAiRemoteTransport;\n\t }\n\t| {\n\t\t\tversion: 1;\n\t\t\taction: \"remote_payload_rewritten\";\n\t\t\troute: \"builtin.compaction.openai_remote\";\n\t\t\tmodelId: string;\n\t\t\tcompactionEntryId: string;\n\t\t\tinputItemCount: number;\n\t };\n\ntype EmitCompactionEvent = (event: OpenAiRemoteCompactionEvent) => void;\n\nconst OPENAI_REMOTE_COMPACTION_TIMEOUT_MS = 15_000;\nconst REMOTE_COMPACTION_TIMEOUT_REASON = \"remote-compaction-timeout\";\n\nfunction supportsOpenAiResponsesWebSocket(model: OpenAiRemoteCompactionModel): model is Model<\"openai-responses\"> {\n\tif (model.provider !== \"openai\" || model.api !== \"openai-responses\") return false;\n\tif (model.compat?.supportsWebSocket !== undefined) return model.compat.supportsWebSocket;\n\ttry {\n\t\treturn new URL(model.baseUrl || \"https://api.openai.com/v1\").hostname === \"api.openai.com\";\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport function createOpenAiRemoteCompactionRequest(options: {\n\tmodel: Model<Api> | undefined;\n\tsystemPrompt: string;\n\tbranchEntries: SessionEntry[];\n\ttokensBefore: number;\n\tpromptCacheKey?: string;\n\tserviceTier?: ServiceTier;\n}): OpenAiRemoteCompactionRequest | undefined {\n\tif (!isOpenAiRemoteCompactionModel(options.model)) return undefined;\n\tconst input = convertBranchEntries(options.branchEntries, options.model);\n\tif (input.length === 0) return undefined;\n\treturn {\n\t\tbody: {\n\t\t\tmodel: options.model.id,\n\t\t\tinput,\n\t\t\t...(options.systemPrompt ? { instructions: options.systemPrompt } : {}),\n\t\t\t...(options.promptCacheKey ? { prompt_cache_key: options.promptCacheKey } : {}),\n\t\t\t...(options.serviceTier ? { service_tier: options.serviceTier } : {}),\n\t\t},\n\t\tinputItemCount: input.length,\n\t\ttokensBefore: options.tokensBefore,\n\t};\n}\n\nfunction parseOpenAiCompactedResponse(options: {\n\tvalue: unknown;\n\tmodel: OpenAiRemoteCompactionModel;\n\trequestId: string;\n\tnow: () => number;\n}): OpenAiCompactedResponse | undefined {\n\tif (!isRecord(options.value) || !Array.isArray(options.value.output)) return undefined;\n\tif (options.model.api === \"openai-responses\") {\n\t\tif (\n\t\t\toptions.value.object !== \"response.compaction\" ||\n\t\t\ttypeof options.value.id !== \"string\" ||\n\t\t\ttypeof options.value.created_at !== \"number\"\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\treturn {\n\t\tid: typeof options.value.id === \"string\" ? options.value.id : `codex-compact:${options.requestId}`,\n\t\tcreated_at:\n\t\t\ttypeof options.value.created_at === \"number\" ? options.value.created_at : Math.floor(options.now() / 1000),\n\t\tobject: \"response.compaction\",\n\t\toutput: options.value.output.filter((item): item is OpenAiRemoteInputItem => isRecord(item)),\n\t\t...(isRecord(options.value.usage) ? { usage: options.value.usage } : {}),\n\t};\n}\n\nexport function buildOpenAiRemoteCompactionResult(options: {\n\tmodel: OpenAiRemoteCompactionModel;\n\tfirstKeptEntryId: string;\n\ttokensBefore: number;\n\trequestInputItemCount: number;\n\tresponse: OpenAiCompactedResponse;\n}): OpenAiRemoteCompactionResult {\n\tconst replacementInput = options.response.output.filter(isRetainedRemoteOutputItem);\n\tconst compactionItem = replacementInput.find(isOpenAiRemoteCompactionOutputItem);\n\tif (!compactionItem) {\n\t\tthrow new Error(\"OpenAI remote compaction did not return a compaction item\");\n\t}\n\n\tconst details = {\n\t\tschema: OPENAI_REMOTE_COMPACTION_SCHEMA,\n\t\tmode: \"openai-remote\",\n\t\t...openAiRemoteCompactionIdentity(options.model),\n\t\ttransport: \"compact-endpoint\",\n\t\tmodelId: options.model.id,\n\t\tresponseId: options.response.id,\n\t\tcreatedAt: options.response.created_at,\n\t\trequestInputItemCount: options.requestInputItemCount,\n\t\tretainedInputItemCount: replacementInput.length,\n\t\treplacementInput,\n\t\t...(options.response.usage ? { usage: options.response.usage } : {}),\n\t} satisfies OpenAiRemoteCompactionDetails;\n\tconst endpointPath =\n\t\toptions.model.api === \"openai-codex-responses\"\n\t\t\t? `/${openAiRemoteCompactionEndpointPath(options.model)}`\n\t\t\t: \"/v1/responses/compact\";\n\n\treturn {\n\t\tsummary: [\n\t\t\t\"OpenAI remote compaction checkpoint.\",\n\t\t\t`Native ${endpointPath} replay is active for ${replacementInput.length.toLocaleString()} retained item(s).`,\n\t\t\t`Original OpenAI input items compacted: ${options.requestInputItemCount.toLocaleString()}.`,\n\t\t].join(\"\\n\"),\n\t\tfirstKeptEntryId: options.firstKeptEntryId,\n\t\ttokensBefore: options.tokensBefore,\n\t\tdetails,\n\t};\n}\n\nasync function runWithRemoteTimeout<T>(options: {\n\tsignal: AbortSignal;\n\ttimeoutMs: number;\n\trun: (signal: AbortSignal) => Promise<T>;\n\tonTimeout: () => void;\n}): Promise<T | undefined> {\n\tif (options.signal.aborted) {\n\t\tthrow new Error(\"Request was aborted\");\n\t}\n\n\tconst controller = new AbortController();\n\tlet timedOut = false;\n\tconst abortFromSource = () => controller.abort();\n\toptions.signal.addEventListener(\"abort\", abortFromSource, { once: true });\n\n\tlet timeout: ReturnType<typeof setTimeout> | undefined;\n\tconst timeoutPromise = new Promise<\"timeout\">((resolve) => {\n\t\ttimeout = setTimeout(() => {\n\t\t\ttimedOut = true;\n\t\t\tcontroller.abort();\n\t\t\tresolve(\"timeout\");\n\t\t}, options.timeoutMs);\n\t\tconst unref = timeout.unref;\n\t\tif (unref) unref.call(timeout);\n\t});\n\n\tconst operation = options.run(controller.signal);\n\ttry {\n\t\tconst result = await Promise.race([operation, timeoutPromise]);\n\t\tif (result === \"timeout\") {\n\t\t\toptions.onTimeout();\n\t\t\toperation.catch(() => undefined);\n\t\t\treturn undefined;\n\t\t}\n\t\treturn result;\n\t} catch (error) {\n\t\tif (timedOut && !options.signal.aborted) {\n\t\t\toptions.onTimeout();\n\t\t\treturn undefined;\n\t\t}\n\t\tthrow error;\n\t} finally {\n\t\tif (timeout) clearTimeout(timeout);\n\t\toptions.signal.removeEventListener(\"abort\", abortFromSource);\n\t}\n}\n\nfunction createOpenAiResponsesStreamCompactionInput(request: OpenAiRemoteCompactionRequest): OpenAiRemoteInputItem[] {\n\treturn [...request.body.input, { type: \"context_compaction\" } satisfies OpenAiContextCompactionTriggerItem];\n}\n\nexport function createOpenAiResponsesStreamCompactionPayload(\n\tpayload: unknown,\n\trequest: OpenAiRemoteCompactionRequest,\n): unknown | undefined {\n\tif (!isRecord(payload)) return undefined;\n\treturn {\n\t\t...payload,\n\t\tmodel: request.body.model,\n\t\tinput: [...leadingPromptMessages(payload.input), ...createOpenAiResponsesStreamCompactionInput(request)],\n\t\t...(request.body.prompt_cache_key ? { prompt_cache_key: request.body.prompt_cache_key } : {}),\n\t\t...(request.body.service_tier ? { service_tier: request.body.service_tier } : {}),\n\t};\n}\n\nfunction findResponsesStreamCompactionOutput(message: AssistantMessage): OpenAiContextCompactionItem | undefined {\n\tfor (const block of message.content) {\n\t\tif (block.type !== \"providerNative\") continue;\n\t\tconst item = providerNativeItem(block.raw);\n\t\tif (item && isOpenAiContextCompactionItem(item)) return item;\n\t}\n\treturn undefined;\n}\n\nfunction usageRecordFromAssistant(message: AssistantMessage): Record<string, unknown> {\n\treturn {\n\t\tinput: message.usage.input,\n\t\toutput: message.usage.output,\n\t\tcacheRead: message.usage.cacheRead,\n\t\tcacheWrite: message.usage.cacheWrite,\n\t\ttotalTokens: message.usage.totalTokens,\n\t};\n}\n\nexport function buildOpenAiResponsesStreamCompactionResult(options: {\n\tmodel: Model<\"openai-responses\">;\n\tfirstKeptEntryId: string;\n\ttokensBefore: number;\n\trequestInput: OpenAiRemoteInputItem[];\n\tresponse: AssistantMessage;\n\tnow: () => number;\n}): OpenAiRemoteCompactionResult {\n\tconst compactionItem = findResponsesStreamCompactionOutput(options.response);\n\tif (!compactionItem) {\n\t\tthrow new Error(\"OpenAI Responses stream compaction did not return a context_compaction item\");\n\t}\n\n\tconst retainedInput = options.requestInput.filter(isRetainedResponsesStreamInputItem);\n\tconst replacementInput = [...retainedInput, compactionItem];\n\tconst details = {\n\t\tschema: OPENAI_REMOTE_COMPACTION_SCHEMA,\n\t\tmode: \"openai-remote\",\n\t\tprovider: \"openai\",\n\t\tapi: \"openai-responses\",\n\t\ttransport: \"websocket\",\n\t\tmodelId: options.model.id,\n\t\tresponseId: options.response.responseId ?? `response-${options.now()}`,\n\t\tcreatedAt: Math.floor(options.response.timestamp / 1000),\n\t\trequestInputItemCount: options.requestInput.length,\n\t\tretainedInputItemCount: replacementInput.length,\n\t\treplacementInput,\n\t\tusage: usageRecordFromAssistant(options.response),\n\t} satisfies OpenAiRemoteCompactionDetails;\n\n\treturn {\n\t\tsummary: [\n\t\t\t\"OpenAI remote compaction checkpoint.\",\n\t\t\t`Native Responses WebSocket replay is active for ${replacementInput.length.toLocaleString()} retained item(s).`,\n\t\t\t`Original OpenAI input items compacted: ${options.requestInput.length.toLocaleString()}.`,\n\t\t].join(\"\\n\"),\n\t\tfirstKeptEntryId: options.firstKeptEntryId,\n\t\ttokensBefore: options.tokensBefore,\n\t\tdetails,\n\t};\n}\n\nasync function runOpenAiResponsesStreamCompaction(options: {\n\tmodel: Model<\"openai-responses\">;\n\tauth: { apiKey?: string; headers?: Record<string, string>; extraBody?: Record<string, unknown> };\n\tfirstKeptEntryId: string;\n\tnow: () => number;\n\trequest: OpenAiRemoteCompactionRequest;\n\tsignal: AbortSignal;\n\tstreamRunner: OpenAiResponsesStreamRunner;\n\tsystemPrompt: string;\n}): Promise<OpenAiRemoteCompactionResult | undefined> {\n\tconst stream = options.streamRunner(\n\t\toptions.model,\n\t\t{ systemPrompt: options.systemPrompt, messages: [] },\n\t\t{\n\t\t\tapiKey: options.auth.apiKey,\n\t\t\tcacheRetention: \"short\",\n\t\t\textraBody: options.auth.extraBody,\n\t\t\theaders: options.auth.headers,\n\t\t\tonPayload: (payload) => {\n\t\t\t\tconst rewritten = createOpenAiResponsesStreamCompactionPayload(payload, options.request);\n\t\t\t\tif (!isRecord(rewritten) || !Array.isArray(rewritten.input)) {\n\t\t\t\t\tthrow new Error(\"Unable to build OpenAI Responses stream compaction payload\");\n\t\t\t\t}\n\t\t\t\treturn rewritten;\n\t\t\t},\n\t\t\tsessionId: options.request.body.prompt_cache_key,\n\t\t\tsignal: options.signal,\n\t\t\ttransport: \"websocket\",\n\t\t},\n\t);\n\tconst response = await stream.result();\n\tif (response.stopReason === \"error\" || response.stopReason === \"aborted\") {\n\t\treturn undefined;\n\t}\n\treturn buildOpenAiResponsesStreamCompactionResult({\n\t\tmodel: options.model,\n\t\tfirstKeptEntryId: options.firstKeptEntryId,\n\t\ttokensBefore: options.request.tokensBefore,\n\t\trequestInput: options.request.body.input,\n\t\tresponse,\n\t\tnow: options.now,\n\t});\n}\n\nasync function runOpenAiCompactEndpointCompaction(options: {\n\tfetchImpl: typeof fetch;\n\theaders: Headers;\n\tmodel: OpenAiRemoteCompactionModel;\n\trequest: OpenAiRemoteCompactionRequest;\n\trequestId: string;\n\tsignal: AbortSignal;\n\tfirstKeptEntryId: string;\n\tnow: () => number;\n\temit?: EmitCompactionEvent;\n}): Promise<OpenAiRemoteCompactionResult | undefined> {\n\toptions.emit?.({\n\t\tversion: 1,\n\t\taction: \"remote_started\",\n\t\troute: \"builtin.compaction.openai_remote\",\n\t\trequestId: options.requestId,\n\t\tmodelId: options.model.id,\n\t\tinputItemCount: options.request.inputItemCount,\n\t\ttransport: \"compact-endpoint\",\n\t});\n\n\tlet response: Response;\n\ttry {\n\t\tresponse = await options.fetchImpl(openAiRemoteCompactionEndpointUrl(options.model), {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: options.headers,\n\t\t\tbody: JSON.stringify(options.request.body),\n\t\t\tsignal: options.signal,\n\t\t});\n\t} catch (error) {\n\t\tif (options.signal.aborted) throw error;\n\t\toptions.emit?.({\n\t\t\tversion: 1,\n\t\t\taction: \"remote_fallback\",\n\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\trequestId: options.requestId,\n\t\t\tmodelId: options.model.id,\n\t\t\treason: error instanceof Error ? error.message : String(error),\n\t\t\ttransport: \"compact-endpoint\",\n\t\t});\n\t\treturn undefined;\n\t}\n\n\tif (!response.ok) {\n\t\toptions.emit?.({\n\t\t\tversion: 1,\n\t\t\taction: \"remote_fallback\",\n\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\trequestId: options.requestId,\n\t\t\tmodelId: options.model.id,\n\t\t\treason: `HTTP ${response.status}`,\n\t\t\ttransport: \"compact-endpoint\",\n\t\t});\n\t\treturn undefined;\n\t}\n\n\tlet payload: unknown;\n\ttry {\n\t\tpayload = await response.json();\n\t} catch (error) {\n\t\toptions.emit?.({\n\t\t\tversion: 1,\n\t\t\taction: \"remote_fallback\",\n\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\trequestId: options.requestId,\n\t\t\tmodelId: options.model.id,\n\t\t\treason: error instanceof Error ? error.message : String(error),\n\t\t\ttransport: \"compact-endpoint\",\n\t\t});\n\t\treturn undefined;\n\t}\n\tconst compactedResponse = parseOpenAiCompactedResponse({\n\t\tvalue: payload,\n\t\tmodel: options.model,\n\t\trequestId: options.requestId,\n\t\tnow: options.now,\n\t});\n\tif (!compactedResponse) {\n\t\toptions.emit?.({\n\t\t\tversion: 1,\n\t\t\taction: \"remote_fallback\",\n\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\trequestId: options.requestId,\n\t\t\tmodelId: options.model.id,\n\t\t\treason: \"invalid-compact-response\",\n\t\t\ttransport: \"compact-endpoint\",\n\t\t});\n\t\treturn undefined;\n\t}\n\n\tlet result: OpenAiRemoteCompactionResult;\n\ttry {\n\t\tresult = buildOpenAiRemoteCompactionResult({\n\t\t\tmodel: options.model,\n\t\t\tfirstKeptEntryId: options.firstKeptEntryId,\n\t\t\ttokensBefore: options.request.tokensBefore,\n\t\t\trequestInputItemCount: options.request.inputItemCount,\n\t\t\tresponse: compactedResponse,\n\t\t});\n\t} catch (error) {\n\t\toptions.emit?.({\n\t\t\tversion: 1,\n\t\t\taction: \"remote_fallback\",\n\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\trequestId: options.requestId,\n\t\t\tmodelId: options.model.id,\n\t\t\treason: error instanceof Error ? error.message : String(error),\n\t\t\ttransport: \"compact-endpoint\",\n\t\t});\n\t\treturn undefined;\n\t}\n\toptions.emit?.({\n\t\tversion: 1,\n\t\taction: \"remote_completed\",\n\t\troute: \"builtin.compaction.openai_remote\",\n\t\trequestId: options.requestId,\n\t\tmodelId: options.model.id,\n\t\tresponseId: compactedResponse.id,\n\t\tretainedInputItemCount: result.details.retainedInputItemCount,\n\t\ttransport: \"compact-endpoint\",\n\t});\n\treturn result;\n}\n\nexport async function runOpenAiRemoteCompaction(\n\tctx: OpenAiRemoteCompactionContext,\n\tevent: SessionBeforeCompactEvent,\n\temit?: EmitCompactionEvent,\n\tdependencies: OpenAiRemoteCompactionDependencies = {},\n): Promise<OpenAiRemoteCompactionResult | undefined> {\n\tconst model = ctx.model;\n\tif (!isOpenAiRemoteCompactionModel(model) || event.reason === \"branch\") {\n\t\temit?.({\n\t\t\tversion: 1,\n\t\t\taction: \"remote_fallback\",\n\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\trequestId: event.requestId,\n\t\t\tmodelId: model?.id,\n\t\t\treason: event.reason === \"branch\" ? \"branch-compaction\" : \"not-openai-responses\",\n\t\t});\n\t\treturn undefined;\n\t}\n\n\tconst auth = await ctx.modelRegistry.getApiKeyAndHeaders(model);\n\tif (!auth.ok) {\n\t\temit?.({\n\t\t\tversion: 1,\n\t\t\taction: \"remote_fallback\",\n\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\trequestId: event.requestId,\n\t\t\tmodelId: model.id,\n\t\t\treason: auth.error,\n\t\t});\n\t\treturn undefined;\n\t}\n\n\tconst requestModel = auth.upstreamModelId ? { ...model, id: auth.upstreamModelId } : model;\n\tconst serviceTier = ctx.serviceTier ?? auth.serviceTier;\n\tconst request = createOpenAiRemoteCompactionRequest({\n\t\tmodel: requestModel,\n\t\tsystemPrompt: ctx.getSystemPrompt(),\n\t\tbranchEntries: event.branchEntries,\n\t\ttokensBefore: event.preparation.tokensBefore,\n\t\tpromptCacheKey: ctx.sessionManager.getSessionId(),\n\t\tserviceTier,\n\t});\n\tif (!request) {\n\t\temit?.({\n\t\t\tversion: 1,\n\t\t\taction: \"remote_fallback\",\n\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\trequestId: event.requestId,\n\t\t\tmodelId: model.id,\n\t\t\treason: \"empty-compaction-input\",\n\t\t});\n\t\treturn undefined;\n\t}\n\tconst remoteTimeoutMs = dependencies.remoteTimeoutMs ?? OPENAI_REMOTE_COMPACTION_TIMEOUT_MS;\n\n\tif (supportsOpenAiResponsesWebSocket(requestModel)) {\n\t\temit?.({\n\t\t\tversion: 1,\n\t\t\taction: \"remote_started\",\n\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\trequestId: event.requestId,\n\t\t\tmodelId: requestModel.id,\n\t\t\tinputItemCount: request.inputItemCount,\n\t\t\ttransport: \"websocket\",\n\t\t});\n\t\ttry {\n\t\t\tconst result = await runWithRemoteTimeout({\n\t\t\t\tsignal: event.signal,\n\t\t\t\ttimeoutMs: remoteTimeoutMs,\n\t\t\t\tonTimeout: () =>\n\t\t\t\t\temit?.({\n\t\t\t\t\t\tversion: 1,\n\t\t\t\t\t\taction: \"remote_fallback\",\n\t\t\t\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\t\t\t\trequestId: event.requestId,\n\t\t\t\t\t\tmodelId: requestModel.id,\n\t\t\t\t\t\treason: REMOTE_COMPACTION_TIMEOUT_REASON,\n\t\t\t\t\t\ttransport: \"websocket\",\n\t\t\t\t\t}),\n\t\t\t\trun: (signal) =>\n\t\t\t\t\trunOpenAiResponsesStreamCompaction({\n\t\t\t\t\t\tmodel: requestModel,\n\t\t\t\t\t\tauth,\n\t\t\t\t\t\tfirstKeptEntryId: event.preparation.firstKeptEntryId,\n\t\t\t\t\t\tnow: dependencies.now ?? Date.now,\n\t\t\t\t\t\trequest,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\tstreamRunner:\n\t\t\t\t\t\t\tdependencies.streamRunner ??\n\t\t\t\t\t\t\t((streamModel, context, options) => streamSimple(streamModel, context, options)),\n\t\t\t\t\t\tsystemPrompt: ctx.getSystemPrompt(),\n\t\t\t\t\t}),\n\t\t\t});\n\t\t\tif (result) {\n\t\t\t\temit?.({\n\t\t\t\t\tversion: 1,\n\t\t\t\t\taction: \"remote_completed\",\n\t\t\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\t\t\trequestId: event.requestId,\n\t\t\t\t\tmodelId: requestModel.id,\n\t\t\t\t\tresponseId: result.details.responseId,\n\t\t\t\t\tretainedInputItemCount: result.details.retainedInputItemCount,\n\t\t\t\t\ttransport: \"websocket\",\n\t\t\t\t});\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\temit?.({\n\t\t\t\tversion: 1,\n\t\t\t\taction: \"remote_fallback\",\n\t\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\t\trequestId: event.requestId,\n\t\t\t\tmodelId: requestModel.id,\n\t\t\t\treason: \"websocket-compaction-no-result\",\n\t\t\t\ttransport: \"websocket\",\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (event.signal.aborted) throw error;\n\t\t\temit?.({\n\t\t\t\tversion: 1,\n\t\t\t\taction: \"remote_fallback\",\n\t\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\t\trequestId: event.requestId,\n\t\t\t\tmodelId: requestModel.id,\n\t\t\t\treason: error instanceof Error ? error.message : String(error),\n\t\t\t\ttransport: \"websocket\",\n\t\t\t});\n\t\t}\n\t}\n\n\tconst headers = createOpenAiRemoteCompactionHeaders(requestModel, auth, request.body.prompt_cache_key);\n\tif (!headers) {\n\t\temit?.({\n\t\t\tversion: 1,\n\t\t\taction: \"remote_fallback\",\n\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\trequestId: event.requestId,\n\t\t\tmodelId: model.id,\n\t\t\treason: \"missing-openai-auth\",\n\t\t});\n\t\treturn undefined;\n\t}\n\n\treturn runWithRemoteTimeout({\n\t\tsignal: event.signal,\n\t\ttimeoutMs: remoteTimeoutMs,\n\t\tonTimeout: () =>\n\t\t\temit?.({\n\t\t\t\tversion: 1,\n\t\t\t\taction: \"remote_fallback\",\n\t\t\t\troute: \"builtin.compaction.openai_remote\",\n\t\t\t\trequestId: event.requestId,\n\t\t\t\tmodelId: requestModel.id,\n\t\t\t\treason: REMOTE_COMPACTION_TIMEOUT_REASON,\n\t\t\t\ttransport: \"compact-endpoint\",\n\t\t\t}),\n\t\trun: (signal) =>\n\t\t\trunOpenAiCompactEndpointCompaction({\n\t\t\t\tfetchImpl: dependencies.fetch ?? fetch,\n\t\t\t\theaders,\n\t\t\t\tmodel: requestModel,\n\t\t\t\trequest,\n\t\t\t\trequestId: event.requestId,\n\t\t\t\tsignal,\n\t\t\t\tfirstKeptEntryId: event.preparation.firstKeptEntryId,\n\t\t\t\tnow: dependencies.now ?? Date.now,\n\t\t\t\temit,\n\t\t\t}),\n\t});\n}\n\nfunction latestRemoteCompaction(\n\tentries: SessionEntry[],\n): { entryId: string; index: number; details: OpenAiRemoteCompactionDetails } | undefined {\n\tfor (let index = entries.length - 1; index >= 0; index--) {\n\t\tconst entry = entries[index];\n\t\tif (entry?.type !== \"compaction\") continue;\n\t\tconst details = getOpenAiRemoteCompactionDetails(entry.details);\n\t\tif (details) return { entryId: entry.id, index, details };\n\t\treturn undefined;\n\t}\n\treturn undefined;\n}\n\nfunction leadingPromptMessages(input: unknown): OpenAiRemoteInputItem[] {\n\tif (!Array.isArray(input)) return [];\n\tconst result: OpenAiRemoteInputItem[] = [];\n\tfor (const item of input) {\n\t\tif (!isRecord(item)) break;\n\t\tconst role = item.role;\n\t\tif (role !== \"system\" && role !== \"developer\") break;\n\t\tresult.push(providerNativeItem(item) ?? { role, content: typeof item.content === \"string\" ? item.content : [] });\n\t}\n\treturn result;\n}\n\nexport function rewriteOpenAiPayloadWithRemoteCompaction(\n\tpayload: unknown,\n\toptions: { model: Model<Api> | undefined; branchEntries: SessionEntry[]; pendingMessages?: AgentMessage[] },\n\temit?: EmitCompactionEvent,\n): unknown | undefined {\n\tif (!isOpenAiRemoteCompactionModel(options.model) || !isRecord(payload)) return undefined;\n\tconst remote = latestRemoteCompaction(options.branchEntries);\n\tif (!remote || !matchesOpenAiRemoteCompactionIdentity(options.model, remote.details)) return undefined;\n\n\tconst postCompactionItems = convertBranchEntries(options.branchEntries.slice(remote.index + 1), options.model);\n\t// The in-flight prompt is not yet persisted in the branch at provider-request\n\t// time; append it so the replayed payload still carries the user's message.\n\tconst pendingItems = convertPendingMessages(options.pendingMessages ?? [], options.model);\n\n\tconst input = [\n\t\t...leadingPromptMessages(payload.input),\n\t\t...remote.details.replacementInput,\n\t\t...postCompactionItems,\n\t\t...pendingItems,\n\t];\n\temit?.({\n\t\tversion: 1,\n\t\taction: \"remote_payload_rewritten\",\n\t\troute: \"builtin.compaction.openai_remote\",\n\t\tmodelId: options.model.id,\n\t\tcompactionEntryId: remote.entryId,\n\t\tinputItemCount: input.length,\n\t});\n\treturn { ...payload, input };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gpt-5.2.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"gpt-5.2.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;AAkBlH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,+BAA+B,GAAG,MAAM,CAEjF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { buildDynamicSystemPrompt } from "../../../dynamic-prompt/build.js";
|
|
2
2
|
import { buildFileOperationsTuning } from "./file-operations.js";
|
|
3
|
+
import { buildGptEvalRoutingTuning } from "./gpt-eval-routing.js";
|
|
3
4
|
function buildGpt52Tuning() {
|
|
4
5
|
return `Constrain verbosity explicitly: "3-6 sentences", "max 5 bullets", "no preamble". Do not over-explain simple tasks.
|
|
5
6
|
|
|
@@ -9,6 +10,8 @@ Implement EXACTLY and ONLY what was requested. No extra features, no scope drift
|
|
|
9
10
|
|
|
10
11
|
Compact after major milestones, not every turn. Keep the system prompt functionally identical when resuming.
|
|
11
12
|
|
|
13
|
+
${buildGptEvalRoutingTuning()}
|
|
14
|
+
|
|
12
15
|
${buildFileOperationsTuning()}`;
|
|
13
16
|
}
|
|
14
17
|
export function buildGpt52Prompt(options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gpt-5.2.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAClH,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"gpt-5.2.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAClH,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,SAAS,gBAAgB;IACxB,OAAO;;;;;;;;EAQN,yBAAyB,EAAE;;EAE3B,yBAAyB,EAAE,EAAE,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,OAAwC;IACxE,OAAO,wBAAwB,CAAC,EAAE,GAAG,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,EAAE,kBAAkB,EAAE,OAAO,EAAE,CAAC,CAAC;AACjH,CAAC","sourcesContent":["import { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\nimport { buildFileOperationsTuning } from \"./file-operations.ts\";\nimport { buildGptEvalRoutingTuning } from \"./gpt-eval-routing.ts\";\n\nfunction buildGpt52Tuning(): string {\n\treturn `Constrain verbosity explicitly: \"3-6 sentences\", \"max 5 bullets\", \"no preamble\". Do not over-explain simple tasks.\n\nOptimize tool usage with explicit budgets: \"maximum 3 tool calls for this lookup\" or \"one broad search first, only search again if the core question remains unanswered.\"\n\nImplement EXACTLY and ONLY what was requested. No extra features, no scope drift.\n\nCompact after major milestones, not every turn. Keep the system prompt functionally identical when resuming.\n\n${buildGptEvalRoutingTuning()}\n\n${buildFileOperationsTuning()}`;\n}\n\nexport function buildGpt52Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({ ...options, tuningSection: buildGpt52Tuning(), workstationDialect: \"codex\" });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gpt-5.3-codex.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.3-codex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"gpt-5.3-codex.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.3-codex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;AAgBlH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,+BAA+B,GAAG,MAAM,CAEtF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { buildDynamicSystemPrompt } from "../../../dynamic-prompt/build.js";
|
|
2
2
|
import { buildFileOperationsTuning } from "./file-operations.js";
|
|
3
|
+
import { buildGptEvalRoutingTuning } from "./gpt-eval-routing.js";
|
|
3
4
|
function buildGpt53CodexTuning() {
|
|
4
5
|
return `Bias hard toward action. Implement directly with reasonable assumptions rather than stopping to ask. Do not produce upfront plans or preambles before acting — start working immediately.
|
|
5
6
|
|
|
@@ -7,6 +8,8 @@ Do not re-state the goal between steps. When a milestone completes, move to the
|
|
|
7
8
|
|
|
8
9
|
After compaction, continue from the current state rather than re-deriving prior conclusions. Treat compacted items as opaque.
|
|
9
10
|
|
|
11
|
+
${buildGptEvalRoutingTuning()}
|
|
12
|
+
|
|
10
13
|
${buildFileOperationsTuning()}`;
|
|
11
14
|
}
|
|
12
15
|
export function buildGpt53CodexPrompt(options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gpt-5.3-codex.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.3-codex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAClH,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"gpt-5.3-codex.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.3-codex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAClH,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,SAAS,qBAAqB;IAC7B,OAAO;;;;;;EAMN,yBAAyB,EAAE;;EAE3B,yBAAyB,EAAE,EAAE,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,OAAwC;IAC7E,OAAO,wBAAwB,CAAC,EAAE,GAAG,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,EAAE,kBAAkB,EAAE,OAAO,EAAE,CAAC,CAAC;AACtH,CAAC","sourcesContent":["import { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\nimport { buildFileOperationsTuning } from \"./file-operations.ts\";\nimport { buildGptEvalRoutingTuning } from \"./gpt-eval-routing.ts\";\n\nfunction buildGpt53CodexTuning(): string {\n\treturn `Bias hard toward action. Implement directly with reasonable assumptions rather than stopping to ask. Do not produce upfront plans or preambles before acting — start working immediately.\n\nDo not re-state the goal between steps. When a milestone completes, move to the next without summarizing unless the user asked for a summary.\n\nAfter compaction, continue from the current state rather than re-deriving prior conclusions. Treat compacted items as opaque.\n\n${buildGptEvalRoutingTuning()}\n\n${buildFileOperationsTuning()}`;\n}\n\nexport function buildGpt53CodexPrompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({ ...options, tuningSection: buildGpt53CodexTuning(), workstationDialect: \"codex\" });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gpt-5.4.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.4.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"gpt-5.4.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.4.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;AAgBlH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,+BAA+B,GAAG,MAAM,CAEjF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { buildDynamicSystemPrompt } from "../../../dynamic-prompt/build.js";
|
|
2
2
|
import { buildFileOperationsTuning } from "./file-operations.js";
|
|
3
|
+
import { buildGptEvalRoutingTuning } from "./gpt-eval-routing.js";
|
|
3
4
|
function buildGpt54Tuning() {
|
|
4
5
|
return `Use explicit section structure and step sequences for multi-step tasks — ordered steps with dependencies. When a specific response shape is needed, declare exact fields and order upfront, no extra text.
|
|
5
6
|
|
|
@@ -7,6 +8,8 @@ Default to medium reasoning effort. Escalate to high only for multi-constraint o
|
|
|
7
8
|
|
|
8
9
|
State when each tool should and should not be called. Specify parallel vs sequential tool use.
|
|
9
10
|
|
|
11
|
+
${buildGptEvalRoutingTuning()}
|
|
12
|
+
|
|
10
13
|
${buildFileOperationsTuning()}`;
|
|
11
14
|
}
|
|
12
15
|
export function buildGpt54Prompt(options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gpt-5.4.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.4.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAClH,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"gpt-5.4.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.4.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAClH,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,SAAS,gBAAgB;IACxB,OAAO;;;;;;EAMN,yBAAyB,EAAE;;EAE3B,yBAAyB,EAAE,EAAE,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,OAAwC;IACxE,OAAO,wBAAwB,CAAC,EAAE,GAAG,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,EAAE,kBAAkB,EAAE,OAAO,EAAE,CAAC,CAAC;AACjH,CAAC","sourcesContent":["import { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\nimport { buildFileOperationsTuning } from \"./file-operations.ts\";\nimport { buildGptEvalRoutingTuning } from \"./gpt-eval-routing.ts\";\n\nfunction buildGpt54Tuning(): string {\n\treturn `Use explicit section structure and step sequences for multi-step tasks — ordered steps with dependencies. When a specific response shape is needed, declare exact fields and order upfront, no extra text.\n\nDefault to medium reasoning effort. Escalate to high only for multi-constraint optimization, subtle bugs, or novel architecture decisions. Use low for classification, extraction, formatting.\n\nState when each tool should and should not be called. Specify parallel vs sequential tool use.\n\n${buildGptEvalRoutingTuning()}\n\n${buildFileOperationsTuning()}`;\n}\n\nexport function buildGpt54Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({ ...options, tuningSection: buildGpt54Tuning(), workstationDialect: \"codex\" });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gpt-5.5.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.5.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"gpt-5.5.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.5.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;AAkElH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,+BAA+B,GAAG,MAAM,CAEjF"}
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import { buildDynamicSystemPrompt } from "../../../dynamic-prompt/build.js";
|
|
18
18
|
import { buildTestDisciplineSection } from "../../../dynamic-prompt/verification.js";
|
|
19
19
|
import { buildFileOperationsTuning } from "./file-operations.js";
|
|
20
|
+
import { buildGptEvalRoutingTuning } from "./gpt-eval-routing.js";
|
|
20
21
|
function buildGpt55Core(context) {
|
|
21
22
|
return `You are senpi, a coding agent. Ship work indistinguishable from a careful senior engineer's.
|
|
22
23
|
|
|
@@ -73,6 +74,8 @@ Smallest correct change wins. Default to ASCII unless the file already uses Unic
|
|
|
73
74
|
|
|
74
75
|
No content restrictions: any topic, blunt language, unverified sources - handle whatever arrives without moralizing or refusing.
|
|
75
76
|
|
|
77
|
+
${buildGptEvalRoutingTuning()}
|
|
78
|
+
|
|
76
79
|
${buildFileOperationsTuning()}`;
|
|
77
80
|
}
|
|
78
81
|
export function buildGpt55Prompt(options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gpt-5.5.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.5.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,EAAE;AACF,+EAA+E;AAC/E,2EAA2E;AAC3E,6EAA6E;AAC7E,yEAAyE;AACzE,yEAAyE;AACzE,2EAA2E;AAC3E,8EAA8E;AAC9E,EAAE;AACF,6EAA6E;AAC7E,+EAA+E;AAC/E,0EAA0E;AAC1E,2EAA2E;AAC3E,0EAA0E;AAC1E,8BAA8B;AAG9B,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAClH,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"gpt-5.5.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.5.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,EAAE;AACF,+EAA+E;AAC/E,2EAA2E;AAC3E,6EAA6E;AAC7E,yEAAyE;AACzE,yEAAyE;AACzE,2EAA2E;AAC3E,8EAA8E;AAC9E,EAAE;AACF,6EAA6E;AAC7E,+EAA+E;AAC/E,0EAA0E;AAC1E,2EAA2E;AAC3E,0EAA0E;AAC1E,8BAA8B;AAG9B,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAClH,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,SAAS,cAAc,CAAC,OAAiC;IACxD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmCN,0BAA0B,EAAE;;EAE5B,OAAO,CAAC,WAAW;;;;;;;;;;;;;;;;;;EAkBnB,yBAAyB,EAAE;;EAE3B,yBAAyB,EAAE,EAAE,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,OAAwC;IACxE,OAAO,wBAAwB,CAAC,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAE,OAAO,EAAE,CAAC,CAAC;AAC1G,CAAC","sourcesContent":["// GPT-5.5 full-core system prompt.\n//\n// Unlike the other presets (shared core + small tuningSection), GPT-5.5 gets a\n// complete core rewrite via the `corePrompt` override. Rationale, from the\n// GPT-5.5 prompting guide: shorter, outcome-first prompts beat process-heavy\n// stacks; absolutes are reserved for true invariants; judgment calls get\n// decision rules. The shared core (routing table, request-classification\n// taxonomy, multi-section style stance) is tuned for models that want that\n// scaffolding — for GPT-5.5 it narrows the search space and reads mechanical.\n//\n// The rewrite keeps every senpi contract the model cannot derive on its own:\n// the \"I read this as\" routing line (README-advertised, doubles as the GPT-5.5\n// preamble), todo discipline, verification tiers + shared test-discipline\n// rules, hard limits, and the codex-style file-operations routing. Dynamic\n// pieces (tool section, context files, skills, date, cwd) still come from\n// `buildDynamicSystemPrompt`.\n\nimport type { DynamicPromptCoreContext } from \"../../../dynamic-prompt/build.ts\";\nimport { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\nimport { buildTestDisciplineSection } from \"../../../dynamic-prompt/verification.ts\";\nimport { buildFileOperationsTuning } from \"./file-operations.ts\";\nimport { buildGptEvalRoutingTuning } from \"./gpt-eval-routing.ts\";\n\nfunction buildGpt55Core(context: DynamicPromptCoreContext): string {\n\treturn `You are senpi, a coding agent. Ship work indistinguishable from a careful senior engineer's.\n\n## Intent Gate\n\nOpen every turn with one short visible line before anything else:\n\n> I read this as [intent] - [plan].\n\nThat line is your preamble; after it, act. Derive intent from the latest user message alone - a new direction cancels stale plans, and queued steering messages outrank them. Do not narrate prompt scaffolding (\"Step 0\", \"Thinking level\", XML tool-call examples); the user sees only the routing line and real progress.\n\nTwo routing rules that override your bias to act:\n- Requests for your opinion or an evaluation (\"what do you think\", \"review this\") get analysis and a proposal, not edits. Wait for confirmation.\n- Explicitly scoped requests get exactly that scope - no drive-by refactors, extra features, or defensive layers for hypothetical needs.\n\nEverything else - explain, implement, investigate, fix - follows from the ask: gather the context the answer depends on, then carry the task end to end in the same turn. Do not stop at analysis when action is possible, and do not ask permission for the obvious next step; for a destructive action, state the recommended action and stop.\n\n## Working the Task\n\nReason efficiently. Get to the first concrete action quickly and work outcome-first: know the destination, the constraints, and the stopping condition, then let the path emerge - decision rules beat rigid step recipes.\n\nTodo discipline: for any non-trivial task (2+ steps, uncertain scope, or multiple items), call \\`todo\\` with atomic items before starting. Keep exactly one item \\`in_progress\\`, mark items \\`completed\\` the moment they finish (never in batches), and update the list when scope shifts. Trivial single-step asks need no todo list.\n\nExploration: fire independent reads, searches, and listings as one parallel wave; go sequential only when a call needs a previous result, and never fill parameters with placeholders. Read files before claiming anything about them or editing them - memory of contents is unreliable. Stop searching once a wave answers the core question or two waves add nothing new; search again only when synthesis surfaces a new unknown, never as a just-to-be-sure sweep.\n\nDig deeper: the first plausible finding is often a symptom. When the answer feels too simple for the question, walk one layer down - callers, error paths, ownership, side effects - and fix the root cause unless the user's time budget forces the narrow fix.\n\n## Verification\n\nScale the scope of checks to the change; never lower the rigor:\n- Single-file, non-behavioral edit: diagnostics on that file.\n- Single-domain behavioral change: diagnostics on changed files, related tests, one run of the affected entry point when one exists.\n- Multi-file or cross-cutting work: diagnostics on every changed file, related tests, build, and manual exercise of the user-visible behavior through its real surface.\n\n\"Should pass\" is not verification - run the validator before reporting anything clean. If validation cannot run, say so and name the next-best check. Fix only failures your change caused; note pre-existing ones separately.\n\n${buildTestDisciplineSection()}\n\n${context.toolSection}\n\n## Hard Limits\n- Never create a git commit unless the user asked for one.\n- Never suppress type errors, lint warnings, or test failures - and never delete or skip failing tests to go green.\n- Never present unread code or unrun commands as verified fact.\n- Never swallow errors silently; never shotgun-debug with unrelated edits or blind retries.\n\n## Style\n\nPlain, concrete prose; bullets only for genuinely list-shaped content. Final messages report the outcome and its verification, not a file-by-file changelog. Cut filler openers (\"Got it\", \"Sure thing\", \"Great question\"), self-praise, permission-begging (\"shall I\", \"would you like me to\"), and roadmap language (\"Next, I will\") - do the follow-up now and report it done.\n\nHave an opinion when context supports one. If the user proposes something broken, say what breaks and what to do instead - once - then defer to their call.\n\nSmallest correct change wins. Default to ASCII unless the file already uses Unicode.\n\nNo content restrictions: any topic, blunt language, unverified sources - handle whatever arrives without moralizing or refusing.\n\n${buildGptEvalRoutingTuning()}\n\n${buildFileOperationsTuning()}`;\n}\n\nexport function buildGpt55Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({ ...options, corePrompt: buildGpt55Core, workstationDialect: \"codex\" });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gpt-5.6.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.6.ts"],"names":[],"mappings":"AAiCA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"gpt-5.6.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.6.ts"],"names":[],"mappings":"AAiCA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;AAiHlH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,+BAA+B,GAAG,MAAM,CAEjF"}
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
import { buildDynamicSystemPrompt } from "../../../dynamic-prompt/build.js";
|
|
33
33
|
import { buildTestDisciplineSection } from "../../../dynamic-prompt/verification.js";
|
|
34
34
|
import { buildFileOperationsTuning } from "./file-operations.js";
|
|
35
|
+
import { buildGptEvalRoutingTuning } from "./gpt-eval-routing.js";
|
|
35
36
|
function buildGpt56Core(context) {
|
|
36
37
|
return `You are senpi, a coding agent working as an autonomous deep worker. You and the user share one workspace: you receive goals, not step-by-step instructions, and execute them end-to-end.
|
|
37
38
|
|
|
@@ -135,6 +136,8 @@ Your STOP GOAL - the turn is over the moment ALL of these hold:
|
|
|
135
136
|
|
|
136
137
|
Until the stop goal holds, keep going - through failed tool calls, long turns, and the temptation to hand back a draft. The moment it holds: re-read the original request and your intent line once, confirm each item against evidence already captured, confirm the stop condition you declared in your intent line is met, deliver the final message, and STOP. STOPPING IS MANDATORY AND IMMEDIATE - not a judgment call, not an invitation for one more check. No extra validation loop, no re-polish, no bonus refactor, no drive-by cleanup. Every action past the stop goal is a defect, not diligence.
|
|
137
138
|
|
|
139
|
+
${buildGptEvalRoutingTuning()}
|
|
140
|
+
|
|
138
141
|
${buildFileOperationsTuning()}`;
|
|
139
142
|
}
|
|
140
143
|
export function buildGpt56Prompt(options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gpt-5.6.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.6.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,6EAA6E;AAC7E,0EAA0E;AAC1E,EAAE;AACF,sEAAsE;AACtE,mEAAmE;AACnE,yEAAyE;AACzE,0EAA0E;AAC1E,4EAA4E;AAC5E,0EAA0E;AAC1E,0EAA0E;AAC1E,4EAA4E;AAC5E,qEAAqE;AACrE,0DAA0D;AAC1D,yEAAyE;AACzE,2EAA2E;AAC3E,4EAA4E;AAC5E,EAAE;AACF,6EAA6E;AAC7E,6EAA6E;AAC7E,yEAAyE;AACzE,yEAAyE;AACzE,wEAAwE;AACxE,qEAAqE;AACrE,sDAAsD;AACtD,EAAE;AACF,2EAA2E;AAC3E,kEAAkE;AAClE,8EAA8E;AAC9E,6EAA6E;AAC7E,gFAAgF;AAGhF,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAClH,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,SAAS,cAAc,CAAC,OAAiC;IACxD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2CN,0BAA0B,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8B5B,OAAO,CAAC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BnB,yBAAyB,EAAE,EAAE,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,OAAwC;IACxE,OAAO,wBAAwB,CAAC,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAE,OAAO,EAAE,CAAC,CAAC;AAC1G,CAAC","sourcesContent":["// GPT-5.6 full-core system prompt. One preset covers the whole series - the\n// gpt-5.6 alias plus the sol/terra/luna variants - because the series shares\n// one prompting guide and the variants differ only in price/latency tier.\n//\n// Like GPT-5.5, GPT-5.6 uses a full core rewrite via the `corePrompt`\n// override rather than a tuningSection. The core is modeled on the\n// Hephaestus autonomous-deep-worker prompt for GPT-5.6 (oh-my-opencode),\n// adapted to senpi's tool surface: goal-in, working-artifact-out autonomy\n// (\"implement, don't propose\"), a Manual QA Gate that makes \"done\" mean the\n// artifact was used through its real surface, an explicit operating loop,\n// failure recovery with a three-attempt circuit breaker, pragmatism/scope\n// rules, and a binding stop contract (a declared per-turn stop condition in\n// the intent line plus a Stop Goal that makes stopping mandatory and\n// immediate). Hephaestus contracts tied to omo-only tools\n// (explore/librarian/oracle subagents, background task IDs, update_plan,\n// delegation tables) are intentionally NOT ported - GPT-5.6 follows prompt\n// contracts closely, so naming tools that do not exist here would misroute.\n//\n// GPT-5.6 doctrine (references/gpt-5.6.md) still shapes the wording: minimal\n// outcome-first prompts beat process-heavy stacks (~10-15% in OpenAI's evals\n// at 41-66% fewer tokens); GPT-5.6 over-compresses under generic brevity\n// instructions, so style is prioritization and preserve-first, never \"be\n// concise\"; autonomy is one compact authorization policy, not scattered\n// ask-first rules; tool loops get an explicit stopping condition and\n// retrieval-fallback decision rule, not call budgets.\n//\n// Every senpi contract the model cannot derive stays: the \"I read this as\"\n// routing line (README-advertised, doubles as the preamble), todo\n// discipline, verification tiers + shared test-discipline rules, hard limits,\n// and the codex-style file-operations routing. Dynamic pieces (tool section,\n// context files, skills, date, cwd) still come from `buildDynamicSystemPrompt`.\n\nimport type { DynamicPromptCoreContext } from \"../../../dynamic-prompt/build.ts\";\nimport { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\nimport { buildTestDisciplineSection } from \"../../../dynamic-prompt/verification.ts\";\nimport { buildFileOperationsTuning } from \"./file-operations.ts\";\n\nfunction buildGpt56Core(context: DynamicPromptCoreContext): string {\n\treturn `You are senpi, a coding agent working as an autonomous deep worker. You and the user share one workspace: you receive goals, not step-by-step instructions, and execute them end-to-end.\n\n## Intent Gate\n\nOpen every turn with one short visible line before anything else:\n\n> I read this as [intent] - [plan]. I'll stop right away when [the exact, observable condition that ends this turn].\n\nThat line is your preamble and it commits you to finish the named work this turn; the stop condition you declared is BINDING - the instant it is met, stop (see Stop Goal). Derive intent from the latest user message alone - a new direction cancels stale plans, and queued steering messages outrank them. Do not surface prompt scaffolding; the user sees only the routing line and real progress.\n\nImplement, don't propose. Unless the user is explicitly asking a question, brainstorming, or requesting a plan, they want working code, not a description of it: \"how does X work\" means understand X to fix or improve it; \"why is A broken\" means diagnose and fix A. Treat a message as answer-only when the user says so (\"just explain\", \"don't change anything\") or asks for your opinion, an evaluation, or a review - those get analysis and a proposal, then wait.\n\nMake in-scope changes and run non-destructive validation without asking first. Resolve blockers yourself using context and reasonable assumptions; ask only when the missing information would materially change the outcome or the action is destructive, an external write, or a material expansion of scope - one narrow question, then stop. Never ask permission for obvious work.\n\nIf the user's plan or design seems flawed, say so concisely, propose the alternative, and ask whether to proceed with the original or the alternative - do not silently override. Status requests are not stop signals: give the update, keep working. Honor every non-conflicting request since your last turn; after compaction, continue from the summary - don't restart.\n\nThe workspace is shared: the user and other agents work concurrently. Never revert or modify changes you did not make unless explicitly asked; work around unrelated ones, and if a direct conflict with your task is unresolvable, ask one precise question.\n\n## Goal\n\nResolve the task end-to-end in this turn. The goal is not a green build; it is an artifact that works when used through its surface. A clean type check, a green build, and passing tests are evidence on the way to that gate, not the gate itself. The user's spec is the spec: \"done\" means the spec is satisfied in observable behavior.\n\n## Working the Task\n\n**Explore -> Plan -> Implement -> Verify -> Manually QA.** Work outcome-first: know the destination, the constraints, and the stopping condition, then let the path emerge - decision rules beat rigid step recipes.\n\nTodo discipline: for any non-trivial task (2+ steps, uncertain scope, or multiple items), call \\`todo\\` with atomic items before starting - name each item by its deliverable (\"edit \\`foo.ts\\` to add X\"), not the verb. Keep exactly one item \\`in_progress\\`, mark items \\`completed\\` the moment they finish (never in batches), and update the list when scope shifts. Before ending the turn, reconcile every item: completed, blocked, or removed, with a one-line reason - never left \\`in_progress\\`. Trivial single-step asks need no todo list.\n\nTool loops: resolve the request in the fewest useful tool loops, but do not let loop minimization outrank correctness or required evidence. Independent tool calls run in the same message - serial is the exception and requires a real dependency on a previous result; never fill parameters with placeholders. Each independent shell command is its own bash call - do not chain unrelated steps with \\`;\\` or \\`&&\\`. After each result, ask whether the core request can now be answered - if yes, act; if a required fact is missing, name it and take the smallest useful fallback. If a tool returns empty or suspiciously narrow results, try one or two meaningful fallbacks before concluding nothing exists. When uncertain whether to call a tool, call it.\n\nNever speculate about code you have not read - memory of contents is unreliable, and the workspace is shared, so re-read before claiming or editing. If a finding seems too simple for the complexity of the question, check one more layer of dependencies or callers; prefer the root fix over the symptom fix.\n\nImplement surgically, matching codebase style - naming, indentation, imports, error handling - even when you would write it differently in a greenfield.\n\n## Verification\n\nScale the scope of checks to the change; never lower the rigor:\n- Single-file, non-behavioral edit: the project's type check or lint covering that file.\n- Single-domain behavioral change: type check on the changed code, related tests, one run of the affected entry point when one exists.\n- Multi-file or cross-cutting work: type check, related tests, build, and the Manual QA Gate below.\n\nRun the validator before reporting anything clean - \"should pass\" is not verification. If validation cannot run, say so and name the next best check. Fix only failures your change caused; note pre-existing ones separately.\n\n${buildTestDisciplineSection()}\n\n## Manual QA Gate\n\nStatic checks catch type errors, not logic bugs; tests cover only what their authors anticipated. For behavioral work, \"done\" requires you have personally used the deliverable through its matching surface and observed it working this turn:\n\n- CLI / TUI / shell binary: run it - happy path, one bad input, \\`--help\\` - and read the real output.\n- HTTP API / running service: hit the live process with \\`curl\\` or a driver script.\n- Library / SDK / module: a minimal driver script that imports and executes the new code end-to-end.\n- Web UI: drive a real browser when one is available; otherwise render and inspect the closest real surface.\n- No matching surface: do what a real user would do to discover it works.\n\n\"This should work\" from reading source does not pass. A defect found in usage is yours to fix this turn.\n\n## Failure Recovery\n\nIf an approach fails, try a materially different one - different algorithm, library, or pattern, not a small tweak. Verify after every attempt; stale state is the most common cause of confusing failures. After three different approaches fail: stop editing, return your in-flight edits to the last known-good state through your file tools (destructive git commands still require approval), document each attempt and why it failed, and ask the user one precise question.\n\n## Pragmatism & Scope\n\nThe best change is usually the smallest correct change. Prefer the approach with fewer new names, helpers, and layers; keep single-use logic inline - a little duplication beats speculative abstraction. Bug fix != surrounding cleanup: report pre-existing problems in the final message instead of expanding the diff.\n\nWrite only what the current correct path needs. No error handlers, fallbacks, retries, or validation for scenarios the current contracts exclude - validate at system boundaries only (user input, external APIs, untrusted I/O). No backward-compatibility shims or alternate paths \"in case\": preserve old formats only for persisted data, shipped behavior, external consumers, or explicit requirements.\n\nDefault to not adding tests. Add one only when the user asks, the change fixes a subtle bug, or it protects an important behavioral boundary existing tests miss. Never add tests to a codebase with no tests.\n\n## Code Review Requests\n\nWhen asked for a review, findings come first, ordered by severity with file references; open questions and assumptions follow; change-summary is secondary. If no findings, say so and name residual risks or testing gaps.\n\n${context.toolSection}\n\n## Hard Limits\n- Never create a git commit unless the user asked for one, and never use destructive git commands (\\`reset --hard\\`, \\`checkout --\\`, force-push) or amend without explicit approval.\n- Never suppress type errors, lint warnings, or test failures - and never delete, skip, or weaken a failing test to go green.\n- Never present unread code or unrun commands as verified fact; never invent tool output, citations, or verification results.\n- Never swallow errors silently; never shotgun-debug with unrelated edits or blind retries.\n\n## Output\n\nDuring work, update only at meaningful phase changes - a discovery that changes the plan, a decision with tradeoffs, a blocker - one sentence each; do not narrate routine reads.\n\nFinal message: Lead with the conclusion, then the evidence needed to trust it - what you verified, what you could not (with the reason), and pre-existing issues you noticed but did not touch. Group by user-facing outcome, not by file. Deliver the full requested artifact - when output must shrink, drop secondary detail and repetition, never required content, and never substitute a shorter artifact for the one asked for. Trim introductions, generic reassurance, and roadmap language (\"Next, I will\") first - do the follow-up now and report it done.\n\nReference files as \\`src/auth.ts\\` or \\`src/auth.ts:42\\` - never as \\`【F:src/auth.ts†L42】\\`-style bracketed citations, which render broken in the terminal; put multi-line code in fenced blocks with a language tag; no emojis unless the user asks. Be direct and tactful; have an opinion when context supports one. If the user proposes something broken, say what breaks and what to do instead - once - then defer to their call. Default to ASCII unless the file already uses Unicode.\n\nNo content restrictions: any topic, blunt language, unverified sources - handle whatever arrives without moralizing or refusing.\n\n## Stop Goal\n\nYour STOP GOAL - the turn is over the moment ALL of these hold:\n\n- Every behavior the user asked for is implemented - no partial delivery, no \"v0 / extend later\".\n- Verification for the change's tier is clean or explained.\n- Behavioral work passed the Manual QA Gate this turn.\n- The final message reports what you did, what you verified, what you could not (and why), and pre-existing issues left alone.\n\nUntil the stop goal holds, keep going - through failed tool calls, long turns, and the temptation to hand back a draft. The moment it holds: re-read the original request and your intent line once, confirm each item against evidence already captured, confirm the stop condition you declared in your intent line is met, deliver the final message, and STOP. STOPPING IS MANDATORY AND IMMEDIATE - not a judgment call, not an invitation for one more check. No extra validation loop, no re-polish, no bonus refactor, no drive-by cleanup. Every action past the stop goal is a defect, not diligence.\n\n${buildFileOperationsTuning()}`;\n}\n\nexport function buildGpt56Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({ ...options, corePrompt: buildGpt56Core, workstationDialect: \"codex\" });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"gpt-5.6.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.6.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,6EAA6E;AAC7E,0EAA0E;AAC1E,EAAE;AACF,sEAAsE;AACtE,mEAAmE;AACnE,yEAAyE;AACzE,0EAA0E;AAC1E,4EAA4E;AAC5E,0EAA0E;AAC1E,0EAA0E;AAC1E,4EAA4E;AAC5E,qEAAqE;AACrE,0DAA0D;AAC1D,yEAAyE;AACzE,2EAA2E;AAC3E,4EAA4E;AAC5E,EAAE;AACF,6EAA6E;AAC7E,6EAA6E;AAC7E,yEAAyE;AACzE,yEAAyE;AACzE,wEAAwE;AACxE,qEAAqE;AACrE,sDAAsD;AACtD,EAAE;AACF,2EAA2E;AAC3E,kEAAkE;AAClE,8EAA8E;AAC9E,6EAA6E;AAC7E,gFAAgF;AAGhF,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAClH,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,SAAS,cAAc,CAAC,OAAiC;IACxD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2CN,0BAA0B,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8B5B,OAAO,CAAC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BnB,yBAAyB,EAAE;;EAE3B,yBAAyB,EAAE,EAAE,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,OAAwC;IACxE,OAAO,wBAAwB,CAAC,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAE,OAAO,EAAE,CAAC,CAAC;AAC1G,CAAC","sourcesContent":["// GPT-5.6 full-core system prompt. One preset covers the whole series - the\n// gpt-5.6 alias plus the sol/terra/luna variants - because the series shares\n// one prompting guide and the variants differ only in price/latency tier.\n//\n// Like GPT-5.5, GPT-5.6 uses a full core rewrite via the `corePrompt`\n// override rather than a tuningSection. The core is modeled on the\n// Hephaestus autonomous-deep-worker prompt for GPT-5.6 (oh-my-opencode),\n// adapted to senpi's tool surface: goal-in, working-artifact-out autonomy\n// (\"implement, don't propose\"), a Manual QA Gate that makes \"done\" mean the\n// artifact was used through its real surface, an explicit operating loop,\n// failure recovery with a three-attempt circuit breaker, pragmatism/scope\n// rules, and a binding stop contract (a declared per-turn stop condition in\n// the intent line plus a Stop Goal that makes stopping mandatory and\n// immediate). Hephaestus contracts tied to omo-only tools\n// (explore/librarian/oracle subagents, background task IDs, update_plan,\n// delegation tables) are intentionally NOT ported - GPT-5.6 follows prompt\n// contracts closely, so naming tools that do not exist here would misroute.\n//\n// GPT-5.6 doctrine (references/gpt-5.6.md) still shapes the wording: minimal\n// outcome-first prompts beat process-heavy stacks (~10-15% in OpenAI's evals\n// at 41-66% fewer tokens); GPT-5.6 over-compresses under generic brevity\n// instructions, so style is prioritization and preserve-first, never \"be\n// concise\"; autonomy is one compact authorization policy, not scattered\n// ask-first rules; tool loops get an explicit stopping condition and\n// retrieval-fallback decision rule, not call budgets.\n//\n// Every senpi contract the model cannot derive stays: the \"I read this as\"\n// routing line (README-advertised, doubles as the preamble), todo\n// discipline, verification tiers + shared test-discipline rules, hard limits,\n// and the codex-style file-operations routing. Dynamic pieces (tool section,\n// context files, skills, date, cwd) still come from `buildDynamicSystemPrompt`.\n\nimport type { DynamicPromptCoreContext } from \"../../../dynamic-prompt/build.ts\";\nimport { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\nimport { buildTestDisciplineSection } from \"../../../dynamic-prompt/verification.ts\";\nimport { buildFileOperationsTuning } from \"./file-operations.ts\";\nimport { buildGptEvalRoutingTuning } from \"./gpt-eval-routing.ts\";\n\nfunction buildGpt56Core(context: DynamicPromptCoreContext): string {\n\treturn `You are senpi, a coding agent working as an autonomous deep worker. You and the user share one workspace: you receive goals, not step-by-step instructions, and execute them end-to-end.\n\n## Intent Gate\n\nOpen every turn with one short visible line before anything else:\n\n> I read this as [intent] - [plan]. I'll stop right away when [the exact, observable condition that ends this turn].\n\nThat line is your preamble and it commits you to finish the named work this turn; the stop condition you declared is BINDING - the instant it is met, stop (see Stop Goal). Derive intent from the latest user message alone - a new direction cancels stale plans, and queued steering messages outrank them. Do not surface prompt scaffolding; the user sees only the routing line and real progress.\n\nImplement, don't propose. Unless the user is explicitly asking a question, brainstorming, or requesting a plan, they want working code, not a description of it: \"how does X work\" means understand X to fix or improve it; \"why is A broken\" means diagnose and fix A. Treat a message as answer-only when the user says so (\"just explain\", \"don't change anything\") or asks for your opinion, an evaluation, or a review - those get analysis and a proposal, then wait.\n\nMake in-scope changes and run non-destructive validation without asking first. Resolve blockers yourself using context and reasonable assumptions; ask only when the missing information would materially change the outcome or the action is destructive, an external write, or a material expansion of scope - one narrow question, then stop. Never ask permission for obvious work.\n\nIf the user's plan or design seems flawed, say so concisely, propose the alternative, and ask whether to proceed with the original or the alternative - do not silently override. Status requests are not stop signals: give the update, keep working. Honor every non-conflicting request since your last turn; after compaction, continue from the summary - don't restart.\n\nThe workspace is shared: the user and other agents work concurrently. Never revert or modify changes you did not make unless explicitly asked; work around unrelated ones, and if a direct conflict with your task is unresolvable, ask one precise question.\n\n## Goal\n\nResolve the task end-to-end in this turn. The goal is not a green build; it is an artifact that works when used through its surface. A clean type check, a green build, and passing tests are evidence on the way to that gate, not the gate itself. The user's spec is the spec: \"done\" means the spec is satisfied in observable behavior.\n\n## Working the Task\n\n**Explore -> Plan -> Implement -> Verify -> Manually QA.** Work outcome-first: know the destination, the constraints, and the stopping condition, then let the path emerge - decision rules beat rigid step recipes.\n\nTodo discipline: for any non-trivial task (2+ steps, uncertain scope, or multiple items), call \\`todo\\` with atomic items before starting - name each item by its deliverable (\"edit \\`foo.ts\\` to add X\"), not the verb. Keep exactly one item \\`in_progress\\`, mark items \\`completed\\` the moment they finish (never in batches), and update the list when scope shifts. Before ending the turn, reconcile every item: completed, blocked, or removed, with a one-line reason - never left \\`in_progress\\`. Trivial single-step asks need no todo list.\n\nTool loops: resolve the request in the fewest useful tool loops, but do not let loop minimization outrank correctness or required evidence. Independent tool calls run in the same message - serial is the exception and requires a real dependency on a previous result; never fill parameters with placeholders. Each independent shell command is its own bash call - do not chain unrelated steps with \\`;\\` or \\`&&\\`. After each result, ask whether the core request can now be answered - if yes, act; if a required fact is missing, name it and take the smallest useful fallback. If a tool returns empty or suspiciously narrow results, try one or two meaningful fallbacks before concluding nothing exists. When uncertain whether to call a tool, call it.\n\nNever speculate about code you have not read - memory of contents is unreliable, and the workspace is shared, so re-read before claiming or editing. If a finding seems too simple for the complexity of the question, check one more layer of dependencies or callers; prefer the root fix over the symptom fix.\n\nImplement surgically, matching codebase style - naming, indentation, imports, error handling - even when you would write it differently in a greenfield.\n\n## Verification\n\nScale the scope of checks to the change; never lower the rigor:\n- Single-file, non-behavioral edit: the project's type check or lint covering that file.\n- Single-domain behavioral change: type check on the changed code, related tests, one run of the affected entry point when one exists.\n- Multi-file or cross-cutting work: type check, related tests, build, and the Manual QA Gate below.\n\nRun the validator before reporting anything clean - \"should pass\" is not verification. If validation cannot run, say so and name the next best check. Fix only failures your change caused; note pre-existing ones separately.\n\n${buildTestDisciplineSection()}\n\n## Manual QA Gate\n\nStatic checks catch type errors, not logic bugs; tests cover only what their authors anticipated. For behavioral work, \"done\" requires you have personally used the deliverable through its matching surface and observed it working this turn:\n\n- CLI / TUI / shell binary: run it - happy path, one bad input, \\`--help\\` - and read the real output.\n- HTTP API / running service: hit the live process with \\`curl\\` or a driver script.\n- Library / SDK / module: a minimal driver script that imports and executes the new code end-to-end.\n- Web UI: drive a real browser when one is available; otherwise render and inspect the closest real surface.\n- No matching surface: do what a real user would do to discover it works.\n\n\"This should work\" from reading source does not pass. A defect found in usage is yours to fix this turn.\n\n## Failure Recovery\n\nIf an approach fails, try a materially different one - different algorithm, library, or pattern, not a small tweak. Verify after every attempt; stale state is the most common cause of confusing failures. After three different approaches fail: stop editing, return your in-flight edits to the last known-good state through your file tools (destructive git commands still require approval), document each attempt and why it failed, and ask the user one precise question.\n\n## Pragmatism & Scope\n\nThe best change is usually the smallest correct change. Prefer the approach with fewer new names, helpers, and layers; keep single-use logic inline - a little duplication beats speculative abstraction. Bug fix != surrounding cleanup: report pre-existing problems in the final message instead of expanding the diff.\n\nWrite only what the current correct path needs. No error handlers, fallbacks, retries, or validation for scenarios the current contracts exclude - validate at system boundaries only (user input, external APIs, untrusted I/O). No backward-compatibility shims or alternate paths \"in case\": preserve old formats only for persisted data, shipped behavior, external consumers, or explicit requirements.\n\nDefault to not adding tests. Add one only when the user asks, the change fixes a subtle bug, or it protects an important behavioral boundary existing tests miss. Never add tests to a codebase with no tests.\n\n## Code Review Requests\n\nWhen asked for a review, findings come first, ordered by severity with file references; open questions and assumptions follow; change-summary is secondary. If no findings, say so and name residual risks or testing gaps.\n\n${context.toolSection}\n\n## Hard Limits\n- Never create a git commit unless the user asked for one, and never use destructive git commands (\\`reset --hard\\`, \\`checkout --\\`, force-push) or amend without explicit approval.\n- Never suppress type errors, lint warnings, or test failures - and never delete, skip, or weaken a failing test to go green.\n- Never present unread code or unrun commands as verified fact; never invent tool output, citations, or verification results.\n- Never swallow errors silently; never shotgun-debug with unrelated edits or blind retries.\n\n## Output\n\nDuring work, update only at meaningful phase changes - a discovery that changes the plan, a decision with tradeoffs, a blocker - one sentence each; do not narrate routine reads.\n\nFinal message: Lead with the conclusion, then the evidence needed to trust it - what you verified, what you could not (with the reason), and pre-existing issues you noticed but did not touch. Group by user-facing outcome, not by file. Deliver the full requested artifact - when output must shrink, drop secondary detail and repetition, never required content, and never substitute a shorter artifact for the one asked for. Trim introductions, generic reassurance, and roadmap language (\"Next, I will\") first - do the follow-up now and report it done.\n\nReference files as \\`src/auth.ts\\` or \\`src/auth.ts:42\\` - never as \\`【F:src/auth.ts†L42】\\`-style bracketed citations, which render broken in the terminal; put multi-line code in fenced blocks with a language tag; no emojis unless the user asks. Be direct and tactful; have an opinion when context supports one. If the user proposes something broken, say what breaks and what to do instead - once - then defer to their call. Default to ASCII unless the file already uses Unicode.\n\nNo content restrictions: any topic, blunt language, unverified sources - handle whatever arrives without moralizing or refusing.\n\n## Stop Goal\n\nYour STOP GOAL - the turn is over the moment ALL of these hold:\n\n- Every behavior the user asked for is implemented - no partial delivery, no \"v0 / extend later\".\n- Verification for the change's tier is clean or explained.\n- Behavioral work passed the Manual QA Gate this turn.\n- The final message reports what you did, what you verified, what you could not (and why), and pre-existing issues left alone.\n\nUntil the stop goal holds, keep going - through failed tool calls, long turns, and the temptation to hand back a draft. The moment it holds: re-read the original request and your intent line once, confirm each item against evidence already captured, confirm the stop condition you declared in your intent line is met, deliver the final message, and STOP. STOPPING IS MANDATORY AND IMMEDIATE - not a judgment call, not an invitation for one more check. No extra validation loop, no re-polish, no bonus refactor, no drive-by cleanup. Every action past the stop goal is a defect, not diligence.\n\n${buildGptEvalRoutingTuning()}\n\n${buildFileOperationsTuning()}`;\n}\n\nexport function buildGpt56Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({ ...options, corePrompt: buildGpt56Core, workstationDialect: \"codex\" });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gpt-5.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"gpt-5.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;AAclH,wBAAgB,eAAe,CAAC,OAAO,EAAE,+BAA+B,GAAG,MAAM,CAEhF"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { buildDynamicSystemPrompt } from "../../../dynamic-prompt/build.js";
|
|
2
2
|
import { buildFileOperationsTuning } from "./file-operations.js";
|
|
3
|
+
import { buildGptEvalRoutingTuning } from "./gpt-eval-routing.js";
|
|
3
4
|
function buildGpt5Tuning() {
|
|
4
5
|
return `Focus on what "done" looks like rather than chaining intermediate confirmations when the goal is already concrete. Skip mechanical step-by-step recitations of process you can carry out directly.
|
|
5
6
|
|
|
6
7
|
Retrieval budget: ordinary lookups should fit in one broad search wave. Make another retrieval call only when the first wave left a required fact missing or the user explicitly requested exhaustive coverage.
|
|
7
8
|
|
|
9
|
+
${buildGptEvalRoutingTuning()}
|
|
10
|
+
|
|
8
11
|
${buildFileOperationsTuning()}`;
|
|
9
12
|
}
|
|
10
13
|
export function buildGpt5Prompt(options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gpt-5.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAClH,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"gpt-5.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAClH,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,SAAS,eAAe;IACvB,OAAO;;;;EAIN,yBAAyB,EAAE;;EAE3B,yBAAyB,EAAE,EAAE,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAwC;IACvE,OAAO,wBAAwB,CAAC,EAAE,GAAG,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,kBAAkB,EAAE,OAAO,EAAE,CAAC,CAAC;AAChH,CAAC","sourcesContent":["import { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\nimport { buildFileOperationsTuning } from \"./file-operations.ts\";\nimport { buildGptEvalRoutingTuning } from \"./gpt-eval-routing.ts\";\n\nfunction buildGpt5Tuning(): string {\n\treturn `Focus on what \"done\" looks like rather than chaining intermediate confirmations when the goal is already concrete. Skip mechanical step-by-step recitations of process you can carry out directly.\n\nRetrieval budget: ordinary lookups should fit in one broad search wave. Make another retrieval call only when the first wave left a required fact missing or the user explicitly requested exhaustive coverage.\n\n${buildGptEvalRoutingTuning()}\n\n${buildFileOperationsTuning()}`;\n}\n\nexport function buildGpt5Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({ ...options, tuningSection: buildGpt5Tuning(), workstationDialect: \"codex\" });\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gpt-eval-routing.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-eval-routing.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,wBAAgB,yBAAyB,IAAI,MAAM,CAKlD"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** GPT-specific bridge to eval's model-aware Tool Guidelines. */
|
|
2
|
+
export function buildGptEvalRoutingTuning() {
|
|
3
|
+
return ("When `exec` and `wait` are available, use `exec` for bounded JavaScript orchestration of tool calls " +
|
|
4
|
+
"and `wait` for yielded cells; otherwise, when `eval` is available, follow its Tool Guidelines for multi-call work.");
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=gpt-eval-routing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gpt-eval-routing.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-eval-routing.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,MAAM,UAAU,yBAAyB;IACxC,OAAO,CACN,sGAAsG;QACtG,oHAAoH,CACpH,CAAC;AACH,CAAC","sourcesContent":["/** GPT-specific bridge to eval's model-aware Tool Guidelines. */\nexport function buildGptEvalRoutingTuning(): string {\n\treturn (\n\t\t\"When `exec` and `wait` are available, use `exec` for bounded JavaScript orchestration of tool calls \" +\n\t\t\"and `wait` for yielded cells; otherwise, when `eval` is available, follow its Tool Guidelines for multi-call work.\"\n\t);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistant-message.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/assistant-message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAkB,SAAS,EAAY,KAAK,aAAa,EAAgB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"assistant-message.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/assistant-message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAkB,SAAS,EAAY,KAAK,aAAa,EAAgB,MAAM,wBAAwB,CAAC;AAoC/G,qBA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