@semiont/sdk 0.5.4 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/index.d.ts +1750 -52
  2. package/dist/index.js +18 -3
  3. package/dist/index.js.map +1 -1
  4. package/package.json +5 -3
  5. package/dist/awaitable.d.ts +0 -103
  6. package/dist/awaitable.d.ts.map +0 -1
  7. package/dist/bus-request.d.ts +0 -18
  8. package/dist/bus-request.d.ts.map +0 -1
  9. package/dist/cache.d.ts +0 -57
  10. package/dist/cache.d.ts.map +0 -1
  11. package/dist/client.d.ts +0 -138
  12. package/dist/client.d.ts.map +0 -1
  13. package/dist/index.d.ts.map +0 -1
  14. package/dist/namespaces/admin.d.ts +0 -27
  15. package/dist/namespaces/admin.d.ts.map +0 -1
  16. package/dist/namespaces/auth.d.ts +0 -26
  17. package/dist/namespaces/auth.d.ts.map +0 -1
  18. package/dist/namespaces/beckon.d.ts +0 -12
  19. package/dist/namespaces/beckon.d.ts.map +0 -1
  20. package/dist/namespaces/bind.d.ts +0 -11
  21. package/dist/namespaces/bind.d.ts.map +0 -1
  22. package/dist/namespaces/browse.d.ts +0 -111
  23. package/dist/namespaces/browse.d.ts.map +0 -1
  24. package/dist/namespaces/frame.d.ts +0 -29
  25. package/dist/namespaces/frame.d.ts.map +0 -1
  26. package/dist/namespaces/gather.d.ts +0 -16
  27. package/dist/namespaces/gather.d.ts.map +0 -1
  28. package/dist/namespaces/job.d.ts +0 -32
  29. package/dist/namespaces/job.d.ts.map +0 -1
  30. package/dist/namespaces/mark.d.ts +0 -27
  31. package/dist/namespaces/mark.d.ts.map +0 -1
  32. package/dist/namespaces/match.d.ts +0 -15
  33. package/dist/namespaces/match.d.ts.map +0 -1
  34. package/dist/namespaces/types.d.ts +0 -438
  35. package/dist/namespaces/types.d.ts.map +0 -1
  36. package/dist/namespaces/yield.d.ts +0 -23
  37. package/dist/namespaces/yield.d.ts.map +0 -1
  38. package/dist/session/errors.d.ts +0 -18
  39. package/dist/session/errors.d.ts.map +0 -1
  40. package/dist/session/http-session-factory.d.ts +0 -15
  41. package/dist/session/http-session-factory.d.ts.map +0 -1
  42. package/dist/session/knowledge-base.d.ts +0 -95
  43. package/dist/session/knowledge-base.d.ts.map +0 -1
  44. package/dist/session/open-resource.d.ts +0 -22
  45. package/dist/session/open-resource.d.ts.map +0 -1
  46. package/dist/session/registry.d.ts +0 -31
  47. package/dist/session/registry.d.ts.map +0 -1
  48. package/dist/session/semiont-browser.d.ts +0 -141
  49. package/dist/session/semiont-browser.d.ts.map +0 -1
  50. package/dist/session/semiont-session.d.ts +0 -210
  51. package/dist/session/semiont-session.d.ts.map +0 -1
  52. package/dist/session/session-factory.d.ts +0 -31
  53. package/dist/session/session-factory.d.ts.map +0 -1
  54. package/dist/session/session-signals.d.ts +0 -40
  55. package/dist/session/session-signals.d.ts.map +0 -1
  56. package/dist/session/session-storage.d.ts +0 -41
  57. package/dist/session/session-storage.d.ts.map +0 -1
  58. package/dist/session/storage.d.ts +0 -52
  59. package/dist/session/storage.d.ts.map +0 -1
  60. package/dist/session/testing.d.ts +0 -7
  61. package/dist/session/testing.d.ts.map +0 -1
  62. package/dist/state/flows/beckon-state-unit.d.ts +0 -22
  63. package/dist/state/flows/beckon-state-unit.d.ts.map +0 -1
  64. package/dist/state/flows/gather-state-unit.d.ts +0 -12
  65. package/dist/state/flows/gather-state-unit.d.ts.map +0 -1
  66. package/dist/state/flows/mark-state-unit.d.ts +0 -17
  67. package/dist/state/flows/mark-state-unit.d.ts.map +0 -1
  68. package/dist/state/flows/match-state-unit.d.ts +0 -7
  69. package/dist/state/flows/match-state-unit.d.ts.map +0 -1
  70. package/dist/state/flows/yield-state-unit.d.ts +0 -25
  71. package/dist/state/flows/yield-state-unit.d.ts.map +0 -1
  72. package/dist/state/index.d.ts +0 -10
  73. package/dist/state/index.d.ts.map +0 -1
  74. package/dist/state/lib/search-pipeline.d.ts +0 -38
  75. package/dist/state/lib/search-pipeline.d.ts.map +0 -1
  76. package/dist/state/lib/state-unit.d.ts +0 -33
  77. package/dist/state/lib/state-unit.d.ts.map +0 -1
  78. package/dist/state/lib/worker-bus.d.ts +0 -21
  79. package/dist/state/lib/worker-bus.d.ts.map +0 -1
