@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.
- package/dist/chunk-4SEK5ER2.js +8 -0
- package/dist/chunk-57SBCUSM.js +62 -0
- package/dist/chunk-625EP7W2.js +108 -0
- package/dist/chunk-64IH2SMY.js +22 -0
- package/dist/chunk-7SDV3QWR.js +67 -0
- package/dist/chunk-7WB6VWRK.js +798 -0
- package/dist/chunk-A2JJT4GA.js +56 -0
- package/dist/chunk-BAS26HBN.js +10 -0
- package/dist/chunk-BOVU4TCQ.js +65 -0
- package/dist/chunk-BY5G4225.js +6 -0
- package/dist/chunk-DFDNHVDW.js +284 -0
- package/dist/chunk-ELBLT2HZ.js +1 -0
- package/dist/chunk-EZZYLTWY.js +1 -0
- package/dist/chunk-FWA5K7Q2.js +48 -0
- package/dist/chunk-HC6ERSAH.js +55 -0
- package/dist/chunk-HLOUDLPI.js +48 -0
- package/dist/chunk-I3TKINSO.js +398 -0
- package/dist/chunk-IOPUS6Q5.js +15 -0
- package/dist/chunk-LKWYCYX5.js +22 -0
- package/dist/chunk-LYFIQPXX.js +1 -0
- package/dist/chunk-LZIOTBFX.js +1 -0
- package/dist/chunk-MU335ZA4.js +63 -0
- package/dist/chunk-MZKIL5IN.js +74 -0
- package/dist/chunk-N7HYNKK6.js +83 -0
- package/dist/chunk-NTFQ36UN.js +52 -0
- package/dist/chunk-NU6LVKGS.js +15 -0
- package/dist/chunk-O57GKTYU.js +30 -0
- package/dist/chunk-P2N6K2IV.js +20 -0
- package/dist/chunk-P53CKOME.js +1 -0
- package/dist/chunk-QCJWPXLH.js +40 -0
- package/dist/chunk-SKLMWHQD.js +109 -0
- package/dist/chunk-SOQDEPME.js +131 -0
- package/dist/chunk-UBN5JJKZ.js +26 -0
- package/dist/chunk-UD2CXYSJ.js +244 -0
- package/dist/chunk-UP6GGGAN.js +34 -0
- package/dist/chunk-V4EMDPCO.js +33 -0
- package/dist/chunk-VNGXRYFF.js +9 -0
- package/dist/chunk-WGCWJOT2.js +21 -0
- package/dist/chunk-X6W44WHO.js +26 -0
- package/dist/chunk-XXWNMJI6.js +15 -0
- package/dist/chunk-ZUSM4VW4.js +197 -0
- package/dist/client/EventTransport.d.ts +147 -0
- package/dist/client/EventTransport.js +1 -0
- package/dist/client/awaiting.d.ts +28 -0
- package/dist/client/awaiting.js +1 -0
- package/dist/client/channel-transport.d.ts +69 -0
- package/dist/client/channel-transport.js +1 -0
- package/dist/client/circuit-store.d.ts +87 -0
- package/dist/client/circuit-store.js +3 -0
- package/dist/client/client-kernel.d.ts +134 -0
- package/dist/client/client-kernel.js +1 -0
- package/dist/client/declared-input-dispatch.d.ts +22 -0
- package/dist/client/declared-input-dispatch.js +1 -0
- package/dist/client/inbound-dispatch.d.ts +24 -0
- package/dist/client/inbound-dispatch.js +1 -0
- package/dist/client/local-fold.d.ts +33 -0
- package/dist/client/local-fold.js +1 -0
- package/dist/client/render-sigils.d.ts +24 -0
- package/dist/client/render-sigils.js +1 -0
- package/dist/client/state-book.d.ts +30 -0
- package/dist/client/state-book.js +1 -0
- package/dist/client/trait-mount-error.d.ts +9 -0
- package/dist/client/trait-mount-error.js +1 -0
- package/dist/client/trait-types.d.ts +67 -0
- package/dist/client/trait-types.js +1 -0
- package/dist/credentials/env-vars.d.ts +18 -0
- package/dist/credentials/env-vars.js +1 -0
- package/dist/credentials/scope.d.ts +51 -0
- package/dist/credentials/scope.js +1 -0
- package/dist/credentials/vault.d.ts +142 -0
- package/dist/credentials/vault.js +1 -0
- package/dist/effects/in-flight-calls.d.ts +36 -0
- package/dist/effects/in-flight-calls.js +1 -0
- package/dist/effects/on-device-model.d.ts +22 -0
- package/dist/effects/on-device-model.js +1 -0
- package/dist/events/EventBus.d.ts +87 -0
- package/dist/events/EventBus.js +1 -0
- package/dist/events/emit-stamp.d.ts +47 -0
- package/dist/events/emit-stamp.js +1 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +41 -0
- package/dist/kernel/decode.d.ts +13 -0
- package/dist/kernel/decode.js +1 -0
- package/dist/kernel/engine.d.ts +195 -0
- package/dist/kernel/engine.js +9 -0
- package/dist/kernel/frame-applier.d.ts +44 -0
- package/dist/kernel/frame-applier.js +1 -0
- package/dist/kernel/host.d.ts +206 -0
- package/dist/kernel/host.js +6 -0
- package/dist/kernel/lane.d.ts +7 -0
- package/dist/kernel/lane.js +1 -0
- package/dist/kernel/os-fetch-port.d.ts +7 -0
- package/dist/kernel/os-fetch-port.js +3 -0
- package/dist/kernel/os-port.d.ts +155 -0
- package/dist/kernel/os-port.js +1 -0
- package/dist/kernel/program-effects.d.ts +48 -0
- package/dist/kernel/program-effects.js +1 -0
- package/dist/kernel/secret-ports.d.ts +139 -0
- package/dist/kernel/secret-ports.js +2 -0
- package/dist/kernel/wire.d.ts +104 -0
- package/dist/kernel/wire.js +1 -0
- package/dist/loader/fetch-loader.d.ts +26 -0
- package/dist/loader/fetch-loader.js +1 -0
- package/dist/loader/lazy-page.d.ts +12 -0
- package/dist/loader/lazy-page.js +1 -0
- package/dist/loader/schema-loader.d.ts +144 -0
- package/dist/loader/schema-loader.js +1 -0
- package/dist/persistence/native-memory.d.ts +28 -0
- package/dist/persistence/native-memory.js +1 -0
- package/dist/runtime/entities/declaredCollections.d.ts +6 -0
- package/dist/runtime/entities/declaredCollections.js +1 -0
- package/dist/runtime/evaluation/local-store-transport.d.ts +59 -0
- package/dist/runtime/evaluation/local-store-transport.js +14 -0
- package/dist/runtime/evaluation/residence-transport.d.ts +15 -0
- package/dist/runtime/evaluation/residence-transport.js +1 -0
- package/dist/runtime/evaluation/routed-persistence.d.ts +9 -0
- package/dist/runtime/evaluation/routed-persistence.js +1 -0
- package/dist/runtime/events/identity/routing.d.ts +33 -0
- package/dist/runtime/events/identity/routing.js +1 -0
- package/dist/runtime/types.d.ts +374 -0
- package/dist/runtime/types.js +1 -0
- package/dist/service/default-call-service.d.ts +23 -0
- package/dist/service/default-call-service.js +2 -0
- package/dist/service/service-provider.d.ts +37 -0
- package/dist/service/service-provider.js +1 -0
- package/package.json +49 -3
- package/README.md +0 -3
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { AwaitingRegistry } from './awaiting.js';
|
|
2
|
+
import { StateBook } from './state-book.js';
|
|
3
|
+
import { EntityRow, TraitDefinition } from '@almadar/core';
|
|
4
|
+
import { FrameDelta } from '@almadar/core/kernel-wire';
|
|
5
|
+
import { RollbackCause, TransitionObserver } from './trait-types.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* CircuitStore — P2, `docs/Almadar_Runtime_Stateless_Stateful_PLAN.md` §4.2.
|
|
9
|
+
*
|
|
10
|
+
* The browser client's circuit state: each trait's state and entity frame as the kernel last reported them.
|
|
11
|
+
*
|
|
12
|
+
* `snapshot`/`restore` are the JS twin of orbital-core's
|
|
13
|
+
* `RuntimeKernel::snapshot_trait`/`restore_trait` (`runtime/kernel.rs`) — the
|
|
14
|
+
* `runtimeOptimistic` rollback point. `subscribe`/`getVersion` let a later
|
|
15
|
+
* React adapter drive `useSyncExternalStore` off this store without the
|
|
16
|
+
* store knowing anything about React.
|
|
17
|
+
*
|
|
18
|
+
* @packageDocumentation
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A trait instance's state + entity frame at a point in time — the twin of
|
|
23
|
+
* orbital-core's `TraitSnapshot { state, entity }`. `frame` is `undefined`
|
|
24
|
+
* when the trait had no frame row yet (mirrors Rust's `Value::Null` case:
|
|
25
|
+
* restoring must leave the row absent, not invent one).
|
|
26
|
+
*/
|
|
27
|
+
interface TraitSnapshot {
|
|
28
|
+
state: string;
|
|
29
|
+
frame: EntityRow | undefined;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* What a frame delta did to the store: `applied`; `stale` (its version is behind the one painted: dropped, so an
|
|
33
|
+
* old repaint never overwrites a newer value); `gap` (it starts past the painted version: nothing applied, the
|
|
34
|
+
* caller asks the kernel for `framesSince(frameVersion)` and applies the snapshot).
|
|
35
|
+
*/
|
|
36
|
+
type FrameOutcome = 'applied' | 'stale' | 'gap';
|
|
37
|
+
interface CircuitStore {
|
|
38
|
+
/** Each trait's state as the kernel last reported it. */
|
|
39
|
+
readonly states: StateBook;
|
|
40
|
+
/** The entity-frame map (`(set @entity.X)` writes), keyed by
|
|
41
|
+
* `IndexedTrait.frameKey`. */
|
|
42
|
+
readonly frames: Map<string, EntityRow>;
|
|
43
|
+
/** The version of the kernel's frame record this store has painted. */
|
|
44
|
+
readonly frameVersion: number;
|
|
45
|
+
/**
|
|
46
|
+
* Paint the kernel's frame delta (EXEC-DIST-7): ops land only at the version they start from, and a snapshot
|
|
47
|
+
* (`from` 0 with a leading `clear`) always lands. The store merges nothing by its own rules.
|
|
48
|
+
*/
|
|
49
|
+
applyFrames(delta: FrameDelta): FrameOutcome;
|
|
50
|
+
/** Traits awaiting a server round trip (per-trait subscriptions; see `AwaitingRegistry`). */
|
|
51
|
+
readonly awaiting: AwaitingRegistry;
|
|
52
|
+
/**
|
|
53
|
+
* Capture `trait`'s current state + its frame row, for a
|
|
54
|
+
* `runtimeOptimistic` dispatch's pre-commit rollback point. `frameKey`
|
|
55
|
+
* defaults to `trait` (the non-`[shared]`-entity case); a caller holding
|
|
56
|
+
* the trait's `IndexedTrait.frameKey` (the `[shared]` case) passes it
|
|
57
|
+
* explicitly so the snapshot reads the SAME row the dispatch will write.
|
|
58
|
+
*/
|
|
59
|
+
snapshot(trait: string, entityId?: string, frameKey?: string): TraitSnapshot;
|
|
60
|
+
/**
|
|
61
|
+
* Roll `trait` back to a prior snapshot: state via a reconcile write (no
|
|
62
|
+
* guard evaluation — `rollbackState`, which reports the hop to the observer), frame via REPLACE (never merge — an
|
|
63
|
+
* optimistic commit may have added fields since the snapshot that a merge
|
|
64
|
+
* would keep, the same reasoning as `RuntimeKernel::restore_trait`).
|
|
65
|
+
*/
|
|
66
|
+
restore(trait: string, entityId: string | undefined, snapshot: TraitSnapshot, frameKey: string | undefined, cause: RollbackCause): void;
|
|
67
|
+
/**
|
|
68
|
+
* Notify subscribers that circuit state changed. Callers (the client
|
|
69
|
+
* role, `client-role.ts`) call this ONCE after a dispatch/fold finishes
|
|
70
|
+
* writing state — the store never fires this on its own.
|
|
71
|
+
*/
|
|
72
|
+
notify(): void;
|
|
73
|
+
/** `useSyncExternalStore`-shaped subscription. Returns the unsubscribe fn. */
|
|
74
|
+
subscribe(listener: () => void): () => void;
|
|
75
|
+
/** Monotonic version, bumped by every `notify()` call. */
|
|
76
|
+
getVersion(): number;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The one in-memory `CircuitStore` implementation. Per-request (stateless
|
|
80
|
+
* server) or long-lived (stateful server, browser client) is only a
|
|
81
|
+
* question of how long the caller HOLDS the returned store — the
|
|
82
|
+
* implementation itself carries no lifetime opinion.
|
|
83
|
+
*/
|
|
84
|
+
declare function createMemoryCircuitStore(traits?: readonly TraitDefinition[], observer?: TransitionObserver): CircuitStore;
|
|
85
|
+
|
|
86
|
+
export { createMemoryCircuitStore };
|
|
87
|
+
export type { CircuitStore, FrameOutcome, TraitSnapshot };
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { EventResponse, EventRequest, DispatchMode, EmittedEvent, MountSeed, TransitionRejection } from '@almadar/core';
|
|
2
|
+
import { CircuitStore } from './circuit-store.js';
|
|
3
|
+
import './awaiting.js';
|
|
4
|
+
import './state-book.js';
|
|
5
|
+
import './trait-types.js';
|
|
6
|
+
import '@almadar/core/kernel-wire';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The contract of a client kernel: what a view dispatches into and what it gets back. `@almadar/ui`'s kernel client
|
|
10
|
+
* (over `@almadar/kernel/client`) implements it.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** One `ClientKernel.dispatch()` call's settled outcome. */
|
|
14
|
+
interface ClientKernelOutcome {
|
|
15
|
+
response: EventResponse;
|
|
16
|
+
mode: DispatchMode;
|
|
17
|
+
/**
|
|
18
|
+
* True when `onLocal` already received the local arm's response (the leg
|
|
19
|
+
* was posted). `serverEffects` then holds only what the server's fold
|
|
20
|
+
* added — the local ones were painted before the round trip.
|
|
21
|
+
*/
|
|
22
|
+
localPainted?: boolean;
|
|
23
|
+
serverEffects?: Pick<EventResponse, 'clientEffectsByTrait'>;
|
|
24
|
+
/**
|
|
25
|
+
* A tick-lane dispatch: what its post's fold added on top of the local run,
|
|
26
|
+
* once the post settles (undefined when a newer firing superseded it). The
|
|
27
|
+
* drain never waits on it; the caller paints it when it lands.
|
|
28
|
+
*/
|
|
29
|
+
tickSettled?: Promise<Pick<EventResponse, 'clientEffectsByTrait'> | undefined>;
|
|
30
|
+
}
|
|
31
|
+
/** Per-dispatch hooks: `onLocal` sees the locally-evaluated response before its server leg is sent. */
|
|
32
|
+
interface ClientDispatchHooks {
|
|
33
|
+
onLocal?: (local: EventResponse) => void;
|
|
34
|
+
}
|
|
35
|
+
/** Mount hooks: `onLocal` sees each seed's local response before the mount leg is sent. */
|
|
36
|
+
interface ClientMountHooks {
|
|
37
|
+
onLocal?: (trait: string, local: EventResponse) => void;
|
|
38
|
+
}
|
|
39
|
+
/** What the kernel answered to an emit that entered from outside it: the cascade it ran, with its paint and its emits. */
|
|
40
|
+
interface ClientEmitOutcome {
|
|
41
|
+
response: EventResponse;
|
|
42
|
+
}
|
|
43
|
+
/** One `ClientKernel.dispatchMount()` call's settled outcome. */
|
|
44
|
+
interface ClientMountOutcome {
|
|
45
|
+
/** Each seed's local run, in seed order (already painted through `onLocal`). */
|
|
46
|
+
seeds: Array<{
|
|
47
|
+
trait: string;
|
|
48
|
+
event: string;
|
|
49
|
+
mode: DispatchMode;
|
|
50
|
+
local: EventResponse;
|
|
51
|
+
}>;
|
|
52
|
+
/** Whether any mount leg was posted. */
|
|
53
|
+
posted: boolean;
|
|
54
|
+
success: boolean;
|
|
55
|
+
error?: string;
|
|
56
|
+
/** Per-trait effect failures the posted legs reported (`effect-failed`). */
|
|
57
|
+
rejections: TransitionRejection[];
|
|
58
|
+
/** What the posted legs added: the server's effects and the emits the client had not run. */
|
|
59
|
+
serverEffects: Pick<EventResponse, 'clientEffectsByTrait'>;
|
|
60
|
+
emittedEvents: EventResponse['emittedEvents'];
|
|
61
|
+
}
|
|
62
|
+
interface ClientKernel {
|
|
63
|
+
/**
|
|
64
|
+
* Enqueue one event. FIFO per kernel: this entry's local dispatch → post
|
|
65
|
+
* (per the posting rule) → fold → `store.notify()` all complete before the
|
|
66
|
+
* next queued entry's local dispatch begins — the twin of orbital-client's
|
|
67
|
+
* `ClientKernel::dispatch` being called serially off one queue, ported to
|
|
68
|
+
* JS's single-threaded-but-concurrent-microtask model where two `dispatch`
|
|
69
|
+
* calls made back to back would otherwise interleave.
|
|
70
|
+
*
|
|
71
|
+
* A `request.tick`-stamped entry coalesces onto a pending entry with the
|
|
72
|
+
* SAME `(event, targetTrait)` that is itself tick-stamped — same contract
|
|
73
|
+
* as `@almadar/ui`'s `lib/event-queue-coalesce.ts` `enqueueEvent` (see
|
|
74
|
+
* that file's tests, mirrored in `client-kernel.test.ts`): only the
|
|
75
|
+
* pending entry's `payload` is replaced (its FIFO slot and every other
|
|
76
|
+
* field are kept), a sourceless/non-tick entry is never coalesced, and an
|
|
77
|
+
* entry already shifted off the queue (in flight) is never a coalesce
|
|
78
|
+
* target. Every caller coalesced onto the same pending entry resolves to
|
|
79
|
+
* that ONE entry's eventual outcome.
|
|
80
|
+
*
|
|
81
|
+
* A tick-stamped entry resolves after its LOCAL dispatch; its post goes
|
|
82
|
+
* out on a per-(event, trait) newest-wins lane outside the FIFO, with no
|
|
83
|
+
* rollback, so a tick round trip never delays a command.
|
|
84
|
+
*/
|
|
85
|
+
dispatch(request: EventRequest, hooks?: ClientDispatchHooks): Promise<ClientKernelOutcome>;
|
|
86
|
+
/**
|
|
87
|
+
* Dispatch a server-pushed live message of THIS client's own running
|
|
88
|
+
* request (`PushTarget` `origin`). Outside the FIFO, because the request
|
|
89
|
+
* producing it is the entry the FIFO is waiting on; progress dispatches run
|
|
90
|
+
* one at a time, in push order, and never mark traits awaiting.
|
|
91
|
+
*/
|
|
92
|
+
dispatchProgress(request: EventRequest): Promise<ClientKernelOutcome>;
|
|
93
|
+
/**
|
|
94
|
+
* Show the result of a dispatch the host ran on its own (`EventTransport.subscribeHostDispatches`):
|
|
95
|
+
* the host's states, rows and render land in this view. Nothing runs here and nothing is posted,
|
|
96
|
+
* so the dispatch's effects happen once, on the host. Host dispatches fold one at a time, in order.
|
|
97
|
+
*/
|
|
98
|
+
foldHostDispatch(request: EventRequest, response: EventResponse): Promise<ClientKernelOutcome>;
|
|
99
|
+
/**
|
|
100
|
+
* Hand the kernel an emit that happened outside it (a bus emit with no dispatch behind it, a server push). The kernel
|
|
101
|
+
* decides who hears it: the emitter's own arm and every declared `listens` route (EXEC-DISP). Nothing is routed here.
|
|
102
|
+
*/
|
|
103
|
+
deliverEmit(emitted: EmittedEvent): Promise<ClientEmitOutcome>;
|
|
104
|
+
/**
|
|
105
|
+
* Hand the kernel an emit another client made (a server push): it reaches its declared `listens` routes only, guards and
|
|
106
|
+
* payload mapping included. The emitter's own arm does not run here, and neither the emit's `dispatched` stamp nor the
|
|
107
|
+
* host's fan-out narrows who hears it.
|
|
108
|
+
*/
|
|
109
|
+
deliverToListeners(emitted: EmittedEvent): Promise<ClientEmitOutcome>;
|
|
110
|
+
/**
|
|
111
|
+
* Hand the kernel the live message of this client's own running call, whose emitter already ran its own arm as that call's
|
|
112
|
+
* progress dispatch: it reaches its declared `listens` routes like `deliverToListeners`, except that a route back to the
|
|
113
|
+
* emitter under the emitted name is that arm again and does not run twice.
|
|
114
|
+
*/
|
|
115
|
+
deliverOriginEmit(emitted: EmittedEvent): Promise<ClientEmitOutcome>;
|
|
116
|
+
/**
|
|
117
|
+
* Mount several traits in ONE FIFO entry: every seed's local arm runs and
|
|
118
|
+
* paints, then one `mount` leg per owning orbital is posted and folded.
|
|
119
|
+
*/
|
|
120
|
+
dispatchMount(seeds: readonly MountSeed[], hooks?: ClientMountHooks, base?: Pick<EventRequest, 'payload' | 'entityId' | 'clientId' | 'locale' | 'route'>): Promise<ClientMountOutcome>;
|
|
121
|
+
readonly store: CircuitStore;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Show the result of a dispatch THIS kernel already ran (a tick frame's aggregate response or one of its
|
|
125
|
+
* cascade dispatches): the response's states, rows and paint land in the view's store. Nothing runs and
|
|
126
|
+
* nothing is posted: the in-process kernel owns the state, so (unlike `foldHostDispatch`) the server fold
|
|
127
|
+
* (`applyServerResponse`) is never called. `traceHops` reports the response's executed hops to the transition
|
|
128
|
+
* observer; a frame's aggregate response carries tick hops the kernel's tick observer already reported. `notify` wakes the store's subscribers after the fold; a frame folds several responses and notifies on the last only.
|
|
129
|
+
*/
|
|
130
|
+
interface LocalFoldKernel {
|
|
131
|
+
foldLocalResponse(response: EventResponse, traceHops: boolean, notify: boolean): Promise<void>;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export type { ClientDispatchHooks, ClientEmitOutcome, ClientKernel, ClientKernelOutcome, ClientMountHooks, ClientMountOutcome, LocalFoldKernel };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../chunk-LZIOTBFX.js';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ExternalInputRequest, EventRequest, EventResponse } from '@almadar/core';
|
|
2
|
+
import { KernelEngine } from '../kernel/engine.js';
|
|
3
|
+
import '@almadar/core/kernel-wire';
|
|
4
|
+
import '../kernel/host.js';
|
|
5
|
+
import '../effects/in-flight-calls.js';
|
|
6
|
+
import '../service/service-provider.js';
|
|
7
|
+
import '../kernel/program-effects.js';
|
|
8
|
+
import '../kernel/secret-ports.js';
|
|
9
|
+
import '../credentials/vault.js';
|
|
10
|
+
import '../kernel/wire.js';
|
|
11
|
+
import '../kernel/os-port.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The dispatcher for declared external inputs. The server runtime and the in-process host (a
|
|
15
|
+
* browser extension's worker) both route outside-client inputs through it: the kernel says whether the
|
|
16
|
+
* input is declared, an undeclared one is refused identically everywhere and a declared one is an ordinary
|
|
17
|
+
* event addressed to its trait.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
declare function dispatchDeclaredInput(contract: Pick<KernelEngine, 'findExternalInput'>, orbitalName: string, request: ExternalInputRequest, send: (orbitalName: string, request: EventRequest) => Promise<EventResponse>): Promise<EventResponse>;
|
|
21
|
+
|
|
22
|
+
export { dispatchDeclaredInput };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { dispatchDeclaredInput } from '../chunk-LKWYCYX5.js';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { InboundDelivery, EventRequest, EventResponse, InboundAnswer } from '@almadar/core';
|
|
2
|
+
import { KernelEngine } from '../kernel/engine.js';
|
|
3
|
+
import '@almadar/core/kernel-wire';
|
|
4
|
+
import '../kernel/host.js';
|
|
5
|
+
import '../effects/in-flight-calls.js';
|
|
6
|
+
import '../service/service-provider.js';
|
|
7
|
+
import '../kernel/program-effects.js';
|
|
8
|
+
import '../kernel/secret-ports.js';
|
|
9
|
+
import '../credentials/vault.js';
|
|
10
|
+
import '../kernel/wire.js';
|
|
11
|
+
import '../kernel/os-port.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The dispatcher for inbound deliveries (EXEC-INBOUND-1). A host carries `{name, headers,
|
|
15
|
+
* rawBody}` from `/api/hooks/<name>`; the kernel decides whether the name is served, what payload the
|
|
16
|
+
* handler event is delivered with and what answer the handler's emit of its `answers` event is; this
|
|
17
|
+
* delivers the event through the host's own dispatch and writes what the kernel said.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
type InboundContract = Pick<KernelEngine, 'findInbound' | 'inboundPayload' | 'inboundAnswer' | 'credentialUnset' | 'dispatchFailed'>;
|
|
21
|
+
declare function dispatchInbound(contract: InboundContract, name: string, delivery: InboundDelivery, send: (orbitalName: string, request: EventRequest) => Promise<EventResponse>, credential: (name: string) => Promise<string | null | undefined>): Promise<InboundAnswer>;
|
|
22
|
+
|
|
23
|
+
export { dispatchInbound };
|
|
24
|
+
export type { InboundContract };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { dispatchInbound } from '../chunk-P2N6K2IV.js';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { EventResponse } from '@almadar/core';
|
|
2
|
+
import { FrameDelta } from '@almadar/core/kernel-wire';
|
|
3
|
+
import { LocalFoldKernel } from './client-kernel.js';
|
|
4
|
+
import { CircuitStore } from './circuit-store.js';
|
|
5
|
+
import { TransitionObserver } from './trait-types.js';
|
|
6
|
+
import './awaiting.js';
|
|
7
|
+
import './state-book.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The view's side of a dispatch the in-process kernel already ran: report its executed hops to the observer,
|
|
11
|
+
* paint its states, frame delta and sticky callsite payloads into the `CircuitStore`, then notify subscribers.
|
|
12
|
+
* One implementation for every response the kernel produces (a dispatch, a mount seed, a posted leg's fold,
|
|
13
|
+
* a tick frame).
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** A snapshot of the kernel's frames for a painter at `since` (the kernel's `framesSince`). */
|
|
17
|
+
type FramesSince = (since: number) => FrameDelta;
|
|
18
|
+
/** Paint a response's states. Rows are the kernel's frame delta, painted by [`paintFrames`]. */
|
|
19
|
+
declare function paintStates(store: CircuitStore, response: EventResponse): void;
|
|
20
|
+
/** Paint the kernel's frame delta; on a version gap, ask the kernel for the snapshot and paint that. */
|
|
21
|
+
declare function paintFrames(store: CircuitStore, delta: FrameDelta | undefined, framesSince: FramesSince): void;
|
|
22
|
+
/** Paint a response the in-process kernel produced: its states, payloads and frames. */
|
|
23
|
+
declare function paintResponse(store: CircuitStore, framesSince: FramesSince, response: EventResponse): void;
|
|
24
|
+
declare function traceResponse(observer: TransitionObserver | undefined, response: EventResponse): void;
|
|
25
|
+
interface LocalFoldOptions {
|
|
26
|
+
store: CircuitStore;
|
|
27
|
+
framesSince: FramesSince;
|
|
28
|
+
observer?: TransitionObserver;
|
|
29
|
+
}
|
|
30
|
+
declare function createLocalFold(opts: LocalFoldOptions): LocalFoldKernel;
|
|
31
|
+
|
|
32
|
+
export { createLocalFold, paintFrames, paintResponse, paintStates, traceResponse };
|
|
33
|
+
export type { FramesSince, LocalFoldOptions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createLocalFold, paintFrames, paintResponse, paintStates, traceResponse } from '../chunk-QCJWPXLH.js';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { OrbitalDefinition, NavItem, PageRef } from '@almadar/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The render sigils `@pages` and `@currentTheme`, assembled one way for every effect
|
|
5
|
+
* stage (the server's and the index runner's). Mirrors the compiler's resolver.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** The baseline theme `@currentTheme` falls back to when no orbital or app theme is declared. Mirrors the compiler's `DEFAULT_THEME_KEY`. */
|
|
11
|
+
declare const DEFAULT_THEME_KEY = "minimalist-light";
|
|
12
|
+
/**
|
|
13
|
+
* Map an orbital's inline pages to the `NavItem[]` the `@pages` sigil yields: one
|
|
14
|
+
* entry per root page that declares `@label` (`href = page.path`, its `@icon` and
|
|
15
|
+
* `@roles`). References (resolved before any stage runs) and `:param` pages are
|
|
16
|
+
* skipped — the Rust resolver's filter.
|
|
17
|
+
*/
|
|
18
|
+
declare function inlineNavItems(pages: readonly PageRef[]): NavItem[];
|
|
19
|
+
/** `@pages` is app-wide: the root pages of every orbital, deduped by path, in orbital order. */
|
|
20
|
+
declare function appNavItems(orbitals: Iterable<Pick<OrbitalDefinition, 'pages'>>): NavItem[];
|
|
21
|
+
/** `@currentTheme`: the orbital's declared theme, else the app's theme key, else the baseline. */
|
|
22
|
+
declare function sigilThemeKey(orbitalTheme: OrbitalDefinition['theme'], appThemeKey?: string): string;
|
|
23
|
+
|
|
24
|
+
export { DEFAULT_THEME_KEY, appNavItems, inlineNavItems, sigilThemeKey };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DEFAULT_THEME_KEY, appNavItems, inlineNavItems, sigilThemeKey } from '../chunk-UP6GGGAN.js';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { TraitDefinition } from '@almadar/core';
|
|
2
|
+
import { TransitionObserver, TraitState, RollbackCause } from './trait-types.js';
|
|
3
|
+
import '@almadar/core/kernel-wire';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The client's record of each trait's state, as the kernel reports it. The kernel decides every transition;
|
|
7
|
+
* this book only holds the states its responses carry, so a render can read them synchronously.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** The state a trait starts in: the one marked initial, else the first declared. */
|
|
13
|
+
declare function findInitialState(trait: TraitDefinition): string;
|
|
14
|
+
declare function createInitialTraitState(trait: TraitDefinition): TraitState;
|
|
15
|
+
declare class StateBook {
|
|
16
|
+
private readonly observer?;
|
|
17
|
+
private readonly traits;
|
|
18
|
+
private readonly states;
|
|
19
|
+
constructor(traits?: readonly TraitDefinition[], observer?: TransitionObserver | undefined);
|
|
20
|
+
/** The trait's state, its initial state until the kernel reports one; `undefined` for a trait not on the page. */
|
|
21
|
+
getState(traitName: string, entityId?: string): TraitState | undefined;
|
|
22
|
+
/** Each trait's singleton-scope state. */
|
|
23
|
+
getAllStates(): Map<string, TraitState>;
|
|
24
|
+
/** Record the state the kernel reports. No-op for a trait not on the page. */
|
|
25
|
+
seedState(traitName: string, currentState: string, entityId?: string): void;
|
|
26
|
+
/** Undo an optimistic commit, reporting the hop back to the observer. */
|
|
27
|
+
rollbackState(traitName: string, toState: string, entityId: string | undefined, cause: RollbackCause): void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { StateBook, createInitialTraitState, findInitialState };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { StateBook, createInitialTraitState, findInitialState } from '../chunk-A2JJT4GA.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** A mount seed's lifecycle dispatch threw: names that trait and event, the original error's message kept. */
|
|
2
|
+
declare class TraitMountError extends Error {
|
|
3
|
+
readonly trait: string;
|
|
4
|
+
readonly event: string;
|
|
5
|
+
readonly original: Error;
|
|
6
|
+
constructor(trait: string, event: string, original: Error);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { TraitMountError };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TraitMountError } from '../chunk-IOPUS6Q5.js';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { SExpr, TraitConfig } from '@almadar/core';
|
|
2
|
+
import { HopObservation } from '@almadar/core/kernel-wire';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The client host's view of a trait: its running state, its flat definition, and the observer a
|
|
6
|
+
* verifier hangs on committed hops. Client-host types, not language contract.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* State of a single trait's state machine
|
|
11
|
+
*/
|
|
12
|
+
interface TraitState {
|
|
13
|
+
/** Trait name */
|
|
14
|
+
traitName: string;
|
|
15
|
+
/** Current state name */
|
|
16
|
+
currentState: string;
|
|
17
|
+
/** Previous state (null if initial) */
|
|
18
|
+
previousState: string | null;
|
|
19
|
+
/** Last event that caused a transition */
|
|
20
|
+
lastEvent: string | null;
|
|
21
|
+
/** Custom context data */
|
|
22
|
+
context: TraitConfig;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Observer interface for recording transition and effect traces.
|
|
26
|
+
* Implement this to wire in the verificationRegistry or other monitoring tools.
|
|
27
|
+
*
|
|
28
|
+
* The runtime calls these hooks automatically when transitions execute and
|
|
29
|
+
* effects complete, enabling runtime verification without tight coupling.
|
|
30
|
+
*/
|
|
31
|
+
interface TransitionObserver {
|
|
32
|
+
/**
|
|
33
|
+
* Called after a transition is processed (whether or not it executed).
|
|
34
|
+
*/
|
|
35
|
+
onTransition(trace: {
|
|
36
|
+
traitName: string;
|
|
37
|
+
from: string;
|
|
38
|
+
to: string;
|
|
39
|
+
event: string;
|
|
40
|
+
/** The arm that fired, by its position among the state's arms for the event. */
|
|
41
|
+
firedArm?: number;
|
|
42
|
+
guardResult?: boolean;
|
|
43
|
+
effects: Array<{
|
|
44
|
+
type: string;
|
|
45
|
+
args: SExpr[];
|
|
46
|
+
status: "executed" | "failed" | "skipped";
|
|
47
|
+
error?: string;
|
|
48
|
+
durationMs?: number;
|
|
49
|
+
}>;
|
|
50
|
+
/** Recorded for a verifier only (`setRecordEntityAfter`): the payload and `@entity` before and after. */
|
|
51
|
+
observed?: HopObservation;
|
|
52
|
+
}): void;
|
|
53
|
+
/**
|
|
54
|
+
* Called when an optimistic dispatch is undone: the state moved back from
|
|
55
|
+
* `from` to `to` because the server rejected the leg or never answered.
|
|
56
|
+
*/
|
|
57
|
+
onRollback?(trace: {
|
|
58
|
+
traitName: string;
|
|
59
|
+
from: string;
|
|
60
|
+
to: string;
|
|
61
|
+
cause: RollbackCause;
|
|
62
|
+
}): void;
|
|
63
|
+
}
|
|
64
|
+
/** Why an optimistic dispatch was rolled back. */
|
|
65
|
+
type RollbackCause = 'transport-error' | 'server-rejected';
|
|
66
|
+
|
|
67
|
+
export type { RollbackCause, TraitState, TransitionObserver };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../chunk-P53CKOME.js';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Env var holding the 64-char-hex AES-256 master key (Secret Manager in production). */
|
|
2
|
+
declare const CREDENTIAL_MASTER_KEY_ENV = "ALMADAR_CREDENTIAL_MASTER_KEY";
|
|
3
|
+
/** Env var holding the PREVIOUS master key during a rotation window: `rotate` re-encrypts every row under the current key, then the previous key is retired. */
|
|
4
|
+
declare const CREDENTIAL_PREVIOUS_MASTER_KEY_ENV = "ALMADAR_CREDENTIAL_MASTER_KEY_PREVIOUS";
|
|
5
|
+
/**
|
|
6
|
+
* Bootstrap secrets that must NEVER enter store custody: the master key(s)
|
|
7
|
+
* decrypt the store itself, so seeding them as rows (encrypted under
|
|
8
|
+
* themselves) or stripping them from the env would be circular.
|
|
9
|
+
*/
|
|
10
|
+
declare const STORE_BOOTSTRAP_ENV_VARS: ReadonlySet<string>;
|
|
11
|
+
/**
|
|
12
|
+
* Every env var a forked verify/harness process must not inherit so it can never see, and therefore
|
|
13
|
+
* never spend, a real credential: the store's bootstrap keys. A program's own credentials are declared
|
|
14
|
+
* in the program (`program_credentials` in the kernel) and held in the store, never in the fork's env.
|
|
15
|
+
*/
|
|
16
|
+
declare function allCredentialEnvVars(): Set<string>;
|
|
17
|
+
|
|
18
|
+
export { CREDENTIAL_MASTER_KEY_ENV, CREDENTIAL_PREVIOUS_MASTER_KEY_ENV, STORE_BOOTSTRAP_ENV_VARS, allCredentialEnvVars };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CREDENTIAL_MASTER_KEY_ENV, CREDENTIAL_PREVIOUS_MASTER_KEY_ENV, STORE_BOOTSTRAP_ENV_VARS, allCredentialEnvVars } from '../chunk-VNGXRYFF.js';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { CredentialVault } from './vault.js';
|
|
2
|
+
import '@almadar/core';
|
|
3
|
+
import '@almadar/core/kernel-wire';
|
|
4
|
+
|
|
5
|
+
/** Whether integrations answer with mock data or call their real backends. */
|
|
6
|
+
type CredentialMode = 'mock' | 'real';
|
|
7
|
+
/** The mode an env asks for: `ALMADAR_INTEGRATIONS_MODE=mock` or `USE_MOCK_DATA=true` mean mock. */
|
|
8
|
+
declare function credentialModeFromEnv(env: Record<string, string | undefined>): CredentialMode;
|
|
9
|
+
/** The host's live mode switch, reachable from the kernel's `credential-mode` asks. */
|
|
10
|
+
interface CredentialModeControl {
|
|
11
|
+
readonly mode: CredentialMode;
|
|
12
|
+
setMode(mode: CredentialMode): void;
|
|
13
|
+
}
|
|
14
|
+
/** The per-tenant credential scope: a Node host installs AsyncLocalStorage (`@almadar/shell-node`); a browser has none. */
|
|
15
|
+
interface CredentialScopeStorage {
|
|
16
|
+
run<T>(store: CredentialVault, fn: () => T): T;
|
|
17
|
+
getStore(): CredentialVault | undefined;
|
|
18
|
+
}
|
|
19
|
+
declare function installCredentialScopeStorage(storage: CredentialScopeStorage): void;
|
|
20
|
+
/**
|
|
21
|
+
* Run `fn` as one tenant of a multi-tenant host: every credential reference resolved inside it
|
|
22
|
+
* (across awaits) comes from `store` alone, never from the host's env or installed store.
|
|
23
|
+
*/
|
|
24
|
+
declare function runWithCredentialScope<T>(store: CredentialVault, fn: () => T): T;
|
|
25
|
+
/** The host's mode switch, installed beside its credential store. */
|
|
26
|
+
declare function installModeControl(control: CredentialModeControl): void;
|
|
27
|
+
declare function getModeControl(): CredentialModeControl | null;
|
|
28
|
+
/**
|
|
29
|
+
* Install the host's credential store as the process-wide resolution source.
|
|
30
|
+
* Called once at boot (playground / generated server) after the store is
|
|
31
|
+
* constructed over the host's persistence adapter.
|
|
32
|
+
*/
|
|
33
|
+
declare function installCredentialStore(store: CredentialVault): void;
|
|
34
|
+
/** The installed store, for the credentials admin service. */
|
|
35
|
+
declare function getInstalledCredentialStore(): CredentialVault | null;
|
|
36
|
+
declare function getEffectiveCredentialStore(): CredentialVault | null;
|
|
37
|
+
/** Testing/reset hook. */
|
|
38
|
+
declare function uninstallCredentialStore(): void;
|
|
39
|
+
/** The env var selecting store-only resolution (the kernel rule `credential_admin::SOURCE_VAR`). */
|
|
40
|
+
declare const CREDENTIALS_SOURCE_ENV = "ALMADAR_CREDENTIALS_SOURCE";
|
|
41
|
+
/** Whether `env` selects store-only resolution: exactly `ALMADAR_CREDENTIALS_SOURCE=store`. */
|
|
42
|
+
declare function credentialsFromStoreOnly(env: Record<string, string | undefined>): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* The one credential-reference resolver: store, then env, then undefined; inside a tenant's
|
|
45
|
+
* credential scope, that tenant's store only. With `ALMADAR_CREDENTIALS_SOURCE=store` every
|
|
46
|
+
* name but a host setting answers from the store alone, never from the env. `ref` is an env-var name.
|
|
47
|
+
*/
|
|
48
|
+
declare function resolveCredentialRef(ref: string, env?: Record<string, string | undefined>, principal?: string): string | undefined;
|
|
49
|
+
|
|
50
|
+
export { CREDENTIALS_SOURCE_ENV, credentialModeFromEnv, credentialsFromStoreOnly, getEffectiveCredentialStore, getInstalledCredentialStore, getModeControl, installCredentialScopeStorage, installCredentialStore, installModeControl, resolveCredentialRef, runWithCredentialScope, uninstallCredentialStore };
|
|
51
|
+
export type { CredentialMode, CredentialModeControl, CredentialScopeStorage };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CREDENTIALS_SOURCE_ENV, credentialModeFromEnv, credentialsFromStoreOnly, getEffectiveCredentialStore, getInstalledCredentialStore, getModeControl, installCredentialScopeStorage, installCredentialStore, installModeControl, resolveCredentialRef, runWithCredentialScope, uninstallCredentialStore } from '../chunk-HLOUDLPI.js';
|