@agen-ai/agent-protocol 0.3.1 → 0.4.1

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 (50) hide show
  1. package/README.md +114 -13
  2. package/dist/capabilities/types.d.ts +6 -1
  3. package/dist/events/types.d.ts +12 -4
  4. package/dist/events/types.js +1 -0
  5. package/dist/failures/index.d.ts +3 -0
  6. package/dist/failures/index.js +2 -0
  7. package/dist/failures/parsers.d.ts +5 -0
  8. package/dist/failures/parsers.js +12 -0
  9. package/dist/failures/types.d.ts +41 -0
  10. package/dist/failures/types.js +21 -0
  11. package/dist/foundation/parsers.d.ts +2 -3
  12. package/dist/foundation/parsers.js +1 -7
  13. package/dist/foundation/types.d.ts +2 -12
  14. package/dist/foundation/types.js +1 -1
  15. package/dist/jsonSchema/generated.d.ts +5519 -3498
  16. package/dist/jsonSchema/generated.js +4038 -2645
  17. package/dist/public/index.d.ts +2 -0
  18. package/dist/public/index.js +2 -0
  19. package/dist/public/sessionInteractions.d.ts +2 -0
  20. package/dist/public/sessionInteractions.js +1 -0
  21. package/dist/requests/types.d.ts +17 -4
  22. package/dist/sessionInteractions/index.d.ts +3 -0
  23. package/dist/sessionInteractions/index.js +2 -0
  24. package/dist/sessionInteractions/parsers.d.ts +10 -0
  25. package/dist/sessionInteractions/parsers.js +48 -0
  26. package/dist/sessionInteractions/types.d.ts +50 -0
  27. package/dist/sessionInteractions/types.js +18 -0
  28. package/dist/zod/accountQuota.d.ts +8 -0
  29. package/dist/zod/accountQuota.js +7 -5
  30. package/dist/zod/capabilities.d.ts +75 -9
  31. package/dist/zod/capabilities.js +32 -30
  32. package/dist/zod/collaboration.js +1 -1
  33. package/dist/zod/events.d.ts +68 -45
  34. package/dist/zod/events.js +17 -3
  35. package/dist/zod/failures.d.ts +23 -0
  36. package/dist/zod/failures.js +76 -0
  37. package/dist/zod/foundation.d.ts +2 -7
  38. package/dist/zod/foundation.js +15 -15
  39. package/dist/zod/index.d.ts +4 -2
  40. package/dist/zod/index.js +28 -2
  41. package/dist/zod/operations.d.ts +4 -4
  42. package/dist/zod/operations.js +1 -1
  43. package/dist/zod/requests.d.ts +79 -28
  44. package/dist/zod/requests.js +15 -2
  45. package/dist/zod/resources.js +1 -1
  46. package/dist/zod/sessionInteractions.d.ts +55 -0
  47. package/dist/zod/sessionInteractions.js +114 -0
  48. package/dist/zod/turns.js +1 -1
  49. package/dist/zod/typeEquality.generated.d.ts +36 -8
  50. package/package.json +6 -2
package/README.md CHANGED
@@ -3,9 +3,11 @@
3
3
  `@agen-ai/agent-protocol` is the provider-neutral data contract for coding-agent runtimes. It
4
4
  defines opaque identifiers, sessions, turns, approval and elicitation requests, technical
5
5
  capabilities, typed operations, safe configuration and managed-content inventories, integration
6
- observations, effective harness content and package catalogs, environment observations, account-quota observations, collaboration lifecycles, generated resources, portable
6
+ observations, effective harness content and package catalogs, environment observations, account-quota observations, operational failures and recovery hints, collaboration lifecycles, generated resources, portable
7
7
  artifact descriptors, and provider-observed events. The package does not define a transport or
8
8
  execution runtime.
9
+ The coordinated source version is unpublished `0.4.1` and uses Agent Protocol V11. The published
10
+ release remains `0.4.0` with V10. The source candidate also includes session-decision data.
9
11
 
10
12
  ## Ownership boundary
11
13
 
@@ -30,7 +32,7 @@ carry no fabricated windows or hints.
30
32
  ## Entrypoints
31
33
 
