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
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
import type { VaultCredentialHost } from "#mcp/factories/vault-host";
|
|
3
|
-
|
|
4
|
-
export interface VaultRunRequest {
|
|
5
|
-
command: string;
|
|
6
|
-
timeoutMs?: number;
|
|
7
|
-
maxOutputBytes?: number;
|
|
8
|
-
cwd?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface VaultRunResult {
|
|
12
|
-
ok: boolean;
|
|
13
|
-
exitCode: number | null;
|
|
14
|
-
signal: NodeJS.Signals | null;
|
|
15
|
-
stdout: string;
|
|
16
|
-
stderr: string;
|
|
17
|
-
truncated: boolean;
|
|
18
|
-
usedKeys: string[];
|
|
19
|
-
error?: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function appendBounded(
|
|
23
|
-
chunks: Buffer[],
|
|
24
|
-
chunk: Buffer,
|
|
25
|
-
state: { bytes: number; truncated: boolean },
|
|
26
|
-
maxBytes: number,
|
|
27
|
-
): void {
|
|
28
|
-
if (state.bytes >= maxBytes) {
|
|
29
|
-
state.truncated = true;
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const remaining = maxBytes - state.bytes;
|
|
33
|
-
const visible = chunk.subarray(0, remaining);
|
|
34
|
-
chunks.push(visible);
|
|
35
|
-
state.bytes += visible.byteLength;
|
|
36
|
-
if (visible.byteLength < chunk.byteLength) state.truncated = true;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/** Execute a placeholder-bearing shell command without exposing expanded input/output to the SDK. */
|
|
40
|
-
export async function executeVaultRun(
|
|
41
|
-
userId: string,
|
|
42
|
-
request: VaultRunRequest,
|
|
43
|
-
host: VaultCredentialHost,
|
|
44
|
-
): Promise<VaultRunResult> {
|
|
45
|
-
const substitution = host.substitute(userId, request.command);
|
|
46
|
-
if (substitution.usedKeys.length === 0) {
|
|
47
|
-
return {
|
|
48
|
-
ok: false,
|
|
49
|
-
exitCode: null,
|
|
50
|
-
signal: null,
|
|
51
|
-
stdout: "",
|
|
52
|
-
stderr: "",
|
|
53
|
-
truncated: false,
|
|
54
|
-
usedKeys: [],
|
|
55
|
-
error: "No valid Vault placeholder was found in command",
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const timeoutMs = Math.min(Math.max(request.timeoutMs ?? 120_000, 1_000), 600_000);
|
|
60
|
-
const maxOutputBytes = Math.min(
|
|
61
|
-
Math.max(request.maxOutputBytes ?? 512 * 1024, 1_024),
|
|
62
|
-
2 * 1024 * 1024,
|
|
63
|
-
);
|
|
64
|
-
const stdoutChunks: Buffer[] = [];
|
|
65
|
-
const stderrChunks: Buffer[] = [];
|
|
66
|
-
const stdoutState = { bytes: 0, truncated: false };
|
|
67
|
-
const stderrState = { bytes: 0, truncated: false };
|
|
68
|
-
const startedAt = Date.now();
|
|
69
|
-
|
|
70
|
-
return await new Promise<VaultRunResult>((resolve) => {
|
|
71
|
-
// Feed the expanded script over stdin so plaintext never appears in argv or
|
|
72
|
-
// the provider-visible tool input. zsh -s reads commands from standard input.
|
|
73
|
-
const child = spawn(process.env.SHELL || "/bin/sh", ["-s"], {
|
|
74
|
-
cwd: request.cwd,
|
|
75
|
-
detached: true,
|
|
76
|
-
env: process.env,
|
|
77
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
78
|
-
});
|
|
79
|
-
let settled = false;
|
|
80
|
-
let timedOut = false;
|
|
81
|
-
const signalTree = (signal: NodeJS.Signals) => {
|
|
82
|
-
if (!child.pid) return;
|
|
83
|
-
try {
|
|
84
|
-
process.kill(-child.pid, signal);
|
|
85
|
-
} catch {
|
|
86
|
-
try {
|
|
87
|
-
child.kill(signal);
|
|
88
|
-
} catch {
|
|
89
|
-
// The process tree already exited.
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const finish = (result: Omit<VaultRunResult, "usedKeys">) => {
|
|
95
|
-
if (settled) return;
|
|
96
|
-
settled = true;
|
|
97
|
-
clearTimeout(timeout);
|
|
98
|
-
host.log?.(
|
|
99
|
-
"info",
|
|
100
|
-
{
|
|
101
|
-
userId,
|
|
102
|
-
vaultKeys: substitution.usedKeys,
|
|
103
|
-
exitCode: result.exitCode,
|
|
104
|
-
signal: result.signal,
|
|
105
|
-
durationMs: Date.now() - startedAt,
|
|
106
|
-
timedOut,
|
|
107
|
-
},
|
|
108
|
-
"vault credential command used",
|
|
109
|
-
);
|
|
110
|
-
resolve({ ...result, usedKeys: substitution.usedKeys });
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
child.stdout.on("data", (chunk: Buffer) =>
|
|
114
|
-
appendBounded(stdoutChunks, chunk, stdoutState, maxOutputBytes),
|
|
115
|
-
);
|
|
116
|
-
child.stderr.on("data", (chunk: Buffer) =>
|
|
117
|
-
appendBounded(stderrChunks, chunk, stderrState, maxOutputBytes),
|
|
118
|
-
);
|
|
119
|
-
child.once("error", (error) => {
|
|
120
|
-
finish({
|
|
121
|
-
ok: false,
|
|
122
|
-
exitCode: null,
|
|
123
|
-
signal: null,
|
|
124
|
-
stdout: "",
|
|
125
|
-
stderr: "",
|
|
126
|
-
truncated: false,
|
|
127
|
-
error: host.redact(userId, error.message),
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
child.once("close", (exitCode, signal) => {
|
|
131
|
-
// vault_run is deliberately foreground-only. Clean up descendants a
|
|
132
|
-
// command attempted to leave behind so secrets do not linger in argv/env.
|
|
133
|
-
signalTree("SIGTERM");
|
|
134
|
-
const stdout = host.redact(userId, Buffer.concat(stdoutChunks).toString("utf8"));
|
|
135
|
-
const stderr = host.redact(userId, Buffer.concat(stderrChunks).toString("utf8"));
|
|
136
|
-
finish({
|
|
137
|
-
ok: !timedOut && exitCode === 0,
|
|
138
|
-
exitCode,
|
|
139
|
-
signal,
|
|
140
|
-
stdout,
|
|
141
|
-
stderr,
|
|
142
|
-
truncated: stdoutState.truncated || stderrState.truncated,
|
|
143
|
-
...(timedOut ? { error: `Command timed out after ${timeoutMs}ms` } : {}),
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
const timeout = setTimeout(() => {
|
|
148
|
-
timedOut = true;
|
|
149
|
-
signalTree("SIGKILL");
|
|
150
|
-
}, timeoutMs);
|
|
151
|
-
|
|
152
|
-
child.stdin.end(substitution.text);
|
|
153
|
-
});
|
|
154
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { VaultEntry, VaultSubstitutionResult } from "../../storage/vault";
|
|
2
|
-
export interface VaultCredentialHost {
|
|
3
|
-
list(userId: string): readonly VaultEntry[];
|
|
4
|
-
substitute(userId: string, text: string): VaultSubstitutionResult;
|
|
5
|
-
redact(userId: string, text: string): string;
|
|
6
|
-
log?(level: "info" | "warn", details: Record<string, unknown>, message: string): void;
|
|
7
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { VaultCredentialHost } from "./factories/vault-host";
|
|
2
|
-
export interface VaultHttpRequest {
|
|
3
|
-
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
4
|
-
url: string;
|
|
5
|
-
headers?: Record<string, string>;
|
|
6
|
-
body?: string;
|
|
7
|
-
timeoutMs?: number;
|
|
8
|
-
maxResponseBytes?: number;
|
|
9
|
-
}
|
|
10
|
-
export interface VaultHttpResult {
|
|
11
|
-
ok: boolean;
|
|
12
|
-
status?: number;
|
|
13
|
-
statusText?: string;
|
|
14
|
-
headers?: Record<string, string>;
|
|
15
|
-
body?: string;
|
|
16
|
-
truncated?: boolean;
|
|
17
|
-
error?: string;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Execute an HTTPS request inside the credential boundary. The caller supplies
|
|
21
|
-
* only {{KEY}} references; expanded headers/body never leave this function.
|
|
22
|
-
*/
|
|
23
|
-
export declare function executeVaultHttpRequest(userId: string, request: VaultHttpRequest, host: VaultCredentialHost, fetchImpl?: typeof fetch): Promise<VaultHttpResult>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { VaultCredentialHost } from "./factories/vault-host";
|
|
2
|
-
export interface VaultRunRequest {
|
|
3
|
-
command: string;
|
|
4
|
-
timeoutMs?: number;
|
|
5
|
-
maxOutputBytes?: number;
|
|
6
|
-
cwd?: string;
|
|
7
|
-
}
|
|
8
|
-
export interface VaultRunResult {
|
|
9
|
-
ok: boolean;
|
|
10
|
-
exitCode: number | null;
|
|
11
|
-
signal: NodeJS.Signals | null;
|
|
12
|
-
stdout: string;
|
|
13
|
-
stderr: string;
|
|
14
|
-
truncated: boolean;
|
|
15
|
-
usedKeys: string[];
|
|
16
|
-
error?: string;
|
|
17
|
-
}
|
|
18
|
-
/** Execute a placeholder-bearing shell command without exposing expanded input/output to the SDK. */
|
|
19
|
-
export declare function executeVaultRun(userId: string, request: VaultRunRequest, host: VaultCredentialHost): Promise<VaultRunResult>;
|