llmz 0.8.0 → 0.9.1

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.
Files changed (68) hide show
  1. package/README.md +45 -11
  2. package/dist/chat.d.ts +6 -6
  3. package/dist/{common-DdArNQhl.cjs → common-DJkSpeqw.cjs} +239 -22
  4. package/dist/{common-pgJjFu2Y.js → common-DuEhn6u3.js} +234 -23
  5. package/dist/compiler/plugins/variable-extraction.d.ts +1 -7
  6. package/dist/{compiler-C-OI9sim.cjs → compiler-BJJUmNS9.cjs} +34 -68
  7. package/dist/{compiler-CW1VjQsn.js → compiler-BPl-5CXh.js} +34 -68
  8. package/dist/{component-BXS8vAwO.cjs → component-CPKXe6Ca.cjs} +2 -2
  9. package/dist/{component-Dq7ZLdvy.js → component-DGG7d_Mz.js} +1 -1
  10. package/dist/component.default.d.ts +10 -0
  11. package/dist/context.d.ts +4 -8
  12. package/dist/{custom-client-HkM1Sdzv.cjs → custom-client-B_o56CB4.cjs} +22 -19
  13. package/dist/{custom-client-2V9lmzUf.js → custom-client-C-nDKG37.js} +17 -14
  14. package/dist/{dual-modes-Cb7ThvoV.cjs → dual-modes-BNHlj2qM.cjs} +1252 -1181
  15. package/dist/{dual-modes-Cy0_W4O2.js → dual-modes-BNIiNLrR.js} +1257 -1180
  16. package/dist/example-format.d.ts +8 -0
  17. package/dist/{execute-COIHOIKR.cjs → execute-0bvqakr7.cjs} +91 -99
  18. package/dist/{execute-Aw4cbIx-.js → execute-CWFIL5ny.js} +91 -99
  19. package/dist/{exit-DUM96DN1.cjs → exit-CGLXI0BH.cjs} +2 -2
  20. package/dist/index.cjs +265 -22
  21. package/dist/index.js +258 -15
  22. package/dist/index.workerd.js +8565 -8005
  23. package/dist/inspect.d.ts +2 -0
  24. package/dist/isPlainObject-CSxXVKCk.cjs +56 -0
  25. package/dist/isPlainObject-D39AzPO2.js +51 -0
  26. package/dist/{jsx-D5Y2cPo-.cjs → jsx-BJ6GWXI2.cjs} +3 -57
  27. package/dist/{jsx-B0iYyvfr.js → jsx-CIgdGGVs.js} +2 -50
  28. package/dist/message-stream/instructions.d.ts +8 -0
  29. package/dist/message-stream/parser.d.ts +6 -0
  30. package/dist/message-stream/response-parser.d.ts +24 -0
  31. package/dist/message-stream/response-parser.test.d.ts +1 -0
  32. package/dist/message-stream/types.d.ts +3 -2
  33. package/dist/prompts/adherence.test.d.ts +1 -0
  34. package/dist/prompts/catalogue-examples.test.d.ts +1 -0
  35. package/dist/prompts/chat-mode/protocol.d.ts +2 -0
  36. package/dist/prompts/chat-mode/system.d.ts +1 -1
  37. package/dist/prompts/chat-mode/user.d.ts +1 -1
  38. package/dist/prompts/code-examples.d.ts +2 -0
  39. package/dist/prompts/code-examples.test.d.ts +1 -0
  40. package/dist/prompts/common.d.ts +2 -1
  41. package/dist/prompts/concrete-patterns.test.d.ts +1 -0
  42. package/dist/prompts/long-search.test.d.ts +1 -0
  43. package/dist/prompts/prompt.d.ts +5 -2
  44. package/dist/prompts/protocol-basics.d.ts +5 -0
  45. package/dist/prompts/protocol-simple.test.d.ts +1 -0
  46. package/dist/prompts/protocol.d.ts +13 -0
  47. package/dist/prompts/sections.test.d.ts +1 -0
  48. package/dist/prompts/worker-mode/protocol.d.ts +2 -0
  49. package/dist/prompts/worker-mode/system.d.ts +1 -1
  50. package/dist/prompts/worker-mode/user.d.ts +1 -1
  51. package/dist/runtime/citations.test.d.ts +1 -0
  52. package/dist/runtime/fixtures/long-search.d.ts +19 -0
  53. package/dist/runtime/fixtures/protocol-languages.d.ts +74 -0
  54. package/dist/runtime/fixtures/qwen-protocol-failures.d.ts +29 -0
  55. package/dist/runtime/generate.d.ts +2 -9
  56. package/dist/runtime/generate.test.d.ts +1 -0
  57. package/dist/runtime/protocol-adherence.test.d.ts +1 -0
  58. package/dist/runtime/types.d.ts +4 -7
  59. package/dist/{tool-Bv8N4IPj.js → tool-B6Pmuk6K.js} +35 -49
  60. package/dist/{tool-Dy6AJpJH.cjs → tool-BLTrA-sL.cjs} +38 -52
  61. package/dist/tool.d.ts +5 -3
  62. package/dist/{truncator-DZqEqnpD.js → truncator-CD7QtE84.js} +11 -6
  63. package/dist/{truncator-CLkouTCO.cjs → truncator-DmCu9M4m.cjs} +13 -8
  64. package/dist/{typings-3lsqCbkn.cjs → typings-DXJMu59O.cjs} +2 -2
  65. package/dist/{utils-3ESwP3yg.cjs → utils-DGQ4sRke.cjs} +1 -1
  66. package/dist/{vm-BLsHw1da.js → vm-Cn3jvZ00.js} +109 -53
  67. package/dist/{vm-D6s1zF6M.cjs → vm-X0uTj5Aa.cjs} +109 -53
  68. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,17 +1,17 @@
