@agent-native/agentkit 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.
Files changed (88) hide show
  1. package/ARCHITECTURE.md +290 -0
  2. package/README.md +822 -0
  3. package/dist/adapters/http.d.ts +56 -0
  4. package/dist/adapters/http.d.ts.map +1 -0
  5. package/dist/adapters/http.js +950 -0
  6. package/dist/adapters/http.js.map +1 -0
  7. package/dist/adapters/index.d.ts +2 -0
  8. package/dist/adapters/index.d.ts.map +1 -0
  9. package/dist/adapters/index.js +2 -0
  10. package/dist/adapters/index.js.map +1 -0
  11. package/dist/client/client.d.ts +240 -0
  12. package/dist/client/client.d.ts.map +1 -0
  13. package/dist/client/client.js +1605 -0
  14. package/dist/client/client.js.map +1 -0
  15. package/dist/client/index.d.ts +3 -0
  16. package/dist/client/index.d.ts.map +1 -0
  17. package/dist/client/index.js +3 -0
  18. package/dist/client/index.js.map +1 -0
  19. package/dist/client/state.d.ts +72 -0
  20. package/dist/client/state.d.ts.map +1 -0
  21. package/dist/client/state.js +385 -0
  22. package/dist/client/state.js.map +1 -0
  23. package/dist/conformance/index.d.ts +41 -0
  24. package/dist/conformance/index.d.ts.map +1 -0
  25. package/dist/conformance/index.js +924 -0
  26. package/dist/conformance/index.js.map +1 -0
  27. package/dist/index.d.ts +3 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +3 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/protocol/agui-codec.d.ts +28 -0
  32. package/dist/protocol/agui-codec.d.ts.map +1 -0
  33. package/dist/protocol/agui-codec.js +250 -0
  34. package/dist/protocol/agui-codec.js.map +1 -0
  35. package/dist/protocol/agui.d.ts +144 -0
  36. package/dist/protocol/agui.d.ts.map +1 -0
  37. package/dist/protocol/agui.js +253 -0
  38. package/dist/protocol/agui.js.map +1 -0
  39. package/dist/protocol/compatibility.d.ts +35 -0
  40. package/dist/protocol/compatibility.d.ts.map +1 -0
  41. package/dist/protocol/compatibility.js +160 -0
  42. package/dist/protocol/compatibility.js.map +1 -0
  43. package/dist/protocol/errors.d.ts +24 -0
  44. package/dist/protocol/errors.d.ts.map +1 -0
  45. package/dist/protocol/errors.js +77 -0
  46. package/dist/protocol/errors.js.map +1 -0
  47. package/dist/protocol/index.d.ts +982 -0
  48. package/dist/protocol/index.d.ts.map +1 -0
  49. package/dist/protocol/index.js +56 -0
  50. package/dist/protocol/index.js.map +1 -0
  51. package/dist/protocol/validation.d.ts +94 -0
  52. package/dist/protocol/validation.d.ts.map +1 -0
  53. package/dist/protocol/validation.js +1871 -0
  54. package/dist/protocol/validation.js.map +1 -0
  55. package/dist/protocol/version.d.ts +7 -0
  56. package/dist/protocol/version.d.ts.map +1 -0
  57. package/dist/protocol/version.js +9 -0
  58. package/dist/protocol/version.js.map +1 -0
  59. package/dist/react/chat.d.ts +34 -0
  60. package/dist/react/chat.d.ts.map +1 -0
  61. package/dist/react/chat.js +23 -0
  62. package/dist/react/chat.js.map +1 -0
  63. package/dist/react/components.d.ts +96 -0
  64. package/dist/react/components.d.ts.map +1 -0
  65. package/dist/react/components.js +1300 -0
  66. package/dist/react/components.js.map +1 -0
  67. package/dist/react/context.d.ts +259 -0
  68. package/dist/react/context.d.ts.map +1 -0
  69. package/dist/react/context.js +359 -0
  70. package/dist/react/context.js.map +1 -0
  71. package/dist/react/headless.d.ts +3 -0
  72. package/dist/react/headless.d.ts.map +1 -0
  73. package/dist/react/headless.js +3 -0
  74. package/dist/react/headless.js.map +1 -0
  75. package/dist/react/index.d.ts +6 -0
  76. package/dist/react/index.d.ts.map +1 -0
  77. package/dist/react/index.js +6 -0
  78. package/dist/react/index.js.map +1 -0
  79. package/dist/react/root.d.ts +58 -0
  80. package/dist/react/root.d.ts.map +1 -0
  81. package/dist/react/root.js +151 -0
  82. package/dist/react/root.js.map +1 -0
  83. package/dist/react/streaming-text.d.ts +19 -0
  84. package/dist/react/streaming-text.d.ts.map +1 -0
  85. package/dist/react/streaming-text.js +259 -0
  86. package/dist/react/streaming-text.js.map +1 -0
  87. package/dist/react/styles.css +1477 -0
  88. package/package.json +112 -0
