@cortexkit/pi-magic-context 0.49.21 → 0.49.23

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.
@@ -7,7 +7,7 @@ import {
7
7
  ceilProviderOutputTokens2,
8
8
  withoutProviderTemperature2,
9
9
  historianCalibrationExtension
10
- } from "./index-fa485mqs.js";
10
+ } from "./index-0b5kqg7n.js";
11
11
  import"./index-4knyh1kt.js";
12
12
  import"./index-6x556c2q.js";
13
13
  import"./index-fgs78jyd.js";
@@ -404,6 +404,41 @@ class SubagentTelemetry {
404
404
  }
405
405
  }
406
406
 
407
+ // src/subagent-tool-boundary.ts
408
+ var SUBAGENT_TOOL_ALLOWLIST_FLAG = "magic-context-tool-allowlist";
409
+ var OMP_CHILD_TOOL_CONFIG = `tools:
410
+ xdev: false
411
+ plan:
412
+ enabled: false
413
+ defaultOnStartup: false
414
+ `;
415
+ function registerSubagentToolBoundary(pi) {
416
+ pi.registerFlag(SUBAGENT_TOOL_ALLOWLIST_FLAG, {
417
+ description: "Exact active tool names for a Magic Context hidden child.",
418
+ type: "string"
419
+ });
420
+ pi.on("session_start", async () => {
421
+ const value = pi.getFlag(SUBAGENT_TOOL_ALLOWLIST_FLAG);
422
+ if (value === undefined)
423
+ return;
424
+ try {
425
+ const names = typeof value === "string" ? JSON.parse(value) : null;
426
+ if (!Array.isArray(names) || !names.every((name) => typeof name === "string")) {
427
+ throw new Error("Invalid Magic Context child tool allowlist");
428
+ }
429
+ await pi.setActiveTools(names);
430
+ const allowed = new Set(names);
431
+ if (pi.getActiveTools().some((name) => !allowed.has(name))) {
432
+ throw new Error("Host activated tools outside the Magic Context child allowlist");
433
+ }
434
+ } catch (error) {
435
+ process.stderr.write(`Magic Context child tool restriction failed: ${String(error)}
436
+ `);
437
+ process.exit(1);
438
+ }
439
+ });
440
+ }
441
+
407
442
  // src/historian-calibration-extension.ts
408
443
  var HISTORIAN_TEMPERATURE_ENV2 = "MAGIC_CONTEXT_HISTORIAN_TEMPERATURE";
409
444
  var HISTORIAN_CACHE_TAIL_ENV2 = "MAGIC_CONTEXT_HISTORIAN_CACHE_TAIL";
@@ -517,6 +552,7 @@ function withoutProviderTemperature2(payload) {
517
552
  return clean;
518
553
  }
519
554
  function historianCalibrationExtension(pi) {
555
+ registerSubagentToolBoundary(pi);
520
556
  if (process.env[HISTORIAN_CACHE_TAIL_ENV2] === "skip") {
521
557
  let requests = 0;
522
558
  let warned = false;
@@ -577,4 +613,4 @@ function historianCalibrationExtension(pi) {
577
613
  });
578
614
  }
579
615
 
580
- export { DREAMER_PRIMER_INVESTIGATOR_ALLOWED_TOOLS, buildHiddenAgentRegistrations, logTemperatureDecision, readHostSystemPrompt, subagentStepCap, SubagentTelemetry, HISTORIAN_TEMPERATURE_ENV2, HISTORIAN_CACHE_TAIL_ENV2, HISTORIAN_MAX_OUTPUT_TOKENS_ENV2, SUBAGENT_OUTPUT_CEILING_ENV2, calibrateHistorianProviderPayload2, ceilProviderOutputTokens2, withoutProviderTemperature2, historianCalibrationExtension };
616
+ export { DREAMER_PRIMER_INVESTIGATOR_ALLOWED_TOOLS, buildHiddenAgentRegistrations, logTemperatureDecision, readHostSystemPrompt, subagentStepCap, SubagentTelemetry, OMP_CHILD_TOOL_CONFIG, HISTORIAN_TEMPERATURE_ENV2, HISTORIAN_CACHE_TAIL_ENV2, HISTORIAN_MAX_OUTPUT_TOKENS_ENV2, SUBAGENT_OUTPUT_CEILING_ENV2, calibrateHistorianProviderPayload2, ceilProviderOutputTokens2, withoutProviderTemperature2, historianCalibrationExtension };
@@ -10006,6 +10006,24 @@ async function ensureProjectRegisteredFromPiDirectory(directory, db, options = {
10006
10006
  }
10007
10007
  }
