@odingard/guardian-sdk 0.0.0-stage → 0.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/LICENSE +201 -0
- package/README.md +302 -2
- package/dist/contracts.js +9865 -0
- package/dist/index.js +14437 -0
- package/dist/public-catalog.v1.json +6915 -0
- package/dist-dts/catalog.d.ts +14 -0
- package/dist-dts/client.d.ts +130 -0
- package/dist-dts/contracts/action-pack.d.ts +464 -0
- package/dist-dts/contracts/action-parameters.d.ts +34 -0
- package/dist-dts/contracts/action-registry.d.ts +287 -0
- package/dist-dts/contracts/action.d.ts +2358 -0
- package/dist-dts/contracts/agent-state.d.ts +386 -0
- package/dist-dts/contracts/api.d.ts +78 -0
- package/dist-dts/contracts/approval.d.ts +425 -0
- package/dist-dts/contracts/assurance.d.ts +60 -0
- package/dist-dts/contracts/authority-graph.d.ts +294 -0
- package/dist-dts/contracts/authority-state.d.ts +108 -0
- package/dist-dts/contracts/authority.d.ts +339 -0
- package/dist-dts/contracts/billing.d.ts +32 -0
- package/dist-dts/contracts/calendar.d.ts +146 -0
- package/dist-dts/contracts/canonical-json.d.ts +4 -0
- package/dist-dts/contracts/capability.d.ts +28 -0
- package/dist-dts/contracts/commerce.d.ts +133 -0
- package/dist-dts/contracts/denial.d.ts +648 -0
- package/dist-dts/contracts/digest.d.ts +2 -0
- package/dist-dts/contracts/email.d.ts +45 -0
- package/dist-dts/contracts/evidence.d.ts +1087 -0
- package/dist-dts/contracts/execution.d.ts +1732 -0
- package/dist-dts/contracts/files.d.ts +61 -0
- package/dist-dts/contracts/identifiers.d.ts +49 -0
- package/dist-dts/contracts/index.d.ts +41 -0
- package/dist-dts/contracts/intent.d.ts +335 -0
- package/dist-dts/contracts/lineage.d.ts +218 -0
- package/dist-dts/contracts/local.d.ts +101 -0
- package/dist-dts/contracts/multi-principal.d.ts +292 -0
- package/dist-dts/contracts/multiparty.d.ts +169 -0
- package/dist-dts/contracts/obligation.d.ts +196 -0
- package/dist-dts/contracts/plan.d.ts +67 -0
- package/dist-dts/contracts/policy-simulation.d.ts +681 -0
- package/dist-dts/contracts/prerequisite.d.ts +147 -0
- package/dist-dts/contracts/protected-data.d.ts +160 -0
- package/dist-dts/contracts/receipt.d.ts +3126 -0
- package/dist-dts/contracts/resource-claims.d.ts +146 -0
- package/dist-dts/contracts/runtime.d.ts +111 -0
- package/dist-dts/contracts/safety-envelope.d.ts +287 -0
- package/dist-dts/contracts/sequence.d.ts +132 -0
- package/dist-dts/contracts/sources.d.ts +191 -0
- package/dist-dts/contracts/tools.d.ts +232 -0
- package/dist-dts/contracts/transaction.d.ts +360 -0
- package/dist-dts/contracts-entry.d.ts +1 -0
- package/dist-dts/embedded.d.ts +58 -0
- package/dist-dts/evidence/evidence.d.ts +25 -0
- package/dist-dts/evidence/receipt.d.ts +61 -0
- package/dist-dts/index.d.ts +5 -0
- package/dist-dts/lifecycle.d.ts +25 -0
- package/dist-dts/proposal.d.ts +41 -0
- package/dist-dts/receipts.d.ts +37 -0
- package/package.json +56 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,303 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src=".github/assets/guardian-logo.png" alt="Guardian — human authority for AI" width="640" />
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
# @odingard/guardian-sdk
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@odingard/guardian-sdk)
|
|
8
|
+
[](https://www.npmjs.com/package/@odingard/guardian-sdk)
|
|
9
|
+
[](https://registry.modelcontextprotocol.io/)
|
|
10
|
+
[](https://mcprush.com/to/odingard-guardian-mcp?ref=badge)
|
|
11
|
+
[](LICENSE)
|
|
12
|
+
|
|
13
|
+
**Human Authority Infrastructure for Autonomous AI.** The agent proposes; the human
|
|
14
|
+
decides. This SDK lets an AI agent request governed capabilities and execute
|
|
15
|
+
consequential actions under human authority. Every decision is deterministic (`ALLOW` / `ASK` / `DENY`) and every
|
|
16
|
+
execution produces a tamper-evident receipt.
|
|
17
|
+
|
|
18
|
+
Hosted Guardian: [guardian.odingard.com](https://guardian.odingard.com) — free tier for developers
|
|
19
|
+
(1 agent, 1 connection, 50 protected actions/month), no card required.
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @odingard/guardian-sdk
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Requires Node.js >= 22 (receipt verification uses `node:crypto` Ed25519; browser runtimes are not supported in 0.2).
|
|
28
|
+
|
|
29
|
+
## Quickstart
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { classifyRequestResult, createGuardianClient } from "@odingard/guardian-sdk";
|
|
33
|
+
|
|
34
|
+
const guardian = createGuardianClient({
|
|
35
|
+
baseUrl: "https://guardian-api.odingard.com",
|
|
36
|
+
credential: process.env.GUARDIAN_AGENT_CREDENTIAL!, // gac1.… issued per agent
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// 1. The agent asks for a capability — it never holds real credentials.
|
|
40
|
+
const result = await guardian.request({
|
|
41
|
+
action: "tool.invoke",
|
|
42
|
+
connectionId: "con_…",
|
|
43
|
+
toolName: "refund_order",
|
|
44
|
+
arguments: { orderId: "ord_123" },
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const d = classifyRequestResult(result); // the one fail-closed reading
|
|
48
|
+
|
|
49
|
+
if (d.decision === "ALLOW") {
|
|
50
|
+
// 2. Guardian minted a single-use capability. Execute it.
|
|
51
|
+
const execution = await guardian.execute({
|
|
52
|
+
requestId: d.requestId,
|
|
53
|
+
capabilityToken: d.capabilityToken,
|
|
54
|
+
});
|
|
55
|
+
console.log(execution.ok ? execution.receipt : execution.reasonCode);
|
|
56
|
+
} else if (d.decision === "ASK") {
|
|
57
|
+
// Held for a human. Keep d.requestId; after the human approves:
|
|
58
|
+
const granted = classifyRequestResult(await guardian.claim(d.requestId));
|
|
59
|
+
// …execute as above once granted.decision === "ALLOW".
|
|
60
|
+
}
|
|
61
|
+
// d.decision === "DENY" → refused before execution, with d.reasonCode.
|
|
62
|
+
// Ambiguity (ALLOW without a token, unreachable Guardian, unknown shape)
|
|
63
|
+
// is always DENY.
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## What the agent can and cannot do
|
|
67
|
+
|
|
68
|
+
- The agent only ever holds a scoped, revocable agent credential (`gac1.…`).
|
|
69
|
+
- Provider secrets (API keys, OAuth tokens) live in the Guardian vault and are
|
|
70
|
+
leased to the adapter at execution time — the agent never sees them.
|
|
71
|
+
- `ASK` decisions wait for a human. `DENY` stops the action before execution.
|
|
72
|
+
- `receipts(requestId)` returns the machine-readable proof of what happened,
|
|
73
|
+
who authorized it, and what authority version applied.
|
|
74
|
+
|
|
75
|
+
## Lifecycle and governed actions (0.2)
|
|
76
|
+
|
|
77
|
+
| Result from `request` / `claim` | `classifyRequestResult` | What to do |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| `{ ok: true, decision: "ALLOW", capabilityToken }` | `ALLOW` | `execute({ requestId, capabilityToken })` |
|
|
80
|
+
| `{ ok: true, decision: "ASK" }` or `{ ok: false, reasonCode: "APPROVAL_REQUIRED", requestId }` | `ASK` | keep `requestId`; `claim(requestId)` after the human decides |
|
|
81
|
+
| anything else (DENY, `SERVICE_UNAVAILABLE`, ALLOW without token) | `DENY` | do not run the effect |
|
|
82
|
+
|
|
83
|
+
A held ASK always carries its `requestId` (fixed in 0.2 — 0.1 dropped it).
|
|
84
|
+
|
|
85
|
+
Invocation types: `tool.invoke`, `mcp.install`, `mcp.enable` (typed), and the
|
|
86
|
+
governed pass-through actions `api.request`, `protected_data.derive|transform|export`,
|
|
87
|
+
`agent.message`, `agent.share_context`, `agent.share_memory`,
|
|
88
|
+
`agent.transfer_task`, `agent.transfer_capability` (you supply
|
|
89
|
+
`materialParameters`; Guardian validates them). Optional provenance:
|
|
90
|
+
`purpose`, `intentId`, `planId`, `parentActionId`, `sourceEffectId`. The wire
|
|
91
|
+
schemas are exported from `@odingard/guardian-sdk/contracts`, synced from
|
|
92
|
+
Guardian's canonical contracts.
|
|
93
|
+
|
|
94
|
+
## Portable receipts — verify without an account
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
import { fetchReceiptVerificationKeys, verifyReceiptOffline, verifyReceiptOnline } from "@odingard/guardian-sdk";
|
|
98
|
+
|
|
99
|
+
const { receipt } = await guardian.portableReceipt(requestId); // greceipt.v1
|
|
100
|
+
const keys = await fetchReceiptVerificationKeys("https://guardian-api.odingard.com"); // public
|
|
101
|
+
verifyReceiptOffline(receipt, keys.keys);
|
|
102
|
+
// → { valid: true, decision: "ALLOW", effect: "verified", subject } — or { valid: false, reasonCode }
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Offline verification checks the Ed25519 signature over the
|
|
106
|
+
`guardian-canonical-json.v1` body and re-derives every embedded record against
|
|
107
|
+
the receipt's evidence chain. It needs no credential, plan or Guardian service
|
|
108
|
+
once you hold the keys, and is never billed. `verifyReceiptOnline` asks a
|
|
109
|
+
Guardian deployment to do the same over the public `POST /v1/receipts/verify`.
|
|
110
|
+
|
|
111
|
+
## Embedded approvals — humans only
|
|
112
|
+
|
|
113
|
+
`createEmbeddedApprovalClient({ baseUrl, sessionToken })` lets your own UI list,
|
|
114
|
+
view, approve/deny and revoke pending approvals. It requires a **human** session
|
|
115
|
+
token. Agent credentials (`gak_…`, `gac1.…`) and capability tokens (`gcap.…`)
|
|
116
|
+
are refused locally (`HUMAN_SESSION_REQUIRED`) before any request is sent, and
|
|
117
|
+
the server independently accepts only human sessions on these routes. Agent
|
|
118
|
+
credentials can never approve, create grants or revoke.
|
|
119
|
+
|
|
120
|
+
## Catalog metadata (declarative)
|
|
121
|
+
|
|
122
|
+
`guardianCatalog` (also `@odingard/guardian-sdk/catalog.json`) is generated from
|
|
123
|
+
Guardian's canonical catalog: 62 verticals, 25 agent systems, 48 agent roles,
|
|
124
|
+
221 entities, each vertical with its tier and maturity. It grants nothing:
|
|
125
|
+
every action is still decided at runtime under a human's policy. Current
|
|
126
|
+
honest status: 3 verticals `governed`, 58 `integration-ready` (governed
|
|
127
|
+
decision path; external adapters declared, not built), 1
|
|
128
|
+
`production-integrated` (recorded external-system proof). Maturity L1 = built-in
|
|
129
|
+
governed, L2 = modeled/decidable, L3 = production-integrated with recorded proof.
|
|
130
|
+
`verticalsForAction("tool.invoke")` lists verticals using an action.
|
|
131
|
+
|
|
132
|
+
## Guardian for Steel — `@odingard/guardian-steel`
|
|
133
|
+
|
|
134
|
+
Browser-agent checkout governed by Guardian: the agent can only propose
|
|
135
|
+
`steel.checkout.submit`; ALLOW/ASK/DENY happens before the order; the Steel
|
|
136
|
+
session and merchant credential stay on the protected executor side. See
|
|
137
|
+
[`packages/steel/README.md`](packages/steel/README.md) for the boundary and
|
|
138
|
+
current maturity.
|
|
139
|
+
|
|
140
|
+
## Maturity of what this SDK reaches
|
|
141
|
+
|
|
142
|
+
| Path | Status |
|
|
143
|
+
|---|---|
|
|
144
|
+
| Decision + capability + execute for `api.request`, Gmail, Calendar, tool/MCP connections | LIVE on hosted Guardian |
|
|
145
|
+
| Portable receipt retrieval + offline/online verification | LIVE (staging and production publish keys) |
|
|
146
|
+
| Embedded human approvals | LIVE routes; needs a human session from your Guardian sign-in |
|
|
147
|
+
| Steel checkout | agent side published; protected executor proven in-process, not yet injected into hosted Guardian |
|
|
148
|
+
| Framework `inProcess` mode | decision-gated only — see below |
|
|
149
|
+
|
|
150
|
+
## MCP server
|
|
151
|
+
|
|
152
|
+
No code needed for MCP-native agents — `@odingard/guardian-mcp` is a stdio
|
|
153
|
+
MCP server exposing `guardian_invoke_tool`, `guardian_claim` and
|
|
154
|
+
`guardian_receipt`. Listed on the official MCP registry as
|
|
155
|
+
`io.github.Odingard/guardian-mcp` — see [mcp-server/README.md](mcp-server/README.md).
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
npm install -g @odingard/guardian-mcp
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
```json
|
|
162
|
+
{
|
|
163
|
+
"mcpServers": {
|
|
164
|
+
"guardian": {
|
|
165
|
+
"command": "guardian-mcp",
|
|
166
|
+
"env": {
|
|
167
|
+
"GUARDIAN_BASE_URL": "https://guardian-api.odingard.com",
|
|
168
|
+
"GUARDIAN_AGENT_CREDENTIAL": "gac1.…",
|
|
169
|
+
"GUARDIAN_CONNECTION_ID": "con_…"
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Plans and limits
|
|
177
|
+
|
|
178
|
+
Guardian is free for individuals — no card required, with the same core
|
|
179
|
+
authority protections on every plan. Usage is metered per month on
|
|
180
|
+
protected actions (the consequential things an agent can cause); reading
|
|
181
|
+
receipts and requests is never metered.
|
|
182
|
+
|
|
183
|
+
| Plan | Price | Connections | Agents | Protected actions / month |
|
|
184
|
+
|------|-------|-------------|--------|---------------------------|
|
|
185
|
+
| Free | $0 | 1 | 1 | 50 |
|
|
186
|
+
| Guardian Personal | $19/month or $190/year | 10 | 25 | 50,000 |
|
|
187
|
+
| Guardian Family | $39/month or $390/year | 50 | 250 | 500,000 |
|
|
188
|
+
| Guardian Developer | $99/month plus protected-action usage | 250 | 1,000 | 5,000,000 |
|
|
189
|
+
|
|
190
|
+
Over a limit, the API returns `403 PLAN_LIMIT_EXCEEDED` naming your plan,
|
|
191
|
+
the limit, and current usage. Upgrade in the console → Billing
|
|
192
|
+
(`POST /v1/billing/checkout` with `{plan, interval}` issues a Stripe
|
|
193
|
+
Checkout URL; monthly and annual billing are both offered).
|
|
194
|
+
|
|
195
|
+
## Framework adapters
|
|
196
|
+
|
|
197
|
+
Drop-in wrappers that put an agent framework's tool calls behind the same
|
|
198
|
+
ALLOW / ASK / DENY triad — nothing runs before a decision, and no tool
|
|
199
|
+
ever runs without a capability issued for that exact call.
|
|
200
|
+
|
|
201
|
+
Two execution modes, per tool or per wrapper (`mode` / `modes` options):
|
|
202
|
+
|
|
203
|
+
- `remote` (default): the tool name is a registered Guardian catalog
|
|
204
|
+
entry — a bounded HTTP(S) call Guardian performs itself on `ALLOW`.
|
|
205
|
+
`client.execute` IS the execution; the call resolves to the ALLOW
|
|
206
|
+
receipt and the local impl never runs.
|
|
207
|
+
- `inProcess` (opt-in): the local impl IS the tool. It runs only after
|
|
208
|
+
the capability is issued, then `client.execute` redeems + records the
|
|
209
|
+
evidence — needs a `transport: "record"` catalog entry, auto-installed
|
|
210
|
+
via `mcp.install` on first use (WO-021 control plane required).
|
|
211
|
+
|
|
212
|
+
### `remote` vs `inProcess` — read this
|
|
213
|
+
|
|
214
|
+
`remote` (default): Guardian holds the effect. Nothing local runs; after ALLOW
|
|
215
|
+
the SDK calls `execute` and Guardian's adapter performs the action.
|
|
216
|
+
|
|
217
|
+
`inProcess`: your local tool body runs **after an ALLOW decision but before the
|
|
218
|
+
capability is redeemed**. Redemption-time checks (revocation, expiry,
|
|
219
|
+
single-use) therefore land after the effect, and the effect itself is not
|
|
220
|
+
mediated by Guardian. It is decision-gated, not pre-execution enforcement. If
|
|
221
|
+
redemption then fails, `GuardianExecutionFailed.localEffectRan === true` —
|
|
222
|
+
treat it as an incident. Use `remote` wherever Guardian must hold the effect.
|
|
223
|
+
|
|
224
|
+
### Vercel AI SDK — `@odingard/guardian-vercel-ai`
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
npm install @odingard/guardian-vercel-ai
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
```ts
|
|
231
|
+
import { createGuardianClient } from "@odingard/guardian-sdk";
|
|
232
|
+
import { GuardianApprovalPending, GuardianDenied, withGuardian }
|
|
233
|
+
from "@odingard/guardian-vercel-ai";
|
|
234
|
+
|
|
235
|
+
const guardian = createGuardianClient({ baseUrl, credential });
|
|
236
|
+
const tools = withGuardian({ refund_order, send_email }, {
|
|
237
|
+
client: guardian,
|
|
238
|
+
connectionId: "con_…",
|
|
239
|
+
agentName: "billing-agent",
|
|
240
|
+
modes: { refund_order: "inProcess" }, // send_email stays remote
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
// ALLOW remote: client.execute performs the catalog call, call resolves
|
|
244
|
+
// to the ALLOW receipt. ALLOW inProcess: local impl runs, then
|
|
245
|
+
// execute redeems + records it, call resolves to the impl output.
|
|
246
|
+
// ASK: GuardianApprovalPending carries requestId — approve in Guardian,
|
|
247
|
+
// then `await pending.resume()`. DENY: GuardianDenied carries
|
|
248
|
+
// reasonCode; nothing executes. onAsk/onDeny: "result" returns a
|
|
249
|
+
// serializable decision to the model instead of throwing.
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### LangChain.js — `@odingard/guardian-langchain`
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
npm install @odingard/guardian-langchain
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
```ts
|
|
259
|
+
import { createGuardianClient } from "@odingard/guardian-sdk";
|
|
260
|
+
import { GuardianApprovalPending, GuardianDenied, guardianTool }
|
|
261
|
+
from "@odingard/guardian-langchain";
|
|
262
|
+
|
|
263
|
+
const guardian = createGuardianClient({ baseUrl, credential });
|
|
264
|
+
const refundOrder = guardianTool(refundOrderTool, {
|
|
265
|
+
client: guardian,
|
|
266
|
+
connectionId: "con_…",
|
|
267
|
+
mode: "inProcess",
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
// Same triad + modes: the wrapped tool keeps its name, description,
|
|
271
|
+
// schema and returnDirect flag, so it drops into bindTools / LangGraph
|
|
272
|
+
// unchanged. On ASK, catch GuardianApprovalPending in your node and
|
|
273
|
+
// interrupt() — pending.resume() claims the capability and completes
|
|
274
|
+
// the call after the human approves.
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
## Examples
|
|
278
|
+
|
|
279
|
+
Runnable examples live in [`examples/`](examples/). Each prints its label:
|
|
280
|
+
`SIMULATED` = a local demo policy stands in for Guardian (nothing real
|
|
281
|
+
happens); `LIVE` = real hosted Guardian (set `GUARDIAN_BASE_URL`,
|
|
282
|
+
`GUARDIAN_AGENT_CREDENTIAL`, `GUARDIAN_CONNECTION_ID`) or real published keys.
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
cd examples && npm install
|
|
286
|
+
|
|
287
|
+
node verify-receipt.mjs # LIVE, no account: verify a real staging receipt offline, then tamper
|
|
288
|
+
node demo-classes.mjs # the 7 demo classes (email, delegation, vendor payment, PHI, deploy, CRM, robot stop)
|
|
289
|
+
node steel-checkout.mjs # Steel checkout → ASK → resume
|
|
290
|
+
node shopping-agent.mjs # purchase → ASK, human approves, receipt
|
|
291
|
+
node prompt-injection-deny.mjs # injected "export contacts" → DENY
|
|
292
|
+
node coding-agent-ask.mjs # consequential command → ASK
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## License
|
|
296
|
+
|
|
297
|
+
Apache-2.0
|
|
298
|
+
|
|
299
|
+
## Provenance
|
|
300
|
+
|
|
301
|
+
Canonical development happens in the [Odingard Guardian monorepo](https://github.com/Odingard/guardian);
|
|
302
|
+
this repository is the standalone open-source distribution of the agent SDK
|
|
303
|
+
(source mirrored, Apache-2.0). Issues and contributions welcome here.
|