@almadar/shell-runtime 0.1.0 → 1.1.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-2WCVOMZ2.js +112 -0
- package/dist/chunk-57SBCUSM.js +62 -0
- package/dist/{chunk-Q2H75UYT.js → chunk-A2JJT4GA.js} +1 -37
- package/dist/chunk-BAS26HBN.js +10 -0
- package/dist/{chunk-REPX5QPI.js → chunk-BOVU4TCQ.js} +11 -3
- package/dist/chunk-BY5G4225.js +6 -0
- package/dist/chunk-DFDNHVDW.js +284 -0
- package/dist/{chunk-NATGCIVM.js → chunk-JVSREWQO.js} +378 -130
- package/dist/{chunk-DYOJGLIX.js → chunk-LKWYCYX5.js} +2 -5
- package/dist/chunk-LYFIQPXX.js +1 -0
- package/dist/{chunk-ODJCZ27I.js → chunk-N7HYNKK6.js} +35 -2
- package/dist/{chunk-4J2QEIUV.js → chunk-NTFQ36UN.js} +4 -30
- package/dist/chunk-NU6LVKGS.js +15 -0
- package/dist/{chunk-VNMG7NKY.js → chunk-OQVSN7DP.js} +21 -26
- package/dist/chunk-P2N6K2IV.js +20 -0
- package/dist/{chunk-QQRDUMB2.js → chunk-QCJWPXLH.js} +11 -11
- package/dist/{chunk-QELZ6TEJ.js → chunk-UD2CXYSJ.js} +39 -3
- package/dist/{chunk-UJHOUZAL.js → chunk-V4EMDPCO.js} +2 -5
- package/dist/chunk-VKQA2DJX.js +409 -0
- package/dist/chunk-VNGXRYFF.js +9 -0
- package/dist/{chunk-HNOAZWFH.js → chunk-WGCWJOT2.js} +2 -0
- package/dist/chunk-XZGVOBY6.js +33 -0
- package/dist/chunk-ZUSM4VW4.js +197 -0
- package/dist/client/EventTransport.d.ts +23 -7
- package/dist/client/EventTransport.js +1 -2
- package/dist/client/awaiting.js +0 -1
- package/dist/client/channel-transport.d.ts +6 -6
- package/dist/client/channel-transport.js +0 -1
- package/dist/client/circuit-store.d.ts +16 -5
- package/dist/client/circuit-store.js +2 -3
- package/dist/client/client-kernel.d.ts +36 -15
- package/dist/client/declared-input-dispatch.d.ts +19 -2
- package/dist/client/declared-input-dispatch.js +1 -2
- package/dist/client/inbound-dispatch.d.ts +21 -2
- package/dist/client/inbound-dispatch.js +1 -2
- package/dist/client/local-fold.d.ts +15 -8
- package/dist/client/local-fold.js +1 -2
- package/dist/client/render-sigils.js +0 -1
- package/dist/client/state-book.d.ts +9 -16
- package/dist/client/state-book.js +1 -2
- package/dist/client/trait-mount-error.js +0 -1
- package/dist/credentials/env-vars.d.ts +5 -1
- package/dist/credentials/env-vars.js +1 -3
- package/dist/credentials/scope.d.ts +8 -7
- package/dist/credentials/scope.js +0 -1
- package/dist/credentials/vault.d.ts +142 -0
- package/dist/credentials/vault.js +1 -0
- package/dist/effects/in-flight-calls.js +0 -1
- package/dist/effects/on-device-model.js +0 -1
- package/dist/events/EventBus.d.ts +1 -4
- package/dist/events/EventBus.js +0 -1
- package/dist/events/emit-stamp.js +0 -1
- package/dist/index.d.ts +25 -42
- package/dist/index.js +27 -45
- package/dist/kernel/decode.d.ts +10 -10
- package/dist/kernel/decode.js +1 -2
- package/dist/kernel/engine.d.ts +133 -31
- package/dist/kernel/engine.js +7 -9
- package/dist/kernel/frame-applier.d.ts +8 -7
- package/dist/kernel/frame-applier.js +1 -2
- package/dist/kernel/host.d.ts +148 -16
- package/dist/kernel/host.js +4 -7
- package/dist/kernel/lane.d.ts +1 -22
- package/dist/kernel/lane.js +1 -2
- 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 +30 -8
- package/dist/kernel/os-port.js +1 -2
- package/dist/kernel/program-effects.d.ts +11 -28
- package/dist/kernel/program-effects.js +1 -2
- package/dist/kernel/secret-ports.d.ts +139 -0
- package/dist/kernel/secret-ports.js +2 -0
- package/dist/kernel/wire.d.ts +113 -12
- package/dist/loader/fetch-loader.d.ts +26 -0
- package/dist/loader/fetch-loader.js +1 -0
- package/dist/loader/lazy-page.js +0 -1
- package/dist/loader/schema-loader.d.ts +1 -17
- package/dist/persistence/native-memory.js +0 -1
- 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 +16 -23
- package/dist/runtime/evaluation/local-store-transport.js +9 -13
- package/dist/runtime/evaluation/residence-transport.d.ts +3 -3
- package/dist/runtime/evaluation/residence-transport.js +1 -2
- package/dist/runtime/evaluation/routed-persistence.js +0 -1
- package/dist/runtime/events/identity/routing.d.ts +2 -53
- package/dist/runtime/events/identity/routing.js +1 -2
- package/dist/runtime/types.d.ts +5 -205
- package/dist/runtime/types.js +1 -2
- package/dist/service/default-call-service.js +0 -1
- package/dist/service/service-provider.js +0 -1
- package/package.json +8 -5
- package/dist/chunk-2JU7Y4KU.js +0 -21
- package/dist/chunk-46RWK2B5.js +0 -28
- package/dist/chunk-4ZICQ5PM.js +0 -192
- package/dist/chunk-53IPZXDP.js +0 -76
- package/dist/chunk-5D63EMO5.js +0 -16
- package/dist/chunk-CPSQXEJ6.js +0 -55
- package/dist/chunk-CQP5XAX6.js +0 -173
- package/dist/chunk-CROS2GEX.js +0 -49
- package/dist/chunk-D4XJTBLB.js +0 -217
- package/dist/chunk-D5USD2EX.js +0 -232
- package/dist/chunk-EV56K4GB.js +0 -63
- package/dist/chunk-FQ6IZMIU.js +0 -10
- package/dist/chunk-HMK6YMQS.js +0 -135
- package/dist/chunk-IHQLE5M7.js +0 -62
- package/dist/chunk-JFWFDUTR.js +0 -35
- package/dist/chunk-MHYSHSRG.js +0 -54
- package/dist/chunk-MLKGABMK.js +0 -7
- package/dist/chunk-NAECVIAR.js +0 -322
- package/dist/chunk-Q7JK4KY7.js +0 -9
- package/dist/chunk-RBUMDYFS.js +0 -681
- package/dist/chunk-SAS5KKCR.js +0 -43
- package/dist/chunk-SWPDU752.js +0 -28
- package/dist/chunk-T775TUCD.js +0 -18
- package/dist/chunk-VMOBW7RK.js +0 -21
- package/dist/chunk-WNPNNYXY.js +0 -22
- package/dist/chunk-XB5GYODW.js +0 -28
- package/dist/chunk-YL2SO5TP.js +0 -334
- package/dist/chunk-YO4LWS3I.js +0 -606
- package/dist/chunk-ZAQSS47X.js +0 -157
- package/dist/chunk-ZCQUUJIF.js +0 -129
- package/dist/client/ServerBridge.d.ts +0 -126
- package/dist/client/ServerBridge.js +0 -3
- package/dist/credentials/seed.d.ts +0 -21
- package/dist/credentials/seed.js +0 -2
- package/dist/credentials/store.d.ts +0 -110
- package/dist/credentials/store.js +0 -2
- package/dist/index-hT1xCdTq.d.ts +0 -46
- package/dist/kernel/beacon.d.ts +0 -32
- package/dist/kernel/beacon.js +0 -2
- package/dist/kernel/http.d.ts +0 -302
- package/dist/kernel/http.js +0 -6
- package/dist/kernel/oauth-effects.d.ts +0 -25
- package/dist/kernel/oauth-effects.js +0 -7
- package/dist/kernel/oauth-port.d.ts +0 -31
- package/dist/kernel/oauth-port.js +0 -2
- package/dist/loader/http-loader.d.ts +0 -111
- package/dist/loader/http-loader.js +0 -2
- package/dist/runtime/effects/composition/compose-behaviors.d.ts +0 -58
- package/dist/runtime/effects/composition/compose-behaviors.js +0 -4
- package/dist/runtime/effects/composition/event-wiring.d.ts +0 -38
- package/dist/runtime/effects/composition/event-wiring.js +0 -2
- package/dist/runtime/effects/composition/index.d.ts +0 -5
- package/dist/runtime/effects/composition/index.js +0 -6
- package/dist/runtime/effects/composition/layout-strategy.d.ts +0 -35
- package/dist/runtime/effects/composition/layout-strategy.js +0 -2
- package/dist/runtime/effects/composition/pipe.d.ts +0 -25
- package/dist/runtime/effects/composition/pipe.js +0 -2
- package/dist/runtime/entities/mockStoreSeed.d.ts +0 -56
- package/dist/runtime/entities/mockStoreSeed.js +0 -3
- package/dist/runtime/entities/seedBrowserStore.d.ts +0 -28
- package/dist/runtime/entities/seedBrowserStore.js +0 -2
- package/dist/runtime/entities/std-mock-seed.d.ts +0 -87
- package/dist/runtime/entities/std-mock-seed.js +0 -2
- package/dist/runtime/time/TickScheduler.d.ts +0 -77
- package/dist/runtime/time/TickScheduler.js +0 -3
- package/dist/runtime/time/cron.d.ts +0 -25
- package/dist/runtime/time/cron.js +0 -2
- package/dist/runtime/time/duration.d.ts +0 -20
- package/dist/runtime/time/duration.js +0 -2
- package/dist/runtime/traits/OrbitalTraitParsing.d.ts +0 -34
- package/dist/runtime/traits/OrbitalTraitParsing.js +0 -2
- package/dist/runtime/traits/listen-targets.d.ts +0 -16
- package/dist/runtime/traits/listen-targets.js +0 -3
- package/dist/runtime/traits/trait-index.d.ts +0 -35
- package/dist/runtime/traits/trait-index.js +0 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OrbitalSchema,
|
|
1
|
+
import { OrbitalSchema, EventRequest, EventResponse, RowSetRef, RowQueryPage, EmittedEvent, ServerTopology } from '@almadar/core';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* EventTransport — the client → orbital event transport port (plan P5,
|
|
@@ -11,8 +11,8 @@ import { OrbitalSchema, OrbitalEventRequest, OrbitalEventResponse, RowSetRef, Ro
|
|
|
11
11
|
* be switched onto this port at the W5b build checkpoint (see the plan);
|
|
12
12
|
* until then this file has no consumers outside this package.
|
|
13
13
|
*
|
|
14
|
-
* The wire shapes are `@almadar/core`'s existing `
|
|
15
|
-
* `
|
|
14
|
+
* The wire shapes are `@almadar/core`'s existing `EventRequest` /
|
|
15
|
+
* `EventResponse` — no shadow types.
|
|
16
16
|
*
|
|
17
17
|
* @packageDocumentation
|
|
18
18
|
*/
|
|
@@ -48,7 +48,7 @@ interface EventTransport {
|
|
|
48
48
|
register(schema: OrbitalSchema): Promise<EventTransportRegisterResult>;
|
|
49
49
|
unregister(): Promise<void>;
|
|
50
50
|
/** Play one event through the orbital named `orbitalName`. */
|
|
51
|
-
send(orbitalName: string, request:
|
|
51
|
+
send(orbitalName: string, request: EventRequest): Promise<EventResponse>;
|
|
52
52
|
/**
|
|
53
53
|
* A row-set reference resolved by the host that holds the rows, for the viewer the transport is signed in as (the
|
|
54
54
|
* host applies `@read`): the rows that still match, in the reference's order. Absent when the transport has no
|
|
@@ -78,7 +78,7 @@ interface EventTransport {
|
|
|
78
78
|
subscribeHostDispatches?(onDispatch: HostDispatchListener, params?: Record<string, string>): () => void;
|
|
79
79
|
}
|
|
80
80
|
/** A dispatch the host ran on its own, with its result. */
|
|
81
|
-
type HostDispatchListener = (orbitalName: string, request:
|
|
81
|
+
type HostDispatchListener = (orbitalName: string, request: EventRequest, response: EventResponse) => void;
|
|
82
82
|
/**
|
|
83
83
|
* Supplies the bearer token the hosting server authenticates with. Resolved
|
|
84
84
|
* per request (tokens expire); `undefined` sends the request unauthenticated
|
|
@@ -86,6 +86,22 @@ type HostDispatchListener = (orbitalName: string, request: OrbitalEventRequest,
|
|
|
86
86
|
* from `@almadar/ui`'s `providers/ServerBridge.tsx`.
|
|
87
87
|
*/
|
|
88
88
|
type AccessTokenProvider = () => Promise<string | undefined>;
|
|
89
|
+
/** The host freed this client's session after its live stream dropped: mount again with the frames the client holds (EXEC-DIST-9). */
|
|
90
|
+
declare class SessionEndedError extends Error {
|
|
91
|
+
constructor(message: string);
|
|
92
|
+
}
|
|
93
|
+
/** The host answered a dispatch with a non-2xx status: a transport or auth failure, never an event response. */
|
|
94
|
+
declare class TransportStatusError extends Error {
|
|
95
|
+
readonly status: number;
|
|
96
|
+
readonly bodyText: string;
|
|
97
|
+
/** The `{ error, code }` body when the answer carried one. */
|
|
98
|
+
readonly refusal: RefusalBody | undefined;
|
|
99
|
+
constructor(status: number, bodyText: string);
|
|
100
|
+
}
|
|
101
|
+
interface RefusalBody {
|
|
102
|
+
code?: string;
|
|
103
|
+
error?: string;
|
|
104
|
+
}
|
|
89
105
|
interface HttpTransportOptions {
|
|
90
106
|
serverUrl: string;
|
|
91
107
|
getAccessToken?: AccessTokenProvider;
|
|
@@ -108,7 +124,7 @@ declare function encodeJsonBody(value: object, compress: boolean): Promise<{
|
|
|
108
124
|
/** HTTP transport — POSTs to a server speaking the canonical playground-runtime contract. */
|
|
109
125
|
declare function createHttpTransport(options: HttpTransportOptions): EventTransport;
|
|
110
126
|
/** Evaluates one event against an orbital with no wire in between — the unified `evaluateOrbitalEvent` (a separate, in-progress unit) is a valid `OrbitalEvaluator`. */
|
|
111
|
-
type OrbitalEvaluator = (orbitalName: string, request:
|
|
127
|
+
type OrbitalEvaluator = (orbitalName: string, request: EventRequest) => Promise<EventResponse>;
|
|
112
128
|
interface InProcessTransportOptions {
|
|
113
129
|
onRegister?: (schema: OrbitalSchema) => Promise<void> | void;
|
|
114
130
|
onUnregister?: () => Promise<void> | void;
|
|
@@ -127,5 +143,5 @@ interface InProcessTransportOptions {
|
|
|
127
143
|
/** In-process transport — the evaluator is INJECTED (e.g. the unified `evaluateOrbitalEvent`, owned elsewhere). */
|
|
128
144
|
declare function createInProcessTransport(evaluate: OrbitalEvaluator, options?: InProcessTransportOptions): EventTransport;
|
|
129
145
|
|
|
130
|
-
export { COMPRESSED_BODY_MIN_BYTES, createHttpTransport, createInProcessTransport, deriveCarriesCircuitState, encodeJsonBody };
|
|
146
|
+
export { COMPRESSED_BODY_MIN_BYTES, SessionEndedError, TransportStatusError, createHttpTransport, createInProcessTransport, deriveCarriesCircuitState, encodeJsonBody };
|
|
131
147
|
export type { AccessTokenProvider, EventTransport, EventTransportRegisterResult, HostDispatchListener, HttpTransportOptions, InProcessTransportOptions, OrbitalEvaluator, PushTarget };
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { COMPRESSED_BODY_MIN_BYTES, createHttpTransport, createInProcessTransport, deriveCarriesCircuitState, encodeJsonBody } from '../chunk-
|
|
2
|
-
import '../chunk-MLKGABMK.js';
|
|
1
|
+
export { COMPRESSED_BODY_MIN_BYTES, SessionEndedError, TransportStatusError, createHttpTransport, createInProcessTransport, deriveCarriesCircuitState, encodeJsonBody } from '../chunk-UD2CXYSJ.js';
|
package/dist/client/awaiting.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EventRequest, EventResponse, EmittedEvent } from '@almadar/core';
|
|
2
2
|
import { PushTarget, EventTransport } from './EventTransport.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -20,11 +20,11 @@ type ChannelMessage = {
|
|
|
20
20
|
almadarChannel: 'send';
|
|
21
21
|
id: number;
|
|
22
22
|
orbitalName: string;
|
|
23
|
-
request:
|
|
23
|
+
request: EventRequest;
|
|
24
24
|
} | {
|
|
25
25
|
almadarChannel: 'reply';
|
|
26
26
|
id: number;
|
|
27
|
-
response:
|
|
27
|
+
response: EventResponse;
|
|
28
28
|
} | {
|
|
29
29
|
almadarChannel: 'push';
|
|
30
30
|
emitted: EmittedEvent;
|
|
@@ -32,8 +32,8 @@ type ChannelMessage = {
|
|
|
32
32
|
} | {
|
|
33
33
|
almadarChannel: 'dispatched';
|
|
34
34
|
orbitalName: string;
|
|
35
|
-
request:
|
|
36
|
-
response:
|
|
35
|
+
request: EventRequest;
|
|
36
|
+
response: EventResponse;
|
|
37
37
|
};
|
|
38
38
|
interface TransportChannel {
|
|
39
39
|
post(message: ChannelMessage): void;
|
|
@@ -51,7 +51,7 @@ interface ServedChannel {
|
|
|
51
51
|
/** Push a host-side event to the view (e.g. one a declared input caused while no view was asking). */
|
|
52
52
|
push(emitted: EmittedEvent, target: PushTarget): void;
|
|
53
53
|
/** Send the view the result of a dispatch the host ran on its own. */
|
|
54
|
-
pushDispatch(orbitalName: string, request:
|
|
54
|
+
pushDispatch(orbitalName: string, request: EventRequest, response: EventResponse): void;
|
|
55
55
|
stop(): void;
|
|
56
56
|
}
|
|
57
57
|
/** The host half: serve `transport` on `channel` for the program named `schemaName`. */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AwaitingRegistry } from './awaiting.js';
|
|
2
2
|
import { StateBook } from './state-book.js';
|
|
3
|
-
import { EntityRow,
|
|
3
|
+
import { EntityRow, TraitDefinition } from '@almadar/core';
|
|
4
|
+
import { FrameDelta } from '@almadar/core/kernel-wire';
|
|
4
5
|
import { RollbackCause, TransitionObserver } from './trait-types.js';
|
|
5
|
-
import '@almadar/core/kernel-wire';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* CircuitStore — P2, `docs/Almadar_Runtime_Stateless_Stateful_PLAN.md` §4.2.
|
|
@@ -28,14 +28,25 @@ interface TraitSnapshot {
|
|
|
28
28
|
state: string;
|
|
29
29
|
frame: EntityRow | undefined;
|
|
30
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';
|
|
31
37
|
interface CircuitStore {
|
|
32
38
|
/** Each trait's state as the kernel last reported it. */
|
|
33
39
|
readonly states: StateBook;
|
|
34
40
|
/** The entity-frame map (`(set @entity.X)` writes), keyed by
|
|
35
41
|
* `IndexedTrait.frameKey`. */
|
|
36
42
|
readonly frames: Map<string, EntityRow>;
|
|
37
|
-
/**
|
|
38
|
-
readonly
|
|
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;
|
|
39
50
|
/** Traits awaiting a server round trip (per-trait subscriptions; see `AwaitingRegistry`). */
|
|
40
51
|
readonly awaiting: AwaitingRegistry;
|
|
41
52
|
/**
|
|
@@ -73,4 +84,4 @@ interface CircuitStore {
|
|
|
73
84
|
declare function createMemoryCircuitStore(traits?: readonly TraitDefinition[], observer?: TransitionObserver): CircuitStore;
|
|
74
85
|
|
|
75
86
|
export { createMemoryCircuitStore };
|
|
76
|
-
export type { CircuitStore, TraitSnapshot };
|
|
87
|
+
export type { CircuitStore, FrameOutcome, TraitSnapshot };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EventResponse, EventRequest, DispatchMode, EmittedEvent, MountSeed, TransitionRejection } from '@almadar/core';
|
|
2
2
|
import { CircuitStore } from './circuit-store.js';
|
|
3
3
|
import './awaiting.js';
|
|
4
4
|
import './state-book.js';
|
|
@@ -12,7 +12,7 @@ import '@almadar/core/kernel-wire';
|
|
|
12
12
|
|
|
13
13
|
/** One `ClientKernel.dispatch()` call's settled outcome. */
|
|
14
14
|
interface ClientKernelOutcome {
|
|
15
|
-
response:
|
|
15
|
+
response: EventResponse;
|
|
16
16
|
mode: DispatchMode;
|
|
17
17
|
/**
|
|
18
18
|
* True when `onLocal` already received the local arm's response (the leg
|
|
@@ -20,21 +20,25 @@ interface ClientKernelOutcome {
|
|
|
20
20
|
* added — the local ones were painted before the round trip.
|
|
21
21
|
*/
|
|
22
22
|
localPainted?: boolean;
|
|
23
|
-
serverEffects?: Pick<
|
|
23
|
+
serverEffects?: Pick<EventResponse, 'clientEffectsByTrait'>;
|
|
24
24
|
/**
|
|
25
25
|
* A tick-lane dispatch: what its post's fold added on top of the local run,
|
|
26
26
|
* once the post settles (undefined when a newer firing superseded it). The
|
|
27
27
|
* drain never waits on it; the caller paints it when it lands.
|
|
28
28
|
*/
|
|
29
|
-
tickSettled?: Promise<Pick<
|
|
29
|
+
tickSettled?: Promise<Pick<EventResponse, 'clientEffectsByTrait'> | undefined>;
|
|
30
30
|
}
|
|
31
31
|
/** Per-dispatch hooks: `onLocal` sees the locally-evaluated response before its server leg is sent. */
|
|
32
32
|
interface ClientDispatchHooks {
|
|
33
|
-
onLocal?: (local:
|
|
33
|
+
onLocal?: (local: EventResponse) => void;
|
|
34
34
|
}
|
|
35
35
|
/** Mount hooks: `onLocal` sees each seed's local response before the mount leg is sent. */
|
|
36
36
|
interface ClientMountHooks {
|
|
37
|
-
onLocal?: (trait: string, local:
|
|
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;
|
|
38
42
|
}
|
|
39
43
|
/** One `ClientKernel.dispatchMount()` call's settled outcome. */
|
|
40
44
|
interface ClientMountOutcome {
|
|
@@ -43,7 +47,7 @@ interface ClientMountOutcome {
|
|
|
43
47
|
trait: string;
|
|
44
48
|
event: string;
|
|
45
49
|
mode: DispatchMode;
|
|
46
|
-
local:
|
|
50
|
+
local: EventResponse;
|
|
47
51
|
}>;
|
|
48
52
|
/** Whether any mount leg was posted. */
|
|
49
53
|
posted: boolean;
|
|
@@ -52,8 +56,8 @@ interface ClientMountOutcome {
|
|
|
52
56
|
/** Per-trait effect failures the posted legs reported (`effect-failed`). */
|
|
53
57
|
rejections: TransitionRejection[];
|
|
54
58
|
/** What the posted legs added: the server's effects and the emits the client had not run. */
|
|
55
|
-
serverEffects: Pick<
|
|
56
|
-
emittedEvents:
|
|
59
|
+
serverEffects: Pick<EventResponse, 'clientEffectsByTrait'>;
|
|
60
|
+
emittedEvents: EventResponse['emittedEvents'];
|
|
57
61
|
}
|
|
58
62
|
interface ClientKernel {
|
|
59
63
|
/**
|
|
@@ -78,25 +82,42 @@ interface ClientKernel {
|
|
|
78
82
|
* out on a per-(event, trait) newest-wins lane outside the FIFO, with no
|
|
79
83
|
* rollback, so a tick round trip never delays a command.
|
|
80
84
|
*/
|
|
81
|
-
dispatch(request:
|
|
85
|
+
dispatch(request: EventRequest, hooks?: ClientDispatchHooks): Promise<ClientKernelOutcome>;
|
|
82
86
|
/**
|
|
83
87
|
* Dispatch a server-pushed live message of THIS client's own running
|
|
84
88
|
* request (`PushTarget` `origin`). Outside the FIFO, because the request
|
|
85
89
|
* producing it is the entry the FIFO is waiting on; progress dispatches run
|
|
86
90
|
* one at a time, in push order, and never mark traits awaiting.
|
|
87
91
|
*/
|
|
88
|
-
dispatchProgress(request:
|
|
92
|
+
dispatchProgress(request: EventRequest): Promise<ClientKernelOutcome>;
|
|
89
93
|
/**
|
|
90
94
|
* Show the result of a dispatch the host ran on its own (`EventTransport.subscribeHostDispatches`):
|
|
91
95
|
* the host's states, rows and render land in this view. Nothing runs here and nothing is posted,
|
|
92
96
|
* so the dispatch's effects happen once, on the host. Host dispatches fold one at a time, in order.
|
|
93
97
|
*/
|
|
94
|
-
foldHostDispatch(request:
|
|
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>;
|
|
95
116
|
/**
|
|
96
117
|
* Mount several traits in ONE FIFO entry: every seed's local arm runs and
|
|
97
118
|
* paints, then one `mount` leg per owning orbital is posted and folded.
|
|
98
119
|
*/
|
|
99
|
-
dispatchMount(seeds: readonly MountSeed[], hooks?: ClientMountHooks, base?: Pick<
|
|
120
|
+
dispatchMount(seeds: readonly MountSeed[], hooks?: ClientMountHooks, base?: Pick<EventRequest, 'payload' | 'entityId' | 'clientId' | 'locale' | 'route'>): Promise<ClientMountOutcome>;
|
|
100
121
|
readonly store: CircuitStore;
|
|
101
122
|
}
|
|
102
123
|
/**
|
|
@@ -107,7 +128,7 @@ interface ClientKernel {
|
|
|
107
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.
|
|
108
129
|
*/
|
|
109
130
|
interface LocalFoldKernel {
|
|
110
|
-
foldLocalResponse(response:
|
|
131
|
+
foldLocalResponse(response: EventResponse, traceHops: boolean, notify: boolean): Promise<void>;
|
|
111
132
|
}
|
|
112
133
|
|
|
113
|
-
export type { ClientDispatchHooks, ClientKernel, ClientKernelOutcome, ClientMountHooks, ClientMountOutcome, LocalFoldKernel };
|
|
134
|
+
export type { ClientDispatchHooks, ClientEmitOutcome, ClientKernel, ClientKernelOutcome, ClientMountHooks, ClientMountOutcome, LocalFoldKernel };
|
|
@@ -1,5 +1,22 @@
|
|
|
1
|
-
import {
|
|
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';
|
|
2
12
|
|
|
3
|
-
|
|
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>;
|
|
4
21
|
|
|
5
22
|
export { dispatchDeclaredInput };
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { dispatchDeclaredInput } from '../chunk-
|
|
2
|
-
import '../chunk-MLKGABMK.js';
|
|
1
|
+
export { dispatchDeclaredInput } from '../chunk-LKWYCYX5.js';
|
|
@@ -1,5 +1,24 @@
|
|
|
1
|
-
import {
|
|
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';
|
|
2
12
|
|
|
3
|
-
|
|
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>;
|
|
4
22
|
|
|
5
23
|
export { dispatchInbound };
|
|
24
|
+
export type { InboundContract };
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { dispatchInbound } from '../chunk-
|
|
2
|
-
import '../chunk-MLKGABMK.js';
|
|
1
|
+
export { dispatchInbound } from '../chunk-P2N6K2IV.js';
|
|
@@ -1,26 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EventResponse } from '@almadar/core';
|
|
2
|
+
import { FrameDelta } from '@almadar/core/kernel-wire';
|
|
2
3
|
import { LocalFoldKernel } from './client-kernel.js';
|
|
3
4
|
import { CircuitStore } from './circuit-store.js';
|
|
4
5
|
import { TransitionObserver } from './trait-types.js';
|
|
5
6
|
import './awaiting.js';
|
|
6
7
|
import './state-book.js';
|
|
7
|
-
import '@almadar/core/kernel-wire';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* The view's side of a dispatch the in-process kernel already ran: report its executed hops to the observer,
|
|
11
|
-
*
|
|
11
|
+
* paint its states, frame delta and sticky callsite payloads into the `CircuitStore`, then notify subscribers.
|
|
12
12
|
* One implementation for every response the kernel produces (a dispatch, a mount seed, a posted leg's fold,
|
|
13
13
|
* a tick frame).
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
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;
|
|
18
25
|
interface LocalFoldOptions {
|
|
19
26
|
store: CircuitStore;
|
|
20
|
-
|
|
27
|
+
framesSince: FramesSince;
|
|
21
28
|
observer?: TransitionObserver;
|
|
22
29
|
}
|
|
23
30
|
declare function createLocalFold(opts: LocalFoldOptions): LocalFoldKernel;
|
|
24
31
|
|
|
25
|
-
export { createLocalFold,
|
|
26
|
-
export type { LocalFoldOptions };
|
|
32
|
+
export { createLocalFold, paintFrames, paintResponse, paintStates, traceResponse };
|
|
33
|
+
export type { FramesSince, LocalFoldOptions };
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { createLocalFold,
|
|
2
|
-
import '../chunk-MLKGABMK.js';
|
|
1
|
+
export { createLocalFold, paintFrames, paintResponse, paintStates, traceResponse } from '../chunk-QCJWPXLH.js';
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { TraitDefinition
|
|
1
|
+
import { TraitDefinition } from '@almadar/core';
|
|
2
2
|
import { TransitionObserver, TraitState, RollbackCause } from './trait-types.js';
|
|
3
3
|
import '@almadar/core/kernel-wire';
|
|
4
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
|
+
|
|
5
12
|
/** The state a trait starts in: the one marked initial, else the first declared. */
|
|
6
13
|
declare function findInitialState(trait: TraitDefinition): string;
|
|
7
14
|
declare function createInitialTraitState(trait: TraitDefinition): TraitState;
|
|
8
|
-
/**
|
|
9
|
-
* Every transition out of `currentState` on the event, in declaration order. An event id is compared with a
|
|
10
|
-
* transition's own id when both carry one, so an arm still matches after its event was renamed.
|
|
11
|
-
*/
|
|
12
|
-
declare function findMatchingTransitions(trait: TraitDefinition, currentState: string, eventKey: string, eventId?: EventId): TraitDefinition['transitions'];
|
|
13
|
-
/** The first transition out of `currentState` on the event, ignoring guards. */
|
|
14
|
-
declare function findTransition(trait: TraitDefinition, currentState: string, eventKey: string, eventId?: EventId): TraitDefinition['transitions'][0] | undefined;
|
|
15
15
|
declare class StateBook {
|
|
16
16
|
private readonly observer?;
|
|
17
17
|
private readonly traits;
|
|
@@ -21,17 +21,10 @@ declare class StateBook {
|
|
|
21
21
|
getState(traitName: string, entityId?: string): TraitState | undefined;
|
|
22
22
|
/** Each trait's singleton-scope state. */
|
|
23
23
|
getAllStates(): Map<string, TraitState>;
|
|
24
|
-
/** Whether the trait has an arm on the event from its current state. */
|
|
25
|
-
canHandleEvent(traitName: string, eventKey: string, entityId?: string, eventId?: EventId): boolean;
|
|
26
|
-
/**
|
|
27
|
-
* The lifecycle event an embedded child can be repainted with: the one it handles from its current state,
|
|
28
|
-
* provided every matching arm stays in that state and only renders.
|
|
29
|
-
*/
|
|
30
|
-
repaintLifecycleEvent(traitName: string, entityId?: string): string | undefined;
|
|
31
24
|
/** Record the state the kernel reports. No-op for a trait not on the page. */
|
|
32
25
|
seedState(traitName: string, currentState: string, entityId?: string): void;
|
|
33
26
|
/** Undo an optimistic commit, reporting the hop back to the observer. */
|
|
34
27
|
rollbackState(traitName: string, toState: string, entityId: string | undefined, cause: RollbackCause): void;
|
|
35
28
|
}
|
|
36
29
|
|
|
37
|
-
export { StateBook, createInitialTraitState, findInitialState
|
|
30
|
+
export { StateBook, createInitialTraitState, findInitialState };
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { StateBook, createInitialTraitState, findInitialState
|
|
2
|
-
import '../chunk-MLKGABMK.js';
|
|
1
|
+
export { StateBook, createInitialTraitState, findInitialState } from '../chunk-A2JJT4GA.js';
|
|
@@ -1,3 +1,7 @@
|
|
|
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";
|
|
1
5
|
/**
|
|
2
6
|
* Bootstrap secrets that must NEVER enter store custody: the master key(s)
|
|
3
7
|
* decrypt the store itself, so seeding them as rows (encrypted under
|
|
@@ -11,4 +15,4 @@ declare const STORE_BOOTSTRAP_ENV_VARS: ReadonlySet<string>;
|
|
|
11
15
|
*/
|
|
12
16
|
declare function allCredentialEnvVars(): Set<string>;
|
|
13
17
|
|
|
14
|
-
export { STORE_BOOTSTRAP_ENV_VARS, allCredentialEnvVars };
|
|
18
|
+
export { CREDENTIAL_MASTER_KEY_ENV, CREDENTIAL_PREVIOUS_MASTER_KEY_ENV, STORE_BOOTSTRAP_ENV_VARS, allCredentialEnvVars };
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
export { STORE_BOOTSTRAP_ENV_VARS, allCredentialEnvVars } from '../chunk-
|
|
2
|
-
import '../chunk-NAECVIAR.js';
|
|
3
|
-
import '../chunk-MLKGABMK.js';
|
|
1
|
+
export { CREDENTIAL_MASTER_KEY_ENV, CREDENTIAL_PREVIOUS_MASTER_KEY_ENV, STORE_BOOTSTRAP_ENV_VARS, allCredentialEnvVars } from '../chunk-VNGXRYFF.js';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CredentialVault } from './vault.js';
|
|
2
2
|
import '@almadar/core';
|
|
3
|
+
import '@almadar/core/kernel-wire';
|
|
3
4
|
|
|
4
5
|
/** Whether integrations answer with mock data or call their real backends. */
|
|
5
6
|
type CredentialMode = 'mock' | 'real';
|
|
@@ -12,15 +13,15 @@ interface CredentialModeControl {
|
|
|
12
13
|
}
|
|
13
14
|
/** The per-tenant credential scope: a Node host installs AsyncLocalStorage (`@almadar/shell-node`); a browser has none. */
|
|
14
15
|
interface CredentialScopeStorage {
|
|
15
|
-
run<T>(store:
|
|
16
|
-
getStore():
|
|
16
|
+
run<T>(store: CredentialVault, fn: () => T): T;
|
|
17
|
+
getStore(): CredentialVault | undefined;
|
|
17
18
|
}
|
|
18
19
|
declare function installCredentialScopeStorage(storage: CredentialScopeStorage): void;
|
|
19
20
|
/**
|
|
20
21
|
* Run `fn` as one tenant of a multi-tenant host: every credential reference resolved inside it
|
|
21
22
|
* (across awaits) comes from `store` alone, never from the host's env or installed store.
|
|
22
23
|
*/
|
|
23
|
-
declare function runWithCredentialScope<T>(store:
|
|
24
|
+
declare function runWithCredentialScope<T>(store: CredentialVault, fn: () => T): T;
|
|
24
25
|
/** The host's mode switch, installed beside its credential store. */
|
|
25
26
|
declare function installModeControl(control: CredentialModeControl): void;
|
|
26
27
|
declare function getModeControl(): CredentialModeControl | null;
|
|
@@ -29,10 +30,10 @@ declare function getModeControl(): CredentialModeControl | null;
|
|
|
29
30
|
* Called once at boot (playground / generated server) after the store is
|
|
30
31
|
* constructed over the host's persistence adapter.
|
|
31
32
|
*/
|
|
32
|
-
declare function installCredentialStore(store:
|
|
33
|
+
declare function installCredentialStore(store: CredentialVault): void;
|
|
33
34
|
/** The installed store, for the credentials admin service. */
|
|
34
|
-
declare function getInstalledCredentialStore():
|
|
35
|
-
declare function getEffectiveCredentialStore():
|
|
35
|
+
declare function getInstalledCredentialStore(): CredentialVault | null;
|
|
36
|
+
declare function getEffectiveCredentialStore(): CredentialVault | null;
|
|
36
37
|
/** Testing/reset hook. */
|
|
37
38
|
declare function uninstallCredentialStore(): void;
|
|
38
39
|
/** The env var selecting store-only resolution (the kernel rule `credential_admin::SOURCE_VAR`). */
|
|
@@ -1,2 +1 @@
|
|
|
1
1
|
export { CREDENTIALS_SOURCE_ENV, credentialModeFromEnv, credentialsFromStoreOnly, getEffectiveCredentialStore, getInstalledCredentialStore, getModeControl, installCredentialScopeStorage, installCredentialStore, installModeControl, resolveCredentialRef, runWithCredentialScope, uninstallCredentialStore } from '../chunk-HLOUDLPI.js';
|
|
2
|
-
import '../chunk-MLKGABMK.js';
|