@copilotkit/shared 2.0.0-rc.3 → 2.0.0-rc.30
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/README.md +3 -14
- package/dist/a2ui-envelope.cjs +2 -2
- package/dist/a2ui-envelope.cjs.map +1 -1
- package/dist/a2ui-envelope.d.cts +1 -1
- package/dist/a2ui-envelope.d.cts.map +1 -1
- package/dist/a2ui-envelope.d.mts +1 -1
- package/dist/a2ui-envelope.d.mts.map +1 -1
- package/dist/a2ui-envelope.mjs +2 -2
- package/dist/a2ui-envelope.mjs.map +1 -1
- package/dist/a2ui-prompts.cjs +21 -62
- package/dist/a2ui-prompts.cjs.map +1 -1
- package/dist/a2ui-prompts.d.cts +8 -1
- package/dist/a2ui-prompts.d.cts.map +1 -1
- package/dist/a2ui-prompts.d.mts +8 -1
- package/dist/a2ui-prompts.d.mts.map +1 -1
- package/dist/a2ui-prompts.mjs +22 -62
- package/dist/a2ui-prompts.mjs.map +1 -1
- package/dist/attachments/types.d.cts +1 -3
- package/dist/attachments/types.d.cts.map +1 -1
- package/dist/attachments/types.d.mts +1 -3
- package/dist/attachments/types.d.mts.map +1 -1
- package/dist/attachments/utils.cjs +16 -5
- package/dist/attachments/utils.cjs.map +1 -1
- package/dist/attachments/utils.d.cts +3 -1
- package/dist/attachments/utils.d.cts.map +1 -1
- package/dist/attachments/utils.d.mts +3 -1
- package/dist/attachments/utils.d.mts.map +1 -1
- package/dist/attachments/utils.mjs +16 -5
- package/dist/attachments/utils.mjs.map +1 -1
- package/dist/finalize-events.cjs +16 -0
- package/dist/finalize-events.cjs.map +1 -1
- package/dist/finalize-events.d.cts.map +1 -1
- package/dist/finalize-events.d.mts.map +1 -1
- package/dist/finalize-events.mjs +16 -0
- package/dist/finalize-events.mjs.map +1 -1
- package/dist/generative-ui/basic-functions.cjs +1 -1
- package/dist/generative-ui/basic-functions.cjs.map +1 -1
- package/dist/generative-ui/basic-functions.mjs +1 -1
- package/dist/generative-ui/basic-functions.mjs.map +1 -1
- package/dist/generative-ui/child-refs.cjs +3 -3
- package/dist/generative-ui/child-refs.cjs.map +1 -1
- package/dist/generative-ui/child-refs.d.cts.map +1 -1
- package/dist/generative-ui/child-refs.d.mts.map +1 -1
- package/dist/generative-ui/child-refs.mjs +3 -3
- package/dist/generative-ui/child-refs.mjs.map +1 -1
- package/dist/generative-ui/compact-schema.cjs +187 -0
- package/dist/generative-ui/compact-schema.cjs.map +1 -0
- package/dist/generative-ui/compact-schema.d.cts +55 -0
- package/dist/generative-ui/compact-schema.d.cts.map +1 -0
- package/dist/generative-ui/compact-schema.d.mts +55 -0
- package/dist/generative-ui/compact-schema.d.mts.map +1 -0
- package/dist/generative-ui/compact-schema.mjs +185 -0
- package/dist/generative-ui/compact-schema.mjs.map +1 -0
- package/dist/generative-ui/prompt-spec.cjs +225 -0
- package/dist/generative-ui/prompt-spec.cjs.map +1 -0
- package/dist/generative-ui/prompt-spec.d.cts +94 -0
- package/dist/generative-ui/prompt-spec.d.cts.map +1 -0
- package/dist/generative-ui/prompt-spec.d.mts +94 -0
- package/dist/generative-ui/prompt-spec.d.mts.map +1 -0
- package/dist/generative-ui/prompt-spec.mjs +220 -0
- package/dist/generative-ui/prompt-spec.mjs.map +1 -0
- package/dist/generative-ui/prompt.cjs +10 -36
- package/dist/generative-ui/prompt.cjs.map +1 -1
- package/dist/generative-ui/prompt.d.cts +2 -1
- package/dist/generative-ui/prompt.d.cts.map +1 -1
- package/dist/generative-ui/prompt.d.mts +2 -1
- package/dist/generative-ui/prompt.d.mts.map +1 -1
- package/dist/generative-ui/prompt.mjs +12 -38
- package/dist/generative-ui/prompt.mjs.map +1 -1
- package/dist/generative-ui/render-ui-args.cjs +1 -0
- package/dist/generative-ui/render-ui-args.cjs.map +1 -1
- package/dist/generative-ui/render-ui-args.d.cts.map +1 -1
- package/dist/generative-ui/render-ui-args.d.mts.map +1 -1
- package/dist/generative-ui/render-ui-args.mjs +1 -0
- package/dist/generative-ui/render-ui-args.mjs.map +1 -1
- package/dist/generative-ui/schema-render.cjs +242 -0
- package/dist/generative-ui/schema-render.cjs.map +1 -0
- package/dist/generative-ui/schema-render.d.cts +44 -0
- package/dist/generative-ui/schema-render.d.cts.map +1 -0
- package/dist/generative-ui/schema-render.d.mts +44 -0
- package/dist/generative-ui/schema-render.d.mts.map +1 -0
- package/dist/generative-ui/schema-render.mjs +239 -0
- package/dist/generative-ui/schema-render.mjs.map +1 -0
- package/dist/generative-ui/types.cjs +2 -2
- package/dist/generative-ui/types.cjs.map +1 -1
- package/dist/generative-ui/types.d.cts +7 -7
- package/dist/generative-ui/types.d.cts.map +1 -1
- package/dist/generative-ui/types.d.mts +7 -7
- package/dist/generative-ui/types.d.mts.map +1 -1
- package/dist/generative-ui/types.mjs +2 -2
- package/dist/generative-ui/types.mjs.map +1 -1
- package/dist/generative-ui/validate-operation.cjs +2 -2
- package/dist/generative-ui/validate-operation.cjs.map +1 -1
- package/dist/generative-ui/validate-operation.mjs +2 -2
- package/dist/generative-ui/validate-operation.mjs.map +1 -1
- package/dist/index.cjs +16 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -10
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +10 -10
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +9 -8
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +866 -455
- package/dist/index.umd.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/standard-schema.cjs +20 -7
- package/dist/standard-schema.cjs.map +1 -1
- package/dist/standard-schema.d.cts +15 -16
- package/dist/standard-schema.d.cts.map +1 -1
- package/dist/standard-schema.d.mts +15 -16
- package/dist/standard-schema.d.mts.map +1 -1
- package/dist/standard-schema.mjs +20 -8
- package/dist/standard-schema.mjs.map +1 -1
- package/dist/telemetry/lambda-client.cjs +1 -1
- package/dist/telemetry/lambda-client.cjs.map +1 -1
- package/dist/telemetry/lambda-client.d.cts.map +1 -1
- package/dist/telemetry/lambda-client.d.mts.map +1 -1
- package/dist/telemetry/lambda-client.mjs +1 -1
- package/dist/telemetry/lambda-client.mjs.map +1 -1
- package/dist/telemetry/telemetry-disabled.cjs +0 -5
- package/dist/telemetry/telemetry-disabled.cjs.map +1 -1
- package/dist/telemetry/telemetry-disabled.d.cts +0 -5
- package/dist/telemetry/telemetry-disabled.d.cts.map +1 -1
- package/dist/telemetry/telemetry-disabled.d.mts +0 -5
- package/dist/telemetry/telemetry-disabled.d.mts.map +1 -1
- package/dist/telemetry/telemetry-disabled.mjs +0 -5
- package/dist/telemetry/telemetry-disabled.mjs.map +1 -1
- package/dist/types/message.d.cts +1 -18
- package/dist/types/message.d.cts.map +1 -1
- package/dist/types/message.d.mts +1 -18
- package/dist/types/message.d.mts.map +1 -1
- package/dist/utils/errors.cjs +5 -42
- package/dist/utils/errors.cjs.map +1 -1
- package/dist/utils/errors.d.cts +16 -34
- package/dist/utils/errors.d.cts.map +1 -1
- package/dist/utils/errors.d.mts +16 -34
- package/dist/utils/errors.d.mts.map +1 -1
- package/dist/utils/errors.mjs +6 -41
- package/dist/utils/errors.mjs.map +1 -1
- package/dist/utils/index.cjs +0 -2
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +4 -6
- package/dist/utils/index.d.cts.map +1 -1
- package/dist/utils/index.d.mts +4 -6
- package/dist/utils/index.d.mts.map +1 -1
- package/dist/utils/index.mjs +4 -6
- package/dist/utils/index.mjs.map +1 -1
- package/dist/utils/inspector-visibility.cjs +25 -3
- package/dist/utils/inspector-visibility.cjs.map +1 -1
- package/dist/utils/inspector-visibility.d.cts +26 -3
- package/dist/utils/inspector-visibility.d.cts.map +1 -1
- package/dist/utils/inspector-visibility.d.mts +26 -3
- package/dist/utils/inspector-visibility.d.mts.map +1 -1
- package/dist/utils/inspector-visibility.mjs +25 -4
- package/dist/utils/inspector-visibility.mjs.map +1 -1
- package/dist/utils/json-schema.cjs +4 -79
- package/dist/utils/json-schema.cjs.map +1 -1
- package/dist/utils/json-schema.d.cts +1 -4
- package/dist/utils/json-schema.d.cts.map +1 -1
- package/dist/utils/json-schema.d.mts +1 -4
- package/dist/utils/json-schema.d.mts.map +1 -1
- package/dist/utils/json-schema.mjs +5 -78
- package/dist/utils/json-schema.mjs.map +1 -1
- package/dist/utils/random-id.cjs +13 -26
- package/dist/utils/random-id.cjs.map +1 -1
- package/dist/utils/random-id.d.cts +6 -3
- package/dist/utils/random-id.d.cts.map +1 -1
- package/dist/utils/random-id.d.mts +6 -3
- package/dist/utils/random-id.d.mts.map +1 -1
- package/dist/utils/random-id.mjs +14 -25
- package/dist/utils/random-id.mjs.map +1 -1
- package/package.json +10 -34
- package/scripts/verify-cjs-exports.cjs +1 -1
- package/src/__tests__/a2ui-envelope.test.ts +18 -13
- package/src/__tests__/a2ui-prompts.test.ts +47 -14
- package/src/__tests__/fixtures/prompt-goldens.json +354 -0
- package/src/__tests__/prompt-spec.test.ts +191 -0
- package/src/__tests__/root-entry-browser-safety.test.ts +5 -7
- package/src/__tests__/schema-render.test.ts +245 -0
- package/src/__tests__/standard-schema.test.ts +61 -101
- package/src/a2ui-envelope.ts +7 -6
- package/src/a2ui-prompts.ts +47 -96
- package/src/attachments/__tests__/utils.test.ts +22 -0
- package/src/attachments/types.ts +1 -3
- package/src/attachments/utils.ts +23 -5
- package/src/finalize-events.ts +16 -0
- package/src/generative-ui/__tests__/render-ui-args.test.ts +7 -7
- package/src/generative-ui/__tests__/validate-operation.test.ts +19 -13
- package/src/generative-ui/basic-functions.ts +1 -1
- package/src/generative-ui/child-refs.ts +5 -4
- package/src/generative-ui/compact-schema.ts +277 -0
- package/src/generative-ui/index.ts +3 -0
- package/src/generative-ui/prompt-spec.ts +335 -0
- package/src/generative-ui/prompt.ts +25 -75
- package/src/generative-ui/render-ui-args.ts +3 -0
- package/src/generative-ui/schema-render.ts +377 -0
- package/src/generative-ui/types.ts +10 -7
- package/src/generative-ui/validate-operation.ts +2 -2
- package/src/index.ts +3 -16
- package/src/standard-schema.ts +24 -27
- package/src/telemetry/lambda-client.ts +8 -3
- package/src/telemetry/model-host.test.ts +2 -5
- package/src/telemetry/telemetry-disabled.ts +0 -5
- package/src/types/message.ts +1 -19
- package/src/utils/__tests__/errors.test.ts +44 -0
- package/src/utils/__tests__/json-schema.test.ts +3 -479
- package/src/utils/__tests__/random-id.test.ts +37 -0
- package/src/utils/errors.ts +28 -85
- package/src/utils/index.ts +0 -2
- package/src/utils/inspector-visibility.test.ts +26 -0
- package/src/utils/inspector-visibility.ts +35 -3
- package/src/utils/json-schema.ts +5 -152
- package/src/utils/random-id.ts +17 -37
- package/tsconfig.json +3 -1
- package/tsdown.config.ts +2 -19
- package/dist/event-transforms/index.cjs +0 -15
- package/dist/event-transforms/index.d.cts +0 -4
- package/dist/event-transforms/index.d.mts +0 -4
- package/dist/event-transforms/index.mjs +0 -5
- package/dist/event-transforms/open-generative-ui-middleware.cjs +0 -286
- package/dist/event-transforms/open-generative-ui-middleware.cjs.map +0 -1
- package/dist/event-transforms/open-generative-ui-middleware.d.cts +0 -60
- package/dist/event-transforms/open-generative-ui-middleware.d.cts.map +0 -1
- package/dist/event-transforms/open-generative-ui-middleware.d.mts +0 -60
- package/dist/event-transforms/open-generative-ui-middleware.d.mts.map +0 -1
- package/dist/event-transforms/open-generative-ui-middleware.mjs +0 -283
- package/dist/event-transforms/open-generative-ui-middleware.mjs.map +0 -1
- package/dist/event-transforms/recorded-events.cjs +0 -59
- package/dist/event-transforms/recorded-events.cjs.map +0 -1
- package/dist/event-transforms/recorded-events.d.cts +0 -23
- package/dist/event-transforms/recorded-events.d.cts.map +0 -1
- package/dist/event-transforms/recorded-events.d.mts +0 -23
- package/dist/event-transforms/recorded-events.d.mts.map +0 -1
- package/dist/event-transforms/recorded-events.mjs +0 -58
- package/dist/event-transforms/recorded-events.mjs.map +0 -1
- package/dist/telemetry/events.d.cts +0 -72
- package/dist/telemetry/events.d.cts.map +0 -1
- package/dist/telemetry/events.d.mts +0 -72
- package/dist/telemetry/events.d.mts.map +0 -1
- package/dist/telemetry/index.cjs +0 -18
- package/dist/telemetry/index.d.cts +0 -5
- package/dist/telemetry/index.d.mts +0 -5
- package/dist/telemetry/index.mjs +0 -6
- package/dist/telemetry/telemetry-client.cjs +0 -165
- package/dist/telemetry/telemetry-client.cjs.map +0 -1
- package/dist/telemetry/telemetry-client.d.cts +0 -87
- package/dist/telemetry/telemetry-client.d.cts.map +0 -1
- package/dist/telemetry/telemetry-client.d.mts +0 -87
- package/dist/telemetry/telemetry-client.d.mts.map +0 -1
- package/dist/telemetry/telemetry-client.mjs +0 -164
- package/dist/telemetry/telemetry-client.mjs.map +0 -1
- package/dist/telemetry/utils.cjs +0 -14
- package/dist/telemetry/utils.cjs.map +0 -1
- package/dist/telemetry/utils.mjs +0 -13
- package/dist/telemetry/utils.mjs.map +0 -1
- package/dist/utils/conditions.cjs +0 -32
- package/dist/utils/conditions.cjs.map +0 -1
- package/dist/utils/conditions.d.cts +0 -31
- package/dist/utils/conditions.d.cts.map +0 -1
- package/dist/utils/conditions.d.mts +0 -31
- package/dist/utils/conditions.d.mts.map +0 -1
- package/dist/utils/conditions.mjs +0 -31
- package/dist/utils/conditions.mjs.map +0 -1
- package/dist/utils/console-styling.cjs +0 -91
- package/dist/utils/console-styling.cjs.map +0 -1
- package/dist/utils/console-styling.d.cts +0 -65
- package/dist/utils/console-styling.d.cts.map +0 -1
- package/dist/utils/console-styling.d.mts +0 -65
- package/dist/utils/console-styling.d.mts.map +0 -1
- package/dist/utils/console-styling.mjs +0 -85
- package/dist/utils/console-styling.mjs.map +0 -1
- package/src/__tests__/zod-regression.test.ts +0 -319
- package/src/event-transforms/index.ts +0 -5
- package/src/event-transforms/open-generative-ui-middleware.ts +0 -392
- package/src/event-transforms/recorded-events.test.ts +0 -166
- package/src/event-transforms/recorded-events.ts +0 -74
- package/src/telemetry/events.ts +0 -68
- package/src/telemetry/index.ts +0 -9
- package/src/telemetry/telemetry-blank-license-identity.test.ts +0 -128
- package/src/telemetry/telemetry-client.test.ts +0 -798
- package/src/telemetry/telemetry-client.ts +0 -328
- package/src/telemetry/utils.ts +0 -15
- package/src/utils/__tests__/conditions.test.ts +0 -161
- package/src/utils/conditions.ts +0 -116
- package/src/utils/console-styling.ts +0 -126
package/src/a2ui-prompts.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { isA2UIBasicFunction } from "./generative-ui/basic-functions";
|
|
2
2
|
import { A2UI_CHILD_LIST_REF } from "./generative-ui/child-refs";
|
|
3
|
-
import { GENERATIVE_UI_AGENT_FUNCTION_CALLS } from "./generative-ui/types";
|
|
4
3
|
import type { GenerativeUIManifest } from "./generative-ui/types";
|
|
4
|
+
import {
|
|
5
|
+
defaultGenerativeUIPromptSpec,
|
|
6
|
+
GUIDE_COMPONENTS,
|
|
7
|
+
generativeUIPromptFeatures,
|
|
8
|
+
selectPromptItems,
|
|
9
|
+
} from "./generative-ui/prompt-spec";
|
|
10
|
+
import type { GenerativeUIPromptSpec } from "./generative-ui/prompt-spec";
|
|
11
|
+
export {
|
|
12
|
+
GENERATIVE_UI_MARKDOWN_WHEN_TO_SHOW,
|
|
13
|
+
GENERATIVE_UI_WHEN_TO_SHOW,
|
|
14
|
+
} from "./generative-ui/prompt-spec";
|
|
5
15
|
/**
|
|
6
16
|
* Default A2UI generation and design guideline prompts.
|
|
7
17
|
*
|
|
@@ -118,14 +128,6 @@ Design principles:
|
|
|
118
128
|
|
|
119
129
|
Use the SAME surfaceId as the main surface. Match action names to button action event names.`;
|
|
120
130
|
|
|
121
|
-
/**
|
|
122
|
-
* When UI helps the user, for both transports: a light nudge to reach for UI
|
|
123
|
-
* where it conveys the answer better than prose, and to stay in prose
|
|
124
|
-
* otherwise.
|
|
125
|
-
*/
|
|
126
|
-
export const GENERATIVE_UI_WHEN_TO_SHOW =
|
|
127
|
-
"Show UI when it conveys the answer better than prose: to illustrate a concept (a diagram, a chart of how something changes), to compare options side by side, to let the user explore or adjust values, or to collect input. A small, focused surface next to your explanation often lands better than a long description. Reply in prose alone for a quick fact, a short answer, or conversation, and never add UI only as decoration.";
|
|
128
|
-
|
|
129
131
|
/** Description of the context entry that carries `GENERATIVE_UI_MARKDOWN_GUIDELINES`. */
|
|
130
132
|
export const GENERATIVE_UI_MARKDOWN_GUIDELINES_DESCRIPTION =
|
|
131
133
|
"Generative UI markdown guide: how to write UI surfaces inside ```a2ui code fences in a normal markdown reply.";
|
|
@@ -154,6 +156,11 @@ export interface GenerativeUIGuideFeatures {
|
|
|
154
156
|
templates: boolean;
|
|
155
157
|
/** A component has a "checks" prop: validation rules on inputs. */
|
|
156
158
|
checks: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* The component names of the catalog. A guide line that names a standard
|
|
161
|
+
* component missing from it is left out. Unset keeps every line.
|
|
162
|
+
*/
|
|
163
|
+
components?: readonly string[];
|
|
157
164
|
}
|
|
158
165
|
|
|
159
166
|
/** Every optional rule group. Use it when the manifest is not known. */
|
|
@@ -190,6 +197,7 @@ export function generativeUIGuideFeatures(
|
|
|
190
197
|
return Object.values(node).some(hasChildList);
|
|
191
198
|
};
|
|
192
199
|
return {
|
|
200
|
+
components: Object.keys(manifest.components),
|
|
193
201
|
// App functions only: the built-in ones are always there and have
|
|
194
202
|
// their own rules.
|
|
195
203
|
functions: Object.keys(manifest.functions).some(
|
|
@@ -212,44 +220,22 @@ export function generativeUIGuideFeatures(
|
|
|
212
220
|
};
|
|
213
221
|
}
|
|
214
222
|
|
|
215
|
-
/**
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
'Write a component as one flat object: {"id":"title","component":"<Name>","text":"Hello"}.',
|
|
232
|
-
'Put the component name in "component" (never "type"). Put props next to it, never inside a "props" object.',
|
|
233
|
-
'A component may take "accessibility":{"label":"<1 to 3 words>","description":"<what it does>"} for screen readers: on the component it describes, when nothing visible names it. Not on every component, and "live":"polite" only on text that changes by itself.',
|
|
234
|
-
'Use only the components, props, events, and slots in the schema. A component with "includesCommonProps" also takes every prop in "commonProps".',
|
|
235
|
-
'Give a prop a literal value, or bind it to the data model with {"@path":"/x"}. Never write {"path":"/x"} as a binding.',
|
|
236
|
-
'A prop can also be a function value that updates with the data: {"@call":"formatCurrency","args":{"value":{"@path":"/total"},"currency":"EUR"}}. Use only the functions under "functions" in the schema. Write a literal when the value never changes.',
|
|
237
|
-
'formatString interpolates ${...}: {"@call":"formatString","args":{"value":"${/qty} × ${formatCurrency(value: /price, currency: \'EUR\')}"}}. Inside ${...}, a path has no quotes, a string has single quotes, and a function takes named args.',
|
|
238
|
-
'${...} is evaluated only in the value of formatString and in the item of series; in other strings it stays literal text. Inside formatString, ${...} does not support operators. For arithmetic use calc, with the values as named args: {"@call":"calc","args":{"expression":"seats * 29 * (annual ? 0.8 : 1)","seats":{"@path":"/seats"},"annual":{"@path":"/annual"}}}. Inside formatString: ${formatCurrency(value: calc(expression: \'seats * 29\', seats: /seats), currency: \'USD\')}. The UI then follows the user\'s input with no round trip.',
|
|
239
|
-
'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.',
|
|
240
|
-
'Bind a writable prop to let the user edit it: "value":{"@path":"/form/email"}. The user\'s input goes to that path.',
|
|
241
|
-
'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".',
|
|
242
|
-
'Set "value":null to delete the key at "path".',
|
|
243
|
-
];
|
|
244
|
-
|
|
245
|
-
/** The last rules of every markdown guideline, after the optional groups. */
|
|
246
|
-
const MARKDOWN_CLOSING_RULES = [
|
|
247
|
-
'The schema lists the surfaces that already exist under "surfaces". "dataModel" holds the values that the user entered: read them, and do not write those paths. "rejected" lists operations that the client dropped: send corrected operations in a new fence for that surfaceId. "status":"deleted" means the surface is gone: never use its id again. "status":"failed" means its createSurface was rejected: send a corrected createSurface with that id.',
|
|
248
|
-
"Never make a surface that is only prose. Write headings, paragraphs, lists of text, intros, and summaries as markdown outside the fences, also between two fences.",
|
|
249
|
-
"Put in a fence only what markdown cannot show: charts, tables, maps, images, badges, inputs, buttons, cards with controls.",
|
|
250
|
-
"Use Card only for an interactive panel (controls, a form, a configurator). Put everything else in a plain layout component.",
|
|
251
|
-
"Never wrap the whole reply in a fence.",
|
|
252
|
-
];
|
|
223
|
+
/**
|
|
224
|
+
* Whether a guide line names only standard components (`GUIDE_COMPONENTS`,
|
|
225
|
+
* also in the plural) that the catalog has. With no catalog, every line fits.
|
|
226
|
+
*/
|
|
227
|
+
function namesOnlyCatalogComponents(catalog: readonly string[] | undefined) {
|
|
228
|
+
if (!catalog) return () => true;
|
|
229
|
+
const has = new Set(catalog);
|
|
230
|
+
return (line: string) =>
|
|
231
|
+
(line.match(/\b[A-Z][A-Za-z0-9]*\b/g) ?? []).every((word) => {
|
|
232
|
+
const name =
|
|
233
|
+
!GUIDE_COMPONENTS.has(word) && word.endsWith("s")
|
|
234
|
+
? word.slice(0, -1)
|
|
235
|
+
: word;
|
|
236
|
+
return !GUIDE_COMPONENTS.has(name) || has.has(name);
|
|
237
|
+
});
|
|
238
|
+
}
|
|
253
239
|
|
|
254
240
|
/**
|
|
255
241
|
* Builds the markdown-transport guideline. The model writes A2UI v1.0
|
|
@@ -258,60 +244,25 @@ const MARKDOWN_CLOSING_RULES = [
|
|
|
258
244
|
* none of them, so the guideline stays small.
|
|
259
245
|
*
|
|
260
246
|
* @param features - The optional rule groups to include. Defaults to all.
|
|
247
|
+
* @param spec - The wording. Defaults to the prompts that ship.
|
|
261
248
|
* @returns The guideline text, one rule per line.
|
|
262
249
|
*/
|
|
263
250
|
export function buildGenerativeUIMarkdownGuidelines(
|
|
264
251
|
features: GenerativeUIGuideFeatures = ALL_GENERATIVE_UI_GUIDE_FEATURES,
|
|
252
|
+
spec: GenerativeUIPromptSpec = defaultGenerativeUIPromptSpec(),
|
|
265
253
|
) {
|
|
266
|
-
const {
|
|
267
|
-
const
|
|
268
|
-
|
|
269
|
-
rules
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
279
|
-
if (checks) {
|
|
280
|
-
rules.push(
|
|
281
|
-
'Validate an input with "checks": [{"condition":{"@call":"email","args":{"value":{"@path":"/form/email"}}},"message":"Enter a valid email"}]. The check functions are required, regex, length, numeric and email; a condition can also be a boolean {"@path"}. A failed check shows the message under the input and disables a Button that has the same checks.',
|
|
282
|
-
);
|
|
283
|
-
}
|
|
284
|
-
rules.push(
|
|
285
|
-
'A prop typed componentId takes the id of another component, and a childList takes ids ["a","b"]: "child":"card", "children":["a","b"], "tabs":[{"title":"Specs","child":"specs"}].',
|
|
286
|
-
);
|
|
287
|
-
if (templates) {
|
|
288
|
-
rules.push(
|
|
289
|
-
'To repeat a component for each item of a list, give a childList a template: "children":{"componentId":"row","path":"/items"}.',
|
|
290
|
-
'Inside a template, paths are relative to the item ("name", not "/name").',
|
|
291
|
-
'Inside a template, {"@call":"@index"} gives the position of the item, from 0. To count from 1, write {"@call":"@index","args":{"offset":1}}.',
|
|
292
|
-
);
|
|
293
|
-
}
|
|
294
|
-
rules.push(
|
|
295
|
-
"Updating a component replaces all of its props. Send every prop again.",
|
|
296
|
-
"To change a surface in this reply, write another fence with the same surfaceId. Do not send createSurface again. The surface changes where it already is. A surface in a target can also be changed from a later reply; a chat surface cannot, because the chat is a transcript: a later reply with the same surfaceId makes a new surface.",
|
|
297
|
-
"Use a new surfaceId for a different view. Never use a surfaceId again, also after the surface is deleted.",
|
|
298
|
-
);
|
|
299
|
-
if (functions && GENERATIVE_UI_AGENT_FUNCTION_CALLS) {
|
|
300
|
-
rules.push(
|
|
301
|
-
'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.',
|
|
302
|
-
'Give every callRendererFunction a new functionCallId. Call only a function from the schema with "callers": "UI or agent" or "agent only"; a function without "callers" is for the UI only. A function with "callers": "agent only" is only for callRendererFunction: do not bind an event to it.',
|
|
303
|
-
'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.',
|
|
304
|
-
"Do not guess the result of a callRendererFunction. Wait for the developer message.",
|
|
305
|
-
);
|
|
306
|
-
}
|
|
307
|
-
rules.push(...MARKDOWN_CLOSING_RULES);
|
|
308
|
-
return `You can show interactive UI in your reply. Write A2UI operations inside a fenced code block tagged a2ui.
|
|
309
|
-
|
|
310
|
-
${GENERATIVE_UI_WHEN_TO_SHOW}
|
|
311
|
-
|
|
312
|
-
RULES
|
|
313
|
-
${rules.map((rule) => `- ${rule}`).join("\n")}
|
|
314
|
-
`;
|
|
254
|
+
const { intro, rules } = spec.markdown;
|
|
255
|
+
const fits = namesOnlyCatalogComponents(features.components);
|
|
256
|
+
const selected = selectPromptItems(
|
|
257
|
+
rules,
|
|
258
|
+
generativeUIPromptFeatures(features),
|
|
259
|
+
).filter(fits);
|
|
260
|
+
const whenToShow = spec.markdown.whenToShow
|
|
261
|
+
.split("\n")
|
|
262
|
+
.filter(fits)
|
|
263
|
+
.join("\n");
|
|
264
|
+
const when = whenToShow ? `${whenToShow}\n\n` : "";
|
|
265
|
+
return `${intro}\n\n${when}RULES\n${selected.map((rule) => `- ${rule}`).join("\n")}\n`;
|
|
315
266
|
}
|
|
316
267
|
|
|
317
268
|
/**
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
exceedsMaxSize,
|
|
5
5
|
matchesAcceptFilter,
|
|
6
6
|
getSourceUrl,
|
|
7
|
+
generateVideoThumbnail,
|
|
7
8
|
} from "../utils";
|
|
8
9
|
|
|
9
10
|
// ---------------------------------------------------------------------------
|
|
@@ -212,3 +213,24 @@ describe("getSourceUrl", () => {
|
|
|
212
213
|
expect(getSourceUrl({ type: "file", value: "file-abc123" })).toBe("");
|
|
213
214
|
});
|
|
214
215
|
});
|
|
216
|
+
|
|
217
|
+
// ---------------------------------------------------------------------------
|
|
218
|
+
// generateVideoThumbnail
|
|
219
|
+
// ---------------------------------------------------------------------------
|
|
220
|
+
|
|
221
|
+
describe("generateVideoThumbnail", () => {
|
|
222
|
+
afterEach(() => {
|
|
223
|
+
vi.unstubAllGlobals();
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
it("returns undefined for a file that is not a Blob, such as a React Native file", async () => {
|
|
227
|
+
vi.stubGlobal("document", { createElement: () => ({}) });
|
|
228
|
+
const nativeVideo = {
|
|
229
|
+
name: "clip.mp4",
|
|
230
|
+
size: 1,
|
|
231
|
+
type: "video/mp4",
|
|
232
|
+
} as unknown as File;
|
|
233
|
+
|
|
234
|
+
await expect(generateVideoThumbnail(nativeVideo)).resolves.toBeUndefined();
|
|
235
|
+
});
|
|
236
|
+
});
|
package/src/attachments/types.ts
CHANGED
|
@@ -49,9 +49,7 @@ export interface AttachmentsConfig {
|
|
|
49
49
|
* called concurrently unless you raise this. Files past the limit wait for a
|
|
50
50
|
* free slot; `Infinity` lifts it. The limit covers everything in flight, so
|
|
51
51
|
* two selections dropped or pasted at once share the slots rather than each
|
|
52
|
-
* taking the full number.
|
|
53
|
-
* Honored by the React `useAttachments` hook — the Vue and Angular bindings
|
|
54
|
-
* still upload serially.
|
|
52
|
+
* taking the full number. React, Vue and Angular all honor it.
|
|
55
53
|
*/
|
|
56
54
|
maxConcurrentUploads?: number;
|
|
57
55
|
/** Custom upload handler. Return an InputContentSource with optional metadata. */
|
package/src/attachments/utils.ts
CHANGED
|
@@ -54,19 +54,37 @@ export function readFileAsBase64(file: File): Promise<string> {
|
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* Generate a thumbnail data URL from a video file by capturing a frame near the start (at 0.1s).
|
|
57
|
-
* Returns undefined if thumbnail generation fails
|
|
57
|
+
* Returns undefined if thumbnail generation fails, if called outside a browser environment,
|
|
58
|
+
* or if `file` is not a `Blob` the browser can read (React Native for web passes a
|
|
59
|
+
* native file's description). Never rejects.
|
|
58
60
|
*/
|
|
59
61
|
export function generateVideoThumbnail(
|
|
60
62
|
file: File,
|
|
61
63
|
): Promise<string | undefined> {
|
|
62
|
-
if (
|
|
64
|
+
if (
|
|
65
|
+
typeof document === "undefined" ||
|
|
66
|
+
typeof Blob === "undefined" ||
|
|
67
|
+
!(file instanceof Blob)
|
|
68
|
+
) {
|
|
63
69
|
return Promise.resolve(undefined);
|
|
64
70
|
}
|
|
65
71
|
return new Promise((resolve) => {
|
|
66
72
|
let resolved = false;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
let url: string;
|
|
74
|
+
let video: HTMLVideoElement;
|
|
75
|
+
let canvas: HTMLCanvasElement;
|
|
76
|
+
try {
|
|
77
|
+
video = document.createElement("video");
|
|
78
|
+
canvas = document.createElement("canvas");
|
|
79
|
+
url = URL.createObjectURL(file);
|
|
80
|
+
} catch (error) {
|
|
81
|
+
console.warn(
|
|
82
|
+
`[CopilotKit] generateVideoThumbnail: could not read file "${file.name}"`,
|
|
83
|
+
error,
|
|
84
|
+
);
|
|
85
|
+
resolve(undefined);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
70
88
|
|
|
71
89
|
const cleanup = (result: string | undefined) => {
|
|
72
90
|
if (resolved) return;
|
package/src/finalize-events.ts
CHANGED
|
@@ -136,6 +136,22 @@ export function createRunEventFinalizer(): RunEventFinalizer {
|
|
|
136
136
|
terminalEventObserved = true;
|
|
137
137
|
clearOpen();
|
|
138
138
|
break;
|
|
139
|
+
case EventType.TEXT_MESSAGE_CONTENT:
|
|
140
|
+
case EventType.TEXT_MESSAGE_CHUNK:
|
|
141
|
+
case EventType.TOOL_CALL_ARGS:
|
|
142
|
+
case EventType.TOOL_CALL_CHUNK:
|
|
143
|
+
case EventType.STATE_SNAPSHOT:
|
|
144
|
+
case EventType.STATE_DELTA:
|
|
145
|
+
case EventType.MESSAGES_SNAPSHOT:
|
|
146
|
+
case EventType.ACTIVITY_SNAPSHOT:
|
|
147
|
+
case EventType.ACTIVITY_DELTA:
|
|
148
|
+
case EventType.RAW:
|
|
149
|
+
case EventType.CUSTOM:
|
|
150
|
+
case EventType.STEP_STARTED:
|
|
151
|
+
case EventType.STEP_FINISHED:
|
|
152
|
+
case EventType.REASONING_MESSAGE_CONTENT:
|
|
153
|
+
case EventType.REASONING_MESSAGE_CHUNK:
|
|
154
|
+
case EventType.REASONING_ENCRYPTED_VALUE:
|
|
139
155
|
default:
|
|
140
156
|
break;
|
|
141
157
|
}
|
|
@@ -2,11 +2,11 @@ import { describe, expect, it } from "vitest";
|
|
|
2
2
|
import { RenderUIArgsStream, extractRenderUIArgs } from "../render-ui-args";
|
|
3
3
|
|
|
4
4
|
const opA = {
|
|
5
|
-
version: "
|
|
5
|
+
version: "1.0",
|
|
6
6
|
createSurface: { surfaceId: "s" },
|
|
7
7
|
};
|
|
8
8
|
const opB = {
|
|
9
|
-
version: "
|
|
9
|
+
version: "1.0",
|
|
10
10
|
updateComponents: {
|
|
11
11
|
surfaceId: "s",
|
|
12
12
|
components: [
|
|
@@ -20,12 +20,12 @@ const opB = {
|
|
|
20
20
|
},
|
|
21
21
|
};
|
|
22
22
|
const opC = {
|
|
23
|
-
version: "
|
|
23
|
+
version: "1.0",
|
|
24
24
|
updateDataModel: { surfaceId: "s", path: "/a", value: [1, { b: "]" }] },
|
|
25
25
|
};
|
|
26
26
|
/** One createSurface with the data model and the root inline. */
|
|
27
27
|
const inlineCreate = {
|
|
28
|
-
version: "
|
|
28
|
+
version: "1.0",
|
|
29
29
|
createSurface: {
|
|
30
30
|
surfaceId: "plan",
|
|
31
31
|
dataModel: { seats: 10, plans: [{ name: "Team" }] },
|
|
@@ -40,7 +40,7 @@ const inlineCreate = {
|
|
|
40
40
|
},
|
|
41
41
|
};
|
|
42
42
|
const functionCall = {
|
|
43
|
-
version: "
|
|
43
|
+
version: "1.0",
|
|
44
44
|
callRendererFunction: {
|
|
45
45
|
functionCallId: "f1",
|
|
46
46
|
callFunction: { "@call": "addToCart", args: { productId: "p{1}" } },
|
|
@@ -75,7 +75,7 @@ describe("extractRenderUIArgs", () => {
|
|
|
75
75
|
|
|
76
76
|
it("returns null for a balanced element that is not valid JSON", () => {
|
|
77
77
|
const text =
|
|
78
|
-
'{"target":"chat","operations":[{"version":"
|
|
78
|
+
'{"target":"chat","operations":[{"version":"1.0", bad},' +
|
|
79
79
|
JSON.stringify(opA) +
|
|
80
80
|
"]}";
|
|
81
81
|
expect(extractRenderUIArgs(text).operations).toEqual([null, opA]);
|
|
@@ -140,7 +140,7 @@ describe("RenderUIArgsStream", () => {
|
|
|
140
140
|
|
|
141
141
|
it("keeps the parser state across deltas that split strings, escapes and braces", () => {
|
|
142
142
|
const tricky = {
|
|
143
|
-
version: "
|
|
143
|
+
version: "1.0",
|
|
144
144
|
updateDataModel: { surfaceId: "s", path: "/q", value: 'a "}{" \\ ]' },
|
|
145
145
|
};
|
|
146
146
|
const text = JSON.stringify({
|
|
@@ -62,19 +62,19 @@ const functions = {
|
|
|
62
62
|
const knownSurfaces = new Set(["s1"]);
|
|
63
63
|
|
|
64
64
|
const update = (...components: unknown[]) => ({
|
|
65
|
-
version: "
|
|
65
|
+
version: "1.0",
|
|
66
66
|
updateComponents: { surfaceId: "s1", components },
|
|
67
67
|
});
|
|
68
68
|
const setData = (fields: { path?: string; value?: unknown }) => ({
|
|
69
|
-
version: "
|
|
69
|
+
version: "1.0",
|
|
70
70
|
updateDataModel: { surfaceId: "s1", ...fields },
|
|
71
71
|
});
|
|
72
72
|
const create = (fields: Record<string, unknown>) => ({
|
|
73
|
-
version: "
|
|
73
|
+
version: "1.0",
|
|
74
74
|
createSurface: { surfaceId: "s2", ...fields },
|
|
75
75
|
});
|
|
76
76
|
const callFunction = (fields: Record<string, unknown>) => ({
|
|
77
|
-
version: "
|
|
77
|
+
version: "1.0",
|
|
78
78
|
callRendererFunction: { functionCallId: "f1", ...fields },
|
|
79
79
|
});
|
|
80
80
|
/** A valid ProductCard with `props` added or replaced. */
|
|
@@ -90,23 +90,29 @@ const reasonOf = (
|
|
|
90
90
|
};
|
|
91
91
|
|
|
92
92
|
describe("validateOperation: version and kind", () => {
|
|
93
|
-
it("rejects
|
|
93
|
+
it("rejects the pre-release v1.0 spelling", () => {
|
|
94
|
+
expect(
|
|
95
|
+
reasonOf({ version: "v1.0", deleteSurface: { surfaceId: "s1" } }),
|
|
96
|
+
).toBe('unsupported version "v1.0"; use "1.0"');
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("rejects a v0.9 operation with a reason that names 1.0", () => {
|
|
94
100
|
expect(
|
|
95
101
|
reasonOf({ version: "v0.9", deleteSurface: { surfaceId: "s1" } }),
|
|
96
|
-
).toBe('unsupported version "v0.9"; use "
|
|
102
|
+
).toBe('unsupported version "v0.9"; use "1.0"');
|
|
97
103
|
});
|
|
98
104
|
|
|
99
105
|
it("rejects an operation without a version", () => {
|
|
100
106
|
expect(reasonOf({ deleteSurface: { surfaceId: "s1" } })).toBe(
|
|
101
|
-
'operation needs "version":"
|
|
107
|
+
'operation needs "version":"1.0"',
|
|
102
108
|
);
|
|
103
109
|
});
|
|
104
110
|
|
|
105
111
|
it("rejects ops with zero or several kinds", () => {
|
|
106
|
-
expect(reasonOf({ version: "
|
|
112
|
+
expect(reasonOf({ version: "1.0" })).toMatch(/exactly one/);
|
|
107
113
|
expect(
|
|
108
114
|
reasonOf({
|
|
109
|
-
version: "
|
|
115
|
+
version: "1.0",
|
|
110
116
|
deleteSurface: { surfaceId: "s1" },
|
|
111
117
|
updateDataModel: { surfaceId: "s1", value: 1 },
|
|
112
118
|
}),
|
|
@@ -133,7 +139,7 @@ describe("validateOperation: createSurface", () => {
|
|
|
133
139
|
};
|
|
134
140
|
const check = (catalogId: string) =>
|
|
135
141
|
validateOperation(
|
|
136
|
-
{ version: "
|
|
142
|
+
{ version: "1.0", createSurface: { surfaceId: "s2", catalogId } },
|
|
137
143
|
options,
|
|
138
144
|
);
|
|
139
145
|
expect(check("copilotkit/standard@1")).toEqual({ ok: true });
|
|
@@ -146,13 +152,13 @@ describe("validateOperation: createSurface", () => {
|
|
|
146
152
|
|
|
147
153
|
it("rejects a createSurface without a surfaceId", () => {
|
|
148
154
|
expect(
|
|
149
|
-
reasonOf({ version: "
|
|
155
|
+
reasonOf({ version: "1.0", createSurface: { catalogId: "shop" } }),
|
|
150
156
|
).toBe("createSurface.surfaceId is required");
|
|
151
157
|
});
|
|
152
158
|
|
|
153
159
|
it("rejects an existing surface", () => {
|
|
154
160
|
expect(
|
|
155
|
-
reasonOf({ version: "
|
|
161
|
+
reasonOf({ version: "1.0", createSurface: { surfaceId: "s1" } }),
|
|
156
162
|
).toBe('surface "s1" already exists');
|
|
157
163
|
});
|
|
158
164
|
|
|
@@ -201,7 +207,7 @@ describe("validateOperation: surface updates", () => {
|
|
|
201
207
|
it("rejects updates to surfaces that do not exist", () => {
|
|
202
208
|
expect(
|
|
203
209
|
reasonOf({
|
|
204
|
-
version: "
|
|
210
|
+
version: "1.0",
|
|
205
211
|
updateComponents: {
|
|
206
212
|
surfaceId: "missing",
|
|
207
213
|
components: [{ id: "root", component: "ProductGrid" }],
|
|
@@ -189,7 +189,7 @@ export const COPILOTKIT_FUNCTIONS: Readonly<
|
|
|
189
189
|
> = rendererOnly({
|
|
190
190
|
calc: {
|
|
191
191
|
description:
|
|
192
|
-
"The value of an arithmetic expression over the other args, by name: + - * / % ( ), comparisons, && || !, cond ? a : b, min max round floor ceil abs, 'text' + name",
|
|
192
|
+
"The value of an arithmetic expression over the other args, by name: + - * / % ( ), x ^ y (power), comparisons, && || !, cond ? a : b, min max round floor ceil abs pow sqrt exp ln log10, the constants pi and e, 'text' + name",
|
|
193
193
|
parameters:
|
|
194
194
|
"{ expression: string; [name: string]: number | string | boolean }",
|
|
195
195
|
returnType: "any",
|
|
@@ -107,7 +107,8 @@ export function collectChildRefs(schema: GenerativeUIJSONSchema): ChildRef[] {
|
|
|
107
107
|
);
|
|
108
108
|
const key = (ref: ChildRef) =>
|
|
109
109
|
`${ref.kind}\u0000${ref.path.join("\u0000")}`;
|
|
110
|
-
|
|
110
|
+
// `list` is not empty (checked above), so `perVariant` is not empty.
|
|
111
|
+
const shared = perVariant[0]!.filter((ref) =>
|
|
111
112
|
perVariant.every((refs) => refs.some((r) => key(r) === key(ref))),
|
|
112
113
|
);
|
|
113
114
|
shared.forEach((ref) => add([...path, ...ref.path], ref.kind));
|
|
@@ -146,8 +147,8 @@ export function childIdsAtRefs(
|
|
|
146
147
|
}
|
|
147
148
|
};
|
|
148
149
|
const visit = (value: unknown, path: readonly string[]) => {
|
|
149
|
-
if (path.length === 0) return collect(value);
|
|
150
150
|
const [head, ...rest] = path;
|
|
151
|
+
if (head === undefined) return collect(value);
|
|
151
152
|
if (head === "*") {
|
|
152
153
|
if (Array.isArray(value)) value.forEach((item) => visit(item, rest));
|
|
153
154
|
return;
|
|
@@ -173,8 +174,8 @@ export function hasBoundChildRef(
|
|
|
173
174
|
isRecord(value) && ("@path" in value || "@call" in value);
|
|
174
175
|
const visit = (value: unknown, path: readonly string[]): boolean => {
|
|
175
176
|
if (isDynamic(value)) return true;
|
|
176
|
-
if (path.length === 0) return false;
|
|
177
177
|
const [head, ...rest] = path;
|
|
178
|
+
if (head === undefined) return false;
|
|
178
179
|
if (head === "*") {
|
|
179
180
|
return Array.isArray(value) && value.some((item) => visit(item, rest));
|
|
180
181
|
}
|
|
@@ -197,8 +198,8 @@ export function mapAtChildRef(
|
|
|
197
198
|
path: readonly string[],
|
|
198
199
|
replace: (found: unknown) => unknown,
|
|
199
200
|
): unknown {
|
|
200
|
-
if (path.length === 0) return replace(value);
|
|
201
201
|
const [head, ...rest] = path;
|
|
202
|
+
if (head === undefined) return replace(value);
|
|
202
203
|
if (head === "*") {
|
|
203
204
|
if (!Array.isArray(value)) return value;
|
|
204
205
|
return value.map((item) => mapAtChildRef(item, rest, replace));
|