llmist 1.4.0 → 1.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/dist/{chunk-UEEESLOA.js → chunk-QR5IQXEM.js} +2 -2
- package/dist/{chunk-VGZCFUPX.js → chunk-X5XQ6M5P.js} +84 -31
- package/dist/chunk-X5XQ6M5P.js.map +1 -0
- package/dist/cli.cjs +84 -31
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +3 -3
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +83 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +2 -2
- package/dist/{mock-stream-DD5yJM44.d.cts → mock-stream-Cc47j12U.d.cts} +6 -2
- package/dist/{mock-stream-DD5yJM44.d.ts → mock-stream-Cc47j12U.d.ts} +6 -2
- package/dist/testing/index.cjs +83 -30
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +2 -2
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-VGZCFUPX.js.map +0 -1
- /package/dist/{chunk-UEEESLOA.js.map → chunk-QR5IQXEM.js.map} +0 -0
package/dist/cli.cjs
CHANGED
|
@@ -830,38 +830,83 @@ function formatParamsAsBlock(params, prefix = "", argPrefix = GADGET_ARG_PREFIX)
|
|
|
830
830
|
}
|
|
831
831
|
return lines.join("\n");
|
|
832
832
|
}
|
|
833
|
-
function
|
|
833
|
+
function formatParamLine(key, propObj, isRequired, indent = "") {
|
|
834
|
+
const type = propObj.type;
|
|
835
|
+
const description = propObj.description;
|
|
836
|
+
const enumValues = propObj.enum;
|
|
837
|
+
let line = `${indent}- ${key}`;
|
|
838
|
+
if (type === "array") {
|
|
839
|
+
const items = propObj.items;
|
|
840
|
+
const itemType = items?.type || "any";
|
|
841
|
+
line += ` (array of ${itemType})`;
|
|
842
|
+
} else if (type === "object" && propObj.properties) {
|
|
843
|
+
line += " (object)";
|
|
844
|
+
} else {
|
|
845
|
+
line += ` (${type})`;
|
|
846
|
+
}
|
|
847
|
+
if (isRequired && indent !== "") {
|
|
848
|
+
line += " [required]";
|
|
849
|
+
}
|
|
850
|
+
if (description) {
|
|
851
|
+
line += `: ${description}`;
|
|
852
|
+
}
|
|
853
|
+
if (enumValues) {
|
|
854
|
+
line += ` - one of: ${enumValues.map((v) => `"${v}"`).join(", ")}`;
|
|
855
|
+
}
|
|
856
|
+
return line;
|
|
857
|
+
}
|
|
858
|
+
function formatSchemaAsPlainText(schema, indent = "", atRoot = true) {
|
|
834
859
|
const lines = [];
|
|
835
860
|
const properties = schema.properties || {};
|
|
836
861
|
const required = schema.required || [];
|
|
837
|
-
|
|
838
|
-
const
|
|
839
|
-
const
|
|
840
|
-
const
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
const itemType = items?.type || "any";
|
|
847
|
-
line += ` (array of ${itemType})`;
|
|
848
|
-
} else if (type === "object" && propObj.properties) {
|
|
849
|
-
line += " (object)";
|
|
850
|
-
} else {
|
|
851
|
-
line += ` (${type})`;
|
|
862
|
+
if (atRoot && indent === "") {
|
|
863
|
+
const requiredProps = [];
|
|
864
|
+
const optionalProps = [];
|
|
865
|
+
for (const [key, prop] of Object.entries(properties)) {
|
|
866
|
+
if (required.includes(key)) {
|
|
867
|
+
requiredProps.push([key, prop]);
|
|
868
|
+
} else {
|
|
869
|
+
optionalProps.push([key, prop]);
|
|
870
|
+
}
|
|
852
871
|
}
|
|
853
|
-
|
|
854
|
-
|
|
872
|
+
const reqCount = requiredProps.length;
|
|
873
|
+
const optCount = optionalProps.length;
|
|
874
|
+
if (reqCount > 0 || optCount > 0) {
|
|
875
|
+
const parts = [];
|
|
876
|
+
if (reqCount > 0) parts.push(`${reqCount} required`);
|
|
877
|
+
if (optCount > 0) parts.push(`${optCount} optional`);
|
|
878
|
+
lines.push(parts.join(", "));
|
|
879
|
+
lines.push("");
|
|
855
880
|
}
|
|
856
|
-
if (
|
|
857
|
-
|
|
881
|
+
if (reqCount > 0) {
|
|
882
|
+
lines.push("REQUIRED Parameters:");
|
|
883
|
+
for (const [key, prop] of requiredProps) {
|
|
884
|
+
lines.push(formatParamLine(key, prop, true, ""));
|
|
885
|
+
const propObj = prop;
|
|
886
|
+
if (propObj.type === "object" && propObj.properties) {
|
|
887
|
+
lines.push(formatSchemaAsPlainText(propObj, " ", false));
|
|
888
|
+
}
|
|
889
|
+
}
|
|
858
890
|
}
|
|
859
|
-
if (
|
|
860
|
-
|
|
891
|
+
if (optCount > 0) {
|
|
892
|
+
if (reqCount > 0) lines.push("");
|
|
893
|
+
lines.push("OPTIONAL Parameters:");
|
|
894
|
+
for (const [key, prop] of optionalProps) {
|
|
895
|
+
lines.push(formatParamLine(key, prop, false, ""));
|
|
896
|
+
const propObj = prop;
|
|
897
|
+
if (propObj.type === "object" && propObj.properties) {
|
|
898
|
+
lines.push(formatSchemaAsPlainText(propObj, " ", false));
|
|
899
|
+
}
|
|
900
|
+
}
|
|
861
901
|
}
|
|
862
|
-
lines.
|
|
863
|
-
|
|
864
|
-
|
|
902
|
+
return lines.join("\n");
|
|
903
|
+
}
|
|
904
|
+
for (const [key, prop] of Object.entries(properties)) {
|
|
905
|
+
const isRequired = required.includes(key);
|
|
906
|
+
lines.push(formatParamLine(key, prop, isRequired, indent));
|
|
907
|
+
const propObj = prop;
|
|
908
|
+
if (propObj.type === "object" && propObj.properties) {
|
|
909
|
+
lines.push(formatSchemaAsPlainText(propObj, indent + " ", false));
|
|
865
910
|
}
|
|
866
911
|
}
|
|
867
912
|
return lines.join("\n");
|
|
@@ -912,10 +957,11 @@ var init_gadget = __esm({
|
|
|
912
957
|
* Generate instruction text for the LLM.
|
|
913
958
|
* Combines name, description, and parameter schema into a formatted instruction.
|
|
914
959
|
*
|
|
915
|
-
* @param
|
|
960
|
+
* @param optionsOrArgPrefix - Optional custom prefixes for examples, or just argPrefix string for backwards compatibility
|
|
916
961
|
* @returns Formatted instruction string
|
|
917
962
|
*/
|
|
918
|
-
getInstruction(
|
|
963
|
+
getInstruction(optionsOrArgPrefix) {
|
|
964
|
+
const options = typeof optionsOrArgPrefix === "string" ? { argPrefix: optionsOrArgPrefix } : optionsOrArgPrefix;
|
|
919
965
|
const parts = [];
|
|
920
966
|
parts.push(this.description);
|
|
921
967
|
if (this.parameterSchema) {
|
|
@@ -929,18 +975,25 @@ var init_gadget = __esm({
|
|
|
929
975
|
}
|
|
930
976
|
if (this.examples && this.examples.length > 0) {
|
|
931
977
|
parts.push("\n\nExamples:");
|
|
932
|
-
const effectiveArgPrefix = argPrefix ?? GADGET_ARG_PREFIX;
|
|
978
|
+
const effectiveArgPrefix = options?.argPrefix ?? GADGET_ARG_PREFIX;
|
|
979
|
+
const effectiveStartPrefix = options?.startPrefix ?? GADGET_START_PREFIX;
|
|
980
|
+
const effectiveEndPrefix = options?.endPrefix ?? GADGET_END_PREFIX;
|
|
981
|
+
const gadgetName = this.name || this.constructor.name;
|
|
933
982
|
this.examples.forEach((example, index) => {
|
|
934
983
|
if (index > 0) {
|
|
935
984
|
parts.push("");
|
|
985
|
+
parts.push("---");
|
|
986
|
+
parts.push("");
|
|
936
987
|
}
|
|
937
988
|
if (example.comment) {
|
|
938
989
|
parts.push(`# ${example.comment}`);
|
|
939
990
|
}
|
|
940
|
-
parts.push(
|
|
991
|
+
parts.push(`${effectiveStartPrefix}${gadgetName}`);
|
|
941
992
|
parts.push(formatParamsAsBlock(example.params, "", effectiveArgPrefix));
|
|
993
|
+
parts.push(effectiveEndPrefix);
|
|
942
994
|
if (example.output !== void 0) {
|
|
943
|
-
parts.push("
|
|
995
|
+
parts.push("");
|
|
996
|
+
parts.push("Expected Output:");
|
|
944
997
|
parts.push(example.output);
|
|
945
998
|
}
|
|
946
999
|
});
|
|
@@ -6526,7 +6579,7 @@ var import_commander2 = require("commander");
|
|
|
6526
6579
|
// package.json
|
|
6527
6580
|
var package_default = {
|
|
6528
6581
|
name: "llmist",
|
|
6529
|
-
version: "1.
|
|
6582
|
+
version: "1.4.0",
|
|
6530
6583
|
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.",
|
|
6531
6584
|
type: "module",
|
|
6532
6585
|
main: "dist/index.cjs",
|