@anhlp/alp 0.0.1-beta.4 → 0.0.1-beta.7

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.
Files changed (198) hide show
  1. package/README.md +11 -412
  2. package/bin/alp.js +3 -0
  3. package/package.json +11 -103
  4. package/dist/THIRD-PARTY-NOTICES.txt +0 -626
  5. package/dist/acp.js +0 -19936
  6. package/dist/alpd.js +0 -49562
  7. package/docs/modular-monorepo.md +0 -214
  8. package/packages/cli/README.md +0 -7
  9. package/packages/cli/dist/THIRD-PARTY-NOTICES.txt +0 -651
  10. package/packages/cli/dist/acp/agent.d.ts +0 -37
  11. package/packages/cli/dist/acp/agent.js +0 -489
  12. package/packages/cli/dist/acp/main.d.ts +0 -4
  13. package/packages/cli/dist/acp/main.js +0 -23
  14. package/packages/cli/dist/acp.js +0 -19936
  15. package/packages/cli/dist/alp-web/THIRD-PARTY-NOTICES.txt +0 -2590
  16. package/packages/cli/dist/alp-web/alp-boundary.json +0 -15
  17. package/packages/cli/dist/alp-web/apple-touch-icon.png +0 -0
  18. package/packages/cli/dist/alp-web/assets/TerminalPanel-DLuoa74B.css +0 -1
  19. package/packages/cli/dist/alp-web/assets/TerminalPanel-PrU2l3u5.js +0 -16
  20. package/packages/cli/dist/alp-web/assets/index-BJdBTDFX.css +0 -1
  21. package/packages/cli/dist/alp-web/assets/index-DpfiPv5s.js +0 -52
  22. package/packages/cli/dist/alp-web/favicon-attention.svg +0 -6
  23. package/packages/cli/dist/alp-web/favicon-running.svg +0 -6
  24. package/packages/cli/dist/alp-web/favicon.svg +0 -5
  25. package/packages/cli/dist/alp-web/index.html +0 -20
  26. package/packages/cli/dist/alp-web.js +0 -9640
  27. package/packages/cli/dist/alpd.js +0 -49562
  28. package/packages/cli/dist/backup.d.ts +0 -4
  29. package/packages/cli/dist/backup.js +0 -146
  30. package/packages/cli/dist/build-manifest.json +0 -240
  31. package/packages/cli/dist/cli.d.ts +0 -2
  32. package/packages/cli/dist/cli.js +0 -30
  33. package/packages/cli/dist/daemon.d.ts +0 -35
  34. package/packages/cli/dist/daemon.js +0 -126
  35. package/packages/cli/dist/index.d.ts +0 -1
  36. package/packages/cli/dist/index.js +0 -5
  37. package/packages/cli/dist/interfaces.d.ts +0 -24
  38. package/packages/cli/dist/interfaces.js +0 -156
  39. package/packages/cli/dist/library.d.ts +0 -140
  40. package/packages/cli/dist/library.js +0 -319
  41. package/packages/cli/dist/paths.d.ts +0 -3
  42. package/packages/cli/dist/paths.js +0 -18
  43. package/packages/cli/dist/projects.d.ts +0 -9
  44. package/packages/cli/dist/projects.js +0 -159
  45. package/packages/cli/dist/schedules.d.ts +0 -2
  46. package/packages/cli/dist/schedules.js +0 -45
  47. package/packages/cli/dist/sessions.d.ts +0 -43
  48. package/packages/cli/dist/sessions.js +0 -458
  49. package/packages/cli/dist/tasks.d.ts +0 -29
  50. package/packages/cli/dist/tasks.js +0 -345
  51. package/packages/cli/dist/terminal.d.ts +0 -8
  52. package/packages/cli/dist/terminal.js +0 -79
  53. package/packages/cli/dist/usage.d.ts +0 -3
  54. package/packages/cli/dist/usage.js +0 -78
  55. package/packages/cli/dist/web-service.d.ts +0 -38
  56. package/packages/cli/dist/web-service.js +0 -119
  57. package/packages/client/README.md +0 -29
  58. package/packages/client/dist/acp-probe.d.ts +0 -44
  59. package/packages/client/dist/acp-probe.js +0 -37
  60. package/packages/client/dist/antigravity-probe.d.ts +0 -34
  61. package/packages/client/dist/antigravity-probe.js +0 -95
  62. package/packages/client/dist/command.d.ts +0 -5
  63. package/packages/client/dist/command.js +0 -33
  64. package/packages/client/dist/doctor.d.ts +0 -13
  65. package/packages/client/dist/doctor.js +0 -587
  66. package/packages/client/dist/index.d.ts +0 -151
  67. package/packages/client/dist/index.js +0 -533
  68. package/packages/client/dist/integration-lock.d.ts +0 -35
  69. package/packages/client/dist/integration-lock.js +0 -179
  70. package/packages/client/dist/ipc.d.ts +0 -42
  71. package/packages/client/dist/ipc.js +0 -69
  72. package/packages/client/dist/library-test.d.ts +0 -94
  73. package/packages/client/dist/library-test.js +0 -37
  74. package/packages/client/dist/mcp-probe.d.ts +0 -24
  75. package/packages/client/dist/mcp-probe.js +0 -147
  76. package/packages/client/dist/portable.d.ts +0 -19
  77. package/packages/client/dist/portable.js +0 -33
  78. package/packages/client/dist/prompt.d.ts +0 -32
  79. package/packages/client/dist/prompt.js +0 -59
  80. package/packages/client/dist/render.d.ts +0 -6
  81. package/packages/client/dist/render.js +0 -120
  82. package/packages/client/dist/rpc/client.d.ts +0 -82
  83. package/packages/client/dist/rpc/client.js +0 -292
  84. package/packages/client/dist/rpc/errors.d.ts +0 -42
  85. package/packages/client/dist/rpc/errors.js +0 -34
  86. package/packages/client/dist/rpc/framing.d.ts +0 -21
  87. package/packages/client/dist/rpc/framing.js +0 -57
  88. package/packages/client/dist/rpc/handshake.d.ts +0 -19
  89. package/packages/client/dist/rpc/handshake.js +0 -8
  90. package/packages/client/dist/rpc/reconnect.d.ts +0 -97
  91. package/packages/client/dist/rpc/reconnect.js +0 -227
  92. package/packages/client/dist/rpc/registry.d.ts +0 -211
  93. package/packages/client/dist/rpc/registry.js +0 -145
  94. package/packages/client/dist/rpc/timers.d.ts +0 -11
  95. package/packages/client/dist/rpc/timers.js +0 -11
  96. package/packages/client/dist/service.d.ts +0 -50
  97. package/packages/client/dist/service.js +0 -143
  98. package/packages/client/dist/setup.d.ts +0 -2
  99. package/packages/client/dist/setup.js +0 -146
  100. package/packages/client/dist/supervise.d.ts +0 -14
  101. package/packages/client/dist/supervise.js +0 -87
  102. package/packages/client/dist/websocket.d.ts +0 -51
  103. package/packages/client/dist/websocket.js +0 -190
  104. package/packages/core/README.md +0 -7
  105. package/packages/core/dist/adapter.d.ts +0 -20
  106. package/packages/core/dist/adapter.js +0 -30
  107. package/packages/core/dist/atomic.d.ts +0 -2
  108. package/packages/core/dist/atomic.js +0 -28
  109. package/packages/core/dist/backup.d.ts +0 -27
  110. package/packages/core/dist/backup.js +0 -681
  111. package/packages/core/dist/beads.d.ts +0 -65
  112. package/packages/core/dist/beads.js +0 -213
  113. package/packages/core/dist/delegation.d.ts +0 -2
  114. package/packages/core/dist/delegation.js +0 -32
  115. package/packages/core/dist/errors.d.ts +0 -4
  116. package/packages/core/dist/errors.js +0 -11
  117. package/packages/core/dist/formulas.d.ts +0 -25
  118. package/packages/core/dist/formulas.js +0 -201
  119. package/packages/core/dist/hook-run.d.ts +0 -44
  120. package/packages/core/dist/hook-run.js +0 -60
  121. package/packages/core/dist/hooks.d.ts +0 -35
  122. package/packages/core/dist/hooks.js +0 -30
  123. package/packages/core/dist/index.d.ts +0 -31
  124. package/packages/core/dist/index.js +0 -65
  125. package/packages/core/dist/init.d.ts +0 -30
  126. package/packages/core/dist/init.js +0 -89
  127. package/packages/core/dist/library-edit.d.ts +0 -93
  128. package/packages/core/dist/library-edit.js +0 -368
  129. package/packages/core/dist/library.d.ts +0 -28
  130. package/packages/core/dist/library.js +0 -108
  131. package/packages/core/dist/log.d.ts +0 -37
  132. package/packages/core/dist/log.js +0 -156
  133. package/packages/core/dist/migrations.d.ts +0 -9
  134. package/packages/core/dist/migrations.js +0 -95
  135. package/packages/core/dist/models.d.ts +0 -11
  136. package/packages/core/dist/models.js +0 -44
  137. package/packages/core/dist/permissions.d.ts +0 -14
  138. package/packages/core/dist/permissions.js +0 -229
  139. package/packages/core/dist/profiles.d.ts +0 -27
  140. package/packages/core/dist/profiles.js +0 -122
  141. package/packages/core/dist/promptsafe.d.ts +0 -1
  142. package/packages/core/dist/promptsafe.js +0 -13
  143. package/packages/core/dist/providers.d.ts +0 -90
  144. package/packages/core/dist/providers.js +0 -101
  145. package/packages/core/dist/resolver.d.ts +0 -41
  146. package/packages/core/dist/resolver.js +0 -240
  147. package/packages/core/dist/safe-path.d.ts +0 -2
  148. package/packages/core/dist/safe-path.js +0 -24
  149. package/packages/core/dist/shell.d.ts +0 -16
  150. package/packages/core/dist/shell.js +0 -22
  151. package/packages/core/dist/state-schema.d.ts +0 -9
  152. package/packages/core/dist/state-schema.js +0 -54
  153. package/packages/core/dist/task-rows.d.ts +0 -47
  154. package/packages/core/dist/task-rows.js +0 -45
  155. package/packages/core/dist/tasks.d.ts +0 -128
  156. package/packages/core/dist/tasks.js +0 -835
  157. package/packages/core/dist/teams.d.ts +0 -80
  158. package/packages/core/dist/teams.js +0 -159
  159. package/packages/core/dist/template-path.d.ts +0 -2
  160. package/packages/core/dist/template-path.js +0 -10
  161. package/packages/core/dist/trust.d.ts +0 -8
  162. package/packages/core/dist/trust.js +0 -47
  163. package/packages/core/dist/types.d.ts +0 -51
  164. package/packages/core/dist/upgrade.d.ts +0 -10
  165. package/packages/core/dist/upgrade.js +0 -200
  166. package/packages/core/dist/user-settings.d.ts +0 -6
  167. package/packages/core/dist/user-settings.js +0 -72
  168. package/packages/core/dist/user-worktree.d.ts +0 -29
  169. package/packages/core/dist/user-worktree.js +0 -242
  170. package/packages/core/dist/validation.d.ts +0 -17
  171. package/packages/core/dist/validation.js +0 -296
  172. package/packages/core/dist/verify.d.ts +0 -15
  173. package/packages/core/dist/verify.js +0 -123
  174. package/packages/core/dist/workflow.d.ts +0 -45
  175. package/packages/core/dist/workflow.js +0 -33
  176. package/templates/ALP.md +0 -52
  177. package/templates/agents/lead/AGENT.md +0 -90
  178. package/templates/agents/main/AGENT.md +0 -150
  179. package/templates/agents/oracle/AGENT.md +0 -44
  180. package/templates/agents/peer/AGENT.md +0 -55
  181. package/templates/agents/reviewer/AGENT.md +0 -80
  182. package/templates/agents/supervisor/AGENT.md +0 -72
  183. package/templates/providers/antigravity.json +0 -6
  184. package/templates/providers/opencode.json +0 -7
  185. package/templates/role-skills.json +0 -8
  186. package/templates/skills/bug-loop/SKILL.md +0 -44
  187. package/templates/skills/bug-loop/references/test-proof.md +0 -25
  188. package/templates/skills/goal-griller/SKILL.md +0 -49
  189. package/templates/skills/prompt-leverage/SKILL.md +0 -37
  190. package/templates/skills/prompt-leverage/references/brief-template.md +0 -27
  191. package/templates/skills/sequence-execution-plan/SKILL.md +0 -42
  192. package/templates/skills/sequence-execution-plan/references/plan-template.md +0 -22
  193. package/templates/skills/smart-commits/SKILL.md +0 -40
  194. package/templates/skills/xia/SKILL.md +0 -42
  195. package/templates/teams/cafe/HOUSE_RULES.md +0 -1
  196. package/templates/teams/cafe/team.json +0 -15
  197. package/templates/teams/pho/HOUSE_RULES.md +0 -1
  198. package/templates/teams/pho/team.json +0 -14
