@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,47 @@
1
+ import { type VoicePublicationToolReview, type VoiceToolBinding, type VoiceTrustedVerifierResult, type VoiceVerificationAttempt, type VoiceVerificationAttemptRequest, type VoiceVerificationState } from './voice-authority-contracts.js';
2
+ type AttemptDenial = 'already_verified' | 'authority_expired' | 'verification_expired' | 'verification_locked' | 'verification_revoked';
3
+ export type BeginVoiceVerificationAttemptResult = {
4
+ outcome: 'started';
5
+ state: VoiceVerificationState;
6
+ attempt: VoiceVerificationAttempt;
7
+ } | {
8
+ outcome: 'retry';
9
+ state: VoiceVerificationState;
10
+ attempt: VoiceVerificationAttempt;
11
+ } | {
12
+ outcome: 'conflict';
13
+ reason: 'idempotency_conflict' | 'existing_attempt_key_mismatch';
14
+ } | {
15
+ outcome: 'denied';
16
+ reason: AttemptDenial;
17
+ state: VoiceVerificationState;
18
+ };
19
+ export declare function beginVoiceVerificationAttempt({ state, request, existingAttempt, now }: {
20
+ state: VoiceVerificationState;
21
+ request: VoiceVerificationAttemptRequest;
22
+ existingAttempt: VoiceVerificationAttempt | null;
23
+ now: string;
24
+ }): BeginVoiceVerificationAttemptResult;
25
+ type ResultRejection = 'authority_expired' | 'verification_already_established' | 'verification_binding_mismatch' | 'verification_expiry_invalid' | 'verification_locked' | 'verification_revoked' | 'verifier_review_stale' | 'verifier_result_untrusted';
26
+ export type ApplyVoiceVerifierResult = {
27
+ outcome: 'applied';
28
+ state: VoiceVerificationState;
29
+ attempt: VoiceVerificationAttempt;
30
+ } | {
31
+ outcome: 'retry';
32
+ state: VoiceVerificationState;
33
+ attempt: VoiceVerificationAttempt;
34
+ } | {
35
+ outcome: 'rejected';
36
+ reason: ResultRejection;
37
+ state: VoiceVerificationState;
38
+ };
39
+ export declare function applyVoiceVerifierResult({ state, attempt, result, verifierReview, currentBinding, now, }: {
40
+ state: VoiceVerificationState;
41
+ attempt: VoiceVerificationAttempt;
42
+ result: VoiceTrustedVerifierResult;
43
+ verifierReview: VoicePublicationToolReview;
44
+ currentBinding: VoiceToolBinding;
45
+ now: string;
46
+ }): ApplyVoiceVerifierResult;
47
+ export {};
@@ -0,0 +1,184 @@
1
+ import { voiceTimestampSchema } from './voice-common.js';
2
+ import { isVoicePublicationToolReviewCurrent, sameVoiceResource, voicePublicationToolReviewSchema, voiceToolBindingSchema, voiceTrustedVerifierResultSchema, voiceVerificationAttemptRequestSchema, voiceVerificationAttemptSchema, voiceVerificationStateSchema, } from './voice-authority-contracts.js';
3
+ function sameSubject({ left, right }) {
4
+ return left.tenantId === right.tenantId &&
5
+ left.environmentId === right.environmentId &&
6
+ left.agentId === right.agentId &&
7
+ left.sessionId === right.sessionId &&
8
+ left.releaseId === right.releaseId;
9
+ }
10
+ function sameAttemptRequest({ attempt, request }) {
11
+ return attempt.attemptId === request.attemptId &&
12
+ sameSubject({ left: attempt.subject, right: request.subject }) &&
13
+ sameVoiceResource({ left: attempt.candidateResource, right: request.candidateResource }) &&
14
+ attempt.methodKey === request.methodKey &&
15
+ attempt.idempotencyKey === request.idempotencyKey &&
16
+ attempt.requestDigest === request.requestDigest;
17
+ }
18
+ function expireState({ state }) {
19
+ return {
20
+ ...state,
21
+ status: 'expired',
22
+ verifiedResource: null,
23
+ verificationId: null,
24
+ verificationMethodKey: null,
25
+ verificationExpiresAt: null,
26
+ revision: state.revision + 1,
27
+ };
28
+ }
29
+ function inactiveAttemptResult({ state }) {
30
+ if (state.status === 'verified') {
31
+ return { outcome: 'denied', reason: 'already_verified', state };
32
+ }
33
+ if (state.status === 'locked') {
34
+ return { outcome: 'denied', reason: 'verification_locked', state };
35
+ }
36
+ if (state.status === 'revoked') {
37
+ return { outcome: 'denied', reason: 'verification_revoked', state };
38
+ }
39
+ if (state.status === 'expired') {
40
+ return { outcome: 'denied', reason: 'verification_expired', state };
41
+ }
42
+ return null;
43
+ }
44
+ export function beginVoiceVerificationAttempt({ state, request, existingAttempt, now }) {
45
+ const parsedState = voiceVerificationStateSchema.parse(state);
46
+ const parsedRequest = voiceVerificationAttemptRequestSchema.parse(request);
47
+ const parsedNow = voiceTimestampSchema.parse(now);
48
+ if (!sameSubject({ left: parsedState.subject, right: parsedRequest.subject })) {
49
+ return { outcome: 'conflict', reason: 'idempotency_conflict' };
50
+ }
51
+ if (existingAttempt !== null) {
52
+ const attempt = voiceVerificationAttemptSchema.parse(existingAttempt);
53
+ if (attempt.idempotencyKey !== parsedRequest.idempotencyKey) {
54
+ return { outcome: 'conflict', reason: 'existing_attempt_key_mismatch' };
55
+ }
56
+ return sameAttemptRequest({ attempt, request: parsedRequest })
57
+ ? { outcome: 'retry', state: parsedState, attempt }
58
+ : { outcome: 'conflict', reason: 'idempotency_conflict' };
59
+ }
60
+ if (Date.parse(parsedNow) >= Date.parse(parsedState.authorityExpiresAt)) {
61
+ return { outcome: 'denied', reason: 'authority_expired', state: expireState({ state: parsedState }) };
62
+ }
63
+ const inactive = inactiveAttemptResult({ state: parsedState });
64
+ if (inactive !== null)
65
+ return inactive;
66
+ if (parsedState.attemptBudget.usedAttempts >= parsedState.attemptBudget.maxAttempts) {
67
+ const locked = { ...parsedState, status: 'locked', revision: parsedState.revision + 1 };
68
+ return { outcome: 'denied', reason: 'verification_locked', state: locked };
69
+ }
70
+ const attemptNumber = parsedState.attemptBudget.usedAttempts + 1;
71
+ return {
72
+ outcome: 'started',
73
+ state: {
74
+ ...parsedState,
75
+ attemptBudget: { ...parsedState.attemptBudget, usedAttempts: attemptNumber },
76
+ revision: parsedState.revision + 1,
77
+ },
78
+ attempt: {
79
+ ...parsedRequest, attemptNumber, status: 'pending', completedAt: null,
80
+ verifierInvocationId: null, verificationId: null,
81
+ },
82
+ };
83
+ }
84
+ function resultMatchesAttempt({ result, attempt }) {
85
+ return result.attemptId === attempt.attemptId &&
86
+ sameSubject({ left: result.subject, right: attempt.subject }) &&
87
+ sameVoiceResource({ left: result.candidateResource, right: attempt.candidateResource }) &&
88
+ result.methodKey === attempt.methodKey &&
89
+ result.idempotencyKey === attempt.idempotencyKey &&
90
+ result.requestDigest === attempt.requestDigest;
91
+ }
92
+ function trustedResultReason({ state, result, review, currentBinding }) {
93
+ const correctReview = review.requirement.authority === 'authentication' &&
94
+ review.requirement.resourceKind === result.candidateResource.kind &&
95
+ result.verifierReviewId === review.reviewId &&
96
+ result.observedFunctionVersionId === review.binding.functionVersionId &&
97
+ review.releaseId === state.subject.releaseId &&
98
+ review.scope.tenantId === state.subject.tenantId &&
99
+ review.scope.environmentId === state.subject.environmentId &&
100
+ review.scope.agentId === state.subject.agentId;
101
+ if (!correctReview)
102
+ return 'verifier_result_untrusted';
103
+ return isVoicePublicationToolReviewCurrent({
104
+ review, currentBinding,
105
+ currentRequirement: { authority: 'authentication', effect: 'resource_verification', resourceKind: result.candidateResource.kind },
106
+ }) ? null : 'verifier_review_stale';
107
+ }
108
+ function completedAttemptResult({ state, attempt, result }) {
109
+ if (attempt.status === 'pending' || attempt.status === 'uncertain')
110
+ return null;
111
+ const matches = attempt.verificationId === result.verificationId &&
112
+ attempt.verifierInvocationId === result.verifierInvocationId &&
113
+ attempt.status === result.verdict;
114
+ return matches
115
+ ? { outcome: 'retry', state, attempt }
116
+ : { outcome: 'rejected', reason: 'verification_binding_mismatch', state };
117
+ }
118
+ function appliedVerifiedResult({ state, attempt, result, now }) {
119
+ const invalidExpiry = Date.parse(result.verificationExpiresAt) <= Date.parse(now) ||
120
+ Date.parse(result.verificationExpiresAt) > Date.parse(state.authorityExpiresAt);
121
+ if (invalidExpiry) {
122
+ return { outcome: 'rejected', reason: 'verification_expiry_invalid', state };
123
+ }
124
+ return {
125
+ outcome: 'applied',
126
+ state: {
127
+ ...state, status: 'verified', verifiedResource: result.candidateResource,
128
+ verificationId: result.verificationId, verificationMethodKey: result.methodKey,
129
+ verificationExpiresAt: result.verificationExpiresAt, revision: state.revision + 1,
130
+ },
131
+ attempt: {
132
+ ...attempt, status: 'verified', completedAt: result.completedAt,
133
+ verifierInvocationId: result.verifierInvocationId, verificationId: result.verificationId,
134
+ },
135
+ };
136
+ }
137
+ function appliedRejectedResult({ state, attempt, result }) {
138
+ const locked = state.attemptBudget.usedAttempts >= state.attemptBudget.maxAttempts;
139
+ return {
140
+ outcome: 'applied',
141
+ state: { ...state, status: locked ? 'locked' : 'unverified', revision: state.revision + 1 },
142
+ attempt: {
143
+ ...attempt, status: 'rejected', completedAt: result.completedAt,
144
+ verifierInvocationId: result.verifierInvocationId, verificationId: result.verificationId,
145
+ },
146
+ };
147
+ }
148
+ export function applyVoiceVerifierResult({ state, attempt, result, verifierReview, currentBinding, now, }) {
149
+ const parsedState = voiceVerificationStateSchema.parse(state);
150
+ const parsedAttempt = voiceVerificationAttemptSchema.parse(attempt);
151
+ const parsedResult = voiceTrustedVerifierResultSchema.parse(result);
152
+ const review = voicePublicationToolReviewSchema.parse(verifierReview);
153
+ const binding = voiceToolBindingSchema.parse(currentBinding);
154
+ const parsedNow = voiceTimestampSchema.parse(now);
155
+ const mismatched = !sameSubject({ left: parsedState.subject, right: parsedAttempt.subject }) ||
156
+ !resultMatchesAttempt({ result: parsedResult, attempt: parsedAttempt });
157
+ if (mismatched) {
158
+ return { outcome: 'rejected', reason: 'verification_binding_mismatch', state: parsedState };
159
+ }
160
+ const trustReason = trustedResultReason({ state: parsedState, result: parsedResult, review,
161
+ currentBinding: binding });
162
+ if (trustReason !== null)
163
+ return { outcome: 'rejected', reason: trustReason, state: parsedState };
164
+ const completed = completedAttemptResult({ state: parsedState, attempt: parsedAttempt,
165
+ result: parsedResult });
166
+ if (completed !== null)
167
+ return completed;
168
+ if (parsedState.status === 'verified') {
169
+ return { outcome: 'rejected', reason: 'verification_already_established', state: parsedState };
170
+ }
171
+ if (Date.parse(parsedNow) >= Date.parse(parsedState.authorityExpiresAt)) {
172
+ return { outcome: 'rejected', reason: 'authority_expired', state: expireState({ state: parsedState }) };
173
+ }
174
+ if (parsedState.status === 'revoked') {
175
+ return { outcome: 'rejected', reason: 'verification_revoked', state: parsedState };
176
+ }
177
+ if (parsedState.status === 'locked' || parsedState.status === 'expired') {
178
+ return { outcome: 'rejected', reason: 'verification_locked', state: parsedState };
179
+ }
180
+ return parsedResult.verdict === 'verified'
181
+ ? appliedVerifiedResult({ state: parsedState, attempt: parsedAttempt, result: parsedResult,
182
+ now: parsedNow })
183
+ : appliedRejectedResult({ state: parsedState, attempt: parsedAttempt, result: parsedResult });
184
+ }
@@ -0,0 +1,3 @@
1
+ export * from './voice-authority-contracts.js';
2
+ export * from './voice-authority-verification.js';
3
+ export * from './voice-authority-evaluation.js';
@@ -0,0 +1,3 @@
1
+ export * from './voice-authority-contracts.js';
2
+ export * from './voice-authority-verification.js';
3
+ export * from './voice-authority-evaluation.js';
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod';
2
+ export declare const voiceIdSchema: z.ZodString;
3
+ export declare const voiceHashSchema: z.ZodString;
4
+ export declare const voiceRevisionSchema: z.ZodNumber;
5
+ export declare const voiceTimestampSchema: z.ZodISODateTime;
6
+ export declare const voiceScopeSchema: z.ZodObject<{
7
+ tenantId: z.ZodString;
8
+ environmentId: z.ZodString;
9
+ }, z.core.$strict>;
10
+ export type VoiceScope = z.infer<typeof voiceScopeSchema>;
11
+ export declare const voiceAgentScopeSchema: z.ZodObject<{
12
+ tenantId: z.ZodString;
13
+ environmentId: z.ZodString;
14
+ agentId: z.ZodString;
15
+ }, z.core.$strict>;
16
+ export type VoiceAgentScope = z.infer<typeof voiceAgentScopeSchema>;
17
+ export declare const voiceLocalKeySchema: z.ZodString;
18
+ export declare const VOICE_RESERVED_VARIABLES: readonly ["secret__atlas_demo_call_grant", "voice_session_id", "atlas_session_id", "sessionId", "releaseId", "tenantId", "environmentId", "runtimeAccountId", "initiatingStaffPrincipalId", "verifiedResource", "customerVerified", "customerId", "verifiedCustomerId", "candidateCustomerId", "syntheticResource", "candidateResource", "verificationId", "actorPrincipalId", "runtimeServiceAccountId", "serviceAccountId", "principalId", "systemRunner", "assertedBy", "authority", "grant", "namespace", "functionId", "managedFunctionId"];
19
+ export declare function isReservedVoiceVariable({ name }: {
20
+ name: string;
21
+ }): boolean;
@@ -0,0 +1,23 @@
1
+ import { z } from 'zod';
2
+ export const voiceIdSchema = z.string().trim().min(1).max(200);
3
+ export const voiceHashSchema = z.string().regex(/^[a-f0-9]{64}$/);
4
+ export const voiceRevisionSchema = z.number().int().nonnegative().safe();
5
+ export const voiceTimestampSchema = z.iso.datetime({ offset: true });
6
+ export const voiceScopeSchema = z.strictObject({
7
+ tenantId: voiceIdSchema,
8
+ environmentId: voiceIdSchema,
9
+ });
10
+ export const voiceAgentScopeSchema = voiceScopeSchema.extend({ agentId: voiceIdSchema });
11
+ export const voiceLocalKeySchema = z.string().regex(/^[a-z][a-z0-9_]{0,63}$/);
12
+ export const VOICE_RESERVED_VARIABLES = [
13
+ 'secret__atlas_demo_call_grant', 'voice_session_id', 'atlas_session_id',
14
+ 'sessionId', 'releaseId', 'tenantId', 'environmentId', 'runtimeAccountId',
15
+ 'initiatingStaffPrincipalId', 'verifiedResource', 'customerVerified',
16
+ 'customerId', 'verifiedCustomerId', 'candidateCustomerId', 'syntheticResource', 'candidateResource', 'verificationId', 'actorPrincipalId',
17
+ 'runtimeServiceAccountId', 'serviceAccountId', 'principalId', 'systemRunner',
18
+ 'assertedBy', 'authority', 'grant', 'namespace', 'functionId', 'managedFunctionId',
19
+ ];
20
+ export function isReservedVoiceVariable({ name }) {
21
+ return name.startsWith('secret__') || name.startsWith('system__') ||
22
+ VOICE_RESERVED_VARIABLES.some((reserved) => reserved === name);
23
+ }