@langchain/langgraph-sdk 0.1.10 → 1.0.1

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 (235) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +11 -0
  3. package/dist/_virtual/rolldown_runtime.cjs +25 -0
  4. package/dist/auth/error.cjs +76 -86
  5. package/dist/auth/error.cjs.map +1 -0
  6. package/dist/auth/error.d.cts +13 -0
  7. package/dist/auth/error.d.cts.map +1 -0
  8. package/dist/auth/error.d.ts +12 -8
  9. package/dist/auth/error.d.ts.map +1 -0
  10. package/dist/auth/error.js +76 -83
  11. package/dist/auth/error.js.map +1 -0
  12. package/dist/auth/index.cjs +36 -44
  13. package/dist/auth/index.cjs.map +1 -0
  14. package/dist/auth/index.d.cts +31 -0
  15. package/dist/auth/index.d.cts.map +1 -0
  16. package/dist/auth/index.d.ts +20 -15
  17. package/dist/auth/index.d.ts.map +1 -0
  18. package/dist/auth/index.js +35 -39
  19. package/dist/auth/index.js.map +1 -0
  20. package/dist/auth/types.d.cts +294 -0
  21. package/dist/auth/types.d.cts.map +1 -0
  22. package/dist/auth/types.d.ts +162 -165
  23. package/dist/auth/types.d.ts.map +1 -0
  24. package/dist/client.cjs +1110 -1294
  25. package/dist/client.cjs.map +1 -0
  26. package/dist/client.d.cts +697 -0
  27. package/dist/client.d.cts.map +1 -0
  28. package/dist/client.d.ts +656 -639
  29. package/dist/client.d.ts.map +1 -0
  30. package/dist/client.js +1101 -1281
  31. package/dist/client.js.map +1 -0
  32. package/dist/index.cjs +6 -8
  33. package/dist/index.d.cts +7 -0
  34. package/dist/index.d.ts +7 -7
  35. package/dist/index.js +4 -2
  36. package/dist/logging/index.cjs +30 -31
  37. package/dist/logging/index.cjs.map +1 -0
  38. package/dist/logging/index.d.cts +47 -0
  39. package/dist/logging/index.d.cts.map +1 -0
  40. package/dist/logging/index.d.ts +20 -16
  41. package/dist/logging/index.d.ts.map +1 -0
  42. package/dist/logging/index.js +31 -29
  43. package/dist/logging/index.js.map +1 -0
  44. package/dist/react/index.cjs +5 -7
  45. package/dist/react/index.d.cts +4 -0
  46. package/dist/react/index.d.ts +4 -3
  47. package/dist/react/index.js +4 -2
  48. package/dist/react/stream.cjs +14 -15
  49. package/dist/react/stream.cjs.map +1 -0
  50. package/dist/react/stream.custom.cjs +126 -145
  51. package/dist/react/stream.custom.cjs.map +1 -0
  52. package/dist/react/stream.custom.d.cts +39 -0
  53. package/dist/react/stream.custom.d.cts.map +1 -0
  54. package/dist/react/stream.custom.d.ts +35 -37
  55. package/dist/react/stream.custom.d.ts.map +1 -0
  56. package/dist/react/stream.custom.js +122 -137
  57. package/dist/react/stream.custom.js.map +1 -0
  58. package/dist/react/stream.d.cts +73 -0
  59. package/dist/react/stream.d.cts.map +1 -0
  60. package/dist/react/stream.d.ts +21 -15
  61. package/dist/react/stream.d.ts.map +1 -0
  62. package/dist/react/stream.js +12 -11
  63. package/dist/react/stream.js.map +1 -0
  64. package/dist/react/stream.lgp.cjs +438 -498
  65. package/dist/react/stream.lgp.cjs.map +1 -0
  66. package/dist/react/stream.lgp.js +433 -490
  67. package/dist/react/stream.lgp.js.map +1 -0
  68. package/dist/react/thread.cjs +18 -15
  69. package/dist/react/thread.cjs.map +1 -0
  70. package/dist/react/thread.js +19 -13
  71. package/dist/react/thread.js.map +1 -0
  72. package/dist/react/types.d.cts +356 -0
  73. package/dist/react/types.d.cts.map +1 -0
  74. package/dist/react/types.d.ts +334 -329
  75. package/dist/react/types.d.ts.map +1 -0
  76. package/dist/react-ui/client.cjs +123 -184
  77. package/dist/react-ui/client.cjs.map +1 -0
  78. package/dist/react-ui/client.d.cts +90 -0
  79. package/dist/react-ui/client.d.cts.map +1 -0
  80. package/dist/react-ui/client.d.ts +67 -51
  81. package/dist/react-ui/client.d.ts.map +1 -0
  82. package/dist/react-ui/client.js +118 -143
  83. package/dist/react-ui/client.js.map +1 -0
  84. package/dist/react-ui/index.cjs +14 -13
  85. package/dist/react-ui/index.cjs.map +1 -0
  86. package/dist/react-ui/index.d.cts +3 -0
  87. package/dist/react-ui/index.d.ts +3 -2
  88. package/dist/react-ui/index.js +8 -3
  89. package/dist/react-ui/index.js.map +1 -0
  90. package/dist/react-ui/server/index.cjs +5 -7
  91. package/dist/react-ui/server/index.d.cts +3 -0
  92. package/dist/react-ui/server/index.d.ts +3 -2
  93. package/dist/react-ui/server/index.js +4 -2
  94. package/dist/react-ui/server/server.cjs +53 -44
  95. package/dist/react-ui/server/server.cjs.map +1 -0
  96. package/dist/react-ui/server/server.d.cts +55 -0
  97. package/dist/react-ui/server/server.d.cts.map +1 -0
  98. package/dist/react-ui/server/server.d.ts +43 -39
  99. package/dist/react-ui/server/server.d.ts.map +1 -0
  100. package/dist/react-ui/server/server.js +54 -42
  101. package/dist/react-ui/server/server.js.map +1 -0
  102. package/dist/react-ui/types.cjs +32 -36
  103. package/dist/react-ui/types.cjs.map +1 -0
  104. package/dist/react-ui/types.d.cts +25 -0
  105. package/dist/react-ui/types.d.cts.map +1 -0
  106. package/dist/react-ui/types.d.ts +23 -19
  107. package/dist/react-ui/types.d.ts.map +1 -0
  108. package/dist/react-ui/types.js +32 -34
  109. package/dist/react-ui/types.js.map +1 -0
  110. package/dist/schema.d.cts +278 -0
  111. package/dist/schema.d.cts.map +1 -0
  112. package/dist/schema.d.ts +250 -242
  113. package/dist/schema.d.ts.map +1 -0
  114. package/dist/singletons/fetch.cjs +16 -20
  115. package/dist/singletons/fetch.cjs.map +1 -0
  116. package/dist/singletons/fetch.d.cts +14 -0
  117. package/dist/singletons/fetch.d.cts.map +1 -0
  118. package/dist/singletons/fetch.d.ts +5 -2
  119. package/dist/singletons/fetch.d.ts.map +1 -0
  120. package/dist/singletons/fetch.js +16 -17
  121. package/dist/singletons/fetch.js.map +1 -0
  122. package/dist/types.d.cts +187 -0
  123. package/dist/types.d.cts.map +1 -0
  124. package/dist/types.d.ts +178 -173
  125. package/dist/types.d.ts.map +1 -0
  126. package/dist/types.messages.d.cts +91 -0
  127. package/dist/types.messages.d.cts.map +1 -0
  128. package/dist/types.messages.d.ts +71 -66
  129. package/dist/types.messages.d.ts.map +1 -0
  130. package/dist/types.stream.d.cts +235 -0
  131. package/dist/types.stream.d.cts.map +1 -0
  132. package/dist/types.stream.d.ts +149 -142
  133. package/dist/types.stream.d.ts.map +1 -0
  134. package/dist/ui/branching.cjs +145 -141
  135. package/dist/ui/branching.cjs.map +1 -0
  136. package/dist/ui/branching.d.cts +22 -0
  137. package/dist/ui/branching.d.cts.map +1 -0
  138. package/dist/ui/branching.d.ts +17 -30
  139. package/dist/ui/branching.d.ts.map +1 -0
  140. package/dist/ui/branching.js +147 -139
  141. package/dist/ui/branching.js.map +1 -0
  142. package/dist/ui/errors.cjs +14 -12
  143. package/dist/ui/errors.cjs.map +1 -0
  144. package/dist/ui/errors.js +14 -9
  145. package/dist/ui/errors.js.map +1 -0
  146. package/dist/ui/manager.cjs +156 -232
  147. package/dist/ui/manager.cjs.map +1 -0
  148. package/dist/ui/manager.js +156 -228
  149. package/dist/ui/manager.js.map +1 -0
  150. package/dist/ui/messages.cjs +55 -69
  151. package/dist/ui/messages.cjs.map +1 -0
  152. package/dist/ui/messages.js +55 -66
  153. package/dist/ui/messages.js.map +1 -0
  154. package/dist/ui/utils.cjs +10 -10
  155. package/dist/ui/utils.cjs.map +1 -0
  156. package/dist/ui/utils.js +10 -8
  157. package/dist/ui/utils.js.map +1 -0
  158. package/dist/utils/async_caller.cjs +103 -185
  159. package/dist/utils/async_caller.cjs.map +1 -0
  160. package/dist/utils/async_caller.d.cts +53 -0
  161. package/dist/utils/async_caller.d.cts.map +1 -0
  162. package/dist/utils/async_caller.d.ts +36 -31
  163. package/dist/utils/async_caller.d.ts.map +1 -0
  164. package/dist/utils/async_caller.js +101 -177
  165. package/dist/utils/async_caller.js.map +1 -0
  166. package/dist/utils/env.cjs +11 -13
  167. package/dist/utils/env.cjs.map +1 -0
  168. package/dist/utils/env.js +11 -11
  169. package/dist/utils/env.js.map +1 -0
  170. package/dist/utils/signals.cjs +18 -19
  171. package/dist/utils/signals.cjs.map +1 -0
  172. package/dist/utils/signals.js +18 -17
  173. package/dist/utils/signals.js.map +1 -0
  174. package/dist/utils/sse.cjs +110 -140
  175. package/dist/utils/sse.cjs.map +1 -0
  176. package/dist/utils/sse.js +110 -138
  177. package/dist/utils/sse.js.map +1 -0
  178. package/dist/utils/stream.cjs +90 -114
  179. package/dist/utils/stream.cjs.map +1 -0
  180. package/dist/utils/stream.js +90 -111
  181. package/dist/utils/stream.js.map +1 -0
  182. package/package.json +73 -81
  183. package/auth.cjs +0 -1
  184. package/auth.d.cts +0 -1
  185. package/auth.d.ts +0 -1
  186. package/auth.js +0 -1
  187. package/client.cjs +0 -1
  188. package/client.d.cts +0 -1
  189. package/client.d.ts +0 -1
  190. package/client.js +0 -1
  191. package/dist/auth/types.cjs +0 -2
  192. package/dist/auth/types.js +0 -1
  193. package/dist/react/stream.lgp.d.ts +0 -7
  194. package/dist/react/thread.d.ts +0 -4
  195. package/dist/react/types.cjs +0 -2
  196. package/dist/react/types.js +0 -1
  197. package/dist/schema.cjs +0 -2
  198. package/dist/schema.js +0 -1
  199. package/dist/types.cjs +0 -2
  200. package/dist/types.js +0 -1
  201. package/dist/types.messages.cjs +0 -2
  202. package/dist/types.messages.js +0 -1
  203. package/dist/types.stream.cjs +0 -2
  204. package/dist/types.stream.js +0 -1
  205. package/dist/ui/branching.test.cjs +0 -370
  206. package/dist/ui/branching.test.d.ts +0 -1
  207. package/dist/ui/branching.test.js +0 -368
  208. package/dist/ui/errors.d.ts +0 -12
  209. package/dist/ui/manager.d.ts +0 -87
  210. package/dist/ui/messages.d.ts +0 -18
  211. package/dist/ui/utils.d.ts +0 -2
  212. package/dist/utils/env.d.ts +0 -1
  213. package/dist/utils/signals.d.ts +0 -1
  214. package/dist/utils/sse.d.ts +0 -8
  215. package/dist/utils/stream.d.ts +0 -13
  216. package/index.cjs +0 -1
  217. package/index.d.cts +0 -1
  218. package/index.d.ts +0 -1
  219. package/index.js +0 -1
  220. package/logging.cjs +0 -1
  221. package/logging.d.cts +0 -1
  222. package/logging.d.ts +0 -1
  223. package/logging.js +0 -1
  224. package/react-ui/server.cjs +0 -1
  225. package/react-ui/server.d.cts +0 -1
  226. package/react-ui/server.d.ts +0 -1
  227. package/react-ui/server.js +0 -1
  228. package/react-ui.cjs +0 -1
  229. package/react-ui.d.cts +0 -1
  230. package/react-ui.d.ts +0 -1
  231. package/react-ui.js +0 -1
  232. package/react.cjs +0 -1
  233. package/react.d.cts +0 -1
  234. package/react.d.ts +0 -1
  235. package/react.js +0 -1
