llmz 0.7.1 → 0.9.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/README.md +45 -11
- package/dist/{_baseForOwn-buOZDFbK.cjs → _baseForOwn-BfWDTL8L.cjs} +0 -50
- package/dist/chat.d.ts +6 -6
- package/dist/common-BlRFtdf2.js +807 -0
- package/dist/common-BnvrDnIT.cjs +860 -0
- package/dist/compiler-C-OI9sim.cjs +547 -0
- package/dist/compiler-CW1VjQsn.js +473 -0
- package/dist/{component-BwixNVH8.cjs → component-C6Agl2ns.cjs} +3 -3
- package/dist/component.d.ts +4 -4
- package/dist/component.default.d.ts +70 -87
- package/dist/component.default.test.d.ts +1 -0
- package/dist/context.d.ts +14 -8
- package/dist/{custom-client-CMuy7fXU.js → custom-client-ChuZ63zp.js} +128 -30
- package/dist/{custom-client-Bp1TgTKk.cjs → custom-client-DAsGRnYc.cjs} +131 -33
- package/dist/{dual-modes-mNyMThtf.js → dual-modes-DDkoCp3R.js} +1771 -1489
- package/dist/{dual-modes-CfqTk9M8.cjs → dual-modes-DPXiuvNe.cjs} +1767 -1491
- package/dist/example-format.d.ts +8 -0
- package/dist/example.d.ts +45 -0
- package/dist/example.test.d.ts +1 -0
- package/dist/{execute-DP_17lYZ.js → execute-BWcdv9so.js} +77 -85
- package/dist/{execute-msui51b2.cjs → execute-DM2-7y86.cjs} +83 -92
- package/dist/{exit-BGi0Kk0y.cjs → exit-DUM96DN1.cjs} +3 -3
- package/dist/exit-parser.d.ts +2 -0
- package/dist/index.cjs +137 -217
- package/dist/index.d.ts +2 -0
- package/dist/index.js +115 -196
- package/dist/index.workerd.js +16664 -15533
- package/dist/inspect.d.ts +2 -0
- package/dist/{jsx-BWvT6ukg.cjs → jsx-owqxrquU.cjs} +2 -2
- package/dist/message-stream/instructions.d.ts +8 -0
- package/dist/message-stream/parser.d.ts +9 -0
- package/dist/message-stream/response-parser.d.ts +24 -0
- package/dist/message-stream/response-parser.test.d.ts +1 -0
- package/dist/message-stream/types.d.ts +3 -2
- package/dist/prompts/adherence.test.d.ts +1 -0
- package/dist/prompts/catalogue-examples.test.d.ts +1 -0
- package/dist/prompts/chat-mode/protocol.d.ts +2 -0
- package/dist/prompts/chat-mode/system.d.ts +2 -0
- package/dist/prompts/chat-mode/user.d.ts +2 -0
- package/dist/prompts/code-examples.d.ts +2 -0
- package/dist/prompts/code-examples.test.d.ts +1 -0
- package/dist/prompts/common.d.ts +2 -1
- package/dist/prompts/concrete-patterns.test.d.ts +1 -0
- package/dist/prompts/execution-history.d.ts +6 -0
- package/dist/prompts/execution-state.d.ts +3 -0
- package/dist/prompts/long-search.test.d.ts +1 -0
- package/dist/prompts/prompt.d.ts +31 -2
- package/dist/prompts/protocol-basics.d.ts +5 -0
- package/dist/prompts/protocol-simple.test.d.ts +1 -0
- package/dist/prompts/protocol.d.ts +13 -0
- package/dist/prompts/protocol.test.d.ts +1 -0
- package/dist/prompts/sections.test.d.ts +1 -0
- package/dist/prompts/worker-mode/protocol.d.ts +2 -0
- package/dist/prompts/worker-mode/system.d.ts +2 -0
- package/dist/prompts/worker-mode/user.d.ts +2 -0
- package/dist/runtime/citations.test.d.ts +1 -0
- package/dist/runtime/fixtures/long-search.d.ts +19 -0
- package/dist/runtime/fixtures/protocol-languages.d.ts +74 -0
- package/dist/runtime/fixtures/qwen-protocol-failures.d.ts +29 -0
- package/dist/runtime/generate.d.ts +2 -9
- package/dist/runtime/protocol-adherence.test.d.ts +1 -0
- package/dist/runtime/types.d.ts +13 -7
- 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/index.cjs
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_dual_modes = require("./dual-modes-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
2
|
+
const require_dual_modes = require("./dual-modes-DPXiuvNe.cjs");
|
|
3
|
+
const require_common = require("./common-BnvrDnIT.cjs");
|
|
4
|
+
const require_custom_client = require("./custom-client-DAsGRnYc.cjs");
|
|
5
|
+
const require_utils = require("./utils-3ESwP3yg.cjs");
|
|
6
|
+
const require_tool = require("./tool-Dy6AJpJH.cjs");
|
|
6
7
|
const require_errors = require("./errors-C962uJdS.cjs");
|
|
7
|
-
const require_typings = require("./typings-
|
|
8
|
-
const require_exit = require("./exit-
|
|
9
|
-
const require_component = require("./component-
|
|
10
|
-
const require_truncator = require("./truncator-
|
|
8
|
+
const require_typings = require("./typings-3lsqCbkn.cjs");
|
|
9
|
+
const require_exit = require("./exit-DUM96DN1.cjs");
|
|
10
|
+
const require_component = require("./component-C6Agl2ns.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.9.0";
|
|
15
16
|
//#endregion
|
|
16
17
|
//#region src/hoist.ts
|
|
17
18
|
/**
|
|
@@ -798,12 +799,37 @@ const Button = new require_component.Component({
|
|
|
798
799
|
name: "Button",
|
|
799
800
|
aliases: ["btn"],
|
|
800
801
|
generation: {
|
|
801
|
-
usage: "
|
|
802
|
-
examples: [
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
802
|
+
usage: "Offer quick actions or choices after a message. It is common to send several buttons together: write one separate ■send=button block per choice in the SAME response. Each button has its own props and no body. Send all the choices before the final exit; do not wait for a user reply between buttons.",
|
|
803
|
+
examples: [
|
|
804
|
+
{ props: {
|
|
805
|
+
action: "say",
|
|
806
|
+
label: "Track my order"
|
|
807
|
+
} },
|
|
808
|
+
{ props: {
|
|
809
|
+
action: "url",
|
|
810
|
+
label: "View guide",
|
|
811
|
+
url: "https://example.com/guide"
|
|
812
|
+
} },
|
|
813
|
+
{ props: {
|
|
814
|
+
action: "postback",
|
|
815
|
+
label: "Choose Standard",
|
|
816
|
+
value: "plan_standard"
|
|
817
|
+
} },
|
|
818
|
+
[
|
|
819
|
+
{ props: {
|
|
820
|
+
action: "say",
|
|
821
|
+
label: "Track my order"
|
|
822
|
+
} },
|
|
823
|
+
{ props: {
|
|
824
|
+
action: "say",
|
|
825
|
+
label: "Return an item"
|
|
826
|
+
} },
|
|
827
|
+
{ props: {
|
|
828
|
+
action: "say",
|
|
829
|
+
label: "Contact support"
|
|
830
|
+
} }
|
|
831
|
+
]
|
|
832
|
+
]
|
|
807
833
|
},
|
|
808
834
|
leaf: { props: _bpinternal_zui.z.object({
|
|
809
835
|
action: _bpinternal_zui.z.enum([
|
|
@@ -821,10 +847,13 @@ const Image = new require_component.Component({
|
|
|
821
847
|
name: "Image",
|
|
822
848
|
description: "Displays an image from a URL.",
|
|
823
849
|
aliases: [],
|
|
824
|
-
generation: {
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
850
|
+
generation: {
|
|
851
|
+
usage: "Use a known image URL from the user or tool results; never invent an image URL. No body.",
|
|
852
|
+
examples: [{ props: {
|
|
853
|
+
url: "https://example.com/trail.jpg",
|
|
854
|
+
alt: "Forest trail beside a lake"
|
|
855
|
+
} }]
|
|
856
|
+
},
|
|
828
857
|
leaf: { props: _bpinternal_zui.z.object({
|
|
829
858
|
url: _bpinternal_zui.z.string().describe("The URL of the image (must be valid)"),
|
|
830
859
|
alt: _bpinternal_zui.z.string().optional().describe("Alternative text describing the image")
|
|
@@ -875,15 +904,18 @@ const Audio = new require_component.Component({
|
|
|
875
904
|
const Card = new require_component.Component({
|
|
876
905
|
type: "container",
|
|
877
906
|
name: "Card",
|
|
878
|
-
description: "A
|
|
907
|
+
description: "A card with a title, optional subtitle, and Markdown body.",
|
|
879
908
|
aliases: [],
|
|
880
|
-
generation: {
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
909
|
+
generation: {
|
|
910
|
+
usage: "Present one item. The block body is Markdown, not nested component blocks or JSX.",
|
|
911
|
+
examples: [{
|
|
912
|
+
props: {
|
|
913
|
+
title: "Standard plan",
|
|
914
|
+
subtitle: "$20/month"
|
|
915
|
+
},
|
|
916
|
+
body: "Includes 5 projects and email support."
|
|
917
|
+
}]
|
|
918
|
+
},
|
|
887
919
|
container: {
|
|
888
920
|
props: _bpinternal_zui.z.object({
|
|
889
921
|
title: _bpinternal_zui.z.string().min(1).max(250).describe("Title text (1–250 characters)"),
|
|
@@ -898,6 +930,23 @@ const Card = new require_component.Component({
|
|
|
898
930
|
}]
|
|
899
931
|
}
|
|
900
932
|
});
|
|
933
|
+
const carouselProps = _bpinternal_zui.z.object({ cards: _bpinternal_zui.z.array(Card.definition.container.props.extend({
|
|
934
|
+
body: _bpinternal_zui.z.string().optional().describe("Markdown text for this card"),
|
|
935
|
+
image: Image.definition.leaf.props.optional().describe("Optional image for this card; use a known URL"),
|
|
936
|
+
buttons: _bpinternal_zui.z.array(Button.definition.leaf.props).max(5).optional().describe("Up to 5 actions for this card")
|
|
937
|
+
})).min(1).max(10).describe("1–10 cards, in display order. Each card has its own title, optional subtitle, body, image, and buttons") });
|
|
938
|
+
var CarouselComponent = class extends require_component.Component {
|
|
939
|
+
render(props, children = []) {
|
|
940
|
+
if (!("cards" in props) && children.length && children.every((child) => require_component.isComponent(child, Card))) return super.render(props, children);
|
|
941
|
+
const { cards } = carouselProps.parse(props);
|
|
942
|
+
const renderedCards = cards.map(({ body, image, buttons, ...cardProps }) => Card.render(cardProps, [
|
|
943
|
+
...body ? [body] : [],
|
|
944
|
+
...image ? [Image.render(image)] : [],
|
|
945
|
+
...(buttons ?? []).map((button) => Button.render(button))
|
|
946
|
+
]));
|
|
947
|
+
return super.render({}, renderedCards);
|
|
948
|
+
}
|
|
949
|
+
};
|
|
901
950
|
const DefaultComponents = {
|
|
902
951
|
Button,
|
|
903
952
|
Image,
|
|
@@ -905,13 +954,44 @@ const DefaultComponents = {
|
|
|
905
954
|
Video,
|
|
906
955
|
Audio,
|
|
907
956
|
Card,
|
|
908
|
-
Carousel: new
|
|
957
|
+
Carousel: new CarouselComponent({
|
|
909
958
|
type: "container",
|
|
910
959
|
name: "Carousel",
|
|
911
|
-
description: "
|
|
960
|
+
description: "Displays a horizontally scrollable collection of cards, each with its own content and actions.",
|
|
912
961
|
aliases: [],
|
|
962
|
+
body: false,
|
|
963
|
+
generation: {
|
|
964
|
+
usage: "Use for several comparable items. Put ALL cards in the cards array of ONE send block. Each card can include title, subtitle, body, image {url, alt?}, and buttons [{action, label, value?, url?}]. Do not write a Markdown list or separate Card blocks; those do not form a carousel.",
|
|
965
|
+
examples: [{ props: { cards: [{
|
|
966
|
+
title: "Standard plan",
|
|
967
|
+
subtitle: "$20/month",
|
|
968
|
+
body: "5 projects and email support.",
|
|
969
|
+
image: {
|
|
970
|
+
url: "https://example.com/standard.jpg",
|
|
971
|
+
alt: "Standard plan"
|
|
972
|
+
},
|
|
973
|
+
buttons: [{
|
|
974
|
+
action: "postback",
|
|
975
|
+
label: "Choose Standard",
|
|
976
|
+
value: "plan_standard"
|
|
977
|
+
}]
|
|
978
|
+
}, {
|
|
979
|
+
title: "Team plan",
|
|
980
|
+
subtitle: "$50/month",
|
|
981
|
+
body: "20 projects and priority support.",
|
|
982
|
+
image: {
|
|
983
|
+
url: "https://example.com/team.jpg",
|
|
984
|
+
alt: "Team plan"
|
|
985
|
+
},
|
|
986
|
+
buttons: [{
|
|
987
|
+
action: "postback",
|
|
988
|
+
label: "Choose Team",
|
|
989
|
+
value: "plan_team"
|
|
990
|
+
}]
|
|
991
|
+
}] } }]
|
|
992
|
+
},
|
|
913
993
|
container: {
|
|
914
|
-
props:
|
|
994
|
+
props: carouselProps,
|
|
915
995
|
children: [{
|
|
916
996
|
description: "Card component (required, 1–10 allowed)",
|
|
917
997
|
component: Card.definition
|
|
@@ -923,16 +1003,13 @@ const DefaultComponents = {
|
|
|
923
1003
|
name: "Message",
|
|
924
1004
|
aliases: ["Text", "Markdown"],
|
|
925
1005
|
description: "A Markdown-formatted text message. Long answers are written the same way: plain Markdown prose.",
|
|
926
|
-
generation: { examples: [{ body: `
|
|
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.
|
|
1006
|
+
generation: { examples: [{ body: `To reset your password:
|
|
929
1007
|
|
|
930
|
-
|
|
1008
|
+
1. Open the sign-in page and select **Forgot password?**
|
|
1009
|
+
2. Enter the email address you use for your account.
|
|
1010
|
+
3. Open the reset link in your email and choose a new password.
|
|
931
1011
|
|
|
932
|
-
|
|
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!" }] },
|
|
1012
|
+
If the email does not arrive, check your spam folder. If you sign in through your organization, use its password reset process.` }, { body: "How do you currently manage board meetings?" }] },
|
|
936
1013
|
default: {
|
|
937
1014
|
props: _bpinternal_zui.z.object({}),
|
|
938
1015
|
children: []
|
|
@@ -1461,7 +1538,7 @@ function parseText(text, options) {
|
|
|
1461
1538
|
})(), options);
|
|
1462
1539
|
}
|
|
1463
1540
|
async function* parseResponses(stream, options) {
|
|
1464
|
-
const pump = new EventPump(stream, new
|
|
1541
|
+
const pump = new EventPump(stream, new require_common.StreamingMessageParser(options));
|
|
1465
1542
|
let activeBody;
|
|
1466
1543
|
while (true) {
|
|
1467
1544
|
if (activeBody) {
|
|
@@ -1498,34 +1575,6 @@ async function* bodyStream(pump, itemId) {
|
|
|
1498
1575
|
}
|
|
1499
1576
|
}
|
|
1500
1577
|
//#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
1578
|
//#region src/message-stream/normalizer.ts
|
|
1530
1579
|
const EMPTY_PROPS_SCHEMA = {
|
|
1531
1580
|
type: "object",
|
|
@@ -1535,7 +1584,7 @@ const EMPTY_PROPS_SCHEMA = {
|
|
|
1535
1584
|
const normalizeComponentName = (name) => name.trim().toLowerCase();
|
|
1536
1585
|
function normalizeComponentDefinition(definition) {
|
|
1537
1586
|
const name = normalizeComponentName(definition.name ?? "");
|
|
1538
|
-
if (!
|
|
1587
|
+
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
1588
|
return {
|
|
1540
1589
|
name,
|
|
1541
1590
|
description: definition.description,
|
|
@@ -1559,137 +1608,6 @@ function normalizePropsSchema(props, name) {
|
|
|
1559
1608
|
throw new Error(`Invalid props schema for "${name}". Expected a ZUI/Zod object schema or a JSON schema, but got type "${typeof props}".`);
|
|
1560
1609
|
}
|
|
1561
1610
|
//#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
1611
|
//#region src/message-stream/sanitize.ts
|
|
1694
1612
|
/**
|
|
1695
1613
|
* The protocol has no escaping mechanism by design. Any untrusted text that is
|
|
@@ -1716,6 +1634,7 @@ const utils = {
|
|
|
1716
1634
|
* @param props - Configuration object for the execution
|
|
1717
1635
|
* @param props.client - Botpress Client or Cognitive Client instance for LLM generation
|
|
1718
1636
|
* @param props.instructions - System prompt/instructions for the LLM (static string or dynamic function)
|
|
1637
|
+
* @param props.examples - Optional labeled few-shot examples (static array or dynamic function)
|
|
1719
1638
|
* @param props.chat - Optional Chat instance to enable Chat Mode with user interaction
|
|
1720
1639
|
* @param props.tools - Array of Tool instances available to the agent (static or dynamic)
|
|
1721
1640
|
* @param props.objects - Array of ObjectInstance for namespaced tools and variables (static or dynamic)
|
|
@@ -1774,7 +1693,7 @@ const utils = {
|
|
|
1774
1693
|
* })
|
|
1775
1694
|
*/
|
|
1776
1695
|
const execute = async (props) => {
|
|
1777
|
-
const { executeContext } = await Promise.resolve().then(() => require("./execute-
|
|
1696
|
+
const { executeContext } = await Promise.resolve().then(() => require("./execute-DM2-7y86.cjs"));
|
|
1778
1697
|
return executeContext(props);
|
|
1779
1698
|
};
|
|
1780
1699
|
/**
|
|
@@ -1783,32 +1702,33 @@ const execute = async (props) => {
|
|
|
1783
1702
|
* It's recommended to call this function at the beginning of your application without awaiting it (void init())
|
|
1784
1703
|
*/
|
|
1785
1704
|
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-
|
|
1705
|
+
await Promise.resolve().then(() => require("./execute-DM2-7y86.cjs"));
|
|
1706
|
+
await Promise.resolve().then(() => require("./component-C6Agl2ns.cjs")).then((n) => n.component_exports);
|
|
1707
|
+
await Promise.resolve().then(() => require("./tool-Dy6AJpJH.cjs")).then((n) => n.tool_exports);
|
|
1708
|
+
await Promise.resolve().then(() => require("./exit-DUM96DN1.cjs")).then((n) => n.exit_exports);
|
|
1709
|
+
await Promise.resolve().then(() => require("./jsx-owqxrquU.cjs")).then((n) => n.jsx_exports);
|
|
1710
|
+
await Promise.resolve().then(() => require("./vm-D6s1zF6M.cjs"));
|
|
1711
|
+
await Promise.resolve().then(() => require("./utils-3ESwP3yg.cjs")).then((n) => n.utils_exports);
|
|
1712
|
+
await Promise.resolve().then(() => require("./truncator-CLkouTCO.cjs")).then((n) => n.truncator_exports);
|
|
1713
|
+
await Promise.resolve().then(() => require("./typings-3lsqCbkn.cjs")).then((n) => n.typings_exports);
|
|
1714
|
+
await Promise.resolve().then(() => require("./dual-modes-DPXiuvNe.cjs")).then((n) => n.dual_modes_exports);
|
|
1796
1715
|
};
|
|
1797
1716
|
//#endregion
|
|
1798
1717
|
exports.BaseResponse = BaseResponse;
|
|
1799
1718
|
exports.Chat = Chat;
|
|
1800
1719
|
exports.CitationsManager = CitationsManager;
|
|
1801
1720
|
exports.Component = require_component.Component;
|
|
1802
|
-
exports.ComponentRegistry = ComponentRegistry;
|
|
1721
|
+
exports.ComponentRegistry = require_dual_modes.ComponentRegistry;
|
|
1803
1722
|
exports.DefaultComponents = DefaultComponents;
|
|
1804
1723
|
exports.DefaultExit = require_custom_client.DefaultExit;
|
|
1805
1724
|
exports.ErrorExecutionResult = require_custom_client.ErrorExecutionResult;
|
|
1725
|
+
exports.Example = require_dual_modes.Example;
|
|
1806
1726
|
exports.ExecutionResult = require_custom_client.ExecutionResult;
|
|
1807
1727
|
exports.Exit = require_exit.Exit;
|
|
1808
1728
|
exports.ListenExit = require_custom_client.ListenExit;
|
|
1809
1729
|
exports.LoopExceededError = require_errors.LoopExceededError;
|
|
1810
|
-
exports.MARKER =
|
|
1811
|
-
exports.NAME_REGEX =
|
|
1730
|
+
exports.MARKER = require_common.MARKER;
|
|
1731
|
+
exports.NAME_REGEX = require_common.NAME_REGEX;
|
|
1812
1732
|
exports.NextResponse = NextResponse;
|
|
1813
1733
|
exports.ObjectInstance = ObjectInstance;
|
|
1814
1734
|
exports.PartialExecutionResult = require_custom_client.PartialExecutionResult;
|
|
@@ -1817,7 +1737,7 @@ exports.RunResponse = RunResponse;
|
|
|
1817
1737
|
exports.SendResponse = SendResponse;
|
|
1818
1738
|
exports.Snapshot = require_custom_client.Snapshot;
|
|
1819
1739
|
exports.SnapshotSignal = require_errors.SnapshotSignal;
|
|
1820
|
-
exports.StreamingMessageParser =
|
|
1740
|
+
exports.StreamingMessageParser = require_common.StreamingMessageParser;
|
|
1821
1741
|
exports.SuccessExecutionResult = require_custom_client.SuccessExecutionResult;
|
|
1822
1742
|
exports.ThinkExit = require_custom_client.ThinkExit;
|
|
1823
1743
|
exports.ThinkSignal = require_errors.ThinkSignal;
|
|
@@ -1840,10 +1760,10 @@ exports.parseExit = require_custom_client.parseExit;
|
|
|
1840
1760
|
exports.parseStream = parseStream;
|
|
1841
1761
|
exports.parseText = parseText;
|
|
1842
1762
|
exports.sanitizeMessageText = sanitizeMessageText;
|
|
1843
|
-
exports.tryParseJson =
|
|
1763
|
+
exports.tryParseJson = require_common.tryParseJson;
|
|
1844
1764
|
exports.utils = utils;
|
|
1845
|
-
exports.validateComponent = validateComponent;
|
|
1846
|
-
exports.validateProps = validateProps;
|
|
1765
|
+
exports.validateComponent = require_dual_modes.validateComponent;
|
|
1766
|
+
exports.validateProps = require_dual_modes.validateProps;
|
|
1847
1767
|
Object.defineProperty(exports, "version", {
|
|
1848
1768
|
enumerable: true,
|
|
1849
1769
|
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)
|