@lobehub/sdk 1.0.20260807012700

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,70 @@
1
+ # @lobehub/sdk
2
+
3
+ Official TypeScript SDK for the [LobeHub REST API](https://app.lobehub.com/api/v1/docs), generated from the OpenAPI spec in [`packages/openapi`](../openapi) via [@hey-api/openapi-ts](https://heyapi.dev).
4
+
5
+ Resource-style methods with full typing — every path, parameter, request body, and response comes from `openapi.yml`, and the HTTP runtime is inlined (zero dependencies).
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @lobehub/sdk
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```ts
16
+ import { createLobeHub } from '@lobehub/sdk';
17
+
18
+ const lobehub = createLobeHub({
19
+ // LobeHub API Key (`sk-lh-...`) or an OIDC JWT
20
+ apiKey: process.env.LOBEHUB_API_KEY!,
21
+ });
22
+
23
+ const me = await lobehub.users.me();
24
+ const { data, error } = await lobehub.agents.list();
25
+ const agent = await lobehub.agents.get({ path: { id: 'agt_...' } });
26
+
27
+ await lobehub.agentGroups.create({ body: { name: 'My group' } });
28
+ await lobehub.files.uploadBatch({ body: { files: [/* … */] } });
29
+ ```
30
+
31
+ Resources map to the API's top-level path segments: `health`, `agentGroups`, `agents`, `files`, `knowledgeBases`, `messageTranslations`, `messages`, `models`, `permissions`, `providers`, `responses`, `roles`, `topics`, `users`. Method names follow a fixed rule — `list` / `get` / `create` / `update` / `delete` plus PascalCase sub-segments (`files.listChunks`, `roles.updatePermissions`) — with a few curated names (`files.uploadBatch`, `files.query`, `knowledgeBases.addFiles`, `users.me`).
32
+
33
+ Point the client at another deployment with `baseURL`, and pass any other client option (custom `fetch`, `headers`, …):
34
+
35
+ ```ts
36
+ const lobehub = createLobeHub({
37
+ apiKey: 'sk-lh-...',
38
+ baseURL: 'http://localhost:3010',
39
+ });
40
+ ```
41
+
42
+ Raw spec types are exported from `@lobehub/sdk/types`.
43
+
44
+ ### Streaming responses
45
+
46
+ `responses.create` returns Server-Sent Events when `body.stream: true`. Opt out of JSON parsing with `parseAs: 'stream'` and read the raw stream from `response.body`:
47
+
48
+ ```ts
49
+ const { response } = await lobehub.responses.create({
50
+ body: { input: '…', model: '…', stream: true },
51
+ parseAs: 'stream',
52
+ });
53
+ for await (const chunk of response.body!) {
54
+ // decode SSE chunks
55
+ }
56
+ ```
57
+
58
+ (First-class typed SSE methods will come with the spec's response schemas.)
59
+
60
+ ## Development
61
+
62
+ - `bun generate` — regenerate `src/generated/` from `../openapi/openapi.yml` (run after the spec changes; naming rules live in `openapi-ts.config.ts`)
63
+ - `bun run build` — build ESM + d.ts to `dist/`
64
+ - `bun run test` — unit tests + generated-output drift check (local and release workflow only; not wired into PR CI)
65
+
66
+ ## Releasing
67
+
68
+ Publishing is automated by [`release-sdk.yml`](../../.github/workflows/release-sdk.yml): every push to `canary` touching `packages/sdk/**` publishes `1.0.<UTC timestamp>` to npm with provenance (manual `workflow_dispatch` also available). To ship a spec change, run `bun generate` and commit the regenerated output — the workflow's drift check (`bun scripts/generate-sdk.ts --check`) guards the published artifact.
69
+
70
+ Regular PR CI does not gate on spec drift — the check runs locally (`bun run test`) and inside the release workflow only.