@langchain/langgraph-sdk 0.1.2 → 0.1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @langchain/langgraph-sdk
2
2
 
3
+ ## 0.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - ba7682f: Add TTL support to ThreadsClient in TypeScript to match Python SDK:
8
+
9
+ - `threads.create({ ttl })` now accepts either a number (minutes) or an object `{ ttl: number, strategy?: "delete" }`.
10
+ - `threads.update(threadId, { ttl })` accepts the same forms.
11
+
12
+ Numeric TTL values are normalized to `{ ttl, strategy: "delete" }` in the request payload.
13
+
3
14
  ## 0.1.2
4
15
 
5
16
  ### Patch Changes
package/dist/client.cjs CHANGED
@@ -500,6 +500,10 @@ class ThreadsClient extends BaseClient {
500
500
  * @returns The created thread.
501
501
  */
502
502
  async create(payload) {
503
+ // Normalize ttl to an object if a number is provided
504
+ const ttlPayload = typeof payload?.ttl === "number"
505
+ ? { ttl: payload.ttl, strategy: "delete" }
506
+ : payload?.ttl;
503
507
  return this.fetch(`/threads`, {
504
508
  method: "POST",
505
509
  json: {
@@ -516,6 +520,7 @@ class ThreadsClient extends BaseClient {
516
520
  as_node: u.asNode,
517
521
  })),
518
522
  })),
523
+ ttl: ttlPayload,
519
524
  },
520
525
  });
521
526
  }
@@ -537,9 +542,12 @@ class ThreadsClient extends BaseClient {
537
542
  * @returns The updated thread.
538
543
  */
539
544
  async update(threadId, payload) {
545
+ const ttlPayload = typeof payload?.ttl === "number"
546
+ ? { ttl: payload.ttl, strategy: "delete" }
547
+ : payload?.ttl;
540
548
  return this.fetch(`/threads/${threadId}`, {
541
549
  method: "PATCH",
542
- json: { metadata: payload?.metadata },
550
+ json: { metadata: payload?.metadata, ttl: ttlPayload },
543
551
  });
544
552
  }
545
553
  /**
package/dist/client.d.ts CHANGED
@@ -260,6 +260,15 @@ export declare class ThreadsClient<TStateType = DefaultValues, TUpdateType = TSt
260
260
  asNode: string;
261
261
  }>;
262
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
+ };
263
272
  }): Promise<Thread<TStateType>>;
264
273
  /**
265
274
  * Copy an existing thread
@@ -279,6 +288,15 @@ export declare class ThreadsClient<TStateType = DefaultValues, TUpdateType = TSt
279
288
  * Metadata for the thread.
280
289
  */
281
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
+ };
282
300
  }): Promise<Thread>;
283
301
  /**
284
302
  * Delete a thread.
package/dist/client.js CHANGED
@@ -493,6 +493,10 @@ export class ThreadsClient extends BaseClient {
493
493
  * @returns The created thread.
494
494
  */
495
495
  async create(payload) {
496
+ // Normalize ttl to an object if a number is provided
497
+ const ttlPayload = typeof payload?.ttl === "number"
498
+ ? { ttl: payload.ttl, strategy: "delete" }
499
+ : payload?.ttl;
496
500
  return this.fetch(`/threads`, {
497
501
  method: "POST",
498
502
  json: {
@@ -509,6 +513,7 @@ export class ThreadsClient extends BaseClient {
509
513
  as_node: u.asNode,
510
514
  })),
511
515
  })),
516
+ ttl: ttlPayload,
512
517
  },
513
518
  });
514
519
  }
@@ -530,9 +535,12 @@ export class ThreadsClient extends BaseClient {
530
535
  * @returns The updated thread.
531
536
  */
532
537
  async update(threadId, payload) {
538
+ const ttlPayload = typeof payload?.ttl === "number"
539
+ ? { ttl: payload.ttl, strategy: "delete" }
540
+ : payload?.ttl;
533
541
  return this.fetch(`/threads/${threadId}`, {
534
542
  method: "PATCH",
535
- json: { metadata: payload?.metadata },
543
+ json: { metadata: payload?.metadata, ttl: ttlPayload },
536
544
  });
537
545
  }
538
546
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph-sdk",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Client library for interacting with the LangGraph API",
5
5
  "type": "module",
6
6
  "scripts": {