@rynx-ai/daemon 0.1.10 → 0.1.11-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.
Files changed (156) hide show
  1. package/bundled-plugins/.rynx-plugin/marketplace.json +10 -0
  2. package/bundled-plugins/plugins/lark/.rynx-plugin/plugin.json +25 -0
  3. package/bundled-plugins/plugins/lark/dist/cli-mirror/mirror-index.d.ts +48 -0
  4. package/bundled-plugins/plugins/lark/dist/cli-mirror/mirror-index.js +56 -0
  5. package/bundled-plugins/plugins/lark/dist/cli-mirror/rollout-mirror.d.ts +85 -0
  6. package/bundled-plugins/plugins/lark/dist/cli-mirror/rollout-mirror.js +333 -0
  7. package/bundled-plugins/plugins/lark/dist/cli-mirror/rollout-watcher.d.ts +109 -0
  8. package/bundled-plugins/plugins/lark/dist/cli-mirror/rollout-watcher.js +347 -0
  9. package/bundled-plugins/plugins/lark/dist/host-adapters.d.ts +95 -0
  10. package/bundled-plugins/plugins/lark/dist/host-adapters.js +506 -0
  11. package/bundled-plugins/plugins/lark/dist/index.d.ts +7 -0
  12. package/bundled-plugins/plugins/lark/dist/index.js +7 -0
  13. package/bundled-plugins/plugins/lark/dist/lark-card-stream.d.ts +363 -0
  14. package/bundled-plugins/plugins/lark/dist/lark-card-stream.js +1335 -0
  15. package/bundled-plugins/plugins/lark/dist/lark-config-store.d.ts +30 -0
  16. package/bundled-plugins/plugins/lark/dist/lark-config-store.js +135 -0
  17. package/bundled-plugins/plugins/lark/dist/lark-content.d.ts +30 -0
  18. package/bundled-plugins/plugins/lark/dist/lark-content.js +138 -0
  19. package/bundled-plugins/plugins/lark/dist/lark-conversation-directory.d.ts +65 -0
  20. package/bundled-plugins/plugins/lark/dist/lark-conversation-directory.js +106 -0
  21. package/bundled-plugins/plugins/lark/dist/lark-diff-card.d.ts +25 -0
  22. package/bundled-plugins/plugins/lark/dist/lark-diff-card.js +58 -0
  23. package/bundled-plugins/plugins/lark/dist/lark-fork-transcript.d.ts +16 -0
  24. package/bundled-plugins/plugins/lark/dist/lark-fork-transcript.js +141 -0
  25. package/bundled-plugins/plugins/lark/dist/lark-resume-card.d.ts +31 -0
  26. package/bundled-plugins/plugins/lark/dist/lark-resume-card.js +105 -0
  27. package/bundled-plugins/plugins/lark/dist/lark-runtime-state-store.d.ts +18 -0
  28. package/bundled-plugins/plugins/lark/dist/lark-runtime-state-store.js +95 -0
  29. package/bundled-plugins/plugins/lark/dist/lark-sdk/client.d.ts +8 -0
  30. package/bundled-plugins/plugins/lark/dist/lark-sdk/client.js +32 -0
  31. package/bundled-plugins/plugins/lark/dist/lark-sdk/index.d.ts +1 -0
  32. package/bundled-plugins/plugins/lark/dist/lark-sdk/index.js +1 -0
  33. package/bundled-plugins/plugins/lark/dist/lark-sender.d.ts +114 -0
  34. package/bundled-plugins/plugins/lark/dist/lark-sender.js +323 -0
  35. package/bundled-plugins/plugins/lark/dist/lark-session-store.d.ts +13 -0
  36. package/bundled-plugins/plugins/lark/dist/lark-session-store.js +14 -0
  37. package/bundled-plugins/plugins/lark/dist/lark-settings-card.d.ts +55 -0
  38. package/bundled-plugins/plugins/lark/dist/lark-settings-card.js +158 -0
  39. package/bundled-plugins/plugins/lark/dist/lark-setup.d.ts +39 -0
  40. package/bundled-plugins/plugins/lark/dist/lark-setup.js +103 -0
  41. package/bundled-plugins/plugins/lark/dist/lark.d.ts +507 -0
  42. package/bundled-plugins/plugins/lark/dist/lark.js +1975 -0
  43. package/bundled-plugins/plugins/lark/dist/runtime.d.ts +13 -0
  44. package/bundled-plugins/plugins/lark/dist/runtime.js +131328 -0
  45. package/bundled-plugins/plugins/lark/dist/settings.d.ts +7 -0
  46. package/bundled-plugins/plugins/lark/dist/settings.js +126971 -0
  47. package/bundled-plugins/plugins/lark/package.json +57 -0
  48. package/bundled-plugins/plugins/lark/ui/assets/index-CGUVAMsv.css +1 -0
  49. package/bundled-plugins/plugins/lark/ui/assets/index-D8Amoe6a.js +201 -0
  50. package/bundled-plugins/plugins/lark/ui/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
  51. package/bundled-plugins/plugins/lark/ui/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
  52. package/bundled-plugins/plugins/lark/ui/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
  53. package/bundled-plugins/plugins/lark/ui/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
  54. package/bundled-plugins/plugins/lark/ui/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  55. package/bundled-plugins/plugins/lark/ui/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  56. package/bundled-plugins/plugins/lark/ui/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
  57. package/bundled-plugins/plugins/lark/ui/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  58. package/bundled-plugins/plugins/lark/ui/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  59. package/bundled-plugins/plugins/lark/ui/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  60. package/bundled-plugins/plugins/lark/ui/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  61. package/bundled-plugins/plugins/lark/ui/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  62. package/bundled-plugins/plugins/lark/ui/index.html +13 -0
  63. package/dist/agent-file.js +0 -1
  64. package/dist/browser-artifact-management.d.ts +4 -1
  65. package/dist/browser-artifact-management.js +18 -10
  66. package/dist/browser-artifacts.d.ts +1 -0
  67. package/dist/browser-artifacts.js +1 -0
  68. package/dist/bundled-plugins.d.ts +15 -0
  69. package/dist/bundled-plugins.js +134 -0
  70. package/dist/chrome-for-testing-runtime.d.ts +27 -0
  71. package/dist/chrome-for-testing-runtime.js +193 -0
  72. package/dist/chrome-for-testing-store.d.ts +2 -0
  73. package/dist/chrome-for-testing-store.js +9 -0
  74. package/dist/control-deps.d.ts +6 -2
  75. package/dist/control-deps.js +88 -82
  76. package/dist/daemon-server.d.ts +7 -1
  77. package/dist/daemon-server.js +310 -87
  78. package/dist/db.js +181 -124
  79. package/dist/entry-path.d.ts +3 -0
  80. package/dist/entry-path.js +12 -0
  81. package/dist/index-daemon.js +3 -66
  82. package/dist/lifecycle.d.ts +12 -0
  83. package/dist/lifecycle.js +16 -0
  84. package/dist/maintenance-lease.d.ts +39 -0
  85. package/dist/maintenance-lease.js +250 -0
  86. package/dist/migrations/cleanup-legacy-sessions.d.ts +1 -1
  87. package/dist/migrations/cleanup-legacy-sessions.js +33 -15
  88. package/dist/official-plugins.d.ts +2 -0
  89. package/dist/official-plugins.js +2 -0
  90. package/dist/plugin-cli.d.ts +1 -3
  91. package/dist/plugin-cli.js +56 -45
  92. package/dist/plugin-host-leases.d.ts +4 -0
  93. package/dist/plugin-host-leases.js +7 -0
  94. package/dist/plugin-host-rpc.d.ts +73 -6
  95. package/dist/plugin-host-rpc.js +354 -81
  96. package/dist/plugin-installer.d.ts +24 -55
  97. package/dist/plugin-installer.js +258 -412
  98. package/dist/plugin-management-service.d.ts +30 -23
  99. package/dist/plugin-management-service.js +288 -105
  100. package/dist/plugin-marketplace.d.ts +35 -0
  101. package/dist/plugin-marketplace.js +299 -0
  102. package/dist/plugin-package.d.ts +22 -24
  103. package/dist/plugin-package.js +520 -571
  104. package/dist/plugin-skill-context.d.ts +4 -0
  105. package/dist/plugin-skill-context.js +35 -0
  106. package/dist/plugin-store.d.ts +36 -37
  107. package/dist/plugin-store.js +138 -92
  108. package/dist/plugin-supervisor.d.ts +50 -125
  109. package/dist/plugin-supervisor.js +678 -1030
  110. package/dist/pm2.d.ts +11 -2
  111. package/dist/pm2.js +130 -28
  112. package/dist/process.d.ts +12 -0
  113. package/dist/process.js +91 -0
  114. package/dist/runtime-project-store.d.ts +9 -0
  115. package/dist/runtime-project-store.js +83 -0
  116. package/dist/session-fallback-workspace.d.ts +22 -0
  117. package/dist/session-fallback-workspace.js +120 -0
  118. package/dist/session-fork-store.d.ts +41 -0
  119. package/dist/session-fork-store.js +288 -0
  120. package/dist/session-launch-operations.d.ts +23 -2
  121. package/dist/session-launch-operations.js +48 -7
  122. package/dist/session-meta-store.d.ts +12 -9
  123. package/dist/session-meta-store.js +50 -49
  124. package/dist/session-portal-grant-store.d.ts +29 -0
  125. package/dist/session-portal-grant-store.js +84 -0
  126. package/dist/setup-service.d.ts +21 -0
  127. package/dist/setup-service.js +39 -0
  128. package/dist/skills-catalog.d.ts +11 -2
  129. package/dist/skills-catalog.js +307 -7
  130. package/dist/system-dependencies.d.ts +26 -0
  131. package/dist/system-dependencies.js +149 -0
  132. package/package.json +36 -20
  133. package/dist/browser-cli-args.d.ts +0 -20
  134. package/dist/browser-cli-args.js +0 -100
  135. package/dist/channel-store.d.ts +0 -22
  136. package/dist/channel-store.js +0 -65
  137. package/dist/cli.d.ts +0 -2
  138. package/dist/cli.js +0 -732
  139. package/dist/control-client.d.ts +0 -122
  140. package/dist/control-client.js +0 -855
  141. package/dist/control-endpoint.d.ts +0 -14
  142. package/dist/control-endpoint.js +0 -124
  143. package/dist/desktop-browser-host-client.d.ts +0 -35
  144. package/dist/desktop-browser-host-client.js +0 -415
  145. package/dist/instance-store.d.ts +0 -38
  146. package/dist/instance-store.js +0 -85
  147. package/dist/plugin-install-restart.d.ts +0 -13
  148. package/dist/plugin-install-restart.js +0 -24
  149. package/dist/plugin-runtime-control.d.ts +0 -2
  150. package/dist/plugin-runtime-control.js +0 -37
  151. package/dist/registry.d.ts +0 -10
  152. package/dist/registry.js +0 -52
  153. package/dist/setup.d.ts +0 -20
  154. package/dist/setup.js +0 -374
  155. package/dist/update.d.ts +0 -25
  156. package/dist/update.js +0 -133