@@ -0,0 +1,982 @@
1
+ import type { AgentKitProtocolName, AgentKitProtocolVersion } from "./version.js";
2
+ export { AGENTKIT_PROTOCOL_NAME, AGENTKIT_SUPPORTED_PROTOCOL_VERSIONS, AGENTKIT_PROTOCOL_VERSION, isAgentKitProtocolVersion, type AgentKitProtocolName, type AgentKitProtocolVersion, } from "./version.js";
3
+ /** Stable identifiers are strings so hosts can choose their own ID strategy. */
4
+ export type AgentId = string;
5
+ export type ThreadId = string;
6
+ export type RunId = string;
7
+ export type EventId = string;
8
+ export type ToolCallId = string;
9
+ export type ApprovalId = string;
10
+ export type ConnectionRequestId = string;
11
+ export type ActionInvocationId = string;
12
+ export type UploadId = string;
13
+ export type TaskId = string;
14
+ export type AgentInteractionId = string;
15
+ /**
16
+ * A backend-neutral reference carried across trust, tenancy, and observability
17
+ * boundaries. The referenced system owns resolution and authorization.
18
+ */
19
+ export interface AgentProtocolReference {
20
+ id: string;
21
+ kind?: string;
22
+ label?: string;
23
+ uri?: string;
24
+ }
25
+ /** W3C-compatible trace identity without requiring a tracing implementation. */
26
+ export interface AgentTraceReference {
27
+ traceId: string;
28
+ spanId?: string;
29
+ parentSpanId?: string;
30
+ traceState?: string;
31
+ }
32
+ /**
33
+ * Portable provenance references for protocol values. Additional legacy keys
34
+ * remain allowed; new non-standard keys should use an `x-*` namespace.
35
+ */
36
+ export interface AgentProtocolMetadata extends Record<string, unknown> {
37
+ actor?: AgentProtocolReference;
38
+ workspace?: AgentProtocolReference;
39
+ access?: AgentProtocolReference[];
40
+ audit?: AgentProtocolReference;
41
+ trace?: AgentTraceReference;
42
+ context?: AgentProtocolReference[];
43
+ }
44
+ export type AgentRole = "user" | "assistant" | "system" | "tool";
45
+ export interface TextPart {
46
+ type: "text";
47
+ text: string;
48
+ /** Plain text is the safe default; rich formatting must be explicitly authored. */
49
+ format?: "plain" | "markdown";
50
+ }
51
+ export interface ReasoningPart {
52
+ type: "reasoning";
53
+ text: string;
54
+ /** Concise agent-authored summary shown in the collapsed activity row. */
55
+ label?: string;
56
+ visibility?: "visible" | "summary" | "hidden";
57
+ }
58
+ export interface CitationPart {
59
+ type: "citation";
60
+ title: string;
61
+ url?: string;
62
+ sourceId?: string;
63
+ }
64
+ export interface AgentAnnotation {
65
+ id: string;
66
+ kind: "source" | "entity" | "reference" | (string & {});
67
+ label: string;
68
+ url?: string;
69
+ start?: number;
70
+ end?: number;
71
+ metadata?: AgentProtocolMetadata;
72
+ }
73
+ export interface AnnotationPart {
74
+ type: "annotation";
75
+ annotation: AgentAnnotation;
76
+ }
77
+ export interface FilePart {
78
+ type: "file";
79
+ name: string;
80
+ mediaType?: string;
81
+ url?: string;
82
+ fileId?: string;
83
+ }
84
+ export interface AgentWidgetAction {
85
+ id: string;
86
+ label: string;
87
+ kind?: "primary" | "secondary" | "danger";
88
+ /** Stable action identifier routed through `AgentTransport.invokeAction`. */
89
+ action?: string;
90
+ payload?: unknown;
91
+ disabled?: boolean;
92
+ }
93
+ export interface AgentWidget {
94
+ id: string;
95
+ kind: string;
96
+ data: unknown;
97
+ title?: string;
98
+ actions?: AgentWidgetAction[];
99
+ state?: "active" | "submitted" | "dismissed" | "expired";
100
+ metadata?: AgentProtocolMetadata;
101
+ }
102
+ export interface WidgetPart {
103
+ type: "widget";
104
+ widget: AgentWidget;
105
+ }
106
+ /** Opaque structured content for host-owned renderers and runtime metadata. */
107
+ export interface DataPart {
108
+ type: "data";
109
+ data: unknown;
110
+ mediaType?: string;
111
+ title?: string;
112
+ }
113
+ /** Host-defined message parts keep domain-specific UI out of the base protocol. */
114
+ export interface AgentCustomMessagePart {
115
+ type: `x-${string}`;
116
+ [key: string]: unknown;
117
+ }
118
+ export type AgentMessagePart<TCustomPart extends AgentCustomMessagePart = never> = TextPart | ReasoningPart | CitationPart | AnnotationPart | FilePart | WidgetPart | DataPart | TCustomPart;
119
+ export interface AgentMessage<TCustomPart extends AgentCustomMessagePart = never> {
120
+ id: string;
121
+ role: AgentRole;
122
+ parts: AgentMessagePart<TCustomPart>[];
123
+ createdAt?: string;
124
+ status?: "streaming" | "complete" | "error";
125
+ metadata?: AgentProtocolMetadata;
126
+ }
127
+ export type AgentRunStatus = "queued" | "running" | "awaiting_approval" | "awaiting_input" | "completed" | "failed" | "cancelled";
128
+ export interface AgentToolCall {
129
+ id: ToolCallId;
130
+ name: string;
131
+ input?: unknown;
132
+ output?: unknown;
133
+ status: "running" | "completed" | "failed" | "cancelled";
134
+ error?: AgentError;
135
+ runId?: RunId;
136
+ messageId?: string;
137
+ agentId?: AgentId;
138
+ metadata?: AgentProtocolMetadata;
139
+ }
140
+ /** A portable reference that hosts can resolve into files, records, or views. */
141
+ export interface AgentObjectReference {
142
+ id: string;
143
+ kind: string;
144
+ label: string;
145
+ uri?: string;
146
+ metadata?: AgentProtocolMetadata;
147
+ }
148
+ export type AgentWorkScope = "thread" | "workspace" | "external";
149
+ export type AgentParticipantStatus = "idle" | "working" | "waiting" | "paused" | "completed" | "failed" | "closed";
150
+ /**
151
+ * Portable identity and live state for one agent participating in a thread.
152
+ * `origin` identifies the app, workspace, or remote runtime that owns it;
153
+ * hosts retain control of navigation and presentation for that reference.
154
+ */
155
+ export interface AgentParticipant {
156
+ id: AgentId;
157
+ name: string;
158
+ kind?: "primary" | "subagent" | "peer" | "external" | (string & {});
159
+ status: AgentParticipantStatus;
160
+ parentAgentId?: AgentId;
161
+ activeTaskId?: TaskId;
162
+ description?: string;
163
+ avatarUrl?: string;
164
+ origin?: AgentObjectReference;
165
+ startedAt?: string;
166
+ updatedAt?: string;
167
+ completedAt?: string;
168
+ metadata?: AgentProtocolMetadata;
169
+ }
170
+ export type AgentInteractionKind = "started" | "resumed" | "messaged" | "delegated" | "paused" | "completed" | "failed" | "closed" | (string & {});
171
+ /**
172
+ * Append-only collaboration evidence. Participant events describe current
173
+ * state; interactions explain how agents entered, coordinated, or left work.
174
+ */
175
+ export interface AgentInteraction {
176
+ id: AgentInteractionId;
177
+ kind: AgentInteractionKind;
178
+ agentId: AgentId;
179
+ targetAgentId?: AgentId;
180
+ label?: string;
181
+ detail?: string;
182
+ scope?: AgentWorkScope;
183
+ object?: AgentObjectReference;
184
+ source?: AgentObjectReference;
185
+ occurredAt?: string;
186
+ metadata?: AgentProtocolMetadata;
187
+ }
188
+ export type AgentActivityKind = "status" | "reasoning" | "model" | "search" | "read" | "write" | "edit" | "command" | "check" | "mcp" | "connection" | "navigation" | "delegation" | "approval" | "tool" | (string & {});
189
+ /**
190
+ * Infers a conservative presentation kind from a stable tool identifier.
191
+ * Adapters should prefer an explicitly authored activity kind when available.
192
+ */
193
+ export declare function inferAgentActivityKind(toolName: string): AgentActivityKind;
194
+ export interface AgentActivity {
195
+ id: string;
196
+ kind: AgentActivityKind;
197
+ label: string;
198
+ detail?: string;
199
+ status: "running" | "completed" | "failed" | "cancelled";
200
+ /** Agent responsible for this activity when work is delegated or parallel. */
201
+ agentId?: AgentId;
202
+ runId?: RunId;
203
+ /** Distinguishes transcript-local work from workspace or remote execution. */
204
+ scope?: AgentWorkScope;
205
+ object?: AgentObjectReference;
206
+ source?: AgentObjectReference;
207
+ summary?: AgentMessagePart[];
208
+ startedAt?: string;
209
+ completedAt?: string;
210
+ metadata?: AgentProtocolMetadata;
211
+ }
212
+ export type AgentTaskStatus = "pending" | "running" | "awaiting_input" | "completed" | "failed" | "cancelled";
213
+ /**
214
+ * A durable unit of agent work. Tasks are intentionally distinct from
215
+ * activities: activities explain execution, while tasks expose delegable work
216
+ * that a host can organize across agents and parent/child workflows.
217
+ */
218
+ export interface AgentTask {
219
+ id: TaskId;
220
+ title: string;
221
+ status: AgentTaskStatus;
222
+ kind?: string;
223
+ parentTaskId?: TaskId;
224
+ assignedAgentId?: AgentId;
225
+ runId?: RunId;
226
+ detail?: string;
227
+ progress?: {
228
+ completed: number;
229
+ total: number;
230
+ };
231
+ object?: AgentObjectReference;
232
+ source?: AgentObjectReference;
233
+ summary?: AgentMessagePart[];
234
+ createdAt?: string;
235
+ updatedAt?: string;
236
+ completedAt?: string;
237
+ metadata?: AgentProtocolMetadata;
238
+ }
239
+ /**
240
+ * Explicit, durable organization for related tasks. A group is presentation
241
+ * metadata over task identities; tasks remain the canonical units of work.
242
+ */
243
+ export interface AgentTaskGroup {
244
+ id: string;
245
+ taskIds: TaskId[];
246
+ title?: string;
247
+ status?: AgentTaskStatus;
248
+ runId?: RunId;
249
+ object?: AgentObjectReference;
250
+ source?: AgentObjectReference;
251
+ createdAt?: string;
252
+ updatedAt?: string;
253
+ completedAt?: string;
254
+ metadata?: AgentProtocolMetadata;
255
+ }
256
+ export interface AgentApprovalRequest {
257
+ id: ApprovalId;
258
+ title: string;
259
+ description?: string;
260
+ kind?: "approval" | "choice" | "input";
261
+ allowMultiple?: boolean;
262
+ /** Choice prompts accept a user-authored alternative by default. */
263
+ allowOther?: boolean;
264
+ options?: Array<{
265
+ id: string;
266
+ label: string;
267
+ description?: string;
268
+ kind?: "primary" | "secondary" | "danger";
269
+ }>;
270
+ input?: {
271
+ id: string;
272
+ label?: string;
273
+ placeholder?: string;
274
+ type?: "text" | "number" | "url";
275
+ required?: boolean;
276
+ };
277
+ expiresAt?: string;
278
+ metadata?: AgentProtocolMetadata;
279
+ }
280
+ export interface AgentApprovalResponse {
281
+ decision: "approve" | "deny";
282
+ optionIds?: string[];
283
+ /** User-authored alternative to the predefined options. */
284
+ other?: string;
285
+ input?: Record<string, unknown>;
286
+ }
287
+ /**
288
+ * Why a host-managed provider connection is required. Action approval remains
289
+ * a separate workflow: this contract only establishes usable connectivity.
290
+ */
291
+ export type AgentConnectionRequestReason = "connect" | "grant" | "reauthorize" | "admin_required";
292
+ export type AgentConnectionRequestStatus = "requested" | "connecting" | "connected" | "declined" | "failed";
293
+ /**
294
+ * A provider-agnostic request resolved by the host's trusted connection
295
+ * catalog. URLs, credentials, and OAuth scopes are deliberately absent so an
296
+ * agent cannot author connection authority.
297
+ */
298
+ export interface AgentConnectionRequest {
299
+ id: ConnectionRequestId;
300
+ provider: string;
301
+ reason: AgentConnectionRequestReason;
302
+ status: AgentConnectionRequestStatus;
303
+ appId?: string;
304
+ detail?: string;
305
+ source?: AgentProtocolReference;
306
+ createdAt?: string;
307
+ updatedAt?: string;
308
+ metadata?: AgentProtocolMetadata;
309
+ }
310
+ export interface AgentConnectionResponse {
311
+ status: "connected" | "declined" | "failed";
312
+ connectionId?: string;
313
+ message?: string;
314
+ }
315
+ export interface AgentArtifactReference {
316
+ id: string;
317
+ kind: string;
318
+ title?: string;
319
+ url?: string;
320
+ runId?: RunId;
321
+ createdAt?: string;
322
+ metadata?: AgentProtocolMetadata;
323
+ }
324
+ export type AgentReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh";
325
+ export type AgentToolChoice = "auto" | "none" | "required" | {
326
+ name: string;
327
+ };
328
+ /** Typed inference and workflow controls attached to one run. */
329
+ export interface AgentRunOptions {
330
+ agentId?: AgentId;
331
+ model?: string;
332
+ reasoningEffort?: AgentReasoningEffort;
333
+ toolChoice?: AgentToolChoice;
334
+ temperature?: number;
335
+ locale?: string;
336
+ mode?: string;
337
+ parallelToolCalls?: boolean;
338
+ metadata?: AgentProtocolMetadata;
339
+ }
340
+ export interface AgentActionInvocation {
341
+ id: ActionInvocationId;
342
+ action: string;
343
+ threadId: ThreadId;
344
+ runId?: RunId;
345
+ messageId?: string;
346
+ widgetId?: string;
347
+ itemId?: string;
348
+ payload?: unknown;
349
+ metadata?: AgentProtocolMetadata;
350
+ }
351
+ export interface AgentActionResult {
352
+ invocationId: ActionInvocationId;
353
+ status: "completed" | "failed" | "cancelled";
354
+ data?: unknown;
355
+ error?: AgentError;
356
+ metadata?: AgentProtocolMetadata;
357
+ }
358
+ export interface AgentUploadDescriptor {
359
+ name: string;
360
+ mediaType: string;
361
+ size: number;
362
+ checksum?: string;
363
+ purpose?: "message" | "context" | "artifact" | (string & {});
364
+ metadata?: AgentProtocolMetadata;
365
+ }
366
+ /**
367
+ * Negotiated upload destination. The protocol never places binary bodies in
368
+ * events or messages; clients upload bytes to this target and then complete it.
369
+ */
370
+ export interface AgentUploadTarget {
371
+ uploadId: UploadId;
372
+ method: "POST" | "PUT";
373
+ url: string;
374
+ headers?: Record<string, string>;
375
+ fields?: Record<string, string>;
376
+ expiresAt?: string;
377
+ }
378
+ export interface AgentUploadProgress {
379
+ uploadId: UploadId;
380
+ loaded: number;
381
+ total: number;
382
+ }
383
+ /** A provider-neutral next action an agent can publish after a turn. */
384
+ export interface AgentSuggestion {
385
+ id: string;
386
+ /** Concise, single-line action label. Put the full instruction in `prompt`. */
387
+ label: string;
388
+ /** Prompt submitted when selected. Defaults to `label`. */
389
+ prompt?: string;
390
+ runId?: RunId;
391
+ updatedAt?: string;
392
+ metadata?: AgentProtocolMetadata;
393
+ }
394
+ export interface AgentError {
395
+ code: string;
396
+ message: string;
397
+ retryable?: boolean;
398
+ correlationId?: string;
399
+ details?: unknown;
400
+ metadata?: AgentProtocolMetadata;
401
+ }
402
+ export interface AgentCapabilityUnsupportedError extends AgentError {
403
+ code: "capability_unsupported";
404
+ capability: AgentCapabilityId;
405
+ retryable: false;
406
+ }
407
+ export interface AgentCapabilityUnavailableError extends AgentError {
408
+ code: "capability_unavailable";
409
+ capability: AgentCapabilityId;
410
+ retryable: boolean;
411
+ }
412
+ export interface AgentOperationUnsupportedError extends AgentError {
413
+ code: "operation_unsupported";
414
+ operation: string;
415
+ retryable: false;
416
+ }
417
+ export interface AgentProtocolVersionUnsupportedError extends AgentError {
418
+ code: "protocol_version_unsupported";
419
+ supportedVersions: AgentKitProtocolVersion[];
420
+ receivedVersions: number[];
421
+ retryable: false;
422
+ }
423
+ export interface AgentRequestAbortedError extends AgentError {
424
+ code: "request_aborted";
425
+ retryable: false;
426
+ }
427
+ /**
428
+ * Ephemeral execution context for one transport operation. This context is not
429
+ * part of the JSON wire payload: adapters project it onto their native request
430
+ * mechanism and providers use it to stop abandoned work and correlate traces.
431
+ */
432
+ export interface AgentRequestContext {
433
+ /** Cancels this operation only; it never implies cancellation of a run. */
434
+ signal?: AbortSignal;
435
+ /** Stable identity shared by every layer participating in this operation. */
436
+ correlationId?: string;
437
+ }
438
+ export interface AgentUsage {
439
+ inputTokens?: number;
440
+ outputTokens?: number;
441
+ totalTokens?: number;
442
+ cost?: number;
443
+ currency?: string;
444
+ }
445
+ export type AgentCapabilityId = "actions" | "activities" | "approvals" | "artifacts" | "attachments" | "citations" | "clientEffects" | "codeExecution" | "connectionRequests" | "durableThreadSnapshots" | "feedback" | "messageQueue" | "modelSelection" | "multiAgentActivity" | "reasoning" | "resumableRuns" | "smartObjects" | "suggestions" | "taskGroups" | "threadForking" | "threadHistory" | "toolSelection" | "uploads" | "widgets" | `x-${string}`;
446
+ /**
447
+ * Capability status is explicit: unsupported is permanent for this protocol
448
+ * endpoint, while unavailable may recover without renegotiating the protocol.
449
+ */
450
+ export type AgentCapabilityState = "available" | "degraded" | "unavailable" | "unsupported";
451
+ export interface AgentCapabilityDescriptorBase {
452
+ id: AgentCapabilityId;
453
+ /** Human-readable operational context; clients must branch on `state`. */
454
+ description?: string;
455
+ metadata?: AgentProtocolMetadata;
456
+ }
457
+ export type AgentCapabilityDescriptor = (AgentCapabilityDescriptorBase & {
458
+ state: "available";
459
+ error?: never;
460
+ }) | (AgentCapabilityDescriptorBase & {
461
+ state: "degraded" | "unavailable";
462
+ error: AgentCapabilityUnavailableError;
463
+ }) | (AgentCapabilityDescriptorBase & {
464
+ state: "unsupported";
465
+ error: AgentCapabilityUnsupportedError;
466
+ });
467
+ /**
468
+ * `unknown` has no descriptor state because it is the absence of one: the
469
+ * backend never reported the capability. Keeping it distinct from
470
+ * `unsupported` is what stops an older backend's silence from rendering as a
471
+ * deliberate denial.
472
+ */
473
+ export type AgentCapabilityAffordanceState = AgentCapabilityState | "unknown";
474
+ export interface AgentCapabilityAffordance {
475
+ id: AgentCapabilityId;
476
+ state: AgentCapabilityAffordanceState;
477
+ /** Render the control. False when the capability is denied or unreported. */
478
+ visible: boolean;
479
+ /** Permit interaction. False while the capability is temporarily down. */
480
+ enabled: boolean;
481
+ /** Operator explanation, present for degraded and unavailable capabilities. */
482
+ reason?: string;
483
+ }
484
+ /**
485
+ * Stream integrity problems the client can detect but not fix. Each one is a
486
+ * silent correctness failure today: a gap or duplicate means the transport and
487
+ * the reducer disagree about ordering, a missing terminal means a run looks
488
+ * frozen, and a dropped promotion means a queued follow-up never runs. Hosts
489
+ * wire `onIntegrityReport` to their own counters.
490
+ */
491
+ export type AgentStreamIntegrityCode = "sequence_gap" | "duplicate_event" | "run_missing_terminal" | "queue_promotion_dropped";
492
+ export interface AgentStreamIntegrityReport {
493
+ code: AgentStreamIntegrityCode;
494
+ threadId: ThreadId;
495
+ runId?: RunId;
496
+ /** Low-cardinality discriminator. Never an id, timestamp, or free text. */
497
+ reason?: "transport-cannot-steer" | "run-still-active";
498
+ expectedSequence?: number;
499
+ receivedSequence?: number;
500
+ }
501
+ export interface AgentProtocolVersionOffer {
502
+ protocol: AgentKitProtocolName;
503
+ /** Positive, unique protocol versions understood by the caller. */
504
+ versions: number[];
505
+ }
506
+ export type AgentProtocolCompatibility = {
507
+ status: "compatible";
508
+ selectedVersion: AgentKitProtocolVersion;
509
+ localVersions: AgentKitProtocolVersion[];
510
+ peerVersions: number[];
511
+ } | {
512
+ status: "incompatible";
513
+ localVersions: AgentKitProtocolVersion[];
514
+ peerVersions: number[];
515
+ error: AgentProtocolVersionUnsupportedError;
516
+ };
517
+ export interface DiscoverCapabilitiesInput {
518
+ protocol: AgentProtocolVersionOffer;
519
+ requested?: AgentCapabilityId[];
520
+ metadata?: AgentProtocolMetadata;
521
+ }
522
+ export interface AgentCapabilitiesDiscovery {
523
+ protocol: AgentProtocolCompatibility;
524
+ capabilities: AgentCapabilityDescriptor[];
525
+ discoveredAt: string;
526
+ expiresAt?: string;
527
+ /** Optional projection for clients implementing the original boolean map. */
528
+ legacy?: AgentCapabilities;
529
+ metadata?: AgentProtocolMetadata;
530
+ }
531
+ /**
532
+ * Backward-compatible capability projection. `true` means available, `false`
533
+ * means unsupported, and omission means unknown. New transports should also
534
+ * expose `discoverCapabilities` for degraded and temporarily unavailable state.
535
+ */
536
+ export interface AgentCapabilities {
537
+ protocolVersion?: AgentKitProtocolVersion;
538
+ actions?: boolean;
539
+ activities?: boolean;
540
+ approvals?: boolean;
541
+ artifacts?: boolean;
542
+ attachments?: boolean;
543
+ citations?: boolean;
544
+ codeExecution?: boolean;
545
+ connectionRequests?: boolean;
546
+ durableThreadSnapshots?: boolean;
547
+ feedback?: boolean;
548
+ widgets?: boolean;
549
+ uploads?: boolean;
550
+ clientEffects?: boolean;
551
+ modelSelection?: boolean;
552
+ toolSelection?: boolean;
553
+ threadHistory?: boolean;
554
+ threadForking?: boolean;
555
+ messageQueue?: boolean;
556
+ multiAgentActivity?: boolean;
557
+ reasoning?: "none" | "summary" | "full";
558
+ resumableRuns?: boolean;
559
+ taskGroups?: boolean;
560
+ suggestions?: boolean;
561
+ smartObjects?: boolean;
562
+ [extension: `x-${string}`]: unknown;
563
+ }
564
+ export interface AgentEventBase {
565
+ id: EventId;
566
+ threadId: ThreadId;
567
+ runId: RunId;
568
+ sequence: number;
569
+ occurredAt: string;
570
+ metadata?: AgentProtocolMetadata;
571
+ }
572
+ export type AgentEvent = (AgentEventBase & {
573
+ type: "run.started";
574
+ agentId?: AgentId;
575
+ }) | (AgentEventBase & {
576
+ type: "run.status";
577
+ status: AgentRunStatus;
578
+ }) | (AgentEventBase & {
579
+ type: "agent.registered" | "agent.updated" | "agent.unregistered";
580
+ agent: AgentParticipant;
581
+ }) | (AgentEventBase & {
582
+ type: "agent.interaction";
583
+ interaction: AgentInteraction;
584
+ }) | (AgentEventBase & {
585
+ type: "message.created";
586
+ message: AgentMessage;
587
+ }) | (AgentEventBase & {
588
+ type: "message.delta";
589
+ messageId: string;
590
+ text: string;
591
+ format?: TextPart["format"];
592
+ }) | (AgentEventBase & {
593
+ type: "message.completed";
594
+ message: AgentMessage;
595
+ }) | (AgentEventBase & {
596
+ type: "reasoning.delta";
597
+ messageId: string;
598
+ text: string;
599
+ }) | (AgentEventBase & {
600
+ type: "tool.started";
601
+ toolCall: AgentToolCall;
602
+ }) | (AgentEventBase & {
603
+ type: "tool.delta";
604
+ toolCallId: ToolCallId;
605
+ inputTextDelta?: string;
606
+ outputTextDelta?: string;
607
+ }) | (AgentEventBase & {
608
+ type: "tool.updated";
609
+ toolCall: AgentToolCall;
610
+ }) | (AgentEventBase & {
611
+ type: "activity.started" | "activity.updated" | "activity.completed";
612
+ activity: AgentActivity;
613
+ }) | (AgentEventBase & {
614
+ type: "task.created" | "task.updated" | "task.completed";
615
+ task: AgentTask;
616
+ }) | (AgentEventBase & {
617
+ type: "task-group.created" | "task-group.updated" | "task-group.completed";
618
+ taskGroup: AgentTaskGroup;
619
+ }) | (AgentEventBase & {
620
+ type: "task-group.removed";
621
+ taskGroupId: string;
622
+ }) | (AgentEventBase & {
623
+ type: "approval.requested";
624
+ request: AgentApprovalRequest;
625
+ }) | (AgentEventBase & {
626
+ type: "approval.resolved";
627
+ approvalId: ApprovalId;
628
+ optionId?: string;
629
+ response: AgentApprovalResponse;
630
+ }) | (AgentEventBase & {
631
+ type: "connection.requested" | "connection.updated";
632
+ request: AgentConnectionRequest;
633
+ }) | (AgentEventBase & {
634
+ type: "artifact.created";
635
+ artifact: AgentArtifactReference;
636
+ }) | (AgentEventBase & {
637
+ type: "widget.created" | "widget.updated";
638
+ messageId?: string;
639
+ widget: AgentWidget;
640
+ }) | (AgentEventBase & {
641
+ type: "widget.removed";
642
+ widgetId: string;
643
+ }) | (AgentEventBase & {
644
+ type: "annotation.created";
645
+ messageId?: string;
646
+ annotation: AgentAnnotation;
647
+ }) | (AgentEventBase & {
648
+ type: "annotation.updated";
649
+ messageId?: string;
650
+ annotation: AgentAnnotation;
651
+ }) | (AgentEventBase & {
652
+ type: "annotation.removed";
653
+ annotationId: string;
654
+ }) | (AgentEventBase & {
655
+ type: "suggestions.updated";
656
+ suggestions: AgentSuggestion[];
657
+ }) | (AgentEventBase & {
658
+ type: "action.started";
659
+ invocation: AgentActionInvocation;
660
+ }) | (AgentEventBase & {
661
+ type: "action.completed" | "action.failed";
662
+ result: AgentActionResult;
663
+ }) | (AgentEventBase & {
664
+ type: "upload.progress";
665
+ progress: AgentUploadProgress;
666
+ }) | (AgentEventBase & {
667
+ type: "client.effect" | "client.deeplink";
668
+ name: string;
669
+ data?: Record<string, unknown>;
670
+ }) | (AgentEventBase & {
671
+ type: "thread.updated";
672
+ thread: AgentThread;
673
+ }) | (AgentEventBase & {
674
+ type: "queue.updated";
675
+ messages: AgentQueuedMessage[];
676
+ }) | (AgentEventBase & {
677
+ type: "run.completed";
678
+ usage?: AgentUsage;
679
+ }) | (AgentEventBase & {
680
+ type: "run.failed";
681
+ error: AgentError;
682
+ }) | (AgentEventBase & {
683
+ type: "run.cancelled";
684
+ }) | (AgentEventBase & {
685
+ type: `x-${string}`;
686
+ payload: unknown;
687
+ });
688
+ export interface AgentThread {
689
+ id: ThreadId;
690
+ title?: string;
691
+ createdAt: string;
692
+ updatedAt: string;
693
+ status?: "active" | "archived" | "deleted";
694
+ metadata?: AgentProtocolMetadata;
695
+ }
696
+ export interface AgentApprovalSnapshot {
697
+ request: AgentApprovalRequest;
698
+ status: "pending" | "approved" | "denied" | "expired" | "cancelled";
699
+ runId?: RunId;
700
+ response?: AgentApprovalResponse;
701
+ resolvedAt?: string;
702
+ metadata?: AgentProtocolMetadata;
703
+ }
704
+ export interface AgentConnectionRequestSnapshot {
705
+ request: AgentConnectionRequest;
706
+ runId?: RunId;
707
+ }
708
+ export interface AgentWidgetSnapshot {
709
+ messageId: string;
710
+ widget: AgentWidget;
711
+ }
712
+ export interface AgentAnnotationSnapshot {
713
+ messageId: string;
714
+ annotation: AgentAnnotation;
715
+ }
716
+ /** Cursor proving exactly how far each run is represented by a snapshot. */
717
+ export interface AgentReplayCheckpoint {
718
+ id: string;
719
+ capturedAt: string;
720
+ sequenceByRun: Record<RunId, number>;
721
+ cursor?: string;
722
+ metadata?: AgentProtocolMetadata;
723
+ }
724
+ export interface AgentThreadSnapshot extends AgentThread {
725
+ messages: AgentMessage[];
726
+ queuedMessages?: AgentQueuedMessage[];
727
+ /**
728
+ * Ordered durable events used to rebuild rich activity, approvals, widgets,
729
+ * agents, and suggestions without inventing a second projection format.
730
+ */
731
+ events?: AgentEvent[];
732
+ /** Run checkpoints paired with the event log for efficient reconnects. */
733
+ runs?: AgentRunSnapshot[];
734
+ activeRunIds?: RunId[];
735
+ checkpoint?: AgentReplayCheckpoint;
736
+ toolCalls?: AgentToolCall[];
737
+ activities?: AgentActivity[];
738
+ tasks?: AgentTask[];
739
+ taskGroups?: AgentTaskGroup[];
740
+ approvals?: AgentApprovalSnapshot[];
741
+ connectionRequests?: AgentConnectionRequestSnapshot[];
742
+ widgets?: AgentWidgetSnapshot[];
743
+ annotations?: AgentAnnotationSnapshot[];
744
+ agents?: AgentParticipant[];
745
+ interactions?: AgentInteraction[];
746
+ artifacts?: AgentArtifactReference[];
747
+ suggestions?: AgentSuggestion[];
748
+ }
749
+ /**
750
+ * Canonical, restart-safe thread state. Every projection is required so an
751
+ * empty list is distinguishable from data omitted by a partial legacy host.
752
+ */
753
+ export interface AgentDurableThreadSnapshot extends AgentThreadSnapshot {
754
+ checkpoint: AgentReplayCheckpoint;
755
+ queuedMessages: AgentQueuedMessage[];
756
+ events: AgentEvent[];
757
+ runs: AgentRunSnapshot[];
758
+ activeRunIds: RunId[];
759
+ toolCalls: AgentToolCall[];
760
+ activities: AgentActivity[];
761
+ tasks: AgentTask[];
762
+ taskGroups: AgentTaskGroup[];
763
+ approvals: AgentApprovalSnapshot[];
764
+ widgets: AgentWidgetSnapshot[];
765
+ annotations: AgentAnnotationSnapshot[];
766
+ agents: AgentParticipant[];
767
+ interactions: AgentInteraction[];
768
+ artifacts: AgentArtifactReference[];
769
+ suggestions: AgentSuggestion[];
770
+ }
771
+ export interface AgentRunSnapshot {
772
+ id: RunId;
773
+ threadId: ThreadId;
774
+ status: AgentRunStatus;
775
+ lastSequence: number;
776
+ startedAt?: string;
777
+ completedAt?: string;
778
+ usage?: AgentUsage;
779
+ error?: AgentError;
780
+ metadata?: AgentProtocolMetadata;
781
+ }
782
+ export interface AgentQueuedMessage {
783
+ id: string;
784
+ threadId: ThreadId;
785
+ text: string;
786
+ createdAt: string;
787
+ attachments?: FilePart[];
788
+ metadata?: AgentProtocolMetadata;
789
+ }
790
+ export interface ListThreadsInput {
791
+ limit?: number;
792
+ cursor?: string;
793
+ metadata?: AgentProtocolMetadata;
794
+ }
795
+ export interface ListThreadsResult {
796
+ threads: AgentThread[];
797
+ nextCursor?: string;
798
+ }
799
+ export interface ThreadIdInput {
800
+ threadId: ThreadId;
801
+ }
802
+ export interface ThreadMessageInput extends ThreadIdInput {
803
+ messageId: string;
804
+ }
805
+ export interface CreateThreadInput {
806
+ id?: ThreadId;
807
+ title?: string;
808
+ metadata?: AgentProtocolMetadata;
809
+ }
810
+ export interface UpdateThreadInput extends ThreadIdInput {
811
+ title?: string;
812
+ status?: "active" | "archived";
813
+ metadata?: AgentProtocolMetadata;
814
+ }
815
+ export interface ForkThreadInput extends ThreadIdInput {
816
+ fromMessageId?: string;
817
+ title?: string;
818
+ metadata?: AgentProtocolMetadata;
819
+ }
820
+ export interface QueueMessageInput {
821
+ threadId: ThreadId;
822
+ text: string;
823
+ attachments?: FilePart[];
824
+ metadata?: AgentProtocolMetadata;
825
+ }
826
+ export interface QueueMessageResult {
827
+ message: AgentQueuedMessage;
828
+ }
829
+ /**
830
+ * A queue promotion may join an already-streaming run or start a new run.
831
+ * Returning a run result tells the client to subscribe to that promoted work;
832
+ * returning void preserves transports that acknowledge through queue events.
833
+ */
834
+ export type SteerQueuedMessageResult = StartRunResult | void;
835
+ export interface AgentTransportThreadOperations {
836
+ createThread?(input?: CreateThreadInput, context?: AgentRequestContext): Promise<AgentThread>;
837
+ listThreads?(input?: ListThreadsInput, context?: AgentRequestContext): Promise<ListThreadsResult>;
838
+ getThread?(input: ThreadIdInput, context?: AgentRequestContext): Promise<AgentThread | null>;
839
+ getThreadSnapshot?(input: ThreadIdInput, context?: AgentRequestContext): Promise<AgentThreadSnapshot | null>;
840
+ updateThread?(input: UpdateThreadInput, context?: AgentRequestContext): Promise<AgentThread>;
841
+ forkThread?(input: ForkThreadInput, context?: AgentRequestContext): Promise<AgentThread>;
842
+ deleteThread?(input: ThreadIdInput, context?: AgentRequestContext): Promise<void>;
843
+ listQueuedMessages?(input: ThreadIdInput, context?: AgentRequestContext): Promise<AgentQueuedMessage[]>;
844
+ queueMessage?(input: QueueMessageInput, context?: AgentRequestContext): Promise<QueueMessageResult>;
845
+ /**
846
+ * Accepts a queued item into agent work. A transport can return a new run to
847
+ * subscribe to, or acknowledge through `message.created` and `queue.updated`
848
+ * events on an existing run. A rejected command leaves the item queued.
849
+ */
850
+ steerQueuedMessage?(input: ThreadMessageInput, context?: AgentRequestContext): Promise<SteerQueuedMessageResult>;
851
+ removeQueuedMessage?(input: ThreadMessageInput, context?: AgentRequestContext): Promise<void>;
852
+ }
853
+ export interface AgentTransport extends AgentTransportThreadOperations {
854
+ /**
855
+ * Releases resources owned by this transport. Clients must call this only
856
+ * when they explicitly own the transport; shared transports are borrowed.
857
+ */
858
+ dispose?(): void | Promise<void>;
859
+ capabilities?: AgentCapabilities;
860
+ discoverCapabilities?(input: DiscoverCapabilitiesInput, context?: AgentRequestContext): Promise<AgentCapabilitiesDiscovery>;
861
+ startRun(input: StartRunInput, context?: AgentRequestContext): Promise<StartRunResult>;
862
+ subscribeToRun(input: SubscribeToRunInput): AsyncIterable<AgentEvent>;
863
+ cancelRun(input: CancelRunInput, context?: AgentRequestContext): Promise<void>;
864
+ /**
865
+ * Answers the interrupts that ended a run and starts the run that carries the
866
+ * work forward. An interrupt terminates its run under AG-UI semantics, so
867
+ * resolution produces a new run to subscribe to rather than resuming a
868
+ * stream that is already closed.
869
+ */
870
+ resumeRun?(input: ResumeRunInput, context?: AgentRequestContext): Promise<StartRunResult>;
871
+ /**
872
+ * @deprecated Implement {@link resumeRun}. Kept as a source-compatible
873
+ * bridge for protocol-v1 transports while consumers migrate to interrupts.
874
+ */
875
+ resolveApproval?(input: ResolveApprovalInput, context?: AgentRequestContext): Promise<void>;
876
+ resolveConnectionRequest?(input: ResolveConnectionRequestInput, context?: AgentRequestContext): Promise<void>;
877
+ getRun?(input: GetRunInput, context?: AgentRequestContext): Promise<AgentRunSnapshot | null>;
878
+ invokeAction?(input: InvokeActionInput, context?: AgentRequestContext): Promise<AgentActionResult>;
879
+ createUpload?(input: CreateUploadInput, context?: AgentRequestContext): Promise<AgentUploadTarget>;
880
+ completeUpload?(input: CompleteUploadInput, context?: AgentRequestContext): Promise<FilePart>;
881
+ cancelUpload?(input: CancelUploadInput, context?: AgentRequestContext): Promise<void>;
882
+ submitFeedback?(input: SubmitFeedbackInput, context?: AgentRequestContext): Promise<void>;
883
+ }
884
+ export interface StartRunInput {
885
+ threadId: ThreadId;
886
+ messages: AgentMessage[];
887
+ options?: AgentRunOptions;
888
+ /**
889
+ * Resolutions for interrupts raised by an earlier run. Mirrors AG-UI's
890
+ * `RunAgentInput.resume`, so a resumed run is an ordinary run start rather
891
+ * than a second command channel with its own lifecycle.
892
+ */
893
+ resume?: AgentResumeEntry[];
894
+ metadata?: AgentProtocolMetadata;
895
+ }
896
+ /**
897
+ * One interrupt resolution, shaped exactly like AG-UI's `ResumeEntry` so it
898
+ * needs no translation on the wire.
899
+ */
900
+ export interface AgentResumeEntry {
901
+ interruptId: ApprovalId;
902
+ status: "resolved" | "cancelled";
903
+ payload?: unknown;
904
+ metadata?: AgentProtocolMetadata;
905
+ }
906
+ export interface ResumeRunInput {
907
+ threadId: ThreadId;
908
+ /** The interrupted run being answered, used to scope authorization. */
909
+ runId: RunId;
910
+ resume: AgentResumeEntry[];
911
+ }
912
+ export interface StartRunResult {
913
+ runId: RunId;
914
+ capabilities?: AgentCapabilities;
915
+ }
916
+ export interface SubscribeToRunInput {
917
+ threadId: ThreadId;
918
+ runId: RunId;
919
+ afterSequence?: number;
920
+ /**
921
+ * Cancels only this subscription. Implementations must stop iteration and
922
+ * release transport resources; they must not cancel the remote run.
923
+ */
924
+ signal?: AbortSignal;
925
+ }
926
+ export interface CancelRunInput {
927
+ threadId: ThreadId;
928
+ runId: RunId;
929
+ }
930
+ /** @deprecated Use {@link ResumeRunInput} with {@link AgentResumeEntry}. */
931
+ export interface ResolveApprovalInput {
932
+ threadId: ThreadId;
933
+ runId: RunId;
934
+ approvalId: ApprovalId;
935
+ /** Kept for simple approval consumers; use `response` for choices or input. */
936
+ optionId?: string;
937
+ response: AgentApprovalResponse;
938
+ }
939
+ export interface ResolveConnectionRequestInput {
940
+ threadId: ThreadId;
941
+ runId: RunId;
942
+ requestId: ConnectionRequestId;
943
+ response: AgentConnectionResponse;
944
+ }
945
+ export interface GetRunInput {
946
+ threadId: ThreadId;
947
+ runId: RunId;
948
+ }
949
+ export interface InvokeActionInput {
950
+ invocation: AgentActionInvocation;
951
+ }
952
+ export interface CreateUploadInput {
953
+ threadId: ThreadId;
954
+ descriptor: AgentUploadDescriptor;
955
+ }
956
+ export interface CompleteUploadInput {
957
+ threadId: ThreadId;
958
+ uploadId: UploadId;
959
+ }
960
+ export interface CancelUploadInput extends CompleteUploadInput {
961
+ }
962
+ export interface SubmitFeedbackInput {
963
+ threadId: ThreadId;
964
+ messageId: string;
965
+ value: "positive" | "negative" | "dismissed";
966
+ reason?: string;
967
+ metadata?: AgentProtocolMetadata;
968
+ }
969
+ export interface AgentProtocolEnvelope<TPayload = unknown> {
970
+ protocol: AgentKitProtocolName;
971
+ version: AgentKitProtocolVersion;
972
+ kind: "request" | "response" | "event" | "error";
973
+ correlationId?: string;
974
+ metadata?: AgentProtocolMetadata;
975
+ payload: TPayload;
976
+ }
977
+ export * from "./validation.js";
978
+ export * from "./compatibility.js";
979
+ export * from "./errors.js";
980
+ export * from "./agui.js";
981
+ export * from "./agui-codec.js";
982
+ //# sourceMappingURL=index.d.ts.map