1
- import { a as StreamingMessageParser, c as NAME_REGEX, o as tryParseJson, s as MARKER } from "./common-pgJjFu2Y.js";
2
- import { a as Example, h as ComponentRegistry, m as validateProps, o as generateInstructions, p as validateComponent, s as DefaultComponents } from "./dual-modes-Cy0_W4O2.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-2V9lmzUf.js";
1
+ import { d as generateInstructions, f as validateComponent, m as ComponentRegistry, p as validateProps, u as Example } from "./dual-modes-BNIiNLrR.js";
2
+ import { c as MARKER, l as NAME_REGEX, o as StreamingMessageParser, s as tryParseJson } from "./common-DuEhn6u3.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-C-nDKG37.js";
4
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";
5
- import { a as isComponent, i as isAnyComponent, n as assertValidComponent, t as Component } from "./component-Dq7ZLdvy.js";
6
- import { t as Tool } from "./tool-Bv8N4IPj.js";
5
+ import { t as Tool } from "./tool-B6Pmuk6K.js";
7
6
  import { c as SnapshotSignal, l as ThinkSignal, o as LoopExceededError, r as CodeFormattingError } from "./errors-Cg1G0Awu.js";
8
7
  import { a as isPunct, i as isGroup, o as parse, r as formatTypings, s as tokenize, t as getTypings } from "./typings-CrBa7Tyy.js";
9
8
  import { t as Exit } from "./exit-CDdxDBRT.js";
10
- import { i as wrapContent, n as truncateWrappedContent, t as stripTruncationTags } from "./truncator-DZqEqnpD.js";
9
+ import { a as isComponent, i as isAnyComponent, n as assertValidComponent, t as Component } from "./component-DGG7d_Mz.js";
10
+ import { i as wrapContent, n as truncateWrappedContent, t as stripTruncationTags } from "./truncator-CD7QtE84.js";
11
11
  import { t as configureQuickJS } from "./quickjs-variant-BYhMBpwU.js";
