@runtypelabs/cli 2.31.1 → 2.31.4

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 +357 -157
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -15260,7 +15260,7 @@ var edgeContextPayloadSchema = external_exports.object({
15260
15260
  // ../shared/dist/chunk-SCJRL6LP.mjs
15261
15261
  var MAX_DURABLE_POLL_ATTEMPTS = 1e3;
15262
15262
 
15263
- // ../shared/dist/chunk-K5ARRYN3.mjs
15263
+ // ../shared/dist/chunk-R7RM64AL.mjs
15264
15264
  var DEFAULT_MODELS_FOR_NEW_ACCOUNTS = [
15265
15265
  // Mixlayer models
15266
15266
  {
@@ -15325,7 +15325,7 @@ var DEFAULT_MODELS_FOR_NEW_ACCOUNTS = [
15325
15325
  },
15326
15326
  {
15327
15327
  provider: "runtype",
15328
- modelId: "gemini-3.5-flash",
15328
+ modelId: "gemini-3.6-flash",
15329
15329
  isDefault: false,
15330
15330
  strengths: "Fast, low-cost, and natively multimodal with good reasoning, tool-use, and a 1M context \u2014 a strong choice for vision and high-throughput steps.",
15331
15331
  bestFor: ["default", "vision", "fast-cheap", "agentic-tools", "long-context"]
@@ -15786,7 +15786,7 @@ function resolveFallback(parsed, context, tracking, options = {}) {
15786
15786
  }
15787
15787
  var templateEngine = new SimpleTemplateEngine();
15788
15788
 
15789
- // ../shared/dist/chunk-PL7A5DM4.mjs
15789
+ // ../shared/dist/chunk-3DRXBLKO.mjs
15790
15790
  var tokensSchema = external_exports.object({ input: external_exports.number(), output: external_exports.number() });
15791
15791
  var wireStopReasonSchema = external_exports.enum([
15792
15792
  "end_turn",
@@ -15807,6 +15807,10 @@ var unifiedBase = {
15807
15807
  seq: external_exports.number()
15808
15808
  };
15809
15809
  var executionKindSchema = external_exports.enum(["agent", "flow"]);
15810
+ var unifiedExternalAgentContextSchema = external_exports.object({
15811
+ contextId: external_exports.string().optional(),
15812
+ taskId: external_exports.string().optional()
15813
+ });
15810
15814
  var fallbackAttemptSchema = external_exports.object({
15811
15815
  attempt: external_exports.number(),
15812
15816
  type: external_exports.enum(["retry", "model", "message", "flow"]),
@@ -15856,12 +15860,19 @@ var unifiedExecutionCompleteEventSchema = external_exports.object({
15856
15860
  stopReason: external_exports.string().optional(),
15857
15861
  totalCost: external_exports.number().optional(),
15858
15862
  totalTokens: tokensSchema.optional(),
15863
+ // Flow-level total token scalar forwarded from the engine's `flow_complete`
15864
+ // (matches the per-step `tokensUsed` scalar on `step_complete`). Debug-only:
15865
+ // FilteredStream strips it for user-facing streams.
15866
+ totalTokensUsed: external_exports.number().optional(),
15859
15867
  totalSteps: external_exports.number().optional(),
15860
15868
  successfulSteps: external_exports.number().optional(),
15861
15869
  failedSteps: external_exports.number().optional(),
15862
15870
  // Inline Claude Managed create dispatches return the reusable Anthropic
15863
15871
  // agent id on the terminal frame so callers can connect on a later turn.
15864
- claudeManagedAgentId: external_exports.string().optional()
15872
+ claudeManagedAgentId: external_exports.string().optional(),
15873
+ // External A2A agents return the conversation handle callers must persist in
15874
+ // order to resume the same upstream task on the next execution.
15875
+ externalAgent: unifiedExternalAgentContextSchema.optional()
15865
15876
  });
15866
15877
  var unifiedExecutionErrorEventSchema = external_exports.object({
15867
15878
  ...unifiedBase,
@@ -16109,7 +16120,11 @@ var unifiedToolCompleteEventSchema = external_exports.object({
16109
16120
  error: external_exports.string().optional(),
16110
16121
  executionTime: external_exports.number().optional(),
16111
16122
  iteration: external_exports.number().optional(),
16112
- stepId: external_exports.string().optional()
16123
+ stepId: external_exports.string().optional(),
16124
+ // Debug-only per-tool cost forwarded from the engine's flow `tool_complete`.
16125
+ // FilteredStream strips it for user-facing streams (same gating as
16126
+ // `step_complete.cost`).
16127
+ toolCost: external_exports.number().optional()
16113
16128
  });
16114
16129
  var unifiedSubagentAttributionSchema = external_exports.object({
16115
16130
  toolName: external_exports.string(),
@@ -16135,7 +16150,10 @@ var unifiedApprovalStartEventSchema = external_exports.object({
16135
16150
  iteration: external_exports.number().optional(),
16136
16151
  // Present when the approval originated inside a subagent's execution.
16137
16152
  // Attribution only — never a control signal.
16138
- subagent: unifiedSubagentAttributionSchema.optional()
16153
+ subagent: unifiedSubagentAttributionSchema.optional(),
16154
+ // External A2A input/auth pauses must expose the handle used to resume the
16155
+ // paused upstream conversation after approval.
16156
+ externalAgent: unifiedExternalAgentContextSchema.optional()
16139
16157
  });
16140
16158
  var unifiedApprovalCompleteEventSchema = external_exports.object({
16141
16159
  ...unifiedBase,
@@ -16428,6 +16446,7 @@ var agentToolCompleteEventSchema = external_exports.object({
16428
16446
  toolName: external_exports.string(),
16429
16447
  success: external_exports.boolean(),
16430
16448
  result: external_exports.unknown().optional(),
16449
+ error: external_exports.string().optional(),
16431
16450
  executionTime: external_exports.number().optional()
16432
16451
  });
16433
16452
  var agentMediaEventSchema = external_exports.object({
@@ -35069,6 +35088,36 @@ var CORE_BUILTIN_TOOLS_REGISTRY = [
35069
35088
  // Requires OpenAI key for embeddings
35070
35089
  executionHint: "platform"
35071
35090
  },
35091
+ // Runtype documentation search — semantic RAG over the published docs corpus.
35092
+ // Executes server-side against Fern's hosted docs MCP server (see
35093
+ // apps/api/src/services/docs-search-service.ts). Free (no per-call cost, no
35094
+ // provider key); gated by the `enable-docs-search` Flagship flag at execution.
35095
+ {
35096
+ id: "search_runtype_docs",
35097
+ name: "Search Runtype Docs",
35098
+ description: "Search Runtype's own product documentation and get back a synthesized answer with citations. Use this to answer how-to and conceptual questions about building on Runtype \u2014 flows, agents, surfaces, tools, records, schedules, and platform capabilities. Prefer this over generic web search for anything about how Runtype itself works. Returns { success, content } where content carries the answer text and its source citations.",
35099
+ category: BuiltInToolCategory.KNOWLEDGE_RETRIEVAL,
35100
+ providers: [BuiltInToolProvider.MULTI],
35101
+ parametersSchema: {
35102
+ type: "object",
35103
+ properties: {
35104
+ query: {
35105
+ type: "string",
35106
+ description: 'Natural-language documentation question about how to build or configure something on Runtype. Example: "How do I add an approval step to an agent?"',
35107
+ minLength: 1
35108
+ }
35109
+ },
35110
+ required: ["query"]
35111
+ },
35112
+ executionHint: "platform",
35113
+ requiresApiKey: false,
35114
+ platformKeySupport: false,
35115
+ // Hidden from production tool discovery until `enable-docs-search` rolls out
35116
+ // (the flag fails closed in production, so a discoverable tool would just
35117
+ // error "not enabled" for every prod account). Execution path is
35118
+ // unaffected — the Generator Agent and non-prod accounts still use it.
35119
+ experimental: true
35120
+ },
35072
35121
  // ElevenLabs Text-to-Speech
35073
35122
  {
35074
35123
  id: "elevenlabs-tts",
@@ -38740,10 +38789,18 @@ var caseCheckpointSchema = external_exports.object({
38740
38789
  */
38741
38790
  forkMessageIndex: external_exports.number().int().nonnegative()
38742
38791
  }).strict();
38792
+ var requiredJsonValueSchema = external_exports.union([
38793
+ external_exports.null(),
38794
+ external_exports.boolean(),
38795
+ external_exports.number(),
38796
+ external_exports.string(),
38797
+ external_exports.array(external_exports.any()),
38798
+ external_exports.record(external_exports.string(), external_exports.any())
38799
+ ]);
38743
38800
  var toolMockSchema = external_exports.object({
38744
38801
  toolName: external_exports.string().min(1),
38745
38802
  input: external_exports.unknown().optional(),
38746
- output: external_exports.unknown(),
38803
+ output: requiredJsonValueSchema,
38747
38804
  /**
38748
38805
  * True when the recorded call FAILED — `output` is then the error payload,
38749
38806
  * and a replay must serve it as a failure, not a success. Captured now so
@@ -38782,7 +38839,7 @@ var recordedToolUnmatchedPolicySchema = external_exports.enum(RECORDED_TOOL_UNMA
38782
38839
  var EVAL_JUDGE_SYSTEM_PROMPT = [
38783
38840
  "You are Runtype's evaluation expert: a rigorous, impartial judge of AI agent and flow behavior. Your job is to decide whether ONE run of an AI system met ONE plain-language criterion written by the system's builder.",
38784
38841
  "",
38785
- 'You are given the criterion (what this flow or agent is supposed to do \u2014 the only standard you grade against), the case name, an optional expected answer for reference, and the run transcript: an indexed record of the steps that ran and every tool call with its inputs and outputs (labeled "[message N]" and "[tool_call N]"), followed by the final output.',
38842
+ `You are given the criterion (what this flow or agent is supposed to do \u2014 the only standard you grade against), the case name, an optional expected answer for reference, and the run transcript: an indexed record of the steps that ran and every tool call with its inputs and outputs (labeled "[message N]" and "[tool_call N]"), followed by the final output. For conversation-seeded cases, the transcript opens with the seeded conversation \u2014 the dialogue the run was replying to. It is context the system was given, not something the run produced: use it to understand what the final output is responding to, and never grade the seeded turns themselves against the criterion. The transcript may also include a "Deterministic check results" section: the pass/fail outcomes of the suite's automated checks, already decided before you were called. Treat those results as settled ground truth.`,
38786
38843
  "",
38787
38844
  "How to judge:",
38788
38845
  '1. Read the criterion first and decide what evidence it demands. A process criterion ("confirms X before Y", "never calls Z", "asks first") is judged on the trajectory \u2014 what the system actually did. An outcome criterion ("answers the question", "matches the expected answer", "right tone") is judged on the final output. Many criteria need both.',
@@ -38790,6 +38847,7 @@ var EVAL_JUDGE_SYSTEM_PROMPT = [
38790
38847
  "3. Judge whether a required action occurred when it mattered. Never demand a rigid, exact step ordering unless the criterion explicitly requires one; incidental extra steps or interleaved calls are not failures.",
38791
38848
  "4. Grade only the criterion you were given. Do not reward or punish anything outside it: not verbosity or brevity, not style, not parts of the run the criterion doesn't mention, and not whether you would have approached the task differently.",
38792
38849
  "5. When the transcript is truncated or no trajectory was captured, judge what you can see. If what you can see cannot settle the criterion, decline \u2014 do not guess in either direction.",
38850
+ '6. Do not re-litigate the deterministic checks. Whether a tool was or was not called, a step ran, the run completed, or the output contains a required string is already settled by the "Deterministic check results" shown as ground truth \u2014 take those outcomes as given, never re-assert or contradict them, and do not make your verdict hinge on restating one. Your job is the qualitative substance those structural checks cannot decide.',
38793
38851
  "",
38794
38852
  "Reason first, then decide: in one paragraph, walk through the specific evidence for and against the criterion BEFORE settling on a verdict, and never rewrite your reasoning to justify a verdict you already picked.",
38795
38853
  "",
@@ -38798,7 +38856,7 @@ var EVAL_JUDGE_SYSTEM_PROMPT = [
38798
38856
  '- "fail" \u2014 the criterion is clearly not met on the evidence shown.',
38799
38857
  '- "insufficient_evidence" \u2014 what you were shown cannot settle this criterion. This is the honest answer, not a failure; use it instead of guessing.',
38800
38858
  "",
38801
- 'Cite the transcript entries your verdict rests on as an array of {"kind": "message"|"tool_call", "index": N}, using the exact labeled indices. An empty array is correct when the final output alone (which has no labeled index) is the evidence.',
38859
+ 'Cite the transcript entries your verdict rests on as an array of {"kind": "message"|"tool_call", "index": N}, using the exact labeled indices. An empty array is correct when the evidence is the final output or the seeded conversation (neither has a labeled index).',
38802
38860
  "",
38803
38861
  'Return ONLY a JSON object of the form {"reasoning": "<one paragraph>", "verdict": "pass"|"fail"|"insufficient_evidence", "evidence": [{"kind": "message"|"tool_call", "index": <integer>}]}. Do not include any text outside the JSON object.',
38804
38862
  "",
@@ -39051,6 +39109,13 @@ var MODEL_FAMILY_PROVIDER_IDS = {
39051
39109
  "claude-opus-4.8-fast": {
39052
39110
  "vercel": "anthropic/claude-opus-4.8-fast"
39053
39111
  },
39112
+ "claude-opus-5": {
39113
+ "anthropic": "claude-opus-5",
39114
+ "vercel": "anthropic/claude-opus-5"
39115
+ },
39116
+ "claude-opus-5-fast": {
39117
+ "vercel": "anthropic/claude-opus-5-fast"
39118
+ },
39054
39119
  "claude-sonnet-4": {
39055
39120
  "vercel": "anthropic/claude-sonnet-4"
39056
39121
  },
@@ -39084,6 +39149,12 @@ var MODEL_FAMILY_PROVIDER_IDS = {
39084
39149
  "command-a": {
39085
39150
  "vercel": "cohere/command-a"
39086
39151
  },
39152
+ "deep-research-max-preview-04-2026": {
39153
+ "google": "deep-research-max-preview-04-2026"
39154
+ },
39155
+ "deep-research-preview-04-2026": {
39156
+ "google": "deep-research-preview-04-2026"
39157
+ },
39087
39158
  "deepcogito/cogito-v2-1-671b": {
39088
39159
  "togetherai": "togetherai/deepcogito/cogito-v2-1-671b"
39089
39160
  },
@@ -39109,6 +39180,9 @@ var MODEL_FAMILY_PROVIDER_IDS = {
39109
39180
  "fugu-ultra": {
39110
39181
  "vercel": "sakana/fugu-ultra"
39111
39182
  },
39183
+ "gemini-2-5-computer-use-preview-10-2025": {
39184
+ "google": "gemini-2.5-computer-use-preview-10-2025"
39185
+ },
39112
39186
  "gemini-2-5-flash": {
39113
39187
  "google": "gemini-2.5-flash",
39114
39188
  "vercel": "google/gemini-2.5-flash"
@@ -39125,6 +39199,9 @@ var MODEL_FAMILY_PROVIDER_IDS = {
39125
39199
  "google": "gemini-2.5-pro",
39126
39200
  "vercel": "google/gemini-2.5-pro"
39127
39201
  },
39202
+ "gemini-2.5-computer-use-preview-10-2025": {
39203
+ "google": "gemini-2.5-computer-use-preview-10-2025"
39204
+ },
39128
39205
  "gemini-2.5-flash": {
39129
39206
  "google": "gemini-2.5-flash",
39130
39207
  "vercel": "google/gemini-2.5-flash"
@@ -39142,6 +39219,7 @@ var MODEL_FAMILY_PROVIDER_IDS = {
39142
39219
  "vercel": "google/gemini-2.5-pro"
39143
39220
  },
39144
39221
  "gemini-3-1-flash-image": {
39222
+ "google": "gemini-3.1-flash-image",
39145
39223
  "vercel": "google/gemini-3.1-flash-image"
39146
39224
  },
39147
39225
  "gemini-3-1-flash-lite": {
@@ -39149,8 +39227,12 @@ var MODEL_FAMILY_PROVIDER_IDS = {
39149
39227
  "vercel": "google/gemini-3.1-flash-lite"
39150
39228
  },
39151
39229
  "gemini-3-1-flash-lite-image": {
39230
+ "google": "gemini-3.1-flash-lite-image",
39152
39231
  "vercel": "google/gemini-3.1-flash-lite-image"
39153
39232
  },
39233
+ "gemini-3-1-flash-live": {
39234
+ "google": "gemini-3.1-flash-live-preview"
39235
+ },
39154
39236
  "gemini-3-1-pro": {
39155
39237
  "google": "gemini-3.1-pro-preview",
39156
39238
  "vercel": "google/gemini-3.1-pro-preview"
@@ -39162,6 +39244,17 @@ var MODEL_FAMILY_PROVIDER_IDS = {
39162
39244
  "google": "gemini-3.5-flash",
39163
39245
  "vercel": "google/gemini-3.5-flash"
39164
39246
  },
39247
+ "gemini-3-5-flash-lite": {
39248
+ "google": "gemini-3.5-flash-lite",
39249
+ "vercel": "google/gemini-3.5-flash-lite"
39250
+ },
39251
+ "gemini-3-5-live-translate": {
39252
+ "google": "gemini-3.5-live-translate-preview"
39253
+ },
39254
+ "gemini-3-6-flash": {
39255
+ "google": "gemini-3.6-flash",
39256
+ "vercel": "google/gemini-3.6-flash"
39257
+ },
39165
39258
  "gemini-3-flash": {
39166
39259
  "google": "gemini-3-flash-preview"
39167
39260
  },
@@ -39176,6 +39269,7 @@ var MODEL_FAMILY_PROVIDER_IDS = {
39176
39269
  "google": "gemini-3-pro-image-preview"
39177
39270
  },
39178
39271
  "gemini-3.1-flash-image": {
39272
+ "google": "gemini-3.1-flash-image",
39179
39273
  "vercel": "google/gemini-3.1-flash-image"
39180
39274
  },
39181
39275
  "gemini-3.1-flash-lite": {
@@ -39183,8 +39277,12 @@ var MODEL_FAMILY_PROVIDER_IDS = {
39183
39277
  "vercel": "google/gemini-3.1-flash-lite"
39184
39278
  },
39185
39279
  "gemini-3.1-flash-lite-image": {
39280
+ "google": "gemini-3.1-flash-lite-image",
39186
39281
  "vercel": "google/gemini-3.1-flash-lite-image"
39187
39282
  },
39283
+ "gemini-3.1-flash-live-preview": {
39284
+ "google": "gemini-3.1-flash-live-preview"
39285
+ },
39188
39286
  "gemini-3.1-pro-preview": {
39189
39287
  "google": "gemini-3.1-pro-preview",
39190
39288
  "vercel": "google/gemini-3.1-pro-preview"
@@ -39196,15 +39294,35 @@ var MODEL_FAMILY_PROVIDER_IDS = {
39196
39294
  "google": "gemini-3.5-flash",
39197
39295
  "vercel": "google/gemini-3.5-flash"
39198
39296
  },
39297
+ "gemini-3.5-flash-lite": {
39298
+ "google": "gemini-3.5-flash-lite",
39299
+ "vercel": "google/gemini-3.5-flash-lite"
39300
+ },
39301
+ "gemini-3.5-live-translate-preview": {
39302
+ "google": "gemini-3.5-live-translate-preview"
39303
+ },
39304
+ "gemini-3.6-flash": {
39305
+ "google": "gemini-3.6-flash",
39306
+ "vercel": "google/gemini-3.6-flash"
39307
+ },
39199
39308
  "gemini-embedding-001": {
39200
39309
  "google": "gemini-embedding-001"
39201
39310
  },
39311
+ "gemini-embedding-2": {
39312
+ "google": "gemini-embedding-2"
39313
+ },
39202
39314
  "gemini-omni-flash": {
39203
39315
  "vercel": "google/gemini-omni-flash-preview"
39204
39316
  },
39205
39317
  "gemini-omni-flash-preview": {
39206
39318
  "vercel": "google/gemini-omni-flash-preview"
39207
39319
  },
39320
+ "gemini-robotics-er-1-6": {
39321
+ "google": "gemini-robotics-er-1.6-preview"
39322
+ },
39323
+ "gemini-robotics-er-1.6-preview": {
39324
+ "google": "gemini-robotics-er-1.6-preview"
39325
+ },
39208
39326
  "gemma-4-26b-a4b-it": {
39209
39327
  "google": "gemma-4-26b-a4b-it",
39210
39328
  "vercel": "google/gemma-4-26b-a4b-it"
@@ -39284,15 +39402,12 @@ var MODEL_FAMILY_PROVIDER_IDS = {
39284
39402
  "openai": "gpt-5.1"
39285
39403
  },
39286
39404
  "gpt-5-1-codex": {
39287
- "openai": "gpt-5.1-codex",
39288
39405
  "vercel": "openai/gpt-5.1-codex"
39289
39406
  },
39290
39407
  "gpt-5-1-codex-max": {
39291
- "openai": "gpt-5.1-codex-max",
39292
39408
  "vercel": "openai/gpt-5.1-codex-max"
39293
39409
  },
39294
39410
  "gpt-5-1-codex-mini": {
39295
- "openai": "gpt-5.1-codex-mini",
39296
39411
  "vercel": "openai/gpt-5.1-codex-mini"
39297
39412
  },
39298
39413
  "gpt-5-2": {
@@ -39300,7 +39415,6 @@ var MODEL_FAMILY_PROVIDER_IDS = {
39300
39415
  "vercel": "openai/gpt-5.2"
39301
39416
  },
39302
39417
  "gpt-5-2-codex": {
39303
- "openai": "gpt-5.2-codex",
39304
39418
  "vercel": "openai/gpt-5.2-codex"
39305
39419
  },
39306
39420
  "gpt-5-2-pro": {
@@ -39354,7 +39468,6 @@ var MODEL_FAMILY_PROVIDER_IDS = {
39354
39468
  "vercel": "openai/gpt-5.6-terra"
39355
39469
  },
39356
39470
  "gpt-5-codex": {
39357
- "openai": "gpt-5-codex",
39358
39471
  "vercel": "openai/gpt-5-codex"
39359
39472
  },
39360
39473
  "gpt-5-mini": {
@@ -39373,15 +39486,12 @@ var MODEL_FAMILY_PROVIDER_IDS = {
39373
39486
  "openai": "gpt-5.1"
39374
39487
  },
39375
39488
  "gpt-5.1-codex": {
39376
- "openai": "gpt-5.1-codex",
39377
39489
  "vercel": "openai/gpt-5.1-codex"
39378
39490
  },
39379
39491
  "gpt-5.1-codex-max": {
39380
- "openai": "gpt-5.1-codex-max",
39381
39492
  "vercel": "openai/gpt-5.1-codex-max"
39382
39493
  },
39383
39494
  "gpt-5.1-codex-mini": {
39384
- "openai": "gpt-5.1-codex-mini",
39385
39495
  "vercel": "openai/gpt-5.1-codex-mini"
39386
39496
  },
39387
39497
  "gpt-5.2": {
@@ -39389,7 +39499,6 @@ var MODEL_FAMILY_PROVIDER_IDS = {
39389
39499
  "vercel": "openai/gpt-5.2"
39390
39500
  },
39391
39501
  "gpt-5.2-codex": {
39392
- "openai": "gpt-5.2-codex",
39393
39502
  "vercel": "openai/gpt-5.2-codex"
39394
39503
  },
39395
39504
  "gpt-5.2-pro": {
@@ -39532,7 +39641,11 @@ var MODEL_FAMILY_PROVIDER_IDS = {
39532
39641
  "grok-voice-think-fast-1.0": {
39533
39642
  "vercel": "xai/grok-voice-think-fast-1.0"
39534
39643
  },
39644
+ "hy3": {
39645
+ "vercel": "tencent/hy3"
39646
+ },
39535
39647
  "inkling": {
39648
+ "togetherai": "togetherai/thinkingmachines/Inkling",
39536
39649
  "vercel": "thinkingmachines/inkling"
39537
39650
  },
39538
39651
  "interfaze-beta": {
@@ -39595,23 +39708,29 @@ var MODEL_FAMILY_PROVIDER_IDS = {
39595
39708
  "kimi-k3": {
39596
39709
  "vercel": "moonshotai/kimi-k3"
39597
39710
  },
39598
- "lfm2-24b-a2b": {
39599
- "togetherai": "togetherai/LiquidAI/LFM2-24B-A2B"
39711
+ "laguna-s-2-1": {
39712
+ "vercel": "poolside/laguna-s-2.1"
39600
39713
  },
39601
- "LiquidAI/LFM2-24B-A2B": {
39602
- "togetherai": "togetherai/LiquidAI/LFM2-24B-A2B"
39714
+ "laguna-s-2-1-free": {
39715
+ "vercel": "poolside/laguna-s-2.1-free"
39716
+ },
39717
+ "laguna-s-2.1": {
39718
+ "vercel": "poolside/laguna-s-2.1"
39603
39719
  },
39604
- "llama-3-2-11b": {
39605
- "vercel": "meta/llama-3.2-11b"
39720
+ "laguna-s-2.1-free": {
39721
+ "vercel": "poolside/laguna-s-2.1-free"
39606
39722
  },
39607
- "llama-3-2-1b": {
39608
- "vercel": "meta/llama-3.2-1b"
39723
+ "lfm2-24b-a2b": {
39724
+ "togetherai": "togetherai/LiquidAI/LFM2-24B-A2B"
39609
39725
  },
39610
- "llama-3-2-3b": {
39611
- "vercel": "meta/llama-3.2-3b"
39726
+ "ling-3-0-flash-free": {
39727
+ "vercel": "inclusionai/ling-3.0-flash-free"
39612
39728
  },
39613
- "llama-3-2-90b": {
39614
- "vercel": "meta/llama-3.2-90b"
39729
+ "ling-3.0-flash-free": {
39730
+ "vercel": "inclusionai/ling-3.0-flash-free"
39731
+ },
39732
+ "LiquidAI/LFM2-24B-A2B": {
39733
+ "togetherai": "togetherai/LiquidAI/LFM2-24B-A2B"
39615
39734
  },
39616
39735
  "llama-3-3-70b-instruct-turbo": {
39617
39736
  "togetherai": "togetherai/meta-llama/Llama-3.3-70B-Instruct-Turbo"
@@ -39622,18 +39741,6 @@ var MODEL_FAMILY_PROVIDER_IDS = {
39622
39741
  "llama-3.1-8b": {
39623
39742
  "vercel": "meta/llama-3.1-8b"
39624
39743
  },
39625
- "llama-3.2-11b": {
39626
- "vercel": "meta/llama-3.2-11b"
39627
- },
39628
- "llama-3.2-1b": {
39629
- "vercel": "meta/llama-3.2-1b"
39630
- },
39631
- "llama-3.2-3b": {
39632
- "vercel": "meta/llama-3.2-3b"
39633
- },
39634
- "llama-3.2-90b": {
39635
- "vercel": "meta/llama-3.2-90b"
39636
- },
39637
39744
  "llama-3.3-70b": {
39638
39745
  "vercel": "meta/llama-3.3-70b"
39639
39746
  },
@@ -39646,6 +39753,18 @@ var MODEL_FAMILY_PROVIDER_IDS = {
39646
39753
  "llama3-3-70b": {
39647
39754
  "vercel": "meta/llama-3.3-70b"
39648
39755
  },
39756
+ "lyria-3-clip": {
39757
+ "google": "lyria-3-clip-preview"
39758
+ },
39759
+ "lyria-3-clip-preview": {
39760
+ "google": "lyria-3-clip-preview"
39761
+ },
39762
+ "lyria-3-pro": {
39763
+ "google": "lyria-3-pro-preview"
39764
+ },
39765
+ "lyria-3-pro-preview": {
39766
+ "google": "lyria-3-pro-preview"
39767
+ },
39649
39768
  "magistral-medium": {
39650
39769
  "vercel": "mistral/magistral-medium"
39651
39770
  },
@@ -39774,25 +39893,6 @@ var MODEL_FAMILY_PROVIDER_IDS = {
39774
39893
  "nvidia/nemotron-3-ultra-550b-a55b": {
39775
39894
  "togetherai": "togetherai/nvidia/nemotron-3-ultra-550b-a55b"
39776
39895
  },
39777
- "o3": {
39778
- "openai": "o3",
39779
- "vercel": "openai/o3"
39780
- },
39781
- "o3-deep-research": {
39782
- "openai": "o3-deep-research",
39783
- "vercel": "openai/o3-deep-research"
39784
- },
39785
- "o3-pro": {
39786
- "openai": "o3-pro",
39787
- "vercel": "openai/o3-pro"
39788
- },
39789
- "o4-mini": {
39790
- "openai": "o4-mini",
39791
- "vercel": "openai/o4-mini"
39792
- },
39793
- "o4-mini-deep-research": {
39794
- "openai": "o4-mini-deep-research"
39795
- },
39796
39896
  "openai/gpt-oss-120b": {
39797
39897
  "togetherai": "togetherai/openai/gpt-oss-120b"
39798
39898
  },
@@ -40039,6 +40139,9 @@ var MODEL_FAMILY_PROVIDER_IDS = {
40039
40139
  "text-embedding-ada-002": {
40040
40140
  "openai": "text-embedding-ada-002"
40041
40141
  },
40142
+ "thinkingmachines/Inkling": {
40143
+ "togetherai": "togetherai/thinkingmachines/Inkling"
40144
+ },
40042
40145
  "trinity-large": {
40043
40146
  "vercel": "arcee-ai/trinity-large-thinking"
40044
40147
  },
@@ -45079,6 +45182,70 @@ var MOCK_INVENTORY_LEVELS = MOCK_PRODUCTS.flatMap(
45079
45182
  sku: variant.sku
45080
45183
  }))
45081
45184
  );
45185
+ var LOCAL_INFERENCE_PROTOCOL_VERSION = 1;
45186
+ var LocalInferenceSelectionSchema = external_exports.object({
45187
+ sessionId: external_exports.string().uuid(),
45188
+ model: external_exports.string().trim().min(1).max(256),
45189
+ backend: external_exports.literal("ollama")
45190
+ });
45191
+ var LocalInferenceMessageSchema = external_exports.object({
45192
+ role: external_exports.enum(["system", "user", "assistant"]),
45193
+ content: external_exports.string().max(1e6)
45194
+ });
45195
+ var LocalInferenceInvokeSchema = external_exports.object({
45196
+ type: external_exports.literal("inference.invoke"),
45197
+ protocolVersion: external_exports.literal(LOCAL_INFERENCE_PROTOCOL_VERSION),
45198
+ invocationId: external_exports.string().uuid(),
45199
+ model: external_exports.string().trim().min(1).max(256),
45200
+ messages: external_exports.array(LocalInferenceMessageSchema).min(1).max(500),
45201
+ temperature: external_exports.number().finite().min(0).max(2).optional(),
45202
+ maxTokens: external_exports.number().int().positive().max(131072).optional()
45203
+ });
45204
+ var LocalInferenceServerFrameSchema = external_exports.discriminatedUnion("type", [
45205
+ LocalInferenceInvokeSchema,
45206
+ external_exports.object({
45207
+ type: external_exports.literal("inference.cancel"),
45208
+ protocolVersion: external_exports.literal(LOCAL_INFERENCE_PROTOCOL_VERSION),
45209
+ invocationId: external_exports.string().uuid()
45210
+ }),
45211
+ external_exports.object({
45212
+ type: external_exports.literal("session.connected"),
45213
+ protocolVersion: external_exports.literal(LOCAL_INFERENCE_PROTOCOL_VERSION),
45214
+ sessionId: external_exports.string().uuid()
45215
+ })
45216
+ ]);
45217
+ var LocalInferenceClientFrameSchema = external_exports.discriminatedUnion("type", [
45218
+ external_exports.object({
45219
+ type: external_exports.literal("session.ready"),
45220
+ protocolVersion: external_exports.literal(LOCAL_INFERENCE_PROTOCOL_VERSION)
45221
+ }),
45222
+ external_exports.object({
45223
+ type: external_exports.literal("inference.chunk"),
45224
+ protocolVersion: external_exports.literal(LOCAL_INFERENCE_PROTOCOL_VERSION),
45225
+ invocationId: external_exports.string().uuid(),
45226
+ sequence: external_exports.number().int().nonnegative(),
45227
+ text: external_exports.string().max(256e3)
45228
+ }),
45229
+ external_exports.object({
45230
+ type: external_exports.literal("inference.complete"),
45231
+ protocolVersion: external_exports.literal(LOCAL_INFERENCE_PROTOCOL_VERSION),
45232
+ invocationId: external_exports.string().uuid(),
45233
+ sequence: external_exports.number().int().nonnegative(),
45234
+ finishReason: external_exports.string().max(64).optional(),
45235
+ usage: external_exports.object({
45236
+ inputTokens: external_exports.number().int().nonnegative().max(1e8).optional(),
45237
+ outputTokens: external_exports.number().int().nonnegative().max(1e8).optional()
45238
+ }).optional()
45239
+ }),
45240
+ external_exports.object({
45241
+ type: external_exports.literal("inference.error"),
45242
+ protocolVersion: external_exports.literal(LOCAL_INFERENCE_PROTOCOL_VERSION),
45243
+ invocationId: external_exports.string().uuid(),
45244
+ sequence: external_exports.number().int().nonnegative(),
45245
+ code: external_exports.enum(["cancelled", "ollama_unavailable", "model_error", "protocol_error"]),
45246
+ message: external_exports.string().min(1).max(2e3)
45247
+ })
45248
+ ]);
45082
45249
  function flattenTextContent(content) {
45083
45250
  if (typeof content === "string") return content;
45084
45251
  return content.filter((p) => p.type === "text" && typeof p.text === "string").map((p) => p.text).join("");
@@ -45379,7 +45546,11 @@ var DispatchRequestSchema = external_exports.object({
45379
45546
  autoAppendMetadata: external_exports.boolean().optional().default(false),
45380
45547
  debugMode: external_exports.boolean().optional().default(false),
45381
45548
  loggingPolicy: external_exports.enum(["default", "on", "off"]).optional(),
45382
- useRuntimePackage: external_exports.boolean().optional().default(false),
45549
+ useRuntimePackage: external_exports.boolean().optional().describe(
45550
+ "Selects the execution engine for a streaming FLOW dispatch (two controls, A4-3). `true` forces the @runtypelabs/runtime lane (subject only to eligibility \u2014 an ineligible flow still folds to legacy silently); `false` forces the legacy engine. When omitted, the `use-runtime-package-flows` rollout flag sets the default engine for this caller. An explicit value always wins over the flag. Left undefined on purpose \u2014 do NOT default it, or the flag-as-default case becomes unreachable."
45551
+ ),
45552
+ /** Route prompt model calls through an attached dashboard browser. */
45553
+ localInference: LocalInferenceSelectionSchema.optional(),
45383
45554
  /**
45384
45555
  * Resume a checkpointed agent-loop execution from its latest (or a
45385
45556
  * specific) iteration-boundary snapshot. Runtime-path only: requires
@@ -45400,6 +45571,18 @@ var DispatchRequestSchema = external_exports.object({
45400
45571
  /** Specific boundary to resume from (time-travel); latest when omitted. */
45401
45572
  iteration: external_exports.number().int().nonnegative().optional()
45402
45573
  }).optional(),
45574
+ /**
45575
+ * Client-executed (local / WebMCP) tool outputs for resuming a
45576
+ * client-tool pause on the runtime agent lane. Keyed by the paused
45577
+ * call's per-call id (`toolu_…` / `call_…`) or, as a fallback, the tool
45578
+ * name; the value is the tool's result. Runtime-path only and consumed
45579
+ * ONLY together with `resumeFrom` — the engine resolves each output
45580
+ * against the checkpoint's pending calls, injects the tool-call/result
45581
+ * message pairs so the model sees its prior calls, and re-pauses for any
45582
+ * unresolved parallel siblings. Passthrough-typed so a client can
45583
+ * resolve arbitrary tool return values.
45584
+ */
45585
+ clientToolOutputs: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
45403
45586
  environment: external_exports.enum(["development", "production"]).optional().default("development"),
45404
45587
  createVersion: external_exports.boolean().optional().default(false),
45405
45588
  versionType: external_exports.enum(["published", "draft", "test", "virtual"]).optional(),
@@ -45431,12 +45614,29 @@ var DispatchRequestSchema = external_exports.object({
45431
45614
  storeResults: true,
45432
45615
  autoAppendMetadata: false,
45433
45616
  debugMode: false,
45434
- useRuntimePackage: false,
45617
+ // useRuntimePackage intentionally omitted — absent = silent request, so
45618
+ // the `use-runtime-package-flows` flag decides the default engine (A4-3).
45435
45619
  environment: "development",
45436
45620
  createVersion: false
45437
45621
  })
45438
45622
  }).refine((data) => data.flow || data.agent, {
45439
45623
  message: "Either 'flow' or 'agent' configuration must be provided"
45624
+ }).superRefine((data, ctx) => {
45625
+ if (!data.options.localInference) return;
45626
+ if (!data.options.useRuntimePackage) {
45627
+ ctx.addIssue({
45628
+ code: "custom",
45629
+ path: ["options", "useRuntimePackage"],
45630
+ message: "Local inference requires useRuntimePackage to be enabled"
45631
+ });
45632
+ }
45633
+ if (data.options.modelOverride) {
45634
+ ctx.addIssue({
45635
+ code: "custom",
45636
+ path: ["options", "modelOverride"],
45637
+ message: "Local inference cannot be combined with modelOverride"
45638
+ });
45639
+ }
45440
45640
  }).superRefine((data, ctx) => {
45441
45641
  if (data.agent?.agentType !== "claude_managed") return;
45442
45642
  if (!hasUsableClaudeManagedSeed(data.messages ?? [])) {
@@ -68109,8 +68309,8 @@ import { execFileSync } from "child_process";
68109
68309
  // src/lib/persona-init.ts
68110
68310
  init_credential_store();
68111
68311
 
68112
- // ../../node_modules/.pnpm/@runtypelabs+persona@4.8.0/node_modules/@runtypelabs/persona/dist/codegen.js
68113
- var w = "4.8.0";
68312
+ // ../../node_modules/.pnpm/@runtypelabs+persona@4.10.0/node_modules/@runtypelabs/persona/dist/codegen.js
68313
+ var w = "4.10.0";
68114
68314
  var c = w;
68115
68315
  function u(e) {
68116
68316
  if (e !== void 0) return typeof e == "string" ? e : Array.isArray(e) ? `[${e.map((i) => i.toString()).join(", ")}]` : e.toString();
@@ -68118,7 +68318,7 @@ function u(e) {
68118
68318
  function P(e) {
68119
68319
  if (e) return { getHeaders: u(e.getHeaders), onFeedback: u(e.onFeedback), onCopy: u(e.onCopy), requestMiddleware: u(e.requestMiddleware), actionHandlers: u(e.actionHandlers), actionParsers: u(e.actionParsers), postprocessMessage: u(e.postprocessMessage), contextProviders: u(e.contextProviders), streamParser: u(e.streamParser) };
68120
68320
  }
68121
- var S = `({ text, message }: any) => {
68321
+ var x = `({ text, message }: any) => {
68122
68322
  const jsonSource = (message as any).rawContent || text || message.content;
68123
68323
  if (!jsonSource || typeof jsonSource !== 'string') return null;
68124
68324
  let cleanJson = jsonSource
@@ -68132,7 +68332,7 @@ var S = `({ text, message }: any) => {
68132
68332
  } catch (e) { return null; }
68133
68333
  return null;
68134
68334
  }`;
68135
- var x = `function(ctx) {
68335
+ var S = `function(ctx) {
68136
68336
  var jsonSource = ctx.message.rawContent || ctx.text || ctx.message.content;
68137
68337
  if (!jsonSource || typeof jsonSource !== 'string') return null;
68138
68338
  var cleanJson = jsonSource
@@ -68206,35 +68406,35 @@ function g(e) {
68206
68406
  }
68207
68407
  function m(e, i) {
68208
68408
  let n = [];
68209
- return e.toolCall && (n.push(`${i}toolCall: {`), Object.entries(e.toolCall).forEach(([s, o]) => {
68210
- typeof o == "string" && n.push(`${i} ${s}: "${o}",`);
68409
+ return e.toolCall && (n.push(`${i}toolCall: {`), Object.entries(e.toolCall).forEach(([s, a]) => {
68410
+ typeof a == "string" && n.push(`${i} ${s}: "${a}",`);
68211
68411
  }), n.push(`${i}},`)), n;
68212
68412
  }
68213
68413
  function f(e, i, n) {
68214
- let s = [], o = e.messageActions && Object.entries(e.messageActions).some(([r, a]) => r !== "onFeedback" && r !== "onCopy" && a !== void 0), t = n?.onFeedback || n?.onCopy;
68215
- return (o || t) && (s.push(`${i}messageActions: {`), e.messageActions && Object.entries(e.messageActions).forEach(([r, a]) => {
68216
- r === "onFeedback" || r === "onCopy" || (typeof a == "string" ? s.push(`${i} ${r}: "${a}",`) : typeof a == "boolean" && s.push(`${i} ${r}: ${a},`));
68414
+ let s = [], a = e.messageActions && Object.entries(e.messageActions).some(([r, o]) => r !== "onFeedback" && r !== "onCopy" && o !== void 0), t = n?.onFeedback || n?.onCopy;
68415
+ return (a || t) && (s.push(`${i}messageActions: {`), e.messageActions && Object.entries(e.messageActions).forEach(([r, o]) => {
68416
+ r === "onFeedback" || r === "onCopy" || (typeof o == "string" ? s.push(`${i} ${r}: "${o}",`) : typeof o == "boolean" && s.push(`${i} ${r}: ${o},`));
68217
68417
  }), n?.onFeedback && s.push(`${i} onFeedback: ${n.onFeedback},`), n?.onCopy && s.push(`${i} onCopy: ${n.onCopy},`), s.push(`${i}},`)), s;
68218
68418
  }
68219
68419
  function y(e, i) {
68220
68420
  let n = [];
68221
68421
  if (e.markdown) {
68222
- let s = e.markdown.options && Object.keys(e.markdown.options).length > 0, o = e.markdown.disableDefaultStyles !== void 0;
68223
- (s || o) && (n.push(`${i}markdown: {`), s && (n.push(`${i} options: {`), Object.entries(e.markdown.options).forEach(([t, r]) => {
68422
+ let s = e.markdown.options && Object.keys(e.markdown.options).length > 0, a = e.markdown.disableDefaultStyles !== void 0;
68423
+ (s || a) && (n.push(`${i}markdown: {`), s && (n.push(`${i} options: {`), Object.entries(e.markdown.options).forEach(([t, r]) => {
68224
68424
  typeof r == "string" ? n.push(`${i} ${t}: "${r}",`) : typeof r == "boolean" && n.push(`${i} ${t}: ${r},`);
68225
- }), n.push(`${i} },`)), o && n.push(`${i} disableDefaultStyles: ${e.markdown.disableDefaultStyles},`), n.push(`${i}},`));
68425
+ }), n.push(`${i} },`)), a && n.push(`${i} disableDefaultStyles: ${e.markdown.disableDefaultStyles},`), n.push(`${i}},`));
68226
68426
  }
68227
68427
  return n;
68228
68428
  }
68229
68429
  function C(e, i) {
68230
68430
  let n = [];
68231
68431
  if (e.layout) {
68232
- let s = e.layout.header && Object.keys(e.layout.header).some((t) => t !== "render"), o = e.layout.messages && Object.keys(e.layout.messages).some((t) => t !== "renderUserMessage" && t !== "renderAssistantMessage");
68233
- (s || o) && (n.push(`${i}layout: {`), s && (n.push(`${i} header: {`), Object.entries(e.layout.header).forEach(([t, r]) => {
68432
+ let s = e.layout.header && Object.keys(e.layout.header).some((t) => t !== "render"), a = e.layout.messages && Object.keys(e.layout.messages).some((t) => t !== "renderUserMessage" && t !== "renderAssistantMessage");
68433
+ (s || a) && (n.push(`${i}layout: {`), s && (n.push(`${i} header: {`), Object.entries(e.layout.header).forEach(([t, r]) => {
68234
68434
  t !== "render" && (typeof r == "string" ? n.push(`${i} ${t}: "${r}",`) : typeof r == "boolean" && n.push(`${i} ${t}: ${r},`));
68235
- }), n.push(`${i} },`)), o && (n.push(`${i} messages: {`), Object.entries(e.layout.messages).forEach(([t, r]) => {
68236
- t === "renderUserMessage" || t === "renderAssistantMessage" || (t === "avatar" && typeof r == "object" && r !== null ? (n.push(`${i} avatar: {`), Object.entries(r).forEach(([a, p]) => {
68237
- typeof p == "string" ? n.push(`${i} ${a}: "${p}",`) : typeof p == "boolean" && n.push(`${i} ${a}: ${p},`);
68435
+ }), n.push(`${i} },`)), a && (n.push(`${i} messages: {`), Object.entries(e.layout.messages).forEach(([t, r]) => {
68436
+ t === "renderUserMessage" || t === "renderAssistantMessage" || (t === "avatar" && typeof r == "object" && r !== null ? (n.push(`${i} avatar: {`), Object.entries(r).forEach(([o, p]) => {
68437
+ typeof p == "string" ? n.push(`${i} ${o}: "${p}",`) : typeof p == "boolean" && n.push(`${i} ${o}: ${p},`);
68238
68438
  }), n.push(`${i} },`)) : t === "timestamp" && typeof r == "object" && r !== null ? Object.entries(r).some(([p]) => p !== "format") && (n.push(`${i} timestamp: {`), Object.entries(r).forEach(([p, l]) => {
68239
68439
  p !== "format" && (typeof l == "string" ? n.push(`${i} ${p}: "${l}",`) : typeof l == "boolean" && n.push(`${i} ${p}: ${l},`));
68240
68440
  }), n.push(`${i} },`)) : typeof r == "string" ? n.push(`${i} ${t}: "${r}",`) : typeof r == "boolean" && n.push(`${i} ${t}: ${r},`));
@@ -68247,17 +68447,17 @@ function $(e, i) {
68247
68447
  return e && (e.getHeaders && n.push(`${i}getHeaders: ${e.getHeaders},`), e.requestMiddleware && n.push(`${i}requestMiddleware: ${e.requestMiddleware},`), e.actionParsers && n.push(`${i}actionParsers: ${e.actionParsers},`), e.actionHandlers && n.push(`${i}actionHandlers: ${e.actionHandlers},`), e.contextProviders && n.push(`${i}contextProviders: ${e.contextProviders},`), e.streamParser && n.push(`${i}streamParser: ${e.streamParser},`)), n;
68248
68448
  }
68249
68449
  function O(e, i, n) {
68250
- Object.entries(i).forEach(([s, o]) => {
68251
- if (!(o === void 0 || typeof o == "function")) {
68252
- if (Array.isArray(o)) {
68253
- e.push(`${n}${s}: ${JSON.stringify(o)},`);
68450
+ Object.entries(i).forEach(([s, a]) => {
68451
+ if (!(a === void 0 || typeof a == "function")) {
68452
+ if (Array.isArray(a)) {
68453
+ e.push(`${n}${s}: ${JSON.stringify(a)},`);
68254
68454
  return;
68255
68455
  }
68256
- if (o && typeof o == "object") {
68257
- e.push(`${n}${s}: {`), O(e, o, `${n} `), e.push(`${n}},`);
68456
+ if (a && typeof a == "object") {
68457
+ e.push(`${n}${s}: {`), O(e, a, `${n} `), e.push(`${n}},`);
68258
68458
  return;
68259
68459
  }
68260
- e.push(`${n}${s}: ${JSON.stringify(o)},`);
68460
+ e.push(`${n}${s}: ${JSON.stringify(a)},`);
68261
68461
  }
68262
68462
  });
68263
68463
  }
@@ -68270,38 +68470,38 @@ function h(e) {
68270
68470
  function T(e, i = "esm", n) {
68271
68471
  let s = { ...e };
68272
68472
  delete s.postprocessMessage, delete s.initialMessages;
68273
- let o = n ? { ...n, hooks: P(n.hooks) } : void 0;
68274
- return i === "esm" ? M(s, o) : i === "script-installer" ? H(s, o) : i === "script-advanced" ? D(s, o) : i === "react-component" ? R(s, o) : i === "react-advanced" ? W(s, o) : N(s, o);
68473
+ let a = n ? { ...n, hooks: P(n.hooks) } : void 0;
68474
+ return i === "esm" ? M(s, a) : i === "script-installer" ? H(s, a) : i === "script-advanced" ? D(s, a) : i === "react-component" ? R(s, a) : i === "react-advanced" ? W(s, a) : N(s, a);
68275
68475
  }
68276
68476
  function M(e, i) {
68277
- let n = i?.hooks, s = g(e), o = s !== "plain", t = ["import '@runtypelabs/persona/widget.css';", "import { initAgentWidget, markdownPostprocessor } from '@runtypelabs/persona';", "", "initAgentWidget({", ` target: '${h(i)}',`, " config: {"];
68278
- return e.apiUrl && t.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && t.push(` clientToken: "${e.clientToken}",`), e.agentId && t.push(` agentId: "${e.agentId}",`), e.target && t.push(` target: "${e.target}",`), e.flowId && t.push(` flowId: "${e.flowId}",`), o && t.push(` parserType: "${s}",`), e.theme && typeof e.theme == "object" && Object.keys(e.theme).length > 0 && d(t, "theme", e.theme, " "), e.launcher && d(t, "launcher", e.launcher, " "), e.copy && (t.push(" copy: {"), Object.entries(e.copy).forEach(([r, a]) => {
68279
- t.push(` ${r}: "${a}",`);
68280
- }), t.push(" },")), e.sendButton && (t.push(" sendButton: {"), Object.entries(e.sendButton).forEach(([r, a]) => {
68281
- typeof a == "string" ? t.push(` ${r}: "${a}",`) : typeof a == "boolean" && t.push(` ${r}: ${a},`);
68282
- }), t.push(" },")), e.voiceRecognition && (t.push(" voiceRecognition: {"), Object.entries(e.voiceRecognition).forEach(([r, a]) => {
68283
- typeof a == "string" ? t.push(` ${r}: "${a}",`) : typeof a == "boolean" ? t.push(` ${r}: ${a},`) : typeof a == "number" && t.push(` ${r}: ${a},`);
68284
- }), t.push(" },")), e.statusIndicator && (t.push(" statusIndicator: {"), Object.entries(e.statusIndicator).forEach(([r, a]) => {
68285
- typeof a == "string" ? t.push(` ${r}: "${a}",`) : typeof a == "boolean" && t.push(` ${r}: ${a},`);
68286
- }), t.push(" },")), e.features && (t.push(" features: {"), Object.entries(e.features).forEach(([r, a]) => {
68287
- t.push(` ${r}: ${a},`);
68477
+ let n = i?.hooks, s = g(e), a = s !== "plain", t = ["import '@runtypelabs/persona/widget.css';", "import { initAgentWidget, markdownPostprocessor } from '@runtypelabs/persona';", "", "initAgentWidget({", ` target: '${h(i)}',`, " config: {"];
68478
+ return e.apiUrl && t.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && t.push(` clientToken: "${e.clientToken}",`), e.agentId && t.push(` agentId: "${e.agentId}",`), e.target && t.push(` target: "${e.target}",`), e.flowId && t.push(` flowId: "${e.flowId}",`), a && t.push(` parserType: "${s}",`), e.theme && typeof e.theme == "object" && Object.keys(e.theme).length > 0 && d(t, "theme", e.theme, " "), e.launcher && d(t, "launcher", e.launcher, " "), e.copy && (t.push(" copy: {"), Object.entries(e.copy).forEach(([r, o]) => {
68479
+ t.push(` ${r}: "${o}",`);
68480
+ }), t.push(" },")), e.sendButton && (t.push(" sendButton: {"), Object.entries(e.sendButton).forEach(([r, o]) => {
68481
+ typeof o == "string" ? t.push(` ${r}: "${o}",`) : typeof o == "boolean" && t.push(` ${r}: ${o},`);
68482
+ }), t.push(" },")), e.voiceRecognition && (t.push(" voiceRecognition: {"), Object.entries(e.voiceRecognition).forEach(([r, o]) => {
68483
+ typeof o == "string" ? t.push(` ${r}: "${o}",`) : typeof o == "boolean" ? t.push(` ${r}: ${o},`) : typeof o == "number" && t.push(` ${r}: ${o},`);
68484
+ }), t.push(" },")), e.statusIndicator && (t.push(" statusIndicator: {"), Object.entries(e.statusIndicator).forEach(([r, o]) => {
68485
+ typeof o == "string" ? t.push(` ${r}: "${o}",`) : typeof o == "boolean" && t.push(` ${r}: ${o},`);
68486
+ }), t.push(" },")), e.features && (t.push(" features: {"), Object.entries(e.features).forEach(([r, o]) => {
68487
+ t.push(` ${r}: ${o},`);
68288
68488
  }), t.push(" },")), e.suggestionChips && e.suggestionChips.length > 0 && (t.push(" suggestionChips: ["), e.suggestionChips.forEach((r) => {
68289
68489
  t.push(` "${r}",`);
68290
68490
  }), t.push(" ],")), e.suggestionChipsConfig && (t.push(" suggestionChipsConfig: {"), e.suggestionChipsConfig.fontFamily && t.push(` fontFamily: "${e.suggestionChipsConfig.fontFamily}",`), e.suggestionChipsConfig.fontWeight && t.push(` fontWeight: "${e.suggestionChipsConfig.fontWeight}",`), e.suggestionChipsConfig.paddingX && t.push(` paddingX: "${e.suggestionChipsConfig.paddingX}",`), e.suggestionChipsConfig.paddingY && t.push(` paddingY: "${e.suggestionChipsConfig.paddingY}",`), t.push(" },")), t.push(...m(e, " ")), t.push(...f(e, " ", n)), t.push(...y(e, " ")), t.push(...C(e, " ")), t.push(...$(n, " ")), e.debug && t.push(` debug: ${e.debug},`), n?.postprocessMessage ? t.push(` postprocessMessage: ${n.postprocessMessage}`) : t.push(" postprocessMessage: ({ text }) => markdownPostprocessor(text)"), t.push(" }"), t.push("});"), t.join(`
68291
68491
  `);
68292
68492
  }
68293
68493
  function R(e, i) {
68294
- let n = i?.hooks, s = g(e), o = s !== "plain", t = ["// ChatWidget.tsx", "'use client'; // Required for Next.js - remove for Vite/CRA", "", "import { useEffect } from 'react';", "import '@runtypelabs/persona/widget.css';", "import { initAgentWidget, markdownPostprocessor } from '@runtypelabs/persona';", "import type { AgentWidgetInitHandle } from '@runtypelabs/persona';", "", "export function ChatWidget() {", " useEffect(() => {", " let handle: AgentWidgetInitHandle | null = null;", "", " handle = initAgentWidget({", ` target: '${h(i)}',`, " config: {"];
68295
- return e.apiUrl && t.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && t.push(` clientToken: "${e.clientToken}",`), e.agentId && t.push(` agentId: "${e.agentId}",`), e.target && t.push(` target: "${e.target}",`), e.flowId && t.push(` flowId: "${e.flowId}",`), o && t.push(` parserType: "${s}",`), e.theme && typeof e.theme == "object" && Object.keys(e.theme).length > 0 && d(t, "theme", e.theme, " "), e.launcher && d(t, "launcher", e.launcher, " "), e.copy && (t.push(" copy: {"), Object.entries(e.copy).forEach(([r, a]) => {
68296
- t.push(` ${r}: "${a}",`);
68297
- }), t.push(" },")), e.sendButton && (t.push(" sendButton: {"), Object.entries(e.sendButton).forEach(([r, a]) => {
68298
- typeof a == "string" ? t.push(` ${r}: "${a}",`) : typeof a == "boolean" && t.push(` ${r}: ${a},`);
68299
- }), t.push(" },")), e.voiceRecognition && (t.push(" voiceRecognition: {"), Object.entries(e.voiceRecognition).forEach(([r, a]) => {
68300
- typeof a == "string" ? t.push(` ${r}: "${a}",`) : typeof a == "boolean" ? t.push(` ${r}: ${a},`) : typeof a == "number" && t.push(` ${r}: ${a},`);
68301
- }), t.push(" },")), e.statusIndicator && (t.push(" statusIndicator: {"), Object.entries(e.statusIndicator).forEach(([r, a]) => {
68302
- typeof a == "string" ? t.push(` ${r}: "${a}",`) : typeof a == "boolean" && t.push(` ${r}: ${a},`);
68303
- }), t.push(" },")), e.features && (t.push(" features: {"), Object.entries(e.features).forEach(([r, a]) => {
68304
- t.push(` ${r}: ${a},`);
68494
+ let n = i?.hooks, s = g(e), a = s !== "plain", t = ["// ChatWidget.tsx", "'use client'; // Required for Next.js - remove for Vite/CRA", "", "import { useEffect } from 'react';", "import '@runtypelabs/persona/widget.css';", "import { initAgentWidget, markdownPostprocessor } from '@runtypelabs/persona';", "import type { AgentWidgetInitHandle } from '@runtypelabs/persona';", "", "export function ChatWidget() {", " useEffect(() => {", " let handle: AgentWidgetInitHandle | null = null;", "", " handle = initAgentWidget({", ` target: '${h(i)}',`, " config: {"];
68495
+ return e.apiUrl && t.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && t.push(` clientToken: "${e.clientToken}",`), e.agentId && t.push(` agentId: "${e.agentId}",`), e.target && t.push(` target: "${e.target}",`), e.flowId && t.push(` flowId: "${e.flowId}",`), a && t.push(` parserType: "${s}",`), e.theme && typeof e.theme == "object" && Object.keys(e.theme).length > 0 && d(t, "theme", e.theme, " "), e.launcher && d(t, "launcher", e.launcher, " "), e.copy && (t.push(" copy: {"), Object.entries(e.copy).forEach(([r, o]) => {
68496
+ t.push(` ${r}: "${o}",`);
68497
+ }), t.push(" },")), e.sendButton && (t.push(" sendButton: {"), Object.entries(e.sendButton).forEach(([r, o]) => {
68498
+ typeof o == "string" ? t.push(` ${r}: "${o}",`) : typeof o == "boolean" && t.push(` ${r}: ${o},`);
68499
+ }), t.push(" },")), e.voiceRecognition && (t.push(" voiceRecognition: {"), Object.entries(e.voiceRecognition).forEach(([r, o]) => {
68500
+ typeof o == "string" ? t.push(` ${r}: "${o}",`) : typeof o == "boolean" ? t.push(` ${r}: ${o},`) : typeof o == "number" && t.push(` ${r}: ${o},`);
68501
+ }), t.push(" },")), e.statusIndicator && (t.push(" statusIndicator: {"), Object.entries(e.statusIndicator).forEach(([r, o]) => {
68502
+ typeof o == "string" ? t.push(` ${r}: "${o}",`) : typeof o == "boolean" && t.push(` ${r}: ${o},`);
68503
+ }), t.push(" },")), e.features && (t.push(" features: {"), Object.entries(e.features).forEach(([r, o]) => {
68504
+ t.push(` ${r}: ${o},`);
68305
68505
  }), t.push(" },")), e.suggestionChips && e.suggestionChips.length > 0 && (t.push(" suggestionChips: ["), e.suggestionChips.forEach((r) => {
68306
68506
  t.push(` "${r}",`);
68307
68507
  }), t.push(" ],")), e.suggestionChipsConfig && (t.push(" suggestionChipsConfig: {"), e.suggestionChipsConfig.fontFamily && t.push(` fontFamily: "${e.suggestionChipsConfig.fontFamily}",`), e.suggestionChipsConfig.fontWeight && t.push(` fontWeight: "${e.suggestionChipsConfig.fontWeight}",`), e.suggestionChipsConfig.paddingX && t.push(` paddingX: "${e.suggestionChipsConfig.paddingX}",`), e.suggestionChipsConfig.paddingY && t.push(` paddingY: "${e.suggestionChipsConfig.paddingY}",`), t.push(" },")), t.push(...m(e, " ")), t.push(...f(e, " ", n)), t.push(...y(e, " ")), t.push(...C(e, " ")), t.push(...$(n, " ")), e.debug && t.push(` debug: ${e.debug},`), n?.postprocessMessage ? t.push(` postprocessMessage: ${n.postprocessMessage}`) : t.push(" postprocessMessage: ({ text }) => markdownPostprocessor(text)"), t.push(" }"), t.push(" });"), t.push(""), t.push(" // Cleanup on unmount"), t.push(" return () => {"), t.push(" if (handle) {"), t.push(" handle.destroy();"), t.push(" }"), t.push(" };"), t.push(" }, []);"), t.push(""), t.push(" return null; // Widget injects itself into the DOM"), t.push("}"), t.push(""), t.push("// Usage in your app:"), t.push("// import { ChatWidget } from './components/ChatWidget';"), t.push("//"), t.push("// export default function App() {"), t.push("// return ("), t.push("// <div>"), t.push("// {/* Your app content */}"), t.push("// <ChatWidget />"), t.push("// </div>"), t.push("// );"), t.push("// }"), t.join(`
@@ -68309,79 +68509,79 @@ function R(e, i) {
68309
68509
  }
68310
68510
  function W(e, i) {
68311
68511
  let n = i?.hooks, s = ["// ChatWidgetAdvanced.tsx", "'use client'; // Required for Next.js - remove for Vite/CRA", "", "import { useEffect } from 'react';", "import '@runtypelabs/persona/widget.css';", "import {", " initAgentWidget,", " createFlexibleJsonStreamParser,", " defaultJsonActionParser,", " defaultActionHandlers,", " markdownPostprocessor", "} from '@runtypelabs/persona';", "import type { AgentWidgetInitHandle } from '@runtypelabs/persona';", "", "const STORAGE_KEY = 'chat-widget-state';", "const PROCESSED_ACTIONS_KEY = 'chat-widget-processed-actions';", "", "// Types for DOM elements", "interface PageElement {", " type: string;", " tagName: string;", " selector: string;", " innerText: string;", " href?: string;", "}", "", "interface DOMContext {", " page_elements: PageElement[];", " page_element_count: number;", " element_types: Record<string, number>;", " page_url: string;", " page_title: string;", " timestamp: string;", "}", "", "// DOM context provider - extracts page elements for AI context", "const collectDOMContext = (): DOMContext => {", " const selectors = {", ` products: '[data-product-id], .product-card, .product-item, [role="article"]',`, ` buttons: 'button, [role="button"], .btn',`, " links: 'a[href]',", " inputs: 'input, textarea, select'", " };", "", " const elements: PageElement[] = [];", " Object.entries(selectors).forEach(([type, selector]) => {", " document.querySelectorAll(selector).forEach((element) => {", " if (!(element instanceof HTMLElement)) return;", " ", " // Exclude elements within the widget", " const widgetHost = element.closest('.persona-host');", " if (widgetHost) return;", " ", " const text = element.innerText?.trim();", " if (!text) return;", "", " const selectorString =", " element.id ? `#${element.id}` :", " element.getAttribute('data-testid') ? `[data-testid=\"${element.getAttribute('data-testid')}\"]` :", " element.getAttribute('data-product-id') ? `[data-product-id=\"${element.getAttribute('data-product-id')}\"]` :", " element.tagName.toLowerCase();", "", " const elementData: PageElement = {", " type,", " tagName: element.tagName.toLowerCase(),", " selector: selectorString,", " innerText: text.substring(0, 200)", " };", "", " if (type === 'links' && element instanceof HTMLAnchorElement && element.href) {", " elementData.href = element.href;", " }", "", " elements.push(elementData);", " });", " });", "", " const counts = elements.reduce((acc, el) => {", " acc[el.type] = (acc[el.type] || 0) + 1;", " return acc;", " }, {} as Record<string, number>);", "", " return {", " page_elements: elements.slice(0, 50),", " page_element_count: elements.length,", " element_types: counts,", " page_url: window.location.href,", " page_title: document.title,", " timestamp: new Date().toISOString()", " };", "};", "", "export function ChatWidgetAdvanced() {", " useEffect(() => {", " let handle: AgentWidgetInitHandle | null = null;", "", " // Load saved state", " const loadSavedMessages = () => {", " const savedState = localStorage.getItem(STORAGE_KEY);", " if (savedState) {", " try {", " const { messages } = JSON.parse(savedState);", " return messages || [];", " } catch (e) {", " console.error('Failed to load saved state:', e);", " }", " }", " return [];", " };", "", " handle = initAgentWidget({", ` target: '${h(i)}',`, " config: {"];
68312
- return e.apiUrl && s.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && s.push(` clientToken: "${e.clientToken}",`), e.agentId && s.push(` agentId: "${e.agentId}",`), e.target && s.push(` target: "${e.target}",`), e.flowId && s.push(` flowId: "${e.flowId}",`), e.theme && typeof e.theme == "object" && Object.keys(e.theme).length > 0 && d(s, "theme", e.theme, " "), e.launcher && d(s, "launcher", e.launcher, " "), e.copy && (s.push(" copy: {"), Object.entries(e.copy).forEach(([o, t]) => {
68313
- s.push(` ${o}: "${t}",`);
68314
- }), s.push(" },")), e.sendButton && (s.push(" sendButton: {"), Object.entries(e.sendButton).forEach(([o, t]) => {
68315
- typeof t == "string" ? s.push(` ${o}: "${t}",`) : typeof t == "boolean" && s.push(` ${o}: ${t},`);
68316
- }), s.push(" },")), e.voiceRecognition && (s.push(" voiceRecognition: {"), Object.entries(e.voiceRecognition).forEach(([o, t]) => {
68317
- typeof t == "string" ? s.push(` ${o}: "${t}",`) : typeof t == "boolean" ? s.push(` ${o}: ${t},`) : typeof t == "number" && s.push(` ${o}: ${t},`);
68318
- }), s.push(" },")), e.statusIndicator && (s.push(" statusIndicator: {"), Object.entries(e.statusIndicator).forEach(([o, t]) => {
68319
- typeof t == "string" ? s.push(` ${o}: "${t}",`) : typeof t == "boolean" && s.push(` ${o}: ${t},`);
68320
- }), s.push(" },")), e.features && (s.push(" features: {"), Object.entries(e.features).forEach(([o, t]) => {
68321
- s.push(` ${o}: ${t},`);
68322
- }), s.push(" },")), e.suggestionChips && e.suggestionChips.length > 0 && (s.push(" suggestionChips: ["), e.suggestionChips.forEach((o) => {
68323
- s.push(` "${o}",`);
68324
- }), s.push(" ],")), e.suggestionChipsConfig && (s.push(" suggestionChipsConfig: {"), e.suggestionChipsConfig.fontFamily && s.push(` fontFamily: "${e.suggestionChipsConfig.fontFamily}",`), e.suggestionChipsConfig.fontWeight && s.push(` fontWeight: "${e.suggestionChipsConfig.fontWeight}",`), e.suggestionChipsConfig.paddingX && s.push(` paddingX: "${e.suggestionChipsConfig.paddingX}",`), e.suggestionChipsConfig.paddingY && s.push(` paddingY: "${e.suggestionChipsConfig.paddingY}",`), s.push(" },")), s.push(...m(e, " ")), s.push(...f(e, " ", n)), s.push(...y(e, " ")), s.push(...C(e, " ")), n?.getHeaders && s.push(` getHeaders: ${n.getHeaders},`), n?.contextProviders && s.push(` contextProviders: ${n.contextProviders},`), e.debug && s.push(` debug: ${e.debug},`), s.push(" initialMessages: loadSavedMessages(),"), n?.streamParser ? s.push(` streamParser: ${n.streamParser},`) : (s.push(" // Flexible JSON stream parser for handling structured actions"), s.push(` streamParser: () => createFlexibleJsonStreamParser(${v}),`)), n?.actionParsers ? (s.push(" // Action parsers (custom merged with defaults)"), s.push(` actionParsers: [...(${n.actionParsers}), defaultJsonActionParser,`), s.push(" // Built-in parser for markdown-wrapped JSON"), s.push(` ${S}`), s.push(" ],")) : (s.push(" // Action parsers to detect JSON actions in responses"), s.push(" actionParsers: ["), s.push(" defaultJsonActionParser,"), s.push(" // Parser for markdown-wrapped JSON"), s.push(` ${S}`), s.push(" ],")), n?.actionHandlers ? (s.push(" // Action handlers (custom merged with defaults)"), s.push(` actionHandlers: [...(${n.actionHandlers}),`), s.push(" defaultActionHandlers.message,"), s.push(" defaultActionHandlers.messageAndClick,"), s.push(" // Built-in handler for nav_then_click action"), s.push(` ${A}`), s.push(" ],")) : (s.push(" // Action handlers for navigation and other actions"), s.push(" actionHandlers: ["), s.push(" defaultActionHandlers.message,"), s.push(" defaultActionHandlers.messageAndClick,"), s.push(" // Handler for nav_then_click action"), s.push(` ${A}`), s.push(" ],")), n?.postprocessMessage ? s.push(` postprocessMessage: ${n.postprocessMessage},`) : s.push(" postprocessMessage: ({ text }) => markdownPostprocessor(text),"), n?.requestMiddleware ? (s.push(" // Request middleware (custom merged with DOM context)"), s.push(" requestMiddleware: ({ payload, config }) => {"), s.push(` const customResult = (${n.requestMiddleware})({ payload, config });`), s.push(" const merged = customResult || payload;"), s.push(" return {"), s.push(" ...merged,"), s.push(" metadata: { ...merged.metadata, ...collectDOMContext() }"), s.push(" };"), s.push(" }")) : (s.push(" requestMiddleware: ({ payload }) => {"), s.push(" return {"), s.push(" ...payload,"), s.push(" metadata: collectDOMContext()"), s.push(" };"), s.push(" }")), s.push(" }"), s.push(" });"), s.push(""), s.push(" // Save state on message events"), s.push(" const handleMessage = () => {"), s.push(" const session = handle?.getSession?.();"), s.push(" if (session) {"), s.push(" localStorage.setItem(STORAGE_KEY, JSON.stringify({"), s.push(" messages: session.messages,"), s.push(" timestamp: new Date().toISOString()"), s.push(" }));"), s.push(" }"), s.push(" };"), s.push(""), s.push(" // Clear state on clear chat"), s.push(" const handleClearChat = () => {"), s.push(" localStorage.removeItem(STORAGE_KEY);"), s.push(" localStorage.removeItem(PROCESSED_ACTIONS_KEY);"), s.push(" };"), s.push(""), s.push(" window.addEventListener('persona:message', handleMessage);"), s.push(" window.addEventListener('persona:clear-chat', handleClearChat);"), s.push(""), s.push(" // Cleanup on unmount"), s.push(" return () => {"), s.push(" window.removeEventListener('persona:message', handleMessage);"), s.push(" window.removeEventListener('persona:clear-chat', handleClearChat);"), s.push(" if (handle) {"), s.push(" handle.destroy();"), s.push(" }"), s.push(" };"), s.push(" }, []);"), s.push(""), s.push(" return null; // Widget injects itself into the DOM"), s.push("}"), s.push(""), s.push("// Usage: Collects DOM context for AI-powered navigation"), s.push("// Features:"), s.push("// - Extracts page elements (products, buttons, links)"), s.push("// - Persists chat history across page loads"), s.push("// - Handles navigation actions (nav_then_click)"), s.push("// - Processes structured JSON actions from AI"), s.push("//"), s.push("// Example usage in Next.js:"), s.push("// import { ChatWidgetAdvanced } from './components/ChatWidgetAdvanced';"), s.push("//"), s.push("// export default function RootLayout({ children }) {"), s.push("// return ("), s.push('// <html lang="en">'), s.push("// <body>"), s.push("// {children}"), s.push("// <ChatWidgetAdvanced />"), s.push("// </body>"), s.push("// </html>"), s.push("// );"), s.push("// }"), s.join(`
68512
+ return e.apiUrl && s.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && s.push(` clientToken: "${e.clientToken}",`), e.agentId && s.push(` agentId: "${e.agentId}",`), e.target && s.push(` target: "${e.target}",`), e.flowId && s.push(` flowId: "${e.flowId}",`), e.theme && typeof e.theme == "object" && Object.keys(e.theme).length > 0 && d(s, "theme", e.theme, " "), e.launcher && d(s, "launcher", e.launcher, " "), e.copy && (s.push(" copy: {"), Object.entries(e.copy).forEach(([a, t]) => {
68513
+ s.push(` ${a}: "${t}",`);
68514
+ }), s.push(" },")), e.sendButton && (s.push(" sendButton: {"), Object.entries(e.sendButton).forEach(([a, t]) => {
68515
+ typeof t == "string" ? s.push(` ${a}: "${t}",`) : typeof t == "boolean" && s.push(` ${a}: ${t},`);
68516
+ }), s.push(" },")), e.voiceRecognition && (s.push(" voiceRecognition: {"), Object.entries(e.voiceRecognition).forEach(([a, t]) => {
68517
+ typeof t == "string" ? s.push(` ${a}: "${t}",`) : typeof t == "boolean" ? s.push(` ${a}: ${t},`) : typeof t == "number" && s.push(` ${a}: ${t},`);
68518
+ }), s.push(" },")), e.statusIndicator && (s.push(" statusIndicator: {"), Object.entries(e.statusIndicator).forEach(([a, t]) => {
68519
+ typeof t == "string" ? s.push(` ${a}: "${t}",`) : typeof t == "boolean" && s.push(` ${a}: ${t},`);
68520
+ }), s.push(" },")), e.features && (s.push(" features: {"), Object.entries(e.features).forEach(([a, t]) => {
68521
+ s.push(` ${a}: ${t},`);
68522
+ }), s.push(" },")), e.suggestionChips && e.suggestionChips.length > 0 && (s.push(" suggestionChips: ["), e.suggestionChips.forEach((a) => {
68523
+ s.push(` "${a}",`);
68524
+ }), s.push(" ],")), e.suggestionChipsConfig && (s.push(" suggestionChipsConfig: {"), e.suggestionChipsConfig.fontFamily && s.push(` fontFamily: "${e.suggestionChipsConfig.fontFamily}",`), e.suggestionChipsConfig.fontWeight && s.push(` fontWeight: "${e.suggestionChipsConfig.fontWeight}",`), e.suggestionChipsConfig.paddingX && s.push(` paddingX: "${e.suggestionChipsConfig.paddingX}",`), e.suggestionChipsConfig.paddingY && s.push(` paddingY: "${e.suggestionChipsConfig.paddingY}",`), s.push(" },")), s.push(...m(e, " ")), s.push(...f(e, " ", n)), s.push(...y(e, " ")), s.push(...C(e, " ")), n?.getHeaders && s.push(` getHeaders: ${n.getHeaders},`), n?.contextProviders && s.push(` contextProviders: ${n.contextProviders},`), e.debug && s.push(` debug: ${e.debug},`), s.push(" initialMessages: loadSavedMessages(),"), n?.streamParser ? s.push(` streamParser: ${n.streamParser},`) : (s.push(" // Flexible JSON stream parser for handling structured actions"), s.push(` streamParser: () => createFlexibleJsonStreamParser(${v}),`)), n?.actionParsers ? (s.push(" // Action parsers (custom merged with defaults)"), s.push(` actionParsers: [...(${n.actionParsers}), defaultJsonActionParser,`), s.push(" // Built-in parser for markdown-wrapped JSON"), s.push(` ${x}`), s.push(" ],")) : (s.push(" // Action parsers to detect JSON actions in responses"), s.push(" actionParsers: ["), s.push(" defaultJsonActionParser,"), s.push(" // Parser for markdown-wrapped JSON"), s.push(` ${x}`), s.push(" ],")), n?.actionHandlers ? (s.push(" // Action handlers (custom merged with defaults)"), s.push(` actionHandlers: [...(${n.actionHandlers}),`), s.push(" defaultActionHandlers.message,"), s.push(" defaultActionHandlers.messageAndClick,"), s.push(" // Built-in handler for nav_then_click action"), s.push(` ${A}`), s.push(" ],")) : (s.push(" // Action handlers for navigation and other actions"), s.push(" actionHandlers: ["), s.push(" defaultActionHandlers.message,"), s.push(" defaultActionHandlers.messageAndClick,"), s.push(" // Handler for nav_then_click action"), s.push(` ${A}`), s.push(" ],")), n?.postprocessMessage ? s.push(` postprocessMessage: ${n.postprocessMessage},`) : s.push(" postprocessMessage: ({ text }) => markdownPostprocessor(text),"), n?.requestMiddleware ? (s.push(" // Request middleware (custom merged with DOM context)"), s.push(" requestMiddleware: ({ payload, config }) => {"), s.push(` const customResult = (${n.requestMiddleware})({ payload, config });`), s.push(" const merged = customResult || payload;"), s.push(" return {"), s.push(" ...merged,"), s.push(" metadata: { ...merged.metadata, ...collectDOMContext() }"), s.push(" };"), s.push(" }")) : (s.push(" requestMiddleware: ({ payload }) => {"), s.push(" return {"), s.push(" ...payload,"), s.push(" metadata: collectDOMContext()"), s.push(" };"), s.push(" }")), s.push(" }"), s.push(" });"), s.push(""), s.push(" // Save state on message events"), s.push(" const handleMessage = () => {"), s.push(" const session = handle?.getSession?.();"), s.push(" if (session) {"), s.push(" localStorage.setItem(STORAGE_KEY, JSON.stringify({"), s.push(" messages: session.messages,"), s.push(" timestamp: new Date().toISOString()"), s.push(" }));"), s.push(" }"), s.push(" };"), s.push(""), s.push(" // Clear state on clear chat"), s.push(" const handleClearChat = () => {"), s.push(" localStorage.removeItem(STORAGE_KEY);"), s.push(" localStorage.removeItem(PROCESSED_ACTIONS_KEY);"), s.push(" };"), s.push(""), s.push(" window.addEventListener('persona:message', handleMessage);"), s.push(" window.addEventListener('persona:clear-chat', handleClearChat);"), s.push(""), s.push(" // Cleanup on unmount"), s.push(" return () => {"), s.push(" window.removeEventListener('persona:message', handleMessage);"), s.push(" window.removeEventListener('persona:clear-chat', handleClearChat);"), s.push(" if (handle) {"), s.push(" handle.destroy();"), s.push(" }"), s.push(" };"), s.push(" }, []);"), s.push(""), s.push(" return null; // Widget injects itself into the DOM"), s.push("}"), s.push(""), s.push("// Usage: Collects DOM context for AI-powered navigation"), s.push("// Features:"), s.push("// - Extracts page elements (products, buttons, links)"), s.push("// - Persists chat history across page loads"), s.push("// - Handles navigation actions (nav_then_click)"), s.push("// - Processes structured JSON actions from AI"), s.push("//"), s.push("// Example usage in Next.js:"), s.push("// import { ChatWidgetAdvanced } from './components/ChatWidgetAdvanced';"), s.push("//"), s.push("// export default function RootLayout({ children }) {"), s.push("// return ("), s.push('// <html lang="en">'), s.push("// <body>"), s.push("// {children}"), s.push("// <ChatWidgetAdvanced />"), s.push("// </body>"), s.push("// </html>"), s.push("// );"), s.push("// }"), s.join(`
68325
68525
  `);
68326
68526
  }
68327
68527
  function E(e) {
68328
68528
  let i = g(e), n = i !== "plain", s = {};
68329
68529
  if (e.apiUrl && (s.apiUrl = e.apiUrl), e.clientToken && (s.clientToken = e.clientToken), e.agentId && (s.agentId = e.agentId), e.target && (s.target = e.target), e.flowId && (s.flowId = e.flowId), n && (s.parserType = i), e.theme && (s.theme = e.theme), e.launcher && (s.launcher = e.launcher), e.copy && (s.copy = e.copy), e.sendButton && (s.sendButton = e.sendButton), e.voiceRecognition && (s.voiceRecognition = e.voiceRecognition), e.statusIndicator && (s.statusIndicator = e.statusIndicator), e.features && (s.features = e.features), e.suggestionChips?.length > 0 && (s.suggestionChips = e.suggestionChips), e.suggestionChipsConfig && (s.suggestionChipsConfig = e.suggestionChipsConfig), e.debug && (s.debug = e.debug), e.toolCall) {
68330
- let o = {};
68530
+ let a = {};
68331
68531
  Object.entries(e.toolCall).forEach(([t, r]) => {
68332
- typeof r == "string" && (o[t] = r);
68333
- }), Object.keys(o).length > 0 && (s.toolCall = o);
68532
+ typeof r == "string" && (a[t] = r);
68533
+ }), Object.keys(a).length > 0 && (s.toolCall = a);
68334
68534
  }
68335
68535
  if (e.messageActions) {
68336
- let o = {};
68536
+ let a = {};
68337
68537
  Object.entries(e.messageActions).forEach(([t, r]) => {
68338
- t !== "onFeedback" && t !== "onCopy" && r !== void 0 && (typeof r == "string" || typeof r == "boolean") && (o[t] = r);
68339
- }), Object.keys(o).length > 0 && (s.messageActions = o);
68538
+ t !== "onFeedback" && t !== "onCopy" && r !== void 0 && (typeof r == "string" || typeof r == "boolean") && (a[t] = r);
68539
+ }), Object.keys(a).length > 0 && (s.messageActions = a);
68340
68540
  }
68341
68541
  if (e.markdown) {
68342
- let o = {};
68343
- e.markdown.options && (o.options = e.markdown.options), e.markdown.disableDefaultStyles !== void 0 && (o.disableDefaultStyles = e.markdown.disableDefaultStyles), Object.keys(o).length > 0 && (s.markdown = o);
68542
+ let a = {};
68543
+ e.markdown.options && (a.options = e.markdown.options), e.markdown.disableDefaultStyles !== void 0 && (a.disableDefaultStyles = e.markdown.disableDefaultStyles), Object.keys(a).length > 0 && (s.markdown = a);
68344
68544
  }
68345
68545
  if (e.layout) {
68346
- let o = {};
68546
+ let a = {};
68347
68547
  if (e.layout.header) {
68348
68548
  let t = {};
68349
- Object.entries(e.layout.header).forEach(([r, a]) => {
68350
- r !== "render" && (typeof a == "string" || typeof a == "boolean") && (t[r] = a);
68351
- }), Object.keys(t).length > 0 && (o.header = t);
68549
+ Object.entries(e.layout.header).forEach(([r, o]) => {
68550
+ r !== "render" && (typeof o == "string" || typeof o == "boolean") && (t[r] = o);
68551
+ }), Object.keys(t).length > 0 && (a.header = t);
68352
68552
  }
68353
68553
  if (e.layout.messages) {
68354
68554
  let t = {};
68355
- Object.entries(e.layout.messages).forEach(([r, a]) => {
68356
- if (r !== "renderUserMessage" && r !== "renderAssistantMessage") if (r === "avatar" && typeof a == "object" && a !== null) t.avatar = a;
68357
- else if (r === "timestamp" && typeof a == "object" && a !== null) {
68555
+ Object.entries(e.layout.messages).forEach(([r, o]) => {
68556
+ if (r !== "renderUserMessage" && r !== "renderAssistantMessage") if (r === "avatar" && typeof o == "object" && o !== null) t.avatar = o;
68557
+ else if (r === "timestamp" && typeof o == "object" && o !== null) {
68358
68558
  let p = {};
68359
- Object.entries(a).forEach(([l, b]) => {
68559
+ Object.entries(o).forEach(([l, b]) => {
68360
68560
  l !== "format" && (typeof b == "string" || typeof b == "boolean") && (p[l] = b);
68361
68561
  }), Object.keys(p).length > 0 && (t.timestamp = p);
68362
- } else (typeof a == "string" || typeof a == "boolean") && (t[r] = a);
68363
- }), Object.keys(t).length > 0 && (o.messages = t);
68562
+ } else (typeof o == "string" || typeof o == "boolean") && (t[r] = o);
68563
+ }), Object.keys(t).length > 0 && (a.messages = t);
68364
68564
  }
68365
- Object.keys(o).length > 0 && (s.layout = o);
68565
+ Object.keys(a).length > 0 && (s.layout = a);
68366
68566
  }
68367
68567
  return s;
68368
68568
  }
68369
68569
  function H(e, i) {
68370
- let n = E(e), o = !!(i?.windowKey || i?.target) ? { config: n, ...i?.windowKey ? { windowKey: i.windowKey } : {}, ...i?.target ? { target: i.target } : {} } : n, t = JSON.stringify(o, null, 0).replace(/'/g, "&#39;");
68570
+ let n = E(e), a = !!(i?.windowKey || i?.target) ? { config: n, ...i?.windowKey ? { windowKey: i.windowKey } : {}, ...i?.target ? { target: i.target } : {} } : n, t = JSON.stringify(a, null, 0).replace(/'/g, "&#39;");
68371
68571
  return `<script src="https://cdn.jsdelivr.net/npm/@runtypelabs/persona@${c}/dist/install.global.js" data-config='${t}'></script>`;
68372
68572
  }
68373
68573
  function N(e, i) {
68374
- let n = i?.hooks, s = g(e), o = s !== "plain", t = ["<!-- Load CSS -->", `<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@runtypelabs/persona@${c}/dist/widget.css" />`, "", "<!-- Load JavaScript -->", `<script src="https://cdn.jsdelivr.net/npm/@runtypelabs/persona@${c}/dist/index.global.js"></script>`, "", "<!-- Initialize widget -->", "<script>", " var handle = window.AgentWidget.initAgentWidget({", ` target: '${h(i)}',`, ...i?.windowKey ? [` windowKey: '${i.windowKey}',`] : [], " config: {"];
68375
- return e.apiUrl && t.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && t.push(` clientToken: "${e.clientToken}",`), e.agentId && t.push(` agentId: "${e.agentId}",`), e.target && t.push(` target: "${e.target}",`), e.flowId && t.push(` flowId: "${e.flowId}",`), o && t.push(` parserType: "${s}",`), e.theme && typeof e.theme == "object" && Object.keys(e.theme).length > 0 && d(t, "theme", e.theme, " "), e.launcher && d(t, "launcher", e.launcher, " "), e.copy && (t.push(" copy: {"), Object.entries(e.copy).forEach(([r, a]) => {
68376
- t.push(` ${r}: "${a}",`);
68377
- }), t.push(" },")), e.sendButton && (t.push(" sendButton: {"), Object.entries(e.sendButton).forEach(([r, a]) => {
68378
- typeof a == "string" ? t.push(` ${r}: "${a}",`) : typeof a == "boolean" && t.push(` ${r}: ${a},`);
68379
- }), t.push(" },")), e.voiceRecognition && (t.push(" voiceRecognition: {"), Object.entries(e.voiceRecognition).forEach(([r, a]) => {
68380
- typeof a == "string" ? t.push(` ${r}: "${a}",`) : typeof a == "boolean" ? t.push(` ${r}: ${a},`) : typeof a == "number" && t.push(` ${r}: ${a},`);
68381
- }), t.push(" },")), e.statusIndicator && (t.push(" statusIndicator: {"), Object.entries(e.statusIndicator).forEach(([r, a]) => {
68382
- typeof a == "string" ? t.push(` ${r}: "${a}",`) : typeof a == "boolean" && t.push(` ${r}: ${a},`);
68383
- }), t.push(" },")), e.features && (t.push(" features: {"), Object.entries(e.features).forEach(([r, a]) => {
68384
- t.push(` ${r}: ${a},`);
68574
+ let n = i?.hooks, s = g(e), a = s !== "plain", t = ["<!-- Load CSS -->", `<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@runtypelabs/persona@${c}/dist/widget.css" />`, "", "<!-- Load JavaScript -->", `<script src="https://cdn.jsdelivr.net/npm/@runtypelabs/persona@${c}/dist/index.global.js"></script>`, "", "<!-- Initialize widget -->", "<script>", " var handle = window.AgentWidget.initAgentWidget({", ` target: '${h(i)}',`, ...i?.windowKey ? [` windowKey: '${i.windowKey}',`] : [], " config: {"];
68575
+ return e.apiUrl && t.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && t.push(` clientToken: "${e.clientToken}",`), e.agentId && t.push(` agentId: "${e.agentId}",`), e.target && t.push(` target: "${e.target}",`), e.flowId && t.push(` flowId: "${e.flowId}",`), a && t.push(` parserType: "${s}",`), e.theme && typeof e.theme == "object" && Object.keys(e.theme).length > 0 && d(t, "theme", e.theme, " "), e.launcher && d(t, "launcher", e.launcher, " "), e.copy && (t.push(" copy: {"), Object.entries(e.copy).forEach(([r, o]) => {
68576
+ t.push(` ${r}: "${o}",`);
68577
+ }), t.push(" },")), e.sendButton && (t.push(" sendButton: {"), Object.entries(e.sendButton).forEach(([r, o]) => {
68578
+ typeof o == "string" ? t.push(` ${r}: "${o}",`) : typeof o == "boolean" && t.push(` ${r}: ${o},`);
68579
+ }), t.push(" },")), e.voiceRecognition && (t.push(" voiceRecognition: {"), Object.entries(e.voiceRecognition).forEach(([r, o]) => {
68580
+ typeof o == "string" ? t.push(` ${r}: "${o}",`) : typeof o == "boolean" ? t.push(` ${r}: ${o},`) : typeof o == "number" && t.push(` ${r}: ${o},`);
68581
+ }), t.push(" },")), e.statusIndicator && (t.push(" statusIndicator: {"), Object.entries(e.statusIndicator).forEach(([r, o]) => {
68582
+ typeof o == "string" ? t.push(` ${r}: "${o}",`) : typeof o == "boolean" && t.push(` ${r}: ${o},`);
68583
+ }), t.push(" },")), e.features && (t.push(" features: {"), Object.entries(e.features).forEach(([r, o]) => {
68584
+ t.push(` ${r}: ${o},`);
68385
68585
  }), t.push(" },")), e.suggestionChips && e.suggestionChips.length > 0 && (t.push(" suggestionChips: ["), e.suggestionChips.forEach((r) => {
68386
68586
  t.push(` "${r}",`);
68387
68587
  }), t.push(" ],")), e.suggestionChipsConfig && (t.push(" suggestionChipsConfig: {"), e.suggestionChipsConfig.fontFamily && t.push(` fontFamily: "${e.suggestionChipsConfig.fontFamily}",`), e.suggestionChipsConfig.fontWeight && t.push(` fontWeight: "${e.suggestionChipsConfig.fontWeight}",`), e.suggestionChipsConfig.paddingX && t.push(` paddingX: "${e.suggestionChipsConfig.paddingX}",`), e.suggestionChipsConfig.paddingY && t.push(` paddingY: "${e.suggestionChipsConfig.paddingY}",`), t.push(" },")), t.push(...m(e, " ")), t.push(...f(e, " ", n)), t.push(...y(e, " ")), t.push(...C(e, " ")), t.push(...$(n, " ")), e.debug && t.push(` debug: ${e.debug},`), n?.postprocessMessage ? t.push(` postprocessMessage: ${n.postprocessMessage}`) : t.push(" postprocessMessage: ({ text }) => window.AgentWidget.markdownPostprocessor(text)"), t.push(" }"), t.push(" });"), t.push("</script>"), t.join(`
@@ -68389,9 +68589,9 @@ function N(e, i) {
68389
68589
  }
68390
68590
  function D(e, i) {
68391
68591
  let n = i?.hooks, s = E(e), t = ["<script>", "(function() {", " 'use strict';", "", " // Configuration", ` var CONFIG = ${JSON.stringify(s, null, 2).split(`
68392
- `).map((r, a) => a === 0 ? r : " " + r).join(`
68592
+ `).map((r, o) => o === 0 ? r : " " + r).join(`
68393
68593
  `)};`, "", " // Constants", ` var CDN_BASE = 'https://cdn.jsdelivr.net/npm/@runtypelabs/persona@${c}/dist';`, " var STORAGE_KEY = 'chat-widget-state';", " var PROCESSED_ACTIONS_KEY = 'chat-widget-processed-actions';", "", " // DOM context provider - extracts page elements for AI context", " var domContextProvider = function() {", " var selectors = {", ` products: '[data-product-id], .product-card, .product-item, [role="article"]',`, ` buttons: 'button, [role="button"], .btn',`, " links: 'a[href]',", " inputs: 'input, textarea, select'", " };", "", " var elements = [];", " Object.entries(selectors).forEach(function(entry) {", " var type = entry[0], selector = entry[1];", " document.querySelectorAll(selector).forEach(function(element) {", " if (!(element instanceof HTMLElement)) return;", " var widgetHost = element.closest('.persona-host');", " if (widgetHost) return;", " var text = element.innerText ? element.innerText.trim() : '';", " if (!text) return;", "", " var selectorString = element.id ? '#' + element.id :", ` element.getAttribute('data-testid') ? '[data-testid="' + element.getAttribute('data-testid') + '"]' :`, ` element.getAttribute('data-product-id') ? '[data-product-id="' + element.getAttribute('data-product-id') + '"]' :`, " element.tagName.toLowerCase();", "", " var elementData = {", " type: type,", " tagName: element.tagName.toLowerCase(),", " selector: selectorString,", " innerText: text.substring(0, 200)", " };", "", " if (type === 'links' && element instanceof HTMLAnchorElement && element.href) {", " elementData.href = element.href;", " }", " elements.push(elementData);", " });", " });", "", " var counts = elements.reduce(function(acc, el) {", " acc[el.type] = (acc[el.type] || 0) + 1;", " return acc;", " }, {});", "", " return {", " page_elements: elements.slice(0, 50),", " page_element_count: elements.length,", " element_types: counts,", " page_url: window.location.href,", " page_title: document.title,", " timestamp: new Date().toISOString()", " };", " };", "", " // Load CSS dynamically", " var loadCSS = function() {", " if (document.querySelector('link[data-persona]')) return;", " var link = document.createElement('link');", " link.rel = 'stylesheet';", " link.href = CDN_BASE + '/widget.css';", " link.setAttribute('data-persona', 'true');", " document.head.appendChild(link);", " };", "", " // Load JS dynamically", " var loadJS = function(callback) {", " if (window.AgentWidget) { callback(); return; }", " var script = document.createElement('script');", " script.src = CDN_BASE + '/index.global.js';", " script.onload = callback;", " script.onerror = function() { console.error('Failed to load AgentWidget'); };", " document.head.appendChild(script);", " };", "", " // Create widget config with advanced features", " var createWidgetConfig = function(agentWidget) {", " var widgetConfig = Object.assign({}, CONFIG);", ""];
68394
- return n?.getHeaders && (t.push(` widgetConfig.getHeaders = ${n.getHeaders};`), t.push("")), n?.contextProviders && (t.push(` widgetConfig.contextProviders = ${n.contextProviders};`), t.push("")), n?.streamParser ? t.push(` widgetConfig.streamParser = ${n.streamParser};`) : (t.push(" // Flexible JSON stream parser for handling structured actions"), t.push(" widgetConfig.streamParser = function() {"), t.push(` return agentWidget.createFlexibleJsonStreamParser(${I});`), t.push(" };")), t.push(""), n?.actionParsers ? (t.push(" // Action parsers (custom merged with defaults)"), t.push(` var customParsers = ${n.actionParsers};`), t.push(" widgetConfig.actionParsers = customParsers.concat(["), t.push(" agentWidget.defaultJsonActionParser,"), t.push(` ${x}`), t.push(" ]);")) : (t.push(" // Action parsers to detect JSON actions in responses"), t.push(" widgetConfig.actionParsers = ["), t.push(" agentWidget.defaultJsonActionParser,"), t.push(` ${x}`), t.push(" ];")), t.push(""), n?.actionHandlers ? (t.push(" // Action handlers (custom merged with defaults)"), t.push(` var customHandlers = ${n.actionHandlers};`), t.push(" widgetConfig.actionHandlers = customHandlers.concat(["), t.push(" agentWidget.defaultActionHandlers.message,"), t.push(" agentWidget.defaultActionHandlers.messageAndClick,"), t.push(` ${j}`), t.push(" ]);")) : (t.push(" // Action handlers for navigation and other actions"), t.push(" widgetConfig.actionHandlers = ["), t.push(" agentWidget.defaultActionHandlers.message,"), t.push(" agentWidget.defaultActionHandlers.messageAndClick,"), t.push(` ${j}`), t.push(" ];")), t.push(""), n?.requestMiddleware ? (t.push(" // Request middleware (custom merged with DOM context)"), t.push(" widgetConfig.requestMiddleware = function(ctx) {"), t.push(` var customResult = (${n.requestMiddleware})(ctx);`), t.push(" var merged = customResult || ctx.payload;"), t.push(" return Object.assign({}, merged, { metadata: Object.assign({}, merged.metadata, domContextProvider()) });"), t.push(" };")) : (t.push(" // Send DOM context with each request"), t.push(" widgetConfig.requestMiddleware = function(ctx) {"), t.push(" return Object.assign({}, ctx.payload, { metadata: domContextProvider() });"), t.push(" };")), t.push(""), n?.postprocessMessage ? t.push(` widgetConfig.postprocessMessage = ${n.postprocessMessage};`) : (t.push(" // Markdown postprocessor"), t.push(" widgetConfig.postprocessMessage = function(ctx) {"), t.push(" return agentWidget.markdownPostprocessor(ctx.text);"), t.push(" };")), t.push(""), (n?.onFeedback || n?.onCopy) && (t.push(" // Message action callbacks"), t.push(" widgetConfig.messageActions = widgetConfig.messageActions || {};"), n?.onFeedback && t.push(` widgetConfig.messageActions.onFeedback = ${n.onFeedback};`), n?.onCopy && t.push(` widgetConfig.messageActions.onCopy = ${n.onCopy};`), t.push("")), t.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: '${h(i)}',`, " useShadowDom: false,", ...i?.windowKey ? [` windowKey: '${i.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>"), t.join(`
68594
+ return n?.getHeaders && (t.push(` widgetConfig.getHeaders = ${n.getHeaders};`), t.push("")), n?.contextProviders && (t.push(` widgetConfig.contextProviders = ${n.contextProviders};`), t.push("")), n?.streamParser ? t.push(` widgetConfig.streamParser = ${n.streamParser};`) : (t.push(" // Flexible JSON stream parser for handling structured actions"), t.push(" widgetConfig.streamParser = function() {"), t.push(` return agentWidget.createFlexibleJsonStreamParser(${I});`), t.push(" };")), t.push(""), n?.actionParsers ? (t.push(" // Action parsers (custom merged with defaults)"), t.push(` var customParsers = ${n.actionParsers};`), t.push(" widgetConfig.actionParsers = customParsers.concat(["), t.push(" agentWidget.defaultJsonActionParser,"), t.push(` ${S}`), t.push(" ]);")) : (t.push(" // Action parsers to detect JSON actions in responses"), t.push(" widgetConfig.actionParsers = ["), t.push(" agentWidget.defaultJsonActionParser,"), t.push(` ${S}`), t.push(" ];")), t.push(""), n?.actionHandlers ? (t.push(" // Action handlers (custom merged with defaults)"), t.push(` var customHandlers = ${n.actionHandlers};`), t.push(" widgetConfig.actionHandlers = customHandlers.concat(["), t.push(" agentWidget.defaultActionHandlers.message,"), t.push(" agentWidget.defaultActionHandlers.messageAndClick,"), t.push(` ${j}`), t.push(" ]);")) : (t.push(" // Action handlers for navigation and other actions"), t.push(" widgetConfig.actionHandlers = ["), t.push(" agentWidget.defaultActionHandlers.message,"), t.push(" agentWidget.defaultActionHandlers.messageAndClick,"), t.push(` ${j}`), t.push(" ];")), t.push(""), n?.requestMiddleware ? (t.push(" // Request middleware (custom merged with DOM context)"), t.push(" widgetConfig.requestMiddleware = function(ctx) {"), t.push(` var customResult = (${n.requestMiddleware})(ctx);`), t.push(" var merged = customResult || ctx.payload;"), t.push(" return Object.assign({}, merged, { metadata: Object.assign({}, merged.metadata, domContextProvider()) });"), t.push(" };")) : (t.push(" // Send DOM context with each request"), t.push(" widgetConfig.requestMiddleware = function(ctx) {"), t.push(" return Object.assign({}, ctx.payload, { metadata: domContextProvider() });"), t.push(" };")), t.push(""), n?.postprocessMessage ? t.push(` widgetConfig.postprocessMessage = ${n.postprocessMessage};`) : (t.push(" // Markdown postprocessor"), t.push(" widgetConfig.postprocessMessage = function(ctx) {"), t.push(" return agentWidget.markdownPostprocessor(ctx.text);"), t.push(" };")), t.push(""), (n?.onFeedback || n?.onCopy) && (t.push(" // Message action callbacks"), t.push(" widgetConfig.messageActions = widgetConfig.messageActions || {};"), n?.onFeedback && t.push(` widgetConfig.messageActions.onFeedback = ${n.onFeedback};`), n?.onCopy && t.push(` widgetConfig.messageActions.onCopy = ${n.onCopy};`), t.push("")), t.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: '${h(i)}',`, " useShadowDom: false,", ...i?.windowKey ? [` windowKey: '${i.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>"), t.join(`
68395
68595
  `);
68396
68596
  }
68397
68597
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runtypelabs/cli",
3
- "version": "2.31.1",
3
+ "version": "2.31.4",
4
4
  "description": "Command-line interface for Runtype AI platform",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -26,11 +26,11 @@
26
26
  "rosie-skills": "0.8.1",
27
27
  "yaml": "^2.9.0",
28
28
  "@runtypelabs/ink-components": "0.3.5",
29
- "@runtypelabs/sdk": "6.2.0",
29
+ "@runtypelabs/sdk": "6.3.1",
30
30
  "@runtypelabs/terminal-animations": "0.2.2"
31
31
  },
32
32
  "devDependencies": {
33
- "@runtypelabs/persona": "4.8.0",
33
+ "@runtypelabs/persona": "4.10.0",
34
34
  "@types/express": "^5.0.6",
35
35
  "@types/micromatch": "^4.0.9",
36
36
  "@types/node": "^25.3.3",
@@ -41,7 +41,7 @@
41
41
  "tsx": "^4.7.1",
42
42
  "typescript": "^6.0.3",
43
43
  "vitest": "^4.1.0",
44
- "@runtypelabs/shared": "3.6.0"
44
+ "@runtypelabs/shared": "3.8.1"
45
45
  },
46
46
  "engines": {
47
47
  "node": ">=22.12.0"