@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,52 @@
1
+ import { type VoiceActionIntentBinding, type VoiceActionIntentState, type VoiceActionIntentTransition, type VoiceCommittedActionReceipt, type VoicePrepareActionRequest, type VoicePreparedActionIntent } from './voice-actions-contracts.js';
2
+ export type PrepareVoiceActionIntentResult = {
3
+ outcome: 'prepared';
4
+ state: VoicePreparedActionIntent;
5
+ } | {
6
+ outcome: 'retry';
7
+ state: VoiceActionIntentState;
8
+ } | {
9
+ outcome: 'conflict';
10
+ reason: 'intent_binding_conflict';
11
+ };
12
+ export declare function prepareVoiceActionIntent({ request, existing }: {
13
+ request: VoicePrepareActionRequest;
14
+ existing: VoiceActionIntentState | null;
15
+ }): PrepareVoiceActionIntentResult;
16
+ export type VoiceActionConfirmationDecision = {
17
+ decision: 'dispatch';
18
+ } | {
19
+ decision: 'reconcile';
20
+ reason: 'uncertain_outcome';
21
+ } | {
22
+ decision: 'return_receipt';
23
+ receipt: VoiceCommittedActionReceipt;
24
+ } | {
25
+ decision: 'conflict';
26
+ reason: 'intent_binding_conflict';
27
+ } | {
28
+ decision: 'denied';
29
+ reason: 'intent_cancelled' | 'intent_expired';
30
+ };
31
+ export declare function decideVoiceActionConfirmation({ state, binding, now }: {
32
+ state: VoiceActionIntentState;
33
+ binding: VoiceActionIntentBinding;
34
+ now: string;
35
+ }): VoiceActionConfirmationDecision;
36
+ export type TransitionVoiceActionIntentResult = {
37
+ outcome: 'transitioned';
38
+ state: VoiceActionIntentState;
39
+ } | {
40
+ outcome: 'retry';
41
+ state: VoiceActionIntentState;
42
+ } | {
43
+ outcome: 'conflict';
44
+ reason: 'intent_binding_conflict' | 'terminal_receipt_conflict';
45
+ } | {
46
+ outcome: 'denied';
47
+ reason: 'intent_expired' | 'terminal_intent' | 'uncertain_requires_reconciliation';
48
+ };
49
+ export declare function transitionVoiceActionIntent({ state, transition }: {
50
+ state: VoiceActionIntentState;
51
+ transition: VoiceActionIntentTransition;
52
+ }): TransitionVoiceActionIntentResult;
@@ -0,0 +1,170 @@
1
+ import { voiceTimestampSchema } from './voice-common.js';
2
+ import { sameVoiceResource } from './voice-authority-contracts.js';
3
+ import { voiceActionIntentBindingSchema, voiceActionIntentStateSchema, voiceActionIntentTransitionSchema, voicePrepareActionRequestSchema, voicePreparedActionIntentSchema, } from './voice-actions-contracts.js';
4
+ function sameCallSubject({ left, right }) {
5
+ return left.tenantId === right.tenantId &&
6
+ left.environmentId === right.environmentId &&
7
+ left.agentId === right.agentId &&
8
+ left.sessionId === right.sessionId &&
9
+ left.releaseId === right.releaseId;
10
+ }
11
+ function sameAuthoritySubject({ left, right }) {
12
+ if (left.kind !== right.kind)
13
+ return false;
14
+ if (left.kind === 'unverified' || right.kind === 'unverified') {
15
+ return left.kind === right.kind;
16
+ }
17
+ return sameVoiceResource({ left: left.resource, right: right.resource }) &&
18
+ left.verificationId === right.verificationId;
19
+ }
20
+ function bindingFromState({ state }) {
21
+ return {
22
+ intentId: state.intentId,
23
+ subject: state.subject,
24
+ actionAlias: state.actionAlias,
25
+ authoritySubject: state.authoritySubject,
26
+ argumentDigest: state.argumentDigest,
27
+ };
28
+ }
29
+ function sameIntentBinding({ left, right }) {
30
+ return left.intentId === right.intentId &&
31
+ sameCallSubject({ left: left.subject, right: right.subject }) &&
32
+ left.actionAlias === right.actionAlias &&
33
+ sameAuthoritySubject({ left: left.authoritySubject, right: right.authoritySubject }) &&
34
+ left.argumentDigest === right.argumentDigest;
35
+ }
36
+ export function prepareVoiceActionIntent({ request, existing }) {
37
+ const parsedRequest = voicePrepareActionRequestSchema.parse(request);
38
+ if (existing !== null) {
39
+ const parsedExisting = voiceActionIntentStateSchema.parse(existing);
40
+ return sameIntentBinding({
41
+ left: bindingFromState({ state: parsedExisting }), right: parsedRequest.binding,
42
+ })
43
+ ? { outcome: 'retry', state: parsedExisting }
44
+ : { outcome: 'conflict', reason: 'intent_binding_conflict' };
45
+ }
46
+ return {
47
+ outcome: 'prepared',
48
+ state: voicePreparedActionIntentSchema.parse({
49
+ ...parsedRequest.binding, state: 'prepared',
50
+ confirmationSummary: parsedRequest.confirmationSummary,
51
+ preparedAt: parsedRequest.preparedAt, expiresAt: parsedRequest.expiresAt,
52
+ }),
53
+ };
54
+ }
55
+ export function decideVoiceActionConfirmation({ state, binding, now }) {
56
+ const parsedState = voiceActionIntentStateSchema.parse(state);
57
+ const parsedBinding = voiceActionIntentBindingSchema.parse(binding);
58
+ const parsedNow = voiceTimestampSchema.parse(now);
59
+ if (!sameIntentBinding({ left: bindingFromState({ state: parsedState }),
60
+ right: parsedBinding })) {
61
+ return { decision: 'conflict', reason: 'intent_binding_conflict' };
62
+ }
63
+ if (parsedState.state === 'committed') {
64
+ return { decision: 'return_receipt', receipt: parsedState };
65
+ }
66
+ if (parsedState.state === 'cancelled') {
67
+ return { decision: 'denied', reason: 'intent_cancelled' };
68
+ }
69
+ if (parsedState.state === 'uncertain') {
70
+ return { decision: 'reconcile', reason: 'uncertain_outcome' };
71
+ }
72
+ return Date.parse(parsedNow) >= Date.parse(parsedState.expiresAt)
73
+ ? { decision: 'denied', reason: 'intent_expired' }
74
+ : { decision: 'dispatch' };
75
+ }
76
+ function sameCommittedReceipt({ state, transition }) {
77
+ return state.receiptId === transition.receiptId &&
78
+ state.resultDigest === transition.resultDigest &&
79
+ state.resultStatus === transition.resultStatus &&
80
+ state.committedAt === transition.occurredAt;
81
+ }
82
+ function sameCancellationReceipt({ state, transition }) {
83
+ return state.cancellationReceiptId === transition.cancellationReceiptId &&
84
+ state.cancellationResolution === transition.resolution &&
85
+ state.cancelledAt === transition.occurredAt;
86
+ }
87
+ function terminalTransition({ state, transition }) {
88
+ if (state.state === 'committed') {
89
+ if (transition.kind !== 'commit')
90
+ return { outcome: 'denied', reason: 'terminal_intent' };
91
+ return sameCommittedReceipt({ state, transition })
92
+ ? { outcome: 'retry', state }
93
+ : { outcome: 'conflict', reason: 'terminal_receipt_conflict' };
94
+ }
95
+ if (state.state === 'cancelled') {
96
+ if (transition.kind !== 'cancel')
97
+ return { outcome: 'denied', reason: 'terminal_intent' };
98
+ return sameCancellationReceipt({ state, transition })
99
+ ? { outcome: 'retry', state }
100
+ : { outcome: 'conflict', reason: 'terminal_receipt_conflict' };
101
+ }
102
+ return null;
103
+ }
104
+ function uncertaintyTransition({ state, transition }) {
105
+ if (state.state === 'uncertain') {
106
+ const same = state.dispatchAttemptId === transition.dispatchAttemptId &&
107
+ state.uncertainAt === transition.occurredAt;
108
+ return same ? { outcome: 'retry', state }
109
+ : { outcome: 'denied', reason: 'uncertain_requires_reconciliation' };
110
+ }
111
+ if (Date.parse(transition.occurredAt) >= Date.parse(state.expiresAt)) {
112
+ return { outcome: 'denied', reason: 'intent_expired' };
113
+ }
114
+ return {
115
+ outcome: 'transitioned',
116
+ state: {
117
+ ...bindingFromState({ state }), state: 'uncertain',
118
+ confirmationSummary: state.confirmationSummary, preparedAt: state.preparedAt,
119
+ expiresAt: state.expiresAt, dispatchAttemptId: transition.dispatchAttemptId,
120
+ uncertainAt: transition.occurredAt,
121
+ },
122
+ };
123
+ }
124
+ function commitTransition({ state, transition }) {
125
+ const expired = state.state === 'prepared' &&
126
+ Date.parse(transition.occurredAt) >= Date.parse(state.expiresAt);
127
+ if (expired)
128
+ return { outcome: 'denied', reason: 'intent_expired' };
129
+ return {
130
+ outcome: 'transitioned',
131
+ state: {
132
+ ...bindingFromState({ state }), state: 'committed', receiptId: transition.receiptId,
133
+ resultDigest: transition.resultDigest, resultStatus: transition.resultStatus,
134
+ committedAt: transition.occurredAt,
135
+ },
136
+ };
137
+ }
138
+ function cancelTransition({ state, transition }) {
139
+ const invalid = (state.state === 'uncertain' && transition.resolution !== 'confirmed_not_committed') ||
140
+ (state.state === 'prepared' && transition.resolution !== 'local_before_dispatch');
141
+ if (invalid)
142
+ return { outcome: 'denied', reason: 'uncertain_requires_reconciliation' };
143
+ return {
144
+ outcome: 'transitioned',
145
+ state: {
146
+ ...bindingFromState({ state }), state: 'cancelled',
147
+ cancellationReceiptId: transition.cancellationReceiptId,
148
+ cancellationResolution: transition.resolution, cancelledAt: transition.occurredAt,
149
+ },
150
+ };
151
+ }
152
+ export function transitionVoiceActionIntent({ state, transition }) {
153
+ const parsedState = voiceActionIntentStateSchema.parse(state);
154
+ const parsedTransition = voiceActionIntentTransitionSchema.parse(transition);
155
+ if (!sameIntentBinding({ left: bindingFromState({ state: parsedState }),
156
+ right: parsedTransition.binding })) {
157
+ return { outcome: 'conflict', reason: 'intent_binding_conflict' };
158
+ }
159
+ if (parsedState.state === 'committed' || parsedState.state === 'cancelled') {
160
+ const terminal = terminalTransition({ state: parsedState, transition: parsedTransition });
161
+ return terminal ?? { outcome: 'denied', reason: 'terminal_intent' };
162
+ }
163
+ if (parsedTransition.kind === 'mark_uncertain') {
164
+ return uncertaintyTransition({ state: parsedState, transition: parsedTransition });
165
+ }
166
+ if (parsedTransition.kind === 'commit') {
167
+ return commitTransition({ state: parsedState, transition: parsedTransition });
168
+ }
169
+ return cancelTransition({ state: parsedState, transition: parsedTransition });
170
+ }
@@ -0,0 +1,2 @@
1
+ export * from './voice-actions-contracts.js';
2
+ export * from './voice-actions-transitions.js';
@@ -0,0 +1,2 @@
1
+ export * from './voice-actions-contracts.js';
2
+ export * from './voice-actions-transitions.js';