llmist 0.6.1 → 0.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.
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ZodType, ZodTypeAny } from 'zod';
2
2
  export { z } from 'zod';
3
- import { A as AgentHooks, o as ModelRegistry, L as LLMMessage, P as ParameterFormat, S as StreamEvent, G as GadgetRegistry, p as LLMStreamChunk, q as GadgetExample, B as BaseGadget, r as ParsedGadgetCall, s as GadgetExecutionResult, t as ProviderAdapter, u as ModelDescriptor, v as ModelSpec, w as LLMGenerationOptions, x as LLMStream } from './mock-stream-CCe8vISa.cjs';
4
- export { F as AfterGadgetExecutionAction, I as AfterGadgetExecutionControllerContext, J as AfterLLMCallAction, K as AfterLLMCallControllerContext, N as AfterLLMErrorAction, y as AgentBuilder, O as AgentOptions, Q as BeforeGadgetExecutionAction, R as BeforeLLMCallAction, T as ChunkInterceptorContext, U as Controllers, ab as CostEstimate, al as DEFAULT_PROMPTS, E as EventHandlers, as as GadgetClass, V as GadgetExecutionControllerContext, at as GadgetOrClass, W as GadgetParameterInterceptorContext, X as GadgetResultInterceptorContext, H as HistoryMessage, Y as Interceptors, Z as LLMCallControllerContext, _ as LLMErrorControllerContext, aa as LLMMessageBuilder, a9 as LLMRole, a8 as LLMist, a7 as LLMistOptions, $ as MessageInterceptorContext, a as MockBuilder, d as MockManager, h as MockMatcher, i as MockMatcherContext, j as MockOptions, M as MockProviderAdapter, k as MockRegistration, l as MockResponse, n as MockStats, ac as ModelFeatures, ah as ModelIdentifierParser, ad as ModelLimits, ae as ModelPricing, a0 as ObserveChunkContext, a1 as ObserveGadgetCompleteContext, a2 as ObserveGadgetStartContext, a3 as ObserveLLMCallContext, a4 as ObserveLLMCompleteContext, a5 as ObserveLLMErrorContext, a6 as Observers, ai as PromptConfig, aj as PromptContext, ak as PromptTemplate, af as ProviderIdentifier, ao as QuickOptions, ar as StreamParser, au as TextOnlyAction, av as TextOnlyContext, aw as TextOnlyCustomHandler, ax as TextOnlyGadgetConfig, ay as TextOnlyHandler, az as TextOnlyStrategy, ag as TokenUsage, z as collectEvents, C as collectText, ap as complete, c as createMockAdapter, b as createMockClient, e as createMockStream, f as createTextMockStream, g as getMockManager, m as mockLLM, am as resolvePromptTemplate, an as resolveRulesTemplate, D as runWithHandlers, aq as stream } from './mock-stream-CCe8vISa.cjs';
3
+ import { A as AgentHooks, o as ModelRegistry, L as LLMMessage, P as ParameterFormat, S as StreamEvent, G as GadgetRegistry, p as LLMStreamChunk, q as GadgetExample, B as BaseGadget, r as ParsedGadgetCall, s as GadgetExecutionResult, t as ProviderAdapter, u as ModelDescriptor, v as ModelSpec, w as LLMGenerationOptions, x as LLMStream } from './mock-stream-B5R6XPif.cjs';
4
+ export { F as AfterGadgetExecutionAction, I as AfterGadgetExecutionControllerContext, J as AfterLLMCallAction, K as AfterLLMCallControllerContext, N as AfterLLMErrorAction, y as AgentBuilder, O as AgentOptions, Q as BeforeGadgetExecutionAction, R as BeforeLLMCallAction, T as ChunkInterceptorContext, U as Controllers, ab as CostEstimate, al as DEFAULT_PROMPTS, E as EventHandlers, as as GadgetClass, V as GadgetExecutionControllerContext, at as GadgetOrClass, W as GadgetParameterInterceptorContext, X as GadgetResultInterceptorContext, H as HistoryMessage, Y as Interceptors, Z as LLMCallControllerContext, _ as LLMErrorControllerContext, aa as LLMMessageBuilder, a9 as LLMRole, a8 as LLMist, a7 as LLMistOptions, $ as MessageInterceptorContext, a as MockBuilder, d as MockManager, h as MockMatcher, i as MockMatcherContext, j as MockOptions, M as MockProviderAdapter, k as MockRegistration, l as MockResponse, n as MockStats, ac as ModelFeatures, ah as ModelIdentifierParser, ad as ModelLimits, ae as ModelPricing, a0 as ObserveChunkContext, a1 as ObserveGadgetCompleteContext, a2 as ObserveGadgetStartContext, a3 as ObserveLLMCallContext, a4 as ObserveLLMCompleteContext, a5 as ObserveLLMErrorContext, a6 as Observers, ai as PromptConfig, aj as PromptContext, ak as PromptTemplate, af as ProviderIdentifier, ao as QuickOptions, ar as StreamParser, au as TextOnlyAction, av as TextOnlyContext, aw as TextOnlyCustomHandler, ax as TextOnlyGadgetConfig, ay as TextOnlyHandler, az as TextOnlyStrategy, ag as TokenUsage, z as collectEvents, C as collectText, ap as complete, c as createMockAdapter, b as createMockClient, e as createMockStream, f as createTextMockStream, g as getMockManager, m as mockLLM, am as resolvePromptTemplate, an as resolveRulesTemplate, D as runWithHandlers, aq as stream } from './mock-stream-B5R6XPif.cjs';
5
5
  import { Logger, ILogObj } from 'tslog';