@@ -1,95 +0,0 @@
1
- /**
2
- * KnowledgeBase — a connection to a Semiont knowledge system.
3
- *
4
- * The KB type itself is uniform. The transport-shape variation lives in
5
- * the nested `endpoint` field, which is a discriminated union:
6
- *
7
- * - `endpoint.kind === 'http'` — a remote backend reached over HTTP+SSE.
8
- * Carries `host`/`port`/`protocol`.
9
- * - `endpoint.kind === 'local'` — an in-process knowledge system reached
10
- * via `LocalTransport` from
11
- * `@semiont/make-meaning`. Carries an
12
- * opaque `kbId` identifying the local
13
- * instance to the host process.
14
- *
15
- * Code that doesn't know how to make a transport (`SemiontSession`,
16
- * `SemiontBrowser`, the frontend KB list UI) treats `KnowledgeBase` as
17
- * uniform and never inspects `endpoint`. Code that *does* construct
18
- * transports (the transport-factory passed to `SemiontBrowser`,
19
- * `kbBackendUrl` for HTTP URL construction) inspects `endpoint.kind`
20
- * and dispatches.
21
- *
22
- * Each KB has its own session, its own credentials (where applicable),
23
- * and its own JWT (HTTP only). The user is "authenticated against KB X" —
24
- * never globally authenticated.
25
- */
26
- /** Fields shared by every KB regardless of endpoint kind. */
27
- export interface KnowledgeBase {
28
- id: string;
29
- label: string;
30
- email: string;
31
- gitBranch?: string;
32
- endpoint: KbEndpoint;
33
- }
34
- export type KbEndpoint = HttpEndpoint | LocalEndpoint;
35
- export interface HttpEndpoint {
36
- kind: 'http';
37
- host: string;
38
- port: number;
39
- protocol: 'http' | 'https';
40
- }
41
- export interface LocalEndpoint {
42
- kind: 'local';
43
- /** Opaque identifier for the in-process KB instance the host has loaded. */
44
- kbId: string;
45
- }
46
- /**
47
- * Input shape for adding a new KB. The id is generated by the provider.
48
- */
49
- export type NewKnowledgeBase = Omit<KnowledgeBase, 'id'>;
50
- /**
51
- * Status of the locally-stored credential for a KB. Derived from the
52
- * presence and validity of the JWT in session storage.
53
- */
54
- export type KbSessionStatus = 'authenticated' | 'expired' | 'signed-out' | 'unreachable';
55
- /**
56
- * Construct a `KnowledgeBase` for an HTTP-backed Semiont backend without
57
- * spelling out the nested `endpoint` literal. Convenience for tests,
58
- * worker bootstraps, and one-off scripts.
59
- *
60
- * ```ts
61
- * const kb = httpKb({
62
- * id: 'my-watcher',
63
- * label: 'My Watcher',
64
- * email: 'me@example.com',
65
- * host: 'localhost',
66
- * port: 4000,
67
- * protocol: 'http',
68
- * });
69
- * ```
70
- *
71
- * Equivalent to:
72
- *
73
- * ```ts
74
- * const kb: KnowledgeBase = {
75
- * id, label, email,
76
- * endpoint: { kind: 'http', host, port, protocol },
77
- * };
78
- * ```
79
- *
80
- * UI hosts that have a structured form (host / port / protocol pickers)
81
- * already construct the literal directly — they don't need this helper.
82
- * Local-endpoint KBs construct the literal directly too; the local
83
- * endpoint shape (`{ kind: 'local', kbId }`) is one line and doesn't
84
- * earn a helper.
85
- */
86
- export declare function httpKb(opts: {
87
- id: string;
88
- label: string;
89
- email: string;
90
- host: string;
91
- port: number;
92
- protocol: 'http' | 'https';
93
- gitBranch?: string;
94
- }): KnowledgeBase;
95
- //# sourceMappingURL=knowledge-base.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"knowledge-base.d.ts","sourceRoot":"","sources":["../../src/session/knowledge-base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,6DAA6D;AAC7D,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,UAAU,CAAC;CACtB;AAED,MAAM,MAAM,UAAU,GAAG,YAAY,GAAG,aAAa,CAAC;AAEtD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,OAAO,CAAC;IACd,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;AAEzD;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,eAAe,GAAG,SAAS,GAAG,YAAY,GAAG,aAAa,CAAC;AAEzF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,aAAa,CAShB"}
@@ -1,22 +0,0 @@
1
- /**
2
- * OpenResource — a single entry in the open-resources list (tabs).
3
- *
4
- * The list itself lives on `SemiontBrowser.openResources$`. The CRUD
5
- * methods (`addOpenResource`, `removeOpenResource`, `updateOpenResourceName`,
6
- * `reorderOpenResources`) live on `SemiontBrowser` too.
7
- */
8
- export interface OpenResource {
9
- /** Unique identifier for the resource */
10
- id: string;
11
- /** Display name of the resource */
12
- name: string;
13
- /** Timestamp when the resource was opened */
14
- openedAt: number;
15
- /** Order/position for manual sorting (optional for backward compatibility) */
16
- order?: number;
17
- /** Media type for icon display (e.g., 'application/pdf', 'text/plain') */
18
- mediaType?: string;
19
- /** Working-tree URI (e.g. "file://docs/overview.md") — used as tooltip in navigation */
20
- storageUri?: string;
21
- }
22
- //# sourceMappingURL=open-resource.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"open-resource.d.ts","sourceRoot":"","sources":["../../src/session/open-resource.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,WAAW,YAAY;IAC3B,yCAAyC;IACzC,EAAE,EAAE,MAAM,CAAC;IAEX,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IAEb,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,CAAC;IAEjB,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,0EAA0E;IAC1E,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,wFAAwF;IACxF,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
@@ -1,31 +0,0 @@
1
- /**
2
- * Process-wide accessor for `SemiontBrowser`. Constructed lazily on the
3
- * first `getBrowser()` call and held for the host's lifetime — a single
4
- * instance owns the KB list, identity token, and active-session state,
5
- * so callers throughout the host get the same view of "which KB am I
6
- * talking to right now" regardless of where they pick it up.
7
- *
8
- * The caller provides a `SessionStorage` implementation and a
9
- * `SessionFactory` — both are environment-specific (browsers use
10
- * `WebBrowserStorage` + `createHttpSessionFactory()`, CLI/embedded
11
- * hosts use a filesystem adapter and possibly a local-process
12
- * factory, tests use `InMemorySessionStorage` and stubs). The first
13
- * call to `getBrowser` wins; subsequent calls return the cached
14
- * instance regardless of the options passed.
15
- */
16
- import { SemiontBrowser } from './semiont-browser';
17
- import type { SessionStorage } from './session-storage';
18
- import type { SessionFactory } from './session-factory';
19
- export interface GetBrowserOptions {
20
- /** Persistence adapter used to construct the singleton on first call. */
21
- storage: SessionStorage;
22
- /** Session factory used to build a `SemiontSession` per active KB. */
23
- sessionFactory: SessionFactory;
24
- }
25
- export declare function getBrowser(options: GetBrowserOptions): SemiontBrowser;
26
- /**
27
- * Test-only reset hook. Tests import this to clear the singleton between
28
- * runs. Production code must not import it.
29
- */
30
- export declare function __resetForTests(): Promise<void>;
31
- //# sourceMappingURL=registry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/session/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAIxD,MAAM,WAAW,iBAAiB;IAChC,yEAAyE;IACzE,OAAO,EAAE,cAAc,CAAC;IACxB,sEAAsE;IACtE,cAAc,EAAE,cAAc,CAAC;CAChC;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,cAAc,CAQrE;AAED;;;GAGG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAKrD"}
@@ -1,141 +0,0 @@
1
- /**
2
- * SemiontBrowser — top-level app-facing container for non-KB state.
3
- *
4
- * Holds the list of configured KBs, the active KB selection, the active
5
- * SemiontSession, the identity token, the open-resources list, and a
6
- * session-level error stream. Held as a process-wide instance for the
7
- * host's lifetime — see `getBrowser()` in `registry.ts` for the canonical
8
- * accessor.
9
- *
10
- * Transport-agnostic: the browser orchestrates session *lifecycle* but
11
- * delegates session *construction* to a `SessionFactory` injected at
12
- * construction. HTTP-backed apps pass `createHttpSessionFactory()` from
13
- * `@semiont/sdk`; in-process apps pass their own factory.
14
- *
15
- * Persistence goes through a `SessionStorage` adapter provided at
16
- * construction — the browser never touches `localStorage` or `window`
17
- * directly.
18
- */
19
- import { BehaviorSubject, Subject, type Observable } from 'rxjs';
20
- import { type EventMap } from '@semiont/core';
21
- import type { KnowledgeBase, KbSessionStatus, NewKnowledgeBase } from './knowledge-base';
22
- import type { OpenResource } from './open-resource';
23
- import { SemiontSession } from './semiont-session';
24
- import { SessionSignals } from './session-signals';
25
- import { SemiontSessionError } from './errors';
26
- import type { SessionStorage } from './session-storage';
27
- import type { SessionFactory } from './session-factory';
28
- export interface SemiontBrowserConfig {
29
- /** Persistence adapter. The browser reads/writes all persisted state via this. */
30
- storage: SessionStorage;
31
- /**
32
- * Builds a `SemiontSession` for a KB. The browser is transport-
33
- * agnostic — every HTTP-vs-local construction concern lives in the
34
- * factory. HTTP-backed apps pass `createHttpSessionFactory()` from
35
- * `@semiont/sdk`; a future in-process variant from `@semiont/make-meaning`
36
- * would expose its own factory.
37
- */
38
- sessionFactory: SessionFactory;
39
- }
40
- export declare class SemiontBrowser {
41
- readonly kbs$: BehaviorSubject<KnowledgeBase[]>;
42
- readonly activeKbId$: BehaviorSubject<string | null>;
43
- readonly activeSession$: BehaviorSubject<SemiontSession | null>;
44
- /**
45
- * Modal signals (session-expired / permission-denied) for the
46
- * currently-active session. Parallels `activeSession$` — always
47
- * non-null when `activeSession$` is non-null, always null when it
48
- * is. Extracted from the session itself so headless sessions
49
- * (workers, CLIs, tests) don't carry dead modal observables.
50
- * See [SessionSignals](./session-signals.ts).
51
- */
52
- readonly activeSignals$: BehaviorSubject<SessionSignals | null>;
53
- /**
54
- * True while a session is actively being constructed (setActiveKb /
55
- * signIn in flight, awaiting `session.ready`). Distinguishes the
56
- * "session about to arrive" intermediate state from "session
57
- * intentionally null" (after signOut, or when the active KB has no
58
- * stored credentials). UIs that want a loading spinner should gate
59
- * on this; otherwise they get stuck spinning after every signOut.
60
- */
61
- readonly sessionActivating$: BehaviorSubject<boolean>;
62
- readonly openResources$: BehaviorSubject<OpenResource[]>;
63
- readonly error$: Subject<SemiontSessionError>;
64
- readonly identityToken$: BehaviorSubject<string | null>;
65
- private readonly storage;
66
- private readonly sessionFactory;
67
- /**
68
- * App-scoped EventBus. Hosts UI-shell events that must work regardless
69
- * of whether a KB session is active: panel toggles, sidebar state,
70
- * tab reorders, routing, settings, etc. Disjoint from the per-session
71
- * bus inside `SemiontClient`, which carries KB-content events
72
- * (mark:*, beckon:*, gather:*, match:*, bind:*, yield:*, browse:click).
73
- */
74
- private readonly eventBus;
75
- private unsubscribeStorage;
76
- private disposed;
77
- private activating;
78
- constructor(config: SemiontBrowserConfig);
79
- /** Emit an event on the browser's app-scoped bus. */
80
- emit<K extends keyof EventMap>(channel: K, payload: EventMap[K]): void;
81
- /** Subscribe to an event; returns unsubscribe. */
82
- on<K extends keyof EventMap>(channel: K, handler: (payload: EventMap[K]) => void): () => void;
83
- /** Read-only observable for an app-scoped channel. */
84
- stream<K extends keyof EventMap>(channel: K): Observable<EventMap[K]>;
85
- /**
86
- * Set the app-level identity token. Sourced from whatever the host
87
- * environment uses for OAuth sessions (e.g. NextAuth in a browser app).
88
- * Should be called once from the host's startup-and-on-change site;
89
- * no other code should write to this slot.
90
- */
91
- setIdentityToken(token: string | null): void;
92
- addKb(input: NewKnowledgeBase, access: string, refresh: string): KnowledgeBase;
93
- removeKb(id: string): void;
94
- /**
95
- * Patch a KB in the list. Restricted to the common, endpoint-agnostic
96
- * fields (`label`, `email`, `gitBranch`) — the `endpoint` shape isn't
97
- * editable in place; remove and re-add to change the connection
98
- * target.
99
- */
100
- updateKb(id: string, updates: {
101
- label?: string;
102
- email?: string;
103
- gitBranch?: string;
104
- }): void;
105
- /**
106
- * Read the locally-stored credential status for a KB. Pure / synchronous —
107
- * does not subscribe to context changes. Used by KB-list UI to color status
108
- * dots without requiring re-renders on every tick.
109
- */
110
- getKbSessionStatus(kbId: string): KbSessionStatus;
111
- /**
112
- * Switch the active KB. Follows the D2 disposal contract:
113
- * 1. Synchronously announce the new id on `activeKbId$` and null out
114
- * `activeSession$` so views see a safe empty state first.
115
- * 2. Serialize overlapping calls — if an activation is in flight, wait
116
- * for it before proceeding.
117
- * 3. Dispose whatever session is currently live.
118
- * 4. Construct the next session and await `session.ready`.
119
- * 5. Before emitting, re-check `activeKbId$` — if a newer call superseded
120
- * us while we waited, dispose our session and skip the emit.
121
- * 6. Emit the new session.
122
- */
123
- setActiveKb(id: string | null): Promise<void>;
124
- /**
125
- * Sign in to an existing KB: store the tokens and (re)activate the
126
- * session. If the KB is already active, the current session is disposed
127
- * and replaced so the new tokens take effect.
128
- */
129
- signIn(id: string, access: string, refresh: string): Promise<void>;
130
- /**
131
- * Sign out of a KB: clear stored tokens. If the KB is active, dispose
132
- * its session + signals and emit null for both.
133
- */
134
- signOut(id: string): Promise<void>;
135
- addOpenResource(id: string, name: string, mediaType?: string, storageUri?: string): void;
136
- removeOpenResource(id: string): void;
137
- updateOpenResourceName(id: string, name: string): void;
138
- reorderOpenResources(oldIndex: number, newIndex: number): void;
139
- dispose(): Promise<void>;
140
- }
141
- //# sourceMappingURL=semiont-browser.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"semiont-browser.d.ts","sourceRoot":"","sources":["../../src/session/semiont-browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AACjE,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAWxD,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAqBxD,MAAM,WAAW,oBAAoB;IACnC,kFAAkF;IAClF,OAAO,EAAE,cAAc,CAAC;IACxB;;;;;;OAMG;IACH,cAAc,EAAE,cAAc,CAAC;CAChC;AAED,qBAAa,cAAc;IACzB,QAAQ,CAAC,IAAI,EAAE,eA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I,CAAC;CAyB/B"}
@@ -1,210 +0,0 @@
1
- /**
2
- * SemiontSession — per-backend session lifetime object. Owns the
3
- * SemiontClient, the access token BehaviorSubject, and optionally
4
- * an authenticated user. One SemiontSession exists per active backend
5
- * connection; lifetime is decoupled from React mount lifetime.
6
- *
7
- * Headless by design. Runs in browsers, CLIs, workers, and tests.
8
- * UI-specific state (session-expired/permission-denied modals) lives
9
- * in `SessionSignals`, which wraps a session — the session
10
- * itself has no modal observables, no user-facing notifications.
11
- *
12
- * Auth is parameterized via callbacks passed at construction:
13
- *
14
- * - `refresh()` — invoked on 401 / proactive re-auth. Returns the
15
- * new access token, or null on failure. The frontend passes a
16
- * closure that runs the refresh-token flow; the worker passes
17
- * one that exchanges the shared secret.
18
- *
19
- * - `validate(token)` — optional. If provided, the session calls
20
- * it once at startup with the stored token to confirm it's
21
- * still good and populate `user$`. Frontend passes `getMe`;
22
- * worker omits this (service principals have no user record).
23
- *
24
- * - `onAuthFailed(message)` — optional. Invoked when refresh
25
- * terminally fails (expired token, no recovery possible). UI hosts
26
- * typically wire this to `SessionSignals.notifySessionExpired` so a
27
- * modal surfaces; headless consumers typically just log.
28
- *
29
- * Persistence goes through a `SessionStorage` adapter provided at
30
- * construction — the session never touches `localStorage` or `window`
31
- * directly.
32
- */
33
- import { BehaviorSubject, type Observable } from 'rxjs';
34
- import { type AccessToken, type BaseUrl } from '@semiont/core';
35
- import type { components, EventMap } from '@semiont/core';
36
- import { SemiontClient } from '../client';
37
- import type { SemiontError } from '@semiont/core';
38
- import type { ConnectionState } from '@semiont/core';
39
- import type { KnowledgeBase } from './knowledge-base';
40
- import { SemiontSessionError } from './errors';
41
- import type { SessionStorage } from './session-storage';
42
- export type UserInfo = components['schemas']['UserResponse'];
43
- export interface SemiontSessionConfig {
44
- kb: KnowledgeBase;
45
- /** Persistence adapter. Reads/writes tokens via this. */
46
- storage: SessionStorage;
47
- /**
48
- * Pre-built api client. The session does not construct it — caller
49
- * builds the transport stack and passes the client in. This is the
50
- * seam where consumers swap one `ITransport` implementation for
51
- * another (HTTP, in-process, etc.).
52
- */
53
- client: SemiontClient;
54
- /**
55
- * Token observable shared with the transport. Caller must pass the
56
- * SAME instance to both the transport (via `HttpTransport` config)
57
- * and the session. The session writes refreshed tokens here; the
58
- * transport reads from here.
59
- */
60
- token$: BehaviorSubject<AccessToken | null>;
61
- /**
62
- * Re-authenticate after expiry / 401. Returns a new access token
63
- * (no "Bearer " prefix) on success, or null if recovery is
64
- * impossible. Omit for transports where tokens don't apply.
65
- */
66
- refresh?: () => Promise<string | null>;
67
- /**
68
- * Validate the stored token at startup and populate `user$`. Omit
69
- * for service-principal sessions (worker, CLI tools) where there
70
- * is no user record to fetch.
71
- */
72
- validate?: (token: AccessToken) => Promise<UserInfo | null>;
73
- /**
74
- * Invoked when refresh terminally fails. Frontend consumers wire
75
- * this to a UI signal that surfaces the session-expired modal.
76
- */
77
- onAuthFailed?: (message: string | null) => void;
78
- /** Called for session-level failures (auth, refresh exhaustion). */
79
- onError?: (err: SemiontSessionError) => void;
80
- }
81
- export declare class SemiontSession {
82
- readonly kb: KnowledgeBase;
83
- readonly client: SemiontClient;
84
- readonly token$: BehaviorSubject<AccessToken | null>;
85
- readonly user$: BehaviorSubject<UserInfo | null>;
86
- readonly streamState$: Observable<ConnectionState>;
87
- /**
88
- * Stream of `SemiontError` instances surfaced by the underlying transport
89
- * just before they're thrown to the caller. For `HttpTransport` this is
90
- * an `APIError` (status-coded); other transports emit their own subclass.
91
- * Surfaced here so a host layer (e.g. `SemiontBrowser`) can route by
92
- * `err.code` to global notifications without every call site handling
93
- * errors itself. Headless consumers can subscribe for logging.
94
- *
95
- * Re-published from `client.transport.errors$` per the `ITransport`
96
- * contract — the session is purely a passthrough.
97
- */
98
- readonly errors$: Observable<SemiontError>;
99
- /** Resolves after the initial validation round-trip completes (success or failure). */
100
- readonly ready: Promise<void>;
101
- private readonly storage;
102
- private readonly doRefresh?;
103
- private readonly doValidate?;
104
- private readonly onAuthFailed;
105
- private readonly onError;
106
- private refreshTimer;
107
- private unsubscribeStorage;
108
- private disposed;
109
- constructor(config: SemiontSessionConfig);
110
- /**
111
- * Run the initial mount-time validation. If a stored access token is
112
- * present and unexpired, call the configured `validate` with it to
113
- * confirm it still works and populate `user$`. If expired, try
114
- * refresh first. On 401 from validate, try refresh once. Surfaces
115
- * auth-failed on terminal failure.
116
- *
117
- * When no `validate` callback is provided (service principals), this
118
- * still runs through the refresh-if-expired step so the stored
119
- * token is current — it just skips the user-validation round trip.
120
- */
121
- private validate;
122
- /**
123
- * Refresh the access token via the configured `refresh` callback.
124
- * On success, pushes the new token into `token$` and schedules the
125
- * next proactive refresh. On failure, clears persisted state and
126
- * fires `onAuthFailed` — the frontend's wiring of that callback is
127
- * what surfaces the session-expired modal.
128
- */
129
- refresh(): Promise<AccessToken | null>;
130
- private scheduleProactiveRefresh;
131
- private clearRefreshTimer;
132
- /**
133
- * Cross-context sync: another tab/process refreshed or signed out this
134
- * KB. Mirror the change into our in-memory state.
135
- */
136
- private handleStorageChange;
137
- get expiresAt(): Date | null;
138
- /**
139
- * Subscribe to a session-bus channel. The single sanctioned escape hatch
140
- * for generic-channel subscription (the case `useEventSubscription` needs
141
- * — channel name is a hook parameter, not known statically). All other
142
- * consumers must call typed namespace methods (e.g. `session.client.mark.archive(...)`).
143
- *
144
- * @returns disposer that unsubscribes the handler.
145
- */
146
- subscribe<K extends keyof EventMap>(channel: K, handler: (payload: EventMap[K]) => void): () => void;
147
- dispose(): Promise<void>;
148
- /**
149
- * Convenience factory for the default HTTP setup. Constructs the
150
- * shared `BehaviorSubject<AccessToken | null>`, an `HttpTransport`,
151
- * an `HttpContentTransport`, and a `SemiontClient`, then wires
152
- * the session over them. Removes the load-bearing
153
- * "same-token$-instance" invariant from the caller's hands.
154
- *
155
- * Strings are accepted for `baseUrl` and `token`; they are branded
156
- * via `baseUrl()` / `accessToken()` from `@semiont/core` automatically.
157
- *
158
- * The remaining options (`refresh`, `validate`, `onAuthFailed`,
159
- * `onError`) match `SemiontSessionConfig` exactly.
160
- */
161
- static fromHttp(opts: {
162
- kb: KnowledgeBase;
163
- storage: SessionStorage;
164
- baseUrl: BaseUrl | string;
165
- token?: AccessToken | string | null;
166
- refresh?: () => Promise<string | null>;
167
- validate?: (token: AccessToken) => Promise<UserInfo | null>;
168
- onAuthFailed?: (message: string | null) => void;
169
- onError?: (err: SemiontSessionError) => void;
170
- }): SemiontSession;
171
- /**
172
- * Async factory for the credentials-first long-running script case.
173
- * Builds the HTTP transport stack, calls `auth.password(email,
174
- * password)` to acquire access + refresh tokens, persists them via
175
- * the storage adapter, wires a default `refresh` callback that
176
- * exchanges the refresh token via `auth.refresh(...)`, and returns
177
- * the ready session.
178
- *
179
- * The consumer-supplied `refresh` callback becomes optional — only
180
- * needed for non-standard refresh flows (worker-pool shared secret,
181
- * OAuth refresh-token grant, interactive re-prompt). The default
182
- * uses the refresh token returned by `auth.password`.
183
- *
184
- * `kb` is required and must be a full `KnowledgeBase`. The `id` field
185
- * is the storage key for this session — distinct scripts sharing the
186
- * same `SessionStorage` instance must use distinct ids to avoid
187
- * trampling each other's tokens. The factory does not synthesize a
188
- * default; the consumer makes the choice.
189
- *
190
- * Named `signInHttp` because email+password authentication is
191
- * inherently an HTTP-shaped operation in the current backend; an
192
- * in-process `LocalTransport` doesn't have a credentials login
193
- * path. Non-HTTP transports construct the session directly from
194
- * their package's transport instance.
195
- *
196
- * Throws on auth failure with no resources leaked. On success, the
197
- * returned session's `ready` promise has already resolved.
198
- */
199
- static signInHttp(opts: {
200
- kb: KnowledgeBase;
201
- storage: SessionStorage;
202
- baseUrl: BaseUrl | string;
203
- email: string;
204
- password: string;
205
- validate?: (token: AccessToken) => Promise<UserInfo | null>;
206
- onAuthFailed?: (message: string | null) => void;
207
- onError?: (err: SemiontSessionError) => void;
208
- }): Promise<SemiontSession>;
209
- }
210
- //# sourceMappingURL=semiont-session.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"semiont-session.d.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C,GAAG,OAAO,CAAC,cAAc,CAAC;CAmD5B"}
@@ -1,31 +0,0 @@
1
- /**
2
- * SessionFactory — the injection point that lets `SemiontBrowser` stay
3
- * transport-agnostic.
4
- *
5
- * The browser knows how to manage the *lifecycle* of an active session
6
- * (track it in `activeSession$`, dispose on KB switch, serialize
7
- * overlapping activations) but does not know how to *construct* one —
8
- * because that's where transport choice lives. The construction step
9
- * is parameterized via this factory.
10
- *
11
- * The HTTP factory is provided by `createHttpSessionFactory`. A
12
- * future in-process variant from `@semiont/make-meaning` would expose
13
- * its own factory.
14
- */
15
- import type { KnowledgeBase } from './knowledge-base';
16
- import type { SessionSignals } from './session-signals';
17
- import type { SessionStorage } from './session-storage';
18
- import type { SemiontSession } from './semiont-session';
19
- import type { SemiontSessionError } from './errors';
20
- export interface SessionFactoryOptions {
21
- /** The KB the session is being constructed for. */
22
- kb: KnowledgeBase;
23
- /** Persistence adapter — same one the browser uses. */
24
- storage: SessionStorage;
25
- /** Modal-signal sink for auth-failed / permission-denied notifications. */
26
- signals: SessionSignals;
27
- /** Receives session-level errors (auth-failed, refresh-exhausted, ...). */
28
- onError: (err: SemiontSessionError) => void;
29
- }
30
- export type SessionFactory = (opts: SessionFactoryOptions) => SemiontSession;
31
- //# sourceMappingURL=session-factory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"session-factory.d.ts","sourceRoot":"","sources":["../../src/session/session-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD,MAAM,WAAW,qBAAqB;IACpC,mDAAmD;IACnD,EAAE,EAAE,aAAa,CAAC;IAClB,uDAAuD;IACvD,OAAO,EAAE,cAAc,CAAC;IACxB,2EAA2E;IAC3E,OAAO,EAAE,cAAc,CAAC;IACxB,2EAA2E;IAC3E,OAAO,EAAE,CAAC,GAAG,EAAE,mBAAmB,KAAK,IAAI,CAAC;CAC7C;AAED,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,qBAAqB,KAAK,cAAc,CAAC"}
@@ -1,40 +0,0 @@
1
- /**
2
- * SessionSignals — UI-facing notification state that belongs to the host
3
- * surface, not to the session itself.
4
- *
5
- * `SemiontSession` is a headless per-backend client + token + user
6
- * holder. It can run in any process: browser, worker, CLI, test. But
7
- * the session-expired / permission-denied *notifications* are inherently
8
- * a UI-host concern. Keeping those observables on `SemiontSession` meant
9
- * workers and CLIs carried four dead BehaviorSubjects that nothing would
10
- * ever fire.
11
- *
12
- * `SessionSignals` owns the notification state and has no hard reference
13
- * to a session. A UI host (e.g. `SemiontBrowser`) constructs one alongside
14
- * every active session and wires:
15
- *
16
- * - `session.onAuthFailed` → `signals.notifySessionExpired` so
17
- * proactive-refresh failures surface as a notification
18
- *
19
- * UI consumers that need to render modal/banner state subscribe here;
20
- * consumers that need bus/HTTP access continue to subscribe to the session.
21
- *
22
- * Session auth-state cleanup (clearing token, clearing storage) is
23
- * the session's own responsibility inside `refresh()` — by the time
24
- * `notifySessionExpired` runs, the session has already torn down.
25
- * Signals only surfaces the notification.
26
- */
27
- import { BehaviorSubject } from 'rxjs';
28
- export declare class SessionSignals {
29
- readonly sessionExpiredAt$: BehaviorSubject<number | null>;
30
- readonly sessionExpiredMessage$: BehaviorSubject<string | null>;
31
- readonly permissionDeniedAt$: BehaviorSubject<number | null>;
32
- readonly permissionDeniedMessage$: BehaviorSubject<string | null>;
33
- constructor();
34
- notifySessionExpired(message: string | null): void;
35
- notifyPermissionDenied(message: string | null): void;
36
- acknowledgeSessionExpired(): void;
37
- acknowledgePermissionDenied(): void;
38
- dispose(): void;
39
- }
40
- //# sourceMappingURL=session-signals.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"session-signals.d.ts","sourceRoot":"","sources":["../../src/session/session-signals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAEvC,qBAAa,cAAc;IACzB,QAAQ,CAAC,iBAAiB,EAAE,eAAe,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC3D,QAAQ,CAAC,sBAAsB,EAAE,eAAe,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAChE,QAAQ,CAAC,mBAAmB,EAAE,eAAe,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC7D,QAAQ,CAAC,wBAAwB,EAAE,eAAe,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;;IASlE,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAOlD,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAOpD,yBAAyB,IAAI,IAAI;IAKjC,2BAA2B,IAAI,IAAI;IAKnC,OAAO,IAAI,IAAI;CAMhB"}
@@ -1,41 +0,0 @@
1
- /**
2
- * SessionStorage — environment-agnostic persistence adapter for the
3
- * Semiont session layer. Decouples `SemiontSession` / `SemiontBrowser`
4
- * from `localStorage` / `window` so the same classes can run in a
5
- * browser, a CLI process, or tests without environment guards.
6
- *
7
- * Implementations shipped here:
8
- * - `InMemorySessionStorage` — map-backed, for tests.
9
- *
10
- * Browser-backed (`WebBrowserStorage`) lives in `@semiont/react-ui`
11
- * because it touches browser-only globals.
12
- */
13
- /** String key/value store with optional cross-context change subscription. */
14
- export interface SessionStorage {
15
- /** Read a string value; null if absent. */
16
- get(key: string): string | null;
17
- /** Write a string value. */
18
- set(key: string, value: string): void;
19
- /** Remove a key. No-op if absent. */
20
- delete(key: string): void;
21
- /**
22
- * Optional: subscribe to external changes (cross-tab, cross-process).
23
- * Browser implements via the `storage` event; filesystem would use
24
- * fs.watch; in-memory omits this method. Returns an unsubscribe
25
- * callback. If omitted, cross-context sync simply isn't available
26
- * in that environment — the session still works correctly within a
27
- * single process.
28
- */
29
- subscribe?(handler: (key: string, newValue: string | null) => void): () => void;
30
- }
31
- /**
32
- * Map-backed `SessionStorage`. Cross-context sync is not implemented;
33
- * tests that need it can drive it manually.
34
- */
35
- export declare class InMemorySessionStorage implements SessionStorage {
36
- private readonly map;
37
- get(key: string): string | null;
38
- set(key: string, value: string): void;
39
- delete(key: string): void;
40
- }
41
- //# sourceMappingURL=session-storage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"session-storage.d.ts","sourceRoot":"","sources":["../../src/session/session-storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,8EAA8E;AAC9E,MAAM,WAAW,cAAc;IAC7B,2CAA2C;IAC3C,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAChC,4BAA4B;IAC5B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,qCAAqC;IACrC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;;;;;;OAOG;IACH,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACjF;AAED;;;GAGG;AACH,qBAAa,sBAAuB,YAAW,cAAc;IAC3D,OAAO,CAAC,QAAQ,CAAC,GAAG,CAA6B;IAEjD,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAI/B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAIrC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;CAG1B"}