@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
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session
|
|
3
|
+
*
|
|
4
|
+
* Represents a conversation session with the Chucky sandbox.
|
|
5
|
+
* Supports multi-turn conversations, tool execution, and streaming.
|
|
6
|
+
*/
|
|
7
|
+
import { createInitMessage, createSdkMessage, createControlMessage, createToolResultMessage, isToolCallMessage, isControlMessage, isResultMessage, isErrorMessage, } from '../types/messages.js';
|
|
8
|
+
/**
|
|
9
|
+
* Session class for managing conversations
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const session = await client.createSession({
|
|
14
|
+
* model: 'claude-sonnet-4-5-20250929',
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* // Simple send
|
|
18
|
+
* const result = await session.send('Hello!');
|
|
19
|
+
*
|
|
20
|
+
* // Streaming
|
|
21
|
+
* for await (const event of session.sendStream('Tell me a story')) {
|
|
22
|
+
* if (event.type === 'text') {
|
|
23
|
+
* process.stdout.write(event.text);
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* // Multi-turn
|
|
28
|
+
* await session.send('What is the capital of France?');
|
|
29
|
+
* await session.send('What about Germany?');
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export class Session {
|
|
33
|
+
transport;
|
|
34
|
+
options;
|
|
35
|
+
config;
|
|
36
|
+
eventHandlers = {};
|
|
37
|
+
toolHandlers = new Map();
|
|
38
|
+
messageBuffer = [];
|
|
39
|
+
currentResult = null;
|
|
40
|
+
_state = 'idle';
|
|
41
|
+
_sessionId = null;
|
|
42
|
+
messageResolvers = [];
|
|
43
|
+
constructor(transport, options, config = {}) {
|
|
44
|
+
this.transport = transport;
|
|
45
|
+
this.options = options;
|
|
46
|
+
this.config = config;
|
|
47
|
+
// Extract tool handlers from tool definitions
|
|
48
|
+
if (options.tools) {
|
|
49
|
+
for (const tool of options.tools) {
|
|
50
|
+
if (tool.handler) {
|
|
51
|
+
this.toolHandlers.set(tool.name, tool.handler);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// Set up transport event handlers
|
|
56
|
+
this.transport.setEventHandlers({
|
|
57
|
+
onMessage: (message) => this.handleMessage(message),
|
|
58
|
+
onError: (error) => this.eventHandlers.onError?.(error),
|
|
59
|
+
onStatusChange: (status) => {
|
|
60
|
+
if (status === 'disconnected' && this._state !== 'completed') {
|
|
61
|
+
this._state = 'error';
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get the current session state
|
|
68
|
+
*/
|
|
69
|
+
get state() {
|
|
70
|
+
return this._state;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get the session ID
|
|
74
|
+
*/
|
|
75
|
+
get sessionId() {
|
|
76
|
+
return this._sessionId;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Set event handlers
|
|
80
|
+
*/
|
|
81
|
+
on(handlers) {
|
|
82
|
+
this.eventHandlers = { ...this.eventHandlers, ...handlers };
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Connect and initialize the session
|
|
87
|
+
*/
|
|
88
|
+
async connect() {
|
|
89
|
+
this._state = 'initializing';
|
|
90
|
+
await this.transport.connect();
|
|
91
|
+
// Send init message
|
|
92
|
+
const initPayload = this.buildInitPayload();
|
|
93
|
+
await this.transport.send(createInitMessage(initPayload));
|
|
94
|
+
// Wait for ready/session_info
|
|
95
|
+
await this.waitForReady();
|
|
96
|
+
this._state = 'ready';
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Send a message and wait for complete response
|
|
100
|
+
*/
|
|
101
|
+
async send(message) {
|
|
102
|
+
if (this._state !== 'ready') {
|
|
103
|
+
throw new Error(`Cannot send: session state is ${this._state}`);
|
|
104
|
+
}
|
|
105
|
+
this._state = 'processing';
|
|
106
|
+
this.currentResult = null;
|
|
107
|
+
// Send user message
|
|
108
|
+
await this.transport.send(createSdkMessage({
|
|
109
|
+
type: 'user_message',
|
|
110
|
+
content: message,
|
|
111
|
+
}));
|
|
112
|
+
// Wait for result
|
|
113
|
+
const result = await this.waitForResult();
|
|
114
|
+
this._state = 'ready';
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Send a message with streaming
|
|
119
|
+
*/
|
|
120
|
+
async *sendStream(message) {
|
|
121
|
+
if (this._state !== 'ready') {
|
|
122
|
+
throw new Error(`Cannot send: session state is ${this._state}`);
|
|
123
|
+
}
|
|
124
|
+
this._state = 'processing';
|
|
125
|
+
this.currentResult = null;
|
|
126
|
+
// Send user message
|
|
127
|
+
await this.transport.send(createSdkMessage({
|
|
128
|
+
type: 'user_message',
|
|
129
|
+
content: message,
|
|
130
|
+
}));
|
|
131
|
+
// Stream messages
|
|
132
|
+
while (this._state === 'processing' || this._state === 'waiting_tool') {
|
|
133
|
+
const msg = await this.waitForNextMessage();
|
|
134
|
+
// Convert to streaming events
|
|
135
|
+
const events = this.messageToStreamingEvents(msg);
|
|
136
|
+
for (const event of events) {
|
|
137
|
+
yield event;
|
|
138
|
+
}
|
|
139
|
+
// Check if complete
|
|
140
|
+
if (isResultMessage(msg)) {
|
|
141
|
+
this.currentResult = msg.payload;
|
|
142
|
+
this._state = 'completed';
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
// Handle tool calls
|
|
146
|
+
if (isToolCallMessage(msg)) {
|
|
147
|
+
this._state = 'waiting_tool';
|
|
148
|
+
await this.handleToolCall(msg.payload);
|
|
149
|
+
this._state = 'processing';
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
this._state = 'ready';
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Execute a one-shot prompt
|
|
156
|
+
*/
|
|
157
|
+
async prompt(message) {
|
|
158
|
+
return this.send(message);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Get the current/last result
|
|
162
|
+
*/
|
|
163
|
+
getResult() {
|
|
164
|
+
return this.currentResult;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Close the session
|
|
168
|
+
*/
|
|
169
|
+
async close() {
|
|
170
|
+
await this.transport.send(createControlMessage('close'));
|
|
171
|
+
await this.transport.disconnect();
|
|
172
|
+
this._state = 'completed';
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Build init payload from options
|
|
176
|
+
*/
|
|
177
|
+
buildInitPayload() {
|
|
178
|
+
const { tools, mcpServers, ...rest } = this.options;
|
|
179
|
+
// Serialize tools (remove handlers)
|
|
180
|
+
const serializedTools = tools?.map((tool) => ({
|
|
181
|
+
name: tool.name,
|
|
182
|
+
description: tool.description,
|
|
183
|
+
inputSchema: tool.inputSchema,
|
|
184
|
+
executeIn: tool.executeIn,
|
|
185
|
+
}));
|
|
186
|
+
// Serialize MCP servers
|
|
187
|
+
const serializedMcpServers = mcpServers?.map((server) => ({
|
|
188
|
+
name: server.name,
|
|
189
|
+
version: server.version,
|
|
190
|
+
tools: server.tools.map((tool) => ({
|
|
191
|
+
name: tool.name,
|
|
192
|
+
description: tool.description,
|
|
193
|
+
inputSchema: tool.inputSchema,
|
|
194
|
+
executeIn: tool.executeIn,
|
|
195
|
+
})),
|
|
196
|
+
}));
|
|
197
|
+
return {
|
|
198
|
+
...rest,
|
|
199
|
+
tools: serializedTools,
|
|
200
|
+
mcpServers: serializedMcpServers,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Handle incoming message
|
|
205
|
+
*/
|
|
206
|
+
handleMessage(message) {
|
|
207
|
+
this.log('Received:', message.type);
|
|
208
|
+
// Handle control messages
|
|
209
|
+
if (isControlMessage(message)) {
|
|
210
|
+
if (message.payload.action === 'session_info') {
|
|
211
|
+
const info = message.payload.data;
|
|
212
|
+
this._sessionId = info.sessionId;
|
|
213
|
+
this.eventHandlers.onSessionInfo?.(info);
|
|
214
|
+
}
|
|
215
|
+
else if (message.payload.action === 'ready') {
|
|
216
|
+
// Session is ready
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// Handle errors
|
|
220
|
+
if (isErrorMessage(message)) {
|
|
221
|
+
const error = new Error(message.payload.message);
|
|
222
|
+
this.eventHandlers.onError?.(error);
|
|
223
|
+
}
|
|
224
|
+
// Handle tool calls
|
|
225
|
+
if (isToolCallMessage(message)) {
|
|
226
|
+
// Will be handled by stream/send
|
|
227
|
+
}
|
|
228
|
+
// Handle results
|
|
229
|
+
if (isResultMessage(message)) {
|
|
230
|
+
this.currentResult = message.payload;
|
|
231
|
+
this.eventHandlers.onComplete?.(this.currentResult);
|
|
232
|
+
}
|
|
233
|
+
// Notify waiting resolvers
|
|
234
|
+
const resolver = this.messageResolvers.shift();
|
|
235
|
+
if (resolver) {
|
|
236
|
+
resolver(message);
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
this.messageBuffer.push(message);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Wait for session to be ready
|
|
244
|
+
*/
|
|
245
|
+
async waitForReady() {
|
|
246
|
+
return new Promise((resolve, reject) => {
|
|
247
|
+
const timeout = setTimeout(() => {
|
|
248
|
+
reject(new Error('Session initialization timeout'));
|
|
249
|
+
}, 30000);
|
|
250
|
+
const checkReady = (message) => {
|
|
251
|
+
if (isControlMessage(message)) {
|
|
252
|
+
if (message.payload.action === 'ready' || message.payload.action === 'session_info') {
|
|
253
|
+
clearTimeout(timeout);
|
|
254
|
+
resolve();
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if (isErrorMessage(message)) {
|
|
259
|
+
clearTimeout(timeout);
|
|
260
|
+
reject(new Error(message.payload.message));
|
|
261
|
+
return true;
|
|
262
|
+
}
|
|
263
|
+
return false;
|
|
264
|
+
};
|
|
265
|
+
// Check buffered messages first
|
|
266
|
+
for (let i = 0; i < this.messageBuffer.length; i++) {
|
|
267
|
+
if (checkReady(this.messageBuffer[i])) {
|
|
268
|
+
this.messageBuffer.splice(i, 1);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
// Wait for new message
|
|
273
|
+
this.messageResolvers.push((msg) => {
|
|
274
|
+
checkReady(msg);
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Wait for result
|
|
280
|
+
*/
|
|
281
|
+
async waitForResult() {
|
|
282
|
+
return new Promise((resolve, reject) => {
|
|
283
|
+
const processMessage = async (message) => {
|
|
284
|
+
if (isResultMessage(message)) {
|
|
285
|
+
this.currentResult = message.payload;
|
|
286
|
+
resolve(this.currentResult);
|
|
287
|
+
return true;
|
|
288
|
+
}
|
|
289
|
+
if (isErrorMessage(message)) {
|
|
290
|
+
reject(new Error(message.payload.message));
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
if (isToolCallMessage(message)) {
|
|
294
|
+
await this.handleToolCall(message.payload);
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
return false;
|
|
298
|
+
};
|
|
299
|
+
const processLoop = async () => {
|
|
300
|
+
// Process buffered messages
|
|
301
|
+
while (this.messageBuffer.length > 0) {
|
|
302
|
+
const msg = this.messageBuffer.shift();
|
|
303
|
+
if (await processMessage(msg)) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
// Wait for new messages
|
|
308
|
+
const waitForNext = () => {
|
|
309
|
+
this.messageResolvers.push(async (msg) => {
|
|
310
|
+
if (await processMessage(msg)) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
waitForNext();
|
|
314
|
+
});
|
|
315
|
+
};
|
|
316
|
+
waitForNext();
|
|
317
|
+
};
|
|
318
|
+
processLoop();
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Wait for next message
|
|
323
|
+
*/
|
|
324
|
+
async waitForNextMessage() {
|
|
325
|
+
// Check buffer first
|
|
326
|
+
if (this.messageBuffer.length > 0) {
|
|
327
|
+
return this.messageBuffer.shift();
|
|
328
|
+
}
|
|
329
|
+
// Wait for new message
|
|
330
|
+
return new Promise((resolve) => {
|
|
331
|
+
this.messageResolvers.push(resolve);
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Handle a tool call
|
|
336
|
+
*/
|
|
337
|
+
async handleToolCall(toolCall) {
|
|
338
|
+
const handler = this.toolHandlers.get(toolCall.toolName);
|
|
339
|
+
if (!handler) {
|
|
340
|
+
// No local handler - server will execute it
|
|
341
|
+
this.log('No local handler for tool:', toolCall.toolName);
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
this.log('Executing tool:', toolCall.toolName);
|
|
345
|
+
this.eventHandlers.onToolUse?.(toolCall);
|
|
346
|
+
try {
|
|
347
|
+
const result = await handler(toolCall.input);
|
|
348
|
+
this.eventHandlers.onToolResult?.(toolCall.callId, result);
|
|
349
|
+
// Send result back
|
|
350
|
+
await this.transport.send(createToolResultMessage(toolCall.callId, result));
|
|
351
|
+
}
|
|
352
|
+
catch (error) {
|
|
353
|
+
const errorResult = {
|
|
354
|
+
content: [{ type: 'text', text: error.message }],
|
|
355
|
+
isError: true,
|
|
356
|
+
};
|
|
357
|
+
await this.transport.send(createToolResultMessage(toolCall.callId, errorResult));
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Convert message to streaming events
|
|
362
|
+
*/
|
|
363
|
+
messageToStreamingEvents(message) {
|
|
364
|
+
const events = [];
|
|
365
|
+
if (message.type === 'sdk_message') {
|
|
366
|
+
const payload = message.payload;
|
|
367
|
+
// Handle different SDK message types
|
|
368
|
+
if (payload.type === 'assistant_message' || payload.type === 'content_block_delta') {
|
|
369
|
+
const delta = payload.delta;
|
|
370
|
+
if (delta?.type === 'text_delta' && delta.text) {
|
|
371
|
+
events.push({ type: 'text', text: delta.text });
|
|
372
|
+
this.eventHandlers.onText?.(delta.text);
|
|
373
|
+
}
|
|
374
|
+
else if (delta?.type === 'thinking_delta' && delta.thinking) {
|
|
375
|
+
events.push({ type: 'thinking', thinking: delta.thinking });
|
|
376
|
+
this.eventHandlers.onThinking?.(delta.thinking);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
if (isToolCallMessage(message)) {
|
|
381
|
+
events.push({
|
|
382
|
+
type: 'tool_use',
|
|
383
|
+
id: message.payload.callId,
|
|
384
|
+
name: message.payload.toolName,
|
|
385
|
+
input: message.payload.input,
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
if (isErrorMessage(message)) {
|
|
389
|
+
events.push({
|
|
390
|
+
type: 'error',
|
|
391
|
+
error: new Error(message.payload.message),
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
return events;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Log debug messages
|
|
398
|
+
*/
|
|
399
|
+
log(...args) {
|
|
400
|
+
if (this.config.debug) {
|
|
401
|
+
console.log('[ChuckySession]', ...args);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
//# sourceMappingURL=Session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Session.js","sourceRoot":"","sources":["../../src/client/Session.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACvB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,cAAc,GACf,MAAM,sBAAsB,CAAC;AAkC9B;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,OAAO;IACV,SAAS,CAAY;IACrB,OAAO,CAAiB;IACxB,MAAM,CAAgB;IACtB,aAAa,GAAyB,EAAE,CAAC;IACzC,YAAY,GAA2C,IAAI,GAAG,EAAE,CAAC;IACjE,aAAa,GAAsB,EAAE,CAAC;IACtC,aAAa,GAAyB,IAAI,CAAC;IAC3C,MAAM,GAAiB,MAAM,CAAC;IAC9B,UAAU,GAAkB,IAAI,CAAC;IACjC,gBAAgB,GAA8C,EAAE,CAAC;IAEzE,YAAY,SAAoB,EAAE,OAAuB,EAAE,S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,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;oBAC5D,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;gBAClD,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,iBAAiB,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/B,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,UAAU;gBAChB,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM;gBAC1B,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,QAAQ;gBAC9B,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK;aAC7B,CAAC,CAAC;QACL,CAAC;QAED,IAAI,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5B,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;aAC1C,CAAC,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;OAEG;IACK,GAAG,CAAC,GAAG,IAAe;QAC5B,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YACtB,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,GAAG,IAAI,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client Index
|
|
3
|
+
*
|
|
4
|
+
* Re-exports all client classes and types.
|
|
5
|
+
*/
|
|
6
|
+
export { ChuckyClient, createClient } from './ChuckyClient.js';
|
|
7
|
+
export type { StreamingEvent, StreamingTextEvent, StreamingToolUseEvent, StreamingToolResultEvent, StreamingThinkingEvent, StreamingErrorEvent, } from './ChuckyClient.js';
|
|
8
|
+
export { Session } from './Session.js';
|
|
9
|
+
export type { SessionEventHandlers } from './Session.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC/D,YAAY,EACV,cAAc,EACd,kBAAkB,EAClB,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAU/D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @chucky.cloud/sdk
|
|
3
|
+
*
|
|
4
|
+
* SDK for interacting with Chucky sandbox - supports both browser and Node.js.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { ChuckyClient, tool, createBudget, createToken } from '@chucky.cloud/sdk';
|
|
9
|
+
*
|
|
10
|
+
* // Server-side: Create a token for your user
|
|
11
|
+
* const token = await createToken({
|
|
12
|
+
* userId: 'user-123',
|
|
13
|
+
* projectId: 'your-project-uuid',
|
|
14
|
+
* secret: 'your-hmac-secret',
|
|
15
|
+
* budget: createBudget({
|
|
16
|
+
* aiDollars: 1.00,
|
|
17
|
+
* computeHours: 1,
|
|
18
|
+
* window: 'day',
|
|
19
|
+
* }),
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* // Create client with the token
|
|
23
|
+
* const client = new ChuckyClient({ token });
|
|
24
|
+
*
|
|
25
|
+
* // Create a session with tools
|
|
26
|
+
* const session = await client.createSession({
|
|
27
|
+
* model: 'claude-sonnet-4-5-20250929',
|
|
28
|
+
* tools: [
|
|
29
|
+
* tool('greet', 'Greet someone', {
|
|
30
|
+
* type: 'object',
|
|
31
|
+
* properties: { name: { type: 'string' } },
|
|
32
|
+
* required: ['name'],
|
|
33
|
+
* }, async ({ name }) => ({
|
|
34
|
+
* content: [{ type: 'text', text: `Hello, ${name}!` }],
|
|
35
|
+
* })),
|
|
36
|
+
* ],
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* // Send a message
|
|
40
|
+
* const result = await session.send('Greet the world!');
|
|
41
|
+
* console.log(result.text);
|
|
42
|
+
*
|
|
43
|
+
* // Or stream the response
|
|
44
|
+
* for await (const event of session.sendStream('Tell me a story')) {
|
|
45
|
+
* if (event.type === 'text') {
|
|
46
|
+
* process.stdout.write(event.text);
|
|
47
|
+
* }
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @packageDocumentation
|
|
52
|
+
*/
|
|
53
|
+
export { ChuckyClient, createClient } from './client/index.js';
|
|
54
|
+
export type { StreamingEvent, StreamingTextEvent, StreamingToolUseEvent, StreamingToolResultEvent, StreamingThinkingEvent, StreamingErrorEvent, } from './client/index.js';
|
|
55
|
+
export { Session } from './client/index.js';
|
|
56
|
+
export type { SessionEventHandlers } from './client/index.js';
|
|
57
|
+
export { createTool, tool, browserTool, serverTool, textResult, errorResult, imageResult, McpServerBuilder, createMcpServer, mcpServer, } from './tools/index.js';
|
|
58
|
+
export type { CreateToolOptions } from './tools/index.js';
|
|
59
|
+
export { createToken, decodeToken, verifyToken, isTokenExpired, createBudget, } from './utils/index.js';
|
|
60
|
+
export { ChuckyError, ConnectionError, AuthenticationError, BudgetExceededError, ConcurrencyLimitError, RateLimitError, SessionError, ToolExecutionError, TimeoutError, ValidationError, createError, } from './utils/index.js';
|
|
61
|
+
export { WebSocketTransport } from './transport/index.js';
|
|
62
|
+
export type { Transport, TransportConfig, TransportEvents } from './transport/index.js';
|
|
63
|
+
export type { Model, SystemPrompt, OutputFormat, AgentDefinition, BaseOptions, SessionOptions, PromptOptions, ClientOptions, ConnectionStatus, ClientEventHandlers, } from './types/index.js';
|
|
64
|
+
export type { JsonSchemaType, JsonSchemaProperty, ToolInputSchema, ToolContentType, TextContent, ImageContent, ResourceContent, ToolContent, ToolResult, ToolExecutionLocation, ToolHandler, ToolDefinition, McpServerDefinition, ToolCall, ToolCallResponse, } from './types/index.js';
|
|
65
|
+
export type { WsEnvelopeType, WsEnvelope, InitPayload, PromptPayload, ControlAction, ControlPayload, ErrorPayload, OutgoingMessage, IncomingMessage, } from './types/index.js';
|
|
66
|
+
export type { BudgetWindow, TokenBudget, TokenPermissions, TokenSdkConfig, BudgetTokenPayload, CreateTokenOptions, DecodedToken, } from './types/index.js';
|
|
67
|
+
export type { MessageRole, ContentBlockType, TextBlock, ToolUseBlock, ToolResultBlock, ThinkingBlock, ImageBlock, ContentBlock, Message, Usage, CostBreakdown, SessionResult, PromptResult, StreamEvent, PartialMessage, SessionState, SessionInfo, } from './types/index.js';
|
|
68
|
+
export { createInitMessage, createPromptMessage, createSdkMessage, createControlMessage, createPingMessage, createToolResultMessage, isResultMessage, isToolCallMessage, isControlMessage, isErrorMessage, } from './types/index.js';
|
|
69
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAMH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC/D,YAAY,EACV,cAAc,EACd,kBAAkB,EAClB,qBAAqB,EACrB,wBAAwB,EACxB,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e,EACf,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EACV,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,GACb,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,eAAe,EACf,aAAa,EACb,UAAU,EACV,YAAY,EACZ,OAAO,EACP,KAAK,EACL,aAAa,EACb,aAAa,EACb,YAAY,EACZ,WAAW,EACX,cAAc,EACd,YAAY,EACZ,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,EACvB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,GACf,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @chucky.cloud/sdk
|
|
3
|
+
*
|
|
4
|
+
* SDK for interacting with Chucky sandbox - supports both browser and Node.js.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { ChuckyClient, tool, createBudget, createToken } from '@chucky.cloud/sdk';
|
|
9
|
+
*
|
|
10
|
+
* // Server-side: Create a token for your user
|
|
11
|
+
* const token = await createToken({
|
|
12
|
+
* userId: 'user-123',
|
|
13
|
+
* projectId: 'your-project-uuid',
|
|
14
|
+
* secret: 'your-hmac-secret',
|
|
15
|
+
* budget: createBudget({
|
|
16
|
+
* aiDollars: 1.00,
|
|
17
|
+
* computeHours: 1,
|
|
18
|
+
* window: 'day',
|
|
19
|
+
* }),
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* // Create client with the token
|
|
23
|
+
* const client = new ChuckyClient({ token });
|
|
24
|
+
*
|
|
25
|
+
* // Create a session with tools
|
|
26
|
+
* const session = await client.createSession({
|
|
27
|
+
* model: 'claude-sonnet-4-5-20250929',
|
|
28
|
+
* tools: [
|
|
29
|
+
* tool('greet', 'Greet someone', {
|
|
30
|
+
* type: 'object',
|
|
31
|
+
* properties: { name: { type: 'string' } },
|
|
32
|
+
* required: ['name'],
|
|
33
|
+
* }, async ({ name }) => ({
|
|
34
|
+
* content: [{ type: 'text', text: `Hello, ${name}!` }],
|
|
35
|
+
* })),
|
|
36
|
+
* ],
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* // Send a message
|
|
40
|
+
* const result = await session.send('Greet the world!');
|
|
41
|
+
* console.log(result.text);
|
|
42
|
+
*
|
|
43
|
+
* // Or stream the response
|
|
44
|
+
* for await (const event of session.sendStream('Tell me a story')) {
|
|
45
|
+
* if (event.type === 'text') {
|
|
46
|
+
* process.stdout.write(event.text);
|
|
47
|
+
* }
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @packageDocumentation
|
|
52
|
+
*/
|
|
53
|
+
// ============================================================================
|
|
54
|
+
// Client
|
|
55
|
+
// ============================================================================
|
|
56
|
+
export { ChuckyClient, createClient } from './client/index.js';
|
|
57
|
+
export { Session } from './client/index.js';
|
|
58
|
+
// ============================================================================
|
|
59
|
+
// Tools
|
|
60
|
+
// ============================================================================
|
|
61
|
+
export { createTool, tool, browserTool, serverTool, textResult, errorResult, imageResult, McpServerBuilder, createMcpServer, mcpServer, } from './tools/index.js';
|
|
62
|
+
// ============================================================================
|
|
63
|
+
// Utils
|
|
64
|
+
// ============================================================================
|
|
65
|
+
export { createToken, decodeToken, verifyToken, isTokenExpired, createBudget, } from './utils/index.js';
|
|
66
|
+
export { ChuckyError, ConnectionError, AuthenticationError, BudgetExceededError, ConcurrencyLimitError, RateLimitError, SessionError, ToolExecutionError, TimeoutError, ValidationError, createError, } from './utils/index.js';
|
|
67
|
+
// ============================================================================
|
|
68
|
+
// Transport (advanced usage)
|
|
69
|
+
// ============================================================================
|
|
70
|
+
export { WebSocketTransport } from './transport/index.js';
|
|
71
|
+
// Message helpers
|
|
72
|
+
export { createInitMessage, createPromptMessage, createSdkMessage, createControlMessage, createPingMessage, createToolResultMessage, isResultMessage, isToolCallMessage, isControlMessage, isErrorMessage, } from './types/index.js';
|
|
73
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH,+EAA+E;AAC/E,SAAS;AACT,+EAA+E;AAE/E,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAU/D,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C,+EAA+E;AAC/E,QAAQ;AACR,+EAA+E;AAE/E,OAAO,EACL,UAAU,EACV,IAAI,EACJ,WAAW,EACX,UAAU,EACV,UAAU,EACV,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,eAAe,EACf,SAAS,GACV,MAAM,kBAAkB,CAAC;AAG1B,+EAA+E;AAC/E,QAAQ;AACR,+EAA+E;AAE/E,OAAO,EACL,WAAW,EACX,WAAW,EACX,WAAW,EACX,cAAc,EACd,YAAY,GACb,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,WAAW,EACX,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAE1B,+EAA+E;AAC/E,6BAA6B;AAC7B,+EAA+E;AAE/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAqF1D,kBAAkB;AAClB,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,EACvB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,GACf,MAAM,kBAAkB,CAAC"}
|
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,YAAY,CAAC"}
|
package/dist/node.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node.js Entry Point
|
|
3
|
+
*
|
|
4
|
+
* Optimized exports for Node.js environments.
|
|
5
|
+
* Includes all functionality including token creation.
|
|
6
|
+
*/
|
|
7
|
+
// Re-export everything from main index
|
|
8
|
+
export * from './index.js';
|
|
9
|
+
// Node.js-specific note: Uses 'ws' package for WebSocket
|
|
10
|
+
// and Node.js crypto module for token signing.
|
|
11
|
+
//# sourceMappingURL=node.js.map
|
package/dist/node.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,uCAAuC;AACvC,cAAc,YAAY,CAAC;AAE3B,yDAAyD;AACzD,+CAA+C"}
|