@@ -1,119 +0,0 @@
1
- // packages/cli/src/web-service.js
2
- import { execFile } from "node:child_process";
3
- import { existsSync } from "node:fs";
4
- import { lstat, readFile } from "node:fs/promises";
5
- import path from "node:path";
6
- import { fileURLToPath } from "node:url";
7
- import { promisify } from "node:util";
8
- import { bootTime, readLock } from "@anhlp/alp-client/index";
9
- import { distributionEntry } from "./paths.js";
10
- var execFileAsync = promisify(execFile);
11
- var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
12
- function alpWebEntry() {
13
- const entry = fileURLToPath(distributionEntry("alp-web.js"));
14
- if (!existsSync(entry)) throw new Error(`alp web is not built: ${entry} is missing. Build the CLI (npm run build in the ALP checkout) or reinstall ALP.`);
15
- return entry;
16
- }
17
- var readJson = async (file) => JSON.parse(await readFile(file, "utf8"));
18
- async function processStart(pid) {
19
- try {
20
- const { stdout } = await execFileAsync("ps", ["-o", "etime=", "-p", String(pid)], { encoding: "utf8", timeout: 5e3 });
21
- const match = /^\s*(?:(\d+)-)?(?:(\d+):)?(\d+):(\d+)\s*$/.exec(stdout);
22
- if (!match) return void 0;
23
- const [, days = "0", hours = "0", minutes, seconds] = match;
24
- const elapsed = ((Number(days) * 24 + Number(hours)) * 60 + Number(minutes)) * 60 + Number(seconds);
25
- return Date.now() - elapsed * 1e3;
26
- } catch {
27
- return void 0;
28
- }
29
- }
30
- async function webOwner(home) {
31
- const lockFile = path.join(home, "integrations", "web.lock");
32
- const infoFile = path.join(home, "web.json");
33
- let lock, lockInfo;
34
- try {
35
- lockInfo = await lstat(lockFile);
36
- lock = await readJson(lockFile);
37
- } catch {
38
- return { reason: `${lockFile} is missing or unreadable`, alive: false };
39
- }
40
- if (!lockInfo.isFile() || !Number.isSafeInteger(lock?.pid) || lock.pid <= 0 || typeof lock.bootTime !== "number" || !Number.isFinite(Date.parse(lock.startedAt))) {
41
- return { reason: `${lockFile} is not a complete integration lock`, alive: false };
42
- }
43
- const { pid } = lock;
44
- try {
45
- process.kill(pid, 0);
46
- } catch (error) {
47
- if (error?.code === "ESRCH") return { reason: `its pid ${pid} has exited`, alive: false };
48
- if (error?.code === "EPERM") return { reason: `pid ${pid} belongs to another user`, alive: true, kind: "foreign" };
49
- return { reason: `pid ${pid} cannot be signalled (${error?.code ?? error})`, alive: true, kind: "unknown" };
50
- }
51
- const refuse = (reason, kind) => ({ reason, alive: true, kind });
52
- if (process.platform === "win32") return refuse("alp does not stop it on Windows", "unknown");
53
- const uid = process.getuid?.();
54
- if (lockInfo.uid !== uid) return refuse("its lock is not yours", "foreign");
55
- if (Math.abs(lock.bootTime - bootTime()) > 30) return refuse("its lock is from another boot", "foreign");
56
- if (pid === process.pid || pid === (await readLock(home).catch(() => void 0))?.pid) return refuse(`pid ${pid} is not an integration`, "foreign");
57
- const started = await processStart(pid);
58
- if (started === void 0) return refuse(`the start time of pid ${pid} is unknown`, "unknown");
59
- if (started > Date.parse(lock.startedAt) + 2e3) return refuse(`pid ${pid} started after the lock was written (a reused pid)`, "foreign");
60
- let info, infoStat;
61
- try {
62
- infoStat = await lstat(infoFile);
63
- info = await readJson(infoFile);
64
- } catch {
65
- return refuse(`${infoFile} is missing or unreadable`, "transient");
66
- }
67
- if (info?.pid !== pid) return refuse(`${infoFile} names another process than the lock`, "transient");
68
- if (!infoStat.isFile() || infoStat.uid !== uid) return refuse(`${infoFile} is not yours`, "foreign");
69
- return { pid, app: info.app };
70
- }
71
- async function terminate(pid, what, timeoutMs = 2e4) {
72
- try {
73
- process.kill(pid, "SIGTERM");
74
- } catch (error) {
75
- if (error?.code === "ESRCH") return;
76
- throw error;
77
- }
78
- const deadline = Date.now() + timeoutMs;
79
- while (Date.now() < deadline) {
80
- try {
81
- process.kill(pid, 0);
82
- } catch (error) {
83
- if (error?.code === "ESRCH") return;
84
- }
85
- await sleep(100);
86
- }
87
- throw new Error(`${what} (pid ${pid}) did not stop within ${timeoutMs / 1e3} s of SIGTERM; stop it, then run the command again`);
88
- }
89
- var isAlpWeb = (app) => app === "alp-web";
90
- var PASEO_BEFORE_RENAME = "The Paseo integration from before its rename";
91
- async function stopPreRenamePaseo(home) {
92
- const owner = await webOwner(home);
93
- if (!("pid" in owner) || isAlpWeb(owner.app)) return void 0;
94
- await terminate(owner.pid, PASEO_BEFORE_RENAME);
95
- return owner.pid;
96
- }
97
- async function stopWebService(home, timeoutMs = 3e4) {
98
- const deadline = Date.now() + timeoutMs;
99
- for (; ; ) {
100
- const owner = await webOwner(home);
101
- if ("pid" in owner) {
102
- await terminate(owner.pid, isAlpWeb(owner.app) ? "alp web" : PASEO_BEFORE_RENAME);
103
- return owner.pid;
104
- }
105
- if (!owner.alive) return void 0;
106
- if (owner.kind !== "transient" || Date.now() >= deadline) throw new Error(`${refusal(home)} (${owner.reason}); stop it, then run the command again`);
107
- await sleep(200);
108
- }
109
- }
110
- function refusal(home) {
111
- return `${path.join(home, "integrations", "web.lock")} is held by a process that alp cannot prove is alp web or the Paseo integration from before its rename, so it was left running`;
112
- }
113
- export {
114
- alpWebEntry,
115
- refusal,
116
- stopPreRenamePaseo,
117
- stopWebService,
118
- webOwner
119
- };
@@ -1,29 +0,0 @@
1
- # @anhlp/alp-client
2
-
3
- The ALP RPC client: a portable JSON-RPC engine for Node, browsers and React Native, its
4
- WebSocket and Node IPC transports, and the Node-only daemon discovery, supervision, services
5
- and setup helpers.
6
-
7
- - `@anhlp/alp-client/portable`: `AlpRpcClient`, errors, `hello`, `createReconnectingClient`,
8
- NDJSON framing. No Node built-ins, `process` or `Buffer`; needs no polyfills.
9
- - `@anhlp/alp-client/websocket`: `connectWebSocket` over the browser's, React Native's or an
10
- injected WebSocket. Authentication is the caller's (the gateway's) business.
11
- - `@anhlp/alp-client` (Node): everything above plus `connect`, `AlpClient`, `connectSocket`,
12
- `ensureDaemon`, the private-socket checks and lock helpers, unchanged for existing callers.
13
- - `@anhlp/alp-client/ipc` (Node): `createSocketTransport` for a Unix socket or named pipe.
14
- - `@anhlp/alp-client/integration-lock` (Node): `createIntegrationLock(home, name)`, the single-owner
15
- lock of one integration service at `<home>/integrations/<name>.lock`, serialized by the exclusive
16
- guard directory `<name>.lock.reclaim`. Each instance is single-use (`acquire`, then `setReady` and
17
- `release` while it owns the lock); its recovery rules are in
18
- [docs/modular-monorepo.md](../../docs/modular-monorepo.md).
19
-
20
- Timeouts and aborts end only the caller's wait, and nothing is ever resent after a disconnect.
21
- See [docs/alp/client-sdk.md](../../docs/alp/client-sdk.md) for the transport contract, the
22
- request lifecycle, the old-to-new API table and what still waits on the protocol (Task 06) and
23
- the gateway (Task 08).
24
-
25
- `startIntegration({ name, entry, home, args })` (or `startIntegration(name)`; `name` defaults to `web`) discovers an optional integration's descriptor and starts it detached with `--service` and then `args`, so the entry writes its own log; discovery and the selected `ALP_HOME` are pinned by tests. `name` is a single lowercase path segment (`assertIntegrationName`). With `entry`, that script runs with the current Node and no descriptor, environment or PATH discovery happens; a missing entry is an error even when a live owner would be reused. `web` is alp-web, the service of the ALP CLI (`alp web`): it is never discovered, so it needs its `entry`, and `"web": { "enabled": false }` in the home's settings refuses it and no other integration. Everything once registered under `web` (`integrations/web.json`, the `alp-web-integration` binary, `ALP_WEB_INTEGRATION`) is the Paseo integration from before its rename; `discoverIntegration('paseo')` reads `ALP_PASEO_INTEGRATION`, then `ALP_WEB_INTEGRATION` for one release, then `ALP_INTEGRATION_ENTRY`. Errors name the integration, the entry and its log under `<home>/logs/integrations`. Either way a live owner of `integrations/<name>.lock` is reused, and the call resolves once that lock is ready and `<home>/<name>.json` names the same pid. Restarting is non-destructive: a daemon left running by an older install is reported as older than the current CLI and is never killed in place.
26
-
27
- Build: `npm run build --workspace=@anhlp/alp-client`. Test: `npm run test --workspace=@anhlp/alp-client`.
28
-
29
- Public imports use the package root and its explicitly exported subpaths. See [architecture, provider extension, compatibility and release instructions](../../docs/modular-monorepo.md).
@@ -1,44 +0,0 @@
1
- /**
2
- * Starts an ACP provider once and runs initialize (ALPD §46), for `alp provider test`
3
- * and the settings screen. It reports who the agent says it is and what it supports;
4
- * a provider that needs a login usually says so here, in authMethods. With `discover`,
5
- * it also opens a session in `cwd`, as Paseo does, to read the models and modes the agent
6
- * offers (ALPD §65); an agent that offers none leaves them out.
7
- * @param {{ command: string, args?: string[], env?: Record<string, string>, label?: string, id?: string }} provider
8
- * @param {{ cwd?: string, timeoutMs?: number, discover?: boolean }} [options]
9
- * @returns {Promise<{ protocolVersion: number, agent?: { name?: string, title?: string, version?: string }, loadSession: boolean, mcpHttp: boolean, authMethods: string[],
10
- * models?: Array<{ id: string, label: string, description?: string }>, currentModel?: string, modes?: Array<{ id: string, label: string, description?: string }>, currentMode?: string }>}
11
- */
12
- export function probeAcp(provider: {
13
- command: string;
14
- args?: string[];
15
- env?: Record<string, string>;
16
- label?: string;
17
- id?: string;
18
- }, { cwd, timeoutMs, discover }?: {
19
- cwd?: string;
20
- timeoutMs?: number;
21
- discover?: boolean;
22
- }): Promise<{
23
- protocolVersion: number;
24
- agent?: {
25
- name?: string;
26
- title?: string;
27
- version?: string;
28
- };
29
- loadSession: boolean;
30
- mcpHttp: boolean;
31
- authMethods: string[];
32
- models?: Array<{
33
- id: string;
34
- label: string;
35
- description?: string;
36
- }>;
37
- currentModel?: string;
38
- modes?: Array<{
39
- id: string;
40
- label: string;
41
- description?: string;
42
- }>;
43
- currentMode?: string;
44
- }>;
@@ -1,37 +0,0 @@
1
- // packages/client/src/acp-probe.js
2
- import { stdioSession } from "./mcp-probe.js";
3
- async function probeAcp(provider, { cwd, timeoutMs = 2e4, discover = false } = {}) {
4
- const session = stdioSession({ command: provider.command, args: provider.args ?? [], env: provider.env ?? {} }, cwd, timeoutMs);
5
- try {
6
- const result = await session.request("initialize", {
7
- protocolVersion: 1,
8
- clientCapabilities: { fs: { readTextFile: false, writeTextFile: false }, terminal: false },
9
- clientInfo: { name: "alp", title: "ALP", version: "1" }
10
- });
11
- if (result.protocolVersion !== 1) throw new Error(`${provider.label ?? provider.id} speaks ACP version ${result.protocolVersion}; ALP speaks version 1`);
12
- const info = result.agentInfo;
13
- const offered = discover ? await session.request("session/new", { cwd, mcpServers: [] }) : void 0;
14
- const choices = (list) => Array.isArray(list) ? list.filter((item) => typeof (item?.modelId ?? item?.id) === "string").map((item) => ({ id: item.modelId ?? item.id, label: typeof item.name === "string" && item.name ? item.name : item.modelId ?? item.id, ...typeof item.description === "string" && item.description ? { description: item.description } : {} })) : void 0;
15
- const config = offered?.configOptions?.find((option) => option.category === "model" && option.type === "select");
16
- const modeConfig = offered?.configOptions?.find((option) => option.category === "mode" && option.type === "select");
17
- const flatten = (options) => options?.flatMap((option) => option.options ?? [option]).map((option) => ({ ...option, id: option.value }));
18
- const modelState = offered?.models ?? (config ? { availableModels: flatten(config.options), currentModelId: config.currentValue } : void 0);
19
- const modeState = offered?.modes ?? (modeConfig ? { availableModes: flatten(modeConfig.options), currentModeId: modeConfig.currentValue } : void 0);
20
- const models = choices(modelState?.availableModels);
21
- const modes = choices(modeState?.availableModes);
22
- return {
23
- ...models ? { models, ...typeof modelState.currentModelId === "string" ? { currentModel: modelState.currentModelId } : {} } : {},
24
- ...modes ? { modes, ...typeof modeState.currentModeId === "string" ? { currentMode: modeState.currentModeId } : {} } : {},
25
- protocolVersion: result.protocolVersion,
26
- ...info ? { agent: { ...info.name ? { name: info.name } : {}, ...info.title ? { title: info.title } : {}, ...info.version ? { version: info.version } : {} } } : {},
27
- loadSession: Boolean(result.agentCapabilities?.loadSession),
28
- mcpHttp: Boolean(result.agentCapabilities?.mcpCapabilities?.http),
29
- authMethods: (result.authMethods ?? []).map((method) => method?.name ?? method?.id).filter(Boolean)
30
- };
31
- } finally {
32
- await session.close();
33
- }
34
- }
35
- export {
36
- probeAcp
37
- };
@@ -1,34 +0,0 @@
1
- /**
2
- * Probes Antigravity CLI for version, status and available models.
3
- * @param {{ command?: string, args?: string[], env?: Record<string, string>, label?: string, id?: string, readOnlyMode?: 'instructions' | 'reject' }} [provider]
4
- * @param {{ cwd?: string, timeoutMs?: number }} [options]
5
- */
6
- export function probeAntigravity(provider?: {
7
- command?: string;
8
- args?: string[];
9
- env?: Record<string, string>;
10
- label?: string;
11
- id?: string;
12
- readOnlyMode?: "instructions" | "reject";
13
- }, { cwd, timeoutMs }?: {
14
- cwd?: string;
15
- timeoutMs?: number;
16
- }): Promise<{
17
- version: string;
18
- agent: {
19
- name: string;
20
- title: string;
21
- version: string;
22
- };
23
- models: {
24
- id: any;
25
- label: any;
26
- }[];
27
- currentModel: any;
28
- modes: {
29
- id: string;
30
- label: string;
31
- description: string;
32
- }[];
33
- currentMode: string;
34
- }>;
@@ -1,95 +0,0 @@
1
- // packages/client/src/antigravity-probe.js
2
- import { spawn } from "node:child_process";
3
- var DEFAULT_ANTIGRAVITY_MODELS = [
4
- { id: "gemini-3.8-flash-high", label: "Gemini 3.8 Flash (High)" },
5
- { id: "gemini-3.8-flash-medium", label: "Gemini 3.8 Flash (Medium)" },
6
- { id: "gemini-3.8-flash-low", label: "Gemini 3.8 Flash (Low)" },
7
- { id: "gemini-2.5-pro", label: "Gemini 2.5 Pro" },
8
- { id: "gemini-2.5-flash", label: "Gemini 2.5 Flash" },
9
- { id: "claude-sonnet-4-6", label: "Claude Sonnet 4.6 (Thinking)" },
10
- { id: "claude-opus-4-6-thinking", label: "Claude Opus 4.6 (Thinking)" },
11
- { id: "gpt-oss-120b-medium", label: "GPT-OSS 120B (Medium)" }
12
- ];
13
- var ANTIGRAVITY_MODES = [
14
- {
15
- id: "full-access",
16
- label: "Full access",
17
- description: "Antigravity runs with full access (--dangerously-skip-permissions)."
18
- }
19
- ];
20
- function runCommand(command, args, { env = process.env, cwd, timeoutMs = 2e4 } = {}) {
21
- return new Promise((resolve, reject) => {
22
- const child = spawn(command, args, {
23
- cwd,
24
- env,
25
- stdio: ["ignore", "pipe", "pipe"],
26
- windowsHide: true
27
- });
28
- let stdout = "";
29
- let stderr = "";
30
- const timer = setTimeout(() => {
31
- child.kill("SIGKILL");
32
- reject(new Error(`${command} ${args.join(" ")} timed out after ${timeoutMs / 1e3}s`));
33
- }, timeoutMs);
34
- child.stdout.on("data", (chunk) => {
35
- stdout += chunk.toString();
36
- });
37
- child.stderr.on("data", (chunk) => {
38
- stderr += chunk.toString();
39
- });
40
- child.on("error", (error) => {
41
- clearTimeout(timer);
42
- reject(error);
43
- });
44
- child.on("close", (code) => {
45
- clearTimeout(timer);
46
- if (code === 0) resolve({ stdout, stderr });
47
- else reject(new Error(`${command} exited with code ${code}: ${stderr.trim() || stdout.trim()}`));
48
- });
49
- });
50
- }
51
- async function probeAntigravity(provider = {}, { cwd, timeoutMs = 2e4 } = {}) {
52
- const command = provider.command || "agy";
53
- const args = provider.args ?? [];
54
- const env = { ...process.env, ...provider.env ?? {} };
55
- let version = "";
56
- try {
57
- const res = await runCommand(command, [...args, "--version"], { env, cwd, timeoutMs: Math.min(timeoutMs, 5e3) });
58
- version = res.stdout.trim().split("\n")[0] ?? "";
59
- } catch (error) {
60
- throw new Error(`Antigravity command '${command}' is not available: ${error.message}`);
61
- }
62
- let models = [];
63
- try {
64
- const res = await runCommand(command, [...args, "models"], { env, cwd, timeoutMs });
65
- for (const line of res.stdout.trim().split(/\r?\n/)) {
66
- if (!line.trim()) continue;
67
- const [id, label] = line.split(" ");
68
- if (id && label) {
69
- models.push({ id: id.trim(), label: label.trim() });
70
- } else if (id) {
71
- models.push({ id: id.trim(), label: id.trim() });
72
- }
73
- }
74
- } catch {
75
- models = [...DEFAULT_ANTIGRAVITY_MODELS];
76
- }
77
- if (!models.length) {
78
- models = [...DEFAULT_ANTIGRAVITY_MODELS];
79
- }
80
- return {
81
- version,
82
- agent: { name: "antigravity", title: "Antigravity", version },
83
- models,
84
- currentModel: models[0]?.id,
85
- modes: provider.readOnlyMode === "instructions" ? [...ANTIGRAVITY_MODES, {
86
- id: "read-only",
87
- label: "Read only (instructions)",
88
- description: "For new sessions: prompt-only read-only behavior. agy still runs with full access; no OS sandbox enforces this mode."
89
- }] : ANTIGRAVITY_MODES,
90
- currentMode: "full-access"
91
- };
92
- }
93
- export {
94
- probeAntigravity
95
- };
@@ -1,5 +0,0 @@
1
- /** Runs a command; resolves with its exit code and output, never rejects. */
2
- export function runCommand(command: any, args: any, { cwd, env, timeoutMs }?: {
3
- env?: NodeJS.ProcessEnv | undefined;
4
- timeoutMs?: number | undefined;
5
- }): Promise<any>;
@@ -1,33 +0,0 @@
1
- // packages/client/src/command.js
2
- import { spawn } from "node:child_process";
3
- function runCommand(command, args, { cwd, env = process.env, timeoutMs = 15e3 } = {}) {
4
- return new Promise((resolve) => {
5
- let child;
6
- const script = process.platform === "win32" && /\.[cm]?js$/i.test(command);
7
- try {
8
- child = spawn(script ? process.execPath : command, script ? [command, ...args] : args, { cwd, env, stdio: ["ignore", "pipe", "pipe"] });
9
- } catch (error) {
10
- resolve({ code: -1, stdout: "", stderr: error.message });
11
- return;
12
- }
13
- let stdout = "", stderr = "";
14
- child.stdout.on("data", (chunk) => {
15
- stdout += chunk;
16
- });
17
- child.stderr.on("data", (chunk) => {
18
- stderr += chunk;
19
- });
20
- const timer = setTimeout(() => child.kill("SIGKILL"), timeoutMs);
21
- child.on("error", (error) => {
22
- clearTimeout(timer);
23
- resolve({ code: -1, stdout, stderr: error.message });
24
- });
25
- child.on("close", (code) => {
26
- clearTimeout(timer);
27
- resolve({ code: code ?? -1, stdout, stderr });
28
- });
29
- });
30
- }
31
- export {
32
- runCommand
33
- };
@@ -1,13 +0,0 @@
1
- export type DoctorCheck = {
2
- id: string;
3
- status: 'ok' | 'info' | 'warn' | 'fail';
4
- summary: string;
5
- details?: string[];
6
- hint?: string;
7
- fix?: { describe: string; apply(): Promise<string> };
8
- };
9
- export type CommandResult = { code: number; stdout: string; stderr: string };
10
- export type CommandRunner = (command: string, args: string[], options?: { cwd?: string; env?: NodeJS.ProcessEnv; timeoutMs?: number }) => Promise<CommandResult>;
11
- export const runCommand: CommandRunner;
12
- export function diagnose(options?: { home?: string; project?: string; env?: NodeJS.ProcessEnv; run?: CommandRunner; sandbox?: boolean; daemonEntry?: string; timeoutMs?: number }): Promise<DoctorCheck[]>;
13
- export function repair(checks: DoctorCheck[]): Promise<Array<{ id: string; result: string }>>;