@jini-ai/agent-runtime 0.6.11 → 0.6.15-rc.1

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/dist/agent-protocol/acp/json.d.ts +1 -1
  3. package/dist/agent-protocol/acp/json.js +6 -3
  4. package/dist/agent-protocol/acp/models.js +53 -15
  5. package/dist/agent-protocol/acp/rpc.js +1 -1
  6. package/dist/agent-protocol/acp/session.d.ts +1 -1
  7. package/dist/agent-protocol/acp/session.js +25 -8
  8. package/dist/agent-protocol/acp/text-suppression.js +2 -1
  9. package/dist/ai-trace/capture.d.ts +17 -0
  10. package/dist/ai-trace/capture.js +43 -0
  11. package/dist/ai-trace/classify.d.ts +12 -0
  12. package/dist/ai-trace/classify.js +13 -0
  13. package/dist/ai-trace/index.d.ts +13 -0
  14. package/dist/ai-trace/index.js +6 -0
  15. package/dist/ai-trace/recorder.d.ts +65 -0
  16. package/dist/ai-trace/recorder.js +259 -0
  17. package/dist/ai-trace/sinks.d.ts +51 -0
  18. package/dist/ai-trace/sinks.js +137 -0
  19. package/dist/ai-trace/types.d.ts +123 -0
  20. package/dist/ai-trace/types.js +17 -0
  21. package/dist/ai-trace/usage.d.ts +13 -0
  22. package/dist/ai-trace/usage.js +43 -0
  23. package/dist/claude-filesystem-policy.d.ts +25 -3
  24. package/dist/claude-filesystem-policy.js +104 -14
  25. package/dist/core/model-discovery-shared.d.ts +28 -0
  26. package/dist/core/model-discovery-shared.js +88 -0
  27. package/dist/defs/antigravity.js +10 -2
  28. package/dist/defs/claude.js +2 -1
  29. package/dist/defs/codex.js +13 -2
  30. package/dist/index.d.ts +1 -0
  31. package/dist/index.js +1 -0
  32. package/dist/model-discovery-adapters.js +1 -1
  33. package/dist/model-discovery-shared.d.ts +2 -27
  34. package/dist/model-discovery-shared.js +2 -87
  35. package/dist/model-discovery.d.ts +1 -1
  36. package/dist/model-discovery.js +2 -2
  37. package/dist/models.js +1 -1
  38. package/dist/providers/anthropic-messages.d.ts +1 -1
  39. package/dist/providers/anthropic-messages.js +10 -4
  40. package/dist/types.d.ts +4 -0
  41. package/package.json +16 -10
@@ -10,18 +10,38 @@ export declare function validateFilesystemLaunch(required: {
10
10
  extraAllowedDirs?: readonly string[];
11
11
  imagePaths?: readonly string[];
12
12
  }, _optional?: {}): string;
13
+ /** Owner-picked folders granted read-only beside the site (owner 2026-10-27). Unlike
14
+ * extraAllowedDirs these lie OUTSIDE the site, so containment is replaced by refusals: a symlinked
15
+ * folder, `/`, home or any ancestor of home, the site, anything inside it or any ancestor of it.
16
+ * @returns Canonical directories. @throws Before spawn on the first refused path. O(n) stat/realpath.
17
+ */
18
+ export declare function validateReadOnlyExtraDirs(required: {
19
+ filesystemRoot: string;
20
+ dirs: readonly string[];
21
+ }, { homeDir, }?: {
22
+ homeDir?: string;
23
+ }): string[];
24
+ /** Create one executor's probe cache; no filesystem access until the returned probe is called.
25
+ * Cache concurrent and subsequent launches by executable identity for that executor's lifetime
26
+ * so repeated launches do not spawn redundant metadata probes or share another host's evidence.
27
+ * @returns The support check bound to an empty cache. @complexity O(1) allocation.
28
+ * @example const verify = createClaudeFilesystemSupportProbe({});
29
+ */
30
+ export declare function createClaudeFilesystemSupportProbe(_required: Record<string, never>, _options?: {}): typeof assertClaudeFilesystemSupport;
13
31
  /** Probe official CLI enforcement, retrying uncertain evidence once without logging its values.
14
32
  * The 2.1.285 floor covers native read blocking and admin-required sandbox locks.
15
33
  * https://code.claude.com/docs/en/sandboxing#repository-settings-under-an-admin-required-sandbox
16
34
  * 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.
35
+ * O(1) metadata I/O and at most two bounded subprocesses per cache slot. Standalone calls
36
+ * probe independently; executors bind a cache with createClaudeFilesystemSupportProbe.
18
37
  */
19
38
  export declare function assertClaudeFilesystemSupport(required: {
20
39
  agentId: string;
21
40
  launchPath: string;
22
41
  env: NodeJS.ProcessEnv;
23
- }, { probe }?: {
42
+ }, { probe, cache }?: {
24
43
  probe?: typeof execAgentFile;
44
+ cache?: Map<string, Promise<boolean | undefined>>;
25
45
  }): Promise<boolean | void>;
26
46
  /** Runtime assets under a denied home remain readable, never writable. Native installs need the
27
47
  * binary; npm installs also need their adjacent package resources. O(1), canonical filesystem I/O.
@@ -35,12 +55,14 @@ export declare function claudeFilesystemRuntimePaths(required: {
35
55
  * https://code.claude.com/docs/en/permissions#working-directories
36
56
  * O(s + r) serialization for s host settings bytes and r runtime exception paths. Pure with
37
57
  * injectable host facts; errors reject malformed/file-based settings rather than dropping policy.
58
+ * @example claudeFilesystemSettings({ options: { filesystemRoot: '/site' } }, { platform: 'darwin', uid: 501 })
38
59
  */