6
6
  import { MessageCreateParamsStreaming, MessageStreamEvent } from '@anthropic-ai/sdk/resources/messages';
7
7
  import OpenAI from 'openai';
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ZodType, ZodTypeAny } from 'zod';
2
2
  export { z } from 'zod';
3
- import { A as AgentHooks, o as ModelRegistry, L as LLMMessage, P as ParameterFormat, S as StreamEvent, G as GadgetRegistry, p as LLMStreamChunk, q as GadgetExample, B as BaseGadget, r as ParsedGadgetCall, s as GadgetExecutionResult, t as ProviderAdapter, u as ModelDescriptor, v as ModelSpec, w as LLMGenerationOptions, x as LLMStream } from './mock-stream-CCe8vISa.js';
4
- export { F as AfterGadgetExecutionAction, I as AfterGadgetExecutionControllerContext, J as AfterLLMCallAction, K as AfterLLMCallControllerContext, N as AfterLLMErrorAction, y as AgentBuilder, O as AgentOptions, Q as BeforeGadgetExecutionAction, R as BeforeLLMCallAction, T as ChunkInterceptorContext, U as Controllers, ab as CostEstimate, al as DEFAULT_PROMPTS, E as EventHandlers, as as GadgetClass, V as GadgetExecutionControllerContext, at as GadgetOrClass, W as GadgetParameterInterceptorContext, X as GadgetResultInterceptorContext, H as HistoryMessage, Y as Interceptors, Z as LLMCallControllerContext, _ as LLMErrorControllerContext, aa as LLMMessageBuilder, a9 as LLMRole, a8 as LLMist, a7 as LLMistOptions, $ as MessageInterceptorContext, a as MockBuilder, d as MockManager, h as MockMatcher, i as MockMatcherContext, j as MockOptions, M as MockProviderAdapter, k as MockRegistration, l as MockResponse, n as MockStats, ac as ModelFeatures, ah as ModelIdentifierParser, ad as ModelLimits, ae as ModelPricing, a0 as ObserveChunkContext, a1 as ObserveGadgetCompleteContext, a2 as ObserveGadgetStartContext, a3 as ObserveLLMCallContext, a4 as ObserveLLMCompleteContext, a5 as ObserveLLMErrorContext, a6 as Observers, ai as PromptConfig, aj as PromptContext, ak as PromptTemplate, af as ProviderIdentifier, ao as QuickOptions, ar as StreamParser, au as TextOnlyAction, av as TextOnlyContext, aw as TextOnlyCustomHandler, ax as TextOnlyGadgetConfig, ay as TextOnlyHandler, az as TextOnlyStrategy, ag as TokenUsage, z as collectEvents, C as collectText, ap as complete, c as createMockAdapter, b as createMockClient, e as createMockStream, f as createTextMockStream, g as getMockManager, m as mockLLM, am as resolvePromptTemplate, an as resolveRulesTemplate, D as runWithHandlers, aq as stream } from './mock-stream-CCe8vISa.js';
3
+ import { A as AgentHooks, o as ModelRegistry, L as LLMMessage, P as ParameterFormat, S as StreamEvent, G as GadgetRegistry, p as LLMStreamChunk, q as GadgetExample, B as BaseGadget, r as ParsedGadgetCall, s as GadgetExecutionResult, t as ProviderAdapter, u as ModelDescriptor, v as ModelSpec, w as LLMGenerationOptions, x as LLMStream } from './mock-stream-B5R6XPif.js';
4
+ export { F as AfterGadgetExecutionAction, I as AfterGadgetExecutionControllerContext, J as AfterLLMCallAction, K as AfterLLMCallControllerContext, N as AfterLLMErrorAction, y as AgentBuilder, O as AgentOptions, Q as BeforeGadgetExecutionAction, R as BeforeLLMCallAction, T as ChunkInterceptorContext, U as Controllers, ab as CostEstimate, al as DEFAULT_PROMPTS, E as EventHandlers, as as GadgetClass, V as GadgetExecutionControllerContext, at as GadgetOrClass, W as GadgetParameterInterceptorContext, X as GadgetResultInterceptorContext, H as HistoryMessage, Y as Interceptors, Z as LLMCallControllerContext, _ as LLMErrorControllerContext, aa as LLMMessageBuilder, a9 as LLMRole, a8 as LLMist, a7 as LLMistOptions, $ as MessageInterceptorContext, a as MockBuilder, d as MockManager, h as MockMatcher, i as MockMatcherContext, j as MockOptions, M as MockProviderAdapter, k as MockRegistration, l as MockResponse, n as MockStats, ac as ModelFeatures, ah as ModelIdentifierParser, ad as ModelLimits, ae as ModelPricing, a0 as ObserveChunkContext, a1 as ObserveGadgetCompleteContext, a2 as ObserveGadgetStartContext, a3 as ObserveLLMCallContext, a4 as ObserveLLMCompleteContext, a5 as ObserveLLMErrorContext, a6 as Observers, ai as PromptConfig, aj as PromptContext, ak as PromptTemplate, af as ProviderIdentifier, ao as QuickOptions, ar as StreamParser, au as TextOnlyAction, av as TextOnlyContext, aw as TextOnlyCustomHandler, ax as TextOnlyGadgetConfig, ay as TextOnlyHandler, az as TextOnlyStrategy, ag as TokenUsage, z as collectEvents, C as collectText, ap as complete, c as createMockAdapter, b as createMockClient, e as createMockStream, f as createTextMockStream, g as getMockManager, m as mockLLM, am as resolvePromptTemplate, an as resolveRulesTemplate, D as runWithHandlers, aq as stream } from './mock-stream-B5R6XPif.js';
5
5
  import { Logger, ILogObj } from 'tslog';
