llmist 0.6.0 → 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.cjs CHANGED
@@ -641,7 +641,9 @@ This content can contain:
641
641
  - Multiple paragraphs
642
642
  EOF
643
643
 
644
- The delimiter (EOF) can be any identifier. The closing delimiter must be on its own line.`);
644
+ The delimiter (EOF) can be any identifier. The closing delimiter must be on its own line.
645
+ IMPORTANT: Content inside heredoc is LITERAL - do NOT escape backticks, dollar signs, or any characters.
646
+ NEVER use TOML triple-quote strings ("""). ALWAYS use heredoc syntax (<<<EOF...EOF) for multiline content.`);
645
647
  }
646
648
  return parts.join("");
647
649
  }
@@ -689,9 +691,9 @@ ${this.endPrefix}`
689
691
  if (format === "toml") {
690
692
  return Object.entries(parameters).map(([key, value]) => {
691
693
  if (typeof value === "string" && value.includes("\n")) {
692
- return `${key} = """
694
+ return `${key} = <<<EOF
693
695
  ${value}
694
- """`;
696
+ EOF`;
695
697
  }
696
698
  return `${key} = ${JSON.stringify(value)}`;
697
699
  }).join("\n");
@@ -1678,7 +1680,8 @@ var init_executor = __esm({
1678
1680
  if (call.parseError || !call.parameters) {
1679
1681
  this.logger.error("Gadget parameter parse error", {
1680
1682
  gadgetName: call.gadgetName,
1681
- parseError: call.parseError
1683
+ parseError: call.parseError,
1684
+ rawParameters: call.parametersYaml
1682
1685
  });
1683
1686
  return {
1684
1687
  gadgetName: call.gadgetName,
@@ -1957,6 +1960,9 @@ function preprocessYaml(yamlStr) {
1957
1960
  }
1958
1961
  return result.join("\n");
1959
1962
  }
1963
+ function unescapeHeredocContent(content) {
1964
+ return content.replace(/\\`/g, "`").replace(/\\\$/g, "$").replace(/\\{/g, "{").replace(/\\}/g, "}");
1965
+ }
1960
1966
  function preprocessTomlHeredoc(tomlStr) {
1961
1967
  const lines = tomlStr.split("\n");
1962
1968
  const result = [];
@@ -1982,13 +1988,13 @@ function preprocessTomlHeredoc(tomlStr) {
1982
1988
  i++;
1983
1989
  }
1984
1990
  if (bodyLines.length === 0) {
1985
- result.push(`${indent}${key} = """"""`);
1991
+ result.push(`${indent}${key} = ''''''`);
1986
1992
  } else {
1987
- result.push(`${indent}${key} = """`);
1993
+ result.push(`${indent}${key} = '''`);
1988
1994
  for (let j = 0; j < bodyLines.length - 1; j++) {
1989
- result.push(bodyLines[j]);
1995
+ result.push(unescapeHeredocContent(bodyLines[j]));
1990
1996
  }
1991
- result.push(`${bodyLines[bodyLines.length - 1]}"""`);
1997
+ result.push(`${unescapeHeredocContent(bodyLines[bodyLines.length - 1])}'''`);
1992
1998
  }
1993
1999
  if (!foundClosing) {
1994
2000
  }
@@ -2037,6 +2043,19 @@ var init_parser = __esm({
2037
2043
  }
2038
2044
  return { actualName: gadgetName, invocationId: `gadget_${++globalInvocationCounter}` };
2039
2045
  }
2046
+ /**
2047
+ * Truncate verbose parse errors to avoid context overflow.
2048
+ * Keeps first meaningful line and limits total length.
2049
+ */
2050
+ truncateParseError(error, format) {
2051
+ const message = error instanceof Error ? error.message : String(error);
2052
+ const firstLine = message.split("\n")[0];
2053
+ const maxLen = 200;
2054
+ if (firstLine.length <= maxLen) {
2055
+ return firstLine;
2056
+ }
2057
+ return `${firstLine.slice(0, maxLen)}... (${message.length} chars total)`;
2058
+ }
2040
2059
  /**
2041
2060
  * Parse parameter string according to configured format
2042
2061
  */
@@ -2045,21 +2064,21 @@ var init_parser = __esm({
2045
2064
  try {
2046
2065
  return { parameters: JSON.parse(raw) };
2047
2066
  } catch (error) {
2048
- return { parseError: error instanceof Error ? error.message : "Failed to parse JSON" };
2067
+ return { parseError: this.truncateParseError(error, "JSON") };
2049
2068
  }
2050
2069
  }
2051
2070
  if (this.parameterFormat === "yaml") {
2052
2071
  try {
2053
2072
  return { parameters: yaml2.load(preprocessYaml(raw)) };
2054
2073
  } catch (error) {
2055
- return { parseError: error instanceof Error ? error.message : "Failed to parse YAML" };
2074
+ return { parseError: this.truncateParseError(error, "YAML") };
2056
2075
  }
2057
2076
  }
2058
2077
  if (this.parameterFormat === "toml") {
2059
2078
  try {
2060
2079
  return { parameters: (0, import_js_toml.load)(preprocessTomlHeredoc(raw)) };
2061
2080
  } catch (error) {
2062
- return { parseError: error instanceof Error ? error.message : "Failed to parse TOML" };
2081
+ return { parseError: this.truncateParseError(error, "TOML") };
2063
2082
  }
2064
2083
  }
2065
2084
  try {
@@ -2071,9 +2090,7 @@ var init_parser = __esm({
2071
2090
  try {
2072
2091
  return { parameters: yaml2.load(preprocessYaml(raw)) };
2073
2092
  } catch (error) {
2074
- return {
2075
- parseError: error instanceof Error ? error.message : "Failed to parse as JSON, TOML, or YAML"
2076
- };
2093
+ return { parseError: this.truncateParseError(error, "auto") };
2077
2094
  }
2078
2095
  }
2079
2096
  }
@@ -2375,7 +2392,8 @@ var init_stream_processor = __esm({
2375
2392
  if (call.parseError) {
2376
2393
  this.logger.warn("Gadget has parse error", {
2377
2394
  gadgetName: call.gadgetName,
2378
- error: call.parseError
2395
+ error: call.parseError,
2396
+ rawParameters: call.parametersYaml
2379
2397
  });
2380
2398
  const shouldContinue = await this.checkContinueAfterError(
2381
2399
  call.parseError,