@runtypelabs/persona-proxy 3.22.0 → 3.31.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/index.cjs CHANGED
@@ -28,6 +28,8 @@ __export(index_exports, {
28
28
  SHOPPING_ASSISTANT_FLOW: () => SHOPPING_ASSISTANT_FLOW,
29
29
  SHOPPING_ASSISTANT_METADATA_FLOW: () => SHOPPING_ASSISTANT_METADATA_FLOW,
30
30
  STOREFRONT_ASSISTANT_FLOW: () => STOREFRONT_ASSISTANT_FLOW,
31
+ WEBMCP_CALENDAR_FLOW: () => WEBMCP_CALENDAR_FLOW,
32
+ WEBMCP_STOREFRONT_FLOW: () => WEBMCP_STOREFRONT_FLOW,
31
33
  createChatProxyApp: () => createChatProxyApp,
32
34
  createCheckoutSession: () => createCheckoutSession,
33
35
  createVercelHandler: () => createVercelHandler,
@@ -48,7 +50,7 @@ var CONVERSATIONAL_FLOW = {
48
50
  type: "prompt",
49
51
  enabled: true,
50
52
  config: {
51
- model: "mercury-2",
53
+ model: "nemotron-3-ultra-550b-a55b",
52
54
  responseFormat: "markdown",
53
55
  outputVariable: "prompt_result",
54
56
  userPrompt: "{{user_message}}",
@@ -70,7 +72,7 @@ var FORM_DIRECTIVE_FLOW = {
70
72
  type: "prompt",
71
73
  enabled: true,
72
74
  config: {
73
- model: "mercury-2",
75
+ model: "nemotron-3-ultra-550b-a55b",
74
76
  reasoning: false,
75
77
  responseFormat: "JSON",
76
78
  outputVariable: "prompt_result",
@@ -131,7 +133,7 @@ var SHOPPING_ASSISTANT_FLOW = {
131
133
  type: "prompt",
132
134
  enabled: true,
133
135
  config: {
134
- model: "mercury-2",
136
+ model: "nemotron-3-ultra-550b-a55b",
135
137
  reasoning: false,
136
138
  responseFormat: "JSON",
137
139
  outputVariable: "prompt_result",
@@ -204,7 +206,7 @@ var SHOPPING_ASSISTANT_METADATA_FLOW = {
204
206
  type: "prompt",
205
207
  enabled: true,
206
208
  config: {
207
- model: "mercury-2",
209
+ model: "nemotron-3-ultra-550b-a55b",
208
210
  reasoning: false,
209
211
  responseFormat: "JSON",
210
212
  outputVariable: "prompt_result",
@@ -288,7 +290,7 @@ var COMPONENT_FLOW = {
288
290
  type: "prompt",
289
291
  enabled: true,
290
292
  config: {
291
- model: "mercury-2",
293
+ model: "nemotron-3-ultra-550b-a55b",
292
294
  reasoning: false,
293
295
  responseFormat: "JSON",
294
296
  outputVariable: "prompt_result",
@@ -342,7 +344,7 @@ var BAKERY_ASSISTANT_FLOW = {
342
344
  type: "prompt",
343
345
  enabled: true,
344
346
  config: {
345
- model: "mercury-2",
347
+ model: "nemotron-3-ultra-550b-a55b",
346
348
  reasoning: false,
347
349
  responseFormat: "JSON",
348
350
  outputVariable: "prompt_result",
@@ -461,7 +463,7 @@ var STOREFRONT_ASSISTANT_FLOW = {
461
463
  type: "prompt",
462
464
  enabled: true,
463
465
  config: {
464
- model: "mercury-2",
466
+ model: "nemotron-3-ultra-550b-a55b",
465
467
  reasoning: false,
466
468
  responseFormat: "JSON",
467
469
  outputVariable: "prompt_result",
@@ -575,6 +577,85 @@ User asks "what's the best way to care for cashmere?":
575
577
  ]
576
578
  };
577
579
 
580
+ // src/flows/webmcp-storefront.ts
581
+ var WEBMCP_STOREFRONT_FLOW = {
582
+ name: "WebMCP Storefront Flow",
583
+ description: "Switchback running-store assistant \u2014 drives page-provided WebMCP tools (clientTools[])",
584
+ steps: [
585
+ {
586
+ id: "webmcp_storefront_prompt",
587
+ name: "WebMCP Storefront Prompt",
588
+ type: "prompt",
589
+ enabled: true,
590
+ config: {
591
+ model: "nemotron-3-ultra-550b-a55b",
592
+ reasoning: false,
593
+ responseFormat: "markdown",
594
+ outputVariable: "prompt_result",
595
+ userPrompt: "{{user_message}}",
596
+ systemPrompt: `You are the shopping assistant for **Switchback**, a trail & road running store. You help shoppers find gear, inspect products, and manage their cart.
597
+
598
+ Brand voice: friendly, outdoorsy, concise. Knowledgeable about running shoes, apparel, and trail gear. No hype, no emoji. Keep replies short \u2014 a sentence or two around the actions you take.
599
+
600
+ ## Your tools come from the page
601
+
602
+ This storefront exposes its own tools to you (search the catalog, view a product, add/remove from the cart, apply a promo code). Always **use the tools** to act on the catalog and cart \u2014 never invent products, SKUs, prices, or cart contents from memory.
603
+
604
+ Rules:
605
+ - Before referencing or adding any SKU, call **search_products** (or view_product) first to confirm it exists and to get the canonical SKU, title, and price. Do not guess SKUs.
606
+ - When the shopper asks to add, remove, or change the cart, call the matching tool. The page renders the cart \u2014 after a cart change, confirm what changed and the running total from the tool's result, briefly.
607
+ - If the shopper asks to add two (or more) specific items "at the same time" / "both", emit the add_to_cart calls together in one turn so they batch.
608
+ - Only apply a promo code the shopper actually gives you; if it's rejected, say so and suggest they double-check the code.
609
+ - If a tool reports an item wasn't found or isn't in the cart, relay that plainly and offer to search.
610
+ - Tool results include product \`imageUrl\` and \`imageAlt\`. When you recommend, compare, or describe specific products, include Markdown product images when it helps the shopper decide: \`![imageAlt](imageUrl)\`. Use the exact imageUrl/imageAlt from the tool result, include at most three product images in one reply, and skip images for pure cart-total/status replies unless a single changed item is the focus.
611
+
612
+ After your tool calls resolve, summarize the outcome in plain language (what you found, what's in the cart, the total). Do not describe tools, JSON, SKUs, or the WebMCP mechanism to the shopper.`,
613
+ previousMessages: "{{messages}}"
614
+ }
615
+ }
616
+ ]
617
+ };
618
+
619
+ // src/flows/webmcp-calendar.ts
620
+ var WEBMCP_CALENDAR_FLOW = {
621
+ name: "WebMCP Calendar Flow",
622
+ description: "Calendar copilot \u2014 drives page-provided WebMCP calendar tools (clientTools[])",
623
+ steps: [
624
+ {
625
+ id: "webmcp_calendar_prompt",
626
+ name: "WebMCP Calendar Prompt",
627
+ type: "prompt",
628
+ enabled: true,
629
+ config: {
630
+ model: "nemotron-3-ultra-550b-a55b",
631
+ reasoning: false,
632
+ responseFormat: "markdown",
633
+ outputVariable: "prompt_result",
634
+ userPrompt: "{{user_message}}",
635
+ systemPrompt: `You are the Calendar Copilot for a team scheduling dashboard. You help the user inspect availability, create, move, and delete events \u2014 the calendar on the page updates live as your tools run.
636
+
637
+ Voice: helpful, concise, plain language. Keep replies short \u2014 a sentence or two around the actions you take.
638
+
639
+ ## Your tools come from the page
640
+
641
+ The dashboard exposes its own calendar tools to you. Always **use the tools** to read or change the calendar \u2014 never invent events, IDs, owners, or availability from memory.
642
+
643
+ Rules:
644
+ - Start by calling **get_calendar_state** to learn today's date, the current local time, the timezone, and the visible week before resolving relative dates like "tomorrow" or "Thursday".
645
+ - All date-times are LOCAL wall-clock strings in the calendar's timezone, formatted \`YYYY-MM-DDTHH:mm\`. Never append "Z" or a UTC offset \u2014 write the clock time the user said.
646
+ - Use a real userId from **get_users** and a color from **get_event_colors** when creating events. Do not guess IDs.
647
+ - Before proposing a meeting time, check **find_availability** for that date; the workday is 9am\u20135pm local.
648
+ - To change or remove an event, find its eventId via **get_events** or **get_calendar_state** first.
649
+ - After a mutation, confirm briefly what changed (title, day, time) \u2014 the page renders the calendar, so don't repeat the full schedule unless asked.
650
+ - If a tool reports an error (invalid time, missing event), relay it plainly and suggest a fix.
651
+
652
+ After your tool calls resolve, summarize the outcome in plain language. Do not describe tools, JSON, IDs, or the WebMCP mechanism to the user unless they ask.`,
653
+ previousMessages: "{{messages}}"
654
+ }
655
+ }
656
+ ]
657
+ };
658
+
578
659
  // src/flows/page-context.ts
579
660
  var PAGE_CONTEXT_FLOW = {
580
661
  name: "Page Context Assistant Flow",
@@ -586,7 +667,7 @@ var PAGE_CONTEXT_FLOW = {
586
667
  type: "prompt",
587
668
  enabled: true,
588
669
  config: {
589
- model: "mercury-2",
670
+ model: "nemotron-3-ultra-550b-a55b",
590
671
  responseFormat: "JSON",
591
672
  outputVariable: "prompt_result",
592
673
  userPrompt: "{{user_message}}",
@@ -734,6 +815,24 @@ var isDevelopmentRuntime = () => {
734
815
  var _a;
735
816
  return ((_a = getRuntimeEnv()) == null ? void 0 : _a.NODE_ENV) === "development";
736
817
  };
818
+ var isVercelPreviewRuntime = () => {
819
+ var _a;
820
+ return ((_a = getRuntimeEnv()) == null ? void 0 : _a.VERCEL_ENV) === "preview";
821
+ };
822
+ var DEFAULT_PREVIEW_ORIGIN_PATTERN = /^https:\/\/[a-z0-9-]+\.vercel\.app$/i;
823
+ var resolvePreviewOriginPattern = (option) => {
824
+ var _a;
825
+ if (option === false) return null;
826
+ if (option instanceof RegExp) return option;
827
+ const envPattern = (_a = getRuntimeEnv()) == null ? void 0 : _a.PREVIEW_ORIGIN_PATTERN;
828
+ if (envPattern) {
829
+ try {
830
+ return new RegExp(envPattern);
831
+ } catch {
832
+ }
833
+ }
834
+ return DEFAULT_PREVIEW_ORIGIN_PATTERN;
835
+ };
737
836
  var DEFAULT_FLOW = {
738
837
  name: "Streaming Prompt Flow",
739
838
  description: "Streaming chat generated by the widget",
@@ -744,7 +843,7 @@ var DEFAULT_FLOW = {
744
843
  type: "prompt",
745
844
  enabled: true,
746
845
  config: {
747
- model: "mercury-2",
846
+ model: "nemotron-3-ultra-550b-a55b",
748
847
  responseFormat: "markdown",
749
848
  outputVariable: "prompt_result",
750
849
  userPrompt: "{{user_message}}",
@@ -759,9 +858,12 @@ var DEFAULT_FLOW = {
759
858
  }
760
859
  ]
761
860
  };
762
- var withCors = (allowedOrigins) => async (c, next) => {
861
+ var withCors = (allowedOrigins, previewOriginPattern) => async (c, next) => {
763
862
  const origin = c.req.header("origin");
764
863
  const isDevelopment = isDevelopmentRuntime();
864
+ const isPreviewOrigin = Boolean(
865
+ origin && (isVercelPreviewRuntime() || previewOriginPattern !== null && previewOriginPattern.test(origin))
866
+ );
765
867
  let corsOrigin;
766
868
  if (!allowedOrigins || allowedOrigins.length === 0) {
767
869
  corsOrigin = origin || "*";
@@ -769,6 +871,8 @@ var withCors = (allowedOrigins) => async (c, next) => {
769
871
  corsOrigin = origin || "*";
770
872
  } else if (isDevelopment && origin) {
771
873
  corsOrigin = origin;
874
+ } else if (isPreviewOrigin && origin) {
875
+ corsOrigin = origin;
772
876
  } else {
773
877
  if (c.req.method === "OPTIONS") {
774
878
  return c.json({ error: "CORS policy violation: origin not allowed" }, 403);
@@ -796,7 +900,10 @@ var createChatProxyApp = (options = {}) => {
796
900
  const path = (_a = options.path) != null ? _a : DEFAULT_PATH;
797
901
  const feedbackPath = (_b = options.feedbackPath) != null ? _b : "/api/feedback";
798
902
  const upstream = (_c = options.upstreamUrl) != null ? _c : DEFAULT_ENDPOINT;
799
- app.use("*", withCors(options.allowedOrigins));
903
+ const previewOriginPattern = resolvePreviewOriginPattern(
904
+ options.previewOriginPattern
905
+ );
906
+ app.use("*", withCors(options.allowedOrigins, previewOriginPattern));
800
907
  app.post(feedbackPath, async (c) => {
801
908
  var _a2, _b2, _c2;
802
909
  let payload;
@@ -1006,6 +1113,8 @@ var index_default = createChatProxyApp;
1006
1113
  SHOPPING_ASSISTANT_FLOW,
1007
1114
  SHOPPING_ASSISTANT_METADATA_FLOW,
1008
1115
  STOREFRONT_ASSISTANT_FLOW,
1116
+ WEBMCP_CALENDAR_FLOW,
1117
+ WEBMCP_STOREFRONT_FLOW,
1009
1118
  createChatProxyApp,
1010
1119
  createCheckoutSession,
1011
1120
  createVercelHandler