@agen-ai/agent-protocol 0.4.0 → 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.
Files changed (39) hide show
  1. package/README.md +115 -18
  2. package/dist/capabilities/types.d.ts +6 -1
  3. package/dist/events/types.d.ts +9 -3
  4. package/dist/events/types.js +4 -1
  5. package/dist/foundation/types.d.ts +1 -1
  6. package/dist/foundation/types.js +1 -1
  7. package/dist/jsonSchema/generated.d.ts +11214 -7152
  8. package/dist/jsonSchema/generated.js +2835 -227
  9. package/dist/public/index.d.ts +1 -0
  10. package/dist/public/index.js +1 -0
  11. package/dist/public/sessionInteractions.d.ts +2 -0
  12. package/dist/public/sessionInteractions.js +1 -0
  13. package/dist/requests/elicitation.d.ts +4 -0
  14. package/dist/requests/elicitation.js +107 -0
  15. package/dist/requests/parsers.js +2 -100
  16. package/dist/requests/types.d.ts +17 -4
  17. package/dist/sessionInteractions/index.d.ts +3 -0
  18. package/dist/sessionInteractions/index.js +2 -0
  19. package/dist/sessionInteractions/parsers.d.ts +37 -0
  20. package/dist/sessionInteractions/parsers.js +201 -0
  21. package/dist/sessionInteractions/types.d.ts +162 -0
  22. package/dist/sessionInteractions/types.js +34 -0
  23. package/dist/zod/capabilities.d.ts +72 -6
  24. package/dist/zod/capabilities.js +32 -30
  25. package/dist/zod/collaboration.d.ts +2 -2
  26. package/dist/zod/events.d.ts +75 -42
  27. package/dist/zod/events.js +8 -0
  28. package/dist/zod/foundation.d.ts +1 -0
  29. package/dist/zod/foundation.js +15 -2
  30. package/dist/zod/index.d.ts +2 -1
  31. package/dist/zod/index.js +60 -0
  32. package/dist/zod/operations.d.ts +1 -1
  33. package/dist/zod/requests.d.ts +175 -32
  34. package/dist/zod/requests.js +33 -10
  35. package/dist/zod/sessionInteractions.d.ts +925 -0
  36. package/dist/zod/sessionInteractions.js +284 -0
  37. package/dist/zod/turns.d.ts +1 -1
  38. package/dist/zod/typeEquality.generated.d.ts +38 -4
  39. package/package.json +6 -2
package/README.md CHANGED
@@ -6,6 +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 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.
9
15
 
10
16
  ## Ownership boundary
11
17
 
@@ -30,7 +36,7 @@ carry no fabricated windows or hints.
30
36
  ## Entrypoints
31
37
 
32
38
  - `@agen-ai/agent-protocol` exports the complete plain API.
33
- - `/sessions`, `/turns`, `/requests`, `/events`, `/capabilities`, `/artifacts`, `/operations`,
39
+ - `/sessions`, `/session-interactions`, `/turns`, `/requests`, `/events`, `/capabilities`, `/artifacts`, `/operations`,
34
40
  `/configuration`, `/managed-content`, `/integrations`, `/collaboration`, `/resources`, and
35
41
  `/account-quota`, `/effective-content`, `/commands`, `/extensions`, and `/environment` are focused plain entrypoints.
36
42
  - `/zod` is the only entrypoint that exposes Zod schemas.
@@ -50,7 +56,7 @@ import {
50
56
  } from '@agen-ai/agent-protocol';
51
57
 
