ag-ui-validate 0.2.0 → 0.4.0
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 +82 -23
- package/dist/{catalog-BglXBNbL.js → catalog-3e6INLCp.js} +122 -4
- package/dist/catalog-3e6INLCp.js.map +1 -0
- package/dist/{catalog-Ci9dqc1a.cjs → catalog-DH5gDIbo.cjs} +122 -4
- package/dist/catalog-DH5gDIbo.cjs.map +1 -0
- package/dist/cli.js +641 -63
- package/dist/cli.js.map +1 -1
- package/dist/{index-Hmqj3r_r.d.cts → index-Cydfs-rB.d.ts} +4 -4
- package/dist/{index-oNG1kOp9.d.ts → index-DsVmjcLO.d.cts} +4 -4
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/report.cjs +11 -2
- package/dist/report.cjs.map +1 -1
- package/dist/report.d.cts +21 -12
- package/dist/report.d.ts +21 -12
- package/dist/report.js +11 -2
- package/dist/report.js.map +1 -1
- package/dist/{src-rGZ2G4qA.js → src-CezZ73Mm.js} +494 -59
- package/dist/src-CezZ73Mm.js.map +1 -0
- package/dist/{src-HmI-kxef.cjs → src-CyugLoks.cjs} +494 -59
- package/dist/src-CyugLoks.cjs.map +1 -0
- package/dist/transport.cjs +1 -1
- package/dist/transport.cjs.map +1 -1
- package/dist/transport.d.cts +1 -1
- package/dist/transport.d.ts +1 -1
- package/dist/transport.js +1 -1
- package/dist/transport.js.map +1 -1
- package/dist/{types-oH_QTnn2.d.ts → types-CUIgyj2N.d.cts} +3 -1
- package/dist/{types-oH_QTnn2.d.cts → types-CUIgyj2N.d.ts} +3 -1
- package/dist/vitest.js +616 -61
- package/dist/vitest.js.map +1 -1
- package/{src → js/src}/cli-args.ts +16 -0
- package/{src → js/src}/cli.ts +1 -1
- package/{src → js/src}/index.ts +5 -0
- package/{src → js/src}/protocol/event-table.ts +93 -2
- package/js/src/report/json.ts +31 -0
- package/{src → js/src}/report/sarif.ts +3 -6
- package/{src → js/src}/rules/catalog.ts +5 -1
- package/{src → js/src}/rules/checks/context.ts +48 -3
- package/{src → js/src}/rules/checks/lifecycle.ts +5 -2
- package/js/src/rules/checks/subagents.ts +78 -0
- package/{src → js/src}/rules/checks/text.ts +11 -3
- package/{src → js/src}/rules/checks/toolcalls.ts +8 -2
- package/{src → js/src}/transport/index.ts +1 -1
- package/package.json +15 -14
- package/{src/rules → spec}/catalog.json +109 -2
- package/spec/event-categories.json +60 -0
- package/spec/fixtures/README.md +91 -0
- package/spec/fixtures/invalid/AGUI001-first-event-not-run-started/expected.json +10 -0
- package/spec/fixtures/invalid/AGUI001-first-event-not-run-started/stream.jsonl +4 -0
- package/spec/fixtures/invalid/AGUI002-duplicate-run-started/expected.json +11 -0
- package/spec/fixtures/invalid/AGUI002-duplicate-run-started/stream.jsonl +3 -0
- package/spec/fixtures/invalid/AGUI003-run-never-terminated/expected.json +10 -0
- package/spec/fixtures/invalid/AGUI003-run-never-terminated/stream.jsonl +4 -0
- package/spec/fixtures/invalid/AGUI004-event-after-terminal/expected.json +11 -0
- package/spec/fixtures/invalid/AGUI004-event-after-terminal/stream.jsonl +3 -0
- package/spec/fixtures/invalid/AGUI005-finished-and-error/expected.json +11 -0
- package/spec/fixtures/invalid/AGUI005-finished-and-error/stream.jsonl +3 -0
- package/spec/fixtures/invalid/AGUI006-step-finished-unmatched/expected.json +11 -0
- package/spec/fixtures/invalid/AGUI006-step-finished-unmatched/stream.jsonl +3 -0
- package/spec/fixtures/invalid/AGUI007-step-unterminated/expected.json +10 -0
- package/spec/fixtures/invalid/AGUI007-step-unterminated/stream.jsonl +3 -0
- package/spec/fixtures/invalid/AGUI008-unstable-run-ids/expected.json +12 -0
- package/spec/fixtures/invalid/AGUI008-unstable-run-ids/stream.jsonl +2 -0
- package/spec/fixtures/invalid/AGUI101-content-without-start/expected.json +11 -0
- package/spec/fixtures/invalid/AGUI101-content-without-start/stream.jsonl +3 -0
- package/spec/fixtures/invalid/AGUI102-end-without-start/expected.json +11 -0
- package/spec/fixtures/invalid/AGUI102-end-without-start/stream.jsonl +3 -0
- package/spec/fixtures/invalid/AGUI103-message-unterminated/expected.json +10 -0
- package/spec/fixtures/invalid/AGUI103-message-unterminated/stream.jsonl +4 -0
- package/spec/fixtures/invalid/AGUI104-duplicate-message-id/expected.json +12 -0
- package/spec/fixtures/invalid/AGUI104-duplicate-message-id/stream.jsonl +6 -0
- package/spec/fixtures/invalid/AGUI105-empty-content-delta/expected.json +12 -0
- package/spec/fixtures/invalid/AGUI105-empty-content-delta/stream.jsonl +5 -0
- package/spec/fixtures/invalid/AGUI106-interleaved-same-message-id/expected.json +12 -0
- package/spec/fixtures/invalid/AGUI106-interleaved-same-message-id/stream.jsonl +5 -0
- package/spec/fixtures/invalid/AGUI201-args-without-start/expected.json +11 -0
- package/spec/fixtures/invalid/AGUI201-args-without-start/stream.jsonl +3 -0
- package/spec/fixtures/invalid/AGUI202-end-without-start/expected.json +11 -0
- package/spec/fixtures/invalid/AGUI202-end-without-start/stream.jsonl +3 -0
- package/spec/fixtures/invalid/AGUI203-unterminated-tool-call/expected.json +10 -0
- package/spec/fixtures/invalid/AGUI203-unterminated-tool-call/stream.jsonl +4 -0
- package/spec/fixtures/invalid/AGUI204-args-not-json/expected.json +10 -0
- package/spec/fixtures/invalid/AGUI204-args-not-json/stream.jsonl +6 -0
- package/spec/fixtures/invalid/AGUI205-duplicate-tool-call-id/expected.json +12 -0
- package/spec/fixtures/invalid/AGUI205-duplicate-tool-call-id/stream.jsonl +5 -0
- package/spec/fixtures/invalid/AGUI206-result-before-end/expected.json +12 -0
- package/spec/fixtures/invalid/AGUI206-result-before-end/stream.jsonl +5 -0
- package/spec/fixtures/invalid/AGUI207-result-unknown-id/expected.json +11 -0
- package/spec/fixtures/invalid/AGUI207-result-unknown-id/stream.jsonl +3 -0
- package/spec/fixtures/invalid/AGUI208-unknown-parent-message-id/expected.json +11 -0
- package/spec/fixtures/invalid/AGUI208-unknown-parent-message-id/stream.jsonl +4 -0
- package/spec/fixtures/invalid/AGUI301-delta-before-snapshot/expected.json +10 -0
- package/spec/fixtures/invalid/AGUI301-delta-before-snapshot/stream.jsonl +3 -0
- package/spec/fixtures/invalid/AGUI302-delta-failed-to-apply/expected.json +11 -0
- package/spec/fixtures/invalid/AGUI302-delta-failed-to-apply/stream.jsonl +4 -0
- package/spec/fixtures/invalid/AGUI303-invalid-patch-document/expected.json +11 -0
- package/spec/fixtures/invalid/AGUI303-invalid-patch-document/stream.jsonl +4 -0
- package/spec/fixtures/invalid/AGUI304-midrun-snapshot-discards-deltas/expected.json +10 -0
- package/spec/fixtures/invalid/AGUI304-midrun-snapshot-discards-deltas/stream.jsonl +5 -0
- package/spec/fixtures/invalid/AGUI305-shared-state-never-established/expected.json +9 -0
- package/spec/fixtures/invalid/AGUI305-shared-state-never-established/options.json +5 -0
- package/spec/fixtures/invalid/AGUI305-shared-state-never-established/stream.jsonl +5 -0
- package/spec/fixtures/invalid/AGUI401-reasoning-content-without-start/expected.json +11 -0
- package/spec/fixtures/invalid/AGUI401-reasoning-content-without-start/stream.jsonl +3 -0
- package/spec/fixtures/invalid/AGUI402-reasoning-unterminated/expected.json +10 -0
- package/spec/fixtures/invalid/AGUI402-reasoning-unterminated/stream.jsonl +3 -0
- package/spec/fixtures/invalid/AGUI501-missing-data-prefix/expected.json +9 -0
- package/spec/fixtures/invalid/AGUI501-missing-data-prefix/scenario.json +17 -0
- package/spec/fixtures/invalid/AGUI502-payload-not-json/expected.json +10 -0
- package/spec/fixtures/invalid/AGUI502-payload-not-json/stream.jsonl +3 -0
- package/spec/fixtures/invalid/AGUI503-unknown-event-type/expected.json +10 -0
- package/spec/fixtures/invalid/AGUI503-unknown-event-type/stream.jsonl +3 -0
- package/spec/fixtures/invalid/AGUI504-schema-violation/expected.json +11 -0
- package/spec/fixtures/invalid/AGUI504-schema-violation/stream.jsonl +4 -0
- package/spec/fixtures/invalid/AGUI505-unexpected-content-type/expected.json +9 -0
- package/spec/fixtures/invalid/AGUI505-unexpected-content-type/scenario.json +25 -0
- package/spec/fixtures/invalid/AGUI506-keepalive-gap/expected.json +9 -0
- package/spec/fixtures/invalid/AGUI506-keepalive-gap/scenario.json +25 -0
- package/spec/fixtures/invalid/AGUI507-buffered-response/expected.json +9 -0
- package/spec/fixtures/invalid/AGUI507-buffered-response/scenario.json +9 -0
- package/spec/fixtures/invalid/AGUI508-connection-dropped/expected.json +17 -0
- package/spec/fixtures/invalid/AGUI508-connection-dropped/scenario.json +10 -0
- package/spec/fixtures/invalid/AGUI601-duplicate-subagent-started/expected.json +12 -0
- package/spec/fixtures/invalid/AGUI601-duplicate-subagent-started/stream.jsonl +5 -0
- package/spec/fixtures/invalid/AGUI602-finished-without-start/expected.json +11 -0
- package/spec/fixtures/invalid/AGUI602-finished-without-start/stream.jsonl +3 -0
- package/spec/fixtures/invalid/AGUI603-error-without-start/expected.json +11 -0
- package/spec/fixtures/invalid/AGUI603-error-without-start/stream.jsonl +3 -0
- package/spec/fixtures/invalid/AGUI604-subagent-unterminated/expected.json +10 -0
- package/spec/fixtures/invalid/AGUI604-subagent-unterminated/stream.jsonl +3 -0
- package/spec/fixtures/invalid/AGUI605-unknown-parent-subagent-run-id/expected.json +11 -0
- package/spec/fixtures/invalid/AGUI605-unknown-parent-subagent-run-id/stream.jsonl +4 -0
- package/spec/fixtures/invalid/AGUI606-continuation-owner-mismatch/expected.json +11 -0
- package/spec/fixtures/invalid/AGUI606-continuation-owner-mismatch/stream.jsonl +6 -0
- package/spec/fixtures/invalid/AGUI901-raw-wraps-typed-event/expected.json +11 -0
- package/spec/fixtures/invalid/AGUI901-raw-wraps-typed-event/stream.jsonl +3 -0
- package/spec/fixtures/invalid/AGUI902-no-timestamps/expected.json +9 -0
- package/spec/fixtures/invalid/AGUI902-no-timestamps/stream.jsonl +2 -0
- package/spec/fixtures/invalid/AGUI903-custom-name-not-namespaced/expected.json +11 -0
- package/spec/fixtures/invalid/AGUI903-custom-name-not-namespaced/stream.jsonl +3 -0
- package/spec/fixtures/valid/agentic-chat.jsonl +14 -0
- package/spec/fixtures/valid/agentic-generative-ui.jsonl +13 -0
- package/spec/fixtures/valid/backend-tool-rendering.jsonl +14 -0
- package/spec/fixtures/valid/human-in-the-loop.jsonl +13 -0
- package/spec/fixtures/valid/predictive-state-updates.expected.json +11 -0
- package/spec/fixtures/valid/predictive-state-updates.jsonl +11 -0
- package/spec/fixtures/valid/shared-state.jsonl +8 -0
- package/spec/fixtures/valid/tool-based-generative-ui.jsonl +5 -0
- package/dist/catalog-BglXBNbL.js.map +0 -1
- package/dist/catalog-Ci9dqc1a.cjs.map +0 -1
- package/dist/src-HmI-kxef.cjs.map +0 -1
- package/dist/src-rGZ2G4qA.js.map +0 -1
- package/src/report/json.ts +0 -20
- /package/{src → js/src}/protocol/jsonpatch.ts +0 -0
- /package/{src → js/src}/report/index.ts +0 -0
- /package/{src → js/src}/report/junit.ts +0 -0
- /package/{src → js/src}/report/pretty.ts +0 -0
- /package/{src → js/src}/rules/checks/reasoning.ts +0 -0
- /package/{src → js/src}/rules/checks/state.ts +0 -0
- /package/{src → js/src}/rules/checks/transport.ts +0 -0
- /package/{src → js/src}/transport/ndjson.ts +0 -0
- /package/{src → js/src}/transport/sse.ts +0 -0
- /package/{src → js/src}/types.ts +0 -0
- /package/{src → js/src}/vitest/index.ts +0 -0
- /package/{src → js/src}/vitest/matcher.ts +0 -0
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import { n as RULES, r as formatMessage, t as CATALOG } from "./catalog-
|
|
1
|
+
import { n as RULES, r as formatMessage, t as CATALOG } from "./catalog-3e6INLCp.js";
|
|
2
2
|
//#region src/protocol/event-table.ts
|
|
3
3
|
/** Version of @ag-ui/core this table was derived from. */
|
|
4
|
-
const SDK_VERSION = "0.0.
|
|
4
|
+
const SDK_VERSION = "0.0.59";
|
|
5
5
|
/** Canonical wire event types and their schemas, derived from @ag-ui/core. */
|
|
6
6
|
const EVENT_TABLE = {
|
|
7
7
|
"TEXT_MESSAGE_START": {
|
|
8
8
|
category: "text",
|
|
9
9
|
specUrl: "https://docs.ag-ui.com/concepts/events#textmessagestart",
|
|
10
10
|
fields: {
|
|
11
|
+
"metadata": {
|
|
12
|
+
kind: "object",
|
|
13
|
+
required: false
|
|
14
|
+
},
|
|
11
15
|
"messageId": {
|
|
12
16
|
kind: "string",
|
|
13
17
|
required: true
|
|
@@ -25,6 +29,10 @@ const EVENT_TABLE = {
|
|
|
25
29
|
"name": {
|
|
26
30
|
kind: "string",
|
|
27
31
|
required: false
|
|
32
|
+
},
|
|
33
|
+
"subagentRunId": {
|
|
34
|
+
kind: "string",
|
|
35
|
+
required: false
|
|
28
36
|
}
|
|
29
37
|
}
|
|
30
38
|
},
|
|
@@ -32,6 +40,10 @@ const EVENT_TABLE = {
|
|
|
32
40
|
category: "text",
|
|
33
41
|
specUrl: "https://docs.ag-ui.com/concepts/events#textmessagecontent",
|
|
34
42
|
fields: {
|
|
43
|
+
"metadata": {
|
|
44
|
+
kind: "object",
|
|
45
|
+
required: false
|
|
46
|
+
},
|
|
35
47
|
"messageId": {
|
|
36
48
|
kind: "string",
|
|
37
49
|
required: true
|
|
@@ -39,21 +51,39 @@ const EVENT_TABLE = {
|
|
|
39
51
|
"delta": {
|
|
40
52
|
kind: "string",
|
|
41
53
|
required: true
|
|
54
|
+
},
|
|
55
|
+
"subagentRunId": {
|
|
56
|
+
kind: "string",
|
|
57
|
+
required: false
|
|
42
58
|
}
|
|
43
59
|
}
|
|
44
60
|
},
|
|
45
61
|
"TEXT_MESSAGE_END": {
|
|
46
62
|
category: "text",
|
|
47
63
|
specUrl: "https://docs.ag-ui.com/concepts/events#textmessageend",
|
|
48
|
-
fields: {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
64
|
+
fields: {
|
|
65
|
+
"metadata": {
|
|
66
|
+
kind: "object",
|
|
67
|
+
required: false
|
|
68
|
+
},
|
|
69
|
+
"messageId": {
|
|
70
|
+
kind: "string",
|
|
71
|
+
required: true
|
|
72
|
+
},
|
|
73
|
+
"subagentRunId": {
|
|
74
|
+
kind: "string",
|
|
75
|
+
required: false
|
|
76
|
+
}
|
|
77
|
+
}
|
|
52
78
|
},
|
|
53
79
|
"TEXT_MESSAGE_CHUNK": {
|
|
54
80
|
category: "text",
|
|
55
81
|
specUrl: "https://docs.ag-ui.com/concepts/events#textmessagechunk",
|
|
56
82
|
fields: {
|
|
83
|
+
"metadata": {
|
|
84
|
+
kind: "object",
|
|
85
|
+
required: false
|
|
86
|
+
},
|
|
57
87
|
"messageId": {
|
|
58
88
|
kind: "string",
|
|
59
89
|
required: false
|
|
@@ -75,6 +105,10 @@ const EVENT_TABLE = {
|
|
|
75
105
|
"name": {
|
|
76
106
|
kind: "string",
|
|
77
107
|
required: false
|
|
108
|
+
},
|
|
109
|
+
"subagentRunId": {
|
|
110
|
+
kind: "string",
|
|
111
|
+
required: false
|
|
78
112
|
}
|
|
79
113
|
}
|
|
80
114
|
},
|
|
@@ -82,6 +116,10 @@ const EVENT_TABLE = {
|
|
|
82
116
|
category: "toolcall",
|
|
83
117
|
specUrl: "https://docs.ag-ui.com/concepts/events#toolcallstart",
|
|
84
118
|
fields: {
|
|
119
|
+
"metadata": {
|
|
120
|
+
kind: "object",
|
|
121
|
+
required: false
|
|
122
|
+
},
|
|
85
123
|
"toolCallId": {
|
|
86
124
|
kind: "string",
|
|
87
125
|
required: true
|
|
@@ -93,6 +131,10 @@ const EVENT_TABLE = {
|
|
|
93
131
|
"parentMessageId": {
|
|
94
132
|
kind: "string",
|
|
95
133
|
required: false
|
|
134
|
+
},
|
|
135
|
+
"subagentRunId": {
|
|
136
|
+
kind: "string",
|
|
137
|
+
required: false
|
|
96
138
|
}
|
|
97
139
|
}
|
|
98
140
|
},
|
|
@@ -100,6 +142,10 @@ const EVENT_TABLE = {
|
|
|
100
142
|
category: "toolcall",
|
|
101
143
|
specUrl: "https://docs.ag-ui.com/concepts/events#toolcallargs",
|
|
102
144
|
fields: {
|
|
145
|
+
"metadata": {
|
|
146
|
+
kind: "object",
|
|
147
|
+
required: false
|
|
148
|
+
},
|
|
103
149
|
"toolCallId": {
|
|
104
150
|
kind: "string",
|
|
105
151
|
required: true
|
|
@@ -107,21 +153,39 @@ const EVENT_TABLE = {
|
|
|
107
153
|
"delta": {
|
|
108
154
|
kind: "string",
|
|
109
155
|
required: true
|
|
156
|
+
},
|
|
157
|
+
"subagentRunId": {
|
|
158
|
+
kind: "string",
|
|
159
|
+
required: false
|
|
110
160
|
}
|
|
111
161
|
}
|
|
112
162
|
},
|
|
113
163
|
"TOOL_CALL_END": {
|
|
114
164
|
category: "toolcall",
|
|
115
165
|
specUrl: "https://docs.ag-ui.com/concepts/events#toolcallend",
|
|
116
|
-
fields: {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
166
|
+
fields: {
|
|
167
|
+
"metadata": {
|
|
168
|
+
kind: "object",
|
|
169
|
+
required: false
|
|
170
|
+
},
|
|
171
|
+
"toolCallId": {
|
|
172
|
+
kind: "string",
|
|
173
|
+
required: true
|
|
174
|
+
},
|
|
175
|
+
"subagentRunId": {
|
|
176
|
+
kind: "string",
|
|
177
|
+
required: false
|
|
178
|
+
}
|
|
179
|
+
}
|
|
120
180
|
},
|
|
121
181
|
"TOOL_CALL_CHUNK": {
|
|
122
182
|
category: "toolcall",
|
|
123
183
|
specUrl: "https://docs.ag-ui.com/concepts/events#toolcallchunk",
|
|
124
184
|
fields: {
|
|
185
|
+
"metadata": {
|
|
186
|
+
kind: "object",
|
|
187
|
+
required: false
|
|
188
|
+
},
|
|
125
189
|
"toolCallId": {
|
|
126
190
|
kind: "string",
|
|
127
191
|
required: false
|
|
@@ -137,6 +201,10 @@ const EVENT_TABLE = {
|
|
|
137
201
|
"delta": {
|
|
138
202
|
kind: "string",
|
|
139
203
|
required: false
|
|
204
|
+
},
|
|
205
|
+
"subagentRunId": {
|
|
206
|
+
kind: "string",
|
|
207
|
+
required: false
|
|
140
208
|
}
|
|
141
209
|
}
|
|
142
210
|
},
|
|
@@ -144,6 +212,10 @@ const EVENT_TABLE = {
|
|
|
144
212
|
category: "toolcall",
|
|
145
213
|
specUrl: "https://docs.ag-ui.com/concepts/events#toolcallresult",
|
|
146
214
|
fields: {
|
|
215
|
+
"metadata": {
|
|
216
|
+
kind: "object",
|
|
217
|
+
required: false
|
|
218
|
+
},
|
|
147
219
|
"messageId": {
|
|
148
220
|
kind: "string",
|
|
149
221
|
required: true
|
|
@@ -160,6 +232,10 @@ const EVENT_TABLE = {
|
|
|
160
232
|
kind: "string",
|
|
161
233
|
required: false,
|
|
162
234
|
enum: ["tool"]
|
|
235
|
+
},
|
|
236
|
+
"subagentRunId": {
|
|
237
|
+
kind: "string",
|
|
238
|
+
required: false
|
|
163
239
|
}
|
|
164
240
|
}
|
|
165
241
|
},
|
|
@@ -167,66 +243,117 @@ const EVENT_TABLE = {
|
|
|
167
243
|
category: "thinking",
|
|
168
244
|
deprecated: "REASONING_START",
|
|
169
245
|
specUrl: "https://docs.ag-ui.com/concepts/events#thinking-events-deprecated",
|
|
170
|
-
fields: {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
246
|
+
fields: {
|
|
247
|
+
"metadata": {
|
|
248
|
+
kind: "object",
|
|
249
|
+
required: false
|
|
250
|
+
},
|
|
251
|
+
"title": {
|
|
252
|
+
kind: "string",
|
|
253
|
+
required: false
|
|
254
|
+
}
|
|
255
|
+
}
|
|
174
256
|
},
|
|
175
257
|
"THINKING_END": {
|
|
176
258
|
category: "thinking",
|
|
177
259
|
deprecated: "REASONING_END",
|
|
178
260
|
specUrl: "https://docs.ag-ui.com/concepts/events#thinking-events-deprecated",
|
|
179
|
-
fields: {
|
|
261
|
+
fields: { "metadata": {
|
|
262
|
+
kind: "object",
|
|
263
|
+
required: false
|
|
264
|
+
} }
|
|
180
265
|
},
|
|
181
266
|
"THINKING_TEXT_MESSAGE_START": {
|
|
182
267
|
category: "thinking",
|
|
183
268
|
deprecated: "REASONING_MESSAGE_START",
|
|
184
269
|
specUrl: "https://docs.ag-ui.com/concepts/events#thinking-events-deprecated",
|
|
185
|
-
fields: {
|
|
270
|
+
fields: { "metadata": {
|
|
271
|
+
kind: "object",
|
|
272
|
+
required: false
|
|
273
|
+
} }
|
|
186
274
|
},
|
|
187
275
|
"THINKING_TEXT_MESSAGE_CONTENT": {
|
|
188
276
|
category: "thinking",
|
|
189
277
|
deprecated: "REASONING_MESSAGE_CONTENT",
|
|
190
278
|
specUrl: "https://docs.ag-ui.com/concepts/events#thinking-events-deprecated",
|
|
191
|
-
fields: {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
279
|
+
fields: {
|
|
280
|
+
"metadata": {
|
|
281
|
+
kind: "object",
|
|
282
|
+
required: false
|
|
283
|
+
},
|
|
284
|
+
"delta": {
|
|
285
|
+
kind: "string",
|
|
286
|
+
required: true
|
|
287
|
+
}
|
|
288
|
+
}
|
|
195
289
|
},
|
|
196
290
|
"THINKING_TEXT_MESSAGE_END": {
|
|
197
291
|
category: "thinking",
|
|
198
292
|
deprecated: "REASONING_MESSAGE_END",
|
|
199
293
|
specUrl: "https://docs.ag-ui.com/concepts/events#thinking-events-deprecated",
|
|
200
|
-
fields: {
|
|
294
|
+
fields: { "metadata": {
|
|
295
|
+
kind: "object",
|
|
296
|
+
required: false
|
|
297
|
+
} }
|
|
201
298
|
},
|
|
202
299
|
"STATE_SNAPSHOT": {
|
|
203
300
|
category: "state",
|
|
204
301
|
specUrl: "https://docs.ag-ui.com/concepts/events#statesnapshot",
|
|
205
|
-
fields: {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
302
|
+
fields: {
|
|
303
|
+
"metadata": {
|
|
304
|
+
kind: "object",
|
|
305
|
+
required: false
|
|
306
|
+
},
|
|
307
|
+
"snapshot": {
|
|
308
|
+
kind: "any",
|
|
309
|
+
required: true
|
|
310
|
+
},
|
|
311
|
+
"subagentRunId": {
|
|
312
|
+
kind: "string",
|
|
313
|
+
required: false
|
|
314
|
+
}
|
|
315
|
+
}
|
|
209
316
|
},
|
|
210
317
|
"STATE_DELTA": {
|
|
211
318
|
category: "state",
|
|
212
319
|
specUrl: "https://docs.ag-ui.com/concepts/events#statedelta",
|
|
213
|
-
fields: {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
320
|
+
fields: {
|
|
321
|
+
"metadata": {
|
|
322
|
+
kind: "object",
|
|
323
|
+
required: false
|
|
324
|
+
},
|
|
325
|
+
"delta": {
|
|
326
|
+
kind: "array",
|
|
327
|
+
required: true
|
|
328
|
+
},
|
|
329
|
+
"subagentRunId": {
|
|
330
|
+
kind: "string",
|
|
331
|
+
required: false
|
|
332
|
+
}
|
|
333
|
+
}
|
|
217
334
|
},
|
|
218
335
|
"MESSAGES_SNAPSHOT": {
|
|
219
336
|
category: "state",
|
|
220
337
|
specUrl: "https://docs.ag-ui.com/concepts/events#messagessnapshot",
|
|
221
|
-
fields: {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
338
|
+
fields: {
|
|
339
|
+
"metadata": {
|
|
340
|
+
kind: "object",
|
|
341
|
+
required: false
|
|
342
|
+
},
|
|
343
|
+
"messages": {
|
|
344
|
+
kind: "array",
|
|
345
|
+
required: true
|
|
346
|
+
}
|
|
347
|
+
}
|
|
225
348
|
},
|
|
226
349
|
"ACTIVITY_SNAPSHOT": {
|
|
227
350
|
category: "activity",
|
|
228
351
|
specUrl: "https://docs.ag-ui.com/concepts/events#activitysnapshot",
|
|
229
352
|
fields: {
|
|
353
|
+
"metadata": {
|
|
354
|
+
kind: "object",
|
|
355
|
+
required: false
|
|
356
|
+
},
|
|
230
357
|
"messageId": {
|
|
231
358
|
kind: "string",
|
|
232
359
|
required: true
|
|
@@ -242,6 +369,10 @@ const EVENT_TABLE = {
|
|
|
242
369
|
"replace": {
|
|
243
370
|
kind: "boolean",
|
|
244
371
|
required: false
|
|
372
|
+
},
|
|
373
|
+
"subagentRunId": {
|
|
374
|
+
kind: "string",
|
|
375
|
+
required: false
|
|
245
376
|
}
|
|
246
377
|
}
|
|
247
378
|
},
|
|
@@ -249,6 +380,10 @@ const EVENT_TABLE = {
|
|
|
249
380
|
category: "activity",
|
|
250
381
|
specUrl: "https://docs.ag-ui.com/concepts/events#activitydelta",
|
|
251
382
|
fields: {
|
|
383
|
+
"metadata": {
|
|
384
|
+
kind: "object",
|
|
385
|
+
required: false
|
|
386
|
+
},
|
|
252
387
|
"messageId": {
|
|
253
388
|
kind: "string",
|
|
254
389
|
required: true
|
|
@@ -260,6 +395,10 @@ const EVENT_TABLE = {
|
|
|
260
395
|
"patch": {
|
|
261
396
|
kind: "array",
|
|
262
397
|
required: true
|
|
398
|
+
},
|
|
399
|
+
"subagentRunId": {
|
|
400
|
+
kind: "string",
|
|
401
|
+
required: false
|
|
263
402
|
}
|
|
264
403
|
}
|
|
265
404
|
},
|
|
@@ -267,6 +406,10 @@ const EVENT_TABLE = {
|
|
|
267
406
|
category: "special",
|
|
268
407
|
specUrl: "https://docs.ag-ui.com/concepts/events#raw",
|
|
269
408
|
fields: {
|
|
409
|
+
"metadata": {
|
|
410
|
+
kind: "object",
|
|
411
|
+
required: false
|
|
412
|
+
},
|
|
270
413
|
"event": {
|
|
271
414
|
kind: "any",
|
|
272
415
|
required: true
|
|
@@ -274,6 +417,10 @@ const EVENT_TABLE = {
|
|
|
274
417
|
"source": {
|
|
275
418
|
kind: "string",
|
|
276
419
|
required: false
|
|
420
|
+
},
|
|
421
|
+
"subagentRunId": {
|
|
422
|
+
kind: "string",
|
|
423
|
+
required: false
|
|
277
424
|
}
|
|
278
425
|
}
|
|
279
426
|
},
|
|
@@ -281,6 +428,10 @@ const EVENT_TABLE = {
|
|
|
281
428
|
category: "special",
|
|
282
429
|
specUrl: "https://docs.ag-ui.com/concepts/events#custom",
|
|
283
430
|
fields: {
|
|
431
|
+
"metadata": {
|
|
432
|
+
kind: "object",
|
|
433
|
+
required: false
|
|
434
|
+
},
|
|
284
435
|
"name": {
|
|
285
436
|
kind: "string",
|
|
286
437
|
required: true
|
|
@@ -288,6 +439,10 @@ const EVENT_TABLE = {
|
|
|
288
439
|
"value": {
|
|
289
440
|
kind: "any",
|
|
290
441
|
required: true
|
|
442
|
+
},
|
|
443
|
+
"subagentRunId": {
|
|
444
|
+
kind: "string",
|
|
445
|
+
required: false
|
|
291
446
|
}
|
|
292
447
|
}
|
|
293
448
|
},
|
|
@@ -295,6 +450,10 @@ const EVENT_TABLE = {
|
|
|
295
450
|
category: "lifecycle",
|
|
296
451
|
specUrl: "https://docs.ag-ui.com/concepts/events#runstarted",
|
|
297
452
|
fields: {
|
|
453
|
+
"metadata": {
|
|
454
|
+
kind: "object",
|
|
455
|
+
required: false
|
|
456
|
+
},
|
|
298
457
|
"threadId": {
|
|
299
458
|
kind: "string",
|
|
300
459
|
required: true
|
|
@@ -317,6 +476,10 @@ const EVENT_TABLE = {
|
|
|
317
476
|
category: "lifecycle",
|
|
318
477
|
specUrl: "https://docs.ag-ui.com/concepts/events#runfinished",
|
|
319
478
|
fields: {
|
|
479
|
+
"metadata": {
|
|
480
|
+
kind: "object",
|
|
481
|
+
required: false
|
|
482
|
+
},
|
|
320
483
|
"threadId": {
|
|
321
484
|
kind: "string",
|
|
322
485
|
required: true
|
|
@@ -343,6 +506,10 @@ const EVENT_TABLE = {
|
|
|
343
506
|
category: "lifecycle",
|
|
344
507
|
specUrl: "https://docs.ag-ui.com/concepts/events#runerror",
|
|
345
508
|
fields: {
|
|
509
|
+
"metadata": {
|
|
510
|
+
kind: "object",
|
|
511
|
+
required: false
|
|
512
|
+
},
|
|
346
513
|
"message": {
|
|
347
514
|
kind: "string",
|
|
348
515
|
required: true
|
|
@@ -360,31 +527,65 @@ const EVENT_TABLE = {
|
|
|
360
527
|
"STEP_STARTED": {
|
|
361
528
|
category: "lifecycle",
|
|
362
529
|
specUrl: "https://docs.ag-ui.com/concepts/events#stepstarted",
|
|
363
|
-
fields: {
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
530
|
+
fields: {
|
|
531
|
+
"metadata": {
|
|
532
|
+
kind: "object",
|
|
533
|
+
required: false
|
|
534
|
+
},
|
|
535
|
+
"stepName": {
|
|
536
|
+
kind: "string",
|
|
537
|
+
required: true
|
|
538
|
+
},
|
|
539
|
+
"subagentRunId": {
|
|
540
|
+
kind: "string",
|
|
541
|
+
required: false
|
|
542
|
+
}
|
|
543
|
+
}
|
|
367
544
|
},
|
|
368
545
|
"STEP_FINISHED": {
|
|
369
546
|
category: "lifecycle",
|
|
370
547
|
specUrl: "https://docs.ag-ui.com/concepts/events#stepfinished",
|
|
371
|
-
fields: {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
548
|
+
fields: {
|
|
549
|
+
"metadata": {
|
|
550
|
+
kind: "object",
|
|
551
|
+
required: false
|
|
552
|
+
},
|
|
553
|
+
"stepName": {
|
|
554
|
+
kind: "string",
|
|
555
|
+
required: true
|
|
556
|
+
},
|
|
557
|
+
"subagentRunId": {
|
|
558
|
+
kind: "string",
|
|
559
|
+
required: false
|
|
560
|
+
}
|
|
561
|
+
}
|
|
375
562
|
},
|
|
376
563
|
"REASONING_START": {
|
|
377
564
|
category: "reasoning",
|
|
378
565
|
specUrl: "https://docs.ag-ui.com/concepts/events#reasoningstart",
|
|
379
|
-
fields: {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
566
|
+
fields: {
|
|
567
|
+
"metadata": {
|
|
568
|
+
kind: "object",
|
|
569
|
+
required: false
|
|
570
|
+
},
|
|
571
|
+
"messageId": {
|
|
572
|
+
kind: "string",
|
|
573
|
+
required: true
|
|
574
|
+
},
|
|
575
|
+
"subagentRunId": {
|
|
576
|
+
kind: "string",
|
|
577
|
+
required: false
|
|
578
|
+
}
|
|
579
|
+
}
|
|
383
580
|
},
|
|
384
581
|
"REASONING_MESSAGE_START": {
|
|
385
582
|
category: "reasoning",
|
|
386
583
|
specUrl: "https://docs.ag-ui.com/concepts/events#reasoningmessagestart",
|
|
387
584
|
fields: {
|
|
585
|
+
"metadata": {
|
|
586
|
+
kind: "object",
|
|
587
|
+
required: false
|
|
588
|
+
},
|
|
388
589
|
"messageId": {
|
|
389
590
|
kind: "string",
|
|
390
591
|
required: true
|
|
@@ -393,6 +594,10 @@ const EVENT_TABLE = {
|
|
|
393
594
|
kind: "string",
|
|
394
595
|
required: true,
|
|
395
596
|
enum: ["reasoning"]
|
|
597
|
+
},
|
|
598
|
+
"subagentRunId": {
|
|
599
|
+
kind: "string",
|
|
600
|
+
required: false
|
|
396
601
|
}
|
|
397
602
|
}
|
|
398
603
|
},
|
|
@@ -400,6 +605,10 @@ const EVENT_TABLE = {
|
|
|
400
605
|
category: "reasoning",
|
|
401
606
|
specUrl: "https://docs.ag-ui.com/concepts/events#reasoningmessagecontent",
|
|
402
607
|
fields: {
|
|
608
|
+
"metadata": {
|
|
609
|
+
kind: "object",
|
|
610
|
+
required: false
|
|
611
|
+
},
|
|
403
612
|
"messageId": {
|
|
404
613
|
kind: "string",
|
|
405
614
|
required: true
|
|
@@ -407,21 +616,39 @@ const EVENT_TABLE = {
|
|
|
407
616
|
"delta": {
|
|
408
617
|
kind: "string",
|
|
409
618
|
required: true
|
|
619
|
+
},
|
|
620
|
+
"subagentRunId": {
|
|
621
|
+
kind: "string",
|
|
622
|
+
required: false
|
|
410
623
|
}
|
|
411
624
|
}
|
|
412
625
|
},
|
|
413
626
|
"REASONING_MESSAGE_END": {
|
|
414
627
|
category: "reasoning",
|
|
415
628
|
specUrl: "https://docs.ag-ui.com/concepts/events#reasoningmessageend",
|
|
416
|
-
fields: {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
629
|
+
fields: {
|
|
630
|
+
"metadata": {
|
|
631
|
+
kind: "object",
|
|
632
|
+
required: false
|
|
633
|
+
},
|
|
634
|
+
"messageId": {
|
|
635
|
+
kind: "string",
|
|
636
|
+
required: true
|
|
637
|
+
},
|
|
638
|
+
"subagentRunId": {
|
|
639
|
+
kind: "string",
|
|
640
|
+
required: false
|
|
641
|
+
}
|
|
642
|
+
}
|
|
420
643
|
},
|
|
421
644
|
"REASONING_MESSAGE_CHUNK": {
|
|
422
645
|
category: "reasoning",
|
|
423
646
|
specUrl: "https://docs.ag-ui.com/concepts/events#reasoningmessagechunk",
|
|
424
647
|
fields: {
|
|
648
|
+
"metadata": {
|
|
649
|
+
kind: "object",
|
|
650
|
+
required: false
|
|
651
|
+
},
|
|
425
652
|
"messageId": {
|
|
426
653
|
kind: "string",
|
|
427
654
|
required: false
|
|
@@ -429,21 +656,39 @@ const EVENT_TABLE = {
|
|
|
429
656
|
"delta": {
|
|
430
657
|
kind: "string",
|
|
431
658
|
required: false
|
|
659
|
+
},
|
|
660
|
+
"subagentRunId": {
|
|
661
|
+
kind: "string",
|
|
662
|
+
required: false
|
|
432
663
|
}
|
|
433
664
|
}
|
|
434
665
|
},
|
|
435
666
|
"REASONING_END": {
|
|
436
667
|
category: "reasoning",
|
|
437
668
|
specUrl: "https://docs.ag-ui.com/concepts/events#reasoningend",
|
|
438
|
-
fields: {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
669
|
+
fields: {
|
|
670
|
+
"metadata": {
|
|
671
|
+
kind: "object",
|
|
672
|
+
required: false
|
|
673
|
+
},
|
|
674
|
+
"messageId": {
|
|
675
|
+
kind: "string",
|
|
676
|
+
required: true
|
|
677
|
+
},
|
|
678
|
+
"subagentRunId": {
|
|
679
|
+
kind: "string",
|
|
680
|
+
required: false
|
|
681
|
+
}
|
|
682
|
+
}
|
|
442
683
|
},
|
|
443
684
|
"REASONING_ENCRYPTED_VALUE": {
|
|
444
685
|
category: "reasoning",
|
|
445
686
|
specUrl: "https://docs.ag-ui.com/concepts/events#reasoningencryptedvalue",
|
|
446
687
|
fields: {
|
|
688
|
+
"metadata": {
|
|
689
|
+
kind: "object",
|
|
690
|
+
required: false
|
|
691
|
+
},
|
|
447
692
|
"subtype": {
|
|
448
693
|
kind: "string",
|
|
449
694
|
required: true,
|
|
@@ -456,6 +701,88 @@ const EVENT_TABLE = {
|
|
|
456
701
|
"encryptedValue": {
|
|
457
702
|
kind: "string",
|
|
458
703
|
required: true
|
|
704
|
+
},
|
|
705
|
+
"subagentRunId": {
|
|
706
|
+
kind: "string",
|
|
707
|
+
required: false
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
},
|
|
711
|
+
"SUBAGENT_STARTED": {
|
|
712
|
+
category: "subagent",
|
|
713
|
+
specUrl: "https://docs.ag-ui.com/concepts/events#subagent-events",
|
|
714
|
+
fields: {
|
|
715
|
+
"metadata": {
|
|
716
|
+
kind: "object",
|
|
717
|
+
required: false
|
|
718
|
+
},
|
|
719
|
+
"subagentRunId": {
|
|
720
|
+
kind: "string",
|
|
721
|
+
required: true
|
|
722
|
+
},
|
|
723
|
+
"name": {
|
|
724
|
+
kind: "string",
|
|
725
|
+
required: true
|
|
726
|
+
},
|
|
727
|
+
"description": {
|
|
728
|
+
kind: "string",
|
|
729
|
+
required: false
|
|
730
|
+
},
|
|
731
|
+
"parentSubagentRunId": {
|
|
732
|
+
kind: "string",
|
|
733
|
+
required: false
|
|
734
|
+
},
|
|
735
|
+
"parentToolCallId": {
|
|
736
|
+
kind: "string",
|
|
737
|
+
required: false
|
|
738
|
+
},
|
|
739
|
+
"parentMessageId": {
|
|
740
|
+
kind: "string",
|
|
741
|
+
required: false
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
},
|
|
745
|
+
"SUBAGENT_FINISHED": {
|
|
746
|
+
category: "subagent",
|
|
747
|
+
specUrl: "https://docs.ag-ui.com/concepts/events#subagent-events",
|
|
748
|
+
fields: {
|
|
749
|
+
"metadata": {
|
|
750
|
+
kind: "object",
|
|
751
|
+
required: false
|
|
752
|
+
},
|
|
753
|
+
"subagentRunId": {
|
|
754
|
+
kind: "string",
|
|
755
|
+
required: true
|
|
756
|
+
},
|
|
757
|
+
"result": {
|
|
758
|
+
kind: "any",
|
|
759
|
+
required: false
|
|
760
|
+
},
|
|
761
|
+
"outcome": {
|
|
762
|
+
kind: "object",
|
|
763
|
+
required: false
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
},
|
|
767
|
+
"SUBAGENT_ERROR": {
|
|
768
|
+
category: "subagent",
|
|
769
|
+
specUrl: "https://docs.ag-ui.com/concepts/events#subagent-events",
|
|
770
|
+
fields: {
|
|
771
|
+
"metadata": {
|
|
772
|
+
kind: "object",
|
|
773
|
+
required: false
|
|
774
|
+
},
|
|
775
|
+
"subagentRunId": {
|
|
776
|
+
kind: "string",
|
|
777
|
+
required: true
|
|
778
|
+
},
|
|
779
|
+
"message": {
|
|
780
|
+
kind: "string",
|
|
781
|
+
required: true
|
|
782
|
+
},
|
|
783
|
+
"code": {
|
|
784
|
+
kind: "string",
|
|
785
|
+
required: false
|
|
459
786
|
}
|
|
460
787
|
}
|
|
461
788
|
}
|
|
@@ -476,10 +803,14 @@ function newRunState(init) {
|
|
|
476
803
|
openMessages: /* @__PURE__ */ new Map(),
|
|
477
804
|
closedMessages: /* @__PURE__ */ new Map(),
|
|
478
805
|
knownMessageIds: /* @__PURE__ */ new Set(),
|
|
806
|
+
messageOwner: /* @__PURE__ */ new Map(),
|
|
479
807
|
openToolCalls: /* @__PURE__ */ new Map(),
|
|
480
808
|
closedToolCalls: /* @__PURE__ */ new Map(),
|
|
481
809
|
knownToolCallIds: /* @__PURE__ */ new Set(),
|
|
482
810
|
openSteps: /* @__PURE__ */ new Map(),
|
|
811
|
+
openSubagents: /* @__PURE__ */ new Map(),
|
|
812
|
+
closedSubagents: /* @__PURE__ */ new Map(),
|
|
813
|
+
knownSubagentRunIds: /* @__PURE__ */ new Set(),
|
|
483
814
|
openReasoningBlocks: /* @__PURE__ */ new Map(),
|
|
484
815
|
openReasoningMessages: /* @__PURE__ */ new Map(),
|
|
485
816
|
state: {
|
|
@@ -499,6 +830,21 @@ function str(event, field) {
|
|
|
499
830
|
const v = event[field];
|
|
500
831
|
return typeof v === "string" ? v : void 0;
|
|
501
832
|
}
|
|
833
|
+
/** AGUI606 — a continuation/close event's explicit subagentRunId must agree
|
|
834
|
+
* with the owner recorded when its entity opened. Only compared when the
|
|
835
|
+
* event explicitly tags itself; omitting the field is never flagged (SQ-15).
|
|
836
|
+
* Shared by text/toolcalls/lifecycle — not the *_CHUNK forms or
|
|
837
|
+
* TOOL_CALL_RESULT, which are independently attributed by spec. */
|
|
838
|
+
function checkOwnerConsistency(emit, type, entityType, entityId, event, owner) {
|
|
839
|
+
const actual = str(event, "subagentRunId");
|
|
840
|
+
if (actual !== void 0 && actual !== owner) emit("AGUI606", {
|
|
841
|
+
type,
|
|
842
|
+
actual,
|
|
843
|
+
entityType,
|
|
844
|
+
entityId,
|
|
845
|
+
expected: owner !== void 0 ? `'${owner}'` : "the run"
|
|
846
|
+
}, { pointer: "/subagentRunId" });
|
|
847
|
+
}
|
|
502
848
|
//#endregion
|
|
503
849
|
//#region src/rules/checks/lifecycle.ts
|
|
504
850
|
function handleStepEvent(api) {
|
|
@@ -510,7 +856,8 @@ function handleStepEvent(api) {
|
|
|
510
856
|
if (open !== void 0) open.count += 1;
|
|
511
857
|
else run.openSteps.set(stepName, {
|
|
512
858
|
count: 1,
|
|
513
|
-
firstIndex: index
|
|
859
|
+
firstIndex: index,
|
|
860
|
+
owner: str(event, "subagentRunId")
|
|
514
861
|
});
|
|
515
862
|
return;
|
|
516
863
|
}
|
|
@@ -520,6 +867,7 @@ function handleStepEvent(api) {
|
|
|
520
867
|
emit("AGUI006", { stepName }, { pointer: "/stepName" });
|
|
521
868
|
return;
|
|
522
869
|
}
|
|
870
|
+
checkOwnerConsistency(emit, type, "stepName", stepName, event, open.owner);
|
|
523
871
|
open.count -= 1;
|
|
524
872
|
if (open.count === 0) run.openSteps.delete(stepName);
|
|
525
873
|
}
|
|
@@ -922,6 +1270,76 @@ function handleStateEvent(api) {
|
|
|
922
1270
|
}
|
|
923
1271
|
}
|
|
924
1272
|
//#endregion
|
|
1273
|
+
//#region src/rules/checks/subagents.ts
|
|
1274
|
+
function handleSubagentEvent(api) {
|
|
1275
|
+
const { type, event, run, emit, index } = api;
|
|
1276
|
+
switch (type) {
|
|
1277
|
+
case "SUBAGENT_STARTED": {
|
|
1278
|
+
const id = str(event, "subagentRunId");
|
|
1279
|
+
if (id === void 0) return;
|
|
1280
|
+
run.knownSubagentRunIds.add(id);
|
|
1281
|
+
const open = run.openSubagents.get(id);
|
|
1282
|
+
if (open !== void 0) {
|
|
1283
|
+
emit("AGUI601", { subagentRunId: id }, {
|
|
1284
|
+
pointer: "/subagentRunId",
|
|
1285
|
+
relatedEventIndex: open.startIndex
|
|
1286
|
+
});
|
|
1287
|
+
return;
|
|
1288
|
+
}
|
|
1289
|
+
const closed = run.closedSubagents.get(id);
|
|
1290
|
+
if (closed !== void 0 && !closed.resumable) {
|
|
1291
|
+
emit("AGUI601", { subagentRunId: id }, {
|
|
1292
|
+
pointer: "/subagentRunId",
|
|
1293
|
+
relatedEventIndex: closed.index
|
|
1294
|
+
});
|
|
1295
|
+
return;
|
|
1296
|
+
}
|
|
1297
|
+
run.openSubagents.set(id, { startIndex: index });
|
|
1298
|
+
if (closed !== void 0) run.closedSubagents.delete(id);
|
|
1299
|
+
const parent = str(event, "parentSubagentRunId");
|
|
1300
|
+
if (parent !== void 0 && !run.knownSubagentRunIds.has(parent)) emit("AGUI605", { parentSubagentRunId: parent }, { pointer: "/parentSubagentRunId" });
|
|
1301
|
+
return;
|
|
1302
|
+
}
|
|
1303
|
+
case "SUBAGENT_FINISHED": {
|
|
1304
|
+
const id = str(event, "subagentRunId");
|
|
1305
|
+
if (id === void 0) return;
|
|
1306
|
+
if (run.openSubagents.get(id) === void 0) {
|
|
1307
|
+
emit("AGUI602", { subagentRunId: id }, { pointer: "/subagentRunId" });
|
|
1308
|
+
return;
|
|
1309
|
+
}
|
|
1310
|
+
run.openSubagents.delete(id);
|
|
1311
|
+
const outcome = event.outcome;
|
|
1312
|
+
const resumable = typeof outcome === "object" && outcome !== null && outcome.type === "suspended";
|
|
1313
|
+
run.closedSubagents.set(id, {
|
|
1314
|
+
index,
|
|
1315
|
+
resumable
|
|
1316
|
+
});
|
|
1317
|
+
return;
|
|
1318
|
+
}
|
|
1319
|
+
case "SUBAGENT_ERROR": {
|
|
1320
|
+
const id = str(event, "subagentRunId");
|
|
1321
|
+
if (id === void 0) return;
|
|
1322
|
+
if (run.openSubagents.get(id) === void 0) {
|
|
1323
|
+
emit("AGUI603", { subagentRunId: id }, { pointer: "/subagentRunId" });
|
|
1324
|
+
return;
|
|
1325
|
+
}
|
|
1326
|
+
run.openSubagents.delete(id);
|
|
1327
|
+
run.closedSubagents.set(id, {
|
|
1328
|
+
index,
|
|
1329
|
+
resumable: false
|
|
1330
|
+
});
|
|
1331
|
+
return;
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
/** AGUI604 — open subagents when the run reaches a clean end. */
|
|
1336
|
+
function endOfRunSubagents(run, emit, atIndex) {
|
|
1337
|
+
for (const [id, open] of run.openSubagents) emit("AGUI604", { subagentRunId: id }, {
|
|
1338
|
+
eventIndex: atIndex,
|
|
1339
|
+
relatedEventIndex: open.startIndex
|
|
1340
|
+
});
|
|
1341
|
+
}
|
|
1342
|
+
//#endregion
|
|
925
1343
|
//#region src/rules/checks/text.ts
|
|
926
1344
|
function handleTextEvent(api) {
|
|
927
1345
|
const { type, event, run, emit, index } = api;
|
|
@@ -944,8 +1362,13 @@ function handleTextEvent(api) {
|
|
|
944
1362
|
});
|
|
945
1363
|
return;
|
|
946
1364
|
}
|
|
947
|
-
|
|
1365
|
+
const owner = str(event, "subagentRunId");
|
|
1366
|
+
run.openMessages.set(id, {
|
|
1367
|
+
startIndex: index,
|
|
1368
|
+
owner
|
|
1369
|
+
});
|
|
948
1370
|
run.knownMessageIds.add(id);
|
|
1371
|
+
run.messageOwner.set(id, owner);
|
|
949
1372
|
return;
|
|
950
1373
|
}
|
|
951
1374
|
case "TEXT_MESSAGE_CONTENT": {
|
|
@@ -964,15 +1387,18 @@ function handleTextEvent(api) {
|
|
|
964
1387
|
pointer: "/delta",
|
|
965
1388
|
relatedEventIndex: open.startIndex
|
|
966
1389
|
});
|
|
1390
|
+
checkOwnerConsistency(emit, type, "messageId", id, event, open.owner);
|
|
967
1391
|
return;
|
|
968
1392
|
}
|
|
969
1393
|
case "TEXT_MESSAGE_END": {
|
|
970
1394
|
const id = str(event, "messageId");
|
|
971
1395
|
if (id === void 0) return;
|
|
972
|
-
|
|
1396
|
+
const open = run.openMessages.get(id);
|
|
1397
|
+
if (open === void 0) {
|
|
973
1398
|
emit("AGUI102", { messageId: id }, { pointer: "/messageId" });
|
|
974
1399
|
return;
|
|
975
1400
|
}
|
|
1401
|
+
checkOwnerConsistency(emit, type, "messageId", id, event, open.owner);
|
|
976
1402
|
run.openMessages.delete(id);
|
|
977
1403
|
run.closedMessages.set(id, index);
|
|
978
1404
|
return;
|
|
@@ -1001,6 +1427,7 @@ function handleTextEvent(api) {
|
|
|
1001
1427
|
startIndex: index
|
|
1002
1428
|
};
|
|
1003
1429
|
run.knownMessageIds.add(id);
|
|
1430
|
+
run.messageOwner.set(id, str(event, "subagentRunId"));
|
|
1004
1431
|
return;
|
|
1005
1432
|
}
|
|
1006
1433
|
}
|
|
@@ -1035,12 +1462,14 @@ function handleToolCallEvent(api) {
|
|
|
1035
1462
|
});
|
|
1036
1463
|
return;
|
|
1037
1464
|
}
|
|
1465
|
+
const parent = str(event, "parentMessageId");
|
|
1466
|
+
const owner = str(event, "subagentRunId") ?? (parent !== void 0 ? run.messageOwner.get(parent) : void 0);
|
|
1038
1467
|
run.openToolCalls.set(id, {
|
|
1039
1468
|
startIndex: index,
|
|
1040
1469
|
args: "",
|
|
1041
|
-
sawArgs: false
|
|
1470
|
+
sawArgs: false,
|
|
1471
|
+
owner
|
|
1042
1472
|
});
|
|
1043
|
-
const parent = str(event, "parentMessageId");
|
|
1044
1473
|
if (parent !== void 0 && !run.knownMessageIds.has(parent)) emit("AGUI208", { parentMessageId: parent }, { pointer: "/parentMessageId" });
|
|
1045
1474
|
return;
|
|
1046
1475
|
}
|
|
@@ -1057,6 +1486,7 @@ function handleToolCallEvent(api) {
|
|
|
1057
1486
|
open.args += delta;
|
|
1058
1487
|
open.sawArgs = true;
|
|
1059
1488
|
}
|
|
1489
|
+
checkOwnerConsistency(emit, type, "toolCallId", id, event, open.owner);
|
|
1060
1490
|
return;
|
|
1061
1491
|
}
|
|
1062
1492
|
case "TOOL_CALL_END": {
|
|
@@ -1067,6 +1497,7 @@ function handleToolCallEvent(api) {
|
|
|
1067
1497
|
emit("AGUI202", { toolCallId: id }, { pointer: "/toolCallId" });
|
|
1068
1498
|
return;
|
|
1069
1499
|
}
|
|
1500
|
+
checkOwnerConsistency(emit, type, "toolCallId", id, event, open.owner);
|
|
1070
1501
|
run.openToolCalls.delete(id);
|
|
1071
1502
|
run.closedToolCalls.set(id, index);
|
|
1072
1503
|
checkArgsJson(id, open, emit, index);
|
|
@@ -1289,6 +1720,7 @@ function createValidator(opts = {}) {
|
|
|
1289
1720
|
endOfRunToolCalls(r, emit, atIndex);
|
|
1290
1721
|
endOfRunSteps(r, emit, atIndex);
|
|
1291
1722
|
endOfRunReasoning(r, emit, atIndex);
|
|
1723
|
+
endOfRunSubagents(r, emit, atIndex);
|
|
1292
1724
|
}
|
|
1293
1725
|
/** Opens the implicit run scope for streams that never announced one. */
|
|
1294
1726
|
function ensureRun(index, type, emit) {
|
|
@@ -1439,6 +1871,9 @@ function createValidator(opts = {}) {
|
|
|
1439
1871
|
break;
|
|
1440
1872
|
case "thinking": break;
|
|
1441
1873
|
case "activity": break;
|
|
1874
|
+
case "subagent":
|
|
1875
|
+
handleSubagentEvent(a);
|
|
1876
|
+
break;
|
|
1442
1877
|
case "special": if (type === "RAW") {
|
|
1443
1878
|
const wrapped = ev.event;
|
|
1444
1879
|
if (typeof wrapped === "object" && wrapped !== null) {
|
|
@@ -1552,4 +1987,4 @@ function createValidator(opts = {}) {
|
|
|
1552
1987
|
//#endregion
|
|
1553
1988
|
export { EVENT_TABLE as a, validatePatchShape as i, CANONICAL_FEATURES as n, EVENT_TYPES as o, applyPatch as r, SDK_VERSION as s, createValidator as t };
|
|
1554
1989
|
|
|
1555
|
-
//# sourceMappingURL=src-
|
|
1990
|
+
//# sourceMappingURL=src-CezZ73Mm.js.map
|