39
60
  export declare function claudeFilesystemSettings(required: {
40
61
  options: RuntimeBuildOptions;
41
- }, { platform, homeDir, tempDir, }?: {
62
+ }, { platform, homeDir, tempDir, uid, }?: {
42
63
  platform?: NodeJS.Platform;
43
64
  homeDir?: string;
44
65
  tempDir?: string;
66
+ uid?: number | null | undefined;
45
67
  }): string;
46
68
  //# sourceMappingURL=claude-filesystem-policy.d.ts.map
@@ -1,6 +1,6 @@
1
- import { realpathSync, statSync } from 'node:fs';
1
+ import { lstatSync, realpathSync, statSync } from 'node:fs';
2
2
  import { homedir, tmpdir } from 'node:os';
3
- import { basename, dirname, isAbsolute, relative, resolve } from 'node:path';
3
+ import { basename, dirname, isAbsolute, relative, resolve, sep } from 'node:path';
4
4
  import { createGuardedFileReader, createNodeGuardedReaderFilesystem } from '@jini-ai/platform/fs/guarded-reader';
5
5
  import { execAgentFile } from './invocation.js';
6
6
  /** Canonical host directory and attachment grants, checked again after image augmentation.
@@ -26,15 +26,50 @@ export function validateFilesystemLaunch(required, _optional = {}) {
26
26
  }
27
27
  return root;
28
28
  }
29
- // Cache concurrent and subsequent launches by executable identity for the process lifetime.
30
- const filesystemSupport = new Map();
29
+ /** Owner-picked folders granted read-only beside the site (owner 2026-10-27). Unlike
30
+ * extraAllowedDirs these lie OUTSIDE the site, so containment is replaced by refusals: a symlinked
31
+ * folder, `/`, home or any ancestor of home, the site, anything inside it or any ancestor of it.
32
+ * @returns Canonical directories. @throws Before spawn on the first refused path. O(n) stat/realpath.
33
+ */
34
+ export function validateReadOnlyExtraDirs(required, { homeDir = homedir(), } = {}) {
35
+ const site = realpathSync(required.filesystemRoot);
36
+ const home = realpathSync(homeDir);
37
+ return required.dirs.map((dir) => {
38
+ if (!isAbsolute(dir))
39
+ throw new Error('Read-only directory must be absolute');
40
+ if (lstatSync(dir).isSymbolicLink())
41
+ throw new Error('Read-only directory must not be a symlink');
42
+ const real = realpathSync(dir);
43
+ if (!statSync(real).isDirectory())
44
+ throw new Error('Read-only directory must be a directory');
45
+ if ([home, site].some(path => isSameOrInside({ path, dir: real })) || isSameOrInside({ path: real, dir: site })) {
46
+ throw new Error('Read-only directory must not contain home or the site, nor lie inside the site');
47
+ }
48
+ return real;
49
+ });
50
+ }
51
+ /** Whether `path` equals `dir` or lies beneath it. `/` contains everything. Pure, O(p). */
52
+ function isSameOrInside({ path, dir }, _optional = {}) {
53
+ return path === dir || path.startsWith(dir.endsWith(sep) ? dir : dir + sep);
54
+ }
55
+ /** Create one executor's probe cache; no filesystem access until the returned probe is called.
56
+ * Cache concurrent and subsequent launches by executable identity for that executor's lifetime
57
+ * so repeated launches do not spawn redundant metadata probes or share another host's evidence.
58
+ * @returns The support check bound to an empty cache. @complexity O(1) allocation.
59
+ * @example const verify = createClaudeFilesystemSupportProbe({});
60
+ */
61
+ export function createClaudeFilesystemSupportProbe(_required, _options = {}) {
62
+ const cache = new Map();
63
+ return (required, options = {}) => assertClaudeFilesystemSupport(required, { ...options, cache });
64
+ }
31
65
  /** Probe official CLI enforcement, retrying uncertain evidence once without logging its values.
32
66
  * The 2.1.285 floor covers native read blocking and admin-required sandbox locks.
33
67
  * https://code.claude.com/docs/en/sandboxing#repository-settings-under-an-admin-required-sandbox
34
68
  * 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.
69
+ * O(1) metadata I/O and at most two bounded subprocesses per cache slot. Standalone calls
70
+ * probe independently; executors bind a cache with createClaudeFilesystemSupportProbe.
36
71
  */
