llmist 0.4.1 → 0.5.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/README.md CHANGED
@@ -16,7 +16,7 @@ llmist is an asynchonous, streaming-first, provider-agnostic LLM client that mak
16
16
  ## 🎯 Why llmist?
17
17
 
18
18
  - **🌍 Universal** - Works with any LLM provider (OpenAI, Anthropic, Gemini, custom)
19
- - **📝 No Structured Outputs** - Flexible YAML/JSON grammar works with any text model
19
+ - **📝 No Structured Outputs** - Flexible TOML/YAML/JSON grammar works with any text model
20
20
  - **⚡ Streaming-First** - Built for real-time responses and efficient error handling
21
21
  - **🪝 Powerful Hooks** - Monitor, customize, and control every step of execution
22
22
  - **🎨 Beautiful API** - Fluent builder pattern with model shortcuts and presets
@@ -56,6 +56,9 @@ cat document.txt | llmist complete "Summarize" --model gpt-5-nano
56
56
  ```bash
57
57
  # Disable built-in gadgets
58
58
  bunx llmist agent "Task" --no-builtins -g ./my-tools.ts
59
+
60
+ # Override parameter format (default: toml, options: toml, yaml, json, auto)
61
+ bunx llmist agent "Task" --parameter-format yaml -g ./my-tools.ts
59
62
  ```
60
63
 
61
64
  📖 **[CLI Reference](./docs/CLI.md)** | **[CLI Gadgets Guide](./docs/CLI_GADGETS.md)**
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BaseGadget
3
- } from "./chunk-LQE7TKKW.js";
3
+ } from "./chunk-MH4TQ5AD.js";
4
4
 
5
5
  // src/gadgets/create-gadget.ts
6
6
  function createGadget(config) {
@@ -9,6 +9,7 @@ function createGadget(config) {
9
9
  description = config.description;
10
10
  parameterSchema = config.schema;
11
11
  timeoutMs = config.timeoutMs;
12
+ examples = config.examples;
12
13
  execute(params) {
13
14
  return config.execute(params);
14
15
  }
@@ -19,4 +20,4 @@ function createGadget(config) {
19
20
  export {
20
21
  createGadget
21
22
  };
22
- //# sourceMappingURL=chunk-QVDGTUQN.js.map
23
+ //# sourceMappingURL=chunk-LKIBXQ5I.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/gadgets/create-gadget.ts"],"sourcesContent":["/**\n * Function-based gadget creation helper.\n *\n * For simple gadgets, use createGadget() instead of defining a class.\n * Parameters are automatically typed from the Zod schema.\n *\n * @example\n * ```typescript\n * const calculator = createGadget({\n * description: \"Performs arithmetic operations\",\n * schema: z.object({\n * operation: z.enum([\"add\", \"subtract\"]),\n * a: z.number(),\n * b: z.number(),\n * }),\n * execute: ({ operation, a, b }) => {\n * // Automatically typed!\n * return operation === \"add\" ? String(a + b) : String(a - b);\n * },\n * });\n * ```\n */\n\nimport type { ZodType } from \"zod\";\nimport { BaseGadget } from \"./gadget.js\";\nimport type { GadgetExample } from \"./types.js\";\n\n/**\n * Infer the TypeScript type from a Zod schema.\n */\ntype InferSchema<T> = T extends ZodType<infer U> ? U : never;\n\n/**\n * Configuration for creating a function-based gadget.\n */\nexport interface CreateGadgetConfig<TSchema extends ZodType> {\n /** Optional custom name (defaults to \"FunctionGadget\") */\n name?: string;\n\n /** Human-readable description of what the gadget does */\n description: string;\n\n /** Zod schema for parameter validation */\n schema: TSchema;\n\n /** Execution function with typed parameters */\n execute: (params: InferSchema<TSchema>) => string | Promise<string>;\n\n /** Optional timeout in milliseconds */\n timeoutMs?: number;\n\n /** Optional usage examples to help LLMs understand proper invocation */\n examples?: GadgetExample<InferSchema<TSchema>>[];\n}\n\n/**\n * Creates a gadget from a function (simpler than class-based approach).\n *\n * This is perfect for simple gadgets where you don't need the full\n * power of a class. Parameters are automatically typed from the schema.\n *\n * @param config - Configuration with execute function and schema\n * @returns Gadget instance ready to be registered\n *\n * @example\n * ```typescript\n * import { z } from 'zod';\n * import { createGadget } from 'llmist';\n *\n * // Simple calculator gadget\n * const calculator = createGadget({\n * description: \"Performs arithmetic operations\",\n * schema: z.object({\n * operation: z.enum([\"add\", \"subtract\", \"multiply\", \"divide\"]),\n * a: z.number().describe(\"First number\"),\n * b: z.number().describe(\"Second number\"),\n * }),\n * execute: ({ operation, a, b }) => {\n * // Parameters are automatically typed!\n * switch (operation) {\n * case \"add\": return String(a + b);\n * case \"subtract\": return String(a - b);\n * case \"multiply\": return String(a * b);\n * case \"divide\": return String(a / b);\n * }\n * },\n * });\n * ```\n *\n * @example\n * ```typescript\n * // Async gadget with custom name and timeout\n * const weather = createGadget({\n * name: \"weather\",\n * description: \"Fetches current weather for a city\",\n * schema: z.object({\n * city: z.string().min(1).describe(\"City name\"),\n * }),\n * timeoutMs: 10000,\n * execute: async ({ city }) => {\n * const response = await fetch(`https://api.weather.com/${city}`);\n * const data = await response.json();\n * return `Weather in ${city}: ${data.description}, ${data.temp}°C`;\n * },\n * });\n * ```\n *\n * @example\n * ```typescript\n * // Use with agent\n * const agent = LLMist.createAgent()\n * .withGadgets(calculator, weather)\n * .ask(\"What's the weather in Paris and what's 10 + 5?\");\n * ```\n */\nexport function createGadget<TSchema extends ZodType>(\n config: CreateGadgetConfig<TSchema>,\n): BaseGadget {\n class DynamicGadget extends BaseGadget {\n name = config.name;\n description = config.description;\n parameterSchema = config.schema;\n timeoutMs = config.timeoutMs;\n examples = config.examples;\n\n execute(params: Record<string, unknown>): string | Promise<string> {\n // Cast to inferred type and call user's function\n return config.execute(params as InferSchema<TSchema>);\n }\n }\n\n return new DynamicGadget();\n}\n"],"mappings":";;;;;AAmHO,SAAS,aACd,QACY;AAAA,EACZ,MAAM,sBAAsB,WAAW;AAAA,IACrC,OAAO,OAAO;AAAA,IACd,cAAc,OAAO;AAAA,IACrB,kBAAkB,OAAO;AAAA,IACzB,YAAY,OAAO;AAAA,IACnB,WAAW,OAAO;AAAA,IAElB,QAAQ,QAA2D;AAEjE,aAAO,OAAO,QAAQ,MAA8B;AAAA,IACtD;AAAA,EACF;AAEA,SAAO,IAAI,cAAc;AAC3B;","names":[]}