@tambo-ai/typescript-sdk 0.82.0 → 0.84.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/CHANGELOG.md +19 -0
- package/client.d.mts +2 -2
- package/client.d.mts.map +1 -1
- package/client.d.ts +2 -2
- package/client.d.ts.map +1 -1
- package/client.js.map +1 -1
- package/client.mjs.map +1 -1
- package/core/streaming.d.mts +33 -0
- package/core/streaming.d.mts.map +1 -0
- package/core/streaming.d.ts +33 -0
- package/core/streaming.d.ts.map +1 -0
- package/core/streaming.js +263 -0
- package/core/streaming.js.map +1 -0
- package/core/streaming.mjs +258 -0
- package/core/streaming.mjs.map +1 -0
- package/internal/decoders/line.d.mts +17 -0
- package/internal/decoders/line.d.mts.map +1 -0
- package/internal/decoders/line.d.ts +17 -0
- package/internal/decoders/line.d.ts.map +1 -0
- package/internal/decoders/line.js +113 -0
- package/internal/decoders/line.js.map +1 -0
- package/internal/decoders/line.mjs +108 -0
- package/internal/decoders/line.mjs.map +1 -0
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +10 -0
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +10 -0
- package/internal/parse.mjs.map +1 -1
- package/internal/request-options.d.mts +2 -0
- package/internal/request-options.d.mts.map +1 -1
- package/internal/request-options.d.ts +2 -0
- package/internal/request-options.d.ts.map +1 -1
- package/internal/request-options.js.map +1 -1
- package/internal/request-options.mjs.map +1 -1
- package/package.json +11 -1
- package/resources/index.d.mts +1 -1
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/threads/index.d.mts +2 -2
- package/resources/threads/index.d.mts.map +1 -1
- package/resources/threads/index.d.ts +2 -2
- package/resources/threads/index.d.ts.map +1 -1
- package/resources/threads/index.js.map +1 -1
- package/resources/threads/index.mjs.map +1 -1
- package/resources/threads/messages.d.mts +3 -2
- package/resources/threads/messages.d.mts.map +1 -1
- package/resources/threads/messages.d.ts +3 -2
- package/resources/threads/messages.d.ts.map +1 -1
- package/resources/threads/messages.js.map +1 -1
- package/resources/threads/messages.mjs.map +1 -1
- package/resources/threads/runs.d.mts +42 -9
- package/resources/threads/runs.d.mts.map +1 -1
- package/resources/threads/runs.d.ts +42 -9
- package/resources/threads/runs.d.ts.map +1 -1
- package/resources/threads/runs.js +18 -7
- package/resources/threads/runs.js.map +1 -1
- package/resources/threads/runs.mjs +18 -7
- package/resources/threads/runs.mjs.map +1 -1
- package/resources/threads/threads.d.mts +83 -4
- package/resources/threads/threads.d.mts.map +1 -1
- package/resources/threads/threads.d.ts +83 -4
- package/resources/threads/threads.d.ts.map +1 -1
- package/resources/threads/threads.js.map +1 -1
- package/resources/threads/threads.mjs.map +1 -1
- package/src/client.ts +10 -0
- package/src/core/streaming.ts +315 -0
- package/src/internal/decoders/line.ts +135 -0
- package/src/internal/parse.ts +14 -0
- package/src/internal/request-options.ts +2 -0
- package/src/resources/index.ts +5 -0
- package/src/resources/threads/index.ts +7 -0
- package/src/resources/threads/messages.ts +15 -2
- package/src/resources/threads/runs.ts +53 -12
- package/src/resources/threads/threads.ts +112 -1
- package/src/streaming.ts +2 -0
- package/src/version.ts +1 -1
- package/streaming.d.mts +2 -0
- package/streaming.d.mts.map +1 -0
- package/streaming.d.ts +2 -0
- package/streaming.d.ts.map +1 -0
- package/streaming.js +6 -0
- package/streaming.js.map +1 -0
- package/streaming.mjs +2 -0
- package/streaming.mjs.map +1 -0
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import { APIResource } from '../../core/resource';
|
|
4
4
|
import * as RunsAPI from './runs';
|
|
5
|
+
import * as ThreadsAPI from './threads';
|
|
5
6
|
import { APIPromise } from '../../core/api-promise';
|
|
7
|
+
import { Stream } from '../../core/streaming';
|
|
6
8
|
import { buildHeaders } from '../../internal/headers';
|
|
7
9
|
import { RequestOptions } from '../../internal/request-options';
|
|
8
10
|
import { path } from '../../internal/utils/path';
|
|
@@ -14,17 +16,21 @@ export class Runs extends APIResource {
|
|
|
14
16
|
*
|
|
15
17
|
* @example
|
|
16
18
|
* ```ts
|
|
17
|
-
* await client.threads.runs.create({
|
|
18
|
-
* message: {
|
|
19
|
+
* const run = await client.threads.runs.create({
|
|
20
|
+
* message: {
|
|
21
|
+
* content: [{ text: 'Hello, world!', type: 'text' }],
|
|
22
|
+
* role: 'user',
|
|
23
|
+
* },
|
|
19
24
|
* });
|
|
20
25
|
* ```
|
|
21
26
|
*/
|
|
22
|
-
create(body: RunCreateParams, options?: RequestOptions): APIPromise<
|
|
27
|
+
create(body: RunCreateParams, options?: RequestOptions): APIPromise<Stream<RunCreateResponse>> {
|
|
23
28
|
return this._client.post('/v1/threads/runs', {
|
|
24
29
|
body,
|
|
25
30
|
...options,
|
|
26
|
-
headers: buildHeaders([{ Accept: '
|
|
27
|
-
|
|
31
|
+
headers: buildHeaders([{ Accept: 'text/event-stream' }, options?.headers]),
|
|
32
|
+
stream: true,
|
|
33
|
+
}) as APIPromise<Stream<RunCreateResponse>>;
|
|
28
34
|
}
|
|
29
35
|
|
|
30
36
|
/**
|
|
@@ -50,17 +56,24 @@ export class Runs extends APIResource {
|
|
|
50
56
|
*
|
|
51
57
|
* @example
|
|
52
58
|
* ```ts
|
|
53
|
-
* await client.threads.runs.run(
|
|
54
|
-
*
|
|
55
|
-
*
|
|
59
|
+
* const response = await client.threads.runs.run(
|
|
60
|
+
* 'thr_abc123xyz',
|
|
61
|
+
* {
|
|
62
|
+
* message: {
|
|
63
|
+
* content: [{ text: 'Hello, world!', type: 'text' }],
|
|
64
|
+
* role: 'user',
|
|
65
|
+
* },
|
|
66
|
+
* },
|
|
67
|
+
* );
|
|
56
68
|
* ```
|
|
57
69
|
*/
|
|
58
|
-
run(threadID: string, body: RunRunParams, options?: RequestOptions): APIPromise<
|
|
70
|
+
run(threadID: string, body: RunRunParams, options?: RequestOptions): APIPromise<Stream<RunRunResponse>> {
|
|
59
71
|
return this._client.post(path`/v1/threads/${threadID}/runs`, {
|
|
60
72
|
body,
|
|
61
73
|
...options,
|
|
62
|
-
headers: buildHeaders([{ Accept: '
|
|
63
|
-
|
|
74
|
+
headers: buildHeaders([{ Accept: 'text/event-stream' }, options?.headers]),
|
|
75
|
+
stream: true,
|
|
76
|
+
}) as APIPromise<Stream<RunRunResponse>>;
|
|
64
77
|
}
|
|
65
78
|
}
|
|
66
79
|
|
|
@@ -68,7 +81,7 @@ export interface InputMessage {
|
|
|
68
81
|
/**
|
|
69
82
|
* Content blocks (text, resource, or tool_result)
|
|
70
83
|
*/
|
|
71
|
-
content: Array<
|
|
84
|
+
content: Array<ThreadsAPI.TextContent | ThreadsAPI.ResourceContent | ThreadsAPI.ToolResultContent>;
|
|
72
85
|
|
|
73
86
|
/**
|
|
74
87
|
* Message role - must be 'user' for input messages
|
|
@@ -81,6 +94,19 @@ export interface InputMessage {
|
|
|
81
94
|
metadata?: unknown;
|
|
82
95
|
}
|
|
83
96
|
|
|
97
|
+
export interface RunCreateResponse {
|
|
98
|
+
/**
|
|
99
|
+
* Event type discriminator (e.g., RUN_STARTED, TEXT_MESSAGE_CONTENT,
|
|
100
|
+
* TOOL_CALL_START)
|
|
101
|
+
*/
|
|
102
|
+
type: string;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Unix timestamp (milliseconds) when event was generated
|
|
106
|
+
*/
|
|
107
|
+
timestamp?: number;
|
|
108
|
+
}
|
|
109
|
+
|
|
84
110
|
export interface RunDeleteResponse {
|
|
85
111
|
/**
|
|
86
112
|
* The run ID that was cancelled
|
|
@@ -93,6 +119,19 @@ export interface RunDeleteResponse {
|
|
|
93
119
|
status: 'cancelled';
|
|
94
120
|
}
|
|
95
121
|
|
|
122
|
+
export interface RunRunResponse {
|
|
123
|
+
/**
|
|
124
|
+
* Event type discriminator (e.g., RUN_STARTED, TEXT_MESSAGE_CONTENT,
|
|
125
|
+
* TOOL_CALL_START)
|
|
126
|
+
*/
|
|
127
|
+
type: string;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Unix timestamp (milliseconds) when event was generated
|
|
131
|
+
*/
|
|
132
|
+
timestamp?: number;
|
|
133
|
+
}
|
|
134
|
+
|
|
96
135
|
export interface RunCreateParams {
|
|
97
136
|
/**
|
|
98
137
|
* The user's message
|
|
@@ -339,7 +378,9 @@ export namespace RunRunParams {
|
|
|
339
378
|
export declare namespace Runs {
|
|
340
379
|
export {
|
|
341
380
|
type InputMessage as InputMessage,
|
|
381
|
+
type RunCreateResponse as RunCreateResponse,
|
|
342
382
|
type RunDeleteResponse as RunDeleteResponse,
|
|
383
|
+
type RunRunResponse as RunRunResponse,
|
|
343
384
|
type RunCreateParams as RunCreateParams,
|
|
344
385
|
type RunDeleteParams as RunDeleteParams,
|
|
345
386
|
type RunRunParams as RunRunParams,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { APIResource } from '../../core/resource';
|
|
4
4
|
import * as ThreadsAPI from './threads';
|
|
5
|
+
import * as Shared from '../shared';
|
|
5
6
|
import * as MessagesAPI from './messages';
|
|
6
7
|
import {
|
|
7
8
|
MessageGetParams,
|
|
@@ -14,9 +15,11 @@ import * as RunsAPI from './runs';
|
|
|
14
15
|
import {
|
|
15
16
|
InputMessage,
|
|
16
17
|
RunCreateParams,
|
|
18
|
+
RunCreateResponse,
|
|
17
19
|
RunDeleteParams,
|
|
18
20
|
RunDeleteResponse,
|
|
19
21
|
RunRunParams,
|
|
22
|
+
RunRunResponse,
|
|
20
23
|
Runs,
|
|
21
24
|
} from './runs';
|
|
22
25
|
import { APIPromise } from '../../core/api-promise';
|
|
@@ -88,6 +91,45 @@ export class Threads extends APIResource {
|
|
|
88
91
|
}
|
|
89
92
|
}
|
|
90
93
|
|
|
94
|
+
export interface ComponentContent {
|
|
95
|
+
/**
|
|
96
|
+
* Unique identifier for this component instance
|
|
97
|
+
*/
|
|
98
|
+
id: string;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Name of the component to render
|
|
102
|
+
*/
|
|
103
|
+
name: string;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Props to pass to the component
|
|
107
|
+
*/
|
|
108
|
+
props: unknown;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Content block type identifier
|
|
112
|
+
*/
|
|
113
|
+
type: 'component';
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Current state of the component
|
|
117
|
+
*/
|
|
118
|
+
state?: unknown;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface ResourceContent {
|
|
122
|
+
/**
|
|
123
|
+
* Resource data containing URI, text, or blob
|
|
124
|
+
*/
|
|
125
|
+
resource: Shared.Resource;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Content block type identifier
|
|
129
|
+
*/
|
|
130
|
+
type: 'resource';
|
|
131
|
+
}
|
|
132
|
+
|
|
91
133
|
export interface RunError {
|
|
92
134
|
/**
|
|
93
135
|
* Error message
|
|
@@ -100,6 +142,62 @@ export interface RunError {
|
|
|
100
142
|
code?: string;
|
|
101
143
|
}
|
|
102
144
|
|
|
145
|
+
export interface TextContent {
|
|
146
|
+
/**
|
|
147
|
+
* The text content
|
|
148
|
+
*/
|
|
149
|
+
text: string;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Content block type identifier
|
|
153
|
+
*/
|
|
154
|
+
type: 'text';
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface ToolResultContent {
|
|
158
|
+
/**
|
|
159
|
+
* Result content (text or resource blocks)
|
|
160
|
+
*/
|
|
161
|
+
content: Array<TextContent | ResourceContent>;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* ID of the tool call this result responds to
|
|
165
|
+
*/
|
|
166
|
+
toolUseId: string;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Content block type identifier
|
|
170
|
+
*/
|
|
171
|
+
type: 'tool_result';
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Whether the tool call resulted in an error
|
|
175
|
+
*/
|
|
176
|
+
isError?: boolean;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface ToolUseContent {
|
|
180
|
+
/**
|
|
181
|
+
* Unique identifier for this tool call
|
|
182
|
+
*/
|
|
183
|
+
id: string;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Input arguments for the tool
|
|
187
|
+
*/
|
|
188
|
+
input: unknown;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Name of the tool being called
|
|
192
|
+
*/
|
|
193
|
+
name: string;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Content block type identifier
|
|
197
|
+
*/
|
|
198
|
+
type: 'tool_use';
|
|
199
|
+
}
|
|
200
|
+
|
|
103
201
|
export interface ThreadCreateResponse {
|
|
104
202
|
/**
|
|
105
203
|
* Unique identifier for this thread
|
|
@@ -255,7 +353,13 @@ export namespace ThreadRetrieveResponse {
|
|
|
255
353
|
/**
|
|
256
354
|
* Content blocks in this message
|
|
257
355
|
*/
|
|
258
|
-
content: Array<
|
|
356
|
+
content: Array<
|
|
357
|
+
| ThreadsAPI.TextContent
|
|
358
|
+
| ThreadsAPI.ResourceContent
|
|
359
|
+
| ThreadsAPI.ToolUseContent
|
|
360
|
+
| ThreadsAPI.ToolResultContent
|
|
361
|
+
| ThreadsAPI.ComponentContent
|
|
362
|
+
>;
|
|
259
363
|
|
|
260
364
|
/**
|
|
261
365
|
* Message role
|
|
@@ -402,7 +506,12 @@ Threads.Runs = Runs;
|
|
|
402
506
|
|
|
403
507
|
export declare namespace Threads {
|
|
404
508
|
export {
|
|
509
|
+
type ComponentContent as ComponentContent,
|
|
510
|
+
type ResourceContent as ResourceContent,
|
|
405
511
|
type RunError as RunError,
|
|
512
|
+
type TextContent as TextContent,
|
|
513
|
+
type ToolResultContent as ToolResultContent,
|
|
514
|
+
type ToolUseContent as ToolUseContent,
|
|
406
515
|
type ThreadCreateResponse as ThreadCreateResponse,
|
|
407
516
|
type ThreadRetrieveResponse as ThreadRetrieveResponse,
|
|
408
517
|
type ThreadListResponse as ThreadListResponse,
|
|
@@ -421,7 +530,9 @@ export declare namespace Threads {
|
|
|
421
530
|
export {
|
|
422
531
|
Runs as Runs,
|
|
423
532
|
type InputMessage as InputMessage,
|
|
533
|
+
type RunCreateResponse as RunCreateResponse,
|
|
424
534
|
type RunDeleteResponse as RunDeleteResponse,
|
|
535
|
+
type RunRunResponse as RunRunResponse,
|
|
425
536
|
type RunCreateParams as RunCreateParams,
|
|
426
537
|
type RunDeleteParams as RunDeleteParams,
|
|
427
538
|
type RunRunParams as RunRunParams,
|
package/src/streaming.ts
ADDED
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.84.0'; // x-release-please-version
|
package/streaming.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.d.mts","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":""}
|
package/streaming.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":""}
|
package/streaming.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("./internal/tslib.js");
|
|
4
|
+
/** @deprecated Import from ./core/streaming instead */
|
|
5
|
+
tslib_1.__exportStar(require("./core/streaming.js"), exports);
|
|
6
|
+
//# sourceMappingURL=streaming.js.map
|
package/streaming.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.js","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AACvD,8DAAiC"}
|
package/streaming.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.mjs","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":""}
|
package/version.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.84.0";
|
|
2
2
|
//# sourceMappingURL=version.d.mts.map
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.84.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.js
CHANGED
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.84.0'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|