llmist 0.1.3 → 0.1.5

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.
@@ -108,7 +108,6 @@ declare class StreamParser {
108
108
  private readonly startPrefix;
109
109
  private readonly endPrefix;
110
110
  private readonly parameterFormat;
111
- private invocationCounter;
112
111
  constructor(options?: StreamParserOptions);
113
112
  private takeTextUntil;
114
113
  /**
@@ -291,7 +290,7 @@ declare class LLMMessageBuilder {
291
290
  startPrefix?: string;
292
291
  endPrefix?: string;
293
292
  }): this;
294
- private buildGadgetsXmlSection;
293
+ private buildGadgetsSection;
295
294
  private buildUsageSection;
296
295
  private buildExamplesSection;
297
296
  private buildRulesSection;
@@ -488,14 +488,15 @@ var init_messages = __esm({
488
488
  context
489
489
  );
490
490
  parts.push(mainInstruction);
491
- parts.push(this.buildGadgetsXmlSection(gadgets, parameterFormat));
491
+ parts.push(this.buildGadgetsSection(gadgets, parameterFormat));
492
492
  parts.push(this.buildUsageSection(parameterFormat, context));
493
493
  this.messages.push({ role: "system", content: parts.join("") });
494
494
  return this;
495
495
  }
496
- buildGadgetsXmlSection(gadgets, parameterFormat) {
496
+ buildGadgetsSection(gadgets, parameterFormat) {
497
497
  const parts = [];
498
- parts.push("<GADGETS>");
498
+ parts.push("\n\nAVAILABLE GADGETS");
499
+ parts.push("\n=================\n");
499
500
  for (const gadget of gadgets) {
500
501
  const gadgetName = gadget.name ?? gadget.constructor.name;
501
502
  const instruction = gadget.getInstruction(parameterFormat);
@@ -503,18 +504,17 @@ var init_messages = __esm({
503
504
  const schemaIndex = instruction.indexOf(schemaMarker);
504
505
  const description = (schemaIndex !== -1 ? instruction.substring(0, schemaIndex) : instruction).trim();
505
506
  const schema = schemaIndex !== -1 ? instruction.substring(schemaIndex + schemaMarker.length).trim() : "";
506
- parts.push("\n <gadget>");
507
507
  parts.push(`
508
- <name>${gadgetName}</name>`);
508
+ GADGET: ${gadgetName}`);
509
509
  parts.push(`
510
- <description>${description}</description>`);
510
+ ${description}`);
511
511
  if (schema) {
512
512
  parts.push(`
513
- <schema format="${parameterFormat}">
514
- ${schema}
515
- </schema>`);
513
+
514
+ PARAMETERS (${parameterFormat.toUpperCase()}):
515
+ ${schema}`);
516
516
  }
517
- parts.push("\n </gadget>");
517
+ parts.push("\n\n---");
518
518
  }
519
519
  return parts.join("");
520
520
  }
@@ -529,26 +529,26 @@ ${schema}
529
529
  DEFAULT_PROMPTS.formatDescriptionJson,
530
530
  context
531
531
  );
532
- parts.push("<usage>");
532
+ parts.push("\n\nHOW TO INVOKE GADGETS");
533
+ parts.push("\n=====================\n");
533
534
  const criticalUsage = resolvePromptTemplate(
534
535
  this.promptConfig.criticalUsage,
535
536
  DEFAULT_PROMPTS.criticalUsage,
536
537
  context
537
538
  );
538
539
  parts.push(`
539
- <critical>${criticalUsage}</critical>`);
540
- parts.push("\n <format>");
540
+ CRITICAL: ${criticalUsage}
541
+ `);
542
+ parts.push("\nFORMAT:");
541
543
  parts.push(`
542
- <step>Start marker: ${this.startPrefix}gadget_name</step>`);
544
+ 1. Start marker: ${this.startPrefix}gadget_name`);
543
545
  parts.push(`
544
- <step>${formatDescription}</step>`);
546
+ 2. ${formatDescription}`);
545
547
  parts.push(`
546
- <step>End marker: ${this.endPrefix}</step>`);
547
- parts.push("\n </format>");
548
+ 3. End marker: ${this.endPrefix}`);
548
549
  parts.push(this.buildExamplesSection(parameterFormat, context));
549
550
  parts.push(this.buildRulesSection(context));
550
- parts.push("\n</usage>");
551
- parts.push("\n</GADGETS>\n\n");
551
+ parts.push("\n");
552
552
  return parts.join("");
553
553
  }
554
554
  buildExamplesSection(parameterFormat, context) {
@@ -556,7 +556,6 @@ ${schema}
556
556
  return this.promptConfig.customExamples(context);
557
557
  }
558
558
  const parts = [];
559
- parts.push("\n <examples>");
560
559
  const singleExample = parameterFormat === "yaml" ? `${this.startPrefix}translate
561
560
  from: English
562
561
  to: Polish
@@ -565,9 +564,10 @@ ${this.endPrefix}` : `${this.startPrefix}translate
565
564
  {"from": "English", "to": "Polish", "content": "Paris is the capital of France."}
566
565
  ${this.endPrefix}`;
567
566
  parts.push(`
568
- <example title="Single Gadget">
569
- ${singleExample}
570
- </example>`);
567
+
568
+ EXAMPLE (Single Gadget):
569
+
570
+ ${singleExample}`);
571
571
  const multipleExample = parameterFormat === "yaml" ? `${this.startPrefix}translate
572
572
  from: English
573
573
  to: Polish
@@ -584,21 +584,20 @@ ${this.startPrefix}analyze
584
584
  {"type": "economic_analysis", "matter": "Polish Economy", "question": "Polish arms exports 2025."}
585
585
  ${this.endPrefix}`;
586
586
  parts.push(`
587
- <example title="Multiple Gadgets">
588
- ${multipleExample}
589
- </example>`);
590
- parts.push("\n </examples>");
587
+
588
+ EXAMPLE (Multiple Gadgets):
589
+
590
+ ${multipleExample}`);
591
591
  return parts.join("");
592
592
  }
593
593
  buildRulesSection(context) {
594
594
  const parts = [];
595
- parts.push("\n <rules>");
595
+ parts.push("\n\nRULES:");
596
596
  const rules = resolveRulesTemplate(this.promptConfig.rules, context);
597
597
  for (const rule of rules) {
598
598
  parts.push(`
599
- <rule>${rule}</rule>`);
599
+ - ${rule}`);
600
600
  }
601
- parts.push("\n </rules>");
602
601
  return parts.join("");
603
602
  }
604
603
  addUser(content, metadata) {
@@ -1139,19 +1138,19 @@ var init_executor = __esm({
1139
1138
  });
1140
1139
 
1141
1140
  // src/gadgets/parser.ts
1142
- var yaml, StreamParser;
1141
+ var yaml, globalInvocationCounter, StreamParser;
1143
1142
  var init_parser = __esm({
1144
1143
  "src/gadgets/parser.ts"() {
1145
1144
  "use strict";
1146
1145
  yaml = __toESM(require("js-yaml"), 1);
1147
1146
  init_constants();
1147
+ globalInvocationCounter = 0;
1148
1148
  StreamParser = class {
1149
1149
  buffer = "";
1150
1150
  lastReportedTextLength = 0;
1151
1151
  startPrefix;
1152
1152
  endPrefix;
1153
1153
  parameterFormat;
1154
- invocationCounter = 0;
1155
1154
  constructor(options = {}) {
1156
1155
  this.startPrefix = options.startPrefix ?? GADGET_START_PREFIX;
1157
1156
  this.endPrefix = options.endPrefix ?? GADGET_END_PREFIX;
@@ -1218,7 +1217,7 @@ var init_parser = __esm({
1218
1217
  invocationId = parts[1];
1219
1218
  } else {
1220
1219
  actualGadgetName = gadgetName;
1221
- invocationId = `auto_${++this.invocationCounter}`;
1220
+ invocationId = `gadget_${++globalInvocationCounter}`;
1222
1221
  }
1223
1222
  const contentStartIndex = metadataEndIndex + 1;
1224
1223
  let partEndIndex;
@@ -1275,11 +1274,10 @@ var init_parser = __esm({
1275
1274
  yield { type: "text", content: remainingText };
1276
1275
  }
1277
1276
  }
1278
- // Reset parser state
1277
+ // Reset parser state (note: global invocation counter is NOT reset to ensure unique IDs)
1279
1278
  reset() {
1280
1279
  this.buffer = "";
1281
1280
  this.lastReportedTextLength = 0;
1282
- this.invocationCounter = 0;
1283
1281
  }
1284
1282
  };
1285
1283
  }