@vorim/sdk 4.1.0 → 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 +14 -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.cjs +3 -2
- package/dist/integrations/amazon.cjs.map +1 -1
- package/dist/integrations/amazon.d.cts +2 -2
- package/dist/integrations/amazon.d.ts +2 -2
- package/dist/integrations/amazon.js +3 -2
- package/dist/integrations/amazon.js.map +1 -1
- 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.cjs +3 -2
- package/dist/integrations/delivery.cjs.map +1 -1
- package/dist/integrations/delivery.d.cts +2 -2
- package/dist/integrations/delivery.d.ts +2 -2
- package/dist/integrations/delivery.js +3 -2
- package/dist/integrations/delivery.js.map +1 -1
- package/dist/integrations/ebay.cjs +3 -2
- package/dist/integrations/ebay.cjs.map +1 -1
- package/dist/integrations/ebay.d.cts +2 -2
- package/dist/integrations/ebay.d.ts +2 -2
- package/dist/integrations/ebay.js +3 -2
- package/dist/integrations/ebay.js.map +1 -1
- package/dist/integrations/entra.d.cts +1 -1
- package/dist/integrations/entra.d.ts +1 -1
- package/dist/integrations/etsy.cjs +3 -2
- package/dist/integrations/etsy.cjs.map +1 -1
- package/dist/integrations/etsy.d.cts +2 -2
- package/dist/integrations/etsy.d.ts +2 -2
- package/dist/integrations/etsy.js +3 -2
- package/dist/integrations/etsy.js.map +1 -1
- package/dist/integrations/fhir.d.cts +1 -1
- package/dist/integrations/fhir.d.ts +1 -1
- package/dist/integrations/google-merchant.cjs +3 -2
- package/dist/integrations/google-merchant.cjs.map +1 -1
- package/dist/integrations/google-merchant.d.cts +2 -2
- package/dist/integrations/google-merchant.d.ts +2 -2
- package/dist/integrations/google-merchant.js +3 -2
- package/dist/integrations/google-merchant.js.map +1 -1
- 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.cjs +3 -2
- package/dist/integrations/meta.cjs.map +1 -1
- package/dist/integrations/meta.d.cts +2 -2
- package/dist/integrations/meta.d.ts +2 -2
- package/dist/integrations/meta.js +3 -2
- package/dist/integrations/meta.js.map +1 -1
- 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.cjs +3 -2
- package/dist/integrations/social-ads.cjs.map +1 -1
- package/dist/integrations/social-ads.d.cts +2 -2
- package/dist/integrations/social-ads.d.ts +2 -2
- package/dist/integrations/social-ads.js +3 -2
- package/dist/integrations/social-ads.js.map +1 -1
- 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.cjs +3 -2
- package/dist/integrations/tiktok-shop.cjs.map +1 -1
- package/dist/integrations/tiktok-shop.d.cts +2 -2
- package/dist/integrations/tiktok-shop.d.ts +2 -2
- package/dist/integrations/tiktok-shop.js +3 -2
- package/dist/integrations/tiktok-shop.js.map +1 -1
- 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.cjs +3 -2
- package/dist/integrations/walmart.cjs.map +1 -1
- package/dist/integrations/walmart.d.cts +2 -2
- package/dist/integrations/walmart.d.ts +2 -2
- package/dist/integrations/walmart.js +3 -2
- package/dist/integrations/walmart.js.map +1 -1
- 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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog — @vorim/sdk
|
|
2
2
|
|
|
3
|
+
## 4.2.0
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **Agent behaviour and intent.** `declareIntent({ agentId, goal, expectedActionTypes?, expectedTargets?, maxAmount?, amountCurrency?, amountField?, maxActions?, ttlSeconds?, workflowId? })` records what an agent is about to do before it acts; pass the returned `intent_id` as `intentId` on every `beforeAction()` of that job and Vorim judges each action against it. `RuntimeDecision.intent` carries `{ id, alignment: 'aligned' | 'off_intent' | 'none', reasons }`. `completeIntent(intentId, 'completed' | 'abandoned', outcome?)` closes it; `listIntents({ agentId?, status?, limit? })` lists them; `getIntentLedger({ agentId?, days? })` returns a platform-signed ledger of declared intents for a counterparty to verify offline against `GET /trust/keys`.
|
|
8
|
+
- When the SDK holds the agent's key (`useAgentKey`, or a registration in this process) the declaration is signed with it, so the intent is the agent's own word; `canonicalIntent()` is exported so callers can verify what was signed.
|
|
9
|
+
- Rules can now use `intent_required` (actions with no intent), `off_intent` (actions that crossed their intent) and `behaviour_drift_gt` (the agent's last 24 hours against its 30-day baseline, 0-100). Nothing changes for callers that never declare an intent.
|
|
10
|
+
|
|
11
|
+
## 4.1.1
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- **A commerce ceiling is a hard stop.** On an operation that always needs a person (eBay `placeOrder` / `placeBid`), an amount over `maxOrderAmount` was sent to the approver even with `overLimit: 'deny'`. It is now refused at once without asking anyone; with `overLimit: 'escalate'` it still goes to the approver. Found by an end-to-end test of the buying flow against a live API (approve, deny, timeout, over-limit, missing scope, suspension, signed approvals, offline bundle verification: 24/24).
|
|
16
|
+
|
|
3
17
|
## 4.1.0
|
|
4
18
|
|
|
5
19
|
### Added
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VorimSDK } from './index.js';
|
|
2
|
-
import { P as PermissionScope } from './types-
|
|
2
|
+
import { P as PermissionScope } from './types-DwPEBj7p.js';
|
|
3
3
|
import { E as EscalationPolicy } from './_runtime-gate-DOJUKJBu.js';
|
|
4
4
|
|
|
5
5
|
/** What a ceiling an operation is measured against. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VorimSDK } from './index.cjs';
|
|
2
|
-
import { P as PermissionScope } from './types-
|
|
2
|
+
import { P as PermissionScope } from './types-DwPEBj7p.cjs';
|
|
3
3
|
import { E as EscalationPolicy } from './_runtime-gate-DOJUKJBu.cjs';
|
|
4
4
|
|
|
5
5
|
/** What a ceiling an operation is measured against. */
|
package/dist/index.cjs
CHANGED
|
@@ -37,6 +37,7 @@ __export(index_exports, {
|
|
|
37
37
|
VorimDeniedError: () => VorimDeniedError,
|
|
38
38
|
VorimError: () => VorimError,
|
|
39
39
|
VorimSDK: () => VorimSDK,
|
|
40
|
+
canonicalIntent: () => canonicalIntent,
|
|
40
41
|
canonicalPayloadV0: () => canonicalPayloadV0,
|
|
41
42
|
canonicalPayloadV1: () => canonicalPayloadV1,
|
|
42
43
|
commitPayload: () => commitPayload,
|
|
@@ -931,7 +932,15 @@ async function verifyHttpRequest(request, options) {
|
|
|
931
932
|
}
|
|
932
933
|
|
|
933
934
|
// src/index.ts
|
|
934
|
-
|
|
935
|
+
function canonicalIntent(value) {
|
|
936
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
937
|
+
if (Array.isArray(value)) return `[${value.map((v) => v === void 0 ? "null" : canonicalIntent(v)).join(",")}]`;
|
|
938
|
+
if (value instanceof Date) return JSON.stringify(value.toISOString());
|
|
939
|
+
const obj = value;
|
|
940
|
+
const keys = Object.keys(obj).filter((k) => obj[k] !== void 0).sort();
|
|
941
|
+
return `{${keys.map((k) => `${JSON.stringify(k)}:${canonicalIntent(obj[k])}`).join(",")}}`;
|
|
942
|
+
}
|
|
943
|
+
var SDK_VERSION = true ? "4.2.0" : "0.0.0";
|
|
935
944
|
var USER_AGENT = `vorim-sdk/${SDK_VERSION}`;
|
|
936
945
|
function sleep(ms) {
|
|
937
946
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -1552,7 +1561,8 @@ var VorimSDK = class _VorimSDK {
|
|
|
1552
1561
|
estimated_tokens: input.estimatedTokens,
|
|
1553
1562
|
trace_id: input.traceId,
|
|
1554
1563
|
span_id: input.spanId,
|
|
1555
|
-
traceparent: input.traceparent
|
|
1564
|
+
traceparent: input.traceparent,
|
|
1565
|
+
intent_id: input.intentId
|
|
1556
1566
|
};
|
|
1557
1567
|
let raw;
|
|
1558
1568
|
try {
|
|
@@ -1574,7 +1584,8 @@ var VorimSDK = class _VorimSDK {
|
|
|
1574
1584
|
policyVersion: 0,
|
|
1575
1585
|
swarmId: null,
|
|
1576
1586
|
escalationResolution: null,
|
|
1577
|
-
approval: null
|
|
1587
|
+
approval: null,
|
|
1588
|
+
intent: null
|
|
1578
1589
|
};
|
|
1579
1590
|
}
|
|
1580
1591
|
throw err;
|
|
@@ -1723,7 +1734,12 @@ var VorimSDK = class _VorimSDK {
|
|
|
1723
1734
|
policyVersion: raw?.policy_version ?? 0,
|
|
1724
1735
|
swarmId: typeof raw?.swarm_id === "string" ? raw.swarm_id : null,
|
|
1725
1736
|
escalationResolution: resolution,
|
|
1726
|
-
approval: toApprovalAttestation(raw?.approval)
|
|
1737
|
+
approval: toApprovalAttestation(raw?.approval),
|
|
1738
|
+
intent: raw?.intent && typeof raw.intent === "object" ? {
|
|
1739
|
+
id: typeof raw.intent.id === "string" ? raw.intent.id : null,
|
|
1740
|
+
alignment: raw.intent.alignment === "aligned" || raw.intent.alignment === "off_intent" ? raw.intent.alignment : "none",
|
|
1741
|
+
reasons: Array.isArray(raw.intent.reasons) ? raw.intent.reasons.filter((r) => typeof r === "string") : []
|
|
1742
|
+
} : null
|
|
1727
1743
|
};
|
|
1728
1744
|
}
|
|
1729
1745
|
// ─── Audit ────────────────────────────────────────────────────────
|
|
@@ -2036,6 +2052,70 @@ var VorimSDK = class _VorimSDK {
|
|
|
2036
2052
|
async getSwarmScore(swarmId) {
|
|
2037
2053
|
return this.get(`/swarms/${encodeURIComponent(swarmId)}/score`);
|
|
2038
2054
|
}
|
|
2055
|
+
// ─── Agent behaviour and intent ───────────────────────────────────────
|
|
2056
|
+
//
|
|
2057
|
+
// An intent is what the agent says it is about to do, declared before it
|
|
2058
|
+
// acts. Pass its id as `intentId` on every beforeAction() of that job and
|
|
2059
|
+
// Vorim judges each action against it (aligned / off_intent); the Behaviour
|
|
2060
|
+
// page shows the goal next to the steps, and rules can hold or block work
|
|
2061
|
+
// that is off intent or undeclared (`off_intent`, `intent_required`).
|
|
2062
|
+
/**
|
|
2063
|
+
* Declare an intent for an agent. Needs the `agents:write` scope.
|
|
2064
|
+
*
|
|
2065
|
+
* @example
|
|
2066
|
+
* const intent = await vorim.declareIntent({
|
|
2067
|
+
* agentId: 'agid_acme_refunds',
|
|
2068
|
+
* goal: 'Refund order 4471: the item arrived damaged',
|
|
2069
|
+
* expectedActionTypes: ['lookup', 'refund', 'email'],
|
|
2070
|
+
* expectedTargets: ['shopify:order', 'stripe:refund', 'email:customer'],
|
|
2071
|
+
* maxAmount: 8000, amountCurrency: 'GBP', ttlSeconds: 1800,
|
|
2072
|
+
* });
|
|
2073
|
+
* await vorim.beforeAction({ agentId, actionType: 'refund', actionTarget: 'stripe:refund', requiredScope: 'agent:transact', payload: { amount: 7900 }, intentId: intent.intent_id });
|
|
2074
|
+
* await vorim.completeIntent(intent.intent_id, 'completed', 'Refunded 79.00');
|
|
2075
|
+
*/
|
|
2076
|
+
async declareIntent(input) {
|
|
2077
|
+
const list = (xs) => Array.from(new Set((xs ?? []).map((s) => String(s).trim()).filter(Boolean)));
|
|
2078
|
+
const fields = {
|
|
2079
|
+
agent_id: input.agentId,
|
|
2080
|
+
goal: String(input.goal).trim(),
|
|
2081
|
+
expected_action_types: list(input.expectedActionTypes),
|
|
2082
|
+
expected_targets: list(input.expectedTargets),
|
|
2083
|
+
max_amount: typeof input.maxAmount === "number" ? input.maxAmount : null,
|
|
2084
|
+
amount_currency: input.amountCurrency ? input.amountCurrency.toUpperCase() : null,
|
|
2085
|
+
amount_field: input.amountField ?? null,
|
|
2086
|
+
max_actions: typeof input.maxActions === "number" ? input.maxActions : null,
|
|
2087
|
+
ttl_seconds: typeof input.ttlSeconds === "number" ? input.ttlSeconds : 86400
|
|
2088
|
+
};
|
|
2089
|
+
const key = this.agentKeys.get(input.agentId);
|
|
2090
|
+
let signed;
|
|
2091
|
+
if (key) {
|
|
2092
|
+
const signed_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
2093
|
+
const signature = await this.sign(canonicalIntent({ type: "vorim-agent-intent", v: 1, ...fields, signed_at }), key);
|
|
2094
|
+
signed = { signature, signed_at };
|
|
2095
|
+
}
|
|
2096
|
+
return this.post("/intents", { ...fields, workflow_id: input.workflowId, ...signed });
|
|
2097
|
+
}
|
|
2098
|
+
/** A platform-signed ledger of intents over a period, for a counterparty to verify offline. */
|
|
2099
|
+
async getIntentLedger(params = {}) {
|
|
2100
|
+
const q = new URLSearchParams();
|
|
2101
|
+
if (params.agentId) q.set("agent_id", params.agentId);
|
|
2102
|
+
if (params.days) q.set("days", String(params.days));
|
|
2103
|
+
const s = q.toString();
|
|
2104
|
+
return this.get(`/intents/ledger${s ? `?${s}` : ""}`);
|
|
2105
|
+
}
|
|
2106
|
+
/** Close an intent when the job ends. Further actions under it are off intent. */
|
|
2107
|
+
async completeIntent(intentId, status = "completed", outcome) {
|
|
2108
|
+
return this.post(`/intents/${encodeURIComponent(intentId)}/complete`, { status, outcome });
|
|
2109
|
+
}
|
|
2110
|
+
/** Intents for the org, newest first; filter by agent or status. */
|
|
2111
|
+
async listIntents(params = {}) {
|
|
2112
|
+
const q = new URLSearchParams();
|
|
2113
|
+
if (params.agentId) q.set("agent_id", params.agentId);
|
|
2114
|
+
if (params.status) q.set("status", params.status);
|
|
2115
|
+
if (params.limit) q.set("limit", String(params.limit));
|
|
2116
|
+
const s = q.toString();
|
|
2117
|
+
return this.get(`/intents${s ? `?${s}` : ""}`);
|
|
2118
|
+
}
|
|
2039
2119
|
/**
|
|
2040
2120
|
* Issue a platform-signed attestation of the swarm as it is now: roster
|
|
2041
2121
|
* and its hash, policy version and rules hash, charter, budget, kills,
|
|
@@ -2446,6 +2526,7 @@ async function deviceLogin(opts) {
|
|
|
2446
2526
|
VorimDeniedError,
|
|
2447
2527
|
VorimError,
|
|
2448
2528
|
VorimSDK,
|
|
2529
|
+
canonicalIntent,
|
|
2449
2530
|
canonicalPayloadV0,
|
|
2450
2531
|
canonicalPayloadV1,
|
|
2451
2532
|
commitPayload,
|