@vibe-agent-toolkit/agent-schema 0.1.1 → 0.1.2-rc.3

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/dist/index.d.ts CHANGED
@@ -3,10 +3,12 @@
3
3
  *
4
4
  * JSON Schema definitions and TypeScript types for VAT agent manifest format.
5
5
  */
6
- export declare const VERSION = "0.1.0";
6
+ export { toJsonSchema, type JsonSchemaOptions } from './schema-utils.js';
7
+ export * from './result-types.js';
8
+ export * from './output-envelopes.js';
7
9
  export { AgentMetadataSchema, BuildMetadataSchema, type AgentMetadata, type BuildMetadata, } from './metadata.js';
8
10
  export { LLMConfigSchema, type LLMConfig, } from './llm.js';
9
- export { AgentInterfaceSchema, SchemaRefSchema, type AgentInterface, type SchemaRef, } from './interface.js';
11
+ export { AgentInterfaceSchema, SchemaRefSchema, type Agent, type AgentInterface, type SchemaRef, } from './interface.js';
10
12
  export { ToolAlternativeSchema, ToolSchema, type Tool, type ToolAlternative, } from './tool.js';
11
13
  export { ResourceRegistrySchema, ResourceSchema, type Resource, type ResourceRegistry, } from './resource-registry.js';
12
14
  export { AgentManifestSchema, AgentSpecSchema, CompositionConfigSchema, CredentialsConfigSchema, MemoryConfigSchema, PromptConfigSchema, PromptsConfigSchema, RAGConfigSchema, TestConfigSchema, type AgentManifest, type AgentSpec, type CompositionConfig, type CredentialsConfig, type MemoryConfig, type PromptConfig, type PromptsConfig, type RAGConfig, type TestConfig, } from './agent-manifest.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,OAAO,UAAU,CAAC;AAG/B,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,KAAK,aAAa,EAClB,KAAK,aAAa,GACnB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,eAAe,EACf,KAAK,SAAS,GACf,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,SAAS,GACf,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,qBAAqB,EACrB,UAAU,EACV,KAAK,IAAI,EACT,KAAK,eAAe,GACrB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,KAAK,QAAQ,EACb,KAAK,gBAAgB,GACtB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,UAAU,GAChB,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGzE,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AAGtC,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,KAAK,aAAa,EAClB,KAAK,aAAa,GACnB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,eAAe,EACf,KAAK,SAAS,GACf,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,KAAK,KAAK,EACV,KAAK,cAAc,EACnB,KAAK,SAAS,GACf,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,qBAAqB,EACrB,UAAU,EACV,KAAK,IAAI,EACT,KAAK,eAAe,GACrB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,KAAK,QAAQ,EACb,KAAK,gBAAgB,GACtB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,UAAU,GAChB,MAAM,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -3,7 +3,11 @@
3
3
  *
4
4
  * JSON Schema definitions and TypeScript types for VAT agent manifest format.
5
5
  */
6
- export const VERSION = '0.1.0';
6
+ // JSON Schema utilities
7
+ export { toJsonSchema } from './schema-utils.js';
8
+ // Result types
9
+ export * from './result-types.js';
10
+ export * from './output-envelopes.js';
7
11
  // Core schemas
8
12
  export { AgentMetadataSchema, BuildMetadataSchema, } from './metadata.js';
9
13
  export { LLMConfigSchema, } from './llm.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAE/B,eAAe;AACf,OAAO,EACL,mBAAmB,EACnB,mBAAmB,GAGpB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,eAAe,GAEhB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,oBAAoB,EACpB,eAAe,GAGhB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,qBAAqB,EACrB,UAAU,GAGX,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,sBAAsB,EACtB,cAAc,GAGf,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,GAUjB,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,wBAAwB;AACxB,OAAO,EAAE,YAAY,EAA0B,MAAM,mBAAmB,CAAC;AAEzE,eAAe;AACf,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AAEtC,eAAe;AACf,OAAO,EACL,mBAAmB,EACnB,mBAAmB,GAGpB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,eAAe,GAEhB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,oBAAoB,EACpB,eAAe,GAIhB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,qBAAqB,EACrB,UAAU,GAGX,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,sBAAsB,EACtB,cAAc,GAGf,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,GAUjB,MAAM,qBAAqB,CAAC"}
@@ -44,4 +44,37 @@ export declare const AgentInterfaceSchema: z.ZodObject<{
44
44
  } | undefined;
