@chucky.cloud/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 +330 -0
- package/dist/browser.d.ts +8 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +12 -0
- package/dist/browser.js.map +1 -0
- package/dist/client/ChuckyClient.d.ts +187 -0
- package/dist/client/ChuckyClient.d.ts.map +1 -0
- package/dist/client/ChuckyClient.js +232 -0
- package/dist/client/ChuckyClient.js.map +1 -0
- package/dist/client/Session.d.ts +146 -0
- package/dist/client/Session.d.ts.map +1 -0
- package/dist/client/Session.js +405 -0
- package/dist/client/Session.js.map +1 -0
- package/dist/client/index.d.ts +10 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +8 -0
- package/dist/client/index.js.map +1 -0
- package/dist/index.d.ts +69 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/node.d.ts +8 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +11 -0
- package/dist/node.js.map +1 -0
- package/dist/tools/McpServer.d.ts +117 -0
- package/dist/tools/McpServer.d.ts.map +1 -0
- package/dist/tools/McpServer.js +142 -0
- package/dist/tools/McpServer.js.map +1 -0
- package/dist/tools/index.d.ts +9 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +8 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/tool.d.ts +146 -0
- package/dist/tools/tool.d.ts.map +1 -0
- package/dist/tools/tool.js +232 -0
- package/dist/tools/tool.js.map +1 -0
- package/dist/transport/Transport.d.ts +82 -0
- package/dist/transport/Transport.d.ts.map +1 -0
- package/dist/transport/Transport.js +45 -0
- package/dist/transport/Transport.js.map +1 -0
- package/dist/transport/WebSocketTransport.d.ts +78 -0
- package/dist/transport/WebSocketTransport.d.ts.map +1 -0
- package/dist/transport/WebSocketTransport.js +253 -0
- package/dist/transport/WebSocketTransport.js.map +1 -0
- package/dist/transport/index.d.ts +10 -0
- package/dist/transport/index.d.ts.map +1 -0
- package/dist/transport/index.js +8 -0
- package/dist/transport/index.js.map +1 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +8 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/messages.d.ts +195 -0
- package/dist/types/messages.d.ts.map +1 -0
- package/dist/types/messages.js +70 -0
- package/dist/types/messages.js.map +1 -0
- package/dist/types/options.d.ts +210 -0
- package/dist/types/options.d.ts.map +1 -0
- package/dist/types/options.js +8 -0
- package/dist/types/options.js.map +1 -0
- package/dist/types/results.d.ts +182 -0
- package/dist/types/results.d.ts.map +1 -0
- package/dist/types/results.js +7 -0
- package/dist/types/results.js.map +1 -0
- package/dist/types/token.d.ts +124 -0
- package/dist/types/token.d.ts.map +1 -0
- package/dist/types/token.js +7 -0
- package/dist/types/token.js.map +1 -0
- package/dist/types/tools.d.ts +160 -0
- package/dist/types/tools.d.ts.map +1 -0
- package/dist/types/tools.js +8 -0
- package/dist/types/tools.js.map +1 -0
- package/dist/utils/errors.d.ts +80 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +158 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/token.d.ts +93 -0
- package/dist/utils/token.d.ts.map +1 -0
- package/dist/utils/token.js +195 -0
- package/dist/utils/token.js.map +1 -0
- package/package.json +63 -0
package/README.md
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
# @chucky.cloud/sdk
|
|
2
|
+
|
|
3
|
+
SDK for interacting with Chucky sandbox - supports both browser and Node.js.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @chucky.cloud/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { ChuckyClient, tool, createBudget, createToken } from '@chucky.cloud/sdk';
|
|
15
|
+
|
|
16
|
+
// Server-side: Create a token for your user
|
|
17
|
+
const token = await createToken({
|
|
18
|
+
userId: 'user-123',
|
|
19
|
+
projectId: 'your-project-uuid',
|
|
20
|
+
secret: 'your-hmac-secret',
|
|
21
|
+
budget: createBudget({
|
|
22
|
+
aiDollars: 1.00,
|
|
23
|
+
computeHours: 1,
|
|
24
|
+
window: 'day',
|
|
25
|
+
}),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Create client with the token
|
|
29
|
+
const client = new ChuckyClient({ token });
|
|
30
|
+
|
|
31
|
+
// Create a session
|
|
32
|
+
const session = await client.createSession({
|
|
33
|
+
model: 'claude-sonnet-4-5-20250929',
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Send a message and get response
|
|
37
|
+
const result = await session.send('Hello, world!');
|
|
38
|
+
console.log(result.text);
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Features
|
|
42
|
+
|
|
43
|
+
- **Browser & Node.js Support**: Same API works in both environments
|
|
44
|
+
- **Sessions**: Multi-turn conversations with state persistence
|
|
45
|
+
- **One-shot Prompts**: Stateless prompt execution
|
|
46
|
+
- **Tools**: Define custom tools with full type safety
|
|
47
|
+
- **Streaming**: Real-time response streaming
|
|
48
|
+
- **Token Management**: Create and verify JWT tokens
|
|
49
|
+
|
|
50
|
+
## Sessions
|
|
51
|
+
|
|
52
|
+
### Creating a Session
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
const session = await client.createSession({
|
|
56
|
+
model: 'claude-sonnet-4-5-20250929',
|
|
57
|
+
systemPrompt: 'You are a helpful assistant.',
|
|
58
|
+
maxTurns: 10,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const result = await session.send('What is 2 + 2?');
|
|
62
|
+
console.log(result.text); // "4"
|
|
63
|
+
|
|
64
|
+
// Multi-turn conversation
|
|
65
|
+
const followUp = await session.send('And what is that times 3?');
|
|
66
|
+
console.log(followUp.text); // "12"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Resuming a Session
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
const session = await client.resumeSession('session-123', {
|
|
73
|
+
continue: true,
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Streaming Responses
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
for await (const event of session.sendStream('Tell me a story')) {
|
|
81
|
+
if (event.type === 'text') {
|
|
82
|
+
process.stdout.write(event.text);
|
|
83
|
+
} else if (event.type === 'tool_use') {
|
|
84
|
+
console.log('Using tool:', event.name);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Tools
|
|
90
|
+
|
|
91
|
+
### Defining Tools
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
import { tool, textResult } from '@chucky.cloud/sdk';
|
|
95
|
+
|
|
96
|
+
const weatherTool = tool(
|
|
97
|
+
'get_weather',
|
|
98
|
+
'Get current weather for a city',
|
|
99
|
+
{
|
|
100
|
+
type: 'object',
|
|
101
|
+
properties: {
|
|
102
|
+
city: { type: 'string', description: 'City name' },
|
|
103
|
+
unit: { type: 'string', enum: ['celsius', 'fahrenheit'] },
|
|
104
|
+
},
|
|
105
|
+
required: ['city'],
|
|
106
|
+
},
|
|
107
|
+
async ({ city, unit }) => textResult(`Weather in ${city}: Sunny, 72°${unit === 'celsius' ? 'C' : 'F'}`)
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
const session = await client.createSession({
|
|
111
|
+
tools: [weatherTool],
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Browser Tools
|
|
116
|
+
|
|
117
|
+
Tools that execute in the browser:
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
import { browserTool } from '@chucky.cloud/sdk';
|
|
121
|
+
|
|
122
|
+
const alertTool = browserTool({
|
|
123
|
+
name: 'show_alert',
|
|
124
|
+
description: 'Show an alert dialog',
|
|
125
|
+
inputSchema: {
|
|
126
|
+
type: 'object',
|
|
127
|
+
properties: { message: { type: 'string' } },
|
|
128
|
+
required: ['message'],
|
|
129
|
+
},
|
|
130
|
+
handler: async ({ message }) => {
|
|
131
|
+
alert(message);
|
|
132
|
+
return { content: [{ type: 'text', text: 'Alert shown' }] };
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### MCP Server Builder
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
import { mcpServer, tool } from '@chucky.cloud/sdk';
|
|
141
|
+
|
|
142
|
+
const myTools = mcpServer('my-tools', '1.0.0')
|
|
143
|
+
.addTool({
|
|
144
|
+
name: 'greet',
|
|
145
|
+
description: 'Greet someone',
|
|
146
|
+
inputSchema: {
|
|
147
|
+
type: 'object',
|
|
148
|
+
properties: { name: { type: 'string' } },
|
|
149
|
+
required: ['name'],
|
|
150
|
+
},
|
|
151
|
+
handler: async ({ name }) => ({
|
|
152
|
+
content: [{ type: 'text', text: `Hello, ${name}!` }],
|
|
153
|
+
}),
|
|
154
|
+
})
|
|
155
|
+
.build();
|
|
156
|
+
|
|
157
|
+
const session = await client.createSession({
|
|
158
|
+
mcpServers: [myTools],
|
|
159
|
+
});
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Token Management
|
|
163
|
+
|
|
164
|
+
### Creating Tokens (Server-side)
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
import { createToken, createBudget } from '@chucky.cloud/sdk';
|
|
168
|
+
|
|
169
|
+
const token = await createToken({
|
|
170
|
+
userId: 'user-123',
|
|
171
|
+
projectId: 'your-project-uuid',
|
|
172
|
+
secret: 'your-hmac-secret',
|
|
173
|
+
expiresIn: 3600, // 1 hour
|
|
174
|
+
budget: createBudget({
|
|
175
|
+
aiDollars: 5.00,
|
|
176
|
+
computeHours: 2,
|
|
177
|
+
window: 'day',
|
|
178
|
+
}),
|
|
179
|
+
permissions: {
|
|
180
|
+
tools: ['get_weather', 'search'],
|
|
181
|
+
maxTurns: 20,
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Verifying Tokens
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
import { verifyToken, decodeToken, isTokenExpired } from '@chucky.cloud/sdk';
|
|
190
|
+
|
|
191
|
+
// Verify signature
|
|
192
|
+
const isValid = await verifyToken(token, 'your-hmac-secret');
|
|
193
|
+
|
|
194
|
+
// Decode without verification
|
|
195
|
+
const decoded = decodeToken(token);
|
|
196
|
+
console.log(decoded.payload.sub); // User ID
|
|
197
|
+
console.log(decoded.payload.budget); // Budget limits
|
|
198
|
+
|
|
199
|
+
// Check expiration
|
|
200
|
+
if (isTokenExpired(token)) {
|
|
201
|
+
console.log('Token has expired');
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Client Options
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
const client = new ChuckyClient({
|
|
209
|
+
// Required
|
|
210
|
+
token: 'your-jwt-token',
|
|
211
|
+
|
|
212
|
+
// Optional
|
|
213
|
+
baseUrl: 'wss://box.chucky.cloud/ws', // Custom endpoint
|
|
214
|
+
debug: false, // Enable debug logging
|
|
215
|
+
timeout: 30000, // Connection timeout (ms)
|
|
216
|
+
keepAliveInterval: 300000, // Keep-alive interval (ms)
|
|
217
|
+
autoReconnect: true, // Auto-reconnect on disconnect
|
|
218
|
+
maxReconnectAttempts: 5, // Max reconnect attempts
|
|
219
|
+
});
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Session Options
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
const session = await client.createSession({
|
|
226
|
+
// Model
|
|
227
|
+
model: 'claude-sonnet-4-5-20250929',
|
|
228
|
+
fallbackModel: 'claude-3-5-haiku-20241022',
|
|
229
|
+
|
|
230
|
+
// Limits
|
|
231
|
+
maxTurns: 10,
|
|
232
|
+
maxBudgetUsd: 1.00,
|
|
233
|
+
maxThinkingTokens: 10000,
|
|
234
|
+
|
|
235
|
+
// System prompt
|
|
236
|
+
systemPrompt: 'You are a helpful assistant.',
|
|
237
|
+
// Or use preset:
|
|
238
|
+
// systemPrompt: { type: 'preset', preset: 'claude_code', append: 'Be concise.' },
|
|
239
|
+
|
|
240
|
+
// Tools
|
|
241
|
+
tools: [myTool],
|
|
242
|
+
allowedTools: ['get_weather'],
|
|
243
|
+
disallowedTools: ['dangerous_tool'],
|
|
244
|
+
|
|
245
|
+
// MCP servers
|
|
246
|
+
mcpServers: [myServer],
|
|
247
|
+
|
|
248
|
+
// Sub-agents
|
|
249
|
+
agents: {
|
|
250
|
+
researcher: {
|
|
251
|
+
name: 'Researcher',
|
|
252
|
+
model: 'claude-sonnet-4-5-20250929',
|
|
253
|
+
tools: ['search'],
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
|
|
257
|
+
// Session management
|
|
258
|
+
sessionId: 'session-123', // Resume existing session
|
|
259
|
+
forkSession: true, // Fork instead of resume
|
|
260
|
+
continue: true, // Continue from where left off
|
|
261
|
+
|
|
262
|
+
// Output
|
|
263
|
+
includePartialMessages: true,
|
|
264
|
+
outputFormat: {
|
|
265
|
+
type: 'json_schema',
|
|
266
|
+
schema: { /* your schema */ },
|
|
267
|
+
},
|
|
268
|
+
});
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
## Error Handling
|
|
272
|
+
|
|
273
|
+
```typescript
|
|
274
|
+
import {
|
|
275
|
+
ChuckyError,
|
|
276
|
+
ConnectionError,
|
|
277
|
+
AuthenticationError,
|
|
278
|
+
BudgetExceededError,
|
|
279
|
+
ConcurrencyLimitError,
|
|
280
|
+
} from '@chucky.cloud/sdk';
|
|
281
|
+
|
|
282
|
+
try {
|
|
283
|
+
await session.send('Hello');
|
|
284
|
+
} catch (error) {
|
|
285
|
+
if (error instanceof BudgetExceededError) {
|
|
286
|
+
console.log('Budget exceeded:', error.message);
|
|
287
|
+
} else if (error instanceof ConcurrencyLimitError) {
|
|
288
|
+
console.log('Too many concurrent sessions');
|
|
289
|
+
} else if (error instanceof AuthenticationError) {
|
|
290
|
+
console.log('Invalid token');
|
|
291
|
+
} else if (error instanceof ConnectionError) {
|
|
292
|
+
console.log('Connection failed');
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## TypeScript
|
|
298
|
+
|
|
299
|
+
The SDK is fully typed. All types are exported:
|
|
300
|
+
|
|
301
|
+
```typescript
|
|
302
|
+
import type {
|
|
303
|
+
// Options
|
|
304
|
+
ClientOptions,
|
|
305
|
+
SessionOptions,
|
|
306
|
+
PromptOptions,
|
|
307
|
+
|
|
308
|
+
// Tools
|
|
309
|
+
ToolDefinition,
|
|
310
|
+
ToolResult,
|
|
311
|
+
ToolInputSchema,
|
|
312
|
+
McpServerDefinition,
|
|
313
|
+
|
|
314
|
+
// Results
|
|
315
|
+
SessionResult,
|
|
316
|
+
PromptResult,
|
|
317
|
+
Message,
|
|
318
|
+
|
|
319
|
+
// Token
|
|
320
|
+
BudgetTokenPayload,
|
|
321
|
+
TokenBudget,
|
|
322
|
+
|
|
323
|
+
// Streaming
|
|
324
|
+
StreamingEvent,
|
|
325
|
+
} from '@chucky.cloud/sdk';
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
## License
|
|
329
|
+
|
|
330
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,YAAY,CAAC"}
|
package/dist/browser.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser Entry Point
|
|
3
|
+
*
|
|
4
|
+
* Optimized exports for browser environments.
|
|
5
|
+
* Excludes Node.js-specific functionality like token creation.
|
|
6
|
+
*/
|
|
7
|
+
// Re-export everything from main index
|
|
8
|
+
export * from './index.js';
|
|
9
|
+
// Browser-specific note: Token creation uses Web Crypto API
|
|
10
|
+
// which is available in modern browsers. For older browsers,
|
|
11
|
+
// you may need a polyfill.
|
|
12
|
+
//# sourceMappingURL=browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,uCAAuC;AACvC,cAAc,YAAY,CAAC;AAE3B,4DAA4D;AAC5D,6DAA6D;AAC7D,2BAA2B"}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chucky Client
|
|
3
|
+
*
|
|
4
|
+
* Main entry point for the Chucky SDK.
|
|
5
|
+
* Provides methods to create sessions and execute prompts.
|
|
6
|
+
*/
|
|
7
|
+
import type { ClientOptions, SessionOptions, PromptOptions, ConnectionStatus, ClientEventHandlers } from '../types/options.js';
|
|
8
|
+
import type { PromptResult } from '../types/results.js';
|
|
9
|
+
import { Session } from './Session.js';
|
|
10
|
+
/**
|
|
11
|
+
* Chucky client for interacting with the sandbox service
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { ChuckyClient } from '@chucky.cloud/sdk';
|
|
16
|
+
*
|
|
17
|
+
* const client = new ChuckyClient({
|
|
18
|
+
* token: 'your-jwt-token',
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* // Create a session
|
|
22
|
+
* const session = await client.createSession({
|
|
23
|
+
* model: 'claude-sonnet-4-5-20250929',
|
|
24
|
+
* systemPrompt: 'You are a helpful assistant.',
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // Send messages
|
|
28
|
+
* const result = await session.send('Hello, world!');
|
|
29
|
+
* console.log(result.text);
|
|
30
|
+
*
|
|
31
|
+
* // Or use one-shot prompts
|
|
32
|
+
* const response = await client.prompt({
|
|
33
|
+
* message: 'What is 2 + 2?',
|
|
34
|
+
* model: 'claude-sonnet-4-5-20250929',
|
|
35
|
+
* });
|
|
36
|
+
* console.log(response.text);
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare class ChuckyClient {
|
|
40
|
+
private readonly options;
|
|
41
|
+
private transport;
|
|
42
|
+
private eventHandlers;
|
|
43
|
+
private activeSessions;
|
|
44
|
+
/**
|
|
45
|
+
* Create a new Chucky client
|
|
46
|
+
*/
|
|
47
|
+
constructor(options: ClientOptions);
|
|
48
|
+
/**
|
|
49
|
+
* Get the current connection status
|
|
50
|
+
*/
|
|
51
|
+
get status(): ConnectionStatus;
|
|
52
|
+
/**
|
|
53
|
+
* Set event handlers
|
|
54
|
+
*/
|
|
55
|
+
on(handlers: ClientEventHandlers): this;
|
|
56
|
+
/**
|
|
57
|
+
* Create a new session
|
|
58
|
+
*
|
|
59
|
+
* @param options - Session configuration options
|
|
60
|
+
* @returns A new session instance
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const session = await client.createSession({
|
|
65
|
+
* model: 'claude-sonnet-4-5-20250929',
|
|
66
|
+
* systemPrompt: 'You are a helpful coding assistant.',
|
|
67
|
+
* tools: [
|
|
68
|
+
* {
|
|
69
|
+
* name: 'get_weather',
|
|
70
|
+
* description: 'Get the current weather',
|
|
71
|
+
* inputSchema: {
|
|
72
|
+
* type: 'object',
|
|
73
|
+
* properties: {
|
|
74
|
+
* city: { type: 'string', description: 'City name' },
|
|
75
|
+
* },
|
|
76
|
+
* required: ['city'],
|
|
77
|
+
* },
|
|
78
|
+
* handler: async ({ city }) => ({
|
|
79
|
+
* content: [{ type: 'text', text: `Weather in ${city}: Sunny, 72°F` }],
|
|
80
|
+
* }),
|
|
81
|
+
* },
|
|
82
|
+
* ],
|
|
83
|
+
* });
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
createSession(options?: SessionOptions): Promise<Session>;
|
|
87
|
+
/**
|
|
88
|
+
* Resume an existing session
|
|
89
|
+
*
|
|
90
|
+
* @param sessionId - The session ID to resume
|
|
91
|
+
* @param options - Additional session options
|
|
92
|
+
* @returns The resumed session
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* const session = await client.resumeSession('session-123', {
|
|
97
|
+
* continue: true,
|
|
98
|
+
* });
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
resumeSession(sessionId: string, options?: Omit<SessionOptions, 'sessionId'>): Promise<Session>;
|
|
102
|
+
/**
|
|
103
|
+
* Execute a one-shot prompt (stateless)
|
|
104
|
+
*
|
|
105
|
+
* @param options - Prompt configuration
|
|
106
|
+
* @returns The prompt result
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const result = await client.prompt({
|
|
111
|
+
* message: 'Explain quantum computing in simple terms',
|
|
112
|
+
* model: 'claude-sonnet-4-5-20250929',
|
|
113
|
+
* });
|
|
114
|
+
* console.log(result.text);
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
prompt(options: PromptOptions): Promise<PromptResult>;
|
|
118
|
+
/**
|
|
119
|
+
* Execute a prompt with streaming
|
|
120
|
+
*
|
|
121
|
+
* @param options - Prompt configuration
|
|
122
|
+
* @yields Stream events and final result
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* for await (const event of client.promptStream({ message: 'Tell me a story' })) {
|
|
127
|
+
* if (event.type === 'text') {
|
|
128
|
+
* process.stdout.write(event.text);
|
|
129
|
+
* }
|
|
130
|
+
* }
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
promptStream(options: PromptOptions): AsyncGenerator<StreamingEvent, PromptResult, unknown>;
|
|
134
|
+
/**
|
|
135
|
+
* Close all active sessions and disconnect
|
|
136
|
+
*/
|
|
137
|
+
close(): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Create a new transport instance
|
|
140
|
+
*/
|
|
141
|
+
private createTransport;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Streaming event types
|
|
145
|
+
*/
|
|
146
|
+
export interface StreamingTextEvent {
|
|
147
|
+
type: 'text';
|
|
148
|
+
text: string;
|
|
149
|
+
}
|
|
150
|
+
export interface StreamingToolUseEvent {
|
|
151
|
+
type: 'tool_use';
|
|
152
|
+
id: string;
|
|
153
|
+
name: string;
|
|
154
|
+
input: Record<string, unknown>;
|
|
155
|
+
}
|
|
156
|
+
export interface StreamingToolResultEvent {
|
|
157
|
+
type: 'tool_result';
|
|
158
|
+
id: string;
|
|
159
|
+
content: unknown;
|
|
160
|
+
isError?: boolean;
|
|
161
|
+
}
|
|
162
|
+
export interface StreamingThinkingEvent {
|
|
163
|
+
type: 'thinking';
|
|
164
|
+
thinking: string;
|
|
165
|
+
}
|
|
166
|
+
export interface StreamingErrorEvent {
|
|
167
|
+
type: 'error';
|
|
168
|
+
error: Error;
|
|
169
|
+
}
|
|
170
|
+
export type StreamingEvent = StreamingTextEvent | StreamingToolUseEvent | StreamingToolResultEvent | StreamingThinkingEvent | StreamingErrorEvent;
|
|
171
|
+
/**
|
|
172
|
+
* Create a Chucky client
|
|
173
|
+
*
|
|
174
|
+
* @param options - Client configuration
|
|
175
|
+
* @returns A new ChuckyClient instance
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```typescript
|
|
179
|
+
* import { createClient } from '@chucky.cloud/sdk';
|
|
180
|
+
*
|
|
181
|
+
* const client = createClient({
|
|
182
|
+
* token: 'your-jwt-token',
|
|
183
|
+
* });
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
export declare function createClient(options: ClientOptions): ChuckyClient;
|
|
187
|
+
//# sourceMappingURL=ChuckyClient.d.ts.map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