@cortexkit/pi-magic-context 0.49.59 → 0.49.61

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.
@@ -501,7 +501,8 @@ var PROVIDER_GEOMETRY = {
501
501
  anthropic: "shared_truncating",
502
502
  xai: "shared_truncating",
503
503
  google: "separate",
504
- "google-antigravity": "separate"
504
+ "google-antigravity": "separate",
505
+ "antigravity-cli": "separate"
505
506
  };
506
507
  var geometryClampLogSeen = new Set;
507
508
  function isFinitePositive(value) {
@@ -691,7 +692,11 @@ var MAX_SANE_LIMIT = 3000000;
691
692
  function isSaneLimit(limit) {
692
693
  return typeof limit === "number" && limit >= MIN_SANE_LIMIT && limit <= MAX_SANE_LIMIT;
693
694
  }
694
- var SEPARATE_OUTPUT_QUOTA_PROVIDERS = new Set(["google", "google-antigravity"]);
695
+ var SEPARATE_OUTPUT_QUOTA_PROVIDERS = new Set([
696
+ "google",
697
+ "google-antigravity",
698
+ "antigravity-cli"
699
+ ]);
695
700
  var MIN_PLAUSIBLE_CONTEXT_LIMIT2 = 1024;
696
701
  var OUTPUT_RESERVE_CAP_RATIO2 = 0.25;
697
702
  var outputReserveConfig;
package/dist/index.js CHANGED
@@ -154,7 +154,7 @@ import {
154
154
  registerTodoStateLifecycle,
155
155
  syncCtxMemoryToolEnabled,
156
156
  registerMagicContextTools
157
- } from "./index-2tk7e0bx.js";
157
+ } from "./index-418za765.js";
158
158
  import"./index-4knyh1kt.js";
