@jini-ai/agent-runtime 0.4.12 → 0.6.11
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/CHANGELOG.md +91 -1
- package/dist/claude-filesystem-policy.d.ts +46 -0
- package/dist/claude-filesystem-policy.js +121 -0
- package/dist/claude-stream.d.ts +2 -0
- package/dist/claude-stream.js +4 -0
- package/dist/defs/claude.d.ts +2 -2
- package/dist/defs/claude.js +26 -2
- package/dist/defs/shared.d.ts +12 -8
- package/dist/defs/shared.js +14 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/providers/tool-turn-types.d.ts +21 -0
- package/dist/providers/tool-turn.js +12 -5
- package/dist/types.d.ts +8 -0
- package/package.json +9 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,94 @@
|
|
|
1
|
+
## 0.6.11
|
|
2
|
+
|
|
3
|
+
### Patch Changes
|
|
4
|
+
|
|
5
|
+
- Site agents are confined to the site folder: Claude file tools are bounded to the site root and private temp dir, and attachments are staged inside the site (`stageAttachmentClaim`).
|
|
6
|
+
- Updated dependencies
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @jini-ai/core@0.6.11
|
|
10
|
+
- @jini-ai/oauth@0.6.11
|
|
11
|
+
- @jini-ai/protocol@0.6.11
|
|
12
|
+
|
|
13
|
+
## 0.6.10
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 3fe4d14: Parse optional delegated-result markers while preserving the CLI call id and original content for daemon validation.
|
|
18
|
+
|
|
19
|
+
Require the co-released protocol package at runtime for its shared marker codec, replacing the optional protocol peer. The workspace dependency follows the protocol release version when Changesets versions the release set.
|
|
20
|
+
|
|
21
|
+
- aad3d2e: Add the optional `onUnexposedToolCall` refusal hook to `runProviderToolTurn` for all four
|
|
22
|
+
provider protocols. Hosts can await audit writes and supply uniform refusal text without
|
|
23
|
+
calling the normal tool executor. Results remain errors; omitted hooks and `undefined`
|
|
24
|
+
replies preserve the existing refusal text and protocol formatting. Hook failures propagate
|
|
25
|
+
without falling through to execution.
|
|
26
|
+
- 8ff5653: Drive Antigravity (`agy`) — the 24th and last agent definition `AgentExecutor` rejected.
|
|
27
|
+
|
|
28
|
+
`AgentExecutor` drove 23 of 24 registered definitions. Antigravity was rejected by an explicit
|
|
29
|
+
`def.id === 'antigravity'` guard, for two reasons that are real but narrow:
|
|
30
|
+
|
|
31
|
+
- **`agy` can print an OAuth sign-in URL to stdout and still exit 0.** Streaming stdout live shows
|
|
32
|
+
that URL to the user as if it were the model's reply — a URL that carries the daemon operator's
|
|
33
|
+
`client_id`/`redirect_uri` into a chat transcript, and that is useless to click anyway (`agy -p`
|
|
34
|
+
print mode has no field to paste the resulting auth code into).
|
|
35
|
+
- **`agy` has no `--model` flag.** The model choice is written into one process-global
|
|
36
|
+
`~/.gemini/antigravity-cli/settings.json` that `agy` reads on its own startup, so two concurrent
|
|
37
|
+
runs race: run A writes model A, A spawns, B writes model B, and only _then_ does A's `agy` read
|
|
38
|
+
the file — so A silently executes on B's model.
|
|
39
|
+
|
|
40
|
+
Both are now met by **declarative `RuntimeAgentDef` fields the executor reads generically**, joining
|
|
41
|
+
the 14 optional behavior flags (`promptViaFile`, `authProbe`, …) that already work this way. There is
|
|
42
|
+
no agent-id branch anywhere in the dispatch path — a deliberate divergence from Open Design's own
|
|
43
|
+
daemon, which hardcodes the id twice.
|
|
44
|
+
|
|
45
|
+
New on `@jini-ai/agent-runtime`'s `RuntimeAgentDef`:
|
|
46
|
+
|
|
47
|
+
- `needsAgentLogFile?: boolean` — asks the caller to stage a temp path and pass it as
|
|
48
|
+
`RuntimeContext.agentLogFilePath` before `buildArgs` runs, mirroring `promptViaFile`. Staged by the
|
|
49
|
+
new `prepareAgentLogFile(def, label)` (the sibling of `preparePromptFileForAgent`; it creates only
|
|
50
|
+
the `0o700` containing directory, since the log file is output the CLI authors, not input we do).
|
|
51
|
+
- `stdoutPolicy?: RuntimeStdoutPolicy` — `{buffering: 'live'}` (the default, and every other
|
|
52
|
+
definition's behavior) or `{buffering: 'until-close', sanitize?}`. A discriminated union rather
|
|
53
|
+
than two flat fields on purpose: a sanitizer is only meaningful on the buffered path, because the
|
|
54
|
+
pattern to redact can straddle two `'data'` chunks. Two independent flags would let a definition
|
|
55
|
+
declare a sanitizer the caller could not honor — a confidentiality gap that _looks_ closed.
|
|
56
|
+
- `runtimeLock?: RuntimeLock` — a mutex around a process-global side effect `buildArgs` performs.
|
|
57
|
+
Acquired before `buildArgs`, released on whichever of `waitForHandoff` settling or process exit
|
|
58
|
+
comes first. Releasing on exit is load-bearing, not a fallback: a watcher that stops polling means
|
|
59
|
+
"I stopped watching", never "the child definitely didn't read the file".
|
|
60
|
+
|
|
61
|
+
All three are stripped from the `DetectedAgent` registry projection. They instruct whoever _spawns_
|
|
62
|
+
the CLI, not whoever lists agents — and two carry closures, which `JSON.stringify` would flatten into
|
|
63
|
+
a misleading `{"buffering":"until-close"}` / `{}` rather than omit.
|
|
64
|
+
|
|
65
|
+
In `@jini-ai/daemon`, `AgentExecutor` now stages a log file when `needsAgentLogFile` is set (released
|
|
66
|
+
on every pre-spawn, spawn-failure, and close path alongside the prompt file, through one composed
|
|
67
|
+
`cleanupStagedFiles` closure), calls `runtimeLock.acquire()` before `buildArgs`, and branches its
|
|
68
|
+
`streamFormat: 'plain'` stdout handling on `stdoutPolicy`. `assessAgentExecutorCompatibility` no
|
|
69
|
+
longer rejects anything by id, and `isAgentExecutorSupported` now accepts all 24 definitions.
|
|
70
|
+
|
|
71
|
+
**No behavior change for any other agent.** Antigravity is the only definition declaring any of the
|
|
72
|
+
three fields; the other four `streamFormat: 'plain'` definitions (`grok-build`, `aider`, `deepseek`,
|
|
73
|
+
`qwen`) keep streaming live, per chunk, which `aider`'s and `deepseek`'s own comments call out as
|
|
74
|
+
deliberate. That is pinned by an explicit regression test rather than left implied.
|
|
75
|
+
|
|
76
|
+
One thing worth knowing if you consume the run event stream: on the buffered path the raw `'stdout'`
|
|
77
|
+
echo is held back and sanitized too, not just the `'agent'`/`text_delta` copy. Emitting an
|
|
78
|
+
unsanitized raw echo while withholding the chat copy would leak the exact string the sanitizer exists
|
|
79
|
+
to remove to any subscriber. The opt-in byte journal still records raw bytes per chunk — that is its
|
|
80
|
+
documented contract, and it deliberately lives in a separate `EventLog` instance that is never
|
|
81
|
+
replayed to run-event subscribers.
|
|
82
|
+
|
|
83
|
+
- e16a907: Add optional adapter-owned usageCostBasis metadata; Claude declares that its reported dollars are cumulative within a session.
|
|
84
|
+
- Updated dependencies [22f0619]
|
|
85
|
+
- Updated dependencies [82ed2d3]
|
|
86
|
+
- Updated dependencies [3fe4d14]
|
|
87
|
+
- Updated dependencies [5a3de86]
|
|
88
|
+
- @jini-ai/core@0.6.10
|
|
89
|
+
- @jini-ai/protocol@0.6.10
|
|
90
|
+
- @jini-ai/oauth@0.6.10
|
|
91
|
+
|
|
1
92
|
## 0.4.12 — 2026-10-22
|
|
2
93
|
|
|
3
94
|
- 2026-10-22: Probe-gated chromeIntegration build option, declarative supportsSubagents, network-capture and asset-harvest fixes, coverage.
|
|
@@ -67,7 +158,6 @@
|
|
|
67
158
|
- Model catalog clocks use core `Clock.nowMs()`; ACP unknown-value records are named `UnknownRecord`, not JSON objects.
|
|
68
159
|
- Callback payload caches use the main bounded store while retaining exclusive TTL and unref timer behavior. Neutralize host-settings wording and host identity comments. Drop the conversion report from published files; the document remains for later relocation.
|
|
69
160
|
|
|
70
|
-
|
|
71
161
|
- Preserve host environment customization after CLI housekeeping; correct the hook documentation.
|
|
72
162
|
- Keep DNS resolver injection required and reject lookup failures or empty answers instead of allowing unpinned fallback.
|
|
73
163
|
- Validate model catalogue variants with an explicit `TypeError` before trimming.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { execAgentFile } from './invocation.js';
|
|
2
|
+
import type { RuntimeBuildOptions } from './types.js';
|
|
3
|
+
/** Canonical host directory and attachment grants, checked again after image augmentation.
|
|
4
|
+
* Throws before spawn on missing/non-directory roots, conflicting cwd, traversal or symlinks.
|
|
5
|
+
* Reuses the platform reader's containment owner; O(n) filesystem checks for n supplied paths.
|
|
6
|
+
*/
|
|
7
|
+
export declare function validateFilesystemLaunch(required: {
|
|
8
|
+
filesystemRoot: string;
|
|
9
|
+
cwd: string;
|
|
10
|
+
extraAllowedDirs?: readonly string[];
|
|
11
|
+
imagePaths?: readonly string[];
|
|
12
|
+
}, _optional?: {}): string;
|
|
13
|
+
/** Probe official CLI enforcement, retrying uncertain evidence once without logging its values.
|
|
14
|
+
* The 2.1.285 floor covers native read blocking and admin-required sandbox locks.
|
|
15
|
+
* https://code.claude.com/docs/en/sandboxing#repository-settings-under-an-admin-required-sandbox
|
|
16
|
+
* True means supported, false means known unsupported, undefined means apply settings optimistically.
|
|
17
|
+
* O(1) metadata I/O and at most two bounded subprocesses per CLI path/mtime.
|
|
18
|
+
*/
|
|
19
|
+
export declare function assertClaudeFilesystemSupport(required: {
|
|
20
|
+
agentId: string;
|
|
21
|
+
launchPath: string;
|
|
22
|
+
env: NodeJS.ProcessEnv;
|
|
23
|
+
}, { probe }?: {
|
|
24
|
+
probe?: typeof execAgentFile;
|
|
25
|
+
}): Promise<boolean | void>;
|
|
26
|
+
/** Runtime assets under a denied home remain readable, never writable. Native installs need the
|
|
27
|
+
* binary; npm installs also need their adjacent package resources. O(1), canonical filesystem I/O.
|
|
28
|
+
*/
|
|
29
|
+
export declare function claudeFilesystemRuntimePaths(required: {
|
|
30
|
+
launchPath: string;
|
|
31
|
+
}, _optional?: {}): readonly string[];
|
|
32
|
+
/** Host settings override widening fields even when a Full CLI grant is enabled.
|
|
33
|
+
* Personal/project layers are excluded separately. Preserve host hooks and secret denies.
|
|
34
|
+
* Phase 1 leaves network policy unconfigured; the CLI's sandbox network defaults still apply.
|
|
35
|
+
* https://code.claude.com/docs/en/permissions#working-directories
|
|
36
|
+
* O(s + r) serialization for s host settings bytes and r runtime exception paths. Pure with
|
|
37
|
+
* injectable host facts; errors reject malformed/file-based settings rather than dropping policy.
|
|
38
|
+
*/
|
|
39
|
+
export declare function claudeFilesystemSettings(required: {
|
|
40
|
+
options: RuntimeBuildOptions;
|
|
41
|
+
}, { platform, homeDir, tempDir, }?: {
|
|
42
|
+
platform?: NodeJS.Platform;
|
|
43
|
+
homeDir?: string;
|
|
44
|
+
tempDir?: string;
|
|
45
|
+
}): string;
|
|
46
|
+
//# sourceMappingURL=claude-filesystem-policy.d.ts.map
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { realpathSync, statSync } from 'node:fs';
|
|
2
|
+
import { homedir, tmpdir } from 'node:os';
|
|
3
|
+
import { basename, dirname, isAbsolute, relative, resolve } from 'node:path';
|
|
4
|
+
import { createGuardedFileReader, createNodeGuardedReaderFilesystem } from '@jini-ai/platform/fs/guarded-reader';
|
|
5
|
+
import { execAgentFile } from './invocation.js';
|
|
6
|
+
/** Canonical host directory and attachment grants, checked again after image augmentation.
|
|
7
|
+
* Throws before spawn on missing/non-directory roots, conflicting cwd, traversal or symlinks.
|
|
8
|
+
* Reuses the platform reader's containment owner; O(n) filesystem checks for n supplied paths.
|
|
9
|
+
*/
|
|
10
|
+
export function validateFilesystemLaunch(required, _optional = {}) {
|
|
11
|
+
if (!isAbsolute(required.filesystemRoot))
|
|
12
|
+
throw new Error('filesystemRoot must be an absolute directory');
|
|
13
|
+
const root = realpathSync(required.filesystemRoot);
|
|
14
|
+
if (!statSync(root).isDirectory())
|
|
15
|
+
throw new Error('filesystemRoot must be a directory');
|
|
16
|
+
if (realpathSync(required.cwd) !== root)
|
|
17
|
+
throw new Error('Working directory must equal filesystemRoot');
|
|
18
|
+
const reader = createGuardedFileReader({ rootPath: root, filesystem: createNodeGuardedReaderFilesystem({}),
|
|
19
|
+
denyRules: { segments: new Set(), filenamePatterns: [] },
|
|
20
|
+
limits: { maxFileBytes: 1, binarySniffBytes: 1, maxListedFiles: 1, maxWalkDepth: 32, maxWalkEntries: 1 },
|
|
21
|
+
});
|
|
22
|
+
for (const path of [...(required.extraAllowedDirs ?? []), ...(required.imagePaths ?? [])]) {
|
|
23
|
+
// Canonicalize first: root is a realpath, so a symlinked component such as macOS /var would
|
|
24
|
+
// otherwise make every in-site path look outside. A broken link throws here and is refused.
|
|
25
|
+
reader.resolve({ relativePath: relative(root, realpathSync(resolve(required.cwd, path))) || '.' });
|
|
26
|
+
}
|
|
27
|
+
return root;
|
|
28
|
+
}
|
|
29
|
+
// Cache concurrent and subsequent launches by executable identity for the process lifetime.
|
|
30
|
+
const filesystemSupport = new Map();
|
|
31
|
+
/** Probe official CLI enforcement, retrying uncertain evidence once without logging its values.
|
|
32
|
+
* The 2.1.285 floor covers native read blocking and admin-required sandbox locks.
|
|
33
|
+
* https://code.claude.com/docs/en/sandboxing#repository-settings-under-an-admin-required-sandbox
|
|
34
|
+
* True means supported, false means known unsupported, undefined means apply settings optimistically.
|
|
35
|
+
* O(1) metadata I/O and at most two bounded subprocesses per CLI path/mtime.
|
|
36
|
+
*/
|
|
37
|
+
export async function assertClaudeFilesystemSupport(required, { probe = execAgentFile } = {}) {
|
|
38
|
+
if (required.agentId !== 'claude' || /^openclaude(?:\.|$)/i.test(basename(required.launchPath)))
|
|
39
|
+
return false;
|
|
40
|
+
let key;
|
|
41
|
+
try {
|
|
42
|
+
key = `${realpathSync(required.launchPath)}:${statSync(required.launchPath).mtimeMs}`;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
let pending = filesystemSupport.get(key);
|
|
48
|
+
if (!pending) {
|
|
49
|
+
pending = probeFilesystemSupport({ ...required, probe }, {});
|
|
50
|
+
filesystemSupport.set(key, pending);
|
|
51
|
+
}
|
|
52
|
+
return pending;
|
|
53
|
+
}
|
|
54
|
+
/** Unknown/failed evidence is retried with a longer budget; no diagnostic includes CLI output.
|
|
55
|
+
* O(1), at most 20 seconds across both probes; no subprocess output escapes this boundary.
|
|
56
|
+
*/
|
|
57
|
+
async function probeFilesystemSupport(required, _optional = {}) {
|
|
58
|
+
for (const timeout of [5000, 15000]) {
|
|
59
|
+
try {
|
|
60
|
+
const { stdout } = await required.probe({ command: required.launchPath, args: ['--version'] }, {
|
|
61
|
+
options: { env: required.env, timeout },
|
|
62
|
+
});
|
|
63
|
+
const version = /^(\d+)\.(\d+)\.(\d+)\s+\(Claude Code\)\s*$/.exec(String(stdout).trim());
|
|
64
|
+
if (version)
|
|
65
|
+
return supportedClaudeVersion({ version }, {});
|
|
66
|
+
}
|
|
67
|
+
catch { /* Retry once; uncertainty must not remove the owner's ability to launch. */ }
|
|
68
|
+
}
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
/** Compare the already parsed official version tuple against the enforcement floor. Pure, O(1). */
|
|
72
|
+
function supportedClaudeVersion({ version }, _optional = {}) {
|
|
73
|
+
const major = Number(version[1]), minor = Number(version[2]), patch = Number(version[3]);
|
|
74
|
+
if (major !== 2)
|
|
75
|
+
return major > 2;
|
|
76
|
+
if (minor !== 1)
|
|
77
|
+
return minor > 1;
|
|
78
|
+
return patch >= 285;
|
|
79
|
+
}
|
|
80
|
+
/** Runtime assets under a denied home remain readable, never writable. Native installs need the
|
|
81
|
+
* binary; npm installs also need their adjacent package resources. O(1), canonical filesystem I/O.
|
|
82
|
+
*/
|
|
83
|
+
export function claudeFilesystemRuntimePaths(required, _optional = {}) {
|
|
84
|
+
const executable = realpathSync(required.launchPath);
|
|
85
|
+
const assets = /\.[cm]?js$/.test(executable) ? dirname(executable) : executable;
|
|
86
|
+
return [...new Set([resolve(required.launchPath), assets, realpathSync(process.execPath)])];
|
|
87
|
+
}
|
|
88
|
+
/** Host settings override widening fields even when a Full CLI grant is enabled.
|
|
89
|
+
* Personal/project layers are excluded separately. Preserve host hooks and secret denies.
|
|
90
|
+
* Phase 1 leaves network policy unconfigured; the CLI's sandbox network defaults still apply.
|
|
91
|
+
* https://code.claude.com/docs/en/permissions#working-directories
|
|
92
|
+
* O(s + r) serialization for s host settings bytes and r runtime exception paths. Pure with
|
|
93
|
+
* injectable host facts; errors reject malformed/file-based settings rather than dropping policy.
|
|
94
|
+
*/
|
|
95
|
+
export function claudeFilesystemSettings(required, { platform = process.platform, homeDir = homedir(), tempDir = tmpdir(), } = {}) {
|
|
96
|
+
const { options } = required;
|
|
97
|
+
const settings = options.settings ? JSON.parse(options.settings) : {};
|
|
98
|
+
if (!settings || typeof settings !== 'object' || Array.isArray(settings))
|
|
99
|
+
throw new Error('Host settings must be a JSON object');
|
|
100
|
+
const permissions = settings.permissions;
|
|
101
|
+
return JSON.stringify({ ...settings, autoMemoryEnabled: false,
|
|
102
|
+
permissions: { ...permissions, blockReadsOutsideWorkingDirectories: true, additionalDirectories: [] },
|
|
103
|
+
sandbox: { enabled: platform !== 'win32', failIfUnavailable: platform !== 'win32',
|
|
104
|
+
allowUnsandboxedCommands: platform === 'win32', excludedCommands: [],
|
|
105
|
+
filesystem: filesystemSandboxPaths({ options, homeDir, tempDir }, {}),
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
/** Build explicit filesystem exceptions; shared temp and the rest of home remain denied.
|
|
110
|
+
* Pure, O(r + t) for r runtime paths and t shared temp roots; no filesystem access.
|
|
111
|
+
*/
|
|
112
|
+
function filesystemSandboxPaths({ options, homeDir, tempDir }, _optional = {}) {
|
|
113
|
+
const privateTemp = options.filesystemTempDir ?? resolve(options.filesystemRoot, '.agent-runtime', 'tmp');
|
|
114
|
+
const sharedTempRoots = [...new Set(['/tmp', '/private/tmp', tempDir, ...(options.filesystemSharedTempRoots ?? [])])];
|
|
115
|
+
return { denyRead: [homeDir, ...sharedTempRoots],
|
|
116
|
+
// Owner 2026-10-23: git config is a read-only infrastructure exception, never all of home.
|
|
117
|
+
allowRead: [options.filesystemRoot, privateTemp, resolve(homeDir, '.gitconfig'),
|
|
118
|
+
resolve(homeDir, '.config/git/config'), ...(options.filesystemRuntimeReadPaths ?? [])],
|
|
119
|
+
allowWrite: [options.filesystemRoot, privateTemp] };
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=claude-filesystem-policy.js.map
|
package/dist/claude-stream.d.ts
CHANGED
package/dist/claude-stream.js
CHANGED
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
* a larger, riskier change than this pass makes. They stay as closures,
|
|
37
37
|
* exercised only through `feed`/`flush` in the test suite.
|
|
38
38
|
*/
|
|
39
|
+
import { readDelegatedResult } from '@jini-ai/protocol';
|
|
39
40
|
import { createRoleMarkerGuard } from './role-marker-guard.js';
|
|
40
41
|
import { createClaudeSegmentUsage } from './claude-segment-usage.js';
|
|
41
42
|
function isRecord(value) {
|
|
@@ -306,10 +307,13 @@ export function handleUserMessage(obj, onEvent) {
|
|
|
306
307
|
if (!isRecord(block))
|
|
307
308
|
continue;
|
|
308
309
|
if (block.type === 'tool_result') {
|
|
310
|
+
const delegated = readDelegatedResult({ content: block.content });
|
|
309
311
|
onEvent({
|
|
310
312
|
type: 'tool_result',
|
|
311
313
|
toolUseId: block.tool_use_id,
|
|
314
|
+
// Keep original pixels until the daemon verifies the run, outcome and digest.
|
|
312
315
|
content: stringifyToolResult(block.content),
|
|
316
|
+
...(delegated ? { delegatedToolUseId: delegated.marker.toolUseId, delegatedResultContent: delegated.content } : {}),
|
|
313
317
|
isError: Boolean(block.is_error),
|
|
314
318
|
});
|
|
315
319
|
}
|
package/dist/defs/claude.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RuntimeBuildOptions } from '../types.js';
|
|
1
|
+
import type { RuntimeBuildOptions, RuntimeContext } from '../types.js';
|
|
2
2
|
export declare const claudeAgentDef: {
|
|
3
3
|
id: string;
|
|
4
4
|
supportsNativeToolAccess: true;
|
|
@@ -37,7 +37,7 @@ export declare const claudeAgentDef: {
|
|
|
37
37
|
}, { extraAllowedDirs, options, runtimeContext }?: {
|
|
38
38
|
extraAllowedDirs?: string[];
|
|
39
39
|
options?: RuntimeBuildOptions;
|
|
40
|
-
runtimeContext?:
|
|
40
|
+
runtimeContext?: RuntimeContext;
|
|
41
41
|
} | undefined) => string[];
|
|
42
42
|
promptViaStdin: true;
|
|
43
43
|
promptInputFormat: "stream-json";
|
package/dist/defs/claude.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { resolveNativeCapabilityDenies, resolveNativeToolDenies } from '../native-tool-policy.js';
|
|
2
|
+
import { claudeFilesystemSettings, validateFilesystemLaunch } from '../claude-filesystem-policy.js';
|
|
2
3
|
import { createAgentModelDiscovery } from '../model-discovery-native.js';
|
|
3
4
|
/**
|
|
4
5
|
* Claude Code has no dedicated image-attachment flag. imageDelivery: 'prompt-path' makes the
|
|
5
6
|
* executor append local image paths to the prompt and add their directories to extraAllowedDirs;
|
|
6
7
|
* buildArgs then grants --add-dir access so the CLI can read them itself. Native-delivery defs
|
|
7
8
|
* must not also receive this augmentation; see RuntimeAgentDef.imageDelivery for that contract.
|
|
9
|
+
* A filesystemRoot launch instead validates these directories and omits --add-dir entirely;
|
|
10
|
+
* hosts must stage attachments inside that root (owner boundary introduced 2026-10-23).
|
|
8
11
|
*/
|
|
9
12
|
import { addDirArgs, nonDefaultFlag, permissionModeArgs, resolveCapabilities, sessionArgs } from './claude-compatible-args.js';
|
|
10
13
|
import { buildClaudeMcpConfigArgs, DEFAULT_MODEL_OPTION } from './shared.js';
|
|
@@ -103,6 +106,9 @@ function claudeSettingSourcesArgs({ options, caps }) {
|
|
|
103
106
|
// This is an explicit restriction, not an optional enhancement: do not probe it away.
|
|
104
107
|
return ['--setting-sources', '', '--disable-slash-commands'];
|
|
105
108
|
}
|
|
109
|
+
// An explicit empty source list is a host isolation policy, not an optional enhancement.
|
|
110
|
+
if (options.filesystemRoot || options.settingSources?.length === 0)
|
|
111
|
+
return ['--setting-sources', ''];
|
|
106
112
|
if (options.settingSources !== undefined && caps.settingSources) {
|
|
107
113
|
return ['--setting-sources', options.settingSources.join(',')];
|
|
108
114
|
}
|
|
@@ -116,6 +122,19 @@ function claudeChromeArgs({ options, caps }) {
|
|
|
116
122
|
return [];
|
|
117
123
|
return [options.chromeIntegration ? '--chrome' : '--no-chrome'];
|
|
118
124
|
}
|
|
125
|
+
/** Resolve the mandatory filesystem settings as one launch fragment, independently of parity.
|
|
126
|
+
* Native file reads keep today's tool set; outside attachment grants fail before argv exists.
|
|
127
|
+
* O(n) containment checks for n attachment paths, plus host-settings serialization.
|
|
128
|
+
*/
|
|
129
|
+
function claudeLaunchPolicy({ options, caps, extraAllowedDirs, imagePaths, runtimeContext }, _optional = {}) {
|
|
130
|
+
if (options.filesystemRoot !== undefined) {
|
|
131
|
+
validateFilesystemLaunch({ filesystemRoot: options.filesystemRoot, cwd: runtimeContext.cwd ?? options.filesystemRoot,
|
|
132
|
+
extraAllowedDirs, imagePaths }, {});
|
|
133
|
+
return { directoryArgs: [], settingsArgs: ['--settings', claudeFilesystemSettings({ options }, {})] };
|
|
134
|
+
}
|
|
135
|
+
return { directoryArgs: addDirArgs({ extraAllowedDirs, caps }),
|
|
136
|
+
settingsArgs: options.settings ? ['--settings', options.settings] : [] };
|
|
137
|
+
}
|
|
119
138
|
export const claudeAgentDef = {
|
|
120
139
|
...createAgentModelDiscovery('claude', { fallbackModels: () => claudeAgentDef.fallbackModels }),
|
|
121
140
|
id: 'claude',
|
|
@@ -212,6 +231,7 @@ export const claudeAgentDef = {
|
|
|
212
231
|
// cursor/qwen entries below.
|
|
213
232
|
buildArgs: (_requiredArgs, { extraAllowedDirs = [], options = {}, runtimeContext = {} } = {}) => {
|
|
214
233
|
const caps = resolveCapabilities({ agentId: 'claude', options });
|
|
234
|
+
const policy = claudeLaunchPolicy({ options, caps, extraAllowedDirs, imagePaths: _requiredArgs.imagePaths, runtimeContext }, {});
|
|
215
235
|
return [
|
|
216
236
|
// `--input-format stream-json` lets the daemon stream multiple JSONL
|
|
217
237
|
// messages into stdin instead of closing it after the initial prompt,
|
|
@@ -227,7 +247,7 @@ export const claudeAgentDef = {
|
|
|
227
247
|
...claudeEffortArgs({ options, caps }),
|
|
228
248
|
// `--add-dir` is older but still gate it for symmetry — old/forked
|
|
229
249
|
// builds may lack it.
|
|
230
|
-
...
|
|
250
|
+
...policy.directoryArgs,
|
|
231
251
|
// `--append-system-prompt` delivery now lives outside this function — see
|
|
232
252
|
// `systemPromptDelivery` below and `@jini-ai/daemon`'s `resolveSystemPromptOverlayDelivery`
|
|
233
253
|
// (the single dispatch point for every def, not just this one). The probe-gate reasoning
|
|
@@ -237,6 +257,10 @@ export const claudeAgentDef = {
|
|
|
237
257
|
// itself.
|
|
238
258
|
// Continue Claude's own CLI session across turns (see `sessionArgs`).
|
|
239
259
|
...sessionArgs(runtimeContext),
|
|
260
|
+
// The permission mode is unchanged for folder-limited runs: blockReadsOutsideWorkingDirectories
|
|
261
|
+
// and the Bash sandbox hold in every mode, including bypassPermissions (verified live on
|
|
262
|
+
// 2.1.309, 2026-10-23). dontAsk would deny Edit/Write and every MCP tool, because the CLI skips
|
|
263
|
+
// an unanchored `--allowedTools '*'` (permissions docs, "Tool name wildcards").
|
|
240
264
|
...permissionModeArgs(options),
|
|
241
265
|
// Explicit `--strict-mcp-config --mcp-config <path>` instead of relying on Claude Code's
|
|
242
266
|
// auto-discovery of `.mcp.json` from cwd. Shared with every other `'claude-mcp-json'` def —
|
|
@@ -247,7 +271,7 @@ export const claudeAgentDef = {
|
|
|
247
271
|
...claudeToolPolicyArgs(options),
|
|
248
272
|
...claudeSettingSourcesArgs({ options, caps }),
|
|
249
273
|
// See `RuntimeBuildOptions.settings`. Not probe-gated: `--settings` long predates `--setting-sources`.
|
|
250
|
-
...
|
|
274
|
+
...policy.settingsArgs,
|
|
251
275
|
...claudeChromeArgs({ options, caps }),
|
|
252
276
|
];
|
|
253
277
|
},
|
package/dist/defs/shared.d.ts
CHANGED
|
@@ -14,6 +14,15 @@ import { execAgentFile } from '../invocation.js';
|
|
|
14
14
|
import { DEFAULT_MODEL_OPTION } from '../models.js';
|
|
15
15
|
import type { RuntimeContext, RuntimeModelOption } from '../types.js';
|
|
16
16
|
export { detectAcpModels, parsePiModels, execAgentFile, DEFAULT_MODEL_OPTION };
|
|
17
|
+
type ClaudeMcpOptions = {
|
|
18
|
+
filesystemRoot?: string;
|
|
19
|
+
cliParity?: boolean;
|
|
20
|
+
permissionMode?: string;
|
|
21
|
+
nativeToolAccess?: boolean;
|
|
22
|
+
nativeCapabilities?: {
|
|
23
|
+
userMcp?: boolean;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
17
26
|
/**
|
|
18
27
|
* The argv every `externalMcpInjection: 'claude-mcp-json'` def appends so the caller-staged
|
|
19
28
|
* `.mcp.json` is loaded *explicitly* rather than auto-discovered from cwd.
|
|
@@ -39,19 +48,14 @@ export { detectAcpModels, parsePiModels, execAgentFile, DEFAULT_MODEL_OPTION };
|
|
|
39
48
|
* it is present only when the caller is actually staging that file for this run (see
|
|
40
49
|
* `RuntimeContext.mcpJsonPath`'s own doc), so an unconfigured host gets `[]` and no argv change.
|
|
41
50
|
* Trusted bypass parity omits strict isolation so user MCP/Chrome settings remain available.
|
|
51
|
+
* Owner 2026-10-23: filesystemRoot keeps the explicit personal-MCP opt-in; those servers are
|
|
52
|
+
* outside the folder boundary. OFF still stays strict (the default grant).
|
|
42
53
|
* Explicit --mcp-config still avoids a headless trust prompt. A locked run without a staged
|
|
43
54
|
* config gets --strict-mcp-config alone, exposing no auto-discovered MCP servers.
|
|
44
55
|
* @complexity O(1).
|
|
45
56
|
* @overallScore 100/100
|
|
46
57
|
*/
|
|
47
|
-
export declare function buildClaudeMcpConfigArgs(runtimeContext: RuntimeContext, options?:
|
|
48
|
-
cliParity?: boolean;
|
|
49
|
-
permissionMode?: string;
|
|
50
|
-
nativeToolAccess?: boolean;
|
|
51
|
-
nativeCapabilities?: {
|
|
52
|
-
userMcp?: boolean;
|
|
53
|
-
};
|
|
54
|
-
}): string[];
|
|
58
|
+
export declare function buildClaudeMcpConfigArgs(runtimeContext: RuntimeContext, options?: ClaudeMcpOptions): string[];
|
|
55
59
|
export declare function clampCodexReasoning(modelId: string | null | undefined, effort: string | null | undefined): string | null | undefined;
|
|
56
60
|
export declare function parseLineSeparatedModels({ stdout }: {
|
|
57
61
|
stdout: string;
|
package/dist/defs/shared.js
CHANGED
|
@@ -13,6 +13,10 @@ import { parsePiModels } from '../pi-models.js';
|
|
|
13
13
|
import { execAgentFile } from '../invocation.js';
|
|
14
14
|
import { DEFAULT_MODEL_OPTION } from '../models.js';
|
|
15
15
|
export { detectAcpModels, parsePiModels, execAgentFile, DEFAULT_MODEL_OPTION };
|
|
16
|
+
/** User MCP inheritance requires the explicit MCP grant or legacy trusted bypass, without a tool lock. */
|
|
17
|
+
function trustedMcpBypass({ options, userMcpLocked }, _optional = {}) {
|
|
18
|
+
return (options.nativeCapabilities?.userMcp === true || Boolean(options.cliParity) && options.permissionMode === 'bypass') && !userMcpLocked;
|
|
19
|
+
}
|
|
16
20
|
/**
|
|
17
21
|
* The argv every `externalMcpInjection: 'claude-mcp-json'` def appends so the caller-staged
|
|
18
22
|
* `.mcp.json` is loaded *explicitly* rather than auto-discovered from cwd.
|
|
@@ -38,6 +42,8 @@ export { detectAcpModels, parsePiModels, execAgentFile, DEFAULT_MODEL_OPTION };
|
|
|
38
42
|
* it is present only when the caller is actually staging that file for this run (see
|
|
39
43
|
* `RuntimeContext.mcpJsonPath`'s own doc), so an unconfigured host gets `[]` and no argv change.
|
|
40
44
|
* Trusted bypass parity omits strict isolation so user MCP/Chrome settings remain available.
|
|
45
|
+
* Owner 2026-10-23: filesystemRoot keeps the explicit personal-MCP opt-in; those servers are
|
|
46
|
+
* outside the folder boundary. OFF still stays strict (the default grant).
|
|
41
47
|
* Explicit --mcp-config still avoids a headless trust prompt. A locked run without a staged
|
|
42
48
|
* config gets --strict-mcp-config alone, exposing no auto-discovered MCP servers.
|
|
43
49
|
* @complexity O(1).
|
|
@@ -45,13 +51,18 @@ export { detectAcpModels, parsePiModels, execAgentFile, DEFAULT_MODEL_OPTION };
|
|
|
45
51
|
*/
|
|
46
52
|
export function buildClaudeMcpConfigArgs(runtimeContext, options = {}) {
|
|
47
53
|
const mcpJsonPath = runtimeContext.mcpJsonPath;
|
|
48
|
-
const userMcpLocked =
|
|
54
|
+
const userMcpLocked = claudeUserMcpLocked({ options }, {});
|
|
49
55
|
if (typeof mcpJsonPath !== 'string' || mcpJsonPath.length === 0)
|
|
50
56
|
return userMcpLocked ? ['--strict-mcp-config'] : [];
|
|
51
|
-
// Explicit config still avoids headless trust prompts.
|
|
52
|
-
const trustedBypass =
|
|
57
|
+
// Explicit config still avoids headless trust prompts. An explicit MCP grant or trusted legacy bypass run inherits MCP.
|
|
58
|
+
const trustedBypass = trustedMcpBypass({ options, userMcpLocked }, {});
|
|
53
59
|
return [...(trustedBypass ? [] : ['--strict-mcp-config']), '--mcp-config', mcpJsonPath];
|
|
54
60
|
}
|
|
61
|
+
/** Keep site MCP off by default; an explicit ON grant retains the owner's servers. Pure, O(1). */
|
|
62
|
+
function claudeUserMcpLocked({ options }, _optional = {}) {
|
|
63
|
+
return options.nativeToolAccess === false || options.nativeCapabilities?.userMcp === false ||
|
|
64
|
+
(options.filesystemRoot !== undefined && options.nativeCapabilities?.userMcp !== true);
|
|
65
|
+
}
|
|
55
66
|
/** Model-id prefixes of the late gpt-5.x family, which rejects `minimal` effort. */
|
|
56
67
|
const GPT5_LATE_FAMILY_PREFIXES = ['gpt-5.2', 'gpt-5.3', 'gpt-5.4', 'gpt-5.5'];
|
|
57
68
|
/** True for the empty/`default` id (the CLI's own default model) or a late gpt-5.x id. */
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
// Core contract and diagnostic types.
|
|
12
12
|
export * from './types.js';
|
|
13
13
|
export * from './native-tool-policy.js';
|
|
14
|
+
export * from './claude-filesystem-policy.js';
|
|
14
15
|
// Generic supporting modules.
|
|
15
16
|
export * from './paths.js';
|
|
16
17
|
export * from './models.js';
|
|
@@ -90,6 +90,19 @@ export interface ProviderToolResult {
|
|
|
90
90
|
readonly isError?: boolean;
|
|
91
91
|
}
|
|
92
92
|
export type ProviderToolExecutor = (call: ProviderToolCall) => Promise<ProviderToolResult>;
|
|
93
|
+
/** Raw provider call metadata: an unpublished wire name has no canonical tool ID or decoder. */
|
|
94
|
+
export interface ProviderUnexposedToolCall {
|
|
95
|
+
readonly toolName: string;
|
|
96
|
+
readonly callId: string;
|
|
97
|
+
readonly input: unknown;
|
|
98
|
+
readonly protocol: ProviderProtocol;
|
|
99
|
+
}
|
|
100
|
+
/** Refusal wording only; no result content, success flag, or execution capability is accepted. */
|
|
101
|
+
export interface ProviderToolRefusal {
|
|
102
|
+
readonly text: string;
|
|
103
|
+
}
|
|
104
|
+
/** May audit the denied attempt; throws/rejections propagate and never authorize execution. */
|
|
105
|
+
export type ProviderUnexposedToolCallHandler = (call: ProviderUnexposedToolCall) => ProviderToolRefusal | undefined | Promise<ProviderToolRefusal | undefined>;
|
|
93
106
|
export interface ProviderToolTurnInput {
|
|
94
107
|
readonly protocol: ProviderProtocol;
|
|
95
108
|
readonly adapters: ProviderTurnAdapters;
|
|
@@ -107,6 +120,14 @@ export interface ProviderToolTurnResult {
|
|
|
107
120
|
}
|
|
108
121
|
/** Optional turn controls; dependencies belong in the required input object. */
|
|
109
122
|
export interface ProviderToolTurnOptions {
|
|
123
|
+
/** Audit and word an unpublished call's refusal. Undefined retains the built-in text.
|
|
124
|
+
* The result is always an error; this callback must never execute a tool handler.
|
|
125
|
+
* @example onUnexposedToolCall: async ({ toolName, callId }) => {
|
|
126
|
+
* await auditDeniedAttempt({ toolName, callId });
|
|
127
|
+
* return { text: 'This tool is unavailable.' };
|
|
128
|
+
* }
|
|
129
|
+
*/
|
|
130
|
+
readonly onUnexposedToolCall?: ProviderUnexposedToolCallHandler;
|
|
110
131
|
/** Current run-scoped descriptors; adapters refresh the projection before every request. */
|
|
111
132
|
readonly getToolSnapshot?: () => readonly ProviderToolDescriptor[];
|
|
112
133
|
/** Value-free diagnostic only; execution must still validate through the host executor. */
|
|
@@ -93,9 +93,9 @@ function pinWireNames(descriptors, names) {
|
|
|
93
93
|
}
|
|
94
94
|
/** Per-turn projection state only; the host registry/executor retains definition and policy ownership.
|
|
95
95
|
* Names and previously published decoders survive refresh so in-flight calls remain resolvable.
|
|
96
|
-
*
|
|
96
|
+
* Snapshot work is O(n log n + s) for n IDs and s bounded expanded schema nodes; host ports own I/O.
|
|
97
97
|
*/
|
|
98
|
-
function createToolProjection(input) {
|
|
98
|
+
function createToolProjection(input, _options = {}) {
|
|
99
99
|
const names = new Map();
|
|
100
100
|
const published = new Map();
|
|
101
101
|
const reported = new Set();
|
|
@@ -120,9 +120,16 @@ function createToolProjection(input) {
|
|
|
120
120
|
}
|
|
121
121
|
return {
|
|
122
122
|
getTools,
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
/** Dispatch a published call or await host refusal wording/audit; callback errors propagate.
|
|
124
|
+
* O(1) local lookup and space; host callback/executor costs belong to those ports.
|
|
125
|
+
*/
|
|
126
|
+
async execute(call, _options = {}) {
|
|
127
|
+
if (!published.has(call.name)) {
|
|
128
|
+
// MOVE: Refusal auditing must stay separate from execution so a policy change during
|
|
129
|
+
// the callback cannot authorize a call whose name was never published this turn.
|
|
130
|
+
const refusal = await input.onUnexposedToolCall?.({ toolName: call.name, callId: call.id, input: call.input, protocol: input.protocol });
|
|
131
|
+
return { isError: true, content: refusal?.text ?? 'Tool is not exposed in this turn.' };
|
|
132
|
+
}
|
|
126
133
|
return input.executeTool(decode(call));
|
|
127
134
|
},
|
|
128
135
|
onEvent(event) {
|
package/dist/types.d.ts
CHANGED
|
@@ -75,6 +75,14 @@ export type RuntimeReasoningInModelId = {
|
|
|
75
75
|
levels: readonly RuntimeReasoningOption[];
|
|
76
76
|
};
|
|
77
77
|
export type RuntimeBuildOptions = {
|
|
78
|
+
/** Host folder boundary, independent of native grants; unsupported providers disclose the exception. */
|
|
79
|
+
filesystemRoot?: string;
|
|
80
|
+
/** Executor-created private temporary directory inside the host root; never a shared temp root. */
|
|
81
|
+
filesystemTempDir?: string;
|
|
82
|
+
/** Shared host/login temp roots denied even when child TMPDIR is replaced. */
|
|
83
|
+
filesystemSharedTempRoots?: readonly string[];
|
|
84
|
+
/** Executor-resolved CLI/runtime files; read-only exceptions for sandboxed commands. */
|
|
85
|
+
filesystemRuntimeReadPaths?: readonly string[];
|
|
78
86
|
/** Host-verified per-run overrides; false dimensions must be enforced or launch refused. */
|
|
79
87
|
nativeCapabilities?: Partial<import('./native-tool-policy.js').NativeCapabilities>;
|
|
80
88
|
/** Explicit host grant for shell/direct edits. false must be enforced or launch refused.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jini-ai/agent-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.11",
|
|
4
4
|
"description": "Coding-agent runtime adapters: runtime registry, detection, launch, stream parsers, and the ACP/pi-rpc subprocess transport.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -107,20 +107,19 @@
|
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
109
|
"@vitest/coverage-v8": "^2.1.9",
|
|
110
|
-
"@jini-ai/core": "^0.
|
|
111
|
-
"@jini-ai/
|
|
112
|
-
"@jini-ai/
|
|
113
|
-
"@jini-ai/platform": "^0.5.10"
|
|
110
|
+
"@jini-ai/core": "^0.6.11",
|
|
111
|
+
"@jini-ai/platform": "^0.6.11",
|
|
112
|
+
"@jini-ai/integrations": "^0.6.11"
|
|
114
113
|
},
|
|
115
114
|
"dependencies": {
|
|
116
|
-
"@jini-ai/
|
|
117
|
-
"@jini-ai/
|
|
115
|
+
"@jini-ai/oauth": "^0.6.11",
|
|
116
|
+
"@jini-ai/core": "^0.6.11",
|
|
117
|
+
"@jini-ai/protocol": "^0.6.11"
|
|
118
118
|
},
|
|
119
119
|
"peerDependencies": {
|
|
120
|
-
"@jini-ai/integrations": "^0.
|
|
120
|
+
"@jini-ai/integrations": "^0.6.10",
|
|
121
121
|
"@github/copilot-sdk": "*",
|
|
122
|
-
"@jini-ai/platform": "^0.
|
|
123
|
-
"@jini-ai/protocol": "^0.4.4"
|
|
122
|
+
"@jini-ai/platform": "^0.6.10"
|
|
124
123
|
},
|
|
125
124
|
"peerDependenciesMeta": {
|
|
126
125
|
"@jini-ai/integrations": {
|
|
@@ -131,9 +130,6 @@
|
|
|
131
130
|
},
|
|
132
131
|
"@jini-ai/platform": {
|
|
133
132
|
"optional": true
|
|
134
|
-
},
|
|
135
|
-
"@jini-ai/protocol": {
|
|
136
|
-
"optional": true
|
|
137
133
|
}
|
|
138
134
|
},
|
|
139
135
|
"scripts": {
|