@semiont/api-client 0.4.21 → 0.4.22
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 +49 -91
- package/dist/index.d.ts +87 -1965
- package/dist/index.js +479 -4275
- package/dist/index.js.map +1 -1
- package/package.json +3 -7
- package/dist/utils/index.d.ts +0 -584
- package/dist/utils/index.js +0 -646
- package/dist/utils/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -6,109 +6,67 @@
|
|
|
6
6
|
[](https://www.npmjs.com/package/@semiont/api-client)
|
|
7
7
|
[](https://github.com/The-AI-Alliance/semiont/blob/main/LICENSE)
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
HTTP-specific transport adapters for the Semiont SDK. This is the wire-side
|
|
10
|
+
implementation of the `ITransport` and `IContentTransport` contracts defined
|
|
11
|
+
in [`@semiont/core`](../core/), consumed by [`@semiont/sdk`](../sdk/).
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
Most application code does **not** import this package directly. The sdk
|
|
14
|
+
re-exports the HTTP adapters for convenience, so a typical consumer writes:
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
```ts
|
|
17
|
+
import { SemiontClient, HttpTransport, HttpContentTransport } from '@semiont/sdk';
|
|
18
|
+
import { baseUrl } from '@semiont/core';
|
|
14
19
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
```typescript
|
|
18
|
-
import { SemiontApiClient } from '@semiont/api-client';
|
|
19
|
-
|
|
20
|
-
const semiont = new SemiontApiClient({ baseUrl, eventBus, token$ });
|
|
21
|
-
|
|
22
|
-
// Browse — reads from materialized views
|
|
23
|
-
const resource = semiont.browse.resource(resourceId); // Observable
|
|
24
|
-
const annotations = semiont.browse.annotations(resourceId); // Observable
|
|
25
|
-
const content = await semiont.browse.resourceContent(rid); // Promise
|
|
26
|
-
|
|
27
|
-
// Mark — annotation CRUD + AI assist
|
|
28
|
-
await semiont.mark.annotation(resourceId, input);
|
|
29
|
-
await semiont.mark.delete(resourceId, annotationId);
|
|
30
|
-
semiont.mark.assist(resourceId, 'linking', options); // Observable (progress)
|
|
31
|
-
|
|
32
|
-
// Bind — reference linking
|
|
33
|
-
await semiont.bind.body(resourceId, annotationId, operations);
|
|
34
|
-
|
|
35
|
-
// Gather — LLM context assembly
|
|
36
|
-
semiont.gather.annotation(annotationId, resourceId); // Observable (progress → context)
|
|
37
|
-
|
|
38
|
-
// Match — semantic search
|
|
39
|
-
semiont.match.search(resourceId, referenceId, context); // Observable (results)
|
|
40
|
-
|
|
41
|
-
// Yield — resource creation + AI generation
|
|
42
|
-
await semiont.yield.resource(data);
|
|
43
|
-
semiont.yield.fromAnnotation(resourceId, annotationId, opts); // Observable (progress)
|
|
44
|
-
|
|
45
|
-
// Beckon — attention coordination
|
|
46
|
-
semiont.beckon.attention(annotationId, resourceId); // void (ephemeral)
|
|
47
|
-
|
|
48
|
-
// + Job, Auth, Admin namespaces
|
|
20
|
+
const transport = new HttpTransport({ baseUrl: baseUrl('https://kb.example/') });
|
|
21
|
+
const client = new SemiontClient(transport, new HttpContentTransport(transport));
|
|
49
22
|
```
|
|
50
23
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const semiont = new SemiontApiClient({
|
|
73
|
-
baseUrl: baseUrl('http://localhost:4000'),
|
|
74
|
-
eventBus: new EventBus(),
|
|
75
|
-
token$,
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
// No auth on individual calls
|
|
79
|
-
const annotations = semiont.browse.annotations(resourceId);
|
|
80
|
-
await semiont.mark.annotation(resourceId, input);
|
|
81
|
-
await semiont.bind.body(resourceId, annotationId, operations);
|
|
82
|
-
|
|
83
|
-
// Token rotation — e.g. after refresh
|
|
84
|
-
token$.next(accessToken(newToken));
|
|
24
|
+
Direct imports from `@semiont/api-client` are appropriate when constructing
|
|
25
|
+
the transport stack by hand — e.g. CLI factories, MCP entrypoints, or worker
|
|
26
|
+
pools that wire bespoke `tokenRefresher` / `BehaviorSubject` token sources.
|
|
27
|
+
|
|
28
|
+
## Public surface
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import {
|
|
32
|
+
HttpTransport,
|
|
33
|
+
HttpContentTransport,
|
|
34
|
+
type HttpTransportConfig,
|
|
35
|
+
type TokenRefresher,
|
|
36
|
+
APIError,
|
|
37
|
+
// SSE-actor machinery used by SDK adapters; not application code:
|
|
38
|
+
createActorVM,
|
|
39
|
+
type ActorVM,
|
|
40
|
+
type BusEvent,
|
|
41
|
+
type ActorVMOptions,
|
|
42
|
+
DEGRADED_THRESHOLD_MS,
|
|
43
|
+
} from '@semiont/api-client';
|
|
85
44
|
```
|
|
86
45
|
|
|
87
|
-
|
|
88
|
-
The bus actor will not connect until a non-null token is available.
|
|
89
|
-
|
|
90
|
-
## Installation
|
|
91
|
-
|
|
92
|
-
```bash
|
|
93
|
-
npm install @semiont/api-client
|
|
94
|
-
```
|
|
46
|
+
That's the entire surface. Everything else moved out:
|
|
95
47
|
|
|
96
|
-
|
|
48
|
+
- **`ITransport`, `IContentTransport`, `BRIDGED_CHANNELS`, `ConnectionState`,
|
|
49
|
+
response/progress types** live in [`@semiont/core`](../core/).
|
|
50
|
+
- **`SemiontClient`, namespaces, `SemiontSession`, `SemiontBrowser`,
|
|
51
|
+
view-models, `bus-request`, `cache`** live in [`@semiont/sdk`](../sdk/).
|
|
97
52
|
|
|
98
|
-
##
|
|
53
|
+
## Behavioral contract
|
|
99
54
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
-
|
|
103
|
-
-
|
|
55
|
+
The guarantees every `ITransport` implementation must honor — including
|
|
56
|
+
`HttpTransport` — are documented in
|
|
57
|
+
[`packages/core/docs/TRANSPORT-CONTRACT.md`](../core/docs/TRANSPORT-CONTRACT.md).
|
|
58
|
+
HTTP-specific guarantees (the `/bus/emit` gateway, SSE reconnect, `Last-Event-ID`
|
|
59
|
+
replay, etc.) live alongside the backend at
|
|
60
|
+
[`apps/backend/docs/TRANSPORT.md`](../../apps/backend/docs/TRANSPORT.md).
|
|
104
61
|
|
|
105
|
-
##
|
|
62
|
+
## Writing a new transport
|
|
106
63
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
-
|
|
64
|
+
If you need to add a non-HTTP transport (gRPC, WebSocket, IPC, …), implement
|
|
65
|
+
`ITransport` + `IContentTransport` from `@semiont/core` and consume the
|
|
66
|
+
contract from there. There's no inheritance from `HttpTransport`. For an
|
|
67
|
+
in-process example, see `LocalTransport` in
|
|
68
|
+
[`@semiont/make-meaning`](../make-meaning/).
|
|
111
69
|
|
|
112
70
|
## License
|
|
113
71
|
|
|
114
|
-
Apache-2.0
|
|
72
|
+
Apache-2.0 — see [LICENSE](./LICENSE).
|