37
- export async function assertClaudeFilesystemSupport(required, { probe = execAgentFile } = {}) {
72
+ export async function assertClaudeFilesystemSupport(required, { probe = execAgentFile, cache = new Map() } = {}) {
38
73
  if (required.agentId !== 'claude' || /^openclaude(?:\.|$)/i.test(basename(required.launchPath)))
39
74
  return false;
40
75
  let key;
@@ -44,10 +79,10 @@ export async function assertClaudeFilesystemSupport(required, { probe = execAgen
44
79
  catch {
45
80
  return undefined;
46
81
  }
47
- let pending = filesystemSupport.get(key);
82
+ let pending = cache.get(key);
48
83
  if (!pending) {
49
84
  pending = probeFilesystemSupport({ ...required, probe }, {});
50
- filesystemSupport.set(key, pending);
85
+ cache.set(key, pending);
51
86
  }
52
87
  return pending;
53
88
  }
@@ -91,31 +126,86 @@ export function claudeFilesystemRuntimePaths(required, _optional = {}) {
91
126
  * https://code.claude.com/docs/en/permissions#working-directories
92
127
  * O(s + r) serialization for s host settings bytes and r runtime exception paths. Pure with
93
128
  * injectable host facts; errors reject malformed/file-based settings rather than dropping policy.
129
+ * @example claudeFilesystemSettings({ options: { filesystemRoot: '/site' } }, { platform: 'darwin', uid: 501 })
94
130
  */
95
- export function claudeFilesystemSettings(required, { platform = process.platform, homeDir = homedir(), tempDir = tmpdir(), } = {}) {
131
+ export function claudeFilesystemSettings(required, { platform = process.platform, homeDir = homedir(), tempDir = tmpdir(), uid, } = {}) {
96
132
  const { options } = required;
133
+ const runtimeTempPaths = claudeRuntimeTempPaths({ options, platform }, { uid });
97
134
  const settings = options.settings ? JSON.parse(options.settings) : {};
98
135
  if (!settings || typeof settings !== 'object' || Array.isArray(settings))
99
136
  throw new Error('Host settings must be a JSON object');
100
137
  const permissions = settings.permissions;
138
+ const readOnlyDirs = expressibleReadOnlyDirs({ options }, {});
101
139
  return JSON.stringify({ ...settings, autoMemoryEnabled: false,
102
- permissions: { ...permissions, blockReadsOutsideWorkingDirectories: true, additionalDirectories: [] },
140
+ permissions: { ...permissions, blockReadsOutsideWorkingDirectories: true, additionalDirectories: readOnlyDirs,
141
+ ...readOnlyEditDenies({ permissions, readOnlyDirs }, {}) },
103
142
  sandbox: { enabled: platform !== 'win32', failIfUnavailable: platform !== 'win32',
104
143
  allowUnsandboxedCommands: platform === 'win32', excludedCommands: [],
105
- filesystem: filesystemSandboxPaths({ options, homeDir, tempDir }, {}),
144
+ filesystem: filesystemSandboxPaths({ options, homeDir, tempDir, runtimeTempPaths, readOnlyDirs }, {}),
106
145
  },
107
146
  });
108
147
  }
148
+ /** Picked folders a permission rule can name literally. A gitignore-pattern or rule-syntax
149
+ * character (`* ? [ ] \ ( )`) would turn the Edit deny into a different pattern, so such a folder
150
+ * gets no native grant at all; the host's own file tools still reach it. Pure, O(n).
151
+ */
152
+ function expressibleReadOnlyDirs({ options }, _optional = {}) {
153
+ return (options.filesystemReadOnlyDirs ?? []).filter(dir => !/[*?[\]\\()]/.test(dir));
154
+ }
155
+ /** A working directory is editable in every permission mode unless denied; deny rules hold even
156
+ * in bypassPermissions and cover Edit, Write and NotebookEdit. Merged without duplicates so a
157
+ * rebuild from this function's own output is identical. Pure, O(d + n).
158
+ */
159
+ function readOnlyEditDenies({ permissions, readOnlyDirs }, _optional = {}) {
160
+ if (readOnlyDirs.length === 0)
161
+ return {};
162
+ const hostDenies = Array.isArray(permissions?.deny) ? permissions.deny : [];
163
+ return { deny: [...new Set([...hostDenies, ...readOnlyDirs.map(dir => `Edit(/${dir}/**)`)])] };
164
+ }
165
+ /** Exact scratch subtree inside the executor's private per-run CLAUDE_CODE_TMPDIR.
166
+ * Missing bases grant nothing; long bases are refused so Bash cannot fall back to shared scratch.
167
+ * Pure, O(p) time/space for p path bytes; invalid Unix host facts throw before policy generation.
168
+ */
169
+ function claudeRuntimeTempPaths({ options, platform }, { uid } = {}) {
170
+ if (platform === 'win32')
171
+ return [];
172
+ const base = options.filesystemRuntimeTempBase;
173
+ if (!base)
174
+ return [];
175
+ if (!isAbsolute(base))
176
+ throw new Error('Runtime temp base must be absolute');
177
+ const runtimeTemp = resolve(base, `claude-${requireUnixUid({}, { uid })}`);
178
+ if (Buffer.byteLength(runtimeTemp) > 44)
179
+ throw new Error('Runtime temp path must not exceed 44 bytes');
180
+ return claudeTempAliases({ path: runtimeTemp, platform }, {});
181
+ }
182
+ /** The host UID that names Claude's scratch subtree; fails closed rather than granting a guessed path. O(1). */
183
+ function requireUnixUid(_required = {}, { uid = process.getuid?.() } = {}) {
184
+ if (!Number.isSafeInteger(uid) || uid < 0)
185
+ throw new Error('Runtime temp policy requires a Unix UID');
186
+ return uid;
187
+ }
188
+ /** Preserve macOS's lexical and /private spellings without filesystem I/O. Pure, O(p) path bytes. */
189
+ function claudeTempAliases({ path, platform }, _optional = {}) {
190
+ if (platform !== 'darwin')
191
+ return [path];
192
+ const unprefixed = path.replace(/^\/private\/(?=tmp\/|var\/)/, '/');
193
+ return /^\/(?:tmp|var)\//.test(unprefixed) ? [unprefixed, `/private${unprefixed}`] : [path];
194
+ }
109
195
  /** Build explicit filesystem exceptions; shared temp and the rest of home remain denied.
196
+ * Claude's exact scratch subtree in the executor-created per-run directory is a read/write
197
+ * infrastructure exception so Bash can track cwd. Shared and other runs' scratch stay denied.
110
198
  * Pure, O(r + t) for r runtime paths and t shared temp roots; no filesystem access.
111
199
  */
112
- function filesystemSandboxPaths({ options, homeDir, tempDir }, _optional = {}) {
200
+ function filesystemSandboxPaths({ options, homeDir, tempDir, runtimeTempPaths, readOnlyDirs }, _optional = {}) {
113
201
  const privateTemp = options.filesystemTempDir ?? resolve(options.filesystemRoot, '.agent-runtime', 'tmp');
114
202
  const sharedTempRoots = [...new Set(['/tmp', '/private/tmp', tempDir, ...(options.filesystemSharedTempRoots ?? [])])];
115
203
  return { denyRead: [homeDir, ...sharedTempRoots],
116
204
  // Owner 2026-10-23: git config is a read-only infrastructure exception, never all of home.
117
205
  allowRead: [options.filesystemRoot, privateTemp, resolve(homeDir, '.gitconfig'),
118
- resolve(homeDir, '.config/git/config'), ...(options.filesystemRuntimeReadPaths ?? [])],
119
- allowWrite: [options.filesystemRoot, privateTemp] };
206
+ resolve(homeDir, '.config/git/config'), ...(options.filesystemRuntimeReadPaths ?? []), ...runtimeTempPaths, ...readOnlyDirs],
207
+ allowWrite: [options.filesystemRoot, privateTemp, ...runtimeTempPaths],
208
+ // Additional working directories are sandbox-writable by default; the picked folder never is.
209
+ ...(readOnlyDirs.length > 0 ? { denyWrite: [...readOnlyDirs] } : {}) };
120
210
  }
121
211
  //# sourceMappingURL=claude-filesystem-policy.js.map
@@ -0,0 +1,28 @@
1
+ /** Shared discovery normalization and timeout/error contracts; no native adapters. */
2
+ import type { RuntimeModelOption } from '../types.js';
3
+ import type { DiscoveredModel, ModelCatalogSnapshot } from '../model-discovery-types.js';
4
+ export declare function modelIdentityKind(id: string): DiscoveredModel['identityKind'];
5
+ export declare function normalizeDiscoveredModels(models: readonly RuntimeModelOption[]): DiscoveredModel[];
6
+ type DefaultResolutionLike = {
7
+ status: string;
8
+ id?: string;
9
+ };
10
+ /** Concrete picker choices, shared with server-side selection validation.
11
+ * Aliases contribute their resolved ID; routing modes never become launch IDs.
12
+ * Preserves first position and upgrades raw labels. Pure; O(rows) time and space.
13
+ */
14
+ export declare function concreteModelOptions({ models, supportsConcreteModelSelection, defaultModelResolution }: {
15
+ models?: readonly RuntimeModelOption[];
16
+ supportsConcreteModelSelection?: boolean;
17
+ defaultModelResolution?: DefaultResolutionLike;
18
+ }, _options?: {}): RuntimeModelOption[];
19
+ export declare class ProbeTimeout extends Error {
20
+ }
21
+ /** Cancellation always reaches the effect port. A broken port cannot hold callers indefinitely. */
22
+ export declare function withModelProbeTimeout<T>(work: (signal: AbortSignal) => Promise<T>, timeoutMs: number, parent?: AbortSignal): Promise<T>;
23
+ export declare class ModelProbeError extends Error {
24
+ readonly code: ModelCatalogSnapshot['diagnostics'][number]['code'];
25
+ constructor(code: ModelCatalogSnapshot['diagnostics'][number]['code']);
26
+ }
27
+ export {};
28
+ //# sourceMappingURL=model-discovery-shared.d.ts.map
@@ -0,0 +1,88 @@
1
+ export function modelIdentityKind(id) {
2
+ const token = id.slice(id.lastIndexOf('/') + 1);
3
+ if (/^(default|auto|adaptive|smart|deep|rush|ultimate|premium|balanced|fast|vercel-ai-gateway|grok-build)$/i.test(token) || /(?:^|[-/])gateway$/i.test(id))
4
+ return 'routing-mode';
5
+ if (/^(opus|sonnet|haiku|fable|best|latest|claude|gemini|gpt|codex|swe)(?:\[.*\])?$/i.test(token) || /(?:^|[-/])latest$/i.test(id))
6
+ return 'alias';
7
+ return 'concrete';
8
+ }
9
+ export function normalizeDiscoveredModels(models) {
10
+ const seen = new Set();
11
+ return models.flatMap((row) => {
12
+ if (!row.id || row.id === 'default' || seen.has(row.id))
13
+ return [];
14
+ seen.add(row.id);
15
+ const model = row;
16
+ return [{ ...row, identityKind: model.identityKind ?? modelIdentityKind(row.id) }];
17
+ });
18
+ }
19
+ /** The concrete launch id a catalog row contributes, or undefined when it contributes none. */
20
+ function concreteRowId({ row }) {
21
+ const id = row.resolvedId || (row.identityKind === 'routing-mode' || row.identityKind === 'alias' ? undefined : row.id);
22
+ return id && modelIdentityKind(id) === 'concrete' ? id : undefined;
23
+ }
24
+ /** Add one row's concrete choice; first position wins, a raw-id label is upgraded later. */
25
+ function addConcreteChoice({ choices, row }) {
26
+ const id = concreteRowId({ row });
27
+ if (!id)
28
+ return;
29
+ // Older cached inventories can attach a default-policy label to a resolved concrete ID.
30
+ const label = row.id === 'default' || /^default\b/i.test(row.label) ? id : row.label;
31
+ const existing = choices.get(id);
32
+ if (!existing)
33
+ choices.set(id, { ...row, id, label, identityKind: 'concrete' });
34
+ else if (existing.label === id && label !== id)
35
+ choices.set(id, { ...existing, label });
36
+ }
37
+ /** The resolved concrete default id when it is missing from `choices`, else undefined. */
38
+ function missingResolvedDefaultId({ choices }, { resolution } = {}) {
39
+ if (resolution?.status !== 'resolved' || !resolution.id)
40
+ return undefined;
41
+ return modelIdentityKind(resolution.id) === 'concrete' && !choices.has(resolution.id) ? resolution.id : undefined;
42
+ }
43
+ /** Concrete picker choices, shared with server-side selection validation.
44
+ * Aliases contribute their resolved ID; routing modes never become launch IDs.
45
+ * Preserves first position and upgrades raw labels. Pure; O(rows) time and space.
46
+ */
47
+ export function concreteModelOptions({ models = [], supportsConcreteModelSelection, defaultModelResolution }, _options = {}) {
48
+ if (supportsConcreteModelSelection === false)
49
+ return [];
50
+ const choices = new Map();
51
+ for (const row of models)
52
+ addConcreteChoice({ choices, row });
53
+ const options = [...choices.values()];
54
+ // A host may publish a resolved default outside its visible catalog. Preserve its concrete ID.
55
+ const hiddenDefaultId = missingResolvedDefaultId({ choices }, { resolution: defaultModelResolution });
56
+ if (hiddenDefaultId)
57
+ options.unshift({ id: hiddenDefaultId, label: hiddenDefaultId, identityKind: 'concrete' });
58
+ return options;
59
+ }
60
+ export class ProbeTimeout extends Error {
61
+ }
62
+ /** Cancellation always reaches the effect port. A broken port cannot hold callers indefinitely. */
63
+ export async function withModelProbeTimeout(work, timeoutMs, parent) {
64
+ if (parent?.aborted)
65
+ throw new ProbeTimeout('Probe cancelled');
66
+ const controller = new AbortController();
67
+ let rejectStopped;
68
+ const stopped = new Promise((_resolve, reject) => { rejectStopped = reject; });
69
+ // `parent` was not aborted above and nothing has awaited since, so listening is enough.
70
+ const abortListener = () => { controller.abort(); rejectStopped(new ProbeTimeout('Probe cancelled')); };
71
+ parent?.addEventListener('abort', abortListener, { once: true });
72
+ const timer = setTimeout(() => { controller.abort(); rejectStopped(new ProbeTimeout('Probe timed out')); }, timeoutMs);
73
+ try {
74
+ return await Promise.race([work(controller.signal), stopped]);
75
+ }
76
+ finally {
77
+ clearTimeout(timer);
78
+ parent?.removeEventListener('abort', abortListener);
79
+ }
80
+ }
81
+ export class ModelProbeError extends Error {
82
+ code;
83
+ constructor(code) {
84
+ super(code);
85
+ this.code = code;
86
+ }
87
+ }
88
+ //# sourceMappingURL=model-discovery-shared.js.map
@@ -168,9 +168,15 @@ export const antigravityAgentDef = {
168
168
  timeoutMs: AGY_MODELS_TIMEOUT_MS,
169
169
  },
170
170
  // Checked against agy 1.4.2 and https://antigravity.google/docs/cli/headless/.
171
- fallbackModelsAssertedAt: '2026-10-18',
171
+ fallbackModelsAssertedAt: '2026-10-24',
172
172
  fallbackModels: [
173
173
  DEFAULT_MODEL_OPTION,
174
+ { id: 'claude-opus-5-5-low', label: 'Claude Opus 5.5 (Low)' },
175
+ { id: 'claude-opus-5-5-medium', label: 'Claude Opus 5.5 (Medium)' },
176
+ { id: 'claude-opus-5-5-high', label: 'Claude Opus 5.5 (High)' },
177
+ { id: 'claude-sonnet-5-5-low', label: 'Claude Sonnet 5.5 (Low)' },
178
+ { id: 'claude-sonnet-5-5-medium', label: 'Claude Sonnet 5.5 (Medium)' },
179
+ { id: 'claude-sonnet-5-5-high', label: 'Claude Sonnet 5.5 (High)' },
174
180
  { id: 'gemini-4-argon-high', label: 'Gemini 4 Argon High' },
175
181
  { id: 'gemini-4-argon-medium', label: 'Gemini 4 Argon Medium' },
176
182
  { id: 'gemini-4-argon-low', label: 'Gemini 4 Argon Low' },
@@ -273,7 +279,9 @@ export const antigravityAgentDef = {
273
279
  // (protocolVersion `2025-11-25`, clientInfo `antigravity-client`).
274
280
  // - That makes the registration itself a STATIC, one-time operation — the operator adds one
275
281
  // bridge entry to their real `~/.gemini/config/mcp_config.json` (confirmed still the one real
276
- // mechanism; see the probes below) with a bare, env-free `command` pointing at this package's
282
+ // mechanism; see the probes below; `@jini-ai/mcp`'s `mcp install antigravity` writes exactly
283
+ // this path from its `ANTIGRAVITY_MCP_CONFIG_SEGMENTS`, so change the two together) with a
284
+ // bare, env-free `command` pointing at this package's
277
285
  // own `jini-mcp` bin, resolving its credential from the environment at spawn time instead of
278
286
  // a baked-in value. No per-spawn config mutation, no lock, no restore discipline — the exact
279
287
  // "safe, run-scoped delivery" gap the old verdict cited is closed by inheritance, not by
@@ -1,5 +1,5 @@
1
1
  import { resolveNativeCapabilityDenies, resolveNativeToolDenies } from '../native-tool-policy.js';
2
- import { claudeFilesystemSettings, validateFilesystemLaunch } from '../claude-filesystem-policy.js';
2
+ import { claudeFilesystemSettings, validateFilesystemLaunch, validateReadOnlyExtraDirs } from '../claude-filesystem-policy.js';
3
3
  import { createAgentModelDiscovery } from '../model-discovery-native.js';
4
4
  /**
5
5
  * Claude Code has no dedicated image-attachment flag. imageDelivery: 'prompt-path' makes the
@@ -130,6 +130,7 @@ function claudeLaunchPolicy({ options, caps, extraAllowedDirs, imagePaths, runti
130
130
  if (options.filesystemRoot !== undefined) {
131
131
  validateFilesystemLaunch({ filesystemRoot: options.filesystemRoot, cwd: runtimeContext.cwd ?? options.filesystemRoot,
132
132
  extraAllowedDirs, imagePaths }, {});
133
+ validateReadOnlyExtraDirs({ filesystemRoot: options.filesystemRoot, dirs: options.filesystemReadOnlyDirs ?? [] }, {});
133
134
  return { directoryArgs: [], settingsArgs: ['--settings', claudeFilesystemSettings({ options }, {})] };
134
135
  }
135
136
  return { directoryArgs: addDirArgs({ extraAllowedDirs, caps }),
@@ -200,12 +200,14 @@ const CODEX_SANDBOX_ARGS = {
200
200
  resume: ['-c', 'sandbox_mode="workspace-write"', '-c', 'sandbox_workspace_write.network_access=true'],
201
201
  },
202
202
  };
203
- // Read-only prevents direct patches; disable every shell transport as well.
203
+ // Read-only prevents direct patches; disable every shell transport as well, and the
204
+ // plugin/app/skill-dependency MCP sources a locked run's staged home cannot drop.
204
205
  // CLI config overrides apply on BOTH create and resume, regardless of the saved session.
205
206
  const CODEX_NATIVE_TOOLS_LOCKED_ARGS = [
206
207
  '-c', 'features.shell_tool=false', '-c', 'features.unified_exec=false',
207
208
  '-c', 'features.code_mode=false', '-c', 'features.apply_patch_freeform=false',
208
209
  '-c', 'features.multi_agent=false', '-c', 'features.collab=false', '-c', 'features.plugins=false',
210
+ '-c', 'features.apps=false', '-c', 'features.skill_mcp_dependency_install=false',
209
211
  '-c', 'approval_policy="never"',
210
212
  ];
211
213
  // Per-turn overrides also apply to resumed sessions, ahead of persisted CLI defaults.
@@ -217,6 +219,12 @@ const CODEX_CAPABILITY_OVERRIDES = [
217
219
  ['web', ['web_search="disabled"']],
218
220
  ['workflows', ['features.worktrees=false', 'features.remote_control=false']],
219
221
  ['userSettings', ['features.skills=false', 'features.plugins=false']],
222
+ // The staged CODEX_HOME drops config-file MCP servers; plugin-bundled servers and ChatGPT apps
223
+ // (connectors) are other MCP sources, and only this CLI layer outranks a trusted project's config.
224
+ // `codex_apps` is a runtime-only server gated by `features.apps` alone (codex-rs `ext/mcp/src/lib.rs`,
225
+ // key verified in `features/src/lib.rs` at rust-v0.151.0). A mentioned skill can install and start
226
+ // its declared MCP servers (`mcp_skill_dependencies.rs`) unless `skill_mcp_dependency_install` is off.
227
+ ['userMcp', ['features.plugins=false', 'features.apps=false', 'features.skill_mcp_dependency_install=false']],
220
228
  ];
221
229
  // Capture-style resume: when the caller has a stored Codex thread id
222
230
  // for this conversation it asks the CLI to continue that session
@@ -305,6 +313,9 @@ export const codexAgentDef = {
305
313
  // rather than dropped.
306
314
  fallbackModels: [
307
315
  DEFAULT_MODEL_OPTION,
316
+ { id: 'gpt-6.1-sol', label: 'GPT-6.1 Sol' },
317
+ { id: 'gpt-6-sol', label: 'GPT-6 Sol' },
318
+ { id: 'gpt-6-luna', label: 'GPT-6 Luna' },
308
319
  { id: 'gpt-6-astra', label: 'gpt-6-astra' },
309
320
  { id: 'gpt-5.6-sol', label: 'gpt-5.6-sol' },
310
321
  { id: 'gpt-5.6-terra', label: 'gpt-5.6-terra' },
@@ -326,7 +337,7 @@ export const codexAgentDef = {
326
337
  ],
327
338
  // Asserted against a live `codex debug models` run (codex-cli 0.153.4). See
328
339
  // `RuntimeAgentDef.fallbackModelsAssertedAt` and `scripts/check-model-fallback-freshness.ts`.
329
- fallbackModelsAssertedAt: '2026-09-05',
340
+ fallbackModelsAssertedAt: '2026-10-24',
330
341
  // The OLD-CLI path only. A Codex build new enough to answer `debug models` gets its effort list
331
342
  // derived from that catalog instead (see `deriveReasoningOptions` below), which is what makes
332
343
  // `max` and `ultra` reachable. This list is deliberately NOT widened to match: it is what a build
package/dist/index.d.ts CHANGED
@@ -46,6 +46,7 @@ export * from './pi-models.js';
46
46
  export * from './prompt-augmenter.js';
47
47
  export * from './artifact-taxonomy.js';
48
48
  export * from './telemetry-sink.js';
49
+ export * from './ai-trace/index.js';
49
50
  export * from './providers/index.js';
50
51
  /** ACP + pi-rpc protocol adapters over the shared JSON-line-stream core. See aliases above. */
51
52
  export { createJsonLineStream, type AcpMcpServerInput, type AcpPermissionDecision, type AcpPermissionHandler, type AcpPermissionOption, type AcpPermissionRequest, type AcpSessionController, type ModelOption, type AttachAcpSessionOptions, type AccountFailure, type AccountFailureClassifier, buildAcpSessionNewParams, normalizeModels, detectAcpModels, attachAcpSession, noopAccountFailureClassifier, mapPiRpcEvent, attachPiRpcSession, parsePiModels as parsePiRpcModels, type PiRpcSession, type PiRpcSessionOptions, } from './agent-protocol/index.js';
package/dist/index.js CHANGED
@@ -68,6 +68,7 @@ export * from './pi-models.js';
68
68
  export * from './prompt-augmenter.js';
69
69
  export * from './artifact-taxonomy.js';
70
70
  export * from './telemetry-sink.js';
71
+ export * from './ai-trace/index.js';
71
72
  // LLM-provider integrations (BYOK model catalogs, OAuth+PKCE, gateway helpers).
72
73
  export * from './providers/index.js';
73
74
  /** ACP + pi-rpc protocol adapters over the shared JSON-line-stream core. See aliases above. */
@@ -11,7 +11,7 @@ import { execAgentFile } from './invocation.js';
11
11
  import { scheduleProbeProcess } from './probe-scheduler.js';
12
12
  import { probeCopilotSdk, probeDroidSdk } from './model-discovery-sdk.js';
13
13
  import { parseSettingsJson, readModelConfiguration } from './model-discovery-config.js';
14
- import { ModelProbeError, modelIdentityKind, withModelProbeTimeout } from './model-discovery-shared.js';
14
+ import { ModelProbeError, modelIdentityKind, withModelProbeTimeout } from './core/model-discovery-shared.js';
15
15
  const ACP_ARGS = {
16
16
  amr: ['agent', 'run', '--runtime', 'opencode'],
17
17
  auggie: ['--acp'], cline: ['--acp'], devin: ['--permission-mode', 'dangerous', '--respect-workspace-trust', 'false', 'acp'],
@@ -1,28 +1,3 @@
1
- /** Shared discovery normalization and timeout/error contracts; no native adapters. */
2
- import type { RuntimeModelOption } from './types.js';
3
- import type { DiscoveredModel, ModelCatalogSnapshot } from './model-discovery-types.js';
4
- export declare function modelIdentityKind(id: string): DiscoveredModel['identityKind'];
5
- export declare function normalizeDiscoveredModels(models: readonly RuntimeModelOption[]): DiscoveredModel[];
6
- type DefaultResolutionLike = {
7
- status: string;
8
- id?: string;
9
- };
10
- /** Concrete picker choices, shared with server-side selection validation.
11
- * Aliases contribute their resolved ID; routing modes never become launch IDs.
12
- * Preserves first position and upgrades raw labels. Pure; O(rows) time and space.
13
- */
14
- export declare function concreteModelOptions({ models, supportsConcreteModelSelection, defaultModelResolution }: {
15
- models?: readonly RuntimeModelOption[];
16
- supportsConcreteModelSelection?: boolean;
17
- defaultModelResolution?: DefaultResolutionLike;
18
- }, _options?: {}): RuntimeModelOption[];
19
- export declare class ProbeTimeout extends Error {
20
- }
21
- /** Cancellation always reaches the effect port. A broken port cannot hold callers indefinitely. */
22
- export declare function withModelProbeTimeout<T>(work: (signal: AbortSignal) => Promise<T>, timeoutMs: number, parent?: AbortSignal): Promise<T>;
23
- export declare class ModelProbeError extends Error {
24
- readonly code: ModelCatalogSnapshot['diagnostics'][number]['code'];
25
- constructor(code: ModelCatalogSnapshot['diagnostics'][number]['code']);
26
- }
27
- export {};
1
+ /** Compatibility path; discovery and selection reuse the same framework-free policy. */
2
+ export * from './core/model-discovery-shared.js';
28
3
  //# sourceMappingURL=model-discovery-shared.d.ts.map
@@ -1,88 +1,3 @@
1
- export function modelIdentityKind(id) {
2
- const token = id.slice(id.lastIndexOf('/') + 1);
3
- if (/^(default|auto|adaptive|smart|deep|rush|ultimate|premium|balanced|fast|vercel-ai-gateway|grok-build)$/i.test(token) || /(?:^|[-/])gateway$/i.test(id))
4
- return 'routing-mode';
5
- if (/^(opus|sonnet|haiku|fable|best|latest|claude|gemini|gpt|codex|swe)(?:\[.*\])?$/i.test(token) || /(?:^|[-/])latest$/i.test(id))
6
- return 'alias';
7
- return 'concrete';
8
- }
9
- export function normalizeDiscoveredModels(models) {
10
- const seen = new Set();
11
- return models.flatMap((row) => {
12
- if (!row.id || row.id === 'default' || seen.has(row.id))
13
- return [];
14
- seen.add(row.id);
15
- const model = row;
16
- return [{ ...row, identityKind: model.identityKind ?? modelIdentityKind(row.id) }];
17
- });
18
- }
19
- /** The concrete launch id a catalog row contributes, or undefined when it contributes none. */
20
- function concreteRowId({ row }) {
21
- const id = row.resolvedId || (row.identityKind === 'routing-mode' || row.identityKind === 'alias' ? undefined : row.id);
22
- return id && modelIdentityKind(id) === 'concrete' ? id : undefined;
23
- }
24
- /** Add one row's concrete choice; first position wins, a raw-id label is upgraded later. */
25
- function addConcreteChoice({ choices, row }) {
26
- const id = concreteRowId({ row });
27
- if (!id)
28
- return;
29
- // Older cached inventories can attach a default-policy label to a resolved concrete ID.
30
- const label = row.id === 'default' || /^default\b/i.test(row.label) ? id : row.label;
31
- const existing = choices.get(id);
32
- if (!existing)
33
- choices.set(id, { ...row, id, label, identityKind: 'concrete' });
34
- else if (existing.label === id && label !== id)
35
- choices.set(id, { ...existing, label });
36
- }
37
- /** The resolved concrete default id when it is missing from `choices`, else undefined. */
38
- function missingResolvedDefaultId({ choices }, { resolution } = {}) {
39
- if (resolution?.status !== 'resolved' || !resolution.id)
40
- return undefined;
41
- return modelIdentityKind(resolution.id) === 'concrete' && !choices.has(resolution.id) ? resolution.id : undefined;
42
- }
43
- /** Concrete picker choices, shared with server-side selection validation.
44
- * Aliases contribute their resolved ID; routing modes never become launch IDs.
45
- * Preserves first position and upgrades raw labels. Pure; O(rows) time and space.
46
- */
47
- export function concreteModelOptions({ models = [], supportsConcreteModelSelection, defaultModelResolution }, _options = {}) {
48
- if (supportsConcreteModelSelection === false)
49
- return [];
50
- const choices = new Map();
51
- for (const row of models)
52
- addConcreteChoice({ choices, row });
53
- const options = [...choices.values()];
54
- // A host may publish a resolved default outside its visible catalog. Preserve its concrete ID.
55
- const hiddenDefaultId = missingResolvedDefaultId({ choices }, { resolution: defaultModelResolution });
56
- if (hiddenDefaultId)
57
- options.unshift({ id: hiddenDefaultId, label: hiddenDefaultId, identityKind: 'concrete' });
58
- return options;
59
- }
60
- export class ProbeTimeout extends Error {
61
- }
62
- /** Cancellation always reaches the effect port. A broken port cannot hold callers indefinitely. */
63
- export async function withModelProbeTimeout(work, timeoutMs, parent) {
64
- if (parent?.aborted)
65
- throw new ProbeTimeout('Probe cancelled');
66
- const controller = new AbortController();
67
- let rejectStopped;
68
- const stopped = new Promise((_resolve, reject) => { rejectStopped = reject; });
69
- // `parent` was not aborted above and nothing has awaited since, so listening is enough.
70
- const abortListener = () => { controller.abort(); rejectStopped(new ProbeTimeout('Probe cancelled')); };
71
- parent?.addEventListener('abort', abortListener, { once: true });
72
- const timer = setTimeout(() => { controller.abort(); rejectStopped(new ProbeTimeout('Probe timed out')); }, timeoutMs);
73
- try {
74
- return await Promise.race([work(controller.signal), stopped]);
75
- }
76
- finally {
77
- clearTimeout(timer);
78
- parent?.removeEventListener('abort', abortListener);
79
- }
80
- }
81
- export class ModelProbeError extends Error {
82
- code;
83
- constructor(code) {
84
- super(code);
85
- this.code = code;
86
- }
87
- }
1
+ /** Compatibility path; discovery and selection reuse the same framework-free policy. */
2
+ export * from './core/model-discovery-shared.js';
88
3
  //# sourceMappingURL=model-discovery-shared.js.map
@@ -1,6 +1,6 @@
1
1
  import type { RuntimeModelOption } from './types.js';
2
2
  import type { AgentModelDiscoveryPort, AgentDiscoveryConfiguration, DefaultModelResolution, ModelCatalogSnapshot, ModelDiscoveryContext, ModelDiscoveryDeps, ModelDiscoveryProbes } from './model-discovery-types.js';
3
- export { ModelProbeError, modelIdentityKind, normalizeDiscoveredModels, withModelProbeTimeout } from './model-discovery-shared.js';
3
+ export { ModelProbeError, modelIdentityKind, normalizeDiscoveredModels, withModelProbeTimeout } from './core/model-discovery-shared.js';
4
4
  export type * from './model-discovery-types.js';
5
5
  export declare const MODEL_CATALOG_TTL_MS: number;
6
6
  export declare const MODEL_NEGATIVE_TTL_MS = 30000;
@@ -1,7 +1,7 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { readModelConfiguration } from './model-discovery-config.js';
3
- import { ModelProbeError, ProbeTimeout, modelIdentityKind, normalizeDiscoveredModels, withModelProbeTimeout } from './model-discovery-shared.js';
4
- export { ModelProbeError, modelIdentityKind, normalizeDiscoveredModels, withModelProbeTimeout } from './model-discovery-shared.js';
3
+ import { ModelProbeError, ProbeTimeout, modelIdentityKind, normalizeDiscoveredModels, withModelProbeTimeout } from './core/model-discovery-shared.js';
4
+ export { ModelProbeError, modelIdentityKind, normalizeDiscoveredModels, withModelProbeTimeout } from './core/model-discovery-shared.js';
5
5
  export const MODEL_CATALOG_TTL_MS = 15 * 60_000;
6
6
  export const MODEL_NEGATIVE_TTL_MS = 30_000;
7
7
  const MAX_CATALOG_SCOPES = 128;
package/dist/models.js CHANGED
@@ -1,4 +1,4 @@
1
- import { concreteModelOptions } from './model-discovery-shared.js';
1
+ import { concreteModelOptions } from './core/model-discovery-shared.js';
2
2
  import { defaultRuntimeState } from './runtime-state.js';
3
3
  /** Refusal for an agent that cannot take this pick at all, before any model lookup. */
4
4
  function agentReadinessRefusal({ agent, agentId, modelId, effort }) {
@@ -330,7 +330,7 @@ export declare function handleAnthropicErrorFrame({ data, onEvent, apiKey }: {
330
330
  onEvent: (event: AnthropicTurnEvent) => void;
331
331
  apiKey: string;
332
332
  }): void;
333
- /** The SSE event's dispatch key: `data.type` when present (every real Anthropic frame carries one), else the record's `event:` line, else `''` — a key that intentionally matches no entry in {@link ANTHROPIC_FRAME_HANDLERS} (`message_start`/`message_stop`/`ping`/future event types fall through as no-ops, same as before this frame was a lookup table). */
333
+ /** The SSE event's dispatch key: `data.type` when present (every real Anthropic frame carries one), else the record's `event:` line, else `''` — a key that intentionally matches no entry in {@link ANTHROPIC_FRAME_HANDLERS} (`message_stop`/`ping`/future event types fall through as no-ops, same as before this frame was a lookup table). */
334
334
  export declare function anthropicFrameKind({ data, frameEvent }: {
335
335
  data: Record<string, unknown>;
336
336
  frameEvent: string | null;