@parall/parall 1.31.0 → 1.32.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.
Files changed (47) hide show
  1. package/dist/accounts.d.ts +1 -1
  2. package/dist/accounts.js +4 -4
  3. package/dist/channel.d.ts +2 -2
  4. package/dist/channel.d.ts.map +1 -1
  5. package/dist/channel.js +10 -10
  6. package/dist/config-manager.d.ts +1 -1
  7. package/dist/config-manager.d.ts.map +1 -1
  8. package/dist/config-manager.js +70 -30
  9. package/dist/fork.d.ts.map +1 -1
  10. package/dist/fork.js +17 -17
  11. package/dist/gateway.d.ts +3 -3
  12. package/dist/gateway.d.ts.map +1 -1
  13. package/dist/gateway.js +147 -127
  14. package/dist/hooks.d.ts +1 -1
  15. package/dist/hooks.d.ts.map +1 -1
  16. package/dist/hooks.js +52 -26
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.js +7 -7
  19. package/dist/oc-session.d.ts.map +1 -1
  20. package/dist/oc-session.js +35 -27
  21. package/dist/outbound.d.ts +2 -2
  22. package/dist/outbound.d.ts.map +1 -1
  23. package/dist/outbound.js +13 -14
  24. package/dist/routing.d.ts +2 -2
  25. package/dist/routing.js +1 -1
  26. package/dist/runtime.d.ts +5 -5
  27. package/dist/runtime.d.ts.map +1 -1
  28. package/dist/runtime.js +2 -2
  29. package/dist/session.js +4 -4
  30. package/dist/wiki-helper.d.ts.map +1 -1
  31. package/dist/wiki-helper.js +27 -27
  32. package/openclaw.plugin.json +4 -1
  33. package/package.json +3 -3
  34. package/skills/parall-clips/SKILL.md +48 -0
  35. package/src/accounts.ts +5 -5
  36. package/src/channel.ts +15 -14
  37. package/src/config-manager.ts +79 -34
  38. package/src/fork.ts +26 -22
  39. package/src/gateway.ts +177 -134
  40. package/src/hooks.ts +109 -50
  41. package/src/index.ts +8 -8
  42. package/src/oc-session.ts +43 -35
  43. package/src/outbound.ts +18 -17
  44. package/src/routing.ts +2 -2
  45. package/src/runtime.ts +11 -7
  46. package/src/session.ts +4 -4
  47. package/src/wiki-helper.ts +47 -34
@@ -1,5 +1,5 @@
1
- import { spawn, spawnSync } from "node:child_process";
2
- import path from "node:path";
1
+ import { spawn, spawnSync } from 'node:child_process';
2
+ import path from 'node:path';
3
3
 
