@sequenceholdings/agent-spec 0.1.2 → 0.1.4

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 (76) hide show
  1. package/README.md +152 -0
  2. package/dist/agent-definition.d.ts +626 -0
  3. package/dist/agent-definition.js +250 -0
  4. package/dist/canonical-json.d.ts +2 -0
  5. package/dist/canonical-json.js +13 -0
  6. package/dist/client-proposals.d.ts +20 -0
  7. package/dist/client-proposals.js +172 -0
  8. package/dist/index.d.ts +4 -116
  9. package/dist/index.js +4 -247
  10. package/dist/input-schema.d.ts +19 -0
  11. package/dist/input-schema.js +57 -0
  12. package/dist/job-request-hash.d.ts +27 -0
  13. package/dist/job-request-hash.js +54 -0
  14. package/dist/voice-access.d.ts +40 -0
  15. package/dist/voice-access.js +34 -0
  16. package/dist/voice-actions-contracts.d.ts +423 -0
  17. package/dist/voice-actions-contracts.js +95 -0
  18. package/dist/voice-actions-transitions.d.ts +52 -0
  19. package/dist/voice-actions-transitions.js +170 -0
  20. package/dist/voice-actions.d.ts +2 -0
  21. package/dist/voice-actions.js +2 -0
  22. package/dist/voice-api.d.ts +1102 -0
  23. package/dist/voice-api.js +164 -0
  24. package/dist/voice-authoring.d.ts +463 -0
  25. package/dist/voice-authoring.js +132 -0
  26. package/dist/voice-authority-contracts.d.ts +247 -0
  27. package/dist/voice-authority-contracts.js +177 -0
  28. package/dist/voice-authority-evaluation.d.ts +29 -0
  29. package/dist/voice-authority-evaluation.js +80 -0
  30. package/dist/voice-authority-verification.d.ts +47 -0
  31. package/dist/voice-authority-verification.js +184 -0
  32. package/dist/voice-authority.d.ts +3 -0
  33. package/dist/voice-authority.js +3 -0
  34. package/dist/voice-common.d.ts +21 -0
  35. package/dist/voice-common.js +23 -0
  36. package/dist/voice-drafts.d.ts +441 -0
  37. package/dist/voice-drafts.js +75 -0
  38. package/dist/voice-grant.d.ts +19 -0
  39. package/dist/voice-grant.js +21 -0
  40. package/dist/voice-lifecycle-control.d.ts +130 -0
  41. package/dist/voice-lifecycle-control.js +138 -0
  42. package/dist/voice-lifecycle-session.d.ts +168 -0
  43. package/dist/voice-lifecycle-session.js +114 -0
  44. package/dist/voice-lifecycle-states.d.ts +96 -0
  45. package/dist/voice-lifecycle-states.js +139 -0
  46. package/dist/voice-lifecycle.d.ts +3 -0
  47. package/dist/voice-lifecycle.js +3 -0
  48. package/dist/voice-policy-duration.d.ts +46 -0
  49. package/dist/voice-policy-duration.js +166 -0
  50. package/dist/voice-policy-limits.d.ts +174 -0
  51. package/dist/voice-policy-limits.js +188 -0
  52. package/dist/voice-policy.d.ts +2 -0
  53. package/dist/voice-policy.js +2 -0
  54. package/dist/voice-provider-evidence.d.ts +80 -0
  55. package/dist/voice-provider-evidence.js +115 -0
  56. package/dist/voice-provider-publication.d.ts +319 -0
  57. package/dist/voice-provider-publication.js +117 -0
  58. package/dist/voice-provider-release.d.ts +386 -0
  59. package/dist/voice-provider-release.js +154 -0
  60. package/dist/voice-provider.d.ts +3 -0
  61. package/dist/voice-provider.js +3 -0
  62. package/dist/voice-release.d.ts +808 -0
  63. package/dist/voice-release.js +110 -0
  64. package/dist/voice-runs-audio.d.ts +157 -0
  65. package/dist/voice-runs-audio.js +85 -0
  66. package/dist/voice-runs-evidence.d.ts +183 -0
  67. package/dist/voice-runs-evidence.js +154 -0
  68. package/dist/voice-runs-model.d.ts +967 -0
  69. package/dist/voice-runs-model.js +199 -0
  70. package/dist/voice-runs-tooling.d.ts +88 -0
  71. package/dist/voice-runs-tooling.js +100 -0
  72. package/dist/voice-runs.d.ts +4 -0
  73. package/dist/voice-runs.js +4 -0
  74. package/dist/voice.d.ts +13 -0
  75. package/dist/voice.js +13 -0
  76. package/package.json +8 -3
