@librechat/agents 3.1.90 → 3.1.92

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 (94) hide show
  1. package/dist/cjs/agents/AgentContext.cjs +9 -5
  2. package/dist/cjs/agents/AgentContext.cjs.map +1 -1
  3. package/dist/cjs/graphs/Graph.cjs +48 -14
  4. package/dist/cjs/graphs/Graph.cjs.map +1 -1
  5. package/dist/cjs/instrumentation.cjs +2 -7
  6. package/dist/cjs/instrumentation.cjs.map +1 -1
  7. package/dist/cjs/langfuse.cjs +285 -0
  8. package/dist/cjs/langfuse.cjs.map +1 -0
  9. package/dist/cjs/main.cjs +25 -0
  10. package/dist/cjs/main.cjs.map +1 -1
  11. package/dist/cjs/run.cjs +75 -44
  12. package/dist/cjs/run.cjs.map +1 -1
  13. package/dist/cjs/stream.cjs +10 -3
  14. package/dist/cjs/stream.cjs.map +1 -1
  15. package/dist/cjs/tools/cloudflare/CloudflareBridgeRuntime.cjs +380 -0
  16. package/dist/cjs/tools/cloudflare/CloudflareBridgeRuntime.cjs.map +1 -0
  17. package/dist/cjs/tools/cloudflare/CloudflareProgrammaticToolCalling.cjs +997 -0
  18. package/dist/cjs/tools/cloudflare/CloudflareProgrammaticToolCalling.cjs.map +1 -0
  19. package/dist/cjs/tools/cloudflare/CloudflareSandboxExecutionEngine.cjs +575 -0
  20. package/dist/cjs/tools/cloudflare/CloudflareSandboxExecutionEngine.cjs.map +1 -0
  21. package/dist/cjs/tools/cloudflare/CloudflareSandboxTools.cjs +165 -0
  22. package/dist/cjs/tools/cloudflare/CloudflareSandboxTools.cjs.map +1 -0
  23. package/dist/cjs/tools/local/LocalExecutionEngine.cjs +17 -5
  24. package/dist/cjs/tools/local/LocalExecutionEngine.cjs.map +1 -1
  25. package/dist/cjs/tools/local/resolveLocalExecutionTools.cjs +110 -6
  26. package/dist/cjs/tools/local/resolveLocalExecutionTools.cjs.map +1 -1
  27. package/dist/cjs/utils/callbacks.cjs +27 -0
  28. package/dist/cjs/utils/callbacks.cjs.map +1 -0
  29. package/dist/esm/agents/AgentContext.mjs +9 -5
  30. package/dist/esm/agents/AgentContext.mjs.map +1 -1
  31. package/dist/esm/graphs/Graph.mjs +48 -14
  32. package/dist/esm/graphs/Graph.mjs.map +1 -1
  33. package/dist/esm/instrumentation.mjs +2 -7
  34. package/dist/esm/instrumentation.mjs.map +1 -1
  35. package/dist/esm/langfuse.mjs +275 -0
  36. package/dist/esm/langfuse.mjs.map +1 -0
  37. package/dist/esm/main.mjs +5 -1
  38. package/dist/esm/main.mjs.map +1 -1
  39. package/dist/esm/run.mjs +75 -44
  40. package/dist/esm/run.mjs.map +1 -1
  41. package/dist/esm/stream.mjs +10 -3
  42. package/dist/esm/stream.mjs.map +1 -1
  43. package/dist/esm/tools/cloudflare/CloudflareBridgeRuntime.mjs +378 -0
  44. package/dist/esm/tools/cloudflare/CloudflareBridgeRuntime.mjs.map +1 -0
  45. package/dist/esm/tools/cloudflare/CloudflareProgrammaticToolCalling.mjs +994 -0
  46. package/dist/esm/tools/cloudflare/CloudflareProgrammaticToolCalling.mjs.map +1 -0
  47. package/dist/esm/tools/cloudflare/CloudflareSandboxExecutionEngine.mjs +566 -0
  48. package/dist/esm/tools/cloudflare/CloudflareSandboxExecutionEngine.mjs.map +1 -0
  49. package/dist/esm/tools/cloudflare/CloudflareSandboxTools.mjs +155 -0
  50. package/dist/esm/tools/cloudflare/CloudflareSandboxTools.mjs.map +1 -0
  51. package/dist/esm/tools/local/LocalExecutionEngine.mjs +17 -6
  52. package/dist/esm/tools/local/LocalExecutionEngine.mjs.map +1 -1
  53. package/dist/esm/tools/local/resolveLocalExecutionTools.mjs +111 -7
  54. package/dist/esm/tools/local/resolveLocalExecutionTools.mjs.map +1 -1
  55. package/dist/esm/utils/callbacks.mjs +24 -0
  56. package/dist/esm/utils/callbacks.mjs.map +1 -0
  57. package/dist/types/agents/AgentContext.d.ts +4 -1
  58. package/dist/types/graphs/Graph.d.ts +6 -5
  59. package/dist/types/index.d.ts +1 -0
  60. package/dist/types/langfuse.d.ts +57 -0
  61. package/dist/types/tools/cloudflare/CloudflareBridgeRuntime.d.ts +23 -0
  62. package/dist/types/tools/cloudflare/CloudflareProgrammaticToolCalling.d.ts +4 -0
  63. package/dist/types/tools/cloudflare/CloudflareSandboxExecutionEngine.d.ts +21 -0
  64. package/dist/types/tools/cloudflare/CloudflareSandboxTools.d.ts +22 -0
  65. package/dist/types/tools/cloudflare/index.d.ts +4 -0
  66. package/dist/types/tools/local/LocalExecutionEngine.d.ts +1 -0
  67. package/dist/types/types/graph.d.ts +8 -0
  68. package/dist/types/types/run.d.ts +2 -2
  69. package/dist/types/types/tools.d.ts +118 -2
  70. package/dist/types/utils/callbacks.d.ts +5 -0
  71. package/package.json +4 -4
  72. package/src/__tests__/stream.eagerEventExecution.test.ts +66 -0
  73. package/src/agents/AgentContext.ts +13 -3
  74. package/src/graphs/Graph.ts +57 -16
  75. package/src/index.ts +1 -0
  76. package/src/instrumentation.ts +2 -7
  77. package/src/langfuse.ts +441 -0
  78. package/src/run.ts +105 -59
  79. package/src/specs/langfuse-callbacks.test.ts +75 -0
  80. package/src/specs/langfuse-config.test.ts +114 -0
  81. package/src/specs/langfuse-metadata.test.ts +19 -1
  82. package/src/stream.ts +13 -3
  83. package/src/tools/__tests__/CloudflareSandboxExecution.test.ts +537 -0
  84. package/src/tools/cloudflare/CloudflareBridgeRuntime.ts +480 -0
  85. package/src/tools/cloudflare/CloudflareProgrammaticToolCalling.ts +1162 -0
  86. package/src/tools/cloudflare/CloudflareSandboxExecutionEngine.ts +744 -0
  87. package/src/tools/cloudflare/CloudflareSandboxTools.ts +225 -0
  88. package/src/tools/cloudflare/index.ts +4 -0
  89. package/src/tools/local/LocalExecutionEngine.ts +20 -4
  90. package/src/tools/local/resolveLocalExecutionTools.ts +169 -7
  91. package/src/types/graph.ts +9 -0
  92. package/src/types/run.ts +2 -7
  93. package/src/types/tools.ts +141 -2
  94. package/src/utils/callbacks.ts +39 -0
