@copilotkit/shared 2.0.0-rc.15 → 2.0.0-rc.16

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 (38) hide show
  1. package/dist/a2ui-envelope.cjs +2 -2
  2. package/dist/a2ui-envelope.cjs.map +1 -1
  3. package/dist/a2ui-envelope.d.cts +1 -1
  4. package/dist/a2ui-envelope.d.cts.map +1 -1
  5. package/dist/a2ui-envelope.d.mts +1 -1
  6. package/dist/a2ui-envelope.d.mts.map +1 -1
  7. package/dist/a2ui-envelope.mjs +2 -2
  8. package/dist/a2ui-envelope.mjs.map +1 -1
  9. package/dist/generative-ui/prompt-spec.cjs +11 -11
  10. package/dist/generative-ui/prompt-spec.cjs.map +1 -1
  11. package/dist/generative-ui/prompt-spec.mjs +11 -11
  12. package/dist/generative-ui/prompt-spec.mjs.map +1 -1
  13. package/dist/generative-ui/prompt.cjs +1 -1
  14. package/dist/generative-ui/prompt.cjs.map +1 -1
  15. package/dist/generative-ui/prompt.mjs +1 -1
  16. package/dist/generative-ui/prompt.mjs.map +1 -1
  17. package/dist/generative-ui/types.cjs +2 -2
  18. package/dist/generative-ui/types.cjs.map +1 -1
  19. package/dist/generative-ui/types.d.cts +7 -7
  20. package/dist/generative-ui/types.d.cts.map +1 -1
  21. package/dist/generative-ui/types.d.mts +7 -7
  22. package/dist/generative-ui/types.d.mts.map +1 -1
  23. package/dist/generative-ui/types.mjs +2 -2
  24. package/dist/generative-ui/types.mjs.map +1 -1
  25. package/dist/index.umd.js +17 -17
  26. package/dist/index.umd.js.map +1 -1
  27. package/dist/package.cjs +1 -1
  28. package/dist/package.mjs +1 -1
  29. package/package.json +1 -1
  30. package/src/__tests__/a2ui-envelope.test.ts +18 -13
  31. package/src/__tests__/a2ui-prompts.test.ts +5 -5
  32. package/src/__tests__/fixtures/prompt-goldens.json +64 -64
  33. package/src/a2ui-envelope.ts +5 -5
  34. package/src/generative-ui/__tests__/render-ui-args.test.ts +7 -7
  35. package/src/generative-ui/__tests__/validate-operation.test.ts +19 -13
  36. package/src/generative-ui/prompt-spec.ts +11 -11
  37. package/src/generative-ui/prompt.ts +1 -1
  38. package/src/generative-ui/types.ts +10 -7
package/dist/index.umd.js CHANGED
@@ -2113,7 +2113,7 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
2113
2113
 
2114
2114
  //#endregion
2115
2115
  //#region package.json
2116
- var version = "2.0.0-rc.15";
2116
+ var version = "2.0.0-rc.16";
2117
2117
 
2118
2118
  //#endregion
2119
2119
  //#region src/generative-ui/basic-functions.ts
@@ -2440,7 +2440,7 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
2440
2440
  //#endregion
2441
2441
  //#region src/generative-ui/types.ts
2442
2442
  /** A2UI protocol version used on the wire. */
2443
- const A2UI_VERSION = "v1.0";
2443
+ const A2UI_VERSION = "1.0";
2444
2444
  /** Activity type of a generated surface message. */
2445
2445
  const GENERATIVE_UI_ACTIVITY_TYPE = "generative-ui-surface";
2446
2446
  /** Activity type of a function call that the agent asks the client to run. */
@@ -2504,7 +2504,7 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
2504
2504
  * @example
2505
2505
  * ```ts
2506
2506
  * toA2UIActionMessage({ name: "buy", surfaceId: "s1", componentId: "b", context: { sku: "a" } });
2507
- * // { version: "v1.0", action: { name: "buy", surfaceId: "s1", sourceComponentId: "b", timestamp: "2026-…", context: { sku: "a" } } }
2507
+ * // { version: "1.0", action: { name: "buy", surfaceId: "s1", sourceComponentId: "b", timestamp: "2026-…", context: { sku: "a" } } }
2508
2508
  * ```
