@vorim/sdk 4.1.1 → 4.2.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.
- package/CHANGELOG.md +8 -0
- package/dist/{_commerce-core-Dyr_dHVP.d.ts → _commerce-core-BIqTJ7Om.d.ts} +1 -1
- package/dist/{_commerce-core-wY2jC6rC.d.cts → _commerce-core-BQbISpWe.d.cts} +1 -1
- package/dist/index.cjs +85 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +38 -3
- package/dist/index.d.ts +38 -3
- package/dist/index.js +84 -4
- package/dist/index.js.map +1 -1
- package/dist/integrations/amazon.d.cts +2 -2
- package/dist/integrations/amazon.d.ts +2 -2
- package/dist/integrations/anthropic.d.cts +1 -1
- package/dist/integrations/anthropic.d.ts +1 -1
- package/dist/integrations/ap2.d.cts +1 -1
- package/dist/integrations/ap2.d.ts +1 -1
- package/dist/integrations/aws-iam.d.cts +1 -1
- package/dist/integrations/aws-iam.d.ts +1 -1
- package/dist/integrations/bank-rails.d.cts +1 -1
- package/dist/integrations/bank-rails.d.ts +1 -1
- package/dist/integrations/circle.d.cts +1 -1
- package/dist/integrations/circle.d.ts +1 -1
- package/dist/integrations/cloudflare.d.cts +1 -1
- package/dist/integrations/cloudflare.d.ts +1 -1
- package/dist/integrations/coinbase-cdp.d.cts +1 -1
- package/dist/integrations/coinbase-cdp.d.ts +1 -1
- package/dist/integrations/commerce-agents.d.cts +1 -1
- package/dist/integrations/commerce-agents.d.ts +1 -1
- package/dist/integrations/crewai.d.cts +1 -1
- package/dist/integrations/crewai.d.ts +1 -1
- package/dist/integrations/delivery.d.cts +2 -2
- package/dist/integrations/delivery.d.ts +2 -2
- package/dist/integrations/ebay.d.cts +2 -2
- package/dist/integrations/ebay.d.ts +2 -2
- package/dist/integrations/entra.d.cts +1 -1
- package/dist/integrations/entra.d.ts +1 -1
- package/dist/integrations/etsy.d.cts +2 -2
- package/dist/integrations/etsy.d.ts +2 -2
- package/dist/integrations/fhir.d.cts +1 -1
- package/dist/integrations/fhir.d.ts +1 -1
- package/dist/integrations/google-merchant.d.cts +2 -2
- package/dist/integrations/google-merchant.d.ts +2 -2
- package/dist/integrations/grok.d.cts +1 -1
- package/dist/integrations/grok.d.ts +1 -1
- package/dist/integrations/guidewire.d.cts +1 -1
- package/dist/integrations/guidewire.d.ts +1 -1
- package/dist/integrations/hermes.d.cts +1 -1
- package/dist/integrations/hermes.d.ts +1 -1
- package/dist/integrations/jira.d.cts +1 -1
- package/dist/integrations/jira.d.ts +1 -1
- package/dist/integrations/langchain.d.cts +1 -1
- package/dist/integrations/langchain.d.ts +1 -1
- package/dist/integrations/langgraph.d.cts +1 -1
- package/dist/integrations/langgraph.d.ts +1 -1
- package/dist/integrations/legal.d.cts +1 -1
- package/dist/integrations/legal.d.ts +1 -1
- package/dist/integrations/life-sciences.d.cts +1 -1
- package/dist/integrations/life-sciences.d.ts +1 -1
- package/dist/integrations/linear.d.cts +1 -1
- package/dist/integrations/linear.d.ts +1 -1
- package/dist/integrations/lithic.d.cts +1 -1
- package/dist/integrations/lithic.d.ts +1 -1
- package/dist/integrations/llamaindex.d.cts +1 -1
- package/dist/integrations/llamaindex.d.ts +1 -1
- package/dist/integrations/marqeta.d.cts +1 -1
- package/dist/integrations/marqeta.d.ts +1 -1
- package/dist/integrations/meta.d.cts +2 -2
- package/dist/integrations/meta.d.ts +2 -2
- package/dist/integrations/modern-treasury.d.cts +1 -1
- package/dist/integrations/modern-treasury.d.ts +1 -1
- package/dist/integrations/muse.d.cts +1 -1
- package/dist/integrations/muse.d.ts +1 -1
- package/dist/integrations/nekuda.d.cts +1 -1
- package/dist/integrations/nekuda.d.ts +1 -1
- package/dist/integrations/okta.d.cts +1 -1
- package/dist/integrations/okta.d.ts +1 -1
- package/dist/integrations/openai.d.cts +1 -1
- package/dist/integrations/openai.d.ts +1 -1
- package/dist/integrations/openrouter.d.cts +1 -1
- package/dist/integrations/openrouter.d.ts +1 -1
- package/dist/integrations/paypal-agent.d.cts +1 -1
- package/dist/integrations/paypal-agent.d.ts +1 -1
- package/dist/integrations/perplexity.d.cts +1 -1
- package/dist/integrations/perplexity.d.ts +1 -1
- package/dist/integrations/plaid.d.cts +1 -1
- package/dist/integrations/plaid.d.ts +1 -1
- package/dist/integrations/ramp.d.cts +1 -1
- package/dist/integrations/ramp.d.ts +1 -1
- package/dist/integrations/shopify.d.cts +1 -1
- package/dist/integrations/shopify.d.ts +1 -1
- package/dist/integrations/siem.d.cts +1 -1
- package/dist/integrations/siem.d.ts +1 -1
- package/dist/integrations/skyfire.d.cts +1 -1
- package/dist/integrations/skyfire.d.ts +1 -1
- package/dist/integrations/social-ads.d.cts +2 -2
- package/dist/integrations/social-ads.d.ts +2 -2
- package/dist/integrations/stripe-acp.d.cts +1 -1
- package/dist/integrations/stripe-acp.d.ts +1 -1
- package/dist/integrations/stripe-issuing.d.cts +1 -1
- package/dist/integrations/stripe-issuing.d.ts +1 -1
- package/dist/integrations/tiktok-shop.d.cts +2 -2
- package/dist/integrations/tiktok-shop.d.ts +2 -2
- package/dist/integrations/truanon.d.cts +1 -1
- package/dist/integrations/truanon.d.ts +1 -1
- package/dist/integrations/typesafe.d.cts +1 -1
- package/dist/integrations/typesafe.d.ts +1 -1
- package/dist/integrations/ucp.d.cts +1 -1
- package/dist/integrations/ucp.d.ts +1 -1
- package/dist/integrations/vercel-ai.d.cts +1 -1
- package/dist/integrations/vercel-ai.d.ts +1 -1
- package/dist/integrations/walmart.d.cts +2 -2
- package/dist/integrations/walmart.d.ts +2 -2
- package/dist/integrations/x402.d.cts +1 -1
- package/dist/integrations/x402.d.ts +1 -1
- package/dist/{types-DphtTyIC.d.cts → types-DwPEBj7p.d.cts} +56 -1
- package/dist/{types-DphtTyIC.d.ts → types-DwPEBj7p.d.ts} +56 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AgentRegistrationResult, R as RuntimeDecision, a as AgentRegistrationInput, T as TrustRecord, b as Agent, S as SuspendPreview, P as PermissionScope, c as PermissionCheckResult, D as DelegationLinkClaims, d as AgentDelegationRecord, W as WorkflowProvenanceGraph, C as CapabilityProfile, e as SharedMemoryWriteInput, f as SharedMemoryEntry, g as SharedMemoryListResult, B as BeforeActionInput, h as TokenBudgetInput, i as TokenBudget, j as BudgetSpend, k as AuditEventInput, l as SwarmView } from './types-
|
|
2
|
-
export {
|
|
1
|
+
import { A as AgentRegistrationResult, R as RuntimeDecision, a as AgentRegistrationInput, T as TrustRecord, b as Agent, S as SuspendPreview, P as PermissionScope, c as PermissionCheckResult, D as DelegationLinkClaims, d as AgentDelegationRecord, W as WorkflowProvenanceGraph, C as CapabilityProfile, e as SharedMemoryWriteInput, f as SharedMemoryEntry, g as SharedMemoryListResult, B as BeforeActionInput, h as TokenBudgetInput, i as TokenBudget, j as BudgetSpend, k as AuditEventInput, l as SwarmView, m as DeclareIntentInput, I as Intent } from './types-DwPEBj7p.cjs';
|
|
2
|
+
export { n as AgentStatus, o as ApprovalAttestation, p as AuditEventType, q as AuditResult, r as BudgetEnforcement, s as BudgetScope, t as DecisionVerdict, u as WorkflowGraphEdge, v as WorkflowGraphEvent, w as WorkflowGraphNode } from './types-DwPEBj7p.cjs';
|
|
3
3
|
import { PortableSignedReceipt } from '@vorim/shared-types';
|
|
4
4
|
export { PortableSignedReceipt, portableReceiptCanonicalBytes } from '@vorim/shared-types';
|
|
5
5
|
import { HttpRequestLike, SignHttpRequestOptions, SignHttpRequestResult } from './httpSignatures.cjs';
|
|
@@ -186,6 +186,13 @@ declare function isKeyedCommitment(digest: unknown): boolean;
|
|
|
186
186
|
*/
|
|
187
187
|
declare function isDigest(digest: unknown): boolean;
|
|
188
188
|
|
|
189
|
+
/**
|
|
190
|
+
* The server's canonical JSON for an intent declaration (services/intents.ts
|
|
191
|
+
* `intentSigningPayload`): keys sorted at every level, `undefined` dropped,
|
|
192
|
+
* arrays kept in order. Exported so a caller can verify what the SDK signed.
|
|
193
|
+
*/
|
|
194
|
+
declare function canonicalIntent(value: unknown): string;
|
|
195
|
+
|
|
189
196
|
interface VorimConfig {
|
|
190
197
|
apiKey: string;
|
|
191
198
|
baseUrl?: string;
|
|
@@ -1046,6 +1053,34 @@ declare class VorimSDK {
|
|
|
1046
1053
|
* (for anything derived from peer reports), per member.
|
|
1047
1054
|
*/
|
|
1048
1055
|
getSwarmScore(swarmId: string): Promise<any>;
|
|
1056
|
+
/**
|
|
1057
|
+
* Declare an intent for an agent. Needs the `agents:write` scope.
|
|
1058
|
+
*
|
|
1059
|
+
* @example
|
|
1060
|
+
* const intent = await vorim.declareIntent({
|
|
1061
|
+
* agentId: 'agid_acme_refunds',
|
|
1062
|
+
* goal: 'Refund order 4471: the item arrived damaged',
|
|
1063
|
+
* expectedActionTypes: ['lookup', 'refund', 'email'],
|
|
1064
|
+
* expectedTargets: ['shopify:order', 'stripe:refund', 'email:customer'],
|
|
1065
|
+
* maxAmount: 8000, amountCurrency: 'GBP', ttlSeconds: 1800,
|
|
1066
|
+
* });
|
|
1067
|
+
* await vorim.beforeAction({ agentId, actionType: 'refund', actionTarget: 'stripe:refund', requiredScope: 'agent:transact', payload: { amount: 7900 }, intentId: intent.intent_id });
|
|
1068
|
+
* await vorim.completeIntent(intent.intent_id, 'completed', 'Refunded 79.00');
|
|
1069
|
+
*/
|
|
1070
|
+
declareIntent(input: DeclareIntentInput): Promise<Intent>;
|
|
1071
|
+
/** A platform-signed ledger of intents over a period, for a counterparty to verify offline. */
|
|
1072
|
+
getIntentLedger(params?: {
|
|
1073
|
+
agentId?: string;
|
|
1074
|
+
days?: number;
|
|
1075
|
+
}): Promise<any>;
|
|
1076
|
+
/** Close an intent when the job ends. Further actions under it are off intent. */
|
|
1077
|
+
completeIntent(intentId: string, status?: 'completed' | 'abandoned', outcome?: string): Promise<any>;
|
|
1078
|
+
/** Intents for the org, newest first; filter by agent or status. */
|
|
1079
|
+
listIntents(params?: {
|
|
1080
|
+
agentId?: string;
|
|
1081
|
+
status?: 'active' | 'completed' | 'abandoned' | 'expired';
|
|
1082
|
+
limit?: number;
|
|
1083
|
+
}): Promise<Intent[]>;
|
|
1049
1084
|
/**
|
|
1050
1085
|
* Issue a platform-signed attestation of the swarm as it is now: roster
|
|
1051
1086
|
* and its hash, policy version and rules hash, charter, budget, kills,
|
|
@@ -1305,4 +1340,4 @@ interface DeviceLoginResult {
|
|
|
1305
1340
|
*/
|
|
1306
1341
|
declare function deviceLogin(opts: DeviceLoginOptions): Promise<DeviceLoginResult>;
|
|
1307
1342
|
|
|
1308
|
-
export { Agent, AgentDelegationRecord, AgentRegistrationInput, AgentRegistrationResult, AuditEventInput, BeforeActionInput, BudgetSpend, CANONICAL_TOOL_CATALOGUE_VERSION, type CatalogueTool, type CommitmentKey, DelegationLinkClaims, type DeviceLoginOptions, type DeviceLoginResult, HMAC_SHA256_PREFIX, HttpRequestLike, type HttpSignatureVerification, PermissionCheckResult, PermissionScope, type ReplayContext, type ReplayInputs, RuntimeDecision, SHA256_PREFIX, SharedMemoryEntry, SharedMemoryListResult, SharedMemoryWriteInput, SignHttpRequestOptions, SignHttpRequestResult, SuspendPreview, SwarmView, TokenBudget, TokenBudgetInput, TrustRecord, type VorimConfig, VorimDeniedError, VorimError, VorimSDK, WorkflowProvenanceGraph, canonicalPayloadV0, canonicalPayloadV1, commitPayload, createVorim as default, deviceLogin, eventDigest, foldTraceparent, hashPayload, hashPreviousEvent, hashSystemPrompt, hashTool, hashToolCatalogue, isDigest, isKeyedCommitment, jcsCanonicalise, prepareReplayContext };
|
|
1343
|
+
export { Agent, AgentDelegationRecord, AgentRegistrationInput, AgentRegistrationResult, AuditEventInput, BeforeActionInput, BudgetSpend, CANONICAL_TOOL_CATALOGUE_VERSION, type CatalogueTool, type CommitmentKey, DeclareIntentInput, DelegationLinkClaims, type DeviceLoginOptions, type DeviceLoginResult, HMAC_SHA256_PREFIX, HttpRequestLike, type HttpSignatureVerification, Intent, PermissionCheckResult, PermissionScope, type ReplayContext, type ReplayInputs, RuntimeDecision, SHA256_PREFIX, SharedMemoryEntry, SharedMemoryListResult, SharedMemoryWriteInput, SignHttpRequestOptions, SignHttpRequestResult, SuspendPreview, SwarmView, TokenBudget, TokenBudgetInput, TrustRecord, type VorimConfig, VorimDeniedError, VorimError, VorimSDK, WorkflowProvenanceGraph, canonicalIntent, canonicalPayloadV0, canonicalPayloadV1, commitPayload, createVorim as default, deviceLogin, eventDigest, foldTraceparent, 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, a as AgentRegistrationInput, T as TrustRecord, b as Agent, S as SuspendPreview, P as PermissionScope, c as PermissionCheckResult, D as DelegationLinkClaims, d as AgentDelegationRecord, W as WorkflowProvenanceGraph, C as CapabilityProfile, e as SharedMemoryWriteInput, f as SharedMemoryEntry, g as SharedMemoryListResult, B as BeforeActionInput, h as TokenBudgetInput, i as TokenBudget, j as BudgetSpend, k as AuditEventInput, l as SwarmView } from './types-
|
|
2
|
-
export {
|
|
1
|
+
import { A as AgentRegistrationResult, R as RuntimeDecision, a as AgentRegistrationInput, T as TrustRecord, b as Agent, S as SuspendPreview, P as PermissionScope, c as PermissionCheckResult, D as DelegationLinkClaims, d as AgentDelegationRecord, W as WorkflowProvenanceGraph, C as CapabilityProfile, e as SharedMemoryWriteInput, f as SharedMemoryEntry, g as SharedMemoryListResult, B as BeforeActionInput, h as TokenBudgetInput, i as TokenBudget, j as BudgetSpend, k as AuditEventInput, l as SwarmView, m as DeclareIntentInput, I as Intent } from './types-DwPEBj7p.js';
|
|
2
|
+
export { n as AgentStatus, o as ApprovalAttestation, p as AuditEventType, q as AuditResult, r as BudgetEnforcement, s as BudgetScope, t as DecisionVerdict, u as WorkflowGraphEdge, v as WorkflowGraphEvent, w as WorkflowGraphNode } from './types-DwPEBj7p.js';
|
|
3
3
|
import { PortableSignedReceipt } from '@vorim/shared-types';
|
|
4
4
|
export { PortableSignedReceipt, portableReceiptCanonicalBytes } from '@vorim/shared-types';
|
|
5
5
|
import { HttpRequestLike, SignHttpRequestOptions, SignHttpRequestResult } from './httpSignatures.js';
|
|
@@ -186,6 +186,13 @@ declare function isKeyedCommitment(digest: unknown): boolean;
|
|
|
186
186
|
*/
|
|
187
187
|
declare function isDigest(digest: unknown): boolean;
|
|
188
188
|
|
|
189
|
+
/**
|
|
190
|
+
* The server's canonical JSON for an intent declaration (services/intents.ts
|
|
191
|
+
* `intentSigningPayload`): keys sorted at every level, `undefined` dropped,
|
|
192
|
+
* arrays kept in order. Exported so a caller can verify what the SDK signed.
|
|
193
|
+
*/
|
|
194
|
+
declare function canonicalIntent(value: unknown): string;
|
|
195
|
+
|
|
189
196
|
interface VorimConfig {
|
|
190
197
|
apiKey: string;
|
|
191
198
|
baseUrl?: string;
|
|
@@ -1046,6 +1053,34 @@ declare class VorimSDK {
|
|
|
1046
1053
|
* (for anything derived from peer reports), per member.
|
|
1047
1054
|
*/
|
|
1048
1055
|
getSwarmScore(swarmId: string): Promise<any>;
|
|
1056
|
+
/**
|
|
1057
|
+
* Declare an intent for an agent. Needs the `agents:write` scope.
|
|
1058
|
+
*
|
|
1059
|
+
* @example
|
|
1060
|
+
* const intent = await vorim.declareIntent({
|
|
1061
|
+
* agentId: 'agid_acme_refunds',
|
|
1062
|
+
* goal: 'Refund order 4471: the item arrived damaged',
|
|
1063
|
+
* expectedActionTypes: ['lookup', 'refund', 'email'],
|
|
1064
|
+
* expectedTargets: ['shopify:order', 'stripe:refund', 'email:customer'],
|
|
1065
|
+
* maxAmount: 8000, amountCurrency: 'GBP', ttlSeconds: 1800,
|
|
1066
|
+
* });
|
|
1067
|
+
* await vorim.beforeAction({ agentId, actionType: 'refund', actionTarget: 'stripe:refund', requiredScope: 'agent:transact', payload: { amount: 7900 }, intentId: intent.intent_id });
|
|
1068
|
+
* await vorim.completeIntent(intent.intent_id, 'completed', 'Refunded 79.00');
|
|
1069
|
+
*/
|
|
1070
|
+
declareIntent(input: DeclareIntentInput): Promise<Intent>;
|
|
1071
|
+
/** A platform-signed ledger of intents over a period, for a counterparty to verify offline. */
|
|
1072
|
+
getIntentLedger(params?: {
|
|
1073
|
+
agentId?: string;
|
|
1074
|
+
days?: number;
|
|
1075
|
+
}): Promise<any>;
|
|
1076
|
+
/** Close an intent when the job ends. Further actions under it are off intent. */
|
|
1077
|
+
completeIntent(intentId: string, status?: 'completed' | 'abandoned', outcome?: string): Promise<any>;
|
|
1078
|
+
/** Intents for the org, newest first; filter by agent or status. */
|
|
1079
|
+
listIntents(params?: {
|
|
1080
|
+
agentId?: string;
|
|
1081
|
+
status?: 'active' | 'completed' | 'abandoned' | 'expired';
|
|
1082
|
+
limit?: number;
|
|
1083
|
+
}): Promise<Intent[]>;
|
|
1049
1084
|
/**
|
|
1050
1085
|
* Issue a platform-signed attestation of the swarm as it is now: roster
|
|
1051
1086
|
* and its hash, policy version and rules hash, charter, budget, kills,
|
|
@@ -1305,4 +1340,4 @@ interface DeviceLoginResult {
|
|
|
1305
1340
|
*/
|
|
1306
1341
|
declare function deviceLogin(opts: DeviceLoginOptions): Promise<DeviceLoginResult>;
|
|
1307
1342
|
|
|
1308
|
-
export { Agent, AgentDelegationRecord, AgentRegistrationInput, AgentRegistrationResult, AuditEventInput, BeforeActionInput, BudgetSpend, CANONICAL_TOOL_CATALOGUE_VERSION, type CatalogueTool, type CommitmentKey, DelegationLinkClaims, type DeviceLoginOptions, type DeviceLoginResult, HMAC_SHA256_PREFIX, HttpRequestLike, type HttpSignatureVerification, PermissionCheckResult, PermissionScope, type ReplayContext, type ReplayInputs, RuntimeDecision, SHA256_PREFIX, SharedMemoryEntry, SharedMemoryListResult, SharedMemoryWriteInput, SignHttpRequestOptions, SignHttpRequestResult, SuspendPreview, SwarmView, TokenBudget, TokenBudgetInput, TrustRecord, type VorimConfig, VorimDeniedError, VorimError, VorimSDK, WorkflowProvenanceGraph, canonicalPayloadV0, canonicalPayloadV1, commitPayload, createVorim as default, deviceLogin, eventDigest, foldTraceparent, hashPayload, hashPreviousEvent, hashSystemPrompt, hashTool, hashToolCatalogue, isDigest, isKeyedCommitment, jcsCanonicalise, prepareReplayContext };
|
|
1343
|
+
export { Agent, AgentDelegationRecord, AgentRegistrationInput, AgentRegistrationResult, AuditEventInput, BeforeActionInput, BudgetSpend, CANONICAL_TOOL_CATALOGUE_VERSION, type CatalogueTool, type CommitmentKey, DeclareIntentInput, DelegationLinkClaims, type DeviceLoginOptions, type DeviceLoginResult, HMAC_SHA256_PREFIX, HttpRequestLike, type HttpSignatureVerification, Intent, PermissionCheckResult, PermissionScope, type ReplayContext, type ReplayInputs, RuntimeDecision, SHA256_PREFIX, SharedMemoryEntry, SharedMemoryListResult, SharedMemoryWriteInput, SignHttpRequestOptions, SignHttpRequestResult, SuspendPreview, SwarmView, TokenBudget, TokenBudgetInput, TrustRecord, type VorimConfig, VorimDeniedError, VorimError, VorimSDK, WorkflowProvenanceGraph, canonicalIntent, canonicalPayloadV0, canonicalPayloadV1, commitPayload, createVorim as default, deviceLogin, eventDigest, foldTraceparent, hashPayload, hashPreviousEvent, hashSystemPrompt, hashTool, hashToolCatalogue, isDigest, isKeyedCommitment, jcsCanonicalise, prepareReplayContext };
|
package/dist/index.js
CHANGED
|
@@ -867,7 +867,15 @@ async function verifyHttpRequest(request, options) {
|
|
|
867
867
|
}
|
|
868
868
|
|
|
869
869
|
// src/index.ts
|
|
870
|
-
|
|
870
|
+
function canonicalIntent(value) {
|
|
871
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
872
|
+
if (Array.isArray(value)) return `[${value.map((v) => v === void 0 ? "null" : canonicalIntent(v)).join(",")}]`;
|
|
873
|
+
if (value instanceof Date) return JSON.stringify(value.toISOString());
|
|
874
|
+
const obj = value;
|
|
875
|
+
const keys = Object.keys(obj).filter((k) => obj[k] !== void 0).sort();
|
|
876
|
+
return `{${keys.map((k) => `${JSON.stringify(k)}:${canonicalIntent(obj[k])}`).join(",")}}`;
|
|
877
|
+
}
|
|
878
|
+
var SDK_VERSION = true ? "4.2.0" : "0.0.0";
|
|
871
879
|
var USER_AGENT = `vorim-sdk/${SDK_VERSION}`;
|
|
872
880
|
function sleep(ms) {
|
|
873
881
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -1488,7 +1496,8 @@ var VorimSDK = class _VorimSDK {
|
|
|
1488
1496
|
estimated_tokens: input.estimatedTokens,
|
|
1489
1497
|
trace_id: input.traceId,
|
|
1490
1498
|
span_id: input.spanId,
|
|
1491
|
-
traceparent: input.traceparent
|
|
1499
|
+
traceparent: input.traceparent,
|
|
1500
|
+
intent_id: input.intentId
|
|
1492
1501
|
};
|
|
1493
1502
|
let raw;
|
|
1494
1503
|
try {
|
|
@@ -1510,7 +1519,8 @@ var VorimSDK = class _VorimSDK {
|
|
|
1510
1519
|
policyVersion: 0,
|
|
1511
1520
|
swarmId: null,
|
|
1512
1521
|
escalationResolution: null,
|
|
1513
|
-
approval: null
|
|
1522
|
+
approval: null,
|
|
1523
|
+
intent: null
|
|
1514
1524
|
};
|
|
1515
1525
|
}
|
|
1516
1526
|
throw err;
|
|
@@ -1659,7 +1669,12 @@ var VorimSDK = class _VorimSDK {
|
|
|
1659
1669
|
policyVersion: raw?.policy_version ?? 0,
|
|
1660
1670
|
swarmId: typeof raw?.swarm_id === "string" ? raw.swarm_id : null,
|
|
1661
1671
|
escalationResolution: resolution,
|
|
1662
|
-
approval: toApprovalAttestation(raw?.approval)
|
|
1672
|
+
approval: toApprovalAttestation(raw?.approval),
|
|
1673
|
+
intent: raw?.intent && typeof raw.intent === "object" ? {
|
|
1674
|
+
id: typeof raw.intent.id === "string" ? raw.intent.id : null,
|
|
1675
|
+
alignment: raw.intent.alignment === "aligned" || raw.intent.alignment === "off_intent" ? raw.intent.alignment : "none",
|
|
1676
|
+
reasons: Array.isArray(raw.intent.reasons) ? raw.intent.reasons.filter((r) => typeof r === "string") : []
|
|
1677
|
+
} : null
|
|
1663
1678
|
};
|
|
1664
1679
|
}
|
|
1665
1680
|
// ─── Audit ────────────────────────────────────────────────────────
|
|
@@ -1972,6 +1987,70 @@ var VorimSDK = class _VorimSDK {
|
|
|
1972
1987
|
async getSwarmScore(swarmId) {
|
|
1973
1988
|
return this.get(`/swarms/${encodeURIComponent(swarmId)}/score`);
|
|
1974
1989
|
}
|
|
1990
|
+
// ─── Agent behaviour and intent ───────────────────────────────────────
|
|
1991
|
+
//
|
|
1992
|
+
// An intent is what the agent says it is about to do, declared before it
|
|
1993
|
+
// acts. Pass its id as `intentId` on every beforeAction() of that job and
|
|
1994
|
+
// Vorim judges each action against it (aligned / off_intent); the Behaviour
|
|
1995
|
+
// page shows the goal next to the steps, and rules can hold or block work
|
|
1996
|
+
// that is off intent or undeclared (`off_intent`, `intent_required`).
|
|
1997
|
+
/**
|
|
1998
|
+
* Declare an intent for an agent. Needs the `agents:write` scope.
|
|
1999
|
+
*
|
|
2000
|
+
* @example
|
|
2001
|
+
* const intent = await vorim.declareIntent({
|
|
2002
|
+
* agentId: 'agid_acme_refunds',
|
|
2003
|
+
* goal: 'Refund order 4471: the item arrived damaged',
|
|
2004
|
+
* expectedActionTypes: ['lookup', 'refund', 'email'],
|
|
2005
|
+
* expectedTargets: ['shopify:order', 'stripe:refund', 'email:customer'],
|
|
2006
|
+
* maxAmount: 8000, amountCurrency: 'GBP', ttlSeconds: 1800,
|
|
2007
|
+
* });
|
|
2008
|
+
* await vorim.beforeAction({ agentId, actionType: 'refund', actionTarget: 'stripe:refund', requiredScope: 'agent:transact', payload: { amount: 7900 }, intentId: intent.intent_id });
|
|
2009
|
+
* await vorim.completeIntent(intent.intent_id, 'completed', 'Refunded 79.00');
|
|
2010
|
+
*/
|
|
2011
|
+
async declareIntent(input) {
|
|
2012
|
+
const list = (xs) => Array.from(new Set((xs ?? []).map((s) => String(s).trim()).filter(Boolean)));
|
|
2013
|
+
const fields = {
|
|
2014
|
+
agent_id: input.agentId,
|
|
2015
|
+
goal: String(input.goal).trim(),
|
|
2016
|
+
expected_action_types: list(input.expectedActionTypes),
|
|
2017
|
+
expected_targets: list(input.expectedTargets),
|
|
2018
|
+
max_amount: typeof input.maxAmount === "number" ? input.maxAmount : null,
|
|
2019
|
+
amount_currency: input.amountCurrency ? input.amountCurrency.toUpperCase() : null,
|
|
2020
|
+
amount_field: input.amountField ?? null,
|
|
2021
|
+
max_actions: typeof input.maxActions === "number" ? input.maxActions : null,
|
|
2022
|
+
ttl_seconds: typeof input.ttlSeconds === "number" ? input.ttlSeconds : 86400
|
|
2023
|
+
};
|
|
2024
|
+
const key = this.agentKeys.get(input.agentId);
|
|
2025
|
+
let signed;
|
|
2026
|
+
if (key) {
|
|
2027
|
+
const signed_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
2028
|
+
const signature = await this.sign(canonicalIntent({ type: "vorim-agent-intent", v: 1, ...fields, signed_at }), key);
|
|
2029
|
+
signed = { signature, signed_at };
|
|
2030
|
+
}
|
|
2031
|
+
return this.post("/intents", { ...fields, workflow_id: input.workflowId, ...signed });
|
|
2032
|
+
}
|
|
2033
|
+
/** A platform-signed ledger of intents over a period, for a counterparty to verify offline. */
|
|
2034
|
+
async getIntentLedger(params = {}) {
|
|
2035
|
+
const q = new URLSearchParams();
|
|
2036
|
+
if (params.agentId) q.set("agent_id", params.agentId);
|
|
2037
|
+
if (params.days) q.set("days", String(params.days));
|
|
2038
|
+
const s = q.toString();
|
|
2039
|
+
return this.get(`/intents/ledger${s ? `?${s}` : ""}`);
|
|
2040
|
+
}
|
|
2041
|
+
/** Close an intent when the job ends. Further actions under it are off intent. */
|
|
2042
|
+
async completeIntent(intentId, status = "completed", outcome) {
|
|
2043
|
+
return this.post(`/intents/${encodeURIComponent(intentId)}/complete`, { status, outcome });
|
|
2044
|
+
}
|
|
2045
|
+
/** Intents for the org, newest first; filter by agent or status. */
|
|
2046
|
+
async listIntents(params = {}) {
|
|
2047
|
+
const q = new URLSearchParams();
|
|
2048
|
+
if (params.agentId) q.set("agent_id", params.agentId);
|
|
2049
|
+
if (params.status) q.set("status", params.status);
|
|
2050
|
+
if (params.limit) q.set("limit", String(params.limit));
|
|
2051
|
+
const s = q.toString();
|
|
2052
|
+
return this.get(`/intents${s ? `?${s}` : ""}`);
|
|
2053
|
+
}
|
|
1975
2054
|
/**
|
|
1976
2055
|
* Issue a platform-signed attestation of the swarm as it is now: roster
|
|
1977
2056
|
* and its hash, policy version and rules hash, charter, budget, kills,
|
|
@@ -2381,6 +2460,7 @@ export {
|
|
|
2381
2460
|
VorimDeniedError,
|
|
2382
2461
|
VorimError,
|
|
2383
2462
|
VorimSDK,
|
|
2463
|
+
canonicalIntent,
|
|
2384
2464
|
canonicalPayloadV0,
|
|
2385
2465
|
canonicalPayloadV1,
|
|
2386
2466
|
commitPayload,
|