@cortexkit/opencode-magic-context 0.44.1 → 0.44.3
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 +6 -0
- package/dist/agents/dreamer.d.ts +4 -6
- package/dist/agents/dreamer.d.ts.map +1 -1
- package/dist/config/live-child-output-cap.d.ts.map +1 -1
- package/dist/config/schema/magic-context.d.ts +63 -10
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/{conflict-warning-hook-d14ah73v.js → conflict-warning-hook-hmpzxep6.js} +3 -3
- package/dist/{derive-budgets-gd2270s0.js → derive-budgets-vjmvh6pz.js} +3 -1
- package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts +11 -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/dreamer/classify.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/docs-proposals.d.ts +2 -0
- package/dist/features/magic-context/dreamer/docs-proposals.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/lease.d.ts +1 -1
- package/dist/features/magic-context/dreamer/lease.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/manual-summary.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/map-memories-prompt.d.ts +1 -1
- package/dist/features/magic-context/dreamer/map-memories-prompt.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/map-memories.d.ts +5 -0
- package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/refresh-primers.d.ts +5 -0
- package/dist/features/magic-context/dreamer/refresh-primers.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/retrospective-raw-provider.d.ts +2 -2
- package/dist/features/magic-context/dreamer/retrospective-raw-provider.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts +8 -1
- package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-config.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-executor.d.ts +5 -0
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-gates.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-prompts.d.ts +18 -2
- package/dist/features/magic-context/dreamer/task-prompts.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-registry.d.ts +12 -0
- package/dist/features/magic-context/dreamer/task-registry.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts +3 -1
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/token-budget.d.ts +33 -0
- package/dist/features/magic-context/dreamer/token-budget.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/verify-diff.d.ts +15 -0
- package/dist/features/magic-context/dreamer/verify-diff.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/verify-gate.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify-prompt.d.ts +5 -2
- package/dist/features/magic-context/dreamer/verify-prompt.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify-read-cap.d.ts +4 -0
- package/dist/features/magic-context/dreamer/verify-read-cap.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/verify.d.ts +5 -0
- package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
- package/dist/features/magic-context/git-commits/git-log-reader.d.ts.map +1 -1
- package/dist/features/magic-context/memory/project-identity-cache.d.ts +6 -0
- package/dist/features/magic-context/memory/project-identity-cache.d.ts.map +1 -0
- package/dist/features/magic-context/memory/project-identity.d.ts +11 -22
- package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
- package/dist/features/magic-context/memory/storage-memory-fts.d.ts +1 -0
- package/dist/features/magic-context/memory/storage-memory-fts.d.ts.map +1 -1
- package/dist/features/magic-context/memory/verification-paths.d.ts +1 -0
- package/dist/features/magic-context/memory/verification-paths.d.ts.map +1 -1
- package/dist/features/magic-context/message-index-async.d.ts +1 -1
- package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts +5 -0
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/features/magic-context/session-activity.d.ts +10 -0
- package/dist/features/magic-context/session-activity.d.ts.map +1 -0
- package/dist/features/magic-context/session-project-backfill.d.ts +4 -1
- package/dist/features/magic-context/session-project-backfill.d.ts.map +1 -1
- package/dist/features/magic-context/session-project-storage.d.ts +5 -5
- package/dist/features/magic-context/session-project-storage.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/compiler.d.ts +5 -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 +1 -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 +1 -1
- package/dist/features/magic-context/smart-notes/storage.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/types.d.ts +2 -0
- package/dist/features/magic-context/smart-notes/types.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts +2 -1
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-embedding-measurements.d.ts.map +1 -1
- package/dist/features/magic-context/storage-identity-merge.d.ts +4 -1
- package/dist/features/magic-context/storage-identity-merge.d.ts.map +1 -1
- package/dist/features/magic-context/storage-session-tables.d.ts.map +1 -1
- package/dist/features/magic-context/v22-deferred-backfill.d.ts.map +1 -1
- package/dist/hooks/auto-update-checker/checker.d.ts.map +1 -1
- package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts +2 -1
- package/dist/hooks/magic-context/compartment-runner-historian.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/compartment-runner-types.d.ts +1 -0
- package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner.d.ts +1 -0
- package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/derive-budgets.d.ts +4 -0
- package/dist/hooks/magic-context/derive-budgets.d.ts.map +1 -1
- package/dist/hooks/magic-context/dropped-input-guard.d.ts.map +1 -1
- package/dist/hooks/magic-context/embed-session-state.d.ts +3 -0
- package/dist/hooks/magic-context/embed-session-state.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-handler.d.ts +1 -0
- package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-payloads.d.ts +1 -0
- package/dist/hooks/magic-context/event-payloads.d.ts.map +1 -1
- package/dist/hooks/magic-context/historian-host-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-persist.d.ts +1 -4
- package/dist/hooks/magic-context/lkg-persist.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-replay.d.ts +6 -4
- package/dist/hooks/magic-context/lkg-replay.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-state-sync.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-wire.d.ts.map +1 -1
- package/dist/hooks/magic-context/producer-window-guard.d.ts +4 -1
- package/dist/hooks/magic-context/producer-window-guard.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts +1 -0
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/storage-busy-refusal.d.ts +13 -0
- package/dist/hooks/magic-context/storage-busy-refusal.d.ts.map +1 -0
- package/dist/hooks/magic-context/strip-content.d.ts +1 -0
- package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-a9vbtdzv.js → index-33q7s9y2.js} +1 -1
- package/dist/{index-cz88kw0n.js → index-4an2p8qa.js} +183 -39
- package/dist/{index-d107az47.js → index-638hf49n.js} +1 -1
- package/dist/{index-stb5fg12.js → index-9y5p0d50.js} +31 -1
- package/dist/{index-s6b7h12g.js → index-dgg5y7er.js} +73 -2
- package/dist/{index-6w9p73jz.js → index-jqcbs2k1.js} +10 -0
- package/dist/{index-0rp6pj54.js → index-nf9sk8sh.js} +7 -5
- package/dist/index-q5p1aqvv.js +7260 -0
- package/dist/index-rdsaxnf2.js +125 -0
- package/dist/{index-jtdrvmcn.js → index-yhm60r53.js} +37544 -37072
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8402 -14429
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/embedding-bootstrap.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/messages-transform.d.ts +10 -9
- package/dist/plugin/messages-transform.d.ts.map +1 -1
- package/dist/plugin/rpc-handlers.d.ts +1 -0
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/{read-session-chunk-fkdv2g5b.js → read-session-chunk-n072mcq4.js} +2 -2
- package/dist/{recomp-orchestrator-k4h5n0p3.js → recomp-orchestrator-19tr6zya.js} +6 -5
- package/dist/{send-session-notification-g2k03zyn.js → send-session-notification-04hvd54c.js} +2 -2
- package/dist/shared/model-suggestion-retry.d.ts +1 -1
- package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
- package/dist/shared/prompt-async-transport.d.ts +7 -7
- package/dist/shared/prompt-async-transport.d.ts.map +1 -1
- package/dist/shared/rpc-server.d.ts.map +1 -1
- package/dist/shared/rpc-utils.d.ts +21 -0
- package/dist/shared/rpc-utils.d.ts.map +1 -1
- package/dist/shared/run-token-log.d.ts +13 -0
- package/dist/shared/run-token-log.d.ts.map +1 -0
- package/dist/shared/sqlite-write-locker-test-support.d.ts.map +1 -1
- package/dist/shared/sqlite.d.ts +19 -0
- package/dist/shared/sqlite.d.ts.map +1 -1
- package/dist/shared/subagent-runner.d.ts +3 -1
- package/dist/shared/subagent-runner.d.ts.map +1 -1
- package/dist/shared/user-facing-codes.d.ts +5 -0
- package/dist/shared/user-facing-codes.d.ts.map +1 -1
- package/dist/{task-config-mgf5nsh3.js → task-config-2bm68628.js} +1 -1
- package/dist/transform-postprocess-phase-z2mfc5w1.js +36 -0
- package/dist/v2/hidden-completion.d.ts +9 -1
- package/dist/v2/hidden-completion.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/hidden-child.d.ts +1 -0
- package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
- package/dist/v2/hooks/hidden-terminal-error.d.ts +8 -0
- package/dist/v2/hooks/hidden-terminal-error.d.ts.map +1 -0
- package/dist/v2/hooks/lkg-system.d.ts +11 -0
- package/dist/v2/hooks/lkg-system.d.ts.map +1 -0
- package/dist/v2/hooks/session-project-backfill.d.ts +1 -1
- package/dist/v2/hooks/session-project-backfill.d.ts.map +1 -1
- package/dist/v2/hooks/storage-gate.d.ts +11 -5
- package/dist/v2/hooks/storage-gate.d.ts.map +1 -1
- package/dist/v2/hooks/tools.d.ts +1 -1
- package/dist/v2/hooks/tools.d.ts.map +1 -1
- package/dist/v2/host-service.d.ts +2 -1
- package/dist/v2/host-service.d.ts.map +1 -1
- package/dist/v2/server.js +24948 -22659
- package/dist/v2/store-reader.d.ts +2 -0
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/{wrapup-orchestrator-35y56636.js → wrapup-orchestrator-sy4m56a7.js} +7 -6
- package/package.json +1 -1
- package/src/agents/dreamer.ts +4 -6
- package/src/agents/hidden-agent-registrations.ts +3 -3
- package/src/agents/permissions.test.ts +3 -4
- package/src/config/latch-permanence-guard.test.ts +13 -0
- package/src/config/live-child-output-cap.test.ts +26 -0
- package/src/config/live-child-output-cap.ts +6 -2
- package/src/config/schema/magic-context.ts +21 -6
- package/src/features/magic-context/dreamer/task-registry.ts +13 -0
- package/src/shared/data-path.test.ts +1 -1
- package/src/shared/logger.test.ts +1 -0
- package/src/shared/model-suggestion-retry.ts +9 -2
- package/src/shared/models-dev-cache.test.ts +30 -1
- package/src/shared/prompt-async-transport.test.ts +254 -1
- package/src/shared/prompt-async-transport.ts +153 -44
- package/src/shared/rpc-async-probes.test.ts +230 -0
- package/src/shared/rpc-server.ts +6 -4
- package/src/shared/rpc-utils.test.ts +27 -1
- package/src/shared/rpc-utils.ts +161 -9
- package/src/shared/run-token-log.test.ts +65 -0
- package/src/shared/run-token-log.ts +39 -0
- package/src/shared/sqlite-acquisition-fence.test.ts +132 -0
- package/src/shared/sqlite-acquisition-routing.test.ts +102 -0
- package/src/shared/sqlite-pass-scope.test.ts +153 -0
- package/src/shared/sqlite-transaction-mode-guard.test.ts +42 -10
- package/src/shared/sqlite-write-locker-test-support.ts +1 -0
- package/src/shared/sqlite.ts +245 -56
- package/src/shared/storage-busy.test.ts +72 -0
- package/src/shared/subagent-runner.ts +4 -0
- package/src/shared/user-facing-codes.ts +6 -0
- package/src/shared/windows-hidden-spawns.test.ts +132 -0
- package/src/shared/write-transaction-attribution.test.ts +14 -11
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import {
|
|
2
|
+
renderUserFacingFailure,
|
|
3
|
+
userFacingFailureCode,
|
|
4
|
+
clearEmergencyRecovery,
|
|
5
|
+
dropSlot,
|
|
6
|
+
executeContextRecomp
|
|
7
|
+
} from "./index-yhm60r53.js";
|
|
8
|
+
import {
|
|
9
|
+
sessionLog
|
|
10
|
+
} from "./index-3bygzk2d.js";
|
|
11
|
+
|
|
12
|
+
// src/hooks/magic-context/recomp-orchestrator.ts
|
|
13
|
+
function resolveLiveModelKey(liveSessionState, sessionId) {
|
|
14
|
+
const model = liveSessionState.liveModelBySession.get(sessionId);
|
|
15
|
+
return model ? `${model.providerID}/${model.modelID}` : undefined;
|
|
16
|
+
}
|
|
17
|
+
function isRecompFailure(message) {
|
|
18
|
+
return /—\s*(Failed|Skipped)/.test(message);
|
|
19
|
+
}
|
|
20
|
+
function isRecompSkip(message) {
|
|
21
|
+
return /—\s*Skipped|already mutating compartment state|already running/i.test(message);
|
|
22
|
+
}
|
|
23
|
+
function extractRecompReason(raw) {
|
|
24
|
+
const meaningful = raw.split(`
|
|
25
|
+
`).map((l) => l.trim()).filter((l) => l.length > 0 && !l.startsWith("#"));
|
|
26
|
+
return meaningful.join(" ").trim() || "Recomp finished";
|
|
27
|
+
}
|
|
28
|
+
var RECOMP_DONE_GRACE_MS = 30000;
|
|
29
|
+
function setRecompStarting2(liveSessionState, sessionId, note, kind = "recomp") {
|
|
30
|
+
dropSlot(sessionId, "recomp-start");
|
|
31
|
+
liveSessionState.recompProgressBySession.set(sessionId, {
|
|
32
|
+
sessionId,
|
|
33
|
+
kind,
|
|
34
|
+
phase: "recomp",
|
|
35
|
+
processedMessages: 0,
|
|
36
|
+
totalMessages: 0,
|
|
37
|
+
passCount: 0,
|
|
38
|
+
compartmentsCreated: 0,
|
|
39
|
+
startedAt: Date.now(),
|
|
40
|
+
updatedAt: Date.now(),
|
|
41
|
+
note
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function setRecompTerminal2(liveSessionState, sessionId, phase, message) {
|
|
45
|
+
const existing = liveSessionState.recompProgressBySession.get(sessionId);
|
|
46
|
+
liveSessionState.recompProgressBySession.set(sessionId, {
|
|
47
|
+
sessionId,
|
|
48
|
+
kind: existing?.kind ?? "recomp",
|
|
49
|
+
phase,
|
|
50
|
+
processedMessages: existing?.processedMessages ?? 0,
|
|
51
|
+
totalMessages: existing?.totalMessages ?? 0,
|
|
52
|
+
passCount: existing?.passCount ?? 0,
|
|
53
|
+
compartmentsCreated: existing?.compartmentsCreated ?? 0,
|
|
54
|
+
startedAt: existing?.startedAt ?? Date.now(),
|
|
55
|
+
updatedAt: Date.now(),
|
|
56
|
+
message
|
|
57
|
+
});
|
|
58
|
+
if (phase === "done" || phase === "skipped") {
|
|
59
|
+
const t = setTimeout(() => {
|
|
60
|
+
const cur = liveSessionState.recompProgressBySession.get(sessionId);
|
|
61
|
+
if (cur?.phase === phase)
|
|
62
|
+
liveSessionState.recompProgressBySession.delete(sessionId);
|
|
63
|
+
}, RECOMP_DONE_GRACE_MS);
|
|
64
|
+
t.unref?.();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function buildRecompDeps(ctx, sessionId) {
|
|
68
|
+
return {
|
|
69
|
+
client: ctx.client,
|
|
70
|
+
hiddenCompletionExecutor: ctx.hiddenCompletionExecutor,
|
|
71
|
+
db: ctx.db,
|
|
72
|
+
sessionId,
|
|
73
|
+
historianChunkTokens: ctx.historianChunkTokens,
|
|
74
|
+
historianTimeoutMs: ctx.historianTimeoutMs,
|
|
75
|
+
directory: ctx.directory,
|
|
76
|
+
memoryEnabled: ctx.memoryEnabled,
|
|
77
|
+
autoPromote: ctx.autoPromote,
|
|
78
|
+
model: ctx.historianModel,
|
|
79
|
+
historianContextLimit: ctx.historianContextLimit,
|
|
80
|
+
historianMaxOutputTokens: ctx.historianMaxOutputTokens,
|
|
81
|
+
fallbackModels: ctx.fallbackModels,
|
|
82
|
+
language: ctx.language,
|
|
83
|
+
fallbackModelId: ctx.fallbackModelId ?? resolveLiveModelKey(ctx.liveSessionState, sessionId),
|
|
84
|
+
historianTwoPass: ctx.historianTwoPass,
|
|
85
|
+
ensureProjectRegistered: ctx.ensureProjectRegistered,
|
|
86
|
+
getNotificationParams: () => ctx.getNotificationParams(sessionId),
|
|
87
|
+
onCompartmentStatePublished: (sid) => {
|
|
88
|
+
ctx.liveSessionState.historyRefreshSessions.add(sid);
|
|
89
|
+
ctx.liveSessionState.pendingMaterializationSessions.add(sid);
|
|
90
|
+
},
|
|
91
|
+
onDeferredMarkerPending: (sid) => {
|
|
92
|
+
ctx.liveSessionState.deferredHistoryRefreshSessions.add(sid);
|
|
93
|
+
},
|
|
94
|
+
onRecompProgress: (p) => {
|
|
95
|
+
const prevKind = ctx.liveSessionState.recompProgressBySession.get(sessionId)?.kind ?? "recomp";
|
|
96
|
+
ctx.liveSessionState.recompProgressBySession.set(sessionId, {
|
|
97
|
+
...p,
|
|
98
|
+
kind: p.kind ?? prevKind
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
async function runManagedRecomp2(ctx, sessionId, options) {
|
|
104
|
+
setRecompStarting2(ctx.liveSessionState, sessionId, "Starting recomp…", "recomp");
|
|
105
|
+
try {
|
|
106
|
+
const message = await executeContextRecomp(buildRecompDeps(ctx, sessionId), options);
|
|
107
|
+
const terminalPhase = isRecompSkip(message) ? "skipped" : isRecompFailure(message) ? "failed" : "done";
|
|
108
|
+
if (terminalPhase === "done") {
|
|
109
|
+
try {
|
|
110
|
+
clearEmergencyRecovery(ctx.db, sessionId);
|
|
111
|
+
} catch {}
|
|
112
|
+
}
|
|
113
|
+
setRecompTerminal2(ctx.liveSessionState, sessionId, terminalPhase, extractRecompReason(message));
|
|
114
|
+
return message;
|
|
115
|
+
} catch (error) {
|
|
116
|
+
const failure = renderUserFacingFailure("recomp_unavailable");
|
|
117
|
+
sessionLog(sessionId, `recomp failed code=${userFacingFailureCode("recomp_unavailable")}`, error);
|
|
118
|
+
setRecompTerminal2(ctx.liveSessionState, sessionId, "failed", failure);
|
|
119
|
+
return `## Magic Recomp — Failed
|
|
120
|
+
|
|
121
|
+
${failure}`;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export { setRecompStarting2, setRecompTerminal2, runManagedRecomp2 };
|