@junctionpanel/server 0.1.72 → 0.1.74
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/dist/server/client/daemon-client.d.ts +5 -1
- package/dist/server/client/daemon-client.d.ts.map +1 -1
- package/dist/server/client/daemon-client.js +12 -5
- package/dist/server/client/daemon-client.js.map +1 -1
- package/dist/server/server/agent/provider-model-cache.d.ts +1 -0
- package/dist/server/server/agent/provider-model-cache.d.ts.map +1 -1
- package/dist/server/server/agent/provider-model-cache.js +44 -0
- package/dist/server/server/agent/provider-model-cache.js.map +1 -1
- package/dist/server/server/agent/providers/gemini-agent.d.ts +2 -1
- package/dist/server/server/agent/providers/gemini-agent.d.ts.map +1 -1
- package/dist/server/server/agent/providers/gemini-agent.js +96 -45
- package/dist/server/server/agent/providers/gemini-agent.js.map +1 -1
- package/dist/server/server/daemon-doctor.d.ts +7 -1
- package/dist/server/server/daemon-doctor.d.ts.map +1 -1
- package/dist/server/server/daemon-doctor.js +115 -3
- package/dist/server/server/daemon-doctor.js.map +1 -1
- package/dist/server/server/relay-transport.d.ts.map +1 -1
- package/dist/server/server/relay-transport.js +34 -2
- package/dist/server/server/relay-transport.js.map +1 -1
- package/dist/server/server/session.d.ts +1 -2
- package/dist/server/server/session.d.ts.map +1 -1
- package/dist/server/server/session.js +123 -67
- package/dist/server/server/session.js.map +1 -1
- package/dist/server/shared/messages.d.ts +32 -0
- package/dist/server/shared/messages.d.ts.map +1 -1
- package/dist/server/shared/messages.js +2 -0
- package/dist/server/shared/messages.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-model-cache.d.ts","sourceRoot":"","sources":["../../../../src/server/agent/provider-model-cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,eAAO,MAAM,2BAA2B,QAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"provider-model-cache.d.ts","sourceRoot":"","sources":["../../../../src/server/agent/provider-model-cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,eAAO,MAAM,2BAA2B,QAAS,CAAC;AAClD,eAAO,MAAM,kCAAkC,QAAS,CAAC;AAYzD,KAAK,4BAA4B,GAAG;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAmGF,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,4BAA4B,GAClC,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAkCjC;AAED,wBAAgB,+BAA+B,IAAI,IAAI,CAItD"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export const PROVIDER_MODEL_CACHE_TTL_MS = 60000;
|
|
2
|
+
export const PROVIDER_MODEL_FAILURE_COOLDOWN_MS = 60000;
|
|
2
3
|
const providerModelCache = new Map();
|
|
3
4
|
const providerModelInflight = new Map();
|
|
5
|
+
const providerModelFailures = new Map();
|
|
4
6
|
function cloneThinkingOptions(options) {
|
|
5
7
|
return options?.map((option) => ({
|
|
6
8
|
...option,
|
|
@@ -19,6 +21,28 @@ function cloneProviderModels(models) {
|
|
|
19
21
|
function isFresh(entry, ttlMs) {
|
|
20
22
|
return Date.now() - entry.fetchedAt < ttlMs;
|
|
21
23
|
}
|
|
24
|
+
function isFailureFresh(entry) {
|
|
25
|
+
return Date.now() - entry.failedAt < PROVIDER_MODEL_FAILURE_COOLDOWN_MS;
|
|
26
|
+
}
|
|
27
|
+
function toProviderModelError(error) {
|
|
28
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
29
|
+
}
|
|
30
|
+
function cloneProviderModelError(error) {
|
|
31
|
+
const cloned = new Error(error.message);
|
|
32
|
+
cloned.name = error.name;
|
|
33
|
+
if (error.stack) {
|
|
34
|
+
cloned.stack = error.stack;
|
|
35
|
+
}
|
|
36
|
+
if ("cause" in error) {
|
|
37
|
+
Object.defineProperty(cloned, "cause", {
|
|
38
|
+
configurable: true,
|
|
39
|
+
enumerable: false,
|
|
40
|
+
value: error.cause,
|
|
41
|
+
writable: true,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return cloned;
|
|
45
|
+
}
|
|
22
46
|
async function refreshProviderModels(input) {
|
|
23
47
|
const existingInflight = providerModelInflight.get(input.cacheKey);
|
|
24
48
|
if (existingInflight) {
|
|
@@ -33,6 +57,7 @@ async function refreshProviderModels(input) {
|
|
|
33
57
|
models: cachedModels,
|
|
34
58
|
fetchedAt: Date.now(),
|
|
35
59
|
});
|
|
60
|
+
providerModelFailures.delete(input.cacheKey);
|
|
36
61
|
input.logger.debug({
|
|
37
62
|
provider: input.provider,
|
|
38
63
|
durationMs: Date.now() - startedAt,
|
|
@@ -40,6 +65,14 @@ async function refreshProviderModels(input) {
|
|
|
40
65
|
}, "Provider model catalog refreshed");
|
|
41
66
|
return cachedModels;
|
|
42
67
|
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
const normalizedError = toProviderModelError(error);
|
|
70
|
+
providerModelFailures.set(input.cacheKey, {
|
|
71
|
+
error: normalizedError,
|
|
72
|
+
failedAt: Date.now(),
|
|
73
|
+
});
|
|
74
|
+
throw normalizedError;
|
|
75
|
+
}
|
|
43
76
|
finally {
|
|
44
77
|
providerModelInflight.delete(input.cacheKey);
|
|
45
78
|
}
|
|
@@ -50,12 +83,22 @@ async function refreshProviderModels(input) {
|
|
|
50
83
|
export async function getCachedProviderModels(input) {
|
|
51
84
|
const ttlMs = input.ttlMs ?? PROVIDER_MODEL_CACHE_TTL_MS;
|
|
52
85
|
const cached = providerModelCache.get(input.cacheKey);
|
|
86
|
+
const recentFailure = providerModelFailures.get(input.cacheKey);
|
|
53
87
|
if (!cached) {
|
|
88
|
+
if (recentFailure && isFailureFresh(recentFailure)) {
|
|
89
|
+
throw cloneProviderModelError(recentFailure.error);
|
|
90
|
+
}
|
|
54
91
|
return refreshProviderModels(input);
|
|
55
92
|
}
|
|
56
93
|
if (isFresh(cached, ttlMs)) {
|
|
57
94
|
return cloneProviderModels(cached.models);
|
|
58
95
|
}
|
|
96
|
+
if (providerModelInflight.has(input.cacheKey)) {
|
|
97
|
+
return cloneProviderModels(cached.models);
|
|
98
|
+
}
|
|
99
|
+
if (recentFailure && isFailureFresh(recentFailure)) {
|
|
100
|
+
return cloneProviderModels(cached.models);
|
|
101
|
+
}
|
|
59
102
|
void refreshProviderModels(input).catch((error) => {
|
|
60
103
|
input.logger.warn({
|
|
61
104
|
err: error,
|
|
@@ -67,5 +110,6 @@ export async function getCachedProviderModels(input) {
|
|
|
67
110
|
export function clearProviderModelCacheForTests() {
|
|
68
111
|
providerModelCache.clear();
|
|
69
112
|
providerModelInflight.clear();
|
|
113
|
+
providerModelFailures.clear();
|
|
70
114
|
}
|
|
71
115
|
//# sourceMappingURL=provider-model-cache.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-model-cache.js","sourceRoot":"","sources":["../../../../src/server/agent/provider-model-cache.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,2BAA2B,GAAG,KAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"provider-model-cache.js","sourceRoot":"","sources":["../../../../src/server/agent/provider-model-cache.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,2BAA2B,GAAG,KAAM,CAAC;AAClD,MAAM,CAAC,MAAM,kCAAkC,GAAG,KAAM,CAAC;AAoBzD,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAmC,CAAC;AACtE,MA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AC;QACD,OAAO,qBAAqB,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;IAED,IAAI,qBAAqB,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC9C,OAAO,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;IAED,IAAI,aAAa,IAAI,cAAc,CAAC,aAAa,CAAC,EAAE,CAAC;QACnD,OAAO,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,qBAAqB,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QAChD,KAAK,CAAC,MAAM,CAAC,IAAI,CACf;YACE,GAAG,EAAE,KAAK;YACV,QAAQ,EAAE,KAAK,CAAC,QAAQ;SACzB,EACD,oEAAoE,CACrE,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,+BAA+B;IAC7C,kBAAkB,CAAC,KAAK,EAAE,CAAC;IAC3B,qBAAqB,CAAC,KAAK,EAAE,CAAC;IAC9B,qBAAqB,CAAC,KAAK,EAAE,CAAC;AAChC,CAAC"}
|
|
@@ -683,7 +683,8 @@ type GeminiRecordedTurnSummary = {
|
|
|
683
683
|
usage: AgentUsage;
|
|
684
684
|
modelId: string | null;
|
|
685
685
|
};
|
|
686
|
-
export declare function
|
|
686
|
+
export declare function ensureGeminiAcpSupport(runtimeSettings?: ProviderRuntimeSettings): Promise<void>;
|
|
687
|
+
export declare function clearGeminiAcpSupportCacheForTests(): void;
|
|
687
688
|
export declare function normalizeGeminiMode(modeId: string | undefined): GeminiModeId;
|
|
688
689
|
export declare function getRequestedGeminiSessionState(config: {
|
|
689
690
|
modeId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gemini-agent.d.ts","sourceRoot":"","sources":["../../../../../src/server/agent/providers/gemini-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,0BAA0B,CAAC;AAQhD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EACV,oBAAoB,EACpB,WAAW,EAGX,oBAAoB,EACpB,sBAAsB,EAEtB,sBAAsB,EACtB,gBAAgB,EAIhB,YAAY,EACZ,kBAAkB,EAElB,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,0BAA0B,EAE1B,wBAAwB,EAExB,oBAAoB,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAIL,KAAK,uBAAuB,EAC7B,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"gemini-agent.d.ts","sourceRoot":"","sources":["../../../../../src/server/agent/providers/gemini-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,0BAA0B,CAAC;AAQhD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EACV,oBAAoB,EACpB,WAAW,EAGX,oBAAoB,EACpB,sBAAsB,EAEtB,sBAAsB,EACtB,gBAAgB,EAIhB,YAAY,EACZ,kBAAkB,EAElB,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,0BAA0B,EAE1B,wBAAwB,EAExB,oBAAoB,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAIL,KAAK,uBAAuB,EAC7B,MAAM,8BAA8B,CAAC;AAoBtC,QAAA,MAAM,YAAY,mDAAoD,CAAC;AAYvE,KAAK,YAAY,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;IAiBhC,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAYrC,OAAO,CAAC,YAAY;CASrB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as acp from "@agentclientprotocol/sdk";
|
|
2
|
-
import { execSync, spawn
|
|
2
|
+
import { execSync, spawn } from "node:child_process";
|
|
3
3
|
import { access, open, readdir, readFile, realpath, stat } from "node:fs/promises";
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
5
|
import path from "node:path";
|
|
@@ -7,7 +7,6 @@ import { Readable as NodeReadable, Writable as NodeWritable } from "node:stream"
|
|
|
7
7
|
import { setTimeout as delay } from "node:timers/promises";
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
import { applyProviderEnv, isProviderCommandAvailable, resolveProviderCommandPrefix, } from "../provider-launch-config.js";
|
|
10
|
-
import { getCachedProviderModels } from "../provider-model-cache.js";
|
|
11
10
|
import { ToolEditInputSchema, ToolEditOutputSchema, ToolReadInputSchema, ToolReadOutputSchema, ToolSearchInputSchema, ToolShellInputSchema, ToolShellOutputSchema, ToolWriteInputSchema, ToolWriteOutputSchema, toEditToolDetail, toReadToolDetail, toSearchToolDetail, toShellToolDetail, toWriteToolDetail, } from "./tool-call-detail-primitives.js";
|
|
12
11
|
import { coerceToolCallId, nonEmptyString } from "./tool-call-mapper-utils.js";
|
|
13
12
|
const GEMINI_PROVIDER = "gemini";
|
|
@@ -19,6 +18,8 @@ const GEMINI_RECORDED_SESSION_POLL_INTERVAL_MS = 100;
|
|
|
19
18
|
const GEMINI_RECORDED_SESSION_DISCOVERY_TIMEOUT_MS = 200;
|
|
20
19
|
const GEMINI_PLAN_TEXT_MAX_BYTES = 64 * 1024;
|
|
21
20
|
const GEMINI_PLAN_TEXT_TRUNCATION_MARKER = "\n\n[Plan truncated because the file exceeded Junction's Gemini plan preview limit.]";
|
|
21
|
+
const GEMINI_ACP_PROBE_TIMEOUT_MS = 3000;
|
|
22
|
+
const GEMINI_ACP_PROBE_CACHE_TTL_MS = 10 * 60000;
|
|
22
23
|
const GEMINI_CAPABILITIES = {
|
|
23
24
|
supportsStreaming: true,
|
|
24
25
|
supportsSessionPersistence: true,
|
|
@@ -29,6 +30,8 @@ const GEMINI_CAPABILITIES = {
|
|
|
29
30
|
};
|
|
30
31
|
const DEFAULT_GEMINI_MODE = "default";
|
|
31
32
|
const GEMINI_STRUCTURED_PERMISSION_PAYLOADS_SUPPORTED = false;
|
|
33
|
+
const geminiAcpProbeCache = new Map();
|
|
34
|
+
const geminiAcpProbeInflight = new Map();
|
|
32
35
|
export const GEMINI_MODEL_CATALOG = [
|
|
33
36
|
{
|
|
34
37
|
id: "auto-gemini-2.5",
|
|
@@ -218,21 +221,101 @@ function formatGeminiLaunchError(error) {
|
|
|
218
221
|
const message = stringifyUnknown(error);
|
|
219
222
|
return new Error(`Failed to launch Gemini ACP process: ${message}`);
|
|
220
223
|
}
|
|
221
|
-
|
|
224
|
+
function getGeminiAcpProbeCacheKey(runtimeSettings) {
|
|
225
|
+
return JSON.stringify({
|
|
226
|
+
command: runtimeSettings?.command ?? null,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
async function runGeminiAcpSupportProbe(runtimeSettings) {
|
|
222
230
|
const launchPrefix = resolveProviderCommandPrefix(runtimeSettings?.command, resolveGeminiBinary);
|
|
223
231
|
const env = applyProviderEnv(process.env, runtimeSettings);
|
|
224
|
-
const
|
|
232
|
+
const child = spawn(launchPrefix.command, [...launchPrefix.args, "--help"], {
|
|
225
233
|
env,
|
|
226
|
-
|
|
234
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
235
|
+
});
|
|
236
|
+
await new Promise((resolve, reject) => {
|
|
237
|
+
let settled = false;
|
|
238
|
+
let stdout = "";
|
|
239
|
+
let stderr = "";
|
|
240
|
+
const finish = (callback) => {
|
|
241
|
+
if (settled) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
settled = true;
|
|
245
|
+
clearTimeout(timeoutId);
|
|
246
|
+
callback();
|
|
247
|
+
};
|
|
248
|
+
const timeoutId = setTimeout(() => {
|
|
249
|
+
if (!child.killed) {
|
|
250
|
+
child.kill();
|
|
251
|
+
}
|
|
252
|
+
finish(() => {
|
|
253
|
+
reject(new Error("Gemini ACP support probe timed out while checking `gemini --help`."));
|
|
254
|
+
});
|
|
255
|
+
}, GEMINI_ACP_PROBE_TIMEOUT_MS);
|
|
256
|
+
child.once("error", (error) => {
|
|
257
|
+
finish(() => {
|
|
258
|
+
reject(formatGeminiLaunchError(error));
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
child.stdout?.on("data", (chunk) => {
|
|
262
|
+
stdout += chunk.toString();
|
|
263
|
+
});
|
|
264
|
+
child.stderr?.on("data", (chunk) => {
|
|
265
|
+
stderr += chunk.toString();
|
|
266
|
+
});
|
|
267
|
+
child.once("close", () => {
|
|
268
|
+
finish(() => {
|
|
269
|
+
const output = `${stdout}\n${stderr}`;
|
|
270
|
+
if (output.includes("--acp")) {
|
|
271
|
+
resolve();
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
reject(new Error("Installed Gemini CLI does not support --acp. Upgrade Gemini CLI to a version that includes ACP support."));
|
|
275
|
+
});
|
|
276
|
+
});
|
|
227
277
|
});
|
|
228
|
-
|
|
229
|
-
|
|
278
|
+
}
|
|
279
|
+
export async function ensureGeminiAcpSupport(runtimeSettings) {
|
|
280
|
+
const cacheKey = getGeminiAcpProbeCacheKey(runtimeSettings);
|
|
281
|
+
const cached = geminiAcpProbeCache.get(cacheKey);
|
|
282
|
+
if (cached && Date.now() - cached.checkedAt < GEMINI_ACP_PROBE_CACHE_TTL_MS) {
|
|
283
|
+
if (cached.error) {
|
|
284
|
+
throw new Error(cached.error.message);
|
|
285
|
+
}
|
|
286
|
+
return;
|
|
230
287
|
}
|
|
231
|
-
const
|
|
232
|
-
if (
|
|
288
|
+
const existingInflight = geminiAcpProbeInflight.get(cacheKey);
|
|
289
|
+
if (existingInflight) {
|
|
290
|
+
await existingInflight;
|
|
233
291
|
return;
|
|
234
292
|
}
|
|
235
|
-
|
|
293
|
+
const probePromise = (async () => {
|
|
294
|
+
try {
|
|
295
|
+
await runGeminiAcpSupportProbe(runtimeSettings);
|
|
296
|
+
geminiAcpProbeCache.set(cacheKey, {
|
|
297
|
+
checkedAt: Date.now(),
|
|
298
|
+
error: null,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
catch (error) {
|
|
302
|
+
const normalizedError = error instanceof Error ? error : new Error(stringifyUnknown(error));
|
|
303
|
+
geminiAcpProbeCache.set(cacheKey, {
|
|
304
|
+
checkedAt: Date.now(),
|
|
305
|
+
error: normalizedError,
|
|
306
|
+
});
|
|
307
|
+
throw normalizedError;
|
|
308
|
+
}
|
|
309
|
+
finally {
|
|
310
|
+
geminiAcpProbeInflight.delete(cacheKey);
|
|
311
|
+
}
|
|
312
|
+
})();
|
|
313
|
+
geminiAcpProbeInflight.set(cacheKey, probePromise);
|
|
314
|
+
await probePromise;
|
|
315
|
+
}
|
|
316
|
+
export function clearGeminiAcpSupportCacheForTests() {
|
|
317
|
+
geminiAcpProbeCache.clear();
|
|
318
|
+
geminiAcpProbeInflight.clear();
|
|
236
319
|
}
|
|
237
320
|
function stringifyUnknown(value) {
|
|
238
321
|
if (typeof value === "string") {
|
|
@@ -493,12 +576,6 @@ function toGeminiModelDefinitions() {
|
|
|
493
576
|
...("isDefault" in model && model.isDefault ? { isDefault: true } : {}),
|
|
494
577
|
}));
|
|
495
578
|
}
|
|
496
|
-
function getGeminiModelCatalogCacheKey(runtimeSettings) {
|
|
497
|
-
return JSON.stringify({
|
|
498
|
-
provider: GEMINI_PROVIDER,
|
|
499
|
-
runtimeSettings: runtimeSettings ?? null,
|
|
500
|
-
});
|
|
501
|
-
}
|
|
502
579
|
async function readGeminiSessionFile(filePath) {
|
|
503
580
|
try {
|
|
504
581
|
const raw = await readFile(filePath, "utf8");
|
|
@@ -1315,28 +1392,7 @@ export class GeminiAgentClient {
|
|
|
1315
1392
|
return session;
|
|
1316
1393
|
}
|
|
1317
1394
|
async listModels(_options) {
|
|
1318
|
-
|
|
1319
|
-
return getCachedProviderModels({
|
|
1320
|
-
cacheKey: JSON.stringify({
|
|
1321
|
-
provider: GEMINI_PROVIDER,
|
|
1322
|
-
cwd,
|
|
1323
|
-
runtime: getGeminiModelCatalogCacheKey(this.runtimeSettings),
|
|
1324
|
-
}),
|
|
1325
|
-
provider: GEMINI_PROVIDER,
|
|
1326
|
-
logger: this.logger,
|
|
1327
|
-
load: async () => {
|
|
1328
|
-
const session = new GeminiAgentSession({
|
|
1329
|
-
provider: GEMINI_PROVIDER,
|
|
1330
|
-
cwd,
|
|
1331
|
-
}, this.logger, this.runtimeSettings);
|
|
1332
|
-
try {
|
|
1333
|
-
return await session.getAvailableModelsCatalog();
|
|
1334
|
-
}
|
|
1335
|
-
finally {
|
|
1336
|
-
await session.close().catch(() => { });
|
|
1337
|
-
}
|
|
1338
|
-
},
|
|
1339
|
-
});
|
|
1395
|
+
return toGeminiModelDefinitions();
|
|
1340
1396
|
}
|
|
1341
1397
|
async listPersistedAgents(options) {
|
|
1342
1398
|
const projects = await listKnownGeminiProjects();
|
|
@@ -1351,12 +1407,7 @@ export class GeminiAgentClient {
|
|
|
1351
1407
|
}
|
|
1352
1408
|
async isAvailable() {
|
|
1353
1409
|
try {
|
|
1354
|
-
|
|
1355
|
-
if (!available) {
|
|
1356
|
-
return false;
|
|
1357
|
-
}
|
|
1358
|
-
assertGeminiAcpSupport(this.runtimeSettings);
|
|
1359
|
-
return true;
|
|
1410
|
+
return isProviderCommandAvailable(this.runtimeSettings?.command, resolveGeminiBinary, applyProviderEnv(process.env, this.runtimeSettings));
|
|
1360
1411
|
}
|
|
1361
1412
|
catch {
|
|
1362
1413
|
return false;
|
|
@@ -1415,7 +1466,7 @@ class GeminiAgentSession {
|
|
|
1415
1466
|
if (this.initialized) {
|
|
1416
1467
|
return;
|
|
1417
1468
|
}
|
|
1418
|
-
|
|
1469
|
+
await ensureGeminiAcpSupport(this.runtimeSettings);
|
|
1419
1470
|
await this.openConnection();
|
|
1420
1471
|
this.initialized = true;
|
|
1421
1472
|
}
|