@runtypelabs/persona 4.2.0 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +22 -6
  2. package/dist/animations/glyph-cycle.d.cts +1 -1
  3. package/dist/animations/glyph-cycle.d.ts +1 -1
  4. package/dist/animations/{types-B_xbfvR0.d.cts → types-C6tFDxKy.d.cts} +1 -1
  5. package/dist/animations/{types-B_xbfvR0.d.ts → types-C6tFDxKy.d.ts} +1 -1
  6. package/dist/animations/wipe.d.cts +1 -1
  7. package/dist/animations/wipe.d.ts +1 -1
  8. package/dist/codegen.cjs +6 -6
  9. package/dist/codegen.js +9 -9
  10. package/dist/index.cjs +44 -44
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +101 -3
  13. package/dist/index.d.ts +101 -3
  14. package/dist/index.global.js +33 -33
  15. package/dist/index.global.js.map +1 -1
  16. package/dist/index.js +44 -44
  17. package/dist/index.js.map +1 -1
  18. package/dist/install.global.js +1 -1
  19. package/dist/install.global.js.map +1 -1
  20. package/dist/launcher.global.js.map +1 -1
  21. package/dist/smart-dom-reader.d.cts +76 -1
  22. package/dist/smart-dom-reader.d.ts +76 -1
  23. package/dist/theme-editor-preview.cjs +35 -35
  24. package/dist/theme-editor-preview.d.cts +76 -1
  25. package/dist/theme-editor-preview.d.ts +76 -1
  26. package/dist/theme-editor-preview.js +37 -37
  27. package/dist/theme-editor.cjs +1 -1
  28. package/dist/theme-editor.d.cts +76 -1
  29. package/dist/theme-editor.d.ts +76 -1
  30. package/dist/theme-editor.js +1 -1
  31. package/package.json +1 -1
  32. package/src/client.test.ts +349 -29
  33. package/src/client.ts +96 -24
  34. package/src/defaults.ts +2 -0
  35. package/src/index-core.ts +2 -0
  36. package/src/install.ts +9 -1
  37. package/src/session.ts +6 -3
  38. package/src/session.voice.test.ts +65 -0
  39. package/src/types.ts +57 -2
  40. package/src/utils/__fixtures__/unified-translator.oracle.ts +3 -3
  41. package/src/utils/code-generators.ts +10 -0
  42. package/src/utils/target.test.ts +51 -0
  43. package/src/utils/target.ts +90 -0
@@ -1385,6 +1385,32 @@ type RuntypeTurnCompleteEvent = RuntypeStreamEventOf<RuntypeExecutionStreamEvent
1385
1385
  type RuntypeStepCompleteEvent = RuntypeStreamEventOf<RuntypeFlowSSEEvent, "step_complete">;
1386
1386
  type RuntypeStopReasonKind = NonNullable<RuntypeTurnCompleteEvent["stopReason"] | RuntypeStepCompleteEvent["stopReason"]>;
1387
1387
 
1388
+ /**
1389
+ * Target resolution for the normalized, backend-neutral `target` field.
1390
+ *
1391
+ * `target` is a single string that selects which backend resource a widget
1392
+ * talks to, optimized for a browser widget (always serializable, no live
1393
+ * objects). Three shapes are supported:
1394
+ *
1395
+ * - Runtype TypeID (no prefix): `"agent_…"` / `"flow_…"` route to the
1396
+ * Runtype agent/flow paths. The TypeID prefix is self-describing, so no
1397
+ * wrapper is needed for the common case.
1398
+ * - Provider-prefixed: `"<provider>:<id>"` is handed to the matching
1399
+ * `targetProviders[provider]` resolver, which returns the dispatch payload
1400
+ * fragment for that backend (e.g. `eve`, `langgraph`). `"runtype:…"` is a
1401
+ * built-in that re-detects a TypeID.
1402
+ * - Bare name: `"support"` requires a `targetProviders.default` resolver,
1403
+ * otherwise it throws (a bare name is ambiguous without one).
1404
+ *
1405
+ * Resolvers are registered, not passed as the value, which keeps `target`
1406
+ * itself a plain string that survives script-tag installs, `data-config`,
1407
+ * persisted state, and codegen.
1408
+ */
1409
+ /** Resolver for a provider-prefixed (or default) target id. */
1410
+ type TargetResolver = (id: string) => {
1411
+ payload: Record<string, unknown>;
1412
+ };
1413
+
1388
1414
  /**
1389
1415
  * Text content part for multi-modal messages
1390
1416
  */
