@sequenceholdings/agent-spec 0.1.1 → 0.1.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.
Files changed (72) hide show
  1. package/README.md +93 -0
  2. package/dist/agent-definition.d.ts +616 -0
  3. package/dist/agent-definition.js +240 -0
  4. package/dist/canonical-json.d.ts +2 -0
  5. package/dist/canonical-json.js +13 -0
  6. package/dist/index.d.ts +2 -117
  7. package/dist/index.js +2 -248
  8. package/dist/input-schema.d.ts +19 -0
  9. package/dist/input-schema.js +57 -0
  10. package/dist/voice-access.d.ts +40 -0
  11. package/dist/voice-access.js +34 -0
  12. package/dist/voice-actions-contracts.d.ts +423 -0
  13. package/dist/voice-actions-contracts.js +95 -0
  14. package/dist/voice-actions-transitions.d.ts +52 -0
  15. package/dist/voice-actions-transitions.js +170 -0
  16. package/dist/voice-actions.d.ts +2 -0
  17. package/dist/voice-actions.js +2 -0
  18. package/dist/voice-api.d.ts +1102 -0
  19. package/dist/voice-api.js +164 -0
  20. package/dist/voice-authoring.d.ts +463 -0
  21. package/dist/voice-authoring.js +132 -0
  22. package/dist/voice-authority-contracts.d.ts +247 -0
  23. package/dist/voice-authority-contracts.js +177 -0
  24. package/dist/voice-authority-evaluation.d.ts +29 -0
  25. package/dist/voice-authority-evaluation.js +80 -0
  26. package/dist/voice-authority-verification.d.ts +47 -0
  27. package/dist/voice-authority-verification.js +184 -0
  28. package/dist/voice-authority.d.ts +3 -0
  29. package/dist/voice-authority.js +3 -0
  30. package/dist/voice-common.d.ts +21 -0
  31. package/dist/voice-common.js +23 -0
  32. package/dist/voice-drafts.d.ts +441 -0
  33. package/dist/voice-drafts.js +75 -0
  34. package/dist/voice-grant.d.ts +19 -0
  35. package/dist/voice-grant.js +21 -0
  36. package/dist/voice-lifecycle-control.d.ts +130 -0
  37. package/dist/voice-lifecycle-control.js +138 -0
  38. package/dist/voice-lifecycle-session.d.ts +168 -0
  39. package/dist/voice-lifecycle-session.js +114 -0
  40. package/dist/voice-lifecycle-states.d.ts +96 -0
  41. package/dist/voice-lifecycle-states.js +139 -0
  42. package/dist/voice-lifecycle.d.ts +3 -0
  43. package/dist/voice-lifecycle.js +3 -0
  44. package/dist/voice-policy-duration.d.ts +46 -0
  45. package/dist/voice-policy-duration.js +166 -0
  46. package/dist/voice-policy-limits.d.ts +174 -0
  47. package/dist/voice-policy-limits.js +188 -0
  48. package/dist/voice-policy.d.ts +2 -0
  49. package/dist/voice-policy.js +2 -0
  50. package/dist/voice-provider-evidence.d.ts +80 -0
  51. package/dist/voice-provider-evidence.js +115 -0
  52. package/dist/voice-provider-publication.d.ts +319 -0
  53. package/dist/voice-provider-publication.js +117 -0
  54. package/dist/voice-provider-release.d.ts +386 -0
  55. package/dist/voice-provider-release.js +154 -0
  56. package/dist/voice-provider.d.ts +3 -0
  57. package/dist/voice-provider.js +3 -0
  58. package/dist/voice-release.d.ts +808 -0
  59. package/dist/voice-release.js +110 -0
  60. package/dist/voice-runs-audio.d.ts +157 -0
  61. package/dist/voice-runs-audio.js +85 -0
  62. package/dist/voice-runs-evidence.d.ts +183 -0
  63. package/dist/voice-runs-evidence.js +154 -0
  64. package/dist/voice-runs-model.d.ts +967 -0
  65. package/dist/voice-runs-model.js +199 -0
  66. package/dist/voice-runs-tooling.d.ts +88 -0
  67. package/dist/voice-runs-tooling.js +100 -0
  68. package/dist/voice-runs.d.ts +4 -0
  69. package/dist/voice-runs.js +4 -0
  70. package/dist/voice.d.ts +13 -0
  71. package/dist/voice.js +13 -0
  72. package/package.json +8 -3
