@anhlp/alp-client 0.0.1-beta.7 → 0.0.1-beta.8
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/acp-probe.d.ts +3 -2
- package/dist/acp-probe.js +11 -2
- package/dist/antigravity-probe.d.ts +1 -1
- package/dist/doctor.d.ts +8 -1
- package/dist/doctor.js +179 -10
- package/dist/index.d.ts +16 -3
- package/dist/index.js +69 -16
- package/dist/render.js +3 -0
- package/dist/setup.d.ts +7 -1
- package/dist/setup.js +154 -29
- package/dist/supervise.js +2 -2
- package/package.json +3 -3
- package/src/acp-probe.js +10 -3
- package/src/antigravity-probe.js +1 -1
- package/src/doctor.d.ts +8 -1
- package/src/doctor.js +245 -9
- package/src/index.js +83 -21
- package/src/render.js +3 -0
- package/src/setup.js +194 -31
- package/src/supervise.js +4 -3
package/dist/setup.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// packages/client/src/setup.js
|
|
2
|
-
import { copyFile, readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { copyFile, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { parseArgs } from "node:util";
|
|
5
5
|
import { initProject } from "@anhlp/alp-core/init";
|
|
6
|
-
import { catalogModels } from "@anhlp/alp-core/models";
|
|
7
|
-
import { fitEffort, modelEfforts } from "@anhlp/alp-core/profiles";
|
|
8
|
-
import { resolveTeam } from "@anhlp/alp-core/teams";
|
|
6
|
+
import { catalogModels, useLiveModels } from "@anhlp/alp-core/models";
|
|
7
|
+
import { fitEffort, modelEfforts, profileDefaults, profileFingerprint, projectProfiles } from "@anhlp/alp-core/profiles";
|
|
8
|
+
import { BUILTIN_TEAMS, resolveTeam, teamSources } from "@anhlp/alp-core/teams";
|
|
9
9
|
import { validateSettings } from "@anhlp/alp-core/validation";
|
|
10
10
|
import { Cancelled, select, text } from "./prompt.js";
|
|
11
11
|
var PROVIDERS = ["claude", "codex"];
|
|
@@ -20,6 +20,7 @@ var FLAGS = { main: "model", worker: "model", supervisor: "supervisor", oracle:
|
|
|
20
20
|
var SEAT_LABEL = { main: "main", worker: "lead, reviewer", supervisor: "supervisor", oracle: "oracle" };
|
|
21
21
|
var ANY_EFFORT = ["low", "medium", "high", "xhigh", "max"];
|
|
22
22
|
async function setup(args, home) {
|
|
23
|
+
useLiveModels(catalogModels(home));
|
|
23
24
|
const { values, positionals } = parseArgs({ args, allowPositionals: true, options: Object.fromEntries(
|
|
24
25
|
["runtime", "prefer", ...PROVIDERS.flatMap((provider) => Object.values(FLAGS).map((flag) => `${provider}-${flag}`))].map((name) => [name, { type: "string" }])
|
|
25
26
|
) });
|
|
@@ -45,16 +46,8 @@ async function setup(args, home) {
|
|
|
45
46
|
if (!enabled.includes(provider) && values[`${provider}-${flag}`]) throw new Error(`--${provider}-${flag} is unavailable in ${runtime}-only mode`);
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
|
-
const seats =
|
|
49
|
-
|
|
50
|
-
seats[seat] = (seat === "main" ? [prefer] : enabled).map((provider) => {
|
|
51
|
-
const option = `${provider}-${flag}`;
|
|
52
|
-
const [fallback, effort] = DEFAULTS[seat][provider];
|
|
53
|
-
const model = nativeModel(values[option] ?? fallback, provider, `--${option}`);
|
|
54
|
-
return { provider, model, effort: fitEffort(`${provider}:${model}`, effort) };
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
const peers = enabled.map((provider) => `${provider}:*`);
|
|
49
|
+
const seats = seatsFor(enabled, prefer, values);
|
|
50
|
+
const peers = peersFor(enabled);
|
|
58
51
|
const file = path.join(root, ".alp/settings.json");
|
|
59
52
|
const settings = await readFile(file, "utf8").then((content) => {
|
|
60
53
|
try {
|
|
@@ -70,10 +63,14 @@ async function setup(args, home) {
|
|
|
70
63
|
for (const [seat, choices] of Object.entries(seats)) console.log(` ${SEAT_LABEL[seat]}: ${choices.map(describe).join(", ")}`);
|
|
71
64
|
console.log(` peer: ${peers.join(", ")} (any model: whoever assigns a peer picks its model and effort for the task)`);
|
|
72
65
|
};
|
|
66
|
+
if (settings) validateSettings(settings, file);
|
|
73
67
|
console.log(`Profiles for Ph\u1EDF and Cafe in ${file}:`);
|
|
74
68
|
show();
|
|
75
|
-
const
|
|
76
|
-
|
|
69
|
+
const owners = await ownership(root, home, settings);
|
|
70
|
+
const replaced = BUILTIN_TEAMS.filter((id) => Object.keys(currentTeams(settings)?.[id] ?? {}).some((name) => owners.rewrites(id, name)));
|
|
71
|
+
if (replaced.length) console.log(`These replace the ${replaced.join(" and ")} profiles ALP or an earlier alp setup wrote; saving backs the file up to ${file}.bak first.`);
|
|
72
|
+
for (const line of owners.kept) console.log(line);
|
|
73
|
+
for (const line of owners.others) console.log(line);
|
|
77
74
|
if (interactive) {
|
|
78
75
|
for (; ; ) {
|
|
79
76
|
const next2 = await select({ message: "Save these profiles?", initial: "save", choices: [
|
|
@@ -87,14 +84,14 @@ async function setup(args, home) {
|
|
|
87
84
|
show();
|
|
88
85
|
}
|
|
89
86
|
}
|
|
90
|
-
|
|
91
|
-
validateSettings({ ...settings ?? {}, team: { ...settings?.profile ?? {}, ...settings?.team ?? {}, ...profile } }, file);
|
|
87
|
+
validateSettings(merge(settings ?? {}, await profiles(root, home, seats, peers, settings), owners).next, file);
|
|
92
88
|
if (!settings) await initProject(root, { library: home });
|
|
93
89
|
else if (replaced.length) await copyFile(file, `${file}.bak`);
|
|
94
90
|
const written = settings ?? JSON.parse(await readFile(file, "utf8"));
|
|
95
|
-
const next =
|
|
96
|
-
|
|
91
|
+
const { next, record } = merge(written, await profiles(root, home, seats, peers, written), owners);
|
|
92
|
+
validateSettings(next, file);
|
|
97
93
|
await writeFile(file, JSON.stringify(next, null, 2) + "\n");
|
|
94
|
+
await writeRecord(root, record, owners.newer);
|
|
98
95
|
console.log("Setup saved. New sessions in this project use these profiles; edit the file to change one agent. Run alp doctor to check that each CLI is installed and logged in.");
|
|
99
96
|
} catch (error) {
|
|
100
97
|
if (!(error instanceof Cancelled)) throw error;
|
|
@@ -120,24 +117,152 @@ async function change(seats, home) {
|
|
|
120
117
|
}) : efforts[0];
|
|
121
118
|
seats[seat][at] = { provider: current.provider, model, ...effort ? { effort } : {} };
|
|
122
119
|
}
|
|
120
|
+
function seatsFor(enabled, prefer, values = {}) {
|
|
121
|
+
const seats = {};
|
|
122
|
+
for (const [seat, flag] of Object.entries(FLAGS)) {
|
|
123
|
+
seats[seat] = (seat === "main" ? [prefer] : enabled).map((provider) => {
|
|
124
|
+
const option = `${provider}-${flag}`;
|
|
125
|
+
const [fallback, effort] = DEFAULTS[seat][provider];
|
|
126
|
+
const model = nativeModel(values[option] ?? fallback, provider, `--${option}`);
|
|
127
|
+
return { provider, model, effort: fitEffort(`${provider}:${model}`, effort) };
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return seats;
|
|
131
|
+
}
|
|
132
|
+
var sameEntries = (a, b) => JSON.stringify(Object.entries(a ?? {}).sort()) === JSON.stringify(Object.entries(b ?? {}).sort());
|
|
133
|
+
var peersFor = (enabled) => enabled.map((provider) => `${provider}:*`);
|
|
134
|
+
var currentTeams = (settings) => settings && { ...settings.profile ?? {}, ...settings.team ?? {} };
|
|
135
|
+
function teamProfiles(team, seats, peers) {
|
|
136
|
+
const strings = (choices) => choices.map((choice) => typeof choice === "string" ? choice : describe(choice));
|
|
137
|
+
const agents = {};
|
|
138
|
+
for (const [name, member] of Object.entries(team.members)) {
|
|
139
|
+
if (name !== "oracle") agents[name] = strings(name === team.main ? seats.main : member.role === "peer" ? peers : seats.worker);
|
|
140
|
+
}
|
|
141
|
+
if (team.supervisor) agents[team.supervisor.agent] = strings(seats.supervisor);
|
|
142
|
+
if (team.members.oracle) agents.oracle = strings(seats.oracle);
|
|
143
|
+
return agents;
|
|
144
|
+
}
|
|
123
145
|
async function profiles(root, home, seats, peers, settings) {
|
|
124
146
|
const profile = {};
|
|
125
|
-
for (const id of
|
|
147
|
+
for (const id of BUILTIN_TEAMS) {
|
|
126
148
|
const team = await resolveTeam(root, id, { library: home });
|
|
127
149
|
const agents = {};
|
|
128
|
-
const
|
|
129
|
-
const old = (settings
|
|
130
|
-
agents[name] = { profiles:
|
|
131
|
-
};
|
|
132
|
-
for (const [name, member] of Object.entries(team.members)) {
|
|
133
|
-
if (name !== "oracle") seat(name, name === team.main ? seats.main : member.role === "peer" ? peers : seats.worker);
|
|
150
|
+
for (const [name, list] of Object.entries(teamProfiles(team, seats, peers))) {
|
|
151
|
+
const old = currentTeams(settings)?.[id]?.[name];
|
|
152
|
+
agents[name] = { profiles: list, autocompact: old?.autocompact ?? "auto", ...old?.commands ? { commands: old.commands } : {} };
|
|
134
153
|
}
|
|
135
|
-
if (team.supervisor) seat(team.supervisor.agent, seats.supervisor);
|
|
136
|
-
if (team.members.oracle) seat("oracle", seats.oracle);
|
|
137
154
|
profile[id] = agents;
|
|
138
155
|
}
|
|
139
156
|
return profile;
|
|
140
157
|
}
|
|
158
|
+
var RECORD_VERSION = 1;
|
|
159
|
+
var recordFile = (root) => path.join(root, ".alp", "state", "setup-profiles.json");
|
|
160
|
+
async function readRecord(root) {
|
|
161
|
+
let value;
|
|
162
|
+
try {
|
|
163
|
+
value = JSON.parse(await readFile(recordFile(root), "utf8"));
|
|
164
|
+
} catch {
|
|
165
|
+
return { teams: {}, newer: false };
|
|
166
|
+
}
|
|
167
|
+
if (Number.isSafeInteger(value?.version) && value.version > RECORD_VERSION) return { teams: {}, newer: true };
|
|
168
|
+
const teams = value?.version === RECORD_VERSION && value.teams && typeof value.teams === "object" && !Array.isArray(value.teams) ? value.teams : {};
|
|
169
|
+
return { newer: false, teams: Object.fromEntries(Object.entries(teams).filter(([, agents]) => agents && typeof agents === "object" && !Array.isArray(agents)).map(([id, agents]) => [id, Object.fromEntries(Object.entries(agents).filter(([, hash]) => typeof hash === "string" && /^[a-f0-9]{64}$/.test(hash)))])) };
|
|
170
|
+
}
|
|
171
|
+
async function writeRecord(root, teams, newer) {
|
|
172
|
+
if (newer) return;
|
|
173
|
+
const directory = path.dirname(recordFile(root));
|
|
174
|
+
try {
|
|
175
|
+
await mkdir(directory, { recursive: true });
|
|
176
|
+
await writeFile(path.join(directory, ".gitignore"), "*\n", { flag: "wx" }).catch((error) => {
|
|
177
|
+
if (error.code !== "EEXIST") throw error;
|
|
178
|
+
});
|
|
179
|
+
await writeFile(recordFile(root), JSON.stringify({ version: RECORD_VERSION, teams }, null, 2) + "\n");
|
|
180
|
+
} catch (error) {
|
|
181
|
+
console.log(`Could not save ${recordFile(root)} (${error.message}); the next alp setup recognizes these profiles by setup's defaults instead.`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
async function ownership(root, home, existing) {
|
|
185
|
+
const { teams: record, newer } = await readRecord(root);
|
|
186
|
+
const initial = existing ? void 0 : await projectProfiles({ root, library: home });
|
|
187
|
+
const settings = existing ?? { team: initial, templateDefaults: profileDefaults(initial) };
|
|
188
|
+
const teams = currentTeams(settings) ?? {};
|
|
189
|
+
const file = path.join(root, ".alp/settings.json");
|
|
190
|
+
const legacy = {};
|
|
191
|
+
const pinned = {};
|
|
192
|
+
for (const id of BUILTIN_TEAMS) {
|
|
193
|
+
const team = await resolveTeam(root, id, { library: home });
|
|
194
|
+
const builtin = await resolveTeam(void 0, id, { library: "" });
|
|
195
|
+
legacy[id] = {};
|
|
196
|
+
for (const runtime of [...PROVIDERS, "mix"]) {
|
|
197
|
+
for (const prefer of runtime === "mix" ? PROVIDERS : [runtime]) {
|
|
198
|
+
const enabled = runtime === "mix" ? [prefer, ...PROVIDERS.filter((provider) => provider !== prefer)] : [runtime];
|
|
199
|
+
for (const [name, list] of Object.entries(teamProfiles(team, seatsFor(enabled, prefer), peersFor(enabled)))) {
|
|
200
|
+
(legacy[id][name] ??= []).push(profileFingerprint({ profiles: list }, name));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
pinned[id] = {};
|
|
205
|
+
if (team.source !== "builtin") {
|
|
206
|
+
const choice = (own, base) => {
|
|
207
|
+
const parts = [own?.model && own.model !== base?.model ? own.model : void 0, own?.thinking && own.thinking !== base?.thinking ? `effort ${own.thinking}` : void 0].filter(Boolean);
|
|
208
|
+
return parts.length ? parts.join(", ") : void 0;
|
|
209
|
+
};
|
|
210
|
+
for (const [name, member] of Object.entries(team.members)) {
|
|
211
|
+
const set = name === "oracle" ? void 0 : choice(member, builtin.members[name]);
|
|
212
|
+
if (set) pinned[id][name] = set;
|
|
213
|
+
}
|
|
214
|
+
if (team.supervisor) {
|
|
215
|
+
const set = choice(team.supervisor, builtin.supervisor && builtin.supervisor.agent === team.supervisor.agent ? builtin.supervisor : void 0);
|
|
216
|
+
if (set) pinned[id][team.supervisor.agent] = set;
|
|
217
|
+
}
|
|
218
|
+
if (team.members.oracle && (team.oracleModels && JSON.stringify(team.oracleModels) !== JSON.stringify(builtin.oracleModels) || team.oracleThinking && sameEntries(team.oracleThinking, builtin.oracleThinking) === false)) {
|
|
219
|
+
pinned[id].oracle = [team.oracleModels?.join(", "), team.oracleThinking ? `efforts ${Object.entries(team.oracleThinking).map(([lens, effort]) => `${lens} ${effort}`).join(", ")}` : void 0].filter(Boolean).join("; ");
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
const rewrites = (id, name) => {
|
|
224
|
+
const config = teams[id]?.[name];
|
|
225
|
+
if (!config) return true;
|
|
226
|
+
const fingerprint = profileFingerprint(config, name);
|
|
227
|
+
if (record[id]?.[name] === fingerprint || legacy[id]?.[name]?.includes(fingerprint)) return true;
|
|
228
|
+
return settings?.templateDefaults?.[id]?.[name] === fingerprint && !pinned[id]?.[name];
|
|
229
|
+
};
|
|
230
|
+
const kept = [];
|
|
231
|
+
for (const id of BUILTIN_TEAMS) {
|
|
232
|
+
for (const [name, config] of Object.entries(teams[id] ?? {})) {
|
|
233
|
+
if (rewrites(id, name)) continue;
|
|
234
|
+
const list = (config.profiles ?? []).map((profile) => typeof profile === "string" ? profile : describe(profile)).join(", ");
|
|
235
|
+
kept.push(pinned[id]?.[name] && settings?.templateDefaults?.[id]?.[name] === profileFingerprint(config, name) ? `Kept team.${id}.${name}.profiles (${list}): the ${id} team's team.json sets it (${pinned[id][name]}). Delete the entry from the file and run alp setup again to replace it.` : record[id]?.[name] ? `Kept team.${id}.${name}.profiles (${list}): changed since alp setup wrote it, so it is kept as yours. Delete the entry from the file and run alp setup again to replace it.` : `Kept team.${id}.${name}.profiles (${list}): ALP cannot tell whether an earlier alp setup or you wrote it (it is none of setup's defaults, and no setup record names it), so it is kept as yours. Delete the entry from the file and run alp setup again to replace it.`);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
const others = [];
|
|
239
|
+
for (const [id, found] of await teamSources(root, { library: home })) {
|
|
240
|
+
if (BUILTIN_TEAMS.includes(id)) continue;
|
|
241
|
+
const team = await resolveTeam(root, id, { library: home }).catch(() => void 0);
|
|
242
|
+
const agents = team ? [...Object.keys(team.members).filter((name) => name !== "oracle"), ...team.supervisor ? [team.supervisor.agent] : [], ...team.members.oracle ? ["oracle"] : []] : [];
|
|
243
|
+
others.push(`Team ${id} (${found.source}) is not Ph\u1EDF or Cafe, so alp setup leaves its profiles as they are: its team.json chooses its models. To change them, edit team.${id}.<agent>.profiles in ${file}${agents.length ? ` (agents: ${agents.join(", ")})` : ""}.`);
|
|
244
|
+
}
|
|
245
|
+
return { rewrites, kept, others, record, newer };
|
|
246
|
+
}
|
|
247
|
+
function merge(written, profile, owners) {
|
|
248
|
+
const next = { ...written, team: currentTeams(written) };
|
|
249
|
+
delete next.profile;
|
|
250
|
+
const record = structuredClone(owners.record);
|
|
251
|
+
for (const [id, agents] of Object.entries(profile)) {
|
|
252
|
+
const team = { ...next.team[id] ?? {} };
|
|
253
|
+
for (const [name, config] of Object.entries(agents)) {
|
|
254
|
+
if (!owners.rewrites(id, name)) {
|
|
255
|
+
if (record[id]) delete record[id][name];
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
team[name] = config;
|
|
259
|
+
(record[id] ??= {})[name] = profileFingerprint(config, name);
|
|
260
|
+
}
|
|
261
|
+
next.team[id] = team;
|
|
262
|
+
if (record[id] && !Object.keys(record[id]).length) delete record[id];
|
|
263
|
+
}
|
|
264
|
+
return { next, record };
|
|
265
|
+
}
|
|
141
266
|
function nativeModel(id, provider, where) {
|
|
142
267
|
const model = id.startsWith(`${provider}:`) ? id.slice(provider.length + 1) : id;
|
|
143
268
|
if (!model || /\s/.test(model) || /^(codex|claude):/.test(model) || model.includes(":") && !id.startsWith(`${provider}:`)) throw new Error(`${where} expects a ${provider} model, got '${id}'`);
|
package/dist/supervise.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// packages/client/src/supervise.js
|
|
2
2
|
import { mkdir, unlink, writeFile, stat } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { ensureDaemon, lockAlive, readLock, withDaemonLifecycle } from "./index.js";
|
|
4
|
+
import { daemonStartTimeoutMs, ensureDaemon, lockAlive, readLock, withDaemonLifecycle } from "./index.js";
|
|
5
5
|
import { installedProgram, serviceFor, startService } from "./service.js";
|
|
6
6
|
var holdFile = (home) => path.join(home, "state", "alpd.held");
|
|
7
7
|
async function holdDaemon(home, by = "alp daemon stop") {
|
|
@@ -25,7 +25,7 @@ async function whenReady(home, timeoutMs, signal) {
|
|
|
25
25
|
}
|
|
26
26
|
throw new Error(`alpd did not become ready within ${timeoutMs / 1e3} s; see ${path.join(home, "logs")}`);
|
|
27
27
|
}
|
|
28
|
-
async function startDaemon({ home, entry, env = process.env, timeoutMs =
|
|
28
|
+
async function startDaemon({ home, entry, env = process.env, timeoutMs = daemonStartTimeoutMs(env), automatic = false, signal }) {
|
|
29
29
|
return withDaemonLifecycle(home, "start", async () => {
|
|
30
30
|
signal?.throwIfAborted();
|
|
31
31
|
if (automatic) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anhlp/alp-client",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "ALP client: portable JSON-RPC SDK, WebSocket and Node IPC transports, daemon discovery and setup",
|
|
6
6
|
"files": [
|
|
@@ -150,8 +150,8 @@
|
|
|
150
150
|
"node": ">=22.12"
|
|
151
151
|
},
|
|
152
152
|
"dependencies": {
|
|
153
|
-
"@anhlp/alp-core": "0.0.1-beta.
|
|
154
|
-
"@anhlp/alp-protocol": "0.0.1-beta.
|
|
153
|
+
"@anhlp/alp-core": "0.0.1-beta.8",
|
|
154
|
+
"@anhlp/alp-protocol": "0.0.1-beta.8"
|
|
155
155
|
},
|
|
156
156
|
"scripts": {
|
|
157
157
|
"build": "node ../../scripts/build-workspace.mjs client",
|
package/src/acp-probe.js
CHANGED
|
@@ -7,12 +7,17 @@ import { stdioSession } from './mcp-probe.js';
|
|
|
7
7
|
* it also opens a session in `cwd`, as Paseo does, to read the models and modes the agent
|
|
8
8
|
* offers (ALPD §65); an agent that offers none leaves them out.
|
|
9
9
|
* @param {{ command: string, args?: string[], env?: Record<string, string>, label?: string, id?: string }} provider
|
|
10
|
-
* @param {{ cwd?: string, timeoutMs?: number, discover?: boolean }} [options]
|
|
10
|
+
* @param {{ cwd?: string, timeoutMs?: number, discover?: boolean, signal?: AbortSignal }} [options]
|
|
11
11
|
* @returns {Promise<{ protocolVersion: number, agent?: { name?: string, title?: string, version?: string }, loadSession: boolean, mcpHttp: boolean, authMethods: string[],
|
|
12
12
|
* models?: Array<{ id: string, label: string, description?: string }>, currentModel?: string, modes?: Array<{ id: string, label: string, description?: string }>, currentMode?: string }>}
|
|
13
13
|
*/
|
|
14
|
-
export async function probeAcp(provider, { cwd, timeoutMs = 20_000, discover = false } = {}) {
|
|
14
|
+
export async function probeAcp(provider, { cwd, timeoutMs = 20_000, discover = false, signal } = {}) {
|
|
15
|
+
signal?.throwIfAborted();
|
|
15
16
|
const session = stdioSession({ command: provider.command, args: provider.args ?? [], env: provider.env ?? {} }, cwd, timeoutMs);
|
|
17
|
+
let closing;
|
|
18
|
+
const abort = () => { closing ??= session.close(); };
|
|
19
|
+
signal?.addEventListener('abort', abort, { once: true });
|
|
20
|
+
if (signal?.aborted) abort();
|
|
16
21
|
try {
|
|
17
22
|
const result = await session.request('initialize', {
|
|
18
23
|
protocolVersion: 1,
|
|
@@ -41,6 +46,8 @@ export async function probeAcp(provider, { cwd, timeoutMs = 20_000, discover = f
|
|
|
41
46
|
authMethods: (result.authMethods ?? []).map(method => method?.name ?? method?.id).filter(Boolean),
|
|
42
47
|
};
|
|
43
48
|
} finally {
|
|
44
|
-
|
|
49
|
+
signal?.removeEventListener('abort', abort);
|
|
50
|
+
await (closing ?? session.close());
|
|
51
|
+
signal?.throwIfAborted();
|
|
45
52
|
}
|
|
46
53
|
}
|
package/src/antigravity-probe.js
CHANGED
|
@@ -64,7 +64,7 @@ function runCommand(command, args, { env = process.env, cwd, timeoutMs = 20_000
|
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* Probes Antigravity CLI for version, status and available models.
|
|
67
|
-
* @param {{ command?: string, args?: string[], env?: Record<string, string>, label?: string, id?: string}} [provider]
|
|
67
|
+
* @param {{ command?: string, args?: string[], env?: Record<string, string>, label?: string, id?: string}} [provider]
|
|
68
68
|
* @param {{ cwd?: string, timeoutMs?: number }} [options]
|
|
69
69
|
*/
|
|
70
70
|
export async function probeAntigravity(provider = {}, { cwd, timeoutMs = 20_000 } = {}) {
|
package/src/doctor.d.ts
CHANGED
|
@@ -10,5 +10,12 @@ export type CommandResult = { code: number; stdout: string; stderr: string };
|
|
|
10
10
|
export type CommandRunner = (command: string, args: string[], options?: { cwd?: string; env?: NodeJS.ProcessEnv; timeoutMs?: number }) => Promise<CommandResult>;
|
|
11
11
|
export const runCommand: CommandRunner;
|
|
12
12
|
export function diagnose(options?: { home?: string; project?: string; env?: NodeJS.ProcessEnv; run?: CommandRunner; sandbox?: boolean; daemonEntry?: string; timeoutMs?: number }): Promise<DoctorCheck[]>;
|
|
13
|
-
export
|
|
13
|
+
export type LeftoverState = 'clean-pushed' | 'dirty' | 'local-only' | 'unpushed' | 'in-use' | 'unknown';
|
|
14
|
+
export type Leftover = { path: string; state: LeftoverState; reason?: string; command?: string };
|
|
15
|
+
export const LEFTOVER_STATES: Record<LeftoverState, string>;
|
|
16
|
+
/** An absolute path of ASCII letters, digits, space and . _ - / \ : in single quotes, for sh or PowerShell; undefined for any other path. */
|
|
17
|
+
export function shellQuote(text: string, platform?: NodeJS.Platform): string | undefined;
|
|
18
|
+
/** A path as alp doctor prints it in a comment line: escaped injectively, on one line. */
|
|
19
|
+
export function printable(text: unknown): string;
|
|
20
|
+
export function diskCheck(home: string, options?: { run?: CommandRunner; env?: NodeJS.ProcessEnv; free?: number; tempDirs?: string[]; cwd?: string; classifyMs?: number; recentMs?: number; platform?: NodeJS.Platform }): Promise<DoctorCheck & { leftovers?: Leftover[] }>;
|
|
14
21
|
export function repair(checks: DoctorCheck[]): Promise<Array<{ id: string; result: string }>>;
|