@cortexkit/pi-magic-context 0.49.46 → 0.49.48
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 +1 -1
- package/dist/chunk-embedding-write-worker.js +1 -1
- package/dist/{index-v7m1nqwz.js → index-6748dkmx.js} +1 -1
- package/dist/{index-qt711raa.js → index-806brt0p.js} +1 -1
- package/dist/{index-wwf9vxpf.js → index-bbffazv6.js} +1 -1
- package/dist/{index-zchc0df8.js → index-bhj8kymt.js} +1 -9
- package/dist/{index-nvgq29cw.js → index-gwm5x42c.js} +5 -5
- package/dist/{index-ewf0sd7d.js → index-h1rtbjrp.js} +112 -12
- package/dist/{index-jaqdcqwz.js → index-j1kkx3f3.js} +1 -1
- package/dist/{index-ea37qn4x.js → index-nvh6d3bz.js} +66 -14
- package/dist/{index-6bedye3n.js → index-pja6ggeq.js} +4 -4
- package/dist/{index-7esg5v2x.js → index-vnygvrad.js} +1 -1
- package/dist/{index-fzadydec.js → index-zybqfwfv.js} +1 -1
- package/dist/index.js +336 -28
- package/dist/{message-index-bounded-cqn6x6fc.js → message-index-bounded-f0bk44ch.js} +3 -3
- package/dist/migration-worker.js +1 -1
- package/dist/raw-ordinal-warmup-worker.js +4 -4
- package/dist/{read-session-chunk-0ecmbegv.js → read-session-chunk-6nt4dzkk.js} +2 -2
- package/dist/{render-s6k2xqhj.js → render-yn7fgmg7.js} +6 -6
- package/dist/{search-archive-qza20zkm.js → search-archive-pcf0za02.js} +4 -4
- package/dist/{search-p4fj69gn.js → search-yvcam5gm.js} +4 -4
- package/dist/{storage-tags-g0j9mr4b.js → storage-tags-s0zqj0m0.js} +1 -1
- package/dist/{store-v60q7dje.js → store-0hhs1db3.js} +1 -1
- package/dist/{store-reader-2m80zs5z.js → store-reader-mmfw2h48.js} +1 -1
- package/dist/subagent-entry.js +10 -10
- package/dist/tag-snapshot-worker-pi.js +3 -3
- package/dist/{v2-archive-reader-2v7a879f.js → v2-archive-reader-accb2tjp.js} +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -97,6 +97,9 @@ import {
|
|
|
97
97
|
MEMORY_MURAL_BLOCK,
|
|
98
98
|
buildMagicContextSection,
|
|
99
99
|
resolveMuralWire,
|
|
100
|
+
requestToolsFingerprint,
|
|
101
|
+
classifyRequestToolsChange,
|
|
102
|
+
requestToolSchemaDigest,
|
|
100
103
|
updateCompactionMarkerAfterPublication,
|
|
101
104
|
COMPARTMENT_RENDER_EPOCH,
|
|
102
105
|
MEMORY_RENDER_FORMAT_EPOCH,
|
|
@@ -150,7 +153,7 @@ import {
|
|
|
150
153
|
registerTodoStateLifecycle,
|
|
151
154
|
syncCtxMemoryToolEnabled,
|
|
152
155
|
registerMagicContextTools
|
|
153
|
-
} from "./index-
|
|
156
|
+
} from "./index-h1rtbjrp.js";
|
|
154
157
|
import"./index-4knyh1kt.js";
|
|
155
158
|
import {
|
|
156
159
|
canonicalModelIdentity,
|
|
@@ -353,7 +356,7 @@ import {
|
|
|
353
356
|
getRawSessionTagKeysThrough2,
|
|
354
357
|
getLegacyProtectedTailStartOrdinal2,
|
|
355
358
|
readSessionChunk2
|
|
356
|
-
} from "./index-
|
|
359
|
+
} from "./index-vnygvrad.js";
|
|
357
360
|
import {
|
|
358
361
|
UNKNOWN_FIT_RATIO,
|
|
359
362
|
hasMeasuredDecisionCalibration,
|
|
@@ -379,6 +382,8 @@ import {
|
|
|
379
382
|
TailHygieneJsonMemo,
|
|
380
383
|
piJsonHash,
|
|
381
384
|
estimateImageTokensFromDataUrl,
|
|
385
|
+
TODO_STATUSES,
|
|
386
|
+
TODO_PRIORITIES,
|
|
382
387
|
normalizeTodoStateJson,
|
|
383
388
|
buildSyntheticTodoPart,
|
|
384
389
|
stripChannel1ReminderSpans,
|
|
@@ -440,7 +445,7 @@ import {
|
|
|
440
445
|
getToolTagNumberByOwner2,
|
|
441
446
|
getNullOwnerToolTag2,
|
|
442
447
|
adoptNullOwnerToolTag2
|
|
443
|
-
} from "./index-
|
|
448
|
+
} from "./index-bhj8kymt.js";
|
|
444
449
|
import {
|
|
445
450
|
textMentionsRecentCommit,
|
|
446
451
|
hasMeaningfulUserText2,
|
|
@@ -490,7 +495,7 @@ import {
|
|
|
490
495
|
openCurrentDatabase,
|
|
491
496
|
openDatabaseAsync,
|
|
492
497
|
closeDatabase
|
|
493
|
-
} from "./index-
|
|
498
|
+
} from "./index-bbffazv6.js";
|
|
494
499
|
import {
|
|
495
500
|
LkgRecoveryFenceError,
|
|
496
501
|
clearLkgFenceProcessState,
|
|
@@ -607,7 +612,7 @@ import {
|
|
|
607
612
|
getSourceContents,
|
|
608
613
|
recordSubagentInvocation,
|
|
609
614
|
getLatestHistorianInvocationId
|
|
610
|
-
} from "./index-
|
|
615
|
+
} from "./index-pja6ggeq.js";
|
|
611
616
|
import {
|
|
612
617
|
resolveOpenCodeDbPath,
|
|
613
618
|
assertOpenCodeStoreGeneration,
|
|
@@ -626,7 +631,7 @@ import {
|
|
|
626
631
|
import {
|
|
627
632
|
RAW_SUMMARY_TEXT_MAX_CHARS2
|
|
628
633
|
} from "./index-3g9fnq6y.js";
|
|
629
|
-
import"./index-
|
|
634
|
+
import"./index-nvh6d3bz.js";
|
|
630
635
|
import {
|
|
631
636
|
formatSynapseLaneDescriptor
|
|
632
637
|
} from "./index-gwvahsdz.js";
|
|
@@ -665,7 +670,7 @@ import {
|
|
|
665
670
|
clearCompressionDepthRange,
|
|
666
671
|
cleanSearchText,
|
|
667
672
|
matchedSearchSnippet
|
|
668
|
-
} from "./index-
|
|
673
|
+
} from "./index-zybqfwfv.js";
|
|
669
674
|
import {
|
|
670
675
|
rememberV1HiddenRun
|
|
671
676
|
} from "./index-6x556c2q.js";
|
|
@@ -797,7 +802,7 @@ import {
|
|
|
797
802
|
scheduleClearAndReindex,
|
|
798
803
|
clearSessionTracking,
|
|
799
804
|
createAutoSearchDiagnostics
|
|
800
|
-
} from "./index-
|
|
805
|
+
} from "./index-806brt0p.js";
|
|
801
806
|
import"./index-2kmwjq42.js";
|
|
802
807
|
import {
|
|
803
808
|
DREAMER_PRIMER_INVESTIGATOR_ALLOWED_TOOLS,
|
|
@@ -825,11 +830,11 @@ import {
|
|
|
825
830
|
drainPiTagSnapshotSession,
|
|
826
831
|
assertPiTagSnapshotReady,
|
|
827
832
|
ensurePiTagSnapshotReady
|
|
828
|
-
} from "./index-
|
|
833
|
+
} from "./index-j1kkx3f3.js";
|
|
829
834
|
import"./index-cq71g4dk.js";
|
|
830
835
|
import"./index-1cvyaw9a.js";
|
|
831
|
-
import"./index-
|
|
832
|
-
import"./index-
|
|
836
|
+
import"./index-gwm5x42c.js";
|
|
837
|
+
import"./index-6748dkmx.js";
|
|
833
838
|
import {
|
|
834
839
|
__toESM
|
|
835
840
|
} from "./index-22jkk6wg.js";
|
|
@@ -3584,7 +3589,7 @@ function startHostStallProfilerSwitch() {
|
|
|
3584
3589
|
// package.json
|
|
3585
3590
|
var package_default = {
|
|
3586
3591
|
name: "@cortexkit/pi-magic-context",
|
|
3587
|
-
version: "0.49.
|
|
3592
|
+
version: "0.49.48",
|
|
3588
3593
|
type: "module",
|
|
3589
3594
|
description: "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
|
|
3590
3595
|
main: "dist/index.js",
|
|
@@ -25344,7 +25349,7 @@ function hasReclaimRide(signals) {
|
|
|
25344
25349
|
return signals.hardFold || signals.force || signals.explicitFlush || signals.publishedHistory || signals.subagentExecute === true || signals.executeReclaim === true || signals.servedShapeRepair === true;
|
|
25345
25350
|
}
|
|
25346
25351
|
function prefixMutationPermitted(gate) {
|
|
25347
|
-
return !gate.signedThinkingHold || gate.firstRender || gate.emergency;
|
|
25352
|
+
return !gate.signedThinkingHold || gate.firstRender || gate.hostCheckpointHead === true || gate.emergency;
|
|
25348
25353
|
}
|
|
25349
25354
|
function reclaimRidePermitted(signals, gate) {
|
|
25350
25355
|
return prefixMutationPermitted(gate) && hasReclaimRide(signals);
|
|
@@ -27387,6 +27392,89 @@ function recoveryRefusalNotice(historyRemains) {
|
|
|
27387
27392
|
return historyRemains ? RECOVERY_REFUSAL_NOTICE : RECOVERY_NO_HISTORY_REFUSAL_NOTICE;
|
|
27388
27393
|
}
|
|
27389
27394
|
|
|
27395
|
+
// ../plugin/src/hooks/magic-context/request-tools-release.ts
|
|
27396
|
+
var NAMESPACE3 = "requestToolsRelease";
|
|
27397
|
+
var MAX_MODEL_RECORDS = 8;
|
|
27398
|
+
function parseEntry(value) {
|
|
27399
|
+
if (typeof value !== "object" || value === null)
|
|
27400
|
+
return null;
|
|
27401
|
+
const record = value;
|
|
27402
|
+
if (typeof record.modelKey !== "string" || typeof record.names !== "string" || typeof record.descriptions !== "string" || typeof record.schemas !== "string")
|
|
27403
|
+
return null;
|
|
27404
|
+
return {
|
|
27405
|
+
modelKey: record.modelKey,
|
|
27406
|
+
names: record.names,
|
|
27407
|
+
descriptions: record.descriptions,
|
|
27408
|
+
schemas: record.schemas
|
|
27409
|
+
};
|
|
27410
|
+
}
|
|
27411
|
+
function parseStored(value) {
|
|
27412
|
+
const models = value?.models;
|
|
27413
|
+
if (!Array.isArray(models))
|
|
27414
|
+
return [];
|
|
27415
|
+
const entries = [];
|
|
27416
|
+
for (const item of models) {
|
|
27417
|
+
const entry = parseEntry(item);
|
|
27418
|
+
if (entry)
|
|
27419
|
+
entries.push(entry);
|
|
27420
|
+
}
|
|
27421
|
+
return entries;
|
|
27422
|
+
}
|
|
27423
|
+
function sameEntry(left, right) {
|
|
27424
|
+
return left !== undefined && left.modelKey === right.modelKey && left.names === right.names && left.descriptions === right.descriptions && left.schemas === right.schemas;
|
|
27425
|
+
}
|
|
27426
|
+
function isLatest(entries, current) {
|
|
27427
|
+
return sameEntry(entries.at(-1), current);
|
|
27428
|
+
}
|
|
27429
|
+
function withLatest(entries, current) {
|
|
27430
|
+
const next = entries.filter((entry) => entry.modelKey !== current.modelKey);
|
|
27431
|
+
next.push(current);
|
|
27432
|
+
return next.slice(-MAX_MODEL_RECORDS);
|
|
27433
|
+
}
|
|
27434
|
+
function evaluateRequestToolsRelease(args) {
|
|
27435
|
+
const current = { modelKey: args.modelKey, ...args.fingerprint };
|
|
27436
|
+
let entries = [];
|
|
27437
|
+
let readable = true;
|
|
27438
|
+
try {
|
|
27439
|
+
entries = parseStored(readReplayEnvelope(args.db, args.sessionId, "read")[NAMESPACE3]);
|
|
27440
|
+
} catch (error) {
|
|
27441
|
+
readable = false;
|
|
27442
|
+
sessionLog2(args.sessionId, "request tools record unreadable:", error);
|
|
27443
|
+
}
|
|
27444
|
+
const stored = entries.find((entry) => entry.modelKey === current.modelKey);
|
|
27445
|
+
const change = stored ? classifyRequestToolsChange(stored, current) : null;
|
|
27446
|
+
if (change !== null) {
|
|
27447
|
+
sessionLog2(args.sessionId, `request tools changed (kind=${change === "schemas" ? "schema-only" : change}, model=${current.modelKey}, schemas ${stored?.schemas.slice(0, 12)}→${current.schemas.slice(0, 12)}): releasing signed thinking`);
|
|
27448
|
+
} else if (readable && !stored) {
|
|
27449
|
+
sessionLog2(args.sessionId, `request tools fingerprint adopted for model=${current.modelKey}${entries.length > 0 ? ` (records kept for ${entries.map((entry) => entry.modelKey).join(",")})` : ""}`);
|
|
27450
|
+
}
|
|
27451
|
+
return {
|
|
27452
|
+
change,
|
|
27453
|
+
commit: () => {
|
|
27454
|
+
if (!readable || isLatest(entries, current))
|
|
27455
|
+
return;
|
|
27456
|
+
try {
|
|
27457
|
+
let next = entries;
|
|
27458
|
+
const written = updateReplayDocument(args.db, args.sessionId, (doc) => {
|
|
27459
|
+
const latest = parseStored(doc[NAMESPACE3]);
|
|
27460
|
+
if (isLatest(latest, current))
|
|
27461
|
+
return false;
|
|
27462
|
+
next = withLatest(latest, current);
|
|
27463
|
+
doc.version = 2;
|
|
27464
|
+
doc[NAMESPACE3] = { models: next };
|
|
27465
|
+
return true;
|
|
27466
|
+
});
|
|
27467
|
+
if (written)
|
|
27468
|
+
entries = next;
|
|
27469
|
+
else
|
|
27470
|
+
sessionLog2(args.sessionId, "request tools record not written");
|
|
27471
|
+
} catch (error) {
|
|
27472
|
+
sessionLog2(args.sessionId, "request tools record write failed:", error);
|
|
27473
|
+
}
|
|
27474
|
+
}
|
|
27475
|
+
};
|
|
27476
|
+
}
|
|
27477
|
+
|
|
27390
27478
|
// ../plugin/src/hooks/magic-context/signed-thinking-hold.ts
|
|
27391
27479
|
var HEAVY_REASONING_TOKENS = 1500;
|
|
27392
27480
|
var HEAVY_REASONING_WINDOW_STEPS = 15;
|
|
@@ -42283,6 +42371,167 @@ function resolvePiProvenInputFloor(args) {
|
|
|
42283
42371
|
return observed;
|
|
42284
42372
|
}
|
|
42285
42373
|
|
|
42374
|
+
// src/pi-request-tools.ts
|
|
42375
|
+
var schemaDigests = {
|
|
42376
|
+
omp: new WeakMap,
|
|
42377
|
+
anthropic: new WeakMap,
|
|
42378
|
+
"anthropic-strict": new WeakMap,
|
|
42379
|
+
raw: new WeakMap
|
|
42380
|
+
};
|
|
42381
|
+
function anthropicWireSchema(parameters, strict) {
|
|
42382
|
+
const schema = typeof parameters === "object" && parameters !== null ? parameters : {};
|
|
42383
|
+
const legacy = {
|
|
42384
|
+
type: "object",
|
|
42385
|
+
properties: schema.properties ?? {},
|
|
42386
|
+
required: schema.required ?? []
|
|
42387
|
+
};
|
|
42388
|
+
return strict ? { ...schema, ...legacy } : legacy;
|
|
42389
|
+
}
|
|
42390
|
+
function schemaDigest(tool, mode, wireSchema) {
|
|
42391
|
+
const key = tool.parameters;
|
|
42392
|
+
const cacheable = typeof key === "object" && key !== null || typeof key === "function";
|
|
42393
|
+
const cache = schemaDigests[mode];
|
|
42394
|
+
if (cacheable) {
|
|
42395
|
+
const cached = cache.get(key);
|
|
42396
|
+
if (cached !== undefined)
|
|
42397
|
+
return cached;
|
|
42398
|
+
}
|
|
42399
|
+
const digest = requestToolSchemaDigest(mode === "omp" && wireSchema ? wireSchema(tool) : mode === "anthropic" || mode === "anthropic-strict" ? anthropicWireSchema(tool.parameters, mode === "anthropic-strict") : tool.parameters);
|
|
42400
|
+
if (cacheable)
|
|
42401
|
+
cache.set(key, digest);
|
|
42402
|
+
return digest;
|
|
42403
|
+
}
|
|
42404
|
+
var CLAUDE_CODE_TOOL_NAMES = new Map([
|
|
42405
|
+
"Read",
|
|
42406
|
+
"Write",
|
|
42407
|
+
"Edit",
|
|
42408
|
+
"Bash",
|
|
42409
|
+
"Grep",
|
|
42410
|
+
"Glob",
|
|
42411
|
+
"AskUserQuestion",
|
|
42412
|
+
"EnterPlanMode",
|
|
42413
|
+
"ExitPlanMode",
|
|
42414
|
+
"KillShell",
|
|
42415
|
+
"NotebookEdit",
|
|
42416
|
+
"Skill",
|
|
42417
|
+
"Task",
|
|
42418
|
+
"TaskOutput",
|
|
42419
|
+
"TodoWrite",
|
|
42420
|
+
"WebFetch",
|
|
42421
|
+
"WebSearch"
|
|
42422
|
+
].map((name) => [name.toLowerCase(), name]));
|
|
42423
|
+
var identityName = (name) => name;
|
|
42424
|
+
var claudeCodeName = (name) => CLAUDE_CODE_TOOL_NAMES.get(name.toLowerCase()) ?? name;
|
|
42425
|
+
function compatFlag(model, flag) {
|
|
42426
|
+
const value = model?.compat?.[flag];
|
|
42427
|
+
return typeof value === "boolean" ? value : undefined;
|
|
42428
|
+
}
|
|
42429
|
+
function supportsToolReferences(model) {
|
|
42430
|
+
const declared = compatFlag(model, "supportsToolReferences");
|
|
42431
|
+
if (declared !== undefined)
|
|
42432
|
+
return declared;
|
|
42433
|
+
if (model.provider !== "anthropic" || typeof model.id !== "string")
|
|
42434
|
+
return false;
|
|
42435
|
+
if (model.id.includes("haiku"))
|
|
42436
|
+
return false;
|
|
42437
|
+
const version = model.id.match(/^claude-(?:opus|sonnet|fable)-(\d+)(?:-(\d+))?(?:-|$)/);
|
|
42438
|
+
if (!version)
|
|
42439
|
+
return false;
|
|
42440
|
+
const major = Number(version[1]);
|
|
42441
|
+
const minor = version[2] && version[2].length < 8 ? Number(version[2]) : 0;
|
|
42442
|
+
return major > 4 || major === 4 && minor >= 5;
|
|
42443
|
+
}
|
|
42444
|
+
function deferredAndReferencedNames(messages, normalizeName) {
|
|
42445
|
+
const deferred = new Set;
|
|
42446
|
+
const referenced = new Set;
|
|
42447
|
+
for (const message of messages) {
|
|
42448
|
+
const { role, content, addedToolNames } = message ?? {};
|
|
42449
|
+
if (role === "assistant" && Array.isArray(content)) {
|
|
42450
|
+
for (const block of content) {
|
|
42451
|
+
const { type, name } = block ?? {};
|
|
42452
|
+
if (type === "toolCall" && typeof name === "string")
|
|
42453
|
+
referenced.add(normalizeName(name));
|
|
42454
|
+
}
|
|
42455
|
+
} else if (role === "toolResult" && Array.isArray(addedToolNames)) {
|
|
42456
|
+
for (const name of addedToolNames) {
|
|
42457
|
+
if (typeof name !== "string")
|
|
42458
|
+
continue;
|
|
42459
|
+
const normalized = normalizeName(name);
|
|
42460
|
+
if (!referenced.has(normalized))
|
|
42461
|
+
deferred.add(normalized);
|
|
42462
|
+
}
|
|
42463
|
+
}
|
|
42464
|
+
}
|
|
42465
|
+
for (const name of deferred)
|
|
42466
|
+
referenced.add(name);
|
|
42467
|
+
return { deferred, referenced };
|
|
42468
|
+
}
|
|
42469
|
+
function calledToolNames(messages) {
|
|
42470
|
+
const names = new Set;
|
|
42471
|
+
for (const message of messages) {
|
|
42472
|
+
const content = message?.content;
|
|
42473
|
+
if (!Array.isArray(content))
|
|
42474
|
+
continue;
|
|
42475
|
+
for (const part of content) {
|
|
42476
|
+
const { type, name } = part ?? {};
|
|
42477
|
+
if (typeof type === "string" && type.toLowerCase().includes("tool") && typeof name === "string")
|
|
42478
|
+
names.add(name);
|
|
42479
|
+
}
|
|
42480
|
+
}
|
|
42481
|
+
return names;
|
|
42482
|
+
}
|
|
42483
|
+
function readPiRequestToolsFingerprint(pi, wireSchema, messages, route = {}) {
|
|
42484
|
+
try {
|
|
42485
|
+
if (typeof pi.getAllTools !== "function" || typeof pi.getActiveTools !== "function")
|
|
42486
|
+
return;
|
|
42487
|
+
const all = pi.getAllTools();
|
|
42488
|
+
const active = pi.getActiveTools();
|
|
42489
|
+
if (!Array.isArray(all) || !Array.isArray(active))
|
|
42490
|
+
return;
|
|
42491
|
+
const registered = new Map;
|
|
42492
|
+
for (const tool of all) {
|
|
42493
|
+
if (!tool || typeof tool !== "object")
|
|
42494
|
+
return;
|
|
42495
|
+
const { name } = tool;
|
|
42496
|
+
if (typeof name !== "string")
|
|
42497
|
+
return;
|
|
42498
|
+
registered.set(name, tool);
|
|
42499
|
+
}
|
|
42500
|
+
const model = route.model;
|
|
42501
|
+
const anthropicWriter = route.host === "pi" && wireSchema === undefined && model?.api === "anthropic-messages";
|
|
42502
|
+
const mode = wireSchema ? "omp" : anthropicWriter ? compatFlag(model, "supportsStrictTools") === true ? "anthropic-strict" : "anthropic" : "raw";
|
|
42503
|
+
const normalizeName = anthropicWriter && route.oauth === true ? claudeCodeName : identityName;
|
|
42504
|
+
const sent = new Map;
|
|
42505
|
+
for (const name of active) {
|
|
42506
|
+
if (typeof name !== "string")
|
|
42507
|
+
return;
|
|
42508
|
+
const tool = registered.get(name);
|
|
42509
|
+
if (!tool)
|
|
42510
|
+
continue;
|
|
42511
|
+
sent.set(normalizeName(name), tool);
|
|
42512
|
+
}
|
|
42513
|
+
const split = anthropicWriter && model && supportsToolReferences(model) ? deferredAndReferencedNames(messages, normalizeName) : undefined;
|
|
42514
|
+
const anyImmediate = [...sent.keys()].some((name) => !split?.deferred.has(name));
|
|
42515
|
+
const tools = [];
|
|
42516
|
+
for (const [name, tool] of sent) {
|
|
42517
|
+
const description = typeof tool.description === "string" ? tool.description : "";
|
|
42518
|
+
tools.push({
|
|
42519
|
+
name,
|
|
42520
|
+
description,
|
|
42521
|
+
schemaDigest: schemaDigest({
|
|
42522
|
+
name: tool.name,
|
|
42523
|
+
description,
|
|
42524
|
+
parameters: tool.parameters
|
|
42525
|
+
}, mode, wireSchema),
|
|
42526
|
+
deferLoading: split ? anyImmediate && split.deferred.has(name) : tool.defer_loading === true || tool.deferLoading === true
|
|
42527
|
+
});
|
|
42528
|
+
}
|
|
42529
|
+
return requestToolsFingerprint(tools, () => split?.referenced ?? calledToolNames(messages));
|
|
42530
|
+
} catch {
|
|
42531
|
+
return;
|
|
42532
|
+
}
|
|
42533
|
+
}
|
|
42534
|
+
|
|
42286
42535
|
// src/pi-tag-identity-repair.ts
|
|
42287
42536
|
var PI_TAG_IDENTITY_REPAIR_REASON = "tag_identity_repair";
|
|
42288
42537
|
var unreadableLedgerLogged = new Set;
|
|
@@ -42779,13 +43028,26 @@ function resolvePiBindingStripOrder(args) {
|
|
|
42779
43028
|
if (hasThinkingPart(args.messages[index]))
|
|
42780
43029
|
carriesThinking = true;
|
|
42781
43030
|
}
|
|
42782
|
-
|
|
42783
|
-
if (mayChangeOrder && addMergedReasoningStrippedIds(args.db, args.sessionId, [
|
|
43031
|
+
if (onBranch && carriesThinking && args.bustPermittedAtStart && addMergedReasoningStrippedIds(args.db, args.sessionId, [
|
|
42784
43032
|
THINKING_BINDING_STRIP_ORDER_END_MARKER
|
|
42785
43033
|
])) {
|
|
42786
43034
|
return "end";
|
|
42787
43035
|
}
|
|
42788
|
-
return "start";
|
|
43036
|
+
return args.releasesAllThinking === true ? "end" : "start";
|
|
43037
|
+
}
|
|
43038
|
+
function recordPiBindingStripEndOrder(db, sessionId) {
|
|
43039
|
+
try {
|
|
43040
|
+
const ledger = getMergedReasoningStrippedIds(db, sessionId);
|
|
43041
|
+
if (ledger.has(THINKING_BINDING_STRIP_ORDER_END_MARKER))
|
|
43042
|
+
return true;
|
|
43043
|
+
if (frozenBindingEntryIds(db, sessionId).size === 0)
|
|
43044
|
+
return true;
|
|
43045
|
+
return addMergedReasoningStrippedIds(db, sessionId, [
|
|
43046
|
+
THINKING_BINDING_STRIP_ORDER_END_MARKER
|
|
43047
|
+
]);
|
|
43048
|
+
} catch {
|
|
43049
|
+
return false;
|
|
43050
|
+
}
|
|
42789
43051
|
}
|
|
42790
43052
|
function shouldRunPiProactiveThinkingStrip(args) {
|
|
42791
43053
|
return !args.compactionOff && args.bindingStripOrder === "end";
|
|
@@ -46236,12 +46498,34 @@ function registerPiContextHandler(pi, baseOptions) {
|
|
|
46236
46498
|
const lkgInputIdByRef = new Map;
|
|
46237
46499
|
for (const input of lkgPassSnapshot.inputs)
|
|
46238
46500
|
lkgInputIdByRef.set(event.messages[input.messageIndex], input.id);
|
|
46501
|
+
const requestToolsRelease = isPrefixBoundThinkingModel(ctx.model?.provider, ctx.model?.id) ? (() => {
|
|
46502
|
+
const fingerprint = readPiRequestToolsFingerprint(pi, toolWireSchema, event.messages, {
|
|
46503
|
+
host: getHarness2() === "omp" ? "omp" : "pi",
|
|
46504
|
+
model: ctx.model,
|
|
46505
|
+
oauth: (() => {
|
|
46506
|
+
try {
|
|
46507
|
+
const registry = ctx.modelRegistry;
|
|
46508
|
+
return ctx.model && typeof registry?.isUsingOAuth === "function" ? registry.isUsingOAuth(ctx.model) === true : false;
|
|
46509
|
+
} catch {
|
|
46510
|
+
return false;
|
|
46511
|
+
}
|
|
46512
|
+
})()
|
|
46513
|
+
});
|
|
46514
|
+
return fingerprint ? evaluateRequestToolsRelease({
|
|
46515
|
+
db: options.db,
|
|
46516
|
+
sessionId,
|
|
46517
|
+
modelKey: `${ctx.model?.provider}/${ctx.model?.id}`,
|
|
46518
|
+
fingerprint
|
|
46519
|
+
}) : undefined;
|
|
46520
|
+
})() : undefined;
|
|
46521
|
+
const requestToolsChange = requestToolsRelease?.change ?? null;
|
|
46239
46522
|
const bindingStripOrder = resolvePiBindingStripOrder({
|
|
46240
46523
|
db: options.db,
|
|
46241
46524
|
sessionId,
|
|
46242
46525
|
messages: event.messages,
|
|
46243
46526
|
entryIds: lkgEntryIds ?? [],
|
|
46244
|
-
bustPermittedAtStart: hasPendingMaterialization(sessionId)
|
|
46527
|
+
bustPermittedAtStart: hasPendingMaterialization(sessionId),
|
|
46528
|
+
releasesAllThinking: requestToolsChange !== null
|
|
46245
46529
|
});
|
|
46246
46530
|
const startOfPassBindingRecovery = bindingStripOrder === "start" ? applyPiThinkingBindingRecovery({
|
|
46247
46531
|
db: options.db,
|
|
@@ -46657,7 +46941,7 @@ function registerPiContextHandler(pi, baseOptions) {
|
|
|
46657
46941
|
schedulerDeferReason,
|
|
46658
46942
|
forceMaterialization: forceMaterialization || isEmergency,
|
|
46659
46943
|
forceMaterializationPercentage,
|
|
46660
|
-
signedThinkingHold: resolvePiSignedThinkingHold({
|
|
46944
|
+
signedThinkingHold: requestToolsChange === null && resolvePiSignedThinkingHold({
|
|
46661
46945
|
sessionId,
|
|
46662
46946
|
db: options.db,
|
|
46663
46947
|
messages: event.messages,
|
|
@@ -46665,6 +46949,7 @@ function registerPiContextHandler(pi, baseOptions) {
|
|
|
46665
46949
|
usagePercentage,
|
|
46666
46950
|
executeThresholdPercentage: effectiveExecuteThresholdPercentage
|
|
46667
46951
|
}),
|
|
46952
|
+
requestToolsChange,
|
|
46668
46953
|
contextUsage: {
|
|
46669
46954
|
percentage: usagePercentage,
|
|
46670
46955
|
inputTokens: usageInputTokens
|
|
@@ -47400,7 +47685,11 @@ function registerPiContextHandler(pi, baseOptions) {
|
|
|
47400
47685
|
}
|
|
47401
47686
|
budget.assertOutcome();
|
|
47402
47687
|
publishTransformDecision?.();
|
|
47403
|
-
if (
|
|
47688
|
+
if (requestToolsChange === null || recordPiBindingStripEndOrder(options.db, sessionId))
|
|
47689
|
+
requestToolsRelease?.commit();
|
|
47690
|
+
else
|
|
47691
|
+
sessionLog2(sessionId, "request tools release not recorded: the end strip order could not be written");
|
|
47692
|
+
if (!budget.sideTurn && (result.strictThinkingKept && !result.signedPrefixRewritten || result.heldHeadReleasedForSystemChange === true) && !result.materialized)
|
|
47404
47693
|
recordPiHeldSystemHead(sessionId, (ownsHistory) => deferPiDeliveredSystemRefresh(sessionId, ownsHistory));
|
|
47405
47694
|
recordServedSystemHash();
|
|
47406
47695
|
return { messages: outputMessages };
|
|
@@ -48143,7 +48432,7 @@ async function runCompactionOffPipeline(args) {
|
|
|
48143
48432
|
muralEnabled: args.injection.muralEnabled === true,
|
|
48144
48433
|
compactionOff: true
|
|
48145
48434
|
};
|
|
48146
|
-
const signedTurnHoldsHead = args.reasoningClearing?.prefixBound === true && hasActiveAnthropicThinkingTurn(args.messages, args.resolvedProviderID, args.resolvedModelID);
|
|
48435
|
+
const signedTurnHoldsHead = !args.requestToolsChange && args.reasoningClearing?.prefixBound === true && hasActiveAnthropicThinkingTurn(args.messages, args.resolvedProviderID, args.resolvedModelID);
|
|
48147
48436
|
if (signedTurnHoldsHead)
|
|
48148
48437
|
state.preparedPrefix = prepareCachedM0M1PiReplay(state, args.db, args.injectionPassSnapshot?.cachedRow);
|
|
48149
48438
|
const servedBeforeFirstRender = signedTurnHoldsHead && !state.preparedPrefix ? args.readLastServedMessages?.() ?? null : undefined;
|
|
@@ -48160,7 +48449,7 @@ async function runCompactionOffPipeline(args) {
|
|
|
48160
48449
|
sessionLog2(args.sessionId, "compaction-off fold changed the head: stripping signed thinking");
|
|
48161
48450
|
}
|
|
48162
48451
|
}
|
|
48163
|
-
if (headChangedUnderSignedThinking)
|
|
48452
|
+
if (headChangedUnderSignedThinking || args.requestToolsChange)
|
|
48164
48453
|
applyPiProactiveThinkingStrip({
|
|
48165
48454
|
db: args.db,
|
|
48166
48455
|
sessionId: args.sessionId,
|
|
@@ -48271,7 +48560,7 @@ async function runPipeline(args) {
|
|
|
48271
48560
|
cacheBustingPass: isCacheBustingPass,
|
|
48272
48561
|
stripActiveTurn: true,
|
|
48273
48562
|
persistOnly: true,
|
|
48274
|
-
requirePersistence: !!args.recoveryRebuildReason
|
|
48563
|
+
requirePersistence: !!args.recoveryRebuildReason || !!args.requestToolsChange
|
|
48275
48564
|
});
|
|
48276
48565
|
if (activeThinkingTurn && isCacheBustingPass && !result)
|
|
48277
48566
|
throw new Error("Cannot persist signed thinking omission before prefix rewrite");
|
|
@@ -48281,6 +48570,8 @@ async function runPipeline(args) {
|
|
|
48281
48570
|
};
|
|
48282
48571
|
if (args.recoveryRebuildReason || args.forceSignedRebuildForFit && signedTurnOnPrefixBoundModel)
|
|
48283
48572
|
stripForPrefixRewrite(isCacheBustingPass);
|
|
48573
|
+
if (args.requestToolsChange && !rewritingSignedPrefix)
|
|
48574
|
+
stripForPrefixRewrite();
|
|
48284
48575
|
const stripUnheldSignedTurnOnBust = () => {
|
|
48285
48576
|
if (isCacheBustingPass && signedTurnOnPrefixBoundModel && !protectedSignedPrefix && !rewritingSignedPrefix)
|
|
48286
48577
|
stripForPrefixRewrite();
|
|
@@ -48458,6 +48749,12 @@ async function runPipeline(args) {
|
|
|
48458
48749
|
const mismatch = foldDueDecision.mismatch ? ` mismatch=${JSON.stringify(foldDueDecision.mismatch)}` : "";
|
|
48459
48750
|
sessionLog2(args.sessionId, `pi m[0] HARD fold decision: reason=${preFoldInjectionResult?.m0Reason ?? foldDueDecision.reason ?? "soft_refresh"}${mismatch} executed=${foldExecutedThisPass} bustsServedPrefix=${foldBustsServedPrefixThisPass}`);
|
|
48460
48751
|
}
|
|
48752
|
+
let heldHeadReleasedForSystemChange = false;
|
|
48753
|
+
if (effectiveSystemChangedThisPass && protectedSignedPrefix) {
|
|
48754
|
+
sessionLog2(args.sessionId, "system prompt changed under a held signed turn: releasing signed thinking");
|
|
48755
|
+
heldHeadReleasedForSystemChange = !firstRenderBust && piM0State !== undefined;
|
|
48756
|
+
stripForPrefixRewrite();
|
|
48757
|
+
}
|
|
48461
48758
|
const temporalCandidates = args.temporalAwareness ? collectPiTemporalCandidates(args.messages, args.entryIds ?? []) : new Map;
|
|
48462
48759
|
for (const entry of readPiIdentityDecisions(args.db, args.sessionId) ?? []) {
|
|
48463
48760
|
const decision = decodePiContentDecision(entry);
|
|
@@ -49469,12 +49766,14 @@ async function runPipeline(args) {
|
|
|
49469
49766
|
stripPiLeadingTemporalMarker(message);
|
|
49470
49767
|
}
|
|
49471
49768
|
}
|
|
49472
|
-
if (
|
|
49473
|
-
|
|
49474
|
-
|
|
49475
|
-
|
|
49476
|
-
|
|
49477
|
-
|
|
49769
|
+
if (!heldHeadReleasedForSystemChange) {
|
|
49770
|
+
if (args.isCacheBusting && prefixMutationAllowed) {
|
|
49771
|
+
historyRefreshSessions.delete(args.sessionId);
|
|
49772
|
+
historyWasConsumedThisPass = true;
|
|
49773
|
+
}
|
|
49774
|
+
if (deferredHistoryRefresh && prefixMutationAllowed) {
|
|
49775
|
+
historyWasConsumedThisPass = true;
|
|
49776
|
+
}
|
|
49478
49777
|
}
|
|
49479
49778
|
logTransformTiming(args.sessionId, "prepareCompartmentInjection", tInjection);
|
|
49480
49779
|
logTransformTiming(args.sessionId, "compartmentPhase", tInjection);
|
|
@@ -49722,6 +50021,7 @@ async function runPipeline(args) {
|
|
|
49722
50021
|
prefixBustPermitted: isCacheBustingPass,
|
|
49723
50022
|
prefixMutationAllowed,
|
|
49724
50023
|
strictThinkingKept: protectedSignedPrefix,
|
|
50024
|
+
heldHeadReleasedForSystemChange,
|
|
49725
50025
|
signedPrefixRewritten: rewritingSignedPrefix,
|
|
49726
50026
|
prefixRebuildAlreadyPriced: firstRenderBust || !!args.recoveryRebuildReason && isCacheBustingPass,
|
|
49727
50027
|
identityRebuilt: identityRebuild,
|
|
@@ -53542,6 +53842,8 @@ function persistPiMessageEndModelMeta(args) {
|
|
|
53542
53842
|
function getCompatiblePiTodoCapture(todos) {
|
|
53543
53843
|
if (!Array.isArray(todos))
|
|
53544
53844
|
return null;
|
|
53845
|
+
if (!todos.every(hasPiTodowriteEnumValues))
|
|
53846
|
+
return null;
|
|
53545
53847
|
const normalized = normalizeTodoStateJson(todos);
|
|
53546
53848
|
if (normalized === null)
|
|
53547
53849
|
return null;
|
|
@@ -53550,6 +53852,12 @@ function getCompatiblePiTodoCapture(todos) {
|
|
|
53550
53852
|
return null;
|
|
53551
53853
|
return { normalized, todos: parsed };
|
|
53552
53854
|
}
|
|
53855
|
+
function hasPiTodowriteEnumValues(todo) {
|
|
53856
|
+
if (todo === null || typeof todo !== "object")
|
|
53857
|
+
return false;
|
|
53858
|
+
const { status, priority } = todo;
|
|
53859
|
+
return TODO_STATUSES.includes(status) && (priority === undefined || TODO_PRIORITIES.includes(priority));
|
|
53860
|
+
}
|
|
53553
53861
|
function applyCompatiblePiTodoCapture(args) {
|
|
53554
53862
|
rememberTodowriteToolCallTodos(args.toolCallId, args.capture.todos);
|
|
53555
53863
|
if (args.todowriteEnabled) {
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
withIndexChunk2,
|
|
4
4
|
yieldIndexChunk2
|
|
5
5
|
} from "./index-2qtx0q6h.js";
|
|
6
|
-
import"./index-
|
|
6
|
+
import"./index-bhj8kymt.js";
|
|
7
7
|
import"./index-000fthre.js";
|
|
8
8
|
import"./index-0h2mkab2.js";
|
|
9
9
|
import"./index-gymgz20n.js";
|
|
@@ -15,7 +15,7 @@ import"./index-wfqysrwq.js";
|
|
|
15
15
|
import"./index-x2n261wp.js";
|
|
16
16
|
import"./index-3g9fnq6y.js";
|
|
17
17
|
import"./index-n0zjvs3h.js";
|
|
18
|
-
import"./index-
|
|
18
|
+
import"./index-vnygvrad.js";
|
|
19
19
|
import"./index-6x556c2q.js";
|
|
20
20
|
import"./index-c6wbq66z.js";
|
|
21
21
|
import {
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
markMessageIndexDirty,
|
|
26
26
|
getIndexableContent,
|
|
27
27
|
indexSingleMessage
|
|
28
|
-
} from "./index-
|
|
28
|
+
} from "./index-zybqfwfv.js";
|
|
29
29
|
import"./index-bbbp8zs1.js";
|
|
30
30
|
import"./index-0wtm7g7f.js";
|
|
31
31
|
|
package/dist/migration-worker.js
CHANGED
|
@@ -19,7 +19,7 @@ serveWorkerJobs(async (input, port) => {
|
|
|
19
19
|
await main();
|
|
20
20
|
async function main() {
|
|
21
21
|
if (input.v2ArchiveReader) {
|
|
22
|
-
const { serveV2ArchiveReads } = await import("./v2-archive-reader-
|
|
22
|
+
const { serveV2ArchiveReads } = await import("./v2-archive-reader-accb2tjp.js");
|
|
23
23
|
await serveV2ArchiveReads(port, openConnections);
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
@@ -51,7 +51,7 @@ serveWorkerJobs(async (input, port) => {
|
|
|
51
51
|
await runMessageFtsRowidMapBackfill(db);
|
|
52
52
|
reply = { kind: "fts-rowid-backfill" };
|
|
53
53
|
} else if (input.searchArchive) {
|
|
54
|
-
const { renderSearchArchive } = await import("./search-archive-
|
|
54
|
+
const { renderSearchArchive } = await import("./search-archive-pcf0za02.js");
|
|
55
55
|
const { readRawSessionMessageIdOrdinalsForRangeFromDb } = await import("./read-session-raw-nttnwy8p.js");
|
|
56
56
|
const archive = input.searchArchive;
|
|
57
57
|
let raw;
|
|
@@ -81,7 +81,7 @@ serveWorkerJobs(async (input, port) => {
|
|
|
81
81
|
const { setHarness } = await import("./harness-9872e0ym.js");
|
|
82
82
|
setHarness(input.harness ?? "opencode");
|
|
83
83
|
const [{ indexMessageInShortChunks }, { configureContextDatabasePragmas }] = await Promise.all([
|
|
84
|
-
import("./message-index-bounded-
|
|
84
|
+
import("./message-index-bounded-f0bk44ch.js"),
|
|
85
85
|
import("./sqlite-context-pragmas-gcgch6qz.js")
|
|
86
86
|
]);
|
|
87
87
|
configureContextDatabasePragmas(db);
|
|
@@ -95,7 +95,7 @@ serveWorkerJobs(async (input, port) => {
|
|
|
95
95
|
measurements: result.measurements
|
|
96
96
|
};
|
|
97
97
|
} else if (input.tagRatio !== undefined) {
|
|
98
|
-
const { scanTagOwnerSummary, scanTagOwnerDelta } = await import("./storage-tags-
|
|
98
|
+
const { scanTagOwnerSummary, scanTagOwnerDelta } = await import("./storage-tags-s0zqj0m0.js");
|
|
99
99
|
const delta = input.tagState ? scanTagOwnerDelta(db, input.sessionId, input.tagState) : null;
|
|
100
100
|
if (delta)
|
|
101
101
|
reply = { kind: "tag-delta", delta };
|
|
@@ -38,8 +38,8 @@ import {
|
|
|
38
38
|
readSessionChunk2,
|
|
39
39
|
getRawSessionMessageIdsThrough2,
|
|
40
40
|
readRawSessionSeedTail2
|
|
41
|
-
} from "./index-
|
|
42
|
-
import"./index-
|
|
41
|
+
} from "./index-vnygvrad.js";
|
|
42
|
+
import"./index-bhj8kymt.js";
|
|
43
43
|
import"./index-6x556c2q.js";
|
|
44
44
|
import"./index-gzk7d940.js";
|
|
45
45
|
import"./index-c6wbq66z.js";
|
|
@@ -3,18 +3,18 @@ import {
|
|
|
3
3
|
renderVerboseRange2,
|
|
4
4
|
renderVerboseRangeForTool2,
|
|
5
5
|
renderItemByTag2
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-pja6ggeq.js";
|
|
7
7
|
import"./index-w26zvs1q.js";
|
|
8
|
-
import"./index-
|
|
8
|
+
import"./index-zybqfwfv.js";
|
|
9
9
|
import"./index-hgd00nas.js";
|
|
10
|
-
import"./index-
|
|
10
|
+
import"./index-nvh6d3bz.js";
|
|
11
11
|
import"./index-4sa1rx3h.js";
|
|
12
|
-
import"./index-
|
|
13
|
-
import"./index-
|
|
12
|
+
import"./index-vnygvrad.js";
|
|
13
|
+
import"./index-bhj8kymt.js";
|
|
14
14
|
import"./index-6x556c2q.js";
|
|
15
15
|
import"./index-gwvahsdz.js";
|
|
16
16
|
import"./index-gzk7d940.js";
|
|
17
|
-
import"./index-
|
|
17
|
+
import"./index-bbffazv6.js";
|
|
18
18
|
import"./index-fapenpch.js";
|
|
19
19
|
import"./index-d107f484.js";
|
|
20
20
|
import"./index-135e8hvg.js";
|