@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 +120 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +58 -1
- package/dist/index.d.ts +58 -1
- package/dist/index.js +118 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/flows/bakery-assistant.ts +1 -1
- package/src/flows/components.ts +1 -1
- package/src/flows/conversational.ts +1 -1
- package/src/flows/index.ts +2 -0
- package/src/flows/page-context.ts +1 -1
- package/src/flows/scheduling.ts +1 -1
- package/src/flows/shopping-assistant.ts +2 -2
- package/src/flows/storefront-assistant.ts +1 -1
- package/src/flows/webmcp-calendar.ts +60 -0
- package/src/flows/webmcp-storefront.ts +63 -0
- package/src/index.test.ts +95 -0
- package/src/index.ts +81 -4
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var CONVERSATIONAL_FLOW = {
|
|
|
13
13
|
type: "prompt",
|
|
14
14
|
enabled: true,
|
|
15
15
|
config: {
|
|
16
|
-
model: "
|
|
16
|
+
model: "nemotron-3-ultra-550b-a55b",
|
|
17
17
|
responseFormat: "markdown",
|
|
18
18
|
outputVariable: "prompt_result",
|
|
19
19
|
userPrompt: "{{user_message}}",
|
|
@@ -35,7 +35,7 @@ var FORM_DIRECTIVE_FLOW = {
|
|
|
35
35
|
type: "prompt",
|
|
36
36
|
enabled: true,
|
|
37
37
|
config: {
|
|
38
|
-
model: "
|
|
38
|
+
model: "nemotron-3-ultra-550b-a55b",
|
|
39
39
|
reasoning: false,
|
|
40
40
|
responseFormat: "JSON",
|
|
41
41
|
outputVariable: "prompt_result",
|
|
@@ -96,7 +96,7 @@ var SHOPPING_ASSISTANT_FLOW = {
|
|
|
96
96
|
type: "prompt",
|
|
97
97
|
enabled: true,
|
|
98
98
|
config: {
|
|
99
|
-
model: "
|
|
99
|
+
model: "nemotron-3-ultra-550b-a55b",
|
|
100
100
|
reasoning: false,
|
|
101
101
|
responseFormat: "JSON",
|
|
102
102
|
outputVariable: "prompt_result",
|
|
@@ -169,7 +169,7 @@ var SHOPPING_ASSISTANT_METADATA_FLOW = {
|
|
|
169
169
|
type: "prompt",
|
|
170
170
|
enabled: true,
|
|
171
171
|
config: {
|
|
172
|
-
model: "
|
|
172
|
+
model: "nemotron-3-ultra-550b-a55b",
|
|
173
173
|
reasoning: false,
|
|
174
174
|
responseFormat: "JSON",
|
|
175
175
|
outputVariable: "prompt_result",
|
|
@@ -253,7 +253,7 @@ var COMPONENT_FLOW = {
|
|
|
253
253
|
type: "prompt",
|
|
254
254
|
enabled: true,
|
|
255
255
|
config: {
|
|
256
|
-
model: "
|
|
256
|
+
model: "nemotron-3-ultra-550b-a55b",
|
|
257
257
|
reasoning: false,
|
|
258
258
|
responseFormat: "JSON",
|
|
259
259
|
outputVariable: "prompt_result",
|
|
@@ -307,7 +307,7 @@ var BAKERY_ASSISTANT_FLOW = {
|
|
|
307
307
|
type: "prompt",
|
|
308
308
|
enabled: true,
|
|
309
309
|
config: {
|
|
310
|
-
model: "
|
|
310
|
+
model: "nemotron-3-ultra-550b-a55b",
|
|
311
311
|
reasoning: false,
|
|
312
312
|
responseFormat: "JSON",
|
|
313
313
|
outputVariable: "prompt_result",
|
|
@@ -426,7 +426,7 @@ var STOREFRONT_ASSISTANT_FLOW = {
|
|
|
426
426
|
type: "prompt",
|
|
427
427
|
enabled: true,
|
|
428
428
|
config: {
|
|
429
|
-
model: "
|
|
429
|
+
model: "nemotron-3-ultra-550b-a55b",
|
|
430
430
|
reasoning: false,
|
|
431
431
|
responseFormat: "JSON",
|
|
432
432
|
outputVariable: "prompt_result",
|
|
@@ -540,6 +540,85 @@ User asks "what's the best way to care for cashmere?":
|
|
|
540
540
|
]
|
|
541
541
|
};
|
|
542
542
|
|
|
543
|
+
// src/flows/webmcp-storefront.ts
|
|
544
|
+
var WEBMCP_STOREFRONT_FLOW = {
|
|
545
|
+
name: "WebMCP Storefront Flow",
|
|
546
|
+
description: "Switchback running-store assistant \u2014 drives page-provided WebMCP tools (clientTools[])",
|
|
547
|
+
steps: [
|
|
548
|
+
{
|
|
549
|
+
id: "webmcp_storefront_prompt",
|
|
550
|
+
name: "WebMCP Storefront Prompt",
|
|
551
|
+
type: "prompt",
|
|
552
|
+
enabled: true,
|
|
553
|
+
config: {
|
|
554
|
+
model: "nemotron-3-ultra-550b-a55b",
|
|
555
|
+
reasoning: false,
|
|
556
|
+
responseFormat: "markdown",
|
|
557
|
+
outputVariable: "prompt_result",
|
|
558
|
+
userPrompt: "{{user_message}}",
|
|
559
|
+
systemPrompt: `You are the shopping assistant for **Switchback**, a trail & road running store. You help shoppers find gear, inspect products, and manage their cart.
|
|
560
|
+
|
|
561
|
+
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.
|
|
562
|
+
|
|
563
|
+
## Your tools come from the page
|
|
564
|
+
|
|
565
|
+
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.
|
|
566
|
+
|
|
567
|
+
Rules:
|
|
568
|
+
- 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.
|
|
569
|
+
- 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.
|
|
570
|
+
- 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.
|
|
571
|
+
- Only apply a promo code the shopper actually gives you; if it's rejected, say so and suggest they double-check the code.
|
|
572
|
+
- If a tool reports an item wasn't found or isn't in the cart, relay that plainly and offer to search.
|
|
573
|
+
- 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: \`\`. 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.
|
|
574
|
+
|
|
575
|
+
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.`,
|
|
576
|
+
previousMessages: "{{messages}}"
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
]
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
// src/flows/webmcp-calendar.ts
|
|
583
|
+
var WEBMCP_CALENDAR_FLOW = {
|
|
584
|
+
name: "WebMCP Calendar Flow",
|
|
585
|
+
description: "Calendar copilot \u2014 drives page-provided WebMCP calendar tools (clientTools[])",
|
|
586
|
+
steps: [
|
|
587
|
+
{
|
|
588
|
+
id: "webmcp_calendar_prompt",
|
|
589
|
+
name: "WebMCP Calendar Prompt",
|
|
590
|
+
type: "prompt",
|
|
591
|
+
enabled: true,
|
|
592
|
+
config: {
|
|
593
|
+
model: "nemotron-3-ultra-550b-a55b",
|
|
594
|
+
reasoning: false,
|
|
595
|
+
responseFormat: "markdown",
|
|
596
|
+
outputVariable: "prompt_result",
|
|
597
|
+
userPrompt: "{{user_message}}",
|
|
598
|
+
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.
|
|
599
|
+
|
|
600
|
+
Voice: helpful, concise, plain language. Keep replies short \u2014 a sentence or two around the actions you take.
|
|
601
|
+
|
|
602
|
+
## Your tools come from the page
|
|
603
|
+
|
|
604
|
+
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.
|
|
605
|
+
|
|
606
|
+
Rules:
|
|
607
|
+
- 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".
|
|
608
|
+
- 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.
|
|
609
|
+
- Use a real userId from **get_users** and a color from **get_event_colors** when creating events. Do not guess IDs.
|
|
610
|
+
- Before proposing a meeting time, check **find_availability** for that date; the workday is 9am\u20135pm local.
|
|
611
|
+
- To change or remove an event, find its eventId via **get_events** or **get_calendar_state** first.
|
|
612
|
+
- 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.
|
|
613
|
+
- If a tool reports an error (invalid time, missing event), relay it plainly and suggest a fix.
|
|
614
|
+
|
|
615
|
+
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.`,
|
|
616
|
+
previousMessages: "{{messages}}"
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
]
|
|
620
|
+
};
|
|
621
|
+
|
|
543
622
|
// src/flows/page-context.ts
|
|
544
623
|
var PAGE_CONTEXT_FLOW = {
|
|
545
624
|
name: "Page Context Assistant Flow",
|
|
@@ -551,7 +630,7 @@ var PAGE_CONTEXT_FLOW = {
|
|
|
551
630
|
type: "prompt",
|
|
552
631
|
enabled: true,
|
|
553
632
|
config: {
|
|
554
|
-
model: "
|
|
633
|
+
model: "nemotron-3-ultra-550b-a55b",
|
|
555
634
|
responseFormat: "JSON",
|
|
556
635
|
outputVariable: "prompt_result",
|
|
557
636
|
userPrompt: "{{user_message}}",
|
|
@@ -699,6 +778,24 @@ var isDevelopmentRuntime = () => {
|
|
|
699
778
|
var _a;
|
|
700
779
|
return ((_a = getRuntimeEnv()) == null ? void 0 : _a.NODE_ENV) === "development";
|
|
701
780
|
};
|
|
781
|
+
var isVercelPreviewRuntime = () => {
|
|
782
|
+
var _a;
|
|
783
|
+
return ((_a = getRuntimeEnv()) == null ? void 0 : _a.VERCEL_ENV) === "preview";
|
|
784
|
+
};
|
|
785
|
+
var DEFAULT_PREVIEW_ORIGIN_PATTERN = /^https:\/\/[a-z0-9-]+\.vercel\.app$/i;
|
|
786
|
+
var resolvePreviewOriginPattern = (option) => {
|
|
787
|
+
var _a;
|
|
788
|
+
if (option === false) return null;
|
|
789
|
+
if (option instanceof RegExp) return option;
|
|
790
|
+
const envPattern = (_a = getRuntimeEnv()) == null ? void 0 : _a.PREVIEW_ORIGIN_PATTERN;
|
|
791
|
+
if (envPattern) {
|
|
792
|
+
try {
|
|
793
|
+
return new RegExp(envPattern);
|
|
794
|
+
} catch {
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
return DEFAULT_PREVIEW_ORIGIN_PATTERN;
|
|
798
|
+
};
|
|
702
799
|
var DEFAULT_FLOW = {
|
|
703
800
|
name: "Streaming Prompt Flow",
|
|
704
801
|
description: "Streaming chat generated by the widget",
|
|
@@ -709,7 +806,7 @@ var DEFAULT_FLOW = {
|
|
|
709
806
|
type: "prompt",
|
|
710
807
|
enabled: true,
|
|
711
808
|
config: {
|
|
712
|
-
model: "
|
|
809
|
+
model: "nemotron-3-ultra-550b-a55b",
|
|
713
810
|
responseFormat: "markdown",
|
|
714
811
|
outputVariable: "prompt_result",
|
|
715
812
|
userPrompt: "{{user_message}}",
|
|
@@ -724,9 +821,12 @@ var DEFAULT_FLOW = {
|
|
|
724
821
|
}
|
|
725
822
|
]
|
|
726
823
|
};
|
|
727
|
-
var withCors = (allowedOrigins) => async (c, next) => {
|
|
824
|
+
var withCors = (allowedOrigins, previewOriginPattern) => async (c, next) => {
|
|
728
825
|
const origin = c.req.header("origin");
|
|
729
826
|
const isDevelopment = isDevelopmentRuntime();
|
|
827
|
+
const isPreviewOrigin = Boolean(
|
|
828
|
+
origin && (isVercelPreviewRuntime() || previewOriginPattern !== null && previewOriginPattern.test(origin))
|
|
829
|
+
);
|
|
730
830
|
let corsOrigin;
|
|
731
831
|
if (!allowedOrigins || allowedOrigins.length === 0) {
|
|
732
832
|
corsOrigin = origin || "*";
|
|
@@ -734,6 +834,8 @@ var withCors = (allowedOrigins) => async (c, next) => {
|
|
|
734
834
|
corsOrigin = origin || "*";
|
|
735
835
|
} else if (isDevelopment && origin) {
|
|
736
836
|
corsOrigin = origin;
|
|
837
|
+
} else if (isPreviewOrigin && origin) {
|
|
838
|
+
corsOrigin = origin;
|
|
737
839
|
} else {
|
|
738
840
|
if (c.req.method === "OPTIONS") {
|
|
739
841
|
return c.json({ error: "CORS policy violation: origin not allowed" }, 403);
|
|
@@ -761,7 +863,10 @@ var createChatProxyApp = (options = {}) => {
|
|
|
761
863
|
const path = (_a = options.path) != null ? _a : DEFAULT_PATH;
|
|
762
864
|
const feedbackPath = (_b = options.feedbackPath) != null ? _b : "/api/feedback";
|
|
763
865
|
const upstream = (_c = options.upstreamUrl) != null ? _c : DEFAULT_ENDPOINT;
|
|
764
|
-
|
|
866
|
+
const previewOriginPattern = resolvePreviewOriginPattern(
|
|
867
|
+
options.previewOriginPattern
|
|
868
|
+
);
|
|
869
|
+
app.use("*", withCors(options.allowedOrigins, previewOriginPattern));
|
|
765
870
|
app.post(feedbackPath, async (c) => {
|
|
766
871
|
var _a2, _b2, _c2;
|
|
767
872
|
let payload;
|
|
@@ -970,6 +1075,8 @@ export {
|
|
|
970
1075
|
SHOPPING_ASSISTANT_FLOW,
|
|
971
1076
|
SHOPPING_ASSISTANT_METADATA_FLOW,
|
|
972
1077
|
STOREFRONT_ASSISTANT_FLOW,
|
|
1078
|
+
WEBMCP_CALENDAR_FLOW,
|
|
1079
|
+
WEBMCP_STOREFRONT_FLOW,
|
|
973
1080
|
createChatProxyApp,
|
|
974
1081
|
createCheckoutSession,
|
|
975
1082
|
createVercelHandler,
|