@runtypelabs/cli 2.59.0 → 2.59.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 (2) hide show
  1. package/dist/index.js +204 -179
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -6679,6 +6679,7 @@ const SYSTEM_VARIABLES = /* @__PURE__ */ new Set([
6679
6679
  "_record",
6680
6680
  "_now",
6681
6681
  "_schedule",
6682
+ "_conversation",
6682
6683
  "_tools",
6683
6684
  "_endUser",
6684
6685
  "_tenant",
@@ -6768,7 +6769,7 @@ function hasNoReservedInputKeys(inputs) {
6768
6769
  if (!inputs) return true;
6769
6770
  return Object.keys(inputs).every((key) => !key.startsWith("_"));
6770
6771
  }
6771
- // ../shared/dist/chunk-DWLsnzbx.mjs
6772
+ // ../shared/dist/chunk-DDof6pMi.mjs
6772
6773
  /**
6773
6774
  * Get nested property value using dot notation and bracket notation.
6774
6775
  * Example: getNestedValue({user: {name: 'John'}}, 'user.name') returns 'John'.
@@ -9824,7 +9825,7 @@ function identityAudienceAllowed(audience, patterns) {
9824
9825
  return HOSTNAME_LABEL.test(label);
9825
9826
  });
9826
9827
  }
9827
- // ../shared/dist/chunk-CL2Drp2Y.mjs
9828
+ // ../shared/dist/chunk-D0Rc89Pf.mjs
9828
9829
  function extractSecretReferences(template) {
9829
9830
  const keys = /* @__PURE__ */ new Set();
9830
9831
  let match;
@@ -11671,7 +11672,7 @@ object$4({
11671
11672
  schemaTokens: number$2().int().min(0).optional(),
11672
11673
  passes: number$2().int().min(0).optional()
11673
11674
  });
11674
- // ../shared/dist/chunk-BKBbdDsl.mjs
11675
+ // ../shared/dist/chunk-B1k7UGsl.mjs
11675
11676
  const voiceInterruptionModeSchema = _enum([
11676
11677
  "none",
11677
11678
  "cancel",
@@ -12097,6 +12098,11 @@ const runtimeToolHiddenParameterNamesSchema = array(string$2().min(1, "hiddenPar
12097
12098
  message: reservedHiddenParameterNameMessage(name)
12098
12099
  });
12099
12100
  }));
12101
+ /** Identity roots only the host may fill in a tool call; a tool naming one never takes it from the model (#8503). */
12102
+ const HOST_IDENTITY_TOOL_ROOTS = ["_endUser", "_tenant"];
12103
+ /** Non-identity system roots a tool may name in an external template or as a parameter (`{{_conversation.id}}`). */
12104
+ const HOST_SYSTEM_TOOL_ROOTS = ["_conversation"];
12105
+ [...HOST_IDENTITY_TOOL_ROOTS, ...HOST_SYSTEM_TOOL_ROOTS];
12100
12106
  /** The `mergeStrategy` used when a channel omits one. */
12101
12107
  const AGENT_STATE_DEFAULT_MERGE_STRATEGY = "merge";
12102
12108
  /**
@@ -14268,7 +14274,7 @@ const makeNestedStepEnvelope = (type, configSchema) => object$4({
14268
14274
  * Type annotation is z.ZodType<ContextStep>; a documentation contract, not a data-flow guarantee.
14269
14275
  */
14270
14276
  const contextStepSchema = discriminatedUnion("type", Object.entries(sharedStepConfigSchemas).map(([type, configSchema]) => makeNestedStepEnvelope(type, configSchema)));
14271
- // ../shared/dist/chunk-DJMWTgFP.mjs
14277
+ // ../shared/dist/tool-name-sanitize.mjs
14272
14278
  /**
14273
14279
  * The AI-SDK tool-name sanitizer, as a dependency-free leaf.
14274
14280
  * Canonical home: the rule is enforced in three places that cannot all import model-execution.
@@ -14297,7 +14303,7 @@ function modelVisibleToolName(toolId) {
14297
14303
  function toolNamesCollideForAiSdk(left, right) {
14298
14304
  return sanitizeToolNameForAiSdk(left) === sanitizeToolNameForAiSdk(right);
14299
14305
  }
14300
- // ../shared/dist/chunk-qMrWcT2m.mjs
14306
+ // ../shared/dist/chunk-BiZ25Ayv.mjs
14301
14307
  /**
14302
14308
  * The reserved model-facing name of the agent state write tool
14303
14309
  * (`packages/runtime/src/engine/state-write-tool.ts`). The model is told to call
@@ -15227,7 +15233,7 @@ object$4({
15227
15233
  externalId: string$2().min(1).max(500).optional().describe("The conversation id in the source system. Re-creating with the same system and externalId returns the existing conversation with imported: false instead of a duplicate."),
15228
15234
  importedAt: string$2().datetime({ offset: true }).optional()
15229
15235
  });
15230
- // ../shared/dist/chunk-BJzjymMT.mjs
15236
+ // ../shared/dist/chunk-DPi-TibD.mjs
15231
15237
  /** Public schedule knobs shared by canonical, product-surface and FPO schedule writes. */
15232
15238
  const scheduleExecutionOptionsSchema = object$4({
15233
15239
  chunkSize: number$2().int().min(1).max(250).optional(),
@@ -26340,7 +26346,7 @@ function loadBrandConfig(env) {
26340
26346
  }
26341
26347
  loadBrandConfig();
26342
26348
  BRAND_CONFIGS[DEFAULT_BRAND_NAME];
26343
- // ../shared/dist/chunk-_tv2jbfe.mjs
26349
+ // ../shared/dist/chunk-C2OV6xD6.mjs
26344
26350
  const ARCHITECTURE_PREVIEW_SURFACE_TYPES = [
26345
26351
  "chat",
26346
26352
  "api",
@@ -56992,7 +56998,7 @@ const i$1 = `function(ctx) {
56992
56998
  } catch (e) { return null; }
56993
56999
  return null;
56994
57000
  }`;
56995
- const a = `(action: any, context: any) => {
57001
+ const a$1 = `(action: any, context: any) => {
56996
57002
  if (action.type !== 'nav_then_click') return;
56997
57003
  const payload = action.payload || action.raw || {};
56998
57004
  const url = payload?.page;
@@ -57010,7 +57016,7 @@ const a = `(action: any, context: any) => {
57010
57016
  window.location.href = targetUrl;
57011
57017
  return { handled: true, displayText: text };
57012
57018
  }`;
57013
- const o$2 = `function(action, context) {
57019
+ const o$1 = `function(action, context) {
57014
57020
  if (action.type !== 'nav_then_click') return;
57015
57021
  var payload = action.payload || action.raw || {};
57016
57022
  var url = payload.page;
@@ -57359,7 +57365,7 @@ function T$2(e, t) {
57359
57365
  if (parsed.action === 'message') return parsed.text || '';
57360
57366
  if (parsed.action === 'message_and_click') return parsed.text || 'Processing...';
57361
57367
  return parsed.text || null;
57362
- }),`)), n?.actionParsers ? (i.push(` // Action parsers (custom merged with defaults)`), i.push(` actionParsers: [...(${n.actionParsers}), defaultJsonActionParser,`), i.push(` // Built-in parser for markdown-wrapped JSON`), i.push(` ${r$1}`), i.push(` ],`)) : (i.push(` // Action parsers to detect JSON actions in responses`), i.push(` actionParsers: [`), i.push(` defaultJsonActionParser,`), i.push(` // Parser for markdown-wrapped JSON`), i.push(` ${r$1}`), i.push(` ],`)), n?.actionHandlers ? (i.push(` // Action handlers (custom merged with defaults)`), i.push(` actionHandlers: [...(${n.actionHandlers}),`), i.push(` defaultActionHandlers.message,`), i.push(` defaultActionHandlers.messageAndClick,`), i.push(` // Built-in handler for nav_then_click action`), i.push(` ${a}`), i.push(` ],`)) : (i.push(` // Action handlers for navigation and other actions`), i.push(` actionHandlers: [`), i.push(` defaultActionHandlers.message,`), i.push(` defaultActionHandlers.messageAndClick,`), i.push(` // Handler for nav_then_click action`), i.push(` ${a}`), i.push(` ],`)), n?.postprocessMessage ? i.push(` postprocessMessage: ${n.postprocessMessage},`) : i.push(` postprocessMessage: ({ text }) => markdownPostprocessor(text),`), n?.requestMiddleware ? (i.push(` // Request middleware (custom merged with DOM context)`), i.push(` requestMiddleware: ({ payload, config }) => {`), i.push(` const customResult = (${n.requestMiddleware})({ payload, config });`), i.push(` const merged = customResult || payload;`), i.push(` return {`), i.push(` ...merged,`), i.push(` metadata: { ...merged.metadata, ...collectDOMContext() }`), i.push(` };`), i.push(` }`)) : (i.push(` requestMiddleware: ({ payload }) => {`), i.push(` return {`), i.push(` ...payload,`), i.push(` metadata: collectDOMContext()`), i.push(` };`), i.push(` }`)), i.push(` }`), i.push(` });`), i.push(``), i.push(` // Save state on message events`), i.push(` const handleMessage = () => {`), i.push(` const session = handle?.getSession?.();`), i.push(` if (session) {`), i.push(` localStorage.setItem(STORAGE_KEY, JSON.stringify({`), i.push(` messages: session.messages,`), i.push(` timestamp: new Date().toISOString()`), i.push(` }));`), i.push(` }`), i.push(` };`), i.push(``), i.push(` // Clear state on clear chat`), i.push(` const handleClearChat = () => {`), i.push(` localStorage.removeItem(STORAGE_KEY);`), i.push(` localStorage.removeItem(PROCESSED_ACTIONS_KEY);`), i.push(` };`), i.push(``), i.push(` window.addEventListener('persona:message', handleMessage);`), i.push(` window.addEventListener('persona:clear-chat', handleClearChat);`), i.push(``), i.push(` // Cleanup on unmount`), i.push(` return () => {`), i.push(` window.removeEventListener('persona:message', handleMessage);`), i.push(` window.removeEventListener('persona:clear-chat', handleClearChat);`), i.push(` if (handle) {`), i.push(` handle.destroy();`), i.push(` }`), i.push(` };`), i.push(` }, []);`), i.push(``), i.push(` return null; // Widget injects itself into the DOM`), i.push(`}`), i.push(``), i.push(`// Usage: Collects DOM context for AI-powered navigation`), i.push(`// Features:`), i.push(`// - Extracts page elements (products, buttons, links)`), i.push(`// - Persists chat history across page loads`), i.push(`// - Handles navigation actions (nav_then_click)`), i.push(`// - Processes structured JSON actions from AI`), i.push(`//`), i.push(`// Example usage in Next.js:`), i.push(`// import { ChatWidgetAdvanced } from './components/ChatWidgetAdvanced';`), i.push(`//`), i.push(`// export default function RootLayout({ children }) {`), i.push(`// return (`), i.push(`// <html lang="en">`), i.push(`// <body>`), i.push(`// {children}`), i.push(`// <ChatWidgetAdvanced />`), i.push(`// </body>`), i.push(`// </html>`), i.push(`// );`), i.push(`// }`), i.join(`
57368
+ }),`)), n?.actionParsers ? (i.push(` // Action parsers (custom merged with defaults)`), i.push(` actionParsers: [...(${n.actionParsers}), defaultJsonActionParser,`), i.push(` // Built-in parser for markdown-wrapped JSON`), i.push(` ${r$1}`), i.push(` ],`)) : (i.push(` // Action parsers to detect JSON actions in responses`), i.push(` actionParsers: [`), i.push(` defaultJsonActionParser,`), i.push(` // Parser for markdown-wrapped JSON`), i.push(` ${r$1}`), i.push(` ],`)), n?.actionHandlers ? (i.push(` // Action handlers (custom merged with defaults)`), i.push(` actionHandlers: [...(${n.actionHandlers}),`), i.push(` defaultActionHandlers.message,`), i.push(` defaultActionHandlers.messageAndClick,`), i.push(` // Built-in handler for nav_then_click action`), i.push(` ${a$1}`), i.push(` ],`)) : (i.push(` // Action handlers for navigation and other actions`), i.push(` actionHandlers: [`), i.push(` defaultActionHandlers.message,`), i.push(` defaultActionHandlers.messageAndClick,`), i.push(` // Handler for nav_then_click action`), i.push(` ${a$1}`), i.push(` ],`)), n?.postprocessMessage ? i.push(` postprocessMessage: ${n.postprocessMessage},`) : i.push(` postprocessMessage: ({ text }) => markdownPostprocessor(text),`), n?.requestMiddleware ? (i.push(` // Request middleware (custom merged with DOM context)`), i.push(` requestMiddleware: ({ payload, config }) => {`), i.push(` const customResult = (${n.requestMiddleware})({ payload, config });`), i.push(` const merged = customResult || payload;`), i.push(` return {`), i.push(` ...merged,`), i.push(` metadata: { ...merged.metadata, ...collectDOMContext() }`), i.push(` };`), i.push(` }`)) : (i.push(` requestMiddleware: ({ payload }) => {`), i.push(` return {`), i.push(` ...payload,`), i.push(` metadata: collectDOMContext()`), i.push(` };`), i.push(` }`)), i.push(` }`), i.push(` });`), i.push(``), i.push(` // Save state on message events`), i.push(` const handleMessage = () => {`), i.push(` const session = handle?.getSession?.();`), i.push(` if (session) {`), i.push(` localStorage.setItem(STORAGE_KEY, JSON.stringify({`), i.push(` messages: session.messages,`), i.push(` timestamp: new Date().toISOString()`), i.push(` }));`), i.push(` }`), i.push(` };`), i.push(``), i.push(` // Clear state on clear chat`), i.push(` const handleClearChat = () => {`), i.push(` localStorage.removeItem(STORAGE_KEY);`), i.push(` localStorage.removeItem(PROCESSED_ACTIONS_KEY);`), i.push(` };`), i.push(``), i.push(` window.addEventListener('persona:message', handleMessage);`), i.push(` window.addEventListener('persona:clear-chat', handleClearChat);`), i.push(``), i.push(` // Cleanup on unmount`), i.push(` return () => {`), i.push(` window.removeEventListener('persona:message', handleMessage);`), i.push(` window.removeEventListener('persona:clear-chat', handleClearChat);`), i.push(` if (handle) {`), i.push(` handle.destroy();`), i.push(` }`), i.push(` };`), i.push(` }, []);`), i.push(``), i.push(` return null; // Widget injects itself into the DOM`), i.push(`}`), i.push(``), i.push(`// Usage: Collects DOM context for AI-powered navigation`), i.push(`// Features:`), i.push(`// - Extracts page elements (products, buttons, links)`), i.push(`// - Persists chat history across page loads`), i.push(`// - Handles navigation actions (nav_then_click)`), i.push(`// - Processes structured JSON actions from AI`), i.push(`//`), i.push(`// Example usage in Next.js:`), i.push(`// import { ChatWidgetAdvanced } from './components/ChatWidgetAdvanced';`), i.push(`//`), i.push(`// export default function RootLayout({ children }) {`), i.push(`// return (`), i.push(`// <html lang="en">`), i.push(`// <body>`), i.push(`// {children}`), i.push(`// <ChatWidgetAdvanced />`), i.push(`// </body>`), i.push(`// </html>`), i.push(`// );`), i.push(`// }`), i.join(`
57363
57369
  `);
57364
57370
  }
57365
57371
  function E$2(e) {
@@ -57542,7 +57548,7 @@ function k$2(t, n) {
57542
57548
  if (parsed.action === 'message') return parsed.text || '';
57543
57549
  if (parsed.action === 'message_and_click') return parsed.text || 'Processing...';
57544
57550
  return parsed.text || null;
57545
- });`), a.push(` };`)), a.push(``), r?.actionParsers ? (a.push(` // Action parsers (custom merged with defaults)`), a.push(` var customParsers = ${r.actionParsers};`), a.push(` widgetConfig.actionParsers = customParsers.concat([`), a.push(` agentWidget.defaultJsonActionParser,`), a.push(` ${i$1}`), a.push(` ]);`)) : (a.push(` // Action parsers to detect JSON actions in responses`), a.push(` widgetConfig.actionParsers = [`), a.push(` agentWidget.defaultJsonActionParser,`), a.push(` ${i$1}`), a.push(` ];`)), a.push(``), r?.actionHandlers ? (a.push(` // Action handlers (custom merged with defaults)`), a.push(` var customHandlers = ${r.actionHandlers};`), a.push(` widgetConfig.actionHandlers = customHandlers.concat([`), a.push(` agentWidget.defaultActionHandlers.message,`), a.push(` agentWidget.defaultActionHandlers.messageAndClick,`), a.push(` ${o$2}`), a.push(` ]);`)) : (a.push(` // Action handlers for navigation and other actions`), a.push(` widgetConfig.actionHandlers = [`), a.push(` agentWidget.defaultActionHandlers.message,`), a.push(` agentWidget.defaultActionHandlers.messageAndClick,`), a.push(` ${o$2}`), a.push(` ];`)), a.push(``), r?.requestMiddleware ? (a.push(` // Request middleware (custom merged with DOM context)`), a.push(` widgetConfig.requestMiddleware = function(ctx) {`), a.push(` var customResult = (${r.requestMiddleware})(ctx);`), a.push(` var merged = customResult || ctx.payload;`), a.push(` return Object.assign({}, merged, { metadata: Object.assign({}, merged.metadata, domContextProvider()) });`), a.push(` };`)) : (a.push(` // Send DOM context with each request`), a.push(` widgetConfig.requestMiddleware = function(ctx) {`), a.push(` return Object.assign({}, ctx.payload, { metadata: domContextProvider() });`), a.push(` };`)), a.push(``), r?.postprocessMessage ? a.push(` widgetConfig.postprocessMessage = ${r.postprocessMessage};`) : (a.push(` // Markdown postprocessor`), a.push(` widgetConfig.postprocessMessage = function(ctx) {`), a.push(` return agentWidget.markdownPostprocessor(ctx.text);`), a.push(` };`)), a.push(``), (r?.onFeedback || r?.onCopy) && (a.push(` // Message action callbacks`), a.push(` widgetConfig.messageActions = widgetConfig.messageActions || {};`), r?.onFeedback && a.push(` widgetConfig.messageActions.onFeedback = ${r.onFeedback};`), r?.onCopy && a.push(` widgetConfig.messageActions.onCopy = ${r.onCopy};`), a.push(``)), a.push(` return widgetConfig;`, ` };`, ``, ` // Initialize widget`, ` var init = function() {`, ` var agentWidget = window.AgentWidget;`, ` if (!agentWidget) {`, ` console.error('AgentWidget not loaded');`, ` return;`, ` }`, ``, ` var widgetConfig = createWidgetConfig(agentWidget);`, ``, ` // Load saved state`, ` var savedState = localStorage.getItem(STORAGE_KEY);`, ` if (savedState) {`, ` try {`, ` var parsed = JSON.parse(savedState);`, ` widgetConfig.initialMessages = parsed.messages || [];`, ` } catch (e) {`, ` console.error('Failed to load saved state:', e);`, ` }`, ` }`, ``, ` // Initialize widget`, ` var handle = agentWidget.initAgentWidget({`, ` target: '${b$2(n)}',`, ` useShadowDom: false,`, ...n?.windowKey ? [` windowKey: '${n.windowKey}',`] : [], ` config: widgetConfig`, ` });`, ``, ` // Save state on message events`, ` window.addEventListener('persona:message', function() {`, ` var session = handle.getSession ? handle.getSession() : null;`, ` if (session) {`, ` localStorage.setItem(STORAGE_KEY, JSON.stringify({`, ` messages: session.messages,`, ` timestamp: new Date().toISOString()`, ` }));`, ` }`, ` });`, ``, ` // Clear state on clear chat`, ` window.addEventListener('persona:clear-chat', function() {`, ` localStorage.removeItem(STORAGE_KEY);`, ` localStorage.removeItem(PROCESSED_ACTIONS_KEY);`, ` });`, ` };`, ``, ` // Wait for framework hydration to complete (Next.js, Nuxt, etc.)`, ` // This prevents the framework from removing dynamically added CSS during reconciliation`, ` var waitForHydration = function(callback) {`, ` var executed = false;`, ` `, ` var execute = function() {`, ` if (executed) return;`, ` executed = true;`, ` callback();`, ` };`, ``, ` var afterDom = function() {`, ` // Strategy 1: Use requestIdleCallback if available (best for detecting idle after hydration)`, ` if (typeof requestIdleCallback !== 'undefined') {`, ` requestIdleCallback(function() {`, ` // Double requestAnimationFrame ensures at least one full paint cycle completed`, ` requestAnimationFrame(function() {`, ` requestAnimationFrame(execute);`, ` });`, ` }, { timeout: 3000 }); // Max wait 3 seconds, then proceed anyway`, ` } else {`, ` // Strategy 2: Fallback for Safari (no requestIdleCallback)`, ` // 300ms is typically enough for hydration on most pages`, ` setTimeout(execute, 300);`, ` }`, ` };`, ``, ` if (document.readyState === 'loading') {`, ` document.addEventListener('DOMContentLoaded', afterDom);`, ` } else {`, ` // DOM already ready, but still wait for potential hydration`, ` afterDom();`, ` }`, ` };`, ``, ` // Boot sequence: wait for hydration, then load CSS and JS, then initialize`, ` // This prevents Next.js/Nuxt/etc. from removing dynamically added CSS during reconciliation`, ` waitForHydration(function() {`, ` loadCSS();`, ` loadJS(function() {`, ` init();`, ` });`, ` });`, `})();`, `<\/script>`), a.join(`
57551
+ });`), a.push(` };`)), a.push(``), r?.actionParsers ? (a.push(` // Action parsers (custom merged with defaults)`), a.push(` var customParsers = ${r.actionParsers};`), a.push(` widgetConfig.actionParsers = customParsers.concat([`), a.push(` agentWidget.defaultJsonActionParser,`), a.push(` ${i$1}`), a.push(` ]);`)) : (a.push(` // Action parsers to detect JSON actions in responses`), a.push(` widgetConfig.actionParsers = [`), a.push(` agentWidget.defaultJsonActionParser,`), a.push(` ${i$1}`), a.push(` ];`)), a.push(``), r?.actionHandlers ? (a.push(` // Action handlers (custom merged with defaults)`), a.push(` var customHandlers = ${r.actionHandlers};`), a.push(` widgetConfig.actionHandlers = customHandlers.concat([`), a.push(` agentWidget.defaultActionHandlers.message,`), a.push(` agentWidget.defaultActionHandlers.messageAndClick,`), a.push(` ${o$1}`), a.push(` ]);`)) : (a.push(` // Action handlers for navigation and other actions`), a.push(` widgetConfig.actionHandlers = [`), a.push(` agentWidget.defaultActionHandlers.message,`), a.push(` agentWidget.defaultActionHandlers.messageAndClick,`), a.push(` ${o$1}`), a.push(` ];`)), a.push(``), r?.requestMiddleware ? (a.push(` // Request middleware (custom merged with DOM context)`), a.push(` widgetConfig.requestMiddleware = function(ctx) {`), a.push(` var customResult = (${r.requestMiddleware})(ctx);`), a.push(` var merged = customResult || ctx.payload;`), a.push(` return Object.assign({}, merged, { metadata: Object.assign({}, merged.metadata, domContextProvider()) });`), a.push(` };`)) : (a.push(` // Send DOM context with each request`), a.push(` widgetConfig.requestMiddleware = function(ctx) {`), a.push(` return Object.assign({}, ctx.payload, { metadata: domContextProvider() });`), a.push(` };`)), a.push(``), r?.postprocessMessage ? a.push(` widgetConfig.postprocessMessage = ${r.postprocessMessage};`) : (a.push(` // Markdown postprocessor`), a.push(` widgetConfig.postprocessMessage = function(ctx) {`), a.push(` return agentWidget.markdownPostprocessor(ctx.text);`), a.push(` };`)), a.push(``), (r?.onFeedback || r?.onCopy) && (a.push(` // Message action callbacks`), a.push(` widgetConfig.messageActions = widgetConfig.messageActions || {};`), r?.onFeedback && a.push(` widgetConfig.messageActions.onFeedback = ${r.onFeedback};`), r?.onCopy && a.push(` widgetConfig.messageActions.onCopy = ${r.onCopy};`), a.push(``)), a.push(` return widgetConfig;`, ` };`, ``, ` // Initialize widget`, ` var init = function() {`, ` var agentWidget = window.AgentWidget;`, ` if (!agentWidget) {`, ` console.error('AgentWidget not loaded');`, ` return;`, ` }`, ``, ` var widgetConfig = createWidgetConfig(agentWidget);`, ``, ` // Load saved state`, ` var savedState = localStorage.getItem(STORAGE_KEY);`, ` if (savedState) {`, ` try {`, ` var parsed = JSON.parse(savedState);`, ` widgetConfig.initialMessages = parsed.messages || [];`, ` } catch (e) {`, ` console.error('Failed to load saved state:', e);`, ` }`, ` }`, ``, ` // Initialize widget`, ` var handle = agentWidget.initAgentWidget({`, ` target: '${b$2(n)}',`, ` useShadowDom: false,`, ...n?.windowKey ? [` windowKey: '${n.windowKey}',`] : [], ` config: widgetConfig`, ` });`, ``, ` // Save state on message events`, ` window.addEventListener('persona:message', function() {`, ` var session = handle.getSession ? handle.getSession() : null;`, ` if (session) {`, ` localStorage.setItem(STORAGE_KEY, JSON.stringify({`, ` messages: session.messages,`, ` timestamp: new Date().toISOString()`, ` }));`, ` }`, ` });`, ``, ` // Clear state on clear chat`, ` window.addEventListener('persona:clear-chat', function() {`, ` localStorage.removeItem(STORAGE_KEY);`, ` localStorage.removeItem(PROCESSED_ACTIONS_KEY);`, ` });`, ` };`, ``, ` // Wait for framework hydration to complete (Next.js, Nuxt, etc.)`, ` // This prevents the framework from removing dynamically added CSS during reconciliation`, ` var waitForHydration = function(callback) {`, ` var executed = false;`, ` `, ` var execute = function() {`, ` if (executed) return;`, ` executed = true;`, ` callback();`, ` };`, ``, ` var afterDom = function() {`, ` // Strategy 1: Use requestIdleCallback if available (best for detecting idle after hydration)`, ` if (typeof requestIdleCallback !== 'undefined') {`, ` requestIdleCallback(function() {`, ` // Double requestAnimationFrame ensures at least one full paint cycle completed`, ` requestAnimationFrame(function() {`, ` requestAnimationFrame(execute);`, ` });`, ` }, { timeout: 3000 }); // Max wait 3 seconds, then proceed anyway`, ` } else {`, ` // Strategy 2: Fallback for Safari (no requestIdleCallback)`, ` // 300ms is typically enough for hydration on most pages`, ` setTimeout(execute, 300);`, ` }`, ` };`, ``, ` if (document.readyState === 'loading') {`, ` document.addEventListener('DOMContentLoaded', afterDom);`, ` } else {`, ` // DOM already ready, but still wait for potential hydration`, ` afterDom();`, ` }`, ` };`, ``, ` // Boot sequence: wait for hydration, then load CSS and JS, then initialize`, ` // This prevents Next.js/Nuxt/etc. from removing dynamically added CSS during reconciliation`, ` waitForHydration(function() {`, ` loadCSS();`, ` loadJS(function() {`, ` init();`, ` });`, ` });`, `})();`, `<\/script>`), a.join(`
57546
57552
  `);