12
12
  import { transforms, z } from "@bpinternal/zui";
13
13
  //#region package.json
14
- var version = "0.8.0";
14
+ var version = "0.9.1";
15
15
  //#endregion
16
16
  //#region src/hoist.ts
17
17
  /**
@@ -791,6 +791,249 @@ var CitationsManager = class {
791
791
  }
792
792
  };
793
793
  //#endregion
794
+ //#region src/component.default.ts
795
+ const Button = new 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: "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
+ ]
832
+ },
833
+ leaf: { props: z.object({
834
+ action: z.enum([
835
+ "say",
836
+ "url",
837
+ "postback"
838
+ ]).default("say").describe("The action to perform when the button is clicked. Can be \"say\", \"url\", or \"postback\""),
839
+ label: z.string().describe("The text displayed on the button (min 1 character, max 250 characters)"),
840
+ value: z.string().optional().describe("The postback value to send when the button is clicked. Required if action is \"postback\""),
841
+ url: z.string().optional().describe("The URL to open when the button is clicked. Required if action is \"url\"")
842
+ }) }
843
+ });
844
+ const Image = new Component({
845
+ type: "leaf",
846
+ name: "Image",
847
+ description: "Displays an image from a URL.",
848
+ aliases: [],
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
+ },
856
+ leaf: { props: z.object({
857
+ url: z.string().describe("The URL of the image (must be valid)"),
858
+ alt: z.string().optional().describe("Alternative text describing the image")
859
+ }) }
860
+ });
861
+ const File = new Component({
862
+ type: "leaf",
863
+ name: "File",
864
+ description: "Sends a downloadable file to the user.",
865
+ aliases: [],
866
+ generation: { examples: [{ props: {
867
+ url: "https://example.com/report.pdf",
868
+ name: "Report.pdf"
869
+ } }] },
870
+ leaf: { props: z.object({
871
+ url: z.string().describe("The URL of the file (must be valid)"),
872
+ name: z.string().optional().describe("The display name of the file")
873
+ }) }
874
+ });
875
+ const Video = new Component({
876
+ type: "leaf",
877
+ name: "Video",
878
+ description: "Embeds a video from a URL.",
879
+ aliases: [],
880
+ generation: { examples: [{ props: {
881
+ url: "https://example.com/intro.mp4",
882
+ title: "Welcome"
883
+ } }] },
884
+ leaf: { props: z.object({
885
+ url: z.string().describe("The URL of the video (must be valid)"),
886
+ title: z.string().optional().describe("Title for the video")
887
+ }) }
888
+ });
889
+ const Audio = new Component({
890
+ type: "leaf",
891
+ name: "Audio",
892
+ description: "Plays an audio clip from a URL.",
893
+ aliases: [],
894
+ generation: { examples: [{ props: {
895
+ url: "https://example.com/audio.mp3",
896
+ title: "Sample"
897
+ } }] },
898
+ leaf: { props: z.object({
899
+ url: z.string().describe("The URL of the audio clip (must be valid)"),
900
+ title: z.string().optional().describe("Title for the audio clip")
901
+ }) }
902
+ });
903
+ const Card = new Component({
904
+ type: "container",
905
+ name: "Card",
906
+ description: "A card with a title, optional subtitle, and Markdown body.",
907
+ aliases: [],
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
+ },
918
+ container: {
919
+ props: z.object({
920
+ title: z.string().min(1).max(250).describe("Title text (1–250 characters)"),
921
+ subtitle: z.string().optional().describe("Optional subtitle for the card")
922
+ }),
923
+ children: [{
924
+ description: "Image (optional, max 1)",
925
+ component: Image.definition
926
+ }, {
927
+ description: "Button (optional, up to 5)",
928
+ component: Button.definition
929
+ }]
930
+ }
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
+ };
949
+ const DefaultComponents = {
950
+ Button,
951
+ Image,
952
+ File,
953
+ Video,
954
+ Audio,
955
+ Card,
956
+ Carousel: new CarouselComponent({
957
+ type: "container",
958
+ name: "Carousel",
959
+ description: "Displays a horizontally scrollable collection of cards, each with its own content and actions.",
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
+ },
992
+ container: {
993
+ props: carouselProps,
994
+ children: [{
995
+ description: "Card component (required, 1–10 allowed)",
996
+ component: Card.definition
997
+ }]
998
+ }
999
+ }),
1000
+ Text: new Component({
1001
+ type: "default",
1002
+ name: "Message",
1003
+ aliases: ["Text", "Markdown"],
1004
+ description: "A Markdown-formatted text message. Long answers are written the same way: plain Markdown prose.",
1005
+ generation: { examples: [{ body: `To reset your password:
1006
+
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.
1010
+
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?" }] },
1012
+ default: {
1013
+ props: z.object({}),
1014
+ children: []
1015
+ }
1016
+ }),
1017
+ Speech: new Component({
1018
+ type: "default",
1019
+ name: "Speech",
1020
+ aliases: ["speak", "spoken"],
1021
+ description: "A message spoken aloud to the user via text-to-speech.",
1022
+ body: {
1023
+ format: "text",
1024
+ 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\")."
1025
+ },
1026
+ generation: {
1027
+ usage: "Use when the reply will be played back as audio (voice conversations).",
1028
+ examples: [{ body: "Sure! Your order shipped this morning and should arrive on Tuesday, June third, around noon." }]
1029
+ },
1030
+ default: {
1031
+ props: z.object({}),
1032
+ children: []
1033
+ }
1034
+ })
1035
+ };
1036
+ //#endregion
794
1037
  //#region src/chat.ts
795
1038
  /**
796
1039
  * Base class for implementing chat interfaces in LLMz agents.
@@ -1449,7 +1692,7 @@ const utils = {
1449
1692
  * })
1450
1693
  */
