llmist 2.6.0 → 3.0.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/README.md +10 -1
- package/dist/{chunk-364PEMVT.js → chunk-67MMSOAT.js} +221 -174
- package/dist/chunk-67MMSOAT.js.map +1 -0
- package/dist/{chunk-4IHLIYW5.js → chunk-NBPKLSXJ.js} +6 -6
- package/dist/chunk-NBPKLSXJ.js.map +1 -0
- package/dist/cli.cjs +721 -219
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +501 -45
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +230 -182
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +100 -52
- package/dist/index.d.ts +100 -52
- package/dist/index.js +20 -18
- package/dist/{mock-stream-Jgg5u6Uf.d.cts → mock-stream-COHw8h9b.d.cts} +182 -54
- package/dist/{mock-stream-Jgg5u6Uf.d.ts → mock-stream-COHw8h9b.d.ts} +182 -54
- package/dist/testing/index.cjs +212 -166
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +6 -6
- package/dist/testing/index.d.ts +6 -6
- package/dist/testing/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-364PEMVT.js.map +0 -1
- package/dist/chunk-4IHLIYW5.js.map +0 -1
|
@@ -745,9 +745,9 @@ declare class ModelIdentifierParser {
|
|
|
745
745
|
*/
|
|
746
746
|
|
|
747
747
|
/**
|
|
748
|
-
* Options for
|
|
748
|
+
* Options for text generation methods (complete/stream).
|
|
749
749
|
*/
|
|
750
|
-
interface
|
|
750
|
+
interface TextGenerationOptions {
|
|
751
751
|
/** Model to use (supports aliases like "gpt4", "sonnet", "flash") */
|
|
752
752
|
model?: string;
|
|
753
753
|
/** Temperature (0-1) */
|
|
@@ -772,7 +772,7 @@ interface QuickOptions {
|
|
|
772
772
|
* console.log(answer); // "4" or "2+2 equals 4"
|
|
773
773
|
* ```
|
|
774
774
|
*/
|
|
775
|
-
declare function complete(client: LLMist, prompt: string, options?:
|
|
775
|
+
declare function complete(client: LLMist, prompt: string, options?: TextGenerationOptions): Promise<string>;
|
|
776
776
|
/**
|
|
777
777
|
* Quick streaming - returns async generator of text chunks.
|
|
778
778
|
*
|
|
@@ -790,7 +790,7 @@ declare function complete(client: LLMist, prompt: string, options?: QuickOptions
|
|
|
790
790
|
* }
|
|
791
791
|
* ```
|
|
792
792
|
*/
|
|
793
|
-
declare function stream(client: LLMist, prompt: string, options?:
|
|
793
|
+
declare function stream(client: LLMist, prompt: string, options?: TextGenerationOptions): AsyncGenerator<string>;
|
|
794
794
|
|
|
795
795
|
/**
|
|
796
796
|
* Example of gadget usage to help LLMs understand proper invocation.
|
|
@@ -1103,12 +1103,12 @@ interface CostReportingLLMist {
|
|
|
1103
1103
|
* Quick completion - returns final text response.
|
|
1104
1104
|
* Costs are automatically reported to the execution context.
|
|
1105
1105
|
*/
|
|
1106
|
-
complete(prompt: string, options?:
|
|
1106
|
+
complete(prompt: string, options?: TextGenerationOptions): Promise<string>;
|
|
1107
1107
|
/**
|
|
1108
1108
|
* Quick streaming - returns async generator of text chunks.
|
|
1109
1109
|
* Costs are automatically reported when the stream completes.
|
|
1110
1110
|
*/
|
|
1111
|
-
streamText(prompt: string, options?:
|
|
1111
|
+
streamText(prompt: string, options?: TextGenerationOptions): AsyncGenerator<string>;
|
|
1112
1112
|
/**
|
|
1113
1113
|
* Low-level stream access for full control.
|
|
1114
1114
|
* Costs are automatically reported based on usage metadata in chunks.
|
|
@@ -1257,16 +1257,111 @@ interface ExecutionContext {
|
|
|
1257
1257
|
* ```
|
|
1258
1258
|
*/
|
|
1259
1259
|
signal: AbortSignal;
|
|
1260
|
+
/**
|
|
1261
|
+
* Parent agent configuration for subagents to inherit.
|
|
1262
|
+
*
|
|
1263
|
+
* Contains the model and settings of the agent that invoked this gadget.
|
|
1264
|
+
* Subagent gadgets (like BrowseWeb) can use this to inherit the parent's
|
|
1265
|
+
* model by default, rather than using hardcoded defaults.
|
|
1266
|
+
*
|
|
1267
|
+
* This is optional - it will be `undefined` for:
|
|
1268
|
+
* - Gadgets executed via CLI `gadget run` command
|
|
1269
|
+
* - Direct gadget testing without agent context
|
|
1270
|
+
*
|
|
1271
|
+
* @example
|
|
1272
|
+
* ```typescript
|
|
1273
|
+
* execute: async (params, ctx) => {
|
|
1274
|
+
* // Inherit parent model unless explicitly specified
|
|
1275
|
+
* const model = params.model ?? ctx.agentConfig?.model ?? "sonnet";
|
|
1276
|
+
*
|
|
1277
|
+
* const agent = new AgentBuilder(new LLMist())
|
|
1278
|
+
* .withModel(model)
|
|
1279
|
+
* .build();
|
|
1280
|
+
* // ...
|
|
1281
|
+
* }
|
|
1282
|
+
* ```
|
|
1283
|
+
*/
|
|
1284
|
+
agentConfig?: AgentContextConfig;
|
|
1285
|
+
/**
|
|
1286
|
+
* Subagent-specific configuration overrides from CLI config.
|
|
1287
|
+
*
|
|
1288
|
+
* Contains per-subagent settings defined in `[subagents.Name]` or
|
|
1289
|
+
* `[profile.subagents.Name]` sections of cli.toml. Allows users to
|
|
1290
|
+
* customize subagent behavior without modifying gadget parameters.
|
|
1291
|
+
*
|
|
1292
|
+
* Resolution priority (highest to lowest):
|
|
1293
|
+
* 1. Runtime params (explicit gadget call)
|
|
1294
|
+
* 2. Profile-level subagent config
|
|
1295
|
+
* 3. Global subagent config
|
|
1296
|
+
* 4. Parent model (if "inherit")
|
|
1297
|
+
* 5. Package defaults
|
|
1298
|
+
*
|
|
1299
|
+
* @example
|
|
1300
|
+
* ```typescript
|
|
1301
|
+
* execute: async (params, ctx) => {
|
|
1302
|
+
* const subagentConfig = ctx.subagentConfig?.BrowseWeb ?? {};
|
|
1303
|
+
*
|
|
1304
|
+
* const model = params.model
|
|
1305
|
+
* ?? subagentConfig.model
|
|
1306
|
+
* ?? ctx.agentConfig?.model
|
|
1307
|
+
* ?? "sonnet";
|
|
1308
|
+
*
|
|
1309
|
+
* const maxIterations = params.maxIterations
|
|
1310
|
+
* ?? subagentConfig.maxIterations
|
|
1311
|
+
* ?? 15;
|
|
1312
|
+
* // ...
|
|
1313
|
+
* }
|
|
1314
|
+
* ```
|
|
1315
|
+
*/
|
|
1316
|
+
subagentConfig?: SubagentConfigMap;
|
|
1317
|
+
}
|
|
1318
|
+
/**
|
|
1319
|
+
* Parent agent configuration passed to gadgets.
|
|
1320
|
+
* Contains settings that subagents can inherit.
|
|
1321
|
+
*/
|
|
1322
|
+
interface AgentContextConfig {
|
|
1323
|
+
/** Model identifier used by the parent agent */
|
|
1324
|
+
model: string;
|
|
1325
|
+
/** Temperature setting used by the parent agent */
|
|
1326
|
+
temperature?: number;
|
|
1260
1327
|
}
|
|
1328
|
+
/**
|
|
1329
|
+
* Configuration for a single subagent.
|
|
1330
|
+
* Can be defined globally in `[subagents.Name]` or per-profile in `[profile.subagents.Name]`.
|
|
1331
|
+
*
|
|
1332
|
+
* @example
|
|
1333
|
+
* ```toml
|
|
1334
|
+
* [subagents.BrowseWeb]
|
|
1335
|
+
* model = "inherit" # Use parent agent's model
|
|
1336
|
+
* maxIterations = 20
|
|
1337
|
+
* headless = true
|
|
1338
|
+
* ```
|
|
1339
|
+
*/
|
|
1340
|
+
interface SubagentConfig {
|
|
1341
|
+
/**
|
|
1342
|
+
* Model to use for this subagent.
|
|
1343
|
+
* - "inherit": Use parent agent's model (default behavior)
|
|
1344
|
+
* - Any model ID: Use specific model (e.g., "sonnet", "haiku", "gpt-4o")
|
|
1345
|
+
*/
|
|
1346
|
+
model?: string;
|
|
1347
|
+
/** Maximum iterations for the subagent loop */
|
|
1348
|
+
maxIterations?: number;
|
|
1349
|
+
/** Additional subagent-specific options */
|
|
1350
|
+
[key: string]: unknown;
|
|
1351
|
+
}
|
|
1352
|
+
/**
|
|
1353
|
+
* Map of subagent names to their configurations.
|
|
1354
|
+
*/
|
|
1355
|
+
type SubagentConfigMap = Record<string, SubagentConfig>;
|
|
1261
1356
|
|
|
1262
1357
|
/**
|
|
1263
|
-
*
|
|
1264
|
-
*
|
|
1265
|
-
*
|
|
1358
|
+
* Abstract base class for gadgets. Most users should use the `Gadget()` factory
|
|
1359
|
+
* or `createGadget()` function instead, as they provide better type safety
|
|
1360
|
+
* and simpler APIs.
|
|
1266
1361
|
*
|
|
1267
|
-
*
|
|
1362
|
+
* Extend this class directly only when you need advanced control over gadget behavior.
|
|
1268
1363
|
*/
|
|
1269
|
-
declare abstract class
|
|
1364
|
+
declare abstract class AbstractGadget {
|
|
1270
1365
|
/**
|
|
1271
1366
|
* The name of the gadget. Used for identification when LLM calls it.
|
|
1272
1367
|
* If not provided, defaults to the class name.
|
|
@@ -1332,14 +1427,14 @@ declare abstract class BaseGadget {
|
|
|
1332
1427
|
*/
|
|
1333
1428
|
abstract execute(params: Record<string, unknown>, ctx?: ExecutionContext): GadgetExecuteReturn | Promise<GadgetExecuteReturn>;
|
|
1334
1429
|
/**
|
|
1335
|
-
* Throws an
|
|
1430
|
+
* Throws an AbortException if the execution has been aborted.
|
|
1336
1431
|
*
|
|
1337
1432
|
* Call this at key checkpoints in long-running gadgets to allow early exit
|
|
1338
1433
|
* when the gadget has been cancelled (e.g., due to timeout). This enables
|
|
1339
1434
|
* resource cleanup and prevents unnecessary work after cancellation.
|
|
1340
1435
|
*
|
|
1341
1436
|
* @param ctx - The execution context containing the abort signal
|
|
1342
|
-
* @throws
|
|
1437
|
+
* @throws AbortException if ctx.signal.aborted is true
|
|
1343
1438
|
*
|
|
1344
1439
|
* @example
|
|
1345
1440
|
* ```typescript
|
|
@@ -1697,7 +1792,7 @@ type HintTemplate = string | ((context: HintContext) => string);
|
|
|
1697
1792
|
*
|
|
1698
1793
|
* @example
|
|
1699
1794
|
* ```typescript
|
|
1700
|
-
* const customConfig:
|
|
1795
|
+
* const customConfig: PromptTemplateConfig = {
|
|
1701
1796
|
* mainInstruction: "USE ONLY THE GADGET MARKERS BELOW:",
|
|
1702
1797
|
* criticalUsage: "Important: Follow the exact format shown.",
|
|
1703
1798
|
* rules: (ctx) => [
|
|
@@ -1708,7 +1803,7 @@ type HintTemplate = string | ((context: HintContext) => string);
|
|
|
1708
1803
|
* };
|
|
1709
1804
|
* ```
|
|
1710
1805
|
*/
|
|
1711
|
-
interface
|
|
1806
|
+
interface PromptTemplateConfig {
|
|
1712
1807
|
/**
|
|
1713
1808
|
* Main instruction block that appears at the start of the gadget system prompt.
|
|
1714
1809
|
* Default emphasizes using text markers instead of function calling.
|
|
@@ -1762,7 +1857,7 @@ declare const DEFAULT_HINTS: {
|
|
|
1762
1857
|
/**
|
|
1763
1858
|
* Default prompt templates used by llmist.
|
|
1764
1859
|
*/
|
|
1765
|
-
declare const DEFAULT_PROMPTS: Required<Omit<
|
|
1860
|
+
declare const DEFAULT_PROMPTS: Required<Omit<PromptTemplateConfig, "rules" | "customExamples" | "parallelGadgetsHint" | "iterationProgressHint"> & {
|
|
1766
1861
|
rules: (context: PromptContext) => string[];
|
|
1767
1862
|
customExamples: null;
|
|
1768
1863
|
}>;
|
|
@@ -1773,7 +1868,7 @@ declare function resolvePromptTemplate(template: PromptTemplate | undefined, def
|
|
|
1773
1868
|
/**
|
|
1774
1869
|
* Resolve rules template to an array of strings.
|
|
1775
1870
|
*/
|
|
1776
|
-
declare function resolveRulesTemplate(rules:
|
|
1871
|
+
declare function resolveRulesTemplate(rules: PromptTemplateConfig["rules"] | undefined, context: PromptContext): string[];
|
|
1777
1872
|
/**
|
|
1778
1873
|
* Resolve a hint template to a string using the given context.
|
|
1779
1874
|
* Supports both function templates and string templates with placeholders.
|
|
@@ -1785,14 +1880,14 @@ declare function resolveRulesTemplate(rules: PromptConfig["rules"] | undefined,
|
|
|
1785
1880
|
*/
|
|
1786
1881
|
declare function resolveHintTemplate(template: HintTemplate | undefined, defaultValue: string, context: HintContext): string;
|
|
1787
1882
|
|
|
1788
|
-
type
|
|
1883
|
+
type MessageRole = "system" | "user" | "assistant";
|
|
1789
1884
|
/**
|
|
1790
1885
|
* Message content can be a simple string (text only) or an array of content parts (multimodal).
|
|
1791
1886
|
* Using a string is simpler for text-only messages, while arrays support images and audio.
|
|
1792
1887
|
*/
|
|
1793
1888
|
type MessageContent = string | ContentPart[];
|
|
1794
1889
|
interface LLMMessage {
|
|
1795
|
-
role:
|
|
1890
|
+
role: MessageRole;
|
|
1796
1891
|
content: MessageContent;
|
|
1797
1892
|
name?: string;
|
|
1798
1893
|
metadata?: Record<string, unknown>;
|
|
@@ -1804,7 +1899,7 @@ interface LLMMessage {
|
|
|
1804
1899
|
* @param content - Message content (string or ContentPart[])
|
|
1805
1900
|
* @returns Array of content parts
|
|
1806
1901
|
*/
|
|
1807
|
-
declare function
|
|
1902
|
+
declare function normalizeMessageContent(content: MessageContent): ContentPart[];
|
|
1808
1903
|
/**
|
|
1809
1904
|
* Extract text from message content.
|
|
1810
1905
|
* Concatenates all text parts in the content.
|
|
@@ -1812,21 +1907,21 @@ declare function normalizeContent(content: MessageContent): ContentPart[];
|
|
|
1812
1907
|
* @param content - Message content (string or ContentPart[])
|
|
1813
1908
|
* @returns Combined text from all text parts
|
|
1814
1909
|
*/
|
|
1815
|
-
declare function
|
|
1910
|
+
declare function extractMessageText(content: MessageContent): string;
|
|
1816
1911
|
declare class LLMMessageBuilder {
|
|
1817
1912
|
private readonly messages;
|
|
1818
1913
|
private startPrefix;
|
|
1819
1914
|
private endPrefix;
|
|
1820
1915
|
private argPrefix;
|
|
1821
1916
|
private promptConfig;
|
|
1822
|
-
constructor(promptConfig?:
|
|
1917
|
+
constructor(promptConfig?: PromptTemplateConfig);
|
|
1823
1918
|
/**
|
|
1824
1919
|
* Set custom prefixes for gadget markers.
|
|
1825
1920
|
* Used to configure history builder to match system prompt markers.
|
|
1826
1921
|
*/
|
|
1827
1922
|
withPrefixes(startPrefix: string, endPrefix: string, argPrefix?: string): this;
|
|
1828
1923
|
addSystem(content: string, metadata?: Record<string, unknown>): this;
|
|
1829
|
-
addGadgets(gadgets:
|
|
1924
|
+
addGadgets(gadgets: AbstractGadget[], options?: {
|
|
1830
1925
|
startPrefix?: string;
|
|
1831
1926
|
endPrefix?: string;
|
|
1832
1927
|
argPrefix?: string;
|
|
@@ -1921,7 +2016,17 @@ declare class LLMMessageBuilder {
|
|
|
1921
2016
|
* ```
|
|
1922
2017
|
*/
|
|
1923
2018
|
addUserMultimodal(parts: ContentPart[]): this;
|
|
1924
|
-
|
|
2019
|
+
/**
|
|
2020
|
+
* Record a gadget execution result in the message history.
|
|
2021
|
+
* Creates an assistant message with the gadget invocation and a user message with the result.
|
|
2022
|
+
*
|
|
2023
|
+
* @param gadget - Name of the gadget that was executed
|
|
2024
|
+
* @param parameters - Parameters that were passed to the gadget
|
|
2025
|
+
* @param result - Text result from the gadget execution
|
|
2026
|
+
* @param media - Optional media outputs from the gadget
|
|
2027
|
+
* @param mediaIds - Optional IDs for the media outputs
|
|
2028
|
+
*/
|
|
2029
|
+
addGadgetCallResult(gadget: string, parameters: Record<string, unknown>, result: string, media?: GadgetMediaOutput[], mediaIds?: string[]): this;
|
|
1925
2030
|
/**
|
|
1926
2031
|
* Format parameters as Block format with JSON Pointer paths.
|
|
1927
2032
|
* Uses the configured argPrefix for consistency with system prompt.
|
|
@@ -2114,7 +2219,7 @@ declare class TextNamespace {
|
|
|
2114
2219
|
* @param options - Optional configuration
|
|
2115
2220
|
* @returns Complete text response
|
|
2116
2221
|
*/
|
|
2117
|
-
complete(prompt: string, options?:
|
|
2222
|
+
complete(prompt: string, options?: TextGenerationOptions): Promise<string>;
|
|
2118
2223
|
/**
|
|
2119
2224
|
* Stream text chunks.
|
|
2120
2225
|
*
|
|
@@ -2122,7 +2227,7 @@ declare class TextNamespace {
|
|
|
2122
2227
|
* @param options - Optional configuration
|
|
2123
2228
|
* @returns Async generator yielding text chunks
|
|
2124
2229
|
*/
|
|
2125
|
-
stream(prompt: string, options?:
|
|
2230
|
+
stream(prompt: string, options?: TextGenerationOptions): AsyncGenerator<string>;
|
|
2126
2231
|
}
|
|
2127
2232
|
|
|
2128
2233
|
/**
|
|
@@ -2345,7 +2450,7 @@ declare class LLMist {
|
|
|
2345
2450
|
* });
|
|
2346
2451
|
* ```
|
|
2347
2452
|
*/
|
|
2348
|
-
static complete(prompt: string, options?:
|
|
2453
|
+
static complete(prompt: string, options?: TextGenerationOptions): Promise<string>;
|
|
2349
2454
|
/**
|
|
2350
2455
|
* Quick streaming - returns async generator of text chunks.
|
|
2351
2456
|
* Convenient for streaming responses without needing agent setup.
|
|
@@ -2369,7 +2474,7 @@ declare class LLMist {
|
|
|
2369
2474
|
* }
|
|
2370
2475
|
* ```
|
|
2371
2476
|
*/
|
|
2372
|
-
static stream(prompt: string, options?:
|
|
2477
|
+
static stream(prompt: string, options?: TextGenerationOptions): AsyncGenerator<string>;
|
|
2373
2478
|
/**
|
|
2374
2479
|
* Instance method: Quick completion using this client instance.
|
|
2375
2480
|
*
|
|
@@ -2377,7 +2482,7 @@ declare class LLMist {
|
|
|
2377
2482
|
* @param options - Optional configuration
|
|
2378
2483
|
* @returns Complete text response
|
|
2379
2484
|
*/
|
|
2380
|
-
complete(prompt: string, options?:
|
|
2485
|
+
complete(prompt: string, options?: TextGenerationOptions): Promise<string>;
|
|
2381
2486
|
/**
|
|
2382
2487
|
* Instance method: Quick streaming using this client instance.
|
|
2383
2488
|
*
|
|
@@ -2385,7 +2490,7 @@ declare class LLMist {
|
|
|
2385
2490
|
* @param options - Optional configuration
|
|
2386
2491
|
* @returns Async generator yielding text chunks
|
|
2387
2492
|
*/
|
|
2388
|
-
streamText(prompt: string, options?:
|
|
2493
|
+
streamText(prompt: string, options?: TextGenerationOptions): AsyncGenerator<string>;
|
|
2389
2494
|
/**
|
|
2390
2495
|
* Create a fluent agent builder.
|
|
2391
2496
|
* Provides a chainable API for configuring and creating agents.
|
|
@@ -2432,8 +2537,8 @@ declare class LLMist {
|
|
|
2432
2537
|
createAgent(): AgentBuilder;
|
|
2433
2538
|
}
|
|
2434
2539
|
|
|
2435
|
-
type GadgetClass = new (...args: unknown[]) =>
|
|
2436
|
-
type GadgetOrClass =
|
|
2540
|
+
type GadgetClass = new (...args: unknown[]) => AbstractGadget;
|
|
2541
|
+
type GadgetOrClass = AbstractGadget | GadgetClass;
|
|
2437
2542
|
declare class GadgetRegistry {
|
|
2438
2543
|
private readonly gadgets;
|
|
2439
2544
|
/**
|
|
@@ -2472,12 +2577,12 @@ declare class GadgetRegistry {
|
|
|
2472
2577
|
* ```
|
|
2473
2578
|
*/
|
|
2474
2579
|
registerMany(gadgets: GadgetOrClass[]): this;
|
|
2475
|
-
register(name: string, gadget:
|
|
2476
|
-
registerByClass(gadget:
|
|
2477
|
-
get(name: string):
|
|
2580
|
+
register(name: string, gadget: AbstractGadget): void;
|
|
2581
|
+
registerByClass(gadget: AbstractGadget): void;
|
|
2582
|
+
get(name: string): AbstractGadget | undefined;
|
|
2478
2583
|
has(name: string): boolean;
|
|
2479
2584
|
getNames(): string[];
|
|
2480
|
-
getAll():
|
|
2585
|
+
getAll(): AbstractGadget[];
|
|
2481
2586
|
unregister(name: string): boolean;
|
|
2482
2587
|
clear(): void;
|
|
2483
2588
|
}
|
|
@@ -3320,8 +3425,8 @@ interface AgentOptions {
|
|
|
3320
3425
|
logger?: Logger<ILogObj>;
|
|
3321
3426
|
/** Clean hooks system */
|
|
3322
3427
|
hooks?: AgentHooks;
|
|
3323
|
-
/** Callback for human input */
|
|
3324
|
-
|
|
3428
|
+
/** Callback for requesting human input during execution */
|
|
3429
|
+
requestHumanInput?: (question: string) => Promise<string>;
|
|
3325
3430
|
/** Custom gadget start prefix */
|
|
3326
3431
|
gadgetStartPrefix?: string;
|
|
3327
3432
|
/** Custom gadget end prefix */
|
|
@@ -3349,8 +3454,8 @@ interface AgentOptions {
|
|
|
3349
3454
|
};
|
|
3350
3455
|
/** Stop on gadget error */
|
|
3351
3456
|
stopOnGadgetError?: boolean;
|
|
3352
|
-
/** Custom error
|
|
3353
|
-
|
|
3457
|
+
/** Custom error recovery logic */
|
|
3458
|
+
canRecoverFromGadgetError?: (context: {
|
|
3354
3459
|
error: string;
|
|
3355
3460
|
gadgetName: string;
|
|
3356
3461
|
errorType: "parse" | "validation" | "execution";
|
|
@@ -3359,7 +3464,7 @@ interface AgentOptions {
|
|
|
3359
3464
|
/** Default gadget timeout */
|
|
3360
3465
|
defaultGadgetTimeoutMs?: number;
|
|
3361
3466
|
/** Custom prompt configuration for gadget system prompts */
|
|
3362
|
-
promptConfig?:
|
|
3467
|
+
promptConfig?: PromptTemplateConfig;
|
|
3363
3468
|
/** Enable gadget output limiting (default: true) */
|
|
3364
3469
|
gadgetOutputLimit?: boolean;
|
|
3365
3470
|
/** Max gadget output as % of model context window (default: 15) */
|
|
@@ -3368,6 +3473,8 @@ interface AgentOptions {
|
|
|
3368
3473
|
compactionConfig?: CompactionConfig;
|
|
3369
3474
|
/** Optional abort signal for cancelling requests mid-flight */
|
|
3370
3475
|
signal?: AbortSignal;
|
|
3476
|
+
/** Subagent-specific configuration overrides (from CLI config) */
|
|
3477
|
+
subagentConfig?: SubagentConfigMap;
|
|
3371
3478
|
}
|
|
3372
3479
|
/**
|
|
3373
3480
|
* Agent: Lean orchestrator that delegates to StreamProcessor.
|
|
@@ -3396,20 +3503,22 @@ declare class Agent {
|
|
|
3396
3503
|
private readonly gadgetStartPrefix?;
|
|
3397
3504
|
private readonly gadgetEndPrefix?;
|
|
3398
3505
|
private readonly gadgetArgPrefix?;
|
|
3399
|
-
private readonly
|
|
3506
|
+
private readonly requestHumanInput?;
|
|
3400
3507
|
private readonly textOnlyHandler;
|
|
3401
3508
|
private readonly textWithGadgetsHandler?;
|
|
3402
3509
|
private readonly stopOnGadgetError;
|
|
3403
|
-
private readonly
|
|
3510
|
+
private readonly canRecoverFromGadgetError?;
|
|
3404
3511
|
private readonly defaultGadgetTimeoutMs?;
|
|
3405
3512
|
private readonly defaultMaxTokens?;
|
|
3406
|
-
private
|
|
3513
|
+
private hasUserPrompt;
|
|
3407
3514
|
private readonly outputStore;
|
|
3408
3515
|
private readonly outputLimitEnabled;
|
|
3409
3516
|
private readonly outputLimitCharLimit;
|
|
3410
3517
|
private readonly compactionManager?;
|
|
3411
3518
|
private readonly mediaStore;
|
|
3412
3519
|
private readonly signal?;
|
|
3520
|
+
private readonly agentContextConfig;
|
|
3521
|
+
private readonly subagentConfig?;
|
|
3413
3522
|
/**
|
|
3414
3523
|
* Creates a new Agent instance.
|
|
3415
3524
|
* @internal This constructor is private. Use LLMist.createAgent() or AgentBuilder instead.
|
|
@@ -3526,10 +3635,10 @@ declare class Agent {
|
|
|
3526
3635
|
*/
|
|
3527
3636
|
private resolveMaxTokensFromCatalog;
|
|
3528
3637
|
/**
|
|
3529
|
-
*
|
|
3638
|
+
* Chain the output limiter interceptor with user-provided hooks.
|
|
3530
3639
|
* The limiter runs first, then chains to any user interceptor.
|
|
3531
3640
|
*/
|
|
3532
|
-
private
|
|
3641
|
+
private chainOutputLimiterWithUserHooks;
|
|
3533
3642
|
/**
|
|
3534
3643
|
* Run agent with named event handlers (syntactic sugar).
|
|
3535
3644
|
*
|
|
@@ -3605,20 +3714,21 @@ declare class AgentBuilder {
|
|
|
3605
3714
|
private promptConfig?;
|
|
3606
3715
|
private gadgets;
|
|
3607
3716
|
private initialMessages;
|
|
3608
|
-
private
|
|
3717
|
+
private requestHumanInput?;
|
|
3609
3718
|
private gadgetStartPrefix?;
|
|
3610
3719
|
private gadgetEndPrefix?;
|
|
3611
3720
|
private gadgetArgPrefix?;
|
|
3612
3721
|
private textOnlyHandler?;
|
|
3613
3722
|
private textWithGadgetsHandler?;
|
|
3614
3723
|
private stopOnGadgetError?;
|
|
3615
|
-
private
|
|
3724
|
+
private canRecoverFromGadgetError?;
|
|
3616
3725
|
private defaultGadgetTimeoutMs?;
|
|
3617
3726
|
private gadgetOutputLimit?;
|
|
3618
3727
|
private gadgetOutputLimitPercent?;
|
|
3619
3728
|
private compactionConfig?;
|
|
3620
3729
|
private signal?;
|
|
3621
3730
|
private trailingMessage?;
|
|
3731
|
+
private subagentConfig?;
|
|
3622
3732
|
constructor(client?: LLMist);
|
|
3623
3733
|
/**
|
|
3624
3734
|
* Set the model to use.
|
|
@@ -3689,13 +3799,13 @@ declare class AgentBuilder {
|
|
|
3689
3799
|
*
|
|
3690
3800
|
* @example
|
|
3691
3801
|
* ```typescript
|
|
3692
|
-
* .
|
|
3802
|
+
* .withPromptTemplateConfig({
|
|
3693
3803
|
* mainInstruction: "Use the gadget markers below:",
|
|
3694
3804
|
* rules: ["Always use markers", "Never use function calling"]
|
|
3695
3805
|
* })
|
|
3696
3806
|
* ```
|
|
3697
3807
|
*/
|
|
3698
|
-
|
|
3808
|
+
withPromptTemplateConfig(config: PromptTemplateConfig): this;
|
|
3699
3809
|
/**
|
|
3700
3810
|
* Add gadgets (classes or instances).
|
|
3701
3811
|
* Can be called multiple times to add more gadgets.
|
|
@@ -3874,9 +3984,9 @@ declare class AgentBuilder {
|
|
|
3874
3984
|
* Provides fine-grained control over whether to continue after different types of errors.
|
|
3875
3985
|
* Overrides `stopOnGadgetError` when provided.
|
|
3876
3986
|
*
|
|
3877
|
-
* **Note:** This builder method configures the underlying `
|
|
3987
|
+
* **Note:** This builder method configures the underlying `canRecoverFromGadgetError` option
|
|
3878
3988
|
* in `AgentOptions`. The method is named `withErrorHandler` for better developer experience,
|
|
3879
|
-
* but maps to the `
|
|
3989
|
+
* but maps to the `canRecoverFromGadgetError` property internally.
|
|
3880
3990
|
*
|
|
3881
3991
|
* @param handler - Function that decides whether to continue after an error.
|
|
3882
3992
|
* Return `true` to continue execution, `false` to stop.
|
|
@@ -4016,6 +4126,24 @@ declare class AgentBuilder {
|
|
|
4016
4126
|
* ```
|
|
4017
4127
|
*/
|
|
4018
4128
|
withSignal(signal: AbortSignal): this;
|
|
4129
|
+
/**
|
|
4130
|
+
* Set subagent configuration overrides.
|
|
4131
|
+
*
|
|
4132
|
+
* Subagent gadgets (like BrowseWeb) can read these settings from ExecutionContext
|
|
4133
|
+
* to inherit model and other options from the CLI configuration.
|
|
4134
|
+
*
|
|
4135
|
+
* @param config - Subagent configuration map keyed by gadget name
|
|
4136
|
+
* @returns This builder for chaining
|
|
4137
|
+
*
|
|
4138
|
+
* @example
|
|
4139
|
+
* ```typescript
|
|
4140
|
+
* .withSubagentConfig({
|
|
4141
|
+
* BrowseWeb: { model: "inherit", maxIterations: 20, headless: true },
|
|
4142
|
+
* CodeAnalyzer: { model: "sonnet", maxIterations: 10 }
|
|
4143
|
+
* })
|
|
4144
|
+
* ```
|
|
4145
|
+
*/
|
|
4146
|
+
withSubagentConfig(config: SubagentConfigMap): this;
|
|
4019
4147
|
/**
|
|
4020
4148
|
* Add an ephemeral trailing message that appears at the end of each LLM request.
|
|
4021
4149
|
*
|
|
@@ -4237,7 +4365,7 @@ interface IConversationManager {
|
|
|
4237
4365
|
* Adds a gadget call and its result to the conversation.
|
|
4238
4366
|
* Optionally includes media outputs (images, audio, etc.) for multimodal results.
|
|
4239
4367
|
*/
|
|
4240
|
-
|
|
4368
|
+
addGadgetCallResult(gadgetName: string, parameters: Record<string, unknown>, result: string, media?: GadgetMediaOutput[], mediaIds?: string[]): void;
|
|
4241
4369
|
/**
|
|
4242
4370
|
* Gets the complete conversation history including base messages (system prompts, gadget instructions).
|
|
4243
4371
|
*/
|
|
@@ -4973,4 +5101,4 @@ declare function createTextMockStream(text: string, options?: {
|
|
|
4973
5101
|
usage?: MockResponse["usage"];
|
|
4974
5102
|
}): LLMStream;
|
|
4975
5103
|
|
|
4976
|
-
export { type
|
|
5104
|
+
export { type ImageModelSpec 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 GadgetExecuteReturn as N, type GadgetExample as O, type ParsedGadgetCall as P, type GadgetExecutionResult as Q, type ResolvedCompactionConfig as R, type StreamEvent as S, type TokenUsage as T, type MediaKind as U, type MediaMetadata as V, type GadgetExecuteResultWithMedia as W, type ProviderAdapter as X, type ModelDescriptor as Y, type ModelSpec as Z, type LLMGenerationOptions as _, type LLMStream as a, parseDataUrl as a$, type ImageGenerationOptions as a0, type ImageGenerationResult as a1, type SpeechModelSpec as a2, type SpeechGenerationOptions as a3, type SpeechGenerationResult as a4, type HistoryMessage as a5, type TrailingMessage as a6, type TrailingMessageContext as a7, AgentBuilder as a8, type EventHandlers as a9, type ObserveLLMCompleteContext as aA, type ObserveLLMErrorContext as aB, type Observers as aC, DEFAULT_COMPACTION_CONFIG as aD, DEFAULT_SUMMARIZATION_PROMPT as aE, type LLMistOptions as aF, type AudioContentPart as aG, type AudioMimeType as aH, type AudioSource as aI, type ContentPart as aJ, type ImageBase64Source as aK, type ImageContentPart as aL, type ImageMimeType as aM, type ImageSource as aN, type ImageUrlSource as aO, type TextContentPart as aP, audioFromBase64 as aQ, audioFromBuffer as aR, detectAudioMimeType as aS, detectImageMimeType as aT, imageFromBase64 as aU, imageFromBuffer as aV, imageFromUrl as aW, isAudioPart as aX, isDataUrl as aY, isImagePart as aZ, isTextPart as a_, collectEvents as aa, collectText as ab, runWithHandlers as ac, type AfterGadgetExecutionAction as ad, type AfterGadgetExecutionControllerContext as ae, type AfterLLMCallAction as af, type AfterLLMCallControllerContext as ag, type AfterLLMErrorAction as ah, type AgentOptions as ai, type BeforeGadgetExecutionAction as aj, type BeforeLLMCallAction as ak, type ChunkInterceptorContext as al, type Controllers as am, type GadgetExecutionControllerContext as an, type GadgetParameterInterceptorContext as ao, type GadgetResultInterceptorContext as ap, type Interceptors as aq, type LLMCallControllerContext as ar, type LLMErrorControllerContext as as, type MessageInterceptorContext as at, type MessageTurn as au, type ObserveChunkContext as av, type ObserveCompactionContext as aw, type ObserveGadgetCompleteContext as ax, type ObserveGadgetStartContext as ay, type ObserveLLMCallContext as az, type LLMStreamChunk as b, text as b0, toBase64 as b1, type MessageRole as b2, extractMessageText as b3, LLMMessageBuilder as b4, normalizeMessageContent as b5, type CostEstimate as b6, type ModelFeatures as b7, type ModelLimits as b8, type ModelPricing as b9, type TextOnlyHandler as bA, type TextOnlyStrategy as bB, type VisionAnalyzeOptions as ba, type VisionAnalyzeResult as bb, type ProviderIdentifier as bc, ModelIdentifierParser as bd, type HintContext as be, type PromptContext as bf, type PromptTemplate as bg, type PromptTemplateConfig as bh, DEFAULT_HINTS as bi, DEFAULT_PROMPTS as bj, resolveHintTemplate as bk, resolvePromptTemplate as bl, resolveRulesTemplate as bm, type TextGenerationOptions as bn, complete as bo, stream as bp, type GadgetClass as bq, type GadgetOrClass as br, type CostReportingLLMist as bs, type GadgetExecuteResult as bt, type GadgetSkippedEvent as bu, type StoredMedia as bv, type TextOnlyAction as bw, type TextOnlyContext as bx, type TextOnlyCustomHandler as by, type TextOnlyGadgetConfig 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 };
|