llmist 1.6.1 → 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.
@@ -30,7 +30,7 @@ import {
30
30
  init_strategy,
31
31
  init_stream_processor,
32
32
  resolveHintTemplate
33
- } from "./chunk-X5XQ6M5P.js";
33
+ } from "./chunk-T3DIKQWU.js";
34
34
 
35
35
  // src/index.ts
36
36
  init_builder();
@@ -971,4 +971,4 @@ export {
971
971
  Gadget,
972
972
  z
973
973
  };
974
- //# sourceMappingURL=chunk-QR5IQXEM.js.map
974
+ //# sourceMappingURL=chunk-TDRPJP2Q.js.map
package/dist/cli.cjs CHANGED
@@ -1074,7 +1074,7 @@ function applyLineLimit(lines, limit) {
1074
1074
  }
1075
1075
  return lines;
1076
1076
  }
1077
- function createGadgetOutputViewer(store) {
1077
+ function createGadgetOutputViewer(store, maxOutputChars = DEFAULT_MAX_OUTPUT_CHARS) {
1078
1078
  return createGadget({
1079
1079
  name: "GadgetOutputViewer",
1080
1080
  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.",
@@ -1139,19 +1139,43 @@ function createGadgetOutputViewer(store) {
1139
1139
  if (limit) {
1140
1140
  lines = applyLineLimit(lines, limit);
1141
1141
  }
1142
+ let output = lines.join("\n");
1142
1143
  const totalLines = stored.lineCount;
1143
1144
  const returnedLines = lines.length;
1144
1145
  if (returnedLines === 0) {
1145
1146
  return `No lines matched the filters. Original output had ${totalLines} lines.`;
1146
1147
  }
1147
- const header = returnedLines < totalLines ? `[Showing ${returnedLines} of ${totalLines} lines]
1148
- ` : `[Showing all ${totalLines} lines]
1148
+ let truncatedBySize = false;
1149
+ let linesIncluded = returnedLines;
1150
+ if (output.length > maxOutputChars) {
1151
+ truncatedBySize = true;
1152
+ let truncatedOutput = "";
1153
+ linesIncluded = 0;
1154
+ for (const line of lines) {
1155
+ if (truncatedOutput.length + line.length + 1 > maxOutputChars) break;
1156
+ truncatedOutput += line + "\n";
1157
+ linesIncluded++;
1158
+ }
1159
+ output = truncatedOutput;
1160
+ }
1161
+ let header;
1162
+ if (truncatedBySize) {
1163
+ const remainingLines = returnedLines - linesIncluded;
1164
+ header = `[Showing ${linesIncluded} of ${totalLines} lines (truncated due to size limit)]
1165
+ [... ${remainingLines.toLocaleString()} more lines. Use limit parameter to paginate, e.g., limit: "${linesIncluded + 1}-${linesIncluded + 200}"]
1149
1166
  `;
1150
- return header + lines.join("\n");
1167
+ } else if (returnedLines < totalLines) {
1168
+ header = `[Showing ${returnedLines} of ${totalLines} lines]
1169
+ `;
1170
+ } else {
1171
+ header = `[Showing all ${totalLines} lines]
1172
+ `;
1173
+ }
1174
+ return header + output;
1151
1175
  }
1152
1176
  });
1153
1177
  }
1154
- var import_zod, patternSchema;
1178
+ var import_zod, patternSchema, DEFAULT_MAX_OUTPUT_CHARS;
1155
1179
  var init_output_viewer = __esm({
1156
1180
  "src/gadgets/output-viewer.ts"() {
1157
1181
  "use strict";
@@ -1163,6 +1187,7 @@ var init_output_viewer = __esm({
1163
1187
  before: import_zod.z.number().int().min(0).default(0).describe("Context lines before each match (like grep -B)"),
1164
1188
  after: import_zod.z.number().int().min(0).default(0).describe("Context lines after each match (like grep -A)")
1165
1189
  });
1190
+ DEFAULT_MAX_OUTPUT_CHARS = 76800;
1166
1191
  }
1167
1192
  });
1168
1193
 
@@ -3338,7 +3363,10 @@ var init_agent = __esm({
3338
3363
  const contextWindow = limits?.contextWindow ?? FALLBACK_CONTEXT_WINDOW;
3339
3364
  this.outputLimitCharLimit = Math.floor(contextWindow * (limitPercent / 100) * CHARS_PER_TOKEN);
3340
3365
  if (this.outputLimitEnabled) {
3341
- this.registry.register("GadgetOutputViewer", createGadgetOutputViewer(this.outputStore));
3366
+ this.registry.register(
3367
+ "GadgetOutputViewer",
3368
+ createGadgetOutputViewer(this.outputStore, this.outputLimitCharLimit)
3369
+ );
3342
3370
  }
3343
3371
  this.hooks = this.mergeOutputLimiterHook(options.hooks);
3344
3372
  const baseBuilder = new LLMMessageBuilder(options.promptConfig);
@@ -6587,7 +6615,7 @@ var import_commander2 = require("commander");
6587
6615
  // package.json
6588
6616
  var package_default = {
6589
6617
  name: "llmist",
6590
- version: "1.6.0",
6618
+ version: "1.6.1",
6591
6619
  description: "Universal TypeScript LLM client with streaming-first agent framework. Works with any model - no structured outputs or native tool calling required. Implements its own flexible grammar for function calling.",
6592
6620
  type: "module",
6593
6621
  main: "dist/index.cjs",