@agentdocumentformat/cli 0.7.2 → 0.7.3
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/README.md +44 -21
- package/dist/adf.mjs +8 -6
- package/dist/chunks/{App-L5L37JI5.mjs → App-QMFRLBPQ.mjs} +1766 -1667
- package/dist/chunks/{adf-schema-JRU2BTOG.mjs → adf-schema-US4NFHMR.mjs} +2 -2
- package/dist/chunks/{chunk-4MQPTCXY.mjs → chunk-2WSQ7V6K.mjs} +1 -1
- package/dist/chunks/{chunk-X34PDRUH.mjs → chunk-3UCKYP7P.mjs} +55 -7
- package/dist/chunks/{chunk-WFQUVXML.mjs → chunk-CD3ATSXE.mjs} +6 -1
- package/dist/chunks/chunk-GKKCMXIZ.mjs +94 -0
- package/dist/chunks/{chunk-HWLWPXQ7.mjs → chunk-HDBPBORT.mjs} +7 -2
- package/dist/chunks/{chunk-3M4ZPOA3.mjs → chunk-J74STFKE.mjs} +35 -6
- package/dist/chunks/{chunk-TMT32MXT.mjs → chunk-TPRZQ7Z4.mjs} +1 -1
- package/dist/chunks/chunk-UEZR2CNS.mjs +65 -0
- package/dist/chunks/{chunk-7MTRVW2U.mjs → chunk-ZROSGV65.mjs} +16 -7
- package/dist/chunks/{cli-TCMBNZF6.mjs → cli-ZGVQRVSQ.mjs} +48 -22
- package/dist/chunks/{commands-DTEKM4ZL.mjs → commands-XNJMCD5L.mjs} +2 -2
- package/dist/chunks/{daemon-ZC3FZ2P4.mjs → daemon-G6OQZER2.mjs} +16380 -3911
- package/dist/chunks/{daemon-control-WDX7PMTC.mjs → daemon-control-HKFVSQTQ.mjs} +27 -9
- package/dist/chunks/{pipeline-executor-BHBSJX2K.mjs → pipeline-executor-U6IMCCP3.mjs} +3 -3
- package/dist/chunks/{store-WR7TZJZS.mjs → store-HUVDJPYN.mjs} +1 -1
- package/dist/chunks/{tui-ODVYUIMT.mjs → tui-LWLJUXZ3.mjs} +8 -7
- package/package.json +1 -1
- package/dist/chunks/chunk-G426FACA.mjs +0 -49
|
@@ -5,9 +5,13 @@ const require = __adfCreateRequire(import.meta.url);
|
|
|
5
5
|
const __filename = __adfFileURLToPath(import.meta.url);
|
|
6
6
|
const __dirname = __adfDirname(__filename);
|
|
7
7
|
import {
|
|
8
|
+
DEFAULT_DAEMON_PORT,
|
|
8
9
|
DEFAULT_DAEMON_URL,
|
|
10
|
+
isLocalDaemonUrl,
|
|
11
|
+
localProofHeaders,
|
|
9
12
|
resolveDaemonToken
|
|
10
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-GKKCMXIZ.mjs";
|
|
14
|
+
import "./chunk-UEZR2CNS.mjs";
|
|
11
15
|
import {
|
|
12
16
|
defaultUserDataPath
|
|
13
17
|
} from "./chunk-IHDDCZBS.mjs";
|
|
@@ -15,11 +19,11 @@ import "./chunk-M2RX3S2T.mjs";
|
|
|
15
19
|
|
|
16
20
|
// src/main/cli/daemon-control.ts
|
|
17
21
|
import { spawn, execFileSync } from "node:child_process";
|
|
18
|
-
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, statSync, readSync } from "node:fs";
|
|
22
|
+
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, rmSync, statSync, readSync } from "node:fs";
|
|
19
23
|
import { homedir } from "node:os";
|
|
20
24
|
import { dirname, join, resolve } from "node:path";
|
|
21
25
|
import { fileURLToPath } from "node:url";
|
|
22
|
-
var
|
|
26
|
+
var DEFAULT_MESH_PORT = 7295, START_TIMEOUT_MS = 9e4, STOP_TIMEOUT_MS = 3e4;
|
|
23
27
|
function daemonTarget(url) {
|
|
24
28
|
let host = "127.0.0.1", port = DEFAULT_DAEMON_PORT;
|
|
25
29
|
try {
|
|
@@ -64,10 +68,17 @@ function readPidFile(file) {
|
|
|
64
68
|
}
|
|
65
69
|
function processAlive(pid) {
|
|
66
70
|
try {
|
|
67
|
-
|
|
71
|
+
process.kill(pid, 0);
|
|
68
72
|
} catch (err) {
|
|
69
73
|
return err?.code === "EPERM";
|
|
70
74
|
}
|
|
75
|
+
if (process.platform === "linux")
|
|
76
|
+
try {
|
|
77
|
+
let stat = readFileSync(`/proc/${pid}/stat`, "utf-8");
|
|
78
|
+
if (stat.slice(stat.lastIndexOf(")") + 2).startsWith("Z")) return !1;
|
|
79
|
+
} catch {
|
|
80
|
+
}
|
|
81
|
+
return !0;
|
|
71
82
|
}
|
|
72
83
|
function readJson(file) {
|
|
73
84
|
try {
|
|
@@ -129,9 +140,16 @@ async function startDaemon(target, options = {}) {
|
|
|
129
140
|
if (conflict) throw new DaemonStartError(conflict, STUDIO_ADVICE);
|
|
130
141
|
}
|
|
131
142
|
let existing = readPidFile(paths.pidFile);
|
|
132
|
-
if (existing && processAlive(existing.pid) && !await isHealthy(target.url, fetchImpl))
|
|
133
|
-
|
|
134
|
-
`), await waitHealthy(target.url, fetchImpl, START_TIMEOUT_MS, () => processAlive(existing.pid))
|
|
143
|
+
if (existing && processAlive(existing.pid) && !await isHealthy(target.url, fetchImpl)) {
|
|
144
|
+
if (log(`Waiting for the ADF daemon pid ${existing.pid}\u2026
|
|
145
|
+
`), await waitHealthy(target.url, fetchImpl, START_TIMEOUT_MS, () => processAlive(existing.pid))) return { pid: existing.pid, paths, ms: 0 };
|
|
146
|
+
if (processAlive(existing.pid))
|
|
147
|
+
throw new DaemonStartError(`The daemon (pid ${existing.pid}) did not answer ${target.url}/health within ${START_TIMEOUT_MS / 1e3}s.`, `Log: ${paths.logFile}`);
|
|
148
|
+
try {
|
|
149
|
+
rmSync(paths.pidFile, { force: !0 });
|
|
150
|
+
} catch {
|
|
151
|
+
}
|
|
152
|
+
}
|
|
135
153
|
mkdirSync(dirname(paths.logFile), { recursive: !0 });
|
|
136
154
|
let launch = daemonLaunch(), tty = process.stderr.isTTY, started = Date.now();
|
|
137
155
|
if (log(`Starting the ADF daemon on ${target.host}:${target.port}\u2026${tty ? "" : `
|
|
@@ -196,7 +214,7 @@ async function waitHealthy(url, fetchImpl, timeoutMs, alive) {
|
|
|
196
214
|
}
|
|
197
215
|
async function ensureDaemon(url, options = {}) {
|
|
198
216
|
let env = options.env ?? process.env, fetchImpl = options.fetch ?? fetch, target = daemonTarget(url);
|
|
199
|
-
return await isHealthy(target.url, fetchImpl) || !target.loopback || options.disabled || env.ADF_NO_AUTOSTART === "1" ? null : await startDaemon(target, options);
|
|
217
|
+
return await isHealthy(target.url, fetchImpl) || !target.loopback || !isLocalDaemonUrl(target.url, env) || options.disabled || env.ADF_NO_AUTOSTART === "1" ? null : await startDaemon(target, options);
|
|
200
218
|
}
|
|
201
219
|
async function stopDaemon(target, options = {}) {
|
|
202
220
|
let env = options.env ?? process.env, fetchImpl = options.fetch ?? fetch, paths = daemonPaths(target.port, env), record = readPidFile(paths.pidFile), token = resolveDaemonToken(void 0, env, target.url);
|
|
@@ -204,7 +222,7 @@ async function stopDaemon(target, options = {}) {
|
|
|
204
222
|
return record && processAlive(record.pid) ? { stopped: !1, message: `No daemon answers ${target.url}, but pid ${record.pid} from ${paths.pidFile} is alive. It may be starting or stuck; see adf daemon logs.` } : { stopped: !0, message: `No daemon running at ${target.url}.` };
|
|
205
223
|
let accepted = !1;
|
|
206
224
|
try {
|
|
207
|
-
let res = await fetchImpl(`${target.url}/daemon/shutdown`, { method: "POST", headers: token ? { Authorization: `Bearer ${token}` } : {}, signal: AbortSignal.timeout(5e3) });
|
|
225
|
+
let res = await fetchImpl(`${target.url}/daemon/shutdown`, { method: "POST", headers: { ...token ? { Authorization: `Bearer ${token}` } : {}, ...localProofHeaders(target.url, "/daemon/shutdown", env) }, signal: AbortSignal.timeout(5e3) });
|
|
208
226
|
if (accepted = res.ok, !res.ok && res.status !== 404)
|
|
209
227
|
return { stopped: !1, message: `The daemon refused to stop: ${(await res.json().catch(() => null))?.error ?? `HTTP ${res.status}`}` };
|
|
210
228
|
} catch {
|
|
@@ -7,11 +7,11 @@ const __dirname = __adfDirname(__filename);
|
|
|
7
7
|
import {
|
|
8
8
|
MAX_SHELL_DEPTH,
|
|
9
9
|
executeNode
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-TPRZQ7Z4.mjs";
|
|
11
11
|
import "./chunk-5W7KES6P.mjs";
|
|
12
12
|
import "./chunk-HPVFJYXR.mjs";
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-ZROSGV65.mjs";
|
|
14
|
+
import "./chunk-CD3ATSXE.mjs";
|
|
15
15
|
import "./chunk-M2RX3S2T.mjs";
|
|
16
16
|
export {
|
|
17
17
|
MAX_SHELL_DEPTH,
|
|
@@ -6,7 +6,7 @@ const __filename = __adfFileURLToPath(import.meta.url);
|
|
|
6
6
|
const __dirname = __adfDirname(__filename);
|
|
7
7
|
import {
|
|
8
8
|
DaemonClient
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-3UCKYP7P.mjs";
|
|
10
10
|
import "./chunk-XNPZBLYL.mjs";
|
|
11
11
|
import {
|
|
12
12
|
cjs
|
|
@@ -18,7 +18,8 @@ import {
|
|
|
18
18
|
} from "./chunk-5QU5VY7N.mjs";
|
|
19
19
|
import {
|
|
20
20
|
daemon_url_exports
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-GKKCMXIZ.mjs";
|
|
22
|
+
import "./chunk-UEZR2CNS.mjs";
|
|
22
23
|
import "./chunk-IHDDCZBS.mjs";
|
|
23
24
|
import "./chunk-M2RX3S2T.mjs";
|
|
24
25
|
|
|
@@ -38,8 +39,8 @@ own goal, on demand or on a schedule.
|
|
|
38
39
|
|
|
39
40
|
Options:
|
|
40
41
|
--url, -u <url> Daemon URL (default ADF_DAEMON_URL or ${resolveDaemonUrl(void 0, {})})
|
|
41
|
-
--token <token> Bearer token (default ADF_DAEMON_TOKEN)
|
|
42
|
-
--view <id> Start view:
|
|
42
|
+
--token <token> Bearer token (default: ADF_DAEMON_TOKEN, else the local daemon's token file)
|
|
43
|
+
--view <id> Start view: chat | files | loops | inspect | fleet | runtime
|
|
43
44
|
--agent <id|handle> Preselect an agent
|
|
44
45
|
--loop <name> Preselect one of its loops (default main)
|
|
45
46
|
--theme <name> adf (dark) | adf-light | adf-contrast | adf-mono (also ADF_TUI_THEME)
|
|
@@ -103,7 +104,7 @@ ${tuiUsage()}
|
|
|
103
104
|
`), 0;
|
|
104
105
|
if (!io.stdout.isTTY || !io.stdin.isTTY)
|
|
105
106
|
return io.stderr.write(
|
|
106
|
-
"adf: the terminal app needs a terminal (stdin and stdout must be a TTY).\nFor scripts and pipes use one-shot commands, e.g. `
|
|
107
|
+
"adf: the terminal app needs a terminal (stdin and stdout must be a TTY).\nFor scripts and pipes use one-shot commands, e.g. `adf agents` or `adf --help`.\n"
|
|
107
108
|
), 1;
|
|
108
109
|
preferProductionReact();
|
|
109
110
|
let [
|
|
@@ -118,9 +119,9 @@ ${tuiUsage()}
|
|
|
118
119
|
] = await Promise.all([
|
|
119
120
|
import("./react-IUIDQ5LX.mjs"),
|
|
120
121
|
import("./build-QF5W473T.mjs"),
|
|
121
|
-
import("./App-
|
|
122
|
+
import("./App-QMFRLBPQ.mjs"),
|
|
122
123
|
import("./themes-F2FKU7CP.mjs"),
|
|
123
|
-
import("./store-
|
|
124
|
+
import("./store-HUVDJPYN.mjs"),
|
|
124
125
|
import("./theme-NORU4J74.mjs"),
|
|
125
126
|
import("./terminal-O5WO7C5U.mjs"),
|
|
126
127
|
import("./layout-EPJQNFAI.mjs")
|
package/package.json
CHANGED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { createRequire as __adfCreateRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __adfFileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __adfDirname } from 'node:path';
|
|
4
|
-
const require = __adfCreateRequire(import.meta.url);
|
|
5
|
-
const __filename = __adfFileURLToPath(import.meta.url);
|
|
6
|
-
const __dirname = __adfDirname(__filename);
|
|
7
|
-
import {
|
|
8
|
-
daemonSettingsDir,
|
|
9
|
-
readDaemonToken
|
|
10
|
-
} from "./chunk-IHDDCZBS.mjs";
|
|
11
|
-
import {
|
|
12
|
-
__export
|
|
13
|
-
} from "./chunk-M2RX3S2T.mjs";
|
|
14
|
-
|
|
15
|
-
// src/main/cli/daemon-url.ts
|
|
16
|
-
var daemon_url_exports = {};
|
|
17
|
-
__export(daemon_url_exports, {
|
|
18
|
-
DEFAULT_DAEMON_URL: () => DEFAULT_DAEMON_URL,
|
|
19
|
-
localDaemonToken: () => localDaemonToken,
|
|
20
|
-
resolveDaemonToken: () => resolveDaemonToken,
|
|
21
|
-
resolveDaemonUrl: () => resolveDaemonUrl
|
|
22
|
-
});
|
|
23
|
-
var DEFAULT_DAEMON_URL = "http://127.0.0.1:7385";
|
|
24
|
-
function resolveDaemonUrl(explicit, env = process.env) {
|
|
25
|
-
return (explicit ?? env.ADF_DAEMON_URL ?? DEFAULT_DAEMON_URL).replace(/\/+$/, "");
|
|
26
|
-
}
|
|
27
|
-
function isLoopbackUrl(url) {
|
|
28
|
-
try {
|
|
29
|
-
let host = new URL(url).hostname.replace(/^\[|\]$/g, "").toLowerCase();
|
|
30
|
-
return host === "localhost" || host === "::1" || /^127\./.test(host);
|
|
31
|
-
} catch {
|
|
32
|
-
return !1;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
function localDaemonToken(url, env = process.env) {
|
|
36
|
-
if (isLoopbackUrl(url))
|
|
37
|
-
return readDaemonToken(daemonSettingsDir(env)) ?? void 0;
|
|
38
|
-
}
|
|
39
|
-
function resolveDaemonToken(explicit, env = process.env, url) {
|
|
40
|
-
let token = explicit ?? env.ADF_DAEMON_TOKEN;
|
|
41
|
-
return token || (url ? localDaemonToken(url, env) : void 0);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export {
|
|
45
|
-
DEFAULT_DAEMON_URL,
|
|
46
|
-
resolveDaemonUrl,
|
|
47
|
-
resolveDaemonToken,
|
|
48
|
-
daemon_url_exports
|
|
49
|
-
};
|