@agentskit/chat-protocol 0.1.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.
@@ -0,0 +1,346 @@
1
+ // src/fixtures.ts
2
+ var base = {
3
+ protocol: "agentskit.chat.turn",
4
+ version: 1,
5
+ sessionId: "session-conformance",
6
+ turnId: "turn-conformance",
7
+ emittedAt: "2026-07-11T03:00:00.000Z"
8
+ };
9
+ var validTurnEventFixtures = [
10
+ {
11
+ name: "submit",
12
+ event: {
13
+ ...base,
14
+ eventId: "event-submit",
15
+ sequence: 0,
16
+ event: "client.turn.submit",
17
+ payload: { input: "hello" }
18
+ }
19
+ },
20
+ {
21
+ name: "idle snapshot",
22
+ event: {
23
+ ...base,
24
+ eventId: "event-idle",
25
+ sequence: 1,
26
+ event: "server.turn.snapshot",
27
+ payload: {
28
+ status: "idle",
29
+ usage: { promptTokens: 0, completionTokens: 0, totalTokens: 0 },
30
+ messages: []
31
+ }
32
+ }
33
+ },
34
+ {
35
+ name: "streaming snapshot",
36
+ event: {
37
+ ...base,
38
+ eventId: "event-streaming",
39
+ sequence: 2,
40
+ event: "server.turn.snapshot",
41
+ payload: {
42
+ status: "streaming",
43
+ lineage: { operation: "submit" },
44
+ usage: { promptTokens: 2, completionTokens: 1, totalTokens: 3 },
45
+ messages: [{
46
+ id: "message-assistant",
47
+ role: "assistant",
48
+ content: "AgentsKit",
49
+ status: "streaming",
50
+ createdAt: "2026-07-11T03:00:00.000Z"
51
+ }]
52
+ }
53
+ }
54
+ },
55
+ {
56
+ name: "complete snapshot with tool call",
57
+ event: {
58
+ ...base,
59
+ eventId: "event-complete",
60
+ sequence: 3,
61
+ event: "server.turn.snapshot",
62
+ payload: {
63
+ status: "complete",
64
+ lineage: { operation: "regenerate", parentTurnId: "turn-previous", sourceMessageId: "message-assistant" },
65
+ usage: { promptTokens: 2, completionTokens: 3, totalTokens: 5 },
66
+ messages: [{
67
+ id: "message-assistant",
68
+ role: "assistant",
69
+ content: "AgentsKit received: hello",
70
+ status: "complete",
71
+ toolCalls: [{
72
+ id: "tool-call-1",
73
+ name: "lookup",
74
+ args: { query: "hello" },
75
+ result: "found",
76
+ status: "complete"
77
+ }],
78
+ createdAt: "2026-07-11T03:00:01.000Z"
79
+ }]
80
+ }
81
+ }
82
+ },
83
+ {
84
+ name: "diagnostic",
85
+ event: {
86
+ ...base,
87
+ eventId: "event-diagnostic",
88
+ sequence: 4,
89
+ event: "server.turn.diagnostic",
90
+ payload: {
91
+ version: 1,
92
+ code: "ADAPTER_FAILED",
93
+ message: "The adapter failed.",
94
+ retryable: false
95
+ }
96
+ }
97
+ },
98
+ {
99
+ name: "error snapshot",
100
+ event: {
101
+ ...base,
102
+ eventId: "event-error",
103
+ sequence: 5,
104
+ event: "server.turn.snapshot",
105
+ payload: {
106
+ status: "error",
107
+ usage: { promptTokens: 2, completionTokens: 0, totalTokens: 2 },
108
+ messages: [],
109
+ error: {
110
+ version: 1,
111
+ code: "ADAPTER_FAILED",
112
+ message: "The adapter failed.",
113
+ retryable: false
114
+ }
115
+ }
116
+ }
117
+ }
118
+ ];
119
+ var invalidTurnEventFixtures = [
120
+ {
121
+ name: "invalid payload",
122
+ event: null,
123
+ code: "PROTOCOL_INVALID_PAYLOAD"
124
+ },
125
+ {
126
+ name: "unknown version",
127
+ event: { ...base, eventId: "future", version: 2, sequence: 0, event: "client.turn.submit", payload: { input: "hello" } },
128
+ code: "PROTOCOL_UNSUPPORTED_VERSION"
129
+ },
130
+ {
131
+ name: "unknown event",
132
+ event: { ...base, eventId: "unknown", sequence: 0, event: "server.turn.future", payload: {} },
133
+ code: "PROTOCOL_UNKNOWN_EVENT"
134
+ },
135
+ {
136
+ name: "blank input",
137
+ event: { ...base, eventId: "blank", sequence: 0, event: "client.turn.submit", payload: { input: " " } },
138
+ code: "PROTOCOL_INVALID_PAYLOAD"
139
+ }
140
+ ];
141
+ var validChoiceListFrame = {
142
+ protocol: "agentskit.chat.component",
143
+ version: 1,
144
+ type: "render",
145
+ componentKey: "choice-list",
146
+ instanceId: "destination-choice",
147
+ props: {
148
+ prompt: "Where should we go?",
149
+ choices: [
150
+ { id: "docs", label: "Documentation", description: "Read the component guide." },
151
+ { id: "demo", label: "Demo" }
152
+ ]
153
+ },
154
+ fallback: { kind: "choice-list", summary: "Choose Documentation or Demo." }
155
+ };
156
+ var catalogFrame = (componentKey, props, summary) => ({
157
+ protocol: "agentskit.chat.component",
158
+ version: 1,
159
+ type: "render",
160
+ componentKey,
161
+ instanceId: `${componentKey}-fixture`,
162
+ props,
163
+ fallback: { kind: componentKey, summary }
164
+ });
165
+ var standardComponentFrameFixtures = [
166
+ catalogFrame("button-group", { label: "Actions", buttons: [{ id: "save", label: "Save" }] }, "Choose Save."),
167
+ validChoiceListFrame,
168
+ catalogFrame("form", { title: "Contact", fields: [{ id: "email", label: "Email", type: "email", required: true }], submitLabel: "Send" }, "Contact form."),
169
+ catalogFrame("confirmation", { title: "Delete?", message: "This cannot be undone.", confirmLabel: "Delete", cancelLabel: "Cancel" }, "Confirm deletion."),
170
+ catalogFrame("progress", { label: "Upload", value: 42, status: "Uploading" }, "Upload is 42% complete."),
171
+ catalogFrame("source-list", { label: "Sources", sources: [{ id: "docs", title: "Documentation", url: "/docs" }] }, "Sources: Documentation."),
172
+ catalogFrame("link-card", { title: "Guide", description: "Read the guide.", href: "https://example.com/guide" }, "Guide link."),
173
+ catalogFrame("error-notice", { title: "Failed", message: "Try again.", code: "E_TEST", retryLabel: "Retry" }, "Failed: Try again."),
174
+ catalogFrame("tool-call", { name: "Search", status: "complete", arguments: { q: "AgentsKit" }, result: "Found" }, "Search completed."),
175
+ catalogFrame("approval-request", { title: "Approve send?", description: "Send the email.", approveLabel: "Approve", denyLabel: "Deny" }, "Approval required."),
176
+ catalogFrame("table", { caption: "Users", columns: [{ key: "name", label: "Name" }], rows: [{ name: "Ada" }] }, "Users table with one row."),
177
+ catalogFrame("file-attachment", { name: "report.pdf", mimeType: "application/pdf", sizeBytes: 1024, url: "/report.pdf" }, "Attached report.pdf.")
178
+ ];
179
+ var invalidChoiceListPropsFrame = {
180
+ ...validChoiceListFrame,
181
+ props: { prompt: "", choices: [] }
182
+ };
183
+ var unknownComponentFrame = {
184
+ ...validChoiceListFrame,
185
+ componentKey: "future-component"
186
+ };
187
+ var invalidComponentFrameFixtures = [
188
+ { name: "invalid frame", frame: null, code: "COMPONENT_INVALID_FRAME" },
189
+ { name: "unsupported version", frame: { ...validChoiceListFrame, version: 2 }, code: "COMPONENT_UNSUPPORTED_VERSION" },
190
+ { name: "unknown type", frame: { ...validChoiceListFrame, type: "future" }, code: "COMPONENT_UNKNOWN_TYPE" }
191
+ ];
192
+ var persistentSessionFixture = {
193
+ protocol: "agentskit.chat.session",
194
+ version: 1,
195
+ sessionId: "cross-client",
196
+ definitionId: "protocol-session",
197
+ definitionRevision: 1,
198
+ updatedAt: "2026-07-11T00:00:00.000Z",
199
+ cursor: 1,
200
+ conversation: { state: "complete", decisions: [] },
201
+ confirmations: []
202
+ };
203
+ var deterministicContentHashFixture = "sha256:d1b98e69dcb00985dc5fdad4a8475f926168e6485e85716758ad5e0f35cd4906";
204
+ var deterministicSiteConfigFixture = {
205
+ protocol: "agentskit.chat.site",
206
+ version: 1,
207
+ siteId: "agentskit-docs",
208
+ artifact: { href: "/agentskit-chat.knowledge.json", contentHash: deterministicContentHashFixture },
209
+ fallback: { mode: "backend" }
210
+ };
211
+ var localKnowledgeArtifactFixture = {
212
+ protocol: "agentskit.chat.knowledge",
213
+ version: 1,
214
+ artifactId: "agentskit-docs-2026-07-13",
215
+ siteId: "agentskit-docs",
216
+ contentHash: deterministicContentHashFixture,
217
+ generatedAt: "2026-07-13T00:00:00.000Z",
218
+ expiresAt: "2026-07-14T00:00:00.000Z",
219
+ entries: [
220
+ {
221
+ id: "install-cli",
222
+ kind: "command",
223
+ label: "Install the CLI",
224
+ match: { type: "exact", values: ["install cli", "npm install agentskit"] },
225
+ answer: { markdown: "Run `npm install agentskit`.", citations: [{ id: "quickstart", title: "Quickstart", href: "/docs/quickstart" }] }
226
+ },
227
+ {
228
+ id: "docs-agentskit",
229
+ kind: "document",
230
+ label: "AgentsKit documentation",
231
+ match: { type: "exact", values: ["docs", "agentskit docs"] },
232
+ answer: { markdown: "Open the AgentsKit documentation.", citations: [{ id: "agentskit-docs", title: "AgentsKit docs", href: "https://agentskit.io/docs" }] }
233
+ },
234
+ {
235
+ id: "docs-registry",
236
+ kind: "document",
237
+ label: "Registry documentation",
238
+ match: { type: "exact", values: ["docs", "registry docs"] },
239
+ answer: { markdown: "Open the Registry documentation.", citations: [{ id: "registry-docs", title: "Registry docs", href: "https://registry.agentskit.io" }] }
240
+ }
241
+ ]
242
+ };
243
+ var staleLocalKnowledgeArtifactFixture = {
244
+ ...localKnowledgeArtifactFixture,
245
+ artifactId: "agentskit-docs-stale",
246
+ contentHash: "sha256:c48a310e9497d1588e408bf7eb72ca64c04f25431ef8d17cd351b1d3bab3a3e9",
247
+ generatedAt: "2026-07-11T00:00:00.000Z",
248
+ expiresAt: "2026-07-12T00:00:00.000Z"
249
+ };
250
+ var deterministicAnswerFixtures = {
251
+ local: {
252
+ protocol: "agentskit.chat.answer",
253
+ version: 1,
254
+ outcome: "answer",
255
+ query: "Install CLI",
256
+ normalizedQuery: "install cli",
257
+ answer: localKnowledgeArtifactFixture.entries[0].answer,
258
+ provenance: { source: "local", artifactId: localKnowledgeArtifactFixture.artifactId, contentHash: deterministicContentHashFixture, entryIds: ["install-cli"] },
259
+ confidence: { level: "high", basis: "exact" }
260
+ },
261
+ backend: {
262
+ protocol: "agentskit.chat.answer",
263
+ version: 1,
264
+ outcome: "answer",
265
+ query: "Compare runtimes",
266
+ normalizedQuery: "compare runtimes",
267
+ answer: { markdown: "The backend can answer open-ended comparisons.", citations: [] },
268
+ provenance: { source: "backend", provider: "ask", model: "configured-by-host" },
269
+ confidence: { level: "high", basis: "backend" }
270
+ },
271
+ ambiguous: {
272
+ protocol: "agentskit.chat.answer",
273
+ version: 1,
274
+ outcome: "choices",
275
+ query: "docs",
276
+ normalizedQuery: "docs",
277
+ message: "More than one exact local answer matches. Choose one to continue.",
278
+ suggestions: [
279
+ { id: "docs-agentskit", label: "AgentsKit documentation", value: "agentskit docs" },
280
+ { id: "docs-registry", label: "Registry documentation", value: "registry docs" }
281
+ ],
282
+ provenance: { source: "local", artifactId: localKnowledgeArtifactFixture.artifactId, contentHash: deterministicContentHashFixture, entryIds: ["docs-agentskit", "docs-registry"] },
283
+ confidence: { level: "medium", basis: "ambiguous" }
284
+ },
285
+ miss: {
286
+ protocol: "agentskit.chat.answer",
287
+ version: 1,
288
+ outcome: "escalation",
289
+ query: "Why?",
290
+ normalizedQuery: "why?",
291
+ message: "No exact local answer was found. A backend answer is required.",
292
+ reason: "miss",
293
+ confidence: { level: "low", basis: "miss" }
294
+ },
295
+ stale: {
296
+ protocol: "agentskit.chat.answer",
297
+ version: 1,
298
+ outcome: "escalation",
299
+ query: "install cli",
300
+ normalizedQuery: "install cli",
301
+ message: "Local knowledge is stale. A backend answer is required.",
302
+ reason: "stale",
303
+ confidence: { level: "low", basis: "stale" }
304
+ },
305
+ corrupt: {
306
+ protocol: "agentskit.chat.answer",
307
+ version: 1,
308
+ outcome: "escalation",
309
+ query: "install cli",
310
+ normalizedQuery: "install cli",
311
+ message: "Local knowledge is corrupt. A backend answer is required.",
312
+ reason: "corrupt",
313
+ confidence: { level: "low", basis: "corrupt" }
314
+ },
315
+ offline: {
316
+ protocol: "agentskit.chat.answer",
317
+ version: 1,
318
+ outcome: "escalation",
319
+ query: "Why?",
320
+ normalizedQuery: "why?",
321
+ message: "This question needs the backend, which is not available.",
322
+ reason: "offline",
323
+ confidence: { level: "low", basis: "offline" }
324
+ }
325
+ };
326
+ var invalidDeterministicArtifactFixtures = [
327
+ { name: "unsupported version", artifact: { ...localKnowledgeArtifactFixture, version: 2 }, code: "DETERMINISTIC_UNSUPPORTED_VERSION" },
328
+ { name: "corrupt artifact", artifact: { ...localKnowledgeArtifactFixture, entries: [{ unexpected: true }] }, code: "DETERMINISTIC_INVALID_PAYLOAD" },
329
+ { name: "hash mismatch", artifact: localKnowledgeArtifactFixture, expectedContentHash: `sha256:${"b".repeat(64)}`, code: "DETERMINISTIC_HASH_MISMATCH" }
330
+ ];
331
+ export {
332
+ deterministicAnswerFixtures,
333
+ deterministicContentHashFixture,
334
+ deterministicSiteConfigFixture,
335
+ invalidChoiceListPropsFrame,
336
+ invalidComponentFrameFixtures,
337
+ invalidDeterministicArtifactFixtures,
338
+ invalidTurnEventFixtures,
339
+ localKnowledgeArtifactFixture,
340
+ persistentSessionFixture,
341
+ staleLocalKnowledgeArtifactFixture,
342
+ standardComponentFrameFixtures,
343
+ unknownComponentFrame,
344
+ validChoiceListFrame,
345
+ validTurnEventFixtures
346
+ };