@almadar/shell-runtime 0.1.0 → 1.0.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.
Files changed (167) hide show
  1. package/dist/chunk-57SBCUSM.js +62 -0
  2. package/dist/chunk-625EP7W2.js +108 -0
  3. package/dist/{chunk-NATGCIVM.js → chunk-7WB6VWRK.js} +344 -129
  4. package/dist/{chunk-Q2H75UYT.js → chunk-A2JJT4GA.js} +1 -37
  5. package/dist/chunk-BAS26HBN.js +10 -0
  6. package/dist/{chunk-REPX5QPI.js → chunk-BOVU4TCQ.js} +11 -3
  7. package/dist/chunk-BY5G4225.js +6 -0
  8. package/dist/chunk-DFDNHVDW.js +284 -0
  9. package/dist/chunk-I3TKINSO.js +398 -0
  10. package/dist/{chunk-DYOJGLIX.js → chunk-LKWYCYX5.js} +2 -5
  11. package/dist/chunk-LYFIQPXX.js +1 -0
  12. package/dist/{chunk-VNMG7NKY.js → chunk-MU335ZA4.js} +20 -26
  13. package/dist/{chunk-ODJCZ27I.js → chunk-N7HYNKK6.js} +35 -2
  14. package/dist/{chunk-4J2QEIUV.js → chunk-NTFQ36UN.js} +4 -30
  15. package/dist/chunk-NU6LVKGS.js +15 -0
  16. package/dist/chunk-P2N6K2IV.js +20 -0
  17. package/dist/{chunk-QQRDUMB2.js → chunk-QCJWPXLH.js} +11 -11
  18. package/dist/{chunk-QELZ6TEJ.js → chunk-UD2CXYSJ.js} +39 -3
  19. package/dist/{chunk-UJHOUZAL.js → chunk-V4EMDPCO.js} +2 -5
  20. package/dist/chunk-VNGXRYFF.js +9 -0
  21. package/dist/{chunk-HNOAZWFH.js → chunk-WGCWJOT2.js} +2 -0
  22. package/dist/chunk-X6W44WHO.js +26 -0
  23. package/dist/chunk-ZUSM4VW4.js +197 -0
  24. package/dist/client/EventTransport.d.ts +23 -7
  25. package/dist/client/EventTransport.js +1 -2
  26. package/dist/client/awaiting.js +0 -1
  27. package/dist/client/channel-transport.d.ts +6 -6
  28. package/dist/client/channel-transport.js +0 -1
  29. package/dist/client/circuit-store.d.ts +16 -5
  30. package/dist/client/circuit-store.js +2 -3
  31. package/dist/client/client-kernel.d.ts +36 -15
  32. package/dist/client/declared-input-dispatch.d.ts +19 -2
  33. package/dist/client/declared-input-dispatch.js +1 -2
  34. package/dist/client/inbound-dispatch.d.ts +21 -2
  35. package/dist/client/inbound-dispatch.js +1 -2
  36. package/dist/client/local-fold.d.ts +15 -8
  37. package/dist/client/local-fold.js +1 -2
  38. package/dist/client/render-sigils.js +0 -1
  39. package/dist/client/state-book.d.ts +9 -16
  40. package/dist/client/state-book.js +1 -2
  41. package/dist/client/trait-mount-error.js +0 -1
  42. package/dist/credentials/env-vars.d.ts +5 -1
  43. package/dist/credentials/env-vars.js +1 -3
  44. package/dist/credentials/scope.d.ts +8 -7
  45. package/dist/credentials/scope.js +0 -1
  46. package/dist/credentials/vault.d.ts +142 -0
  47. package/dist/credentials/vault.js +1 -0
  48. package/dist/effects/in-flight-calls.js +0 -1
  49. package/dist/effects/on-device-model.js +0 -1
  50. package/dist/events/EventBus.d.ts +1 -4
  51. package/dist/events/EventBus.js +0 -1
  52. package/dist/events/emit-stamp.js +0 -1
  53. package/dist/index.d.ts +25 -42
  54. package/dist/index.js +27 -45
  55. package/dist/kernel/decode.d.ts +8 -10
  56. package/dist/kernel/decode.js +1 -2
  57. package/dist/kernel/engine.d.ts +132 -31
  58. package/dist/kernel/engine.js +7 -9
  59. package/dist/kernel/frame-applier.d.ts +8 -7
  60. package/dist/kernel/frame-applier.js +1 -2
  61. package/dist/kernel/host.d.ts +127 -16
  62. package/dist/kernel/host.js +4 -7
  63. package/dist/kernel/lane.d.ts +1 -22
  64. package/dist/kernel/lane.js +1 -2
  65. package/dist/kernel/os-fetch-port.d.ts +7 -0
  66. package/dist/kernel/os-fetch-port.js +3 -0
  67. package/dist/kernel/os-port.d.ts +30 -8
  68. package/dist/kernel/os-port.js +1 -2
  69. package/dist/kernel/program-effects.d.ts +11 -28
  70. package/dist/kernel/program-effects.js +1 -2
  71. package/dist/kernel/secret-ports.d.ts +139 -0
  72. package/dist/kernel/secret-ports.js +2 -0
  73. package/dist/kernel/wire.d.ts +50 -12
  74. package/dist/loader/fetch-loader.d.ts +26 -0
  75. package/dist/loader/fetch-loader.js +1 -0
  76. package/dist/loader/lazy-page.js +0 -1
  77. package/dist/loader/schema-loader.d.ts +1 -17
  78. package/dist/persistence/native-memory.js +0 -1
  79. package/dist/runtime/entities/declaredCollections.d.ts +6 -0
  80. package/dist/runtime/entities/declaredCollections.js +1 -0
  81. package/dist/runtime/evaluation/local-store-transport.d.ts +14 -23
  82. package/dist/runtime/evaluation/local-store-transport.js +9 -13
  83. package/dist/runtime/evaluation/residence-transport.d.ts +3 -3
  84. package/dist/runtime/evaluation/residence-transport.js +1 -2
  85. package/dist/runtime/evaluation/routed-persistence.js +0 -1
  86. package/dist/runtime/events/identity/routing.d.ts +2 -53
  87. package/dist/runtime/events/identity/routing.js +1 -2
  88. package/dist/runtime/types.d.ts +5 -205
  89. package/dist/runtime/types.js +1 -2
  90. package/dist/service/default-call-service.js +0 -1
  91. package/dist/service/service-provider.js +0 -1
  92. package/package.json +8 -5
  93. package/dist/chunk-2JU7Y4KU.js +0 -21
  94. package/dist/chunk-46RWK2B5.js +0 -28
  95. package/dist/chunk-4ZICQ5PM.js +0 -192
  96. package/dist/chunk-53IPZXDP.js +0 -76
  97. package/dist/chunk-5D63EMO5.js +0 -16
  98. package/dist/chunk-CPSQXEJ6.js +0 -55
  99. package/dist/chunk-CQP5XAX6.js +0 -173
  100. package/dist/chunk-CROS2GEX.js +0 -49
  101. package/dist/chunk-D4XJTBLB.js +0 -217
  102. package/dist/chunk-D5USD2EX.js +0 -232
  103. package/dist/chunk-EV56K4GB.js +0 -63
  104. package/dist/chunk-FQ6IZMIU.js +0 -10
  105. package/dist/chunk-HMK6YMQS.js +0 -135
  106. package/dist/chunk-IHQLE5M7.js +0 -62
  107. package/dist/chunk-JFWFDUTR.js +0 -35
  108. package/dist/chunk-MHYSHSRG.js +0 -54
  109. package/dist/chunk-MLKGABMK.js +0 -7
  110. package/dist/chunk-NAECVIAR.js +0 -322
  111. package/dist/chunk-Q7JK4KY7.js +0 -9
  112. package/dist/chunk-RBUMDYFS.js +0 -681
  113. package/dist/chunk-SAS5KKCR.js +0 -43
  114. package/dist/chunk-SWPDU752.js +0 -28
  115. package/dist/chunk-T775TUCD.js +0 -18
  116. package/dist/chunk-VMOBW7RK.js +0 -21
  117. package/dist/chunk-WNPNNYXY.js +0 -22
  118. package/dist/chunk-XB5GYODW.js +0 -28
  119. package/dist/chunk-YL2SO5TP.js +0 -334
  120. package/dist/chunk-YO4LWS3I.js +0 -606
  121. package/dist/chunk-ZAQSS47X.js +0 -157
  122. package/dist/chunk-ZCQUUJIF.js +0 -129
  123. package/dist/client/ServerBridge.d.ts +0 -126
  124. package/dist/client/ServerBridge.js +0 -3
  125. package/dist/credentials/seed.d.ts +0 -21
  126. package/dist/credentials/seed.js +0 -2
  127. package/dist/credentials/store.d.ts +0 -110
  128. package/dist/credentials/store.js +0 -2
  129. package/dist/index-hT1xCdTq.d.ts +0 -46
  130. package/dist/kernel/beacon.d.ts +0 -32
  131. package/dist/kernel/beacon.js +0 -2
  132. package/dist/kernel/http.d.ts +0 -302
  133. package/dist/kernel/http.js +0 -6
  134. package/dist/kernel/oauth-effects.d.ts +0 -25
  135. package/dist/kernel/oauth-effects.js +0 -7
  136. package/dist/kernel/oauth-port.d.ts +0 -31
  137. package/dist/kernel/oauth-port.js +0 -2
  138. package/dist/loader/http-loader.d.ts +0 -111
  139. package/dist/loader/http-loader.js +0 -2
  140. package/dist/runtime/effects/composition/compose-behaviors.d.ts +0 -58
  141. package/dist/runtime/effects/composition/compose-behaviors.js +0 -4
  142. package/dist/runtime/effects/composition/event-wiring.d.ts +0 -38
  143. package/dist/runtime/effects/composition/event-wiring.js +0 -2
  144. package/dist/runtime/effects/composition/index.d.ts +0 -5
  145. package/dist/runtime/effects/composition/index.js +0 -6
  146. package/dist/runtime/effects/composition/layout-strategy.d.ts +0 -35
  147. package/dist/runtime/effects/composition/layout-strategy.js +0 -2
  148. package/dist/runtime/effects/composition/pipe.d.ts +0 -25
  149. package/dist/runtime/effects/composition/pipe.js +0 -2
  150. package/dist/runtime/entities/mockStoreSeed.d.ts +0 -56
  151. package/dist/runtime/entities/mockStoreSeed.js +0 -3
  152. package/dist/runtime/entities/seedBrowserStore.d.ts +0 -28
  153. package/dist/runtime/entities/seedBrowserStore.js +0 -2
  154. package/dist/runtime/entities/std-mock-seed.d.ts +0 -87
  155. package/dist/runtime/entities/std-mock-seed.js +0 -2
  156. package/dist/runtime/time/TickScheduler.d.ts +0 -77
  157. package/dist/runtime/time/TickScheduler.js +0 -3
  158. package/dist/runtime/time/cron.d.ts +0 -25
  159. package/dist/runtime/time/cron.js +0 -2
  160. package/dist/runtime/time/duration.d.ts +0 -20
  161. package/dist/runtime/time/duration.js +0 -2
  162. package/dist/runtime/traits/OrbitalTraitParsing.d.ts +0 -34
  163. package/dist/runtime/traits/OrbitalTraitParsing.js +0 -2
  164. package/dist/runtime/traits/listen-targets.d.ts +0 -16
  165. package/dist/runtime/traits/listen-targets.js +0 -3
  166. package/dist/runtime/traits/trait-index.d.ts +0 -35
  167. package/dist/runtime/traits/trait-index.js +0 -3
