@anhlp/alp-cli 0.0.0-beta.2 → 0.0.1-beta.4
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 +25 -0
- package/dist/acp/main.js +1 -1
- package/dist/acp.js +139 -23
- package/dist/alp-web/THIRD-PARTY-NOTICES.txt +2590 -0
- package/dist/alp-web/alp-boundary.json +15 -0
- package/dist/alp-web/apple-touch-icon.png +0 -0
- package/dist/alp-web/assets/TerminalPanel-DLuoa74B.css +1 -0
- package/dist/alp-web/assets/TerminalPanel-PrU2l3u5.js +16 -0
- package/dist/alp-web/assets/index-BJdBTDFX.css +1 -0
- package/dist/alp-web/assets/index-DpfiPv5s.js +52 -0
- package/dist/alp-web/favicon-attention.svg +6 -0
- package/dist/alp-web/favicon-running.svg +6 -0
- package/dist/alp-web/favicon.svg +5 -0
- package/dist/alp-web/index.html +20 -0
- package/dist/alp-web.js +9640 -0
- package/dist/alpd.js +10897 -3514
- package/dist/backup.js +2 -2
- package/dist/build-manifest.json +99 -1
- package/dist/cli.js +9 -3
- package/dist/daemon.js +6 -2
- package/dist/interfaces.d.ts +9 -1
- package/dist/interfaces.js +99 -39
- package/dist/schedules.d.ts +2 -0
- package/dist/schedules.js +45 -0
- package/dist/sessions.d.ts +3 -1
- package/dist/sessions.js +22 -11
- package/dist/terminal.d.ts +8 -0
- package/dist/terminal.js +79 -0
- package/dist/usage.d.ts +1 -1
- package/dist/usage.js +8 -2
- package/dist/web-service.d.ts +38 -0
- package/dist/web-service.js +119 -0
- package/package.json +10 -4
- package/src/backup.js +1 -1
- package/src/cli.js +12 -3
- package/src/daemon.js +8 -3
- package/src/interfaces.js +136 -31
- package/src/schedules.js +38 -0
- package/src/sessions.js +21 -11
- package/src/terminal.js +77 -0
- package/src/usage.js +8 -2
- package/src/web/grant.js +204 -0
- package/src/web/main.js +285 -0
- package/src/web/serve.js +144 -0
- package/src/web-service.js +143 -0
|
@@ -579,6 +579,31 @@ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
579
579
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
|
580
580
|
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
581
581
|
|
|
582
|
+
================================================================================
|
|
583
|
+
ws@8.22.0 (MIT)
|
|
584
|
+
================================================================================
|
|
585
|
+
|
|
586
|
+
Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com>
|
|
587
|
+
Copyright (c) 2013 Arnout Kazemier and contributors
|
|
588
|
+
Copyright (c) 2016 Luigi Pinca and contributors
|
|
589
|
+
|
|
590
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
591
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
592
|
+
the Software without restriction, including without limitation the rights to
|
|
593
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
594
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
595
|
+
subject to the following conditions:
|
|
596
|
+
|
|
597
|
+
The above copyright notice and this permission notice shall be included in all
|
|
598
|
+
copies or substantial portions of the Software.
|
|
599
|
+
|
|
600
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
601
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
602
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
603
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
604
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
605
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
606
|
+
|
|
582
607
|
================================================================================
|
|
583
608
|
zod@4.4.3 (MIT)
|
|
584
609
|
================================================================================
|
package/dist/acp/main.js
CHANGED
|
@@ -6,7 +6,7 @@ import { startDaemon } from "@anhlp/alp-client/supervise";
|
|
|
6
6
|
import { createLogger } from "@anhlp/alp-core/log";
|
|
7
7
|
import { createAcpAgent } from "./agent.js";
|
|
8
8
|
async function runAcp({ daemonEntry }) {
|
|
9
|
-
const version = true ? "0.0.
|
|
9
|
+
const version = true ? "0.0.1-beta.4" : "0.0.0";
|
|
10
10
|
const logger = createLogger({ component: "acp" });
|
|
11
11
|
const log = (message, fields) => logger.warn(message, fields);
|
|
12
12
|
const app = createAcpAgent({
|
package/dist/acp.js
CHANGED
|
@@ -18419,8 +18419,8 @@ import { Readable, Writable } from "node:stream";
|
|
|
18419
18419
|
|
|
18420
18420
|
// packages/client/src/index.js
|
|
18421
18421
|
import { spawn } from "node:child_process";
|
|
18422
|
-
import { createHash } from "node:crypto";
|
|
18423
|
-
import { open, readFile, realpath, stat, lstat, mkdir, readlink, unlink } from "node:fs/promises";
|
|
18422
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
18423
|
+
import { open, readFile, writeFile, realpath, stat, lstat, mkdir, readlink, unlink, readdir, rename, rmdir, link } from "node:fs/promises";
|
|
18424
18424
|
import net from "node:net";
|
|
18425
18425
|
import os from "node:os";
|
|
18426
18426
|
import path from "node:path";
|
|
@@ -18552,10 +18552,40 @@ var AlpRpcError = class extends Error {
|
|
|
18552
18552
|
};
|
|
18553
18553
|
var ERROR = Object.freeze({ failed: 1e3, notFound: 1001, forbidden: 1003, conflict: 1004, unavailable: 1005, protocol: 1006 });
|
|
18554
18554
|
var RPC_ERROR = Object.freeze({ parseError: -32700, invalidRequest: -32600, methodNotFound: -32601, invalidParams: -32602 });
|
|
18555
|
-
var CAPABILITY = Object.freeze({ attachAfter: "attach.after", promptReceipts: "prompt.receipts", extensionMethods: "extension.methods", team: "team", task: "task", library: "library", settingsLanguage: "settings.language", sessionListPage: "session.list.page", questionWatch: "question.watch", questionWatchTurns: "question.watch.turns", workspaceFiles: "workspace.files", workspaceFilesRead: "workspace.files.read", promptImages: "prompt.images" });
|
|
18555
|
+
var CAPABILITY = Object.freeze({ sessionInterruptTurn: "session.interrupt.turn", attachAfter: "attach.after", sessionHistory: "session.history", workspaceRegistry: "workspace.registry", workspaceWorktree: "workspace.worktree", workspaceGit: "workspace.git", promptReceipts: "prompt.receipts", extensionMethods: "extension.methods", team: "team", task: "task", library: "library", libraryProjectWrite: "library.project.write", settingsLanguage: "settings.language", sessionListPage: "session.list.page", questionWatch: "question.watch", questionWatchTurns: "question.watch.turns", sessionAttention: "session.attention", workspaceFiles: "workspace.files", workspaceFilesRead: "workspace.files.read", promptImages: "prompt.images", schedule: "schedule", attachments: "attachments", sessionFork: "session.fork", sessionRewind: "session.rewind", sessionReload: "session.reload", sessionResumeCommand: "session.resumeCommand", sessionConfigureLive: "session.configure.live", terminal: "terminal" });
|
|
18556
18556
|
var PROMPT_IMAGES = Object.freeze({ mimeTypes: Object.freeze(["image/png", "image/jpeg", "image/gif", "image/webp"]), maxCount: 8, maxBytes: 5 * 1024 * 1024, maxTotalBytes: 11 * 1024 * 1024 });
|
|
18557
|
-
var RPC_METHODS = Object.freeze(["assignment.recall", "board.list", "catalog.get", "daemon.hello", "daemon.pause", "daemon.pauses", "daemon.resume", "daemon.shutdown", "daemon.status", "daemon.usage", "extension.register", "extension.unregister", "library.delete", "library.duplicate", "library.get", "library.list", "library.models", "library.rename", "library.save", "library.skills.set", "question.answer", "question.list", "question.watch", "session.archive", "session.attach", "session.close", "session.configure", "session.create", "session.get", "session.interrupt", "session.list", "session.log", "session.message", "session.preview", "session.prompt", "session.release", "session.rename", "session.status", "settings.language.get", "settings.language.set", "task.create", "task.gate.resolve", "task.list", "task.update", "team.list", "workspace.files.list", "workspace.files.read", "workspace.files.search"]);
|
|
18557
|
+
var RPC_METHODS = Object.freeze(["assignment.recall", "attachment.abort", "attachment.begin", "attachment.chunk", "attachment.commit", "attachment.delete", "attachment.get", "board.list", "catalog.get", "daemon.hello", "daemon.pause", "daemon.pauses", "daemon.resume", "daemon.shutdown", "daemon.status", "daemon.usage", "extension.register", "extension.unregister", "library.delete", "library.duplicate", "library.get", "library.list", "library.models", "library.rename", "library.save", "library.skills.set", "project.list", "project.register", "project.remove", "question.answer", "question.list", "question.watch", "registry.owner", "registry.worktree", "schedule.cancel", "schedule.create", "schedule.get", "schedule.list", "session.archive", "session.attach", "session.attention.clear", "session.close", "session.configure", "session.configure.preview", "session.create", "session.fork", "session.get", "session.history", "session.interrupt", "session.list", "session.log", "session.message", "session.preview", "session.prompt", "session.release", "session.reload", "session.rename", "session.resumeCommand", "session.rewind", "session.status", "settings.language.get", "settings.language.set", "task.create", "task.gate.resolve", "task.list", "task.update", "team.list", "terminal.attach", "terminal.close", "terminal.create", "terminal.input", "terminal.list", "terminal.resize", "terminal.revoke", "workspace.files.list", "workspace.files.read", "workspace.files.search", "workspace.get", "workspace.git.diff", "workspace.git.status", "workspace.list", "workspace.update", "workspace.worktree.create", "workspace.worktree.options", "workspace.worktree.remove"]);
|
|
18558
18558
|
var WORKSPACE_FILES = Object.freeze({ maxReadBytes: 1024 * 1024, maxListEntries: 1e3, maxPathLength: 4096 });
|
|
18559
|
+
var WORKSPACE_GIT = Object.freeze({ maxFileBytes: 1024 * 1024, maxTotalBytes: 2 * 1024 * 1024, maxUntracked: 200, maxStatusFiles: 1e3, maxRefLength: 255 });
|
|
18560
|
+
var ATTACHMENTS = Object.freeze({
|
|
18561
|
+
maxObjectBytes: 20 * 1024 * 1024,
|
|
18562
|
+
maxPerPrompt: 8,
|
|
18563
|
+
maxPromptBytes: 40 * 1024 * 1024,
|
|
18564
|
+
maxChunkBytes: 256 * 1024,
|
|
18565
|
+
maxActiveUploads: 2,
|
|
18566
|
+
maxPrincipalBytes: 200 * 1024 * 1024,
|
|
18567
|
+
maxDaemonBytes: 1024 * 1024 * 1024,
|
|
18568
|
+
uploadTimeoutMs: 60 * 60 * 1e3,
|
|
18569
|
+
unreferencedRetentionMs: 24 * 60 * 60 * 1e3,
|
|
18570
|
+
releasedGraceMs: 7 * 24 * 60 * 60 * 1e3,
|
|
18571
|
+
maxNameBytes: 255
|
|
18572
|
+
});
|
|
18573
|
+
var TERMINAL = Object.freeze({
|
|
18574
|
+
maxPerPrincipal: 4,
|
|
18575
|
+
maxPerDaemon: 16,
|
|
18576
|
+
maxInputBytes: 64 * 1024,
|
|
18577
|
+
maxOutputFrameBytes: 64 * 1024,
|
|
18578
|
+
replayBytes: 1024 * 1024,
|
|
18579
|
+
idleMs: 30 * 60 * 1e3,
|
|
18580
|
+
maxLifetimeMs: 8 * 60 * 60 * 1e3,
|
|
18581
|
+
reconnectMs: 60 * 1e3,
|
|
18582
|
+
minCols: 2,
|
|
18583
|
+
maxCols: 500,
|
|
18584
|
+
minRows: 1,
|
|
18585
|
+
maxRows: 200
|
|
18586
|
+
});
|
|
18587
|
+
var TERMINAL_LIMIT_KEYS = Object.freeze(["maxPerPrincipal", "maxPerDaemon", "maxInputBytes", "maxOutputFrameBytes", "replayBytes", "idleMs", "maxLifetimeMs", "reconnectMs"]);
|
|
18588
|
+
var ATTACHMENT_CHUNK_OVERHEAD = 64 * 1024;
|
|
18559
18589
|
|
|
18560
18590
|
// packages/client/src/rpc/errors.js
|
|
18561
18591
|
var BRAND = Symbol.for("@anhlp/alp-client/AlpClientError");
|
|
@@ -19108,6 +19138,8 @@ function lockAlive(lock) {
|
|
|
19108
19138
|
}
|
|
19109
19139
|
}
|
|
19110
19140
|
var AlpClient = class extends AlpRpcClient {
|
|
19141
|
+
/** Host features captured by connect's handshake. @type {readonly string[]} */
|
|
19142
|
+
capabilities = [];
|
|
19111
19143
|
/**
|
|
19112
19144
|
* @param {import('node:net').Socket} socket a connected or connecting socket; the client owns it
|
|
19113
19145
|
* @param {import('./rpc/client.js').AlpRpcClientOptions & import('./ipc.js').SocketTransportOptions} [options]
|
|
@@ -19133,7 +19165,8 @@ async function openSocket(socketPath) {
|
|
|
19133
19165
|
async function connect(socketPath, client = { name: "alp", version: "0" }, options = {}) {
|
|
19134
19166
|
const connection = new AlpClient(await openSocket(socketPath), options);
|
|
19135
19167
|
try {
|
|
19136
|
-
await hello(connection, client);
|
|
19168
|
+
const greeting = await hello(connection, client);
|
|
19169
|
+
connection.capabilities = Object.freeze(Array.isArray(greeting.capabilities) ? greeting.capabilities.filter((value) => typeof value === "string") : []);
|
|
19137
19170
|
} catch (error51) {
|
|
19138
19171
|
connection.close();
|
|
19139
19172
|
throw error51;
|
|
@@ -19158,10 +19191,86 @@ async function tail(file2, lines = 30) {
|
|
|
19158
19191
|
return "";
|
|
19159
19192
|
}
|
|
19160
19193
|
}
|
|
19194
|
+
async function lifecycleOwners(home) {
|
|
19195
|
+
const directory = path.join(home, "state", "alpd.starting");
|
|
19196
|
+
const names = await readdir(directory).catch((error51) => {
|
|
19197
|
+
if (error51.code === "ENOENT") return [];
|
|
19198
|
+
throw error51;
|
|
19199
|
+
});
|
|
19200
|
+
return names.map((token) => {
|
|
19201
|
+
const match = /^owner-(\d+)-(\d+)-(start|stop)-[a-f0-9-]+$/.exec(token);
|
|
19202
|
+
if (!match) throw new Error("Invalid alpd startup admission owner");
|
|
19203
|
+
return { token, pid: Number(match[1]), bootTime: Number(match[2]), action: match[3] };
|
|
19204
|
+
});
|
|
19205
|
+
}
|
|
19206
|
+
async function readDaemonLifecycle(home) {
|
|
19207
|
+
return (await lifecycleOwners(home)).find((owner) => lockAlive(owner));
|
|
19208
|
+
}
|
|
19209
|
+
async function withDaemonLifecycle(home, action, run, { joinStart = false } = {}) {
|
|
19210
|
+
try {
|
|
19211
|
+
await assertPrivateDirectory(home, { create: true });
|
|
19212
|
+
} catch (cause) {
|
|
19213
|
+
throw Object.assign(new Error(`ALP_HOME_UNUSABLE, alpd failed to start while preparing its home: ${cause.message}`, { cause }), { code: "ALP_HOME_UNUSABLE" });
|
|
19214
|
+
}
|
|
19215
|
+
const state = path.join(home, "state");
|
|
19216
|
+
await assertPrivateDirectory(state, { create: true });
|
|
19217
|
+
const directory = path.join(state, "alpd.starting");
|
|
19218
|
+
const token = `owner-${process.pid}-${bootTime()}-${action}-${randomUUID()}`;
|
|
19219
|
+
const candidate = path.join(state, `alpd.starting-${token}`);
|
|
19220
|
+
await mkdir(candidate, { mode: 448 });
|
|
19221
|
+
await writeFile(path.join(candidate, token), JSON.stringify({ pid: process.pid, bootTime: bootTime(), action }), { mode: 384 });
|
|
19222
|
+
try {
|
|
19223
|
+
let joined = false;
|
|
19224
|
+
if (joinStart) {
|
|
19225
|
+
const owner = await readDaemonLifecycle(home);
|
|
19226
|
+
if (owner?.action === "start") {
|
|
19227
|
+
try {
|
|
19228
|
+
await link(path.join(directory, owner.token), path.join(directory, token));
|
|
19229
|
+
joined = true;
|
|
19230
|
+
} catch (error51) {
|
|
19231
|
+
if (error51.code !== "ENOENT") throw error51;
|
|
19232
|
+
}
|
|
19233
|
+
}
|
|
19234
|
+
}
|
|
19235
|
+
while (!joined) {
|
|
19236
|
+
try {
|
|
19237
|
+
await rename(candidate, directory);
|
|
19238
|
+
break;
|
|
19239
|
+
} catch (error51) {
|
|
19240
|
+
if (!["EEXIST", "ENOTEMPTY", "EPERM", "EACCES"].includes(error51.code)) throw error51;
|
|
19241
|
+
for (const owner of await lifecycleOwners(home)) {
|
|
19242
|
+
if (!lockAlive(owner)) await unlink(path.join(directory, owner.token)).catch((error52) => {
|
|
19243
|
+
if (error52.code !== "ENOENT") throw error52;
|
|
19244
|
+
});
|
|
19245
|
+
}
|
|
19246
|
+
await rmdir(directory).catch((error52) => {
|
|
19247
|
+
if (!["ENOENT", "ENOTEMPTY", "EEXIST"].includes(error52.code)) throw error52;
|
|
19248
|
+
});
|
|
19249
|
+
await new Promise((resolve) => setTimeout(resolve, 25));
|
|
19250
|
+
}
|
|
19251
|
+
}
|
|
19252
|
+
try {
|
|
19253
|
+
return await run();
|
|
19254
|
+
} finally {
|
|
19255
|
+
await unlink(path.join(directory, token));
|
|
19256
|
+
await rmdir(directory).catch((error51) => {
|
|
19257
|
+
if (!["ENOENT", "ENOTEMPTY", "EEXIST"].includes(error51.code)) throw error51;
|
|
19258
|
+
});
|
|
19259
|
+
}
|
|
19260
|
+
} finally {
|
|
19261
|
+
await unlink(path.join(candidate, token)).catch((error51) => {
|
|
19262
|
+
if (error51.code !== "ENOENT") throw error51;
|
|
19263
|
+
});
|
|
19264
|
+
await rmdir(candidate).catch((error51) => {
|
|
19265
|
+
if (error51.code !== "ENOENT") throw error51;
|
|
19266
|
+
});
|
|
19267
|
+
}
|
|
19268
|
+
}
|
|
19161
19269
|
async function ensureDaemon({ home = alpHome(), entry = (
|
|
19162
19270
|
/** @type {string | undefined} */
|
|
19163
19271
|
void 0
|
|
19164
|
-
), env = process.env, execPath = process.execPath, timeoutMs = 15e3 } = {}) {
|
|
19272
|
+
), env = process.env, execPath = process.execPath, timeoutMs = 15e3, lifecycleLocked = false } = {}) {
|
|
19273
|
+
if (!lifecycleLocked) return withDaemonLifecycle(home, "start", () => ensureDaemon({ home, entry, env, execPath, timeoutMs, lifecycleLocked: true }));
|
|
19165
19274
|
const ready = async () => {
|
|
19166
19275
|
const lock = await readLock(home);
|
|
19167
19276
|
return lockAlive(lock) && lock.ready ? lock.socket : void 0;
|
|
@@ -19174,7 +19283,7 @@ async function ensureDaemon({ home = alpHome(), entry = (
|
|
|
19174
19283
|
entry ??= await findDaemonEntry({ home, env });
|
|
19175
19284
|
if (!entry) throw new Error("ALP daemon is not running and alpd.js was not found. Install the ALP CLI and run `alp daemon start`, or set ALP_DAEMON_ENTRY to alpd.js");
|
|
19176
19285
|
await new Promise((resolve, reject) => {
|
|
19177
|
-
const launcher = spawn(execPath, [entry, "--detach"], {
|
|
19286
|
+
const launcher = spawn(execPath, [entry, "--detach", `--startup-timeout=${timeoutMs}`], {
|
|
19178
19287
|
env: { ...env, ALP_HOME: home, ELECTRON_RUN_AS_NODE: "1" },
|
|
19179
19288
|
stdio: ["ignore", "ignore", "pipe"],
|
|
19180
19289
|
windowsHide: true
|
|
@@ -19199,12 +19308,12 @@ ${log}` : ""}`);
|
|
|
19199
19308
|
}
|
|
19200
19309
|
|
|
19201
19310
|
// packages/client/src/supervise.js
|
|
19202
|
-
import { mkdir as mkdir3, unlink as unlink3, writeFile as
|
|
19311
|
+
import { mkdir as mkdir3, unlink as unlink3, writeFile as writeFile3, stat as stat2 } from "node:fs/promises";
|
|
19203
19312
|
import path3 from "node:path";
|
|
19204
19313
|
|
|
19205
19314
|
// packages/client/src/service.js
|
|
19206
19315
|
import { createHash as createHash2 } from "node:crypto";
|
|
19207
|
-
import { mkdir as mkdir2, readFile as readFile2, unlink as unlink2, writeFile } from "node:fs/promises";
|
|
19316
|
+
import { mkdir as mkdir2, readFile as readFile2, unlink as unlink2, writeFile as writeFile2 } from "node:fs/promises";
|
|
19208
19317
|
import os2 from "node:os";
|
|
19209
19318
|
import path2 from "node:path";
|
|
19210
19319
|
|
|
@@ -19301,6 +19410,9 @@ async function releaseHold(home) {
|
|
|
19301
19410
|
await unlink3(holdFile(home)).catch(() => {
|
|
19302
19411
|
});
|
|
19303
19412
|
}
|
|
19413
|
+
async function daemonHeld(home) {
|
|
19414
|
+
return stat2(holdFile(home)).then(() => true, () => false);
|
|
19415
|
+
}
|
|
19304
19416
|
async function whenReady(home, timeoutMs) {
|
|
19305
19417
|
const deadline = Date.now() + timeoutMs;
|
|
19306
19418
|
while (Date.now() < deadline) {
|
|
@@ -19310,20 +19422,24 @@ async function whenReady(home, timeoutMs) {
|
|
|
19310
19422
|
}
|
|
19311
19423
|
throw new Error(`alpd did not become ready within ${timeoutMs / 1e3} s; see ${path3.join(home, "logs")}`);
|
|
19312
19424
|
}
|
|
19313
|
-
async function startDaemon({ home, entry, env = process.env, timeoutMs = 15e3 }) {
|
|
19314
|
-
|
|
19315
|
-
|
|
19316
|
-
|
|
19317
|
-
|
|
19318
|
-
|
|
19319
|
-
|
|
19320
|
-
|
|
19321
|
-
|
|
19322
|
-
|
|
19425
|
+
async function startDaemon({ home, entry, env = process.env, timeoutMs = 15e3, automatic = false }) {
|
|
19426
|
+
return withDaemonLifecycle(home, "start", async () => {
|
|
19427
|
+
if (automatic) {
|
|
19428
|
+
if (await daemonHeld(home)) return;
|
|
19429
|
+
} else await releaseHold(home);
|
|
19430
|
+
const lock = await readLock(home);
|
|
19431
|
+
if (lockAlive(lock)) return lock.ready ? lock.socket : whenReady(home, timeoutMs);
|
|
19432
|
+
const service = serviceFor({ home, env });
|
|
19433
|
+
if (service && await installedProgram(service)) {
|
|
19434
|
+
await startService(service);
|
|
19435
|
+
return whenReady(home, timeoutMs);
|
|
19436
|
+
}
|
|
19437
|
+
return ensureDaemon({ home, entry, env, timeoutMs, lifecycleLocked: true });
|
|
19438
|
+
});
|
|
19323
19439
|
}
|
|
19324
19440
|
|
|
19325
19441
|
// packages/cli/src/acp/agent.ts
|
|
19326
|
-
import { randomUUID } from "node:crypto";
|
|
19442
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
19327
19443
|
import path4 from "node:path";
|
|
19328
19444
|
var unlistedOf = ({ teams, team, teamLabel }) => teams.some((entry) => entry.id === team) ? void 0 : { id: team, label: teamLabel ?? (team === "custom" ? "Custom" : team) };
|
|
19329
19445
|
var MODES = [
|
|
@@ -19681,7 +19797,7 @@ ${item2.text}`;
|
|
|
19681
19797
|
send(session, { sessionUpdate: "config_option_update", configOptions: configOptions(session) });
|
|
19682
19798
|
}
|
|
19683
19799
|
if (session.waiting) throw RequestError.invalidRequest(void 0, "A prompt is already running in this session");
|
|
19684
|
-
const clientMessageId =
|
|
19800
|
+
const clientMessageId = randomUUID2();
|
|
19685
19801
|
session.ours.add(clientMessageId);
|
|
19686
19802
|
let done;
|
|
19687
19803
|
const ended = new Promise((resolve) => {
|
|
@@ -19726,7 +19842,7 @@ ${item2.text}`;
|
|
|
19726
19842
|
})).onRequest("authenticate", () => ({})).onRequest("session/new", async ({ params }) => {
|
|
19727
19843
|
const cwd = absolute(params.cwd);
|
|
19728
19844
|
const mcpServers = hostServers(params.mcpServers);
|
|
19729
|
-
const session = track(`acp-${
|
|
19845
|
+
const session = track(`acp-${randomUUID2()}`, cwd, mcpServers, await preview(cwd, mcpServers), false);
|
|
19730
19846
|
queueMicrotask(() => send(session, { sessionUpdate: "available_commands_update", availableCommands: COMMANDS }));
|
|
19731
19847
|
return { sessionId: session.id, configOptions: configOptions(session), modes: modeState(session) };
|
|
19732
19848
|
}).onRequest("session/load", async ({ params }) => {
|
|
@@ -19803,7 +19919,7 @@ ${item2.text}`;
|
|
|
19803
19919
|
|
|
19804
19920
|
// packages/cli/src/acp/main.ts
|
|
19805
19921
|
async function runAcp({ daemonEntry }) {
|
|
19806
|
-
const version2 = true ? "0.0.
|
|
19922
|
+
const version2 = true ? "0.0.1-beta.4" : "0.0.0";
|
|
19807
19923
|
const logger = createLogger({ component: "acp" });
|
|
19808
19924
|
const log = (message, fields) => logger.warn(message, fields);
|
|
19809
19925
|
const app = createAcpAgent({
|