57547
57553
  }
57548
57554
  // src/lib/persona-snippets.ts
@@ -62790,7 +62796,7 @@ function r(e) {
62790
62796
  return e.replace(t, ``).replace(/\r\n/g, `
62791
62797
  `).replace(n, ``);
62792
62798
  }
62793
- function o$1(e) {
62799
+ function o(e) {
62794
62800
  let t = e.endsWith(`==`) ? 2 : +!!e.endsWith(`=`);
62795
62801
  return Math.max(0, Math.floor(e.length * 3 / 4) - t);
62796
62802
  }
@@ -62804,12 +62810,12 @@ function c$1(e, t, n) {
62804
62810
  case `image`:
62805
62811
  case `audio`: {
62806
62812
  let t = String(e.mimeType ?? `application/octet-stream`);
62807
- return i ? `[${e.type} ${t} saved to ${i.path}]` : `[${e.type} ${t}, ${s$1(o$1(String(e.data ?? ``)))}; use --save <dir> to write it]`;
62813
+ return i ? `[${e.type} ${t} saved to ${i.path}]` : `[${e.type} ${t}, ${s$1(o(String(e.data ?? ``)))}; use --save <dir> to write it]`;
62808
62814
  }
62809
62815
  case `resource_link`: return `${e.name ? `${r(String(e.name))}: ` : ``}${r(String(e.uri))}`;
62810
62816
  case `resource`: {
62811
62817
  let t = e.resource ?? {};
62812
- return typeof t.text == `string` ? n ? t.text : r(t.text) : i ? `[resource ${t.uri ?? ``} saved to ${i.path}]` : `[resource ${r(String(t.uri ?? ``))}${t.blob ? `, ${s$1(o$1(t.blob))}` : ``}]`;
62818
+ return typeof t.text == `string` ? n ? t.text : r(t.text) : i ? `[resource ${t.uri ?? ``} saved to ${i.path}]` : `[resource ${r(String(t.uri ?? ``))}${t.blob ? `, ${s$1(o(t.blob))}` : ``}]`;
62813
62819
  }
62814
62820
  default: return `[${r(String(e.type))} content]`;
62815
62821
  }
@@ -62874,7 +62880,7 @@ function h$2(e, t) {
62874
62880
  }
62875
62881
  }
