@agen-ai/agent-protocol 0.1.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/LICENSE +21 -0
- package/README.md +101 -0
- package/dist/artifacts/index.d.ts +3 -0
- package/dist/artifacts/index.js +2 -0
- package/dist/artifacts/parsers.d.ts +5 -0
- package/dist/artifacts/parsers.js +12 -0
- package/dist/artifacts/types.d.ts +19 -0
- package/dist/artifacts/types.js +16 -0
- package/dist/capabilities/index.d.ts +3 -0
- package/dist/capabilities/index.js +2 -0
- package/dist/capabilities/parsers.d.ts +6 -0
- package/dist/capabilities/parsers.js +18 -0
- package/dist/capabilities/types.d.ts +96 -0
- package/dist/capabilities/types.js +20 -0
- package/dist/events/index.d.ts +3 -0
- package/dist/events/index.js +2 -0
- package/dist/events/parsers.d.ts +6 -0
- package/dist/events/parsers.js +16 -0
- package/dist/events/types.d.ts +78 -0
- package/dist/events/types.js +21 -0
- package/dist/foundation/index.d.ts +4 -0
- package/dist/foundation/index.js +3 -0
- package/dist/foundation/ordering.d.ts +2 -0
- package/dist/foundation/ordering.js +15 -0
- package/dist/foundation/parsers.d.ts +39 -0
- package/dist/foundation/parsers.js +148 -0
- package/dist/foundation/types.d.ts +62 -0
- package/dist/foundation/types.js +39 -0
- package/dist/foundation/validation.d.ts +16 -0
- package/dist/foundation/validation.js +11 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/internal/parsers.d.ts +5 -0
- package/dist/internal/parsers.js +21 -0
- package/dist/jsonSchema/generated.d.ts +6667 -0
- package/dist/jsonSchema/generated.js +4150 -0
- package/dist/jsonSchema/index.d.ts +2 -0
- package/dist/jsonSchema/index.js +1 -0
- package/dist/public/artifacts.d.ts +2 -0
- package/dist/public/artifacts.js +1 -0
- package/dist/public/capabilities.d.ts +2 -0
- package/dist/public/capabilities.js +1 -0
- package/dist/public/events.d.ts +2 -0
- package/dist/public/events.js +1 -0
- package/dist/public/index.d.ts +8 -0
- package/dist/public/index.js +7 -0
- package/dist/public/requests.d.ts +2 -0
- package/dist/public/requests.js +1 -0
- package/dist/public/sessions.d.ts +2 -0
- package/dist/public/sessions.js +1 -0
- package/dist/public/turns.d.ts +2 -0
- package/dist/public/turns.js +1 -0
- package/dist/requests/index.d.ts +3 -0
- package/dist/requests/index.js +2 -0
- package/dist/requests/parsers.d.ts +9 -0
- package/dist/requests/parsers.js +134 -0
- package/dist/requests/types.d.ts +89 -0
- package/dist/requests/types.js +0 -0
- package/dist/sessions/index.d.ts +3 -0
- package/dist/sessions/index.js +2 -0
- package/dist/sessions/parsers.d.ts +10 -0
- package/dist/sessions/parsers.js +38 -0
- package/dist/sessions/types.d.ts +37 -0
- package/dist/sessions/types.js +0 -0
- package/dist/turns/index.d.ts +3 -0
- package/dist/turns/index.js +2 -0
- package/dist/turns/parsers.d.ts +11 -0
- package/dist/turns/parsers.js +41 -0
- package/dist/turns/types.d.ts +207 -0
- package/dist/turns/types.js +62 -0
- package/dist/zod/artifacts.d.ts +4 -0
- package/dist/zod/artifacts.js +28 -0
- package/dist/zod/capabilities.d.ts +180 -0
- package/dist/zod/capabilities.js +222 -0
- package/dist/zod/events.d.ts +357 -0
- package/dist/zod/events.js +190 -0
- package/dist/zod/foundation.d.ts +45 -0
- package/dist/zod/foundation.js +205 -0
- package/dist/zod/index.d.ts +9 -0
- package/dist/zod/index.js +118 -0
- package/dist/zod/requests.d.ts +123 -0
- package/dist/zod/requests.js +174 -0
- package/dist/zod/sessions.d.ts +65 -0
- package/dist/zod/sessions.js +124 -0
- package/dist/zod/turns.d.ts +219 -0
- package/dist/zod/turns.js +400 -0
- package/dist/zod/typeEquality.generated.d.ts +51 -0
- package/dist/zod/typeEquality.generated.js +0 -0
- package/package.json +95 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Trevor Nichols
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# `@agen-ai/agent-protocol`
|
|
2
|
+
|
|
3
|
+
`@agen-ai/agent-protocol` is the provider-neutral data contract for coding-agent runtimes. It
|
|
4
|
+
defines opaque identifiers, sessions, turns, approval and elicitation requests, technical
|
|
5
|
+
capabilities, portable artifact descriptors, and provider-observed events. The package does not
|
|
6
|
+
define a transport or execution runtime.
|
|
7
|
+
|
|
8
|
+
## Ownership boundary
|
|
9
|
+
|
|
10
|
+
The protocol deliberately has no concept of a tenant, SaaS product, database row, assigned actor,
|
|
11
|
+
host lease, persistence sequence, member visibility, billing rule, or storage backend. Opaque IDs
|
|
12
|
+
are correlation values supplied by the caller; they are never authorization credentials.
|
|
13
|
+
|
|
14
|
+
Use `@agen-ai/agent-runtime` for the process-local driver and adapter SPI. A product control plane
|
|
15
|
+
is responsible for authorization, scheduling, persistence, audit attribution, and mapping its own
|
|
16
|
+
identities to protocol IDs.
|
|
17
|
+
|
|
18
|
+
`capabilities.turns.steer` is only the provider's technical ability to accept canonical input into
|
|
19
|
+
the currently running turn. It does not describe, authorize, or implement future-turn queueing;
|
|
20
|
+
that product concern belongs to the caller's control plane.
|
|
21
|
+
|
|
22
|
+
## Entrypoints
|
|
23
|
+
|
|
24
|
+
- `@agen-ai/agent-protocol` exports the complete plain API.
|
|
25
|
+
- `/sessions`, `/turns`, `/requests`, `/events`, `/capabilities`, and `/artifacts` are focused plain
|
|
26
|
+
entrypoints.
|
|
27
|
+
- `/zod` is the only entrypoint that exposes Zod schemas.
|
|
28
|
+
- `/json-schema` exposes deterministic draft 2020-12 schema artifacts.
|
|
29
|
+
|
|
30
|
+
Ordinary entrypoints expose plain TypeScript types, constants, parsers, and validator-neutral
|
|
31
|
+
issues. Their declarations do not expose Zod.
|
|
32
|
+
|
|
33
|
+
## Protocol-only example
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import {
|
|
37
|
+
parseAgentEvent,
|
|
38
|
+
parseAgentSessionId,
|
|
39
|
+
parseAgentTurnId,
|
|
40
|
+
type AgentEvent,
|
|
41
|
+
} from '@agen-ai/agent-protocol';
|
|
42
|
+
|
|
43
|
+
const event: AgentEvent = parseAgentEvent({
|
|
44
|
+
protocolVersion: 6,
|
|
45
|
+
type: 'content.delta',
|
|
46
|
+
sessionId: parseAgentSessionId('external-session:42'),
|
|
47
|
+
turnId: parseAgentTurnId('external-turn:9'),
|
|
48
|
+
occurredAt: '2026-08-03T20:00:00.000Z',
|
|
49
|
+
payload: {
|
|
50
|
+
itemId: 'assistant-message:1',
|
|
51
|
+
streamKind: 'assistant_text',
|
|
52
|
+
delta: 'Hello from a provider.',
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const roundTripped = parseAgentEvent(JSON.parse(JSON.stringify(event)));
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Serialized values carry `protocolVersion: 6`; TypeScript API names remain unsuffixed. Unknown
|
|
60
|
+
fields and unsupported protocol versions are rejected.
|
|
61
|
+
|
|
62
|
+
Item snapshots are a closed union keyed by `itemKind`. Common identity and lifecycle fields are
|
|
63
|
+
shared, while commands, file changes, managed tools, web/computer activity, image views, and
|
|
64
|
+
reviews expose only their bounded semantic `details`. Message, reasoning, plan, compaction, and
|
|
65
|
+
unknown items have no details. Review details are required and distinguish an entered target from
|
|
66
|
+
an exited report. There is no metadata or provider-native attribute bag; source evidence belongs
|
|
67
|
+
outside the portable event. File-change producers can use `compareStringsByUnicodeCodePoint` to
|
|
68
|
+
emit the canonical path ordering required by the protocol across both BMP and supplementary
|
|
69
|
+
Unicode characters.
|
|
70
|
+
|
|
71
|
+
## Errors and trust
|
|
72
|
+
|
|
73
|
+
Throwing parsers raise `AgentProtocolValidationError`, a `TypeError` with stable, JSON-safe
|
|
74
|
+
`issues`. Each corresponding `safeParse...` function returns either parsed data or the same issue
|
|
75
|
+
array without throwing. Callers should branch on that public result or error class, not on Zod
|
|
76
|
+
classes or native issue objects.
|
|
77
|
+
|
|
78
|
+
Opaque identifiers provide correlation, not authorization. A host must authorize the actor,
|
|
79
|
+
select the provider instance, constrain the working directory, and map product identities before
|
|
80
|
+
constructing protocol input. Unknown fields are rejected; the protocol has no metadata escape
|
|
81
|
+
hatch for carrying authority or private provider evidence. Portable JSON objects also reject the
|
|
82
|
+
prototype-sensitive keys `__proto__`, `constructor`, and `prototype`; ordinary parsers and the
|
|
83
|
+
published JSON Schemas enforce the same rule. Plan-step and progress identifiers, diagnostic codes,
|
|
84
|
+
messages, and error context must contain non-whitespace content without surrounding whitespace so
|
|
85
|
+
validated protocol output remains canonical across transports and consumers.
|
|
86
|
+
|
|
87
|
+
## Versioning and release
|
|
88
|
+
|
|
89
|
+
The package is at `0.1.0` while the public API is still being proven with external adapters. Minor
|
|
90
|
+
releases may include breaking changes during this beta period. Every such change will be called out
|
|
91
|
+
in the release notes. Protocol V6 is independent of any host transport or product persistence
|
|
92
|
+
version.
|
|
93
|
+
|
|
94
|
+
The repository release proof builds and packs `@agen-ai/validation`, this package, and
|
|
95
|
+
`@agen-ai/agent-runtime`; rejects workspace-only or private references; then typechecks and runs a
|
|
96
|
+
consumer outside the monorepo:
|
|
97
|
+
|
|
98
|
+
From the public repository root, run `pnpm check` to execute the same packed-consumer proof.
|
|
99
|
+
|
|
100
|
+
That command does not publish. Registry publication, provenance submission, tags, and release
|
|
101
|
+
credentials require a separately authorized release.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AgentProtocolParseResult } from '../foundation/index.js';
|
|
2
|
+
import type { AgentArtifactDescriptor } from './types.js';
|
|
3
|
+
export declare function parseAgentArtifactDescriptor(input: unknown): AgentArtifactDescriptor;
|
|
4
|
+
export declare function safeParseAgentArtifactDescriptor(input: unknown): AgentProtocolParseResult<AgentArtifactDescriptor>;
|
|
5
|
+
//# sourceMappingURL=parsers.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { parseWithSchema, safeParseWithSchema } from "../internal/parsers.js";
|
|
2
|
+
import { AgentArtifactDescriptorSchema } from "../zod/artifacts.js";
|
|
3
|
+
function parseAgentArtifactDescriptor(input) {
|
|
4
|
+
return parseWithSchema(AgentArtifactDescriptorSchema, input);
|
|
5
|
+
}
|
|
6
|
+
function safeParseAgentArtifactDescriptor(input) {
|
|
7
|
+
return safeParseWithSchema(AgentArtifactDescriptorSchema, input);
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
parseAgentArtifactDescriptor,
|
|
11
|
+
safeParseAgentArtifactDescriptor
|
|
12
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AgentArtifactId } from '../foundation/index.js';
|
|
2
|
+
export declare const AGENT_ARTIFACT_KINDS: readonly ["plan", "diff", "file", "log", "image", "report", "other"];
|
|
3
|
+
export declare const AGENT_ARTIFACT_DISPLAY_NAME_MAX_LENGTH = 200;
|
|
4
|
+
export declare const AGENT_ARTIFACT_BYTE_SIZE_MAX: number;
|
|
5
|
+
export type AgentArtifactKind = (typeof AGENT_ARTIFACT_KINDS)[number];
|
|
6
|
+
export interface AgentArtifactDigest {
|
|
7
|
+
readonly algorithm: 'sha256';
|
|
8
|
+
readonly value: string;
|
|
9
|
+
}
|
|
10
|
+
export interface AgentArtifactDescriptor {
|
|
11
|
+
readonly artifactId: AgentArtifactId;
|
|
12
|
+
readonly kind: AgentArtifactKind;
|
|
13
|
+
readonly displayName: string;
|
|
14
|
+
readonly mediaType?: string;
|
|
15
|
+
readonly byteSize?: number;
|
|
16
|
+
readonly digest?: AgentArtifactDigest;
|
|
17
|
+
readonly summary?: string;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const AGENT_ARTIFACT_KINDS = [
|
|
2
|
+
"plan",
|
|
3
|
+
"diff",
|
|
4
|
+
"file",
|
|
5
|
+
"log",
|
|
6
|
+
"image",
|
|
7
|
+
"report",
|
|
8
|
+
"other"
|
|
9
|
+
];
|
|
10
|
+
const AGENT_ARTIFACT_DISPLAY_NAME_MAX_LENGTH = 200;
|
|
11
|
+
const AGENT_ARTIFACT_BYTE_SIZE_MAX = Number.MAX_SAFE_INTEGER;
|
|
12
|
+
export {
|
|
13
|
+
AGENT_ARTIFACT_BYTE_SIZE_MAX,
|
|
14
|
+
AGENT_ARTIFACT_DISPLAY_NAME_MAX_LENGTH,
|
|
15
|
+
AGENT_ARTIFACT_KINDS
|
|
16
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AgentProtocolParseResult } from '../foundation/index.js';
|
|
2
|
+
import type { AgentCapabilities } from './types.js';
|
|
3
|
+
export declare function parseAgentCapabilities(input: unknown): AgentCapabilities;
|
|
4
|
+
export declare function safeParseAgentCapabilities(input: unknown): AgentProtocolParseResult<AgentCapabilities>;
|
|
5
|
+
export declare function matchesAgentCapabilities(actual: unknown, expected: unknown): boolean;
|
|
6
|
+
//# sourceMappingURL=parsers.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { parseWithSchema, safeParseWithSchema } from "../internal/parsers.js";
|
|
2
|
+
import { AgentCapabilitiesSchema } from "../zod/capabilities.js";
|
|
3
|
+
function parseAgentCapabilities(input) {
|
|
4
|
+
return parseWithSchema(AgentCapabilitiesSchema, input);
|
|
5
|
+
}
|
|
6
|
+
function safeParseAgentCapabilities(input) {
|
|
7
|
+
return safeParseWithSchema(AgentCapabilitiesSchema, input);
|
|
8
|
+
}
|
|
9
|
+
function matchesAgentCapabilities(actual, expected) {
|
|
10
|
+
const parsedActual = safeParseAgentCapabilities(actual);
|
|
11
|
+
const parsedExpected = safeParseAgentCapabilities(expected);
|
|
12
|
+
return parsedActual.success && parsedExpected.success && JSON.stringify(parsedActual.data) === JSON.stringify(parsedExpected.data);
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
matchesAgentCapabilities,
|
|
16
|
+
parseAgentCapabilities,
|
|
17
|
+
safeParseAgentCapabilities
|
|
18
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { AgentArtifactKind } from '../artifacts/index.js';
|
|
2
|
+
import type { AgentProviderKey } from '../foundation/index.js';
|
|
3
|
+
import type { AgentImageInputMediaType, AgentImageInputSourceKind, AgentTurnInteractionMode } from '../turns/types.js';
|
|
4
|
+
export declare const AGENT_ELICITATION_MODES: readonly ["unsupported", "text", "structured"];
|
|
5
|
+
export declare const AGENT_FILE_CHANGE_MODES: readonly ["none", "final_diff", "structured"];
|
|
6
|
+
export declare const AGENT_AUTHENTICATION_FLOWS: readonly ["device_code", "browser", "terminal"];
|
|
7
|
+
export type AgentElicitationMode = (typeof AGENT_ELICITATION_MODES)[number];
|
|
8
|
+
export type AgentFileChangeMode = (typeof AGENT_FILE_CHANGE_MODES)[number];
|
|
9
|
+
export type AgentAuthenticationFlow = (typeof AGENT_AUTHENTICATION_FLOWS)[number];
|
|
10
|
+
export type AgentBranchCapability = Readonly<{
|
|
11
|
+
kind: 'unsupported';
|
|
12
|
+
}> | Readonly<{
|
|
13
|
+
kind: 'through_turn';
|
|
14
|
+
}>;
|
|
15
|
+
export type AgentElicitationCapability = Readonly<{
|
|
16
|
+
kind: 'unsupported';
|
|
17
|
+
}> | Readonly<{
|
|
18
|
+
kind: 'text';
|
|
19
|
+
}> | Readonly<{
|
|
20
|
+
kind: 'structured';
|
|
21
|
+
}>;
|
|
22
|
+
export interface AgentConfigurationFieldCapability {
|
|
23
|
+
readonly key: string;
|
|
24
|
+
readonly optionIds: readonly string[];
|
|
25
|
+
}
|
|
26
|
+
export type AgentConfigurationCapability = Readonly<{
|
|
27
|
+
kind: 'managed';
|
|
28
|
+
}> | Readonly<{
|
|
29
|
+
kind: 'selectable';
|
|
30
|
+
fields: readonly AgentConfigurationFieldCapability[];
|
|
31
|
+
}>;
|
|
32
|
+
export type AgentAuthenticationCapability = Readonly<{
|
|
33
|
+
kind: 'unsupported';
|
|
34
|
+
}> | Readonly<{
|
|
35
|
+
kind: 'supported';
|
|
36
|
+
flows: readonly AgentAuthenticationFlow[];
|
|
37
|
+
}>;
|
|
38
|
+
export type AgentImageInputCapability = Readonly<{
|
|
39
|
+
kind: 'unsupported';
|
|
40
|
+
}> | Readonly<{
|
|
41
|
+
kind: 'supported';
|
|
42
|
+
sourceKinds: readonly AgentImageInputSourceKind[];
|
|
43
|
+
mediaTypes: readonly AgentImageInputMediaType[];
|
|
44
|
+
maxImages: number;
|
|
45
|
+
maxBytesPerImage: number;
|
|
46
|
+
maxTotalBytes: number;
|
|
47
|
+
maxWidthPixels: number;
|
|
48
|
+
maxHeightPixels: number;
|
|
49
|
+
maxPixelsPerImage: number;
|
|
50
|
+
supportsImageOnly: boolean;
|
|
51
|
+
}>;
|
|
52
|
+
export interface AgentOperationInputCapability {
|
|
53
|
+
readonly text: true;
|
|
54
|
+
readonly images: AgentImageInputCapability;
|
|
55
|
+
}
|
|
56
|
+
export type AgentTurnSteeringCapability = Readonly<{
|
|
57
|
+
kind: 'unsupported';
|
|
58
|
+
}> | Readonly<{
|
|
59
|
+
kind: 'supported';
|
|
60
|
+
input: AgentOperationInputCapability;
|
|
61
|
+
}>;
|
|
62
|
+
export interface AgentCapabilities {
|
|
63
|
+
readonly protocolVersion: 6;
|
|
64
|
+
readonly providerKey: AgentProviderKey;
|
|
65
|
+
readonly sessions: Readonly<{
|
|
66
|
+
create: true;
|
|
67
|
+
resume: boolean;
|
|
68
|
+
branch: AgentBranchCapability;
|
|
69
|
+
}>;
|
|
70
|
+
readonly turns: Readonly<{
|
|
71
|
+
interactionModes: readonly AgentTurnInteractionMode[];
|
|
72
|
+
interrupt: boolean;
|
|
73
|
+
steer: AgentTurnSteeringCapability;
|
|
74
|
+
}>;
|
|
75
|
+
readonly requests: Readonly<{
|
|
76
|
+
approval: boolean;
|
|
77
|
+
elicitation: AgentElicitationCapability;
|
|
78
|
+
}>;
|
|
79
|
+
readonly input: AgentOperationInputCapability;
|
|
80
|
+
readonly output: Readonly<{
|
|
81
|
+
streaming: boolean;
|
|
82
|
+
plans: boolean;
|
|
83
|
+
fileChanges: AgentFileChangeMode;
|
|
84
|
+
artifactKinds: readonly AgentArtifactKind[];
|
|
85
|
+
}>;
|
|
86
|
+
readonly configuration: AgentConfigurationCapability;
|
|
87
|
+
readonly interactionExtensions: Readonly<{
|
|
88
|
+
slashCommands: boolean;
|
|
89
|
+
mcp: boolean;
|
|
90
|
+
subagents: boolean;
|
|
91
|
+
imageGeneration: boolean;
|
|
92
|
+
}>;
|
|
93
|
+
readonly authentication: AgentAuthenticationCapability;
|
|
94
|
+
readonly versionReporting: boolean;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const AGENT_ELICITATION_MODES = [
|
|
2
|
+
"unsupported",
|
|
3
|
+
"text",
|
|
4
|
+
"structured"
|
|
5
|
+
];
|
|
6
|
+
const AGENT_FILE_CHANGE_MODES = [
|
|
7
|
+
"none",
|
|
8
|
+
"final_diff",
|
|
9
|
+
"structured"
|
|
10
|
+
];
|
|
11
|
+
const AGENT_AUTHENTICATION_FLOWS = [
|
|
12
|
+
"device_code",
|
|
13
|
+
"browser",
|
|
14
|
+
"terminal"
|
|
15
|
+
];
|
|
16
|
+
export {
|
|
17
|
+
AGENT_AUTHENTICATION_FLOWS,
|
|
18
|
+
AGENT_ELICITATION_MODES,
|
|
19
|
+
AGENT_FILE_CHANGE_MODES
|
|
20
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AgentProtocolParseResult } from '../foundation/index.js';
|
|
2
|
+
import type { AgentEvent } from './types.js';
|
|
3
|
+
export declare function parseAgentEvent(input: unknown): AgentEvent;
|
|
4
|
+
export declare function safeParseAgentEvent(input: unknown): AgentProtocolParseResult<AgentEvent>;
|
|
5
|
+
export declare function createAgentEvent(input: AgentEvent): AgentEvent;
|
|
6
|
+
//# sourceMappingURL=parsers.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { parseWithSchema, safeParseWithSchema } from "../internal/parsers.js";
|
|
2
|
+
import { AgentEventSchema } from "../zod/events.js";
|
|
3
|
+
function parseAgentEvent(input) {
|
|
4
|
+
return parseWithSchema(AgentEventSchema, input);
|
|
5
|
+
}
|
|
6
|
+
function safeParseAgentEvent(input) {
|
|
7
|
+
return safeParseWithSchema(AgentEventSchema, input);
|
|
8
|
+
}
|
|
9
|
+
function createAgentEvent(input) {
|
|
10
|
+
return parseAgentEvent(input);
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
createAgentEvent,
|
|
14
|
+
parseAgentEvent,
|
|
15
|
+
safeParseAgentEvent
|
|
16
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { AgentArtifactDescriptor } from '../artifacts/index.js';
|
|
2
|
+
import type { AgentArtifactId, AgentError, AgentErrorContext, AgentIsoDateTime, AgentItemId, AgentProviderRefs, AgentRequestId, AgentSessionId, AgentTurnId } from '../foundation/index.js';
|
|
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"];
|
|
6
|
+
export type AgentEventType = (typeof AGENT_EVENT_TYPES)[number];
|
|
7
|
+
interface AgentEventBase<Type extends AgentEventType, Payload> {
|
|
8
|
+
readonly protocolVersion: 6;
|
|
9
|
+
readonly type: Type;
|
|
10
|
+
readonly sessionId: AgentSessionId;
|
|
11
|
+
readonly providerRefs?: AgentProviderRefs;
|
|
12
|
+
readonly occurredAt: AgentIsoDateTime;
|
|
13
|
+
readonly payload: Payload;
|
|
14
|
+
}
|
|
15
|
+
interface AgentTurnEventBase<Type extends AgentEventType, Payload> extends AgentEventBase<Type, Payload> {
|
|
16
|
+
readonly turnId: AgentTurnId;
|
|
17
|
+
}
|
|
18
|
+
interface AgentOptionallyTurnScopedEventBase<Type extends AgentEventType, Payload> extends AgentEventBase<Type, Payload> {
|
|
19
|
+
readonly turnId?: AgentTurnId;
|
|
20
|
+
}
|
|
21
|
+
export type AgentTurnStartedEvent = AgentTurnEventBase<'turn.started', Readonly<{
|
|
22
|
+
message?: string;
|
|
23
|
+
}>>;
|
|
24
|
+
export type AgentTurnStateChangedEvent = AgentTurnEventBase<'turn.state_changed', Readonly<{
|
|
25
|
+
state: AgentTurnState;
|
|
26
|
+
requestId?: AgentRequestId;
|
|
27
|
+
message?: string;
|
|
28
|
+
}>>;
|
|
29
|
+
export type AgentTurnCompletedEvent = AgentTurnEventBase<'turn.completed', AgentTurnCompletedPayload>;
|
|
30
|
+
export type AgentItemStartedEvent = AgentTurnEventBase<'item.started', AgentItemSnapshot>;
|
|
31
|
+
export type AgentItemUpdatedEvent = AgentTurnEventBase<'item.updated', AgentItemSnapshot>;
|
|
32
|
+
export type AgentItemCompletedEvent = AgentTurnEventBase<'item.completed', AgentItemSnapshot>;
|
|
33
|
+
export type AgentContentDeltaEvent = AgentTurnEventBase<'content.delta', Readonly<{
|
|
34
|
+
itemId: AgentItemId;
|
|
35
|
+
streamKind: AgentContentStreamKind;
|
|
36
|
+
delta: string;
|
|
37
|
+
}>>;
|
|
38
|
+
export type AgentPlanUpdatedEvent = AgentTurnEventBase<'turn.plan.updated', Readonly<{
|
|
39
|
+
explanation?: string;
|
|
40
|
+
steps: readonly AgentPlanStep[];
|
|
41
|
+
}>>;
|
|
42
|
+
export type AgentPlanProposedEvent = AgentTurnEventBase<'turn.plan.proposed', Readonly<{
|
|
43
|
+
artifactId: AgentArtifactId;
|
|
44
|
+
requestId: AgentRequestId;
|
|
45
|
+
}>>;
|
|
46
|
+
export type AgentDiffUpdatedEvent = AgentTurnEventBase<'turn.diff.updated', AgentDiffSummary>;
|
|
47
|
+
export type AgentRequestOpenedEvent = AgentTurnEventBase<'request.opened', Readonly<{
|
|
48
|
+
request: AgentRequest;
|
|
49
|
+
}>>;
|
|
50
|
+
export type AgentProgressUpdatedEvent = AgentTurnEventBase<'progress.updated', Readonly<{
|
|
51
|
+
progressId: string;
|
|
52
|
+
kind: 'task' | 'hook' | 'tool' | 'unknown';
|
|
53
|
+
phase: 'started' | 'updated' | 'completed';
|
|
54
|
+
title?: string;
|
|
55
|
+
message?: string;
|
|
56
|
+
current?: number;
|
|
57
|
+
total?: number;
|
|
58
|
+
}>>;
|
|
59
|
+
export type AgentArtifactReferencedEvent = AgentOptionallyTurnScopedEventBase<'artifact.referenced', Readonly<{
|
|
60
|
+
artifact: AgentArtifactDescriptor;
|
|
61
|
+
}>>;
|
|
62
|
+
export type AgentRuntimeWarningEvent = AgentOptionallyTurnScopedEventBase<'runtime.warning', Readonly<{
|
|
63
|
+
code: string;
|
|
64
|
+
message: string;
|
|
65
|
+
retryable?: boolean;
|
|
66
|
+
context?: AgentErrorContext;
|
|
67
|
+
}>>;
|
|
68
|
+
export type AgentRuntimeErrorEvent = AgentOptionallyTurnScopedEventBase<'runtime.error', Readonly<{
|
|
69
|
+
error: AgentError;
|
|
70
|
+
}>>;
|
|
71
|
+
export type AgentProviderDiagnosticEvent = AgentOptionallyTurnScopedEventBase<'provider.diagnostic', Readonly<{
|
|
72
|
+
code: string;
|
|
73
|
+
message: string;
|
|
74
|
+
context?: AgentErrorContext;
|
|
75
|
+
}>>;
|
|
76
|
+
export type AgentEvent = AgentTurnStartedEvent | AgentTurnStateChangedEvent | AgentTurnCompletedEvent | AgentItemStartedEvent | AgentItemUpdatedEvent | AgentItemCompletedEvent | AgentContentDeltaEvent | AgentPlanUpdatedEvent | AgentPlanProposedEvent | AgentDiffUpdatedEvent | AgentRequestOpenedEvent | AgentProgressUpdatedEvent | AgentArtifactReferencedEvent | AgentRuntimeWarningEvent | AgentRuntimeErrorEvent | AgentProviderDiagnosticEvent;
|
|
77
|
+
export {};
|
|
78
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const AGENT_EVENT_TYPES = [
|
|
2
|
+
"turn.started",
|
|
3
|
+
"turn.state_changed",
|
|
4
|
+
"turn.completed",
|
|
5
|
+
"item.started",
|
|
6
|
+
"item.updated",
|
|
7
|
+
"item.completed",
|
|
8
|
+
"content.delta",
|
|
9
|
+
"turn.plan.updated",
|
|
10
|
+
"turn.plan.proposed",
|
|
11
|
+
"turn.diff.updated",
|
|
12
|
+
"request.opened",
|
|
13
|
+
"progress.updated",
|
|
14
|
+
"artifact.referenced",
|
|
15
|
+
"runtime.warning",
|
|
16
|
+
"runtime.error",
|
|
17
|
+
"provider.diagnostic"
|
|
18
|
+
];
|
|
19
|
+
export {
|
|
20
|
+
AGENT_EVENT_TYPES
|
|
21
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function compareStringsByUnicodeCodePoint(left, right) {
|
|
2
|
+
const leftIterator = left[Symbol.iterator]();
|
|
3
|
+
const rightIterator = right[Symbol.iterator]();
|
|
4
|
+
while (true) {
|
|
5
|
+
const leftCodePoint = leftIterator.next();
|
|
6
|
+
const rightCodePoint = rightIterator.next();
|
|
7
|
+
if (leftCodePoint.done) return rightCodePoint.done ? 0 : -1;
|
|
8
|
+
if (rightCodePoint.done) return 1;
|
|
9
|
+
const difference = (leftCodePoint.value.codePointAt(0) ?? 0) - (rightCodePoint.value.codePointAt(0) ?? 0);
|
|
10
|
+
if (difference !== 0) return difference;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
compareStringsByUnicodeCodePoint
|
|
15
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AgentArtifactId, AgentConfigurationRevisionId, AgentError, AgentInstanceId, AgentIsoDateTime, AgentItemId, AgentJsonValue, AgentProviderConversationId, AgentProviderHistoryAnchor, AgentProviderItemRef, AgentProviderKey, AgentProviderRefs, AgentProviderRequestRef, AgentProviderTurnRef, AgentRequestFieldId, AgentRequestId, AgentSessionId, AgentTurnId } from './types.js';
|
|
2
|
+
import type { AgentProtocolParseResult } from './validation.js';
|
|
3
|
+
export declare const parseAgentInstanceId: (input: unknown) => AgentInstanceId;
|
|
4
|
+
export declare const safeParseAgentInstanceId: (input: unknown) => AgentProtocolParseResult<AgentInstanceId>;
|
|
5
|
+
export declare const parseAgentSessionId: (input: unknown) => AgentSessionId;
|
|
6
|
+
export declare const safeParseAgentSessionId: (input: unknown) => AgentProtocolParseResult<AgentSessionId>;
|
|
7
|
+
export declare const parseAgentTurnId: (input: unknown) => AgentTurnId;
|
|
8
|
+
export declare const safeParseAgentTurnId: (input: unknown) => AgentProtocolParseResult<AgentTurnId>;
|
|
9
|
+
export declare const parseAgentItemId: (input: unknown) => AgentItemId;
|
|
10
|
+
export declare const safeParseAgentItemId: (input: unknown) => AgentProtocolParseResult<AgentItemId>;
|
|
11
|
+
export declare const parseAgentRequestId: (input: unknown) => AgentRequestId;
|
|
12
|
+
export declare const safeParseAgentRequestId: (input: unknown) => AgentProtocolParseResult<AgentRequestId>;
|
|
13
|
+
export declare const parseAgentRequestFieldId: (input: unknown) => AgentRequestFieldId;
|
|
14
|
+
export declare const safeParseAgentRequestFieldId: (input: unknown) => AgentProtocolParseResult<AgentRequestFieldId>;
|
|
15
|
+
export declare const parseAgentArtifactId: (input: unknown) => AgentArtifactId;
|
|
16
|
+
export declare const safeParseAgentArtifactId: (input: unknown) => AgentProtocolParseResult<AgentArtifactId>;
|
|
17
|
+
export declare const parseAgentConfigurationRevisionId: (input: unknown) => AgentConfigurationRevisionId;
|
|
18
|
+
export declare const safeParseAgentConfigurationRevisionId: (input: unknown) => AgentProtocolParseResult<AgentConfigurationRevisionId>;
|
|
19
|
+
export declare const parseAgentProviderConversationId: (input: unknown) => AgentProviderConversationId;
|
|
20
|
+
export declare const safeParseAgentProviderConversationId: (input: unknown) => AgentProtocolParseResult<AgentProviderConversationId>;
|
|
21
|
+
export declare const parseAgentProviderHistoryAnchor: (input: unknown) => AgentProviderHistoryAnchor;
|
|
22
|
+
export declare const safeParseAgentProviderHistoryAnchor: (input: unknown) => AgentProtocolParseResult<AgentProviderHistoryAnchor>;
|
|
23
|
+
export declare const parseAgentProviderTurnRef: (input: unknown) => AgentProviderTurnRef;
|
|
24
|
+
export declare const safeParseAgentProviderTurnRef: (input: unknown) => AgentProtocolParseResult<AgentProviderTurnRef>;
|
|
25
|
+
export declare const parseAgentProviderItemRef: (input: unknown) => AgentProviderItemRef;
|
|
26
|
+
export declare const safeParseAgentProviderItemRef: (input: unknown) => AgentProtocolParseResult<AgentProviderItemRef>;
|
|
27
|
+
export declare const parseAgentProviderRequestRef: (input: unknown) => AgentProviderRequestRef;
|
|
28
|
+
export declare const safeParseAgentProviderRequestRef: (input: unknown) => AgentProtocolParseResult<AgentProviderRequestRef>;
|
|
29
|
+
export declare function parseAgentProviderKey(input: unknown): AgentProviderKey;
|
|
30
|
+
export declare function safeParseAgentProviderKey(input: unknown): AgentProtocolParseResult<AgentProviderKey>;
|
|
31
|
+
export declare function parseAgentIsoDateTime(input: unknown): AgentIsoDateTime;
|
|
32
|
+
export declare function safeParseAgentIsoDateTime(input: unknown): AgentProtocolParseResult<AgentIsoDateTime>;
|
|
33
|
+
export declare function parseAgentJsonValue(input: unknown): AgentJsonValue;
|
|
34
|
+
export declare function safeParseAgentJsonValue(input: unknown): AgentProtocolParseResult<AgentJsonValue>;
|
|
35
|
+
export declare function parseAgentProviderRefs(input: unknown): AgentProviderRefs;
|
|
36
|
+
export declare function safeParseAgentProviderRefs(input: unknown): AgentProtocolParseResult<AgentProviderRefs>;
|
|
37
|
+
export declare function parseAgentError(input: unknown): AgentError;
|
|
38
|
+
export declare function safeParseAgentError(input: unknown): AgentProtocolParseResult<AgentError>;
|
|
39
|
+
//# sourceMappingURL=parsers.d.ts.map
|