@runtypelabs/cli 2.53.1 → 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 +304 -249
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -10675,6 +10675,26 @@ function parseRecordCollectionSchema(input) {
10675
10675
  }))
10676
10676
  };
10677
10677
  }
10678
+ //#endregion
10679
+ //#region ../shared/dist/browser-domain-policy.mjs
10680
+ function canonicalHostname(hostname) {
10681
+ let end = hostname.length;
10682
+ while (end > 0 && hostname.charCodeAt(end - 1) === 46) end--;
10683
+ return hostname.slice(0, end).toLowerCase();
10684
+ }
10685
+ const DOMAIN_LABEL = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
10686
+ const MAX_HOSTNAME_LENGTH = 253;
10687
+ /** Trim, lowercase and strip trailing dots, as Stagehand canonicalizes both patterns and hostnames. */
10688
+ function canonicalBrowserDomainPattern(pattern) {
10689
+ return canonicalHostname(pattern.trim());
10690
+ }
10691
+ /** Exactly what Stagehand's `normalizeDomainPattern` accepts, for an already-canonical pattern. */
10692
+ function isValidBrowserDomainPattern(pattern) {
10693
+ const hostname = pattern.startsWith("*.") ? pattern.slice(2) : pattern;
10694
+ if (!hostname || hostname.length > MAX_HOSTNAME_LENGTH) return false;
10695
+ const labels = hostname.split(".");
10696
+ return labels.length >= 2 && labels.every((label) => DOMAIN_LABEL.test(label));
10697
+ }
10678
10698
  /** Compaction strategies; the config schema's zod enum derives from this tuple so the two cannot drift. */
