@runtypelabs/cli 2.53.3 → 2.54.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.
Files changed (2) hide show
  1. package/dist/index.js +161 -51
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -23908,6 +23908,13 @@ object({
23908
23908
  agentExecutionRowId: string().nullable().describe("The agent_executions ROW id the scheduled run stored. Provenance only: a different id space from executionId, and never a /v1/runs key."),
23909
23909
  batchExecutionId: string().nullable().describe("The batch whose per-record runs are GET /v1/runs?batchExecutionId=.")
23910
23910
  });
23911
+ //#endregion
23912
+ //#region ../shared/dist/chunk-Di71fDrM.mjs
23913
+ const HTTP_REASON_PHRASES = "bad request|unauthori[sz]ed|forbidden|not found|method not allowed|request timeout|conflict|gone|unprocessable entity|too many requests|internal server error|not implemented|bad gateway|service unavailable|gateway timeout";
23914
+ /** A bare status number ends the message, meets punctuation (not a `,000` digit group), or leads its reason phrase. */
23915
+ const STATUS_NUMBER_END = String.raw`(?=\s*$|[:;)\]]|[.,](?!\d)|\s*[:-]?\s*(?:${HTTP_REASON_PHRASES})\b)`;
23916
+ new RegExp(String.raw`\b(?:status(?:[ _]code)?|code|error|returned|responded(?: with)?|failed(?: with)?)[\s:=]*([45]\d{2})\b` + STATUS_NUMBER_END, "i");
23917
+ new RegExp(String.raw`(?<![$€£#.\d])\b([45]\d{2})\s*[:-]?\s*(?:${HTTP_REASON_PHRASES})\b`, "i");
23911
23918
  /**
23912
23919
  * The same attribute names, exported for readers of GenAI spans.
23913
23920
  * OTLP trace ingest reads back the identical vocabulary a customer's own SDK produced.
@@ -24393,7 +24400,7 @@ _enum([
24393
24400
  "interrupted"
24394
24401
  ]);
24395
24402
  //#endregion
24396
- //#region ../shared/dist/chunk-B4rF4aQI.mjs
24403
+ //#region ../shared/dist/chunk-BCcCVYD-.mjs
24397
24404
  /**
24398
24405
  * Maps model families to provider-specific model IDs.
24399
24406
  * Use for routing: family + provider → exact model ID
@@ -24923,6 +24930,7 @@ const MODEL_FAMILY_PROVIDER_IDS = {
24923
24930
  "openai": "gpt-6.1-sol",
24924
24931
  "vercel": "openai/gpt-6.1-sol"
24925
24932
  },
24933
+ "gpt-6-1-sol-ultrafast": { "openai": "gpt-6.1-sol-ultrafast" },
24926
24934
  "gpt-6-1-sol-batch": { "vercel": "openai/gpt-6.1-sol-batch" },
24927
24935
  "gpt-6-1-sol-fast": { "vercel": "openai/gpt-6.1-sol-fast" },
24928
24936
  "gpt-6-astra": {
@@ -24947,6 +24955,7 @@ const MODEL_FAMILY_PROVIDER_IDS = {
24947
24955
  "openai": "gpt-6.1-sol",
24948
24956
  "vercel": "openai/gpt-6.1-sol"
24949
24957
  },
24958
+ "gpt-6.1-sol-ultrafast": { "openai": "gpt-6.1-sol-ultrafast" },
24950
24959
  "gpt-6.1-sol-batch": { "vercel": "openai/gpt-6.1-sol-batch" },
24951
24960
  "gpt-6.1-sol-fast": { "vercel": "openai/gpt-6.1-sol-fast" },
24952
24961
  "gpt-image-1-5": { "openai": "gpt-image-1.5" },
@@ -25490,7 +25499,7 @@ const CREATOR_TO_PROVIDER = {
25490
25499
  "unknown": "openai"
25491
25500
  };
25492
25501
  //#endregion
25493
- //#region ../shared/dist/chunk-56H9IdjP.mjs
25502
+ //#region ../shared/dist/chunk-jaE_lS2E.mjs
25494
25503
  const DEFAULT_GENERIC_OPENAI_API_FORMAT = "chat-completions";
25495
25504
  /** Provider defaults shared by every execution engine and deploy guidance. */
25496
25505
  const DEFAULT_BEDROCK_REGION = "us-east-1";
