@cortexkit/opencode-magic-context 0.41.4 → 0.42.0
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 +17 -0
- 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 +23 -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 +7 -0
- 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/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-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-synapse.d.ts +43 -10
- 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-recomp.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/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 +1 -1
- package/dist/hooks/magic-context/execute-status.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/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/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-4avmwfp5.js → index-36wd1d6k.js} +6 -29
- package/dist/{index-0y2mcg5y.js → index-c9hamh36.js} +18332 -16226
- 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 +6199 -5088
- 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-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-3atsasjy.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 +111 -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.map +1 -1
- 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/transcript.d.ts +6 -0
- package/dist/shared/transcript.d.ts.map +1 -1
- 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 +11 -22
- package/src/config/project-security.ts +103 -9
- 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 +21 -42
- package/src/config/schema/magic-context.ts +46 -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 +118 -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 +6 -3
- package/src/shared/status-detail-text.ts +15 -0
- package/src/shared/subagent-runner.ts +17 -10
- package/src/shared/tag-transcript.ts +33 -21
- package/src/shared/transcript.ts +7 -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 +3 -3
- package/src/tui/slots/sidebar-content.tsx +12 -7
- package/src/tui-compiled/index.tsx +3 -3
- 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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sidekick.d.ts","sourceRoot":"","sources":["../../src/agents/sidekick.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,aAAa,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/defaults.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,KAAK,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { SidekickConfig } from "../../../config/schema/magic-context";
|
|
2
|
-
import type { PluginContext } from "../../../plugin/types";
|
|
3
|
-
import { SIDEKICK_SYSTEM_PROMPT } from "./core";
|
|
4
|
-
export { SIDEKICK_SYSTEM_PROMPT };
|
|
5
|
-
export declare function runSidekick(deps: {
|
|
6
|
-
client: PluginContext["client"];
|
|
7
|
-
sessionId?: string;
|
|
8
|
-
projectPath: string;
|
|
9
|
-
userMessage: string;
|
|
10
|
-
config: SidekickConfig;
|
|
11
|
-
sessionDirectory?: string;
|
|
12
|
-
language?: string;
|
|
13
|
-
}): Promise<string | null>;
|
|
14
|
-
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/sidekick/agent.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAE3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAQ3D,OAAO,EAAE,sBAAsB,EAAuB,MAAM,QAAQ,CAAC;AAKrE,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAElC,wBAAsB,WAAW,CAAC,IAAI,EAAE;IACpC,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,cAAc,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAqHzB"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Harness-agnostic sidekick logic.
|
|
3
|
-
*
|
|
4
|
-
* Sidekick is a memory-retrieval subagent: given a user prompt, it searches
|
|
5
|
-
* project memories / session facts / conversation history via the `ctx_search`
|
|
6
|
-
* tool, and returns a short augmentation block to prepend to the user's
|
|
7
|
-
* prompt before sending it to the main agent.
|
|
8
|
-
*
|
|
9
|
-
* The actual spawn mechanism is harness-specific — OpenCode creates a child
|
|
10
|
-
* session via `client.session.create()` and Pi spawns `pi --print --mode json`
|
|
11
|
-
* as a subprocess. This module owns the parts that are the same in both:
|
|
12
|
-
*
|
|
13
|
-
* - The system prompt that defines sidekick's role and tool-use policy.
|
|
14
|
-
* - The post-processing that strips `<think>` reasoning blocks (DeepSeek,
|
|
15
|
-
* Qwen, etc. emit these even with explicit "no chain-of-thought" prompts).
|
|
16
|
-
*
|
|
17
|
-
* The harness-specific OpenCode wrapper continues to live in `agent.ts`; the
|
|
18
|
-
* Pi-plugin runner imports from this file directly so it never depends on
|
|
19
|
-
* OpenCode-specific types.
|
|
20
|
-
*/
|
|
21
|
-
export declare const SIDEKICK_SYSTEM_PROMPT = "You are Sidekick, a focused memory-retrieval subagent for an AI coding assistant.\n\nYour job is to search project memories, session facts, and conversation history and return a concise augmentation for the user's prompt.\n\nRules:\n- Use ctx_search(query=\"...\") to look up relevant memories, facts, and history before answering.\n- Run targeted searches only; prefer 1-3 precise queries.\n- Return only findings that materially help with the user's prompt.\n- If nothing useful is found, respond with exactly: No relevant memories found.\n- Keep the response focused and concise.\n- Do not invent facts or speculate beyond what memories support.";
|
|
22
|
-
/**
|
|
23
|
-
* Strip <think>...</think> blocks emitted by reasoning models (DeepSeek,
|
|
24
|
-
* Qwen, etc.). These contain chain-of-thought traces that shouldn't appear
|
|
25
|
-
* in the augmentation output even when the model ignores instructions to
|
|
26
|
-
* suppress them.
|
|
27
|
-
*/
|
|
28
|
-
export declare function stripThinkingBlocks(text: string): string;
|
|
29
|
-
/**
|
|
30
|
-
* Decide whether a sidekick result is "empty enough to discard".
|
|
31
|
-
*
|
|
32
|
-
* Sidekick is instructed to return exactly "No relevant memories found"
|
|
33
|
-
* when nothing useful turns up. We treat that string (with optional
|
|
34
|
-
* whitespace and trailing punctuation variations from chatty models) as
|
|
35
|
-
* a no-op result so the caller can skip injecting an augmentation block.
|
|
36
|
-
*/
|
|
37
|
-
export declare function isEmptySidekickResult(text: string): boolean;
|
|
38
|
-
//# sourceMappingURL=core.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/sidekick/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,eAAO,MAAM,sBAAsB,6oBAU8B,CAAC;AAElE;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAM3D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/sidekick/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export type BypassReason = "force-materialize" | "explicit-bust" | "subagent" | "none";
|
|
2
|
-
export interface BypassInput {
|
|
3
|
-
contextUsage: {
|
|
4
|
-
percentage: number;
|
|
5
|
-
};
|
|
6
|
-
sessionMeta: {
|
|
7
|
-
isSubagent: boolean;
|
|
8
|
-
};
|
|
9
|
-
historyRefreshSessions: Set<string>;
|
|
10
|
-
sessionId: string;
|
|
11
|
-
effectiveExecuteThresholdPercentage: number;
|
|
12
|
-
}
|
|
13
|
-
export declare function detectMidTurnBypassReason(input: BypassInput): BypassReason;
|
|
14
|
-
export interface ApplyMidTurnDeferralInput {
|
|
15
|
-
base: "execute" | "defer";
|
|
16
|
-
bypassReason: BypassReason;
|
|
17
|
-
midTurn: boolean;
|
|
18
|
-
}
|
|
19
|
-
export type SchedulerDeferReason = "scheduler_defer" | "mid_turn_boundary";
|
|
20
|
-
export interface ApplyMidTurnDeferralOutput {
|
|
21
|
-
midTurnAdjustedSchedulerDecision: "execute" | "defer";
|
|
22
|
-
sideEffect: "set-flag" | "none";
|
|
23
|
-
/** Preserve the reason that corresponds to the final mid-turn scheduler decision so refusal logs remain consistent and do not recompute state after the decision changes. */
|
|
24
|
-
deferReason: SchedulerDeferReason | null;
|
|
25
|
-
}
|
|
26
|
-
export declare function applyMidTurnDeferral(input: ApplyMidTurnDeferralInput): ApplyMidTurnDeferralOutput;
|
|
27
|
-
//# sourceMappingURL=boundary-execution.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"boundary-execution.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/boundary-execution.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,YAAY,GAAG,mBAAmB,GAAG,eAAe,GAAG,UAAU,GAAG,MAAM,CAAC;AAEvF,MAAM,WAAW,WAAW;IACxB,YAAY,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IACrC,WAAW,EAAE;QAAE,UAAU,EAAE,OAAO,CAAA;KAAE,CAAC;IACrC,sBAAsB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,mCAAmC,EAAE,MAAM,CAAC;CAC/C;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,WAAW,GAAG,YAAY,CAQ1E;AAED,MAAM,WAAW,yBAAyB;IACtC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC;IAC1B,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,GAAG,mBAAmB,CAAC;AAE3E,MAAM,WAAW,0BAA0B;IACvC,gCAAgC,EAAE,SAAS,GAAG,OAAO,CAAC;IACtD,UAAU,EAAE,UAAU,GAAG,MAAM,CAAC;IAChC,6KAA6K;IAC7K,WAAW,EAAE,oBAAoB,GAAG,IAAI,CAAC;CAC5C;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,0BAA0B,CA6BjG"}
|
package/dist/index-raatkvw5.js
DELETED
|
@@ -1,360 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
log
|
|
3
|
-
} from "./index-dkv2dn46.js";
|
|
4
|
-
import {
|
|
5
|
-
getDataDir
|
|
6
|
-
} from "./index-3fe78beq.js";
|
|
7
|
-
|
|
8
|
-
// src/shared/sqlite-helpers.ts
|
|
9
|
-
function closeQuietly(db) {
|
|
10
|
-
if (!db)
|
|
11
|
-
return;
|
|
12
|
-
try {
|
|
13
|
-
db.close();
|
|
14
|
-
} catch {}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// src/hooks/magic-context/read-session-db.ts
|
|
18
|
-
import { existsSync } from "node:fs";
|
|
19
|
-
import { join } from "node:path";
|
|
20
|
-
|
|
21
|
-
// src/shared/sqlite.ts
|
|
22
|
-
function detectSqliteRuntime() {
|
|
23
|
-
const hasBunVersion = typeof process !== "undefined" && typeof process.versions?.bun === "string";
|
|
24
|
-
const hasBunGlobal = typeof globalThis !== "undefined" && typeof globalThis.Bun !== "undefined";
|
|
25
|
-
return hasBunVersion || hasBunGlobal ? "Bun" : "Node.js";
|
|
26
|
-
}
|
|
27
|
-
var bunSpec = "bun:" + "sqlite";
|
|
28
|
-
var nodeSpec = "node:" + "sqlite";
|
|
29
|
-
async function importSqliteModule(specifier) {
|
|
30
|
-
return await import(specifier);
|
|
31
|
-
}
|
|
32
|
-
function isModuleNotFoundError(error, specifier) {
|
|
33
|
-
const candidate = error;
|
|
34
|
-
const code = typeof candidate?.code === "string" ? candidate.code : "";
|
|
35
|
-
const name = typeof candidate?.name === "string" ? candidate.name : "";
|
|
36
|
-
const message = error instanceof Error ? error.message : String(error ?? "");
|
|
37
|
-
const details = `${code} ${name} ${message}`.toLowerCase();
|
|
38
|
-
const mentionsSpecifier = details.includes(specifier.toLowerCase());
|
|
39
|
-
if (!mentionsSpecifier)
|
|
40
|
-
return false;
|
|
41
|
-
return code === "ERR_MODULE_NOT_FOUND" || code === "ERR_UNKNOWN_BUILTIN_MODULE" || code === "MODULE_NOT_FOUND" || name === "ResolveMessage" || details.includes("module not found") || details.includes("cannot find module") || details.includes("cannot find package") || details.includes("no such built-in module");
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
class SqliteRuntimeUnavailableError extends Error {
|
|
45
|
-
runtime;
|
|
46
|
-
specifier;
|
|
47
|
-
constructor(runtime, specifier, cause) {
|
|
48
|
-
const requirement = specifier === nodeSpec ? "Requires Node.js >= 24, or Bun with bun:sqlite — this Bun build lacks node:sqlite." : "Requires Bun with bun:sqlite, or Node.js >= 24 — this Bun build lacks bun:sqlite.";
|
|
49
|
-
super(`Magic Context detected ${runtime}, but could not load ${specifier}. ${requirement}`, { cause });
|
|
50
|
-
this.name = "SqliteRuntimeUnavailableError";
|
|
51
|
-
this.runtime = runtime;
|
|
52
|
-
this.specifier = specifier;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
async function loadSqliteModule(runtime = detectSqliteRuntime(), importer = importSqliteModule) {
|
|
56
|
-
const specifier = runtime === "Bun" ? bunSpec : nodeSpec;
|
|
57
|
-
try {
|
|
58
|
-
return await importer(specifier);
|
|
59
|
-
} catch (error) {
|
|
60
|
-
if (isModuleNotFoundError(error, specifier)) {
|
|
61
|
-
throw new SqliteRuntimeUnavailableError(runtime, specifier, error);
|
|
62
|
-
}
|
|
63
|
-
throw error;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
var detectedRuntime = detectSqliteRuntime();
|
|
67
|
-
var isBun = detectedRuntime === "Bun";
|
|
68
|
-
var sqliteModule = await loadSqliteModule(detectedRuntime);
|
|
69
|
-
var DatabaseImpl = isBun ? sqliteModule.Database : buildNodeSqliteDatabaseClass(sqliteModule.DatabaseSync);
|
|
70
|
-
function buildNodeSqliteDatabaseClass(DatabaseSync) {
|
|
71
|
-
const SAVEPOINT = "mc_tx_sp";
|
|
72
|
-
|
|
73
|
-
class NodeSqliteDatabase extends DatabaseSync {
|
|
74
|
-
constructor(filename, options) {
|
|
75
|
-
const translated = { ...options };
|
|
76
|
-
if (options && "readonly" in options) {
|
|
77
|
-
translated.readOnly = options.readonly;
|
|
78
|
-
delete translated.readonly;
|
|
79
|
-
}
|
|
80
|
-
super(typeof filename === "string" ? filename : ":memory:", translated);
|
|
81
|
-
}
|
|
82
|
-
prepare(sql) {
|
|
83
|
-
const stmt = super.prepare(sql);
|
|
84
|
-
for (const method of ["run", "get", "all"]) {
|
|
85
|
-
const original = stmt[method].bind(stmt);
|
|
86
|
-
stmt[method] = (...args) => args.length === 1 && Array.isArray(args[0]) ? original(...args[0]) : original(...args);
|
|
87
|
-
}
|
|
88
|
-
return stmt;
|
|
89
|
-
}
|
|
90
|
-
transaction(fn) {
|
|
91
|
-
const self = this;
|
|
92
|
-
const execute = (mode, receiver, args) => {
|
|
93
|
-
const nested = self.isTransaction === true;
|
|
94
|
-
self.exec(nested ? `SAVEPOINT ${SAVEPOINT}` : `BEGIN${mode ? ` ${mode}` : ""}`);
|
|
95
|
-
try {
|
|
96
|
-
const result = fn.apply(receiver, args);
|
|
97
|
-
self.exec(nested ? `RELEASE ${SAVEPOINT}` : "COMMIT");
|
|
98
|
-
return result;
|
|
99
|
-
} catch (error) {
|
|
100
|
-
if (nested) {
|
|
101
|
-
self.exec(`ROLLBACK TO ${SAVEPOINT}`);
|
|
102
|
-
self.exec(`RELEASE ${SAVEPOINT}`);
|
|
103
|
-
} else {
|
|
104
|
-
self.exec("ROLLBACK");
|
|
105
|
-
}
|
|
106
|
-
throw error;
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
const wrapped = function(...args) {
|
|
110
|
-
return execute("", this, args);
|
|
111
|
-
};
|
|
112
|
-
wrapped.default = function(...args) {
|
|
113
|
-
return execute("", this, args);
|
|
114
|
-
};
|
|
115
|
-
wrapped.deferred = function(...args) {
|
|
116
|
-
return execute("DEFERRED", this, args);
|
|
117
|
-
};
|
|
118
|
-
wrapped.immediate = function(...args) {
|
|
119
|
-
return execute("IMMEDIATE", this, args);
|
|
120
|
-
};
|
|
121
|
-
wrapped.exclusive = function(...args) {
|
|
122
|
-
return execute("EXCLUSIVE", this, args);
|
|
123
|
-
};
|
|
124
|
-
return wrapped;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return NodeSqliteDatabase;
|
|
128
|
-
}
|
|
129
|
-
var Database = DatabaseImpl;
|
|
130
|
-
var privilegeDepth = new WeakMap;
|
|
131
|
-
function isInTransaction(db) {
|
|
132
|
-
const candidate = db;
|
|
133
|
-
return candidate.inTransaction === true || candidate.isTransaction === true;
|
|
134
|
-
}
|
|
135
|
-
function withPrivilegedWriter(db, operation) {
|
|
136
|
-
const previousDepth = privilegeDepth.get(db) ?? 0;
|
|
137
|
-
const nested = isInTransaction(db);
|
|
138
|
-
const savepoint = "mc_privilege_scope";
|
|
139
|
-
if (nested) {
|
|
140
|
-
db.exec(`SAVEPOINT ${savepoint}`);
|
|
141
|
-
} else {
|
|
142
|
-
db.exec("BEGIN IMMEDIATE");
|
|
143
|
-
}
|
|
144
|
-
privilegeDepth.set(db, previousDepth + 1);
|
|
145
|
-
try {
|
|
146
|
-
db.prepare("INSERT INTO context_privilege_state(id, enabled) VALUES (1, 1) ON CONFLICT(id) DO UPDATE SET enabled = 1").run();
|
|
147
|
-
const result = operation();
|
|
148
|
-
if (previousDepth === 0) {
|
|
149
|
-
db.prepare("UPDATE context_privilege_state SET enabled = 0 WHERE id = 1").run();
|
|
150
|
-
}
|
|
151
|
-
if (nested) {
|
|
152
|
-
db.exec(`RELEASE ${savepoint}`);
|
|
153
|
-
} else {
|
|
154
|
-
db.exec("COMMIT");
|
|
155
|
-
}
|
|
156
|
-
if (previousDepth > 0)
|
|
157
|
-
privilegeDepth.set(db, previousDepth);
|
|
158
|
-
else
|
|
159
|
-
privilegeDepth.delete(db);
|
|
160
|
-
return result;
|
|
161
|
-
} catch (error) {
|
|
162
|
-
try {
|
|
163
|
-
if (nested) {
|
|
164
|
-
db.exec(`ROLLBACK TO ${savepoint}`);
|
|
165
|
-
db.exec(`RELEASE ${savepoint}`);
|
|
166
|
-
} else {
|
|
167
|
-
db.exec("ROLLBACK");
|
|
168
|
-
}
|
|
169
|
-
} finally {
|
|
170
|
-
if (previousDepth > 0)
|
|
171
|
-
privilegeDepth.set(db, previousDepth);
|
|
172
|
-
else
|
|
173
|
-
privilegeDepth.delete(db);
|
|
174
|
-
}
|
|
175
|
-
throw error;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// src/hooks/magic-context/read-session-db.ts
|
|
180
|
-
function getOpenCodeDbPath() {
|
|
181
|
-
return join(getDataDir(), "opencode", "opencode.db");
|
|
182
|
-
}
|
|
183
|
-
function openCodeDbExists() {
|
|
184
|
-
return existsSync(getOpenCodeDbPath());
|
|
185
|
-
}
|
|
186
|
-
var cachedReadOnlyDb = null;
|
|
187
|
-
function closeCachedReadOnlyDb() {
|
|
188
|
-
if (!cachedReadOnlyDb) {
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
try {
|
|
192
|
-
closeQuietly(cachedReadOnlyDb.db);
|
|
193
|
-
} catch (error) {
|
|
194
|
-
log("[magic-context] failed to close cached OpenCode read-only DB:", error);
|
|
195
|
-
} finally {
|
|
196
|
-
cachedReadOnlyDb = null;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
function getReadOnlySessionDb() {
|
|
200
|
-
const dbPath = getOpenCodeDbPath();
|
|
201
|
-
if (cachedReadOnlyDb?.path === dbPath) {
|
|
202
|
-
return cachedReadOnlyDb.db;
|
|
203
|
-
}
|
|
204
|
-
closeCachedReadOnlyDb();
|
|
205
|
-
const db = new Database(dbPath, { readonly: true });
|
|
206
|
-
cachedReadOnlyDb = { path: dbPath, db };
|
|
207
|
-
return db;
|
|
208
|
-
}
|
|
209
|
-
function withReadOnlySessionDb(fn) {
|
|
210
|
-
return fn(getReadOnlySessionDb());
|
|
211
|
-
}
|
|
212
|
-
function getRawSessionMessageCountFromDb(db, sessionId) {
|
|
213
|
-
const row = db.prepare(`SELECT COUNT(*) as count FROM message WHERE session_id = ?
|
|
214
|
-
AND NOT (COALESCE(json_extract(data, '$.summary'), 0) = 1
|
|
215
|
-
AND COALESCE(json_extract(data, '$.finish'), '') = 'stop')`).get(sessionId);
|
|
216
|
-
return typeof row?.count === "number" ? row.count : 0;
|
|
217
|
-
}
|
|
218
|
-
function isMidTurn(_deps, sessionId) {
|
|
219
|
-
try {
|
|
220
|
-
return withReadOnlySessionDb((db) => isMidTurnFromOpenCodeDb(db, sessionId));
|
|
221
|
-
} catch (error) {
|
|
222
|
-
log("[magic-context] failed to inspect OpenCode mid-turn state:", error);
|
|
223
|
-
return false;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
function shouldHoldIgnoredNotificationFromOpenCodeDb(db, sessionId) {
|
|
227
|
-
if (isMidTurnFromOpenCodeDb(db, sessionId))
|
|
228
|
-
return true;
|
|
229
|
-
if (hasUnfinishedAssistant(db, sessionId))
|
|
230
|
-
return true;
|
|
231
|
-
if (hasUnansweredRealUser(db, sessionId))
|
|
232
|
-
return true;
|
|
233
|
-
return false;
|
|
234
|
-
}
|
|
235
|
-
function shouldHoldIgnoredNotification(sessionId) {
|
|
236
|
-
if (process.env.MAGIC_CONTEXT_NOTICE_GATE === "bypass")
|
|
237
|
-
return false;
|
|
238
|
-
if (process.env.MAGIC_CONTEXT_NOTICE_GATE === "hold")
|
|
239
|
-
return true;
|
|
240
|
-
try {
|
|
241
|
-
return withReadOnlySessionDb((db) => shouldHoldIgnoredNotificationFromOpenCodeDb(db, sessionId));
|
|
242
|
-
} catch (error) {
|
|
243
|
-
log("[magic-context] failed to inspect notice-hold state:", error);
|
|
244
|
-
return false;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
function isMidTurnFromOpenCodeDb(db, sessionId) {
|
|
248
|
-
const latestAssistant = latestAssistantRow(db, sessionId);
|
|
249
|
-
if (typeof latestAssistant?.id !== "string")
|
|
250
|
-
return false;
|
|
251
|
-
if (hasNewerRealUserMessage(db, sessionId, latestAssistant.timeCreated))
|
|
252
|
-
return false;
|
|
253
|
-
if (latestAssistant.finish === "tool-calls")
|
|
254
|
-
return true;
|
|
255
|
-
const partRows = db.prepare("SELECT data FROM part WHERE session_id = ? AND message_id = ?").all(sessionId, latestAssistant.id);
|
|
256
|
-
return partRows.some((row) => {
|
|
257
|
-
if (typeof row.data !== "string" || row.data.length === 0)
|
|
258
|
-
return false;
|
|
259
|
-
try {
|
|
260
|
-
const part = JSON.parse(row.data);
|
|
261
|
-
return part.type === "tool" && part.providerExecuted !== true;
|
|
262
|
-
} catch {
|
|
263
|
-
return false;
|
|
264
|
-
}
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
function hasNewerRealUserMessage(db, sessionId, latestAssistantTimeCreated) {
|
|
268
|
-
if (typeof latestAssistantTimeCreated !== "number")
|
|
269
|
-
return false;
|
|
270
|
-
const row = db.prepare(`SELECT 1 as one
|
|
271
|
-
FROM message m
|
|
272
|
-
WHERE m.session_id = ?
|
|
273
|
-
AND m.time_created > ?
|
|
274
|
-
AND json_extract(m.data, '$.role') = 'user'
|
|
275
|
-
AND NOT (
|
|
276
|
-
EXISTS (SELECT 1 FROM part p WHERE p.message_id = m.id)
|
|
277
|
-
AND NOT EXISTS (
|
|
278
|
-
SELECT 1 FROM part p
|
|
279
|
-
WHERE p.message_id = m.id
|
|
280
|
-
AND COALESCE(json_extract(p.data, '$.synthetic'), 0) NOT IN (1, 'true')
|
|
281
|
-
AND json_extract(p.data, '$.metadata.marker.kind') IS NULL
|
|
282
|
-
AND COALESCE(json_extract(p.data, '$.ignored'), 0) NOT IN (1, 'true')
|
|
283
|
-
)
|
|
284
|
-
)
|
|
285
|
-
LIMIT 1`).get(sessionId, latestAssistantTimeCreated);
|
|
286
|
-
return row?.one === 1;
|
|
287
|
-
}
|
|
288
|
-
function latestAssistantRow(db, sessionId) {
|
|
289
|
-
return db.prepare(`SELECT id,
|
|
290
|
-
json_extract(data, '$.finish') as finish,
|
|
291
|
-
time_created as timeCreated
|
|
292
|
-
FROM message
|
|
293
|
-
WHERE session_id = ?
|
|
294
|
-
AND json_extract(data, '$.role') = 'assistant'
|
|
295
|
-
ORDER BY time_created DESC
|
|
296
|
-
LIMIT 1`).get(sessionId);
|
|
297
|
-
}
|
|
298
|
-
function hasUnfinishedAssistant(db, sessionId) {
|
|
299
|
-
const latestAssistant = latestAssistantRow(db, sessionId);
|
|
300
|
-
if (typeof latestAssistant?.id !== "string")
|
|
301
|
-
return false;
|
|
302
|
-
const finish = latestAssistant.finish;
|
|
303
|
-
if (typeof finish !== "string" || finish.length === 0)
|
|
304
|
-
return true;
|
|
305
|
-
return finish === "tool-calls" || finish === "unknown";
|
|
306
|
-
}
|
|
307
|
-
function hasUnansweredRealUser(db, sessionId) {
|
|
308
|
-
const latestAssistant = latestAssistantRow(db, sessionId);
|
|
309
|
-
const latestAssistantTime = typeof latestAssistant?.timeCreated === "number" ? latestAssistant.timeCreated : -1;
|
|
310
|
-
return hasNewerRealUserMessage(db, sessionId, latestAssistantTime);
|
|
311
|
-
}
|
|
312
|
-
function getMessageTimesFromOpenCodeDb(sessionId, messageIds) {
|
|
313
|
-
const result = new Map;
|
|
314
|
-
if (messageIds.length === 0)
|
|
315
|
-
return result;
|
|
316
|
-
try {
|
|
317
|
-
withReadOnlySessionDb((db) => {
|
|
318
|
-
const placeholders = messageIds.map(() => "?").join(",");
|
|
319
|
-
const rows = db.prepare(`SELECT id, time_created FROM message WHERE session_id = ? AND id IN (${placeholders})`).all(sessionId, ...messageIds);
|
|
320
|
-
for (const row of rows) {
|
|
321
|
-
if (typeof row.id === "string" && typeof row.time_created === "number") {
|
|
322
|
-
result.set(row.id, row.time_created);
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
});
|
|
326
|
-
} catch (error) {
|
|
327
|
-
log("[magic-context] failed to resolve message times from OpenCode DB:", error);
|
|
328
|
-
}
|
|
329
|
-
return result;
|
|
330
|
-
}
|
|
331
|
-
function findLastAssistantModelFromOpenCodeDb(sessionId) {
|
|
332
|
-
try {
|
|
333
|
-
return withReadOnlySessionDb((db) => {
|
|
334
|
-
const row = db.prepare(`SELECT json_extract(data, '$.providerID') as providerID,
|
|
335
|
-
json_extract(data, '$.modelID') as modelID,
|
|
336
|
-
json_extract(data, '$.agent') as agent
|
|
337
|
-
FROM message
|
|
338
|
-
WHERE session_id = ?
|
|
339
|
-
AND json_extract(data, '$.role') = 'assistant'
|
|
340
|
-
AND json_extract(data, '$.providerID') IS NOT NULL
|
|
341
|
-
AND json_extract(data, '$.modelID') IS NOT NULL
|
|
342
|
-
ORDER BY time_created DESC
|
|
343
|
-
LIMIT 1`).get(sessionId);
|
|
344
|
-
if (!row || typeof row.providerID !== "string" || typeof row.modelID !== "string") {
|
|
345
|
-
return null;
|
|
346
|
-
}
|
|
347
|
-
const agent = typeof row.agent === "string" && row.agent.length > 0 ? row.agent : undefined;
|
|
348
|
-
return {
|
|
349
|
-
providerID: row.providerID,
|
|
350
|
-
modelID: row.modelID,
|
|
351
|
-
...agent ? { agent } : {}
|
|
352
|
-
};
|
|
353
|
-
});
|
|
354
|
-
} catch (error) {
|
|
355
|
-
log("[magic-context] failed to recover live model from OpenCode DB:", error);
|
|
356
|
-
return null;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
export { detectSqliteRuntime, Database, withPrivilegedWriter, closeQuietly, openCodeDbExists, withReadOnlySessionDb, getRawSessionMessageCountFromDb, isMidTurn, shouldHoldIgnoredNotification, getMessageTimesFromOpenCodeDb, findLastAssistantModelFromOpenCodeDb };
|
package/src/agents/sidekick.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const SIDEKICK_AGENT = "sidekick";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const DEFAULT_PROTECTED_TAGS = 20;
|