package/README.md CHANGED
@@ -5,6 +5,12 @@ Preview SDK for authoring typed Sequence agent definitions.
5
5
  The package is versioned independently and its API may change before a stable
6
6
  release. Use Node.js 20 or later.
7
7
 
8
+ Agents is a workflow-agnostic platform primitive. The schema, runtime, and
9
+ deployment path own generic agent capabilities; deployed agent bundles own
10
+ prompts, tools, and product behavior. Primitive code must not branch on an
11
+ agent ID or product identity. See
12
+ [Platform primitive boundaries](../../../docs/platform/platform-primitives.md).
13
+
8
14
  ## Install
9
15
 
10
16
  ```bash
@@ -28,6 +34,79 @@ Definitions must be pure data literals: do not read environment variables, call
28
34
  functions, or compute fields in `agent.ts`. Keep deployment targeting separate
29
35
  from a definition, then use `seq-studio agents validate`, `plan`, and `apply`.
30
36
 
37
+ ## Require a declared dependency
38
+
39
+ Declared MCP servers, skills, and subagents are optional by default: when the
40
+ caller cannot use one, that run proceeds without it and records why. List a
41
+ dependency in `requiredReferences` when the agent must refuse to run, before
42
+ any model call, if it is unavailable:
43
+
44
+ ```ts
45
+ mcpServers: ['support-data'],
46
+ requiredReferences: [{ kind: 'mcp_server', id: 'support-data' }],
47
+ ```
48
+
49
+ Each entry must also be declared in its matching `mcpServers`, `skills`,
50
+ `subagents`, or `managedFunctions` list. Valid kinds are `mcp_server`, `skill`,
51
+ `subagent`, and `managed_function`. `requiredMcpServers` remains supported and
52
+ means the same as listing those servers here.
53
+
54
+ ## Call Managed Functions as tools
55
+
56
+ List Managed Functions by slug (or id) in `managedFunctions` to give the agent
57
+ one tool per function, named `call_function_<slug>`:
58
+
59
+ ```ts
60
+ managedFunctions: ['loan-lookup'],
61
+ requiredReferences: [{ kind: 'managed_function', id: 'loan-lookup' }],
62
+ ```
63
+
64
+ Each call runs as whoever runs the agent: the person in chat, or the step's
65
+ service account in a Lattice process. That principal needs its own `invoker`
66
+ grant on the function; listing a function on an agent never grants it. A run
67
+ with no such identity, such as a Lattice step without
68
+ `run_as.service_account`, gets no function tools and records each function as
69
+ unavailable (`no_user_identity`).
70
+
71
+ ## Author client proposals (preview)
72
+
73
+ The upcoming `0.1.4` release adds optional `clientProposals` to text agent
74
+ definitions. Each literal descriptor supplies its exact tool name, description
75
+ and a bounded JSON input schema:
76
+
77
+ ```ts
78
+ clientProposals: [{
79
+ name: 'propose_label',
80
+ description: 'Propose a support label for the user to review.',
81
+ inputSchema: {
82
+ type: 'object',
83
+ properties: { label: { type: 'string', enum: ['ready', 'needs-review'] } },
84
+ required: ['label'],
85
+ additionalProperties: false,
86
+ },
87
+ }],
88
+ ```
89
+
90
+ `clientProposalSchema`, `clientProposalsSchema` and the `ClientProposal` type
91
+ are root exports. Definitions accept at most 64 uniquely named proposals,
92
+ 32,000 characters per description, 128 KiB per input schema and 512 KiB for all
93
+ descriptors. Schemas are limited to depth 32 and 10,000 nodes. They use a finite
94
+ JSON Schema subset: executable values and unsupported keywords such as
95
+ `pattern`, `format`, `default` and `$ref` are rejected. Schema URL annotations
96
+ are never fetched. Keep descriptors as authored literals so their exact
97
+ instructions and schemas enter the captured execution definition. Omitting
98
+ the field preserves existing definition hashes.
99
+
100
+ The matching Vercel-framework runtime validates arguments, bounded to 256 KiB,
101
+ depth 64, 50,000 nodes and 100,000 validation work units, then returns
102
+ `{ status: 'pending_client_review', applied: false }`. This acknowledgement
103
+ proves neither a backend apply nor client delivery. It does not execute a
104
+ provider call or authorize a mutation.
105
+ The application owns proposal rendering, validation, human review and any
106
+ separate authorized write. Proposal names that collide with another resolved
107
+ tool are rejected. Confirm package publication and matching runtime support
108
+ before relying on this preview contract.
109
+
31
110
  ## Exports
32
111
 
33
112
  - `@sequenceholdings/agent-spec` provides `defineAgent`,
@@ -37,3 +116,76 @@ from a definition, then use `seq-studio agents validate`, `plan`, and `apply`.
37
116
  imports or executes agent source.
38
117
  - `@sequenceholdings/agent-spec/yaml` provides `parseYamlAgent` only for
39
118
  migrating legacy YAML definitions.
119
+
120
+ ## Job request fingerprints (preview)
121
+
122
+ The upcoming `0.1.4` release adds `hashJobCreateRequest` at the package root.
123
+ Confirm registry publication before installing that version. This pure helper
124
+ hashes the job kind, resource ID, expected source identity and exact parsed
125
+ payload using the platform's versioned request format. It sorts object keys
126
+ while preserving array order and string bytes. `normalizeJobRequestJson`
127
+ normalizes dates to ISO strings and omits undefined object fields; non-JSON,
128
+ cyclic, excessively nested or oversized input is refused with
129
+ `JobRequestHashError` (`status` 400 or 413). The serialized input is bounded
130
+ to 16 MiB.
131
+
132
+ The fingerprint excludes transport credentials and caller identity. It is not
133
+ an authorization grant, an admission receipt, proof that a job ran, or an
134
+ application's business-source association. An application comparing an
135
+ authorized admission receipt must still verify the actual caller, current
136
+ protected intent, expected source identity and recorded job separately. Use
137
+ the exact parsed request payload, not a display projection or reconstructed
138
+ subset.
139
+
140
+ ## Voice definitions (preview)
141
+
142
+ Choose either `text` or `voice` when creating an Agent. Definitions without `mode` retain their existing text defaults, source format, and bundle hashes. `validateAgentModeUpdate` rejects changing an existing Agent's mode in either direction. Voice uses the same identity, prompt, model, native Skill references, permissions, source compiler, and bundle hashing as text; its supported authoring fields are deliberately smaller.
143
+
144
+ ```ts
145
+ import { defineAgent } from '@sequenceholdings/agent-spec'
146
+
147
+ export const assistant = defineAgent({
148
+ id: '680000000000000000000002',
149
+ name: 'Voice Assistant',
150
+ mode: 'voice',
151
+ model: { provider: 'supported-provider', name: 'supported-model' },
152
+ systemPrompt: 'Be helpful. Answer general questions using these reviewed public facts.',
153
+ skills: ['example-welcome-skill'],
154
+ voice: {
155
+ schemaVersion: '1',
156
+ voice: 'supported-voice',
157
+ language: 'en',
158
+ firstMessage: 'Hello. How can I help?',
159
+ procedures: [{
160
+ key: 'welcome',
161
+ name: 'Welcome',
162
+ instructions: '# Welcome\nAsk how you can help.\n',
163
+ activationDescription: 'When a conversation begins.',
164
+ source: { skillId: 'example-welcome-skill' },
165
+ toolAliases: [],
166
+ subprocedures: [],
167
+ }],
168
+ tools: [],
169
+ },
170
+ })
171
+ ```
172
+
173
+ Model and voice names in this example are placeholders for the server-supported catalog. `validateVoiceAuthoringOptions` checks that catalog; syntactic validation alone does not authorize a model, function, deployment, or call. Runtime identities, environment settings, phone numbers, credentials, provider resources, raw provider configuration, and tool-review assertions are excluded from the authored definition. Text execution settings such as MCP servers, subagents, and framework overrides are rejected on Voice Agents.
174
+
175
+ Each captured procedure preserves exact Markdown, its name, activation description, native source identity, required tool aliases, and local subprocedure references. `contentHash` is recomputed from the captured name and instructions; it is not a native Skill version. Procedure keys, dependency sets, tool aliases, and field mappings have canonical ordering. Duplicate, missing, and cyclic dependencies fail validation. An empty activation description is allowed for a procedure referenced by another declared procedure. Saving a library Skill does not update captured content; an authorized explicit capture/refresh updates a draft. Consumers enforce current source permissions and optimistic revisions before persistence.
176
+
177
+ Authored tools reference an existing Managed Function and operation. Optional input/output mappings support top-level field renames only; input mappings map public `argument` to function `parameter`, and output mappings map function `field` to public `result`. Empty mappings preserve the reviewed operation schema's existing public field names. Publication must validate every mapping against that operation's current input/output schemas and reserved runtime fields. Executable schemas and authority requirements come from the reviewed server catalog, not the author. `projectVoiceAuthoring` produces a deterministic local digest; it makes no promise that a future provider compilation will produce identical output.
178
+
179
+ The root export also provides `VoiceAuthoringService` and `VoiceCallService` interfaces and strict contracts for drafts, publication, call admission, tool authority, verification, action receipts, operator limits, provider evidence, completed runs, and authorized audio responses. Publication validation presents both each concrete function binding and its operation policy; `hashVoiceToolReviewBinding` binds reviewer confirmation to both. These are data contracts and pure validation/transition helpers. Their consumers must implement current authorization, transactional claims, durable idempotency, provider verification, and persistence. A state transition helper does not perform those checks or an external action.
180
+
181
+ Publication validation includes the current deployment revision and active release so consumers can construct a compare-and-swap request. Publication status separately reports the current deployment revision, admission enablement and pause flags. `voiceAgentDisableRequestSchema` accepts only an Agent ID and expected revision; its response contract reports closed admission and preserved pause state. These schemas neither enable a deployment nor cancel existing calls.
182
+
183
+ This package slice supports offline authoring, validation, and export. Generic Agent deployment and ordinary text create/update reject Voice; its dedicated publication path owns provider and runtime authorization. Importing these contracts requires no Voice settings, provider credentials, or database connection. They do not provision resources or enable phone calls.
184
+
185
+ ### Browser audio-read contract
186
+
187
+ Import `voiceAudioReadRequestSchema`, `voiceAudioReadResponseSchema` and
188
+ `voiceAudioCapabilitySchema` from `@sequenceholdings/agent-spec/voice-runs-audio`
189
+ when validating Voice recording metadata in a browser. This narrow entry point
190
+ avoids the Node-only compiler/hash exports at the package root. It defines
191
+ metadata and delivery limits, not provider credentials or an audio transport.