45
45
  }>;
46
46
  export type AgentInterface = z.infer<typeof AgentInterfaceSchema>;
47
+ /**
48
+ * TypeScript interface for executable agents.
49
+ *
50
+ * Represents a VAT agent with a defined input/output contract and manifest.
51
+ * ALL agents must be async for consistency and future capabilities.
52
+ */
53
+ export interface Agent<TInput = unknown, TOutput = unknown> {
54
+ /** Unique name for the agent */
55
+ name: string;
56
+ /** Metadata describing the agent's interface and capabilities */
57
+ manifest: AgentManifest;
58
+ /**
59
+ * Execute the agent with given input.
60
+ * ALL agents must return Promise for consistency and future-proofing.
61
+ */
62
+ execute(input: TInput, context?: unknown): Promise<TOutput>;
63
+ }
64
+ /**
65
+ * Agent manifest metadata.
66
+ * Describes what the agent does and how to interact with it.
67
+ */
68
+ export interface AgentManifest {
69
+ /** Unique name for the agent */
70
+ name: string;
71
+ /** Semantic version (e.g., "1.0.0") */
72
+ version: string;
73
+ /** Human-readable description of what the agent does */
74
+ description: string;
75
+ /** Agent archetype (e.g., "pure-function-tool", "llm-analyzer", "conversational-assistant") */
76
+ archetype: string;
77
+ /** Additional metadata (model, temperature, capabilities, etc.) */
78
+ metadata?: Record<string, unknown>;
79
+ }
47
80
  //# sourceMappingURL=interface.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;EAGiB,CAAC;AAE9C,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQmB,CAAC;AAErD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
