@cobbl-ai/sdk 0.1.0 → 0.1.2
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 +179 -55
- package/dist/admin.d.mts +90 -0
- package/dist/admin.d.ts +90 -0
- package/dist/admin.js +185 -0
- package/dist/admin.js.map +1 -0
- package/dist/admin.mjs +182 -0
- package/dist/admin.mjs.map +1 -0
- package/dist/cobbl-sdk.global.js +2 -0
- package/dist/cobbl-sdk.global.js.map +1 -0
- package/dist/errors-BaYZ2rGo.d.mts +208 -0
- package/dist/errors-BaYZ2rGo.d.ts +208 -0
- package/dist/index.d.mts +3 -348
- package/dist/index.d.ts +3 -348
- package/dist/index.js +222 -75
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +221 -75
- package/dist/index.mjs.map +1 -1
- package/dist/public.d.mts +130 -0
- package/dist/public.d.ts +130 -0
- package/dist/public.js +271 -0
- package/dist/public.js.map +1 -0
- package/dist/public.mjs +268 -0
- package/dist/public.mjs.map +1 -0
- package/package.json +40 -11
- package/src/__tests__/client.test.ts +362 -107
- package/src/__tests__/integration.test.ts +129 -38
- package/src/admin.ts +184 -0
- package/src/browser.ts +12 -0
- package/src/errors.ts +49 -0
- package/src/index.ts +35 -10
- package/src/public.ts +270 -0
- package/src/types.ts +164 -58
- package/src/validation.ts +52 -0
- package/src/client.ts +0 -257
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ The official TypeScript/JavaScript SDK for [Cobbl](https://cobbl.ai) - a feedbac
|
|
|
13
13
|
- 📦 **Zero config** - Works out of the box with sensible defaults
|
|
14
14
|
- 🌐 **Cross-platform** - Supports both CommonJS and ES modules
|
|
15
15
|
- ⚡ **Optimized** - Minimal bundle size, tree-shakeable exports
|
|
16
|
+
- 🎯 **Namespaced exports** - Separate admin and public clients for different use cases
|
|
16
17
|
|
|
17
18
|
## Installation
|
|
18
19
|
|
|
@@ -27,18 +28,39 @@ yarn add @cobbl-ai/sdk
|
|
|
27
28
|
pnpm add @cobbl-ai/sdk
|
|
28
29
|
```
|
|
29
30
|
|
|
31
|
+
### CDN / Script Tag
|
|
32
|
+
|
|
33
|
+
For use without a bundler, load the SDK via a `<script>` tag. This exposes `CobblPublicClient` on `window.Cobbl`:
|
|
34
|
+
|
|
35
|
+
```html
|
|
36
|
+
<script src="https://cdn.jsdelivr.net/npm/@cobbl-ai/sdk"></script>
|
|
37
|
+
|
|
38
|
+
<script>
|
|
39
|
+
const client = new Cobbl.CobblPublicClient()
|
|
40
|
+
|
|
41
|
+
client.createFeedback({
|
|
42
|
+
runId: 'your-run-id',
|
|
43
|
+
helpful: 'helpful',
|
|
44
|
+
}).then(({ id }) => {
|
|
45
|
+
console.log('Feedback created:', id)
|
|
46
|
+
})
|
|
47
|
+
</script>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
> **Note:** Only `CobblPublicClient` is available via the CDN bundle. The `CobblAdminClient` requires an API key and should only be used server-side.
|
|
51
|
+
|
|
30
52
|
## Quick Start
|
|
31
53
|
|
|
32
54
|
```typescript
|
|
33
|
-
|
|
55
|
+
// Admin operations (server-side)
|
|
56
|
+
import { CobblAdminClient } from '@cobbl-ai/sdk/admin'
|
|
34
57
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
apiKey: process.env.PROMPTI_API_KEY,
|
|
58
|
+
const adminClient = new CobblAdminClient({
|
|
59
|
+
apiKey: process.env.COBBL_API_KEY,
|
|
38
60
|
})
|
|
39
61
|
|
|
40
62
|
// Run a prompt
|
|
41
|
-
const result = await
|
|
63
|
+
const result = await adminClient.runPrompt('sales_summary', {
|
|
42
64
|
topic: 'Q4 Results',
|
|
43
65
|
tone: 'friendly',
|
|
44
66
|
audience: 'investors',
|
|
@@ -47,46 +69,98 @@ const result = await client.runPrompt('sales_summary', {
|
|
|
47
69
|
console.log(result.output) // AI-generated response
|
|
48
70
|
console.log(result.runId) // Save this to link feedback later
|
|
49
71
|
|
|
50
|
-
//
|
|
51
|
-
|
|
72
|
+
// Public operations (client-facing, no auth required)
|
|
73
|
+
import { CobblPublicClient } from '@cobbl-ai/sdk/public'
|
|
74
|
+
|
|
75
|
+
const publicClient = new CobblPublicClient()
|
|
76
|
+
|
|
77
|
+
// Create user feedback
|
|
78
|
+
await publicClient.createFeedback({
|
|
52
79
|
runId: result.runId,
|
|
53
80
|
helpful: 'not_helpful',
|
|
54
81
|
userFeedback: 'The response was too formal and lengthy',
|
|
55
82
|
})
|
|
56
83
|
```
|
|
57
84
|
|
|
85
|
+
## Namespaced Imports
|
|
86
|
+
|
|
87
|
+
The SDK provides separate entry points for admin and public operations:
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
// Admin client - for server-side operations
|
|
91
|
+
import { CobblAdminClient } from '@cobbl-ai/sdk/admin'
|
|
92
|
+
|
|
93
|
+
// Public client - for client-facing feedback operations
|
|
94
|
+
import { CobblPublicClient } from '@cobbl-ai/sdk/public'
|
|
95
|
+
|
|
96
|
+
// Or import both from main entry
|
|
97
|
+
import { CobblAdminClient, CobblPublicClient } from '@cobbl-ai/sdk'
|
|
98
|
+
```
|
|
99
|
+
|
|
58
100
|
## Configuration
|
|
59
101
|
|
|
60
|
-
### Initializing the
|
|
102
|
+
### Initializing the Clients
|
|
61
103
|
|
|
62
104
|
```typescript
|
|
63
|
-
import {
|
|
105
|
+
import { CobblAdminClient } from '@cobbl-ai/sdk/admin'
|
|
106
|
+
import { CobblPublicClient } from '@cobbl-ai/sdk/public'
|
|
107
|
+
|
|
108
|
+
// Production (uses default URL: https://api.cobbl.ai)
|
|
109
|
+
const adminClient = new CobblAdminClient({
|
|
110
|
+
apiKey: 'your-api-key',
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
// Public client (no auth required)
|
|
114
|
+
const publicClient = new CobblPublicClient()
|
|
64
115
|
|
|
65
|
-
|
|
66
|
-
|
|
116
|
+
// Custom URL (e.g., local development)
|
|
117
|
+
const devAdminClient = new CobblAdminClient({
|
|
118
|
+
apiKey: 'your-api-key',
|
|
119
|
+
baseUrl: 'http://localhost:5001/your-project-id/us-central1/externalApi',
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
const devPublicClient = new CobblPublicClient({
|
|
123
|
+
baseUrl: 'http://localhost:5001/your-project-id/us-central1/externalApi',
|
|
67
124
|
})
|
|
68
125
|
```
|
|
69
126
|
|
|
127
|
+
### Configuration Options
|
|
128
|
+
|
|
129
|
+
**CobblAdminClient:**
|
|
130
|
+
|
|
131
|
+
| Option | Type | Required | Default | Description |
|
|
132
|
+
| --------- | ------ | -------- | ---------------------- | -------------------- |
|
|
133
|
+
| `apiKey` | string | Yes | - | Your Cobbl API key |
|
|
134
|
+
| `baseUrl` | string | No | `https://api.cobbl.ai` | Base URL for the API |
|
|
135
|
+
|
|
136
|
+
**CobblPublicClient:**
|
|
137
|
+
|
|
138
|
+
| Option | Type | Required | Default | Description |
|
|
139
|
+
| --------- | ------ | -------- | ---------------------- | ------------------------------------------------- |
|
|
140
|
+
| `baseUrl` | string | No | `https://api.cobbl.ai` | Base URL for the API (no authentication required) |
|
|
141
|
+
|
|
70
142
|
### Environment Variables
|
|
71
143
|
|
|
72
144
|
We recommend storing your API key in environment variables:
|
|
73
145
|
|
|
74
146
|
```bash
|
|
75
147
|
# .env
|
|
76
|
-
|
|
148
|
+
COBBL_API_KEY=your_api_key_here
|
|
77
149
|
```
|
|
78
150
|
|
|
79
151
|
Then load it in your application:
|
|
80
152
|
|
|
81
153
|
```typescript
|
|
82
|
-
const
|
|
83
|
-
apiKey: process.env.
|
|
154
|
+
const adminClient = new CobblAdminClient({
|
|
155
|
+
apiKey: process.env.COBBL_API_KEY,
|
|
84
156
|
})
|
|
85
157
|
```
|
|
86
158
|
|
|
87
159
|
## API Reference
|
|
88
160
|
|
|
89
|
-
###
|
|
161
|
+
### CobblAdminClient
|
|
162
|
+
|
|
163
|
+
#### `runPrompt(promptSlug, input)`
|
|
90
164
|
|
|
91
165
|
Execute a prompt with the given input variables.
|
|
92
166
|
|
|
@@ -129,7 +203,7 @@ Execute a prompt with the given input variables.
|
|
|
129
203
|
**Example:**
|
|
130
204
|
|
|
131
205
|
```typescript
|
|
132
|
-
const result = await
|
|
206
|
+
const result = await adminClient.runPrompt('customer_email', {
|
|
133
207
|
customerName: 'John Doe',
|
|
134
208
|
issue: 'login_problem',
|
|
135
209
|
urgency: 'high',
|
|
@@ -139,24 +213,30 @@ console.log(result.output)
|
|
|
139
213
|
// => "Dear John Doe, We understand you're experiencing login issues..."
|
|
140
214
|
```
|
|
141
215
|
|
|
142
|
-
###
|
|
216
|
+
### CobblPublicClient
|
|
217
|
+
|
|
218
|
+
The public client is designed for end-user feedback submission and **does not require authentication**. This makes it safe to use in client-side applications like React, Vue, or vanilla JavaScript.
|
|
143
219
|
|
|
144
|
-
|
|
220
|
+
#### `createFeedback(feedback)`
|
|
221
|
+
|
|
222
|
+
Create user feedback for a prompt run.
|
|
145
223
|
|
|
146
224
|
**Parameters:**
|
|
147
225
|
|
|
148
|
-
- `feedback` (
|
|
226
|
+
- `feedback` (CreateFeedbackRequest):
|
|
149
227
|
- `runId` (string): The run ID from a previous `runPrompt` call
|
|
150
|
-
- `helpful` ('helpful' | 'not_helpful'): Whether the output was helpful
|
|
151
|
-
- `userFeedback` (string): Detailed feedback message
|
|
228
|
+
- `helpful` ('helpful' | 'not_helpful'): Whether the output was helpful (optional)
|
|
229
|
+
- `userFeedback` (string): Detailed feedback message (optional)
|
|
230
|
+
|
|
231
|
+
At least one of `helpful` or `userFeedback` is required.
|
|
152
232
|
|
|
153
|
-
**Returns:** `Promise<
|
|
233
|
+
**Returns:** `Promise<CreateFeedbackResponse>`
|
|
154
234
|
|
|
155
235
|
**Response:**
|
|
156
236
|
|
|
157
237
|
```typescript
|
|
158
238
|
{
|
|
159
|
-
|
|
239
|
+
id: string // Unique ID for the feedback item
|
|
160
240
|
message: string // Success message
|
|
161
241
|
}
|
|
162
242
|
```
|
|
@@ -164,13 +244,41 @@ Submit user feedback for a prompt run.
|
|
|
164
244
|
**Example:**
|
|
165
245
|
|
|
166
246
|
```typescript
|
|
167
|
-
await
|
|
247
|
+
await publicClient.createFeedback({
|
|
168
248
|
runId: result.runId,
|
|
169
249
|
helpful: 'not_helpful',
|
|
170
250
|
userFeedback: 'The tone was too casual for a professional email',
|
|
171
251
|
})
|
|
172
252
|
```
|
|
173
253
|
|
|
254
|
+
#### `updateFeedback(id, update)`
|
|
255
|
+
|
|
256
|
+
Update existing feedback with additional data.
|
|
257
|
+
|
|
258
|
+
**Parameters:**
|
|
259
|
+
|
|
260
|
+
- `id` (string): The feedback ID from `createFeedback`
|
|
261
|
+
- `update` (UpdateFeedbackRequest):
|
|
262
|
+
- `helpful` ('helpful' | 'not_helpful'): Whether the output was helpful (optional)
|
|
263
|
+
- `userFeedback` (string): Detailed feedback message (optional)
|
|
264
|
+
|
|
265
|
+
**Returns:** `Promise<UpdateFeedbackResponse>`
|
|
266
|
+
|
|
267
|
+
**Example:**
|
|
268
|
+
|
|
269
|
+
```typescript
|
|
270
|
+
// First create feedback with just a rating
|
|
271
|
+
const { id } = await publicClient.createFeedback({
|
|
272
|
+
runId: result.runId,
|
|
273
|
+
helpful: 'not_helpful',
|
|
274
|
+
})
|
|
275
|
+
|
|
276
|
+
// Later update with detailed feedback
|
|
277
|
+
await publicClient.updateFeedback(id, {
|
|
278
|
+
userFeedback: 'The response was too verbose and missed key points.',
|
|
279
|
+
})
|
|
280
|
+
```
|
|
281
|
+
|
|
174
282
|
## Advanced Usage
|
|
175
283
|
|
|
176
284
|
### Error Handling
|
|
@@ -178,10 +286,10 @@ await client.submitFeedback({
|
|
|
178
286
|
The SDK throws `CobblError` for all error cases. You can catch and handle these errors:
|
|
179
287
|
|
|
180
288
|
```typescript
|
|
181
|
-
import {
|
|
289
|
+
import { CobblAdminClient, CobblError } from '@cobbl-ai/sdk/admin'
|
|
182
290
|
|
|
183
291
|
try {
|
|
184
|
-
const result = await
|
|
292
|
+
const result = await adminClient.runPrompt('my-prompt', { topic: 'test' })
|
|
185
293
|
} catch (error) {
|
|
186
294
|
if (error instanceof CobblError) {
|
|
187
295
|
console.error(`Error [${error.code}]: ${error.message}`)
|
|
@@ -191,9 +299,15 @@ try {
|
|
|
191
299
|
case 'UNAUTHORIZED':
|
|
192
300
|
console.error('Invalid API key')
|
|
193
301
|
break
|
|
302
|
+
case 'FORBIDDEN':
|
|
303
|
+
console.error('Prompt is disabled or forbidden')
|
|
304
|
+
break
|
|
194
305
|
case 'NOT_FOUND':
|
|
195
306
|
console.error('Prompt not found')
|
|
196
307
|
break
|
|
308
|
+
case 'ARCHIVED':
|
|
309
|
+
console.error('Prompt has been archived')
|
|
310
|
+
break
|
|
197
311
|
case 'INVALID_REQUEST':
|
|
198
312
|
console.error('Invalid request:', error.details)
|
|
199
313
|
break
|
|
@@ -214,7 +328,9 @@ try {
|
|
|
214
328
|
- `INVALID_CONFIG` - Invalid SDK configuration
|
|
215
329
|
- `INVALID_REQUEST` - Malformed request (e.g., missing required fields)
|
|
216
330
|
- `UNAUTHORIZED` - Invalid or missing API key
|
|
331
|
+
- `FORBIDDEN` - Prompt is disabled or access is forbidden
|
|
217
332
|
- `NOT_FOUND` - Resource not found (e.g., prompt doesn't exist)
|
|
333
|
+
- `ARCHIVED` - Prompt has been archived and is no longer available
|
|
218
334
|
- `RATE_LIMIT_EXCEEDED` - Too many requests
|
|
219
335
|
- `SERVER_ERROR` - Server-side error
|
|
220
336
|
- `NETWORK_ERROR` - Network connectivity issue
|
|
@@ -228,7 +344,7 @@ The SDK is written in TypeScript and includes full type definitions:
|
|
|
228
344
|
import type {
|
|
229
345
|
PromptInput,
|
|
230
346
|
RunPromptResponse,
|
|
231
|
-
|
|
347
|
+
CreateFeedbackRequest,
|
|
232
348
|
TokenUsage,
|
|
233
349
|
} from '@cobbl-ai/sdk'
|
|
234
350
|
|
|
@@ -239,7 +355,10 @@ const input: PromptInput = {
|
|
|
239
355
|
}
|
|
240
356
|
|
|
241
357
|
// Type-safe response handling
|
|
242
|
-
const result: RunPromptResponse = await
|
|
358
|
+
const result: RunPromptResponse = await adminClient.runPrompt(
|
|
359
|
+
'blog_post',
|
|
360
|
+
input
|
|
361
|
+
)
|
|
243
362
|
|
|
244
363
|
// Access token usage
|
|
245
364
|
const tokens: TokenUsage = result.tokenUsage
|
|
@@ -252,16 +371,20 @@ console.log(`Used ${tokens.totalTokens} tokens`)
|
|
|
252
371
|
|
|
253
372
|
```typescript
|
|
254
373
|
import express from 'express'
|
|
255
|
-
import {
|
|
374
|
+
import { CobblAdminClient } from '@cobbl-ai/sdk/admin'
|
|
375
|
+
import { CobblPublicClient } from '@cobbl-ai/sdk/public'
|
|
256
376
|
|
|
257
377
|
const app = express()
|
|
258
|
-
const
|
|
259
|
-
apiKey: process.env.
|
|
378
|
+
const adminClient = new CobblAdminClient({
|
|
379
|
+
apiKey: process.env.COBBL_API_KEY,
|
|
380
|
+
})
|
|
381
|
+
const publicClient = new CobblPublicClient({
|
|
382
|
+
apiKey: process.env.COBBL_API_KEY,
|
|
260
383
|
})
|
|
261
384
|
|
|
262
385
|
app.post('/api/generate', async (req, res) => {
|
|
263
386
|
try {
|
|
264
|
-
const result = await
|
|
387
|
+
const result = await adminClient.runPrompt('content_generator', req.body)
|
|
265
388
|
res.json({
|
|
266
389
|
output: result.output,
|
|
267
390
|
runId: result.runId,
|
|
@@ -273,10 +396,10 @@ app.post('/api/generate', async (req, res) => {
|
|
|
273
396
|
|
|
274
397
|
app.post('/api/feedback', async (req, res) => {
|
|
275
398
|
try {
|
|
276
|
-
await
|
|
399
|
+
await publicClient.createFeedback(req.body)
|
|
277
400
|
res.json({ success: true })
|
|
278
401
|
} catch (error) {
|
|
279
|
-
res.status(500).json({ error: 'Failed to
|
|
402
|
+
res.status(500).json({ error: 'Failed to create feedback' })
|
|
280
403
|
}
|
|
281
404
|
})
|
|
282
405
|
```
|
|
@@ -285,18 +408,18 @@ app.post('/api/feedback', async (req, res) => {
|
|
|
285
408
|
|
|
286
409
|
```typescript
|
|
287
410
|
// app/api/generate/route.ts
|
|
288
|
-
import {
|
|
411
|
+
import { CobblAdminClient } from '@cobbl-ai/sdk/admin'
|
|
289
412
|
import { NextResponse } from 'next/server'
|
|
290
413
|
|
|
291
|
-
const
|
|
292
|
-
apiKey: process.env.
|
|
414
|
+
const adminClient = new CobblAdminClient({
|
|
415
|
+
apiKey: process.env.COBBL_API_KEY!,
|
|
293
416
|
})
|
|
294
417
|
|
|
295
418
|
export async function POST(request: Request) {
|
|
296
419
|
const body = await request.json()
|
|
297
420
|
|
|
298
421
|
try {
|
|
299
|
-
const result = await
|
|
422
|
+
const result = await adminClient.runPrompt('summarizer', {
|
|
300
423
|
text: body.text,
|
|
301
424
|
length: 'short',
|
|
302
425
|
})
|
|
@@ -311,7 +434,7 @@ export async function POST(request: Request) {
|
|
|
311
434
|
}
|
|
312
435
|
```
|
|
313
436
|
|
|
314
|
-
#### React
|
|
437
|
+
#### React (Client-Side via API)
|
|
315
438
|
|
|
316
439
|
```typescript
|
|
317
440
|
'use client'
|
|
@@ -382,7 +505,7 @@ Always save the `runId` returned from `runPrompt()` so users can provide feedbac
|
|
|
382
505
|
|
|
383
506
|
```typescript
|
|
384
507
|
// Store in database with your application data
|
|
385
|
-
const result = await
|
|
508
|
+
const result = await adminClient.runPrompt('recommendation', { userId: '123' })
|
|
386
509
|
|
|
387
510
|
await db.recommendations.create({
|
|
388
511
|
userId: '123',
|
|
@@ -397,7 +520,7 @@ Always wrap SDK calls in try-catch blocks and provide fallback behavior:
|
|
|
397
520
|
|
|
398
521
|
```typescript
|
|
399
522
|
try {
|
|
400
|
-
const result = await
|
|
523
|
+
const result = await adminClient.runPrompt('greeting', { name: userName })
|
|
401
524
|
return result.output
|
|
402
525
|
} catch (error) {
|
|
403
526
|
// Log for debugging
|
|
@@ -413,8 +536,8 @@ try {
|
|
|
413
536
|
Use different API keys for development, staging, and production:
|
|
414
537
|
|
|
415
538
|
```typescript
|
|
416
|
-
const
|
|
417
|
-
apiKey: process.env.
|
|
539
|
+
const adminClient = new CobblAdminClient({
|
|
540
|
+
apiKey: process.env.COBBL_API_KEY,
|
|
418
541
|
})
|
|
419
542
|
```
|
|
420
543
|
|
|
@@ -456,18 +579,21 @@ pnpm clean
|
|
|
456
579
|
```
|
|
457
580
|
sdk/
|
|
458
581
|
├── src/
|
|
459
|
-
│ ├──
|
|
582
|
+
│ ├── admin.ts # Admin API client
|
|
583
|
+
│ ├── public.ts # Public API client
|
|
584
|
+
│ ├── browser.ts # Browser entry point (CDN/script tag)
|
|
460
585
|
│ ├── errors.ts # Error classes
|
|
461
586
|
│ ├── types.ts # Type definitions
|
|
462
|
-
│ ├── shared-types.ts # Inlined types from shared package
|
|
463
587
|
│ └── index.ts # Public exports
|
|
464
588
|
├── dist/ # Compiled output (created by build)
|
|
465
|
-
│ ├── index.js # CommonJS bundle
|
|
466
|
-
│ ├── index.mjs # ES modules bundle
|
|
467
|
-
│ ├──
|
|
468
|
-
│ ├──
|
|
469
|
-
│
|
|
470
|
-
├──
|
|
589
|
+
│ ├── index.js # CommonJS bundle (main)
|
|
590
|
+
│ ├── index.mjs # ES modules bundle (main)
|
|
591
|
+
│ ├── admin.js # CommonJS bundle (admin)
|
|
592
|
+
│ ├── admin.mjs # ES modules bundle (admin)
|
|
593
|
+
│ ├── public.js # CommonJS bundle (public)
|
|
594
|
+
│ ├── public.mjs # ES modules bundle (public)
|
|
595
|
+
│ ├── cobbl-sdk.global.js # IIFE bundle for CDN/script tag
|
|
596
|
+
│ └── *.d.ts # TypeScript declarations
|
|
471
597
|
├── tsup.config.ts # Build configuration
|
|
472
598
|
├── package.json
|
|
473
599
|
└── README.md
|
|
@@ -494,8 +620,7 @@ Before publishing, make sure to:
|
|
|
494
620
|
```bash
|
|
495
621
|
# Test the package locally
|
|
496
622
|
pnpm pack
|
|
497
|
-
# This creates cobbl-ai
|
|
498
|
-
-sdk-0.1.0.tgz that you can test
|
|
623
|
+
# This creates @cobbl-ai-sdk-0.1.0.tgz that you can test
|
|
499
624
|
|
|
500
625
|
# Publish to npm (requires npm login)
|
|
501
626
|
pnpm publish --access public
|
|
@@ -507,9 +632,8 @@ pnpm publish --tag beta --access public
|
|
|
507
632
|
## Support
|
|
508
633
|
|
|
509
634
|
- 📧 Email: support@cobbl.ai
|
|
510
|
-
- 🐛 Issues: [GitHub Issues](https://github.com/
|
|
635
|
+
- 🐛 Issues: [GitHub Issues](https://github.com/cobbl-ai/sdk/issues)
|
|
511
636
|
- 📚 Documentation: [docs.cobbl.ai](https://docs.cobbl.ai)
|
|
512
|
-
- 💬 Discord: [Join our community](https://discord.gg/cobbl)
|
|
513
637
|
|
|
514
638
|
## License
|
|
515
639
|
|
package/dist/admin.d.mts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { b as CobblConfig, P as PromptInput, c as RunPromptResponse } from './errors-BaYZ2rGo.mjs';
|
|
2
|
+
export { C as CobblError, a as CobblErrorCode, g as PromptVersionClient, h as Provider, R as RunPromptRequest, T as TokenUsage, V as VariableConfig } from './errors-BaYZ2rGo.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Cobbl SDK - Admin API Client
|
|
6
|
+
*
|
|
7
|
+
* A client for admin/server-side operations like running prompts.
|
|
8
|
+
* Use this in server-side contexts where you need to execute prompts.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { CobblAdminClient } from '@cobbl-ai/sdk/admin'
|
|
13
|
+
*
|
|
14
|
+
* const client = new CobblAdminClient({
|
|
15
|
+
* apiKey: process.env.COBBL_API_KEY
|
|
16
|
+
* })
|
|
17
|
+
*
|
|
18
|
+
* // Run a prompt
|
|
19
|
+
* const result = await client.runPrompt('sales_summary', {
|
|
20
|
+
* topic: 'Q4 Results',
|
|
21
|
+
* tone: 'friendly'
|
|
22
|
+
* })
|
|
23
|
+
*
|
|
24
|
+
* console.log(result.output)
|
|
25
|
+
* console.log(result.runId) // Use this to link feedback later
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Admin API Client for Cobbl
|
|
31
|
+
*
|
|
32
|
+
* Provides methods to run prompts via the admin API.
|
|
33
|
+
* This client is suitable for use in server-side contexts.
|
|
34
|
+
*/
|
|
35
|
+
declare class CobblAdminClient {
|
|
36
|
+
private readonly apiKey;
|
|
37
|
+
private readonly baseUrl;
|
|
38
|
+
/**
|
|
39
|
+
* Initialize the Cobbl Admin SDK client
|
|
40
|
+
*
|
|
41
|
+
* @param config - Configuration object
|
|
42
|
+
* @param config.apiKey - Your Cobbl API key
|
|
43
|
+
* @param config.baseUrl - Optional base URL for the API (defaults to 'https://api.cobbl.ai')
|
|
44
|
+
*
|
|
45
|
+
* @example Production (uses default URL)
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const client = new CobblAdminClient({
|
|
48
|
+
* apiKey: process.env.COBBL_API_KEY
|
|
49
|
+
* })
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @example Local development with Firebase emulators
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const client = new CobblAdminClient({
|
|
55
|
+
* apiKey: process.env.COBBL_API_KEY,
|
|
56
|
+
* baseUrl: 'http://localhost:5001/your-project-id/us-central1/externalApi'
|
|
57
|
+
* })
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
constructor(config: CobblConfig);
|
|
61
|
+
/**
|
|
62
|
+
* Execute a prompt with the given input variables
|
|
63
|
+
*
|
|
64
|
+
* @param promptSlug - The unique slug identifier for the prompt
|
|
65
|
+
* @param input - Input variables to populate the prompt template
|
|
66
|
+
* @returns Promise containing the prompt execution results
|
|
67
|
+
*
|
|
68
|
+
* @throws {CobblError} When the request fails or API returns an error
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const result = await client.runPrompt('sales_summary', {
|
|
73
|
+
* topic: 'Q4 Results',
|
|
74
|
+
* tone: 'friendly',
|
|
75
|
+
* audience: 'investors'
|
|
76
|
+
* })
|
|
77
|
+
*
|
|
78
|
+
* console.log(result.output) // AI-generated response
|
|
79
|
+
* console.log(result.runId) // Save this to link feedback later
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
runPrompt(promptSlug: string, input: PromptInput): Promise<RunPromptResponse>;
|
|
83
|
+
/**
|
|
84
|
+
* Make an HTTP request to the Cobbl API
|
|
85
|
+
* @private
|
|
86
|
+
*/
|
|
87
|
+
private makeRequest;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export { CobblAdminClient, CobblConfig, PromptInput, RunPromptResponse };
|
package/dist/admin.d.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { b as CobblConfig, P as PromptInput, c as RunPromptResponse } from './errors-BaYZ2rGo.js';
|
|
2
|
+
export { C as CobblError, a as CobblErrorCode, g as PromptVersionClient, h as Provider, R as RunPromptRequest, T as TokenUsage, V as VariableConfig } from './errors-BaYZ2rGo.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Cobbl SDK - Admin API Client
|
|
6
|
+
*
|
|
7
|
+
* A client for admin/server-side operations like running prompts.
|
|
8
|
+
* Use this in server-side contexts where you need to execute prompts.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { CobblAdminClient } from '@cobbl-ai/sdk/admin'
|
|
13
|
+
*
|
|
14
|
+
* const client = new CobblAdminClient({
|
|
15
|
+
* apiKey: process.env.COBBL_API_KEY
|
|
16
|
+
* })
|
|
17
|
+
*
|
|
18
|
+
* // Run a prompt
|
|
19
|
+
* const result = await client.runPrompt('sales_summary', {
|
|
20
|
+
* topic: 'Q4 Results',
|
|
21
|
+
* tone: 'friendly'
|
|
22
|
+
* })
|
|
23
|
+
*
|
|
24
|
+
* console.log(result.output)
|
|
25
|
+
* console.log(result.runId) // Use this to link feedback later
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Admin API Client for Cobbl
|
|
31
|
+
*
|
|
32
|
+
* Provides methods to run prompts via the admin API.
|
|
33
|
+
* This client is suitable for use in server-side contexts.
|
|
34
|
+
*/
|
|
35
|
+
declare class CobblAdminClient {
|
|
36
|
+
private readonly apiKey;
|
|
37
|
+
private readonly baseUrl;
|
|
38
|
+
/**
|
|
39
|
+
* Initialize the Cobbl Admin SDK client
|
|
40
|
+
*
|
|
41
|
+
* @param config - Configuration object
|
|
42
|
+
* @param config.apiKey - Your Cobbl API key
|
|
43
|
+
* @param config.baseUrl - Optional base URL for the API (defaults to 'https://api.cobbl.ai')
|
|
44
|
+
*
|
|
45
|
+
* @example Production (uses default URL)
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const client = new CobblAdminClient({
|
|
48
|
+
* apiKey: process.env.COBBL_API_KEY
|
|
49
|
+
* })
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @example Local development with Firebase emulators
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const client = new CobblAdminClient({
|
|
55
|
+
* apiKey: process.env.COBBL_API_KEY,
|
|
56
|
+
* baseUrl: 'http://localhost:5001/your-project-id/us-central1/externalApi'
|
|
57
|
+
* })
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
constructor(config: CobblConfig);
|
|
61
|
+
/**
|
|
62
|
+
* Execute a prompt with the given input variables
|
|
63
|
+
*
|
|
64
|
+
* @param promptSlug - The unique slug identifier for the prompt
|
|
65
|
+
* @param input - Input variables to populate the prompt template
|
|
66
|
+
* @returns Promise containing the prompt execution results
|
|
67
|
+
*
|
|
68
|
+
* @throws {CobblError} When the request fails or API returns an error
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const result = await client.runPrompt('sales_summary', {
|
|
73
|
+
* topic: 'Q4 Results',
|
|
74
|
+
* tone: 'friendly',
|
|
75
|
+
* audience: 'investors'
|
|
76
|
+
* })
|
|
77
|
+
*
|
|
78
|
+
* console.log(result.output) // AI-generated response
|
|
79
|
+
* console.log(result.runId) // Save this to link feedback later
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
runPrompt(promptSlug: string, input: PromptInput): Promise<RunPromptResponse>;
|
|
83
|
+
/**
|
|
84
|
+
* Make an HTTP request to the Cobbl API
|
|
85
|
+
* @private
|
|
86
|
+
*/
|
|
87
|
+
private makeRequest;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export { CobblAdminClient, CobblConfig, PromptInput, RunPromptResponse };
|