@jini-ai/agent-runtime 0.6.19 → 0.6.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 0.6.23
2
+
3
+ - Security hardening.
4
+
5
+ ## 0.6.22
6
+
7
+ - Antigravity moved to its own `defs/antigravity/` folder, with card order and streaming fixes. A runtime can ask for complete stdout lines to be sanitized before live delivery.
8
+
1
9
  ## 0.6.19
2
10
 
3
11
  - Redact OAuth callback, token parsing and file-permission failure diagnostics.
@@ -16,4 +16,4 @@ export declare function handleAntigravityEvent({ frame, emit, state }: {
16
16
  state: AntigravityStreamState;
17
17
  }, _options?: Record<string, never>): boolean;
18
18
  export {};
19
- //# sourceMappingURL=antigravity-event-stream.d.ts.map
19
+ //# sourceMappingURL=event-stream.d.ts.map
@@ -80,4 +80,4 @@ export function handleAntigravityEvent({ frame, emit, state }, _options = {}) {
80
80
  toolStep({ step, emit, state });
81
81
  return true;
82
82
  }
83
- //# sourceMappingURL=antigravity-event-stream.js.map
83
+ //# sourceMappingURL=event-stream.js.map
@@ -1,4 +1,4 @@
1
- import type { RuntimeBuildOptions, RuntimeContext, RuntimeModelOption } from '../types.js';
1
+ import type { RuntimeBuildOptions, RuntimeContext, RuntimeModelOption } from '../../types.js';
2
2
  /**
3
3
  * Redacts any OAuth sign-in URL from agy's buffered print-mode stdout,
4
4
  * leaving all other output byte-identical.
@@ -18,6 +18,15 @@ import type { RuntimeBuildOptions, RuntimeContext, RuntimeModelOption } from '..
18
18
  export declare function redactAntigravityAuthUrls({ fullText }: {
19
19
  fullText: string;
20
20
  }): string;
21
+ /** Redact JSON string values before parsing/delivery, preserving escaped quotes and line framing.
22
+ * Plain auth prompts use the same URL redactor; no raw sign-in URL reaches the event stream.
23
+ * @returns A sanitized complete wire line; never throws for malformed CLI output.
24
+ * @complexity O(n) time/space for n line characters; no I/O or retained state.
25
+ * @example sanitizeAntigravityWireLine({ fullText: '{"event":"init"}\n' });
26
+ */
27
+ export declare function sanitizeAntigravityWireLine({ fullText }: {
28
+ fullText: string;
29
+ }, _options?: Record<string, never>): string;
21
30
  /**
22
31
  * Parses `agy models`' stdout into the shared `RuntimeModelOption[]` shape.
23
32
  *
@@ -73,26 +82,26 @@ export declare const antigravityAgentDef: {
73
82
  supportsNativeToolAccess: false;
74
83
  needsAgentLogFile: true;
75
84
  stdoutPolicy: {
76
- buffering: "until-close";
77
- sanitize: typeof redactAntigravityAuthUrls;
85
+ buffering: "line";
86
+ sanitize: typeof sanitizeAntigravityWireLine;
78
87
  };
79
88
  installUrl: string;
80
89
  docsUrl: string;
81
90
  externalMcpInjection: "env-passthrough";
82
91
  discoverModels(requiredArgs: {
83
- context: import("../model-discovery-types.js").ModelDiscoveryContext;
92
+ context: import("../../model-discovery-types.js").ModelDiscoveryContext;
84
93
  }, optionalArgs?: {
85
94
  signal?: AbortSignal;
86
95
  force?: boolean;
87
96
  staleWhileRevalidate?: boolean;
88
- deps?: import("../model-discovery-types.js").ModelDiscoveryDeps;
89
- }): Promise<import("../model-discovery-types.js").ModelCatalogSnapshot>;
97
+ deps?: import("../../model-discovery-types.js").ModelDiscoveryDeps;
98
+ }): Promise<import("../../model-discovery-types.js").ModelCatalogSnapshot>;
90
99
  resolveDefaultModel(requiredArgs: {
91
- context: import("../model-discovery-types.js").ModelDiscoveryContext;
92
- catalog: import("../model-discovery-types.js").ModelCatalogSnapshot;
100
+ context: import("../../model-discovery-types.js").ModelDiscoveryContext;
101
+ catalog: import("../../model-discovery-types.js").ModelCatalogSnapshot;
93
102
  }, optionalArgs?: {
94
103
  signal?: AbortSignal;
95
- deps?: import("../model-discovery-types.js").ModelDiscoveryDeps;
96
- }): Promise<import("../model-discovery-types.js").DefaultModelResolution>;
104
+ deps?: import("../../model-discovery-types.js").ModelDiscoveryDeps;
105
+ }): Promise<import("../../model-discovery-types.js").DefaultModelResolution>;
97
106
  };
98
- //# sourceMappingURL=antigravity.d.ts.map
107
+ //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,6 @@
1
- import { createAgentModelDiscovery } from '../model-discovery-native.js';
1
+ import { createAgentModelDiscovery } from '../../model-discovery-native.js';
2
2
  import { redactOAuthUrls } from '@jini-ai/oauth';
3
- import { DEFAULT_MODEL_OPTION } from './shared.js';
3
+ import { DEFAULT_MODEL_OPTION } from '../shared.js';
4
4
  // `agy` v1.1.24 has a real `--model <id>` flag (`agy --help`: "Model for the current CLI
5
5
  // session") plus a machine-readable `agy models` subcommand that lists every selectable model as
6
6
  // a stable `<slug>\t<label>` pair — both verified live, neither true of the v1.0.3 this file used
@@ -38,7 +38,7 @@ import { DEFAULT_MODEL_OPTION } from './shared.js';
38
38
  // - it is also useless to click: `-p` print mode has no field to paste the
39
39
  // resulting auth code back into (see `auth.ts`'s
40
40
  // `antigravityAuthGuidance`), so the only outcome is a leaked URL.
41
- // Hence `stdoutPolicy: {buffering: 'until-close'}` plus this redactor.
41
+ // Complete stdout lines must be redacted before delivery, including a URL split across chunks.
42
42
  //
43
43
  // The shape being matched is real, not guessed — it is the same text this
44
44
  // package's own `isAntigravityAuthFailureText` already classifies, captured
@@ -79,6 +79,23 @@ const OAUTH_URL_PLACEHOLDER = '[redacted sign-in URL]';
79
79
  export function redactAntigravityAuthUrls({ fullText }) {
80
80
  return redactOAuthUrls({ text: fullText, pattern: OAUTH_URL_PATTERN, replacement: OAUTH_URL_PLACEHOLDER });
81
81
  }
82
+ /** Redact JSON string values before parsing/delivery, preserving escaped quotes and line framing.
83
+ * Plain auth prompts use the same URL redactor; no raw sign-in URL reaches the event stream.
84
+ * @returns A sanitized complete wire line; never throws for malformed CLI output.
85
+ * @complexity O(n) time/space for n line characters; no I/O or retained state.
86
+ * @example sanitizeAntigravityWireLine({ fullText: '{"event":"init"}\n' });
87
+ */
88
+ export function sanitizeAntigravityWireLine({ fullText }, _options = {}) {
89
+ let frame;
90
+ try {
91
+ frame = JSON.parse(fullText);
92
+ }
93
+ catch {
94
+ return redactAntigravityAuthUrls({ fullText });
95
+ }
96
+ const safe = JSON.stringify(frame, (_key, value) => typeof value === 'string' ? redactAntigravityAuthUrls({ fullText: value }) : value);
97
+ return safe + (fullText.endsWith('\n') ? '\n' : '');
98
+ }
82
99
  /**
83
100
  * Parses `agy models`' stdout into the shared `RuntimeModelOption[]` shape.
84
101
  *
@@ -256,13 +273,13 @@ export const antigravityAgentDef = {
256
273
  // only way to tell those two apart — see server.ts's empty-output guard
257
274
  // for the consumer.
258
275
  needsAgentLogFile: true,
259
- // The one adapter in this package that must not stream live — see
276
+ // Sanitize each complete wire line before live parsing/diagnostics — see
260
277
  // `redactAntigravityAuthUrls`'s comment for the OAuth-URL-on-stdout-plus-
261
- // exit-0 behavior that forces it. Every other `streamFormat: 'plain'`
278
+ // exit-0 behavior that requires redaction. Every other `streamFormat: 'plain'`
262
279
  // adapter (grok-build, aider, deepseek, qwen) leaves `stdoutPolicy` unset
263
280
  // and keeps streaming per chunk; aider's and deepseek's own comments call
264
281
  // that live cadence out as deliberate.
265
- stdoutPolicy: { buffering: 'until-close', sanitize: redactAntigravityAuthUrls },
282
+ stdoutPolicy: { buffering: 'line', sanitize: sanitizeAntigravityWireLine },
266
283
  installUrl: 'https://antigravity.google/cli',
267
284
  docsUrl: 'https://antigravity.google/docs/cli-overview',
268
285
  // `externalMcpInjection: 'env-passthrough'` — the prior verdict here ("no safe, run-scoped
@@ -340,4 +357,4 @@ function antigravityModelRow(line) {
340
357
  // side: neither the id nor the label can come out empty here.
341
358
  return { id: line.slice(0, tabIndex).trim(), label: line.slice(tabIndex + 1).trim() };
342
359
  }
343
- //# sourceMappingURL=antigravity.js.map
360
+ //# sourceMappingURL=index.js.map
@@ -5,7 +5,7 @@
5
5
  export * from './aider.js';
6
6
  export * from './amp.js';
7
7
  export * from './amr.js';
8
- export * from './antigravity.js';
8
+ export * from './antigravity/index.js';
9
9
  export * from './auggie.js';
10
10
  export * from './claude.js';
11
11
  export * from './cline.js';
@@ -5,7 +5,7 @@
5
5
  export * from './aider.js';
6
6
  export * from './amp.js';
7
7
  export * from './amr.js';
8
- export * from './antigravity.js';
8
+ export * from './antigravity/index.js';
9
9
  export * from './auggie.js';
10
10
  export * from './claude.js';
11
11
  export * from './cline.js';
@@ -1,11 +1,26 @@
1
1
  /**
2
2
  * @module diagnostics
3
- * Explain three detection failures: unresolved executable, uninvocable executable or missing authentication.
3
+ * Explain executable/authentication detection failures and preserve safe startup evidence.
4
4
  */