4
4
  type Logger = {
5
5
  info?: (message: string) => void;
@@ -26,7 +26,7 @@ const DEFAULT_SYNC_TIMEOUT_MS = 90_000; // includes npx cold-start download time
26
26
  const DEFAULT_WATCH_INTERVAL_SEC = 30;
27
27
 
28
28
  function isCommandMissing(error: unknown): boolean {
29
- return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
29
+ return typeof error === 'object' && error !== null && 'code' in error && error.code === 'ENOENT';
30
30
  }
31
31
 
32
32
  // Prefer bare `parall` (globally installed in hosted images). Fall back to
@@ -34,16 +34,16 @@ function isCommandMissing(error: unknown): boolean {
34
34
  let _cli: { cmd: string; prefix: string[] } | undefined;
35
35
  function resolveParallCli(): { cmd: string; prefix: string[] } {
36
36
  if (!_cli) {
37
- const r = spawnSync("parall", ["--version"], { stdio: "ignore", timeout: 5_000 });
37
+ const r = spawnSync('parall', ['--version'], { stdio: 'ignore', timeout: 5_000 });
38
38
  _cli = r.error
39
- ? { cmd: "npx", prefix: ["--yes", "@parall/cli@latest"] }
40
- : { cmd: "parall", prefix: [] };
39
+ ? { cmd: 'npx', prefix: ['--yes', '@parall/cli@latest'] }
40
+ : { cmd: 'parall', prefix: [] };
41
41
  }
42
42
  return _cli;
43
43
  }
44
44
 
45
45
  function resolveMountRoot(stateDir: string): string {
46
- return process.env.PRLL_WIKI_MOUNT_ROOT?.trim() || path.join(stateDir, "workspace");
46
+ return process.env.PRLL_WIKI_MOUNT_ROOT?.trim() || path.join(stateDir, 'workspace');
47
47
  }
48
48
 
49
49
  function resolveWatchIntervalSec(): number {
@@ -66,18 +66,21 @@ function buildWikiHelperEnv(params: StartWikiHelperParams, mountRoot: string): N
66
66
  };
67
67
  }
68
68
 
69
- async function runWikiSync(params: StartWikiHelperParams, env: NodeJS.ProcessEnv): Promise<"ok" | "missing" | "failed"> {
69
+ async function runWikiSync(
70
+ params: StartWikiHelperParams,
71
+ env: NodeJS.ProcessEnv,
72
+ ): Promise<'ok' | 'missing' | 'failed'> {
70
73
  return new Promise((resolve) => {
71
74
  let timedOut = false;
72
75
  let settled = false;
73
76
 
74
77
  const { cmd, prefix } = resolveParallCli();
75
- const child = spawn(cmd, [...prefix, "wiki", "sync"], {
78
+ const child = spawn(cmd, [...prefix, 'wiki', 'sync'], {
76
79
  env,
77
- stdio: "ignore",
80
+ stdio: 'ignore',
78
81
  });
79
82
 
80
- const settle = (value: "ok" | "missing" | "failed") => {
83
+ const settle = (value: 'ok' | 'missing' | 'failed') => {
81
84
  if (settled) return;
82
85
  settled = true;
83
86
  resolve(value);
@@ -85,38 +88,44 @@ async function runWikiSync(params: StartWikiHelperParams, env: NodeJS.ProcessEnv
85
88
 
86
89
  const timer = setTimeout(() => {
87
90
  timedOut = true;
88
- params.log?.warn?.(`parall[${params.accountId}]: parall sync timed out after ${DEFAULT_SYNC_TIMEOUT_MS}ms`);
89
- child.kill("SIGTERM");
90
- setTimeout(() => child.kill("SIGKILL"), 5_000).unref();
91
+ params.log?.warn?.(
92
+ `parall[${params.accountId}]: parall sync timed out after ${DEFAULT_SYNC_TIMEOUT_MS}ms`,
93
+ );
94
+ child.kill('SIGTERM');
95
+ setTimeout(() => child.kill('SIGKILL'), 5_000).unref();
91
96
  }, DEFAULT_SYNC_TIMEOUT_MS);
92
97
  timer.unref();
93
98
 
94
- child.on("error", (error) => {
99
+ child.on('error', (error) => {
95
100
  clearTimeout(timer);
96
101
  if (isCommandMissing(error)) {
97
- params.log?.warn?.(`parall[${params.accountId}]: parall not installed, skipping wiki auto-sync/watch`);
98
- settle("missing");
102
+ params.log?.warn?.(
103
+ `parall[${params.accountId}]: parall not installed, skipping wiki auto-sync/watch`,
104
+ );
105
+ settle('missing');
99
106
  return;
100
107
  }
101
- params.log?.warn?.(`parall[${params.accountId}]: parall sync failed to start: ${String(error)}`);
102
- settle("failed");
108
+ params.log?.warn?.(
109
+ `parall[${params.accountId}]: parall sync failed to start: ${String(error)}`,
110
+ );
111
+ settle('failed');
103
112
  });
104
113
 
105
- child.on("exit", (code, signal) => {
114
+ child.on('exit', (code, signal) => {
106
115
  clearTimeout(timer);
107
116
  if (timedOut) {
108
- settle("failed");
117
+ settle('failed');
109
118
  return;
110
119
  }
111
120
  if (code === 0) {
112
121
  params.log?.info?.(`parall[${params.accountId}]: parall sync completed`);
113
- settle("ok");
122
+ settle('ok');
114
123
  return;
115
124
  }
116
125
  params.log?.warn?.(
117
- `parall[${params.accountId}]: parall sync exited with code=${code ?? "null"} signal=${signal ?? "null"}`,
126
+ `parall[${params.accountId}]: parall sync exited with code=${code ?? 'null'} signal=${signal ?? 'null'}`,
118
127
  );
119
- settle("failed");
128
+ settle('failed');
120
129
  });
121
130
  });
122
131
  }
@@ -126,7 +135,7 @@ export async function startWikiHelper(params: StartWikiHelperParams): Promise<Wi
126
135
  const env = buildWikiHelperEnv(params, mountRoot);
127
136
 
128
137
  const syncResult = await runWikiSync(params, env);
129
- if (syncResult === "missing") {
138
+ if (syncResult === 'missing') {
130
139
  return {
131
140
  mountRoot,
132
141
  stop() {},
@@ -136,36 +145,40 @@ export async function startWikiHelper(params: StartWikiHelperParams): Promise<Wi
136
145
  const intervalSec = resolveWatchIntervalSec();
137
146
  let stopped = false;
138
147
  const { cmd, prefix } = resolveParallCli();
139
- const watch = spawn(cmd, [...prefix, "wiki", "watch", "--interval-sec", String(intervalSec)], {
148
+ const watch = spawn(cmd, [...prefix, 'wiki', 'watch', '--interval-sec', String(intervalSec)], {
140
149
  env,
141
- stdio: "ignore",
150
+ stdio: 'ignore',
142
151
  });
143
152
 
144
- watch.on("error", (error) => {
153
+ watch.on('error', (error) => {
145
154
  if (stopped) return;
146
155
  if (isCommandMissing(error)) {
147
- params.log?.warn?.(`parall[${params.accountId}]: parall disappeared before watch could start`);
156
+ params.log?.warn?.(
157
+ `parall[${params.accountId}]: parall disappeared before watch could start`,
158
+ );
148
159
  return;
149
160
  }
150
161
  params.log?.warn?.(`parall[${params.accountId}]: parall watch failed: ${String(error)}`);
151
162
  });
152
163
 
153
- watch.on("exit", (code, signal) => {
164
+ watch.on('exit', (code, signal) => {
154
165
  if (stopped) return;
155
166
  params.log?.warn?.(
156
- `parall[${params.accountId}]: parall watch exited with code=${code ?? "null"} signal=${signal ?? "null"}`,
167
+ `parall[${params.accountId}]: parall watch exited with code=${code ?? 'null'} signal=${signal ?? 'null'}`,
157
168
  );
158
169
  });
159
170
 
160
- params.log?.info?.(`parall[${params.accountId}]: parall watch started (interval=${intervalSec}s)`);
171
+ params.log?.info?.(
172
+ `parall[${params.accountId}]: parall watch started (interval=${intervalSec}s)`,
173
+ );
161
174
 
162
175
  return {
163
176
  mountRoot,
164
177
  stop() {
165
178
  stopped = true;
166
179
  if (watch.exitCode === null && watch.signalCode === null) {
167
- watch.kill("SIGTERM");
168
- setTimeout(() => watch.kill("SIGKILL"), 5_000).unref();
180
+ watch.kill('SIGTERM');
181
+ setTimeout(() => watch.kill('SIGKILL'), 5_000).unref();
169
182
  }
170
183
  },
171
184
  };