@@ -1,14 +1,54 @@
1
- import { CODE_EXECUTION_TOOLS, Constants } from '../../common/enum.mjs';
1
+ import { CODE_EXECUTION_TOOLS, LOCAL_CODING_BUNDLE_NAMES, Constants } from '../../common/enum.mjs';
2
2
  import { createLocalBashExecutionTool, createLocalCodeExecutionTool } from './LocalExecutionTools.mjs';
3
3
  import { createLocalCodingToolBundle, createLocalCodingTools, createLocalCodingToolDefinitions } from './LocalCodingTools.mjs';
4
4
  import { createLocalBashProgrammaticToolCallingTool, createLocalProgrammaticToolCallingTool } from './LocalProgrammaticToolCalling.mjs';
5
+ import 'path';
6
+ import '../cloudflare/CloudflareProgrammaticToolCalling.mjs';
7
+ import 'events';
8
+ import 'stream';
9
+ import './LocalExecutionEngine.mjs';
10
+ import { createCloudflareCodingToolBundle, createCloudflareCodingTools, createCloudflareExecutionTool } from '../cloudflare/CloudflareSandboxTools.mjs';
5
11
 
6
12
  function shouldUseLocalExecution(config) {
7
13
  return config?.engine === 'local';
8
14
  }
15
+ function shouldUseCloudflareSandboxExecution(config) {
16
+ return config?.engine === 'cloudflare-sandbox';
17
+ }
9
18
  function shouldIncludeCodingTools(config) {
10
- return (shouldUseLocalExecution(config) &&
11
- config?.local?.includeCodingTools !== false);
19
+ return ((shouldUseLocalExecution(config) &&
20
+ config?.local?.includeCodingTools !== false) ||
21
+ (shouldUseCloudflareSandboxExecution(config) &&
22
+ config?.cloudflare?.includeCodingTools !== false));
23
+ }
24
+ function getCloudflareConfig(config) {
25
+ if (config?.cloudflare == null) {
26
+ throw new Error('toolExecution.cloudflare is required when engine is "cloudflare-sandbox".');
27
+ }
28
+ return config.cloudflare;
29
+ }
30
+ function getSelectedCloudflareCodingToolNames(config) {
31
+ return new Set(config.codingToolNames ?? LOCAL_CODING_BUNDLE_NAMES);
32
+ }
33
+ function filterCloudflareCodingToolAllowlist(tools, selectedNames) {
34
+ const existingTools = tools ?? [];
35
+ if (existingTools.length === 0) {
36
+ return tools;
37
+ }
38
+ return existingTools.filter((existingTool) => {
39
+ if (!('name' in existingTool) || typeof existingTool.name !== 'string') {
40
+ return true;
41
+ }
42
+ return (!LOCAL_CODING_BUNDLE_NAMES.includes(existingTool.name) ||
43
+ selectedNames.has(existingTool.name));
44
+ });
45
+ }
46
+ function pruneCloudflareCodingToolAllowlist(toolMap, selectedNames) {
47
+ for (const name of LOCAL_CODING_BUNDLE_NAMES) {
48
+ if (!selectedNames.has(name)) {
49
+ toolMap.delete(name);
50
+ }
51
+ }
12
52
  }
