@cortexkit/opencode-magic-context 0.49.28 → 0.49.29
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/dist/auto-search-worker.js +3 -3
- package/dist/chunk-embedding-write-worker.js +1 -1
- package/dist/config/commit-retention-recovery.d.ts +9 -0
- package/dist/config/commit-retention-recovery.d.ts.map +1 -0
- package/dist/config/index.d.ts +2 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/live-child-output-cap.d.ts.map +1 -1
- package/dist/config/live-run-config.d.ts.map +1 -1
- package/dist/config/project-security.d.ts +1 -0
- package/dist/config/project-security.d.ts.map +1 -1
- package/dist/{conflict-warning-hook-tgnw019g.js → conflict-warning-hook-xgskea1v.js} +3 -3
- package/dist/{context-dxfztzsd.js → context-836j3vte.js} +63 -27
- package/dist/{embedding-backfill-cwnyr4fj.js → embedding-backfill-mms9nb0h.js} +2 -2
- package/dist/features/magic-context/dreamer/evaluate-smart-notes.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/map-memories.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify-diff.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
- package/dist/features/magic-context/git-commits/indexer.d.ts +2 -0
- package/dist/features/magic-context/git-commits/indexer.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts +3 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/compiler.d.ts.map +1 -1
- package/dist/features/magic-context/work-metrics.d.ts +5 -3
- package/dist/features/magic-context/work-metrics.d.ts.map +1 -1
- package/dist/hooks/magic-context/apply-operations.d.ts +2 -0
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-types.d.ts +5 -1
- package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-recovery-prefix.d.ts +3 -1
- package/dist/hooks/magic-context/lkg-recovery-prefix.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-replay.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-slot.d.ts +7 -0
- package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-db.d.ts +3 -2
- package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
- package/dist/hooks/magic-context/replay-committed-drops.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-n8qmmd7f.js → index-093c4g1c.js} +3 -3
- package/dist/{index-89k1w6x2.js → index-a1h316s9.js} +2 -2
- package/dist/{index-fq2p158w.js → index-bps8vn9r.js} +13 -7
- package/dist/{index-tvzvjggy.js → index-gkee6p4g.js} +1 -1
- package/dist/{index-a2fz9hpa.js → index-gxkhzmjq.js} +4 -2
- package/dist/{index-4cpc59jv.js → index-h4s5jk7f.js} +1 -1
- package/dist/{index-t3rbb8wr.js → index-pe6b4bhs.js} +1 -1
- package/dist/{index-dcqk0y27.js → index-q9zvphbq.js} +104 -24
- package/dist/{index-7gbcg8xv.js → index-tx68g9nc.js} +1 -1
- package/dist/{index-4ypqzvhf.js → index-vnn5405n.js} +1 -1
- package/dist/{index-077ht5cq.js → index-waktfbjy.js} +1 -1
- package/dist/{index-k9jx7ma9.js → index-wpcdk76y.js} +325 -249
- package/dist/{index-dzfevacx.js → index-wvffze8y.js} +10 -6
- package/dist/{index-31y1mznz.js → index-wyt5m81v.js} +4 -4
- package/dist/{index-v0dhhxsq.js → index-y1qwzvxn.js} +5 -5
- package/dist/{index-yzjhx10y.js → index-zhgqgxtt.js} +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -30
- package/dist/{message-index-bounded-7ayzb2ah.js → message-index-bounded-7qsn4fd3.js} +3 -3
- package/dist/migration-worker.js +1 -1
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/embedding-bootstrap-helpers.d.ts +5 -1
- package/dist/plugin/embedding-bootstrap-helpers.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/{project-embedding-registry-94nncs5g.js → project-embedding-registry-cg281d9j.js} +1 -1
- package/dist/raw-ordinal-warmup-worker.js +2 -2
- package/dist/{read-session-chunk-jzb6w9w5.js → read-session-chunk-a5d0q3m0.js} +2 -2
- package/dist/{recomp-orchestrator-02sa2ngr.js → recomp-orchestrator-na34m4c5.js} +10 -10
- package/dist/{search-spq6nfyf.js → search-0cd6hx7a.js} +7 -7
- package/dist/{search-archive-q1vw7zg4.js → search-archive-66pm17gm.js} +3 -3
- package/dist/{send-session-notification-afzzqy5b.js → send-session-notification-vz86nt79.js} +2 -2
- package/dist/{transform-postprocess-phase-6menyyxc.js → transform-postprocess-phase-27we33af.js} +10 -10
- package/dist/v2/auto-search-worker.js +3 -3
- package/dist/v2/chunk-embedding-write-worker.js +1 -1
- package/dist/v2/{context-0qhz1nnj.js → context-g4ptae4x.js} +197 -80
- package/dist/v2/{embedding-backfill-rh5dgsva.js → embedding-backfill-35k6czrr.js} +2 -2
- package/dist/v2/hidden-completion.d.ts.map +1 -1
- package/dist/v2/hooks/dream-timer.d.ts.map +1 -1
- package/dist/v2/hooks/store.d.ts.map +1 -1
- package/dist/v2/{message-index-bounded-n09b74vr.js → message-index-bounded-7363502m.js} +3 -3
- package/dist/v2/migration-worker.js +1 -1
- package/dist/v2/{project-embedding-registry-6pak822h.js → project-embedding-registry-p1p10ks7.js} +1 -1
- package/dist/v2/raw-ordinal-warmup-worker.js +2 -2
- package/dist/v2/{read-session-chunk-vpt69tw9.js → read-session-chunk-kkppfhft.js} +2 -2
- package/dist/v2/{recomp-orchestrator-txsmbnvw.js → recomp-orchestrator-f1df1gb8.js} +10 -10
- package/dist/v2/{search-dcy9b6gd.js → search-2v3xyzse.js} +7 -7
- package/dist/v2/{search-archive-t9bcz4ht.js → search-archive-v07jpw25.js} +3 -3
- package/dist/v2/{send-session-notification-vdsgnf4c.js → send-session-notification-x5nzy34v.js} +2 -2
- package/dist/v2/{server-e3hc93wk.js → server-77gznpmf.js} +1 -1
- package/dist/v2/{server-94wk1ey3.js → server-835q39kd.js} +45 -5
- package/dist/v2/{server-txbc3czn.js → server-976dxaxh.js} +10 -6
- package/dist/v2/{server-3vhxy2k5.js → server-a7x00tw8.js} +5 -5
- package/dist/v2/{server-z2n2xaeh.js → server-k9je35ev.js} +1 -1
- package/dist/v2/{server-xkvxss5g.js → server-mxzj3r0y.js} +5 -1
- package/dist/v2/{server-6avtp9jp.js → server-p0snacz3.js} +1 -1
- package/dist/v2/{server-z3mk9jdc.js → server-ph300d6m.js} +1 -1
- package/dist/v2/{server-jj9qye8y.js → server-q50ttc2g.js} +62 -21
- package/dist/v2/{server-6v3cdzsx.js → server-qc915kw2.js} +1 -1
- package/dist/v2/{server-zmcrvpm3.js → server-w79f8ejn.js} +2 -2
- package/dist/v2/{server-yqek3s4k.js → server-zh3esb0z.js} +4 -2
- package/dist/v2/server.js +3 -3
- package/dist/v2/{wrapup-orchestrator-gjkszser.js → wrapup-orchestrator-jq33fda8.js} +10 -10
- package/dist/{wrapup-orchestrator-n5h5sr1x.js → wrapup-orchestrator-f0xr7pft.js} +11 -11
- package/package.json +1 -1
- package/src/config/commit-retention-recovery.ts +34 -0
- package/src/config/index.ts +22 -2
- package/src/config/live-child-output-cap.test.ts +28 -0
- package/src/config/live-child-output-cap.ts +2 -0
- package/src/config/live-run-config.test.ts +44 -1
- package/src/config/live-run-config.ts +8 -1
- package/src/config/project-config-trust-boundary.test.ts +57 -0
- package/src/config/project-security.ts +6 -2
- package/src/shared/windows-hidden-spawns.test.ts +133 -23
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getMagicContextBuiltinCommands,
|
|
3
3
|
readJsoncFile,
|
|
4
|
+
isCommitRetentionPaused,
|
|
4
5
|
cortexKitUserConfigBasePath,
|
|
5
6
|
cortexKitProjectConfigBasePath,
|
|
6
7
|
resolveLegacyConfigSources,
|
|
7
8
|
getProtectedTokensTierOverrides,
|
|
8
9
|
loadPluginConfigDetailed
|
|
9
|
-
} from "./server-
|
|
10
|
+
} from "./server-835q39kd.js";
|
|
10
11
|
import {
|
|
11
12
|
getHarness2,
|
|
12
13
|
harnessOwnsOpenCodeStore2
|
|
@@ -149,6 +150,7 @@ import {
|
|
|
149
150
|
noteLkgHealthyPrefix,
|
|
150
151
|
lkgRecoveryReplayUnproven,
|
|
151
152
|
lkgRecoveryEntryUnproven,
|
|
153
|
+
lkgInputIdentity,
|
|
152
154
|
beginLkgPass,
|
|
153
155
|
visitMessageContentFields,
|
|
154
156
|
contentSnapshotValue,
|
|
@@ -230,6 +232,7 @@ import {
|
|
|
230
232
|
normalizeSDKResponse,
|
|
231
233
|
annotateSubagentInvocationError,
|
|
232
234
|
failedInvocationStatus,
|
|
235
|
+
emptyTokenTotals,
|
|
233
236
|
sumTokensFromChildMessages,
|
|
234
237
|
recordChildInvocation,
|
|
235
238
|
createPromptAsyncTransport,
|
|
@@ -302,7 +305,7 @@ import {
|
|
|
302
305
|
startCompartmentAgent,
|
|
303
306
|
setRecompStarting2,
|
|
304
307
|
setRecompTerminal2
|
|
305
|
-
} from "./server-
|
|
308
|
+
} from "./server-q50ttc2g.js";
|
|
306
309
|
import {
|
|
307
310
|
resolveHistorianModel2
|
|
308
311
|
} from "./server-5kym00ag.js";
|
|
@@ -327,7 +330,7 @@ import {
|
|
|
327
330
|
openDatabaseAsync,
|
|
328
331
|
isDatabasePersisted,
|
|
329
332
|
getDatabasePersistenceError
|
|
330
|
-
} from "./server-
|
|
333
|
+
} from "./server-77gznpmf.js";
|
|
331
334
|
import {
|
|
332
335
|
pruneMissingProjectIdentities,
|
|
333
336
|
setHomeProjectPermission,
|
|
@@ -500,7 +503,7 @@ import {
|
|
|
500
503
|
latestRealUserTurnIdFromOpenCodeDb,
|
|
501
504
|
getMessageTimesFromOpenCodeDb,
|
|
502
505
|
findLastAssistantModelFromOpenCodeDb
|
|
503
|
-
} from "./server-
|
|
506
|
+
} from "./server-a7x00tw8.js";
|
|
504
507
|
import {
|
|
505
508
|
expandToolPart,
|
|
506
509
|
askAnswerLines,
|
|
@@ -699,7 +702,7 @@ import {
|
|
|
699
702
|
readRawSessionMessageById2,
|
|
700
703
|
readSessionChunk2,
|
|
701
704
|
readRawSessionSeedTail2
|
|
702
|
-
} from "./server-
|
|
705
|
+
} from "./server-mxzj3r0y.js";
|
|
703
706
|
import {
|
|
704
707
|
BoundedSessionMap,
|
|
705
708
|
recordToolDefinitionSet,
|
|
@@ -714,7 +717,7 @@ import {
|
|
|
714
717
|
isMessageIndexReconciledThrough,
|
|
715
718
|
clearIndexedMessages,
|
|
716
719
|
indexMessagesAfterOrdinal
|
|
717
|
-
} from "./server-
|
|
720
|
+
} from "./server-k9je35ev.js";
|
|
718
721
|
import"./server-awr8qa4c.js";
|
|
719
722
|
import {
|
|
720
723
|
embedPauseBySession,
|
|
@@ -745,7 +748,7 @@ import {
|
|
|
745
748
|
embedSessionCompartmentChunks2,
|
|
746
749
|
getEmbeddingCoverageStatus2,
|
|
747
750
|
getAutoEmbeddingSessionCoverage2
|
|
748
|
-
} from "./server-
|
|
751
|
+
} from "./server-zh3esb0z.js";
|
|
749
752
|
import {
|
|
750
753
|
SubcClient,
|
|
751
754
|
connectionFileExists,
|
|
@@ -822,7 +825,7 @@ import {
|
|
|
822
825
|
readGitFileChangeTimesSince,
|
|
823
826
|
verificationFileExists,
|
|
824
827
|
normalizeVerificationFiles
|
|
825
|
-
} from "./server-
|
|
828
|
+
} from "./server-ph300d6m.js";
|
|
826
829
|
import {
|
|
827
830
|
deriveTriggerBudget2,
|
|
828
831
|
deriveHistorianChunkTokens2,
|
|
@@ -856,7 +859,7 @@ import {
|
|
|
856
859
|
} from "./server-vr4szghm.js";
|
|
857
860
|
import {
|
|
858
861
|
cosineSimilarity
|
|
859
|
-
} from "./server-
|
|
862
|
+
} from "./server-p0snacz3.js";
|
|
860
863
|
import {
|
|
861
864
|
computeCueContentHash,
|
|
862
865
|
hasMuralCueColumns,
|
|
@@ -893,7 +896,7 @@ import"./server-1bw1wcbp.js";
|
|
|
893
896
|
import {
|
|
894
897
|
flushIgnoredMessages2,
|
|
895
898
|
sendStatusNotification2
|
|
896
|
-
} from "./server-
|
|
899
|
+
} from "./server-qc915kw2.js";
|
|
897
900
|
import {
|
|
898
901
|
renderSingleStoreMigrationRequiredRefusal,
|
|
899
902
|
SingleStoreMigrationRequiredError,
|
|
@@ -913,14 +916,14 @@ import {
|
|
|
913
916
|
resolveMemoriesByIdsForSearch2,
|
|
914
917
|
unifiedSearch2,
|
|
915
918
|
formatSearchResults2
|
|
916
|
-
} from "./server-
|
|
919
|
+
} from "./server-976dxaxh.js";
|
|
917
920
|
import {
|
|
918
921
|
resolvePromptContext2
|
|
919
922
|
} from "./server-fmsr7v69.js";
|
|
920
923
|
import"./server-kaqs6h31.js";
|
|
921
924
|
import {
|
|
922
925
|
renderSearchArchiveOffThread2
|
|
923
|
-
} from "./server-
|
|
926
|
+
} from "./server-w79f8ejn.js";
|
|
924
927
|
import {
|
|
925
928
|
compareSemverCore
|
|
926
929
|
} from "./server-84w6rvvf.js";
|
|
@@ -7520,6 +7523,12 @@ var RECENT_TOOL_SKELETON_WINDOW = 20;
|
|
|
7520
7523
|
function buildReplacementContent(tagId) {
|
|
7521
7524
|
return `[dropped §${tagId}§]`;
|
|
7522
7525
|
}
|
|
7526
|
+
var FROZEN_TEXT_ANNOTATION_SUFFIX = /(?:\n\n(?:<instruction name="deferred_notes">(?:(?!<\/instruction>)[\s\S])*<\/instruction>|<ctx-search-hint>(?:(?!<\/ctx-search-hint>)[\s\S])*<\/ctx-search-hint>))+$/;
|
|
7527
|
+
function renderDroppedText(tagId, renderedText) {
|
|
7528
|
+
const placeholder = buildReplacementContent(tagId);
|
|
7529
|
+
const annotations = renderedText?.match(FROZEN_TEXT_ANNOTATION_SUFFIX)?.[0] ?? "";
|
|
7530
|
+
return placeholder + annotations;
|
|
7531
|
+
}
|
|
7523
7532
|
function applyNewToolDrop(target, options) {
|
|
7524
7533
|
const plan = planNewToolDrop(target, options, !!options.persist);
|
|
7525
7534
|
if (!plan)
|
|
@@ -19284,8 +19293,21 @@ function createTransform(deps) {
|
|
|
19284
19293
|
const temporalReplayIds = temporalCandidates ? messages.flatMap((message) => message.info.id ? [message.info.id] : []) : undefined;
|
|
19285
19294
|
logTransformTiming(sessionId, "findSessionId", tSessionId, `messages=${messages.length}`);
|
|
19286
19295
|
const tLkgEntry = performance.now();
|
|
19287
|
-
const lkgInput = deps.transformMode === "rust" ? [] : projectEntry(sessionId,
|
|
19296
|
+
const lkgInput = deps.transformMode === "rust" ? [] : projectEntry(sessionId, entryOrderForThinkingFit);
|
|
19288
19297
|
const recovery = deps.compactionOff || deps.transformMode === "rust" ? {} : readLkgRecoveryPrefix(sessionId, lkgInput, messages, deps.db);
|
|
19298
|
+
const recoveryTailSources = [];
|
|
19299
|
+
if (recovery.prefix) {
|
|
19300
|
+
const priorIdentities = new Set(recovery.prefix.inputs.map((input) => input.id));
|
|
19301
|
+
lkgInput.forEach((input, index) => {
|
|
19302
|
+
const identity = lkgInputIdentity(input.id, input.role, index);
|
|
19303
|
+
if (!identity || priorIdentities.has(identity))
|
|
19304
|
+
return;
|
|
19305
|
+
recoveryTailSources.push({
|
|
19306
|
+
identity,
|
|
19307
|
+
pristineSystem: input.id === null && input.role === "system" ? structuredClone(entryOrderForThinkingFit[index]) : undefined
|
|
19308
|
+
});
|
|
19309
|
+
});
|
|
19310
|
+
}
|
|
19289
19311
|
const persistedUntaggedInputIds = deps.compactionOff || deps.transformMode === "rust" ? [] : readPersistedLkgUntaggedInputIds(deps.db, sessionId);
|
|
19290
19312
|
const untaggedReplayIds = new Set([
|
|
19291
19313
|
...recovery.prefix?.untaggedInputIds ?? [],
|
|
@@ -20322,9 +20344,15 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
20322
20344
|
});
|
|
20323
20345
|
compactionModeTransitionPending.delete(sessionId);
|
|
20324
20346
|
if (recovery.prefix && !recoveryNormalized) {
|
|
20325
|
-
const
|
|
20326
|
-
|
|
20327
|
-
|
|
20347
|
+
const renderedById = new Map;
|
|
20348
|
+
for (const message of messages) {
|
|
20349
|
+
if (!message.info.id)
|
|
20350
|
+
continue;
|
|
20351
|
+
const group = renderedById.get(message.info.id) ?? [];
|
|
20352
|
+
group.push(message);
|
|
20353
|
+
renderedById.set(message.info.id, group);
|
|
20354
|
+
}
|
|
20355
|
+
const suffix = recoveryTailSources.flatMap(({ identity, pristineSystem }) => pristineSystem ? [pristineSystem] : renderedById.get(identity) ?? []);
|
|
20328
20356
|
messages.splice(0, messages.length, ...JSON.parse(recovery.prefix.json), ...suffix);
|
|
20329
20357
|
}
|
|
20330
20358
|
const recoveryReleaseReason = recovery.rebuildReason ?? (recoveryNormalized ? "recovery_tail_normalized" : undefined);
|
|
@@ -20781,6 +20809,8 @@ function replayCommittedDrops(db, sessionId, messages) {
|
|
|
20781
20809
|
const toolThinking = new Map;
|
|
20782
20810
|
const batch = new ToolMutationBatch(messages);
|
|
20783
20811
|
for (const message of messages) {
|
|
20812
|
+
if (message.info.syntheticHead === true)
|
|
20813
|
+
continue;
|
|
20784
20814
|
if (message.info.role === "user")
|
|
20785
20815
|
precedingThinking = [];
|
|
20786
20816
|
const thinking = message.parts.filter(isThinkingPart);
|
|
@@ -20814,9 +20844,10 @@ function replayCommittedDrops(db, sessionId, messages) {
|
|
|
20814
20844
|
message,
|
|
20815
20845
|
setContent(content) {
|
|
20816
20846
|
if (isTextPart(part)) {
|
|
20817
|
-
|
|
20847
|
+
const rendered = renderDroppedText(tag.tagNumber, part.text);
|
|
20848
|
+
if (part.text === rendered)
|
|
20818
20849
|
return false;
|
|
20819
|
-
part.text =
|
|
20850
|
+
part.text = rendered;
|
|
20820
20851
|
} else
|
|
20821
20852
|
message.parts[p] = { type: "text", text: content };
|
|
20822
20853
|
return true;
|
|
@@ -22349,8 +22380,23 @@ WHERE session_id = ?
|
|
|
22349
22380
|
AND data IS NOT NULL
|
|
22350
22381
|
AND (time_created > ? OR (time_created = ? AND id > ?))
|
|
22351
22382
|
ORDER BY time_created, id`;
|
|
22352
|
-
|
|
22353
|
-
|
|
22383
|
+
var V2_ASSISTANT_USAGE_ROWS_AFTER_SQL = `
|
|
22384
|
+
SELECT
|
|
22385
|
+
json_extract(data, '$.agent') AS agent,
|
|
22386
|
+
seq AS time_created,
|
|
22387
|
+
id AS id,
|
|
22388
|
+
COALESCE(json_extract(data, '$.tokens.input'), 0)
|
|
22389
|
+
+ COALESCE(json_extract(data, '$.tokens.cache.read'), 0)
|
|
22390
|
+
+ COALESCE(json_extract(data, '$.tokens.cache.write'), 0) AS prompt,
|
|
22391
|
+
COALESCE(json_extract(data, '$.tokens.output'), 0) AS output
|
|
22392
|
+
FROM session_message
|
|
22393
|
+
WHERE session_id = ?
|
|
22394
|
+
AND type = 'assistant'
|
|
22395
|
+
AND data IS NOT NULL
|
|
22396
|
+
AND (seq > ? OR (seq = ? AND id > ?))
|
|
22397
|
+
ORDER BY seq, id`;
|
|
22398
|
+
function readAssistantUsageRowsAfter(openCodeDb, sessionId, afterTimeCreated, afterId, generation = "v1") {
|
|
22399
|
+
const rows = openCodeDb.prepare(generation === "v2" ? V2_ASSISTANT_USAGE_ROWS_AFTER_SQL : ASSISTANT_USAGE_ROWS_AFTER_SQL).all(sessionId, afterTimeCreated, afterTimeCreated, afterId);
|
|
22354
22400
|
return rows.map((r) => ({
|
|
22355
22401
|
agent: r.agent ?? null,
|
|
22356
22402
|
timeCreated: Number(r.time_created ?? 0),
|
|
@@ -22359,8 +22405,8 @@ function readAssistantUsageRowsAfter(openCodeDb, sessionId, afterTimeCreated, af
|
|
|
22359
22405
|
output: Number(r.output ?? 0)
|
|
22360
22406
|
}));
|
|
22361
22407
|
}
|
|
22362
|
-
function computeOpenCodeWorkMetricsIncremental(openCodeDb, sessionId, carry) {
|
|
22363
|
-
const rows = readAssistantUsageRowsAfter(openCodeDb, sessionId, carry.lastTimeCreated, carry.lastId);
|
|
22408
|
+
function computeOpenCodeWorkMetricsIncremental(openCodeDb, sessionId, carry, generation = "v1") {
|
|
22409
|
+
const rows = readAssistantUsageRowsAfter(openCodeDb, sessionId, carry.lastTimeCreated, carry.lastId, generation);
|
|
22364
22410
|
if (rows.length === 0) {
|
|
22365
22411
|
return { carry, metrics: metricsFromCarry(carry) };
|
|
22366
22412
|
}
|
|
@@ -22387,28 +22433,28 @@ var EMBEDDING_AFFECTING_KEYS = new Set([
|
|
|
22387
22433
|
"embedding.query_instruction",
|
|
22388
22434
|
"embedding.document_prefix",
|
|
22389
22435
|
"embedding.fallback_provider",
|
|
22390
|
-
"
|
|
22436
|
+
"embedding.local_runtime",
|
|
22437
|
+
"embedding.local_dtype",
|
|
22391
22438
|
"subc.connection_file",
|
|
22392
|
-
"shadow_embedding"
|
|
22439
|
+
"shadow_embedding.enabled",
|
|
22440
|
+
"memory.enabled",
|
|
22441
|
+
"memory.git_commit_indexing.enabled",
|
|
22442
|
+
"allow_home_project"
|
|
22393
22443
|
]);
|
|
22394
22444
|
var LITERAL_CONFIG_TOKEN_RE = /\{(?:env|file):[^}]+\}/;
|
|
22395
|
-
function
|
|
22396
|
-
|
|
22397
|
-
|
|
22398
|
-
|
|
22445
|
+
function affectsEmbeddingRegistration(path) {
|
|
22446
|
+
return [...EMBEDDING_AFFECTING_KEYS].some((field) => field === path || field.startsWith(`${path}.`));
|
|
22447
|
+
}
|
|
22448
|
+
function untrustedConfigFieldPaths(detailed) {
|
|
22449
|
+
const paths = (detailed.recoveredFieldPaths ?? detailed.recoveredTopLevelKeys).filter(affectsEmbeddingRegistration);
|
|
22450
|
+
paths.push(...detailed.substitutionFailures.map((failure) => failure.keyPath).filter(affectsEmbeddingRegistration));
|
|
22451
|
+
for (const [key, value] of Object.entries(detailed.config.embedding)) {
|
|
22399
22452
|
if (typeof value === "string" && LITERAL_CONFIG_TOKEN_RE.test(value)) {
|
|
22400
|
-
|
|
22453
|
+
paths.push(`embedding.${key}`);
|
|
22401
22454
|
}
|
|
22402
22455
|
}
|
|
22403
|
-
return
|
|
22456
|
+
return [...new Set(paths)].sort();
|
|
22404
22457
|
}
|
|
22405
|
-
var EMBEDDING_AFFECTING_TOP_LEVEL_KEYS = new Set([
|
|
22406
|
-
"embedding",
|
|
22407
|
-
"memory",
|
|
22408
|
-
"experimental",
|
|
22409
|
-
"subc",
|
|
22410
|
-
"shadow_embedding"
|
|
22411
|
-
]);
|
|
22412
22458
|
var EMBEDDING_WARNING_TERMS = [
|
|
22413
22459
|
"api_key",
|
|
22414
22460
|
"endpoint",
|
|
@@ -22433,21 +22479,12 @@ function isConfigLoadUntrusted(detailed) {
|
|
|
22433
22479
|
return true;
|
|
22434
22480
|
}
|
|
22435
22481
|
for (const failure of detailed.substitutionFailures) {
|
|
22436
|
-
if (EMBEDDING_AFFECTING_KEYS.has(failure.keyPath)) {
|
|
22437
|
-
return true;
|
|
22438
|
-
}
|
|
22439
22482
|
if (failure.keyPath === "<unknown>" && warningLooksEmbeddingRelated(failure.message)) {
|
|
22440
22483
|
return true;
|
|
22441
22484
|
}
|
|
22442
22485
|
}
|
|
22443
|
-
|
|
22444
|
-
if (EMBEDDING_AFFECTING_TOP_LEVEL_KEYS.has(recoveredKey)) {
|
|
22445
|
-
return true;
|
|
22446
|
-
}
|
|
22447
|
-
}
|
|
22448
|
-
if (embeddingConfigHasLiteralTokens(detailed.config.embedding)) {
|
|
22486
|
+
if (untrustedConfigFieldPaths(detailed).length > 0)
|
|
22449
22487
|
return true;
|
|
22450
|
-
}
|
|
22451
22488
|
return false;
|
|
22452
22489
|
}
|
|
22453
22490
|
function describeFailure(detailed) {
|
|
@@ -22460,8 +22497,9 @@ function describeFailure(detailed) {
|
|
|
22460
22497
|
if (detailed.substitutionFailures.length > 0) {
|
|
22461
22498
|
parts.push(`substitution=${detailed.substitutionFailures.map((failure) => `${failure.source}:${failure.keyPath}`).join(",")}`);
|
|
22462
22499
|
}
|
|
22463
|
-
|
|
22464
|
-
|
|
22500
|
+
const recovered = detailed.recoveredFieldPaths ?? detailed.recoveredTopLevelKeys;
|
|
22501
|
+
if (recovered.length > 0) {
|
|
22502
|
+
parts.push(`recovered=${recovered.join(",")}`);
|
|
22465
22503
|
}
|
|
22466
22504
|
return parts.length > 0 ? parts.join("; ") : detailed.loadOutcome;
|
|
22467
22505
|
}
|
|
@@ -22469,7 +22507,8 @@ function logConfigFailureOnce(projectIdentity, detailed) {
|
|
|
22469
22507
|
const signature = sha256Prefix(JSON.stringify({
|
|
22470
22508
|
outcomes: detailed.sources,
|
|
22471
22509
|
substitutions: detailed.substitutionFailures.map((failure) => `${failure.source}:${failure.keyPath}:${failure.message}`).sort(),
|
|
22472
|
-
recoveredTopLevelKeys: [...detailed.recoveredTopLevelKeys].sort()
|
|
22510
|
+
recoveredTopLevelKeys: [...detailed.recoveredTopLevelKeys].sort(),
|
|
22511
|
+
recoveredFieldPaths: detailed.recoveredFieldPaths?.slice().sort()
|
|
22473
22512
|
}));
|
|
22474
22513
|
const existing = loggedFailureSignatures.get(projectIdentity) ?? new Set;
|
|
22475
22514
|
if (existing.has(signature))
|
|
@@ -22485,9 +22524,14 @@ function handleUntrustedLoad(db, projectIdentity, directory, detailed) {
|
|
|
22485
22524
|
logConfigFailureOnce(projectIdentity, detailed);
|
|
22486
22525
|
return true;
|
|
22487
22526
|
}
|
|
22488
|
-
registerProjectInObservationMode2(db, projectIdentity, directory, detailed.config.embedding, describeFailure(detailed));
|
|
22527
|
+
registerProjectInObservationMode2(db, projectIdentity, directory, detailed.config.embedding, describeFailure(detailed), untrustedConfigMemoryMessage(detailed));
|
|
22489
22528
|
return true;
|
|
22490
22529
|
}
|
|
22530
|
+
function untrustedConfigMemoryMessage(detailed) {
|
|
22531
|
+
const fields = untrustedConfigFieldPaths(detailed);
|
|
22532
|
+
const cause = fields.length > 0 ? `has invalid embedding or project identity settings: ${fields.join(", ")}` : Object.values(detailed.sources).includes("legacy-config-unmigrated") ? "is awaiting config migration" : Object.values(detailed.sources).some((source) => source === "project-file-parse-error" || source === "project-file-io-error") ? "could not be read or parsed" : "has invalid embedding settings";
|
|
22533
|
+
return `Cross-session memory is off for this project because magic-context.jsonc ${cause}.`;
|
|
22534
|
+
}
|
|
22491
22535
|
|
|
22492
22536
|
// src/plugin/embedding-routing.ts
|
|
22493
22537
|
var SYNAPSE_PROBE_TTL_MS = 60000;
|
|
@@ -23034,13 +23078,15 @@ function runnerStatusFromModule(status) {
|
|
|
23034
23078
|
}
|
|
23035
23079
|
var rustStatusInFlight = new Map;
|
|
23036
23080
|
function resolveSidebarWorkMetrics(db, sessionId, persistedNewWork, persistedTotalInput) {
|
|
23037
|
-
|
|
23081
|
+
const generation = getHarness2() === "opencode2" ? "v2" : "v1";
|
|
23082
|
+
if (!openCodeDbExists(generation)) {
|
|
23038
23083
|
return { newWorkTokens: persistedNewWork, totalInputTokens: persistedTotalInput };
|
|
23039
23084
|
}
|
|
23040
23085
|
try {
|
|
23041
|
-
const
|
|
23042
|
-
const
|
|
23043
|
-
|
|
23086
|
+
const carryKey = `${generation}:${sessionId}`;
|
|
23087
|
+
const carry = workMetricsCarryBySession.get(carryKey) ?? emptyWorkMetricsCarry();
|
|
23088
|
+
const { carry: nextCarry, metrics } = withReadOnlySessionDb((openCodeDb) => computeOpenCodeWorkMetricsIncremental(openCodeDb, sessionId, carry, generation), generation);
|
|
23089
|
+
workMetricsCarryBySession.set(carryKey, nextCarry);
|
|
23044
23090
|
try {
|
|
23045
23091
|
setSessionWorkMetrics(db, sessionId, metrics.newWorkTokens, metrics.totalInputTokens);
|
|
23046
23092
|
} catch {}
|
|
@@ -23941,8 +23987,8 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
23941
23987
|
const db = readDatabase();
|
|
23942
23988
|
if (!db)
|
|
23943
23989
|
return { ok: false, error: "db unavailable" };
|
|
23944
|
-
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-
|
|
23945
|
-
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-
|
|
23990
|
+
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-f1df1gb8.js"));
|
|
23991
|
+
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-x5nzy34v.js"));
|
|
23946
23992
|
log2(`[rpc] recomp requested for session ${sessionId}`);
|
|
23947
23993
|
if (!args.client && !args.hiddenCompletionExecutor) {
|
|
23948
23994
|
return {
|
|
@@ -24026,7 +24072,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
24026
24072
|
const db = readDatabase();
|
|
24027
24073
|
if (!db)
|
|
24028
24074
|
return { ok: false, error: "db unavailable" };
|
|
24029
|
-
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-
|
|
24075
|
+
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-jq33fda8.js"));
|
|
24030
24076
|
const model = liveSessionState.liveModelBySession.get(sessionId);
|
|
24031
24077
|
const contextLimit = model ? resolveContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : 128000;
|
|
24032
24078
|
const ctx = {
|
|
@@ -27139,6 +27185,16 @@ function toolResultText(result) {
|
|
|
27139
27185
|
`);
|
|
27140
27186
|
return text.length > 0 ? text : undefined;
|
|
27141
27187
|
}
|
|
27188
|
+
function sumRowUsage(rows) {
|
|
27189
|
+
const count = (value) => typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
27190
|
+
return rows.reduce((total, row) => ({
|
|
27191
|
+
input: total.input + count(row.data.tokens?.input),
|
|
27192
|
+
output: total.output + count(row.data.tokens?.output),
|
|
27193
|
+
cacheRead: total.cacheRead + count(row.data.tokens?.cache?.read),
|
|
27194
|
+
cacheWrite: total.cacheWrite + count(row.data.tokens?.cache?.write),
|
|
27195
|
+
...total.reasoning !== undefined || row.data.tokens?.reasoning !== undefined ? { reasoning: (total.reasoning ?? 0) + count(row.data.tokens?.reasoning) } : {}
|
|
27196
|
+
}), { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 });
|
|
27197
|
+
}
|
|
27142
27198
|
function toolLoopMessages(attempt, rows) {
|
|
27143
27199
|
const messages = attempt.observedMessages ?? [];
|
|
27144
27200
|
const results = new Map;
|
|
@@ -27331,6 +27387,10 @@ function createLateHiddenExecutor(current) {
|
|
|
27331
27387
|
open: (run) => wired().open(run),
|
|
27332
27388
|
attempt: (handle, request) => wired().attempt(handle, request),
|
|
27333
27389
|
collect: (handle, limit) => wired().collect(handle, limit),
|
|
27390
|
+
collectPartial: (handle, limit) => {
|
|
27391
|
+
const executor = wired();
|
|
27392
|
+
return executor.collectPartial?.(handle, limit) ?? executor.collect(handle, limit);
|
|
27393
|
+
},
|
|
27334
27394
|
close: (handle, settlement) => wired().close(handle, settlement)
|
|
27335
27395
|
};
|
|
27336
27396
|
}
|
|
@@ -27420,9 +27480,32 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
27420
27480
|
});
|
|
27421
27481
|
run.child = lifecycle.updateModel(run.child, requested);
|
|
27422
27482
|
};
|
|
27483
|
+
const partialCompletion = (run) => {
|
|
27484
|
+
const attempt = run.attempt;
|
|
27485
|
+
const rows = attempt ? withReader(options.openReader, (reader) => {
|
|
27486
|
+
const latest = reader.latestAssistant(run.child.id);
|
|
27487
|
+
return (reader.assistantSince?.(run.child.id, attempt.baseline) ?? (latest ? [latest] : [])).filter((row) => row.seq > attempt.baseline);
|
|
27488
|
+
}) : [];
|
|
27489
|
+
const usage = sumRowUsage(rows);
|
|
27490
|
+
return {
|
|
27491
|
+
text: rows.map(assistantText).filter(Boolean).join(`
|
|
27492
|
+
`) || null,
|
|
27493
|
+
messages: attempt ? toolLoopMessages(attempt.child, rows) : [],
|
|
27494
|
+
usage,
|
|
27495
|
+
tokenLog: runTokenLog(usage),
|
|
27496
|
+
lengthCapped: false
|
|
27497
|
+
};
|
|
27498
|
+
};
|
|
27423
27499
|
const retire = (run, reason) => {
|
|
27424
27500
|
if (run.retired)
|
|
27425
27501
|
return;
|
|
27502
|
+
if (hiddenToolLoop(run.identity) && !run.completion) {
|
|
27503
|
+
try {
|
|
27504
|
+
run.partialCompletion = partialCompletion(run);
|
|
27505
|
+
} catch (error) {
|
|
27506
|
+
note(`[magic-context] could not read interrupted child output: ${String(error)}`);
|
|
27507
|
+
}
|
|
27508
|
+
}
|
|
27426
27509
|
lifecycle.retire(run.child, reason);
|
|
27427
27510
|
run.retired = true;
|
|
27428
27511
|
};
|
|
@@ -27553,6 +27636,8 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
27553
27636
|
shaped: false,
|
|
27554
27637
|
budget: run.budget
|
|
27555
27638
|
};
|
|
27639
|
+
run.partialCompletion = undefined;
|
|
27640
|
+
run.attempt = { child: attempt, baseline };
|
|
27556
27641
|
options.hook.registerAttempt(marker, attempt);
|
|
27557
27642
|
const deadline = Date.now() + run.identity.timeoutMs;
|
|
27558
27643
|
const budget = run.budget;
|
|
@@ -27688,19 +27773,14 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
27688
27773
|
const tokenNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
27689
27774
|
const steps = withReader(options.openReader, (reader) => reader.assistantSince?.(run.child.id, baseline) ?? [row]).filter((step) => step.seq > baseline && step.seq <= row.seq);
|
|
27690
27775
|
const reportedUsage = steps.some((step) => tokenNumber(step.data.tokens?.input) !== undefined || tokenNumber(step.data.tokens?.output) !== undefined);
|
|
27691
|
-
const usage = steps
|
|
27692
|
-
input: total.input + (tokenNumber(step.data.tokens?.input) ?? 0),
|
|
27693
|
-
output: total.output + (tokenNumber(step.data.tokens?.output) ?? 0),
|
|
27694
|
-
cacheRead: total.cacheRead + (tokenNumber(step.data.tokens?.cache?.read) ?? 0),
|
|
27695
|
-
cacheWrite: total.cacheWrite + (tokenNumber(step.data.tokens?.cache?.write) ?? 0)
|
|
27696
|
-
}), { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 });
|
|
27776
|
+
const usage = sumRowUsage(steps);
|
|
27697
27777
|
if (request.signal?.aborted || run.retired || Date.now() >= deadline) {
|
|
27698
27778
|
await interruptAndRetire(run, "prompt-aborted-or-timeout");
|
|
27699
27779
|
throw new Error(request.signal?.aborted ? "Hidden completion prompt aborted" : "Hidden completion prompt timed out");
|
|
27700
27780
|
}
|
|
27701
27781
|
run.completion = {
|
|
27702
27782
|
text,
|
|
27703
|
-
tokenLog: runTokenLog(tokens, run.identity.maxOutputTokens, row.data.finish),
|
|
27783
|
+
tokenLog: runTokenLog(reportedUsage ? usage : tokens, run.identity.maxOutputTokens, row.data.finish),
|
|
27704
27784
|
...hiddenToolLoop(run.identity) ? { messages: toolLoopMessages(attempt, steps) } : {},
|
|
27705
27785
|
reasoning: text ? null : assistantReasoning(row),
|
|
27706
27786
|
usage: reportedUsage ? usage : meter(system, promptText(request), text ?? ""),
|
|
@@ -27749,6 +27829,12 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
27749
27829
|
throw new Error("Hidden completion has no settled output");
|
|
27750
27830
|
return completion;
|
|
27751
27831
|
},
|
|
27832
|
+
async collectPartial(handle) {
|
|
27833
|
+
const run = runs.get(handle);
|
|
27834
|
+
if (!run)
|
|
27835
|
+
throw new Error("Hidden completion handle is closed");
|
|
27836
|
+
return run.completion ?? run.partialCompletion ?? partialCompletion(run);
|
|
27837
|
+
},
|
|
27752
27838
|
async close(handle, settlement) {
|
|
27753
27839
|
if (!handle)
|
|
27754
27840
|
return;
|
|
@@ -28923,7 +29009,7 @@ async function runHiddenSingleShotPrompt(args) {
|
|
|
28923
29009
|
let timer;
|
|
28924
29010
|
try {
|
|
28925
29011
|
const completion = await Promise.race([
|
|
28926
|
-
args.executor.collect(handle, 200),
|
|
29012
|
+
args.executor.collectPartial?.(handle, 200) ?? args.executor.collect(handle, 200),
|
|
28927
29013
|
new Promise((resolve) => {
|
|
28928
29014
|
timer = setTimeout(() => resolve(null), 5000);
|
|
28929
29015
|
})
|
|
@@ -30756,6 +30842,7 @@ Remember: output only the JSON object described by the system prompt.`;
|
|
|
30756
30842
|
let childSessionId = null;
|
|
30757
30843
|
let promptSettled = false;
|
|
30758
30844
|
let invocationRecorded = false;
|
|
30845
|
+
let completionUsage;
|
|
30759
30846
|
const recordInvocation = (params) => {
|
|
30760
30847
|
if (!args.db || !args.parentSessionId || invocationRecorded)
|
|
30761
30848
|
return;
|
|
@@ -30769,6 +30856,7 @@ Remember: output only the JSON object described by the system prompt.`;
|
|
|
30769
30856
|
startedAt,
|
|
30770
30857
|
status: params.status,
|
|
30771
30858
|
messages: params.messages,
|
|
30859
|
+
tokens: args.hiddenCompletionExecutor?.capabilities.harness === "opencode2" ? completionUsage : undefined,
|
|
30772
30860
|
attemptedModel: args.model,
|
|
30773
30861
|
configuredModels: args.fallbackModels,
|
|
30774
30862
|
error: params.error
|
|
@@ -30793,11 +30881,15 @@ Remember: output only the JSON object described by the system prompt.`;
|
|
|
30793
30881
|
timeoutMs: remainingMs,
|
|
30794
30882
|
signal: args.signal,
|
|
30795
30883
|
metadata: { task: "evaluate-smart-notes" },
|
|
30884
|
+
onFailureOutput: (completion) => {
|
|
30885
|
+
completionUsage = completion.usage;
|
|
30886
|
+
},
|
|
30796
30887
|
parse: parseCompilerOutput
|
|
30797
30888
|
});
|
|
30798
30889
|
promptSettled = true;
|
|
30799
30890
|
response = carried.validated;
|
|
30800
30891
|
outputMessages = carried.completion.messages;
|
|
30892
|
+
completionUsage = carried.completion.usage;
|
|
30801
30893
|
} else {
|
|
30802
30894
|
const client = args.client;
|
|
30803
30895
|
if (!client) {
|
|
@@ -31575,6 +31667,7 @@ async function confirmReadOnly(args, noteId, content, surfaceCondition, leaseSig
|
|
|
31575
31667
|
startedAt,
|
|
31576
31668
|
status: params.status,
|
|
31577
31669
|
messages: params.messages,
|
|
31670
|
+
tokens: args.hiddenCompletionExecutor?.capabilities.harness === "opencode2" ? params.tokens : undefined,
|
|
31578
31671
|
attemptedModel: args.model,
|
|
31579
31672
|
configuredModels: args.fallbackModels,
|
|
31580
31673
|
error: params.error
|
|
@@ -31602,7 +31695,11 @@ async function confirmReadOnly(args, noteId, content, surfaceCondition, leaseSig
|
|
|
31602
31695
|
parse: parseConfirmationVerdict
|
|
31603
31696
|
});
|
|
31604
31697
|
promptSettled = true;
|
|
31605
|
-
recordInvocation({
|
|
31698
|
+
recordInvocation({
|
|
31699
|
+
status: "completed",
|
|
31700
|
+
messages: run.completion.messages,
|
|
31701
|
+
tokens: run.completion.usage
|
|
31702
|
+
});
|
|
31606
31703
|
return run.validated;
|
|
31607
31704
|
} finally {
|
|
31608
31705
|
promptSignal.cleanup();
|
|
@@ -32270,7 +32367,8 @@ async function mapOneBatch(args, batch, sliceMs, signal) {
|
|
|
32270
32367
|
});
|
|
32271
32368
|
recordInvocation2(args, startedAt, {
|
|
32272
32369
|
status: "completed",
|
|
32273
|
-
messages: run.completion.messages ?? []
|
|
32370
|
+
messages: run.completion.messages ?? [],
|
|
32371
|
+
tokens: run.completion.usage
|
|
32274
32372
|
});
|
|
32275
32373
|
stage = "apply";
|
|
32276
32374
|
const outcome = await applyParsedBatchMappings(args, batch, run.validated, budgetFinalized, true);
|
|
@@ -32345,7 +32443,8 @@ async function mapOneBatch(args, batch, sliceMs, signal) {
|
|
|
32345
32443
|
recordInvocation2(args, startedAt, {
|
|
32346
32444
|
status: failedInvocationStatus(error),
|
|
32347
32445
|
error,
|
|
32348
|
-
messages
|
|
32446
|
+
messages,
|
|
32447
|
+
tokens: failedCompletion?.usage
|
|
32349
32448
|
});
|
|
32350
32449
|
if (error instanceof DreamerModuleFailureError)
|
|
32351
32450
|
throw error;
|
|
@@ -32512,6 +32611,7 @@ function recordInvocation2(args, startedAt, params) {
|
|
|
32512
32611
|
startedAt,
|
|
32513
32612
|
status: params.status,
|
|
32514
32613
|
messages: params.messages,
|
|
32614
|
+
tokens: args.hiddenCompletionExecutor?.capabilities.harness === "opencode2" ? params.tokens : undefined,
|
|
32515
32615
|
attemptedModel: args.model,
|
|
32516
32616
|
configuredModels: args.fallbackModels,
|
|
32517
32617
|
error: params.error
|
|
@@ -33790,7 +33890,8 @@ async function git2(root, args) {
|
|
|
33790
33890
|
cwd: root,
|
|
33791
33891
|
timeout: 1e4,
|
|
33792
33892
|
maxBuffer: MAX_DIFF_BYTES,
|
|
33793
|
-
encoding: "utf8"
|
|
33893
|
+
encoding: "utf8",
|
|
33894
|
+
windowsHide: true
|
|
33794
33895
|
});
|
|
33795
33896
|
return stdout;
|
|
33796
33897
|
}
|
|
@@ -34432,7 +34533,8 @@ async function verifyOneBatch(args, batch, sliceMs, signal) {
|
|
|
34432
34533
|
});
|
|
34433
34534
|
recordInvocation4(args, startedAt, {
|
|
34434
34535
|
status: "completed",
|
|
34435
|
-
messages: run.completion.messages ?? []
|
|
34536
|
+
messages: run.completion.messages ?? [],
|
|
34537
|
+
tokens: run.completion.usage
|
|
34436
34538
|
});
|
|
34437
34539
|
reportUsage(run.completion.messages ?? [], run.childSessionId, run.completion.usage.input + (run.completion.usage.cacheRead ?? 0) + (run.completion.usage.cacheWrite ?? 0));
|
|
34438
34540
|
return await applyParsedVerifyManifest(args, batch, run.validated, evidence?.head ?? headAtPrompt, budgetFinalized);
|
|
@@ -34506,7 +34608,8 @@ async function verifyOneBatch(args, batch, sliceMs, signal) {
|
|
|
34506
34608
|
recordInvocation4(args, startedAt, {
|
|
34507
34609
|
status: failedInvocationStatus(error),
|
|
34508
34610
|
error,
|
|
34509
|
-
messages
|
|
34611
|
+
messages,
|
|
34612
|
+
tokens: failedCompletion?.usage
|
|
34510
34613
|
});
|
|
34511
34614
|
if (error instanceof DreamerModuleFailureError || signal.aborted)
|
|
34512
34615
|
throw error;
|
|
@@ -34765,6 +34868,7 @@ function recordInvocation4(args, startedAt, params) {
|
|
|
34765
34868
|
startedAt,
|
|
34766
34869
|
status: params.status,
|
|
34767
34870
|
messages: params.messages,
|
|
34871
|
+
tokens: args.hiddenCompletionExecutor?.capabilities.harness === "opencode2" ? params.tokens : undefined,
|
|
34768
34872
|
attemptedModel: args.model,
|
|
34769
34873
|
configuredModels: args.fallbackModels,
|
|
34770
34874
|
error: params.error
|
|
@@ -34834,6 +34938,15 @@ function classifyFailure(error) {
|
|
|
34834
34938
|
const transient = explicitTransient || name === "AbortError" || /abort|lease|timeout|timed out|econn|socket|network|rate.?limit|429|503|overloaded|sqlite_busy|database is locked/.test(combined);
|
|
34835
34939
|
return { transient, brief };
|
|
34836
34940
|
}
|
|
34941
|
+
function sumCompletionUsages(usages) {
|
|
34942
|
+
return usages.reduce((total, usage) => ({
|
|
34943
|
+
input: total.input + usage.input,
|
|
34944
|
+
output: total.output + usage.output,
|
|
34945
|
+
cacheRead: total.cacheRead + usage.cacheRead,
|
|
34946
|
+
cacheWrite: total.cacheWrite + usage.cacheWrite,
|
|
34947
|
+
...total.reasoning !== undefined || usage.reasoning !== undefined ? { reasoning: (total.reasoning ?? 0) + (usage.reasoning ?? 0) } : {}
|
|
34948
|
+
}), emptyTokenTotals());
|
|
34949
|
+
}
|
|
34837
34950
|
function newIds(beforeIds, afterIds) {
|
|
34838
34951
|
const before = new Set(beforeIds);
|
|
34839
34952
|
const out = [];
|
|
@@ -35641,6 +35754,7 @@ async function runRetrospectiveTask(config, ctx, helpers) {
|
|
|
35641
35754
|
}, ctx.leaseAcquisition);
|
|
35642
35755
|
let childSessionId = null;
|
|
35643
35756
|
let hiddenHandle = null;
|
|
35757
|
+
const hiddenUsages = [];
|
|
35644
35758
|
let promptSettled = false;
|
|
35645
35759
|
let invocationRecorded = false;
|
|
35646
35760
|
const recordInvocation = (status, messages, error) => {
|
|
@@ -35656,6 +35770,7 @@ async function runRetrospectiveTask(config, ctx, helpers) {
|
|
|
35656
35770
|
startedAt: helpers.invocationStartedAt,
|
|
35657
35771
|
status,
|
|
35658
35772
|
messages,
|
|
35773
|
+
tokens: deps.hiddenCompletionExecutor?.capabilities.harness === "opencode2" && hiddenUsages.length ? sumCompletionUsages(hiddenUsages) : undefined,
|
|
35659
35774
|
attemptedModel: config.model,
|
|
35660
35775
|
configuredModels: config.fallbackModels,
|
|
35661
35776
|
error
|
|
@@ -35741,6 +35856,8 @@ async function runRetrospectiveTask(config, ctx, helpers) {
|
|
|
35741
35856
|
}
|
|
35742
35857
|
});
|
|
35743
35858
|
promptSettled = true;
|
|
35859
|
+
if (hiddenHandle)
|
|
35860
|
+
hiddenUsages.push(run.output.usage);
|
|
35744
35861
|
const output = hiddenHandle ? run.output.messages ?? [] : run.output;
|
|
35745
35862
|
return { ...run, output };
|
|
35746
35863
|
};
|
|
@@ -35911,6 +36028,7 @@ async function runAgenticTask(config, ctx, helpers) {
|
|
|
35911
36028
|
let childSessionId = null;
|
|
35912
36029
|
let promptSettled = false;
|
|
35913
36030
|
let expiredArchived = 0;
|
|
36031
|
+
const hiddenUsages = [];
|
|
35914
36032
|
let invocationRecorded = false;
|
|
35915
36033
|
const recordInvocation = (status, messages, error) => {
|
|
35916
36034
|
if (!parent || !childSessionId || invocationRecorded)
|
|
@@ -35925,6 +36043,7 @@ async function runAgenticTask(config, ctx, helpers) {
|
|
|
35925
36043
|
startedAt: invocationStartedAt,
|
|
35926
36044
|
status,
|
|
35927
36045
|
messages,
|
|
36046
|
+
tokens: deps.hiddenCompletionExecutor?.capabilities.harness === "opencode2" && hiddenUsages.length ? sumCompletionUsages(hiddenUsages) : undefined,
|
|
35928
36047
|
attemptedModel: config.model,
|
|
35929
36048
|
configuredModels: config.fallbackModels,
|
|
35930
36049
|
error
|
|
@@ -36042,6 +36161,7 @@ async function runAgenticTask(config, ctx, helpers) {
|
|
|
36042
36161
|
}
|
|
36043
36162
|
});
|
|
36044
36163
|
childSessionId = hidden.childSessionId;
|
|
36164
|
+
hiddenUsages.push(hidden.completion.usage);
|
|
36045
36165
|
run = { output: hidden.completion.messages ?? [], validated: hidden.validated };
|
|
36046
36166
|
promptSettled = true;
|
|
36047
36167
|
} else {
|
|
@@ -37256,7 +37376,8 @@ async function sweepGitCommits(args) {
|
|
|
37256
37376
|
try {
|
|
37257
37377
|
const result = await indexCommitsForProject(db, projectIdentity, directory, {
|
|
37258
37378
|
sinceDays: gitCommitIndexing.since_days,
|
|
37259
|
-
maxCommits: gitCommitIndexing.max_commits
|
|
37379
|
+
maxCommits: gitCommitIndexing.max_commits,
|
|
37380
|
+
skipRetention: isCommitRetentionPaused(gitCommitIndexing)
|
|
37260
37381
|
});
|
|
37261
37382
|
if (result.nonIndexable) {
|
|
37262
37383
|
if (!parkGitSweepNonIndexable(db, projectIdentity, holderId)) {
|
|
@@ -37341,11 +37462,7 @@ function registerV2DreamScheduleTimer(args) {
|
|
|
37341
37462
|
embeddingConfig: config.embedding,
|
|
37342
37463
|
transformMode: config.transform_mode,
|
|
37343
37464
|
moduleClient: createDreamTimerModuleClient(args.rustModeModuleClient),
|
|
37344
|
-
gitCommitIndexing: gitCommitIndexing?.enabled ?
|
|
37345
|
-
enabled: true,
|
|
37346
|
-
since_days: gitCommitIndexing.since_days,
|
|
37347
|
-
max_commits: gitCommitIndexing.max_commits
|
|
37348
|
-
} : undefined,
|
|
37465
|
+
gitCommitIndexing: gitCommitIndexing?.enabled ? gitCommitIndexing : undefined,
|
|
37349
37466
|
ensureRegistered: args.ensureRegistered ?? ensureProjectRegisteredFromOpenCodeDirectory
|
|
37350
37467
|
}).catch((error) => {
|
|
37351
37468
|
log2(`[magic-context] v2 dream timer registration failed (continuing without it): ${error}`);
|
|
@@ -38414,7 +38531,7 @@ function projectRawMessages(rows, ordinalFor) {
|
|
|
38414
38531
|
const message = {
|
|
38415
38532
|
id: row.id,
|
|
38416
38533
|
ordinal: ordinalFor(row, index),
|
|
38417
|
-
role: row.type === "assistant" ? "assistant" : "user",
|
|
38534
|
+
role: row.type === "assistant" ? "assistant" : row.type === "system" ? "system" : "user",
|
|
38418
38535
|
createdAt: row.time_created ?? row.data.time?.created,
|
|
38419
38536
|
parts: row.type === "assistant" ? (row.data.content ?? []).map((part) => {
|
|
38420
38537
|
if (part.type !== "tool")
|
|
@@ -51102,7 +51219,7 @@ function createCtxMemoryTool(deps) {
|
|
|
51102
51219
|
const memoryOwnedByTool = (memory) => visibility.owned(memory);
|
|
51103
51220
|
const embeddingSnapshot = getProjectEmbeddingSnapshot2(projectPath);
|
|
51104
51221
|
if (embeddingSnapshot ? !embeddingSnapshot.features.memoryEnabled : deps.memoryEnabled === false) {
|
|
51105
|
-
return getDisabledMessage();
|
|
51222
|
+
return embeddingSnapshot?.memoryDisabledReason ?? getDisabledMessage();
|
|
51106
51223
|
}
|
|
51107
51224
|
if (args.action === "write") {
|
|
51108
51225
|
const content = args.content?.trim();
|