@llmist/cli 15.17.0 → 15.18.1

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
@@ -23,6 +23,7 @@ var OPTION_FLAGS = {
23
23
  temperature: "-t, --temperature <value>",
24
24
  maxTokens: "--max-tokens <count>",
25
25
  maxIterations: "-i, --max-iterations <count>",
26
+ budget: "-b, --budget <amount>",
26
27
  gadgetModule: "-g, --gadget <module>",
27
28
  logLevel: "--log-level <level>",
28
29
  logLlmRequests: "--log-llm-requests",
@@ -65,6 +66,7 @@ var OPTION_DESCRIPTIONS = {
65
66
  temperature: "Sampling temperature between 0 and 2.",
66
67
  maxTokens: "Maximum number of output tokens requested from the model.",
67
68
  maxIterations: "Maximum number of agent loop iterations before exiting.",
69
+ budget: "Maximum spend in USD before the agent loop exits.",
68
70
  gadgetModule: "Path or module specifier for a gadget export. Repeat to register multiple gadgets.",
69
71
  logLevel: "Log level: silly, trace, debug, info, warn, error, fatal.",
70
72
  logLlmRequests: "Save LLM requests/responses to the session log directory.",
@@ -108,7 +110,7 @@ import { Command, InvalidArgumentError as InvalidArgumentError2 } from "commande
108
110
  // package.json
109
111
  var package_default = {
110
112
  name: "@llmist/cli",
111
- version: "15.17.0",
113
+ version: "15.18.1",
112
114
  description: "CLI for llmist - run LLM agents from the command line",
113
115
  type: "module",
114
116
  main: "dist/cli.js",
@@ -164,7 +166,7 @@ var package_default = {
164
166
  node: ">=22.0.0"
165
167
  },
166
168
  dependencies: {
167
- llmist: "^15.17.0",
169
+ llmist: "^15.18.1",
168
170
  "@unblessed/node": "^1.0.0-alpha.23",
169
171
  chalk: "^5.6.2",
170
172
  commander: "^12.1.0",
@@ -178,7 +180,7 @@ var package_default = {
178
180
  zod: "^4.1.12"
179
181
  },
180
182
  devDependencies: {
181
- "@llmist/testing": "^15.17.0",
183
+ "@llmist/testing": "^15.18.1",
182
184
  "@types/diff": "^8.0.0",
183
185
  "@types/js-yaml": "^4.0.9",
184
186
  "@types/marked-terminal": "^6.1.1",
@@ -439,6 +441,7 @@ var AGENT_CONFIG_KEYS = /* @__PURE__ */ new Set([
439
441
  "system",
440
442
  "temperature",
441
443
  "max-iterations",
444
+ "budget",
442
445
  "gadgets",
443
446
  // Full replacement (preferred)
444
447
  "gadget-add",
@@ -561,6 +564,11 @@ function validateSingleSubagentConfig(value, subagentName, section) {
561
564
  );
562
565
  }
563
566
  result.maxIterations = val;
567
+ } else if (key === "budget") {
568
+ if (typeof val !== "number" || val < 0) {
569
+ throw new ConfigError(`[${section}].${subagentName}.budget must be a non-negative number`);
570
+ }
571
+ result.budget = val;
564
572
  } else if (key === "timeoutMs") {
565
573
  if (typeof val !== "number" || !Number.isInteger(val) || val < 0) {
566
574
  throw new ConfigError(
@@ -920,6 +928,9 @@ function validateAgentConfig(raw, section) {
920
928
  min: 1
921
929
  });
922
930
  }
931
+ if ("budget" in rawObj) {
932
+ result.budget = validateNumber(rawObj.budget, "budget", section, { min: 0 });
933
+ }
923
934
  if ("gadgets" in rawObj) {
924
935
  result.gadgets = validateStringArray(rawObj.gadgets, "gadgets", section);
925
936
  }
@@ -1100,6 +1111,9 @@ function validateCustomConfig(raw, section) {
1100
1111
  min: 1
1101
1112
  });
1102
1113
  }
1114
+ if ("budget" in rawObj) {
1115
+ result.budget = validateNumber(rawObj.budget, "budget", section, { min: 0 });
1116
+ }
1103
1117
  if ("gadgets" in rawObj) {
1104
1118
  result.gadgets = validateStringArray(rawObj.gadgets, "gadgets", section);
1105
1119
  }
@@ -4045,6 +4059,11 @@ function addAgentOptions(cmd, defaults) {
4045
4059
  OPTION_DESCRIPTIONS.maxIterations,
4046
4060
  createNumericParser({ label: "Max iterations", integer: true, min: 1 }),
4047
4061
  defaults?.["max-iterations"]
4062
+ ).option(
4063
+ OPTION_FLAGS.budget,
4064
+ OPTION_DESCRIPTIONS.budget,
4065
+ createNumericParser({ label: "Budget", min: 0 }),
4066
+ defaults?.budget
4048
4067
  ).option(OPTION_FLAGS.gadgetModule, OPTION_DESCRIPTIONS.gadgetModule, gadgetAccumulator, [
4049
4068
  ...defaultGadgets
4050
4069
  ]).option(OPTION_FLAGS.noBuiltins, OPTION_DESCRIPTIONS.noBuiltins, defaults?.builtins !== false).option(
@@ -4130,6 +4149,7 @@ function configToAgentOptions(config) {
4130
4149
  if (config.system !== void 0) result.system = config.system;
4131
4150
  if (config.temperature !== void 0) result.temperature = config.temperature;
4132
4151
  if (config["max-iterations"] !== void 0) result.maxIterations = config["max-iterations"];
4152
+ if (config.budget !== void 0) result.budget = config.budget;
4133
4153
  const gadgets = config.gadgets ?? config.gadget;
4134
4154
  if (gadgets !== void 0) result.gadget = gadgets;
4135
4155
  if (config.builtins !== void 0) result.builtins = config.builtins;
@@ -8900,6 +8920,9 @@ ${ctx.gadgetName} requires interactive approval. Run in a terminal to approve.`
8900
8920
  if (options.maxIterations !== void 0) {
8901
8921
  builder.withMaxIterations(options.maxIterations);
8902
8922
  }
8923
+ if (options.budget !== void 0) {
8924
+ builder.withBudget(options.budget);
8925
+ }
8903
8926
  if (options.temperature !== void 0) {
8904
8927
  builder.withTemperature(options.temperature);
8905
8928
  }
@@ -8973,7 +8996,7 @@ ${ctx.gadgetName} requires interactive approval. Run in a terminal to approve.`
8973
8996
  });
8974
8997
  builder.withTrailingMessage(
8975
8998
  (ctx) => [
8976
- `[Iteration ${ctx.iteration + 1}/${ctx.maxIterations}]`,
8999
+ `[Iteration ${ctx.iteration + 1}/${ctx.maxIterations}${ctx.budget ? ` | Budget: $${ctx.totalCost.toFixed(4)}/$${ctx.budget}` : ""}]`,
8977
9000
  "Think carefully in two steps: 1. what gadget invocations we should be making next? 2. how do they depend on one another so we can run all of them in the right order? Then respond with all the gadget invocations you are able to do now."
8978
9001
  ].join(" ")
8979
9002
  );
@@ -9328,6 +9351,10 @@ Profile: ${name}
9328
9351
  `);
9329
9352
  env.stdout.write(` Max Iterations: ${section["max-iterations"] ?? "(default)"}
9330
9353
  `);
9354
+ env.stdout.write(
9355
+ ` Budget: ${section.budget !== void 0 ? `$${section.budget}` : "(none)"}
9356
+ `
9357
+ );
9331
9358
  env.stdout.write(
9332
9359
  ` Temperature: ${section.temperature !== void 0 ? section.temperature : "(default)"}
9333
9360
  `
@@ -9357,6 +9384,8 @@ Profile: ${name}
9357
9384
  `);
9358
9385
  if (subConfig.maxIterations)
9359
9386
  env.stdout.write(` maxIterations: ${subConfig.maxIterations}
9387
+ `);
9388
+ if (subConfig.budget) env.stdout.write(` budget: $${subConfig.budget}
9360
9389
  `);
9361
9390
  if (subConfig.timeoutMs) env.stdout.write(` timeoutMs: ${subConfig.timeoutMs}
9362
9391
  `);
@@ -10050,6 +10079,7 @@ var STARTER_CONFIG = `# ~/.llmist/cli.toml
10050
10079
  [agent]
10051
10080
  # model = "anthropic:claude-sonnet-4-5"
10052
10081
  # max-iterations = 15 # Max tool-use loops before stopping
10082
+ # budget = 0.50 # Max USD spend per agent run
10053
10083
  # gadgets = [ # Tools the agent can use
10054
10084
  # "ListDirectory",
10055
10085
  # "ReadFile",