@semiont/sdk 0.4.21

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/README.md ADDED
@@ -0,0 +1,115 @@
1
+ # @semiont/sdk
2
+
3
+ The developer-facing SDK for [Semiont](https://github.com/The-AI-Alliance/semiont).
4
+ This package owns the high-level surface every Semiont consumer reaches for:
5
+
6
+ - **`SemiontClient`** — the verb-oriented coordinator over a wire transport.
7
+ - **Namespaces** — `browse`, `mark`, `bind`, `gather`, `match`, `yield`,
8
+ `beckon`, `job`, `auth`, `admin`. Typed methods that wrap the bus
9
+ protocol; consumers never touch raw channel strings.
10
+ - **Session layer** — `SemiontSession` (per-KB authentication, token
11
+ refresh, lifecycle), `SemiontBrowser` (tab-singleton coordinator),
12
+ `SessionStorage` adapters (`InMemorySessionStorage`, plus a web one in
13
+ `@semiont/react-ui`).
14
+ - **View-models** — RxJS-based MVVM factories the React layer mounts via
15
+ `useViewModel`.
16
+ - **Helpers** — `bus-request` (correlation-ID request/reply), `cache`
17
+ (per-key SWR cache).
18
+
19
+ The sdk is **transport-agnostic**: it consumes the `ITransport` /
20
+ `IContentTransport` contract defined in
21
+ [`@semiont/core`](../core/). For HTTP, the canonical wire adapter is
22
+ re-exported from this package for convenience; for in-process operation,
23
+ use `LocalTransport` from
24
+ [`@semiont/make-meaning`](../make-meaning/).
25
+
26
+ ## Quick start (HTTP)
27
+
28
+ ```ts
29
+ import {
30
+ SemiontSession,
31
+ InMemorySessionStorage,
32
+ setStoredSession,
33
+ type KnowledgeBase,
34
+ } from '@semiont/sdk';
35
+ import { accessToken } from '@semiont/core';
36
+ import { firstValueFrom } from 'rxjs';
37
+ import { filter } from 'rxjs/operators';
38
+
39
+ const kb: KnowledgeBase = {
40
+ id: 'local',
41
+ label: 'Local Backend',
42
+ protocol: 'http',
43
+ host: 'localhost',
44
+ port: 4000,
45
+ email: 'me@example.com',
46
+ };
47
+
48
+ const storage = new InMemorySessionStorage();
49
+ setStoredSession(storage, kb.id, { access: accessToken('your-jwt'), refresh: '' });
50
+
51
+ const session = await SemiontSession.create({ kb, storage });
52
+ const resources = await firstValueFrom(
53
+ session.client.browse.resources({ limit: 10 }).pipe(filter((r): r is NonNullable<typeof r> => r !== undefined)),
54
+ );
55
+ console.log(resources);
56
+ ```
57
+
58
+ ## Quick start (in-process)
59
+
60
+ ```ts
61
+ import { SemiontClient } from '@semiont/sdk';
62
+ import {
63
+ startMakeMeaning,
64
+ LocalTransport,
65
+ LocalContentTransport,
66
+ } from '@semiont/make-meaning';
67
+
68
+ const ks = await startMakeMeaning(project, config, eventBus, logger);
69
+ const transport = new LocalTransport({
70
+ knowledgeSystem: ks.knowledgeSystem,
71
+ eventBus,
72
+ userId,
73
+ });
74
+ const client = new SemiontClient(transport, new LocalContentTransport(ks.knowledgeSystem));
75
+ ```
76
+
77
+ ## Verb namespaces
78
+
79
+ All ten namespaces hang off `SemiontClient`. Each method either returns a
80
+ `Promise` (for one-shot RPC-style operations) or an `Observable` (for
81
+ streaming subscriptions). The bus is invisible to callers — channel
82
+ strings, correlation IDs, and reconnection are internal.
83
+
84
+ ```ts
85
+ // Browse
86
+ await client.browse.resources({ limit: 10 });
87
+ client.browse.resource(resourceId).subscribe(/* ... */);
88
+
89
+ // Mark / Bind
90
+ const { annotationId } = await client.mark.annotation(rid, request);
91
+ await client.bind.body(rid, aid, [{ op: 'add', item: { ... } }]);
92
+
93
+ // Gather / Match
94
+ const ctx = await lastValueFrom(client.gather.annotation(aid, rid));
95
+ client.match.search(rid, refId, ctx, { limit: 10 }).subscribe(/* ... */);
96
+
97
+ // Yield
98
+ const { resourceId } = await client.yield.resource({ name, file, format, storageUri });
99
+
100
+ // Beckon (UI signals)
101
+ client.beckon.hover(annotationId);
102
+ ```
103
+
104
+ See [docs/flows](../../docs/flows/) for verb-by-verb walkthroughs.
105
+
106
+ ## Behavioral contract
107
+
108
+ The guarantees every `ITransport` implementation must honor are documented in
109
+ [`packages/core/docs/TRANSPORT-CONTRACT.md`](../core/docs/TRANSPORT-CONTRACT.md).
110
+ HTTP-specific guarantees (gateway, SSE, `Last-Event-ID`, etc.) live at
111
+ [`apps/backend/docs/TRANSPORT.md`](../../apps/backend/docs/TRANSPORT.md).
112
+
113
+ ## License
114
+
115
+ Apache-2.0 — see [LICENSE](./LICENSE).