@jini-ai/agent-runtime 0.4.12 → 0.6.10

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,82 @@
1
+ ## 0.6.10
2
+
3
+ ### Patch Changes
4
+
5
+ - 3fe4d14: Parse optional delegated-result markers while preserving the CLI call id and original content for daemon validation.
6
+
7
+ 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.
8
+
9
+ - aad3d2e: Add the optional `onUnexposedToolCall` refusal hook to `runProviderToolTurn` for all four
10
+ provider protocols. Hosts can await audit writes and supply uniform refusal text without
11
+ calling the normal tool executor. Results remain errors; omitted hooks and `undefined`
12
+ replies preserve the existing refusal text and protocol formatting. Hook failures propagate
13
+ without falling through to execution.
14
+ - 8ff5653: Drive Antigravity (`agy`) — the 24th and last agent definition `AgentExecutor` rejected.
15
+
16
+ `AgentExecutor` drove 23 of 24 registered definitions. Antigravity was rejected by an explicit
17
+ `def.id === 'antigravity'` guard, for two reasons that are real but narrow:
18
+
19
+ - **`agy` can print an OAuth sign-in URL to stdout and still exit 0.** Streaming stdout live shows
20
+ that URL to the user as if it were the model's reply — a URL that carries the daemon operator's
21
+ `client_id`/`redirect_uri` into a chat transcript, and that is useless to click anyway (`agy -p`
22
+ print mode has no field to paste the resulting auth code into).
23
+ - **`agy` has no `--model` flag.** The model choice is written into one process-global
24
+ `~/.gemini/antigravity-cli/settings.json` that `agy` reads on its own startup, so two concurrent
25
+ runs race: run A writes model A, A spawns, B writes model B, and only _then_ does A's `agy` read
26
+ the file — so A silently executes on B's model.
27
+
28
+ Both are now met by **declarative `RuntimeAgentDef` fields the executor reads generically**, joining
29
+ the 14 optional behavior flags (`promptViaFile`, `authProbe`, …) that already work this way. There is
30
+ no agent-id branch anywhere in the dispatch path — a deliberate divergence from Open Design's own
31
+ daemon, which hardcodes the id twice.
32
+
33
+ New on `@jini-ai/agent-runtime`'s `RuntimeAgentDef`:
34
+
35
+ - `needsAgentLogFile?: boolean` — asks the caller to stage a temp path and pass it as
36
+ `RuntimeContext.agentLogFilePath` before `buildArgs` runs, mirroring `promptViaFile`. Staged by the
37
+ new `prepareAgentLogFile(def, label)` (the sibling of `preparePromptFileForAgent`; it creates only
38
+ the `0o700` containing directory, since the log file is output the CLI authors, not input we do).
39
+ - `stdoutPolicy?: RuntimeStdoutPolicy` — `{buffering: 'live'}` (the default, and every other
40
+ definition's behavior) or `{buffering: 'until-close', sanitize?}`. A discriminated union rather
41
+ than two flat fields on purpose: a sanitizer is only meaningful on the buffered path, because the
42
+ pattern to redact can straddle two `'data'` chunks. Two independent flags would let a definition
43
+ declare a sanitizer the caller could not honor — a confidentiality gap that _looks_ closed.
44
+ - `runtimeLock?: RuntimeLock` — a mutex around a process-global side effect `buildArgs` performs.
45
+ Acquired before `buildArgs`, released on whichever of `waitForHandoff` settling or process exit
46
+ comes first. Releasing on exit is load-bearing, not a fallback: a watcher that stops polling means
47
+ "I stopped watching", never "the child definitely didn't read the file".
48
+
49
+ All three are stripped from the `DetectedAgent` registry projection. They instruct whoever _spawns_
50
+ the CLI, not whoever lists agents — and two carry closures, which `JSON.stringify` would flatten into
51
+ a misleading `{"buffering":"until-close"}` / `{}` rather than omit.
52
+
53
+ In `@jini-ai/daemon`, `AgentExecutor` now stages a log file when `needsAgentLogFile` is set (released
54
+ on every pre-spawn, spawn-failure, and close path alongside the prompt file, through one composed
55
+ `cleanupStagedFiles` closure), calls `runtimeLock.acquire()` before `buildArgs`, and branches its
56
+ `streamFormat: 'plain'` stdout handling on `stdoutPolicy`. `assessAgentExecutorCompatibility` no
57
+ longer rejects anything by id, and `isAgentExecutorSupported` now accepts all 24 definitions.
58
+
59
+ **No behavior change for any other agent.** Antigravity is the only definition declaring any of the
60
+ three fields; the other four `streamFormat: 'plain'` definitions (`grok-build`, `aider`, `deepseek`,
61
+ `qwen`) keep streaming live, per chunk, which `aider`'s and `deepseek`'s own comments call out as
62
+ deliberate. That is pinned by an explicit regression test rather than left implied.
63
+
64
+ One thing worth knowing if you consume the run event stream: on the buffered path the raw `'stdout'`
65
+ echo is held back and sanitized too, not just the `'agent'`/`text_delta` copy. Emitting an
66
+ unsanitized raw echo while withholding the chat copy would leak the exact string the sanitizer exists
67
+ to remove to any subscriber. The opt-in byte journal still records raw bytes per chunk — that is its
68
+ documented contract, and it deliberately lives in a separate `EventLog` instance that is never
69
+ replayed to run-event subscribers.
70
+
71
+ - e16a907: Add optional adapter-owned usageCostBasis metadata; Claude declares that its reported dollars are cumulative within a session.
72
+ - Updated dependencies [22f0619]
73
+ - Updated dependencies [82ed2d3]
74
+ - Updated dependencies [3fe4d14]
75
+ - Updated dependencies [5a3de86]
76
+ - @jini-ai/core@0.6.10
77
+ - @jini-ai/protocol@0.6.10
78
+ - @jini-ai/oauth@0.6.10
79
+
1
80
  ## 0.4.12 — 2026-10-22
2
81
 
3
82
  - 2026-10-22: Probe-gated chromeIntegration build option, declarative supportsSubagents, network-capture and asset-harvest fixes, coverage.
@@ -67,7 +146,6 @@
67
146
  - Model catalog clocks use core `Clock.nowMs()`; ACP unknown-value records are named `UnknownRecord`, not JSON objects.
68
147
  - 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
148
 
70
-
71
149
  - Preserve host environment customization after CLI housekeeping; correct the hook documentation.
72
150
  - Keep DNS resolver injection required and reject lookup failures or empty answers instead of allowing unpinned fallback.
73
151
  - Validate model catalogue variants with an explicit `TypeError` before trimming.
@@ -75,6 +75,8 @@ export type ClaudeStreamEvent = {
75
75
  toolUseId: unknown;
76
76
  content: string;
77
77
  isError: boolean;
78
+ delegatedToolUseId?: string;
79
+ delegatedResultContent?: readonly unknown[];
78
80
  } | {
79
81
  type: 'turn_end';
80
82
  stopReason: string;
@@ -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
  }
@@ -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
- * Work is O(n log n + s) per snapshot for n IDs and s bounded expanded schema nodes; no I/O.
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
- async execute(call) {
124
- if (!published.has(call.name))
125
- return { isError: true, content: 'Tool is not exposed in this turn.' };
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jini-ai/agent-runtime",
3
- "version": "0.4.12",
3
+ "version": "0.6.10",
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.4.0",
111
- "@jini-ai/integrations": "^0.4.3",
112
- "@jini-ai/protocol": "^0.4.5",
113
- "@jini-ai/platform": "^0.5.10"
110
+ "@jini-ai/core": "^0.6.10",
111
+ "@jini-ai/integrations": "^0.6.10",
112
+ "@jini-ai/platform": "^0.6.10"
114
113
  },
115
114
  "dependencies": {
116
- "@jini-ai/core": "^0.4.9",
117
- "@jini-ai/oauth": "^0.2.3"
115
+ "@jini-ai/core": "^0.6.10",
116
+ "@jini-ai/oauth": "^0.6.10",
117
+ "@jini-ai/protocol": "^0.6.10"
118
118
  },
119
119
  "peerDependencies": {
120
- "@jini-ai/integrations": "^0.4.2",
120
+ "@jini-ai/integrations": "^0.6.10",
121
121
  "@github/copilot-sdk": "*",
122
- "@jini-ai/platform": "^0.5.5",
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": {