@ai-dev-orchestrator/schemas 0.1.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 (103) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +51 -0
  3. package/dist/artifacts/agreement-artifacts.d.ts +311 -0
  4. package/dist/artifacts/agreement-artifacts.js +48 -0
  5. package/dist/artifacts/artifact-dependency-graph.d.ts +775 -0
  6. package/dist/artifacts/artifact-dependency-graph.js +57 -0
  7. package/dist/artifacts/artifact-system.d.ts +657 -0
  8. package/dist/artifacts/artifact-system.js +124 -0
  9. package/dist/artifacts/index.d.ts +3 -0
  10. package/dist/artifacts/index.js +3 -0
  11. package/dist/config/configuration.d.ts +324 -0
  12. package/dist/config/configuration.js +93 -0
  13. package/dist/config/event-bus-config.d.ts +153 -0
  14. package/dist/config/event-bus-config.js +27 -0
  15. package/dist/config/event-payloads.d.ts +919 -0
  16. package/dist/config/event-payloads.js +304 -0
  17. package/dist/config/event-system.d.ts +3231 -0
  18. package/dist/config/event-system.js +428 -0
  19. package/dist/config/event-types.d.ts +62 -0
  20. package/dist/config/event-types.js +66 -0
  21. package/dist/config/index.d.ts +5 -0
  22. package/dist/config/index.js +5 -0
  23. package/dist/dashboard/dashboard-api.d.ts +149 -0
  24. package/dist/dashboard/dashboard-api.js +80 -0
  25. package/dist/dashboard/dashboard-domain.d.ts +1076 -0
  26. package/dist/dashboard/dashboard-domain.js +305 -0
  27. package/dist/dashboard/index.d.ts +3 -0
  28. package/dist/dashboard/index.js +3 -0
  29. package/dist/dashboard/run-creation-params.d.ts +111 -0
  30. package/dist/dashboard/run-creation-params.js +14 -0
  31. package/dist/governance/governance.d.ts +1119 -0
  32. package/dist/governance/governance.js +111 -0
  33. package/dist/governance/index.d.ts +3 -0
  34. package/dist/governance/index.js +3 -0
  35. package/dist/governance/policy-engine.d.ts +634 -0
  36. package/dist/governance/policy-engine.js +214 -0
  37. package/dist/governance/review-resolution.d.ts +1053 -0
  38. package/dist/governance/review-resolution.js +67 -0
  39. package/dist/index.d.ts +10 -0
  40. package/dist/index.js +10 -0
  41. package/dist/observability/diagnostics.d.ts +185 -0
  42. package/dist/observability/diagnostics.js +63 -0
  43. package/dist/observability/index.d.ts +2 -0
  44. package/dist/observability/index.js +2 -0
  45. package/dist/observability/metrics.d.ts +187 -0
  46. package/dist/observability/metrics.js +67 -0
  47. package/dist/persistence/execution-analytics.d.ts +173 -0
  48. package/dist/persistence/execution-analytics.js +71 -0
  49. package/dist/persistence/index.d.ts +5 -0
  50. package/dist/persistence/index.js +5 -0
  51. package/dist/persistence/project-context.d.ts +164 -0
  52. package/dist/persistence/project-context.js +88 -0
  53. package/dist/persistence/repository-model.d.ts +27 -0
  54. package/dist/persistence/repository-model.js +16 -0
  55. package/dist/persistence/run-manifest.d.ts +422 -0
  56. package/dist/persistence/run-manifest.js +118 -0
  57. package/dist/persistence/state-persistence.d.ts +276 -0
  58. package/dist/persistence/state-persistence.js +83 -0
  59. package/dist/runner/built-in-runner-ids.d.ts +8 -0
  60. package/dist/runner/built-in-runner-ids.js +11 -0
  61. package/dist/runner/collaboration-model.d.ts +100 -0
  62. package/dist/runner/collaboration-model.js +19 -0
  63. package/dist/runner/confidence.d.ts +17 -0
  64. package/dist/runner/confidence.js +11 -0
  65. package/dist/runner/index.d.ts +8 -0
  66. package/dist/runner/index.js +8 -0
  67. package/dist/runner/permission-approval.d.ts +38 -0
  68. package/dist/runner/permission-approval.js +14 -0
  69. package/dist/runner/prompt-engine.d.ts +1467 -0
  70. package/dist/runner/prompt-engine.js +193 -0
  71. package/dist/runner/role-system.d.ts +458 -0
  72. package/dist/runner/role-system.js +94 -0
  73. package/dist/runner/runner-system.d.ts +1721 -0
  74. package/dist/runner/runner-system.js +268 -0
  75. package/dist/runner/task-brief.d.ts +18 -0
  76. package/dist/runner/task-brief.js +12 -0
  77. package/dist/shared/index.d.ts +3 -0
  78. package/dist/shared/index.js +3 -0
  79. package/dist/shared/shared.d.ts +30 -0
  80. package/dist/shared/shared.js +27 -0
  81. package/dist/shared/string-enums.d.ts +59 -0
  82. package/dist/shared/string-enums.js +24 -0
  83. package/dist/shared/utils.d.ts +25 -0
  84. package/dist/shared/utils.js +22 -0
  85. package/dist/specification/canonical-specification.d.ts +475 -0
  86. package/dist/specification/canonical-specification.js +151 -0
  87. package/dist/specification/index.d.ts +3 -0
  88. package/dist/specification/index.js +3 -0
  89. package/dist/specification/intake.d.ts +419 -0
  90. package/dist/specification/intake.js +70 -0
  91. package/dist/specification/iteration-contracts.d.ts +421 -0
  92. package/dist/specification/iteration-contracts.js +61 -0
  93. package/dist/workflow/index.d.ts +4 -0
  94. package/dist/workflow/index.js +4 -0
  95. package/dist/workflow/workflow-dsl.d.ts +81 -0
  96. package/dist/workflow/workflow-dsl.js +38 -0
  97. package/dist/workflow/workflow-engine.d.ts +5788 -0
  98. package/dist/workflow/workflow-engine.js +414 -0
  99. package/dist/workflow/workflow-file.d.ts +331 -0
  100. package/dist/workflow/workflow-file.js +41 -0
  101. package/dist/workflow/workflow-journal.d.ts +520 -0
  102. package/dist/workflow/workflow-journal.js +151 -0
  103. package/package.json +39 -0
