llmist 3.1.0 → 4.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/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import "./chunk-LFI4WQVV.js";
2
+ import "./chunk-Q6NQRMYD.js";
3
3
  import {
4
4
  AbstractGadget,
5
5
  AgentBuilder,
@@ -34,7 +34,7 @@ import {
34
34
  schemaToJSONSchema,
35
35
  text,
36
36
  validateGadgetSchema
37
- } from "./chunk-JCFPJMRQ.js";
37
+ } from "./chunk-RHR2M6T6.js";
38
38
 
39
39
  // src/cli/constants.ts
40
40
  var CLI_NAME = "llmist";
@@ -123,7 +123,7 @@ import { Command, InvalidArgumentError as InvalidArgumentError2 } from "commande
123
123
  // package.json
124
124
  var package_default = {
125
125
  name: "llmist",
126
- version: "3.0.0",
126
+ version: "3.1.0",
127
127
  description: "TypeScript LLM client with streaming tool execution. Tools fire mid-stream. Built-in function calling works with any model\u2014no structured outputs or native tool support required.",
128
128
  type: "module",
129
129
  main: "dist/index.cjs",
@@ -3063,20 +3063,53 @@ function renderOverallSummary(metadata) {
3063
3063
  }
3064
3064
  return parts.join(chalk3.dim(" | "));
3065
3065
  }
