@bimpeai/sdk 0.0.0-beta-20260606071952
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/LICENSE +21 -0
- package/README.md +192 -0
- package/dist/index.cjs +803 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +478 -0
- package/dist/index.d.ts +478 -0
- package/dist/index.js +774 -0
- package/dist/index.js.map +1 -0
- package/package.json +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 BimpeAI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# @bimpeai/sdk
|
|
2
|
+
|
|
3
|
+
Official TypeScript SDK for the BimpeAI Agent Console API. Zero runtime dependencies. Runs on Node 24+, Bun, Deno, modern browsers, and edge runtimes.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @bimpeai/sdk
|
|
9
|
+
# npm install @bimpeai/sdk
|
|
10
|
+
# yarn add @bimpeai/sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quickstart
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { BimpeAI } from '@bimpeai/sdk';
|
|
17
|
+
|
|
18
|
+
const bimpe = new BimpeAI({ apiKey: process.env.BIMPEAI_API_KEY! });
|
|
19
|
+
|
|
20
|
+
const agents = await bimpe.agents.list();
|
|
21
|
+
for (const agent of agents.data) console.log(agent.id, agent.name);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Authentication
|
|
25
|
+
|
|
26
|
+
The SDK sends your team API key as `Authorization: Bearer <key>`. Keys are prefixed `sk_`.
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
const bimpe = new BimpeAI({ apiKey: 'sk_…' });
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Scope-restricted keys (for example `workflows:read`) work the same way; a call outside the key's scope throws `PermissionDeniedError`.
|
|
33
|
+
|
|
34
|
+
## Resources
|
|
35
|
+
|
|
36
|
+
### Agents
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
await bimpe.agents.list({ page: 2, limit: 50, sort: '-created_at' });
|
|
40
|
+
await bimpe.agents.create({ name: 'Support bot' }, { idempotencyKey: 'op-1' });
|
|
41
|
+
await bimpe.agents.retrieve(agentId);
|
|
42
|
+
await bimpe.agents.update(agentId, { description: 'Updated' });
|
|
43
|
+
|
|
44
|
+
await bimpe.agents.integrations.list(agentId);
|
|
45
|
+
await bimpe.agents.channels.list(agentId);
|
|
46
|
+
await bimpe.agents.conversationFlows.list(agentId);
|
|
47
|
+
await bimpe.agents.actions.list(agentId);
|
|
48
|
+
|
|
49
|
+
await bimpe.agents.knowledgeBases.list(agentId);
|
|
50
|
+
await bimpe.agents.knowledgeBases.create(agentId, { type: 'text', name: 'FAQ', content: '…' });
|
|
51
|
+
await bimpe.agents.knowledgeBases.update(agentId, kbId, { description: '…' });
|
|
52
|
+
await bimpe.agents.knowledgeBases.delete(agentId, kbId);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Workflows
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
await bimpe.workflows.list({ scope: 'public' });
|
|
59
|
+
await bimpe.workflows.create({ name: 'Triage' });
|
|
60
|
+
await bimpe.workflows.retrieve(id);
|
|
61
|
+
await bimpe.workflows.update(id, { tags: ['v2'] });
|
|
62
|
+
await bimpe.workflows.delete(id);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Conversations and messages
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
await bimpe.conversations.list(agentId, { channel: 'whatsapp' });
|
|
69
|
+
await bimpe.conversations.retrieve(agentId, conversationId);
|
|
70
|
+
await bimpe.conversations.messages.list(agentId, conversationId);
|
|
71
|
+
await bimpe.conversations.messages.send(agentId, conversationId, { message: 'Hello' });
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Calls
|
|
75
|
+
|
|
76
|
+
`calls.list()` is wired but the API answers with 501 today, so it throws `NotImplementedError`. It will start returning data once the endpoint ships, without an SDK change to your call site.
|
|
77
|
+
|
|
78
|
+
## Pagination
|
|
79
|
+
|
|
80
|
+
`list` returns a value you can both await and iterate. Await it for a single `Page`; iterate it with `for await` to walk every item across pages, fetching lazily.
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
// One page
|
|
84
|
+
const page = await bimpe.agents.list({ limit: 50 });
|
|
85
|
+
page.data; // ReadonlyArray<Agent>
|
|
86
|
+
page.meta; // PaginationMeta
|
|
87
|
+
page.requestId; // string | null
|
|
88
|
+
page.hasNextPage; // boolean
|
|
89
|
+
const next = await page.getNextPage();
|
|
90
|
+
|
|
91
|
+
// Every item, fetching pages on demand
|
|
92
|
+
for await (const agent of bimpe.agents.list({ limit: 50 })) {
|
|
93
|
+
console.log(agent.id);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Page by page
|
|
97
|
+
for await (const page of bimpe.agents.list().pages()) {
|
|
98
|
+
console.log(page.meta?.current_page);
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Errors
|
|
103
|
+
|
|
104
|
+
Every SDK error extends `BimpeAIError`. Server responses extend `ApiError`.
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
import { RateLimitError, ValidationError } from '@bimpeai/sdk';
|
|
108
|
+
|
|
109
|
+
try {
|
|
110
|
+
await bimpe.agents.create({ name: '' });
|
|
111
|
+
} catch (error) {
|
|
112
|
+
if (error instanceof ValidationError) {
|
|
113
|
+
for (const field of error.fieldErrors) console.warn(`${field.path}: ${field.message}`);
|
|
114
|
+
} else if (error instanceof RateLimitError) {
|
|
115
|
+
console.warn(`retry in ${error.retryAfter}s`);
|
|
116
|
+
} else {
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
The hierarchy:
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
BimpeAIError
|
|
126
|
+
├── UserError
|
|
127
|
+
├── ConnectionError
|
|
128
|
+
│ └── ConnectionTimeoutError
|
|
129
|
+
└── ApiError
|
|
130
|
+
├── BadRequestError
|
|
131
|
+
│ └── ValidationError
|
|
132
|
+
├── AuthenticationError
|
|
133
|
+
├── PermissionDeniedError
|
|
134
|
+
├── NotFoundError
|
|
135
|
+
├── ConflictError
|
|
136
|
+
├── RateLimitError
|
|
137
|
+
├── InternalServerError
|
|
138
|
+
└── NotImplementedError
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Every `ApiError` carries `status`, `code`, `requestId`, `headers`, and the raw `body`. `RateLimitError` adds `retryAfter`, `limit`, `remaining`, and `resetAt`. `ValidationError` adds `fieldErrors`.
|
|
142
|
+
|
|
143
|
+
## Retries and idempotency
|
|
144
|
+
|
|
145
|
+
By default the SDK retries up to twice on connection errors, timeouts, 408, 429, and 5xx (never 409 or 501), with exponential backoff and full jitter. A 429 honours `Retry-After`.
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
const bimpe = new BimpeAI({ apiKey: '…', maxRetries: 3 });
|
|
149
|
+
await bimpe.agents.create(body, { maxRetries: 0 }); // override per call
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Writes accept an `idempotencyKey`. When retries are on and you do not supply one, the SDK generates a key once per call and reuses it across attempts, so a retried write cannot create a duplicate.
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
await bimpe.agents.create({ name: 'A' }, { idempotencyKey: 'create-A-2026-06-06' });
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Configuration
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
new BimpeAI({
|
|
162
|
+
apiKey: string, // required
|
|
163
|
+
baseUrl?: string, // default 'https://api.bimpeai.com'
|
|
164
|
+
timeout?: number, // per-request ms; default 30_000
|
|
165
|
+
maxRetries?: number, // default 2
|
|
166
|
+
fetch?: typeof fetch, // override for tests or edge runtimes
|
|
167
|
+
defaultHeaders?: Record<string, string>,
|
|
168
|
+
logger?: { debug; warn }, // structured hooks; off by default
|
|
169
|
+
});
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Per-call options on writes: `idempotencyKey`, `signal`, `timeout`, `maxRetries`, `headers`.
|
|
173
|
+
|
|
174
|
+
## Escape hatch
|
|
175
|
+
|
|
176
|
+
For endpoints the SDK does not model yet, call the transport directly.
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
const res = await bimpe.request<{ pong: boolean }>({ method: 'GET', path: '/health' });
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Runtime support
|
|
183
|
+
|
|
184
|
+
Node 24+, Bun, Deno, modern browsers, Cloudflare Workers, and Vercel Edge. Ships as ESM and CJS with subpath exports and bundled type declarations.
|
|
185
|
+
|
|
186
|
+
## Versioning
|
|
187
|
+
|
|
188
|
+
Pre-1.0, minor versions may include breaking changes. See `CHANGELOG.md` for each release.
|
|
189
|
+
|
|
190
|
+
## License
|
|
191
|
+
|
|
192
|
+
MIT
|