@@ -27431,6 +27440,7 @@ const PRODUCT_EVENT_NAMES = [
27431
27440
  "runtype.approval.requested",
27432
27441
  "runtype.schedule.run_failed",
27433
27442
  "runtype.eval.run_completed",
27443
+ "runtype.simulation.run_completed",
27434
27444
  "runtype.conversation.human_takeover",
27435
27445
  "runtype.skill.proposal_created",
27436
27446
  "runtype.task.input_required",
@@ -27456,6 +27466,7 @@ const ProductEventFilterFieldSchemas = {
27456
27466
  surfaceId: resourceId("Only occurrences on this surface"),
27457
27467
  scheduleId: resourceId("Only occurrences for this schedule"),
27458
27468
  suiteId: resourceId("Only occurrences for this eval suite"),
27469
+ simulationId: resourceId("Only occurrences for this simulation"),
27459
27470
  taskId: resourceId("Only occurrences for this delegated task"),
27460
27471
  key: string().min(1).max(64).describe("Only signal occurrences for this signal key, such as tool_error"),
27461
27472
  onlyRegressions: boolean().describe("Only eval runs whose pass rate dropped below the previous run"),
@@ -27481,6 +27492,10 @@ const EvalRunCompletedArgumentsSchema = object({
27481
27492
  suiteId: filter.suiteId.optional(),
27482
27493
  onlyRegressions: filter.onlyRegressions.optional()
27483
27494
  }).strict();
27495
+ const SimulationRunCompletedArgumentsSchema = object({
27496
+ simulationId: filter.simulationId.optional(),
27497
+ productId: filter.productId.optional()
27498
+ }).strict();
27484
27499
  const ConversationHumanTakeoverArgumentsSchema = object({
27485
27500
  surfaceId: filter.surfaceId.optional(),
27486
27501
  productId: filter.productId.optional()
@@ -27503,6 +27518,7 @@ object({
27503
27518
  surfaceId: filter.surfaceId.optional(),
27504
27519
  scheduleId: filter.scheduleId.optional(),
27505
27520
  suiteId: filter.suiteId.optional(),
27521
+ simulationId: filter.simulationId.optional(),
27506
27522
  taskId: filter.taskId.optional(),
27507
27523
  key: filter.key.optional(),
27508
27524
  onlyRegressions: filter.onlyRegressions.optional(),
@@ -27546,6 +27562,23 @@ const EvalRunCompletedPayloadSchema = object({
27546
27562
  regressed: boolean().describe("True when passRate is below previousPassRate"),
27547
27563
  completedAt: isoTimestamp("When the run finished")
27548
27564
  });
27565
+ const SimulationRunCompletedPayloadSchema = object({
27566
+ runId: resourceId("The simulation run"),
27567
+ simulationId: resourceId("The simulation"),
27568
+ productId: resourceId("Product the simulation belongs to").optional(),
27569
+ status: _enum([
27570
+ "completed",
27571
+ "failed",
27572
+ "cancelled",
27573
+ "budget_exhausted"
27574
+ ]).describe("Terminal status of the run; budget_exhausted stopped at its spend cap"),
27575
+ episodesPlanned: number$1().int().min(0).describe("Episodes the run planned"),
27576
+ episodesCompleted: number$1().int().min(0).describe("Episodes that completed"),
27577
+ episodesFailed: number$1().int().min(0).describe("Episodes that failed"),
27578
+ spentUsd: number$1().min(0).describe("Spend the run recorded, in USD"),
27579
+ errorMessage: errorMessage$2.optional(),
27580
+ completedAt: isoTimestamp("When the run finished")
27581
+ });
27549
27582
  const ConversationHumanTakeoverPayloadSchema = object({
27550
27583
  conversationId: resourceId("The conversation a human took over"),
27551
27584
  surfaceId: resourceId("Surface the conversation is on").optional(),
@@ -27611,6 +27644,7 @@ const PRODUCT_EVENT_ARGUMENT_SCHEMAS = {
27611
27644
  "runtype.approval.requested": ApprovalRequestedArgumentsSchema,
27612
27645
  "runtype.schedule.run_failed": ScheduleRunFailedArgumentsSchema,
27613
27646
  "runtype.eval.run_completed": EvalRunCompletedArgumentsSchema,
27647
+ "runtype.simulation.run_completed": SimulationRunCompletedArgumentsSchema,
27614
27648
  "runtype.conversation.human_takeover": ConversationHumanTakeoverArgumentsSchema,
27615
27649
  "runtype.skill.proposal_created": SkillProposalCreatedArgumentsSchema,
27616
27650
  "runtype.task.input_required": DelegateTaskArgumentsSchema,
@@ -27625,6 +27659,7 @@ const PRODUCT_EVENT_PAYLOAD_SCHEMAS = {
27625
27659
  "runtype.approval.requested": ApprovalRequestedPayloadSchema,
27626
27660
  "runtype.schedule.run_failed": ScheduleRunFailedPayloadSchema,
27627
27661
  "runtype.eval.run_completed": EvalRunCompletedPayloadSchema,
27662
+ "runtype.simulation.run_completed": SimulationRunCompletedPayloadSchema,
27628
27663
  "runtype.conversation.human_takeover": ConversationHumanTakeoverPayloadSchema,
27629
27664
  "runtype.skill.proposal_created": SkillProposalCreatedPayloadSchema,
27630
27665
  "runtype.task.input_required": TaskInputRequiredPayloadSchema,
@@ -27639,6 +27674,7 @@ const PRODUCT_EVENT_DESCRIPTIONS = {
27639
27674
  "runtype.approval.requested": "An agent paused for a human to approve a tool call.",
27640
27675
  "runtype.schedule.run_failed": "A scheduled run of a flow or agent failed.",
27641
27676
  "runtype.eval.run_completed": "An eval suite run finished; `regressed` is true when its pass rate dropped.",
27677
+ "runtype.simulation.run_completed": "A simulation run reached a terminal status: completed, failed, cancelled or budget_exhausted. Read its report with get_simulation_report.",
27642
27678
  "runtype.conversation.human_takeover": "A human took over a messaging conversation from the agent.",
27643
27679
  "runtype.skill.proposal_created": "A deployed agent proposed a skill that is waiting for review.",
27644
27680
  "runtype.task.input_required": "A delegated task stopped to ask a question; answer it by calling delegate_to_runtype with its task id.",
@@ -27654,6 +27690,11 @@ const PRODUCT_EVENT_REQUIRED_SCOPES = {
27654
27690
  "runtype.approval.requested": ["AGENTS:READ"],
27655
27691
  "runtype.schedule.run_failed": ["SCHEDULES:READ"],
27656
27692
  "runtype.eval.run_completed": ["EVALS:READ"],
27693
+ "runtype.simulation.run_completed": [
27694
+ "SIMULATIONS:READ",
27695
+ "SIMULATIONS:WRITE",
27696
+ "SIMULATIONS:RUN"
27697
+ ],
27657
27698
  "runtype.conversation.human_takeover": ["MESSAGING:READ"],
27658
27699
  "runtype.skill.proposal_created": ["SKILLS:READ"],
27659
27700
  "runtype.task.input_required": ["DELEGATE_TASKS:READ", "DELEGATE_TASKS:WRITE"],
@@ -55997,9 +56038,9 @@ clientTokensCommand.command("regenerate <id>").description("Regenerate a client
55997
56038
  });
55998
56039
  clientTokensCommand.addCommand(clientTokenEnsureCommand);
55999
56040
  //#endregion
56000
- //#region ../../node_modules/.pnpm/@runtypelabs+persona@4.29.2/node_modules/@runtypelabs/persona/dist/codegen.js
56041
+ //#region ../../node_modules/.pnpm/@runtypelabs+persona@4.32.2/node_modules/@runtypelabs/persona/dist/codegen.js
56001
56042
  function e(e) {
56002
- return e?.cdnBase?.trim().replace(/\/+$/, ``).replace(/[\\'"<>`]/g, (e) => `%${e.charCodeAt(0).toString(16).toUpperCase().padStart(2, `0`)}`) || `https://cdn.jsdelivr.net/npm/@runtypelabs/persona@4.29.2/dist`;
56043
+ return e?.cdnBase?.trim().replace(/\/+$/, ``).replace(/[\\'"<>`]/g, (e) => `%${e.charCodeAt(0).toString(16).toUpperCase().padStart(2, `0`)}`) || `https://cdn.jsdelivr.net/npm/@runtypelabs/persona@4.32.2/dist`;
56003
56044
  }
56004
56045
  function t(e) {
56005
56046
  if (e !== void 0) return typeof e == `string` ? e : Array.isArray(e) ? `[${e.map((e) => e.toString()).join(`, `)}]` : e.toString();
@@ -56137,41 +56178,106 @@ function m(e, t) {
56137
56178
  let n = [];
56138
56179
  return e && (e.getHeaders && n.push(`${t}getHeaders: ${e.getHeaders},`), e.requestMiddleware && n.push(`${t}requestMiddleware: ${e.requestMiddleware},`), e.actionParsers && n.push(`${t}actionParsers: ${e.actionParsers},`), e.actionHandlers && n.push(`${t}actionHandlers: ${e.actionHandlers},`), e.contextProviders && n.push(`${t}contextProviders: ${e.contextProviders},`), e.streamParser && n.push(`${t}streamParser: ${e.streamParser},`)), n;
56139
56180
  }
56140
- function h(e, t, n) {
56181
+ function h(e, t) {
56182
+ return JSON.stringify(e, null, t).replace(/</g, `\\u003c`).replace(/\u2028/g, `\\u2028`).replace(/\u2029/g, `\\u2029`);
56183
+ }
56184
+ function g(e, t, n) {
56141
56185
  Object.entries(t).forEach(([t, r]) => {
56142
- r !== void 0 && typeof r != `function` && (Array.isArray(r) ? e.push(`${n}${t}: ${JSON.stringify(r)},`) : r && typeof r == `object` ? (e.push(`${n}${t}: {`), h(e, r, `${n} `), e.push(`${n}},`)) : e.push(`${n}${t}: ${JSON.stringify(r)},`));
56186
+ if (r === void 0 || typeof r == `function`) return;
56187
+ let i = /^[a-zA-Z_$][\w$]*$/.test(t) ? t : h(t);
56188
+ Array.isArray(r) ? e.push(`${n}${i}: ${h(r)},`) : r && typeof r == `object` ? (e.push(`${n}${i}: {`), g(e, r, `${n} `), e.push(`${n}},`)) : e.push(`${n}${i}: ${h(r)},`);
56143
56189
  });
56144
56190
  }
56145
- function g(e, t, n, r) {
56146
- n && (e.push(`${r}${t}: {`), h(e, n, `${r} `), e.push(`${r}},`));
56191
+ function _(e, t, n, r) {
56192
+ n && (e.push(`${r}${t}: {`), g(e, n, `${r} `), e.push(`${r}},`));
56193
+ }
56194
+ function v(e, t, n) {
56195
+ _(e, `copy`, t.copy, n), _(e, `welcome`, t.welcome, n), t.approval === !1 ? e.push(`${n}approval: false,`) : _(e, `approval`, t.approval, n);
56147
56196
  }
56148
- function _(e, t, n) {
56149
- t.future?.v5Defaults !== void 0 && e.push(`${n}future: { v5Defaults: ${t.future.v5Defaults === !0} },`);
56197
+ function y(e, t, n) {
56198
+ t.future?.v5Defaults !== void 0 && e.push(`${n}future: { v5Defaults: ${t.future.v5Defaults === !0} },`), _(e, `brand`, t.brand, n), _(e, `darkTheme`, t.darkTheme, n), t.colorScheme !== void 0 && e.push(`${n}colorScheme: ${JSON.stringify(t.colorScheme)},`);
56150
56199
  }
56151
- function v(e) {
56200
+ function b(e) {
56152
56201
  return (e?.target ?? `body`).replace(/\\/g, `\\\\`).replace(/'/g, `\\'`);
56153
56202
  }
56154
- function y(e, t = `esm`, r) {
56203
+ function x(e, t = `esm`, r) {
56204
+ if (r?.authoredOverrides) return S(e, t, r);
56155
56205
  let i = { ...e };
56156
56206
  delete i.postprocessMessage, delete i.initialMessages;
56157
56207
  let a = r ? {
56158
56208
  ...r,
56159
56209
  hooks: n(r.hooks)
56160
- } : void 0;
56161
- return t === `esm` ? b(i, a) : t === `script-installer` ? w(i, a) : t === `script-advanced` ? E(i, a) : t === `react-component` ? x(i, a) : t === `react-advanced` ? S(i, a) : T(i, a);
56162
- }
56163
- function b(e, t) {
56210
+ } : void 0, o;
56211
+ o = t === `esm` ? C(i, a) : t === `script-installer` ? D(i, a) : t === `script-advanced` ? k(i, a) : t === `react-component` ? w(i, a) : t === `react-advanced` ? T(i, a) : O(i, a);
56212
+ let s = [
56213
+ [`welcome.icon`, e.welcome?.icon],
56214
+ [`approval.formatDescription`, e.approval?.formatDescription],
56215
+ [`approval.onDecision`, e.approval?.onDecision]
56216
+ ].filter(([, e]) => typeof e == `function`).map(([e]) => e);
56217
+ if (s.length === 0) return o;
56218
+ let c = `Function-valued ${s.join(`, `)} omitted; reattach in host JavaScript.`;
56219
+ return t.startsWith(`script-`) ? `<!-- ${c} -->\n${o}` : `// ${c}\n${o}`;
56220
+ }
56221
+ function S(t, r, i) {
56222
+ let a = [], o = Symbol(`omit`), s = /* @__PURE__ */ new Set([
56223
+ `storageAdapter`,
56224
+ `targetProviders`,
56225
+ `components`,
56226
+ `voiceRecognition.provider`,
56227
+ `voiceRecognition.provider.custom`
56228
+ ]), c = (e) => typeof e == `function` || !!e && typeof e == `object` && Object.values(e).some(c), l = (e, t) => {
56229
+ if (typeof e == `function` || typeof e == `symbol` || e === void 0) return a.push(t), o;
56230
+ if (!e || typeof e != `object`) return e;
56231
+ if (s.has(t) && c(e) || !Array.isArray(e) && Object.getPrototypeOf(e) !== Object.prototype) return a.push(t), o;
56232
+ if (Array.isArray(e)) {
56233
+ let n = e.map((e, n) => l(e, `${t}.${n}`));
56234
+ return n.includes(o) ? (a.push(t), o) : n;
56235
+ }
56236
+ return Object.fromEntries(Object.entries(e).flatMap(([e, n]) => {
56237
+ let r = l(n, t ? `${t}.${e}` : e);
56238
+ return r === o ? [] : [[e, r]];
56239
+ }));
56240
+ }, u = l(t, ``), d = n(i.hooks), f = r === `script-installer`, p = h(u, 2);
56241
+ if (d) {
56242
+ let e = m(d, ` `);
56243
+ d.postprocessMessage && e.push(` postprocessMessage: ${d.postprocessMessage},`);
56244
+ let t = [`onFeedback`, `onCopy`];
56245
+ if (t.some((e) => d[e])) {
56246
+ if (!f) {
56247
+ let e = { ...u };
56248
+ delete e.messageActions, p = h(e, 2);
56249
+ }
56250
+ e.push(` messageActions: {`), e.push(...Object.entries(u.messageActions ?? {}).map(([e, t]) => ` ${h(e)}: ${h(t)},`));
56251
+ for (let n of t) d[n] && e.push(` ${n}: ${d[n]},`);
56252
+ e.push(` },`);
56253
+ }
56254
+ if (f) a.push(...Object.keys(d).map((e) => `hooks.${e}`));
56255
+ else if (e.length) {
56256
+ let t = p.slice(1, -1).trim();
56257
+ p = `{\n${t}${t ? `,` : ``}\n${e.join(`
56258
+ `)}\n}`;
56259
+ }
56260
+ }
56261
+ r.startsWith(`script-`) && (p = p.replace(/<\/script/gi, `<\\/script`));
56262
+ let g, _ = h(i.target ?? `body`), v = i.windowKey ? `, windowKey: ${h(i.windowKey)}` : ``, y = e(i);
56263
+ if (g = f ? `<script src="${y}/install.global.js" data-config='${h(i.target || i.windowKey ? {
56264
+ config: u,
56265
+ ...i.target ? { target: i.target } : {},
56266
+ ...i.windowKey ? { windowKey: i.windowKey } : {}
56267
+ } : u).replace(/&/g, `&amp;`).replace(/'/g, `&#39;`).replace(/"/g, `&quot;`)}'><\/script>` : r.startsWith(`script-`) ? `<link rel="stylesheet" href="${y}/widget.css" />\n<script src="${y}/index.global.js"><\/script>\n<script>\nvar config = ${p};\nvar handle = window.AgentWidget.initAgentWidget({ target: ${_}${v}, config });\n<\/script>` : r.startsWith(`react-`) ? `'use client';\nimport { useEffect } from 'react';\nimport '@runtypelabs/persona/widget.css';\nimport { initAgentWidget } from '@runtypelabs/persona';\n\nexport function ChatWidget() {\n useEffect(() => {\n const handle = initAgentWidget({ target: ${_}${v}, config: ${p} });\n return () => handle.destroy();\n }, []);\n return null;\n}` : `import '@runtypelabs/persona/widget.css';\nimport { initAgentWidget } from '@runtypelabs/persona';\n\ninitAgentWidget({ target: ${_}${v}, config: ${p} });`, !a.length) return g;
56268
+ let b = `Omitted non-serializable inputs: ${[...new Set(a)].join(`, `)}. Reattach functions/custom implementations in host JavaScript; closures cannot be reconstructed.`;
56269
+ return r.startsWith(`script-`) ? `<!-- ${b.replace(/--/g, `—`).replace(/</g, `&lt;`).replace(/>/g, `&gt;`)} -->\n${g}` : `// ${b.replace(/[\r\n\u2028\u2029]/g, ` `)}\n${g}`;
56270
+ }
56271
+ function C(e, t) {
56164
56272
  let n = t?.hooks, r = c(e), i = r !== `plain`, a = [
56165
56273
  `import '@runtypelabs/persona/widget.css';`,
56166
56274
  `import { initAgentWidget, markdownPostprocessor } from '@runtypelabs/persona';`,
56167
56275
  ``,
56168
56276
  `initAgentWidget({`,
56169
- ` target: '${v(t)}',`,
56277
+ ` target: '${b(t)}',`,
56170
56278
  ` config: {`
56171
56279
  ];
56172
- return e.apiUrl && a.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && a.push(` clientToken: "${e.clientToken}",`), e.agentId && a.push(` agentId: "${e.agentId}",`), e.target && a.push(` target: "${e.target}",`), e.flowId && a.push(` flowId: "${e.flowId}",`), i && a.push(` parserType: "${r}",`), _(a, e, ` `), e.theme && typeof e.theme == `object` && Object.keys(e.theme).length > 0 && g(a, `theme`, e.theme, ` `), e.launcher && g(a, `launcher`, e.launcher, ` `), e.copy && (a.push(` copy: {`), Object.entries(e.copy).forEach(([e, t]) => {
56173
- a.push(` ${e}: "${t}",`);
56174
- }), a.push(` },`)), e.sendButton && (a.push(` sendButton: {`), Object.entries(e.sendButton).forEach(([e, t]) => {
56280
+ return e.apiUrl && a.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && a.push(` clientToken: "${e.clientToken}",`), e.agentId && a.push(` agentId: "${e.agentId}",`), e.target && a.push(` target: "${e.target}",`), e.flowId && a.push(` flowId: "${e.flowId}",`), i && a.push(` parserType: "${r}",`), y(a, e, ` `), e.theme && typeof e.theme == `object` && Object.keys(e.theme).length > 0 && _(a, `theme`, e.theme, ` `), e.launcher && _(a, `launcher`, e.launcher, ` `), v(a, e, ` `), e.sendButton && (a.push(` sendButton: {`), Object.entries(e.sendButton).forEach(([e, t]) => {
56175
56281
  typeof t == `string` ? a.push(` ${e}: "${t}",`) : typeof t == `boolean` && a.push(` ${e}: ${t},`);
56176
56282
  }), a.push(` },`)), e.voiceRecognition && (a.push(` voiceRecognition: {`), Object.entries(e.voiceRecognition).forEach(([e, t]) => {
56177
56283
  typeof t == `string` ? a.push(` ${e}: "${t}",`) : (typeof t == `boolean` || typeof t == `number`) && a.push(` ${e}: ${t},`);
@@ -56184,7 +56290,7 @@ function b(e, t) {
56184
56290
  }), a.push(` ],`)), e.suggestionChipsConfig && (a.push(` suggestionChipsConfig: {`), e.suggestionChipsConfig.fontFamily && a.push(` fontFamily: "${e.suggestionChipsConfig.fontFamily}",`), e.suggestionChipsConfig.fontWeight && a.push(` fontWeight: "${e.suggestionChipsConfig.fontWeight}",`), e.suggestionChipsConfig.paddingX && a.push(` paddingX: "${e.suggestionChipsConfig.paddingX}",`), e.suggestionChipsConfig.paddingY && a.push(` paddingY: "${e.suggestionChipsConfig.paddingY}",`), a.push(` },`)), a.push(...l(e, ` `)), a.push(...u(e, ` `, n)), a.push(...d(e, ` `)), a.push(...p(e, ` `)), a.push(...m(n, ` `)), e.debug && a.push(` debug: ${e.debug},`), n?.postprocessMessage ? a.push(` postprocessMessage: ${n.postprocessMessage}`) : a.push(` postprocessMessage: ({ text }) => markdownPostprocessor(text)`), a.push(` }`), a.push(`});`), a.join(`
56185
56291
  `);
56186
56292
  }
56187
- function x(e, t) {
56293
+ function w(e, t) {
56188
56294
  let n = t?.hooks, r = c(e), i = r !== `plain`, a = [
56189
56295
  `// ChatWidget.tsx`,
56190
56296
  `'use client'; // Required for Next.js - remove for Vite/CRA`,
@@ -56199,12 +56305,10 @@ function x(e, t) {
56199
56305
  ` let handle: AgentWidgetInitHandle | null = null;`,
56200
56306
  ``,
56201
56307
  ` handle = initAgentWidget({`,
56202
- ` target: '${v(t)}',`,
56308
+ ` target: '${b(t)}',`,
56203
56309
  ` config: {`
56204
56310
  ];
56205
- return e.apiUrl && a.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && a.push(` clientToken: "${e.clientToken}",`), e.agentId && a.push(` agentId: "${e.agentId}",`), e.target && a.push(` target: "${e.target}",`), e.flowId && a.push(` flowId: "${e.flowId}",`), i && a.push(` parserType: "${r}",`), _(a, e, ` `), e.theme && typeof e.theme == `object` && Object.keys(e.theme).length > 0 && g(a, `theme`, e.theme, ` `), e.launcher && g(a, `launcher`, e.launcher, ` `), e.copy && (a.push(` copy: {`), Object.entries(e.copy).forEach(([e, t]) => {
56206
- a.push(` ${e}: "${t}",`);
56207
- }), a.push(` },`)), e.sendButton && (a.push(` sendButton: {`), Object.entries(e.sendButton).forEach(([e, t]) => {
56311
+ return e.apiUrl && a.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && a.push(` clientToken: "${e.clientToken}",`), e.agentId && a.push(` agentId: "${e.agentId}",`), e.target && a.push(` target: "${e.target}",`), e.flowId && a.push(` flowId: "${e.flowId}",`), i && a.push(` parserType: "${r}",`), y(a, e, ` `), e.theme && typeof e.theme == `object` && Object.keys(e.theme).length > 0 && _(a, `theme`, e.theme, ` `), e.launcher && _(a, `launcher`, e.launcher, ` `), v(a, e, ` `), e.sendButton && (a.push(` sendButton: {`), Object.entries(e.sendButton).forEach(([e, t]) => {
56208
56312
  typeof t == `string` ? a.push(` ${e}: "${t}",`) : typeof t == `boolean` && a.push(` ${e}: ${t},`);
56209
56313
  }), a.push(` },`)), e.voiceRecognition && (a.push(` voiceRecognition: {`), Object.entries(e.voiceRecognition).forEach(([e, t]) => {
56210
56314
  typeof t == `string` ? a.push(` ${e}: "${t}",`) : (typeof t == `boolean` || typeof t == `number`) && a.push(` ${e}: ${t},`);
@@ -56217,7 +56321,7 @@ function x(e, t) {
56217
56321
  }), a.push(` ],`)), e.suggestionChipsConfig && (a.push(` suggestionChipsConfig: {`), e.suggestionChipsConfig.fontFamily && a.push(` fontFamily: "${e.suggestionChipsConfig.fontFamily}",`), e.suggestionChipsConfig.fontWeight && a.push(` fontWeight: "${e.suggestionChipsConfig.fontWeight}",`), e.suggestionChipsConfig.paddingX && a.push(` paddingX: "${e.suggestionChipsConfig.paddingX}",`), e.suggestionChipsConfig.paddingY && a.push(` paddingY: "${e.suggestionChipsConfig.paddingY}",`), a.push(` },`)), a.push(...l(e, ` `)), a.push(...u(e, ` `, n)), a.push(...d(e, ` `)), a.push(...p(e, ` `)), a.push(...m(n, ` `)), e.debug && a.push(` debug: ${e.debug},`), n?.postprocessMessage ? a.push(` postprocessMessage: ${n.postprocessMessage}`) : a.push(` postprocessMessage: ({ text }) => markdownPostprocessor(text)`), a.push(` }`), a.push(` });`), a.push(``), a.push(` // Cleanup on unmount`), a.push(` return () => {`), a.push(` if (handle) {`), a.push(` handle.destroy();`), a.push(` }`), a.push(` };`), a.push(` }, []);`), a.push(``), a.push(` return null; // Widget injects itself into the DOM`), a.push(`}`), a.push(``), a.push(`// Usage in your app:`), a.push(`// import { ChatWidget } from './components/ChatWidget';`), a.push(`//`), a.push(`// export default function App() {`), a.push(`// return (`), a.push(`// <div>`), a.push(`// {/* Your app content */}`), a.push(`// <ChatWidget />`), a.push(`// </div>`), a.push(`// );`), a.push(`// }`), a.join(`
56218
56322
  `);
56219
56323
  }
56220
- function S(e, t) {
56324
+ function T(e, t) {
56221
56325
  let n = t?.hooks, i = [
56222
56326
  `// ChatWidgetAdvanced.tsx`,
56223
56327
  `'use client'; // Required for Next.js - remove for Vite/CRA`,
@@ -56330,12 +56434,10 @@ function S(e, t) {
56330
56434
  ` };`,
56331
56435
  ``,
56332
56436
  ` handle = initAgentWidget({`,
56333
- ` target: '${v(t)}',`,
56437
+ ` target: '${b(t)}',`,
56334
56438
  ` config: {`
56335
56439
  ];
56336
- return e.apiUrl && i.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && i.push(` clientToken: "${e.clientToken}",`), e.agentId && i.push(` agentId: "${e.agentId}",`), e.target && i.push(` target: "${e.target}",`), e.flowId && i.push(` flowId: "${e.flowId}",`), _(i, e, ` `), e.theme && typeof e.theme == `object` && Object.keys(e.theme).length > 0 && g(i, `theme`, e.theme, ` `), e.launcher && g(i, `launcher`, e.launcher, ` `), e.copy && (i.push(` copy: {`), Object.entries(e.copy).forEach(([e, t]) => {
56337
- i.push(` ${e}: "${t}",`);
56338
- }), i.push(` },`)), e.sendButton && (i.push(` sendButton: {`), Object.entries(e.sendButton).forEach(([e, t]) => {
56440
+ return e.apiUrl && i.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && i.push(` clientToken: "${e.clientToken}",`), e.agentId && i.push(` agentId: "${e.agentId}",`), e.target && i.push(` target: "${e.target}",`), e.flowId && i.push(` flowId: "${e.flowId}",`), y(i, e, ` `), e.theme && typeof e.theme == `object` && Object.keys(e.theme).length > 0 && _(i, `theme`, e.theme, ` `), e.launcher && _(i, `launcher`, e.launcher, ` `), v(i, e, ` `), e.sendButton && (i.push(` sendButton: {`), Object.entries(e.sendButton).forEach(([e, t]) => {
56339
56441
  typeof t == `string` ? i.push(` ${e}: "${t}",`) : typeof t == `boolean` && i.push(` ${e}: ${t},`);
56340
56442
  }), i.push(` },`)), e.voiceRecognition && (i.push(` voiceRecognition: {`), Object.entries(e.voiceRecognition).forEach(([e, t]) => {
56341
56443
  typeof t == `string` ? i.push(` ${e}: "${t}",`) : (typeof t == `boolean` || typeof t == `number`) && i.push(` ${e}: ${t},`);
@@ -56354,9 +56456,9 @@ function S(e, t) {
56354
56456
  }),`)), 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}`), 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}`), 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(`
56355
56457
  `);
56356
56458
  }
56357
- function C(e) {
56459
+ function E(e) {
56358
56460
  let t = c(e), n = t !== `plain`, r = {};
56359
- if (e.apiUrl && (r.apiUrl = e.apiUrl), e.clientToken && (r.clientToken = e.clientToken), e.agentId && (r.agentId = e.agentId), e.target && (r.target = e.target), e.flowId && (r.flowId = e.flowId), n && (r.parserType = t), e.future?.v5Defaults !== void 0 && (r.future = { v5Defaults: e.future.v5Defaults === !0 }), e.theme && (r.theme = e.theme), e.launcher && (r.launcher = e.launcher), e.copy && (r.copy = e.copy), e.sendButton && (r.sendButton = e.sendButton), e.voiceRecognition && (r.voiceRecognition = e.voiceRecognition), e.statusIndicator && (r.statusIndicator = e.statusIndicator), e.features && (r.features = e.features), e.suggestions && (r.suggestions = e.suggestions), e.suggestionChips?.length > 0 && (r.suggestionChips = e.suggestionChips), e.suggestionChipsConfig && (r.suggestionChipsConfig = e.suggestionChipsConfig), e.debug && (r.debug = e.debug), e.toolCall) {
56461
+ if (e.apiUrl && (r.apiUrl = e.apiUrl), e.clientToken && (r.clientToken = e.clientToken), e.agentId && (r.agentId = e.agentId), e.target && (r.target = e.target), e.flowId && (r.flowId = e.flowId), n && (r.parserType = t), e.future?.v5Defaults !== void 0 && (r.future = { v5Defaults: e.future.v5Defaults === !0 }), e.theme && (r.theme = e.theme), e.brand && (r.brand = e.brand), e.darkTheme && (r.darkTheme = e.darkTheme), e.colorScheme !== void 0 && (r.colorScheme = e.colorScheme), e.launcher && (r.launcher = e.launcher), e.copy && (r.copy = e.copy), e.welcome !== void 0 && (r.welcome = e.welcome), e.approval !== void 0 && (r.approval = e.approval), e.sendButton && (r.sendButton = e.sendButton), e.voiceRecognition && (r.voiceRecognition = e.voiceRecognition), e.statusIndicator && (r.statusIndicator = e.statusIndicator), e.features && (r.features = e.features), e.suggestions && (r.suggestions = e.suggestions), e.suggestionChips?.length > 0 && (r.suggestionChips = e.suggestionChips), e.suggestionChipsConfig && (r.suggestionChipsConfig = e.suggestionChipsConfig), e.debug && (r.debug = e.debug), e.toolCall) {
56360
56462
  let t = {};
56361
56463
  Object.entries(e.toolCall).forEach(([e, n]) => {
56362
56464
  typeof n == `string` && (t[e] = n);
@@ -56398,15 +56500,15 @@ function C(e) {
56398
56500
  }
56399
56501
  return r;
56400
56502
  }
56401
- function w(t, n) {
56402
- let r = C(t), i = n?.windowKey || n?.target ? {
56503
+ function D(t, n) {
56504
+ let r = E(t), i = n?.windowKey || n?.target ? {
56403
56505
  config: r,
56404
56506
  ...n?.windowKey ? { windowKey: n.windowKey } : {},
56405
56507
  ...n?.target ? { target: n.target } : {}
56406
- } : r, a = JSON.stringify(i, null, 0).replace(/'/g, `&#39;`);
56508
+ } : r, a = JSON.stringify(i).replace(/&/g, `&amp;`).replace(/</g, `&lt;`).replace(/>/g, `&gt;`).replace(/'/g, `&#39;`);
56407
56509
  return `<script src="${e(n)}/install.global.js" data-config='${a}'><\/script>`;
56408
56510
  }
56409
- function T(t, n) {
56511
+ function O(t, n) {
56410
56512
  let r = n?.hooks, i = c(t), a = i !== `plain`, o = e(n), s = [
56411
56513
  `<!-- Load CSS -->`,
56412
56514
  `<link rel="stylesheet" href="${o}/widget.css" />`,
@@ -56417,13 +56519,11 @@ function T(t, n) {
56417
56519
  `<!-- Initialize widget -->`,
56418
56520
  `<script>`,
56419
56521
  ` var handle = window.AgentWidget.initAgentWidget({`,
56420
- ` target: '${v(n)}',`,
56522
+ ` target: '${b(n)}',`,
56421
56523
  ...n?.windowKey ? [` windowKey: '${n.windowKey}',`] : [],
56422
56524
  ` config: {`
56423
56525
  ];
56424
- return t.apiUrl && s.push(` apiUrl: "${t.apiUrl}",`), t.clientToken && s.push(` clientToken: "${t.clientToken}",`), t.agentId && s.push(` agentId: "${t.agentId}",`), t.target && s.push(` target: "${t.target}",`), t.flowId && s.push(` flowId: "${t.flowId}",`), a && s.push(` parserType: "${i}",`), _(s, t, ` `), t.theme && typeof t.theme == `object` && Object.keys(t.theme).length > 0 && g(s, `theme`, t.theme, ` `), t.launcher && g(s, `launcher`, t.launcher, ` `), t.copy && (s.push(` copy: {`), Object.entries(t.copy).forEach(([e, t]) => {
56425
- s.push(` ${e}: "${t}",`);
56426
- }), s.push(` },`)), t.sendButton && (s.push(` sendButton: {`), Object.entries(t.sendButton).forEach(([e, t]) => {
56526
+ return t.apiUrl && s.push(` apiUrl: "${t.apiUrl}",`), t.clientToken && s.push(` clientToken: "${t.clientToken}",`), t.agentId && s.push(` agentId: "${t.agentId}",`), t.target && s.push(` target: "${t.target}",`), t.flowId && s.push(` flowId: "${t.flowId}",`), a && s.push(` parserType: "${i}",`), y(s, t, ` `), t.theme && typeof t.theme == `object` && Object.keys(t.theme).length > 0 && _(s, `theme`, t.theme, ` `), t.launcher && _(s, `launcher`, t.launcher, ` `), v(s, t, ` `), t.sendButton && (s.push(` sendButton: {`), Object.entries(t.sendButton).forEach(([e, t]) => {
56427
56527
  typeof t == `string` ? s.push(` ${e}: "${t}",`) : typeof t == `boolean` && s.push(` ${e}: ${t},`);
56428
56528
  }), s.push(` },`)), t.voiceRecognition && (s.push(` voiceRecognition: {`), Object.entries(t.voiceRecognition).forEach(([e, t]) => {
56429
56529
  typeof t == `string` ? s.push(` ${e}: "${t}",`) : (typeof t == `boolean` || typeof t == `number`) && s.push(` ${e}: ${t},`);
@@ -56436,14 +56536,14 @@ function T(t, n) {
56436
56536
  }), s.push(` ],`)), t.suggestionChipsConfig && (s.push(` suggestionChipsConfig: {`), t.suggestionChipsConfig.fontFamily && s.push(` fontFamily: "${t.suggestionChipsConfig.fontFamily}",`), t.suggestionChipsConfig.fontWeight && s.push(` fontWeight: "${t.suggestionChipsConfig.fontWeight}",`), t.suggestionChipsConfig.paddingX && s.push(` paddingX: "${t.suggestionChipsConfig.paddingX}",`), t.suggestionChipsConfig.paddingY && s.push(` paddingY: "${t.suggestionChipsConfig.paddingY}",`), s.push(` },`)), s.push(...l(t, ` `)), s.push(...u(t, ` `, r)), s.push(...d(t, ` `)), s.push(...p(t, ` `)), s.push(...m(r, ` `)), t.debug && s.push(` debug: ${t.debug},`), r?.postprocessMessage ? s.push(` postprocessMessage: ${r.postprocessMessage}`) : s.push(` postprocessMessage: ({ text }) => window.AgentWidget.markdownPostprocessor(text)`), s.push(` }`), s.push(` });`), s.push(`<\/script>`), s.join(`
56437
56537
  `);
56438
56538
  }
56439
- function E(t, n) {
56440
- let r = n?.hooks, a = C(t), s = [
56539
+ function k(t, n) {
56540
+ let r = n?.hooks, a = [
56441
56541
  `<script>`,
56442
56542
  `(function() {`,
56443
56543
  ` 'use strict';`,
56444
56544
  ``,
56445
56545
  ` // Configuration`,
56446
- ` var CONFIG = ${JSON.stringify(a, null, 2).split(`
56546
+ ` var CONFIG = ${h(E(t), 2).split(`
56447
56547
  `).map((e, t) => t === 0 ? e : ` ` + e).join(`
56448
56548
  `)};`,
56449
56549
  ``,
@@ -56530,13 +56630,13 @@ function E(t, n) {
56530
56630
  ` var widgetConfig = Object.assign({}, CONFIG);`,
56531
56631
  ``
56532
56632
  ];
56533
- return r?.getHeaders && (s.push(` widgetConfig.getHeaders = ${r.getHeaders};`), s.push(``)), r?.contextProviders && (s.push(` widgetConfig.contextProviders = ${r.contextProviders};`), s.push(``)), r?.streamParser ? s.push(` widgetConfig.streamParser = ${r.streamParser};`) : (s.push(` // Flexible JSON stream parser for handling structured actions`), s.push(` widgetConfig.streamParser = function() {`), s.push(` return agentWidget.createFlexibleJsonStreamParser(function(parsed) {
56633
+ return r?.getHeaders && (a.push(` widgetConfig.getHeaders = ${r.getHeaders};`), a.push(``)), r?.contextProviders && (a.push(` widgetConfig.contextProviders = ${r.contextProviders};`), a.push(``)), r?.streamParser ? a.push(` widgetConfig.streamParser = ${r.streamParser};`) : (a.push(` // Flexible JSON stream parser for handling structured actions`), a.push(` widgetConfig.streamParser = function() {`), a.push(` return agentWidget.createFlexibleJsonStreamParser(function(parsed) {
56534
56634
  if (!parsed || typeof parsed !== 'object') return null;
56535
56635
  if (parsed.action === 'nav_then_click') return 'Navigating...';
56536
56636
  if (parsed.action === 'message') return parsed.text || '';
56537
56637
  if (parsed.action === 'message_and_click') return parsed.text || 'Processing...';
56538
56638
  return parsed.text || null;
56539
- });`), s.push(` };`)), s.push(``), r?.actionParsers ? (s.push(` // Action parsers (custom merged with defaults)`), s.push(` var customParsers = ${r.actionParsers};`), s.push(` widgetConfig.actionParsers = customParsers.concat([`), s.push(` agentWidget.defaultJsonActionParser,`), s.push(` ${i}`), s.push(` ]);`)) : (s.push(` // Action parsers to detect JSON actions in responses`), s.push(` widgetConfig.actionParsers = [`), s.push(` agentWidget.defaultJsonActionParser,`), s.push(` ${i}`), s.push(` ];`)), s.push(``), r?.actionHandlers ? (s.push(` // Action handlers (custom merged with defaults)`), s.push(` var customHandlers = ${r.actionHandlers};`), s.push(` widgetConfig.actionHandlers = customHandlers.concat([`), s.push(` agentWidget.defaultActionHandlers.message,`), s.push(` agentWidget.defaultActionHandlers.messageAndClick,`), s.push(` ${o}`), s.push(` ]);`)) : (s.push(` // Action handlers for navigation and other actions`), s.push(` widgetConfig.actionHandlers = [`), s.push(` agentWidget.defaultActionHandlers.message,`), s.push(` agentWidget.defaultActionHandlers.messageAndClick,`), s.push(` ${o}`), s.push(` ];`)), s.push(``), r?.requestMiddleware ? (s.push(` // Request middleware (custom merged with DOM context)`), s.push(` widgetConfig.requestMiddleware = function(ctx) {`), s.push(` var customResult = (${r.requestMiddleware})(ctx);`), s.push(` var merged = customResult || ctx.payload;`), s.push(` return Object.assign({}, merged, { metadata: Object.assign({}, merged.metadata, domContextProvider()) });`), s.push(` };`)) : (s.push(` // Send DOM context with each request`), s.push(` widgetConfig.requestMiddleware = function(ctx) {`), s.push(` return Object.assign({}, ctx.payload, { metadata: domContextProvider() });`), s.push(` };`)), s.push(``), r?.postprocessMessage ? s.push(` widgetConfig.postprocessMessage = ${r.postprocessMessage};`) : (s.push(` // Markdown postprocessor`), s.push(` widgetConfig.postprocessMessage = function(ctx) {`), s.push(` return agentWidget.markdownPostprocessor(ctx.text);`), s.push(` };`)), s.push(``), (r?.onFeedback || r?.onCopy) && (s.push(` // Message action callbacks`), s.push(` widgetConfig.messageActions = widgetConfig.messageActions || {};`), r?.onFeedback && s.push(` widgetConfig.messageActions.onFeedback = ${r.onFeedback};`), r?.onCopy && s.push(` widgetConfig.messageActions.onCopy = ${r.onCopy};`), s.push(``)), s.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: '${v(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>`), s.join(`
56639
+ });`), 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}`), a.push(` ]);`)) : (a.push(` // Action parsers to detect JSON actions in responses`), a.push(` widgetConfig.actionParsers = [`), a.push(` agentWidget.defaultJsonActionParser,`), a.push(` ${i}`), 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}`), 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}`), 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(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(`
56540
56640
  `);
56541
56641
  }
56542
56642
  //#endregion
@@ -56571,13 +56671,14 @@ function buildWidgetConfig(input) {
56571
56671
  return {
56572
56672
  apiUrl: input.apiUrl,
56573
56673
  clientToken: input.clientToken,
56574
- parserType: "json"
56674
+ parserType: "json",
56675
+ future: { v5Defaults: true }
56575
56676
  };
56576
56677
  }
56577
56678
  function generatePersonaInitSnippet(input, personaFormat) {
56578
56679
  const widgetConfig = buildWidgetConfig(input);
56579
56680
  const target = input.targetSelector?.trim();
56580
- return y(widgetConfig, personaFormat, target ? { target } : void 0);
56681
+ return x(widgetConfig, personaFormat, target ? { target } : void 0);
56581
56682
  }
56582
56683
  /**
56583
56684
  * Return the version-pinned Persona CDN installer URL from the same generator
@@ -56585,7 +56686,7 @@ function generatePersonaInitSnippet(input, personaFormat) {
56585
56686
  * a second manually-maintained Persona version string in the CLI.
56586
56687
  */
56587
56688
  function getPersonaInstallerScriptUrl() {
56588
- return y({
56689
+ return x({
56589
56690
  apiUrl: "https://api.runtype.com",
56590
56691
  clientToken: "ct_test_demo_00000000000000000000000000000000",
56591
56692
  parserType: "json"
@@ -57322,6 +57423,7 @@ function generatePersonaDemoHtml(input) {
57322
57423
  apiUrl: demo.apiUrl,
57323
57424
  clientToken: demo.clientToken,
57324
57425
  parserType: 'json',
57426
+ future: { v5Defaults: true },
57325
57427
  launcher: {
57326
57428
  enabled: true,
57327
57429
  autoExpand: true,
@@ -59154,6 +59256,7 @@ function buildEventsQuery(options, after) {
59154
59256
  ["surfaceId", options.surface],
59155
59257
  ["scheduleId", options.schedule],
59156
59258
  ["suiteId", options.suite],
59259
+ ["simulationId", options.simulation],
59157
59260
  ["taskId", options.task],
59158
59261
  ["key", options.key],
59159
59262
  ["onlyRegressions", options.onlyRegressions ? "true" : void 0],
@@ -59322,7 +59425,7 @@ const eventsCommand = new Command("events").description("Watch product events (f
59322
59425
  eventsCommand.command("types").description("List the product event types you can watch").option("--json", "Output as JSON").option("--no-color", "Disable color output").action(async (options) => {
59323
59426
  await runTypes(options);
59324
59427
  });
59325
- eventsCommand.command("watch").description("Long-poll product events and print one line per event").option("--name <name>", "Event type to watch (default: every type; see `runtype events types`)").option("--agent <id>", "Filter by agent ID").option("--flow <id>", "Filter by flow ID").option("--product <id>", "Filter by product ID").option("--surface <id>", "Filter by surface ID").option("--schedule <id>", "Filter by schedule ID").option("--suite <id>", "Filter by eval suite ID").option("--task <id>", "Filter by delegated task ID").option("--key <key>", "Signal events: only this signal key, such as tool_error").option("--only-regressions", "Eval runs: only those whose pass rate dropped").option("--since <cursor>", "Start after this cursor, or \"now\" (default)").option("--json", "Output NDJSON: one event object per line on stdout").option("--once", "Exit after the first poll that returns events").option("--no-color", "Disable color output").action(async (options) => {
59428
+ eventsCommand.command("watch").description("Long-poll product events and print one line per event").option("--name <name>", "Event type to watch (default: every type; see `runtype events types`)").option("--agent <id>", "Filter by agent ID").option("--flow <id>", "Filter by flow ID").option("--product <id>", "Filter by product ID").option("--surface <id>", "Filter by surface ID").option("--schedule <id>", "Filter by schedule ID").option("--suite <id>", "Filter by eval suite ID").option("--simulation <id>", "Filter by simulation ID").option("--task <id>", "Filter by delegated task ID").option("--key <key>", "Signal events: only this signal key, such as tool_error").option("--only-regressions", "Eval runs: only those whose pass rate dropped").option("--since <cursor>", "Start after this cursor, or \"now\" (default)").option("--json", "Output NDJSON: one event object per line on stdout").option("--once", "Exit after the first poll that returns events").option("--no-color", "Disable color output").action(async (options) => {
59326
59429
  await runWatch(options);
59327
59430
  });
59328
59431
  //#endregion
@@ -63715,7 +63818,7 @@ object({
63715
63818
  revealed: array(string()).optional()
63716
63819
  });
63717
63820
  //#endregion
63718
- //#region ../shared/dist/chunk-DwsXhSgv.mjs
63821
+ //#region ../shared/dist/chunk-C_UG0PQc.mjs
63719
63822
  /** Every change kind a scrub report can name; a leaf so the data-source contracts reach it without the scrubber. */
63720
63823
  const METADATA_SCRUB_CHANGE_KIND_NAMES = [
63721
63824
  "url_redirected",
@@ -63770,7 +63873,7 @@ const productKindSchema = _enum([
63770
63873
  "spec_only"
63771
63874
  ]);
63772
63875
  //#endregion
63773
- //#region ../shared/dist/chunk-D0CW0BS7.mjs
63876
+ //#region ../shared/dist/chunk-CTgbBN2x.mjs
63774
63877
  /** The manifest file at the root of a candidate's source bundle. */
63775
63878
  const CANDIDATE_MANIFEST_FILENAME = "runtype-candidate.json";
63776
63879
  const candidateRuntimeSchema = _enum([
@@ -66528,6 +66631,12 @@ const simulationRunResponseSchema = object({
66528
66631
  reportId: entityId.nullable()
66529
66632
  });
66530
66633
  object({ run: simulationRunSchema });
66634
+ simulationRunResponseSchema.extend({ repair: object({
66635
+ /** Episodes whose AI judge failed, graded again from their stored transcripts. */
66636
+ regrading: number$1().int(),
66637
+ /** Episodes the platform kept from running, played again under fresh episode ids. */
66638
+ replaying: number$1().int()
66639
+ }) });
66531
66640
  simulationRunResponseSchema.extend({ advance: object({
66532
66641
  /** Episodes this call finished; one it parked at the time budget resumes on the next call. */
66533
66642
  episodesFinished: number$1().int(),
@@ -66619,6 +66728,7 @@ object({
66619
66728
  "SIMULATION_OVERLAY_INVALID",
66620
66729
  "SIMULATION_OVERLAY_NOT_OWN_TARGET",
66621
66730
  "SIMULATION_RUN_NOT_CANCELLABLE",
66731
+ "SIMULATION_RUN_NOT_REPAIRABLE",
66622
66732
  "SIMULATION_VARIANT_INVALID",
66623
66733
  "SIMULATION_IDENTITY_INVALID",
66624
66734
  "SIMULATION_FORBIDDEN",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runtypelabs/cli",
3
- "version": "2.53.3",
3
+ "version": "2.54.0",
4
4
  "description": "Command-line interface for Runtype AI platform",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -12,7 +12,7 @@
12
12
  "@modelcontextprotocol/core": "2.3.1",
13
13
  "@napi-rs/keyring": "2.1.0",
14
14
  "@runtypelabs/ink-components": "0.3.12",
15
- "@runtypelabs/sdk": "11.7.0",
15
+ "@runtypelabs/sdk": "11.7.1",
16
16
  "@runtypelabs/terminal-animations": "0.2.4",
17
17
  "add-mcp": "2.0.0",
18
18
  "chalk": "^5.3.0",
@@ -35,8 +35,8 @@
35
35
  "devDependencies": {
36
36
  "@modelcontextprotocol/server": "2.3.1",
37
37
  "@runtypelabs/device-bridge": "0.2.4",
38
- "@runtypelabs/persona": "4.29.2",
39
- "@runtypelabs/shared": "3.95.1",
38
+ "@runtypelabs/persona": "4.32.2",
39
+ "@runtypelabs/shared": "3.96.0",
40
40
  "@types/express": "^5.0.6",
41
41
  "@types/micromatch": "^4.0.9",
42
42
  "@types/node": "^25.3.3",