@@ -0,0 +1,62 @@
1
+ // src/loader/fetch-loader.ts
2
+ var FetchSchemaLoader = class {
3
+ /** `base`: the URL relative imports resolve against when no importer is named (the page's own URL by default). */
4
+ constructor(base) {
5
+ this.base = base;
6
+ }
7
+ base;
8
+ cache = /* @__PURE__ */ new Map();
9
+ resolvePath(importPath, fromPath) {
10
+ try {
11
+ return { success: true, data: new URL(importPath, new URL(fromPath ?? this.base, this.base)).href };
12
+ } catch (error) {
13
+ return { success: false, error: `Cannot resolve ${importPath}${fromPath !== void 0 ? ` from ${fromPath}` : ""}: ${error instanceof Error ? error.message : String(error)}` };
14
+ }
15
+ }
16
+ load(importPath, fromPath) {
17
+ const resolved = this.resolvePath(importPath, fromPath);
18
+ if (!resolved.success) return Promise.resolve(resolved);
19
+ const url = resolved.data;
20
+ const held = this.cache.get(url);
21
+ if (held !== void 0) return held;
22
+ const loading = fetchSchema(url, importPath);
23
+ loading.then((result) => {
24
+ if (!result.success) this.cache.delete(url);
25
+ }, () => this.cache.delete(url));
26
+ this.cache.set(url, loading);
27
+ return loading;
28
+ }
29
+ async loadOrbital(importPath, orbitalName, fromPath) {
30
+ const loaded = await this.load(importPath, fromPath);
31
+ if (!loaded.success) return loaded;
32
+ const { schema, sourcePath } = loaded.data;
33
+ const orbital = orbitalName === void 0 ? schema.orbitals[0] : schema.orbitals.find((o) => o.name === orbitalName);
34
+ if (orbital === void 0) {
35
+ return { success: false, error: `${sourcePath} has no orbital ${orbitalName ?? "(none)"}; found: ${schema.orbitals.map((o) => o.name).join(", ")}` };
36
+ }
37
+ return { success: true, data: { orbital, orbitals: schema.orbitals, sourcePath, importPath } };
38
+ }
39
+ clearCache() {
40
+ this.cache.clear();
41
+ }
42
+ getCacheStats() {
43
+ return { size: this.cache.size };
44
+ }
45
+ };
46
+ async function fetchSchema(url, importPath) {
47
+ let response;
48
+ try {
49
+ response = await fetch(url);
50
+ } catch (error) {
51
+ return { success: false, error: `${url}: ${error instanceof Error ? error.message : String(error)}` };
52
+ }
53
+ if (!response.ok) return { success: false, error: `${url}: ${response.status} ${response.statusText}` };
54
+ try {
55
+ const schema = await response.json();
56
+ return { success: true, data: { schema, sourcePath: url, importPath } };
57
+ } catch (error) {
58
+ return { success: false, error: `${url} is not a program: ${error instanceof Error ? error.message : String(error)}` };
59
+ }
60
+ }
61
+
62
+ export { FetchSchemaLoader };
@@ -0,0 +1,108 @@
1
+ import { base64Standard } from './chunk-ZUSM4VW4.js';
2
+
3
+ // src/kernel/os-fetch-port.ts
4
+ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
5
+ var fail = (kind, message) => ({ error: { kind, message: `os/fetch: ${message}` } });
6
+ function bytesOf(base64) {
7
+ const text = atob(base64);
8
+ const bytes = new Uint8Array(text.length);
9
+ for (let i = 0; i < text.length; i += 1) bytes[i] = text.charCodeAt(i);
10
+ return bytes;
11
+ }
12
+ function headersOf(value) {
13
+ const headers = new Headers();
14
+ if (value === void 0) return headers;
15
+ if (!Array.isArray(value)) return "headers must be a list of { name, value }";
16
+ for (const header of value) {
17
+ if (!isRecord(header) || typeof header.name !== "string" || typeof header.value !== "string") return "headers must be a list of { name, value }";
18
+ headers.append(header.name, header.value);
19
+ }
20
+ return headers;
21
+ }
22
+ var failed = (kind, op, message) => ({ error: { kind, message: `${op}: ${message}` } });
23
+ function createFetchOsHost(performFetch) {
24
+ const pending = /* @__PURE__ */ new Set();
25
+ const bodies = /* @__PURE__ */ new Map();
26
+ let nextHandle = 1;
27
+ const openOf = (op, handle) => {
28
+ const open = typeof handle === "number" ? bodies.get(handle) : void 0;
29
+ return open ?? failed("closed", op, "the handle is not an open streamed response");
30
+ };
31
+ async function receive(args) {
32
+ const open = openOf("os/recv", args[0]);
33
+ if (!("reader" in open)) return open;
34
+ const count = args[1];
35
+ if (typeof count !== "number" || !Number.isInteger(count) || count < 1) return failed("invalid", "os/recv", "the count must be a positive integer");
36
+ try {
37
+ if (open.held.length === 0) {
38
+ const next = await open.reader.read();
39
+ if (next.done) return { ok: { data: base64Standard(new Uint8Array(0)), eof: true } };
40
+ open.held = next.value;
41
+ }
42
+ const data = open.held.subarray(0, count);
43
+ open.held = open.held.subarray(count);
44
+ return { ok: { data: base64Standard(data), eof: false } };
45
+ } catch (raised) {
46
+ return failed("io", "os/recv", raised instanceof Error ? raised.message : "the response body failed");
47
+ }
48
+ }
49
+ async function release(args) {
50
+ const open = openOf("os/close", args[0]);
51
+ if (!("reader" in open)) return open;
52
+ if (typeof args[0] === "number") bodies.delete(args[0]);
53
+ pending.delete(open.control);
54
+ open.control.abort();
55
+ await open.reader.cancel().catch(() => void 0);
56
+ return { ok: {} };
57
+ }
58
+ return {
59
+ async answer(op, args) {
60
+ if (op === "os/recv") return receive(args);
61
+ if (op === "os/close") return release(args);
62
+ if (op !== "os/fetch") return { error: { kind: "unsupported", message: `${op}: a browser host answers only os/fetch, and os/recv and os/close on the handle of a streamed one` } };
63
+ const [method, url, request] = args;
64
+ if (typeof method !== "string" || typeof url !== "string") return fail("invalid", "the method and the url must be text");
65
+ if (request !== void 0 && !isRecord(request)) return fail("invalid", "the request must be { headers?, body?, timeoutMs?, stream? }");
66
+ const headers = headersOf(request?.headers);
67
+ if (typeof headers === "string") return fail("invalid", headers);
68
+ const body = request?.body;
69
+ if (body !== void 0 && typeof body !== "string") return fail("invalid", "the body must be bytes");
70
+ const timeoutMs = request?.timeoutMs;
71
+ if (timeoutMs !== void 0 && (typeof timeoutMs !== "number" || !(timeoutMs > 0))) return fail("invalid", "timeoutMs must be a positive number");
72
+ const stream = request?.stream;
73
+ if (stream !== void 0 && typeof stream !== "boolean") return fail("invalid", "stream must be a boolean");
74
+ const control = new AbortController();
75
+ pending.add(control);
76
+ const timer = typeof timeoutMs === "number" ? setTimeout(() => control.abort(), timeoutMs) : void 0;
77
+ let kept = false;
78
+ try {
79
+ const response = await performFetch(url, { method, headers, signal: control.signal, ...body !== void 0 ? { body: bytesOf(body) } : {} });
80
+ const received = [];
81
+ response.headers.forEach((value, name) => received.push({ name, value }));
82
+ if (stream === true) {
83
+ const handle = nextHandle;
84
+ nextHandle += 1;
85
+ const reader = (response.body ?? new ReadableStream({ start: (sink) => sink.close() })).getReader();
86
+ bodies.set(handle, { reader, control, held: new Uint8Array(0) });
87
+ kept = true;
88
+ return { ok: { status: response.status, headers: received, body: base64Standard(new Uint8Array(0)), handle } };
89
+ }
90
+ return { ok: { status: response.status, headers: received, body: base64Standard(new Uint8Array(await response.arrayBuffer())) } };
91
+ } catch (raised) {
92
+ if (control.signal.aborted) return fail("timeout", `no answer within ${String(timeoutMs)} ms`);
93
+ return fail("io", raised instanceof Error ? raised.message : "the fetch failed");
94
+ } finally {
95
+ if (timer !== void 0) clearTimeout(timer);
96
+ if (!kept) pending.delete(control);
97
+ }
98
+ },
99
+ close() {
100
+ for (const control of pending) control.abort();
101
+ pending.clear();
102
+ for (const open of bodies.values()) void open.reader.cancel().catch(() => void 0);
103
+ bodies.clear();
104
+ }
105
+ };
106
+ }
107
+
108
+ export { createFetchOsHost };