llmist 1.6.0 → 1.6.2

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/index.d.cts CHANGED
@@ -1517,16 +1517,17 @@ declare function createGadget<TSchema extends ZodType>(config: CreateGadgetConfi
1517
1517
  * which is created per-agent-run.
1518
1518
  *
1519
1519
  * @param store - The GadgetOutputStore to read outputs from
1520
+ * @param maxOutputChars - Maximum characters to return (default: 76,800 = ~19k tokens)
1520
1521
  * @returns A GadgetOutputViewer gadget instance
1521
1522
  *
1522
1523
  * @example
1523
1524
  * ```typescript
1524
1525
  * const store = new GadgetOutputStore();
1525
- * const viewer = createGadgetOutputViewer(store);
1526
+ * const viewer = createGadgetOutputViewer(store, 76_800);
1526
1527
  * registry.register("GadgetOutputViewer", viewer);
1527
1528
  * ```
1528
1529
  */
1529
- declare function createGadgetOutputViewer(store: GadgetOutputStore): BaseGadget;
1530
+ declare function createGadgetOutputViewer(store: GadgetOutputStore, maxOutputChars?: number): BaseGadget;
1530
1531
 
1531
1532
  /**
1532
1533
  * Exception that gadgets can throw to signal the agent loop should terminate.
package/dist/index.d.ts CHANGED
@@ -1517,16 +1517,17 @@ declare function createGadget<TSchema extends ZodType>(config: CreateGadgetConfi
1517
1517
  * which is created per-agent-run.
1518
1518
  *
1519
1519
  * @param store - The GadgetOutputStore to read outputs from
1520
+ * @param maxOutputChars - Maximum characters to return (default: 76,800 = ~19k tokens)
1520
1521
  * @returns A GadgetOutputViewer gadget instance
1521
1522
  *
1522
1523
  * @example
1523
1524
  * ```typescript
1524
1525
  * const store = new GadgetOutputStore();
1525
- * const viewer = createGadgetOutputViewer(store);
1526
+ * const viewer = createGadgetOutputViewer(store, 76_800);
1526
1527
  * registry.register("GadgetOutputViewer", viewer);
1527
1528
  * ```
1528
1529
  */
1529
- declare function createGadgetOutputViewer(store: GadgetOutputStore): BaseGadget;
1530
+ declare function createGadgetOutputViewer(store: GadgetOutputStore, maxOutputChars?: number): BaseGadget;
1530
1531
 
1531
1532
  /**
1532
1533
  * Exception that gadgets can throw to signal the agent loop should terminate.
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  iterationProgressHint,
6
6
  parallelGadgetHint,
7
7
  z
8
- } from "./chunk-QR5IQXEM.js";
8
+ } from "./chunk-TDRPJP2Q.js";
9
9
  import {
10
10
  AgentBuilder,
11
11
  AnthropicMessagesProvider,
@@ -64,7 +64,7 @@ import {
64
64
  stream,
65
65
  validateAndApplyDefaults,
66
66
  validateGadgetParams
67
- } from "./chunk-X5XQ6M5P.js";
67
+ } from "./chunk-T3DIKQWU.js";
68
68
  export {
69
69
  AgentBuilder,
70
70
  AnthropicMessagesProvider,
@@ -1073,7 +1073,7 @@ function applyLineLimit(lines, limit) {
1073
1073
  }
1074
1074
  return lines;
1075
1075
  }
1076
- function createGadgetOutputViewer(store) {
1076
+ function createGadgetOutputViewer(store, maxOutputChars = DEFAULT_MAX_OUTPUT_CHARS) {
1077
1077
  return createGadget({
1078
1078
  name: "GadgetOutputViewer",
1079
1079
  description: "View stored output from gadgets that returned too much data. Use patterns to filter lines (like grep) and limit to control output size. Patterns are applied first in order, then the limit is applied to the result.",
@@ -1138,19 +1138,43 @@ function createGadgetOutputViewer(store) {
1138
1138
  if (limit) {
1139
1139
  lines = applyLineLimit(lines, limit);
1140
1140
  }
1141
+ let output = lines.join("\n");
1141
1142
  const totalLines = stored.lineCount;
1142
1143
  const returnedLines = lines.length;
1143
1144
  if (returnedLines === 0) {
1144
1145
  return `No lines matched the filters. Original output had ${totalLines} lines.`;
1145
1146
  }
1146
- const header = returnedLines < totalLines ? `[Showing ${returnedLines} of ${totalLines} lines]
1147
- ` : `[Showing all ${totalLines} lines]
1147
+ let truncatedBySize = false;
1148
+ let linesIncluded = returnedLines;
1149
+ if (output.length > maxOutputChars) {
1150
+ truncatedBySize = true;
1151
+ let truncatedOutput = "";
1152
+ linesIncluded = 0;
1153
+ for (const line of lines) {
1154
+ if (truncatedOutput.length + line.length + 1 > maxOutputChars) break;
1155
+ truncatedOutput += line + "\n";
1156
+ linesIncluded++;
1157
+ }
1158
+ output = truncatedOutput;
1159
+ }
1160
+ let header;
1161
+ if (truncatedBySize) {
1162
+ const remainingLines = returnedLines - linesIncluded;
1163
+ header = `[Showing ${linesIncluded} of ${totalLines} lines (truncated due to size limit)]
1164
+ [... ${remainingLines.toLocaleString()} more lines. Use limit parameter to paginate, e.g., limit: "${linesIncluded + 1}-${linesIncluded + 200}"]
1148
1165
  `;
1149
- return header + lines.join("\n");
1166
+ } else if (returnedLines < totalLines) {
1167
+ header = `[Showing ${returnedLines} of ${totalLines} lines]
1168
+ `;
1169
+ } else {
1170
+ header = `[Showing all ${totalLines} lines]
1171
+ `;
1172
+ }
1173
+ return header + output;
1150
1174
  }
1151
1175
  });
1152
1176
  }
1153
- var import_zod, patternSchema;
1177
+ var import_zod, patternSchema, DEFAULT_MAX_OUTPUT_CHARS;
1154
1178
  var init_output_viewer = __esm({
1155
1179
  "src/gadgets/output-viewer.ts"() {
1156
1180
  "use strict";
@@ -1162,6 +1186,7 @@ var init_output_viewer = __esm({
1162
1186
  before: import_zod.z.number().int().min(0).default(0).describe("Context lines before each match (like grep -B)"),
1163
1187
  after: import_zod.z.number().int().min(0).default(0).describe("Context lines after each match (like grep -A)")
1164
1188
  });
1189
+ DEFAULT_MAX_OUTPUT_CHARS = 76800;
1165
1190
  }
1166
1191
  });
1167
1192
 
@@ -3337,7 +3362,10 @@ var init_agent = __esm({
3337
3362
  const contextWindow = limits?.contextWindow ?? FALLBACK_CONTEXT_WINDOW;
3338
3363
  this.outputLimitCharLimit = Math.floor(contextWindow * (limitPercent / 100) * CHARS_PER_TOKEN);
3339
3364
  if (this.outputLimitEnabled) {
3340
- this.registry.register("GadgetOutputViewer", createGadgetOutputViewer(this.outputStore));
3365
+ this.registry.register(
3366
+ "GadgetOutputViewer",
3367
+ createGadgetOutputViewer(this.outputStore, this.outputLimitCharLimit)
3368
+ );
3341
3369
  }
3342
3370
  this.hooks = this.mergeOutputLimiterHook(options.hooks);
3343
3371
  const baseBuilder = new LLMMessageBuilder(options.promptConfig);