@agen-ai/agent-protocol 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -11
- package/dist/capabilities/types.d.ts +32 -3
- package/dist/events/types.d.ts +5 -4
- package/dist/events/types.js +1 -0
- package/dist/foundation/parsers.d.ts +3 -1
- package/dist/foundation/parsers.js +8 -0
- package/dist/foundation/types.d.ts +2 -1
- package/dist/foundation/types.js +1 -1
- package/dist/jsonSchema/generated.d.ts +1116 -216
- package/dist/jsonSchema/generated.js +729 -129
- package/dist/requests/parsers.d.ts +5 -1
- package/dist/requests/parsers.js +26 -0
- package/dist/requests/types.d.ts +30 -7
- package/dist/requests/types.js +23 -0
- package/dist/turns/types.d.ts +38 -0
- package/dist/turns/types.js +33 -0
- package/dist/zod/capabilities.d.ts +74 -2
- package/dist/zod/capabilities.js +96 -1
- package/dist/zod/events.d.ts +107 -17
- package/dist/zod/events.js +57 -0
- package/dist/zod/foundation.d.ts +2 -1
- package/dist/zod/foundation.js +2 -0
- package/dist/zod/index.d.ts +5 -5
- package/dist/zod/index.js +15 -2
- package/dist/zod/requests.d.ts +76 -11
- package/dist/zod/requests.js +56 -11
- package/dist/zod/turns.d.ts +2 -1
- package/dist/zod/turns.js +34 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
} from '@agen-ai/agent-protocol';
|
|
42
42
|
|
|
43
43
|
const event: AgentEvent = parseAgentEvent({
|
|
44
|
-
protocolVersion:
|
|
44
|
+
protocolVersion: 7,
|
|
45
45
|
type: 'content.delta',
|
|
46
46
|
sessionId: parseAgentSessionId('external-session:42'),
|
|
47
47
|
turnId: parseAgentTurnId('external-turn:9'),
|
|
@@ -56,17 +56,25 @@ const event: AgentEvent = parseAgentEvent({
|
|
|
56
56
|
const roundTripped = parseAgentEvent(JSON.parse(JSON.stringify(event)));
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
Serialized values carry `protocolVersion:
|
|
59
|
+
Serialized values carry `protocolVersion: 7`; TypeScript API names remain unsuffixed. Unknown
|
|
60
60
|
fields and unsupported protocol versions are rejected.
|
|
61
61
|
|
|
62
62
|
Item snapshots are a closed union keyed by `itemKind`. Common identity and lifecycle fields are
|
|
63
63
|
shared, while commands, file changes, managed tools, web/computer activity, image views, and
|
|
64
|
-
reviews expose only their bounded semantic `details`.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
reviews expose only their bounded semantic `details`. Context-compaction items require neutral
|
|
65
|
+
details describing the trigger, optional before/after occupancy, duration, and bounded summary
|
|
66
|
+
preview. Message, reasoning, plan, and unknown items have no details. Review details are required
|
|
67
|
+
and distinguish an entered target from an exited report. There is no metadata or provider-native
|
|
68
|
+
attribute bag; source evidence belongs outside the portable event. File-change producers can use
|
|
69
|
+
`compareStringsByUnicodeCodePoint` to emit the canonical path ordering required by the protocol
|
|
70
|
+
across both BMP and supplementary Unicode characters.
|
|
71
|
+
|
|
72
|
+
V7 approval requests correlate to one live item or exact proposed-plan artifact and provide a
|
|
73
|
+
bounded list of typed options. Every option declares its decision, persistence, and neutral scope;
|
|
74
|
+
resolutions select one offered `optionId` or explicitly cancel. Approval capabilities advertise
|
|
75
|
+
the exact persistence/scope combinations an adapter can emit. `context.usage.updated` reports
|
|
76
|
+
bounded occupancy and optional monotonic cumulative counters for an advertised session or
|
|
77
|
+
materialization measurement scope.
|
|
70
78
|
|
|
71
79
|
## Errors and trust
|
|
72
80
|
|
|
@@ -86,10 +94,11 @@ validated protocol output remains canonical across transports and consumers.
|
|
|
86
94
|
|
|
87
95
|
## Versioning and release
|
|
88
96
|
|
|
89
|
-
The package is at `0.
|
|
97
|
+
The package is at `0.2.0` while the public API is still being proven with external adapters. Minor
|
|
90
98
|
releases may include breaking changes during this beta period. Every such change will be called out
|
|
91
|
-
in the release notes. Protocol
|
|
92
|
-
version.
|
|
99
|
+
in the release notes. Protocol V7 is independent of any host transport or product persistence
|
|
100
|
+
version. Version `0.2.0` is a direct break from V6/`0.1.0`; there is no compatibility parser. See
|
|
101
|
+
the repository `MIGRATING-TO-0.2.md` guide for the complete API change matrix.
|
|
93
102
|
|
|
94
103
|
The repository release proof builds and packs `@agen-ai/validation`, this package, and
|
|
95
104
|
`@agen-ai/agent-runtime`; rejects workspace-only or private references; then typechecks and runs a
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AgentArtifactKind } from '../artifacts/index.js';
|
|
2
2
|
import type { AgentProviderKey } from '../foundation/index.js';
|
|
3
|
-
import type { AgentImageInputMediaType, AgentImageInputSourceKind, AgentTurnInteractionMode } from '../turns/types.js';
|
|
3
|
+
import type { AgentContextCompactionTrigger, AgentContextCumulativeUsageField, AgentContextMeasurementScope, AgentImageInputMediaType, AgentImageInputSourceKind, AgentTurnInteractionMode } from '../turns/types.js';
|
|
4
|
+
import type { AgentApprovalPersistence, AgentApprovalScopeKind } from '../requests/types.js';
|
|
4
5
|
export declare const AGENT_ELICITATION_MODES: readonly ["unsupported", "text", "structured"];
|
|
5
6
|
export declare const AGENT_FILE_CHANGE_MODES: readonly ["none", "final_diff", "structured"];
|
|
6
7
|
export declare const AGENT_AUTHENTICATION_FLOWS: readonly ["device_code", "browser", "terminal"];
|
|
@@ -35,6 +36,30 @@ export type AgentAuthenticationCapability = Readonly<{
|
|
|
35
36
|
kind: 'supported';
|
|
36
37
|
flows: readonly AgentAuthenticationFlow[];
|
|
37
38
|
}>;
|
|
39
|
+
export interface AgentApprovalCapabilityMode {
|
|
40
|
+
readonly persistence: AgentApprovalPersistence;
|
|
41
|
+
readonly scopeKinds: readonly AgentApprovalScopeKind[];
|
|
42
|
+
}
|
|
43
|
+
export type AgentApprovalCapability = Readonly<{
|
|
44
|
+
kind: 'unsupported';
|
|
45
|
+
}> | Readonly<{
|
|
46
|
+
kind: 'supported';
|
|
47
|
+
modes: readonly AgentApprovalCapabilityMode[];
|
|
48
|
+
}>;
|
|
49
|
+
export type AgentContextUsageCapability = Readonly<{
|
|
50
|
+
kind: 'unsupported';
|
|
51
|
+
}> | Readonly<{
|
|
52
|
+
kind: 'supported';
|
|
53
|
+
measurementScopes: readonly AgentContextMeasurementScope[];
|
|
54
|
+
cumulativeFields: readonly AgentContextCumulativeUsageField[];
|
|
55
|
+
}>;
|
|
56
|
+
export type AgentContextCompactionCapability = Readonly<{
|
|
57
|
+
kind: 'unsupported';
|
|
58
|
+
}> | Readonly<{
|
|
59
|
+
kind: 'supported';
|
|
60
|
+
triggers: readonly AgentContextCompactionTrigger[];
|
|
61
|
+
sameSessionContinuation: boolean;
|
|
62
|
+
}>;
|
|
38
63
|
export type AgentImageInputCapability = Readonly<{
|
|
39
64
|
kind: 'unsupported';
|
|
40
65
|
}> | Readonly<{
|
|
@@ -60,7 +85,7 @@ export type AgentTurnSteeringCapability = Readonly<{
|
|
|
60
85
|
input: AgentOperationInputCapability;
|
|
61
86
|
}>;
|
|
62
87
|
export interface AgentCapabilities {
|
|
63
|
-
readonly protocolVersion:
|
|
88
|
+
readonly protocolVersion: 7;
|
|
64
89
|
readonly providerKey: AgentProviderKey;
|
|
65
90
|
readonly sessions: Readonly<{
|
|
66
91
|
create: true;
|
|
@@ -73,9 +98,13 @@ export interface AgentCapabilities {
|
|
|
73
98
|
steer: AgentTurnSteeringCapability;
|
|
74
99
|
}>;
|
|
75
100
|
readonly requests: Readonly<{
|
|
76
|
-
approval:
|
|
101
|
+
approval: AgentApprovalCapability;
|
|
77
102
|
elicitation: AgentElicitationCapability;
|
|
78
103
|
}>;
|
|
104
|
+
readonly context: Readonly<{
|
|
105
|
+
usage: AgentContextUsageCapability;
|
|
106
|
+
compaction: AgentContextCompactionCapability;
|
|
107
|
+
}>;
|
|
79
108
|
readonly input: AgentOperationInputCapability;
|
|
80
109
|
readonly output: Readonly<{
|
|
81
110
|
streaming: boolean;
|
package/dist/events/types.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { AgentArtifactDescriptor } from '../artifacts/index.js';
|
|
2
2
|
import type { AgentArtifactId, AgentError, AgentErrorContext, AgentIsoDateTime, AgentItemId, AgentProviderRefs, AgentRequestId, AgentSessionId, AgentTurnId } from '../foundation/index.js';
|
|
3
3
|
import type { AgentRequest } from '../requests/index.js';
|
|
4
|
-
import type { AgentContentStreamKind, AgentDiffSummary, AgentItemSnapshot, AgentPlanStep, AgentTurnCompletedPayload, AgentTurnState } from '../turns/index.js';
|
|
5
|
-
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", "artifact.referenced", "runtime.warning", "runtime.error", "provider.diagnostic"];
|
|
4
|
+
import type { AgentContentStreamKind, AgentContextUsage, AgentDiffSummary, AgentItemSnapshot, AgentPlanStep, AgentTurnCompletedPayload, AgentTurnState } from '../turns/index.js';
|
|
5
|
+
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", "runtime.warning", "runtime.error", "provider.diagnostic"];
|
|
6
6
|
export type AgentEventType = (typeof AGENT_EVENT_TYPES)[number];
|
|
7
7
|
interface AgentEventBase<Type extends AgentEventType, Payload> {
|
|
8
|
-
readonly protocolVersion:
|
|
8
|
+
readonly protocolVersion: 7;
|
|
9
9
|
readonly type: Type;
|
|
10
10
|
readonly sessionId: AgentSessionId;
|
|
11
11
|
readonly providerRefs?: AgentProviderRefs;
|
|
@@ -56,6 +56,7 @@ export type AgentProgressUpdatedEvent = AgentTurnEventBase<'progress.updated', R
|
|
|
56
56
|
current?: number;
|
|
57
57
|
total?: number;
|
|
58
58
|
}>>;
|
|
59
|
+
export type AgentContextUsageUpdatedEvent = AgentTurnEventBase<'context.usage.updated', AgentContextUsage>;
|
|
59
60
|
export type AgentArtifactReferencedEvent = AgentOptionallyTurnScopedEventBase<'artifact.referenced', Readonly<{
|
|
60
61
|
artifact: AgentArtifactDescriptor;
|
|
61
62
|
}>>;
|
|
@@ -73,6 +74,6 @@ export type AgentProviderDiagnosticEvent = AgentOptionallyTurnScopedEventBase<'p
|
|
|
73
74
|
message: string;
|
|
74
75
|
context?: AgentErrorContext;
|
|
75
76
|
}>>;
|
|
76
|
-
export type AgentEvent = AgentTurnStartedEvent | AgentTurnStateChangedEvent | AgentTurnCompletedEvent | AgentItemStartedEvent | AgentItemUpdatedEvent | AgentItemCompletedEvent | AgentContentDeltaEvent | AgentPlanUpdatedEvent | AgentPlanProposedEvent | AgentDiffUpdatedEvent | AgentRequestOpenedEvent | AgentProgressUpdatedEvent | AgentArtifactReferencedEvent | AgentRuntimeWarningEvent | AgentRuntimeErrorEvent | AgentProviderDiagnosticEvent;
|
|
77
|
+
export type AgentEvent = AgentTurnStartedEvent | AgentTurnStateChangedEvent | AgentTurnCompletedEvent | AgentItemStartedEvent | AgentItemUpdatedEvent | AgentItemCompletedEvent | AgentContentDeltaEvent | AgentPlanUpdatedEvent | AgentPlanProposedEvent | AgentDiffUpdatedEvent | AgentRequestOpenedEvent | AgentProgressUpdatedEvent | AgentContextUsageUpdatedEvent | AgentArtifactReferencedEvent | AgentRuntimeWarningEvent | AgentRuntimeErrorEvent | AgentProviderDiagnosticEvent;
|
|
77
78
|
export {};
|
|
78
79
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/events/types.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AgentArtifactId, AgentConfigurationRevisionId, AgentError, AgentInstanceId, AgentIsoDateTime, AgentItemId, AgentJsonValue, AgentProviderConversationId, AgentProviderHistoryAnchor, AgentProviderItemRef, AgentProviderKey, AgentProviderRefs, AgentProviderRequestRef, AgentProviderTurnRef, AgentRequestFieldId, AgentRequestId, AgentSessionId, AgentTurnId } from './types.js';
|
|
1
|
+
import type { AgentArtifactId, AgentApprovalOptionId, AgentConfigurationRevisionId, AgentError, AgentInstanceId, AgentIsoDateTime, AgentItemId, AgentJsonValue, AgentProviderConversationId, AgentProviderHistoryAnchor, AgentProviderItemRef, AgentProviderKey, AgentProviderRefs, AgentProviderRequestRef, AgentProviderTurnRef, AgentRequestFieldId, AgentRequestId, AgentSessionId, AgentTurnId } from './types.js';
|
|
2
2
|
import type { AgentProtocolParseResult } from './validation.js';
|
|
3
3
|
export declare const parseAgentInstanceId: (input: unknown) => AgentInstanceId;
|
|
4
4
|
export declare const safeParseAgentInstanceId: (input: unknown) => AgentProtocolParseResult<AgentInstanceId>;
|
|
@@ -10,6 +10,8 @@ export declare const parseAgentItemId: (input: unknown) => AgentItemId;
|
|
|
10
10
|
export declare const safeParseAgentItemId: (input: unknown) => AgentProtocolParseResult<AgentItemId>;
|
|
11
11
|
export declare const parseAgentRequestId: (input: unknown) => AgentRequestId;
|
|
12
12
|
export declare const safeParseAgentRequestId: (input: unknown) => AgentProtocolParseResult<AgentRequestId>;
|
|
13
|
+
export declare const parseAgentApprovalOptionId: (input: unknown) => AgentApprovalOptionId;
|
|
14
|
+
export declare const safeParseAgentApprovalOptionId: (input: unknown) => AgentProtocolParseResult<AgentApprovalOptionId>;
|
|
13
15
|
export declare const parseAgentRequestFieldId: (input: unknown) => AgentRequestFieldId;
|
|
14
16
|
export declare const safeParseAgentRequestFieldId: (input: unknown) => AgentProtocolParseResult<AgentRequestFieldId>;
|
|
15
17
|
export declare const parseAgentArtifactId: (input: unknown) => AgentArtifactId;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { parseWithSchema, safeParseWithSchema } from "../internal/parsers.js";
|
|
2
2
|
import {
|
|
3
3
|
AgentArtifactIdSchema,
|
|
4
|
+
AgentApprovalOptionIdSchema,
|
|
4
5
|
AgentConfigurationRevisionIdSchema,
|
|
5
6
|
AgentErrorSchema,
|
|
6
7
|
AgentInstanceIdSchema,
|
|
@@ -30,6 +31,9 @@ const sessionIdParser = idParser(AgentSessionIdSchema);
|
|
|
30
31
|
const turnIdParser = idParser(AgentTurnIdSchema);
|
|
31
32
|
const itemIdParser = idParser(AgentItemIdSchema);
|
|
32
33
|
const requestIdParser = idParser(AgentRequestIdSchema);
|
|
34
|
+
const approvalOptionIdParser = idParser(
|
|
35
|
+
AgentApprovalOptionIdSchema
|
|
36
|
+
);
|
|
33
37
|
const requestFieldIdParser = idParser(
|
|
34
38
|
AgentRequestFieldIdSchema
|
|
35
39
|
);
|
|
@@ -62,6 +66,8 @@ const parseAgentItemId = itemIdParser.parse;
|
|
|
62
66
|
const safeParseAgentItemId = itemIdParser.safeParse;
|
|
63
67
|
const parseAgentRequestId = requestIdParser.parse;
|
|
64
68
|
const safeParseAgentRequestId = requestIdParser.safeParse;
|
|
69
|
+
const parseAgentApprovalOptionId = approvalOptionIdParser.parse;
|
|
70
|
+
const safeParseAgentApprovalOptionId = approvalOptionIdParser.safeParse;
|
|
65
71
|
const parseAgentRequestFieldId = requestFieldIdParser.parse;
|
|
66
72
|
const safeParseAgentRequestFieldId = requestFieldIdParser.safeParse;
|
|
67
73
|
const parseAgentArtifactId = artifactIdParser.parse;
|
|
@@ -109,6 +115,7 @@ function safeParseAgentError(input) {
|
|
|
109
115
|
return safeParseWithSchema(AgentErrorSchema, input);
|
|
110
116
|
}
|
|
111
117
|
export {
|
|
118
|
+
parseAgentApprovalOptionId,
|
|
112
119
|
parseAgentArtifactId,
|
|
113
120
|
parseAgentConfigurationRevisionId,
|
|
114
121
|
parseAgentError,
|
|
@@ -127,6 +134,7 @@ export {
|
|
|
127
134
|
parseAgentRequestId,
|
|
128
135
|
parseAgentSessionId,
|
|
129
136
|
parseAgentTurnId,
|
|
137
|
+
safeParseAgentApprovalOptionId,
|
|
130
138
|
safeParseAgentArtifactId,
|
|
131
139
|
safeParseAgentConfigurationRevisionId,
|
|
132
140
|
safeParseAgentError,
|
|
@@ -1,6 +1,6 @@
|
|
|
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:
|
|
3
|
+
export declare const AGENT_PROTOCOL_VERSION: 7;
|
|
4
4
|
export declare const AGENT_PROTOCOL_ID_MAX_LENGTH = 256;
|
|
5
5
|
export declare const AGENT_PROTOCOL_PROVIDER_REFERENCE_MAX_LENGTH = 512;
|
|
6
6
|
export declare const AGENT_PROTOCOL_PROVIDER_KEY_MAX_LENGTH = 100;
|
|
@@ -22,6 +22,7 @@ export type AgentSessionId = AgentProtocolId<'AgentSessionId'>;
|
|
|
22
22
|
export type AgentTurnId = AgentProtocolId<'AgentTurnId'>;
|
|
23
23
|
export type AgentItemId = AgentProtocolId<'AgentItemId'>;
|
|
24
24
|
export type AgentRequestId = AgentProtocolId<'AgentRequestId'>;
|
|
25
|
+
export type AgentApprovalOptionId = AgentProtocolId<'AgentApprovalOptionId'>;
|
|
25
26
|
export type AgentRequestFieldId = AgentProtocolId<'AgentRequestFieldId'>;
|
|
26
27
|
export type AgentArtifactId = AgentProtocolId<'AgentArtifactId'>;
|
|
27
28
|
export type AgentConfigurationRevisionId = AgentProtocolId<'AgentConfigurationRevisionId'>;
|
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 = 7;
|
|
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;
|