llmz 0.7.1 → 0.8.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/{_baseForOwn-buOZDFbK.cjs → _baseForOwn-BfWDTL8L.cjs} +0 -50
- package/dist/common-DdArNQhl.cjs +643 -0
- package/dist/common-pgJjFu2Y.js +596 -0
- package/dist/compiler-C-OI9sim.cjs +547 -0
- package/dist/compiler-CW1VjQsn.js +473 -0
- package/dist/{component-BwixNVH8.cjs → component-BXS8vAwO.cjs} +3 -3
- package/dist/{component-DGG7d_Mz.js → component-Dq7ZLdvy.js} +1 -1
- package/dist/component.d.ts +4 -4
- package/dist/component.default.d.ts +60 -87
- package/dist/component.default.test.d.ts +1 -0
- package/dist/context.d.ts +10 -0
- package/dist/{custom-client-CMuy7fXU.js → custom-client-2V9lmzUf.js} +119 -24
- package/dist/{custom-client-Bp1TgTKk.cjs → custom-client-HkM1Sdzv.cjs} +124 -29
- package/dist/{dual-modes-CfqTk9M8.cjs → dual-modes-Cb7ThvoV.cjs} +1268 -1062
- package/dist/{dual-modes-mNyMThtf.js → dual-modes-Cy0_W4O2.js} +1242 -1036
- package/dist/example.d.ts +45 -0
- package/dist/example.test.d.ts +1 -0
- package/dist/{execute-DP_17lYZ.js → execute-Aw4cbIx-.js} +23 -10
- package/dist/{execute-msui51b2.cjs → execute-COIHOIKR.cjs} +30 -18
- package/dist/{exit-BGi0Kk0y.cjs → exit-DUM96DN1.cjs} +3 -3
- package/dist/exit-parser.d.ts +2 -0
- package/dist/index.cjs +33 -356
- package/dist/index.d.ts +2 -0
- package/dist/index.js +13 -337
- package/dist/index.workerd.js +9981 -9388
- package/dist/{jsx-CIgdGGVs.js → jsx-B0iYyvfr.js} +50 -2
- package/dist/{jsx-BWvT6ukg.cjs → jsx-D5Y2cPo-.cjs} +58 -4
- package/dist/message-stream/parser.d.ts +3 -0
- package/dist/message-stream/types.d.ts +1 -1
- package/dist/prompts/chat-mode/system.d.ts +2 -0
- package/dist/prompts/chat-mode/user.d.ts +2 -0
- package/dist/prompts/execution-history.d.ts +6 -0
- package/dist/prompts/execution-state.d.ts +3 -0
- package/dist/prompts/prompt.d.ts +26 -0
- package/dist/prompts/protocol.test.d.ts +1 -0
- package/dist/prompts/worker-mode/system.d.ts +2 -0
- package/dist/prompts/worker-mode/user.d.ts +2 -0
- package/dist/runtime/types.d.ts +9 -0
- package/dist/{tool-ReA9gxMp.cjs → tool-Dy6AJpJH.cjs} +4 -4
- package/dist/{truncator-B6aaJaN1.cjs → truncator-CLkouTCO.cjs} +3 -3
- package/dist/{typings-BwAz_TM9.cjs → typings-3lsqCbkn.cjs} +3 -3
- package/dist/{utils-ZpJm00ed.cjs → utils-3ESwP3yg.cjs} +2 -2
- package/dist/{vm-C5vf1LH3.js → vm-BLsHw1da.js} +3 -462
- package/dist/{vm-BjkJqSQH.cjs → vm-D6s1zF6M.cjs} +28 -489
- package/package.json +1 -1
- package/dist/isPlainObject-CSxXVKCk.cjs +0 -56
- package/dist/isPlainObject-D39AzPO2.js +0 -51
package/dist/index.cjs
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
2
|
+
const require_common = require("./common-DdArNQhl.cjs");
|
|
3
|
+
const require_dual_modes = require("./dual-modes-Cb7ThvoV.cjs");
|
|
4
|
+
const require_custom_client = require("./custom-client-HkM1Sdzv.cjs");
|
|
5
|
+
const require_utils = require("./utils-3ESwP3yg.cjs");
|
|
6
|
+
const require_component = require("./component-BXS8vAwO.cjs");
|
|
7
|
+
const require_tool = require("./tool-Dy6AJpJH.cjs");
|
|
6
8
|
const require_errors = require("./errors-C962uJdS.cjs");
|
|
7
|
-
const require_typings = require("./typings-
|
|
8
|
-
const require_exit = require("./exit-
|
|
9
|
-
const
|
|
10
|
-
const require_truncator = require("./truncator-B6aaJaN1.cjs");
|
|
9
|
+
const require_typings = require("./typings-3lsqCbkn.cjs");
|
|
10
|
+
const require_exit = require("./exit-DUM96DN1.cjs");
|
|
11
|
+
const require_truncator = require("./truncator-CLkouTCO.cjs");
|
|
11
12
|
const require_quickjs_variant = require("./quickjs-variant-CsIwTVFC.cjs");
|
|
12
13
|
let _bpinternal_zui = require("@bpinternal/zui");
|
|
13
14
|
//#region package.json
|
|
14
|
-
var version = "0.
|
|
15
|
+
var version = "0.8.0";
|
|
15
16
|
//#endregion
|
|
16
17
|
//#region src/hoist.ts
|
|
17
18
|
/**
|
|
@@ -791,173 +792,6 @@ var CitationsManager = class {
|
|
|
791
792
|
}
|
|
792
793
|
};
|
|
793
794
|
//#endregion
|
|
794
|
-
//#region src/component.default.ts
|
|
795
|
-
const Button = new require_component.Component({
|
|
796
|
-
type: "leaf",
|
|
797
|
-
description: "A button component that can perform actions when clicked",
|
|
798
|
-
name: "Button",
|
|
799
|
-
aliases: ["btn"],
|
|
800
|
-
generation: {
|
|
801
|
-
usage: "Attach quick actions to a message, e.g. postback choices or a URL to open.",
|
|
802
|
-
examples: [{ props: {
|
|
803
|
-
action: "postback",
|
|
804
|
-
label: "Buy",
|
|
805
|
-
value: "buy_product"
|
|
806
|
-
} }]
|
|
807
|
-
},
|
|
808
|
-
leaf: { props: _bpinternal_zui.z.object({
|
|
809
|
-
action: _bpinternal_zui.z.enum([
|
|
810
|
-
"say",
|
|
811
|
-
"url",
|
|
812
|
-
"postback"
|
|
813
|
-
]).default("say").describe("The action to perform when the button is clicked. Can be \"say\", \"url\", or \"postback\""),
|
|
814
|
-
label: _bpinternal_zui.z.string().describe("The text displayed on the button (min 1 character, max 250 characters)"),
|
|
815
|
-
value: _bpinternal_zui.z.string().optional().describe("The postback value to send when the button is clicked. Required if action is \"postback\""),
|
|
816
|
-
url: _bpinternal_zui.z.string().optional().describe("The URL to open when the button is clicked. Required if action is \"url\"")
|
|
817
|
-
}) }
|
|
818
|
-
});
|
|
819
|
-
const Image = new require_component.Component({
|
|
820
|
-
type: "leaf",
|
|
821
|
-
name: "Image",
|
|
822
|
-
description: "Displays an image from a URL.",
|
|
823
|
-
aliases: [],
|
|
824
|
-
generation: { examples: [{ props: {
|
|
825
|
-
url: "https://example.com/photo.jpg",
|
|
826
|
-
alt: "Example image"
|
|
827
|
-
} }] },
|
|
828
|
-
leaf: { props: _bpinternal_zui.z.object({
|
|
829
|
-
url: _bpinternal_zui.z.string().describe("The URL of the image (must be valid)"),
|
|
830
|
-
alt: _bpinternal_zui.z.string().optional().describe("Alternative text describing the image")
|
|
831
|
-
}) }
|
|
832
|
-
});
|
|
833
|
-
const File = new require_component.Component({
|
|
834
|
-
type: "leaf",
|
|
835
|
-
name: "File",
|
|
836
|
-
description: "Sends a downloadable file to the user.",
|
|
837
|
-
aliases: [],
|
|
838
|
-
generation: { examples: [{ props: {
|
|
839
|
-
url: "https://example.com/report.pdf",
|
|
840
|
-
name: "Report.pdf"
|
|
841
|
-
} }] },
|
|
842
|
-
leaf: { props: _bpinternal_zui.z.object({
|
|
843
|
-
url: _bpinternal_zui.z.string().describe("The URL of the file (must be valid)"),
|
|
844
|
-
name: _bpinternal_zui.z.string().optional().describe("The display name of the file")
|
|
845
|
-
}) }
|
|
846
|
-
});
|
|
847
|
-
const Video = new require_component.Component({
|
|
848
|
-
type: "leaf",
|
|
849
|
-
name: "Video",
|
|
850
|
-
description: "Embeds a video from a URL.",
|
|
851
|
-
aliases: [],
|
|
852
|
-
generation: { examples: [{ props: {
|
|
853
|
-
url: "https://example.com/intro.mp4",
|
|
854
|
-
title: "Welcome"
|
|
855
|
-
} }] },
|
|
856
|
-
leaf: { props: _bpinternal_zui.z.object({
|
|
857
|
-
url: _bpinternal_zui.z.string().describe("The URL of the video (must be valid)"),
|
|
858
|
-
title: _bpinternal_zui.z.string().optional().describe("Title for the video")
|
|
859
|
-
}) }
|
|
860
|
-
});
|
|
861
|
-
const Audio = new require_component.Component({
|
|
862
|
-
type: "leaf",
|
|
863
|
-
name: "Audio",
|
|
864
|
-
description: "Plays an audio clip from a URL.",
|
|
865
|
-
aliases: [],
|
|
866
|
-
generation: { examples: [{ props: {
|
|
867
|
-
url: "https://example.com/audio.mp3",
|
|
868
|
-
title: "Sample"
|
|
869
|
-
} }] },
|
|
870
|
-
leaf: { props: _bpinternal_zui.z.object({
|
|
871
|
-
url: _bpinternal_zui.z.string().describe("The URL of the audio clip (must be valid)"),
|
|
872
|
-
title: _bpinternal_zui.z.string().optional().describe("Title for the audio clip")
|
|
873
|
-
}) }
|
|
874
|
-
});
|
|
875
|
-
const Card = new require_component.Component({
|
|
876
|
-
type: "container",
|
|
877
|
-
name: "Card",
|
|
878
|
-
description: "A visual card component that can include an image and buttons.",
|
|
879
|
-
aliases: [],
|
|
880
|
-
generation: { examples: [{
|
|
881
|
-
props: {
|
|
882
|
-
title: "Product Name",
|
|
883
|
-
subtitle: "Limited offer"
|
|
884
|
-
},
|
|
885
|
-
body: "Featured product of the week."
|
|
886
|
-
}] },
|
|
887
|
-
container: {
|
|
888
|
-
props: _bpinternal_zui.z.object({
|
|
889
|
-
title: _bpinternal_zui.z.string().min(1).max(250).describe("Title text (1–250 characters)"),
|
|
890
|
-
subtitle: _bpinternal_zui.z.string().optional().describe("Optional subtitle for the card")
|
|
891
|
-
}),
|
|
892
|
-
children: [{
|
|
893
|
-
description: "Image (optional, max 1)",
|
|
894
|
-
component: Image.definition
|
|
895
|
-
}, {
|
|
896
|
-
description: "Button (optional, up to 5)",
|
|
897
|
-
component: Button.definition
|
|
898
|
-
}]
|
|
899
|
-
}
|
|
900
|
-
});
|
|
901
|
-
const DefaultComponents = {
|
|
902
|
-
Button,
|
|
903
|
-
Image,
|
|
904
|
-
File,
|
|
905
|
-
Video,
|
|
906
|
-
Audio,
|
|
907
|
-
Card,
|
|
908
|
-
Carousel: new require_component.Component({
|
|
909
|
-
type: "container",
|
|
910
|
-
name: "Carousel",
|
|
911
|
-
description: "A virtual container for displaying 1 to 10 Card components as a carousel.",
|
|
912
|
-
aliases: [],
|
|
913
|
-
container: {
|
|
914
|
-
props: _bpinternal_zui.z.object({}),
|
|
915
|
-
children: [{
|
|
916
|
-
description: "Card component (required, 1–10 allowed)",
|
|
917
|
-
component: Card.definition
|
|
918
|
-
}]
|
|
919
|
-
}
|
|
920
|
-
}),
|
|
921
|
-
Text: new require_component.Component({
|
|
922
|
-
type: "default",
|
|
923
|
-
name: "Message",
|
|
924
|
-
aliases: ["Text", "Markdown"],
|
|
925
|
-
description: "A Markdown-formatted text message. Long answers are written the same way: plain Markdown prose.",
|
|
926
|
-
generation: { examples: [{ body: `Great question! Deploying happens in three steps.
|
|
927
|
-
|
|
928
|
-
First, connect your repository from the dashboard — we support GitHub and GitLab. Once connected, every push to your main branch triggers a build automatically.
|
|
929
|
-
|
|
930
|
-
Then configure your build settings:
|
|
931
|
-
|
|
932
|
-
- **Build command** — usually \`npm run build\`
|
|
933
|
-
- **Output directory** — where the compiled assets end up
|
|
934
|
-
|
|
935
|
-
Finally, hit **Deploy**. The first build takes a couple of minutes; subsequent ones are incremental and much faster. Want me to walk you through connecting your repository?` }, { body: "**Hello**, welcome to our service!" }] },
|
|
936
|
-
default: {
|
|
937
|
-
props: _bpinternal_zui.z.object({}),
|
|
938
|
-
children: []
|
|
939
|
-
}
|
|
940
|
-
}),
|
|
941
|
-
Speech: new require_component.Component({
|
|
942
|
-
type: "default",
|
|
943
|
-
name: "Speech",
|
|
944
|
-
aliases: ["speak", "spoken"],
|
|
945
|
-
description: "A message spoken aloud to the user via text-to-speech.",
|
|
946
|
-
body: {
|
|
947
|
-
format: "text",
|
|
948
|
-
description: "Plain conversational prose only, written to be read aloud: no Markdown, no links or URLs, no emojis, no code, no bullet points, tables or headings. Write everything the way it should be pronounced — spell out numbers, dates, units and abbreviations (e.g. \"June third at three thirty PM\", not \"06/03 @ 3:30pm\")."
|
|
949
|
-
},
|
|
950
|
-
generation: {
|
|
951
|
-
usage: "Use when the reply will be played back as audio (voice conversations).",
|
|
952
|
-
examples: [{ body: "Sure! Your order shipped this morning and should arrive on Tuesday, June third, around noon." }]
|
|
953
|
-
},
|
|
954
|
-
default: {
|
|
955
|
-
props: _bpinternal_zui.z.object({}),
|
|
956
|
-
children: []
|
|
957
|
-
}
|
|
958
|
-
})
|
|
959
|
-
};
|
|
960
|
-
//#endregion
|
|
961
795
|
//#region src/chat.ts
|
|
962
796
|
/**
|
|
963
797
|
* Base class for implementing chat interfaces in LLMz agents.
|
|
@@ -1461,7 +1295,7 @@ function parseText(text, options) {
|
|
|
1461
1295
|
})(), options);
|
|
1462
1296
|
}
|
|
1463
1297
|
async function* parseResponses(stream, options) {
|
|
1464
|
-
const pump = new EventPump(stream, new
|
|
1298
|
+
const pump = new EventPump(stream, new require_common.StreamingMessageParser(options));
|
|
1465
1299
|
let activeBody;
|
|
1466
1300
|
while (true) {
|
|
1467
1301
|
if (activeBody) {
|
|
@@ -1498,34 +1332,6 @@ async function* bodyStream(pump, itemId) {
|
|
|
1498
1332
|
}
|
|
1499
1333
|
}
|
|
1500
1334
|
//#endregion
|
|
1501
|
-
//#region src/message-stream/registry.ts
|
|
1502
|
-
/**
|
|
1503
|
-
* Stores normalized component definitions. The registry (not the parser) is the
|
|
1504
|
-
* single source of truth for which components exist and how they are validated.
|
|
1505
|
-
*/
|
|
1506
|
-
var ComponentRegistry = class {
|
|
1507
|
-
_definitions = /* @__PURE__ */ new Map();
|
|
1508
|
-
constructor(definitions = []) {
|
|
1509
|
-
for (const definition of definitions) this.register(definition);
|
|
1510
|
-
}
|
|
1511
|
-
register(definition) {
|
|
1512
|
-
if (!require_dual_modes.NAME_REGEX.test(definition.name)) throw new Error(`Invalid component name "${definition.name}". Component names must be lowercase ([a-z][a-z0-9_-]*).`);
|
|
1513
|
-
this._definitions.set(definition.name, definition);
|
|
1514
|
-
}
|
|
1515
|
-
unregister(name) {
|
|
1516
|
-
this._definitions.delete(name);
|
|
1517
|
-
}
|
|
1518
|
-
has(name) {
|
|
1519
|
-
return this._definitions.has(name);
|
|
1520
|
-
}
|
|
1521
|
-
get(name) {
|
|
1522
|
-
return this._definitions.get(name);
|
|
1523
|
-
}
|
|
1524
|
-
list() {
|
|
1525
|
-
return [...this._definitions.values()];
|
|
1526
|
-
}
|
|
1527
|
-
};
|
|
1528
|
-
//#endregion
|
|
1529
1335
|
//#region src/message-stream/normalizer.ts
|
|
1530
1336
|
const EMPTY_PROPS_SCHEMA = {
|
|
1531
1337
|
type: "object",
|
|
@@ -1535,7 +1341,7 @@ const EMPTY_PROPS_SCHEMA = {
|
|
|
1535
1341
|
const normalizeComponentName = (name) => name.trim().toLowerCase();
|
|
1536
1342
|
function normalizeComponentDefinition(definition) {
|
|
1537
1343
|
const name = normalizeComponentName(definition.name ?? "");
|
|
1538
|
-
if (!
|
|
1344
|
+
if (!require_common.NAME_REGEX.test(name)) throw new Error(`Invalid component name "${definition.name}". Component names must be lowercase ([a-z][a-z0-9_-]*).`);
|
|
1539
1345
|
return {
|
|
1540
1346
|
name,
|
|
1541
1347
|
description: definition.description,
|
|
@@ -1559,137 +1365,6 @@ function normalizePropsSchema(props, name) {
|
|
|
1559
1365
|
throw new Error(`Invalid props schema for "${name}". Expected a ZUI/Zod object schema or a JSON schema, but got type "${typeof props}".`);
|
|
1560
1366
|
}
|
|
1561
1367
|
//#endregion
|
|
1562
|
-
//#region src/message-stream/validator.ts
|
|
1563
|
-
/**
|
|
1564
|
-
* Validates a syntactically parsed `■send` item against the registered
|
|
1565
|
-
* component definitions. Validation is intentionally separate from parsing: a
|
|
1566
|
-
* validation failure never stops the stream, it only produces errors the caller
|
|
1567
|
-
* can turn into diagnostics or fallback rendering.
|
|
1568
|
-
*/
|
|
1569
|
-
function validateComponent(item, registry) {
|
|
1570
|
-
const definition = registry.get(item.name);
|
|
1571
|
-
if (!definition) {
|
|
1572
|
-
const registered = registry.list().map((d) => d.name).join(", ") || "(none)";
|
|
1573
|
-
return {
|
|
1574
|
-
valid: false,
|
|
1575
|
-
props: item.props,
|
|
1576
|
-
errors: [{
|
|
1577
|
-
code: "unknown-component",
|
|
1578
|
-
message: `Unknown component "${item.name}". Registered components: ${registered}`
|
|
1579
|
-
}]
|
|
1580
|
-
};
|
|
1581
|
-
}
|
|
1582
|
-
const errors = [..._validateProps(item.props, definition), ..._validateBody(item, definition)];
|
|
1583
|
-
return {
|
|
1584
|
-
valid: errors.length === 0,
|
|
1585
|
-
props: item.props,
|
|
1586
|
-
errors
|
|
1587
|
-
};
|
|
1588
|
-
}
|
|
1589
|
-
/** Validates a props object against a JSON schema (also used for `■next` exit props). */
|
|
1590
|
-
function validateProps(props, schema) {
|
|
1591
|
-
const errors = [];
|
|
1592
|
-
_checkValue(props, schema, "", errors);
|
|
1593
|
-
return errors;
|
|
1594
|
-
}
|
|
1595
|
-
const _validateProps = (props, definition) => validateProps(props, definition.propsJsonSchema);
|
|
1596
|
-
const _validateBody = (item, definition) => {
|
|
1597
|
-
var _definition$body;
|
|
1598
|
-
const hasBody = typeof item.body === "string" && item.body.length > 0;
|
|
1599
|
-
if (hasBody && !definition.body) return [{
|
|
1600
|
-
code: "body-not-allowed",
|
|
1601
|
-
message: `Component "${definition.name}" does not support a body`
|
|
1602
|
-
}];
|
|
1603
|
-
if (!hasBody && ((_definition$body = definition.body) === null || _definition$body === void 0 ? void 0 : _definition$body.required)) return [{
|
|
1604
|
-
code: "missing-required-body",
|
|
1605
|
-
message: `Component "${definition.name}" requires a body`
|
|
1606
|
-
}];
|
|
1607
|
-
return [];
|
|
1608
|
-
};
|
|
1609
|
-
const _typeOf = (value) => {
|
|
1610
|
-
if (value === null) return "null";
|
|
1611
|
-
if (Array.isArray(value)) return "array";
|
|
1612
|
-
return typeof value;
|
|
1613
|
-
};
|
|
1614
|
-
const _matchesType = (value, type) => {
|
|
1615
|
-
switch (type) {
|
|
1616
|
-
case "string": return typeof value === "string";
|
|
1617
|
-
case "number": return typeof value === "number";
|
|
1618
|
-
case "integer": return typeof value === "number" && Number.isInteger(value);
|
|
1619
|
-
case "boolean": return typeof value === "boolean";
|
|
1620
|
-
case "null": return value === null;
|
|
1621
|
-
case "array": return Array.isArray(value);
|
|
1622
|
-
case "object": return !!value && typeof value === "object" && !Array.isArray(value);
|
|
1623
|
-
default: return true;
|
|
1624
|
-
}
|
|
1625
|
-
};
|
|
1626
|
-
const _isEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
1627
|
-
/**
|
|
1628
|
-
* Minimal JSON-schema subset checker covering what component schemas need:
|
|
1629
|
-
* type, enum, const, required, properties, additionalProperties, items, anyOf/oneOf.
|
|
1630
|
-
* Unknown keywords are ignored (lenient by design).
|
|
1631
|
-
*/
|
|
1632
|
-
const _checkValue = (value, schema, path, errors) => {
|
|
1633
|
-
if (schema === void 0 || typeof schema === "boolean" || typeof schema !== "object") return;
|
|
1634
|
-
const label = path || "props";
|
|
1635
|
-
const propError = (message) => {
|
|
1636
|
-
errors.push({
|
|
1637
|
-
code: "invalid-prop-value",
|
|
1638
|
-
message,
|
|
1639
|
-
path: path || void 0
|
|
1640
|
-
});
|
|
1641
|
-
};
|
|
1642
|
-
if (schema.const !== void 0 && !_isEqual(value, schema.const)) {
|
|
1643
|
-
propError(`Expected "${label}" to equal ${JSON.stringify(schema.const)}`);
|
|
1644
|
-
return;
|
|
1645
|
-
}
|
|
1646
|
-
if (schema.enum && !schema.enum.some((allowed) => _isEqual(value, allowed))) {
|
|
1647
|
-
propError(`Expected "${label}" to be one of: ${schema.enum.map((v) => JSON.stringify(v)).join(", ")}`);
|
|
1648
|
-
return;
|
|
1649
|
-
}
|
|
1650
|
-
const variants = schema.anyOf ?? schema.oneOf;
|
|
1651
|
-
if (variants === null || variants === void 0 ? void 0 : variants.length) {
|
|
1652
|
-
if (!variants.some((variant) => {
|
|
1653
|
-
const variantErrors = [];
|
|
1654
|
-
_checkValue(value, variant, path, variantErrors);
|
|
1655
|
-
return variantErrors.length === 0;
|
|
1656
|
-
})) {
|
|
1657
|
-
propError(`Value of "${label}" does not match any of the allowed types`);
|
|
1658
|
-
return;
|
|
1659
|
-
}
|
|
1660
|
-
}
|
|
1661
|
-
if (schema.type) {
|
|
1662
|
-
const types = Array.isArray(schema.type) ? schema.type : [schema.type];
|
|
1663
|
-
if (!types.some((type) => _matchesType(value, type))) {
|
|
1664
|
-
propError(`Expected "${label}" to be of type ${types.join(" | ")}, but got ${_typeOf(value)}`);
|
|
1665
|
-
return;
|
|
1666
|
-
}
|
|
1667
|
-
}
|
|
1668
|
-
if (Array.isArray(value) && schema.items && !Array.isArray(schema.items)) value.forEach((item, index) => _checkValue(item, schema.items, `${label}[${index}]`, errors));
|
|
1669
|
-
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
1670
|
-
const record = value;
|
|
1671
|
-
const properties = schema.properties ?? {};
|
|
1672
|
-
for (const requiredKey of schema.required ?? []) if (record[requiredKey] === void 0) errors.push({
|
|
1673
|
-
code: "missing-required-prop",
|
|
1674
|
-
message: `Missing required prop "${path ? `${path}.` : ""}${requiredKey}"`,
|
|
1675
|
-
path: path ? `${path}.${requiredKey}` : requiredKey
|
|
1676
|
-
});
|
|
1677
|
-
for (const [key, propValue] of Object.entries(record)) {
|
|
1678
|
-
const propSchema = properties[key];
|
|
1679
|
-
const propPath = path ? `${path}.${key}` : key;
|
|
1680
|
-
if (propSchema === void 0) {
|
|
1681
|
-
if (schema.additionalProperties === false) errors.push({
|
|
1682
|
-
code: "unexpected-prop",
|
|
1683
|
-
message: `Unexpected prop "${propPath}"`,
|
|
1684
|
-
path: propPath
|
|
1685
|
-
});
|
|
1686
|
-
continue;
|
|
1687
|
-
}
|
|
1688
|
-
_checkValue(propValue, propSchema, propPath, errors);
|
|
1689
|
-
}
|
|
1690
|
-
}
|
|
1691
|
-
};
|
|
1692
|
-
//#endregion
|
|
1693
1368
|
//#region src/message-stream/sanitize.ts
|
|
1694
1369
|
/**
|
|
1695
1370
|
* The protocol has no escaping mechanism by design. Any untrusted text that is
|
|
@@ -1716,6 +1391,7 @@ const utils = {
|
|
|
1716
1391
|
* @param props - Configuration object for the execution
|
|
1717
1392
|
* @param props.client - Botpress Client or Cognitive Client instance for LLM generation
|
|
1718
1393
|
* @param props.instructions - System prompt/instructions for the LLM (static string or dynamic function)
|
|
1394
|
+
* @param props.examples - Optional labeled few-shot examples (static array or dynamic function)
|
|
1719
1395
|
* @param props.chat - Optional Chat instance to enable Chat Mode with user interaction
|
|
1720
1396
|
* @param props.tools - Array of Tool instances available to the agent (static or dynamic)
|
|
1721
1397
|
* @param props.objects - Array of ObjectInstance for namespaced tools and variables (static or dynamic)
|
|
@@ -1774,7 +1450,7 @@ const utils = {
|
|
|
1774
1450
|
* })
|
|
1775
1451
|
*/
|
|
1776
1452
|
const execute = async (props) => {
|
|
1777
|
-
const { executeContext } = await Promise.resolve().then(() => require("./execute-
|
|
1453
|
+
const { executeContext } = await Promise.resolve().then(() => require("./execute-COIHOIKR.cjs"));
|
|
1778
1454
|
return executeContext(props);
|
|
1779
1455
|
};
|
|
1780
1456
|
/**
|
|
@@ -1783,32 +1459,33 @@ const execute = async (props) => {
|
|
|
1783
1459
|
* It's recommended to call this function at the beginning of your application without awaiting it (void init())
|
|
1784
1460
|
*/
|
|
1785
1461
|
const init = async () => {
|
|
1786
|
-
await Promise.resolve().then(() => require("./execute-
|
|
1787
|
-
await Promise.resolve().then(() => require("./component-
|
|
1788
|
-
await Promise.resolve().then(() => require("./tool-
|
|
1789
|
-
await Promise.resolve().then(() => require("./exit-
|
|
1790
|
-
await Promise.resolve().then(() => require("./jsx-
|
|
1791
|
-
await Promise.resolve().then(() => require("./vm-
|
|
1792
|
-
await Promise.resolve().then(() => require("./utils-
|
|
1793
|
-
await Promise.resolve().then(() => require("./truncator-
|
|
1794
|
-
await Promise.resolve().then(() => require("./typings-
|
|
1795
|
-
await Promise.resolve().then(() => require("./dual-modes-
|
|
1462
|
+
await Promise.resolve().then(() => require("./execute-COIHOIKR.cjs"));
|
|
1463
|
+
await Promise.resolve().then(() => require("./component-BXS8vAwO.cjs")).then((n) => n.component_exports);
|
|
1464
|
+
await Promise.resolve().then(() => require("./tool-Dy6AJpJH.cjs")).then((n) => n.tool_exports);
|
|
1465
|
+
await Promise.resolve().then(() => require("./exit-DUM96DN1.cjs")).then((n) => n.exit_exports);
|
|
1466
|
+
await Promise.resolve().then(() => require("./jsx-D5Y2cPo-.cjs")).then((n) => n.jsx_exports);
|
|
1467
|
+
await Promise.resolve().then(() => require("./vm-D6s1zF6M.cjs"));
|
|
1468
|
+
await Promise.resolve().then(() => require("./utils-3ESwP3yg.cjs")).then((n) => n.utils_exports);
|
|
1469
|
+
await Promise.resolve().then(() => require("./truncator-CLkouTCO.cjs")).then((n) => n.truncator_exports);
|
|
1470
|
+
await Promise.resolve().then(() => require("./typings-3lsqCbkn.cjs")).then((n) => n.typings_exports);
|
|
1471
|
+
await Promise.resolve().then(() => require("./dual-modes-Cb7ThvoV.cjs")).then((n) => n.dual_modes_exports);
|
|
1796
1472
|
};
|
|
1797
1473
|
//#endregion
|
|
1798
1474
|
exports.BaseResponse = BaseResponse;
|
|
1799
1475
|
exports.Chat = Chat;
|
|
1800
1476
|
exports.CitationsManager = CitationsManager;
|
|
1801
1477
|
exports.Component = require_component.Component;
|
|
1802
|
-
exports.ComponentRegistry = ComponentRegistry;
|
|
1803
|
-
exports.DefaultComponents = DefaultComponents;
|
|
1478
|
+
exports.ComponentRegistry = require_dual_modes.ComponentRegistry;
|
|
1479
|
+
exports.DefaultComponents = require_dual_modes.DefaultComponents;
|
|
1804
1480
|
exports.DefaultExit = require_custom_client.DefaultExit;
|
|
1805
1481
|
exports.ErrorExecutionResult = require_custom_client.ErrorExecutionResult;
|
|
1482
|
+
exports.Example = require_dual_modes.Example;
|
|
1806
1483
|
exports.ExecutionResult = require_custom_client.ExecutionResult;
|
|
1807
1484
|
exports.Exit = require_exit.Exit;
|
|
1808
1485
|
exports.ListenExit = require_custom_client.ListenExit;
|
|
1809
1486
|
exports.LoopExceededError = require_errors.LoopExceededError;
|
|
1810
|
-
exports.MARKER =
|
|
1811
|
-
exports.NAME_REGEX =
|
|
1487
|
+
exports.MARKER = require_common.MARKER;
|
|
1488
|
+
exports.NAME_REGEX = require_common.NAME_REGEX;
|
|
1812
1489
|
exports.NextResponse = NextResponse;
|
|
1813
1490
|
exports.ObjectInstance = ObjectInstance;
|
|
1814
1491
|
exports.PartialExecutionResult = require_custom_client.PartialExecutionResult;
|
|
@@ -1817,7 +1494,7 @@ exports.RunResponse = RunResponse;
|
|
|
1817
1494
|
exports.SendResponse = SendResponse;
|
|
1818
1495
|
exports.Snapshot = require_custom_client.Snapshot;
|
|
1819
1496
|
exports.SnapshotSignal = require_errors.SnapshotSignal;
|
|
1820
|
-
exports.StreamingMessageParser =
|
|
1497
|
+
exports.StreamingMessageParser = require_common.StreamingMessageParser;
|
|
1821
1498
|
exports.SuccessExecutionResult = require_custom_client.SuccessExecutionResult;
|
|
1822
1499
|
exports.ThinkExit = require_custom_client.ThinkExit;
|
|
1823
1500
|
exports.ThinkSignal = require_errors.ThinkSignal;
|
|
@@ -1840,10 +1517,10 @@ exports.parseExit = require_custom_client.parseExit;
|
|
|
1840
1517
|
exports.parseStream = parseStream;
|
|
1841
1518
|
exports.parseText = parseText;
|
|
1842
1519
|
exports.sanitizeMessageText = sanitizeMessageText;
|
|
1843
|
-
exports.tryParseJson =
|
|
1520
|
+
exports.tryParseJson = require_common.tryParseJson;
|
|
1844
1521
|
exports.utils = utils;
|
|
1845
|
-
exports.validateComponent = validateComponent;
|
|
1846
|
-
exports.validateProps = validateProps;
|
|
1522
|
+
exports.validateComponent = require_dual_modes.validateComponent;
|
|
1523
|
+
exports.validateProps = require_dual_modes.validateProps;
|
|
1847
1524
|
Object.defineProperty(exports, "version", {
|
|
1848
1525
|
enumerable: true,
|
|
1849
1526
|
get: function() {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { version } from '../package.json';
|
|
2
|
+
export { Example, type ExampleDefinition, type ExampleMessage } from './example.js';
|
|
2
3
|
export { Tool } from './tool.js';
|
|
3
4
|
export { Exit, type ExitResult } from './exit.js';
|
|
4
5
|
export { ObjectInstance } from './objects.js';
|
|
@@ -42,6 +43,7 @@ export declare const utils: {
|
|
|
42
43
|
* @param props - Configuration object for the execution
|
|
43
44
|
* @param props.client - Botpress Client or Cognitive Client instance for LLM generation
|
|
44
45
|
* @param props.instructions - System prompt/instructions for the LLM (static string or dynamic function)
|
|
46
|
+
* @param props.examples - Optional labeled few-shot examples (static array or dynamic function)
|
|
45
47
|
* @param props.chat - Optional Chat instance to enable Chat Mode with user interaction
|
|
46
48
|
* @param props.tools - Array of Tool instances available to the agent (static or dynamic)
|
|
47
49
|
* @param props.objects - Array of ObjectInstance for namespaced tools and variables (static or dynamic)
|