5
5
  import { type ExecutableResolutionOptions } from './executables.js';
6
6
  import type { AgentLaunchResolution } from './launch.js';
7
7
  import type { AgentAuthProbeResult } from './auth.js';
8
8
  import type { AgentDiagnostic, RuntimeAgentDef } from './types.js';
9
+ /** Pasteable startup evidence, redacted before a UTF-8 byte cap is applied. No stack or input
10
+ * envelope is copied; deepest causes come first so a long wrapper cannot hide the cause.
11
+ * @param required Stage owned by the caller and the thrown startup value.
12
+ * @param options Exact host secrets and caller wording for an unconfirmed start response.
13
+ * @returns At most 2 KiB of actionable text; hostile diagnostic getters never escape.
14
+ * @complexity O(n) time/space in the messages read, with at most four causes; no I/O.
15
+ * @example startupFailureMessage({ stage: 'session binding', error }, {});
16
+ */
17
+ export declare function startupFailureMessage({ stage, error }: {
18
+ stage: string;
19
+ error: unknown;
20
+ }, { exactSecrets, notice }?: {
21
+ exactSecrets?: readonly string[];
22
+ notice?: string;
23
+ }): string;
9
24
  export declare function buildExecutableDiagnostic({ def }: {
10
25
  def: Pick<RuntimeAgentDef, 'id' | 'name' | 'bin'>;
11
26
  }, { configuredEnv, ...options }?: ExecutableResolutionOptions & {
@@ -1,8 +1,51 @@
1
1
  /**
2
2
  * @module diagnostics
3
- * Explain three detection failures: unresolved executable, uninvocable executable or missing authentication.
3
+ * Explain executable/authentication detection failures and preserve safe startup evidence.
4
4
  */
5
5
  import { agentBinEnvKey, agentSearchDirs } from './executables.js';
6
+ import { formatErrorForLog } from '@jini-ai/core';
7
+ /** Pasteable startup evidence, redacted before a UTF-8 byte cap is applied. No stack or input
8
+ * envelope is copied; deepest causes come first so a long wrapper cannot hide the cause.
9
+ * @param required Stage owned by the caller and the thrown startup value.
10
+ * @param options Exact host secrets and caller wording for an unconfirmed start response.
11
+ * @returns At most 2 KiB of actionable text; hostile diagnostic getters never escape.
12
+ * @complexity O(n) time/space in the messages read, with at most four causes; no I/O.
13
+ * @example startupFailureMessage({ stage: 'session binding', error }, {});
14
+ */
15
+ export function startupFailureMessage({ stage, error }, { exactSecrets = [], notice = 'The assistant could not start. Correct the reported cause, then send again.' } = {}) {
16
+ let cause;
17
+ try {
18
+ cause = startupCauseText({ error });
19
+ }
20
+ catch {
21
+ cause = 'The error details could not be read.';
22
+ }
23
+ const safe = formatErrorForLog({ error: `${notice}\nStartup stage: ${stage}\nCause: ${cause}` }, { exactSecrets });
24
+ const bytes = new TextEncoder().encode(safe);
25
+ if (bytes.length <= 2048)
26
+ return safe;
27
+ // Streaming decode drops an incomplete trailing code point rather than inserting U+FFFD.
28
+ return new TextDecoder().decode(bytes.subarray(0, 2045), { stream: true }) + '…';
29
+ }
30
+ /** Bound cause traversal (including cycles); copy diagnostic fields only, never environment data. */
31
+ function startupCauseText({ error }) {
32
+ const parts = [];
33
+ const seen = new Set();
34
+ let current = error;
35
+ while (current != null && !seen.has(current) && parts.length < 4) {
36
+ seen.add(current);
37
+ parts.push(startupErrorPart({ error: current }));
38
+ current = typeof current === 'object' ? current.cause : undefined;
39
+ }
40
+ return parts.reverse().join('\nCaused by: ') || 'No startup cause was supplied.';
41
+ }
42
+ /** Retain plain messages and OS/provider codes without serializing arbitrary object fields. */
43
+ function startupErrorPart({ error }) {
44
+ if (typeof error !== 'object' || error === null)
45
+ return String(error);
46
+ const { message, code } = error;
47
+ return [code, message].filter(value => typeof value === 'string' || typeof value === 'number').join(': ') || 'Startup error without a message';
48
+ }
6
49
  // Cap on how many searched dirs we attach to a `not-on-path` diagnostic.
7
50
  // The resolver walks PATH + the user-toolchain whitelist, which can run to
8
51
  // dozens of entries; the UI only needs enough to make "we looked here"
@@ -1,7 +1,7 @@
1
1
  /** @module json-event-stream
2
2
  * Multi-CLI JSON event parsing with per-handler stream state. */
3
3
  import { sanitizeUntrustedText } from '@jini-ai/core/text';
4
- import { handleAntigravityEvent } from './defs/antigravity-event-stream.js';
4
+ import { handleAntigravityEvent } from './defs/antigravity/event-stream.js';
5
5
  function isRecord(value) {
6
6
  return value != null && typeof value === 'object' && !Array.isArray(value);
7
7
  }
@@ -58,7 +58,7 @@ function nativeToolPolicyRefusal({ cliName, offSwitches }, _options = {}) {
58
58
  const blocked = switches.length > 0 ? `with ${new Intl.ListFormat('en', { type: 'conjunction' }).format(switches)} off` : `with this chat's CLI tool limits`;
59
59
  const pronoun = switches.length === 1 ? 'it' : 'them';
60
60
  const action = switches.length === 0 ? `Turn on 'Full CLI access'` : `Turn ${pronoun} on`;
61
- return `${cliName} can't run ${blocked}. ${action} in the assistant settings, or choose Claude or Codex.`;
61
+ return `${cliName} can't run ${blocked}. ${action} in gear → More settings → Agent permissions, or choose an available agent that supports these limits.`;
62
62
  }
63
63
  /** The same fail-closed assessment at selection and spawn; no CLI-name allowlist.
64
64
  * Unknown explicit OFF switches stay blocked. O(c) over declared limits, without effects.
package/dist/types.d.ts CHANGED
@@ -169,6 +169,13 @@ export type RuntimeStdoutPolicy =
169
169
  {
170
170
  readonly buffering: 'live';
171
171
  }
172
+ /** Sanitize complete stdout lines before live delivery; partial lines remain bounded by the host. */
173
+ | {
174
+ readonly buffering: 'line';
175
+ readonly sanitize: (requiredArgs: {
176
+ fullText: string;
177
+ }) => string;
178
+ }
172
179
  /**
173
180
  * Accumulate every stdout chunk and forward the whole thing exactly once,
174
181
  * after the child process closes. For adapters that can print a secret
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jini-ai/agent-runtime",
3
- "version": "0.6.19",
3
+ "version": "0.6.23",
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": {
@@ -120,15 +120,15 @@
120
120
  "devDependencies": {
121
121
  "@vitest/coverage-v8": "^2.1.9",
122
122
  "@jini-ai/core": "^0.6.13",
123
- "@jini-ai/integrations": "^0.6.19",
124
- "@jini-ai/platform": "^0.6.19"
123
+ "@jini-ai/platform": "^0.6.23",
124
+ "@jini-ai/integrations": "^0.6.19"
125
125
  },
126
126
  "dependencies": {
127
- "@jini-ai/core": "^0.6.19",
128
- "@jini-ai/platform": "^0.6.19",
129
- "@jini-ai/protocol": "^0.6.19",
127
+ "@jini-ai/core": "^0.6.23",
128
+ "@jini-ai/integrations": "^0.6.19",
129
+ "@jini-ai/platform": "^0.6.23",
130
130
  "@jini-ai/oauth": "^0.6.19",
131
- "@jini-ai/integrations": "^0.6.19"
131
+ "@jini-ai/protocol": "^0.6.19"
132
132
  },
133
133
  "scripts": {
134
134
  "build": "tsc -p tsconfig.json",