package/dist/client.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- import { Assistant, AssistantGraph, AssistantSortBy, AssistantSelectField, AssistantVersion, CancelAction, Checkpoint, Config, Cron, CronSelectField, CronCreateForThreadResponse, CronCreateResponse, CronSortBy, DefaultValues, GraphSchema, Item, ListNamespaceResponse, Metadata, Run, RunSelectField, RunStatus, SearchItemsResponse, SortOrder, Subgraphs, Thread, ThreadSelectField, ThreadSortBy, ThreadState, ThreadStatus } from "./schema.js";
2
- import type { Command, CronsCreatePayload, OnConflictBehavior, RunsCreatePayload, RunsStreamPayload, RunsWaitPayload, StreamEvent } from "./types.js";
3
- import type { StreamMode, ThreadStreamMode, TypedAsyncGenerator } from "./types.stream.js";
1
+ import { Assistant, AssistantGraph, AssistantSelectField, AssistantSortBy, AssistantVersion, CancelAction, Checkpoint, Config, Cron, CronCreateForThreadResponse, CronCreateResponse, CronSelectField, CronSortBy, DefaultValues, GraphSchema, Item, ListNamespaceResponse, Metadata, Run, RunSelectField, RunStatus, SearchItemsResponse, SortOrder, Subgraphs, Thread, ThreadSelectField, ThreadSortBy, ThreadState, ThreadStatus, ThreadValuesFilter } from "./schema.js";
2
+ import { StreamMode, ThreadStreamMode, TypedAsyncGenerator } from "./types.stream.js";
3
+ import { Command, CronsCreatePayload, OnConflictBehavior, RunsCreatePayload, RunsStreamPayload, RunsWaitPayload, StreamEvent } from "./types.js";
4
4
  import { AsyncCaller, AsyncCallerParams } from "./utils/async_caller.js";
5
+
6
+ //#region src/client.d.ts
5
7
  type HeaderValue = string | undefined | null;
6
8
  /**
7
9
  * Get the API key from the environment.
@@ -14,667 +16,682 @@ type HeaderValue = string | undefined | null;
14
16
  * @param apiKey - Optional API key provided as an argument
15
17
  * @returns The API key if found, otherwise undefined
16
18
  */
