@parall/parall 1.30.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.
- package/dist/accounts.d.ts +1 -1
- package/dist/accounts.js +4 -4
- package/dist/channel.d.ts +2 -2
- package/dist/channel.d.ts.map +1 -1
- package/dist/channel.js +10 -10
- package/dist/config-manager.d.ts +1 -1
- package/dist/config-manager.d.ts.map +1 -1
- package/dist/config-manager.js +70 -30
- package/dist/fork.d.ts.map +1 -1
- package/dist/fork.js +17 -17
- package/dist/gateway.d.ts +3 -3
- package/dist/gateway.d.ts.map +1 -1
- package/dist/gateway.js +214 -171
- package/dist/hooks.d.ts +1 -1
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +52 -26
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -7
- package/dist/oc-session.d.ts.map +1 -1
- package/dist/oc-session.js +35 -27
- package/dist/outbound.d.ts +2 -2
- package/dist/outbound.d.ts.map +1 -1
- package/dist/outbound.js +13 -14
- package/dist/routing.d.ts +2 -2
- package/dist/routing.js +1 -1
- package/dist/runtime.d.ts +5 -5
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +2 -2
- package/dist/session.js +4 -4
- package/dist/wiki-helper.d.ts.map +1 -1
- package/dist/wiki-helper.js +27 -27
- package/openclaw.plugin.json +4 -1
- package/package.json +3 -3
- package/skills/parall-clips/SKILL.md +48 -0
- package/src/accounts.ts +5 -5
- package/src/channel.ts +15 -14
- package/src/config-manager.ts +79 -34
- package/src/fork.ts +26 -22
- package/src/gateway.ts +245 -175
- package/src/hooks.ts +109 -50
- package/src/index.ts +8 -8
- package/src/oc-session.ts +43 -35
- package/src/outbound.ts +18 -17
- package/src/routing.ts +2 -2
- package/src/runtime.ts +11 -7
- package/src/session.ts +4 -4
- package/src/wiki-helper.ts +47 -34
package/src/wiki-helper.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { spawn, spawnSync } from
|
|
2
|
-
import path from
|
|
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 ===
|
|
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(
|
|
37
|
+
const r = spawnSync('parall', ['--version'], { stdio: 'ignore', timeout: 5_000 });
|
|
38
38
|
_cli = r.error
|
|
39
|
-
? { cmd:
|
|
40
|
-
: { cmd:
|
|
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,
|
|
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(
|
|
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,
|
|
78
|
+
const child = spawn(cmd, [...prefix, 'wiki', 'sync'], {
|
|
76
79
|
env,
|
|
77
|
-
stdio:
|
|
80
|
+
stdio: 'ignore',
|
|
78
81
|
});
|
|
79
82
|
|
|
80
|
-
const settle = (value:
|
|
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?.(
|
|
89
|
-
|
|
90
|
-
|
|
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(
|
|
99
|
+
child.on('error', (error) => {
|
|
95
100
|
clearTimeout(timer);
|
|
96
101
|
if (isCommandMissing(error)) {
|
|
97
|
-
params.log?.warn?.(
|
|
98
|
-
|
|
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?.(
|
|
102
|
-
|
|
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(
|
|
114
|
+
child.on('exit', (code, signal) => {
|
|
106
115
|
clearTimeout(timer);
|
|
107
116
|
if (timedOut) {
|
|
108
|
-
settle(
|
|
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(
|
|
122
|
+
settle('ok');
|
|
114
123
|
return;
|
|
115
124
|
}
|
|
116
125
|
params.log?.warn?.(
|
|
117
|
-
`parall[${params.accountId}]: parall sync exited with code=${code ??
|
|
126
|
+
`parall[${params.accountId}]: parall sync exited with code=${code ?? 'null'} signal=${signal ?? 'null'}`,
|
|
118
127
|
);
|
|
119
|
-
settle(
|
|
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 ===
|
|
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,
|
|
148
|
+
const watch = spawn(cmd, [...prefix, 'wiki', 'watch', '--interval-sec', String(intervalSec)], {
|
|
140
149
|
env,
|
|
141
|
-
stdio:
|
|
150
|
+
stdio: 'ignore',
|
|
142
151
|
});
|
|
143
152
|
|
|
144
|
-
watch.on(
|
|
153
|
+
watch.on('error', (error) => {
|
|
145
154
|
if (stopped) return;
|
|
146
155
|
if (isCommandMissing(error)) {
|
|
147
|
-
params.log?.warn?.(
|
|
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(
|
|
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 ??
|
|
167
|
+
`parall[${params.accountId}]: parall watch exited with code=${code ?? 'null'} signal=${signal ?? 'null'}`,
|
|
157
168
|
);
|
|
158
169
|
});
|
|
159
170
|
|
|
160
|
-
params.log?.info?.(
|
|
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(
|
|
168
|
-
setTimeout(() => watch.kill(
|
|
180
|
+
watch.kill('SIGTERM');
|
|
181
|
+
setTimeout(() => watch.kill('SIGKILL'), 5_000).unref();
|
|
169
182
|
}
|
|
170
183
|
},
|
|
171
184
|
};
|