@copilotkit/core 2.0.0-rc.42 → 2.0.0-rc.43
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/chat-configuration.d.cts +1 -1
- package/dist/chat-configuration.d.mts +1 -1
- package/dist/generative-ui/index.cjs +325 -13
- package/dist/generative-ui/index.cjs.map +1 -1
- package/dist/generative-ui/index.d.cts +105 -7
- package/dist/generative-ui/index.d.cts.map +1 -1
- package/dist/generative-ui/index.d.mts +105 -7
- package/dist/generative-ui/index.d.mts.map +1 -1
- package/dist/generative-ui/index.mjs +323 -11
- package/dist/generative-ui/index.mjs.map +1 -1
- package/dist/index.cjs +58 -792
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +58 -767
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +137 -911
- package/dist/index.umd.js.map +1 -1
- package/dist/{learning-bridge-DNdPfyx2.d.mts → learning-bridge-DbE4J5tK.d.mts} +64 -460
- package/dist/learning-bridge-DbE4J5tK.d.mts.map +1 -0
- package/dist/{learning-bridge-DkOdyUdA.d.cts → learning-bridge-jOC46U9n.d.cts} +64 -460
- package/dist/learning-bridge-jOC46U9n.d.cts.map +1 -0
- package/dist/styles.cjs +1 -1
- package/dist/styles.cjs.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.mjs +1 -1
- package/dist/styles.mjs.map +1 -1
- package/package.json +3 -4
- package/tsdown.config.ts +0 -4
- package/dist/learning-bridge-DNdPfyx2.d.mts.map +0 -1
- package/dist/learning-bridge-DkOdyUdA.d.cts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -2108,8 +2108,8 @@ var AgentRegistry = class {
|
|
|
2108
2108
|
inspectorMetadataCredentialsGeneration = 0;
|
|
2109
2109
|
inspectorMetadataAbortController;
|
|
2110
2110
|
inspectorMetadataNotificationQueue = Promise.resolve();
|
|
2111
|
-
|
|
2112
|
-
|
|
2111
|
+
_generativeUIEnabled = false;
|
|
2112
|
+
_generativeUIAgents;
|
|
2113
2113
|
_openGenerativeUIEnabled = false;
|
|
2114
2114
|
_licenseStatus;
|
|
2115
2115
|
_runtimeEntitlements;
|
|
@@ -2181,15 +2181,16 @@ var AgentRegistry = class {
|
|
|
2181
2181
|
get inspectorMetadata() {
|
|
2182
2182
|
return this._inspectorMetadata;
|
|
2183
2183
|
}
|
|
2184
|
-
|
|
2185
|
-
|
|
2184
|
+
/** Whether the runtime turns generative UI (A2UI 1.0) on. */
|
|
2185
|
+
get generativeUIEnabled() {
|
|
2186
|
+
return this._generativeUIEnabled;
|
|
2186
2187
|
}
|
|
2187
2188
|
/**
|
|
2188
|
-
* Agent ids the runtime
|
|
2189
|
-
*
|
|
2189
|
+
* Agent ids the runtime limits generative UI to. `undefined` means every
|
|
2190
|
+
* agent, or off; check `generativeUIEnabled`.
|
|
2190
2191
|
*/
|
|
2191
|
-
get
|
|
2192
|
-
return this.
|
|
2192
|
+
get generativeUIAgents() {
|
|
2193
|
+
return this._generativeUIAgents;
|
|
2193
2194
|
}
|
|
2194
2195
|
get openGenerativeUIEnabled() {
|
|
2195
2196
|
return this._openGenerativeUIEnabled;
|
|
@@ -2951,8 +2952,8 @@ var AgentRegistry = class {
|
|
|
2951
2952
|
this._singleRouteResourceOperations = false;
|
|
2952
2953
|
this._suggestions = void 0;
|
|
2953
2954
|
this._inspectorLearning = false;
|
|
2954
|
-
this.
|
|
2955
|
-
this.
|
|
2955
|
+
this._generativeUIEnabled = false;
|
|
2956
|
+
this._generativeUIAgents = void 0;
|
|
2956
2957
|
this._openGenerativeUIEnabled = false;
|
|
2957
2958
|
this._licenseStatus = void 0;
|
|
2958
2959
|
this._runtimeEntitlements = void 0;
|
|
@@ -3030,9 +3031,9 @@ var AgentRegistry = class {
|
|
|
3030
3031
|
this._inspectorMetadataSupported = runtimeInfoResponse.inspectorMetadata === true;
|
|
3031
3032
|
this.inspectorMetadataRefreshReady = false;
|
|
3032
3033
|
if (!this._inspectorMetadataSupported) this.setInspectorMetadata(void 0);
|
|
3033
|
-
const
|
|
3034
|
-
this.
|
|
3035
|
-
this.
|
|
3034
|
+
const generativeUIInfo = runtimeInfoResponse.generativeUI;
|
|
3035
|
+
this._generativeUIEnabled = generativeUIInfo?.enabled ?? false;
|
|
3036
|
+
this._generativeUIAgents = generativeUIInfo?.enabled ? generativeUIInfo.agents : void 0;
|
|
3036
3037
|
this._openGenerativeUIEnabled = runtimeInfoResponse.openGenerativeUIEnabled ?? false;
|
|
3037
3038
|
this._licenseStatus = runtimeInfoResponse.licenseStatus;
|
|
3038
3039
|
this._runtimeEntitlements = runtimeInfoResponse.runtimeEntitlements;
|
|
@@ -3063,8 +3064,8 @@ var AgentRegistry = class {
|
|
|
3063
3064
|
this._singleRouteResourceOperations = false;
|
|
3064
3065
|
this._suggestions = void 0;
|
|
3065
3066
|
this._inspectorLearning = false;
|
|
3066
|
-
this.
|
|
3067
|
-
this.
|
|
3067
|
+
this._generativeUIEnabled = false;
|
|
3068
|
+
this._generativeUIAgents = void 0;
|
|
3068
3069
|
this._openGenerativeUIEnabled = false;
|
|
3069
3070
|
if (!boundedEntitlementRetryFailed) {
|
|
3070
3071
|
this._licenseStatus = void 0;
|
|
@@ -7854,9 +7855,9 @@ function ɵhitlRenderProps(props, tool, registry) {
|
|
|
7854
7855
|
//#region src/core/runtime-info.ts
|
|
7855
7856
|
const RUNTIME_INFO_KEYS = [
|
|
7856
7857
|
"status",
|
|
7857
|
-
"a2uiEnabled",
|
|
7858
|
-
"a2uiAgents",
|
|
7859
7858
|
"openGenerativeUIEnabled",
|
|
7859
|
+
"generativeUIEnabled",
|
|
7860
|
+
"generativeUIAgents",
|
|
7860
7861
|
"licenseStatus",
|
|
7861
7862
|
"runtimeEntitlements",
|
|
7862
7863
|
"runtimeEntitlementRetryPending",
|
|
@@ -8046,8 +8047,8 @@ var CopilotKitCore = class {
|
|
|
8046
8047
|
this.learningBridge = new LearningBridge(this, learning, () => this.notifyTrajectoryChanged());
|
|
8047
8048
|
this.runtimeInfoStore = new ɵRuntimeInfoStore(() => ({
|
|
8048
8049
|
status: this.runtimeConnectionStatus,
|
|
8049
|
-
|
|
8050
|
-
|
|
8050
|
+
generativeUIEnabled: this.generativeUIEnabled,
|
|
8051
|
+
generativeUIAgents: this.generativeUIAgents,
|
|
8051
8052
|
openGenerativeUIEnabled: this.openGenerativeUIEnabled,
|
|
8052
8053
|
licenseStatus: this.licenseStatus,
|
|
8053
8054
|
runtimeEntitlements: this.runtimeEntitlements,
|
|
@@ -8327,15 +8328,16 @@ var CopilotKitCore = class {
|
|
|
8327
8328
|
async refreshInspectorMetadata() {
|
|
8328
8329
|
await this.agentRegistry.refreshInspectorMetadata();
|
|
8329
8330
|
}
|
|
8330
|
-
|
|
8331
|
-
|
|
8331
|
+
/** Whether the runtime turns generative UI (A2UI 1.0) on. */
|
|
8332
|
+
get generativeUIEnabled() {
|
|
8333
|
+
return this.agentRegistry.generativeUIEnabled;
|
|
8332
8334
|
}
|
|
8333
8335
|
/**
|
|
8334
|
-
* Agent ids the runtime
|
|
8335
|
-
*
|
|
8336
|
+
* Agent ids the runtime limits generative UI to. `undefined` means every
|
|
8337
|
+
* agent (or off; check `generativeUIEnabled`).
|
|
8336
8338
|
*/
|
|
8337
|
-
get
|
|
8338
|
-
return this.agentRegistry.
|
|
8339
|
+
get generativeUIAgents() {
|
|
8340
|
+
return this.agentRegistry.generativeUIAgents;
|
|
8339
8341
|
}
|
|
8340
8342
|
get openGenerativeUIEnabled() {
|
|
8341
8343
|
return this.agentRegistry.openGenerativeUIEnabled;
|
|
@@ -9623,7 +9625,7 @@ function toolCallKey(entry) {
|
|
|
9623
9625
|
* Tool-call renderers come from three places. Prop renderers are the list the
|
|
9624
9626
|
* provider was given (`setPropToolCalls`). Hook renderers are added one at a
|
|
9625
9627
|
* time (`addHookToolCall`), for example by `useRenderTool`. Built-in
|
|
9626
|
-
* renderers are added by CopilotKit features such as
|
|
9628
|
+
* renderers are added by CopilotKit features such as generative UI
|
|
9627
9629
|
* (`addBuiltInToolCall`). Each renderer has a key made of its `agentId` and
|
|
9628
9630
|
* `name`. A hook renderer replaces a prop renderer with the same key, and a
|
|
9629
9631
|
* later hook renderer replaces an earlier one with the same key, so the
|
|
@@ -9753,7 +9755,7 @@ var ɵRendererRegistry = class {
|
|
|
9753
9755
|
}
|
|
9754
9756
|
/**
|
|
9755
9757
|
* Add a built-in renderer, for a tool that a CopilotKit feature owns (for
|
|
9756
|
-
* example the
|
|
9758
|
+
* example the generative UI render tool). Prop and hook renderers with the same
|
|
9757
9759
|
* `agentId` and `name` win over it, and setting the prop renderers never
|
|
9758
9760
|
* removes it.
|
|
9759
9761
|
*
|
|
@@ -9764,7 +9766,7 @@ var ɵRendererRegistry = class {
|
|
|
9764
9766
|
*
|
|
9765
9767
|
* @example
|
|
9766
9768
|
* ```ts
|
|
9767
|
-
* const remove = registry.addBuiltInToolCall({ name: "
|
|
9769
|
+
* const remove = registry.addBuiltInToolCall({ name: "render_ui", render: Nothing });
|
|
9768
9770
|
* // when the feature turns off
|
|
9769
9771
|
* remove();
|
|
9770
9772
|
* ```
|
|
@@ -10599,8 +10601,7 @@ function toRuntimeTransport(runtimeTransport, useSingleEndpoint) {
|
|
|
10599
10601
|
* - The transport is `runtimeTransport`, else `useSingleEndpoint` mapped to
|
|
10600
10602
|
* `"single"` (true), `"rest"` (false) or `"auto"` (unset).
|
|
10601
10603
|
* - The agents are the dev agents with `selfManagedAgents` on top.
|
|
10602
|
-
* - The properties
|
|
10603
|
-
* Without a catalog the input object is returned as is.
|
|
10604
|
+
* - The properties are the input object, or a shared empty object.
|
|
10604
10605
|
* - The header defaults carry the public key header when a key is set.
|
|
10605
10606
|
*
|
|
10606
10607
|
* It does not log or throw. The provider reports `diagnostics` (see
|
|
@@ -10616,11 +10617,7 @@ function ɵresolveProviderConfig(input) {
|
|
|
10616
10617
|
...input.agents__unsafe_dev_only,
|
|
10617
10618
|
...input.selfManagedAgents
|
|
10618
10619
|
};
|
|
10619
|
-
const
|
|
10620
|
-
const properties = input.a2uiCatalog ? {
|
|
10621
|
-
...baseProperties,
|
|
10622
|
-
a2uiCatalogAvailable: true
|
|
10623
|
-
} : baseProperties;
|
|
10620
|
+
const properties = input.properties ?? EMPTY_PROPERTIES;
|
|
10624
10621
|
const headerDefaults = ɵpublicKeyHeaderDefaults(publicKey);
|
|
10625
10622
|
const diagnostics = [];
|
|
10626
10623
|
const hasLocalAgents = Object.keys(agents).length > 0;
|
|
@@ -10817,45 +10814,46 @@ function ɵassembleProviderToolRenderers(input) {
|
|
|
10817
10814
|
return renderToolCalls;
|
|
10818
10815
|
}
|
|
10819
10816
|
/**
|
|
10820
|
-
* @internal Whether the provider
|
|
10821
|
-
* its
|
|
10817
|
+
* @internal Whether the provider falls back to the standard UI for generative
|
|
10818
|
+
* UI. That is when the provider has no `generativeUI` UI of its own and the
|
|
10819
|
+
* runtime turns generative UI on. A UI of the app always wins, with its own
|
|
10820
|
+
* `agentIds`.
|
|
10822
10821
|
*
|
|
10823
|
-
*
|
|
10824
|
-
*
|
|
10825
|
-
*
|
|
10826
|
-
* the provider should tell the developer to configure a catalog.
|
|
10822
|
+
* The fallback is scoped to the agents of the runtime: pass `agentIds` on as
|
|
10823
|
+
* the `agentIds` of the generative UI config, so only those agents get the
|
|
10824
|
+
* envelope.
|
|
10827
10825
|
*
|
|
10828
10826
|
* @example
|
|
10829
|
-
*
|
|
10830
|
-
*
|
|
10831
|
-
*
|
|
10832
|
-
*
|
|
10833
|
-
|
|
10834
|
-
|
|
10835
|
-
|
|
10836
|
-
|
|
10837
|
-
|
|
10838
|
-
|
|
10827
|
+
* const fallback = ɵresolveGenerativeUIDefault({
|
|
10828
|
+
* runtimeEnabled: runtimeInfo.generativeUIEnabled,
|
|
10829
|
+
* runtimeAgents: runtimeInfo.generativeUIAgents,
|
|
10830
|
+
* hasUI: !!generativeUI?.ui,
|
|
10831
|
+
* });
|
|
10832
|
+
* const config =
|
|
10833
|
+
* generativeUI ??
|
|
10834
|
+
* (fallback.active
|
|
10835
|
+
* ? { ui: standardUI, agentIds: fallback.agentIds }
|
|
10836
|
+
* : undefined);
|
|
10837
|
+
*/
|
|
10838
|
+
function ɵresolveGenerativeUIDefault({ runtimeEnabled, runtimeAgents, hasUI }) {
|
|
10839
|
+
if (hasUI || !runtimeEnabled) return { active: false };
|
|
10839
10840
|
return {
|
|
10840
|
-
active:
|
|
10841
|
-
|
|
10841
|
+
active: true,
|
|
10842
|
+
agentIds: runtimeAgents
|
|
10842
10843
|
};
|
|
10843
10844
|
}
|
|
10844
10845
|
/**
|
|
10845
10846
|
* @internal The provider's activity renderer list: the app's renderers, then
|
|
10846
|
-
* the
|
|
10847
|
-
* left out.
|
|
10847
|
+
* the built-in renderers. Missing entries are left out.
|
|
10848
10848
|
*
|
|
10849
10849
|
* @example
|
|
10850
10850
|
* ɵassembleActivityRenderers({
|
|
10851
10851
|
* app: props.renderActivityMessages,
|
|
10852
|
-
*
|
|
10853
|
-
* builtIns: [mcpAppsRenderer, openGenUIActive && openGenUIRenderer],
|
|
10852
|
+
* * builtIns: [mcpAppsRenderer, openGenUIActive && openGenUIRenderer],
|
|
10854
10853
|
* });
|
|
10855
10854
|
*/
|
|
10856
|
-
function ɵassembleActivityRenderers({ app = [],
|
|
10855
|
+
function ɵassembleActivityRenderers({ app = [], builtIns = [] }) {
|
|
10857
10856
|
const renderers = [...app];
|
|
10858
|
-
if (a2ui) renderers.push(a2ui);
|
|
10859
10857
|
for (const renderer of builtIns) if (renderer) renderers.push(renderer);
|
|
10860
10858
|
return renderers;
|
|
10861
10859
|
}
|
|
@@ -12075,713 +12073,6 @@ var ɵInspectorThreadOverride = class {
|
|
|
12075
12073
|
}
|
|
12076
12074
|
};
|
|
12077
12075
|
|
|
12078
|
-
//#endregion
|
|
12079
|
-
//#region src/a2ui/constants.ts
|
|
12080
|
-
/**
|
|
12081
|
-
* The content key that carries A2UI operations, on `a2ui-surface` activities
|
|
12082
|
-
* and on render tool results. Must match `A2UI_OPERATIONS_KEY` in
|
|
12083
|
-
* `@ag-ui/a2ui-middleware` and `copilotkit_runtime.a2ui` (Python).
|
|
12084
|
-
*/
|
|
12085
|
-
const A2UI_OPERATIONS_KEY = "a2ui_operations";
|
|
12086
|
-
/** The activity type the A2UI middleware streams surfaces and their lifecycle on. */
|
|
12087
|
-
const A2UI_SURFACE_ACTIVITY_TYPE = "a2ui-surface";
|
|
12088
|
-
/** The tool the A2UI middleware injects so the model can generate a surface. */
|
|
12089
|
-
const RENDER_A2UI_TOOL_NAME = "render_a2ui";
|
|
12090
|
-
/** The surface an operation that names no surface is filed under. */
|
|
12091
|
-
const A2UI_DEFAULT_SURFACE_ID = "default";
|
|
12092
|
-
/**
|
|
12093
|
-
* The component id every renderer starts from when it walks a surface. A2UI
|
|
12094
|
-
* v0.9 gives a payload no way to name its own entry point, so it is fixed.
|
|
12095
|
-
* `@copilotkit/a2ui-renderer` exports the same value as `ROOT_COMPONENT_ID`.
|
|
12096
|
-
*/
|
|
12097
|
-
const A2UI_ROOT_COMPONENT_ID = "root";
|
|
12098
|
-
|
|
12099
|
-
//#endregion
|
|
12100
|
-
//#region src/a2ui/operations.ts
|
|
12101
|
-
function isRecord$1(value) {
|
|
12102
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12103
|
-
}
|
|
12104
|
-
/**
|
|
12105
|
-
* Reads the A2UI operations from activity content or a tool result payload.
|
|
12106
|
-
* The `a2ui_operations` key wins; a bare `operations` key is accepted too.
|
|
12107
|
-
* Entries that are not objects are dropped.
|
|
12108
|
-
*
|
|
12109
|
-
* @param content - Activity content or a parsed tool result, of any shape.
|
|
12110
|
-
* @returns The operations, or an empty list when there are none.
|
|
12111
|
-
*/
|
|
12112
|
-
function getA2UIOperations(content) {
|
|
12113
|
-
if (!isRecord$1(content)) return [];
|
|
12114
|
-
const operations = content[A2UI_OPERATIONS_KEY] ?? content.operations;
|
|
12115
|
-
if (!Array.isArray(operations)) return [];
|
|
12116
|
-
return operations.filter(isRecord$1);
|
|
12117
|
-
}
|
|
12118
|
-
/**
|
|
12119
|
-
* The operation keys that nest a `surfaceId`, v0.9 first, then the v0.8 keys
|
|
12120
|
-
* older agents still send.
|
|
12121
|
-
*/
|
|
12122
|
-
const NESTED_SURFACE_KEYS = [
|
|
12123
|
-
"createSurface",
|
|
12124
|
-
"updateComponents",
|
|
12125
|
-
"updateDataModel",
|
|
12126
|
-
"deleteSurface",
|
|
12127
|
-
"beginRendering",
|
|
12128
|
-
"surfaceUpdate",
|
|
12129
|
-
"dataModelUpdate"
|
|
12130
|
-
];
|
|
12131
|
-
/**
|
|
12132
|
-
* Resolves the surface an operation addresses.
|
|
12133
|
-
*
|
|
12134
|
-
* The nested `surfaceId` wins, because that is the id `MessageProcessor`
|
|
12135
|
-
* creates the surface under. Grouping by a top-level `surfaceId` instead files
|
|
12136
|
-
* the operations against a surface that never exists, which paints nothing
|
|
12137
|
-
* (OSS-1048). A top-level `surfaceId` is honoured only when no nested id is
|
|
12138
|
-
* present.
|
|
12139
|
-
*
|
|
12140
|
-
* @param operation - One A2UI operation, of any shape.
|
|
12141
|
-
* @returns The surface id, or null when the operation names none.
|
|
12142
|
-
*/
|
|
12143
|
-
function getA2UIOperationSurfaceId(operation) {
|
|
12144
|
-
if (!isRecord$1(operation)) return null;
|
|
12145
|
-
for (const key of NESTED_SURFACE_KEYS) {
|
|
12146
|
-
const inner = operation[key];
|
|
12147
|
-
if (isRecord$1(inner) && typeof inner.surfaceId === "string") return inner.surfaceId;
|
|
12148
|
-
}
|
|
12149
|
-
return typeof operation.surfaceId === "string" ? operation.surfaceId : null;
|
|
12150
|
-
}
|
|
12151
|
-
/**
|
|
12152
|
-
* Groups operations by the surface they address, in first-seen order. An
|
|
12153
|
-
* operation that names no surface goes under `"default"`.
|
|
12154
|
-
*
|
|
12155
|
-
* @param operations - Operations in arrival order.
|
|
12156
|
-
*/
|
|
12157
|
-
function groupA2UIOperationsBySurface(operations) {
|
|
12158
|
-
const groups = /* @__PURE__ */ new Map();
|
|
12159
|
-
for (const operation of operations) {
|
|
12160
|
-
const surfaceId = getA2UIOperationSurfaceId(operation) ?? A2UI_DEFAULT_SURFACE_ID;
|
|
12161
|
-
const group = groups.get(surfaceId);
|
|
12162
|
-
if (group) group.push(operation);
|
|
12163
|
-
else groups.set(surfaceId, [operation]);
|
|
12164
|
-
}
|
|
12165
|
-
return groups;
|
|
12166
|
-
}
|
|
12167
|
-
function hasValue(value) {
|
|
12168
|
-
if (Array.isArray(value)) return value.length > 0;
|
|
12169
|
-
return value !== null && value !== void 0 && value !== "";
|
|
12170
|
-
}
|
|
12171
|
-
/**
|
|
12172
|
-
* The component definitions an operation carries: those of an
|
|
12173
|
-
* `updateComponents`, or those a native (A2UI 1.0) `createSurface` carries
|
|
12174
|
-
* inline.
|
|
12175
|
-
*
|
|
12176
|
-
* @param operation - One A2UI operation.
|
|
12177
|
-
*/
|
|
12178
|
-
function getA2UIOperationComponents(operation) {
|
|
12179
|
-
const update = operation.updateComponents;
|
|
12180
|
-
const create = operation.createSurface;
|
|
12181
|
-
const components = isRecord$1(update) ? update.components : operation.version === "1.0" && isRecord$1(create) ? create.components : void 0;
|
|
12182
|
-
return Array.isArray(components) ? components : [];
|
|
12183
|
-
}
|
|
12184
|
-
/**
|
|
12185
|
-
* Whether operations are enough to paint a visible card yet. A data-bound
|
|
12186
|
-
* surface addresses its values by `path` (`@path` in A2UI 1.0) and draws
|
|
12187
|
-
* nothing until a data model update, or a native create's inline data model,
|
|
12188
|
-
* carries a non-empty value; a static surface paints from its components
|
|
12189
|
-
* alone. Times the loader → surface hand-off to real content rather than a
|
|
12190
|
-
* fixed delay (OSS-162).
|
|
12191
|
-
*
|
|
12192
|
-
* @param operations - The operations of one surface or of a whole activity.
|
|
12193
|
-
*/
|
|
12194
|
-
function surfaceHasRenderableContent(operations) {
|
|
12195
|
-
const components = operations.flatMap(getA2UIOperationComponents);
|
|
12196
|
-
if (components.length === 0) return false;
|
|
12197
|
-
const serialized = JSON.stringify(components);
|
|
12198
|
-
if (!(serialized.includes("\"path\"") || serialized.includes("\"@path\""))) return true;
|
|
12199
|
-
return operations.some((operation) => {
|
|
12200
|
-
const update = isRecord$1(operation.updateDataModel) ? operation.updateDataModel : void 0;
|
|
12201
|
-
const create = operation.createSurface;
|
|
12202
|
-
const value = update?.value ?? (operation.version === "1.0" && isRecord$1(create) ? create.dataModel : void 0);
|
|
12203
|
-
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
12204
|
-
const path = typeof update?.path === "string" ? update.path : "/";
|
|
12205
|
-
const key = operation.version === "1.0" ? "@path" : "path";
|
|
12206
|
-
return value !== "" && serialized.includes(JSON.stringify({ [key]: path }));
|
|
12207
|
-
}
|
|
12208
|
-
if (typeof value !== "object" || value === null) return false;
|
|
12209
|
-
return Object.values(value).some(hasValue);
|
|
12210
|
-
});
|
|
12211
|
-
}
|
|
12212
|
-
|
|
12213
|
-
//#endregion
|
|
12214
|
-
//#region src/a2ui/diagnostics.ts
|
|
12215
|
-
/**
|
|
12216
|
-
* How long a surface may take to report its first paint before the loader
|
|
12217
|
-
* hand-off gives up and shows it anyway. Reaching it with no paint is also the
|
|
12218
|
-
* moment the unpainted and unresolved-root diagnostics fire.
|
|
12219
|
-
*/
|
|
12220
|
-
const A2UI_PAINT_FALLBACK_MS = 8e3;
|
|
12221
|
-
/** The operation kinds a surface received, comma-separated, or "none". */
|
|
12222
|
-
function describeOperationKinds(operations) {
|
|
12223
|
-
const kinds = /* @__PURE__ */ new Set();
|
|
12224
|
-
for (const operation of operations) for (const key of Object.keys(operation)) if (key !== "version") kinds.add(key);
|
|
12225
|
-
return kinds.size === 0 ? "none" : Array.from(kinds).join(", ");
|
|
12226
|
-
}
|
|
12227
|
-
function componentLists(operations) {
|
|
12228
|
-
const lists = [];
|
|
12229
|
-
for (const operation of operations) {
|
|
12230
|
-
const components = getA2UIOperationComponents(operation);
|
|
12231
|
-
if (components.length > 0) lists.push(components);
|
|
12232
|
-
}
|
|
12233
|
-
return lists;
|
|
12234
|
-
}
|
|
12235
|
-
/** The component ids a surface was sent, quoted and comma-separated, or "none". */
|
|
12236
|
-
function describeComponentIds(operations) {
|
|
12237
|
-
const ids = [];
|
|
12238
|
-
const lists = componentLists(operations);
|
|
12239
|
-
for (const components of lists) for (const component of components) {
|
|
12240
|
-
const id = isRecord$1(component) ? component.id : void 0;
|
|
12241
|
-
if (typeof id === "string" && !ids.includes(id)) ids.push(id);
|
|
12242
|
-
}
|
|
12243
|
-
return ids.length === 0 ? "none" : ids.map((id) => `"${id}"`).join(", ");
|
|
12244
|
-
}
|
|
12245
|
-
/**
|
|
12246
|
-
* Explains why a surface that received operations never painted, or returns
|
|
12247
|
-
* null when its operations are enough to paint.
|
|
12248
|
-
*
|
|
12249
|
-
* Reaching {@link A2UI_PAINT_FALLBACK_MS} with no paint means the operations
|
|
12250
|
-
* were accepted and still put nothing on screen. Left alone that is
|
|
12251
|
-
* invisible, so the message says which half is missing.
|
|
12252
|
-
*
|
|
12253
|
-
* @param surfaceId - The surface the operations address.
|
|
12254
|
-
* @param operations - The operations grouped under that surface.
|
|
12255
|
-
*/
|
|
12256
|
-
function diagnoseUnpaintedSurface(surfaceId, operations) {
|
|
12257
|
-
if (surfaceHasRenderableContent(operations)) return null;
|
|
12258
|
-
const cause = componentLists(operations).length === 0 ? "no updateComponents operation arrived, so the surface was never given anything to draw" : "its components address their values by \"path\" and no updateDataModel carried a non-empty value, so every bound component drew empty";
|
|
12259
|
-
return `[CopilotKit] A2UI surface "${surfaceId}" received operations and never painted after ${String(A2UI_PAINT_FALLBACK_MS)}ms: ${cause}. Operations received: ${describeOperationKinds(operations)}. The payload was accepted, so check what the agent sent rather than the client wiring. This warning is development-only.`;
|
|
12260
|
-
}
|
|
12261
|
-
/**
|
|
12262
|
-
* Explains a surface that never got created although operations addressed
|
|
12263
|
-
* it. The usual cause is operations sent to one surface id while the surface
|
|
12264
|
-
* was created under another, or operations that were all dropped as invalid.
|
|
12265
|
-
*
|
|
12266
|
-
* @param surfaceId - The surface the operations address.
|
|
12267
|
-
* @param operations - The operations processed for that surface.
|
|
12268
|
-
*/
|
|
12269
|
-
function diagnoseMissingSurface(surfaceId, operations) {
|
|
12270
|
-
return `[CopilotKit] A2UI processed ${String(operations.length)} operation(s) addressed to surface "${surfaceId}" and no surface by that id exists, so this card rendered nothing. Operations received: ${describeOperationKinds(operations)}. A createSurface for "${surfaceId}" has to arrive before, or with, the operations that target it. This warning is development-only.`;
|
|
12271
|
-
}
|
|
12272
|
-
/**
|
|
12273
|
-
* Explains a surface still waiting for its root component once operations
|
|
12274
|
-
* have stopped arriving, or returns null when the root resolved (or when no
|
|
12275
|
-
* components arrived at all, which {@link diagnoseUnpaintedSurface} explains
|
|
12276
|
-
* better).
|
|
12277
|
-
*
|
|
12278
|
-
* Renderers begin walking a surface at the root id and treat an id they cannot
|
|
12279
|
-
* find as not arrived yet, so a payload without it animates a placeholder
|
|
12280
|
-
* forever while every other check calls it healthy. Reads the live components
|
|
12281
|
-
* model, so it covers every way the root can fail to resolve.
|
|
12282
|
-
*
|
|
12283
|
-
* @param surfaceId - The surface the operations address.
|
|
12284
|
-
* @param operations - The operations processed for that surface.
|
|
12285
|
-
* @param surface - The live surface model.
|
|
12286
|
-
*/
|
|
12287
|
-
function diagnoseUnresolvedRoot(surfaceId, operations, surface) {
|
|
12288
|
-
if (surface.componentsModel.get(A2UI_ROOT_COMPONENT_ID)) return null;
|
|
12289
|
-
const lists = componentLists(operations);
|
|
12290
|
-
if (lists.length === 0) return null;
|
|
12291
|
-
const cause = lists.some((components) => components.some((component) => isRecord$1(component) && component.id === A2UI_ROOT_COMPONENT_ID)) ? `a component with id "${A2UI_ROOT_COMPONENT_ID}" WAS sent, so the components did not reach the surface's model — check for an A2UI render error above, or a catalog that took none of them` : `the components it received are named ${describeComponentIds(operations)}, and none of them is "${A2UI_ROOT_COMPONENT_ID}" — rename the entry-point component to "${A2UI_ROOT_COMPONENT_ID}", and make every other component reachable from it through child/children`;
|
|
12292
|
-
return `[CopilotKit] A2UI surface "${surfaceId}" has no "${A2UI_ROOT_COMPONENT_ID}" component ${String(A2UI_PAINT_FALLBACK_MS)}ms after its last operations were processed, so it is showing the placeholder for a component that has not arrived yet and will keep showing it: ${cause}. Operations received: ${describeOperationKinds(operations)}. This warning is development-only.`;
|
|
12293
|
-
}
|
|
12294
|
-
|
|
12295
|
-
//#endregion
|
|
12296
|
-
//#region src/a2ui/actions.ts
|
|
12297
|
-
/**
|
|
12298
|
-
* Wraps a raw processor action in the client-event envelope the runtimes read,
|
|
12299
|
-
* filling the fields a partial action leaves out. Other fields the action
|
|
12300
|
-
* carries, such as a native action's `userMessage`, are kept.
|
|
12301
|
-
*
|
|
12302
|
-
* @param action - What the `MessageProcessor` action handler received.
|
|
12303
|
-
*/
|
|
12304
|
-
function toA2UIClientEvent(action) {
|
|
12305
|
-
return { userAction: {
|
|
12306
|
-
...action,
|
|
12307
|
-
name: action.name ?? "unknown",
|
|
12308
|
-
surfaceId: action.surfaceId ?? A2UI_DEFAULT_SURFACE_ID,
|
|
12309
|
-
sourceComponentId: action.sourceComponentId ?? "",
|
|
12310
|
-
context: action.context,
|
|
12311
|
-
timestamp: action.timestamp ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
12312
|
-
} };
|
|
12313
|
-
}
|
|
12314
|
-
/**
|
|
12315
|
-
* Sends one A2UI user action to the agent: runs the optional `onAction`
|
|
12316
|
-
* interceptor first, then sets the `a2uiAction` run property and runs the
|
|
12317
|
-
* agent unless the interceptor suppressed it (returned `null`). The
|
|
12318
|
-
* `a2uiAction` property is always removed afterwards so it does not leak into
|
|
12319
|
-
* later runs.
|
|
12320
|
-
*
|
|
12321
|
-
* Does nothing when there is no agent (a surface rendered outside a chat).
|
|
12322
|
-
*
|
|
12323
|
-
* @example
|
|
12324
|
-
* ```ts
|
|
12325
|
-
* new MessageProcessor([catalog], (action) =>
|
|
12326
|
-
* ɵrunA2UIAction({ message: ɵtoA2UIClientEvent(action), agent, core }),
|
|
12327
|
-
* );
|
|
12328
|
-
* ```
|
|
12329
|
-
*/
|
|
12330
|
-
async function runA2UIAction({ message, agent, core, onAction }) {
|
|
12331
|
-
if (!agent) return;
|
|
12332
|
-
const forward = async (forwardAction) => {
|
|
12333
|
-
const a2uiAction = forwardAction === void 0 ? message : {
|
|
12334
|
-
...message,
|
|
12335
|
-
userAction: forwardAction
|
|
12336
|
-
};
|
|
12337
|
-
try {
|
|
12338
|
-
core.setProperties({
|
|
12339
|
-
...core.properties,
|
|
12340
|
-
a2uiAction
|
|
12341
|
-
});
|
|
12342
|
-
await core.runAgent({ agent });
|
|
12343
|
-
} finally {
|
|
12344
|
-
const { a2uiAction: _removed, ...rest } = core.properties;
|
|
12345
|
-
core.setProperties(rest);
|
|
12346
|
-
}
|
|
12347
|
-
};
|
|
12348
|
-
if (onAction) {
|
|
12349
|
-
const result = await onAction(message.userAction, forward);
|
|
12350
|
-
if (result === null) return;
|
|
12351
|
-
if (result) {
|
|
12352
|
-
await forward(result);
|
|
12353
|
-
return;
|
|
12354
|
-
}
|
|
12355
|
-
}
|
|
12356
|
-
await forward();
|
|
12357
|
-
}
|
|
12358
|
-
|
|
12359
|
-
//#endregion
|
|
12360
|
-
//#region src/a2ui/lifecycle.ts
|
|
12361
|
-
const A2UI_RECOVERY_DEFAULTS = {
|
|
12362
|
-
showAfterMs: 2e3,
|
|
12363
|
-
showAfterAttempts: 2,
|
|
12364
|
-
debugExposure: "collapsed",
|
|
12365
|
-
paintFallbackMs: A2UI_PAINT_FALLBACK_MS
|
|
12366
|
-
};
|
|
12367
|
-
/** User-visible text of the lifecycle states. */
|
|
12368
|
-
const A2UI_LIFECYCLE_TEXT = {
|
|
12369
|
-
building: "Building interface",
|
|
12370
|
-
retrying: "Retrying generation…",
|
|
12371
|
-
failureTitle: "Couldn't generate the UI",
|
|
12372
|
-
failureDescription: "Something went wrong rendering this. You can keep chatting and try again.",
|
|
12373
|
-
failureDetails: "developer details",
|
|
12374
|
-
retryDetails: "validation issues"
|
|
12375
|
-
};
|
|
12376
|
-
function isDebugExposure(value) {
|
|
12377
|
-
return value === "hidden" || value === "collapsed" || value === "verbose";
|
|
12378
|
-
}
|
|
12379
|
-
function numberOrUndefined(value) {
|
|
12380
|
-
return typeof value === "number" ? value : void 0;
|
|
12381
|
-
}
|
|
12382
|
-
function arrayOrUndefined(value) {
|
|
12383
|
-
return Array.isArray(value) ? value : void 0;
|
|
12384
|
-
}
|
|
12385
|
-
/**
|
|
12386
|
-
* Reads the lifecycle fields from activity content. An unknown or missing
|
|
12387
|
-
* `status` reads as "building"; fields of the wrong type are left out.
|
|
12388
|
-
*
|
|
12389
|
-
* @param content - `a2ui-surface` activity content, of any shape.
|
|
12390
|
-
*/
|
|
12391
|
-
function readA2UILifecycle(content) {
|
|
12392
|
-
if (!isRecord$1(content)) return { status: "building" };
|
|
12393
|
-
return {
|
|
12394
|
-
status: content.status === "retrying" || content.status === "failed" ? content.status : "building",
|
|
12395
|
-
attempt: numberOrUndefined(content.attempt),
|
|
12396
|
-
maxAttempts: numberOrUndefined(content.maxAttempts),
|
|
12397
|
-
progressTokens: numberOrUndefined(content.progressTokens),
|
|
12398
|
-
error: typeof content.error === "string" ? content.error : void 0,
|
|
12399
|
-
errors: arrayOrUndefined(content.errors),
|
|
12400
|
-
attempts: arrayOrUndefined(content.attempts),
|
|
12401
|
-
debugExposure: isDebugExposure(content.debugExposure) ? content.debugExposure : void 0
|
|
12402
|
-
};
|
|
12403
|
-
}
|
|
12404
|
-
/**
|
|
12405
|
-
* Validates `a2ui-surface` activity content for activity renderer
|
|
12406
|
-
* registration. Any object passes: {@link readA2UILifecycle} and
|
|
12407
|
-
* `getA2UIOperations` read the fields and ignore mistyped ones, so a field
|
|
12408
|
-
* a newer middleware adds can never hide the surface.
|
|
12409
|
-
*/
|
|
12410
|
-
const A2UI_SURFACE_CONTENT_SCHEMA = { "~standard": {
|
|
12411
|
-
version: 1,
|
|
12412
|
-
vendor: "copilotkit",
|
|
12413
|
-
validate: (value) => isRecord$1(value) ? { value } : { issues: [{ message: "a2ui-surface content must be an object" }] }
|
|
12414
|
-
} };
|
|
12415
|
-
/**
|
|
12416
|
-
* The debug exposure to use: the server-stamped one wins, then the client
|
|
12417
|
-
* option, then "collapsed".
|
|
12418
|
-
*/
|
|
12419
|
-
function resolveA2UIDebugExposure(lifecycle, option) {
|
|
12420
|
-
return lifecycle.debugExposure ?? option ?? A2UI_RECOVERY_DEFAULTS.debugExposure;
|
|
12421
|
-
}
|
|
12422
|
-
/**
|
|
12423
|
-
* How much of the skeleton to reveal for an estimated token count. With no
|
|
12424
|
-
* count yet the full skeleton shows rather than an empty box.
|
|
12425
|
-
*
|
|
12426
|
-
* @param tokens - The streamed token estimate, if the server sent one.
|
|
12427
|
-
*/
|
|
12428
|
-
function getA2UIProgressPhase(tokens) {
|
|
12429
|
-
let phase = 3;
|
|
12430
|
-
if (tokens === void 0) return phase;
|
|
12431
|
-
if (tokens < 50) phase = 0;
|
|
12432
|
-
else if (tokens < 200) phase = 1;
|
|
12433
|
-
else if (tokens < 400) phase = 2;
|
|
12434
|
-
return phase;
|
|
12435
|
-
}
|
|
12436
|
-
/**
|
|
12437
|
-
* The label under the skeleton: "Building interface" until a retry is
|
|
12438
|
-
* revealed, then "Retrying generation…", with the attempt count when known.
|
|
12439
|
-
*/
|
|
12440
|
-
function formatA2UIRetryLabel(lifecycle, retryRevealed) {
|
|
12441
|
-
if (lifecycle.status !== "retrying" || !retryRevealed) return A2UI_LIFECYCLE_TEXT.building;
|
|
12442
|
-
const { attempt, maxAttempts } = lifecycle;
|
|
12443
|
-
if (attempt === void 0 || maxAttempts === void 0) return A2UI_LIFECYCLE_TEXT.retrying;
|
|
12444
|
-
return `${A2UI_LIFECYCLE_TEXT.retrying} (${String(attempt)}/${String(maxAttempts)} attempts)`;
|
|
12445
|
-
}
|
|
12446
|
-
/**
|
|
12447
|
-
* Serializes a debug payload for display. Never throws: circular references,
|
|
12448
|
-
* functions, bigints and symbols get placeholder text.
|
|
12449
|
-
*/
|
|
12450
|
-
function formatA2UIDebugPayload(value) {
|
|
12451
|
-
if (typeof value === "string") return value;
|
|
12452
|
-
const seen = /* @__PURE__ */ new WeakSet();
|
|
12453
|
-
try {
|
|
12454
|
-
return JSON.stringify(value, (_key, candidate) => {
|
|
12455
|
-
if (typeof candidate === "bigint") return `${candidate.toString()}n`;
|
|
12456
|
-
if (typeof candidate === "function") return "[Function]";
|
|
12457
|
-
if (typeof candidate === "symbol") return candidate.toString();
|
|
12458
|
-
if (typeof candidate === "object" && candidate !== null) {
|
|
12459
|
-
if (seen.has(candidate)) return "[Circular]";
|
|
12460
|
-
seen.add(candidate);
|
|
12461
|
-
}
|
|
12462
|
-
return candidate;
|
|
12463
|
-
}, 2) ?? String(value);
|
|
12464
|
-
} catch {
|
|
12465
|
-
return "[Unserializable value]";
|
|
12466
|
-
}
|
|
12467
|
-
}
|
|
12468
|
-
/** The skeleton rows; each row shows once the progress phase reaches `phase`. */
|
|
12469
|
-
const A2UI_SKELETON_ROWS = [
|
|
12470
|
-
{
|
|
12471
|
-
phase: 0,
|
|
12472
|
-
delay: 0,
|
|
12473
|
-
parts: [{
|
|
12474
|
-
w: 36,
|
|
12475
|
-
bg: "rgba(147,197,253,0.7)",
|
|
12476
|
-
anim: 0
|
|
12477
|
-
}, {
|
|
12478
|
-
w: 80,
|
|
12479
|
-
bg: "rgba(219,234,254,0.8)",
|
|
12480
|
-
anim: .2
|
|
12481
|
-
}]
|
|
12482
|
-
},
|
|
12483
|
-
{
|
|
12484
|
-
phase: 0,
|
|
12485
|
-
delay: .1,
|
|
12486
|
-
parts: [
|
|
12487
|
-
"spacer",
|
|
12488
|
-
"dot",
|
|
12489
|
-
{
|
|
12490
|
-
w: 100,
|
|
12491
|
-
bg: "rgba(24,24,27,0.2)",
|
|
12492
|
-
anim: .3
|
|
12493
|
-
}
|
|
12494
|
-
]
|
|
12495
|
-
},
|
|
12496
|
-
{
|
|
12497
|
-
phase: 1,
|
|
12498
|
-
delay: .15,
|
|
12499
|
-
parts: [
|
|
12500
|
-
"spacer",
|
|
12501
|
-
{
|
|
12502
|
-
w: 48,
|
|
12503
|
-
bg: "rgba(24,24,27,0.15)",
|
|
12504
|
-
anim: .1
|
|
12505
|
-
},
|
|
12506
|
-
{
|
|
12507
|
-
w: 40,
|
|
12508
|
-
bg: "rgba(153,246,228,0.6)",
|
|
12509
|
-
anim: .5
|
|
12510
|
-
},
|
|
12511
|
-
{
|
|
12512
|
-
w: 56,
|
|
12513
|
-
bg: "rgba(147,197,253,0.6)",
|
|
12514
|
-
anim: .3
|
|
12515
|
-
}
|
|
12516
|
-
]
|
|
12517
|
-
},
|
|
12518
|
-
{
|
|
12519
|
-
phase: 1,
|
|
12520
|
-
delay: .2,
|
|
12521
|
-
parts: [
|
|
12522
|
-
"spacer",
|
|
12523
|
-
"dot",
|
|
12524
|
-
{
|
|
12525
|
-
w: 60,
|
|
12526
|
-
bg: "rgba(24,24,27,0.15)",
|
|
12527
|
-
anim: .4
|
|
12528
|
-
}
|
|
12529
|
-
]
|
|
12530
|
-
},
|
|
12531
|
-
{
|
|
12532
|
-
phase: 2,
|
|
12533
|
-
delay: .25,
|
|
12534
|
-
parts: [
|
|
12535
|
-
{
|
|
12536
|
-
w: 40,
|
|
12537
|
-
bg: "rgba(153,246,228,0.5)",
|
|
12538
|
-
anim: .2
|
|
12539
|
-
},
|
|
12540
|
-
"dot",
|
|
12541
|
-
{
|
|
12542
|
-
w: 48,
|
|
12543
|
-
bg: "rgba(24,24,27,0.15)",
|
|
12544
|
-
anim: .6
|
|
12545
|
-
},
|
|
12546
|
-
{
|
|
12547
|
-
w: 64,
|
|
12548
|
-
bg: "rgba(147,197,253,0.5)",
|
|
12549
|
-
anim: .1
|
|
12550
|
-
}
|
|
12551
|
-
]
|
|
12552
|
-
},
|
|
12553
|
-
{
|
|
12554
|
-
phase: 2,
|
|
12555
|
-
delay: .3,
|
|
12556
|
-
parts: [{
|
|
12557
|
-
w: 36,
|
|
12558
|
-
bg: "rgba(147,197,253,0.6)",
|
|
12559
|
-
anim: .5
|
|
12560
|
-
}, {
|
|
12561
|
-
w: 36,
|
|
12562
|
-
bg: "rgba(24,24,27,0.12)",
|
|
12563
|
-
anim: .7
|
|
12564
|
-
}]
|
|
12565
|
-
},
|
|
12566
|
-
{
|
|
12567
|
-
phase: 3,
|
|
12568
|
-
delay: .35,
|
|
12569
|
-
parts: [
|
|
12570
|
-
"dot",
|
|
12571
|
-
{
|
|
12572
|
-
w: 44,
|
|
12573
|
-
bg: "rgba(24,24,27,0.18)",
|
|
12574
|
-
anim: .3
|
|
12575
|
-
},
|
|
12576
|
-
"dot",
|
|
12577
|
-
{
|
|
12578
|
-
w: 56,
|
|
12579
|
-
bg: "rgba(153,246,228,0.5)",
|
|
12580
|
-
anim: .8
|
|
12581
|
-
},
|
|
12582
|
-
{
|
|
12583
|
-
w: 48,
|
|
12584
|
-
bg: "rgba(147,197,253,0.5)",
|
|
12585
|
-
anim: .4
|
|
12586
|
-
}
|
|
12587
|
-
]
|
|
12588
|
-
}
|
|
12589
|
-
];
|
|
12590
|
-
const defaultSchedule = (callback, ms) => {
|
|
12591
|
-
const handle = setTimeout(callback, ms);
|
|
12592
|
-
return () => clearTimeout(handle);
|
|
12593
|
-
};
|
|
12594
|
-
function defaultRequestFrame(callback) {
|
|
12595
|
-
if (typeof globalThis.requestAnimationFrame === "function") globalThis.requestAnimationFrame(() => callback());
|
|
12596
|
-
else callback();
|
|
12597
|
-
}
|
|
12598
|
-
const BUILDING = { status: "building" };
|
|
12599
|
-
/**
|
|
12600
|
-
* Drives what an `a2ui-surface` activity shows: the lifecycle state before
|
|
12601
|
-
* paint, the hand-off while the surface paints hidden, then the surface.
|
|
12602
|
-
*
|
|
12603
|
-
* Give it each content snapshot with `setContent()`, and call `markRendered()`
|
|
12604
|
-
* every time the surface applied operations. A surface counts as painted once
|
|
12605
|
-
* its operations are renderable (see `surfaceHasRenderableContent`) and a
|
|
12606
|
-
* frame has passed; if that never happens the hand-off ends after 8 s anyway
|
|
12607
|
-
* and `warn` reports why.
|
|
12608
|
-
*
|
|
12609
|
-
* @example
|
|
12610
|
-
* ```ts
|
|
12611
|
-
* const controller = new ɵA2UIActivityController({ recovery });
|
|
12612
|
-
* controller.subscribe(() => render(controller.getSnapshot()));
|
|
12613
|
-
* controller.setContent(content);
|
|
12614
|
-
* // after the surface processed operations:
|
|
12615
|
-
* controller.markRendered();
|
|
12616
|
-
* // on unmount:
|
|
12617
|
-
* controller.dispose();
|
|
12618
|
-
* ```
|
|
12619
|
-
*/
|
|
12620
|
-
var A2UIActivityController = class {
|
|
12621
|
-
#listeners = /* @__PURE__ */ new Set();
|
|
12622
|
-
#showAfterMs;
|
|
12623
|
-
#showAfterAttempts;
|
|
12624
|
-
#debugExposureOption;
|
|
12625
|
-
#warn;
|
|
12626
|
-
#schedule;
|
|
12627
|
-
#requestFrame;
|
|
12628
|
-
#content = void 0;
|
|
12629
|
-
#operations = [];
|
|
12630
|
-
#lifecycle = BUILDING;
|
|
12631
|
-
#retryRevealed = false;
|
|
12632
|
-
#cancelRetryTimer;
|
|
12633
|
-
#surfaceReady = false;
|
|
12634
|
-
#paintRequested = false;
|
|
12635
|
-
#cancelFallback;
|
|
12636
|
-
/** Bumped by `dispose()`, so callbacks scheduled before it do nothing. */
|
|
12637
|
-
#generation = 0;
|
|
12638
|
-
#snapshot;
|
|
12639
|
-
constructor(options = {}) {
|
|
12640
|
-
const recovery = options.recovery ?? {};
|
|
12641
|
-
this.#showAfterMs = recovery.showAfterMs ?? A2UI_RECOVERY_DEFAULTS.showAfterMs;
|
|
12642
|
-
this.#showAfterAttempts = recovery.showAfterAttempts ?? A2UI_RECOVERY_DEFAULTS.showAfterAttempts;
|
|
12643
|
-
this.#debugExposureOption = recovery.debugExposure;
|
|
12644
|
-
this.#warn = options.warn;
|
|
12645
|
-
this.#schedule = options.schedule ?? defaultSchedule;
|
|
12646
|
-
this.#requestFrame = options.requestFrame ?? defaultRequestFrame;
|
|
12647
|
-
this.#snapshot = this.#buildSnapshot();
|
|
12648
|
-
}
|
|
12649
|
-
/** The current snapshot. The same object until something changes. */
|
|
12650
|
-
getSnapshot = () => this.#snapshot;
|
|
12651
|
-
/** Calls `listener` when the snapshot changes. Returns the unsubscribe function. */
|
|
12652
|
-
subscribe = (listener) => {
|
|
12653
|
-
this.#listeners.add(listener);
|
|
12654
|
-
return () => {
|
|
12655
|
-
this.#listeners.delete(listener);
|
|
12656
|
-
};
|
|
12657
|
-
};
|
|
12658
|
-
/** Sets the latest activity content. */
|
|
12659
|
-
setContent(content) {
|
|
12660
|
-
if (content === this.#content) return;
|
|
12661
|
-
this.#content = content;
|
|
12662
|
-
const hadOperations = this.#operations.length > 0;
|
|
12663
|
-
this.#operations = getA2UIOperations(content);
|
|
12664
|
-
if (this.#operations.length === 0) {
|
|
12665
|
-
this.#lifecycle = readA2UILifecycle(content);
|
|
12666
|
-
this.#updateRetry();
|
|
12667
|
-
if (hadOperations) this.#resetHandoff();
|
|
12668
|
-
} else if (!hadOperations) this.#startHandoff();
|
|
12669
|
-
this.#emit();
|
|
12670
|
-
}
|
|
12671
|
-
/**
|
|
12672
|
-
* Reports that the surface applied operations. Ends the hand-off after the
|
|
12673
|
-
* next frame once the operations can paint something.
|
|
12674
|
-
*/
|
|
12675
|
-
markRendered() {
|
|
12676
|
-
if (this.#paintRequested || this.#surfaceReady) return;
|
|
12677
|
-
if (this.#operations.length === 0) return;
|
|
12678
|
-
if (!surfaceHasRenderableContent(this.#operations)) return;
|
|
12679
|
-
this.#paintRequested = true;
|
|
12680
|
-
const generation = this.#generation;
|
|
12681
|
-
this.#requestFrame(() => {
|
|
12682
|
-
if (generation !== this.#generation || !this.#paintRequested) return;
|
|
12683
|
-
this.#cancelFallback?.();
|
|
12684
|
-
this.#cancelFallback = void 0;
|
|
12685
|
-
this.#surfaceReady = true;
|
|
12686
|
-
this.#emit();
|
|
12687
|
-
});
|
|
12688
|
-
}
|
|
12689
|
-
/**
|
|
12690
|
-
* Stops the timers and forgets the content. A later `setContent()` starts
|
|
12691
|
-
* again, so a component that remounts can keep using the controller.
|
|
12692
|
-
*/
|
|
12693
|
-
dispose() {
|
|
12694
|
-
this.#generation += 1;
|
|
12695
|
-
this.#cancelRetryTimer?.();
|
|
12696
|
-
this.#cancelRetryTimer = void 0;
|
|
12697
|
-
this.#resetHandoff();
|
|
12698
|
-
this.#content = void 0;
|
|
12699
|
-
this.#operations = [];
|
|
12700
|
-
this.#lifecycle = BUILDING;
|
|
12701
|
-
this.#retryRevealed = false;
|
|
12702
|
-
this.#snapshot = this.#buildSnapshot();
|
|
12703
|
-
}
|
|
12704
|
-
#updateRetry() {
|
|
12705
|
-
const { status, attempt } = this.#lifecycle;
|
|
12706
|
-
if (status !== "retrying") {
|
|
12707
|
-
this.#cancelRetryTimer?.();
|
|
12708
|
-
this.#cancelRetryTimer = void 0;
|
|
12709
|
-
this.#retryRevealed = false;
|
|
12710
|
-
return;
|
|
12711
|
-
}
|
|
12712
|
-
if (attempt !== void 0 && attempt >= this.#showAfterAttempts) {
|
|
12713
|
-
this.#cancelRetryTimer?.();
|
|
12714
|
-
this.#cancelRetryTimer = void 0;
|
|
12715
|
-
this.#retryRevealed = true;
|
|
12716
|
-
return;
|
|
12717
|
-
}
|
|
12718
|
-
if (this.#retryRevealed || this.#cancelRetryTimer) return;
|
|
12719
|
-
this.#cancelRetryTimer = this.#schedule(() => {
|
|
12720
|
-
this.#cancelRetryTimer = void 0;
|
|
12721
|
-
this.#retryRevealed = true;
|
|
12722
|
-
this.#emit();
|
|
12723
|
-
}, this.#showAfterMs);
|
|
12724
|
-
}
|
|
12725
|
-
#startHandoff() {
|
|
12726
|
-
this.#surfaceReady = false;
|
|
12727
|
-
this.#paintRequested = false;
|
|
12728
|
-
this.#cancelFallback?.();
|
|
12729
|
-
this.#cancelFallback = this.#schedule(() => {
|
|
12730
|
-
this.#cancelFallback = void 0;
|
|
12731
|
-
if (!this.#paintRequested) this.#reportUnpainted();
|
|
12732
|
-
this.#surfaceReady = true;
|
|
12733
|
-
this.#emit();
|
|
12734
|
-
}, A2UI_RECOVERY_DEFAULTS.paintFallbackMs);
|
|
12735
|
-
}
|
|
12736
|
-
#resetHandoff() {
|
|
12737
|
-
this.#cancelFallback?.();
|
|
12738
|
-
this.#cancelFallback = void 0;
|
|
12739
|
-
this.#surfaceReady = false;
|
|
12740
|
-
this.#paintRequested = false;
|
|
12741
|
-
}
|
|
12742
|
-
#reportUnpainted() {
|
|
12743
|
-
const warn = this.#warn;
|
|
12744
|
-
if (!warn) return;
|
|
12745
|
-
const groups = groupA2UIOperationsBySurface(this.#operations);
|
|
12746
|
-
for (const [surfaceId, operations] of groups) {
|
|
12747
|
-
const message = diagnoseUnpaintedSurface(surfaceId, operations);
|
|
12748
|
-
if (message) warn(message);
|
|
12749
|
-
}
|
|
12750
|
-
}
|
|
12751
|
-
#emit() {
|
|
12752
|
-
this.#snapshot = this.#buildSnapshot();
|
|
12753
|
-
for (const listener of this.#listeners) listener();
|
|
12754
|
-
}
|
|
12755
|
-
#buildSnapshot() {
|
|
12756
|
-
const lifecycle = this.#lifecycle;
|
|
12757
|
-
const debugExposure = resolveA2UIDebugExposure(lifecycle, this.#debugExposureOption);
|
|
12758
|
-
const isFailed = lifecycle.status === "failed";
|
|
12759
|
-
const hasRetryErrors = lifecycle.status === "retrying" && this.#retryRevealed && (lifecycle.errors?.length ?? 0) > 0;
|
|
12760
|
-
let view = "surface";
|
|
12761
|
-
if (this.#operations.length === 0) view = "lifecycle";
|
|
12762
|
-
else if (!this.#surfaceReady) view = "handoff";
|
|
12763
|
-
return {
|
|
12764
|
-
view,
|
|
12765
|
-
operations: this.#operations,
|
|
12766
|
-
lifecycle,
|
|
12767
|
-
debugExposure,
|
|
12768
|
-
retryRevealed: this.#retryRevealed,
|
|
12769
|
-
label: formatA2UIRetryLabel(lifecycle, this.#retryRevealed),
|
|
12770
|
-
progressPhase: getA2UIProgressPhase(lifecycle.progressTokens),
|
|
12771
|
-
showDebugDetails: debugExposure !== "hidden" && (isFailed || hasRetryErrors),
|
|
12772
|
-
debugDetailsOpen: debugExposure === "verbose",
|
|
12773
|
-
debugDetailsLabel: isFailed ? A2UI_LIFECYCLE_TEXT.failureDetails : A2UI_LIFECYCLE_TEXT.retryDetails,
|
|
12774
|
-
debugPayload: formatA2UIDebugPayload(isFailed ? {
|
|
12775
|
-
error: lifecycle.error,
|
|
12776
|
-
attempts: lifecycle.attempts
|
|
12777
|
-
} : {
|
|
12778
|
-
attempt: lifecycle.attempt,
|
|
12779
|
-
errors: lifecycle.errors
|
|
12780
|
-
})
|
|
12781
|
-
};
|
|
12782
|
-
}
|
|
12783
|
-
};
|
|
12784
|
-
|
|
12785
12076
|
//#endregion
|
|
12786
12077
|
//#region src/chat/labels.ts
|
|
12787
12078
|
/**
|
|
@@ -19245,16 +18536,6 @@ exports.props = props;
|
|
|
19245
18536
|
exports.segmentSurfaceProse = require_a2ui_markdown.segmentSurfaceProse;
|
|
19246
18537
|
exports.select = select;
|
|
19247
18538
|
exports.splitA2UIMarkdown = require_a2ui_markdown.splitA2UIMarkdown;
|
|
19248
|
-
exports.ɵA2UIActivityController = A2UIActivityController;
|
|
19249
|
-
exports.ɵA2UI_DEFAULT_SURFACE_ID = A2UI_DEFAULT_SURFACE_ID;
|
|
19250
|
-
exports.ɵA2UI_LIFECYCLE_TEXT = A2UI_LIFECYCLE_TEXT;
|
|
19251
|
-
exports.ɵA2UI_OPERATIONS_KEY = A2UI_OPERATIONS_KEY;
|
|
19252
|
-
exports.ɵA2UI_PAINT_FALLBACK_MS = A2UI_PAINT_FALLBACK_MS;
|
|
19253
|
-
exports.ɵA2UI_RECOVERY_DEFAULTS = A2UI_RECOVERY_DEFAULTS;
|
|
19254
|
-
exports.ɵA2UI_ROOT_COMPONENT_ID = A2UI_ROOT_COMPONENT_ID;
|
|
19255
|
-
exports.ɵA2UI_SKELETON_ROWS = A2UI_SKELETON_ROWS;
|
|
19256
|
-
exports.ɵA2UI_SURFACE_ACTIVITY_TYPE = A2UI_SURFACE_ACTIVITY_TYPE;
|
|
19257
|
-
exports.ɵA2UI_SURFACE_CONTENT_SCHEMA = A2UI_SURFACE_CONTENT_SCHEMA;
|
|
19258
18539
|
exports.ɵALL_AGENT_UPDATES = ɵALL_AGENT_UPDATES;
|
|
19259
18540
|
exports.ɵAgentResolver = ɵAgentResolver;
|
|
19260
18541
|
exports.ɵAttachmentQueue = ɵAttachmentQueue;
|
|
@@ -19305,7 +18586,6 @@ exports.ɵPOPUP_ANIMATION_MS = require_viewport.ɵPOPUP_ANIMATION_MS;
|
|
|
19305
18586
|
exports.ɵPOPUP_DEFAULT_HEIGHT = require_viewport.ɵPOPUP_DEFAULT_HEIGHT;
|
|
19306
18587
|
exports.ɵPOPUP_DEFAULT_WIDTH = require_viewport.ɵPOPUP_DEFAULT_WIDTH;
|
|
19307
18588
|
exports.ɵPlaceholderCycler = PlaceholderCycler;
|
|
19308
|
-
exports.ɵRENDER_A2UI_TOOL_NAME = RENDER_A2UI_TOOL_NAME;
|
|
19309
18589
|
exports.ɵRESIZE_SETTLE_MS = require_viewport.ɵRESIZE_SETTLE_MS;
|
|
19310
18590
|
exports.ɵRUNTIME_PROBE_TIMEOUT_MS = ɵRUNTIME_PROBE_TIMEOUT_MS;
|
|
19311
18591
|
exports.ɵReasoningDisclosure = ɵReasoningDisclosure;
|
|
@@ -19370,9 +18650,6 @@ exports.ɵdecodeTextSource = require_viewport.ɵdecodeTextSource;
|
|
|
19370
18650
|
exports.ɵdeduplicateMessages = ɵdeduplicateMessages;
|
|
19371
18651
|
exports.ɵdescribeActivityRendererFailure = ɵdescribeActivityRendererFailure;
|
|
19372
18652
|
exports.ɵdescribeUnrenderedToolCalls = ɵdescribeUnrenderedToolCalls;
|
|
19373
|
-
exports.ɵdiagnoseMissingSurface = diagnoseMissingSurface;
|
|
19374
|
-
exports.ɵdiagnoseUnpaintedSurface = diagnoseUnpaintedSurface;
|
|
19375
|
-
exports.ɵdiagnoseUnresolvedRoot = diagnoseUnresolvedRoot;
|
|
19376
18653
|
exports.ɵdimensionToCss = require_viewport.ɵdimensionToCss;
|
|
19377
18654
|
exports.ɵdockedSidebarRegistryFor = require_viewport.ɵdockedSidebarRegistryFor;
|
|
19378
18655
|
exports.ɵduplicateMessagesWarning = ɵduplicateMessagesWarning;
|
|
@@ -19385,17 +18662,12 @@ exports.ɵfitTextareaHeight = ɵfitTextareaHeight;
|
|
|
19385
18662
|
exports.ɵflattenCommandItems = ɵflattenCommandItems;
|
|
19386
18663
|
exports.ɵflattenToolsMenuForDisplay = ɵflattenToolsMenuForDisplay;
|
|
19387
18664
|
exports.ɵflattenUserMessageContent = ɵflattenUserMessageContent;
|
|
19388
|
-
exports.ɵformatA2UIDebugPayload = formatA2UIDebugPayload;
|
|
19389
|
-
exports.ɵformatA2UIRetryLabel = formatA2UIRetryLabel;
|
|
19390
18665
|
exports.ɵformatCountLabel = ɵformatCountLabel;
|
|
19391
18666
|
exports.ɵformatLabel = ɵformatLabel;
|
|
19392
18667
|
exports.ɵformatReasoningDuration = formatReasoningDuration;
|
|
19393
18668
|
exports.ɵformatReasoningDurationLabel = ɵformatReasoningDurationLabel;
|
|
19394
18669
|
exports.ɵformatToolNames = formatToolNames;
|
|
19395
18670
|
exports.ɵformatWorkDuration = formatWorkDuration;
|
|
19396
|
-
exports.ɵgetA2UIOperationSurfaceId = getA2UIOperationSurfaceId;
|
|
19397
|
-
exports.ɵgetA2UIOperations = getA2UIOperations;
|
|
19398
|
-
exports.ɵgetA2UIProgressPhase = getA2UIProgressPhase;
|
|
19399
18671
|
exports.ɵgetAgentCapabilities = ɵgetAgentCapabilities;
|
|
19400
18672
|
exports.ɵgetAgentInterruptState = ɵgetAgentInterruptState;
|
|
19401
18673
|
exports.ɵgetAgentResolver = ɵgetAgentResolver;
|
|
@@ -19425,7 +18697,6 @@ exports.ɵgetUserMessageMediaFilename = ɵgetUserMessageMediaFilename;
|
|
|
19425
18697
|
exports.ɵgetUserMessageMediaParts = ɵgetUserMessageMediaParts;
|
|
19426
18698
|
exports.ɵgetWorkOpenState = getWorkOpenState;
|
|
19427
18699
|
exports.ɵgetWorkSummaryText = ɵgetWorkSummaryText;
|
|
19428
|
-
exports.ɵgroupA2UIOperationsBySurface = groupA2UIOperationsBySurface;
|
|
19429
18700
|
exports.ɵhasAssistantMessageText = ɵhasAssistantMessageText;
|
|
19430
18701
|
exports.ɵhitlRenderProps = ɵhitlRenderProps;
|
|
19431
18702
|
exports.ɵimplementsConnect = ɵimplementsConnect;
|
|
@@ -19475,7 +18746,6 @@ exports.ɵpluralize = pluralize;
|
|
|
19475
18746
|
exports.ɵprocessPartialHtml = processPartialHtml;
|
|
19476
18747
|
exports.ɵprojectThread = ɵprojectThread;
|
|
19477
18748
|
exports.ɵpublicKeyHeaderDefaults = ɵpublicKeyHeaderDefaults;
|
|
19478
|
-
exports.ɵreadA2UILifecycle = readA2UILifecycle;
|
|
19479
18749
|
exports.ɵreadKeyboardState = require_viewport.ɵreadKeyboardState;
|
|
19480
18750
|
exports.ɵrecordAnnotation = ɵrecordAnnotation;
|
|
19481
18751
|
exports.ɵrecordWorkTime = recordWorkTime;
|
|
@@ -19484,8 +18754,6 @@ exports.ɵreportProviderConfigDiagnostics = ɵreportProviderConfigDiagnostics;
|
|
|
19484
18754
|
exports.ɵreserveLicenseBannerOffset = ɵreserveLicenseBannerOffset;
|
|
19485
18755
|
exports.ɵresetAgentThreadBaseline = ɵresetAgentThreadBaseline;
|
|
19486
18756
|
exports.ɵresetMessageFeedbackCache = ɵresetMessageFeedbackCache;
|
|
19487
|
-
exports.ɵresolveA2UIActivation = ɵresolveA2UIActivation;
|
|
19488
|
-
exports.ɵresolveA2UIDebugExposure = resolveA2UIDebugExposure;
|
|
19489
18757
|
exports.ɵresolveActivityRenderer = ɵresolveActivityRenderer;
|
|
19490
18758
|
exports.ɵresolveAgentId = ɵresolveAgentId;
|
|
19491
18759
|
exports.ɵresolveAgentThreadId = ɵresolveAgentThreadId;
|
|
@@ -19493,6 +18761,7 @@ exports.ɵresolveChatNotice = ɵresolveChatNotice;
|
|
|
19493
18761
|
exports.ɵresolveComposerKey = ɵresolveComposerKey;
|
|
19494
18762
|
exports.ɵresolveCustomMessageRenderContext = ɵresolveCustomMessageRenderContext;
|
|
19495
18763
|
exports.ɵresolveCustomMessageRenderers = ɵresolveCustomMessageRenderers;
|
|
18764
|
+
exports.ɵresolveGenerativeUIDefault = ɵresolveGenerativeUIDefault;
|
|
19496
18765
|
exports.ɵresolveLicenseState = ɵresolveLicenseState;
|
|
19497
18766
|
exports.ɵresolveProviderConfig = ɵresolveProviderConfig;
|
|
19498
18767
|
exports.ɵresolveSlashKey = ɵresolveSlashKey;
|
|
@@ -19500,7 +18769,6 @@ exports.ɵresolveThreadsLicense = ɵresolveThreadsLicense;
|
|
|
19500
18769
|
exports.ɵresolveToolCallAgentId = ɵresolveToolCallAgentId;
|
|
19501
18770
|
exports.ɵresolveToolCallRenderer = ɵresolveToolCallRenderer;
|
|
19502
18771
|
exports.ɵrmsAmplitude = ɵrmsAmplitude;
|
|
19503
|
-
exports.ɵrunA2UIAction = runA2UIAction;
|
|
19504
18772
|
exports.ɵselectFetchMoreError = ɵselectFetchMoreError;
|
|
19505
18773
|
exports.ɵselectHasNextPage = ɵselectHasNextPage;
|
|
19506
18774
|
exports.ɵselectIsFetchingNextPage = ɵselectIsFetchingNextPage;
|
|
@@ -19530,10 +18798,8 @@ exports.ɵsubscribeToAgentSuggestions = ɵsubscribeToAgentSuggestions;
|
|
|
19530
18798
|
exports.ɵsubscribeToAgentUpdates = ɵsubscribeToAgentUpdates;
|
|
19531
18799
|
exports.ɵsubscribeToLearningFeedbackEnabled = ɵsubscribeToLearningFeedbackEnabled;
|
|
19532
18800
|
exports.ɵsubscribeToMessageFeedback = ɵsubscribeToMessageFeedback;
|
|
19533
|
-
exports.ɵsurfaceHasRenderableContent = surfaceHasRenderableContent;
|
|
19534
18801
|
exports.ɵsyncRecorderToMode = ɵsyncRecorderToMode;
|
|
19535
18802
|
exports.ɵthreadAdapterEvents = ɵthreadAdapterEvents;
|
|
19536
|
-
exports.ɵtoA2UIClientEvent = toA2UIClientEvent;
|
|
19537
18803
|
exports.ɵtoDefaultToolCallStatus = ɵtoDefaultToolCallStatus;
|
|
19538
18804
|
exports.ɵtoDrawerThread = ɵtoDrawerThread;
|
|
19539
18805
|
exports.ɵtoLearningConfig = ɵtoLearningConfig;
|