@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.
- package/README.md +93 -0
- package/dist/agent-definition.d.ts +616 -0
- package/dist/agent-definition.js +240 -0
- package/dist/canonical-json.d.ts +2 -0
- package/dist/canonical-json.js +13 -0
- package/dist/index.d.ts +2 -117
- package/dist/index.js +2 -248
- package/dist/input-schema.d.ts +19 -0
- package/dist/input-schema.js +57 -0
- package/dist/voice-access.d.ts +40 -0
- package/dist/voice-access.js +34 -0
- package/dist/voice-actions-contracts.d.ts +423 -0
- package/dist/voice-actions-contracts.js +95 -0
- package/dist/voice-actions-transitions.d.ts +52 -0
- package/dist/voice-actions-transitions.js +170 -0
- package/dist/voice-actions.d.ts +2 -0
- package/dist/voice-actions.js +2 -0
- package/dist/voice-api.d.ts +1102 -0
- package/dist/voice-api.js +164 -0
- package/dist/voice-authoring.d.ts +463 -0
- package/dist/voice-authoring.js +132 -0
- package/dist/voice-authority-contracts.d.ts +247 -0
- package/dist/voice-authority-contracts.js +177 -0
- package/dist/voice-authority-evaluation.d.ts +29 -0
- package/dist/voice-authority-evaluation.js +80 -0
- package/dist/voice-authority-verification.d.ts +47 -0
- package/dist/voice-authority-verification.js +184 -0
- package/dist/voice-authority.d.ts +3 -0
- package/dist/voice-authority.js +3 -0
- package/dist/voice-common.d.ts +21 -0
- package/dist/voice-common.js +23 -0
- package/dist/voice-drafts.d.ts +441 -0
- package/dist/voice-drafts.js +75 -0
- package/dist/voice-grant.d.ts +19 -0
- package/dist/voice-grant.js +21 -0
- package/dist/voice-lifecycle-control.d.ts +130 -0
- package/dist/voice-lifecycle-control.js +138 -0
- package/dist/voice-lifecycle-session.d.ts +168 -0
- package/dist/voice-lifecycle-session.js +114 -0
- package/dist/voice-lifecycle-states.d.ts +96 -0
- package/dist/voice-lifecycle-states.js +139 -0
- package/dist/voice-lifecycle.d.ts +3 -0
- package/dist/voice-lifecycle.js +3 -0
- package/dist/voice-policy-duration.d.ts +46 -0
- package/dist/voice-policy-duration.js +166 -0
- package/dist/voice-policy-limits.d.ts +174 -0
- package/dist/voice-policy-limits.js +188 -0
- package/dist/voice-policy.d.ts +2 -0
- package/dist/voice-policy.js +2 -0
- package/dist/voice-provider-evidence.d.ts +80 -0
- package/dist/voice-provider-evidence.js +115 -0
- package/dist/voice-provider-publication.d.ts +319 -0
- package/dist/voice-provider-publication.js +117 -0
- package/dist/voice-provider-release.d.ts +386 -0
- package/dist/voice-provider-release.js +154 -0
- package/dist/voice-provider.d.ts +3 -0
- package/dist/voice-provider.js +3 -0
- package/dist/voice-release.d.ts +808 -0
- package/dist/voice-release.js +110 -0
- package/dist/voice-runs-audio.d.ts +157 -0
- package/dist/voice-runs-audio.js +85 -0
- package/dist/voice-runs-evidence.d.ts +183 -0
- package/dist/voice-runs-evidence.js +154 -0
- package/dist/voice-runs-model.d.ts +967 -0
- package/dist/voice-runs-model.js +199 -0
- package/dist/voice-runs-tooling.d.ts +88 -0
- package/dist/voice-runs-tooling.js +100 -0
- package/dist/voice-runs.d.ts +4 -0
- package/dist/voice-runs.js +4 -0
- package/dist/voice.d.ts +13 -0
- package/dist/voice.js +13 -0
- package/package.json +8 -3
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { voiceIdSchema, voiceTimestampSchema } from './voice-common.js';
|
|
3
|
+
import { sameVoiceResource, voiceResourceReferenceSchema } from './voice-authority-contracts.js';
|
|
4
|
+
export const voiceRunSanitizedTextSchema = z.string().trim().min(1).max(2_000);
|
|
5
|
+
const MAX_JSON_BYTES = 16 * 1024;
|
|
6
|
+
const SECRET_KEY = /(?:^|[_-])(authorization|credential|password|secret|token|api[_-]?key|call[_-]?grant)(?:$|[_-])/i;
|
|
7
|
+
function findSecretKey({ value, path }) {
|
|
8
|
+
if (Array.isArray(value)) {
|
|
9
|
+
for (const [index, entry] of value.entries()) {
|
|
10
|
+
const found = findSecretKey({ value: entry, path: `${path}[${index}]` });
|
|
11
|
+
if (found !== null)
|
|
12
|
+
return found;
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
if (value === null || typeof value !== 'object')
|
|
17
|
+
return null;
|
|
18
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
19
|
+
if (SECRET_KEY.test(key))
|
|
20
|
+
return `${path}.${key}`;
|
|
21
|
+
const found = findSecretKey({ value: entry, path: `${path}.${key}` });
|
|
22
|
+
if (found !== null)
|
|
23
|
+
return found;
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
function boundedEvidenceValue(maxBytes) {
|
|
28
|
+
return z.json().superRefine((value, context) => {
|
|
29
|
+
if (Buffer.byteLength(JSON.stringify(value), 'utf8') > maxBytes) {
|
|
30
|
+
context.addIssue({ code: 'custom', message: `run evidence exceeds ${maxBytes} bytes` });
|
|
31
|
+
}
|
|
32
|
+
const secretPath = findSecretKey({ value, path: '(root)' });
|
|
33
|
+
if (secretPath !== null) {
|
|
34
|
+
context.addIssue({
|
|
35
|
+
code: 'custom', message: `${secretPath} is a secret-bearing key and cannot be retained`,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export const voiceBoundedRunEvidenceValueSchema = boundedEvidenceValue(MAX_JSON_BYTES);
|
|
41
|
+
export const voiceDetailedRunEvidenceValueSchema = boundedEvidenceValue(64 * 1024);
|
|
42
|
+
export const voiceTranscriptEntrySchema = z.strictObject({
|
|
43
|
+
sequence: z.number().int().nonnegative().safe(),
|
|
44
|
+
speaker: z.enum(['AGENT', 'CALLER', 'TOOL', 'SYSTEM']),
|
|
45
|
+
text: z.string().max(8_000),
|
|
46
|
+
startedAt: voiceTimestampSchema.nullable(),
|
|
47
|
+
endedAt: voiceTimestampSchema.nullable(),
|
|
48
|
+
});
|
|
49
|
+
const availableTranscript = z.strictObject({
|
|
50
|
+
status: z.literal('AVAILABLE'), transcriptReferenceId: voiceIdSchema,
|
|
51
|
+
capturedAt: voiceTimestampSchema, entries: z.array(voiceTranscriptEntrySchema).min(1).max(500),
|
|
52
|
+
sanitizedDetail: z.null(),
|
|
53
|
+
});
|
|
54
|
+
const absentTranscript = z.strictObject({
|
|
55
|
+
status: z.enum(['PENDING', 'MISSING']), transcriptReferenceId: z.null(),
|
|
56
|
+
capturedAt: voiceTimestampSchema.nullable(), entries: z.array(voiceTranscriptEntrySchema).length(0),
|
|
57
|
+
sanitizedDetail: voiceRunSanitizedTextSchema,
|
|
58
|
+
});
|
|
59
|
+
const contradictoryTranscript = z.strictObject({
|
|
60
|
+
status: z.literal('CONTRADICTORY'), transcriptReferenceId: voiceIdSchema.nullable(),
|
|
61
|
+
capturedAt: voiceTimestampSchema.nullable(), entries: z.array(voiceTranscriptEntrySchema).max(500),
|
|
62
|
+
sanitizedDetail: voiceRunSanitizedTextSchema,
|
|
63
|
+
});
|
|
64
|
+
export const voiceTranscriptSchema = z.discriminatedUnion('status', [
|
|
65
|
+
availableTranscript, absentTranscript, contradictoryTranscript,
|
|
66
|
+
]).superRefine((value, context) => {
|
|
67
|
+
if (value.entries.reduce((total, { text }) => total + text.length, 0) > 250_000) {
|
|
68
|
+
context.addIssue({ code: 'custom', path: ['entries'], message: 'transcript text is too large' });
|
|
69
|
+
}
|
|
70
|
+
const sequences = value.entries.map(({ sequence }) => sequence);
|
|
71
|
+
if (new Set(sequences).size !== sequences.length) {
|
|
72
|
+
context.addIssue({ code: 'custom', path: ['entries'], message: 'sequences must be unique' });
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
export const voiceCompletionEventKindSchema = z.literal('CALL_COMPLETED');
|
|
76
|
+
export const voiceLogicalCompletionEventIdentitySchema = z.strictObject({
|
|
77
|
+
sessionId: voiceIdSchema, kind: voiceCompletionEventKindSchema,
|
|
78
|
+
});
|
|
79
|
+
export function voiceLogicalCompletionEventKey({ sessionId, kind }) {
|
|
80
|
+
const identity = voiceLogicalCompletionEventIdentitySchema.parse({ sessionId, kind });
|
|
81
|
+
return JSON.stringify([identity.sessionId, identity.kind]);
|
|
82
|
+
}
|
|
83
|
+
export const voiceCompletionEventSchema = z.strictObject({
|
|
84
|
+
eventId: voiceIdSchema,
|
|
85
|
+
logicalIdentity: voiceLogicalCompletionEventIdentitySchema,
|
|
86
|
+
providerDeliveryIds: z.array(voiceIdSchema).max(100)
|
|
87
|
+
.refine((values) => new Set(values).size === values.length, {
|
|
88
|
+
message: 'provider delivery IDs must be unique evidence references',
|
|
89
|
+
}),
|
|
90
|
+
evidenceStatus: z.enum(['CONFIRMED', 'PENDING', 'CONTRADICTORY']),
|
|
91
|
+
persistedAt: voiceTimestampSchema,
|
|
92
|
+
providerConversationId: voiceIdSchema.nullable(),
|
|
93
|
+
});
|
|
94
|
+
export const voiceTelephoneOutcomeSchema = z.enum(['COMPLETED', 'FAILED', 'CANCELLED', 'UNKNOWN']);
|
|
95
|
+
export const voiceBusinessOutcomeSchema = z.enum([
|
|
96
|
+
'SUCCEEDED', 'FAILED', 'PARTIAL', 'NOT_REQUESTED', 'UNKNOWN',
|
|
97
|
+
]);
|
|
98
|
+
export const voiceRunWritebackStatusSchema = z.enum([
|
|
99
|
+
'PENDING', 'COMPLETE', 'FAILED', 'RECONCILIATION_REQUIRED',
|
|
100
|
+
]);
|
|
101
|
+
export const voiceRunEvidenceStatusSchema = z.enum([
|
|
102
|
+
'COMPLETE', 'PENDING', 'INCOMPLETE', 'CONTRADICTORY',
|
|
103
|
+
]);
|
|
104
|
+
export const voiceSyntheticResourceEvidenceSchema = z.strictObject({
|
|
105
|
+
candidate: z.strictObject({
|
|
106
|
+
fixtureId: voiceIdSchema, syntheticResource: voiceResourceReferenceSchema,
|
|
107
|
+
}).nullable(),
|
|
108
|
+
verifiedResource: voiceResourceReferenceSchema.nullable(),
|
|
109
|
+
verificationStatus: z.enum([
|
|
110
|
+
'NOT_VERIFIED', 'VERIFIED', 'FAILED', 'LOCKED', 'EXPIRED', 'REVOKED', 'UNKNOWN',
|
|
111
|
+
]),
|
|
112
|
+
}).superRefine((value, context) => {
|
|
113
|
+
if (value.verificationStatus === 'VERIFIED') {
|
|
114
|
+
if (value.candidate === null || value.verifiedResource === null ||
|
|
115
|
+
!sameVoiceResource({ left: value.candidate.syntheticResource, right: value.verifiedResource })) {
|
|
116
|
+
context.addIssue({ code: 'custom', message: 'verified resource must match candidate' });
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
else if (value.verifiedResource !== null) {
|
|
120
|
+
context.addIssue({ code: 'custom', message: 'unverified evidence cannot claim a resource' });
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
export const voiceRunEvidenceRetentionSchema = z.strictObject({
|
|
124
|
+
policy: z.literal('UNLIMITED'),
|
|
125
|
+
ageBasedExpiry: z.literal(false),
|
|
126
|
+
appliesTo: z.tuple([
|
|
127
|
+
z.literal('TRANSCRIPT'), z.literal('TOOL_EVIDENCE'), z.literal('COMPLETION_EVENT'),
|
|
128
|
+
z.literal('RUN_METADATA'), z.literal('RECORDING'),
|
|
129
|
+
]),
|
|
130
|
+
});
|
|
131
|
+
const providerUnlimitedRetention = z.strictObject({
|
|
132
|
+
policy: z.literal('UNLIMITED'), providerRetentionDays: z.literal(-1),
|
|
133
|
+
evidenceRef: z.string().trim().min(1).max(500),
|
|
134
|
+
});
|
|
135
|
+
export const voiceRunRecordingSchema = z.discriminatedUnion('status', [
|
|
136
|
+
z.strictObject({
|
|
137
|
+
status: z.literal('DISABLED'), enabled: z.literal(false), providerRetention: z.null(),
|
|
138
|
+
sanitizedDetail: voiceRunSanitizedTextSchema,
|
|
139
|
+
}),
|
|
140
|
+
z.strictObject({
|
|
141
|
+
status: z.literal('PENDING'), enabled: z.literal(true),
|
|
142
|
+
providerRetention: providerUnlimitedRetention,
|
|
143
|
+
sanitizedDetail: voiceRunSanitizedTextSchema.nullable(),
|
|
144
|
+
}),
|
|
145
|
+
z.strictObject({
|
|
146
|
+
status: z.literal('AVAILABLE'), enabled: z.literal(true),
|
|
147
|
+
providerRetention: providerUnlimitedRetention, sanitizedDetail: z.null(),
|
|
148
|
+
}),
|
|
149
|
+
z.strictObject({
|
|
150
|
+
status: z.literal('UNAVAILABLE'), enabled: z.literal(true),
|
|
151
|
+
providerRetention: providerUnlimitedRetention,
|
|
152
|
+
sanitizedDetail: voiceRunSanitizedTextSchema,
|
|
153
|
+
}),
|
|
154
|
+
]);
|