@ricsam/r5d-worker 0.0.172 → 0.0.174
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/cjs/package.json +1 -1
- package/dist/mjs/internal-r5dctl.cjs +1 -1
- package/dist/mjs/main.mjs +2 -2
- package/dist/mjs/package.json +1 -1
- package/dist/mjs/personal/client.mjs +19 -8
- package/dist/mjs/personal/runtime.mjs +12 -1
- package/dist/mjs/personal/terminal-stream-protocol.mjs +66 -0
- package/dist/mjs/personal/terminal-stream.mjs +161 -0
- package/dist/mjs/runtime/client.mjs +58 -1
- package/dist/mjs/runtime/daemon.mjs +26 -3
- package/dist/mjs/runtime/executor.mjs +76 -4
- package/dist/mjs/runtime/protocol.mjs +15 -1
- package/dist/mjs/runtime/workspace/authority.mjs +78 -14
- package/dist/mjs/runtime/workspace/files.mjs +6 -3
- package/dist/types/personal/runtime.d.ts +29 -0
- package/dist/types/personal/terminal-stream-protocol.d.ts +132 -0
- package/dist/types/personal/terminal-stream.d.ts +31 -0
- package/dist/types/runtime/client.d.ts +18 -1
- package/dist/types/runtime/executor.d.ts +9 -2
- package/dist/types/runtime/protocol.d.ts +98 -0
- package/dist/types/runtime/releases/rpc-protocol.d.ts +136 -0
- package/dist/types/runtime/workspace/authority.d.ts +53 -5
- package/dist/types/runtime/workspace/contracts.d.ts +1 -1
- package/dist/types/runtime/workspace/files.d.ts +4 -0
- package/package.json +2 -2
|
@@ -273,6 +273,40 @@ export declare const ManagerCommand: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
273
273
|
}, z.core.$strict>;
|
|
274
274
|
}, z.core.$strict>;
|
|
275
275
|
actionId: z.ZodString;
|
|
276
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
277
|
+
method: z.ZodLiteral<"subscribe">;
|
|
278
|
+
run: z.ZodObject<{
|
|
279
|
+
operationId: z.ZodString;
|
|
280
|
+
userId: z.ZodString;
|
|
281
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
282
|
+
fence: z.ZodObject<{
|
|
283
|
+
installationId: z.ZodString;
|
|
284
|
+
resourceType: z.ZodString;
|
|
285
|
+
resourceId: z.ZodString;
|
|
286
|
+
ownerId: z.ZodString;
|
|
287
|
+
epoch: z.ZodNumber;
|
|
288
|
+
}, z.core.$strict>;
|
|
289
|
+
}, z.core.$strict>;
|
|
290
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
291
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
292
|
+
method: z.ZodLiteral<"input">;
|
|
293
|
+
run: z.ZodObject<{
|
|
294
|
+
operationId: z.ZodString;
|
|
295
|
+
userId: z.ZodString;
|
|
296
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
297
|
+
fence: z.ZodObject<{
|
|
298
|
+
installationId: z.ZodString;
|
|
299
|
+
resourceType: z.ZodString;
|
|
300
|
+
resourceId: z.ZodString;
|
|
301
|
+
ownerId: z.ZodString;
|
|
302
|
+
epoch: z.ZodNumber;
|
|
303
|
+
}, z.core.$strict>;
|
|
304
|
+
}, z.core.$strict>;
|
|
305
|
+
data: z.ZodOptional<z.ZodString>;
|
|
306
|
+
resize: z.ZodOptional<z.ZodObject<{
|
|
307
|
+
cols: z.ZodNumber;
|
|
308
|
+
rows: z.ZodNumber;
|
|
309
|
+
}, z.core.$strict>>;
|
|
276
310
|
}, z.core.$strict>], "method">;
|
|
277
311
|
}, z.core.$strict>, z.ZodObject<{
|
|
278
312
|
method: z.ZodLiteral<"observe">;
|
|
@@ -439,6 +473,40 @@ export declare const ManagerCommand: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
439
473
|
}, z.core.$strict>;
|
|
440
474
|
}, z.core.$strict>;
|
|
441
475
|
actionId: z.ZodString;
|
|
476
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
477
|
+
method: z.ZodLiteral<"subscribe">;
|
|
478
|
+
run: z.ZodObject<{
|
|
479
|
+
operationId: z.ZodString;
|
|
480
|
+
userId: z.ZodString;
|
|
481
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
482
|
+
fence: z.ZodObject<{
|
|
483
|
+
installationId: z.ZodString;
|
|
484
|
+
resourceType: z.ZodString;
|
|
485
|
+
resourceId: z.ZodString;
|
|
486
|
+
ownerId: z.ZodString;
|
|
487
|
+
epoch: z.ZodNumber;
|
|
488
|
+
}, z.core.$strict>;
|
|
489
|
+
}, z.core.$strict>;
|
|
490
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
491
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
492
|
+
method: z.ZodLiteral<"input">;
|
|
493
|
+
run: z.ZodObject<{
|
|
494
|
+
operationId: z.ZodString;
|
|
495
|
+
userId: z.ZodString;
|
|
496
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
497
|
+
fence: z.ZodObject<{
|
|
498
|
+
installationId: z.ZodString;
|
|
499
|
+
resourceType: z.ZodString;
|
|
500
|
+
resourceId: z.ZodString;
|
|
501
|
+
ownerId: z.ZodString;
|
|
502
|
+
epoch: z.ZodNumber;
|
|
503
|
+
}, z.core.$strict>;
|
|
504
|
+
}, z.core.$strict>;
|
|
505
|
+
data: z.ZodOptional<z.ZodString>;
|
|
506
|
+
resize: z.ZodOptional<z.ZodObject<{
|
|
507
|
+
cols: z.ZodNumber;
|
|
508
|
+
rows: z.ZodNumber;
|
|
509
|
+
}, z.core.$strict>>;
|
|
442
510
|
}, z.core.$strict>], "method">;
|
|
443
511
|
}, z.core.$strict>, z.ZodObject<{
|
|
444
512
|
method: z.ZodLiteral<"receipt">;
|
|
@@ -782,6 +850,40 @@ export declare const ManagerRequest: z.ZodObject<{
|
|
|
782
850
|
}, z.core.$strict>;
|
|
783
851
|
}, z.core.$strict>;
|
|
784
852
|
actionId: z.ZodString;
|
|
853
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
854
|
+
method: z.ZodLiteral<"subscribe">;
|
|
855
|
+
run: z.ZodObject<{
|
|
856
|
+
operationId: z.ZodString;
|
|
857
|
+
userId: z.ZodString;
|
|
858
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
859
|
+
fence: z.ZodObject<{
|
|
860
|
+
installationId: z.ZodString;
|
|
861
|
+
resourceType: z.ZodString;
|
|
862
|
+
resourceId: z.ZodString;
|
|
863
|
+
ownerId: z.ZodString;
|
|
864
|
+
epoch: z.ZodNumber;
|
|
865
|
+
}, z.core.$strict>;
|
|
866
|
+
}, z.core.$strict>;
|
|
867
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
868
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
869
|
+
method: z.ZodLiteral<"input">;
|
|
870
|
+
run: z.ZodObject<{
|
|
871
|
+
operationId: z.ZodString;
|
|
872
|
+
userId: z.ZodString;
|
|
873
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
874
|
+
fence: z.ZodObject<{
|
|
875
|
+
installationId: z.ZodString;
|
|
876
|
+
resourceType: z.ZodString;
|
|
877
|
+
resourceId: z.ZodString;
|
|
878
|
+
ownerId: z.ZodString;
|
|
879
|
+
epoch: z.ZodNumber;
|
|
880
|
+
}, z.core.$strict>;
|
|
881
|
+
}, z.core.$strict>;
|
|
882
|
+
data: z.ZodOptional<z.ZodString>;
|
|
883
|
+
resize: z.ZodOptional<z.ZodObject<{
|
|
884
|
+
cols: z.ZodNumber;
|
|
885
|
+
rows: z.ZodNumber;
|
|
886
|
+
}, z.core.$strict>>;
|
|
785
887
|
}, z.core.$strict>], "method">;
|
|
786
888
|
}, z.core.$strict>, z.ZodObject<{
|
|
787
889
|
method: z.ZodLiteral<"observe">;
|
|
@@ -948,6 +1050,40 @@ export declare const ManagerRequest: z.ZodObject<{
|
|
|
948
1050
|
}, z.core.$strict>;
|
|
949
1051
|
}, z.core.$strict>;
|
|
950
1052
|
actionId: z.ZodString;
|
|
1053
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1054
|
+
method: z.ZodLiteral<"subscribe">;
|
|
1055
|
+
run: z.ZodObject<{
|
|
1056
|
+
operationId: z.ZodString;
|
|
1057
|
+
userId: z.ZodString;
|
|
1058
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
1059
|
+
fence: z.ZodObject<{
|
|
1060
|
+
installationId: z.ZodString;
|
|
1061
|
+
resourceType: z.ZodString;
|
|
1062
|
+
resourceId: z.ZodString;
|
|
1063
|
+
ownerId: z.ZodString;
|
|
1064
|
+
epoch: z.ZodNumber;
|
|
1065
|
+
}, z.core.$strict>;
|
|
1066
|
+
}, z.core.$strict>;
|
|
1067
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
1068
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1069
|
+
method: z.ZodLiteral<"input">;
|
|
1070
|
+
run: z.ZodObject<{
|
|
1071
|
+
operationId: z.ZodString;
|
|
1072
|
+
userId: z.ZodString;
|
|
1073
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
1074
|
+
fence: z.ZodObject<{
|
|
1075
|
+
installationId: z.ZodString;
|
|
1076
|
+
resourceType: z.ZodString;
|
|
1077
|
+
resourceId: z.ZodString;
|
|
1078
|
+
ownerId: z.ZodString;
|
|
1079
|
+
epoch: z.ZodNumber;
|
|
1080
|
+
}, z.core.$strict>;
|
|
1081
|
+
}, z.core.$strict>;
|
|
1082
|
+
data: z.ZodOptional<z.ZodString>;
|
|
1083
|
+
resize: z.ZodOptional<z.ZodObject<{
|
|
1084
|
+
cols: z.ZodNumber;
|
|
1085
|
+
rows: z.ZodNumber;
|
|
1086
|
+
}, z.core.$strict>>;
|
|
951
1087
|
}, z.core.$strict>], "method">;
|
|
952
1088
|
}, z.core.$strict>, z.ZodObject<{
|
|
953
1089
|
method: z.ZodLiteral<"receipt">;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OperationEnvelope } from "@ricsam/r5d-api/runtime-protocol";
|
|
2
|
-
import { type PollResult, type RunIdentity } from "../protocol";
|
|
2
|
+
import { ExecutorError, type PollResult, type RunIdentity, type RunReceipt, type StreamFrame } from "../protocol";
|
|
3
|
+
import type { ExecutorSubscription } from "../client";
|
|
3
4
|
import { WorkspaceConfig, type ExecutorRoute, type WorkspaceIdentity, type OuterState, type ApprovedWorkbench as ApprovedWorkbenchInput } from "./contracts";
|
|
4
5
|
import { SessionArtifactChunk } from "./artifacts";
|
|
5
6
|
import { WorkspaceFileWrite } from "./file-write";
|
|
@@ -32,6 +33,7 @@ export declare class WorkspaceAuthority {
|
|
|
32
33
|
private closed;
|
|
33
34
|
private closeTask?;
|
|
34
35
|
private readonly actions;
|
|
36
|
+
private readonly subscriptions;
|
|
35
37
|
private readonly repositoryInitializations;
|
|
36
38
|
private outerRepository?;
|
|
37
39
|
private pending;
|
|
@@ -55,7 +57,7 @@ export declare class WorkspaceAuthority {
|
|
|
55
57
|
content: string;
|
|
56
58
|
bytes: number;
|
|
57
59
|
}>;
|
|
58
|
-
processes(identity: WorkspaceIdentity): Promise<{
|
|
60
|
+
processes(identity: WorkspaceIdentity): Promise<({
|
|
59
61
|
workerLabel: string;
|
|
60
62
|
operationId: string;
|
|
61
63
|
userId: string;
|
|
@@ -78,7 +80,30 @@ export declare class WorkspaceAuthority {
|
|
|
78
80
|
startedAt?: string;
|
|
79
81
|
updatedAt?: string;
|
|
80
82
|
completedAt?: string;
|
|
81
|
-
}
|
|
83
|
+
} | {
|
|
84
|
+
operationId: string;
|
|
85
|
+
userId: string;
|
|
86
|
+
sessionId: string;
|
|
87
|
+
state: string;
|
|
88
|
+
pid: null;
|
|
89
|
+
pty: boolean;
|
|
90
|
+
lane: string;
|
|
91
|
+
stdoutBytes: number;
|
|
92
|
+
stderrBytes: number;
|
|
93
|
+
stdinClosed: boolean;
|
|
94
|
+
exitCode: null;
|
|
95
|
+
signal: null;
|
|
96
|
+
reason: string;
|
|
97
|
+
workerLabel: string;
|
|
98
|
+
artifactEnvironment?: boolean;
|
|
99
|
+
mutating: boolean;
|
|
100
|
+
payloadHash: string;
|
|
101
|
+
argv?: string[];
|
|
102
|
+
cwd?: string;
|
|
103
|
+
startedAt?: string;
|
|
104
|
+
updatedAt?: string;
|
|
105
|
+
completedAt?: string;
|
|
106
|
+
})[]>;
|
|
82
107
|
fileHistoryDates(identity: WorkspaceIdentity, file: string): Promise<{
|
|
83
108
|
createdAt: string | null;
|
|
84
109
|
updatedAt: string;
|
|
@@ -192,6 +217,11 @@ export declare class WorkspaceAuthority {
|
|
|
192
217
|
original?: undefined;
|
|
193
218
|
modified?: undefined;
|
|
194
219
|
}>;
|
|
220
|
+
/** Bench state is one in-memory object with several writers on different
|
|
221
|
+
* queues (checkout work, run receipts). Writes of its file are chained so
|
|
222
|
+
* they never overlap and the write that lands last always serializes the
|
|
223
|
+
* newest state; the chain covers only the write itself, never the work
|
|
224
|
+
* around it, so a run receipt does not wait for a publication. */
|
|
195
225
|
private save;
|
|
196
226
|
private owned;
|
|
197
227
|
private serial;
|
|
@@ -433,7 +463,7 @@ export declare class WorkspaceAuthority {
|
|
|
433
463
|
startWithCredentials(identity: WorkspaceIdentity, input: OperationEnvelope, resolve: () => Promise<Array<{
|
|
434
464
|
id: string;
|
|
435
465
|
generation: number;
|
|
436
|
-
}>>): Promise<
|
|
466
|
+
}>>): Promise<RunReceipt>;
|
|
437
467
|
materializeArtifact(identity: WorkspaceIdentity, input: SessionArtifactChunk): Promise<{
|
|
438
468
|
filename: string;
|
|
439
469
|
sha256: string;
|
|
@@ -442,10 +472,28 @@ export declare class WorkspaceAuthority {
|
|
|
442
472
|
complete: boolean;
|
|
443
473
|
}>;
|
|
444
474
|
/** Default arbitrary shell is mutating. Exact trusted config approval is the sole exemption. */
|
|
445
|
-
start(identity: WorkspaceIdentity, input: OperationEnvelope, allowBlockedConflict?: boolean): Promise<
|
|
475
|
+
start(identity: WorkspaceIdentity, input: OperationEnvelope, allowBlockedConflict?: boolean): Promise<RunReceipt>;
|
|
446
476
|
private runRoute;
|
|
447
477
|
private action;
|
|
448
478
|
poll(identity: WorkspaceIdentity, run: RunIdentity, stdoutOffset?: number, stderrOffset?: number, maxBytes?: number): Promise<PollResult>;
|
|
479
|
+
/** Run liveness is process state observed from the executor, not a workspace
|
|
480
|
+
* mutation: it is recorded on its own short queue, never behind the checkout's
|
|
481
|
+
* hydration, commit or publication work. A crash between two writers loses
|
|
482
|
+
* nothing lasting — `refresh` re-reads every open run from the executor. */
|
|
483
|
+
private recordRunState;
|
|
484
|
+
/** Live terminal channel. The subscription is not an admitted action: it
|
|
485
|
+
* lives as long as its transport, outlives the request budget, and is torn
|
|
486
|
+
* down on close. Its exit frame is the only durable-state effect. */
|
|
487
|
+
subscribe(identity: WorkspaceIdentity, run: RunIdentity, offset: number, handlers: {
|
|
488
|
+
frame(frame: StreamFrame): void;
|
|
489
|
+
close(error?: ExecutorError): void;
|
|
490
|
+
}): Promise<ExecutorSubscription>;
|
|
491
|
+
/** Live PTY input: fenced and owned like a write, but with no action receipt
|
|
492
|
+
* and no queue in front of it. */
|
|
493
|
+
streamInput(identity: WorkspaceIdentity, run: RunIdentity, data?: string, resize?: {
|
|
494
|
+
cols: number;
|
|
495
|
+
rows: number;
|
|
496
|
+
}): Promise<import("../protocol").InputResult>;
|
|
449
497
|
private actionOutcome;
|
|
450
498
|
write(identity: WorkspaceIdentity, run: RunIdentity, actionId: string, data: string, eof?: boolean): Promise<import("..").ActionReceipt>;
|
|
451
499
|
resize(identity: WorkspaceIdentity, run: RunIdentity, actionId: string, cols: number, rows: number): Promise<import("..").ActionReceipt>;
|
|
@@ -44,7 +44,7 @@ export declare const WorkspaceConfig: z.ZodObject<{
|
|
|
44
44
|
}, z.core.$strict>;
|
|
45
45
|
export type WorkspaceConfig = z.input<typeof WorkspaceConfig>;
|
|
46
46
|
export type ExecutorRoute = {
|
|
47
|
-
client: Pick<HostExecutorClient, "start" | "poll" | "write" | "cancel"> & Partial<Pick<HostExecutorClient, "resize">>;
|
|
47
|
+
client: Pick<HostExecutorClient, "start" | "poll" | "write" | "cancel"> & Partial<Pick<HostExecutorClient, "resize" | "subscribe" | "input">>;
|
|
48
48
|
workerFence: OwnershipFence;
|
|
49
49
|
};
|
|
50
50
|
export type WorkspaceIdentity = {
|
|
@@ -15,6 +15,10 @@ export declare function readHostRegular(file: string, limit?: number): Promise<B
|
|
|
15
15
|
* Restore only that directory skeleton after confirming the authority-owned
|
|
16
16
|
* repository markers; refs, objects, indexes and configuration are untouched. */
|
|
17
17
|
export declare function ensureAuthorityGitRepositoryLayout(repo: string): Promise<void>;
|
|
18
|
+
/** Writes `value` atomically: a private temporary file, fsync, rename, directory
|
|
19
|
+
* fsync. Concurrent writers of the same file each get their own temporary name,
|
|
20
|
+
* so neither fails on the other's; the rename that lands last wins, which is why
|
|
21
|
+
* callers that share in-memory state also serialize their writes. */
|
|
18
22
|
export declare function durableJson(file: string, value: unknown): Promise<void>;
|
|
19
23
|
/** All Git operates in authority-created repos; NEVER workbench .git/config/index.
|
|
20
24
|
* hash-object --no-filters and update-index --index-info replace git add/checkout.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ricsam/r5d-worker",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.174",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/mjs/main.mjs",
|
|
6
6
|
"module": "./dist/mjs/main.mjs",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"r5d-worker": "dist/mjs/main.mjs"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@ricsam/r5d-api": "^0.0.
|
|
24
|
+
"@ricsam/r5d-api": "^0.0.174",
|
|
25
25
|
"node-pty": "1.1.0",
|
|
26
26
|
"zod": "^4.1.13",
|
|
27
27
|
"picomatch": "^4.0.3"
|