@cortexkit/opencode-magic-context 0.42.3 → 0.42.5
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 +3 -1
- package/dist/{announcement-3c1vertn.js → announcement-8mgn61fw.js} +1 -1
- package/dist/{conflict-warning-hook-aedp084d.js → conflict-warning-hook-jyj54gbe.js} +4 -4
- package/dist/{derive-budgets-s2pgnnm4.js → derive-budgets-v1fkhjjr.js} +2 -2
- package/dist/features/magic-context/context-authority.d.ts +13 -0
- package/dist/features/magic-context/context-authority.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/classify.d.ts +3 -1
- package/dist/features/magic-context/dreamer/classify.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/curate-category-rotation.d.ts +26 -0
- package/dist/features/magic-context/dreamer/curate-category-rotation.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/storage-task-schedule.d.ts +7 -5
- package/dist/features/magic-context/dreamer/storage-task-schedule.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-executor.d.ts +6 -2
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-gates.d.ts +1 -0
- package/dist/features/magic-context/dreamer/task-gates.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-prompts.d.ts +3 -0
- package/dist/features/magic-context/dreamer/task-prompts.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-registry.d.ts +9 -0
- package/dist/features/magic-context/dreamer/task-registry.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts +5 -1
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-local.d.ts +11 -0
- package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
- package/dist/features/magic-context/mural/compress-cues.d.ts +3 -1
- package/dist/features/magic-context/mural/compress-cues.d.ts.map +1 -1
- package/dist/features/magic-context/transform-decision-log.d.ts +4 -0
- package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
- package/dist/hooks/magic-context/apply-operations.d.ts +4 -1
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/caveman-cleanup.d.ts +4 -0
- package/dist/hooks/magic-context/caveman-cleanup.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts +5 -2
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts +2 -2
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-types.d.ts +61 -2
- package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner.d.ts +2 -2
- package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/dropped-token-estimate.d.ts +20 -0
- package/dist/hooks/magic-context/dropped-token-estimate.d.ts.map +1 -0
- package/dist/hooks/magic-context/heuristic-cleanup.d.ts +2 -0
- package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts +2 -2
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-transport.d.ts +4 -1
- package/dist/hooks/magic-context/module-transport.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts +2 -0
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts +3 -0
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +8 -0
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +21 -0
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-sf6x1ga9.js → index-1ar7b3e9.js} +3 -3
- package/dist/{index-wde5446v.js → index-3wbd8sdq.js} +225 -67
- package/dist/{index-3fe78beq.js → index-4ftb5hcq.js} +9 -1
- package/dist/{index-may8skc8.js → index-4wwr6cz0.js} +18 -1
- package/dist/{index-ecz14qke.js → index-d8mgqezq.js} +2 -2
- package/dist/{index-xdtge3y2.js → index-f9gem5cr.js} +2 -2
- package/dist/{index-z8552w7e.js → index-jkrqhc7y.js} +1 -1
- package/dist/{index-3wzdwt6p.js → index-ntbmt6rq.js} +1 -1
- package/dist/{index-gynz8qdc.js → index-p474rw9p.js} +3 -3
- package/dist/{index-dkv2dn46.js → index-qp20p2py.js} +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1625 -148
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/rpc-handlers.d.ts +18 -0
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/plugin/rust-tool-backends.d.ts +3 -1
- package/dist/plugin/rust-tool-backends.d.ts.map +1 -1
- package/dist/{recomp-orchestrator-447vycpt.js → recomp-orchestrator-k20sfpm2.js} +6 -6
- package/dist/{safe-notification-target-q9z81zt3.js → safe-notification-target-fepvcbsj.js} +1 -1
- package/dist/{send-session-notification-2mzgd3zf.js → send-session-notification-xnypkxpx.js} +3 -3
- package/dist/shared/harness.d.ts +2 -1
- package/dist/shared/harness.d.ts.map +1 -1
- package/dist/shared/model-suggestion-retry.d.ts +5 -1
- package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
- package/dist/shared/prompt-surface-runtime.d.ts.map +1 -1
- package/dist/shared/rpc-types.d.ts +13 -0
- package/dist/shared/rpc-types.d.ts.map +1 -1
- package/dist/shared/status-detail-text.d.ts.map +1 -1
- package/dist/shared/status-summary.d.ts.map +1 -1
- package/dist/shared/user-facing-codes.d.ts +10 -0
- package/dist/shared/user-facing-codes.d.ts.map +1 -1
- package/dist/{storage-meta-session-fkmfhswa.js → storage-meta-session-x3j0q9qy.js} +3 -3
- package/dist/{task-config-hnv93r7p.js → task-config-cv8k9y8r.js} +1 -1
- package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
- package/dist/tools/ctx-note/tools.d.ts.map +1 -1
- package/dist/v2/fold/markers.d.ts +7 -0
- package/dist/v2/fold/markers.d.ts.map +1 -0
- package/dist/v2/fold/owner.d.ts +40 -0
- package/dist/v2/fold/owner.d.ts.map +1 -0
- package/dist/v2/fold/restore.d.ts +11 -0
- package/dist/v2/fold/restore.d.ts.map +1 -0
- package/dist/v2/hidden-completion.d.ts +20 -0
- package/dist/v2/hidden-completion.d.ts.map +1 -0
- package/dist/v2/hooks/channel2.d.ts +8 -0
- package/dist/v2/hooks/channel2.d.ts.map +1 -0
- package/dist/v2/hooks/context.d.ts +7 -0
- package/dist/v2/hooks/context.d.ts.map +1 -0
- package/dist/v2/hooks/dream-trigger.d.ts +19 -0
- package/dist/v2/hooks/dream-trigger.d.ts.map +1 -0
- package/dist/v2/hooks/payload.d.ts +12 -0
- package/dist/v2/hooks/payload.d.ts.map +1 -0
- package/dist/v2/hooks/refusal.d.ts +7 -0
- package/dist/v2/hooks/refusal.d.ts.map +1 -0
- package/dist/v2/hooks/store.d.ts +6 -0
- package/dist/v2/hooks/store.d.ts.map +1 -0
- package/dist/v2/hooks/types.d.ts +90 -0
- package/dist/v2/hooks/types.d.ts.map +1 -0
- package/dist/v2/hooks/update-check.d.ts +10 -0
- package/dist/v2/hooks/update-check.d.ts.map +1 -0
- package/dist/v2/server.d.ts +3 -1
- package/dist/v2/server.d.ts.map +1 -1
- package/dist/v2/server.js +116641 -4
- package/dist/v2/store-reader.d.ts +2 -0
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/index.js +1 -0
- package/package.json +5 -4
- package/src/features/magic-context/dreamer/task-registry.ts +29 -0
- package/src/shared/harness.ts +2 -1
- package/src/shared/model-suggestion-retry.ts +66 -14
- package/src/shared/prompt-surface-runtime.ts +5 -1
- package/src/shared/rpc-types.ts +13 -0
- package/src/shared/status-detail-text.test.ts +26 -0
- package/src/shared/status-detail-text.ts +11 -0
- package/src/shared/status-summary.ts +2 -0
- package/src/shared/user-facing-codes.test.ts +1 -1
- package/src/shared/user-facing-codes.ts +10 -0
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
sanitizeDiagnosticText,
|
|
3
3
|
log,
|
|
4
4
|
sessionLog
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-qp20p2py.js";
|
|
6
6
|
import {
|
|
7
7
|
logSlowWriteTransaction,
|
|
8
8
|
ensureSessionMetaRow,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
SESSION_SCOPED_TABLES,
|
|
12
12
|
deleteSessionScopedRows,
|
|
13
13
|
updateSessionMeta2
|
|
14
|
-
} from "./index-
|
|
14
|
+
} from "./index-1ar7b3e9.js";
|
|
15
15
|
import {
|
|
16
16
|
resolveOpenCodeDbPath,
|
|
17
17
|
openCodeDbPathExists,
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
withReadOnlySessionDb,
|
|
26
26
|
getRawSessionMessageCountFromDb,
|
|
27
27
|
getMessageTimesFromOpenCodeDb
|
|
28
|
-
} from "./index-
|
|
28
|
+
} from "./index-jkrqhc7y.js";
|
|
29
29
|
import {
|
|
30
30
|
pushNotification2
|
|
31
31
|
} from "./index-jdxxq8cz.js";
|
|
@@ -42,12 +42,12 @@ import {
|
|
|
42
42
|
shouldEnforcePrivateStoragePermissions,
|
|
43
43
|
modelSupportsVision,
|
|
44
44
|
deriveTriggerBudget2
|
|
45
|
-
} from "./index-
|
|
45
|
+
} from "./index-f9gem5cr.js";
|
|
46
46
|
import {
|
|
47
47
|
getErrorMessage,
|
|
48
48
|
describeError,
|
|
49
49
|
sendStatusNotification2
|
|
50
|
-
} from "./index-
|
|
50
|
+
} from "./index-p474rw9p.js";
|
|
51
51
|
import {
|
|
52
52
|
piModelRefToCanonical,
|
|
53
53
|
modelRefLookupOrder
|
|
@@ -58,7 +58,7 @@ import {
|
|
|
58
58
|
getProjectMagicContextHistorianDir,
|
|
59
59
|
getMagicContextStorageDir,
|
|
60
60
|
getLegacyOpenCodeMagicContextStorageDir
|
|
61
|
-
} from "./index-
|
|
61
|
+
} from "./index-4ftb5hcq.js";
|
|
62
62
|
|
|
63
63
|
// src/features/magic-context/compartment-lease.ts
|
|
64
64
|
var COMPARTMENT_LEASE_TTL_MS = 5 * 60 * 1000;
|
|
@@ -1737,6 +1737,11 @@ async function drainAuthority(args) {
|
|
|
1737
1737
|
if (finished.state !== "TS") {
|
|
1738
1738
|
throw new Error("memory authority drain did not reactivate TypeScript ownership");
|
|
1739
1739
|
}
|
|
1740
|
+
if (args.domain === "memories") {
|
|
1741
|
+
withPrivilegedWriter(args.db, () => {
|
|
1742
|
+
args.db.prepare("DELETE FROM mirror_live_memory_rows WHERE module_project = ?").run(args.projectPath);
|
|
1743
|
+
});
|
|
1744
|
+
}
|
|
1740
1745
|
const remaining = await Promise.all(AUTHORITY_DOMAINS.map((domain) => args.module.authorityStatus({
|
|
1741
1746
|
context_store_uuid: contextStoreUuid,
|
|
1742
1747
|
project: args.projectPath,
|
|
@@ -1779,6 +1784,28 @@ function chunkRowsForFrame(rows) {
|
|
|
1779
1784
|
chunks.push(current);
|
|
1780
1785
|
return chunks;
|
|
1781
1786
|
}
|
|
1787
|
+
var MEMORY_MIRROR_STALL_THRESHOLD_MS = 40000;
|
|
1788
|
+
function getMemoryMirrorStatus(db, feedHead, nowMs = Date.now()) {
|
|
1789
|
+
const cursorRow = db.prepare("SELECT cursor, updated_at FROM mirror_cursors WHERE domain = 'memories'").get();
|
|
1790
|
+
const liveRow = db.prepare("SELECT COUNT(*) AS count FROM mirror_live_memory_rows").get();
|
|
1791
|
+
const cursor = typeof cursorRow?.cursor === "number" ? cursorRow.cursor : 0;
|
|
1792
|
+
const cursorUpdatedAt = typeof cursorRow?.updated_at === "number" && cursorRow.updated_at > 0 ? cursorRow.updated_at : null;
|
|
1793
|
+
const cursorAgeMs = cursorUpdatedAt === null ? null : Math.max(0, Math.floor(nowMs - cursorUpdatedAt));
|
|
1794
|
+
const liveRows = typeof liveRow?.count === "number" ? liveRow.count : 0;
|
|
1795
|
+
const resolvedFeedHead = typeof feedHead === "number" && Number.isSafeInteger(feedHead) && feedHead >= 0 ? feedHead : null;
|
|
1796
|
+
const pendingRows = resolvedFeedHead === null ? null : Math.max(0, resolvedFeedHead - cursor);
|
|
1797
|
+
const stalled = liveRows > 0 && pendingRows !== null && pendingRows > 0 && cursorAgeMs !== null && cursorAgeMs >= MEMORY_MIRROR_STALL_THRESHOLD_MS;
|
|
1798
|
+
return {
|
|
1799
|
+
cursor,
|
|
1800
|
+
cursorUpdatedAt,
|
|
1801
|
+
cursorAgeMs,
|
|
1802
|
+
liveRows,
|
|
1803
|
+
feedHead: resolvedFeedHead,
|
|
1804
|
+
pendingRows,
|
|
1805
|
+
stalled,
|
|
1806
|
+
code: stalled ? "MC-M01" : null
|
|
1807
|
+
};
|
|
1808
|
+
}
|
|
1782
1809
|
function getMirrorCursor(db, domain) {
|
|
1783
1810
|
const row = db.prepare("SELECT cursor FROM mirror_cursors WHERE domain = ?").get(domain);
|
|
1784
1811
|
return typeof row?.cursor === "number" ? row.cursor : 0;
|
|
@@ -2587,7 +2614,7 @@ function pullMemoryMirrorOnce(args) {
|
|
|
2587
2614
|
db: args.db,
|
|
2588
2615
|
module: args.module,
|
|
2589
2616
|
domain: "memories",
|
|
2590
|
-
limit: args.limit,
|
|
2617
|
+
limit: args.limit ?? 1000,
|
|
2591
2618
|
pageBudget: args.pageBudget ?? TRANSFORM_MEMORY_MIRROR_PAGE_BUDGET
|
|
2592
2619
|
}).then((result) => ({ ...result, cuePoolVersion: result.cursor })).finally(() => mirrorFlights.delete(args.module));
|
|
2593
2620
|
mirrorFlights.set(args.module, flight);
|
|
@@ -8919,7 +8946,7 @@ function memoizedContent(kind, content) {
|
|
|
8919
8946
|
return cached;
|
|
8920
8947
|
const measured = {
|
|
8921
8948
|
hash: fnv1a32(key),
|
|
8922
|
-
tokens: kind === "excluded" ? 0 :
|
|
8949
|
+
tokens: kind === "excluded" ? 0 : undefined,
|
|
8923
8950
|
keyBytes: key.length * 2 + 32
|
|
8924
8951
|
};
|
|
8925
8952
|
contentMemo.set(key, measured);
|
|
@@ -8935,6 +8962,13 @@ function memoizedContent(kind, content) {
|
|
|
8935
8962
|
}
|
|
8936
8963
|
return measured;
|
|
8937
8964
|
}
|
|
8965
|
+
function memoizedTokens(kind, content) {
|
|
8966
|
+
const measured = memoizedContent(kind, content);
|
|
8967
|
+
if (measured.tokens === undefined) {
|
|
8968
|
+
measured.tokens = estimateTokens(content);
|
|
8969
|
+
}
|
|
8970
|
+
return measured.tokens;
|
|
8971
|
+
}
|
|
8938
8972
|
function safeStableStringify(value) {
|
|
8939
8973
|
if (value === undefined || value === null)
|
|
8940
8974
|
return "";
|
|
@@ -9237,8 +9271,8 @@ function fileContentAndTokens(part) {
|
|
|
9237
9271
|
};
|
|
9238
9272
|
}
|
|
9239
9273
|
const content = firstString(part, ["content", "text", "source", "url"]);
|
|
9240
|
-
const
|
|
9241
|
-
return { content, tokens
|
|
9274
|
+
const tokens = memoizedTokens("file", content);
|
|
9275
|
+
return { content, tokens };
|
|
9242
9276
|
}
|
|
9243
9277
|
function contentSignature(parts) {
|
|
9244
9278
|
return fnv1a32(parts.map((part) => `${part.key}:${part.contentHash}`).join("\x00"));
|
|
@@ -9323,13 +9357,13 @@ function measureTailHygiene(input) {
|
|
|
9323
9357
|
parts.push(excludedSnapshot(`${key}\x00excluded`, part));
|
|
9324
9358
|
continue;
|
|
9325
9359
|
}
|
|
9326
|
-
const
|
|
9360
|
+
const tokens = memoizedTokens("text", content);
|
|
9327
9361
|
const tag = attribution.messageTags.get(`${message.info.id}:p${partIndex}`);
|
|
9328
9362
|
const measured = snapshot({
|
|
9329
9363
|
key: `${key}\x00text`,
|
|
9330
9364
|
kind: "text",
|
|
9331
9365
|
content,
|
|
9332
|
-
tokens
|
|
9366
|
+
tokens,
|
|
9333
9367
|
tag,
|
|
9334
9368
|
protectedNumbers: attribution.protectedNumbers,
|
|
9335
9369
|
pendingDropTagNumbers
|
|
@@ -9370,12 +9404,12 @@ function measureTailHygiene(input) {
|
|
|
9370
9404
|
const tag = attribution.toolTagsByPart.get(part);
|
|
9371
9405
|
const inputText = toolInputText(part);
|
|
9372
9406
|
if (inputText !== null) {
|
|
9373
|
-
const
|
|
9407
|
+
const tokens = memoizedTokens("toolInput", inputText);
|
|
9374
9408
|
const measured = snapshot({
|
|
9375
9409
|
key: `${key}\x00toolInput`,
|
|
9376
9410
|
kind: "toolInput",
|
|
9377
9411
|
content: inputText,
|
|
9378
|
-
tokens
|
|
9412
|
+
tokens,
|
|
9379
9413
|
tag,
|
|
9380
9414
|
protectedNumbers: attribution.protectedNumbers,
|
|
9381
9415
|
pendingDropTagNumbers
|
|
@@ -9390,12 +9424,12 @@ function measureTailHygiene(input) {
|
|
|
9390
9424
|
if (isDropSentinel(output)) {
|
|
9391
9425
|
parts.push(excludedSnapshot(`${key}\x00excludedOutput`, output));
|
|
9392
9426
|
} else {
|
|
9393
|
-
const
|
|
9427
|
+
const tokens = memoizedTokens("toolOutput", output);
|
|
9394
9428
|
const measured = snapshot({
|
|
9395
9429
|
key: `${key}\x00toolOutput`,
|
|
9396
9430
|
kind: "toolOutput",
|
|
9397
9431
|
content: output,
|
|
9398
|
-
tokens
|
|
9432
|
+
tokens,
|
|
9399
9433
|
tag,
|
|
9400
9434
|
protectedNumbers: attribution.protectedNumbers,
|
|
9401
9435
|
pendingDropTagNumbers
|
|
@@ -21652,7 +21686,7 @@ function parseModelSuggestion(error) {
|
|
|
21652
21686
|
suggestion: suggestionMatch[1].trim()
|
|
21653
21687
|
};
|
|
21654
21688
|
}
|
|
21655
|
-
async function promptWithTimeout(client, args, timeoutMs, signal) {
|
|
21689
|
+
async function promptWithTimeout(client, args, timeoutMs, signal, transport) {
|
|
21656
21690
|
if (signal?.aborted) {
|
|
21657
21691
|
throw new Error("prompt aborted by external signal");
|
|
21658
21692
|
}
|
|
@@ -21661,17 +21695,25 @@ async function promptWithTimeout(client, args, timeoutMs, signal) {
|
|
|
21661
21695
|
const onExternalAbort = () => controller.abort();
|
|
21662
21696
|
signal?.addEventListener("abort", onExternalAbort);
|
|
21663
21697
|
try {
|
|
21664
|
-
|
|
21665
|
-
|
|
21666
|
-
|
|
21667
|
-
|
|
21698
|
+
const request = { ...args, signal: controller.signal };
|
|
21699
|
+
if (transport)
|
|
21700
|
+
await transport(request);
|
|
21701
|
+
else {
|
|
21702
|
+
if (!client)
|
|
21703
|
+
throw new Error("Hidden completion transport is unavailable");
|
|
21704
|
+
await client.session.prompt(request);
|
|
21705
|
+
}
|
|
21668
21706
|
} catch (error) {
|
|
21669
21707
|
if (signal?.aborted) {
|
|
21670
|
-
|
|
21708
|
+
if (!transport || transport.childSessionId) {
|
|
21709
|
+
await abortChildRun(client, transport?.childSessionId ?? args.path.id);
|
|
21710
|
+
}
|
|
21671
21711
|
throw new Error("prompt aborted by external signal");
|
|
21672
21712
|
}
|
|
21673
21713
|
if (controller.signal.aborted) {
|
|
21674
|
-
|
|
21714
|
+
if (!transport || transport.childSessionId) {
|
|
21715
|
+
await abortChildRun(client, transport?.childSessionId ?? args.path.id);
|
|
21716
|
+
}
|
|
21675
21717
|
throw new Error(`prompt timed out after ${timeoutMs}ms`);
|
|
21676
21718
|
}
|
|
21677
21719
|
throw error;
|
|
@@ -21681,6 +21723,8 @@ async function promptWithTimeout(client, args, timeoutMs, signal) {
|
|
|
21681
21723
|
}
|
|
21682
21724
|
}
|
|
21683
21725
|
async function abortChildRun(client, sessionId) {
|
|
21726
|
+
if (!client)
|
|
21727
|
+
return;
|
|
21684
21728
|
try {
|
|
21685
21729
|
await Promise.race([
|
|
21686
21730
|
client.session.abort({ path: { id: sessionId } }),
|
|
@@ -21729,7 +21773,7 @@ function classifyPromptFailure(error, phase, externalSignal) {
|
|
|
21729
21773
|
}
|
|
21730
21774
|
return phase === "prompt" || phase === "output" ? "provider_error" : "unknown";
|
|
21731
21775
|
}
|
|
21732
|
-
function throwWithPromptFailure(legacyError, failedAttempts, args, timeoutMs) {
|
|
21776
|
+
function throwWithPromptFailure(legacyError, failedAttempts, args, timeoutMs, transport) {
|
|
21733
21777
|
const error = legacyError instanceof Error ? legacyError : new Error(extractMessage(legacyError));
|
|
21734
21778
|
const last = failedAttempts.at(-1);
|
|
21735
21779
|
const failureClass = last?.failureClass ?? "unknown";
|
|
@@ -21740,15 +21784,15 @@ function throwWithPromptFailure(legacyError, failedAttempts, args, timeoutMs) {
|
|
|
21740
21784
|
modelsTried: failedAttempts.map((failure) => failure.attempt.label),
|
|
21741
21785
|
providerError,
|
|
21742
21786
|
timeoutMs: failureClass === "provider_timeout" ? timeoutMs : null,
|
|
21743
|
-
childSessionId: args.path.id || null
|
|
21787
|
+
childSessionId: transport ? transport.childSessionId ?? null : args.path.id || null
|
|
21744
21788
|
});
|
|
21745
21789
|
throw error;
|
|
21746
21790
|
}
|
|
21747
|
-
async function attemptOnce(client, args, timeoutMs, signal, callContext, label) {
|
|
21791
|
+
async function attemptOnce(client, args, timeoutMs, signal, callContext, label, transport) {
|
|
21748
21792
|
const originalBody = { ...args.body };
|
|
21749
21793
|
const attemptArgs = copyPromptArgs(args, originalBody);
|
|
21750
21794
|
try {
|
|
21751
|
-
await promptWithTimeout(client, attemptArgs, timeoutMs, signal);
|
|
21795
|
+
await promptWithTimeout(client, attemptArgs, timeoutMs, signal, transport);
|
|
21752
21796
|
return;
|
|
21753
21797
|
} catch (error) {
|
|
21754
21798
|
if (isNonRetryable(error, signal))
|
|
@@ -21767,7 +21811,7 @@ async function attemptOnce(client, args, timeoutMs, signal, callContext, label)
|
|
|
21767
21811
|
providerID: suggestion.providerID,
|
|
21768
21812
|
modelID: suggestion.suggestion
|
|
21769
21813
|
}
|
|
21770
|
-
}), timeoutMs, signal);
|
|
21814
|
+
}), timeoutMs, signal, transport);
|
|
21771
21815
|
}
|
|
21772
21816
|
}
|
|
21773
21817
|
async function promptSyncWithModelSuggestionRetry(client, args, options = {}) {
|
|
@@ -21779,7 +21823,7 @@ async function promptSyncWithModelSuggestionRetry(client, args, options = {}) {
|
|
|
21779
21823
|
const explicitPrimaryLabel = baseBody.model?.providerID && baseBody.model.modelID ? `${baseBody.model.providerID}/${baseBody.model.modelID}` : "primary";
|
|
21780
21824
|
let lastError = null;
|
|
21781
21825
|
try {
|
|
21782
|
-
await attemptOnce(client, baseArgs, timeoutMs, options.signal, callContext, explicitPrimaryLabel);
|
|
21826
|
+
await attemptOnce(client, baseArgs, timeoutMs, options.signal, callContext, explicitPrimaryLabel, options.transport);
|
|
21783
21827
|
return;
|
|
21784
21828
|
} catch (error) {
|
|
21785
21829
|
lastError = error;
|
|
@@ -21805,7 +21849,7 @@ async function promptSyncWithModelSuggestionRetry(client, args, options = {}) {
|
|
|
21805
21849
|
...fallback?.qualifier ? { variant: fallback.qualifier } : {}
|
|
21806
21850
|
});
|
|
21807
21851
|
try {
|
|
21808
|
-
await attemptOnce(client, attemptArgs, timeoutMs, options.signal, callContext, label);
|
|
21852
|
+
await attemptOnce(client, attemptArgs, timeoutMs, options.signal, callContext, label, options.transport);
|
|
21809
21853
|
log(`[${callContext}] fallback succeeded with ${label} (attempt ${i + 2}/${fallbacks.length + 1})`);
|
|
21810
21854
|
return;
|
|
21811
21855
|
} catch (error) {
|
|
@@ -21823,7 +21867,7 @@ async function promptSyncWithModelSuggestionRetry(client, args, options = {}) {
|
|
|
21823
21867
|
}
|
|
21824
21868
|
async function attemptAndValidate(client, args, timeoutMs, signal, callContext, attempt, options) {
|
|
21825
21869
|
try {
|
|
21826
|
-
await attemptOnce(client, args, timeoutMs, signal, callContext, attempt.label);
|
|
21870
|
+
await attemptOnce(client, args, timeoutMs, signal, callContext, attempt.label, options.transport);
|
|
21827
21871
|
} catch (error) {
|
|
21828
21872
|
throw {
|
|
21829
21873
|
error,
|
|
@@ -21877,10 +21921,10 @@ async function promptSyncWithValidatedOutputRetry(client, args, options) {
|
|
|
21877
21921
|
firstError = failure.error;
|
|
21878
21922
|
lastError = failure.error;
|
|
21879
21923
|
if (isNonRetryable(failure.error, options.signal)) {
|
|
21880
|
-
throwWithPromptFailure(failure.error, failedAttempts, args, timeoutMs);
|
|
21924
|
+
throwWithPromptFailure(failure.error, failedAttempts, args, timeoutMs, options.transport);
|
|
21881
21925
|
}
|
|
21882
21926
|
if (fallbacks.length === 0) {
|
|
21883
|
-
throwWithPromptFailure(failure.error, failedAttempts, args, timeoutMs);
|
|
21927
|
+
throwWithPromptFailure(failure.error, failedAttempts, args, timeoutMs, options.transport);
|
|
21884
21928
|
}
|
|
21885
21929
|
log(`[${callContext}] primary (${explicitPrimaryLabel}) failed validation/prompt: ${shortErr(failure.error)}; trying ${fallbacks.length} fallback(s)`);
|
|
21886
21930
|
}
|
|
@@ -21914,7 +21958,7 @@ async function promptSyncWithValidatedOutputRetry(client, args, options) {
|
|
|
21914
21958
|
failedAttempts.push(failure);
|
|
21915
21959
|
lastError = failure.error;
|
|
21916
21960
|
if (isNonRetryable(failure.error, options.signal)) {
|
|
21917
|
-
throwWithPromptFailure(failure.error, failedAttempts, args, timeoutMs);
|
|
21961
|
+
throwWithPromptFailure(failure.error, failedAttempts, args, timeoutMs, options.transport);
|
|
21918
21962
|
}
|
|
21919
21963
|
const remaining = fallbacks.length - i - 1;
|
|
21920
21964
|
if (remaining > 0) {
|
|
@@ -21923,7 +21967,7 @@ async function promptSyncWithValidatedOutputRetry(client, args, options) {
|
|
|
21923
21967
|
}
|
|
21924
21968
|
}
|
|
21925
21969
|
log(`[${callContext}] all models exhausted; tried: ${failedAttempts.map((failure) => failure.attempt.label).join(", ")}; original error: ${shortErr(firstError)}; last error: ${shortErr(lastError)}`);
|
|
21926
|
-
throwWithPromptFailure(firstError ?? lastError ?? new Error("All fallback models failed validation"), failedAttempts, args, timeoutMs);
|
|
21970
|
+
throwWithPromptFailure(firstError ?? lastError ?? new Error("All fallback models failed validation"), failedAttempts, args, timeoutMs, options.transport);
|
|
21927
21971
|
}
|
|
21928
21972
|
// src/shared/normalize-sdk-response.ts
|
|
21929
21973
|
function normalizeSDKResponse(response, fallback, options) {
|
|
@@ -22449,7 +22493,7 @@ function resolveUserConfigDirectory(options) {
|
|
|
22449
22493
|
if (shared.format !== "none")
|
|
22450
22494
|
return dirname4(shared.path);
|
|
22451
22495
|
if (options.harness) {
|
|
22452
|
-
const legacy = resolveLegacyConfigSourcesForHarness(options.directory ?? process.cwd(), options.harness === "omp" ? "pi" : options.harness).user.find((source) => existsSync6(source.path));
|
|
22496
|
+
const legacy = resolveLegacyConfigSourcesForHarness(options.directory ?? process.cwd(), options.harness === "omp" ? "pi" : options.harness === "opencode2" ? "opencode" : options.harness).user.find((source) => existsSync6(source.path));
|
|
22453
22497
|
if (legacy)
|
|
22454
22498
|
return dirname4(legacy.path);
|
|
22455
22499
|
}
|
|
@@ -24127,6 +24171,16 @@ var USER_FACING_FAILURES = {
|
|
|
24127
24171
|
code: "MC-C10",
|
|
24128
24172
|
sentence: "Magic Context is temporarily unavailable.",
|
|
24129
24173
|
action: "Retry in a moment."
|
|
24174
|
+
},
|
|
24175
|
+
memory_mirror_stalled: {
|
|
24176
|
+
code: "MC-M01",
|
|
24177
|
+
sentence: "Memory synchronization stopped before the host mirror caught up.",
|
|
24178
|
+
action: "Send another message to resume it, or run `ck doctor drain-authority`."
|
|
24179
|
+
},
|
|
24180
|
+
memory_authority_mismatch: {
|
|
24181
|
+
code: "MC-M02",
|
|
24182
|
+
sentence: "Memory authority is inconsistent between the host and module.",
|
|
24183
|
+
action: "Run `ck doctor drain-authority` before changing Rust mode."
|
|
24130
24184
|
}
|
|
24131
24185
|
};
|
|
24132
24186
|
function renderUserFacingFailure(key, style = "markdown") {
|
|
@@ -27855,16 +27909,27 @@ function startLockHeartbeat(lockPath) {
|
|
|
27855
27909
|
timer.unref?.();
|
|
27856
27910
|
return () => clearInterval(timer);
|
|
27857
27911
|
}
|
|
27912
|
+
var ONNX_RUNTIME_WEB_SPECIFIER = "onnxruntime-web";
|
|
27858
27913
|
var localEmbeddingRuntimeMode = "native";
|
|
27859
27914
|
var localEmbeddingProcessFailure = null;
|
|
27860
27915
|
var wasmRuntimeInjected = false;
|
|
27861
27916
|
var localEmbeddingHostForRuntime = currentLocalEmbeddingHost;
|
|
27917
|
+
var resolveWasmOrtForRuntime = () => {
|
|
27918
|
+
try {
|
|
27919
|
+
return typeof import.meta.resolve === "function" ? import.meta.resolve(ONNX_RUNTIME_WEB_SPECIFIER) : undefined;
|
|
27920
|
+
} catch {
|
|
27921
|
+
return;
|
|
27922
|
+
}
|
|
27923
|
+
};
|
|
27924
|
+
var importWasmOrtModule = async (specifier) => await import(specifier);
|
|
27925
|
+
var importWasmOrtModuleForRuntime = importWasmOrtModule;
|
|
27862
27926
|
var importWasmOrtForRuntime = async () => {
|
|
27863
27927
|
const { createRequire: createRequireFn } = await import("node:module");
|
|
27864
27928
|
const requireFn = createRequireFn(import.meta.url);
|
|
27865
|
-
const ortEntry = requireFn.resolve(
|
|
27929
|
+
const ortEntry = requireFn.resolve(ONNX_RUNTIME_WEB_SPECIFIER);
|
|
27930
|
+
const ortSpecifier = resolveWasmOrtForRuntime() ?? ONNX_RUNTIME_WEB_SPECIFIER;
|
|
27866
27931
|
return {
|
|
27867
|
-
module: await
|
|
27932
|
+
module: await importWasmOrtModuleForRuntime(ortSpecifier),
|
|
27868
27933
|
entryPath: ortEntry
|
|
27869
27934
|
};
|
|
27870
27935
|
};
|
|
@@ -33024,6 +33089,18 @@ function recordChildInvocation(input) {
|
|
|
33024
33089
|
}
|
|
33025
33090
|
}
|
|
33026
33091
|
|
|
33092
|
+
// src/hooks/magic-context/compartment-runner-types.ts
|
|
33093
|
+
class HiddenCompletionRefusal extends Error {
|
|
33094
|
+
code;
|
|
33095
|
+
terminal;
|
|
33096
|
+
constructor(code, message, terminal = false) {
|
|
33097
|
+
super(`${code}: ${message}`);
|
|
33098
|
+
this.code = code;
|
|
33099
|
+
this.terminal = terminal;
|
|
33100
|
+
this.name = "HiddenCompletionRefusal";
|
|
33101
|
+
}
|
|
33102
|
+
}
|
|
33103
|
+
|
|
33027
33104
|
// src/hooks/magic-context/compartment-runner-mapping.ts
|
|
33028
33105
|
function tierFieldsOf(c) {
|
|
33029
33106
|
return {
|
|
@@ -33270,6 +33347,61 @@ function historianMessageCreatedAt(message) {
|
|
|
33270
33347
|
return 0;
|
|
33271
33348
|
return typeof message.info.time.created === "number" ? message.info.time.created : 0;
|
|
33272
33349
|
}
|
|
33350
|
+
function createV1HiddenCompletionExecutor(client, db, directory) {
|
|
33351
|
+
return {
|
|
33352
|
+
capabilities: { tools: true, harness: "opencode" },
|
|
33353
|
+
async open(run) {
|
|
33354
|
+
if (!client)
|
|
33355
|
+
throw new Error("Hidden completion client is unavailable");
|
|
33356
|
+
const response = await createChildSessionWithFence({
|
|
33357
|
+
client,
|
|
33358
|
+
db,
|
|
33359
|
+
parentSessionId: run.parentSessionId,
|
|
33360
|
+
title: run.title,
|
|
33361
|
+
directory: run.directory
|
|
33362
|
+
});
|
|
33363
|
+
const created = normalizeSDKResponse(response, null, {
|
|
33364
|
+
preferResponseOnMissingData: true
|
|
33365
|
+
});
|
|
33366
|
+
const id = typeof created?.id === "string" ? created.id : "";
|
|
33367
|
+
return { id, childSessionId: id || undefined };
|
|
33368
|
+
},
|
|
33369
|
+
async attempt(_handle, request) {
|
|
33370
|
+
if (!client)
|
|
33371
|
+
throw new Error("Hidden completion client is unavailable");
|
|
33372
|
+
await client.session.prompt(request);
|
|
33373
|
+
},
|
|
33374
|
+
async collect(handle, limit) {
|
|
33375
|
+
if (!client)
|
|
33376
|
+
throw new Error("Hidden completion client is unavailable");
|
|
33377
|
+
const response = await client.session.messages({
|
|
33378
|
+
path: { id: handle.id },
|
|
33379
|
+
query: { directory, limit }
|
|
33380
|
+
});
|
|
33381
|
+
const messages = normalizeSDKResponse(response, [], {
|
|
33382
|
+
preferResponseOnMissingData: true
|
|
33383
|
+
});
|
|
33384
|
+
const text = extractLatestAssistantText(messages);
|
|
33385
|
+
return {
|
|
33386
|
+
messages,
|
|
33387
|
+
text,
|
|
33388
|
+
reasoning: text ? null : extractLatestHistorianReasoning(messages),
|
|
33389
|
+
lengthCapped: hasLengthCappedOutput(messages),
|
|
33390
|
+
usage: sumTokensFromChildMessages(messages)
|
|
33391
|
+
};
|
|
33392
|
+
},
|
|
33393
|
+
async close(handle, settlement) {
|
|
33394
|
+
if (!client)
|
|
33395
|
+
return;
|
|
33396
|
+
await teardownChildSession({
|
|
33397
|
+
client,
|
|
33398
|
+
sessionId: handle?.id || null,
|
|
33399
|
+
sessionDirectory: directory,
|
|
33400
|
+
...settlement
|
|
33401
|
+
});
|
|
33402
|
+
}
|
|
33403
|
+
};
|
|
33404
|
+
}
|
|
33273
33405
|
async function runValidatedHistorianPass(args) {
|
|
33274
33406
|
const firstRun = await runHistorianPrompt({
|
|
33275
33407
|
...args,
|
|
@@ -33278,6 +33410,8 @@ async function runValidatedHistorianPass(args) {
|
|
|
33278
33410
|
agentId: args.agentId
|
|
33279
33411
|
});
|
|
33280
33412
|
if (!firstRun.ok || !firstRun.result) {
|
|
33413
|
+
if (firstRun.refusal?.terminal)
|
|
33414
|
+
return { ok: false, error: firstRun.error ?? firstRun.refusal.message };
|
|
33281
33415
|
return runFallbackHistorianPass({
|
|
33282
33416
|
...args,
|
|
33283
33417
|
prompt: args.prompt,
|
|
@@ -33307,6 +33441,8 @@ async function runValidatedHistorianPass(args) {
|
|
|
33307
33441
|
agentId: args.agentId
|
|
33308
33442
|
});
|
|
33309
33443
|
if (!repairRun.ok || !repairRun.result) {
|
|
33444
|
+
if (repairRun.refusal?.terminal)
|
|
33445
|
+
return { ok: false, error: repairRun.error ?? repairRun.refusal.message };
|
|
33310
33446
|
return runFallbackHistorianPass({
|
|
33311
33447
|
...args,
|
|
33312
33448
|
prompt: repairPrompt,
|
|
@@ -33337,11 +33473,14 @@ async function runEditorPassOrFallback(args) {
|
|
|
33337
33473
|
sessionLog(args.parentSessionId, "historian two-pass: running editor on draft");
|
|
33338
33474
|
const editorRun = await runHistorianPrompt({
|
|
33339
33475
|
client: args.client,
|
|
33476
|
+
hiddenCompletionExecutor: args.hiddenCompletionExecutor,
|
|
33340
33477
|
db: args.db,
|
|
33341
33478
|
parentSessionId: args.parentSessionId,
|
|
33342
33479
|
sessionDirectory: args.sessionDirectory,
|
|
33343
33480
|
prompt: buildHistorianEditorPrompt(args.draftXml),
|
|
33344
33481
|
timeoutMs: args.timeoutMs,
|
|
33482
|
+
maxOutputTokens: args.maxOutputTokens,
|
|
33483
|
+
language: args.language,
|
|
33345
33484
|
dumpLabel: `${args.dumpLabelBase}-editor`,
|
|
33346
33485
|
agentId: HISTORIAN_EDITOR_AGENT,
|
|
33347
33486
|
parentInvocationId: args.draftInvocationId ?? null,
|
|
@@ -33378,6 +33517,9 @@ async function runHistorianPrompt(args) {
|
|
|
33378
33517
|
parentInvocationId
|
|
33379
33518
|
} = args;
|
|
33380
33519
|
let agentSessionId = null;
|
|
33520
|
+
let handle = null;
|
|
33521
|
+
let completion;
|
|
33522
|
+
const executor = args.hiddenCompletionExecutor ?? createV1HiddenCompletionExecutor(client, db, sessionDirectory);
|
|
33381
33523
|
let promptSettled = false;
|
|
33382
33524
|
let hadUnsettledPrompt = false;
|
|
33383
33525
|
const startedAt = Date.now();
|
|
@@ -33389,26 +33531,41 @@ async function runHistorianPrompt(args) {
|
|
|
33389
33531
|
return recordChildInvocation({
|
|
33390
33532
|
db: openDatabase(),
|
|
33391
33533
|
parentSessionId,
|
|
33392
|
-
harness:
|
|
33534
|
+
harness: executor.capabilities.harness,
|
|
33393
33535
|
subagent: agentId === HISTORIAN_EDITOR_AGENT ? "historian_editor" : subagentKind ?? "historian",
|
|
33394
33536
|
startedAt,
|
|
33395
33537
|
status: params.status,
|
|
33396
33538
|
messages: params.messages,
|
|
33539
|
+
...completion && !completion.messages ? {
|
|
33540
|
+
tokens: completion.usage,
|
|
33541
|
+
providerId: completion.providerId,
|
|
33542
|
+
modelId: completion.modelId
|
|
33543
|
+
} : {},
|
|
33397
33544
|
error: params.error,
|
|
33398
33545
|
parentInvocationId: agentId === HISTORIAN_EDITOR_AGENT ? parentInvocationId ?? null : null
|
|
33399
33546
|
});
|
|
33400
33547
|
};
|
|
33401
33548
|
try {
|
|
33402
33549
|
sessionLog(parentSessionId, `historian: creating child session (agent=${toModelEntry(modelOverride)?.model ?? `agent:${agentId}`})`);
|
|
33403
|
-
|
|
33404
|
-
client,
|
|
33405
|
-
db,
|
|
33550
|
+
handle = await executor.open({
|
|
33406
33551
|
parentSessionId,
|
|
33552
|
+
parentInvocationId,
|
|
33553
|
+
agent: agentId,
|
|
33554
|
+
kind: agentId === HISTORIAN_EDITOR_AGENT ? "historian-editor" : "historian",
|
|
33555
|
+
system: withContentLanguageDirective(agentId === HISTORIAN_EDITOR_AGENT ? HISTORIAN_EDITOR_SYSTEM_PROMPT : COMPARTMENT_AGENT_SYSTEM_PROMPT, args.language),
|
|
33556
|
+
maxOutputTokens: args.maxOutputTokens,
|
|
33557
|
+
model: modelOverride,
|
|
33558
|
+
configuredModels: [
|
|
33559
|
+
...modelOverride ? [modelOverride] : [],
|
|
33560
|
+
...fallbackModels ?? []
|
|
33561
|
+
],
|
|
33562
|
+
timeoutMs: timeoutMs ?? DEFAULT_HISTORIAN_TIMEOUT_MS,
|
|
33407
33563
|
title: "magic-context-compartment",
|
|
33408
|
-
directory: sessionDirectory
|
|
33564
|
+
directory: sessionDirectory,
|
|
33565
|
+
metadata: { dumpLabel, subagentKind }
|
|
33409
33566
|
});
|
|
33410
|
-
|
|
33411
|
-
|
|
33567
|
+
agentSessionId = handle.id || null;
|
|
33568
|
+
const opened = handle;
|
|
33412
33569
|
if (!agentSessionId) {
|
|
33413
33570
|
recordInvocation({
|
|
33414
33571
|
status: "failed",
|
|
@@ -33427,6 +33584,7 @@ async function runHistorianPrompt(args) {
|
|
|
33427
33584
|
parts: [{ type: "text", text: prompt, synthetic: true }]
|
|
33428
33585
|
}
|
|
33429
33586
|
}, {
|
|
33587
|
+
transport: Object.assign((request) => executor.attempt(opened, request), { childSessionId: opened.childSessionId }),
|
|
33430
33588
|
timeoutMs: timeoutMs ?? DEFAULT_HISTORIAN_TIMEOUT_MS,
|
|
33431
33589
|
fallbackModels: modelOverride ? undefined : fallbackModels,
|
|
33432
33590
|
callContext: agentId === HISTORIAN_EDITOR_AGENT ? "historian:editor" : "historian"
|
|
@@ -33448,19 +33606,16 @@ async function runHistorianPrompt(args) {
|
|
|
33448
33606
|
await sleep(backoffMs);
|
|
33449
33607
|
}
|
|
33450
33608
|
}
|
|
33451
|
-
|
|
33452
|
-
|
|
33453
|
-
|
|
33454
|
-
|
|
33455
|
-
const messages = normalizeSDKResponse(messagesResponse, [], {
|
|
33456
|
-
preferResponseOnMissingData: true
|
|
33609
|
+
completion = await executor.collect(handle, 50);
|
|
33610
|
+
const invocationId = recordInvocation({
|
|
33611
|
+
status: "completed",
|
|
33612
|
+
messages: completion.messages
|
|
33457
33613
|
});
|
|
33458
|
-
const
|
|
33459
|
-
const
|
|
33460
|
-
const
|
|
33461
|
-
const reasoningResult = textResult ? null : extractLatestHistorianReasoning(messages);
|
|
33614
|
+
const lengthCapped = completion.lengthCapped;
|
|
33615
|
+
const textResult = completion.text;
|
|
33616
|
+
const reasoningResult = textResult ? null : completion.reasoning;
|
|
33462
33617
|
if (!textResult && reasoningResult && lengthCapped) {
|
|
33463
|
-
const outputTokens =
|
|
33618
|
+
const outputTokens = completion.usage.output;
|
|
33464
33619
|
return {
|
|
33465
33620
|
ok: false,
|
|
33466
33621
|
error: `historian output length-capped at ${outputTokens} tokens (all reasoning, no text) — set historian.maxTokens or route historian.model to a low-reasoning lane/variant`,
|
|
@@ -33483,13 +33638,11 @@ async function runHistorianPrompt(args) {
|
|
|
33483
33638
|
recordInvocation({ status: "failed", error: modelError });
|
|
33484
33639
|
return {
|
|
33485
33640
|
ok: false,
|
|
33486
|
-
error: `Historian failed while processing this session: ${desc.brief}
|
|
33641
|
+
error: `Historian failed while processing this session: ${desc.brief}`,
|
|
33642
|
+
...modelError instanceof HiddenCompletionRefusal ? { refusal: modelError } : {}
|
|
33487
33643
|
};
|
|
33488
33644
|
} finally {
|
|
33489
|
-
await
|
|
33490
|
-
client,
|
|
33491
|
-
sessionId: agentSessionId,
|
|
33492
|
-
sessionDirectory,
|
|
33645
|
+
await executor.close(handle, {
|
|
33493
33646
|
promptSettled,
|
|
33494
33647
|
privacySensitive: false,
|
|
33495
33648
|
context: "historian",
|
|
@@ -33531,11 +33684,14 @@ async function runFallbackHistorianPass(args) {
|
|
|
33531
33684
|
args.callbacks?.onModelFallback?.(modelId, i + 1, chain.length);
|
|
33532
33685
|
const fallbackRun = await runHistorianPrompt({
|
|
33533
33686
|
client: args.client,
|
|
33687
|
+
hiddenCompletionExecutor: args.hiddenCompletionExecutor,
|
|
33534
33688
|
db: args.db,
|
|
33535
33689
|
parentSessionId: args.parentSessionId,
|
|
33536
33690
|
sessionDirectory: args.sessionDirectory,
|
|
33537
33691
|
prompt: args.prompt,
|
|
33538
33692
|
timeoutMs: args.timeoutMs,
|
|
33693
|
+
maxOutputTokens: args.maxOutputTokens,
|
|
33694
|
+
language: args.language,
|
|
33539
33695
|
dumpLabel: `${args.dumpLabelBase}-fallback-${i + 1}`,
|
|
33540
33696
|
modelOverride,
|
|
33541
33697
|
agentId: args.agentId
|
|
@@ -39362,7 +39518,7 @@ async function runCompartmentAgent(deps) {
|
|
|
39362
39518
|
const invocationId = latest != null && (invocationBaseline == null || latest > invocationBaseline) ? latest : null;
|
|
39363
39519
|
recordHistorianRun(db, {
|
|
39364
39520
|
sessionId,
|
|
39365
|
-
harness: "opencode",
|
|
39521
|
+
harness: deps.hiddenCompletionExecutor?.capabilities.harness ?? "opencode",
|
|
39366
39522
|
subagentInvocationId: invocationId,
|
|
39367
39523
|
runKind: telemetry.runKind ?? "incremental",
|
|
39368
39524
|
status: telemetry.status ?? "failed",
|
|
@@ -39586,7 +39742,7 @@ async function runCompartmentAgent(deps) {
|
|
|
39586
39742
|
${chunkText}`,
|
|
39587
39743
|
memoryEnabled: deps.memoryEnabled !== false
|
|
39588
39744
|
});
|
|
39589
|
-
const parentSessionResponse = await client
|
|
39745
|
+
const parentSessionResponse = await client?.session.get({ path: { id: sessionId } }).catch(() => null);
|
|
39590
39746
|
const parentSession = normalizeSDKResponse(parentSessionResponse, null, { preferResponseOnMissingData: true });
|
|
39591
39747
|
const sessionDirectory = parentSession?.directory ?? directory;
|
|
39592
39748
|
const maxExistingSequence = priorCompartments.reduce((max, c) => c.sequence > max ? c.sequence : max, -1);
|
|
@@ -39594,6 +39750,7 @@ ${chunkText}`,
|
|
|
39594
39750
|
retainDrainReservationForRetryThrottle = true;
|
|
39595
39751
|
const validatedPass = await runValidatedHistorianPass({
|
|
39596
39752
|
client,
|
|
39753
|
+
hiddenCompletionExecutor: deps.hiddenCompletionExecutor,
|
|
39597
39754
|
db,
|
|
39598
39755
|
parentSessionId: sessionId,
|
|
39599
39756
|
sessionDirectory,
|
|
@@ -39603,6 +39760,7 @@ ${chunkText}`,
|
|
|
39603
39760
|
sequenceOffset,
|
|
39604
39761
|
dumpLabelBase: `incremental-${sessionId}-${chunk.startIndex}-${chunk.endIndex}`,
|
|
39605
39762
|
timeoutMs: historianTimeoutMs,
|
|
39763
|
+
maxOutputTokens: deps.historianMaxOutputTokens,
|
|
39606
39764
|
model: deps.model,
|
|
39607
39765
|
fallbackModelId: deps.fallbackModelId,
|
|
39608
39766
|
fallbackModels: deps.fallbackModels,
|
|
@@ -39716,7 +39874,7 @@ ${chunkText}`,
|
|
|
39716
39874
|
clearEmergencyRecovery(db, sessionId);
|
|
39717
39875
|
drainReservation = null;
|
|
39718
39876
|
if (deferMarkerApplication && lastNewEndMessageId) {
|
|
39719
|
-
setPendingCompactionMarkerState(db, sessionId, {
|
|
39877
|
+
(deps.compactionMarkerStrategy?.setPending ?? setPendingCompactionMarkerState)(db, sessionId, {
|
|
39720
39878
|
ordinal: lastCompartmentEnd,
|
|
39721
39879
|
endMessageId: lastNewEndMessageId,
|
|
39722
39880
|
publishedAt: Date.now()
|
|
@@ -39739,7 +39897,7 @@ ${chunkText}`,
|
|
|
39739
39897
|
if (deferMarkerApplication) {
|
|
39740
39898
|
deps.onDeferredMarkerPending?.(sessionId);
|
|
39741
39899
|
} else {
|
|
39742
|
-
updateCompactionMarkerAfterPublication(db, sessionId, lastCompartmentEnd, sessionDirectory);
|
|
39900
|
+
(deps.compactionMarkerStrategy?.publish ?? updateCompactionMarkerAfterPublication)(db, sessionId, lastCompartmentEnd, sessionDirectory);
|
|
39743
39901
|
}
|
|
39744
39902
|
updateSessionMeta2(db, sessionId, { compartmentInProgress: false });
|
|
39745
39903
|
completedSuccessfully = true;
|
|
@@ -39818,7 +39976,7 @@ ${chunkText}`,
|
|
|
39818
39976
|
const stored = insertPrimerCandidates(db, [
|
|
39819
39977
|
{
|
|
39820
39978
|
projectPath: promotionProjectIdentity,
|
|
39821
|
-
harness: "opencode",
|
|
39979
|
+
harness: deps.hiddenCompletionExecutor?.capabilities.harness ?? "opencode",
|
|
39822
39980
|
sessionId,
|
|
39823
39981
|
question: candidate.question,
|
|
39824
39982
|
sourceCompartmentStart: startC?.startMessage,
|
|
@@ -41375,4 +41533,4 @@ async function runUpgradeMemoryMigration(ctx, sessionId, migrationDirectory) {
|
|
|
41375
41533
|
}
|
|
41376
41534
|
}
|
|
41377
41535
|
|
|
41378
|
-
export { withContentLanguageDirective, buildPrimaryLanguageDirective, setJsoncValue, removeJsoncValue, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, resolveLegacyConfigSources, resolveLegacyConfigSourcesForHarness, migrateMagicContextConfigLocations, string, unknown, array, object, union, tuple, record, parseCron, nextOccurrence, nextDueAtMs, promptSurfaceConfigIdentity, resolveModelConfigValue, resolvePromptSurface, resolveModelConfigOrDefault, DEFAULT_EXECUTE_THRESHOLD_PERCENTAGE, DEFAULT_HISTORIAN_TIMEOUT_MS, DEFAULT_LOCAL_EMBEDDING_MODEL, PER_HARNESS_MIGRATION_INVENTORY, PER_HARNESS_MODEL_KEYS, ConfigProfilesSchema, MagicContextConfigSchema, isFailClosedBlockingError, shouldBypassFailClosedBlock, resolveAgentNameFromMessages, createFailClosedController, recordHookInitFailure, clearHookInitFailure, getLastHookInitFailure, ProjectIdentityError, resolveProjectIdentityStrict, takeDubiousOwnershipProjectIdentityWarning, resolveProjectIdentity, directoryHasGitMetadata, resolveProjectIdentityForSession, normalizeStoredProjectPath, storedPathBelongsToIdentity, isLinkedGitWorktree, recordSessionProjectIdentity, beginBootQuietPeriod, bootQuietRemainingMs, scheduleAfterBootQuiet, rpcPortDir, rpcPortFilePath, isPidAlive, parseRpcPortFile, observeAuthorityRouting, registerModuleNoteEvaluationBridge, getModuleNoteEvaluationBridge, getContextStoreUuid, ensureContextStoreUuid, getAuthorityManagedMarker, reconcileAuthorityProject, checksumAuthoritySeedRows, prepareAuthority, drainAuthority, applyMirroredNoteCompileFields, drainMirrorPages, pullMemoryMirrorOnce, V2_MEMORY_CATEGORIES, CATEGORY_PRIORITY, resolveWorkspaceShareCategories, resolveWorkspaceIdentitySet, expandWorkspaceIdentitySetWithAliases, resolveStoredPathWorkspaceIdentity, storedPathBelongsToWorkspace, sourceNameForMemory, computeWorkspaceEpochFingerprint, textMentionsRecentCommit, hasMeaningfulUserText, extractTexts, extractToolCallSummaries, getTokenizerNativeMemoryStats, preloadTokenizer, estimateTokens, normalizeText, getCurrentToolSetHash, recordToolDefinition, getMeasuredToolDefinitionTokens, getSchemaFenceRejection, getMigrationOnOpenRefusal, LATEST_SUPPORTED_VERSION, getDatabasePath, getPersistedSchemaVersion, setSqlitePragmaConfig, runSqliteOptimize, openDatabase, openDatabaseAsync, isDatabasePersisted, getDatabasePersistenceError, COMPARTMENT_AGENT_SYSTEM_PROMPT, HISTORIAN_EDITOR_SYSTEM_PROMPT, COMPARTMENT_STRUCTURAL_SYSTEM_PROMPT, Priority, AdmissionClass, SocketClosedError, SocketTimeoutError, StaleRouteHandleError, SubcClient, isConsumerReconnectTransient, connectionFileExists, isRecord, CTX_REDUCE_KEEP, newestCtxReduceTagNumbers, stripWellFormedLeadingTagPrefix, stripPersistedAssistantText, byteSize, stripTagPrefix, prependTag, isThinkingPart, estimateImageTokensFromDataUrl, normalizeTodoStateJson, buildSyntheticTodoPart, computeSyntheticCallId, isSyntheticTodoPart, countRealUserMessages, tailHygieneStructuralSignature, sameTailHygieneStructuralSignature, refreshTailHygieneBaseline, effectiveTailHygiene, assertTailHygieneContentUnchanged, CHANNEL1_SENTINEL, CHANNEL1_FLOOR_TOKENS, toolOutputTokens, decideChannel1, evaluateChannel2, formatChannel1Evaluation, formatChannel2Evaluation, reclaimableToolOutputCount, buildChannel2Reminder, buildChannel1Reminder, estimateEmergencyDropReclaimTokens, planEmergencyDrop, getRecentTagOwnerMessageIds, AGE_RECLAIM_MIN_TOKENS, getOldestActiveUnprotectedToolTags, getActiveToolTagsForAgeReclaim, getTriggerTagTokenUpperBound, getActiveTagTokenTotalsByMessage, tagTokenCountIsNull, backfillTagTokenCounts, insertTag, updateTagStatus, markWhitespaceAssistantTagInert, getInertWhitespaceAssistantTags, updateTagDropMode, updateCavemanDepth, updateTagMessageId, markTagsCompactedByMessageIds, deleteTagsByMessageId, getMaxTagNumberBySession, getTagNumberByMessageId, getAssignableTagNumberByMessageId, deriveTagLoadFloor, getTagsBySession, getActiveTagsBySession, getTailHygieneTags, getDroppedTagsBySession, getTagsByNumbers, getDroppedTagsByNumbers, getMaxDroppedTagNumber, getTagById, getToolTagNumberByOwner, getNullOwnerToolTag, adoptNullOwnerToolTag, getCandidateToolOwners, pickNearestPriorOwner, isRawCompactionSummaryInfo, extractInMemoryMessageViews, buildInMemoryTailRawMessages, estimateTrueRawMessageTokens, invalidateTrueRawTokenCache, isTextPart, isToolPartWithOutput, isFilePart, buildFileSourceContent, createDroppedInputToolExecuteBeforeHook, isEditTool, partHasCompletedResult, extractToolCallObservation, ToolMutationBatch, createToolDropTarget, setRawMessageProvider, cleanUserText, withRawSessionMessageCache, readRawSessionMessages, primeTailRawMessageCache, primeInMemoryTailRawMessageCache, readRawSessionMessageOrdinalPage, getRawSessionStoredMessageCount, readRawSessionMessagePartsById, readRawSessionMessageOrdinalById, readRawSessionMessageById, readSessionChunk, readRawSessionSeedTail, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLeaseBestEffort, HAS_COMPARTMENT_CONTENT_SQL, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, clearRecompStaging, getMessageIndexSourceIdentity, isMessageIndexSourceCurrent, getLastIndexedOrdinal, getIndexedMessageCorpusSize, getMessageIndexReconciliationStartOrdinal, isMessageIndexReconciledThrough, deleteIndexedMessage, clearIndexedMessages, indexSingleMessage, indexMessagesAfterOrdinal, sweepOrphanedOpenCodeMessageIndexes, recordEmbeddingMeasurement, getMaxM0MutationId, queueMemoryMutation, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationIdForProjects, MAX_EXECUTE_THRESHOLD, escalationBands, MERGED_REASONING_PARTS_PREFIX, readFrozenMergedReasoningParts, getProtectionWindowForSession, isEmergencyRecoveryArmed, isProviderOverflowReconfirmed, isProviderOverflowFailClosedProven, getEmergencyRecoveryArmedAt, loadPersistedUsage, loadProtectedTailMeta, resetProtectedTailNoEligibleHead, getWrapupInProgressState, acquireWrapupInProgress, updateWrapupInProgress, releaseWrapupInProgress, resolveCompactionModeRecord, getCompactionModeRecord, setCompactionModeRecord, getPersistedReasoningWatermark, setPersistedReasoningWatermark, clearPersistedReasoningWatermark, getEmergencyInputSample, setEmergencyDropSample, clearEmergencyDropSample, getLastNudgeUndropped, setLastNudgeUndropped, getChannel1NudgeState, setChannel1NudgeState, markChannel1PostReduceGracePending, captureChannel1PostReduceGraceBaseline, getChannel2NudgeState, getChannel2NudgeClaim, setChannel2NudgeState, casChannel2NudgeState, claimChannel2NudgeState, casChannel2NudgeClaim, getPersistedNoteNudge, getNoteNudgeAnchors, getAutoSearchHintDecisions, appendAutoSearchHintDecision, pruneNoteNudgeAnchors, pruneAutoSearchHintDecisions, removeNoteNudgeAnchorByMessageId, removeAutoSearchHintDecisionByMessageId, getPersistedTodoPermissionDenied, setPersistedTodoPermissionDenied, getPersistedTodoSyntheticAnchor, setPersistedTodoSyntheticAnchor, clearPersistedTodoSyntheticAnchor, setNoteLastReadAt, getHistorianFailureState, clearHistorianFailureState, getOverflowState, loadTransformPassStateSnapshot, recordOverflowDetected, recordDetectedContextLimit, clearEmergencyRecovery, clearDetectedContextLimit, getPersistedCompactionMarkerState, setPersistedCompactionMarkerState, getDeferredClearedCompactionMarkerState, retireDeferredClearedCompactionMarkerState, getStrippedPlaceholderIds, applyStrippedPlaceholderDelta, removeStrippedPlaceholderId, NEWEST_REASONING_BEARING_ASSISTANT, THINKING_BINDING_RECOVERY_FROZEN_PREFIX, thinkingBindingRecoveryFrozenId, getThinkingBindingRecoveryTarget, armThinkingBindingRecovery, clearThinkingBindingRecoveryIf, getMergedReasoningStrippedIds, addMergedReasoningStrippedIds, getTrailingBlankDecisions, addTrailingBlankDecisions, demoteTrailingBlankKeepDecisions, getStaleReduceStrippedIds, addStaleReduceStrippedIds, getProcessedImageStrippedIds, addProcessedImageStrippedIds, getPendingCompactionMarkerState, loadPostprocessReplaySnapshot, setPendingCompactionMarkerState, clearPendingCompactionMarkerStateIf, getSessionsWithPendingMarker, setSessionWorkMetrics, getObservedEpochFloor, resolveEpochFloorForPass, getNotes, addNote, getSessionNotes, getPendingSmartNotes, getReadySmartNotes, updateNote, dismissNotes, dismissNote, markNoteReady, markNoteChecked, queuePendingOp, getPendingOps, getPendingOpsCount, clearPendingOps, removePendingOp, PRIMER_CANDIDATE_TTL_MS, PRIMER_CANDIDATE_MAX_AGE_MS, primerOccurrenceKey, primerOccurrenceUtcDay, updatePrimerCandidateEmbedding, getPrimerCandidatesByIds, getPrimerCandidatesForPromotion, countPrimerCandidatesForProject, getActivePrimers, createPrimer, updatePrimerSupport, updatePrimerAnswer, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectMemoryEpoch, bumpProjectUserProfileVersion, saveSourceContent, replaceSourceContent, getSourceContents, createChildSessionWithFence, detectThinkingBindingMismatch, isFable51ThinkingBindingModel, detectOverflow, modelBodyField, toModelEntry, getPromptFailureDetail, promptSyncWithValidatedOutputRetry, normalizeSDKResponse, promptSurfaceHashMaterial, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, extractLatestAssistantText, hasLengthCappedOutput, setKeepSubagents, teardownChildSession, renderUserFacingFailure, userFacingFailureCode, renderCapabilityRefusal, capabilityRefusalCode, renderDreamFailure, dreamFailureCode, renderEmbeddingFailure, getCompartmentEvents, SYNAPSE_DEFAULT_MODEL, toSynapseLaneDescriptor, formatSynapseLaneDescriptor, SynapseEmbeddingProvider, loadCompartmentChunkEmbeddingsForSearch, cosineSimilarity, computeNormalizedHash, getLocalEmbeddingNativeMemoryStats, saveCommitEmbedding, loadProjectCommitEmbeddings, loadUnembeddedCommits, countEmbeddedCommits, upsertCommits, getLatestIndexedCommitTimeMs, enforceProjectCap, GIT_SWEEP_LEASE_RENEWAL_MS, acquireGitSweepLease, renewGitSweepLease, markGitSweepSuccessAndRelease, parkGitSweepNonIndexable, releaseGitSweepLease, saveEmbeddingIfHashMatches, getProjectEmbeddings, peekProjectEmbeddings, invalidateProject, invalidateMemory, describeShadowBackfillWriteRefusal, markProjectLoadUntrusted, contentSha256, sweepStaleEmbeddingIdentitiesForProject, registerProjectEmbedding, registerProjectShadowEmbedding, getShadowEmbeddingMeasurementCohort, getPrimaryEmbeddingMeasurementCohort, embedShadowTextForProject, enqueueShadowEmbeddingItems, registerProjectInObservationMode, getProjectEmbeddingSnapshot, embedTextForProject, embedBatchForProject, embedItemsForProject, embedUnembeddedMemoriesForProject, drainCommitBacklogForProject, embedSessionCompartmentChunks, getEmbeddingCoverageStatus, isEmbeddingEnabled, embedText, ensureMemoryEmbeddings, computeCueContentHash, hasMuralCueColumns, getMuralCueState, memoryNeedsCue, setMuralCue, recordMuralCueRejection, hasMemoryShareableColumn, hasMemoryClassifiedAtColumn, getUnclassifiedMemoryIds, ModuleMemoryAuthorityError, insertMemory, insertMemoryIdempotent, getMemoryByHash, getMemoriesByProject, buildWorkspaceMemorySqlFilter, getMemoriesByProjects, getMaxMemoryIdForProjects, readNewMemoriesForM1Union, getMemoryById, getMemoriesByIds, updateMemorySeenCount, updateMemoryRetrievalCount, setMemoryClassification, supersededMemory, mergeMemoryStats, archiveMemory, getMemoryCountsByStatus, sanitizeFtsQuery, searchMemoriesFTS, searchMemoriesFTSUnion, recordMemoryMapping, recordMemoryVerifications, getUnmappedMemoryIds, clearMemoryVerifications, getMemoryVerifications, resolveGitTopLevel, readGitHead, readGitChangedFilesSince, readGitFileChangeTimesSince, verificationFileExists, normalizeVerificationFiles, recordChildInvocation, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, getMural, BoundedSessionMap, registerLkgPersistence, beginLkgPass, visitMessageContentFields, messageContentFields, signatureForFields, exactReusablePrefix, incrementalLkgContentDigests, lkgContentDigest, captureSlot, getInMemorySlot, getSlot, dropSlot, noteEntry, getLkgSlotHeapStats, onNoteTrigger, peekNoteNudgeText, markNoteNudgeDelivered, clearNoteNudgeTriggerAndCooldown, resetNoteNudgeCooldownOnly, clearNoteNudgeTriggerOnly, getOpenCodeDbPath, removeMcOwnedCompactionMarkers, MARKER_SUMMARY_TEXT, applyDeferredCompactionMarker, removeCompactionMarkerForSession, checkCompactionMarkerConsistency, modelKeyAcceptsImages, resolveMuralWire, extractM0Block, formatDate, injectTemporalMarkers, clearInjectionCache, getVisibleMemoryIds, selectHiddenMessagesAtCompactionSeam, prepareCompartmentInjection, renderCompartmentInjection, mustMaterialize, trimMemoriesToBudgetV2, renderMemoryBlockV2, prepareCachedM0M1Replay, hasCompleteCachedM0M1, injectM0M1, describeBoundaryDiagnostics, RECOVERY_NO_HEAD_LIMIT, resolveOpenCodeProtectedTailBoundary, resolveWrapupProtectedTailBoundary, getRawHistoryEligibility, hasRunnableCompartmentWindow, recordHighPressureNoEligibleHead, runCompartmentAgent, snapRangeToCompartments, getActiveCompartmentRun, markActiveCompartmentRunPublished, registerActiveCompartmentRun, startCompartmentAgent, setRecompStarting2, setRecompTerminal2, runManagedRecomp2, runManagedUpgrade2 };
|
|
41536
|
+
export { withContentLanguageDirective, buildPrimaryLanguageDirective, setJsoncValue, removeJsoncValue, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, resolveLegacyConfigSources, resolveLegacyConfigSourcesForHarness, migrateMagicContextConfigLocations, string, unknown, array, object, union, tuple, record, parseCron, nextOccurrence, nextDueAtMs, promptSurfaceConfigIdentity, resolveModelConfigValue, resolvePromptSurface, resolveModelConfigOrDefault, DEFAULT_EXECUTE_THRESHOLD_PERCENTAGE, DEFAULT_HISTORIAN_TIMEOUT_MS, DEFAULT_LOCAL_EMBEDDING_MODEL, PER_HARNESS_MIGRATION_INVENTORY, PER_HARNESS_MODEL_KEYS, ConfigProfilesSchema, MagicContextConfigSchema, isFailClosedBlockingError, shouldBypassFailClosedBlock, resolveAgentNameFromMessages, createFailClosedController, recordHookInitFailure, clearHookInitFailure, getLastHookInitFailure, ProjectIdentityError, resolveProjectIdentityStrict, takeDubiousOwnershipProjectIdentityWarning, resolveProjectIdentity, directoryHasGitMetadata, resolveProjectIdentityForSession, normalizeStoredProjectPath, storedPathBelongsToIdentity, isLinkedGitWorktree, recordSessionProjectIdentity, beginBootQuietPeriod, bootQuietRemainingMs, scheduleAfterBootQuiet, rpcPortDir, rpcPortFilePath, isPidAlive, parseRpcPortFile, observeAuthorityRouting, registerModuleNoteEvaluationBridge, getModuleNoteEvaluationBridge, getContextStoreUuid, ensureContextStoreUuid, getAuthorityManagedMarker, reconcileAuthorityProject, checksumAuthoritySeedRows, prepareAuthority, drainAuthority, getMemoryMirrorStatus, applyMirroredNoteCompileFields, drainMirrorPages, pullMemoryMirrorOnce, V2_MEMORY_CATEGORIES, CATEGORY_PRIORITY, resolveWorkspaceShareCategories, resolveWorkspaceIdentitySet, expandWorkspaceIdentitySetWithAliases, resolveStoredPathWorkspaceIdentity, storedPathBelongsToWorkspace, sourceNameForMemory, computeWorkspaceEpochFingerprint, textMentionsRecentCommit, hasMeaningfulUserText, extractTexts, extractToolCallSummaries, getTokenizerNativeMemoryStats, preloadTokenizer, estimateTokens, normalizeText, getCurrentToolSetHash, recordToolDefinition, getMeasuredToolDefinitionTokens, getSchemaFenceRejection, getMigrationOnOpenRefusal, LATEST_SUPPORTED_VERSION, getDatabasePath, getPersistedSchemaVersion, setSqlitePragmaConfig, runSqliteOptimize, openDatabase, openDatabaseAsync, isDatabasePersisted, getDatabasePersistenceError, COMPARTMENT_AGENT_SYSTEM_PROMPT, HISTORIAN_EDITOR_SYSTEM_PROMPT, COMPARTMENT_STRUCTURAL_SYSTEM_PROMPT, Priority, AdmissionClass, SocketClosedError, SocketTimeoutError, StaleRouteHandleError, SubcClient, isConsumerReconnectTransient, connectionFileExists, isRecord, CTX_REDUCE_KEEP, newestCtxReduceTagNumbers, stripWellFormedLeadingTagPrefix, stripPersistedAssistantText, byteSize, stripTagPrefix, prependTag, isThinkingPart, estimateImageTokensFromDataUrl, normalizeTodoStateJson, buildSyntheticTodoPart, computeSyntheticCallId, isSyntheticTodoPart, countRealUserMessages, tailHygieneStructuralSignature, sameTailHygieneStructuralSignature, refreshTailHygieneBaseline, effectiveTailHygiene, assertTailHygieneContentUnchanged, CHANNEL1_SENTINEL, CHANNEL1_FLOOR_TOKENS, toolOutputTokens, decideChannel1, evaluateChannel2, formatChannel1Evaluation, formatChannel2Evaluation, reclaimableToolOutputCount, buildChannel2Reminder, buildChannel1Reminder, estimateEmergencyDropReclaimTokens, planEmergencyDrop, getRecentTagOwnerMessageIds, AGE_RECLAIM_MIN_TOKENS, getOldestActiveUnprotectedToolTags, getActiveToolTagsForAgeReclaim, getTriggerTagTokenUpperBound, getActiveTagTokenTotalsByMessage, tagTokenCountIsNull, backfillTagTokenCounts, insertTag, updateTagStatus, markWhitespaceAssistantTagInert, getInertWhitespaceAssistantTags, updateTagDropMode, updateCavemanDepth, updateTagMessageId, markTagsCompactedByMessageIds, deleteTagsByMessageId, getMaxTagNumberBySession, getTagNumberByMessageId, getAssignableTagNumberByMessageId, deriveTagLoadFloor, getTagsBySession, getActiveTagsBySession, getTailHygieneTags, getDroppedTagsBySession, getTagsByNumbers, getDroppedTagsByNumbers, getMaxDroppedTagNumber, getTagById, getToolTagNumberByOwner, getNullOwnerToolTag, adoptNullOwnerToolTag, getCandidateToolOwners, pickNearestPriorOwner, isRawCompactionSummaryInfo, extractInMemoryMessageViews, buildInMemoryTailRawMessages, estimateTrueRawMessageTokens, invalidateTrueRawTokenCache, isTextPart, isToolPartWithOutput, isFilePart, buildFileSourceContent, assertExecutableToolInput, createDroppedInputToolExecuteBeforeHook, isEditTool, partHasCompletedResult, extractToolCallObservation, ToolMutationBatch, createToolDropTarget, setRawMessageProvider, cleanUserText, withRawSessionMessageCache, readRawSessionMessages, primeTailRawMessageCache, primeInMemoryTailRawMessageCache, readRawSessionMessageOrdinalPage, getRawSessionStoredMessageCount, readRawSessionMessagePartsById, readRawSessionMessageOrdinalById, readRawSessionMessageById, readSessionChunk, readRawSessionSeedTail, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLeaseBestEffort, HAS_COMPARTMENT_CONTENT_SQL, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, clearRecompStaging, getMessageIndexSourceIdentity, isMessageIndexSourceCurrent, getLastIndexedOrdinal, getIndexedMessageCorpusSize, getMessageIndexReconciliationStartOrdinal, isMessageIndexReconciledThrough, deleteIndexedMessage, clearIndexedMessages, indexSingleMessage, indexMessagesAfterOrdinal, sweepOrphanedOpenCodeMessageIndexes, recordEmbeddingMeasurement, getMaxM0MutationId, queueMemoryMutation, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationIdForProjects, MAX_EXECUTE_THRESHOLD, escalationBands, MERGED_REASONING_PARTS_PREFIX, readFrozenMergedReasoningParts, getProtectionWindowForSession, isEmergencyRecoveryArmed, isProviderOverflowReconfirmed, isProviderOverflowFailClosedProven, getEmergencyRecoveryArmedAt, loadPersistedUsage, loadProtectedTailMeta, resetProtectedTailNoEligibleHead, getWrapupInProgressState, acquireWrapupInProgress, updateWrapupInProgress, releaseWrapupInProgress, resolveCompactionModeRecord, getCompactionModeRecord, setCompactionModeRecord, getPersistedReasoningWatermark, setPersistedReasoningWatermark, clearPersistedReasoningWatermark, getEmergencyInputSample, setEmergencyDropSample, clearEmergencyDropSample, getLastNudgeUndropped, setLastNudgeUndropped, getChannel1NudgeState, setChannel1NudgeState, markChannel1PostReduceGracePending, captureChannel1PostReduceGraceBaseline, getChannel2NudgeState, getChannel2NudgeClaim, setChannel2NudgeState, casChannel2NudgeState, claimChannel2NudgeState, casChannel2NudgeClaim, getPersistedNoteNudge, getNoteNudgeAnchors, getAutoSearchHintDecisions, appendAutoSearchHintDecision, pruneNoteNudgeAnchors, pruneAutoSearchHintDecisions, removeNoteNudgeAnchorByMessageId, removeAutoSearchHintDecisionByMessageId, getPersistedTodoPermissionDenied, setPersistedTodoPermissionDenied, getPersistedTodoSyntheticAnchor, setPersistedTodoSyntheticAnchor, clearPersistedTodoSyntheticAnchor, setNoteLastReadAt, getHistorianFailureState, clearHistorianFailureState, getOverflowState, loadTransformPassStateSnapshot, recordOverflowDetected, recordDetectedContextLimit, clearEmergencyRecovery, clearDetectedContextLimit, getPersistedCompactionMarkerState, setPersistedCompactionMarkerState, getDeferredClearedCompactionMarkerState, retireDeferredClearedCompactionMarkerState, getStrippedPlaceholderIds, applyStrippedPlaceholderDelta, removeStrippedPlaceholderId, NEWEST_REASONING_BEARING_ASSISTANT, THINKING_BINDING_RECOVERY_FROZEN_PREFIX, thinkingBindingRecoveryFrozenId, getThinkingBindingRecoveryTarget, armThinkingBindingRecovery, clearThinkingBindingRecoveryIf, getMergedReasoningStrippedIds, addMergedReasoningStrippedIds, getTrailingBlankDecisions, addTrailingBlankDecisions, demoteTrailingBlankKeepDecisions, getStaleReduceStrippedIds, addStaleReduceStrippedIds, getProcessedImageStrippedIds, addProcessedImageStrippedIds, getPendingCompactionMarkerState, loadPostprocessReplaySnapshot, setPendingCompactionMarkerState, clearPendingCompactionMarkerStateIf, getSessionsWithPendingMarker, setSessionWorkMetrics, getObservedEpochFloor, resolveEpochFloorForPass, getNotes, addNote, getSessionNotes, getPendingSmartNotes, getReadySmartNotes, updateNote, dismissNotes, dismissNote, markNoteReady, markNoteChecked, queuePendingOp, getPendingOps, getPendingOpsCount, clearPendingOps, removePendingOp, PRIMER_CANDIDATE_TTL_MS, PRIMER_CANDIDATE_MAX_AGE_MS, primerOccurrenceKey, primerOccurrenceUtcDay, updatePrimerCandidateEmbedding, getPrimerCandidatesByIds, getPrimerCandidatesForPromotion, countPrimerCandidatesForProject, getActivePrimers, createPrimer, updatePrimerSupport, updatePrimerAnswer, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectMemoryEpoch, bumpProjectUserProfileVersion, saveSourceContent, replaceSourceContent, getSourceContents, createChildSessionWithFence, HiddenCompletionRefusal, detectThinkingBindingMismatch, isFable51ThinkingBindingModel, detectOverflow, modelBodyField, toModelEntry, getPromptFailureDetail, promptSyncWithValidatedOutputRetry, normalizeSDKResponse, promptSurfaceHashMaterial, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, extractLatestAssistantText, hasLengthCappedOutput, setKeepSubagents, teardownChildSession, renderUserFacingFailure, userFacingFailureCode, renderCapabilityRefusal, capabilityRefusalCode, renderDreamFailure, dreamFailureCode, renderEmbeddingFailure, getCompartmentEvents, SYNAPSE_DEFAULT_MODEL, toSynapseLaneDescriptor, formatSynapseLaneDescriptor, SynapseEmbeddingProvider, loadCompartmentChunkEmbeddingsForSearch, cosineSimilarity, computeNormalizedHash, getLocalEmbeddingNativeMemoryStats, saveCommitEmbedding, loadProjectCommitEmbeddings, loadUnembeddedCommits, countEmbeddedCommits, upsertCommits, getLatestIndexedCommitTimeMs, enforceProjectCap, GIT_SWEEP_LEASE_RENEWAL_MS, acquireGitSweepLease, renewGitSweepLease, markGitSweepSuccessAndRelease, parkGitSweepNonIndexable, releaseGitSweepLease, saveEmbeddingIfHashMatches, getProjectEmbeddings, peekProjectEmbeddings, invalidateProject, invalidateMemory, describeShadowBackfillWriteRefusal, markProjectLoadUntrusted, contentSha256, sweepStaleEmbeddingIdentitiesForProject, registerProjectEmbedding, registerProjectShadowEmbedding, getShadowEmbeddingMeasurementCohort, getPrimaryEmbeddingMeasurementCohort, embedShadowTextForProject, enqueueShadowEmbeddingItems, registerProjectInObservationMode, getProjectEmbeddingSnapshot, embedTextForProject, embedBatchForProject, embedItemsForProject, embedUnembeddedMemoriesForProject, drainCommitBacklogForProject, embedSessionCompartmentChunks, getEmbeddingCoverageStatus, isEmbeddingEnabled, embedText, ensureMemoryEmbeddings, computeCueContentHash, hasMuralCueColumns, getMuralCueState, memoryNeedsCue, setMuralCue, recordMuralCueRejection, hasMemoryShareableColumn, hasMemoryClassifiedAtColumn, getUnclassifiedMemoryIds, ModuleMemoryAuthorityError, insertMemory, insertMemoryIdempotent, getMemoryByHash, getMemoriesByProject, buildWorkspaceMemorySqlFilter, getMemoriesByProjects, getMaxMemoryIdForProjects, readNewMemoriesForM1Union, getMemoryById, getMemoriesByIds, updateMemorySeenCount, updateMemoryRetrievalCount, setMemoryClassification, supersededMemory, mergeMemoryStats, archiveMemory, getMemoryCountsByStatus, sanitizeFtsQuery, searchMemoriesFTS, searchMemoriesFTSUnion, recordMemoryMapping, recordMemoryVerifications, getUnmappedMemoryIds, clearMemoryVerifications, getMemoryVerifications, resolveGitTopLevel, readGitHead, readGitChangedFilesSince, readGitFileChangeTimesSince, verificationFileExists, normalizeVerificationFiles, recordChildInvocation, createV1HiddenCompletionExecutor, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, getMural, BoundedSessionMap, registerLkgPersistence, beginLkgPass, visitMessageContentFields, messageContentFields, signatureForFields, exactReusablePrefix, incrementalLkgContentDigests, lkgContentDigest, captureSlot, getInMemorySlot, getSlot, dropSlot, noteEntry, getLkgSlotHeapStats, onNoteTrigger, peekNoteNudgeText, markNoteNudgeDelivered, clearNoteNudgeTriggerAndCooldown, resetNoteNudgeCooldownOnly, clearNoteNudgeTriggerOnly, getOpenCodeDbPath, removeMcOwnedCompactionMarkers, MARKER_SUMMARY_TEXT, applyDeferredCompactionMarker, removeCompactionMarkerForSession, checkCompactionMarkerConsistency, modelKeyAcceptsImages, resolveMuralWire, extractM0Block, formatDate, injectTemporalMarkers, clearInjectionCache, getVisibleMemoryIds, selectHiddenMessagesAtCompactionSeam, prepareCompartmentInjection, renderCompartmentInjection, mustMaterialize, trimMemoriesToBudgetV2, renderMemoryBlockV2, materializeM0, prepareCachedM0M1Replay, hasCompleteCachedM0M1, injectM0M1, describeBoundaryDiagnostics, RECOVERY_NO_HEAD_LIMIT, resolveOpenCodeProtectedTailBoundary, resolveWrapupProtectedTailBoundary, getRawHistoryEligibility, hasRunnableCompartmentWindow, recordHighPressureNoEligibleHead, runCompartmentAgent, snapRangeToCompartments, getActiveCompartmentRun, markActiveCompartmentRunPublished, registerActiveCompartmentRun, startCompartmentAgent, setRecompStarting2, setRecompTerminal2, runManagedRecomp2, runManagedUpgrade2 };
|