@jini-ai/agent-runtime 0.4.10 → 0.4.12
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 +9 -0
- package/dist/acp-model-probe.d.ts +2 -20
- package/dist/agent-protocol/acp/json.js +46 -37
- package/dist/agent-protocol/acp/models.js +91 -73
- package/dist/agent-protocol/acp/rpc.d.ts +3 -2
- package/dist/agent-protocol/acp/rpc.js +3 -2
- package/dist/agent-protocol/acp/session-params.d.ts +1 -1
- package/dist/agent-protocol/acp/session-params.js +33 -30
- package/dist/agent-protocol/acp/session.d.ts +3 -1
- package/dist/agent-protocol/acp/session.js +62 -24
- package/dist/agent-protocol/acp/updates.js +49 -35
- package/dist/agent-protocol/pi-rpc/session.js +3 -1
- package/dist/anthropic-live-models.d.ts +12 -4
- package/dist/anthropic-live-models.js +0 -0
- package/dist/auth.js +84 -91
- package/dist/claude-code-models.d.ts +6 -5
- package/dist/claude-code-models.js +19 -12
- package/dist/claude-segment-usage.d.ts +3 -3
- package/dist/claude-segment-usage.js +63 -29
- package/dist/claude-stream.js +12 -5
- package/dist/copilot-stream.js +42 -50
- package/dist/defs/aider.js +3 -4
- package/dist/defs/amr.js +52 -61
- package/dist/defs/antigravity.d.ts +6 -5
- package/dist/defs/antigravity.js +48 -34
- package/dist/defs/auggie.d.ts +1 -1
- package/dist/defs/claude-compatible-args.d.ts +19 -0
- package/dist/defs/claude-compatible-args.js +42 -0
- package/dist/defs/claude.d.ts +7 -2
- package/dist/defs/claude.js +96 -85
- package/dist/defs/cline.d.ts +1 -1
- package/dist/defs/codebuddy.d.ts +1 -1
- package/dist/defs/codebuddy.js +29 -46
- package/dist/defs/codex.d.ts +15 -3
- package/dist/defs/codex.js +143 -108
- package/dist/defs/cursor-agent.d.ts +9 -7
- package/dist/defs/cursor-agent.js +53 -51
- package/dist/defs/devin.d.ts +1 -1
- package/dist/defs/goose.d.ts +1 -1
- package/dist/defs/hermes.d.ts +1 -1
- package/dist/defs/kilo.d.ts +1 -1
- package/dist/defs/kimi.d.ts +1 -1
- package/dist/defs/kiro.d.ts +1 -1
- package/dist/defs/opencode.d.ts +5 -4
- package/dist/defs/opencode.js +26 -32
- package/dist/defs/pi.d.ts +6 -5
- package/dist/defs/pi.js +24 -26
- package/dist/defs/qoder.d.ts +4 -3
- package/dist/defs/qoder.js +25 -25
- package/dist/defs/reasonix.d.ts +1 -1
- package/dist/defs/shared.d.ts +12 -3
- package/dist/defs/shared.js +19 -13
- package/dist/defs/trae-cli.d.ts +1 -1
- package/dist/defs/vibe.d.ts +1 -1
- package/dist/detection.d.ts +13 -20
- package/dist/detection.js +129 -111
- package/dist/env.js +56 -41
- package/dist/executables.js +103 -114
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/json-event-stream.js +611 -527
- package/dist/launch.js +44 -37
- package/dist/model-discovery-adapters.d.ts +17 -0
- package/dist/model-discovery-adapters.js +223 -164
- package/dist/model-discovery-config.js +107 -87
- package/dist/model-discovery-sdk.d.ts +16 -2
- package/dist/model-discovery-sdk.js +4 -3
- package/dist/model-discovery-shared.d.ts +14 -0
- package/dist/model-discovery-shared.js +50 -15
- package/dist/model-discovery-types.d.ts +2 -0
- package/dist/model-discovery.js +219 -117
- package/dist/models.d.ts +14 -1
- package/dist/models.js +75 -19
- package/dist/native-tool-policy.d.ts +29 -0
- package/dist/native-tool-policy.js +36 -0
- package/dist/opencode-log.js +46 -30
- package/dist/paths.d.ts +2 -0
- package/dist/paths.js +3 -3
- package/dist/providers/aihubmix.js +13 -18
- package/dist/providers/anthropic-messages.d.ts +7 -0
- package/dist/providers/anthropic-messages.js +45 -21
- package/dist/providers/azure-chat.d.ts +5 -0
- package/dist/providers/azure-chat.js +13 -5
- package/dist/providers/connection-guard.d.ts +2 -45
- package/dist/providers/connection-guard.js +11 -10
- package/dist/providers/connection-test.d.ts +4 -0
- package/dist/providers/connection-test.js +127 -110
- package/dist/providers/elevenlabs.js +4 -1
- package/dist/providers/google-messages.d.ts +7 -0
- package/dist/providers/google-messages.js +69 -23
- package/dist/providers/google-schema.js +17 -23
- package/dist/providers/model-catalog.js +160 -145
- package/dist/providers/oauth-callback-server.js +37 -34
- package/dist/providers/oauth-credentials.js +23 -23
- package/dist/providers/oauth-tokens.js +16 -24
- package/dist/providers/openai-chat.d.ts +42 -0
- package/dist/providers/openai-chat.js +80 -10
- package/dist/providers/operation-schema.d.ts +25 -0
- package/dist/providers/operation-schema.js +226 -0
- package/dist/providers/response-text.d.ts +10 -0
- package/dist/providers/response-text.js +23 -0
- package/dist/providers/tool-turn-types.d.ts +35 -9
- package/dist/providers/tool-turn.d.ts +7 -0
- package/dist/providers/tool-turn.js +113 -32
- package/dist/qoder-stream.js +93 -80
- package/dist/registry.d.ts +45 -0
- package/dist/registry.js +39 -0
- package/dist/runtime-state.d.ts +1 -1
- package/dist/types.d.ts +43 -1
- package/package.json +16 -7
- package/dist/defs/gemini.d.ts +0 -24
- package/dist/defs/gemini.js +0 -81
|
@@ -1,3 +1,48 @@
|
|
|
1
|
+
function isFiniteNumber(value) {
|
|
2
|
+
return typeof value === 'number' && Number.isFinite(value);
|
|
3
|
+
}
|
|
4
|
+
function isRecord(value) {
|
|
5
|
+
return Boolean(value) && typeof value === 'object';
|
|
6
|
+
}
|
|
7
|
+
/** Sum each counter across every message observed in the segment. O(m·k). */
|
|
8
|
+
function sumObserved({ messages }) {
|
|
9
|
+
const observed = {};
|
|
10
|
+
for (const counters of messages.values()) {
|
|
11
|
+
for (const [key, value] of Object.entries(counters))
|
|
12
|
+
observed[key] = (observed[key] ?? 0) + value;
|
|
13
|
+
}
|
|
14
|
+
return observed;
|
|
15
|
+
}
|
|
16
|
+
/** Overlay observed totals onto the reported usage, keeping the larger finite counter. */
|
|
17
|
+
function mergeUsage({ reported, observed }) {
|
|
18
|
+
const usage = { ...(isRecord(reported) ? reported : {}) };
|
|
19
|
+
for (const [key, value] of Object.entries(observed)) {
|
|
20
|
+
const current = usage[key];
|
|
21
|
+
usage[key] = isFiniteNumber(current) ? Math.max(current, value) : value;
|
|
22
|
+
}
|
|
23
|
+
return Object.keys(usage).length ? usage : reported ?? null;
|
|
24
|
+
}
|
|
25
|
+
/** Sum the valid (finite, non-negative) per-model `costUSD` values the CLI reported. */
|
|
26
|
+
function sumModelCosts({ modelUsage }) {
|
|
27
|
+
const models = isRecord(modelUsage) ? Object.values(modelUsage) : [];
|
|
28
|
+
return models.reduce((sum, model) => {
|
|
29
|
+
const cost = isRecord(model) ? model.costUSD : undefined;
|
|
30
|
+
return sum + (isFiniteNumber(cost) && cost >= 0 ? cost : 0);
|
|
31
|
+
}, 0);
|
|
32
|
+
}
|
|
33
|
+
/** Never infer a monetary charge from token counts: only CLI-reported costs are eligible. */
|
|
34
|
+
function resolveCostUsd({ result }) {
|
|
35
|
+
const reportedModelCost = sumModelCosts({ modelUsage: result.modelUsage });
|
|
36
|
+
if (reportedModelCost <= 0)
|
|
37
|
+
return result.total_cost_usd ?? null;
|
|
38
|
+
return Math.max(typeof result.total_cost_usd === 'number' ? result.total_cost_usd : 0, reportedModelCost);
|
|
39
|
+
}
|
|
40
|
+
/** Prefer the CLI's positive duration; otherwise measure an active or interrupted segment. */
|
|
41
|
+
function resolveDurationMs({ duration, active, elapsedMs }) {
|
|
42
|
+
if (typeof duration === 'number' && duration > 0)
|
|
43
|
+
return duration;
|
|
44
|
+
return active ? Math.max(0, elapsedMs) : duration ?? null;
|
|
45
|
+
}
|
|
1
46
|
/** Token counters are per segment; Claude's dollar counter spans the session.
|
|
2
47
|
* Aborted results can zero counters already streamed. */
|
|
3
48
|
export function createClaudeSegmentUsage(_required, { nowMs = Date.now, costBasis = 'session' } = {}) {
|
|
@@ -12,50 +57,39 @@ export function createClaudeSegmentUsage(_required, { nowMs = Date.now, costBasi
|
|
|
12
57
|
/** Merge cumulative counters for one message; wrappers repeat the same streamed usage.
|
|
13
58
|
* O(k) per snapshot in k reported counters; retained state is O(m·k) for m messages in a segment. */
|
|
14
59
|
function observe({ messageId, usage }, _optional = {}) {
|
|
15
|
-
if (!usage
|
|
60
|
+
if (!isRecord(usage))
|
|
16
61
|
return;
|
|
17
62
|
const previous = messages.get(messageId) ?? {};
|
|
18
63
|
for (const [key, value] of Object.entries(usage)) {
|
|
19
|
-
if (
|
|
64
|
+
if (isFiniteNumber(value) && value >= 0)
|
|
20
65
|
previous[key] = Math.max(previous[key] ?? 0, value);
|
|
21
66
|
}
|
|
22
67
|
if (Object.keys(previous).length)
|
|
23
68
|
messages.set(messageId, previous);
|
|
24
69
|
}
|
|
70
|
+
/** Preserve the cumulative snapshot rather than calling it a per-run charge. A zeroed
|
|
71
|
+
* aborted result still uses the existing model-cost fallback for its interrupted segment. */
|
|
72
|
+
function cumulativeCostOf({ costUsd, interrupted, result }) {
|
|
73
|
+
if (costBasis !== 'session' || sessionId === undefined)
|
|
74
|
+
return undefined;
|
|
75
|
+
if (!isFiniteNumber(costUsd) || costUsd < 0)
|
|
76
|
+
return undefined;
|
|
77
|
+
return interrupted && result.total_cost_usd === 0 ? undefined : costUsd;
|
|
78
|
+
}
|
|
25
79
|
/** Produce one segment's totals and release its snapshots. Never infer a monetary charge
|
|
26
80
|
* from token counts: only CLI-reported costs are eligible. O(m·k), no external effects. */
|
|
27
81
|
function finish({ result, interrupted }, _optional = {}) {
|
|
28
|
-
const usage = {
|
|
29
|
-
const
|
|
30
|
-
for (const counters of messages.values()) {
|
|
31
|
-
for (const [key, value] of Object.entries(counters))
|
|
32
|
-
observed[key] = (observed[key] ?? 0) + value;
|
|
33
|
-
}
|
|
34
|
-
for (const [key, value] of Object.entries(observed)) {
|
|
35
|
-
const reported = usage[key];
|
|
36
|
-
usage[key] = typeof reported === 'number' && Number.isFinite(reported) ? Math.max(reported, value) : value;
|
|
37
|
-
}
|
|
38
|
-
const modelCosts = result.modelUsage && typeof result.modelUsage === 'object' ? Object.values(result.modelUsage) : [];
|
|
39
|
-
const reportedModelCost = modelCosts.reduce((sum, model) => {
|
|
40
|
-
const cost = model && typeof model === 'object' ? model.costUSD : undefined;
|
|
41
|
-
return sum + (typeof cost === 'number' && Number.isFinite(cost) && cost >= 0 ? cost : 0);
|
|
42
|
-
}, 0);
|
|
43
|
-
const costUsd = reportedModelCost > 0 ? Math.max(typeof result.total_cost_usd === 'number' ? result.total_cost_usd : 0, reportedModelCost) : result.total_cost_usd ?? null;
|
|
82
|
+
const usage = mergeUsage({ reported: result.usage, observed: sumObserved({ messages }) });
|
|
83
|
+
const costUsd = resolveCostUsd({ result });
|
|
44
84
|
const endedAt = nowMs();
|
|
45
|
-
const
|
|
46
|
-
const durationMs = typeof duration === 'number' && duration > 0 ? duration
|
|
47
|
-
: messages.size || interrupted ? Math.max(0, endedAt - startedAt) : duration ?? null;
|
|
85
|
+
const durationMs = resolveDurationMs({ duration: result.duration_ms, active: messages.size > 0 || interrupted, elapsedMs: endedAt - startedAt });
|
|
48
86
|
messages.clear();
|
|
49
87
|
startedAt = endedAt;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
typeof costUsd === 'number' && Number.isFinite(costUsd) && costUsd >= 0 &&
|
|
54
|
-
!(interrupted && result.total_cost_usd === 0);
|
|
55
|
-
return { usage: Object.keys(usage).length ? usage : result.usage ?? null,
|
|
56
|
-
costUsd: cumulative ? null : costUsd, durationMs,
|
|
88
|
+
const cumulativeCostUsd = cumulativeCostOf({ costUsd, interrupted, result });
|
|
89
|
+
return { usage,
|
|
90
|
+
costUsd: cumulativeCostUsd === undefined ? costUsd : null, durationMs,
|
|
57
91
|
...(costBasis === 'session' && sessionId !== undefined ? { costSessionId: sessionId } : {}),
|
|
58
|
-
...(
|
|
92
|
+
...(cumulativeCostUsd === undefined ? {} : { cumulativeCostUsd }),
|
|
59
93
|
};
|
|
60
94
|
}
|
|
61
95
|
return { observe, finish, setSession, hasObserved: () => messages.size > 0 };
|
package/dist/claude-stream.js
CHANGED
|
@@ -638,7 +638,7 @@ export function createClaudeStreamHandler({ onEvent }, options = {}) {
|
|
|
638
638
|
if (typeof message.model === 'string')
|
|
639
639
|
onEvent({ type: 'status', label: 'model', model: message.model });
|
|
640
640
|
const { textMsgId, thinkingMsgId, textAlreadyStreamed, thinkingAlreadyStreamed } = resolveAssistantMessageIds(message);
|
|
641
|
-
segmentUsage.observe({ messageId:
|
|
641
|
+
segmentUsage.observe({ messageId: usageMessageKey(), usage: message.usage });
|
|
642
642
|
// Per-turn `stop_reason` is emitted as `turn_end` AFTER the content
|
|
643
643
|
// blocks have been processed (see below). When `--include-partial-
|
|
644
644
|
// messages` is unsupported, tool_use events surface only from the
|
|
@@ -716,7 +716,7 @@ export function createClaudeStreamHandler({ onEvent }, options = {}) {
|
|
|
716
716
|
// New message boundary — see `anonymousMessageEpoch`'s declaration.
|
|
717
717
|
if (currentMessageId === null)
|
|
718
718
|
anonymousMessageEpoch += 1;
|
|
719
|
-
segmentUsage.observe({ messageId:
|
|
719
|
+
segmentUsage.observe({ messageId: usageMessageKey(), usage: isRecord(ev.message) ? ev.message.usage : undefined });
|
|
720
720
|
currentMessageStreamedText = false;
|
|
721
721
|
currentMessageStreamedThinking = false;
|
|
722
722
|
if (typeof ev.ttft_ms === 'number') {
|
|
@@ -778,6 +778,15 @@ export function createClaudeStreamHandler({ onEvent }, options = {}) {
|
|
|
778
778
|
}
|
|
779
779
|
blocks.delete(key);
|
|
780
780
|
}
|
|
781
|
+
// Usage is keyed per message; an id-less message is keyed by its epoch.
|
|
782
|
+
function usageMessageKey() {
|
|
783
|
+
return currentMessageId ?? `anon${anonymousMessageEpoch}`;
|
|
784
|
+
}
|
|
785
|
+
function handleMessageDeltaStreamEvent(ev) {
|
|
786
|
+
segmentUsage.observe({ messageId: usageMessageKey(), usage: ev.usage ?? (isRecord(ev.delta) ? ev.delta.usage : undefined) });
|
|
787
|
+
if (isRecord(ev.delta))
|
|
788
|
+
handleMessageDeltaEvent(ev.delta);
|
|
789
|
+
}
|
|
781
790
|
function handleMessageDeltaEvent(delta) {
|
|
782
791
|
const stopReason = typeof delta.stop_reason === 'string' ? delta.stop_reason : null;
|
|
783
792
|
if (stopReason)
|
|
@@ -800,9 +809,7 @@ export function createClaudeStreamHandler({ onEvent }, options = {}) {
|
|
|
800
809
|
handleContentBlockStop(ev);
|
|
801
810
|
return;
|
|
802
811
|
case 'message_delta':
|
|
803
|
-
|
|
804
|
-
if (isRecord(ev.delta))
|
|
805
|
-
handleMessageDeltaEvent(ev.delta);
|
|
812
|
+
handleMessageDeltaStreamEvent(ev);
|
|
806
813
|
return;
|
|
807
814
|
}
|
|
808
815
|
}
|
package/dist/copilot-stream.js
CHANGED
|
@@ -62,59 +62,51 @@ export function createCopilotStreamHandler({ onEvent }) {
|
|
|
62
62
|
if (!isRecord(obj) || typeof obj.type !== 'string')
|
|
63
63
|
return;
|
|
64
64
|
const data = isRecord(obj.data) ? obj.data : {};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (data.model) {
|
|
68
|
-
onEvent({ type: 'status', label: 'initializing', model: data.model });
|
|
69
|
-
}
|
|
70
|
-
return;
|
|
71
|
-
case 'assistant.turn_start':
|
|
72
|
-
onEvent({ type: 'status', label: 'streaming' });
|
|
73
|
-
return;
|
|
74
|
-
case 'assistant.reasoning_delta':
|
|
75
|
-
if (typeof data.deltaContent === 'string') {
|
|
76
|
-
onEvent({ type: 'thinking_delta', delta: data.deltaContent });
|
|
77
|
-
}
|
|
78
|
-
return;
|
|
79
|
-
case 'assistant.message_delta':
|
|
80
|
-
if (typeof data.deltaContent === 'string') {
|
|
81
|
-
onEvent({ type: 'text_delta', delta: data.deltaContent });
|
|
82
|
-
}
|
|
83
|
-
return;
|
|
84
|
-
case 'tool.execution_start':
|
|
85
|
-
onEvent({
|
|
86
|
-
type: 'tool_use',
|
|
87
|
-
id: data.toolCallId ?? null,
|
|
88
|
-
name: data.toolName ?? null,
|
|
89
|
-
input: data.arguments ?? null,
|
|
90
|
-
});
|
|
91
|
-
return;
|
|
92
|
-
case 'tool.execution_complete':
|
|
93
|
-
onEvent({
|
|
94
|
-
type: 'tool_result',
|
|
95
|
-
toolUseId: data.toolCallId ?? null,
|
|
96
|
-
content: stringifyResult(data.result),
|
|
97
|
-
isError: data.success === false,
|
|
98
|
-
});
|
|
99
|
-
return;
|
|
100
|
-
case 'result':
|
|
101
|
-
// `result` puts usage / exitCode at the top level, not under `data`.
|
|
102
|
-
// Treat a missing exitCode as success when `success: true` is set —
|
|
103
|
-
// strict `=== 0` would otherwise mis-flag turns where Copilot emits
|
|
104
|
-
// usage without a numeric exit code as `error`.
|
|
105
|
-
onEvent({
|
|
106
|
-
type: 'usage',
|
|
107
|
-
usage: obj.usage ?? null,
|
|
108
|
-
stopReason: obj.success === true || obj.exitCode === 0 ? 'completed' : 'error',
|
|
109
|
-
durationMs: isRecord(obj.usage) ? obj.usage.sessionDurationMs ?? null : null,
|
|
110
|
-
});
|
|
111
|
-
return;
|
|
112
|
-
default:
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
65
|
+
// Event types we have no UI lane for are dropped on the floor.
|
|
66
|
+
COPILOT_EVENT_HANDLERS.get(obj.type)?.({ obj, data, onEvent });
|
|
115
67
|
}
|
|
116
68
|
return { feed, flush };
|
|
117
69
|
}
|
|
70
|
+
function emitDelta(type) {
|
|
71
|
+
return ({ data, onEvent }) => {
|
|
72
|
+
if (typeof data.deltaContent === 'string') {
|
|
73
|
+
onEvent({ type, delta: data.deltaContent });
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
// Map (not an object literal) so a prototype-named `type` can never resolve to a handler.
|
|
78
|
+
const COPILOT_EVENT_HANDLERS = new Map([
|
|
79
|
+
['session.tools_updated', ({ data, onEvent }) => {
|
|
80
|
+
if (data.model) {
|
|
81
|
+
onEvent({ type: 'status', label: 'initializing', model: data.model });
|
|
82
|
+
}
|
|
83
|
+
}],
|
|
84
|
+
['assistant.turn_start', ({ onEvent }) => onEvent({ type: 'status', label: 'streaming' })],
|
|
85
|
+
['assistant.reasoning_delta', emitDelta('thinking_delta')],
|
|
86
|
+
['assistant.message_delta', emitDelta('text_delta')],
|
|
87
|
+
['tool.execution_start', ({ data, onEvent }) => onEvent({
|
|
88
|
+
type: 'tool_use',
|
|
89
|
+
id: data.toolCallId ?? null,
|
|
90
|
+
name: data.toolName ?? null,
|
|
91
|
+
input: data.arguments ?? null,
|
|
92
|
+
})],
|
|
93
|
+
['tool.execution_complete', ({ data, onEvent }) => onEvent({
|
|
94
|
+
type: 'tool_result',
|
|
95
|
+
toolUseId: data.toolCallId ?? null,
|
|
96
|
+
content: stringifyResult(data.result),
|
|
97
|
+
isError: data.success === false,
|
|
98
|
+
})],
|
|
99
|
+
// `result` puts usage / exitCode at the top level, not under `data`.
|
|
100
|
+
// Treat a missing exitCode as success when `success: true` is set —
|
|
101
|
+
// strict `=== 0` would otherwise mis-flag turns where Copilot emits
|
|
102
|
+
// usage without a numeric exit code as `error`.
|
|
103
|
+
['result', ({ obj, onEvent }) => onEvent({
|
|
104
|
+
type: 'usage',
|
|
105
|
+
usage: obj.usage ?? null,
|
|
106
|
+
stopReason: obj.success === true || obj.exitCode === 0 ? 'completed' : 'error',
|
|
107
|
+
durationMs: isRecord(obj.usage) ? obj.usage.sessionDurationMs ?? null : null,
|
|
108
|
+
})],
|
|
109
|
+
]);
|
|
118
110
|
function stringifyResult(r) {
|
|
119
111
|
if (r == null)
|
|
120
112
|
return '';
|
package/dist/defs/aider.js
CHANGED
|
@@ -42,7 +42,7 @@ export const aiderAgentDef = {
|
|
|
42
42
|
// --yes-always — skip per-action confirmation
|
|
43
43
|
// --no-pretty — strip ANSI so stdout parses as plain text
|
|
44
44
|
// --no-stream — left as default (streaming on)
|
|
45
|
-
// --no-git / --no-auto-commits — the host
|
|
45
|
+
// --no-git / --no-auto-commits — outside trusted CLI parity, the host uses a
|
|
46
46
|
// managed project workspace that
|
|
47
47
|
// is not the user's git repo, so
|
|
48
48
|
// the commit machinery has
|
|
@@ -60,9 +60,8 @@ export const aiderAgentDef = {
|
|
|
60
60
|
// which is the conservative outcome restricted mode is asking for.
|
|
61
61
|
...(options.permissionMode !== 'restricted' ? ['--yes-always'] : []),
|
|
62
62
|
'--no-pretty',
|
|
63
|
-
|
|
64
|
-
'--no-auto-commits',
|
|
65
|
-
'--no-suggest-shell-commands',
|
|
63
|
+
// Managed scratch workspaces suppress git/shell; trusted parity uses Aider's own settings.
|
|
64
|
+
...(options.cliParity && options.permissionMode === 'bypass' && options.nativeToolAccess !== false ? [] : ['--no-git', '--no-auto-commits', '--no-suggest-shell-commands']),
|
|
66
65
|
'--no-show-model-warnings',
|
|
67
66
|
];
|
|
68
67
|
if (options.model && options.model !== 'default') {
|
package/dist/defs/amr.js
CHANGED
|
@@ -31,33 +31,25 @@ const PREFERRED_AMR_CHAT_MODEL_RANK = new Map(PREFERRED_AMR_CHAT_MODEL_ORDER.map
|
|
|
31
31
|
// normalizes those public ids at the spawn boundary until Vela exposes
|
|
32
32
|
// canonical ACP ids directly.
|
|
33
33
|
export function normalizeVelaModelId({ rawId }) {
|
|
34
|
-
const
|
|
35
|
-
if (!trimmed)
|
|
36
|
-
return null;
|
|
37
|
-
const withoutProvider = trimmed.startsWith('vela/')
|
|
38
|
-
? trimmed.slice('vela/'.length)
|
|
39
|
-
: trimmed;
|
|
40
|
-
const withoutPrefix = withoutProvider.startsWith('public_model_')
|
|
41
|
-
? withoutProvider.slice('public_model_'.length)
|
|
42
|
-
: withoutProvider;
|
|
34
|
+
const withoutPrefix = stripPrefix({ value: stripPrefix({ value: rawId.trim(), prefix: 'vela/' }), prefix: 'public_model_' });
|
|
43
35
|
if (!withoutPrefix)
|
|
44
36
|
return null;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return
|
|
37
|
+
const alias = VELA_MODEL_ID_ALIASES.find(([pattern]) => pattern.test(withoutPrefix));
|
|
38
|
+
if (alias)
|
|
39
|
+
return alias[1];
|
|
40
|
+
return normalizeKnownVelaVersionId(withoutPrefix) ?? withoutPrefix.replace(/_/g, '-');
|
|
41
|
+
}
|
|
42
|
+
/** Compact Vela public ids whose link-facing slug is not a plain underscore-to-dash rewrite. */
|
|
43
|
+
const VELA_MODEL_ID_ALIASES = [
|
|
44
|
+
[/^deepseek_v3_2$/i, 'deepseek-v3.2'],
|
|
45
|
+
[/^deepseek-v3-2$/i, 'deepseek-v3.2'],
|
|
46
|
+
[/^kimi_k2_6$/i, 'kimi-k2.6'],
|
|
47
|
+
[/^kimi_k2_7_code$/i, 'kimi-k2.7-code'],
|
|
48
|
+
[/^glm_5_1$/i, 'glm-5.1'],
|
|
49
|
+
[/^glm_5$/i, 'glm-5'],
|
|
50
|
+
];
|
|
51
|
+
function stripPrefix({ value, prefix }) {
|
|
52
|
+
return value.startsWith(prefix) ? value.slice(prefix.length) : value;
|
|
61
53
|
}
|
|
62
54
|
// Every capture group below is a mandatory (non-optional) part of its
|
|
63
55
|
// pattern — `(haiku|opus|sonnet)` is a required alternation and `(\d+)`
|
|
@@ -109,8 +101,7 @@ function isVelaChatModelId(modelId) {
|
|
|
109
101
|
return true;
|
|
110
102
|
}
|
|
111
103
|
export function parseVelaModels({ stdout }) {
|
|
112
|
-
const
|
|
113
|
-
const models = [];
|
|
104
|
+
const ids = [];
|
|
114
105
|
for (const line of String(stdout || '').split('\n')) {
|
|
115
106
|
const trimmed = line.trim();
|
|
116
107
|
if (!trimmed || trimmed.startsWith('#'))
|
|
@@ -118,21 +109,27 @@ export function parseVelaModels({ stdout }) {
|
|
|
118
109
|
// `trimmed` is already non-empty and has no leading whitespace (checked
|
|
119
110
|
// above), so its first whitespace-split token is always non-empty too.
|
|
120
111
|
const rawId = trimmed.split(/\s+/)[0];
|
|
121
|
-
|
|
122
|
-
if (!id || seen.has(id) || !isVelaChatModelId(id))
|
|
123
|
-
continue;
|
|
124
|
-
seen.add(id);
|
|
125
|
-
models.push({ id, label: id });
|
|
112
|
+
ids.push(normalizeVelaModelId({ rawId: rawId }));
|
|
126
113
|
}
|
|
127
|
-
return
|
|
114
|
+
return collectChatModels(ids);
|
|
128
115
|
}
|
|
129
116
|
export function parseVelaModelJson({ stdout, expectedSource }) {
|
|
117
|
+
const data = parseVelaModelJsonData({ stdout, expectedSource });
|
|
118
|
+
return collectChatModels(data.map((item) => {
|
|
119
|
+
const rawId = item && typeof item === 'object'
|
|
120
|
+
? item.id
|
|
121
|
+
: null;
|
|
122
|
+
return typeof rawId === 'string' ? rawId.trim() : '';
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
/** Validates the `{ source, data: [...] }` envelope and returns its `data` array. */
|
|
126
|
+
function parseVelaModelJsonData({ stdout, expectedSource }) {
|
|
130
127
|
let parsed;
|
|
131
128
|
try {
|
|
132
129
|
parsed = JSON.parse(stdout);
|
|
133
130
|
}
|
|
134
131
|
catch (error) {
|
|
135
|
-
throw new Error(`Invalid vela model JSON: ${error instanceof Error ? error.message : String(error)}
|
|
132
|
+
throw new Error(`Invalid vela model JSON: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
136
133
|
}
|
|
137
134
|
if (!parsed || typeof parsed !== 'object') {
|
|
138
135
|
throw new Error('Invalid vela model JSON: expected object');
|
|
@@ -145,13 +142,13 @@ export function parseVelaModelJson({ stdout, expectedSource }) {
|
|
|
145
142
|
if (!Array.isArray(data)) {
|
|
146
143
|
throw new Error('Invalid vela model JSON: expected data array');
|
|
147
144
|
}
|
|
145
|
+
return data;
|
|
146
|
+
}
|
|
147
|
+
/** First occurrence of each non-empty chat model id, in preferred AMR chat order. */
|
|
148
|
+
function collectChatModels(ids) {
|
|
148
149
|
const seen = new Set();
|
|
149
150
|
const models = [];
|
|
150
|
-
for (const
|
|
151
|
-
const rawId = item && typeof item === 'object'
|
|
152
|
-
? item.id
|
|
153
|
-
: null;
|
|
154
|
-
const id = typeof rawId === 'string' ? rawId.trim() : '';
|
|
151
|
+
for (const id of ids) {
|
|
155
152
|
if (!id || seen.has(id) || !isVelaChatModelId(id))
|
|
156
153
|
continue;
|
|
157
154
|
seen.add(id);
|
|
@@ -202,34 +199,28 @@ export async function fetchVelaPresetModels({ resolvedBin, env }) {
|
|
|
202
199
|
return parseVelaModelJson({ stdout: String(stdout), expectedSource: 'preset' });
|
|
203
200
|
}
|
|
204
201
|
export async function fetchVelaRemoteModelsWithRetry({ resolvedBin, env }) {
|
|
205
|
-
//
|
|
206
|
-
//
|
|
207
|
-
//
|
|
208
|
-
|
|
209
|
-
// also means `attempt` is always a valid in-bounds index into
|
|
210
|
-
// `AMR_MODELS_RETRY_DELAYS_MS` whenever we reach the `sleep()` call below
|
|
211
|
-
// (the assertion just satisfies `noUncheckedIndexedAccess`).
|
|
212
|
-
//
|
|
213
|
-
// The empty loop condition and absence of break make the closing statement unreachable:
|
|
214
|
-
// success returns, and exhaustion throws after at most three attempts. Coverage instrumentation
|
|
215
|
-
// cannot prove that; document the invariant instead of forcing a test or adding v8 ignore.
|
|
216
|
-
for (let attempt = 0;; attempt += 1) {
|
|
202
|
+
// One attempt per retry delay, each followed by that delay when it fails with a retriable
|
|
203
|
+
// error; a non-retriable error (including a malformed catalog) is thrown at once. The final
|
|
204
|
+
// attempt after the last delay is not retried, so whatever it throws propagates as-is.
|
|
205
|
+
for (const delayMs of AMR_MODELS_RETRY_DELAYS_MS) {
|
|
217
206
|
try {
|
|
218
|
-
|
|
219
|
-
env,
|
|
220
|
-
timeout: AMR_MODELS_TIMEOUT_MS,
|
|
221
|
-
maxBuffer: 1024 * 1024,
|
|
222
|
-
} });
|
|
223
|
-
return parseVelaModelJson({ stdout: String(stdout), expectedSource: 'remote' });
|
|
207
|
+
return await fetchVelaRemoteModelsOnce({ resolvedBin, env });
|
|
224
208
|
}
|
|
225
209
|
catch (error) {
|
|
226
|
-
if (
|
|
227
|
-
!isRetriableVelaModelsError(error)) {
|
|
210
|
+
if (!isRetriableVelaModelsError(error))
|
|
228
211
|
throw error;
|
|
229
|
-
}
|
|
230
|
-
await sleep(AMR_MODELS_RETRY_DELAYS_MS[attempt]);
|
|
231
212
|
}
|
|
213
|
+
await sleep(delayMs);
|
|
232
214
|
}
|
|
215
|
+
return fetchVelaRemoteModelsOnce({ resolvedBin, env });
|
|
216
|
+
}
|
|
217
|
+
async function fetchVelaRemoteModelsOnce({ resolvedBin, env }) {
|
|
218
|
+
const { stdout } = await execAgentFile({ command: resolvedBin, args: ['model', 'list', '--format', 'json'] }, { options: {
|
|
219
|
+
env,
|
|
220
|
+
timeout: AMR_MODELS_TIMEOUT_MS,
|
|
221
|
+
maxBuffer: 1024 * 1024,
|
|
222
|
+
} });
|
|
223
|
+
return parseVelaModelJson({ stdout: String(stdout), expectedSource: 'remote' });
|
|
233
224
|
}
|
|
234
225
|
/**
|
|
235
226
|
* Read the signed-in account's billing summary via the vela CLI — the same
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { 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.
|
|
@@ -48,6 +48,7 @@ export declare const antigravityAgentDef: {
|
|
|
48
48
|
parse: typeof parseAgyModels;
|
|
49
49
|
timeoutMs: number;
|
|
50
50
|
};
|
|
51
|
+
fallbackModelsAssertedAt: string;
|
|
51
52
|
fallbackModels: RuntimeModelOption[];
|
|
52
53
|
supportsCustomModel: false;
|
|
53
54
|
reasoningInModelId: {
|
|
@@ -56,13 +57,13 @@ export declare const antigravityAgentDef: {
|
|
|
56
57
|
label: string;
|
|
57
58
|
}[];
|
|
58
59
|
};
|
|
59
|
-
buildArgs: ({ prompt
|
|
60
|
+
buildArgs: ({ prompt }: {
|
|
60
61
|
prompt: string;
|
|
61
62
|
imagePaths: string[];
|
|
62
|
-
}, {
|
|
63
|
+
}, { options, runtimeContext }?: {
|
|
63
64
|
extraAllowedDirs?: string[];
|
|
64
|
-
options?:
|
|
65
|
-
runtimeContext?:
|
|
65
|
+
options?: RuntimeBuildOptions;
|
|
66
|
+
runtimeContext?: RuntimeContext;
|
|
66
67
|
} | undefined) => string[];
|
|
67
68
|
maxPromptArgBytes: number;
|
|
68
69
|
streamFormat: string;
|
package/dist/defs/antigravity.js
CHANGED
|
@@ -111,33 +111,69 @@ export function parseAgyModels({ stdout }) {
|
|
|
111
111
|
const tabIndex = line.indexOf('\t');
|
|
112
112
|
if (tabIndex === -1)
|
|
113
113
|
continue;
|
|
114
|
+
// `line` is already trimmed, so a tab inside it always has a non-blank character on each
|
|
115
|
+
// side: neither the id nor the label can come out empty here.
|
|
114
116
|
const id = line.slice(0, tabIndex).trim();
|
|
115
|
-
if (
|
|
117
|
+
if (seen.has(id))
|
|
116
118
|
continue;
|
|
117
119
|
seen.add(id);
|
|
118
|
-
|
|
119
|
-
out.push({ id, label: label || id });
|
|
120
|
+
out.push({ id, label: line.slice(tabIndex + 1).trim() });
|
|
120
121
|
}
|
|
121
122
|
return out.length > 1 ? out : null;
|
|
122
123
|
}
|
|
124
|
+
// `agy models` does a real network fetch (its own stdout says "Fetching
|
|
125
|
+
// available models..."), so this gets a longer budget than codex's 5s
|
|
126
|
+
// local-cache read — 10s to absorb ordinary network latency without
|
|
127
|
+
// making every detection pass wait needlessly long on a slow/offline run
|
|
128
|
+
// (`detection.ts#fetchModels` falls back to `fallbackModels` on timeout).
|
|
129
|
+
// It runs within the outer 10s discovery budget: Antigravity has no disk
|
|
130
|
+
// fallback, so `probeAgentCatalog` reserves no recovery time for it.
|
|
131
|
+
const AGY_MODELS_TIMEOUT_MS = 10_000;
|
|
132
|
+
// Match the owner's existing Full CLI grant; never infer approval from headless mode.
|
|
133
|
+
function skipPermissionsArgs({ options }) {
|
|
134
|
+
return options.cliParity === true && options.permissionMode === 'bypass' && options.nativeToolAccess !== false
|
|
135
|
+
? ['--dangerously-skip-permissions']
|
|
136
|
+
: [];
|
|
137
|
+
}
|
|
138
|
+
// `--model` is the same kind of Go flag as `--log-file`/`-p`: its value is
|
|
139
|
+
// whatever argv token immediately follows it, so it too must be pushed
|
|
140
|
+
// before `-p` (always last — see `buildArgs`). Verified live against agy
|
|
141
|
+
// v1.1.24: `agy --model <slug> -p '<prompt>'` runs that one print-mode
|
|
142
|
+
// turn on the named model, and combining it with `--log-file` works the
|
|
143
|
+
// same way — relative order between `--model` and `--log-file` doesn't
|
|
144
|
+
// matter (each independently consumes exactly the one token after it),
|
|
145
|
+
// only that both precede `-p`.
|
|
146
|
+
function modelArgs({ options }) {
|
|
147
|
+
return options.model && options.model !== DEFAULT_MODEL_OPTION.id ? ['--model', options.model] : [];
|
|
148
|
+
}
|
|
149
|
+
// Always opt into `--log-file` when the daemon supplied a path so
|
|
150
|
+
// it can post-exit grep for the actual upstream failure shape
|
|
151
|
+
// (auth missing vs quota reached vs upstream error) — without it
|
|
152
|
+
// the chat surfaces a generic "empty response" because print mode
|
|
153
|
+
// never echoes those errors on stdout. See server.ts empty-output
|
|
154
|
+
// guard for the consumer.
|
|
155
|
+
function logFileArgs({ runtimeContext }) {
|
|
156
|
+
return runtimeContext.agentLogFilePath ? ['--log-file', runtimeContext.agentLogFilePath] : [];
|
|
157
|
+
}
|
|
123
158
|
export const antigravityAgentDef = {
|
|
124
|
-
...createAgentModelDiscovery('antigravity', { fallbackModels: () => antigravityAgentDef.fallbackModels, args: ['models'], parse:
|
|
159
|
+
...createAgentModelDiscovery('antigravity', { fallbackModels: () => antigravityAgentDef.fallbackModels, args: ['models'], parse: parseAgyModels, timeoutMs: AGY_MODELS_TIMEOUT_MS }),
|
|
125
160
|
id: 'antigravity',
|
|
126
161
|
name: 'Antigravity',
|
|
127
162
|
bin: 'agy',
|
|
128
163
|
versionArgs: ['--version'],
|
|
129
|
-
//
|
|
130
|
-
// available models..."), so this gets a longer budget than codex's 5s
|
|
131
|
-
// local-cache read — 10s to absorb ordinary network latency without
|
|
132
|
-
// making every detection pass wait needlessly long on a slow/offline run
|
|
133
|
-
// (`detection.ts#fetchModels` falls back to `fallbackModels` on timeout).
|
|
164
|
+
// Budget rationale: see `AGY_MODELS_TIMEOUT_MS`.
|
|
134
165
|
listModels: {
|
|
135
166
|
args: ['models'],
|
|
136
167
|
parse: parseAgyModels,
|
|
137
|
-
timeoutMs:
|
|
168
|
+
timeoutMs: AGY_MODELS_TIMEOUT_MS,
|
|
138
169
|
},
|
|
170
|
+
// Checked against agy 1.4.2 and https://antigravity.google/docs/cli/headless/.
|
|
171
|
+
fallbackModelsAssertedAt: '2026-10-18',
|
|
139
172
|
fallbackModels: [
|
|
140
173
|
DEFAULT_MODEL_OPTION,
|
|
174
|
+
{ id: 'gemini-4-argon-high', label: 'Gemini 4 Argon High' },
|
|
175
|
+
{ id: 'gemini-4-argon-medium', label: 'Gemini 4 Argon Medium' },
|
|
176
|
+
{ id: 'gemini-4-argon-low', label: 'Gemini 4 Argon Low' },
|
|
141
177
|
{ id: 'gemini-3.8-flash-high', label: 'Gemini 3.8 Flash (High)' },
|
|
142
178
|
{ id: 'gemini-3.8-flash-medium', label: 'Gemini 3.8 Flash (Medium)' },
|
|
143
179
|
{ id: 'gemini-3.8-flash-low', label: 'Gemini 3.8 Flash (Low)' },
|
|
@@ -186,7 +222,7 @@ export const antigravityAgentDef = {
|
|
|
186
222
|
// apps/web/src/providers/daemon.ts). The stronger OVERRIDE block
|
|
187
223
|
// composed in server.ts gives a second line of defense for weak
|
|
188
224
|
// plain-stream models like Gemini 3.5 Flash.
|
|
189
|
-
buildArgs: ({ prompt
|
|
225
|
+
buildArgs: ({ prompt }, { options = {}, runtimeContext = {} } = {}) => {
|
|
190
226
|
// `-p` is a Go `flag`-package flag that TAKES THE PROMPT AS ITS VALUE,
|
|
191
227
|
// not a boolean switch followed by a positional prompt, and agy has no
|
|
192
228
|
// stdin sentinel under the default `--input-format text`. Verified
|
|
@@ -199,29 +235,7 @@ export const antigravityAgentDef = {
|
|
|
199
235
|
// - `agy -p '<prompt>'` -> the prompt actually lands.
|
|
200
236
|
// So the prompt rides argv as `-p`'s value. That is also why this def is
|
|
201
237
|
// argv-budgeted (`maxPromptArgBytes` below) rather than `promptViaStdin`.
|
|
202
|
-
|
|
203
|
-
// `--model` is the same kind of Go flag as `--log-file`/`-p`: its value is
|
|
204
|
-
// whatever argv token immediately follows it, so it too must be pushed
|
|
205
|
-
// before `-p` (always last — see below). Verified live against agy
|
|
206
|
-
// v1.1.24: `agy --model <slug> -p '<prompt>'` runs that one print-mode
|
|
207
|
-
// turn on the named model, and combining it with `--log-file` works the
|
|
208
|
-
// same way — relative order between `--model` and `--log-file` doesn't
|
|
209
|
-
// matter (each independently consumes exactly the one token after it),
|
|
210
|
-
// only that both precede `-p`.
|
|
211
|
-
if (options.model && options.model !== DEFAULT_MODEL_OPTION.id) {
|
|
212
|
-
args.push('--model', options.model);
|
|
213
|
-
}
|
|
214
|
-
// Always opt into `--log-file` when the daemon supplied a path so
|
|
215
|
-
// it can post-exit grep for the actual upstream failure shape
|
|
216
|
-
// (auth missing vs quota reached vs upstream error) — without it
|
|
217
|
-
// the chat surfaces a generic "empty response" because print mode
|
|
218
|
-
// never echoes those errors on stdout. See server.ts empty-output
|
|
219
|
-
// guard for the consumer.
|
|
220
|
-
if (runtimeContext.agentLogFilePath) {
|
|
221
|
-
args.push('--log-file', runtimeContext.agentLogFilePath);
|
|
222
|
-
}
|
|
223
|
-
args.push('-p', prompt);
|
|
224
|
-
return args;
|
|
238
|
+
return [...skipPermissionsArgs({ options }), ...modelArgs({ options }), ...logFileArgs({ runtimeContext }), '-p', prompt];
|
|
225
239
|
},
|
|
226
240
|
// agy takes its prompt on argv (see `buildArgs`), so this def is
|
|
227
241
|
// argv-budgeted like the other plain-stream argv adapters (aider,
|
package/dist/defs/auggie.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare const auggieAgentDef: {
|
|
|
7
7
|
resolvedBin: string;
|
|
8
8
|
env: import("../types.js").RuntimeEnv;
|
|
9
9
|
}, { acpModelProbe }?: {
|
|
10
|
-
acpModelProbe?: import("../
|
|
10
|
+
acpModelProbe?: import("../types.js").AcpModelProbe;
|
|
11
11
|
} | undefined) => Promise<import("../types.js").RuntimeModelOption[]>;
|
|
12
12
|
fallbackModels: import("../types.js").RuntimeModelOption[];
|
|
13
13
|
buildArgs: () => string[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { RuntimeBuildOptions, RuntimeCapabilityMap, RuntimeContext } from '../types.js';
|
|
2
|
+
/** Host-scoped capabilities when supplied, else the published `--help` probe cache for `agentId`. */
|
|
3
|
+
export declare function resolveCapabilities({ agentId, options }: {
|
|
4
|
+
agentId: string;
|
|
5
|
+
options: RuntimeBuildOptions;
|
|
6
|
+
}): RuntimeCapabilityMap;
|
|
7
|
+
/** `--add-dir <dir...>` for every non-empty string dir, unless the probe recorded `addDir: false`. */
|
|
8
|
+
export declare function addDirArgs({ extraAllowedDirs, caps }: {
|
|
9
|
+
extraAllowedDirs: readonly string[] | null | undefined;
|
|
10
|
+
caps: RuntimeCapabilityMap;
|
|
11
|
+
}): string[];
|
|
12
|
+
export declare function sessionArgs(runtimeContext: RuntimeContext): string[];
|
|
13
|
+
export declare function permissionModeArgs(options: RuntimeBuildOptions): string[];
|
|
14
|
+
/** `<flag> <value>` unless the value is empty or the CLI-owned `default` sentinel. */
|
|
15
|
+
export declare function nonDefaultFlag({ flag, value }: {
|
|
16
|
+
flag: string;
|
|
17
|
+
value: string | null | undefined;
|
|
18
|
+
}): string[];
|
|
19
|
+
//# sourceMappingURL=claude-compatible-args.d.ts.map
|