62876
62882
  }
62877
- // ../mcp-cli/dist/chunk-Ce22LqPV.mjs
62883
+ // ../mcp-cli/dist/chunk-CMnHEuio.mjs
62878
62884
  const i = /* @__PURE__ */ new Set([
62879
62885
  `approvals`,
62880
62886
  `auth`,
@@ -62894,12 +62900,13 @@ const i = /* @__PURE__ */ new Set([
62894
62900
  `whoami`,
62895
62901
  `__complete`
62896
62902
  ]);
62897
- function o(e) {
62903
+ [...i];
62904
+ function s(e) {
62898
62905
  return e.split(/\s+/).filter(Boolean);
62899
62906
  }
62900
- function s(e, t) {
62907
+ function c(e, t) {
62901
62908
  if (t?.group || t?.name) {
62902
- let n = t.group ? o(t.group) : [], r = t.name ?? (e.name.includes(`.`) ? e.name.split(`.`).filter(Boolean).at(-1) ?? e.name : e.name);
62909
+ let n = t.group ? s(t.group) : [], r = t.name ?? (e.name.includes(`.`) ? e.name.split(`.`).filter(Boolean).at(-1) ?? e.name : e.name);
62903
62910
  return [...n, r];
62904
62911
  }
62905
62912
  if (e.name.includes(`.`)) {
@@ -62908,87 +62915,87 @@ function s(e, t) {
62908
62915
  }
62909
62916
  return [e.name];
62910
62917
  }
62911
- const c = (e) => e.join(`\0`);
62912
- function l(e, t = {}) {
62913
- let r = [], a = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), u = (e, t, n) => {
62918
+ const l = (e) => e.join(`\0`);
62919
+ function u(e, t = {}, r = i) {
62920
+ let a = [], o = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), d = (e, t, n) => {
62914
62921
  if (t.length === 0 || t.some((e) => e === ``)) return;
62915
- let r = l.get(c(t)) ?? [];
62922
+ let r = u.get(l(t)) ?? [];
62916
62923
  r.push({
62917
62924
  entry: e,
62918
62925
  priority: n
62919
- }), l.set(c(t), r);
62920
- }, d = /* @__PURE__ */ new Map();
62921
- for (let i of e) {
62922
- if (a.has(i.name)) continue;
62923
- let e = Object.prototype.hasOwnProperty.call(t, i.name) ? t[i.name] : void 0, c = s(i, e), l = {
62926
+ }), u.set(l(t), r);
62927
+ }, f = /* @__PURE__ */ new Map();
62928
+ for (let r of e) {
62929
+ if (o.has(r.name)) continue;
62930
+ let e = Object.prototype.hasOwnProperty.call(t, r.name) ? t[r.name] : void 0, i = c(r, e), l = {
62924
62931
  tool: e?.description ? {
62925
- ...i,
62932
+ ...r,
62926
62933
  description: e.description
62927
- } : i,
62928
- path: c,
62934
+ } : r,
62935
+ path: i,
62929
62936
  aliases: [],
62930
62937
  hidden: e?.hidden === !0,
62931
62938
  callOnly: !1,
62932
62939
  override: e
62933
62940
  };
62934
- r.push(l), a.set(i.name, l);
62935
- let f = [
62941
+ a.push(l), o.set(r.name, l);
62942
+ let u = [
62936
62943
  {
62937
- path: [i.name],
62944
+ path: [r.name],
62938
62945
  priority: 0
62939
62946
  },
62940
62947
  {
62941
- path: c,
62948
+ path: i,
62942
62949
  priority: 1
62943
62950
  },
62944
62951
  ...(e?.aliases ?? []).map((e) => ({
62945
- path: o(e),
62952
+ path: s(e),
62946
62953
  priority: 2
62947
62954
  })),
62948
62955
  {
62949
- path: c.map(e$1),
62956
+ path: i.map(e$1),
62950
62957
  priority: 3
62951
62958
  },
62952
62959
  {
62953
- path: [e$1(i.name)],
62960
+ path: [e$1(r.name)],
62954
62961
  priority: 3
62955
62962
  }
62956
62963
  ];
62957
- d.set(l, f);
62958
- for (let e of f) u(l, e.path, e.priority);
62964
+ f.set(l, u);
62965
+ for (let e of u) d(l, e.path, e.priority);
62959
62966
  }
62960
- let f = { children: /* @__PURE__ */ new Map() }, p = /* @__PURE__ */ new Map();
62961
- for (let [e, t] of d) {
62967
+ let p = { children: /* @__PURE__ */ new Map() }, m = /* @__PURE__ */ new Map();
62968
+ for (let [e, t] of f) {
62962
62969
  let n = /* @__PURE__ */ new Set();
62963
- for (let { path: r } of t) {
62964
- let t = c(r);
62965
- if (n.has(t) || r.length === 0 || (n.add(t), i.has(r[0]))) continue;
62966
- let a = l.get(t) ?? [], o = Math.min(...a.map((e) => e.priority)), s = a.filter((e) => e.priority === o), u = new Set(s.map((e) => e.entry));
62967
- if (u.size !== 1 || !u.has(e)) continue;
62968
- let d = f;
62969
- for (let e of r) {
62970
+ for (let { path: i } of t) {
62971
+ let t = l(i);
62972
+ if (n.has(t) || i.length === 0 || (n.add(t), r.has(i[0]))) continue;
62973
+ let a = u.get(t) ?? [], o = Math.min(...a.map((e) => e.priority)), s = a.filter((e) => e.priority === o), c = new Set(s.map((e) => e.entry));
62974
+ if (c.size !== 1 || !c.has(e)) continue;
62975
+ let d = p;
62976
+ for (let e of i) {
62970
62977
  let t = d.children.get(e);
62971
62978
  t || (t = { children: /* @__PURE__ */ new Map() }, d.children.set(e, t)), d = t;
62972
62979
  }
62973
62980
  d.entry = e;
62974
- let m = p.get(e) ?? [];
62975
- m.push(r), p.set(e, m);
62981
+ let f = m.get(e) ?? [];
62982
+ f.push(i), m.set(e, f);
62976
62983
  }
62977
62984
  }
62978
- for (let e of r) {
62979
- let t = p.get(e) ?? [], n = c(e.path), r = t.find((e) => c(e) === n) ?? t[0];
62980
- r ? (e.path = r, e.aliases = t.filter((e) => c(e) !== c(r))) : e.callOnly = !0;
62985
+ for (let e of a) {
62986
+ let t = m.get(e) ?? [], n = l(e.path), r = t.find((e) => l(e) === n) ?? t[0];
62987
+ r ? (e.path = r, e.aliases = t.filter((e) => l(e) !== l(r))) : e.callOnly = !0;
62981
62988
  }
62982
- let m = (e) => {
62983
- let t = f;
62989
+ let h = (e) => {
62990
+ let t = p;
62984
62991
  for (let n of e) if (t = t?.children.get(n), !t) return;
62985
62992
  return t;
62986
62993
  };
62987
62994
  return {
62988
- entries: r,
62989
- byToolName: a,
62995
+ entries: a,
62996
+ byToolName: o,
62990
62997
  resolve(e) {
62991
- let t = f, n = { kind: `none` }, r = [];
62998
+ let t = p, n = { kind: `none` }, r = [];
62992
62999
  for (let [i, a] of e.entries()) {
62993
63000
  let e = t.children.get(a);
62994
63001
  if (!e) break;
@@ -63005,37 +63012,37 @@ function l(e, t = {}) {
63005
63012
  } : n;
63006
63013
  },
63007
63014
  topLevelWords() {
63008
- return [...f.children.keys()].sort();
63015
+ return [...p.children.keys()].sort();
63009
63016
  },
63010
63017
  childrenOf(e) {
63011
- return [...m(e)?.children.keys() ?? []].sort();
63018
+ return [...h(e)?.children.keys() ?? []].sort();
63012
63019
  }
63013
63020
  };
63014
63021
  }
63015
- function u(e) {
63022
+ function d(e) {
63016
63023
  return typeof e == `object` && !!e && !Array.isArray(e);
63017
63024
  }
63018
- function d(e) {
63025
+ function f(e) {
63019
63026
  return decodeURIComponent(e).replace(/~1/g, `/`).replace(/~0/g, `~`);
63020
63027
  }
63021
- function f(e, t) {
63028
+ function p$1(e, t) {
63022
63029
  if (t === `#`) return e;
63023
63030
  if (!t.startsWith(`#/`)) return;
63024
63031
  let n = e;
63025
63032
  for (let e of t.slice(2).split(`/`)) {
63026
- if (!u(n)) return;
63027
- n = n[d(e)];
63033
+ if (!d(n)) return;
63034
+ n = n[f(e)];
63028
63035
  }
63029
- return u(n) ? n : void 0;
63036
+ return d(n) ? n : void 0;
63030
63037
  }
63031
- var p$1 = class extends Error {};
63032
- function m$1(e, t, n, r) {
63033
- if (n.length > 32) throw new p$1();
63038
+ var m$1 = class extends Error {};
63039
+ function h$1(e, t, n, r) {
63040
+ if (n.length > 32) throw new m$1();
63034
63041
  let i = t;
63035
63042
  if (typeof i.$ref == `string`) {
63036
63043
  let t = i.$ref;
63037
- if (n.includes(t)) throw new p$1();
63038
- let a = f(e, t);
63044
+ if (n.includes(t)) throw new m$1();
63045
+ let a = p$1(e, t);
63039
63046
  if (!a) return {
63040
63047
  ...i,
63041
63048
  $ref: void 0
@@ -63043,39 +63050,39 @@ function m$1(e, t, n, r) {
63043
63050
  r.add(t);
63044
63051
  let { $ref: o, ...s } = i;
63045
63052
  i = {
63046
- ...m$1(e, a, [...n, t], r),
63053
+ ...h$1(e, a, [...n, t], r),
63047
63054
  ...s
63048
63055
  };
63049
63056
  }
63050
63057
  if (Array.isArray(i.allOf)) {
63051
63058
  let { allOf: t, ...a } = i, o = {};
63052
- for (let i of t) u(i) && (o = h$1(o, m$1(e, i, n, r)));
63053
- i = h$1(o, a);
63059
+ for (let i of t) d(i) && (o = g$1(o, h$1(e, i, n, r)));
63060
+ i = g$1(o, a);
63054
63061
  }
63055
63062
  return i;
63056
63063
  }
63057
- function h$1(e, t) {
63064
+ function g$1(e, t) {
63058
63065
  let n = {
63059
63066
  ...e,
63060
63067
  ...t
63061
63068
  };
63062
- (u(e.properties) || u(t.properties)) && (n.properties = {
63063
- ...u(e.properties) ? e.properties : {},
63064
- ...u(t.properties) ? t.properties : {}
63069
+ (d(e.properties) || d(t.properties)) && (n.properties = {
63070
+ ...d(e.properties) ? e.properties : {},
63071
+ ...d(t.properties) ? t.properties : {}
63065
63072
  });
63066
63073
  let r = [...Array.isArray(e.required) ? e.required : [], ...Array.isArray(t.required) ? t.required : []];
63067
63074
  return r.length > 0 && (n.required = [...new Set(r)]), n;
63068
63075
  }
63069
- function g$1(e, t, n = []) {
63076
+ function _$1(e, t, n = []) {
63070
63077
  let r = /* @__PURE__ */ new Set();
63071
63078
  try {
63072
63079
  return {
63073
- schema: m$1(e, t, n, r),
63080
+ schema: h$1(e, t, n, r),
63074
63081
  recursive: !1,
63075
63082
  ancestors: [...n, ...r]
63076
63083
  };
63077
63084
  } catch (e) {
63078
- if (e instanceof p$1) return {
63085
+ if (e instanceof m$1) return {
63079
63086
  schema: t,
63080
63087
  recursive: !0,
63081
63088
  ancestors: n
@@ -63083,16 +63090,16 @@ function g$1(e, t, n = []) {
63083
63090
  throw e;
63084
63091
  }
63085
63092
  }
63086
- function _$1(e) {
63093
+ function v$1(e) {
63087
63094
  return typeof e.type == `string` ? [e.type] : Array.isArray(e.type) ? e.type.filter((e) => typeof e == `string`) : [];
63088
63095
  }
63089
63096
  function ee(e) {
63090
63097
  return e.contentEncoding === `base64` || e.format === `binary` || e.format === `byte` || typeof e.contentMediaType == `string`;
63091
63098
  }
63092
- function v$1(e) {
63093
- return u(e) && (e.type === `null` || Array.isArray(e.type) && e.type.length === 1 && e.type[0] === `null`);
63099
+ function y$1(e) {
63100
+ return d(e) && (e.type === `null` || Array.isArray(e.type) && e.type.length === 1 && e.type[0] === `null`);
63094
63101
  }
63095
- function y$1(e, t, n) {
63102
+ function b$1(e, t, n) {
63096
63103
  return {
63097
63104
  kind: t,
63098
63105
  schema: e,
@@ -63105,13 +63112,13 @@ function y$1(e, t, n) {
63105
63112
  format: typeof e.format == `string` ? e.format : void 0
63106
63113
  };
63107
63114
  }
63108
- const b$1 = [
63115
+ const x$1 = [
63109
63116
  `integer`,
63110
63117
  `number`,
63111
63118
  `boolean`,
63112
63119
  `string`
63113
63120
  ];
63114
- function x$1(e) {
63121
+ function S$1(e) {
63115
63122
  if (e.kind === `integer` || e.kind === `number` || e.kind === `boolean` || e.kind === `string`) return e.kind;
63116
63123
  if (e.kind === `binary`) return `string`;
63117
63124
  if (e.kind === `enum` || e.kind === `const`) {
@@ -63122,28 +63129,28 @@ function x$1(e) {
63122
63129
  if (t.every((e) => typeof e == `boolean`)) return `boolean`;
63123
63130
  }
63124
63131
  }
63125
- function S$1(e, t, n = []) {
63126
- let { schema: r, recursive: i, ancestors: a } = g$1(e, t, n);
63127
- if (i) return y$1(r, `json`, !1);
63128
- let o = r.nullable === !0, s = _$1(r);
63132
+ function C$1(e, t, n = []) {
63133
+ let { schema: r, recursive: i, ancestors: a } = _$1(e, t, n);
63134
+ if (i) return b$1(r, `json`, !1);
63135
+ let o = r.nullable === !0, s = v$1(r);
63129
63136
  s.includes(`null`) && (o = !0);
63130
63137
  let c = s.filter((e) => e !== `null`);
63131
63138
  if (Object.prototype.hasOwnProperty.call(r, `const`)) return {
63132
- ...y$1(r, `const`, o),
63139
+ ...b$1(r, `const`, o),
63133
63140
  constValue: r.const
63134
63141
  };
63135
63142
  if (Array.isArray(r.enum)) {
63136
63143
  let e = r.enum.filter((e) => e !== null);
63137
63144
  return e.length !== r.enum.length && (o = !0), {
63138
- ...y$1(r, `enum`, o),
63145
+ ...b$1(r, `enum`, o),
63139
63146
  enumValues: e
63140
63147
  };
63141
63148
  }
63142
63149
  let l = Array.isArray(r.anyOf) ? r.anyOf : Array.isArray(r.oneOf) ? r.oneOf : void 0;
63143
63150
  if (l) {
63144
- let t = l.filter((e) => !v$1(e));
63151
+ let t = l.filter((e) => !y$1(e));
63145
63152
  t.length !== l.length && (o = !0);
63146
- let n = t.filter(u).map((t) => S$1(e, t, a)), i = {
63153
+ let n = t.filter(d).map((t) => C$1(e, t, a)), i = {
63147
63154
  ...r,
63148
63155
  anyOf: void 0,
63149
63156
  oneOf: void 0
@@ -63159,83 +63166,83 @@ function S$1(e, t, n = []) {
63159
63166
  deprecated: r.deprecated === !0 || e.deprecated
63160
63167
  };
63161
63168
  }
63162
- let s = n.map(x$1);
63169
+ let s = n.map(S$1);
63163
63170
  if (n.length > 0 && s.every((e) => e !== void 0)) {
63164
- let e = b$1.filter((e) => s.includes(e));
63171
+ let e = x$1.filter((e) => s.includes(e));
63165
63172
  return {
63166
- ...y$1(i, `scalar-union`, o),
63173
+ ...b$1(i, `scalar-union`, o),
63167
63174
  unionKinds: e
63168
63175
  };
63169
63176
  }
63170
- return y$1(i, `json`, o);
63177
+ return b$1(i, `json`, o);
63171
63178
  }
63172
63179
  if (c.length > 1) {
63173
- let e = b$1.filter((e) => c.includes(e));
63180
+ let e = x$1.filter((e) => c.includes(e));
63174
63181
  return e.length === c.length ? {
63175
- ...y$1(r, `scalar-union`, o),
63182
+ ...b$1(r, `scalar-union`, o),
63176
63183
  unionKinds: e
63177
- } : y$1(r, `json`, o);
63184
+ } : b$1(r, `json`, o);
63178
63185
  }
63179
- switch (c[0] ?? (u(r.properties) || u(r.additionalProperties) ? `object` : void 0)) {
63180
- case `string`: return y$1(r, ee(r) ? `binary` : `string`, o);
63181
- case `integer`: return y$1(r, `integer`, o);
63182
- case `number`: return y$1(r, `number`, o);
63183
- case `boolean`: return y$1(r, `boolean`, o);
63186
+ switch (c[0] ?? (d(r.properties) || d(r.additionalProperties) ? `object` : void 0)) {
63187
+ case `string`: return b$1(r, ee(r) ? `binary` : `string`, o);
63188
+ case `integer`: return b$1(r, `integer`, o);
63189
+ case `number`: return b$1(r, `number`, o);
63190
+ case `boolean`: return b$1(r, `boolean`, o);
63184
63191
  case `array`: {
63185
- let t = S$1(e, u(r.items) ? r.items : {}, a);
63186
- return x$1(t) !== void 0 || t.kind === `scalar-union` ? {
63187
- ...y$1(r, `scalar-array`, o),
63192
+ let t = C$1(e, d(r.items) ? r.items : {}, a);
63193
+ return S$1(t) !== void 0 || t.kind === `scalar-union` ? {
63194
+ ...b$1(r, `scalar-array`, o),
63188
63195
  item: t
63189
63196
  } : {
63190
- ...y$1(r, `object-array`, o),
63197
+ ...b$1(r, `object-array`, o),
63191
63198
  item: t
63192
63199
  };
63193
63200
  }
63194
63201
  case `object`:
63195
- if (!(u(r.properties) && Object.keys(r.properties).length > 0) && u(r.additionalProperties)) {
63196
- let t = S$1(e, r.additionalProperties, a);
63197
- if (x$1(t) !== void 0 || t.kind === `scalar-union`) return {
63198
- ...y$1(r, `map`, o),
63202
+ if (!(d(r.properties) && Object.keys(r.properties).length > 0) && d(r.additionalProperties)) {
63203
+ let t = C$1(e, r.additionalProperties, a);
63204
+ if (S$1(t) !== void 0 || t.kind === `scalar-union`) return {
63205
+ ...b$1(r, `map`, o),
63199
63206
  item: t
63200
63207
  };
63201
63208
  }
63202
- return y$1(r, `object`, o);
63203
- default: return y$1(r, `any`, o);
63209
+ return b$1(r, `object`, o);
63210
+ default: return b$1(r, `any`, o);
63204
63211
  }
63205
63212
  }
63206
63213
  function te(e) {
63207
- let { schema: t, recursive: n } = g$1(e, e);
63214
+ let { schema: t, recursive: n } = _$1(e, e);
63208
63215
  if (n) return null;
63209
- let r = _$1(t);
63210
- if (!(r.includes(`object`) || r.length === 0 && (u(t.properties) || Object.keys(t).length === 0))) return null;
63216
+ let r = v$1(t);
63217
+ if (!(r.includes(`object`) || r.length === 0 && (d(t.properties) || Object.keys(t).length === 0))) return null;
63211
63218
  let i = Object.create(null);
63212
- if (u(t.properties)) for (let [e, n] of Object.entries(t.properties)) u(n) && (i[e] = n);
63219
+ if (d(t.properties)) for (let [e, n] of Object.entries(t.properties)) d(n) && (i[e] = n);
63213
63220
  return {
63214
63221
  properties: i,
63215
63222
  required: Array.isArray(t.required) ? t.required.filter((e) => typeof e == `string` && Object.hasOwn(i, e)) : []
63216
63223
  };
63217
63224
  }
63218
63225
  function ne(e, t) {
63219
- let n = (Array.isArray(t.anyOf) ? t.anyOf : Array.isArray(t.oneOf) ? t.oneOf : []).filter((e) => u(e) && !v$1(e));
63220
- return n.length === 1 ? g$1(e, n[0]).schema : t;
63226
+ let n = (Array.isArray(t.anyOf) ? t.anyOf : Array.isArray(t.oneOf) ? t.oneOf : []).filter((e) => d(e) && !y$1(e));
63227
+ return n.length === 1 ? _$1(e, n[0]).schema : t;
63221
63228
  }
63222
63229
  function re(e, t) {
63223
63230
  let n = e;
63224
63231
  for (let r of t) {
63225
- let { schema: t, recursive: i } = g$1(e, n);
63232
+ let { schema: t, recursive: i } = _$1(e, n);
63226
63233
  if (i) return;
63227
63234
  let a = ne(e, t);
63228
63235
  if (r === `[]`) {
63229
- if (!u(a.items)) return;
63236
+ if (!d(a.items)) return;
63230
63237
  n = a.items;
63231
- } else if (u(a.properties) && u(a.properties[r])) n = a.properties[r];
63232
- else if (u(a.additionalProperties)) n = a.additionalProperties;
63238
+ } else if (d(a.properties) && d(a.properties[r])) n = a.properties[r];
63239
+ else if (d(a.additionalProperties)) n = a.additionalProperties;
63233
63240
  else return;
63234
63241
  }
63235
- return S$1(e, n);
63242
+ return C$1(e, n);
63236
63243
  }
63237
- const C$1 = /* @__PURE__ */ new Set(/* @__PURE__ */ `answers.approvals.approve.approve-all.color.deny.detach.dry-run.example.field.help.help-all.input.json.json-body.jsonl.max-output.no-color.no-input.output.profile.raw-field.raw-strings.save.stream.timeout.token.verbose.wait.yes`.split(`.`));
63238
- function w$1(e) {
63244
+ const w$1 = /* @__PURE__ */ new Set(/* @__PURE__ */ `answers.approvals.approve.approve-all.color.deny.detach.dry-run.example.field.help.help-all.input.json.json-body.jsonl.max-output.no-color.no-input.output.profile.raw-field.raw-strings.save.stream.timeout.token.verbose.wait.yes`.split(`.`));
63245
+ function ie(e) {
63239
63246
  return e.kind === `string` || e.kind === `enum` || e.kind === `binary`;
63240
63247
  }
63241
63248
  function T$1(e, t) {
@@ -63254,14 +63261,14 @@ function T$1(e, t) {
63254
63261
  let a = {}, o = { ...t?.defaults }, s = [], c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map();
63255
63262
  for (let e of Object.keys(i.properties)) l.set(e$1(e), (l.get(e$1(e)) ?? 0) + 1);
63256
63263
  for (let [e, t] of Object.entries(i.properties)) {
63257
- let u = S$1(r, t);
63264
+ let u = C$1(r, t);
63258
63265
  if (u.readOnly) continue;
63259
63266
  if (u.kind === `const`) {
63260
63267
  E$1(a, e, u.constValue);
63261
63268
  continue;
63262
63269
  }
63263
63270
  let d = e$1(e) || e, f = d;
63264
- if (C$1.has(f) || (l.get(d) ?? 0) > 1 || c.has(f)) for (f = `arg-${d}`, (c.has(f) || (l.get(d) ?? 0) > 1) && (f = `arg-${e}`); c.has(f);) f = `arg-${f}`;
63271
+ if (w$1.has(f) || (l.get(d) ?? 0) > 1 || c.has(f)) for (f = `arg-${d}`, (c.has(f) || (l.get(d) ?? 0) > 1) && (f = `arg-${e}`); c.has(f);) f = `arg-${f}`;
63265
63272
  c.add(f);
63266
63273
  let p = i.required.includes(e);
63267
63274
  p && u.hasDefault && !Object.hasOwn(o, e) && E$1(o, e, u.defaultValue), s.push({
@@ -63273,7 +63280,7 @@ function T$1(e, t) {
63273
63280
  });
63274
63281
  }
63275
63282
  let u = new Map(s.map((e) => [e.wire, e])), d = [];
63276
- if (t?.positional && t.positional.length > 0) d = t.positional.map((e) => u.get(e)).filter((e) => e !== void 0 && w$1(e.field));
63283
+ if (t?.positional && t.positional.length > 0) d = t.positional.map((e) => u.get(e)).filter((e) => e !== void 0 && ie(e.field));
63277
63284
  else {
63278
63285
  let e = s.filter((e) => e.required);
63279
63286
  e.length === 1 && e[0].field.kind === `string` && (d = e);
@@ -63341,29 +63348,29 @@ const M$1 = /* @__PURE__ */ new Set([
63341
63348
  `fail`,
63342
63349
  `deny`
63343
63350
  ]);
63344
- const N$1 = {
63351
+ const oe = {
63345
63352
  h: `help`,
63346
63353
  o: `output`,
63347
63354
  y: `yes`,
63348
63355
  f: `raw-field`,
63349
63356
  F: `field`
63350
63357
  };
63351
- function P$1(e) {
63358
+ function N$1(e) {
63352
63359
  return e.field.kind === `scalar-array` || e.field.kind === `object-array` || e.field.kind === `map`;
63353
63360
  }
63354
- function F(t, n) {
63361
+ function P$1(t, n) {
63355
63362
  let r = /^(\d+(?:\.\d+)?)(ms|s|m|h)?$/.exec(t.trim());
63356
63363
  if (!r) throw new n$2(`invalid_value`, `${n} expects a duration such as 30000, 30s or 5m`);
63357
63364
  let i = Number(r[1]), a = r[2] ?? `ms`, o = Math.round(i * (a === `h` ? 36e5 : a === `m` ? 6e4 : a === `s` ? 1e3 : 1));
63358
63365
  if (o <= 0) throw new n$2(`invalid_value`, `${n} must be greater than zero`);
63359
63366
  return o;
63360
63367
  }
63361
- function I(t) {
63368
+ function se(t) {
63362
63369
  if (t === `0` || t === `none` || t === `unlimited`) return null;
63363
63370
  if (!/^\d+$/.test(t)) throw new n$2(`invalid_value`, `--max-output expects a character count, or 0 for unlimited`);
63364
63371
  return Number(t);
63365
63372
  }
63366
- function ae(t, n) {
63373
+ function ce(t, n) {
63367
63374
  let r = {
63368
63375
  help: !1,
63369
63376
  helpAll: !1,
@@ -63388,10 +63395,10 @@ function ae(t, n) {
63388
63395
  switch (s.add(t), t) {
63389
63396
  case `output`:
63390
63397
  if (!k$1.has(n)) throw new n$2(`invalid_value`, `--output must be one of ${[...k$1].join(`, `)}`);
63391
- r.output = L(r.output, n);
63398
+ r.output = F(r.output, n);
63392
63399
  return;
63393
63400
  case `timeout`:
63394
- r.timeoutMs = F(n, `--timeout`);
63401
+ r.timeoutMs = P$1(n, `--timeout`);
63395
63402
  return;
63396
63403
  case `save`:
63397
63404
  r.save = n;
@@ -63403,7 +63410,7 @@ function ae(t, n) {
63403
63410
  r.jsonBody = n;
63404
63411
  return;
63405
63412
  case `max-output`:
63406
- r.maxOutput = I(n);
63413
+ r.maxOutput = se(n);
63407
63414
  return;
63408
63415
  case `approvals`:
63409
63416
  if (!M$1.has(n)) throw new n$2(`invalid_value`, `--approvals must be prompt, fail or deny`);
@@ -63425,8 +63432,8 @@ function ae(t, n) {
63425
63432
  switch (e) {
63426
63433
  case `help`: return r.help = !0, !0;
63427
63434
  case `help-all`: return r.helpAll = !0, !0;
63428
- case `json`: return r.output = L(r.output, `json`), !0;
63429
- case `jsonl`: return r.output = L(r.output, `ndjson`), !0;
63435
+ case `json`: return r.output = F(r.output, `json`), !0;
63436
+ case `jsonl`: return r.output = F(r.output, `ndjson`), !0;
63430
63437
  case `dry-run`: return r.dryRun = !0, !0;
63431
63438
  case `example`: return r.example = !0, !0;
63432
63439
  case `detach`: return r.detach = !0, !0;
@@ -63437,7 +63444,7 @@ function ae(t, n) {
63437
63444
  }
63438
63445
  }, u = (t, n) => {
63439
63446
  let r = i.get(t) ?? [];
63440
- if (r.length > 0 && !P$1(t)) throw new n$2(`usage`, `--${t.flag} was given more than once`, oe(t));
63447
+ if (r.length > 0 && !N$1(t)) throw new n$2(`usage`, `--${t.flag} was given more than once`, le(t));
63441
63448
  r.push(n), i.set(t, r);
63442
63449
  }, d = (t, n) => {
63443
63450
  if (a.has(t)) throw new n$2(`usage`, `--${t.flag} was given more than once`);
@@ -63458,7 +63465,7 @@ function ae(t, n) {
63458
63465
  return r += 1, t[r];
63459
63466
  }, p = n.byFlag.get(o);
63460
63467
  if (p) {
63461
- p.field.kind === `boolean` ? d(p, s === void 0 || se(s, `--${o}`)) : u(p, f());
63468
+ p.field.kind === `boolean` ? d(p, s === void 0 || I(s, `--${o}`)) : u(p, f());
63462
63469
  continue;
63463
63470
  }
63464
63471
  if (o.startsWith(`no-`)) {
@@ -63474,11 +63481,11 @@ function ae(t, n) {
63474
63481
  continue;
63475
63482
  }
63476
63483
  if (s === void 0 && l(o)) continue;
63477
- throw R(o, n);
63484
+ throw L(o, n);
63478
63485
  }
63479
63486
  if (i.startsWith(`-`) && i.length > 1 && !/^-\d/.test(i)) {
63480
- let a = i.slice(1, 2), o = N$1[a];
63481
- if (!o) throw R(i.slice(1), n);
63487
+ let a = i.slice(1, 2), o = oe[a];
63488
+ if (!o) throw L(i.slice(1), n);
63482
63489
  let s = i.slice(2);
63483
63490
  if (A$1.has(o)) {
63484
63491
  let n = s;
@@ -63489,7 +63496,7 @@ function ae(t, n) {
63489
63496
  }
63490
63497
  c(o, n);
63491
63498
  } else {
63492
- if (s !== ``) throw R(i.slice(1), n);
63499
+ if (s !== ``) throw L(i.slice(1), n);
63493
63500
  l(o);
63494
63501
  }
63495
63502
  } else o.push(i);
@@ -63502,34 +63509,34 @@ function ae(t, n) {
63502
63509
  positionals: o
63503
63510
  };
63504
63511
  }
63505
- function L(t, n) {
63512
+ function F(t, n) {
63506
63513
  if (t && t !== n) throw new n$2(`usage`, `Choose one output format: --json, --jsonl or --output`);
63507
63514
  return n;
63508
63515
  }
63509
- function oe(e) {
63516
+ function le(e) {
63510
63517
  return e.field.kind === `object` || e.field.kind === `json` ? `Pass one JSON value to --${e.flag}, or use -F ${e.wire}[key]=value` : void 0;
63511
63518
  }
63512
- function se(t, n) {
63519
+ function I(t, n) {
63513
63520
  let r = t.trim().toLowerCase();
63514
63521
  if (r === `true`) return !0;
63515
63522
  if (r === `false`) return !1;
63516
63523
  throw new n$2(`invalid_value`, `${n} expects true or false, got ${JSON.stringify(t)}`);
63517
63524
  }
63518
- function R(n, r) {
63519
- let a = n$1(n, [...r.flags.filter((e) => !e.hidden).map((e) => e.flag), ...C$1]);
63525
+ function L(n, r) {
63526
+ let a = n$1(n, [...r.flags.filter((e) => !e.hidden).map((e) => e.flag), ...w$1]);
63520
63527
  return new n$2(`unknown_flag`, `Unknown flag --${n} for ${r.tool.name}`, a.length > 0 ? `Did you mean ${a.map((e) => `--${e}`).join(`, `)}?` : `Run with --help to list flags`);
63521
63528
  }
63522
- function z(e) {
63529
+ function R(e) {
63523
63530
  if (!e) return ``;
63524
63531
  let t = r(e).trim().split(`
63525
63532
  `, 1)[0], n = /^(.+?[.!?])(\s|$)/.exec(t);
63526
63533
  return (n ? n[1] : t).trim();
63527
63534
  }
63528
- function B(e) {
63535
+ function z(e) {
63529
63536
  let t = e.annotations ?? {}, n = [];
63530
63537
  return t.readOnlyHint && n.push(`read-only`), t.destructiveHint && n.push(`destructive`), t.idempotentHint && n.push(`idempotent`), t.openWorldHint && n.push(`open-world`), n;
63531
63538
  }
63532
- function V(e, t, n = 0) {
63539
+ function B(e, t, n = 0) {
63533
63540
  switch (e.kind) {
63534
63541
  case `string`: return `string`;
63535
63542
  case `binary`: return `base64`;
@@ -63539,51 +63546,69 @@ function V(e, t, n = 0) {
63539
63546
  case `number`: return `number`;
63540
63547
  case `boolean`: return `boolean`;
63541
63548
  case `scalar-union`: return (e.unionKinds ?? []).map((e) => e === `integer` ? `number` : e).filter((e, t, n) => n.indexOf(e) === t).join(` | `);
63542
- case `scalar-array`: return `${H(V(e.item ?? e, t, n))}[]`;
63543
- case `object-array`: return `${U(e.item?.schema ?? {}, t, n)}[]`;
63544
- case `map`: return `Record<string, ${V(e.item ?? e, t, n)}>`;
63545
- case `object`: return U(e.schema, t, n);
63549
+ case `scalar-array`: return `${V(B(e.item ?? e, t, n))}[]`;
63550
+ case `object-array`: return `${H(e.item?.schema ?? {}, t, n)}[]`;
63551
+ case `map`: return `Record<string, ${B(e.item ?? e, t, n)}>`;
63552
+ case `object`: return H(e.schema, t, n);
63546
63553
  case `json`:
63547
63554
  case `any`: return `unknown`;
63548
63555
  }
63549
63556
  }
63550
- function H(e) {
63557
+ function V(e) {
63551
63558
  return e.includes(` | `) ? `(${e})` : e;
63552
63559
  }
63553
- function U(e, t, n = 0) {
63560
+ function H(e, t, n = 0) {
63554
63561
  let r = e.properties;
63555
63562
  if (n > 1 || typeof r != `object` || !r) return `object`;
63556
63563
  let i = Array.isArray(e.required) ? e.required : [], a = Object.entries(r).map(([e, r]) => {
63557
- let a = S$1(t, r), o = V(a, t, n + 1);
63564
+ let a = C$1(t, r), o = B(a, t, n + 1);
63558
63565
  return `${e}${i.includes(e) ? `` : `?`}: ${o}${a.nullable ? ` | null` : ``}`;
63559
63566
  });
63560
63567
  return a.length > 0 ? `{ ${a.join(`; `)} }` : `object`;
63561
63568
  }
63562
- function W(e) {
63569
+ function U(e) {
63563
63570
  let t = e.inputSchema ?? {}, n = T$1(e);
63564
63571
  if (n.bodyOnly) return r(`${e.name}(body: unknown)`);
63565
- let i = n.flags.filter((e) => !e.hidden).map((e) => `${e.wire}${e.required ? `` : `?`}: ${V(e.field, t)}${e.field.nullable ? ` | null` : ``}`);
63572
+ let i = n.flags.filter((e) => !e.hidden).map((e) => `${e.wire}${e.required ? `` : `?`}: ${B(e.field, t)}${e.field.nullable ? ` | null` : ``}`);
63566
63573
  return r(`${e.name}(${i.length > 0 ? `{ ${i.join(`; `)} }` : ``})`);
63567
63574
  }
63568
- function K(e) {
63575
+ function W(e) {
63569
63576
  return e.callOnly ? `call ${e.tool.name}` : e.path.join(` `);
63570
63577
  }
63571
- function $(e, t = !1) {
63578
+ function Z(e, t = !1) {
63572
63579
  return e.entries.filter((e) => t || !e.hidden).map((e) => ({
63573
- command: K(e),
63580
+ command: W(e),
63574
63581
  tool: e.tool.name,
63575
- summary: z(e.tool.description),
63576
- badges: B(e.tool)
63582
+ summary: R(e.tool.description),
63583
+ badges: z(e.tool)
63577
63584
  })).sort((e, t) => e.command.localeCompare(t.command));
63578
63585
  }
63579
- function de(e) {
63586
+ function Q(e) {
63580
63587
  if (e.length === 0) return `No tools.
63581
63588
  `;
63582
63589
  let t = Math.min(40, Math.max(...e.map((e) => e.command.length)));
63583
63590
  return r(`${e.map((e) => ` ${e.command.padEnd(t)} ${e.summary}${e.badges.length > 0 ? ` [${e.badges.join(`, `)}]` : ``}`.trimEnd()).join(`
63584
63591
  `)}\n`);
63585
63592
  }
63586
- // ../mcp-cli/dist/chunk-BzzREe8T.mjs
63593
+ [...[
63594
+ [`login`, `Sign in (browser, --device for a code to approve elsewhere, or --with-token for an API key)`],
63595
+ [`logout`, `Sign out: revoke the session on the server and remove it here`],
63596
+ [`auth status`, `Show who is signed in and which credential is in use`],
63597
+ [`auth token`, `Print the current token`],
63598
+ [`tools`, `List tools (--search <q>, --refresh, --json)`],
63599
+ [`schema <tool>`, `Print a tool's input and output schemas`],
63600
+ [`call <tool>`, `Call a tool by its exact name`],
63601
+ [`resume <id>`, `Answer a paused call (an approval or other input) and print its result`],
63602
+ [`tasks get <id>`, `Print a task's status, or its result once it has finished`],
63603
+ [`tasks watch <id>`, `Follow a task (from --detach or --wait) until it finishes`],
63604
+ [`tasks answer <id>`, `Answer a task waiting for approval or input, then follow it`],
63605
+ [`tasks cancel <id>`, `Ask the server to cancel a task`],
63606
+ [`completion <shell>`, `Print a bash, zsh or fish completion script`],
63607
+ [`skill install`, `Write a SKILL.md for coding agents`],
63608
+ [`doctor`, `Check node, credentials and the server`],
63609
+ [`version`, `Print the version`]
63610
+ ].slice(0, 13)];
63611
+ // ../mcp-cli/dist/chunk-Bc2e_4bO.mjs
63587
63612
  var p = class extends n$2 {};
63588
63613
  function m(e) {
63589
63614
  return typeof e == `object` && !!e && !Array.isArray(e);
@@ -63908,7 +63933,7 @@ function toMcpCliArgv(options) {
63908
63933
  function usesMcpStdin(options) {
63909
63934
  const spec = T$1(SCHEMALESS);
63910
63935
  try {
63911
- return N(ae(toMcpCliArgv(options), spec), spec);
63936
+ return N(ce(toMcpCliArgv(options), spec), spec);
63912
63937
  } catch {
63913
63938
  return false;
63914
63939
  }
@@ -63942,7 +63967,7 @@ async function resolveMcpArguments(options, dependencies = {}) {
63942
63967
  required: [],
63943
63968
  positionals: []
63944
63969
  };
63945
- const { args } = await P(spec, ae(toMcpCliArgv(options), spec), {
63970
+ const { args } = await P(spec, ce(toMcpCliArgv(options), spec), {
63946
63971
  readFile: deps.readFile,
63947
63972
  readStdin: deps.readStdin,
63948
63973
  stdinIsPipedData: () => false,
@@ -64004,11 +64029,11 @@ function printTools(tools, target) {
64004
64029
  }
64005
64030
  const label = target === "code" ? "Code Mode MCP Tools" : "MCP Tools";
64006
64031
  console.log(chalk.cyan(`${label}:`));
64007
- const rows = $(l(tools), true).map((row) => ({
64032
+ const rows = Z(u(tools), true).map((row) => ({
64008
64033
  ...row,
64009
64034
  command: row.tool
64010
64035
  }));
64011
- process.stdout.write(de(rows));
64036
+ process.stdout.write(Q(rows));
64012
64037
  console.log(chalk.dim(`\n Total: ${tools.length} tools`));
64013
64038
  }
64014
64039
  function printTool(tool) {
@@ -64027,11 +64052,11 @@ function printTool(tool) {
64027
64052
  },
64028
64053
  {
64029
64054
  label: "Signature",
64030
- value: W(tool)
64055
+ value: U(tool)
64031
64056
  },
64032
64057
  {
64033
64058
  label: "Hints",
64034
- value: B(tool).join(", ") || void 0
64059
+ value: z(tool).join(", ") || void 0
64035
64060
  },
64036
64061
  {
64037
64062
  label: "Input Schema",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runtypelabs/cli",
3
- "version": "2.59.0",
3
+ "version": "2.59.1",
4
4
  "description": "Command-line interface for Runtype AI platform",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -13,7 +13,7 @@
13
13
  "@modelcontextprotocol/core": "2.3.1",
14
14
  "@napi-rs/keyring": "2.1.0",
15
15
  "@runtypelabs/ink-components": "0.3.14",
16
- "@runtypelabs/sdk": "11.20.0",
16
+ "@runtypelabs/sdk": "11.20.1",
17
17
  "@runtypelabs/terminal-animations": "0.2.4",
18
18
  "add-mcp": "2.6.0",
19
19
  "chalk": "^5.3.0",
@@ -37,10 +37,10 @@
37
37
  "devDependencies": {
38
38
  "@modelcontextprotocol/server": "2.3.1",
39
39
  "@runtypelabs/device-bridge": "0.2.5",
40
- "@runtypelabs/mcp-cli": "0.3.2",
40
+ "@runtypelabs/mcp-cli": "0.4.0",
41
41
  "@runtypelabs/model-execution": "0.41.8",
42
42
  "@runtypelabs/persona": "4.34.0",
43
- "@runtypelabs/shared": "3.116.0",
43
+ "@runtypelabs/shared": "3.117.0",
44
44
  "@types/express": "^5.0.6",
45
45
  "@types/micromatch": "^4.0.9",
46
46
  "@types/node": "^25.3.3",