3066
- function formatParametersInline(params) {
3066
+ function getRawValue(value) {
3067
+ if (typeof value === "string") {
3068
+ return value;
3069
+ }
3070
+ if (typeof value === "boolean" || typeof value === "number") {
3071
+ return String(value);
3072
+ }
3073
+ return JSON.stringify(value);
3074
+ }
3075
+ function truncateValue(str, maxLen) {
3076
+ if (maxLen <= 0) return "";
3077
+ if (str.length <= maxLen) return str;
3078
+ return `${str.slice(0, maxLen)}\u2026`;
3079
+ }
3080
+ function formatParametersInline(params, maxWidth) {
3067
3081
  if (!params || Object.keys(params).length === 0) {
3068
3082
  return "";
3069
3083
  }
3070
- return Object.entries(params).map(([key, value]) => {
3071
- let formatted;
3072
- if (typeof value === "string") {
3073
- formatted = value.length > 30 ? `${value.slice(0, 30)}\u2026` : value;
3074
- } else if (typeof value === "boolean" || typeof value === "number") {
3075
- formatted = String(value);
3084
+ const entries = Object.entries(params);
3085
+ const defaultLimit = 30;
3086
+ const rawValues = entries.map(([, value]) => getRawValue(value));
3087
+ const overhead = entries.reduce((sum, [key], i) => {
3088
+ return sum + key.length + 1 + (i > 0 ? 2 : 0);
3089
+ }, 0);
3090
+ let limits;
3091
+ if (maxWidth && maxWidth > overhead) {
3092
+ const availableForValues = maxWidth - overhead;
3093
+ const totalRawLength = rawValues.reduce((sum, v) => sum + v.length, 0);
3094
+ if (totalRawLength <= availableForValues) {
3095
+ limits = rawValues.map(() => Infinity);
3076
3096
  } else {
3077
- const json = JSON.stringify(value);
3078
- formatted = json.length > 30 ? `${json.slice(0, 30)}\u2026` : json;
3097
+ const minPerValue = 10;
3098
+ const minTotal = entries.length * minPerValue;
3099
+ if (availableForValues <= minTotal) {
3100
+ limits = rawValues.map(() => Math.max(1, Math.floor(availableForValues / entries.length)));
3101
+ } else {
3102
+ limits = rawValues.map((v) => {
3103
+ const proportion = v.length / totalRawLength;
3104
+ return Math.max(minPerValue, Math.floor(proportion * availableForValues));
3105
+ });
3106
+ }
3079
3107
  }
3108
+ } else {
3109
+ limits = rawValues.map(() => defaultLimit);
3110
+ }
3111
+ return entries.map(([key, _], i) => {
3112
+ const formatted = truncateValue(rawValues[i], limits[i]);
3080
3113
  return `${chalk3.dim(key)}${chalk3.dim("=")}${chalk3.cyan(formatted)}`;
3081
3114
  }).join(chalk3.dim(", "));
3082
3115
  }
@@ -3112,25 +3145,28 @@ function formatMediaLine(media) {
3112
3145
  return `${chalk3.dim("[")}${icon} ${id} ${mimeType} ${size}${chalk3.dim("]")} ${chalk3.dim("\u2192")} ${path6}`;
3113
3146
  }
3114
3147
  function formatGadgetSummary2(result) {
3148
+ const terminalWidth = process.stdout.columns || 80;
3115
3149
  const gadgetLabel = chalk3.magenta.bold(result.gadgetName);
3116
- const timeLabel = chalk3.dim(
3117
- result.executionTimeMs >= 1e3 ? `${(result.executionTimeMs / 1e3).toFixed(1)}s` : `${Math.round(result.executionTimeMs)}ms`
3118
- );
3119
- const paramsStr = formatParametersInline(result.parameters);
3120
- const paramsLabel = paramsStr ? `${chalk3.dim("(")}${paramsStr}${chalk3.dim(")")}` : "";
3121
- if (result.error) {
3122
- const errorMsg = result.error.length > 50 ? `${result.error.slice(0, 50)}\u2026` : result.error;
3123
- return `${chalk3.red("\u2717")} ${gadgetLabel}${paramsLabel} ${chalk3.red("error:")} ${errorMsg} ${timeLabel}`;
3124
- }
3125
- let outputLabel;
3150
+ const timeStr = result.executionTimeMs >= 1e3 ? `${(result.executionTimeMs / 1e3).toFixed(1)}s` : `${Math.round(result.executionTimeMs)}ms`;
3151
+ const timeLabel = chalk3.dim(timeStr);
3152
+ let outputStr;
3126
3153
  if (result.tokenCount !== void 0 && result.tokenCount > 0) {
3127
- outputLabel = chalk3.green(`${formatTokens(result.tokenCount)} tokens`);
3154
+ outputStr = `${formatTokens(result.tokenCount)} tokens`;
3128
3155
  } else if (result.result) {
3129
3156
  const outputBytes = Buffer.byteLength(result.result, "utf-8");
3130
- outputLabel = outputBytes > 0 ? chalk3.green(formatBytes(outputBytes)) : chalk3.dim("no output");
3157
+ outputStr = outputBytes > 0 ? formatBytes(outputBytes) : "no output";
3131
3158
  } else {
3132
- outputLabel = chalk3.dim("no output");
3159
+ outputStr = "no output";
3160
+ }
3161
+ const fixedLength = 2 + result.gadgetName.length + 2 + 3 + outputStr.length + 1 + timeStr.length;
3162
+ const availableForParams = Math.max(40, terminalWidth - fixedLength - 2);
3163
+ const paramsStr = formatParametersInline(result.parameters, availableForParams);
3164
+ const paramsLabel = paramsStr ? `${chalk3.dim("(")}${paramsStr}${chalk3.dim(")")}` : "";
3165
+ if (result.error) {
3166
+ const errorMsg = result.error.length > 50 ? `${result.error.slice(0, 50)}\u2026` : result.error;
3167
+ return `${chalk3.red("\u2717")} ${gadgetLabel}${paramsLabel} ${chalk3.red("error:")} ${errorMsg} ${timeLabel}`;
3133
3168
  }
3169
+ const outputLabel = outputStr === "no output" ? chalk3.dim(outputStr) : chalk3.green(outputStr);
3134
3170
  const icon = result.breaksLoop ? chalk3.yellow("\u23F9") : chalk3.green("\u2713");
3135
3171
  let summaryLine = `${icon} ${gadgetLabel}${paramsLabel} ${chalk3.dim("\u2192")} ${outputLabel} ${timeLabel}`;
3136
3172
  if (result.media && result.media.length > 0) {
@@ -3397,6 +3433,18 @@ var StreamProgress = class {
3397
3433
  this.render();
3398
3434
  }
3399
3435
  }
3436
+ /**
3437
+ * Mark a nested gadget as completed (keeps it visible with ✓ indicator).
3438
+ */
3439
+ completeNestedGadget(id) {
3440
+ const gadget = this.nestedGadgets.get(id);
3441
+ if (gadget) {
3442
+ gadget.completed = true;
3443
+ if (this.isRunning && this.isTTY) {
3444
+ this.render();
3445
+ }
3446
+ }
3447
+ }
3400
3448
  /**
3401
3449
  * Starts a new LLM call. Switches to streaming mode.
3402
3450
  * @param model - Model name being used
@@ -3545,11 +3593,12 @@ var StreamProgress = class {
3545
3593
  const nestedLine = `${indent}${chalk4.cyan(`#${nested.iteration}`)} ${chalk4.dim(nested.model)}${tokens}${outTokens} ${chalk4.dim(nestedElapsed + "s")} ${chalk4.cyan(spinner)}`;
3546
3594
  lines.push(nestedLine);
3547
3595
  }
3548
- for (const [_nestedId, nestedGadget] of this.nestedGadgets) {
3596
+ for (const [nestedId, nestedGadget] of this.nestedGadgets) {
3549
3597
  if (nestedGadget.parentInvocationId === gadgetId) {
3550
3598
  const indent = " ".repeat(nestedGadget.depth + 1);
3551
3599
  const nestedElapsed = ((Date.now() - nestedGadget.startTime) / 1e3).toFixed(1);
3552
- const nestedGadgetLine = `${indent}${chalk4.blue("\u23F5")} ${chalk4.dim(nestedGadget.name + "(...)")} ${chalk4.dim(nestedElapsed + "s")}`;
3600
+ const icon = nestedGadget.completed ? chalk4.green("\u2713") : chalk4.blue("\u23F5");
3601
+ const nestedGadgetLine = `${indent}${icon} ${chalk4.dim(nestedGadget.name + "(...)")} ${chalk4.dim(nestedElapsed + "s")}`;
3553
3602
  lines.push(nestedGadgetLine);
3554
3603
  }
3555
3604
  }
@@ -4260,34 +4309,34 @@ Denied: ${result.reason ?? "by user"}`
4260
4309
  ].join(" ")
4261
4310
  );
4262
4311
  if (!options.quiet) {
4263
- builder.withNestedEventCallback((event) => {
4264
- if (event.type === "llm_call_start") {
4265
- const info = event.event;
4266
- const nestedId = `${event.gadgetInvocationId}:${info.iteration}`;
4312
+ builder.withSubagentEventCallback((subagentEvent) => {
4313
+ if (subagentEvent.type === "llm_call_start") {
4314
+ const info = subagentEvent.event;
4315
+ const subagentId = `${subagentEvent.gadgetInvocationId}:${info.iteration}`;
4267
4316
  progress.addNestedAgent(
4268
- nestedId,
4269
- event.gadgetInvocationId,
4270
- event.depth,
4317
+ subagentId,
4318
+ subagentEvent.gadgetInvocationId,
4319
+ subagentEvent.depth,
4271
4320
  info.model,
4272
4321
  info.iteration,
4273
4322
  info.inputTokens
4274
4323
  );
4275
- } else if (event.type === "llm_call_end") {
4276
- const info = event.event;
4277
- const nestedId = `${event.gadgetInvocationId}:${info.iteration}`;
4278
- progress.updateNestedAgent(nestedId, info.outputTokens);
4279
- setTimeout(() => progress.removeNestedAgent(nestedId), 100);
4280
- } else if (event.type === "gadget_call") {
4281
- const gadgetEvent = event.event;
4324
+ } else if (subagentEvent.type === "llm_call_end") {
4325
+ const info = subagentEvent.event;
4326
+ const subagentId = `${subagentEvent.gadgetInvocationId}:${info.iteration}`;
4327
+ progress.updateNestedAgent(subagentId, info.outputTokens);
4328
+ setTimeout(() => progress.removeNestedAgent(subagentId), 100);
4329
+ } else if (subagentEvent.type === "gadget_call") {
4330
+ const gadgetEvent = subagentEvent.event;
4282
4331
  progress.addNestedGadget(
4283
4332
  gadgetEvent.call.invocationId,
4284
- event.depth,
4285
- event.gadgetInvocationId,
4333
+ subagentEvent.depth,
4334
+ subagentEvent.gadgetInvocationId,
4286
4335
  gadgetEvent.call.gadgetName
4287
4336
  );
4288
- } else if (event.type === "gadget_result") {
4289
- const resultEvent = event.event;
4290
- progress.removeNestedGadget(resultEvent.result.invocationId);
4337
+ } else if (subagentEvent.type === "gadget_result") {
4338
+ const resultEvent = subagentEvent.event;
4339
+ progress.completeNestedGadget(resultEvent.result.invocationId);
4291
4340
  }
4292
4341
  });
4293
4342
  }
@@ -4348,6 +4397,7 @@ Denied: ${result.reason ?? "by user"}`
4348
4397
  if (progress.hasInFlightGadgets()) {
4349
4398
  progress.start();
4350
4399
  }
4400
+ } else if (event.type === "subagent_event") {
4351
4401
  }
4352
4402
  }
4353
4403
  } catch (error) {