159
159
  import {
160
160
  canonicalModelIdentity,
@@ -3601,7 +3601,7 @@ function startHostStallProfilerSwitch() {
3601
3601
  // package.json
3602
3602
  var package_default = {
3603
3603
  name: "@cortexkit/pi-magic-context",
3604
- version: "0.49.59",
3604
+ version: "0.49.61",
3605
3605
  type: "module",
3606
3606
  description: "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
3607
3607
  main: "dist/index.js",
@@ -3630,7 +3630,7 @@ var package_default = {
3630
3630
  ],
3631
3631
  "//": "The build intentionally bundles typebox (no --external typebox) and keeps it a regular dependency. OMP's extension loader rewrites every bare `typebox` import to its own omptype-based shim, whose schemas are callable objects rather than JSON Schema; they fail structuredClone during tool registration, so an external typebox import stops Magic Context loading on OMP. src/typebox-bundling.test.ts guards this.",
3632
3632
  scripts: {
3633
- build: "bun ../../scripts/check-bun.mjs && tsc -p ../retina-local-fs/tsconfig.build.json && bun ../../scripts/clean-dist-chunks.mjs dist index.js subagent-entry.js historian-calibration-extension.js embedding-worker-process.js raw-ordinal-warmup-worker.js tag-snapshot-worker-pi.js transformers-web.js transformers-node-wasm.js && bun build ../plugin/src/features/magic-context/memory/transformers-web-entry.ts --outfile dist/transformers-web.js --target browser --format esm --external onnxruntime-web && bun ../plugin/scripts/build-transformers-node-wasm.ts dist && bun build src/index.ts src/tag-snapshot-worker-pi.ts src/subagent-entry.ts src/historian-calibration-extension.ts ../plugin/src/features/magic-context/memory/embedding-worker.ts ../plugin/src/features/magic-context/memory/embedding-worker-process.ts ../plugin/src/features/magic-context/migration-worker.ts ../plugin/src/hooks/magic-context/auto-search-worker.ts ../plugin/src/hooks/magic-context/raw-ordinal-warmup-worker.ts ../plugin/src/features/magic-context/compaction-marker-candidates-worker.ts ../plugin/src/features/magic-context/chunk-embedding-write-worker.ts --outdir dist --entry-naming '[name].[ext]' --target node --format esm --splitting --external @earendil-works/pi-coding-agent --external @oh-my-pi/pi-coding-agent --external @earendil-works/pi-tui --external onnxruntime-node --external onnxruntime-web --external sharp --external bun:ffi --external node:sqlite",
3633
+ build: "bun ../../scripts/check-bun.mjs && tsc -p ../retina-local-fs/tsconfig.build.json && bun ../../scripts/clean-dist-chunks.mjs dist index.js subagent-entry.js historian-calibration-extension.js embedding-worker-process.js raw-ordinal-warmup-worker.js tag-snapshot-worker-pi.js transformers-web.js transformers-node-wasm.js && bun build ../plugin/src/features/magic-context/memory/transformers-web-entry.ts --outfile dist/transformers-web.js --target browser --format esm --external onnxruntime-web && bun ../plugin/scripts/build-transformers-node-wasm.ts dist && bun build src/index.ts src/tag-snapshot-worker-pi.ts src/subagent-entry.ts src/historian-calibration-extension.ts ../plugin/src/features/magic-context/memory/embedding-worker.ts ../plugin/src/features/magic-context/memory/embedding-worker-process.ts ../plugin/src/features/magic-context/migration-worker.ts ../plugin/src/hooks/magic-context/auto-search-worker.ts ../plugin/src/hooks/magic-context/raw-ordinal-warmup-worker.ts ../plugin/src/features/magic-context/compaction-marker-candidates-worker.ts ../plugin/src/features/magic-context/chunk-embedding-write-worker.ts --outdir dist --entry-naming '[name].[ext]' --target node --format esm --splitting --external @earendil-works/pi-coding-agent --external @oh-my-pi/pi-coding-agent --external @earendil-works/pi-tui --external @earendil-works/pi-ai --external onnxruntime-node --external onnxruntime-web --external sharp --external bun:ffi --external node:sqlite",
3634
3634
  "build:e2e-argv": `bun ../../scripts/clean-dist-chunks.mjs ../../tests/docker/.generated subagent-runner-e2e.mjs && bun build src/subagent-runner.ts --outdir ../../tests/docker/.generated --entry-naming 'subagent-runner-e2e.mjs' --splitting --target node --format esm --external node:sqlite && node --input-type=module -e 'const { __test } = await import("../../tests/docker/.generated/subagent-runner-e2e.mjs"); if (typeof __test.buildArgs !== "function" || typeof __test.resolvePiInvocation !== "function") throw new Error("argv renderer exports missing"); console.log("Node argv renderer: 2 exports loaded")'`,
3635
3635
  typecheck: "tsc -p ../retina-local-fs/tsconfig.build.json && tsc --noEmit",
3636
3636
  test: "bun ../../scripts/check-bun.mjs && bun install --frozen-lockfile && MC_SLOW_TESTS=0 BUN_JSC_useOMGJIT=0 bun test --parallel=4 --timeout 30000",
@@ -3670,6 +3670,7 @@ var package_default = {
3670
3670
  "omp-coding-agent-18132": "npm:@oh-my-pi/pi-coding-agent@18.13.2",
3671
3671
  "omp-coding-agent-18186": "npm:@oh-my-pi/pi-coding-agent@18.18.6",
3672
3672
  "omp-coding-agent-18190": "npm:@oh-my-pi/pi-coding-agent@18.19.0",
3673
+ "omp-coding-agent-18220": "npm:@oh-my-pi/pi-coding-agent@18.22.0",
3673
3674
  "omp-pi-ai-171": "npm:@oh-my-pi/pi-ai@17.1.7",
3674
3675
  "omp-pi-ai-1889": "npm:@oh-my-pi/pi-ai@18.8.9",
3675
3676
  "omp-pi-ai-1811": "npm:@oh-my-pi/pi-ai@18.11.3",
@@ -33501,7 +33502,7 @@ function applyPiHeuristicCleanup(sessionId, db, targets, piMessages, config, pre
33501
33502
  const tMeasure = performance.now();
33502
33503
  const activeTags = tags.filter((t) => t.status === "active").map((tag) => {
33503
33504
  const target = targets.get(tag.tagNumber);
33504
- const imageTokens = emergency.serializedImageTokens?.get(tag.messageId) ?? 0;
33505
+ const imageTokens = emergency.toolImageTokens?.get(tag.messageId) ?? 0;
33505
33506
  const observation = target?.measureReclaim;
33506
33507
  const measuredTarget = imageTokens && observation ? {
33507
33508
  ...target,
@@ -33518,7 +33519,7 @@ function applyPiHeuristicCleanup(sessionId, db, targets, piMessages, config, pre
33518
33519
  return emergency.sinceReading?.has(tag.tagNumber) ? { ...measured, sinceReading: true } : measured;
33519
33520
  });
33520
33521
  const byTag = new Map(activeTags.map((tag) => [tag.tagNumber, tag]));
33521
- const removedThisPassTokens = emergency.servedBeforePass ? piServedMassRemovedSince(emergency.servedBeforePass, new Set(activeTags.map((tag) => tag.tagNumber)), targets, calibration, emergency.serializedImageTokens) : 0;
33522
+ const removedThisPassTokens = emergency.servedBeforePass ? piServedMassRemovedSince(emergency.servedBeforePass, new Set(activeTags.map((tag) => tag.tagNumber)), targets, calibration, emergency.toolImageTokens) : 0;
33522
33523
  const droppableTags = candidateTags.flatMap((tag) => {
33523
33524
  const measured = byTag.get(tag.tagNumber);
33524
33525
  return measured ? [measured] : [];
@@ -34905,28 +34906,27 @@ function trimPiMessagesToBoundary(piMessages, entryIds, cutoffMessageId, trimMut
34905
34906
  break;
34906
34907
  }
34907
34908
  }
34908
- if (cutoffIndex < 0 && sessionId && hasRawMessageProvider2(sessionId)) {
34909
+ let promptReachesBoundary;
34910
+ if (cutoffIndex >= 0) {
34911
+ idCutBoundaryByMessages.set(piMessages, cutoffMessageId);
34912
+ } else if (sessionId && piMessages.length > 0 && hasRawMessageProvider2(sessionId)) {
34913
+ let placement;
34909
34914
  try {
34910
- const branch = readRawSessionMessages2(sessionId);
34911
- const positions = new Map(branch.map((message, index) => [message.id, index]));
34912
- const boundaryPosition = positions.get(cutoffMessageId);
34913
- if (boundaryPosition === undefined)
34914
- return 0;
34915
- let previous = -1;
34916
- for (const [index, message] of piMessages.entries()) {
34917
- if (isPiSystemEntry(message))
34918
- continue;
34919
- const id = resolveStableId(message, index, entryIds);
34920
- const position = positions.get(id) ?? positions.get(`${SYNTH_USER_ID_PREFIX}${id}`);
34921
- if (position === undefined || position <= previous)
34922
- return 0;
34923
- previous = position;
34924
- if (position <= boundaryPosition)
34925
- cutoffIndex = index;
34926
- }
34927
- } catch {
34915
+ placement = placeCutByBranchPosition(piMessages, entryIds, cutoffMessageId, sessionId);
34916
+ } catch (error) {
34917
+ placement = {
34918
+ placed: false,
34919
+ reason: `the branch could not be read (${error instanceof Error ? error.message : String(error)})`,
34920
+ firstUnplacedRole: "unknown"
34921
+ };
34922
+ }
34923
+ if (!placement.placed) {
34924
+ if (idCutBoundaryByMessages.get(piMessages) !== cutoffMessageId)
34925
+ logUnplacedCut(sessionId, cutoffMessageId, piMessages.length, placement.reason, placement.firstUnplacedRole);
34928
34926
  return 0;
34929
34927
  }
34928
+ cutoffIndex = placement.cutoffIndex;
34929
+ promptReachesBoundary = placement.promptReachesBoundary;
34930
34930
  }
34931
34931
  if (cutoffIndex < 0)
34932
34932
  return 0;
@@ -34985,6 +34985,9 @@ function trimPiMessagesToBoundary(piMessages, entryIds, cutoffMessageId, trimMut
34985
34985
  }
34986
34986
  }
34987
34987
  }
34988
+ const keptPrompt = keptPromptIndex(piMessages, cutoffIndex, remove, promptReachesBoundary);
34989
+ if (keptPrompt >= 0)
34990
+ remove.delete(keptPrompt);
34988
34991
  const retiredIds = new Set;
34989
34992
  if (retireDecisions) {
34990
34993
  for (const index of remove) {
@@ -35005,6 +35008,100 @@ function trimPiMessagesToBoundary(piMessages, entryIds, cutoffMessageId, trimMut
35005
35008
  retireDecisions?.(retiredIds);
35006
35009
  return removed;
35007
35010
  }
35011
+ function placeCutByBranchPosition(piMessages, entryIds, cutoffMessageId, sessionId) {
35012
+ const branch = readRawSessionMessages2(sessionId);
35013
+ const positions = new Map(branch.map((message, index) => [message.id, index]));
35014
+ const eventPositions = new Map;
35015
+ let firstUnplacedRole;
35016
+ let contentMessages = 0;
35017
+ for (const [index, message] of piMessages.entries()) {
35018
+ if (isPiSystemEntry(message))
35019
+ continue;
35020
+ contentMessages++;
35021
+ const id = resolveStableId(message, index, entryIds);
35022
+ const position = positions.get(id) ?? positions.get(`${SYNTH_USER_ID_PREFIX}${id}`);
35023
+ if (position === undefined)
35024
+ firstUnplacedRole ??= String(message.role);
35025
+ else
35026
+ eventPositions.set(index, position);
35027
+ }
35028
+ const unplacedRole = firstUnplacedRole ?? "none";
35029
+ const boundaryPosition = positions.get(cutoffMessageId);
35030
+ if (boundaryPosition === undefined)
35031
+ return {
35032
+ placed: false,
35033
+ reason: "it is not on the active branch either",
35034
+ firstUnplacedRole: unplacedRole
35035
+ };
35036
+ if (contentMessages > 0 && eventPositions.size === 0)
35037
+ return {
35038
+ placed: false,
35039
+ reason: "none of them has a branch position",
35040
+ firstUnplacedRole: unplacedRole
35041
+ };
35042
+ let cutoffIndex = -1;
35043
+ let previous = -1;
35044
+ for (const [index, position] of eventPositions) {
35045
+ if (position <= previous)
35046
+ return {
35047
+ placed: false,
35048
+ reason: "the context messages are not in branch order",
35049
+ firstUnplacedRole: unplacedRole
35050
+ };
35051
+ previous = position;
35052
+ if (position <= boundaryPosition)
35053
+ cutoffIndex = index;
35054
+ }
35055
+ return {
35056
+ placed: true,
35057
+ cutoffIndex,
35058
+ promptReachesBoundary: (eventIndex) => {
35059
+ const promptPosition = eventPositions.get(eventIndex);
35060
+ if (promptPosition === undefined)
35061
+ return true;
35062
+ for (let p = promptPosition + 1;p <= boundaryPosition; p++) {
35063
+ const message = branch[p];
35064
+ if (message?.role === "user" && !message.id.startsWith(SYNTH_USER_ID_PREFIX))
35065
+ return false;
35066
+ }
35067
+ return true;
35068
+ }
35069
+ };
35070
+ }
35071
+ function keptPromptIndex(piMessages, cutoffIndex, removed, promptReachesBoundary) {
35072
+ let promptIndex = -1;
35073
+ for (let i = cutoffIndex;i >= 0; i--) {
35074
+ if (piMessages[i]?.role === "user") {
35075
+ promptIndex = i;
35076
+ break;
35077
+ }
35078
+ }
35079
+ if (promptIndex < 0)
35080
+ return -1;
35081
+ for (let i = cutoffIndex + 1;i < piMessages.length; i++) {
35082
+ if (removed.has(i))
35083
+ continue;
35084
+ const message = piMessages[i];
35085
+ if (message?.role === "user")
35086
+ return -1;
35087
+ if (message?.role === "assistant" && message.stopReason !== "error")
35088
+ break;
35089
+ }
35090
+ if (promptReachesBoundary && !promptReachesBoundary(promptIndex))
35091
+ return -1;
35092
+ return promptIndex;
35093
+ }
35094
+ var idCutBoundaryByMessages = new WeakMap;
35095
+ var unplacedCutLoggedSessions = new Set;
35096
+ function resetPiUnplacedCutLog(sessionId) {
35097
+ unplacedCutLoggedSessions.delete(sessionId);
35098
+ }
35099
+ function logUnplacedCut(sessionId, boundaryMessageId, eventLength, reason, firstUnplacedRole) {
35100
+ if (unplacedCutLoggedSessions.has(sessionId))
35101
+ return;
35102
+ unplacedCutLoggedSessions.add(sessionId);
35103
+ sessionLog2(sessionId, `pi history cut not placed: boundary ${boundaryMessageId} is not among the ${eventLength} context messages and ${reason}; first message without a branch position: ${firstUnplacedRole}; nothing was cut at this boundary`);
35104
+ }
35008
35105
  function toolPairKey(callId, assistantIndex) {
35009
35106
  return `${callId}\x00${assistantIndex}`;
35010
35107
  }
@@ -37330,10 +37427,20 @@ function isOmpSideContext(event) {
37330
37427
  return row.role === "developer" && row.attribution === "agent" && textContainsReminder(row.content);
37331
37428
  });
37332
37429
  }
37333
- var ADVISOR_PREFIX = "<conventions>\nRFC 2119 keywords: MUST, REQUIRED, SHOULD, RECOMMENDED, MAY, OPTIONAL. `NEVER`=`MUST NOT`; `AVOID`=`SHOULD NOT`.\n</conventions>\n\nUser, code-quality, robustness advocate; peer-shadow main agent.\n";
37430
+ var ADVISOR_CONVENTIONS = "<conventions>\nRFC 2119 keywords: MUST, REQUIRED, SHOULD, RECOMMENDED, MAY, OPTIONAL. `NEVER`=`MUST NOT`; `AVOID`=`SHOULD NOT`.\n</conventions>\n\n";
37431
+ var ADVISOR_ROLE = `User, code-quality, robustness advocate; peer-shadow main agent.
37432
+ `;
37334
37433
  var ADVISOR_WORKFLOW = `<workflow>
37335
37434
  Receive incremental agent transcript, including thoughts.
37336
37435
  `;
37436
+ var SESSION_UPDATE = `### Session update
37437
+
37438
+ `;
37439
+ var COMPACTION_SUMMARY = `Prior model work/tool state available.
37440
+ MUST build on prior work; NEVER duplicate prior work.
37441
+
37442
+ <summary>
37443
+ `;
37337
37444
  var CAPTURE_PREFIX = "Automated capture turn — not a user reply; user has not responded to your previous turn.";
37338
37445
  function record3(value) {
37339
37446
  return value && typeof value === "object" && !Array.isArray(value) ? value : undefined;
@@ -37413,11 +37520,17 @@ function firstTextBlock(value) {
37413
37520
  const part = record3(value);
37414
37521
  return part?.type === "text" && typeof part.text === "string" ? part.text : undefined;
37415
37522
  }
37523
+ function isOmpStockAdvisorPrompt(text) {
37524
+ if (typeof text !== "string")
37525
+ return false;
37526
+ const body = text.startsWith(ADVISOR_CONVENTIONS) ? text.slice(ADVISOR_CONVENTIONS.length) : text;
37527
+ return body.startsWith(ADVISOR_ROLE) && body.includes(ADVISOR_WORKFLOW);
37528
+ }
37416
37529
  function isOmpAdvisorRequest(payload) {
37417
37530
  const request = providerRequest(payload);
37418
37531
  if (!request?.tools.includes("advise"))
37419
37532
  return false;
37420
- if (!request.system.some((text) => text?.startsWith(ADVISOR_PREFIX) && text.includes(ADVISOR_WORKFLOW)))
37533
+ if (!request.system.some(isOmpStockAdvisorPrompt))
37421
37534
  return false;
37422
37535
  const first = record3(request.messages[0]);
37423
37536
  if (first?.role !== "user")
@@ -37425,9 +37538,7 @@ function isOmpAdvisorRequest(payload) {
37425
37538
  let text = firstText(first.content, request.textType)?.replace(/^<system-reminder>\nToday: [^\n]+\n<\/system-reminder>(?:\n|$)/, "");
37426
37539
  if (text === "" && Array.isArray(first.content))
37427
37540
  text = firstText(first.content.slice(1, 2), request.textType);
37428
- return text?.startsWith(`### Session update
37429
-
37430
- `) === true;
37541
+ return text?.startsWith(SESSION_UPDATE) === true || text?.startsWith(COMPACTION_SUMMARY) === true;
37431
37542
  }
37432
37543
  function isOmpUnmanagedCaptureRequest(payload) {
37433
37544
  return isOmpLegacyCaptureRequest(payload) || isOmpAutolearnCapture(payload);
@@ -43345,6 +43456,20 @@ function piFitMessageBytes(raw) {
43345
43456
  const bytes = Buffer.byteLength(JSON.stringify(content ? { ...message, content } : raw));
43346
43457
  return bytes + (opaque ? 4 * opaqueThinkingCost(message.usage?.reasoning, message.usage?.output).tokens : 0);
43347
43458
  }
43459
+ function piFitMessageBytesPricingImages(raw, bytesPerImage = PI_IMAGE_TOKENS) {
43460
+ const message = raw;
43461
+ if (!Array.isArray(message?.content) || !message.content.some((part) => part && typeof part === "object" && part.type === "image"))
43462
+ return piFitMessageBytes(raw);
43463
+ let images = 0;
43464
+ const content = message.content.map((part) => {
43465
+ if (!part || typeof part !== "object" || part.type !== "image")
43466
+ return part;
43467
+ images += 1;
43468
+ const { data: _data, ...rest } = part;
43469
+ return rest;
43470
+ });
43471
+ return piFitMessageBytes({ ...message, content }) + images * bytesPerImage;
43472
+ }
43348
43473
  function tokenCacheFingerprintsEqual(left, right) {
43349
43474
  if (left.length !== right.length)
43350
43475
  return false;
@@ -43453,9 +43578,19 @@ function estimatePiOutgoingInputTokens(messages, observed, measuredPrefix, conte
43453
43578
  if (!knownRole(message))
43454
43579
  return false;
43455
43580
  const m = message;
43456
- return typeof m.content === "string" || Array.isArray(m.content) && m.content.every((p) => p && typeof p === "object" && ["text", "thinking", "redacted_thinking", "toolCall"].includes(String(p.type)));
43581
+ return typeof m.content === "string" || Array.isArray(m.content) && m.content.every((p) => p && typeof p === "object" && [
43582
+ "text",
43583
+ "thinking",
43584
+ "redacted_thinking",
43585
+ "toolCall",
43586
+ "image"
43587
+ ].includes(String(p.type)));
43457
43588
  };
43458
43589
  const complete = messages.every(countable);
43590
+ const hasImages = messages.some((message) => {
43591
+ const content = message?.content;
43592
+ return Array.isArray(content) && content.some((part) => part && typeof part === "object" && part.type === "image");
43593
+ });
43459
43594
  const measuredForBounds = measuredPrefix && measuredPrefix.modelKey === observed.modelKey && observed.envelopeSignature && measuredPrefix.envelopeSignature === observed.envelopeSignature && Number.isSafeInteger(measuredPrefix.inputTokens) && measuredPrefix.inputTokens > 0 ? measuredPrefix : undefined;
43460
43595
  if (contextLimit && Number.isFinite(contextLimit) && contextLimit > 0) {
43461
43596
  const priced = measuredForBounds?.appendedMessages ?? messages;
@@ -43496,7 +43631,7 @@ function estimatePiOutgoingInputTokens(messages, observed, measuredPrefix, conte
43496
43631
  tools: observed.toolDefinitionTokens
43497
43632
  }, observed.calibration ?? calibrationForModelKey(observed.modelKey), true);
43498
43633
  const fit = observed.calibration ?? calibrationForModelKey(observed.modelKey);
43499
- const upper = envelope + Math.max(UNKNOWN_FIT_RATIO, fit.toolsRatio, fit.proseRatio) * priced.reduce((sum, message) => sum + piFitMessageBytes(message), 0);
43634
+ const upper = envelope + Math.max(UNKNOWN_FIT_RATIO, fit.toolsRatio, fit.proseRatio) * priced.reduce((sum, message) => sum + piFitMessageBytesPricingImages(message), 0);
43500
43635
  if (upper <= contextLimit)
43501
43636
  return {
43502
43637
  tokens: upper,
@@ -43509,7 +43644,7 @@ function estimatePiOutgoingInputTokens(messages, observed, measuredPrefix, conte
43509
43644
  return {
43510
43645
  tokens: providerMass({
43511
43646
  system: observed.systemTokens,
43512
- tools: observed.toolDefinitionTokens + messages.reduce((sum, message) => sum + piFitMessageBytes(message), 0)
43647
+ tools: observed.toolDefinitionTokens + messages.reduce((sum, message) => sum + piFitMessageBytesPricingImages(message), 0)
43513
43648
  }, observed.calibration ?? calibrationForModelKey(observed.modelKey), true),
43514
43649
  trusted: true,
43515
43650
  refusalGrade: false
@@ -43530,7 +43665,7 @@ function estimatePiOutgoingInputTokens(messages, observed, measuredPrefix, conte
43530
43665
  return {
43531
43666
  tokens: providerMass({
43532
43667
  system: observed.systemTokens,
43533
- tools: observed.toolDefinitionTokens + messages.reduce((sum, message) => sum + piFitMessageBytes(message), 0)
43668
+ tools: observed.toolDefinitionTokens + messages.reduce((sum, message) => sum + piFitMessageBytesPricingImages(message), 0)
43534
43669
  }, observed.calibration ?? calibrationForModelKey(observed.modelKey), true),
43535
43670
  trusted: true,
43536
43671
  refusalGrade: false,
@@ -43544,7 +43679,7 @@ function estimatePiOutgoingInputTokens(messages, observed, measuredPrefix, conte
43544
43679
  tools: observed.toolDefinitionTokens + raw.toolCall,
43545
43680
  prose: raw.conversation
43546
43681
  }, calibration, true);
43547
- const refusalGrade = Number.isFinite(tokens) && messages.every((rawMessage) => {
43682
+ const refusalGrade = Number.isFinite(tokens) && !hasImages && messages.every((rawMessage) => {
43548
43683
  const content = rawMessage.content;
43549
43684
  if (typeof content === "string")
43550
43685
  return !tokenCountUsesByteBound(content);
@@ -43583,7 +43718,7 @@ function assertPiRawFallbackFits(messages, contextLimit, log, cause, observed, m
43583
43718
  let serializationFailed = false;
43584
43719
  try {
43585
43720
  for (const message of pricedMessages) {
43586
- bytes += piFitMessageBytes(message) + 1;
43721
+ bytes += piFitMessageBytesPricingImages(message, 4 * PI_IMAGE_TOKENS) + 1;
43587
43722
  if (baseInputTokens + Math.ceil(bytes / 4) > contextLimit)
43588
43723
  break;
43589
43724
  }
@@ -43599,7 +43734,13 @@ function assertPiRawFallbackFits(messages, contextLimit, log, cause, observed, m
43599
43734
  if (!message || typeof message !== "object")
43600
43735
  return false;
43601
43736
  const m = message;
43602
- return ["user", "assistant", "toolResult", "custom"].includes(m.role ?? "") && (typeof m.content === "string" || Array.isArray(m.content) && m.content.every((p) => p !== null && typeof p === "object" && ["text", "thinking", "redacted_thinking", "toolCall"].includes(String(p.type))));
43737
+ return ["user", "assistant", "toolResult", "custom"].includes(m.role ?? "") && (typeof m.content === "string" || Array.isArray(m.content) && m.content.every((p) => p !== null && typeof p === "object" && [
43738
+ "text",
43739
+ "thinking",
43740
+ "redacted_thinking",
43741
+ "toolCall",
43742
+ "image"
43743
+ ].includes(String(p.type))));
43603
43744
  });
43604
43745
  const raw = tokenizePiMessages([...pricedMessages]);
43605
43746
  if (!hasTokenizerForFit()) {
@@ -43611,9 +43752,17 @@ function assertPiRawFallbackFits(messages, contextLimit, log, cause, observed, m
43611
43752
  tools: (measured ? 0 : observed.toolDefinitionTokens) + raw.toolCall,
43612
43753
  prose: raw.conversation
43613
43754
  }, observed.calibration ?? calibrationForModelKey(observed.modelKey), true);
43614
- if (!complete || !Number.isFinite(tokens) || tokens <= 0 || tokens > contextLimit || serializationFailed || proxyTokens > contextLimit) {
43615
- log(`raw_fallback_over_context_limit proxy_bytes=${bytes} proxy_tokens=${proxyTokens} limit=${contextLimit} early_abort=true serialization_failed=${serializationFailed}`);
43616
- throw piFallbackRefusal(complete ? "fallback-over-context-limit" : "fallback-messages-incomplete", cause);
43755
+ if (!complete) {
43756
+ log("raw_fallback_refused completeness=partial messages=unpriceable");
43757
+ throw piFallbackRefusal("fallback-messages-incomplete", cause);
43758
+ }
43759
+ if (!Number.isFinite(tokens) || tokens <= 0) {
43760
+ log(`raw_fallback_refused count=unusable tokens=${tokens}`);
43761
+ throw piFallbackRefusal("fallback-over-context-limit", cause);
43762
+ }
43763
+ if (tokens > contextLimit) {
43764
+ log(`raw_fallback_over_context_limit tokens=${Math.ceil(tokens)} limit=${contextLimit} proxy_bytes=${bytes} proxy_tokens=${proxyTokens}`);
43765
+ throw piFallbackRefusal("fallback-over-context-limit", cause);
43617
43766
  }
43618
43767
  }
43619
43768
  function classifyPiOutgoingFit(estimate, limit) {
@@ -45215,6 +45364,12 @@ function piRecoveryFitCalibration(calibration) {
45215
45364
  return calibration.seeded ? calibration : { toolsRatio: UNKNOWN_FIT_RATIO, proseRatio: UNKNOWN_FIT_RATIO };
45216
45365
  }
45217
45366
  function piRecoveryToolImageTokens(messages) {
45367
+ return piToolResultImageTokens(messages, (part) => estimateTokens(JSON.stringify(part)));
45368
+ }
45369
+ function piToolImageCostTokens(messages) {
45370
+ return piToolResultImageTokens(messages, () => PI_IMAGE_TOKENS);
45371
+ }
45372
+ function piToolResultImageTokens(messages, priceImage) {
45218
45373
  const counts = new Map;
45219
45374
  const seen = new Set;
45220
45375
  for (const value of messages) {
@@ -45228,7 +45383,7 @@ function piRecoveryToolImageTokens(messages) {
45228
45383
  seen.add(message.toolCallId);
45229
45384
  for (const part of message.content) {
45230
45385
  if (part?.type === "image")
45231
- counts.set(message.toolCallId, (counts.get(message.toolCallId) ?? 0) + estimateTokens(JSON.stringify(part)));
45386
+ counts.set(message.toolCallId, (counts.get(message.toolCallId) ?? 0) + priceImage(part));
45232
45387
  }
45233
45388
  }
45234
45389
  return counts;
@@ -45329,6 +45484,8 @@ function extractAssistantUsage(message) {
45329
45484
  result.cacheWrite = u.cacheWrite;
45330
45485
  if (typeof u.totalTokens === "number")
45331
45486
  result.totalTokens = u.totalTokens;
45487
+ if (typeof u.contextTokens === "number")
45488
+ result.contextTokens = u.contextTokens;
45332
45489
  return result;
45333
45490
  }
45334
45491
  function computePiPressure(usage, contextLimit, absoluteWall) {
@@ -45347,9 +45504,12 @@ function piUsageInputTokens(usage) {
45347
45504
  const componentPromptTokens = input + cacheRead + cacheWrite;
45348
45505
  const totalPromptTokens = typeof usage.totalTokens === "number" && Number.isFinite(usage.totalTokens) && typeof usage.output === "number" && Number.isFinite(usage.output) ? Math.max(0, usage.totalTokens - usage.output) : undefined;
45349
45506
  const inputTokens = totalPromptTokens !== undefined && totalPromptTokens > 0 ? Math.min(componentPromptTokens, totalPromptTokens) : componentPromptTokens;
45350
- if (inputTokens <= 0 || !Number.isFinite(inputTokens))
45351
- return null;
45352
- return inputTokens;
45507
+ if (inputTokens > 0 && Number.isFinite(inputTokens))
45508
+ return inputTokens;
45509
+ return positiveContextTokens(usage.contextTokens);
45510
+ }
45511
+ function positiveContextTokens(value) {
45512
+ return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : null;
45353
45513
  }
45354
45514
  function resolvePiPressureSnapshot(args) {
45355
45515
  const persistedInputTokens = Number.isFinite(args.persistedInputTokens) && args.persistedInputTokens > 0 ? args.persistedInputTokens : 0;
@@ -45380,7 +45540,7 @@ function entryUsageTokens(usage) {
45380
45540
  return 0;
45381
45541
  const u = usage;
45382
45542
  const n = (value) => typeof value === "number" && Number.isFinite(value) ? value : 0;
45383
- return n(u.totalTokens) || n(u.input) + n(u.output) + n(u.cacheRead) + n(u.cacheWrite);
45543
+ return n(u.totalTokens) || n(u.input) + n(u.output) + n(u.cacheRead) + n(u.cacheWrite) || (positiveContextTokens(u.contextTokens) ?? 0);
45384
45544
  }
45385
45545
  function isPiLiveUsageRawBranchEstimate(branchEntries) {
45386
45546
  if (!branchEntries)
@@ -45981,6 +46141,22 @@ function reportBindingRecovery(sessionId, report, message) {
45981
46141
  else
45982
46142
  log2(`[magic-context][${sessionId}] ${message}`);
45983
46143
  }
46144
+ function armPiProviderOverflowRecovery(args) {
46145
+ recordOverflowDetected(args.db, args.sessionId, args.reportedLimit, args.modelKey, "provider_overflow", args.reportedLimitProvenance, args.reportedInputTokens);
46146
+ if (getHarness2() === "pi") {
46147
+ try {
46148
+ resetPiUpperEstimateReclaim(args.db, args.sessionId);
46149
+ } catch (error) {
46150
+ args.report?.(`upper-estimate reclaim reset deferred: ${String(error)}`);
46151
+ }
46152
+ }
46153
+ }
46154
+ function armPiRecoveryForHostOverflowCompaction(args) {
46155
+ if (getOverflowState(args.db, args.sessionId).needsEmergencyRecovery)
46156
+ return "already-armed";
46157
+ armPiProviderOverflowRecovery(args);
46158
+ return "armed";
46159
+ }
45984
46160
  function handlePiProviderFailure(args) {
45985
46161
  if (!args.message || typeof args.message !== "object")
45986
46162
  return { kind: "none" };
@@ -46010,19 +46186,21 @@ function handlePiProviderFailure(args) {
46010
46186
  if (args.compactionOff)
46011
46187
  return { kind: "none" };
46012
46188
  const overflow = detectOverflow(message.errorMessage);
46013
- if (!overflow.isOverflow)
46189
+ const hostOnly = !overflow.isOverflow && args.hostOverflowCheck?.(args.message) === true;
46190
+ if (!overflow.isOverflow && !hostOnly)
46014
46191
  return { kind: "none" };
46015
- const modelKey = provider && model ? `${provider}/${model}` : undefined;
46016
- recordOverflowDetected(args.db, args.sessionId, overflow.reportedLimit, modelKey, "provider_overflow", overflow.reportedLimitProvenance, overflow.reportedInputTokens);
46017
- if (getHarness2() === "pi") {
46018
- try {
46019
- resetPiUpperEstimateReclaim(args.db, args.sessionId);
46020
- } catch (error) {
46021
- args.report?.(`upper-estimate reclaim reset deferred: ${String(error)}`);
46022
- }
46023
- }
46192
+ armPiProviderOverflowRecovery({
46193
+ db: args.db,
46194
+ sessionId: args.sessionId,
46195
+ modelKey: provider && model ? `${provider}/${model}` : undefined,
46196
+ reportedLimit: overflow.reportedLimit,
46197
+ reportedLimitProvenance: overflow.reportedLimitProvenance,
46198
+ reportedInputTokens: overflow.reportedInputTokens,
46199
+ report: args.report
46200
+ });
46024
46201
  return {
46025
46202
  kind: "overflow",
46203
+ source: hostOnly ? "host" : "magic-context",
46026
46204
  ...overflow.reportedLimit !== undefined ? { reportedLimit: overflow.reportedLimit } : {},
46027
46205
  ...overflow.reportedLimitProvenance !== undefined ? { reportedLimitProvenance: overflow.reportedLimitProvenance } : {},
46028
46206
  ...overflow.matchedPattern !== undefined ? { matchedPattern: overflow.matchedPattern } : {}
@@ -49710,6 +49888,7 @@ function registerPiContextHandler(pi, baseOptions) {
49710
49888
  return;
49711
49889
  }
49712
49890
  sessionIdForError = sessionId;
49891
+ resetPiUnplacedCutLog(sessionId);
49713
49892
  try {
49714
49893
  const effectiveSystem = readHostSystemPrompt(ctx);
49715
49894
  if (effectiveSystem !== undefined)
@@ -52746,7 +52925,8 @@ async function runPipeline(args) {
52746
52925
  const emergencyPlannerMayRun = shouldRunHeuristics && args.heuristics !== undefined && args.forceMaterialization === true && args.emergencyCeilingTokens !== undefined && args.emergencyCeilingTokens > 0;
52747
52926
  const tagsNewerThanReading = emergencyPlannerMayRun ? tagsSinceReading(transcript.messages, newTargets) : undefined;
52748
52927
  const queuedDropTags = new Set(pendingOps.map((op) => op.tagId));
52749
- const emergencyServedBeforeDrain = emergencyPlannerMayRun && shouldApplyPendingOps && queuedDropTags.size > 0 ? snapshotPiEmergencyServedMass(getPiActiveTagSnapshotView(args.db, args.sessionId).filter((tag) => queuedDropTags.has(tag.tagNumber) && !tagsNewerThanReading?.has(tag.tagNumber)), newTargets, args.providerOverflowRecovery === true ? piRecoveryToolImageTokens(workingMessages) : undefined) : undefined;
52928
+ const emergencyToolImageTokens = () => args.providerOverflowRecovery === true ? piRecoveryToolImageTokens(workingMessages) : piToolImageCostTokens(workingMessages);
52929
+ const emergencyServedBeforeDrain = emergencyPlannerMayRun && shouldApplyPendingOps && queuedDropTags.size > 0 ? snapshotPiEmergencyServedMass(getPiActiveTagSnapshotView(args.db, args.sessionId).filter((tag) => queuedDropTags.has(tag.tagNumber) && !tagsNewerThanReading?.has(tag.tagNumber)), newTargets, emergencyToolImageTokens()) : undefined;
52750
52930
  mutationGateObserverForTests?.({
52751
52931
  foldDue: foldDueDecision.value,
52752
52932
  foldExecuted: foldExecutedThisPass,
@@ -52904,7 +53084,7 @@ async function runPipeline(args) {
52904
53084
  ceilingTokens: args.emergencyCeilingTokens,
52905
53085
  usagePercentage: args.contextUsage.percentage,
52906
53086
  passAlreadyPriced: independentMutationBeforeHeuristics,
52907
- serializedImageTokens: providerOverflow ? piRecoveryToolImageTokens(workingMessages) : undefined,
53087
+ toolImageTokens: emergencyToolImageTokens(),
52908
53088
  fitCalibration: providerOverflow ? piRecoveryFitCalibration(recoveryCalibration) : undefined,
52909
53089
  servedBeforePass: emergencyServedBeforeDrain,
52910
53090
  sinceReading: tagsNewerThanReading
@@ -53289,7 +53469,12 @@ async function runPipeline(args) {
53289
53469
  logTransformTiming(args.sessionId, "prepareCompartmentInjection", tInjection);
53290
53470
  logTransformTiming(args.sessionId, "compartmentPhase", tInjection);
53291
53471
  } catch (err) {
53292
- sessionLog2(args.sessionId, `compartment injection failed (continuing): ${err instanceof Error ? err.message : String(err)}`);
53472
+ sessionLog2(args.sessionId, `compartment injection failed; replaying the last good request or refusing the turn: ${err instanceof Error ? err.message : String(err)}`);
53473
+ if (isTransientPiStorageError(err))
53474
+ throw err;
53475
+ throw new PiDegradedPassError("m0-m1-injection-degradation", {
53476
+ cause: err
53477
+ });
53293
53478
  }
53294
53479
  }
53295
53480
  transcript.finalizeToolRemovals();
@@ -53829,6 +54014,7 @@ function clearContextHandlerSession(sessionId) {
53829
54014
  clearPiCompactionMarkerDrainLogState(sessionId);
53830
54015
  clearPiInjectionTokenCountCache(sessionId);
53831
54016
  clearPiMuralProcessCache(sessionId);
54017
+ resetPiUnplacedCutLog(sessionId);
53832
54018
  clearPiTailHygieneContentMemo();
53833
54019
  clearPiChannel1State(sessionId);
53834
54020
  lastHeuristicsTurnIdBySession.delete(sessionId);
@@ -56877,6 +57063,38 @@ function registerPiFailClosedSurface(pi, args) {
56877
57063
  };
56878
57064
  }
56879
57065
 
57066
+ // src/host-overflow-check-pi.ts
57067
+ var HOST_PI_AI_MODULE = "@earendil-works/pi-ai";
57068
+ var importHostModule = () => import("@earendil-works/pi-ai");
57069
+ var loadHostModule = importHostModule;
57070
+ var hostCheck;
57071
+ function loadPiHostOverflowCheck() {
57072
+ hostCheck ??= resolveHostOverflowCheck();
57073
+ return hostCheck;
57074
+ }
57075
+ async function resolveHostOverflowCheck() {
57076
+ let module;
57077
+ try {
57078
+ module = await loadHostModule();
57079
+ } catch (error) {
57080
+ log2(`[magic-context] host overflow check unavailable: ${HOST_PI_AI_MODULE} did not load (${error instanceof Error ? error.message : String(error)}); using Magic Context's overflow patterns only`);
57081
+ return;
57082
+ }
57083
+ const check = module?.isContextOverflow;
57084
+ if (typeof check !== "function") {
57085
+ log2(`[magic-context] host overflow check unavailable: ${HOST_PI_AI_MODULE} has no isContextOverflow export; using Magic Context's overflow patterns only`);
57086
+ return;
57087
+ }
57088
+ log2(`[magic-context] host overflow check: using isContextOverflow from ${HOST_PI_AI_MODULE}`);
57089
+ return (message) => {
57090
+ try {
57091
+ return check(message) === true;
57092
+ } catch {
57093
+ return false;
57094
+ }
57095
+ };
57096
+ }
57097
+
56880
57098
  // src/message-end-index-pi.ts
56881
57099
  var unpersistedMessageSeq = 0;
56882
57100
  function findEntryIdForMessage(branch, message) {
@@ -57360,6 +57578,23 @@ function signalPiDeferredCompactionMarkerDrain(sessionId) {
57360
57578
  }
57361
57579
  async function handlePiSessionBeforeCompact(args) {
57362
57580
  if (!args.compactionOff) {
57581
+ if (args.event?.reason === "overflow" && args.event.willRetry === true) {
57582
+ try {
57583
+ const sessionId = args.ctx.sessionManager?.getSessionId?.();
57584
+ if (typeof sessionId === "string" && sessionId.length > 0) {
57585
+ const provider = args.ctx.model?.provider;
57586
+ const model = args.ctx.model?.id;
57587
+ const outcome = armPiRecoveryForHostOverflowCompaction({
57588
+ db: args.db,
57589
+ sessionId,
57590
+ modelKey: typeof provider === "string" && typeof model === "string" ? `${provider}/${model}` : undefined
57591
+ });
57592
+ info(`session_before_compact: host compacting for overflow; provider-overflow recovery ${outcome}`);
57593
+ }
57594
+ } catch (err) {
57595
+ warn("session_before_compact: overflow recovery arm failed:", err);
57596
+ }
57597
+ }
57363
57598
  info("session_before_compact: cancelling — magic-context owns compaction");
57364
57599
  return { cancel: true };
57365
57600
  }
@@ -58695,7 +58930,7 @@ async function startPiMagicContextRuntime(pi, database, dbPath) {
58695
58930
  log2(`tool_result hook failed (continuing): ${err instanceof Error ? err.message : String(err)}`);
58696
58931
  }
58697
58932
  });
58698
- pi.on("session_before_compact", async (_event, ctx) => handlePiSessionBeforeCompact({ db, compactionOff, ctx }));
58933
+ pi.on("session_before_compact", async (event, ctx) => handlePiSessionBeforeCompact({ db, compactionOff, ctx, event }));
58699
58934
  if (PI_HARNESS_KIND !== "omp") {
58700
58935
  registerStreamTagPrefixStrip(pi, () => !compactionOff);
58701
58936
  } else {
@@ -58787,14 +59022,17 @@ async function startPiMagicContextRuntime(pi, database, dbPath) {
58787
59022
  const sessionId = sm?.getSessionId?.();
58788
59023
  if (typeof sessionId !== "string" || sessionId.length === 0)
58789
59024
  return;
59025
+ const failed = event.message;
59026
+ const hostOverflowCheck = !compactionOff && failed?.role === "assistant" && typeof failed.errorMessage === "string" && failed.errorMessage.length > 0 ? await loadPiHostOverflowCheck() : undefined;
58790
59027
  const recovery = handlePiProviderFailure({
58791
59028
  db,
58792
59029
  sessionId,
58793
59030
  message: event.message,
58794
- compactionOff
59031
+ compactionOff,
59032
+ hostOverflowCheck
58795
59033
  });
58796
59034
  if (recovery.kind === "overflow") {
58797
- log2(`[magic-context][${sessionId}] overflow detected: reportedLimit=${recovery.reportedLimit ?? "?"} provenance=${recovery.reportedLimitProvenance ?? "?"} pattern=${recovery.matchedPattern ?? "?"}`);
59035
+ log2(`[magic-context][${sessionId}] overflow detected: source=${recovery.source} reportedLimit=${recovery.reportedLimit ?? "?"} provenance=${recovery.reportedLimitProvenance ?? "?"} pattern=${recovery.matchedPattern ?? "?"}`);
58798
59036
  }
58799
59037
  } catch (err) {
58800
59038
  warn("message_end: provider failure classification failed:", err);
@@ -34,7 +34,7 @@ import {
34
34
  resolvePiHarnessKind,
35
35
  reportSubagentStartupError,
36
36
  registerMagicContextTools
37
- } from "./index-2tk7e0bx.js";
37
+ } from "./index-418za765.js";
38
38
  import"./index-vcegxfwg.js";
39
39
  import"./index-5rcjs14a.js";
40
40
  import"./index-cxczethe.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/pi-magic-context",
3
- "version": "0.49.59",
3
+ "version": "0.49.61",
4
4
  "type": "module",
5
5
  "description": "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
6
6
  "main": "dist/index.js",
@@ -29,7 +29,7 @@
29
29
  ],
30
30
  "//": "The build intentionally bundles typebox (no --external typebox) and keeps it a regular dependency. OMP's extension loader rewrites every bare `typebox` import to its own omptype-based shim, whose schemas are callable objects rather than JSON Schema; they fail structuredClone during tool registration, so an external typebox import stops Magic Context loading on OMP. src/typebox-bundling.test.ts guards this.",
31
31
  "scripts": {
32
- "build": "bun ../../scripts/check-bun.mjs && tsc -p ../retina-local-fs/tsconfig.build.json && bun ../../scripts/clean-dist-chunks.mjs dist index.js subagent-entry.js historian-calibration-extension.js embedding-worker-process.js raw-ordinal-warmup-worker.js tag-snapshot-worker-pi.js transformers-web.js transformers-node-wasm.js && bun build ../plugin/src/features/magic-context/memory/transformers-web-entry.ts --outfile dist/transformers-web.js --target browser --format esm --external onnxruntime-web && bun ../plugin/scripts/build-transformers-node-wasm.ts dist && bun build src/index.ts src/tag-snapshot-worker-pi.ts src/subagent-entry.ts src/historian-calibration-extension.ts ../plugin/src/features/magic-context/memory/embedding-worker.ts ../plugin/src/features/magic-context/memory/embedding-worker-process.ts ../plugin/src/features/magic-context/migration-worker.ts ../plugin/src/hooks/magic-context/auto-search-worker.ts ../plugin/src/hooks/magic-context/raw-ordinal-warmup-worker.ts ../plugin/src/features/magic-context/compaction-marker-candidates-worker.ts ../plugin/src/features/magic-context/chunk-embedding-write-worker.ts --outdir dist --entry-naming '[name].[ext]' --target node --format esm --splitting --external @earendil-works/pi-coding-agent --external @oh-my-pi/pi-coding-agent --external @earendil-works/pi-tui --external onnxruntime-node --external onnxruntime-web --external sharp --external bun:ffi --external node:sqlite",
32
+ "build": "bun ../../scripts/check-bun.mjs && tsc -p ../retina-local-fs/tsconfig.build.json && bun ../../scripts/clean-dist-chunks.mjs dist index.js subagent-entry.js historian-calibration-extension.js embedding-worker-process.js raw-ordinal-warmup-worker.js tag-snapshot-worker-pi.js transformers-web.js transformers-node-wasm.js && bun build ../plugin/src/features/magic-context/memory/transformers-web-entry.ts --outfile dist/transformers-web.js --target browser --format esm --external onnxruntime-web && bun ../plugin/scripts/build-transformers-node-wasm.ts dist && bun build src/index.ts src/tag-snapshot-worker-pi.ts src/subagent-entry.ts src/historian-calibration-extension.ts ../plugin/src/features/magic-context/memory/embedding-worker.ts ../plugin/src/features/magic-context/memory/embedding-worker-process.ts ../plugin/src/features/magic-context/migration-worker.ts ../plugin/src/hooks/magic-context/auto-search-worker.ts ../plugin/src/hooks/magic-context/raw-ordinal-warmup-worker.ts ../plugin/src/features/magic-context/compaction-marker-candidates-worker.ts ../plugin/src/features/magic-context/chunk-embedding-write-worker.ts --outdir dist --entry-naming '[name].[ext]' --target node --format esm --splitting --external @earendil-works/pi-coding-agent --external @oh-my-pi/pi-coding-agent --external @earendil-works/pi-tui --external @earendil-works/pi-ai --external onnxruntime-node --external onnxruntime-web --external sharp --external bun:ffi --external node:sqlite",
33
33
  "build:e2e-argv": "bun ../../scripts/clean-dist-chunks.mjs ../../tests/docker/.generated subagent-runner-e2e.mjs && bun build src/subagent-runner.ts --outdir ../../tests/docker/.generated --entry-naming 'subagent-runner-e2e.mjs' --splitting --target node --format esm --external node:sqlite && node --input-type=module -e 'const { __test } = await import(\"../../tests/docker/.generated/subagent-runner-e2e.mjs\"); if (typeof __test.buildArgs !== \"function\" || typeof __test.resolvePiInvocation !== \"function\") throw new Error(\"argv renderer exports missing\"); console.log(\"Node argv renderer: 2 exports loaded\")'",
34
34
  "typecheck": "tsc -p ../retina-local-fs/tsconfig.build.json && tsc --noEmit",
35
35
  "test": "bun ../../scripts/check-bun.mjs && bun install --frozen-lockfile && MC_SLOW_TESTS=0 BUN_JSC_useOMGJIT=0 bun test --parallel=4 --timeout 30000",
@@ -69,6 +69,7 @@
69
69
  "omp-coding-agent-18132": "npm:@oh-my-pi/pi-coding-agent@18.13.2",
70
70
  "omp-coding-agent-18186": "npm:@oh-my-pi/pi-coding-agent@18.18.6",
71
71
  "omp-coding-agent-18190": "npm:@oh-my-pi/pi-coding-agent@18.19.0",
72
+ "omp-coding-agent-18220": "npm:@oh-my-pi/pi-coding-agent@18.22.0",
72
73
  "omp-pi-ai-171": "npm:@oh-my-pi/pi-ai@17.1.7",
73
74
  "omp-pi-ai-1889": "npm:@oh-my-pi/pi-ai@18.8.9",
74
75
  "omp-pi-ai-1811": "npm:@oh-my-pi/pi-ai@18.11.3",