@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.
Files changed (92) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/client.d.mts +2 -2
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +2 -2
  5. package/client.d.ts.map +1 -1
  6. package/client.js.map +1 -1
  7. package/client.mjs.map +1 -1
  8. package/core/streaming.d.mts +33 -0
  9. package/core/streaming.d.mts.map +1 -0
  10. package/core/streaming.d.ts +33 -0
  11. package/core/streaming.d.ts.map +1 -0
  12. package/core/streaming.js +263 -0
  13. package/core/streaming.js.map +1 -0
  14. package/core/streaming.mjs +258 -0
  15. package/core/streaming.mjs.map +1 -0
  16. package/internal/decoders/line.d.mts +17 -0
  17. package/internal/decoders/line.d.mts.map +1 -0
  18. package/internal/decoders/line.d.ts +17 -0
  19. package/internal/decoders/line.d.ts.map +1 -0
  20. package/internal/decoders/line.js +113 -0
  21. package/internal/decoders/line.js.map +1 -0
  22. package/internal/decoders/line.mjs +108 -0
  23. package/internal/decoders/line.mjs.map +1 -0
  24. package/internal/parse.d.mts.map +1 -1
  25. package/internal/parse.d.ts.map +1 -1
  26. package/internal/parse.js +10 -0
  27. package/internal/parse.js.map +1 -1
  28. package/internal/parse.mjs +10 -0
  29. package/internal/parse.mjs.map +1 -1
  30. package/internal/request-options.d.mts +2 -0
  31. package/internal/request-options.d.mts.map +1 -1
  32. package/internal/request-options.d.ts +2 -0
  33. package/internal/request-options.d.ts.map +1 -1
  34. package/internal/request-options.js.map +1 -1
  35. package/internal/request-options.mjs.map +1 -1
  36. package/package.json +11 -1
  37. package/resources/index.d.mts +1 -1
  38. package/resources/index.d.mts.map +1 -1
  39. package/resources/index.d.ts +1 -1
  40. package/resources/index.d.ts.map +1 -1
  41. package/resources/index.js.map +1 -1
  42. package/resources/index.mjs.map +1 -1
  43. package/resources/threads/index.d.mts +2 -2
  44. package/resources/threads/index.d.mts.map +1 -1
  45. package/resources/threads/index.d.ts +2 -2
  46. package/resources/threads/index.d.ts.map +1 -1
  47. package/resources/threads/index.js.map +1 -1
  48. package/resources/threads/index.mjs.map +1 -1
  49. package/resources/threads/messages.d.mts +3 -2
  50. package/resources/threads/messages.d.mts.map +1 -1
  51. package/resources/threads/messages.d.ts +3 -2
  52. package/resources/threads/messages.d.ts.map +1 -1
  53. package/resources/threads/messages.js.map +1 -1
  54. package/resources/threads/messages.mjs.map +1 -1
  55. package/resources/threads/runs.d.mts +42 -9
  56. package/resources/threads/runs.d.mts.map +1 -1
  57. package/resources/threads/runs.d.ts +42 -9
  58. package/resources/threads/runs.d.ts.map +1 -1
  59. package/resources/threads/runs.js +18 -7
  60. package/resources/threads/runs.js.map +1 -1
  61. package/resources/threads/runs.mjs +18 -7
  62. package/resources/threads/runs.mjs.map +1 -1
  63. package/resources/threads/threads.d.mts +83 -4
  64. package/resources/threads/threads.d.mts.map +1 -1
  65. package/resources/threads/threads.d.ts +83 -4
  66. package/resources/threads/threads.d.ts.map +1 -1
  67. package/resources/threads/threads.js.map +1 -1
  68. package/resources/threads/threads.mjs.map +1 -1
  69. package/src/client.ts +10 -0
  70. package/src/core/streaming.ts +315 -0
  71. package/src/internal/decoders/line.ts +135 -0
  72. package/src/internal/parse.ts +14 -0
  73. package/src/internal/request-options.ts +2 -0
  74. package/src/resources/index.ts +5 -0
  75. package/src/resources/threads/index.ts +7 -0
  76. package/src/resources/threads/messages.ts +15 -2
  77. package/src/resources/threads/runs.ts +53 -12
  78. package/src/resources/threads/threads.ts +112 -1
  79. package/src/streaming.ts +2 -0
  80. package/src/version.ts +1 -1
  81. package/streaming.d.mts +2 -0
  82. package/streaming.d.mts.map +1 -0
  83. package/streaming.d.ts +2 -0
  84. package/streaming.d.ts.map +1 -0
  85. package/streaming.js +6 -0
  86. package/streaming.js.map +1 -0
  87. package/streaming.mjs +2 -0
  88. package/streaming.mjs.map +1 -0
  89. package/version.d.mts +1 -1
  90. package/version.d.ts +1 -1
  91. package/version.js +1 -1
  92. 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: { content: [{}], role: 'user' },
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<void> {
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: '*/*' }, options?.headers]),
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('thr_abc123xyz', {
54
- * message: { content: [{}], role: 'user' },
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<void> {
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: '*/*' }, options?.headers]),
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<unknown>;
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<unknown>;
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,
@@ -0,0 +1,2 @@
1
+ /** @deprecated Import from ./core/streaming instead */
2
+ export * from './core/streaming';
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.82.0'; // x-release-please-version
1
+ export const VERSION = '0.84.0'; // x-release-please-version
@@ -0,0 +1,2 @@
1
+ export * from "./core/streaming.mjs";
2
+ //# sourceMappingURL=streaming.d.mts.map
@@ -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,2 @@
1
+ export * from "./core/streaming.js";
2
+ //# sourceMappingURL=streaming.d.ts.map
@@ -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
@@ -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,2 @@
1
+ export * from "./core/streaming.mjs";
2
+ //# sourceMappingURL=streaming.mjs.map
@@ -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.82.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.82.0";
1
+ export declare const VERSION = "0.84.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.82.0'; // x-release-please-version
4
+ exports.VERSION = '0.84.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.82.0'; // x-release-please-version
1
+ export const VERSION = '0.84.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map