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