@jaypie/llm 1.3.6 → 1.3.7

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.
@@ -1,7 +1,7 @@
1
1
  export { default as Llm } from "./Llm.js";
2
2
  export * as LLM from "./constants.js";
3
- export type { LlmFallbackConfig, LlmHistory, LlmInputContent, LlmInputContentFile, LlmInputContentImage, LlmInputContentText, LlmInputMessage, LlmMessageOptions, LlmOperateInput, LlmOperateInputContent, LlmOperateInputFile, LlmOperateInputImage, LlmOperateOptions, LlmOperateResponse, LlmOptions, LlmProvider, } from "./types/LlmProvider.interface.js";
4
- export { LlmMessageRole, LlmMessageType, } from "./types/LlmProvider.interface.js";
3
+ export type { LlmFallbackConfig, LlmHistory, LlmInputContent, LlmInputContentFile, LlmInputContentImage, LlmInputContentText, LlmInputMessage, LlmMessageOptions, LlmOperateInput, LlmOperateInputContent, LlmOperateInputFile, LlmOperateInputImage, LlmOperateOptions, LlmOperateResponse, LlmOptions, LlmProgressCallback, LlmProgressEvent, LlmProgressToolCall, LlmProvider, } from "./types/LlmProvider.interface.js";
4
+ export { LlmMessageRole, LlmMessageType, LlmProgressEventType, } from "./types/LlmProvider.interface.js";
5
5
  export { isLlmOperateInput, isLlmOperateInputContent, isLlmOperateInputFile, isLlmOperateInputImage, } from "./types/LlmOperateInput.guards.js";
6
6
  export type { LlmTool } from "./types/LlmTool.interface.js";
7
7
  export type { LlmStreamChunk, LlmStreamChunkDone, LlmStreamChunkError, LlmStreamChunkText, LlmStreamChunkToolCall, LlmStreamChunkToolResult, } from "./types/LlmStreamChunk.interface.js";
@@ -34,6 +34,11 @@ export declare class OperateLoop {
34
34
  private createContext;
35
35
  private buildInitialRequest;
36
36
  private executeOneTurn;
37
+ /**
38
+ * Draconian summary of a history item for trace logging: string message
39
+ * content is kept; everything else is reduced to its type.
40
+ */
41
+ private summarizeHistoryItem;
37
42
  /**
38
43
  * Reconcile structured output against the declared `format` contract. A
39
44
  * declared `format` is a schema contract: returned keys should match the
@@ -0,0 +1,10 @@
1
+ import { LlmProgressCallback, LlmProgressEvent } from "../../types/LlmProvider.interface.js";
2
+ /**
3
+ * Deliver a progress event to the caller's onProgress callback.
4
+ * Errors thrown by the callback are logged and swallowed — progress
5
+ * reporting must never interrupt the operate loop.
6
+ */
7
+ export declare function emitProgress({ event, onProgress, }: {
8
+ event: LlmProgressEvent;
9
+ onProgress?: LlmProgressCallback;
10
+ }): Promise<void>;
@@ -0,0 +1 @@
1
+ export { emitProgress } from "./emitProgress.js";
@@ -166,6 +166,49 @@ export interface LlmMessageOptions {
166
166
  response?: NaturalSchema | z.ZodType;
167
167
  system?: string;
168
168
  }
169
+ export declare enum LlmProgressEventType {
170
+ Done = "done",
171
+ ModelRequest = "model_request",
172
+ ModelResponse = "model_response",
173
+ Retry = "retry",
174
+ Start = "start",
175
+ ToolCall = "tool_call",
176
+ ToolError = "tool_error",
177
+ ToolResult = "tool_result"
178
+ }
179
+ export interface LlmProgressToolCall {
180
+ /** JSON string of arguments (tool_call events only) */
181
+ arguments?: string;
182
+ /** Tool name */
183
+ name: string;
184
+ }
185
+ /**
186
+ * Lightweight, serializable progress event emitted by the operate loop.
187
+ * Suitable for forwarding directly to websockets, queues, or UI updates.
188
+ */
189
+ export interface LlmProgressEvent {
190
+ /** Text or structured content (model_response, done) */
191
+ content?: string | JsonObject;
192
+ /** Error message (tool_error, retry) */
193
+ error?: string;
194
+ /** Maximum turns allowed for the loop (start) */
195
+ maxTurns?: number;
196
+ /** Model handling the request (start, model_request) */
197
+ model?: string;
198
+ /** Provider name (start) */
199
+ provider?: string;
200
+ /** The tool involved (tool_call, tool_result, tool_error) */
201
+ tool?: LlmProgressToolCall;
202
+ /** Tools the model requested (model_response) */
203
+ toolCalls?: LlmProgressToolCall[];
204
+ /** Current turn, 1-indexed */
205
+ turn?: number;
206
+ /** Event type */
207
+ type: LlmProgressEventType;
208
+ /** Usage: this turn for model_response, cumulative for done */
209
+ usage?: LlmUsage;
210
+ }
211
+ export type LlmProgressCallback = (event: LlmProgressEvent) => unknown | Promise<unknown>;
169
212
  export interface LlmOperateOptions {
170
213
  data?: NaturalMap;
171
214
  explain?: boolean;
@@ -216,6 +259,13 @@ export interface LlmOperateOptions {
216
259
  };
217
260
  instructions?: string;
218
261
  model?: string;
262
+ /**
263
+ * Receives lightweight progress events as the operate loop runs:
264
+ * start, model_request, model_response, tool_call, tool_result,
265
+ * tool_error, retry, done. Errors thrown by the callback are logged
266
+ * and never interrupt the loop.
267
+ */
268
+ onProgress?: LlmProgressCallback;
219
269
  placeholders?: {
220
270
  input?: boolean;
221
271
  instructions?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jaypie/llm",
3
- "version": "1.3.6",
3
+ "version": "1.3.7",
4
4
  "description": "Large language model utilities",
5
5
  "repository": {
6
6
  "type": "git",