10679
10699
  const COMPACTION_STRATEGIES = [
10680
10700
  "auto",
@@ -10796,7 +10816,9 @@ object({
10796
10816
  schemaTokens: number$1().int().min(0).optional(),
10797
10817
  passes: number$1().int().min(0).optional()
10798
10818
  });
10799
- const FLOW_STEP_TYPES = ["prompt", ...[
10819
+ //#endregion
10820
+ //#region ../shared/dist/chunk-BQYclXzM.mjs
10821
+ const CONTEXT_STEP_TYPES = [
10800
10822
  "crawl",
10801
10823
  "fetch-url",
10802
10824
  "retrieve-record",
@@ -10827,7 +10849,8 @@ const FLOW_STEP_TYPES = ["prompt", ...[
10827
10849
  "recall-memory",
10828
10850
  "memory-summary",
10829
10851
  "extract"
10830
- ]];
10852
+ ];
10853
+ const FLOW_STEP_TYPES = ["prompt", ...CONTEXT_STEP_TYPES];
10831
10854
  //#endregion
10832
10855
  //#region ../shared/dist/durable-poll-limits.mjs
10833
10856
  /**
@@ -11520,7 +11543,7 @@ object({
11520
11543
  importedAt: string().datetime({ offset: true }).optional()
11521
11544
  });
11522
11545
  //#endregion
11523
- //#region ../shared/dist/chunk-DYf4FR-s.mjs
11546
+ //#region ../shared/dist/chunk-DPqK6XE9.mjs
11524
11547
  const voiceInterruptionModeSchema = _enum([
11525
11548
  "none",
11526
11549
  "cancel",
@@ -12520,6 +12543,53 @@ function validateBrowserToolConfigsAuth(toolConfigs, ctx) {
12520
12543
  });
12521
12544
  });
12522
12545
  }
12546
+ const BROWSER_DOMAIN_POLICY_MESSAGES = {
12547
+ notObject: "\"domainPolicy\" must be an object with \"allowedDomains\" and/or \"blockedDomains\" arrays.",
12548
+ empty: "\"domainPolicy\" must list at least one domain in \"allowedDomains\" or \"blockedDomains\".",
12549
+ listEmpty: "\"domainPolicy\" lists must not be empty; omit the key instead (an empty list does not mean \"allow nothing\").",
12550
+ patternShape: "\"domainPolicy\" entries must be bare hostnames such as \"example.com\" or \"*.example.com\" (no scheme, port, path or inner wildcard).",
12551
+ patternIp: "\"domainPolicy\" entries must be DNS hostnames, not IP addresses.",
12552
+ allowedTooMany: "\"domainPolicy.allowedDomains\" accepts at most 50 entries (the Browser Run guardrails limit).",
12553
+ noBrowsing: (toolId) => `"domainPolicy" has no effect on ${toolId}, which takes no browsing action; set it on browser:open, and the session keeps it.`
12554
+ };
12555
+ /** Session tools that never load a URL; a policy on them would be accepted and silently do nothing. */
12556
+ const BROWSER_TOOLS_WITHOUT_DOMAIN_POLICY = /* @__PURE__ */ new Set([
12557
+ "browser:session-info",
12558
+ "browser:close",
12559
+ "browser:get_live_view",
12560
+ "browser:request_handoff",
12561
+ "browser:get_handoff_state"
12562
+ ]);
12563
+ const domainListSchema = array(string({ error: BROWSER_DOMAIN_POLICY_MESSAGES.patternShape }).transform(canonicalBrowserDomainPattern).refine(isValidBrowserDomainPattern, {
12564
+ message: BROWSER_DOMAIN_POLICY_MESSAGES.patternShape,
12565
+ abort: true
12566
+ }).refine((pattern) => !isIpLiteralHost(pattern.replace(/^\*\./, "")), { message: BROWSER_DOMAIN_POLICY_MESSAGES.patternIp }), { error: BROWSER_DOMAIN_POLICY_MESSAGES.notObject }).min(1, { message: BROWSER_DOMAIN_POLICY_MESSAGES.listEmpty }).transform((patterns) => [...new Set(patterns)]);
12567
+ /** The `domainPolicy` block of a browser tool's config; operator-owned, never set from call arguments. */
12568
+ const browserDomainPolicySchema = strictObject({
12569
+ allowedDomains: domainListSchema.refine((patterns) => patterns.length <= 50, { message: BROWSER_DOMAIN_POLICY_MESSAGES.allowedTooMany }).optional(),
12570
+ blockedDomains: domainListSchema.optional()
12571
+ }, { error: BROWSER_DOMAIN_POLICY_MESSAGES.notObject }).refine((policy) => policy.allowedDomains !== void 0 || policy.blockedDomains !== void 0, { message: BROWSER_DOMAIN_POLICY_MESSAGES.empty });
12572
+ /** Save-time check for every browser tool config that carries a `domainPolicy` block. */
12573
+ function validateBrowserToolConfigsDomainPolicy(toolConfigs, ctx) {
12574
+ Object.entries(toolConfigs).filter(([key]) => isBrowserToolConfigKey(key)).filter(([, config]) => "domainPolicy" in config).forEach(([key, config]) => {
12575
+ const toolId = getBuiltInToolById(parseToolInstanceId(key).baseId)?.id ?? key;
12576
+ if (BROWSER_TOOLS_WITHOUT_DOMAIN_POLICY.has(toolId)) {
12577
+ ctx.addIssue({
12578
+ code: "custom",
12579
+ path: [key, "domainPolicy"],
12580
+ message: BROWSER_DOMAIN_POLICY_MESSAGES.noBrowsing(toolId)
12581
+ });
12582
+ return;
12583
+ }
12584
+ browserDomainPolicySchema.safeParse(config.domainPolicy).error?.issues.slice(0, 1).forEach((issue) => {
12585
+ ctx.addIssue({
12586
+ code: "custom",
12587
+ path: [key, "domainPolicy"],
12588
+ message: issue.message
12589
+ });
12590
+ });
12591
+ });
12592
+ }
12523
12593
  /** How a conversation is reduced when it approaches the model's context window. */
12524
12594
  const compactionStrategySchema = _enum(COMPACTION_STRATEGIES);
12525
12595
  /**
@@ -12857,7 +12927,7 @@ const agentRuntimeConfigSchema = object({
12857
12927
  ...samplingConfigSchema,
12858
12928
  tools: object({
12859
12929
  toolIds: array(string()).optional(),
12860
- toolConfigs: record(string(), record(string(), unknown())).superRefine(validateBrowserToolConfigsAuth).optional(),
12930
+ toolConfigs: record(string(), record(string(), unknown())).superRefine(validateBrowserToolConfigsAuth).superRefine(validateBrowserToolConfigsDomainPolicy).optional(),
12861
12931
  runtimeTools: array(object({
12862
12932
  name: string(),
12863
12933
  description: string(),
@@ -14586,13 +14656,39 @@ function validateAndNormalizeErrorHandling(value, fieldName, stepType) {
14586
14656
  }
14587
14657
  return normalizeErrorHandling(value);
14588
14658
  }
14589
- /**
14590
- * Normalize a context step from API format (snake_case) to internal format (camelCase)
14591
- * Only normalizes known API structure fields, preserves all user data
14592
- * @throws {NormalizationError} If validation fails
14593
- */
14594
- function normalizeContextStep(apiStep, options = {}) {
14595
- if (!apiStep || typeof apiStep !== "object") throw new NormalizationError("Step must be a valid object", "unknown", "apiStep", "object", typeof apiStep);
14659
+ /** The config normalizer for every step type whose normalized step is just the envelope plus its config. */
14660
+ const CONTEXT_STEP_CONFIG_NORMALIZERS = {
14661
+ "crawl": normalizeCrawlConfig,
14662
+ "fetch-url": normalizeFetchUrlConfig,
14663
+ "get-record": normalizeGetRecordConfig,
14664
+ "list-records": normalizeListRecordsConfig,
14665
+ "api-call": normalizeApiCallConfig,
14666
+ "transform-data": normalizeTransformDataConfig,
14667
+ "template": normalizeTemplateConfig,
14668
+ "conditional": normalizeConditionalConfig,
14669
+ "set-variable": normalizeSetVariableConfig,
14670
+ "upsert-record": normalizeUpsertRecordConfig,
14671
+ "send-email": normalizeSendEmailConfig,
14672
+ "send-event": normalizeSendEventConfig,
14673
+ "send-stream": normalizeSendStreamConfig,
14674
+ "update-record": normalizeUpdateRecordConfig,
14675
+ "search": normalizeSearchConfig,
14676
+ "generate-embedding": normalizeGenerateEmbeddingConfig,
14677
+ "vector-search": normalizeVectorSearchConfig,
14678
+ "paginate-api": normalizePaginateApiConfig,
14679
+ "store-vector": normalizeStoreVectorConfig,
14680
+ "tool-call": normalizeToolCallConfig,
14681
+ "wait-until": normalizeWaitUntilConfig,
14682
+ "execute-agent": normalizeExecuteAgentConfig,
14683
+ "store-asset": normalizeStoreAssetConfig,
14684
+ "generate-pdf": normalizeGeneratePdfConfig,
14685
+ "save-memory": normalizeSaveMemoryConfig,
14686
+ "recall-memory": normalizeRecallMemoryConfig,
14687
+ "memory-summary": normalizeMemorySummaryConfig,
14688
+ "extract": normalizeExtractConfig
14689
+ };
14690
+ /** Envelope validation: a usable id, type, name and order, and a known step type. */
14691
+ function validateContextStepEnvelope(apiStep) {
14596
14692
  validateRequired(apiStep.id, "id", apiStep.type || "unknown");
14597
14693
  validateRequired(apiStep.type, "type", "step");
14598
14694
  validateRequired(apiStep.name, "name", apiStep.type || "unknown");
@@ -14601,39 +14697,38 @@ function normalizeContextStep(apiStep, options = {}) {
14601
14697
  validateString(apiStep.type, "type", "step", true);
14602
14698
  validateString(apiStep.name, "name", apiStep.type, true);
14603
14699
  validateNumber(apiStep.order, "order", apiStep.type, true);
14604
- const validStepTypes = [
14605
- "crawl",
14606
- "fetch-url",
14607
- "retrieve-record",
14608
- "get-record",
14609
- "list-records",
14610
- "api-call",
14611
- "transform-data",
14612
- "template",
14613
- "conditional",
14614
- "loop",
14615
- "set-variable",
14616
- "upsert-record",
14617
- "send-email",
14618
- "send-event",
14619
- "send-stream",
14620
- "update-record",
14621
- "search",
14622
- "generate-embedding",
14623
- "vector-search",
14624
- "tool-call",
14625
- "wait-until",
14626
- "paginate-api",
14627
- "store-vector",
14628
- "execute-agent",
14629
- "store-asset",
14630
- "generate-pdf",
14631
- "save-memory",
14632
- "recall-memory",
14633
- "memory-summary",
14634
- "extract"
14635
- ];
14636
- if (!validStepTypes.includes(apiStep.type)) throw new NormalizationError(`Unknown context step type: ${apiStep.type}. Must be one of: ${validStepTypes.join(", ")}`, apiStep.type, "type", `one of [${validStepTypes.join(", ")}]`, apiStep.type);
14700
+ if (!CONTEXT_STEP_TYPES.includes(apiStep.type)) throw new NormalizationError(`Unknown context step type: ${apiStep.type}. Must be one of: ${CONTEXT_STEP_TYPES.join(", ")}`, apiStep.type, "type", `one of [${CONTEXT_STEP_TYPES.join(", ")}]`, apiStep.type);
14701
+ }
14702
+ function normalizeContextStepByType(apiStep, baseStep, options) {
14703
+ switch (apiStep.type) {
14704
+ case "retrieve-record": {
14705
+ const aliased = resolveRetrieveRecordAlias(normalizeRetrieveRecordConfig(apiStep.config));
14706
+ return {
14707
+ ...baseStep,
14708
+ type: aliased.type,
14709
+ config: aliased.config
14710
+ };
14711
+ }
14712
+ case "loop": return lowerLoopToConditional(baseStep, apiStep.config);
14713
+ default: {
14714
+ const normalizeConfig = CONTEXT_STEP_CONFIG_NORMALIZERS[apiStep.type];
14715
+ if (!normalizeConfig) throw new NormalizationError(`Unknown context step type: ${apiStep.type}`, apiStep.type, "type", "valid step type", apiStep.type);
14716
+ return {
14717
+ ...baseStep,
14718
+ type: apiStep.type,
14719
+ config: normalizeConfig(apiStep.config, options)
14720
+ };
14721
+ }
14722
+ }
14723
+ }
14724
+ /**
14725
+ * Normalize a context step from API format (snake_case) to internal format (camelCase)
14726
+ * Only normalizes known API structure fields, preserves all user data
14727
+ * @throws {NormalizationError} If validation fails
14728
+ */
14729
+ function normalizeContextStep(apiStep, options = {}) {
14730
+ if (!apiStep || typeof apiStep !== "object") throw new NormalizationError("Step must be a valid object", "unknown", "apiStep", "object", typeof apiStep);
14731
+ validateContextStepEnvelope(apiStep);
14637
14732
  const baseStep = {
14638
14733
  id: apiStep.id,
14639
14734
  type: apiStep.type,
@@ -14643,158 +14738,7 @@ function normalizeContextStep(apiStep, options = {}) {
14643
14738
  ...typeof apiStep.when === "string" ? { when: apiStep.when } : {}
14644
14739
  };
14645
14740
  try {
14646
- switch (apiStep.type) {
14647
- case "crawl": return {
14648
- ...baseStep,
14649
- type: "crawl",
14650
- config: normalizeCrawlConfig(apiStep.config)
14651
- };
14652
- case "fetch-url": return {
14653
- ...baseStep,
14654
- type: "fetch-url",
14655
- config: normalizeFetchUrlConfig(apiStep.config)
14656
- };
14657
- case "retrieve-record": {
14658
- const aliased = resolveRetrieveRecordAlias(normalizeRetrieveRecordConfig(apiStep.config));
14659
- return {
14660
- ...baseStep,
14661
- type: aliased.type,
14662
- config: aliased.config
14663
- };
14664
- }
14665
- case "get-record": return {
14666
- ...baseStep,
14667
- type: "get-record",
14668
- config: normalizeGetRecordConfig(apiStep.config)
14669
- };
14670
- case "list-records": return {
14671
- ...baseStep,
14672
- type: "list-records",
14673
- config: normalizeListRecordsConfig(apiStep.config)
14674
- };
14675
- case "api-call": return {
14676
- ...baseStep,
14677
- type: "api-call",
14678
- config: normalizeApiCallConfig(apiStep.config)
14679
- };
14680
- case "transform-data": return {
14681
- ...baseStep,
14682
- type: "transform-data",
14683
- config: normalizeTransformDataConfig(apiStep.config)
14684
- };
14685
- case "template": return {
14686
- ...baseStep,
14687
- type: "template",
14688
- config: normalizeTemplateConfig(apiStep.config)
14689
- };
14690
- case "conditional": return {
14691
- ...baseStep,
14692
- type: "conditional",
14693
- config: normalizeConditionalConfig(apiStep.config)
14694
- };
14695
- case "loop": return lowerLoopToConditional(baseStep, apiStep.config);
14696
- case "set-variable": return {
14697
- ...baseStep,
14698
- type: "set-variable",
14699
- config: normalizeSetVariableConfig(apiStep.config)
14700
- };
14701
- case "upsert-record": return {
14702
- ...baseStep,
14703
- type: "upsert-record",
14704
- config: normalizeUpsertRecordConfig(apiStep.config)
14705
- };
14706
- case "send-email": return {
14707
- ...baseStep,
14708
- type: "send-email",
14709
- config: normalizeSendEmailConfig(apiStep.config, options)
14710
- };
14711
- case "send-event": return {
14712
- ...baseStep,
14713
- type: "send-event",
14714
- config: normalizeSendEventConfig(apiStep.config)
14715
- };
14716
- case "send-stream": return {
14717
- ...baseStep,
14718
- type: "send-stream",
14719
- config: normalizeSendStreamConfig(apiStep.config)
14720
- };
14721
- case "update-record": return {
14722
- ...baseStep,
14723
- type: "update-record",
14724
- config: normalizeUpdateRecordConfig(apiStep.config)
14725
- };
14726
- case "search": return {
14727
- ...baseStep,
14728
- type: "search",
14729
- config: normalizeSearchConfig(apiStep.config)
14730
- };
14731
- case "generate-embedding": return {
14732
- ...baseStep,
14733
- type: "generate-embedding",
14734
- config: normalizeGenerateEmbeddingConfig(apiStep.config)
14735
- };
14736
- case "vector-search": return {
14737
- ...baseStep,
14738
- type: "vector-search",
14739
- config: normalizeVectorSearchConfig(apiStep.config)
14740
- };
14741
- case "paginate-api": return {
14742
- ...baseStep,
14743
- type: "paginate-api",
14744
- config: normalizePaginateApiConfig(apiStep.config)
14745
- };
14746
- case "store-vector": return {
14747
- ...baseStep,
14748
- type: "store-vector",
14749
- config: normalizeStoreVectorConfig(apiStep.config)
14750
- };
14751
- case "tool-call": return {
14752
- ...baseStep,
14753
- type: "tool-call",
14754
- config: normalizeToolCallConfig(apiStep.config)
14755
- };
14756
- case "wait-until": return {
14757
- ...baseStep,
14758
- type: "wait-until",
14759
- config: normalizeWaitUntilConfig(apiStep.config)
14760
- };
14761
- case "execute-agent": return {
14762
- ...baseStep,
14763
- type: "execute-agent",
14764
- config: normalizeExecuteAgentConfig(apiStep.config)
14765
- };
14766
- case "store-asset": return {
14767
- ...baseStep,
14768
- type: "store-asset",
14769
- config: normalizeStoreAssetConfig(apiStep.config)
14770
- };
14771
- case "generate-pdf": return {
14772
- ...baseStep,
14773
- type: "generate-pdf",
14774
- config: normalizeGeneratePdfConfig(apiStep.config)
14775
- };
14776
- case "save-memory": return {
14777
- ...baseStep,
14778
- type: "save-memory",
14779
- config: normalizeSaveMemoryConfig(apiStep.config)
14780
- };
14781
- case "recall-memory": return {
14782
- ...baseStep,
14783
- type: "recall-memory",
14784
- config: normalizeRecallMemoryConfig(apiStep.config)
14785
- };
14786
- case "memory-summary": return {
14787
- ...baseStep,
14788
- type: "memory-summary",
14789
- config: normalizeMemorySummaryConfig(apiStep.config)
14790
- };
14791
- case "extract": return {
14792
- ...baseStep,
14793
- type: "extract",
14794
- config: normalizeExtractConfig(apiStep.config)
14795
- };
14796
- default: throw new NormalizationError(`Unknown context step type: ${apiStep.type}`, apiStep.type, "type", "valid step type", apiStep.type);
14797
- }
14741
+ return normalizeContextStepByType(apiStep, baseStep, options);
14798
14742
  } catch (error) {
14799
14743
  if (error instanceof NormalizationError) throw error;
14800
14744
  throw new NormalizationError(`Failed to normalize ${apiStep.type} step: ${error instanceof Error ? error.message : String(error)}`, apiStep.type, void 0, void 0, error);
@@ -23964,6 +23908,13 @@ object({
23964
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."),
23965
23909
  batchExecutionId: string().nullable().describe("The batch whose per-record runs are GET /v1/runs?batchExecutionId=.")
23966
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");
23967
23918
  /**
23968
23919
  * The same attribute names, exported for readers of GenAI spans.
23969
23920
  * OTLP trace ingest reads back the identical vocabulary a customer's own SDK produced.
@@ -24449,7 +24400,7 @@ _enum([
24449
24400
  "interrupted"
24450
24401
  ]);
24451
24402
  //#endregion
24452
- //#region ../shared/dist/chunk-B4rF4aQI.mjs
24403
+ //#region ../shared/dist/chunk-BCcCVYD-.mjs
24453
24404
  /**
24454
24405
  * Maps model families to provider-specific model IDs.
24455
24406
  * Use for routing: family + provider → exact model ID
@@ -24979,6 +24930,7 @@ const MODEL_FAMILY_PROVIDER_IDS = {
24979
24930
  "openai": "gpt-6.1-sol",
24980
24931
  "vercel": "openai/gpt-6.1-sol"
24981
24932
  },
24933
+ "gpt-6-1-sol-ultrafast": { "openai": "gpt-6.1-sol-ultrafast" },
24982
24934
  "gpt-6-1-sol-batch": { "vercel": "openai/gpt-6.1-sol-batch" },
24983
24935
  "gpt-6-1-sol-fast": { "vercel": "openai/gpt-6.1-sol-fast" },
24984
24936
  "gpt-6-astra": {
@@ -25003,6 +24955,7 @@ const MODEL_FAMILY_PROVIDER_IDS = {
25003
24955
  "openai": "gpt-6.1-sol",
25004
24956
  "vercel": "openai/gpt-6.1-sol"
25005
24957
  },
24958
+ "gpt-6.1-sol-ultrafast": { "openai": "gpt-6.1-sol-ultrafast" },
25006
24959
  "gpt-6.1-sol-batch": { "vercel": "openai/gpt-6.1-sol-batch" },
25007
24960
  "gpt-6.1-sol-fast": { "vercel": "openai/gpt-6.1-sol-fast" },
25008
24961
  "gpt-image-1-5": { "openai": "gpt-image-1.5" },
@@ -25546,7 +25499,7 @@ const CREATOR_TO_PROVIDER = {
25546
25499
  "unknown": "openai"
25547
25500
  };
25548
25501
  //#endregion
25549
- //#region ../shared/dist/chunk-56H9IdjP.mjs
25502
+ //#region ../shared/dist/chunk-jaE_lS2E.mjs
25550
25503
  const DEFAULT_GENERIC_OPENAI_API_FORMAT = "chat-completions";
25551
25504
  /** Provider defaults shared by every execution engine and deploy guidance. */
25552
25505
  const DEFAULT_BEDROCK_REGION = "us-east-1";
@@ -25974,7 +25927,7 @@ function loadBrandConfig(env) {
25974
25927
  loadBrandConfig();
25975
25928
  BRAND_CONFIGS[DEFAULT_BRAND_NAME];
25976
25929
  //#endregion
25977
- //#region ../shared/dist/chunk-BXwQFtLl.mjs
25930
+ //#region ../shared/dist/chunk-CNTixTjk.mjs
25978
25931
  const ARCHITECTURE_PREVIEW_SURFACE_TYPES = [
25979
25932
  "chat",
25980
25933
  "api",
@@ -27487,6 +27440,7 @@ const PRODUCT_EVENT_NAMES = [
27487
27440
  "runtype.approval.requested",
27488
27441
  "runtype.schedule.run_failed",
27489
27442
  "runtype.eval.run_completed",
27443
+ "runtype.simulation.run_completed",
27490
27444
  "runtype.conversation.human_takeover",
27491
27445
  "runtype.skill.proposal_created",
27492
27446
  "runtype.task.input_required",
@@ -27512,6 +27466,7 @@ const ProductEventFilterFieldSchemas = {
27512
27466
  surfaceId: resourceId("Only occurrences on this surface"),
27513
27467
  scheduleId: resourceId("Only occurrences for this schedule"),
27514
27468
  suiteId: resourceId("Only occurrences for this eval suite"),
27469
+ simulationId: resourceId("Only occurrences for this simulation"),
27515
27470
  taskId: resourceId("Only occurrences for this delegated task"),
27516
27471
  key: string().min(1).max(64).describe("Only signal occurrences for this signal key, such as tool_error"),
27517
27472
  onlyRegressions: boolean().describe("Only eval runs whose pass rate dropped below the previous run"),
@@ -27537,6 +27492,10 @@ const EvalRunCompletedArgumentsSchema = object({
27537
27492
  suiteId: filter.suiteId.optional(),
27538
27493
  onlyRegressions: filter.onlyRegressions.optional()
27539
27494
  }).strict();
27495
+ const SimulationRunCompletedArgumentsSchema = object({
27496
+ simulationId: filter.simulationId.optional(),
27497
+ productId: filter.productId.optional()
27498
+ }).strict();
27540
27499
  const ConversationHumanTakeoverArgumentsSchema = object({
27541
27500
  surfaceId: filter.surfaceId.optional(),
27542
27501
  productId: filter.productId.optional()
@@ -27559,6 +27518,7 @@ object({
27559
27518
  surfaceId: filter.surfaceId.optional(),
27560
27519
  scheduleId: filter.scheduleId.optional(),
27561
27520
  suiteId: filter.suiteId.optional(),
27521
+ simulationId: filter.simulationId.optional(),
27562
27522
  taskId: filter.taskId.optional(),
27563
27523
  key: filter.key.optional(),
27564
27524
  onlyRegressions: filter.onlyRegressions.optional(),
@@ -27602,6 +27562,23 @@ const EvalRunCompletedPayloadSchema = object({
27602
27562
  regressed: boolean().describe("True when passRate is below previousPassRate"),
27603
27563
  completedAt: isoTimestamp("When the run finished")
27604
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
+ });
27605
27582
  const ConversationHumanTakeoverPayloadSchema = object({
27606
27583
  conversationId: resourceId("The conversation a human took over"),
27607
27584
  surfaceId: resourceId("Surface the conversation is on").optional(),
@@ -27667,6 +27644,7 @@ const PRODUCT_EVENT_ARGUMENT_SCHEMAS = {
27667
27644
  "runtype.approval.requested": ApprovalRequestedArgumentsSchema,
27668
27645
  "runtype.schedule.run_failed": ScheduleRunFailedArgumentsSchema,
27669
27646
  "runtype.eval.run_completed": EvalRunCompletedArgumentsSchema,
27647
+ "runtype.simulation.run_completed": SimulationRunCompletedArgumentsSchema,
27670
27648
  "runtype.conversation.human_takeover": ConversationHumanTakeoverArgumentsSchema,
27671
27649
  "runtype.skill.proposal_created": SkillProposalCreatedArgumentsSchema,
27672
27650
  "runtype.task.input_required": DelegateTaskArgumentsSchema,
@@ -27681,6 +27659,7 @@ const PRODUCT_EVENT_PAYLOAD_SCHEMAS = {
27681
27659
  "runtype.approval.requested": ApprovalRequestedPayloadSchema,
27682
27660
  "runtype.schedule.run_failed": ScheduleRunFailedPayloadSchema,
27683
27661
  "runtype.eval.run_completed": EvalRunCompletedPayloadSchema,
27662
+ "runtype.simulation.run_completed": SimulationRunCompletedPayloadSchema,
27684
27663
  "runtype.conversation.human_takeover": ConversationHumanTakeoverPayloadSchema,
27685
27664
  "runtype.skill.proposal_created": SkillProposalCreatedPayloadSchema,
27686
27665
  "runtype.task.input_required": TaskInputRequiredPayloadSchema,
@@ -27695,6 +27674,7 @@ const PRODUCT_EVENT_DESCRIPTIONS = {
27695
27674
  "runtype.approval.requested": "An agent paused for a human to approve a tool call.",
27696
27675
  "runtype.schedule.run_failed": "A scheduled run of a flow or agent failed.",
27697
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.",
27698
27678
  "runtype.conversation.human_takeover": "A human took over a messaging conversation from the agent.",
27699
27679
  "runtype.skill.proposal_created": "A deployed agent proposed a skill that is waiting for review.",
27700
27680
  "runtype.task.input_required": "A delegated task stopped to ask a question; answer it by calling delegate_to_runtype with its task id.",
@@ -27710,6 +27690,11 @@ const PRODUCT_EVENT_REQUIRED_SCOPES = {
27710
27690
  "runtype.approval.requested": ["AGENTS:READ"],
27711
27691
  "runtype.schedule.run_failed": ["SCHEDULES:READ"],
27712
27692
  "runtype.eval.run_completed": ["EVALS:READ"],
27693
+ "runtype.simulation.run_completed": [
27694
+ "SIMULATIONS:READ",
27695
+ "SIMULATIONS:WRITE",
27696
+ "SIMULATIONS:RUN"
27697
+ ],
27713
27698
  "runtype.conversation.human_takeover": ["MESSAGING:READ"],
27714
27699
  "runtype.skill.proposal_created": ["SKILLS:READ"],
27715
27700
  "runtype.task.input_required": ["DELEGATE_TASKS:READ", "DELEGATE_TASKS:WRITE"],
@@ -41496,7 +41481,7 @@ function createSandboxInstructions(provider) {
41496
41481
  "{ \"code\": \"...\", \"parameters\": { ... }, \"language\": \"javascript|typescript|python\", \"timeoutMs\": 30000 }",
41497
41482
  "Runtype Sandbox rules:",
41498
41483
  "1. Choose one language: javascript, typescript, or python.",
41499
- "2. Each session is a full Linux container (Node 24, Python 3.13 with numpy/pandas/matplotlib, pnpm, tsx, uv, git).",
41484
+ "2. Each session is a full Linux container (Node 26, Python 3.15 with numpy/pandas/matplotlib, pnpm, tsx, uv, git).",
41500
41485
  "3. Inputs are available as the `parameters` object (JS/TS) or `parameters` dict (Python).",
41501
41486
  "4. async/await, Promises, and long-running processes are fully supported.",
41502
41487
  "5. Write the final result to stdout (JSON string is preferred for structured output).",
@@ -56053,9 +56038,9 @@ clientTokensCommand.command("regenerate <id>").description("Regenerate a client
56053
56038
  });
56054
56039
  clientTokensCommand.addCommand(clientTokenEnsureCommand);
56055
56040
  //#endregion
56056
- //#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
56057
56042
  function e(e) {
56058
- 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`;
56059
56044
  }
56060
56045
  function t(e) {
56061
56046
  if (e !== void 0) return typeof e == `string` ? e : Array.isArray(e) ? `[${e.map((e) => e.toString()).join(`, `)}]` : e.toString();
@@ -56193,41 +56178,106 @@ function m(e, t) {
56193
56178
  let n = [];
56194
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;
56195
56180
  }
56196
- 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) {
56197
56185
  Object.entries(t).forEach(([t, r]) => {
56198
- 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)},`);
56199
56189
  });
56200
56190
  }
56201
- function g(e, t, n, r) {
56202
- 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}},`));
56203
56193
  }
56204
- function _(e, t, n) {
56205
- t.future?.v5Defaults !== void 0 && e.push(`${n}future: { v5Defaults: ${t.future.v5Defaults === !0} },`);
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);
56206
56196
  }
56207
- function v(e) {
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)},`);
56199
+ }
56200
+ function b(e) {
56208
56201
  return (e?.target ?? `body`).replace(/\\/g, `\\\\`).replace(/'/g, `\\'`);
56209
56202
  }
56210
- function y(e, t = `esm`, r) {
56203
+ function x(e, t = `esm`, r) {
56204
+ if (r?.authoredOverrides) return S(e, t, r);
56211
56205
  let i = { ...e };
56212
56206
  delete i.postprocessMessage, delete i.initialMessages;
56213
56207
  let a = r ? {
56214
56208
  ...r,
56215
56209
  hooks: n(r.hooks)
56216
- } : void 0;
56217
- 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);
56218
- }
56219
- 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) {
56220
56272
  let n = t?.hooks, r = c(e), i = r !== `plain`, a = [
56221
56273
  `import '@runtypelabs/persona/widget.css';`,
56222
56274
  `import { initAgentWidget, markdownPostprocessor } from '@runtypelabs/persona';`,
56223
56275
  ``,
56224
56276
  `initAgentWidget({`,
56225
- ` target: '${v(t)}',`,
56277
+ ` target: '${b(t)}',`,
56226
56278
  ` config: {`
56227
56279
  ];
56228
- 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]) => {
56229
- a.push(` ${e}: "${t}",`);
56230
- }), 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]) => {
56231
56281
  typeof t == `string` ? a.push(` ${e}: "${t}",`) : typeof t == `boolean` && a.push(` ${e}: ${t},`);
56232
56282
  }), a.push(` },`)), e.voiceRecognition && (a.push(` voiceRecognition: {`), Object.entries(e.voiceRecognition).forEach(([e, t]) => {
56233
56283
  typeof t == `string` ? a.push(` ${e}: "${t}",`) : (typeof t == `boolean` || typeof t == `number`) && a.push(` ${e}: ${t},`);
@@ -56240,7 +56290,7 @@ function b(e, t) {
56240
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(`
56241
56291
  `);
56242
56292
  }
56243
- function x(e, t) {
56293
+ function w(e, t) {
56244
56294
  let n = t?.hooks, r = c(e), i = r !== `plain`, a = [
56245
56295
  `// ChatWidget.tsx`,
56246
56296
  `'use client'; // Required for Next.js - remove for Vite/CRA`,
@@ -56255,12 +56305,10 @@ function x(e, t) {
56255
56305
  ` let handle: AgentWidgetInitHandle | null = null;`,
56256
56306
  ``,
56257
56307
  ` handle = initAgentWidget({`,
56258
- ` target: '${v(t)}',`,
56308
+ ` target: '${b(t)}',`,
56259
56309
  ` config: {`
56260
56310
  ];
56261
- 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]) => {
56262
- a.push(` ${e}: "${t}",`);
56263
- }), 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]) => {
56264
56312
  typeof t == `string` ? a.push(` ${e}: "${t}",`) : typeof t == `boolean` && a.push(` ${e}: ${t},`);
56265
56313
  }), a.push(` },`)), e.voiceRecognition && (a.push(` voiceRecognition: {`), Object.entries(e.voiceRecognition).forEach(([e, t]) => {
56266
56314
  typeof t == `string` ? a.push(` ${e}: "${t}",`) : (typeof t == `boolean` || typeof t == `number`) && a.push(` ${e}: ${t},`);
@@ -56273,7 +56321,7 @@ function x(e, t) {
56273
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(`
56274
56322
  `);
56275
56323
  }
56276
- function S(e, t) {
56324
+ function T(e, t) {
56277
56325
  let n = t?.hooks, i = [
56278
56326
  `// ChatWidgetAdvanced.tsx`,
56279
56327
  `'use client'; // Required for Next.js - remove for Vite/CRA`,
@@ -56386,12 +56434,10 @@ function S(e, t) {
56386
56434
  ` };`,
56387
56435
  ``,
56388
56436
  ` handle = initAgentWidget({`,
56389
- ` target: '${v(t)}',`,
56437
+ ` target: '${b(t)}',`,
56390
56438
  ` config: {`
56391
56439
  ];
56392
- 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]) => {
56393
- i.push(` ${e}: "${t}",`);
56394
- }), 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]) => {
56395
56441
  typeof t == `string` ? i.push(` ${e}: "${t}",`) : typeof t == `boolean` && i.push(` ${e}: ${t},`);
56396
56442
  }), i.push(` },`)), e.voiceRecognition && (i.push(` voiceRecognition: {`), Object.entries(e.voiceRecognition).forEach(([e, t]) => {
56397
56443
  typeof t == `string` ? i.push(` ${e}: "${t}",`) : (typeof t == `boolean` || typeof t == `number`) && i.push(` ${e}: ${t},`);
@@ -56410,9 +56456,9 @@ function S(e, t) {
56410
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(`
56411
56457
  `);
56412
56458
  }
56413
- function C(e) {
56459
+ function E(e) {
56414
56460
  let t = c(e), n = t !== `plain`, r = {};
56415
- 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) {
56416
56462
  let t = {};
56417
56463
  Object.entries(e.toolCall).forEach(([e, n]) => {
56418
56464
  typeof n == `string` && (t[e] = n);
@@ -56454,15 +56500,15 @@ function C(e) {
56454
56500
  }
56455
56501
  return r;
56456
56502
  }
56457
- function w(t, n) {
56458
- let r = C(t), i = n?.windowKey || n?.target ? {
56503
+ function D(t, n) {
56504
+ let r = E(t), i = n?.windowKey || n?.target ? {
56459
56505
  config: r,
56460
56506
  ...n?.windowKey ? { windowKey: n.windowKey } : {},
56461
56507
  ...n?.target ? { target: n.target } : {}
56462
- } : 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;`);
56463
56509
  return `<script src="${e(n)}/install.global.js" data-config='${a}'><\/script>`;
56464
56510
  }
56465
- function T(t, n) {
56511
+ function O(t, n) {
56466
56512
  let r = n?.hooks, i = c(t), a = i !== `plain`, o = e(n), s = [
56467
56513
  `<!-- Load CSS -->`,
56468
56514
  `<link rel="stylesheet" href="${o}/widget.css" />`,
@@ -56473,13 +56519,11 @@ function T(t, n) {
56473
56519
  `<!-- Initialize widget -->`,
56474
56520
  `<script>`,
56475
56521
  ` var handle = window.AgentWidget.initAgentWidget({`,
56476
- ` target: '${v(n)}',`,
56522
+ ` target: '${b(n)}',`,
56477
56523
  ...n?.windowKey ? [` windowKey: '${n.windowKey}',`] : [],
56478
56524
  ` config: {`
56479
56525
  ];
56480
- 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]) => {
56481
- s.push(` ${e}: "${t}",`);
56482
- }), 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]) => {
56483
56527
  typeof t == `string` ? s.push(` ${e}: "${t}",`) : typeof t == `boolean` && s.push(` ${e}: ${t},`);
56484
56528
  }), s.push(` },`)), t.voiceRecognition && (s.push(` voiceRecognition: {`), Object.entries(t.voiceRecognition).forEach(([e, t]) => {
56485
56529
  typeof t == `string` ? s.push(` ${e}: "${t}",`) : (typeof t == `boolean` || typeof t == `number`) && s.push(` ${e}: ${t},`);
@@ -56492,14 +56536,14 @@ function T(t, n) {
56492
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(`
56493
56537
  `);
56494
56538
  }
56495
- function E(t, n) {
56496
- let r = n?.hooks, a = C(t), s = [
56539
+ function k(t, n) {
56540
+ let r = n?.hooks, a = [
56497
56541
  `<script>`,
56498
56542
  `(function() {`,
56499
56543
  ` 'use strict';`,
56500
56544
  ``,
56501
56545
  ` // Configuration`,
56502
- ` var CONFIG = ${JSON.stringify(a, null, 2).split(`
56546
+ ` var CONFIG = ${h(E(t), 2).split(`
56503
56547
  `).map((e, t) => t === 0 ? e : ` ` + e).join(`
56504
56548
  `)};`,
56505
56549
  ``,
@@ -56586,13 +56630,13 @@ function E(t, n) {
56586
56630
  ` var widgetConfig = Object.assign({}, CONFIG);`,
56587
56631
  ``
56588
56632
  ];
56589
- 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) {
56590
56634
  if (!parsed || typeof parsed !== 'object') return null;
56591
56635
  if (parsed.action === 'nav_then_click') return 'Navigating...';
56592
56636
  if (parsed.action === 'message') return parsed.text || '';
56593
56637
  if (parsed.action === 'message_and_click') return parsed.text || 'Processing...';
56594
56638
  return parsed.text || null;
56595
- });`), 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(`
56596
56640
  `);
56597
56641
  }
56598
56642
  //#endregion
@@ -56627,13 +56671,14 @@ function buildWidgetConfig(input) {
56627
56671
  return {
56628
56672
  apiUrl: input.apiUrl,
56629
56673
  clientToken: input.clientToken,
56630
- parserType: "json"
56674
+ parserType: "json",
56675
+ future: { v5Defaults: true }
56631
56676
  };
56632
56677
  }
56633
56678
  function generatePersonaInitSnippet(input, personaFormat) {
56634
56679
  const widgetConfig = buildWidgetConfig(input);
56635
56680
  const target = input.targetSelector?.trim();
56636
- return y(widgetConfig, personaFormat, target ? { target } : void 0);
56681
+ return x(widgetConfig, personaFormat, target ? { target } : void 0);
56637
56682
  }
56638
56683
  /**
56639
56684
  * Return the version-pinned Persona CDN installer URL from the same generator
@@ -56641,7 +56686,7 @@ function generatePersonaInitSnippet(input, personaFormat) {
56641
56686
  * a second manually-maintained Persona version string in the CLI.
56642
56687
  */
56643
56688
  function getPersonaInstallerScriptUrl() {
56644
- return y({
56689
+ return x({
56645
56690
  apiUrl: "https://api.runtype.com",
56646
56691
  clientToken: "ct_test_demo_00000000000000000000000000000000",
56647
56692
  parserType: "json"
@@ -57378,6 +57423,7 @@ function generatePersonaDemoHtml(input) {
57378
57423
  apiUrl: demo.apiUrl,
57379
57424
  clientToken: demo.clientToken,
57380
57425
  parserType: 'json',
57426
+ future: { v5Defaults: true },
57381
57427
  launcher: {
57382
57428
  enabled: true,
57383
57429
  autoExpand: true,
@@ -59210,6 +59256,7 @@ function buildEventsQuery(options, after) {
59210
59256
  ["surfaceId", options.surface],
59211
59257
  ["scheduleId", options.schedule],
59212
59258
  ["suiteId", options.suite],
59259
+ ["simulationId", options.simulation],
59213
59260
  ["taskId", options.task],
59214
59261
  ["key", options.key],
59215
59262
  ["onlyRegressions", options.onlyRegressions ? "true" : void 0],
@@ -59378,7 +59425,7 @@ const eventsCommand = new Command("events").description("Watch product events (f
59378
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) => {
59379
59426
  await runTypes(options);
59380
59427
  });
59381
- 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) => {
59382
59429
  await runWatch(options);
59383
59430
  });
59384
59431
  //#endregion
@@ -63771,7 +63818,7 @@ object({
63771
63818
  revealed: array(string()).optional()
63772
63819
  });
63773
63820
  //#endregion
63774
- //#region ../shared/dist/chunk-DwsXhSgv.mjs
63821
+ //#region ../shared/dist/chunk-C_UG0PQc.mjs
63775
63822
  /** Every change kind a scrub report can name; a leaf so the data-source contracts reach it without the scrubber. */
63776
63823
  const METADATA_SCRUB_CHANGE_KIND_NAMES = [
63777
63824
  "url_redirected",
@@ -63826,7 +63873,7 @@ const productKindSchema = _enum([
63826
63873
  "spec_only"
63827
63874
  ]);
63828
63875
  //#endregion
63829
- //#region ../shared/dist/chunk-Bvkm1pLW.mjs
63876
+ //#region ../shared/dist/chunk-CTgbBN2x.mjs
63830
63877
  /** The manifest file at the root of a candidate's source bundle. */
63831
63878
  const CANDIDATE_MANIFEST_FILENAME = "runtype-candidate.json";
63832
63879
  const candidateRuntimeSchema = _enum([
@@ -65106,6 +65153,7 @@ const servedBySchema = _enum([
65106
65153
  "composite",
65107
65154
  "synthesized",
65108
65155
  "stub",
65156
+ "rejected",
65109
65157
  "fault"
65110
65158
  ]);
65111
65159
  /** Calls per ladder rung; a rung with no calls is absent. */
@@ -66583,6 +66631,12 @@ const simulationRunResponseSchema = object({
66583
66631
  reportId: entityId.nullable()
66584
66632
  });
66585
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
+ }) });
66586
66640
  simulationRunResponseSchema.extend({ advance: object({
66587
66641
  /** Episodes this call finished; one it parked at the time budget resumes on the next call. */
66588
66642
  episodesFinished: number$1().int(),
@@ -66674,6 +66728,7 @@ object({
66674
66728
  "SIMULATION_OVERLAY_INVALID",
66675
66729
  "SIMULATION_OVERLAY_NOT_OWN_TARGET",
66676
66730
  "SIMULATION_RUN_NOT_CANCELLABLE",
66731
+ "SIMULATION_RUN_NOT_REPAIRABLE",
66677
66732
  "SIMULATION_VARIANT_INVALID",
66678
66733
  "SIMULATION_IDENTITY_INVALID",
66679
66734
  "SIMULATION_FORBIDDEN",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runtypelabs/cli",
3
- "version": "2.53.1",
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.6.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.94.0",
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",