@@ -1451,6 +1477,9 @@ type AgentWidgetRequestPayloadMessage = {
1451
1477
  type AgentWidgetRequestPayload = {
1452
1478
  messages: AgentWidgetRequestPayloadMessage[];
1453
1479
  flowId?: string;
1480
+ agent?: {
1481
+ agentId: string;
1482
+ };
1454
1483
  context?: Record<string, unknown>;
1455
1484
  metadata?: Record<string, unknown>;
1456
1485
  /** Per-turn template variables for /v1/client/chat (merged as root-level {{var}} in Runtype). */
@@ -4482,6 +4511,52 @@ type AgentWidgetLoadingIndicatorConfig = {
4482
4511
  type AgentWidgetConfig = {
4483
4512
  apiUrl?: string;
4484
4513
  flowId?: string;
4514
+ /**
4515
+ * Persisted Runtype agent ID to execute.
4516
+ *
4517
+ * This is the primary Runtype entry point for simple agent-backed widgets.
4518
+ * It is mutually exclusive with `flowId` and with inline `agent` configs.
4519
+ * Voice and Runtype TTS providers inherit this value unless they specify their
4520
+ * own feature-scoped agent ID.
4521
+ */
4522
+ agentId?: string;
4523
+ /**
4524
+ * Normalized, backend-neutral routing target. A single string that selects
4525
+ * the backend resource to talk to, optimized for portability across
4526
+ * frameworks (it is always serializable: no live objects).
4527
+ *
4528
+ * Shapes:
4529
+ * - Runtype TypeID (no prefix): `"agent_…"` / `"flow_…"` route to the
4530
+ * Runtype agent/flow paths (the prefix is self-describing).
4531
+ * - Provider-prefixed: `"<provider>:<id>"` is resolved by
4532
+ * `targetProviders[provider]` (e.g. `"eve:support"`). `"runtype:…"` is a
4533
+ * built-in that re-detects a TypeID.
4534
+ * - Bare name: `"support"` requires a `targetProviders.default` resolver.
4535
+ *
4536
+ * Mutually exclusive with `agentId`, `flowId`, and inline `agent`. Prefer
4537
+ * `target` for backend-agnostic apps; use `agentId`/`flowId` for the explicit
4538
+ * Runtype path.
4539
+ *
4540
+ * @example
4541
+ * ```typescript
4542
+ * config: { target: "agent_01k..." } // Runtype agent
4543
+ * config: { target: "flow_01k..." } // Runtype flow
4544
+ * config: { // custom backend
4545
+ * apiUrl: "/api/chat",
4546
+ * target: "eve:support",
4547
+ * targetProviders: { eve: (id) => ({ payload: { assistant: id } }) },
4548
+ * }
4549
+ * ```
4550
+ */
4551
+ target?: string;
4552
+ /**
4553
+ * Prefix-keyed resolvers for `target` strings of the form
4554
+ * `"<provider>:<id>"`. Each resolver maps the id to the dispatch-payload
4555
+ * fragment its backend expects. Register a `default` resolver to also accept
4556
+ * bare (unprefixed, non-TypeID) target names. The built-in `runtype` provider
4557
+ * is always available and does not need to be registered.
4558
+ */
4559
+ targetProviders?: Record<string, TargetResolver>;
4485
4560
  /**
4486
4561
  * Override the assistant-bubble copy shown when a dispatch fails before any
4487
4562
  * response streams back (connection refused, CORS, 4xx/5xx, malformed
@@ -5167,7 +5242,7 @@ type AgentWidgetReasoning = {
5167
5242
  status: "pending" | "streaming" | "complete";
5168
5243
  chunks: string[];
5169
5244
  /**
5170
- * Reasoning channel scope (unified spec). `"turn"` is ordinary per-turn
5245
+ * Reasoning channel scope (wire spec). `"turn"` is ordinary per-turn
5171
5246
  * thinking; `"loop"` is a cross-iteration agent reflection (the fold that
5172
5247
  * replaced the legacy `agent_reflection` event). Absent for legacy streams.
5173
5248
  */
@@ -1385,6 +1385,32 @@ type RuntypeTurnCompleteEvent = RuntypeStreamEventOf<RuntypeExecutionStreamEvent
1385
1385
  type RuntypeStepCompleteEvent = RuntypeStreamEventOf<RuntypeFlowSSEEvent, "step_complete">;
1386
1386
  type RuntypeStopReasonKind = NonNullable<RuntypeTurnCompleteEvent["stopReason"] | RuntypeStepCompleteEvent["stopReason"]>;
1387
1387
 
1388
+ /**
1389
+ * Target resolution for the normalized, backend-neutral `target` field.
1390
+ *
1391
+ * `target` is a single string that selects which backend resource a widget
1392
+ * talks to, optimized for a browser widget (always serializable, no live
1393
+ * objects). Three shapes are supported:
1394
+ *
1395
+ * - Runtype TypeID (no prefix): `"agent_…"` / `"flow_…"` route to the
1396
+ * Runtype agent/flow paths. The TypeID prefix is self-describing, so no
1397
+ * wrapper is needed for the common case.
1398
+ * - Provider-prefixed: `"<provider>:<id>"` is handed to the matching
1399
+ * `targetProviders[provider]` resolver, which returns the dispatch payload
1400
+ * fragment for that backend (e.g. `eve`, `langgraph`). `"runtype:…"` is a
1401
+ * built-in that re-detects a TypeID.
1402
+ * - Bare name: `"support"` requires a `targetProviders.default` resolver,
1403
+ * otherwise it throws (a bare name is ambiguous without one).
1404
+ *
1405
+ * Resolvers are registered, not passed as the value, which keeps `target`
1406
+ * itself a plain string that survives script-tag installs, `data-config`,
1407
+ * persisted state, and codegen.
1408
+ */
1409
+ /** Resolver for a provider-prefixed (or default) target id. */
1410
+ type TargetResolver = (id: string) => {
1411
+ payload: Record<string, unknown>;
1412
+ };
1413
+
1388
1414
  /**
1389
1415
  * Text content part for multi-modal messages
1390
1416
  */
@@ -1451,6 +1477,9 @@ type AgentWidgetRequestPayloadMessage = {
1451
1477
  type AgentWidgetRequestPayload = {
1452
1478
  messages: AgentWidgetRequestPayloadMessage[];
1453
1479
  flowId?: string;
1480
+ agent?: {
1481
+ agentId: string;
1482
+ };
1454
1483
  context?: Record<string, unknown>;
1455
1484
  metadata?: Record<string, unknown>;
1456
1485
  /** Per-turn template variables for /v1/client/chat (merged as root-level {{var}} in Runtype). */
@@ -4482,6 +4511,52 @@ type AgentWidgetLoadingIndicatorConfig = {
4482
4511
  type AgentWidgetConfig = {
4483
4512
  apiUrl?: string;
4484
4513
  flowId?: string;
4514
+ /**
4515
+ * Persisted Runtype agent ID to execute.
4516
+ *
4517
+ * This is the primary Runtype entry point for simple agent-backed widgets.
4518
+ * It is mutually exclusive with `flowId` and with inline `agent` configs.
4519
+ * Voice and Runtype TTS providers inherit this value unless they specify their
4520
+ * own feature-scoped agent ID.
4521
+ */
4522
+ agentId?: string;
4523
+ /**
4524
+ * Normalized, backend-neutral routing target. A single string that selects
4525
+ * the backend resource to talk to, optimized for portability across
4526
+ * frameworks (it is always serializable: no live objects).
4527
+ *
4528
+ * Shapes:
4529
+ * - Runtype TypeID (no prefix): `"agent_…"` / `"flow_…"` route to the
4530
+ * Runtype agent/flow paths (the prefix is self-describing).
4531
+ * - Provider-prefixed: `"<provider>:<id>"` is resolved by
4532
+ * `targetProviders[provider]` (e.g. `"eve:support"`). `"runtype:…"` is a
4533
+ * built-in that re-detects a TypeID.
4534
+ * - Bare name: `"support"` requires a `targetProviders.default` resolver.
4535
+ *
4536
+ * Mutually exclusive with `agentId`, `flowId`, and inline `agent`. Prefer
4537
+ * `target` for backend-agnostic apps; use `agentId`/`flowId` for the explicit
4538
+ * Runtype path.
4539
+ *
4540
+ * @example
4541
+ * ```typescript
4542
+ * config: { target: "agent_01k..." } // Runtype agent
4543
+ * config: { target: "flow_01k..." } // Runtype flow
4544
+ * config: { // custom backend
4545
+ * apiUrl: "/api/chat",
4546
+ * target: "eve:support",
4547
+ * targetProviders: { eve: (id) => ({ payload: { assistant: id } }) },
4548
+ * }
4549
+ * ```
4550
+ */
4551
+ target?: string;
4552
+ /**
4553
+ * Prefix-keyed resolvers for `target` strings of the form
4554
+ * `"<provider>:<id>"`. Each resolver maps the id to the dispatch-payload
4555
+ * fragment its backend expects. Register a `default` resolver to also accept
4556
+ * bare (unprefixed, non-TypeID) target names. The built-in `runtype` provider
4557
+ * is always available and does not need to be registered.
4558
+ */
4559
+ targetProviders?: Record<string, TargetResolver>;
4485
4560
  /**
4486
4561
  * Override the assistant-bubble copy shown when a dispatch fails before any
4487
4562
  * response streams back (connection refused, CORS, 4xx/5xx, malformed
@@ -5167,7 +5242,7 @@ type AgentWidgetReasoning = {
5167
5242
  status: "pending" | "streaming" | "complete";
5168
5243
  chunks: string[];
5169
5244
  /**
5170
- * Reasoning channel scope (unified spec). `"turn"` is ordinary per-turn
5245
+ * Reasoning channel scope (wire spec). `"turn"` is ordinary per-turn
5171
5246
  * thinking; `"loop"` is a cross-iteration agent reflection (the fold that
5172
5247
  * replaced the legacy `agent_reflection` event). Absent for legacy streams.
5173
5248
  */