zeitlich 0.2.46 → 0.2.47

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 (83) hide show
  1. package/README.md +64 -6
  2. package/dist/{activities-CyeiqK_f.d.cts → activities-CPwKoUlD.d.cts} +3 -3
  3. package/dist/{activities-Bm4TLTid.d.ts → activities-DlaBxNID.d.ts} +3 -3
  4. package/dist/adapters/thread/anthropic/index.cjs +105 -6
  5. package/dist/adapters/thread/anthropic/index.cjs.map +1 -1
  6. package/dist/adapters/thread/anthropic/index.d.cts +48 -9
  7. package/dist/adapters/thread/anthropic/index.d.ts +48 -9
  8. package/dist/adapters/thread/anthropic/index.js +104 -7
  9. package/dist/adapters/thread/anthropic/index.js.map +1 -1
  10. package/dist/adapters/thread/anthropic/workflow.cjs +38 -22
  11. package/dist/adapters/thread/anthropic/workflow.cjs.map +1 -1
  12. package/dist/adapters/thread/anthropic/workflow.d.cts +5 -4
  13. package/dist/adapters/thread/anthropic/workflow.d.ts +5 -4
  14. package/dist/adapters/thread/anthropic/workflow.js +38 -22
  15. package/dist/adapters/thread/anthropic/workflow.js.map +1 -1
  16. package/dist/adapters/thread/google-genai/index.d.cts +6 -5
  17. package/dist/adapters/thread/google-genai/index.d.ts +6 -5
  18. package/dist/adapters/thread/google-genai/workflow.cjs +38 -22
  19. package/dist/adapters/thread/google-genai/workflow.cjs.map +1 -1
  20. package/dist/adapters/thread/google-genai/workflow.d.cts +7 -5
  21. package/dist/adapters/thread/google-genai/workflow.d.ts +7 -5
  22. package/dist/adapters/thread/google-genai/workflow.js +38 -22
  23. package/dist/adapters/thread/google-genai/workflow.js.map +1 -1
  24. package/dist/adapters/thread/langchain/index.d.cts +6 -5
  25. package/dist/adapters/thread/langchain/index.d.ts +6 -5
  26. package/dist/adapters/thread/langchain/workflow.cjs +38 -22
  27. package/dist/adapters/thread/langchain/workflow.cjs.map +1 -1
  28. package/dist/adapters/thread/langchain/workflow.d.cts +5 -4
  29. package/dist/adapters/thread/langchain/workflow.d.ts +5 -4
  30. package/dist/adapters/thread/langchain/workflow.js +38 -22
  31. package/dist/adapters/thread/langchain/workflow.js.map +1 -1
  32. package/dist/{cold-store-CFHwemBJ.d.ts → cold-store-BDgJpwLI.d.ts} +8 -11
  33. package/dist/{cold-store-BC5L5Z8A.d.cts → cold-store-Z2wvK2cV.d.cts} +8 -11
  34. package/dist/index.cjs +264 -90
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +21 -9
  37. package/dist/index.d.ts +21 -9
  38. package/dist/index.js +265 -93
  39. package/dist/index.js.map +1 -1
  40. package/dist/proxy-CDh3Rsa7.d.cts +40 -0
  41. package/dist/proxy-Du8ggERu.d.ts +40 -0
  42. package/dist/{thread-manager-D33SUmZa.d.cts → thread-manager-BjoYYXgd.d.cts} +2 -2
  43. package/dist/{thread-manager-9tezUcLW.d.cts → thread-manager-D8zKNFZ9.d.cts} +2 -2
  44. package/dist/{thread-manager-B-zy3xrs.d.ts → thread-manager-DtHYws2F.d.ts} +2 -2
  45. package/dist/{thread-manager-DduoSkvJ.d.ts → thread-manager-Dw96FKH1.d.ts} +2 -2
  46. package/dist/{types-oxt8GN97.d.cts → types-BMJrsHo0.d.cts} +1 -1
  47. package/dist/{types-L5bvbF-n.d.ts → types-CtdOquo3.d.ts} +1 -1
  48. package/dist/{types-CnuN9T6t.d.cts → types-DNEl5uxQ.d.cts} +16 -0
  49. package/dist/{types-CwN6_tAL.d.ts → types-qQVZfhoT.d.ts} +16 -0
  50. package/dist/{workflow-DIaIV7L2.d.cts → workflow-BH9ImDGq.d.cts} +17 -2
  51. package/dist/{workflow-B1TOcHbt.d.ts → workflow-Cdw3-RNB.d.ts} +17 -2
  52. package/dist/workflow.cjs +33 -3
  53. package/dist/workflow.cjs.map +1 -1
  54. package/dist/workflow.d.cts +2 -2
  55. package/dist/workflow.d.ts +2 -2
  56. package/dist/workflow.js +33 -4
  57. package/dist/workflow.js.map +1 -1
  58. package/package.json +9 -3
  59. package/src/adapters/thread/anthropic/activities.ts +18 -11
  60. package/src/adapters/thread/anthropic/index.ts +8 -0
  61. package/src/adapters/thread/anthropic/model-invoker.test.ts +110 -0
  62. package/src/adapters/thread/anthropic/model-invoker.ts +26 -5
  63. package/src/adapters/thread/anthropic/prompt-cache.test.ts +134 -0
  64. package/src/adapters/thread/anthropic/prompt-cache.ts +163 -0
  65. package/src/adapters/thread/anthropic/proxy.ts +1 -0
  66. package/src/adapters/thread/google-genai/proxy.ts +1 -0
  67. package/src/adapters/thread/langchain/proxy.ts +1 -0
  68. package/src/index.ts +1 -1
  69. package/src/lib/subagent/define.ts +1 -0
  70. package/src/lib/subagent/handler.ts +11 -2
  71. package/src/lib/subagent/subagent.integration.test.ts +139 -0
  72. package/src/lib/subagent/types.ts +16 -0
  73. package/src/lib/thread/cold-store.test.ts +33 -5
  74. package/src/lib/thread/cold-store.ts +50 -31
  75. package/src/lib/thread/proxy.ts +79 -29
  76. package/src/tools/edit/handler.test.ts +177 -0
  77. package/src/tools/edit/handler.ts +249 -47
  78. package/src/tools/edit/tool.ts +40 -0
  79. package/src/tools/task-create/handler.ts +1 -1
  80. package/src/tools/task-update/handler.ts +1 -1
  81. package/src/workflow.ts +2 -2
  82. package/dist/proxy-BxFyd6cg.d.cts +0 -24
  83. package/dist/proxy-Cskmj4Yx.d.ts +0 -24
@@ -3,33 +3,49 @@
3
3
  var workflow = require('@temporalio/workflow');
