@vorim/sdk 3.18.2 → 3.20.0

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 (109) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +73 -1
  3. package/dist/index.cjs +145 -7
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.cts +111 -3
  6. package/dist/index.d.ts +111 -3
  7. package/dist/index.js +138 -7
  8. package/dist/index.js.map +1 -1
  9. package/dist/integrations/anthropic.d.cts +1 -1
  10. package/dist/integrations/anthropic.d.ts +1 -1
  11. package/dist/integrations/ap2.d.cts +1 -1
  12. package/dist/integrations/ap2.d.ts +1 -1
  13. package/dist/integrations/aws-iam.d.cts +1 -1
  14. package/dist/integrations/aws-iam.d.ts +1 -1
  15. package/dist/integrations/bank-rails.d.cts +1 -1
  16. package/dist/integrations/bank-rails.d.ts +1 -1
  17. package/dist/integrations/circle.d.cts +1 -1
  18. package/dist/integrations/circle.d.ts +1 -1
  19. package/dist/integrations/cloudflare.d.cts +1 -1
  20. package/dist/integrations/cloudflare.d.ts +1 -1
  21. package/dist/integrations/coinbase-cdp.d.cts +1 -1
  22. package/dist/integrations/coinbase-cdp.d.ts +1 -1
  23. package/dist/integrations/commerce-agents.cjs +467 -0
  24. package/dist/integrations/commerce-agents.cjs.map +1 -0
  25. package/dist/integrations/commerce-agents.d.cts +199 -0
  26. package/dist/integrations/commerce-agents.d.ts +199 -0
  27. package/dist/integrations/commerce-agents.js +429 -0
  28. package/dist/integrations/commerce-agents.js.map +1 -0
  29. package/dist/integrations/crewai.d.cts +1 -1
  30. package/dist/integrations/crewai.d.ts +1 -1
  31. package/dist/integrations/entra.d.cts +1 -1
  32. package/dist/integrations/entra.d.ts +1 -1
  33. package/dist/integrations/fhir.d.cts +1 -1
  34. package/dist/integrations/fhir.d.ts +1 -1
  35. package/dist/integrations/grok.d.cts +1 -1
  36. package/dist/integrations/grok.d.ts +1 -1
  37. package/dist/integrations/guidewire.d.cts +1 -1
  38. package/dist/integrations/guidewire.d.ts +1 -1
  39. package/dist/integrations/hermes.d.cts +1 -1
  40. package/dist/integrations/hermes.d.ts +1 -1
  41. package/dist/integrations/jira.cjs +190 -0
  42. package/dist/integrations/jira.cjs.map +1 -0
  43. package/dist/integrations/jira.d.cts +162 -0
  44. package/dist/integrations/jira.d.ts +162 -0
  45. package/dist/integrations/jira.js +164 -0
  46. package/dist/integrations/jira.js.map +1 -0
  47. package/dist/integrations/langchain.d.cts +1 -1
  48. package/dist/integrations/langchain.d.ts +1 -1
  49. package/dist/integrations/langgraph.d.cts +1 -1
  50. package/dist/integrations/langgraph.d.ts +1 -1
  51. package/dist/integrations/legal.d.cts +1 -1
  52. package/dist/integrations/legal.d.ts +1 -1
  53. package/dist/integrations/life-sciences.d.cts +1 -1
  54. package/dist/integrations/life-sciences.d.ts +1 -1
  55. package/dist/integrations/linear.cjs +193 -0
  56. package/dist/integrations/linear.cjs.map +1 -0
  57. package/dist/integrations/linear.d.cts +173 -0
  58. package/dist/integrations/linear.d.ts +173 -0
  59. package/dist/integrations/linear.js +167 -0
  60. package/dist/integrations/linear.js.map +1 -0
  61. package/dist/integrations/lithic.d.cts +1 -1
  62. package/dist/integrations/lithic.d.ts +1 -1
  63. package/dist/integrations/llamaindex.d.cts +1 -1
  64. package/dist/integrations/llamaindex.d.ts +1 -1
  65. package/dist/integrations/marqeta.d.cts +1 -1
  66. package/dist/integrations/marqeta.d.ts +1 -1
  67. package/dist/integrations/modern-treasury.d.cts +1 -1
  68. package/dist/integrations/modern-treasury.d.ts +1 -1
  69. package/dist/integrations/nekuda.d.cts +1 -1
  70. package/dist/integrations/nekuda.d.ts +1 -1
  71. package/dist/integrations/okta.d.cts +1 -1
  72. package/dist/integrations/okta.d.ts +1 -1
  73. package/dist/integrations/openai.d.cts +1 -1
  74. package/dist/integrations/openai.d.ts +1 -1
  75. package/dist/integrations/openrouter.d.cts +1 -1
  76. package/dist/integrations/openrouter.d.ts +1 -1
  77. package/dist/integrations/paypal-agent.d.cts +1 -1
  78. package/dist/integrations/paypal-agent.d.ts +1 -1
  79. package/dist/integrations/perplexity.cjs +430 -0
  80. package/dist/integrations/perplexity.cjs.map +1 -0
  81. package/dist/integrations/perplexity.d.cts +65 -0
  82. package/dist/integrations/perplexity.d.ts +65 -0
  83. package/dist/integrations/perplexity.js +388 -0
  84. package/dist/integrations/perplexity.js.map +1 -0
  85. package/dist/integrations/plaid.d.cts +1 -1
  86. package/dist/integrations/plaid.d.ts +1 -1
  87. package/dist/integrations/ramp.d.cts +1 -1
  88. package/dist/integrations/ramp.d.ts +1 -1
  89. package/dist/integrations/shopify.d.cts +1 -1
  90. package/dist/integrations/shopify.d.ts +1 -1
  91. package/dist/integrations/siem.d.cts +1 -1
  92. package/dist/integrations/siem.d.ts +1 -1
  93. package/dist/integrations/skyfire.d.cts +1 -1
  94. package/dist/integrations/skyfire.d.ts +1 -1
  95. package/dist/integrations/stripe-acp.d.cts +1 -1
  96. package/dist/integrations/stripe-acp.d.ts +1 -1
  97. package/dist/integrations/stripe-issuing.d.cts +1 -1
  98. package/dist/integrations/stripe-issuing.d.ts +1 -1
  99. package/dist/integrations/truanon.d.cts +1 -1
  100. package/dist/integrations/truanon.d.ts +1 -1
  101. package/dist/integrations/ucp.d.cts +1 -1
  102. package/dist/integrations/ucp.d.ts +1 -1
  103. package/dist/integrations/vercel-ai.d.cts +1 -1
  104. package/dist/integrations/vercel-ai.d.ts +1 -1
  105. package/dist/integrations/x402.d.cts +1 -1
  106. package/dist/integrations/x402.d.ts +1 -1
  107. package/dist/{types-Lp1iHEDz.d.cts → types-BmeluKHI.d.cts} +1 -1
  108. package/dist/{types-Lp1iHEDz.d.ts → types-BmeluKHI.d.ts} +1 -1
  109. package/package.json +41 -1
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as AgentRegistrationResult, R as RuntimeDecision, b as AgentRegistrationInput, T as TrustRecord, c as Agent, P as PermissionScope, d as PermissionCheckResult, D as DelegationLinkClaims, e as AgentDelegationRecord, W as WorkflowProvenanceGraph, C as CapabilityProfile, S as SharedMemoryWriteInput, f as SharedMemoryEntry, g as SharedMemoryListResult, B as BeforeActionInput, h as TokenBudgetInput, i as TokenBudget, j as BudgetSpend, a as AuditEventInput } from './types-Lp1iHEDz.cjs';
2
- export { k as AgentStatus, l as AuditEventType, m as AuditResult, n as BudgetEnforcement, o as BudgetScope, p as DecisionVerdict, q as WorkflowGraphEdge, r as WorkflowGraphEvent, s as WorkflowGraphNode } from './types-Lp1iHEDz.cjs';
1
+ import { A as AgentRegistrationResult, R as RuntimeDecision, a as AgentRegistrationInput, T as TrustRecord, b as Agent, P as PermissionScope, c as PermissionCheckResult, D as DelegationLinkClaims, d as AgentDelegationRecord, W as WorkflowProvenanceGraph, C as CapabilityProfile, S as SharedMemoryWriteInput, e as SharedMemoryEntry, f as SharedMemoryListResult, B as BeforeActionInput, g as TokenBudgetInput, h as TokenBudget, i as BudgetSpend, j as AuditEventInput } from './types-BmeluKHI.cjs';
2
+ export { k as AgentStatus, l as AuditEventType, m as AuditResult, n as BudgetEnforcement, o as BudgetScope, p as DecisionVerdict, q as WorkflowGraphEdge, r as WorkflowGraphEvent, s as WorkflowGraphNode } from './types-BmeluKHI.cjs';
3
3
 