@@ -0,0 +1,441 @@
1
+ import { z } from 'zod';
2
+ import { type VoiceAgentDefinition } from './agent-definition.js';
3
+ import { type CapturedVoiceProcedure } from './voice-authoring.js';
4
+ export declare const voiceDraftSchema: z.ZodObject<{
5
+ tenantId: z.ZodString;
6
+ environmentId: z.ZodString;
7
+ agentId: z.ZodString;
8
+ revision: z.ZodNumber;
9
+ definition: z.ZodObject<{
10
+ name: z.ZodString;
11
+ description: z.ZodOptional<z.ZodString>;
12
+ id: z.ZodString;
13
+ permissions: z.ZodOptional<z.ZodArray<z.ZodObject<{
14
+ type: z.ZodEnum<{
15
+ user: "user";
16
+ group: "group";
17
+ }>;
18
+ id: z.ZodString;
19
+ role: z.ZodEnum<{
20
+ owner: "owner";
21
+ editor: "editor";
22
+ invoker: "invoker";
23
+ outputs_viewer: "outputs_viewer";
24
+ }>;
25
+ }, z.core.$strip>>>;
26
+ mode: z.ZodLiteral<"voice">;
27
+ model: z.ZodObject<{
28
+ provider: z.ZodString;
29
+ name: z.ZodString;
30
+ }, z.core.$strict>;
31
+ systemPrompt: z.ZodString;
32
+ skills: z.ZodPipe<z.ZodDefault<z.ZodArray<z.ZodString>>, z.ZodTransform<string[], string[]>>;
33
+ voice: z.ZodPipe<z.ZodObject<{
34
+ schemaVersion: z.ZodLiteral<"1">;
35
+ voice: z.ZodString;
36
+ language: z.ZodString;
37
+ firstMessage: z.ZodString;
38
+ procedures: z.ZodDefault<z.ZodArray<z.ZodPipe<z.ZodObject<{
39
+ key: z.ZodString;
40
+ name: z.ZodString;
41
+ instructions: z.ZodString;
42
+ activationDescription: z.ZodString;
43
+ source: z.ZodObject<{
44
+ skillId: z.ZodString;
45
+ contentHash: z.ZodOptional<z.ZodString>;
46
+ }, z.core.$strict>;
47
+ toolAliases: z.ZodDefault<z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string[], string[]>>>;
48
+ subprocedures: z.ZodDefault<z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string[], string[]>>>;
49
+ }, z.core.$strict>, z.ZodTransform<{
50
+ source: {
51
+ skillId: string;
52
+ contentHash: string;
53
+ };
54
+ key: string;
55
+ name: string;
56
+ instructions: string;
57
+ activationDescription: string;
58
+ toolAliases: string[];
59
+ subprocedures: string[];
60
+ }, {
61
+ key: string;
62
+ name: string;
63
+ instructions: string;
64
+ activationDescription: string;
65
+ source: {
66
+ skillId: string;
67
+ contentHash?: string | undefined;
68
+ };
69
+ toolAliases: string[];
70
+ subprocedures: string[];
71
+ }>>>>;
72
+ tools: z.ZodDefault<z.ZodArray<z.ZodPipe<z.ZodObject<{
73
+ alias: z.ZodString;
74
+ description: z.ZodString;
75
+ managedFunction: z.ZodObject<{
76
+ ref: z.ZodString;
77
+ operation: z.ZodString;
78
+ }, z.core.$strict>;
79
+ inputMappings: z.ZodDefault<z.ZodArray<z.ZodObject<{
80
+ argument: z.ZodString;
81
+ parameter: z.ZodString;
82
+ }, z.core.$strict>>>;
83
+ outputMappings: z.ZodDefault<z.ZodArray<z.ZodObject<{
84
+ field: z.ZodString;
85
+ result: z.ZodString;
86
+ }, z.core.$strict>>>;
87
+ }, z.core.$strict>, z.ZodTransform<{
88
+ inputMappings: {
89
+ argument: string;
90
+ parameter: string;
91
+ }[];
92
+ outputMappings: {
93
+ field: string;
94
+ result: string;
95
+ }[];
96
+ alias: string;
97
+ description: string;
98
+ managedFunction: {
99
+ ref: string;
100
+ operation: string;
101
+ };
102
+ }, {
103
+ alias: string;
104
+ description: string;
105
+ managedFunction: {
106
+ ref: string;
107
+ operation: string;
108
+ };
109
+ inputMappings: {
110
+ argument: string;
111
+ parameter: string;
112
+ }[];
113
+ outputMappings: {
114
+ field: string;
115
+ result: string;
116
+ }[];
117
+ }>>>>;
118
+ }, z.core.$strict>, z.ZodTransform<{
119
+ procedures: {
120
+ source: {
121
+ skillId: string;
122
+ contentHash: string;
123
+ };
124
+ key: string;
125
+ name: string;
126
+ instructions: string;
127
+ activationDescription: string;
128
+ toolAliases: string[];
129
+ subprocedures: string[];
130
+ }[];
131
+ tools: {
132
+ inputMappings: {
133
+ argument: string;
134
+ parameter: string;
135
+ }[];
136
+ outputMappings: {
137
+ field: string;
138
+ result: string;
139
+ }[];
140
+ alias: string;
141
+ description: string;
142
+ managedFunction: {
143
+ ref: string;
144
+ operation: string;
145
+ };
146
+ }[];
147
+ schemaVersion: "1";
148
+ voice: string;
149
+ language: string;
150
+ firstMessage: string;
151
+ }, {
152
+ schemaVersion: "1";
153
+ voice: string;
154
+ language: string;
155
+ firstMessage: string;
156
+ procedures: {
157
+ source: {
158
+ skillId: string;
159
+ contentHash: string;
160
+ };
161
+ key: string;
162
+ name: string;
163
+ instructions: string;
164
+ activationDescription: string;
165
+ toolAliases: string[];
166
+ subprocedures: string[];
167
+ }[];
168
+ tools: {
169
+ inputMappings: {
170
+ argument: string;
171
+ parameter: string;
172
+ }[];
173
+ outputMappings: {
174
+ field: string;
175
+ result: string;
176
+ }[];
177
+ alias: string;
178
+ description: string;
179
+ managedFunction: {
180
+ ref: string;
181
+ operation: string;
182
+ };
183
+ }[];
184
+ }>>;
185
+ isPublic: z.ZodOptional<z.ZodLiteral<false>>;
186
+ publicOutputs: z.ZodOptional<z.ZodLiteral<false>>;
187
+ }, z.core.$strict>;
188
+ updatedByPrincipalId: z.ZodString;
189
+ updatedAt: z.ZodISODateTime;
190
+ }, z.core.$strict>;
191
+ export type VoiceDraft = z.infer<typeof voiceDraftSchema>;
192
+ export declare const voiceDraftSaveRequestSchema: z.ZodObject<{
193
+ agentId: z.ZodString;
194
+ expectedRevision: z.ZodNullable<z.ZodNumber>;
195
+ definition: z.ZodObject<{
196
+ name: z.ZodString;
197
+ description: z.ZodOptional<z.ZodString>;
198
+ id: z.ZodString;
199
+ permissions: z.ZodOptional<z.ZodArray<z.ZodObject<{
200
+ type: z.ZodEnum<{
201
+ user: "user";
202
+ group: "group";
203
+ }>;
204
+ id: z.ZodString;
205
+ role: z.ZodEnum<{
206
+ owner: "owner";
207
+ editor: "editor";
208
+ invoker: "invoker";
209
+ outputs_viewer: "outputs_viewer";
210
+ }>;
211
+ }, z.core.$strip>>>;
212
+ mode: z.ZodLiteral<"voice">;
213
+ model: z.ZodObject<{
214
+ provider: z.ZodString;
215
+ name: z.ZodString;
216
+ }, z.core.$strict>;
217
+ systemPrompt: z.ZodString;
218
+ skills: z.ZodPipe<z.ZodDefault<z.ZodArray<z.ZodString>>, z.ZodTransform<string[], string[]>>;
219
+ voice: z.ZodPipe<z.ZodObject<{
220
+ schemaVersion: z.ZodLiteral<"1">;
221
+ voice: z.ZodString;
222
+ language: z.ZodString;
223
+ firstMessage: z.ZodString;
224
+ procedures: z.ZodDefault<z.ZodArray<z.ZodPipe<z.ZodObject<{
225
+ key: z.ZodString;
226
+ name: z.ZodString;
227
+ instructions: z.ZodString;
228
+ activationDescription: z.ZodString;
229
+ source: z.ZodObject<{
230
+ skillId: z.ZodString;
231
+ contentHash: z.ZodOptional<z.ZodString>;
232
+ }, z.core.$strict>;
233
+ toolAliases: z.ZodDefault<z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string[], string[]>>>;
234
+ subprocedures: z.ZodDefault<z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string[], string[]>>>;
235
+ }, z.core.$strict>, z.ZodTransform<{
236
+ source: {
237
+ skillId: string;
238
+ contentHash: string;
239
+ };
240
+ key: string;
241
+ name: string;
242
+ instructions: string;
243
+ activationDescription: string;
244
+ toolAliases: string[];
245
+ subprocedures: string[];
246
+ }, {
247
+ key: string;
248
+ name: string;
249
+ instructions: string;
250
+ activationDescription: string;
251
+ source: {
252
+ skillId: string;
253
+ contentHash?: string | undefined;
254
+ };
255
+ toolAliases: string[];
256
+ subprocedures: string[];
257
+ }>>>>;
258
+ tools: z.ZodDefault<z.ZodArray<z.ZodPipe<z.ZodObject<{
259
+ alias: z.ZodString;
260
+ description: z.ZodString;
261
+ managedFunction: z.ZodObject<{
262
+ ref: z.ZodString;
263
+ operation: z.ZodString;
264
+ }, z.core.$strict>;
265
+ inputMappings: z.ZodDefault<z.ZodArray<z.ZodObject<{
266
+ argument: z.ZodString;
267
+ parameter: z.ZodString;
268
+ }, z.core.$strict>>>;
269
+ outputMappings: z.ZodDefault<z.ZodArray<z.ZodObject<{
270
+ field: z.ZodString;
271
+ result: z.ZodString;
272
+ }, z.core.$strict>>>;
273
+ }, z.core.$strict>, z.ZodTransform<{
274
+ inputMappings: {
275
+ argument: string;
276
+ parameter: string;
277
+ }[];
278
+ outputMappings: {
279
+ field: string;
280
+ result: string;
281
+ }[];
282
+ alias: string;
283
+ description: string;
284
+ managedFunction: {
285
+ ref: string;
286
+ operation: string;
287
+ };
288
+ }, {
289
+ alias: string;
290
+ description: string;
291
+ managedFunction: {
292
+ ref: string;
293
+ operation: string;
294
+ };
295
+ inputMappings: {
296
+ argument: string;
297
+ parameter: string;
298
+ }[];
299
+ outputMappings: {
300
+ field: string;
301
+ result: string;
302
+ }[];
303
+ }>>>>;
304
+ }, z.core.$strict>, z.ZodTransform<{
305
+ procedures: {
306
+ source: {
307
+ skillId: string;
308
+ contentHash: string;
309
+ };
310
+ key: string;
311
+ name: string;
312
+ instructions: string;
313
+ activationDescription: string;
314
+ toolAliases: string[];
315
+ subprocedures: string[];
316
+ }[];
317
+ tools: {
318
+ inputMappings: {
319
+ argument: string;
320
+ parameter: string;
321
+ }[];
322
+ outputMappings: {
323
+ field: string;
324
+ result: string;
325
+ }[];
326
+ alias: string;
327
+ description: string;
328
+ managedFunction: {
329
+ ref: string;
330
+ operation: string;
331
+ };
332
+ }[];
333
+ schemaVersion: "1";
334
+ voice: string;
335
+ language: string;
336
+ firstMessage: string;
337
+ }, {
338
+ schemaVersion: "1";
339
+ voice: string;
340
+ language: string;
341
+ firstMessage: string;
342
+ procedures: {
343
+ source: {
344
+ skillId: string;
345
+ contentHash: string;
346
+ };
347
+ key: string;
348
+ name: string;
349
+ instructions: string;
350
+ activationDescription: string;
351
+ toolAliases: string[];
352
+ subprocedures: string[];
353
+ }[];
354
+ tools: {
355
+ inputMappings: {
356
+ argument: string;
357
+ parameter: string;
358
+ }[];
359
+ outputMappings: {
360
+ field: string;
361
+ result: string;
362
+ }[];
363
+ alias: string;
364
+ description: string;
365
+ managedFunction: {
366
+ ref: string;
367
+ operation: string;
368
+ };
369
+ }[];
370
+ }>>;
371
+ isPublic: z.ZodOptional<z.ZodLiteral<false>>;
372
+ publicOutputs: z.ZodOptional<z.ZodLiteral<false>>;
373
+ }, z.core.$strict>;
374
+ }, z.core.$strict>;
375
+ export type VoiceDraftSaveRequest = z.infer<typeof voiceDraftSaveRequestSchema>;
376
+ export declare const voiceSkillCaptureRequestSchema: z.ZodObject<{
377
+ agentId: z.ZodString;
378
+ expectedDraftRevision: z.ZodNumber;
379
+ action: z.ZodEnum<{
380
+ ATTACH: "ATTACH";
381
+ REFRESH: "REFRESH";
382
+ }>;
383
+ skillId: z.ZodString;
384
+ procedureKey: z.ZodString;
385
+ activationDescription: z.ZodString;
386
+ toolAliases: z.ZodArray<z.ZodString>;
387
+ subprocedures: z.ZodArray<z.ZodString>;
388
+ }, z.core.$strict>;
389
+ export type VoiceSkillCaptureRequest = z.infer<typeof voiceSkillCaptureRequestSchema>;
390
+ export declare const voiceSkillSourceStatusSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
391
+ status: z.ZodLiteral<"CURRENT">;
392
+ skillId: z.ZodString;
393
+ capturedContentHash: z.ZodString;
394
+ currentContentHash: z.ZodString;
395
+ }, z.core.$strict>, z.ZodObject<{
396
+ status: z.ZodLiteral<"CHANGED">;
397
+ skillId: z.ZodString;
398
+ capturedContentHash: z.ZodString;
399
+ currentContentHash: z.ZodString;
400
+ }, z.core.$strict>, z.ZodObject<{
401
+ status: z.ZodLiteral<"MISSING">;
402
+ skillId: z.ZodString;
403
+ capturedContentHash: z.ZodString;
404
+ }, z.core.$strict>, z.ZodObject<{
405
+ status: z.ZodLiteral<"FORBIDDEN">;
406
+ skillId: z.ZodString;
407
+ capturedContentHash: z.ZodString;
408
+ }, z.core.$strict>], "status">;
409
+ export type VoiceSkillSourceStatus = z.infer<typeof voiceSkillSourceStatusSchema>;
410
+ export declare const voiceResolvedSkillSourceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
411
+ access: z.ZodLiteral<"ALLOWED">;
412
+ skillId: z.ZodString;
413
+ name: z.ZodString;
414
+ instructions: z.ZodString;
415
+ }, z.core.$strict>, z.ZodObject<{
416
+ access: z.ZodLiteral<"MISSING">;
417
+ skillId: z.ZodString;
418
+ }, z.core.$strict>, z.ZodObject<{
419
+ access: z.ZodLiteral<"FORBIDDEN">;
420
+ skillId: z.ZodString;
421
+ }, z.core.$strict>], "access">;
422
+ export type VoiceResolvedSkillSource = z.infer<typeof voiceResolvedSkillSourceSchema>;
423
+ export declare function assessVoiceSkillSource({ captured, source }: {
424
+ captured: CapturedVoiceProcedure;
425
+ source: VoiceResolvedSkillSource;
426
+ }): VoiceSkillSourceStatus;
427
+ export declare function captureVoiceSkill({ definition, request, source }: {
428
+ definition: VoiceAgentDefinition;
429
+ request: VoiceSkillCaptureRequest;
430
+ source: VoiceResolvedSkillSource;
431
+ }): VoiceAgentDefinition;
432
+ export declare const voiceDefinitionExportRequestSchema: z.ZodObject<{
433
+ agentId: z.ZodString;
434
+ source: z.ZodDiscriminatedUnion<[z.ZodObject<{
435
+ kind: z.ZodLiteral<"DRAFT">;
436
+ expectedRevision: z.ZodNumber;
437
+ }, z.core.$strict>, z.ZodObject<{
438
+ kind: z.ZodLiteral<"VERSION">;
439
+ agentVersionId: z.ZodString;
440
+ }, z.core.$strict>], "kind">;
441
+ }, z.core.$strict>;
@@ -0,0 +1,75 @@
1
+ import { z } from 'zod';
2
+ import { voiceAgentDefinitionSchema } from './agent-definition.js';
3
+ import { capturedVoiceProcedureSchema, hashVoiceSkillContent } from './voice-authoring.js';
4
+ import { voiceAgentScopeSchema, voiceHashSchema, voiceIdSchema, voiceLocalKeySchema, voiceRevisionSchema, voiceTimestampSchema } from './voice-common.js';
5
+ export const voiceDraftSchema = voiceAgentScopeSchema.extend({
6
+ revision: voiceRevisionSchema,
7
+ definition: voiceAgentDefinitionSchema,
8
+ updatedByPrincipalId: voiceIdSchema,
9
+ updatedAt: voiceTimestampSchema,
10
+ }).refine((draft) => draft.agentId === draft.definition.id, { path: ['definition', 'id'], message: 'Draft Agent identity mismatch' });
11
+ export const voiceDraftSaveRequestSchema = z.strictObject({
12
+ agentId: voiceIdSchema,
13
+ expectedRevision: voiceRevisionSchema.nullable(),
14
+ definition: voiceAgentDefinitionSchema,
15
+ }).refine((request) => request.agentId === request.definition.id, { path: ['definition', 'id'], message: 'Draft Agent identity mismatch' });
16
+ const procedureReferencesSchema = z.array(voiceLocalKeySchema).max(64)
17
+ .refine((keys) => new Set(keys).size === keys.length, 'Duplicate procedure reference');
18
+ export const voiceSkillCaptureRequestSchema = z.strictObject({
19
+ agentId: voiceIdSchema,
20
+ expectedDraftRevision: voiceRevisionSchema,
21
+ action: z.enum(['ATTACH', 'REFRESH']),
22
+ skillId: voiceIdSchema,
23
+ procedureKey: voiceLocalKeySchema,
24
+ activationDescription: z.string().trim().max(4_000),
25
+ toolAliases: procedureReferencesSchema,
26
+ subprocedures: procedureReferencesSchema,
27
+ });
28
+ export const voiceSkillSourceStatusSchema = z.discriminatedUnion('status', [
29
+ z.strictObject({ status: z.literal('CURRENT'), skillId: voiceIdSchema, capturedContentHash: voiceHashSchema, currentContentHash: voiceHashSchema })
30
+ .refine((source) => source.capturedContentHash === source.currentContentHash, 'Current source hash must match capture'),
31
+ z.strictObject({ status: z.literal('CHANGED'), skillId: voiceIdSchema, capturedContentHash: voiceHashSchema, currentContentHash: voiceHashSchema })
32
+ .refine((source) => source.capturedContentHash !== source.currentContentHash, 'Changed source hash must differ from capture'),
33
+ z.strictObject({ status: z.literal('MISSING'), skillId: voiceIdSchema, capturedContentHash: voiceHashSchema }),
34
+ z.strictObject({ status: z.literal('FORBIDDEN'), skillId: voiceIdSchema, capturedContentHash: voiceHashSchema }),
35
+ ]);
36
+ export const voiceResolvedSkillSourceSchema = z.discriminatedUnion('access', [
37
+ z.strictObject({ access: z.literal('ALLOWED'), skillId: voiceIdSchema,
38
+ name: z.string().trim().min(1).max(200), instructions: z.string().min(1).max(100_000) }),
39
+ z.strictObject({ access: z.literal('MISSING'), skillId: voiceIdSchema }),
40
+ z.strictObject({ access: z.literal('FORBIDDEN'), skillId: voiceIdSchema }),
41
+ ]);
42
+ export function assessVoiceSkillSource({ captured, source }) {
43
+ if (captured.source.skillId !== source.skillId)
44
+ throw new Error('Skill source identity mismatch');
45
+ const common = { skillId: source.skillId, capturedContentHash: captured.source.contentHash };
46
+ if (source.access !== 'ALLOWED')
47
+ return { ...common, status: source.access };
48
+ const currentContentHash = hashVoiceSkillContent(source);
49
+ return { ...common, currentContentHash,
50
+ status: currentContentHash === captured.source.contentHash ? 'CURRENT' : 'CHANGED' };
51
+ }
52
+ export function captureVoiceSkill({ definition, request, source }) {
53
+ if (request.agentId !== definition.id || source.skillId !== request.skillId)
54
+ throw new Error('Capture identity mismatch');
55
+ if (source.access !== 'ALLOWED')
56
+ throw new Error(`Skill source ${source.access.toLowerCase()}`);
57
+ const existing = definition.voice.procedures.find((procedure) => procedure.key === request.procedureKey);
58
+ if ((request.action === 'ATTACH' && existing !== undefined) ||
59
+ (request.action === 'REFRESH' && existing?.source.skillId !== source.skillId)) {
60
+ throw new Error('Capture target conflict');
61
+ }
62
+ const captured = capturedVoiceProcedureSchema.parse({ key: request.procedureKey,
63
+ name: source.name, instructions: source.instructions, source: { skillId: source.skillId },
64
+ activationDescription: request.activationDescription, toolAliases: request.toolAliases, subprocedures: request.subprocedures });
65
+ const procedures = [...definition.voice.procedures.filter((item) => item.key !== captured.key), captured];
66
+ return voiceAgentDefinitionSchema.parse({ ...definition,
67
+ skills: procedures.map((item) => item.source.skillId), voice: { ...definition.voice, procedures } });
68
+ }
69
+ export const voiceDefinitionExportRequestSchema = z.strictObject({
70
+ agentId: voiceIdSchema,
71
+ source: z.discriminatedUnion('kind', [
72
+ z.strictObject({ kind: z.literal('DRAFT'), expectedRevision: voiceRevisionSchema }),
73
+ z.strictObject({ kind: z.literal('VERSION'), agentVersionId: voiceIdSchema }),
74
+ ]),
75
+ });
@@ -0,0 +1,19 @@
1
+ import { z } from 'zod';
2
+ export declare const voiceCallGrantSchema: z.ZodObject<{
3
+ purpose: z.ZodLiteral<"VOICE_TOOL_INGRESS">;
4
+ subject: z.ZodObject<{
5
+ tenantId: z.ZodString;
6
+ environmentId: z.ZodString;
7
+ agentId: z.ZodString;
8
+ sessionId: z.ZodString;
9
+ releaseId: z.ZodString;
10
+ }, z.core.$strict>;
11
+ tokenHash: z.ZodString;
12
+ runtimeAccountId: z.ZodString;
13
+ twilioCallSid: z.ZodString;
14
+ revocationGeneration: z.ZodNumber;
15
+ issuedAt: z.ZodISODateTime;
16
+ expiresAt: z.ZodISODateTime;
17
+ revokedAt: z.ZodNullable<z.ZodISODateTime>;
18
+ }, z.core.$strict>;
19
+ export type VoiceCallGrant = z.infer<typeof voiceCallGrantSchema>;
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod';
2
+ import { voiceCallSubjectSchema } from './voice-authority.js';
3
+ import { voiceHashSchema, voiceIdSchema, voiceRevisionSchema, voiceTimestampSchema } from './voice-common.js';
4
+ export const voiceCallGrantSchema = z.strictObject({
5
+ purpose: z.literal('VOICE_TOOL_INGRESS'),
6
+ subject: voiceCallSubjectSchema,
7
+ tokenHash: voiceHashSchema,
8
+ runtimeAccountId: voiceIdSchema,
9
+ twilioCallSid: voiceIdSchema,
10
+ revocationGeneration: voiceRevisionSchema,
11
+ issuedAt: voiceTimestampSchema,
12
+ expiresAt: voiceTimestampSchema,
13
+ revokedAt: voiceTimestampSchema.nullable(),
14
+ }).superRefine((grant, context) => {
15
+ if (Date.parse(grant.expiresAt) <= Date.parse(grant.issuedAt)) {
16
+ context.addIssue({ code: 'custom', path: ['expiresAt'], message: 'Grant expiry must follow issue time' });
17
+ }
18
+ if (grant.revokedAt !== null && Date.parse(grant.revokedAt) < Date.parse(grant.issuedAt)) {
19
+ context.addIssue({ code: 'custom', path: ['revokedAt'], message: 'Revocation cannot precede issue time' });
20
+ }
21
+ });
@@ -0,0 +1,130 @@
1
+ import { z } from 'zod';
2
+ import { voiceAgentScopeSchema } from './voice-common.js';
3
+ export declare const voicePublicationPauseSchema: z.ZodObject<{
4
+ tenantId: z.ZodString;
5
+ environmentId: z.ZodString;
6
+ agentId: z.ZodString;
7
+ publicationOperationId: z.ZodString;
8
+ status: z.ZodEnum<{
9
+ ACTIVE: "ACTIVE";
10
+ RELEASED: "RELEASED";
11
+ }>;
12
+ revision: z.ZodNumber;
13
+ claimedAt: z.ZodISODateTime;
14
+ releasedAt: z.ZodNullable<z.ZodISODateTime>;
15
+ }, z.core.$strict>;
16
+ export type VoicePublicationPause = z.infer<typeof voicePublicationPauseSchema>;
17
+ type PauseClaimResult = {
18
+ ok: true;
19
+ pause: VoicePublicationPause;
20
+ changed: boolean;
21
+ } | {
22
+ ok: false;
23
+ reason: 'OWNED_BY_ANOTHER_OPERATION' | 'SCOPE_MISMATCH';
24
+ };
25
+ export declare function claimVoicePublicationPause({ current, agentScope, publicationOperationId, claimedAt, }: {
26
+ current: VoicePublicationPause | null;
27
+ agentScope: z.infer<typeof voiceAgentScopeSchema>;
28
+ publicationOperationId: string;
29
+ claimedAt: string;
30
+ }): PauseClaimResult;
31
+ type PauseReleaseResult = {
32
+ ok: true;
33
+ pause: VoicePublicationPause;
34
+ changed: boolean;
35
+ } | {
36
+ ok: false;
37
+ reason: 'OWNED_BY_ANOTHER_OPERATION';
38
+ };
39
+ export declare function releaseVoicePublicationPause({ current, publicationOperationId, releasedAt, }: {
40
+ current: VoicePublicationPause;
41
+ publicationOperationId: string;
42
+ releasedAt: string;
43
+ }): PauseReleaseResult;
44
+ export declare const voiceDependencyReferenceSchema: z.ZodObject<{
45
+ kind: z.ZodLiteral<"MANAGED_FUNCTION">;
46
+ managedFunctionId: z.ZodString;
47
+ observedVersionId: z.ZodNullable<z.ZodString>;
48
+ }, z.core.$strict>;
49
+ export type VoiceDependencyReference = z.infer<typeof voiceDependencyReferenceSchema>;
50
+ export declare const voiceDependencyMaintenanceTargetSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
51
+ kind: z.ZodLiteral<"ENVIRONMENT">;
52
+ }, z.core.$strict>, z.ZodObject<{
53
+ kind: z.ZodLiteral<"DEPENDENCIES">;
54
+ dependencies: z.ZodArray<z.ZodObject<{
55
+ kind: z.ZodLiteral<"MANAGED_FUNCTION">;
56
+ managedFunctionId: z.ZodString;
57
+ observedVersionId: z.ZodNullable<z.ZodString>;
58
+ }, z.core.$strict>>;
59
+ affectedAgentIds: z.ZodArray<z.ZodString>;
60
+ }, z.core.$strict>], "kind">;
61
+ export type VoiceDependencyMaintenanceTarget = z.infer<typeof voiceDependencyMaintenanceTargetSchema>;
62
+ export declare const voiceDependencyMaintenanceFenceSchema: z.ZodObject<{
63
+ tenantId: z.ZodString;
64
+ environmentId: z.ZodString;
65
+ fenceId: z.ZodString;
66
+ target: z.ZodDiscriminatedUnion<[z.ZodObject<{
67
+ kind: z.ZodLiteral<"ENVIRONMENT">;
68
+ }, z.core.$strict>, z.ZodObject<{
69
+ kind: z.ZodLiteral<"DEPENDENCIES">;
70
+ dependencies: z.ZodArray<z.ZodObject<{
71
+ kind: z.ZodLiteral<"MANAGED_FUNCTION">;
72
+ managedFunctionId: z.ZodString;
73
+ observedVersionId: z.ZodNullable<z.ZodString>;
74
+ }, z.core.$strict>>;
75
+ affectedAgentIds: z.ZodArray<z.ZodString>;
76
+ }, z.core.$strict>], "kind">;
77
+ ownerPrincipalId: z.ZodString;
78
+ state: z.ZodEnum<{
79
+ RECONCILIATION_REQUIRED: "RECONCILIATION_REQUIRED";
80
+ DRAINING: "DRAINING";
81
+ MAINTENANCE: "MAINTENANCE";
82
+ VERIFYING: "VERIFYING";
83
+ REPUBLICATION_REQUIRED: "REPUBLICATION_REQUIRED";
84
+ RELEASED: "RELEASED";
85
+ }>;
86
+ revision: z.ZodNumber;
87
+ createdAt: z.ZodISODateTime;
88
+ updatedAt: z.ZodISODateTime;
89
+ }, z.core.$strict>;
90
+ export type VoiceDependencyMaintenanceFence = z.infer<typeof voiceDependencyMaintenanceFenceSchema>;
91
+ export declare const voiceAdmissionControlInputSchema: z.ZodObject<{
92
+ environmentEnabled: z.ZodBoolean;
93
+ agentEnabled: z.ZodBoolean;
94
+ routeEnabled: z.ZodBoolean;
95
+ runtimeAccountEnabled: z.ZodBoolean;
96
+ releaseReady: z.ZodBoolean;
97
+ publicationPause: z.ZodNullable<z.ZodObject<{
98
+ tenantId: z.ZodString;
99
+ environmentId: z.ZodString;
100
+ agentId: z.ZodString;
101
+ publicationOperationId: z.ZodString;
102
+ status: z.ZodEnum<{
103
+ ACTIVE: "ACTIVE";
104
+ RELEASED: "RELEASED";
105
+ }>;
106
+ revision: z.ZodNumber;
107
+ claimedAt: z.ZodISODateTime;
108
+ releasedAt: z.ZodNullable<z.ZodISODateTime>;
109
+ }, z.core.$strict>>;
110
+ dependencyMaintenanceBlocked: z.ZodBoolean;
111
+ }, z.core.$strict>;
112
+ export type VoiceAdmissionControlInput = z.infer<typeof voiceAdmissionControlInputSchema>;
113
+ export declare const voiceAdmissionControlReasonSchema: z.ZodEnum<{
114
+ ENVIRONMENT_DISABLED: "ENVIRONMENT_DISABLED";
115
+ AGENT_DISABLED: "AGENT_DISABLED";
116
+ ROUTE_DISABLED: "ROUTE_DISABLED";
117
+ RUNTIME_ACCOUNT_DISABLED: "RUNTIME_ACCOUNT_DISABLED";
118
+ RELEASE_NOT_READY: "RELEASE_NOT_READY";
119
+ PUBLICATION_PAUSED: "PUBLICATION_PAUSED";
120
+ DEPENDENCY_MAINTENANCE: "DEPENDENCY_MAINTENANCE";
121
+ }>;
122
+ export type VoiceAdmissionControlReason = z.infer<typeof voiceAdmissionControlReasonSchema>;
123
+ export type VoiceAdmissionControlEvaluation = {
124
+ admitted: true;
125
+ } | {
126
+ admitted: false;
127
+ reason: VoiceAdmissionControlReason;
128
+ };
129
+ export declare function evaluateVoiceAdmissionControl(input: VoiceAdmissionControlInput): VoiceAdmissionControlEvaluation;
130
+ export {};