@almadar/shell-runtime 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-57SBCUSM.js +62 -0
- package/dist/chunk-625EP7W2.js +108 -0
- package/dist/{chunk-NATGCIVM.js → chunk-7WB6VWRK.js} +344 -129
- 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-I3TKINSO.js +398 -0
- package/dist/{chunk-DYOJGLIX.js → chunk-LKWYCYX5.js} +2 -5
- package/dist/chunk-LYFIQPXX.js +1 -0
- package/dist/{chunk-VNMG7NKY.js → chunk-MU335ZA4.js} +20 -26
- 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-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-VNGXRYFF.js +9 -0
- package/dist/{chunk-HNOAZWFH.js → chunk-WGCWJOT2.js} +2 -0
- package/dist/chunk-X6W44WHO.js +26 -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 +8 -10
- package/dist/kernel/decode.js +1 -2
- package/dist/kernel/engine.d.ts +132 -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 +127 -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 +50 -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 +14 -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 {
|
|
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';
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { EntityRow } from '@almadar/core';
|
|
2
|
+
import { CredentialGrantWire, CredentialStanding, ConnectFailure, ConnectFailureKind } from '@almadar/core/kernel-wire';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The credential rows a host keeps over its medium (`chrome.storage`, files, Firestore). It answers four raw asks and
|
|
6
|
+
* decides nothing: encryption, row shape, identity and every failure rule are the kernel's (`CredentialVault`, wasm).
|
|
7
|
+
* `create` carries the id the kernel gave the row; `update` merges `data` over the row; `delete` answers whether this call
|
|
8
|
+
* removed the row, and must do so atomically against other takers of the same medium: it is the conditional delete a
|
|
9
|
+
* one-use value is taken with.
|
|
10
|
+
*/
|
|
11
|
+
interface CredentialRowsPort {
|
|
12
|
+
list(): Promise<EntityRow[]>;
|
|
13
|
+
create(row: EntityRow & {
|
|
14
|
+
id: string;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
update(id: string, data: EntityRow): Promise<void>;
|
|
17
|
+
delete(id: string): Promise<boolean>;
|
|
18
|
+
}
|
|
19
|
+
/** The slice of the wasm `CredentialVault` class (`@almadar/kernel`) this handle uses; each result is JSON text. */
|
|
20
|
+
interface CredentialVaultKernel {
|
|
21
|
+
readonly enabled: boolean;
|
|
22
|
+
load(rowsJson: string): number;
|
|
23
|
+
resolve(name: string, principal?: string): string | undefined;
|
|
24
|
+
label(name: string, principal?: string): string | undefined;
|
|
25
|
+
snapshotEnv(): string;
|
|
26
|
+
entries(principal?: string): string;
|
|
27
|
+
listing(): string;
|
|
28
|
+
set(service: string, name: string, value: string, principal?: string, label?: string): string;
|
|
29
|
+
replace(name: string, value: string, principal?: string): string;
|
|
30
|
+
persist(name: string, value: string, principal?: string, label?: string): string;
|
|
31
|
+
remove(name: string, principal?: string): boolean;
|
|
32
|
+
rotate(): string;
|
|
33
|
+
takeWrites(): string;
|
|
34
|
+
connectBegin(grantJson: string): string;
|
|
35
|
+
refreshBegin(name: string, principal?: string): string;
|
|
36
|
+
connectFinish(ticket: number, status: number, body: string): string;
|
|
37
|
+
connectAbandon(ticket: number): boolean;
|
|
38
|
+
}
|
|
39
|
+
/** What the kernel asks a host to POST to a token endpoint. The host decides nothing about it. */
|
|
40
|
+
interface TokenRequest {
|
|
41
|
+
endpoint: string;
|
|
42
|
+
headers: Array<[string, string]>;
|
|
43
|
+
body: string;
|
|
44
|
+
}
|
|
45
|
+
interface TokenReply {
|
|
46
|
+
status: number;
|
|
47
|
+
body: string;
|
|
48
|
+
}
|
|
49
|
+
/** The host's one network capability the credential exchange needs: a form POST to an https token endpoint, no redirects followed. */
|
|
50
|
+
type TokenEndpointPost = (request: TokenRequest) => Promise<TokenReply>;
|
|
51
|
+
/** A token exchange the kernel's store refused or the host could not carry; `kind` is the kernel's `ConnectFailureKind`. */
|
|
52
|
+
declare class CredentialExchangeError extends Error {
|
|
53
|
+
readonly kind: ConnectFailureKind;
|
|
54
|
+
constructor(kind: ConnectFailureKind, message: string);
|
|
55
|
+
}
|
|
56
|
+
/** A kernel module that carries the vault class: `import * as kernel from '@almadar/kernel/client'`. */
|
|
57
|
+
interface CredentialVaultModule {
|
|
58
|
+
CredentialVault: new (masterKey?: string, previousKey?: string) => CredentialVaultKernel;
|
|
59
|
+
}
|
|
60
|
+
/** Masked view of one stored credential, safe to return to a settings page. */
|
|
61
|
+
interface CredentialEntry {
|
|
62
|
+
service: string;
|
|
63
|
+
envVar: string;
|
|
64
|
+
last4: string;
|
|
65
|
+
updatedAt: number;
|
|
66
|
+
principal?: string;
|
|
67
|
+
}
|
|
68
|
+
interface CredentialRotation {
|
|
69
|
+
rotated: number;
|
|
70
|
+
alreadyCurrent: number;
|
|
71
|
+
unreadable: number;
|
|
72
|
+
}
|
|
73
|
+
interface CredentialListing {
|
|
74
|
+
enabled: boolean;
|
|
75
|
+
entries: Array<{
|
|
76
|
+
service: string;
|
|
77
|
+
name: string;
|
|
78
|
+
last4?: string;
|
|
79
|
+
}>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The host's handle on the kernel's encrypted credential store. The kernel keeps the rows the host last listed, runs every
|
|
83
|
+
* operation (set, remove, rotate, resolution, masking) and records what changed; this handle lists the rows into
|
|
84
|
+
* it and applies the recorded writes to the host's medium, one operation at a time. A row the kernel cannot read fails
|
|
85
|
+
* `open` and every operation after it: nothing here reads a broken store as an empty one.
|
|
86
|
+
*/
|
|
87
|
+
declare class CredentialVault {
|
|
88
|
+
private readonly kernel;
|
|
89
|
+
private readonly rows;
|
|
90
|
+
private readonly listeners;
|
|
91
|
+
private queue;
|
|
92
|
+
private broken;
|
|
93
|
+
private constructor();
|
|
94
|
+
/** List the host's rows into the kernel and read them; rejects naming the rows it cannot read. */
|
|
95
|
+
static open(kernel: CredentialVaultKernel, rows: CredentialRowsPort): Promise<CredentialVault>;
|
|
96
|
+
/** True when a valid master key is present (writes and decryption enabled). */
|
|
97
|
+
get enabled(): boolean;
|
|
98
|
+
/** Subscribe to credential changes; returns an unsubscribe function. */
|
|
99
|
+
subscribe(listener: (principal?: string) => void): () => void;
|
|
100
|
+
private notify;
|
|
101
|
+
private reload;
|
|
102
|
+
private current;
|
|
103
|
+
private apply;
|
|
104
|
+
/** One operation at a time: the kernel runs it, then its writes reach the medium before the next begins. */
|
|
105
|
+
private serial;
|
|
106
|
+
private exclusive;
|
|
107
|
+
/** Resolve one credential by name (warmed values only). */
|
|
108
|
+
resolve(envVar: string, principal?: string): string | undefined;
|
|
109
|
+
/** The non-secret account label stored in the clear beside a credential's ciphertext; undefined when its row carries none. */
|
|
110
|
+
label(envVar: string, principal?: string): string | undefined;
|
|
111
|
+
/** All app-wide values as an env-shaped map, for merging over the process env. */
|
|
112
|
+
snapshotEnv(): Record<string, string>;
|
|
113
|
+
/** Masked entries for display — never includes plaintext. */
|
|
114
|
+
entries(principal?: string): CredentialEntry[];
|
|
115
|
+
/** Whether the store can encrypt and the service and name of every app-wide row. */
|
|
116
|
+
listing(): CredentialListing;
|
|
117
|
+
/** Upsert one credential; `label` is a non-secret account name kept in the clear beside it, left out it stays as it is. */
|
|
118
|
+
set(service: string, envVar: string, value: string, principal?: string, label?: string): Promise<CredentialEntry>;
|
|
119
|
+
/** Replace the value of a credential already stored, keeping its service (a rotated refresh token). */
|
|
120
|
+
replace(envVar: string, value: string, principal?: string): Promise<CredentialEntry>;
|
|
121
|
+
/** Keep `value` as the credential until it is forgotten, creating it when absent. */
|
|
122
|
+
persist(envVar: string, value: string, principal?: string, label?: string): Promise<CredentialEntry>;
|
|
123
|
+
/** Delete one credential row; whether one existed. */
|
|
124
|
+
remove(envVar: string, principal?: string): Promise<boolean>;
|
|
125
|
+
private readonly flights;
|
|
126
|
+
private readonly turns;
|
|
127
|
+
private post;
|
|
128
|
+
private finish;
|
|
129
|
+
/** Exchange `grant` at its token endpoint through `post` and keep the result as the credential: the kernel builds the request and settles the reply, the host only sends. */
|
|
130
|
+
connect(grant: CredentialGrantWire, post: TokenEndpointPost): Promise<{
|
|
131
|
+
ok: CredentialStanding;
|
|
132
|
+
} | {
|
|
133
|
+
error: ConnectFailure;
|
|
134
|
+
}>;
|
|
135
|
+
/** The credential `envVar` for `principal`, refreshed first through `post` when it is past its expiry; concurrent resolves share one refresh. Undefined when nothing is held, nothing can renew it, or the provider refused (which drops the row). */
|
|
136
|
+
resolveFresh(envVar: string, principal: string | undefined, post: TokenEndpointPost): Promise<string | undefined>;
|
|
137
|
+
/** Re-encrypt every row under the current master key; a row the kernel cannot read fails it before any row changes. */
|
|
138
|
+
rotate(): Promise<CredentialRotation>;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export { CredentialExchangeError, CredentialVault };
|
|
142
|
+
export type { CredentialEntry, CredentialListing, CredentialRotation, CredentialRowsPort, CredentialVaultKernel, CredentialVaultModule, TokenEndpointPost, TokenReply, TokenRequest };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CredentialExchangeError, CredentialVault } from '../chunk-DFDNHVDW.js';
|
|
@@ -3,10 +3,7 @@ import { EventPayload } from '@almadar/core';
|
|
|
3
3
|
import '../service/default-call-service.js';
|
|
4
4
|
import '../service/service-provider.js';
|
|
5
5
|
import '../kernel/program-effects.js';
|
|
6
|
-
import '
|
|
7
|
-
import '../runtime/effects/composition/event-wiring.js';
|
|
8
|
-
import '../runtime/effects/composition/layout-strategy.js';
|
|
9
|
-
import '../runtime/effects/composition/pipe.js';
|
|
6
|
+
import '@almadar/core/kernel-wire';
|
|
10
7
|
|
|
11
8
|
/**
|
|
12
9
|
* EventBus - Platform-Agnostic Pub/Sub Implementation
|
package/dist/events/EventBus.js
CHANGED