@vedmalex/ai-connect 0.4.0 → 0.5.0
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/README.md +4 -9
- package/dist/browser/index.js +24 -87
- package/dist/browser/index.js.map +2 -2
- package/dist/bun/index.js +30 -388
- package/dist/bun/index.js.map +3 -3
- package/dist/bun/local.js +22 -350
- package/dist/bun/local.js.map +3 -3
- package/dist/node/index.js +30 -388
- package/dist/node/index.js.map +3 -3
- package/dist/node/local.js +22 -350
- package/dist/node/local.js.map +3 -3
- package/dist/types/acp-presets.d.ts.map +1 -1
- package/dist/types/acp.d.ts.map +1 -1
- package/dist/types/catalog.d.ts.map +1 -1
- package/dist/types/cli-presets.d.ts.map +1 -1
- package/dist/types/cli.d.ts.map +1 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/model-reference.d.ts.map +1 -1
- package/dist/types/types.d.ts +1 -1
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/bun/index.js
CHANGED
|
@@ -383,7 +383,7 @@ function normalizeTransport(providerId, input) {
|
|
|
383
383
|
};
|
|
384
384
|
}
|
|
385
385
|
if (descriptor.kind === "cli") {
|
|
386
|
-
const inferredId2 = providerId === "anthropic" ? "claude-cli" : providerId === "openclaude" ? "openclaude-cli" : providerId === "openai" ? "codex-cli" : providerId === "
|
|
386
|
+
const inferredId2 = providerId === "anthropic" ? "claude-cli" : providerId === "openclaude" ? "openclaude-cli" : providerId === "openai" ? "codex-cli" : providerId === "pi" ? "pi-cli" : "cli";
|
|
387
387
|
return {
|
|
388
388
|
kind: "cli",
|
|
389
389
|
id: descriptor.id?.trim() || inferredId2,
|
|
@@ -400,7 +400,7 @@ function normalizeTransport(providerId, input) {
|
|
|
400
400
|
...descriptor.baseUrl?.trim() ? { baseUrl: descriptor.baseUrl.trim() } : {}
|
|
401
401
|
};
|
|
402
402
|
}
|
|
403
|
-
const inferredId = providerId === "anthropic" ? "claude-code-acp" : providerId === "openai" ? "codex-acp" :
|
|
403
|
+
const inferredId = providerId === "anthropic" ? "claude-code-acp" : providerId === "openai" ? "codex-acp" : "acp";
|
|
404
404
|
const normalizedLaunch = descriptor.launch ? (() => {
|
|
405
405
|
const contextMode = descriptor.launch?.contextMode ?? "workspace";
|
|
406
406
|
const skillsMode = descriptor.launch?.skillsMode ?? "default";
|
|
@@ -1638,18 +1638,14 @@ var MODEL_REFERENCE = {
|
|
|
1638
1638
|
key: "gemini-3.1-flash-lite",
|
|
1639
1639
|
contextLength: 1048576
|
|
1640
1640
|
},
|
|
1641
|
+
"gemini-3.1-pro": { key: "gemini-3.1-pro", contextLength: 1048576 },
|
|
1641
1642
|
"gemini-3-pro": { key: "gemini-3-pro", contextLength: 2097152 },
|
|
1642
1643
|
"auto-gemini-3": { key: "auto-gemini-3", contextLength: 1048576 },
|
|
1643
1644
|
"gemini-2.5-flash": { key: "gemini-2.5-flash", contextLength: 1048576 },
|
|
1644
1645
|
"gemini-2.5-pro": { key: "gemini-2.5-pro", contextLength: 2097152 },
|
|
1645
1646
|
"gemini-2.0-flash": { key: "gemini-2.0-flash", contextLength: 1048576 },
|
|
1646
1647
|
"gemini-1.5-flash": { key: "gemini-1.5-flash", contextLength: 1048576 },
|
|
1647
|
-
"gemini-1.5-pro": { key: "gemini-1.5-pro", contextLength: 2097152 }
|
|
1648
|
-
// --- Qwen (catalog: qwen3-coder-plus) ---
|
|
1649
|
-
"qwen3-coder-plus": { key: "qwen3-coder-plus", contextLength: 1048576 },
|
|
1650
|
-
"qwen3-coder": { key: "qwen3-coder", contextLength: 262144 },
|
|
1651
|
-
"qwen-max": { key: "qwen-max", contextLength: 32768 },
|
|
1652
|
-
"qwen-plus": { key: "qwen-plus", contextLength: 131072 }
|
|
1648
|
+
"gemini-1.5-pro": { key: "gemini-1.5-pro", contextLength: 2097152 }
|
|
1653
1649
|
};
|
|
1654
1650
|
function normalizeModelKey(model) {
|
|
1655
1651
|
let key = model.trim().toLowerCase();
|
|
@@ -6343,54 +6339,26 @@ function createDefaultRouteHandlers(options = {}) {
|
|
|
6343
6339
|
var AI_CONNECT_DEFAULT_ACP_COMMANDS = {
|
|
6344
6340
|
"anthropic:claude-code-acp": "npx -y @agentclientprotocol/claude-agent-acp@^0.25.0",
|
|
6345
6341
|
"openai:codex-acp": "npx @zed-industries/codex-acp@^0.11.1",
|
|
6346
|
-
"gemini:gemini-acp": "gemini --acp",
|
|
6347
|
-
"qwen:qwen-acp": "qwen --acp",
|
|
6348
6342
|
"opencode:opencode-acp": "opencode acp"
|
|
6349
6343
|
};
|
|
6350
6344
|
|
|
6351
6345
|
// src/cli-presets.ts
|
|
6352
6346
|
var AI_CONNECT_DEFAULT_CLI_PRESETS = {
|
|
6353
|
-
|
|
6354
|
-
id: "
|
|
6355
|
-
label: "
|
|
6356
|
-
command: "
|
|
6357
|
-
transportId: "
|
|
6347
|
+
pi: {
|
|
6348
|
+
id: "pi",
|
|
6349
|
+
label: "pi (coding agent)",
|
|
6350
|
+
command: "pi",
|
|
6351
|
+
transportId: "pi-cli",
|
|
6358
6352
|
options: {
|
|
6359
|
-
preset: "
|
|
6360
|
-
|
|
6353
|
+
preset: "pi",
|
|
6354
|
+
// pi print mode emits the answer as plain text on stdout (no JSON wrapper),
|
|
6355
|
+
// and has no ACP mode — so it uses the raw `text` parser and no discovery sidecar.
|
|
6356
|
+
argsTemplate: ["--print", "--model", "{model}", "{prompt}"],
|
|
6361
6357
|
discovery: {
|
|
6362
|
-
via: "
|
|
6363
|
-
acp: {
|
|
6364
|
-
transportId: "gemini-acp"
|
|
6365
|
-
}
|
|
6358
|
+
via: "none"
|
|
6366
6359
|
},
|
|
6367
6360
|
parser: {
|
|
6368
|
-
kind: "
|
|
6369
|
-
textPath: "response",
|
|
6370
|
-
usagePath: "stats",
|
|
6371
|
-
errorPath: "error"
|
|
6372
|
-
}
|
|
6373
|
-
}
|
|
6374
|
-
},
|
|
6375
|
-
qwen: {
|
|
6376
|
-
id: "qwen",
|
|
6377
|
-
label: "Qwen CLI",
|
|
6378
|
-
command: "qwen",
|
|
6379
|
-
transportId: "qwen-cli",
|
|
6380
|
-
options: {
|
|
6381
|
-
preset: "qwen",
|
|
6382
|
-
argsTemplate: ["-p", "{prompt}", "--output-format", "json", "--model", "{model}"],
|
|
6383
|
-
discovery: {
|
|
6384
|
-
via: "acp",
|
|
6385
|
-
acp: {
|
|
6386
|
-
transportId: "qwen-acp"
|
|
6387
|
-
}
|
|
6388
|
-
},
|
|
6389
|
-
parser: {
|
|
6390
|
-
kind: "json",
|
|
6391
|
-
textPath: "__preset__:qwen.result",
|
|
6392
|
-
usagePath: "__preset__:qwen.stats",
|
|
6393
|
-
errorPath: "__preset__:qwen.error"
|
|
6361
|
+
kind: "text"
|
|
6394
6362
|
}
|
|
6395
6363
|
}
|
|
6396
6364
|
},
|
|
@@ -6474,8 +6442,7 @@ var AI_CONNECT_DEFAULT_CLI_COMMANDS = {
|
|
|
6474
6442
|
"anthropic:openclaude-cli": AI_CONNECT_DEFAULT_CLI_PRESETS.openclaude.command,
|
|
6475
6443
|
"openclaude:openclaude-cli": AI_CONNECT_DEFAULT_CLI_PRESETS.openclaude.command,
|
|
6476
6444
|
"openai:codex-cli": AI_CONNECT_DEFAULT_CLI_PRESETS.codex.command,
|
|
6477
|
-
"
|
|
6478
|
-
"qwen:qwen-cli": AI_CONNECT_DEFAULT_CLI_PRESETS.qwen.command
|
|
6445
|
+
"pi:pi-cli": AI_CONNECT_DEFAULT_CLI_PRESETS.pi.command
|
|
6479
6446
|
};
|
|
6480
6447
|
function getCliTransportPreset(presetId) {
|
|
6481
6448
|
return AI_CONNECT_DEFAULT_CLI_PRESETS[presetId];
|
|
@@ -6597,52 +6564,22 @@ var TEXT_PROVIDER_CATALOG = [
|
|
|
6597
6564
|
runtime: "universal",
|
|
6598
6565
|
defaultModel: "gemini-3.1-flash-lite",
|
|
6599
6566
|
defaultBaseUrl: ""
|
|
6600
|
-
},
|
|
6601
|
-
{
|
|
6602
|
-
providerId: "gemini",
|
|
6603
|
-
providerLabel: "Gemini",
|
|
6604
|
-
transportKind: "cli",
|
|
6605
|
-
transportId: "gemini-cli",
|
|
6606
|
-
transportLabel: "Gemini CLI",
|
|
6607
|
-
runtime: "local",
|
|
6608
|
-
defaultModel: "gemini-2.5-flash",
|
|
6609
|
-
defaultCommand: AI_CONNECT_DEFAULT_CLI_COMMANDS["gemini:gemini-cli"]
|
|
6610
|
-
},
|
|
6611
|
-
{
|
|
6612
|
-
providerId: "gemini",
|
|
6613
|
-
providerLabel: "Gemini",
|
|
6614
|
-
transportKind: "acp",
|
|
6615
|
-
transportId: "gemini-acp",
|
|
6616
|
-
transportLabel: "Gemini ACP",
|
|
6617
|
-
runtime: "local",
|
|
6618
|
-
defaultModel: "auto-gemini-3",
|
|
6619
|
-
defaultCommand: AI_CONNECT_DEFAULT_ACP_COMMANDS["gemini:gemini-acp"]
|
|
6620
6567
|
}
|
|
6621
6568
|
]
|
|
6622
6569
|
},
|
|
6623
6570
|
{
|
|
6624
|
-
providerId: "
|
|
6625
|
-
label: "
|
|
6571
|
+
providerId: "pi",
|
|
6572
|
+
label: "pi",
|
|
6626
6573
|
transports: [
|
|
6627
6574
|
{
|
|
6628
|
-
providerId: "
|
|
6629
|
-
providerLabel: "
|
|
6575
|
+
providerId: "pi",
|
|
6576
|
+
providerLabel: "pi",
|
|
6630
6577
|
transportKind: "cli",
|
|
6631
|
-
transportId: "
|
|
6632
|
-
transportLabel: "
|
|
6578
|
+
transportId: "pi-cli",
|
|
6579
|
+
transportLabel: "pi CLI",
|
|
6633
6580
|
runtime: "local",
|
|
6634
|
-
defaultModel: "
|
|
6635
|
-
defaultCommand: AI_CONNECT_DEFAULT_CLI_COMMANDS["
|
|
6636
|
-
},
|
|
6637
|
-
{
|
|
6638
|
-
providerId: "qwen",
|
|
6639
|
-
providerLabel: "Qwen",
|
|
6640
|
-
transportKind: "acp",
|
|
6641
|
-
transportId: "qwen-acp",
|
|
6642
|
-
transportLabel: "Qwen ACP",
|
|
6643
|
-
runtime: "local",
|
|
6644
|
-
defaultModel: "default",
|
|
6645
|
-
defaultCommand: AI_CONNECT_DEFAULT_ACP_COMMANDS["qwen:qwen-acp"]
|
|
6581
|
+
defaultModel: "gemini-3.1-pro-low",
|
|
6582
|
+
defaultCommand: AI_CONNECT_DEFAULT_CLI_COMMANDS["pi:pi-cli"]
|
|
6646
6583
|
}
|
|
6647
6584
|
]
|
|
6648
6585
|
},
|
|
@@ -6815,15 +6752,6 @@ function resolveHomeDir(env) {
|
|
|
6815
6752
|
function resolveXdgConfigHome(env) {
|
|
6816
6753
|
return env.XDG_CONFIG_HOME ?? path.join(resolveHomeDir(env), ".config");
|
|
6817
6754
|
}
|
|
6818
|
-
function resolveGeminiCliHome(env) {
|
|
6819
|
-
return env.GEMINI_CLI_HOME ?? resolveHomeDir(env);
|
|
6820
|
-
}
|
|
6821
|
-
function resolveGeminiDir(env) {
|
|
6822
|
-
return path.join(resolveGeminiCliHome(env), ".gemini");
|
|
6823
|
-
}
|
|
6824
|
-
function resolveQwenDir(env) {
|
|
6825
|
-
return path.join(resolveHomeDir(env), ".qwen");
|
|
6826
|
-
}
|
|
6827
6755
|
function resolveCodexHome(env) {
|
|
6828
6756
|
return env.CODEX_HOME ?? path.join(resolveHomeDir(env), ".codex");
|
|
6829
6757
|
}
|
|
@@ -6869,118 +6797,6 @@ async function removeIfExists(targetPath) {
|
|
|
6869
6797
|
}
|
|
6870
6798
|
});
|
|
6871
6799
|
}
|
|
6872
|
-
async function readJsonFile(filePath) {
|
|
6873
|
-
try {
|
|
6874
|
-
const raw = await fs.readFile(filePath, "utf8");
|
|
6875
|
-
const parsed = JSON.parse(raw);
|
|
6876
|
-
return isRecord2(parsed) ? parsed : void 0;
|
|
6877
|
-
} catch (error) {
|
|
6878
|
-
if (error instanceof SyntaxError || error.code === "ENOENT") {
|
|
6879
|
-
return void 0;
|
|
6880
|
-
}
|
|
6881
|
-
throw error;
|
|
6882
|
-
}
|
|
6883
|
-
}
|
|
6884
|
-
function mergeRecordValues(current, next) {
|
|
6885
|
-
const merged = { ...current };
|
|
6886
|
-
for (const [key, value] of Object.entries(next)) {
|
|
6887
|
-
const existing = merged[key];
|
|
6888
|
-
if (isRecord2(existing) && isRecord2(value)) {
|
|
6889
|
-
merged[key] = mergeRecordValues(existing, value);
|
|
6890
|
-
continue;
|
|
6891
|
-
}
|
|
6892
|
-
merged[key] = value;
|
|
6893
|
-
}
|
|
6894
|
-
return merged;
|
|
6895
|
-
}
|
|
6896
|
-
async function writeJsonFile(filePath, value) {
|
|
6897
|
-
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
6898
|
-
await fs.writeFile(filePath, `${JSON.stringify(value, null, 2)}
|
|
6899
|
-
`, "utf8");
|
|
6900
|
-
}
|
|
6901
|
-
async function prepareGeminiLaunchRuntime(base, launch) {
|
|
6902
|
-
if (launch.contextMode === "workspace" && launch.skillsMode === "default") {
|
|
6903
|
-
return {
|
|
6904
|
-
...base,
|
|
6905
|
-
launch
|
|
6906
|
-
};
|
|
6907
|
-
}
|
|
6908
|
-
const sandbox = await createSandboxPaths("ai-connect-gemini-acp-");
|
|
6909
|
-
const originalGeminiDir = resolveGeminiDir(base.env);
|
|
6910
|
-
const sandboxGeminiDir = path.join(sandbox.root, ".gemini");
|
|
6911
|
-
const settingsPath = path.join(sandboxGeminiDir, "settings.json");
|
|
6912
|
-
const systemSettingsPath = path.join(sandbox.config, "gemini-settings.json");
|
|
6913
|
-
const systemDefaultsPath = path.join(
|
|
6914
|
-
sandbox.config,
|
|
6915
|
-
"gemini-system-defaults.json"
|
|
6916
|
-
);
|
|
6917
|
-
const isolatedCwd = launch.contextMode === "clean" || launch.skillsMode === "disabled" ? sandbox.root : base.cwd;
|
|
6918
|
-
await Promise.all(
|
|
6919
|
-
[
|
|
6920
|
-
"oauth_creds.json",
|
|
6921
|
-
"google_accounts.json",
|
|
6922
|
-
"mcp-oauth-tokens.json",
|
|
6923
|
-
"a2a-oauth-tokens.json",
|
|
6924
|
-
"installation_id"
|
|
6925
|
-
].map(
|
|
6926
|
-
(fileName) => maybeCopyFile(
|
|
6927
|
-
path.join(originalGeminiDir, fileName),
|
|
6928
|
-
path.join(sandboxGeminiDir, fileName)
|
|
6929
|
-
)
|
|
6930
|
-
)
|
|
6931
|
-
);
|
|
6932
|
-
const settings = mergeRecordValues(
|
|
6933
|
-
await readJsonFile(settingsPath) ?? {},
|
|
6934
|
-
{
|
|
6935
|
-
context: {
|
|
6936
|
-
fileName: "AI_CONNECT_CONTEXT_DISABLED.md",
|
|
6937
|
-
includeDirectoryTree: false,
|
|
6938
|
-
memoryBoundaryMarkers: [],
|
|
6939
|
-
includeDirectories: [],
|
|
6940
|
-
loadMemoryFromIncludeDirectories: false,
|
|
6941
|
-
discoveryMaxDirs: 0
|
|
6942
|
-
},
|
|
6943
|
-
admin: {
|
|
6944
|
-
mcp: {
|
|
6945
|
-
enabled: false,
|
|
6946
|
-
config: {},
|
|
6947
|
-
requiredConfig: {}
|
|
6948
|
-
},
|
|
6949
|
-
...launch.skillsMode === "disabled" ? {
|
|
6950
|
-
skills: {
|
|
6951
|
-
enabled: false
|
|
6952
|
-
}
|
|
6953
|
-
} : {}
|
|
6954
|
-
},
|
|
6955
|
-
...launch.skillsMode === "disabled" ? {
|
|
6956
|
-
skills: {
|
|
6957
|
-
enabled: false,
|
|
6958
|
-
disabled: []
|
|
6959
|
-
}
|
|
6960
|
-
} : {}
|
|
6961
|
-
}
|
|
6962
|
-
);
|
|
6963
|
-
await Promise.all([
|
|
6964
|
-
writeJsonFile(settingsPath, settings),
|
|
6965
|
-
writeJsonFile(systemSettingsPath, {}),
|
|
6966
|
-
writeJsonFile(systemDefaultsPath, {})
|
|
6967
|
-
]);
|
|
6968
|
-
return {
|
|
6969
|
-
commandLine: base.commandLine,
|
|
6970
|
-
cwd: isolatedCwd,
|
|
6971
|
-
env: {
|
|
6972
|
-
...base.env,
|
|
6973
|
-
HOME: sandbox.root,
|
|
6974
|
-
GEMINI_CLI_HOME: sandbox.root,
|
|
6975
|
-
GEMINI_CLI_SYSTEM_SETTINGS_PATH: systemSettingsPath,
|
|
6976
|
-
GEMINI_CLI_SYSTEM_DEFAULTS_PATH: systemDefaultsPath
|
|
6977
|
-
},
|
|
6978
|
-
launch,
|
|
6979
|
-
cleanup: async () => {
|
|
6980
|
-
await removeIfExists(sandbox.root);
|
|
6981
|
-
}
|
|
6982
|
-
};
|
|
6983
|
-
}
|
|
6984
6800
|
async function prepareOpenCodeLaunchRuntime(base, launch) {
|
|
6985
6801
|
if (launch.contextMode === "workspace" && launch.skillsMode === "default") {
|
|
6986
6802
|
return {
|
|
@@ -7029,70 +6845,6 @@ async function prepareOpenCodeLaunchRuntime(base, launch) {
|
|
|
7029
6845
|
}
|
|
7030
6846
|
};
|
|
7031
6847
|
}
|
|
7032
|
-
async function prepareQwenLaunchRuntime(base, launch) {
|
|
7033
|
-
if (launch.contextMode === "workspace" && launch.skillsMode === "default") {
|
|
7034
|
-
return {
|
|
7035
|
-
...base,
|
|
7036
|
-
launch
|
|
7037
|
-
};
|
|
7038
|
-
}
|
|
7039
|
-
const sandbox = await createSandboxPaths("ai-connect-qwen-acp-");
|
|
7040
|
-
const originalQwenDir = resolveQwenDir(base.env);
|
|
7041
|
-
const sandboxQwenDir = path.join(sandbox.home, ".qwen");
|
|
7042
|
-
const settingsPath = path.join(sandboxQwenDir, "settings.json");
|
|
7043
|
-
const systemSettingsPath = path.join(sandbox.config, "qwen-settings.json");
|
|
7044
|
-
const systemDefaultsPath = path.join(
|
|
7045
|
-
sandbox.config,
|
|
7046
|
-
"qwen-system-defaults.json"
|
|
7047
|
-
);
|
|
7048
|
-
await Promise.all(
|
|
7049
|
-
[
|
|
7050
|
-
"oauth_creds.json",
|
|
7051
|
-
"mcp-oauth-tokens.json",
|
|
7052
|
-
"installation_id",
|
|
7053
|
-
".env",
|
|
7054
|
-
"settings.json"
|
|
7055
|
-
].map(
|
|
7056
|
-
(fileName) => maybeCopyFile(
|
|
7057
|
-
path.join(originalQwenDir, fileName),
|
|
7058
|
-
path.join(sandboxQwenDir, fileName)
|
|
7059
|
-
)
|
|
7060
|
-
)
|
|
7061
|
-
);
|
|
7062
|
-
const settings = mergeRecordValues(
|
|
7063
|
-
await readJsonFile(settingsPath) ?? {},
|
|
7064
|
-
{
|
|
7065
|
-
context: {
|
|
7066
|
-
fileName: ["AI_CONNECT_CONTEXT_DISABLED.md"],
|
|
7067
|
-
includeDirectories: [],
|
|
7068
|
-
loadFromIncludeDirectories: false
|
|
7069
|
-
},
|
|
7070
|
-
model: {
|
|
7071
|
-
skipStartupContext: true
|
|
7072
|
-
}
|
|
7073
|
-
}
|
|
7074
|
-
);
|
|
7075
|
-
await Promise.all([
|
|
7076
|
-
writeJsonFile(settingsPath, settings),
|
|
7077
|
-
writeJsonFile(systemSettingsPath, {}),
|
|
7078
|
-
writeJsonFile(systemDefaultsPath, {})
|
|
7079
|
-
]);
|
|
7080
|
-
const isolatedCwd = launch.contextMode === "clean" || launch.skillsMode === "disabled" ? sandbox.root : base.cwd;
|
|
7081
|
-
return {
|
|
7082
|
-
commandLine: base.commandLine,
|
|
7083
|
-
cwd: isolatedCwd,
|
|
7084
|
-
env: {
|
|
7085
|
-
...base.env,
|
|
7086
|
-
HOME: sandbox.home,
|
|
7087
|
-
QWEN_CODE_SYSTEM_SETTINGS_PATH: systemSettingsPath,
|
|
7088
|
-
QWEN_CODE_SYSTEM_DEFAULTS_PATH: systemDefaultsPath
|
|
7089
|
-
},
|
|
7090
|
-
launch,
|
|
7091
|
-
cleanup: async () => {
|
|
7092
|
-
await removeIfExists(sandbox.root);
|
|
7093
|
-
}
|
|
7094
|
-
};
|
|
7095
|
-
}
|
|
7096
6848
|
async function prepareCodexLaunchRuntime(base, launch) {
|
|
7097
6849
|
if (launch.contextMode === "workspace" && launch.skillsMode === "default") {
|
|
7098
6850
|
return {
|
|
@@ -7210,15 +6962,9 @@ async function prepareAcpLaunchRuntime(route, options, commandLine, cwdOverride)
|
|
|
7210
6962
|
...options?.env ?? {}
|
|
7211
6963
|
}
|
|
7212
6964
|
};
|
|
7213
|
-
if (route.transport.id === "gemini-acp") {
|
|
7214
|
-
return prepareGeminiLaunchRuntime(base, launch);
|
|
7215
|
-
}
|
|
7216
6965
|
if (route.transport.id === "opencode-acp") {
|
|
7217
6966
|
return prepareOpenCodeLaunchRuntime(base, launch);
|
|
7218
6967
|
}
|
|
7219
|
-
if (route.transport.id === "qwen-acp") {
|
|
7220
|
-
return prepareQwenLaunchRuntime(base, launch);
|
|
7221
|
-
}
|
|
7222
6968
|
if (route.transport.id === "codex-acp") {
|
|
7223
6969
|
return prepareCodexLaunchRuntime(base, launch);
|
|
7224
6970
|
}
|
|
@@ -7799,10 +7545,6 @@ function buildAcpLifecycle(route, authRequest, mode) {
|
|
|
7799
7545
|
steps.push("authenticate");
|
|
7800
7546
|
}
|
|
7801
7547
|
steps.push("session/new");
|
|
7802
|
-
if (mode === "prompt" && route.transport.id === "gemini-acp") {
|
|
7803
|
-
steps.push("session/set_model");
|
|
7804
|
-
keys.push("session/set_model.modelId");
|
|
7805
|
-
}
|
|
7806
7548
|
if (mode === "prompt") {
|
|
7807
7549
|
steps.push("session/prompt");
|
|
7808
7550
|
}
|
|
@@ -7938,16 +7680,6 @@ var AcpConnection = class {
|
|
|
7938
7680
|
);
|
|
7939
7681
|
}
|
|
7940
7682
|
const sessionId = session.sessionId;
|
|
7941
|
-
if (context.route.transport.id === "gemini-acp") {
|
|
7942
|
-
await measurePhase(
|
|
7943
|
-
transport.phases ?? [],
|
|
7944
|
-
"session/set_model",
|
|
7945
|
-
async () => this.request("session/set_model", {
|
|
7946
|
-
sessionId,
|
|
7947
|
-
modelId: context.route.model
|
|
7948
|
-
})
|
|
7949
|
-
);
|
|
7950
|
-
}
|
|
7951
7683
|
this.activePrompt = {
|
|
7952
7684
|
sessionId,
|
|
7953
7685
|
text: "",
|
|
@@ -8460,9 +8192,6 @@ var AcpConnection = class {
|
|
|
8460
8192
|
});
|
|
8461
8193
|
}
|
|
8462
8194
|
};
|
|
8463
|
-
function isGeminiAcpFallbackCandidate(route, commandLine) {
|
|
8464
|
-
return route.transport.id === "gemini-acp" && commandLine.includes("--acp") && !commandLine.includes("--experimental-acp");
|
|
8465
|
-
}
|
|
8466
8195
|
function cacheKeyForConnection(route, runtime, options) {
|
|
8467
8196
|
const envEntries = Object.entries(options.env).sort(([left], [right]) => left.localeCompare(right)).map(([key, value]) => `${key}=${value}`).join("");
|
|
8468
8197
|
return [
|
|
@@ -8709,18 +8438,7 @@ function createAcpTransportManager(options) {
|
|
|
8709
8438
|
}
|
|
8710
8439
|
async function drivePrompt(context, onDelta) {
|
|
8711
8440
|
const commandLine = resolveAcpCommand(context.route, options);
|
|
8712
|
-
|
|
8713
|
-
return await runWithCommand(context, commandLine, onDelta);
|
|
8714
|
-
} catch (error) {
|
|
8715
|
-
if (!isGeminiAcpFallbackCandidate(context.route, commandLine)) {
|
|
8716
|
-
throw error;
|
|
8717
|
-
}
|
|
8718
|
-
return await runWithCommand(
|
|
8719
|
-
context,
|
|
8720
|
-
commandLine.replace("--acp", "--experimental-acp"),
|
|
8721
|
-
onDelta
|
|
8722
|
-
);
|
|
8723
|
-
}
|
|
8441
|
+
return await runWithCommand(context, commandLine, onDelta);
|
|
8724
8442
|
}
|
|
8725
8443
|
return {
|
|
8726
8444
|
async runPrompt(context) {
|
|
@@ -8789,17 +8507,7 @@ function createAcpTransportManager(options) {
|
|
|
8789
8507
|
},
|
|
8790
8508
|
async discoverModels(context) {
|
|
8791
8509
|
const commandLine = resolveAcpCommand(context.route, options);
|
|
8792
|
-
|
|
8793
|
-
return await discoverWithCommand(context, commandLine);
|
|
8794
|
-
} catch (error) {
|
|
8795
|
-
if (!isGeminiAcpFallbackCandidate(context.route, commandLine)) {
|
|
8796
|
-
throw error;
|
|
8797
|
-
}
|
|
8798
|
-
return await discoverWithCommand(
|
|
8799
|
-
context,
|
|
8800
|
-
commandLine.replace("--acp", "--experimental-acp")
|
|
8801
|
-
);
|
|
8802
|
-
}
|
|
8510
|
+
return await discoverWithCommand(context, commandLine);
|
|
8803
8511
|
},
|
|
8804
8512
|
async dispose() {
|
|
8805
8513
|
const values = [...connectionPools.values()].flat();
|
|
@@ -8824,14 +8532,6 @@ import fs2 from "node:fs/promises";
|
|
|
8824
8532
|
import os2 from "node:os";
|
|
8825
8533
|
import path2 from "node:path";
|
|
8826
8534
|
var CLI_PRESET_ACP_DISCOVERY_DEFAULTS = {
|
|
8827
|
-
gemini: {
|
|
8828
|
-
transportId: "gemini-acp",
|
|
8829
|
-
providerId: "gemini"
|
|
8830
|
-
},
|
|
8831
|
-
qwen: {
|
|
8832
|
-
transportId: "qwen-acp",
|
|
8833
|
-
providerId: "qwen"
|
|
8834
|
-
},
|
|
8835
8535
|
claude: {
|
|
8836
8536
|
transportId: "claude-code-acp",
|
|
8837
8537
|
providerId: "anthropic"
|
|
@@ -8938,10 +8638,8 @@ function buildCliCwd(context, options) {
|
|
|
8938
8638
|
}
|
|
8939
8639
|
function defaultCliPresetIdForRoute(route) {
|
|
8940
8640
|
switch (route.transport.id) {
|
|
8941
|
-
case "
|
|
8942
|
-
return "
|
|
8943
|
-
case "qwen-cli":
|
|
8944
|
-
return "qwen";
|
|
8641
|
+
case "pi-cli":
|
|
8642
|
+
return "pi";
|
|
8945
8643
|
case "claude-cli":
|
|
8946
8644
|
return "claude";
|
|
8947
8645
|
case "openclaude-cli":
|
|
@@ -9320,60 +9018,6 @@ function parseCliModelList(stdout, parser, selector) {
|
|
|
9320
9018
|
}
|
|
9321
9019
|
return models;
|
|
9322
9020
|
}
|
|
9323
|
-
function parseGeminiCli(stdout) {
|
|
9324
|
-
const payload = JSON.parse(stdout);
|
|
9325
|
-
if (typeof payload.error === "string") {
|
|
9326
|
-
throw new AiConnectError("temporary_unavailable", payload.error);
|
|
9327
|
-
}
|
|
9328
|
-
if (typeof payload.response !== "string") {
|
|
9329
|
-
throw new AiConnectError(
|
|
9330
|
-
"temporary_unavailable",
|
|
9331
|
-
"Gemini CLI JSON output did not include response text."
|
|
9332
|
-
);
|
|
9333
|
-
}
|
|
9334
|
-
const usage = payload.stats ? statsToUsage(payload.stats) : void 0;
|
|
9335
|
-
return {
|
|
9336
|
-
text: payload.response,
|
|
9337
|
-
...usage ? { usage } : {},
|
|
9338
|
-
data: payload
|
|
9339
|
-
};
|
|
9340
|
-
}
|
|
9341
|
-
function parseQwenCli(stdout) {
|
|
9342
|
-
const payload = JSON.parse(stdout);
|
|
9343
|
-
if (!Array.isArray(payload)) {
|
|
9344
|
-
throw new AiConnectError(
|
|
9345
|
-
"temporary_unavailable",
|
|
9346
|
-
"Qwen CLI JSON output did not return a message array."
|
|
9347
|
-
);
|
|
9348
|
-
}
|
|
9349
|
-
const resultMessage = payload.find(
|
|
9350
|
-
(entry) => entry && typeof entry === "object" && entry.type === "result"
|
|
9351
|
-
);
|
|
9352
|
-
if (!resultMessage) {
|
|
9353
|
-
throw new AiConnectError(
|
|
9354
|
-
"temporary_unavailable",
|
|
9355
|
-
"Qwen CLI JSON output did not contain a result message."
|
|
9356
|
-
);
|
|
9357
|
-
}
|
|
9358
|
-
if (resultMessage.is_error === true) {
|
|
9359
|
-
throw new AiConnectError(
|
|
9360
|
-
"temporary_unavailable",
|
|
9361
|
-
typeof resultMessage.result === "string" ? resultMessage.result : "Qwen CLI returned an error result."
|
|
9362
|
-
);
|
|
9363
|
-
}
|
|
9364
|
-
if (typeof resultMessage.result !== "string") {
|
|
9365
|
-
throw new AiConnectError(
|
|
9366
|
-
"temporary_unavailable",
|
|
9367
|
-
"Qwen CLI result message did not contain text output."
|
|
9368
|
-
);
|
|
9369
|
-
}
|
|
9370
|
-
const usage = resultMessage.stats ? statsToUsage(resultMessage.stats) : void 0;
|
|
9371
|
-
return {
|
|
9372
|
-
text: resultMessage.result,
|
|
9373
|
-
...usage ? { usage } : {},
|
|
9374
|
-
data: payload
|
|
9375
|
-
};
|
|
9376
|
-
}
|
|
9377
9021
|
function parseClaudeCli(stdout) {
|
|
9378
9022
|
const payload = JSON.parse(stdout);
|
|
9379
9023
|
const text = typeof payload.result === "string" ? payload.result : typeof payload.response === "string" ? payload.response : typeof payload.text === "string" ? payload.text : void 0;
|
|
@@ -9459,10 +9103,8 @@ function parseCliResult(route, result, outputFileContent) {
|
|
|
9459
9103
|
}
|
|
9460
9104
|
}
|
|
9461
9105
|
switch (cliOptions.preset) {
|
|
9462
|
-
case "
|
|
9463
|
-
return
|
|
9464
|
-
case "qwen":
|
|
9465
|
-
return parseQwenCli(stdout);
|
|
9106
|
+
case "pi":
|
|
9107
|
+
return parseTextCli(stdout, { kind: "text" });
|
|
9466
9108
|
case "claude":
|
|
9467
9109
|
case "openclaude":
|
|
9468
9110
|
return parseClaudeCli(stdout);
|