@amalgm/shell 0.1.164-main.41474889901 → 0.1.164-main.41526666971

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 (74) hide show
  1. package/dist/cli.js +34 -41
  2. package/dist/cli.js.map +1 -1
  3. package/dist/drive/fuse.d.ts +13 -116
  4. package/dist/drive/fuse.js +36 -145
  5. package/dist/drive/fuse.js.map +1 -1
  6. package/dist/drive/kernel.d.ts +17 -0
  7. package/dist/drive/kernel.js +32 -0
  8. package/dist/drive/kernel.js.map +1 -0
  9. package/dist/drive/layout.d.ts +2 -0
  10. package/dist/drive/layout.js +8 -4
  11. package/dist/drive/layout.js.map +1 -1
  12. package/dist/drive/mount.d.ts +16 -6
  13. package/dist/drive/mount.js +50 -24
  14. package/dist/drive/mount.js.map +1 -1
  15. package/dist/drive/mountpoint.d.ts +14 -0
  16. package/dist/drive/mountpoint.js +51 -0
  17. package/dist/drive/mountpoint.js.map +1 -0
  18. package/dist/drive/nfs/apple-double.d.ts +6 -0
  19. package/dist/drive/nfs/apple-double.js +140 -0
  20. package/dist/drive/nfs/apple-double.js.map +1 -0
  21. package/dist/drive/nfs/attributes.d.ts +64 -0
  22. package/dist/drive/nfs/attributes.js +97 -0
  23. package/dist/drive/nfs/attributes.js.map +1 -0
  24. package/dist/drive/nfs/handles.d.ts +44 -0
  25. package/dist/drive/nfs/handles.js +209 -0
  26. package/dist/drive/nfs/handles.js.map +1 -0
  27. package/dist/drive/nfs/mount3.d.ts +16 -0
  28. package/dist/drive/nfs/mount3.js +38 -0
  29. package/dist/drive/nfs/mount3.js.map +1 -0
  30. package/dist/drive/nfs/nfs3.d.ts +27 -0
  31. package/dist/drive/nfs/nfs3.js +458 -0
  32. package/dist/drive/nfs/nfs3.js.map +1 -0
  33. package/dist/drive/nfs/rpc.d.ts +66 -0
  34. package/dist/drive/nfs/rpc.js +122 -0
  35. package/dist/drive/nfs/rpc.js.map +1 -0
  36. package/dist/drive/nfs/server.d.ts +30 -0
  37. package/dist/drive/nfs/server.js +109 -0
  38. package/dist/drive/nfs/server.js.map +1 -0
  39. package/dist/drive/nfs/xdr.d.ts +44 -0
  40. package/dist/drive/nfs/xdr.js +111 -0
  41. package/dist/drive/nfs/xdr.js.map +1 -0
  42. package/dist/drive/nfs.d.ts +60 -0
  43. package/dist/drive/nfs.js +181 -0
  44. package/dist/drive/nfs.js.map +1 -0
  45. package/dist/drive/operations.d.ts +125 -0
  46. package/dist/drive/operations.js +141 -0
  47. package/dist/drive/operations.js.map +1 -0
  48. package/dist/error-facts.d.ts +24 -0
  49. package/dist/error-facts.js +35 -0
  50. package/dist/error-facts.js.map +1 -0
  51. package/dist/files-program/client.d.ts +122 -0
  52. package/dist/files-program/client.js +430 -0
  53. package/dist/files-program/client.js.map +1 -0
  54. package/dist/files-program/journeys.d.ts +15 -0
  55. package/dist/files-program/journeys.js +79 -0
  56. package/dist/files-program/journeys.js.map +1 -0
  57. package/dist/files-program/program.d.ts +1 -0
  58. package/dist/files-program/program.js +255 -0
  59. package/dist/files-program/program.js.map +1 -0
  60. package/dist/files-program/protocol.d.ts +154 -0
  61. package/dist/files-program/protocol.js +7 -0
  62. package/dist/files-program/protocol.js.map +1 -0
  63. package/dist/machine-host.d.ts +35 -32
  64. package/dist/machine-host.js +124 -195
  65. package/dist/machine-host.js.map +1 -1
  66. package/dist/runtime-node-flags.d.ts +6 -6
  67. package/dist/runtime-node-flags.js +6 -6
  68. package/dist/sharing-host.d.ts +6 -11
  69. package/dist/sharing-host.js +6 -10
  70. package/dist/sharing-host.js.map +1 -1
  71. package/dist/sync-cli.js +1 -1
  72. package/dist/sync-cli.js.map +1 -1
  73. package/npm-shrinkwrap.json +2 -2
  74. package/package.json +4 -4
