@bastani/atomic 0.9.4 → 0.9.5-alpha.10
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 +136 -2
- package/README.md +2 -2
- package/dist/builtin/cursor/CHANGELOG.md +6 -0
- package/dist/builtin/cursor/package.json +3 -3
- package/dist/builtin/cursor/src/model-mapper.ts +6 -3
- package/dist/builtin/intercom/CHANGELOG.md +31 -0
- package/dist/builtin/intercom/README.md +29 -21
- package/dist/builtin/intercom/broker/broker.ts +9 -120
- package/dist/builtin/intercom/broker/client.ts +29 -54
- package/dist/builtin/intercom/broker/delivered-message-cache.ts +44 -0
- package/dist/builtin/intercom/broker/paths.ts +42 -5
- package/dist/builtin/intercom/broker/pending-send-registry.ts +142 -0
- package/dist/builtin/intercom/broker/send-handler.ts +106 -0
- package/dist/builtin/intercom/broker/send-signature.ts +37 -0
- package/dist/builtin/intercom/broker/spawn.ts +78 -10
- package/dist/builtin/intercom/config.ts +6 -3
- package/dist/builtin/intercom/contact-supervisor-tool.ts +6 -4
- package/dist/builtin/intercom/foreground-detach-handoff.ts +136 -0
- package/dist/builtin/intercom/index-heavy.ts +50 -54
- package/dist/builtin/intercom/index.ts +320 -272
- package/dist/builtin/intercom/intercom-tool.ts +9 -3
- package/dist/builtin/intercom/lazy-heavy-proxy.ts +114 -0
- package/dist/builtin/intercom/lazy-subagent-ack.ts +20 -0
- package/dist/builtin/intercom/lazy-tool-execution.ts +39 -0
- package/dist/builtin/intercom/lifecycle-lease.ts +51 -0
- package/dist/builtin/intercom/lifecycle.ts +37 -20
- package/dist/builtin/intercom/package.json +12 -6
- package/dist/builtin/intercom/reply-routing.ts +17 -0
- package/dist/builtin/intercom/result-renderers.ts +1 -1
- package/dist/builtin/intercom/subagent-relay.ts +58 -12
- package/dist/builtin/intercom/types.ts +3 -3
- package/dist/builtin/intercom/ui/compose.ts +2 -2
- package/dist/builtin/intercom/ui/inline-message.ts +2 -2
- package/dist/builtin/intercom/ui/session-list.ts +2 -2
- package/dist/builtin/mcp/CHANGELOG.md +23 -0
- package/dist/builtin/mcp/OAUTH.md +1 -0
- package/dist/builtin/mcp/README.md +10 -6
- package/dist/builtin/mcp/apps-cancellation.ts +32 -0
- package/dist/builtin/mcp/call-tool-result.ts +9 -0
- package/dist/builtin/mcp/caller-wait.ts +50 -0
- package/dist/builtin/mcp/command-registration.ts +82 -0
- package/dist/builtin/mcp/direct-tool-executor.ts +279 -0
- package/dist/builtin/mcp/direct-tools.ts +40 -255
- package/dist/builtin/mcp/host-html-template.ts +4 -2
- package/dist/builtin/mcp/index.ts +274 -239
- package/dist/builtin/mcp/init.ts +96 -126
- package/dist/builtin/mcp/mcp-auth-flow.ts +247 -237
- package/dist/builtin/mcp/mcp-callback-server.ts +89 -68
- package/dist/builtin/mcp/mcp-oauth-provider.ts +23 -1
- package/dist/builtin/mcp/metadata-hydration.ts +52 -0
- package/dist/builtin/mcp/package.json +3 -3
- package/dist/builtin/mcp/proxy-auth.ts +4 -4
- package/dist/builtin/mcp/proxy-call.ts +111 -40
- package/dist/builtin/mcp/proxy-connect.ts +35 -15
- package/dist/builtin/mcp/proxy-info-modes.ts +106 -23
- package/dist/builtin/mcp/proxy-modes.ts +3 -3
- package/dist/builtin/mcp/session-cleanup-barrier.ts +43 -0
- package/dist/builtin/mcp/startup-warmup.ts +98 -0
- package/dist/builtin/mcp/state-lease.ts +12 -0
- package/dist/builtin/mcp/tool-result-renderer.ts +3 -3
- package/dist/builtin/mcp/ui-server.ts +8 -8
- package/dist/builtin/mcp/ui-session.ts +9 -18
- package/dist/builtin/subagents/CHANGELOG.md +60 -0
- package/dist/builtin/subagents/README.md +30 -29
- package/dist/builtin/subagents/agents/code-simplifier.md +2 -2
- package/dist/builtin/subagents/agents/codebase-analyzer.md +2 -2
- package/dist/builtin/subagents/agents/codebase-locator.md +2 -2
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +2 -2
- package/dist/builtin/subagents/agents/codebase-pattern-finder.md +2 -2
- package/dist/builtin/subagents/agents/codebase-research-analyzer.md +2 -2
- package/dist/builtin/subagents/agents/codebase-research-locator.md +2 -2
- package/dist/builtin/subagents/agents/debugger.md +2 -2
- package/dist/builtin/subagents/agents/worker.md +2 -2
- package/dist/builtin/subagents/package.json +5 -5
- package/dist/builtin/subagents/prompts/review-loop.md +1 -1
- package/dist/builtin/subagents/skills/subagent/SKILL.md +37 -36
- package/dist/builtin/subagents/src/extension/api-lifecycle.ts +64 -0
- package/dist/builtin/subagents/src/extension/fanout-child.ts +44 -51
- package/dist/builtin/subagents/src/extension/index.ts +289 -320
- package/dist/builtin/subagents/src/extension/prompt-guidance.ts +7 -10
- package/dist/builtin/subagents/src/extension/schemas.ts +22 -5
- package/dist/builtin/subagents/src/extension/startup-maintenance.ts +89 -0
- package/dist/builtin/subagents/src/extension/tool-description.ts +29 -0
- package/dist/builtin/subagents/src/intercom/intercom-bridge.ts +13 -2
- package/dist/builtin/subagents/src/intercom/result-intercom.ts +4 -4
- package/dist/builtin/subagents/src/runs/background/async-event-journal.ts +106 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-common.ts +26 -20
- package/dist/builtin/subagents/src/runs/background/async-execution-single.ts +13 -2
- package/dist/builtin/subagents/src/runs/background/async-execution-types.ts +3 -0
- package/dist/builtin/subagents/src/runs/background/async-job-tracker.ts +1 -1
- package/dist/builtin/subagents/src/runs/background/completion-claims.ts +189 -0
- package/dist/builtin/subagents/src/runs/background/completion-dedupe.ts +44 -7
- package/dist/builtin/subagents/src/runs/background/completion-notification.ts +34 -0
- package/dist/builtin/subagents/src/runs/background/notify.ts +72 -22
- package/dist/builtin/subagents/src/runs/background/result-delivery-processor.ts +232 -0
- package/dist/builtin/subagents/src/runs/background/result-file-claims.ts +151 -0
- package/dist/builtin/subagents/src/runs/background/result-quarantine.ts +72 -0
- package/dist/builtin/subagents/src/runs/background/result-retry-scheduler.ts +48 -0
- package/dist/builtin/subagents/src/runs/background/result-status.ts +81 -0
- package/dist/builtin/subagents/src/runs/background/result-watcher-data.ts +59 -0
- package/dist/builtin/subagents/src/runs/background/result-watcher.ts +177 -233
- package/dist/builtin/subagents/src/runs/background/run-id-resolver.ts +3 -2
- package/dist/builtin/subagents/src/runs/background/stale-run-reconciler.ts +73 -14
- package/dist/builtin/subagents/src/runs/background/subagent-runner-streaming.ts +29 -15
- package/dist/builtin/subagents/src/runs/background/top-level-async.ts +1 -2
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-dynamic-step.ts +1 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-runner.ts +1 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-step.ts +1 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-sequential-step.ts +7 -9
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-types.ts +3 -13
- package/dist/builtin/subagents/src/runs/foreground/chain-execution.ts +2 -15
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt-finalize.ts +2 -2
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt.ts +63 -46
- package/dist/builtin/subagents/src/runs/foreground/execution-detach-reservations.ts +48 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-detach-route.ts +17 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-run-sync.ts +39 -26
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-async.ts +3 -1
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-chain.ts +3 -51
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-context.ts +6 -11
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-input.ts +11 -2
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +5 -112
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-resume.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +68 -118
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-status.ts +79 -7
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts +2 -2
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +3 -0
- package/dist/builtin/subagents/src/runs/shared/pi-args.ts +2 -2
- package/dist/builtin/subagents/src/runs/shared/pi-spawn.ts +55 -12
- package/dist/builtin/subagents/src/shared/artifacts.ts +22 -11
- package/dist/builtin/subagents/src/shared/event-jsonl-writer.ts +294 -0
- package/dist/builtin/subagents/src/shared/exclusive-file-publication.ts +44 -0
- package/dist/builtin/subagents/src/shared/jsonl-writer.ts +1 -0
- package/dist/builtin/subagents/src/shared/model-info.ts +2 -2
- package/dist/builtin/subagents/src/shared/settings.ts +20 -10
- package/dist/builtin/subagents/src/shared/types-async.ts +3 -1
- package/dist/builtin/subagents/src/shared/types-config.ts +2 -0
- package/dist/builtin/subagents/src/shared/types-runtime.ts +3 -2
- package/dist/builtin/subagents/src/slash/slash-commands.ts +9 -12
- package/dist/builtin/subagents/src/slash/slash-live-state.ts +63 -32
- package/dist/builtin/subagents/src/tui/render-event-formatting.ts +15 -48
- package/dist/builtin/subagents/src/tui/render-layout.ts +9 -0
- package/dist/builtin/subagents/src/tui/render-result.ts +7 -0
- package/dist/builtin/subagents/src/tui/render-stable-output.ts +1 -0
- package/dist/builtin/subagents/src/tui/render-widget-graph.ts +27 -25
- package/dist/builtin/subagents/src/tui/render-widget.ts +177 -132
- package/dist/builtin/subagents/src/tui/render.ts +1 -1
- package/dist/builtin/web-access/CHANGELOG.md +14 -0
- package/dist/builtin/web-access/README.md +4 -0
- package/dist/builtin/web-access/content-tools.ts +8 -3
- package/dist/builtin/web-access/index-heavy.ts +1 -1
- package/dist/builtin/web-access/index.ts +190 -46
- package/dist/builtin/web-access/lifecycle-lease.ts +38 -0
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/web-access/result-renderers.ts +1 -1
- package/dist/builtin/web-access/summary-review.ts +1 -1
- package/dist/builtin/web-access/web-search-activity.ts +1 -1
- package/dist/builtin/web-access/web-search-return.ts +7 -0
- package/dist/builtin/web-access/web-search-summary.ts +1 -1
- package/dist/builtin/web-access/web-search-tool.ts +4 -2
- package/dist/builtin/workflows/CHANGELOG.md +98 -0
- package/dist/builtin/workflows/README.md +20 -16
- package/dist/builtin/workflows/builtin/deep-research-codebase-utils.ts +33 -9
- package/dist/builtin/workflows/builtin/goal-artifacts.ts +3 -1
- package/dist/builtin/workflows/builtin/goal-ledger.ts +3 -0
- package/dist/builtin/workflows/builtin/goal-prompts.ts +39 -5
- package/dist/builtin/workflows/builtin/goal-reducer.ts +21 -0
- package/dist/builtin/workflows/builtin/goal-reports.ts +23 -0
- package/dist/builtin/workflows/builtin/goal-review.ts +85 -6
- package/dist/builtin/workflows/builtin/goal-runner.ts +122 -49
- package/dist/builtin/workflows/builtin/goal-schemas.ts +22 -0
- package/dist/builtin/workflows/builtin/goal-types.ts +25 -1
- package/dist/builtin/workflows/builtin/goal.d.ts +5 -0
- package/dist/builtin/workflows/builtin/goal.ts +13 -2
- package/dist/builtin/workflows/builtin/index.d.ts +8 -0
- package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +16 -5
- package/dist/builtin/workflows/builtin/ralph-core.ts +100 -15
- package/dist/builtin/workflows/builtin/ralph-models.ts +98 -66
- package/dist/builtin/workflows/builtin/ralph-review-gate.ts +37 -5
- package/dist/builtin/workflows/builtin/ralph-reviewer-prompt.ts +159 -0
- package/dist/builtin/workflows/builtin/ralph-runner.ts +75 -165
- package/dist/builtin/workflows/builtin/ralph.d.ts +3 -0
- package/dist/builtin/workflows/builtin/ralph.ts +4 -1
- package/dist/builtin/workflows/builtin/review-convergence.ts +111 -0
- package/dist/builtin/workflows/builtin/shared-prompts.ts +20 -1
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/skills/create-spec/SKILL.md +2 -0
- package/dist/builtin/workflows/skills/impeccable/SKILL.md +16 -13
- package/dist/builtin/workflows/skills/impeccable/reference/adapt.md +1 -0
- package/dist/builtin/workflows/skills/impeccable/reference/adapt.native.md +58 -0
- package/dist/builtin/workflows/skills/impeccable/reference/android.md +40 -0
- package/dist/builtin/workflows/skills/impeccable/reference/animate.md +2 -0
- package/dist/builtin/workflows/skills/impeccable/reference/audit.md +2 -0
- package/dist/builtin/workflows/skills/impeccable/reference/audit.native.md +139 -0
- package/dist/builtin/workflows/skills/impeccable/reference/bolder.md +69 -62
- package/dist/builtin/workflows/skills/impeccable/reference/critique.md +21 -7
- package/dist/builtin/workflows/skills/impeccable/reference/document.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +92 -0
- package/dist/builtin/workflows/skills/impeccable/reference/init.md +29 -7
- package/dist/builtin/workflows/skills/impeccable/reference/ios.md +45 -0
- package/dist/builtin/workflows/skills/impeccable/reference/layout.md +25 -1
- package/dist/builtin/workflows/skills/impeccable/reference/typeset.md +23 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/context-signals.mjs +2 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/context.mjs +75 -14
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/browser/injected/index.mjs +1 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/cli/main.mjs +31 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/design-system.mjs +64 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +118 -11
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +16 -11
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/registry/antipatterns.mjs +66 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/rules/checks.mjs +42 -10
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/fonts.mjs +30 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/page.mjs +4 -6
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-admin.mjs +660 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-before-edit.mjs +516 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-lib.mjs +1764 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/hook.mjs +61 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-config.mjs +4 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/is-generated.mjs +2 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/live/svelte-component.mjs +13 -16
- package/dist/builtin/workflows/skills/impeccable/scripts/live-accept.mjs +17 -11
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +104 -37
- package/dist/builtin/workflows/skills/impeccable/scripts/live-wrap.mjs +9 -0
- package/dist/builtin/workflows/src/durable/backend.ts +12 -0
- package/dist/builtin/workflows/src/durable/child-primitive.ts +12 -8
- package/dist/builtin/workflows/src/durable/dbos-backend.ts +63 -2
- package/dist/builtin/workflows/src/durable/dbos-envelope.ts +28 -0
- package/dist/builtin/workflows/src/durable/resume-catalog.ts +12 -0
- package/dist/builtin/workflows/src/durable/resume-runtime.ts +5 -2
- package/dist/builtin/workflows/src/durable/stage-primitive.ts +167 -28
- package/dist/builtin/workflows/src/durable/types.ts +30 -1
- package/dist/builtin/workflows/src/engine/primitives/task.ts +3 -1
- package/dist/builtin/workflows/src/engine/run-durable-finalize.ts +1 -2
- package/dist/builtin/workflows/src/engine/run-returned-status.ts +50 -16
- package/dist/builtin/workflows/src/engine/run.ts +32 -32
- package/dist/builtin/workflows/src/engine/runtime.ts +5 -0
- package/dist/builtin/workflows/src/extension/extension-factory.ts +3 -0
- package/dist/builtin/workflows/src/extension/extension-lifecycle.ts +9 -2
- package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +137 -27
- package/dist/builtin/workflows/src/extension/lifecycle-notifications.ts +22 -6
- package/dist/builtin/workflows/src/extension/public-types.ts +1 -1
- package/dist/builtin/workflows/src/extension/workflow-command-completions.ts +13 -1
- package/dist/builtin/workflows/src/extension/workflow-command-registration.ts +19 -4
- package/dist/builtin/workflows/src/extension/workflow-command-surfaces.ts +9 -0
- package/dist/builtin/workflows/src/extension/workflow-prompts.ts +17 -17
- package/dist/builtin/workflows/src/extension/workflow-run-control-command.ts +48 -23
- package/dist/builtin/workflows/src/extension/workflow-schema.ts +15 -2
- package/dist/builtin/workflows/src/extension/workflow-tool-control.ts +20 -8
- package/dist/builtin/workflows/src/extension/workflow-tool.ts +24 -8
- package/dist/builtin/workflows/src/runs/background/status.ts +4 -3
- package/dist/builtin/workflows/src/runs/foreground/executor-continuation.ts +13 -3
- package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +29 -8
- package/dist/builtin/workflows/src/runs/foreground/executor-hil.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-control.ts +8 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +4 -3
- package/dist/builtin/workflows/src/runs/foreground/stage-control-registry.ts +2 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +18 -19
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-unresolved-overflow.ts +38 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-tool-execution-buffer.ts +47 -0
- package/dist/builtin/workflows/src/runs/shared/model-fallback-candidates.ts +1 -1
- package/dist/builtin/workflows/src/runs/shared/worktree-git.ts +155 -20
- package/dist/builtin/workflows/src/runs/shared/worktree-types.ts +6 -0
- package/dist/builtin/workflows/src/runs/shared/worktree.ts +2 -1
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +2 -2
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.ts +2 -2
- package/dist/builtin/workflows/src/shared/persistence-restore-helpers.ts +18 -1
- package/dist/builtin/workflows/src/shared/persistence-restore.ts +23 -5
- package/dist/builtin/workflows/src/shared/persistence-session-entries.ts +4 -0
- package/dist/builtin/workflows/src/shared/resume-continuation.ts +2 -0
- package/dist/builtin/workflows/src/shared/returned-run-status.ts +116 -0
- package/dist/builtin/workflows/src/shared/workflow-failures-decisions.ts +2 -0
- package/dist/builtin/workflows/src/tui/graph-view-render-helpers.ts +21 -3
- package/dist/builtin/workflows/src/tui/graph-view-state.ts +3 -0
- package/dist/builtin/workflows/src/tui/graph-view-types.ts +3 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-archive-history.ts +1 -23
- package/dist/builtin/workflows/src/tui/stage-chat-view-footer-status.ts +54 -9
- package/dist/builtin/workflows/src/tui/stage-chat-view-pending-tools.ts +9 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-render-settings.ts +27 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-state.ts +5 -6
- package/dist/builtin/workflows/src/tui/stage-chat-view.ts +5 -2
- package/dist/builtin/workflows/src/tui/status-list.ts +22 -15
- package/dist/builtin/workflows/src/tui/workflow-attach-pane.ts +4 -4
- package/dist/bun/internal-intercom-broker.d.ts +6 -0
- package/dist/bun/internal-intercom-broker.d.ts.map +1 -0
- package/dist/bun/internal-intercom-broker.js +39 -0
- package/dist/bun/internal-intercom-broker.js.map +1 -0
- package/dist/bun/split-loader.d.ts +2 -0
- package/dist/bun/split-loader.d.ts.map +1 -0
- package/dist/bun/split-loader.js +50 -0
- package/dist/bun/split-loader.js.map +1 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +2 -2
- package/dist/cli/args.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +6 -4
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts +26 -6
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +178 -19
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +25 -4
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +12 -2
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +1 -1
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +1 -1
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +13 -4
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-models.d.ts +2 -2
- package/dist/core/agent-session-models.d.ts.map +1 -1
- package/dist/core/agent-session-models.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +2 -1
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts +2 -0
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +152 -4
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +4 -2
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +15 -1
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +6 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +6 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/anthropic-thinking-guard.d.ts +5 -5
- package/dist/core/anthropic-thinking-guard.d.ts.map +1 -1
- package/dist/core/anthropic-thinking-guard.js +42 -32
- package/dist/core/anthropic-thinking-guard.js.map +1 -1
- package/dist/core/atomic-guide-command.d.ts.map +1 -1
- package/dist/core/atomic-guide-command.js +15 -15
- package/dist/core/atomic-guide-command.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +14 -9
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/builtin-packages.d.ts.map +1 -1
- package/dist/core/builtin-packages.js +8 -4
- package/dist/core/builtin-packages.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +2 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +79 -46
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/context-assistant-turns.d.ts +42 -0
- package/dist/core/compaction/context-assistant-turns.d.ts.map +1 -0
- package/dist/core/compaction/context-assistant-turns.js +87 -0
- package/dist/core/compaction/context-assistant-turns.js.map +1 -0
- package/dist/core/compaction/context-compaction-critical.d.ts +15 -0
- package/dist/core/compaction/context-compaction-critical.d.ts.map +1 -0
- package/dist/core/compaction/context-compaction-critical.js +57 -0
- package/dist/core/compaction/context-compaction-critical.js.map +1 -0
- package/dist/core/compaction/context-compaction-eviction-alternates.d.ts +18 -0
- package/dist/core/compaction/context-compaction-eviction-alternates.d.ts.map +1 -0
- package/dist/core/compaction/context-compaction-eviction-alternates.js +186 -0
- package/dist/core/compaction/context-compaction-eviction-alternates.js.map +1 -0
- package/dist/core/compaction/context-compaction-eviction.d.ts +12 -0
- package/dist/core/compaction/context-compaction-eviction.d.ts.map +1 -0
- package/dist/core/compaction/context-compaction-eviction.js +222 -0
- package/dist/core/compaction/context-compaction-eviction.js.map +1 -0
- package/dist/core/compaction/context-compaction-prompt.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-prompt.js +1 -1
- package/dist/core/compaction/context-compaction-prompt.js.map +1 -1
- package/dist/core/compaction/context-compaction-runner.d.ts +7 -1
- package/dist/core/compaction/context-compaction-runner.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-runner.js +113 -21
- package/dist/core/compaction/context-compaction-runner.js.map +1 -1
- package/dist/core/compaction/context-compaction-types.d.ts +2 -0
- package/dist/core/compaction/context-compaction-types.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-types.js.map +1 -1
- package/dist/core/compaction/context-deletion-application.d.ts +5 -4
- package/dist/core/compaction/context-deletion-application.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-application.js +17 -15
- package/dist/core/compaction/context-deletion-application.js.map +1 -1
- package/dist/core/compaction/context-deletion-store.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-store.js +1 -1
- package/dist/core/compaction/context-deletion-store.js.map +1 -1
- package/dist/core/compaction/context-deletion-targets.d.ts +2 -1
- package/dist/core/compaction/context-deletion-targets.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-targets.js +36 -31
- package/dist/core/compaction/context-deletion-targets.js.map +1 -1
- package/dist/core/compaction/context-deletion-tool-helpers.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-tool-helpers.js +116 -43
- package/dist/core/compaction/context-deletion-tool-helpers.js.map +1 -1
- package/dist/core/compaction/context-transcript-analysis.d.ts +4 -2
- package/dist/core/compaction/context-transcript-analysis.d.ts.map +1 -1
- package/dist/core/compaction/context-transcript-analysis.js +36 -40
- package/dist/core/compaction/context-transcript-analysis.js.map +1 -1
- package/dist/core/copilot-anthropic-sse-repair.d.ts +23 -0
- package/dist/core/copilot-anthropic-sse-repair.d.ts.map +1 -0
- package/dist/core/copilot-anthropic-sse-repair.js +340 -0
- package/dist/core/copilot-anthropic-sse-repair.js.map +1 -0
- package/dist/core/copilot-gemini-reasoning.d.ts +16 -8
- package/dist/core/copilot-gemini-reasoning.d.ts.map +1 -1
- package/dist/core/copilot-gemini-reasoning.js +27 -22
- package/dist/core/copilot-gemini-reasoning.js.map +1 -1
- package/dist/core/copilot-hosts.d.ts +12 -0
- package/dist/core/copilot-hosts.d.ts.map +1 -0
- package/dist/core/copilot-hosts.js +33 -0
- package/dist/core/copilot-hosts.js.map +1 -0
- package/dist/core/copilot-model-catalog.d.ts.map +1 -1
- package/dist/core/copilot-model-catalog.js +3 -2
- package/dist/core/copilot-model-catalog.js.map +1 -1
- package/dist/core/copilot-model-synthesis.d.ts.map +1 -1
- package/dist/core/copilot-model-synthesis.js +3 -1
- package/dist/core/copilot-model-synthesis.js.map +1 -1
- package/dist/core/extensions/agent-events.d.ts +1 -1
- package/dist/core/extensions/agent-events.d.ts.map +1 -1
- package/dist/core/extensions/agent-events.js.map +1 -1
- package/dist/core/extensions/loader-core.d.ts.map +1 -1
- package/dist/core/extensions/loader-core.js +6 -0
- package/dist/core/extensions/loader-core.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts +8 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +10 -4
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/provider-types.d.ts +2 -7
- package/dist/core/extensions/provider-types.d.ts.map +1 -1
- package/dist/core/extensions/provider-types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +6 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +72 -29
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +5 -5
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/messages.d.ts +9 -0
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +100 -18
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-registry-builtins.d.ts.map +1 -1
- package/dist/core/model-registry-builtins.js +5 -0
- package/dist/core/model-registry-builtins.js.map +1 -1
- package/dist/core/model-registry-custom-loader.d.ts.map +1 -1
- package/dist/core/model-registry-custom-loader.js +49 -8
- package/dist/core/model-registry-custom-loader.js.map +1 -1
- package/dist/core/model-registry-dynamic.d.ts.map +1 -1
- package/dist/core/model-registry-dynamic.js +11 -5
- package/dist/core/model-registry-dynamic.js.map +1 -1
- package/dist/core/model-registry-loader.d.ts.map +1 -1
- package/dist/core/model-registry-loader.js +8 -0
- package/dist/core/model-registry-loader.js.map +1 -1
- package/dist/core/model-registry-schemas.d.ts +93 -8
- package/dist/core/model-registry-schemas.d.ts.map +1 -1
- package/dist/core/model-registry-schemas.js +24 -12
- package/dist/core/model-registry-schemas.js.map +1 -1
- package/dist/core/model-registry-types.d.ts +7 -6
- package/dist/core/model-registry-types.d.ts.map +1 -1
- package/dist/core/model-registry-types.js.map +1 -1
- package/dist/core/model-registry.d.ts +5 -0
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +23 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver-cli.d.ts.map +1 -1
- package/dist/core/model-resolver-cli.js +33 -5
- package/dist/core/model-resolver-cli.js.map +1 -1
- package/dist/core/model-resolver-initial.d.ts +6 -1
- package/dist/core/model-resolver-initial.d.ts.map +1 -1
- package/dist/core/model-resolver-initial.js +12 -7
- package/dist/core/model-resolver-initial.js.map +1 -1
- package/dist/core/model-resolver-scope.d.ts +9 -0
- package/dist/core/model-resolver-scope.d.ts.map +1 -1
- package/dist/core/model-resolver-scope.js +12 -4
- package/dist/core/model-resolver-scope.js.map +1 -1
- package/dist/core/model-resolver.d.ts +4 -3
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +2 -2
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/openai-responses-payload-sanitizer.d.ts +7 -0
- package/dist/core/openai-responses-payload-sanitizer.d.ts.map +1 -0
- package/dist/core/openai-responses-payload-sanitizer.js +74 -0
- package/dist/core/openai-responses-payload-sanitizer.js.map +1 -0
- package/dist/core/package-manager-auto-resources.d.ts +2 -2
- package/dist/core/package-manager-auto-resources.d.ts.map +1 -1
- package/dist/core/package-manager-auto-resources.js +32 -52
- package/dist/core/package-manager-auto-resources.js.map +1 -1
- package/dist/core/package-manager-resolver.d.ts.map +1 -1
- package/dist/core/package-manager-resolver.js +23 -14
- package/dist/core/package-manager-resolver.js.map +1 -1
- package/dist/core/package-manager-resource-collector.d.ts +3 -3
- package/dist/core/package-manager-resource-collector.d.ts.map +1 -1
- package/dist/core/package-manager-resource-collector.js +76 -73
- package/dist/core/package-manager-resource-collector.js.map +1 -1
- package/dist/core/package-manager-resource-files.d.ts +9 -8
- package/dist/core/package-manager-resource-files.d.ts.map +1 -1
- package/dist/core/package-manager-resource-files.js +92 -81
- package/dist/core/package-manager-resource-files.js.map +1 -1
- package/dist/core/prompt-templates-async.d.ts +3 -0
- package/dist/core/prompt-templates-async.d.ts.map +1 -0
- package/dist/core/prompt-templates-async.js +118 -0
- package/dist/core/prompt-templates-async.js.map +1 -0
- package/dist/core/provider-context-usage.d.ts +11 -0
- package/dist/core/provider-context-usage.d.ts.map +1 -0
- package/dist/core/provider-context-usage.js +58 -0
- package/dist/core/provider-context-usage.js.map +1 -0
- package/dist/core/resource-loader-assets.d.ts +3 -3
- package/dist/core/resource-loader-assets.d.ts.map +1 -1
- package/dist/core/resource-loader-assets.js +66 -83
- package/dist/core/resource-loader-assets.js.map +1 -1
- package/dist/core/resource-loader-context-files.d.ts +1 -0
- package/dist/core/resource-loader-context-files.d.ts.map +1 -1
- package/dist/core/resource-loader-context-files.js +13 -10
- package/dist/core/resource-loader-context-files.js.map +1 -1
- package/dist/core/resource-loader-core.d.ts +1 -1
- package/dist/core/resource-loader-core.d.ts.map +1 -1
- package/dist/core/resource-loader-core.js +5 -5
- package/dist/core/resource-loader-core.js.map +1 -1
- package/dist/core/resource-loader-extensions.d.ts.map +1 -1
- package/dist/core/resource-loader-extensions.js +4 -0
- package/dist/core/resource-loader-extensions.js.map +1 -1
- package/dist/core/resource-loader-reload.d.ts.map +1 -1
- package/dist/core/resource-loader-reload.js +54 -7
- package/dist/core/resource-loader-reload.js.map +1 -1
- package/dist/core/resource-loader-types.d.ts +7 -1
- package/dist/core/resource-loader-types.d.ts.map +1 -1
- package/dist/core/resource-loader-types.js.map +1 -1
- package/dist/core/sdk-types.d.ts +2 -0
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +9 -6
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-entry-normalization.d.ts +7 -0
- package/dist/core/session-entry-normalization.d.ts.map +1 -0
- package/dist/core/session-entry-normalization.js +14 -0
- package/dist/core/session-entry-normalization.js.map +1 -0
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +1 -0
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-history.d.ts +2 -2
- package/dist/core/session-manager-history.d.ts.map +1 -1
- package/dist/core/session-manager-history.js +127 -108
- package/dist/core/session-manager-history.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts +3 -2
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js +6 -0
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-manager-core.d.ts.map +1 -1
- package/dist/core/settings-manager-core.js +3 -2
- package/dist/core/settings-manager-core.js.map +1 -1
- package/dist/core/settings-storage.d.ts.map +1 -1
- package/dist/core/settings-storage.js +2 -1
- package/dist/core/settings-storage.js.map +1 -1
- package/dist/core/settings-types.d.ts +2 -1
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/skills-async.d.ts +3 -0
- package/dist/core/skills-async.d.ts.map +1 -0
- package/dist/core/skills-async.js +269 -0
- package/dist/core/skills-async.js.map +1 -0
- package/dist/core/slash-commands.d.ts +2 -0
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +141 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +11 -8
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/trust-manager.d.ts +9 -0
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +44 -2
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/index-extensions.d.ts +1 -1
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/main-deferred-startup.d.ts +33 -0
- package/dist/main-deferred-startup.d.ts.map +1 -0
- package/dist/main-deferred-startup.js +44 -0
- package/dist/main-deferred-startup.js.map +1 -0
- package/dist/main-early-input.d.ts +41 -0
- package/dist/main-early-input.d.ts.map +1 -0
- package/dist/main-early-input.js +154 -0
- package/dist/main-early-input.js.map +1 -0
- package/dist/main-session.d.ts.map +1 -1
- package/dist/main-session.js +1 -0
- package/dist/main-session.js.map +1 -1
- package/dist/main.d.ts +0 -6
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +47 -39
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.js +0 -1
- package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.js +15 -0
- package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-options.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-options.js +3 -1
- package/dist/modes/interactive/components/settings-selector-options.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +2 -1
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +37 -2
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-login.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-auth-login.js +0 -1
- package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +21 -9
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-child-ordering.d.ts +7 -0
- package/dist/modes/interactive/interactive-child-ordering.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-child-ordering.js +26 -0
- package/dist/modes/interactive/interactive-child-ordering.js.map +1 -0
- package/dist/modes/interactive/interactive-deferred-startup.d.ts +8 -1
- package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.js +86 -26
- package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-editor-actions.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-editor-actions.js +13 -13
- package/dist/modes/interactive/interactive-editor-actions.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +16 -0
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-hotkeys-debug.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-hotkeys-debug.js +4 -3
- package/dist/modes/interactive/interactive-hotkeys-debug.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +360 -230
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +19 -4
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +46 -4
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +3 -3
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js +3 -3
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +27 -17
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-types.d.ts +8 -1
- package/dist/modes/interactive/interactive-mode-types.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-types.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +14 -10
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-onboarding.d.ts +0 -9
- package/dist/modes/interactive/interactive-onboarding.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-onboarding.js +24 -201
- package/dist/modes/interactive/interactive-onboarding.js.map +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.js +43 -9
- package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +93 -10
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-resource-disclosure.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-resource-disclosure.js +3 -2
- package/dist/modes/interactive/interactive-resource-disclosure.js.map +1 -1
- package/dist/modes/interactive/interactive-resource-rendering.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-resource-rendering.js +10 -8
- package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +9 -5
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.js +1 -1
- package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +102 -98
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/theme/global-theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/global-theme.js +26 -2
- package/dist/modes/interactive/theme/global-theme.js.map +1 -1
- package/dist/modes/interactive/theme/theme-class.d.ts +1 -1
- package/dist/modes/interactive/theme/theme-class.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-class.js +2 -0
- package/dist/modes/interactive/theme/theme-class.js.map +1 -1
- package/dist/modes/interactive/theme/theme-loading.d.ts +1 -0
- package/dist/modes/interactive/theme/theme-loading.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-loading.js +3 -0
- package/dist/modes/interactive/theme/theme-loading.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +1 -1
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/utils/child-process.d.ts +8 -1
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js +39 -6
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +3 -0
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/event-loop.d.ts +7 -0
- package/dist/utils/event-loop.d.ts.map +1 -0
- package/dist/utils/event-loop.js +14 -0
- package/dist/utils/event-loop.js.map +1 -0
- package/dist/utils/fs-watch.d.ts +24 -1
- package/dist/utils/fs-watch.d.ts.map +1 -1
- package/dist/utils/fs-watch.js +60 -5
- package/dist/utils/fs-watch.js.map +1 -1
- package/dist/utils/json.d.ts +4 -0
- package/dist/utils/json.d.ts.map +1 -1
- package/dist/utils/json.js +8 -0
- package/dist/utils/json.js.map +1 -1
- package/dist/utils/module-require.d.ts +11 -0
- package/dist/utils/module-require.d.ts.map +1 -1
- package/dist/utils/module-require.js +14 -1
- package/dist/utils/module-require.js.map +1 -1
- package/dist/utils/split-launcher.d.ts +38 -0
- package/dist/utils/split-launcher.d.ts.map +1 -0
- package/dist/utils/split-launcher.js +63 -0
- package/dist/utils/split-launcher.js.map +1 -0
- package/docs/changelog.mdx +19 -0
- package/docs/compaction.md +100 -64
- package/docs/custom-provider.md +18 -5
- package/docs/development.md +4 -0
- package/docs/extensions.md +11 -2
- package/docs/json.md +3 -1
- package/docs/keybindings.md +2 -2
- package/docs/models.md +69 -10
- package/docs/providers.md +3 -2
- package/docs/quickstart.md +15 -11
- package/docs/rpc.md +5 -3
- package/docs/sdk.md +1 -1
- package/docs/settings.md +33 -3
- package/docs/subagents.md +40 -5
- package/docs/terminal-setup.md +4 -0
- package/docs/tools.md +1 -1
- package/docs/usage.md +8 -6
- package/docs/windows.md +4 -0
- package/docs/workflows.md +59 -36
- package/examples/extensions/preset.ts +2 -2
- package/examples/extensions/subagent/README.md +2 -2
- package/examples/extensions/subagent/index.ts +1 -2
- package/examples/extensions/subagent/schemas.ts +4 -1
- package/examples/sdk/12-full-control.ts +1 -1
- package/npm-shrinkwrap.json +538 -51
- package/package.json +10 -9
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-behavior.ts +0 -75
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-component.ts +0 -202
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-edit.ts +0 -97
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-editor.ts +0 -160
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-frame.ts +0 -72
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-render-modes.ts +0 -161
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-render-selectors.ts +0 -203
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-selectors.ts +0 -234
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-state.ts +0 -103
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-types.ts +0 -29
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify.ts +0 -9
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-clarify.ts +0 -117
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Narrow repair for GitHub Copilot Anthropic Messages SSE streams that carry a
|
|
3
|
+
* complete Anthropic turn but omit the required terminal `message_stop` event.
|
|
4
|
+
*
|
|
5
|
+
* The wrapper is deliberately conservative: it is only installed for Copilot
|
|
6
|
+
* `/v1/messages` event streams, passes original SSE frames through unchanged,
|
|
7
|
+
* and appends/inserts a single synthetic `message_stop` only after observing the
|
|
8
|
+
* same terminal evidence Anthropic's parser requires for a complete message.
|
|
9
|
+
*/
|
|
10
|
+
import { isCopilotApiHost } from "./copilot-hosts.js";
|
|
11
|
+
export const COPILOT_ANTHROPIC_SYNTHETIC_MESSAGE_STOP_EVENT = 'event: message_stop\ndata: {"type":"message_stop"}\n\n';
|
|
12
|
+
const COPILOT_ANTHROPIC_MESSAGES_PATH = "/v1/messages";
|
|
13
|
+
const KNOWN_ANTHROPIC_SSE_EVENT_NAMES = new Set([
|
|
14
|
+
"message_start",
|
|
15
|
+
"content_block_start",
|
|
16
|
+
"content_block_delta",
|
|
17
|
+
"content_block_stop",
|
|
18
|
+
"message_delta",
|
|
19
|
+
"message_stop",
|
|
20
|
+
"ping",
|
|
21
|
+
"error",
|
|
22
|
+
]);
|
|
23
|
+
function createRepairState() {
|
|
24
|
+
return {
|
|
25
|
+
sawMessageStart: false,
|
|
26
|
+
sawMessageStop: false,
|
|
27
|
+
sawTerminalStopReason: false,
|
|
28
|
+
sawErrorEvent: false,
|
|
29
|
+
malformedOrUncertain: false,
|
|
30
|
+
sawDoneSentinel: false,
|
|
31
|
+
insertedSyntheticStop: false,
|
|
32
|
+
openContentBlockIndexes: new Set(),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function isPlainObject(value) {
|
|
36
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
37
|
+
}
|
|
38
|
+
function isNonNegativeInteger(value) {
|
|
39
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
40
|
+
}
|
|
41
|
+
function markMalformed(state) {
|
|
42
|
+
state.malformedOrUncertain = true;
|
|
43
|
+
}
|
|
44
|
+
function shouldSynthesizeMessageStop(state) {
|
|
45
|
+
return (state.sawMessageStart &&
|
|
46
|
+
!state.sawMessageStop &&
|
|
47
|
+
state.sawTerminalStopReason &&
|
|
48
|
+
!state.sawErrorEvent &&
|
|
49
|
+
!state.malformedOrUncertain &&
|
|
50
|
+
!state.sawDoneSentinel &&
|
|
51
|
+
!state.insertedSyntheticStop &&
|
|
52
|
+
state.openContentBlockIndexes.size === 0);
|
|
53
|
+
}
|
|
54
|
+
function findSseEventBoundary(buffer) {
|
|
55
|
+
const candidates = ["\r\n\r\n", "\n\n", "\r\r"];
|
|
56
|
+
let bestIndex = -1;
|
|
57
|
+
let bestLength = 0;
|
|
58
|
+
for (const candidate of candidates) {
|
|
59
|
+
const index = buffer.indexOf(candidate);
|
|
60
|
+
if (index === -1)
|
|
61
|
+
continue;
|
|
62
|
+
if (bestIndex === -1 || index < bestIndex) {
|
|
63
|
+
bestIndex = index;
|
|
64
|
+
bestLength = candidate.length;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return bestIndex === -1 ? -1 : bestIndex + bestLength;
|
|
68
|
+
}
|
|
69
|
+
function stripEventSeparator(frame) {
|
|
70
|
+
if (frame.endsWith("\r\n\r\n"))
|
|
71
|
+
return frame.slice(0, -4);
|
|
72
|
+
if (frame.endsWith("\n\n"))
|
|
73
|
+
return frame.slice(0, -2);
|
|
74
|
+
if (frame.endsWith("\r\r"))
|
|
75
|
+
return frame.slice(0, -2);
|
|
76
|
+
return frame;
|
|
77
|
+
}
|
|
78
|
+
function missingFinalFrameSeparator(frame) {
|
|
79
|
+
if (frame.endsWith("\r\n"))
|
|
80
|
+
return "\r\n";
|
|
81
|
+
if (frame.endsWith("\n"))
|
|
82
|
+
return "\n";
|
|
83
|
+
if (frame.endsWith("\r"))
|
|
84
|
+
return "\r";
|
|
85
|
+
return "\n\n";
|
|
86
|
+
}
|
|
87
|
+
function hasKnownAnthropicEventName(eventName) {
|
|
88
|
+
return eventName !== undefined && KNOWN_ANTHROPIC_SSE_EVENT_NAMES.has(eventName);
|
|
89
|
+
}
|
|
90
|
+
function canObserveOpenMessageLifecycle(state) {
|
|
91
|
+
if (!state.sawMessageStart || state.sawMessageStop || state.sawTerminalStopReason) {
|
|
92
|
+
markMalformed(state);
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
function observeContentBlockStart(payload, state) {
|
|
98
|
+
if (!canObserveOpenMessageLifecycle(state))
|
|
99
|
+
return;
|
|
100
|
+
const index = payload.index;
|
|
101
|
+
if (!isNonNegativeInteger(index) || state.openContentBlockIndexes.has(index)) {
|
|
102
|
+
markMalformed(state);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
state.openContentBlockIndexes.add(index);
|
|
106
|
+
}
|
|
107
|
+
function observeContentBlockDelta(payload, state) {
|
|
108
|
+
if (!canObserveOpenMessageLifecycle(state))
|
|
109
|
+
return;
|
|
110
|
+
const index = payload.index;
|
|
111
|
+
if (!isNonNegativeInteger(index) || !state.openContentBlockIndexes.has(index)) {
|
|
112
|
+
markMalformed(state);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function observeContentBlockStop(payload, state) {
|
|
116
|
+
if (!canObserveOpenMessageLifecycle(state))
|
|
117
|
+
return;
|
|
118
|
+
const index = payload.index;
|
|
119
|
+
if (!isNonNegativeInteger(index) || !state.openContentBlockIndexes.delete(index)) {
|
|
120
|
+
markMalformed(state);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function observeMessageDelta(payload, state) {
|
|
124
|
+
if (!canObserveOpenMessageLifecycle(state))
|
|
125
|
+
return;
|
|
126
|
+
const delta = payload.delta;
|
|
127
|
+
if (!isPlainObject(delta))
|
|
128
|
+
return;
|
|
129
|
+
const stopReason = delta.stop_reason;
|
|
130
|
+
if (typeof stopReason === "string" && stopReason.length > 0) {
|
|
131
|
+
state.sawTerminalStopReason = true;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function observeAnthropicPayload(eventName, payload, state) {
|
|
135
|
+
if (!hasKnownAnthropicEventName(eventName)) {
|
|
136
|
+
markMalformed(state);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const type = payload.type;
|
|
140
|
+
if (typeof type !== "string" || eventName !== type) {
|
|
141
|
+
markMalformed(state);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
switch (type) {
|
|
145
|
+
case "message_start":
|
|
146
|
+
if (state.sawMessageStart || state.sawMessageStop || state.sawTerminalStopReason)
|
|
147
|
+
markMalformed(state);
|
|
148
|
+
state.sawMessageStart = true;
|
|
149
|
+
break;
|
|
150
|
+
case "content_block_start":
|
|
151
|
+
observeContentBlockStart(payload, state);
|
|
152
|
+
break;
|
|
153
|
+
case "content_block_delta":
|
|
154
|
+
observeContentBlockDelta(payload, state);
|
|
155
|
+
break;
|
|
156
|
+
case "content_block_stop":
|
|
157
|
+
observeContentBlockStop(payload, state);
|
|
158
|
+
break;
|
|
159
|
+
case "message_delta":
|
|
160
|
+
observeMessageDelta(payload, state);
|
|
161
|
+
break;
|
|
162
|
+
case "message_stop":
|
|
163
|
+
if (!state.sawMessageStart || state.sawMessageStop || state.openContentBlockIndexes.size > 0) {
|
|
164
|
+
markMalformed(state);
|
|
165
|
+
}
|
|
166
|
+
state.sawMessageStop = true;
|
|
167
|
+
break;
|
|
168
|
+
case "ping":
|
|
169
|
+
break;
|
|
170
|
+
case "error":
|
|
171
|
+
state.sawErrorEvent = true;
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function observeSseFrame(frame, state) {
|
|
176
|
+
if (state.sawDoneSentinel) {
|
|
177
|
+
markMalformed(state);
|
|
178
|
+
}
|
|
179
|
+
const core = stripEventSeparator(frame);
|
|
180
|
+
if (core.length === 0)
|
|
181
|
+
return "empty";
|
|
182
|
+
let eventName;
|
|
183
|
+
const dataLines = [];
|
|
184
|
+
for (const line of core.split(/\r\n|\n|\r/)) {
|
|
185
|
+
if (line.length === 0 || line.startsWith(":"))
|
|
186
|
+
continue;
|
|
187
|
+
const separatorIndex = line.indexOf(":");
|
|
188
|
+
const field = separatorIndex === -1 ? line : line.slice(0, separatorIndex);
|
|
189
|
+
let value = separatorIndex === -1 ? "" : line.slice(separatorIndex + 1);
|
|
190
|
+
if (value.startsWith(" "))
|
|
191
|
+
value = value.slice(1);
|
|
192
|
+
if (field === "event") {
|
|
193
|
+
eventName = value;
|
|
194
|
+
}
|
|
195
|
+
else if (field === "data") {
|
|
196
|
+
dataLines.push(value);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (dataLines.length === 0) {
|
|
200
|
+
if (eventName === "error")
|
|
201
|
+
state.sawErrorEvent = true;
|
|
202
|
+
return "empty";
|
|
203
|
+
}
|
|
204
|
+
const dataPayload = dataLines.join("\n");
|
|
205
|
+
if (dataPayload.trim() === "[DONE]") {
|
|
206
|
+
return "done";
|
|
207
|
+
}
|
|
208
|
+
let parsed;
|
|
209
|
+
try {
|
|
210
|
+
parsed = JSON.parse(dataPayload);
|
|
211
|
+
}
|
|
212
|
+
catch {
|
|
213
|
+
markMalformed(state);
|
|
214
|
+
return "data";
|
|
215
|
+
}
|
|
216
|
+
if (!isPlainObject(parsed)) {
|
|
217
|
+
markMalformed(state);
|
|
218
|
+
return "data";
|
|
219
|
+
}
|
|
220
|
+
observeAnthropicPayload(eventName, parsed, state);
|
|
221
|
+
return "data";
|
|
222
|
+
}
|
|
223
|
+
function drainCompleteFrames(buffer, state) {
|
|
224
|
+
let rest = buffer;
|
|
225
|
+
let output = "";
|
|
226
|
+
for (;;) {
|
|
227
|
+
const boundaryEnd = findSseEventBoundary(rest);
|
|
228
|
+
if (boundaryEnd === -1)
|
|
229
|
+
break;
|
|
230
|
+
const frame = rest.slice(0, boundaryEnd);
|
|
231
|
+
rest = rest.slice(boundaryEnd);
|
|
232
|
+
const observation = observeSseFrame(frame, state);
|
|
233
|
+
if (observation === "done") {
|
|
234
|
+
if (shouldSynthesizeMessageStop(state)) {
|
|
235
|
+
output += COPILOT_ANTHROPIC_SYNTHETIC_MESSAGE_STOP_EVENT;
|
|
236
|
+
state.insertedSyntheticStop = true;
|
|
237
|
+
state.sawMessageStop = true;
|
|
238
|
+
}
|
|
239
|
+
state.sawDoneSentinel = true;
|
|
240
|
+
}
|
|
241
|
+
output += frame;
|
|
242
|
+
}
|
|
243
|
+
return { output, rest };
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Wrap a Copilot Anthropic Messages SSE byte stream and repair one narrow class
|
|
247
|
+
* of provider truncation: missing `message_stop` after a fully closed message.
|
|
248
|
+
* Original SSE frames are emitted unchanged; the only possible mutation is one
|
|
249
|
+
* synthetic terminal event at clean EOF or immediately before `[DONE]`.
|
|
250
|
+
*/
|
|
251
|
+
export function createCopilotAnthropicMessagesSseRepairStream(source) {
|
|
252
|
+
const reader = source.getReader();
|
|
253
|
+
const decoder = new TextDecoder();
|
|
254
|
+
const encoder = new TextEncoder();
|
|
255
|
+
const state = createRepairState();
|
|
256
|
+
let buffer = "";
|
|
257
|
+
return new ReadableStream({
|
|
258
|
+
async pull(controller) {
|
|
259
|
+
for (;;) {
|
|
260
|
+
const { done, value } = await reader.read();
|
|
261
|
+
if (done) {
|
|
262
|
+
buffer += decoder.decode();
|
|
263
|
+
const drained = drainCompleteFrames(buffer, state);
|
|
264
|
+
buffer = drained.rest;
|
|
265
|
+
let output = drained.output;
|
|
266
|
+
if (buffer.length > 0) {
|
|
267
|
+
const trailingFrame = buffer;
|
|
268
|
+
const observation = observeSseFrame(trailingFrame, state);
|
|
269
|
+
buffer = "";
|
|
270
|
+
if (observation === "done") {
|
|
271
|
+
if (shouldSynthesizeMessageStop(state)) {
|
|
272
|
+
output += COPILOT_ANTHROPIC_SYNTHETIC_MESSAGE_STOP_EVENT;
|
|
273
|
+
state.insertedSyntheticStop = true;
|
|
274
|
+
state.sawMessageStop = true;
|
|
275
|
+
}
|
|
276
|
+
state.sawDoneSentinel = true;
|
|
277
|
+
}
|
|
278
|
+
output += trailingFrame;
|
|
279
|
+
if (observation === "data" && shouldSynthesizeMessageStop(state)) {
|
|
280
|
+
output += missingFinalFrameSeparator(trailingFrame);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
if (shouldSynthesizeMessageStop(state)) {
|
|
284
|
+
output += COPILOT_ANTHROPIC_SYNTHETIC_MESSAGE_STOP_EVENT;
|
|
285
|
+
state.insertedSyntheticStop = true;
|
|
286
|
+
state.sawMessageStop = true;
|
|
287
|
+
}
|
|
288
|
+
if (output.length > 0) {
|
|
289
|
+
controller.enqueue(encoder.encode(output));
|
|
290
|
+
}
|
|
291
|
+
controller.close();
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
buffer += decoder.decode(value, { stream: true });
|
|
295
|
+
const drained = drainCompleteFrames(buffer, state);
|
|
296
|
+
buffer = drained.rest;
|
|
297
|
+
if (drained.output.length > 0) {
|
|
298
|
+
controller.enqueue(encoder.encode(drained.output));
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
cancel(reason) {
|
|
304
|
+
return reader.cancel(reason);
|
|
305
|
+
},
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
function isCopilotAnthropicMessagesUrl(url) {
|
|
309
|
+
if (!url)
|
|
310
|
+
return false;
|
|
311
|
+
try {
|
|
312
|
+
const parsed = new URL(url);
|
|
313
|
+
return isCopilotApiHost(parsed) && parsed.pathname === COPILOT_ANTHROPIC_MESSAGES_PATH;
|
|
314
|
+
}
|
|
315
|
+
catch {
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
function isEventStreamResponse(response) {
|
|
320
|
+
return (response.headers.get("content-type") ?? "").toLowerCase().includes("text/event-stream");
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Scope the Anthropic SSE repair to GitHub Copilot `/v1/messages` event streams
|
|
324
|
+
* with a body. All other responses are returned as the original instance.
|
|
325
|
+
*/
|
|
326
|
+
export function maybeRepairCopilotAnthropicMessagesResponse(url, response) {
|
|
327
|
+
if (!isCopilotAnthropicMessagesUrl(url))
|
|
328
|
+
return response;
|
|
329
|
+
if (!isEventStreamResponse(response))
|
|
330
|
+
return response;
|
|
331
|
+
if (!response.body)
|
|
332
|
+
return response;
|
|
333
|
+
const transformed = createCopilotAnthropicMessagesSseRepairStream(response.body);
|
|
334
|
+
return new Response(transformed, {
|
|
335
|
+
status: response.status,
|
|
336
|
+
statusText: response.statusText,
|
|
337
|
+
headers: response.headers,
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
//# sourceMappingURL=copilot-anthropic-sse-repair.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot-anthropic-sse-repair.js","sourceRoot":"","sources":["../../src/core/copilot-anthropic-sse-repair.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAkBtD,MAAM,CAAC,MAAM,8CAA8C,GACzD,wDAAwD,CAAC;AAE3D,MAAM,+BAA+B,GAAG,cAAc,CAAC;AACvD,MAAM,+BAA+B,GAAG,IAAI,GAAG,CAAC;IAC9C,eAAe;IACf,qBAAqB;IACrB,qBAAqB;IACrB,oBAAoB;IACpB,eAAe;IACf,cAAc;IACd,MAAM;IACN,OAAO;CACR,CAAC,CAAC;AAEH,SAAS,iBAAiB;IACxB,OAAO;QACL,eAAe,EAAE,KAAK;QACtB,cAAc,EAAE,KAAK;QACrB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,CAAC;QAAE,OAAO,QAAQ,CAAC;IACtD,IAAI,CAAC,QAAQ,CAAC,IAAI;QAAE,OAAO,QAAQ,CAAC;IAEpC,MAAM,WAAW,GAAG,6CAA6C,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACjF,OAAO,IAAI,QAAQ,CAAC,WAAW,EAAE;QAC/B,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,OAAO,EAAE,QAAQ,CAAC,OAAO;KAC1B,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * Narrow repair for GitHub Copilot Anthropic Messages SSE streams that carry a\n * complete Anthropic turn but omit the required terminal `message_stop` event.\n *\n * The wrapper is deliberately conservative: it is only installed for Copilot\n * `/v1/messages` event streams, passes original SSE frames through unchanged,\n * and appends/inserts a single synthetic `message_stop` only after observing the\n * same terminal evidence Anthropic's parser requires for a complete message.\n */\n\nimport { isCopilotApiHost } from \"./copilot-hosts.ts\";\n\ntype JsonObject = { [key: string]: JsonValue };\ntype JsonValue = string | number | boolean | null | JsonValue[] | JsonObject;\n\ntype SseObservation = \"data\" | \"done\" | \"empty\";\n\ninterface RepairState {\n sawMessageStart: boolean;\n sawMessageStop: boolean;\n sawTerminalStopReason: boolean;\n sawErrorEvent: boolean;\n malformedOrUncertain: boolean;\n sawDoneSentinel: boolean;\n insertedSyntheticStop: boolean;\n openContentBlockIndexes: Set<number>;\n}\n\nexport const COPILOT_ANTHROPIC_SYNTHETIC_MESSAGE_STOP_EVENT =\n 'event: message_stop\\ndata: {\"type\":\"message_stop\"}\\n\\n';\n\nconst COPILOT_ANTHROPIC_MESSAGES_PATH = \"/v1/messages\";\nconst KNOWN_ANTHROPIC_SSE_EVENT_NAMES = new Set([\n \"message_start\",\n \"content_block_start\",\n \"content_block_delta\",\n \"content_block_stop\",\n \"message_delta\",\n \"message_stop\",\n \"ping\",\n \"error\",\n]);\n\nfunction createRepairState(): RepairState {\n return {\n sawMessageStart: false,\n sawMessageStop: false,\n sawTerminalStopReason: false,\n sawErrorEvent: false,\n malformedOrUncertain: false,\n sawDoneSentinel: false,\n insertedSyntheticStop: false,\n openContentBlockIndexes: new Set<number>(),\n };\n}\n\nfunction isPlainObject(value: JsonValue): value is JsonObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isNonNegativeInteger(value: JsonValue | undefined): value is number {\n return typeof value === \"number\" && Number.isInteger(value) && value >= 0;\n}\n\nfunction markMalformed(state: RepairState): void {\n state.malformedOrUncertain = true;\n}\n\nfunction shouldSynthesizeMessageStop(state: RepairState): boolean {\n return (\n state.sawMessageStart &&\n !state.sawMessageStop &&\n state.sawTerminalStopReason &&\n !state.sawErrorEvent &&\n !state.malformedOrUncertain &&\n !state.sawDoneSentinel &&\n !state.insertedSyntheticStop &&\n state.openContentBlockIndexes.size === 0\n );\n}\n\nfunction findSseEventBoundary(buffer: string): number {\n const candidates = [\"\\r\\n\\r\\n\", \"\\n\\n\", \"\\r\\r\"];\n let bestIndex = -1;\n let bestLength = 0;\n for (const candidate of candidates) {\n const index = buffer.indexOf(candidate);\n if (index === -1) continue;\n if (bestIndex === -1 || index < bestIndex) {\n bestIndex = index;\n bestLength = candidate.length;\n }\n }\n return bestIndex === -1 ? -1 : bestIndex + bestLength;\n}\n\nfunction stripEventSeparator(frame: string): string {\n if (frame.endsWith(\"\\r\\n\\r\\n\")) return frame.slice(0, -4);\n if (frame.endsWith(\"\\n\\n\")) return frame.slice(0, -2);\n if (frame.endsWith(\"\\r\\r\")) return frame.slice(0, -2);\n return frame;\n}\n\nfunction missingFinalFrameSeparator(frame: string): string {\n if (frame.endsWith(\"\\r\\n\")) return \"\\r\\n\";\n if (frame.endsWith(\"\\n\")) return \"\\n\";\n if (frame.endsWith(\"\\r\")) return \"\\r\";\n return \"\\n\\n\";\n}\n\nfunction hasKnownAnthropicEventName(eventName: string | undefined): eventName is string {\n return eventName !== undefined && KNOWN_ANTHROPIC_SSE_EVENT_NAMES.has(eventName);\n}\n\nfunction canObserveOpenMessageLifecycle(state: RepairState): boolean {\n if (!state.sawMessageStart || state.sawMessageStop || state.sawTerminalStopReason) {\n markMalformed(state);\n return false;\n }\n return true;\n}\n\nfunction observeContentBlockStart(payload: JsonObject, state: RepairState): void {\n if (!canObserveOpenMessageLifecycle(state)) return;\n const index = payload.index;\n if (!isNonNegativeInteger(index) || state.openContentBlockIndexes.has(index)) {\n markMalformed(state);\n return;\n }\n state.openContentBlockIndexes.add(index);\n}\n\nfunction observeContentBlockDelta(payload: JsonObject, state: RepairState): void {\n if (!canObserveOpenMessageLifecycle(state)) return;\n const index = payload.index;\n if (!isNonNegativeInteger(index) || !state.openContentBlockIndexes.has(index)) {\n markMalformed(state);\n }\n}\n\nfunction observeContentBlockStop(payload: JsonObject, state: RepairState): void {\n if (!canObserveOpenMessageLifecycle(state)) return;\n const index = payload.index;\n if (!isNonNegativeInteger(index) || !state.openContentBlockIndexes.delete(index)) {\n markMalformed(state);\n }\n}\n\nfunction observeMessageDelta(payload: JsonObject, state: RepairState): void {\n if (!canObserveOpenMessageLifecycle(state)) return;\n const delta = payload.delta;\n if (!isPlainObject(delta)) return;\n const stopReason = delta.stop_reason;\n if (typeof stopReason === \"string\" && stopReason.length > 0) {\n state.sawTerminalStopReason = true;\n }\n}\n\nfunction observeAnthropicPayload(eventName: string | undefined, payload: JsonObject, state: RepairState): void {\n if (!hasKnownAnthropicEventName(eventName)) {\n markMalformed(state);\n return;\n }\n\n const type = payload.type;\n if (typeof type !== \"string\" || eventName !== type) {\n markMalformed(state);\n return;\n }\n\n switch (type) {\n case \"message_start\":\n if (state.sawMessageStart || state.sawMessageStop || state.sawTerminalStopReason) markMalformed(state);\n state.sawMessageStart = true;\n break;\n case \"content_block_start\":\n observeContentBlockStart(payload, state);\n break;\n case \"content_block_delta\":\n observeContentBlockDelta(payload, state);\n break;\n case \"content_block_stop\":\n observeContentBlockStop(payload, state);\n break;\n case \"message_delta\":\n observeMessageDelta(payload, state);\n break;\n case \"message_stop\":\n if (!state.sawMessageStart || state.sawMessageStop || state.openContentBlockIndexes.size > 0) {\n markMalformed(state);\n }\n state.sawMessageStop = true;\n break;\n case \"ping\":\n break;\n case \"error\":\n state.sawErrorEvent = true;\n break;\n }\n}\n\nfunction observeSseFrame(frame: string, state: RepairState): SseObservation {\n if (state.sawDoneSentinel) {\n markMalformed(state);\n }\n\n const core = stripEventSeparator(frame);\n if (core.length === 0) return \"empty\";\n\n let eventName: string | undefined;\n const dataLines: string[] = [];\n for (const line of core.split(/\\r\\n|\\n|\\r/)) {\n if (line.length === 0 || line.startsWith(\":\")) continue;\n const separatorIndex = line.indexOf(\":\");\n const field = separatorIndex === -1 ? line : line.slice(0, separatorIndex);\n let value = separatorIndex === -1 ? \"\" : line.slice(separatorIndex + 1);\n if (value.startsWith(\" \")) value = value.slice(1);\n\n if (field === \"event\") {\n eventName = value;\n } else if (field === \"data\") {\n dataLines.push(value);\n }\n }\n\n if (dataLines.length === 0) {\n if (eventName === \"error\") state.sawErrorEvent = true;\n return \"empty\";\n }\n\n const dataPayload = dataLines.join(\"\\n\");\n if (dataPayload.trim() === \"[DONE]\") {\n return \"done\";\n }\n\n let parsed: JsonValue;\n try {\n parsed = JSON.parse(dataPayload) as JsonValue;\n } catch {\n markMalformed(state);\n return \"data\";\n }\n\n if (!isPlainObject(parsed)) {\n markMalformed(state);\n return \"data\";\n }\n\n observeAnthropicPayload(eventName, parsed, state);\n return \"data\";\n}\n\nfunction drainCompleteFrames(buffer: string, state: RepairState): { output: string; rest: string } {\n let rest = buffer;\n let output = \"\";\n for (;;) {\n const boundaryEnd = findSseEventBoundary(rest);\n if (boundaryEnd === -1) break;\n\n const frame = rest.slice(0, boundaryEnd);\n rest = rest.slice(boundaryEnd);\n const observation = observeSseFrame(frame, state);\n if (observation === \"done\") {\n if (shouldSynthesizeMessageStop(state)) {\n output += COPILOT_ANTHROPIC_SYNTHETIC_MESSAGE_STOP_EVENT;\n state.insertedSyntheticStop = true;\n state.sawMessageStop = true;\n }\n state.sawDoneSentinel = true;\n }\n output += frame;\n }\n return { output, rest };\n}\n\n/**\n * Wrap a Copilot Anthropic Messages SSE byte stream and repair one narrow class\n * of provider truncation: missing `message_stop` after a fully closed message.\n * Original SSE frames are emitted unchanged; the only possible mutation is one\n * synthetic terminal event at clean EOF or immediately before `[DONE]`.\n */\nexport function createCopilotAnthropicMessagesSseRepairStream(\n source: ReadableStream<Uint8Array>,\n): ReadableStream<Uint8Array> {\n const reader = source.getReader();\n const decoder = new TextDecoder();\n const encoder = new TextEncoder();\n const state = createRepairState();\n let buffer = \"\";\n\n return new ReadableStream<Uint8Array>({\n async pull(controller) {\n for (;;) {\n const { done, value } = await reader.read();\n if (done) {\n buffer += decoder.decode();\n const drained = drainCompleteFrames(buffer, state);\n buffer = drained.rest;\n let output = drained.output;\n\n if (buffer.length > 0) {\n const trailingFrame = buffer;\n const observation = observeSseFrame(trailingFrame, state);\n buffer = \"\";\n if (observation === \"done\") {\n if (shouldSynthesizeMessageStop(state)) {\n output += COPILOT_ANTHROPIC_SYNTHETIC_MESSAGE_STOP_EVENT;\n state.insertedSyntheticStop = true;\n state.sawMessageStop = true;\n }\n state.sawDoneSentinel = true;\n }\n output += trailingFrame;\n if (observation === \"data\" && shouldSynthesizeMessageStop(state)) {\n output += missingFinalFrameSeparator(trailingFrame);\n }\n }\n\n if (shouldSynthesizeMessageStop(state)) {\n output += COPILOT_ANTHROPIC_SYNTHETIC_MESSAGE_STOP_EVENT;\n state.insertedSyntheticStop = true;\n state.sawMessageStop = true;\n }\n\n if (output.length > 0) {\n controller.enqueue(encoder.encode(output));\n }\n controller.close();\n return;\n }\n\n buffer += decoder.decode(value, { stream: true });\n const drained = drainCompleteFrames(buffer, state);\n buffer = drained.rest;\n if (drained.output.length > 0) {\n controller.enqueue(encoder.encode(drained.output));\n return;\n }\n }\n },\n cancel(reason) {\n return reader.cancel(reason);\n },\n });\n}\n\nfunction isCopilotAnthropicMessagesUrl(url: string | undefined): boolean {\n if (!url) return false;\n try {\n const parsed = new URL(url);\n return isCopilotApiHost(parsed) && parsed.pathname === COPILOT_ANTHROPIC_MESSAGES_PATH;\n } catch {\n return false;\n }\n}\n\nfunction isEventStreamResponse(response: Response): boolean {\n return (response.headers.get(\"content-type\") ?? \"\").toLowerCase().includes(\"text/event-stream\");\n}\n\n/**\n * Scope the Anthropic SSE repair to GitHub Copilot `/v1/messages` event streams\n * with a body. All other responses are returned as the original instance.\n */\nexport function maybeRepairCopilotAnthropicMessagesResponse(\n url: string | undefined,\n response: Response,\n): Response {\n if (!isCopilotAnthropicMessagesUrl(url)) return response;\n if (!isEventStreamResponse(response)) return response;\n if (!response.body) return response;\n\n const transformed = createCopilotAnthropicMessagesSseRepairStream(response.body);\n return new Response(transformed, {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n });\n}\n"]}
|
|
@@ -103,16 +103,24 @@ export declare function restoreCopilotGeminiReasoningOpaque(payload: unknown, mo
|
|
|
103
103
|
*/
|
|
104
104
|
export declare function maybeRewriteCopilotGeminiResponse(url: string | undefined, response: Response): Response;
|
|
105
105
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
106
|
+
* Apply Copilot response-body transforms before pi-ai parses streamed provider
|
|
107
|
+
* output. Anthropic Messages repair gets first refusal for `/v1/messages`
|
|
108
|
+
* streams; other Copilot event streams keep the existing Gemini reasoning bridge.
|
|
109
|
+
*/
|
|
110
|
+
export declare function maybeRewriteCopilotProviderResponse(url: string | undefined, response: Response): Response;
|
|
111
|
+
/**
|
|
112
|
+
* Install a `globalThis.fetch` wrapper that applies Copilot-only stream
|
|
113
|
+
* compatibility shims before pi-ai parses provider output. Currently this
|
|
114
|
+
* includes the Gemini `reasoning_opaque` bridge and the Anthropic Messages
|
|
115
|
+
* terminal `message_stop` repair. Idempotent.
|
|
109
116
|
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* keeping the blast radius to streaming CAPI Gemini turns only.
|
|
117
|
+
* SDK clients resolve `globalThis.fetch` at client-construction time, and a new
|
|
118
|
+
* client is built per request, so wrapping the global before the first request
|
|
119
|
+
* is reliably picked up. Non-Copilot hosts and non-event-stream responses are
|
|
120
|
+
* returned untouched by the underlying shims.
|
|
115
121
|
*/
|
|
122
|
+
export declare function installCopilotResponseInterceptor(): void;
|
|
123
|
+
/** Backward-compatible name for the original Gemini-only interceptor export. */
|
|
116
124
|
export declare function installCopilotGeminiReasoningInterceptor(): void;
|
|
117
125
|
export {};
|
|
118
126
|
//# sourceMappingURL=copilot-gemini-reasoning.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copilot-gemini-reasoning.d.ts","sourceRoot":"","sources":["../../src/core/copilot-gemini-reasoning.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAG/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH,KAAK,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAC/C,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,EAAE,GAAG,UAAU,CAAC;AAS7E;;;;;;;;;;;;GAYG;AACH,wBAAgB,mCAAmC,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAiC7E;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAWvE;AAeD;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,GACjC,cAAc,CAAC,UAAU,CAAC,CAyC5B;AAED;;;;;;;;;GASG;AACH,wBAAgB,mCAAmC,CACjD,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,UAAU,GAAG,KAAK,GAAG,IAAI,CAAC,GACjD,OAAO,CA2BT;AAyBD;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAC/C,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,QAAQ,EAAE,QAAQ,GACjB,QAAQ,CAWV;AAID;;;;;;;;;;GAUG;AACH,wBAAgB,wCAAwC,IAAI,IAAI,CAuB/D","sourcesContent":["import type { Api, Model } from \"@earendil-works/pi-ai/compat\";\nimport { isCopilotGeminiModel } from \"./copilot-gemini-payload-sanitizer.ts\";\n\n/**\n * Round-trips GitHub Copilot Gemini \"thought signatures\" so multi-turn tool use\n * does not silently die after the first tool call.\n *\n * Why this exists\n * ---------------\n * `github-copilot` Gemini models (e.g. `gemini-3.1-pro-preview`) are served\n * through Copilot's CAPI gateway, which proxies to Google's GenAI API. Gemini\n * is a thinking model: when it emits a function/tool call it also returns an\n * opaque **thought signature** that must be sent back, verbatim, on the next\n * request or Gemini refuses to continue the reasoning chain.\n *\n * CAPI carries that signature in a non-standard OpenAI-completions field named\n * **`reasoning_opaque`** (an encrypted blob) on the assistant message / streamed\n * delta, and on replay it reads the same `reasoning_opaque` back off the\n * assistant message and re-attaches the signature to each Gemini function-call\n * part (keyed by `tool_call.id`). The underlying OpenAI-completions client\n * (`@earendil-works/pi-ai`) does not understand `reasoning_opaque`; it captures\n * thought signatures only from the OpenRouter-style\n * `reasoning_details: [{ type: \"reasoning.encrypted\", id, data }]` shape, which\n * CAPI never emits. So the real Gemini thought signature was being dropped on\n * the way in and never replayed on the way out.\n *\n * With the signature missing, CAPI substitutes the sentinel\n * `skip_thought_signature_validator` on the first replayed function call, and\n * Gemini responds with an empty candidate / `finish_reason: \"stop\"` and zero\n * output tokens — the harness sees a degenerate empty completion, retries with\n * the same signature-less history, and eventually gives up: \"Gemini just stops\n * responding.\"\n *\n * What this does\n * --------------\n * Two gated, self-contained transforms bridge CAPI's `reasoning_opaque` to the\n * `reasoning_details` mechanism the client already round-trips:\n *\n * - **Inbound** ({@link rewriteCopilotGeminiSseData} via\n * {@link createCopilotGeminiSseStream}): rewrites the CAPI Gemini SSE\n * stream so each streamed delta that carries both `reasoning_opaque` and a\n * `tool_calls[].id` gains a\n * `reasoning_details: [{ type: \"reasoning.encrypted\", id, data: <opaque> }]`\n * entry. The client then stores it as the tool call's `thoughtSignature`.\n * CAPI confirms `reasoning_opaque` rides on the same streamed delta as the\n * first (id-bearing) tool-call chunk, so the association is exact.\n * - **Outbound** ({@link restoreCopilotGeminiReasoningOpaque} from the\n * `onPayload` hook): converts the `reasoning_details` the client re-emits on\n * replayed assistant messages back into a single `reasoning_opaque` field on\n * that assistant message, which is the only shape CAPI reads.\n *\n * Both transforms are gated to GitHub Copilot Gemini and are no-ops for every\n * other provider/model (and for Gemini turns that carry no thought signature).\n */\n\ntype JsonObject = { [key: string]: JsonValue };\ntype JsonValue = string | number | boolean | null | JsonValue[] | JsonObject;\n\n/** OpenRouter-style encrypted reasoning detail the pi-ai client round-trips. */\nconst REASONING_ENCRYPTED_TYPE = \"reasoning.encrypted\";\n\nfunction isPlainObject(value: unknown): value is JsonObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Inject `reasoning_details` into a parsed CAPI Gemini streaming chunk so the\n * pi-ai OpenAI-completions parser captures the Gemini thought signature.\n *\n * For each `choices[].delta` that carries a non-empty `reasoning_opaque` string\n * and a `tool_calls[]` entry with an `id`, adds a single\n * `reasoning_details: [{ type: \"reasoning.encrypted\", id, data: <opaque> }]`\n * entry keyed by that tool-call id. Returns whether the chunk was mutated.\n *\n * No-op when the delta already has `reasoning_details`, has no id-bearing tool\n * call (e.g. argument-continuation deltas or pure-text thought chunks), or has\n * no `reasoning_opaque`.\n */\nexport function injectCopilotGeminiReasoningDetails(chunk: JsonValue): boolean {\n if (!isPlainObject(chunk)) return false;\n const choices = chunk.choices;\n if (!Array.isArray(choices)) return false;\n\n let mutated = false;\n for (const choice of choices) {\n if (!isPlainObject(choice)) continue;\n const delta = choice.delta;\n if (!isPlainObject(delta)) continue;\n\n const opaque = delta.reasoning_opaque;\n if (typeof opaque !== \"string\" || opaque.length === 0) continue;\n\n // Already carries the encrypted detail (don't double-inject / clobber).\n if (Array.isArray(delta.reasoning_details) && delta.reasoning_details.length > 0) {\n continue;\n }\n\n const toolCalls = delta.tool_calls;\n if (!Array.isArray(toolCalls)) continue;\n const idBearing = toolCalls.find(\n (call): call is JsonObject =>\n isPlainObject(call) && typeof call.id === \"string\" && call.id.length > 0,\n );\n if (!idBearing) continue;\n\n delta.reasoning_details = [\n { type: REASONING_ENCRYPTED_TYPE, id: idBearing.id as string, data: opaque },\n ];\n mutated = true;\n }\n return mutated;\n}\n\n/**\n * Rewrite the JSON payload of a single SSE `data:` line. Returns the original\n * string unchanged when it is not a Gemini chunk that needs a thought signature\n * bridged, or when parsing fails (fail-open: never corrupt the stream).\n */\nexport function rewriteCopilotGeminiSseData(dataPayload: string): string {\n // Cheap gate: only chunks that actually carry a thought signature are touched.\n if (!dataPayload.includes(\"reasoning_opaque\")) return dataPayload;\n let parsed: JsonValue;\n try {\n parsed = JSON.parse(dataPayload) as JsonValue;\n } catch {\n return dataPayload;\n }\n if (!injectCopilotGeminiReasoningDetails(parsed)) return dataPayload;\n return JSON.stringify(parsed);\n}\n\n/** Rewrite one SSE line, preserving a trailing carriage return when present. */\nfunction rewriteSseLine(line: string): string {\n const hasCr = line.endsWith(\"\\r\");\n const core = hasCr ? line.slice(0, -1) : line;\n if (!core.startsWith(\"data:\")) return line;\n const payload = core.slice(\"data:\".length).trimStart();\n if (payload.length === 0 || payload === \"[DONE]\") return line;\n const rewritten = rewriteCopilotGeminiSseData(payload);\n if (rewritten === payload) return line;\n const rebuilt = `data: ${rewritten}`;\n return hasCr ? `${rebuilt}\\r` : rebuilt;\n}\n\n/**\n * Wrap a CAPI Gemini SSE byte stream so `reasoning_opaque` is bridged into\n * `reasoning_details`. Buffers across chunk boundaries and rewrites whole lines\n * only; bytes that are not affected pass through unchanged.\n *\n * Implemented as a `ReadableStream` over the source reader (rather than a\n * `TransformStream` piped via `pipeThrough`) so the transform pulls lazily and\n * propagates cancellation to the upstream body.\n */\nexport function createCopilotGeminiSseStream(\n source: ReadableStream<Uint8Array>,\n): ReadableStream<Uint8Array> {\n const reader = source.getReader();\n const decoder = new TextDecoder();\n const encoder = new TextEncoder();\n let buffer = \"\";\n\n return new ReadableStream<Uint8Array>({\n async pull(controller) {\n // Loop until we emit at least one chunk or close, so a read that yields no\n // complete line still makes progress without relying on the runtime to\n // re-invoke pull after a no-enqueue return.\n for (;;) {\n const { done, value } = await reader.read();\n if (done) {\n buffer += decoder.decode();\n if (buffer.length > 0) {\n controller.enqueue(encoder.encode(rewriteSseLine(buffer)));\n buffer = \"\";\n }\n controller.close();\n return;\n }\n buffer += decoder.decode(value, { stream: true });\n let newlineIndex = buffer.indexOf(\"\\n\");\n let out = \"\";\n while (newlineIndex !== -1) {\n const line = buffer.slice(0, newlineIndex);\n buffer = buffer.slice(newlineIndex + 1);\n out += `${rewriteSseLine(line)}\\n`;\n newlineIndex = buffer.indexOf(\"\\n\");\n }\n if (out.length > 0) {\n controller.enqueue(encoder.encode(out));\n return;\n }\n }\n },\n cancel(reason) {\n return reader.cancel(reason);\n },\n });\n}\n\n/**\n * Convert the `reasoning_details` the pi-ai client re-emits on replayed\n * assistant messages back into the single `reasoning_opaque` field CAPI reads.\n *\n * For GitHub Copilot Gemini payloads, each assistant message that carries a\n * `reasoning_details` entry of `type: \"reasoning.encrypted\"` has its `data`\n * (the original CAPI thought-signature blob) promoted to `reasoning_opaque`,\n * and the now-redundant `reasoning_details` removed. No-op for every other\n * provider/model and for payloads without such messages.\n */\nexport function restoreCopilotGeminiReasoningOpaque(\n payload: unknown,\n model: Pick<Model<Api>, \"provider\" | \"api\" | \"id\">,\n): unknown {\n if (!isCopilotGeminiModel(model)) return payload;\n if (!isPlainObject(payload as JsonValue)) return payload;\n const payloadObject = payload as JsonObject;\n const messages = payloadObject.messages;\n if (!Array.isArray(messages)) return payload;\n\n let mutated = false;\n const nextMessages = messages.map((message) => {\n if (!isPlainObject(message) || message.role !== \"assistant\") return message;\n const details = message.reasoning_details;\n if (!Array.isArray(details) || details.length === 0) return message;\n const encrypted = details.find(\n (detail): detail is JsonObject =>\n isPlainObject(detail) &&\n detail.type === REASONING_ENCRYPTED_TYPE &&\n typeof detail.data === \"string\" &&\n detail.data.length > 0,\n );\n if (!encrypted) return message;\n mutated = true;\n const { reasoning_details: _omitted, ...rest } = message;\n return { ...rest, reasoning_opaque: encrypted.data as string };\n });\n\n if (!mutated) return payload;\n return { ...payloadObject, messages: nextMessages };\n}\n\n/** Whether the URL targets Copilot's CAPI gateway (`*.githubcopilot.com`). */\nfunction isCopilotApiHost(url: string): boolean {\n try {\n const host = new URL(url).hostname.toLowerCase();\n // Exact host or a real subdomain only — never a look-alike suffix such as\n // `notgithubcopilot.com` (CodeQL: incomplete URL substring sanitization).\n return host === \"githubcopilot.com\" || host.endsWith(\".githubcopilot.com\");\n } catch {\n return false;\n }\n}\n\n/** Resolve the request URL string from a `fetch` input argument. */\nfunction resolveRequestUrl(input: Parameters<typeof fetch>[0]): string | undefined {\n if (typeof input === \"string\") return input;\n if (input instanceof URL) return input.href;\n if (typeof input === \"object\" && input !== null && \"url\" in input) {\n const url = (input as { url?: unknown }).url;\n if (typeof url === \"string\") return url;\n }\n return undefined;\n}\n\n/**\n * Rewrite a streaming CAPI Gemini response so its SSE body bridges\n * `reasoning_opaque` into `reasoning_details`. Returns the original response\n * untouched for non-Copilot hosts, non-event-stream responses, or bodyless\n * responses, keeping the blast radius to streaming CAPI Gemini turns only.\n */\nexport function maybeRewriteCopilotGeminiResponse(\n url: string | undefined,\n response: Response,\n): Response {\n if (!url || !isCopilotApiHost(url)) return response;\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n if (!contentType.includes(\"text/event-stream\")) return response;\n if (!response.body) return response;\n const transformed = createCopilotGeminiSseStream(response.body);\n return new Response(transformed, {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n });\n}\n\nlet originalFetch: typeof fetch | undefined;\n\n/**\n * Install a `globalThis.fetch` wrapper that rewrites CAPI Gemini SSE responses\n * to bridge `reasoning_opaque` into `reasoning_details` (see\n * {@link createCopilotGeminiSseStream}). Idempotent.\n *\n * The OpenAI SDK used by the `openai-completions` provider resolves\n * `globalThis.fetch` at client-construction time, and a new client is built per\n * request, so wrapping the global before the first request is reliably picked\n * up. Non-Copilot hosts and non-event-stream responses are returned untouched,\n * keeping the blast radius to streaming CAPI Gemini turns only.\n */\nexport function installCopilotGeminiReasoningInterceptor(): void {\n if (originalFetch) return;\n if (typeof globalThis.fetch !== \"function\") return;\n const base = globalThis.fetch;\n originalFetch = base;\n const boundFetch = base.bind(globalThis);\n\n const wrapped = (async (input, init) => {\n const response = await boundFetch(input, init);\n try {\n return maybeRewriteCopilotGeminiResponse(resolveRequestUrl(input), response);\n } catch {\n return response;\n }\n }) as typeof fetch;\n\n // Preserve `fetch.preconnect` so the wrapper remains a drop-in replacement.\n const preconnect = (base as { preconnect?: unknown }).preconnect;\n if (typeof preconnect === \"function\") {\n (wrapped as { preconnect?: unknown }).preconnect = preconnect.bind(globalThis);\n }\n\n globalThis.fetch = wrapped;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"copilot-gemini-reasoning.d.ts","sourceRoot":"","sources":["../../src/core/copilot-gemini-reasoning.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAK/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH,KAAK,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAC/C,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,EAAE,GAAG,UAAU,CAAC;AAS7E;;;;;;;;;;;;GAYG;AACH,wBAAgB,mCAAmC,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAiC7E;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAWvE;AAeD;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,GACjC,cAAc,CAAC,UAAU,CAAC,CAyC5B;AAED;;;;;;;;;GASG;AACH,wBAAgB,mCAAmC,CACjD,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,UAAU,GAAG,KAAK,GAAG,IAAI,CAAC,GACjD,OAAO,CA2BT;AAaD;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAC/C,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,QAAQ,EAAE,QAAQ,GACjB,QAAQ,CAWV;AAED;;;;GAIG;AACH,wBAAgB,mCAAmC,CACjD,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,QAAQ,EAAE,QAAQ,GACjB,QAAQ,CAIV;AAID;;;;;;;;;;GAUG;AACH,wBAAgB,iCAAiC,IAAI,IAAI,CAuBxD;AAED,gFAAgF;AAChF,wBAAgB,wCAAwC,IAAI,IAAI,CAE/D","sourcesContent":["import type { Api, Model } from \"@earendil-works/pi-ai/compat\";\nimport { maybeRepairCopilotAnthropicMessagesResponse } from \"./copilot-anthropic-sse-repair.ts\";\nimport { isCopilotApiHost } from \"./copilot-hosts.ts\";\nimport { isCopilotGeminiModel } from \"./copilot-gemini-payload-sanitizer.ts\";\n\n/**\n * Round-trips GitHub Copilot Gemini \"thought signatures\" so multi-turn tool use\n * does not silently die after the first tool call.\n *\n * Why this exists\n * ---------------\n * `github-copilot` Gemini models (e.g. `gemini-3.1-pro-preview`) are served\n * through Copilot's CAPI gateway, which proxies to Google's GenAI API. Gemini\n * is a thinking model: when it emits a function/tool call it also returns an\n * opaque **thought signature** that must be sent back, verbatim, on the next\n * request or Gemini refuses to continue the reasoning chain.\n *\n * CAPI carries that signature in a non-standard OpenAI-completions field named\n * **`reasoning_opaque`** (an encrypted blob) on the assistant message / streamed\n * delta, and on replay it reads the same `reasoning_opaque` back off the\n * assistant message and re-attaches the signature to each Gemini function-call\n * part (keyed by `tool_call.id`). The underlying OpenAI-completions client\n * (`@earendil-works/pi-ai`) does not understand `reasoning_opaque`; it captures\n * thought signatures only from the OpenRouter-style\n * `reasoning_details: [{ type: \"reasoning.encrypted\", id, data }]` shape, which\n * CAPI never emits. So the real Gemini thought signature was being dropped on\n * the way in and never replayed on the way out.\n *\n * With the signature missing, CAPI substitutes the sentinel\n * `skip_thought_signature_validator` on the first replayed function call, and\n * Gemini responds with an empty candidate / `finish_reason: \"stop\"` and zero\n * output tokens — the harness sees a degenerate empty completion, retries with\n * the same signature-less history, and eventually gives up: \"Gemini just stops\n * responding.\"\n *\n * What this does\n * --------------\n * Two gated, self-contained transforms bridge CAPI's `reasoning_opaque` to the\n * `reasoning_details` mechanism the client already round-trips:\n *\n * - **Inbound** ({@link rewriteCopilotGeminiSseData} via\n * {@link createCopilotGeminiSseStream}): rewrites the CAPI Gemini SSE\n * stream so each streamed delta that carries both `reasoning_opaque` and a\n * `tool_calls[].id` gains a\n * `reasoning_details: [{ type: \"reasoning.encrypted\", id, data: <opaque> }]`\n * entry. The client then stores it as the tool call's `thoughtSignature`.\n * CAPI confirms `reasoning_opaque` rides on the same streamed delta as the\n * first (id-bearing) tool-call chunk, so the association is exact.\n * - **Outbound** ({@link restoreCopilotGeminiReasoningOpaque} from the\n * `onPayload` hook): converts the `reasoning_details` the client re-emits on\n * replayed assistant messages back into a single `reasoning_opaque` field on\n * that assistant message, which is the only shape CAPI reads.\n *\n * Both transforms are gated to GitHub Copilot Gemini and are no-ops for every\n * other provider/model (and for Gemini turns that carry no thought signature).\n */\n\ntype JsonObject = { [key: string]: JsonValue };\ntype JsonValue = string | number | boolean | null | JsonValue[] | JsonObject;\n\n/** OpenRouter-style encrypted reasoning detail the pi-ai client round-trips. */\nconst REASONING_ENCRYPTED_TYPE = \"reasoning.encrypted\";\n\nfunction isPlainObject(value: unknown): value is JsonObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Inject `reasoning_details` into a parsed CAPI Gemini streaming chunk so the\n * pi-ai OpenAI-completions parser captures the Gemini thought signature.\n *\n * For each `choices[].delta` that carries a non-empty `reasoning_opaque` string\n * and a `tool_calls[]` entry with an `id`, adds a single\n * `reasoning_details: [{ type: \"reasoning.encrypted\", id, data: <opaque> }]`\n * entry keyed by that tool-call id. Returns whether the chunk was mutated.\n *\n * No-op when the delta already has `reasoning_details`, has no id-bearing tool\n * call (e.g. argument-continuation deltas or pure-text thought chunks), or has\n * no `reasoning_opaque`.\n */\nexport function injectCopilotGeminiReasoningDetails(chunk: JsonValue): boolean {\n if (!isPlainObject(chunk)) return false;\n const choices = chunk.choices;\n if (!Array.isArray(choices)) return false;\n\n let mutated = false;\n for (const choice of choices) {\n if (!isPlainObject(choice)) continue;\n const delta = choice.delta;\n if (!isPlainObject(delta)) continue;\n\n const opaque = delta.reasoning_opaque;\n if (typeof opaque !== \"string\" || opaque.length === 0) continue;\n\n // Already carries the encrypted detail (don't double-inject / clobber).\n if (Array.isArray(delta.reasoning_details) && delta.reasoning_details.length > 0) {\n continue;\n }\n\n const toolCalls = delta.tool_calls;\n if (!Array.isArray(toolCalls)) continue;\n const idBearing = toolCalls.find(\n (call): call is JsonObject =>\n isPlainObject(call) && typeof call.id === \"string\" && call.id.length > 0,\n );\n if (!idBearing) continue;\n\n delta.reasoning_details = [\n { type: REASONING_ENCRYPTED_TYPE, id: idBearing.id as string, data: opaque },\n ];\n mutated = true;\n }\n return mutated;\n}\n\n/**\n * Rewrite the JSON payload of a single SSE `data:` line. Returns the original\n * string unchanged when it is not a Gemini chunk that needs a thought signature\n * bridged, or when parsing fails (fail-open: never corrupt the stream).\n */\nexport function rewriteCopilotGeminiSseData(dataPayload: string): string {\n // Cheap gate: only chunks that actually carry a thought signature are touched.\n if (!dataPayload.includes(\"reasoning_opaque\")) return dataPayload;\n let parsed: JsonValue;\n try {\n parsed = JSON.parse(dataPayload) as JsonValue;\n } catch {\n return dataPayload;\n }\n if (!injectCopilotGeminiReasoningDetails(parsed)) return dataPayload;\n return JSON.stringify(parsed);\n}\n\n/** Rewrite one SSE line, preserving a trailing carriage return when present. */\nfunction rewriteSseLine(line: string): string {\n const hasCr = line.endsWith(\"\\r\");\n const core = hasCr ? line.slice(0, -1) : line;\n if (!core.startsWith(\"data:\")) return line;\n const payload = core.slice(\"data:\".length).trimStart();\n if (payload.length === 0 || payload === \"[DONE]\") return line;\n const rewritten = rewriteCopilotGeminiSseData(payload);\n if (rewritten === payload) return line;\n const rebuilt = `data: ${rewritten}`;\n return hasCr ? `${rebuilt}\\r` : rebuilt;\n}\n\n/**\n * Wrap a CAPI Gemini SSE byte stream so `reasoning_opaque` is bridged into\n * `reasoning_details`. Buffers across chunk boundaries and rewrites whole lines\n * only; bytes that are not affected pass through unchanged.\n *\n * Implemented as a `ReadableStream` over the source reader (rather than a\n * `TransformStream` piped via `pipeThrough`) so the transform pulls lazily and\n * propagates cancellation to the upstream body.\n */\nexport function createCopilotGeminiSseStream(\n source: ReadableStream<Uint8Array>,\n): ReadableStream<Uint8Array> {\n const reader = source.getReader();\n const decoder = new TextDecoder();\n const encoder = new TextEncoder();\n let buffer = \"\";\n\n return new ReadableStream<Uint8Array>({\n async pull(controller) {\n // Loop until we emit at least one chunk or close, so a read that yields no\n // complete line still makes progress without relying on the runtime to\n // re-invoke pull after a no-enqueue return.\n for (;;) {\n const { done, value } = await reader.read();\n if (done) {\n buffer += decoder.decode();\n if (buffer.length > 0) {\n controller.enqueue(encoder.encode(rewriteSseLine(buffer)));\n buffer = \"\";\n }\n controller.close();\n return;\n }\n buffer += decoder.decode(value, { stream: true });\n let newlineIndex = buffer.indexOf(\"\\n\");\n let out = \"\";\n while (newlineIndex !== -1) {\n const line = buffer.slice(0, newlineIndex);\n buffer = buffer.slice(newlineIndex + 1);\n out += `${rewriteSseLine(line)}\\n`;\n newlineIndex = buffer.indexOf(\"\\n\");\n }\n if (out.length > 0) {\n controller.enqueue(encoder.encode(out));\n return;\n }\n }\n },\n cancel(reason) {\n return reader.cancel(reason);\n },\n });\n}\n\n/**\n * Convert the `reasoning_details` the pi-ai client re-emits on replayed\n * assistant messages back into the single `reasoning_opaque` field CAPI reads.\n *\n * For GitHub Copilot Gemini payloads, each assistant message that carries a\n * `reasoning_details` entry of `type: \"reasoning.encrypted\"` has its `data`\n * (the original CAPI thought-signature blob) promoted to `reasoning_opaque`,\n * and the now-redundant `reasoning_details` removed. No-op for every other\n * provider/model and for payloads without such messages.\n */\nexport function restoreCopilotGeminiReasoningOpaque(\n payload: unknown,\n model: Pick<Model<Api>, \"provider\" | \"api\" | \"id\">,\n): unknown {\n if (!isCopilotGeminiModel(model)) return payload;\n if (!isPlainObject(payload as JsonValue)) return payload;\n const payloadObject = payload as JsonObject;\n const messages = payloadObject.messages;\n if (!Array.isArray(messages)) return payload;\n\n let mutated = false;\n const nextMessages = messages.map((message) => {\n if (!isPlainObject(message) || message.role !== \"assistant\") return message;\n const details = message.reasoning_details;\n if (!Array.isArray(details) || details.length === 0) return message;\n const encrypted = details.find(\n (detail): detail is JsonObject =>\n isPlainObject(detail) &&\n detail.type === REASONING_ENCRYPTED_TYPE &&\n typeof detail.data === \"string\" &&\n detail.data.length > 0,\n );\n if (!encrypted) return message;\n mutated = true;\n const { reasoning_details: _omitted, ...rest } = message;\n return { ...rest, reasoning_opaque: encrypted.data as string };\n });\n\n if (!mutated) return payload;\n return { ...payloadObject, messages: nextMessages };\n}\n\n/** Resolve the request URL string from a `fetch` input argument. */\nfunction resolveRequestUrl(input: Parameters<typeof fetch>[0]): string | undefined {\n if (typeof input === \"string\") return input;\n if (input instanceof URL) return input.href;\n if (typeof input === \"object\" && input !== null && \"url\" in input) {\n const url = (input as { url?: unknown }).url;\n if (typeof url === \"string\") return url;\n }\n return undefined;\n}\n\n/**\n * Rewrite a streaming CAPI Gemini response so its SSE body bridges\n * `reasoning_opaque` into `reasoning_details`. Returns the original response\n * untouched for non-Copilot hosts, non-event-stream responses, or bodyless\n * responses, keeping the blast radius to streaming CAPI Gemini turns only.\n */\nexport function maybeRewriteCopilotGeminiResponse(\n url: string | undefined,\n response: Response,\n): Response {\n if (!url || !isCopilotApiHost(url)) return response;\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n if (!contentType.includes(\"text/event-stream\")) return response;\n if (!response.body) return response;\n const transformed = createCopilotGeminiSseStream(response.body);\n return new Response(transformed, {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n });\n}\n\n/**\n * Apply Copilot response-body transforms before pi-ai parses streamed provider\n * output. Anthropic Messages repair gets first refusal for `/v1/messages`\n * streams; other Copilot event streams keep the existing Gemini reasoning bridge.\n */\nexport function maybeRewriteCopilotProviderResponse(\n url: string | undefined,\n response: Response,\n): Response {\n const anthropicRepaired = maybeRepairCopilotAnthropicMessagesResponse(url, response);\n if (anthropicRepaired !== response) return anthropicRepaired;\n return maybeRewriteCopilotGeminiResponse(url, response);\n}\n\nlet originalFetch: typeof fetch | undefined;\n\n/**\n * Install a `globalThis.fetch` wrapper that applies Copilot-only stream\n * compatibility shims before pi-ai parses provider output. Currently this\n * includes the Gemini `reasoning_opaque` bridge and the Anthropic Messages\n * terminal `message_stop` repair. Idempotent.\n *\n * SDK clients resolve `globalThis.fetch` at client-construction time, and a new\n * client is built per request, so wrapping the global before the first request\n * is reliably picked up. Non-Copilot hosts and non-event-stream responses are\n * returned untouched by the underlying shims.\n */\nexport function installCopilotResponseInterceptor(): void {\n if (originalFetch) return;\n if (typeof globalThis.fetch !== \"function\") return;\n const base = globalThis.fetch;\n originalFetch = base;\n const boundFetch = base.bind(globalThis);\n\n const wrapped = (async (input, init) => {\n const response = await boundFetch(input, init);\n try {\n return maybeRewriteCopilotProviderResponse(resolveRequestUrl(input), response);\n } catch {\n return response;\n }\n }) as typeof fetch;\n\n // Preserve `fetch.preconnect` so the wrapper remains a drop-in replacement.\n const preconnect = (base as { preconnect?: unknown }).preconnect;\n if (typeof preconnect === \"function\") {\n (wrapped as { preconnect?: unknown }).preconnect = preconnect.bind(globalThis);\n }\n\n globalThis.fetch = wrapped;\n}\n\n/** Backward-compatible name for the original Gemini-only interceptor export. */\nexport function installCopilotGeminiReasoningInterceptor(): void {\n installCopilotResponseInterceptor();\n}\n"]}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { maybeRepairCopilotAnthropicMessagesResponse } from "./copilot-anthropic-sse-repair.js";
|
|
2
|
+
import { isCopilotApiHost } from "./copilot-hosts.js";
|
|
1
3
|
import { isCopilotGeminiModel } from "./copilot-gemini-payload-sanitizer.js";
|
|
2
4
|
/** OpenRouter-style encrypted reasoning detail the pi-ai client round-trips. */
|
|
3
5
|
const REASONING_ENCRYPTED_TYPE = "reasoning.encrypted";
|
|
@@ -175,18 +177,6 @@ export function restoreCopilotGeminiReasoningOpaque(payload, model) {
|
|
|
175
177
|
return payload;
|
|
176
178
|
return { ...payloadObject, messages: nextMessages };
|
|
177
179
|
}
|
|
178
|
-
/** Whether the URL targets Copilot's CAPI gateway (`*.githubcopilot.com`). */
|
|
179
|
-
function isCopilotApiHost(url) {
|
|
180
|
-
try {
|
|
181
|
-
const host = new URL(url).hostname.toLowerCase();
|
|
182
|
-
// Exact host or a real subdomain only — never a look-alike suffix such as
|
|
183
|
-
// `notgithubcopilot.com` (CodeQL: incomplete URL substring sanitization).
|
|
184
|
-
return host === "githubcopilot.com" || host.endsWith(".githubcopilot.com");
|
|
185
|
-
}
|
|
186
|
-
catch {
|
|
187
|
-
return false;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
180
|
/** Resolve the request URL string from a `fetch` input argument. */
|
|
191
181
|
function resolveRequestUrl(input) {
|
|
192
182
|
if (typeof input === "string")
|
|
@@ -221,19 +211,30 @@ export function maybeRewriteCopilotGeminiResponse(url, response) {
|
|
|
221
211
|
headers: response.headers,
|
|
222
212
|
});
|
|
223
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* Apply Copilot response-body transforms before pi-ai parses streamed provider
|
|
216
|
+
* output. Anthropic Messages repair gets first refusal for `/v1/messages`
|
|
217
|
+
* streams; other Copilot event streams keep the existing Gemini reasoning bridge.
|
|
218
|
+
*/
|
|
219
|
+
export function maybeRewriteCopilotProviderResponse(url, response) {
|
|
220
|
+
const anthropicRepaired = maybeRepairCopilotAnthropicMessagesResponse(url, response);
|
|
221
|
+
if (anthropicRepaired !== response)
|
|
222
|
+
return anthropicRepaired;
|
|
223
|
+
return maybeRewriteCopilotGeminiResponse(url, response);
|
|
224
|
+
}
|
|
224
225
|
let originalFetch;
|
|
225
226
|
/**
|
|
226
|
-
* Install a `globalThis.fetch` wrapper that
|
|
227
|
-
*
|
|
228
|
-
*
|
|
227
|
+
* Install a `globalThis.fetch` wrapper that applies Copilot-only stream
|
|
228
|
+
* compatibility shims before pi-ai parses provider output. Currently this
|
|
229
|
+
* includes the Gemini `reasoning_opaque` bridge and the Anthropic Messages
|
|
230
|
+
* terminal `message_stop` repair. Idempotent.
|
|
229
231
|
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
* keeping the blast radius to streaming CAPI Gemini turns only.
|
|
232
|
+
* SDK clients resolve `globalThis.fetch` at client-construction time, and a new
|
|
233
|
+
* client is built per request, so wrapping the global before the first request
|
|
234
|
+
* is reliably picked up. Non-Copilot hosts and non-event-stream responses are
|
|
235
|
+
* returned untouched by the underlying shims.
|
|
235
236
|
*/
|
|
236
|
-
export function
|
|
237
|
+
export function installCopilotResponseInterceptor() {
|
|
237
238
|
if (originalFetch)
|
|
238
239
|
return;
|
|
239
240
|
if (typeof globalThis.fetch !== "function")
|
|
@@ -244,7 +245,7 @@ export function installCopilotGeminiReasoningInterceptor() {
|
|
|
244
245
|
const wrapped = (async (input, init) => {
|
|
245
246
|
const response = await boundFetch(input, init);
|
|
246
247
|
try {
|
|
247
|
-
return
|
|
248
|
+
return maybeRewriteCopilotProviderResponse(resolveRequestUrl(input), response);
|
|
248
249
|
}
|
|
249
250
|
catch {
|
|
250
251
|
return response;
|
|
@@ -257,4 +258,8 @@ export function installCopilotGeminiReasoningInterceptor() {
|
|
|
257
258
|
}
|
|
258
259
|
globalThis.fetch = wrapped;
|
|
259
260
|
}
|
|
261
|
+
/** Backward-compatible name for the original Gemini-only interceptor export. */
|
|
262
|
+
export function installCopilotGeminiReasoningInterceptor() {
|
|
263
|
+
installCopilotResponseInterceptor();
|
|
264
|
+
}
|
|
260
265
|
//# sourceMappingURL=copilot-gemini-reasoning.js.map
|