@jaypie/llm 1.3.7 → 1.3.8

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.
@@ -15,16 +15,19 @@ export interface AfterModelResponseContext {
15
15
  }
16
16
  export interface BeforeToolContext {
17
17
  args: string;
18
+ message?: string;
18
19
  toolName: string;
19
20
  }
20
21
  export interface AfterToolContext {
21
22
  args: string;
23
+ message?: string;
22
24
  result: unknown;
23
25
  toolName: string;
24
26
  }
25
27
  export interface ToolErrorContext {
26
28
  args: string;
27
29
  error: Error;
30
+ message?: string;
28
31
  toolName: string;
29
32
  }
30
33
  export interface RetryableErrorContext {
@@ -14,9 +14,21 @@ export declare class Toolkit {
14
14
  private readonly log;
15
15
  constructor(tools: LlmTool[], options?: ToolkitOptions);
16
16
  get tools(): Omit<LlmTool, "call">[];
17
- call({ name, arguments: args }: {
17
+ private parseArgs;
18
+ /**
19
+ * Resolve a tool's `message` (static string or function of args) without
20
+ * calling the tool. Returns undefined when the tool is missing or defines
21
+ * no message. Never throws; resolution errors log at warn.
22
+ */
23
+ resolveMessage({ name, arguments: args, }: {
18
24
  name: string;
19
25
  arguments: string;
26
+ }): Promise<string | undefined>;
27
+ call({ name, arguments: args, message: resolvedMessage, }: {
28
+ name: string;
29
+ arguments: string;
30
+ /** Pre-resolved tool message; skips re-resolving `tool.message` for logging */
31
+ message?: string;
20
32
  }): Promise<import("@jaypie/types").AnyValue>;
21
33
  extend(tools: LlmTool[], options?: {
22
34
  warn?: boolean;
@@ -179,6 +179,8 @@ export declare enum LlmProgressEventType {
179
179
  export interface LlmProgressToolCall {
180
180
  /** JSON string of arguments (tool_call events only) */
181
181
  arguments?: string;
182
+ /** Resolved `LlmTool.message`, when the tool defines one (tool_call events only) */
183
+ message?: string;
182
184
  /** Tool name */
183
185
  name: string;
184
186
  }
@@ -225,19 +227,23 @@ export interface LlmOperateOptions {
225
227
  content: string | JsonObject;
226
228
  usage: LlmUsage;
227
229
  }) => unknown | Promise<unknown>;
228
- afterEachTool?: ({ result, toolName, args, }: {
230
+ afterEachTool?: ({ result, toolName, args, message, }: {
229
231
  result: unknown;
230
232
  toolName: string;
231
233
  args: string;
234
+ /** Resolved `LlmTool.message`, when the tool defines one */
235
+ message?: string;
232
236
  }) => unknown | Promise<unknown>;
233
237
  beforeEachModelRequest?: ({ input, options, providerRequest, }: {
234
238
  input: string | LlmHistory | LlmInputMessage;
235
239
  options?: LlmOperateOptions;
236
240
  providerRequest: any;
237
241
  }) => unknown | Promise<unknown>;
238
- beforeEachTool?: ({ toolName, args, }: {
242
+ beforeEachTool?: ({ toolName, args, message, }: {
239
243
  toolName: string;
240
244
  args: string;
245
+ /** Resolved `LlmTool.message`, when the tool defines one */
246
+ message?: string;
241
247
  }) => unknown | Promise<unknown>;
242
248
  onRetryableModelError?: ({ input, options, providerRequest, error, }: {
243
249
  input: string | LlmHistory | LlmInputMessage;
@@ -245,10 +251,12 @@ export interface LlmOperateOptions {
245
251
  providerRequest: any;
246
252
  error: any;
247
253
  }) => unknown | Promise<unknown>;
248
- onToolError?: ({ error, toolName, args, }: {
254
+ onToolError?: ({ error, toolName, args, message, }: {
249
255
  error: Error;
250
256
  toolName: string;
251
257
  args: string;
258
+ /** Resolved `LlmTool.message`, when the tool defines one */
259
+ message?: string;
252
260
  }) => unknown | Promise<unknown>;
253
261
  onUnrecoverableModelError?: ({ input, options, providerRequest, error, }: {
254
262
  input: string | LlmHistory | LlmInputMessage;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jaypie/llm",
3
- "version": "1.3.7",
3
+ "version": "1.3.8",
4
4
  "description": "Large language model utilities",
5
5
  "repository": {
6
6
  "type": "git",