1
+ {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;EAGiB,CAAC;AAE9C,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQmB,CAAC;AAErD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;;;;GAKG;AACH,MAAM,WAAW,KAAK,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO;IACxD,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IAEb,iEAAiE;IACjE,QAAQ,EAAE,aAAa,CAAC;IAExB;;;OAGG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7D;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IAEb,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC;IAEhB,wDAAwD;IACxD,WAAW,EAAE,MAAM,CAAC;IAEpB,+FAA+F;IAC/F,SAAS,EAAE,MAAM,CAAC;IAElB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Output envelope types for different agent archetypes.
3
+ */
4
+ import type { AgentResult, StatefulAgentResult } from './result-types.js';
5
+ /**
6
+ * Output envelope for one-shot agents (pure functions, analyzers).
7
+ *
8
+ * Simpler envelope for synchronous, single-execution agents.
9
+ * Used by archetypes: Pure Function Tool, One-Shot LLM Analyzer
10
+ */
11
+ export interface OneShotAgentOutput<TData, TError extends string = string> {
12
+ /** Machine-readable result for orchestration */
13
+ result: AgentResult<TData, TError>;
14
+ /** Optional metadata (tokens used, confidence score, timing, etc.) */
15
+ metadata?: Record<string, unknown>;
16
+ }
17
+ /**
18
+ * Output envelope for conversational agents.
19
+ *
20
+ * Combines human-facing conversational interface with
21
+ * machine-readable result for orchestration.
22
+ * Used by archetype: Conversational Assistant
23
+ */
24
+ export interface ConversationalAgentOutput<TData, TError extends string = string, TSessionState = unknown> {
25
+ /** Human-readable response for display */
26
+ reply: string;
27
+ /** Updated session state for next turn */
28
+ sessionState: TSessionState;
29
+ /** Machine-readable result for orchestration */
30
+ result: StatefulAgentResult<TData, TError, {
31
+ /** Optional progress indicators for monitoring */
32
+ progress?: {
33
+ current: number;
34
+ total: number;
35
+ message?: string;
36
+ };
37
+ }>;
38
+ }
39
+ //# sourceMappingURL=output-envelopes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-envelopes.d.ts","sourceRoot":"","sources":["../src/output-envelopes.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE1E;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB,CAAC,KAAK,EAAE,MAAM,SAAS,MAAM,GAAG,MAAM;IACvE,gDAAgD;IAChD,MAAM,EAAE,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAEnC,sEAAsE;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,yBAAyB,CAAC,KAAK,EAAE,MAAM,SAAS,MAAM,GAAG,MAAM,EAAE,aAAa,GAAG,OAAO;IACvG,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;IAEd,0CAA0C;IAC1C,YAAY,EAAE,aAAa,CAAC;IAE5B,gDAAgD;IAChD,MAAM,EAAE,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE;QACzC,kDAAkD;QAClD,QAAQ,CAAC,EAAE;YACT,OAAO,EAAE,MAAM,CAAC;YAChB,KAAK,EAAE,MAAM,CAAC;YACd,OAAO,CAAC,EAAE,MAAM,CAAC;SAClB,CAAC;KACH,CAAC,CAAC;CACJ"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Output envelope types for different agent archetypes.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=output-envelopes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-envelopes.js","sourceRoot":"","sources":["../src/output-envelopes.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,203 @@
1
+ /**
2
+ * Core result types for VAT agents.
3
+ * Based on Railway-Oriented Programming pattern.
4
+ */
5
+ /** Success status constant */
6
+ export declare const RESULT_SUCCESS: "success";
7
+ /** Error status constant */
8
+ export declare const RESULT_ERROR: "error";
9
+ /** In-progress status constant (for stateful agents) */
10
+ export declare const RESULT_IN_PROGRESS: "in-progress";
11
+ export type ResultStatus = typeof RESULT_SUCCESS | typeof RESULT_ERROR;
12
+ export type StatefulResultStatus = typeof RESULT_IN_PROGRESS | typeof RESULT_SUCCESS | typeof RESULT_ERROR;
13
+ /** LLM refused to generate output (content policy violation) */
14
+ export declare const LLM_REFUSAL: "llm-refusal";
15
+ /** LLM output didn't match expected format (parsing failed) */
16
+ export declare const LLM_INVALID_OUTPUT: "llm-invalid-output";
17
+ /** Request timed out */
18
+ export declare const LLM_TIMEOUT: "llm-timeout";
19
+ /** Hit rate limit */
20
+ export declare const LLM_RATE_LIMIT: "llm-rate-limit";
21
+ /** Exceeded token limit */
22
+ export declare const LLM_TOKEN_LIMIT: "llm-token-limit";
23
+ /** Service unavailable */
24
+ export declare const LLM_UNAVAILABLE: "llm-unavailable";
25
+ /**
26
+ * Standard LLM error types that all LLM-based agents can use.
27
+ *
28
+ * These represent expected LLM failure modes that should be handled
29
+ * gracefully by orchestrators (retry, fallback, etc.) rather than
30
+ * treated as system failures.
31
+ */
32
+ export type LLMError = typeof LLM_REFUSAL | typeof LLM_INVALID_OUTPUT | typeof LLM_TIMEOUT | typeof LLM_RATE_LIMIT | typeof LLM_TOKEN_LIMIT | typeof LLM_UNAVAILABLE;
33
+ /**
34
+ * LLM errors that are retryable (transient failures).
35
+ * Orchestrators should retry these with exponential backoff.
36
+ */
37
+ export declare const RETRYABLE_LLM_ERRORS: Set<LLMError>;
38
+ /**
39
+ * LLM errors that are NOT retryable (permanent failures).
40
+ * Orchestrators should not retry these.
41
+ */
42
+ export declare const NON_RETRYABLE_LLM_ERRORS: Set<LLMError>;
43
+ /** External event timed out */
44
+ export declare const EVENT_TIMEOUT: "event-timeout";
45
+ /** External system unavailable */
46
+ export declare const EVENT_UNAVAILABLE: "event-unavailable";
47
+ /** External system rejected request */
48
+ export declare const EVENT_REJECTED: "event-rejected";
49
+ /** External system returned invalid response */
50
+ export declare const EVENT_INVALID_RESPONSE: "event-invalid-response";
51
+ /**
52
+ * Standard external event error types for agents that integrate with
53
+ * external systems or humans.
54
+ *
55
+ * These represent expected integration failure modes that should be
56
+ * handled gracefully by orchestrators (retry, fallback, escalation)
57
+ * rather than treated as system failures.
58
+ */
59
+ export type ExternalEventError = typeof EVENT_TIMEOUT | typeof EVENT_UNAVAILABLE | typeof EVENT_REJECTED | typeof EVENT_INVALID_RESPONSE;
60
+ /**
61
+ * External event errors that are retryable (transient failures).
62
+ * Orchestrators should retry these with exponential backoff.
63
+ */
64
+ export declare const RETRYABLE_EVENT_ERRORS: Set<ExternalEventError>;
65
+ /**
66
+ * External event errors that are NOT retryable (permanent failures).
67
+ * Orchestrators should not retry these.
68
+ */
69
+ export declare const NON_RETRYABLE_EVENT_ERRORS: Set<ExternalEventError>;
70
+ /**
71
+ * Execution metadata for production observability.
72
+ *
73
+ * Optional fields that agents can populate for monitoring,
74
+ * cost tracking, and debugging.
75
+ *
76
+ * @property durationMs - Total execution duration in milliseconds
77
+ * @property tokensUsed - Total LLM tokens consumed
78
+ * @property cost - Estimated cost in USD
79
+ * @property model - Model identifier (e.g., 'gpt-4o-mini')
80
+ * @property provider - Provider identifier (e.g., 'openai', 'anthropic')
81
+ * @property retryCount - Number of times orchestrator retried (0 = no retries)
82
+ * @property timestamp - ISO 8601 timestamp of execution start
83
+ */
84
+ export interface ExecutionMetadata {
85
+ /** Total execution duration in milliseconds */
86
+ durationMs?: number;
87
+ /** Total LLM tokens consumed */
88
+ tokensUsed?: number;
89
+ /** Estimated cost in USD */
90
+ cost?: number;
91
+ /** Model identifier (e.g., 'gpt-4o-mini') */
92
+ model?: string;
93
+ /** Provider identifier (e.g., 'openai', 'anthropic') */
94
+ provider?: string;
95
+ /**
96
+ * Number of times orchestrator retried agent execution.
97
+ * - 0 = no retries (succeeded on first attempt)
98
+ * - 1 = one retry (failed once, succeeded on second attempt)
99
+ * - N = N retries
100
+ *
101
+ * Set by orchestrator's retry wrapper, not by agent.
102
+ */
103
+ retryCount?: number;
104
+ /** ISO 8601 timestamp of execution start */
105
+ timestamp?: string;
106
+ }
107
+ /**
108
+ * Create a success result with optional observability fields.
109
+ *
110
+ * @example
111
+ * return createSuccess({ name: 'Fluffy', valid: true });
112
+ *
113
+ * @example
114
+ * return createSuccess(data, {
115
+ * confidence: 0.95,
116
+ * warnings: ['Unusual pattern detected'],
117
+ * });
118
+ */
119
+ export declare function createSuccess<TData>(data: TData, options?: {
120
+ confidence?: number;
121
+ warnings?: string[];
122
+ execution?: ExecutionMetadata;
123
+ }): AgentResult<TData, never>;
124
+ /**
125
+ * Create an error result with optional observability fields.
126
+ *
127
+ * @example
128
+ * return createError('invalid-format');
129
+ *
130
+ * @example
131
+ * return createError(LLM_TIMEOUT, {
132
+ * confidence: 0.9,
133
+ * execution: { durationMs: 5000 },
134
+ * });
135
+ */
136
+ export declare function createError<TError extends string>(error: TError, options?: {
137
+ confidence?: number;
138
+ execution?: ExecutionMetadata;
139
+ }): AgentResult<never, TError>;
140
+ /**
141
+ * Create an in-progress result for stateful agents with optional observability fields.
142
+ *
143
+ * @example
144
+ * return createInProgress({ step: 2, totalSteps: 5 });
145
+ *
146
+ * @example
147
+ * return createInProgress(undefined, {
148
+ * confidence: 0.7,
149
+ * warnings: ['Still gathering information'],
150
+ * });
151
+ */
152
+ export declare function createInProgress<TMetadata>(metadata?: TMetadata, options?: {
153
+ confidence?: number;
154
+ warnings?: string[];
155
+ execution?: ExecutionMetadata;
156
+ }): StatefulAgentResult<never, never, TMetadata>;
157
+ /**
158
+ * Standard result envelope for agents.
159
+ *
160
+ * Provides type-safe success/error handling for orchestration.
161
+ * Based on functional programming Result<T, E> pattern (Rust, F#).
162
+ *
163
+ * @template TData - Success data type
164
+ * @template TError - Error type (use constants, not string literals)
165
+ */
166
+ export type AgentResult<TData, TError extends string = string> = {
167
+ status: typeof RESULT_SUCCESS;
168
+ data: TData;
169
+ /** Confidence in result (0-1 scale) */
170
+ confidence?: number;
171
+ /** Non-fatal warnings */
172
+ warnings?: string[];
173
+ /** Execution metadata for observability */
174
+ execution?: ExecutionMetadata;
175
+ } | {
176
+ status: typeof RESULT_ERROR;
177
+ error: TError;
178
+ /** Confidence in error classification (0-1 scale) */
179
+ confidence?: number;
180
+ /** Execution metadata for observability */
181
+ execution?: ExecutionMetadata;
182
+ };
183
+ /**
184
+ * Extended result for stateful/multi-turn agents.
185
+ *
186
+ * Adds 'in-progress' state for conversational, async, or long-running agents.
187
+ * Composes AgentResult (success/error) with an additional in-progress state.
188
+ *
189
+ * @template TData - Success data type
190
+ * @template TError - Error type (use constants, not string literals)
191
+ * @template TMetadata - Metadata type for in-progress state
192
+ */
193
+ export type StatefulAgentResult<TData, TError extends string = string, TMetadata = unknown> = {
194
+ status: typeof RESULT_IN_PROGRESS;
195
+ metadata?: TMetadata;
196
+ /** Progress indicator (0-1 scale) */
197
+ confidence?: number;
198
+ /** Non-fatal warnings */
199
+ warnings?: string[];
200
+ /** Execution metadata for observability */
201
+ execution?: ExecutionMetadata;
202
+ } | AgentResult<TData, TError>;
203
+ //# sourceMappingURL=result-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result-types.d.ts","sourceRoot":"","sources":["../src/result-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,8BAA8B;AAC9B,eAAO,MAAM,cAAc,EAAG,SAAkB,CAAC;AAEjD,4BAA4B;AAC5B,eAAO,MAAM,YAAY,EAAG,OAAgB,CAAC;AAE7C,wDAAwD;AACxD,eAAO,MAAM,kBAAkB,EAAG,aAAsB,CAAC;AAEzD,MAAM,MAAM,YAAY,GAAG,OAAO,cAAc,GAAG,O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;;;;;;GAQG;AACH,MAAM,MAAM,WAAW,CAAC,KAAK,EAAE,MAAM,SAAS,MAAM,GAAG,MAAM,IACzD;IACE,MAAM,EAAE,OAAO,cAAc,CAAC;IAC9B,IAAI,EAAE,KAAK,CAAC;IAEZ,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,yBAAyB;IACzB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAEpB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,iBAAiB,CAAC;CAC/B,GACD;IACE,MAAM,EAAE,OAAO,YAAY,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IAEd,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,iBAAiB,CAAC;CAC/B,CAAC;AAEN;;;;;;;;;GASG;AACH,MAAM,MAAM,mBAAmB,CAC7B,KAAK,EACL,MAAM,SAAS,MAAM,GAAG,MAAM,EAC9B,SAAS,GAAG,OAAO,IAEjB;IACE,MAAM,EAAE,OAAO,kBAAkB,CAAC;IAClC,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB,qCAAqC;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,yBAAyB;IACzB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAEpB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,iBAAiB,CAAC;CAC/B,GACD,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC"}
@@ -0,0 +1,153 @@
1
+ /**
2
+ * Core result types for VAT agents.
3
+ * Based on Railway-Oriented Programming pattern.
4
+ */
5
+ // ============================================================================
6
+ // Status Constants
7
+ // ============================================================================
8
+ /** Success status constant */
9
+ export const RESULT_SUCCESS = 'success';
10
+ /** Error status constant */
11
+ export const RESULT_ERROR = 'error';
12
+ /** In-progress status constant (for stateful agents) */
13
+ export const RESULT_IN_PROGRESS = 'in-progress';
14
+ // ============================================================================
15
+ // LLM Error Constants
16
+ // ============================================================================
17
+ /** LLM refused to generate output (content policy violation) */
18
+ export const LLM_REFUSAL = 'llm-refusal';
19
+ /** LLM output didn't match expected format (parsing failed) */
20
+ export const LLM_INVALID_OUTPUT = 'llm-invalid-output';
21
+ /** Request timed out */
22
+ export const LLM_TIMEOUT = 'llm-timeout';
23
+ /** Hit rate limit */
24
+ export const LLM_RATE_LIMIT = 'llm-rate-limit';
25
+ /** Exceeded token limit */
26
+ export const LLM_TOKEN_LIMIT = 'llm-token-limit';
27
+ /** Service unavailable */
28
+ export const LLM_UNAVAILABLE = 'llm-unavailable';
29
+ /**
30
+ * LLM errors that are retryable (transient failures).
31
+ * Orchestrators should retry these with exponential backoff.
32
+ */
33
+ export const RETRYABLE_LLM_ERRORS = new Set([
34
+ LLM_TIMEOUT,
35
+ LLM_RATE_LIMIT,
36
+ LLM_UNAVAILABLE,
37
+ ]);
38
+ /**
39
+ * LLM errors that are NOT retryable (permanent failures).
40
+ * Orchestrators should not retry these.
41
+ */
42
+ export const NON_RETRYABLE_LLM_ERRORS = new Set([
43
+ LLM_REFUSAL,
44
+ LLM_INVALID_OUTPUT,
45
+ LLM_TOKEN_LIMIT,
46
+ ]);
47
+ // ============================================================================
48
+ // External Event Error Constants
49
+ // ============================================================================
50
+ /** External event timed out */
51
+ export const EVENT_TIMEOUT = 'event-timeout';
52
+ /** External system unavailable */
53
+ export const EVENT_UNAVAILABLE = 'event-unavailable';
54
+ /** External system rejected request */
55
+ export const EVENT_REJECTED = 'event-rejected';
56
+ /** External system returned invalid response */
57
+ export const EVENT_INVALID_RESPONSE = 'event-invalid-response';
58
+ /**
59
+ * External event errors that are retryable (transient failures).
60
+ * Orchestrators should retry these with exponential backoff.
61
+ */
62
+ export const RETRYABLE_EVENT_ERRORS = new Set([
63
+ EVENT_TIMEOUT,
64
+ EVENT_UNAVAILABLE,
65
+ ]);
66
+ /**
67
+ * External event errors that are NOT retryable (permanent failures).
68
+ * Orchestrators should not retry these.
69
+ */
70
+ export const NON_RETRYABLE_EVENT_ERRORS = new Set([
71
+ EVENT_REJECTED,
72
+ EVENT_INVALID_RESPONSE,
73
+ ]);
74
+ // ============================================================================
75
+ // Result Constructors
76
+ // ============================================================================
77
+ /**
78
+ * Internal helper to build observability fields object.
79
+ * Reduces duplication across result constructors.
80
+ *
81
+ * @internal
82
+ */
83
+ function buildObservabilityFields(options) {
84
+ const fields = {};
85
+ if (options?.confidence !== undefined) {
86
+ fields.confidence = options.confidence;
87
+ }
88
+ if (options?.warnings) {
89
+ fields.warnings = options.warnings;
90
+ }
91
+ if (options?.execution) {
92
+ fields.execution = options.execution;
93
+ }
94
+ return fields;
95
+ }
96
+ /**
97
+ * Create a success result with optional observability fields.
98
+ *
99
+ * @example
100
+ * return createSuccess({ name: 'Fluffy', valid: true });
101
+ *
102
+ * @example
103
+ * return createSuccess(data, {
104
+ * confidence: 0.95,
105
+ * warnings: ['Unusual pattern detected'],
106
+ * });
107
+ */
108
+ export function createSuccess(data, options) {
109
+ return {
110
+ status: RESULT_SUCCESS,
111
+ data,
112
+ ...buildObservabilityFields(options),
113
+ };
114
+ }
115
+ /**
116
+ * Create an error result with optional observability fields.
117
+ *
118
+ * @example
119
+ * return createError('invalid-format');
120
+ *
121
+ * @example
122
+ * return createError(LLM_TIMEOUT, {
123
+ * confidence: 0.9,
124
+ * execution: { durationMs: 5000 },
125
+ * });
126
+ */
127
+ export function createError(error, options) {
128
+ return {
129
+ status: RESULT_ERROR,
130
+ error,
131
+ ...buildObservabilityFields(options),
132
+ };
133
+ }
134
+ /**
135
+ * Create an in-progress result for stateful agents with optional observability fields.
136
+ *
137
+ * @example
138
+ * return createInProgress({ step: 2, totalSteps: 5 });
139
+ *
140
+ * @example
141
+ * return createInProgress(undefined, {
142
+ * confidence: 0.7,
143
+ * warnings: ['Still gathering information'],
144
+ * });
145
+ */
146
+ export function createInProgress(metadata, options) {
147
+ return {
148
+ status: RESULT_IN_PROGRESS,
149
+ ...(metadata !== undefined && { metadata }),
150
+ ...buildObservabilityFields(options),
151
+ };
152
+ }
153
+ //# sourceMappingURL=result-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result-types.js","sourceRoot":"","sources":["../src/result-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E,8BAA8B;AAC9B,MAAM,CAAC,MAAM,cAAc,GAAG,SAAkB,CAAC;AAEjD,4BAA4B;AAC5B,MAAM,CAAC,MAAM,YAAY,GAAG,OAAgB,CAAC;AAE7C,wDAAwD;AACxD,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAsB,CAAC;AASzD,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAE/E,gEAAgE;AAChE,MAAM,CAAC,MAAM,WAAW,GAAG,aAAsB,CAAC;AAElD,+DAA+D;AAC/D,MAAM,CAAC,MAAM,kBAAkB,GAAG,oBAA6B,CAAC;AAEhE,wBAAwB;AACxB,MAAM,CAAC,MAAM,WAAW,GAAG,aAAsB,CAAC;AAElD,qBAAqB;AACrB,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAyB,CAAC;AAExD,2BAA2B;AAC3B,MAAM,CAAC,MAAM,eAAe,GAAG,iBAA0B,CAAC;AAE1D,0BAA0B;AAC1B,MAAM,CAAC,MAAM,eAAe,GAAG,iBAA0B,CAAC;AAiB1D;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAW;IACpD,WAAW;IACX,cAAc;IACd,eAAe;CAChB,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAW;IACxD,WAAW;IACX,kBAAkB;IAClB,eAAe;CAChB,CAAC,CAAC;AAEH,+EAA+E;AAC/E,iCAAiC;AACjC,+EAA+E;AAE/E,+BAA+B;AAC/B,MAAM,CAAC,MAAM,aAAa,GAAG,eAAwB,CAAC;AAEtD,kCAAkC;AACl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AAC,OAAO,CAAC;KACrC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAC9B,QAAoB,EACpB,OAIC;IAED,OAAO;QACL,MAAM,EAAE,kBAAkB;QAC1B,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,EAAE,QAAQ,EAAE,CAAC;QAC3C,GAAG,wBAAwB,CAAC,OAAO,CAAC;KACrC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * JSON Schema utilities
3
+ *
4
+ * Provides convenience functions for converting Zod schemas to JSON Schema
5
+ * with vibe-agent-toolkit conventions and enhancements.
6
+ */
7
+ import type { ZodSchema } from 'zod';
8
+ import { type Options } from 'zod-to-json-schema';
9
+ /**
10
+ * Options for JSON Schema generation
11
+ *
12
+ * Extends zod-to-json-schema options with toolkit-specific enhancements
13
+ */
14
+ export interface JsonSchemaOptions extends Partial<Options> {
15
+ /**
16
+ * Include toolkit version metadata in the generated schema
17
+ * Adds x-vat-version field to the schema root
18
+ *
19
+ * @default false
20
+ */
21
+ includeToolkitMetadata?: boolean;
22
+ /**
23
+ * Override the JSON Schema draft version
24
+ *
25
+ * @default "https://json-schema.org/draft/2020-12/schema"
26
+ */
27
+ $schema?: string;
28
+ }
29
+ /**
30
+ * Convert Zod schema to JSON Schema with vibe-agent-toolkit conventions
31
+ *
32
+ * This function wraps zod-to-json-schema with sensible defaults and
33
+ * toolkit-specific enhancements:
34
+ *
35
+ * - Sets $schema to JSON Schema Draft 2020-12 by default
36
+ * - Uses inline refs (no $ref strategy) for simpler schemas
37
+ * - Optionally injects toolkit version metadata
38
+ * - Provides a stable interface for future enhancements
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * import { z } from 'zod';
43
+ * import { toJsonSchema } from '@vibe-agent-toolkit/agent-schema';
44
+ *
45
+ * const MySchema = z.object({
46
+ * name: z.string().describe('User name'),
47
+ * age: z.number().min(0),
48
+ * });
49
+ *
50
+ * const jsonSchema = toJsonSchema(MySchema, {
51
+ * name: 'my-schema',
52
+ * includeToolkitMetadata: true,
53
+ * });
54
+ * ```
55
+ *
56
+ * @param schema - Zod schema to convert
57
+ * @param options - Conversion options
58
+ * @returns JSON Schema object
59
+ */
60
+ export declare function toJsonSchema(schema: ZodSchema, options?: JsonSchemaOptions): object;
61
+ //# sourceMappingURL=schema-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-utils.d.ts","sourceRoot":"","sources":["../src/schema-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AACrC,OAAO,EAAmB,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAEnE;;;;GAIG;AACH,MAAM,WAAW,iBAAkB,SAAQ,OAAO,CAAC,OAAO,CAAC;IACzD;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,MAAM,CAuBnF"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * JSON Schema utilities
3
+ *
4
+ * Provides convenience functions for converting Zod schemas to JSON Schema
5
+ * with vibe-agent-toolkit conventions and enhancements.
6
+ */
7
+ import { zodToJsonSchema } from 'zod-to-json-schema';
8
+ /**
9
+ * Convert Zod schema to JSON Schema with vibe-agent-toolkit conventions
10
+ *
11
+ * This function wraps zod-to-json-schema with sensible defaults and
12
+ * toolkit-specific enhancements:
13
+ *
14
+ * - Sets $schema to JSON Schema Draft 2020-12 by default
15
+ * - Uses inline refs (no $ref strategy) for simpler schemas
16
+ * - Optionally injects toolkit version metadata
17
+ * - Provides a stable interface for future enhancements
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * import { z } from 'zod';
22
+ * import { toJsonSchema } from '@vibe-agent-toolkit/agent-schema';
23
+ *
24
+ * const MySchema = z.object({
25
+ * name: z.string().describe('User name'),
26
+ * age: z.number().min(0),
27
+ * });
28
+ *
29
+ * const jsonSchema = toJsonSchema(MySchema, {
30
+ * name: 'my-schema',
31
+ * includeToolkitMetadata: true,
32
+ * });
33
+ * ```
34
+ *
35
+ * @param schema - Zod schema to convert
36
+ * @param options - Conversion options
37
+ * @returns JSON Schema object
38
+ */
39
+ export function toJsonSchema(schema, options) {
40
+ const { includeToolkitMetadata = false, $schema: schemaVersion = 'https://json-schema.org/draft/2020-12/schema', ...zodOptions } = options ?? {};
41
+ // Convert with default strategy: inline refs for simplicity
42
+ const jsonSchema = zodToJsonSchema(schema, {
43
+ $refStrategy: 'none',
44
+ ...zodOptions,
45
+ });
46
+ // Override $schema to ensure our standard version
47
+ jsonSchema['$schema'] = schemaVersion;
48
+ // Optional: Add toolkit metadata
49
+ if (includeToolkitMetadata) {
50
+ // NOTE: Version hardcoded until it becomes meaningful for adopters
51
+ jsonSchema['x-vat-version'] = '0.1.1';
52
+ }
53
+ return jsonSchema;
54
+ }
55
+ //# sourceMappingURL=schema-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-utils.js","sourceRoot":"","sources":["../src/schema-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,eAAe,EAAgB,MAAM,oBAAoB,CAAC;AAwBnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,UAAU,YAAY,CAAC,MAAiB,EAAE,OAA2B;IACzE,MAAM,EACJ,sBAAsB,GAAG,KAAK,EAC9B,OAAO,EAAE,aAAa,GAAG,8CAA8C,EACvE,GAAG,UAAU,EACd,GAAG,OAAO,IAAI,EAAE,CAAC;IAElB,4DAA4D;IAC5D,MAAM,UAAU,GAAG,eAAe,CAAC,MAAM,EAAE;QACzC,YAAY,EAAE,MAAM;QACpB,GAAG,UAAU;KACd,CAA4B,CAAC;IAE9B,kDAAkD;IAClD,UAAU,CAAC,SAAS,CAAC,GAAG,aAAa,CAAC;IAEtC,iCAAiC;IACjC,IAAI,sBAAsB,EAAE,CAAC;QAC3B,mEAAmE;QACnE,UAAU,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC;IACxC,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibe-agent-toolkit/agent-schema",
3
- "version": "0.1.1",
3
+ "version": "0.1.2-rc.3",
4
4
  "description": "JSON Schema definitions and TypeScript types for VAT agent manifest format",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -37,7 +37,7 @@
37
37
  "zod-to-json-schema": "^3.23.5"
38
38
  },
39
39
  "devDependencies": {
40
- "@vibe-agent-toolkit/utils": "0.1.1",
40
+ "@vibe-agent-toolkit/utils": "0.1.2-rc.3",
41
41
  "tsx": "^4.21.0",
42
42
  "typescript": "^5.9.3",
43
43
  "vitest": "^3.2.4"