52
58
  const event: AgentEvent = parseAgentEvent({
53
- protocolVersion: 10,
59
+ protocolVersion: 12,
54
60
  type: 'content.delta',
55
61
  sessionId: parseAgentSessionId('external-session:42'),
56
62
  turnId: parseAgentTurnId('external-turn:9'),
@@ -65,7 +71,7 @@ const event: AgentEvent = parseAgentEvent({
65
71
  const roundTripped = parseAgentEvent(JSON.parse(JSON.stringify(event)));
66
72
  ```
67
73
 
68
- Serialized values carry `protocolVersion: 10`; TypeScript API names remain unsuffixed. Unknown
74
+ Serialized values carry `protocolVersion: 12`; TypeScript API names remain unsuffixed. Unknown
69
75
  fields and unsupported protocol versions are rejected.
70
76
 
71
77
  Item snapshots are a closed union keyed by `itemKind`. Common identity and lifecycle fields are
@@ -79,9 +85,24 @@ attribute bag; source evidence belongs outside the portable event. File-change p
79
85
  across both BMP and supplementary Unicode characters.
80
86
 
81
87
  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
88
+ bounded list of typed options. Every option declares its decision and a closed `consequence`.
89
+ `scoped` contains precise `persistence` and `scope`; `provider_managed_remembrance` contains explicit
90
+ unknown duration and applicability and a required bounded explanation. Flat persistence/scope
91
+ fields are rejected in V12. Neither approval nor a delivered answer proves the provider wrote a rule.
92
+ Resolutions select one exact offered `optionId` or explicitly cancel. Supported approval capability
93
+ requires `providerManagedRemembrance`: false requires a nonempty readonly precise-mode tuple; true
94
+ allows a bounded readonly array, including empty for a remembered-only provider. Scoped options
95
+ must fit an exact declared mode; remembered options require the true capability. The SDK owns no
96
+ permission database, answer cache, pattern editor, provider payload bag, or revoke API.
97
+
98
+ Consumers should present each offered decision and consequence together. Several options can have
99
+ the same immediate decision and different consequences, so selecting the first `approved` option
100
+ cannot express a person's choice reliably. Return the exact selected `optionId`; keep deny-once,
101
+ deny-and-remember, and explicit cancellation distinct. Show the remembered option's explanation
102
+ and unknown duration/applicability without converting observed provider behavior into a session,
103
+ workspace, path-pattern, or permanent grant.
104
+
105
+ `context.usage.updated` reports
85
106
  bounded occupancy and optional monotonic cumulative counters for an advertised session or
86
107
  materialization measurement scope.
87
108
 
@@ -96,6 +117,81 @@ collapse unrelated pools into one percentage. Quantity units remain distinct fro
96
117
  which uses integer minor units with an explicit scale. None of these domains has a generic
97
118
  extension or metadata bag.
98
119
 
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).
174
+
175
+ | Portable bound | Maximum |
176
+ | --- | --- |
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 |
183
+ | Request description | 4,000 characters |
184
+ | Choice description | 1,000 characters |
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 |
189
+
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.
194
+
99
195
  ## Errors and trust
100
196
 
101
197
  `AgentError` contains required `category`, stable `code`, safe `message`, tagged `recovery`, and
@@ -190,18 +286,19 @@ before delegation; a composer can use the same pure functions to preserve and ex
190
286
 
191
287
  ## Versioning and release
192
288
 
193
- Agent Protocol V10 defines the coordinated SDK `0.4.0` contract shared by this package,
194
- `@agen-ai/validation`, and `@agen-ai/agent-runtime`. Registry publication and dist-tag state are
195
- release metadata outside this contract. The earlier public `0.3.0` and `0.3.1` releases remain historical.
196
- The complete seven-package public release inventory must use one coordinated source version. Protocol V10 is
197
- independent of private transport and product
198
- persistence versions and directly replaces V9 at live boundaries. There is one current parser. V9
199
- serialized data requires the historical owner's frozen decoder and is rejected by the live V10 parser. The
200
- environment and account-quota namespaces each use their own schema version 1.
201
-
202
- The repository release proof builds and packs `@agen-ai/validation`, this package, and
203
- `@agen-ai/agent-runtime`; rejects workspace-only or private references; then typechecks and runs a
204
- 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.
205
302
 
206
303
  From the public repository root, run `pnpm check` to execute the same packed-consumer proof.
207
304
 
@@ -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: 10;
157
+ readonly protocolVersion: 12;
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.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: 10;
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: 10;
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 = 10;
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;