@almadar/shell-runtime 0.0.0-stage → 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 (127) hide show
  1. package/dist/chunk-4SEK5ER2.js +8 -0
  2. package/dist/chunk-57SBCUSM.js +62 -0
  3. package/dist/chunk-625EP7W2.js +108 -0
  4. package/dist/chunk-64IH2SMY.js +22 -0
  5. package/dist/chunk-7SDV3QWR.js +67 -0
  6. package/dist/chunk-7WB6VWRK.js +798 -0
  7. package/dist/chunk-A2JJT4GA.js +56 -0
  8. package/dist/chunk-BAS26HBN.js +10 -0
  9. package/dist/chunk-BOVU4TCQ.js +65 -0
  10. package/dist/chunk-BY5G4225.js +6 -0
  11. package/dist/chunk-DFDNHVDW.js +284 -0
  12. package/dist/chunk-ELBLT2HZ.js +1 -0
  13. package/dist/chunk-EZZYLTWY.js +1 -0
  14. package/dist/chunk-FWA5K7Q2.js +48 -0
  15. package/dist/chunk-HC6ERSAH.js +55 -0
  16. package/dist/chunk-HLOUDLPI.js +48 -0
  17. package/dist/chunk-I3TKINSO.js +398 -0
  18. package/dist/chunk-IOPUS6Q5.js +15 -0
  19. package/dist/chunk-LKWYCYX5.js +22 -0
  20. package/dist/chunk-LYFIQPXX.js +1 -0
  21. package/dist/chunk-LZIOTBFX.js +1 -0
  22. package/dist/chunk-MU335ZA4.js +63 -0
  23. package/dist/chunk-MZKIL5IN.js +74 -0
  24. package/dist/chunk-N7HYNKK6.js +83 -0
  25. package/dist/chunk-NTFQ36UN.js +52 -0
  26. package/dist/chunk-NU6LVKGS.js +15 -0
  27. package/dist/chunk-O57GKTYU.js +30 -0
  28. package/dist/chunk-P2N6K2IV.js +20 -0
  29. package/dist/chunk-P53CKOME.js +1 -0
  30. package/dist/chunk-QCJWPXLH.js +40 -0
  31. package/dist/chunk-SKLMWHQD.js +109 -0
  32. package/dist/chunk-SOQDEPME.js +131 -0
  33. package/dist/chunk-UBN5JJKZ.js +26 -0
  34. package/dist/chunk-UD2CXYSJ.js +244 -0
  35. package/dist/chunk-UP6GGGAN.js +34 -0
  36. package/dist/chunk-V4EMDPCO.js +33 -0
  37. package/dist/chunk-VNGXRYFF.js +9 -0
  38. package/dist/chunk-WGCWJOT2.js +21 -0
  39. package/dist/chunk-X6W44WHO.js +26 -0
  40. package/dist/chunk-XXWNMJI6.js +15 -0
  41. package/dist/chunk-ZUSM4VW4.js +197 -0
  42. package/dist/client/EventTransport.d.ts +147 -0
  43. package/dist/client/EventTransport.js +1 -0
  44. package/dist/client/awaiting.d.ts +28 -0
  45. package/dist/client/awaiting.js +1 -0
  46. package/dist/client/channel-transport.d.ts +69 -0
  47. package/dist/client/channel-transport.js +1 -0
  48. package/dist/client/circuit-store.d.ts +87 -0
  49. package/dist/client/circuit-store.js +3 -0
  50. package/dist/client/client-kernel.d.ts +134 -0
  51. package/dist/client/client-kernel.js +1 -0
  52. package/dist/client/declared-input-dispatch.d.ts +22 -0
  53. package/dist/client/declared-input-dispatch.js +1 -0
  54. package/dist/client/inbound-dispatch.d.ts +24 -0
  55. package/dist/client/inbound-dispatch.js +1 -0
  56. package/dist/client/local-fold.d.ts +33 -0
  57. package/dist/client/local-fold.js +1 -0
  58. package/dist/client/render-sigils.d.ts +24 -0
  59. package/dist/client/render-sigils.js +1 -0
  60. package/dist/client/state-book.d.ts +30 -0
  61. package/dist/client/state-book.js +1 -0
  62. package/dist/client/trait-mount-error.d.ts +9 -0
  63. package/dist/client/trait-mount-error.js +1 -0
  64. package/dist/client/trait-types.d.ts +67 -0
  65. package/dist/client/trait-types.js +1 -0
  66. package/dist/credentials/env-vars.d.ts +18 -0
  67. package/dist/credentials/env-vars.js +1 -0
  68. package/dist/credentials/scope.d.ts +51 -0
  69. package/dist/credentials/scope.js +1 -0
  70. package/dist/credentials/vault.d.ts +142 -0
  71. package/dist/credentials/vault.js +1 -0
  72. package/dist/effects/in-flight-calls.d.ts +36 -0
  73. package/dist/effects/in-flight-calls.js +1 -0
  74. package/dist/effects/on-device-model.d.ts +22 -0
  75. package/dist/effects/on-device-model.js +1 -0
  76. package/dist/events/EventBus.d.ts +87 -0
  77. package/dist/events/EventBus.js +1 -0
  78. package/dist/events/emit-stamp.d.ts +47 -0
  79. package/dist/events/emit-stamp.js +1 -0
  80. package/dist/index.d.ts +43 -0
  81. package/dist/index.js +41 -0
  82. package/dist/kernel/decode.d.ts +13 -0
  83. package/dist/kernel/decode.js +1 -0
  84. package/dist/kernel/engine.d.ts +195 -0
  85. package/dist/kernel/engine.js +9 -0
  86. package/dist/kernel/frame-applier.d.ts +44 -0
  87. package/dist/kernel/frame-applier.js +1 -0
  88. package/dist/kernel/host.d.ts +206 -0
  89. package/dist/kernel/host.js +6 -0
  90. package/dist/kernel/lane.d.ts +7 -0
  91. package/dist/kernel/lane.js +1 -0
  92. package/dist/kernel/os-fetch-port.d.ts +7 -0
  93. package/dist/kernel/os-fetch-port.js +3 -0
  94. package/dist/kernel/os-port.d.ts +155 -0
  95. package/dist/kernel/os-port.js +1 -0
  96. package/dist/kernel/program-effects.d.ts +48 -0
  97. package/dist/kernel/program-effects.js +1 -0
  98. package/dist/kernel/secret-ports.d.ts +139 -0
  99. package/dist/kernel/secret-ports.js +2 -0
  100. package/dist/kernel/wire.d.ts +104 -0
  101. package/dist/kernel/wire.js +1 -0
  102. package/dist/loader/fetch-loader.d.ts +26 -0
  103. package/dist/loader/fetch-loader.js +1 -0
  104. package/dist/loader/lazy-page.d.ts +12 -0
  105. package/dist/loader/lazy-page.js +1 -0
  106. package/dist/loader/schema-loader.d.ts +144 -0
  107. package/dist/loader/schema-loader.js +1 -0
  108. package/dist/persistence/native-memory.d.ts +28 -0
  109. package/dist/persistence/native-memory.js +1 -0
  110. package/dist/runtime/entities/declaredCollections.d.ts +6 -0
  111. package/dist/runtime/entities/declaredCollections.js +1 -0
  112. package/dist/runtime/evaluation/local-store-transport.d.ts +59 -0
  113. package/dist/runtime/evaluation/local-store-transport.js +14 -0
  114. package/dist/runtime/evaluation/residence-transport.d.ts +15 -0
  115. package/dist/runtime/evaluation/residence-transport.js +1 -0
  116. package/dist/runtime/evaluation/routed-persistence.d.ts +9 -0
  117. package/dist/runtime/evaluation/routed-persistence.js +1 -0
  118. package/dist/runtime/events/identity/routing.d.ts +33 -0
  119. package/dist/runtime/events/identity/routing.js +1 -0
  120. package/dist/runtime/types.d.ts +374 -0
  121. package/dist/runtime/types.js +1 -0
  122. package/dist/service/default-call-service.d.ts +23 -0
  123. package/dist/service/default-call-service.js +2 -0
  124. package/dist/service/service-provider.d.ts +37 -0
  125. package/dist/service/service-provider.js +1 -0
  126. package/package.json +49 -3
  127. package/README.md +0 -3
