@agen-ai/agent-protocol 0.4.1 → 0.4.2

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 CHANGED
@@ -6,8 +6,12 @@ capabilities, typed operations, safe configuration and managed-content inventori
6
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
+ The coordinated unpublished source candidate is `0.4.2` and uses Agent Protocol V12, including exact request
10
+ unavailability and session decisions, forms and plan reviews. Published `0.4.1` retains V11;
11
+ `0.4.0` retains V10. Source versioning does not establish registry publication.
12
+ Keep all installed SDK packages at one coordinated version. The [0.4.2 migration
13
+ guide](../../MIGRATING-TO-0.4.2.md) covers V12 envelopes, tagged session responses and
14
+ the separate ownership of request eligibility, entered receipts and continuation output.
11
15
 
12
16
  ## Ownership boundary
13
17
 
@@ -52,7 +56,7 @@ import {
52
56
  } from '@agen-ai/agent-protocol';
53
57
 
54
58
  const event: AgentEvent = parseAgentEvent({
55
- protocolVersion: 11,
59
+ protocolVersion: 12,
56
60
  type: 'content.delta',
57
61
  sessionId: parseAgentSessionId('external-session:42'),
58
62
  turnId: parseAgentTurnId('external-turn:9'),
@@ -67,7 +71,7 @@ const event: AgentEvent = parseAgentEvent({
67
71
  const roundTripped = parseAgentEvent(JSON.parse(JSON.stringify(event)));
68
72
  ```
69
73
 
70
- Serialized values carry `protocolVersion: 11`; TypeScript API names remain unsuffixed. Unknown
74
+ Serialized values carry `protocolVersion: 12`; TypeScript API names remain unsuffixed. Unknown
71
75
  fields and unsupported protocol versions are rejected.
72
76
 
73
77
  Item snapshots are a closed union keyed by `itemKind`. Common identity and lifecycle fields are
@@ -84,7 +88,7 @@ Approval requests correlate to one live item or exact proposed-plan artifact and
84
88
  bounded list of typed options. Every option declares its decision and a closed `consequence`.
85
89
  `scoped` contains precise `persistence` and `scope`; `provider_managed_remembrance` contains explicit
86
90
  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.
91
+ fields are rejected in V12. Neither approval nor a delivered answer proves the provider wrote a rule.
88
92
  Resolutions select one exact offered `optionId` or explicitly cancel. Supported approval capability
89
93
  requires `providerManagedRemembrance`: false requires a nonempty readonly precise-mode tuple; true
90
94
  allows a bounded readonly array, including empty for a remembered-only provider. Scoped options
@@ -113,44 +117,80 @@ collapse unrelated pools into one percentage. Quantity units remain distinct fro
113
117
  which uses integer minor units with an explicit scale. None of these domains has a generic
114
118
  extension or metadata bag.
115
119
 
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).
120
+ ## Request lifecycle and session interactions
121
+
122
+ `request.unavailable` is a turn event with the existing session, turn and timestamp envelope.
123
+ Its strict payload contains the exact `requestId` and a reason: `withdrawn`, `expired` or
124
+ `unknown`. Each reason requires authoritative unavailability of that exact native callback;
125
+ `expired` describes a provider observation. The event ends answer eligibility. It does not
126
+ complete the execution or rewrite an entered response's delivery receipt. Runtime validation
127
+ owns once-only retirement, original execution correlation and same-session request-ID uniqueness.
128
+
129
+ `AgentSessionRequest` is a closed union of `decision`, `form` and `plan_review` descriptors
130
+ outside a model turn. Each carries `requestId`, `sessionId`, a title, optional description,
131
+ explicit offered choices and optional `expiresAt`. That expiry is only a provider-reported fact;
132
+ the host's effective deadline is a separate runtime observation. Descriptors have no `turnId`,
133
+ provider-native request ID, metadata bag or transport correlation field. The root and focused
134
+ `@agen-ai/agent-protocol/session-interactions` entrypoints expose plain types and parsers.
135
+ Only `/zod` exposes schemas. The `/json-schema` registry contains 35 deterministic contracts,
136
+ including request/response schemas for each session kind and their complete unions.
137
+
138
+ A workspace decision preserves its exact target and grant/decline consequences. A workspace
139
+ `grant` is provider-managed, persistent and may affect other sessions; it covers the workspace
140
+ rather than only the categories detected when the question was created. A `decline` leaves
141
+ configuration gated without promising revocation, persisted denial or suppression of future
142
+ questions. Present the target and consequences before applying a decision policy. V12 responses
143
+ are tagged: `parseAgentSessionDecisionResponseFor(request, { kind: 'decision', choiceId })`.
144
+ The earlier untagged `{ choiceId }` argument is rejected.
145
+
146
+ Forms reuse the exact `AgentElicitationField` and `AgentElicitationAnswer` semantics from turn
147
+ elicitation. A form offers exactly one `submit` action and optionally one `cancel` action, with
148
+ unique choice IDs and distinct actions. Submitted responses carry `answers`; canceled responses
149
+ carry no answers. Required fields, kinds, declared select values, custom-choice permission and
150
+ selection limits are checked against the offered descriptor. Cancellation is an explicit offered
151
+ human action and is never synthesized by timeout or cleanup.
152
+
153
+ Plan reviews contain the complete actual offered text in an immutable `AgentSessionPlanSnapshot`,
154
+ with a neutral `planId`, exact `revision`, title and `plain_text` or `markdown` content. They do
155
+ not dereference paths or URLs. Each offered action is `approve`, `revise` or `abandon`, with unique
156
+ choice IDs and distinct actions; a mapping must offer the action explicitly. Every response
157
+ identifies the exact plan and revision. Only revision responses carry nonblank `feedback`.
158
+ Content changes require a fresh revision and request ID. These identities grant no execution
159
+ or replay authority.
160
+
161
+ `parseAgentSessionResponseFor(request, response)` and the kind-specific helpers reject a wrong
162
+ kind, unoffered choice, mismatched action, invalid field answer and stale plan identity/revision.
163
+ Throwing parsers and their `safeParse...` counterparts use validator-neutral issues. Parsing
164
+ creates detached readonly snapshots and rejects unknown fields, cyclic material, accessors and
165
+ non-JSON values before invoking a getter. The nominal decision/form/review choice IDs, plan ID
166
+ and plan revision are distinct TypeScript types granted only after canonical string validation.
167
+
168
+ `AgentSessionAcceptedResponse` is the bounded accepted-response projection: it retains kind,
169
+ choice and action, plus plan identity/revision when applicable. It omits sensitive form answers
170
+ and revision feedback. Actual response authority belongs to the runtime's bound
171
+ `AgentSessionInteraction.respond` capability. Process-local callbacks, human-wait policy,
172
+ delivery receipts, terminal settlement and cleanup are documented by
173
+ [`@agen-ai/agent-runtime`](../agent-runtime/README.md#session-lifetime-interactions).
139
174
 
140
175
  | Portable bound | Maximum |
141
176
  | --- | --- |
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 |
177
+ | Every serialized session request | 65,536 UTF-8 bytes |
178
+ | Serialized decision response | 1,024 UTF-8 bytes |
179
+ | Serialized form or plan-review response | 65,536 UTF-8 bytes |
180
+ | Offered choices | 16, with unique IDs and distinct form/review actions |
181
+ | Choice ID, plan ID and plan revision | 128 UTF-8 bytes each |
182
+ | Request/plan title and choice label | 120 characters |
147
183
  | Request description | 4,000 characters |
148
184
  | Choice description | 1,000 characters |
149
185
  | Workspace target path | 4,096 UTF-8 bytes |
186
+ | Form fields / options per select / text value | 16 / 100 / 4,000 characters |
187
+ | Complete plan text | 49,152 UTF-8 bytes within the request bound |
188
+ | Revision feedback | 4,000 characters and 16,384 UTF-8 bytes |
150
189
 
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.
190
+ The JSON Schema artifacts name residual parser invariants, including serialized UTF-8 bytes,
191
+ identity/action uniqueness, exact offered-choice membership, form-field correlation and exact
192
+ plan/revision matching. Portable session opening, configuration and turn input do not carry
193
+ runtime human-wait policy or callbacks.
154
194
 
155
195
  ## Errors and trust
156
196
 
@@ -246,19 +286,19 @@ before delegation; a composer can use the same pure functions to preserve and ex
246
286
 
247
287
  ## Versioning and release
248
288
 
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
254
- independent of private transport and product
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
257
- environment and account-quota namespaces each use their own schema version 1.
258
-
259
- The repository release proof builds and packs `@agen-ai/validation`, this package, and
260
- `@agen-ai/agent-runtime`; rejects workspace-only or private references; then typechecks and runs a
261
- consumer outside the monorepo:
289
+ Agent Protocol V12 defines the contract shared by this package, `@agen-ai/validation`, and
290
+ `@agen-ai/agent-runtime`. The coordinated source release is `0.4.2`; published `0.4.1` retains
291
+ V11 and `0.4.0` retains V10. Registry publication and dist-tag state are release metadata outside
292
+ this contract. Earlier public releases remain historical. The complete seven-package public
293
+ release inventory must use one coordinated source version.
294
+
295
+ Protocol V12 is independent of private transport and product persistence versions and replaces
296
+ V11 at live boundaries. There is one current parser. V11 and older serialized data require the
297
+ historical owner's frozen decoder and are rejected by the live V12 parser where versioned.
298
+ The environment and account-quota namespaces each retain their own schema version 1.
299
+
300
+ The repository release proof builds and packs the exact seven-package release set, rejects
301
+ workspace-only or private references, then typechecks and runs a consumer outside the monorepo.
262
302
 
263
303
  From the public repository root, run `pnpm check` to execute the same packed-consumer proof.
264
304
 
@@ -154,7 +154,7 @@ export type AgentTurnSteeringCapability = Readonly<{
154
154
  input: AgentOperationInputCapability;
155
155
  }>;
156
156
  export interface AgentCapabilities {
157
- readonly protocolVersion: 11;
157
+ readonly protocolVersion: 12;
158
158
  readonly providerKey: AgentProviderKey;
159
159
  readonly sessions: Readonly<{
160
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.retrying", "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", "request.unavailable", "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: 11;
11
+ readonly protocolVersion: 12;
12
12
  readonly type: Type;
13
13
  readonly sessionId: AgentSessionId;
14
14
  readonly providerRefs?: AgentProviderRefs;
@@ -50,6 +50,12 @@ export type AgentDiffUpdatedEvent = AgentTurnEventBase<'turn.diff.updated', Agen
50
50
  export type AgentRequestOpenedEvent = AgentTurnEventBase<'request.opened', Readonly<{
51
51
  request: AgentRequest;
52
52
  }>>;
53
+ export declare const AGENT_REQUEST_UNAVAILABLE_REASONS: readonly ["withdrawn", "expired", "unknown"];
54
+ export type AgentRequestUnavailableReason = (typeof AGENT_REQUEST_UNAVAILABLE_REASONS)[number];
55
+ export type AgentRequestUnavailableEvent = AgentTurnEventBase<'request.unavailable', Readonly<{
56
+ requestId: AgentRequestId;
57
+ reason: AgentRequestUnavailableReason;
58
+ }>>;
53
59
  export type AgentProgressUpdatedEvent = AgentTurnEventBase<'progress.updated', Readonly<{
54
60
  progressId: string;
55
61
  kind: 'task' | 'hook' | 'tool' | 'unknown';
@@ -94,6 +100,6 @@ export type AgentProviderDiagnosticEvent = AgentOptionallyTurnScopedEventBase<'p
94
100
  message: string;
95
101
  context?: AgentErrorContext;
96
102
  }>>;
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;
103
+ export type AgentEvent = AgentTurnStartedEvent | AgentTurnStateChangedEvent | AgentTurnCompletedEvent | AgentItemStartedEvent | AgentItemUpdatedEvent | AgentItemCompletedEvent | AgentContentDeltaEvent | AgentPlanUpdatedEvent | AgentPlanProposedEvent | AgentDiffUpdatedEvent | AgentRequestOpenedEvent | AgentRequestUnavailableEvent | AgentProgressUpdatedEvent | AgentContextUsageUpdatedEvent | AgentArtifactReferencedEvent | AgentOperationUpdatedEvent | AgentCollaborationUpdatedEvent | AgentResourceUpdatedEvent | AgentRuntimeRetryingEvent | AgentRuntimeWarningEvent | AgentRuntimeErrorEvent | AgentProviderDiagnosticEvent;
98
104
  export {};
99
105
  //# sourceMappingURL=types.d.ts.map
@@ -10,6 +10,7 @@ const AGENT_EVENT_TYPES = [
10
10
  "turn.plan.proposed",
11
11
  "turn.diff.updated",
12
12
  "request.opened",
13
+ "request.unavailable",
13
14
  "progress.updated",
14
15
  "context.usage.updated",
15
16
  "artifact.referenced",
@@ -21,6 +22,8 @@ const AGENT_EVENT_TYPES = [
21
22
  "runtime.error",
22
23
  "provider.diagnostic"
23
24
  ];
25
+ const AGENT_REQUEST_UNAVAILABLE_REASONS = ["withdrawn", "expired", "unknown"];
24
26
  export {
25
- AGENT_EVENT_TYPES
27
+ AGENT_EVENT_TYPES,
28
+ AGENT_REQUEST_UNAVAILABLE_REASONS
26
29
  };
@@ -1,7 +1,7 @@
1
1
  export type { AgentProtocolParseFailure, AgentProtocolParseResult, AgentProtocolParseSuccess, ValidationIssue, ValidationPathSegment, } from './validation.js';
2
2
  export { AgentProtocolValidationError } from './validation.js';
3
3
  export type { AgentError, AgentErrorContext } from '../failures/types.js';
4
- export declare const AGENT_PROTOCOL_VERSION: 11;
4
+ export declare const AGENT_PROTOCOL_VERSION: 12;
5
5
  export declare const AGENT_PROTOCOL_ID_MAX_LENGTH = 256;
6
6
  export declare const AGENT_PROTOCOL_PROVIDER_REFERENCE_MAX_LENGTH = 512;
7
7
  export declare const AGENT_PROTOCOL_PROVIDER_KEY_MAX_LENGTH = 100;
@@ -1,5 +1,5 @@
1
1
  import { AgentProtocolValidationError } from "./validation.js";
2
- const AGENT_PROTOCOL_VERSION = 11;
2
+ const AGENT_PROTOCOL_VERSION = 12;
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;