@@ -0,0 +1,79 @@
1
+ import { emitFilesStage } from "../files-observability.js";
2
+ /** Materialize through Live and prove the same runtime owns ongoing Watch. */
3
+ export function addWorkspace(ground, observe, workspaceId, destinationParent) {
4
+ return ground.operation(async () => {
5
+ const started = performance.now();
6
+ emitFilesStage(observe, {
7
+ primitive: "download", stage: "files-add", status: "started", workspaceId,
8
+ });
9
+ try {
10
+ const { addFilesWorkspace } = await import("@amalgm/live/files");
11
+ const added = await addFilesWorkspace(workspaceId, destinationParent, ground.filesCommandPorts().add);
12
+ const result = { ...added, watch: ground.addedWorkspaceEvidence(added.workspaceId) };
13
+ emitFilesStage(observe, {
14
+ primitive: "download",
15
+ stage: "files-add",
16
+ status: "completed",
17
+ workspaceId,
18
+ durationMs: performance.now() - started,
19
+ });
20
+ return result;
21
+ }
22
+ catch (error) {
23
+ emitFilesStage(observe, {
24
+ primitive: "download",
25
+ stage: "files-add",
26
+ status: "failed",
27
+ workspaceId,
28
+ durationMs: performance.now() - started,
29
+ });
30
+ throw error;
31
+ }
32
+ });
33
+ }
34
+ /** Route the complete user-visible register journey through Live's
35
+ * declaration and this already-running Files owner. */
36
+ export function registerWorkspace(ground, observe, requestedPath) {
37
+ return ground.operation(async () => {
38
+ const journeyStarted = performance.now();
39
+ const declarationStarted = performance.now();
40
+ emitFilesStage(observe, {
41
+ primitive: "register", stage: "files-register", status: "started", path: requestedPath,
42
+ });
43
+ emitFilesStage(observe, {
44
+ primitive: "register", stage: "durable-declaration", status: "started", path: requestedPath,
45
+ });
46
+ try {
47
+ const declared = await (await import("@amalgm/live/files")).registerFilesWorkspace(requestedPath, ground.filesCommandPorts().register);
48
+ emitFilesStage(observe, {
49
+ primitive: "register",
50
+ stage: "durable-declaration",
51
+ status: "completed",
52
+ path: requestedPath,
53
+ workspaceId: declared.workspaceId,
54
+ durationMs: performance.now() - declarationStarted,
55
+ });
56
+ const completed = await ground.completeWorkspaceRegistration(declared.workspaceId);
57
+ emitFilesStage(observe, {
58
+ primitive: "register",
59
+ stage: "files-register",
60
+ status: "completed",
61
+ path: requestedPath,
62
+ workspaceId: declared.workspaceId,
63
+ durationMs: performance.now() - journeyStarted,
64
+ });
65
+ return { ...declared, ...completed };
66
+ }
67
+ catch (error) {
68
+ emitFilesStage(observe, {
69
+ primitive: "register",
70
+ stage: "files-register",
71
+ status: "failed",
72
+ path: requestedPath,
73
+ durationMs: performance.now() - journeyStarted,
74
+ });
75
+ throw error;
76
+ }
77
+ });
78
+ }
79
+ //# sourceMappingURL=journeys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journeys.js","sourceRoot":"","sources":["../../src/files-program/journeys.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAA2B,MAAM,2BAA2B,CAAC;AAUpF,8EAA8E;AAC9E,MAAM,UAAU,YAAY,CAC1B,MAAsB,EACtB,OAA2B,EAC3B,WAAmB,EACnB,iBAAyB;IAEzB,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAClC,cAAc,CAAC,OAAO,EAAE;YACtB,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW;SAC1E,CAAC,CAAC;QACH,IAAI,CAAC;YACH,MAAM,EAAE,iBAAiB,EAAE,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC;YACjE,MAAM,KAAK,GAAG,MAAM,iBAAiB,CACnC,WAAW,EACX,iBAAiB,EACjB,MAAM,CAAC,iBAAiB,EAAE,CAAC,GAAG,CAC/B,CAAC;YACF,MAAM,MAAM,GAAG,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,sBAAsB,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC;YACrF,cAAc,CAAC,OAAO,EAAE;gBACtB,SAAS,EAAE,UAAU;gBACrB,KAAK,EAAE,WAAW;gBAClB,MAAM,EAAE,WAAW;gBACnB,WAAW;gBACX,UAAU,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,OAAO;aACxC,CAAC,CAAC;YACH,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,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;YACH,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,6BAA6B,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;YACnF,cAAc,CAAC,OAAO,EAAE;gBACtB,SAAS,EAAE,UAAU;gBACrB,KAAK,EAAE,gBAAgB;gBACvB,MAAM,EAAE,WAAW;gBACnB,IAAI,EAAE,aAAa;gBACnB,WAAW,EAAE,QAAQ,CAAC,WAAW;gBACjC,UAAU,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,cAAc;aAC/C,CAAC,CAAC;YACH,OAAO,EAAE,GAAG,QAAQ,EAAE,GAAG,SAAS,EAAE,CAAC;QACvC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,cAAc,CAAC,OAAO,EAAE;gBACtB,SAAS,EAAE,UAAU;gBACrB,KAAK,EAAE,gBAAgB;gBACvB,MAAM,EAAE,QAAQ;gBAChB,IAAI,EAAE,aAAa;gBACnB,UAAU,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,cAAc;aAC/C,CAAC,CAAC;YACH,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,255 @@
1
+ /**
2
+ * The Files program: the runtime's one Wire, its Files ground, and the drive
3
+ * that serves the ground, in a program of their own (client.ts says why).
4
+ * Its working folder is real disk, so nothing it starts waits on the drive.
5
+ * It does what the runtime asks over the process channel, asks the runtime
6
+ * only what runs there (Apps, an examination's install hook), and stops when
7
+ * the runtime lets it go or is gone. It never unmounts on its way out: until
8
+ * the drive is mounted again, its folder answers that its server is gone.
9
+ * While the ground a drive serves is closed, the drive rests (mount.ts).
10
+ */
11
+ import { pathToFileURL } from "node:url";
12
+ import { laneLayout, laneRoot } from "@amalgm/core/identity";
13
+ import { createCommands, createSharing } from "@amalgm/live/sharing";
14
+ import { createConstructPort } from "../construct-products.js";
15
+ import { driveLayout } from "../drive/layout.js";
16
+ import { errorFacts, reviveError } from "../error-facts.js";
17
+ import { FilesStageRecorder, serializeStages } from "../files-trace.js";
18
+ import { InstallationOwnership } from "../installation/ownership.js";
19
+ import { RuntimeWireHost } from "../runtime-wire-host.js";
20
+ import { keepSocketMarkingBestEffort } from "../socket-marking.js";
21
+ import { syncBlocked } from "../sync-setting.js";
22
+ import { UserGroundHost } from "../user-ground-host.js";
23
+ import { addWorkspace, registerWorkspace } from "./journeys.js";
24
+ import { countHandle, FILES_PROGRAM_STOPPED, } from "./protocol.js";
25
+ keepSocketMarkingBestEffort();
26
+ /** The Apps product's construct methods, each asked of the runtime. */
27
+ const APP_METHODS = [
28
+ "resolve", "dependencies", "copy", "trash", "inspect", "payloadDependencies", "switchTo", "applyStructure",
29
+ ];
30
+ let init = null;
31
+ let ownership = null;
32
+ let stages = new FilesStageRecorder();
33
+ let openWatch;
34
+ let appSelected = false;
35
+ let wire = null;
36
+ const grounds = new Map();
37
+ const drives = new Map();
38
+ /** The ground each drive serves now, by id; its placer asks that ground. */
39
+ const driveGrounds = new Map();
40
+ const asked = new Map();
41
+ let nextAsk = 0;
42
+ const appProduct = Object.fromEntries(APP_METHODS.map((method) => [method, (...args) => ask("app", [method, args])]));
43
+ function held(map, id, what) {
44
+ const value = map.get(id);
45
+ if (value === undefined) {
46
+ throw Object.assign(new Error(`this Files program holds no ${what} ${id}`), { code: FILES_PROGRAM_STOPPED });
47
+ }
48
+ return value;
49
+ }
50
+ function need(value, what) {
51
+ if (value === null)
52
+ throw new Error(`the Files program has no ${what} yet`);
53
+ return value;
54
+ }
55
+ function observing(name) {
56
+ return init?.observed.includes(name) ?? false;
57
+ }
58
+ function post(message) {
59
+ process.send(message, undefined, undefined, () => undefined);
60
+ }
61
+ /** Events and counts are reports: one the channel cannot carry is said on
62
+ * stderr, never thrown into the Files work that made it. */
63
+ function report(message) {
64
+ try {
65
+ post(message);
66
+ }
67
+ catch (error) {
68
+ process.stderr.write(`The Files program could not report ${message.kind}: ${error instanceof Error ? error.message : String(error)}\n`);
69
+ }
70
+ }
71
+ function emit(name, value) {
72
+ if (observing(name))
73
+ report({ kind: "event", name, value });
74
+ }
75
+ /** A count is null while its source cannot be read, as an Outbox that cannot
76
+ * be opened. */
77
+ function count(handle) {
78
+ return (value) => report({ kind: "count", handle, value });
79
+ }
80
+ function ask(method, args) {
81
+ const id = ++nextAsk;
82
+ return new Promise((resolve, reject) => {
83
+ asked.set(id, { resolve, reject });
84
+ try {
85
+ post({ kind: "ask", id, method, args });
86
+ }
87
+ catch (error) {
88
+ asked.delete(id);
89
+ reject(error);
90
+ }
91
+ });
92
+ }
93
+ async function traced(trace, run) {
94
+ if (!trace)
95
+ return run();
96
+ const captured = await stages.capture(run);
97
+ return { ...captured.result, stages: serializeStages(captured.stages) };
98
+ }
99
+ const methods = {
100
+ init: async (input) => {
101
+ init = input;
102
+ ownership = new InstallationOwnership({ home: input.home, binding: input.binding });
103
+ stages = new FilesStageRecorder(input.observed.includes("filesStage")
104
+ ? (evidence) => emit("filesStage", evidence)
105
+ : undefined);
106
+ openWatch = input.openWatchModule
107
+ ? (await import(pathToFileURL(input.openWatchModule).href)).default
108
+ : undefined;
109
+ },
110
+ products: (app) => { appSelected = app; },
111
+ "wire.open": async (input) => {
112
+ const previous = wire;
113
+ wire = null;
114
+ await previous?.close();
115
+ wire = new RuntimeWireHost(input, (error) => emit("wireError", errorFacts(error)));
116
+ },
117
+ "wire.start": (port, token) => need(wire, "Wire").start(port, token),
118
+ "wire.configure": () => { wire?.client.configureRuntime({}); },
119
+ "wire.close": async () => {
120
+ const closing = wire;
121
+ wire = null;
122
+ await closing?.close();
123
+ },
124
+ "wire.instance": () => need(wire, "Wire").client.instanceId,
125
+ "ground.create": (id, input) => {
126
+ const { userEmail, ...options } = input;
127
+ const owner = need(ownership, "installation");
128
+ grounds.set(id, new UserGroundHost({
129
+ ...options,
130
+ wire: need(wire, "Wire").client,
131
+ reserveWritableRoot: (path) => { owner.reserve(path, userEmail); },
132
+ ...(openWatch ? { openWatch } : {}),
133
+ ...(observing("watchHealth") ? { onWatchHealth: (health) => emit("watchHealth", health) } : {}),
134
+ ...(observing("detectScan") ? { onDetectScan: (evidence) => emit("detectScan", evidence) } : {}),
135
+ ...(observing("applyStage") ? { onApplyStage: (evidence) => emit("applyStage", evidence) } : {}),
136
+ ...(observing("backgroundError") ? { onBackgroundError: (error) => emit("backgroundError", errorFacts(error)) } : {}),
137
+ ...(init?.installStage ? { onInstallStage: async (evidence) => { await ask("installStage", [evidence]); } } : {}),
138
+ onFilesStage: stages.observe,
139
+ filesTraceActive: () => stages.listening,
140
+ // Apps is selected when the runtime starts, after this rail exists, so
141
+ // the owner of a construct type is asked per act.
142
+ constructProduct: (type) => (type === "app" && appSelected ? appProduct : null),
143
+ activity: { unsent: count(countHandle("ground", id, "unsent")), unsettled: count(countHandle("ground", id, "unsettled")) },
144
+ }));
145
+ },
146
+ "ground.converge": (id, identity) => held(grounds, id, "ground").port.converge(identity),
147
+ "ground.close": (id, options) => {
148
+ const ground = held(grounds, id, "ground");
149
+ grounds.delete(id);
150
+ for (const [drive, servedBy] of driveGrounds)
151
+ if (servedBy === id)
152
+ drives.get(drive)?.rest();
153
+ return ground.close(options);
154
+ },
155
+ "ground.flushWatch": (id) => held(grounds, id, "ground").flushWatch(),
156
+ "ground.flush": (id) => held(grounds, id, "ground").flush(),
157
+ "ground.blocked": (id) => syncBlocked(held(grounds, id, "ground").applyWaiting()),
158
+ "ground.watchEvidence": (id) => held(grounds, id, "ground").watchEvidence(),
159
+ "ground.add": (id, workspaceId, destinationParent, trace) => {
160
+ const ground = held(grounds, id, "ground");
161
+ return traced(trace, () => addWorkspace(ground, stages.observe, workspaceId, destinationParent));
162
+ },
163
+ "ground.register": (id, path, trace) => {
164
+ const ground = held(grounds, id, "ground");
165
+ return traced(trace, () => registerWorkspace(ground, stages.observe, path));
166
+ },
167
+ "ground.recordConstruct": (id, change) => {
168
+ const ground = held(grounds, id, "ground");
169
+ return ground.operation(() => ground.recordConstruct(change));
170
+ },
171
+ "ground.share": (id, name, request, actor, linkBase) => {
172
+ const ground = held(grounds, id, "ground");
173
+ const ports = ground.sharingPorts({
174
+ // Apps records its constructs through the intentional door, so it
175
+ // answers for `app`. A kind no product owns here resolves to "not
176
+ // selected in this installation"; no other kind is hurt.
177
+ constructs: createConstructPort({
178
+ products: appSelected ? { app: appProduct } : {},
179
+ kindOf: async (uuid) => ground.constructKind(uuid),
180
+ }),
181
+ link: (entityId) => `${linkBase}/c/${entityId}`,
182
+ });
183
+ return createCommands(createSharing(ports), actor).execute(name, request);
184
+ },
185
+ "drive.serve": async (id, groundId, userEmail) => {
186
+ const ground = held(grounds, groundId, "ground");
187
+ driveGrounds.set(id, groundId);
188
+ const standing = drives.get(id);
189
+ if (standing) {
190
+ await standing.serve(ground);
191
+ return { home: standing.home, mountpoint: standing.mountpoint, shelf: standing.shelf };
192
+ }
193
+ const { home, binding } = need(init, "installation");
194
+ const { serveDrive } = await import("../drive/mount.js");
195
+ const layout = driveLayout(laneLayout(laneRoot(home, binding)));
196
+ const served = await serveDrive(ground, {
197
+ mountpoint: layout.mountpoint(userEmail),
198
+ mountState: layout.mountState(userEmail),
199
+ layout,
200
+ placer: {
201
+ place: (unit) => held(grounds, held(driveGrounds, id, "drive"), "ground").enterNow(unit.uuid, { rootShelf: layout.rootShelf }),
202
+ },
203
+ activity: count(countHandle("drive", id, "placing")),
204
+ ...(observing("placed") ? { onPlaced: (receipt) => emit("placed", receipt) } : {}),
205
+ });
206
+ drives.set(id, served);
207
+ return { home: served.home, mountpoint: served.mountpoint, shelf: served.shelf };
208
+ },
209
+ "drive.folder": (id, address) => held(drives, id, "drive").folder(address),
210
+ "drive.unmount": async (id) => {
211
+ const served = drives.get(id);
212
+ drives.delete(id);
213
+ driveGrounds.delete(id);
214
+ await served?.unmount();
215
+ },
216
+ };
217
+ async function run(call) {
218
+ let reply;
219
+ try {
220
+ const method = methods[call.method];
221
+ reply = { kind: "result", id: call.id, value: await method(...call.args) };
222
+ }
223
+ catch (error) {
224
+ reply = { kind: "failure", id: call.id, error: errorFacts(error) };
225
+ }
226
+ try {
227
+ post(reply);
228
+ }
229
+ catch (error) {
230
+ post({ kind: "failure", id: call.id, error: errorFacts(error) });
231
+ }
232
+ }
233
+ process.on("message", (raw) => {
234
+ const message = raw;
235
+ if ("type" in message) {
236
+ process.send({ type: message.type, nonce: message.nonce }, undefined, undefined, () => undefined);
237
+ return;
238
+ }
239
+ if (message.kind === "call") {
240
+ void run(message);
241
+ return;
242
+ }
243
+ const pending = asked.get(message.id);
244
+ if (!pending)
245
+ return;
246
+ asked.delete(message.id);
247
+ if (message.kind === "answer")
248
+ pending.resolve(message.value);
249
+ else
250
+ pending.reject(reviveError(message.error));
251
+ });
252
+ // The runtime let it go, or is gone.
253
+ process.on("disconnect", () => process.exit(0));
254
+ process.send?.({ type: "amalgm-ready" }, undefined, undefined, () => undefined);
255
+ //# sourceMappingURL=program.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"program.js","sourceRoot":"","sources":["../../src/files-program/program.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAs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AAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC"}
@@ -0,0 +1,154 @@
1
+ /**
2
+ * What the runtime and its Files program say to each other (client.ts,
3
+ * program.ts): calls the runtime makes, the two questions Files asks back,
4
+ * the events it reports, and the counts it says. Only plain data crosses;
5
+ * an error crosses as its facts (error-facts.ts). The liveness rule every
6
+ * supervised process answers to (updates/bootstrap.ts) crosses the same
7
+ * channel, told apart by `type`.
8
+ */
9
+ import type { RuntimeBinding, UserGroundPort } from "@amalgm/core/identity";
10
+ import type { Receipt } from "@amalgm/live/drive";
11
+ import type { Actor, CommandName } from "@amalgm/live/sharing";
12
+ import type { EntityApplyStageEvidence } from "../apply-window-host.js";
13
+ import type { ConstructRecordChange } from "../construct-door.js";
14
+ import type { ErrorFacts } from "../error-facts.js";
15
+ import type { FilesStageEvidence } from "../files-observability.js";
16
+ import type { DetectScanEvidence, FlushOutcome, InstallStage, UserGroundCloseOptions, UserGroundClosed } from "../user-ground-host.js";
17
+ import type { SyncBlocked } from "../sync-setting.js";
18
+ import type { WatchCoverageEvidence, WatchHealth } from "../watching/index.js";
19
+ import type { AddedWorkspace } from "./journeys.js";
20
+ /** What Files reports as it works. The program sends only the ones the
21
+ * runtime listens to. */
22
+ export interface FilesEvents {
23
+ readonly wireError: ErrorFacts;
24
+ readonly backgroundError: ErrorFacts;
25
+ readonly watchHealth: WatchHealth;
26
+ readonly detectScan: DetectScanEvidence;
27
+ readonly applyStage: EntityApplyStageEvidence;
28
+ readonly filesStage: FilesStageEvidence;
29
+ readonly placed: Receipt;
30
+ }
31
+ export type FilesEventName = keyof FilesEvents;
32
+ export interface InstallStageEvidence {
33
+ readonly journey: "add" | "login";
34
+ readonly rootId: string;
35
+ readonly stage: InstallStage;
36
+ }
37
+ /** The questions Files asks the runtime: an install's examination hook, and
38
+ * the Apps product, which runs in the runtime. */
39
+ export interface FilesQuestions {
40
+ installStage(evidence: InstallStageEvidence): void;
41
+ app(method: string, args: readonly unknown[]): unknown;
42
+ }
43
+ export interface FilesInit {
44
+ readonly home: string;
45
+ readonly binding: RuntimeBinding;
46
+ /** A module whose default export opens native Watch; examinations only. */
47
+ readonly openWatchModule?: string;
48
+ readonly observed: readonly FilesEventName[];
49
+ /** Whether the runtime answers install stages. */
50
+ readonly installStage: boolean;
51
+ }
52
+ export interface WireInput {
53
+ readonly url: string;
54
+ readonly token: string;
55
+ readonly runtimeVersion: string;
56
+ }
57
+ export interface GroundInput {
58
+ readonly userEmail: string;
59
+ readonly userRoot: string;
60
+ readonly dir: string;
61
+ readonly drive: boolean;
62
+ readonly gitStorage: string;
63
+ readonly tunnelUrl: string;
64
+ readonly tunnelToken: string;
65
+ readonly runtimeVersion: string;
66
+ }
67
+ export type ConvergeIdentity = Parameters<UserGroundPort["converge"]>[0];
68
+ export type ConvergeEvidence = Awaited<ReturnType<UserGroundPort["converge"]>>;
69
+ export type Traced<T> = T | (T & {
70
+ readonly stages: readonly Record<string, unknown>[];
71
+ });
72
+ export interface DriveFacts {
73
+ readonly home: string;
74
+ readonly mountpoint: string;
75
+ readonly shelf: string;
76
+ }
77
+ /** Every call, by name. A ground and a drive are named by the id the
78
+ * runtime gave them, which outlives the program that holds them. */
79
+ export interface FilesMethods {
80
+ init(init: FilesInit): void;
81
+ /** Whether Apps runs, so whether a product answers for `app`. */
82
+ products(app: boolean): void;
83
+ /** Opens the runtime's one Wire client, closing any before it. */
84
+ "wire.open"(input: WireInput): void;
85
+ "wire.start"(gatewayPort: number, runtimeToken: string): void;
86
+ /** Stops forwarding to the runtime's gateway; the Wire stays open. */
87
+ "wire.configure"(): void;
88
+ "wire.close"(): void;
89
+ "wire.instance"(): string;
90
+ "ground.create"(id: number, input: GroundInput): void;
91
+ "ground.converge"(id: number, identity: ConvergeIdentity): ConvergeEvidence;
92
+ "ground.close"(id: number, options: UserGroundCloseOptions): UserGroundClosed;
93
+ "ground.flushWatch"(id: number): void;
94
+ "ground.flush"(id: number): FlushOutcome;
95
+ /** What holds Apply back, for sync status. */
96
+ "ground.blocked"(id: number): SyncBlocked[];
97
+ "ground.watchEvidence"(id: number): WatchCoverageEvidence;
98
+ "ground.add"(id: number, workspaceId: string, destinationParent: string, trace: boolean): Traced<AddedWorkspace>;
99
+ "ground.register"(id: number, path: string, trace: boolean): Traced<Record<string, unknown>>;
100
+ "ground.recordConstruct"(id: number, change: ConstructRecordChange): void;
101
+ "ground.share"(id: number, name: CommandName, request: unknown, actor: Actor, linkBase: string): unknown;
102
+ "drive.serve"(id: number, groundId: number, userEmail: string): DriveFacts;
103
+ "drive.folder"(id: number, address: readonly string[]): boolean;
104
+ "drive.unmount"(id: number): void;
105
+ }
106
+ export type FilesMethod = keyof FilesMethods;
107
+ export type FilesResult<M extends FilesMethod> = Awaited<ReturnType<FilesMethods[M]>>;
108
+ export type FilesRequest = {
109
+ readonly kind: "call";
110
+ readonly id: number;
111
+ readonly method: FilesMethod;
112
+ readonly args: readonly unknown[];
113
+ } | {
114
+ readonly kind: "answer";
115
+ readonly id: number;
116
+ readonly value: unknown;
117
+ } | {
118
+ readonly kind: "refusal";
119
+ readonly id: number;
120
+ readonly error: ErrorFacts;
121
+ };
122
+ /** What the runtime asks to learn that the program still answers. */
123
+ export interface HealthQuestion {
124
+ readonly type: "amalgm-health";
125
+ readonly nonce: string;
126
+ }
127
+ export type FilesReply = {
128
+ readonly kind: "result";
129
+ readonly id: number;
130
+ readonly value: unknown;
131
+ } | {
132
+ readonly kind: "failure";
133
+ readonly id: number;
134
+ readonly error: ErrorFacts;
135
+ } | {
136
+ readonly kind: "ask";
137
+ readonly id: number;
138
+ readonly method: keyof FilesQuestions;
139
+ readonly args: readonly unknown[];
140
+ } | {
141
+ readonly kind: "event";
142
+ readonly name: FilesEventName;
143
+ readonly value: unknown;
144
+ } | {
145
+ readonly kind: "count";
146
+ readonly handle: string;
147
+ readonly value: number | null;
148
+ };
149
+ /** A count's name on the channel: `ground:<id>:unsent`, `ground:<id>:unsettled`
150
+ * or `drive:<id>:placing`. */
151
+ export declare const countHandle: (owner: "ground" | "drive", id: number, count: "unsent" | "unsettled" | "placing") => string;
152
+ /** What a call names that the program does not hold: it stood in a program
153
+ * that stopped. */
154
+ export declare const FILES_PROGRAM_STOPPED = "files_program_stopped";
@@ -0,0 +1,7 @@
1
+ /** A count's name on the channel: `ground:<id>:unsent`, `ground:<id>:unsettled`
2
+ * or `drive:<id>:placing`. */
3
+ export const countHandle = (owner, id, count) => `${owner}:${id}:${count}`;
4
+ /** What a call names that the program does not hold: it stood in a program
5
+ * that stopped. */
6
+ export const FILES_PROGRAM_STOPPED = "files_program_stopped";
7
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/files-program/protocol.ts"],"names":[],"mappings":"AA4IA;8BAC8B;AAC9B,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAyB,EAAE,EAAU,EAAE,KAAyC,EAAU,EAAE,CACtH,GAAG,KAAK,IAAI,EAAE,IAAI,KAAK,EAAE,CAAC;AAE5B;mBACmB;AACnB,MAAM,CAAC,MAAM,qBAAqB,GAAG,uBAAuB,CAAC"}