@copilotkit/core 2.0.0-rc.40 → 2.0.0-rc.42

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.
package/dist/index.umd.js CHANGED
@@ -13906,22 +13906,43 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
13906
13906
  return value !== null && value !== void 0 && value !== "";
13907
13907
  }
13908
13908
  /**
13909
+ * The component definitions an operation carries: those of an
13910
+ * `updateComponents`, or those a native (A2UI 1.0) `createSurface` carries
13911
+ * inline.
13912
+ *
13913
+ * @param operation - One A2UI operation.
13914
+ */
13915
+ function getA2UIOperationComponents(operation) {
13916
+ const update = operation.updateComponents;
13917
+ const create = operation.createSurface;
13918
+ const components = isRecord$1(update) ? update.components : operation.version === "1.0" && isRecord$1(create) ? create.components : void 0;
13919
+ return Array.isArray(components) ? components : [];
13920
+ }
13921
+ /**
13909
13922
  * Whether operations are enough to paint a visible card yet. A data-bound
13910
- * surface addresses its values by `path` and draws nothing until a data model
13911
- * update carries a non-empty value; a static surface paints from its
13912
- * components alone. Times the loader → surface hand-off to real content rather
13913
- * than a fixed delay (OSS-162).
13923
+ * surface addresses its values by `path` (`@path` in A2UI 1.0) and draws
13924
+ * nothing until a data model update, or a native create's inline data model,
13925
+ * carries a non-empty value; a static surface paints from its components
13926
+ * alone. Times the loader → surface hand-off to real content rather than a
13927
+ * fixed delay (OSS-162).
13914
13928
  *
13915
13929
  * @param operations - The operations of one surface or of a whole activity.
13916
13930
  */
13917
13931
  function surfaceHasRenderableContent(operations) {
13918
- const componentOperations = operations.filter((operation) => isRecord$1(operation.updateComponents));
13919
- if (componentOperations.length === 0) return false;
13920
- if (!JSON.stringify(componentOperations).includes("\"path\"")) return true;
13932
+ const components = operations.flatMap(getA2UIOperationComponents);
13933
+ if (components.length === 0) return false;
13934
+ const serialized = JSON.stringify(components);
13935
+ if (!(serialized.includes("\"path\"") || serialized.includes("\"@path\""))) return true;
13921
13936
  return operations.some((operation) => {
13922
- const update = operation.updateDataModel;
13923
- if (!isRecord$1(update)) return false;
13924
- const value = update.value;
13937
+ var _update$value;
13938
+ const update = isRecord$1(operation.updateDataModel) ? operation.updateDataModel : void 0;
13939
+ const create = operation.createSurface;
13940
+ const value = (_update$value = update === null || update === void 0 ? void 0 : update.value) !== null && _update$value !== void 0 ? _update$value : operation.version === "1.0" && isRecord$1(create) ? create.dataModel : void 0;
13941
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
13942
+ const path = typeof (update === null || update === void 0 ? void 0 : update.path) === "string" ? update.path : "/";
13943
+ const key = operation.version === "1.0" ? "@path" : "path";
13944
+ return value !== "" && serialized.includes(JSON.stringify({ [key]: path }));
13945
+ }
13925
13946
  if (typeof value !== "object" || value === null) return false;
13926
13947
  return Object.values(value).some(hasValue);
13927
13948
  });
@@ -13944,8 +13965,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
13944
13965
  function componentLists(operations) {
13945
13966
  const lists = [];
13946
13967
  for (const operation of operations) {
13947
- const update = operation.updateComponents;
13948
- if (isRecord$1(update) && Array.isArray(update.components)) lists.push(update.components);
13968
+ const components = getA2UIOperationComponents(operation);
13969
+ if (components.length > 0) lists.push(components);
13949
13970
  }
13950
13971
  return lists;
13951
13972
  }
@@ -14013,13 +14034,15 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
14013
14034
  //#region src/a2ui/actions.ts
14014
14035
  /**
14015
14036
  * Wraps a raw processor action in the client-event envelope the runtimes read,
14016
- * filling the fields a partial action leaves out.
14037
+ * filling the fields a partial action leaves out. Other fields the action
14038
+ * carries, such as a native action's `userMessage`, are kept.
14017
14039
  *
14018
14040
  * @param action - What the `MessageProcessor` action handler received.
14019
14041
  */
14020
14042
  function toA2UIClientEvent(action) {
14021
14043
  var _action$name, _action$surfaceId, _action$sourceCompone, _action$timestamp;
14022
14044
  return { userAction: {
14045
+ ...action,
14023
14046
  name: (_action$name = action.name) !== null && _action$name !== void 0 ? _action$name : "unknown",
14024
14047
  surfaceId: (_action$surfaceId = action.surfaceId) !== null && _action$surfaceId !== void 0 ? _action$surfaceId : A2UI_DEFAULT_SURFACE_ID,
14025
14048
  sourceComponentId: (_action$sourceCompone = action.sourceComponentId) !== null && _action$sourceCompone !== void 0 ? _action$sourceCompone : "",