@@ -0,0 +1,149 @@
1
+ import { execFile } from "node:child_process";
2
+ import { constants } from "node:fs";
3
+ import { access } from "node:fs/promises";
4
+ const PROBE_TIMEOUT_MS = 10_000;
5
+ const INSTALL_TIMEOUT_MS = 5 * 60_000;
6
+ const MAX_OUTPUT_BYTES = 1024 * 1024;
7
+ export async function inspectSystemDependencies(options = {}) {
8
+ const runCommand = options.runCommand ?? runSystemDependencyCommand;
9
+ const probe = await probeTmux(runCommand);
10
+ return {
11
+ tmux: probe.installed
12
+ ? { installed: true }
13
+ : { installed: false, detail: probe.detail },
14
+ };
15
+ }
16
+ export async function ensureSystemDependencies(options = {}) {
17
+ const runCommand = options.runCommand ?? runSystemDependencyCommand;
18
+ const before = await probeTmux(runCommand);
19
+ if (before.installed)
20
+ return { tmux: { installed: true } };
21
+ if (before.binaryPresent) {
22
+ throw new Error(before.detail);
23
+ }
24
+ const platform = options.platform ?? process.platform;
25
+ const findSystemExecutable = options.findSystemExecutable ?? findSystemCommand;
26
+ const manager = await resolvePackageManager(platform, findSystemExecutable);
27
+ if (!manager) {
28
+ throw new Error(platform === "darwin"
29
+ ? "tmux is required for live Sessions, but Homebrew is unavailable; install tmux and retry"
30
+ : "tmux is required for live Sessions, but no supported package manager (apt-get, dnf, or yum) is available");
31
+ }
32
+ const installArgs = manager.family === "apt"
33
+ ? ["install", "-y", "--no-install-recommends", "tmux"]
34
+ : manager.family === "brew"
35
+ ? ["install", "tmux"]
36
+ : ["install", "-y", "tmux"];
37
+ let command = manager.path;
38
+ let args = installArgs;
39
+ if (manager.family !== "brew") {
40
+ const getuid = options.getuid ?? (() => process.getuid?.());
41
+ if (getuid() !== 0) {
42
+ const sudo = await findSystemExecutable("sudo");
43
+ const sudoReady = sudo
44
+ ? await runCommand(sudo, ["-n", "true"], { timeoutMs: PROBE_TIMEOUT_MS })
45
+ : undefined;
46
+ if (!sudo || sudoReady?.exitCode !== 0) {
47
+ throw new Error(`tmux is required for live Sessions; install it as an administrator and retry: ` +
48
+ `${manager.commandForHumans} install -y tmux`);
49
+ }
50
+ command = sudo;
51
+ args = ["-n", manager.path, ...installArgs];
52
+ }
53
+ }
54
+ options.onProgress?.("installing required system dependency: tmux");
55
+ const installed = await runCommand(command, args, { timeoutMs: INSTALL_TIMEOUT_MS });
56
+ if (installed.exitCode !== 0) {
57
+ throw new Error(`failed to install required system dependency tmux: ${commandFailure(installed)}`);
58
+ }
59
+ const after = await inspectSystemDependencies({ runCommand });
60
+ if (!after.tmux.installed) {
61
+ throw new Error(`tmux installation completed but tmux is still unavailable: ${after.tmux.detail}`);
62
+ }
63
+ options.onProgress?.("verified required system dependency: tmux");
64
+ return after;
65
+ }
66
+ /**
67
+ * A version probe only proves the binary can start. Live Sessions need tmux to
68
+ * create a server and socket, so exercise that path with a private probe server
69
+ * that cannot interfere with a user's existing tmux sessions.
70
+ */
71
+ async function probeTmux(runCommand) {
72
+ const version = await runCommand("tmux", ["-V"], { timeoutMs: PROBE_TIMEOUT_MS });
73
+ if (version.exitCode !== 0) {
74
+ return {
75
+ installed: false,
76
+ binaryPresent: version.errorCode !== "ENOENT",
77
+ detail: `tmux -V failed: ${commandFailure(version)}`,
78
+ };
79
+ }
80
+ const socketName = `rynx-setup-probe-${process.pid}-${Date.now()}`;
81
+ const functional = await runCommand("tmux", ["-L", socketName, "new-session", "-d", "-s", "probe", "true"], { timeoutMs: PROBE_TIMEOUT_MS });
82
+ await runCommand("tmux", ["-L", socketName, "kill-server"], {
83
+ timeoutMs: PROBE_TIMEOUT_MS,
84
+ });
85
+ if (functional.exitCode !== 0) {
86
+ return {
87
+ installed: false,
88
+ binaryPresent: true,
89
+ detail: `${version.stdout.trim() || "tmux"} is installed but cannot start a server: ` +
90
+ commandFailure(functional),
91
+ };
92
+ }
93
+ return { installed: true, binaryPresent: true };
94
+ }
95
+ async function resolvePackageManager(platform, findExecutable) {
96
+ if (platform === "darwin") {
97
+ const brew = await findExecutable("brew");
98
+ return brew ? { family: "brew", path: brew, commandForHumans: "brew" } : undefined;
99
+ }
100
+ if (platform !== "linux")
101
+ return undefined;
102
+ const apt = await findExecutable("apt-get");
103
+ if (apt)
104
+ return { family: "apt", path: apt, commandForHumans: "apt-get" };
105
+ const dnf = await findExecutable("dnf");
106
+ if (dnf)
107
+ return { family: "rpm", path: dnf, commandForHumans: "dnf" };
108
+ const yum = await findExecutable("yum");
109
+ return yum ? { family: "rpm", path: yum, commandForHumans: "yum" } : undefined;
110
+ }
111
+ async function findSystemCommand(name) {
112
+ const directories = name === "brew"
113
+ ? ["/opt/homebrew/bin", "/usr/local/bin"]
114
+ : ["/usr/bin", "/bin", "/usr/sbin", "/sbin"];
115
+ for (const directory of directories) {
116
+ const candidate = `${directory}/${name}`;
117
+ try {
118
+ await access(candidate, constants.X_OK);
119
+ return candidate;
120
+ }
121
+ catch {
122
+ // Try the next standard system directory.
123
+ }
124
+ }
125
+ return undefined;
126
+ }
127
+ function runSystemDependencyCommand(command, args, options) {
128
+ return new Promise((resolveResult) => {
129
+ execFile(command, [...args], {
130
+ encoding: "utf8",
131
+ env: { ...process.env, DEBIAN_FRONTEND: "noninteractive", LC_ALL: "C" },
132
+ maxBuffer: MAX_OUTPUT_BYTES,
133
+ timeout: options.timeoutMs,
134
+ }, (error, stdout, stderr) => {
135
+ resolveResult({
136
+ exitCode: error
137
+ ? typeof error.code === "number" ? error.code : null
138
+ : 0,
139
+ stdout,
140
+ stderr,
141
+ ...(error && typeof error.code === "string" ? { errorCode: error.code } : {}),
142
+ });
143
+ });
144
+ });
145
+ }
146
+ function commandFailure(result) {
147
+ const detail = result.stderr.trim() || result.stdout.trim() || result.errorCode;
148
+ return detail ? detail.slice(0, 2_000) : `exit code ${result.exitCode ?? "unknown"}`;
149
+ }
package/package.json CHANGED
@@ -1,50 +1,66 @@
1
1
  {
2
2
  "name": "@rynx-ai/daemon",
3
- "version": "0.1.10",
3
+ "version": "0.1.11-beta.10",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/rynx-ai/rynx.git",
7
7
  "directory": "packages/daemon"
8
8
  },
9
- "description": "Rynx daemon CLI: supervises the local agent control plane and isolated optional plugin runtimes.",
9
+ "description": "Rynx resident control-plane service and standalone lifecycle implementation.",
10
10
  "type": "module",
11
+ "engines": {
12
+ "node": ">=22"
13
+ },
11
14
  "publishConfig": {
12
15
  "registry": "https://registry.npmjs.org/",
13
16
  "access": "public"
14
17
  },
15
18
  "files": [
16
- "dist"
19
+ "dist",
20
+ "bundled-plugins"
17
21
  ],
18
- "bin": {
19
- "rynx": "./dist/cli.js"
20
- },
21
- "main": "./dist/index-daemon.js",
22
22
  "exports": {
23
- "./client": {
24
- "types": "./dist/control-client.d.ts",
25
- "default": "./dist/control-client.js"
23
+ "./entry-path": {
24
+ "types": "./dist/entry-path.d.ts",
25
+ "default": "./dist/entry-path.js"
26
+ },
27
+ "./lifecycle": {
28
+ "types": "./dist/lifecycle.d.ts",
29
+ "default": "./dist/lifecycle.js"
30
+ },
31
+ "./browser-artifacts": {
32
+ "types": "./dist/browser-artifacts.d.ts",
33
+ "default": "./dist/browser-artifacts.js"
34
+ },
35
+ "./setup-service": {
36
+ "types": "./dist/setup-service.d.ts",
37
+ "default": "./dist/setup-service.js"
38
+ },
39
+ "./internal/process": {
40
+ "types": "./dist/process.d.ts",
41
+ "default": "./dist/process.js"
26
42
  }
27
43
  },
28
44
  "dependencies": {
29
- "@clack/prompts": "^1.6.0",
30
45
  "better-sqlite3": "^12.11.1",
31
46
  "extract-zip": "2.0.1",
32
47
  "pm2": "^6.0.0",
33
48
  "tar": "^7.5.19",
34
49
  "ws": "^8.21.0",
35
- "@rynx-ai/emulator": "0.1.10",
36
- "@rynx-ai/plugin-runner": "0.1.10",
37
- "@rynx-ai/core": "0.1.10",
38
- "@rynx-ai/protocol": "0.1.10",
39
- "@rynx-ai/remote-runtime-client": "0.1.10",
40
- "@rynx-ai/plugin-sdk": "0.1.10",
41
- "@rynx-ai/server": "0.1.10"
50
+ "@rynx-ai/core": "0.1.11-beta.10",
51
+ "@rynx-ai/emulator": "0.1.11-beta.10",
52
+ "@rynx-ai/plugin-runner": "0.1.11-beta.10",
53
+ "@rynx-ai/plugin-sdk": "0.1.11-beta.10",
54
+ "@rynx-ai/protocol": "0.1.11-beta.10",
55
+ "@rynx-ai/remote-runtime-client": "0.1.11-beta.10",
56
+ "@rynx-ai/server": "0.1.11-beta.10"
42
57
  },
43
58
  "devDependencies": {
44
- "@types/ws": "^8.18.1"
59
+ "@types/ws": "^8.18.1",
60
+ "@rynx-ai/plugin-channel-lark": "0.1.11-beta.10"
45
61
  },
46
62
  "scripts": {
47
- "build": "rm -rf dist && tsc -p tsconfig.json && chmod +x dist/cli.js dist/index-daemon.js",
63
+ "build": "rm -rf dist bundled-plugins && tsc -p tsconfig.json && chmod +x dist/index-daemon.js && node ../../scripts/stage-bundled-plugins.mjs",
48
64
  "dev": "tsx watch --tsconfig ../../tsconfig.json src/index-daemon.ts"
49
65
  }
50
66
  }
