@copilotkit/shared 2.0.0-rc.2 → 2.0.0-rc.20
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/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 +17 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -9
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +10 -9
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +9 -7
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +839 -447
- 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 +3 -6
- 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 +4 -6
- 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 +1 -2
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +4 -5
- package/dist/utils/index.d.cts.map +1 -1
- package/dist/utils/index.d.mts +4 -5
- package/dist/utils/index.d.mts.map +1 -1
- package/dist/utils/index.mjs +4 -5
- package/dist/utils/index.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/process-env.cjs +14 -0
- package/dist/utils/process-env.cjs.map +1 -0
- package/dist/utils/process-env.d.cts +10 -0
- package/dist/utils/process-env.d.cts.map +1 -0
- package/dist/utils/process-env.d.mts +10 -0
- package/dist/utils/process-env.d.mts.map +1 -0
- package/dist/utils/process-env.mjs +13 -0
- package/dist/utils/process-env.mjs.map +1 -0
- 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 +8 -32
- 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/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 +7 -12
- 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__/process-env.test.ts +22 -0
- package/src/utils/__tests__/random-id.test.ts +37 -0
- package/src/utils/errors.ts +28 -85
- package/src/utils/index.ts +1 -2
- package/src/utils/json-schema.ts +5 -152
- package/src/utils/process-env.ts +14 -0
- 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/dist/utils/random-id.cjs
CHANGED
|
@@ -1,38 +1,25 @@
|
|
|
1
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
|
-
let uuid = require("uuid");
|
|
3
1
|
|
|
4
2
|
//#region src/utils/random-id.ts
|
|
5
3
|
function randomId() {
|
|
6
|
-
return "ck-" + (
|
|
7
|
-
}
|
|
8
|
-
function randomUUID() {
|
|
9
|
-
return (0, uuid.v4)();
|
|
4
|
+
return "ck-" + randomUUID();
|
|
10
5
|
}
|
|
11
6
|
/**
|
|
12
|
-
*
|
|
7
|
+
* Returns an RFC 4122 version 4 UUID. Uses `crypto.randomUUID()` when it
|
|
8
|
+
* exists, and builds the UUID from `crypto.getRandomValues()` when it does not
|
|
9
|
+
* (React Native's Hermes has no `randomUUID`).
|
|
13
10
|
*/
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return
|
|
23
|
-
}
|
|
24
|
-
function dataToUUID(input, namespace) {
|
|
25
|
-
const BASE_NAMESPACE = "e4b01160-ff74-4c6e-9b27-d53cd930fe8e";
|
|
26
|
-
const boundNamespace = namespace ? (0, uuid.v5)(namespace, BASE_NAMESPACE) : BASE_NAMESPACE;
|
|
27
|
-
return (0, uuid.v5)(typeof input === "string" ? input : JSON.stringify(toSerializable(input)), boundNamespace);
|
|
28
|
-
}
|
|
29
|
-
function isValidUUID(uuid$1) {
|
|
30
|
-
return (0, uuid.validate)(uuid$1);
|
|
11
|
+
function randomUUID() {
|
|
12
|
+
const crypto = globalThis.crypto;
|
|
13
|
+
if (typeof crypto?.randomUUID === "function") return crypto.randomUUID();
|
|
14
|
+
if (typeof crypto?.getRandomValues !== "function") throw new Error("crypto.getRandomValues() is not available. In React Native, install a polyfill such as react-native-get-random-values.");
|
|
15
|
+
const bytes = crypto.getRandomValues(new Uint8Array(16));
|
|
16
|
+
bytes[6] = bytes[6] & 15 | 64;
|
|
17
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
18
|
+
const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0"));
|
|
19
|
+
return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(6, 8).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
|
|
31
20
|
}
|
|
32
21
|
|
|
33
22
|
//#endregion
|
|
34
|
-
exports.dataToUUID = dataToUUID;
|
|
35
|
-
exports.isValidUUID = isValidUUID;
|
|
36
23
|
exports.randomId = randomId;
|
|
37
24
|
exports.randomUUID = randomUUID;
|
|
38
25
|
//# sourceMappingURL=random-id.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random-id.cjs","names":[
|
|
1
|
+
{"version":3,"file":"random-id.cjs","names":[],"sources":["../../src/utils/random-id.ts"],"sourcesContent":["export function randomId() {\n return \"ck-\" + randomUUID();\n}\n\n/**\n * Returns an RFC 4122 version 4 UUID. Uses `crypto.randomUUID()` when it\n * exists, and builds the UUID from `crypto.getRandomValues()` when it does not\n * (React Native's Hermes has no `randomUUID`).\n */\nexport function randomUUID(): string {\n const crypto = globalThis.crypto;\n if (typeof crypto?.randomUUID === \"function\") {\n return crypto.randomUUID();\n }\n if (typeof crypto?.getRandomValues !== \"function\") {\n throw new Error(\n \"crypto.getRandomValues() is not available. In React Native, install a polyfill such as react-native-get-random-values.\",\n );\n }\n const bytes = crypto.getRandomValues(new Uint8Array(16));\n bytes[6] = (bytes[6]! & 0x0f) | 0x40;\n bytes[8] = (bytes[8]! & 0x3f) | 0x80;\n const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, \"0\"));\n return `${hex.slice(0, 4).join(\"\")}-${hex.slice(4, 6).join(\"\")}-${hex.slice(6, 8).join(\"\")}-${hex.slice(8, 10).join(\"\")}-${hex.slice(10).join(\"\")}`;\n}\n"],"mappings":";;AAAA,SAAgB,WAAW;AACzB,QAAO,QAAQ,YAAY;;;;;;;AAQ7B,SAAgB,aAAqB;CACnC,MAAM,SAAS,WAAW;AAC1B,KAAI,OAAO,QAAQ,eAAe,WAChC,QAAO,OAAO,YAAY;AAE5B,KAAI,OAAO,QAAQ,oBAAoB,WACrC,OAAM,IAAI,MACR,yHACD;CAEH,MAAM,QAAQ,OAAO,gBAAgB,IAAI,WAAW,GAAG,CAAC;AACxD,OAAM,KAAM,MAAM,KAAM,KAAQ;AAChC,OAAM,KAAM,MAAM,KAAM,KAAQ;CAChC,MAAM,MAAM,MAAM,KAAK,QAAQ,SAAS,KAAK,SAAS,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC;AAC3E,QAAO,GAAG,IAAI,MAAM,GAAG,EAAE,CAAC,KAAK,GAAG,CAAC,GAAG,IAAI,MAAM,GAAG,EAAE,CAAC,KAAK,GAAG,CAAC,GAAG,IAAI,MAAM,GAAG,EAAE,CAAC,KAAK,GAAG,CAAC,GAAG,IAAI,MAAM,GAAG,GAAG,CAAC,KAAK,GAAG,CAAC,GAAG,IAAI,MAAM,GAAG,CAAC,KAAK,GAAG"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
//#region src/utils/random-id.d.ts
|
|
2
2
|
declare function randomId(): string;
|
|
3
|
+
/**
|
|
4
|
+
* Returns an RFC 4122 version 4 UUID. Uses `crypto.randomUUID()` when it
|
|
5
|
+
* exists, and builds the UUID from `crypto.getRandomValues()` when it does not
|
|
6
|
+
* (React Native's Hermes has no `randomUUID`).
|
|
7
|
+
*/
|
|
3
8
|
declare function randomUUID(): string;
|
|
4
|
-
declare function dataToUUID(input: string | object, namespace?: string): string;
|
|
5
|
-
declare function isValidUUID(uuid: string): boolean;
|
|
6
9
|
//#endregion
|
|
7
|
-
export {
|
|
10
|
+
export { randomId, randomUUID };
|
|
8
11
|
//# sourceMappingURL=random-id.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random-id.d.cts","names":[],"sources":["../../src/utils/random-id.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"random-id.d.cts","names":[],"sources":["../../src/utils/random-id.ts"],"mappings":";iBAAgB,QAAA,CAAA;AAAhB;;;;;AAAA,iBASgB,UAAA,CAAA"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
//#region src/utils/random-id.d.ts
|
|
2
2
|
declare function randomId(): string;
|
|
3
|
+
/**
|
|
4
|
+
* Returns an RFC 4122 version 4 UUID. Uses `crypto.randomUUID()` when it
|
|
5
|
+
* exists, and builds the UUID from `crypto.getRandomValues()` when it does not
|
|
6
|
+
* (React Native's Hermes has no `randomUUID`).
|
|
7
|
+
*/
|
|
3
8
|
declare function randomUUID(): string;
|
|
4
|
-
declare function dataToUUID(input: string | object, namespace?: string): string;
|
|
5
|
-
declare function isValidUUID(uuid: string): boolean;
|
|
6
9
|
//#endregion
|
|
7
|
-
export {
|
|
10
|
+
export { randomId, randomUUID };
|
|
8
11
|
//# sourceMappingURL=random-id.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random-id.d.mts","names":[],"sources":["../../src/utils/random-id.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"random-id.d.mts","names":[],"sources":["../../src/utils/random-id.ts"],"mappings":";iBAAgB,QAAA,CAAA;AAAhB;;;;;AAAA,iBASgB,UAAA,CAAA"}
|
package/dist/utils/random-id.mjs
CHANGED
|
@@ -1,34 +1,23 @@
|
|
|
1
|
-
import { v4, v5, validate } from "uuid";
|
|
2
|
-
|
|
3
1
|
//#region src/utils/random-id.ts
|
|
4
2
|
function randomId() {
|
|
5
|
-
return "ck-" +
|
|
6
|
-
}
|
|
7
|
-
function randomUUID() {
|
|
8
|
-
return v4();
|
|
3
|
+
return "ck-" + randomUUID();
|
|
9
4
|
}
|
|
10
5
|
/**
|
|
11
|
-
*
|
|
6
|
+
* Returns an RFC 4122 version 4 UUID. Uses `crypto.randomUUID()` when it
|
|
7
|
+
* exists, and builds the UUID from `crypto.getRandomValues()` when it does not
|
|
8
|
+
* (React Native's Hermes has no `randomUUID`).
|
|
12
9
|
*/
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
if (
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return
|
|
22
|
-
}
|
|
23
|
-
function dataToUUID(input, namespace) {
|
|
24
|
-
const BASE_NAMESPACE = "e4b01160-ff74-4c6e-9b27-d53cd930fe8e";
|
|
25
|
-
const boundNamespace = namespace ? v5(namespace, BASE_NAMESPACE) : BASE_NAMESPACE;
|
|
26
|
-
return v5(typeof input === "string" ? input : JSON.stringify(toSerializable(input)), boundNamespace);
|
|
27
|
-
}
|
|
28
|
-
function isValidUUID(uuid) {
|
|
29
|
-
return validate(uuid);
|
|
10
|
+
function randomUUID() {
|
|
11
|
+
const crypto = globalThis.crypto;
|
|
12
|
+
if (typeof crypto?.randomUUID === "function") return crypto.randomUUID();
|
|
13
|
+
if (typeof crypto?.getRandomValues !== "function") throw new Error("crypto.getRandomValues() is not available. In React Native, install a polyfill such as react-native-get-random-values.");
|
|
14
|
+
const bytes = crypto.getRandomValues(new Uint8Array(16));
|
|
15
|
+
bytes[6] = bytes[6] & 15 | 64;
|
|
16
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
17
|
+
const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0"));
|
|
18
|
+
return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(6, 8).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
|
|
30
19
|
}
|
|
31
20
|
|
|
32
21
|
//#endregion
|
|
33
|
-
export {
|
|
22
|
+
export { randomId, randomUUID };
|
|
34
23
|
//# sourceMappingURL=random-id.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random-id.mjs","names":[
|
|
1
|
+
{"version":3,"file":"random-id.mjs","names":[],"sources":["../../src/utils/random-id.ts"],"sourcesContent":["export function randomId() {\n return \"ck-\" + randomUUID();\n}\n\n/**\n * Returns an RFC 4122 version 4 UUID. Uses `crypto.randomUUID()` when it\n * exists, and builds the UUID from `crypto.getRandomValues()` when it does not\n * (React Native's Hermes has no `randomUUID`).\n */\nexport function randomUUID(): string {\n const crypto = globalThis.crypto;\n if (typeof crypto?.randomUUID === \"function\") {\n return crypto.randomUUID();\n }\n if (typeof crypto?.getRandomValues !== \"function\") {\n throw new Error(\n \"crypto.getRandomValues() is not available. In React Native, install a polyfill such as react-native-get-random-values.\",\n );\n }\n const bytes = crypto.getRandomValues(new Uint8Array(16));\n bytes[6] = (bytes[6]! & 0x0f) | 0x40;\n bytes[8] = (bytes[8]! & 0x3f) | 0x80;\n const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, \"0\"));\n return `${hex.slice(0, 4).join(\"\")}-${hex.slice(4, 6).join(\"\")}-${hex.slice(6, 8).join(\"\")}-${hex.slice(8, 10).join(\"\")}-${hex.slice(10).join(\"\")}`;\n}\n"],"mappings":";AAAA,SAAgB,WAAW;AACzB,QAAO,QAAQ,YAAY;;;;;;;AAQ7B,SAAgB,aAAqB;CACnC,MAAM,SAAS,WAAW;AAC1B,KAAI,OAAO,QAAQ,eAAe,WAChC,QAAO,OAAO,YAAY;AAE5B,KAAI,OAAO,QAAQ,oBAAoB,WACrC,OAAM,IAAI,MACR,yHACD;CAEH,MAAM,QAAQ,OAAO,gBAAgB,IAAI,WAAW,GAAG,CAAC;AACxD,OAAM,KAAM,MAAM,KAAM,KAAQ;AAChC,OAAM,KAAM,MAAM,KAAM,KAAQ;CAChC,MAAM,MAAM,MAAM,KAAK,QAAQ,SAAS,KAAK,SAAS,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC;AAC3E,QAAO,GAAG,IAAI,MAAM,GAAG,EAAE,CAAC,KAAK,GAAG,CAAC,GAAG,IAAI,MAAM,GAAG,EAAE,CAAC,KAAK,GAAG,CAAC,GAAG,IAAI,MAAM,GAAG,EAAE,CAAC,KAAK,GAAG,CAAC,GAAG,IAAI,MAAM,GAAG,GAAG,CAAC,KAAK,GAAG,CAAC,GAAG,IAAI,MAAM,GAAG,CAAC,KAAK,GAAG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@copilotkit/shared",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.20",
|
|
4
4
|
"private": false,
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
],
|
|
17
17
|
"homepage": "https://github.com/CopilotKit/CopilotKit",
|
|
18
18
|
"license": "MIT",
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=20"
|
|
21
|
+
},
|
|
19
22
|
"repository": {
|
|
20
23
|
"type": "git",
|
|
21
24
|
"url": "https://github.com/CopilotKit/CopilotKit.git"
|
|
@@ -32,47 +35,19 @@
|
|
|
32
35
|
"import": "./dist/index.mjs",
|
|
33
36
|
"require": "./dist/index.cjs"
|
|
34
37
|
},
|
|
35
|
-
"./event-transforms": {
|
|
36
|
-
"import": "./dist/event-transforms/index.mjs",
|
|
37
|
-
"require": "./dist/event-transforms/index.cjs"
|
|
38
|
-
},
|
|
39
|
-
"./telemetry": {
|
|
40
|
-
"import": "./dist/telemetry/index.mjs",
|
|
41
|
-
"require": "./dist/telemetry/index.cjs"
|
|
42
|
-
},
|
|
43
38
|
"./package.json": "./package.json"
|
|
44
39
|
},
|
|
45
|
-
"typesVersions": {
|
|
46
|
-
"*": {
|
|
47
|
-
"telemetry": [
|
|
48
|
-
"./dist/telemetry/index.d.cts"
|
|
49
|
-
],
|
|
50
|
-
"event-transforms": [
|
|
51
|
-
"./dist/event-transforms/index.d.cts"
|
|
52
|
-
]
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
40
|
"publishConfig": {
|
|
56
41
|
"access": "public"
|
|
57
42
|
},
|
|
58
43
|
"dependencies": {
|
|
59
|
-
"@ag-ui/a2ui-middleware": "0.0.10",
|
|
60
44
|
"@ag-ui/client": "1.0.2",
|
|
61
45
|
"@copilotkit/license-verifier": "~0.5.0",
|
|
62
|
-
"@segment/analytics-node": "^2.1.2",
|
|
63
46
|
"@standard-schema/spec": "^1.0.0",
|
|
64
|
-
"
|
|
65
|
-
"graphql": "^16.8.1",
|
|
66
|
-
"partial-json": "^0.1.7",
|
|
67
|
-
"rxjs": "7.8.1",
|
|
68
|
-
"uuid": "^11.1.0",
|
|
69
|
-
"zod": "^3.23.3",
|
|
70
|
-
"zod-to-json-schema": "^3.23.5"
|
|
47
|
+
"partial-json": "^0.1.7"
|
|
71
48
|
},
|
|
72
49
|
"devDependencies": {
|
|
73
50
|
"@ag-ui/core": "1.0.2",
|
|
74
|
-
"@types/clarinet": "^0.12.3",
|
|
75
|
-
"@types/uuid": "^10.0.0",
|
|
76
51
|
"@valibot/to-json-schema": "^1.5.0",
|
|
77
52
|
"arktype": "^2.1.29",
|
|
78
53
|
"eslint": "^8.56.0",
|
|
@@ -80,10 +55,11 @@
|
|
|
80
55
|
"typescript": "^5.2.3",
|
|
81
56
|
"valibot": "^1.2.0",
|
|
82
57
|
"vitest": "^3.2.4",
|
|
83
|
-
"
|
|
58
|
+
"zod": "^4.2.0",
|
|
59
|
+
"@copilotkit/typescript-config": "1.55.0-next.8"
|
|
84
60
|
},
|
|
85
61
|
"peerDependencies": {
|
|
86
|
-
"@ag-ui/core": "
|
|
62
|
+
"@ag-ui/core": "^1.0.2"
|
|
87
63
|
},
|
|
88
64
|
"scripts": {
|
|
89
65
|
"build": "tsdown",
|
|
@@ -3,7 +3,7 @@ import { envelopeToManifest, readCopilotKitUIEnvelope } from "../a2ui-envelope";
|
|
|
3
3
|
import type { CopilotKitUIEnvelope } from "../a2ui-envelope";
|
|
4
4
|
|
|
5
5
|
type InlineCatalog = NonNullable<
|
|
6
|
-
CopilotKitUIEnvelope["
|
|
6
|
+
CopilotKitUIEnvelope["1.0"]["inlineCatalogs"]
|
|
7
7
|
>[number];
|
|
8
8
|
type Extensions = CopilotKitUIEnvelope["metadata"]["extensions"];
|
|
9
9
|
|
|
@@ -52,7 +52,7 @@ function createEnvelope(options?: {
|
|
|
52
52
|
extensions?: Partial<Extensions>;
|
|
53
53
|
}): CopilotKitUIEnvelope {
|
|
54
54
|
return {
|
|
55
|
-
"
|
|
55
|
+
"1.0": {
|
|
56
56
|
supportedCatalogIds: ["acme/app@1"],
|
|
57
57
|
inlineCatalogs: [createCatalog(options?.catalog)],
|
|
58
58
|
},
|
|
@@ -78,8 +78,8 @@ const withCatalogField = (key: string, value: unknown) => {
|
|
|
78
78
|
const envelope = createEnvelope();
|
|
79
79
|
return {
|
|
80
80
|
...envelope,
|
|
81
|
-
"
|
|
82
|
-
...envelope["
|
|
81
|
+
"1.0": {
|
|
82
|
+
...envelope["1.0"],
|
|
83
83
|
inlineCatalogs: [{ ...createCatalog(), [key]: value }],
|
|
84
84
|
},
|
|
85
85
|
};
|
|
@@ -88,7 +88,7 @@ const withCatalogField = (key: string, value: unknown) => {
|
|
|
88
88
|
/** An envelope with one key of the capabilities replaced by any value. */
|
|
89
89
|
const withCapability = (key: string, value: unknown) => {
|
|
90
90
|
const envelope = createEnvelope();
|
|
91
|
-
return { ...envelope, "
|
|
91
|
+
return { ...envelope, "1.0": { ...envelope["1.0"], [key]: value } };
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
/** An envelope with one CopilotKit extension replaced by any value. */
|
|
@@ -103,6 +103,11 @@ const withExtension = (key: string, value: unknown) => {
|
|
|
103
103
|
};
|
|
104
104
|
|
|
105
105
|
describe("readCopilotKitUIEnvelope", () => {
|
|
106
|
+
it("does not read the pre-release v1.0 capability key", () => {
|
|
107
|
+
const { "1.0": capabilities, ...rest } = createEnvelope();
|
|
108
|
+
expect(readUI({ ...rest, "v1.0": capabilities })).toBeUndefined();
|
|
109
|
+
});
|
|
110
|
+
|
|
106
111
|
it("reads a markdown envelope from forwardedProps.copilotkit.ui", () => {
|
|
107
112
|
const envelope = createEnvelope();
|
|
108
113
|
expect(readUI(envelope)).toEqual(envelope);
|
|
@@ -110,7 +115,7 @@ describe("readCopilotKitUIEnvelope", () => {
|
|
|
110
115
|
|
|
111
116
|
it("reads a tool envelope without instructions and without components", () => {
|
|
112
117
|
const envelope: CopilotKitUIEnvelope = {
|
|
113
|
-
"
|
|
118
|
+
"1.0": {
|
|
114
119
|
supportedCatalogIds: ["acme/app@1"],
|
|
115
120
|
inlineCatalogs: [
|
|
116
121
|
{ catalogId: "acme/app@1", protocolVersion: "1.0", functions: {} },
|
|
@@ -132,7 +137,7 @@ describe("readCopilotKitUIEnvelope", () => {
|
|
|
132
137
|
it("reads an envelope without inline catalogs", () => {
|
|
133
138
|
const envelope: CopilotKitUIEnvelope = {
|
|
134
139
|
...createEnvelope(),
|
|
135
|
-
"
|
|
140
|
+
"1.0": { supportedCatalogIds: ["acme/app@1"] },
|
|
136
141
|
};
|
|
137
142
|
expect(readUI(envelope)).toEqual(envelope);
|
|
138
143
|
});
|
|
@@ -201,7 +206,7 @@ describe("readCopilotKitUIEnvelope", () => {
|
|
|
201
206
|
],
|
|
202
207
|
["format 2 in the extensions", withExtension("copilotkit_format", 2)],
|
|
203
208
|
["an unknown transport", withExtension("copilotkit_transport", "fence")],
|
|
204
|
-
["no capabilities", { ...createEnvelope(), "
|
|
209
|
+
["no capabilities", { ...createEnvelope(), "1.0": undefined }],
|
|
205
210
|
["no metadata", { ...createEnvelope(), metadata: undefined }],
|
|
206
211
|
["no extensions", { ...createEnvelope(), metadata: {} }],
|
|
207
212
|
["no catalog id", withCapability("supportedCatalogIds", [])],
|
|
@@ -333,7 +338,7 @@ describe("envelopeToManifest", () => {
|
|
|
333
338
|
|
|
334
339
|
it("gives the action of the user event that started the run", () => {
|
|
335
340
|
const action = {
|
|
336
|
-
version: "
|
|
341
|
+
version: "1.0" as const,
|
|
337
342
|
action: {
|
|
338
343
|
name: "buy",
|
|
339
344
|
surfaceId: "s1",
|
|
@@ -371,7 +376,7 @@ describe("envelopeToManifest", () => {
|
|
|
371
376
|
it("lists every supported catalog id, the first one as the catalog of the run", () => {
|
|
372
377
|
const envelope: CopilotKitUIEnvelope = {
|
|
373
378
|
...createEnvelope(),
|
|
374
|
-
"
|
|
379
|
+
"1.0": {
|
|
375
380
|
supportedCatalogIds: ["acme/app@1", "copilotkit/standard@1"],
|
|
376
381
|
inlineCatalogs: [createCatalog()],
|
|
377
382
|
},
|
|
@@ -386,7 +391,7 @@ describe("envelopeToManifest", () => {
|
|
|
386
391
|
it("uses only the inline catalog of the first supported catalog id", () => {
|
|
387
392
|
const envelope: CopilotKitUIEnvelope = {
|
|
388
393
|
...createEnvelope(),
|
|
389
|
-
"
|
|
394
|
+
"1.0": {
|
|
390
395
|
supportedCatalogIds: ["acme/app@1"],
|
|
391
396
|
inlineCatalogs: [createCatalog({ catalogId: "other/catalog" })],
|
|
392
397
|
},
|
|
@@ -418,7 +423,7 @@ describe("component parameter order", () => {
|
|
|
418
423
|
"rejects invalid metadata %j",
|
|
419
424
|
(parameterOrder) => {
|
|
420
425
|
const envelope = createEnvelope();
|
|
421
|
-
const catalog = envelope["
|
|
426
|
+
const catalog = envelope["1.0"].inlineCatalogs![0];
|
|
422
427
|
const invalid = {
|
|
423
428
|
...catalog,
|
|
424
429
|
components: { ProductGrid: { ...productGrid, parameterOrder } },
|
|
@@ -426,7 +431,7 @@ describe("component parameter order", () => {
|
|
|
426
431
|
expect(
|
|
427
432
|
readUI({
|
|
428
433
|
...envelope,
|
|
429
|
-
"
|
|
434
|
+
"1.0": { ...envelope["1.0"], inlineCatalogs: [invalid] },
|
|
430
435
|
}),
|
|
431
436
|
).toBeUndefined();
|
|
432
437
|
},
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
GENERATIVE_UI_MARKDOWN_GUIDELINES,
|
|
6
6
|
GENERATIVE_UI_MARKDOWN_GUIDELINES_DESCRIPTION,
|
|
7
7
|
GENERATIVE_UI_MARKDOWN_SCHEMA_CONTEXT_DESCRIPTION,
|
|
8
|
+
GENERATIVE_UI_MARKDOWN_WHEN_TO_SHOW,
|
|
8
9
|
GENERATIVE_UI_WHEN_TO_SHOW,
|
|
9
10
|
} from "../a2ui-prompts";
|
|
10
11
|
import { COPILOTKIT_FUNCTIONS } from "../generative-ui/basic-functions";
|
|
@@ -28,13 +29,13 @@ describe("GENERATIVE_UI_MARKDOWN_GUIDELINES", () => {
|
|
|
28
29
|
"Open a fence with ```a2ui target=<id> to show the surface in a named target.",
|
|
29
30
|
);
|
|
30
31
|
expect(guide).toContain(
|
|
31
|
-
|
|
32
|
+
"When a target limits its components, its surfaces can use only those components.",
|
|
32
33
|
);
|
|
33
34
|
});
|
|
34
35
|
|
|
35
|
-
it("asks for one JSON object per line, each with the
|
|
36
|
+
it("asks for one JSON object per line, each with the 1.0 version and no catalogId", () => {
|
|
36
37
|
expect(guide).toContain("write one JSON object per line and nothing else");
|
|
37
|
-
expect(guide).toContain('Give every operation "version":"
|
|
38
|
+
expect(guide).toContain('Give every operation "version":"1.0".');
|
|
38
39
|
expect(guide).not.toContain("v0.9");
|
|
39
40
|
expect(guide).not.toContain("catalogId");
|
|
40
41
|
});
|
|
@@ -44,7 +45,7 @@ describe("GENERATIVE_UI_MARKDOWN_GUIDELINES", () => {
|
|
|
44
45
|
'Start a surface with one createSurface. Put all the initial data in "dataModel" and the "root" component in "components".',
|
|
45
46
|
);
|
|
46
47
|
expect(guide).toContain(
|
|
47
|
-
'{"version":"
|
|
48
|
+
'{"version":"1.0","createSurface":{"surfaceId":"plan-picker","dataModel":{ ...initial data... },"components":[{"id":"root"',
|
|
48
49
|
);
|
|
49
50
|
expect(guide.indexOf('"createSurface"')).toBeLessThan(
|
|
50
51
|
guide.indexOf('"updateComponents"'),
|
|
@@ -93,9 +94,7 @@ describe("GENERATIVE_UI_MARKDOWN_GUIDELINES", () => {
|
|
|
93
94
|
expect(guide).toContain(
|
|
94
95
|
'A prop can also be a function value that updates with the data: {"@call":"formatCurrency"',
|
|
95
96
|
);
|
|
96
|
-
expect(guide).toContain(
|
|
97
|
-
'Use only the functions under "functions" in the schema.',
|
|
98
|
-
);
|
|
97
|
+
expect(guide).toContain("Use only the functions in the schema.");
|
|
99
98
|
expect(guide).toContain("formatString interpolates ${...}");
|
|
100
99
|
expect(guide).toContain(
|
|
101
100
|
"Inside formatString, ${...} does not support operators",
|
|
@@ -104,7 +103,7 @@ describe("GENERATIVE_UI_MARKDOWN_GUIDELINES", () => {
|
|
|
104
103
|
'{"@call":"calc","args":{"expression":"seats * 29 * (annual ? 0.8 : 1)"',
|
|
105
104
|
);
|
|
106
105
|
expect(guide).toContain(
|
|
107
|
-
|
|
106
|
+
"use series. Its description under Functions in the schema",
|
|
108
107
|
);
|
|
109
108
|
expect(guide).toContain('the "items" of a List');
|
|
110
109
|
expect(guide).not.toContain("template path of a list");
|
|
@@ -150,14 +149,14 @@ describe("GENERATIVE_UI_MARKDOWN_GUIDELINES", () => {
|
|
|
150
149
|
"describes callRendererFunction, its unique id, and the developer-message response",
|
|
151
150
|
() => {
|
|
152
151
|
expect(guide).toContain(
|
|
153
|
-
'{"version":"
|
|
152
|
+
'{"version":"1.0","callRendererFunction":{"functionCallId":"<unique id>","callFunction":{"@call":"<function>","args":{...}}}}',
|
|
154
153
|
);
|
|
155
154
|
expect(guide).toContain(
|
|
156
155
|
"Give every callRendererFunction a new functionCallId.",
|
|
157
156
|
);
|
|
158
157
|
expect(guide).toContain('"callers": "UI or agent" or "agent only"');
|
|
159
158
|
expect(guide).toContain(
|
|
160
|
-
'{"version":"
|
|
159
|
+
'{"version":"1.0","rendererFunctionResponse":{"functionCallId":"<id>","value":...}}',
|
|
161
160
|
);
|
|
162
161
|
expect(guide).toContain("Then you get a new turn.");
|
|
163
162
|
},
|
|
@@ -196,6 +195,7 @@ describe("generativeUIGuideFeatures", () => {
|
|
|
196
195
|
functions: { save: { parameters: props } },
|
|
197
196
|
}),
|
|
198
197
|
).toEqual({
|
|
198
|
+
components: ["List", "Button"],
|
|
199
199
|
functions: true,
|
|
200
200
|
events: true,
|
|
201
201
|
templates: true,
|
|
@@ -212,6 +212,7 @@ describe("generativeUIGuideFeatures", () => {
|
|
|
212
212
|
functions: {},
|
|
213
213
|
}),
|
|
214
214
|
).toEqual({
|
|
215
|
+
components: ["Card"],
|
|
215
216
|
functions: false,
|
|
216
217
|
events: false,
|
|
217
218
|
templates: false,
|
|
@@ -221,6 +222,28 @@ describe("generativeUIGuideFeatures", () => {
|
|
|
221
222
|
});
|
|
222
223
|
|
|
223
224
|
describe("buildGenerativeUIMarkdownGuidelines", () => {
|
|
225
|
+
it("leaves out the guide lines that name a standard component the catalog lacks", () => {
|
|
226
|
+
const all = {
|
|
227
|
+
functions: true,
|
|
228
|
+
events: true,
|
|
229
|
+
templates: true,
|
|
230
|
+
checks: true,
|
|
231
|
+
};
|
|
232
|
+
const full = buildGenerativeUIMarkdownGuidelines(all);
|
|
233
|
+
const reduced = buildGenerativeUIMarkdownGuidelines({
|
|
234
|
+
...all,
|
|
235
|
+
components: ["Text", "Title", "Table", "Button", "Card", "Badge"],
|
|
236
|
+
});
|
|
237
|
+
expect(full).toContain("a Map with the places as markers");
|
|
238
|
+
expect(reduced).not.toMatch(/\bMap\b|\bSlider\b|\bCharts?\b/);
|
|
239
|
+
expect(reduced).toContain(
|
|
240
|
+
"- Items with a status, a category or a level: a Badge on each item.",
|
|
241
|
+
);
|
|
242
|
+
expect(reduced).toContain(
|
|
243
|
+
"Updating a component replaces all of its props.",
|
|
244
|
+
);
|
|
245
|
+
});
|
|
246
|
+
|
|
224
247
|
const none = {
|
|
225
248
|
functions: false,
|
|
226
249
|
events: false,
|
|
@@ -282,13 +305,23 @@ describe("buildGenerativeUIMarkdownGuidelines", () => {
|
|
|
282
305
|
});
|
|
283
306
|
|
|
284
307
|
describe("GENERATIVE_UI_WHEN_TO_SHOW", () => {
|
|
285
|
-
it("
|
|
308
|
+
it("guides the markdown transport with its own text: UI by task, prose for quick answers", () => {
|
|
309
|
+
expect(GENERATIVE_UI_MARKDOWN_WHEN_TO_SHOW).toContain(
|
|
310
|
+
"Match the UI to the task",
|
|
311
|
+
);
|
|
312
|
+
expect(GENERATIVE_UI_MARKDOWN_WHEN_TO_SHOW).toContain(
|
|
313
|
+
"prose alone only for",
|
|
314
|
+
);
|
|
315
|
+
expect(GENERATIVE_UI_MARKDOWN_WHEN_TO_SHOW).toContain("No decoration");
|
|
316
|
+
expect(buildGenerativeUIMarkdownGuidelines()).toContain(
|
|
317
|
+
GENERATIVE_UI_MARKDOWN_WHEN_TO_SHOW,
|
|
318
|
+
);
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
it("encourages UI where it conveys the answer better, and prose otherwise, in the tool transport", () => {
|
|
286
322
|
expect(GENERATIVE_UI_WHEN_TO_SHOW).toContain("illustrate a concept");
|
|
287
323
|
expect(GENERATIVE_UI_WHEN_TO_SHOW).toContain("prose alone");
|
|
288
324
|
expect(GENERATIVE_UI_WHEN_TO_SHOW).toContain("decoration");
|
|
289
|
-
expect(buildGenerativeUIMarkdownGuidelines()).toContain(
|
|
290
|
-
GENERATIVE_UI_WHEN_TO_SHOW,
|
|
291
|
-
);
|
|
292
325
|
expect(
|
|
293
326
|
buildGenerativeUIPrompt({
|
|
294
327
|
catalogId: "test",
|