32
34
  - `@agen-ai/agent-protocol` exports the complete plain API.
33
- - `/sessions`, `/turns`, `/requests`, `/events`, `/capabilities`, `/artifacts`, `/operations`,
35
+ - `/sessions`, `/session-interactions`, `/turns`, `/requests`, `/events`, `/capabilities`, `/artifacts`, `/operations`,
34
36
  `/configuration`, `/managed-content`, `/integrations`, `/collaboration`, `/resources`, and
35
37
  `/account-quota`, `/effective-content`, `/commands`, `/extensions`, and `/environment` are focused plain entrypoints.
36
38
  - `/zod` is the only entrypoint that exposes Zod schemas.
@@ -50,7 +52,7 @@ import {
50
52
  } from '@agen-ai/agent-protocol';
51
53
 
52
54
  const event: AgentEvent = parseAgentEvent({
53
- protocolVersion: 9,
55
+ protocolVersion: 11,
54
56
  type: 'content.delta',
55
57
  sessionId: parseAgentSessionId('external-session:42'),
56
58
  turnId: parseAgentTurnId('external-turn:9'),
@@ -65,7 +67,7 @@ const event: AgentEvent = parseAgentEvent({
65
67
  const roundTripped = parseAgentEvent(JSON.parse(JSON.stringify(event)));
66
68
  ```
67
69
 
68
- Serialized values carry `protocolVersion: 9`; TypeScript API names remain unsuffixed. Unknown
70
+ Serialized values carry `protocolVersion: 11`; TypeScript API names remain unsuffixed. Unknown
69
71
  fields and unsupported protocol versions are rejected.
70
72
 
71
73
  Item snapshots are a closed union keyed by `itemKind`. Common identity and lifecycle fields are
@@ -78,10 +80,25 @@ attribute bag; source evidence belongs outside the portable event. File-change p
78
80
  `compareStringsByUnicodeCodePoint` to emit the canonical path ordering required by the protocol
79
81
  across both BMP and supplementary Unicode characters.
80
82
 
81
- V9 approval requests correlate to one live item or exact proposed-plan artifact and provide a
82
- bounded list of typed options. Every option declares its decision, persistence, and neutral scope;
83
- resolutions select one offered `optionId` or explicitly cancel. Approval capabilities advertise
84
- the exact persistence/scope combinations an adapter can emit. `context.usage.updated` reports
83
+ Approval requests correlate to one live item or exact proposed-plan artifact and provide a
84
+ bounded list of typed options. Every option declares its decision and a closed `consequence`.
85
+ `scoped` contains precise `persistence` and `scope`; `provider_managed_remembrance` contains explicit
86
+ unknown duration and applicability and a required bounded explanation. Flat persistence/scope
87
+ fields are rejected in V11. Neither approval nor a delivered answer proves the provider wrote a rule.
88
+ Resolutions select one exact offered `optionId` or explicitly cancel. Supported approval capability
89
+ requires `providerManagedRemembrance`: false requires a nonempty readonly precise-mode tuple; true
90
+ allows a bounded readonly array, including empty for a remembered-only provider. Scoped options
91
+ must fit an exact declared mode; remembered options require the true capability. The SDK owns no
92
+ permission database, answer cache, pattern editor, provider payload bag, or revoke API.
93
+
94
+ Consumers should present each offered decision and consequence together. Several options can have
95
+ the same immediate decision and different consequences, so selecting the first `approved` option
96
+ cannot express a person's choice reliably. Return the exact selected `optionId`; keep deny-once,
97
+ deny-and-remember, and explicit cancellation distinct. Show the remembered option's explanation
98
+ and unknown duration/applicability without converting observed provider behavior into a session,
99
+ workspace, path-pattern, or permanent grant.
100
+
101
+ `context.usage.updated` reports
85
102
  bounded occupancy and optional monotonic cumulative counters for an advertised session or
86
103
  materialization measurement scope.
87
104
 
@@ -96,8 +113,90 @@ collapse unrelated pools into one percentage. Quantity units remain distinct fro
96
113
  which uses integer minor units with an explicit scale. None of these domains has a generic
97
114
  extension or metadata bag.
98
115
 
116
+ ## Session-decision data
117
+
118
+ `AgentSessionDecisionRequest` describes a bounded decision outside any model turn. It carries
119
+ `requestId`, `sessionId`, a title, optional description, a workspace target, `expiresAt` and
120
+ one to sixteen uniquely identified choices. It has no `turnId`, provider-native request ID,
121
+ open metadata bag or transport correlation field. Use the root entrypoint or the focused
122
+ `@agen-ai/agent-protocol/session-interactions` entrypoint for its plain types and parsers.
123
+ Only `/zod` exposes the corresponding schemas; the deterministic JSON Schema surface retains
124
+ the same portable data boundary.
125
+
126
+ Every choice describes its consequence. A workspace `grant` is provider-managed, persistent
127
+ and may affect other sessions; it authorizes the workspace rather than only the categories
128
+ detected when the question was created. A `decline` leaves configuration gated and does not
129
+ promise revocation of existing trust, persisted denial or suppression of future questions.
130
+ Hosts must present the target and consequences before applying their decision policy.
131
+ Descriptions and opaque IDs are data, not execution authority.
132
+
133
+ `parseAgentSessionDecisionResponseFor(request, { choiceId })` validates that the response
134
+ selects a choice offered by that exact request. The response has no free-form answer or
135
+ caller-supplied request/session correlation. Actual response authority belongs to the runtime's
136
+ bound `AgentSessionInteraction.respond` capability. The protocol defines portable data;
137
+ callback lifetime, deadlines, delivery receipts, terminal settlement and cleanup are documented
138
+ by [`@agen-ai/agent-runtime`](../agent-runtime/README.md#session-lifetime-interactions).
139
+
140
+ | Portable bound | Maximum |
141
+ | --- | --- |
142
+ | Serialized request | 65,536 UTF-8 bytes |
143
+ | Serialized response | 1,024 UTF-8 bytes |
144
+ | Offered choices | 16, with unique IDs |
145
+ | Choice ID | 128 UTF-8 bytes |
146
+ | Request title and choice label | 120 characters |
147
+ | Request description | 4,000 characters |
148
+ | Choice description | 1,000 characters |
149
+ | Workspace target path | 4,096 UTF-8 bytes |
150
+
151
+ Throwing parsers and `safeParse...` variants use the existing validator-neutral issue contract.
152
+ Unknown fields, duplicate choice IDs and unsupported consequence shapes reject. These values
153
+ remain separate from turn approval/elicitation data and introduce no protocol-version change.
154
+
99
155
  ## Errors and trust
100
156
 
157
+ `AgentError` contains required `category`, stable `code`, safe `message`, tagged `recovery`, and
158
+ optional bounded `context`. The categories distinguish rate limiting, exhausted account quota,
159
+ turn budget, execution/context limits, authentication, permission, invalid input, provider overload,
160
+ transport, provider, protocol, internal, and unknown failures. Adapters classify from native evidence;
161
+ an HTTP 429 alone establishes rate limiting and does not establish exhausted account quota.
162
+
163
+ Recovery is one of `unknown`, `none`, `retry`, `wait_for_quota`, or `user_action`. `retry` may carry
164
+ an exactly reported `notBefore` timestamp. `user_action` names `authenticate`, `review_access`,
165
+ `change_configuration`, or `review_allowance`. `none` offers no applicable recovery for this operation.
166
+ These hints describe possible next steps; the application must assess execution certainty and effect
167
+ replay independently before starting more work. The protocol does not retry, schedule continuation,
168
+ switch accounts, or switch providers.
169
+
170
+ An operational failure is separate from terminal authority. `turn.completed` with outcome `failed`
171
+ requires an error; other terminal outcomes cannot carry one. A `runtime.error` observation does not
172
+ itself complete a turn, and a failed tool item does not by itself fail the turn. Contract violations,
173
+ uncertain dispatch and cleanup ownership retain their runtime semantics regardless of failure category.
174
+
175
+ `wait_for_quota` may carry an immutable `AgentFailureQuotaReference` identifying an existing source,
176
+ pool, window, and observation timestamp. Its optional `reset` uses the same `AgentAccountQuotaReset`
177
+ shape and preserves reported versus estimated precision. Reset evidence cannot be newer than the
178
+ referenced observation. Only `rate_limited` and `quota_exhausted` failures may carry a quota reference;
179
+ turn budget and execution limits do not acquire account-quota identity. Omitted quota or reset evidence
180
+ remains absent. The host must establish reference visibility and applicability to the selected binding;
181
+ historical references grant no eligibility after account or credential changes.
182
+
183
+ `runtime.retrying` reports provider-owned retry activity within an active turn. It requires
184
+ `owner: 'provider'`, the turn identity, and an `AgentError`. Its optional `attempt` is a positive,
185
+ one-based retry ordinal; `maxAttempts` is the positive maximum number of retries. Both exclude the
186
+ original attempt. When both are reported, `attempt` cannot exceed `maxAttempts`. Optional `delayMs`
187
+ is a nonnegative safe integer. Counters may repeat or restart across the provider's request/stream
188
+ retry domains within one turn, and missing native facts remain absent. A retry observation neither
189
+ completes a turn nor resolves a pending request; a later authoritative success completes the same turn.
190
+
191
+ V10 removes `AgentError.retryable` and `runtime.warning.payload.retryable`. Warnings retain only
192
+ bounded code, message, and optional context. Existing `AgentError`, `parseAgentError`, and
193
+ `safeParseAgentError` root imports remain available. Failure messages are bounded at 4,000 characters,
194
+ codes at 120 characters, context fields at 160 characters, and serialized failures at 32 KiB.
195
+ Context contains only optional `operation`, `component` and `status`; it cannot carry native payloads,
196
+ credentials or arbitrary attributes.
197
+ The `/json-schema` error artifact publishes structural constraints and names the residual semantic
198
+ invariants enforced by the ordinary parser, including quota applicability and reset observation order.
199
+
101
200
  Throwing parsers raise `AgentProtocolValidationError`, a `TypeError` with stable, JSON-safe
102
201
  `issues`. Each corresponding `safeParse...` function returns either parsed data or the same issue
103
202
  array without throwing. Callers should branch on that public result or error class, not on Zod
@@ -147,12 +246,14 @@ before delegation; a composer can use the same pure functions to preserve and ex
147
246
 
148
247
  ## Versioning and release
149
248
 
150
- Agent Protocol V9 defines the coordinated SDK `0.3.1` contract shared by this package,
151
- `@agen-ai/validation`, and `@agen-ai/agent-runtime`. Registry publication and dist-tag state are
152
- release metadata outside this contract. The earlier public `0.3.0` release implemented the same
153
- protocol and remains historical. All three SDK packages must be released together. Protocol V9 is
249
+ Agent Protocol V11 defines the contract shared by this package, `@agen-ai/validation`, and
250
+ `@agen-ai/agent-runtime`. The coordinated source SDK is unpublished `0.4.1`; the published
251
+ release is `0.4.0` with V10. Registry publication and dist-tag state are
252
+ release metadata outside this contract. The earlier public `0.3.0` and `0.3.1` releases remain historical.
253
+ The complete seven-package public release inventory must use one coordinated source version. Protocol V11 is
154
254
  independent of private transport and product
155
- persistence versions and directly replaces V8 at live boundaries. There is one current parser. The
255
+ persistence versions and directly replaces V10 at live boundaries. There is one current parser. V10
256
+ and older serialized data require the historical owner's frozen decoder and are rejected by the live V11 parser. The
156
257
  environment and account-quota namespaces each use their own schema version 1.
157
258
 
158
259
  The repository release proof builds and packs `@agen-ai/validation`, this package, and
@@ -90,9 +90,14 @@ export interface AgentApprovalCapabilityMode {
90
90
  }
91
91
  export type AgentApprovalCapability = Readonly<{
92
92
  kind: 'unsupported';
93
+ }> | Readonly<{
94
+ kind: 'supported';
95
+ modes: readonly [AgentApprovalCapabilityMode, ...AgentApprovalCapabilityMode[]];
96
+ providerManagedRemembrance: false;
93
97
  }> | Readonly<{
94
98
  kind: 'supported';
95
99
  modes: readonly AgentApprovalCapabilityMode[];
100
+ providerManagedRemembrance: true;
96
101
  }>;
97
102
  export type AgentContextUsageCapability = Readonly<{
98
103
  kind: 'unsupported';
@@ -149,7 +154,7 @@ export type AgentTurnSteeringCapability = Readonly<{
149
154
  input: AgentOperationInputCapability;
150
155
  }>;
151
156
  export interface AgentCapabilities {
152
- readonly protocolVersion: 9;
157
+ readonly protocolVersion: 11;
153
158
  readonly providerKey: AgentProviderKey;
154
159
  readonly sessions: Readonly<{
155
160
  create: true;
@@ -5,10 +5,10 @@ import type { AgentRequest } from '../requests/index.js';
5
5
  import type { AgentOperationResult } from '../operations/index.js';
6
6
  import type { AgentGeneratedResourceDescriptor } from '../resources/index.js';
7
7
  import type { AgentContentStreamKind, AgentContextUsage, AgentDiffSummary, AgentItemSnapshot, AgentPlanStep, AgentTurnCompletedPayload, AgentTurnState } from '../turns/index.js';
8
- export declare const AGENT_EVENT_TYPES: readonly ["turn.started", "turn.state_changed", "turn.completed", "item.started", "item.updated", "item.completed", "content.delta", "turn.plan.updated", "turn.plan.proposed", "turn.diff.updated", "request.opened", "progress.updated", "context.usage.updated", "artifact.referenced", "operation.updated", "collaboration.updated", "resource.updated", "runtime.warning", "runtime.error", "provider.diagnostic"];
8
+ export declare const AGENT_EVENT_TYPES: readonly ["turn.started", "turn.state_changed", "turn.completed", "item.started", "item.updated", "item.completed", "content.delta", "turn.plan.updated", "turn.plan.proposed", "turn.diff.updated", "request.opened", "progress.updated", "context.usage.updated", "artifact.referenced", "operation.updated", "collaboration.updated", "resource.updated", "runtime.retrying", "runtime.warning", "runtime.error", "provider.diagnostic"];
9
9
  export type AgentEventType = (typeof AGENT_EVENT_TYPES)[number];
10
10
  interface AgentEventBase<Type extends AgentEventType, Payload> {
11
- readonly protocolVersion: 9;
11
+ readonly protocolVersion: 11;
12
12
  readonly type: Type;
13
13
  readonly sessionId: AgentSessionId;
14
14
  readonly providerRefs?: AgentProviderRefs;
@@ -72,10 +72,18 @@ export type AgentCollaborationUpdatedEvent = AgentOptionallyTurnScopedEventBase<
72
72
  export type AgentResourceUpdatedEvent = AgentOptionallyTurnScopedEventBase<'resource.updated', Readonly<{
73
73
  resource: AgentGeneratedResourceDescriptor;
74
74
  }>>;
75
+ export type AgentRuntimeRetryingEvent = AgentTurnEventBase<'runtime.retrying', Readonly<{
76
+ owner: 'provider';
77
+ error: AgentError;
78
+ /** One-based retry ordinal, excluding the original attempt. */
79
+ attempt?: number;
80
+ /** Maximum number of retries, excluding the original attempt. */
81
+ maxAttempts?: number;
82
+ delayMs?: number;
83
+ }>>;
75
84
  export type AgentRuntimeWarningEvent = AgentOptionallyTurnScopedEventBase<'runtime.warning', Readonly<{
76
85
  code: string;
77
86
  message: string;
78
- retryable?: boolean;
79
87
  context?: AgentErrorContext;
80
88
  }>>;
81
89
  export type AgentRuntimeErrorEvent = AgentOptionallyTurnScopedEventBase<'runtime.error', Readonly<{
@@ -86,6 +94,6 @@ export type AgentProviderDiagnosticEvent = AgentOptionallyTurnScopedEventBase<'p
86
94
  message: string;
87
95
  context?: AgentErrorContext;
88
96
  }>>;
89
- export type AgentEvent = AgentTurnStartedEvent | AgentTurnStateChangedEvent | AgentTurnCompletedEvent | AgentItemStartedEvent | AgentItemUpdatedEvent | AgentItemCompletedEvent | AgentContentDeltaEvent | AgentPlanUpdatedEvent | AgentPlanProposedEvent | AgentDiffUpdatedEvent | AgentRequestOpenedEvent | AgentProgressUpdatedEvent | AgentContextUsageUpdatedEvent | AgentArtifactReferencedEvent | AgentOperationUpdatedEvent | AgentCollaborationUpdatedEvent | AgentResourceUpdatedEvent | AgentRuntimeWarningEvent | AgentRuntimeErrorEvent | AgentProviderDiagnosticEvent;
97
+ export type AgentEvent = AgentTurnStartedEvent | AgentTurnStateChangedEvent | AgentTurnCompletedEvent | AgentItemStartedEvent | AgentItemUpdatedEvent | AgentItemCompletedEvent | AgentContentDeltaEvent | AgentPlanUpdatedEvent | AgentPlanProposedEvent | AgentDiffUpdatedEvent | AgentRequestOpenedEvent | AgentProgressUpdatedEvent | AgentContextUsageUpdatedEvent | AgentArtifactReferencedEvent | AgentOperationUpdatedEvent | AgentCollaborationUpdatedEvent | AgentResourceUpdatedEvent | AgentRuntimeRetryingEvent | AgentRuntimeWarningEvent | AgentRuntimeErrorEvent | AgentProviderDiagnosticEvent;
90
98
  export {};
91
99
  //# sourceMappingURL=types.d.ts.map
@@ -16,6 +16,7 @@ const AGENT_EVENT_TYPES = [
16
16
  "operation.updated",
17
17
  "collaboration.updated",
18
18
  "resource.updated",
19
+ "runtime.retrying",
19
20
  "runtime.warning",
20
21
  "runtime.error",
21
22
  "provider.diagnostic"
@@ -0,0 +1,3 @@
1
+ export * from './types.js';
2
+ export * from './parsers.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,2 @@
1
+ export * from "./types.js";
2
+ export * from "./parsers.js";
@@ -0,0 +1,5 @@
1
+ import type { AgentProtocolParseResult } from '../foundation/validation.js';
2
+ import type { AgentError } from './types.js';
3
+ export declare function parseAgentError(input: unknown): AgentError;
4
+ export declare function safeParseAgentError(input: unknown): AgentProtocolParseResult<AgentError>;
5
+ //# sourceMappingURL=parsers.d.ts.map
@@ -0,0 +1,12 @@
1
+ import { parseWithSchema, safeParseWithSchema } from "../internal/parsers.js";
2
+ import { AgentErrorSchema } from "../zod/failures.js";
3
+ function parseAgentError(input) {
4
+ return parseWithSchema(AgentErrorSchema, input);
5
+ }
6
+ function safeParseAgentError(input) {
7
+ return safeParseWithSchema(AgentErrorSchema, input);
8
+ }
9
+ export {
10
+ parseAgentError,
11
+ safeParseAgentError
12
+ };
@@ -0,0 +1,41 @@
1
+ import type { AgentAccountQuotaReset } from '../accountQuota/types.js';
2
+ import type { AgentIsoDateTime } from '../foundation/types.js';
3
+ export declare const AGENT_FAILURE_CATEGORIES: readonly ["rate_limited", "quota_exhausted", "budget_exhausted", "execution_limit", "context_limit", "authentication", "permission", "invalid_request", "overloaded", "transport", "provider", "protocol", "internal", "unknown"];
4
+ export type AgentFailureCategory = (typeof AGENT_FAILURE_CATEGORIES)[number];
5
+ export declare const AGENT_ERROR_CONTEXT_MAX_LENGTH = 160;
6
+ export interface AgentErrorContext {
7
+ readonly operation?: string;
8
+ readonly component?: string;
9
+ readonly status?: string;
10
+ }
11
+ /** Immutable quota observation evidence, without account or execution authority. */
12
+ export interface AgentFailureQuotaReference {
13
+ readonly sourceId: string;
14
+ readonly poolId: string;
15
+ readonly windowId: string;
16
+ readonly observedAt: AgentIsoDateTime;
17
+ readonly reset?: AgentAccountQuotaReset;
18
+ }
19
+ /** Recovery describes an applicable next step; it never authorizes effect replay. */
20
+ export type AgentRecoveryHint = Readonly<{
21
+ kind: 'unknown';
22
+ }> | Readonly<{
23
+ kind: 'none';
24
+ }> | Readonly<{
25
+ kind: 'retry';
26
+ notBefore?: AgentIsoDateTime;
27
+ }> | Readonly<{
28
+ kind: 'wait_for_quota';
29
+ quota?: AgentFailureQuotaReference;
30
+ }> | Readonly<{
31
+ kind: 'user_action';
32
+ action: 'authenticate' | 'review_access' | 'change_configuration' | 'review_allowance';
33
+ }>;
34
+ export interface AgentError {
35
+ readonly category: AgentFailureCategory;
36
+ readonly code: string;
37
+ readonly message: string;
38
+ readonly recovery: AgentRecoveryHint;
39
+ readonly context?: AgentErrorContext;
40
+ }
41
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,21 @@
1
+ const AGENT_FAILURE_CATEGORIES = [
2
+ "rate_limited",
3
+ "quota_exhausted",
4
+ "budget_exhausted",
5
+ "execution_limit",
6
+ "context_limit",
7
+ "authentication",
8
+ "permission",
9
+ "invalid_request",
10
+ "overloaded",
11
+ "transport",
12
+ "provider",
13
+ "protocol",
14
+ "internal",
15
+ "unknown"
16
+ ];
17
+ const AGENT_ERROR_CONTEXT_MAX_LENGTH = 160;
18
+ export {
19
+ AGENT_ERROR_CONTEXT_MAX_LENGTH,
20
+ AGENT_FAILURE_CATEGORIES
21
+ };
@@ -1,5 +1,6 @@
1
- import type { AgentArtifactId, AgentApprovalOptionId, AgentCollaborationId, AgentConfigurationRevisionId, AgentError, AgentGeneratedResourceId, AgentInstanceId, AgentIntegrationId, AgentIntegrationResourceId, AgentIntegrationServerId, AgentIntegrationToolId, AgentIsoDateTime, AgentItemId, AgentJsonValue, AgentManagedContentId, AgentEnvironmentId, AgentEffectiveContentId, AgentCommandId, AgentExtensionId, AgentOperationId, AgentOperationInvocationId, AgentProviderConversationId, AgentProviderHistoryAnchor, AgentProviderItemRef, AgentProviderKey, AgentProviderRefs, AgentProviderRequestRef, AgentProviderTurnRef, AgentRequestFieldId, AgentRequestId, AgentSessionId, AgentTurnId } from './types.js';
1
+ import type { AgentArtifactId, AgentApprovalOptionId, AgentCollaborationId, AgentConfigurationRevisionId, AgentGeneratedResourceId, AgentInstanceId, AgentIntegrationId, AgentIntegrationResourceId, AgentIntegrationServerId, AgentIntegrationToolId, AgentIsoDateTime, AgentItemId, AgentJsonValue, AgentManagedContentId, AgentEnvironmentId, AgentEffectiveContentId, AgentCommandId, AgentExtensionId, AgentOperationId, AgentOperationInvocationId, AgentProviderConversationId, AgentProviderHistoryAnchor, AgentProviderItemRef, AgentProviderKey, AgentProviderRefs, AgentProviderRequestRef, AgentProviderTurnRef, AgentRequestFieldId, AgentRequestId, AgentSessionId, AgentTurnId } from './types.js';
2
2
  import type { AgentProtocolParseResult } from './validation.js';
3
+ export { parseAgentError, safeParseAgentError } from '../failures/parsers.js';
3
4
  export declare const parseAgentInstanceId: (input: unknown) => AgentInstanceId;
4
5
  export declare const safeParseAgentInstanceId: (input: unknown) => AgentProtocolParseResult<AgentInstanceId>;
5
6
  export declare const parseAgentSessionId: (input: unknown) => AgentSessionId;
@@ -54,8 +55,6 @@ export declare function parseAgentJsonValue(input: unknown): AgentJsonValue;
54
55
  export declare function safeParseAgentJsonValue(input: unknown): AgentProtocolParseResult<AgentJsonValue>;
55
56
  export declare function parseAgentProviderRefs(input: unknown): AgentProviderRefs;
56
57
  export declare function safeParseAgentProviderRefs(input: unknown): AgentProtocolParseResult<AgentProviderRefs>;
57
- export declare function parseAgentError(input: unknown): AgentError;
58
- export declare function safeParseAgentError(input: unknown): AgentProtocolParseResult<AgentError>;
59
58
  export declare const parseAgentEnvironmentId: (input: unknown) => AgentEnvironmentId;
60
59
  export declare const safeParseAgentEnvironmentId: (input: unknown) => AgentProtocolParseResult<AgentEnvironmentId>;
61
60
  export declare const parseAgentEffectiveContentId: (input: unknown) => AgentEffectiveContentId;
@@ -5,7 +5,6 @@ import {
5
5
  AgentCollaborationIdSchema,
6
6
  AgentConfigurationRevisionIdSchema,
7
7
  AgentGeneratedResourceIdSchema,
8
- AgentErrorSchema,
9
8
  AgentInstanceIdSchema,
10
9
  AgentIntegrationIdSchema,
11
10
  AgentIntegrationResourceIdSchema,
@@ -33,6 +32,7 @@ import {
33
32
  AgentSessionIdSchema,
34
33
  AgentTurnIdSchema
35
34
  } from "../zod/foundation.js";
35
+ import { parseAgentError, safeParseAgentError } from "../failures/parsers.js";
36
36
  function idParser(schema) {
37
37
  return {
38
38
  parse: (input) => parseWithSchema(schema, input),
@@ -164,12 +164,6 @@ function parseAgentProviderRefs(input) {
164
164
  function safeParseAgentProviderRefs(input) {
165
165
  return safeParseWithSchema(AgentProviderRefsSchema, input);
166
166
  }
167
- function parseAgentError(input) {
168
- return parseWithSchema(AgentErrorSchema, input);
169
- }
170
- function safeParseAgentError(input) {
171
- return safeParseWithSchema(AgentErrorSchema, input);
172
- }
173
167
  const environmentIdParser = idParser(AgentEnvironmentIdSchema);
174
168
  const parseAgentEnvironmentId = environmentIdParser.parse;
175
169
  const safeParseAgentEnvironmentId = environmentIdParser.safeParse;
@@ -1,6 +1,7 @@
1
1
  export type { AgentProtocolParseFailure, AgentProtocolParseResult, AgentProtocolParseSuccess, ValidationIssue, ValidationPathSegment, } from './validation.js';
2
2
  export { AgentProtocolValidationError } from './validation.js';
3
- export declare const AGENT_PROTOCOL_VERSION: 9;
3
+ export type { AgentError, AgentErrorContext } from '../failures/types.js';
4
+ export declare const AGENT_PROTOCOL_VERSION: 11;
4
5
  export declare const AGENT_PROTOCOL_ID_MAX_LENGTH = 256;
5
6
  export declare const AGENT_PROTOCOL_PROVIDER_REFERENCE_MAX_LENGTH = 512;
6
7
  export declare const AGENT_PROTOCOL_PROVIDER_KEY_MAX_LENGTH = 100;
@@ -61,16 +62,5 @@ export interface AgentProviderRefs {
61
62
  readonly itemId?: AgentProviderItemRef;
62
63
  readonly requestId?: AgentProviderRequestRef;
63
64
  }
64
- export interface AgentErrorContext {
65
- readonly operation?: string;
66
- readonly component?: string;
67
- readonly status?: string;
68
- }
69
- export interface AgentError {
70
- readonly code: string;
71
- readonly message: string;
72
- readonly retryable: boolean;
73
- readonly context?: AgentErrorContext;
74
- }
75
65
  export declare function agentProtocolSerializedJsonBytes(value: unknown): number;
76
66
  //# sourceMappingURL=types.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { AgentProtocolValidationError } from "./validation.js";
2
- const AGENT_PROTOCOL_VERSION = 9;
2
+ const AGENT_PROTOCOL_VERSION = 11;
3
3
  const AGENT_PROTOCOL_ID_MAX_LENGTH = 256;
4
4
  const AGENT_PROTOCOL_PROVIDER_REFERENCE_MAX_LENGTH = 512;
5
5
  const AGENT_PROTOCOL_PROVIDER_KEY_MAX_LENGTH = 100;