10008
10008
 
10009
+ // src/omp-mentions.ts
10010
+ function neutralizeOmpMentions(text) {
10011
+ return text.replace(/(^|[\s([{<"'`])@/g, "$1⁠@");
10012
+ }
10013
+ function restoreOmpMentions(value) {
10014
+ if (typeof value === "string")
10015
+ return value.replaceAll("⁠@", "@");
10016
+ if (Array.isArray(value))
10017
+ return value.map(restoreOmpMentions);
10018
+ if (value !== null && typeof value === "object") {
10019
+ return Object.fromEntries(Object.entries(value).map(([key, entry]) => [
10020
+ key,
10021
+ restoreOmpMentions(entry)
10022
+ ]));
10023
+ }
10024
+ return value;
10025
+ }
10026
+
10009
10027
  // src/pi-harness-kind.ts
10010
10028
  import { existsSync as existsSync8, readFileSync as readFileSync8, realpathSync as realpathSync2 } from "node:fs";
10011
10029
  import { dirname as dirname5, join as join5, parse as parse2, resolve as resolve3 } from "node:path";
@@ -13565,12 +13583,18 @@ function registerMagicContextTools(pi, opts) {
13565
13583
  });
13566
13584
  const registration = promptSurfaceRuntime.resolveRegistration(opts.promptSurface);
13567
13585
  const smartNotesAvailable = opts.smartNotesEnabled !== false && opts.dreamerEnabled !== false;
13586
+ const restoreChildMentions = process.env.MAGIC_CONTEXT_PI_SUBAGENT === "1" && resolvePiHarnessKind() === "omp";
13568
13587
  const surfaceTool = (definition) => {
13569
13588
  const parameters = structuredClone(definition.parameters);
13570
13589
  applyJsonSchemaParameterDescriptions(definition.name, parameters, registration.preset, smartNotesAvailable ? opts.smartNotesEnabled : false);
13571
13590
  return setOmpEssentialLoadMode(throwReturnedToolErrors({
13572
13591
  ...definition,
13573
13592
  parameters,
13593
+ execute: (...args) => {
13594
+ if (restoreChildMentions)
13595
+ args[1] = restoreOmpMentions(args[1]);
13596
+ return definition.execute(...args);
13597
+ },
13574
13598
  description: definition.name === "ctx_note" && !smartNotesAvailable ? withoutSmartNoteText(registration.preset === "light" ? CTX_NOTE_LIGHT_DESCRIPTION : definition.description) : registration.descriptionFor(definition.name, definition.description)
13575
13599
  }));
13576
13600
  };
@@ -13625,4 +13649,4 @@ function registerMagicContextTools(pi, opts) {
13625
13649
  }
13626
13650
  }
13627
13651
 
13628
- export { COMPACTION_ENABLED_PATH, isDreamerRunnable, isCompactionEnabled, formatConfigParseStatusLine, formatConfigParseNotice, claimConfigParseFailuresOnce, parseJsoncRecovering, detectConfigFile, OPENCODE_OUTPUT_CAP, MIN_PLAUSIBLE_CONTEXT_LIMIT, catalogOutputReserve, deriveWindowGeometry, hasTrustedAbsoluteWall, applyProvenInputFloor, formatWindowDerivationLine, formatWindowSource, isSaneLimit, resolveOutputReserve, getSdkWindowGeometry, getSdkContextLimit, getSdkOutputLimit, getSdkInputLimit, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, migrateMagicContextConfigLocations, getProtectedTokensTierOverrides, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, cancelAutoSearchWork, readSessionMeta, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, isNoContentCompartment, HAS_COMPARTMENT_CONTENT_SQL, queueM0Mutation, getMaxM0MutationId, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getCompartmentsByEndMessageId, appendCompartments, saveRecompStagingPass, getRecompStaging, clearRecompStaging, getRecompPartialRange, setRecompPartialRange, escapeXmlAttr, escapeXmlContent, getUncoveredCompartmentEndThrough, isPartialCompartmentEnd, readProjectDocsCanonical, providerResponseFailed, isSuccessfulProviderCompletion, requestPendingMaterialization, pendingMaterializationOrigin, hasPendingMaterializationOrigin, clearPendingMaterialization, recordSystemRefreshOwnership, recordSystemPromptForRequest, recordHeldHeadForRequest, bindSystemPromptResponse, acknowledgeSystemPromptDelivery, deferDeliveredSystemRefresh, clearSystemPromptDelivery, saveLkgSlotToDb, loadPersistedLkgSlot, drainStaleLkgSlots, createDbLkgPersistence, replayLkg, registerLkgPersistence, LKG_SNAPSHOT_ARRAY, LKG_SNAPSHOT_OBJECT, LKG_SNAPSHOT_KEY, LKG_SNAPSHOT_STRING, LKG_SNAPSHOT_NUMBER, LKG_SNAPSHOT_BOOLEAN, LKG_SNAPSHOT_NULL, LKG_SNAPSHOT_UNDEFINED, contentSnapshotValue, signatureForFields, lkgContentFields, lkgContentDigestFromFields, isLegacyLkgDigest, legacyLkgDigestFromFields, lkgFieldsMatchDigest, exactReusablePrefix, incrementalLkgContentDigests, lkgSlotRejection, captureSlot, getInMemorySlot, getSlot, dropSlot, TOOL_SWEEP_SCOPED_MARKER, encodePiContentDecision, decodePiContentDecision, getPiContentDecisions, freezePiContentDecision, getNativeReplayState, saveNativeToolInputs, addNativeReasoningIds, copySessionStateForClone, externalHistorianFailureReason, subprocessExitHistorianFailureReason, countHistorianRuns, recordHistorianRun, summarizeImportance, tallyFactsByCategory, queueMemoryMutation, getMemoryMutationsForRender, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationId, getMaxMemoryMutationIdForProjects, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, getSourceContents, recordSubagentInvocation, getLatestHistorianInvocationId, noteTouchedAt, noteNudgePickIndex, formatNoteNudge, systemPromptFingerprint, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, SYNTH_USER_ID_PREFIX, resolvePiStableId, resolvePiRealStableId, isPiContentFallbackId, isPiIndexFallbackId, piContentFallbackIds, readPiSessionSnapshot, readPiSessionMessages, readPiSessionMessagePage, findRestartModelSeedFromBranch, iterateEntriesToRawMessageRange, iterateAsyncEntriesToRawMessageRange, convertEntriesToRawMessages, convertPiAssistantEntryById, convertEntriesToRawMessagePage, countPiRawMessages, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, getTaskScheduleState, getFailingDreamTasks, getSkippedDreamTasks, getMostRecentTaskRunAt, pruneNonCanonicalTaskRows, deleteTaskScheduleRowsForProject, seedTaskScheduleState, writeTaskScheduleState, isRetrospectiveWindowProcessed, recordRetrospectiveWindowProcessed, curateCategoryForMemoryCategory, peekCurateCategoryScope, beginCurateCategoryRun, curateTaskStateAfterSuccess, MEMORY_MURAL_BLOCK, buildMagicContextSection, resolveMuralWire, updateCompactionMarkerAfterPublication, COMPARTMENT_RENDER_EPOCH, MEMORY_RENDER_FORMAT_EPOCH, encodeCachedM0UpgradeIdentity, decodeCachedM0UpgradeIdentity, withCachedM0MemoryIds, readCachedM0MemoryIds, renderBudgetIdentityChanged, renderedBudgetSnapshot, renderedBudgetShrinkReason, DEFAULT_HISTORY_BUDGET_TOKENS, renderCompartmentAtTier, renderDecayedCompartments, extractM0Block, TEMPORAL_MARKER_PATTERN, TEMPORAL_MARKER_REPLAY_PATTERN, temporalMarkerPrefix, renderUserProfileContent, clearInjectionCache, getVisibleMemoryIds, orderHistorianMemories, renderHistorianMemoryBlock, DEFAULT_MEMORY_BUDGET_TOKENS, DEFAULT_USER_PROFILE_BUDGET_TOKENS, trimMemoriesToBudgetV2, trimWorkspaceMemoriesToBudgetV2, trimUserMemoriesToBudget, renderMemoryBlockV2, stripMemoryMuralBlock, resetPrefixTrimFallbackState, isDirectiveShapedProjectRule, takeCurateSafetyRefusalCount, wakePlaneStatus, loadPiConfig, loadPiConfigDetailed, unregisterPiProjectEmbeddings, ensureProjectRegisteredFromPiDirectory, resolvePiHarnessDetection, resolvePiHarnessKind, resolvePiOrdinalAlignment, piRawOrdinalOffsetSource, resolvePiOrdinalAlignmentForContext, isPiOrdinalAlignmentUnanchored, clearPiOrdinalAlignmentSession, rememberTodowriteToolCallTodos, parseTodos, setTodoSnapshot, registerTodoOverlay, registerTodoStateLifecycle, syncCtxMemoryToolEnabled, registerMagicContextTools };
13652
+ export { COMPACTION_ENABLED_PATH, isDreamerRunnable, isCompactionEnabled, formatConfigParseStatusLine, formatConfigParseNotice, claimConfigParseFailuresOnce, parseJsoncRecovering, detectConfigFile, OPENCODE_OUTPUT_CAP, MIN_PLAUSIBLE_CONTEXT_LIMIT, catalogOutputReserve, deriveWindowGeometry, hasTrustedAbsoluteWall, applyProvenInputFloor, formatWindowDerivationLine, formatWindowSource, isSaneLimit, resolveOutputReserve, getSdkWindowGeometry, getSdkContextLimit, getSdkOutputLimit, getSdkInputLimit, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, migrateMagicContextConfigLocations, getProtectedTokensTierOverrides, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, cancelAutoSearchWork, readSessionMeta, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, isNoContentCompartment, HAS_COMPARTMENT_CONTENT_SQL, queueM0Mutation, getMaxM0MutationId, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getCompartmentsByEndMessageId, appendCompartments, saveRecompStagingPass, getRecompStaging, clearRecompStaging, getRecompPartialRange, setRecompPartialRange, escapeXmlAttr, escapeXmlContent, getUncoveredCompartmentEndThrough, isPartialCompartmentEnd, readProjectDocsCanonical, providerResponseFailed, isSuccessfulProviderCompletion, requestPendingMaterialization, pendingMaterializationOrigin, hasPendingMaterializationOrigin, clearPendingMaterialization, recordSystemRefreshOwnership, recordSystemPromptForRequest, recordHeldHeadForRequest, bindSystemPromptResponse, acknowledgeSystemPromptDelivery, deferDeliveredSystemRefresh, clearSystemPromptDelivery, saveLkgSlotToDb, loadPersistedLkgSlot, drainStaleLkgSlots, createDbLkgPersistence, replayLkg, registerLkgPersistence, LKG_SNAPSHOT_ARRAY, LKG_SNAPSHOT_OBJECT, LKG_SNAPSHOT_KEY, LKG_SNAPSHOT_STRING, LKG_SNAPSHOT_NUMBER, LKG_SNAPSHOT_BOOLEAN, LKG_SNAPSHOT_NULL, LKG_SNAPSHOT_UNDEFINED, contentSnapshotValue, signatureForFields, lkgContentFields, lkgContentDigestFromFields, isLegacyLkgDigest, legacyLkgDigestFromFields, lkgFieldsMatchDigest, exactReusablePrefix, incrementalLkgContentDigests, lkgSlotRejection, captureSlot, getInMemorySlot, getSlot, dropSlot, TOOL_SWEEP_SCOPED_MARKER, encodePiContentDecision, decodePiContentDecision, getPiContentDecisions, freezePiContentDecision, getNativeReplayState, saveNativeToolInputs, addNativeReasoningIds, copySessionStateForClone, externalHistorianFailureReason, subprocessExitHistorianFailureReason, countHistorianRuns, recordHistorianRun, summarizeImportance, tallyFactsByCategory, queueMemoryMutation, getMemoryMutationsForRender, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationId, getMaxMemoryMutationIdForProjects, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, getSourceContents, recordSubagentInvocation, getLatestHistorianInvocationId, noteTouchedAt, noteNudgePickIndex, formatNoteNudge, systemPromptFingerprint, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, SYNTH_USER_ID_PREFIX, resolvePiStableId, resolvePiRealStableId, isPiContentFallbackId, isPiIndexFallbackId, piContentFallbackIds, readPiSessionSnapshot, readPiSessionMessages, readPiSessionMessagePage, findRestartModelSeedFromBranch, iterateEntriesToRawMessageRange, iterateAsyncEntriesToRawMessageRange, convertEntriesToRawMessages, convertPiAssistantEntryById, convertEntriesToRawMessagePage, countPiRawMessages, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, getTaskScheduleState, getFailingDreamTasks, getSkippedDreamTasks, getMostRecentTaskRunAt, pruneNonCanonicalTaskRows, deleteTaskScheduleRowsForProject, seedTaskScheduleState, writeTaskScheduleState, isRetrospectiveWindowProcessed, recordRetrospectiveWindowProcessed, curateCategoryForMemoryCategory, peekCurateCategoryScope, beginCurateCategoryRun, curateTaskStateAfterSuccess, MEMORY_MURAL_BLOCK, buildMagicContextSection, resolveMuralWire, updateCompactionMarkerAfterPublication, COMPARTMENT_RENDER_EPOCH, MEMORY_RENDER_FORMAT_EPOCH, encodeCachedM0UpgradeIdentity, decodeCachedM0UpgradeIdentity, withCachedM0MemoryIds, readCachedM0MemoryIds, renderBudgetIdentityChanged, renderedBudgetSnapshot, renderedBudgetShrinkReason, DEFAULT_HISTORY_BUDGET_TOKENS, renderCompartmentAtTier, renderDecayedCompartments, extractM0Block, TEMPORAL_MARKER_PATTERN, TEMPORAL_MARKER_REPLAY_PATTERN, temporalMarkerPrefix, renderUserProfileContent, clearInjectionCache, getVisibleMemoryIds, orderHistorianMemories, renderHistorianMemoryBlock, DEFAULT_MEMORY_BUDGET_TOKENS, DEFAULT_USER_PROFILE_BUDGET_TOKENS, trimMemoriesToBudgetV2, trimWorkspaceMemoriesToBudgetV2, trimUserMemoriesToBudget, renderMemoryBlockV2, stripMemoryMuralBlock, resetPrefixTrimFallbackState, isDirectiveShapedProjectRule, takeCurateSafetyRefusalCount, wakePlaneStatus, loadPiConfig, loadPiConfigDetailed, unregisterPiProjectEmbeddings, ensureProjectRegisteredFromPiDirectory, neutralizeOmpMentions, restoreOmpMentions, resolvePiHarnessDetection, resolvePiHarnessKind, resolvePiOrdinalAlignment, piRawOrdinalOffsetSource, resolvePiOrdinalAlignmentForContext, isPiOrdinalAlignmentUnanchored, clearPiOrdinalAlignmentSession, rememberTodowriteToolCallTodos, parseTodos, setTodoSnapshot, registerTodoOverlay, registerTodoStateLifecycle, syncCtxMemoryToolEnabled, registerMagicContextTools };
package/dist/index.js CHANGED
@@ -235,6 +235,8 @@ import {
235
235
  loadPiConfigDetailed,
236
236
  unregisterPiProjectEmbeddings,
237
237
  ensureProjectRegisteredFromPiDirectory,
238
+ neutralizeOmpMentions,
239
+ restoreOmpMentions,
238
240
  resolvePiHarnessDetection,
239
241
  resolvePiHarnessKind,
240
242
  resolvePiOrdinalAlignment,
@@ -249,7 +251,7 @@ import {
249
251
  registerTodoStateLifecycle,
250
252
  syncCtxMemoryToolEnabled,
251
253
  registerMagicContextTools
252
- } from "./index-w6r3ggnp.js";
254
+ } from "./index-2bx7ge3x.js";
253
255
  import"./index-4knyh1kt.js";
254
256
  import {
255
257
  canonicalModelIdentity,
@@ -789,10 +791,11 @@ import {
789
791
  readHostSystemPrompt,
790
792
  subagentStepCap,
791
793
  SubagentTelemetry,
794
+ OMP_CHILD_TOOL_CONFIG,
792
795
  HISTORIAN_CACHE_TAIL_ENV2,
793
796
  HISTORIAN_MAX_OUTPUT_TOKENS_ENV2,
794
797
  SUBAGENT_OUTPUT_CEILING_ENV2
795
- } from "./index-fa485mqs.js";
798
+ } from "./index-0b5kqg7n.js";
796
799
  import {
797
800
  PI_CONTEXT_BUDGET,
798
801
  PiContextDeadlineError,
@@ -3552,7 +3555,7 @@ function startHostStallProfilerSwitch() {
3552
3555
  // package.json
3553
3556
  var package_default = {
3554
3557
  name: "@cortexkit/pi-magic-context",
3555
- version: "0.49.21",
3558
+ version: "0.49.23",
3556
3559
  type: "module",
3557
3560
  description: "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
3558
3561
  main: "dist/index.js",
@@ -20990,6 +20993,12 @@ class PiSubagentRunner {
20990
20993
  }
20991
20994
  }
20992
20995
  async runOnce(options, runMode, modelRefOverride) {
20996
+ if (this.invocation.targetHarness === "omp") {
20997
+ options = {
20998
+ ...options,
20999
+ userMessage: neutralizeOmpMentions(options.userMessage)
21000
+ };
21001
+ }
20993
21002
  const startTime = Date.now();
20994
21003
  const zenChild = STRICT_TOOL_ALLOWLIST.has(options.agent) && isZenModel(options.model);
20995
21004
  let deferredZenStderr = "";
@@ -21069,6 +21078,7 @@ class PiSubagentRunner {
21069
21078
  const deliverViaStdin = !rpcBudget && (promptBytes > PROMPT_ARGV_MAX_BYTES || this.platform === "win32");
21070
21079
  let systemPromptTempDir;
21071
21080
  let systemPromptPath;
21081
+ let ompToolConfigPath;
21072
21082
  const cleanupSystemPromptFile = () => {
21073
21083
  if (!systemPromptTempDir)
21074
21084
  return;
@@ -21089,13 +21099,24 @@ class PiSubagentRunner {
21089
21099
  return failBeforeSpawn("spawn_failed", `failed to prepare pi system prompt file: ${error instanceof Error ? error.message : String(error)}`);
21090
21100
  }
21091
21101
  }
21092
- if (rpcBudget && !systemPromptTempDir) {
21102
+ if ((rpcBudget || this.invocation.targetHarness === "omp") && !systemPromptTempDir) {
21093
21103
  try {
21094
21104
  systemPromptTempDir = mkdtempSync2(join10(tmpdir2(), "mc-pi-prompt-"));
21095
21105
  } catch (error) {
21096
21106
  return failBeforeSpawn("spawn_failed", `failed to prepare pi budget guard: ${error instanceof Error ? error.message : String(error)}`);
21097
21107
  }
21098
21108
  }
21109
+ if (this.invocation.targetHarness === "omp") {
21110
+ try {
21111
+ if (!systemPromptTempDir)
21112
+ throw new Error("child temp directory is unavailable");
21113
+ ompToolConfigPath = join10(systemPromptTempDir, "tool-boundary.yml");
21114
+ writeFileSync4(ompToolConfigPath, OMP_CHILD_TOOL_CONFIG, "utf8");
21115
+ } catch (error) {
21116
+ cleanupSystemPromptFile();
21117
+ return failBeforeSpawn("spawn_failed", `failed to prepare OMP child tool config: ${String(error)}`);
21118
+ }
21119
+ }
21099
21120
  const budgetGuardFile = rpcBudget && systemPromptTempDir ? join10(systemPromptTempDir, "budget-guard") : undefined;
21100
21121
  if (budgetGuardFile) {
21101
21122
  try {
@@ -21112,6 +21133,7 @@ class PiSubagentRunner {
21112
21133
  hostToolNames: this.readHostToolNames(),
21113
21134
  omitPositionalMessage: deliverViaStdin || rpcBudget,
21114
21135
  systemPromptPath,
21136
+ ompToolConfigPath,
21115
21137
  modelRef: modelRefOverride,
21116
21138
  rpc: rpcBudget
21117
21139
  });
@@ -21345,7 +21367,7 @@ class PiSubagentRunner {
21345
21367
  rl.on("line", (line) => {
21346
21368
  if (settled || line.length === 0)
21347
21369
  return;
21348
- const parsed = parsePiEventLine(line);
21370
+ const parsed = parsePiEventLine(line, this.invocation.targetHarness);
21349
21371
  if (!parsed.ok) {
21350
21372
  if ("noise" in parsed)
21351
21373
  return;
@@ -21804,6 +21826,10 @@ var PROMPT_ARGV_MAX_BYTES = 96 * 1024;
21804
21826
  function buildArgs(options, opts) {
21805
21827
  const targetHarness = opts?.targetHarness ?? resolvePiHarnessKind();
21806
21828
  const ompTarget = targetHarness === "omp";
21829
+ const ompToolConfigPath = opts?.ompToolConfigPath;
21830
+ if (ompTarget && !ompToolConfigPath) {
21831
+ throw new Error("OMP child requires a tool-boundary config overlay");
21832
+ }
21807
21833
  const args = [
21808
21834
  ...opts?.rpc ? [] : ["--print"],
21809
21835
  "--mode",
@@ -21812,6 +21838,9 @@ function buildArgs(options, opts) {
21812
21838
  "--no-skills",
21813
21839
  ...ompTarget ? ["--no-rules"] : ["--no-prompt-templates", "--no-context-files"]
21814
21840
  ];
21841
+ if (ompTarget && ompToolConfigPath) {
21842
+ args.push("--config", ompToolConfigPath);
21843
+ }
21815
21844
  if (opts?.disableDiscoveredExtensions || opts?.subagentExtensions !== undefined) {
21816
21845
  args.push("--no-extensions");
21817
21846
  }
@@ -21828,17 +21857,24 @@ function buildArgs(options, opts) {
21828
21857
  args.push("--magic-context-dreamer-actions");
21829
21858
  }
21830
21859
  }
21831
- const historianCalibrationEntryPath = opts?.historianCalibrationEntryPath === undefined ? HISTORIAN_CALIBRATION_ENTRY_PATH : opts.historianCalibrationEntryPath;
21832
- if (subagentStepCap(options.agent) !== undefined && historianCalibrationEntryPath) {
21860
+ const historianCalibrationEntryPath = opts?.historianCalibrationEntryPath === undefined ? HISTORIAN_CALIBRATION_ENTRY_PATH ?? (ompTarget ? resolveSiblingEntryPath("historian-calibration-extension.ts") : undefined) : opts.historianCalibrationEntryPath;
21861
+ if (ompTarget && !historianCalibrationEntryPath) {
21862
+ throw new Error("OMP child requires the tool-boundary startup extension");
21863
+ }
21864
+ if ((ompTarget || subagentStepCap(options.agent) !== undefined) && historianCalibrationEntryPath) {
21833
21865
  args.push("--extension", historianCalibrationEntryPath);
21834
21866
  }
21835
21867
  const strictTools = STRICT_TOOL_ALLOWLIST.get(options.agent);
21868
+ let activeToolNames = [];
21836
21869
  if (strictTools === undefined) {
21837
21870
  sessionLog2(options.accountingSessionId ?? "pi-subagent", `Pi subagent agent "${options.agent}" has no strict tool allow-list; forcing --no-tools`);
21838
21871
  args.push("--no-tools");
21839
21872
  } else {
21840
21873
  const resolution = resolveHostToolAllowlistDetails(strictTools, ompTarget, ompTarget ? opts?.hostToolNames : undefined);
21841
21874
  const hostTools = resolution.tools;
21875
+ activeToolNames = [
21876
+ ...new Set(strictTools.map((tool) => ompTarget ? OMP_TOOL_ALIASES[tool] ?? tool : tool).filter((tool) => !resolution.dropped.includes(tool)))
21877
+ ];
21842
21878
  for (const tool of resolution.dropped) {
21843
21879
  const warningKey = `${options.agent}\x00${tool}`;
21844
21880
  if (loggedUnavailableBuiltinTools.has(warningKey))
@@ -21853,6 +21889,9 @@ function buildArgs(options, opts) {
21853
21889
  args.push("--no-tools");
21854
21890
  }
21855
21891
  }
21892
+ if (ompTarget) {
21893
+ args.push("--magic-context-tool-allowlist", JSON.stringify(activeToolNames));
21894
+ }
21856
21895
  if (opts?.systemPromptPath) {
21857
21896
  args.push("--system-prompt", opts.systemPromptPath);
21858
21897
  }
@@ -21946,12 +21985,16 @@ function countToolCalls(messages) {
21946
21985
  }
21947
21986
  return count;
21948
21987
  }
21949
- function parsePiEventLine(line) {
21988
+ function parsePiEventLine(line, targetHarness = "pi") {
21950
21989
  if (!line.trimStart().startsWith("{")) {
21951
21990
  return { ok: false, noise: true };
21952
21991
  }
21953
21992
  try {
21954
- return { ok: true, event: JSON.parse(line) };
21993
+ const event = JSON.parse(line);
21994
+ return {
21995
+ ok: true,
21996
+ event: targetHarness === "omp" ? restoreOmpMentions(event) : event
21997
+ };
21955
21998
  } catch (error) {
21956
21999
  return {
21957
22000
  ok: false,
@@ -31,7 +31,7 @@ import {
31
31
  ensureProjectRegisteredFromPiDirectory,
32
32
  resolvePiHarnessKind,
33
33
  registerMagicContextTools
34
- } from "./index-w6r3ggnp.js";
34
+ } from "./index-2bx7ge3x.js";
35
35
  import"./index-ccanzg8p.js";
36
36
  import"./index-gwxaz0z5.js";
37
37
  import"./index-vx6f7wff.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/pi-magic-context",
3
- "version": "0.49.21",
3
+ "version": "0.49.23",
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",