@cortexkit/opencode-magic-context 0.41.4 → 0.42.1
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/README.md +21 -3
- package/dist/agents/hidden-agent-registrations.d.ts +1 -3
- package/dist/agents/hidden-agent-registrations.d.ts.map +1 -1
- package/dist/agents/magic-context-prompt.d.ts +1 -1
- package/dist/agents/magic-context-prompt.d.ts.map +1 -1
- package/dist/agents/permissions.d.ts +1 -22
- package/dist/agents/permissions.d.ts.map +1 -1
- package/dist/config/agent-disable.d.ts +0 -5
- package/dist/config/agent-disable.d.ts.map +1 -1
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/migrate-config-location.d.ts.map +1 -1
- package/dist/config/project-security.d.ts +20 -2
- package/dist/config/project-security.d.ts.map +1 -1
- package/dist/config/removed-agent-config.d.ts +8 -0
- package/dist/config/removed-agent-config.d.ts.map +1 -0
- package/dist/config/schema/magic-context.d.ts +43 -201
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/{conflict-warning-hook-ejkc9sjn.js → conflict-warning-hook-6p3xqeac.js} +3 -3
- package/dist/{derive-budgets-bc366cz8.js → derive-budgets-s2pgnnm4.js} +1 -1
- package/dist/features/builtin-commands/commands.d.ts +0 -4
- package/dist/features/builtin-commands/commands.d.ts.map +1 -1
- package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts +15 -4
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
- package/dist/features/magic-context/compartment-storage.d.ts.map +1 -1
- package/dist/features/magic-context/context-authority.d.ts +31 -4
- package/dist/features/magic-context/context-authority.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/classify.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/evaluate-smart-notes.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/open-opencode-db.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/refresh-primers.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/retrospective-orphan-sweep.d.ts +19 -9
- package/dist/features/magic-context/dreamer/retrospective-orphan-sweep.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts +4 -0
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
- package/dist/features/magic-context/fail-closed-block.d.ts.map +1 -1
- package/dist/features/magic-context/git-commits/sweep-coordinator.d.ts.map +1 -1
- package/dist/features/magic-context/index.d.ts +0 -1
- package/dist/features/magic-context/index.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-identity.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-local.d.ts +13 -0
- package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-model-match.d.ts +41 -0
- package/dist/features/magic-context/memory/embedding-model-match.d.ts.map +1 -0
- package/dist/features/magic-context/memory/embedding-openai.d.ts +7 -20
- package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-provider.d.ts +2 -2
- package/dist/features/magic-context/memory/embedding-provider.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-synapse.d.ts +48 -14
- package/dist/features/magic-context/memory/embedding-synapse.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding.d.ts +1 -1
- package/dist/features/magic-context/memory/embedding.d.ts.map +1 -1
- package/dist/features/magic-context/memory/memory-migration.d.ts.map +1 -1
- package/dist/features/magic-context/memory/project-identity.d.ts +1 -0
- package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
- package/dist/features/magic-context/memory/promotion.d.ts +7 -1
- package/dist/features/magic-context/memory/promotion.d.ts.map +1 -1
- package/dist/features/magic-context/merged-reasoning-decisions.d.ts +6 -0
- package/dist/features/magic-context/merged-reasoning-decisions.d.ts.map +1 -0
- package/dist/features/magic-context/message-fts-rowid-map.d.ts.map +1 -1
- package/dist/features/magic-context/message-index-async.d.ts +12 -0
- package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
- package/dist/features/magic-context/message-index.d.ts.map +1 -1
- package/dist/features/magic-context/migrations.d.ts.map +1 -1
- package/dist/features/magic-context/mural/compress-cues.d.ts.map +1 -1
- package/dist/features/magic-context/mural/render-trigger.d.ts +6 -0
- package/dist/features/magic-context/mural/render-trigger.d.ts.map +1 -1
- package/dist/features/magic-context/no-content-compartment.d.ts +12 -0
- package/dist/features/magic-context/no-content-compartment.d.ts.map +1 -0
- package/dist/features/magic-context/pi-content-decisions.d.ts +9 -0
- package/dist/features/magic-context/pi-content-decisions.d.ts.map +1 -0
- package/dist/features/magic-context/project-docs-hash.d.ts +4 -0
- package/dist/features/magic-context/project-docs-hash.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts +13 -4
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/protection-window.d.ts +79 -0
- package/dist/features/magic-context/protection-window.d.ts.map +1 -0
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/features/magic-context/session-project-backfill.d.ts.map +1 -1
- package/dist/features/magic-context/shadow-backfill-state.d.ts +26 -0
- package/dist/features/magic-context/shadow-backfill-state.d.ts.map +1 -0
- package/dist/features/magic-context/smart-notes/compiler.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/sandbox-runner.d.ts +4 -0
- package/dist/features/magic-context/smart-notes/sandbox-runner.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/storage.d.ts.map +1 -1
- package/dist/features/magic-context/storage-clone.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts +1 -1
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-embedding-measurements.d.ts +2 -2
- package/dist/features/magic-context/storage-embedding-measurements.d.ts.map +1 -1
- package/dist/features/magic-context/storage-historian-runs.d.ts +4 -0
- package/dist/features/magic-context/storage-historian-runs.d.ts.map +1 -1
- package/dist/features/magic-context/storage-memory-mutation-log.d.ts +1 -0
- package/dist/features/magic-context/storage-memory-mutation-log.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +79 -13
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta.d.ts +1 -1
- package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
- package/dist/features/magic-context/storage-native-replay.d.ts +29 -0
- package/dist/features/magic-context/storage-native-replay.d.ts.map +1 -0
- package/dist/features/magic-context/storage-notes.d.ts +6 -0
- package/dist/features/magic-context/storage-notes.d.ts.map +1 -1
- package/dist/features/magic-context/storage-replay-document.d.ts +33 -0
- package/dist/features/magic-context/storage-replay-document.d.ts.map +1 -0
- package/dist/features/magic-context/storage-subagent-invocations.d.ts +1 -1
- package/dist/features/magic-context/storage-subagent-invocations.d.ts.map +1 -1
- package/dist/features/magic-context/storage-tags.d.ts +19 -11
- package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
- package/dist/features/magic-context/storage.d.ts +3 -3
- package/dist/features/magic-context/storage.d.ts.map +1 -1
- package/dist/features/magic-context/subagent-token-capture.d.ts.map +1 -1
- package/dist/features/magic-context/tagger.d.ts +13 -0
- package/dist/features/magic-context/tagger.d.ts.map +1 -1
- package/dist/features/magic-context/tool-owner-backfill.d.ts.map +1 -1
- package/dist/features/magic-context/user-memory/review-user-memories.d.ts.map +1 -1
- package/dist/features/magic-context/user-memory/storage-user-memory.d.ts.map +1 -1
- package/dist/features/magic-context/workspaces.d.ts.map +1 -1
- package/dist/hooks/magic-context/apply-operations.d.ts +11 -5
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/cache-busting-signals.d.ts +9 -1
- package/dist/hooks/magic-context/cache-busting-signals.d.ts.map +1 -1
- package/dist/hooks/magic-context/caveman-cleanup.d.ts +1 -1
- package/dist/hooks/magic-context/caveman-cleanup.d.ts.map +1 -1
- package/dist/hooks/magic-context/channel2-delivery.d.ts.map +1 -1
- package/dist/hooks/magic-context/child-session-spawn.d.ts +3 -3
- package/dist/hooks/magic-context/child-session-spawn.d.ts.map +1 -1
- package/dist/hooks/magic-context/command-handler.d.ts +1 -10
- package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-drop-queue.d.ts +10 -21
- package/dist/hooks/magic-context/compartment-runner-drop-queue.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-partial-recomp.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts +1 -1
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
- package/dist/hooks/magic-context/ctx-reduce-nudge.d.ts +26 -2
- package/dist/hooks/magic-context/ctx-reduce-nudge.d.ts.map +1 -1
- package/dist/hooks/magic-context/decay-render.d.ts.map +1 -1
- package/dist/hooks/magic-context/dropped-input-guard.d.ts +9 -0
- package/dist/hooks/magic-context/dropped-input-guard.d.ts.map +1 -0
- package/dist/hooks/magic-context/embed-session-state.d.ts +1 -1
- package/dist/hooks/magic-context/embed-session-state.d.ts.map +1 -1
- package/dist/hooks/magic-context/emergency-drop.d.ts +6 -1
- package/dist/hooks/magic-context/emergency-drop.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-handler.d.ts +0 -1
- package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-payloads.d.ts +7 -6
- package/dist/hooks/magic-context/event-payloads.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-resolvers.d.ts +1 -1
- package/dist/hooks/magic-context/event-resolvers.d.ts.map +1 -1
- package/dist/hooks/magic-context/execute-status.d.ts +3 -1
- package/dist/hooks/magic-context/execute-status.d.ts.map +1 -1
- package/dist/hooks/magic-context/format-embed-failure.d.ts +2 -1
- package/dist/hooks/magic-context/format-embed-failure.d.ts.map +1 -1
- package/dist/hooks/magic-context/format-embed-status.d.ts.map +1 -1
- package/dist/hooks/magic-context/heuristic-cleanup.d.ts +7 -1
- package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook-handlers.d.ts +3 -1
- package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts +13 -4
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts +14 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/live-session-state.d.ts +1 -1
- package/dist/hooks/magic-context/lkg-slot.d.ts +34 -0
- package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
- package/dist/hooks/magic-context/maintenance-authority.d.ts +2 -2
- package/dist/hooks/magic-context/maintenance-authority.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-state-sync-timing.d.ts +21 -0
- package/dist/hooks/magic-context/module-state-sync-timing.d.ts.map +1 -0
- package/dist/hooks/magic-context/module-state-sync.d.ts +21 -7
- package/dist/hooks/magic-context/module-state-sync.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-transport.d.ts +12 -0
- package/dist/hooks/magic-context/module-transport.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-wire.d.ts +8 -0
- package/dist/hooks/magic-context/module-wire.d.ts.map +1 -1
- package/dist/hooks/magic-context/note-nudger.d.ts.map +1 -1
- package/dist/hooks/magic-context/persist-filtered-noise.d.ts +5 -0
- package/dist/hooks/magic-context/persist-filtered-noise.d.ts.map +1 -0
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts +6 -0
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts +18 -18
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-db.d.ts +22 -12
- package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-formatting.d.ts +8 -0
- package/dist/hooks/magic-context/read-session-formatting.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-raw.d.ts +10 -1
- package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
- package/dist/hooks/magic-context/reference-retrieval.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts +74 -9
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/send-session-notification.d.ts +11 -10
- package/dist/hooks/magic-context/send-session-notification.d.ts.map +1 -1
- package/dist/hooks/magic-context/strip-content.d.ts +7 -0
- package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
- package/dist/hooks/magic-context/supersession-reclaim.d.ts +13 -0
- package/dist/hooks/magic-context/supersession-reclaim.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-prompt-hash.d.ts +2 -3
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts +8 -3
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts.map +1 -1
- package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-context-state.d.ts +7 -1
- package/dist/hooks/magic-context/transform-context-state.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +11 -4
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +7 -2
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/upgrade-reminder.d.ts +7 -9
- package/dist/hooks/magic-context/upgrade-reminder.d.ts.map +1 -1
- package/dist/hooks/magic-context/wrapup-orchestrator.d.ts.map +1 -1
- package/dist/index-1974jvn3.js +783 -0
- package/dist/{index-0y2mcg5y.js → index-1q9kay7n.js} +18717 -16197
- package/dist/{index-4avmwfp5.js → index-36wd1d6k.js} +6 -29
- package/dist/{index-fz104x1j.js → index-jmtjh2d3.js} +3 -3
- package/dist/{index-q264erdp.js → index-nqgjwfzn.js} +70 -38
- package/dist/{index-mjv9je4e.js → index-xdtge3y2.js} +45 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6457 -5190
- package/dist/plugin/conflict-warning-hook.d.ts +5 -6
- package/dist/plugin/conflict-warning-hook.d.ts.map +1 -1
- package/dist/plugin/dream-timer.d.ts +1 -0
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/embedding-bootstrap-helpers.d.ts.map +1 -1
- package/dist/plugin/embedding-routing.d.ts +4 -1
- package/dist/plugin/embedding-routing.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts +16 -2
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/rpc-handlers.d.ts +31 -1
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/plugin/rust-tool-backends.d.ts +1 -0
- package/dist/plugin/rust-tool-backends.d.ts.map +1 -1
- package/dist/plugin/tool-registry.d.ts.map +1 -1
- package/dist/{recomp-orchestrator-q98r6rga.js → recomp-orchestrator-m33b3rk9.js} +5 -5
- package/dist/{send-session-notification-hdh02wy9.js → send-session-notification-1qeqkswb.js} +6 -4
- package/dist/shared/child-session-teardown.d.ts +34 -0
- package/dist/shared/child-session-teardown.d.ts.map +1 -0
- package/dist/shared/keep-subagents.d.ts +1 -1
- package/dist/shared/keep-subagents.d.ts.map +1 -1
- package/dist/shared/model-suggestion-retry.d.ts +1 -1
- package/dist/shared/opencode-db-path.d.ts +24 -0
- package/dist/shared/opencode-db-path.d.ts.map +1 -0
- package/dist/shared/prompt-surface-runtime.d.ts +10 -5
- package/dist/shared/prompt-surface-runtime.d.ts.map +1 -1
- package/dist/shared/resolve-fallbacks.d.ts +1 -1
- package/dist/shared/rpc-types.d.ts +121 -0
- package/dist/shared/rpc-types.d.ts.map +1 -1
- package/dist/shared/sqlite.d.ts +42 -0
- package/dist/shared/sqlite.d.ts.map +1 -1
- package/dist/shared/status-detail-text.d.ts +3 -1
- package/dist/shared/status-detail-text.d.ts.map +1 -1
- package/dist/shared/status-summary.d.ts +30 -0
- package/dist/shared/status-summary.d.ts.map +1 -0
- package/dist/shared/subagent-runner.d.ts +17 -10
- package/dist/shared/subagent-runner.d.ts.map +1 -1
- package/dist/shared/tag-transcript.d.ts.map +1 -1
- package/dist/shared/tail-hygiene-status.d.ts +1 -0
- package/dist/shared/tail-hygiene-status.d.ts.map +1 -1
- package/dist/shared/transcript.d.ts +6 -0
- package/dist/shared/transcript.d.ts.map +1 -1
- package/dist/shared/user-facing-codes.d.ts +191 -0
- package/dist/shared/user-facing-codes.d.ts.map +1 -0
- package/dist/shared/window-geometry.d.ts +23 -0
- package/dist/shared/window-geometry.d.ts.map +1 -1
- package/dist/shared/write-transaction-timing.d.ts +1 -1
- package/dist/shared/write-transaction-timing.d.ts.map +1 -1
- package/dist/{storage-meta-session-dvwfw778.js → storage-meta-session-e6g0mmec.js} +2 -2
- package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
- package/dist/tools/ctx-memory/verification-recording.d.ts.map +1 -1
- package/dist/tools/ctx-note/constants.d.ts +1 -1
- package/dist/tools/ctx-note/constants.d.ts.map +1 -1
- package/dist/tools/ctx-note/tools.d.ts.map +1 -1
- package/dist/tools/ctx-note/types.d.ts +1 -0
- package/dist/tools/ctx-note/types.d.ts.map +1 -1
- package/dist/tools/ctx-reduce/tools.d.ts +10 -1
- package/dist/tools/ctx-reduce/tools.d.ts.map +1 -1
- package/dist/tools/ctx-search/constants.d.ts +1 -1
- package/dist/tools/ctx-search/constants.d.ts.map +1 -1
- package/dist/tools/light-descriptions.d.ts +2 -2
- package/dist/tools/light-descriptions.d.ts.map +1 -1
- package/package.json +2 -3
- package/src/agents/hidden-agent-registrations.ts +3 -15
- package/src/agents/magic-context-prompt.test.ts +7 -5
- package/src/agents/magic-context-prompt.ts +22 -30
- package/src/agents/permissions.test.ts +1 -42
- package/src/agents/permissions.ts +1 -24
- package/src/config/agent-disable.ts +5 -22
- package/src/config/index.test.ts +126 -15
- package/src/config/index.ts +41 -6
- package/src/config/latch-permanence-guard.test.ts +4 -0
- package/src/config/migrate-config-location.test.ts +39 -6
- package/src/config/migrate-config-location.ts +18 -31
- package/src/config/profiles.ts +1 -1
- package/src/config/project-security.hostile-matrix.test.ts +0 -8
- package/src/config/project-security.test.ts +21 -24
- package/src/config/project-security.ts +115 -14
- package/src/config/protected-tokens.test.ts +235 -0
- package/src/config/removed-agent-config.ts +45 -0
- package/src/config/removed-agent-source-fence.test.ts +56 -0
- package/src/config/schema/magic-context.test.ts +50 -42
- package/src/config/schema/magic-context.ts +70 -37
- package/src/shared/child-session-teardown.test.ts +218 -0
- package/src/shared/child-session-teardown.ts +66 -0
- package/src/shared/keep-subagents.ts +9 -14
- package/src/shared/model-suggestion-retry.ts +1 -1
- package/src/shared/opencode-db-path.test.ts +196 -0
- package/src/shared/opencode-db-path.ts +215 -0
- package/src/shared/prompt-surface-a1-golden.md +50 -35
- package/src/shared/prompt-surface-runtime.test.ts +28 -0
- package/src/shared/prompt-surface-runtime.ts +22 -5
- package/src/shared/resolve-fallbacks.ts +1 -1
- package/src/shared/rpc-types.ts +128 -0
- package/src/shared/session-messages-bounded.test.ts +1 -1
- package/src/shared/sqlite-import-fence.test.ts +19 -0
- package/src/shared/sqlite.test.ts +27 -1
- package/src/shared/sqlite.ts +204 -1
- package/src/shared/status-detail-text.test.ts +92 -20
- package/src/shared/status-detail-text.ts +24 -2
- package/src/shared/status-summary.ts +167 -0
- package/src/shared/subagent-runner.ts +17 -10
- package/src/shared/tag-transcript.ts +33 -21
- package/src/shared/tail-hygiene-status.ts +8 -0
- package/src/shared/transcript.ts +7 -0
- package/src/shared/user-facing-codes.test.ts +140 -0
- package/src/shared/user-facing-codes.ts +276 -0
- package/src/shared/window-geometry.test.ts +44 -0
- package/src/shared/window-geometry.ts +89 -11
- package/src/shared/write-transaction-attribution.test.ts +241 -0
- package/src/shared/write-transaction-timing.ts +2 -1
- package/src/tui/index.tsx +44 -11
- package/src/tui/slots/sidebar-content.tsx +12 -7
- package/src/tui-compiled/index.tsx +662 -649
- package/src/tui-compiled/slots/sidebar-content.tsx +301 -305
- package/dist/agents/sidekick.d.ts +0 -2
- package/dist/agents/sidekick.d.ts.map +0 -1
- package/dist/features/magic-context/defaults.d.ts +0 -2
- package/dist/features/magic-context/defaults.d.ts.map +0 -1
- package/dist/features/magic-context/sidekick/agent.d.ts +0 -14
- package/dist/features/magic-context/sidekick/agent.d.ts.map +0 -1
- package/dist/features/magic-context/sidekick/core.d.ts +0 -38
- package/dist/features/magic-context/sidekick/core.d.ts.map +0 -1
- package/dist/features/magic-context/sidekick/index.d.ts +0 -3
- package/dist/features/magic-context/sidekick/index.d.ts.map +0 -1
- package/dist/hooks/magic-context/boundary-execution.d.ts +0 -27
- package/dist/hooks/magic-context/boundary-execution.d.ts.map +0 -1
- package/dist/index-raatkvw5.js +0 -360
- package/src/agents/sidekick.ts +0 -1
- package/src/features/magic-context/defaults.ts +0 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import type { DreamRunFailureClass } from "../features/magic-context/dreamer/storage-dream-runs";
|
|
5
|
+
import type { EmbeddingFailureClass } from "../features/magic-context/memory/embedding-failure";
|
|
6
|
+
import {
|
|
7
|
+
type CapabilityRefusal,
|
|
8
|
+
dreamFailureCode,
|
|
9
|
+
embeddingFailureCode,
|
|
10
|
+
renderCapabilityRefusal,
|
|
11
|
+
renderDreamFailure,
|
|
12
|
+
renderEmbeddingFailure,
|
|
13
|
+
renderUserFacingFailure,
|
|
14
|
+
USER_FACING_FAILURES,
|
|
15
|
+
} from "./user-facing-codes";
|
|
16
|
+
|
|
17
|
+
const DREAM_CLASSES: DreamRunFailureClass[] = [
|
|
18
|
+
"provider_timeout",
|
|
19
|
+
"provider_error",
|
|
20
|
+
"empty_completion",
|
|
21
|
+
"no_models",
|
|
22
|
+
"child_aborted",
|
|
23
|
+
"parse_failed",
|
|
24
|
+
"unknown",
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const EMBEDDING_CLASSES: EmbeddingFailureClass[] = [
|
|
28
|
+
"substitution_rejected",
|
|
29
|
+
"http_error",
|
|
30
|
+
"transport_error",
|
|
31
|
+
"invalid_envelope",
|
|
32
|
+
"empty_result",
|
|
33
|
+
"certification_refusal",
|
|
34
|
+
"credential_required",
|
|
35
|
+
"local_binding_missing",
|
|
36
|
+
"local_fs_unavailable",
|
|
37
|
+
"local_download_failure",
|
|
38
|
+
"local_runtime_error",
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
describe("user-facing failure codes", () => {
|
|
42
|
+
test("keeps the closed table unique and renders one calm sentence plus one action", () => {
|
|
43
|
+
const entries = Object.values(USER_FACING_FAILURES);
|
|
44
|
+
expect(new Set(entries.map((entry) => entry.code)).size).toBe(entries.length);
|
|
45
|
+
for (const [key, entry] of Object.entries(USER_FACING_FAILURES)) {
|
|
46
|
+
expect(entry.code).toMatch(/^MC-[CHDERS]\d{2}$/);
|
|
47
|
+
expect(entry.sentence).toEndWith(".");
|
|
48
|
+
expect(entry.action).toEndWith(".");
|
|
49
|
+
expect(renderUserFacingFailure(key as keyof typeof USER_FACING_FAILURES)).toBe(
|
|
50
|
+
`${entry.sentence} ${entry.action} (${entry.code})`,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("uses actionable command and configuration guidance in markdown and plain text", () => {
|
|
56
|
+
expect(renderEmbeddingFailure("local_binding_missing")).toContain(
|
|
57
|
+
"Run `npx @cortexkit/magic-context doctor`, then retry. (MC-E08)",
|
|
58
|
+
);
|
|
59
|
+
expect(renderEmbeddingFailure("local_runtime_error", "plain")).toContain(
|
|
60
|
+
"Run npx @cortexkit/magic-context doctor, then retry. (MC-E11)",
|
|
61
|
+
);
|
|
62
|
+
expect(renderEmbeddingFailure("local_runtime_error", "plain")).not.toContain("`");
|
|
63
|
+
expect(renderEmbeddingFailure("certification_refusal")).toContain(
|
|
64
|
+
"Finish the provider setup, or set a fallback provider in the embedding settings, then run /ctx-embed start again. (MC-E06)",
|
|
65
|
+
);
|
|
66
|
+
expect(renderUserFacingFailure("configuration_warning")).toContain(
|
|
67
|
+
"Fix the configuration warning shown in /ctx-status diagnostics, then restart. (MC-S03)",
|
|
68
|
+
);
|
|
69
|
+
expect(renderUserFacingFailure("session_upgrade_unavailable")).toContain(
|
|
70
|
+
"Run /ctx-recomp instead. (MC-C07)",
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test("maps every structured dream and embedding failure class", () => {
|
|
75
|
+
for (const failureClass of DREAM_CLASSES) {
|
|
76
|
+
expect(renderDreamFailure(failureClass)).toEndWith(
|
|
77
|
+
`(${dreamFailureCode(failureClass)})`,
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
for (const failureClass of EMBEDDING_CLASSES) {
|
|
81
|
+
expect(renderEmbeddingFailure(failureClass)).toEndWith(
|
|
82
|
+
`(${embeddingFailureCode(failureClass)})`,
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test("renders every capability refusal without internal vocabulary", () => {
|
|
88
|
+
const capabilities: CapabilityRefusal[] = [
|
|
89
|
+
"memory_write",
|
|
90
|
+
"memory_access",
|
|
91
|
+
"note_change",
|
|
92
|
+
"note_access",
|
|
93
|
+
"context_cleanup",
|
|
94
|
+
"partial_history",
|
|
95
|
+
"session_upgrade",
|
|
96
|
+
"smart_note_condition",
|
|
97
|
+
"history_compression",
|
|
98
|
+
"context_service",
|
|
99
|
+
];
|
|
100
|
+
for (const capability of capabilities) {
|
|
101
|
+
const rendered = renderCapabilityRefusal(capability);
|
|
102
|
+
expect(rendered).toMatch(/\(MC-C\d{2}\)$/);
|
|
103
|
+
for (const forbidden of ["authority", "MODULE", "drain", "facade", "changefeed"]) {
|
|
104
|
+
expect(rendered).not.toContain(forbidden);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
test("source fence keeps raw exceptions out of user-facing reply builders", () => {
|
|
110
|
+
const builders = [
|
|
111
|
+
"hooks/magic-context/command-handler.ts",
|
|
112
|
+
"hooks/magic-context/compartment-runner-validation.ts",
|
|
113
|
+
"hooks/magic-context/compartment-runner-recomp.ts",
|
|
114
|
+
"hooks/magic-context/compartment-runner-partial-recomp.ts",
|
|
115
|
+
"hooks/magic-context/format-embed-failure.ts",
|
|
116
|
+
"hooks/magic-context/recomp-orchestrator.ts",
|
|
117
|
+
"shared/status-detail-text.ts",
|
|
118
|
+
"../../pi-plugin/src/commands/ctx-dream.ts",
|
|
119
|
+
"../../pi-plugin/src/commands/ctx-status.ts",
|
|
120
|
+
];
|
|
121
|
+
const allowedLogFragments = ["command notification delivery failed", "/ctx-dream failed"];
|
|
122
|
+
const violations: string[] = [];
|
|
123
|
+
for (const relativePath of builders) {
|
|
124
|
+
const path = resolve(import.meta.dir, "..", relativePath);
|
|
125
|
+
const lines = readFileSync(path, "utf8").split("\n");
|
|
126
|
+
lines.forEach((line, index) => {
|
|
127
|
+
if (
|
|
128
|
+
!/(error\.message|String\((?:err|error)\)|describeError\([^)]*\)\.brief)/.test(
|
|
129
|
+
line,
|
|
130
|
+
)
|
|
131
|
+
) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (allowedLogFragments.some((fragment) => line.includes(fragment))) return;
|
|
135
|
+
violations.push(`${relativePath}:${index + 1}: ${line.trim()}`);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
expect(violations).toEqual([]);
|
|
139
|
+
});
|
|
140
|
+
});
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import type { EmbeddingFailureClass } from "../features/magic-context/memory/embedding-failure";
|
|
2
|
+
import type { PromptFailureClass } from "./model-suggestion-retry";
|
|
3
|
+
|
|
4
|
+
export const USER_FACING_FAILURES = {
|
|
5
|
+
historian_unavailable: {
|
|
6
|
+
code: "MC-H01",
|
|
7
|
+
sentence: "History compression could not finish this turn.",
|
|
8
|
+
action: "It will retry automatically.",
|
|
9
|
+
},
|
|
10
|
+
recomp_unavailable: {
|
|
11
|
+
code: "MC-R01",
|
|
12
|
+
sentence: "History compression could not be rebuilt.",
|
|
13
|
+
action: "Run /ctx-recomp again.",
|
|
14
|
+
},
|
|
15
|
+
dream_provider_timeout: {
|
|
16
|
+
code: "MC-D01",
|
|
17
|
+
sentence: "Memory maintenance took too long to respond.",
|
|
18
|
+
action: "Run /ctx-dream again.",
|
|
19
|
+
},
|
|
20
|
+
dream_provider_error: {
|
|
21
|
+
code: "MC-D02",
|
|
22
|
+
sentence: "Memory maintenance could not reach its model.",
|
|
23
|
+
action: "Check the model connection, then run /ctx-dream again.",
|
|
24
|
+
},
|
|
25
|
+
dream_empty_completion: {
|
|
26
|
+
code: "MC-D03",
|
|
27
|
+
sentence: "Memory maintenance received no usable response.",
|
|
28
|
+
action: "Run /ctx-dream again.",
|
|
29
|
+
},
|
|
30
|
+
dream_no_models: {
|
|
31
|
+
code: "MC-D04",
|
|
32
|
+
sentence: "Memory maintenance has no model available.",
|
|
33
|
+
action: "Check the model settings, then run /ctx-dream again.",
|
|
34
|
+
},
|
|
35
|
+
dream_child_aborted: {
|
|
36
|
+
code: "MC-D05",
|
|
37
|
+
sentence: "Memory maintenance was interrupted.",
|
|
38
|
+
action: "Run /ctx-dream again.",
|
|
39
|
+
},
|
|
40
|
+
dream_parse_failed: {
|
|
41
|
+
code: "MC-D06",
|
|
42
|
+
sentence: "Memory maintenance could not use the model response.",
|
|
43
|
+
action: "Run /ctx-dream again.",
|
|
44
|
+
},
|
|
45
|
+
dream_unknown: {
|
|
46
|
+
code: "MC-D07",
|
|
47
|
+
sentence: "Memory maintenance could not finish.",
|
|
48
|
+
action: "Run /ctx-dream again.",
|
|
49
|
+
},
|
|
50
|
+
embedding_substitution_rejected: {
|
|
51
|
+
code: "MC-E01",
|
|
52
|
+
sentence: "Search indexing could not use the selected model.",
|
|
53
|
+
action: "Check the embedding model setting, then run /ctx-embed start again.",
|
|
54
|
+
},
|
|
55
|
+
embedding_http_error: {
|
|
56
|
+
code: "MC-E02",
|
|
57
|
+
sentence: "The search indexing provider refused the request.",
|
|
58
|
+
action: "Check the provider connection and credentials, then run /ctx-embed start again.",
|
|
59
|
+
},
|
|
60
|
+
embedding_transport_error: {
|
|
61
|
+
code: "MC-E03",
|
|
62
|
+
sentence: "Search indexing could not reach its provider.",
|
|
63
|
+
action: "Check the connection, then run /ctx-embed start again.",
|
|
64
|
+
},
|
|
65
|
+
embedding_invalid_envelope: {
|
|
66
|
+
code: "MC-E04",
|
|
67
|
+
sentence: "Search indexing received an unsupported response.",
|
|
68
|
+
action: "Check the embedding endpoint, then run /ctx-embed start again.",
|
|
69
|
+
},
|
|
70
|
+
embedding_empty_result: {
|
|
71
|
+
code: "MC-E05",
|
|
72
|
+
sentence: "Search indexing received no usable result.",
|
|
73
|
+
action: "Run /ctx-embed start again.",
|
|
74
|
+
},
|
|
75
|
+
embedding_certification_refusal: {
|
|
76
|
+
code: "MC-E06",
|
|
77
|
+
sentence: "Search indexing is not ready for this provider.",
|
|
78
|
+
action: "Finish the provider setup, or set a fallback provider in the embedding settings, then run /ctx-embed start again.",
|
|
79
|
+
},
|
|
80
|
+
embedding_credential_required: {
|
|
81
|
+
code: "MC-E07",
|
|
82
|
+
sentence: "Search indexing needs provider credentials.",
|
|
83
|
+
action: "Sign in to the provider, then run /ctx-embed start again.",
|
|
84
|
+
},
|
|
85
|
+
embedding_local_binding_missing: {
|
|
86
|
+
code: "MC-E08",
|
|
87
|
+
sentence: "Local search indexing is unavailable on this system.",
|
|
88
|
+
action: "Run `npx @cortexkit/magic-context doctor`, then retry.",
|
|
89
|
+
},
|
|
90
|
+
embedding_local_fs_unavailable: {
|
|
91
|
+
code: "MC-E09",
|
|
92
|
+
sentence: "Local search indexing cannot save its model files.",
|
|
93
|
+
action: "Update or reinstall Magic Context, then retry.",
|
|
94
|
+
},
|
|
95
|
+
embedding_local_download_failure: {
|
|
96
|
+
code: "MC-E10",
|
|
97
|
+
sentence: "Local search indexing could not download its model.",
|
|
98
|
+
action: "Check the network connection, then retry.",
|
|
99
|
+
},
|
|
100
|
+
embedding_local_runtime_error: {
|
|
101
|
+
code: "MC-E11",
|
|
102
|
+
sentence: "Local search indexing could not start.",
|
|
103
|
+
action: "Run `npx @cortexkit/magic-context doctor`, then retry.",
|
|
104
|
+
},
|
|
105
|
+
embedding_unavailable: {
|
|
106
|
+
code: "MC-E12",
|
|
107
|
+
sentence: "Search indexing could not finish.",
|
|
108
|
+
action: "Run /ctx-embed start again.",
|
|
109
|
+
},
|
|
110
|
+
status_unavailable: {
|
|
111
|
+
code: "MC-S01",
|
|
112
|
+
sentence: "Magic Context status is temporarily unavailable.",
|
|
113
|
+
action: "Retry /ctx-status in a moment.",
|
|
114
|
+
},
|
|
115
|
+
transform_update_failed: {
|
|
116
|
+
code: "MC-S02",
|
|
117
|
+
sentence: "The last context update did not finish.",
|
|
118
|
+
action: "Send another message to retry.",
|
|
119
|
+
},
|
|
120
|
+
configuration_warning: {
|
|
121
|
+
code: "MC-S03",
|
|
122
|
+
sentence: "Some configuration settings could not be applied.",
|
|
123
|
+
action: "Fix the configuration warning shown in /ctx-status diagnostics, then restart.",
|
|
124
|
+
},
|
|
125
|
+
status_log_unavailable: {
|
|
126
|
+
code: "MC-S04",
|
|
127
|
+
sentence: "Some diagnostic details could not be saved.",
|
|
128
|
+
action: "Retry /ctx-status in a moment.",
|
|
129
|
+
},
|
|
130
|
+
memory_writes_paused: {
|
|
131
|
+
code: "MC-C01",
|
|
132
|
+
sentence: "Memory writes are paused while the engine syncs.",
|
|
133
|
+
action: "Retry in a moment.",
|
|
134
|
+
},
|
|
135
|
+
memory_access_unavailable: {
|
|
136
|
+
code: "MC-C02",
|
|
137
|
+
sentence: "Memory access is temporarily unavailable.",
|
|
138
|
+
action: "Retry in a moment.",
|
|
139
|
+
},
|
|
140
|
+
note_changes_paused: {
|
|
141
|
+
code: "MC-C03",
|
|
142
|
+
sentence: "Note changes are paused while the engine syncs.",
|
|
143
|
+
action: "Retry in a moment.",
|
|
144
|
+
},
|
|
145
|
+
note_access_unavailable: {
|
|
146
|
+
code: "MC-C04",
|
|
147
|
+
sentence: "Notes are temporarily unavailable.",
|
|
148
|
+
action: "Retry in a moment.",
|
|
149
|
+
},
|
|
150
|
+
context_cleanup_paused: {
|
|
151
|
+
code: "MC-C05",
|
|
152
|
+
sentence: "Context cleanup is paused while the engine syncs.",
|
|
153
|
+
action: "Retry in a moment.",
|
|
154
|
+
},
|
|
155
|
+
partial_history_unavailable: {
|
|
156
|
+
code: "MC-C06",
|
|
157
|
+
sentence: "Partial history compression is not available in the current mode.",
|
|
158
|
+
action: "Run /ctx-recomp without a range.",
|
|
159
|
+
},
|
|
160
|
+
session_upgrade_unavailable: {
|
|
161
|
+
code: "MC-C07",
|
|
162
|
+
sentence: "Session upgrade is not available in the current mode.",
|
|
163
|
+
action: "Run /ctx-recomp instead.",
|
|
164
|
+
},
|
|
165
|
+
smart_note_conditions_unavailable: {
|
|
166
|
+
code: "MC-C08",
|
|
167
|
+
sentence: "Conditional notes are not available in the current mode.",
|
|
168
|
+
action: "Save a regular note without a condition.",
|
|
169
|
+
},
|
|
170
|
+
history_compression_paused: {
|
|
171
|
+
code: "MC-C09",
|
|
172
|
+
sentence: "History compression is paused while the engine syncs.",
|
|
173
|
+
action: "Retry in a moment.",
|
|
174
|
+
},
|
|
175
|
+
context_service_unavailable: {
|
|
176
|
+
code: "MC-C10",
|
|
177
|
+
sentence: "Magic Context is temporarily unavailable.",
|
|
178
|
+
action: "Retry in a moment.",
|
|
179
|
+
},
|
|
180
|
+
} as const;
|
|
181
|
+
|
|
182
|
+
export type UserFacingFailureKey = keyof typeof USER_FACING_FAILURES;
|
|
183
|
+
|
|
184
|
+
export type UserFacingTextStyle = "markdown" | "plain";
|
|
185
|
+
|
|
186
|
+
export function renderUserFacingFailure(
|
|
187
|
+
key: UserFacingFailureKey,
|
|
188
|
+
style: UserFacingTextStyle = "markdown",
|
|
189
|
+
): string {
|
|
190
|
+
const failure = USER_FACING_FAILURES[key];
|
|
191
|
+
const action = style === "plain" ? failure.action.replaceAll("`", "") : failure.action;
|
|
192
|
+
return `${failure.sentence} ${action} (${failure.code})`;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export function userFacingFailureCode(key: UserFacingFailureKey): string {
|
|
196
|
+
return USER_FACING_FAILURES[key].code;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export type CapabilityRefusal =
|
|
200
|
+
| "memory_write"
|
|
201
|
+
| "memory_access"
|
|
202
|
+
| "note_change"
|
|
203
|
+
| "note_access"
|
|
204
|
+
| "context_cleanup"
|
|
205
|
+
| "partial_history"
|
|
206
|
+
| "session_upgrade"
|
|
207
|
+
| "smart_note_condition"
|
|
208
|
+
| "history_compression"
|
|
209
|
+
| "context_service";
|
|
210
|
+
|
|
211
|
+
const CAPABILITY_FAILURES: Record<CapabilityRefusal, UserFacingFailureKey> = {
|
|
212
|
+
memory_write: "memory_writes_paused",
|
|
213
|
+
memory_access: "memory_access_unavailable",
|
|
214
|
+
note_change: "note_changes_paused",
|
|
215
|
+
note_access: "note_access_unavailable",
|
|
216
|
+
context_cleanup: "context_cleanup_paused",
|
|
217
|
+
partial_history: "partial_history_unavailable",
|
|
218
|
+
session_upgrade: "session_upgrade_unavailable",
|
|
219
|
+
smart_note_condition: "smart_note_conditions_unavailable",
|
|
220
|
+
history_compression: "history_compression_paused",
|
|
221
|
+
context_service: "context_service_unavailable",
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
export function renderCapabilityRefusal(capability: CapabilityRefusal): string {
|
|
225
|
+
return renderUserFacingFailure(CAPABILITY_FAILURES[capability]);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export function capabilityRefusalCode(capability: CapabilityRefusal): string {
|
|
229
|
+
return userFacingFailureCode(CAPABILITY_FAILURES[capability]);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const DREAM_FAILURE_KEYS = {
|
|
233
|
+
provider_timeout: "dream_provider_timeout",
|
|
234
|
+
provider_error: "dream_provider_error",
|
|
235
|
+
empty_completion: "dream_empty_completion",
|
|
236
|
+
no_models: "dream_no_models",
|
|
237
|
+
child_aborted: "dream_child_aborted",
|
|
238
|
+
parse_failed: "dream_parse_failed",
|
|
239
|
+
unknown: "dream_unknown",
|
|
240
|
+
} as const satisfies Record<PromptFailureClass, UserFacingFailureKey>;
|
|
241
|
+
|
|
242
|
+
const EMBEDDING_FAILURE_KEYS = {
|
|
243
|
+
substitution_rejected: "embedding_substitution_rejected",
|
|
244
|
+
http_error: "embedding_http_error",
|
|
245
|
+
transport_error: "embedding_transport_error",
|
|
246
|
+
invalid_envelope: "embedding_invalid_envelope",
|
|
247
|
+
empty_result: "embedding_empty_result",
|
|
248
|
+
certification_refusal: "embedding_certification_refusal",
|
|
249
|
+
credential_required: "embedding_credential_required",
|
|
250
|
+
local_binding_missing: "embedding_local_binding_missing",
|
|
251
|
+
local_fs_unavailable: "embedding_local_fs_unavailable",
|
|
252
|
+
local_download_failure: "embedding_local_download_failure",
|
|
253
|
+
local_runtime_error: "embedding_local_runtime_error",
|
|
254
|
+
} as const satisfies Record<EmbeddingFailureClass, UserFacingFailureKey>;
|
|
255
|
+
|
|
256
|
+
export function renderDreamFailure(
|
|
257
|
+
failureClass: PromptFailureClass,
|
|
258
|
+
style: UserFacingTextStyle = "markdown",
|
|
259
|
+
): string {
|
|
260
|
+
return renderUserFacingFailure(DREAM_FAILURE_KEYS[failureClass], style);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export function dreamFailureCode(failureClass: PromptFailureClass): string {
|
|
264
|
+
return userFacingFailureCode(DREAM_FAILURE_KEYS[failureClass]);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export function renderEmbeddingFailure(
|
|
268
|
+
failureClass: EmbeddingFailureClass,
|
|
269
|
+
style: UserFacingTextStyle = "markdown",
|
|
270
|
+
): string {
|
|
271
|
+
return renderUserFacingFailure(EMBEDDING_FAILURE_KEYS[failureClass], style);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export function embeddingFailureCode(failureClass: EmbeddingFailureClass): string {
|
|
275
|
+
return userFacingFailureCode(EMBEDDING_FAILURE_KEYS[failureClass]);
|
|
276
|
+
}
|
|
@@ -4,6 +4,7 @@ import { tmpdir } from "node:os";
|
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { resolveLimit, resolveOutputReserve } from "./models-dev-cache";
|
|
6
6
|
import {
|
|
7
|
+
applyProvenInputFloor,
|
|
7
8
|
deriveWindowGeometry,
|
|
8
9
|
formatWindowDerivationLine,
|
|
9
10
|
parseWindowOverlay,
|
|
@@ -298,6 +299,49 @@ describe("window geometry", () => {
|
|
|
298
299
|
expect(hooked?.derivation.reserve).toBe(30_000);
|
|
299
300
|
});
|
|
300
301
|
|
|
302
|
+
test("keeps shared-upfront emergency headroom below the separate absolute wall", () => {
|
|
303
|
+
const result = deriveWindowGeometry(
|
|
304
|
+
"openai-codex",
|
|
305
|
+
"gpt-5.6-sol",
|
|
306
|
+
{ context: 272_000, output: 128_000 },
|
|
307
|
+
{ providerLimit: { context: 272_000 }, harness: "pi" },
|
|
308
|
+
);
|
|
309
|
+
|
|
310
|
+
expect(result?.usableSoft).toBe(204_000);
|
|
311
|
+
expect(result?.usableHard).toBe(204_000);
|
|
312
|
+
expect(result?.usableHard).toBeLessThan(result?.derivation.absoluteWall ?? 0);
|
|
313
|
+
expect(result?.derivation.absoluteWall).toBe(272_000);
|
|
314
|
+
expect((result?.derivation.absoluteWall ?? 0) - (result?.usableHard ?? 0)).toBe(
|
|
315
|
+
result?.derivation.reserve,
|
|
316
|
+
);
|
|
317
|
+
expect(result?.derivation.windowSource).toBe("provider");
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
test("bounds proof at trusted absolute walls but retains the static-catalog escape hatch", () => {
|
|
321
|
+
const trusted = deriveWindowGeometry(
|
|
322
|
+
"openai-codex",
|
|
323
|
+
"gpt-5.6-sol",
|
|
324
|
+
{ context: 272_000, output: 128_000 },
|
|
325
|
+
{ providerLimit: { context: 272_000 }, harness: "pi" },
|
|
326
|
+
);
|
|
327
|
+
expect(trusted).toBeDefined();
|
|
328
|
+
const raisedWithinWall = applyProvenInputFloor(trusted!, 255_834);
|
|
329
|
+
expect(raisedWithinWall.geometry.usableSoft).toBe(255_834);
|
|
330
|
+
expect(raisedWithinWall.geometry.usableHard).toBe(204_000);
|
|
331
|
+
const refused = applyProvenInputFloor(trusted!, 593_717);
|
|
332
|
+
expect(refused.refused).toEqual({ reading: 593_717, absoluteWall: 272_000 });
|
|
333
|
+
expect(refused.geometry.usableSoft).toBe(204_000);
|
|
334
|
+
expect(refused.geometry.usableHard).toBe(204_000);
|
|
335
|
+
|
|
336
|
+
const staticFallback = deriveWindowGeometry("custom", "model", { context: 30_000 });
|
|
337
|
+
expect(staticFallback).toBeDefined();
|
|
338
|
+
const escaped = applyProvenInputFloor(staticFallback!, 90_000);
|
|
339
|
+
expect(escaped.refused).toBeUndefined();
|
|
340
|
+
expect(escaped.geometry.usableSoft).toBe(90_000);
|
|
341
|
+
expect(escaped.geometry.usableHard).toBe(90_000);
|
|
342
|
+
expect(escaped.geometry.derivation.absoluteWall).toBe(90_000);
|
|
343
|
+
});
|
|
344
|
+
|
|
301
345
|
test("clamps an inversion and logs it", () => {
|
|
302
346
|
const logs: string[] = [];
|
|
303
347
|
const result = deriveWindowGeometry(
|
|
@@ -10,7 +10,12 @@ export const PROMPT_WALL_MARGIN = 4_096;
|
|
|
10
10
|
export const PI_OUTPUT_FLOOR = 4_096;
|
|
11
11
|
export const OPENCODE_OUTPUT_CAP = 32_000;
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Smallest context window any served model can plausibly have. Reported or
|
|
15
|
+
* inferred limits below this are placeholders (0, 1) or corrupt state, never a
|
|
16
|
+
* real window, so every denominator check shares this one floor.
|
|
17
|
+
*/
|
|
18
|
+
export const MIN_PLAUSIBLE_CONTEXT_LIMIT = 1_024;
|
|
14
19
|
const OUTPUT_RESERVE_CAP_RATIO = 0.25;
|
|
15
20
|
|
|
16
21
|
export type WindowGeometry = "shared_upfront" | "shared_truncating" | "separate";
|
|
@@ -70,11 +75,15 @@ export interface ResolvedWindowOverlayFacts {
|
|
|
70
75
|
facts: Record<string, WindowOverlayFact>;
|
|
71
76
|
}
|
|
72
77
|
|
|
78
|
+
export type WindowLimitSource = "catalog" | "overlay" | "provider" | "detected";
|
|
79
|
+
|
|
73
80
|
export interface WindowDerivation {
|
|
74
81
|
window: number;
|
|
75
82
|
reserve: number;
|
|
76
83
|
reserveSource: WindowReserveSource;
|
|
77
84
|
geometry: WindowGeometry;
|
|
85
|
+
windowSource: WindowLimitSource;
|
|
86
|
+
absoluteWall: number;
|
|
78
87
|
}
|
|
79
88
|
|
|
80
89
|
export interface WindowGeometryResult {
|
|
@@ -446,20 +455,22 @@ export function deriveWindowGeometry(
|
|
|
446
455
|
const catalogContext = isFinitePositive(catalogLimit?.context)
|
|
447
456
|
? catalogLimit.context
|
|
448
457
|
: undefined;
|
|
458
|
+
const providerContext = isFinitePositive(providerLimit?.context)
|
|
459
|
+
? providerLimit.context
|
|
460
|
+
: undefined;
|
|
449
461
|
const advertised = numericOverlayFact(options.overlay, "window.advertised");
|
|
450
462
|
const enforced = numericOverlayFact(options.overlay, "window.enforced");
|
|
451
|
-
let softContext = mergePositive(
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
if (isFinitePositive(options.contextCap)) {
|
|
463
|
+
let softContext = mergePositive(enforced ?? advertised ?? catalogContext, providerContext);
|
|
464
|
+
let hardContext = mergePositive(enforced ?? softContext, providerContext);
|
|
465
|
+
const contextCap = isFinitePositive(options.contextCap) ? options.contextCap : undefined;
|
|
466
|
+
const hasContextCap = contextCap !== undefined;
|
|
467
|
+
if (contextCap !== undefined) {
|
|
457
468
|
softContext = isFinitePositive(softContext)
|
|
458
|
-
? Math.min(softContext,
|
|
459
|
-
:
|
|
469
|
+
? Math.min(softContext, contextCap)
|
|
470
|
+
: contextCap;
|
|
460
471
|
hardContext = isFinitePositive(hardContext)
|
|
461
|
-
? Math.min(hardContext,
|
|
462
|
-
:
|
|
472
|
+
? Math.min(hardContext, contextCap)
|
|
473
|
+
: contextCap;
|
|
463
474
|
}
|
|
464
475
|
const input = mergePositive(
|
|
465
476
|
isFinitePositive(catalogLimit?.input) ? catalogLimit.input : undefined,
|
|
@@ -573,6 +584,13 @@ export function deriveWindowGeometry(
|
|
|
573
584
|
|
|
574
585
|
const hardWindow = hardContext ?? softContext ?? input;
|
|
575
586
|
if (!isFinitePositive(hardWindow)) return undefined;
|
|
587
|
+
const windowSource: WindowLimitSource = hasContextCap
|
|
588
|
+
? "detected"
|
|
589
|
+
: providerContext !== undefined
|
|
590
|
+
? "provider"
|
|
591
|
+
: enforced !== undefined || advertised !== undefined
|
|
592
|
+
? "overlay"
|
|
593
|
+
: "catalog";
|
|
576
594
|
let usableHard: number;
|
|
577
595
|
if (geometry === "separate") {
|
|
578
596
|
usableHard = hardWindow;
|
|
@@ -606,6 +624,66 @@ export function deriveWindowGeometry(
|
|
|
606
624
|
reserve: Math.floor(Math.max(0, resolvedWindow - usableSoft)),
|
|
607
625
|
reserveSource,
|
|
608
626
|
geometry,
|
|
627
|
+
windowSource,
|
|
628
|
+
absoluteWall: Math.floor(hardWindow),
|
|
629
|
+
},
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
export interface ProvenInputFloorResult {
|
|
634
|
+
geometry: WindowGeometryResult;
|
|
635
|
+
refused?: { reading: number; absoluteWall: number };
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
export function hasTrustedAbsoluteWall(geometry: WindowGeometryResult): boolean {
|
|
639
|
+
return geometry.derivation.windowSource !== "catalog";
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* Successful requests can disprove static catalog metadata, but cannot
|
|
644
|
+
* disprove a provider, overlay, or observed-overflow wall. A reading beyond
|
|
645
|
+
* that wall is malformed usage accounting and must not enlarge the geometry.
|
|
646
|
+
*/
|
|
647
|
+
export function applyProvenInputFloor(
|
|
648
|
+
geometry: WindowGeometryResult,
|
|
649
|
+
provenInputTokens: number | undefined,
|
|
650
|
+
): ProvenInputFloorResult {
|
|
651
|
+
if (
|
|
652
|
+
!isFinitePositive(provenInputTokens) ||
|
|
653
|
+
provenInputTokens < MIN_PLAUSIBLE_CONTEXT_LIMIT ||
|
|
654
|
+
provenInputTokens <= geometry.usableSoft
|
|
655
|
+
) {
|
|
656
|
+
return { geometry };
|
|
657
|
+
}
|
|
658
|
+
if (hasTrustedAbsoluteWall(geometry) && provenInputTokens > geometry.derivation.absoluteWall) {
|
|
659
|
+
return {
|
|
660
|
+
geometry,
|
|
661
|
+
refused: {
|
|
662
|
+
reading: provenInputTokens,
|
|
663
|
+
absoluteWall: geometry.derivation.absoluteWall,
|
|
664
|
+
},
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
const trustedAbsoluteWall = hasTrustedAbsoluteWall(geometry);
|
|
669
|
+
const window = trustedAbsoluteWall
|
|
670
|
+
? geometry.derivation.window
|
|
671
|
+
: Math.max(geometry.derivation.window, provenInputTokens);
|
|
672
|
+
return {
|
|
673
|
+
geometry: {
|
|
674
|
+
...geometry,
|
|
675
|
+
usableSoft: provenInputTokens,
|
|
676
|
+
usableHard: trustedAbsoluteWall
|
|
677
|
+
? geometry.usableHard
|
|
678
|
+
: Math.max(geometry.usableHard, provenInputTokens),
|
|
679
|
+
derivation: {
|
|
680
|
+
...geometry.derivation,
|
|
681
|
+
window,
|
|
682
|
+
reserve: Math.max(0, window - provenInputTokens),
|
|
683
|
+
absoluteWall: trustedAbsoluteWall
|
|
684
|
+
? geometry.derivation.absoluteWall
|
|
685
|
+
: Math.max(geometry.derivation.absoluteWall, provenInputTokens),
|
|
686
|
+
},
|
|
609
687
|
},
|
|
610
688
|
};
|
|
611
689
|
}
|