13
53
  function createLocalExecutionTool(name, config) {
14
54
  switch (name) {
@@ -45,9 +85,26 @@ function mergeToolsByName(baseTools, localTools) {
45
85
  return orderedTools;
46
86
  }
47
87
  function resolveLocalToolsForBinding(args) {
48
- if (!shouldUseLocalExecution(args.toolExecution)) {
88
+ if (!shouldUseLocalExecution(args.toolExecution) &&
89
+ !shouldUseCloudflareSandboxExecution(args.toolExecution)) {
49
90
  return args.tools;
50
91
  }
92
+ if (shouldUseCloudflareSandboxExecution(args.toolExecution)) {
93
+ const cloudflareConfig = getCloudflareConfig(args.toolExecution);
94
+ if (shouldIncludeCodingTools(args.toolExecution)) {
95
+ const selectedNames = getSelectedCloudflareCodingToolNames(cloudflareConfig);
96
+ return mergeToolsByName(filterCloudflareCodingToolAllowlist(args.tools, selectedNames), createCloudflareCodingTools(cloudflareConfig));
97
+ }
98
+ const replacements = (args.tools ?? [])
99
+ .filter((existingTool) => 'name' in existingTool &&
100
+ typeof existingTool.name === 'string' &&
101
+ CODE_EXECUTION_TOOLS.has(existingTool.name))
102
+ .map((existingTool) => createCloudflareExecutionTool(existingTool.name, cloudflareConfig))
103
+ .filter((cloudflareTool) => cloudflareTool != null);
104
+ return replacements.length === 0
105
+ ? args.tools
106
+ : mergeToolsByName(args.tools, replacements);
107
+ }
51
108
  const localConfig = args.toolExecution?.local ?? {};
52
109
  if (shouldIncludeCodingTools(args.toolExecution)) {
53
110
  return mergeToolsByName(args.tools, createLocalCodingTools(localConfig));
@@ -67,22 +124,68 @@ function resolveLocalToolRegistry(args) {
67
124
  return args.toolRegistry;
68
125
  }
69
126
  const registry = new Map(args.toolRegistry ?? []);
127
+ const selectedNames = shouldUseCloudflareSandboxExecution(args.toolExecution)
128
+ ? getSelectedCloudflareCodingToolNames(getCloudflareConfig(args.toolExecution))
129
+ : undefined;
70
130
  for (const definition of createLocalCodingToolDefinitions()) {
131
+ if (selectedNames != null && !selectedNames.has(definition.name)) {
132
+ registry.delete(definition.name);
133
+ continue;
134
+ }
71
135
  registry.set(definition.name, definition);
72
136
  }
73
137
  return registry;
74
138
  }
75
139
  function resolveLocalExecutionTools(args) {
76
140
  const directToolNames = new Set();
77
- if (!shouldUseLocalExecution(args.toolExecution)) {
141
+ if (!shouldUseLocalExecution(args.toolExecution) &&
142
+ !shouldUseCloudflareSandboxExecution(args.toolExecution)) {
78
143
  return {
79
144
  toolMap: args.toolMap,
80
145
  directToolNames,
81
146
  };
82
147
  }
83
- const localConfig = args.toolExecution?.local ?? {};
84
148
  const toolMap = new Map(args.toolMap);
85
149
  let fileCheckpointer;
150
+ if (shouldUseCloudflareSandboxExecution(args.toolExecution)) {
151
+ const cloudflareConfig = getCloudflareConfig(args.toolExecution);
152
+ if (shouldIncludeCodingTools(args.toolExecution)) {
153
+ const selectedNames = getSelectedCloudflareCodingToolNames(cloudflareConfig);
154
+ pruneCloudflareCodingToolAllowlist(toolMap, selectedNames);
155
+ if (cloudflareConfig.fileCheckpointing === true ||
156
+ args.fileCheckpointer != null) {
157
+ const bundle = createCloudflareCodingToolBundle(cloudflareConfig, {
158
+ checkpointer: args.fileCheckpointer,
159
+ });
160
+ fileCheckpointer = bundle.checkpointer;
161
+ for (const cloudflareTool of bundle.tools) {
162
+ toolMap.set(cloudflareTool.name, cloudflareTool);
163
+ directToolNames.add(cloudflareTool.name);
164
+ }
165
+ }
166
+ else {
167
+ for (const cloudflareTool of createCloudflareCodingTools(cloudflareConfig)) {
168
+ toolMap.set(cloudflareTool.name, cloudflareTool);
169
+ directToolNames.add(cloudflareTool.name);
170
+ }
171
+ }
172
+ }
173
+ const includeCodingTools = shouldIncludeCodingTools(args.toolExecution);
174
+ for (const name of CODE_EXECUTION_TOOLS) {
175
+ if (includeCodingTools)
176
+ continue;
177
+ if (!toolMap.has(name))
178
+ continue;
179
+ const cloudflareTool = createCloudflareExecutionTool(name, cloudflareConfig);
180
+ if (cloudflareTool == null) {
181
+ continue;
182
+ }
183
+ toolMap.set(name, cloudflareTool);
184
+ directToolNames.add(name);
185
+ }
186
+ return { toolMap, directToolNames, fileCheckpointer };
187
+ }
188
+ const localConfig = args.toolExecution?.local ?? {};
86
189
  if (shouldIncludeCodingTools(args.toolExecution)) {
87
190
  // Use the bundle factory when fileCheckpointing is on so we can
88
191
  // surface the checkpointer back to the caller — without this, the
@@ -90,7 +193,8 @@ function resolveLocalExecutionTools(args) {
90
193
  // immediately discarded, making the public `fileCheckpointing`
91
194
  // config flag a silent no-op outside of direct
92
195
  // `createLocalCodingToolBundle()` use.
93
- if (localConfig.fileCheckpointing === true || args.fileCheckpointer != null) {
196
+ if (localConfig.fileCheckpointing === true ||
197
+ args.fileCheckpointer != null) {
94
198
  const bundle = createLocalCodingToolBundle(localConfig, {
95
199
  checkpointer: args.fileCheckpointer,
96
200
  });
@@ -1 +1 @@
1
- {"version":3,"file":"resolveLocalExecutionTools.mjs","sources":["../../../../src/tools/local/resolveLocalExecutionTools.ts"],"sourcesContent":["import { Constants, CODE_EXECUTION_TOOLS } from '@/common';\nimport {\n createLocalBashExecutionTool,\n createLocalCodeExecutionTool,\n} from './LocalExecutionTools';\nimport {\n createLocalCodingToolBundle,\n createLocalCodingToolDefinitions,\n createLocalCodingTools,\n} from './LocalCodingTools';\nimport {\n createLocalBashProgrammaticToolCallingTool,\n createLocalProgrammaticToolCallingTool,\n} from './LocalProgrammaticToolCalling';\nimport type * as t from '@/types';\n\ntype ResolveLocalToolsResult = {\n toolMap: t.ToolMap;\n directToolNames: Set<string>;\n /**\n * Set when `local.fileCheckpointing === true` AND the auto-bind\n * coding suite is in use. ToolNode stashes this on the node and\n * exposes it via `getFileCheckpointer()` so the host can call\n * `rewind()` after a failed batch. Manual review (finding E)\n * flagged that the config flag was previously a no-op in the\n * Run/ToolNode auto-bind path — only direct\n * `createLocalCodingToolBundle()` callers could access the\n * checkpointer.\n */\n fileCheckpointer?: t.LocalFileCheckpointer;\n};\n\nfunction shouldUseLocalExecution(config?: t.ToolExecutionConfig): boolean {\n return config?.engine === 'local';\n}\n\nfunction shouldIncludeCodingTools(config?: t.ToolExecutionConfig): boolean {\n return (\n shouldUseLocalExecution(config) &&\n config?.local?.includeCodingTools !== false\n );\n}\n\nfunction createLocalExecutionTool(\n name: string,\n config: t.LocalExecutionConfig\n): t.GenericTool | undefined {\n switch (name) {\n case Constants.EXECUTE_CODE:\n return createLocalCodeExecutionTool(config);\n case Constants.BASH_TOOL:\n return createLocalBashExecutionTool({ config });\n case Constants.PROGRAMMATIC_TOOL_CALLING:\n return createLocalProgrammaticToolCallingTool(config);\n case Constants.BASH_PROGRAMMATIC_TOOL_CALLING:\n return createLocalBashProgrammaticToolCallingTool(config);\n default:\n return undefined;\n }\n}\n\nfunction mergeToolsByName(\n baseTools: t.GraphTools | undefined,\n localTools: t.GenericTool[]\n): t.GraphTools {\n const orderedTools: t.GenericTool[] = [];\n const indexByName = new Map<string, number>();\n\n for (const tool of (baseTools as t.GenericTool[] | undefined) ?? []) {\n if ('name' in tool && typeof tool.name === 'string') {\n indexByName.set(tool.name, orderedTools.length);\n }\n orderedTools.push(tool);\n }\n\n for (const tool of localTools) {\n const existingIndex = indexByName.get(tool.name);\n if (existingIndex == null) {\n indexByName.set(tool.name, orderedTools.length);\n orderedTools.push(tool);\n continue;\n }\n orderedTools[existingIndex] = tool;\n }\n\n return orderedTools;\n}\n\nexport function resolveLocalToolsForBinding(args: {\n tools?: t.GraphTools;\n toolExecution?: t.ToolExecutionConfig;\n}): t.GraphTools | undefined {\n if (!shouldUseLocalExecution(args.toolExecution)) {\n return args.tools;\n }\n\n const localConfig = args.toolExecution?.local ?? {};\n if (shouldIncludeCodingTools(args.toolExecution)) {\n return mergeToolsByName(args.tools, createLocalCodingTools(localConfig));\n }\n\n const replacements = ((args.tools as t.GenericTool[] | undefined) ?? [])\n .filter(\n (existingTool): existingTool is t.GenericTool & { name: string } =>\n 'name' in existingTool &&\n typeof existingTool.name === 'string' &&\n CODE_EXECUTION_TOOLS.has(existingTool.name)\n )\n .map((existingTool) =>\n createLocalExecutionTool(existingTool.name, localConfig)\n )\n .filter((localTool): localTool is t.GenericTool => localTool != null);\n\n return replacements.length === 0\n ? args.tools\n : mergeToolsByName(args.tools, replacements);\n}\n\nexport function resolveLocalToolRegistry(args: {\n toolRegistry?: t.LCToolRegistry;\n toolExecution?: t.ToolExecutionConfig;\n}): t.LCToolRegistry | undefined {\n if (!shouldIncludeCodingTools(args.toolExecution)) {\n return args.toolRegistry;\n }\n\n const registry = new Map(args.toolRegistry ?? []);\n for (const definition of createLocalCodingToolDefinitions()) {\n registry.set(definition.name, definition);\n }\n return registry;\n}\n\nexport function resolveLocalExecutionTools(args: {\n toolMap: t.ToolMap;\n toolExecution?: t.ToolExecutionConfig;\n /**\n * Caller-provided checkpointer that overrides the bundle's\n * auto-created one. The Graph layer threads a single per-Run\n * instance so every ToolNode it compiles shares one snapshot\n * store — without that, a multi-agent graph would each get a\n * private checkpointer and `Run.rewindFiles()` couldn't reach\n * any of them.\n */\n fileCheckpointer?: t.LocalFileCheckpointer;\n}): ResolveLocalToolsResult {\n const directToolNames = new Set<string>();\n if (!shouldUseLocalExecution(args.toolExecution)) {\n return {\n toolMap: args.toolMap,\n directToolNames,\n };\n }\n\n const localConfig = args.toolExecution?.local ?? {};\n const toolMap = new Map(args.toolMap);\n let fileCheckpointer: t.LocalFileCheckpointer | undefined;\n\n if (shouldIncludeCodingTools(args.toolExecution)) {\n // Use the bundle factory when fileCheckpointing is on so we can\n // surface the checkpointer back to the caller — without this, the\n // execution-path tools each captured into a checkpointer that was\n // immediately discarded, making the public `fileCheckpointing`\n // config flag a silent no-op outside of direct\n // `createLocalCodingToolBundle()` use.\n if (localConfig.fileCheckpointing === true || args.fileCheckpointer != null) {\n const bundle = createLocalCodingToolBundle(localConfig, {\n checkpointer: args.fileCheckpointer,\n });\n fileCheckpointer = bundle.checkpointer;\n for (const localTool of bundle.tools) {\n toolMap.set(localTool.name, localTool);\n directToolNames.add(localTool.name);\n }\n } else {\n for (const localTool of createLocalCodingTools(localConfig)) {\n toolMap.set(localTool.name, localTool);\n directToolNames.add(localTool.name);\n }\n }\n }\n\n // When the coding-tool bundle was already installed above, it\n // already created `bash_tool` / `execute_code` / programmatic-tool\n // variants. Skip re-creating them here — the audit-of-audit (manual\n // finding #4) flagged that the original loop overwrote those bundle\n // instances with fresh ones via `createLocalExecutionTool`, wasting\n // work and (more importantly) replacing tools the bundle had\n // already wired up with shared state. The CODE_EXECUTION_TOOLS\n // loop is now only relevant when the host pre-bound a tool with\n // one of these names (the `toolMap.has(name)` branch) and coding\n // tools are off.\n const includeCodingTools = shouldIncludeCodingTools(args.toolExecution);\n for (const name of CODE_EXECUTION_TOOLS) {\n if (includeCodingTools) continue;\n if (!toolMap.has(name)) continue;\n\n const localTool = createLocalExecutionTool(name, localConfig);\n if (localTool == null) {\n continue;\n }\n\n toolMap.set(name, localTool);\n directToolNames.add(name);\n }\n\n return { toolMap, directToolNames, fileCheckpointer };\n}\n"],"names":[],"mappings":";;;;;AAgCA,SAAS,uBAAuB,CAAC,MAA8B,EAAA;AAC7D,IAAA,OAAO,MAAM,EAAE,MAAM,KAAK,OAAO;AACnC;AAEA,SAAS,wBAAwB,CAAC,MAA8B,EAAA;AAC9D,IAAA,QACE,uBAAuB,CAAC,MAAM,CAAC;AAC/B,QAAA,MAAM,EAAE,KAAK,EAAE,kBAAkB,KAAK,KAAK;AAE/C;AAEA,SAAS,wBAAwB,CAC/B,IAAY,EACZ,MAA8B,EAAA;IAE9B,QAAQ,IAAI;QACZ,KAA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AO,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE;QAExB,MAAM,SAAS,GAAG,wBAAwB,CAAC,IAAI,EAAE,WAAW,CAAC;AAC7D,QAAA,IAAI,SAAS,IAAI,IAAI,EAAE;YACrB;QACF;AAEA,QAAA,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC;AAC5B,QAAA,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC;IAC3B;AAEA,IAAA,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE;AACvD;;;;"}
1
+ {"version":3,"file":"resolveLocalExecutionTools.mjs","sources":["../../../../src/tools/local/resolveLocalExecutionTools.ts"],"sourcesContent":["import {\n Constants,\n CODE_EXECUTION_TOOLS,\n LOCAL_CODING_BUNDLE_NAMES,\n} from '@/common';\nimport {\n createLocalBashExecutionTool,\n createLocalCodeExecutionTool,\n} from './LocalExecutionTools';\nimport {\n createLocalCodingToolBundle,\n createLocalCodingToolDefinitions,\n createLocalCodingTools,\n} from './LocalCodingTools';\nimport {\n createLocalBashProgrammaticToolCallingTool,\n createLocalProgrammaticToolCallingTool,\n} from './LocalProgrammaticToolCalling';\nimport {\n createCloudflareCodingToolBundle,\n createCloudflareCodingTools,\n createCloudflareExecutionTool,\n} from '@/tools/cloudflare';\nimport type * as t from '@/types';\n\ntype ResolveLocalToolsResult = {\n toolMap: t.ToolMap;\n directToolNames: Set<string>;\n /**\n * Set when `local.fileCheckpointing === true` AND the auto-bind\n * coding suite is in use. ToolNode stashes this on the node and\n * exposes it via `getFileCheckpointer()` so the host can call\n * `rewind()` after a failed batch. Manual review (finding E)\n * flagged that the config flag was previously a no-op in the\n * Run/ToolNode auto-bind path — only direct\n * `createLocalCodingToolBundle()` callers could access the\n * checkpointer.\n */\n fileCheckpointer?: t.LocalFileCheckpointer;\n};\n\nfunction shouldUseLocalExecution(config?: t.ToolExecutionConfig): boolean {\n return config?.engine === 'local';\n}\n\nfunction shouldUseCloudflareSandboxExecution(\n config?: t.ToolExecutionConfig\n): boolean {\n return config?.engine === 'cloudflare-sandbox';\n}\n\nfunction shouldIncludeCodingTools(config?: t.ToolExecutionConfig): boolean {\n return (\n (shouldUseLocalExecution(config) &&\n config?.local?.includeCodingTools !== false) ||\n (shouldUseCloudflareSandboxExecution(config) &&\n config?.cloudflare?.includeCodingTools !== false)\n );\n}\n\nfunction getCloudflareConfig(\n config?: t.ToolExecutionConfig\n): t.CloudflareSandboxExecutionConfig {\n if (config?.cloudflare == null) {\n throw new Error(\n 'toolExecution.cloudflare is required when engine is \"cloudflare-sandbox\".'\n );\n }\n return config.cloudflare;\n}\n\nfunction getSelectedCloudflareCodingToolNames(\n config: t.CloudflareSandboxExecutionConfig\n): Set<string> {\n return new Set(config.codingToolNames ?? LOCAL_CODING_BUNDLE_NAMES);\n}\n\nfunction filterCloudflareCodingToolAllowlist(\n tools: t.GraphTools | undefined,\n selectedNames: Set<string>\n): t.GraphTools | undefined {\n const existingTools = (tools as t.GenericTool[] | undefined) ?? [];\n if (existingTools.length === 0) {\n return tools;\n }\n return existingTools.filter((existingTool) => {\n if (!('name' in existingTool) || typeof existingTool.name !== 'string') {\n return true;\n }\n return (\n !LOCAL_CODING_BUNDLE_NAMES.includes(existingTool.name) ||\n selectedNames.has(existingTool.name)\n );\n });\n}\n\nfunction pruneCloudflareCodingToolAllowlist(\n toolMap: t.ToolMap,\n selectedNames: Set<string>\n): void {\n for (const name of LOCAL_CODING_BUNDLE_NAMES) {\n if (!selectedNames.has(name)) {\n toolMap.delete(name);\n }\n }\n}\n\nfunction createLocalExecutionTool(\n name: string,\n config: t.LocalExecutionConfig\n): t.GenericTool | undefined {\n switch (name) {\n case Constants.EXECUTE_CODE:\n return createLocalCodeExecutionTool(config);\n case Constants.BASH_TOOL:\n return createLocalBashExecutionTool({ config });\n case Constants.PROGRAMMATIC_TOOL_CALLING:\n return createLocalProgrammaticToolCallingTool(config);\n case Constants.BASH_PROGRAMMATIC_TOOL_CALLING:\n return createLocalBashProgrammaticToolCallingTool(config);\n default:\n return undefined;\n }\n}\n\nfunction mergeToolsByName(\n baseTools: t.GraphTools | undefined,\n localTools: t.GenericTool[]\n): t.GraphTools {\n const orderedTools: t.GenericTool[] = [];\n const indexByName = new Map<string, number>();\n\n for (const tool of (baseTools as t.GenericTool[] | undefined) ?? []) {\n if ('name' in tool && typeof tool.name === 'string') {\n indexByName.set(tool.name, orderedTools.length);\n }\n orderedTools.push(tool);\n }\n\n for (const tool of localTools) {\n const existingIndex = indexByName.get(tool.name);\n if (existingIndex == null) {\n indexByName.set(tool.name, orderedTools.length);\n orderedTools.push(tool);\n continue;\n }\n orderedTools[existingIndex] = tool;\n }\n\n return orderedTools;\n}\n\nexport function resolveLocalToolsForBinding(args: {\n tools?: t.GraphTools;\n toolExecution?: t.ToolExecutionConfig;\n}): t.GraphTools | undefined {\n if (\n !shouldUseLocalExecution(args.toolExecution) &&\n !shouldUseCloudflareSandboxExecution(args.toolExecution)\n ) {\n return args.tools;\n }\n\n if (shouldUseCloudflareSandboxExecution(args.toolExecution)) {\n const cloudflareConfig = getCloudflareConfig(args.toolExecution);\n if (shouldIncludeCodingTools(args.toolExecution)) {\n const selectedNames =\n getSelectedCloudflareCodingToolNames(cloudflareConfig);\n return mergeToolsByName(\n filterCloudflareCodingToolAllowlist(args.tools, selectedNames),\n createCloudflareCodingTools(cloudflareConfig)\n );\n }\n\n const replacements = ((args.tools as t.GenericTool[] | undefined) ?? [])\n .filter(\n (existingTool): existingTool is t.GenericTool & { name: string } =>\n 'name' in existingTool &&\n typeof existingTool.name === 'string' &&\n CODE_EXECUTION_TOOLS.has(existingTool.name)\n )\n .map((existingTool) =>\n createCloudflareExecutionTool(existingTool.name, cloudflareConfig)\n )\n .filter(\n (cloudflareTool): cloudflareTool is t.GenericTool =>\n cloudflareTool != null\n );\n\n return replacements.length === 0\n ? args.tools\n : mergeToolsByName(args.tools, replacements);\n }\n\n const localConfig = args.toolExecution?.local ?? {};\n if (shouldIncludeCodingTools(args.toolExecution)) {\n return mergeToolsByName(args.tools, createLocalCodingTools(localConfig));\n }\n\n const replacements = ((args.tools as t.GenericTool[] | undefined) ?? [])\n .filter(\n (existingTool): existingTool is t.GenericTool & { name: string } =>\n 'name' in existingTool &&\n typeof existingTool.name === 'string' &&\n CODE_EXECUTION_TOOLS.has(existingTool.name)\n )\n .map((existingTool) =>\n createLocalExecutionTool(existingTool.name, localConfig)\n )\n .filter((localTool): localTool is t.GenericTool => localTool != null);\n\n return replacements.length === 0\n ? args.tools\n : mergeToolsByName(args.tools, replacements);\n}\n\nexport function resolveLocalToolRegistry(args: {\n toolRegistry?: t.LCToolRegistry;\n toolExecution?: t.ToolExecutionConfig;\n}): t.LCToolRegistry | undefined {\n if (!shouldIncludeCodingTools(args.toolExecution)) {\n return args.toolRegistry;\n }\n\n const registry = new Map(args.toolRegistry ?? []);\n const selectedNames = shouldUseCloudflareSandboxExecution(args.toolExecution)\n ? getSelectedCloudflareCodingToolNames(\n getCloudflareConfig(args.toolExecution)\n )\n : undefined;\n for (const definition of createLocalCodingToolDefinitions()) {\n if (selectedNames != null && !selectedNames.has(definition.name)) {\n registry.delete(definition.name);\n continue;\n }\n registry.set(definition.name, definition);\n }\n return registry;\n}\n\nexport function resolveLocalExecutionTools(args: {\n toolMap: t.ToolMap;\n toolExecution?: t.ToolExecutionConfig;\n /**\n * Caller-provided checkpointer that overrides the bundle's\n * auto-created one. The Graph layer threads a single per-Run\n * instance so every ToolNode it compiles shares one snapshot\n * store — without that, a multi-agent graph would each get a\n * private checkpointer and `Run.rewindFiles()` couldn't reach\n * any of them.\n */\n fileCheckpointer?: t.LocalFileCheckpointer;\n}): ResolveLocalToolsResult {\n const directToolNames = new Set<string>();\n if (\n !shouldUseLocalExecution(args.toolExecution) &&\n !shouldUseCloudflareSandboxExecution(args.toolExecution)\n ) {\n return {\n toolMap: args.toolMap,\n directToolNames,\n };\n }\n\n const toolMap = new Map(args.toolMap);\n let fileCheckpointer: t.LocalFileCheckpointer | undefined;\n\n if (shouldUseCloudflareSandboxExecution(args.toolExecution)) {\n const cloudflareConfig = getCloudflareConfig(args.toolExecution);\n if (shouldIncludeCodingTools(args.toolExecution)) {\n const selectedNames =\n getSelectedCloudflareCodingToolNames(cloudflareConfig);\n pruneCloudflareCodingToolAllowlist(toolMap, selectedNames);\n if (\n cloudflareConfig.fileCheckpointing === true ||\n args.fileCheckpointer != null\n ) {\n const bundle = createCloudflareCodingToolBundle(cloudflareConfig, {\n checkpointer: args.fileCheckpointer,\n });\n fileCheckpointer = bundle.checkpointer;\n for (const cloudflareTool of bundle.tools) {\n toolMap.set(cloudflareTool.name, cloudflareTool);\n directToolNames.add(cloudflareTool.name);\n }\n } else {\n for (const cloudflareTool of createCloudflareCodingTools(\n cloudflareConfig\n )) {\n toolMap.set(cloudflareTool.name, cloudflareTool);\n directToolNames.add(cloudflareTool.name);\n }\n }\n }\n\n const includeCodingTools = shouldIncludeCodingTools(args.toolExecution);\n for (const name of CODE_EXECUTION_TOOLS) {\n if (includeCodingTools) continue;\n if (!toolMap.has(name)) continue;\n\n const cloudflareTool = createCloudflareExecutionTool(\n name,\n cloudflareConfig\n );\n if (cloudflareTool == null) {\n continue;\n }\n\n toolMap.set(name, cloudflareTool);\n directToolNames.add(name);\n }\n\n return { toolMap, directToolNames, fileCheckpointer };\n }\n\n const localConfig = args.toolExecution?.local ?? {};\n\n if (shouldIncludeCodingTools(args.toolExecution)) {\n // Use the bundle factory when fileCheckpointing is on so we can\n // surface the checkpointer back to the caller — without this, the\n // execution-path tools each captured into a checkpointer that was\n // immediately discarded, making the public `fileCheckpointing`\n // config flag a silent no-op outside of direct\n // `createLocalCodingToolBundle()` use.\n if (\n localConfig.fileCheckpointing === true ||\n args.fileCheckpointer != null\n ) {\n const bundle = createLocalCodingToolBundle(localConfig, {\n checkpointer: args.fileCheckpointer,\n });\n fileCheckpointer = bundle.checkpointer;\n for (const localTool of bundle.tools) {\n toolMap.set(localTool.name, localTool);\n directToolNames.add(localTool.name);\n }\n } else {\n for (const localTool of createLocalCodingTools(localConfig)) {\n toolMap.set(localTool.name, localTool);\n directToolNames.add(localTool.name);\n }\n }\n }\n\n // When the coding-tool bundle was already installed above, it\n // already created `bash_tool` / `execute_code` / programmatic-tool\n // variants. Skip re-creating them here — the audit-of-audit (manual\n // finding #4) flagged that the original loop overwrote those bundle\n // instances with fresh ones via `createLocalExecutionTool`, wasting\n // work and (more importantly) replacing tools the bundle had\n // already wired up with shared state. The CODE_EXECUTION_TOOLS\n // loop is now only relevant when the host pre-bound a tool with\n // one of these names (the `toolMap.has(name)` branch) and coding\n // tools are off.\n const includeCodingTools = shouldIncludeCodingTools(args.toolExecution);\n for (const name of CODE_EXECUTION_TOOLS) {\n if (includeCodingTools) continue;\n if (!toolMap.has(name)) continue;\n\n const localTool = createLocalExecutionTool(name, localConfig);\n if (localTool == null) {\n continue;\n }\n\n toolMap.set(name, localTool);\n directToolNames.add(name);\n }\n\n return { toolMap, directToolNames, fileCheckpointer };\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAyCA,SAAS,uBAAuB,CAAC,MAA8B,EAAA;AAC7D,IAAA,OAAO,MAAM,EAAE,MAAM,KAAK,OAAO;AACnC;AAEA,SAAS,mCAAmC,CAC1C,MAA8B,EAAA;AAE9B,IAAA,OAAO,MAAM,EAAE,MAAM,KAAK,oBAAoB;AAChD;AAEA,SAAS,wBAAwB,CAAC,MAA8B,EAAA;AAC9D,IAAA,QACE,CAAC,uBAAuB,CAAC,MAAM,CAAC;AAC9B,QAAA,MAAM,EAAE,KAAK,EAAE,kBAAkB,KAAK,KAAK;SAC5C,mCAAmC,CAAC,MAAM,CAAC;YAC1C,MAAM,EAAE,UAAU,EAAE,kBAAkB,KAAK,KAAK,CAAC;AAEvD;AAEA,SAAS,mBAAmB,CAC1B,MAA8B,EAAA;AAE9B,IAAA,IAAI,MAAM,EAAE,UAAU,IAAI,IAAI,EAAE;AAC9B,QAAA,MAAM,IAAI,KAAK,CACb,2EAA2E,CAC5E;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IAAI,CAAC,aAAa,CAAC;AACvE,IAAA,KAAK,MAAM,IAAI,IAAI,oBAAoB,EAAE;AACvC,QAAA,IAAI,kBAAkB;YAAE;AACxB,QAAA,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE;QAExB,MAAM,SAAS,GAAG,wBAAwB,CAAC,IAAI,EAAE,WAAW,CAAC;AAC7D,QAAA,IAAI,SAAS,IAAI,IAAI,EAAE;YACrB;QACF;AAEA,QAAA,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC;AAC5B,QAAA,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC;IAC3B;AAEA,IAAA,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE;AACvD;;;;"}
@@ -0,0 +1,24 @@
1
+ import { ensureHandler } from '@langchain/core/callbacks/manager';
2
+
3
+ function appendCallbacks(callbacks, additions) {
4
+ if (additions.length === 0) {
5
+ return callbacks ?? [];
6
+ }
7
+ if (callbacks == null) {
8
+ return [...additions];
9
+ }
10
+ if (Array.isArray(callbacks)) {
11
+ return callbacks.concat(additions);
12
+ }
13
+ return callbacks.copy(additions.map(ensureHandler));
14
+ }
15
+ function findCallback(callbacks, predicate) {
16
+ if (callbacks == null) {
17
+ return undefined;
18
+ }
19
+ const handlers = Array.isArray(callbacks) ? callbacks : callbacks.handlers;
20
+ return handlers.find(predicate);
21
+ }
22
+
23
+ export { appendCallbacks, findCallback };
24
+ //# sourceMappingURL=callbacks.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callbacks.mjs","sources":["../../../src/utils/callbacks.ts"],"sourcesContent":["import { ensureHandler } from '@langchain/core/callbacks/manager';\nimport type {\n BaseCallbackHandler,\n CallbackHandlerMethods,\n} from '@langchain/core/callbacks/base';\nimport type { Callbacks } from '@langchain/core/callbacks/manager';\n\nexport type CallbackEntry = BaseCallbackHandler | CallbackHandlerMethods;\n\nexport function appendCallbacks(\n callbacks: Callbacks | undefined,\n additions: readonly CallbackEntry[]\n): Callbacks {\n if (additions.length === 0) {\n return callbacks ?? [];\n }\n\n if (callbacks == null) {\n return [...additions];\n }\n\n if (Array.isArray(callbacks)) {\n return callbacks.concat(additions);\n }\n\n return callbacks.copy(additions.map(ensureHandler));\n}\n\nexport function findCallback(\n callbacks: Callbacks | undefined,\n predicate: (callback: CallbackEntry) => boolean\n): CallbackEntry | undefined {\n if (callbacks == null) {\n return undefined;\n }\n\n const handlers = Array.isArray(callbacks) ? callbacks : callbacks.handlers;\n return handlers.find(predicate);\n}\n"],"names":[],"mappings":";;AASM,SAAU,eAAe,CAC7B,SAAgC,EAChC,SAAmC,EAAA;AAEnC,IAAA,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;QAC1B,OAAO,SAAS,IAAI,EAAE;IACxB;AAEA,IAAA,IAAI,SAAS,IAAI,IAAI,EAAE;AACrB,QAAA,OAAO,CAAC,GAAG,SAAS,CAAC;IACvB;AAEA,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;AAC5B,QAAA,OAAO,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC;IACpC;IAEA,OAAO,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;AACrD;AAEM,SAAU,YAAY,CAC1B,SAAgC,EAChC,SAA+C,EAAA;AAE/C,IAAA,IAAI,SAAS,IAAI,IAAI,EAAE;AACrB,QAAA,OAAO,SAAS;IAClB;AAEA,IAAA,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,SAAS,GAAG,SAAS,CAAC,QAAQ;AAC1E,IAAA,OAAO,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC;AACjC;;;;"}
@@ -20,6 +20,8 @@ export declare class AgentContext {
20
20
  provider: Providers;
21
21
  /** Client options for this agent */
22
22
  clientOptions?: t.ClientOptions;
23
+ /** Per-agent Langfuse tracing configuration. */
24
+ langfuse?: t.LangfuseConfig;
23
25
  /** Token count map indexed by message position */
24
26
  indexTokenCountMap: Record<string, number | undefined>;
25
27
  /** Canonical pre-run token map used to restore token accounting on reset */
@@ -159,11 +161,12 @@ export declare class AgentContext {
159
161
  /** Names of sibling agents executing in parallel (empty if sequential) */
160
162
  parallelSiblings: string[];
161
163
  };
162
- constructor({ agentId, name, provider, clientOptions, maxContextTokens, streamBuffer, tokenCounter, tools, toolMap, toolRegistry, toolDefinitions, instructions, additionalInstructions, reasoningKey, toolEnd, instructionTokens, useLegacyContent, discoveredTools, summarizationEnabled, summarizationConfig, contextPruningConfig, maxToolResultChars, }: {
164
+ constructor({ agentId, name, provider, clientOptions, langfuse, maxContextTokens, streamBuffer, tokenCounter, tools, toolMap, toolRegistry, toolDefinitions, instructions, additionalInstructions, reasoningKey, toolEnd, instructionTokens, useLegacyContent, discoveredTools, summarizationEnabled, summarizationConfig, contextPruningConfig, maxToolResultChars, }: {
163
165
  agentId: string;
164
166
  name?: string;
165
167
  provider: Providers;
166
168
  clientOptions?: t.ClientOptions;
169
+ langfuse?: t.LangfuseConfig;
167
170
  maxContextTokens?: number;
168
171
  streamBuffer?: number;
169
172
  tokenCounter?: t.TokenCounter;
@@ -132,11 +132,12 @@ export declare abstract class Graph<T extends t.BaseGraphState = t.BaseGraphStat
132
132
  /**
133
133
  * Single per-Run file checkpointer shared across every ToolNode the
134
134
  * graph compiles. Lazily constructed when
135
- * `toolExecution.local.fileCheckpointing === true` so multi-agent
136
- * graphs see ONE snapshot store, not one-per-agent. Returns
137
- * undefined when checkpointing is disabled or the local engine
138
- * isn't selected. Exposed via `Run.getFileCheckpointer()` /
139
- * `Run.rewindFiles()`.
135
+ * `toolExecution.local.fileCheckpointing === true` or
136
+ * `toolExecution.cloudflare.fileCheckpointing === true` so
137
+ * multi-agent graphs see ONE snapshot store, not one-per-agent.
138
+ * Returns undefined when checkpointing is disabled or a supported
139
+ * coding-tool engine isn't selected. Exposed via
140
+ * `Run.getFileCheckpointer()` / `Run.rewindFiles()`.
140
141
  */
141
142
  private _fileCheckpointer?;
142
143
  /**
@@ -20,6 +20,7 @@ export * from './tools/ToolNode';
20
20
  export * from './tools/schema';
21
21
  export * from './tools/handlers';
22
22
  export * from './tools/local';
23
+ export * from './tools/cloudflare';
23
24
  export * from './tools/search';
24
25
  export * from './common';
25
26
  export * from './utils';
@@ -0,0 +1,57 @@
1
+ import { CallbackHandler } from '@langfuse/langchain';
2
+ import { BaseCallbackHandler } from '@langchain/core/callbacks/base';
3
+ import type { Serialized } from '@langchain/core/load/serializable';
4
+ import type { BaseMessage } from '@langchain/core/messages';
5
+ import type { LLMResult } from '@langchain/core/outputs';
6
+ import type * as t from '@/types';
7
+ export type LangfuseTraceMetadata = Record<string, string>;
8
+ type LangfuseHandlerParams = {
9
+ userId?: string;
10
+ sessionId?: string;
11
+ traceMetadata?: LangfuseTraceMetadata;
12
+ tags?: string[];
13
+ };
14
+ type AgentLangfuseHandlerParams = LangfuseHandlerParams & {
15
+ langfuse?: t.LangfuseConfig;
16
+ };
17
+ type ResolvedLangfuseConfig = t.LangfuseConfig & {
18
+ enabled: true;
19
+ publicKey: string;
20
+ secretKey: string;
21
+ };
22
+ export declare function createLangfuseTraceMetadata({ messageId, parentMessageId, agentId, agentName, }: {
23
+ messageId?: unknown;
24
+ parentMessageId?: unknown;
25
+ agentId?: unknown;
26
+ agentName?: unknown;
27
+ }): LangfuseTraceMetadata;
28
+ export declare function getLangfuseTraceName(traceMetadata?: LangfuseTraceMetadata, fallback?: string): string;
29
+ export declare class LangfuseAgentCallbackHandler extends BaseCallbackHandler {
30
+ name: string;
31
+ private readonly provider;
32
+ private readonly processor;
33
+ private readonly userId?;
34
+ private readonly sessionId?;
35
+ private readonly traceMetadata?;
36
+ private readonly tags?;
37
+ private readonly spans;
38
+ constructor({ langfuse, userId, sessionId, traceMetadata, tags, }: LangfuseHandlerParams & {
39
+ langfuse: ResolvedLangfuseConfig;
40
+ });
41
+ private startGenerationSpan;
42
+ handleChatModelStart(llm: Serialized, messages: BaseMessage[][], runId: string, _parentRunId?: string, extraParams?: Record<string, unknown>, _tags?: string[], metadata?: Record<string, unknown>, name?: string): Promise<void>;
43
+ handleLLMStart(llm: Serialized, prompts: string[], runId: string, _parentRunId?: string, extraParams?: Record<string, unknown>, _tags?: string[], metadata?: Record<string, unknown>, name?: string): Promise<void>;
44
+ handleLLMEnd(output: LLMResult, runId: string): Promise<void>;
45
+ handleLLMError(err: unknown, runId: string): Promise<void>;
46
+ private flush;
47
+ dispose(): Promise<void>;
48
+ }
49
+ export declare function createLegacyLangfuseHandler(params: LangfuseHandlerParams): CallbackHandler;
50
+ export declare function createLangfuseHandler({ langfuse, userId, sessionId, traceMetadata, tags, }: AgentLangfuseHandlerParams): LangfuseAgentCallbackHandler | undefined;
51
+ export declare function hasExplicitLangfuseConfig(contexts: Iterable<{
52
+ langfuse?: t.LangfuseConfig;
53
+ }>): boolean;
54
+ export declare function hasLangfuseEnvConfig(): boolean;
55
+ export declare function isLangfuseCallbackHandler(value: unknown): boolean;
56
+ export declare function disposeLangfuseHandler(value: unknown): Promise<void>;
57
+ export {};
@@ -0,0 +1,23 @@
1
+ import type * as t from '@/types';
2
+ export type CloudflareBridgeRuntimeConfig = {
3
+ /** Base URL of a Worker using `bridge()` from `@cloudflare/sandbox/bridge`. */
4
+ baseURL: string;
5
+ /** Bearer token stored in the bridge Worker as `SANDBOX_API_KEY`. */
6
+ apiKey?: string;
7
+ /** Existing sandbox id. If omitted, the adapter creates one lazily. */
8
+ sandboxId?: string;
9
+ /** Bridge API route prefix. Defaults to `/v1`. */
10
+ apiRoutePrefix?: string;
11
+ /** Workspace root used for path clamping. Defaults to `/workspace`. */
12
+ workspaceRoot?: string;
13
+ /** Optional bridge session id sent as `Session-Id`. */
14
+ sessionId?: string;
15
+ /** Shell used to run command strings over the bridge exec endpoint. */
16
+ shell?: string;
17
+ /** Optional fetch implementation. Defaults to global `fetch`. */
18
+ fetch?: typeof fetch;
19
+ };
20
+ export type CloudflareBridgeRuntime = t.CloudflareSandboxRuntime & {
21
+ getSandboxId(): Promise<string>;
22
+ };
23
+ export declare function createCloudflareBridgeRuntime(config: CloudflareBridgeRuntimeConfig): CloudflareBridgeRuntime;
@@ -0,0 +1,4 @@
1
+ import type { DynamicStructuredTool } from '@langchain/core/tools';
2
+ import type * as t from '@/types';
3
+ export declare function createCloudflareProgrammaticToolCallingTool(cloudflareConfig: t.CloudflareSandboxExecutionConfig): DynamicStructuredTool;
4
+ export declare function createCloudflareBashProgrammaticToolCallingTool(cloudflareConfig: t.CloudflareSandboxExecutionConfig): DynamicStructuredTool;
@@ -0,0 +1,21 @@
1
+ import type * as t from '@/types';
2
+ import type { WorkspaceFS } from '@/tools/local/workspaceFS';
3
+ type SpawnResult = {
4
+ stdout: string;
5
+ stderr: string;
6
+ exitCode: number | null;
7
+ timedOut: boolean;
8
+ };
9
+ export declare function getCloudflareWorkspaceRoot(config?: t.CloudflareSandboxExecutionConfig): string;
10
+ export declare function resolveCloudflareSandbox(config: t.CloudflareSandboxExecutionConfig): Promise<t.CloudflareSandboxRuntime>;
11
+ export declare function createCloudflareWorkspaceFS(config: t.CloudflareSandboxExecutionConfig): WorkspaceFS;
12
+ export declare function createCloudflareLocalExecutionConfig(config: t.CloudflareSandboxExecutionConfig): t.LocalExecutionConfig;
13
+ export declare function validateCloudflareBashCommand(command: string, args: readonly string[], config: t.CloudflareSandboxExecutionConfig): Promise<void>;
14
+ export declare function executeCloudflareBash(command: string, config: t.CloudflareSandboxExecutionConfig, args?: readonly string[]): Promise<SpawnResult>;
15
+ export declare function executeCloudflareCode(input: {
16
+ lang: string;
17
+ code: string;
18
+ args?: string[];
19
+ }, config: t.CloudflareSandboxExecutionConfig): Promise<SpawnResult>;
20
+ export declare function formatCloudflareOutput(result: SpawnResult, cwd: string): string;
21
+ export {};
@@ -0,0 +1,22 @@
1
+ import type { DynamicStructuredTool } from '@langchain/core/tools';
2
+ import type * as t from '@/types';
3
+ export declare const CLOUDFLARE_CODING_TOOL_NAMES: readonly string[];
4
+ export declare const CLOUDFLARE_BASH_CODING_TOOL_NAMES: readonly string[];
5
+ export declare const CloudflareCodeExecutionToolDescription: string;
6
+ export declare const CloudflareBashExecutionToolDescription: string;
7
+ export declare function createCloudflareCodeExecutionTool(config: t.CloudflareSandboxExecutionConfig): DynamicStructuredTool;
8
+ export declare function createCloudflareBashExecutionTool(options: {
9
+ config: t.CloudflareSandboxExecutionConfig;
10
+ enableToolOutputReferences?: boolean;
11
+ }): DynamicStructuredTool;
12
+ export type CloudflareCodingToolBundle = {
13
+ tools: DynamicStructuredTool[];
14
+ checkpointer?: t.LocalFileCheckpointer;
15
+ };
16
+ export declare function createCloudflareCodingTools(config: t.CloudflareSandboxExecutionConfig, options?: {
17
+ checkpointer?: t.LocalFileCheckpointer;
18
+ }): DynamicStructuredTool[];
19
+ export declare function createCloudflareCodingToolBundle(config: t.CloudflareSandboxExecutionConfig, options?: {
20
+ checkpointer?: t.LocalFileCheckpointer;
21
+ }): CloudflareCodingToolBundle;
22
+ export declare function createCloudflareExecutionTool(name: string, config: t.CloudflareSandboxExecutionConfig): t.GenericTool | undefined;
@@ -0,0 +1,4 @@
1
+ export * from './CloudflareBridgeRuntime';
2
+ export * from './CloudflareProgrammaticToolCalling';
3
+ export * from './CloudflareSandboxExecutionEngine';
4
+ export * from './CloudflareSandboxTools';
@@ -128,6 +128,7 @@ export interface SpawnLocalProcessOptions {
128
128
  */
129
129
  internal?: boolean;
130
130
  }
131
+ export declare const LOCAL_SPAWN_TIMEOUT_MS: unique symbol;
131
132
  export declare function spawnLocalProcess(command: string, args: string[], config?: t.LocalExecutionConfig, options?: SpawnLocalProcessOptions): Promise<SpawnResult>;
132
133
  export declare function executeLocalBash(command: string, config?: t.LocalExecutionConfig): Promise<SpawnResult>;
133
134
  export declare function executeLocalBashWithArgs(command: string, args: readonly string[], config?: t.LocalExecutionConfig): Promise<SpawnResult>;
@@ -288,6 +288,12 @@ export interface SubagentUpdateEvent {
288
288
  /** ISO timestamp for ordering / display. */
289
289
  timestamp: string;
290
290
  }
291
+ export interface LangfuseConfig {
292
+ enabled?: boolean;
293
+ publicKey?: string;
294
+ secretKey?: string;
295
+ baseUrl?: string;
296
+ }
291
297
  export interface AgentInputs {
292
298
  agentId: string;
293
299
  /** Human-readable name for the agent (used in handoff context). Defaults to agentId if not provided. */
@@ -301,6 +307,8 @@ export interface AgentInputs {
301
307
  streamBuffer?: number;
302
308
  maxContextTokens?: number;
303
309
  clientOptions?: ClientOptions;
310
+ /** Per-agent Langfuse tracing configuration. */
311
+ langfuse?: LangfuseConfig;
304
312
  /** Dynamic system tail appended after stable instructions without provider cache markers. */
305
313
  additional_instructions?: string;
306
314
  reasoningKey?: 'reasoning_content' | 'reasoning';
@@ -2,7 +2,7 @@ import type * as z from 'zod';
2
2
  import type { BaseMessage } from '@langchain/core/messages';
3
3
  import type { StructuredTool } from '@langchain/core/tools';
4
4
  import type { RunnableConfig } from '@langchain/core/runnables';
5
- import type { BaseCallbackHandler, CallbackHandlerMethods } from '@langchain/core/callbacks/base';
5
+ import type { Callbacks } from '@langchain/core/callbacks/manager';
6
6
  import type * as s from '@/types/stream';
7
7
  import type * as e from '@/common/enum';
8
8
  import type * as g from '@/types/graph';
@@ -195,7 +195,7 @@ export type RunConfig = {
195
195
  */
196
196
  humanInTheLoop?: HumanInTheLoopConfig;
197
197
  };
198
- export type ProvidedCallbacks = (BaseCallbackHandler | CallbackHandlerMethods)[] | undefined;
198
+ export type ProvidedCallbacks = Callbacks | undefined;
199
199
  export type TokenCounter = (message: BaseMessage) => number;
200
200
  /** Structured breakdown of how context token budget is consumed. */
201
201
  export type TokenBudgetBreakdown = {