@agen-ai/agent-runtime 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 +139 -0
- package/dist/adapterValidation.d.ts +4 -0
- package/dist/adapterValidation.js +242 -0
- package/dist/artifacts.d.ts +28 -0
- package/dist/artifacts.js +87 -0
- package/dist/configurationValidation.d.ts +3 -0
- package/dist/configurationValidation.js +35 -0
- package/dist/contractErrors.d.ts +17 -0
- package/dist/contractErrors.js +59 -0
- package/dist/evidence.d.ts +50 -0
- package/dist/evidence.js +368 -0
- package/dist/foundation.d.ts +8 -0
- package/dist/foundation.js +37 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +12 -0
- package/dist/internal/controlCharacters.d.ts +2 -0
- package/dist/internal/controlCharacters.js +7 -0
- package/dist/internal/serializedJsonBytes.d.ts +3 -0
- package/dist/internal/serializedJsonBytes.js +57 -0
- package/dist/outputValidation.d.ts +13 -0
- package/dist/outputValidation.js +174 -0
- package/dist/outputs.d.ts +81 -0
- package/dist/outputs.js +217 -0
- package/dist/providerCatalog.d.ts +13 -0
- package/dist/providerCatalog.js +33 -0
- package/dist/providerDriver.d.ts +41 -0
- package/dist/providerDriver.js +52 -0
- package/dist/providerInstanceRegistry.d.ts +40 -0
- package/dist/providerInstanceRegistry.js +322 -0
- package/dist/readiness.d.ts +22 -0
- package/dist/readiness.js +58 -0
- package/dist/sessionValidation.d.ts +19 -0
- package/dist/sessionValidation.js +767 -0
- package/dist/sessions.d.ts +133 -0
- package/dist/sessions.js +0 -0
- package/dist/steeringValidation.d.ts +4 -0
- package/dist/steeringValidation.js +36 -0
- package/dist/testing/conformance.d.ts +30 -0
- package/dist/testing/conformance.js +379 -0
- package/dist/testing/fakeProvider.d.ts +35 -0
- package/dist/testing/fakeProvider.js +367 -0
- package/dist/testing/index.d.ts +3 -0
- package/dist/testing/index.js +2 -0
- package/dist/text.d.ts +2 -0
- package/dist/text.js +16 -0
- package/package.json +62 -0
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import {
|
|
2
|
+
parseAgentCapabilities,
|
|
3
|
+
parseAgentInstanceId,
|
|
4
|
+
parseAgentProviderKey
|
|
5
|
+
} from "@agen-ai/agent-protocol";
|
|
6
|
+
import { validateAgentProviderAdapter } from "./adapterValidation.js";
|
|
7
|
+
import {
|
|
8
|
+
createAgentProviderCatalogEntries,
|
|
9
|
+
createAgentProviderInstanceCatalogEntries
|
|
10
|
+
} from "./providerCatalog.js";
|
|
11
|
+
import {
|
|
12
|
+
AgentProviderConfigurationError
|
|
13
|
+
} from "./providerDriver.js";
|
|
14
|
+
import {
|
|
15
|
+
validateAgentProviderReadiness
|
|
16
|
+
} from "./readiness.js";
|
|
17
|
+
const AGENT_PROVIDER_REGISTRY_ERROR_CODES = [
|
|
18
|
+
"invalid_driver",
|
|
19
|
+
"duplicate_provider",
|
|
20
|
+
"duplicate_instance",
|
|
21
|
+
"provider_not_registered",
|
|
22
|
+
"multiple_instances_unsupported",
|
|
23
|
+
"invalid_instance_configuration",
|
|
24
|
+
"instance_materialization_failed",
|
|
25
|
+
"instance_contract_mismatch",
|
|
26
|
+
"instance_not_found",
|
|
27
|
+
"instance_disposed",
|
|
28
|
+
"instance_cleanup_failed",
|
|
29
|
+
"registry_disposed"
|
|
30
|
+
];
|
|
31
|
+
class AgentProviderRegistryError extends Error {
|
|
32
|
+
code;
|
|
33
|
+
providerKey;
|
|
34
|
+
instanceId;
|
|
35
|
+
cleanupFailureInstanceIds;
|
|
36
|
+
constructor(input) {
|
|
37
|
+
super(
|
|
38
|
+
input.message,
|
|
39
|
+
input.cause === void 0 ? void 0 : { cause: input.cause }
|
|
40
|
+
);
|
|
41
|
+
this.name = "AgentProviderRegistryError";
|
|
42
|
+
this.code = input.code;
|
|
43
|
+
this.providerKey = input.providerKey;
|
|
44
|
+
this.instanceId = input.instanceId;
|
|
45
|
+
this.cleanupFailureInstanceIds = Object.freeze([
|
|
46
|
+
...input.cleanupFailureInstanceIds ?? []
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function validateDrivers(drivers) {
|
|
51
|
+
const driverMap = /* @__PURE__ */ new Map();
|
|
52
|
+
for (const candidate of drivers) {
|
|
53
|
+
let providerKey;
|
|
54
|
+
try {
|
|
55
|
+
providerKey = parseAgentProviderKey(candidate?.providerKey);
|
|
56
|
+
} catch (cause) {
|
|
57
|
+
throw new AgentProviderRegistryError({
|
|
58
|
+
code: "invalid_driver",
|
|
59
|
+
message: "Agent provider driver has an invalid provider key.",
|
|
60
|
+
cause
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const supportsMultipleInstances = candidate.supportsMultipleInstances;
|
|
64
|
+
const materialize = candidate.materialize;
|
|
65
|
+
if (typeof supportsMultipleInstances !== "boolean" || typeof materialize !== "function") {
|
|
66
|
+
throw new AgentProviderRegistryError({
|
|
67
|
+
code: "invalid_driver",
|
|
68
|
+
providerKey,
|
|
69
|
+
message: `Agent provider driver ${providerKey} has an invalid runtime contract.`
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
if (driverMap.has(providerKey)) {
|
|
73
|
+
throw new AgentProviderRegistryError({
|
|
74
|
+
code: "duplicate_provider",
|
|
75
|
+
providerKey,
|
|
76
|
+
message: `Duplicate agent provider driver registered for ${providerKey}.`
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
driverMap.set(
|
|
80
|
+
providerKey,
|
|
81
|
+
Object.freeze({
|
|
82
|
+
providerKey,
|
|
83
|
+
supportsMultipleInstances,
|
|
84
|
+
materialize: (definition) => materialize.call(candidate, definition)
|
|
85
|
+
})
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
return driverMap;
|
|
89
|
+
}
|
|
90
|
+
function validateDefinitions(input) {
|
|
91
|
+
const instanceIds = /* @__PURE__ */ new Set();
|
|
92
|
+
const providerCounts = /* @__PURE__ */ new Map();
|
|
93
|
+
for (const definition of input.definitions) {
|
|
94
|
+
const instanceId = parseAgentInstanceId(definition.instanceId);
|
|
95
|
+
const providerKey = parseAgentProviderKey(definition.providerKey);
|
|
96
|
+
if (instanceIds.has(instanceId)) {
|
|
97
|
+
throw new AgentProviderRegistryError({
|
|
98
|
+
code: "duplicate_instance",
|
|
99
|
+
providerKey,
|
|
100
|
+
instanceId,
|
|
101
|
+
message: `Duplicate agent provider instance ${instanceId}.`
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
instanceIds.add(instanceId);
|
|
105
|
+
const driver = input.drivers.get(providerKey);
|
|
106
|
+
if (!driver) {
|
|
107
|
+
throw new AgentProviderRegistryError({
|
|
108
|
+
code: "provider_not_registered",
|
|
109
|
+
providerKey,
|
|
110
|
+
instanceId,
|
|
111
|
+
message: `No agent provider driver is registered for ${providerKey}.`
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
const providerCount = (providerCounts.get(driver.providerKey) ?? 0) + 1;
|
|
115
|
+
providerCounts.set(driver.providerKey, providerCount);
|
|
116
|
+
if (!driver.supportsMultipleInstances && providerCount > 1) {
|
|
117
|
+
throw new AgentProviderRegistryError({
|
|
118
|
+
code: "multiple_instances_unsupported",
|
|
119
|
+
providerKey: driver.providerKey,
|
|
120
|
+
instanceId,
|
|
121
|
+
message: `Agent provider ${driver.providerKey} does not support multiple instances.`
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function managedInstance(rawInstance, providerKey) {
|
|
127
|
+
if (!rawInstance || typeof rawInstance !== "object" || typeof rawInstance.checkReadiness !== "function" || typeof rawInstance.dispose !== "function") {
|
|
128
|
+
throw new AgentProviderRegistryError({
|
|
129
|
+
code: "instance_contract_mismatch",
|
|
130
|
+
providerKey,
|
|
131
|
+
message: "Materialized instance must expose callable readiness and disposal ports."
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
const capabilities = parseAgentCapabilities(rawInstance.capabilities);
|
|
135
|
+
const checkReadiness = rawInstance.checkReadiness.bind(rawInstance);
|
|
136
|
+
const dispose = rawInstance.dispose.bind(rawInstance);
|
|
137
|
+
const lifecycle = {
|
|
138
|
+
status: "active",
|
|
139
|
+
disposePromise: null
|
|
140
|
+
};
|
|
141
|
+
const instance = Object.freeze({
|
|
142
|
+
instanceId: parseAgentInstanceId(rawInstance.instanceId),
|
|
143
|
+
capabilities,
|
|
144
|
+
adapter: validateAgentProviderAdapter(capabilities, rawInstance.adapter),
|
|
145
|
+
checkReadiness: async (input) => {
|
|
146
|
+
const readiness = await checkReadiness(input);
|
|
147
|
+
return validateAgentProviderReadiness(readiness);
|
|
148
|
+
},
|
|
149
|
+
dispose: () => {
|
|
150
|
+
if (lifecycle.status === "disposed") return Promise.resolve();
|
|
151
|
+
if (lifecycle.disposePromise) return lifecycle.disposePromise;
|
|
152
|
+
lifecycle.status = "disposing";
|
|
153
|
+
lifecycle.disposePromise = Promise.resolve().then(() => dispose()).then(() => {
|
|
154
|
+
lifecycle.status = "disposed";
|
|
155
|
+
}).catch((error) => {
|
|
156
|
+
lifecycle.status = "dispose_failed";
|
|
157
|
+
throw error;
|
|
158
|
+
}).finally(() => {
|
|
159
|
+
lifecycle.disposePromise = null;
|
|
160
|
+
});
|
|
161
|
+
return lifecycle.disposePromise;
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
if (capabilities.providerKey !== providerKey) {
|
|
165
|
+
throw new AgentProviderRegistryError({
|
|
166
|
+
code: "instance_contract_mismatch",
|
|
167
|
+
providerKey,
|
|
168
|
+
instanceId: instance.instanceId,
|
|
169
|
+
message: "Materialized instance capabilities identify another provider."
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
return { instance, lifecycle };
|
|
173
|
+
}
|
|
174
|
+
async function disposeInstances(instances) {
|
|
175
|
+
const failures = [];
|
|
176
|
+
for (const { instance } of [...instances].reverse()) {
|
|
177
|
+
try {
|
|
178
|
+
await instance.dispose();
|
|
179
|
+
} catch {
|
|
180
|
+
failures.push(instance.instanceId);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return failures;
|
|
184
|
+
}
|
|
185
|
+
async function materializeInstances(input) {
|
|
186
|
+
const instances = [];
|
|
187
|
+
for (const definition of input.definitions) {
|
|
188
|
+
const driver = input.drivers.get(definition.providerKey);
|
|
189
|
+
let rawInstance;
|
|
190
|
+
try {
|
|
191
|
+
rawInstance = await driver.materialize(definition);
|
|
192
|
+
} catch (error) {
|
|
193
|
+
const cleanupFailureInstanceIds = await disposeInstances(instances);
|
|
194
|
+
throw new AgentProviderRegistryError({
|
|
195
|
+
code: error instanceof AgentProviderConfigurationError ? "invalid_instance_configuration" : "instance_materialization_failed",
|
|
196
|
+
providerKey: definition.providerKey,
|
|
197
|
+
instanceId: definition.instanceId,
|
|
198
|
+
cleanupFailureInstanceIds,
|
|
199
|
+
message: error instanceof AgentProviderConfigurationError ? `Agent provider configuration is invalid for ${definition.instanceId}.` : `Agent provider instance ${definition.instanceId} could not be materialized.`
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
let managed;
|
|
203
|
+
try {
|
|
204
|
+
managed = managedInstance(rawInstance, definition.providerKey);
|
|
205
|
+
if (managed.instance.instanceId !== definition.instanceId) {
|
|
206
|
+
throw new AgentProviderRegistryError({
|
|
207
|
+
code: "instance_contract_mismatch",
|
|
208
|
+
providerKey: definition.providerKey,
|
|
209
|
+
instanceId: definition.instanceId,
|
|
210
|
+
message: "Materialized instance returned another instanceId."
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
} catch (error) {
|
|
214
|
+
let currentCleanupError;
|
|
215
|
+
try {
|
|
216
|
+
await rawInstance.dispose();
|
|
217
|
+
} catch (cleanupError) {
|
|
218
|
+
currentCleanupError = cleanupError;
|
|
219
|
+
}
|
|
220
|
+
const priorCleanupFailureIds = await disposeInstances(instances);
|
|
221
|
+
const cleanupFailureInstanceIds = [
|
|
222
|
+
...currentCleanupError === void 0 ? [] : [definition.instanceId],
|
|
223
|
+
...priorCleanupFailureIds
|
|
224
|
+
];
|
|
225
|
+
throw new AgentProviderRegistryError({
|
|
226
|
+
code: "instance_contract_mismatch",
|
|
227
|
+
providerKey: definition.providerKey,
|
|
228
|
+
instanceId: definition.instanceId,
|
|
229
|
+
cleanupFailureInstanceIds,
|
|
230
|
+
message: error instanceof AgentProviderRegistryError ? error.message : `Materialized instance ${definition.instanceId} violates the provider contract.`,
|
|
231
|
+
cause: currentCleanupError === void 0 ? error : new AggregateError(
|
|
232
|
+
[error, currentCleanupError],
|
|
233
|
+
"Materialized instance contract validation and cleanup failed."
|
|
234
|
+
)
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
instances.push(managed);
|
|
238
|
+
}
|
|
239
|
+
return instances;
|
|
240
|
+
}
|
|
241
|
+
async function createAgentProviderRegistry(input) {
|
|
242
|
+
const drivers = validateDrivers(input.drivers);
|
|
243
|
+
validateDefinitions({ definitions: input.definitions, drivers });
|
|
244
|
+
const managedInstances = await materializeInstances({
|
|
245
|
+
definitions: input.definitions,
|
|
246
|
+
drivers
|
|
247
|
+
});
|
|
248
|
+
const instanceMap = new Map(
|
|
249
|
+
managedInstances.map((managed) => [managed.instance.instanceId, managed])
|
|
250
|
+
);
|
|
251
|
+
const providerCatalog = createAgentProviderCatalogEntries(drivers.values());
|
|
252
|
+
let registryStatus = "active";
|
|
253
|
+
let registryDisposePromise = null;
|
|
254
|
+
const getInstance = (instanceIdInput) => {
|
|
255
|
+
if (registryStatus !== "active") return null;
|
|
256
|
+
const instanceId = parseAgentInstanceId(instanceIdInput);
|
|
257
|
+
const managed = instanceMap.get(instanceId);
|
|
258
|
+
return managed?.lifecycle.status === "active" ? managed.instance : null;
|
|
259
|
+
};
|
|
260
|
+
const lookupError = (instanceId) => {
|
|
261
|
+
if (registryStatus !== "active") {
|
|
262
|
+
return new AgentProviderRegistryError({
|
|
263
|
+
code: "registry_disposed",
|
|
264
|
+
instanceId,
|
|
265
|
+
message: "Agent provider registry is disposed."
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
const managed = instanceMap.get(instanceId);
|
|
269
|
+
return new AgentProviderRegistryError({
|
|
270
|
+
code: managed ? "instance_disposed" : "instance_not_found",
|
|
271
|
+
instanceId,
|
|
272
|
+
providerKey: managed?.instance.capabilities.providerKey,
|
|
273
|
+
message: managed ? `Agent provider instance ${instanceId} is disposed.` : `Agent provider instance ${instanceId} is not registered.`
|
|
274
|
+
});
|
|
275
|
+
};
|
|
276
|
+
const requireInstance = (instanceId) => {
|
|
277
|
+
const instance = getInstance(instanceId);
|
|
278
|
+
if (!instance) throw lookupError(instanceId);
|
|
279
|
+
return instance;
|
|
280
|
+
};
|
|
281
|
+
const dispose = () => {
|
|
282
|
+
if (registryStatus === "disposed") return Promise.resolve();
|
|
283
|
+
if (registryDisposePromise) return registryDisposePromise;
|
|
284
|
+
registryStatus = "disposing";
|
|
285
|
+
registryDisposePromise = disposeInstances(managedInstances).then((cleanupFailureInstanceIds) => {
|
|
286
|
+
if (cleanupFailureInstanceIds.length > 0) {
|
|
287
|
+
throw new AgentProviderRegistryError({
|
|
288
|
+
code: "instance_cleanup_failed",
|
|
289
|
+
instanceId: cleanupFailureInstanceIds[0],
|
|
290
|
+
cleanupFailureInstanceIds,
|
|
291
|
+
message: `${cleanupFailureInstanceIds.length} agent provider cleanup operation(s) failed.`
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
registryStatus = "disposed";
|
|
295
|
+
}).catch((error) => {
|
|
296
|
+
registryStatus = "dispose_failed";
|
|
297
|
+
throw error;
|
|
298
|
+
}).finally(() => {
|
|
299
|
+
registryDisposePromise = null;
|
|
300
|
+
});
|
|
301
|
+
return registryDisposePromise;
|
|
302
|
+
};
|
|
303
|
+
return Object.freeze({
|
|
304
|
+
listProviderCatalogEntries: () => registryStatus === "active" ? providerCatalog : [],
|
|
305
|
+
listInstanceCatalogEntries: () => registryStatus === "active" ? createAgentProviderInstanceCatalogEntries(
|
|
306
|
+
managedInstances.filter(({ lifecycle }) => lifecycle.status === "active").map(({ instance }) => instance)
|
|
307
|
+
) : [],
|
|
308
|
+
listInstances: () => registryStatus === "active" ? managedInstances.filter(({ lifecycle }) => lifecycle.status === "active").map(({ instance }) => instance) : [],
|
|
309
|
+
getInstance,
|
|
310
|
+
hasInstance: (instanceId) => getInstance(instanceId) !== null,
|
|
311
|
+
requireInstance,
|
|
312
|
+
checkReadiness: async (instanceId, readinessInput) => {
|
|
313
|
+
return requireInstance(instanceId).checkReadiness(readinessInput);
|
|
314
|
+
},
|
|
315
|
+
dispose
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
export {
|
|
319
|
+
AGENT_PROVIDER_REGISTRY_ERROR_CODES,
|
|
320
|
+
AgentProviderRegistryError,
|
|
321
|
+
createAgentProviderRegistry
|
|
322
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type AgentError, type AgentIsoDateTime } from "@agen-ai/agent-protocol";
|
|
2
|
+
import { type BoundedAgentProviderData } from "./evidence.js";
|
|
3
|
+
export declare const AGENT_PROVIDER_READINESS_STATUSES: readonly ["ready", "missing_executable", "missing_credentials", "unsupported_version", "unavailable"];
|
|
4
|
+
export type AgentProviderReadinessStatus = (typeof AGENT_PROVIDER_READINESS_STATUSES)[number];
|
|
5
|
+
export interface AgentProviderReadiness {
|
|
6
|
+
readonly status: AgentProviderReadinessStatus;
|
|
7
|
+
readonly checkedAt: AgentIsoDateTime;
|
|
8
|
+
readonly version?: string;
|
|
9
|
+
readonly reason?: AgentError;
|
|
10
|
+
readonly diagnostics: BoundedAgentProviderData;
|
|
11
|
+
}
|
|
12
|
+
export interface CreateAgentProviderReadinessInput {
|
|
13
|
+
readonly status: AgentProviderReadinessStatus;
|
|
14
|
+
readonly checkedAt: string;
|
|
15
|
+
readonly version?: string;
|
|
16
|
+
readonly reason?: AgentError;
|
|
17
|
+
readonly diagnostics?: unknown;
|
|
18
|
+
readonly diagnosticsBytesLimit?: number;
|
|
19
|
+
}
|
|
20
|
+
export declare function createAgentProviderReadiness(input: CreateAgentProviderReadinessInput): AgentProviderReadiness;
|
|
21
|
+
export declare function validateAgentProviderReadiness(input: AgentProviderReadiness): AgentProviderReadiness;
|
|
22
|
+
//# sourceMappingURL=readiness.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
parseAgentError,
|
|
3
|
+
parseAgentIsoDateTime
|
|
4
|
+
} from "@agen-ai/agent-protocol";
|
|
5
|
+
import {
|
|
6
|
+
createBoundedAgentProviderData,
|
|
7
|
+
validateBoundedAgentProviderData
|
|
8
|
+
} from "./evidence.js";
|
|
9
|
+
import { parseAgentCanonicalText } from "./foundation.js";
|
|
10
|
+
const AGENT_PROVIDER_READINESS_STATUSES = [
|
|
11
|
+
"ready",
|
|
12
|
+
"missing_executable",
|
|
13
|
+
"missing_credentials",
|
|
14
|
+
"unsupported_version",
|
|
15
|
+
"unavailable"
|
|
16
|
+
];
|
|
17
|
+
function validatedReadinessReason(status, reason) {
|
|
18
|
+
if (status === "ready" && reason !== void 0) {
|
|
19
|
+
throw new TypeError("Ready providers cannot report a failure reason.");
|
|
20
|
+
}
|
|
21
|
+
return reason === void 0 ? void 0 : parseAgentError(reason);
|
|
22
|
+
}
|
|
23
|
+
function createAgentProviderReadiness(input) {
|
|
24
|
+
if (!AGENT_PROVIDER_READINESS_STATUSES.includes(input.status)) {
|
|
25
|
+
throw new TypeError("Provider readiness status is unsupported.");
|
|
26
|
+
}
|
|
27
|
+
const version = input.version === void 0 ? void 0 : parseAgentCanonicalText(input.version, "Provider version", 160);
|
|
28
|
+
const reason = validatedReadinessReason(input.status, input.reason);
|
|
29
|
+
return Object.freeze({
|
|
30
|
+
status: input.status,
|
|
31
|
+
checkedAt: parseAgentIsoDateTime(input.checkedAt),
|
|
32
|
+
...version === void 0 ? {} : { version },
|
|
33
|
+
...reason === void 0 ? {} : { reason },
|
|
34
|
+
diagnostics: createBoundedAgentProviderData(
|
|
35
|
+
input.diagnostics ?? {},
|
|
36
|
+
input.diagnosticsBytesLimit
|
|
37
|
+
)
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function validateAgentProviderReadiness(input) {
|
|
41
|
+
if (input === null || typeof input !== "object" || !AGENT_PROVIDER_READINESS_STATUSES.includes(input.status)) {
|
|
42
|
+
throw new TypeError("Provider readiness is invalid.");
|
|
43
|
+
}
|
|
44
|
+
const version = input.version === void 0 ? void 0 : parseAgentCanonicalText(input.version, "Provider version", 160);
|
|
45
|
+
const reason = validatedReadinessReason(input.status, input.reason);
|
|
46
|
+
return Object.freeze({
|
|
47
|
+
status: input.status,
|
|
48
|
+
checkedAt: parseAgentIsoDateTime(input.checkedAt),
|
|
49
|
+
...version === void 0 ? {} : { version },
|
|
50
|
+
...reason === void 0 ? {} : { reason },
|
|
51
|
+
diagnostics: validateBoundedAgentProviderData(input.diagnostics)
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
AGENT_PROVIDER_READINESS_STATUSES,
|
|
56
|
+
createAgentProviderReadiness,
|
|
57
|
+
validateAgentProviderReadiness
|
|
58
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type AgentCapabilities, type AgentSessionBinding, type AgentSessionId } from "@agen-ai/agent-protocol";
|
|
2
|
+
import { type MaybePromise } from "./foundation.js";
|
|
3
|
+
import type { AgentProviderSession, AgentSessionBindingCreatedObserver } from "./sessions.js";
|
|
4
|
+
export declare function validateAgentProviderSession(input: {
|
|
5
|
+
readonly capabilities: AgentCapabilities;
|
|
6
|
+
readonly sessionId: AgentSessionId;
|
|
7
|
+
readonly candidate: AgentProviderSession;
|
|
8
|
+
readonly expectedBinding?: AgentSessionBinding;
|
|
9
|
+
readonly sourceBinding?: AgentSessionBinding;
|
|
10
|
+
}): AgentProviderSession;
|
|
11
|
+
export declare function closeRejectedAgentProviderSession(session: AgentProviderSession | null, error: unknown): Promise<never>;
|
|
12
|
+
export declare function openIdentityCreatingAgentProviderSession(input: {
|
|
13
|
+
readonly capabilities: AgentCapabilities;
|
|
14
|
+
readonly sessionId: AgentSessionId;
|
|
15
|
+
readonly observer: AgentSessionBindingCreatedObserver;
|
|
16
|
+
readonly sourceBinding?: AgentSessionBinding;
|
|
17
|
+
readonly open: (observer: AgentSessionBindingCreatedObserver) => MaybePromise<AgentProviderSession>;
|
|
18
|
+
}): Promise<AgentProviderSession>;
|
|
19
|
+
//# sourceMappingURL=sessionValidation.d.ts.map
|