4
4
 
5
5
  // src/lib/thread/proxy.ts
6
+ var DEFAULT_OPTIONS = {
7
+ startToCloseTimeout: "10s",
8
+ retry: {
9
+ maximumAttempts: 6,
10
+ initialInterval: "5s",
11
+ maximumInterval: "15m",
12
+ backoffCoefficient: 4
13
+ }
14
+ };
15
+ var BUILTIN_PER_OP = {
16
+ hydrateThread: { startToCloseTimeout: "60s", heartbeatTimeout: "15s" },
17
+ flushThread: { startToCloseTimeout: "60s", heartbeatTimeout: "15s" }
18
+ };
19
+ function isProxyOptionsShape(o) {
20
+ return "defaults" in o || "perOp" in o;
21
+ }
6
22
  function createThreadOpsProxy(adapterPrefix, scope, options) {
7
23
  const resolvedScope = scope ?? workflow.workflowInfo().workflowType;
8
- const acts = workflow.proxyActivities(
9
- options ?? {
10
- startToCloseTimeout: "10s",
11
- retry: {
12
- maximumAttempts: 6,
13
- initialInterval: "5s",
14
- maximumInterval: "15m",
15
- backoffCoefficient: 4
16
- }
17
- }
18
- );
24
+ const opts = options && isProxyOptionsShape(options) ? options : { defaults: options };
25
+ const base = opts.defaults ?? DEFAULT_OPTIONS;
26
+ const baseActs = workflow.proxyActivities(base);
19
27
  const prefix = `${adapterPrefix}${resolvedScope.charAt(0).toUpperCase()}${resolvedScope.slice(1)}`;
20
28
  const p = (key) => `${prefix}${key.charAt(0).toUpperCase()}${key.slice(1)}`;
29
+ const pick = (op) => {
30
+ const overlay = { ...BUILTIN_PER_OP[op], ...opts.perOp?.[op] };
31
+ if (Object.keys(overlay).length === 0) return baseActs[p(op)];
32
+ return workflow.proxyActivities({
33
+ ...base,
34
+ ...overlay
35
+ })[p(op)];
36
+ };
21
37
  return {
22
- initializeThread: acts[p("initializeThread")],
23
- appendHumanMessage: acts[p("appendHumanMessage")],
24
- appendToolResult: acts[p("appendToolResult")],
25
- appendAgentMessage: acts[p("appendAgentMessage")],
26
- appendSystemMessage: acts[p("appendSystemMessage")],
27
- forkThread: acts[p("forkThread")],
28
- truncateThread: acts[p("truncateThread")],
29
- loadThreadState: acts[p("loadThreadState")],
30
- saveThreadState: acts[p("saveThreadState")],
31
- hydrateThread: acts[p("hydrateThread")],
32
- flushThread: acts[p("flushThread")]
38
+ initializeThread: pick("initializeThread"),
39
+ appendHumanMessage: pick("appendHumanMessage"),
40
+ appendToolResult: pick("appendToolResult"),
41
+ appendAgentMessage: pick("appendAgentMessage"),
42
+ appendSystemMessage: pick("appendSystemMessage"),
43
+ forkThread: pick("forkThread"),
44
+ truncateThread: pick("truncateThread"),
45
+ loadThreadState: pick("loadThreadState"),
46
+ saveThreadState: pick("saveThreadState"),
47
+ hydrateThread: pick("hydrateThread"),
48
+ flushThread: pick("flushThread")
33
49
  };
34
50
  }
