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.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { d as generateInstructions, f as validateComponent, m as ComponentRegistry, p as validateProps, u as Example } from "./dual-modes-DDkoCp3R.js";
|
|
2
|
+
import { c as MARKER, l as NAME_REGEX, o as StreamingMessageParser, s as tryParseJson } from "./common-BlRFtdf2.js";
|
|
3
|
+
import { a as ThinkExit, c as ExecutionResult, d as Snapshot, f as parseExit, i as ListenExit, l as PartialExecutionResult, o as getValue, r as DefaultExit, s as ErrorExecutionResult, t as _CustomModelClient, u as SuccessExecutionResult } from "./custom-client-ChuZ63zp.js";
|
|
3
4
|
import { a as getMultilineComment, c as isJsonSchema, l as isValidIdentifier, m as toValidObjectName, n as escapeString, p as toValidFunctionName, t as configureTokenizer, u as isZuiSchema, v as upperFirst } from "./utils-UBeAFeEI.js";
|
|
4
5
|
import { t as Tool } from "./tool-Bv8N4IPj.js";
|
|
5
6
|
import { c as SnapshotSignal, l as ThinkSignal, o as LoopExceededError, r as CodeFormattingError } from "./errors-Cg1G0Awu.js";
|
|
@@ -10,7 +11,7 @@ import { i as wrapContent, n as truncateWrappedContent, t as stripTruncationTags
|
|
|
10
11
|
import { t as configureQuickJS } from "./quickjs-variant-BYhMBpwU.js";
|
|
11
12
|
import { transforms, z } from "@bpinternal/zui";
|
|
12
13
|
//#region package.json
|
|
13
|
-
var version = "0.
|
|
14
|
+
var version = "0.9.0";
|
|
14
15
|
//#endregion
|
|
15
16
|
//#region src/hoist.ts
|
|
16
17
|
/**
|
|
@@ -797,12 +798,37 @@ const Button = new Component({
|
|
|
797
798
|
name: "Button",
|
|
798
799
|
aliases: ["btn"],
|
|
799
800
|
generation: {
|
|
800
|
-
usage: "
|
|
801
|
-
examples: [
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
801
|
+
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.",
|
|
802
|
+
examples: [
|
|
803
|
+
{ props: {
|
|
804
|
+
action: "say",
|
|
805
|
+
label: "Track my order"
|
|
806
|
+
} },
|
|
807
|
+
{ props: {
|
|
808
|
+
action: "url",
|
|
809
|
+
label: "View guide",
|
|
810
|
+
url: "https://example.com/guide"
|
|
811
|
+
} },
|
|
812
|
+
{ props: {
|
|
813
|
+
action: "postback",
|
|
814
|
+
label: "Choose Standard",
|
|
815
|
+
value: "plan_standard"
|
|
816
|
+
} },
|
|
817
|
+
[
|
|
818
|
+
{ props: {
|
|
819
|
+
action: "say",
|
|
820
|
+
label: "Track my order"
|
|
821
|
+
} },
|
|
822
|
+
{ props: {
|
|
823
|
+
action: "say",
|
|
824
|
+
label: "Return an item"
|
|
825
|
+
} },
|
|
826
|
+
{ props: {
|
|
827
|
+
action: "say",
|
|
828
|
+
label: "Contact support"
|
|
829
|
+
} }
|
|
830
|
+
]
|
|
831
|
+
]
|
|
806
832
|
},
|
|
807
833
|
leaf: { props: z.object({
|
|
808
834
|
action: z.enum([
|
|
@@ -820,10 +846,13 @@ const Image = new Component({
|
|
|
820
846
|
name: "Image",
|
|
821
847
|
description: "Displays an image from a URL.",
|
|
822
848
|
aliases: [],
|
|
823
|
-
generation: {
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
849
|
+
generation: {
|
|
850
|
+
usage: "Use a known image URL from the user or tool results; never invent an image URL. No body.",
|
|
851
|
+
examples: [{ props: {
|
|
852
|
+
url: "https://example.com/trail.jpg",
|
|
853
|
+
alt: "Forest trail beside a lake"
|
|
854
|
+
} }]
|
|
855
|
+
},
|
|
827
856
|
leaf: { props: z.object({
|
|
828
857
|
url: z.string().describe("The URL of the image (must be valid)"),
|
|
829
858
|
alt: z.string().optional().describe("Alternative text describing the image")
|
|
@@ -874,15 +903,18 @@ const Audio = new Component({
|
|
|
874
903
|
const Card = new Component({
|
|
875
904
|
type: "container",
|
|
876
905
|
name: "Card",
|
|
877
|
-
description: "A
|
|
906
|
+
description: "A card with a title, optional subtitle, and Markdown body.",
|
|
878
907
|
aliases: [],
|
|
879
|
-
generation: {
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
908
|
+
generation: {
|
|
909
|
+
usage: "Present one item. The block body is Markdown, not nested component blocks or JSX.",
|
|
910
|
+
examples: [{
|
|
911
|
+
props: {
|
|
912
|
+
title: "Standard plan",
|
|
913
|
+
subtitle: "$20/month"
|
|
914
|
+
},
|
|
915
|
+
body: "Includes 5 projects and email support."
|
|
916
|
+
}]
|
|
917
|
+
},
|
|
886
918
|
container: {
|
|
887
919
|
props: z.object({
|
|
888
920
|
title: z.string().min(1).max(250).describe("Title text (1–250 characters)"),
|
|
@@ -897,6 +929,23 @@ const Card = new Component({
|
|
|
897
929
|
}]
|
|
898
930
|
}
|
|
899
931
|
});
|
|
932
|
+
const carouselProps = z.object({ cards: z.array(Card.definition.container.props.extend({
|
|
933
|
+
body: z.string().optional().describe("Markdown text for this card"),
|
|
934
|
+
image: Image.definition.leaf.props.optional().describe("Optional image for this card; use a known URL"),
|
|
935
|
+
buttons: z.array(Button.definition.leaf.props).max(5).optional().describe("Up to 5 actions for this card")
|
|
936
|
+
})).min(1).max(10).describe("1–10 cards, in display order. Each card has its own title, optional subtitle, body, image, and buttons") });
|
|
937
|
+
var CarouselComponent = class extends Component {
|
|
938
|
+
render(props, children = []) {
|
|
939
|
+
if (!("cards" in props) && children.length && children.every((child) => isComponent(child, Card))) return super.render(props, children);
|
|
940
|
+
const { cards } = carouselProps.parse(props);
|
|
941
|
+
const renderedCards = cards.map(({ body, image, buttons, ...cardProps }) => Card.render(cardProps, [
|
|
942
|
+
...body ? [body] : [],
|
|
943
|
+
...image ? [Image.render(image)] : [],
|
|
944
|
+
...(buttons ?? []).map((button) => Button.render(button))
|
|
945
|
+
]));
|
|
946
|
+
return super.render({}, renderedCards);
|
|
947
|
+
}
|
|
948
|
+
};
|
|
900
949
|
const DefaultComponents = {
|
|
901
950
|
Button,
|
|
902
951
|
Image,
|
|
@@ -904,13 +953,44 @@ const DefaultComponents = {
|
|
|
904
953
|
Video,
|
|
905
954
|
Audio,
|
|
906
955
|
Card,
|
|
907
|
-
Carousel: new
|
|
956
|
+
Carousel: new CarouselComponent({
|
|
908
957
|
type: "container",
|
|
909
958
|
name: "Carousel",
|
|
910
|
-
description: "
|
|
959
|
+
description: "Displays a horizontally scrollable collection of cards, each with its own content and actions.",
|
|
911
960
|
aliases: [],
|
|
961
|
+
body: false,
|
|
962
|
+
generation: {
|
|
963
|
+
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.",
|
|
964
|
+
examples: [{ props: { cards: [{
|
|
965
|
+
title: "Standard plan",
|
|
966
|
+
subtitle: "$20/month",
|
|
967
|
+
body: "5 projects and email support.",
|
|
968
|
+
image: {
|
|
969
|
+
url: "https://example.com/standard.jpg",
|
|
970
|
+
alt: "Standard plan"
|
|
971
|
+
},
|
|
972
|
+
buttons: [{
|
|
973
|
+
action: "postback",
|
|
974
|
+
label: "Choose Standard",
|
|
975
|
+
value: "plan_standard"
|
|
976
|
+
}]
|
|
977
|
+
}, {
|
|
978
|
+
title: "Team plan",
|
|
979
|
+
subtitle: "$50/month",
|
|
980
|
+
body: "20 projects and priority support.",
|
|
981
|
+
image: {
|
|
982
|
+
url: "https://example.com/team.jpg",
|
|
983
|
+
alt: "Team plan"
|
|
984
|
+
},
|
|
985
|
+
buttons: [{
|
|
986
|
+
action: "postback",
|
|
987
|
+
label: "Choose Team",
|
|
988
|
+
value: "plan_team"
|
|
989
|
+
}]
|
|
990
|
+
}] } }]
|
|
991
|
+
},
|
|
912
992
|
container: {
|
|
913
|
-
props:
|
|
993
|
+
props: carouselProps,
|
|
914
994
|
children: [{
|
|
915
995
|
description: "Card component (required, 1–10 allowed)",
|
|
916
996
|
component: Card.definition
|
|
@@ -922,16 +1002,13 @@ const DefaultComponents = {
|
|
|
922
1002
|
name: "Message",
|
|
923
1003
|
aliases: ["Text", "Markdown"],
|
|
924
1004
|
description: "A Markdown-formatted text message. Long answers are written the same way: plain Markdown prose.",
|
|
925
|
-
generation: { examples: [{ body: `
|
|
926
|
-
|
|
927
|
-
First, connect your repository from the dashboard — we support GitHub and GitLab. Once connected, every push to your main branch triggers a build automatically.
|
|
1005
|
+
generation: { examples: [{ body: `To reset your password:
|
|
928
1006
|
|
|
929
|
-
|
|
1007
|
+
1. Open the sign-in page and select **Forgot password?**
|
|
1008
|
+
2. Enter the email address you use for your account.
|
|
1009
|
+
3. Open the reset link in your email and choose a new password.
|
|
930
1010
|
|
|
931
|
-
|
|
932
|
-
- **Output directory** — where the compiled assets end up
|
|
933
|
-
|
|
934
|
-
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!" }] },
|
|
1011
|
+
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?" }] },
|
|
935
1012
|
default: {
|
|
936
1013
|
props: z.object({}),
|
|
937
1014
|
children: []
|
|
@@ -1497,34 +1574,6 @@ async function* bodyStream(pump, itemId) {
|
|
|
1497
1574
|
}
|
|
1498
1575
|
}
|
|
1499
1576
|
//#endregion
|
|
1500
|
-
//#region src/message-stream/registry.ts
|
|
1501
|
-
/**
|
|
1502
|
-
* Stores normalized component definitions. The registry (not the parser) is the
|
|
1503
|
-
* single source of truth for which components exist and how they are validated.
|
|
1504
|
-
*/
|
|
1505
|
-
var ComponentRegistry = class {
|
|
1506
|
-
_definitions = /* @__PURE__ */ new Map();
|
|
1507
|
-
constructor(definitions = []) {
|
|
1508
|
-
for (const definition of definitions) this.register(definition);
|
|
1509
|
-
}
|
|
1510
|
-
register(definition) {
|
|
1511
|
-
if (!NAME_REGEX.test(definition.name)) throw new Error(`Invalid component name "${definition.name}". Component names must be lowercase ([a-z][a-z0-9_-]*).`);
|
|
1512
|
-
this._definitions.set(definition.name, definition);
|
|
1513
|
-
}
|
|
1514
|
-
unregister(name) {
|
|
1515
|
-
this._definitions.delete(name);
|
|
1516
|
-
}
|
|
1517
|
-
has(name) {
|
|
1518
|
-
return this._definitions.has(name);
|
|
1519
|
-
}
|
|
1520
|
-
get(name) {
|
|
1521
|
-
return this._definitions.get(name);
|
|
1522
|
-
}
|
|
1523
|
-
list() {
|
|
1524
|
-
return [...this._definitions.values()];
|
|
1525
|
-
}
|
|
1526
|
-
};
|
|
1527
|
-
//#endregion
|
|
1528
1577
|
//#region src/message-stream/normalizer.ts
|
|
1529
1578
|
const EMPTY_PROPS_SCHEMA = {
|
|
1530
1579
|
type: "object",
|
|
@@ -1558,137 +1607,6 @@ function normalizePropsSchema(props, name) {
|
|
|
1558
1607
|
throw new Error(`Invalid props schema for "${name}". Expected a ZUI/Zod object schema or a JSON schema, but got type "${typeof props}".`);
|
|
1559
1608
|
}
|
|
1560
1609
|
//#endregion
|
|
1561
|
-
//#region src/message-stream/validator.ts
|
|
1562
|
-
/**
|
|
1563
|
-
* Validates a syntactically parsed `■send` item against the registered
|
|
1564
|
-
* component definitions. Validation is intentionally separate from parsing: a
|
|
1565
|
-
* validation failure never stops the stream, it only produces errors the caller
|
|
1566
|
-
* can turn into diagnostics or fallback rendering.
|
|
1567
|
-
*/
|
|
1568
|
-
function validateComponent(item, registry) {
|
|
1569
|
-
const definition = registry.get(item.name);
|
|
1570
|
-
if (!definition) {
|
|
1571
|
-
const registered = registry.list().map((d) => d.name).join(", ") || "(none)";
|
|
1572
|
-
return {
|
|
1573
|
-
valid: false,
|
|
1574
|
-
props: item.props,
|
|
1575
|
-
errors: [{
|
|
1576
|
-
code: "unknown-component",
|
|
1577
|
-
message: `Unknown component "${item.name}". Registered components: ${registered}`
|
|
1578
|
-
}]
|
|
1579
|
-
};
|
|
1580
|
-
}
|
|
1581
|
-
const errors = [..._validateProps(item.props, definition), ..._validateBody(item, definition)];
|
|
1582
|
-
return {
|
|
1583
|
-
valid: errors.length === 0,
|
|
1584
|
-
props: item.props,
|
|
1585
|
-
errors
|
|
1586
|
-
};
|
|
1587
|
-
}
|
|
1588
|
-
/** Validates a props object against a JSON schema (also used for `■next` exit props). */
|
|
1589
|
-
function validateProps(props, schema) {
|
|
1590
|
-
const errors = [];
|
|
1591
|
-
_checkValue(props, schema, "", errors);
|
|
1592
|
-
return errors;
|
|
1593
|
-
}
|
|
1594
|
-
const _validateProps = (props, definition) => validateProps(props, definition.propsJsonSchema);
|
|
1595
|
-
const _validateBody = (item, definition) => {
|
|
1596
|
-
var _definition$body;
|
|
1597
|
-
const hasBody = typeof item.body === "string" && item.body.length > 0;
|
|
1598
|
-
if (hasBody && !definition.body) return [{
|
|
1599
|
-
code: "body-not-allowed",
|
|
1600
|
-
message: `Component "${definition.name}" does not support a body`
|
|
1601
|
-
}];
|
|
1602
|
-
if (!hasBody && ((_definition$body = definition.body) === null || _definition$body === void 0 ? void 0 : _definition$body.required)) return [{
|
|
1603
|
-
code: "missing-required-body",
|
|
1604
|
-
message: `Component "${definition.name}" requires a body`
|
|
1605
|
-
}];
|
|
1606
|
-
return [];
|
|
1607
|
-
};
|
|
1608
|
-
const _typeOf = (value) => {
|
|
1609
|
-
if (value === null) return "null";
|
|
1610
|
-
if (Array.isArray(value)) return "array";
|
|
1611
|
-
return typeof value;
|
|
1612
|
-
};
|
|
1613
|
-
const _matchesType = (value, type) => {
|
|
1614
|
-
switch (type) {
|
|
1615
|
-
case "string": return typeof value === "string";
|
|
1616
|
-
case "number": return typeof value === "number";
|
|
1617
|
-
case "integer": return typeof value === "number" && Number.isInteger(value);
|
|
1618
|
-
case "boolean": return typeof value === "boolean";
|
|
1619
|
-
case "null": return value === null;
|
|
1620
|
-
case "array": return Array.isArray(value);
|
|
1621
|
-
case "object": return !!value && typeof value === "object" && !Array.isArray(value);
|
|
1622
|
-
default: return true;
|
|
1623
|
-
}
|
|
1624
|
-
};
|
|
1625
|
-
const _isEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
1626
|
-
/**
|
|
1627
|
-
* Minimal JSON-schema subset checker covering what component schemas need:
|
|
1628
|
-
* type, enum, const, required, properties, additionalProperties, items, anyOf/oneOf.
|
|
1629
|
-
* Unknown keywords are ignored (lenient by design).
|
|
1630
|
-
*/
|
|
1631
|
-
const _checkValue = (value, schema, path, errors) => {
|
|
1632
|
-
if (schema === void 0 || typeof schema === "boolean" || typeof schema !== "object") return;
|
|
1633
|
-
const label = path || "props";
|
|
1634
|
-
const propError = (message) => {
|
|
1635
|
-
errors.push({
|
|
1636
|
-
code: "invalid-prop-value",
|
|
1637
|
-
message,
|
|
1638
|
-
path: path || void 0
|
|
1639
|
-
});
|
|
1640
|
-
};
|
|
1641
|
-
if (schema.const !== void 0 && !_isEqual(value, schema.const)) {
|
|
1642
|
-
propError(`Expected "${label}" to equal ${JSON.stringify(schema.const)}`);
|
|
1643
|
-
return;
|
|
1644
|
-
}
|
|
1645
|
-
if (schema.enum && !schema.enum.some((allowed) => _isEqual(value, allowed))) {
|
|
1646
|
-
propError(`Expected "${label}" to be one of: ${schema.enum.map((v) => JSON.stringify(v)).join(", ")}`);
|
|
1647
|
-
return;
|
|
1648
|
-
}
|
|
1649
|
-
const variants = schema.anyOf ?? schema.oneOf;
|
|
1650
|
-
if (variants === null || variants === void 0 ? void 0 : variants.length) {
|
|
1651
|
-
if (!variants.some((variant) => {
|
|
1652
|
-
const variantErrors = [];
|
|
1653
|
-
_checkValue(value, variant, path, variantErrors);
|
|
1654
|
-
return variantErrors.length === 0;
|
|
1655
|
-
})) {
|
|
1656
|
-
propError(`Value of "${label}" does not match any of the allowed types`);
|
|
1657
|
-
return;
|
|
1658
|
-
}
|
|
1659
|
-
}
|
|
1660
|
-
if (schema.type) {
|
|
1661
|
-
const types = Array.isArray(schema.type) ? schema.type : [schema.type];
|
|
1662
|
-
if (!types.some((type) => _matchesType(value, type))) {
|
|
1663
|
-
propError(`Expected "${label}" to be of type ${types.join(" | ")}, but got ${_typeOf(value)}`);
|
|
1664
|
-
return;
|
|
1665
|
-
}
|
|
1666
|
-
}
|
|
1667
|
-
if (Array.isArray(value) && schema.items && !Array.isArray(schema.items)) value.forEach((item, index) => _checkValue(item, schema.items, `${label}[${index}]`, errors));
|
|
1668
|
-
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
1669
|
-
const record = value;
|
|
1670
|
-
const properties = schema.properties ?? {};
|
|
1671
|
-
for (const requiredKey of schema.required ?? []) if (record[requiredKey] === void 0) errors.push({
|
|
1672
|
-
code: "missing-required-prop",
|
|
1673
|
-
message: `Missing required prop "${path ? `${path}.` : ""}${requiredKey}"`,
|
|
1674
|
-
path: path ? `${path}.${requiredKey}` : requiredKey
|
|
1675
|
-
});
|
|
1676
|
-
for (const [key, propValue] of Object.entries(record)) {
|
|
1677
|
-
const propSchema = properties[key];
|
|
1678
|
-
const propPath = path ? `${path}.${key}` : key;
|
|
1679
|
-
if (propSchema === void 0) {
|
|
1680
|
-
if (schema.additionalProperties === false) errors.push({
|
|
1681
|
-
code: "unexpected-prop",
|
|
1682
|
-
message: `Unexpected prop "${propPath}"`,
|
|
1683
|
-
path: propPath
|
|
1684
|
-
});
|
|
1685
|
-
continue;
|
|
1686
|
-
}
|
|
1687
|
-
_checkValue(propValue, propSchema, propPath, errors);
|
|
1688
|
-
}
|
|
1689
|
-
}
|
|
1690
|
-
};
|
|
1691
|
-
//#endregion
|
|
1692
1610
|
//#region src/message-stream/sanitize.ts
|
|
1693
1611
|
/**
|
|
1694
1612
|
* The protocol has no escaping mechanism by design. Any untrusted text that is
|
|
@@ -1715,6 +1633,7 @@ const utils = {
|
|
|
1715
1633
|
* @param props - Configuration object for the execution
|
|
1716
1634
|
* @param props.client - Botpress Client or Cognitive Client instance for LLM generation
|
|
1717
1635
|
* @param props.instructions - System prompt/instructions for the LLM (static string or dynamic function)
|
|
1636
|
+
* @param props.examples - Optional labeled few-shot examples (static array or dynamic function)
|
|
1718
1637
|
* @param props.chat - Optional Chat instance to enable Chat Mode with user interaction
|
|
1719
1638
|
* @param props.tools - Array of Tool instances available to the agent (static or dynamic)
|
|
1720
1639
|
* @param props.objects - Array of ObjectInstance for namespaced tools and variables (static or dynamic)
|
|
@@ -1773,7 +1692,7 @@ const utils = {
|
|
|
1773
1692
|
* })
|
|
1774
1693
|
*/
|
|
1775
1694
|
const execute = async (props) => {
|
|
1776
|
-
const { executeContext } = await import("./execute-
|
|
1695
|
+
const { executeContext } = await import("./execute-BWcdv9so.js");
|
|
1777
1696
|
return executeContext(props);
|
|
1778
1697
|
};
|
|
1779
1698
|
/**
|
|
@@ -1782,16 +1701,16 @@ const execute = async (props) => {
|
|
|
1782
1701
|
* It's recommended to call this function at the beginning of your application without awaiting it (void init())
|
|
1783
1702
|
*/
|
|
1784
1703
|
const init = async () => {
|
|
1785
|
-
await import("./execute-
|
|
1704
|
+
await import("./execute-BWcdv9so.js");
|
|
1786
1705
|
await import("./component-DGG7d_Mz.js").then((n) => n.r);
|
|
1787
1706
|
await import("./tool-Bv8N4IPj.js").then((n) => n.n);
|
|
1788
1707
|
await import("./exit-CDdxDBRT.js").then((n) => n.n);
|
|
1789
1708
|
await import("./jsx-CIgdGGVs.js").then((n) => n.i);
|
|
1790
|
-
await import("./vm-
|
|
1709
|
+
await import("./vm-BLsHw1da.js");
|
|
1791
1710
|
await import("./utils-UBeAFeEI.js").then((n) => n.h);
|
|
1792
1711
|
await import("./truncator-DZqEqnpD.js").then((n) => n.r);
|
|
1793
1712
|
await import("./typings-CrBa7Tyy.js").then((n) => n.n);
|
|
1794
|
-
await import("./dual-modes-
|
|
1713
|
+
await import("./dual-modes-DDkoCp3R.js").then((n) => n.n);
|
|
1795
1714
|
};
|
|
1796
1715
|
//#endregion
|
|
1797
|
-
export { BaseResponse, Chat, CitationsManager, Component, ComponentRegistry, DefaultComponents, DefaultExit, ErrorExecutionResult, ExecutionResult, Exit, ListenExit, LoopExceededError, MARKER, NAME_REGEX, NextResponse, ObjectInstance, PartialExecutionResult, ReplayableAsyncIterable, RunResponse, SendResponse, Snapshot, SnapshotSignal, StreamingMessageParser, SuccessExecutionResult, ThinkExit, ThinkSignal, Tool, _CustomModelClient, assertValidComponent, collectText, configureQuickJS, configureTokenizer, execute, generateInstructions, getValue, init, isAnyComponent, isComponent, normalizeComponentDefinition, normalizeComponentName, normalizePropsSchema, parseExit, parseStream, parseText, sanitizeMessageText, tryParseJson, utils, validateComponent, validateProps, version };
|
|
1716
|
+
export { BaseResponse, Chat, CitationsManager, Component, ComponentRegistry, DefaultComponents, DefaultExit, ErrorExecutionResult, Example, ExecutionResult, Exit, ListenExit, LoopExceededError, MARKER, NAME_REGEX, NextResponse, ObjectInstance, PartialExecutionResult, ReplayableAsyncIterable, RunResponse, SendResponse, Snapshot, SnapshotSignal, StreamingMessageParser, SuccessExecutionResult, ThinkExit, ThinkSignal, Tool, _CustomModelClient, assertValidComponent, collectText, configureQuickJS, configureTokenizer, execute, generateInstructions, getValue, init, isAnyComponent, isComponent, normalizeComponentDefinition, normalizeComponentName, normalizePropsSchema, parseExit, parseStream, parseText, sanitizeMessageText, tryParseJson, utils, validateComponent, validateProps, version };
|