@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 +89 -49
- package/dist/capabilities/types.d.ts +1 -1
- package/dist/events/types.d.ts +9 -3
- package/dist/events/types.js +4 -1
- package/dist/foundation/types.d.ts +1 -1
- package/dist/foundation/types.js +1 -1
- package/dist/jsonSchema/generated.d.ts +11294 -7902
- package/dist/jsonSchema/generated.js +2271 -96
- package/dist/requests/elicitation.d.ts +4 -0
- package/dist/requests/elicitation.js +107 -0
- package/dist/requests/parsers.js +2 -100
- package/dist/sessionInteractions/parsers.d.ts +28 -1
- package/dist/sessionInteractions/parsers.js +165 -12
- package/dist/sessionInteractions/types.d.ts +113 -1
- package/dist/sessionInteractions/types.js +18 -2
- package/dist/zod/capabilities.d.ts +8 -8
- package/dist/zod/collaboration.d.ts +2 -2
- package/dist/zod/events.d.ts +50 -29
- package/dist/zod/events.js +8 -0
- package/dist/zod/index.d.ts +1 -1
- package/dist/zod/index.js +43 -1
- package/dist/zod/operations.d.ts +1 -1
- package/dist/zod/requests.d.ts +99 -7
- package/dist/zod/requests.js +18 -8
- package/dist/zod/sessionInteractions.d.ts +875 -5
- package/dist/zod/sessionInteractions.js +203 -33
- package/dist/zod/turns.d.ts +1 -1
- package/dist/zod/typeEquality.generated.d.ts +20 -2
- package/package.json +2 -2
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
|
|
10
|
-
|
|
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:
|
|
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:
|
|
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
|
|
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
|
-
##
|
|
117
|
-
|
|
118
|
-
`
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
-
|
|
|
143
|
-
| Serialized response | 1,024 UTF-8 bytes |
|
|
144
|
-
|
|
|
145
|
-
|
|
|
146
|
-
|
|
|
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
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
|
250
|
-
`@agen-ai/agent-runtime`. The coordinated source
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
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:
|
|
157
|
+
readonly protocolVersion: 12;
|
|
158
158
|
readonly providerKey: AgentProviderKey;
|
|
159
159
|
readonly sessions: Readonly<{
|
|
160
160
|
create: true;
|
package/dist/events/types.d.ts
CHANGED
|
@@ -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
|
+
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
|
package/dist/events/types.js
CHANGED
|
@@ -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:
|
|
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;
|
package/dist/foundation/types.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AgentProtocolValidationError } from "./validation.js";
|
|
2
|
-
const AGENT_PROTOCOL_VERSION =
|
|
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;
|