@rome-os/app-runtime 0.2.3 → 0.3.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/proxies.js DELETED
@@ -1,92 +0,0 @@
1
- // Worker-side typed proxies for main-process services.
2
- //
3
- // An action worker is a forked subprocess that holds no live reference to the
4
- // main-process singletons (RoutineEngine, EventBus, EventCatalog, AppManager) —
5
- // those own in-memory state (trigger timers, subscriber sets, child-process
6
- // handles) that cannot be duplicated across processes. Each proxy below
7
- // presents the action-facing surface of one service but forwards every call to
8
- // the main process over the WorkerRPC IPC channel (see `getWorkerRpc`), where
9
- // the real service does the work.
10
- //
11
- // They are one half of a pair: in the main process an action receives the real
12
- // service; in a worker it receives the matching `*Proxy`. The naming mirrors
13
- // the original (`FooEngine` -> `FooEngineProxy`) so the pair is obvious at a
14
- // callsite. Each proxy owns the RPC method string (and timeout) for its calls,
15
- // keeping that stringly-typed seam in one typed place instead of scattered
16
- // across action bodies.
17
- import { getWorkerRpc } from "./worker-rpc.js";
18
- /** apps.* operations install/pack on the main process — minutes, not seconds. */
19
- const APP_INSTALL_RPC_TIMEOUT_MS = 3 * 60 * 1000;
20
- /** A flag flip with no filesystem work. */
21
- const SHORT_RPC_TIMEOUT_MS = 30 * 1000;
22
- /**
23
- * Worker-side stand-in for the main-process `RoutineEngine`. Implements the
24
- * `RoutineEngine` surface an action depends on, so the same `deps.routineEngine`
25
- * works whether the action runs in the main process (real engine) or a worker
26
- * (this proxy).
27
- */
28
- export class RoutineEngineProxy {
29
- /** Bring a persisted routine live. The main process re-reads the row by id
30
- * and activates it, so only the id needs to cross the wire. */
31
- async activate(routine) {
32
- await getWorkerRpc().call("routines.schedule", { routineId: routine.id });
33
- }
34
- /** Tear down a routine's triggers in the main process. */
35
- async deactivate(routineId) {
36
- await getWorkerRpc().call("routines.cancel", { routineId });
37
- }
38
- }
39
- /**
40
- * Worker-side stand-in for the main-process `EventBus`. Publishing a domain
41
- * event also declares its type to the event catalog (RFC 020) — both happen in
42
- * the main process's `events.publish` handler.
43
- */
44
- export class EventBusProxy {
45
- async publish(event) {
46
- // No `?? {}` here: the `events.publish` Zod schema defaults a missing
47
- // payload to `{}` at the (validated) wire boundary, so defaulting again on
48
- // the way in is redundant.
49
- return await getWorkerRpc().call("events.publish", {
50
- name: event.name,
51
- source: event.source,
52
- payload: event.payload,
53
- });
54
- }
55
- }
56
- /** Worker-side stand-in for the main-process `EventCatalog` (read side). */
57
- export class EventCatalogProxy {
58
- /** Find emittable event types matching `query`, best matches first, capped at
59
- * `limit`. `total` is the full match count before truncation. */
60
- async search(query, limit) {
61
- return await getWorkerRpc().call("events.searchCatalog", { query, limit });
62
- }
63
- }
64
- /**
65
- * Worker-side stand-in for the main-process app lifecycle authority. Each method
66
- * owns its RPC method string and timeout. Results are app-local shapes the
67
- * action knows, so they return as `unknown` and the caller narrows them —
68
- * keeping those result types out of this SDK.
69
- */
70
- export class AppManagerProxy {
71
- async create(params) {
72
- return await getWorkerRpc().call("apps.create", params, {
73
- timeoutMs: APP_INSTALL_RPC_TIMEOUT_MS,
74
- });
75
- }
76
- async install(params) {
77
- return await getWorkerRpc().call("apps.install", params, {
78
- timeoutMs: APP_INSTALL_RPC_TIMEOUT_MS,
79
- });
80
- }
81
- async uninstall(params) {
82
- return await getWorkerRpc().call("apps.uninstall", params, {
83
- timeoutMs: APP_INSTALL_RPC_TIMEOUT_MS,
84
- });
85
- }
86
- async setEnabled(params) {
87
- return await getWorkerRpc().call("apps.setEnabled", params, {
88
- timeoutMs: SHORT_RPC_TIMEOUT_MS,
89
- });
90
- }
91
- }
92
- //# sourceMappingURL=proxies.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"proxies.js","sourceRoot":"","sources":["../src/proxies.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,EAAE;AACF,8EAA8E;AAC9E,gFAAgF;AAChF,4EAA4E;AAC5E,wEAAwE;AACxE,+EAA+E;AAC/E,8EAA8E;AAC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;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,eAAe;IAC1B,KAAK,CAAC,MAAM,CAAC,MAA2C;QACtD,OAAO,MAAM,YAAY,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,EAAE;YACtD,SAAS,EAAE,0BAA0B;SACtC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,MAA6D;QACzE,OAAO,MAAM,YAAY,EAAE,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,EAAE;YACvD,SAAS,EAAE,0BAA0B;SACtC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,MAA0C;QACxD,OAAO,MAAM,YAAY,EAAE,CAAC,IAAI,CAAC,gBAAgB,EAAE,MAAM,EAAE;YACzD,SAAS,EAAE,0BAA0B;SACtC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,MAA2C;QAC1D,OAAO,MAAM,YAAY,EAAE,CAAC,IAAI,CAAC,iBAAiB,EAAE,MAAM,EAAE;YAC1D,SAAS,EAAE,oBAAoB;SAChC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -1,35 +0,0 @@
1
- export interface RpcResponseMessage {
2
- type: "rpc_response";
3
- clientId: string;
4
- id: number;
5
- result?: unknown;
6
- error?: string;
7
- }
8
- export declare class WorkerRpcTimeoutError extends Error {
9
- constructor(method: string, timeoutMs: number);
10
- }
11
- export declare class WorkerRpcDisconnectError extends Error {
12
- constructor();
13
- }
14
- declare class WorkerRpcClient {
15
- private readonly clientId;
16
- private pending;
17
- private nextId;
18
- private processHandlersInstalled;
19
- call<T = unknown>(method: string, params?: unknown, options?: {
20
- timeoutMs?: number;
21
- }): Promise<T>;
22
- handleResponse(message: RpcResponseMessage): void;
23
- private ensureProcessHandlers;
24
- }
25
- export declare function getWorkerRpc(): WorkerRpcClient;
26
- export type WorkerRpcInProcessDispatcher = (method: string, params: unknown) => Promise<unknown>;
27
- /**
28
- * Register (or clear, with `null`) the main-process dispatcher used as a
29
- * fallback when there is no parent IPC channel. Called once during main-process
30
- * wiring with a handler backed by the live WorkerRpcServer.
31
- */
32
- export declare function setWorkerRpcInProcessDispatcher(dispatcher: WorkerRpcInProcessDispatcher | null): void;
33
- export declare function isWorkerRpcResponse(message: unknown): message is RpcResponseMessage;
34
- export {};
35
- //# sourceMappingURL=worker-rpc.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"worker-rpc.d.ts","sourceRoot":"","sources":["../src/worker-rpc.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,cAAc,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAI9C;AAED,qBAAa,wBAAyB,SAAQ,KAAK;;CAKlD;AAoBD,cAAM,eAAe;IACnB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAwB;IACjD,OAAO,CAAC,OAAO,CAAkC;IACjD,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,wBAAwB,CAAS;IAEnC,IAAI,CAAC,CAAC,GAAG,OAAO,EACpB,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAC/B,OAAO,CAAC,CAAC,CAAC;IAgEb,cAAc,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAYjD,OAAO,CAAC,qBAAqB;CAkB9B;AAID,wBAAgB,YAAY,IAAI,eAAe,CAK9C;AAWD,MAAM,MAAM,4BAA4B,GAAG,CACzC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,OAAO,KACZ,OAAO,CAAC,OAAO,CAAC,CAAC;AAItB;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,UAAU,EAAE,4BAA4B,GAAG,IAAI,GAC9C,IAAI,CAEN;AAQD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,kBAAkB,CAOnF"}
@@ -1,149 +0,0 @@
1
- // Worker-side RPC client for calling main-process services.
2
- //
3
- // The main process owns live references to ChannelManager, RoutineEngine,
4
- // and related services. Worker processes reach them over Node's child-process
5
- // IPC channel via this client — a replacement for the former HTTP callbacks
6
- // to the internal API.
7
- import { randomUUID } from "node:crypto";
8
- export class WorkerRpcTimeoutError extends Error {
9
- constructor(method, timeoutMs) {
10
- super(`WorkerRPC timeout: ${method} (${timeoutMs}ms)`);
11
- this.name = "WorkerRpcTimeoutError";
12
- }
13
- }
14
- export class WorkerRpcDisconnectError extends Error {
15
- constructor() {
16
- super("WorkerRPC main process disconnected");
17
- this.name = "WorkerRpcDisconnectError";
18
- }
19
- }
20
- const DEFAULT_TIMEOUT_MS = 30_000;
21
- // There may be more than one copy of this module loaded in the same process
22
- // (e.g. when an installed app ships its own physical copy of @rome-os/app-runtime
23
- // under node_modules/, producing a distinct ESM URL from the monorepo source).
24
- // Each copy constructs its own WorkerRpcClient with a distinct `clientId`.
25
- // Every instance installs its own process.on("message") listener; the main
26
- // process echoes `clientId` back on responses, so each listener only resolves
27
- // responses originating from its own pending map. This keeps pending maps
28
- // fully isolated across copies and avoids id-space collisions (nextId starts
29
- // from 1 independently in each copy).
30
- class WorkerRpcClient {
31
- clientId = randomUUID();
32
- pending = new Map();
33
- nextId = 1;
34
- processHandlersInstalled = false;
35
- async call(method, params, options) {
36
- if (!process.send) {
37
- // Main process: no parent IPC channel, but it directly holds the real
38
- // services. If a dispatcher is registered, run the call in-process
39
- // instead of failing. Worker processes always have `process.send` and
40
- // take the IPC path below — the two paths are mutually exclusive.
41
- const dispatcher = getInProcessDispatcher();
42
- if (dispatcher) {
43
- // Enforce the same deadline as the IPC path so both transports share
44
- // identical timeout semantics. Without this, callers like
45
- // AppManagerProxy (which set multi-minute deadlines for
46
- // apps.install/create/uninstall) would hang forever if an in-process
47
- // service operation stalls.
48
- const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
49
- let timer;
50
- const timeout = new Promise((_, reject) => {
51
- timer = setTimeout(() => reject(new WorkerRpcTimeoutError(method, timeoutMs)), timeoutMs);
52
- });
53
- try {
54
- return (await Promise.race([dispatcher(method, params), timeout]));
55
- }
56
- finally {
57
- if (timer)
58
- clearTimeout(timer);
59
- }
60
- }
61
- throw new Error(`WorkerRPC: not running in a Node.js child process (method=${method})`);
62
- }
63
- this.ensureProcessHandlers();
64
- const id = this.nextId++;
65
- const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
66
- return await new Promise((resolve, reject) => {
67
- const timeout = setTimeout(() => {
68
- this.pending.delete(id);
69
- reject(new WorkerRpcTimeoutError(method, timeoutMs));
70
- }, timeoutMs);
71
- this.pending.set(id, {
72
- resolve: (value) => resolve(value),
73
- reject,
74
- timeout,
75
- method,
76
- });
77
- const request = {
78
- type: "rpc_request",
79
- clientId: this.clientId,
80
- id,
81
- method,
82
- params,
83
- };
84
- process.send(request, (err) => {
85
- if (err) {
86
- clearTimeout(timeout);
87
- this.pending.delete(id);
88
- reject(err);
89
- }
90
- });
91
- });
92
- }
93
- handleResponse(message) {
94
- const pending = this.pending.get(message.id);
95
- if (!pending)
96
- return;
97
- clearTimeout(pending.timeout);
98
- this.pending.delete(message.id);
99
- if (message.error !== undefined) {
100
- pending.reject(new Error(message.error));
101
- }
102
- else {
103
- pending.resolve(message.result);
104
- }
105
- }
106
- ensureProcessHandlers() {
107
- if (this.processHandlersInstalled)
108
- return;
109
- this.processHandlersInstalled = true;
110
- process.on("message", (message) => {
111
- if (isWorkerRpcResponse(message) && message.clientId === this.clientId) {
112
- this.handleResponse(message);
113
- }
114
- });
115
- process.on("disconnect", () => {
116
- for (const pending of this.pending.values()) {
117
- clearTimeout(pending.timeout);
118
- pending.reject(new WorkerRpcDisconnectError());
119
- }
120
- this.pending.clear();
121
- });
122
- }
123
- }
124
- let singleton = null;
125
- export function getWorkerRpc() {
126
- if (!singleton) {
127
- singleton = new WorkerRpcClient();
128
- }
129
- return singleton;
130
- }
131
- const IN_PROCESS_DISPATCHER_KEY = Symbol.for("rome.workerRpc.inProcessDispatcher");
132
- /**
133
- * Register (or clear, with `null`) the main-process dispatcher used as a
134
- * fallback when there is no parent IPC channel. Called once during main-process
135
- * wiring with a handler backed by the live WorkerRpcServer.
136
- */
137
- export function setWorkerRpcInProcessDispatcher(dispatcher) {
138
- globalThis[IN_PROCESS_DISPATCHER_KEY] = dispatcher ?? undefined;
139
- }
140
- function getInProcessDispatcher() {
141
- return globalThis[IN_PROCESS_DISPATCHER_KEY];
142
- }
143
- export function isWorkerRpcResponse(message) {
144
- return (typeof message === "object" &&
145
- message !== null &&
146
- message.type === "rpc_response" &&
147
- typeof message.clientId === "string");
148
- }
149
- //# sourceMappingURL=worker-rpc.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"worker-rpc.js","sourceRoot":"","sources":["../src/worker-rpc.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,EAAE;AACF,0EAA0E;AAC1E,8EAA8E;AAC9E,4EAA4E;AAC5E,uBAAuB;AAEvB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAkBzC,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,MAAc,EAAE,SAAiB;QAC3C,KAAK,CAAC,sBAAsB,MAAM,KAAK,SAAS,KAAK,CAAC,CAAC;QACvD,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AAED,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACjD;QACE,KAAK,CAAC,qCAAqC,CAAC,CAAC;QAC7C,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;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