@jini-ai/agent-runtime 0.6.12 → 0.6.15-rc.2
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 +33 -0
- package/dist/agent-protocol/acp/json.d.ts +1 -1
- package/dist/agent-protocol/acp/json.js +6 -3
- package/dist/agent-protocol/acp/models.js +53 -15
- package/dist/agent-protocol/acp/rpc.js +1 -1
- package/dist/agent-protocol/acp/session.d.ts +1 -1
- package/dist/agent-protocol/acp/session.js +30 -18
- package/dist/agent-protocol/acp/text-suppression.js +2 -1
- package/dist/ai-trace/capture.d.ts +17 -0
- package/dist/ai-trace/capture.js +43 -0
- package/dist/ai-trace/classify.d.ts +12 -0
- package/dist/ai-trace/classify.js +13 -0
- package/dist/ai-trace/index.d.ts +13 -0
- package/dist/ai-trace/index.js +6 -0
- package/dist/ai-trace/recorder.d.ts +65 -0
- package/dist/ai-trace/recorder.js +259 -0
- package/dist/ai-trace/sinks.d.ts +51 -0
- package/dist/ai-trace/sinks.js +137 -0
- package/dist/ai-trace/types.d.ts +123 -0
- package/dist/ai-trace/types.js +17 -0
- package/dist/ai-trace/usage.d.ts +13 -0
- package/dist/ai-trace/usage.js +43 -0
- package/dist/claude-filesystem-policy.d.ts +25 -3
- package/dist/claude-filesystem-policy.js +104 -14
- package/dist/core/model-discovery-shared.d.ts +28 -0
- package/dist/core/model-discovery-shared.js +88 -0
- package/dist/defs/antigravity.js +10 -2
- package/dist/defs/claude.js +2 -1
- package/dist/defs/codex.js +13 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/model-discovery-adapters.js +1 -1
- package/dist/model-discovery-shared.d.ts +2 -27
- package/dist/model-discovery-shared.js +2 -87
- package/dist/model-discovery.d.ts +1 -1
- package/dist/model-discovery.js +2 -2
- package/dist/models.js +1 -1
- package/dist/providers/anthropic-messages.d.ts +1 -1
- package/dist/providers/anthropic-messages.js +10 -4
- package/dist/providers/tool-turn.js +12 -43
- package/dist/types.d.ts +4 -0
- package/package.json +16 -10
|
@@ -285,8 +285,8 @@ export function handleMessageDelta({ state, data, onEvent }) {
|
|
|
285
285
|
state.stopReason = data.delta.stop_reason;
|
|
286
286
|
}
|
|
287
287
|
if (isRecord(data.usage)) {
|
|
288
|
-
state.usage = data.usage;
|
|
289
|
-
onEvent({ type: 'usage', usage:
|
|
288
|
+
state.usage = { ...state.usage, ...data.usage };
|
|
289
|
+
onEvent({ type: 'usage', usage: state.usage });
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
export function handleAnthropicErrorFrame({ data, onEvent, apiKey }) {
|
|
@@ -294,7 +294,7 @@ export function handleAnthropicErrorFrame({ data, onEvent, apiKey }) {
|
|
|
294
294
|
const errorType = isRecord(data.error) && typeof data.error.type === 'string' ? data.error.type : undefined;
|
|
295
295
|
onEvent({ type: 'error', message: redactSecrets({ input: errorDetail }, { exactSecrets: [apiKey] }), ...(errorType ? { code: errorType } : {}) });
|
|
296
296
|
}
|
|
297
|
-
/** 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} (`
|
|
297
|
+
/** 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). */
|
|
298
298
|
export function anthropicFrameKind({ data, frameEvent }) {
|
|
299
299
|
if (typeof data.type === 'string')
|
|
300
300
|
return data.type;
|
|
@@ -302,6 +302,12 @@ export function anthropicFrameKind({ data, frameEvent }) {
|
|
|
302
302
|
}
|
|
303
303
|
/** One entry per SSE event kind this adapter reacts to. Replaces a sequential if-chain over `kind` — every branch below is now a single object-key lookup instead of N nesting-penalized `if` statements (see `runSingleAnthropicRequest`'s doc for the resulting flat loop). */
|
|
304
304
|
const ANTHROPIC_FRAME_HANDLERS = {
|
|
305
|
+
message_start: (state, data) => {
|
|
306
|
+
// Input usage arrives at message_start; message_delta supplies cumulative output usage.
|
|
307
|
+
if (isRecord(data.message) && isRecord(data.message.usage))
|
|
308
|
+
state.usage = data.message.usage;
|
|
309
|
+
return { action: 'continue' };
|
|
310
|
+
},
|
|
305
311
|
content_block_start: (state, data) => {
|
|
306
312
|
handleContentBlockStart({ state: state, data: data });
|
|
307
313
|
return { action: 'continue' };
|
|
@@ -420,7 +426,7 @@ async function runSingleAnthropicRequest(options, messages, emitEnd, retry) {
|
|
|
420
426
|
continue; // malformed/empty keep-alive frame, or a non-object payload
|
|
421
427
|
const handler = ANTHROPIC_FRAME_HANDLERS[anthropicFrameKind({ data: data, frameEvent: frame.event })];
|
|
422
428
|
if (!handler)
|
|
423
|
-
continue; // `
|
|
429
|
+
continue; // `message_stop`, `ping`, or a future event type — nothing to do
|
|
424
430
|
const outcome = handler(state, data, onEvent, options.apiKey);
|
|
425
431
|
if (outcome.action === 'end') {
|
|
426
432
|
emitEnd(outcome.reason);
|
|
@@ -193,7 +193,8 @@ async function runAnthropicTurn(input) {
|
|
|
193
193
|
});
|
|
194
194
|
return normalizeTurnResult(result, capturedEndReason);
|
|
195
195
|
}
|
|
196
|
-
|
|
196
|
+
/** OpenAI and Azure share message/tool projection; the selected adapter retains its native request semantics. */
|
|
197
|
+
async function runOpenAiCompatibleTurn(input, _options = {}) {
|
|
197
198
|
const projection = createToolProjection(input);
|
|
198
199
|
const getTools = (options = {}) => openAiTools(projection.getTools(options));
|
|
199
200
|
const tools = openAiTools(projection.getTools({}, { reportFallback: false }));
|
|
@@ -208,7 +209,14 @@ async function runOpenAiTurn(input) {
|
|
|
208
209
|
return { content: foldToolError(toOpenAiToolContent(result.content), result.isError) };
|
|
209
210
|
};
|
|
210
211
|
let capturedEndReason = null;
|
|
211
|
-
const result = await (({ apiKey, model, messages, onEvent, ...optionalArgs }) =>
|
|
212
|
+
const result = await (({ apiKey, model, messages, onEvent, ...optionalArgs }) => {
|
|
213
|
+
if (input.protocol === 'azure') {
|
|
214
|
+
// runAzureTurn checks the required endpoint before any projection or adapter work.
|
|
215
|
+
const { baseUrl, ...azureOptions } = optionalArgs;
|
|
216
|
+
return input.adapters.azure({ apiKey, baseUrl: baseUrl, model, messages, onEvent }, azureOptions);
|
|
217
|
+
}
|
|
218
|
+
return input.adapters.openai({ apiKey, model, messages, onEvent }, optionalArgs);
|
|
219
|
+
})({
|
|
212
220
|
apiKey: input.apiKey,
|
|
213
221
|
...(input.baseUrl ? { baseUrl: input.baseUrl } : {}),
|
|
214
222
|
model: input.model,
|
|
@@ -241,46 +249,7 @@ async function runAzureTurn(input) {
|
|
|
241
249
|
input.onEvent({ type: "end", reason: "error" });
|
|
242
250
|
return { stopReason: "error", toolTurns: 0 };
|
|
243
251
|
}
|
|
244
|
-
|
|
245
|
-
const getTools = (options = {}) => openAiTools(projection.getTools(options));
|
|
246
|
-
const tools = openAiTools(projection.getTools({}, { reportFallback: false }));
|
|
247
|
-
const messages = [
|
|
248
|
-
{ role: "system", content: input.system },
|
|
249
|
-
...input.messages.map((m) => ({ role: m.role, content: m.images?.length ? toOpenAiToolContent([
|
|
250
|
-
{ type: 'text', text: m.content }, ...m.images.map(image => ({ type: 'image', ...image })),
|
|
251
|
-
]) : m.content })),
|
|
252
|
-
];
|
|
253
|
-
const executeTool = async (call) => {
|
|
254
|
-
const result = await projection.execute({ id: call.id, name: call.name, input: call.input });
|
|
255
|
-
return { content: foldToolError(toOpenAiToolContent(result.content), result.isError) };
|
|
256
|
-
};
|
|
257
|
-
let capturedEndReason = null;
|
|
258
|
-
const result = await (({ apiKey, baseUrl, model, messages, onEvent, ...optionalArgs }) => input.adapters.azure({ apiKey, baseUrl, model, messages, onEvent }, optionalArgs))({
|
|
259
|
-
apiKey: input.apiKey,
|
|
260
|
-
baseUrl: input.baseUrl,
|
|
261
|
-
model: input.model,
|
|
262
|
-
messages,
|
|
263
|
-
tools,
|
|
264
|
-
getTools,
|
|
265
|
-
...(input.onSchemaFallback ? { onSchemaFallback: input.onSchemaFallback } : {}),
|
|
266
|
-
...(input.maxTokens !== undefined ? { maxTokens: input.maxTokens } : {}),
|
|
267
|
-
...(input.maxToolTurns !== undefined ? { maxToolTurns: input.maxToolTurns } : {}),
|
|
268
|
-
executeTool,
|
|
269
|
-
...(input.signal ? { signal: input.signal } : {}),
|
|
270
|
-
onEvent: (event) => {
|
|
271
|
-
if (event.type === "fabricated_role_marker")
|
|
272
|
-
return;
|
|
273
|
-
if (event.type === "end")
|
|
274
|
-
capturedEndReason = event.reason;
|
|
275
|
-
if (event.type === "tool_result") {
|
|
276
|
-
const content = describeToolResultContent(event.content);
|
|
277
|
-
input.onEvent({ type: "tool_result", toolUseId: event.toolUseId, content, isError: event.isError || content.startsWith(TOOL_ERROR_PREFIX.trimEnd()) });
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
projection.onEvent(event);
|
|
281
|
-
},
|
|
282
|
-
});
|
|
283
|
-
return normalizeTurnResult(result, capturedEndReason);
|
|
252
|
+
return runOpenAiCompatibleTurn(input);
|
|
284
253
|
}
|
|
285
254
|
async function runGoogleTurn(input) {
|
|
286
255
|
const projection = createToolProjection(input);
|
|
@@ -336,7 +305,7 @@ export async function runProviderToolTurn(required, optional = {}) {
|
|
|
336
305
|
case "anthropic":
|
|
337
306
|
return runAnthropicTurn(input);
|
|
338
307
|
case "openai":
|
|
339
|
-
return
|
|
308
|
+
return runOpenAiCompatibleTurn(input);
|
|
340
309
|
case "azure":
|
|
341
310
|
return runAzureTurn(input);
|
|
342
311
|
case "google":
|
package/dist/types.d.ts
CHANGED
|
@@ -81,8 +81,12 @@ export type RuntimeBuildOptions = {
|
|
|
81
81
|
filesystemTempDir?: string;
|
|
82
82
|
/** Shared host/login temp roots denied even when child TMPDIR is replaced. */
|
|
83
83
|
filesystemSharedTempRoots?: readonly string[];
|
|
84
|
+
/** Executor-created per-run CLAUDE_CODE_TMPDIR; its /claude-<uid> child must fit 44 bytes. Absent grants no runtime scratch. */
|
|
85
|
+
filesystemRuntimeTempBase?: string;
|
|
84
86
|
/** Executor-resolved CLI/runtime files; read-only exceptions for sandboxed commands. */
|
|
85
87
|
filesystemRuntimeReadPaths?: readonly string[];
|
|
88
|
+
/** Host-validated owner-picked folders outside filesystemRoot: natively readable, never writable. */
|
|
89
|
+
filesystemReadOnlyDirs?: readonly string[];
|
|
86
90
|
/** Host-verified per-run overrides; false dimensions must be enforced or launch refused. */
|
|
87
91
|
nativeCapabilities?: Partial<import('./native-tool-policy.js').NativeCapabilities>;
|
|
88
92
|
/** 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.6.
|
|
3
|
+
"version": "0.6.15-rc.2",
|
|
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": {
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"./model-catalog/cache": "universal",
|
|
19
19
|
"./providers/sse-decode": "universal",
|
|
20
20
|
"./model-discovery": "node",
|
|
21
|
-
"./model-selection": "universal"
|
|
21
|
+
"./model-selection": "universal",
|
|
22
|
+
"./ai-trace": "universal"
|
|
22
23
|
},
|
|
23
24
|
"isolation": {
|
|
24
25
|
"forbidden": {
|
|
@@ -68,6 +69,11 @@
|
|
|
68
69
|
"types": "./dist/model-discovery.d.ts",
|
|
69
70
|
"import": "./dist/model-discovery.js",
|
|
70
71
|
"default": "./dist/model-discovery.js"
|
|
72
|
+
},
|
|
73
|
+
"./ai-trace": {
|
|
74
|
+
"types": "./dist/ai-trace/index.d.ts",
|
|
75
|
+
"import": "./dist/ai-trace/index.js",
|
|
76
|
+
"default": "./dist/ai-trace/index.js"
|
|
71
77
|
}
|
|
72
78
|
},
|
|
73
79
|
"typesVersions": {
|
|
@@ -107,19 +113,19 @@
|
|
|
107
113
|
},
|
|
108
114
|
"devDependencies": {
|
|
109
115
|
"@vitest/coverage-v8": "^2.1.9",
|
|
110
|
-
"@jini-ai/core": "^0.6.
|
|
111
|
-
"@jini-ai/integrations": "^0.6.
|
|
112
|
-
"@jini-ai/platform": "^0.6.
|
|
116
|
+
"@jini-ai/core": "^0.6.13",
|
|
117
|
+
"@jini-ai/integrations": "^0.6.15-rc.2",
|
|
118
|
+
"@jini-ai/platform": "^0.6.15-rc.2"
|
|
113
119
|
},
|
|
114
120
|
"dependencies": {
|
|
115
|
-
"@jini-ai/core": "^0.6.
|
|
116
|
-
"@jini-ai/
|
|
117
|
-
"@jini-ai/
|
|
121
|
+
"@jini-ai/core": "^0.6.15-rc.2",
|
|
122
|
+
"@jini-ai/protocol": "^0.6.15-rc.2",
|
|
123
|
+
"@jini-ai/oauth": "^0.6.15-rc.2"
|
|
118
124
|
},
|
|
119
125
|
"peerDependencies": {
|
|
120
|
-
"@jini-ai/integrations": "^0.6.
|
|
126
|
+
"@jini-ai/integrations": "^0.6.15-rc.2",
|
|
121
127
|
"@github/copilot-sdk": "*",
|
|
122
|
-
"@jini-ai/platform": "^0.6.
|
|
128
|
+
"@jini-ai/platform": "^0.6.15-rc.2"
|
|
123
129
|
},
|
|
124
130
|
"peerDependenciesMeta": {
|
|
125
131
|
"@jini-ai/integrations": {
|