35
51
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/thread/proxy.ts","../../../../src/adapters/thread/langchain/adapter-id.ts","../../../../src/adapters/thread/langchain/proxy.ts"],"names":["workflowInfo","proxyActivities"],"mappings":";;;;;AAwBO,SAAS,oBAAA,CACd,aAAA,EACA,KAAA,EACA,OAAA,EACiC;AACjC,EAAA,MAAM,aAAA,GAAgB,KAAA,IAASA,qBAAA,EAAa,CAAE,YAAA;AAG9C,EAAA,MAAM,IAAA,GAAOC,wBAAA;AAAA,IACX,OAAA,IAAW;AAAA,MACT,mBAAA,EAAqB,KAAA;AAAA,MACrB,KAAA,EAAO;AAAA,QACL,eAAA,EAAiB,CAAA;AAAA,QACjB,eAAA,EAAiB,IAAA;AAAA,QACjB,eAAA,EAAiB,KAAA;AAAA,QACjB,kBAAA,EAAoB;AAAA;AACtB;AACF,GACF;AAEA,EAAA,MAAM,MAAA,GAAS,CAAA,EAAG,aAAa,CAAA,EAAG,cAAc,MAAA,CAAO,CAAC,CAAA,CAAE,WAAA,EAAa,CAAA,EAAG,aAAA,CAAc,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA;AAChG,EAAA,MAAM,IAAI,CAAC,GAAA,KACT,CAAA,EAAG,MAAM,GAAG,GAAA,CAAI,MAAA,CAAO,CAAC,CAAA,CAAE,aAAa,CAAA,EAAG,GAAA,CAAI,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA;AAExD,EAAA,OAAO;AAAA,IACL,gBAAA,EAAkB,IAAA,CAAK,CAAA,CAAE,kBAAkB,CAAC,CAAA;AAAA,IAC5C,kBAAA,EAAoB,IAAA,CAAK,CAAA,CAAE,oBAAoB,CAAC,CAAA;AAAA,IAChD,gBAAA,EAAkB,IAAA,CAAK,CAAA,CAAE,kBAAkB,CAAC,CAAA;AAAA,IAC5C,kBAAA,EAAoB,IAAA,CAAK,CAAA,CAAE,oBAAoB,CAAC,CAAA;AAAA,IAChD,mBAAA,EAAqB,IAAA,CAAK,CAAA,CAAE,qBAAqB,CAAC,CAAA;AAAA,IAClD,UAAA,EAAY,IAAA,CAAK,CAAA,CAAE,YAAY,CAAC,CAAA;AAAA,IAChC,cAAA,EAAgB,IAAA,CAAK,CAAA,CAAE,gBAAgB,CAAC,CAAA;AAAA,IACxC,eAAA,EAAiB,IAAA,CAAK,CAAA,CAAE,iBAAiB,CAAC,CAAA;AAAA,IAC1C,eAAA,EAAiB,IAAA,CAAK,CAAA,CAAE,iBAAiB,CAAC,CAAA;AAAA,IAC1C,aAAA,EAAe,IAAA,CAAK,CAAA,CAAE,eAAe,CAAC,CAAA;AAAA,IACtC,WAAA,EAAa,IAAA,CAAK,CAAA,CAAE,aAAa,CAAC;AAAA,GACpC;AACF;;;ACjDO,IAAM,UAAA,GAAa;;;ACgBnB,SAAS,uBAAA,CACd,OACA,OAAA,EACmD;AACnD,EAAA,OAAO,oBAAA;AAAA,IACL,UAAA;AAAA,IACA,KAAA;AAAA,IACA;AAAA,GACF;AACF","file":"workflow.cjs","sourcesContent":["/**\n * Shared proxy helper for thread operations.\n *\n * Each adapter re-exports a thin wrapper that supplies its prefix and\n * casts the return type to carry the adapter's native content type.\n */\nimport {\n proxyActivities,\n workflowInfo,\n type ActivityInterfaceFor,\n} from \"@temporalio/workflow\";\nimport type { ThreadOps } from \"../session/types\";\n\n/**\n * Creates a workflow-safe Temporal activity proxy for {@link ThreadOps}.\n *\n * The proxy resolves activity names by combining the adapter prefix with\n * the workflow scope, so each adapter + workflow combination gets its own\n * namespace.\n *\n * @param adapterPrefix - Adapter identifier (e.g. \"anthropic\", \"googleGenAI\", \"langChain\")\n * @param scope - Optional workflow scope override. Defaults to `workflowInfo().workflowType`.\n * @param options - Optional Temporal `proxyActivities` options.\n */\nexport function createThreadOpsProxy(\n adapterPrefix: string,\n scope?: string,\n options?: Parameters<typeof proxyActivities>[0]\n): ActivityInterfaceFor<ThreadOps> {\n const resolvedScope = scope ?? workflowInfo().workflowType;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const acts = proxyActivities<Record<string, (...args: any[]) => any>>(\n options ?? {\n startToCloseTimeout: \"10s\",\n retry: {\n maximumAttempts: 6,\n initialInterval: \"5s\",\n maximumInterval: \"15m\",\n backoffCoefficient: 4,\n },\n }\n );\n\n const prefix = `${adapterPrefix}${resolvedScope.charAt(0).toUpperCase()}${resolvedScope.slice(1)}`;\n const p = (key: string): string =>\n `${prefix}${key.charAt(0).toUpperCase()}${key.slice(1)}`;\n\n return {\n initializeThread: acts[p(\"initializeThread\")],\n appendHumanMessage: acts[p(\"appendHumanMessage\")],\n appendToolResult: acts[p(\"appendToolResult\")],\n appendAgentMessage: acts[p(\"appendAgentMessage\")],\n appendSystemMessage: acts[p(\"appendSystemMessage\")],\n forkThread: acts[p(\"forkThread\")],\n truncateThread: acts[p(\"truncateThread\")],\n loadThreadState: acts[p(\"loadThreadState\")],\n saveThreadState: acts[p(\"saveThreadState\")],\n hydrateThread: acts[p(\"hydrateThread\")],\n flushThread: acts[p(\"flushThread\")],\n } as ActivityInterfaceFor<ThreadOps>;\n}\n","/**\n * Public adapter identity for the LangChain thread adapter.\n *\n * This value is wire format — it appears as the prefix for Temporal\n * activity names (e.g. `langChainCodingAgentInitializeThread`) and must\n * never change, since renaming it would orphan existing persisted\n * threads and break in-flight workflows.\n *\n * Re-exported from `zeitlich/adapters/thread/langchain` so downstream\n * consumers can use the exact same literal the adapter uses internally,\n * typed as the narrow string literal `\"langChain\"`.\n */\nexport const ADAPTER_ID = \"langChain\" as const;\n\n/** Narrow string-literal type for {@link ADAPTER_ID}. */\nexport type AdapterId = typeof ADAPTER_ID;\n","/**\n * Workflow-safe proxy for LangChain thread operations.\n *\n * Import this from `zeitlich/adapters/thread/langchain/workflow`\n * in your Temporal workflow files.\n *\n * By default the scope is derived from `workflowInfo().workflowType`,\n * so activities are automatically namespaced per workflow.\n *\n * @example\n * ```typescript\n * import { proxyLangChainThreadOps } from 'zeitlich/adapters/thread/langchain/workflow';\n *\n * // Auto-scoped to the current workflow name\n * const threadOps = proxyLangChainThreadOps();\n *\n * // Explicit scope override\n * const threadOps = proxyLangChainThreadOps(\"customScope\");\n * ```\n */\nimport { type ActivityInterfaceFor } from \"@temporalio/workflow\";\nimport type { ThreadOps } from \"../../../lib/session/types\";\nimport type { LangChainContent } from \"./thread-manager\";\nimport { createThreadOpsProxy } from \"../../../lib/thread/proxy\";\nimport { ADAPTER_ID } from \"./adapter-id\";\n\nexport { ADAPTER_ID, type AdapterId } from \"./adapter-id\";\n\nexport function proxyLangChainThreadOps(\n scope?: string,\n options?: Parameters<typeof createThreadOpsProxy>[2]\n): ActivityInterfaceFor<ThreadOps<LangChainContent>> {\n return createThreadOpsProxy(\n ADAPTER_ID,\n scope,\n options\n ) as ActivityInterfaceFor<ThreadOps<LangChainContent>>;\n}\n"]}
1
+ {"version":3,"sources":["../../../../src/lib/thread/proxy.ts","../../../../src/adapters/thread/langchain/adapter-id.ts","../../../../src/adapters/thread/langchain/proxy.ts"],"names":["workflowInfo","proxyActivities"],"mappings":";;;;;AAiBA,IAAM,eAAA,GAAmC;AAAA,EACvC,mBAAA,EAAqB,KAAA;AAAA,EACrB,KAAA,EAAO;AAAA,IACL,eAAA,EAAiB,CAAA;AAAA,IACjB,eAAA,EAAiB,IAAA;AAAA,IACjB,eAAA,EAAiB,KAAA;AAAA,IACjB,kBAAA,EAAoB;AAAA;AAExB,CAAA;AASA,IAAM,cAAA,GAA2D;AAAA,EAC/D,aAAA,EAAe,EAAE,mBAAA,EAAqB,KAAA,EAAO,kBAAkB,KAAA,EAAM;AAAA,EACrE,WAAA,EAAa,EAAE,mBAAA,EAAqB,KAAA,EAAO,kBAAkB,KAAA;AAC/D,CAAA;AAsBA,SAAS,oBAAoB,CAAA,EAAuC;AAClE,EAAA,OAAO,UAAA,IAAc,KAAK,OAAA,IAAW,CAAA;AACvC;AASO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AC7C,gBAAA,EAAkB,KAAK,kBAAkB,CAAA;AAAA,IACzC,kBAAA,EAAoB,KAAK,oBAAoB,CAAA;AAAA,IAC7C,mBAAA,EAAqB,KAAK,qBAAqB,CAAA;AAAA,IAC/C,UAAA,EAAY,KAAK,YAAY,CAAA;AAAA,IAC7B,cAAA,EAAgB,KAAK,gBAAgB,CAAA;AAAA,IACrC,eAAA,EAAiB,KAAK,iBAAiB,CAAA;AAAA,IACvC,eAAA,EAAiB,KAAK,iBAAiB,CAAA;AAAA,IACvC,aAAA,EAAe,KAAK,eAAe,CAAA;AAAA,IACnC,WAAA,EAAa,KAAK,aAAa;AAAA,GACjC;AACF;;;ACnGO,IAAM,UAAA,GAAa;;;ACiBnB,SAAS,uBAAA,CACd,OACA,OAAA,EACmD;AACnD,EAAA,OAAO,oBAAA;AAAA,IACL,UAAA;AAAA,IACA,KAAA;AAAA,IACA;AAAA,GACF;AACF","file":"workflow.cjs","sourcesContent":["/**\n * Shared proxy helper for thread operations.\n *\n * Each adapter re-exports a thin wrapper that supplies its prefix and\n * casts the return type to carry the adapter's native content type.\n */\nimport {\n proxyActivities,\n workflowInfo,\n type ActivityInterfaceFor,\n type ActivityOptions,\n} from \"@temporalio/workflow\";\nimport type { ThreadOps } from \"../session/types\";\n\ntype OpName = keyof ThreadOps;\n\n/** Tight `startToCloseTimeout` so a sick Redis surfaces quickly via retry. */\nconst DEFAULT_OPTIONS: ActivityOptions = {\n startToCloseTimeout: \"10s\",\n retry: {\n maximumAttempts: 6,\n initialInterval: \"5s\",\n maximumInterval: \"15m\",\n backoffCoefficient: 4,\n },\n};\n\n/**\n * `heartbeatTimeout` assumes the built-in S3 cold store's progress\n * events (multipart `Upload` + chunked stream read). Stalls trip via\n * heartbeat rather than `startToCloseTimeout`. Custom backends without\n * progress events should override via `perOp`. Harmless on Redis-only\n * deployments — the activities no-op.\n */\nconst BUILTIN_PER_OP: Partial<Record<OpName, ActivityOptions>> = {\n hydrateThread: { startToCloseTimeout: \"60s\", heartbeatTimeout: \"15s\" },\n flushThread: { startToCloseTimeout: \"60s\", heartbeatTimeout: \"15s\" },\n};\n\n/**\n * `perOp[op]` layers shallow-rightmost over `defaults` and the\n * built-in cold-tier overlay (`hydrateThread` / `flushThread`).\n * A bare {@link ActivityOptions} is also accepted (treated as `{ defaults }`).\n *\n * @example\n * ```typescript\n * proxyAnthropicThreadOps(undefined, {\n * defaults: { startToCloseTimeout: \"5s\" },\n * perOp: {\n * flushThread: { startToCloseTimeout: \"180s\" }, // heartbeatTimeout still inherited\n * },\n * });\n * ```\n */\nexport interface ThreadOpsProxyOptions {\n defaults?: ActivityOptions;\n perOp?: Partial<Record<OpName, ActivityOptions>>;\n}\n\nfunction isProxyOptionsShape(o: object): o is ThreadOpsProxyOptions {\n return \"defaults\" in o || \"perOp\" in o;\n}\n\n/**\n * Creates a workflow-safe Temporal activity proxy for {@link ThreadOps}.\n *\n * @param adapterPrefix - Adapter identifier (e.g. \"anthropic\", \"googleGenAI\", \"langChain\")\n * @param scope - Workflow scope. Defaults to `workflowInfo().workflowType`.\n * @param options - {@link ThreadOpsProxyOptions} or a bare {@link ActivityOptions}.\n */\nexport function createThreadOpsProxy(\n adapterPrefix: string,\n scope?: string,\n options?: ActivityOptions | ThreadOpsProxyOptions\n): ActivityInterfaceFor<ThreadOps> {\n const resolvedScope = scope ?? workflowInfo().workflowType;\n\n const opts: ThreadOpsProxyOptions =\n options && isProxyOptionsShape(options) ? options : { defaults: options };\n\n const base = opts.defaults ?? DEFAULT_OPTIONS;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const baseActs = proxyActivities<Record<string, (...args: any[]) => any>>(base);\n\n const prefix = `${adapterPrefix}${resolvedScope.charAt(0).toUpperCase()}${resolvedScope.slice(1)}`;\n const p = (key: string): string =>\n `${prefix}${key.charAt(0).toUpperCase()}${key.slice(1)}`;\n\n const pick = (op: OpName): unknown => {\n const overlay = { ...BUILTIN_PER_OP[op], ...opts.perOp?.[op] };\n if (Object.keys(overlay).length === 0) return baseActs[p(op)];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return proxyActivities<Record<string, (...args: any[]) => any>>({\n ...base,\n ...overlay,\n })[p(op)];\n };\n\n return {\n initializeThread: pick(\"initializeThread\"),\n appendHumanMessage: pick(\"appendHumanMessage\"),\n appendToolResult: pick(\"appendToolResult\"),\n appendAgentMessage: pick(\"appendAgentMessage\"),\n appendSystemMessage: pick(\"appendSystemMessage\"),\n forkThread: pick(\"forkThread\"),\n truncateThread: pick(\"truncateThread\"),\n loadThreadState: pick(\"loadThreadState\"),\n saveThreadState: pick(\"saveThreadState\"),\n hydrateThread: pick(\"hydrateThread\"),\n flushThread: pick(\"flushThread\"),\n } as ActivityInterfaceFor<ThreadOps>;\n}\n","/**\n * Public adapter identity for the LangChain thread adapter.\n *\n * This value is wire format — it appears as the prefix for Temporal\n * activity names (e.g. `langChainCodingAgentInitializeThread`) and must\n * never change, since renaming it would orphan existing persisted\n * threads and break in-flight workflows.\n *\n * Re-exported from `zeitlich/adapters/thread/langchain` so downstream\n * consumers can use the exact same literal the adapter uses internally,\n * typed as the narrow string literal `\"langChain\"`.\n */\nexport const ADAPTER_ID = \"langChain\" as const;\n\n/** Narrow string-literal type for {@link ADAPTER_ID}. */\nexport type AdapterId = typeof ADAPTER_ID;\n","/**\n * Workflow-safe proxy for LangChain thread operations.\n *\n * Import this from `zeitlich/adapters/thread/langchain/workflow`\n * in your Temporal workflow files.\n *\n * By default the scope is derived from `workflowInfo().workflowType`,\n * so activities are automatically namespaced per workflow.\n *\n * @example\n * ```typescript\n * import { proxyLangChainThreadOps } from 'zeitlich/adapters/thread/langchain/workflow';\n *\n * // Auto-scoped to the current workflow name\n * const threadOps = proxyLangChainThreadOps();\n *\n * // Explicit scope override\n * const threadOps = proxyLangChainThreadOps(\"customScope\");\n * ```\n */\nimport { type ActivityInterfaceFor } from \"@temporalio/workflow\";\nimport type { ThreadOps } from \"../../../lib/session/types\";\nimport type { LangChainContent } from \"./thread-manager\";\nimport { createThreadOpsProxy } from \"../../../lib/thread/proxy\";\nimport { ADAPTER_ID } from \"./adapter-id\";\n\nexport { ADAPTER_ID, type AdapterId } from \"./adapter-id\";\nexport type { ThreadOpsProxyOptions } from \"../../../lib/thread/proxy\";\n\nexport function proxyLangChainThreadOps(\n scope?: string,\n options?: Parameters<typeof createThreadOpsProxy>[2]\n): ActivityInterfaceFor<ThreadOps<LangChainContent>> {\n return createThreadOpsProxy(\n ADAPTER_ID,\n scope,\n options\n ) as ActivityInterfaceFor<ThreadOps<LangChainContent>>;\n}\n"]}
@@ -1,7 +1,8 @@
1
1
  import { ActivityInterfaceFor } from '@temporalio/workflow';
