@langchain/core 1.1.3 → 1.1.4

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 (190) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/agents.d.cts +2 -0
  3. package/dist/agents.d.ts +2 -0
  4. package/dist/callbacks/base.d.cts +60 -22
  5. package/dist/callbacks/base.d.ts +60 -22
  6. package/dist/callbacks/dispatch/index.d.cts +3 -1
  7. package/dist/callbacks/dispatch/index.d.ts +3 -1
  8. package/dist/callbacks/dispatch/web.d.cts +3 -1
  9. package/dist/callbacks/dispatch/web.d.ts +3 -1
  10. package/dist/callbacks/manager.d.cts +12 -2
  11. package/dist/callbacks/manager.d.ts +12 -2
  12. package/dist/chat_history.d.cts +1 -0
  13. package/dist/chat_history.d.ts +1 -0
  14. package/dist/document_loaders/langsmith.d.cts +3 -0
  15. package/dist/document_loaders/langsmith.d.ts +3 -0
  16. package/dist/documents/document.d.cts +12 -3
  17. package/dist/documents/document.d.ts +12 -3
  18. package/dist/example_selectors/length_based.d.cts +1 -1
  19. package/dist/example_selectors/length_based.d.ts +1 -1
  20. package/dist/indexing/base.d.cts +1 -0
  21. package/dist/indexing/base.d.ts +1 -0
  22. package/dist/indexing/record_manager.d.cts +1 -0
  23. package/dist/indexing/record_manager.d.ts +1 -0
  24. package/dist/language_models/base.d.cts +38 -8
  25. package/dist/language_models/base.d.ts +38 -8
  26. package/dist/language_models/chat_models.d.cts +33 -6
  27. package/dist/language_models/chat_models.d.ts +33 -6
  28. package/dist/language_models/llms.d.cts +6 -0
  29. package/dist/language_models/llms.d.ts +6 -0
  30. package/dist/load/import_type.d.cts +1 -0
  31. package/dist/load/import_type.d.ts +1 -0
  32. package/dist/load/map_keys.cjs +5 -4
  33. package/dist/load/map_keys.cjs.map +1 -1
  34. package/dist/load/map_keys.d.cts +1 -0
  35. package/dist/load/map_keys.d.ts +1 -0
  36. package/dist/load/map_keys.js +3 -3
  37. package/dist/load/map_keys.js.map +1 -1
  38. package/dist/load/serializable.d.cts +1 -0
  39. package/dist/load/serializable.d.ts +1 -0
  40. package/dist/memory.d.cts +3 -0
  41. package/dist/memory.d.ts +3 -0
  42. package/dist/messages/base.d.cts +13 -1
  43. package/dist/messages/base.d.ts +13 -1
  44. package/dist/messages/content/data.d.cts +7 -2
  45. package/dist/messages/content/data.d.ts +7 -2
  46. package/dist/messages/content/index.d.cts +4 -1
  47. package/dist/messages/content/index.d.ts +4 -1
  48. package/dist/messages/content/multimodal.d.cts +1 -0
  49. package/dist/messages/content/multimodal.d.ts +1 -0
  50. package/dist/messages/content/tools.d.cts +1 -0
  51. package/dist/messages/content/tools.d.ts +1 -0
  52. package/dist/messages/tool.d.cts +9 -2
  53. package/dist/messages/tool.d.ts +9 -2
  54. package/dist/messages/transformers.d.cts +3 -0
  55. package/dist/messages/transformers.d.ts +3 -0
  56. package/dist/messages/utils.d.cts +5 -2
  57. package/dist/messages/utils.d.ts +5 -2
  58. package/dist/output_parsers/json.d.cts +5 -1
  59. package/dist/output_parsers/json.d.ts +5 -1
  60. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts +6 -2
  61. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts +6 -2
  62. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.cts +34 -10
  63. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.ts +34 -10
  64. package/dist/output_parsers/transform.d.cts +1 -0
  65. package/dist/output_parsers/transform.d.ts +1 -0
  66. package/dist/outputs.d.cts +6 -0
  67. package/dist/outputs.d.ts +6 -0
  68. package/dist/prompts/base.d.cts +10 -2
  69. package/dist/prompts/base.d.ts +10 -2
  70. package/dist/prompts/chat.d.cts +51 -13
  71. package/dist/prompts/chat.d.ts +51 -13
  72. package/dist/prompts/few_shot.d.cts +5 -1
  73. package/dist/prompts/few_shot.d.ts +5 -1
  74. package/dist/prompts/image.d.cts +10 -2
  75. package/dist/prompts/image.d.ts +10 -2
  76. package/dist/prompts/prompt.d.cts +15 -4
  77. package/dist/prompts/prompt.d.ts +16 -4
  78. package/dist/prompts/serde.d.cts +1 -0
  79. package/dist/prompts/serde.d.ts +1 -0
  80. package/dist/prompts/string.d.cts +5 -1
  81. package/dist/prompts/string.d.ts +5 -1
  82. package/dist/prompts/structured.d.cts +16 -3
  83. package/dist/prompts/structured.d.ts +16 -3
  84. package/dist/retrievers/document_compressors/index.d.cts +1 -0
  85. package/dist/retrievers/document_compressors/index.d.ts +1 -0
  86. package/dist/retrievers/index.d.cts +6 -2
  87. package/dist/retrievers/index.d.ts +6 -2
  88. package/dist/runnables/base.cjs +7 -7
  89. package/dist/runnables/base.cjs.map +1 -1
  90. package/dist/runnables/base.d.cts +64 -12
  91. package/dist/runnables/base.d.ts +64 -12
  92. package/dist/runnables/base.js +1 -1
  93. package/dist/runnables/base.js.map +1 -1
  94. package/dist/runnables/branch.d.cts +2 -0
  95. package/dist/runnables/branch.d.ts +2 -0
  96. package/dist/runnables/config.d.cts +1 -0
  97. package/dist/runnables/config.d.ts +1 -0
  98. package/dist/runnables/graph.d.cts +5 -1
  99. package/dist/runnables/graph.d.ts +5 -1
  100. package/dist/runnables/history.d.cts +12 -4
  101. package/dist/runnables/history.d.ts +12 -4
  102. package/dist/runnables/passthrough.d.cts +2 -0
  103. package/dist/runnables/passthrough.d.ts +2 -0
  104. package/dist/runnables/router.d.cts +1 -0
  105. package/dist/runnables/router.d.ts +1 -0
  106. package/dist/runnables/types.d.cts +9 -2
  107. package/dist/runnables/types.d.ts +9 -2
  108. package/dist/singletons/async_local_storage/context.d.cts +2 -0
  109. package/dist/singletons/async_local_storage/context.d.ts +2 -0
  110. package/dist/singletons/async_local_storage/globals.d.cts +1 -0
  111. package/dist/singletons/async_local_storage/globals.d.ts +1 -0
  112. package/dist/singletons/callbacks.cjs.map +1 -1
  113. package/dist/singletons/callbacks.js.map +1 -1
  114. package/dist/stores.d.cts +1 -0
  115. package/dist/stores.d.ts +1 -0
  116. package/dist/structured_query/utils.d.cts +4 -1
  117. package/dist/structured_query/utils.d.ts +4 -1
  118. package/dist/tools/index.d.cts +6 -1
  119. package/dist/tools/index.d.ts +6 -1
  120. package/dist/tools/types.d.cts +13 -3
  121. package/dist/tools/types.d.ts +13 -3
  122. package/dist/tracers/base.d.cts +20 -1
  123. package/dist/tracers/base.d.ts +20 -1
  124. package/dist/tracers/console.cjs +3 -3
  125. package/dist/tracers/console.cjs.map +1 -1
  126. package/dist/tracers/console.d.cts +2 -0
  127. package/dist/tracers/console.d.ts +2 -0
  128. package/dist/tracers/console.js +3 -3
  129. package/dist/tracers/console.js.map +1 -1
  130. package/dist/tracers/event_stream.d.cts +4 -0
  131. package/dist/tracers/event_stream.d.ts +4 -0
  132. package/dist/tracers/log_stream.d.cts +6 -0
  133. package/dist/tracers/log_stream.d.ts +6 -0
  134. package/dist/types/_internal.d.cts +3 -0
  135. package/dist/types/_internal.d.ts +3 -0
  136. package/dist/types/type-utils.d.cts +2 -0
  137. package/dist/types/type-utils.d.ts +2 -0
  138. package/dist/utils/async_caller.cjs +1 -1
  139. package/dist/utils/async_caller.cjs.map +1 -1
  140. package/dist/utils/async_caller.d.cts +3 -0
  141. package/dist/utils/async_caller.d.ts +3 -0
  142. package/dist/utils/async_caller.js +1 -1
  143. package/dist/utils/async_caller.js.map +1 -1
  144. package/dist/utils/env.d.cts +4 -0
  145. package/dist/utils/env.d.ts +4 -0
  146. package/dist/utils/event_source_parse.d.cts +4 -1
  147. package/dist/utils/event_source_parse.d.ts +4 -1
  148. package/dist/utils/function_calling.d.cts +3 -1
  149. package/dist/utils/function_calling.d.ts +3 -1
  150. package/dist/{node_modules/.pnpm/is-network-error@1.3.0/node_modules → utils}/is-network-error/index.cjs +1 -1
  151. package/dist/utils/is-network-error/index.cjs.map +1 -0
  152. package/dist/{node_modules/.pnpm/is-network-error@1.3.0/node_modules → utils}/is-network-error/index.js +1 -1
  153. package/dist/utils/is-network-error/index.js.map +1 -0
  154. package/dist/utils/json.d.cts +1 -0
  155. package/dist/utils/json.d.ts +1 -0
  156. package/dist/{node_modules/.pnpm/p-retry@7.1.0/node_modules → utils}/p-retry/index.cjs +2 -2
  157. package/dist/utils/p-retry/index.cjs.map +1 -0
  158. package/dist/{node_modules/.pnpm/p-retry@7.1.0/node_modules → utils}/p-retry/index.js +2 -2
  159. package/dist/utils/p-retry/index.js.map +1 -0
  160. package/dist/utils/stream.d.cts +13 -1
  161. package/dist/utils/stream.d.ts +13 -1
  162. package/dist/utils/testing/chat_models.d.cts +11 -3
  163. package/dist/utils/testing/chat_models.d.ts +11 -3
  164. package/dist/utils/testing/retrievers.d.cts +3 -1
  165. package/dist/utils/testing/retrievers.d.ts +3 -1
  166. package/dist/utils/testing/vectorstores.d.cts +1 -0
  167. package/dist/utils/testing/vectorstores.d.ts +1 -0
  168. package/dist/utils/types/index.d.cts +2 -0
  169. package/dist/utils/types/index.d.ts +2 -0
  170. package/dist/utils/types/zod.d.cts +3 -0
  171. package/dist/utils/types/zod.d.ts +3 -0
  172. package/dist/vectorstores.d.cts +17 -5
  173. package/dist/vectorstores.d.ts +17 -5
  174. package/package.json +5 -6
  175. package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.cjs +0 -169
  176. package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.cjs.map +0 -1
  177. package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.js +0 -168
  178. package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.js.map +0 -1
  179. package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.cjs +0 -122
  180. package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.cjs.map +0 -1
  181. package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.js +0 -121
  182. package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.js.map +0 -1
  183. package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.cjs +0 -18
  184. package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.cjs.map +0 -1
  185. package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.js +0 -17
  186. package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.js.map +0 -1
  187. package/dist/node_modules/.pnpm/is-network-error@1.3.0/node_modules/is-network-error/index.cjs.map +0 -1
  188. package/dist/node_modules/.pnpm/is-network-error@1.3.0/node_modules/is-network-error/index.js.map +0 -1
  189. package/dist/node_modules/.pnpm/p-retry@7.1.0/node_modules/p-retry/index.cjs.map +0 -1
  190. package/dist/node_modules/.pnpm/p-retry@7.1.0/node_modules/p-retry/index.js.map +0 -1