2509
2509
  */
2510
2510
  function toA2UIActionMessage(event) {
@@ -2582,8 +2582,8 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
2582
2582
  "Open a fence with ```a2ui target=<id> to show the surface in a named target. Use only target ids from the schema. When a target limits its components, its surfaces can use only those components.",
2583
2583
  "Inside a fence, write one JSON object per line and nothing else. No comments, no trailing commas, no pretty-printing.",
2584
2584
  "Keep each operation whole on its line.",
2585
- "Give every operation \"version\":\"v1.0\".",
2586
- "Start a surface with one createSurface. Put all the initial data in \"dataModel\" and the \"root\" component in \"components\". Then write the children in updateComponents lines, so that they show while you write:\n ```a2ui\n {\"version\":\"v1.0\",\"createSurface\":{\"surfaceId\":\"plan-picker\",\"dataModel\":{ ...initial data... },\"components\":[{\"id\":\"root\",\"component\":\"<Name>\",\"children\":[\"seats\",\"pick\"]}]}}\n {\"version\":\"v1.0\",\"updateComponents\":{\"surfaceId\":\"plan-picker\",\"components\":[ ...the children... ]}}\n ```",
2585
+ "Give every operation \"version\":\"1.0\".",
2586
+ "Start a surface with one createSurface. Put all the initial data in \"dataModel\" and the \"root\" component in \"components\". Then write the children in updateComponents lines, so that they show while you write:\n ```a2ui\n {\"version\":\"1.0\",\"createSurface\":{\"surfaceId\":\"plan-picker\",\"dataModel\":{ ...initial data... },\"components\":[{\"id\":\"root\",\"component\":\"<Name>\",\"children\":[\"seats\",\"pick\"]}]}}\n {\"version\":\"1.0\",\"updateComponents\":{\"surfaceId\":\"plan-picker\",\"components\":[ ...the children... ]}}\n ```",
2587
2587
  "Keep \"dataModel\" flat: top-level keys such as \"seats\" or \"form\", never one wrapper object around everything. Check that every { and [ you open in a line is closed.",
2588
2588
  "Every surface renders from the component with id \"root\". Make every other component reachable from \"root\" through slots.",
2589
2589
  "Send every component you reference in the same reply. If a surface gets long, make it smaller rather than leave components out.",
@@ -2604,7 +2604,7 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
2604
2604
  "For a computed list (chart data, template items) use series. Its description under Functions in the schema gives the rules and an example. Bind the \"data\" of a Chart or the \"items\" of a List to it; a template path stays a literal path.",
2605
2605
  "Bind a writable prop to let the user edit it: \"value\":{\"@path\":\"/form/email\"}. The user's input goes to that path.",
2606
2606
  "The value of a ChoicePicker is a list of strings, also for one choice. SegmentedControl, RadioGroup and Select take one string. Option values are always strings: for a yes/no choice use \"yes\" and \"no\", not true and false.",
2607
- "To change data, write updateDataModel with a \"path\" and a \"value\": {\"version\":\"v1.0\",\"updateDataModel\":{\"surfaceId\":\"plan-picker\",\"path\":\"/seats\",\"value\":12}}. Always give \"value\".",
2607
+ "To change data, write updateDataModel with a \"path\" and a \"value\": {\"version\":\"1.0\",\"updateDataModel\":{\"surfaceId\":\"plan-picker\",\"path\":\"/seats\",\"value\":12}}. Always give \"value\".",
2608
2608
  "Set \"value\":null to delete the key at \"path\".",
2609
2609
  {
2610
2610
  when: ["events"],
@@ -2645,9 +2645,9 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
2645
2645
  {
2646
2646
  when: ["agentCalls"],
2647
2647
  items: [
2648
- "To run an app function now, with no click, write a callRendererFunction line in a fence: {\"version\":\"v1.0\",\"callRendererFunction\":{\"functionCallId\":\"<unique id>\",\"callFunction\":{\"@call\":\"<function>\",\"args\":{...}}}}. It needs no surface.",
2648
+ "To run an app function now, with no click, write a callRendererFunction line in a fence: {\"version\":\"1.0\",\"callRendererFunction\":{\"functionCallId\":\"<unique id>\",\"callFunction\":{\"@call\":\"<function>\",\"args\":{...}}}}. It needs no surface.",
2649
2649
  "Give every callRendererFunction a new functionCallId. Call only a function that the schema marks UI or agent, or agent only; a function with no mark is for the UI only. A function marked agent only is only for callRendererFunction: do not bind an event to it.",
2650
- "The result of a callRendererFunction comes back to you as a developer message: {\"version\":\"v1.0\",\"rendererFunctionResponse\":{\"functionCallId\":\"<id>\",\"value\":...}}. If the call failed, it has \"error\" in place of \"value\". Then you get a new turn.",
2650
+ "The result of a callRendererFunction comes back to you as a developer message: {\"version\":\"1.0\",\"rendererFunctionResponse\":{\"functionCallId\":\"<id>\",\"value\":...}}. If the call failed, it has \"error\" in place of \"value\". Then you get a new turn.",
2651
2651
  "Do not guess the result of a callRendererFunction. Wait for the developer message."
2652
2652
  ]
2653
2653
  },
@@ -2662,13 +2662,13 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
2662
2662
  intro: `Call \`${GENERATIVE_UI_RENDER_TOOL}\` to show UI. Arguments: \`target\` first, then \`operations\` (A2UI v1.0 operations, applied in order).`,
2663
2663
  whenToShow: GENERATIVE_UI_WHEN_TO_SHOW,
2664
2664
  operations: [
2665
- "{\"version\":\"v1.0\",\"createSurface\":{\"surfaceId\":\"<new id>\",\"dataModel\":{...},\"components\":[{\"id\":\"root\",\"component\":\"<Name>\",\"children\":[\"<child id>\"]}]}}: the first operation of a new surface. \"dataModel\" and \"components\" are optional.",
2666
- "{\"version\":\"v1.0\",\"updateComponents\":{\"surfaceId\":\"<id>\",\"components\":[<component>, ...]}}: add or replace components by id.",
2667
- "{\"version\":\"v1.0\",\"updateDataModel\":{\"surfaceId\":\"<id>\",\"path\":\"/some/path\",\"value\":<json>}}: set the value at \"path\". Always give \"value\". \"value\":null deletes the key at \"path\".",
2668
- "{\"version\":\"v1.0\",\"deleteSurface\":{\"surfaceId\":\"<id>\"}}: remove the surface.",
2665
+ "{\"version\":\"1.0\",\"createSurface\":{\"surfaceId\":\"<new id>\",\"dataModel\":{...},\"components\":[{\"id\":\"root\",\"component\":\"<Name>\",\"children\":[\"<child id>\"]}]}}: the first operation of a new surface. \"dataModel\" and \"components\" are optional.",
2666
+ "{\"version\":\"1.0\",\"updateComponents\":{\"surfaceId\":\"<id>\",\"components\":[<component>, ...]}}: add or replace components by id.",
2667
+ "{\"version\":\"1.0\",\"updateDataModel\":{\"surfaceId\":\"<id>\",\"path\":\"/some/path\",\"value\":<json>}}: set the value at \"path\". Always give \"value\". \"value\":null deletes the key at \"path\".",
2668
+ "{\"version\":\"1.0\",\"deleteSurface\":{\"surfaceId\":\"<id>\"}}: remove the surface.",
2669
2669
  {
2670
2670
  when: ["agentCalls"],
2671
- items: ["{\"version\":\"v1.0\",\"callRendererFunction\":{\"functionCallId\":\"<unique id>\",\"callFunction\":{\"@call\":\"<function>\",\"args\":{...}}}}: run an app function now, with no click. It needs no surface."]
2671
+ items: ["{\"version\":\"1.0\",\"callRendererFunction\":{\"functionCallId\":\"<unique id>\",\"callFunction\":{\"@call\":\"<function>\",\"args\":{...}}}}: run an app function now, with no click. It needs no surface."]
2672
2672
  }
2673
2673
  ],
2674
2674
  rules: [
@@ -2700,7 +2700,7 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
2700
2700
  },
2701
2701
  {
2702
2702
  when: ["agentCalls"],
2703
- items: ["Give every callRendererFunction a new functionCallId. Call only a function marked (UI or agent) or (agent only); a function with no mark is for the UI only. A function marked (agent only) is only for callRendererFunction: do not bind an event to it.", "The result of a callRendererFunction comes back to you in a new turn, as a developer message: {\"version\":\"v1.0\",\"rendererFunctionResponse\":{\"functionCallId\":\"<id>\",\"value\":...}}. If the call failed, it has \"error\" in place of \"value\". Do not wait for the result in this reply, and do not guess it."]
2703
+ items: ["Give every callRendererFunction a new functionCallId. Call only a function marked (UI or agent) or (agent only); a function with no mark is for the UI only. A function marked (agent only) is only for callRendererFunction: do not bind an event to it.", "The result of a callRendererFunction comes back to you in a new turn, as a developer message: {\"version\":\"1.0\",\"rendererFunctionResponse\":{\"functionCallId\":\"<id>\",\"value\":...}}. If the call failed, it has \"error\" in place of \"value\". Do not wait for the result in this reply, and do not guess it."]
2704
2704
  }
2705
2705
  ]
2706
2706
  },