2
- import { T as ThreadOps } from '../../../types-CnuN9T6t.cjs';
3
- import { L as LangChainContent } from '../../../thread-manager-D33SUmZa.cjs';
4
- import { c as createThreadOpsProxy } from '../../../proxy-BxFyd6cg.cjs';
2
+ import { T as ThreadOps } from '../../../types-DNEl5uxQ.cjs';
3
+ import { L as LangChainContent } from '../../../thread-manager-BjoYYXgd.cjs';
4
+ import { c as createThreadOpsProxy } from '../../../proxy-CDh3Rsa7.cjs';
5
+ export { T as ThreadOpsProxyOptions } from '../../../proxy-CDh3Rsa7.cjs';
5
6
  export { A as ADAPTER_ID, a as AdapterId } from '../../../adapter-id-CbY2zeSt.cjs';
6
7
  import '@temporalio/common/lib/interfaces';
7
8
  import 'zod';
@@ -9,7 +10,7 @@ import '../../../types-CJ7tCdl6.cjs';
9
10
  import '@temporalio/common';
10
11
  import 'ioredis';
11
12
  import '@langchain/core/messages';
12
- import '../../../types-oxt8GN97.cjs';
13
+ import '../../../types-BMJrsHo0.cjs';
13
14
 
14
15
  /**
15
16
  * Workflow-safe proxy for LangChain thread operations.
@@ -1,7 +1,8 @@
1
1
  import { ActivityInterfaceFor } from '@temporalio/workflow';
2
- import { T as ThreadOps } from '../../../types-CwN6_tAL.js';
3
- import { L as LangChainContent } from '../../../thread-manager-DduoSkvJ.js';
4
- import { c as createThreadOpsProxy } from '../../../proxy-Cskmj4Yx.js';
2
+ import { T as ThreadOps } from '../../../types-qQVZfhoT.js';
3
+ import { L as LangChainContent } from '../../../thread-manager-Dw96FKH1.js';
4
+ import { c as createThreadOpsProxy } from '../../../proxy-Du8ggERu.js';
5
+ export { T as ThreadOpsProxyOptions } from '../../../proxy-Du8ggERu.js';
5
6
  export { A as ADAPTER_ID, a as AdapterId } from '../../../adapter-id-CbY2zeSt.js';
6
7
  import '@temporalio/common/lib/interfaces';
7
8
  import 'zod';
@@ -9,7 +10,7 @@ import '../../../types-CJ7tCdl6.js';
9
10
  import '@temporalio/common';
10
11
  import 'ioredis';
11
12
  import '@langchain/core/messages';
12
- import '../../../types-L5bvbF-n.js';
13
+ import '../../../types-CtdOquo3.js';
13
14
 
14
15
  /**
15
16
  * Workflow-safe proxy for LangChain thread operations.
@@ -1,33 +1,49 @@
1
1
  import { workflowInfo, proxyActivities } from '@temporalio/workflow';
2
2
 
3
3
  // src/lib/thread/proxy.ts
4
+ var DEFAULT_OPTIONS = {
5
+ startToCloseTimeout: "10s",
6
+ retry: {
7
+ maximumAttempts: 6,
8
+ initialInterval: "5s",
9
+ maximumInterval: "15m",
10
+ backoffCoefficient: 4
11
+ }
12
+ };
13
+ var BUILTIN_PER_OP = {
14
+ hydrateThread: { startToCloseTimeout: "60s", heartbeatTimeout: "15s" },
15
+ flushThread: { startToCloseTimeout: "60s", heartbeatTimeout: "15s" }
16
+ };
17
+ function isProxyOptionsShape(o) {
18
+ return "defaults" in o || "perOp" in o;
19
+ }
4
20
  function createThreadOpsProxy(adapterPrefix, scope, options) {
5
21
  const resolvedScope = scope ?? workflowInfo().workflowType;
6
- const acts = proxyActivities(
7
- options ?? {
8
- startToCloseTimeout: "10s",
9
- retry: {
10
- maximumAttempts: 6,
11
- initialInterval: "5s",
12
- maximumInterval: "15m",
13
- backoffCoefficient: 4
14
- }
15
- }
16
- );
22
+ const opts = options && isProxyOptionsShape(options) ? options : { defaults: options };
23
+ const base = opts.defaults ?? DEFAULT_OPTIONS;
24
+ const baseActs = proxyActivities(base);
17
25
  const prefix = `${adapterPrefix}${resolvedScope.charAt(0).toUpperCase()}${resolvedScope.slice(1)}`;
18
26
  const p = (key) => `${prefix}${key.charAt(0).toUpperCase()}${key.slice(1)}`;
27
+ const pick = (op) => {
28
+ const overlay = { ...BUILTIN_PER_OP[op], ...opts.perOp?.[op] };
29
+ if (Object.keys(overlay).length === 0) return baseActs[p(op)];
30
+ return proxyActivities({
31
+ ...base,
32
+ ...overlay
33
+ })[p(op)];
34
+ };
19
35
  return {
20
- initializeThread: acts[p("initializeThread")],
21
- appendHumanMessage: acts[p("appendHumanMessage")],
22
- appendToolResult: acts[p("appendToolResult")],
23
- appendAgentMessage: acts[p("appendAgentMessage")],
24
- appendSystemMessage: acts[p("appendSystemMessage")],
25
- forkThread: acts[p("forkThread")],
26
- truncateThread: acts[p("truncateThread")],
27
- loadThreadState: acts[p("loadThreadState")],
28
- saveThreadState: acts[p("saveThreadState")],
29
- hydrateThread: acts[p("hydrateThread")],
30
- flushThread: acts[p("flushThread")]
36
+ initializeThread: pick("initializeThread"),
37
+ appendHumanMessage: pick("appendHumanMessage"),
38
+ appendToolResult: pick("appendToolResult"),
39
+ appendAgentMessage: pick("appendAgentMessage"),
40
+ appendSystemMessage: pick("appendSystemMessage"),
41
+ forkThread: pick("forkThread"),
42
+ truncateThread: pick("truncateThread"),
43
+ loadThreadState: pick("loadThreadState"),
44
+ saveThreadState: pick("saveThreadState"),
45
+ hydrateThread: pick("hydrateThread"),
46
+ flushThread: pick("flushThread")
31
47
  };
32
48
  }
33
49
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/thread/proxy.ts","../../../../src/adapters/thread/langchain/adapter-id.ts","../../../../src/adapters/thread/langchain/proxy.ts"],"names":[],"mappings":";;;AAwBO,SAAS,oBAAA,CACd,aAAA,EACA,KAAA,EACA,OAAA,EACiC;AACjC,EAAA,MAAM,aAAA,GAAgB,KAAA,IAAS,YAAA,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K,CAAA,CAAE,iBAAiB,CAAC,CAAA;AAAA,IAC1C,aAAA,EAAe,IAAA,CAAK,CAAA,CAAE,eAAe,CAAC,CAAA;AAAA,IACtC,WAAA,EAAa,IAAA,CAAK,CAAA,CAAE,aAAa,CAAC;AAAA,GACpC;AACF;;;ACjDO,IAAM,UAAA,GAAa;;;ACgBnB,SAAS,uBAAA,CACd,OACA,OAAA,EACmD;AACnD,EAAA,OAAO,oBAAA;AAAA,IACL,UAAA;AAAA,IACA,KAAA;AAAA,IACA;AAAA,GACF;AACF","file":"workflow.js","sourcesContent":["/**\n * Shared proxy helper for thread operations.\n *\n * Each adapter re-exports a thin wrapper that supplies its prefix and\n * casts the return type to carry the adapter's native content type.\n */\nimport {\n proxyActivities,\n workflowInfo,\n type ActivityInterfaceFor,\n} from \"@temporalio/workflow\";\nimport type { ThreadOps } from \"../session/types\";\n\n/**\n * Creates a workflow-safe Temporal activity proxy for {@link ThreadOps}.\n *\n * The proxy resolves activity names by combining the adapter prefix with\n * the workflow scope, so each adapter + workflow combination gets its own\n * namespace.\n *\n * @param adapterPrefix - Adapter identifier (e.g. \"anthropic\", \"googleGenAI\", \"langChain\")\n * @param scope - Optional workflow scope override. Defaults to `workflowInfo().workflowType`.\n * @param options - Optional Temporal `proxyActivities` options.\n */\nexport function createThreadOpsProxy(\n adapterPrefix: string,\n scope?: string,\n options?: Parameters<typeof proxyActivities>[0]\n): ActivityInterfaceFor<ThreadOps> {\n const resolvedScope = scope ?? workflowInfo().workflowType;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const acts = proxyActivities<Record<string, (...args: any[]) => any>>(\n options ?? {\n startToCloseTimeout: \"10s\",\n retry: {\n maximumAttempts: 6,\n initialInterval: \"5s\",\n maximumInterval: \"15m\",\n backoffCoefficient: 4,\n },\n }\n );\n\n const prefix = `${adapterPrefix}${resolvedScope.charAt(0).toUpperCase()}${resolvedScope.slice(1)}`;\n const p = (key: string): string =>\n `${prefix}${key.charAt(0).toUpperCase()}${key.slice(1)}`;\n\n return {\n initializeThread: acts[p(\"initializeThread\")],\n appendHumanMessage: acts[p(\"appendHumanMessage\")],\n appendToolResult: acts[p(\"appendToolResult\")],\n appendAgentMessage: acts[p(\"appendAgentMessage\")],\n appendSystemMessage: acts[p(\"appendSystemMessage\")],\n forkThread: acts[p(\"forkThread\")],\n truncateThread: acts[p(\"truncateThread\")],\n loadThreadState: acts[p(\"loadThreadState\")],\n saveThreadState: acts[p(\"saveThreadState\")],\n hydrateThread: acts[p(\"hydrateThread\")],\n flushThread: acts[p(\"flushThread\")],\n } as ActivityInterfaceFor<ThreadOps>;\n}\n","/**\n * Public adapter identity for the LangChain thread adapter.\n *\n * This value is wire format — it appears as the prefix for Temporal\n * activity names (e.g. `langChainCodingAgentInitializeThread`) and must\n * never change, since renaming it would orphan existing persisted\n * threads and break in-flight workflows.\n *\n * Re-exported from `zeitlich/adapters/thread/langchain` so downstream\n * consumers can use the exact same literal the adapter uses internally,\n * typed as the narrow string literal `\"langChain\"`.\n */\nexport const ADAPTER_ID = \"langChain\" as const;\n\n/** Narrow string-literal type for {@link ADAPTER_ID}. */\nexport type AdapterId = typeof ADAPTER_ID;\n","/**\n * Workflow-safe proxy for LangChain thread operations.\n *\n * Import this from `zeitlich/adapters/thread/langchain/workflow`\n * in your Temporal workflow files.\n *\n * By default the scope is derived from `workflowInfo().workflowType`,\n * so activities are automatically namespaced per workflow.\n *\n * @example\n * ```typescript\n * import { proxyLangChainThreadOps } from 'zeitlich/adapters/thread/langchain/workflow';\n *\n * // Auto-scoped to the current workflow name\n * const threadOps = proxyLangChainThreadOps();\n *\n * // Explicit scope override\n * const threadOps = proxyLangChainThreadOps(\"customScope\");\n * ```\n */\nimport { type ActivityInterfaceFor } from \"@temporalio/workflow\";\nimport type { ThreadOps } from \"../../../lib/session/types\";\nimport type { LangChainContent } from \"./thread-manager\";\nimport { createThreadOpsProxy } from \"../../../lib/thread/proxy\";\nimport { ADAPTER_ID } from \"./adapter-id\";\n\nexport { ADAPTER_ID, type AdapterId } from \"./adapter-id\";\n\nexport function proxyLangChainThreadOps(\n scope?: string,\n options?: Parameters<typeof createThreadOpsProxy>[2]\n): ActivityInterfaceFor<ThreadOps<LangChainContent>> {\n return createThreadOpsProxy(\n ADAPTER_ID,\n scope,\n options\n ) as ActivityInterfaceFor<ThreadOps<LangChainContent>>;\n}\n"]}
1
+ {"version":3,"sources":["../../../../src/lib/thread/proxy.ts","../../../../src/adapters/thread/langchain/adapter-id.ts","../../../../src/adapters/thread/langchain/proxy.ts"],"names":[],"mappings":";;;AAiBA,IAAM,eAAA,GAAmC;AAAA,EACvC,mBAAA,EAAqB,KAAA;AAAA,EACrB,KAAA,EAAO;AAAA,IACL,eAAA,EAAiB,CAAA;AAAA,IACjB,eAAA,EAAiB,IAAA;AAAA,IACjB,eAAA,EAAiB,KAAA;AAAA,IACjB,kBAAA,EAAoB;AAAA;AAExB,CAAA;AASA,IAAM,cAAA,GAA2D;AAAA,EAC/D,aAAA,EAAe,EAAE,mBAAA,EAAqB,KAAA,EAAO,kBAAkB,KAAA,EAAM;AAAA,EACrE,WAAA,EAAa,EAAE,mBAAA,EAAqB,KAAA,EAAO,kBAAkB,KAAA;AAC/D,CAAA;AAsBA,SAAS,oBAAoB,CAAA,EAAuC;AAClE,EAAA,OAAO,UAAA,IAAc,KAAK,OAAA,IAAW,CAAA;AACvC;AASO,SAAS,oBAAA,CACd,aAAA,EACA,KAAA,EACA,OAAA,EACiC;AACjC,EAAA,MAAM,aAAA,GAAgB,KAAA,IAAS,YAAA,EAAa,CAAE,YAAA;AAE9C,EAAA,MAAM,IAAA,GACJ,WAAW,mBAAA,CAAoB,OAAO,IAAI,OAAA,GAAU,EAAE,UAAU,OAAA,EAAQ;AAE1E,EAAA,MAAM,IAAA,GAAO,KAAK,QAAA,IAAY,eAAA;AAE9B,EAAA,MAAM,QAAA,GAAW,gBAAyD,IAAI,CAAA;AAE9E,EAAA,MAAM,MAAA,GAAS,CAAA,EAAG,aAAa,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,KAAK,aAAa;AAAA,GACjC;AACF;;;ACnGO,IAAM,UAAA,GAAa;;;ACiBnB,SAAS,uBAAA,CACd,OACA,OAAA,EACmD;AACnD,EAAA,OAAO,oBAAA;AAAA,IACL,UAAA;AAAA,IACA,KAAA;AAAA,IACA;AAAA,GACF;AACF","file":"workflow.js","sourcesContent":["/**\n * Shared proxy helper for thread operations.\n *\n * Each adapter re-exports a thin wrapper that supplies its prefix and\n * casts the return type to carry the adapter's native content type.\n */\nimport {\n proxyActivities,\n workflowInfo,\n type ActivityInterfaceFor,\n type ActivityOptions,\n} from \"@temporalio/workflow\";\nimport type { ThreadOps } from \"../session/types\";\n\ntype OpName = keyof ThreadOps;\n\n/** Tight `startToCloseTimeout` so a sick Redis surfaces quickly via retry. */\nconst DEFAULT_OPTIONS: ActivityOptions = {\n startToCloseTimeout: \"10s\",\n retry: {\n maximumAttempts: 6,\n initialInterval: \"5s\",\n maximumInterval: \"15m\",\n backoffCoefficient: 4,\n },\n};\n\n/**\n * `heartbeatTimeout` assumes the built-in S3 cold store's progress\n * events (multipart `Upload` + chunked stream read). Stalls trip via\n * heartbeat rather than `startToCloseTimeout`. Custom backends without\n * progress events should override via `perOp`. Harmless on Redis-only\n * deployments — the activities no-op.\n */\nconst BUILTIN_PER_OP: Partial<Record<OpName, ActivityOptions>> = {\n hydrateThread: { startToCloseTimeout: \"60s\", heartbeatTimeout: \"15s\" },\n flushThread: { startToCloseTimeout: \"60s\", heartbeatTimeout: \"15s\" },\n};\n\n/**\n * `perOp[op]` layers shallow-rightmost over `defaults` and the\n * built-in cold-tier overlay (`hydrateThread` / `flushThread`).\n * A bare {@link ActivityOptions} is also accepted (treated as `{ defaults }`).\n *\n * @example\n * ```typescript\n * proxyAnthropicThreadOps(undefined, {\n * defaults: { startToCloseTimeout: \"5s\" },\n * perOp: {\n * flushThread: { startToCloseTimeout: \"180s\" }, // heartbeatTimeout still inherited\n * },\n * });\n * ```\n */\nexport interface ThreadOpsProxyOptions {\n defaults?: ActivityOptions;\n perOp?: Partial<Record<OpName, ActivityOptions>>;\n}\n\nfunction isProxyOptionsShape(o: object): o is ThreadOpsProxyOptions {\n return \"defaults\" in o || \"perOp\" in o;\n}\n\n/**\n * Creates a workflow-safe Temporal activity proxy for {@link ThreadOps}.\n *\n * @param adapterPrefix - Adapter identifier (e.g. \"anthropic\", \"googleGenAI\", \"langChain\")\n * @param scope - Workflow scope. Defaults to `workflowInfo().workflowType`.\n * @param options - {@link ThreadOpsProxyOptions} or a bare {@link ActivityOptions}.\n */\nexport function createThreadOpsProxy(\n adapterPrefix: string,\n scope?: string,\n options?: ActivityOptions | ThreadOpsProxyOptions\n): ActivityInterfaceFor<ThreadOps> {\n const resolvedScope = scope ?? workflowInfo().workflowType;\n\n const opts: ThreadOpsProxyOptions =\n options && isProxyOptionsShape(options) ? options : { defaults: options };\n\n const base = opts.defaults ?? DEFAULT_OPTIONS;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const baseActs = proxyActivities<Record<string, (...args: any[]) => any>>(base);\n\n const prefix = `${adapterPrefix}${resolvedScope.charAt(0).toUpperCase()}${resolvedScope.slice(1)}`;\n const p = (key: string): string =>\n `${prefix}${key.charAt(0).toUpperCase()}${key.slice(1)}`;\n\n const pick = (op: OpName): unknown => {\n const overlay = { ...BUILTIN_PER_OP[op], ...opts.perOp?.[op] };\n if (Object.keys(overlay).length === 0) return baseActs[p(op)];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return proxyActivities<Record<string, (...args: any[]) => any>>({\n ...base,\n ...overlay,\n })[p(op)];\n };\n\n return {\n initializeThread: pick(\"initializeThread\"),\n appendHumanMessage: pick(\"appendHumanMessage\"),\n appendToolResult: pick(\"appendToolResult\"),\n appendAgentMessage: pick(\"appendAgentMessage\"),\n appendSystemMessage: pick(\"appendSystemMessage\"),\n forkThread: pick(\"forkThread\"),\n truncateThread: pick(\"truncateThread\"),\n loadThreadState: pick(\"loadThreadState\"),\n saveThreadState: pick(\"saveThreadState\"),\n hydrateThread: pick(\"hydrateThread\"),\n flushThread: pick(\"flushThread\"),\n } as ActivityInterfaceFor<ThreadOps>;\n}\n","/**\n * Public adapter identity for the LangChain thread adapter.\n *\n * This value is wire format — it appears as the prefix for Temporal\n * activity names (e.g. `langChainCodingAgentInitializeThread`) and must\n * never change, since renaming it would orphan existing persisted\n * threads and break in-flight workflows.\n *\n * Re-exported from `zeitlich/adapters/thread/langchain` so downstream\n * consumers can use the exact same literal the adapter uses internally,\n * typed as the narrow string literal `\"langChain\"`.\n */\nexport const ADAPTER_ID = \"langChain\" as const;\n\n/** Narrow string-literal type for {@link ADAPTER_ID}. */\nexport type AdapterId = typeof ADAPTER_ID;\n","/**\n * Workflow-safe proxy for LangChain thread operations.\n *\n * Import this from `zeitlich/adapters/thread/langchain/workflow`\n * in your Temporal workflow files.\n *\n * By default the scope is derived from `workflowInfo().workflowType`,\n * so activities are automatically namespaced per workflow.\n *\n * @example\n * ```typescript\n * import { proxyLangChainThreadOps } from 'zeitlich/adapters/thread/langchain/workflow';\n *\n * // Auto-scoped to the current workflow name\n * const threadOps = proxyLangChainThreadOps();\n *\n * // Explicit scope override\n * const threadOps = proxyLangChainThreadOps(\"customScope\");\n * ```\n */\nimport { type ActivityInterfaceFor } from \"@temporalio/workflow\";\nimport type { ThreadOps } from \"../../../lib/session/types\";\nimport type { LangChainContent } from \"./thread-manager\";\nimport { createThreadOpsProxy } from \"../../../lib/thread/proxy\";\nimport { ADAPTER_ID } from \"./adapter-id\";\n\nexport { ADAPTER_ID, type AdapterId } from \"./adapter-id\";\nexport type { ThreadOpsProxyOptions } from \"../../../lib/thread/proxy\";\n\nexport function proxyLangChainThreadOps(\n scope?: string,\n options?: Parameters<typeof createThreadOpsProxy>[2]\n): ActivityInterfaceFor<ThreadOps<LangChainContent>> {\n return createThreadOpsProxy(\n ADAPTER_ID,\n scope,\n options\n ) as ActivityInterfaceFor<ThreadOps<LangChainContent>>;\n}\n"]}
@@ -1,4 +1,5 @@
1
- import { P as PersistedThreadState } from './types-CwN6_tAL.js';
1
+ import { P as PersistedThreadState } from './types-qQVZfhoT.js';
2
+ import { S3Client } from '@aws-sdk/client-s3';
2
3
 
3
4
  /**
4
5
  * Pluggable cold-tier interface for thread archives.
@@ -58,19 +59,15 @@ interface ColdThreadStore {
58
59
  delete(threadKey: string, threadId: string): Promise<void>;
59
60
  }
60
61
  /**
61
- * Compact, duck-typed shape of an S3 client. Zeitlich only needs the
62
- * `send(...)` method; declaring this locally avoids forcing
63
- * `@aws-sdk/client-s3` to be installed when the consumer is using a
64
- * different cold-store backend.
62
+ * Alias for `@aws-sdk/client-s3`'s `S3Client`. The built-in store
63
+ * calls `send(...)` and accesses `client.config` (read by
64
+ * `@aws-sdk/lib-storage`'s `Upload`) a duck-type with just `send`
65
+ * is not sufficient.
65
66
  */
66
- interface S3LikeClient {
67
- send<TInput, TOutput>(command: {
68
- input: TInput;
69
- } & object): Promise<TOutput>;
70
- }
67
+ type S3LikeClient = S3Client;
71
68
  /** Configuration for the built-in S3 cold store. */
72
69
  interface S3ColdStoreConfig {
73
- /** An `@aws-sdk/client-s3` `S3Client` (or duck-typed equivalent). */
70
+ /** An `@aws-sdk/client-s3` `S3Client`. */
74
71
  s3: S3LikeClient;
75
72
  /** S3 bucket that holds the archive. */
76
73
  bucket: string;
@@ -1,4 +1,5 @@
1
- import { P as PersistedThreadState } from './types-CnuN9T6t.cjs';
1
+ import { P as PersistedThreadState } from './types-DNEl5uxQ.cjs';
2
+ import { S3Client } from '@aws-sdk/client-s3';
2
3
 
3
4
  /**
4
5
  * Pluggable cold-tier interface for thread archives.
@@ -58,19 +59,15 @@ interface ColdThreadStore {
58
59
  delete(threadKey: string, threadId: string): Promise<void>;
59
60
  }
60
61
  /**
61
- * Compact, duck-typed shape of an S3 client. Zeitlich only needs the
62
- * `send(...)` method; declaring this locally avoids forcing
63
- * `@aws-sdk/client-s3` to be installed when the consumer is using a
64
- * different cold-store backend.
62
+ * Alias for `@aws-sdk/client-s3`'s `S3Client`. The built-in store
63
+ * calls `send(...)` and accesses `client.config` (read by
64
+ * `@aws-sdk/lib-storage`'s `Upload`) a duck-type with just `send`
65
+ * is not sufficient.
65
66
  */
66
- interface S3LikeClient {
67
- send<TInput, TOutput>(command: {
68
- input: TInput;
69
- } & object): Promise<TOutput>;
70
- }
67
+ type S3LikeClient = S3Client;
71
68
  /** Configuration for the built-in S3 cold store. */
72
69
  interface S3ColdStoreConfig {
73
- /** An `@aws-sdk/client-s3` `S3Client` (or duck-typed equivalent). */
70
+ /** An `@aws-sdk/client-s3` `S3Client`. */
74
71
  s3: S3LikeClient;
75
72
  /** S3 bucket that holds the archive. */
76
73
  bucket: string;