6
6
  import { MessageCreateParamsStreaming, MessageStreamEvent } from '@anthropic-ai/sdk/resources/messages';
7
7
  import OpenAI from 'openai';
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  mockLLM,
11
11
  validateAndApplyDefaults,
12
12
  validateGadgetParams
13
- } from "./chunk-YWJSGEYT.js";
13
+ } from "./chunk-TSR25DAY.js";
14
14
  import {
15
15
  AgentBuilder,
16
16
  AnthropicMessagesProvider,
@@ -74,7 +74,7 @@ import {
74
74
  resolveRulesTemplate,
75
75
  runWithHandlers,
76
76
  stream
77
- } from "./chunk-KB7LMYC2.js";
77
+ } from "./chunk-DVK6ZQOV.js";
78
78
 
79
79
  // src/index.ts
80
80
  init_builder();
@@ -142,6 +142,11 @@ declare class StreamParser {
142
142
  * For new format, generates a unique invocation ID.
143
143
  */
144
144
  private parseGadgetName;
145
+ /**
146
+ * Truncate verbose parse errors to avoid context overflow.
147
+ * Keeps first meaningful line and limits total length.
148
+ */
149
+ private truncateParseError;
145
150
  /**
146
151
  * Parse parameter string according to configured format
147
152
  */
@@ -142,6 +142,11 @@ declare class StreamParser {
142
142
  * For new format, generates a unique invocation ID.
143
143
  */
144
144
  private parseGadgetName;
145
+ /**
146
+ * Truncate verbose parse errors to avoid context overflow.
147
+ * Keeps first meaningful line and limits total length.
148
+ */
149
+ private truncateParseError;
145
150
  /**
146
151
  * Parse parameter string according to configured format
147
152
  */
@@ -703,7 +703,9 @@ This content can contain:
703
703
  - Multiple paragraphs
704
704
  EOF
705
705
 
706
- The delimiter (EOF) can be any identifier. The closing delimiter must be on its own line.`);
706
+ The delimiter (EOF) can be any identifier. The closing delimiter must be on its own line.
707
+ IMPORTANT: Content inside heredoc is LITERAL - do NOT escape backticks, dollar signs, or any characters.
708
+ NEVER use TOML triple-quote strings ("""). ALWAYS use heredoc syntax (<<<EOF...EOF) for multiline content.`);
707
709
  }