@@ -3025,7 +3025,7 @@ Use the SAME surfaceId as the main surface. Match action names to button action
3025
3025
  return isRecord$2(value) && value.copilotkit_format === COPILOTKIT_UI_ENVELOPE_FORMAT && (value.copilotkit_transport === "tool" || value.copilotkit_transport === "markdown") && Array.isArray(value.copilotkit_targets) && value.copilotkit_targets.every(isTarget) && isRecordOf(value.copilotkit_surfaces, isSurfaceEntry) && typeof value.copilotkit_contextSent === "boolean";
3026
3026
  }
3027
3027
  function isEnvelope(value) {
3028
- return isRecord$2(value) && isCapabilities(value["v1.0"]) && isRecord$2(value.metadata) && isExtensions(value.metadata.extensions);
3028
+ return isRecord$2(value) && isCapabilities(value["1.0"]) && isRecord$2(value.metadata) && isExtensions(value.metadata.extensions);
3029
3029
  }
3030
3030
  /**
3031
3031
  * Reads the generative UI envelope from the `forwardedProps` of a run.
@@ -3081,7 +3081,7 @@ Use the SAME surfaceId as the main surface. Match action names to button action
3081
3081
  */
3082
3082
  function envelopeToManifest(envelope) {
3083
3083
  var _catalog$components, _catalog$functions;
3084
- const { supportedCatalogIds, inlineCatalogs } = envelope["v1.0"];
3084
+ const { supportedCatalogIds, inlineCatalogs } = envelope["1.0"];
3085
3085
  const catalogId = supportedCatalogIds[0];
3086
3086
  const catalog = inlineCatalogs === null || inlineCatalogs === void 0 ? void 0 : inlineCatalogs.find((entry) => entry.catalogId === catalogId);
3087
3087
  const extensions = envelope.metadata.extensions;
@@ -4132,7 +4132,7 @@ Use the SAME surfaceId as the main surface. Match action names to button action
4132
4132
  `## Generative UI
4133
4133
  ${intro}
4134
4134
 
4135
- ${whenToShow ? `${whenToShow}\n\n` : ""}Every operation has "version":"v1.0" and exactly one of:
4135
+ ${whenToShow ? `${whenToShow}\n\n` : ""}Every operation has "version":"1.0" and exactly one of:
4136
4136
  ${operations.map((op) => `- ${op}`).join("\n")}
4137
4137
 
4138
4138
  Rules: