@agen-ai/agent-protocol 0.2.5 → 0.3.1

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 (79) hide show
  1. package/README.md +45 -13
  2. package/dist/capabilities/contentReferenceText.d.ts +13 -0
  3. package/dist/capabilities/contentReferenceText.js +25 -0
  4. package/dist/capabilities/index.d.ts +1 -0
  5. package/dist/capabilities/index.js +1 -0
  6. package/dist/capabilities/types.d.ts +19 -1
  7. package/dist/capabilities/types.js +6 -0
  8. package/dist/commands/index.d.ts +3 -0
  9. package/dist/commands/index.js +2 -0
  10. package/dist/commands/parsers.d.ts +7 -0
  11. package/dist/commands/parsers.js +23 -0
  12. package/dist/commands/types.d.ts +26 -0
  13. package/dist/commands/types.js +10 -0
  14. package/dist/effectiveContent/index.d.ts +3 -0
  15. package/dist/effectiveContent/index.js +2 -0
  16. package/dist/effectiveContent/parsers.d.ts +7 -0
  17. package/dist/effectiveContent/parsers.js +23 -0
  18. package/dist/effectiveContent/types.d.ts +35 -0
  19. package/dist/effectiveContent/types.js +19 -0
  20. package/dist/environment/facts.d.ts +28 -0
  21. package/dist/environment/facts.js +39 -0
  22. package/dist/environment/index.d.ts +4 -0
  23. package/dist/environment/index.js +3 -0
  24. package/dist/environment/parsers.d.ts +17 -0
  25. package/dist/environment/parsers.js +68 -0
  26. package/dist/environment/types.d.ts +61 -0
  27. package/dist/environment/types.js +26 -0
  28. package/dist/events/types.d.ts +1 -1
  29. package/dist/extensions/index.d.ts +3 -0
  30. package/dist/extensions/index.js +2 -0
  31. package/dist/extensions/parsers.d.ts +7 -0
  32. package/dist/extensions/parsers.js +23 -0
  33. package/dist/extensions/types.d.ts +73 -0
  34. package/dist/extensions/types.js +30 -0
  35. package/dist/foundation/parsers.d.ts +9 -1
  36. package/dist/foundation/parsers.js +24 -0
  37. package/dist/foundation/types.d.ts +5 -1
  38. package/dist/foundation/types.js +1 -1
  39. package/dist/integrations/types.d.ts +22 -4
  40. package/dist/integrations/types.js +6 -2
  41. package/dist/jsonSchema/generated.d.ts +9390 -5844
  42. package/dist/jsonSchema/generated.js +2526 -157
  43. package/dist/public/commands.d.ts +2 -0
  44. package/dist/public/commands.js +1 -0
  45. package/dist/public/effectiveContent.d.ts +2 -0
  46. package/dist/public/effectiveContent.js +1 -0
  47. package/dist/public/environment.d.ts +2 -0
  48. package/dist/public/environment.js +1 -0
  49. package/dist/public/extensions.d.ts +2 -0
  50. package/dist/public/extensions.js +1 -0
  51. package/dist/public/index.d.ts +4 -0
  52. package/dist/public/index.js +4 -0
  53. package/dist/turns/parsers.d.ts +3 -1
  54. package/dist/turns/parsers.js +9 -0
  55. package/dist/turns/types.d.ts +13 -2
  56. package/dist/turns/types.js +4 -0
  57. package/dist/zod/capabilities.d.ts +79 -1
  58. package/dist/zod/capabilities.js +21 -5
  59. package/dist/zod/commands.d.ts +35 -0
  60. package/dist/zod/commands.js +114 -0
  61. package/dist/zod/effectiveContent.d.ts +72 -0
  62. package/dist/zod/effectiveContent.js +157 -0
  63. package/dist/zod/environment.d.ts +531 -0
  64. package/dist/zod/environment.js +336 -0
  65. package/dist/zod/environmentFacts.d.ts +10 -0
  66. package/dist/zod/environmentFacts.js +40 -0
  67. package/dist/zod/events.d.ts +21 -21
  68. package/dist/zod/extensions.d.ts +161 -0
  69. package/dist/zod/extensions.js +194 -0
  70. package/dist/zod/foundation.d.ts +5 -1
  71. package/dist/zod/foundation.js +8 -0
  72. package/dist/zod/index.d.ts +9 -4
  73. package/dist/zod/index.js +21 -2
  74. package/dist/zod/integrations.d.ts +50 -5
  75. package/dist/zod/integrations.js +49 -6
  76. package/dist/zod/turns.d.ts +33 -0
  77. package/dist/zod/turns.js +34 -1
  78. package/dist/zod/typeEquality.generated.d.ts +34 -4
  79. package/package.json +18 -2
