@tambo-ai/typescript-sdk 0.87.0 → 0.89.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 +41 -0
- package/bin/migration-config.json +74 -0
- package/client.d.mts.map +1 -1
- package/client.d.ts.map +1 -1
- package/client.js +3 -2
- package/client.js.map +1 -1
- package/client.mjs +3 -2
- package/client.mjs.map +1 -1
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +5 -0
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +5 -0
- package/internal/parse.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/threads/index.d.mts +1 -0
- package/resources/threads/index.d.mts.map +1 -1
- package/resources/threads/index.d.ts +1 -0
- package/resources/threads/index.d.ts.map +1 -1
- package/resources/threads/index.js +3 -1
- package/resources/threads/index.js.map +1 -1
- package/resources/threads/index.mjs +1 -0
- package/resources/threads/index.mjs.map +1 -1
- package/resources/threads/messages.d.mts +1 -1
- package/resources/threads/messages.d.ts +1 -1
- package/resources/threads/runs.d.mts +8 -3
- package/resources/threads/runs.d.mts.map +1 -1
- package/resources/threads/runs.d.ts +8 -3
- package/resources/threads/runs.d.ts.map +1 -1
- package/resources/threads/suggestions.d.mts +122 -0
- package/resources/threads/suggestions.d.mts.map +1 -0
- package/resources/threads/suggestions.d.ts +122 -0
- package/resources/threads/suggestions.d.ts.map +1 -0
- package/resources/threads/suggestions.js +49 -0
- package/resources/threads/suggestions.js.map +1 -0
- package/resources/threads/suggestions.mjs +45 -0
- package/resources/threads/suggestions.mjs.map +1 -0
- package/resources/threads/threads.d.mts +6 -2
- package/resources/threads/threads.d.mts.map +1 -1
- package/resources/threads/threads.d.ts +6 -2
- package/resources/threads/threads.d.ts.map +1 -1
- package/resources/threads/threads.js +4 -0
- package/resources/threads/threads.js.map +1 -1
- package/resources/threads/threads.mjs +4 -0
- package/resources/threads/threads.mjs.map +1 -1
- package/src/client.ts +3 -2
- package/src/internal/parse.ts +6 -0
- package/src/resources/threads/index.ts +7 -0
- package/src/resources/threads/messages.ts +1 -1
- package/src/resources/threads/runs.ts +9 -3
- package/src/resources/threads/suggestions.ts +170 -0
- package/src/resources/threads/threads.ts +20 -2
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"threads.mjs","sourceRoot":"","sources":["../../src/resources/threads/threads.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OAGf,KAAK,WAAW;OAChB,EAKL,QAAQ,GACT;OACM,KAAK,OAAO;OACZ,EAQL,IAAI,GACL;OACM,KAAK,QAAQ;OACb,EAAE,KAAK,EAAoD;
|
|
1
|
+
{"version":3,"file":"threads.mjs","sourceRoot":"","sources":["../../src/resources/threads/threads.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OAGf,KAAK,WAAW;OAChB,EAKL,QAAQ,GACT;OACM,KAAK,OAAO;OACZ,EAQL,IAAI,GACL;OACM,KAAK,QAAQ;OACb,EAAE,KAAK,EAAoD;OAC3D,KAAK,cAAc;OACnB,EAKL,WAAW,GACZ;OAEM,EAAE,YAAY,EAAE;OAEhB,EAAE,IAAI,EAAE;AAEf,MAAM,OAAO,OAAQ,SAAQ,WAAW;IAAxC;;QACE,UAAK,GAAmB,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACzD,aAAQ,GAAyB,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxE,SAAI,GAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpD,gBAAW,GAA+B,IAAI,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAgEzF,CAAC;IA9DC;;;;;;;;OAQG;IACH,MAAM,CAAC,IAAwB,EAAE,OAAwB;QACvD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAChE,CAAC;IAED;;;;;;;;;;OAUG;IACH,QAAQ,CACN,QAAgB,EAChB,QAAiD,EAAE,EACnD,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,eAAe,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAChF,CAAC;IAED;;;;;;;;OAQG;IACH,IAAI,CACF,QAA6C,EAAE,EAC/C,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAChE,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,QAAgB,EAAE,OAAwB;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAA,eAAe,QAAQ,EAAE,EAAE;YACxD,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;SAC7D,CAAC,CAAC;IACL,CAAC;CACF;AAoZD,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;AACtB,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAC5B,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;AACpB,OAAO,CAAC,WAAW,GAAG,WAAW,CAAC"}
|
package/src/client.ts
CHANGED
|
@@ -585,9 +585,10 @@ export class TamboAI {
|
|
|
585
585
|
controller: AbortController,
|
|
586
586
|
): Promise<Response> {
|
|
587
587
|
const { signal, method, ...options } = init || {};
|
|
588
|
-
|
|
588
|
+
const abort = controller.abort.bind(controller);
|
|
589
|
+
if (signal) signal.addEventListener('abort', abort, { once: true });
|
|
589
590
|
|
|
590
|
-
const timeout = setTimeout(
|
|
591
|
+
const timeout = setTimeout(abort, ms);
|
|
591
592
|
|
|
592
593
|
const isReadableBody =
|
|
593
594
|
((globalThis as any).ReadableStream && options.body instanceof (globalThis as any).ReadableStream) ||
|
package/src/internal/parse.ts
CHANGED
|
@@ -43,6 +43,12 @@ export async function defaultParseResponse<T>(client: TamboAI, props: APIRespons
|
|
|
43
43
|
const mediaType = contentType?.split(';')[0]?.trim();
|
|
44
44
|
const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
|
|
45
45
|
if (isJSON) {
|
|
46
|
+
const contentLength = response.headers.get('content-length');
|
|
47
|
+
if (contentLength === '0') {
|
|
48
|
+
// if there is no content we can't do anything
|
|
49
|
+
return undefined as T;
|
|
50
|
+
}
|
|
51
|
+
|
|
46
52
|
const json = await response.json();
|
|
47
53
|
return json as T;
|
|
48
54
|
}
|
|
@@ -18,6 +18,13 @@ export {
|
|
|
18
18
|
type RunRunParams,
|
|
19
19
|
} from './runs';
|
|
20
20
|
export { State, type StateUpdateStateResponse, type StateUpdateStateParams } from './state';
|
|
21
|
+
export {
|
|
22
|
+
Suggestions,
|
|
23
|
+
type SuggestionCreateResponse,
|
|
24
|
+
type SuggestionListResponse,
|
|
25
|
+
type SuggestionCreateParams,
|
|
26
|
+
type SuggestionListParams,
|
|
27
|
+
} from './suggestions';
|
|
21
28
|
export {
|
|
22
29
|
Threads,
|
|
23
30
|
type ComponentContent,
|
|
@@ -88,6 +88,12 @@ export interface InputMessage {
|
|
|
88
88
|
*/
|
|
89
89
|
role: 'user';
|
|
90
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Additional context to provide to the AI beyond the user query, such as current
|
|
93
|
+
* page URL or application state
|
|
94
|
+
*/
|
|
95
|
+
additionalContext?: unknown;
|
|
96
|
+
|
|
91
97
|
/**
|
|
92
98
|
* Additional metadata to attach to the message
|
|
93
99
|
*/
|
|
@@ -190,7 +196,7 @@ export interface RunCreateParams {
|
|
|
190
196
|
tools?: Array<RunCreateParams.Tool>;
|
|
191
197
|
|
|
192
198
|
/**
|
|
193
|
-
*
|
|
199
|
+
* Identifier for a user in your system. Required if no bearer token is provided.
|
|
194
200
|
*/
|
|
195
201
|
userKey?: string;
|
|
196
202
|
}
|
|
@@ -233,7 +239,7 @@ export namespace RunCreateParams {
|
|
|
233
239
|
metadata?: unknown;
|
|
234
240
|
|
|
235
241
|
/**
|
|
236
|
-
*
|
|
242
|
+
* Identifier for a user in your system. Required if no bearer token is provided.
|
|
237
243
|
*/
|
|
238
244
|
userKey?: string;
|
|
239
245
|
}
|
|
@@ -325,7 +331,7 @@ export interface RunRunParams {
|
|
|
325
331
|
tools?: Array<RunRunParams.Tool>;
|
|
326
332
|
|
|
327
333
|
/**
|
|
328
|
-
*
|
|
334
|
+
* Identifier for a user in your system. Required if no bearer token is provided.
|
|
329
335
|
*/
|
|
330
336
|
userKey?: string;
|
|
331
337
|
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../../core/resource';
|
|
4
|
+
import * as ThreadsSuggestionsAPI from '../beta/threads/suggestions';
|
|
5
|
+
import { APIPromise } from '../../core/api-promise';
|
|
6
|
+
import { RequestOptions } from '../../internal/request-options';
|
|
7
|
+
import { path } from '../../internal/utils/path';
|
|
8
|
+
|
|
9
|
+
export class Suggestions extends APIResource {
|
|
10
|
+
/**
|
|
11
|
+
* Generate AI-powered suggestions for the next action based on the thread context.
|
|
12
|
+
* Suggestions are persisted and can be retrieved later via the list endpoint.
|
|
13
|
+
* Calling this endpoint replaces any existing suggestions for the message.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const suggestion = await client.threads.suggestions.create(
|
|
18
|
+
* 'msg_xyz789abc',
|
|
19
|
+
* { threadId: 'thr_abc123xyz' },
|
|
20
|
+
* );
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
create(
|
|
24
|
+
messageID: string,
|
|
25
|
+
params: SuggestionCreateParams,
|
|
26
|
+
options?: RequestOptions,
|
|
27
|
+
): APIPromise<SuggestionCreateResponse> {
|
|
28
|
+
const { threadId, ...body } = params;
|
|
29
|
+
return this._client.post(path`/v1/threads/${threadId}/messages/${messageID}/suggestions`, {
|
|
30
|
+
body,
|
|
31
|
+
...options,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* List suggestions that have been generated for a specific message. Supports
|
|
37
|
+
* cursor-based pagination.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* const suggestions = await client.threads.suggestions.list(
|
|
42
|
+
* 'msg_xyz789abc',
|
|
43
|
+
* { threadId: 'thr_abc123xyz' },
|
|
44
|
+
* );
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
list(
|
|
48
|
+
messageID: string,
|
|
49
|
+
params: SuggestionListParams,
|
|
50
|
+
options?: RequestOptions,
|
|
51
|
+
): APIPromise<SuggestionListResponse> {
|
|
52
|
+
const { threadId, ...query } = params;
|
|
53
|
+
return this._client.get(path`/v1/threads/${threadId}/messages/${messageID}/suggestions`, {
|
|
54
|
+
query,
|
|
55
|
+
...options,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface SuggestionCreateResponse {
|
|
61
|
+
/**
|
|
62
|
+
* Whether there are more results
|
|
63
|
+
*/
|
|
64
|
+
hasMore: boolean;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* List of suggestions for the message
|
|
68
|
+
*/
|
|
69
|
+
suggestions: Array<ThreadsSuggestionsAPI.Suggestion>;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Cursor for the next page of results
|
|
73
|
+
*/
|
|
74
|
+
nextCursor?: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface SuggestionListResponse {
|
|
78
|
+
/**
|
|
79
|
+
* Whether there are more results
|
|
80
|
+
*/
|
|
81
|
+
hasMore: boolean;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* List of suggestions for the message
|
|
85
|
+
*/
|
|
86
|
+
suggestions: Array<ThreadsSuggestionsAPI.Suggestion>;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Cursor for the next page of results
|
|
90
|
+
*/
|
|
91
|
+
nextCursor?: string;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface SuggestionCreateParams {
|
|
95
|
+
/**
|
|
96
|
+
* Path param: Thread ID
|
|
97
|
+
*/
|
|
98
|
+
threadId: string;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Body param: Available components that suggestions can reference
|
|
102
|
+
*/
|
|
103
|
+
availableComponents?: Array<SuggestionCreateParams.AvailableComponent>;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Body param: Maximum number of suggestions to generate (1-10)
|
|
107
|
+
*/
|
|
108
|
+
maxSuggestions?: number;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Body param: Identifier for a user in your system. Required if no bearer token is
|
|
112
|
+
* provided.
|
|
113
|
+
*/
|
|
114
|
+
userKey?: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export namespace SuggestionCreateParams {
|
|
118
|
+
export interface AvailableComponent {
|
|
119
|
+
/**
|
|
120
|
+
* Description of what this component displays
|
|
121
|
+
*/
|
|
122
|
+
description: string;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Component name (e.g., 'StockChart')
|
|
126
|
+
*/
|
|
127
|
+
name: string;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* JSON Schema for component props
|
|
131
|
+
*/
|
|
132
|
+
propsSchema: unknown;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Optional JSON Schema for component state
|
|
136
|
+
*/
|
|
137
|
+
stateSchema?: unknown;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface SuggestionListParams {
|
|
142
|
+
/**
|
|
143
|
+
* Path param: Thread ID
|
|
144
|
+
*/
|
|
145
|
+
threadId: string;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Query param: Cursor for pagination
|
|
149
|
+
*/
|
|
150
|
+
cursor?: string;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Query param: Maximum number of suggestions to return
|
|
154
|
+
*/
|
|
155
|
+
limit?: number;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Query param: Optional user key for thread organization
|
|
159
|
+
*/
|
|
160
|
+
userKey?: string;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export declare namespace Suggestions {
|
|
164
|
+
export {
|
|
165
|
+
type SuggestionCreateResponse as SuggestionCreateResponse,
|
|
166
|
+
type SuggestionListResponse as SuggestionListResponse,
|
|
167
|
+
type SuggestionCreateParams as SuggestionCreateParams,
|
|
168
|
+
type SuggestionListParams as SuggestionListParams,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
@@ -24,6 +24,14 @@ import {
|
|
|
24
24
|
} from './runs';
|
|
25
25
|
import * as StateAPI from './state';
|
|
26
26
|
import { State, StateUpdateStateParams, StateUpdateStateResponse } from './state';
|
|
27
|
+
import * as SuggestionsAPI from './suggestions';
|
|
28
|
+
import {
|
|
29
|
+
SuggestionCreateParams,
|
|
30
|
+
SuggestionCreateResponse,
|
|
31
|
+
SuggestionListParams,
|
|
32
|
+
SuggestionListResponse,
|
|
33
|
+
Suggestions,
|
|
34
|
+
} from './suggestions';
|
|
27
35
|
import { APIPromise } from '../../core/api-promise';
|
|
28
36
|
import { buildHeaders } from '../../internal/headers';
|
|
29
37
|
import { RequestOptions } from '../../internal/request-options';
|
|
@@ -33,6 +41,7 @@ export class Threads extends APIResource {
|
|
|
33
41
|
state: StateAPI.State = new StateAPI.State(this._client);
|
|
34
42
|
messages: MessagesAPI.Messages = new MessagesAPI.Messages(this._client);
|
|
35
43
|
runs: RunsAPI.Runs = new RunsAPI.Runs(this._client);
|
|
44
|
+
suggestions: SuggestionsAPI.Suggestions = new SuggestionsAPI.Suggestions(this._client);
|
|
36
45
|
|
|
37
46
|
/**
|
|
38
47
|
* Create a new empty thread. Note: initialMessages is not supported yet; create
|
|
@@ -471,7 +480,7 @@ export interface ThreadCreateParams {
|
|
|
471
480
|
metadata?: unknown;
|
|
472
481
|
|
|
473
482
|
/**
|
|
474
|
-
*
|
|
483
|
+
* Identifier for a user in your system. Required if no bearer token is provided.
|
|
475
484
|
*/
|
|
476
485
|
userKey?: string;
|
|
477
486
|
}
|
|
@@ -492,7 +501,7 @@ export interface ThreadListParams {
|
|
|
492
501
|
/**
|
|
493
502
|
* Maximum number of threads to return
|
|
494
503
|
*/
|
|
495
|
-
limit?:
|
|
504
|
+
limit?: number;
|
|
496
505
|
|
|
497
506
|
/**
|
|
498
507
|
* Filter by user key
|
|
@@ -503,6 +512,7 @@ export interface ThreadListParams {
|
|
|
503
512
|
Threads.State = State;
|
|
504
513
|
Threads.Messages = Messages;
|
|
505
514
|
Threads.Runs = Runs;
|
|
515
|
+
Threads.Suggestions = Suggestions;
|
|
506
516
|
|
|
507
517
|
export declare namespace Threads {
|
|
508
518
|
export {
|
|
@@ -544,4 +554,12 @@ export declare namespace Threads {
|
|
|
544
554
|
type RunDeleteParams as RunDeleteParams,
|
|
545
555
|
type RunRunParams as RunRunParams,
|
|
546
556
|
};
|
|
557
|
+
|
|
558
|
+
export {
|
|
559
|
+
Suggestions as Suggestions,
|
|
560
|
+
type SuggestionCreateResponse as SuggestionCreateResponse,
|
|
561
|
+
type SuggestionListResponse as SuggestionListResponse,
|
|
562
|
+
type SuggestionCreateParams as SuggestionCreateParams,
|
|
563
|
+
type SuggestionListParams as SuggestionListParams,
|
|
564
|
+
};
|
|
547
565
|
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.89.0'; // x-release-please-version
|
package/version.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.89.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.89.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.89.0'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|