@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,51 +0,0 @@
1
- /** A URL fit for an error message: no credentials, query or fragment, which may carry a token. @param {string} url */
2
- export function redactUrl(url: string): string;
3
- /**
4
- * Wraps an open WebSocket in an ALP transport. The transport owns the socket from then on.
5
- * @param {WebSocketLike} socket
6
- * @param {WebSocketTransportOptions} [options]
7
- * @returns {AlpTransport}
8
- */
9
- export function createWebSocketTransport(socket: WebSocketLike, { maxFrame, maxBufferedBytes }?: WebSocketTransportOptions): AlpTransport;
10
- /**
11
- * Opens a WebSocket to `url` and resolves with its transport once it is open. The socket comes
12
- * from `createSocket`, else `new WebSocket(url, protocols)` with the injected or global WebSocket.
13
- * Errors name the URL without its credentials, query or fragment.
14
- * @param {string} url
15
- * @param {ConnectWebSocketOptions} [options]
16
- * @returns {Promise<AlpTransport>}
17
- */
18
- export function connectWebSocket(url: string, { WebSocket: Implementation, protocols, createSocket, signal, timeoutMs, ...options }?: ConnectWebSocketOptions): Promise<AlpTransport>;
19
- /** Close codes this transport sends when the peer breaks the protocol. */
20
- export const CLOSE_CODE: Readonly<{
21
- unsupportedData: 4003;
22
- tooLarge: 4009;
23
- }>;
24
- export type AlpTransport = import("./rpc/client.js").AlpTransport;
25
- export type TransportClose = import("./rpc/client.js").TransportClose;
26
- export type AbortSignalLike = import("./rpc/client.js").AbortSignalLike;
27
- export type WebSocketLike = {
28
- readonly readyState: number;
29
- readonly bufferedAmount?: number;
30
- binaryType?: string;
31
- send(data: string): void;
32
- close(code?: number, reason?: string): void;
33
- addEventListener?(type: string, listener: (event: any) => void): void;
34
- removeEventListener?(type: string, listener: (event: any) => void): void;
35
- onopen?: ((event: any) => void) | null;
36
- onmessage?: ((event: any) => void) | null;
37
- onerror?: ((event: any) => void) | null;
38
- onclose?: ((event: any) => void) | null;
39
- };
40
- export type WebSocketConstructor = new (url: string, protocols?: string | string[]) => WebSocketLike;
41
- export type WebSocketTransportOptions = {
42
- maxFrame?: number;
43
- maxBufferedBytes?: number;
44
- };
45
- export type ConnectWebSocketOptions = WebSocketTransportOptions & {
46
- WebSocket?: WebSocketConstructor;
47
- protocols?: string | string[];
48
- createSocket?: (url: string, protocols?: string | string[]) => WebSocketLike;
49
- signal?: AbortSignalLike;
50
- timeoutMs?: number;
51
- };
@@ -1,190 +0,0 @@
1
- // packages/client/src/websocket.js
2
- import { MAX_FRAME } from "@anhlp/alp-protocol";
3
- import { AlpClientError } from "./rpc/errors.js";
4
- import { utf8Length } from "./rpc/framing.js";
5
- import { timerDelay } from "./rpc/timers.js";
6
- var CONNECTING = 0;
7
- var OPEN = 1;
8
- var CLOSE_CODE = Object.freeze({ unsupportedData: 4003, tooLarge: 4009 });
9
- var CLOSE_AFTER_ERROR_MS = 250;
10
- var MAX_CLOSE_REASON = 123;
11
- function redactUrl(url) {
12
- const match = /^([a-z][a-z0-9+.-]*:\/\/)(?:[^/?#\\]*@)?([^/?#\\@]*)([^?#]*)/i.exec(String(url));
13
- return match ? `${match[1]}${match[2]}${match[3]}` : "<websocket>";
14
- }
15
- function scrubbed(error, url) {
16
- const text = error instanceof Error ? error.message : String(error ?? "");
17
- const message = (text.split(String(url)).join(redactUrl(url)) || "WebSocket error").replace(/[a-z][a-z0-9+.-]*:\/\/[^\s'"<>]+/gi, (found) => redactUrl(found));
18
- const clean = new Error(message);
19
- if (error instanceof Error && error.name) clean.name = error.name;
20
- return clean;
21
- }
22
- function closeReason(reason) {
23
- let cut = reason;
24
- while (utf8Length(cut) > MAX_CLOSE_REASON) cut = cut.slice(0, -1);
25
- return cut;
26
- }
27
- function release(socket, code, reason) {
28
- if (socket.readyState !== CONNECTING && socket.readyState !== OPEN) return;
29
- try {
30
- if (code === void 0) socket.close();
31
- else socket.close(code, closeReason(reason ?? ""));
32
- return;
33
- } catch {
34
- }
35
- try {
36
- socket.close();
37
- } catch {
38
- }
39
- }
40
- function absorbErrors(socket) {
41
- if (typeof socket.addEventListener === "function") socket.addEventListener("error", () => {
42
- });
43
- }
44
- function listen(socket, type, listener) {
45
- if (typeof socket.addEventListener === "function") {
46
- socket.addEventListener(type, listener);
47
- return () => socket.removeEventListener?.(type, listener);
48
- }
49
- const key = (
50
- /** @type {'onopen' | 'onmessage' | 'onerror' | 'onclose'} */
51
- `on${type}`
52
- );
53
- const previous = socket[key];
54
- socket[key] = (event) => {
55
- previous?.(event);
56
- listener(event);
57
- };
58
- return () => {
59
- socket[key] = previous ?? null;
60
- };
61
- }
62
- var errorOf = (event) => {
63
- const message = event?.error instanceof Error && event.error.message || typeof event?.message === "string" && event.message || "WebSocket error";
64
- return event?.error instanceof Error && event.error.message ? event.error : new Error(message);
65
- };
66
- function createWebSocketTransport(socket, { maxFrame = MAX_FRAME, maxBufferedBytes = 4 * MAX_FRAME } = {}) {
67
- if (socket.readyState !== OPEN) throw new AlpClientError("WebSocket is not open", { reason: "disconnected" });
68
- absorbErrors(socket);
69
- try {
70
- socket.binaryType = "arraybuffer";
71
- } catch {
72
- }
73
- const messages = /* @__PURE__ */ new Set();
74
- const closes = /* @__PURE__ */ new Set();
75
- let ended;
76
- const detach = [];
77
- let failed;
78
- let failTimer;
79
- const end = (close) => {
80
- if (ended) return;
81
- ended = close;
82
- if (failTimer !== void 0) clearTimeout(failTimer);
83
- for (const remove of detach.splice(0)) remove();
84
- messages.clear();
85
- const listeners = [...closes];
86
- closes.clear();
87
- for (const listener of listeners) listener(close);
88
- };
89
- const violate = (message, code) => {
90
- const error = new AlpClientError(message, { reason: "protocol" });
91
- release(socket, code, message);
92
- end({ error });
93
- };
94
- detach.push(listen(socket, "message", (event) => {
95
- if (ended) return;
96
- const data = event?.data;
97
- if (typeof data !== "string") return violate("Binary WebSocket messages are not ALP frames", CLOSE_CODE.unsupportedData);
98
- if (utf8Length(data) > maxFrame) return violate(`ALP frame exceeds ${maxFrame} bytes`, CLOSE_CODE.tooLarge);
99
- for (const line of data.includes("\n") ? data.split("\n") : [data]) {
100
- if (ended) return;
101
- if (line.trim()) for (const listener of [...messages]) listener(line);
102
- }
103
- }));
104
- detach.push(listen(socket, "close", (event) => end({ error: failed, code: typeof event?.code === "number" ? event.code : void 0, reason: typeof event?.reason === "string" && event.reason ? event.reason : void 0 })));
105
- detach.push(listen(socket, "error", (event) => {
106
- if (failed) return;
107
- failed = errorOf(event);
108
- failTimer = setTimeout(() => end({ error: failed }), CLOSE_AFTER_ERROR_MS);
109
- release(socket);
110
- }));
111
- return {
112
- get state() {
113
- return ended || socket.readyState !== OPEN ? "closed" : "open";
114
- },
115
- send(frame) {
116
- if (ended || socket.readyState !== OPEN) throw new AlpClientError("WebSocket is not open", { reason: "send_failed" });
117
- if ((socket.bufferedAmount ?? 0) + utf8Length(frame) > maxBufferedBytes) throw new AlpClientError(`WebSocket send buffer is over ${maxBufferedBytes} bytes`, { reason: "send_failed" });
118
- socket.send(frame);
119
- },
120
- onMessage(listener) {
121
- if (ended) return () => false;
122
- messages.add(listener);
123
- return () => messages.delete(listener);
124
- },
125
- onClose(listener) {
126
- if (ended) return () => false;
127
- closes.add(listener);
128
- return () => closes.delete(listener);
129
- },
130
- close() {
131
- release(socket, 1e3, "client closed");
132
- end({ code: 1e3, reason: "client closed" });
133
- }
134
- };
135
- }
136
- function connectWebSocket(url, { WebSocket: Implementation, protocols, createSocket, signal, timeoutMs = 15e3, ...options } = {}) {
137
- const where = redactUrl(url);
138
- let delay;
139
- try {
140
- delay = timerDelay(timeoutMs);
141
- } catch (error) {
142
- return Promise.reject(error);
143
- }
144
- if (signal?.aborted) return Promise.reject(new AlpClientError(`Connecting to ${where} was aborted`, { reason: "aborted", cause: signal.reason }));
145
- const Constructor = Implementation ?? /** @type {any} */
146
- globalThis.WebSocket;
147
- if (!createSocket && typeof Constructor !== "function") return Promise.reject(new TypeError("No WebSocket implementation: pass options.WebSocket or options.createSocket"));
148
- let socket;
149
- try {
150
- socket = createSocket ? createSocket(url, protocols) : protocols === void 0 ? new Constructor(url) : new Constructor(url, protocols);
151
- } catch (error) {
152
- return Promise.reject(new AlpClientError(`Could not connect to ${where}`, { reason: "disconnected", cause: scrubbed(error, url) }));
153
- }
154
- absorbErrors(socket);
155
- return new Promise((resolve, reject) => {
156
- const detach = [];
157
- let timer;
158
- const settle = () => {
159
- for (const remove of detach.splice(0)) remove();
160
- if (timer !== void 0) clearTimeout(timer);
161
- signal?.removeEventListener("abort", onAbort);
162
- };
163
- const fail = (error) => {
164
- settle();
165
- release(socket);
166
- reject(error);
167
- };
168
- const onAbort = () => fail(new AlpClientError(`Connecting to ${where} was aborted`, { reason: "aborted", cause: signal?.reason }));
169
- const open = () => {
170
- settle();
171
- try {
172
- resolve(createWebSocketTransport(socket, options));
173
- } catch (error) {
174
- reject(error);
175
- }
176
- };
177
- if (socket.readyState === OPEN) return open();
178
- detach.push(listen(socket, "open", open));
179
- detach.push(listen(socket, "error", (event) => fail(new AlpClientError(`Could not connect to ${where}`, { reason: "disconnected", cause: scrubbed(errorOf(event), url) }))));
180
- detach.push(listen(socket, "close", (event) => fail(new AlpClientError(`Could not connect to ${where}`, { reason: "disconnected", data: { code: event?.code, reason: event?.reason || void 0 } }))));
181
- signal?.addEventListener("abort", onAbort, { once: true });
182
- if (delay !== void 0) timer = setTimeout(() => fail(new AlpClientError(`Connecting to ${where} timed out after ${timeoutMs} ms`, { reason: "timeout" })), delay);
183
- });
184
- }
185
- export {
186
- CLOSE_CODE,
187
- connectWebSocket,
188
- createWebSocketTransport,
189
- redactUrl
190
- };
@@ -1,7 +0,0 @@
1
- # @anhlp/alp-core
2
-
3
- Filesystem configuration, agent resolution, teams, tasks, permissions and shipped templates.
4
-
5
- Build: `npm run build --workspace=@anhlp/alp-core`. Test: `npm run test --workspace=@anhlp/alp-core`.
6
-
7
- Public imports use the package root and its explicitly exported subpaths. See [architecture, provider extension, compatibility and release instructions](../../docs/modular-monorepo.md).
@@ -1,20 +0,0 @@
1
- import type { ResolvedAgent } from './types.js';
2
- export type CapabilitySupport = 'native' | 'emulated' | 'unsupported';
3
- export interface AdapterCapabilities {
4
- instructions: CapabilitySupport;
5
- skills: CapabilitySupport;
6
- hooks: CapabilitySupport;
7
- mcp: CapabilitySupport;
8
- }
9
- export interface CompiledAgent<T = unknown> {
10
- adapterId: string;
11
- agentName: string;
12
- projectRoot: string;
13
- material: T;
14
- }
15
- export interface AlpRuntimeAdapter<T = unknown> {
16
- id: string;
17
- capabilities(): AdapterCapabilities;
18
- compile(agent: ResolvedAgent): Promise<CompiledAgent<T>>;
19
- }
20
- export function compileAgent<T>(adapter: AlpRuntimeAdapter<T>, agent: ResolvedAgent): Promise<CompiledAgent<T>>;
@@ -1,30 +0,0 @@
1
- // packages/core/src/adapter.js
2
- import { AlpError } from "./errors.js";
3
- import { validateResolvedAgent } from "./validation.js";
4
- async function compileAgent(adapter, agent) {
5
- if (!adapter || typeof adapter.id !== "string" || !adapter.id.trim() || typeof adapter.capabilities !== "function" || typeof adapter.compile !== "function") {
6
- throw new AlpError("INVALID_ADAPTER", "Adapter requires id, capabilities(), and compile()");
7
- }
8
- validateResolvedAgent(agent);
9
- const capabilities = adapter.capabilities();
10
- for (const key of ["instructions", "skills", "hooks", "mcp"]) {
11
- if (!["native", "emulated", "unsupported"].includes(capabilities?.[key])) throw new AlpError("INVALID_CAPABILITIES", `${adapter.id}: invalid ${key} capability`);
12
- }
13
- const required = {
14
- instructions: Boolean(agent.instructions.project || agent.instructions.agent),
15
- skills: agent.skills.length > 0,
16
- hooks: agent.hooks.length > 0,
17
- mcp: Object.keys(agent.mcp.mcpServers).length > 0
18
- };
19
- for (const [key, present] of Object.entries(required)) {
20
- if (present && capabilities[key] === "unsupported") throw new AlpError("UNSUPPORTED_CAPABILITY", `${adapter.id} does not support ${key} required by '${agent.name}'`);
21
- }
22
- const compiled = await adapter.compile(structuredClone(agent));
23
- if (!compiled || compiled.adapterId !== adapter.id || compiled.agentName !== agent.name || compiled.projectRoot !== agent.projectRoot || !Object.hasOwn(compiled, "material")) {
24
- throw new AlpError("INVALID_COMPILED_AGENT", `${adapter.id}: invalid compiled agent envelope`);
25
- }
26
- return compiled;
27
- }
28
- export {
29
- compileAgent
30
- };
@@ -1,2 +0,0 @@
1
- export function moveFile(from: string, to: string): Promise<void>;
2
- export function writeAtomic(file: string, body: string | Uint8Array, mode?: number): Promise<void>;
@@ -1,28 +0,0 @@
1
- // packages/core/src/atomic.js
2
- import { randomBytes } from "node:crypto";
3
- import { rename, rm, writeFile } from "node:fs/promises";
4
- async function moveFile(from, to) {
5
- for (let attempt = 0; ; attempt++) {
6
- try {
7
- return await rename(from, to);
8
- } catch (error) {
9
- if (process.platform !== "win32" || attempt >= 20 || !["EPERM", "EACCES", "EBUSY"].includes(error?.code)) throw error;
10
- await new Promise((resolve) => setTimeout(resolve, 10 + attempt * 10));
11
- }
12
- }
13
- }
14
- async function writeAtomic(file, body, mode = 384) {
15
- const temporary = `${file}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`;
16
- try {
17
- await writeFile(temporary, body, { mode });
18
- await moveFile(temporary, file);
19
- } catch (error) {
20
- await rm(temporary, { force: true }).catch(() => {
21
- });
22
- throw error;
23
- }
24
- }
25
- export {
26
- moveFile,
27
- writeAtomic
28
- };
@@ -1,27 +0,0 @@
1
- export const BACKUP_FORMAT: number;
2
- export const BACKUP_EXTENSION: string;
3
- export const STATE_UNITS: string[];
4
- export const CLEARED_UNITS: string[];
5
- export const HOME_UNITS: string[];
6
- export const PROJECT_UNITS: string[];
7
- export function backupsDir(home: string): string;
8
- export function knownProjects(home: string): Promise<string[]>;
9
- export type BackupSummary = { file: string; files: number; bytes: number; projects: string[]; stateSchema: number | null; sessions: number; tasks: number };
10
- export function createBackup(options: { home: string; out: string; units?: string[]; projects?: string[]; by?: string; kind?: string }): Promise<BackupSummary>;
11
- export function automaticBackup(home: string, kind: string, options?: { units?: string[]; projects?: string[]; by?: string }): Promise<string>;
12
- export type BackupContents = { file: string; kind: string; by?: string; createdAt: string; home: string; stateSchema: number | null; units: string[]; projects: string[]; sessions: number; tasks: number; files: number; bytes: number; external: number };
13
- export function verifyBackup(file: string): Promise<BackupContents>;
14
- export function recoverInterruptedRestore(home: string): Promise<{ outcome: 'rolled back' | 'completed'; file?: string; safety?: string } | undefined>;
15
- export type RestoreResult = {
16
- file: string;
17
- safety?: string;
18
- stateSchema: number | null;
19
- interrupted?: { outcome: 'rolled back' | 'completed'; file?: string; safety?: string };
20
- units: Array<{ area: string; unit: string; present: boolean }>;
21
- projects: string[];
22
- skipped: Array<{ root: string; reason: string }>;
23
- warnings: string[];
24
- };
25
- export function restoreBackup(options: { home: string; file: string; projects?: boolean; safety?: boolean; clearLive?: boolean; replaceNewer?: boolean; by?: string; beforeSwap?: (index: number, total: number) => Promise<void> | void }): Promise<RestoreResult>;
26
- export function readRestoredMarker(home: string): Promise<{ at?: string; from?: string; by?: string } | undefined>;
27
- export function clearRestoredMarker(home: string): Promise<void>;