@ricsam/r5d-worker 0.0.136 → 0.0.138
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 +4 -94
- package/dist/cjs/package.json +1 -1
- package/dist/mjs/main.mjs +46 -7537
- package/dist/mjs/package.json +1 -1
- package/dist/mjs/personal/action-scheduler.mjs +31 -0
- package/dist/mjs/personal/client.mjs +215 -0
- package/dist/mjs/personal/runtime.mjs +328 -0
- package/dist/mjs/personal/tcp.mjs +217 -0
- package/dist/mjs/runtime/adapter.mjs +42 -0
- package/dist/mjs/runtime/client.mjs +95 -0
- package/dist/mjs/runtime/daemon.mjs +131 -0
- package/dist/mjs/runtime/executor.mjs +436 -0
- package/dist/mjs/runtime/index.mjs +15 -0
- package/dist/mjs/runtime/protocol.mjs +139 -0
- package/dist/mjs/runtime/pty-host.mjs +156 -0
- package/dist/mjs/runtime/pty.mjs +127 -0
- package/dist/mjs/runtime/releases/artifacts.mjs +201 -0
- package/dist/mjs/runtime/releases/grants.mjs +93 -0
- package/dist/mjs/runtime/releases/main.mjs +101 -0
- package/dist/mjs/runtime/releases/manager.mjs +541 -0
- package/dist/mjs/runtime/releases/process.mjs +88 -0
- package/dist/mjs/runtime/releases/retirement.mjs +18 -0
- package/dist/mjs/runtime/releases/rpc-client.mjs +184 -0
- package/dist/mjs/runtime/releases/rpc-main.mjs +213 -0
- package/dist/mjs/runtime/releases/rpc-protocol.mjs +103 -0
- package/dist/mjs/runtime/storage.mjs +156 -0
- package/dist/mjs/runtime/workspace/artifacts.mjs +121 -0
- package/dist/mjs/runtime/workspace/authority.mjs +1355 -0
- package/dist/mjs/runtime/workspace/contracts.mjs +60 -0
- package/dist/mjs/runtime/workspace/file-write.mjs +23 -0
- package/dist/mjs/runtime/workspace/files.mjs +308 -0
- package/dist/mjs/runtime/workspace/http-body.mjs +45 -0
- package/dist/mjs/runtime/workspace/storage-client.mjs +59 -0
- package/dist/mjs/runtime/workspace/storage-wire.mjs +53 -0
- package/dist/types/main.d.ts +0 -1167
- package/dist/types/personal/action-scheduler.d.ts +23 -0
- package/dist/types/personal/client.d.ts +14 -0
- package/dist/types/personal/runtime.d.ts +121 -0
- package/dist/types/personal/tcp.d.ts +14 -0
- package/dist/types/runtime/client.d.ts +17 -0
- package/dist/types/runtime/daemon.d.ts +8 -0
- package/dist/types/runtime/executor.d.ts +35 -0
- package/dist/types/runtime/index.d.ts +5 -0
- package/dist/types/runtime/protocol.d.ts +544 -0
- package/dist/types/runtime/pty.d.ts +30 -0
- package/dist/types/runtime/releases/artifacts.d.ts +51 -0
- package/dist/types/runtime/releases/grants.d.ts +16 -0
- package/dist/types/runtime/releases/manager.d.ts +145 -0
- package/dist/types/runtime/releases/process.d.ts +14 -0
- package/dist/types/runtime/releases/retirement.d.ts +15 -0
- package/dist/types/runtime/releases/rpc-client.d.ts +52 -0
- package/dist/types/runtime/releases/rpc-main.d.ts +10 -0
- package/dist/types/runtime/releases/rpc-protocol.d.ts +1139 -0
- package/dist/types/runtime/storage.d.ts +21 -0
- package/dist/types/runtime/test-harness.d.ts +53 -0
- package/dist/types/runtime/workspace/artifacts.d.ts +30 -0
- package/dist/types/runtime/workspace/authority.d.ts +338 -0
- package/dist/types/runtime/workspace/contracts.d.ts +86 -0
- package/dist/types/runtime/workspace/file-write.d.ts +14 -0
- package/dist/types/runtime/workspace/files.d.ts +21 -0
- package/dist/types/runtime/workspace/http-body.d.ts +9 -0
- package/dist/types/runtime/workspace/storage-client.d.ts +23 -0
- package/dist/types/runtime/workspace/storage-wire.d.ts +138 -0
- package/package.json +8 -6
- package/dist/cjs/atomic-rename.cjs +0 -303
- package/dist/cjs/browser-upload.cjs +0 -73
- package/dist/cjs/cli-update.cjs +0 -108
- package/dist/cjs/command-launcher.cjs +0 -423
- package/dist/cjs/control-command-policy.cjs +0 -177
- package/dist/cjs/git-blob-hash.cjs +0 -41
- package/dist/cjs/git-identity.cjs +0 -39
- package/dist/cjs/git-process-environment.cjs +0 -133
- package/dist/cjs/inline-output.cjs +0 -62
- package/dist/cjs/main.cjs +0 -7511
- package/dist/cjs/managed-paths.cjs +0 -215
- package/dist/cjs/plan-lint.cjs +0 -165
- package/dist/cjs/plan-parser.cjs +0 -127
- package/dist/cjs/plan-paths.cjs +0 -53
- package/dist/cjs/port-forward-client.cjs +0 -206
- package/dist/cjs/process-tree.cjs +0 -117
- package/dist/cjs/project-checkout-garbage.cjs +0 -219
- package/dist/cjs/project-mirror-fetch-policy.cjs +0 -82
- package/dist/cjs/project-mirror-refs-token.cjs +0 -85
- package/dist/cjs/project-workspace-state.cjs +0 -972
- package/dist/cjs/project-worktrees.cjs +0 -1713
- package/dist/cjs/pty-output-coalescer.cjs +0 -87
- package/dist/cjs/recovery-journal-protocol.cjs +0 -56
- package/dist/cjs/recovery-journal-runtime.cjs +0 -133
- package/dist/cjs/recovery-journal-thread.cjs +0 -9
- package/dist/cjs/recovery-journal.cjs +0 -742
- package/dist/cjs/recovery-output-window.cjs +0 -77
- package/dist/cjs/recovery-protocol.cjs +0 -31
- package/dist/cjs/recovery-store.cjs +0 -252
- package/dist/cjs/registry-auth.cjs +0 -310
- package/dist/cjs/repository-transition-policy.cjs +0 -49
- package/dist/cjs/runtime-version.cjs +0 -88
- package/dist/cjs/session-file-mutations.cjs +0 -61
- package/dist/cjs/supervisor.cjs +0 -147
- package/dist/cjs/three-way-merge.cjs +0 -346
- package/dist/cjs/working-tree-mirror.cjs +0 -1872
- package/dist/cjs/workspace-automatic-sync-policy.cjs +0 -79
- package/dist/cjs/workspace-branch-incarnation-policy.cjs +0 -37
- package/dist/cjs/workspace-command-sync-policy.cjs +0 -112
- package/dist/cjs/workspace-command-targets.cjs +0 -63
- package/dist/cjs/workspace-filesystem-executor-thread.cjs +0 -36
- package/dist/cjs/workspace-filesystem-executor.cjs +0 -327
- package/dist/cjs/workspace-filesystem-job-types.cjs +0 -144
- package/dist/cjs/workspace-filesystem-jobs.cjs +0 -59
- package/dist/cjs/workspace-git-sync.cjs +0 -3450
- package/dist/cjs/workspace-hydration-ledger.cjs +0 -66
- package/dist/cjs/workspace-hydration-merge.cjs +0 -433
- package/dist/cjs/workspace-hydration-recovery-state.cjs +0 -53
- package/dist/cjs/workspace-incident-state.cjs +0 -37
- package/dist/cjs/workspace-merge-projection.cjs +0 -467
- package/dist/cjs/workspace-mount-boundary.cjs +0 -71
- package/dist/cjs/workspace-mount-hold-fence.cjs +0 -120
- package/dist/cjs/workspace-mutation-gate.cjs +0 -127
- package/dist/cjs/workspace-path-move.cjs +0 -195
- package/dist/cjs/workspace-preserve-only-policy.cjs +0 -36
- package/dist/cjs/workspace-project-config-policy.cjs +0 -53
- package/dist/cjs/workspace-projection-ledger.cjs +0 -81
- package/dist/cjs/workspace-publication-evidence.cjs +0 -46
- package/dist/cjs/workspace-sync-coalescer.cjs +0 -58
- package/dist/mjs/atomic-rename.mjs +0 -261
- package/dist/mjs/browser-upload.mjs +0 -42
- package/dist/mjs/command-launcher.mjs +0 -393
- package/dist/mjs/control-command-policy.mjs +0 -146
- package/dist/mjs/git-blob-hash.mjs +0 -16
- package/dist/mjs/git-identity.mjs +0 -15
- package/dist/mjs/git-process-environment.mjs +0 -105
- package/dist/mjs/inline-output.mjs +0 -37
- package/dist/mjs/managed-paths.mjs +0 -174
- package/dist/mjs/plan-lint.mjs +0 -129
- package/dist/mjs/plan-parser.mjs +0 -94
- package/dist/mjs/plan-paths.mjs +0 -25
- package/dist/mjs/port-forward-client.mjs +0 -172
- package/dist/mjs/project-checkout-garbage.mjs +0 -178
- package/dist/mjs/project-mirror-fetch-policy.mjs +0 -56
- package/dist/mjs/project-mirror-refs-token.mjs +0 -53
- package/dist/mjs/project-workspace-state.mjs +0 -937
- package/dist/mjs/project-worktrees.mjs +0 -1657
- package/dist/mjs/pty-output-coalescer.mjs +0 -61
- package/dist/mjs/recovery-journal-protocol.mjs +0 -30
- package/dist/mjs/recovery-journal-runtime.mjs +0 -112
- package/dist/mjs/recovery-journal-thread.mjs +0 -8
- package/dist/mjs/recovery-journal.mjs +0 -694
- package/dist/mjs/recovery-output-window.mjs +0 -53
- package/dist/mjs/recovery-protocol.mjs +0 -6
- package/dist/mjs/recovery-store.mjs +0 -217
- package/dist/mjs/registry-auth.mjs +0 -269
- package/dist/mjs/repository-transition-policy.mjs +0 -22
- package/dist/mjs/runtime-version.mjs +0 -54
- package/dist/mjs/session-file-mutations.mjs +0 -37
- package/dist/mjs/supervisor.mjs +0 -114
- package/dist/mjs/three-way-merge.mjs +0 -318
- package/dist/mjs/working-tree-mirror.mjs +0 -1817
- package/dist/mjs/workspace-automatic-sync-policy.mjs +0 -48
- package/dist/mjs/workspace-branch-incarnation-policy.mjs +0 -13
- package/dist/mjs/workspace-command-sync-policy.mjs +0 -84
- package/dist/mjs/workspace-command-targets.mjs +0 -37
- package/dist/mjs/workspace-filesystem-executor-thread.mjs +0 -38
- package/dist/mjs/workspace-filesystem-executor.mjs +0 -287
- package/dist/mjs/workspace-filesystem-job-types.mjs +0 -116
- package/dist/mjs/workspace-filesystem-jobs.mjs +0 -55
- package/dist/mjs/workspace-git-sync.mjs +0 -3407
- package/dist/mjs/workspace-hydration-ledger.mjs +0 -42
- package/dist/mjs/workspace-hydration-merge.mjs +0 -399
- package/dist/mjs/workspace-hydration-recovery-state.mjs +0 -29
- package/dist/mjs/workspace-incident-state.mjs +0 -12
- package/dist/mjs/workspace-merge-projection.mjs +0 -433
- package/dist/mjs/workspace-mount-boundary.mjs +0 -37
- package/dist/mjs/workspace-mount-hold-fence.mjs +0 -95
- package/dist/mjs/workspace-mutation-gate.mjs +0 -103
- package/dist/mjs/workspace-path-move.mjs +0 -160
- package/dist/mjs/workspace-preserve-only-policy.mjs +0 -11
- package/dist/mjs/workspace-project-config-policy.mjs +0 -27
- package/dist/mjs/workspace-projection-ledger.mjs +0 -57
- package/dist/mjs/workspace-publication-evidence.mjs +0 -21
- package/dist/mjs/workspace-sync-coalescer.mjs +0 -34
- package/dist/types/atomic-rename.d.ts +0 -78
- package/dist/types/browser-upload.d.ts +0 -7
- package/dist/types/command-launcher.d.ts +0 -104
- package/dist/types/control-command-policy.d.ts +0 -53
- package/dist/types/git-blob-hash.d.ts +0 -10
- package/dist/types/git-identity.d.ts +0 -9
- package/dist/types/git-process-environment.d.ts +0 -9
- package/dist/types/inline-output.d.ts +0 -3
- package/dist/types/managed-paths.d.ts +0 -19
- package/dist/types/plan-lint.d.ts +0 -16
- package/dist/types/plan-parser.d.ts +0 -38
- package/dist/types/plan-paths.d.ts +0 -36
- package/dist/types/port-forward-client.d.ts +0 -8
- package/dist/types/project-checkout-garbage.d.ts +0 -86
- package/dist/types/project-mirror-fetch-policy.d.ts +0 -84
- package/dist/types/project-mirror-refs-token.d.ts +0 -53
- package/dist/types/project-workspace-state.d.ts +0 -188
- package/dist/types/project-worktrees.d.ts +0 -397
- package/dist/types/pty-output-coalescer.d.ts +0 -20
- package/dist/types/recovery-journal-protocol.d.ts +0 -35
- package/dist/types/recovery-journal-runtime.d.ts +0 -12
- package/dist/types/recovery-journal-thread.d.ts +0 -1
- package/dist/types/recovery-journal.d.ts +0 -248
- package/dist/types/recovery-output-window.d.ts +0 -19
- package/dist/types/recovery-protocol.d.ts +0 -59
- package/dist/types/recovery-store.d.ts +0 -52
- package/dist/types/registry-auth.d.ts +0 -47
- package/dist/types/repository-transition-policy.d.ts +0 -26
- package/dist/types/runtime-version.d.ts +0 -1
- package/dist/types/session-file-mutations.d.ts +0 -22
- package/dist/types/supervisor-daemonized-fixture.d.ts +0 -1
- package/dist/types/supervisor-launcher-cleanup-fixture.d.ts +0 -1
- package/dist/types/supervisor-signal-fixture.d.ts +0 -1
- package/dist/types/supervisor.d.ts +0 -23
- package/dist/types/three-way-merge.d.ts +0 -77
- package/dist/types/working-tree-mirror.d.ts +0 -424
- package/dist/types/workspace-automatic-sync-policy.d.ts +0 -57
- package/dist/types/workspace-branch-incarnation-policy.d.ts +0 -14
- package/dist/types/workspace-command-sync-policy.d.ts +0 -57
- package/dist/types/workspace-command-targets.d.ts +0 -37
- package/dist/types/workspace-filesystem-executor-thread.d.ts +0 -1
- package/dist/types/workspace-filesystem-executor.d.ts +0 -123
- package/dist/types/workspace-filesystem-job-types.d.ts +0 -288
- package/dist/types/workspace-filesystem-jobs.d.ts +0 -7
- package/dist/types/workspace-git-sync.d.ts +0 -495
- package/dist/types/workspace-hydration-ledger.d.ts +0 -43
- package/dist/types/workspace-hydration-merge.d.ts +0 -95
- package/dist/types/workspace-hydration-recovery-state.d.ts +0 -10
- package/dist/types/workspace-incident-state.d.ts +0 -19
- package/dist/types/workspace-merge-projection.d.ts +0 -60
- package/dist/types/workspace-mount-boundary.d.ts +0 -10
- package/dist/types/workspace-mount-hold-fence.d.ts +0 -42
- package/dist/types/workspace-mutation-gate.d.ts +0 -42
- package/dist/types/workspace-path-move.d.ts +0 -21
- package/dist/types/workspace-preserve-only-policy.d.ts +0 -15
- package/dist/types/workspace-project-config-policy.d.ts +0 -48
- package/dist/types/workspace-projection-ledger.d.ts +0 -59
- package/dist/types/workspace-publication-evidence.d.ts +0 -17
- package/dist/types/workspace-sync-coalescer.d.ts +0 -28
- /package/dist/types/{credential-authority-lock-fixture.d.ts → runtime/adapter.d.ts} +0 -0
- /package/dist/types/{recovery-journal-stall-fixture.d.ts → runtime/releases/main.d.ts} +0 -0
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
const DEFAULT_PTY_OUTPUT_FLUSH_INTERVAL_MS = 8;
|
|
2
|
-
const DEFAULT_PTY_OUTPUT_MAX_BUFFER_BYTES = 64 * 1024;
|
|
3
|
-
function defaultSchedule(callback, delayMs) {
|
|
4
|
-
const timer = setTimeout(callback, delayMs);
|
|
5
|
-
timer.unref();
|
|
6
|
-
return () => clearTimeout(timer);
|
|
7
|
-
}
|
|
8
|
-
function createPtyOutputCoalescer(options) {
|
|
9
|
-
const flushIntervalMs = options.flushIntervalMs ?? DEFAULT_PTY_OUTPUT_FLUSH_INTERVAL_MS;
|
|
10
|
-
const maxBufferBytes = options.maxBufferBytes ?? DEFAULT_PTY_OUTPUT_MAX_BUFFER_BYTES;
|
|
11
|
-
const now = options.now ?? Date.now;
|
|
12
|
-
const schedule = options.schedule ?? defaultSchedule;
|
|
13
|
-
let buffer = "";
|
|
14
|
-
let bufferedBytes = 0;
|
|
15
|
-
let cancelScheduledFlush = null;
|
|
16
|
-
let lastSendAt = Number.NEGATIVE_INFINITY;
|
|
17
|
-
const sendNow = (data) => {
|
|
18
|
-
lastSendAt = now();
|
|
19
|
-
options.send(data);
|
|
20
|
-
};
|
|
21
|
-
const flush = () => {
|
|
22
|
-
if (cancelScheduledFlush) {
|
|
23
|
-
cancelScheduledFlush();
|
|
24
|
-
cancelScheduledFlush = null;
|
|
25
|
-
}
|
|
26
|
-
if (bufferedBytes === 0) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const data = buffer;
|
|
30
|
-
buffer = "";
|
|
31
|
-
bufferedBytes = 0;
|
|
32
|
-
sendNow(data);
|
|
33
|
-
};
|
|
34
|
-
const push = (data) => {
|
|
35
|
-
if (data.length === 0) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
if (bufferedBytes === 0 && now() - lastSendAt >= flushIntervalMs) {
|
|
39
|
-
sendNow(data);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
buffer += data;
|
|
43
|
-
bufferedBytes += Buffer.byteLength(data, "utf8");
|
|
44
|
-
if (bufferedBytes >= maxBufferBytes) {
|
|
45
|
-
flush();
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
if (!cancelScheduledFlush) {
|
|
49
|
-
cancelScheduledFlush = schedule(() => {
|
|
50
|
-
cancelScheduledFlush = null;
|
|
51
|
-
flush();
|
|
52
|
-
}, flushIntervalMs);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
return { push, flush };
|
|
56
|
-
}
|
|
57
|
-
export {
|
|
58
|
-
DEFAULT_PTY_OUTPUT_FLUSH_INTERVAL_MS,
|
|
59
|
-
DEFAULT_PTY_OUTPUT_MAX_BUFFER_BYTES,
|
|
60
|
-
createPtyOutputCoalescer
|
|
61
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const WORKER_RECOVERY_JOURNAL_OPS = [
|
|
2
|
-
"admit",
|
|
3
|
-
"readmitUnknownBranchDeletion",
|
|
4
|
-
"record",
|
|
5
|
-
"unknown",
|
|
6
|
-
"unknownRun",
|
|
7
|
-
"acknowledgeResult",
|
|
8
|
-
"acknowledgeOutput",
|
|
9
|
-
"acknowledgeTerminal",
|
|
10
|
-
"cancelSession",
|
|
11
|
-
"isRequestCancelled",
|
|
12
|
-
"operations",
|
|
13
|
-
"recoveryState",
|
|
14
|
-
"terminals",
|
|
15
|
-
"outputReplayBegin",
|
|
16
|
-
"outputReplayNext",
|
|
17
|
-
"outputReplayEnd"
|
|
18
|
-
];
|
|
19
|
-
function isWorkerRecoveryJournalOp(value) {
|
|
20
|
-
return typeof value === "string" && WORKER_RECOVERY_JOURNAL_OPS.includes(value);
|
|
21
|
-
}
|
|
22
|
-
function serializeWorkerRecoveryJournalError(error) {
|
|
23
|
-
if (!(error instanceof Error)) return { name: "Error", message: String(error) };
|
|
24
|
-
return { name: error.name, message: error.message, ...typeof error.stack === "string" ? { stack: error.stack } : {} };
|
|
25
|
-
}
|
|
26
|
-
export {
|
|
27
|
-
WORKER_RECOVERY_JOURNAL_OPS,
|
|
28
|
-
isWorkerRecoveryJournalOp,
|
|
29
|
-
serializeWorkerRecoveryJournalError
|
|
30
|
-
};
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isWorkerRecoveryJournalOp,
|
|
3
|
-
serializeWorkerRecoveryJournalError
|
|
4
|
-
} from "./recovery-journal-protocol.mjs";
|
|
5
|
-
import { WorkerRecoveryStore } from "./recovery-store.mjs";
|
|
6
|
-
function serveRecoveryJournal(port, filename, hooks = {}) {
|
|
7
|
-
const store = new WorkerRecoveryStore(filename);
|
|
8
|
-
const outputReplays = /* @__PURE__ */ new Map();
|
|
9
|
-
let nextReplayId = 1;
|
|
10
|
-
function runOp(op, args) {
|
|
11
|
-
switch (op) {
|
|
12
|
-
case "admit": {
|
|
13
|
-
const message = args[0];
|
|
14
|
-
const admission = store.admit(message);
|
|
15
|
-
return {
|
|
16
|
-
admission,
|
|
17
|
-
response: admission === "new" ? void 0 : store.response(message.requestId),
|
|
18
|
-
cancelled: store.isRequestCancelled(message.requestId)
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
case "readmitUnknownBranchDeletion":
|
|
22
|
-
return store.readmitUnknownBranchDeletion(args[0]);
|
|
23
|
-
case "record": {
|
|
24
|
-
const message = args[0];
|
|
25
|
-
if (typeof message.requestId === "string" && store.isUnknown(message.requestId)) return { suppressed: true, recorded: message };
|
|
26
|
-
return { suppressed: false, recorded: store.record(message) };
|
|
27
|
-
}
|
|
28
|
-
case "unknown":
|
|
29
|
-
store.unknown(args[0]);
|
|
30
|
-
return null;
|
|
31
|
-
case "unknownRun":
|
|
32
|
-
store.unknownRun(args[0]);
|
|
33
|
-
return null;
|
|
34
|
-
case "acknowledgeResult":
|
|
35
|
-
store.acknowledgeResult(args[0]);
|
|
36
|
-
return null;
|
|
37
|
-
case "acknowledgeOutput":
|
|
38
|
-
store.acknowledgeOutput(args[0], args[1], args[2]);
|
|
39
|
-
return null;
|
|
40
|
-
case "acknowledgeTerminal":
|
|
41
|
-
store.acknowledgeTerminal(args[0]);
|
|
42
|
-
return null;
|
|
43
|
-
case "cancelSession":
|
|
44
|
-
store.cancelSession(args[0]);
|
|
45
|
-
return null;
|
|
46
|
-
case "isRequestCancelled":
|
|
47
|
-
return store.isRequestCancelled(args[0]);
|
|
48
|
-
case "operations":
|
|
49
|
-
return store.operations();
|
|
50
|
-
case "recoveryState": {
|
|
51
|
-
const requests = args[0];
|
|
52
|
-
return {
|
|
53
|
-
operations: store.operations(),
|
|
54
|
-
cursors: store.outputCursors(),
|
|
55
|
-
responses: store.responses(requests),
|
|
56
|
-
terminals: store.terminals()
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
case "terminals":
|
|
60
|
-
return store.terminals();
|
|
61
|
-
case "outputReplayBegin": {
|
|
62
|
-
const replayId = nextReplayId++;
|
|
63
|
-
outputReplays.set(replayId, store.output(args[0]));
|
|
64
|
-
return replayId;
|
|
65
|
-
}
|
|
66
|
-
case "outputReplayNext": {
|
|
67
|
-
const replay = outputReplays.get(args[0]);
|
|
68
|
-
if (!replay) return { frames: [], done: true };
|
|
69
|
-
const maxFrames = args[1];
|
|
70
|
-
const frames = [];
|
|
71
|
-
while (frames.length < maxFrames) {
|
|
72
|
-
const next = replay.next();
|
|
73
|
-
if (next.done) {
|
|
74
|
-
outputReplays.delete(args[0]);
|
|
75
|
-
return { frames, done: true };
|
|
76
|
-
}
|
|
77
|
-
frames.push(next.value);
|
|
78
|
-
}
|
|
79
|
-
return { frames, done: false };
|
|
80
|
-
}
|
|
81
|
-
case "outputReplayEnd":
|
|
82
|
-
outputReplays.delete(args[0]);
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
port.on("message", (message) => {
|
|
87
|
-
if (!message || typeof message !== "object") return;
|
|
88
|
-
const request = message;
|
|
89
|
-
if (request.type !== "batch" || typeof request.id !== "number" || !Array.isArray(request.entries)) return;
|
|
90
|
-
const entries = request.entries;
|
|
91
|
-
try {
|
|
92
|
-
hooks.beforeBatch?.();
|
|
93
|
-
const results = store.batch(
|
|
94
|
-
() => entries.map((entry) => {
|
|
95
|
-
if (!isWorkerRecoveryJournalOp(entry.op)) throw new Error(`Unknown recovery journal operation: ${String(entry.op)}`);
|
|
96
|
-
return { seq: entry.seq, value: runOp(entry.op, entry.args) };
|
|
97
|
-
})
|
|
98
|
-
);
|
|
99
|
-
port.postMessage({ type: "batch_result", id: request.id, results });
|
|
100
|
-
} catch (error) {
|
|
101
|
-
port.postMessage({
|
|
102
|
-
type: "batch_failure",
|
|
103
|
-
id: request.id,
|
|
104
|
-
error: serializeWorkerRecoveryJournalError(error)
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
port.postMessage({ type: "ready", ledgerId: store.ledgerId });
|
|
109
|
-
}
|
|
110
|
-
export {
|
|
111
|
-
serveRecoveryJournal
|
|
112
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { isMainThread, parentPort, workerData } from "node:worker_threads";
|
|
2
|
-
import { serveRecoveryJournal } from "./recovery-journal-runtime.mjs";
|
|
3
|
-
if (isMainThread || !parentPort) {
|
|
4
|
-
throw new Error("The recovery journal thread must be started by the worker runtime");
|
|
5
|
-
}
|
|
6
|
-
const data = workerData;
|
|
7
|
-
if (!data || typeof data.filename !== "string" || !data.filename) throw new Error("The recovery journal thread needs a store filename");
|
|
8
|
-
serveRecoveryJournal(parentPort, data.filename);
|