@kagura-agent/atlas-openclaw 0.1.1 → 0.1.2
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 +1 -1
- package/package.json +1 -1
- package/worker.mjs +19 -6
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ Increase the committed package version before another release. An existing versi
|
|
|
40
40
|
|
|
41
41
|
## Design
|
|
42
42
|
|
|
43
|
-
WebSocket notifications wake the worker; reconnecting and periodic server notifications refresh the queue. Finishing a run immediately checks for the next queued task. Short renewable run leases prevent a lost worker from silently reexecuting work. Tool writes use stable request IDs; canvas changes, run updates and receipts commit in the same SQLite transaction. Lost HTTP responses can be retried without duplicating writes. Final settlement is idempotent too.
|
|
43
|
+
WebSocket notifications wake the worker; reconnecting and periodic server notifications refresh the queue. If no server notification or ping arrives for 45 seconds, the plugin closes the stale socket and reconnects, including when a sleeping computer or a network interruption leaves TCP apparently open. Finishing a run immediately checks for the next queued task. Short renewable run leases prevent a lost worker from silently reexecuting work. Tool writes use stable request IDs; canvas changes, run updates and receipts commit in the same SQLite transaction. Lost HTTP responses can be retried without duplicating writes. Final settlement is idempotent too.
|
|
44
44
|
|
|
45
45
|
Each turn gets a fresh OpenClaw session with Atlas's completed conversation history. Cancelled and failed prompts are excluded so runtime transcript replay cannot revive them. The runtime tool allowlist is `atlas_board`; tool instances exist only for the active run's session and cannot choose another board or acquire a new scope. Stop aborts the dispatcher; only after it returns does the plugin report settlement. OpenClaw error payloads are failures, not successful replies.
|
|
46
46
|
|
package/package.json
CHANGED
package/worker.mjs
CHANGED
|
@@ -293,7 +293,7 @@ export async function startAccount(ctx) {
|
|
|
293
293
|
};
|
|
294
294
|
const open = () => {
|
|
295
295
|
if (ctx.abortSignal.aborted) return;
|
|
296
|
-
|
|
296
|
+
const ws = new WebSocket(
|
|
297
297
|
connection(ctx.account).replace(/^http/, "ws") + "/agent-worker",
|
|
298
298
|
{
|
|
299
299
|
headers: { Authorization: `Bearer ${ctx.account.token}` },
|
|
@@ -301,7 +301,17 @@ export async function startAccount(ctx) {
|
|
|
301
301
|
maxPayload: 65536,
|
|
302
302
|
},
|
|
303
303
|
);
|
|
304
|
-
socket
|
|
304
|
+
socket = ws;
|
|
305
|
+
let inactivity;
|
|
306
|
+
const received = () => {
|
|
307
|
+
clearTimeout(inactivity);
|
|
308
|
+
// Atlas sends queue notifications every 10 seconds and pings every 20.
|
|
309
|
+
// A broken network path may leave TCP open without ever emitting close.
|
|
310
|
+
inactivity = setTimeout(() => ws.terminate(), 45000);
|
|
311
|
+
inactivity.unref?.();
|
|
312
|
+
};
|
|
313
|
+
ws.on("open", () => {
|
|
314
|
+
received();
|
|
305
315
|
ctx.setStatus?.({
|
|
306
316
|
accountId: ctx.accountId,
|
|
307
317
|
connected: true,
|
|
@@ -309,15 +319,18 @@ export async function startAccount(ctx) {
|
|
|
309
319
|
});
|
|
310
320
|
void check();
|
|
311
321
|
});
|
|
312
|
-
|
|
322
|
+
ws.on("ping", received);
|
|
323
|
+
ws.on("message", () => {
|
|
324
|
+
received();
|
|
313
325
|
void check();
|
|
314
326
|
});
|
|
315
|
-
|
|
316
|
-
|
|
327
|
+
ws.on("error", () => {});
|
|
328
|
+
ws.on("close", () => {
|
|
329
|
+
clearTimeout(inactivity);
|
|
317
330
|
ctx.setStatus?.({
|
|
318
331
|
accountId: ctx.accountId,
|
|
319
332
|
connected: false,
|
|
320
|
-
running:
|
|
333
|
+
running: !ctx.abortSignal.aborted,
|
|
321
334
|
});
|
|
322
335
|
if (!ctx.abortSignal.aborted) reconnect = setTimeout(open, 3000);
|
|
323
336
|
});
|