@anhlp/alp-cli 0.0.0-beta.2 → 0.0.1-beta.10
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/THIRD-PARTY-NOTICES.txt +52 -2
- package/dist/acp/main.js +1 -1
- package/dist/acp.js +7802 -2239
- package/dist/alp-dashboard/THIRD-PARTY-NOTICES.txt +3256 -0
- package/dist/alp-dashboard/alp-boundary.json +16 -0
- package/dist/alp-dashboard/apple-touch-icon.png +0 -0
- package/dist/alp-dashboard/assets/TerminalPanel-D8HE9XBX.js +22 -0
- package/dist/alp-dashboard/assets/TerminalPanel-DLuoa74B.css +1 -0
- package/dist/alp-dashboard/assets/highlighter-BnicKQ_d.js +18 -0
- package/dist/alp-dashboard/assets/index-DwqDSiIi.css +1 -0
- package/dist/alp-dashboard/assets/index-YdtH3NBy.js +59 -0
- package/dist/alp-dashboard/favicon-attention.svg +6 -0
- package/dist/alp-dashboard/favicon-running.svg +6 -0
- package/dist/alp-dashboard/favicon.svg +5 -0
- package/dist/alp-dashboard/index.html +20 -0
- package/dist/alp-dashboard.js +10165 -0
- package/dist/alpd.js +39374 -17503
- package/dist/backup.js +2 -2
- package/dist/build-manifest.json +139 -3
- package/dist/cli.js +40 -6
- package/dist/daemon.d.ts +3 -3
- package/dist/daemon.js +16 -7
- package/dist/dashboard-migrate.d.ts +31 -0
- package/dist/dashboard-migrate.js +127 -0
- package/dist/dashboard-service.d.ts +69 -0
- package/dist/dashboard-service.js +141 -0
- package/dist/desktop.d.ts +56 -0
- package/dist/desktop.js +91 -0
- package/dist/interfaces.d.ts +23 -3
- package/dist/interfaces.js +277 -41
- package/dist/library.d.ts +16 -2
- package/dist/library.js +114 -7
- package/dist/paths.d.ts +6 -0
- package/dist/paths.js +4 -1
- package/dist/projects.js +2 -1
- package/dist/roles.d.ts +15 -0
- package/dist/roles.js +16 -0
- package/dist/schedules.d.ts +2 -0
- package/dist/schedules.js +45 -0
- package/dist/self-update.d.ts +151 -0
- package/dist/self-update.js +422 -0
- package/dist/sessions.d.ts +7 -2
- package/dist/sessions.js +44 -12
- package/dist/tasks.js +22 -8
- package/dist/terminal-native/README.md +201 -0
- package/dist/terminal-native/prebuilt/darwin-arm64/manifest.json +11 -0
- package/dist/terminal-native/prebuilt/darwin-arm64/terminal-owner +0 -0
- package/dist/terminal-native/prebuilt/darwin-x64/manifest.json +11 -0
- package/dist/terminal-native/prebuilt/darwin-x64/terminal-owner +0 -0
- package/dist/terminal-native/prebuilt/linux-arm64-glibc/manifest.json +10 -0
- package/dist/terminal-native/prebuilt/linux-arm64-glibc/terminal-owner +0 -0
- package/dist/terminal-native/prebuilt/linux-arm64-musl/manifest.json +10 -0
- package/dist/terminal-native/prebuilt/linux-arm64-musl/terminal-owner +0 -0
- package/dist/terminal-native/prebuilt/linux-x64-glibc/manifest.json +10 -0
- package/dist/terminal-native/prebuilt/linux-x64-glibc/terminal-owner +0 -0
- package/dist/terminal-native/prebuilt/linux-x64-musl/manifest.json +10 -0
- package/dist/terminal-native/prebuilt/linux-x64-musl/terminal-owner +0 -0
- package/dist/terminal-native/terminal-owner.c +389 -0
- package/dist/terminal.d.ts +13 -0
- package/dist/terminal.js +80 -0
- package/dist/usage.d.ts +1 -1
- package/dist/usage.js +31 -9
- package/package.json +11 -4
- package/src/backup.js +1 -1
- package/src/cli.js +51 -6
- package/src/daemon.js +18 -9
- package/src/dashboard-migrate.js +152 -0
- package/src/dashboard-service.js +192 -0
- package/src/desktop.js +122 -0
- package/src/interfaces.js +345 -38
- package/src/library.js +108 -9
- package/src/paths.js +9 -1
- package/src/projects.js +3 -1
- package/src/roles.js +26 -0
- package/src/schedules.js +38 -0
- package/src/self-update.js +443 -0
- package/src/sessions.js +44 -15
- package/src/tasks.js +22 -8
- package/src/terminal.js +78 -0
- package/src/usage.js +31 -9
package/dist/backup.js
CHANGED
|
@@ -7,7 +7,7 @@ import { acquireDaemonLock, alpHome, assertPrivateDirectory, daemonPaths, lockAl
|
|
|
7
7
|
import { daemonHeld, holdDaemon, releaseHold } from "@anhlp/alp-client/supervise";
|
|
8
8
|
import { start, stop } from "./daemon.js";
|
|
9
9
|
import { UsageError } from "./usage.js";
|
|
10
|
-
var VERSION = true ? "0.0.
|
|
10
|
+
var VERSION = true ? "0.0.1-beta.10" : "dev";
|
|
11
11
|
var BY = `alp ${VERSION}`;
|
|
12
12
|
var size = (bytes) => bytes >= 1024 * 1024 ? `${(bytes / 1024 / 1024).toFixed(1)} MB` : bytes >= 1024 ? `${(bytes / 1024).toFixed(1)} KB` : `${bytes} B`;
|
|
13
13
|
var stamp = () => (/* @__PURE__ */ new Date()).toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
|
|
@@ -138,7 +138,7 @@ async function restoreCommand(args) {
|
|
|
138
138
|
for (const { root, reason } of result.skipped) console.log(` skipped ${root}: ${reason}`);
|
|
139
139
|
for (const warning of result.warnings) console.log(` note: ${warning}`);
|
|
140
140
|
if (result.stateSchema !== null && result.stateSchema !== void 0) console.log(" sessions that were working when the backup was made wait for you; alpd continues none by itself");
|
|
141
|
-
if (result.safety) console.log(`the data it replaced is in ${result.safety}; alp restore ${result.safety}
|
|
141
|
+
if (result.safety) console.log(`the data it replaced is in ${result.safety}; alp restore ${result.safety} restores that data with the same workspace authority checks`);
|
|
142
142
|
}
|
|
143
143
|
export {
|
|
144
144
|
backupCommand,
|
package/dist/build-manifest.json
CHANGED
|
@@ -1,32 +1,41 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0.
|
|
2
|
+
"version": "0.0.1-beta.10",
|
|
3
3
|
"entries": {
|
|
4
4
|
"packages/cli/dist/alpd.js": {
|
|
5
5
|
"inputs": [
|
|
6
|
+
"packages/client/src/acp-probe.js",
|
|
6
7
|
"packages/client/src/index.js",
|
|
7
8
|
"packages/client/src/ipc.js",
|
|
9
|
+
"packages/client/src/mcp-probe.js",
|
|
8
10
|
"packages/client/src/portable.js",
|
|
9
11
|
"packages/client/src/rpc/client.js",
|
|
10
12
|
"packages/client/src/rpc/errors.js",
|
|
11
13
|
"packages/client/src/rpc/framing.js",
|
|
12
14
|
"packages/client/src/rpc/handshake.js",
|
|
13
15
|
"packages/client/src/rpc/reconnect.js",
|
|
16
|
+
"packages/client/src/rpc/registry.js",
|
|
17
|
+
"packages/client/src/rpc/terminal-directory.js",
|
|
14
18
|
"packages/client/src/rpc/timers.js",
|
|
15
19
|
"packages/client/src/websocket.js",
|
|
16
20
|
"packages/core/src/adapter.js",
|
|
17
21
|
"packages/core/src/atomic.js",
|
|
18
22
|
"packages/core/src/backup.js",
|
|
23
|
+
"packages/core/src/beads.js",
|
|
24
|
+
"packages/core/src/bridges.js",
|
|
19
25
|
"packages/core/src/delegation.js",
|
|
20
26
|
"packages/core/src/errors.js",
|
|
21
27
|
"packages/core/src/formulas.js",
|
|
28
|
+
"packages/core/src/gate-ledger.js",
|
|
22
29
|
"packages/core/src/hook-run.js",
|
|
23
30
|
"packages/core/src/hooks.js",
|
|
31
|
+
"packages/core/src/index.js",
|
|
24
32
|
"packages/core/src/init.js",
|
|
25
33
|
"packages/core/src/library-edit.js",
|
|
26
34
|
"packages/core/src/library.js",
|
|
27
35
|
"packages/core/src/log.js",
|
|
28
36
|
"packages/core/src/migrations.js",
|
|
29
37
|
"packages/core/src/models.js",
|
|
38
|
+
"packages/core/src/packaged.js",
|
|
30
39
|
"packages/core/src/permissions.js",
|
|
31
40
|
"packages/core/src/profiles.js",
|
|
32
41
|
"packages/core/src/promptsafe.js",
|
|
@@ -34,24 +43,42 @@
|
|
|
34
43
|
"packages/core/src/resolver.js",
|
|
35
44
|
"packages/core/src/safe-path.js",
|
|
36
45
|
"packages/core/src/shell.js",
|
|
46
|
+
"packages/core/src/skill-validate.js",
|
|
37
47
|
"packages/core/src/state-schema.js",
|
|
38
48
|
"packages/core/src/task-rows.js",
|
|
39
49
|
"packages/core/src/tasks.js",
|
|
40
50
|
"packages/core/src/teams.js",
|
|
41
51
|
"packages/core/src/template-path.js",
|
|
42
52
|
"packages/core/src/trust.js",
|
|
53
|
+
"packages/core/src/upgrade.js",
|
|
43
54
|
"packages/core/src/user-settings.js",
|
|
55
|
+
"packages/core/src/user-worktree.js",
|
|
44
56
|
"packages/core/src/validation.js",
|
|
45
57
|
"packages/core/src/verify.js",
|
|
46
58
|
"packages/core/src/workflow.js",
|
|
59
|
+
"packages/daemon/src/attachments.ts",
|
|
60
|
+
"packages/daemon/src/conversation.ts",
|
|
61
|
+
"packages/daemon/src/disk.ts",
|
|
47
62
|
"packages/daemon/src/files.ts",
|
|
63
|
+
"packages/daemon/src/git.ts",
|
|
48
64
|
"packages/daemon/src/gitignore.ts",
|
|
65
|
+
"packages/daemon/src/history.ts",
|
|
66
|
+
"packages/daemon/src/lifecycle.ts",
|
|
49
67
|
"packages/daemon/src/lock.ts",
|
|
50
68
|
"packages/daemon/src/main.ts",
|
|
69
|
+
"packages/daemon/src/model-catalog.ts",
|
|
70
|
+
"packages/daemon/src/native-terminal.ts",
|
|
51
71
|
"packages/daemon/src/operations.ts",
|
|
72
|
+
"packages/daemon/src/registry.ts",
|
|
52
73
|
"packages/daemon/src/rpc-error.ts",
|
|
74
|
+
"packages/daemon/src/scheduler.ts",
|
|
75
|
+
"packages/daemon/src/schedules.ts",
|
|
53
76
|
"packages/daemon/src/server.ts",
|
|
54
77
|
"packages/daemon/src/store.ts",
|
|
78
|
+
"packages/daemon/src/terminal-screen.ts",
|
|
79
|
+
"packages/daemon/src/terminals.ts",
|
|
80
|
+
"packages/daemon/src/windows-terminal.ts",
|
|
81
|
+
"packages/daemon/src/worktrees.ts",
|
|
55
82
|
"packages/protocol/src/contract-v1.js",
|
|
56
83
|
"packages/protocol/src/contract.js",
|
|
57
84
|
"packages/protocol/src/index.ts",
|
|
@@ -59,18 +86,26 @@
|
|
|
59
86
|
"packages/protocol/src/wire.js",
|
|
60
87
|
"packages/runtime/src/acp-transport.ts",
|
|
61
88
|
"packages/runtime/src/antigravity-transport.ts",
|
|
89
|
+
"packages/runtime/src/assignment-results.ts",
|
|
90
|
+
"packages/runtime/src/attachments.ts",
|
|
62
91
|
"packages/runtime/src/board-domain.ts",
|
|
63
92
|
"packages/runtime/src/board.ts",
|
|
64
93
|
"packages/runtime/src/catalog.ts",
|
|
65
94
|
"packages/runtime/src/claude-transport.ts",
|
|
95
|
+
"packages/runtime/src/compact.ts",
|
|
96
|
+
"packages/runtime/src/configure.ts",
|
|
66
97
|
"packages/runtime/src/contracts.ts",
|
|
98
|
+
"packages/runtime/src/conversation.ts",
|
|
67
99
|
"packages/runtime/src/github.ts",
|
|
68
100
|
"packages/runtime/src/handoff.ts",
|
|
69
101
|
"packages/runtime/src/index.ts",
|
|
102
|
+
"packages/runtime/src/input-limits.ts",
|
|
70
103
|
"packages/runtime/src/language.ts",
|
|
71
104
|
"packages/runtime/src/live.ts",
|
|
72
105
|
"packages/runtime/src/mailbox.ts",
|
|
73
106
|
"packages/runtime/src/mcp-tools.ts",
|
|
107
|
+
"packages/runtime/src/model-catalog.ts",
|
|
108
|
+
"packages/runtime/src/model-probes.ts",
|
|
74
109
|
"packages/runtime/src/permission-path.ts",
|
|
75
110
|
"packages/runtime/src/process-info.ts",
|
|
76
111
|
"packages/runtime/src/providers.ts",
|
|
@@ -79,13 +114,15 @@
|
|
|
79
114
|
"packages/runtime/src/runtime-context.ts",
|
|
80
115
|
"packages/runtime/src/runtime.ts",
|
|
81
116
|
"packages/runtime/src/session-config.ts",
|
|
117
|
+
"packages/runtime/src/skill-resources.ts",
|
|
82
118
|
"packages/runtime/src/tool-detail.ts",
|
|
83
119
|
"packages/runtime/src/tool-results.ts",
|
|
84
120
|
"packages/runtime/src/tools.ts",
|
|
85
121
|
"packages/runtime/src/transport.ts",
|
|
86
122
|
"packages/runtime/src/usage.ts",
|
|
87
123
|
"packages/runtime/src/workspace.ts",
|
|
88
|
-
"packages/runtime/src/worktree-domain.ts"
|
|
124
|
+
"packages/runtime/src/worktree-domain.ts",
|
|
125
|
+
"packages/runtime/src/write-error.ts"
|
|
89
126
|
],
|
|
90
127
|
"external": [
|
|
91
128
|
"child_process",
|
|
@@ -94,6 +131,7 @@
|
|
|
94
131
|
"node:crypto",
|
|
95
132
|
"node:fs",
|
|
96
133
|
"node:fs/promises",
|
|
134
|
+
"node:module",
|
|
97
135
|
"node:net",
|
|
98
136
|
"node:os",
|
|
99
137
|
"node:path",
|
|
@@ -102,6 +140,7 @@
|
|
|
102
140
|
"node:stream",
|
|
103
141
|
"node:stream/promises",
|
|
104
142
|
"node:string_decoder",
|
|
143
|
+
"node:timers/promises",
|
|
105
144
|
"node:url",
|
|
106
145
|
"node:zlib",
|
|
107
146
|
"path"
|
|
@@ -120,22 +159,119 @@
|
|
|
120
159
|
"packages/client/src/rpc/framing.js",
|
|
121
160
|
"packages/client/src/rpc/handshake.js",
|
|
122
161
|
"packages/client/src/rpc/reconnect.js",
|
|
162
|
+
"packages/client/src/rpc/registry.js",
|
|
163
|
+
"packages/client/src/rpc/terminal-directory.js",
|
|
123
164
|
"packages/client/src/rpc/timers.js",
|
|
124
165
|
"packages/client/src/service.js",
|
|
125
166
|
"packages/client/src/supervise.js",
|
|
126
167
|
"packages/client/src/websocket.js",
|
|
168
|
+
"packages/core/src/atomic.js",
|
|
169
|
+
"packages/core/src/errors.js",
|
|
170
|
+
"packages/core/src/log.js",
|
|
171
|
+
"packages/core/src/models.js",
|
|
172
|
+
"packages/core/src/packaged.js",
|
|
173
|
+
"packages/core/src/permissions.js",
|
|
174
|
+
"packages/core/src/shell.js",
|
|
175
|
+
"packages/core/src/user-settings.js",
|
|
176
|
+
"packages/core/src/validation.js",
|
|
177
|
+
"packages/core/src/verify.js",
|
|
178
|
+
"packages/protocol/src/index.ts",
|
|
179
|
+
"packages/protocol/src/wire.js"
|
|
180
|
+
],
|
|
181
|
+
"external": [
|
|
182
|
+
"node:child_process",
|
|
183
|
+
"node:crypto",
|
|
184
|
+
"node:fs",
|
|
185
|
+
"node:fs/promises",
|
|
186
|
+
"node:net",
|
|
187
|
+
"node:os",
|
|
188
|
+
"node:path",
|
|
189
|
+
"node:stream",
|
|
190
|
+
"node:timers/promises"
|
|
191
|
+
]
|
|
192
|
+
},
|
|
193
|
+
"packages/cli/dist/alp-dashboard.js": {
|
|
194
|
+
"inputs": [
|
|
195
|
+
"apps/gateway/src/config.js",
|
|
196
|
+
"apps/gateway/src/connection.js",
|
|
197
|
+
"apps/gateway/src/credentials.js",
|
|
198
|
+
"apps/gateway/src/index.js",
|
|
199
|
+
"apps/gateway/src/log.js",
|
|
200
|
+
"apps/gateway/src/policy.js",
|
|
201
|
+
"apps/gateway/src/server.js",
|
|
202
|
+
"apps/gateway/src/tickets.js",
|
|
203
|
+
"apps/gateway/src/upstream.js",
|
|
204
|
+
"packages/cli/src/dashboard/grant.js",
|
|
205
|
+
"packages/cli/src/dashboard/main.js",
|
|
206
|
+
"packages/cli/src/dashboard/serve.js",
|
|
207
|
+
"packages/client/src/command.js",
|
|
208
|
+
"packages/client/src/index.js",
|
|
209
|
+
"packages/client/src/integration-lock.js",
|
|
210
|
+
"packages/client/src/ipc.js",
|
|
211
|
+
"packages/client/src/portable.js",
|
|
212
|
+
"packages/client/src/rpc/client.js",
|
|
213
|
+
"packages/client/src/rpc/errors.js",
|
|
214
|
+
"packages/client/src/rpc/framing.js",
|
|
215
|
+
"packages/client/src/rpc/handshake.js",
|
|
216
|
+
"packages/client/src/rpc/reconnect.js",
|
|
217
|
+
"packages/client/src/rpc/registry.js",
|
|
218
|
+
"packages/client/src/rpc/terminal-directory.js",
|
|
219
|
+
"packages/client/src/rpc/timers.js",
|
|
220
|
+
"packages/client/src/service.js",
|
|
221
|
+
"packages/client/src/supervise.js",
|
|
222
|
+
"packages/client/src/websocket.js",
|
|
223
|
+
"packages/core/src/atomic.js",
|
|
224
|
+
"packages/core/src/errors.js",
|
|
225
|
+
"packages/core/src/gate-ledger.js",
|
|
226
|
+
"packages/core/src/library-edit.js",
|
|
227
|
+
"packages/core/src/library.js",
|
|
127
228
|
"packages/core/src/log.js",
|
|
229
|
+
"packages/core/src/models.js",
|
|
230
|
+
"packages/core/src/packaged.js",
|
|
231
|
+
"packages/core/src/permissions.js",
|
|
232
|
+
"packages/core/src/providers.js",
|
|
233
|
+
"packages/core/src/resolver.js",
|
|
234
|
+
"packages/core/src/safe-path.js",
|
|
235
|
+
"packages/core/src/shell.js",
|
|
236
|
+
"packages/core/src/skill-validate.js",
|
|
237
|
+
"packages/core/src/tasks.js",
|
|
238
|
+
"packages/core/src/teams.js",
|
|
239
|
+
"packages/core/src/template-path.js",
|
|
240
|
+
"packages/core/src/user-settings.js",
|
|
241
|
+
"packages/core/src/validation.js",
|
|
242
|
+
"packages/core/src/verify.js",
|
|
243
|
+
"packages/protocol/src/contract-v1.js",
|
|
244
|
+
"packages/protocol/src/contract.js",
|
|
128
245
|
"packages/protocol/src/index.ts",
|
|
246
|
+
"packages/protocol/src/validate.js",
|
|
129
247
|
"packages/protocol/src/wire.js"
|
|
130
248
|
],
|
|
131
249
|
"external": [
|
|
250
|
+
"buffer",
|
|
251
|
+
"bufferutil",
|
|
252
|
+
"crypto",
|
|
253
|
+
"events",
|
|
254
|
+
"http",
|
|
255
|
+
"https",
|
|
256
|
+
"net",
|
|
132
257
|
"node:child_process",
|
|
133
258
|
"node:crypto",
|
|
259
|
+
"node:fs",
|
|
134
260
|
"node:fs/promises",
|
|
261
|
+
"node:http",
|
|
262
|
+
"node:https",
|
|
135
263
|
"node:net",
|
|
136
264
|
"node:os",
|
|
137
265
|
"node:path",
|
|
138
|
-
"node:
|
|
266
|
+
"node:timers/promises",
|
|
267
|
+
"node:url",
|
|
268
|
+
"node:util",
|
|
269
|
+
"stream",
|
|
270
|
+
"tls",
|
|
271
|
+
"url",
|
|
272
|
+
"utf-8-validate",
|
|
273
|
+
"util",
|
|
274
|
+
"zlib"
|
|
139
275
|
]
|
|
140
276
|
}
|
|
141
277
|
}
|
package/dist/cli.js
CHANGED
|
@@ -4,19 +4,53 @@
|
|
|
4
4
|
import { setup } from "@anhlp/alp-client/setup";
|
|
5
5
|
import { alpHome } from "@anhlp/alp-client/index";
|
|
6
6
|
import { scrubText } from "@anhlp/alp-core/log";
|
|
7
|
+
import { catalogModels, useLiveModels } from "@anhlp/alp-core/models";
|
|
7
8
|
import { USAGE, UsageError } from "./usage.js";
|
|
8
9
|
import { project, permissionsCommand, trustCommand, language, verify, doctor } from "./projects.js";
|
|
9
10
|
import { daemon } from "./daemon.js";
|
|
10
|
-
import { run, ps, attach, send, questions, answer, top, log, board, pause, resume, recall, interrupt } from "./sessions.js";
|
|
11
|
-
import { libraryCommand, editCommand, teamsCommand } from "./library.js";
|
|
11
|
+
import { run, ps, attach, send, questions, answer, top, log, board, models, pause, resume, recall, interrupt, compact } from "./sessions.js";
|
|
12
|
+
import { libraryCommand, editCommand, teamsCommand, packsCommand, packCommand } from "./library.js";
|
|
13
|
+
import { scheduleCommand } from "./schedules.js";
|
|
12
14
|
import { tasksCommand, formulaCommand, taskCommand } from "./tasks.js";
|
|
13
|
-
import {
|
|
15
|
+
import { dashboardCommand, acpCommand } from "./interfaces.js";
|
|
16
|
+
import { desktopCommand } from "./desktop.js";
|
|
14
17
|
import { backupCommand, restoreCommand } from "./backup.js";
|
|
15
|
-
|
|
18
|
+
import { terminalCommand } from "./terminal.js";
|
|
19
|
+
import { bridgeCommand } from "./roles.js";
|
|
20
|
+
import { selfUpdate } from "./self-update.js";
|
|
21
|
+
import { bundleInfo } from "@anhlp/alp-core/packaged";
|
|
22
|
+
import { connect, lockAlive, readLock } from "@anhlp/alp-client/index";
|
|
23
|
+
function alpVersion() {
|
|
24
|
+
return true ? "0.0.1-beta.10" : JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
|
|
25
|
+
}
|
|
26
|
+
async function runningDaemon() {
|
|
27
|
+
const lock = await readLock(alpHome());
|
|
28
|
+
if (!lockAlive(lock)) return void 0;
|
|
29
|
+
const client = await connect(lock.socket, { name: "alp-cli", version: "1" }).catch(() => void 0);
|
|
30
|
+
if (!client) return { version: lock.version };
|
|
31
|
+
try {
|
|
32
|
+
const status = await client.request("daemon.status");
|
|
33
|
+
return { version: status.version ?? lock.version, sessions: status.sessions };
|
|
34
|
+
} catch {
|
|
35
|
+
return { version: lock.version };
|
|
36
|
+
} finally {
|
|
37
|
+
client.close();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async function updateCommand(args2) {
|
|
41
|
+
const code = await selfUpdate(args2, { bundle: bundleInfo(), version: alpVersion(), daemon: runningDaemon });
|
|
42
|
+
if (code) process.exitCode = code;
|
|
43
|
+
}
|
|
44
|
+
var commands = { schedule: scheduleCommand, setup: (args2) => setup(args2, alpHome()), init: (args2) => project("init", args2), "update-template": (args2) => project("upgrade", args2), upgrade: (args2) => project("upgrade", args2), update: updateCommand, daemon, doctor, run, ps, top, attach, send, questions, answer, log, board, tasks: tasksCommand, task: taskCommand, formula: formulaCommand, permissions: permissionsCommand, agents: (args2) => libraryCommand("agents", args2), skills: (args2) => libraryCommand("skills", args2), mcp: (args2) => ["add", "rm", "mv", "cp", "test", "show", "edit"].includes(args2[0]) ? editCommand("mcp", args2) : libraryCommand("mcp", args2), hooks: (args2) => libraryCommand("hooks", args2), providers: (args2) => libraryCommand("providers", args2), provider: (args2) => editCommand("providers", args2), teams: teamsCommand, packs: packsCommand, pack: packCommand, trust: trustCommand, agent: (args2) => editCommand("agents", args2), team: (args2) => editCommand("teams", args2), skill: (args2) => editCommand("skills", args2), hook: (args2) => editCommand("hooks", args2), verify, recall, pause, resume, language, models, interrupt, compact, acp: acpCommand, dashboard: dashboardCommand, desktop: desktopCommand, backup: backupCommand, restore: restoreCommand, terminal: terminalCommand, bridge: bridgeCommand };
|
|
16
45
|
var [command, ...args] = process.argv.slice(2);
|
|
17
46
|
try {
|
|
18
|
-
if (
|
|
19
|
-
|
|
47
|
+
if (command === "--version") {
|
|
48
|
+
console.log(alpVersion());
|
|
49
|
+
} else {
|
|
50
|
+
if (!Object.hasOwn(commands, command)) throw new UsageError();
|
|
51
|
+
if (command !== "setup") useLiveModels(catalogModels(alpHome()));
|
|
52
|
+
await commands[command](args);
|
|
53
|
+
}
|
|
20
54
|
} catch (error) {
|
|
21
55
|
if (error instanceof UsageError || error?.code === "ERR_PARSE_ARGS_UNKNOWN_OPTION") console.error(USAGE);
|
|
22
56
|
else console.error(`alp: ${scrubText(error?.message ?? error)}`);
|
package/dist/daemon.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export function built(): Promise<void>;
|
|
2
|
-
/** Waits until an alpd for this home is ready; returns its socket. */
|
|
1
|
+
export function built(entry?: string): Promise<void>;
|
|
2
|
+
/** Waits until an alpd for this home is ready; returns its socket. Default wait: ALP_DAEMON_START_TIMEOUT_MS, else 60 s. */
|
|
3
3
|
export function ready(timeoutMs?: number): Promise<any>;
|
|
4
4
|
/** The installed service for this ALP_HOME, if any. */
|
|
5
5
|
export function installed(): Promise<{
|
|
@@ -32,4 +32,4 @@ export function start(): Promise<string>;
|
|
|
32
32
|
/** Connects to a running daemon without starting one. */
|
|
33
33
|
export function running(): Promise<import("@anhlp/alp-client/index").AlpClient>;
|
|
34
34
|
export function stop(): Promise<boolean>;
|
|
35
|
-
export function daemon([action, ...rest]: [any, ...any[]]): Promise<
|
|
35
|
+
export function daemon([action, ...rest]: [any, ...any[]]): Promise<any>;
|
package/dist/daemon.js
CHANGED
|
@@ -3,18 +3,19 @@ import { access } from "node:fs/promises";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { installedProgram, installService, serviceFor, uninstallService } from "@anhlp/alp-client/service";
|
|
5
5
|
import { holdDaemon, startDaemon } from "@anhlp/alp-client/supervise";
|
|
6
|
-
import { alpHome, connect, lockAlive, readLock } from "@anhlp/alp-client/index";
|
|
6
|
+
import { alpHome, connect, daemonStartTimeoutMs, lockAlive, readLock, withDaemonLifecycle } from "@anhlp/alp-client/index";
|
|
7
7
|
import { scrubText } from "@anhlp/alp-core/log";
|
|
8
8
|
import { UsageError } from "./usage.js";
|
|
9
|
-
import { DAEMON_ENTRY } from "./paths.js";
|
|
10
|
-
|
|
9
|
+
import { DAEMON_ENTRY, DAEMON_SCRIPT } from "./paths.js";
|
|
10
|
+
import { runRole } from "./roles.js";
|
|
11
|
+
async function built(entry = DAEMON_ENTRY) {
|
|
11
12
|
try {
|
|
12
|
-
await access(
|
|
13
|
+
await access(entry);
|
|
13
14
|
} catch {
|
|
14
|
-
throw new Error(`alpd is not built (${
|
|
15
|
+
throw new Error(`alpd is not built (${entry}); run npm run build`);
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
|
-
async function ready(timeoutMs =
|
|
18
|
+
async function ready(timeoutMs = daemonStartTimeoutMs()) {
|
|
18
19
|
const deadline = Date.now() + timeoutMs;
|
|
19
20
|
while (Date.now() < deadline) {
|
|
20
21
|
const lock = await readLock(alpHome());
|
|
@@ -46,14 +47,22 @@ async function stop() {
|
|
|
46
47
|
return true;
|
|
47
48
|
}
|
|
48
49
|
async function daemon([action, ...rest]) {
|
|
50
|
+
if (action === "run") {
|
|
51
|
+
await built(DAEMON_SCRIPT);
|
|
52
|
+
return runRole("daemon", DAEMON_SCRIPT, rest);
|
|
53
|
+
}
|
|
49
54
|
if (rest.length && !(action === "status" && rest.length === 1 && rest[0] === "--json")) throw new UsageError();
|
|
50
55
|
if (action === "start") {
|
|
51
56
|
const socket = await start();
|
|
52
57
|
const lock = await readLock(alpHome());
|
|
53
58
|
console.log(`alpd ${lock.version} running (pid ${lock.pid}) on ${socket}`);
|
|
54
59
|
} else if (action === "stop") {
|
|
55
|
-
const stopped = await stop();
|
|
56
60
|
await holdDaemon(alpHome());
|
|
61
|
+
const stopped = await withDaemonLifecycle(alpHome(), "stop", async () => {
|
|
62
|
+
const stopped2 = await stop();
|
|
63
|
+
await holdDaemon(alpHome());
|
|
64
|
+
return stopped2;
|
|
65
|
+
});
|
|
57
66
|
console.log(stopped ? `alpd stopped; it stays stopped until alp daemon start, a prompt in Paseo, or ${await installed() ? "the next login" : "Paseo starting again"}` : "alpd is not running");
|
|
58
67
|
} else if (action === "restart") {
|
|
59
68
|
const client = await running().catch(() => void 0);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {string} home
|
|
3
|
+
* @param {{ strict?: boolean }} [options] strict: a legacy holder alp cannot stop is an error (a start
|
|
4
|
+
* would otherwise lose its port to it); without it, it is reported and the files are left alone.
|
|
5
|
+
* @returns {Promise<{ stopped?: number, held?: boolean, moved: string[], kept: string[], warnings: string[] }>}
|
|
6
|
+
* held: a legacy holder alp would not stop is still running (only without strict).
|
|
7
|
+
*/
|
|
8
|
+
export function migrateDashboard(home: string, { strict }?: {
|
|
9
|
+
strict?: boolean;
|
|
10
|
+
}): Promise<{
|
|
11
|
+
stopped?: number;
|
|
12
|
+
held?: boolean;
|
|
13
|
+
moved: string[];
|
|
14
|
+
kept: string[];
|
|
15
|
+
warnings: string[];
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* What a home still has under the names from before the rename, without changing anything (for
|
|
19
|
+
* `alp dashboard --status`): `pending` the next `alp dashboard` moves, `kept` it leaves because the
|
|
20
|
+
* new name exists, and the legacy service if one runs.
|
|
21
|
+
* @param {string} home
|
|
22
|
+
* @returns {Promise<{ legacy?: { pid?: number, reason?: string }, pending: string[], kept: string[] }>}
|
|
23
|
+
*/
|
|
24
|
+
export function legacyLeftovers(home: string): Promise<{
|
|
25
|
+
legacy?: {
|
|
26
|
+
pid?: number;
|
|
27
|
+
reason?: string;
|
|
28
|
+
};
|
|
29
|
+
pending: string[];
|
|
30
|
+
kept: string[];
|
|
31
|
+
}>;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// packages/cli/src/dashboard-migrate.js
|
|
2
|
+
import { randomBytes } from "node:crypto";
|
|
3
|
+
import { chmod, link, lstat, readFile, rename, unlink, writeFile } from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { migrateDashboardSettings } from "@anhlp/alp-core/user-settings";
|
|
6
|
+
import { DASHBOARD, LEGACY_WEB, refusal, serviceOwner, stopService } from "./dashboard-service.js";
|
|
7
|
+
var exists = (file) => lstat(file).then(() => true, () => false);
|
|
8
|
+
var readJson = (file) => readFile(file, "utf8").then((text) => {
|
|
9
|
+
try {
|
|
10
|
+
return JSON.parse(text);
|
|
11
|
+
} catch {
|
|
12
|
+
return void 0;
|
|
13
|
+
}
|
|
14
|
+
}, () => void 0);
|
|
15
|
+
var code = (error) => (
|
|
16
|
+
/** @type {any} */
|
|
17
|
+
error?.code
|
|
18
|
+
);
|
|
19
|
+
async function migrateDashboard(home, { strict = false } = {}) {
|
|
20
|
+
const report = { moved: [], kept: [], warnings: [] };
|
|
21
|
+
const owner = await serviceOwner(home, LEGACY_WEB);
|
|
22
|
+
if ("pid" in owner || owner.alive && owner.kind === "transient") {
|
|
23
|
+
try {
|
|
24
|
+
report.stopped = await stopService(home, 3e4, LEGACY_WEB);
|
|
25
|
+
} catch (error) {
|
|
26
|
+
if (strict) throw error;
|
|
27
|
+
report.warnings.push(
|
|
28
|
+
/** @type {any} */
|
|
29
|
+
error?.message ?? String(error)
|
|
30
|
+
);
|
|
31
|
+
report.held = true;
|
|
32
|
+
return report;
|
|
33
|
+
}
|
|
34
|
+
} else if (owner.alive) {
|
|
35
|
+
const message = `${refusal(home, LEGACY_WEB)} (${owner.reason}); stop it, then run the command again`;
|
|
36
|
+
if (strict) throw new Error(message);
|
|
37
|
+
report.warnings.push(message);
|
|
38
|
+
report.held = true;
|
|
39
|
+
return report;
|
|
40
|
+
}
|
|
41
|
+
const oldStore = path.join(home, "web");
|
|
42
|
+
const newStore = path.join(home, "dashboard");
|
|
43
|
+
if (await exists(path.join(oldStore, "credentials.json"))) {
|
|
44
|
+
if (await exists(newStore)) report.kept.push(oldStore);
|
|
45
|
+
else {
|
|
46
|
+
try {
|
|
47
|
+
await rename(oldStore, newStore);
|
|
48
|
+
report.moved.push(`${oldStore} -> ${newStore}`);
|
|
49
|
+
} catch (error) {
|
|
50
|
+
if (!["ENOENT", "EEXIST", "ENOTEMPTY"].includes(code(error))) throw error;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const oldInfo = path.join(home, LEGACY_WEB.info);
|
|
55
|
+
const newInfo = path.join(home, DASHBOARD.info);
|
|
56
|
+
const published = await readJson(oldInfo);
|
|
57
|
+
if (published?.app === LEGACY_WEB.app) {
|
|
58
|
+
const carriedAlready = async () => typeof published.token === "string" && published.token !== "" && (await readJson(newInfo))?.token === published.token;
|
|
59
|
+
const removeOld = () => unlink(oldInfo).catch((error) => {
|
|
60
|
+
if (code(error) !== "ENOENT") throw error;
|
|
61
|
+
});
|
|
62
|
+
if (await exists(newInfo)) {
|
|
63
|
+
if (await carriedAlready()) await removeOld();
|
|
64
|
+
else report.kept.push(oldInfo);
|
|
65
|
+
} else {
|
|
66
|
+
const carried = { version: published.version, app: DASHBOARD.app, token: published.token, credentialId: published.credentialId };
|
|
67
|
+
const temporary = `${newInfo}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`;
|
|
68
|
+
try {
|
|
69
|
+
await writeFile(temporary, `${JSON.stringify(carried)}
|
|
70
|
+
`, { mode: 384, flag: "wx" });
|
|
71
|
+
await chmod(temporary, 384);
|
|
72
|
+
const linked = await link(temporary, newInfo).then(() => true, (error) => {
|
|
73
|
+
if (code(error) !== "EEXIST") throw error;
|
|
74
|
+
return false;
|
|
75
|
+
});
|
|
76
|
+
if (linked) {
|
|
77
|
+
report.moved.push(`${oldInfo} -> ${newInfo}`);
|
|
78
|
+
await removeOld();
|
|
79
|
+
} else if (await carriedAlready()) await removeOld();
|
|
80
|
+
else report.kept.push(oldInfo);
|
|
81
|
+
} finally {
|
|
82
|
+
await unlink(temporary).catch(() => {
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const logs = path.join(home, "logs", "integrations");
|
|
88
|
+
const oldLog = path.join(logs, "alp-web.log");
|
|
89
|
+
const newLog = path.join(logs, "alp-dashboard.log");
|
|
90
|
+
if (await exists(oldLog) && !await exists(newLog)) {
|
|
91
|
+
await rename(oldLog, newLog).then(() => report.moved.push(`${oldLog} -> ${newLog}`), (error) => {
|
|
92
|
+
if (code(error) !== "ENOENT") throw error;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
const settings = await migrateDashboardSettings(home);
|
|
97
|
+
for (const key of settings.moved) report.moved.push(`settings.json web.${key} -> dashboard.${key}`);
|
|
98
|
+
for (const key of settings.conflicts) report.kept.push(`settings.json web.${key} (dashboard.${key} is set and wins)`);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
report.warnings.push(`settings.json was not migrated (web.* is still read): ${/** @type {any} */
|
|
101
|
+
error?.message ?? error}`);
|
|
102
|
+
}
|
|
103
|
+
return report;
|
|
104
|
+
}
|
|
105
|
+
async function legacyLeftovers(home) {
|
|
106
|
+
const result = { pending: [], kept: [] };
|
|
107
|
+
const owner = await serviceOwner(home, LEGACY_WEB);
|
|
108
|
+
if ("pid" in owner) result.legacy = { pid: owner.pid };
|
|
109
|
+
else if (owner.alive) result.legacy = { reason: owner.reason };
|
|
110
|
+
const place = async (old, current) => (await exists(current) ? result.kept : result.pending).push(old);
|
|
111
|
+
if (await exists(path.join(home, "web", "credentials.json"))) await place(path.join(home, "web"), path.join(home, "dashboard"));
|
|
112
|
+
const published = await readJson(path.join(home, LEGACY_WEB.info));
|
|
113
|
+
if (published?.app === LEGACY_WEB.app) await place(path.join(home, LEGACY_WEB.info), path.join(home, DASHBOARD.info));
|
|
114
|
+
const logs = path.join(home, "logs", "integrations");
|
|
115
|
+
if (await exists(path.join(logs, "alp-web.log"))) await place(path.join(logs, "alp-web.log"), path.join(logs, "alp-dashboard.log"));
|
|
116
|
+
const settings = await readJson(path.join(home, "settings.json"));
|
|
117
|
+
for (const key of ["enabled", "port", "permissions"]) {
|
|
118
|
+
if (settings?.web?.[key] === void 0) continue;
|
|
119
|
+
if (settings?.dashboard?.[key] !== void 0) result.kept.push(`settings.json web.${key} (dashboard.${key} is set and wins)`);
|
|
120
|
+
else result.pending.push(`settings.json web.${key}`);
|
|
121
|
+
}
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
export {
|
|
125
|
+
legacyLeftovers,
|
|
126
|
+
migrateDashboard
|
|
127
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** The alp-dashboard service script beside this CLI; a clear error when this CLI was built without it. */
|
|
2
|
+
export function dashboardScript(): string;
|
|
3
|
+
/**
|
|
4
|
+
* The process that owns `service`'s lock, if it is proven safe to stop; else why not. `kind` says
|
|
5
|
+
* whether waiting can help: `transient` (an owner still starting has not published its file yet),
|
|
6
|
+
* `foreign` (proven not to be the integration: another user's, another boot's, or a reused pid) or
|
|
7
|
+
* `unknown` (it cannot be proven either way, for example without ps or on Windows).
|
|
8
|
+
*
|
|
9
|
+
* The reuse proof compares the lock's creation time with the process's start from ps: when
|
|
10
|
+
* `startedUptime` is recorded, monotonic uptime comparison prevents clock step vulnerabilities.
|
|
11
|
+
* For legacy locks, wall-clock `startedAt` is compared.
|
|
12
|
+
* @param {string} home @param {Service} [service]
|
|
13
|
+
* @returns {Promise<{ pid: number, app: unknown } | { reason: string, alive: boolean, kind?: 'transient' | 'foreign' | 'unknown' }>}
|
|
14
|
+
*/
|
|
15
|
+
export function serviceOwner(home: string, service?: Service): Promise<{
|
|
16
|
+
pid: number;
|
|
17
|
+
app: unknown;
|
|
18
|
+
} | {
|
|
19
|
+
reason: string;
|
|
20
|
+
alive: boolean;
|
|
21
|
+
kind?: "transient" | "foreign" | "unknown";
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Stops whatever runs as `service` (alp dashboard; for LEGACY_WEB, alp web from before the rename or
|
|
25
|
+
* the Paseo integration from before its own), waiting up to `timeoutMs` for a starting owner to
|
|
26
|
+
* publish what proves it. Resolves with the pid it stopped, or undefined once no live process owns
|
|
27
|
+
* the lock; refuses at once an owner that is foreign or cannot be proven.
|
|
28
|
+
* @param {string} home @param {number} [timeoutMs] @param {Service} [service]
|
|
29
|
+
*/
|
|
30
|
+
export function stopService(home: string, timeoutMs?: number, service?: Service): Promise<number | undefined>;
|
|
31
|
+
/** The opening of the message for a lock held by a process alp would not stop. @param {string} home @param {Service} [service] */
|
|
32
|
+
export function refusal(home: string, service?: Service): string;
|
|
33
|
+
/**
|
|
34
|
+
* Probes whether the published dashboard URL is live and answering requests.
|
|
35
|
+
* Accepts only loopback HTTP/HTTPS addresses.
|
|
36
|
+
* @param {string | undefined} url
|
|
37
|
+
* @param {number} [timeoutMs]
|
|
38
|
+
*/
|
|
39
|
+
export function isDashboardReady(url: string | undefined, timeoutMs?: number): Promise<boolean>;
|
|
40
|
+
/**
|
|
41
|
+
* Whether the published file is genuinely claimed by a live alp-dashboard process.
|
|
42
|
+
* If the process is proven foreign (e.g. a reused PID or from another boot) or
|
|
43
|
+
* the URL does not answer HTTP requests, it is never claimed.
|
|
44
|
+
* @param {any} published
|
|
45
|
+
* @param {number | undefined} lockPid
|
|
46
|
+
* @param {any} held
|
|
47
|
+
* @param {number} [timeoutMs]
|
|
48
|
+
*/
|
|
49
|
+
export function isServiceClaimed(published: any, lockPid: number | undefined, held: any, timeoutMs?: number): Promise<boolean>;
|
|
50
|
+
export function dashboardEntry(): string;
|
|
51
|
+
/**
|
|
52
|
+
* @typedef {{ lock: string, info: string, app: string, what: string }} Service
|
|
53
|
+
* The integration lock's name, the file the service publishes, the `app` it writes there, and what
|
|
54
|
+
* messages call it.
|
|
55
|
+
*/
|
|
56
|
+
/** @type {Service} */
|
|
57
|
+
export const DASHBOARD: Service;
|
|
58
|
+
/** alp web as 0.0.1-beta.8 and earlier ran it (and, before that, the Paseo integration). @type {Service} */
|
|
59
|
+
export const LEGACY_WEB: Service;
|
|
60
|
+
/**
|
|
61
|
+
* The integration lock's name, the file the service publishes, the `app` it writes there, and what
|
|
62
|
+
* messages call it.
|
|
63
|
+
*/
|
|
64
|
+
export type Service = {
|
|
65
|
+
lock: string;
|
|
66
|
+
info: string;
|
|
67
|
+
app: string;
|
|
68
|
+
what: string;
|
|
69
|
+
};
|