@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.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +139 -0
  3. package/dist/adapterValidation.d.ts +4 -0
  4. package/dist/adapterValidation.js +242 -0
  5. package/dist/artifacts.d.ts +28 -0
  6. package/dist/artifacts.js +87 -0
  7. package/dist/configurationValidation.d.ts +3 -0
  8. package/dist/configurationValidation.js +35 -0
  9. package/dist/contractErrors.d.ts +17 -0
  10. package/dist/contractErrors.js +59 -0
  11. package/dist/evidence.d.ts +50 -0
  12. package/dist/evidence.js +368 -0
  13. package/dist/foundation.d.ts +8 -0
  14. package/dist/foundation.js +37 -0
  15. package/dist/index.d.ts +13 -0
  16. package/dist/index.js +12 -0
  17. package/dist/internal/controlCharacters.d.ts +2 -0
  18. package/dist/internal/controlCharacters.js +7 -0
  19. package/dist/internal/serializedJsonBytes.d.ts +3 -0
  20. package/dist/internal/serializedJsonBytes.js +57 -0
  21. package/dist/outputValidation.d.ts +13 -0
  22. package/dist/outputValidation.js +174 -0
  23. package/dist/outputs.d.ts +81 -0
  24. package/dist/outputs.js +217 -0
  25. package/dist/providerCatalog.d.ts +13 -0
  26. package/dist/providerCatalog.js +33 -0
  27. package/dist/providerDriver.d.ts +41 -0
  28. package/dist/providerDriver.js +52 -0
  29. package/dist/providerInstanceRegistry.d.ts +40 -0
  30. package/dist/providerInstanceRegistry.js +322 -0
  31. package/dist/readiness.d.ts +22 -0
  32. package/dist/readiness.js +58 -0
  33. package/dist/sessionValidation.d.ts +19 -0
  34. package/dist/sessionValidation.js +767 -0
  35. package/dist/sessions.d.ts +133 -0
  36. package/dist/sessions.js +0 -0
  37. package/dist/steeringValidation.d.ts +4 -0
  38. package/dist/steeringValidation.js +36 -0
  39. package/dist/testing/conformance.d.ts +30 -0
  40. package/dist/testing/conformance.js +379 -0
  41. package/dist/testing/fakeProvider.d.ts +35 -0
  42. package/dist/testing/fakeProvider.js +367 -0
  43. package/dist/testing/index.d.ts +3 -0
  44. package/dist/testing/index.js +2 -0
  45. package/dist/text.d.ts +2 -0
  46. package/dist/text.js +16 -0
  47. package/package.json +62 -0
