@holon-run/agentinbox 0.6.0 → 1.0.0-beta.0
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 +32 -7
- package/dist/src/adapters.js +61 -6
- package/dist/src/backend.js +4 -16
- package/dist/src/cli.js +307 -53
- package/dist/src/client.js +2 -2
- package/dist/src/daemon.js +36 -2
- package/dist/src/http.js +467 -45
- package/dist/src/logging.js +112 -0
- package/dist/src/paths.js +1 -0
- package/dist/src/runtime_gate.js +394 -63
- package/dist/src/service.js +856 -154
- package/dist/src/source_hosts.js +75 -0
- package/dist/src/source_resolution.js +20 -20
- package/dist/src/source_schema.js +2 -2
- package/dist/src/sources/feishu.js +66 -28
- package/dist/src/sources/github.js +188 -24
- package/dist/src/sources/remote.js +44 -24
- package/dist/src/sources/{remote_profiles.js → remote_modules.js} +143 -58
- package/dist/src/store.js +861 -106
- package/dist/src/terminal.js +33 -7
- package/dist/src/util.js +46 -1
- package/drizzle/migrations/{0000_initial.sql → 0000_v1_initial.sql} +182 -6
- package/drizzle/schema.ts +93 -1
- package/package.json +2 -1
- package/scripts/iterm2_cursor_probe.py +8 -3
- package/scripts/release_smoke.sh +123 -0
- package/drizzle/migrations/0001_inbox_items_source_occurred_at_idx.sql +0 -3
- package/drizzle/migrations/0002_subscription_cleanup_policy.sql +0 -45
- package/drizzle/migrations/0003_subscription_lifecycle_retirements.sql +0 -14
- package/drizzle/migrations/0004_source_idle_states.sql +0 -10
- package/drizzle/migrations/0005_timers.sql +0 -22
- package/drizzle/migrations/0006_terminal_runtime_pid.sql +0 -1
- package/drizzle/migrations/0007_activation_dispatch_last_notified_fingerprint.sql +0 -2
- package/drizzle/migrations/0008_inbox_item_sequence.sql +0 -21
package/dist/src/daemon.js
CHANGED
|
@@ -9,11 +9,14 @@ exports.stopDaemon = stopDaemon;
|
|
|
9
9
|
exports.daemonStatus = daemonStatus;
|
|
10
10
|
exports.writePidFile = writePidFile;
|
|
11
11
|
exports.removePidFile = removePidFile;
|
|
12
|
+
exports.resolveDaemonLogLevel = resolveDaemonLogLevel;
|
|
13
|
+
exports.writeDaemonMetadata = writeDaemonMetadata;
|
|
12
14
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
13
15
|
const node_path_1 = __importDefault(require("node:path"));
|
|
14
16
|
const node_child_process_1 = require("node:child_process");
|
|
15
17
|
const client_1 = require("./client");
|
|
16
18
|
const paths_1 = require("./paths");
|
|
19
|
+
const logging_1 = require("./logging");
|
|
17
20
|
const START_TIMEOUT_MS = 15_000;
|
|
18
21
|
const PACKAGE_VERSION = readOwnPackageVersion();
|
|
19
22
|
async function ensureDaemonForClient(options = {}) {
|
|
@@ -30,6 +33,7 @@ async function ensureDaemonForClient(options = {}) {
|
|
|
30
33
|
async function startDaemon(options = {}) {
|
|
31
34
|
const env = options.env ?? process.env;
|
|
32
35
|
const transport = requireSocketTransport(resolveDaemonClientTransport(options), "daemon start");
|
|
36
|
+
const logLevel = resolveDaemonLogLevel(env, options.logLevelOverride);
|
|
33
37
|
const homeDir = (0, paths_1.resolveAgentInboxHome)(env, options.homeDirOverride);
|
|
34
38
|
const { pidPath, logPath } = (0, paths_1.resolveDaemonPaths)(env, options.homeDirOverride);
|
|
35
39
|
node_fs_1.default.mkdirSync(homeDir, { recursive: true });
|
|
@@ -39,6 +43,7 @@ async function startDaemon(options = {}) {
|
|
|
39
43
|
return {
|
|
40
44
|
started: false,
|
|
41
45
|
pid: pid ?? -1,
|
|
46
|
+
logLevel,
|
|
42
47
|
pidPath,
|
|
43
48
|
logPath,
|
|
44
49
|
transport,
|
|
@@ -54,6 +59,7 @@ async function startDaemon(options = {}) {
|
|
|
54
59
|
AGENTINBOX_HOME: homeDir,
|
|
55
60
|
AGENTINBOX_SOCKET: transport.socketPath,
|
|
56
61
|
AGENTINBOX_URL: "",
|
|
62
|
+
AGENTINBOX_LOG_LEVEL: logLevel,
|
|
57
63
|
},
|
|
58
64
|
detached: true,
|
|
59
65
|
stdio: ["ignore", logFd, logFd],
|
|
@@ -67,6 +73,7 @@ async function startDaemon(options = {}) {
|
|
|
67
73
|
return {
|
|
68
74
|
started: true,
|
|
69
75
|
pid: child.pid ?? -1,
|
|
76
|
+
logLevel,
|
|
70
77
|
pidPath,
|
|
71
78
|
logPath,
|
|
72
79
|
transport,
|
|
@@ -75,7 +82,7 @@ async function startDaemon(options = {}) {
|
|
|
75
82
|
async function stopDaemon(options = {}) {
|
|
76
83
|
const env = options.env ?? process.env;
|
|
77
84
|
const transport = requireSocketTransport(resolveDaemonClientTransport(options), "daemon stop");
|
|
78
|
-
const { pidPath, logPath } = (0, paths_1.resolveDaemonPaths)(env, options.homeDirOverride);
|
|
85
|
+
const { pidPath, logPath, metadataPath } = (0, paths_1.resolveDaemonPaths)(env, options.homeDirOverride);
|
|
79
86
|
const pid = readPidFile(pidPath);
|
|
80
87
|
if (pid != null && isProcessAlive(pid)) {
|
|
81
88
|
process.kill(pid, "SIGTERM");
|
|
@@ -83,19 +90,22 @@ async function stopDaemon(options = {}) {
|
|
|
83
90
|
}
|
|
84
91
|
cleanupStalePidFile(pidPath, true);
|
|
85
92
|
cleanupFile(transport.socketPath);
|
|
93
|
+
cleanupFile(metadataPath);
|
|
86
94
|
return daemonStatus(options);
|
|
87
95
|
}
|
|
88
96
|
async function daemonStatus(options = {}) {
|
|
89
97
|
const env = options.env ?? process.env;
|
|
90
98
|
const transport = requireSocketTransport(resolveDaemonClientTransport(options), "daemon status");
|
|
91
|
-
const { pidPath, logPath } = (0, paths_1.resolveDaemonPaths)(env, options.homeDirOverride);
|
|
99
|
+
const { pidPath, logPath, metadataPath } = (0, paths_1.resolveDaemonPaths)(env, options.homeDirOverride);
|
|
92
100
|
const pid = readPidFile(pidPath);
|
|
93
101
|
if (pid != null && !isProcessAlive(pid)) {
|
|
94
102
|
cleanupStalePidFile(pidPath, true);
|
|
95
103
|
cleanupFile(transport.socketPath);
|
|
104
|
+
cleanupFile(metadataPath);
|
|
96
105
|
return {
|
|
97
106
|
running: false,
|
|
98
107
|
pid: null,
|
|
108
|
+
logLevel: null,
|
|
99
109
|
version: null,
|
|
100
110
|
startedAt: null,
|
|
101
111
|
command: null,
|
|
@@ -106,9 +116,11 @@ async function daemonStatus(options = {}) {
|
|
|
106
116
|
};
|
|
107
117
|
}
|
|
108
118
|
const processInfo = pid == null ? null : readProcessMetadata(pid);
|
|
119
|
+
const daemonMetadata = readDaemonMetadata(metadataPath);
|
|
109
120
|
return {
|
|
110
121
|
running: await canReachHealthz(transport),
|
|
111
122
|
pid,
|
|
123
|
+
logLevel: daemonMetadata?.logLevel ?? null,
|
|
112
124
|
version: pid == null ? null : PACKAGE_VERSION,
|
|
113
125
|
startedAt: processInfo?.startedAt ?? null,
|
|
114
126
|
command: processInfo?.command ?? null,
|
|
@@ -237,6 +249,28 @@ function cleanupStalePidFile(pidPath, force = false) {
|
|
|
237
249
|
cleanupFile(pidPath);
|
|
238
250
|
}
|
|
239
251
|
}
|
|
252
|
+
function resolveDaemonLogLevel(env = process.env, override) {
|
|
253
|
+
if (override) {
|
|
254
|
+
return override;
|
|
255
|
+
}
|
|
256
|
+
return (0, logging_1.parseLogLevel)(env.AGENTINBOX_LOG_LEVEL, (0, logging_1.defaultLogLevel)());
|
|
257
|
+
}
|
|
258
|
+
function writeDaemonMetadata(metadataPath, metadata) {
|
|
259
|
+
node_fs_1.default.mkdirSync(node_path_1.default.dirname(metadataPath), { recursive: true });
|
|
260
|
+
node_fs_1.default.writeFileSync(metadataPath, JSON.stringify(metadata), "utf8");
|
|
261
|
+
}
|
|
262
|
+
function readDaemonMetadata(metadataPath) {
|
|
263
|
+
try {
|
|
264
|
+
const parsed = JSON.parse(node_fs_1.default.readFileSync(metadataPath, "utf8"));
|
|
265
|
+
if ((0, logging_1.isLogLevel)(parsed.logLevel)) {
|
|
266
|
+
return { logLevel: parsed.logLevel };
|
|
267
|
+
}
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
catch {
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
240
274
|
function readPidFile(pidPath) {
|
|
241
275
|
try {
|
|
242
276
|
const raw = node_fs_1.default.readFileSync(pidPath, "utf8").trim();
|