@@ -1,20 +0,0 @@
1
- export type BrowserCliSubcommand = "install" | "update" | "version" | "clean" | "open" | "status" | "pages" | "endpoint" | "close";
2
- export interface BrowserCliArgs {
3
- subcommand: BrowserCliSubcommand;
4
- json: boolean;
5
- ensure: boolean;
6
- channel?: string;
7
- version?: string;
8
- runtime?: string;
9
- session?: string;
10
- url?: string;
11
- }
12
- export interface BrowserCliTarget {
13
- runtimeSelector: string;
14
- sessionId: string;
15
- credential?: RuntimeBrowserBootstrapCredential;
16
- }
17
- export declare function parseBrowserCliArgs(args: readonly string[]): BrowserCliArgs;
18
- /** Resolve authority without ever turning a managed Session into an operator. */
19
- export declare function resolveBrowserCliTarget(args: BrowserCliArgs, managedCredential: RuntimeBrowserBootstrapCredential | undefined): BrowserCliTarget;
20
- import type { RuntimeBrowserBootstrapCredential } from "@rynx-ai/protocol/runtime-browser-bootstrap";
@@ -1,100 +0,0 @@
1
- const SPECS = {
2
- install: { values: ["--channel", "--version"], flags: ["--json"] },
3
- update: { values: ["--channel"], flags: ["--json"] },
4
- version: { values: [], flags: ["--json"] },
5
- clean: { values: [], flags: ["--json"] },
6
- open: {
7
- values: ["--url", "--session", "--runtime"],
8
- flags: ["--json"],
9
- positionalUrl: true,
10
- },
11
- status: { values: ["--session", "--runtime"], flags: ["--json"] },
12
- pages: { values: ["--session", "--runtime"], flags: ["--json"] },
13
- endpoint: { values: ["--session"], flags: ["--ensure", "--json"] },
14
- close: { values: ["--session", "--runtime"], flags: ["--json"] },
15
- };
16
- export function parseBrowserCliArgs(args) {
17
- const subcommand = args[0];
18
- if (!isBrowserSubcommand(subcommand)) {
19
- throw new Error("browser: expected install, update, version, clean, open, status, pages, endpoint, or close");
20
- }
21
- const spec = SPECS[subcommand];
22
- const values = new Map();
23
- const flags = new Set();
24
- const positionals = [];
25
- for (let index = 1; index < args.length; index += 1) {
26
- const arg = args[index];
27
- if (arg.startsWith("--")) {
28
- if (spec.flags.includes(arg)) {
29
- if (flags.has(arg))
30
- throw new Error(`browser ${subcommand}: duplicate option ${arg}`);
31
- flags.add(arg);
32
- continue;
33
- }
34
- if (spec.values.includes(arg)) {
35
- if (values.has(arg))
36
- throw new Error(`browser ${subcommand}: duplicate option ${arg}`);
37
- const value = args[index + 1];
38
- if (!value || value.startsWith("--")) {
39
- throw new Error(`browser ${subcommand}: ${arg} requires a value`);
40
- }
41
- values.set(arg, value);
42
- index += 1;
43
- continue;
44
- }
45
- throw new Error(`browser ${subcommand}: unknown option ${arg}`);
46
- }
47
- positionals.push(arg);
48
- }
49
- if (!spec.positionalUrl && positionals.length > 0) {
50
- throw new Error(`browser ${subcommand}: unexpected argument ${positionals[0]}`);
51
- }
52
- if (positionals.length > 1) {
53
- throw new Error(`browser ${subcommand}: unexpected extra argument ${positionals[1]}`);
54
- }
55
- if (positionals.length === 1 && values.has("--url")) {
56
- throw new Error("browser open: pass the URL once, either positionally or with --url");
57
- }
58
- return {
59
- subcommand,
60
- json: flags.has("--json"),
61
- ensure: flags.has("--ensure"),
62
- ...(values.has("--channel") ? { channel: values.get("--channel") } : {}),
63
- ...(values.has("--version") ? { version: values.get("--version") } : {}),
64
- ...(values.has("--runtime") ? { runtime: values.get("--runtime") } : {}),
65
- ...(values.has("--session") ? { session: values.get("--session") } : {}),
66
- ...(values.has("--url") || positionals[0]
67
- ? { url: values.get("--url") ?? positionals[0] }
68
- : {}),
69
- };
70
- }
71
- /** Resolve authority without ever turning a managed Session into an operator. */
72
- export function resolveBrowserCliTarget(args, managedCredential) {
73
- const runtimeSelector = args.runtime ?? "local";
74
- if (runtimeSelector !== "local") {
75
- if (managedCredential) {
76
- throw new Error("browser: a managed Session cannot select another Runtime");
77
- }
78
- if (!args.session) {
79
- throw new Error("browser: --session is required when selecting a remote Runtime");
80
- }
81
- return { runtimeSelector, sessionId: args.session };
82
- }
83
- if (managedCredential) {
84
- if (args.session && args.session !== managedCredential.sessionId) {
85
- throw new Error("browser: a managed Session cannot control another Session with --session");
86
- }
87
- return {
88
- runtimeSelector: "local",
89
- sessionId: managedCredential.sessionId,
90
- credential: managedCredential,
91
- };
92
- }
93
- if (!args.session) {
94
- throw new Error("browser: run inside a managed Rynx Session or pass --session for operator access");
95
- }
96
- return { runtimeSelector: "local", sessionId: args.session };
97
- }
98
- function isBrowserSubcommand(value) {
99
- return value !== undefined && Object.hasOwn(SPECS, value);
100
- }
@@ -1,22 +0,0 @@
1
- export interface ChannelConfig {
2
- /** Stable system-assigned id (never changes). */
3
- id: string;
4
- /** Human-visible, unique, editable label. */
5
- name: string;
6
- /** Channel type (which plugin-contributed factory). */
7
- type: string;
8
- options?: Record<string, unknown>;
9
- }
10
- export declare function listChannels(): ChannelConfig[];
11
- export declare function getChannel(id: string): ChannelConfig | undefined;
12
- /** Create a channel with a system-assigned id and a unique `name` label. */
13
- export declare function createChannel(input: {
14
- name: string;
15
- type: string;
16
- options?: Record<string, unknown>;
17
- }): ChannelConfig;
18
- export declare function renameChannel(id: string, name: string): void;
19
- /** Merge credentials/options into a channel (e.g. the result of an authorize flow). */
20
- export declare function setChannelOptions(id: string, options: Record<string, unknown>): void;
21
- /** Remove a channel; its bound instance (if any) cascades away (FK ON DELETE CASCADE). */
22
- export declare function removeChannel(id: string): void;
@@ -1,65 +0,0 @@
1
- /**
2
- * `channels` table CRUD — a channel is a plugin type + its config/credentials
3
- * (`options`), configured and authorized on its own. No agent binding here;
4
- * that lives on an {@link import("./instance-store.js")} instance.
5
- *
6
- * Credentials stay in each channel's `options` and are sent only to that
7
- * plugin runner instance; they are never copied into the daemon environment.
8
- */
9
- import { randomUUID } from "node:crypto";
10
- import { db } from "./db.js";
11
- function parseOptions(raw) {
12
- if (!raw)
13
- return undefined;
14
- try {
15
- const parsed = JSON.parse(raw);
16
- return parsed && typeof parsed === "object" ? parsed : undefined;
17
- }
18
- catch {
19
- return undefined;
20
- }
21
- }
22
- function toConfig(row) {
23
- return { id: row.id, name: row.name, type: row.type, options: parseOptions(row.options) };
24
- }
25
- export function listChannels() {
26
- const rows = db().prepare("SELECT * FROM channels ORDER BY name").all();
27
- return rows.map(toConfig);
28
- }
29
- export function getChannel(id) {
30
- const row = db().prepare("SELECT * FROM channels WHERE id = ?").get(id);
31
- return row ? toConfig(row) : undefined;
32
- }
33
- /** Create a channel with a system-assigned id and a unique `name` label. */
34
- export function createChannel(input) {
35
- const id = randomUUID();
36
- const now = new Date().toISOString();
37
- db()
38
- .prepare(`INSERT INTO channels (id, name, type, options, created_at, updated_at)
39
- VALUES (@id, @name, @type, @options, @now, @now)`)
40
- .run({
41
- id,
42
- name: input.name,
43
- type: input.type,
44
- options: input.options ? JSON.stringify(input.options) : null,
45
- now,
46
- });
47
- return getChannel(id);
48
- }
49
- export function renameChannel(id, name) {
50
- db().prepare("UPDATE channels SET name = ?, updated_at = ? WHERE id = ?").run(name, new Date().toISOString(), id);
51
- }
52
- /** Merge credentials/options into a channel (e.g. the result of an authorize flow). */
53
- export function setChannelOptions(id, options) {
54
- const current = getChannel(id);
55
- if (!current)
56
- return;
57
- const merged = { ...(current.options ?? {}), ...options };
58
- db()
59
- .prepare("UPDATE channels SET options = ?, updated_at = ? WHERE id = ?")
60
- .run(JSON.stringify(merged), new Date().toISOString(), id);
61
- }
62
- /** Remove a channel; its bound instance (if any) cascades away (FK ON DELETE CASCADE). */
63
- export function removeChannel(id) {
64
- db().prepare("DELETE FROM channels WHERE id = ?").run(id);
65
- }
package/dist/cli.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};