llmist 3.0.0 → 3.1.0
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.
- package/dist/{chunk-67MMSOAT.js → chunk-JCFPJMRQ.js} +540 -51
- package/dist/chunk-JCFPJMRQ.js.map +1 -0
- package/dist/{chunk-NBPKLSXJ.js → chunk-LFI4WQVV.js} +2 -2
- package/dist/cli.cjs +741 -64
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +203 -15
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +539 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +42 -5
- package/dist/index.d.ts +42 -5
- package/dist/index.js +2 -2
- package/dist/{mock-stream-COHw8h9b.d.cts → mock-stream-CTLm00_q.d.cts} +163 -3
- package/dist/{mock-stream-COHw8h9b.d.ts → mock-stream-CTLm00_q.d.ts} +163 -3
- package/dist/testing/index.cjs +539 -50
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +2 -2
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-67MMSOAT.js.map +0 -1
- /package/dist/{chunk-NBPKLSXJ.js.map → chunk-LFI4WQVV.js.map} +0 -0
|
@@ -986,6 +986,25 @@ interface GadgetSkippedEvent {
|
|
|
986
986
|
/** The error message from the failed dependency */
|
|
987
987
|
failedDependencyError: string;
|
|
988
988
|
}
|
|
989
|
+
/**
|
|
990
|
+
* Event emitted when stream processing completes, containing metadata.
|
|
991
|
+
* This allows the async generator to "return" metadata while still yielding events.
|
|
992
|
+
*/
|
|
993
|
+
interface StreamCompletionEvent {
|
|
994
|
+
type: "stream_complete";
|
|
995
|
+
/** The reason the LLM stopped generating (e.g., "stop", "tool_use") */
|
|
996
|
+
finishReason: string | null;
|
|
997
|
+
/** Token usage statistics from the LLM call */
|
|
998
|
+
usage?: TokenUsage;
|
|
999
|
+
/** Raw response text from the LLM */
|
|
1000
|
+
rawResponse: string;
|
|
1001
|
+
/** Final message after all interceptors applied */
|
|
1002
|
+
finalMessage: string;
|
|
1003
|
+
/** Whether any gadgets were executed during this iteration */
|
|
1004
|
+
didExecuteGadgets: boolean;
|
|
1005
|
+
/** Whether to break the agent loop (e.g., TaskComplete was called) */
|
|
1006
|
+
shouldBreakLoop: boolean;
|
|
1007
|
+
}
|
|
989
1008
|
type StreamEvent = {
|
|
990
1009
|
type: "text";
|
|
991
1010
|
content: string;
|
|
@@ -1003,7 +1022,52 @@ type StreamEvent = {
|
|
|
1003
1022
|
} | {
|
|
1004
1023
|
type: "compaction";
|
|
1005
1024
|
event: CompactionEvent;
|
|
1006
|
-
};
|
|
1025
|
+
} | StreamCompletionEvent;
|
|
1026
|
+
/**
|
|
1027
|
+
* Information about an LLM call within a nested subagent.
|
|
1028
|
+
* Used by parent agents to display real-time progress of subagent LLM calls.
|
|
1029
|
+
*/
|
|
1030
|
+
interface LLMCallInfo {
|
|
1031
|
+
/** Iteration number within the subagent loop */
|
|
1032
|
+
iteration: number;
|
|
1033
|
+
/** Model identifier (e.g., "sonnet", "gpt-4o") */
|
|
1034
|
+
model: string;
|
|
1035
|
+
/** Input tokens sent to the LLM */
|
|
1036
|
+
inputTokens?: number;
|
|
1037
|
+
/** Output tokens received from the LLM */
|
|
1038
|
+
outputTokens?: number;
|
|
1039
|
+
/** Reason the LLM stopped generating (e.g., "stop", "tool_use") */
|
|
1040
|
+
finishReason?: string;
|
|
1041
|
+
/** Elapsed time in milliseconds */
|
|
1042
|
+
elapsedMs?: number;
|
|
1043
|
+
}
|
|
1044
|
+
/**
|
|
1045
|
+
* Event emitted by subagent gadgets to report internal agent activity.
|
|
1046
|
+
* Enables real-time display of nested LLM calls and gadget executions.
|
|
1047
|
+
*
|
|
1048
|
+
* @example
|
|
1049
|
+
* ```typescript
|
|
1050
|
+
* // Forwarding events from subagent to parent
|
|
1051
|
+
* for await (const event of subagent.run()) {
|
|
1052
|
+
* ctx.onNestedEvent?.({
|
|
1053
|
+
* type: event.type === "gadget_call" ? "gadget_call" : "gadget_result",
|
|
1054
|
+
* gadgetInvocationId: parentInvocationId,
|
|
1055
|
+
* depth: 1,
|
|
1056
|
+
* event,
|
|
1057
|
+
* });
|
|
1058
|
+
* }
|
|
1059
|
+
* ```
|
|
1060
|
+
*/
|
|
1061
|
+
interface NestedAgentEvent {
|
|
1062
|
+
/** Type of nested event */
|
|
1063
|
+
type: "llm_call_start" | "llm_call_end" | "gadget_call" | "gadget_result";
|
|
1064
|
+
/** Invocation ID of the parent gadget this nested event belongs to */
|
|
1065
|
+
gadgetInvocationId: string;
|
|
1066
|
+
/** Nesting depth (1 = direct child, 2 = grandchild, etc.) */
|
|
1067
|
+
depth: number;
|
|
1068
|
+
/** The actual event data - either a StreamEvent or LLMCallInfo */
|
|
1069
|
+
event: StreamEvent | LLMCallInfo;
|
|
1070
|
+
}
|
|
1007
1071
|
|
|
1008
1072
|
type TextOnlyHandler = TextOnlyStrategy | TextOnlyGadgetConfig | TextOnlyCustomHandler;
|
|
1009
1073
|
/**
|
|
@@ -1314,6 +1378,39 @@ interface ExecutionContext {
|
|
|
1314
1378
|
* ```
|
|
1315
1379
|
*/
|
|
1316
1380
|
subagentConfig?: SubagentConfigMap;
|
|
1381
|
+
/**
|
|
1382
|
+
* Unique invocation ID for this gadget execution.
|
|
1383
|
+
* Used by `withParentContext()` to identify which parent gadget
|
|
1384
|
+
* nested events belong to.
|
|
1385
|
+
*/
|
|
1386
|
+
invocationId?: string;
|
|
1387
|
+
/**
|
|
1388
|
+
* Callback for subagent gadgets to report internal events to the parent.
|
|
1389
|
+
*
|
|
1390
|
+
* When provided, subagent gadgets (like BrowseWeb) can use this callback
|
|
1391
|
+
* to report their internal LLM calls and gadget executions in real-time.
|
|
1392
|
+
* This enables the parent agent to display nested progress indicators.
|
|
1393
|
+
*
|
|
1394
|
+
* **Recommended:** Use `builder.withParentContext(ctx)` instead of calling
|
|
1395
|
+
* this directly - it handles all the forwarding automatically.
|
|
1396
|
+
*
|
|
1397
|
+
* @example
|
|
1398
|
+
* ```typescript
|
|
1399
|
+
* // In a subagent gadget like BrowseWeb - just ONE LINE needed:
|
|
1400
|
+
* execute: async (params, ctx) => {
|
|
1401
|
+
* const agent = new AgentBuilder(client)
|
|
1402
|
+
* .withModel(model)
|
|
1403
|
+
* .withGadgets(Navigate, Click)
|
|
1404
|
+
* .withParentContext(ctx) // <-- Enables automatic event forwarding!
|
|
1405
|
+
* .ask(task);
|
|
1406
|
+
*
|
|
1407
|
+
* for await (const event of agent.run()) {
|
|
1408
|
+
* // Events automatically forwarded - just process normally
|
|
1409
|
+
* }
|
|
1410
|
+
* }
|
|
1411
|
+
* ```
|
|
1412
|
+
*/
|
|
1413
|
+
onNestedEvent?: (event: NestedAgentEvent) => void;
|
|
1317
1414
|
}
|
|
1318
1415
|
/**
|
|
1319
1416
|
* Parent agent configuration passed to gadgets.
|
|
@@ -3475,6 +3572,8 @@ interface AgentOptions {
|
|
|
3475
3572
|
signal?: AbortSignal;
|
|
3476
3573
|
/** Subagent-specific configuration overrides (from CLI config) */
|
|
3477
3574
|
subagentConfig?: SubagentConfigMap;
|
|
3575
|
+
/** Callback for subagent gadgets to report nested events to parent */
|
|
3576
|
+
onNestedEvent?: (event: NestedAgentEvent) => void;
|
|
3478
3577
|
}
|
|
3479
3578
|
/**
|
|
3480
3579
|
* Agent: Lean orchestrator that delegates to StreamProcessor.
|
|
@@ -3519,6 +3618,7 @@ declare class Agent {
|
|
|
3519
3618
|
private readonly signal?;
|
|
3520
3619
|
private readonly agentContextConfig;
|
|
3521
3620
|
private readonly subagentConfig?;
|
|
3621
|
+
private readonly onNestedEvent?;
|
|
3522
3622
|
/**
|
|
3523
3623
|
* Creates a new Agent instance.
|
|
3524
3624
|
* @internal This constructor is private. Use LLMist.createAgent() or AgentBuilder instead.
|
|
@@ -3729,6 +3829,8 @@ declare class AgentBuilder {
|
|
|
3729
3829
|
private signal?;
|
|
3730
3830
|
private trailingMessage?;
|
|
3731
3831
|
private subagentConfig?;
|
|
3832
|
+
private nestedEventCallback?;
|
|
3833
|
+
private parentContext?;
|
|
3732
3834
|
constructor(client?: LLMist);
|
|
3733
3835
|
/**
|
|
3734
3836
|
* Set the model to use.
|
|
@@ -4144,6 +4246,62 @@ declare class AgentBuilder {
|
|
|
4144
4246
|
* ```
|
|
4145
4247
|
*/
|
|
4146
4248
|
withSubagentConfig(config: SubagentConfigMap): this;
|
|
4249
|
+
/**
|
|
4250
|
+
* Set the callback for nested subagent events.
|
|
4251
|
+
*
|
|
4252
|
+
* Subagent gadgets (like BrowseWeb) can use ExecutionContext.onNestedEvent
|
|
4253
|
+
* to report their internal LLM calls and gadget executions in real-time.
|
|
4254
|
+
* This callback receives those events, enabling hierarchical progress display.
|
|
4255
|
+
*
|
|
4256
|
+
* @param callback - Function to handle nested agent events
|
|
4257
|
+
* @returns This builder for chaining
|
|
4258
|
+
*
|
|
4259
|
+
* @example
|
|
4260
|
+
* ```typescript
|
|
4261
|
+
* .withNestedEventCallback((event) => {
|
|
4262
|
+
* if (event.type === "llm_call_start") {
|
|
4263
|
+
* console.log(` Nested LLM #${event.event.iteration} starting...`);
|
|
4264
|
+
* } else if (event.type === "gadget_call") {
|
|
4265
|
+
* console.log(` ⏵ ${event.event.call.gadgetName}...`);
|
|
4266
|
+
* }
|
|
4267
|
+
* })
|
|
4268
|
+
* ```
|
|
4269
|
+
*/
|
|
4270
|
+
withNestedEventCallback(callback: (event: NestedAgentEvent) => void): this;
|
|
4271
|
+
/**
|
|
4272
|
+
* Enable automatic nested event forwarding to parent agent.
|
|
4273
|
+
*
|
|
4274
|
+
* When building a subagent inside a gadget, call this method to automatically
|
|
4275
|
+
* forward all LLM calls and gadget events to the parent agent. This enables
|
|
4276
|
+
* hierarchical progress display without any manual event handling.
|
|
4277
|
+
*
|
|
4278
|
+
* The method extracts `invocationId` and `onNestedEvent` from the execution
|
|
4279
|
+
* context and sets up automatic forwarding via hooks and event wrapping.
|
|
4280
|
+
*
|
|
4281
|
+
* @param ctx - ExecutionContext passed to the gadget's execute() method
|
|
4282
|
+
* @param depth - Nesting depth (default: 1 for direct child)
|
|
4283
|
+
* @returns This builder for chaining
|
|
4284
|
+
*
|
|
4285
|
+
* @example
|
|
4286
|
+
* ```typescript
|
|
4287
|
+
* // In a subagent gadget like BrowseWeb - ONE LINE enables auto-forwarding:
|
|
4288
|
+
* execute: async (params, ctx) => {
|
|
4289
|
+
* const agent = new AgentBuilder(client)
|
|
4290
|
+
* .withModel(model)
|
|
4291
|
+
* .withGadgets(Navigate, Click, Screenshot)
|
|
4292
|
+
* .withParentContext(ctx) // <-- This is all you need!
|
|
4293
|
+
* .ask(params.task);
|
|
4294
|
+
*
|
|
4295
|
+
* for await (const event of agent.run()) {
|
|
4296
|
+
* // Events automatically forwarded - just process normally
|
|
4297
|
+
* if (event.type === "text") {
|
|
4298
|
+
* result = event.content;
|
|
4299
|
+
* }
|
|
4300
|
+
* }
|
|
4301
|
+
* }
|
|
4302
|
+
* ```
|
|
4303
|
+
*/
|
|
4304
|
+
withParentContext(ctx: ExecutionContext, depth?: number): this;
|
|
4147
4305
|
/**
|
|
4148
4306
|
* Add an ephemeral trailing message that appears at the end of each LLM request.
|
|
4149
4307
|
*
|
|
@@ -4193,7 +4351,9 @@ declare class AgentBuilder {
|
|
|
4193
4351
|
*/
|
|
4194
4352
|
withSyntheticGadgetCall(gadgetName: string, parameters: Record<string, unknown>, result: string): this;
|
|
4195
4353
|
/**
|
|
4196
|
-
* Compose the final hooks, including
|
|
4354
|
+
* Compose the final hooks, including:
|
|
4355
|
+
* - Trailing message injection (if configured)
|
|
4356
|
+
* - Nested event forwarding for LLM calls (if parentContext is set)
|
|
4197
4357
|
*/
|
|
4198
4358
|
private composeHooks;
|
|
4199
4359
|
/**
|
|
@@ -5101,4 +5261,4 @@ declare function createTextMockStream(text: string, options?: {
|
|
|
5101
5261
|
usage?: MockResponse["usage"];
|
|
5102
5262
|
}): LLMStream;
|
|
5103
5263
|
|
|
5104
|
-
export { type
|
|
5264
|
+
export { type LLMGenerationOptions as $, AbstractGadget as A, type MessageContent as B, type CompactionConfig as C, GadgetRegistry as D, MediaStore as E, type AgentContextConfig as F, type GadgetMediaOutput as G, type HintTemplate as H, type IConversationManager as I, type SubagentConfigMap as J, type ExecutionContext as K, type LLMMessage as L, MockProviderAdapter as M, type NestedAgentEvent as N, type GadgetExecuteReturn as O, type GadgetExample as P, type ParsedGadgetCall as Q, type ResolvedCompactionConfig as R, type StreamEvent as S, type TokenUsage as T, type GadgetExecutionResult as U, type MediaKind as V, type MediaMetadata as W, type GadgetExecuteResultWithMedia as X, type ProviderAdapter as Y, type ModelDescriptor as Z, type ModelSpec as _, type LLMStream as a, isTextPart as a$, type ImageModelSpec as a0, type ImageGenerationOptions as a1, type ImageGenerationResult as a2, type SpeechModelSpec as a3, type SpeechGenerationOptions as a4, type SpeechGenerationResult as a5, type HistoryMessage as a6, type TrailingMessage as a7, type TrailingMessageContext as a8, AgentBuilder as a9, type ObserveLLMCallContext as aA, type ObserveLLMCompleteContext as aB, type ObserveLLMErrorContext as aC, type Observers as aD, DEFAULT_COMPACTION_CONFIG as aE, DEFAULT_SUMMARIZATION_PROMPT as aF, type LLMistOptions as aG, type AudioContentPart as aH, type AudioMimeType as aI, type AudioSource as aJ, type ContentPart as aK, type ImageBase64Source as aL, type ImageContentPart as aM, type ImageMimeType as aN, type ImageSource as aO, type ImageUrlSource as aP, type TextContentPart as aQ, audioFromBase64 as aR, audioFromBuffer as aS, detectAudioMimeType as aT, detectImageMimeType as aU, imageFromBase64 as aV, imageFromBuffer as aW, imageFromUrl as aX, isAudioPart as aY, isDataUrl as aZ, isImagePart as a_, type EventHandlers as aa, collectEvents as ab, collectText as ac, runWithHandlers as ad, type AfterGadgetExecutionAction as ae, type AfterGadgetExecutionControllerContext as af, type AfterLLMCallAction as ag, type AfterLLMCallControllerContext as ah, type AfterLLMErrorAction as ai, type AgentOptions as aj, type BeforeGadgetExecutionAction as ak, type BeforeLLMCallAction as al, type ChunkInterceptorContext as am, type Controllers as an, type GadgetExecutionControllerContext as ao, type GadgetParameterInterceptorContext as ap, type GadgetResultInterceptorContext as aq, type Interceptors as ar, type LLMCallControllerContext as as, type LLMErrorControllerContext as at, type MessageInterceptorContext as au, type MessageTurn as av, type ObserveChunkContext as aw, type ObserveCompactionContext as ax, type ObserveGadgetCompleteContext as ay, type ObserveGadgetStartContext as az, type LLMStreamChunk as b, parseDataUrl as b0, text as b1, toBase64 as b2, type MessageRole as b3, extractMessageText as b4, LLMMessageBuilder as b5, normalizeMessageContent as b6, type CostEstimate as b7, type ModelFeatures as b8, type ModelLimits as b9, type TextOnlyGadgetConfig as bA, type TextOnlyHandler as bB, type TextOnlyStrategy as bC, type ModelPricing as ba, type VisionAnalyzeOptions as bb, type VisionAnalyzeResult as bc, type ProviderIdentifier as bd, ModelIdentifierParser as be, type HintContext as bf, type PromptContext as bg, type PromptTemplate as bh, type PromptTemplateConfig as bi, DEFAULT_HINTS as bj, DEFAULT_PROMPTS as bk, resolveHintTemplate as bl, resolvePromptTemplate as bm, resolveRulesTemplate as bn, type TextGenerationOptions as bo, complete as bp, stream as bq, type GadgetClass as br, type GadgetOrClass as bs, type CostReportingLLMist as bt, type GadgetExecuteResult as bu, type GadgetSkippedEvent as bv, type StoredMedia as bw, type TextOnlyAction as bx, type TextOnlyContext as by, type TextOnlyCustomHandler as bz, createMockAdapter as c, MockBuilder as d, createMockClient as e, MockManager as f, getMockManager as g, createMockStream as h, createTextMockStream as i, type MockAudioData as j, type MockImageData as k, type MockMatcher as l, mockLLM as m, type MockMatcherContext as n, type MockOptions as o, type MockRegistration as p, type MockResponse as q, type MockStats as r, type AgentHooks as s, ModelRegistry as t, LLMist as u, type CompactionEvent as v, type CompactionStats as w, type CompactionStrategy as x, type CompactionContext as y, type CompactionResult as z };
|