@byteplus-iga-pages/agent 0.0.0-stage → 1.0.3

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 (105) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +84 -2
  3. package/dist/cjs/261.js +77 -0
  4. package/dist/cjs/341.js +43 -0
  5. package/dist/cjs/401.js +3632 -0
  6. package/dist/cjs/419.js +854 -0
  7. package/dist/cjs/504.js +760 -0
  8. package/dist/cjs/521.js +242 -0
  9. package/dist/cjs/594.js +79 -0
  10. package/dist/cjs/647.js +1367 -0
  11. package/dist/cjs/808.js +322 -0
  12. package/dist/cjs/82.js +10089 -0
  13. package/dist/cjs/893.js +17720 -0
  14. package/dist/cjs/893.js.LICENSE.txt +13 -0
  15. package/dist/cjs/951.js +59 -0
  16. package/dist/cjs/package.json +3 -0
  17. package/dist/cjs/runtime.js +79 -0
  18. package/dist/cjs/sandbox/host.js +125 -0
  19. package/dist/cjs/sandbox/index.js +286 -0
  20. package/dist/cjs/store/claude.js +209 -0
  21. package/dist/cjs/store/host.js +92 -0
  22. package/dist/cjs/store/index.js +43 -0
  23. package/dist/cjs/store/langgraph.js +581 -0
  24. package/dist/cjs/store/openai.js +118 -0
  25. package/dist/cjs/tools/claude.js +59 -0
  26. package/dist/cjs/tools/index.js +37 -0
  27. package/dist/cjs/tools/langchain.js +52 -0
  28. package/dist/cjs/tools/openai-agents.js +43 -0
  29. package/dist/cjs/tools/openai.js +43 -0
  30. package/dist/esm/128.js +10381 -0
  31. package/dist/esm/261.js +67 -0
  32. package/dist/esm/341.js +30 -0
  33. package/dist/esm/392.js +4453 -0
  34. package/dist/esm/417.js +704 -0
  35. package/dist/esm/521.js +230 -0
  36. package/dist/esm/594.js +67 -0
  37. package/dist/esm/613.js +19042 -0
  38. package/dist/esm/613.js.LICENSE.txt +13 -0
  39. package/dist/esm/951.js +44 -0
  40. package/dist/esm/package.json +3 -0
  41. package/dist/esm/runtime.js +39 -0
  42. package/dist/esm/sandbox/host.js +1 -0
  43. package/dist/esm/sandbox/index.js +183 -0
  44. package/dist/esm/store/claude.js +172 -0
  45. package/dist/esm/store/host.js +46 -0
  46. package/dist/esm/store/index.js +2 -0
  47. package/dist/esm/store/langgraph.js +542 -0
  48. package/dist/esm/store/openai.js +81 -0
  49. package/dist/esm/tools/claude.js +22 -0
  50. package/dist/esm/tools/index.js +1 -0
  51. package/dist/esm/tools/langchain.js +16 -0
  52. package/dist/esm/tools/openai-agents.js +6 -0
  53. package/dist/esm/tools/openai.js +6 -0
  54. package/dist/types/_internal/data-plane/control-plane-request.d.ts +12 -0
  55. package/dist/types/_internal/data-plane/control-plane.d.ts +3 -0
  56. package/dist/types/_internal/data-plane/credential-provider.d.ts +25 -0
  57. package/dist/types/_internal/data-plane/errors.d.ts +19 -0
  58. package/dist/types/_internal/data-plane/index.d.ts +11 -0
  59. package/dist/types/_internal/data-plane/supabase-client.d.ts +12 -0
  60. package/dist/types/_internal/data-plane/token-client.d.ts +23 -0
  61. package/dist/types/sandbox/api-client.d.ts +37 -0
  62. package/dist/types/sandbox/api-types.d.ts +81 -0
  63. package/dist/types/sandbox/binding-repository.d.ts +62 -0
  64. package/dist/types/sandbox/error.d.ts +22 -0
  65. package/dist/types/sandbox/expiry.d.ts +11 -0
  66. package/dist/types/sandbox/host.d.ts +6 -0
  67. package/dist/types/sandbox/iga-sandbox.d.ts +208 -0
  68. package/dist/types/sandbox/index.d.ts +8 -0
  69. package/dist/types/sandbox/public-surface.d.ts +19 -0
  70. package/dist/types/sandbox/runtime-sandbox.d.ts +32 -0
  71. package/dist/types/sandbox/types.d.ts +238 -0
  72. package/dist/types/store/append.d.ts +41 -0
  73. package/dist/types/store/claude-repository.d.ts +36 -0
  74. package/dist/types/store/claude.d.ts +3 -0
  75. package/dist/types/store/control-plane-request.d.ts +2 -0
  76. package/dist/types/store/credential-error.d.ts +2 -0
  77. package/dist/types/store/credential-provider.d.ts +29 -0
  78. package/dist/types/store/errors.d.ts +29 -0
  79. package/dist/types/store/factory.d.ts +31 -0
  80. package/dist/types/store/host.d.ts +5 -0
  81. package/dist/types/store/index.d.ts +6 -0
  82. package/dist/types/store/json.d.ts +7 -0
  83. package/dist/types/store/langgraph-repository.d.ts +98 -0
  84. package/dist/types/store/langgraph.d.ts +43 -0
  85. package/dist/types/store/openai.d.ts +12 -0
  86. package/dist/types/store/pagination.d.ts +27 -0
  87. package/dist/types/store/runtime-data-plane.d.ts +8 -0
  88. package/dist/types/store/runtime-provider.d.ts +1 -0
  89. package/dist/types/store/runtime-store.d.ts +20 -0
  90. package/dist/types/store/store.d.ts +240 -0
  91. package/dist/types/store/supabase-transport.d.ts +43 -0
  92. package/dist/types/store/token-client.d.ts +7 -0
  93. package/dist/types/tools/adapters.d.ts +5 -0
  94. package/dist/types/tools/claude.d.ts +4 -0
  95. package/dist/types/tools/index.d.ts +2 -0
  96. package/dist/types/tools/langchain.d.ts +16 -0
  97. package/dist/types/tools/model-output.d.ts +8 -0
  98. package/dist/types/tools/openai-agents.d.ts +4 -0
  99. package/dist/types/tools/openai.d.ts +5 -0
  100. package/dist/types/tools/registry.d.ts +16 -0
  101. package/dist/types/tools/result.d.ts +17 -0
  102. package/dist/types/tools/sandbox-result-mappers.d.ts +10 -0
  103. package/dist/types/tools/sandbox-tools.d.ts +17 -0
  104. package/dist/types/tools/types.d.ts +307 -0
  105. package/package.json +136 -4