@@ -0,0 +1,50 @@
1
+ import { type AgentJsonValue } from "@agen-ai/agent-protocol";
2
+ export declare const AGENT_PROVIDER_EVIDENCE_BYTES_LIMIT = 24576;
3
+ export declare const AGENT_PROVIDER_REQUEST_CONTEXT_BYTES_LIMIT = 16384;
4
+ export declare const AGENT_PROVIDER_DATA_BYTES_LIMIT_MAX = 32768;
5
+ export type AgentProviderDataTruncationReason = "byte_limit_exceeded" | "structural_limit_exceeded" | "byte_and_structural_limits_exceeded";
6
+ interface BoundedAgentProviderDataBase {
7
+ readonly data: AgentJsonValue;
8
+ readonly dataBytes: number;
9
+ readonly redacted: true;
10
+ }
11
+ export type BoundedAgentProviderData = BoundedAgentProviderDataBase & Readonly<{
12
+ originalDataBytes: number;
13
+ truncated: false;
14
+ truncationReason: null;
15
+ } | {
16
+ originalDataBytes: number;
17
+ truncated: true;
18
+ truncationReason: "byte_limit_exceeded";
19
+ } | {
20
+ originalDataBytes: null;
21
+ truncated: true;
22
+ truncationReason: "structural_limit_exceeded" | "byte_and_structural_limits_exceeded";
23
+ }>;
24
+ export type AgentProviderEvidenceCategory = "provider_event" | "provider_request" | "diagnostic";
25
+ export type AgentProviderEvidence = BoundedAgentProviderData & Readonly<{
26
+ readonly category: AgentProviderEvidenceCategory;
27
+ readonly source: string;
28
+ }>;
29
+ export type AgentProviderRequestContext = BoundedAgentProviderData & Readonly<{
30
+ readonly truncated: false;
31
+ readonly truncationReason: null;
32
+ readonly originalDataBytes: number;
33
+ }>;
34
+ export interface CreateAgentProviderEvidenceInput<Category extends AgentProviderEvidenceCategory = AgentProviderEvidenceCategory> {
35
+ readonly category: Category;
36
+ readonly source: string;
37
+ readonly data: unknown;
38
+ readonly bytesLimit?: number;
39
+ }
40
+ export declare function redactAgentProviderData(value: unknown): AgentJsonValue;
41
+ export declare function createBoundedAgentProviderData(value: unknown, bytesLimit?: number): BoundedAgentProviderData;
42
+ export declare function validateBoundedAgentProviderData(input: BoundedAgentProviderData): BoundedAgentProviderData;
43
+ export declare function createAgentProviderRequestContext(value: unknown): AgentProviderRequestContext;
44
+ export declare function validateAgentProviderRequestContext(input: AgentProviderRequestContext): AgentProviderRequestContext;
45
+ export declare function createAgentProviderEvidence<Category extends AgentProviderEvidenceCategory>(input: CreateAgentProviderEvidenceInput<Category>): AgentProviderEvidence & Readonly<{
46
+ category: Category;
47
+ }>;
48
+ export declare function validateAgentProviderEvidence(input: AgentProviderEvidence): AgentProviderEvidence;
49
+ export {};
50
+ //# sourceMappingURL=evidence.d.ts.map
@@ -0,0 +1,368 @@
1
+ import { isDeepStrictEqual } from "node:util";
2
+ import {
3
+ AGENT_PROTOCOL_JSON_BYTES_LIMIT,
4
+ AGENT_PROTOCOL_JSON_KEY_MAX_LENGTH,
5
+ agentProtocolSerializedJsonBytes,
6
+ parseAgentJsonValue
7
+ } from "@agen-ai/agent-protocol";
8
+ import { parseAgentBoundedText } from "./foundation.js";
9
+ import { containsAgentControlCharacter } from "./internal/controlCharacters.js";
10
+ import { serializedAgentJsonValueBytes } from "./internal/serializedJsonBytes.js";
11
+ const AGENT_PROVIDER_EVIDENCE_BYTES_LIMIT = 24576;
12
+ const AGENT_PROVIDER_REQUEST_CONTEXT_BYTES_LIMIT = 16384;
13
+ const AGENT_PROVIDER_DATA_BYTES_LIMIT_MAX = AGENT_PROTOCOL_JSON_BYTES_LIMIT;
14
+ const AGENT_PROVIDER_DATA_DEPTH_LIMIT = 8;
15
+ const AGENT_PROVIDER_DATA_COLLECTION_LIMIT = 100;
16
+ const AGENT_PROVIDER_DATA_REDACTION_REPLACEMENT = "[REDACTED]";
17
+ const AGENT_PROVIDER_DATA_PROTOTYPE_KEYS = /* @__PURE__ */ new Set([
18
+ "__proto__",
19
+ "constructor",
20
+ "prototype"
21
+ ]);
22
+ const SENSITIVE_KEY_PATTERN = /token|secret|password|private[_-]?key|credential|authorization|api[_-]?key/iu;
23
+ function isPortableAgentProviderDataKey(key) {
24
+ return key.length > 0 && key.length <= AGENT_PROTOCOL_JSON_KEY_MAX_LENGTH && !AGENT_PROVIDER_DATA_PROTOTYPE_KEYS.has(key);
25
+ }
26
+ function normalizedObjectKey(key, index, preservedKeys, usedKeys) {
27
+ if (isPortableAgentProviderDataKey(key) && !usedKeys.has(key)) {
28
+ return { key, rewritten: false };
29
+ }
30
+ let collision = 0;
31
+ let candidate;
32
+ do {
33
+ candidate = `truncated_key_${index}${collision === 0 ? "" : `_${collision}`}`;
34
+ collision += 1;
35
+ } while (preservedKeys.has(candidate) || usedKeys.has(candidate));
36
+ return { key: candidate, rewritten: true };
37
+ }
38
+ function normalizedProviderValue(value, ancestors, depth, truncation) {
39
+ if (depth > AGENT_PROVIDER_DATA_DEPTH_LIMIT) {
40
+ truncation.structurallyTruncated = true;
41
+ return "[MaxDepth]";
42
+ }
43
+ if (value === null || typeof value === "string" || typeof value === "boolean") {
44
+ return value;
45
+ }
46
+ if (typeof value === "number") {
47
+ if (Number.isFinite(value)) return value;
48
+ truncation.structurallyTruncated = true;
49
+ return "[NonFiniteNumber]";
50
+ }
51
+ if (typeof value !== "object") {
52
+ truncation.structurallyTruncated = true;
53
+ return `[Unsupported:${typeof value}]`;
54
+ }
55
+ if (ancestors.has(value)) {
56
+ truncation.structurallyTruncated = true;
57
+ return "[Circular]";
58
+ }
59
+ ancestors.add(value);
60
+ try {
61
+ if (Array.isArray(value)) {
62
+ if (value.length > AGENT_PROVIDER_DATA_COLLECTION_LIMIT) {
63
+ truncation.structurallyTruncated = true;
64
+ }
65
+ for (const key of Reflect.ownKeys(value)) {
66
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
67
+ if (descriptor?.enumerable !== true) continue;
68
+ const index = typeof key === "string" ? Number(key) : Number.NaN;
69
+ if (!Number.isInteger(index) || index < 0 || String(index) !== key || index >= value.length) {
70
+ truncation.structurallyTruncated = true;
71
+ }
72
+ }
73
+ const normalized2 = [];
74
+ const length = Math.min(
75
+ value.length,
76
+ AGENT_PROVIDER_DATA_COLLECTION_LIMIT
77
+ );
78
+ for (let index = 0; index < length; index += 1) {
79
+ const descriptor = Object.getOwnPropertyDescriptor(value, index);
80
+ if (!descriptor) {
81
+ normalized2.push(null);
82
+ } else if (!("value" in descriptor)) {
83
+ truncation.structurallyTruncated = true;
84
+ normalized2.push("[Accessor]");
85
+ } else {
86
+ normalized2.push(
87
+ normalizedProviderValue(
88
+ descriptor.value,
89
+ ancestors,
90
+ depth + 1,
91
+ truncation
92
+ )
93
+ );
94
+ }
95
+ }
96
+ return normalized2;
97
+ }
98
+ const prototype = Object.getPrototypeOf(value);
99
+ if (prototype !== Object.prototype && prototype !== null) {
100
+ truncation.structurallyTruncated = true;
101
+ const constructorDescriptor = Object.getOwnPropertyDescriptor(
102
+ prototype,
103
+ "constructor"
104
+ );
105
+ const constructorName = constructorDescriptor && "value" in constructorDescriptor && typeof constructorDescriptor.value === "function" ? constructorDescriptor.value.name || "Object" : "Object";
106
+ return `[Unsupported:${constructorName}]`;
107
+ }
108
+ const normalized = /* @__PURE__ */ Object.create(null);
109
+ const keys = [];
110
+ let enumerablePropertyCount = 0;
111
+ for (const key of Reflect.ownKeys(value)) {
112
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
113
+ if (descriptor?.enumerable !== true) continue;
114
+ enumerablePropertyCount += 1;
115
+ if (typeof key === "string") {
116
+ keys.push(key);
117
+ } else {
118
+ truncation.structurallyTruncated = true;
119
+ }
120
+ }
121
+ if (enumerablePropertyCount > AGENT_PROVIDER_DATA_COLLECTION_LIMIT) {
122
+ truncation.structurallyTruncated = true;
123
+ }
124
+ const selectedKeys = keys.slice(0, AGENT_PROVIDER_DATA_COLLECTION_LIMIT);
125
+ const preservedKeys = new Set(
126
+ selectedKeys.filter(isPortableAgentProviderDataKey)
127
+ );
128
+ const usedKeys = /* @__PURE__ */ new Set();
129
+ selectedKeys.forEach((key, index) => {
130
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
131
+ if (!descriptor) return;
132
+ const normalizedKey = normalizedObjectKey(
133
+ key,
134
+ index,
135
+ preservedKeys,
136
+ usedKeys
137
+ );
138
+ usedKeys.add(normalizedKey.key);
139
+ if (normalizedKey.rewritten) truncation.structurallyTruncated = true;
140
+ if (!("value" in descriptor)) {
141
+ truncation.structurallyTruncated = true;
142
+ normalized[normalizedKey.key] = "[Accessor]";
143
+ return;
144
+ }
145
+ normalized[normalizedKey.key] = SENSITIVE_KEY_PATTERN.test(key) ? AGENT_PROVIDER_DATA_REDACTION_REPLACEMENT : normalizedProviderValue(
146
+ descriptor.value,
147
+ ancestors,
148
+ depth + 1,
149
+ truncation
150
+ );
151
+ });
152
+ return normalized;
153
+ } catch {
154
+ truncation.structurallyTruncated = true;
155
+ return "[Uninspectable]";
156
+ } finally {
157
+ ancestors.delete(value);
158
+ }
159
+ }
160
+ function normalizeAgentProviderData(value) {
161
+ const truncation = {
162
+ structurallyTruncated: false
163
+ };
164
+ return {
165
+ data: normalizedProviderValue(
166
+ value,
167
+ /* @__PURE__ */ new WeakSet(),
168
+ 0,
169
+ truncation
170
+ ),
171
+ structurallyTruncated: truncation.structurallyTruncated
172
+ };
173
+ }
174
+ function validatedBytesLimit(limit) {
175
+ if (!Number.isSafeInteger(limit) || limit < 256 || limit > AGENT_PROVIDER_DATA_BYTES_LIMIT_MAX) {
176
+ throw new RangeError(
177
+ `Provider data byte limits must be an integer from 256 through ${AGENT_PROVIDER_DATA_BYTES_LIMIT_MAX}.`
178
+ );
179
+ }
180
+ return limit;
181
+ }
182
+ function redactAgentProviderData(value) {
183
+ return parseAgentJsonValue(normalizeAgentProviderData(value).data);
184
+ }
185
+ function createBoundedAgentProviderData(value, bytesLimit = AGENT_PROVIDER_EVIDENCE_BYTES_LIMIT) {
186
+ const validatedLimit = validatedBytesLimit(bytesLimit);
187
+ const normalized = normalizeAgentProviderData(value);
188
+ const normalizedDataBytes = serializedAgentJsonValueBytes(normalized.data);
189
+ if (normalizedDataBytes <= validatedLimit) {
190
+ const data = parseAgentJsonValue(normalized.data);
191
+ if (normalized.structurallyTruncated) {
192
+ return Object.freeze({
193
+ data,
194
+ dataBytes: normalizedDataBytes,
195
+ originalDataBytes: null,
196
+ truncated: true,
197
+ truncationReason: "structural_limit_exceeded",
198
+ redacted: true
199
+ });
200
+ }
201
+ return Object.freeze({
202
+ data,
203
+ dataBytes: normalizedDataBytes,
204
+ originalDataBytes: normalizedDataBytes,
205
+ truncated: false,
206
+ truncationReason: null,
207
+ redacted: true
208
+ });
209
+ }
210
+ if (normalized.structurallyTruncated) {
211
+ const truncatedData2 = parseAgentJsonValue({
212
+ truncated: true,
213
+ reason: "byte_and_structural_limits_exceeded",
214
+ originalDataBytes: null
215
+ });
216
+ return Object.freeze({
217
+ data: truncatedData2,
218
+ dataBytes: agentProtocolSerializedJsonBytes(truncatedData2),
219
+ originalDataBytes: null,
220
+ truncated: true,
221
+ truncationReason: "byte_and_structural_limits_exceeded",
222
+ redacted: true
223
+ });
224
+ }
225
+ const truncatedData = parseAgentJsonValue({
226
+ truncated: true,
227
+ reason: "byte_limit_exceeded",
228
+ originalDataBytes: normalizedDataBytes
229
+ });
230
+ return Object.freeze({
231
+ data: truncatedData,
232
+ dataBytes: agentProtocolSerializedJsonBytes(truncatedData),
233
+ originalDataBytes: normalizedDataBytes,
234
+ truncated: true,
235
+ truncationReason: "byte_limit_exceeded",
236
+ redacted: true
237
+ });
238
+ }
239
+ function validateBoundedAgentProviderData(input) {
240
+ if (input === null || typeof input !== "object" || typeof input.dataBytes !== "number" || typeof input.truncated !== "boolean" || input.redacted !== true) {
241
+ throw new TypeError("Bounded provider data is invalid.");
242
+ }
243
+ const data = parseAgentJsonValue(input.data);
244
+ if (!isDeepStrictEqual(data, redactAgentProviderData(data))) {
245
+ throw new TypeError(
246
+ "Bounded provider data must be canonically normalized and redacted."
247
+ );
248
+ }
249
+ const dataBytes = agentProtocolSerializedJsonBytes(data);
250
+ if (input.dataBytes !== dataBytes) {
251
+ throw new TypeError("Bounded provider data byte accounting is invalid.");
252
+ }
253
+ if (!input.truncated) {
254
+ if (input.truncationReason !== null || !Number.isSafeInteger(input.originalDataBytes) || input.originalDataBytes !== dataBytes) {
255
+ throw new TypeError("Bounded provider data byte accounting is invalid.");
256
+ }
257
+ return Object.freeze({
258
+ data,
259
+ dataBytes,
260
+ originalDataBytes: input.originalDataBytes,
261
+ truncated: false,
262
+ truncationReason: null,
263
+ redacted: true
264
+ });
265
+ }
266
+ switch (input.truncationReason) {
267
+ case "byte_limit_exceeded":
268
+ if (!Number.isSafeInteger(input.originalDataBytes) || input.originalDataBytes <= dataBytes) {
269
+ throw new TypeError("Bounded provider data byte accounting is invalid.");
270
+ }
271
+ return Object.freeze({
272
+ data,
273
+ dataBytes,
274
+ originalDataBytes: input.originalDataBytes,
275
+ truncated: true,
276
+ truncationReason: input.truncationReason,
277
+ redacted: true
278
+ });
279
+ case "structural_limit_exceeded":
280
+ case "byte_and_structural_limits_exceeded":
281
+ if (input.originalDataBytes !== null) {
282
+ throw new TypeError(
283
+ "Bounded provider data truncation metadata is invalid."
284
+ );
285
+ }
286
+ return Object.freeze({
287
+ data,
288
+ dataBytes,
289
+ originalDataBytes: null,
290
+ truncated: true,
291
+ truncationReason: input.truncationReason,
292
+ redacted: true
293
+ });
294
+ default:
295
+ throw new TypeError(
296
+ "Bounded provider data truncation metadata is invalid."
297
+ );
298
+ }
299
+ }
300
+ function createAgentProviderRequestContext(value) {
301
+ const canonical = parseAgentJsonValue(value);
302
+ const bounded = createBoundedAgentProviderData(
303
+ canonical,
304
+ AGENT_PROVIDER_REQUEST_CONTEXT_BYTES_LIMIT
305
+ );
306
+ if (bounded.truncated) {
307
+ throw new RangeError(
308
+ "Provider request context exceeds its transport byte limit."
309
+ );
310
+ }
311
+ if (!isDeepStrictEqual(bounded.data, canonical)) {
312
+ throw new TypeError(
313
+ "Provider request context must be JSON-safe and require no redaction or structural truncation."
314
+ );
315
+ }
316
+ return bounded;
317
+ }
318
+ function validateAgentProviderRequestContext(input) {
319
+ const bounded = validateBoundedAgentProviderData(input);
320
+ if (bounded.truncated) {
321
+ throw new TypeError("Provider request context cannot be truncated.");
322
+ }
323
+ return createAgentProviderRequestContext(bounded.data);
324
+ }
325
+ function parseEvidenceSource(value) {
326
+ const source = parseAgentBoundedText(value, "Provider evidence source", 160);
327
+ if (source !== source.trim() || containsAgentControlCharacter(source)) {
328
+ throw new TypeError(
329
+ "Provider evidence source must be a canonical bounded string."
330
+ );
331
+ }
332
+ return source;
333
+ }
334
+ function createAgentProviderEvidence(input) {
335
+ const bounded = createBoundedAgentProviderData(
336
+ input.data,
337
+ input.bytesLimit
338
+ );
339
+ return Object.freeze({
340
+ category: input.category,
341
+ source: parseEvidenceSource(input.source),
342
+ ...bounded
343
+ });
344
+ }
345
+ function validateAgentProviderEvidence(input) {
346
+ if (input === null || typeof input !== "object" || !["provider_event", "provider_request", "diagnostic"].includes(
347
+ input.category
348
+ )) {
349
+ throw new TypeError("Provider evidence is invalid.");
350
+ }
351
+ return Object.freeze({
352
+ category: input.category,
353
+ source: parseEvidenceSource(input.source),
354
+ ...validateBoundedAgentProviderData(input)
355
+ });
356
+ }
357
+ export {
358
+ AGENT_PROVIDER_DATA_BYTES_LIMIT_MAX,
359
+ AGENT_PROVIDER_EVIDENCE_BYTES_LIMIT,
360
+ AGENT_PROVIDER_REQUEST_CONTEXT_BYTES_LIMIT,
361
+ createAgentProviderEvidence,
362
+ createAgentProviderRequestContext,
363
+ createBoundedAgentProviderData,
364
+ redactAgentProviderData,
365
+ validateAgentProviderEvidence,
366
+ validateAgentProviderRequestContext,
367
+ validateBoundedAgentProviderData
368
+ };
@@ -0,0 +1,8 @@
1
+ export declare const AGENT_RUNTIME_PACKAGE_NAME: "@agen-ai/agent-runtime";
2
+ export type MaybePromise<Value> = Value | Promise<Value>;
3
+ export declare function parseAgentBoundedText(value: unknown, field: string, maxLength: number): string;
4
+ export declare function parseAgentCanonicalText(value: unknown, field: string, maxLength: number): string;
5
+ export declare function parseAgentProviderTechnicalId(value: unknown, field?: string): string;
6
+ export declare function throwIfAgentOperationAborted(signal?: AbortSignal): void;
7
+ export declare function isAgentOperationAbortError(error: unknown): boolean;
8
+ //# sourceMappingURL=foundation.d.ts.map
@@ -0,0 +1,37 @@
1
+ import { AGENT_PROTOCOL_ID_MAX_LENGTH } from "@agen-ai/agent-protocol";
2
+ import { containsAgentControlCharacter } from "./internal/controlCharacters.js";
3
+ const AGENT_RUNTIME_PACKAGE_NAME = "@agen-ai/agent-runtime";
4
+ function parseAgentBoundedText(value, field, maxLength) {
5
+ if (!Number.isSafeInteger(maxLength) || maxLength < 1) {
6
+ throw new RangeError("Agent text maxLength must be a positive integer.");
7
+ }
8
+ if (typeof value !== "string" || value.length < 1 || value.length > maxLength) {
9
+ throw new TypeError(`${field} must be a bounded non-empty string.`);
10
+ }
11
+ return value;
12
+ }
13
+ function parseAgentCanonicalText(value, field, maxLength) {
14
+ const text = parseAgentBoundedText(value, field, maxLength);
15
+ if (text !== text.trim() || containsAgentControlCharacter(text)) {
16
+ throw new TypeError(`${field} must be canonical text.`);
17
+ }
18
+ return text;
19
+ }
20
+ function parseAgentProviderTechnicalId(value, field = "provider technical identifier") {
21
+ return parseAgentCanonicalText(value, field, AGENT_PROTOCOL_ID_MAX_LENGTH);
22
+ }
23
+ function throwIfAgentOperationAborted(signal) {
24
+ if (!signal?.aborted) return;
25
+ throw signal.reason instanceof Error ? signal.reason : new DOMException("The agent operation was aborted.", "AbortError");
26
+ }
27
+ function isAgentOperationAbortError(error) {
28
+ return error instanceof Error && error.name === "AbortError";
29
+ }
30
+ export {
31
+ AGENT_RUNTIME_PACKAGE_NAME,
32
+ isAgentOperationAbortError,
33
+ parseAgentBoundedText,
34
+ parseAgentCanonicalText,
35
+ parseAgentProviderTechnicalId,
36
+ throwIfAgentOperationAborted
37
+ };
@@ -0,0 +1,13 @@
1
+ export * from "./adapterValidation.js";
2
+ export * from "./artifacts.js";
3
+ export * from "./contractErrors.js";
4
+ export * from "./evidence.js";
5
+ export * from "./foundation.js";
6
+ export * from "./outputs.js";
7
+ export * from "./providerCatalog.js";
8
+ export * from "./providerDriver.js";
9
+ export * from "./providerInstanceRegistry.js";
10
+ export * from "./readiness.js";
11
+ export * from "./sessions.js";
12
+ export * from "./text.js";
13
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ export * from "./adapterValidation.js";
2
+ export * from "./artifacts.js";
3
+ export * from "./contractErrors.js";
4
+ export * from "./evidence.js";
5
+ export * from "./foundation.js";
6
+ export * from "./outputs.js";
7
+ export * from "./providerCatalog.js";
8
+ export * from "./providerDriver.js";
9
+ export * from "./providerInstanceRegistry.js";
10
+ export * from "./readiness.js";
11
+ export * from "./sessions.js";
12
+ export * from "./text.js";
@@ -0,0 +1,2 @@
1
+ export declare function containsAgentControlCharacter(value: string): boolean;
2
+ //# sourceMappingURL=controlCharacters.d.ts.map
@@ -0,0 +1,7 @@
1
+ const AGENT_CONTROL_CHARACTER_PATTERN = /[\u0000-\u001F\u007F-\u009F]/u;
2
+ function containsAgentControlCharacter(value) {
3
+ return AGENT_CONTROL_CHARACTER_PATTERN.test(value);
4
+ }
5
+ export {
6
+ containsAgentControlCharacter
7
+ };
@@ -0,0 +1,3 @@
1
+ import type { AgentJsonValue } from "@agen-ai/agent-protocol";
2
+ export declare function serializedAgentJsonValueBytes(value: AgentJsonValue): number;
3
+ //# sourceMappingURL=serializedJsonBytes.d.ts.map
@@ -0,0 +1,57 @@
1
+ function serializedJsonStringBytes(value) {
2
+ let bytes = 2;
3
+ for (let index = 0; index < value.length; index += 1) {
4
+ const codeUnit = value.charCodeAt(index);
5
+ if (codeUnit === 34 || codeUnit === 92) {
6
+ bytes += 2;
7
+ continue;
8
+ }
9
+ if (codeUnit === 8 || codeUnit === 9 || codeUnit === 10 || codeUnit === 12 || codeUnit === 13) {
10
+ bytes += 2;
11
+ continue;
12
+ }
13
+ if (codeUnit < 32) {
14
+ bytes += 6;
15
+ continue;
16
+ }
17
+ if (codeUnit < 128) {
18
+ bytes += 1;
19
+ continue;
20
+ }
21
+ if (codeUnit < 2048) {
22
+ bytes += 2;
23
+ continue;
24
+ }
25
+ if (codeUnit >= 55296 && codeUnit <= 56319) {
26
+ const nextCodeUnit = value.charCodeAt(index + 1);
27
+ if (nextCodeUnit >= 56320 && nextCodeUnit <= 57343) {
28
+ bytes += 4;
29
+ index += 1;
30
+ } else {
31
+ bytes += 6;
32
+ }
33
+ continue;
34
+ }
35
+ bytes += codeUnit >= 56320 && codeUnit <= 57343 ? 6 : 3;
36
+ }
37
+ return bytes;
38
+ }
39
+ function serializedAgentJsonValueBytes(value) {
40
+ if (value === null) return 4;
41
+ if (typeof value === "string") return serializedJsonStringBytes(value);
42
+ if (typeof value === "number") return String(value).length;
43
+ if (typeof value === "boolean") return value ? 4 : 5;
44
+ if (Array.isArray(value)) {
45
+ return value.reduce(
46
+ (bytes, item, index) => bytes + serializedAgentJsonValueBytes(item) + (index === 0 ? 0 : 1),
47
+ 2
48
+ );
49
+ }
50
+ return Object.entries(value).reduce(
51
+ (bytes, [key, item], index) => bytes + serializedJsonStringBytes(key) + 1 + serializedAgentJsonValueBytes(item) + (index === 0 ? 0 : 1),
52
+ 2
53
+ );
54
+ }
55
+ export {
56
+ serializedAgentJsonValueBytes
57
+ };
@@ -0,0 +1,13 @@
1
+ import { type AgentCapabilities, type AgentProviderKey, type AgentSessionId, type AgentTurnId } from "@agen-ai/agent-protocol";
2
+ import { type AgentProviderOutput } from "./outputs.js";
3
+ import type { AgentProviderOperationResult } from "./sessions.js";
4
+ export interface AgentProviderOutputValidationContext {
5
+ readonly capabilities: AgentCapabilities;
6
+ readonly providerKey: AgentProviderKey;
7
+ readonly sessionId?: AgentSessionId;
8
+ readonly turnId?: AgentTurnId;
9
+ readonly authenticationAttemptId?: string;
10
+ }
11
+ export declare function validateAgentProviderOutputForContext(candidate: AgentProviderOutput, context: AgentProviderOutputValidationContext): AgentProviderOutput;
12
+ export declare function validateAgentProviderOperationResult(candidate: AgentProviderOperationResult, context: AgentProviderOutputValidationContext): AgentProviderOperationResult;
13
+ //# sourceMappingURL=outputValidation.d.ts.map