17
- export declare function getApiKey(apiKey?: string): string | undefined;
18
- export type RequestHook = (url: URL, init: RequestInit) => Promise<RequestInit> | RequestInit;
19
- export interface ClientConfig {
20
- apiUrl?: string;
21
- apiKey?: string;
22
- callerOptions?: AsyncCallerParams;
23
- timeoutMs?: number;
24
- defaultHeaders?: Record<string, HeaderValue>;
25
- onRequest?: RequestHook;
19
+ declare function getApiKey(apiKey?: string): string | undefined;
20
+ type RequestHook = (url: URL, init: RequestInit) => Promise<RequestInit> | RequestInit;
21
+ interface ClientConfig {
22
+ apiUrl?: string;
23
+ apiKey?: string;
24
+ callerOptions?: AsyncCallerParams;
25
+ timeoutMs?: number;
26
+ defaultHeaders?: Record<string, HeaderValue>;
27
+ onRequest?: RequestHook;
26
28
  }
27
29
  declare class BaseClient {
28
- protected asyncCaller: AsyncCaller;
29
- protected timeoutMs: number | undefined;
30
- protected apiUrl: string;
31
- protected defaultHeaders: Record<string, HeaderValue>;
32
- protected onRequest?: RequestHook;
33
- constructor(config?: ClientConfig);
34
- protected prepareFetchOptions(path: string, options?: RequestInit & {
35
- json?: unknown;
36
- params?: Record<string, unknown>;
37
- timeoutMs?: number | null;
38
- withResponse?: boolean;
39
- }): [url: URL, init: RequestInit];
40
- protected fetch<T>(path: string, options: RequestInit & {
41
- json?: unknown;
42
- params?: Record<string, unknown>;
43
- timeoutMs?: number | null;
44
- signal?: AbortSignal;
45
- withResponse: true;
46
- }): Promise<[T, Response]>;
47
- protected fetch<T>(path: string, options?: RequestInit & {
48
- json?: unknown;
49
- params?: Record<string, unknown>;
50
- timeoutMs?: number | null;
51
- signal?: AbortSignal;
52
- withResponse?: false;
53
- }): Promise<T>;
30
+ protected asyncCaller: AsyncCaller;
31
+ protected timeoutMs: number | undefined;
32
+ protected apiUrl: string;
33
+ protected defaultHeaders: Record<string, HeaderValue>;
34
+ protected onRequest?: RequestHook;
35
+ constructor(config?: ClientConfig);
36
+ protected prepareFetchOptions(path: string, options?: RequestInit & {
37
+ json?: unknown;
38
+ params?: Record<string, unknown>;
39
+ timeoutMs?: number | null;
40
+ withResponse?: boolean;
41
+ }): [url: URL, init: RequestInit];
42
+ protected fetch<T>(path: string, options: RequestInit & {
43
+ json?: unknown;
44
+ params?: Record<string, unknown>;
45
+ timeoutMs?: number | null;
46
+ signal?: AbortSignal;
47
+ withResponse: true;
48
+ }): Promise<[T, Response]>;
49
+ protected fetch<T>(path: string, options?: RequestInit & {
50
+ json?: unknown;
51
+ params?: Record<string, unknown>;
52
+ timeoutMs?: number | null;
53
+ signal?: AbortSignal;
54
+ withResponse?: false;
55
+ }): Promise<T>;
54
56
  }
55
- export declare class CronsClient extends BaseClient {
56
- /**
57
- *
58
- * @param threadId The ID of the thread.
59
- * @param assistantId Assistant ID to use for this cron job.
60
- * @param payload Payload for creating a cron job.
61
- * @returns The created background run.
62
- */
63
- createForThread(threadId: string, assistantId: string, payload?: CronsCreatePayload): Promise<CronCreateForThreadResponse>;
64
- /**
65
- *
66
- * @param assistantId Assistant ID to use for this cron job.
67
- * @param payload Payload for creating a cron job.
68
- * @returns
69
- */
70
- create(assistantId: string, payload?: CronsCreatePayload): Promise<CronCreateResponse>;
71
- /**
72
- *
73
- * @param cronId Cron ID of Cron job to delete.
74
- */
75
- delete(cronId: string): Promise<void>;
76
- /**
77
- *
78
- * @param query Query options.
79
- * @returns List of crons.
80
- */
81
- search(query?: {
82
- assistantId?: string;
83
- threadId?: string;
84
- limit?: number;
85
- offset?: number;
86
- sortBy?: CronSortBy;
87
- sortOrder?: SortOrder;
88
- select?: CronSelectField[];
89
- }): Promise<Cron[]>;
90
- /**
91
- * Count cron jobs matching filters.
92
- *
93
- * @param query.assistantId Assistant ID to filter by.
94
- * @param query.threadId Thread ID to filter by.
95
- * @returns Number of cron jobs matching the criteria.
96
- */
97
- count(query?: {
98
- assistantId?: string;
99
- threadId?: string;
100
- }): Promise<number>;
101
- }
102
- export declare class AssistantsClient extends BaseClient {
103
- /**
104
- * Get an assistant by ID.
105
- *
106
- * @param assistantId The ID of the assistant.
107
- * @returns Assistant
108
- */
109
- get(assistantId: string): Promise<Assistant>;
110
- /**
111
- * Get the JSON representation of the graph assigned to a runnable
112
- * @param assistantId The ID of the assistant.
113
- * @param options.xray Whether to include subgraphs in the serialized graph representation. If an integer value is provided, only subgraphs with a depth less than or equal to the value will be included.
114
- * @returns Serialized graph
115
- */
116
- getGraph(assistantId: string, options?: {
117
- xray?: boolean | number;
118
- }): Promise<AssistantGraph>;
119
- /**
120
- * Get the state and config schema of the graph assigned to a runnable
121
- * @param assistantId The ID of the assistant.
122
- * @returns Graph schema
123
- */
124
- getSchemas(assistantId: string): Promise<GraphSchema>;
125
- /**
126
- * Get the schemas of an assistant by ID.
127
- *
128
- * @param assistantId The ID of the assistant to get the schema of.
129
- * @param options Additional options for getting subgraphs, such as namespace or recursion extraction.
130
- * @returns The subgraphs of the assistant.
131
- */
132
- getSubgraphs(assistantId: string, options?: {
133
- namespace?: string;
134
- recurse?: boolean;
135
- }): Promise<Subgraphs>;
136
- /**
137
- * Create a new assistant.
138
- * @param payload Payload for creating an assistant.
139
- * @returns The created assistant.
140
- */
141
- create(payload: {
142
- graphId: string;
143
- config?: Config;
144
- context?: unknown;
145
- metadata?: Metadata;
146
- assistantId?: string;
147
- ifExists?: OnConflictBehavior;
148
- name?: string;
149
- description?: string;
150
- }): Promise<Assistant>;
151
- /**
152
- * Update an assistant.
153
- * @param assistantId ID of the assistant.
154
- * @param payload Payload for updating the assistant.
155
- * @returns The updated assistant.
156
- */
157
- update(assistantId: string, payload: {
158
- graphId?: string;
159
- config?: Config;
160
- context?: unknown;
161
- metadata?: Metadata;
162
- name?: string;
163
- description?: string;
164
- }): Promise<Assistant>;
165
- /**
166
- * Delete an assistant.
167
- *
168
- * @param assistantId ID of the assistant.
169
- */
170
- delete(assistantId: string): Promise<void>;
171
- /**
172
- * List assistants.
173
- * @param query Query options.
174
- * @returns List of assistants.
175
- */
176
- search(query?: {
177
- graphId?: string;
178
- metadata?: Metadata;
179
- limit?: number;
180
- offset?: number;
181
- sortBy?: AssistantSortBy;
182
- sortOrder?: SortOrder;
183
- select?: AssistantSelectField[];
184
- }): Promise<Assistant[]>;
185
- /**
186
- * Count assistants matching filters.
187
- *
188
- * @param query.metadata Metadata to filter by. Exact match for each key/value.
189
- * @param query.graphId Optional graph id to filter by.
190
- * @returns Number of assistants matching the criteria.
191
- */
192
- count(query?: {
193
- metadata?: Metadata;
194
- graphId?: string;
195
- }): Promise<number>;
196
- /**
197
- * List all versions of an assistant.
198
- *
199
- * @param assistantId ID of the assistant.
200
- * @returns List of assistant versions.
201
- */
202
- getVersions(assistantId: string, payload?: {
203
- metadata?: Metadata;
204
- limit?: number;
205
- offset?: number;
206
- }): Promise<AssistantVersion[]>;
207
- /**
208
- * Change the version of an assistant.
209
- *
210
- * @param assistantId ID of the assistant.
211
- * @param version The version to change to.
212
- * @returns The updated assistant.
213
- */
214
- setLatest(assistantId: string, version: number): Promise<Assistant>;
57
+ declare class CronsClient extends BaseClient {
58
+ /**
59
+ *
60
+ * @param threadId The ID of the thread.
61
+ * @param assistantId Assistant ID to use for this cron job.
62
+ * @param payload Payload for creating a cron job.
63
+ * @returns The created background run.
64
+ */
65
+ createForThread(threadId: string, assistantId: string, payload?: CronsCreatePayload): Promise<CronCreateForThreadResponse>;
66
+ /**
67
+ *
68
+ * @param assistantId Assistant ID to use for this cron job.
69
+ * @param payload Payload for creating a cron job.
70
+ * @returns
71
+ */
72
+ create(assistantId: string, payload?: CronsCreatePayload): Promise<CronCreateResponse>;
73
+ /**
74
+ *
75
+ * @param cronId Cron ID of Cron job to delete.
76
+ */
77
+ delete(cronId: string): Promise<void>;
78
+ /**
79
+ *
80
+ * @param query Query options.
81
+ * @returns List of crons.
82
+ */
83
+ search(query?: {
84
+ assistantId?: string;
85
+ threadId?: string;
86
+ limit?: number;
87
+ offset?: number;
88
+ sortBy?: CronSortBy;
89
+ sortOrder?: SortOrder;
90
+ select?: CronSelectField[];
91
+ }): Promise<Cron[]>;
92
+ /**
93
+ * Count cron jobs matching filters.
94
+ *
95
+ * @param query.assistantId Assistant ID to filter by.
96
+ * @param query.threadId Thread ID to filter by.
97
+ * @returns Number of cron jobs matching the criteria.
98
+ */
99
+ count(query?: {
100
+ assistantId?: string;
101
+ threadId?: string;
102
+ }): Promise<number>;
215
103
  }
216
- export declare class ThreadsClient<TStateType = DefaultValues, TUpdateType = TStateType> extends BaseClient {
217
- /**
218
- * Get a thread by ID.
219
- *
220
- * @param threadId ID of the thread.
221
- * @returns The thread.
222
- */
223
- get<ValuesType = TStateType>(threadId: string): Promise<Thread<ValuesType>>;
224
- /**
225
- * Create a new thread.
226
- *
227
- * @param payload Payload for creating a thread.
228
- * @returns The created thread.
229
- */
230
- create(payload?: {
231
- /**
232
- * Metadata for the thread.
233
- */
234
- metadata?: Metadata;
235
- /**
236
- * ID of the thread to create.
237
- *
238
- * If not provided, a random UUID will be generated.
239
- */
240
- threadId?: string;
241
- /**
242
- * How to handle duplicate creation.
243
- *
244
- * @default "raise"
245
- */
246
- ifExists?: OnConflictBehavior;
247
- /**
248
- * Graph ID to associate with the thread.
249
- */
250
- graphId?: string;
251
- /**
252
- * Apply a list of supersteps when creating a thread, each containing a sequence of updates.
253
- *
254
- * Used for copying a thread between deployments.
255
- */
256
- supersteps?: Array<{
257
- updates: Array<{
258
- values: unknown;
259
- command?: Command;
260
- asNode: string;
261
- }>;
262
- }>;
263
- /**
264
- * Optional time-to-live in minutes for the thread.
265
- * If a number is provided, it is treated as minutes and defaults to strategy "delete".
266
- * You may also provide an object { ttl: number, strategy?: "delete" }.
267
- */
268
- ttl?: number | {
269
- ttl: number;
270
- strategy?: "delete";
271
- };
272
- }): Promise<Thread<TStateType>>;
273
- /**
274
- * Copy an existing thread
275
- * @param threadId ID of the thread to be copied
276
- * @returns Newly copied thread
277
- */
278
- copy(threadId: string): Promise<Thread<TStateType>>;
279
- /**
280
- * Update a thread.
281
- *
282
- * @param threadId ID of the thread.
283
- * @param payload Payload for updating the thread.
284
- * @returns The updated thread.
285
- */
286
- update(threadId: string, payload?: {
287
- /**
288
- * Metadata for the thread.
289
- */
290
- metadata?: Metadata;
291
- /**
292
- * Optional time-to-live in minutes for the thread.
293
- * If a number is provided, it is treated as minutes and defaults to strategy "delete".
294
- * You may also provide an object { ttl: number, strategy?: "delete" }.
295
- */
296
- ttl?: number | {
297
- ttl: number;
298
- strategy?: "delete";
299
- };
300
- }): Promise<Thread>;
301
- /**
302
- * Delete a thread.
303
- *
304
- * @param threadId ID of the thread.
305
- */
306
- delete(threadId: string): Promise<void>;
307
- /**
308
- * List threads
309
- *
310
- * @param query Query options
311
- * @returns List of threads
312
- */
313
- search<ValuesType = TStateType>(query?: {
314
- /**
315
- * Metadata to filter threads by.
316
- */
317
- metadata?: Metadata;
318
- /**
319
- * Filter by specific thread IDs.
320
- */
321
- ids?: string[];
322
- /**
323
- * Maximum number of threads to return.
324
- * Defaults to 10
325
- */
326
- limit?: number;
327
- /**
328
- * Offset to start from.
329
- */
330
- offset?: number;
331
- /**
332
- * Thread status to filter on.
333
- */
334
- status?: ThreadStatus;
335
- /**
336
- * Sort by.
337
- */
338
- sortBy?: ThreadSortBy;
339
- /**
340
- * Sort order.
341
- * Must be one of 'asc' or 'desc'.
342
- */
343
- sortOrder?: SortOrder;
344
- select?: ThreadSelectField[];
345
- }): Promise<Thread<ValuesType>[]>;
346
- /**
347
- * Count threads matching filters.
348
- *
349
- * @param query.metadata Thread metadata to filter on.
350
- * @param query.values State values to filter on.
351
- * @param query.status Thread status to filter on.
352
- * @returns Number of threads matching the criteria.
353
- */
354
- count<ValuesType = TStateType>(query?: {
355
- metadata?: Metadata;
356
- values?: ValuesType;
357
- status?: ThreadStatus;
358
- }): Promise<number>;
359
- /**
360
- * Get state for a thread.
361
- *
362
- * @param threadId ID of the thread.
363
- * @returns Thread state.
364
- */
365
- getState<ValuesType = TStateType>(threadId: string, checkpoint?: Checkpoint | string, options?: {
366
- subgraphs?: boolean;
367
- }): Promise<ThreadState<ValuesType>>;
368
- /**
369
- * Add state to a thread.
370
- *
371
- * @param threadId The ID of the thread.
372
- * @returns
373
- */
374
- updateState<ValuesType = TUpdateType>(threadId: string, options: {
375
- values: ValuesType;
376
- checkpoint?: Checkpoint;
377
- checkpointId?: string;
378
- asNode?: string;
379
- }): Promise<Pick<Config, "configurable">>;
380
- /**
381
- * Patch the metadata of a thread.
382
- *
383
- * @param threadIdOrConfig Thread ID or config to patch the state of.
384
- * @param metadata Metadata to patch the state with.
385
- */
386
- patchState(threadIdOrConfig: string | Config, metadata: Metadata): Promise<void>;
387
- /**
388
- * Get all past states for a thread.
389
- *
390
- * @param threadId ID of the thread.
391
- * @param options Additional options.
392
- * @returns List of thread states.
393
- */
394
- getHistory<ValuesType = TStateType>(threadId: string, options?: {
395
- limit?: number;
396
- before?: Config;
397
- checkpoint?: Partial<Omit<Checkpoint, "thread_id">>;
398
- metadata?: Metadata;
399
- }): Promise<ThreadState<ValuesType>[]>;
400
- joinStream(threadId: string, options?: {
401
- lastEventId?: string;
402
- streamMode?: ThreadStreamMode | ThreadStreamMode[];
403
- }): AsyncGenerator<{
404
- id?: string;
405
- event: StreamEvent;
406
- data: any;
407
- }>;
104
+ declare class AssistantsClient extends BaseClient {
105
+ /**
106
+ * Get an assistant by ID.
107
+ *
108
+ * @param assistantId The ID of the assistant.
109
+ * @returns Assistant
110
+ */
111
+ get(assistantId: string): Promise<Assistant>;
112
+ /**
113
+ * Get the JSON representation of the graph assigned to a runnable
114
+ * @param assistantId The ID of the assistant.
115
+ * @param options.xray Whether to include subgraphs in the serialized graph representation. If an integer value is provided, only subgraphs with a depth less than or equal to the value will be included.
116
+ * @returns Serialized graph
117
+ */
118
+ getGraph(assistantId: string, options?: {
119
+ xray?: boolean | number;
120
+ }): Promise<AssistantGraph>;
121
+ /**
122
+ * Get the state and config schema of the graph assigned to a runnable
123
+ * @param assistantId The ID of the assistant.
124
+ * @returns Graph schema
125
+ */
126
+ getSchemas(assistantId: string): Promise<GraphSchema>;
127
+ /**
128
+ * Get the schemas of an assistant by ID.
129
+ *
130
+ * @param assistantId The ID of the assistant to get the schema of.
131
+ * @param options Additional options for getting subgraphs, such as namespace or recursion extraction.
132
+ * @returns The subgraphs of the assistant.
133
+ */
134
+ getSubgraphs(assistantId: string, options?: {
135
+ namespace?: string;
136
+ recurse?: boolean;
137
+ }): Promise<Subgraphs>;
138
+ /**
139
+ * Create a new assistant.
140
+ * @param payload Payload for creating an assistant.
141
+ * @returns The created assistant.
142
+ */
143
+ create(payload: {
144
+ graphId: string;
145
+ config?: Config;
146
+ context?: unknown;
147
+ metadata?: Metadata;
148
+ assistantId?: string;
149
+ ifExists?: OnConflictBehavior;
150
+ name?: string;
151
+ description?: string;
152
+ }): Promise<Assistant>;
153
+ /**
154
+ * Update an assistant.
155
+ * @param assistantId ID of the assistant.
156
+ * @param payload Payload for updating the assistant.
157
+ * @returns The updated assistant.
158
+ */
159
+ update(assistantId: string, payload: {
160
+ graphId?: string;
161
+ config?: Config;
162
+ context?: unknown;
163
+ metadata?: Metadata;
164
+ name?: string;
165
+ description?: string;
166
+ }): Promise<Assistant>;
167
+ /**
168
+ * Delete an assistant.
169
+ *
170
+ * @param assistantId ID of the assistant.
171
+ */
172
+ delete(assistantId: string): Promise<void>;
173
+ /**
174
+ * List assistants.
175
+ * @param query Query options.
176
+ * @returns List of assistants.
177
+ */
178
+ search(query?: {
179
+ graphId?: string;
180
+ name?: string;
181
+ metadata?: Metadata;
182
+ limit?: number;
183
+ offset?: number;
184
+ sortBy?: AssistantSortBy;
185
+ sortOrder?: SortOrder;
186
+ select?: AssistantSelectField[];
187
+ }): Promise<Assistant[]>;
188
+ /**
189
+ * Count assistants matching filters.
190
+ *
191
+ * @param query.metadata Metadata to filter by. Exact match for each key/value.
192
+ * @param query.graphId Optional graph id to filter by.
193
+ * @returns Number of assistants matching the criteria.
194
+ */
195
+ count(query?: {
196
+ metadata?: Metadata;
197
+ graphId?: string;
198
+ }): Promise<number>;
199
+ /**
200
+ * List all versions of an assistant.
201
+ *
202
+ * @param assistantId ID of the assistant.
203
+ * @returns List of assistant versions.
204
+ */
205
+ getVersions(assistantId: string, payload?: {
206
+ metadata?: Metadata;
207
+ limit?: number;
208
+ offset?: number;
209
+ }): Promise<AssistantVersion[]>;
210
+ /**
211
+ * Change the version of an assistant.
212
+ *
213
+ * @param assistantId ID of the assistant.
214
+ * @param version The version to change to.
215
+ * @returns The updated assistant.
216
+ */
217
+ setLatest(assistantId: string, version: number): Promise<Assistant>;
408
218
  }
409
- export declare class RunsClient<TStateType = DefaultValues, TUpdateType = TStateType, TCustomEventType = unknown> extends BaseClient {
410
- stream<TStreamMode extends StreamMode | StreamMode[] = StreamMode, TSubgraphs extends boolean = false>(threadId: null, assistantId: string, payload?: Omit<RunsStreamPayload<TStreamMode, TSubgraphs>, "multitaskStrategy" | "onCompletion">): TypedAsyncGenerator<TStreamMode, TSubgraphs, TStateType, TUpdateType, TCustomEventType>;
411
- stream<TStreamMode extends StreamMode | StreamMode[] = StreamMode, TSubgraphs extends boolean = false>(threadId: string, assistantId: string, payload?: RunsStreamPayload<TStreamMode, TSubgraphs>): TypedAsyncGenerator<TStreamMode, TSubgraphs, TStateType, TUpdateType, TCustomEventType>;
412
- /**
413
- * Create a run.
414
- *
415
- * @param threadId The ID of the thread.
416
- * @param assistantId Assistant ID to use for this run.
417
- * @param payload Payload for creating a run.
418
- * @returns The created run.
419
- */
420
- create(threadId: string | null, assistantId: string, payload?: RunsCreatePayload): Promise<Run>;
219
+ declare class ThreadsClient<TStateType = DefaultValues, TUpdateType = TStateType> extends BaseClient {
220
+ /**
221
+ * Get a thread by ID.
222
+ *
223
+ * @param threadId ID of the thread.
224
+ * @returns The thread.
225
+ */
226
+ get<ValuesType = TStateType>(threadId: string): Promise<Thread<ValuesType>>;
227
+ /**
228
+ * Create a new thread.
229
+ *
230
+ * @param payload Payload for creating a thread.
231
+ * @returns The created thread.
232
+ */
233
+ create(payload?: {
421
234
  /**
422
- * Create a batch of stateless background runs.
423
- *
424
- * @param payloads An array of payloads for creating runs.
425
- * @returns An array of created runs.
235
+ * Metadata for the thread.
426
236
  */
427
- createBatch(payloads: (RunsCreatePayload & {
428
- assistantId: string;
429
- })[]): Promise<Run[]>;
430
- wait(threadId: null, assistantId: string, payload?: Omit<RunsWaitPayload, "multitaskStrategy" | "onCompletion">): Promise<ThreadState["values"]>;
431
- wait(threadId: string, assistantId: string, payload?: RunsWaitPayload): Promise<ThreadState["values"]>;
237
+ metadata?: Metadata;
432
238
  /**
433
- * List all runs for a thread.
239
+ * ID of the thread to create.
434
240
  *
435
- * @param threadId The ID of the thread.
436
- * @param options Filtering and pagination options.
437
- * @returns List of runs.
241
+ * If not provided, a random UUID will be generated.
438
242
  */
439
- list(threadId: string, options?: {
440
- /**
441
- * Maximum number of runs to return.
442
- * Defaults to 10
443
- */
444
- limit?: number;
445
- /**
446
- * Offset to start from.
447
- * Defaults to 0.
448
- */
449
- offset?: number;
450
- /**
451
- * Status of the run to filter by.
452
- */
453
- status?: RunStatus;
454
- select?: RunSelectField[];
455
- }): Promise<Run[]>;
243
+ threadId?: string;
456
244
  /**
457
- * Get a run by ID.
245
+ * How to handle duplicate creation.
458
246
  *
459
- * @param threadId The ID of the thread.
460
- * @param runId The ID of the run.
461
- * @returns The run.
247
+ * @default "raise"
462
248
  */
463
- get(threadId: string, runId: string): Promise<Run>;
249
+ ifExists?: OnConflictBehavior;
464
250
  /**
465
- * Cancel a run.
466
- *
467
- * @param threadId The ID of the thread.
468
- * @param runId The ID of the run.
469
- * @param wait Whether to block when canceling
470
- * @param action Action to take when cancelling the run. Possible values are `interrupt` or `rollback`. Default is `interrupt`.
471
- * @returns
251
+ * Graph ID to associate with the thread.
472
252
  */
473
- cancel(threadId: string, runId: string, wait?: boolean, action?: CancelAction): Promise<void>;
253
+ graphId?: string;
474
254
  /**
475
- * Block until a run is done.
255
+ * Apply a list of supersteps when creating a thread, each containing a sequence of updates.
476
256
  *
477
- * @param threadId The ID of the thread.
478
- * @param runId The ID of the run.
479
- * @returns
257
+ * Used for copying a thread between deployments.
480
258
  */
481
- join(threadId: string, runId: string, options?: {
482
- signal?: AbortSignal;
483
- }): Promise<TStateType>;
484
- /**
485
- * Stream output from a run in real-time, until the run is done.
486
- *
487
- * @param threadId The ID of the thread. Can be set to `null` | `undefined` for stateless runs.
488
- * @param runId The ID of the run.
489
- * @param options Additional options for controlling the stream behavior:
490
- * - signal: An AbortSignal that can be used to cancel the stream request
491
- * - lastEventId: The ID of the last event received. Can be used to reconnect to a stream without losing events.
492
- * - cancelOnDisconnect: When true, automatically cancels the run if the client disconnects from the stream
493
- * - streamMode: Controls what types of events to receive from the stream (can be a single mode or array of modes)
494
- * Must be a subset of the stream modes passed when creating the run. Background runs default to having the union of all
495
- * stream modes enabled.
496
- * @returns An async generator yielding stream parts.
497
- */
498
- joinStream(threadId: string | undefined | null, runId: string, options?: {
499
- signal?: AbortSignal;
500
- cancelOnDisconnect?: boolean;
501
- lastEventId?: string;
502
- streamMode?: StreamMode | StreamMode[];
503
- } | AbortSignal): AsyncGenerator<{
504
- id?: string;
505
- event: StreamEvent;
506
- data: any;
259
+ supersteps?: Array<{
260
+ updates: Array<{
261
+ values: unknown;
262
+ command?: Command;
263
+ asNode: string;
264
+ }>;
507
265
  }>;
508
266
  /**
509
- * Delete a run.
510
- *
511
- * @param threadId The ID of the thread.
512
- * @param runId The ID of the run.
513
- * @returns
514
- */
515
- delete(threadId: string, runId: string): Promise<void>;
267
+ * Optional time-to-live in minutes for the thread.
268
+ * If a number is provided, it is treated as minutes and defaults to strategy "delete".
269
+ * You may also provide an object { ttl: number, strategy?: "delete" }.
270
+ */
271
+ ttl?: number | {
272
+ ttl: number;
273
+ strategy?: "delete";
274
+ };
275
+ }): Promise<Thread<TStateType>>;
276
+ /**
277
+ * Copy an existing thread
278
+ * @param threadId ID of the thread to be copied
279
+ * @returns Newly copied thread
280
+ */
281
+ copy(threadId: string): Promise<Thread<TStateType>>;
282
+ /**
283
+ * Update a thread.
284
+ *
285
+ * @param threadId ID of the thread.
286
+ * @param payload Payload for updating the thread.
287
+ * @returns The updated thread.
288
+ */
289
+ update(threadId: string, payload?: {
290
+ /**
291
+ * Metadata for the thread.
292
+ */
293
+ metadata?: Metadata;
294
+ /**
295
+ * Optional time-to-live in minutes for the thread.
296
+ * If a number is provided, it is treated as minutes and defaults to strategy "delete".
297
+ * You may also provide an object { ttl: number, strategy?: "delete" }.
298
+ */
299
+ ttl?: number | {
300
+ ttl: number;
301
+ strategy?: "delete";
302
+ };
303
+ }): Promise<Thread>;
304
+ /**
305
+ * Delete a thread.
306
+ *
307
+ * @param threadId ID of the thread.
308
+ */
309
+ delete(threadId: string): Promise<void>;
310
+ /**
311
+ * List threads
312
+ *
313
+ * @param query Query options
314
+ * @returns List of threads
315
+ */
316
+ search<ValuesType = TStateType>(query?: {
317
+ /**
318
+ * Metadata to filter threads by.
319
+ */
320
+ metadata?: Metadata;
321
+ /**
322
+ * Filter by specific thread IDs.
323
+ */
324
+ ids?: string[];
325
+ /**
326
+ * Maximum number of threads to return.
327
+ * Defaults to 10
328
+ */
329
+ limit?: number;
330
+ /**
331
+ * Offset to start from.
332
+ */
333
+ offset?: number;
334
+ /**
335
+ * Thread status to filter on.
336
+ */
337
+ status?: ThreadStatus;
338
+ /**
339
+ * Sort by.
340
+ */
341
+ sortBy?: ThreadSortBy;
342
+ /**
343
+ * Sort order.
344
+ * Must be one of 'asc' or 'desc'.
345
+ */
346
+ sortOrder?: SortOrder;
347
+ /**
348
+ * Array of fields to select.
349
+ * Elements or array must be one of 'thread_id, 'created_at', 'updated_at', 'metadata', 'config', 'context', 'status', 'values', or 'interrupts'.
350
+ */
351
+ select?: ThreadSelectField[];
352
+ /**
353
+ * Values to filter threads by.
354
+ */
355
+ values?: ThreadValuesFilter;
356
+ }): Promise<Thread<ValuesType>[]>;
357
+ /**
358
+ * Count threads matching filters.
359
+ *
360
+ * @param query.metadata Thread metadata to filter on.
361
+ * @param query.values State values to filter on.
362
+ * @param query.status Thread status to filter on.
363
+ * @returns Number of threads matching the criteria.
364
+ */
365
+ count<ValuesType = TStateType>(query?: {
366
+ metadata?: Metadata;
367
+ values?: ValuesType;
368
+ status?: ThreadStatus;
369
+ }): Promise<number>;
370
+ /**
371
+ * Get state for a thread.
372
+ *
373
+ * @param threadId ID of the thread.
374
+ * @returns Thread state.
375
+ */
376
+ getState<ValuesType = TStateType>(threadId: string, checkpoint?: Checkpoint | string, options?: {
377
+ subgraphs?: boolean;
378
+ }): Promise<ThreadState<ValuesType>>;
379
+ /**
380
+ * Add state to a thread.
381
+ *
382
+ * @param threadId The ID of the thread.
383
+ * @returns
384
+ */
385
+ updateState<ValuesType = TUpdateType>(threadId: string, options: {
386
+ values: ValuesType;
387
+ checkpoint?: Checkpoint;
388
+ checkpointId?: string;
389
+ asNode?: string;
390
+ }): Promise<Pick<Config, "configurable">>;
391
+ /**
392
+ * Patch the metadata of a thread.
393
+ *
394
+ * @param threadIdOrConfig Thread ID or config to patch the state of.
395
+ * @param metadata Metadata to patch the state with.
396
+ */
397
+ patchState(threadIdOrConfig: string | Config, metadata: Metadata): Promise<void>;
398
+ /**
399
+ * Get all past states for a thread.
400
+ *
401
+ * @param threadId ID of the thread.
402
+ * @param options Additional options.
403
+ * @returns List of thread states.
404
+ */
405
+ getHistory<ValuesType = TStateType>(threadId: string, options?: {
406
+ limit?: number;
407
+ before?: Config;
408
+ checkpoint?: Partial<Omit<Checkpoint, "thread_id">>;
409
+ metadata?: Metadata;
410
+ }): Promise<ThreadState<ValuesType>[]>;
411
+ joinStream(threadId: string, options?: {
412
+ lastEventId?: string;
413
+ streamMode?: ThreadStreamMode | ThreadStreamMode[];
414
+ }
415
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
416
+ ): AsyncGenerator<{
417
+ id?: string;
418
+ event: StreamEvent;
419
+ data: any;
420
+ }>;
516
421
  }
517
- export declare class StoreClient extends BaseClient {
518
- /**
519
- * Store or update an item.
520
- *
521
- * @param namespace A list of strings representing the namespace path.
522
- * @param key The unique identifier for the item within the namespace.
523
- * @param value A dictionary containing the item's data.
524
- * @param options.index Controls search indexing - null (use defaults), false (disable), or list of field paths to index.
525
- * @param options.ttl Optional time-to-live in minutes for the item, or null for no expiration.
526
- * @returns Promise<void>
527
- *
528
- * @example
529
- * ```typescript
530
- * await client.store.putItem(
531
- * ["documents", "user123"],
532
- * "item456",
533
- * { title: "My Document", content: "Hello World" },
534
- * { ttl: 60 } // expires in 60 minutes
535
- * );
536
- * ```
537
- */
538
- putItem(namespace: string[], key: string, value: Record<string, unknown>, options?: {
539
- index?: false | string[] | null;
540
- ttl?: number | null;
541
- }): Promise<void>;
542
- /**
543
- * Retrieve a single item.
544
- *
545
- * @param namespace A list of strings representing the namespace path.
546
- * @param key The unique identifier for the item.
547
- * @param options.refreshTtl Whether to refresh the TTL on this read operation. If null, uses the store's default behavior.
548
- * @returns Promise<Item>
549
- *
550
- * @example
551
- * ```typescript
552
- * const item = await client.store.getItem(
553
- * ["documents", "user123"],
554
- * "item456",
555
- * { refreshTtl: true }
556
- * );
557
- * console.log(item);
558
- * // {
559
- * // namespace: ["documents", "user123"],
560
- * // key: "item456",
561
- * // value: { title: "My Document", content: "Hello World" },
562
- * // createdAt: "2024-07-30T12:00:00Z",
563
- * // updatedAt: "2024-07-30T12:00:00Z"
564
- * // }
565
- * ```
566
- */
567
- getItem(namespace: string[], key: string, options?: {
568
- refreshTtl?: boolean | null;
569
- }): Promise<Item | null>;
570
- /**
571
- * Delete an item.
572
- *
573
- * @param namespace A list of strings representing the namespace path.
574
- * @param key The unique identifier for the item.
575
- * @returns Promise<void>
576
- */
577
- deleteItem(namespace: string[], key: string): Promise<void>;
578
- /**
579
- * Search for items within a namespace prefix.
580
- *
581
- * @param namespacePrefix List of strings representing the namespace prefix.
582
- * @param options.filter Optional dictionary of key-value pairs to filter results.
583
- * @param options.limit Maximum number of items to return (default is 10).
584
- * @param options.offset Number of items to skip before returning results (default is 0).
585
- * @param options.query Optional search query.
586
- * @param options.refreshTtl Whether to refresh the TTL on items returned by this search. If null, uses the store's default behavior.
587
- * @returns Promise<SearchItemsResponse>
588
- *
589
- * @example
590
- * ```typescript
591
- * const results = await client.store.searchItems(
592
- * ["documents"],
593
- * {
594
- * filter: { author: "John Doe" },
595
- * limit: 5,
596
- * refreshTtl: true
597
- * }
598
- * );
599
- * console.log(results);
600
- * // {
601
- * // items: [
602
- * // {
603
- * // namespace: ["documents", "user123"],
604
- * // key: "item789",
605
- * // value: { title: "Another Document", author: "John Doe" },
606
- * // createdAt: "2024-07-30T12:00:00Z",
607
- * // updatedAt: "2024-07-30T12:00:00Z"
608
- * // },
609
- * // // ... additional items ...
610
- * // ]
611
- * // }
612
- * ```
613
- */
614
- searchItems(namespacePrefix: string[], options?: {
615
- filter?: Record<string, unknown>;
616
- limit?: number;
617
- offset?: number;
618
- query?: string;
619
- refreshTtl?: boolean | null;
620
- }): Promise<SearchItemsResponse>;
621
- /**
622
- * List namespaces with optional match conditions.
623
- *
624
- * @param options.prefix Optional list of strings representing the prefix to filter namespaces.
625
- * @param options.suffix Optional list of strings representing the suffix to filter namespaces.
626
- * @param options.maxDepth Optional integer specifying the maximum depth of namespaces to return.
627
- * @param options.limit Maximum number of namespaces to return (default is 100).
628
- * @param options.offset Number of namespaces to skip before returning results (default is 0).
629
- * @returns Promise<ListNamespaceResponse>
630
- */
631
- listNamespaces(options?: {
632
- prefix?: string[];
633
- suffix?: string[];
634
- maxDepth?: number;
635
- limit?: number;
636
- offset?: number;
637
- }): Promise<ListNamespaceResponse>;
422
+ declare class RunsClient<TStateType = DefaultValues, TUpdateType = TStateType, TCustomEventType = unknown> extends BaseClient {
423
+ stream<TStreamMode extends StreamMode | StreamMode[] = StreamMode, TSubgraphs extends boolean = false>(threadId: null, assistantId: string, payload?: Omit<RunsStreamPayload<TStreamMode, TSubgraphs>, "multitaskStrategy" | "onCompletion">): TypedAsyncGenerator<TStreamMode, TSubgraphs, TStateType, TUpdateType, TCustomEventType>;
424
+ stream<TStreamMode extends StreamMode | StreamMode[] = StreamMode, TSubgraphs extends boolean = false>(threadId: string, assistantId: string, payload?: RunsStreamPayload<TStreamMode, TSubgraphs>): TypedAsyncGenerator<TStreamMode, TSubgraphs, TStateType, TUpdateType, TCustomEventType>;
425
+ /**
426
+ * Create a run.
427
+ *
428
+ * @param threadId The ID of the thread.
429
+ * @param assistantId Assistant ID to use for this run.
430
+ * @param payload Payload for creating a run.
431
+ * @returns The created run.
432
+ */
433
+ create(threadId: string | null, assistantId: string, payload?: RunsCreatePayload): Promise<Run>;
434
+ /**
435
+ * Create a batch of stateless background runs.
436
+ *
437
+ * @param payloads An array of payloads for creating runs.
438
+ * @returns An array of created runs.
439
+ */
440
+ createBatch(payloads: (RunsCreatePayload & {
441
+ assistantId: string;
442
+ })[]): Promise<Run[]>;
443
+ wait(threadId: null, assistantId: string, payload?: Omit<RunsWaitPayload, "multitaskStrategy" | "onCompletion">): Promise<ThreadState["values"]>;
444
+ wait(threadId: string, assistantId: string, payload?: RunsWaitPayload): Promise<ThreadState["values"]>;
445
+ /**
446
+ * List all runs for a thread.
447
+ *
448
+ * @param threadId The ID of the thread.
449
+ * @param options Filtering and pagination options.
450
+ * @returns List of runs.
451
+ */
452
+ list(threadId: string, options?: {
453
+ /**
454
+ * Maximum number of runs to return.
455
+ * Defaults to 10
456
+ */
457
+ limit?: number;
458
+ /**
459
+ * Offset to start from.
460
+ * Defaults to 0.
461
+ */
462
+ offset?: number;
463
+ /**
464
+ * Status of the run to filter by.
465
+ */
466
+ status?: RunStatus;
467
+ select?: RunSelectField[];
468
+ }): Promise<Run[]>;
469
+ /**
470
+ * Get a run by ID.
471
+ *
472
+ * @param threadId The ID of the thread.
473
+ * @param runId The ID of the run.
474
+ * @returns The run.
475
+ */
476
+ get(threadId: string, runId: string): Promise<Run>;
477
+ /**
478
+ * Cancel a run.
479
+ *
480
+ * @param threadId The ID of the thread.
481
+ * @param runId The ID of the run.
482
+ * @param wait Whether to block when canceling
483
+ * @param action Action to take when cancelling the run. Possible values are `interrupt` or `rollback`. Default is `interrupt`.
484
+ * @returns
485
+ */
486
+ cancel(threadId: string, runId: string, wait?: boolean, action?: CancelAction): Promise<void>;
487
+ /**
488
+ * Block until a run is done.
489
+ *
490
+ * @param threadId The ID of the thread.
491
+ * @param runId The ID of the run.
492
+ * @returns
493
+ */
494
+ join(threadId: string, runId: string, options?: {
495
+ signal?: AbortSignal;
496
+ }): Promise<TStateType>;
497
+ /**
498
+ * Stream output from a run in real-time, until the run is done.
499
+ *
500
+ * @param threadId The ID of the thread. Can be set to `null` | `undefined` for stateless runs.
501
+ * @param runId The ID of the run.
502
+ * @param options Additional options for controlling the stream behavior:
503
+ * - signal: An AbortSignal that can be used to cancel the stream request
504
+ * - lastEventId: The ID of the last event received. Can be used to reconnect to a stream without losing events.
505
+ * - cancelOnDisconnect: When true, automatically cancels the run if the client disconnects from the stream
506
+ * - streamMode: Controls what types of events to receive from the stream (can be a single mode or array of modes)
507
+ * Must be a subset of the stream modes passed when creating the run. Background runs default to having the union of all
508
+ * stream modes enabled.
509
+ * @returns An async generator yielding stream parts.
510
+ */
511
+ joinStream(threadId: string | undefined | null, runId: string, options?: {
512
+ signal?: AbortSignal;
513
+ cancelOnDisconnect?: boolean;
514
+ lastEventId?: string;
515
+ streamMode?: StreamMode | StreamMode[];
516
+ } | AbortSignal
517
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
518
+ ): AsyncGenerator<{
519
+ id?: string;
520
+ event: StreamEvent;
521
+ data: any;
522
+ }>;
523
+ /**
524
+ * Delete a run.
525
+ *
526
+ * @param threadId The ID of the thread.
527
+ * @param runId The ID of the run.
528
+ * @returns
529
+ */
530
+ delete(threadId: string, runId: string): Promise<void>;
531
+ }
532
+ declare class StoreClient extends BaseClient {
533
+ /**
534
+ * Store or update an item.
535
+ *
536
+ * @param namespace A list of strings representing the namespace path.
537
+ * @param key The unique identifier for the item within the namespace.
538
+ * @param value A dictionary containing the item's data.
539
+ * @param options.index Controls search indexing - null (use defaults), false (disable), or list of field paths to index.
540
+ * @param options.ttl Optional time-to-live in minutes for the item, or null for no expiration.
541
+ * @returns Promise<void>
542
+ *
543
+ * @example
544
+ * ```typescript
545
+ * await client.store.putItem(
546
+ * ["documents", "user123"],
547
+ * "item456",
548
+ * { title: "My Document", content: "Hello World" },
549
+ * { ttl: 60 } // expires in 60 minutes
550
+ * );
551
+ * ```
552
+ */
553
+ putItem(namespace: string[], key: string, value: Record<string, unknown>, options?: {
554
+ index?: false | string[] | null;
555
+ ttl?: number | null;
556
+ }): Promise<void>;
557
+ /**
558
+ * Retrieve a single item.
559
+ *
560
+ * @param namespace A list of strings representing the namespace path.
561
+ * @param key The unique identifier for the item.
562
+ * @param options.refreshTtl Whether to refresh the TTL on this read operation. If null, uses the store's default behavior.
563
+ * @returns Promise<Item>
564
+ *
565
+ * @example
566
+ * ```typescript
567
+ * const item = await client.store.getItem(
568
+ * ["documents", "user123"],
569
+ * "item456",
570
+ * { refreshTtl: true }
571
+ * );
572
+ * console.log(item);
573
+ * // {
574
+ * // namespace: ["documents", "user123"],
575
+ * // key: "item456",
576
+ * // value: { title: "My Document", content: "Hello World" },
577
+ * // createdAt: "2024-07-30T12:00:00Z",
578
+ * // updatedAt: "2024-07-30T12:00:00Z"
579
+ * // }
580
+ * ```
581
+ */
582
+ getItem(namespace: string[], key: string, options?: {
583
+ refreshTtl?: boolean | null;
584
+ }): Promise<Item | null>;
585
+ /**
586
+ * Delete an item.
587
+ *
588
+ * @param namespace A list of strings representing the namespace path.
589
+ * @param key The unique identifier for the item.
590
+ * @returns Promise<void>
591
+ */
592
+ deleteItem(namespace: string[], key: string): Promise<void>;
593
+ /**
594
+ * Search for items within a namespace prefix.
595
+ *
596
+ * @param namespacePrefix List of strings representing the namespace prefix.
597
+ * @param options.filter Optional dictionary of key-value pairs to filter results.
598
+ * @param options.limit Maximum number of items to return (default is 10).
599
+ * @param options.offset Number of items to skip before returning results (default is 0).
600
+ * @param options.query Optional search query.
601
+ * @param options.refreshTtl Whether to refresh the TTL on items returned by this search. If null, uses the store's default behavior.
602
+ * @returns Promise<SearchItemsResponse>
603
+ *
604
+ * @example
605
+ * ```typescript
606
+ * const results = await client.store.searchItems(
607
+ * ["documents"],
608
+ * {
609
+ * filter: { author: "John Doe" },
610
+ * limit: 5,
611
+ * refreshTtl: true
612
+ * }
613
+ * );
614
+ * console.log(results);
615
+ * // {
616
+ * // items: [
617
+ * // {
618
+ * // namespace: ["documents", "user123"],
619
+ * // key: "item789",
620
+ * // value: { title: "Another Document", author: "John Doe" },
621
+ * // createdAt: "2024-07-30T12:00:00Z",
622
+ * // updatedAt: "2024-07-30T12:00:00Z"
623
+ * // },
624
+ * // // ... additional items ...
625
+ * // ]
626
+ * // }
627
+ * ```
628
+ */
629
+ searchItems(namespacePrefix: string[], options?: {
630
+ filter?: Record<string, unknown>;
631
+ limit?: number;
632
+ offset?: number;
633
+ query?: string;
634
+ refreshTtl?: boolean | null;
635
+ }): Promise<SearchItemsResponse>;
636
+ /**
637
+ * List namespaces with optional match conditions.
638
+ *
639
+ * @param options.prefix Optional list of strings representing the prefix to filter namespaces.
640
+ * @param options.suffix Optional list of strings representing the suffix to filter namespaces.
641
+ * @param options.maxDepth Optional integer specifying the maximum depth of namespaces to return.
642
+ * @param options.limit Maximum number of namespaces to return (default is 100).
643
+ * @param options.offset Number of namespaces to skip before returning results (default is 0).
644
+ * @returns Promise<ListNamespaceResponse>
645
+ */
646
+ listNamespaces(options?: {
647
+ prefix?: string[];
648
+ suffix?: string[];
649
+ maxDepth?: number;
650
+ limit?: number;
651
+ offset?: number;
652
+ }): Promise<ListNamespaceResponse>;
638
653
  }
639
654
  declare class UiClient extends BaseClient {
640
- private static promiseCache;
641
- private static getOrCached;
642
- getComponent(assistantId: string, agentName: string): Promise<string>;
655
+ private static promiseCache;
656
+ private static getOrCached;
657
+ getComponent(assistantId: string, agentName: string): Promise<string>;
643
658
  }
644
- export declare class Client<TStateType = DefaultValues, TUpdateType = TStateType, TCustomEventType = unknown> {
645
- /**
646
- * The client for interacting with assistants.
647
- */
648
- assistants: AssistantsClient;
649
- /**
650
- * The client for interacting with threads.
651
- */
652
- threads: ThreadsClient<TStateType, TUpdateType>;
653
- /**
654
- * The client for interacting with runs.
655
- */
656
- runs: RunsClient<TStateType, TUpdateType, TCustomEventType>;
657
- /**
658
- * The client for interacting with cron runs.
659
- */
660
- crons: CronsClient;
661
- /**
662
- * The client for interacting with the KV store.
663
- */
664
- store: StoreClient;
665
- /**
666
- * The client for interacting with the UI.
667
- * @internal Used by LoadExternalComponent and the API might change in the future.
668
- */
669
- "~ui": UiClient;
670
- /**
671
- * @internal Used to obtain a stable key representing the client.
672
- */
673
- private "~configHash";
674
- constructor(config?: ClientConfig);
659
+ declare class Client<TStateType = DefaultValues, TUpdateType = TStateType, TCustomEventType = unknown> {
660
+ /**
661
+ * The client for interacting with assistants.
662
+ */
663
+ assistants: AssistantsClient;
664
+ /**
665
+ * The client for interacting with threads.
666
+ */
667
+ threads: ThreadsClient<TStateType, TUpdateType>;
668
+ /**
669
+ * The client for interacting with runs.
670
+ */
671
+ runs: RunsClient<TStateType, TUpdateType, TCustomEventType>;
672
+ /**
673
+ * The client for interacting with cron runs.
674
+ */
675
+ crons: CronsClient;
676
+ /**
677
+ * The client for interacting with the KV store.
678
+ */
679
+ store: StoreClient;
680
+ /**
681
+ * The client for interacting with the UI.
682
+ * @internal Used by LoadExternalComponent and the API might change in the future.
683
+ */
684
+ "~ui": UiClient;
685
+ /**
686
+ * @internal Used to obtain a stable key representing the client.
687
+ */
688
+ private "~configHash";
689
+ constructor(config?: ClientConfig);
675
690
  }
676
691
  /**
677
692
  * @internal Used to obtain a stable key representing the client.
678
693
  */
679
- export declare function getClientConfigHash(client: Client): string | undefined;
680
- export {};
694
+ declare function getClientConfigHash(client: Client): string | undefined;
695
+ //#endregion
696
+ export { AssistantsClient, Client, ClientConfig, CronsClient, RequestHook, RunsClient, StoreClient, ThreadsClient, getApiKey, getClientConfigHash };
697
+ //# sourceMappingURL=client.d.ts.map