@oberik/sdk 0.1.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/README.md +79 -0
- package/dist/cjs/index.js +1751 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/esm/index.d.ts +1614 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +1743 -0
- package/dist/esm/index.js.map +1 -0
- package/package.json +40 -0
package/README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# @oberik/sdk
|
|
2
|
+
|
|
3
|
+
TypeScript client for [Oberik](https://oberik.com) — give your product AI over your
|
|
4
|
+
customers' own data: retrieval with citations, your own tools, sandboxed compute, files and
|
|
5
|
+
media, scheduling.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @oberik/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
Your backend mints a short-lived token for one end-user; the SDK asks for a new one when it
|
|
14
|
+
expires, so an expiry never surfaces at a call site.
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { createClient } from "@oberik/sdk";
|
|
18
|
+
|
|
19
|
+
const ai = createClient({
|
|
20
|
+
// baseUrl defaults to the hosted API; set it for a self-hosted deployment.
|
|
21
|
+
getToken: async ({ expired }) => fetchTokenFromYourBackend({ force: expired }),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const res = await ai.chat.send({ message: "How did Q3 revenue trend?", tags: ["finance"] });
|
|
25
|
+
|
|
26
|
+
res.content; // grounded answer
|
|
27
|
+
res.citations; // document · page · quote
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Streaming, which is what you want in a UI:
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
const handle = ai.chat.stream(
|
|
34
|
+
{ message: input },
|
|
35
|
+
{
|
|
36
|
+
onToken: (_delta, full) => render(full),
|
|
37
|
+
onReasoning: (_delta, full) => showThinking(full), // reasoning models
|
|
38
|
+
onToolStart: (name) => setStatus(`Running ${name}…`),
|
|
39
|
+
onCitations: (cs) => showSources(cs),
|
|
40
|
+
onAttachments: (files) => offerDownloads(files),
|
|
41
|
+
},
|
|
42
|
+
);
|
|
43
|
+
const done = await handle.done;
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
A dropped connection resumes the *same run* rather than restarting it, so a closed laptop
|
|
47
|
+
lid mid-answer doesn't lose the answer or pay for it twice.
|
|
48
|
+
|
|
49
|
+
## What's in the box
|
|
50
|
+
|
|
51
|
+
- **Chat** — blocking or streaming, with citations, unified source pills, guardrail flags
|
|
52
|
+
and `finish_reason`.
|
|
53
|
+
- **Your own tools** — register a handler and `chat.run`/`chat.stream` dispatch it and
|
|
54
|
+
resume for you; or drive the pause/resume loop yourself.
|
|
55
|
+
- **Documents** — resumable presigned multipart upload straight to storage, ranged
|
|
56
|
+
resumable download, retrieval, chunk inspection, ACLs.
|
|
57
|
+
- **Sandboxed compute** — start, pause, resume and reattach a workspace; push and pull
|
|
58
|
+
files.
|
|
59
|
+
- **Scheduling, connected sources, audit** — the rest of the API, typed.
|
|
60
|
+
|
|
61
|
+
Zero dependencies, works in Node 18+ and in the browser, ESM and CommonJS.
|
|
62
|
+
|
|
63
|
+
## Docs
|
|
64
|
+
|
|
65
|
+
Full documentation, including how to mint tokens and which capabilities gate what:
|
|
66
|
+
**https://oberik.com/docs**
|
|
67
|
+
|
|
68
|
+
## Development
|
|
69
|
+
|
|
70
|
+
The client is a single file kept at `client/agent-framework.ts` in the Oberik repository;
|
|
71
|
+
`src/index.ts` here is a symlink to it, so the published package, the dashboard's own
|
|
72
|
+
playground and the docs all use one source. Building emits ESM, CommonJS and types:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npm run build # dist/esm, dist/cjs, .d.ts
|
|
76
|
+
npm run check # asserts the tarball is actually usable before publishing
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
`npm publish` runs both automatically via `prepublishOnly`.
|