@rynx-ai/daemon 0.1.11-beta.1 → 0.1.11-beta.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/bundled-plugins/.rynx-plugin/marketplace.json +10 -0
- package/bundled-plugins/plugins/lark/.rynx-plugin/plugin.json +37 -0
- package/bundled-plugins/plugins/lark/dist/cli-mirror/mirror-index.d.ts +48 -0
- package/bundled-plugins/plugins/lark/dist/cli-mirror/mirror-index.js +54 -0
- package/bundled-plugins/plugins/lark/dist/cli-mirror/rollout-mirror.d.ts +85 -0
- package/bundled-plugins/plugins/lark/dist/cli-mirror/rollout-mirror.js +333 -0
- package/bundled-plugins/plugins/lark/dist/cli-mirror/rollout-watcher.d.ts +109 -0
- package/bundled-plugins/plugins/lark/dist/cli-mirror/rollout-watcher.js +347 -0
- package/bundled-plugins/plugins/lark/dist/host-adapters.d.ts +95 -0
- package/bundled-plugins/plugins/lark/dist/host-adapters.js +504 -0
- package/bundled-plugins/plugins/lark/dist/index.d.ts +7 -0
- package/bundled-plugins/plugins/lark/dist/index.js +7 -0
- package/bundled-plugins/plugins/lark/dist/lark-card-stream.d.ts +363 -0
- package/bundled-plugins/plugins/lark/dist/lark-card-stream.js +1335 -0
- package/bundled-plugins/plugins/lark/dist/lark-config-store.d.ts +30 -0
- package/bundled-plugins/plugins/lark/dist/lark-config-store.js +135 -0
- package/bundled-plugins/plugins/lark/dist/lark-content.d.ts +30 -0
- package/bundled-plugins/plugins/lark/dist/lark-content.js +138 -0
- package/bundled-plugins/plugins/lark/dist/lark-conversation-directory.d.ts +65 -0
- package/bundled-plugins/plugins/lark/dist/lark-conversation-directory.js +106 -0
- package/bundled-plugins/plugins/lark/dist/lark-diff-card.d.ts +25 -0
- package/bundled-plugins/plugins/lark/dist/lark-diff-card.js +58 -0
- package/bundled-plugins/plugins/lark/dist/lark-fork-transcript.d.ts +16 -0
- package/bundled-plugins/plugins/lark/dist/lark-fork-transcript.js +141 -0
- package/bundled-plugins/plugins/lark/dist/lark-resume-card.d.ts +31 -0
- package/bundled-plugins/plugins/lark/dist/lark-resume-card.js +105 -0
- package/bundled-plugins/plugins/lark/dist/lark-runtime-state-store.d.ts +18 -0
- package/bundled-plugins/plugins/lark/dist/lark-runtime-state-store.js +95 -0
- package/bundled-plugins/plugins/lark/dist/lark-sdk/client.d.ts +8 -0
- package/bundled-plugins/plugins/lark/dist/lark-sdk/client.js +32 -0
- package/bundled-plugins/plugins/lark/dist/lark-sdk/index.d.ts +1 -0
- package/bundled-plugins/plugins/lark/dist/lark-sdk/index.js +1 -0
- package/bundled-plugins/plugins/lark/dist/lark-sender.d.ts +114 -0
- package/bundled-plugins/plugins/lark/dist/lark-sender.js +323 -0
- package/bundled-plugins/plugins/lark/dist/lark-session-store.d.ts +13 -0
- package/bundled-plugins/plugins/lark/dist/lark-session-store.js +14 -0
- package/bundled-plugins/plugins/lark/dist/lark-settings-card.d.ts +55 -0
- package/bundled-plugins/plugins/lark/dist/lark-settings-card.js +158 -0
- package/bundled-plugins/plugins/lark/dist/lark-setup.d.ts +39 -0
- package/bundled-plugins/plugins/lark/dist/lark-setup.js +103 -0
- package/bundled-plugins/plugins/lark/dist/lark.d.ts +507 -0
- package/bundled-plugins/plugins/lark/dist/lark.js +1977 -0
- package/bundled-plugins/plugins/lark/dist/runtime.d.ts +13 -0
- package/bundled-plugins/plugins/lark/dist/runtime.js +131313 -0
- package/bundled-plugins/plugins/lark/dist/settings.d.ts +7 -0
- package/bundled-plugins/plugins/lark/dist/settings.js +126958 -0
- package/bundled-plugins/plugins/lark/package.json +57 -0
- package/bundled-plugins/plugins/lark/ui/assets/index-B2dhMlMU.css +1 -0
- package/bundled-plugins/plugins/lark/ui/assets/index-D9N-AkLX.js +201 -0
- package/bundled-plugins/plugins/lark/ui/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
- package/bundled-plugins/plugins/lark/ui/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
- package/bundled-plugins/plugins/lark/ui/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
- package/bundled-plugins/plugins/lark/ui/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
- package/bundled-plugins/plugins/lark/ui/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
- package/bundled-plugins/plugins/lark/ui/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
- package/bundled-plugins/plugins/lark/ui/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
- package/bundled-plugins/plugins/lark/ui/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/bundled-plugins/plugins/lark/ui/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/bundled-plugins/plugins/lark/ui/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/bundled-plugins/plugins/lark/ui/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/bundled-plugins/plugins/lark/ui/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/bundled-plugins/plugins/lark/ui/index.html +13 -0
- package/dist/browser-artifact-management.d.ts +4 -1
- package/dist/browser-artifact-management.js +18 -10
- package/dist/browser-artifacts.d.ts +1 -0
- package/dist/browser-artifacts.js +1 -0
- package/dist/bundled-plugins.d.ts +15 -0
- package/dist/bundled-plugins.js +134 -0
- package/dist/chrome-for-testing-runtime.d.ts +27 -0
- package/dist/chrome-for-testing-runtime.js +193 -0
- package/dist/chrome-for-testing-store.d.ts +2 -0
- package/dist/chrome-for-testing-store.js +9 -0
- package/dist/control-deps.js +2 -79
- package/dist/daemon-server.d.ts +7 -1
- package/dist/daemon-server.js +299 -84
- package/dist/db.js +147 -124
- package/dist/entry-path.d.ts +3 -0
- package/dist/entry-path.js +12 -0
- package/dist/index-daemon.js +3 -66
- package/dist/lifecycle.d.ts +12 -0
- package/dist/lifecycle.js +16 -0
- package/dist/maintenance-lease.d.ts +39 -0
- package/dist/maintenance-lease.js +250 -0
- package/dist/migrations/cleanup-legacy-sessions.d.ts +1 -1
- package/dist/migrations/cleanup-legacy-sessions.js +33 -15
- package/dist/official-plugins.d.ts +2 -0
- package/dist/official-plugins.js +2 -0
- package/dist/plugin-cli.d.ts +1 -3
- package/dist/plugin-cli.js +56 -45
- package/dist/plugin-host-leases.d.ts +4 -0
- package/dist/plugin-host-leases.js +7 -0
- package/dist/plugin-host-rpc.d.ts +60 -4
- package/dist/plugin-host-rpc.js +300 -50
- package/dist/plugin-installer.d.ts +24 -55
- package/dist/plugin-installer.js +258 -412
- package/dist/plugin-management-service.d.ts +30 -23
- package/dist/plugin-management-service.js +290 -105
- package/dist/plugin-marketplace.d.ts +35 -0
- package/dist/plugin-marketplace.js +299 -0
- package/dist/plugin-package.d.ts +22 -24
- package/dist/plugin-package.js +520 -571
- package/dist/plugin-skill-context.d.ts +4 -0
- package/dist/plugin-skill-context.js +35 -0
- package/dist/plugin-store.d.ts +36 -37
- package/dist/plugin-store.js +140 -92
- package/dist/plugin-supervisor.d.ts +50 -125
- package/dist/plugin-supervisor.js +682 -1030
- package/dist/pm2.d.ts +11 -2
- package/dist/pm2.js +130 -28
- package/dist/process.d.ts +12 -0
- package/dist/process.js +91 -0
- package/dist/runtime-project-store.d.ts +9 -0
- package/dist/runtime-project-store.js +83 -0
- package/dist/session-fallback-workspace.d.ts +22 -0
- package/dist/session-fallback-workspace.js +120 -0
- package/dist/session-fork-store.d.ts +41 -0
- package/dist/session-fork-store.js +288 -0
- package/dist/session-launch-operations.d.ts +23 -2
- package/dist/session-launch-operations.js +48 -7
- package/dist/session-meta-store.d.ts +7 -9
- package/dist/session-meta-store.js +28 -49
- package/dist/setup-service.d.ts +20 -0
- package/dist/setup-service.js +38 -0
- package/package.json +36 -20
- package/dist/browser-cli-args.d.ts +0 -20
- package/dist/browser-cli-args.js +0 -100
- package/dist/channel-store.d.ts +0 -22
- package/dist/channel-store.js +0 -65
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -732
- package/dist/control-client.d.ts +0 -122
- package/dist/control-client.js +0 -855
- package/dist/control-endpoint.d.ts +0 -14
- package/dist/control-endpoint.js +0 -124
- package/dist/desktop-browser-host-client.d.ts +0 -35
- package/dist/desktop-browser-host-client.js +0 -415
- package/dist/instance-store.d.ts +0 -38
- package/dist/instance-store.js +0 -85
- package/dist/plugin-install-restart.d.ts +0 -13
- package/dist/plugin-install-restart.js +0 -24
- package/dist/plugin-runtime-control.d.ts +0 -2
- package/dist/plugin-runtime-control.js +0 -37
- package/dist/registry.d.ts +0 -10
- package/dist/registry.js +0 -52
- package/dist/setup.d.ts +0 -20
- package/dist/setup.js +0 -374
- package/dist/update.d.ts +0 -25
- package/dist/update.js +0 -133
package/dist/db.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `~/.rynx/rynx.db` — the daemon's SQLite store. Concerns kept apart:
|
|
3
|
-
* - `
|
|
4
|
-
* - `
|
|
5
|
-
* enforced by a UNIQUE channel_id). This is what the daemon mounts.
|
|
6
|
-
* - `plugins` — static manifests, grants and immutable install locations.
|
|
3
|
+
* - `plugin_installations` — source-qualified manifests, capabilities, and immutable packages.
|
|
4
|
+
* - `plugin_marketplaces` — catalog registrations; catalog data is never executable.
|
|
7
5
|
* - `plugin_session_launch_operations` — durable idempotency/tombstones.
|
|
8
6
|
* - `control_links` — generic, one-use links to the local session console.
|
|
9
7
|
* - `runtime_pairing_claims` / `runtime_client_grants` — one-use enrollment
|
|
@@ -16,15 +14,18 @@
|
|
|
16
14
|
* Connections are cached per resolved path so tests can point `RYNX_DB` /
|
|
17
15
|
* `RYNX_HOME` at a temp dir. Override with `RYNX_DB` (full path) or `RYNX_HOME`.
|
|
18
16
|
*/
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import { dirname, join } from "node:path";
|
|
17
|
+
import { chmodSync, mkdirSync } from "node:fs";
|
|
18
|
+
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
19
|
+
import { rynxHome } from "@rynx-ai/core";
|
|
23
20
|
import Database from "better-sqlite3";
|
|
24
21
|
const connections = new Map();
|
|
25
22
|
/** Absolute path to the SQLite file (override via `RYNX_DB`, else `~/.rynx/rynx.db`). */
|
|
26
23
|
export function dbPath() {
|
|
27
|
-
|
|
24
|
+
const configured = process.env.RYNX_DB?.trim();
|
|
25
|
+
if (configured && !isAbsolute(configured)) {
|
|
26
|
+
throw new Error("RYNX_DB must be an absolute path");
|
|
27
|
+
}
|
|
28
|
+
return configured ? resolve(configured) : join(rynxHome(), "rynx.db");
|
|
28
29
|
}
|
|
29
30
|
/** Open (or reuse) the database at the current path, migrating + importing on first open. */
|
|
30
31
|
export function db() {
|
|
@@ -37,7 +38,7 @@ export function db() {
|
|
|
37
38
|
conn.pragma("busy_timeout = 5000");
|
|
38
39
|
conn.pragma("foreign_keys = ON");
|
|
39
40
|
migrate(conn);
|
|
40
|
-
//
|
|
41
|
+
// Plugin state and daemon credentials are private.
|
|
41
42
|
try {
|
|
42
43
|
chmodSync(path, 0o600);
|
|
43
44
|
}
|
|
@@ -49,34 +50,46 @@ export function db() {
|
|
|
49
50
|
}
|
|
50
51
|
function migrate(conn) {
|
|
51
52
|
conn.exec(`
|
|
52
|
-
CREATE TABLE IF NOT EXISTS
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
integrity TEXT,
|
|
63
|
-
grants TEXT
|
|
53
|
+
CREATE TABLE IF NOT EXISTS plugin_marketplaces (
|
|
54
|
+
marketplace_id TEXT PRIMARY KEY,
|
|
55
|
+
source_type TEXT NOT NULL CHECK(source_type IN ('git', 'local')),
|
|
56
|
+
requested_source TEXT NOT NULL,
|
|
57
|
+
resolved_revision TEXT NOT NULL,
|
|
58
|
+
source_fingerprint TEXT NOT NULL,
|
|
59
|
+
built_in INTEGER NOT NULL DEFAULT 0,
|
|
60
|
+
catalog TEXT NOT NULL,
|
|
61
|
+
created_at TEXT NOT NULL,
|
|
62
|
+
refreshed_at TEXT NOT NULL
|
|
64
63
|
);
|
|
65
|
-
CREATE TABLE IF NOT EXISTS
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
options TEXT,
|
|
70
|
-
created_at TEXT NOT NULL,
|
|
71
|
-
updated_at TEXT NOT NULL
|
|
64
|
+
CREATE TABLE IF NOT EXISTS plugin_marketplace_bindings (
|
|
65
|
+
marketplace_id TEXT PRIMARY KEY,
|
|
66
|
+
source_fingerprint TEXT NOT NULL,
|
|
67
|
+
created_at TEXT NOT NULL
|
|
72
68
|
);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
69
|
+
INSERT OR IGNORE INTO plugin_marketplace_bindings (
|
|
70
|
+
marketplace_id, source_fingerprint, created_at
|
|
71
|
+
)
|
|
72
|
+
SELECT marketplace_id, source_fingerprint, created_at
|
|
73
|
+
FROM plugin_marketplaces;
|
|
74
|
+
CREATE TABLE IF NOT EXISTS plugin_installations (
|
|
75
|
+
canonical_id TEXT PRIMARY KEY,
|
|
76
|
+
marketplace_id TEXT NOT NULL,
|
|
77
|
+
plugin_id TEXT NOT NULL,
|
|
78
|
+
source_type TEXT NOT NULL CHECK(source_type IN ('git', 'local')),
|
|
79
|
+
requested_source TEXT NOT NULL,
|
|
80
|
+
resolved_revision TEXT NOT NULL,
|
|
81
|
+
source_fingerprint TEXT NOT NULL,
|
|
82
|
+
version TEXT NOT NULL,
|
|
83
|
+
enabled INTEGER NOT NULL DEFAULT 1,
|
|
84
|
+
installed_at TEXT NOT NULL,
|
|
85
|
+
updated_at TEXT NOT NULL,
|
|
86
|
+
install_path TEXT NOT NULL,
|
|
87
|
+
manifest TEXT NOT NULL,
|
|
88
|
+
integrity TEXT NOT NULL,
|
|
89
|
+
capabilities TEXT NOT NULL,
|
|
90
|
+
runtime_state TEXT,
|
|
91
|
+
runtime_error TEXT,
|
|
92
|
+
UNIQUE(marketplace_id, plugin_id)
|
|
80
93
|
);
|
|
81
94
|
CREATE TABLE IF NOT EXISTS session_items (
|
|
82
95
|
id TEXT PRIMARY KEY,
|
|
@@ -142,16 +155,25 @@ function migrate(conn) {
|
|
|
142
155
|
ON DELETE CASCADE
|
|
143
156
|
);
|
|
144
157
|
CREATE TABLE IF NOT EXISTS sessions (
|
|
158
|
+
id TEXT PRIMARY KEY,
|
|
159
|
+
workspace TEXT NOT NULL,
|
|
160
|
+
execution TEXT NOT NULL,
|
|
161
|
+
title TEXT,
|
|
162
|
+
forked_from_session_id TEXT,
|
|
163
|
+
source TEXT NOT NULL,
|
|
164
|
+
created_at TEXT NOT NULL,
|
|
165
|
+
updated_at TEXT
|
|
166
|
+
);
|
|
167
|
+
CREATE TABLE IF NOT EXISTS session_snapshot_cleanup (
|
|
168
|
+
session_id TEXT PRIMARY KEY
|
|
169
|
+
);
|
|
170
|
+
CREATE TABLE IF NOT EXISTS runtime_projects (
|
|
145
171
|
id TEXT PRIMARY KEY,
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
model TEXT,
|
|
150
|
-
reasoning_effort TEXT,
|
|
151
|
-
title TEXT,
|
|
152
|
-
source TEXT,
|
|
172
|
+
name TEXT NOT NULL,
|
|
173
|
+
directories_json TEXT NOT NULL,
|
|
174
|
+
primary_dir TEXT NOT NULL,
|
|
153
175
|
created_at TEXT NOT NULL,
|
|
154
|
-
updated_at TEXT
|
|
176
|
+
updated_at TEXT NOT NULL
|
|
155
177
|
);
|
|
156
178
|
CREATE TABLE IF NOT EXISTS session_pending_messages (
|
|
157
179
|
session_id TEXT PRIMARY KEY REFERENCES sessions(id) ON DELETE CASCADE,
|
|
@@ -173,6 +195,7 @@ function migrate(conn) {
|
|
|
173
195
|
scope_id TEXT NOT NULL,
|
|
174
196
|
operation_id TEXT NOT NULL,
|
|
175
197
|
request_hash TEXT NOT NULL,
|
|
198
|
+
raw_request_hash TEXT,
|
|
176
199
|
session_id TEXT NOT NULL,
|
|
177
200
|
state TEXT NOT NULL DEFAULT 'active' CHECK(state IN ('active', 'deleted')),
|
|
178
201
|
created_at TEXT NOT NULL,
|
|
@@ -187,6 +210,31 @@ function migrate(conn) {
|
|
|
187
210
|
);
|
|
188
211
|
CREATE INDEX IF NOT EXISTS idx_plugin_session_launch_operations_session
|
|
189
212
|
ON plugin_session_launch_operations(session_id);
|
|
213
|
+
CREATE TABLE IF NOT EXISTS session_fork_operations (
|
|
214
|
+
operation_id TEXT PRIMARY KEY,
|
|
215
|
+
request_hash TEXT NOT NULL,
|
|
216
|
+
source_session_id TEXT NOT NULL,
|
|
217
|
+
target_session_id TEXT NOT NULL UNIQUE,
|
|
218
|
+
title TEXT,
|
|
219
|
+
fork_position INTEGER,
|
|
220
|
+
state TEXT NOT NULL DEFAULT 'reserved'
|
|
221
|
+
CHECK(state IN ('reserved', 'completed', 'target_deleted')),
|
|
222
|
+
error TEXT,
|
|
223
|
+
created_at TEXT NOT NULL,
|
|
224
|
+
updated_at TEXT NOT NULL,
|
|
225
|
+
completed_at TEXT,
|
|
226
|
+
deleted_at TEXT,
|
|
227
|
+
CHECK(
|
|
228
|
+
(state = 'reserved' AND completed_at IS NULL AND deleted_at IS NULL)
|
|
229
|
+
OR (state = 'completed' AND completed_at IS NOT NULL AND deleted_at IS NULL)
|
|
230
|
+
OR (state = 'target_deleted' AND deleted_at IS NOT NULL)
|
|
231
|
+
)
|
|
232
|
+
);
|
|
233
|
+
CREATE INDEX IF NOT EXISTS idx_session_fork_operations_source
|
|
234
|
+
ON session_fork_operations(source_session_id, state);
|
|
235
|
+
CREATE UNIQUE INDEX IF NOT EXISTS idx_session_fork_operations_reserved_source
|
|
236
|
+
ON session_fork_operations(source_session_id)
|
|
237
|
+
WHERE state = 'reserved';
|
|
190
238
|
CREATE TABLE IF NOT EXISTS control_links (
|
|
191
239
|
token TEXT PRIMARY KEY,
|
|
192
240
|
plugin_id TEXT NOT NULL,
|
|
@@ -260,97 +308,72 @@ function migrate(conn) {
|
|
|
260
308
|
CREATE INDEX IF NOT EXISTS idx_runtime_pending_enrollments_expires
|
|
261
309
|
ON runtime_pending_enrollments(expires_at);
|
|
262
310
|
`);
|
|
311
|
+
migratePluginCapabilities(conn);
|
|
312
|
+
migrateSessionSnapshots(conn);
|
|
263
313
|
// Breaking plugin-runtime cutover: remove obsolete core-owned state.
|
|
264
314
|
conn.exec(`
|
|
265
315
|
DROP TABLE IF EXISTS control_sessions;
|
|
266
316
|
DROP TABLE IF EXISTS plugin_daemon_worker_settings;
|
|
267
317
|
`);
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
// this change — they were all console sessions.
|
|
272
|
-
addColumnIfMissing(conn, "sessions", "source", "TEXT");
|
|
273
|
-
addColumnIfMissing(conn, "sessions", "updated_at", "TEXT");
|
|
274
|
-
addColumnIfMissing(conn, "sessions", "provider", "TEXT");
|
|
275
|
-
const sessionColumns = conn.prepare("PRAGMA table_info(sessions)").all();
|
|
276
|
-
if (sessionColumns.some((column) => column.name === "executor")) {
|
|
277
|
-
conn.exec("UPDATE sessions SET provider = executor WHERE provider IS NULL AND executor IS NOT NULL");
|
|
278
|
-
}
|
|
279
|
-
addColumnIfMissing(conn, "plugins", "updated_at", "TEXT");
|
|
280
|
-
addColumnIfMissing(conn, "plugins", "install_path", "TEXT");
|
|
281
|
-
addColumnIfMissing(conn, "plugins", "manifest", "TEXT");
|
|
282
|
-
addColumnIfMissing(conn, "plugins", "integrity", "TEXT");
|
|
283
|
-
addColumnIfMissing(conn, "plugins", "grants", "TEXT");
|
|
284
|
-
conn.exec("UPDATE sessions SET source = 'console' WHERE source IS NULL");
|
|
285
|
-
conn.exec("UPDATE plugins SET updated_at = installed_at WHERE updated_at IS NULL");
|
|
286
|
-
importLegacyConfig(conn);
|
|
287
|
-
}
|
|
288
|
-
/** Idempotently add a column to an existing table (no-op if already present). */
|
|
289
|
-
function addColumnIfMissing(conn, table, column, ddl) {
|
|
290
|
-
const cols = conn.prepare(`PRAGMA table_info(${table})`).all();
|
|
291
|
-
if (cols.some((c) => c.name === column))
|
|
292
|
-
return;
|
|
293
|
-
conn.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${ddl}`);
|
|
318
|
+
addColumnIfMissing(conn, "plugin_marketplaces", "built_in", "INTEGER NOT NULL DEFAULT 0");
|
|
319
|
+
addColumnIfMissing(conn, "sessions", "forked_from_session_id", "TEXT");
|
|
320
|
+
addColumnIfMissing(conn, "plugin_session_launch_operations", "raw_request_hash", "TEXT");
|
|
294
321
|
}
|
|
295
322
|
/**
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
* (keyed by instanceId) stays intact. Runs only when empty; the file is renamed
|
|
301
|
-
* afterwards so it's never read — or hand-edited — again.
|
|
323
|
+
* Breaking Session cutover: the previous rows contain mutable Agent/Provider
|
|
324
|
+
* references and no immutable workspace/execution snapshots, so they cannot be
|
|
325
|
+
* migrated faithfully. Remove every database-owned Session artifact and create
|
|
326
|
+
* the new snapshot-only table. User workspace directories are never touched.
|
|
302
327
|
*/
|
|
303
|
-
function
|
|
304
|
-
const
|
|
305
|
-
|
|
328
|
+
function migrateSessionSnapshots(conn) {
|
|
329
|
+
const columns = conn.prepare("PRAGMA table_info(sessions)").all();
|
|
330
|
+
const names = new Set(columns.map((column) => column.name));
|
|
331
|
+
if (names.has("workspace") && names.has("execution"))
|
|
306
332
|
return;
|
|
307
|
-
|
|
308
|
-
|
|
333
|
+
conn.transaction(() => {
|
|
334
|
+
conn.exec(`
|
|
335
|
+
INSERT OR IGNORE INTO session_snapshot_cleanup (session_id)
|
|
336
|
+
SELECT id FROM sessions;
|
|
337
|
+
DELETE FROM session_message_operation_resources;
|
|
338
|
+
DELETE FROM session_message_operations;
|
|
339
|
+
DELETE FROM session_resources;
|
|
340
|
+
DELETE FROM session_items;
|
|
341
|
+
DELETE FROM session_pending_messages;
|
|
342
|
+
DELETE FROM session_emulator_bindings;
|
|
343
|
+
DELETE FROM plugin_session_launch_operations;
|
|
344
|
+
DELETE FROM session_fork_operations;
|
|
345
|
+
DELETE FROM control_links;
|
|
346
|
+
DELETE FROM sessions;
|
|
347
|
+
DROP TABLE sessions;
|
|
348
|
+
CREATE TABLE sessions (
|
|
349
|
+
id TEXT PRIMARY KEY,
|
|
350
|
+
workspace TEXT NOT NULL,
|
|
351
|
+
execution TEXT NOT NULL,
|
|
352
|
+
title TEXT,
|
|
353
|
+
forked_from_session_id TEXT,
|
|
354
|
+
source TEXT NOT NULL,
|
|
355
|
+
created_at TEXT NOT NULL,
|
|
356
|
+
updated_at TEXT
|
|
357
|
+
);
|
|
358
|
+
`);
|
|
359
|
+
}).immediate();
|
|
360
|
+
}
|
|
361
|
+
function migratePluginCapabilities(conn) {
|
|
362
|
+
const columns = conn
|
|
363
|
+
.prepare("PRAGMA table_info(plugin_installations)")
|
|
364
|
+
.all();
|
|
365
|
+
if (columns.some((column) => column.name === "capabilities"))
|
|
309
366
|
return;
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
const parsed = JSON.parse(readFileSync(legacy, "utf8"));
|
|
313
|
-
if (parsed.channels && typeof parsed.channels === "object") {
|
|
314
|
-
channels = parsed.channels;
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
catch {
|
|
318
|
-
return; // malformed legacy file — leave it alone, start empty
|
|
319
|
-
}
|
|
320
|
-
if (!channels)
|
|
367
|
+
if (columns.some((column) => column.name === "grants")) {
|
|
368
|
+
conn.exec("ALTER TABLE plugin_installations RENAME COLUMN grants TO capabilities");
|
|
321
369
|
return;
|
|
322
|
-
const now = new Date().toISOString();
|
|
323
|
-
const insertChannel = conn.prepare(`INSERT OR IGNORE INTO channels (id, name, type, options, created_at, updated_at)
|
|
324
|
-
VALUES (@id, @name, @type, @options, @now, @now)`);
|
|
325
|
-
const insertInstance = conn.prepare(`INSERT OR IGNORE INTO instances (id, channel_id, agent, enabled, created_at, updated_at)
|
|
326
|
-
VALUES (@id, @channelId, @agent, @enabled, @now, @now)`);
|
|
327
|
-
const tx = conn.transaction(() => {
|
|
328
|
-
for (const [key, entry] of Object.entries(channels)) {
|
|
329
|
-
const channelId = randomUUID();
|
|
330
|
-
insertChannel.run({
|
|
331
|
-
id: channelId,
|
|
332
|
-
name: key,
|
|
333
|
-
type: entry.type ?? key,
|
|
334
|
-
options: entry.options ? JSON.stringify(entry.options) : null,
|
|
335
|
-
now,
|
|
336
|
-
});
|
|
337
|
-
insertInstance.run({
|
|
338
|
-
id: key, // preserve the old key as the runtime instanceId
|
|
339
|
-
channelId,
|
|
340
|
-
agent: entry.agent ?? null,
|
|
341
|
-
enabled: entry.enabled === false ? 0 : 1,
|
|
342
|
-
now,
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
});
|
|
346
|
-
tx();
|
|
347
|
-
try {
|
|
348
|
-
renameSync(legacy, `${legacy}.imported`);
|
|
349
|
-
}
|
|
350
|
-
catch {
|
|
351
|
-
/* leave the source in place if it can't be renamed */
|
|
352
370
|
}
|
|
371
|
+
conn.exec("ALTER TABLE plugin_installations ADD COLUMN capabilities TEXT NOT NULL DEFAULT '[]'");
|
|
353
372
|
}
|
|
354
|
-
|
|
355
|
-
|
|
373
|
+
/** Idempotently add a column to an existing table (no-op if already present). */
|
|
374
|
+
function addColumnIfMissing(conn, table, column, ddl) {
|
|
375
|
+
const cols = conn.prepare(`PRAGMA table_info(${table})`).all();
|
|
376
|
+
if (cols.some((c) => c.name === column))
|
|
377
|
+
return;
|
|
378
|
+
conn.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${ddl}`);
|
|
356
379
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
const require = createRequire(import.meta.url);
|
|
5
|
+
/** Resolve the executable daemon module without importing its side-effectful entry. */
|
|
6
|
+
export function resolveDaemonEntry(moduleUrl = import.meta.url) {
|
|
7
|
+
return join(dirname(fileURLToPath(moduleUrl)), "index-daemon.js");
|
|
8
|
+
}
|
|
9
|
+
export function installedDaemonVersion() {
|
|
10
|
+
const manifest = require("../package.json");
|
|
11
|
+
return typeof manifest.version === "string" ? manifest.version : "0.0.0";
|
|
12
|
+
}
|
package/dist/index-daemon.js
CHANGED
|
@@ -1,70 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* Boot order matters: install the EPIPE guard first (we're a pm2 child).
|
|
6
|
-
* The composition root reads static plugin manifests, projects chat instances
|
|
7
|
-
* onto remote runner handles, and supervises non-chat plugin workers. Installed
|
|
8
|
-
* plugin code is loaded only in child processes.
|
|
9
|
-
*/
|
|
10
|
-
import { startRynxDaemonServer } from "./daemon-server.js";
|
|
11
|
-
import { installStdioEpipeGuard } from "./stdio-epipe-guard.js";
|
|
12
|
-
installStdioEpipeGuard();
|
|
13
|
-
async function main() {
|
|
14
|
-
const followsApp = process.env.RYNX_DAEMON_LIFECYCLE === "follow-app";
|
|
15
|
-
let parentDisconnected = followsApp && !process.connected;
|
|
16
|
-
const recordParentDisconnect = () => {
|
|
17
|
-
parentDisconnected = true;
|
|
18
|
-
};
|
|
19
|
-
if (followsApp)
|
|
20
|
-
process.once("disconnect", recordParentDisconnect);
|
|
21
|
-
let server;
|
|
22
|
-
try {
|
|
23
|
-
server = await startRynxDaemonServer();
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
process.off("disconnect", recordParentDisconnect);
|
|
27
|
-
throw error;
|
|
28
|
-
}
|
|
29
|
-
let shutdownPromise;
|
|
30
|
-
const shutdown = (signal) => {
|
|
31
|
-
if (shutdownPromise)
|
|
32
|
-
return shutdownPromise;
|
|
33
|
-
process.off("SIGINT", onSigint);
|
|
34
|
-
process.off("SIGTERM", onSigterm);
|
|
35
|
-
process.off("disconnect", onDisconnect);
|
|
36
|
-
shutdownPromise = (async () => {
|
|
37
|
-
console.log(JSON.stringify({ level: "info", type: "shutdown", signal }));
|
|
38
|
-
await server.shutdown();
|
|
39
|
-
})();
|
|
40
|
-
shutdownPromise.catch((error) => {
|
|
41
|
-
process.exitCode = 1;
|
|
42
|
-
console.error(`Shutdown failed: ${error instanceof Error ? (error.stack ?? error.message) : String(error)}`);
|
|
43
|
-
});
|
|
44
|
-
return shutdownPromise;
|
|
45
|
-
};
|
|
46
|
-
const onSigint = () => {
|
|
47
|
-
void shutdown("SIGINT");
|
|
48
|
-
};
|
|
49
|
-
const onSigterm = () => {
|
|
50
|
-
void shutdown("SIGTERM");
|
|
51
|
-
};
|
|
52
|
-
const onDisconnect = () => {
|
|
53
|
-
if (process.env.RYNX_DAEMON_LIFECYCLE === "follow-app") {
|
|
54
|
-
void shutdown("APP_DISCONNECT");
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
process.once("SIGINT", onSigint);
|
|
58
|
-
process.once("SIGTERM", onSigterm);
|
|
59
|
-
if (followsApp) {
|
|
60
|
-
process.once("disconnect", onDisconnect);
|
|
61
|
-
process.off("disconnect", recordParentDisconnect);
|
|
62
|
-
if (parentDisconnected || !process.connected) {
|
|
63
|
-
void shutdown("APP_DISCONNECT");
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
main().catch((err) => {
|
|
2
|
+
/** Direct daemon executable retained only for standalone PM2 supervision. */
|
|
3
|
+
import { runDaemonProcess } from "./process.js";
|
|
4
|
+
runDaemonProcess().catch((err) => {
|
|
68
5
|
console.error(`Fatal error: ${err instanceof Error ? (err.stack ?? err.message) : String(err)}`);
|
|
69
6
|
process.exit(1);
|
|
70
7
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { formatControlUrl, isPm2DaemonOnline, statusDaemon, stopDaemon, streamLogs, } from "./pm2.js";
|
|
2
|
+
export { resolveDaemonEntry } from "./entry-path.js";
|
|
3
|
+
export interface StandaloneDaemonLaunchContext {
|
|
4
|
+
builtinSkillsDir: string;
|
|
5
|
+
cliVersion: string;
|
|
6
|
+
productVersion: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function startDaemon(options: {
|
|
9
|
+
force: boolean;
|
|
10
|
+
quiet?: boolean;
|
|
11
|
+
context: StandaloneDaemonLaunchContext;
|
|
12
|
+
}): number;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { startDaemon as startPm2Daemon, } from "./pm2.js";
|
|
2
|
+
export { formatControlUrl, isPm2DaemonOnline, statusDaemon, stopDaemon, streamLogs, } from "./pm2.js";
|
|
3
|
+
export { resolveDaemonEntry } from "./entry-path.js";
|
|
4
|
+
export function startDaemon(options) {
|
|
5
|
+
return startPm2Daemon({
|
|
6
|
+
force: options.force,
|
|
7
|
+
quiet: options.quiet,
|
|
8
|
+
launchEnvironment: {
|
|
9
|
+
RYNX_BUILTIN_SKILLS_DIR: options.context.builtinSkillsDir,
|
|
10
|
+
RYNX_CLI_VERSION: options.context.cliVersion,
|
|
11
|
+
RYNX_DISTRIBUTION: "standalone",
|
|
12
|
+
RYNX_PRODUCT_VERSION: options.context.productVersion,
|
|
13
|
+
RYNX_DAEMON_LIFECYCLE: "standalone",
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export type MaintenanceLeaseReleaseOutcome = "released" | "not_active" | "denied";
|
|
2
|
+
export interface MaintenanceLeaseStoreOptions {
|
|
3
|
+
filePath?: string;
|
|
4
|
+
now?: () => number;
|
|
5
|
+
ttlMs?: number;
|
|
6
|
+
/** Test seam; production fsyncs the lease directory after rename/remove. */
|
|
7
|
+
syncDirectory?: (directory: string) => void;
|
|
8
|
+
/** Process-local recovery hook, invoked once when a live lease is observed expired. */
|
|
9
|
+
onExpired?: () => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function maintenanceLeaseFile(env?: NodeJS.ProcessEnv): string;
|
|
12
|
+
/**
|
|
13
|
+
* Cross-process admission fence used only during daemon replacement.
|
|
14
|
+
*
|
|
15
|
+
* The raw bearer token is never persisted. The bounded expiry means a crashed
|
|
16
|
+
* upgrader cannot leave the daemon permanently unavailable, while atomic rename
|
|
17
|
+
* ensures a replacement daemon sees either the complete lease or no lease.
|
|
18
|
+
*/
|
|
19
|
+
export declare class MaintenanceLeaseStore {
|
|
20
|
+
private readonly filePath;
|
|
21
|
+
private readonly now;
|
|
22
|
+
private readonly ttlMs;
|
|
23
|
+
private readonly syncDirectory;
|
|
24
|
+
private readonly onExpired;
|
|
25
|
+
private lease;
|
|
26
|
+
private expiryTimer;
|
|
27
|
+
constructor(options?: MaintenanceLeaseStoreOptions);
|
|
28
|
+
isActive(): boolean;
|
|
29
|
+
isHeldBy(token: string): boolean;
|
|
30
|
+
acquire(token: string): boolean;
|
|
31
|
+
release(token: string): MaintenanceLeaseReleaseOutcome;
|
|
32
|
+
private readPersistedLease;
|
|
33
|
+
private writePersistedLease;
|
|
34
|
+
private clear;
|
|
35
|
+
private clearFile;
|
|
36
|
+
private expire;
|
|
37
|
+
private scheduleExpiry;
|
|
38
|
+
private cancelExpiry;
|
|
39
|
+
}
|