@@ -0,0 +1,581 @@
1
+ "use strict";
2
+ (function() {
3
+ exports.ids = [
4
+ "120"
5
+ ];
6
+ exports.modules = {
7
+ "../store/src/langgraph.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
8
+ __webpack_require__.r(__webpack_exports__);
9
+ __webpack_require__.d(__webpack_exports__, {
10
+ createCheckpointer: ()=>createCheckpointer,
11
+ IgaCheckpointSaver: ()=>IgaCheckpointSaver
12
+ });
13
+ var external_node_crypto_ = __webpack_require__("node:crypto");
14
+ const langgraph_checkpoint_namespaceObject = require("@langchain/langgraph-checkpoint");
15
+ var errors = __webpack_require__("../store/src/errors.ts");
16
+ var runtime_data_plane = __webpack_require__("../store/src/runtime-data-plane.ts");
17
+ const LANGGRAPH_RPC_NAMES = {
18
+ putCheckpoint: "langgraph_put_checkpoint",
19
+ getCheckpoint: "langgraph_get_checkpoint",
20
+ listCheckpoints: "langgraph_list_checkpoints",
21
+ putWrites: "langgraph_put_writes",
22
+ getDeltaHistory: "langgraph_get_delta_history",
23
+ deleteThread: "langgraph_delete_thread"
24
+ };
25
+ function rpcOperation(name, params) {
26
+ return (client)=>client.rpc(name, params);
27
+ }
28
+ class LangGraphCheckpointRepository {
29
+ async putCheckpoint(record) {
30
+ const result = await this.execute({
31
+ operationName: "store.langgraph.putCheckpoint",
32
+ retryOnUnauthorized: true,
33
+ retryOnNetworkError: true,
34
+ operation: rpcOperation(LANGGRAPH_RPC_NAMES.putCheckpoint, {
35
+ p_thread_id: record.threadId,
36
+ p_checkpoint_ns: record.checkpointNamespace,
37
+ p_checkpoint_id: record.checkpointId,
38
+ p_parent_checkpoint_id: record.parentCheckpointId,
39
+ p_checkpoint: record.checkpoint,
40
+ p_metadata: record.metadata,
41
+ p_blobs: record.blobs
42
+ })
43
+ });
44
+ return result.data;
45
+ }
46
+ async getCheckpoint(input) {
47
+ const result = await this.execute({
48
+ operationName: "store.langgraph.getCheckpoint",
49
+ retryOnUnauthorized: true,
50
+ retryOnNetworkError: true,
51
+ operation: rpcOperation(LANGGRAPH_RPC_NAMES.getCheckpoint, {
52
+ p_thread_id: input.threadId,
53
+ p_checkpoint_ns: input.checkpointNamespace,
54
+ p_checkpoint_id: input.checkpointId
55
+ })
56
+ });
57
+ return result.data;
58
+ }
59
+ async listCheckpoints(query) {
60
+ const result = await this.execute({
61
+ operationName: "store.langgraph.listCheckpoints",
62
+ retryOnUnauthorized: true,
63
+ retryOnNetworkError: true,
64
+ operation: rpcOperation(LANGGRAPH_RPC_NAMES.listCheckpoints, {
65
+ p_thread_id: query.threadId,
66
+ p_checkpoint_ns: query.checkpointNamespace,
67
+ p_checkpoint_id: query.checkpointId,
68
+ p_metadata: query.metadata,
69
+ p_before_checkpoint_id: query.beforeCheckpointId,
70
+ p_limit: query.limit,
71
+ p_result_format: "array"
72
+ })
73
+ });
74
+ return result.data;
75
+ }
76
+ async putWrites(record) {
77
+ const result = await this.execute({
78
+ operationName: "store.langgraph.putWrites",
79
+ retryOnUnauthorized: true,
80
+ retryOnNetworkError: true,
81
+ operation: rpcOperation(LANGGRAPH_RPC_NAMES.putWrites, {
82
+ p_thread_id: record.threadId,
83
+ p_checkpoint_ns: record.checkpointNamespace,
84
+ p_checkpoint_id: record.checkpointId,
85
+ p_task_id: record.taskId,
86
+ p_writes: record.writes
87
+ })
88
+ });
89
+ return result.data;
90
+ }
91
+ async getDeltaHistory(input) {
92
+ const result = await this.execute({
93
+ operationName: "store.langgraph.getDeltaHistory",
94
+ retryOnUnauthorized: true,
95
+ retryOnNetworkError: true,
96
+ operation: rpcOperation(LANGGRAPH_RPC_NAMES.getDeltaHistory, {
97
+ p_thread_id: input.threadId,
98
+ p_checkpoint_ns: input.checkpointNamespace,
99
+ p_checkpoint_id: input.checkpointId,
100
+ p_channels: input.channels
101
+ })
102
+ });
103
+ return result.data;
104
+ }
105
+ async deleteThread(threadId) {
106
+ const result = await this.execute({
107
+ operationName: "store.langgraph.deleteThread",
108
+ retryOnUnauthorized: true,
109
+ retryOnNetworkError: true,
110
+ operation: rpcOperation(LANGGRAPH_RPC_NAMES.deleteThread, {
111
+ p_thread_id: threadId
112
+ })
113
+ });
114
+ return result.data;
115
+ }
116
+ constructor(execute = runtime_data_plane.G){
117
+ this.execute = execute;
118
+ }
119
+ }
120
+ const langGraphCheckpointRepository = new LangGraphCheckpointRepository();
121
+ const VERSION_PREFIX_PATTERN = /^(\d+)(?:-|$)/;
122
+ const VERSION_WIDTH = 20;
123
+ function jsonObject(value, field) {
124
+ try {
125
+ return requireRecord(JSON.parse(JSON.stringify(value)));
126
+ } catch {
127
+ invalid(`${field} must serialize to a JSON object`);
128
+ }
129
+ }
130
+ function invalid(message) {
131
+ throw new errors.A("BadRequest", message);
132
+ }
133
+ function internal() {
134
+ throw new errors.A("UnknownError", "Store returned invalid data");
135
+ }
136
+ function requireRecord(value) {
137
+ if (null === value || "object" != typeof value || Array.isArray(value)) internal();
138
+ return value;
139
+ }
140
+ function requireArray(value) {
141
+ if (!Array.isArray(value)) internal();
142
+ return value;
143
+ }
144
+ function requireString(value, allowEmpty = false) {
145
+ if ("string" != typeof value || !allowEmpty && 0 === value.length) internal();
146
+ return value;
147
+ }
148
+ function requireNullableString(value) {
149
+ if (null === value) return null;
150
+ return requireString(value, true);
151
+ }
152
+ function requireConversationId(value) {
153
+ if ("string" != typeof value || 0 === value.length) invalid("configurable.thread_id must be a non-empty conversationId string");
154
+ if (Buffer.byteLength(value, "utf8") > 256) invalid("configurable.thread_id must not exceed 256 UTF-8 bytes");
155
+ return value;
156
+ }
157
+ function optionalConversationId(value) {
158
+ return void 0 === value ? null : requireConversationId(value);
159
+ }
160
+ function requireNamespace(value) {
161
+ if (void 0 === value) return "";
162
+ if ("string" != typeof value) invalid("configurable.checkpoint_ns must be a string");
163
+ return value;
164
+ }
165
+ function optionalNamespace(value) {
166
+ if (null == value) return null;
167
+ if ("string" != typeof value) invalid("configurable.checkpoint_ns must be a string");
168
+ return value;
169
+ }
170
+ function optionalIdentifier(value, field) {
171
+ if (null == value || "" === value) return null;
172
+ if ("string" != typeof value) invalid(`${field} must be a string`);
173
+ return value;
174
+ }
175
+ function stringIdentifier(value, field) {
176
+ if ("string" != typeof value) invalid(`${field} must be a string`);
177
+ return value;
178
+ }
179
+ function normalizeVersions(value, field) {
180
+ if (null === value || "object" != typeof value || Array.isArray(value)) invalid(`${field} must be an object`);
181
+ const normalized = {};
182
+ for (const [key, version] of Object.entries(value)){
183
+ if ("string" != typeof version && "number" != typeof version || "number" == typeof version && !Number.isFinite(version)) invalid(`${field} contains an invalid channel version`);
184
+ Object.defineProperty(normalized, key, {
185
+ value: version,
186
+ enumerable: true,
187
+ writable: true,
188
+ configurable: true
189
+ });
190
+ }
191
+ return normalized;
192
+ }
193
+ function normalizeVersionsSeen(value) {
194
+ if (null === value || "object" != typeof value || Array.isArray(value)) invalid("checkpoint.versions_seen must be an object");
195
+ const normalized = {};
196
+ for (const [node, versions] of Object.entries(value))Object.defineProperty(normalized, node, {
197
+ value: normalizeVersions(versions, `checkpoint.versions_seen.${node}`),
198
+ enumerable: true,
199
+ writable: true,
200
+ configurable: true
201
+ });
202
+ return normalized;
203
+ }
204
+ function toBase64(value) {
205
+ return Buffer.from(value).toString("base64");
206
+ }
207
+ function fromBase64(value) {
208
+ if ("string" != typeof value) internal();
209
+ return Buffer.from(value, "base64");
210
+ }
211
+ function parseBlob(value) {
212
+ const row = requireRecord(value);
213
+ const type = requireString(row.type);
214
+ const blobBase64 = row.blob_base64;
215
+ if ("empty" === type && null !== blobBase64 || "empty" !== type && "string" != typeof blobBase64) internal();
216
+ return {
217
+ channel: requireString(row.channel, true),
218
+ version: requireString(row.version, true),
219
+ type,
220
+ blob_base64: blobBase64
221
+ };
222
+ }
223
+ function parseWrite(value) {
224
+ const row = requireRecord(value);
225
+ if (!Number.isInteger(row.idx)) internal();
226
+ return {
227
+ task_id: requireString(row.task_id, true),
228
+ idx: row.idx,
229
+ channel: requireString(row.channel, true),
230
+ type: requireString(row.type),
231
+ blob_base64: requireString(row.blob_base64, true)
232
+ };
233
+ }
234
+ function parseCheckpointRow(value) {
235
+ const row = requireRecord(value);
236
+ return {
237
+ thread_id: requireString(row.thread_id),
238
+ checkpoint_ns: requireString(row.checkpoint_ns, true),
239
+ checkpoint_id: requireString(row.checkpoint_id, true),
240
+ parent_checkpoint_id: requireNullableString(row.parent_checkpoint_id),
241
+ checkpoint: requireRecord(row.checkpoint),
242
+ metadata: requireRecord(row.metadata),
243
+ blobs: requireArray(row.blobs).map(parseBlob),
244
+ writes: requireArray(row.writes).map(parseWrite),
245
+ pending_sends: requireArray(row.pending_sends ?? []).map(parseWrite)
246
+ };
247
+ }
248
+ function parseDeltaHistory(value) {
249
+ return requireArray(value).map((item)=>{
250
+ const row = requireRecord(item);
251
+ if (!Number.isInteger(row.depth) || row.depth < 1) internal();
252
+ return {
253
+ depth: row.depth,
254
+ checkpoint_id: requireString(row.checkpoint_id, true),
255
+ parent_checkpoint_id: requireNullableString(row.parent_checkpoint_id),
256
+ blobs: requireArray(row.blobs).map(parseBlob),
257
+ writes: requireArray(row.writes).map(parseWrite)
258
+ };
259
+ });
260
+ }
261
+ function outputConfig(threadId, checkpointNamespace, checkpointId) {
262
+ return {
263
+ configurable: {
264
+ thread_id: threadId,
265
+ checkpoint_ns: checkpointNamespace,
266
+ checkpoint_id: checkpointId
267
+ }
268
+ };
269
+ }
270
+ class IgaCheckpointSaver extends langgraph_checkpoint_namespaceObject.BaseCheckpointSaver {
271
+ async get(config) {
272
+ return (await this.getTuple(config))?.checkpoint;
273
+ }
274
+ async getTuple(config) {
275
+ const configurable = config.configurable ?? {};
276
+ if (void 0 === configurable.thread_id) return;
277
+ const threadId = requireConversationId(configurable.thread_id);
278
+ if (null === configurable.checkpoint_ns) return;
279
+ const checkpointNamespace = requireNamespace(configurable.checkpoint_ns);
280
+ const checkpointId = optionalIdentifier(configurable.checkpoint_id, "configurable.checkpoint_id");
281
+ const raw = await langGraphCheckpointRepository.getCheckpoint({
282
+ threadId,
283
+ checkpointNamespace,
284
+ checkpointId
285
+ });
286
+ if (null === raw) return;
287
+ return this.materializeTuple(parseCheckpointRow(raw), "getTuple");
288
+ }
289
+ async *list(config, options = {}) {
290
+ const configurable = config?.configurable ?? {};
291
+ const threadId = optionalConversationId(configurable.thread_id);
292
+ const checkpointNamespace = optionalNamespace(configurable.checkpoint_ns);
293
+ const checkpointId = optionalIdentifier(configurable.checkpoint_id, "configurable.checkpoint_id");
294
+ const beforeId = options.before?.configurable?.checkpoint_id;
295
+ if (null === beforeId) return;
296
+ const beforeCheckpointId = void 0 === beforeId ? null : stringIdentifier(beforeId, "before.configurable.checkpoint_id");
297
+ const limit = void 0 === options.limit ? null : Number.parseInt(String(options.limit), 10);
298
+ if (null !== limit && (!Number.isSafeInteger(limit) || limit < 0)) invalid("list limit must be a non-negative integer");
299
+ if (0 === limit) return;
300
+ const metadata = null == options.filter ? null : jsonObject(options.filter, "checkpoint metadata filter");
301
+ const raw = await langGraphCheckpointRepository.listCheckpoints({
302
+ threadId,
303
+ checkpointNamespace,
304
+ checkpointId,
305
+ metadata,
306
+ beforeCheckpointId,
307
+ limit
308
+ });
309
+ for (const row of requireArray(raw))yield await this.materializeTuple(parseCheckpointRow(row), "list");
310
+ }
311
+ async put(config, checkpoint, metadata, newVersions) {
312
+ const configurable = config.configurable ?? {};
313
+ const threadId = requireConversationId(configurable.thread_id);
314
+ const checkpointNamespace = requireNamespace(configurable.checkpoint_ns);
315
+ const checkpointId = stringIdentifier(checkpoint.id, "checkpoint.id");
316
+ const parentCheckpointId = null == configurable.checkpoint_id ? null : stringIdentifier(configurable.checkpoint_id, "configurable.checkpoint_id");
317
+ if ("number" != typeof checkpoint.v || !Number.isFinite(checkpoint.v)) invalid("checkpoint.v must be a finite number");
318
+ if ("string" != typeof checkpoint.ts) invalid("checkpoint.ts must be a string");
319
+ const channelVersions = normalizeVersions(checkpoint.channel_versions, "checkpoint.channel_versions");
320
+ const versionsSeen = normalizeVersionsSeen(checkpoint.versions_seen);
321
+ const { channel_values: _values, ...checkpointFields } = checkpoint;
322
+ const header = jsonObject({
323
+ ...checkpointFields,
324
+ channel_versions: channelVersions,
325
+ versions_seen: versionsSeen
326
+ }, "checkpoint");
327
+ const normalizedNewVersions = normalizeVersions(newVersions, "newVersions");
328
+ const channelValues = checkpoint.channel_values ?? {};
329
+ const blobs = await Promise.all(Object.entries(normalizedNewVersions).map(async ([channel, version])=>{
330
+ if (!(channel in channelValues)) return {
331
+ channel,
332
+ version: String(version),
333
+ type: "empty",
334
+ blob_base64: null
335
+ };
336
+ const [type, bytes] = await this.dumpValue(channelValues[channel], "put");
337
+ return {
338
+ channel,
339
+ version: String(version),
340
+ type,
341
+ blob_base64: toBase64(bytes)
342
+ };
343
+ }));
344
+ await langGraphCheckpointRepository.putCheckpoint({
345
+ threadId,
346
+ checkpointNamespace,
347
+ checkpointId,
348
+ parentCheckpointId,
349
+ checkpoint: header,
350
+ metadata: await this.dumpMetadata(metadata),
351
+ blobs
352
+ });
353
+ return outputConfig(threadId, checkpointNamespace, checkpointId);
354
+ }
355
+ async putWrites(config, writes, taskId) {
356
+ const configurable = config.configurable ?? {};
357
+ const threadId = requireConversationId(configurable.thread_id);
358
+ const checkpointNamespace = requireNamespace(configurable.checkpoint_ns);
359
+ const checkpointId = stringIdentifier(configurable.checkpoint_id, "configurable.checkpoint_id");
360
+ stringIdentifier(taskId, "taskId");
361
+ const materialized = await Promise.all(writes.map(async ([channel, value], index)=>{
362
+ if ("string" != typeof channel) invalid("pending write channel must be a string");
363
+ const [type, bytes] = await this.dumpValue(value, "putWrites");
364
+ return {
365
+ idx: langgraph_checkpoint_namespaceObject.WRITES_IDX_MAP[channel] ?? index,
366
+ channel,
367
+ type,
368
+ blob_base64: toBase64(bytes)
369
+ };
370
+ }));
371
+ await langGraphCheckpointRepository.putWrites({
372
+ threadId,
373
+ checkpointNamespace,
374
+ checkpointId,
375
+ taskId,
376
+ writes: materialized
377
+ });
378
+ }
379
+ async deleteThread(threadId) {
380
+ await langGraphCheckpointRepository.deleteThread(requireConversationId(threadId));
381
+ }
382
+ async getDeltaChannelHistory(options) {
383
+ if (0 === options.channels.length) return {};
384
+ if (options.channels.includes(langgraph_checkpoint_namespaceObject.TASKS)) return super.getDeltaChannelHistory(options);
385
+ const configurable = options.config.configurable ?? {};
386
+ if (void 0 === configurable.thread_id) return Object.fromEntries(options.channels.map((channel)=>[
387
+ channel,
388
+ {
389
+ writes: []
390
+ }
391
+ ]));
392
+ const threadId = requireConversationId(configurable.thread_id);
393
+ if (null === configurable.checkpoint_ns) return Object.fromEntries(options.channels.map((channel)=>[
394
+ channel,
395
+ {
396
+ writes: []
397
+ }
398
+ ]));
399
+ const checkpointNamespace = requireNamespace(configurable.checkpoint_ns);
400
+ const checkpointId = optionalIdentifier(configurable.checkpoint_id, "configurable.checkpoint_id");
401
+ const channels = [
402
+ ...new Set(options.channels)
403
+ ];
404
+ if (channels.some((channel)=>"string" != typeof channel)) invalid("delta-history channels must be strings");
405
+ const chain = parseDeltaHistory(await langGraphCheckpointRepository.getDeltaHistory({
406
+ threadId,
407
+ checkpointNamespace,
408
+ checkpointId,
409
+ channels
410
+ }));
411
+ const collected = new Map(channels.map((channel)=>[
412
+ channel,
413
+ []
414
+ ]));
415
+ const seeds = new Map();
416
+ const remaining = new Set(channels);
417
+ for (const ancestor of chain){
418
+ if (0 === remaining.size) break;
419
+ const writesByChannel = new Map();
420
+ for (const write of ancestor.writes){
421
+ if (!remaining.has(write.channel)) continue;
422
+ const block = writesByChannel.get(write.channel) ?? [];
423
+ block.push([
424
+ write.task_id,
425
+ write.channel,
426
+ await this.loadValue(write.type, write.blob_base64, "getDeltaChannelHistory")
427
+ ]);
428
+ writesByChannel.set(write.channel, block);
429
+ }
430
+ for (const [channel, block] of writesByChannel){
431
+ block.sort((a, b)=>a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
432
+ collected.get(channel)?.push(block);
433
+ }
434
+ for (const blob of ancestor.blobs)if (remaining.has(blob.channel) && "empty" !== blob.type) {
435
+ seeds.set(blob.channel, await this.loadValue(blob.type, blob.blob_base64, "getDeltaChannelHistory"));
436
+ remaining.delete(blob.channel);
437
+ }
438
+ }
439
+ const result = {};
440
+ for (const channel of channels){
441
+ const history = {
442
+ writes: (collected.get(channel) ?? []).reverse().flat()
443
+ };
444
+ if (seeds.has(channel)) history.seed = seeds.get(channel);
445
+ result[channel] = history;
446
+ }
447
+ return result;
448
+ }
449
+ getNextVersion(current) {
450
+ if ("number" == typeof current) {
451
+ if (!Number.isFinite(current) || current + 1 <= current) invalid("current channel version is invalid");
452
+ return current + 1;
453
+ }
454
+ let next = 1n;
455
+ if (void 0 !== current) {
456
+ const match = VERSION_PREFIX_PATTERN.exec(current);
457
+ if (!match) invalid("current channel version is invalid");
458
+ next = BigInt(match[1]) + 1n;
459
+ }
460
+ return `${next.toString().padStart(VERSION_WIDTH, "0")}-${(0, external_node_crypto_.randomUUID)()}`;
461
+ }
462
+ async dumpMetadata(metadata) {
463
+ const [, bytes] = await this.dumpValue(metadata, "put");
464
+ try {
465
+ return requireRecord(JSON.parse(new TextDecoder().decode(bytes).replace(/\0/g, "")));
466
+ } catch {
467
+ throw new errors.A("BadRequest", "Checkpoint metadata could not be serialized");
468
+ }
469
+ }
470
+ async loadMetadata(metadata, operation) {
471
+ try {
472
+ const [type, bytes] = await this.serde.dumpsTyped(metadata);
473
+ return await this.serde.loadsTyped(type, bytes);
474
+ } catch {
475
+ throw new errors.A("UnknownError", "Stored checkpoint metadata could not be deserialized");
476
+ }
477
+ }
478
+ async dumpValue(value, operation) {
479
+ try {
480
+ const [type, bytes] = await this.serde.dumpsTyped(value);
481
+ if (!type || "string" != typeof type || !(bytes instanceof Uint8Array)) throw new Error("Invalid serializer result");
482
+ return [
483
+ type,
484
+ bytes
485
+ ];
486
+ } catch {
487
+ throw new errors.A("BadRequest", "Checkpoint value could not be serialized");
488
+ }
489
+ }
490
+ async loadValue(type, value, operation) {
491
+ try {
492
+ if ("string" != typeof value || !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(value.replace(/\s/g, ""))) throw new Error("Invalid encoded checkpoint value");
493
+ return await this.serde.loadsTyped(type, fromBase64(value));
494
+ } catch {
495
+ throw new errors.A("UnknownError", "Stored checkpoint value could not be deserialized");
496
+ }
497
+ }
498
+ async materializeTuple(row, operation) {
499
+ const checkpointHeader = requireRecord(row.checkpoint);
500
+ if ("number" != typeof checkpointHeader.v || checkpointHeader.id !== row.checkpoint_id || "string" != typeof checkpointHeader.ts) internal();
501
+ const channelVersions = {
502
+ ...requireRecord(checkpointHeader.channel_versions)
503
+ };
504
+ const versionsSeen = requireRecord(checkpointHeader.versions_seen);
505
+ const channelValues = {};
506
+ for (const blob of row.blobs)if ("empty" !== blob.type) Object.defineProperty(channelValues, blob.channel, {
507
+ value: await this.loadValue(blob.type, blob.blob_base64, operation),
508
+ enumerable: true,
509
+ writable: true,
510
+ configurable: true
511
+ });
512
+ if (checkpointHeader.v < 4 && null !== row.parent_checkpoint_id && row.pending_sends?.length) {
513
+ const sends = await Promise.all(row.pending_sends.map((write)=>this.loadValue(write.type, write.blob_base64, operation)));
514
+ try {
515
+ const [type, bytes] = await this.serde.dumpsTyped(sends);
516
+ channelValues[langgraph_checkpoint_namespaceObject.TASKS] = await this.serde.loadsTyped(type, bytes);
517
+ } catch {
518
+ throw new errors.A("UnknownError", "Stored checkpoint sends could not be deserialized");
519
+ }
520
+ const versions = Object.values(channelVersions);
521
+ channelVersions[langgraph_checkpoint_namespaceObject.TASKS] = versions.length ? (0, langgraph_checkpoint_namespaceObject.maxChannelVersion)(...versions) : this.getNextVersion(void 0);
522
+ }
523
+ const pendingWrites = [];
524
+ for (const write of row.writes)pendingWrites.push([
525
+ write.task_id,
526
+ write.channel,
527
+ await this.loadValue(write.type, write.blob_base64, operation)
528
+ ]);
529
+ const tuple = {
530
+ config: outputConfig(row.thread_id, row.checkpoint_ns, row.checkpoint_id),
531
+ checkpoint: {
532
+ ...checkpointHeader,
533
+ v: checkpointHeader.v,
534
+ id: row.checkpoint_id,
535
+ ts: checkpointHeader.ts,
536
+ channel_values: channelValues,
537
+ channel_versions: channelVersions,
538
+ versions_seen: versionsSeen
539
+ },
540
+ metadata: await this.loadMetadata(row.metadata, operation),
541
+ pendingWrites,
542
+ parentConfig: void 0
543
+ };
544
+ if (row.parent_checkpoint_id) tuple.parentConfig = outputConfig(row.thread_id, row.checkpoint_ns, row.parent_checkpoint_id);
545
+ return tuple;
546
+ }
547
+ constructor(serde){
548
+ super(serde);
549
+ }
550
+ }
551
+ function createCheckpointer(serde) {
552
+ return new IgaCheckpointSaver(serde);
553
+ }
554
+ },
555
+ "node:crypto" (module) {
556
+ module.exports = require("node:crypto");
557
+ }
558
+ };
559
+ var __webpack_require__ = require("../runtime.js");
560
+ __webpack_require__.C(exports);
561
+ var __webpack_exec__ = function(moduleId) {
562
+ return __webpack_require__(__webpack_require__.s = moduleId);
563
+ };
564
+ var __webpack_exports__ = __webpack_require__.X(0, [
565
+ "504",
566
+ "808",
567
+ "82",
568
+ "951"
569
+ ], function() {
570
+ return __webpack_exec__("../store/src/langgraph.ts");
571
+ });
572
+ exports.IgaCheckpointSaver = __webpack_exports__.IgaCheckpointSaver;
573
+ exports.createCheckpointer = __webpack_exports__.createCheckpointer;
574
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
575
+ "IgaCheckpointSaver",
576
+ "createCheckpointer"
577
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
578
+ Object.defineProperty(exports, '__esModule', {
579
+ value: true
580
+ });
581
+ })();