@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
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { parseWithSchema, safeParseWithSchema } from "../internal/parsers.js";
|
|
2
|
+
import {
|
|
3
|
+
AgentArtifactIdSchema,
|
|
4
|
+
AgentConfigurationRevisionIdSchema,
|
|
5
|
+
AgentErrorSchema,
|
|
6
|
+
AgentInstanceIdSchema,
|
|
7
|
+
AgentIsoDateTimeSchema,
|
|
8
|
+
AgentItemIdSchema,
|
|
9
|
+
AgentJsonValueSchema,
|
|
10
|
+
AgentProviderConversationIdSchema,
|
|
11
|
+
AgentProviderHistoryAnchorSchema,
|
|
12
|
+
AgentProviderItemRefSchema,
|
|
13
|
+
AgentProviderKeySchema,
|
|
14
|
+
AgentProviderRefsSchema,
|
|
15
|
+
AgentProviderRequestRefSchema,
|
|
16
|
+
AgentProviderTurnRefSchema,
|
|
17
|
+
AgentRequestFieldIdSchema,
|
|
18
|
+
AgentRequestIdSchema,
|
|
19
|
+
AgentSessionIdSchema,
|
|
20
|
+
AgentTurnIdSchema
|
|
21
|
+
} from "../zod/foundation.js";
|
|
22
|
+
function idParser(schema) {
|
|
23
|
+
return {
|
|
24
|
+
parse: (input) => parseWithSchema(schema, input),
|
|
25
|
+
safeParse: (input) => safeParseWithSchema(schema, input)
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const instanceIdParser = idParser(AgentInstanceIdSchema);
|
|
29
|
+
const sessionIdParser = idParser(AgentSessionIdSchema);
|
|
30
|
+
const turnIdParser = idParser(AgentTurnIdSchema);
|
|
31
|
+
const itemIdParser = idParser(AgentItemIdSchema);
|
|
32
|
+
const requestIdParser = idParser(AgentRequestIdSchema);
|
|
33
|
+
const requestFieldIdParser = idParser(
|
|
34
|
+
AgentRequestFieldIdSchema
|
|
35
|
+
);
|
|
36
|
+
const artifactIdParser = idParser(AgentArtifactIdSchema);
|
|
37
|
+
const revisionIdParser = idParser(
|
|
38
|
+
AgentConfigurationRevisionIdSchema
|
|
39
|
+
);
|
|
40
|
+
const conversationIdParser = idParser(
|
|
41
|
+
AgentProviderConversationIdSchema
|
|
42
|
+
);
|
|
43
|
+
const historyAnchorParser = idParser(
|
|
44
|
+
AgentProviderHistoryAnchorSchema
|
|
45
|
+
);
|
|
46
|
+
const providerTurnRefParser = idParser(
|
|
47
|
+
AgentProviderTurnRefSchema
|
|
48
|
+
);
|
|
49
|
+
const providerItemRefParser = idParser(
|
|
50
|
+
AgentProviderItemRefSchema
|
|
51
|
+
);
|
|
52
|
+
const providerRequestRefParser = idParser(
|
|
53
|
+
AgentProviderRequestRefSchema
|
|
54
|
+
);
|
|
55
|
+
const parseAgentInstanceId = instanceIdParser.parse;
|
|
56
|
+
const safeParseAgentInstanceId = instanceIdParser.safeParse;
|
|
57
|
+
const parseAgentSessionId = sessionIdParser.parse;
|
|
58
|
+
const safeParseAgentSessionId = sessionIdParser.safeParse;
|
|
59
|
+
const parseAgentTurnId = turnIdParser.parse;
|
|
60
|
+
const safeParseAgentTurnId = turnIdParser.safeParse;
|
|
61
|
+
const parseAgentItemId = itemIdParser.parse;
|
|
62
|
+
const safeParseAgentItemId = itemIdParser.safeParse;
|
|
63
|
+
const parseAgentRequestId = requestIdParser.parse;
|
|
64
|
+
const safeParseAgentRequestId = requestIdParser.safeParse;
|
|
65
|
+
const parseAgentRequestFieldId = requestFieldIdParser.parse;
|
|
66
|
+
const safeParseAgentRequestFieldId = requestFieldIdParser.safeParse;
|
|
67
|
+
const parseAgentArtifactId = artifactIdParser.parse;
|
|
68
|
+
const safeParseAgentArtifactId = artifactIdParser.safeParse;
|
|
69
|
+
const parseAgentConfigurationRevisionId = revisionIdParser.parse;
|
|
70
|
+
const safeParseAgentConfigurationRevisionId = revisionIdParser.safeParse;
|
|
71
|
+
const parseAgentProviderConversationId = conversationIdParser.parse;
|
|
72
|
+
const safeParseAgentProviderConversationId = conversationIdParser.safeParse;
|
|
73
|
+
const parseAgentProviderHistoryAnchor = historyAnchorParser.parse;
|
|
74
|
+
const safeParseAgentProviderHistoryAnchor = historyAnchorParser.safeParse;
|
|
75
|
+
const parseAgentProviderTurnRef = providerTurnRefParser.parse;
|
|
76
|
+
const safeParseAgentProviderTurnRef = providerTurnRefParser.safeParse;
|
|
77
|
+
const parseAgentProviderItemRef = providerItemRefParser.parse;
|
|
78
|
+
const safeParseAgentProviderItemRef = providerItemRefParser.safeParse;
|
|
79
|
+
const parseAgentProviderRequestRef = providerRequestRefParser.parse;
|
|
80
|
+
const safeParseAgentProviderRequestRef = providerRequestRefParser.safeParse;
|
|
81
|
+
function parseAgentProviderKey(input) {
|
|
82
|
+
return parseWithSchema(AgentProviderKeySchema, input);
|
|
83
|
+
}
|
|
84
|
+
function safeParseAgentProviderKey(input) {
|
|
85
|
+
return safeParseWithSchema(AgentProviderKeySchema, input);
|
|
86
|
+
}
|
|
87
|
+
function parseAgentIsoDateTime(input) {
|
|
88
|
+
return parseWithSchema(AgentIsoDateTimeSchema, input);
|
|
89
|
+
}
|
|
90
|
+
function safeParseAgentIsoDateTime(input) {
|
|
91
|
+
return safeParseWithSchema(AgentIsoDateTimeSchema, input);
|
|
92
|
+
}
|
|
93
|
+
function parseAgentJsonValue(input) {
|
|
94
|
+
return parseWithSchema(AgentJsonValueSchema, input);
|
|
95
|
+
}
|
|
96
|
+
function safeParseAgentJsonValue(input) {
|
|
97
|
+
return safeParseWithSchema(AgentJsonValueSchema, input);
|
|
98
|
+
}
|
|
99
|
+
function parseAgentProviderRefs(input) {
|
|
100
|
+
return parseWithSchema(AgentProviderRefsSchema, input);
|
|
101
|
+
}
|
|
102
|
+
function safeParseAgentProviderRefs(input) {
|
|
103
|
+
return safeParseWithSchema(AgentProviderRefsSchema, input);
|
|
104
|
+
}
|
|
105
|
+
function parseAgentError(input) {
|
|
106
|
+
return parseWithSchema(AgentErrorSchema, input);
|
|
107
|
+
}
|
|
108
|
+
function safeParseAgentError(input) {
|
|
109
|
+
return safeParseWithSchema(AgentErrorSchema, input);
|
|
110
|
+
}
|
|
111
|
+
export {
|
|
112
|
+
parseAgentArtifactId,
|
|
113
|
+
parseAgentConfigurationRevisionId,
|
|
114
|
+
parseAgentError,
|
|
115
|
+
parseAgentInstanceId,
|
|
116
|
+
parseAgentIsoDateTime,
|
|
117
|
+
parseAgentItemId,
|
|
118
|
+
parseAgentJsonValue,
|
|
119
|
+
parseAgentProviderConversationId,
|
|
120
|
+
parseAgentProviderHistoryAnchor,
|
|
121
|
+
parseAgentProviderItemRef,
|
|
122
|
+
parseAgentProviderKey,
|
|
123
|
+
parseAgentProviderRefs,
|
|
124
|
+
parseAgentProviderRequestRef,
|
|
125
|
+
parseAgentProviderTurnRef,
|
|
126
|
+
parseAgentRequestFieldId,
|
|
127
|
+
parseAgentRequestId,
|
|
128
|
+
parseAgentSessionId,
|
|
129
|
+
parseAgentTurnId,
|
|
130
|
+
safeParseAgentArtifactId,
|
|
131
|
+
safeParseAgentConfigurationRevisionId,
|
|
132
|
+
safeParseAgentError,
|
|
133
|
+
safeParseAgentInstanceId,
|
|
134
|
+
safeParseAgentIsoDateTime,
|
|
135
|
+
safeParseAgentItemId,
|
|
136
|
+
safeParseAgentJsonValue,
|
|
137
|
+
safeParseAgentProviderConversationId,
|
|
138
|
+
safeParseAgentProviderHistoryAnchor,
|
|
139
|
+
safeParseAgentProviderItemRef,
|
|
140
|
+
safeParseAgentProviderKey,
|
|
141
|
+
safeParseAgentProviderRefs,
|
|
142
|
+
safeParseAgentProviderRequestRef,
|
|
143
|
+
safeParseAgentProviderTurnRef,
|
|
144
|
+
safeParseAgentRequestFieldId,
|
|
145
|
+
safeParseAgentRequestId,
|
|
146
|
+
safeParseAgentSessionId,
|
|
147
|
+
safeParseAgentTurnId
|
|
148
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export type { AgentProtocolParseFailure, AgentProtocolParseResult, AgentProtocolParseSuccess, ValidationIssue, ValidationPathSegment, } from './validation.js';
|
|
2
|
+
export { AgentProtocolValidationError } from './validation.js';
|
|
3
|
+
export declare const AGENT_PROTOCOL_VERSION: 6;
|
|
4
|
+
export declare const AGENT_PROTOCOL_ID_MAX_LENGTH = 256;
|
|
5
|
+
export declare const AGENT_PROTOCOL_PROVIDER_REFERENCE_MAX_LENGTH = 512;
|
|
6
|
+
export declare const AGENT_PROTOCOL_PROVIDER_KEY_MAX_LENGTH = 100;
|
|
7
|
+
export declare const AGENT_PROTOCOL_CODE_MAX_LENGTH = 120;
|
|
8
|
+
export declare const AGENT_PROTOCOL_TEXT_MAX_LENGTH = 4000;
|
|
9
|
+
export declare const AGENT_PROTOCOL_SUMMARY_MAX_LENGTH = 2000;
|
|
10
|
+
export declare const AGENT_PROTOCOL_COLLECTION_MAX_LENGTH = 100;
|
|
11
|
+
export declare const AGENT_PROTOCOL_JSON_KEY_MAX_LENGTH = 128;
|
|
12
|
+
export declare const AGENT_PROTOCOL_JSON_DEPTH_LIMIT = 16;
|
|
13
|
+
export declare const AGENT_PROTOCOL_JSON_BYTES_LIMIT = 32768;
|
|
14
|
+
export declare const AGENT_PROTOCOL_EVENT_BYTES_LIMIT = 32768;
|
|
15
|
+
export declare const AGENT_PROTOCOL_TURN_INPUT_CONTENT_BYTES_LIMIT = 1064960;
|
|
16
|
+
declare const agentProtocolIdBrand: unique symbol;
|
|
17
|
+
type AgentProtocolId<Kind extends string> = string & {
|
|
18
|
+
readonly [agentProtocolIdBrand]: Kind;
|
|
19
|
+
};
|
|
20
|
+
export type AgentInstanceId = AgentProtocolId<'AgentInstanceId'>;
|
|
21
|
+
export type AgentSessionId = AgentProtocolId<'AgentSessionId'>;
|
|
22
|
+
export type AgentTurnId = AgentProtocolId<'AgentTurnId'>;
|
|
23
|
+
export type AgentItemId = AgentProtocolId<'AgentItemId'>;
|
|
24
|
+
export type AgentRequestId = AgentProtocolId<'AgentRequestId'>;
|
|
25
|
+
export type AgentRequestFieldId = AgentProtocolId<'AgentRequestFieldId'>;
|
|
26
|
+
export type AgentArtifactId = AgentProtocolId<'AgentArtifactId'>;
|
|
27
|
+
export type AgentConfigurationRevisionId = AgentProtocolId<'AgentConfigurationRevisionId'>;
|
|
28
|
+
export type AgentProviderConversationId = AgentProtocolId<'AgentProviderConversationId'>;
|
|
29
|
+
export type AgentProviderHistoryAnchor = AgentProtocolId<'AgentProviderHistoryAnchor'>;
|
|
30
|
+
export type AgentProviderTurnRef = AgentProtocolId<'AgentProviderTurnRef'>;
|
|
31
|
+
export type AgentProviderItemRef = AgentProtocolId<'AgentProviderItemRef'>;
|
|
32
|
+
export type AgentProviderRequestRef = AgentProtocolId<'AgentProviderRequestRef'>;
|
|
33
|
+
export type AgentProviderKey = string & {
|
|
34
|
+
readonly [agentProtocolIdBrand]: 'AgentProviderKey';
|
|
35
|
+
};
|
|
36
|
+
export type AgentIsoDateTime = string & {
|
|
37
|
+
readonly [agentProtocolIdBrand]: 'AgentIsoDateTime';
|
|
38
|
+
};
|
|
39
|
+
export type AgentJsonPrimitive = string | number | boolean | null;
|
|
40
|
+
export type AgentJsonValue = AgentJsonPrimitive | readonly AgentJsonValue[] | {
|
|
41
|
+
readonly [key: string]: AgentJsonValue;
|
|
42
|
+
};
|
|
43
|
+
export interface AgentProviderRefs {
|
|
44
|
+
readonly conversationId?: AgentProviderConversationId;
|
|
45
|
+
readonly historyAnchor?: AgentProviderHistoryAnchor;
|
|
46
|
+
readonly turnId?: AgentProviderTurnRef;
|
|
47
|
+
readonly itemId?: AgentProviderItemRef;
|
|
48
|
+
readonly requestId?: AgentProviderRequestRef;
|
|
49
|
+
}
|
|
50
|
+
export interface AgentErrorContext {
|
|
51
|
+
readonly operation?: string;
|
|
52
|
+
readonly component?: string;
|
|
53
|
+
readonly status?: string;
|
|
54
|
+
}
|
|
55
|
+
export interface AgentError {
|
|
56
|
+
readonly code: string;
|
|
57
|
+
readonly message: string;
|
|
58
|
+
readonly retryable: boolean;
|
|
59
|
+
readonly context?: AgentErrorContext;
|
|
60
|
+
}
|
|
61
|
+
export declare function agentProtocolSerializedJsonBytes(value: unknown): number;
|
|
62
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { AgentProtocolValidationError } from "./validation.js";
|
|
2
|
+
const AGENT_PROTOCOL_VERSION = 6;
|
|
3
|
+
const AGENT_PROTOCOL_ID_MAX_LENGTH = 256;
|
|
4
|
+
const AGENT_PROTOCOL_PROVIDER_REFERENCE_MAX_LENGTH = 512;
|
|
5
|
+
const AGENT_PROTOCOL_PROVIDER_KEY_MAX_LENGTH = 100;
|
|
6
|
+
const AGENT_PROTOCOL_CODE_MAX_LENGTH = 120;
|
|
7
|
+
const AGENT_PROTOCOL_TEXT_MAX_LENGTH = 4e3;
|
|
8
|
+
const AGENT_PROTOCOL_SUMMARY_MAX_LENGTH = 2e3;
|
|
9
|
+
const AGENT_PROTOCOL_COLLECTION_MAX_LENGTH = 100;
|
|
10
|
+
const AGENT_PROTOCOL_JSON_KEY_MAX_LENGTH = 128;
|
|
11
|
+
const AGENT_PROTOCOL_JSON_DEPTH_LIMIT = 16;
|
|
12
|
+
const AGENT_PROTOCOL_JSON_BYTES_LIMIT = 32768;
|
|
13
|
+
const AGENT_PROTOCOL_EVENT_BYTES_LIMIT = 32768;
|
|
14
|
+
const AGENT_PROTOCOL_TURN_INPUT_CONTENT_BYTES_LIMIT = 1064960;
|
|
15
|
+
const textEncoder = new TextEncoder();
|
|
16
|
+
function agentProtocolSerializedJsonBytes(value) {
|
|
17
|
+
const serialized = JSON.stringify(value);
|
|
18
|
+
if (serialized === void 0) {
|
|
19
|
+
throw new TypeError("Agent protocol value is not JSON serializable.");
|
|
20
|
+
}
|
|
21
|
+
return textEncoder.encode(serialized).byteLength;
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
AGENT_PROTOCOL_CODE_MAX_LENGTH,
|
|
25
|
+
AGENT_PROTOCOL_COLLECTION_MAX_LENGTH,
|
|
26
|
+
AGENT_PROTOCOL_EVENT_BYTES_LIMIT,
|
|
27
|
+
AGENT_PROTOCOL_ID_MAX_LENGTH,
|
|
28
|
+
AGENT_PROTOCOL_JSON_BYTES_LIMIT,
|
|
29
|
+
AGENT_PROTOCOL_JSON_DEPTH_LIMIT,
|
|
30
|
+
AGENT_PROTOCOL_JSON_KEY_MAX_LENGTH,
|
|
31
|
+
AGENT_PROTOCOL_PROVIDER_KEY_MAX_LENGTH,
|
|
32
|
+
AGENT_PROTOCOL_PROVIDER_REFERENCE_MAX_LENGTH,
|
|
33
|
+
AGENT_PROTOCOL_SUMMARY_MAX_LENGTH,
|
|
34
|
+
AGENT_PROTOCOL_TEXT_MAX_LENGTH,
|
|
35
|
+
AGENT_PROTOCOL_TURN_INPUT_CONTENT_BYTES_LIMIT,
|
|
36
|
+
AGENT_PROTOCOL_VERSION,
|
|
37
|
+
AgentProtocolValidationError,
|
|
38
|
+
agentProtocolSerializedJsonBytes
|
|
39
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ValidationIssue } from '@agen-ai/validation';
|
|
2
|
+
export type { ValidationIssue, ValidationPathSegment } from '@agen-ai/validation';
|
|
3
|
+
export interface AgentProtocolParseSuccess<T> {
|
|
4
|
+
readonly success: true;
|
|
5
|
+
readonly data: T;
|
|
6
|
+
}
|
|
7
|
+
export interface AgentProtocolParseFailure {
|
|
8
|
+
readonly success: false;
|
|
9
|
+
readonly issues: readonly ValidationIssue[];
|
|
10
|
+
}
|
|
11
|
+
export type AgentProtocolParseResult<T> = AgentProtocolParseSuccess<T> | AgentProtocolParseFailure;
|
|
12
|
+
export declare class AgentProtocolValidationError extends TypeError {
|
|
13
|
+
readonly issues: readonly ValidationIssue[];
|
|
14
|
+
constructor(issues: readonly ValidationIssue[]);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
class AgentProtocolValidationError extends TypeError {
|
|
2
|
+
issues;
|
|
3
|
+
constructor(issues) {
|
|
4
|
+
super("Agent protocol validation failed.");
|
|
5
|
+
this.name = "AgentProtocolValidationError";
|
|
6
|
+
this.issues = issues;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
AgentProtocolValidationError
|
|
11
|
+
};
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./public/index.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ZodType } from 'zod/v4';
|
|
2
|
+
import { type AgentProtocolParseResult } from '../foundation/validation.js';
|
|
3
|
+
export declare function safeParseWithSchema<T>(schema: ZodType<T>, input: unknown): AgentProtocolParseResult<T>;
|
|
4
|
+
export declare function parseWithSchema<T>(schema: ZodType<T>, input: unknown): T;
|
|
5
|
+
//# sourceMappingURL=parsers.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { normalizeZodValidationError } from "@agen-ai/validation/zod";
|
|
2
|
+
import {
|
|
3
|
+
AgentProtocolValidationError
|
|
4
|
+
} from "../foundation/validation.js";
|
|
5
|
+
function safeParseWithSchema(schema, input) {
|
|
6
|
+
const parsed = schema.safeParse(input);
|
|
7
|
+
if (parsed.success) return { success: true, data: parsed.data };
|
|
8
|
+
return {
|
|
9
|
+
success: false,
|
|
10
|
+
issues: normalizeZodValidationError(schema, parsed.error, input)
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function parseWithSchema(schema, input) {
|
|
14
|
+
const parsed = safeParseWithSchema(schema, input);
|
|
15
|
+
if (parsed.success) return parsed.data;
|
|
16
|
+
throw new AgentProtocolValidationError(parsed.issues);
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
parseWithSchema,
|
|
20
|
+
safeParseWithSchema
|
|
21
|
+
};
|