@jini-ai/agent-runtime 0.7.1 → 0.7.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 +10 -0
- package/dist/copilot-stream.d.ts +65 -0
- package/dist/copilot-stream.js +131 -0
- package/dist/defs/antigravity.d.ts +94 -0
- package/dist/defs/antigravity.js +320 -0
- package/dist/defs/copilot.d.ts +34 -0
- package/dist/defs/copilot.js +96 -0
- package/dist/defs/gemini.d.ts +24 -0
- package/dist/defs/gemini.js +81 -0
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module copilot-stream
|
|
3
|
+
*
|
|
4
|
+
* Parses GitHub Copilot CLI's `--output-format json` JSONL stream into the
|
|
5
|
+
* same UI-friendly events that claude-stream.js emits, so the chat panel
|
|
6
|
+
* can render Copilot's thinking / tool calls / text the same way it does
|
|
7
|
+
* Claude Code's.
|
|
8
|
+
*
|
|
9
|
+
* Copilot's schema uses dotted top-level types (`assistant.*`, `tool.*`,
|
|
10
|
+
* `session.*`, `user.*`, `result`) with the payload under `data`. The
|
|
11
|
+
* `ephemeral: true` events (session.mcp_*, reasoning_delta, etc.) are still
|
|
12
|
+
* useful — they carry the streaming deltas — but events we don't have a UI
|
|
13
|
+
* lane for (mcp_server_status, skills_loaded, full reasoning recap, turn
|
|
14
|
+
* boundaries) are dropped on the floor.
|
|
15
|
+
*
|
|
16
|
+
* Mapping:
|
|
17
|
+
* session.tools_updated -> status (initializing, with model name)
|
|
18
|
+
* assistant.turn_start -> status (streaming)
|
|
19
|
+
* assistant.reasoning_delta -> thinking_delta
|
|
20
|
+
* assistant.message_delta -> text_delta
|
|
21
|
+
* tool.execution_start -> tool_use
|
|
22
|
+
* tool.execution_complete -> tool_result
|
|
23
|
+
* result -> usage
|
|
24
|
+
*/
|
|
25
|
+
/** Every event `createCopilotStreamHandler` can emit, discriminated on `type` — see `claude-stream.ts`'s `ClaudeStreamEvent` doc for why this is exported rather than left as `Record<string, unknown>`. */
|
|
26
|
+
export type CopilotStreamEvent = {
|
|
27
|
+
type: 'raw';
|
|
28
|
+
line: string;
|
|
29
|
+
} | {
|
|
30
|
+
type: 'status';
|
|
31
|
+
label: 'initializing';
|
|
32
|
+
model: unknown;
|
|
33
|
+
} | {
|
|
34
|
+
type: 'status';
|
|
35
|
+
label: 'streaming';
|
|
36
|
+
} | {
|
|
37
|
+
type: 'thinking_delta' | 'text_delta';
|
|
38
|
+
delta: string;
|
|
39
|
+
} | {
|
|
40
|
+
type: 'tool_use';
|
|
41
|
+
id: unknown;
|
|
42
|
+
name: unknown;
|
|
43
|
+
input: unknown;
|
|
44
|
+
} | {
|
|
45
|
+
type: 'tool_result';
|
|
46
|
+
toolUseId: unknown;
|
|
47
|
+
content: string;
|
|
48
|
+
isError: boolean;
|
|
49
|
+
} | {
|
|
50
|
+
type: 'usage';
|
|
51
|
+
usage: unknown;
|
|
52
|
+
stopReason: 'completed' | 'error';
|
|
53
|
+
durationMs: unknown;
|
|
54
|
+
};
|
|
55
|
+
type EventSink = (event: CopilotStreamEvent) => void;
|
|
56
|
+
export declare function createCopilotStreamHandler({ onEvent }: {
|
|
57
|
+
onEvent: EventSink;
|
|
58
|
+
}): {
|
|
59
|
+
feed: ({ chunk }: {
|
|
60
|
+
chunk: string;
|
|
61
|
+
}) => void;
|
|
62
|
+
flush: () => void;
|
|
63
|
+
};
|
|
64
|
+
export {};
|
|
65
|
+
//# sourceMappingURL=copilot-stream.d.ts.map
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module copilot-stream
|
|
3
|
+
*
|
|
4
|
+
* Parses GitHub Copilot CLI's `--output-format json` JSONL stream into the
|
|
5
|
+
* same UI-friendly events that claude-stream.js emits, so the chat panel
|
|
6
|
+
* can render Copilot's thinking / tool calls / text the same way it does
|
|
7
|
+
* Claude Code's.
|
|
8
|
+
*
|
|
9
|
+
* Copilot's schema uses dotted top-level types (`assistant.*`, `tool.*`,
|
|
10
|
+
* `session.*`, `user.*`, `result`) with the payload under `data`. The
|
|
11
|
+
* `ephemeral: true` events (session.mcp_*, reasoning_delta, etc.) are still
|
|
12
|
+
* useful — they carry the streaming deltas — but events we don't have a UI
|
|
13
|
+
* lane for (mcp_server_status, skills_loaded, full reasoning recap, turn
|
|
14
|
+
* boundaries) are dropped on the floor.
|
|
15
|
+
*
|
|
16
|
+
* Mapping:
|
|
17
|
+
* session.tools_updated -> status (initializing, with model name)
|
|
18
|
+
* assistant.turn_start -> status (streaming)
|
|
19
|
+
* assistant.reasoning_delta -> thinking_delta
|
|
20
|
+
* assistant.message_delta -> text_delta
|
|
21
|
+
* tool.execution_start -> tool_use
|
|
22
|
+
* tool.execution_complete -> tool_result
|
|
23
|
+
* result -> usage
|
|
24
|
+
*/
|
|
25
|
+
function isRecord(value) {
|
|
26
|
+
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
27
|
+
}
|
|
28
|
+
export function createCopilotStreamHandler({ onEvent }) {
|
|
29
|
+
let buffer = '';
|
|
30
|
+
function feed({ chunk }) {
|
|
31
|
+
buffer += chunk;
|
|
32
|
+
let nl;
|
|
33
|
+
while ((nl = buffer.indexOf('\n')) !== -1) {
|
|
34
|
+
const line = buffer.slice(0, nl).trim();
|
|
35
|
+
buffer = buffer.slice(nl + 1);
|
|
36
|
+
if (!line)
|
|
37
|
+
continue;
|
|
38
|
+
let obj;
|
|
39
|
+
try {
|
|
40
|
+
obj = JSON.parse(line);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
onEvent({ type: 'raw', line });
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
handleObject(obj);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function flush() {
|
|
50
|
+
const rem = buffer.trim();
|
|
51
|
+
buffer = '';
|
|
52
|
+
if (!rem)
|
|
53
|
+
return;
|
|
54
|
+
try {
|
|
55
|
+
handleObject(JSON.parse(rem));
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
onEvent({ type: 'raw', line: rem });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function handleObject(obj) {
|
|
62
|
+
if (!isRecord(obj) || typeof obj.type !== 'string')
|
|
63
|
+
return;
|
|
64
|
+
const data = isRecord(obj.data) ? obj.data : {};
|
|
65
|
+
switch (obj.type) {
|
|
66
|
+
case 'session.tools_updated':
|
|
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
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return { feed, flush };
|
|
117
|
+
}
|
|
118
|
+
function stringifyResult(r) {
|
|
119
|
+
if (r == null)
|
|
120
|
+
return '';
|
|
121
|
+
if (typeof r === 'string')
|
|
122
|
+
return r;
|
|
123
|
+
if (!isRecord(r))
|
|
124
|
+
return JSON.stringify(r);
|
|
125
|
+
if (typeof r.content === 'string')
|
|
126
|
+
return r.content;
|
|
127
|
+
if (typeof r.detailedContent === 'string')
|
|
128
|
+
return r.detailedContent;
|
|
129
|
+
return JSON.stringify(r);
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=copilot-stream.js.map
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { RuntimeModelOption } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Redacts any OAuth sign-in URL from agy's buffered print-mode stdout,
|
|
4
|
+
* leaving all other output byte-identical.
|
|
5
|
+
*
|
|
6
|
+
* Scoped to redaction on purpose: it does **not** classify the output as an
|
|
7
|
+
* auth failure or substitute sign-in guidance for it. That classification
|
|
8
|
+
* already has an owner — `auth.ts`'s `classifyAgentAuthFailure` /
|
|
9
|
+
* `isAntigravityAuthFailureText`, consumed by whatever surfaces a structured
|
|
10
|
+
* auth error — and duplicating the decision here would mean this def silently
|
|
11
|
+
* rewrites assistant text into instructions.
|
|
12
|
+
*
|
|
13
|
+
* @param fullText - The concatenation of every stdout chunk agy produced.
|
|
14
|
+
* @returns The same text with every sign-in URL replaced by a placeholder.
|
|
15
|
+
* @complexity O(n) in the buffered text length.
|
|
16
|
+
* @overallScore 100/100
|
|
17
|
+
*/
|
|
18
|
+
export declare function redactAntigravityAuthUrls({ fullText }: {
|
|
19
|
+
fullText: string;
|
|
20
|
+
}): string;
|
|
21
|
+
/**
|
|
22
|
+
* Parses `agy models`' stdout into the shared `RuntimeModelOption[]` shape.
|
|
23
|
+
*
|
|
24
|
+
* The CLI's real output (agy v1.1.24, verified live — see this file's header
|
|
25
|
+
* comment for the exact captured transcript) is one `Fetching available
|
|
26
|
+
* models...` progress line followed by one `<slug>\t<label>` pair per line.
|
|
27
|
+
* Each data line is split on the FIRST tab only, so a label that itself
|
|
28
|
+
* contains a tab or extra whitespace never bleeds into the id.
|
|
29
|
+
*
|
|
30
|
+
* @param stdout - Raw stdout from `agy models`.
|
|
31
|
+
* @returns The synthetic default option prepended to every parsed entry, or
|
|
32
|
+
* `null` when no real entry was found (empty stdout, or only the progress
|
|
33
|
+
* line survives filtering) — mirrors `parseCursorAgentModels`'s same-shape
|
|
34
|
+
* null contract, which `detection.ts#fetchModels` already treats the same
|
|
35
|
+
* as an empty array: fall back to `fallbackModels`.
|
|
36
|
+
* @complexity O(n) in the stdout length.
|
|
37
|
+
*/
|
|
38
|
+
export declare function parseAgyModels({ stdout }: {
|
|
39
|
+
stdout: string;
|
|
40
|
+
}): RuntimeModelOption[] | null;
|
|
41
|
+
export declare const antigravityAgentDef: {
|
|
42
|
+
id: string;
|
|
43
|
+
name: string;
|
|
44
|
+
bin: string;
|
|
45
|
+
versionArgs: string[];
|
|
46
|
+
listModels: {
|
|
47
|
+
args: string[];
|
|
48
|
+
parse: typeof parseAgyModels;
|
|
49
|
+
timeoutMs: number;
|
|
50
|
+
};
|
|
51
|
+
fallbackModelsAssertedAt: string;
|
|
52
|
+
fallbackModels: RuntimeModelOption[];
|
|
53
|
+
supportsCustomModel: false;
|
|
54
|
+
reasoningInModelId: {
|
|
55
|
+
levels: {
|
|
56
|
+
id: string;
|
|
57
|
+
label: string;
|
|
58
|
+
}[];
|
|
59
|
+
};
|
|
60
|
+
buildArgs: ({ prompt, imagePaths: _imagePaths }: {
|
|
61
|
+
prompt: string;
|
|
62
|
+
imagePaths: string[];
|
|
63
|
+
}, { extraAllowedDirs: _extra, options, runtimeContext }?: {
|
|
64
|
+
extraAllowedDirs?: string[];
|
|
65
|
+
options?: import("../types.js").RuntimeBuildOptions;
|
|
66
|
+
runtimeContext?: import("../types.js").RuntimeContext;
|
|
67
|
+
} | undefined) => string[];
|
|
68
|
+
maxPromptArgBytes: number;
|
|
69
|
+
streamFormat: string;
|
|
70
|
+
needsAgentLogFile: true;
|
|
71
|
+
stdoutPolicy: {
|
|
72
|
+
buffering: "until-close";
|
|
73
|
+
sanitize: typeof redactAntigravityAuthUrls;
|
|
74
|
+
};
|
|
75
|
+
installUrl: string;
|
|
76
|
+
docsUrl: string;
|
|
77
|
+
externalMcpInjection: "env-passthrough";
|
|
78
|
+
discoverModels(requiredArgs: {
|
|
79
|
+
context: import("../model-discovery-types.js").ModelDiscoveryContext;
|
|
80
|
+
}, optionalArgs?: {
|
|
81
|
+
signal?: AbortSignal;
|
|
82
|
+
force?: boolean;
|
|
83
|
+
staleWhileRevalidate?: boolean;
|
|
84
|
+
deps?: import("../model-discovery-types.js").ModelDiscoveryDeps;
|
|
85
|
+
}): Promise<import("../model-discovery-types.js").ModelCatalogSnapshot>;
|
|
86
|
+
resolveDefaultModel(requiredArgs: {
|
|
87
|
+
context: import("../model-discovery-types.js").ModelDiscoveryContext;
|
|
88
|
+
catalog: import("../model-discovery-types.js").ModelCatalogSnapshot;
|
|
89
|
+
}, optionalArgs?: {
|
|
90
|
+
signal?: AbortSignal;
|
|
91
|
+
deps?: import("../model-discovery-types.js").ModelDiscoveryDeps;
|
|
92
|
+
}): Promise<import("../model-discovery-types.js").DefaultModelResolution>;
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=antigravity.d.ts.map
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import { createAgentModelDiscovery } from '../model-discovery-native.js';
|
|
2
|
+
import { redactOAuthUrls } from '@jini-ai/oauth';
|
|
3
|
+
import { DEFAULT_MODEL_OPTION } from './shared.js';
|
|
4
|
+
// `agy` v1.1.24 has a real `--model <id>` flag (`agy --help`: "Model for the current CLI
|
|
5
|
+
// session") plus a machine-readable `agy models` subcommand that lists every selectable model as
|
|
6
|
+
// a stable `<slug>\t<label>` pair — both verified live, neither true of the v1.0.3 this file used
|
|
7
|
+
// to target (upstream issue #35, closed by the flag's addition). That retires the
|
|
8
|
+
// settings.json-write-then-poll-the-log workaround this file used to carry (see git history for
|
|
9
|
+
// `writeAntigravityModelSelection`/`antigravityModelLock`/`waitForAgyToReadModel`, and the
|
|
10
|
+
// process-global race across concurrent runs it existed to serialize): the model rides argv on
|
|
11
|
+
// `buildArgs` below instead, exactly like every other flag this def emits, and there is nothing
|
|
12
|
+
// left to lock.
|
|
13
|
+
//
|
|
14
|
+
// Two cases `buildArgs` treats specially:
|
|
15
|
+
// - `DEFAULT_MODEL_OPTION.id` ('default') or no model at all: omit `--model` entirely, so agy
|
|
16
|
+
// keeps whatever it would otherwise default to (its own TUI's last pick, or its own default).
|
|
17
|
+
// - any other id: one of the stable slugs below (e.g. `gemini-3.1-pro-high`), passed verbatim as
|
|
18
|
+
// `--model`'s value.
|
|
19
|
+
//
|
|
20
|
+
// `supportsCustomModel: false` because the model set is still a server-side enum, not free text —
|
|
21
|
+
// but the failure mode for an id outside it changed for the better: `agy --model <bogus> -p ...`
|
|
22
|
+
// now prints a loud `Error: invalid model selection ...` plus the full list of valid models
|
|
23
|
+
// (verified live), rather than the old settings.json path's silent `availableModels` cache miss +
|
|
24
|
+
// empty print-mode output. Kept `false` anyway: nothing here validates a typed id before spawn, so
|
|
25
|
+
// letting a UI send arbitrary text would just move that same failure into production instead of
|
|
26
|
+
// preventing it — `isKnownModel` (`../models.ts`) is what actually gates a caller-supplied id
|
|
27
|
+
// against this list before it ever reaches `buildArgs`.
|
|
28
|
+
//
|
|
29
|
+
// The 14 slugs/labels below are `agy models`' full live output as of agy v1.1.24 (2026-09-02), not
|
|
30
|
+
// a hand-maintained guess — re-run `agy models` to refresh if upstream's catalog changes.
|
|
31
|
+
// `agy -p` prints an interactive OAuth sign-in URL to **stdout** and then
|
|
32
|
+
// exits **0** when the keyring entry is missing or expired, so a driver that
|
|
33
|
+
// streams stdout live shows that URL to the user as if it were the model's
|
|
34
|
+
// reply. Two reasons that is a leak, not merely ugly:
|
|
35
|
+
// - the URL carries the client_id and redirect_uri of a login flow bound to
|
|
36
|
+
// whoever runs the daemon, and a chat transcript is a far wider audience
|
|
37
|
+
// than a terminal;
|
|
38
|
+
// - it is also useless to click: `-p` print mode has no field to paste the
|
|
39
|
+
// resulting auth code back into (see `auth.ts`'s
|
|
40
|
+
// `antigravityAuthGuidance`), so the only outcome is a leaked URL.
|
|
41
|
+
// Hence `stdoutPolicy: {buffering: 'until-close'}` plus this redactor.
|
|
42
|
+
//
|
|
43
|
+
// The shape being matched is real, not guessed — it is the same text this
|
|
44
|
+
// package's own `isAntigravityAuthFailureText` already classifies, captured
|
|
45
|
+
// from agy v1.0.3:
|
|
46
|
+
// Authentication required. Please visit the URL to log in:
|
|
47
|
+
// https://accounts.google.com/o/oauth2/auth?client_id=…&redirect_uri=antigravity-redirect
|
|
48
|
+
const OAUTH_URL_PATTERN = new RegExp([
|
|
49
|
+
// Google's own OAuth 2.0 authorization host — the endpoint agy actually
|
|
50
|
+
// prints. Host-anchored rather than path-anchored so an upstream move
|
|
51
|
+
// from `/o/oauth2/auth` to any other path on that host still redacts.
|
|
52
|
+
String.raw `https?://accounts\.google\.com/\S*`,
|
|
53
|
+
// Any other absolute URL carrying an OAuth request's or a bearer
|
|
54
|
+
// credential's hallmark query parameter, so a future change of identity
|
|
55
|
+
// provider degrades to "redacted" instead of "leaked". Deliberately keyed
|
|
56
|
+
// on the parameter names rather than on the word "oauth" appearing
|
|
57
|
+
// somewhere in the URL, which would also eat ordinary documentation links
|
|
58
|
+
// an assistant reply might legitimately contain.
|
|
59
|
+
String.raw `https?://\S*[?&](?:client_id|code_challenge|code_verifier|access_token|id_token|refresh_token)=\S*`,
|
|
60
|
+
].join('|'), 'gi');
|
|
61
|
+
/** What a redacted URL is replaced with. Deliberately says *what* was removed, so the surrounding "Please visit the URL to log in:" text does not read as truncated output. */
|
|
62
|
+
const OAUTH_URL_PLACEHOLDER = '[redacted sign-in URL]';
|
|
63
|
+
/**
|
|
64
|
+
* Redacts any OAuth sign-in URL from agy's buffered print-mode stdout,
|
|
65
|
+
* leaving all other output byte-identical.
|
|
66
|
+
*
|
|
67
|
+
* Scoped to redaction on purpose: it does **not** classify the output as an
|
|
68
|
+
* auth failure or substitute sign-in guidance for it. That classification
|
|
69
|
+
* already has an owner — `auth.ts`'s `classifyAgentAuthFailure` /
|
|
70
|
+
* `isAntigravityAuthFailureText`, consumed by whatever surfaces a structured
|
|
71
|
+
* auth error — and duplicating the decision here would mean this def silently
|
|
72
|
+
* rewrites assistant text into instructions.
|
|
73
|
+
*
|
|
74
|
+
* @param fullText - The concatenation of every stdout chunk agy produced.
|
|
75
|
+
* @returns The same text with every sign-in URL replaced by a placeholder.
|
|
76
|
+
* @complexity O(n) in the buffered text length.
|
|
77
|
+
* @overallScore 100/100
|
|
78
|
+
*/
|
|
79
|
+
export function redactAntigravityAuthUrls({ fullText }) {
|
|
80
|
+
return redactOAuthUrls({ text: fullText, pattern: OAUTH_URL_PATTERN, replacement: OAUTH_URL_PLACEHOLDER });
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Parses `agy models`' stdout into the shared `RuntimeModelOption[]` shape.
|
|
84
|
+
*
|
|
85
|
+
* The CLI's real output (agy v1.1.24, verified live — see this file's header
|
|
86
|
+
* comment for the exact captured transcript) is one `Fetching available
|
|
87
|
+
* models...` progress line followed by one `<slug>\t<label>` pair per line.
|
|
88
|
+
* Each data line is split on the FIRST tab only, so a label that itself
|
|
89
|
+
* contains a tab or extra whitespace never bleeds into the id.
|
|
90
|
+
*
|
|
91
|
+
* @param stdout - Raw stdout from `agy models`.
|
|
92
|
+
* @returns The synthetic default option prepended to every parsed entry, or
|
|
93
|
+
* `null` when no real entry was found (empty stdout, or only the progress
|
|
94
|
+
* line survives filtering) — mirrors `parseCursorAgentModels`'s same-shape
|
|
95
|
+
* null contract, which `detection.ts#fetchModels` already treats the same
|
|
96
|
+
* as an empty array: fall back to `fallbackModels`.
|
|
97
|
+
* @complexity O(n) in the stdout length.
|
|
98
|
+
*/
|
|
99
|
+
export function parseAgyModels({ stdout }) {
|
|
100
|
+
const lines = String(stdout || '')
|
|
101
|
+
.split('\n')
|
|
102
|
+
.map((line) => line.trim())
|
|
103
|
+
.filter((line) => line.length > 0);
|
|
104
|
+
if (lines.length === 0)
|
|
105
|
+
return null;
|
|
106
|
+
const out = [DEFAULT_MODEL_OPTION];
|
|
107
|
+
const seen = new Set([DEFAULT_MODEL_OPTION.id]);
|
|
108
|
+
for (const line of lines) {
|
|
109
|
+
if (/^fetching available models\.\.\.$/i.test(line))
|
|
110
|
+
continue;
|
|
111
|
+
const tabIndex = line.indexOf('\t');
|
|
112
|
+
if (tabIndex === -1)
|
|
113
|
+
continue;
|
|
114
|
+
const id = line.slice(0, tabIndex).trim();
|
|
115
|
+
if (!id || seen.has(id))
|
|
116
|
+
continue;
|
|
117
|
+
seen.add(id);
|
|
118
|
+
const label = line.slice(tabIndex + 1).trim();
|
|
119
|
+
out.push({ id, label: label || id });
|
|
120
|
+
}
|
|
121
|
+
return out.length > 1 ? out : null;
|
|
122
|
+
}
|
|
123
|
+
export const antigravityAgentDef = {
|
|
124
|
+
...createAgentModelDiscovery('antigravity', { fallbackModels: () => antigravityAgentDef.fallbackModels, args: ['models'], parse: (input) => antigravityAgentDef.listModels.parse(input), get timeoutMs() { return antigravityAgentDef.listModels.timeoutMs; } }),
|
|
125
|
+
id: 'antigravity',
|
|
126
|
+
name: 'Antigravity',
|
|
127
|
+
bin: 'agy',
|
|
128
|
+
versionArgs: ['--version'],
|
|
129
|
+
// `agy models` does a real network fetch (its own stdout says "Fetching
|
|
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).
|
|
134
|
+
// It runs within the outer 10s discovery budget: Antigravity has no disk
|
|
135
|
+
// fallback, so `probeAgentCatalog` reserves no recovery time for it.
|
|
136
|
+
listModels: {
|
|
137
|
+
args: ['models'],
|
|
138
|
+
parse: parseAgyModels,
|
|
139
|
+
timeoutMs: 10_000,
|
|
140
|
+
},
|
|
141
|
+
// Checked against agy 1.4.2 and https://antigravity.google/docs/cli/headless/.
|
|
142
|
+
fallbackModelsAssertedAt: '2026-10-18',
|
|
143
|
+
fallbackModels: [
|
|
144
|
+
DEFAULT_MODEL_OPTION,
|
|
145
|
+
{ id: 'gemini-4-argon-high', label: 'Gemini 4 Argon High' },
|
|
146
|
+
{ id: 'gemini-4-argon-medium', label: 'Gemini 4 Argon Medium' },
|
|
147
|
+
{ id: 'gemini-4-argon-low', label: 'Gemini 4 Argon Low' },
|
|
148
|
+
{ id: 'gemini-3.8-flash-high', label: 'Gemini 3.8 Flash (High)' },
|
|
149
|
+
{ id: 'gemini-3.8-flash-medium', label: 'Gemini 3.8 Flash (Medium)' },
|
|
150
|
+
{ id: 'gemini-3.8-flash-low', label: 'Gemini 3.8 Flash (Low)' },
|
|
151
|
+
{ id: 'gemini-3.7-flash-high', label: 'Gemini 3.7 Flash (High)' },
|
|
152
|
+
{ id: 'gemini-3.7-flash-medium', label: 'Gemini 3.7 Flash (Medium)' },
|
|
153
|
+
{ id: 'gemini-3.7-flash-low', label: 'Gemini 3.7 Flash (Low)' },
|
|
154
|
+
{ id: 'gemini-3.6-flash-high', label: 'Gemini 3.6 Flash (High)' },
|
|
155
|
+
{ id: 'gemini-3.6-flash-medium', label: 'Gemini 3.6 Flash (Medium)' },
|
|
156
|
+
{ id: 'gemini-3.6-flash-low', label: 'Gemini 3.6 Flash (Low)' },
|
|
157
|
+
{ id: 'gemini-3.1-pro-high', label: 'Gemini 3.1 Pro (High)' },
|
|
158
|
+
{ id: 'gemini-3.1-pro-low', label: 'Gemini 3.1 Pro (Low)' },
|
|
159
|
+
{ id: 'claude-sonnet-4-6', label: 'Claude Sonnet 4.6 (Thinking)' },
|
|
160
|
+
{ id: 'claude-opus-4-6-thinking', label: 'Claude Opus 4.6 (Thinking)' },
|
|
161
|
+
{ id: 'gpt-oss-120b-medium', label: 'GPT-OSS 120B (Medium)' },
|
|
162
|
+
],
|
|
163
|
+
supportsCustomModel: false,
|
|
164
|
+
// agy has no `--effort`-shaped flag: reasoning effort is a trailing `-high`/
|
|
165
|
+
// `-medium`/`-low` on the model slug `--model` already carries (see the
|
|
166
|
+
// `fallbackModels` list above, which is `agy models`' real output). So this
|
|
167
|
+
// def declares the suffix VOCABULARY only — see `types.ts`'s
|
|
168
|
+
// `RuntimeReasoningInModelId` for why the per-base-model availability is
|
|
169
|
+
// derived from the model list instead of enumerated here, and why
|
|
170
|
+
// `-thinking` on `claude-opus-4-6-thinking` must not be read as a level.
|
|
171
|
+
// `buildArgs` below is deliberately unchanged: the effort is already inside
|
|
172
|
+
// `--model`'s value, so there is no second argv to emit.
|
|
173
|
+
reasoningInModelId: {
|
|
174
|
+
levels: [
|
|
175
|
+
{ id: 'high', label: 'High' },
|
|
176
|
+
{ id: 'medium', label: 'Medium' },
|
|
177
|
+
{ id: 'low', label: 'Low' },
|
|
178
|
+
],
|
|
179
|
+
},
|
|
180
|
+
// We deliberately do NOT opt into `resumesSessionViaCli` / agy's `-c`
|
|
181
|
+
// resume flag on follow-up turns. Tested both shapes; `-c` activates
|
|
182
|
+
// agy's internal agentic loop (multi-step model retries, tool calls,
|
|
183
|
+
// fallback-to-cached-response on tool errors) which can't be steered
|
|
184
|
+
// from OD's system-prompt OVERRIDE — even with the strongest wording
|
|
185
|
+
// we got an identical byte-for-byte form re-emission on turn 2 when
|
|
186
|
+
// turn 1's tool-call retry path returned the cached form response.
|
|
187
|
+
//
|
|
188
|
+
// Instead we treat agy as a stateless plain adapter like qwen /
|
|
189
|
+
// deepseek: every spawn gets the full OD-rendered transcript via
|
|
190
|
+
// `buildDaemonTranscript`, and that transcript's prior assistant
|
|
191
|
+
// turns are sanitized to strip `<question-form>` markup + form-schema
|
|
192
|
+
// JSON fences (see `sanitizePriorAssistantTurnForTranscript` in
|
|
193
|
+
// apps/web/src/providers/daemon.ts). The stronger OVERRIDE block
|
|
194
|
+
// composed in server.ts gives a second line of defense for weak
|
|
195
|
+
// plain-stream models like Gemini 3.5 Flash.
|
|
196
|
+
buildArgs: ({ prompt, imagePaths: _imagePaths }, { extraAllowedDirs: _extra = [], options = {}, runtimeContext = {} } = {}) => {
|
|
197
|
+
// `-p` is a Go `flag`-package flag that TAKES THE PROMPT AS ITS VALUE,
|
|
198
|
+
// not a boolean switch followed by a positional prompt, and agy has no
|
|
199
|
+
// stdin sentinel under the default `--input-format text`. Verified
|
|
200
|
+
// against the installed agy v1.1.19:
|
|
201
|
+
// - `agy -p` alone -> `flag needs an argument: -p`
|
|
202
|
+
// - `echo <prompt> | agy -p -` -> runs, but the prompt is the literal
|
|
203
|
+
// one-character string `-`; the piped stdin is never read, and agy
|
|
204
|
+
// answers the empty ask with a generic greeting drawn from whatever
|
|
205
|
+
// project memory it has ("How can I assist you today?").
|
|
206
|
+
// - `agy -p '<prompt>'` -> the prompt actually lands.
|
|
207
|
+
// So the prompt rides argv as `-p`'s value. That is also why this def is
|
|
208
|
+
// argv-budgeted (`maxPromptArgBytes` below) rather than `promptViaStdin`.
|
|
209
|
+
const args = [];
|
|
210
|
+
// Match the owner's existing Full CLI grant; never infer approval from headless mode.
|
|
211
|
+
if (options.cliParity === true && options.permissionMode === 'bypass' && options.nativeToolAccess !== false) {
|
|
212
|
+
args.push('--dangerously-skip-permissions');
|
|
213
|
+
}
|
|
214
|
+
// `--model` is the same kind of Go flag as `--log-file`/`-p`: its value is
|
|
215
|
+
// whatever argv token immediately follows it, so it too must be pushed
|
|
216
|
+
// before `-p` (always last — see below). Verified live against agy
|
|
217
|
+
// v1.1.24: `agy --model <slug> -p '<prompt>'` runs that one print-mode
|
|
218
|
+
// turn on the named model, and combining it with `--log-file` works the
|
|
219
|
+
// same way — relative order between `--model` and `--log-file` doesn't
|
|
220
|
+
// matter (each independently consumes exactly the one token after it),
|
|
221
|
+
// only that both precede `-p`.
|
|
222
|
+
if (options.model && options.model !== DEFAULT_MODEL_OPTION.id) {
|
|
223
|
+
args.push('--model', options.model);
|
|
224
|
+
}
|
|
225
|
+
// Always opt into `--log-file` when the daemon supplied a path so
|
|
226
|
+
// it can post-exit grep for the actual upstream failure shape
|
|
227
|
+
// (auth missing vs quota reached vs upstream error) — without it
|
|
228
|
+
// the chat surfaces a generic "empty response" because print mode
|
|
229
|
+
// never echoes those errors on stdout. See server.ts empty-output
|
|
230
|
+
// guard for the consumer.
|
|
231
|
+
if (runtimeContext.agentLogFilePath) {
|
|
232
|
+
args.push('--log-file', runtimeContext.agentLogFilePath);
|
|
233
|
+
}
|
|
234
|
+
args.push('-p', prompt);
|
|
235
|
+
return args;
|
|
236
|
+
},
|
|
237
|
+
// agy takes its prompt on argv (see `buildArgs`), so this def is
|
|
238
|
+
// argv-budgeted like the other plain-stream argv adapters (aider,
|
|
239
|
+
// deepseek) rather than `promptViaStdin`. Without one of these three
|
|
240
|
+
// fields `assessAgentExecutorCompatibility` rejects the def outright.
|
|
241
|
+
maxPromptArgBytes: 30_000,
|
|
242
|
+
streamFormat: 'plain',
|
|
243
|
+
// `buildArgs` above already consumes `runtimeContext.agentLogFilePath` when
|
|
244
|
+
// the caller supplies one; this is what asks it to. Print mode never
|
|
245
|
+
// echoes auth/quota failures on stdout, so post-exit log inspection is the
|
|
246
|
+
// only way to tell those two apart — see server.ts's empty-output guard
|
|
247
|
+
// for the consumer.
|
|
248
|
+
needsAgentLogFile: true,
|
|
249
|
+
// The one adapter in this package that must not stream live — see
|
|
250
|
+
// `redactAntigravityAuthUrls`'s comment for the OAuth-URL-on-stdout-plus-
|
|
251
|
+
// exit-0 behavior that forces it. Every other `streamFormat: 'plain'`
|
|
252
|
+
// adapter (grok-build, aider, deepseek, qwen) leaves `stdoutPolicy` unset
|
|
253
|
+
// and keeps streaming per chunk; aider's and deepseek's own comments call
|
|
254
|
+
// that live cadence out as deliberate.
|
|
255
|
+
stdoutPolicy: { buffering: 'until-close', sanitize: redactAntigravityAuthUrls },
|
|
256
|
+
installUrl: 'https://antigravity.google/cli',
|
|
257
|
+
docsUrl: 'https://antigravity.google/docs/cli-overview',
|
|
258
|
+
// `externalMcpInjection: 'env-passthrough'` — the prior verdict here ("no safe, run-scoped
|
|
259
|
+
// delivery mechanism exists") stood as long as the only candidates were a per-run config
|
|
260
|
+
// flag/relocatable home dir, neither of which `agy` has (see the probes below, still accurate).
|
|
261
|
+
// What flips the verdict is a THIRD property, verified live and not previously tested: `agy`
|
|
262
|
+
// passes its own parent process environment through to the stdio MCP server children it spawns
|
|
263
|
+
// for servers already sitting in its persistent global registry.
|
|
264
|
+
//
|
|
265
|
+
// - Proven with a probe MCP server registered under a relocated `HOME`'s
|
|
266
|
+
// `.gemini/config/mcp_config.json`: booted under `agy -p`, it read a marker variable
|
|
267
|
+
// straight out of its own `process.env` — no config field, no
|
|
268
|
+
// argv, nothing but inherited environment. Full MCP handshake observed on the same run:
|
|
269
|
+
// `server/discover` → `initialize` → `notifications/initialized` → `tools/list`
|
|
270
|
+
// (protocolVersion `2025-11-25`, clientInfo `antigravity-client`).
|
|
271
|
+
// - That makes the registration itself a STATIC, one-time operation — the operator adds one
|
|
272
|
+
// bridge entry to their real `~/.gemini/config/mcp_config.json` (confirmed still the one real
|
|
273
|
+
// mechanism; see the probes below) with a bare, env-free `command` pointing at this package's
|
|
274
|
+
// own `jini-mcp` bin, resolving its credential from the environment at spawn time instead of
|
|
275
|
+
// a baked-in value. No per-spawn config mutation, no lock, no restore discipline — the exact
|
|
276
|
+
// "safe, run-scoped delivery" gap the old verdict cited is closed by inheritance, not by
|
|
277
|
+
// relocation.
|
|
278
|
+
// - So this def's job shrinks to exactly what `'env-passthrough'` describes in `types.ts`: put
|
|
279
|
+
// the bridge entry's `JINI_RUN_ID`/`JINI_DAEMON_URL`/`JINI_DAEMON_TOKEN` onto `agy`'s OWN
|
|
280
|
+
// spawn env (done centrally by `@jini-ai/daemon`'s `computeChildEnv`, not by this def's
|
|
281
|
+
// `buildArgs`), and `agy` carries them the rest of the way to the already-registered server on
|
|
282
|
+
// its own.
|
|
283
|
+
//
|
|
284
|
+
// The prior probes into a per-run/relocatable mechanism remain accurate and are kept as the
|
|
285
|
+
// record of what does NOT work, so a future reader does not re-walk the same dead ends:
|
|
286
|
+
//
|
|
287
|
+
// - No per-run config-path flag. `agy --help` and `agy mcp add --help` were read in full: `mcp
|
|
288
|
+
// add/remove/list/enable/disable` only mutate the PERSISTENT global registry — there is no
|
|
289
|
+
// `--mcp-config <path>`-shaped flag anywhere on the top-level command or its subcommands.
|
|
290
|
+
// - No CODEX_HOME-equivalent env var. `strings` over the `agy` binary itself (not just docs) for
|
|
291
|
+
// every all-caps `*HOME*`/`*_DIR`/`*_PATH`/`XDG_*` token found nothing naming a relocatable
|
|
292
|
+
// config/data root for Antigravity or Gemini specifically — only the generic `HOME` (relocating
|
|
293
|
+
// that would redirect the ENTIRE user profile for the child, not a scoped config dir, and is not
|
|
294
|
+
// an "explicit, run-scoped delivery" by any reasonable reading). Also why the passthrough probe
|
|
295
|
+
// above used a relocated `HOME` only to prove inheritance in isolation — production spawns
|
|
296
|
+
// always use the operator's real `HOME`, since relocating it breaks `agy`'s own auth.
|
|
297
|
+
// - The workspace-relative `.agents/mcp_config.json` this comment used to cite as unverified is
|
|
298
|
+
// now verified NOT to be what it looked like: a project dir was seeded with a real
|
|
299
|
+
// `.agents/mcp_config.json` entry, then `agy mcp list` (run from that cwd) showed only the
|
|
300
|
+
// REAL global config's servers — the workspace file never appeared. A live headless `agy -p`
|
|
301
|
+
// run from that same cwd (both with and without `--new-project`), captured via `--log-file`,
|
|
302
|
+
// shows zero mention of "mcp" or the seeded server name anywhere in its diagnostic log, and its
|
|
303
|
+
// own log line reports the run scoped to a generic `"CLI Project"` bucket, not the cwd as a
|
|
304
|
+
// distinct project. Best read: `.agents/mcp_config.json` belongs to the Antigravity IDE
|
|
305
|
+
// extension's own project layer, a different consumer than the bare `agy` CLI binary this
|
|
306
|
+
// daemon actually spawns — not a mechanism reachable from a plain `agy -p` invocation at all.
|
|
307
|
+
// Confirmed independently upstream: antigravity-cli issue #60 (open, no maintainer response)
|
|
308
|
+
// reports the identical "project-local mcp_config.json is read but ignored" symptom.
|
|
309
|
+
// - `~/.gemini/config/mcp_config.json` (global, JSON, `{"mcpServers":{"<name>":{"command":...}}}`,
|
|
310
|
+
// confirmed by reading the operator's own file read-only after backing it up) has no relocation
|
|
311
|
+
// path — but per the passthrough finding above, this def never needs to write to it at all
|
|
312
|
+
// outside the one-time operator registration, so the shared-file race a prior version of this
|
|
313
|
+
// comment warned about (a second race alongside the now-deleted settings.json model lock) never
|
|
314
|
+
// materializes: nothing here mutates that file per run.
|
|
315
|
+
//
|
|
316
|
+
// No hang was observed on any of these probes (all completed in well under `--print-timeout`'s
|
|
317
|
+
// default 5m).
|
|
318
|
+
externalMcpInjection: 'env-passthrough',
|
|
319
|
+
};
|
|
320
|
+
//# sourceMappingURL=antigravity.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare const copilotAgentDef: {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
bin: string;
|
|
5
|
+
versionArgs: string[];
|
|
6
|
+
fallbackModels: import("../types.js").RuntimeModelOption[];
|
|
7
|
+
buildArgs: ({ prompt: _prompt, imagePaths: _imagePaths }: {
|
|
8
|
+
prompt: string;
|
|
9
|
+
imagePaths: string[];
|
|
10
|
+
}, { extraAllowedDirs, options }?: {
|
|
11
|
+
extraAllowedDirs?: string[];
|
|
12
|
+
options?: import("../types.js").RuntimeBuildOptions;
|
|
13
|
+
runtimeContext?: import("../types.js").RuntimeContext;
|
|
14
|
+
} | undefined) => string[];
|
|
15
|
+
promptViaStdin: true;
|
|
16
|
+
streamFormat: string;
|
|
17
|
+
inactivityTimeoutMs: number;
|
|
18
|
+
discoverModels(requiredArgs: {
|
|
19
|
+
context: import("../model-discovery-types.js").ModelDiscoveryContext;
|
|
20
|
+
}, optionalArgs?: {
|
|
21
|
+
signal?: AbortSignal;
|
|
22
|
+
force?: boolean;
|
|
23
|
+
staleWhileRevalidate?: boolean;
|
|
24
|
+
deps?: import("../model-discovery-types.js").ModelDiscoveryDeps;
|
|
25
|
+
}): Promise<import("../model-discovery-types.js").ModelCatalogSnapshot>;
|
|
26
|
+
resolveDefaultModel(requiredArgs: {
|
|
27
|
+
context: import("../model-discovery-types.js").ModelDiscoveryContext;
|
|
28
|
+
catalog: import("../model-discovery-types.js").ModelCatalogSnapshot;
|
|
29
|
+
}, optionalArgs?: {
|
|
30
|
+
signal?: AbortSignal;
|
|
31
|
+
deps?: import("../model-discovery-types.js").ModelDiscoveryDeps;
|
|
32
|
+
}): Promise<import("../model-discovery-types.js").DefaultModelResolution>;
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=copilot.d.ts.map
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { createAgentModelDiscovery } from '../model-discovery-native.js';
|
|
2
|
+
import { DEFAULT_MODEL_OPTION } from './shared.js';
|
|
3
|
+
export const copilotAgentDef = {
|
|
4
|
+
// UNVERIFIED live integration locally; source/category and limits are documented in model-discovery-adapters.ts.
|
|
5
|
+
...createAgentModelDiscovery('copilot', { fallbackModels: () => copilotAgentDef.fallbackModels }),
|
|
6
|
+
id: 'copilot',
|
|
7
|
+
name: 'GitHub Copilot CLI',
|
|
8
|
+
bin: 'copilot',
|
|
9
|
+
versionArgs: ['--version'],
|
|
10
|
+
// Prompt is delivered via stdin (gated by `promptViaStdin: true`
|
|
11
|
+
// below) to avoid Windows `spawn ENAMETOOLONG` (issue #705):
|
|
12
|
+
// `copilot -p <body>` ships the full composed prompt as a single
|
|
13
|
+
// argv entry, and CreateProcess caps `lpCommandLine` at ~32 KB
|
|
14
|
+
// direct or ~8 KB through a `.cmd` shim. Any non-trivial composed
|
|
15
|
+
// prompt blows past that — even a "Hi" expands to several thousand
|
|
16
|
+
// chars after selected context is composed in.
|
|
17
|
+
//
|
|
18
|
+
// The transport is "omit `-p` entirely, pipe the prompt to stdin"
|
|
19
|
+
// per upstream copilot-cli issue #1046 (closed as already supported,
|
|
20
|
+
// confirmed working on Copilot CLI for `echo "..." | copilot
|
|
21
|
+
// --model <id>` and `cat prompt.txt | copilot --model <id>`). The
|
|
22
|
+
// `-p -` form is a literal one-character prompt; omitting
|
|
23
|
+
// `-p` entirely is the separate code path that delegates to
|
|
24
|
+
// stdin under a non-TTY pipe — which is exactly how the daemon
|
|
25
|
+
// spawns the child (`stdio: ['pipe', 'pipe', 'pipe']`).
|
|
26
|
+
//
|
|
27
|
+
// `--allow-all-tools` is still required for non-interactive runs:
|
|
28
|
+
// without it the CLI blocks waiting for human approval on every
|
|
29
|
+
// tool call. Unlike Codex (where `exec` is a dedicated headless
|
|
30
|
+
// subcommand with auto-approve baked in) or Claude Code (which
|
|
31
|
+
// inherits its permission policy from the user's settings.json),
|
|
32
|
+
// Copilot always prompts unless this flag is passed explicitly.
|
|
33
|
+
//
|
|
34
|
+
// `--output-format json` produces JSONL that copilot-stream.js
|
|
35
|
+
// parses into the same typed events as claude-stream.js.
|
|
36
|
+
//
|
|
37
|
+
// `--add-dir` (repeatable, same flag as Claude Code's) widens
|
|
38
|
+
// Copilot's path-level sandbox to skill seeds + design-system
|
|
39
|
+
// specs outside the project cwd.
|
|
40
|
+
//
|
|
41
|
+
// No `models` subcommand; the CLI accepts whatever the user's
|
|
42
|
+
// Copilot subscription exposes. Ship a small evidence-based hint
|
|
43
|
+
// list — the default we observed in the JSON stream and the
|
|
44
|
+
// example from `copilot --help`. Users can paste any other id via
|
|
45
|
+
// Settings.
|
|
46
|
+
fallbackModels: [
|
|
47
|
+
DEFAULT_MODEL_OPTION,
|
|
48
|
+
{ id: 'claude-sonnet-4.6', label: 'Claude Sonnet 4.6' },
|
|
49
|
+
{ id: 'gpt-5.2', label: 'GPT-5.2' },
|
|
50
|
+
],
|
|
51
|
+
buildArgs: ({ prompt: _prompt, imagePaths: _imagePaths }, { extraAllowedDirs = [], options = {} } = {}) => {
|
|
52
|
+
const args = [
|
|
53
|
+
// See `RuntimeBuildOptions.permissionMode`'s doc: bypass is the default (unchanged
|
|
54
|
+
// behavior) unless a caller explicitly opts into a restricted run, in which case
|
|
55
|
+
// Copilot withholds tool calls that would need approval instead of auto-running them.
|
|
56
|
+
...(options.permissionMode !== 'restricted' ? ['--allow-all-tools'] : []),
|
|
57
|
+
'--output-format',
|
|
58
|
+
'json',
|
|
59
|
+
];
|
|
60
|
+
if (options.model && options.model !== 'default') {
|
|
61
|
+
args.push('--model', options.model);
|
|
62
|
+
}
|
|
63
|
+
const dirs = (extraAllowedDirs || []).filter((d) => typeof d === 'string' && d.length > 0);
|
|
64
|
+
for (const d of dirs)
|
|
65
|
+
args.push('--add-dir', d);
|
|
66
|
+
return args;
|
|
67
|
+
},
|
|
68
|
+
promptViaStdin: true,
|
|
69
|
+
streamFormat: 'copilot-stream-json',
|
|
70
|
+
// GitHub Copilot's deck-generation and large-prompt turns go silent
|
|
71
|
+
// (no stdout, no streamed events) for stretches that exceed the
|
|
72
|
+
// 10-minute global default — the model is still working but the
|
|
73
|
+
// CLI does not emit keepalive frames. The default watchdog used to
|
|
74
|
+
// kill those runs as `stalled` even though the agent was healthy
|
|
75
|
+
// (issue #2467: "GitHub Copilot agent getting stuck after 10 mins
|
|
76
|
+
// and few seconds"). 30 minutes gives the heavy turns room to land
|
|
77
|
+
// while still bounding genuine hangs; a host can still allow an
|
|
78
|
+
// operator to override this via its own env var if it wants it
|
|
79
|
+
// tighter.
|
|
80
|
+
inactivityTimeoutMs: 30 * 60 * 1000,
|
|
81
|
+
// No `externalMcpInjection` yet. Copilot CLI has an explicit, run-scoped
|
|
82
|
+
// flag for this: `--additional-mcp-config <json|@path>`, documented as
|
|
83
|
+
// session-only and the highest-priority MCP source (it wins over both
|
|
84
|
+
// `~/.copilot/mcp-config.json` and the auto-discovered project
|
|
85
|
+
// `.github/mcp.json`/`.mcp.json`) — so, unlike the global-file or
|
|
86
|
+
// auto-discovery routes this comment previously (incorrectly) treated as
|
|
87
|
+
// the only options, this one needs neither `COPILOT_HOME` redirection nor
|
|
88
|
+
// `GITHUB_COPILOT_PROMPT_MODE_WORKSPACE_MCP` trust gating. What's still
|
|
89
|
+
// unconfirmed is the exact JSON shape the flag expects at its top level
|
|
90
|
+
// (official docs describe the flag's purpose but not its schema
|
|
91
|
+
// verbatim) — needs a local `copilot --help`/`copilot mcp --help` check
|
|
92
|
+
// before wiring, not a guess. Closest candidate for a new strategy: pass
|
|
93
|
+
// `@<run-scoped-file>` the same way `'claude-mcp-json'` passes a path,
|
|
94
|
+
// once the schema is confirmed.
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=copilot.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const geminiAgentDef: {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
bin: string;
|
|
5
|
+
versionArgs: string[];
|
|
6
|
+
versionProbeTimeoutMs: number;
|
|
7
|
+
helpArgs: string[];
|
|
8
|
+
capabilityFlags: {
|
|
9
|
+
"--skip-trust": string;
|
|
10
|
+
};
|
|
11
|
+
fallbackModels: import("../types.js").RuntimeModelOption[];
|
|
12
|
+
buildArgs: ({ prompt: _prompt, imagePaths: _imagePaths }: {
|
|
13
|
+
prompt: string;
|
|
14
|
+
imagePaths: string[];
|
|
15
|
+
}, { extraAllowedDirs, options }?: {
|
|
16
|
+
extraAllowedDirs?: string[];
|
|
17
|
+
options?: import("../types.js").RuntimeBuildOptions;
|
|
18
|
+
runtimeContext?: import("../types.js").RuntimeContext;
|
|
19
|
+
} | undefined) => string[];
|
|
20
|
+
promptViaStdin: true;
|
|
21
|
+
streamFormat: string;
|
|
22
|
+
eventParser: string;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=gemini.d.ts.map
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module defs/gemini
|
|
3
|
+
*
|
|
4
|
+
* Google's Gemini CLI (`gemini`, npm `@google/gemini-cli`). Checked against an installed
|
|
5
|
+
* `gemini` 0.58.0 (`gemini --help` and the bundled headless code path) and the upstream headless
|
|
6
|
+
* docs (<https://geminicli.com/docs/cli/headless>):
|
|
7
|
+
*
|
|
8
|
+
* - Headless mode starts whenever stdin is not a TTY; the whole piped stdin becomes the prompt
|
|
9
|
+
* (`-p` is only needed to pass the prompt in argv, and would be "appended to input on stdin").
|
|
10
|
+
* So the prompt goes over stdin, like the Qwen Code fork, which avoids Windows `spawn
|
|
11
|
+
* ENAMETOOLONG` on large composed prompts.
|
|
12
|
+
* - `--output-format stream-json` emits the JSONL `init` / `message` / `tool_use` /
|
|
13
|
+
* `tool_result` / `error` / `result` events that `json-event-stream.ts`'s `gemini` parser
|
|
14
|
+
* already reads.
|
|
15
|
+
* - `--approval-mode yolo` auto-approves every tool (the `--yolo` alias does the same).
|
|
16
|
+
* - Since folder trust landed, a headless run in an untrusted directory exits with "Gemini CLI
|
|
17
|
+
* is not running in a trusted directory. To proceed, either use `--skip-trust`, …". The host
|
|
18
|
+
* already chose the run's cwd, so the def trusts it for this session only. Older builds
|
|
19
|
+
* reject unknown flags, so `--skip-trust` is gated on the `--help` capability probe.
|
|
20
|
+
* - `--include-directories` (repeatable) widens the workspace to dirs outside the cwd.
|
|
21
|
+
*
|
|
22
|
+
* Auth: since 2026-06-18 Google no longer serves Gemini CLI's "Login with Google" for free /
|
|
23
|
+
* Google AI Pro / Ultra individual accounts (the run dies with `IneligibleTierError: This client
|
|
24
|
+
* is no longer supported for Gemini Code Assist for individuals`). A Gemini API key, Vertex AI,
|
|
25
|
+
* or a Gemini Code Assist license still works. There is no side-effect-free auth-status
|
|
26
|
+
* subcommand, so no `authProbe`; `auth.ts#classifyAgentAuthFailure` turns the failure text into
|
|
27
|
+
* setup guidance instead.
|
|
28
|
+
*/
|
|
29
|
+
import { DEFAULT_MODEL_OPTION } from './shared.js';
|
|
30
|
+
import { agentCapabilities } from '../capabilities.js';
|
|
31
|
+
const SKIP_TRUST_FLAG = '--skip-trust';
|
|
32
|
+
export const geminiAgentDef = {
|
|
33
|
+
id: 'gemini',
|
|
34
|
+
name: 'Gemini CLI',
|
|
35
|
+
bin: 'gemini',
|
|
36
|
+
versionArgs: ['--version'],
|
|
37
|
+
// A cold `gemini --version` took 4.7 s on the dev machine (warm ~2 s), past the 3 s default.
|
|
38
|
+
versionProbeTimeoutMs: 10_000,
|
|
39
|
+
helpArgs: ['--help'],
|
|
40
|
+
capabilityFlags: {
|
|
41
|
+
[SKIP_TRUST_FLAG]: 'skipTrust',
|
|
42
|
+
},
|
|
43
|
+
// No `models` subcommand. `auto` and the concrete ids below are the ones the installed
|
|
44
|
+
// 0.58.0 bundle and the upstream model docs name; any other id can still be typed in.
|
|
45
|
+
fallbackModels: [
|
|
46
|
+
DEFAULT_MODEL_OPTION,
|
|
47
|
+
{ id: 'auto', label: 'auto' },
|
|
48
|
+
{ id: 'gemini-3.1-pro-preview', label: 'gemini-3.1-pro-preview' },
|
|
49
|
+
{ id: 'gemini-3.5-flash', label: 'gemini-3.5-flash' },
|
|
50
|
+
{ id: 'gemini-3-pro-preview', label: 'gemini-3-pro-preview' },
|
|
51
|
+
{ id: 'gemini-3-flash-preview', label: 'gemini-3-flash-preview' },
|
|
52
|
+
{ id: 'gemini-2.5-pro', label: 'gemini-2.5-pro' },
|
|
53
|
+
{ id: 'gemini-2.5-flash', label: 'gemini-2.5-flash' },
|
|
54
|
+
],
|
|
55
|
+
buildArgs: ({ prompt: _prompt, imagePaths: _imagePaths }, { extraAllowedDirs = [], options = {} } = {}) => {
|
|
56
|
+
const args = ['--output-format', 'stream-json'];
|
|
57
|
+
if (agentCapabilities.get('gemini')?.skipTrust) {
|
|
58
|
+
args.push(SKIP_TRUST_FLAG);
|
|
59
|
+
}
|
|
60
|
+
// See `RuntimeBuildOptions.permissionMode`'s doc: bypass is the default (unchanged
|
|
61
|
+
// behavior) unless a caller explicitly opts into a restricted run.
|
|
62
|
+
if (options.permissionMode !== 'restricted') {
|
|
63
|
+
args.push('--approval-mode', 'yolo');
|
|
64
|
+
}
|
|
65
|
+
if (options.model && options.model !== 'default') {
|
|
66
|
+
args.push('--model', options.model);
|
|
67
|
+
}
|
|
68
|
+
const dirs = (extraAllowedDirs || []).filter((d) => typeof d === 'string' && d.length > 0);
|
|
69
|
+
for (const d of dirs)
|
|
70
|
+
args.push('--include-directories', d);
|
|
71
|
+
return args;
|
|
72
|
+
},
|
|
73
|
+
promptViaStdin: true,
|
|
74
|
+
streamFormat: 'json-event-stream',
|
|
75
|
+
eventParser: 'gemini',
|
|
76
|
+
// No `externalMcpInjection` yet: Gemini CLI reads `mcpServers` from `settings.json` (user,
|
|
77
|
+
// project `.gemini/settings.json`, or a system file named by
|
|
78
|
+
// `GEMINI_CLI_SYSTEM_SETTINGS_PATH`), with no per-run `--mcp-config` flag. A run-scoped
|
|
79
|
+
// system-settings file is the likely strategy, but it is not wired or verified live.
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=gemini.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jini-ai/agent-runtime",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.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": {
|
|
@@ -119,16 +119,16 @@
|
|
|
119
119
|
},
|
|
120
120
|
"devDependencies": {
|
|
121
121
|
"@vitest/coverage-v8": "^2.1.9",
|
|
122
|
-
"@jini-ai/core": "^0.7.
|
|
123
|
-
"@jini-ai/integrations": "^0.7.
|
|
124
|
-
"@jini-ai/platform": "^0.7.
|
|
122
|
+
"@jini-ai/core": "^0.7.2",
|
|
123
|
+
"@jini-ai/integrations": "^0.7.2",
|
|
124
|
+
"@jini-ai/platform": "^0.7.2"
|
|
125
125
|
},
|
|
126
126
|
"dependencies": {
|
|
127
|
-
"@jini-ai/
|
|
128
|
-
"@jini-ai/integrations": "^0.7.
|
|
129
|
-
"@jini-ai/oauth": "^0.7.
|
|
130
|
-
"@jini-ai/
|
|
131
|
-
"@jini-ai/platform": "^0.7.
|
|
127
|
+
"@jini-ai/core": "^0.7.2",
|
|
128
|
+
"@jini-ai/integrations": "^0.7.2",
|
|
129
|
+
"@jini-ai/oauth": "^0.7.2",
|
|
130
|
+
"@jini-ai/protocol": "^0.7.2",
|
|
131
|
+
"@jini-ai/platform": "^0.7.2"
|
|
132
132
|
},
|
|
133
133
|
"scripts": {
|
|
134
134
|
"build": "tsc -p tsconfig.json",
|