@@ -0,0 +1,268 @@
1
+ import { z } from 'zod/v4';
2
+ import { artifactRefSchema, artifactTypeSchema } from '../artifacts/artifact-system';
3
+ import { findingSchema } from '../governance/review-resolution';
4
+ import { runIdSchema } from '../shared/shared';
5
+ import { outputFormatSchema, sessionTransportSchema, threeTierSeveritySchema, } from '../shared/string-enums';
6
+ import { agentConfigSchema, modelAssignmentSchema, roleContractSchema, roleIdSchema, } from './role-system';
7
+ // ---------------------------------------------------------------------------
8
+ // Agent session types
9
+ // ---------------------------------------------------------------------------
10
+ export const agentSessionStateSchema = z.enum([
11
+ 'running',
12
+ 'awaiting_human',
13
+ 'paused',
14
+ 'reconnecting',
15
+ 'completed',
16
+ 'failed',
17
+ 'aborted',
18
+ 'orphaned',
19
+ ]);
20
+ export const agentSessionRefSchema = z.object({
21
+ sessionId: z.string(),
22
+ runId: z.string(),
23
+ stateId: z.string(),
24
+ role: roleIdSchema,
25
+ transport: sessionTransportSchema,
26
+ });
27
+ export const permissionPayloadSchema = z
28
+ .object({
29
+ action: z.string(),
30
+ resource: z.string(),
31
+ detail: z.string().optional(),
32
+ riskLevel: threeTierSeveritySchema.optional(),
33
+ externalRequestId: z.string().optional(),
34
+ toolInput: z.string().optional(),
35
+ granted: z.boolean().optional(),
36
+ reason: z.string().optional(),
37
+ timedOut: z.boolean().optional(),
38
+ aborted: z.boolean().optional(),
39
+ })
40
+ .catchall(z.unknown());
41
+ export const clarificationPayloadSchema = z
42
+ .object({
43
+ question: z.string(),
44
+ context: z.string().optional(),
45
+ options: z.array(z.string()).readonly().optional(),
46
+ answer: z.string().optional(),
47
+ })
48
+ .catchall(z.unknown());
49
+ export const sessionPendingRequestSchema = z.discriminatedUnion('kind', [
50
+ z.object({
51
+ requestId: z.string(),
52
+ kind: z.literal('permission'),
53
+ createdAt: z.string(),
54
+ payload: permissionPayloadSchema,
55
+ }),
56
+ z.object({
57
+ requestId: z.string(),
58
+ kind: z.literal('clarification'),
59
+ createdAt: z.string(),
60
+ payload: clarificationPayloadSchema,
61
+ }),
62
+ ]);
63
+ export const stdioReconnectMetaSchema = z.object({
64
+ type: z.literal('stdio'),
65
+ pid: z.number(),
66
+ socketPath: z.string().optional(),
67
+ });
68
+ export const remoteReconnectMetaSchema = z.object({
69
+ type: z.literal('remote'),
70
+ remoteSessionId: z.string(),
71
+ reconnectUrl: z.string(),
72
+ websocketUrl: z.string().optional(),
73
+ leaseExpiresAt: z.string().optional(),
74
+ heartbeatIntervalMs: z.number().optional(),
75
+ authHeader: z.string().optional(),
76
+ });
77
+ export const reconnectMetaSchema = z.discriminatedUnion('type', [
78
+ stdioReconnectMetaSchema,
79
+ remoteReconnectMetaSchema,
80
+ ]);
81
+ export const agentSessionSnapshotSchema = z.object({
82
+ ref: agentSessionRefSchema,
83
+ state: agentSessionStateSchema,
84
+ pendingRequests: z.array(sessionPendingRequestSchema).readonly(),
85
+ lastProtocolTimestamp: z.string(),
86
+ reconnect: reconnectMetaSchema.optional(),
87
+ createdAt: z.string(),
88
+ updatedAt: z.string(),
89
+ expiresAt: z.string().optional(),
90
+ workerId: z.string().optional(),
91
+ error: z.string().optional(),
92
+ });
93
+ export const agentSessionHandleSchema = z.object({
94
+ ref: agentSessionRefSchema,
95
+ state: agentSessionStateSchema,
96
+ pendingRequests: z.array(sessionPendingRequestSchema).readonly(),
97
+ });
98
+ export const sessionDispatchOutcomeSchema = z.enum([
99
+ 'completed',
100
+ 'awaiting_human',
101
+ 'session_active',
102
+ ]);
103
+ // ---------------------------------------------------------------------------
104
+ // Main runner-system types
105
+ // ---------------------------------------------------------------------------
106
+ export const resolvedArtifactSchema = z.object({
107
+ ref: artifactRefSchema,
108
+ content: z.string(),
109
+ });
110
+ export const workerOutputFormatSchema = outputFormatSchema;
111
+ export const workerConstraintsSchema = z.object({
112
+ maxOutputTokens: z.number(),
113
+ timeout: z.number(),
114
+ requiredOutputType: artifactTypeSchema,
115
+ outputSchema: z.record(z.string(), z.unknown()).optional(),
116
+ outputFormat: workerOutputFormatSchema.optional(),
117
+ });
118
+ export const dispatchOverridesSchema = z.object({
119
+ model: modelAssignmentSchema.optional(),
120
+ timeout: z.number().optional(),
121
+ maxRetries: z.number().optional(),
122
+ });
123
+ export const dispatchRequestSchema = z.object({
124
+ runId: runIdSchema,
125
+ stateId: z.string(),
126
+ role: roleIdSchema,
127
+ inputArtifacts: z.array(artifactRefSchema).readonly(),
128
+ overrides: dispatchOverridesSchema.optional(),
129
+ humanFeedback: z.string().optional(),
130
+ userPrompt: z.string().optional(),
131
+ previousReviewContent: z.string().optional(),
132
+ structuredFindings: z.array(findingSchema).readonly().optional(),
133
+ iterationCount: z.number().optional(),
134
+ variableOverrides: z.record(z.string(), z.string()).optional(),
135
+ });
136
+ export const workerErrorTypeSchema = z.enum([
137
+ 'agent_error',
138
+ 'timeout',
139
+ 'invalid_output',
140
+ 'schema_violation',
141
+ 'ownership_violation',
142
+ 'cancelled',
143
+ ]);
144
+ export const workerErrorSchema = z.object({
145
+ type: workerErrorTypeSchema,
146
+ message: z.string(),
147
+ retryable: z.boolean(),
148
+ });
149
+ export const workerMetricsSchema = z.object({
150
+ startedAt: z.string(),
151
+ completedAt: z.string(),
152
+ durationMs: z.number(),
153
+ inputTokens: z.number(),
154
+ outputTokens: z.number(),
155
+ retryCount: z.number(),
156
+ modelUsed: z.string(),
157
+ });
158
+ export const dispatchStatusSchema = z.enum(['success', 'failure', 'timeout', 'cancelled']);
159
+ export const dispatchResultSchema = z.object({
160
+ workerId: z.string(),
161
+ role: roleIdSchema,
162
+ status: dispatchStatusSchema,
163
+ outputArtifacts: z.array(artifactRefSchema).readonly(),
164
+ error: workerErrorSchema.optional(),
165
+ metrics: workerMetricsSchema,
166
+ sessionOutcome: sessionDispatchOutcomeSchema.optional(),
167
+ sessionRef: agentSessionRefSchema.optional(),
168
+ pendingRequest: sessionPendingRequestSchema.optional(),
169
+ });
170
+ export const workerStatusSchema = z.object({
171
+ workerId: z.string(),
172
+ role: roleIdSchema,
173
+ state: z.enum(['pending', 'running', 'completed', 'failed', 'timed-out']),
174
+ startedAt: z.string(),
175
+ elapsedMs: z.number(),
176
+ });
177
+ export const workerContextSchema = z.object({
178
+ role: roleContractSchema,
179
+ prompt: z.string(),
180
+ inputArtifacts: z.array(resolvedArtifactSchema).readonly(),
181
+ modelAssignment: modelAssignmentSchema,
182
+ constraints: workerConstraintsSchema,
183
+ });
184
+ export const workerInvocationRecordSchema = z.object({
185
+ timestamp: z.string(),
186
+ runId: runIdSchema,
187
+ workerId: z.string(),
188
+ stateId: z.string(),
189
+ role: roleIdSchema,
190
+ model: z.string(),
191
+ inputArtifacts: z.array(artifactRefSchema).readonly(),
192
+ outputArtifacts: z.array(artifactRefSchema).readonly(),
193
+ status: dispatchStatusSchema,
194
+ metrics: workerMetricsSchema,
195
+ error: workerErrorSchema.optional(),
196
+ });
197
+ export const retryPolicySchema = z.object({
198
+ maxRetries: z.number(),
199
+ initialDelayMs: z.number(),
200
+ maxDelayMs: z.number(),
201
+ backoffMultiplier: z.number(),
202
+ });
203
+ // ---------------------------------------------------------------------------
204
+ // Agent types
205
+ // ---------------------------------------------------------------------------
206
+ export const agentConstraintsSchema = z.object({
207
+ timeout: z.number(),
208
+ requiredOutputType: artifactTypeSchema,
209
+ outputSchema: z.record(z.string(), z.unknown()).optional(),
210
+ outputFormat: workerOutputFormatSchema.optional(),
211
+ });
212
+ export const agentTaskSchema = z.object({
213
+ taskId: z.string(),
214
+ runId: z.string(),
215
+ stateId: z.string(),
216
+ role: roleIdSchema,
217
+ description: z.string(),
218
+ inputArtifacts: z.array(resolvedArtifactSchema).readonly(),
219
+ repoRoot: z.string(),
220
+ runDir: z.string(),
221
+ outputArtifactPath: z.string(),
222
+ constraints: agentConstraintsSchema,
223
+ instructions: z.string().optional(),
224
+ rolePrompt: z.string().optional(),
225
+ agentConfig: agentConfigSchema.optional(),
226
+ modelHint: z.string().optional(),
227
+ humanFeedback: z.string().optional(),
228
+ userPrompt: z.string().optional(),
229
+ previousFindings: z.string().optional(),
230
+ iterationCount: z.number().optional(),
231
+ });
232
+ export const agentTokenUsageSchema = z.object({
233
+ inputTokens: z.number(),
234
+ outputTokens: z.number(),
235
+ });
236
+ export const agentResultSchema = z.object({
237
+ taskId: z.string(),
238
+ status: z.enum(['success', 'failure', 'timeout']),
239
+ artifactContent: z.string().optional(),
240
+ error: z.string().optional(),
241
+ durationMs: z.number(),
242
+ tokenUsage: agentTokenUsageSchema.optional(),
243
+ });
244
+ // ---------------------------------------------------------------------------
245
+ // Live response payload schemas (for human-in-the-loop responses)
246
+ // ---------------------------------------------------------------------------
247
+ export const livePermissionResponsePayloadSchema = z
248
+ .object({
249
+ granted: z.boolean().optional(),
250
+ reason: z.string().optional(),
251
+ })
252
+ .loose();
253
+ export const liveClarificationResponsePayloadSchema = z
254
+ .object({
255
+ answer: z.string().optional(),
256
+ })
257
+ .loose();
258
+ // ---------------------------------------------------------------------------
259
+ // HTTP agent runner response schemas
260
+ // ---------------------------------------------------------------------------
261
+ export const submitResponseSchema = z.object({ taskId: z.string() }).loose();
262
+ export const pollResponseSchema = z
263
+ .object({
264
+ status: z.enum(['running', 'completed', 'failed']),
265
+ result: agentResultSchema.optional(),
266
+ error: z.string().optional(),
267
+ })
268
+ .loose();
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod/v4';
2
+ export declare const successCriterionSchema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ description: z.ZodString;
5
+ verifiable: z.ZodBoolean;
6
+ }, z.core.$strip>;
7
+ export type SuccessCriterion = z.infer<typeof successCriterionSchema>;
8
+ export declare const taskBriefSchema: z.ZodObject<{
9
+ what: z.ZodString;
10
+ why: z.ZodString;
11
+ how: z.ZodOptional<z.ZodString>;
12
+ successCriteria: z.ZodArray<z.ZodObject<{
13
+ id: z.ZodString;
14
+ description: z.ZodString;
15
+ verifiable: z.ZodBoolean;
16
+ }, z.core.$strip>>;
17
+ }, z.core.$strip>;
18
+ export type TaskBrief = z.infer<typeof taskBriefSchema>;
@@ -0,0 +1,12 @@
1
+ import { z } from 'zod/v4';
2
+ export const successCriterionSchema = z.object({
3
+ id: z.string(),
4
+ description: z.string(),
5
+ verifiable: z.boolean(),
6
+ });
7
+ export const taskBriefSchema = z.object({
8
+ what: z.string(),
9
+ why: z.string(),
10
+ how: z.string().optional(),
11
+ successCriteria: z.array(successCriterionSchema).min(1),
12
+ });
@@ -0,0 +1,3 @@
1
+ export * from './shared';
2
+ export * from './string-enums';
3
+ export * from './utils';
@@ -0,0 +1,3 @@
1
+ export * from './shared';
2
+ export * from './string-enums';
3
+ export * from './utils';
@@ -0,0 +1,30 @@
1
+ import { z } from 'zod/v4';
2
+ export declare const AI_CONFIG_DIR_NAME = ".ai";
3
+ export declare const RUNS_DIR_NAME = "runs";
4
+ export declare const ARTIFACTS_DIR_NAME = "artifacts";
5
+ export declare const VIDEOS_DIR_NAME = "videos";
6
+ export declare const TMP_DIR_NAME = "tmp";
7
+ export declare const RUN_LOCK_FILENAME = "run.lock";
8
+ export declare const STATE_FILENAME = "state.yaml";
9
+ export declare const INVENTORY_FILENAME = "inventory.yaml";
10
+ export declare const WORKFLOW_DEFINITION_FILENAME = "workflow-definition.json";
11
+ export declare const MEDIA_FILE_EXTENSIONS: readonly [".webm", ".mp4", ".png", ".jpg", ".jpeg", ".gif"];
12
+ export type MediaFileExtension = (typeof MEDIA_FILE_EXTENSIONS)[number];
13
+ export declare const MEDIA_MIME_TYPES: Readonly<Record<string, string>>;
14
+ export declare const runIdSchema: z.core.$ZodBranded<z.ZodString, "RunId", "out">;
15
+ export type RunId = z.infer<typeof runIdSchema>;
16
+ export declare const workerIdSchema: z.core.$ZodBranded<z.ZodString, "WorkerId", "out">;
17
+ export type WorkerId = z.infer<typeof workerIdSchema>;
18
+ /**
19
+ * Result type for expected failures in domain/application layers.
20
+ * Cannot be expressed as a Zod schema due to generics -- hand-written.
21
+ */
22
+ export type Result<T, E extends Error = Error> = {
23
+ readonly ok: true;
24
+ readonly value: T;
25
+ } | {
26
+ readonly ok: false;
27
+ readonly error: E;
28
+ };
29
+ export declare function ok<T>(value: T): Result<T, never>;
30
+ export declare function err<E extends Error>(error: E): Result<never, E>;
@@ -0,0 +1,27 @@
1
+ import { z } from 'zod/v4';
2
+ export const AI_CONFIG_DIR_NAME = '.ai';
3
+ export const RUNS_DIR_NAME = 'runs';
4
+ export const ARTIFACTS_DIR_NAME = 'artifacts';
5
+ export const VIDEOS_DIR_NAME = 'videos';
6
+ export const TMP_DIR_NAME = 'tmp';
7
+ export const RUN_LOCK_FILENAME = 'run.lock';
8
+ export const STATE_FILENAME = 'state.yaml';
9
+ export const INVENTORY_FILENAME = 'inventory.yaml';
10
+ export const WORKFLOW_DEFINITION_FILENAME = 'workflow-definition.json';
11
+ export const MEDIA_FILE_EXTENSIONS = ['.webm', '.mp4', '.png', '.jpg', '.jpeg', '.gif'];
12
+ export const MEDIA_MIME_TYPES = {
13
+ '.webm': 'video/webm',
14
+ '.mp4': 'video/mp4',
15
+ '.png': 'image/png',
16
+ '.jpg': 'image/jpeg',
17
+ '.jpeg': 'image/jpeg',
18
+ '.gif': 'image/gif',
19
+ };
20
+ export const runIdSchema = z.string().brand('RunId');
21
+ export const workerIdSchema = z.string().brand('WorkerId');
22
+ export function ok(value) {
23
+ return { ok: true, value };
24
+ }
25
+ export function err(error) {
26
+ return { ok: false, error };
27
+ }
@@ -0,0 +1,59 @@
1
+ import { z } from 'zod/v4';
2
+ export declare const threeTierSeveritySchema: z.ZodEnum<{
3
+ high: "high";
4
+ medium: "medium";
5
+ low: "low";
6
+ }>;
7
+ export type ThreeTierSeverity = z.infer<typeof threeTierSeveritySchema>;
8
+ export declare const sessionTransportSchema: z.ZodEnum<{
9
+ stdio: "stdio";
10
+ remote: "remote";
11
+ }>;
12
+ export type SessionTransport = z.infer<typeof sessionTransportSchema>;
13
+ export declare const liveRequestKindSchema: z.ZodEnum<{
14
+ permission: "permission";
15
+ clarification: "clarification";
16
+ }>;
17
+ export type LiveRequestKind = z.infer<typeof liveRequestKindSchema>;
18
+ export declare const readinessVerdictSchema: z.ZodEnum<{
19
+ Ready: "Ready";
20
+ NotReady: "NotReady";
21
+ }>;
22
+ export type ReadinessVerdict = z.infer<typeof readinessVerdictSchema>;
23
+ export declare const outputFormatSchema: z.ZodEnum<{
24
+ markdown_with_frontmatter: "markdown_with_frontmatter";
25
+ yaml: "yaml";
26
+ json: "json";
27
+ freeform: "freeform";
28
+ }>;
29
+ export type OutputFormat = z.infer<typeof outputFormatSchema>;
30
+ export declare const agentStreamEventTypeSchema: z.ZodEnum<{
31
+ stdout: "stdout";
32
+ stderr: "stderr";
33
+ status: "status";
34
+ permission_request: "permission_request";
35
+ clarification_request: "clarification_request";
36
+ }>;
37
+ export type AgentStreamEventType = z.infer<typeof agentStreamEventTypeSchema>;
38
+ export declare const roleTrustLevelSchema: z.ZodEnum<{
39
+ high: "high";
40
+ medium: "medium";
41
+ none: "none";
42
+ }>;
43
+ export type RoleTrustLevel = z.infer<typeof roleTrustLevelSchema>;
44
+ export declare const permissionActionSchema: z.ZodEnum<{
45
+ file_read: "file_read";
46
+ file_write: "file_write";
47
+ file_delete: "file_delete";
48
+ shell_execute: "shell_execute";
49
+ network_request: "network_request";
50
+ git_operation: "git_operation";
51
+ custom: "custom";
52
+ }>;
53
+ export type PermissionAction = z.infer<typeof permissionActionSchema>;
54
+ export declare const permissionDecisionActionSchema: z.ZodEnum<{
55
+ grant: "grant";
56
+ deny: "deny";
57
+ ask_human: "ask_human";
58
+ }>;
59
+ export type PermissionDecisionAction = z.infer<typeof permissionDecisionActionSchema>;
@@ -0,0 +1,24 @@
1
+ import { z } from 'zod/v4';
2
+ export const threeTierSeveritySchema = z.enum(['high', 'medium', 'low']);
3
+ export const sessionTransportSchema = z.enum(['stdio', 'remote']);
4
+ export const liveRequestKindSchema = z.enum(['permission', 'clarification']);
5
+ export const readinessVerdictSchema = z.enum(['Ready', 'NotReady']);
6
+ export const outputFormatSchema = z.enum(['markdown_with_frontmatter', 'yaml', 'json', 'freeform']);
7
+ export const agentStreamEventTypeSchema = z.enum([
8
+ 'stdout',
9
+ 'stderr',
10
+ 'status',
11
+ 'permission_request',
12
+ 'clarification_request',
13
+ ]);
14
+ export const roleTrustLevelSchema = z.enum(['high', 'medium', 'none']);
15
+ export const permissionActionSchema = z.enum([
16
+ 'file_read',
17
+ 'file_write',
18
+ 'file_delete',
19
+ 'shell_execute',
20
+ 'network_request',
21
+ 'git_operation',
22
+ 'custom',
23
+ ]);
24
+ export const permissionDecisionActionSchema = z.enum(['grant', 'deny', 'ask_human']);
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Minimal schema interface for consumers that don't import Zod directly.
3
+ * Any Zod schema satisfies this interface. The type parameter `T` carries
4
+ * the parsed output type so callers get type-safe results without importing Zod.
5
+ */
6
+ export interface SchemaLike<T = unknown> {
7
+ safeParse(data: unknown): {
8
+ success: boolean;
9
+ data?: T;
10
+ error?: {
11
+ issues: unknown[];
12
+ };
13
+ };
14
+ }
15
+ /**
16
+ * Parse a JSON value with a Zod schema.
17
+ *
18
+ * Throws a `SchemaValidationError` when parsing fails instead of
19
+ * silently returning unvalidated data.
20
+ */
21
+ export declare function safeParseResponse<T>(schema: SchemaLike<T>, data: unknown): T;
22
+ export declare class SchemaValidationError extends Error {
23
+ readonly issues: unknown[];
24
+ constructor(issues: unknown[]);
25
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Parse a JSON value with a Zod schema.
3
+ *
4
+ * Throws a `SchemaValidationError` when parsing fails instead of
5
+ * silently returning unvalidated data.
6
+ */
7
+ export function safeParseResponse(schema, data) {
8
+ const result = schema.safeParse(data);
9
+ if (result.success && result.data !== undefined) {
10
+ return result.data;
11
+ }
12
+ const issues = result.error?.issues ?? [];
13
+ throw new SchemaValidationError(issues);
14
+ }
15
+ export class SchemaValidationError extends Error {
16
+ issues;
17
+ constructor(issues) {
18
+ super(`Schema validation failed: ${JSON.stringify(issues)}`);
19
+ this.name = 'SchemaValidationError';
20
+ this.issues = issues;
21
+ }
22
+ }