1451
1694
  const execute = async (props) => {
1452
- const { executeContext } = await import("./execute-Aw4cbIx-.js");
1695
+ const { executeContext } = await import("./execute-CWFIL5ny.js");
1453
1696
  return executeContext(props);
1454
1697
  };
1455
1698
  /**
@@ -1458,16 +1701,16 @@ const execute = async (props) => {
1458
1701
  * It's recommended to call this function at the beginning of your application without awaiting it (void init())
1459
1702
  */
1460
1703
  const init = async () => {
1461
- await import("./execute-Aw4cbIx-.js");
1462
- await import("./component-Dq7ZLdvy.js").then((n) => n.r);
1463
- await import("./tool-Bv8N4IPj.js").then((n) => n.n);
1704
+ await import("./execute-CWFIL5ny.js");
1705
+ await import("./component-DGG7d_Mz.js").then((n) => n.r);
1706
+ await import("./tool-B6Pmuk6K.js").then((n) => n.n);
1464
1707
  await import("./exit-CDdxDBRT.js").then((n) => n.n);
1465
- await import("./jsx-B0iYyvfr.js").then((n) => n.i);
1466
- await import("./vm-BLsHw1da.js");
1708
+ await import("./jsx-CIgdGGVs.js").then((n) => n.i);
1709
+ await import("./vm-Cn3jvZ00.js");
1467
1710
  await import("./utils-UBeAFeEI.js").then((n) => n.h);
1468
- await import("./truncator-DZqEqnpD.js").then((n) => n.r);
1711
+ await import("./truncator-CD7QtE84.js").then((n) => n.r);
1469
1712
  await import("./typings-CrBa7Tyy.js").then((n) => n.n);
1470
- await import("./dual-modes-Cy0_W4O2.js").then((n) => n.n);
1713
+ await import("./dual-modes-BNIiNLrR.js").then((n) => n.n);
1471
1714
  };
1472
1715
  //#endregion
1473
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 };