4
4
  /**
5
5
  * Replayable agent decision evidence helpers.
@@ -133,6 +133,55 @@ interface ReplayContext {
133
133
  */
134
134
  declare function prepareReplayContext(inputs: ReplayInputs): Promise<ReplayContext>;
135
135
 
136
+ /** Prefix used for keyed commitments. */
137
+ declare const HMAC_SHA256_PREFIX = "hmac-sha256:";
138
+ /** Prefix used for bare digests. */
139
+ declare const SHA256_PREFIX = "sha256:";
140
+ /**
141
+ * Key material for a payload commitment. Never transmitted by the SDK.
142
+ *
143
+ * A string is UTF-8 encoded. Prefer at least 32 bytes from a CSPRNG, held
144
+ * wherever you already hold secrets. One key per org is fine; one per agent
145
+ * or per tenant narrows what a single leaked key exposes.
146
+ */
147
+ type CommitmentKey = string | Uint8Array;
148
+ /**
149
+ * Bare SHA-256 digest of `content`, as `sha256:<hex>`.
150
+ *
151
+ * Correct only when `content` has enough entropy that guessing it is
152
+ * infeasible. For prompts, responses, tool arguments or anything else a
153
+ * human or a model wrote, use {@link commitPayload} instead.
154
+ */
155
+ declare function hashPayload(content: string | Uint8Array): Promise<string>;
156
+ /**
157
+ * Keyed commitment to `content`, as `hmac-sha256:<hex>`.
158
+ *
159
+ * `key` never leaves this process. Vorim stores and signs over the digest
160
+ * with no way to test a candidate plaintext against it.
161
+ *
162
+ * To disclose later, hand the verifier the content and the key; they
163
+ * recompute and compare. Disclosure is per-key, so a key scoped to one agent
164
+ * or one tenant lets you open that subset without opening the rest.
165
+ *
166
+ * Rotating the key does not invalidate past events. Old digests stay
167
+ * verifiable under the old key, which is why the key you used has to be
168
+ * retained for as long as you might need to prove the events it covers.
169
+ */
170
+ declare function commitPayload(content: string | Uint8Array, key: CommitmentKey): Promise<string>;
171
+ /**
172
+ * True when `digest` is a keyed commitment rather than a bare hash.
173
+ *
174
+ * Useful in a review or an export check: a bundle whose `input_hash` values
175
+ * are all `sha256:` carries content that a determined reader may be able to
176
+ * recover, and that is worth knowing before the bundle leaves the building.
177
+ */
178
+ declare function isKeyedCommitment(digest: unknown): boolean;
179
+ /**
180
+ * True when `digest` is a well-formed `<alg>:<64 hex>` value in a form the
181
+ * server and `@vorim/verify` both understand.
182
+ */
183
+ declare function isDigest(digest: unknown): boolean;
184
+
136
185
  interface VorimConfig {
137
186
  apiKey: string;
138
187
  baseUrl?: string;
@@ -164,6 +213,37 @@ interface VorimConfig {
164
213
  * a failure). Chain integrity is checked by `@vorim/verify`.
165
214
  */
166
215
  chainEvents?: boolean;
216
+ /**
217
+ * Refuse to transmit agent content. Default `false`.
218
+ *
219
+ * Vorim's event schema was already digest-shaped: `input_hash`,
220
+ * `output_hash` and `system_prompt_hash` are the fields prompts and
221
+ * responses are meant to travel as. Nothing enforced it, though. `metadata`
222
+ * is `Record<string, unknown>`, so a caller could put a whole prompt in it
223
+ * without noticing, and "we never receive your content" was a property of
224
+ * how you happened to call the SDK rather than a guarantee.
225
+ *
226
+ * With `noPayload` on, {@link VorimSDK.emit} and {@link VorimSDK.emitBatch}
227
+ * throw before anything is sent when an event would carry content:
228
+ *
229
+ * - any `metadata` value that is not a string, number, boolean or null
230
+ * (objects and arrays can nest arbitrary text)
231
+ * - any `metadata` string longer than `maxMetadataChars` (default 256)
232
+ * - any hash field that is not a well-formed `sha256:` / `hmac-sha256:`
233
+ * digest, which catches a raw prompt passed to `input_hash`
234
+ *
235
+ * This is distinct from the server-side Zero Data Retention setting. ZDR
236
+ * drops `metadata` at persistence, so the content still crossed the network
237
+ * and passed through our process. `noPayload` means it never left yours.
238
+ * Enterprises asking "can we send you nothing?" are asking for this one.
239
+ *
240
+ * It does not restrict `action` or `resource`. Both are short structural
241
+ * identifiers, both are covered by the v1 signature, and stripping them
242
+ * would break bundle verification. Keep tool names in them, not arguments.
243
+ */
244
+ noPayload?: boolean | {
245
+ maxMetadataChars?: number;
246
+ };
167
247
  /**
168
248
  * Client-side fail-open behaviour for {@link VorimSDK.beforeAction} when
169
249
  * the runtime decision API itself is unreachable (network error, DNS,
@@ -203,6 +283,21 @@ declare function canonicalPayloadV0(event: AuditEventInput): string;
203
283
  * script enforces equivalence with the Python SDK.
204
284
  */
205
285
  declare function canonicalPayloadV1(event: AuditEventInput): string;
286
+ /**
287
+ * Stable content digest of an audit event: `sha256:<hex>` over the event's
288
+ * canonical bytes, dispatched on `canonical_form` the same way signing is.
289
+ *
290
+ * Byte-identical to `eventDigest` in `@vorim/verify` and to the digest the
291
+ * server returns from `POST /audit/events`, so a counterparty can bind to a
292
+ * reference you computed locally without trusting either of us to compute it.
293
+ * It is also what `prev_event_hash` references, so a hash-chained emitter is
294
+ * already producing these whether it names them or not.
295
+ *
296
+ * Content digest, not an identity: two byte-identical events share one
297
+ * digest. Pair it with the `event_id` the server returns when you need a
298
+ * unique handle.
299
+ */
300
+ declare function eventDigest(event: AuditEventInput): Promise<string>;
206
301
  declare class VorimSDK {
207
302
  private apiKey;
208
303
  private baseUrl;
@@ -211,6 +306,8 @@ declare class VorimSDK {
211
306
  private canonicalForm;
212
307
  private chainEvents;
213
308
  private runtimeFailOpen;
309
+ private noPayload;
310
+ private maxMetadataChars;
214
311
  /**
215
312
  * In-memory keyring mapping agent_id -> PEM-encoded Ed25519 private key.
216
313
  * Populated automatically by register() and registerEphemeral(), or
@@ -670,6 +767,7 @@ declare class VorimSDK {
670
767
  */
671
768
  emit(event: AuditEventInput, options?: {
672
769
  sign?: boolean;
770
+ idempotencyKey?: string;
673
771
  }): Promise<{
674
772
  ingested: number;
675
773
  }>;
@@ -685,6 +783,7 @@ declare class VorimSDK {
685
783
  */
686
784
  emitBatch(events: AuditEventInput[], options?: {
687
785
  sign?: boolean;
786
+ idempotencyKey?: string;
688
787
  }): Promise<{
689
788
  ingested: number;
690
789
  }>;
@@ -712,6 +811,15 @@ declare class VorimSDK {
712
811
  * - Chain ops are serialised per-agent via `chainLocks` so
713
812
  * concurrent emits to the same agent build a deterministic chain.
714
813
  */
814
+ /**
815
+ * Fail closed when `noPayload` is on and an event would carry content.
816
+ *
817
+ * Runs before signing and before any network call, so a rejected event is
818
+ * one Vorim never saw. Throwing rather than stripping is deliberate: a
819
+ * silent strip would leave the caller believing they had logged something
820
+ * they had not, and would change the bytes after they were signed.
821
+ */
822
+ private assertNoPayload;
715
823
  private prepareEvent;
716
824
  /** Serialise per-agent and apply chain hash + sign. */
717
825
  private prepareEventChained;
@@ -924,4 +1032,4 @@ interface DeviceLoginResult {
924
1032
  */
925
1033
  declare function deviceLogin(opts: DeviceLoginOptions): Promise<DeviceLoginResult>;
926
1034
 
927
- export { Agent, AgentDelegationRecord, AgentRegistrationInput, AgentRegistrationResult, AuditEventInput, BeforeActionInput, BudgetSpend, CANONICAL_TOOL_CATALOGUE_VERSION, type CatalogueTool, DelegationLinkClaims, type DeviceLoginOptions, type DeviceLoginResult, PermissionCheckResult, PermissionScope, type ReplayContext, type ReplayInputs, RuntimeDecision, SharedMemoryEntry, SharedMemoryListResult, SharedMemoryWriteInput, TokenBudget, TokenBudgetInput, TrustRecord, type VorimConfig, VorimDeniedError, VorimError, VorimSDK, WorkflowProvenanceGraph, canonicalPayloadV0, canonicalPayloadV1, createVorim as default, deviceLogin, hashPreviousEvent, hashSystemPrompt, hashTool, hashToolCatalogue, jcsCanonicalise, prepareReplayContext };
1035
+ export { Agent, AgentDelegationRecord, AgentRegistrationInput, AgentRegistrationResult, AuditEventInput, BeforeActionInput, BudgetSpend, CANONICAL_TOOL_CATALOGUE_VERSION, type CatalogueTool, type CommitmentKey, DelegationLinkClaims, type DeviceLoginOptions, type DeviceLoginResult, HMAC_SHA256_PREFIX, PermissionCheckResult, PermissionScope, type ReplayContext, type ReplayInputs, RuntimeDecision, SHA256_PREFIX, SharedMemoryEntry, SharedMemoryListResult, SharedMemoryWriteInput, TokenBudget, TokenBudgetInput, TrustRecord, type VorimConfig, VorimDeniedError, VorimError, VorimSDK, WorkflowProvenanceGraph, canonicalPayloadV0, canonicalPayloadV1, commitPayload, createVorim as default, deviceLogin, eventDigest, hashPayload, hashPreviousEvent, hashSystemPrompt, hashTool, hashToolCatalogue, isDigest, isKeyedCommitment, jcsCanonicalise, prepareReplayContext };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as AgentRegistrationResult, R as RuntimeDecision, b as AgentRegistrationInput, T as TrustRecord, c as Agent, P as PermissionScope, d as PermissionCheckResult, D as DelegationLinkClaims, e as AgentDelegationRecord, W as WorkflowProvenanceGraph, C as CapabilityProfile, S as SharedMemoryWriteInput, f as SharedMemoryEntry, g as SharedMemoryListResult, B as BeforeActionInput, h as TokenBudgetInput, i as TokenBudget, j as BudgetSpend, a as AuditEventInput } from './types-Lp1iHEDz.js';
2
- export { k as AgentStatus, l as AuditEventType, m as AuditResult, n as BudgetEnforcement, o as BudgetScope, p as DecisionVerdict, q as WorkflowGraphEdge, r as WorkflowGraphEvent, s as WorkflowGraphNode } from './types-Lp1iHEDz.js';
1
+ import { A as AgentRegistrationResult, R as RuntimeDecision, a as AgentRegistrationInput, T as TrustRecord, b as Agent, P as PermissionScope, c as PermissionCheckResult, D as DelegationLinkClaims, d as AgentDelegationRecord, W as WorkflowProvenanceGraph, C as CapabilityProfile, S as SharedMemoryWriteInput, e as SharedMemoryEntry, f as SharedMemoryListResult, B as BeforeActionInput, g as TokenBudgetInput, h as TokenBudget, i as BudgetSpend, j as AuditEventInput } from './types-BmeluKHI.js';
2
+ export { k as AgentStatus, l as AuditEventType, m as AuditResult, n as BudgetEnforcement, o as BudgetScope, p as DecisionVerdict, q as WorkflowGraphEdge, r as WorkflowGraphEvent, s as WorkflowGraphNode } from './types-BmeluKHI.js';
3
3
 
4
4
  /**
5
5
  * Replayable agent decision evidence helpers.
@@ -133,6 +133,55 @@ interface ReplayContext {
133
133
  */
134
134
  declare function prepareReplayContext(inputs: ReplayInputs): Promise<ReplayContext>;
135
135
 
136
+ /** Prefix used for keyed commitments. */
137
+ declare const HMAC_SHA256_PREFIX = "hmac-sha256:";
138
+ /** Prefix used for bare digests. */
139
+ declare const SHA256_PREFIX = "sha256:";
140
+ /**
141
+ * Key material for a payload commitment. Never transmitted by the SDK.
142
+ *
143
+ * A string is UTF-8 encoded. Prefer at least 32 bytes from a CSPRNG, held
144
+ * wherever you already hold secrets. One key per org is fine; one per agent
145
+ * or per tenant narrows what a single leaked key exposes.
146
+ */
147
+ type CommitmentKey = string | Uint8Array;
148
+ /**
149
+ * Bare SHA-256 digest of `content`, as `sha256:<hex>`.
150
+ *
151
+ * Correct only when `content` has enough entropy that guessing it is
152
+ * infeasible. For prompts, responses, tool arguments or anything else a
153
+ * human or a model wrote, use {@link commitPayload} instead.
154
+ */
155
+ declare function hashPayload(content: string | Uint8Array): Promise<string>;
156
+ /**
157
+ * Keyed commitment to `content`, as `hmac-sha256:<hex>`.
158
+ *
159
+ * `key` never leaves this process. Vorim stores and signs over the digest
160
+ * with no way to test a candidate plaintext against it.
161
+ *
162
+ * To disclose later, hand the verifier the content and the key; they
163
+ * recompute and compare. Disclosure is per-key, so a key scoped to one agent
164
+ * or one tenant lets you open that subset without opening the rest.
165
+ *
166
+ * Rotating the key does not invalidate past events. Old digests stay
167
+ * verifiable under the old key, which is why the key you used has to be
168
+ * retained for as long as you might need to prove the events it covers.
169
+ */
170
+ declare function commitPayload(content: string | Uint8Array, key: CommitmentKey): Promise<string>;
171
+ /**
172
+ * True when `digest` is a keyed commitment rather than a bare hash.
173
+ *
174
+ * Useful in a review or an export check: a bundle whose `input_hash` values
175
+ * are all `sha256:` carries content that a determined reader may be able to
176
+ * recover, and that is worth knowing before the bundle leaves the building.
177
+ */
178
+ declare function isKeyedCommitment(digest: unknown): boolean;
179
+ /**
180
+ * True when `digest` is a well-formed `<alg>:<64 hex>` value in a form the
181
+ * server and `@vorim/verify` both understand.
182
+ */
183
+ declare function isDigest(digest: unknown): boolean;
184
+
136
185
  interface VorimConfig {
137
186
  apiKey: string;
138
187
  baseUrl?: string;
@@ -164,6 +213,37 @@ interface VorimConfig {
164
213
  * a failure). Chain integrity is checked by `@vorim/verify`.
165
214
  */
166
215
  chainEvents?: boolean;
216
+ /**
217
+ * Refuse to transmit agent content. Default `false`.
218
+ *
219
+ * Vorim's event schema was already digest-shaped: `input_hash`,
220
+ * `output_hash` and `system_prompt_hash` are the fields prompts and
221
+ * responses are meant to travel as. Nothing enforced it, though. `metadata`
222
+ * is `Record<string, unknown>`, so a caller could put a whole prompt in it
223
+ * without noticing, and "we never receive your content" was a property of
224
+ * how you happened to call the SDK rather than a guarantee.
225
+ *
226
+ * With `noPayload` on, {@link VorimSDK.emit} and {@link VorimSDK.emitBatch}
227
+ * throw before anything is sent when an event would carry content:
228
+ *
229
+ * - any `metadata` value that is not a string, number, boolean or null
230
+ * (objects and arrays can nest arbitrary text)
231
+ * - any `metadata` string longer than `maxMetadataChars` (default 256)
232
+ * - any hash field that is not a well-formed `sha256:` / `hmac-sha256:`
233
+ * digest, which catches a raw prompt passed to `input_hash`
234
+ *
235
+ * This is distinct from the server-side Zero Data Retention setting. ZDR
236
+ * drops `metadata` at persistence, so the content still crossed the network
237
+ * and passed through our process. `noPayload` means it never left yours.
238
+ * Enterprises asking "can we send you nothing?" are asking for this one.
239
+ *
240
+ * It does not restrict `action` or `resource`. Both are short structural
241
+ * identifiers, both are covered by the v1 signature, and stripping them
242
+ * would break bundle verification. Keep tool names in them, not arguments.
243
+ */
244
+ noPayload?: boolean | {
245
+ maxMetadataChars?: number;
246
+ };
167
247
  /**
168
248
  * Client-side fail-open behaviour for {@link VorimSDK.beforeAction} when
169
249
  * the runtime decision API itself is unreachable (network error, DNS,
@@ -203,6 +283,21 @@ declare function canonicalPayloadV0(event: AuditEventInput): string;
203
283
  * script enforces equivalence with the Python SDK.
204
284
  */
205
285
  declare function canonicalPayloadV1(event: AuditEventInput): string;
286
+ /**
287
+ * Stable content digest of an audit event: `sha256:<hex>` over the event's
288
+ * canonical bytes, dispatched on `canonical_form` the same way signing is.
289
+ *
290
+ * Byte-identical to `eventDigest` in `@vorim/verify` and to the digest the
291
+ * server returns from `POST /audit/events`, so a counterparty can bind to a
292
+ * reference you computed locally without trusting either of us to compute it.
293
+ * It is also what `prev_event_hash` references, so a hash-chained emitter is
294
+ * already producing these whether it names them or not.
295
+ *
296
+ * Content digest, not an identity: two byte-identical events share one
297
+ * digest. Pair it with the `event_id` the server returns when you need a
298
+ * unique handle.
299
+ */
300
+ declare function eventDigest(event: AuditEventInput): Promise<string>;
206
301
  declare class VorimSDK {
207
302
  private apiKey;
208
303
  private baseUrl;
@@ -211,6 +306,8 @@ declare class VorimSDK {
211
306
  private canonicalForm;
212
307
  private chainEvents;
213
308
  private runtimeFailOpen;
309
+ private noPayload;
310
+ private maxMetadataChars;
214
311
  /**
215
312
  * In-memory keyring mapping agent_id -> PEM-encoded Ed25519 private key.
216
313
  * Populated automatically by register() and registerEphemeral(), or
@@ -670,6 +767,7 @@ declare class VorimSDK {
670
767
  */
671
768
  emit(event: AuditEventInput, options?: {
672
769
  sign?: boolean;
770
+ idempotencyKey?: string;
673
771
  }): Promise<{
674
772
  ingested: number;
675
773
  }>;
@@ -685,6 +783,7 @@ declare class VorimSDK {
685
783
  */
686
784
  emitBatch(events: AuditEventInput[], options?: {
687
785
  sign?: boolean;
786
+ idempotencyKey?: string;
688
787
  }): Promise<{
689
788
  ingested: number;
690
789
  }>;
@@ -712,6 +811,15 @@ declare class VorimSDK {
712
811
  * - Chain ops are serialised per-agent via `chainLocks` so
713
812
  * concurrent emits to the same agent build a deterministic chain.
714
813
  */
814
+ /**
815
+ * Fail closed when `noPayload` is on and an event would carry content.
816
+ *
817
+ * Runs before signing and before any network call, so a rejected event is
818
+ * one Vorim never saw. Throwing rather than stripping is deliberate: a
819
+ * silent strip would leave the caller believing they had logged something
820
+ * they had not, and would change the bytes after they were signed.
821
+ */
822
+ private assertNoPayload;
715
823
  private prepareEvent;
716
824
  /** Serialise per-agent and apply chain hash + sign. */
717
825
  private prepareEventChained;
@@ -924,4 +1032,4 @@ interface DeviceLoginResult {
924
1032
  */
925
1033
  declare function deviceLogin(opts: DeviceLoginOptions): Promise<DeviceLoginResult>;
926
1034
 
927
- export { Agent, AgentDelegationRecord, AgentRegistrationInput, AgentRegistrationResult, AuditEventInput, BeforeActionInput, BudgetSpend, CANONICAL_TOOL_CATALOGUE_VERSION, type CatalogueTool, DelegationLinkClaims, type DeviceLoginOptions, type DeviceLoginResult, PermissionCheckResult, PermissionScope, type ReplayContext, type ReplayInputs, RuntimeDecision, SharedMemoryEntry, SharedMemoryListResult, SharedMemoryWriteInput, TokenBudget, TokenBudgetInput, TrustRecord, type VorimConfig, VorimDeniedError, VorimError, VorimSDK, WorkflowProvenanceGraph, canonicalPayloadV0, canonicalPayloadV1, createVorim as default, deviceLogin, hashPreviousEvent, hashSystemPrompt, hashTool, hashToolCatalogue, jcsCanonicalise, prepareReplayContext };
1035
+ export { Agent, AgentDelegationRecord, AgentRegistrationInput, AgentRegistrationResult, AuditEventInput, BeforeActionInput, BudgetSpend, CANONICAL_TOOL_CATALOGUE_VERSION, type CatalogueTool, type CommitmentKey, DelegationLinkClaims, type DeviceLoginOptions, type DeviceLoginResult, HMAC_SHA256_PREFIX, PermissionCheckResult, PermissionScope, type ReplayContext, type ReplayInputs, RuntimeDecision, SHA256_PREFIX, SharedMemoryEntry, SharedMemoryListResult, SharedMemoryWriteInput, TokenBudget, TokenBudgetInput, TrustRecord, type VorimConfig, VorimDeniedError, VorimError, VorimSDK, WorkflowProvenanceGraph, canonicalPayloadV0, canonicalPayloadV1, commitPayload, createVorim as default, deviceLogin, eventDigest, hashPayload, hashPreviousEvent, hashSystemPrompt, hashTool, hashToolCatalogue, isDigest, isKeyedCommitment, jcsCanonicalise, prepareReplayContext };
package/dist/index.js CHANGED
@@ -74,8 +74,57 @@ async function prepareReplayContext(inputs) {
74
74
  return ctx;
75
75
  }
76
76
 
77
+ // src/commit.ts
78
+ var HMAC_SHA256_PREFIX = "hmac-sha256:";
79
+ var SHA256_PREFIX = "sha256:";
80
+ function toBytes(v) {
81
+ return typeof v === "string" ? new TextEncoder().encode(v) : v;
82
+ }
83
+ function toHex(buf) {
84
+ return Array.from(buf instanceof Uint8Array ? buf : new Uint8Array(buf)).map((b) => b.toString(16).padStart(2, "0")).join("");
85
+ }
86
+ async function hashPayload(content) {
87
+ const bytes = toBytes(content);
88
+ const subtle = globalThis.crypto?.subtle;
89
+ if (subtle) {
90
+ return SHA256_PREFIX + toHex(await subtle.digest("SHA-256", bytes));
91
+ }
92
+ const nodeCrypto = await import("crypto");
93
+ return SHA256_PREFIX + nodeCrypto.createHash("sha256").update(bytes).digest("hex");
94
+ }
95
+ async function commitPayload(content, key) {
96
+ const keyBytes = toBytes(key);
97
+ if (keyBytes.length === 0) {
98
+ throw new Error(
99
+ "commitPayload: key must not be empty. An empty key makes the commitment no stronger than hashPayload while labelling it as keyed."
100
+ );
101
+ }
102
+ const bytes = toBytes(content);
103
+ const subtle = globalThis.crypto?.subtle;
104
+ if (subtle) {
105
+ const cryptoKey = await subtle.importKey(
106
+ "raw",
107
+ keyBytes,
108
+ { name: "HMAC", hash: "SHA-256" },
109
+ false,
110
+ ["sign"]
111
+ );
112
+ const sig = await subtle.sign("HMAC", cryptoKey, bytes);
113
+ return HMAC_SHA256_PREFIX + toHex(sig);
114
+ }
115
+ const nodeCrypto = await import("crypto");
116
+ return HMAC_SHA256_PREFIX + nodeCrypto.createHmac("sha256", keyBytes).update(bytes).digest("hex");
117
+ }
118
+ function isKeyedCommitment(digest) {
119
+ return typeof digest === "string" && digest.startsWith(HMAC_SHA256_PREFIX);
120
+ }
121
+ var DIGEST_RE = /^(?:sha256|hmac-sha256):[0-9a-f]{64}$/;
122
+ function isDigest(digest) {
123
+ return typeof digest === "string" && DIGEST_RE.test(digest);
124
+ }
125
+
77
126
  // src/index.ts
78
- var SDK_VERSION = true ? "3.18.2" : "0.0.0";
127
+ var SDK_VERSION = true ? "3.20.0" : "0.0.0";
79
128
  var USER_AGENT = `vorim-sdk/${SDK_VERSION}`;
80
129
  function sleep(ms) {
81
130
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -94,6 +143,14 @@ function canonicalPayloadV1(event) {
94
143
  const { signature: _sig, canonical_form: _cf, ...rest } = event;
95
144
  return jcsCanonicalise(rest);
96
145
  }
146
+ async function eventDigest(event) {
147
+ const form = event.canonical_form ?? "v0";
148
+ const bytes = form === "v1" ? canonicalPayloadV1(event) : canonicalPayloadV0(event);
149
+ return hashPreviousEvent(bytes);
150
+ }
151
+ function idempotencyHeader(key) {
152
+ return key ? { "Idempotency-Key": key } : void 0;
153
+ }
97
154
  var VorimSDK = class _VorimSDK {
98
155
  apiKey;
99
156
  baseUrl;
@@ -102,6 +159,8 @@ var VorimSDK = class _VorimSDK {
102
159
  canonicalForm;
103
160
  chainEvents;
104
161
  runtimeFailOpen;
162
+ noPayload;
163
+ maxMetadataChars;
105
164
  /**
106
165
  * In-memory keyring mapping agent_id -> PEM-encoded Ed25519 private key.
107
166
  * Populated automatically by register() and registerEphemeral(), or
@@ -148,6 +207,8 @@ var VorimSDK = class _VorimSDK {
148
207
  }
149
208
  this.chainEvents = config.chainEvents ?? false;
150
209
  this.runtimeFailOpen = config.runtimeFailOpen ?? true;
210
+ this.noPayload = config.noPayload !== void 0 && config.noPayload !== false;
211
+ this.maxMetadataChars = typeof config.noPayload === "object" && typeof config.noPayload.maxMetadataChars === "number" ? config.noPayload.maxMetadataChars : 256;
151
212
  }
152
213
  /**
153
214
  * Register a previously-issued agent keypair so this SDK instance can
@@ -787,7 +848,11 @@ var VorimSDK = class _VorimSDK {
787
848
  */
788
849
  async emit(event, options) {
789
850
  const prepared = await this.prepareEvent(event, options?.sign);
790
- const result = await this.post("/audit/events", { events: [prepared] });
851
+ const result = await this.post(
852
+ "/audit/events",
853
+ { events: [prepared] },
854
+ idempotencyHeader(options?.idempotencyKey)
855
+ );
791
856
  this.warnOnPartialIngest(1, result?.ingested ?? 0);
792
857
  return result;
793
858
  }
@@ -803,7 +868,11 @@ var VorimSDK = class _VorimSDK {
803
868
  */
804
869
  async emitBatch(events, options) {
805
870
  const prepared = await Promise.all(events.map((e) => this.prepareEvent(e, options?.sign)));
806
- const result = await this.post("/audit/events", { events: prepared });
871
+ const result = await this.post(
872
+ "/audit/events",
873
+ { events: prepared },
874
+ idempotencyHeader(options?.idempotencyKey)
875
+ );
807
876
  this.warnOnPartialIngest(events.length, result?.ingested ?? 0);
808
877
  return result;
809
878
  }
@@ -840,7 +909,61 @@ var VorimSDK = class _VorimSDK {
840
909
  * - Chain ops are serialised per-agent via `chainLocks` so
841
910
  * concurrent emits to the same agent build a deterministic chain.
842
911
  */
912
+ /**
913
+ * Fail closed when `noPayload` is on and an event would carry content.
914
+ *
915
+ * Runs before signing and before any network call, so a rejected event is
916
+ * one Vorim never saw. Throwing rather than stripping is deliberate: a
917
+ * silent strip would leave the caller believing they had logged something
918
+ * they had not, and would change the bytes after they were signed.
919
+ */
920
+ assertNoPayload(event) {
921
+ if (!this.noPayload) return;
922
+ for (const field of ["input_hash", "output_hash", "system_prompt_hash", "tool_catalogue_hash"]) {
923
+ const value = event[field];
924
+ if (value === void 0 || value === null) continue;
925
+ if (!isDigest(value)) {
926
+ throw new VorimError(
927
+ 0,
928
+ "PAYLOAD_BLOCKED",
929
+ `noPayload: ${field} must be a sha256: or hmac-sha256: digest, got ${typeof value === "string" ? `${value.length} chars` : typeof value}. Hash it locally first \u2014 commitPayload() for anything a human or a model wrote, hashPayload() only for content that is already high-entropy.`,
930
+ { field }
931
+ );
932
+ }
933
+ }
934
+ const metadata = event.metadata;
935
+ if (metadata === void 0 || metadata === null) return;
936
+ for (const [key, value] of Object.entries(metadata)) {
937
+ if (value === null) continue;
938
+ const t = typeof value;
939
+ if (t === "object") {
940
+ throw new VorimError(
941
+ 0,
942
+ "PAYLOAD_BLOCKED",
943
+ `noPayload: metadata.${key} is ${Array.isArray(value) ? "an array" : "an object"}. Nested values can carry arbitrary content, so only string, number, boolean and null are allowed. Summarise it, or commit to it with commitPayload() and send the digest.`,
944
+ { field: `metadata.${key}` }
945
+ );
946
+ }
947
+ if (t !== "string" && t !== "number" && t !== "boolean") {
948
+ throw new VorimError(
949
+ 0,
950
+ "PAYLOAD_BLOCKED",
951
+ `noPayload: metadata.${key} is ${t}, which is not a permitted metadata type.`,
952
+ { field: `metadata.${key}` }
953
+ );
954
+ }
955
+ if (t === "string" && value.length > this.maxMetadataChars) {
956
+ throw new VorimError(
957
+ 0,
958
+ "PAYLOAD_BLOCKED",
959
+ `noPayload: metadata.${key} is ${value.length} chars, over the ${this.maxMetadataChars} limit. A value this long is content, not a label. Raise the limit with noPayload: { maxMetadataChars } if this really is a label.`,
960
+ { field: `metadata.${key}`, length: value.length }
961
+ );
962
+ }
963
+ }
964
+ }
843
965
  async prepareEvent(event, signOverride) {
966
+ this.assertNoPayload(event);
844
967
  const shouldSign = signOverride ?? this.autoSign;
845
968
  if (!shouldSign && !this.chainEvents) return event;
846
969
  if (this.chainEvents) {
@@ -1045,8 +1168,8 @@ var VorimSDK = class _VorimSDK {
1045
1168
  async get(path) {
1046
1169
  return this.request("GET", path);
1047
1170
  }
1048
- async post(path, body) {
1049
- return this.request("POST", path, body);
1171
+ async post(path, body, headers) {
1172
+ return this.request("POST", path, body, true, headers);
1050
1173
  }
1051
1174
  async patch(path, body) {
1052
1175
  return this.request("PATCH", path, body);
@@ -1062,7 +1185,7 @@ var VorimSDK = class _VorimSDK {
1062
1185
  async requestEnvelope(method, path, body) {
1063
1186
  return this.request(method, path, body, false);
1064
1187
  }
1065
- async request(method, path, body, unwrap = true) {
1188
+ async request(method, path, body, unwrap = true, extraHeaders) {
1066
1189
  const controller = new AbortController();
1067
1190
  const timeoutId = setTimeout(() => controller.abort(), this.timeout);
1068
1191
  try {
@@ -1071,7 +1194,8 @@ var VorimSDK = class _VorimSDK {
1071
1194
  headers: {
1072
1195
  "Authorization": `Bearer ${this.apiKey}`,
1073
1196
  "Content-Type": "application/json",
1074
- "User-Agent": USER_AGENT
1197
+ "User-Agent": USER_AGENT,
1198
+ ...extraHeaders
1075
1199
  },
1076
1200
  body: body ? JSON.stringify(body) : void 0,
1077
1201
  signal: controller.signal
@@ -1199,17 +1323,24 @@ async function deviceLogin(opts) {
1199
1323
  }
1200
1324
  export {
1201
1325
  CANONICAL_TOOL_CATALOGUE_VERSION,
1326
+ HMAC_SHA256_PREFIX,
1327
+ SHA256_PREFIX,
1202
1328
  VorimDeniedError,
1203
1329
  VorimError,
1204
1330
  VorimSDK,
1205
1331
  canonicalPayloadV0,
1206
1332
  canonicalPayloadV1,
1333
+ commitPayload,
1207
1334
  createVorim as default,
1208
1335
  deviceLogin,
1336
+ eventDigest,
1337
+ hashPayload,
1209
1338
  hashPreviousEvent,
1210
1339
  hashSystemPrompt,
1211
1340
  hashTool,
1212
1341
  hashToolCatalogue,
1342
+ isDigest,
1343
+ isKeyedCommitment,
1213
1344
  jcsCanonicalise,
1214
1345
  prepareReplayContext
1215
1346
  };