@@ -0,0 +1,48 @@
1
+ import { ProgramInspection, CatalogEntry, TraitDescription, BehaviorDescription, OrbitalSchema, EvaluatedProgram, ProgramValidationIssue, DependencyGraph, EventPayload } from '@almadar/core';
2
+ import { ProveReport, OsGrantsReport, PlayedStep } from '@almadar/core/kernel-wire';
3
+ export { PlayedStep } from '@almadar/core/kernel-wire';
4
+
5
+ /** The effects the language trio routes to this host. */
6
+ declare const PROGRAM_EFFECTS: readonly ["behavior/catalog", "behavior/describe", "behavior/source", "behavior/resolve", "behavior/dependencies", "program/read", "program/print", "program/eval", "program/validate", "program/prove", "program/os-grants", "program/compose", "program/step"];
7
+ type ProgramEffectName = (typeof PROGRAM_EFFECTS)[number];
8
+ /** Narrow an effect head to one this host runs. */
9
+ declare function isProgramEffect(name: string): name is ProgramEffectName;
10
+ /** What `program/validate` returns. */
11
+ interface ProgramValidationReport {
12
+ readonly valid: boolean;
13
+ readonly errors: readonly ProgramValidationIssue[];
14
+ readonly warnings: readonly ProgramValidationIssue[];
15
+ }
16
+ /** One transition a host asks to play: the trait, the state it plays from, and the event with its payload. */
17
+ interface StepRequest {
18
+ orbital: string;
19
+ trait: string;
20
+ from: string;
21
+ event: string;
22
+ payload: EventPayload;
23
+ /** Fields merged into the trait's entity row before the event. */
24
+ entity?: EventPayload;
25
+ /** Knob values over the trait's declared config defaults, for this request's trait only. */
26
+ config?: EventPayload;
27
+ /** The ms-epoch `@now` the step's dispatch reads, in place of the wall clock. */
28
+ now?: number;
29
+ /** A live call's cutoff: an open call still running after this many ms is cancelled. */
30
+ settleMs?: number;
31
+ /** Test-only: the verified identity the replay kernel binds for this step (`@user`); absent is the anonymous viewer. */
32
+ identity?: {
33
+ subject: string;
34
+ claims: EventPayload;
35
+ };
36
+ }
37
+ /** The outcome of one program effect: the value for `{ result }`, or the failure (`errors` for eval's validator issues). */
38
+ type ProgramEffectOutcome = {
39
+ readonly ok: true;
40
+ readonly result: ProgramInspection | CatalogEntry[] | TraitDescription | BehaviorDescription | OrbitalSchema | string | EvaluatedProgram | ProgramValidationReport | ProveReport | OsGrantsReport | DependencyGraph | PlayedStep[];
41
+ } | {
42
+ readonly ok: false;
43
+ readonly error: string;
44
+ readonly errors?: readonly ProgramValidationIssue[];
45
+ };
46
+
47
+ export { PROGRAM_EFFECTS, isProgramEffect };
48
+ export type { ProgramEffectName, ProgramEffectOutcome, ProgramValidationReport, StepRequest };
@@ -0,0 +1 @@
1
+ export { PROGRAM_EFFECTS, isProgramEffect } from '../chunk-WGCWJOT2.js';
@@ -0,0 +1,139 @@
1
+ import { RuntimeValue, CredentialPayload } from '@almadar/core';
2
+ import { TokenEndpointPost, CredentialVault } from '../credentials/vault.js';
3
+ import { CredentialGrantWire, CredentialStanding, ConnectFailure } from '@almadar/core/kernel-wire';
4
+
5
+ /**
6
+ * The host ports of the kernel's secret, random and credential asks: the secret store, the CSPRNG and the credential
7
+ * administration port. The `http` effect is retired (HTTP/1.1 is `.lolo` over `os/*`), so nothing here moves HTTP bytes.
8
+ */
9
+
10
+ /**
11
+ * The host's secret store: a credential NAME in, its value out; `set` keeps a minted value for `ttlMs`.
12
+ * `principal` is the signed-in user's id for a user-scoped credential (the kernel sets it from the dispatch's `@user`,
13
+ * never the program); absent, the credential is app-wide.
14
+ */
15
+ interface SecretStore {
16
+ get(name: string, principal?: string): Promise<string | undefined>;
17
+ /** `ttlMs` of 0 forgets the value. */
18
+ set(name: string, value: string, ttlMs: number, principal?: string): Promise<void>;
19
+ /** Replace the stored credential with `value`, durably (a rotated refresh token). A host without one cannot rotate. */
20
+ rotate?(name: string, value: string, principal?: string): Promise<void>;
21
+ /** Drop the credential, the minted value and the stored one. */
22
+ forget(name: string, principal?: string): Promise<void>;
23
+ /** Keep `value` as the credential until it is forgotten, creating it when absent: unlike `rotate` it needs no existing entry. `label` is a non-secret account name stored beside it, never the value. */
24
+ persist?(name: string, value: string, principal?: string, label?: string): Promise<void>;
25
+ /** The non-secret account label stored beside the credential; absent when its row carries none. */
26
+ label?(name: string, principal?: string): Promise<string | undefined>;
27
+ /** Whether `persist` keeps a value on this host. */
28
+ durable?(): Promise<boolean>;
29
+ }
30
+ /** The credential-store key of one user's credential. */
31
+ declare function userCredentialKey(principal: string, name: string): string;
32
+ /** CSPRNG output: `bytes` random bytes. */
33
+ type RandomSource = (bytes: number) => Uint8Array;
34
+ /**
35
+ * The host's raw credential store and mode flag, answered to the kernel's `credentialStore*` and `credentialMode*`
36
+ * asks. It decides nothing: the role gate, the declared-name check, the masking and the mode check are the kernel's.
37
+ */
38
+ interface CredentialAdminPort {
39
+ /** Whether the store can encrypt and the service and name of every stored row; `null` when the host holds no store. */
40
+ list(): Promise<{
41
+ enabled: boolean;
42
+ entries: Array<{
43
+ service: string;
44
+ name: string;
45
+ }>;
46
+ } | null>;
47
+ /** The stored value of credential `name`, from the store only. */
48
+ read(name: string): Promise<string | null>;
49
+ write(service: string, name: string, value: string): Promise<void>;
50
+ /** Whether a stored row existed. */
51
+ remove(name: string): Promise<boolean>;
52
+ rotate(): Promise<{
53
+ rotated: number;
54
+ alreadyCurrent: number;
55
+ unreadable: number;
56
+ }>;
57
+ /** The mode flag; `null` when the host keeps none. */
58
+ mode(): Promise<string | null>;
59
+ /** Switch the flag; the host may refuse. The mode in force afterwards. */
60
+ setMode(mode: string): Promise<string>;
61
+ }
62
+ /** The tails of the named variables this host's own environment holds: `last4` only from eight characters up, never a value. */
63
+ type EnvTailsPort = (names: readonly string[]) => Array<{
64
+ name: string;
65
+ last4?: string;
66
+ }>;
67
+ /** The environment tails of `env`: a name it holds non-empty, with the last four characters of a value of eight or more. */
68
+ declare function envTailsOf(env: Readonly<Record<string, string | undefined>>): EnvTailsPort;
69
+ /** The host's answer to a `credentialConnect` ask: the kernel's store builds the exchange and settles it, the host only sends it. */
70
+ type CredentialConnectPort = (grant: CredentialGrantWire) => Promise<{
71
+ ok: CredentialStanding;
72
+ } | {
73
+ error: ConnectFailure;
74
+ }>;
75
+ interface SecretPorts {
76
+ /** The host CSPRNG `random-bytes` and the driver's `Random` ask draw from. */
77
+ random: RandomSource;
78
+ secrets: SecretStore;
79
+ /** The credential store and mode flag the credential administration effects ask; absent, those asks fail unavailable. */
80
+ credentials?: CredentialAdminPort;
81
+ /** The host's own environment, for `credential-list`; absent, the host answers `unsupported` (a browser reads none). */
82
+ env?: EnvTailsPort;
83
+ /** Carries a `credentialConnect`; absent, the ask answers `unavailable`. */
84
+ connect?: CredentialConnectPort;
85
+ }
86
+ interface SecretPortsOptions {
87
+ random?: RandomSource;
88
+ secrets?: SecretStore;
89
+ /** Defaults to the installed credential store and mode flag. */
90
+ credentials?: CredentialAdminPort;
91
+ /** Defaults to the process environment. */
92
+ env?: EnvTailsPort;
93
+ /** The host's POST to a token endpoint; with it the credential store connects and refreshes OAuth credentials, without it neither is attempted. */
94
+ tokenPost?: TokenEndpointPost;
95
+ }
96
+ /** Where the secrets' durable credentials live: the store a host installed, and how a name resolves through it. */
97
+ interface SecretStoreHost {
98
+ store(): Promise<CredentialVault | null>;
99
+ resolve(name: string, principal: string | undefined): Promise<string | undefined>;
100
+ }
101
+ /**
102
+ * The secrets of a host: minted values with an expiry (a memory tier that never reaches the rows), then the credential vault
103
+ * the host holds (by default the one the host installed). Everything durable is the kernel's: `rotate`, `persist`, `label`,
104
+ * and `forget`.
105
+ */
106
+ declare function createSecretStore(now?: () => number, host?: SecretStoreHost, tokenPost?: TokenEndpointPost): SecretStore;
107
+ /** `credentialConnect` over the installed credential store and the host's token POST. */
108
+ declare function createCredentialConnectPort(post: TokenEndpointPost): CredentialConnectPort;
109
+ /** The credential store and mode flag the host installed, as the kernel's raw asks. */
110
+ declare function createCredentialAdminPort(): CredentialAdminPort;
111
+ /** Bytes from the platform CSPRNG. */
112
+ declare const systemRandom: RandomSource;
113
+ /** The most bytes one `random-bytes` may ask for (the kernel's `RANDOM_BYTES_MAX`). */
114
+ declare const RANDOM_BYTES_MAX = 1024;
115
+ /** Standard padded base64 (the wire form of a `Random` answer). */
116
+ declare function base64Standard(bytes: Uint8Array): string;
117
+ /** URL-safe base64 without padding (the `random-bytes` value; the kernel's `codec::base64url_encode`). */
118
+ declare function base64Url(bytes: Uint8Array): string;
119
+ /**
120
+ * `random-bytes`: the success payload for `bytes` drawn from the host CSPRNG; a bad count or key is the effect's
121
+ * failure. A keyed call echoes its `key` beside the `value`.
122
+ */
123
+ declare function randomBytesPayload(ports: Pick<SecretPorts, 'random'>, bytes: RuntimeValue | undefined, key?: RuntimeValue): {
124
+ value: string;
125
+ key?: string;
126
+ };
127
+ /** `credential-status`: a bare name selects the viewer; an explicit slot selects its declared scope. */
128
+ declare function credentialStatusPayload(ports: Pick<SecretPorts, 'secrets'>, credential: RuntimeValue | undefined, principal: string | undefined): Promise<CredentialPayload>;
129
+ /** `credential-forget`: drops the signed-in viewer's credential; `{ connected: false }`. */
130
+ declare function credentialForgetPayload(ports: Pick<SecretPorts, 'secrets'>, credential: RuntimeValue | undefined, principal: string | undefined): Promise<{
131
+ connected: false;
132
+ label: string;
133
+ }>;
134
+ declare function createSecretPorts(options?: SecretPortsOptions): SecretPorts;
135
+ /** Ports of a browser: it holds no credential, so a secret ask fails and the CSPRNG is the page's. */
136
+ declare function createBrowserSecretPorts(): SecretPorts;
137
+
138
+ export { RANDOM_BYTES_MAX, base64Standard, base64Url, createBrowserSecretPorts, createCredentialAdminPort, createCredentialConnectPort, createSecretPorts, createSecretStore, credentialForgetPayload, credentialStatusPayload, envTailsOf, randomBytesPayload, systemRandom, userCredentialKey };
139
+ export type { CredentialAdminPort, CredentialConnectPort, EnvTailsPort, RandomSource, SecretPorts, SecretPortsOptions, SecretStore, SecretStoreHost };
@@ -0,0 +1,2 @@
1
+ export { RANDOM_BYTES_MAX, base64Standard, base64Url, createBrowserSecretPorts, createCredentialAdminPort, createCredentialConnectPort, createSecretPorts, createSecretStore, credentialForgetPayload, credentialStatusPayload, envTailsOf, randomBytesPayload, systemRandom, userCredentialKey } from '../chunk-ZUSM4VW4.js';
2
+ import '../chunk-HLOUDLPI.js';
@@ -0,0 +1,104 @@
1
+ import { KernelEvaluatorExports } from '@almadar/core';
2
+ import { EventRequest, FrameWire } from '@almadar/core/kernel-wire';
3
+ export { CallRoutesWire, CallSiteWire, CallerWire, IoAnswerWire, IoReplyWire, IoRequestWire, NextWire, PendingRequestWire, ResolveProgressWire, ServerProgressWire, Settled, SubstrateFailureWire } from '@almadar/core/kernel-wire';
4
+
5
+ /** Fired ticks keyed by the orbital that declares them: the one a `runTick` request is addressed to. */
6
+ type FiredByOrbital = FrameWire['fired'];
7
+
8
+ /** The `Server` class of `@almadar/kernel` (wasm-bindgen), as the runtime uses it. */
9
+ interface KernelServerHandle {
10
+ start(orbital: string, requestJson: string): string;
11
+ resume(flight: number, repliesJson: string): string;
12
+ /** The oldest request the kernel queued, started now the lane is free: a `NextWire` as JSON, or `null`. */
13
+ next(): string;
14
+ /** Whether `flight` is a dispatch parked holding the lane. */
15
+ holdsLane(flight: number): boolean;
16
+ /** A live stream of `client`'s session opened (EXEC-DIST-9); answers the id that closes it. */
17
+ openSessionStream(client: string): number;
18
+ /** The live stream `id` dropped; the kernel frees its session once all have dropped and it is quiet. */
19
+ closeSessionStream(id: number): boolean;
20
+ dispatchStream(): string;
21
+ /** Whether a live item reaches `clientId`'s session: addressed to it and admitted by `@read` for the identity that session bound. */
22
+ liveItemDelivered(itemJson: string, clientId?: string): boolean;
23
+ /** A row-set reference resolved through the host-answered store for the identity `clientId`'s session bound (the anonymous viewer with none); a `ResolveProgressWire` as JSON. */
24
+ resolveRows(refJson: string, clientId?: string): string;
25
+ resumeResolve(flight: number, repliesJson: string): string;
26
+ abandon(flight: number): boolean;
27
+ /** `OsGrants::allows` over the grants the registered program declares; `requirementJson` is an `OsRequirement`. */
28
+ osAllows(requirementJson: string, orbital?: string): boolean;
29
+ /** Whether `url`'s origin is one the program declares in `egress`. */
30
+ egressAllows(url: string): boolean;
31
+ /** Place the program's anchored grants and arguments under the host's anchors; answers `[{ path, message }]` for what grants nothing. */
32
+ setOsAnchors(anchorsJson: string): string;
33
+ /** Feed a deferred raw `os` outcome (`Settled`) into the TLS operation parked under `key`: `null`, `{ ask }` or `{ done }`. */
34
+ tlsComplete(key: string, outcomeJson: string): string;
35
+ /** An `os/` call's arguments with its anchored parts resolved; a `Settled<args, OsError>` as JSON. */
36
+ osResolveArgs(op: string, argsJson: string): string;
37
+ inFlight(): number;
38
+ getState(traitName: string, entityId?: string): string;
39
+ /** The kernel's mounts for a host start on `side` (`client|server|process|start`): `MountSeed[]` as JSON. */
40
+ bootMounts(side: string): string;
41
+ /** The kernel's mounts for a client opening `routePath`: `MountSeed[]` as JSON. */
42
+ routeMounts(routePath: string): string;
43
+ /** One question about the registered program (a `ContractQuery`: the declared inputs, inbound hooks, entity owner, scoped rows): its answer as JSON. */
44
+ contractQuery(queryJson: string): string;
45
+ mount(traitsJson: string): void;
46
+ remount(traitsJson: string): void;
47
+ /** Whether the kernel holds the circuit state: a client's copy of it is then taken only on a delegated leg, and any other request carrying one is refused. */
48
+ setStateful(stateful: boolean): void;
49
+ /** `client` mounted the traits (`string[]` JSON) of `orbital`: their mount-scoped ticks fire while any client holds them. */
50
+ mountClient(client: string, orbital: string, traitsJson: string): void;
51
+ unmountClient(client: string, orbital: string, traitsJson: string): void;
52
+ /** `client` is gone: everything it mounted is released. */
53
+ releaseClient(client: string): void;
54
+ /** Queue the tick-stamped request (an `EventRequest` as JSON) of `orbital` for the coalesced peer relay: the window length in ms as JSON when it opened one, else `null`. */
55
+ relayTick(orbital: string, requestJson: string): string;
56
+ setTickRelayInterval(intervalMs: number): void;
57
+ /** Every queued relay item (`LiveBroadcastItem[]` as JSON); the window closes. */
58
+ flushTickRelay(): string;
59
+ /** Whether the program declares any tick. */
60
+ declaresTicks(): boolean;
61
+ /** One pass of the kernel's tick clock at monotonic `nowMs`: the `(trait, tick)` pairs due that this server runs, keyed by orbital, as `FiredByOrbital` JSON. */
62
+ tickPass(nowMs: number): string;
63
+ tickPause(): void;
64
+ tickResume(): void;
65
+ tickPaused(): boolean;
66
+ setCapabilities(entityType: string, queryJson: string, writeJson: string): void;
67
+ /** The program (as JSON) whose declared credentials this server's credential effects manage beside its own. */
68
+ setManagedProgram(programJson: string): void;
69
+ lastError(): string;
70
+ /** A server holding this one's registered program and none of its session (a stateless request's kernel). */
71
+ fork(): KernelServerHandle;
72
+ forkProgram(programJson: string): KernelServerHandle;
73
+ free(): void;
74
+ }
75
+ /** The `Server` constructor of a kernel module. */
76
+ interface KernelServerClass {
77
+ /** `lazyDir`: the folder the program's `uses lazy` files sit beside; the kernel loads each on the first dispatch that reaches it (EXEC-LOAD-2). */
78
+ new (resolvedSchemaJson: string, lazyDir?: string): KernelServerHandle;
79
+ }
80
+ /** An initialised `@almadar/kernel` module: what `OrbitalServerRuntime({ engine: 'kernel' })` is handed. */
81
+ interface KernelModule extends KernelEvaluatorExports {
82
+ Server: KernelServerClass;
83
+ /** Whether the absolute `glob` matches `path`, as the one-grant matcher `os/glob` filters with. */
84
+ osGlobMatches(glob: string, path: string): boolean;
85
+ /** `is_public_address`: the rule an outbound host name must pass. */
86
+ isPublicAddress(ip: string): boolean;
87
+ /** One `ContractQuery` (as JSON) answered for a host with no registered program: the kernel's own answer on an empty kernel, as JSON. */
88
+ contractQueryWithoutProgram(queryJson: string): string;
89
+ /** The `os/` operations whose keyed call may defer its completion (`OsOp::defers_completion`), as a JSON array of names. */
90
+ osDeferringOps(): string;
91
+ /** The `os/` operations whose keyed call is a stream (`OsOp::is_stream`), as a JSON array of names. */
92
+ osStreamOps(): string;
93
+ /** The `{ event, payload }` JSON a deferred keyed `os/` call's outcome fires on its call site, or `null` when it declares no route. */
94
+ osCompletionEvent(siteJson: string, key: string, outcomeJson: string): string;
95
+ substrateCompletionEvent(siteJson: string, key: string, op: string, argsJson: string, outcomeJson: string): string;
96
+ /** Whether the Chrome match pattern matches the URL: the one rule a browser-tab host filters tabs with. */
97
+ tabUrlMatches(pattern: string, url: string): boolean;
98
+ /** The typed event request a `program/dispatch` call names (`EventRequest::from_dispatch`); a record that is no event request throws the reason. */
99
+ parseEventRequest(payloadJson: string, optionsJson: string): EventRequest;
100
+ /** Installs the language data (`@almadar/core/language-data` `LanguageBundle` as JSON) for a host with no `node_modules`; the first install wins. */
101
+ installLanguage(bundleJson: string): void;
102
+ }
103
+
104
+ export type { FiredByOrbital, KernelModule, KernelServerClass, KernelServerHandle };
@@ -0,0 +1 @@
1
+ import '../chunk-EZZYLTWY.js';
@@ -0,0 +1,26 @@
1
+ import { SchemaLoader, LoadResult, LoadedSchema, LoadedOrbital } from './schema-loader.js';
2
+ import '@almadar/core';
3
+
4
+ /**
5
+ * A `SchemaLoader` over HTTP: a browser client fetches the `.orb` of a lazy page (`uses lazy`) from beside the program
6
+ * it booted, at the page's `orbRef` resolved against the importer's URL (EXEC-LOAD-2: a browser client opens lazy pages
7
+ * through its own loader).
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+
12
+ declare class FetchSchemaLoader implements SchemaLoader {
13
+ private readonly base;
14
+ private readonly cache;
15
+ /** `base`: the URL relative imports resolve against when no importer is named (the page's own URL by default). */
16
+ constructor(base: string);
17
+ resolvePath(importPath: string, fromPath?: string): LoadResult<string>;
18
+ load(importPath: string, fromPath?: string): Promise<LoadResult<LoadedSchema>>;
19
+ loadOrbital(importPath: string, orbitalName?: string, fromPath?: string): Promise<LoadResult<LoadedOrbital>>;
20
+ clearCache(): void;
21
+ getCacheStats(): {
22
+ size: number;
23
+ };
24
+ }
25
+
26
+ export { FetchSchemaLoader };
@@ -0,0 +1 @@
1
+ export { FetchSchemaLoader } from '../chunk-57SBCUSM.js';
@@ -0,0 +1,12 @@
1
+ import { LazyPage, OrbitalSchema } from '@almadar/core';
2
+ import { SchemaLoader, LoadResult } from './schema-loader.js';
3
+
4
+ /**
5
+ * `uses lazy`: the behavior behind a lazy page lives in its own `.orb`, at the
6
+ * page's `orbRef` relative to the importer's `.orb`, and is loaded when the
7
+ * page is opened.
8
+ */
9
+
10
+ declare function loadLazyPage(loader: SchemaLoader, page: LazyPage, importerPath?: string): Promise<LoadResult<OrbitalSchema>>;
11
+
12
+ export { loadLazyPage };
@@ -0,0 +1 @@
1
+ export { loadLazyPage } from '../chunk-XXWNMJI6.js';
@@ -0,0 +1,144 @@
1
+ import { OrbitalSchema, Orbital, DeclaredTraitConfig } from '@almadar/core';
2
+
3
+ /**
4
+ * SchemaLoader Interface
5
+ *
6
+ * Abstract interface for loading OrbitalSchema files from various sources.
7
+ * Implementations exist for:
8
+ * - FileSystemLoader (Node.js) - uses fs module
9
+ * - UnifiedLoader (Auto-detect) - routes to appropriate loader
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+
14
+ /**
15
+ * Result of loading a schema.
16
+ */
17
+ interface LoadedSchema {
18
+ /** The loaded schema */
19
+ schema: OrbitalSchema;
20
+ /** Source path/URL (resolved) */
21
+ sourcePath: string;
22
+ /** Original import path */
23
+ importPath: string;
24
+ }
25
+ /**
26
+ * Result of loading a single orbital from a schema.
27
+ */
28
+ interface LoadedOrbital {
29
+ /** The loaded orbital — the named one when requested, else the first. */
30
+ orbital: Orbital;
31
+ /**
32
+ * EVERY orbital in the loaded schema. `Alias.traits.X` carries no orbital
33
+ * segment, so a multi-orbital behavior's traits and pages must all stay
34
+ * reachable; resolving against `orbital` alone silently loses everything
35
+ * outside it. Mirrors the compiled path's `AliasEntry.orbitals`.
36
+ */
37
+ orbitals?: Orbital[];
38
+ /**
39
+ * The loaded schema's own app-level `config`, when it declares one.
40
+ * Traits from this orbital must resolve against THIS config, not the
41
+ * consumer's — omitted (never `undefined`) when the schema declares none.
42
+ */
43
+ schemaConfig?: DeclaredTraitConfig;
44
+ /** Source path/URL (resolved) */
45
+ sourcePath: string;
46
+ /** Original import path */
47
+ importPath: string;
48
+ }
49
+ /**
50
+ * Loader result with error handling.
51
+ */
52
+ type LoadResult<T> = {
53
+ success: true;
54
+ data: T;
55
+ } | {
56
+ success: false;
57
+ error: string;
58
+ };
59
+ /**
60
+ * Base options for all loaders.
61
+ */
62
+ interface BaseLoaderOptions {
63
+ /** Base path/URL for resolving relative imports */
64
+ basePath: string;
65
+ /** Standard library root path/URL */
66
+ stdLibPath?: string;
67
+ /** Scoped package roots (e.g., { "@game-lib": "/path/to/lib" }) */
68
+ scopedPaths?: Record<string, string>;
69
+ }
70
+ /**
71
+ * Abstract interface for schema loaders.
72
+ *
73
+ * All loaders must implement:
74
+ * - load() - Load a schema from an import path
75
+ * - resolvePath() - Resolve an import path to absolute path/URL
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * // Using FileSystemLoader (Node.js)
80
+ * const loader: SchemaLoader = new FileSystemLoader({ basePath: "/schemas" });
81
+ * const result = await loader.load("./my-schema.orb");
82
+ *
83
+ * // Using UnifiedLoader (auto-detect)
84
+ * const loader: SchemaLoader = createUnifiedLoader({ basePath: "/schemas" });
85
+ * const result = await loader.load("./my-schema.orb");
86
+ * ```
87
+ */
88
+ interface SchemaLoader {
89
+ /**
90
+ * Load a schema from an import path.
91
+ *
92
+ * @param importPath - The import path (e.g., "./health.orb", "std/behaviors/game-core")
93
+ * @param fromPath - The path of the file doing the import (for relative resolution)
94
+ * @param chain - Import chain for circular detection (optional)
95
+ */
96
+ load(importPath: string, fromPath?: string, chain?: ImportChainLike): Promise<LoadResult<LoadedSchema>>;
97
+ /**
98
+ * Load a specific orbital from a schema by name.
99
+ *
100
+ * @param importPath - The import path
101
+ * @param orbitalName - The orbital name (optional, defaults to first orbital)
102
+ * @param fromPath - The path of the file doing the import
103
+ * @param chain - Import chain for circular detection (optional)
104
+ */
105
+ loadOrbital(importPath: string, orbitalName?: string, fromPath?: string, chain?: ImportChainLike): Promise<LoadResult<LoadedOrbital>>;
106
+ /**
107
+ * Resolve an import path to an absolute path/URL.
108
+ *
109
+ * @param importPath - The import path
110
+ * @param fromPath - The path of the file doing the import (optional)
111
+ */
112
+ resolvePath(importPath: string, fromPath?: string): LoadResult<string>;
113
+ /**
114
+ * Clear the loader's cache.
115
+ */
116
+ clearCache(): void;
117
+ /**
118
+ * Get cache statistics.
119
+ */
120
+ getCacheStats(): {
121
+ size: number;
122
+ };
123
+ }
124
+ /**
125
+ * Interface for import chain (circular detection).
126
+ * This allows different implementations to interoperate.
127
+ */
128
+ interface ImportChainLike {
129
+ /**
130
+ * Try to add a path to the chain.
131
+ * @returns Error message if circular, null if OK
132
+ */
133
+ push(absolutePath: string): string | null;
134
+ /**
135
+ * Remove the last path from the chain.
136
+ */
137
+ pop(): void;
138
+ /**
139
+ * Clone the chain for nested loading.
140
+ */
141
+ clone(): ImportChainLike;
142
+ }
143
+
144
+ export type { BaseLoaderOptions, ImportChainLike, LoadResult, LoadedOrbital, LoadedSchema, SchemaLoader };
@@ -0,0 +1 @@
1
+ import '../chunk-ELBLT2HZ.js';
@@ -0,0 +1,28 @@
1
+ import { PersistenceAdapter, KernelMemoryStoreWire, EntityRow, RowQuery, RowQueryPage, RowIdPage, QueryCapabilities, RowWriteOp, RowWriteOutcome, RowWriteBatch, WriteCapabilities } from '@almadar/core';
2
+
3
+ declare class NativeMemoryWriteError extends Error {
4
+ readonly outcome: RowWriteOutcome;
5
+ constructor(outcome: RowWriteOutcome);
6
+ }
7
+ declare class NativeMemoryPersistenceAdapter implements PersistenceAdapter {
8
+ readonly store: KernelMemoryStoreWire;
9
+ constructor(store: KernelMemoryStoreWire);
10
+ getById(entityType: string, id: string): Promise<EntityRow | null>;
11
+ list(entityType: string): Promise<EntityRow[]>;
12
+ create(entityType: string, data: EntityRow): Promise<{
13
+ id: string;
14
+ }>;
15
+ update(entityType: string, id: string, data: EntityRow): Promise<void>;
16
+ delete(entityType: string, id: string): Promise<void>;
17
+ queryPage(entityType: string, query: RowQuery): Promise<RowQueryPage>;
18
+ queryIds(entityType: string, query: RowQuery): Promise<RowIdPage>;
19
+ queryCapabilities(_entityType: string): QueryCapabilities;
20
+ writeWhere(op: RowWriteOp): Promise<RowWriteOutcome>;
21
+ writeBatch(batch: RowWriteBatch): Promise<RowWriteOutcome[]>;
22
+ writeCapabilities(_entityType: string): WriteCapabilities;
23
+ bindCollection(entityType: string, collection: string): void;
24
+ clear(): void;
25
+ snapshot(): Record<string, EntityRow[]>;
26
+ }
27
+
28
+ export { NativeMemoryPersistenceAdapter, NativeMemoryWriteError };
@@ -0,0 +1 @@
1
+ export { NativeMemoryPersistenceAdapter, NativeMemoryWriteError } from '../chunk-7SDV3QWR.js';
@@ -0,0 +1,6 @@
1
+ import { PersistenceAdapter, Entity } from '@almadar/core';
2
+
3
+ /** Tells the store each server-persisted entity's declared `[persistent: tbl]` collection (EXEC-STORE-1). */
4
+ declare function bindDeclaredCollections(store: PersistenceAdapter, entities: readonly Entity[]): void;
5
+
6
+ export { bindDeclaredCollections };
@@ -0,0 +1 @@
1
+ export { bindDeclaredCollections } from '../../chunk-BAS26HBN.js';
@@ -0,0 +1,59 @@
1
+ import { OrbitalSchema, PersistenceAdapter, OnDeviceModelPorts, BrowserTabPort, RowSetRef, RowQueryPage } from '@almadar/core';
2
+ import { EffectHandlers } from '../types.js';
3
+ import { KernelEngine } from '../../kernel/engine.js';
4
+ import { KernelHostPorts } from '../../kernel/host.js';
5
+ import { OsHostPort } from '../../kernel/os-port.js';
6
+ import { SecretPorts } from '../../kernel/secret-ports.js';
7
+ import { KernelModule } from '../../kernel/wire.js';
8
+ import { EventTransport } from '../../client/EventTransport.js';
9
+ import '../../service/default-call-service.js';
10
+ import '../../service/service-provider.js';
11
+ import '../../kernel/program-effects.js';
12
+ import '@almadar/core/kernel-wire';
13
+ import '../../effects/in-flight-calls.js';
14
+ import '../../credentials/vault.js';
15
+
16
+ /**
17
+ * An in-process transport over a local store: every request runs on the kernel opened over that store
18
+ * (`openLocalKernel`), and this host answers its I/O. The offline preview and the browser-stored side of a
19
+ * residence-routed host both use it.
20
+ */
21
+
22
+ interface LocalKernelOptions {
23
+ /** The initialised `@almadar/kernel` module with its language already installed (`loadBrowserKernel`): opening a kernel installs nothing. */
24
+ kernel: KernelModule;
25
+ schema: OrbitalSchema;
26
+ /** Every row the kernel reads and writes (`localStorePersistence` over a browser store). */
27
+ persistence: PersistenceAdapter;
28
+ /** Answers every `call-service`; absent, the default provider. */
29
+ callService?: EffectHandlers['callService'];
30
+ /** The running app lent to `call-service` providers; absent, a provider reads the rows its viewer may read and dispatches no input. */
31
+ servicePorts?: KernelHostPorts['servicePorts'];
32
+ /** Where a follow-on call's outcome is dispatched; absent, nowhere. */
33
+ deferCallOutcome?: KernelHostPorts['deferCallOutcome'];
34
+ pageFacts?: KernelHostPorts['pageFacts'];
35
+ hostActions?: KernelHostPorts['hostActions'];
36
+ secretPorts?: SecretPorts;
37
+ onDevice?: OnDeviceModelPorts;
38
+ tabs?: BrowserTabPort;
39
+ /** The host's `os` port (`createFetchOsHost` in a browser); absent, every `os` ask is denied. */
40
+ os?: OsHostPort;
41
+ }
42
+ /** A local store's rows as the kernel holds them: browser-stored entities in `store`, every other entity in `memory` (a native `MemoryStore` adapter). */
43
+ declare function localStorePersistence(schema: OrbitalSchema, store: PersistenceAdapter, memory: PersistenceAdapter): PersistenceAdapter;
44
+ /** A kernel over a local store, answering its I/O with `persistence` and the given ports. */
45
+ declare function openLocalKernel(options: LocalKernelOptions): KernelEngine;
46
+ interface LocalStoreTransportOptions {
47
+ /** The kernel the requests run on (`openLocalKernel`), or its promise while the kernel module loads. */
48
+ kernelEngine: KernelEngine | Promise<KernelEngine>;
49
+ /** The program the kernel runs; given, the transport resolves row-set references on that kernel. */
50
+ schema?: OrbitalSchema;
51
+ /** The page's locale, read per request: a request naming none runs in it, as a server request carries its viewer's. */
52
+ locale?: () => string | undefined;
53
+ }
54
+ declare function createLocalStoreTransport(options: LocalStoreTransportOptions): EventTransport;
55
+ /** `reference` resolved on a local kernel: the kernel applies the session identity's `@read`, the host answers its row reads. */
56
+ declare function resolveLocalRows(engine: KernelEngine, reference: RowSetRef): Promise<RowQueryPage>;
57
+
58
+ export { createLocalStoreTransport, localStorePersistence, openLocalKernel, resolveLocalRows };
59
+ export type { LocalKernelOptions, LocalStoreTransportOptions };
@@ -0,0 +1,14 @@
1
+ export { createLocalStoreTransport, localStorePersistence, openLocalKernel, resolveLocalRows } from '../../chunk-MU335ZA4.js';
2
+ import '../../chunk-4SEK5ER2.js';
3
+ import '../../chunk-UBN5JJKZ.js';
4
+ import '../../chunk-O57GKTYU.js';
5
+ import '../../chunk-I3TKINSO.js';
6
+ import '../../chunk-NU6LVKGS.js';
7
+ import '../../chunk-X6W44WHO.js';
8
+ import '../../chunk-7WB6VWRK.js';
9
+ import '../../chunk-WGCWJOT2.js';
10
+ import '../../chunk-ZUSM4VW4.js';
11
+ import '../../chunk-FWA5K7Q2.js';
12
+ import '../../chunk-HLOUDLPI.js';
13
+ import '../../chunk-MZKIL5IN.js';
14
+ import '../../chunk-UD2CXYSJ.js';
@@ -0,0 +1,15 @@
1
+ import { EventTransport } from '../../client/EventTransport.js';
2
+ import '@almadar/core';
3
+
4
+ interface ResidenceTransportOptions {
5
+ /** In-process transport over the browser store. */
6
+ local: EventTransport;
7
+ /** The server; absent on a static host. */
8
+ remote?: EventTransport;
9
+ /** The program's browser-stored entities (the kernel's `programSurface`): a row-set reference to one of them is resolved in-process. */
10
+ browserEntities: ReadonlySet<string>;
11
+ }
12
+ declare function createResidenceTransport(options: ResidenceTransportOptions): EventTransport;
13
+
14
+ export { createResidenceTransport };
15
+ export type { ResidenceTransportOptions };
@@ -0,0 +1 @@
1
+ export { createResidenceTransport } from '../../chunk-V4EMDPCO.js';
@@ -0,0 +1,9 @@
1
+ import { PersistenceAdapter } from '@almadar/core';
2
+
3
+ /**
4
+ * One persistence over two stores: `stored` entities (a program's browser-stored ones) go to `stored`, every other entity to
5
+ * `other`. The kernel reads and writes every entity through one adapter; a batch is one store's transaction, so it stays in one.
6
+ */
7
+ declare function routeByEntity(storedEntities: ReadonlySet<string>, stored: PersistenceAdapter, other: PersistenceAdapter): PersistenceAdapter;
8
+
9
+ export { routeByEntity };