@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,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';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The in-flight `call-service` registry of ONE running app: a call declared
|
|
3
|
+
* with a `key` registers here for as long as it runs, and `cancel-call` aborts
|
|
4
|
+
* every call running under that key. One instance is shared by every transition of the app.
|
|
5
|
+
*/
|
|
6
|
+
type KeyedCallOutcome<T> = {
|
|
7
|
+
cancelled: true;
|
|
8
|
+
} | {
|
|
9
|
+
cancelled: false;
|
|
10
|
+
value: T;
|
|
11
|
+
};
|
|
12
|
+
interface KeyedCallLease {
|
|
13
|
+
signal: AbortSignal;
|
|
14
|
+
release(): void;
|
|
15
|
+
}
|
|
16
|
+
declare class InFlightCalls {
|
|
17
|
+
private readonly calls;
|
|
18
|
+
/** Whether a call started with `key` is still running. */
|
|
19
|
+
inFlight(key: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Run `work` registered under `key`, handing it the abort signal; `work` must settle promptly once the
|
|
22
|
+
* signal aborts (see `untilAborted`). The call is cancelled when the signal was aborted by the time
|
|
23
|
+
* `work` settles, whatever it settled with.
|
|
24
|
+
*/
|
|
25
|
+
run<T>(key: string, work: (signal: AbortSignal) => Promise<T>): Promise<KeyedCallOutcome<T>>;
|
|
26
|
+
reserve(key: string): KeyedCallLease | undefined;
|
|
27
|
+
private track;
|
|
28
|
+
cancelAll(): void;
|
|
29
|
+
/** Abort every call running under `key`; false (a no-op) when none is. */
|
|
30
|
+
cancel(key: string): boolean;
|
|
31
|
+
}
|
|
32
|
+
/** `promise`, or a rejection as soon as `signal` aborts: a provider that ignores the signal is not waited for. */
|
|
33
|
+
declare function untilAborted<T>(signal: AbortSignal, promise: Promise<T>): Promise<T>;
|
|
34
|
+
|
|
35
|
+
export { InFlightCalls, untilAborted };
|
|
36
|
+
export type { KeyedCallLease, KeyedCallOutcome };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { InFlightCalls, untilAborted } from '../chunk-MZKIL5IN.js';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { OnDeviceFailureKind, OnDeviceFailurePayload, OnDeviceModelPorts } from '@almadar/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `browser/prompt` and `browser/embed`: the host's on-device model and embedder behind one contract, shared by the
|
|
5
|
+
* interpreter (`EffectExecutor`) and the kernel host (`answerRequest`). A host with no port fails `unconfigured`, a
|
|
6
|
+
* model that cannot answer now fails `unavailable`, and one that errors fails `failed`.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
declare const NO_ON_DEVICE_MODEL = "browser/prompt: no on-device model is wired into this host";
|
|
10
|
+
declare const NO_ON_DEVICE_EMBEDDER = "browser/embed: no on-device embedder is wired into this host";
|
|
11
|
+
/** An on-device call that gave no answer; `payload` is what the failure route receives. */
|
|
12
|
+
declare class OnDeviceModelFailure extends Error {
|
|
13
|
+
readonly kind: OnDeviceFailureKind;
|
|
14
|
+
readonly payload: OnDeviceFailurePayload;
|
|
15
|
+
constructor(kind: OnDeviceFailureKind, message: string, key: string | null);
|
|
16
|
+
}
|
|
17
|
+
/** The reply text of one prompt; the schema text must be a JSON object. */
|
|
18
|
+
declare function promptOnDevice(ports: OnDeviceModelPorts | undefined, text: string, schemaText: string, key: string | null, signal?: AbortSignal): Promise<string>;
|
|
19
|
+
/** One vector per text, in input order; an empty list is answered without asking the embedder. */
|
|
20
|
+
declare function embedOnDevice(ports: OnDeviceModelPorts | undefined, texts: readonly string[], key: string | null, signal?: AbortSignal): Promise<number[][]>;
|
|
21
|
+
|
|
22
|
+
export { NO_ON_DEVICE_EMBEDDER, NO_ON_DEVICE_MODEL, OnDeviceModelFailure, embedOnDevice, promptOnDevice };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NO_ON_DEVICE_EMBEDDER, NO_ON_DEVICE_MODEL, OnDeviceModelFailure, embedOnDevice, promptOnDevice } from '../chunk-FWA5K7Q2.js';
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { IEventBus, RuntimeEvent, EventListener, Unsubscribe } from '../runtime/types.js';
|
|
2
|
+
import { EventPayload } from '@almadar/core';
|
|
3
|
+
import '../service/default-call-service.js';
|
|
4
|
+
import '../service/service-provider.js';
|
|
5
|
+
import '../kernel/program-effects.js';
|
|
6
|
+
import '@almadar/core/kernel-wire';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* EventBus - Platform-Agnostic Pub/Sub Implementation
|
|
10
|
+
*
|
|
11
|
+
* Pure TypeScript event bus for cross-trait communication.
|
|
12
|
+
* Works on both client (browser) and server (Node.js).
|
|
13
|
+
*
|
|
14
|
+
* @packageDocumentation
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* EventBus - Simple pub/sub event bus
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const bus = new EventBus({ debug: true });
|
|
23
|
+
*
|
|
24
|
+
* // Subscribe
|
|
25
|
+
* const unsub = bus.on('ORDER_CONFIRMED', (event) => {
|
|
26
|
+
* log.debug('order-confirmed', { orderId: event.payload?.orderId });
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* // Emit
|
|
30
|
+
* bus.emit('ORDER_CONFIRMED', { orderId: '123' });
|
|
31
|
+
*
|
|
32
|
+
* // Unsubscribe
|
|
33
|
+
* unsub();
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
declare class EventBus implements IEventBus {
|
|
37
|
+
private listeners;
|
|
38
|
+
/** Maximum recursion depth before circuit breaker activates (RCG-05) */
|
|
39
|
+
private maxDepth;
|
|
40
|
+
/** Current emission depth for circular loop detection */
|
|
41
|
+
private depth;
|
|
42
|
+
constructor(options?: {
|
|
43
|
+
debug?: boolean;
|
|
44
|
+
maxDepth?: number;
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* Emit an event to all registered listeners.
|
|
48
|
+
*
|
|
49
|
+
* Includes circuit breaker (RCG-05): if emit is called recursively
|
|
50
|
+
* beyond `maxDepth`, the event is dropped and an error is logged.
|
|
51
|
+
* This prevents infinite loops from circular emit/listen chains.
|
|
52
|
+
*/
|
|
53
|
+
emit(type: string, payload?: EventPayload, source?: RuntimeEvent['source'], routingKey?: string): void;
|
|
54
|
+
/**
|
|
55
|
+
* Subscribe to an event type
|
|
56
|
+
*/
|
|
57
|
+
on(type: string, listener: EventListener): Unsubscribe;
|
|
58
|
+
/**
|
|
59
|
+
* Subscribe to ALL events (wildcard listener)
|
|
60
|
+
* Useful for event tracking, logging, debugging
|
|
61
|
+
*/
|
|
62
|
+
onAny(listener: EventListener): Unsubscribe;
|
|
63
|
+
/**
|
|
64
|
+
* Check if there are listeners for an event type
|
|
65
|
+
*/
|
|
66
|
+
hasListeners(type: string): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Get all registered event types
|
|
69
|
+
*/
|
|
70
|
+
getRegisteredEvents(): string[];
|
|
71
|
+
/**
|
|
72
|
+
* Clear all listeners
|
|
73
|
+
*/
|
|
74
|
+
clear(): void;
|
|
75
|
+
/**
|
|
76
|
+
* Get listener count for an event type (for testing)
|
|
77
|
+
*/
|
|
78
|
+
getListenerCount(type: string): number;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Create a new EventBus instance
|
|
82
|
+
*/
|
|
83
|
+
declare function createEventBus(options?: {
|
|
84
|
+
debug?: boolean;
|
|
85
|
+
}): IEventBus;
|
|
86
|
+
|
|
87
|
+
export { EventBus, createEventBus };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { EventBus, createEventBus } from '../chunk-SOQDEPME.js';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { OrbitalId, TraitId, EventId, BusEventSource } from '@almadar/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* emit-stamp — the ONE emit-source stamper.
|
|
5
|
+
*
|
|
6
|
+
* Extracted from `OrbitalServerRuntime.executeEffects`'s emit handler so
|
|
7
|
+
* every execution path (stateful server, stateless per-request, any future
|
|
8
|
+
* emitter) stamps emitted events identically. G-RUNTIME-030 was exactly
|
|
9
|
+
* this decision existing twice with different outcomes: a stamp missing
|
|
10
|
+
* the V4 `traitId`/`orbitalId`/`eventId` triple silently never matches an
|
|
11
|
+
* id-scoped `listens` matcher (`buildSourceMatcher`), and the fan-out dies
|
|
12
|
+
* without an error.
|
|
13
|
+
*
|
|
14
|
+
* All four ids are optional dual-carry: absent → name-only stamp (legacy,
|
|
15
|
+
* name-keyed routing), present → id-keyed routing via `eventRouteKey`.
|
|
16
|
+
*
|
|
17
|
+
* @packageDocumentation
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
interface StampEmitIdentity {
|
|
21
|
+
/** The dispatching orbital's declared name (name-stamp fallback). */
|
|
22
|
+
orbitalName: string;
|
|
23
|
+
/** The emitting trait's declared name (name-stamp fallback). */
|
|
24
|
+
traitName: string;
|
|
25
|
+
/** V4 ids, when the schema carries them. */
|
|
26
|
+
orbitalId?: OrbitalId;
|
|
27
|
+
traitId?: TraitId;
|
|
28
|
+
/**
|
|
29
|
+
* The emitting trait's `emits[]` contract entry id for THIS event — the
|
|
30
|
+
* single canonical event id (mirrors `resolveSourceEmitEventId` on the
|
|
31
|
+
* listen side; the listener's own declared id can be stale, the emit
|
|
32
|
+
* contract's is what the emitter actually stamps).
|
|
33
|
+
*/
|
|
34
|
+
emitContractEventId?: EventId;
|
|
35
|
+
/** The originating tab's client id, when this emit is client-driven. */
|
|
36
|
+
originClientId?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Fill a bus-event source stamp with the V4 identity triple + origin.
|
|
40
|
+
* Mutates and returns `source` when given (handlers pass their closure
|
|
41
|
+
* source through); otherwise synthesizes one from the lexical identity.
|
|
42
|
+
* Never overwrites a field already set on the stamp.
|
|
43
|
+
*/
|
|
44
|
+
declare function stampEmitSource(source: BusEventSource | undefined, identity: StampEmitIdentity): BusEventSource;
|
|
45
|
+
|
|
46
|
+
export { stampEmitSource };
|
|
47
|
+
export type { StampEmitIdentity };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { stampEmitSource } from '../chunk-64IH2SMY.js';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export { AccessTokenProvider, COMPRESSED_BODY_MIN_BYTES, EventTransport, EventTransportRegisterResult, HostDispatchListener, HttpTransportOptions, InProcessTransportOptions, OrbitalEvaluator, PushTarget, SessionEndedError, TransportStatusError, createHttpTransport, createInProcessTransport, deriveCarriesCircuitState, encodeJsonBody } from './client/EventTransport.js';
|
|
2
|
+
export { AwaitingRegistry } from './client/awaiting.js';
|
|
3
|
+
export { ChannelMessage, ChannelTransportOptions, ServedChannel, TransportChannel, createChannelTransport, holdUntilServed, serveChannel } from './client/channel-transport.js';
|
|
4
|
+
export { CircuitStore, FrameOutcome, TraitSnapshot, createMemoryCircuitStore } from './client/circuit-store.js';
|
|
5
|
+
export { ClientDispatchHooks, ClientEmitOutcome, ClientKernel, ClientKernelOutcome, ClientMountHooks, ClientMountOutcome, LocalFoldKernel } from './client/client-kernel.js';
|
|
6
|
+
export { dispatchDeclaredInput } from './client/declared-input-dispatch.js';
|
|
7
|
+
export { InboundContract, dispatchInbound } from './client/inbound-dispatch.js';
|
|
8
|
+
export { FramesSince, LocalFoldOptions, createLocalFold, paintFrames, paintResponse, paintStates, traceResponse } from './client/local-fold.js';
|
|
9
|
+
export { DEFAULT_THEME_KEY, appNavItems, inlineNavItems, sigilThemeKey } from './client/render-sigils.js';
|
|
10
|
+
export { StateBook, createInitialTraitState, findInitialState } from './client/state-book.js';
|
|
11
|
+
export { TraitMountError } from './client/trait-mount-error.js';
|
|
12
|
+
export { RollbackCause, TraitState, TransitionObserver } from './client/trait-types.js';
|
|
13
|
+
export { CREDENTIAL_MASTER_KEY_ENV, CREDENTIAL_PREVIOUS_MASTER_KEY_ENV, STORE_BOOTSTRAP_ENV_VARS, allCredentialEnvVars } from './credentials/env-vars.js';
|
|
14
|
+
export { CREDENTIALS_SOURCE_ENV, CredentialMode, CredentialModeControl, CredentialScopeStorage, credentialModeFromEnv, credentialsFromStoreOnly, getEffectiveCredentialStore, getInstalledCredentialStore, getModeControl, installCredentialScopeStorage, installCredentialStore, installModeControl, resolveCredentialRef, runWithCredentialScope, uninstallCredentialStore } from './credentials/scope.js';
|
|
15
|
+
export { CredentialEntry, CredentialExchangeError, CredentialListing, CredentialRotation, CredentialRowsPort, CredentialVault, CredentialVaultKernel, CredentialVaultModule, TokenEndpointPost, TokenReply, TokenRequest } from './credentials/vault.js';
|
|
16
|
+
export { InFlightCalls, KeyedCallLease, KeyedCallOutcome, untilAborted } from './effects/in-flight-calls.js';
|
|
17
|
+
export { NO_ON_DEVICE_EMBEDDER, NO_ON_DEVICE_MODEL, OnDeviceModelFailure, embedOnDevice, promptOnDevice } from './effects/on-device-model.js';
|
|
18
|
+
export { EventBus, createEventBus } from './events/EventBus.js';
|
|
19
|
+
export { StampEmitIdentity, stampEmitSource } from './events/emit-stamp.js';
|
|
20
|
+
export { decodeDueTicks, decodeNext, decodeProgress, decodeResolveProgress } from './kernel/decode.js';
|
|
21
|
+
export { KernelEngine, KernelEvaluation, ProgramlessContract, evaluateOnKernel, kernelRequest } from './kernel/engine.js';
|
|
22
|
+
export { FrameApplied, FrameDispatch, FramePostPort, TickEffects, applyFrame, decodeFrame } from './kernel/frame-applier.js';
|
|
23
|
+
export { DeferredCallOutcome, EventRequestParser, HostAskError, HostAskFailureKind, HostAskOutcome, HostAskReturn, HostAudioAsk, HostConsentAnswer, HostConsentRequest, HostSignInAnswer, HostSignInRequest, KernelAnswerScope, KernelCallService, KernelHostActions, KernelHostPorts, SubstrateStreamSource, answerRequest, completeTls, consentFromRedirect, declareCapabilities, finishTls, hostAskReturn, kernelEventRequestParser, parseConsentRequest, parseSignInRequest, performHostAnswer, performHostAsk, writeRows } from './kernel/host.js';
|
|
24
|
+
export { CredentialAdminPort, CredentialConnectPort, EnvTailsPort, RANDOM_BYTES_MAX, RandomSource, SecretPorts, SecretPortsOptions, SecretStore, SecretStoreHost, base64Standard, base64Url, createBrowserSecretPorts, createCredentialAdminPort, createCredentialConnectPort, createSecretPorts, createSecretStore, credentialForgetPayload, credentialStatusPayload, envTailsOf, randomBytesPayload, systemRandom, userCredentialKey } from './kernel/secret-ports.js';
|
|
25
|
+
export { LaneHeldByParkedDispatch } from './kernel/lane.js';
|
|
26
|
+
export { AnchoredPath, OsAnchorProblem, OsAnchors, OsCompletionEvent, OsCompletionMatchers, OsCompletionPort, OsDesktopKind, OsFsMode, OsGrantKernel, OsGrantMatchers, OsGrantPort, OsHostPort, OsNetKind, OsRequirement, OsStdioKind, OsSysKind, OsTlsKernel, OsTlsPort, OsTlsStep, anchoredGrants, expandAnchor, kernelOsCompletions, kernelOsGrants, kernelOsTls } from './kernel/os-port.js';
|
|
27
|
+
export { createFetchOsHost } from './kernel/os-fetch-port.js';
|
|
28
|
+
export { PROGRAM_EFFECTS, ProgramEffectName, ProgramEffectOutcome, ProgramValidationReport, StepRequest, isProgramEffect } from './kernel/program-effects.js';
|
|
29
|
+
export { FiredByOrbital, KernelModule, KernelServerClass, KernelServerHandle } from './kernel/wire.js';
|
|
30
|
+
export { loadLazyPage } from './loader/lazy-page.js';
|
|
31
|
+
export { FetchSchemaLoader } from './loader/fetch-loader.js';
|
|
32
|
+
export { BaseLoaderOptions, ImportChainLike, LoadResult, LoadedOrbital, LoadedSchema, SchemaLoader } from './loader/schema-loader.js';
|
|
33
|
+
export { bindDeclaredCollections } from './runtime/entities/declaredCollections.js';
|
|
34
|
+
export { LocalKernelOptions, LocalStoreTransportOptions, createLocalStoreTransport, localStorePersistence, openLocalKernel, resolveLocalRows } from './runtime/evaluation/local-store-transport.js';
|
|
35
|
+
export { ResidenceTransportOptions, createResidenceTransport } from './runtime/evaluation/residence-transport.js';
|
|
36
|
+
export { routeByEntity } from './runtime/evaluation/routed-persistence.js';
|
|
37
|
+
export { eventRouteKey } from './runtime/events/identity/routing.js';
|
|
38
|
+
export { BindingContext, Effect, EffectHandlers, EffectResult, EvaluationContextExtensions, EventListener, IEventBus, PatternProps, RuntimeEvent, Unsubscribe } from './runtime/types.js';
|
|
39
|
+
export { CallServiceHandler, ServiceMessageRoute, defaultCallService } from './service/default-call-service.js';
|
|
40
|
+
export { ServiceCallContext, ServiceCallError, ServiceCallErrorCode, ServiceProvider, callRegisteredService, registerServiceProvider, registeredServices, unregisterServiceProvider } from './service/service-provider.js';
|
|
41
|
+
export { NativeMemoryPersistenceAdapter, NativeMemoryWriteError } from './persistence/native-memory.js';
|
|
42
|
+
export { CallRoutesWire, CallSiteWire, CallerWire, IoAnswerWire, IoReplyWire, IoRequestWire, NextWire, PendingRequestWire, PlayedStep, ResolveProgressWire, ServerProgressWire, Settled, SubstrateFailureWire, decodeIoRequestWire as decodeRequest } from '@almadar/core/kernel-wire';
|
|
43
|
+
export { EntityRow, EventPayload, FetchResult, ServiceParams } from '@almadar/core';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import './chunk-ELBLT2HZ.js';
|
|
2
|
+
export { NativeMemoryPersistenceAdapter, NativeMemoryWriteError } from './chunk-7SDV3QWR.js';
|
|
3
|
+
export { bindDeclaredCollections } from './chunk-BAS26HBN.js';
|
|
4
|
+
export { createLocalStoreTransport, localStorePersistence, openLocalKernel, resolveLocalRows } from './chunk-MU335ZA4.js';
|
|
5
|
+
export { defaultCallService } from './chunk-4SEK5ER2.js';
|
|
6
|
+
export { ServiceCallError, callRegisteredService, registerServiceProvider, registeredServices, unregisterServiceProvider } from './chunk-UBN5JJKZ.js';
|
|
7
|
+
export { createResidenceTransport } from './chunk-V4EMDPCO.js';
|
|
8
|
+
export { routeByEntity } from './chunk-O57GKTYU.js';
|
|
9
|
+
export { eventRouteKey } from './chunk-BY5G4225.js';
|
|
10
|
+
import './chunk-LYFIQPXX.js';
|
|
11
|
+
export { createFetchOsHost } from './chunk-625EP7W2.js';
|
|
12
|
+
export { anchoredGrants, expandAnchor, kernelOsCompletions, kernelOsGrants, kernelOsTls } from './chunk-BOVU4TCQ.js';
|
|
13
|
+
import './chunk-EZZYLTWY.js';
|
|
14
|
+
export { FetchSchemaLoader } from './chunk-57SBCUSM.js';
|
|
15
|
+
export { loadLazyPage } from './chunk-XXWNMJI6.js';
|
|
16
|
+
export { EventBus, createEventBus } from './chunk-SOQDEPME.js';
|
|
17
|
+
export { stampEmitSource } from './chunk-64IH2SMY.js';
|
|
18
|
+
export { KernelEngine, evaluateOnKernel, kernelRequest } from './chunk-I3TKINSO.js';
|
|
19
|
+
export { LaneHeldByParkedDispatch } from './chunk-NU6LVKGS.js';
|
|
20
|
+
export { decodeDueTicks, decodeNext, decodeProgress, decodeIoRequestWire as decodeRequest, decodeResolveProgress } from './chunk-X6W44WHO.js';
|
|
21
|
+
export { applyFrame, decodeFrame } from './chunk-NTFQ36UN.js';
|
|
22
|
+
export { HostAskError, answerRequest, completeTls, consentFromRedirect, declareCapabilities, finishTls, hostAskReturn, kernelEventRequestParser, parseConsentRequest, parseSignInRequest, performHostAnswer, performHostAsk, writeRows } from './chunk-7WB6VWRK.js';
|
|
23
|
+
export { PROGRAM_EFFECTS, isProgramEffect } from './chunk-WGCWJOT2.js';
|
|
24
|
+
export { RANDOM_BYTES_MAX, base64Standard, base64Url, createBrowserSecretPorts, createCredentialAdminPort, createCredentialConnectPort, createSecretPorts, createSecretStore, credentialForgetPayload, credentialStatusPayload, envTailsOf, randomBytesPayload, systemRandom, userCredentialKey } from './chunk-ZUSM4VW4.js';
|
|
25
|
+
export { NO_ON_DEVICE_EMBEDDER, NO_ON_DEVICE_MODEL, OnDeviceModelFailure, embedOnDevice, promptOnDevice } from './chunk-FWA5K7Q2.js';
|
|
26
|
+
export { DEFAULT_THEME_KEY, appNavItems, inlineNavItems, sigilThemeKey } from './chunk-UP6GGGAN.js';
|
|
27
|
+
export { TraitMountError } from './chunk-IOPUS6Q5.js';
|
|
28
|
+
import './chunk-P53CKOME.js';
|
|
29
|
+
export { CREDENTIAL_MASTER_KEY_ENV, CREDENTIAL_PREVIOUS_MASTER_KEY_ENV, STORE_BOOTSTRAP_ENV_VARS, allCredentialEnvVars } from './chunk-VNGXRYFF.js';
|
|
30
|
+
export { CREDENTIALS_SOURCE_ENV, credentialModeFromEnv, credentialsFromStoreOnly, getEffectiveCredentialStore, getInstalledCredentialStore, getModeControl, installCredentialScopeStorage, installCredentialStore, installModeControl, resolveCredentialRef, runWithCredentialScope, uninstallCredentialStore } from './chunk-HLOUDLPI.js';
|
|
31
|
+
export { CredentialExchangeError, CredentialVault } from './chunk-DFDNHVDW.js';
|
|
32
|
+
export { InFlightCalls, untilAborted } from './chunk-MZKIL5IN.js';
|
|
33
|
+
export { COMPRESSED_BODY_MIN_BYTES, SessionEndedError, TransportStatusError, createHttpTransport, createInProcessTransport, deriveCarriesCircuitState, encodeJsonBody } from './chunk-UD2CXYSJ.js';
|
|
34
|
+
export { createChannelTransport, holdUntilServed, serveChannel } from './chunk-SKLMWHQD.js';
|
|
35
|
+
export { createMemoryCircuitStore } from './chunk-N7HYNKK6.js';
|
|
36
|
+
export { StateBook, createInitialTraitState, findInitialState } from './chunk-A2JJT4GA.js';
|
|
37
|
+
export { AwaitingRegistry } from './chunk-HC6ERSAH.js';
|
|
38
|
+
import './chunk-LZIOTBFX.js';
|
|
39
|
+
export { dispatchDeclaredInput } from './chunk-LKWYCYX5.js';
|
|
40
|
+
export { dispatchInbound } from './chunk-P2N6K2IV.js';
|
|
41
|
+
export { createLocalFold, paintFrames, paintResponse, paintStates, traceResponse } from './chunk-QCJWPXLH.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NextWire, ServerProgressWire, ResolveProgressWire } from '@almadar/core/kernel-wire';
|
|
2
|
+
export { decodeIoRequestWire as decodeRequest } from '@almadar/core/kernel-wire';
|
|
3
|
+
import { FiredByOrbital } from './wire.js';
|
|
4
|
+
import '@almadar/core';
|
|
5
|
+
|
|
6
|
+
/** Decoders for what the kernel hands back as JSON: the generated decoders of `@almadar/core/kernel-wire`, which throw naming the failing path. */
|
|
7
|
+
|
|
8
|
+
declare function decodeProgress(json: string): ServerProgressWire;
|
|
9
|
+
declare function decodeNext(json: string): NextWire | null;
|
|
10
|
+
declare function decodeResolveProgress(json: string): ResolveProgressWire;
|
|
11
|
+
declare function decodeDueTicks(json: string): FiredByOrbital;
|
|
12
|
+
|
|
13
|
+
export { decodeDueTicks, decodeNext, decodeProgress, decodeResolveProgress };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { decodeDueTicks, decodeNext, decodeProgress, decodeIoRequestWire as decodeRequest, decodeResolveProgress } from '../chunk-X6W44WHO.js';
|