@@ -0,0 +1,157 @@
1
+ import { z } from "zod/v4";
2
+ import {
3
+ AGENT_PROTOCOL_JSON_DEPTH_LIMIT,
4
+ agentProtocolSerializedJsonBytes
5
+ } from "../foundation/types.js";
6
+ import { compareStringsByUnicodeCodePoint } from "../foundation/ordering.js";
7
+ import {
8
+ AGENT_EFFECTIVE_CONTENT_CATALOG_BYTES_LIMIT,
9
+ AGENT_EFFECTIVE_CONTENT_CATALOG_MAX_LENGTH,
10
+ AGENT_EFFECTIVE_CONTENT_KINDS,
11
+ AGENT_EFFECTIVE_CONTENT_NAME_MAX_LENGTH,
12
+ AGENT_EFFECTIVE_CONTENT_SUMMARY_MAX_LENGTH,
13
+ AGENT_DEFINITION_MODES
14
+ } from "../effectiveContent/types.js";
15
+ import {
16
+ AgentAvailabilityFactSchema,
17
+ AgentEnvironmentSourceSchema,
18
+ AgentInvocationPostureSchema,
19
+ AgentQualifiedExtensionReferenceSchema
20
+ } from "./environmentFacts.js";
21
+ import {
22
+ AgentEffectiveContentIdSchema,
23
+ AgentIsoDateTimeSchema,
24
+ createAgentCanonicalNonBlankStringSchema,
25
+ withAcyclicProtocolInput
26
+ } from "./foundation.js";
27
+ const PositiveSafeIntegerSchema = z.number().int().positive().max(Number.MAX_SAFE_INTEGER);
28
+ const NameSchema = createAgentCanonicalNonBlankStringSchema(
29
+ AGENT_EFFECTIVE_CONTENT_NAME_MAX_LENGTH
30
+ );
31
+ const SummarySchema = createAgentCanonicalNonBlankStringSchema(
32
+ AGENT_EFFECTIVE_CONTENT_SUMMARY_MAX_LENGTH
33
+ );
34
+ const AgentDefinitionObservationSchema = z.object({
35
+ mode: z.enum(AGENT_DEFINITION_MODES),
36
+ hidden: AgentAvailabilityFactSchema
37
+ }).strict().readonly();
38
+ const AgentEffectiveContentDescriptorPortableSchema = z.object({
39
+ contentId: AgentEffectiveContentIdSchema,
40
+ revision: PositiveSafeIntegerSchema,
41
+ kind: z.enum(AGENT_EFFECTIVE_CONTENT_KINDS),
42
+ name: NameSchema,
43
+ summary: SummarySchema.optional(),
44
+ source: AgentEnvironmentSourceSchema,
45
+ registration: AgentAvailabilityFactSchema,
46
+ enablement: AgentAvailabilityFactSchema,
47
+ invocation: AgentInvocationPostureSchema,
48
+ modelCallability: AgentAvailabilityFactSchema,
49
+ extension: AgentQualifiedExtensionReferenceSchema.optional(),
50
+ agentDefinition: AgentDefinitionObservationSchema.optional()
51
+ }).strict().readonly();
52
+ function validateEffectiveContentSemantics(descriptor, context) {
53
+ if (descriptor.agentDefinition && descriptor.kind !== "agent_definition") {
54
+ context.addIssue({
55
+ code: "custom",
56
+ path: ["agentDefinition"],
57
+ message: "Only agent definitions can carry definition observations."
58
+ });
59
+ }
60
+ const unavailable = descriptor.registration.kind === "known" && !descriptor.registration.value || descriptor.enablement.kind === "known" && !descriptor.enablement.value;
61
+ const positiveInvocation = descriptor.invocation === "user_and_model" || descriptor.invocation === "user_only" || descriptor.invocation === "model_only";
62
+ if (unavailable && positiveInvocation) {
63
+ context.addIssue({
64
+ code: "custom",
65
+ path: ["invocation"],
66
+ message: "Denied registration or enablement cannot advertise a positive invocation posture."
67
+ });
68
+ }
69
+ if (unavailable && descriptor.modelCallability.kind === "known" && descriptor.modelCallability.value) {
70
+ context.addIssue({
71
+ code: "custom",
72
+ path: ["modelCallability"],
73
+ message: "Denied registration or enablement cannot be model-callable."
74
+ });
75
+ }
76
+ if (descriptor.modelCallability.kind !== "known") return;
77
+ const modelIsIncluded = descriptor.invocation === "user_and_model" || descriptor.invocation === "model_only";
78
+ const modelIsExcluded = descriptor.invocation === "user_only" || descriptor.invocation === "unavailable";
79
+ if (modelIsIncluded && !descriptor.modelCallability.value || modelIsExcluded && descriptor.modelCallability.value) {
80
+ context.addIssue({
81
+ code: "custom",
82
+ path: ["modelCallability"],
83
+ message: "modelCallability must agree with the explicit invocation posture."
84
+ });
85
+ }
86
+ }
87
+ const AgentEffectiveContentDescriptorSchema = withAcyclicProtocolInput(
88
+ AgentEffectiveContentDescriptorPortableSchema,
89
+ {
90
+ maxDepth: AGENT_PROTOCOL_JSON_DEPTH_LIMIT,
91
+ maxCollectionLength: AGENT_EFFECTIVE_CONTENT_CATALOG_MAX_LENGTH
92
+ }
93
+ ).superRefine(validateEffectiveContentSemantics);
94
+ const AgentEffectiveContentCatalogPortableSchema = z.object({
95
+ revision: PositiveSafeIntegerSchema,
96
+ observedAt: AgentIsoDateTimeSchema,
97
+ content: z.array(AgentEffectiveContentDescriptorPortableSchema).max(AGENT_EFFECTIVE_CONTENT_CATALOG_MAX_LENGTH).readonly()
98
+ }).strict().readonly();
99
+ function addOrderedUniqueIssues(values, path, context) {
100
+ const seen = /* @__PURE__ */ new Set();
101
+ values.forEach((value, index) => {
102
+ if (seen.has(value)) {
103
+ context.addIssue({
104
+ code: "custom",
105
+ path: [...path, index],
106
+ message: "Effective content IDs must be unique."
107
+ });
108
+ }
109
+ if (index > 0 && compareStringsByUnicodeCodePoint(values[index - 1], value) >= 0) {
110
+ context.addIssue({
111
+ code: "custom",
112
+ path: [...path, index],
113
+ message: "Effective content IDs must use canonical order."
114
+ });
115
+ }
116
+ seen.add(value);
117
+ });
118
+ }
119
+ const AgentEffectiveContentCatalogSchema = withAcyclicProtocolInput(
120
+ AgentEffectiveContentCatalogPortableSchema,
121
+ {
122
+ maxDepth: AGENT_PROTOCOL_JSON_DEPTH_LIMIT,
123
+ maxCollectionLength: AGENT_EFFECTIVE_CONTENT_CATALOG_MAX_LENGTH
124
+ }
125
+ ).superRefine((catalog, context) => {
126
+ if (agentProtocolSerializedJsonBytes(catalog) > AGENT_EFFECTIVE_CONTENT_CATALOG_BYTES_LIMIT) {
127
+ context.addIssue({
128
+ code: "custom",
129
+ path: ["content"],
130
+ message: "Effective content catalog exceeds its serialized UTF-8 byte limit."
131
+ });
132
+ }
133
+ addOrderedUniqueIssues(
134
+ catalog.content.map((descriptor) => descriptor.contentId),
135
+ ["content"],
136
+ context
137
+ );
138
+ catalog.content.forEach((descriptor, descriptorIndex) => {
139
+ const parsed = AgentEffectiveContentDescriptorSchema.safeParse(descriptor);
140
+ if (!parsed.success) {
141
+ for (const issue of parsed.error.issues) {
142
+ context.addIssue({
143
+ code: "custom",
144
+ path: ["content", descriptorIndex, ...issue.path],
145
+ message: issue.message
146
+ });
147
+ }
148
+ }
149
+ });
150
+ });
151
+ export {
152
+ AgentDefinitionObservationSchema,
153
+ AgentEffectiveContentCatalogPortableSchema,
154
+ AgentEffectiveContentCatalogSchema,
155
+ AgentEffectiveContentDescriptorPortableSchema,
156
+ AgentEffectiveContentDescriptorSchema
157
+ };