llmist 1.6.2 → 2.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-TDRPJP2Q.js";
2
+ import "./chunk-LFSIEPAE.js";
3
3
  import {
4
4
  AgentBuilder,
5
5
  BaseGadget,
@@ -27,7 +27,7 @@ import {
27
27
  resolveModel,
28
28
  schemaToJSONSchema,
29
29
  validateGadgetSchema
30
- } from "./chunk-T3DIKQWU.js";
30
+ } from "./chunk-LBHWVCZ2.js";
31
31
 
32
32
  // src/cli/constants.ts
33
33
  var CLI_NAME = "llmist";
@@ -88,7 +88,7 @@ import { Command, InvalidArgumentError as InvalidArgumentError2 } from "commande
88
88
  // package.json
89
89
  var package_default = {
90
90
  name: "llmist",
91
- version: "1.6.1",
91
+ version: "1.7.0",
92
92
  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.",
93
93
  type: "module",
94
94
  main: "dist/index.cjs",
@@ -891,38 +891,46 @@ error: ${message}`;
891
891
  import { z as z6 } from "zod";
892
892
  var runCommand = createGadget({
893
893
  name: "RunCommand",
894
- description: "Execute a shell command and return its output. Returns both stdout and stderr combined with the exit status.",
894
+ description: "Execute a command with arguments and return its output. Uses argv array to bypass shell - arguments are passed directly without interpretation. Returns stdout/stderr combined with exit status.",
895
895
  schema: z6.object({
896
- command: z6.string().describe("The shell command to execute"),
896
+ argv: z6.array(z6.string()).describe("Command and arguments as array (e.g., ['git', 'commit', '-m', 'message'])"),
897
897
  cwd: z6.string().optional().describe("Working directory for the command (default: current directory)"),
898
898
  timeout: z6.number().default(3e4).describe("Timeout in milliseconds (default: 30000)")
899
899
  }),
900
900
  examples: [
901
901
  {
902
- params: { command: "ls -la", timeout: 3e4 },
902
+ params: { argv: ["ls", "-la"], timeout: 3e4 },
903
903
  output: "status=0\n\ntotal 24\ndrwxr-xr-x 5 user staff 160 Nov 27 10:00 .\ndrwxr-xr-x 3 user staff 96 Nov 27 09:00 ..\n-rw-r--r-- 1 user staff 1024 Nov 27 10:00 package.json",
904
904
  comment: "List directory contents with details"
905
905
  },
906
906
  {
907
- params: { command: "echo 'Hello World'", timeout: 3e4 },
907
+ params: { argv: ["echo", "Hello World"], timeout: 3e4 },
908
908
  output: "status=0\n\nHello World",
909
- comment: "Simple echo command"
909
+ comment: "Echo without shell - argument passed directly"
910
910
  },
911
911
  {
912
- params: { command: "cat nonexistent.txt", timeout: 3e4 },
912
+ params: { argv: ["cat", "nonexistent.txt"], timeout: 3e4 },
913
913
  output: "status=1\n\ncat: nonexistent.txt: No such file or directory",
914
914
  comment: "Command that fails returns non-zero status"
915
915
  },
916
916
  {
917
- params: { command: "pwd", cwd: "/tmp", timeout: 3e4 },
917
+ params: { argv: ["pwd"], cwd: "/tmp", timeout: 3e4 },
918
918
  output: "status=0\n\n/tmp",
919
919
  comment: "Execute command in a specific directory"
920
+ },
921
+ {
922
+ params: { argv: ["gh", "pr", "review", "123", "--comment", "--body", "Review with `backticks` and 'quotes'"], timeout: 3e4 },
923
+ output: "status=0\n\n(no output)",
924
+ comment: "Complex arguments with special characters - no escaping needed"
920
925
  }
921
926
  ],
922
- execute: async ({ command, cwd, timeout }) => {
927
+ execute: async ({ argv, cwd, timeout }) => {
923
928
  const workingDir = cwd ?? process.cwd();
929
+ if (argv.length === 0) {
930
+ return "status=1\n\nerror: argv array cannot be empty";
931
+ }
924
932
  try {
925
- const proc = Bun.spawn(["sh", "-c", command], {
933
+ const proc = Bun.spawn(argv, {
926
934
  cwd: workingDir,
927
935
  stdout: "pipe",
928
936
  stderr: "pipe"
@@ -3830,9 +3838,11 @@ ${issues}`);
3830
3838
  env.stderr.write(chalk7.dim("\nExecuting...\n"));
3831
3839
  const startTime = Date.now();
3832
3840
  let result;
3841
+ let cost;
3833
3842
  try {
3843
+ let rawResult;
3834
3844
  if (gadget.timeoutMs && gadget.timeoutMs > 0) {
3835
- result = await Promise.race([
3845
+ rawResult = await Promise.race([
3836
3846
  Promise.resolve(gadget.execute(params)),
3837
3847
  new Promise(
3838
3848
  (_, reject) => setTimeout(
@@ -3842,15 +3852,18 @@ ${issues}`);
3842
3852
  )
3843
3853
  ]);
3844
3854
  } else {
3845
- result = await Promise.resolve(gadget.execute(params));
3855
+ rawResult = await Promise.resolve(gadget.execute(params));
3846
3856
  }
3857
+ result = typeof rawResult === "string" ? rawResult : rawResult.result;
3858
+ cost = typeof rawResult === "object" ? rawResult.cost : void 0;
3847
3859
  } catch (error) {
3848
3860
  const message = error instanceof Error ? error.message : String(error);
3849
3861
  throw new Error(`Execution failed: ${message}`);
3850
3862
  }
3851
3863
  const elapsed = Date.now() - startTime;
3864
+ const costInfo = cost !== void 0 && cost > 0 ? ` (Cost: $${cost.toFixed(6)})` : "";
3852
3865
  env.stderr.write(chalk7.green(`
3853
- \u2713 Completed in ${elapsed}ms
3866
+ \u2713 Completed in ${elapsed}ms${costInfo}
3854
3867
 
3855
3868
  `));
3856
3869
  formatOutput(result, options, env.stdout);