negotium 0.3.13 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -6
- package/dist/agent-helpers.js +328 -185
- package/dist/agent-helpers.js.map +9 -8
- package/dist/{chunk-0ynjwr50.js → chunk-zq2tcq4k.js} +12 -29
- package/dist/{chunk-0ynjwr50.js.map → chunk-zq2tcq4k.js.map} +4 -4
- package/dist/hosted-agent.js +207 -64
- package/dist/hosted-agent.js.map +8 -7
- package/dist/main.js +753 -886
- package/dist/main.js.map +13 -13
- package/dist/mcp-factories.js +300 -468
- package/dist/mcp-factories.js.map +9 -10
- package/dist/registry.js +3 -3
- package/dist/registry.js.map +2 -2
- package/dist/rollout.js +1 -1
- package/dist/runtime/src/agents/codex-provider.ts +33 -8
- package/dist/runtime/src/agents/codex-vault-hook-bridge.ts +192 -0
- package/dist/runtime/src/agents/codex-vault-hook.mjs +48 -0
- package/dist/runtime/src/agents/execution-host.ts +1 -14
- package/dist/runtime/src/agents/public-helpers.ts +0 -9
- package/dist/runtime/src/agents/vault-tool-policy.ts +9 -51
- package/dist/runtime/src/mcp/factories/index.ts +1 -8
- package/dist/runtime/src/mcp/factories/vault.ts +6 -104
- package/dist/runtime/src/mcp/vault-server.ts +4 -20
- package/dist/runtime/src/prompts/sessions/_shared-tools.md +1 -1
- package/dist/runtime/src/version.ts +1 -1
- package/dist/types/packages/core/src/agents/codex-vault-hook-bridge.d.ts +27 -0
- package/dist/types/packages/core/src/agents/execution-host.d.ts +0 -2
- package/dist/types/packages/core/src/agents/public-helpers.d.ts +0 -1
- package/dist/types/packages/core/src/agents/vault-tool-policy.d.ts +1 -14
- package/dist/types/packages/core/src/mcp/factories/index.d.ts +1 -3
- package/dist/types/packages/core/src/mcp/factories/vault.d.ts +4 -13
- package/dist/types/packages/core/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/dist/runtime/src/mcp/factories/vault-host.ts +0 -8
- package/dist/runtime/src/mcp/vault-http.ts +0 -235
- package/dist/runtime/src/mcp/vault-run.ts +0 -154
- package/dist/types/packages/core/src/mcp/factories/vault-host.d.ts +0 -7
- package/dist/types/packages/core/src/mcp/vault-http.d.ts +0 -23
- package/dist/types/packages/core/src/mcp/vault-run.d.ts +0 -19
package/dist/hosted-agent.js
CHANGED
|
@@ -503,36 +503,20 @@ function shouldSubstituteVaultToolInput(toolName) {
|
|
|
503
503
|
const leaf = leafToolName(toolName);
|
|
504
504
|
return leaf.startsWith("browser_") || DIRECT_VAULT_EXECUTION_TOOLS.has(leaf);
|
|
505
505
|
}
|
|
506
|
-
function
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
const lower = value.toLowerCase();
|
|
513
|
-
if (SENSITIVE_RUNTIME_NAMES.some((name) => lower.includes(name)))
|
|
514
|
-
return true;
|
|
515
|
-
return value.startsWith("/") && host.isSensitivePath(value);
|
|
516
|
-
}
|
|
517
|
-
if (Array.isArray(value))
|
|
518
|
-
return value.some(referencesRuntimeSecretStorage);
|
|
519
|
-
if (value && typeof value === "object") {
|
|
520
|
-
return Object.values(value).some(referencesRuntimeSecretStorage);
|
|
521
|
-
}
|
|
522
|
-
return false;
|
|
506
|
+
function referencesRuntimeSecretStorage(value) {
|
|
507
|
+
if (typeof value === "string") {
|
|
508
|
+
const lower = value.toLowerCase();
|
|
509
|
+
if (SENSITIVE_RUNTIME_NAMES.some((name) => lower.includes(name)))
|
|
510
|
+
return true;
|
|
511
|
+
return value.startsWith("/") && isSensitivePath(value);
|
|
523
512
|
}
|
|
524
|
-
|
|
525
|
-
return
|
|
513
|
+
if (Array.isArray(value))
|
|
514
|
+
return value.some(referencesRuntimeSecretStorage);
|
|
515
|
+
if (value && typeof value === "object") {
|
|
516
|
+
return Object.values(value).some(referencesRuntimeSecretStorage);
|
|
526
517
|
}
|
|
527
|
-
return
|
|
518
|
+
return false;
|
|
528
519
|
}
|
|
529
|
-
var defaultVaultToolPolicy = createVaultToolPolicy({
|
|
530
|
-
isSensitivePath,
|
|
531
|
-
valueReferencesVaultKey: () => false
|
|
532
|
-
});
|
|
533
|
-
var isVaultBrokerTool = defaultVaultToolPolicy.isVaultBrokerTool;
|
|
534
|
-
var referencesRuntimeSecretStorage = defaultVaultToolPolicy.referencesRuntimeSecretStorage;
|
|
535
|
-
var shouldRedirectVaultTool = defaultVaultToolPolicy.shouldRedirectVaultTool;
|
|
536
520
|
|
|
537
521
|
// ../../packages/core/src/mcp/runtime-spec.ts
|
|
538
522
|
import { createHash, createHmac, timingSafeEqual } from "crypto";
|
|
@@ -1804,7 +1788,6 @@ var defaultHost = {
|
|
|
1804
1788
|
redactVaultSecrets,
|
|
1805
1789
|
substituteVaultSecrets: (userId, value) => vaultSubstituteDetailed(userId, value).text,
|
|
1806
1790
|
referencesRuntimeSecretStorage,
|
|
1807
|
-
shouldRedirectVaultTool,
|
|
1808
1791
|
claudeCodeExecutablePath: () => CLAUDE_EXECUTABLE,
|
|
1809
1792
|
codexAuthFilePath
|
|
1810
1793
|
};
|
|
@@ -2375,9 +2358,9 @@ async function* claudeProvider(opts) {
|
|
|
2375
2358
|
|
|
2376
2359
|
// ../../packages/core/src/agents/codex-provider.ts
|
|
2377
2360
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
2378
|
-
import { existsSync as
|
|
2361
|
+
import { existsSync as existsSync6, readFileSync as readFileSync6, realpathSync as realpathSync3, statSync as statSync3 } from "fs";
|
|
2379
2362
|
import { homedir as homedir3 } from "os";
|
|
2380
|
-
import { dirname as
|
|
2363
|
+
import { dirname as dirname8, isAbsolute, join as join7, relative, resolve as resolve7 } from "path";
|
|
2381
2364
|
import { Codex } from "@openai/codex-sdk";
|
|
2382
2365
|
|
|
2383
2366
|
// ../../packages/core/src/agents/codex-native-multi-agent.ts
|
|
@@ -2399,7 +2382,7 @@ import { tmpdir } from "os";
|
|
|
2399
2382
|
import { dirname as dirname5, join as join4 } from "path";
|
|
2400
2383
|
|
|
2401
2384
|
// ../../packages/core/src/version.ts
|
|
2402
|
-
var NEGOTIUM_VERSION = "0.
|
|
2385
|
+
var NEGOTIUM_VERSION = "0.4.0";
|
|
2403
2386
|
|
|
2404
2387
|
// ../../packages/core/src/agents/codex-native-multi-agent.ts
|
|
2405
2388
|
var moduleRequire = createRequire2(import.meta.url);
|
|
@@ -2827,19 +2810,168 @@ var withCodexSpawnSerial = manager.withSpawnSerial;
|
|
|
2827
2810
|
var killCodexTrees = manager.killTrees;
|
|
2828
2811
|
var killOwnedCodexTreesForShutdown = manager.killOwnedTreesForShutdown;
|
|
2829
2812
|
|
|
2813
|
+
// ../../packages/core/src/agents/codex-vault-hook-bridge.ts
|
|
2814
|
+
import { randomBytes as randomBytes4 } from "crypto";
|
|
2815
|
+
import { existsSync as existsSync4 } from "fs";
|
|
2816
|
+
import { chmod, mkdtemp, rm, writeFile } from "fs/promises";
|
|
2817
|
+
import { createServer } from "net";
|
|
2818
|
+
import { tmpdir as tmpdir2 } from "os";
|
|
2819
|
+
import { dirname as dirname6, join as join5, resolve as resolve5 } from "path";
|
|
2820
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
2821
|
+
var MAX_HOOK_REQUEST_BYTES = 1024 * 1024;
|
|
2822
|
+
var SENSITIVE_STORAGE_DENIAL = "Runtime secret storage access is not permitted";
|
|
2823
|
+
function evaluateCodexVaultPreToolUse(input, userId, operations) {
|
|
2824
|
+
if (operations.referencesSensitiveStorage(input.tool_input)) {
|
|
2825
|
+
return {
|
|
2826
|
+
hookSpecificOutput: {
|
|
2827
|
+
hookEventName: "PreToolUse",
|
|
2828
|
+
permissionDecision: "deny",
|
|
2829
|
+
permissionDecisionReason: SENSITIVE_STORAGE_DENIAL
|
|
2830
|
+
}
|
|
2831
|
+
};
|
|
2832
|
+
}
|
|
2833
|
+
if (!shouldSubstituteVaultToolInput(input.tool_name))
|
|
2834
|
+
return {};
|
|
2835
|
+
const updatedInput = deepMapStrings(input.tool_input, (value) => operations.substitute(userId, value));
|
|
2836
|
+
if (JSON.stringify(updatedInput) === JSON.stringify(input.tool_input))
|
|
2837
|
+
return {};
|
|
2838
|
+
return {
|
|
2839
|
+
hookSpecificOutput: {
|
|
2840
|
+
hookEventName: "PreToolUse",
|
|
2841
|
+
permissionDecision: "allow",
|
|
2842
|
+
updatedInput
|
|
2843
|
+
}
|
|
2844
|
+
};
|
|
2845
|
+
}
|
|
2846
|
+
function shellQuote(value) {
|
|
2847
|
+
return `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
2848
|
+
}
|
|
2849
|
+
function hookClientPath() {
|
|
2850
|
+
const moduleDir = dirname6(fileURLToPath2(import.meta.url));
|
|
2851
|
+
const adjacent = resolve5(moduleDir, "codex-vault-hook.mjs");
|
|
2852
|
+
if (existsSync4(adjacent))
|
|
2853
|
+
return adjacent;
|
|
2854
|
+
const packaged = resolve5(moduleDir, "runtime/src/agents/codex-vault-hook.mjs");
|
|
2855
|
+
if (existsSync4(packaged))
|
|
2856
|
+
return packaged;
|
|
2857
|
+
throw new Error("Codex Vault hook client is missing from this installation");
|
|
2858
|
+
}
|
|
2859
|
+
function privateCodexWrapper(codexScript) {
|
|
2860
|
+
return [
|
|
2861
|
+
"#!/bin/sh",
|
|
2862
|
+
'if [ "$1" = "exec" ]; then',
|
|
2863
|
+
" shift",
|
|
2864
|
+
` exec ${shellQuote(process.execPath)} ${shellQuote(codexScript)} exec --dangerously-bypass-hook-trust "$@"`,
|
|
2865
|
+
"fi",
|
|
2866
|
+
`exec ${shellQuote(process.execPath)} ${shellQuote(codexScript)} "$@"`,
|
|
2867
|
+
""
|
|
2868
|
+
].join(`
|
|
2869
|
+
`);
|
|
2870
|
+
}
|
|
2871
|
+
async function createCodexVaultHookBridge(userId) {
|
|
2872
|
+
const root = await mkdtemp(join5(tmpdir2(), "negotium-codex-vault-"));
|
|
2873
|
+
await chmod(root, 448);
|
|
2874
|
+
const socketPath = join5(root, "hook.sock");
|
|
2875
|
+
const wrapperPath = join5(root, "codex-with-hooks");
|
|
2876
|
+
const token = randomBytes4(32).toString("hex");
|
|
2877
|
+
const connections = new Set;
|
|
2878
|
+
const server = createServer((socket) => {
|
|
2879
|
+
connections.add(socket);
|
|
2880
|
+
socket.once("close", () => connections.delete(socket));
|
|
2881
|
+
socket.setEncoding("utf8");
|
|
2882
|
+
let request = "";
|
|
2883
|
+
let handled = false;
|
|
2884
|
+
const handleRequest = () => {
|
|
2885
|
+
if (handled)
|
|
2886
|
+
return;
|
|
2887
|
+
handled = true;
|
|
2888
|
+
try {
|
|
2889
|
+
const parsed = JSON.parse(request.trimEnd());
|
|
2890
|
+
if (parsed.token !== token)
|
|
2891
|
+
throw new Error("invalid hook capability");
|
|
2892
|
+
if (!parsed.input || typeof parsed.input !== "object" || typeof parsed.input.tool_name !== "string") {
|
|
2893
|
+
throw new Error("invalid PreToolUse payload");
|
|
2894
|
+
}
|
|
2895
|
+
const output = evaluateCodexVaultPreToolUse(parsed.input, userId, {
|
|
2896
|
+
referencesSensitiveStorage: referencesHostedSecretStorage,
|
|
2897
|
+
substitute: substituteHostedSecrets
|
|
2898
|
+
});
|
|
2899
|
+
socket.end(JSON.stringify({ ok: true, output }));
|
|
2900
|
+
} catch (error) {
|
|
2901
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2902
|
+
socket.end(JSON.stringify({ ok: false, error: message }));
|
|
2903
|
+
}
|
|
2904
|
+
};
|
|
2905
|
+
socket.on("data", (chunk) => {
|
|
2906
|
+
request += chunk;
|
|
2907
|
+
if (Buffer.byteLength(request) > MAX_HOOK_REQUEST_BYTES)
|
|
2908
|
+
socket.destroy();
|
|
2909
|
+
else if (request.endsWith(`
|
|
2910
|
+
`))
|
|
2911
|
+
handleRequest();
|
|
2912
|
+
});
|
|
2913
|
+
socket.on("end", handleRequest);
|
|
2914
|
+
});
|
|
2915
|
+
try {
|
|
2916
|
+
await new Promise((resolveListen, reject) => {
|
|
2917
|
+
server.once("error", reject);
|
|
2918
|
+
server.listen(socketPath, () => {
|
|
2919
|
+
server.off("error", reject);
|
|
2920
|
+
resolveListen();
|
|
2921
|
+
});
|
|
2922
|
+
});
|
|
2923
|
+
await chmod(socketPath, 384);
|
|
2924
|
+
await writeFile(wrapperPath, privateCodexWrapper(codexCliScriptPath()), { mode: 448 });
|
|
2925
|
+
const command = [
|
|
2926
|
+
shellQuote(process.execPath),
|
|
2927
|
+
shellQuote(hookClientPath()),
|
|
2928
|
+
shellQuote(socketPath),
|
|
2929
|
+
shellQuote(token)
|
|
2930
|
+
].join(" ");
|
|
2931
|
+
return {
|
|
2932
|
+
codexPathOverride: wrapperPath,
|
|
2933
|
+
hooks: {
|
|
2934
|
+
PreToolUse: [
|
|
2935
|
+
{
|
|
2936
|
+
matcher: "*",
|
|
2937
|
+
hooks: [
|
|
2938
|
+
{
|
|
2939
|
+
type: "command",
|
|
2940
|
+
command,
|
|
2941
|
+
timeout: 30,
|
|
2942
|
+
statusMessage: "Resolving Vault placeholders"
|
|
2943
|
+
}
|
|
2944
|
+
]
|
|
2945
|
+
}
|
|
2946
|
+
]
|
|
2947
|
+
},
|
|
2948
|
+
async close() {
|
|
2949
|
+
for (const socket of connections)
|
|
2950
|
+
socket.destroy();
|
|
2951
|
+
await new Promise((resolveClose) => server.close(() => resolveClose()));
|
|
2952
|
+
await rm(root, { recursive: true, force: true });
|
|
2953
|
+
}
|
|
2954
|
+
};
|
|
2955
|
+
} catch (error) {
|
|
2956
|
+
server.close();
|
|
2957
|
+
await rm(root, { recursive: true, force: true });
|
|
2958
|
+
throw error;
|
|
2959
|
+
}
|
|
2960
|
+
}
|
|
2961
|
+
|
|
2830
2962
|
// ../../packages/core/src/agents/rollout/codex.ts
|
|
2831
|
-
import { existsSync as
|
|
2832
|
-
import { basename, dirname as
|
|
2963
|
+
import { existsSync as existsSync5, readFileSync as readFileSync5, realpathSync as realpathSync2, statSync as statSync2, unlinkSync as unlinkSync4 } from "fs";
|
|
2964
|
+
import { basename, dirname as dirname7, join as join6, resolve as resolve6 } from "path";
|
|
2833
2965
|
function codexSessionsDir() {
|
|
2834
|
-
return
|
|
2966
|
+
return join6(hostedCodexHomePath(), "sessions");
|
|
2835
2967
|
}
|
|
2836
2968
|
function canonicalFilePath(path) {
|
|
2837
|
-
const absolute =
|
|
2969
|
+
const absolute = resolve6(path);
|
|
2838
2970
|
try {
|
|
2839
2971
|
return realpathSync2(absolute);
|
|
2840
2972
|
} catch {
|
|
2841
2973
|
try {
|
|
2842
|
-
return
|
|
2974
|
+
return join6(realpathSync2(dirname7(absolute)), basename(absolute));
|
|
2843
2975
|
} catch {
|
|
2844
2976
|
return absolute;
|
|
2845
2977
|
}
|
|
@@ -3069,19 +3201,19 @@ function latestCodexRolloutPath(threadId) {
|
|
|
3069
3201
|
try {
|
|
3070
3202
|
if (buckets) {
|
|
3071
3203
|
for (const bucket of buckets) {
|
|
3072
|
-
const dir =
|
|
3073
|
-
if (!
|
|
3204
|
+
const dir = join6(sessionsDir, bucket);
|
|
3205
|
+
if (!existsSync5(dir))
|
|
3074
3206
|
continue;
|
|
3075
3207
|
const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
|
|
3076
3208
|
for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
|
|
3077
|
-
candidates.push(
|
|
3209
|
+
candidates.push(join6(dir, rel));
|
|
3078
3210
|
}
|
|
3079
3211
|
}
|
|
3080
3212
|
}
|
|
3081
3213
|
if (candidates.length === 0) {
|
|
3082
3214
|
const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
|
|
3083
3215
|
for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
|
|
3084
|
-
candidates.push(
|
|
3216
|
+
candidates.push(join6(sessionsDir, rel));
|
|
3085
3217
|
}
|
|
3086
3218
|
}
|
|
3087
3219
|
return candidates.sort((a, b) => statSync2(b).mtimeMs - statSync2(a).mtimeMs)[0];
|
|
@@ -3233,8 +3365,8 @@ function codexMcpServerName(name) {
|
|
|
3233
3365
|
return CODEX_MCP_SERVER_NAME_OVERRIDES[name] ?? name;
|
|
3234
3366
|
}
|
|
3235
3367
|
function globalCodexMcpServerNames(authFilePath) {
|
|
3236
|
-
const configPath =
|
|
3237
|
-
if (!
|
|
3368
|
+
const configPath = join7(dirname8(authFilePath), "config.toml");
|
|
3369
|
+
if (!existsSync6(configPath))
|
|
3238
3370
|
return [];
|
|
3239
3371
|
try {
|
|
3240
3372
|
const names = new Set;
|
|
@@ -3332,13 +3464,13 @@ var CODEX_DIFF_BASELINE_FILE_LIMIT = 200;
|
|
|
3332
3464
|
var CODEX_DIFF_BASELINE_BYTE_LIMIT = 16 * 1024 * 1024;
|
|
3333
3465
|
function canonicalPath(path) {
|
|
3334
3466
|
try {
|
|
3335
|
-
return realpathSync3(
|
|
3467
|
+
return realpathSync3(resolve7(path));
|
|
3336
3468
|
} catch {
|
|
3337
|
-
return
|
|
3469
|
+
return resolve7(path);
|
|
3338
3470
|
}
|
|
3339
3471
|
}
|
|
3340
3472
|
function textFile(path, maxBytes = CODEX_DIFF_FILE_LIMIT) {
|
|
3341
|
-
if (!
|
|
3473
|
+
if (!existsSync6(path))
|
|
3342
3474
|
return null;
|
|
3343
3475
|
try {
|
|
3344
3476
|
const byteLimit = Math.min(CODEX_DIFF_FILE_LIMIT, Math.max(0, maxBytes));
|
|
@@ -3378,7 +3510,7 @@ class CodexFilePreviewTracker {
|
|
|
3378
3510
|
const code = record.slice(0, 2);
|
|
3379
3511
|
const path = record.slice(3);
|
|
3380
3512
|
const remainingBytes = CODEX_DIFF_BASELINE_BYTE_LIMIT - loadedBytes;
|
|
3381
|
-
const content = loadedFiles < CODEX_DIFF_BASELINE_FILE_LIMIT && remainingBytes > 0 ? textFile(
|
|
3513
|
+
const content = loadedFiles < CODEX_DIFF_BASELINE_FILE_LIMIT && remainingBytes > 0 ? textFile(resolve7(this.#root, path), remainingBytes) : undefined;
|
|
3382
3514
|
this.#baseline.set(path, content);
|
|
3383
3515
|
if (typeof content === "string") {
|
|
3384
3516
|
loadedFiles += 1;
|
|
@@ -3391,7 +3523,7 @@ class CodexFilePreviewTracker {
|
|
|
3391
3523
|
preview(path, succeeded) {
|
|
3392
3524
|
if (!this.#root || !this.#baselineAvailable || !succeeded)
|
|
3393
3525
|
return {};
|
|
3394
|
-
const absolute = canonicalPath(isAbsolute(path) ? path :
|
|
3526
|
+
const absolute = canonicalPath(isAbsolute(path) ? path : resolve7(this.#cwd, path));
|
|
3395
3527
|
const relativePath = relative(this.#root, absolute);
|
|
3396
3528
|
if (!relativePath || relativePath.startsWith("..") || isAbsolute(relativePath))
|
|
3397
3529
|
return {};
|
|
@@ -3426,7 +3558,7 @@ class CodexFilePreviewTracker {
|
|
|
3426
3558
|
}
|
|
3427
3559
|
}
|
|
3428
3560
|
async function fileChangeEvents(item, previews, cwd, threadId, consumedPatchCallIds) {
|
|
3429
|
-
const expectedPaths = item.changes.map((change) => isAbsolute(change.path) ? change.path :
|
|
3561
|
+
const expectedPaths = item.changes.map((change) => isAbsolute(change.path) ? change.path : resolve7(cwd, change.path));
|
|
3430
3562
|
let nativePreview;
|
|
3431
3563
|
if (threadId && item.status === "completed") {
|
|
3432
3564
|
await new Promise((resolveDelay) => setTimeout(resolveDelay, 20));
|
|
@@ -3551,7 +3683,7 @@ async function* codexProvider(opts) {
|
|
|
3551
3683
|
const filePreviews = new CodexFilePreviewTracker(opts.cwd);
|
|
3552
3684
|
const consumedPatchCallIds = new Set(opts.sessionId ? readCodexPatchCallIds(opts.sessionId) : []);
|
|
3553
3685
|
const codexAuthPath = hostedCodexAuthFilePath();
|
|
3554
|
-
if (!
|
|
3686
|
+
if (!existsSync6(codexAuthPath)) {
|
|
3555
3687
|
yield {
|
|
3556
3688
|
type: "error",
|
|
3557
3689
|
content: `Codex auth file not found at ${codexAuthPath}. Run \`codex login\` to authenticate.`
|
|
@@ -3590,21 +3722,30 @@ async function* codexProvider(opts) {
|
|
|
3590
3722
|
model: opts.model ?? "(sdk default)",
|
|
3591
3723
|
effort: opts.effort ?? "(off)",
|
|
3592
3724
|
cwd: opts.cwd,
|
|
3593
|
-
cwdExists:
|
|
3725
|
+
cwdExists: existsSync6(opts.cwd),
|
|
3594
3726
|
resume: Boolean(opts.sessionId),
|
|
3595
3727
|
mcpServerCount: Object.keys(codexMcpServers).length
|
|
3596
3728
|
}, "codexProvider: starting turn");
|
|
3597
3729
|
const hostedCodexHome = hostedCodexHomePath();
|
|
3598
|
-
const inheritedCodexHome = process.env.CODEX_HOME ||
|
|
3599
|
-
const codexEnvironment = scopedBrowserCapability ||
|
|
3730
|
+
const inheritedCodexHome = process.env.CODEX_HOME || join7(homedir3(), ".codex");
|
|
3731
|
+
const codexEnvironment = scopedBrowserCapability || resolve7(hostedCodexHome) !== resolve7(inheritedCodexHome) ? {
|
|
3600
3732
|
...Object.fromEntries(Object.entries(process.env).filter((entry) => typeof entry[1] === "string")),
|
|
3601
3733
|
CODEX_HOME: hostedCodexHome,
|
|
3602
3734
|
...scopedBrowserCapability ? { [CODEX_BROWSER_CAPABILITY_ENV]: scopedBrowserCapability } : {}
|
|
3603
3735
|
} : undefined;
|
|
3736
|
+
let vaultHook;
|
|
3737
|
+
try {
|
|
3738
|
+
vaultHook = await createCodexVaultHookBridge(opts.vaultUserId ?? opts.userId ?? "");
|
|
3739
|
+
} catch (err) {
|
|
3740
|
+
yield { type: "error", content: `Failed to initialize Codex Vault hooks: ${errMsg(err)}` };
|
|
3741
|
+
return;
|
|
3742
|
+
}
|
|
3604
3743
|
const codex = new Codex({
|
|
3744
|
+
codexPathOverride: vaultHook.codexPathOverride,
|
|
3605
3745
|
...codexEnvironment ? { env: codexEnvironment } : {},
|
|
3606
3746
|
config: {
|
|
3607
|
-
features: { multi_agent: false, multi_agent_v2: false, enable_fanout: false },
|
|
3747
|
+
features: { hooks: true, multi_agent: false, multi_agent_v2: false, enable_fanout: false },
|
|
3748
|
+
hooks: vaultHook.hooks,
|
|
3608
3749
|
model_catalog_json: codexModelCatalogPath,
|
|
3609
3750
|
mcp_servers: codexMcpServers,
|
|
3610
3751
|
...opts.toolPolicy ? { sandbox_permissions: [] } : {}
|
|
@@ -3708,7 +3849,7 @@ async function* codexProvider(opts) {
|
|
|
3708
3849
|
if (!item)
|
|
3709
3850
|
break;
|
|
3710
3851
|
if (item.type === "command_execution") {
|
|
3711
|
-
const command = String(item.command ?? "");
|
|
3852
|
+
const command = redactHostedSecrets(opts.vaultUserId ?? opts.userId ?? "", String(item.command ?? ""));
|
|
3712
3853
|
yield {
|
|
3713
3854
|
type: "tool_use",
|
|
3714
3855
|
name: "Bash",
|
|
@@ -3716,10 +3857,11 @@ async function* codexProvider(opts) {
|
|
|
3716
3857
|
toolUseId: String(item.id ?? "")
|
|
3717
3858
|
};
|
|
3718
3859
|
} else if (item.type === "mcp_tool_call") {
|
|
3860
|
+
const input = item.arguments && typeof item.arguments === "object" ? item.arguments : {};
|
|
3719
3861
|
yield {
|
|
3720
3862
|
type: "tool_use",
|
|
3721
3863
|
name: String(item.tool ?? "unknown"),
|
|
3722
|
-
input:
|
|
3864
|
+
input: deepMapStrings(input, (value) => redactHostedSecrets(opts.vaultUserId ?? opts.userId ?? "", value)),
|
|
3723
3865
|
toolUseId: String(item.id ?? "")
|
|
3724
3866
|
};
|
|
3725
3867
|
}
|
|
@@ -3762,7 +3904,7 @@ async function* codexProvider(opts) {
|
|
|
3762
3904
|
yield {
|
|
3763
3905
|
type: "tool_result",
|
|
3764
3906
|
toolUseId: String(item.id ?? ""),
|
|
3765
|
-
content: summarizeMcpToolCallResult(item),
|
|
3907
|
+
content: redactHostedSecrets(opts.vaultUserId ?? opts.userId ?? "", summarizeMcpToolCallResult(item)),
|
|
3766
3908
|
...isError ? { isError: true } : {}
|
|
3767
3909
|
};
|
|
3768
3910
|
} else if (item.type === "command_execution") {
|
|
@@ -3770,7 +3912,7 @@ async function* codexProvider(opts) {
|
|
|
3770
3912
|
yield {
|
|
3771
3913
|
type: "tool_result",
|
|
3772
3914
|
toolUseId: String(item.id ?? ""),
|
|
3773
|
-
content: String(item.aggregated_output ?? "").slice(0, 200),
|
|
3915
|
+
content: redactHostedSecrets(opts.vaultUserId ?? opts.userId ?? "", String(item.aggregated_output ?? "").slice(0, 200)),
|
|
3774
3916
|
...isError ? { isError: true } : {}
|
|
3775
3917
|
};
|
|
3776
3918
|
} else if (item.type === "file_change") {
|
|
@@ -3867,6 +4009,7 @@ async function* codexProvider(opts) {
|
|
|
3867
4009
|
abortSignal?.removeEventListener("abort", onAbortKill);
|
|
3868
4010
|
if (trackedPids.pids.length > 0)
|
|
3869
4011
|
unregisterOwnedCodexPids(trackedPids.pids);
|
|
4012
|
+
await vaultHook.close();
|
|
3870
4013
|
}
|
|
3871
4014
|
}
|
|
3872
4015
|
|
|
@@ -3874,7 +4017,7 @@ async function* codexProvider(opts) {
|
|
|
3874
4017
|
process.env.MAESTRO_SDK_SILENT_BOOTSTRAP ??= "1";
|
|
3875
4018
|
|
|
3876
4019
|
// ../../packages/core/src/agents/maestro-provider.ts
|
|
3877
|
-
import { resolve as
|
|
4020
|
+
import { resolve as resolve8 } from "path";
|
|
3878
4021
|
import { maestroProvider as sdkMaestroProvider, setMcpResolver } from "maestro-agent-sdk";
|
|
3879
4022
|
var MAESTRO_DEFAULT_MAX_TOKENS = 32768;
|
|
3880
4023
|
var PROVIDER_ASK_USER_TOOL = "AskUserQuestion";
|
|
@@ -3973,7 +4116,7 @@ function buildProviderOwnedToolBlockHook() {
|
|
|
3973
4116
|
}
|
|
3974
4117
|
};
|
|
3975
4118
|
}
|
|
3976
|
-
var MAESTRO_TOOL_OUTPUT_DIR =
|
|
4119
|
+
var MAESTRO_TOOL_OUTPUT_DIR = resolve8(RUN_DIR, "maestro-tool-outputs");
|
|
3977
4120
|
function buildMaestroToolResultTruncation(opts) {
|
|
3978
4121
|
if (opts.toolResultTruncation)
|
|
3979
4122
|
return opts.toolResultTruncation;
|
|
@@ -4008,16 +4151,16 @@ function maestroProvider(opts) {
|
|
|
4008
4151
|
// ../../packages/core/src/agents/claude-runtime-inspection.ts
|
|
4009
4152
|
import { readFileSync as readFileSync7 } from "fs";
|
|
4010
4153
|
import { createRequire as createRequire3 } from "module";
|
|
4011
|
-
import { dirname as
|
|
4154
|
+
import { dirname as dirname9, join as join8 } from "path";
|
|
4012
4155
|
var cached;
|
|
4013
4156
|
function inspectBundledClaudeRuntime() {
|
|
4014
4157
|
if (cached)
|
|
4015
4158
|
return cached;
|
|
4016
4159
|
try {
|
|
4017
4160
|
const require2 = createRequire3(import.meta.url);
|
|
4018
|
-
const sdkDir =
|
|
4019
|
-
const sdkPackage = JSON.parse(readFileSync7(
|
|
4020
|
-
const manifest = JSON.parse(readFileSync7(
|
|
4161
|
+
const sdkDir = dirname9(require2.resolve("@anthropic-ai/claude-agent-sdk"));
|
|
4162
|
+
const sdkPackage = JSON.parse(readFileSync7(join8(sdkDir, "package.json"), "utf8"));
|
|
4163
|
+
const manifest = JSON.parse(readFileSync7(join8(sdkDir, "manifest.json"), "utf8"));
|
|
4021
4164
|
const sdkVersion = typeof sdkPackage.version === "string" ? sdkPackage.version : "";
|
|
4022
4165
|
const claudeCodeVersion = typeof manifest.version === "string" ? manifest.version : "";
|
|
4023
4166
|
if (!sdkVersion || !claudeCodeVersion) {
|
|
@@ -4090,4 +4233,4 @@ export {
|
|
|
4090
4233
|
buildClaudeDisallowedTools
|
|
4091
4234
|
};
|
|
4092
4235
|
|
|
4093
|
-
//# debugId=
|
|
4236
|
+
//# debugId=5CF9F07311E89AE364756E2164756E21
|