708
710
  return parts.join("");
709
711
  }
@@ -751,9 +753,9 @@ ${this.endPrefix}`
751
753
  if (format === "toml") {
752
754
  return Object.entries(parameters).map(([key, value]) => {
753
755
  if (typeof value === "string" && value.includes("\n")) {
754
- return `${key} = """
756
+ return `${key} = <<<EOF
755
757
  ${value}
756
- """`;
758
+ EOF`;
757
759
  }
758
760
  return `${key} = ${JSON.stringify(value)}`;
759
761
  }).join("\n");
@@ -1631,7 +1633,8 @@ var init_executor = __esm({
1631
1633
  if (call.parseError || !call.parameters) {
1632
1634
  this.logger.error("Gadget parameter parse error", {
1633
1635
  gadgetName: call.gadgetName,
1634
- parseError: call.parseError
1636
+ parseError: call.parseError,
1637
+ rawParameters: call.parametersYaml
1635
1638
  });
1636
1639
  return {
1637
1640
  gadgetName: call.gadgetName,
@@ -1910,6 +1913,9 @@ function preprocessYaml(yamlStr) {
1910
1913
  }
1911
1914
  return result.join("\n");
1912
1915
  }
1916
+ function unescapeHeredocContent(content) {
1917
+ return content.replace(/\\`/g, "`").replace(/\\\$/g, "$").replace(/\\{/g, "{").replace(/\\}/g, "}");
1918
+ }
1913
1919
  function preprocessTomlHeredoc(tomlStr) {
1914
1920
  const lines = tomlStr.split("\n");
1915
1921
  const result = [];
@@ -1935,13 +1941,13 @@ function preprocessTomlHeredoc(tomlStr) {
1935
1941
  i++;
1936
1942
  }
1937
1943
  if (bodyLines.length === 0) {
1938
- result.push(`${indent}${key} = """"""`);
1944
+ result.push(`${indent}${key} = ''''''`);
1939
1945
  } else {
1940
- result.push(`${indent}${key} = """`);
1946
+ result.push(`${indent}${key} = '''`);
1941
1947
  for (let j = 0; j < bodyLines.length - 1; j++) {
1942
- result.push(bodyLines[j]);
1948
+ result.push(unescapeHeredocContent(bodyLines[j]));
1943
1949
  }
1944
- result.push(`${bodyLines[bodyLines.length - 1]}"""`);
1950
+ result.push(`${unescapeHeredocContent(bodyLines[bodyLines.length - 1])}'''`);
1945
1951
  }
1946
1952
  if (!foundClosing) {
1947
1953
  }
@@ -1990,6 +1996,19 @@ var init_parser = __esm({
1990
1996
  }
1991
1997
  return { actualName: gadgetName, invocationId: `gadget_${++globalInvocationCounter}` };
1992
1998
  }
1999
+ /**
2000
+ * Truncate verbose parse errors to avoid context overflow.
2001
+ * Keeps first meaningful line and limits total length.
2002
+ */
2003
+ truncateParseError(error, format) {
2004
+ const message = error instanceof Error ? error.message : String(error);
2005
+ const firstLine = message.split("\n")[0];
2006
+ const maxLen = 200;
2007
+ if (firstLine.length <= maxLen) {
2008
+ return firstLine;
2009
+ }
2010
+ return `${firstLine.slice(0, maxLen)}... (${message.length} chars total)`;
2011
+ }
1993
2012
  /**
1994
2013
  * Parse parameter string according to configured format
1995
2014
  */
@@ -1998,21 +2017,21 @@ var init_parser = __esm({
1998
2017
  try {
1999
2018
  return { parameters: JSON.parse(raw) };
2000
2019
  } catch (error) {
2001
- return { parseError: error instanceof Error ? error.message : "Failed to parse JSON" };
2020
+ return { parseError: this.truncateParseError(error, "JSON") };
2002
2021
  }
2003
2022
  }
2004
2023
  if (this.parameterFormat === "yaml") {
2005
2024
  try {
2006
2025
  return { parameters: yaml2.load(preprocessYaml(raw)) };
2007
2026
  } catch (error) {
2008
- return { parseError: error instanceof Error ? error.message : "Failed to parse YAML" };
2027
+ return { parseError: this.truncateParseError(error, "YAML") };
2009
2028
  }
2010
2029
  }
2011
2030
  if (this.parameterFormat === "toml") {
2012
2031
  try {
2013
2032
  return { parameters: (0, import_js_toml.load)(preprocessTomlHeredoc(raw)) };
2014
2033
  } catch (error) {
2015
- return { parseError: error instanceof Error ? error.message : "Failed to parse TOML" };
2034
+ return { parseError: this.truncateParseError(error, "TOML") };
2016
2035
  }
2017
2036
  }
2018
2037
  try {
@@ -2024,9 +2043,7 @@ var init_parser = __esm({
2024
2043
  try {
2025
2044
  return { parameters: yaml2.load(preprocessYaml(raw)) };
2026
2045
  } catch (error) {
2027
- return {
2028
- parseError: error instanceof Error ? error.message : "Failed to parse as JSON, TOML, or YAML"
2029
- };
2046
+ return { parseError: this.truncateParseError(error, "auto") };
2030
2047
  }
2031
2048
  }
2032
2049
  }
@@ -2328,7 +2345,8 @@ var init_stream_processor = __esm({
2328
2345
  if (call.parseError) {
2329
2346
  this.logger.warn("Gadget has parse error", {
2330
2347
  gadgetName: call.gadgetName,
2331
- error: call.parseError
2348
+ error: call.parseError,
2349
+ rawParameters: call.parametersYaml
2332
2350
  });
2333
2351
  const shouldContinue = await this.checkContinueAfterError(
2334
2352
  call.parseError,