@copilotkit/shared 0.0.0-main-20260126221712 → 0.0.0-main-20260402184302
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/CHANGELOG.md +166 -1
- package/README.md +18 -12
- package/dist/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/constants/index.cjs +18 -0
- package/dist/constants/index.cjs.map +1 -0
- package/dist/constants/index.d.cts +11 -0
- package/dist/constants/index.d.cts.map +1 -0
- package/dist/constants/index.d.mts +11 -0
- package/dist/constants/index.d.mts.map +1 -0
- package/dist/constants/index.mjs +11 -12
- package/dist/constants/index.mjs.map +1 -1
- package/dist/finalize-events.cjs +106 -0
- package/dist/finalize-events.cjs.map +1 -0
- package/dist/finalize-events.d.cts +11 -0
- package/dist/finalize-events.d.cts.map +1 -0
- package/dist/finalize-events.d.mts +11 -0
- package/dist/finalize-events.d.mts.map +1 -0
- package/dist/finalize-events.mjs +105 -0
- package/dist/finalize-events.mjs.map +1 -0
- package/dist/index.cjs +89 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +27 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +28 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +23 -123
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +1302 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/logger.cjs +7 -0
- package/dist/logger.cjs.map +1 -0
- package/dist/logger.d.cts +5 -0
- package/dist/logger.d.cts.map +1 -0
- package/dist/logger.d.mts +5 -0
- package/dist/logger.d.mts.map +1 -0
- package/dist/logger.mjs +6 -0
- package/dist/logger.mjs.map +1 -0
- package/dist/package.cjs +12 -0
- package/dist/package.cjs.map +1 -0
- package/dist/package.mjs +6 -0
- package/dist/package.mjs.map +1 -0
- package/dist/standard-schema.cjs +29 -0
- package/dist/standard-schema.cjs.map +1 -0
- package/dist/standard-schema.d.cts +32 -0
- package/dist/standard-schema.d.cts.map +1 -0
- package/dist/standard-schema.d.mts +32 -0
- package/dist/standard-schema.d.mts.map +1 -0
- package/dist/standard-schema.mjs +28 -0
- package/dist/standard-schema.mjs.map +1 -0
- package/dist/telemetry/events.d.cts +39 -0
- package/dist/telemetry/events.d.cts.map +1 -0
- package/dist/telemetry/events.d.mts +39 -0
- package/dist/telemetry/events.d.mts.map +1 -0
- package/dist/telemetry/index.d.mts +1 -0
- package/dist/telemetry/scarf-client.cjs +29 -0
- package/dist/telemetry/scarf-client.cjs.map +1 -0
- package/dist/telemetry/scarf-client.mjs +27 -5
- package/dist/telemetry/scarf-client.mjs.map +1 -1
- package/dist/telemetry/telemetry-client.cjs +87 -0
- package/dist/telemetry/telemetry-client.cjs.map +1 -0
- package/dist/telemetry/telemetry-client.d.cts +48 -0
- package/dist/telemetry/telemetry-client.d.cts.map +1 -0
- package/dist/telemetry/telemetry-client.d.mts +48 -0
- package/dist/telemetry/telemetry-client.d.mts.map +1 -0
- package/dist/telemetry/telemetry-client.mjs +83 -9
- package/dist/telemetry/telemetry-client.mjs.map +1 -1
- package/dist/telemetry/utils.cjs +16 -0
- package/dist/telemetry/utils.cjs.map +1 -0
- package/dist/telemetry/utils.mjs +14 -8
- package/dist/telemetry/utils.mjs.map +1 -1
- package/dist/transcription-errors.cjs +84 -0
- package/dist/transcription-errors.cjs.map +1 -0
- package/dist/transcription-errors.d.cts +52 -0
- package/dist/transcription-errors.d.cts.map +1 -0
- package/dist/transcription-errors.d.mts +52 -0
- package/dist/transcription-errors.d.mts.map +1 -0
- package/dist/transcription-errors.mjs +82 -0
- package/dist/transcription-errors.mjs.map +1 -0
- package/dist/types/{action.d.ts → action.d.cts} +32 -32
- package/dist/types/action.d.cts.map +1 -0
- package/dist/types/action.d.mts +59 -0
- package/dist/types/action.d.mts.map +1 -0
- package/dist/types/copilot-cloud-config.d.cts +15 -0
- package/dist/types/copilot-cloud-config.d.cts.map +1 -0
- package/dist/types/copilot-cloud-config.d.mts +15 -0
- package/dist/types/copilot-cloud-config.d.mts.map +1 -0
- package/dist/types/error.d.cts +57 -0
- package/dist/types/error.d.cts.map +1 -0
- package/dist/types/error.d.mts +57 -0
- package/dist/types/error.d.mts.map +1 -0
- package/dist/types/message.d.cts +31 -0
- package/dist/types/message.d.cts.map +1 -0
- package/dist/types/message.d.mts +31 -0
- package/dist/types/message.d.mts.map +1 -0
- package/dist/types/openai-assistant.d.cts +55 -0
- package/dist/types/openai-assistant.d.cts.map +1 -0
- package/dist/types/openai-assistant.d.mts +55 -0
- package/dist/types/openai-assistant.d.mts.map +1 -0
- package/dist/types/utility.d.cts +6 -0
- package/dist/types/utility.d.cts.map +1 -0
- package/dist/types/utility.d.mts +6 -0
- package/dist/types/utility.d.mts.map +1 -0
- package/dist/utils/conditions.cjs +32 -0
- package/dist/utils/conditions.cjs.map +1 -0
- package/dist/utils/{conditions.d.ts → conditions.d.cts} +16 -11
- package/dist/utils/conditions.d.cts.map +1 -0
- package/dist/utils/conditions.d.mts +31 -0
- package/dist/utils/conditions.d.mts.map +1 -0
- package/dist/utils/conditions.mjs +30 -6
- package/dist/utils/conditions.mjs.map +1 -1
- package/dist/utils/console-styling.cjs +91 -0
- package/dist/utils/console-styling.cjs.map +1 -0
- package/dist/utils/console-styling.d.cts +65 -0
- package/dist/utils/console-styling.d.cts.map +1 -0
- package/dist/utils/console-styling.d.mts +65 -0
- package/dist/utils/console-styling.d.mts.map +1 -0
- package/dist/utils/console-styling.mjs +83 -15
- package/dist/utils/console-styling.mjs.map +1 -1
- package/dist/utils/errors.cjs +439 -0
- package/dist/utils/errors.cjs.map +1 -0
- package/dist/utils/{errors.d.ts → errors.d.cts} +188 -156
- package/dist/utils/errors.d.cts.map +1 -0
- package/dist/utils/errors.d.mts +312 -0
- package/dist/utils/errors.d.mts.map +1 -0
- package/dist/utils/errors.mjs +416 -63
- package/dist/utils/errors.mjs.map +1 -1
- package/dist/utils/index.cjs +99 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.cts +53 -0
- package/dist/utils/index.d.cts.map +1 -0
- package/dist/utils/index.d.mts +53 -0
- package/dist/utils/index.d.mts.map +1 -0
- package/dist/utils/index.mjs +91 -107
- package/dist/utils/index.mjs.map +1 -1
- package/dist/utils/json-schema.cjs +161 -0
- package/dist/utils/json-schema.cjs.map +1 -0
- package/dist/utils/{json-schema.d.ts → json-schema.d.cts} +19 -17
- package/dist/utils/json-schema.d.cts.map +1 -0
- package/dist/utils/json-schema.d.mts +36 -0
- package/dist/utils/json-schema.d.mts.map +1 -0
- package/dist/utils/json-schema.mjs +156 -12
- package/dist/utils/json-schema.mjs.map +1 -1
- package/dist/utils/random-id.cjs +38 -0
- package/dist/utils/random-id.cjs.map +1 -0
- package/dist/utils/{random-id.d.ts → random-id.d.cts} +3 -1
- package/dist/utils/random-id.d.cts.map +1 -0
- package/dist/utils/random-id.d.mts +8 -0
- package/dist/utils/random-id.d.mts.map +1 -0
- package/dist/utils/random-id.mjs +33 -12
- package/dist/utils/random-id.mjs.map +1 -1
- package/dist/utils/requests.cjs +58 -0
- package/dist/utils/requests.cjs.map +1 -0
- package/dist/utils/{requests.d.ts → requests.d.cts} +3 -1
- package/dist/utils/requests.d.cts.map +1 -0
- package/dist/utils/requests.d.mts +12 -0
- package/dist/utils/requests.d.mts.map +1 -0
- package/dist/utils/requests.mjs +56 -6
- package/dist/utils/requests.mjs.map +1 -1
- package/dist/utils/types.cjs +9 -0
- package/dist/utils/types.cjs.map +1 -0
- package/dist/utils/types.d.cts +33 -0
- package/dist/utils/types.d.cts.map +1 -0
- package/dist/utils/types.d.mts +33 -0
- package/dist/utils/types.d.mts.map +1 -0
- package/dist/utils/types.mjs +6 -1
- package/dist/utils/types.mjs.map +1 -1
- package/package.json +49 -40
- package/src/__tests__/standard-schema-types.test.ts +144 -0
- package/src/__tests__/standard-schema.test.ts +267 -0
- package/src/__tests__/zod-regression.test.ts +319 -0
- package/src/constants/index.ts +7 -1
- package/src/finalize-events.ts +154 -0
- package/src/index.ts +12 -0
- package/src/logger.ts +1 -0
- package/src/standard-schema.ts +76 -0
- package/src/telemetry/events.ts +4 -10
- package/src/telemetry/telemetry-client.ts +17 -6
- package/src/telemetry/utils.ts +6 -2
- package/src/transcription-errors.ts +99 -0
- package/src/types/action.ts +9 -5
- package/src/types/error.ts +11 -2
- package/src/types/message.ts +6 -2
- package/src/types/openai-assistant.ts +6 -2
- package/src/utils/{json-schema.test.ts → __tests__/json-schema.test.ts} +50 -7
- package/src/utils/conditions.ts +27 -9
- package/src/utils/console-styling.ts +4 -2
- package/src/utils/errors.ts +49 -16
- package/src/utils/index.ts +58 -0
- package/src/utils/json-schema.ts +40 -9
- package/src/utils/random-id.ts +5 -2
- package/src/utils/requests.ts +3 -1
- package/src/utils/types.ts +26 -1
- package/src/utils.test.ts +66 -0
- package/tsconfig.json +10 -2
- package/tsdown.config.ts +44 -0
- package/vitest.config.mjs +11 -0
- package/dist/chunk-2OJ5OJ2D.mjs +0 -1
- package/dist/chunk-2OJ5OJ2D.mjs.map +0 -1
- package/dist/chunk-64DYJ27R.mjs +0 -201
- package/dist/chunk-64DYJ27R.mjs.map +0 -1
- package/dist/chunk-6QGXWNS5.mjs +0 -34
- package/dist/chunk-6QGXWNS5.mjs.map +0 -1
- package/dist/chunk-6W2UEO2M.mjs +0 -94
- package/dist/chunk-6W2UEO2M.mjs.map +0 -1
- package/dist/chunk-BOKE4OKY.mjs +0 -41
- package/dist/chunk-BOKE4OKY.mjs.map +0 -1
- package/dist/chunk-EXYUAYC3.mjs +0 -426
- package/dist/chunk-EXYUAYC3.mjs.map +0 -1
- package/dist/chunk-FCCOSO5L.mjs +0 -1
- package/dist/chunk-FCCOSO5L.mjs.map +0 -1
- package/dist/chunk-GYZIHHE6.mjs +0 -13
- package/dist/chunk-GYZIHHE6.mjs.map +0 -1
- package/dist/chunk-IAFBVORQ.mjs +0 -1
- package/dist/chunk-IAFBVORQ.mjs.map +0 -1
- package/dist/chunk-MSUB6DGR.mjs +0 -1
- package/dist/chunk-MSUB6DGR.mjs.map +0 -1
- package/dist/chunk-N5EP5OD5.mjs +0 -1
- package/dist/chunk-N5EP5OD5.mjs.map +0 -1
- package/dist/chunk-NAFEBKSO.mjs +0 -1
- package/dist/chunk-NAFEBKSO.mjs.map +0 -1
- package/dist/chunk-P7STFMPO.mjs +0 -1
- package/dist/chunk-P7STFMPO.mjs.map +0 -1
- package/dist/chunk-PEN77NLM.mjs +0 -107
- package/dist/chunk-PEN77NLM.mjs.map +0 -1
- package/dist/chunk-PL5WNHFZ.mjs +0 -50
- package/dist/chunk-PL5WNHFZ.mjs.map +0 -1
- package/dist/chunk-TJKDW3H3.mjs +0 -38
- package/dist/chunk-TJKDW3H3.mjs.map +0 -1
- package/dist/chunk-UYARLQNA.mjs +0 -1
- package/dist/chunk-UYARLQNA.mjs.map +0 -1
- package/dist/chunk-XEMZTHQZ.mjs +0 -67
- package/dist/chunk-XEMZTHQZ.mjs.map +0 -1
- package/dist/chunk-XTHC46M2.mjs +0 -1
- package/dist/chunk-XTHC46M2.mjs.map +0 -1
- package/dist/constants/index.d.ts +0 -6
- package/dist/constants/index.js +0 -40
- package/dist/constants/index.js.map +0 -1
- package/dist/index.d.ts +0 -25
- package/dist/index.js +0 -1098
- package/dist/index.js.map +0 -1
- package/dist/telemetry/events.d.ts +0 -45
- package/dist/telemetry/events.js +0 -19
- package/dist/telemetry/events.js.map +0 -1
- package/dist/telemetry/events.mjs +0 -1
- package/dist/telemetry/events.mjs.map +0 -1
- package/dist/telemetry/index.d.ts +0 -3
- package/dist/telemetry/index.js +0 -188
- package/dist/telemetry/index.js.map +0 -1
- package/dist/telemetry/index.mjs +0 -12
- package/dist/telemetry/index.mjs.map +0 -1
- package/dist/telemetry/scarf-client.d.ts +0 -7
- package/dist/telemetry/scarf-client.js +0 -59
- package/dist/telemetry/scarf-client.js.map +0 -1
- package/dist/telemetry/security-check.d.ts +0 -2
- package/dist/telemetry/security-check.js +0 -2
- package/dist/telemetry/security-check.js.map +0 -1
- package/dist/telemetry/security-check.mjs +0 -1
- package/dist/telemetry/security-check.mjs.map +0 -1
- package/dist/telemetry/telemetry-client.d.ts +0 -40
- package/dist/telemetry/telemetry-client.js +0 -186
- package/dist/telemetry/telemetry-client.js.map +0 -1
- package/dist/telemetry/utils.d.ts +0 -8
- package/dist/telemetry/utils.js +0 -69
- package/dist/telemetry/utils.js.map +0 -1
- package/dist/types/action.js +0 -19
- package/dist/types/action.js.map +0 -1
- package/dist/types/action.mjs +0 -2
- package/dist/types/action.mjs.map +0 -1
- package/dist/types/copilot-cloud-config.d.ts +0 -13
- package/dist/types/copilot-cloud-config.js +0 -19
- package/dist/types/copilot-cloud-config.js.map +0 -1
- package/dist/types/copilot-cloud-config.mjs +0 -2
- package/dist/types/copilot-cloud-config.mjs.map +0 -1
- package/dist/types/error.d.ts +0 -55
- package/dist/types/error.js +0 -19
- package/dist/types/error.js.map +0 -1
- package/dist/types/error.mjs +0 -2
- package/dist/types/error.mjs.map +0 -1
- package/dist/types/index.d.ts +0 -7
- package/dist/types/index.js +0 -19
- package/dist/types/index.js.map +0 -1
- package/dist/types/index.mjs +0 -8
- package/dist/types/index.mjs.map +0 -1
- package/dist/types/message.d.ts +0 -26
- package/dist/types/message.js +0 -19
- package/dist/types/message.js.map +0 -1
- package/dist/types/message.mjs +0 -2
- package/dist/types/message.mjs.map +0 -1
- package/dist/types/openai-assistant.d.ts +0 -53
- package/dist/types/openai-assistant.js +0 -19
- package/dist/types/openai-assistant.js.map +0 -1
- package/dist/types/openai-assistant.mjs +0 -2
- package/dist/types/openai-assistant.mjs.map +0 -1
- package/dist/types/utility.d.ts +0 -6
- package/dist/types/utility.js +0 -19
- package/dist/types/utility.js.map +0 -1
- package/dist/types/utility.mjs +0 -2
- package/dist/types/utility.mjs.map +0 -1
- package/dist/utils/conditions.js +0 -74
- package/dist/utils/conditions.js.map +0 -1
- package/dist/utils/console-styling.d.ts +0 -84
- package/dist/utils/console-styling.js +0 -123
- package/dist/utils/console-styling.js.map +0 -1
- package/dist/utils/errors.js +0 -443
- package/dist/utils/errors.js.map +0 -1
- package/dist/utils/index.d.ts +0 -32
- package/dist/utils/index.js +0 -927
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/json-schema.js +0 -228
- package/dist/utils/json-schema.js.map +0 -1
- package/dist/utils/random-id.js +0 -68
- package/dist/utils/random-id.js.map +0 -1
- package/dist/utils/requests.js +0 -91
- package/dist/utils/requests.js.map +0 -1
- package/dist/utils/types.d.ts +0 -20
- package/dist/utils/types.js +0 -19
- package/dist/utils/types.js.map +0 -1
- package/jest.config.js +0 -5
- package/tsup.config.ts +0 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,158 @@
|
|
|
1
1
|
# @copilotkit/shared
|
|
2
2
|
|
|
3
|
-
## 0.0.0-main-
|
|
3
|
+
## 0.0.0-main-20260402184302
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1ceb963: refactor: consolidate V1/V2 packages into flat @copilotkit/\* structure
|
|
8
|
+
|
|
9
|
+
## 1.55.0-next.8
|
|
10
|
+
|
|
11
|
+
## 1.55.0-next.7
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- 1ceb963: refactor: consolidate V1/V2 packages into flat @copilotkit/\* structure
|
|
16
|
+
|
|
17
|
+
## 1.54.1-next.6
|
|
18
|
+
|
|
19
|
+
## 1.54.1-next.5
|
|
20
|
+
|
|
21
|
+
## 1.54.1-next.4
|
|
22
|
+
|
|
23
|
+
## 1.54.1-next.3
|
|
24
|
+
|
|
25
|
+
## 1.54.1-next.2
|
|
26
|
+
|
|
27
|
+
## 1.54.1-next.1
|
|
28
|
+
|
|
29
|
+
## 1.54.1-next.0
|
|
30
|
+
|
|
31
|
+
## 1.54.0
|
|
32
|
+
|
|
33
|
+
## 1.54.0-next.9
|
|
34
|
+
|
|
35
|
+
## 1.54.0-next.8
|
|
36
|
+
|
|
37
|
+
## 1.54.0-next.7
|
|
38
|
+
|
|
39
|
+
## 1.54.0-next.6
|
|
40
|
+
|
|
41
|
+
## 1.54.0-next.5
|
|
42
|
+
|
|
43
|
+
## 1.54.0-next.4
|
|
44
|
+
|
|
45
|
+
## 1.54.0-next.3
|
|
46
|
+
|
|
47
|
+
## 1.53.1-next.2
|
|
48
|
+
|
|
49
|
+
## 1.53.1-next.1
|
|
50
|
+
|
|
51
|
+
## 1.53.1-next.0
|
|
52
|
+
|
|
53
|
+
## 1.53.0
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
- 1510f64: feat: enable mcp and a2ui middleware directly from copilotkit runtime
|
|
58
|
+
- bf1fc6f: fix: `convertJsonSchemaToZodSchema` drops enum constraints
|
|
59
|
+
|
|
60
|
+
## 1.53.0-next.6
|
|
61
|
+
|
|
62
|
+
## 1.53.0-next.5
|
|
63
|
+
|
|
64
|
+
## 1.52.2-next.4
|
|
65
|
+
|
|
66
|
+
## 1.52.2-next.3
|
|
67
|
+
|
|
68
|
+
### Patch Changes
|
|
69
|
+
|
|
70
|
+
- 1510f64: feat: enable mcp and a2ui middleware directly from copilotkit runtime
|
|
71
|
+
|
|
72
|
+
## 1.52.2-next.2
|
|
73
|
+
|
|
74
|
+
## 1.52.2-next.1
|
|
75
|
+
|
|
76
|
+
### Patch Changes
|
|
77
|
+
|
|
78
|
+
- bf1fc6f: fix: `convertJsonSchemaToZodSchema` drops enum constraints
|
|
79
|
+
|
|
80
|
+
## 1.52.2-next.0
|
|
81
|
+
|
|
82
|
+
## 1.52.1
|
|
83
|
+
|
|
84
|
+
## 1.52.1-next.1
|
|
85
|
+
|
|
86
|
+
## 1.52.1-next.0
|
|
87
|
+
|
|
88
|
+
## 1.52.0
|
|
89
|
+
|
|
90
|
+
### Patch Changes
|
|
91
|
+
|
|
92
|
+
- ef0f539: Add reasoning support and default components for reasoning messages
|
|
93
|
+
|
|
94
|
+
## 1.52.0-next.8
|
|
95
|
+
|
|
96
|
+
## 1.52.0-next.7
|
|
97
|
+
|
|
98
|
+
## 1.52.0-next.6
|
|
99
|
+
|
|
100
|
+
## 1.52.0-next.5
|
|
101
|
+
|
|
102
|
+
## 1.51.5-next.4
|
|
103
|
+
|
|
104
|
+
## 1.51.5-next.3
|
|
105
|
+
|
|
106
|
+
## 1.51.5-next.2
|
|
107
|
+
|
|
108
|
+
## 1.51.5-next.1
|
|
109
|
+
|
|
110
|
+
## 1.51.5-next.0
|
|
111
|
+
|
|
112
|
+
### Patch Changes
|
|
113
|
+
|
|
114
|
+
- ef0f539: Add reasoning support and default components for reasoning messages
|
|
115
|
+
|
|
116
|
+
## 1.51.4
|
|
117
|
+
|
|
118
|
+
## 1.51.4-next.8
|
|
119
|
+
|
|
120
|
+
## 1.51.4-next.7
|
|
121
|
+
|
|
122
|
+
## 1.51.4-next.6
|
|
123
|
+
|
|
124
|
+
## 1.51.4-next.5
|
|
125
|
+
|
|
126
|
+
## 1.51.4-next.4
|
|
127
|
+
|
|
128
|
+
## 1.51.4-next.3
|
|
129
|
+
|
|
130
|
+
## 1.51.4-next.2
|
|
131
|
+
|
|
132
|
+
## 1.51.4-next.1
|
|
133
|
+
|
|
134
|
+
## 1.51.4-next.0
|
|
135
|
+
|
|
136
|
+
## 1.51.3
|
|
4
137
|
|
|
5
138
|
### Patch Changes
|
|
6
139
|
|
|
7
140
|
- d655e75: fix: update ag-ui dependencies
|
|
141
|
+
- d36fc1e: Add UMD export
|
|
142
|
+
|
|
143
|
+
## 1.51.3-next.8
|
|
144
|
+
|
|
145
|
+
### Patch Changes
|
|
146
|
+
|
|
147
|
+
- d36fc1e: Add UMD export
|
|
148
|
+
|
|
149
|
+
## 1.51.3-next.7
|
|
150
|
+
|
|
151
|
+
## 1.51.3-next.6
|
|
152
|
+
|
|
153
|
+
## 1.51.3-next.5
|
|
154
|
+
|
|
155
|
+
## 1.51.3-next.4
|
|
8
156
|
|
|
9
157
|
## 1.51.3-next.3
|
|
10
158
|
|
|
@@ -283,12 +431,14 @@
|
|
|
283
431
|
agentic runtimes we acquired tech-debt that, with this PR, is being alleviated.
|
|
284
432
|
|
|
285
433
|
As such, the following features have been updated to be completely functional with Headless UI.
|
|
434
|
+
|
|
286
435
|
- Generative UI
|
|
287
436
|
- Suggestions
|
|
288
437
|
- Agentic Generative UI
|
|
289
438
|
- Interrupts
|
|
290
439
|
|
|
291
440
|
In addition, a variety of QOL changes have been made.
|
|
441
|
+
|
|
292
442
|
- New AG-UI based message types
|
|
293
443
|
- Inline code rendering is fixed
|
|
294
444
|
|
|
@@ -300,15 +450,19 @@
|
|
|
300
450
|
- 6d1de58: - fix: address issues that would cause headless UI breaking changes in the next release
|
|
301
451
|
|
|
302
452
|
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
|
|
453
|
+
|
|
303
454
|
- fix: more fixes addressing breaking changes in new Headless UI
|
|
304
455
|
|
|
305
456
|
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
|
|
457
|
+
|
|
306
458
|
- chore: address linting issues
|
|
307
459
|
|
|
308
460
|
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
|
|
461
|
+
|
|
309
462
|
- chore: fixing branding and docs
|
|
310
463
|
|
|
311
464
|
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
|
|
465
|
+
|
|
312
466
|
- chore: more docs fixing
|
|
313
467
|
|
|
314
468
|
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
|
|
@@ -326,15 +480,19 @@
|
|
|
326
480
|
- 6d1de58: - fix: address issues that would cause headless UI breaking changes in the next release
|
|
327
481
|
|
|
328
482
|
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
|
|
483
|
+
|
|
329
484
|
- fix: more fixes addressing breaking changes in new Headless UI
|
|
330
485
|
|
|
331
486
|
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
|
|
487
|
+
|
|
332
488
|
- chore: address linting issues
|
|
333
489
|
|
|
334
490
|
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
|
|
491
|
+
|
|
335
492
|
- chore: fixing branding and docs
|
|
336
493
|
|
|
337
494
|
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
|
|
495
|
+
|
|
338
496
|
- chore: more docs fixing
|
|
339
497
|
|
|
340
498
|
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
|
|
@@ -371,12 +529,14 @@
|
|
|
371
529
|
agentic runtimes we acquired tech-debt that, with this PR, is being alleviated.
|
|
372
530
|
|
|
373
531
|
As such, the following features have been updated to be completely functional with Headless UI.
|
|
532
|
+
|
|
374
533
|
- Generative UI
|
|
375
534
|
- Suggestions
|
|
376
535
|
- Agentic Generative UI
|
|
377
536
|
- Interrupts
|
|
378
537
|
|
|
379
538
|
In addition, a variety of QOL changes have been made.
|
|
539
|
+
|
|
380
540
|
- New AG-UI based message types
|
|
381
541
|
- Inline code rendering is fixed
|
|
382
542
|
|
|
@@ -407,6 +567,7 @@
|
|
|
407
567
|
### Patch Changes
|
|
408
568
|
|
|
409
569
|
- fac89c2: - refactor: rename onTrace to onError throughout codebase
|
|
570
|
+
|
|
410
571
|
- Rename CopilotTraceEvent to CopilotErrorEvent and CopilotTraceHandler to CopilotErrorHandler
|
|
411
572
|
|
|
412
573
|
- 9169ad7: - feat: add onTrace handler for runtime and UI error/event tracking
|
|
@@ -1039,6 +1200,7 @@
|
|
|
1039
1200
|
- e16d95e: New prerelease
|
|
1040
1201
|
- 1721cbd: Add convertActionsToDynamicStructuredTools to sdk-js
|
|
1041
1202
|
- CopilotKit Core:
|
|
1203
|
+
|
|
1042
1204
|
- Improved error messages and overall logs
|
|
1043
1205
|
- `useCopilotAction.renderAndAwait` renamed to `.renderAndAwaitForResponse` (backwards compatible, will be deprecated in the future)
|
|
1044
1206
|
- Improved scrolling behavior. It is now possible to scroll up during LLM response generation
|
|
@@ -1046,6 +1208,7 @@
|
|
|
1046
1208
|
- Updated interfaces for better developer ergonomics
|
|
1047
1209
|
|
|
1048
1210
|
CoAgents:
|
|
1211
|
+
|
|
1049
1212
|
- Renamed `remoteActions` to `remoteEndpoints` (backwards compatible, will be deprecated in the future)
|
|
1050
1213
|
- Support for LangGraph Platform in Remote Endpoints
|
|
1051
1214
|
- LangGraph JS Support for CoAgents (locally via `langgraph dev`, `langgraph up` or deployed to LangGraph Platform)
|
|
@@ -1053,6 +1216,7 @@
|
|
|
1053
1216
|
- Enhanced state management and message handling
|
|
1054
1217
|
|
|
1055
1218
|
CopilotKid Back-end SDK:
|
|
1219
|
+
|
|
1056
1220
|
- Released a whole-new `@copilotkit/sdk-js` for building agents with LangGraph JS Support
|
|
1057
1221
|
|
|
1058
1222
|
- 8d0144f: bump
|
|
@@ -1393,6 +1557,7 @@ CopilotKid Back-end SDK:
|
|
|
1393
1557
|
### Major Changes
|
|
1394
1558
|
|
|
1395
1559
|
- b6a4b6eb: V1.0 Release Candidate
|
|
1560
|
+
|
|
1396
1561
|
- A robust new protocol between the frontend and the Copilot Runtime
|
|
1397
1562
|
- Support for Copilot Cloud
|
|
1398
1563
|
- Generative UI
|
package/README.md
CHANGED
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
const { visibleMessages, appendMessage, setMessages, ... } = useCopilotChat();
|
|
49
49
|
|
|
50
50
|
// Pre-built components with deep customization options (CSS + pass custom sub-components)
|
|
51
|
-
<CopilotPopup
|
|
52
|
-
instructions={"You are assisting the user as best as you can. Answer in the best way possible given the data you have."}
|
|
53
|
-
labels={{ title: "Popup Assistant", initial: "Need any help?" }}
|
|
51
|
+
<CopilotPopup
|
|
52
|
+
instructions={"You are assisting the user as best as you can. Answer in the best way possible given the data you have."}
|
|
53
|
+
labels={{ title: "Popup Assistant", initial: "Need any help?" }}
|
|
54
54
|
/>
|
|
55
55
|
```
|
|
56
56
|
|
|
@@ -71,9 +71,9 @@ useCopilotAction({
|
|
|
71
71
|
|
|
72
72
|
```ts
|
|
73
73
|
// Share state between app and agent
|
|
74
|
-
const { agentState } = useCoAgent({
|
|
75
|
-
name: "basic_agent",
|
|
76
|
-
initialState: { input: "NYC" }
|
|
74
|
+
const { agentState } = useCoAgent({
|
|
75
|
+
name: "basic_agent",
|
|
76
|
+
initialState: { input: "NYC" }
|
|
77
77
|
});
|
|
78
78
|
|
|
79
79
|
// agentic generative UI
|
|
@@ -114,14 +114,20 @@ useCopilotAction({
|
|
|
114
114
|
```ts
|
|
115
115
|
// intermediate agent state streaming (supports both LangGraph.js + LangGraph python)
|
|
116
116
|
const modifiedConfig = copilotKitCustomizeConfig(config, {
|
|
117
|
-
emitIntermediateState: [
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
117
|
+
emitIntermediateState: [
|
|
118
|
+
{
|
|
119
|
+
stateKey: "outline",
|
|
120
|
+
tool: "set_outline",
|
|
121
|
+
toolArgument: "outline",
|
|
122
|
+
},
|
|
123
|
+
],
|
|
122
124
|
});
|
|
123
|
-
const response = await ChatOpenAI({ model: "gpt-4o" }).invoke(
|
|
125
|
+
const response = await ChatOpenAI({ model: "gpt-4o" }).invoke(
|
|
126
|
+
messages,
|
|
127
|
+
modifiedConfig,
|
|
128
|
+
);
|
|
124
129
|
```
|
|
130
|
+
|
|
125
131
|
## 🏆 Featured Examples
|
|
126
132
|
|
|
127
133
|
<p align="center">
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/constants/index.ts
|
|
3
|
+
const COPILOT_CLOUD_API_URL = "https://api.cloud.copilotkit.ai";
|
|
4
|
+
const COPILOT_CLOUD_VERSION = "v1";
|
|
5
|
+
const COPILOT_CLOUD_CHAT_URL = `${COPILOT_CLOUD_API_URL}/copilotkit/${COPILOT_CLOUD_VERSION}`;
|
|
6
|
+
const COPILOT_CLOUD_PUBLIC_API_KEY_HEADER = "X-CopilotCloud-Public-Api-Key";
|
|
7
|
+
const DEFAULT_AGENT_ID = "default";
|
|
8
|
+
/** Phoenix channel event name used for all AG-UI events. */
|
|
9
|
+
const AG_UI_CHANNEL_EVENT = "ag-ui";
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.AG_UI_CHANNEL_EVENT = AG_UI_CHANNEL_EVENT;
|
|
13
|
+
exports.COPILOT_CLOUD_API_URL = COPILOT_CLOUD_API_URL;
|
|
14
|
+
exports.COPILOT_CLOUD_CHAT_URL = COPILOT_CLOUD_CHAT_URL;
|
|
15
|
+
exports.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER = COPILOT_CLOUD_PUBLIC_API_KEY_HEADER;
|
|
16
|
+
exports.COPILOT_CLOUD_VERSION = COPILOT_CLOUD_VERSION;
|
|
17
|
+
exports.DEFAULT_AGENT_ID = DEFAULT_AGENT_ID;
|
|
18
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/constants/index.ts"],"sourcesContent":["export const COPILOT_CLOUD_API_URL = \"https://api.cloud.copilotkit.ai\";\nexport const COPILOT_CLOUD_VERSION = \"v1\";\nexport const COPILOT_CLOUD_CHAT_URL = `${COPILOT_CLOUD_API_URL}/copilotkit/${COPILOT_CLOUD_VERSION}`;\nexport const COPILOT_CLOUD_PUBLIC_API_KEY_HEADER =\n \"X-CopilotCloud-Public-Api-Key\";\n\nexport const DEFAULT_AGENT_ID = \"default\";\n\n/** Phoenix channel event name used for all AG-UI events. */\nexport const AG_UI_CHANNEL_EVENT = \"ag-ui\";\n"],"mappings":";;AAAA,MAAa,wBAAwB;AACrC,MAAa,wBAAwB;AACrC,MAAa,yBAAyB,GAAG,sBAAsB,cAAc;AAC7E,MAAa,sCACX;AAEF,MAAa,mBAAmB;;AAGhC,MAAa,sBAAsB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/constants/index.d.ts
|
|
2
|
+
declare const COPILOT_CLOUD_API_URL = "https://api.cloud.copilotkit.ai";
|
|
3
|
+
declare const COPILOT_CLOUD_VERSION = "v1";
|
|
4
|
+
declare const COPILOT_CLOUD_CHAT_URL = "https://api.cloud.copilotkit.ai/copilotkit/v1";
|
|
5
|
+
declare const COPILOT_CLOUD_PUBLIC_API_KEY_HEADER = "X-CopilotCloud-Public-Api-Key";
|
|
6
|
+
declare const DEFAULT_AGENT_ID = "default";
|
|
7
|
+
/** Phoenix channel event name used for all AG-UI events. */
|
|
8
|
+
declare const AG_UI_CHANNEL_EVENT = "ag-ui";
|
|
9
|
+
//#endregion
|
|
10
|
+
export { AG_UI_CHANNEL_EVENT, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION, DEFAULT_AGENT_ID };
|
|
11
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/constants/index.ts"],"mappings":";cAAa,qBAAA;AAAA,cACA,qBAAA;AAAA,cACA,sBAAA;AAAA,cACA,mCAAA;AAAA,cAGA,gBAAA;;cAGA,mBAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/constants/index.d.ts
|
|
2
|
+
declare const COPILOT_CLOUD_API_URL = "https://api.cloud.copilotkit.ai";
|
|
3
|
+
declare const COPILOT_CLOUD_VERSION = "v1";
|
|
4
|
+
declare const COPILOT_CLOUD_CHAT_URL = "https://api.cloud.copilotkit.ai/copilotkit/v1";
|
|
5
|
+
declare const COPILOT_CLOUD_PUBLIC_API_KEY_HEADER = "X-CopilotCloud-Public-Api-Key";
|
|
6
|
+
declare const DEFAULT_AGENT_ID = "default";
|
|
7
|
+
/** Phoenix channel event name used for all AG-UI events. */
|
|
8
|
+
declare const AG_UI_CHANNEL_EVENT = "ag-ui";
|
|
9
|
+
//#endregion
|
|
10
|
+
export { AG_UI_CHANNEL_EVENT, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION, DEFAULT_AGENT_ID };
|
|
11
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/constants/index.ts"],"mappings":";cAAa,qBAAA;AAAA,cACA,qBAAA;AAAA,cACA,sBAAA;AAAA,cACA,mCAAA;AAAA,cAGA,gBAAA;;cAGA,mBAAA"}
|
package/dist/constants/index.mjs
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
1
|
+
//#region src/constants/index.ts
|
|
2
|
+
const COPILOT_CLOUD_API_URL = "https://api.cloud.copilotkit.ai";
|
|
3
|
+
const COPILOT_CLOUD_VERSION = "v1";
|
|
4
|
+
const COPILOT_CLOUD_CHAT_URL = `${COPILOT_CLOUD_API_URL}/copilotkit/${COPILOT_CLOUD_VERSION}`;
|
|
5
|
+
const COPILOT_CLOUD_PUBLIC_API_KEY_HEADER = "X-CopilotCloud-Public-Api-Key";
|
|
6
|
+
const DEFAULT_AGENT_ID = "default";
|
|
7
|
+
/** Phoenix channel event name used for all AG-UI events. */
|
|
8
|
+
const AG_UI_CHANNEL_EVENT = "ag-ui";
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { AG_UI_CHANNEL_EVENT, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION, DEFAULT_AGENT_ID };
|
|
13
12
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/constants/index.ts"],"sourcesContent":["export const COPILOT_CLOUD_API_URL = \"https://api.cloud.copilotkit.ai\";\nexport const COPILOT_CLOUD_VERSION = \"v1\";\nexport const COPILOT_CLOUD_CHAT_URL = `${COPILOT_CLOUD_API_URL}/copilotkit/${COPILOT_CLOUD_VERSION}`;\nexport const COPILOT_CLOUD_PUBLIC_API_KEY_HEADER =\n \"X-CopilotCloud-Public-Api-Key\";\n\nexport const DEFAULT_AGENT_ID = \"default\";\n\n/** Phoenix channel event name used for all AG-UI events. */\nexport const AG_UI_CHANNEL_EVENT = \"ag-ui\";\n"],"mappings":";AAAA,MAAa,wBAAwB;AACrC,MAAa,wBAAwB;AACrC,MAAa,yBAAyB,GAAG,sBAAsB,cAAc;AAC7E,MAAa,sCACX;AAEF,MAAa,mBAAmB;;AAGhC,MAAa,sBAAsB"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_random_id = require('./utils/random-id.cjs');
|
|
3
|
+
let _ag_ui_client = require("@ag-ui/client");
|
|
4
|
+
|
|
5
|
+
//#region src/finalize-events.ts
|
|
6
|
+
const defaultStopMessage = "Run stopped by user";
|
|
7
|
+
const defaultAbruptEndMessage = "Run ended without emitting a terminal event";
|
|
8
|
+
function finalizeRunEvents(events, options = {}) {
|
|
9
|
+
const { stopRequested = false, interruptionMessage } = options;
|
|
10
|
+
const resolvedStopMessage = interruptionMessage ?? defaultStopMessage;
|
|
11
|
+
const resolvedAbruptMessage = interruptionMessage && interruptionMessage !== defaultStopMessage ? interruptionMessage : defaultAbruptEndMessage;
|
|
12
|
+
const appended = [];
|
|
13
|
+
const openMessageIds = /* @__PURE__ */ new Set();
|
|
14
|
+
const openToolCalls = /* @__PURE__ */ new Map();
|
|
15
|
+
for (const event of events) switch (event.type) {
|
|
16
|
+
case _ag_ui_client.EventType.TEXT_MESSAGE_START: {
|
|
17
|
+
const messageId = event.messageId;
|
|
18
|
+
if (typeof messageId === "string") openMessageIds.add(messageId);
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
case _ag_ui_client.EventType.TEXT_MESSAGE_END: {
|
|
22
|
+
const messageId = event.messageId;
|
|
23
|
+
if (typeof messageId === "string") openMessageIds.delete(messageId);
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
case _ag_ui_client.EventType.TOOL_CALL_START: {
|
|
27
|
+
const toolCallId = event.toolCallId;
|
|
28
|
+
if (typeof toolCallId === "string") openToolCalls.set(toolCallId, {
|
|
29
|
+
hasEnd: false,
|
|
30
|
+
hasResult: false
|
|
31
|
+
});
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
case _ag_ui_client.EventType.TOOL_CALL_END: {
|
|
35
|
+
const toolCallId = event.toolCallId;
|
|
36
|
+
const info = toolCallId ? openToolCalls.get(toolCallId) : void 0;
|
|
37
|
+
if (info) info.hasEnd = true;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
case _ag_ui_client.EventType.TOOL_CALL_RESULT: {
|
|
41
|
+
const toolCallId = event.toolCallId;
|
|
42
|
+
const info = toolCallId ? openToolCalls.get(toolCallId) : void 0;
|
|
43
|
+
if (info) info.hasResult = true;
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
default: break;
|
|
47
|
+
}
|
|
48
|
+
const hasRunFinished = events.some((event) => event.type === _ag_ui_client.EventType.RUN_FINISHED);
|
|
49
|
+
const hasRunError = events.some((event) => event.type === _ag_ui_client.EventType.RUN_ERROR);
|
|
50
|
+
const terminalEventMissing = !(hasRunFinished || hasRunError);
|
|
51
|
+
for (const messageId of openMessageIds) {
|
|
52
|
+
const endEvent = {
|
|
53
|
+
type: _ag_ui_client.EventType.TEXT_MESSAGE_END,
|
|
54
|
+
messageId
|
|
55
|
+
};
|
|
56
|
+
events.push(endEvent);
|
|
57
|
+
appended.push(endEvent);
|
|
58
|
+
}
|
|
59
|
+
for (const [toolCallId, info] of openToolCalls) {
|
|
60
|
+
if (!info.hasEnd) {
|
|
61
|
+
const endEvent = {
|
|
62
|
+
type: _ag_ui_client.EventType.TOOL_CALL_END,
|
|
63
|
+
toolCallId
|
|
64
|
+
};
|
|
65
|
+
events.push(endEvent);
|
|
66
|
+
appended.push(endEvent);
|
|
67
|
+
}
|
|
68
|
+
if (terminalEventMissing && !info.hasResult) {
|
|
69
|
+
const resultEvent = {
|
|
70
|
+
type: _ag_ui_client.EventType.TOOL_CALL_RESULT,
|
|
71
|
+
toolCallId,
|
|
72
|
+
messageId: `${toolCallId ?? require_random_id.randomUUID()}-result`,
|
|
73
|
+
role: "tool",
|
|
74
|
+
content: JSON.stringify(stopRequested ? {
|
|
75
|
+
status: "stopped",
|
|
76
|
+
reason: "stop_requested",
|
|
77
|
+
message: resolvedStopMessage
|
|
78
|
+
} : {
|
|
79
|
+
status: "error",
|
|
80
|
+
reason: "missing_terminal_event",
|
|
81
|
+
message: resolvedAbruptMessage
|
|
82
|
+
})
|
|
83
|
+
};
|
|
84
|
+
events.push(resultEvent);
|
|
85
|
+
appended.push(resultEvent);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (terminalEventMissing) if (stopRequested) {
|
|
89
|
+
const finishedEvent = { type: _ag_ui_client.EventType.RUN_FINISHED };
|
|
90
|
+
events.push(finishedEvent);
|
|
91
|
+
appended.push(finishedEvent);
|
|
92
|
+
} else {
|
|
93
|
+
const errorEvent = {
|
|
94
|
+
type: _ag_ui_client.EventType.RUN_ERROR,
|
|
95
|
+
message: resolvedAbruptMessage,
|
|
96
|
+
code: "INCOMPLETE_STREAM"
|
|
97
|
+
};
|
|
98
|
+
events.push(errorEvent);
|
|
99
|
+
appended.push(errorEvent);
|
|
100
|
+
}
|
|
101
|
+
return appended;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
//#endregion
|
|
105
|
+
exports.finalizeRunEvents = finalizeRunEvents;
|
|
106
|
+
//# sourceMappingURL=finalize-events.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finalize-events.cjs","names":["EventType","randomUUID"],"sources":["../src/finalize-events.ts"],"sourcesContent":["import { BaseEvent, EventType, RunErrorEvent } from \"@ag-ui/client\";\nimport { randomUUID } from \"./utils\";\n\ninterface FinalizeRunOptions {\n stopRequested?: boolean;\n interruptionMessage?: string;\n}\n\nconst defaultStopMessage = \"Run stopped by user\";\nconst defaultAbruptEndMessage = \"Run ended without emitting a terminal event\";\n\nexport function finalizeRunEvents(\n events: BaseEvent[],\n options: FinalizeRunOptions = {},\n): BaseEvent[] {\n const { stopRequested = false, interruptionMessage } = options;\n\n const resolvedStopMessage = interruptionMessage ?? defaultStopMessage;\n const resolvedAbruptMessage =\n interruptionMessage && interruptionMessage !== defaultStopMessage\n ? interruptionMessage\n : defaultAbruptEndMessage;\n\n const appended: BaseEvent[] = [];\n\n const openMessageIds = new Set<string>();\n const openToolCalls = new Map<\n string,\n {\n hasEnd: boolean;\n hasResult: boolean;\n }\n >();\n\n for (const event of events) {\n switch (event.type) {\n case EventType.TEXT_MESSAGE_START: {\n const messageId = (event as { messageId?: string }).messageId;\n if (typeof messageId === \"string\") {\n openMessageIds.add(messageId);\n }\n break;\n }\n case EventType.TEXT_MESSAGE_END: {\n const messageId = (event as { messageId?: string }).messageId;\n if (typeof messageId === \"string\") {\n openMessageIds.delete(messageId);\n }\n break;\n }\n case EventType.TOOL_CALL_START: {\n const toolCallId = (event as { toolCallId?: string }).toolCallId;\n if (typeof toolCallId === \"string\") {\n openToolCalls.set(toolCallId, {\n hasEnd: false,\n hasResult: false,\n });\n }\n break;\n }\n case EventType.TOOL_CALL_END: {\n const toolCallId = (event as { toolCallId?: string }).toolCallId;\n const info = toolCallId ? openToolCalls.get(toolCallId) : undefined;\n if (info) {\n info.hasEnd = true;\n }\n break;\n }\n case EventType.TOOL_CALL_RESULT: {\n const toolCallId = (event as { toolCallId?: string }).toolCallId;\n const info = toolCallId ? openToolCalls.get(toolCallId) : undefined;\n if (info) {\n info.hasResult = true;\n }\n break;\n }\n default:\n break;\n }\n }\n\n const hasRunFinished = events.some(\n (event) => event.type === EventType.RUN_FINISHED,\n );\n const hasRunError = events.some(\n (event) => event.type === EventType.RUN_ERROR,\n );\n const hasTerminalEvent = hasRunFinished || hasRunError;\n const terminalEventMissing = !hasTerminalEvent;\n\n for (const messageId of openMessageIds) {\n const endEvent = {\n type: EventType.TEXT_MESSAGE_END,\n messageId,\n } as BaseEvent;\n events.push(endEvent);\n appended.push(endEvent);\n }\n\n for (const [toolCallId, info] of openToolCalls) {\n if (!info.hasEnd) {\n const endEvent = {\n type: EventType.TOOL_CALL_END,\n toolCallId,\n } as BaseEvent;\n events.push(endEvent);\n appended.push(endEvent);\n }\n\n if (terminalEventMissing && !info.hasResult) {\n const resultEvent = {\n type: EventType.TOOL_CALL_RESULT,\n toolCallId,\n messageId: `${toolCallId ?? randomUUID()}-result`,\n role: \"tool\",\n content: JSON.stringify(\n stopRequested\n ? {\n status: \"stopped\",\n reason: \"stop_requested\",\n message: resolvedStopMessage,\n }\n : {\n status: \"error\",\n reason: \"missing_terminal_event\",\n message: resolvedAbruptMessage,\n },\n ),\n } as BaseEvent;\n events.push(resultEvent);\n appended.push(resultEvent);\n }\n }\n\n if (terminalEventMissing) {\n if (stopRequested) {\n const finishedEvent = {\n type: EventType.RUN_FINISHED,\n } as BaseEvent;\n events.push(finishedEvent);\n appended.push(finishedEvent);\n } else {\n const errorEvent: RunErrorEvent = {\n type: EventType.RUN_ERROR,\n message: resolvedAbruptMessage,\n code: \"INCOMPLETE_STREAM\",\n };\n events.push(errorEvent);\n appended.push(errorEvent);\n }\n }\n\n return appended;\n}\n"],"mappings":";;;;;AAQA,MAAM,qBAAqB;AAC3B,MAAM,0BAA0B;AAEhC,SAAgB,kBACd,QACA,UAA8B,EAAE,EACnB;CACb,MAAM,EAAE,gBAAgB,OAAO,wBAAwB;CAEvD,MAAM,sBAAsB,uBAAuB;CACnD,MAAM,wBACJ,uBAAuB,wBAAwB,qBAC3C,sBACA;CAEN,MAAM,WAAwB,EAAE;CAEhC,MAAM,iCAAiB,IAAI,KAAa;CACxC,MAAM,gCAAgB,IAAI,KAMvB;AAEH,MAAK,MAAM,SAAS,OAClB,SAAQ,MAAM,MAAd;EACE,KAAKA,wBAAU,oBAAoB;GACjC,MAAM,YAAa,MAAiC;AACpD,OAAI,OAAO,cAAc,SACvB,gBAAe,IAAI,UAAU;AAE/B;;EAEF,KAAKA,wBAAU,kBAAkB;GAC/B,MAAM,YAAa,MAAiC;AACpD,OAAI,OAAO,cAAc,SACvB,gBAAe,OAAO,UAAU;AAElC;;EAEF,KAAKA,wBAAU,iBAAiB;GAC9B,MAAM,aAAc,MAAkC;AACtD,OAAI,OAAO,eAAe,SACxB,eAAc,IAAI,YAAY;IAC5B,QAAQ;IACR,WAAW;IACZ,CAAC;AAEJ;;EAEF,KAAKA,wBAAU,eAAe;GAC5B,MAAM,aAAc,MAAkC;GACtD,MAAM,OAAO,aAAa,cAAc,IAAI,WAAW,GAAG;AAC1D,OAAI,KACF,MAAK,SAAS;AAEhB;;EAEF,KAAKA,wBAAU,kBAAkB;GAC/B,MAAM,aAAc,MAAkC;GACtD,MAAM,OAAO,aAAa,cAAc,IAAI,WAAW,GAAG;AAC1D,OAAI,KACF,MAAK,YAAY;AAEnB;;EAEF,QACE;;CAIN,MAAM,iBAAiB,OAAO,MAC3B,UAAU,MAAM,SAASA,wBAAU,aACrC;CACD,MAAM,cAAc,OAAO,MACxB,UAAU,MAAM,SAASA,wBAAU,UACrC;CAED,MAAM,uBAAuB,EADJ,kBAAkB;AAG3C,MAAK,MAAM,aAAa,gBAAgB;EACtC,MAAM,WAAW;GACf,MAAMA,wBAAU;GAChB;GACD;AACD,SAAO,KAAK,SAAS;AACrB,WAAS,KAAK,SAAS;;AAGzB,MAAK,MAAM,CAAC,YAAY,SAAS,eAAe;AAC9C,MAAI,CAAC,KAAK,QAAQ;GAChB,MAAM,WAAW;IACf,MAAMA,wBAAU;IAChB;IACD;AACD,UAAO,KAAK,SAAS;AACrB,YAAS,KAAK,SAAS;;AAGzB,MAAI,wBAAwB,CAAC,KAAK,WAAW;GAC3C,MAAM,cAAc;IAClB,MAAMA,wBAAU;IAChB;IACA,WAAW,GAAG,cAAcC,8BAAY,CAAC;IACzC,MAAM;IACN,SAAS,KAAK,UACZ,gBACI;KACE,QAAQ;KACR,QAAQ;KACR,SAAS;KACV,GACD;KACE,QAAQ;KACR,QAAQ;KACR,SAAS;KACV,CACN;IACF;AACD,UAAO,KAAK,YAAY;AACxB,YAAS,KAAK,YAAY;;;AAI9B,KAAI,qBACF,KAAI,eAAe;EACjB,MAAM,gBAAgB,EACpB,MAAMD,wBAAU,cACjB;AACD,SAAO,KAAK,cAAc;AAC1B,WAAS,KAAK,cAAc;QACvB;EACL,MAAM,aAA4B;GAChC,MAAMA,wBAAU;GAChB,SAAS;GACT,MAAM;GACP;AACD,SAAO,KAAK,WAAW;AACvB,WAAS,KAAK,WAAW;;AAI7B,QAAO"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseEvent } from "@ag-ui/client";
|
|
2
|
+
|
|
3
|
+
//#region src/finalize-events.d.ts
|
|
4
|
+
interface FinalizeRunOptions {
|
|
5
|
+
stopRequested?: boolean;
|
|
6
|
+
interruptionMessage?: string;
|
|
7
|
+
}
|
|
8
|
+
declare function finalizeRunEvents(events: BaseEvent[], options?: FinalizeRunOptions): BaseEvent[];
|
|
9
|
+
//#endregion
|
|
10
|
+
export { finalizeRunEvents };
|
|
11
|
+
//# sourceMappingURL=finalize-events.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finalize-events.d.cts","names":[],"sources":["../src/finalize-events.ts"],"mappings":";;;UAGU,kBAAA;EACR,aAAA;EACA,mBAAA;AAAA;AAAA,iBAMc,iBAAA,CACd,MAAA,EAAQ,SAAA,IACR,OAAA,GAAS,kBAAA,GACR,SAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseEvent } from "@ag-ui/client";
|
|
2
|
+
|
|
3
|
+
//#region src/finalize-events.d.ts
|
|
4
|
+
interface FinalizeRunOptions {
|
|
5
|
+
stopRequested?: boolean;
|
|
6
|
+
interruptionMessage?: string;
|
|
7
|
+
}
|
|
8
|
+
declare function finalizeRunEvents(events: BaseEvent[], options?: FinalizeRunOptions): BaseEvent[];
|
|
9
|
+
//#endregion
|
|
10
|
+
export { finalizeRunEvents };
|
|
11
|
+
//# sourceMappingURL=finalize-events.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finalize-events.d.mts","names":[],"sources":["../src/finalize-events.ts"],"mappings":";;;UAGU,kBAAA;EACR,aAAA;EACA,mBAAA;AAAA;AAAA,iBAMc,iBAAA,CACd,MAAA,EAAQ,SAAA,IACR,OAAA,GAAS,kBAAA,GACR,SAAA"}
|