@@ -11,11 +11,14 @@ import { RunTree } from "langsmith/run_trees";
11
11
 
12
12
  //#region src/tracers/base.d.ts
13
13
  type RunType = string;
14
+ // TODO: Remove this type and just use the base LangSmith Run type.
14
15
  interface Run extends BaseRun {
16
+ // some optional fields are always present here
15
17
  id: string;
16
18
  start_time: number;
17
19
  end_time?: number;
18
20
  execution_order: number;
21
+ // some additional fields that don't exist in sdk runs
19
22
  child_runs: this[];
20
23
  child_execution_order: number;
21
24
  events: Array<{
@@ -55,10 +58,12 @@ declare abstract class BaseTracer extends BaseCallbackHandler {
55
58
  parent_run_id?: string | undefined;
56
59
  tags?: string[] | undefined;
57
60
  attachments?: langsmith_schemas0.Attachments | undefined;
61
+ // some optional fields are always present here
58
62
  id: string;
59
63
  start_time: number;
60
64
  end_time?: number | undefined;
61
65
  execution_order: number;
66
+ // some additional fields that don't exist in sdk runs
62
67
  child_runs: Run[];
63
68
  child_execution_order: number;
64
69
  events: {
@@ -90,10 +95,12 @@ declare abstract class BaseTracer extends BaseCallbackHandler {
90
95
  parent_run_id?: string | undefined;
91
96
  tags?: string[] | undefined;
92
97
  attachments?: langsmith_schemas0.Attachments | undefined;
98
+ // some optional fields are always present here
93
99
  id: string;
94
100
  start_time: number;
95
101
  end_time?: number | undefined;
96
102
  execution_order: number;
103
+ // some additional fields that don't exist in sdk runs
97
104
  child_runs: Run[];
98
105
  child_execution_order: number;
99
106
  events: {
@@ -124,10 +131,12 @@ declare abstract class BaseTracer extends BaseCallbackHandler {
124
131
  parent_run_id?: string | undefined;
125
132
  tags?: string[] | undefined;
126
133
  attachments?: langsmith_schemas0.Attachments | undefined;
134
+ // some optional fields are always present here
127
135
  id: string;
128
136
  start_time: number;
129
137
  end_time?: number | undefined;
130
138
  execution_order: number;
139
+ // some additional fields that don't exist in sdk runs
131
140
  child_runs: Run[];
132
141
  child_execution_order: number;
133
142
  events: {
@@ -160,10 +169,12 @@ declare abstract class BaseTracer extends BaseCallbackHandler {
160
169
  parent_run_id?: string | undefined;
161
170
  tags?: string[] | undefined;
162
171
  attachments?: langsmith_schemas0.Attachments | undefined;
172
+ // some optional fields are always present here
163
173
  id: string;
164
174
  start_time: number;
165
175
  end_time?: number | undefined;
166
176
  execution_order: number;
177
+ // some additional fields that don't exist in sdk runs
167
178
  child_runs: Run[];
168
179
  child_execution_order: number;
169
180
  events: {
@@ -200,10 +211,12 @@ declare abstract class BaseTracer extends BaseCallbackHandler {
200
211
  parent_run_id?: string | undefined;
201
212
  tags?: string[] | undefined;
202
213
  attachments?: langsmith_schemas0.Attachments | undefined;
214
+ // some optional fields are always present here
203
215
  id: string;
204
216
  start_time: number;
205
217
  end_time?: number | undefined;
206
218
  execution_order: number;
219
+ // some additional fields that don't exist in sdk runs
207
220
  child_runs: Run[];
208
221
  child_execution_order: number;
209
222
  events: {
@@ -217,6 +230,7 @@ declare abstract class BaseTracer extends BaseCallbackHandler {
217
230
  _serialized_start_time?: string | undefined;
218
231
  };
219
232
  handleToolStart(tool: Serialized, input: string, runId: string, parentRunId?: string, tags?: string[], metadata?: KVMap, name?: string): Promise<Run>;
233
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
220
234
  handleToolEnd(output: any, runId: string): Promise<Run>;
221
235
  handleToolError(error: unknown, runId: string): Promise<Run>;
222
236
  handleAgentAction(action: AgentAction, runId: string): Promise<void>;
@@ -238,10 +252,12 @@ declare abstract class BaseTracer extends BaseCallbackHandler {
238
252
  parent_run_id?: string | undefined;
239
253
  tags?: string[] | undefined;
240
254
  attachments?: langsmith_schemas0.Attachments | undefined;
255
+ // some optional fields are always present here
241
256
  id: string;
242
257
  start_time: number;
243
258
  end_time?: number | undefined;
244
259
  execution_order: number;
260
+ // some additional fields that don't exist in sdk runs
245
261
  child_runs: Run[];
246
262
  child_execution_order: number;
247
263
  events: {
@@ -259,6 +275,7 @@ declare abstract class BaseTracer extends BaseCallbackHandler {
259
275
  handleRetrieverError(error: unknown, runId: string): Promise<Run>;
260
276
  handleText(text: string, runId: string): Promise<void>;
261
277
  handleLLMNewToken(token: string, idx: NewTokenIndices, runId: string, _parentRunId?: string, _tags?: string[], fields?: HandleLLMNewTokenCallbackFields): Promise<Run>;
278
+ // custom event handlers
262
279
  onRunCreate?(run: Run): void | Promise<void>;
263
280
  onRunUpdate?(run: Run): void | Promise<void>;
264
281
  onLLMStart?(run: Run): void | Promise<void>;
@@ -276,7 +293,9 @@ declare abstract class BaseTracer extends BaseCallbackHandler {
276
293
  onRetrieverEnd?(run: Run): void | Promise<void>;
277
294
  onRetrieverError?(run: Run): void | Promise<void>;
278
295
  onText?(run: Run): void | Promise<void>;
279
- onLLMNewToken?(run: Run, token: string, kwargs?: {
296
+ onLLMNewToken?(run: Run, token: string,
297
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
298
+ kwargs?: {
280
299
  chunk: any;
281
300
  }): void | Promise<void>;
282
301
  }
@@ -11,11 +11,14 @@ import { BaseRun, KVMap } from "langsmith/schemas";
11
11
 
12
12
  //#region src/tracers/base.d.ts
13
13
  type RunType = string;
14
+ // TODO: Remove this type and just use the base LangSmith Run type.
14
15
  interface Run extends BaseRun {
16
+ // some optional fields are always present here
15
17
  id: string;
16
18
  start_time: number;
17
19
  end_time?: number;
18
20
  execution_order: number;
21
+ // some additional fields that don't exist in sdk runs
19
22
  child_runs: this[];
20
23
  child_execution_order: number;
21
24
  events: Array<{
@@ -55,10 +58,12 @@ declare abstract class BaseTracer extends BaseCallbackHandler {
55
58
  parent_run_id?: string | undefined;
56
59
  tags?: string[] | undefined;
57
60
  attachments?: langsmith_schemas0.Attachments | undefined;
61
+ // some optional fields are always present here
58
62
  id: string;
59
63
  start_time: number;
60
64
  end_time?: number | undefined;
61
65
  execution_order: number;
66
+ // some additional fields that don't exist in sdk runs
62
67
  child_runs: Run[];
63
68
  child_execution_order: number;
64
69
  events: {
@@ -90,10 +95,12 @@ declare abstract class BaseTracer extends BaseCallbackHandler {
90
95
  parent_run_id?: string | undefined;
91
96
  tags?: string[] | undefined;
92
97
  attachments?: langsmith_schemas0.Attachments | undefined;
98
+ // some optional fields are always present here
93
99
  id: string;
94
100
  start_time: number;
95
101
  end_time?: number | undefined;
96
102
  execution_order: number;
103
+ // some additional fields that don't exist in sdk runs
97
104
  child_runs: Run[];
98
105
  child_execution_order: number;
99
106
  events: {
@@ -124,10 +131,12 @@ declare abstract class BaseTracer extends BaseCallbackHandler {
124
131
  parent_run_id?: string | undefined;
125
132
  tags?: string[] | undefined;
126
133
  attachments?: langsmith_schemas0.Attachments | undefined;
134
+ // some optional fields are always present here
127
135
  id: string;
128
136
  start_time: number;
129
137
  end_time?: number | undefined;
130
138
  execution_order: number;
139
+ // some additional fields that don't exist in sdk runs
131
140
  child_runs: Run[];
132
141
  child_execution_order: number;
133
142
  events: {
@@ -160,10 +169,12 @@ declare abstract class BaseTracer extends BaseCallbackHandler {
160
169
  parent_run_id?: string | undefined;
161
170
  tags?: string[] | undefined;
162
171
  attachments?: langsmith_schemas0.Attachments | undefined;
172
+ // some optional fields are always present here
163
173
  id: string;
164
174
  start_time: number;
165
175
  end_time?: number | undefined;
166
176
  execution_order: number;
177
+ // some additional fields that don't exist in sdk runs
167
178
  child_runs: Run[];
168
179
  child_execution_order: number;
169
180
  events: {
@@ -200,10 +211,12 @@ declare abstract class BaseTracer extends BaseCallbackHandler {
200
211
  parent_run_id?: string | undefined;
201
212
  tags?: string[] | undefined;
202
213
  attachments?: langsmith_schemas0.Attachments | undefined;
214
+ // some optional fields are always present here
203
215
  id: string;
204
216
  start_time: number;
205
217
  end_time?: number | undefined;
206
218
  execution_order: number;
219
+ // some additional fields that don't exist in sdk runs
207
220
  child_runs: Run[];
208
221
  child_execution_order: number;
209
222
  events: {
@@ -217,6 +230,7 @@ declare abstract class BaseTracer extends BaseCallbackHandler {
217
230
  _serialized_start_time?: string | undefined;
218
231
  };
219
232
  handleToolStart(tool: Serialized, input: string, runId: string, parentRunId?: string, tags?: string[], metadata?: KVMap, name?: string): Promise<Run>;
233
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
220
234
  handleToolEnd(output: any, runId: string): Promise<Run>;
221
235
  handleToolError(error: unknown, runId: string): Promise<Run>;
222
236
  handleAgentAction(action: AgentAction, runId: string): Promise<void>;
@@ -238,10 +252,12 @@ declare abstract class BaseTracer extends BaseCallbackHandler {
238
252
  parent_run_id?: string | undefined;
239
253
  tags?: string[] | undefined;
240
254
  attachments?: langsmith_schemas0.Attachments | undefined;
255
+ // some optional fields are always present here
241
256
  id: string;
242
257
  start_time: number;
243
258
  end_time?: number | undefined;
244
259
  execution_order: number;
260
+ // some additional fields that don't exist in sdk runs
245
261
  child_runs: Run[];
246
262
  child_execution_order: number;
247
263
  events: {
@@ -259,6 +275,7 @@ declare abstract class BaseTracer extends BaseCallbackHandler {
259
275
  handleRetrieverError(error: unknown, runId: string): Promise<Run>;
260
276
  handleText(text: string, runId: string): Promise<void>;
261
277
  handleLLMNewToken(token: string, idx: NewTokenIndices, runId: string, _parentRunId?: string, _tags?: string[], fields?: HandleLLMNewTokenCallbackFields): Promise<Run>;
278
+ // custom event handlers
262
279
  onRunCreate?(run: Run): void | Promise<void>;
263
280
  onRunUpdate?(run: Run): void | Promise<void>;
264
281
  onLLMStart?(run: Run): void | Promise<void>;
@@ -276,7 +293,9 @@ declare abstract class BaseTracer extends BaseCallbackHandler {
276
293
  onRetrieverEnd?(run: Run): void | Promise<void>;
277
294
  onRetrieverError?(run: Run): void | Promise<void>;
278
295
  onText?(run: Run): void | Promise<void>;
279
- onLLMNewToken?(run: Run, token: string, kwargs?: {
296
+ onLLMNewToken?(run: Run, token: string,
297
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
298
+ kwargs?: {
280
299
  chunk: any;
281
300
  }): void | Promise<void>;
282
301
  }
@@ -1,6 +1,6 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_tracers_base = require('./base.cjs');
3
- const require_index = require('../node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.cjs');
3
+ const ansi_styles = require_rolldown_runtime.__toESM(require("ansi-styles"));
4
4
 
5
5
  //#region src/tracers/console.ts
6
6
  var console_exports = {};
@@ -26,7 +26,7 @@ function elapsed(run) {
26
26
  if (elapsed$1 < 1e3) return `${elapsed$1}ms`;
27
27
  return `${(elapsed$1 / 1e3).toFixed(2)}s`;
28
28
  }
29
- const { color } = require_index.default;
29
+ const { color } = ansi_styles.default;
30
30
  /**
31
31
  * A tracer that logs all events to the console. It extends from the
32
32
  * `BaseTracer` class and overrides its methods to provide custom logging
@@ -80,7 +80,7 @@ var ConsoleCallbackHandler = class extends require_tracers_base.BaseTracer {
80
80
  const parents = this.getParents(run).reverse();
81
81
  const string = [...parents, run].map((parent, i, arr) => {
82
82
  const name = `${parent.execution_order}:${parent.run_type}:${parent.name}`;
83
- return i === arr.length - 1 ? wrap(require_index.default.bold, name) : name;
83
+ return i === arr.length - 1 ? wrap(ansi_styles.default.bold, name) : name;
84
84
  }).join(" > ");
85
85
  return wrap(color.grey, string);
86
86
  }
@@ -1 +1 @@
1
- {"version":3,"file":"console.cjs","names":["style: CSPair","text: string","obj: unknown","fallback: string","value: unknown","run: Run","elapsed","styles","BaseTracer","_run: Run","parents: Run[]"],"sources":["../../src/tracers/console.ts"],"sourcesContent":["import type { CSPair } from \"ansi-styles\";\nimport styles from \"ansi-styles\";\nimport { BaseTracer, type AgentRun, type Run } from \"./base.js\";\n\nfunction wrap(style: CSPair, text: string) {\n return `${style.open}${text}${style.close}`;\n}\n\nfunction tryJsonStringify(obj: unknown, fallback: string) {\n try {\n return JSON.stringify(obj, null, 2);\n } catch {\n return fallback;\n }\n}\n\nfunction formatKVMapItem(value: unknown) {\n if (typeof value === \"string\") {\n return value.trim();\n }\n\n if (value === null || value === undefined) {\n return value;\n }\n\n return tryJsonStringify(value, value.toString());\n}\n\nfunction elapsed(run: Run): string {\n if (!run.end_time) return \"\";\n const elapsed = run.end_time - run.start_time;\n if (elapsed < 1000) {\n return `${elapsed}ms`;\n }\n return `${(elapsed / 1000).toFixed(2)}s`;\n}\n\nconst { color } = styles;\n\n/**\n * A tracer that logs all events to the console. It extends from the\n * `BaseTracer` class and overrides its methods to provide custom logging\n * functionality.\n * @example\n * ```typescript\n *\n * const llm = new ChatAnthropic({\n * temperature: 0,\n * tags: [\"example\", \"callbacks\", \"constructor\"],\n * callbacks: [new ConsoleCallbackHandler()],\n * });\n *\n * ```\n */\nexport class ConsoleCallbackHandler extends BaseTracer {\n name = \"console_callback_handler\" as const;\n\n /**\n * Method used to persist the run. In this case, it simply returns a\n * resolved promise as there's no persistence logic.\n * @param _run The run to persist.\n * @returns A resolved promise.\n */\n protected persistRun(_run: Run) {\n return Promise.resolve();\n }\n\n // utility methods\n\n /**\n * Method used to get all the parent runs of a given run.\n * @param run The run whose parents are to be retrieved.\n * @returns An array of parent runs.\n */\n getParents(run: Run) {\n const parents: Run[] = [];\n let currentRun = run;\n while (currentRun.parent_run_id) {\n const parent = this.runMap.get(currentRun.parent_run_id);\n if (parent) {\n parents.push(parent);\n currentRun = parent;\n } else {\n break;\n }\n }\n return parents;\n }\n\n /**\n * Method used to get a string representation of the run's lineage, which\n * is used in logging.\n * @param run The run whose lineage is to be retrieved.\n * @returns A string representation of the run's lineage.\n */\n getBreadcrumbs(run: Run) {\n const parents = this.getParents(run).reverse();\n const string = [...parents, run]\n .map((parent, i, arr) => {\n const name = `${parent.execution_order}:${parent.run_type}:${parent.name}`;\n return i === arr.length - 1 ? wrap(styles.bold, name) : name;\n })\n .join(\" > \");\n return wrap(color.grey, string);\n }\n\n // logging methods\n\n /**\n * Method used to log the start of a chain run.\n * @param run The chain run that has started.\n * @returns void\n */\n onChainStart(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(\n color.green,\n \"[chain/start]\"\n )} [${crumbs}] Entering Chain run with input: ${tryJsonStringify(\n run.inputs,\n \"[inputs]\"\n )}`\n );\n }\n\n /**\n * Method used to log the end of a chain run.\n * @param run The chain run that has ended.\n * @returns void\n */\n onChainEnd(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.cyan, \"[chain/end]\")} [${crumbs}] [${elapsed(\n run\n )}] Exiting Chain run with output: ${tryJsonStringify(\n run.outputs,\n \"[outputs]\"\n )}`\n );\n }\n\n /**\n * Method used to log any errors of a chain run.\n * @param run The chain run that has errored.\n * @returns void\n */\n onChainError(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.red, \"[chain/error]\")} [${crumbs}] [${elapsed(\n run\n )}] Chain run errored with error: ${tryJsonStringify(\n run.error,\n \"[error]\"\n )}`\n );\n }\n\n /**\n * Method used to log the start of an LLM run.\n * @param run The LLM run that has started.\n * @returns void\n */\n onLLMStart(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n const inputs =\n \"prompts\" in run.inputs\n ? { prompts: (run.inputs.prompts as string[]).map((p) => p.trim()) }\n : run.inputs;\n console.log(\n `${wrap(\n color.green,\n \"[llm/start]\"\n )} [${crumbs}] Entering LLM run with input: ${tryJsonStringify(\n inputs,\n \"[inputs]\"\n )}`\n );\n }\n\n /**\n * Method used to log the end of an LLM run.\n * @param run The LLM run that has ended.\n * @returns void\n */\n onLLMEnd(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.cyan, \"[llm/end]\")} [${crumbs}] [${elapsed(\n run\n )}] Exiting LLM run with output: ${tryJsonStringify(\n run.outputs,\n \"[response]\"\n )}`\n );\n }\n\n /**\n * Method used to log any errors of an LLM run.\n * @param run The LLM run that has errored.\n * @returns void\n */\n onLLMError(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.red, \"[llm/error]\")} [${crumbs}] [${elapsed(\n run\n )}] LLM run errored with error: ${tryJsonStringify(run.error, \"[error]\")}`\n );\n }\n\n /**\n * Method used to log the start of a tool run.\n * @param run The tool run that has started.\n * @returns void\n */\n onToolStart(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(\n color.green,\n \"[tool/start]\"\n )} [${crumbs}] Entering Tool run with input: \"${formatKVMapItem(\n run.inputs.input\n )}\"`\n );\n }\n\n /**\n * Method used to log the end of a tool run.\n * @param run The tool run that has ended.\n * @returns void\n */\n onToolEnd(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n\n console.log(\n `${wrap(color.cyan, \"[tool/end]\")} [${crumbs}] [${elapsed(\n run\n )}] Exiting Tool run with output: \"${formatKVMapItem(\n run.outputs?.output\n )}\"`\n );\n }\n\n /**\n * Method used to log any errors of a tool run.\n * @param run The tool run that has errored.\n * @returns void\n */\n onToolError(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.red, \"[tool/error]\")} [${crumbs}] [${elapsed(\n run\n )}] Tool run errored with error: ${tryJsonStringify(\n run.error,\n \"[error]\"\n )}`\n );\n }\n\n /**\n * Method used to log the start of a retriever run.\n * @param run The retriever run that has started.\n * @returns void\n */\n onRetrieverStart(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(\n color.green,\n \"[retriever/start]\"\n )} [${crumbs}] Entering Retriever run with input: ${tryJsonStringify(\n run.inputs,\n \"[inputs]\"\n )}`\n );\n }\n\n /**\n * Method used to log the end of a retriever run.\n * @param run The retriever run that has ended.\n * @returns void\n */\n onRetrieverEnd(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.cyan, \"[retriever/end]\")} [${crumbs}] [${elapsed(\n run\n )}] Exiting Retriever run with output: ${tryJsonStringify(\n run.outputs,\n \"[outputs]\"\n )}`\n );\n }\n\n /**\n * Method used to log any errors of a retriever run.\n * @param run The retriever run that has errored.\n * @returns void\n */\n onRetrieverError(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.red, \"[retriever/error]\")} [${crumbs}] [${elapsed(\n run\n )}] Retriever run errored with error: ${tryJsonStringify(\n run.error,\n \"[error]\"\n )}`\n );\n }\n\n /**\n * Method used to log the action selected by the agent.\n * @param run The run in which the agent action occurred.\n * @returns void\n */\n onAgentAction(run: Run) {\n const agentRun = run as AgentRun;\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(\n color.blue,\n \"[agent/action]\"\n )} [${crumbs}] Agent selected action: ${tryJsonStringify(\n agentRun.actions[agentRun.actions.length - 1],\n \"[action]\"\n )}`\n );\n }\n}\n"],"mappings":";;;;;;;AAIA,SAAS,KAAKA,OAAeC,MAAc;AACzC,QAAO,GAAG,MAAM,OAAO,OAAO,MAAM,OAAO;AAC5C;AAED,SAAS,iBAAiBC,KAAcC,UAAkB;AACxD,KAAI;AACF,SAAO,KAAK,UAAU,KAAK,MAAM,EAAE;CACpC,QAAO;AACN,SAAO;CACR;AACF;AAED,SAAS,gBAAgBC,OAAgB;AACvC,KAAI,OAAO,UAAU,SACnB,QAAO,MAAM,MAAM;AAGrB,KAAI,UAAU,QAAQ,UAAU,OAC9B,QAAO;AAGT,QAAO,iBAAiB,OAAO,MAAM,UAAU,CAAC;AACjD;AAED,SAAS,QAAQC,KAAkB;AACjC,KAAI,CAAC,IAAI,SAAU,QAAO;CAC1B,MAAMC,YAAU,IAAI,WAAW,IAAI;AACn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,EAAE,iBACtC,SAAS,QAAQ,SAAS,QAAQ,SAAS,IAC3C,WACD,EAAE,CACJ;CACF;AACF"}
1
+ {"version":3,"file":"console.cjs","names":["style: CSPair","text: string","obj: unknown","fallback: string","value: unknown","run: Run","elapsed","styles","BaseTracer","_run: Run","parents: Run[]"],"sources":["../../src/tracers/console.ts"],"sourcesContent":["import type { CSPair } from \"ansi-styles\";\nimport styles from \"ansi-styles\";\nimport { BaseTracer, type AgentRun, type Run } from \"./base.js\";\n\nfunction wrap(style: CSPair, text: string) {\n return `${style.open}${text}${style.close}`;\n}\n\nfunction tryJsonStringify(obj: unknown, fallback: string) {\n try {\n return JSON.stringify(obj, null, 2);\n } catch {\n return fallback;\n }\n}\n\nfunction formatKVMapItem(value: unknown) {\n if (typeof value === \"string\") {\n return value.trim();\n }\n\n if (value === null || value === undefined) {\n return value;\n }\n\n return tryJsonStringify(value, value.toString());\n}\n\nfunction elapsed(run: Run): string {\n if (!run.end_time) return \"\";\n const elapsed = run.end_time - run.start_time;\n if (elapsed < 1000) {\n return `${elapsed}ms`;\n }\n return `${(elapsed / 1000).toFixed(2)}s`;\n}\n\nconst { color } = styles;\n\n/**\n * A tracer that logs all events to the console. It extends from the\n * `BaseTracer` class and overrides its methods to provide custom logging\n * functionality.\n * @example\n * ```typescript\n *\n * const llm = new ChatAnthropic({\n * temperature: 0,\n * tags: [\"example\", \"callbacks\", \"constructor\"],\n * callbacks: [new ConsoleCallbackHandler()],\n * });\n *\n * ```\n */\nexport class ConsoleCallbackHandler extends BaseTracer {\n name = \"console_callback_handler\" as const;\n\n /**\n * Method used to persist the run. In this case, it simply returns a\n * resolved promise as there's no persistence logic.\n * @param _run The run to persist.\n * @returns A resolved promise.\n */\n protected persistRun(_run: Run) {\n return Promise.resolve();\n }\n\n // utility methods\n\n /**\n * Method used to get all the parent runs of a given run.\n * @param run The run whose parents are to be retrieved.\n * @returns An array of parent runs.\n */\n getParents(run: Run) {\n const parents: Run[] = [];\n let currentRun = run;\n while (currentRun.parent_run_id) {\n const parent = this.runMap.get(currentRun.parent_run_id);\n if (parent) {\n parents.push(parent);\n currentRun = parent;\n } else {\n break;\n }\n }\n return parents;\n }\n\n /**\n * Method used to get a string representation of the run's lineage, which\n * is used in logging.\n * @param run The run whose lineage is to be retrieved.\n * @returns A string representation of the run's lineage.\n */\n getBreadcrumbs(run: Run) {\n const parents = this.getParents(run).reverse();\n const string = [...parents, run]\n .map((parent, i, arr) => {\n const name = `${parent.execution_order}:${parent.run_type}:${parent.name}`;\n return i === arr.length - 1 ? wrap(styles.bold, name) : name;\n })\n .join(\" > \");\n return wrap(color.grey, string);\n }\n\n // logging methods\n\n /**\n * Method used to log the start of a chain run.\n * @param run The chain run that has started.\n * @returns void\n */\n onChainStart(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(\n color.green,\n \"[chain/start]\"\n )} [${crumbs}] Entering Chain run with input: ${tryJsonStringify(\n run.inputs,\n \"[inputs]\"\n )}`\n );\n }\n\n /**\n * Method used to log the end of a chain run.\n * @param run The chain run that has ended.\n * @returns void\n */\n onChainEnd(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.cyan, \"[chain/end]\")} [${crumbs}] [${elapsed(\n run\n )}] Exiting Chain run with output: ${tryJsonStringify(\n run.outputs,\n \"[outputs]\"\n )}`\n );\n }\n\n /**\n * Method used to log any errors of a chain run.\n * @param run The chain run that has errored.\n * @returns void\n */\n onChainError(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.red, \"[chain/error]\")} [${crumbs}] [${elapsed(\n run\n )}] Chain run errored with error: ${tryJsonStringify(\n run.error,\n \"[error]\"\n )}`\n );\n }\n\n /**\n * Method used to log the start of an LLM run.\n * @param run The LLM run that has started.\n * @returns void\n */\n onLLMStart(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n const inputs =\n \"prompts\" in run.inputs\n ? { prompts: (run.inputs.prompts as string[]).map((p) => p.trim()) }\n : run.inputs;\n console.log(\n `${wrap(\n color.green,\n \"[llm/start]\"\n )} [${crumbs}] Entering LLM run with input: ${tryJsonStringify(\n inputs,\n \"[inputs]\"\n )}`\n );\n }\n\n /**\n * Method used to log the end of an LLM run.\n * @param run The LLM run that has ended.\n * @returns void\n */\n onLLMEnd(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.cyan, \"[llm/end]\")} [${crumbs}] [${elapsed(\n run\n )}] Exiting LLM run with output: ${tryJsonStringify(\n run.outputs,\n \"[response]\"\n )}`\n );\n }\n\n /**\n * Method used to log any errors of an LLM run.\n * @param run The LLM run that has errored.\n * @returns void\n */\n onLLMError(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.red, \"[llm/error]\")} [${crumbs}] [${elapsed(\n run\n )}] LLM run errored with error: ${tryJsonStringify(run.error, \"[error]\")}`\n );\n }\n\n /**\n * Method used to log the start of a tool run.\n * @param run The tool run that has started.\n * @returns void\n */\n onToolStart(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(\n color.green,\n \"[tool/start]\"\n )} [${crumbs}] Entering Tool run with input: \"${formatKVMapItem(\n run.inputs.input\n )}\"`\n );\n }\n\n /**\n * Method used to log the end of a tool run.\n * @param run The tool run that has ended.\n * @returns void\n */\n onToolEnd(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n\n console.log(\n `${wrap(color.cyan, \"[tool/end]\")} [${crumbs}] [${elapsed(\n run\n )}] Exiting Tool run with output: \"${formatKVMapItem(\n run.outputs?.output\n )}\"`\n );\n }\n\n /**\n * Method used to log any errors of a tool run.\n * @param run The tool run that has errored.\n * @returns void\n */\n onToolError(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.red, \"[tool/error]\")} [${crumbs}] [${elapsed(\n run\n )}] Tool run errored with error: ${tryJsonStringify(\n run.error,\n \"[error]\"\n )}`\n );\n }\n\n /**\n * Method used to log the start of a retriever run.\n * @param run The retriever run that has started.\n * @returns void\n */\n onRetrieverStart(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(\n color.green,\n \"[retriever/start]\"\n )} [${crumbs}] Entering Retriever run with input: ${tryJsonStringify(\n run.inputs,\n \"[inputs]\"\n )}`\n );\n }\n\n /**\n * Method used to log the end of a retriever run.\n * @param run The retriever run that has ended.\n * @returns void\n */\n onRetrieverEnd(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.cyan, \"[retriever/end]\")} [${crumbs}] [${elapsed(\n run\n )}] Exiting Retriever run with output: ${tryJsonStringify(\n run.outputs,\n \"[outputs]\"\n )}`\n );\n }\n\n /**\n * Method used to log any errors of a retriever run.\n * @param run The retriever run that has errored.\n * @returns void\n */\n onRetrieverError(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.red, \"[retriever/error]\")} [${crumbs}] [${elapsed(\n run\n )}] Retriever run errored with error: ${tryJsonStringify(\n run.error,\n \"[error]\"\n )}`\n );\n }\n\n /**\n * Method used to log the action selected by the agent.\n * @param run The run in which the agent action occurred.\n * @returns void\n */\n onAgentAction(run: Run) {\n const agentRun = run as AgentRun;\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(\n color.blue,\n \"[agent/action]\"\n )} [${crumbs}] Agent selected action: ${tryJsonStringify(\n agentRun.actions[agentRun.actions.length - 1],\n \"[action]\"\n )}`\n );\n }\n}\n"],"mappings":";;;;;;;AAIA,SAAS,KAAKA,OAAeC,MAAc;AACzC,QAAO,GAAG,MAAM,OAAO,OAAO,MAAM,OAAO;AAC5C;AAED,SAAS,iBAAiBC,KAAcC,UAAkB;AACxD,KAAI;AACF,SAAO,KAAK,UAAU,KAAK,MAAM,EAAE;CACpC,QAAO;AACN,SAAO;CACR;AACF;AAED,SAAS,gBAAgBC,OAAgB;AACvC,KAAI,OAAO,UAAU,SACnB,QAAO,MAAM,MAAM;AAGrB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tC,IAAI,OACJ,UACD,EAAE,CACJ;CACF;;;;;;CAOD,cAAcA,KAAU;EACtB,MAAM,WAAW;EACjB,MAAM,SAAS,KAAK,eAAe,IAAI;EACvC,QAAQ,IACN,GAAG,KACD,MAAM,MACN,iBACD,CAAC,EAAE,EAAE,OAAO,yBAAyB,EAAE,iBACtC,SAAS,QAAQ,SAAS,QAAQ,SAAS,IAC3C,WACD,EAAE,CACJ;CACF;AACF"}
@@ -26,6 +26,7 @@ declare class ConsoleCallbackHandler extends BaseTracer {
26
26
  * @returns A resolved promise.
27
27
  */
28
28
  protected persistRun(_run: Run): Promise<void>;
29
+ // utility methods
29
30
  /**
30
31
  * Method used to get all the parent runs of a given run.
31
32
  * @param run The run whose parents are to be retrieved.
@@ -39,6 +40,7 @@ declare class ConsoleCallbackHandler extends BaseTracer {
39
40
  * @returns A string representation of the run's lineage.
40
41
  */
41
42
  getBreadcrumbs(run: Run): string;
43
+ // logging methods
42
44
  /**
43
45
  * Method used to log the start of a chain run.
44
46
  * @param run The chain run that has started.
@@ -26,6 +26,7 @@ declare class ConsoleCallbackHandler extends BaseTracer {
26
26
  * @returns A resolved promise.
27
27
  */
28
28
  protected persistRun(_run: Run): Promise<void>;
29
+ // utility methods
29
30
  /**
30
31
  * Method used to get all the parent runs of a given run.
31
32
  * @param run The run whose parents are to be retrieved.
@@ -39,6 +40,7 @@ declare class ConsoleCallbackHandler extends BaseTracer {
39
40
  * @returns A string representation of the run's lineage.
40
41
  */
41
42
  getBreadcrumbs(run: Run): string;
43
+ // logging methods
42
44
  /**
43
45
  * Method used to log the start of a chain run.
44
46
  * @param run The chain run that has started.
@@ -1,6 +1,6 @@
1
1
  import { __export } from "../_virtual/rolldown_runtime.js";
2
2
  import { BaseTracer } from "./base.js";
3
- import ansi_styles_default from "../node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.js";
3
+ import styles from "ansi-styles";
4
4
 
5
5
  //#region src/tracers/console.ts
6
6
  var console_exports = {};
@@ -26,7 +26,7 @@ function elapsed(run) {
26
26
  if (elapsed$1 < 1e3) return `${elapsed$1}ms`;
27
27
  return `${(elapsed$1 / 1e3).toFixed(2)}s`;
28
28
  }
29
- const { color } = ansi_styles_default;
29
+ const { color } = styles;
30
30
  /**
31
31
  * A tracer that logs all events to the console. It extends from the
32
32
  * `BaseTracer` class and overrides its methods to provide custom logging
@@ -80,7 +80,7 @@ var ConsoleCallbackHandler = class extends BaseTracer {
80
80
  const parents = this.getParents(run).reverse();
81
81
  const string = [...parents, run].map((parent, i, arr) => {
82
82
  const name = `${parent.execution_order}:${parent.run_type}:${parent.name}`;
83
- return i === arr.length - 1 ? wrap(ansi_styles_default.bold, name) : name;
83
+ return i === arr.length - 1 ? wrap(styles.bold, name) : name;
84
84
  }).join(" > ");
85
85
  return wrap(color.grey, string);
86
86
  }
@@ -1 +1 @@
1
- {"version":3,"file":"console.js","names":["style: CSPair","text: string","obj: unknown","fallback: string","value: unknown","run: Run","elapsed","styles","_run: Run","parents: Run[]"],"sources":["../../src/tracers/console.ts"],"sourcesContent":["import type { CSPair } from \"ansi-styles\";\nimport styles from \"ansi-styles\";\nimport { BaseTracer, type AgentRun, type Run } from \"./base.js\";\n\nfunction wrap(style: CSPair, text: string) {\n return `${style.open}${text}${style.close}`;\n}\n\nfunction tryJsonStringify(obj: unknown, fallback: string) {\n try {\n return JSON.stringify(obj, null, 2);\n } catch {\n return fallback;\n }\n}\n\nfunction formatKVMapItem(value: unknown) {\n if (typeof value === \"string\") {\n return value.trim();\n }\n\n if (value === null || value === undefined) {\n return value;\n }\n\n return tryJsonStringify(value, value.toString());\n}\n\nfunction elapsed(run: Run): string {\n if (!run.end_time) return \"\";\n const elapsed = run.end_time - run.start_time;\n if (elapsed < 1000) {\n return `${elapsed}ms`;\n }\n return `${(elapsed / 1000).toFixed(2)}s`;\n}\n\nconst { color } = styles;\n\n/**\n * A tracer that logs all events to the console. It extends from the\n * `BaseTracer` class and overrides its methods to provide custom logging\n * functionality.\n * @example\n * ```typescript\n *\n * const llm = new ChatAnthropic({\n * temperature: 0,\n * tags: [\"example\", \"callbacks\", \"constructor\"],\n * callbacks: [new ConsoleCallbackHandler()],\n * });\n *\n * ```\n */\nexport class ConsoleCallbackHandler extends BaseTracer {\n name = \"console_callback_handler\" as const;\n\n /**\n * Method used to persist the run. In this case, it simply returns a\n * resolved promise as there's no persistence logic.\n * @param _run The run to persist.\n * @returns A resolved promise.\n */\n protected persistRun(_run: Run) {\n return Promise.resolve();\n }\n\n // utility methods\n\n /**\n * Method used to get all the parent runs of a given run.\n * @param run The run whose parents are to be retrieved.\n * @returns An array of parent runs.\n */\n getParents(run: Run) {\n const parents: Run[] = [];\n let currentRun = run;\n while (currentRun.parent_run_id) {\n const parent = this.runMap.get(currentRun.parent_run_id);\n if (parent) {\n parents.push(parent);\n currentRun = parent;\n } else {\n break;\n }\n }\n return parents;\n }\n\n /**\n * Method used to get a string representation of the run's lineage, which\n * is used in logging.\n * @param run The run whose lineage is to be retrieved.\n * @returns A string representation of the run's lineage.\n */\n getBreadcrumbs(run: Run) {\n const parents = this.getParents(run).reverse();\n const string = [...parents, run]\n .map((parent, i, arr) => {\n const name = `${parent.execution_order}:${parent.run_type}:${parent.name}`;\n return i === arr.length - 1 ? wrap(styles.bold, name) : name;\n })\n .join(\" > \");\n return wrap(color.grey, string);\n }\n\n // logging methods\n\n /**\n * Method used to log the start of a chain run.\n * @param run The chain run that has started.\n * @returns void\n */\n onChainStart(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(\n color.green,\n \"[chain/start]\"\n )} [${crumbs}] Entering Chain run with input: ${tryJsonStringify(\n run.inputs,\n \"[inputs]\"\n )}`\n );\n }\n\n /**\n * Method used to log the end of a chain run.\n * @param run The chain run that has ended.\n * @returns void\n */\n onChainEnd(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.cyan, \"[chain/end]\")} [${crumbs}] [${elapsed(\n run\n )}] Exiting Chain run with output: ${tryJsonStringify(\n run.outputs,\n \"[outputs]\"\n )}`\n );\n }\n\n /**\n * Method used to log any errors of a chain run.\n * @param run The chain run that has errored.\n * @returns void\n */\n onChainError(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.red, \"[chain/error]\")} [${crumbs}] [${elapsed(\n run\n )}] Chain run errored with error: ${tryJsonStringify(\n run.error,\n \"[error]\"\n )}`\n );\n }\n\n /**\n * Method used to log the start of an LLM run.\n * @param run The LLM run that has started.\n * @returns void\n */\n onLLMStart(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n const inputs =\n \"prompts\" in run.inputs\n ? { prompts: (run.inputs.prompts as string[]).map((p) => p.trim()) }\n : run.inputs;\n console.log(\n `${wrap(\n color.green,\n \"[llm/start]\"\n )} [${crumbs}] Entering LLM run with input: ${tryJsonStringify(\n inputs,\n \"[inputs]\"\n )}`\n );\n }\n\n /**\n * Method used to log the end of an LLM run.\n * @param run The LLM run that has ended.\n * @returns void\n */\n onLLMEnd(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.cyan, \"[llm/end]\")} [${crumbs}] [${elapsed(\n run\n )}] Exiting LLM run with output: ${tryJsonStringify(\n run.outputs,\n \"[response]\"\n )}`\n );\n }\n\n /**\n * Method used to log any errors of an LLM run.\n * @param run The LLM run that has errored.\n * @returns void\n */\n onLLMError(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.red, \"[llm/error]\")} [${crumbs}] [${elapsed(\n run\n )}] LLM run errored with error: ${tryJsonStringify(run.error, \"[error]\")}`\n );\n }\n\n /**\n * Method used to log the start of a tool run.\n * @param run The tool run that has started.\n * @returns void\n */\n onToolStart(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(\n color.green,\n \"[tool/start]\"\n )} [${crumbs}] Entering Tool run with input: \"${formatKVMapItem(\n run.inputs.input\n )}\"`\n );\n }\n\n /**\n * Method used to log the end of a tool run.\n * @param run The tool run that has ended.\n * @returns void\n */\n onToolEnd(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n\n console.log(\n `${wrap(color.cyan, \"[tool/end]\")} [${crumbs}] [${elapsed(\n run\n )}] Exiting Tool run with output: \"${formatKVMapItem(\n run.outputs?.output\n )}\"`\n );\n }\n\n /**\n * Method used to log any errors of a tool run.\n * @param run The tool run that has errored.\n * @returns void\n */\n onToolError(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.red, \"[tool/error]\")} [${crumbs}] [${elapsed(\n run\n )}] Tool run errored with error: ${tryJsonStringify(\n run.error,\n \"[error]\"\n )}`\n );\n }\n\n /**\n * Method used to log the start of a retriever run.\n * @param run The retriever run that has started.\n * @returns void\n */\n onRetrieverStart(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(\n color.green,\n \"[retriever/start]\"\n )} [${crumbs}] Entering Retriever run with input: ${tryJsonStringify(\n run.inputs,\n \"[inputs]\"\n )}`\n );\n }\n\n /**\n * Method used to log the end of a retriever run.\n * @param run The retriever run that has ended.\n * @returns void\n */\n onRetrieverEnd(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.cyan, \"[retriever/end]\")} [${crumbs}] [${elapsed(\n run\n )}] Exiting Retriever run with output: ${tryJsonStringify(\n run.outputs,\n \"[outputs]\"\n )}`\n );\n }\n\n /**\n * Method used to log any errors of a retriever run.\n * @param run The retriever run that has errored.\n * @returns void\n */\n onRetrieverError(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.red, \"[retriever/error]\")} [${crumbs}] [${elapsed(\n run\n )}] Retriever run errored with error: ${tryJsonStringify(\n run.error,\n \"[error]\"\n )}`\n );\n }\n\n /**\n * Method used to log the action selected by the agent.\n * @param run The run in which the agent action occurred.\n * @returns void\n */\n onAgentAction(run: Run) {\n const agentRun = run as AgentRun;\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(\n color.blue,\n \"[agent/action]\"\n )} [${crumbs}] Agent selected action: ${tryJsonStringify(\n agentRun.actions[agentRun.actions.length - 1],\n \"[action]\"\n )}`\n );\n }\n}\n"],"mappings":";;;;;;;AAIA,SAAS,KAAKA,OAAeC,MAAc;AACzC,QAAO,GAAG,MAAM,OAAO,OAAO,MAAM,OAAO;AAC5C;AAED,SAAS,iBAAiBC,KAAcC,UAAkB;AACxD,KAAI;AACF,SAAO,KAAK,UAAU,KAAK,MAAM,EAAE;CACpC,QAAO;AACN,SAAO;CACR;AACF;AAED,SAAS,gBAAgBC,OAAgB;AACvC,KAAI,OAAO,UAAU,SACnB,QAAO,MAAM,MAAM;AAGrB,KAAI,UAAU,QAAQ,UAAU,OAC9B,QAAO;AAGT,QAAO,iBAAiB,OAAO,MAAM,UAAU,CAAC;AACjD;AAED,SAAS,QAAQC,KAAkB;AACjC,KAAI,CAAC,IAAI,SAAU,QAAO;CAC1B,MAAMC,YAAU,IAAI,WAAW,IAAI;AACnC,KAAIA,YAAU,IACZ,QAAO,GAAGA,UAAQ,EAAE,CAAC;AAEvB,QAAO,IAAIA,YAAU,KAAM,QAAQ,EAAE,CAAC,CAAC,CAAC;AACzC;AAED,MAAM,EAAE,OAAO,GAAGC;;;;;;;;;;;;;;;;AAiBlB,IAAa,yBAAb,cAA4C,WAAW;CACrD,OAAO;;;;;;;CAQP,AAAU,WAAWC,MAAW;AAC9B,SAAO,QAAQ,SAAS;CACzB;;;;;;CASD,WAAWH,KAAU;EACnB,MAAMI,UAAiB,CAAE;EACzB,IAAI,aAAa;AACjB,SAAO,WAAW,eAAe;GAC/B,MAAM,SAAS,KAAK,OAAO,IAAI,WAAW,cAAc;AACxD,OAAI,QAAQ;IACV,QAAQ,KAAK,OAAO;IACpB,aAAa;GACd,MACC;EAEH;AACD,SAAO;CACR;;;;;;;CAQD,eAAeJ,KAAU;EACvB,MAAM,UAAU,KAAK,WAAW,IAAI,CAAC,SAAS;EAC9C,MAAM,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,QACJ,WACD,EAAE,CACJ;CACF;;;;;;CAOD,eAAeA,KAAU;EACvB,MAAM,SAAS,KAAK,eAAe,IAAI;EACvC,QAAQ,IACN,GAAG,KAAK,MAAM,MAAM,kBAAkB,CAAC,EAAE,EAAE,OAAO,GAAG,EAAE,QACrD,IACD,CAAC,qCAAqC,EAAE,iBACvC,IAAI,SACJ,YACD,EAAE,CACJ;CACF;;;;;;CAOD,iBAAiBA,KAAU;EACzB,MAAM,SAAS,KAAK,eAAe,IAAI;EACvC,QAAQ,IACN,GAAG,KAAK,MAAM,KAAK,oBAAoB,CAAC,EAAE,EAAE,OAAO,GAAG,EAAE,QACtD,IACD,CAAC,oCAAoC,EAAE,iBACtC,IAAI,OACJ,UACD,EAAE,CACJ;CACF;;;;;;CAOD,cAAcA,KAAU;EACtB,MAAM,WAAW;EACjB,MAAM,SAAS,KAAK,eAAe,IAAI;EACvC,QAAQ,IACN,GAAG,KACD,MAAM,MACN,iBACD,CAAC,EAAE,EAAE,OAAO,yBAAyB,EAAE,iBACtC,SAAS,QAAQ,SAAS,QAAQ,SAAS,IAC3C,WACD,EAAE,CACJ;CACF;AACF"}
1
+ {"version":3,"file":"console.js","names":["style: CSPair","text: string","obj: unknown","fallback: string","value: unknown","run: Run","elapsed","_run: Run","parents: Run[]"],"sources":["../../src/tracers/console.ts"],"sourcesContent":["import type { CSPair } from \"ansi-styles\";\nimport styles from \"ansi-styles\";\nimport { BaseTracer, type AgentRun, type Run } from \"./base.js\";\n\nfunction wrap(style: CSPair, text: string) {\n return `${style.open}${text}${style.close}`;\n}\n\nfunction tryJsonStringify(obj: unknown, fallback: string) {\n try {\n return JSON.stringify(obj, null, 2);\n } catch {\n return fallback;\n }\n}\n\nfunction formatKVMapItem(value: unknown) {\n if (typeof value === \"string\") {\n return value.trim();\n }\n\n if (value === null || value === undefined) {\n return value;\n }\n\n return tryJsonStringify(value, value.toString());\n}\n\nfunction elapsed(run: Run): string {\n if (!run.end_time) return \"\";\n const elapsed = run.end_time - run.start_time;\n if (elapsed < 1000) {\n return `${elapsed}ms`;\n }\n return `${(elapsed / 1000).toFixed(2)}s`;\n}\n\nconst { color } = styles;\n\n/**\n * A tracer that logs all events to the console. It extends from the\n * `BaseTracer` class and overrides its methods to provide custom logging\n * functionality.\n * @example\n * ```typescript\n *\n * const llm = new ChatAnthropic({\n * temperature: 0,\n * tags: [\"example\", \"callbacks\", \"constructor\"],\n * callbacks: [new ConsoleCallbackHandler()],\n * });\n *\n * ```\n */\nexport class ConsoleCallbackHandler extends BaseTracer {\n name = \"console_callback_handler\" as const;\n\n /**\n * Method used to persist the run. In this case, it simply returns a\n * resolved promise as there's no persistence logic.\n * @param _run The run to persist.\n * @returns A resolved promise.\n */\n protected persistRun(_run: Run) {\n return Promise.resolve();\n }\n\n // utility methods\n\n /**\n * Method used to get all the parent runs of a given run.\n * @param run The run whose parents are to be retrieved.\n * @returns An array of parent runs.\n */\n getParents(run: Run) {\n const parents: Run[] = [];\n let currentRun = run;\n while (currentRun.parent_run_id) {\n const parent = this.runMap.get(currentRun.parent_run_id);\n if (parent) {\n parents.push(parent);\n currentRun = parent;\n } else {\n break;\n }\n }\n return parents;\n }\n\n /**\n * Method used to get a string representation of the run's lineage, which\n * is used in logging.\n * @param run The run whose lineage is to be retrieved.\n * @returns A string representation of the run's lineage.\n */\n getBreadcrumbs(run: Run) {\n const parents = this.getParents(run).reverse();\n const string = [...parents, run]\n .map((parent, i, arr) => {\n const name = `${parent.execution_order}:${parent.run_type}:${parent.name}`;\n return i === arr.length - 1 ? wrap(styles.bold, name) : name;\n })\n .join(\" > \");\n return wrap(color.grey, string);\n }\n\n // logging methods\n\n /**\n * Method used to log the start of a chain run.\n * @param run The chain run that has started.\n * @returns void\n */\n onChainStart(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(\n color.green,\n \"[chain/start]\"\n )} [${crumbs}] Entering Chain run with input: ${tryJsonStringify(\n run.inputs,\n \"[inputs]\"\n )}`\n );\n }\n\n /**\n * Method used to log the end of a chain run.\n * @param run The chain run that has ended.\n * @returns void\n */\n onChainEnd(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.cyan, \"[chain/end]\")} [${crumbs}] [${elapsed(\n run\n )}] Exiting Chain run with output: ${tryJsonStringify(\n run.outputs,\n \"[outputs]\"\n )}`\n );\n }\n\n /**\n * Method used to log any errors of a chain run.\n * @param run The chain run that has errored.\n * @returns void\n */\n onChainError(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.red, \"[chain/error]\")} [${crumbs}] [${elapsed(\n run\n )}] Chain run errored with error: ${tryJsonStringify(\n run.error,\n \"[error]\"\n )}`\n );\n }\n\n /**\n * Method used to log the start of an LLM run.\n * @param run The LLM run that has started.\n * @returns void\n */\n onLLMStart(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n const inputs =\n \"prompts\" in run.inputs\n ? { prompts: (run.inputs.prompts as string[]).map((p) => p.trim()) }\n : run.inputs;\n console.log(\n `${wrap(\n color.green,\n \"[llm/start]\"\n )} [${crumbs}] Entering LLM run with input: ${tryJsonStringify(\n inputs,\n \"[inputs]\"\n )}`\n );\n }\n\n /**\n * Method used to log the end of an LLM run.\n * @param run The LLM run that has ended.\n * @returns void\n */\n onLLMEnd(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.cyan, \"[llm/end]\")} [${crumbs}] [${elapsed(\n run\n )}] Exiting LLM run with output: ${tryJsonStringify(\n run.outputs,\n \"[response]\"\n )}`\n );\n }\n\n /**\n * Method used to log any errors of an LLM run.\n * @param run The LLM run that has errored.\n * @returns void\n */\n onLLMError(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.red, \"[llm/error]\")} [${crumbs}] [${elapsed(\n run\n )}] LLM run errored with error: ${tryJsonStringify(run.error, \"[error]\")}`\n );\n }\n\n /**\n * Method used to log the start of a tool run.\n * @param run The tool run that has started.\n * @returns void\n */\n onToolStart(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(\n color.green,\n \"[tool/start]\"\n )} [${crumbs}] Entering Tool run with input: \"${formatKVMapItem(\n run.inputs.input\n )}\"`\n );\n }\n\n /**\n * Method used to log the end of a tool run.\n * @param run The tool run that has ended.\n * @returns void\n */\n onToolEnd(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n\n console.log(\n `${wrap(color.cyan, \"[tool/end]\")} [${crumbs}] [${elapsed(\n run\n )}] Exiting Tool run with output: \"${formatKVMapItem(\n run.outputs?.output\n )}\"`\n );\n }\n\n /**\n * Method used to log any errors of a tool run.\n * @param run The tool run that has errored.\n * @returns void\n */\n onToolError(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.red, \"[tool/error]\")} [${crumbs}] [${elapsed(\n run\n )}] Tool run errored with error: ${tryJsonStringify(\n run.error,\n \"[error]\"\n )}`\n );\n }\n\n /**\n * Method used to log the start of a retriever run.\n * @param run The retriever run that has started.\n * @returns void\n */\n onRetrieverStart(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(\n color.green,\n \"[retriever/start]\"\n )} [${crumbs}] Entering Retriever run with input: ${tryJsonStringify(\n run.inputs,\n \"[inputs]\"\n )}`\n );\n }\n\n /**\n * Method used to log the end of a retriever run.\n * @param run The retriever run that has ended.\n * @returns void\n */\n onRetrieverEnd(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.cyan, \"[retriever/end]\")} [${crumbs}] [${elapsed(\n run\n )}] Exiting Retriever run with output: ${tryJsonStringify(\n run.outputs,\n \"[outputs]\"\n )}`\n );\n }\n\n /**\n * Method used to log any errors of a retriever run.\n * @param run The retriever run that has errored.\n * @returns void\n */\n onRetrieverError(run: Run) {\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(color.red, \"[retriever/error]\")} [${crumbs}] [${elapsed(\n run\n )}] Retriever run errored with error: ${tryJsonStringify(\n run.error,\n \"[error]\"\n )}`\n );\n }\n\n /**\n * Method used to log the action selected by the agent.\n * @param run The run in which the agent action occurred.\n * @returns void\n */\n onAgentAction(run: Run) {\n const agentRun = run as AgentRun;\n const crumbs = this.getBreadcrumbs(run);\n console.log(\n `${wrap(\n color.blue,\n \"[agent/action]\"\n )} [${crumbs}] Agent selected action: ${tryJsonStringify(\n agentRun.actions[agentRun.actions.length - 1],\n \"[action]\"\n )}`\n );\n }\n}\n"],"mappings":";;;;;;;AAIA,SAAS,KAAKA,OAAeC,MAAc;AACzC,QAAO,GAAG,MAAM,OAAO,OAAO,MAAM,OAAO;AAC5C;AAED,SAAS,iBAAiBC,KAAcC,UAAkB;AACxD,KAAI;AACF,SAAO,KAAK,UAAU,KAAK,MAAM,EAAE;CACpC,QAAO;AACN,SAAO;CACR;AACF;AAED,SAAS,gBAAgBC,OAAgB;AACvC,KAAI,OAAO,UAAU,SACnB,QAAO,MAAM,MAAM;AAGrB,KAAI,UAAU,QAAQ,UAAU,OAC9B,QAAO;AAGT,QAAO,iBAAiB,OAAO,MAAM,UAAU,CAAC;AACjD;AAED,SAAS,QAAQC,KAAkB;AACjC,KAAI,CAAC,IAAI,SAAU,QAAO;CAC1B,MAAMC,YAAU,IAAI,WAAW,IAAI;AACnC,KAAIA,YAAU,IACZ,QAAO,GAAGA,UAAQ,EAAE,CAAC;AAEvB,QAAO,IAAIA,YAAU,KAAM,QAAQ,EAAE,CAAC,CAAC,CAAC;AACzC;AAED,MAAM,EAAE,OAAO,GAAG;;;;;;;;;;;;;;;;AAiBlB,IAAa,yBAAb,cAA4C,WAAW;CACrD,OAAO;;;;;;;CAQP,AAAU,WAAWC,MAAW;AAC9B,SAAO,QAAQ,SAAS;CACzB;;;;;;CASD,WAAWF,KAAU;EACnB,MAAMG,UAAiB,CAAE;EACzB,IAAI,aAAa;AACjB,SAAO,WAAW,eAAe;GAC/B,MAAM,SAAS,KAAK,OAAO,IAAI,WAAW,cAAc;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,CACJ;CACF;;;;;;CAOD,iBAAiBA,KAAU;EACzB,MAAM,SAAS,KAAK,eAAe,IAAI;EACvC,QAAQ,IACN,GAAG,KACD,MAAM,OACN,oBACD,CAAC,EAAE,EAAE,OAAO,qCAAqC,EAAE,iBAClD,IAAI,QACJ,WACD,EAAE,CACJ;CACF;;;;;;CAOD,eAAeA,KAAU;EACvB,MAAM,SAAS,KAAK,eAAe,IAAI;EACvC,QAAQ,IACN,GAAG,KAAK,MAAM,MAAM,kBAAkB,CAAC,EAAE,EAAE,OAAO,GAAG,EAAE,QACrD,IACD,CAAC,qCAAqC,EAAE,iBACvC,IAAI,SACJ,YACD,EAAE,CACJ;CACF;;;;;;CAOD,iBAAiBA,KAAU;EACzB,MAAM,SAAS,KAAK,eAAe,IAAI;EACvC,QAAQ,IACN,GAAG,KAAK,MAAM,KAAK,oBAAoB,CAAC,EAAE,EAAE,OAAO,GAAG,EAAE,QACtD,IACD,CAAC,oCAAoC,EAAE,iBACtC,IAAI,OACJ,UACD,EAAE,CACJ;CACF;;;;;;CAOD,cAAcA,KAAU;EACtB,MAAM,WAAW;EACjB,MAAM,SAAS,KAAK,eAAe,IAAI;EACvC,QAAQ,IACN,GAAG,KACD,MAAM,MACN,iBACD,CAAC,EAAE,EAAE,OAAO,yBAAyB,EAAE,iBACtC,SAAS,QAAQ,SAAS,QAAQ,SAAS,IAC3C,WACD,EAAE,CACJ;CACF;AACF"}
@@ -14,6 +14,7 @@ type StreamEventData = {
14
14
  * won't be known until the *END* of the runnable when it has finished streaming
15
15
  * its inputs.
16
16
  */
17
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
18
  input?: any;
18
19
  /**
19
20
  * The output of the runnable that generated the event.
@@ -22,12 +23,14 @@ type StreamEventData = {
22
23
  * though there might be some exceptions for special cased runnables (e.g., like
23
24
  * chat models), which may return more information.
24
25
  */
26
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
27
  output?: any;
26
28
  /**
27
29
  * A streaming chunk from the output that generated the event.
28
30
  * chunks support addition in general, and adding them up should result
29
31
  * in the output of the runnable that generated the event.
30
32
  */
33
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
34
  chunk?: any;
32
35
  };
33
36
  /**
@@ -71,6 +74,7 @@ type StreamEvent = {
71
74
  */
72
75
  tags?: string[];
73
76
  /** Metadata associated with the runnable that generated this event. */
77
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
74
78
  metadata: Record<string, any>;
75
79
  /**
76
80
  * Event data.
@@ -15,6 +15,7 @@ type StreamEventData = {
15
15
  * won't be known until the *END* of the runnable when it has finished streaming
16
16
  * its inputs.
17
17
  */
18
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
19
  input?: any;
19
20
  /**
20
21
  * The output of the runnable that generated the event.
@@ -23,12 +24,14 @@ type StreamEventData = {
23
24
  * though there might be some exceptions for special cased runnables (e.g., like
24
25
  * chat models), which may return more information.
25
26
  */
27
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
28
  output?: any;
27
29
  /**
28
30
  * A streaming chunk from the output that generated the event.
29
31
  * chunks support addition in general, and adding them up should result
30
32
  * in the output of the runnable that generated the event.
31
33
  */
34
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
35
  chunk?: any;
33
36
  };
34
37
  /**
@@ -72,6 +75,7 @@ type StreamEvent = {
72
75
  */
73
76
  tags?: string[];
74
77
  /** Metadata associated with the runnable that generated this event. */
78
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
75
79
  metadata: Record<string, any>;
76
80
  /**
77
81
  * Event data.
@@ -20,16 +20,20 @@ type LogEntry = {
20
20
  /** List of tags for the run. */
21
21
  tags: string[];
22
22
  /** Key-value pairs of metadata for the run. */
23
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
24
  metadata: Record<string, any>;
24
25
  /** ISO-8601 timestamp of when the run started. */
25
26
  start_time: string;
26
27
  /** List of general output chunks streamed by this run. */
28
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
29
  streamed_output: any[];
28
30
  /** List of LLM tokens streamed by this run, if applicable. */
29
31
  streamed_output_str: string[];
30
32
  /** Inputs to this run. Not available currently via streamLog. */
33
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
34
  inputs?: any;
32
35
  /** Final output of this run. Only available after the run has finished successfully. */
36
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
37
  final_output?: any;
34
38
  /** ISO-8601 timestamp of when the run ended. Only available after the run has finished. */
35
39
  end_time?: string;
@@ -38,8 +42,10 @@ type RunState = {
38
42
  /** ID of the sub-run. */
39
43
  id: string;
40
44
  /** List of output chunks streamed by Runnable.stream() */
45
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
46
  streamed_output: any[];
42
47
  /** Final output of the run, usually the result of aggregating streamed_output. Only available after the run has finished successfully. */
48
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
43
49
  final_output?: any;
44
50
  /**
45
51
  * List of sub-runs contained in this run, if any, in the order they were started.
@@ -20,16 +20,20 @@ type LogEntry = {
20
20
  /** List of tags for the run. */
21
21
  tags: string[];
22
22
  /** Key-value pairs of metadata for the run. */
23
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
24
  metadata: Record<string, any>;
24
25
  /** ISO-8601 timestamp of when the run started. */
25
26
  start_time: string;
26
27
  /** List of general output chunks streamed by this run. */
28
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
29
  streamed_output: any[];
28
30
  /** List of LLM tokens streamed by this run, if applicable. */
29
31
  streamed_output_str: string[];
30
32
  /** Inputs to this run. Not available currently via streamLog. */
33
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
34
  inputs?: any;
32
35
  /** Final output of this run. Only available after the run has finished successfully. */
36
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
37
  final_output?: any;
34
38
  /** ISO-8601 timestamp of when the run ended. Only available after the run has finished. */
35
39
  end_time?: string;
@@ -38,8 +42,10 @@ type RunState = {
38
42
  /** ID of the sub-run. */
39
43
  id: string;
40
44
  /** List of output chunks streamed by Runnable.stream() */
45
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
46
  streamed_output: any[];
42
47
  /** Final output of the run, usually the result of aggregating streamed_output. Only available after the run has finished successfully. */
48
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
43
49
  final_output?: any;
44
50
  /**
45
51
  * List of sub-runs contained in this run, if any, in the order they were started.
@@ -1,4 +1,7 @@
1
1
  //#region src/types/_internal.d.ts
2
+ // Make this a type to override ReadableStream's async iterator type in case
3
+ // the popular web-streams-polyfill is imported - the supplied types
4
+ // in that case don't quite match.
2
5
  type IterableReadableStreamInterface<T> = ReadableStream<T> & AsyncIterable<T>;
3
6
  //#endregion
4
7
  export { IterableReadableStreamInterface };
@@ -1,4 +1,7 @@
1
1
  //#region src/types/_internal.d.ts
2
+ // Make this a type to override ReadableStream's async iterator type in case
3
+ // the popular web-streams-polyfill is imported - the supplied types
4
+ // in that case don't quite match.
2
5
  type IterableReadableStreamInterface<T> = ReadableStream<T> & AsyncIterable<T>;
3
6
  //#endregion
4
7
  export { IterableReadableStreamInterface };
@@ -1,4 +1,6 @@
1
1
  //#region src/types/type-utils.d.ts
2
+ // Utility for marking only some keys of an interface as optional
3
+ // Compare to Partial<T> which marks all keys as optional
2
4
  type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
3
5
  //#endregion
4
6
  export { Optional };
@@ -1,4 +1,6 @@
1
1
  //#region src/types/type-utils.d.ts
2
+ // Utility for marking only some keys of an interface as optional
3
+ // Compare to Partial<T> which marks all keys as optional
2
4
  type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
3
5
  //#endregion
4
6
  export { Optional };
@@ -1,6 +1,6 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- const require_index = require('../node_modules/.pnpm/p-retry@7.1.0/node_modules/p-retry/index.cjs');
3
2
  const require_signal = require('./signal.cjs');
3
+ const require_index = require('./p-retry/index.cjs');
4
4
  const p_queue = require_rolldown_runtime.__toESM(require("p-queue"));
5
5
 
6
6
  //#region src/utils/async_caller.ts