@cortexkit/pi-magic-context 0.49.22 → 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.
|
@@ -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 };
|
package/dist/index.js
CHANGED
|
@@ -791,10 +791,11 @@ import {
|
|
|
791
791
|
readHostSystemPrompt,
|
|
792
792
|
subagentStepCap,
|
|
793
793
|
SubagentTelemetry,
|
|
794
|
+
OMP_CHILD_TOOL_CONFIG,
|
|
794
795
|
HISTORIAN_CACHE_TAIL_ENV2,
|
|
795
796
|
HISTORIAN_MAX_OUTPUT_TOKENS_ENV2,
|
|
796
797
|
SUBAGENT_OUTPUT_CEILING_ENV2
|
|
797
|
-
} from "./index-
|
|
798
|
+
} from "./index-0b5kqg7n.js";
|
|
798
799
|
import {
|
|
799
800
|
PI_CONTEXT_BUDGET,
|
|
800
801
|
PiContextDeadlineError,
|
|
@@ -3554,7 +3555,7 @@ function startHostStallProfilerSwitch() {
|
|
|
3554
3555
|
// package.json
|
|
3555
3556
|
var package_default = {
|
|
3556
3557
|
name: "@cortexkit/pi-magic-context",
|
|
3557
|
-
version: "0.49.
|
|
3558
|
+
version: "0.49.23",
|
|
3558
3559
|
type: "module",
|
|
3559
3560
|
description: "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
|
|
3560
3561
|
main: "dist/index.js",
|
|
@@ -21077,6 +21078,7 @@ class PiSubagentRunner {
|
|
|
21077
21078
|
const deliverViaStdin = !rpcBudget && (promptBytes > PROMPT_ARGV_MAX_BYTES || this.platform === "win32");
|
|
21078
21079
|
let systemPromptTempDir;
|
|
21079
21080
|
let systemPromptPath;
|
|
21081
|
+
let ompToolConfigPath;
|
|
21080
21082
|
const cleanupSystemPromptFile = () => {
|
|
21081
21083
|
if (!systemPromptTempDir)
|
|
21082
21084
|
return;
|
|
@@ -21097,13 +21099,24 @@ class PiSubagentRunner {
|
|
|
21097
21099
|
return failBeforeSpawn("spawn_failed", `failed to prepare pi system prompt file: ${error instanceof Error ? error.message : String(error)}`);
|
|
21098
21100
|
}
|
|
21099
21101
|
}
|
|
21100
|
-
if (rpcBudget && !systemPromptTempDir) {
|
|
21102
|
+
if ((rpcBudget || this.invocation.targetHarness === "omp") && !systemPromptTempDir) {
|
|
21101
21103
|
try {
|
|
21102
21104
|
systemPromptTempDir = mkdtempSync2(join10(tmpdir2(), "mc-pi-prompt-"));
|
|
21103
21105
|
} catch (error) {
|
|
21104
21106
|
return failBeforeSpawn("spawn_failed", `failed to prepare pi budget guard: ${error instanceof Error ? error.message : String(error)}`);
|
|
21105
21107
|
}
|
|
21106
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
|
+
}
|
|
21107
21120
|
const budgetGuardFile = rpcBudget && systemPromptTempDir ? join10(systemPromptTempDir, "budget-guard") : undefined;
|
|
21108
21121
|
if (budgetGuardFile) {
|
|
21109
21122
|
try {
|
|
@@ -21120,6 +21133,7 @@ class PiSubagentRunner {
|
|
|
21120
21133
|
hostToolNames: this.readHostToolNames(),
|
|
21121
21134
|
omitPositionalMessage: deliverViaStdin || rpcBudget,
|
|
21122
21135
|
systemPromptPath,
|
|
21136
|
+
ompToolConfigPath,
|
|
21123
21137
|
modelRef: modelRefOverride,
|
|
21124
21138
|
rpc: rpcBudget
|
|
21125
21139
|
});
|
|
@@ -21812,6 +21826,10 @@ var PROMPT_ARGV_MAX_BYTES = 96 * 1024;
|
|
|
21812
21826
|
function buildArgs(options, opts) {
|
|
21813
21827
|
const targetHarness = opts?.targetHarness ?? resolvePiHarnessKind();
|
|
21814
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
|
+
}
|
|
21815
21833
|
const args = [
|
|
21816
21834
|
...opts?.rpc ? [] : ["--print"],
|
|
21817
21835
|
"--mode",
|
|
@@ -21820,6 +21838,9 @@ function buildArgs(options, opts) {
|
|
|
21820
21838
|
"--no-skills",
|
|
21821
21839
|
...ompTarget ? ["--no-rules"] : ["--no-prompt-templates", "--no-context-files"]
|
|
21822
21840
|
];
|
|
21841
|
+
if (ompTarget && ompToolConfigPath) {
|
|
21842
|
+
args.push("--config", ompToolConfigPath);
|
|
21843
|
+
}
|
|
21823
21844
|
if (opts?.disableDiscoveredExtensions || opts?.subagentExtensions !== undefined) {
|
|
21824
21845
|
args.push("--no-extensions");
|
|
21825
21846
|
}
|
|
@@ -21836,17 +21857,24 @@ function buildArgs(options, opts) {
|
|
|
21836
21857
|
args.push("--magic-context-dreamer-actions");
|
|
21837
21858
|
}
|
|
21838
21859
|
}
|
|
21839
|
-
const historianCalibrationEntryPath = opts?.historianCalibrationEntryPath === undefined ? HISTORIAN_CALIBRATION_ENTRY_PATH : opts.historianCalibrationEntryPath;
|
|
21840
|
-
if (
|
|
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) {
|
|
21841
21865
|
args.push("--extension", historianCalibrationEntryPath);
|
|
21842
21866
|
}
|
|
21843
21867
|
const strictTools = STRICT_TOOL_ALLOWLIST.get(options.agent);
|
|
21868
|
+
let activeToolNames = [];
|
|
21844
21869
|
if (strictTools === undefined) {
|
|
21845
21870
|
sessionLog2(options.accountingSessionId ?? "pi-subagent", `Pi subagent agent "${options.agent}" has no strict tool allow-list; forcing --no-tools`);
|
|
21846
21871
|
args.push("--no-tools");
|
|
21847
21872
|
} else {
|
|
21848
21873
|
const resolution = resolveHostToolAllowlistDetails(strictTools, ompTarget, ompTarget ? opts?.hostToolNames : undefined);
|
|
21849
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
|
+
];
|
|
21850
21878
|
for (const tool of resolution.dropped) {
|
|
21851
21879
|
const warningKey = `${options.agent}\x00${tool}`;
|
|
21852
21880
|
if (loggedUnavailableBuiltinTools.has(warningKey))
|
|
@@ -21861,6 +21889,9 @@ function buildArgs(options, opts) {
|
|
|
21861
21889
|
args.push("--no-tools");
|
|
21862
21890
|
}
|
|
21863
21891
|
}
|
|
21892
|
+
if (ompTarget) {
|
|
21893
|
+
args.push("--magic-context-tool-allowlist", JSON.stringify(activeToolNames));
|
|
21894
|
+
}
|
|
21864
21895
|
if (opts?.systemPromptPath) {
|
|
21865
21896
|
args.push("--system-prompt", opts.systemPromptPath);
|
|
21866
21897
|
}
|
package/package.json
CHANGED