@decidio/sdk 0.1.4 → 0.1.6
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/README.md +27 -12
- package/dist/adapters/_gate.d.ts +0 -2
- package/dist/adapters/_gate.js +0 -15
- package/dist/adapters/langgraph.d.ts +0 -3
- package/dist/adapters/langgraph.js +0 -10
- package/dist/adapters/openai.d.ts +0 -4
- package/dist/adapters/openai.js +0 -20
- package/dist/adapters/temporal.d.ts +0 -1
- package/dist/adapters/temporal.js +1 -13
- package/dist/cli.js +43 -113
- package/dist/guard.d.ts +0 -14
- package/dist/guard.js +1 -18
- package/dist/index.d.ts +0 -41
- package/dist/index.js +3 -81
- package/dist/inngest.d.ts +0 -20
- package/dist/inngest.js +0 -26
- package/dist/resume.d.ts +5 -61
- package/dist/resume.js +70 -66
- package/dist/signing.d.ts +0 -12
- package/dist/signing.js +0 -25
- package/openapi.yaml +1 -1
- package/package.json +5 -1
package/dist/signing.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
/** Sorted-key JCS — must match apps/api/src/canonical.ts byte-for-byte. */
|
|
2
1
|
export declare function canonicalize(v: unknown): string;
|
|
3
|
-
/** Generate a fresh Ed25519 keypair LOCALLY. Returns the public `did:key` (register this)
|
|
4
|
-
* and the PKCS8 private key base64 (keep this in the agent host's env as DECIDIO_AGENT_KEY —
|
|
5
|
-
* it never goes back to Decidio). */
|
|
6
2
|
export declare function generateKeypair(): {
|
|
7
3
|
did: string;
|
|
8
4
|
privateKeyBase64: string;
|
|
@@ -21,20 +17,12 @@ export interface RequesterIdentity {
|
|
|
21
17
|
signature: string;
|
|
22
18
|
};
|
|
23
19
|
}
|
|
24
|
-
/** Sign the CONFIRM call (bound to {action:"confirm", scope:decisionId}) so the gate can
|
|
25
|
-
* prove the caller is the receipt's original requester before granting the wrapper tier
|
|
26
|
-
* (application_confirmed). Returns undefined when no signing key is configured (the server
|
|
27
|
-
* then caps the report at agent_asserted). Used by EVERY confirm path — inline, durable
|
|
28
|
-
* resume, and the engine adapters — so the production paths confirm with a proof too. Also
|
|
29
|
-
* binds `workspaceId` (D-B3.6) when configured, so the confirm proof is tenant-scoped too. */
|
|
30
20
|
export declare function signConfirm(decisionId: string, cfg: {
|
|
31
21
|
agentId?: string;
|
|
32
22
|
agentKey?: string;
|
|
33
23
|
agentDid?: string;
|
|
34
24
|
workspaceId?: string;
|
|
35
25
|
}): RequesterIdentity | undefined;
|
|
36
|
-
/** Sign a request-bound identity proof. The returned object is sent verbatim as the
|
|
37
|
-
* `requesterIdentity` field of /agent/authorize. */
|
|
38
26
|
export declare function signBoundProof(privateKeyBase64: string, fields: {
|
|
39
27
|
agentId: string;
|
|
40
28
|
did: string;
|
package/dist/signing.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
// Client-side agent identity (§13 P0-8). The agent generates its Ed25519 keypair LOCALLY
|
|
2
|
-
// (the private key never crosses the wire — `init` registers only the public did:key) and
|
|
3
|
-
// signs a REQUEST-BOUND proof on each authorize: a detached Ed25519 JWS over
|
|
4
|
-
// canonical({agentId,did,action,amount,scope,nonce,exp}). Decidio's floor verifies the
|
|
5
|
-
// signature, binds it to the exact request, burns the single-use nonce, and checks the
|
|
6
|
-
// did against the agent registry — so the gate PROVES who is calling instead of trusting a
|
|
7
|
-
// label. This canonicalize + proof shape is byte-identical to apps/api (canonical.ts +
|
|
8
|
-
// a2a/identity.ts), so a proof signed here verifies there.
|
|
9
1
|
import { generateKeyPairSync, createPrivateKey, sign as edSign, randomUUID } from "node:crypto";
|
|
10
|
-
// base58btc (Bitcoin alphabet) — for the did:key multibase 'z' prefix.
|
|
11
2
|
const B58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
12
3
|
function b58encode(buf) {
|
|
13
4
|
const digits = [0];
|
|
@@ -34,7 +25,6 @@ function b58encode(buf) {
|
|
|
34
25
|
str += B58[digits[i]];
|
|
35
26
|
return str;
|
|
36
27
|
}
|
|
37
|
-
/** Sorted-key JCS — must match apps/api/src/canonical.ts byte-for-byte. */
|
|
38
28
|
export function canonicalize(v) {
|
|
39
29
|
if (v === null || typeof v !== "object")
|
|
40
30
|
return JSON.stringify(v);
|
|
@@ -43,9 +33,6 @@ export function canonicalize(v) {
|
|
|
43
33
|
const o = v;
|
|
44
34
|
return `{${Object.keys(o).sort().map((k) => `${JSON.stringify(k)}:${canonicalize(o[k])}`).join(",")}}`;
|
|
45
35
|
}
|
|
46
|
-
/** Generate a fresh Ed25519 keypair LOCALLY. Returns the public `did:key` (register this)
|
|
47
|
-
* and the PKCS8 private key base64 (keep this in the agent host's env as DECIDIO_AGENT_KEY —
|
|
48
|
-
* it never goes back to Decidio). */
|
|
49
36
|
export function generateKeypair() {
|
|
50
37
|
const { privateKey, publicKey } = generateKeyPairSync("ed25519");
|
|
51
38
|
const jwk = publicKey.export({ format: "jwk" });
|
|
@@ -54,27 +41,15 @@ export function generateKeypair() {
|
|
|
54
41
|
const privateKeyBase64 = privateKey.export({ format: "der", type: "pkcs8" }).toString("base64");
|
|
55
42
|
return { did, privateKeyBase64 };
|
|
56
43
|
}
|
|
57
|
-
/** Sign the CONFIRM call (bound to {action:"confirm", scope:decisionId}) so the gate can
|
|
58
|
-
* prove the caller is the receipt's original requester before granting the wrapper tier
|
|
59
|
-
* (application_confirmed). Returns undefined when no signing key is configured (the server
|
|
60
|
-
* then caps the report at agent_asserted). Used by EVERY confirm path — inline, durable
|
|
61
|
-
* resume, and the engine adapters — so the production paths confirm with a proof too. Also
|
|
62
|
-
* binds `workspaceId` (D-B3.6) when configured, so the confirm proof is tenant-scoped too. */
|
|
63
44
|
export function signConfirm(decisionId, cfg) {
|
|
64
45
|
if (!cfg.agentKey || !cfg.agentDid || !cfg.agentId)
|
|
65
46
|
return undefined;
|
|
66
47
|
return signBoundProof(cfg.agentKey, { agentId: cfg.agentId, did: cfg.agentDid, action: "confirm", amount: 0, scope: decisionId, workspaceId: cfg.workspaceId });
|
|
67
48
|
}
|
|
68
|
-
/** Sign a request-bound identity proof. The returned object is sent verbatim as the
|
|
69
|
-
* `requesterIdentity` field of /agent/authorize. */
|
|
70
49
|
export function signBoundProof(privateKeyBase64, fields) {
|
|
71
50
|
const key = createPrivateKey({ key: Buffer.from(privateKeyBase64, "base64"), format: "der", type: "pkcs8" });
|
|
72
51
|
const nonce = fields.nonce ?? randomUUID();
|
|
73
52
|
const exp = (fields.now ?? Date.now()) + (fields.ttlMs ?? 120_000);
|
|
74
|
-
// OMIT scope/workspaceId when absent so the canonical bytes match the server + the Python SDK — a key
|
|
75
|
-
// with an undefined value would serialize as literal "undefined", which Python can't reproduce, and a
|
|
76
|
-
// legacy (no-workspace) proof must stay byte-identical. The server's bound-payload reconstruction
|
|
77
|
-
// omits them the same way (a2a/identity.ts).
|
|
78
53
|
const payloadObj = { agentId: fields.agentId, did: fields.did, action: fields.action, amount: fields.amount, ...(fields.scope !== undefined ? { scope: fields.scope } : {}), ...(fields.workspaceId !== undefined ? { workspaceId: fields.workspaceId } : {}), nonce, exp };
|
|
79
54
|
const payload = Buffer.from(canonicalize(payloadObj), "utf8").toString("base64url");
|
|
80
55
|
const protectedHdr = Buffer.from(JSON.stringify({ alg: "EdDSA", kid: fields.did }), "utf8").toString("base64url");
|
package/openapi.yaml
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
openapi: 3.1.0
|
|
6
6
|
info:
|
|
7
7
|
title: Decidio Agent Gate
|
|
8
|
-
version: 0.1.
|
|
8
|
+
version: 0.1.6
|
|
9
9
|
description: >
|
|
10
10
|
Authorize an AI-agent action (proceed | route | block), confirm the captured outcome, and
|
|
11
11
|
receive the signed resume webhook when a routed action is decided. Every outcome seals a
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decidio/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "One-line approval gate for AI-agent actions. Wrap a risky tool call with guard.protect(); Decidio's policy engine decides proceed | route | block, a human approves routed actions, and every outcome is sealed as a verifiable Authority Receipt.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -82,5 +82,9 @@
|
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
84
|
"@decidio/verify": "^0.1.3"
|
|
85
|
+
},
|
|
86
|
+
"author": "OmniTwin Technologies Inc.",
|
|
87
|
+
"bugs": {
|
|
88
|
+
"url": "https://decidioai.com/support/"
|
|
85
89
|
}
|
|
86
90
|
}
|