@odingard/guardian-vercel-ai 0.0.0-stage → 0.1.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 +110 -2
- package/dist/index.js +350 -0
- package/dist-dts/core.d.ts +170 -0
- package/dist-dts/index.d.ts +21 -0
- package/package.json +55 -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,111 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @odingard/guardian-vercel-ai
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Vercel AI SDK adapter for Guardian — route every tool `execute` through a
|
|
4
|
+
deterministic `ALLOW` / `ASK` / `DENY` authority decision before anything
|
|
5
|
+
runs. The agent proposes; the human decides.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @odingard/guardian-vercel-ai @odingard/guardian-sdk ai
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`ai` and `@odingard/guardian-sdk` are peer dependencies.
|
|
14
|
+
|
|
15
|
+
## Two execution modes
|
|
16
|
+
|
|
17
|
+
| Mode | When to use | What happens on `ALLOW` |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| `remote` (default) | The tool name is a registered Guardian catalog entry — a bounded HTTP(S) endpoint Guardian calls itself | `client.execute` performs the call; the call resolves to `{ guardian: { decision: "ALLOW", requestId, receipt } }`. The local `execute` impl **never runs** |
|
|
20
|
+
| `inProcess` (opt-in) | The local `execute` impl IS the tool — the common framework case | The impl runs (only after the capability is issued), then `client.execute` redeems + records the evidence; the call resolves to the impl's output |
|
|
21
|
+
|
|
22
|
+
Set `mode` for every tool or `modes` per tool name:
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
withGuardian(tools, {
|
|
26
|
+
client,
|
|
27
|
+
connectionId: "con_…",
|
|
28
|
+
modes: { refund_order: "inProcess" }, // everything else remote
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
`inProcess` needs a `transport: "record"` catalog entry on the connection so
|
|
33
|
+
`execute` commits evidence instead of performing an HTTP call. The adapter
|
|
34
|
+
auto-proposes `mcp.install` of that entry the first time each tool is called
|
|
35
|
+
(it goes through the same ALLOW/ASK/DENY gate — a human may need to approve
|
|
36
|
+
it once). **This requires the WO-021 control plane**; a client that can't
|
|
37
|
+
form the proposal raises `GuardianRecordTransportRequired` before any
|
|
38
|
+
network call. Pass `installRecordTransport: false` to opt out (entries must
|
|
39
|
+
then be installed some other way).
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { tool } from "ai";
|
|
45
|
+
import { z } from "zod";
|
|
46
|
+
import { createGuardianClient } from "@odingard/guardian-sdk";
|
|
47
|
+
import {
|
|
48
|
+
GuardianApprovalPending,
|
|
49
|
+
GuardianDenied,
|
|
50
|
+
withGuardian,
|
|
51
|
+
} from "@odingard/guardian-vercel-ai";
|
|
52
|
+
|
|
53
|
+
const guardian = createGuardianClient({
|
|
54
|
+
baseUrl: "https://api.guardian.odingard.com",
|
|
55
|
+
credential: process.env.GUARDIAN_AGENT_CREDENTIAL!,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const tools = withGuardian(
|
|
59
|
+
{
|
|
60
|
+
refund_order: tool({
|
|
61
|
+
description: "Refund an order",
|
|
62
|
+
inputSchema: z.object({ orderId: z.string(), amount: z.number() }),
|
|
63
|
+
execute: async ({ orderId, amount }) => refund(orderId, amount),
|
|
64
|
+
}),
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
client: guardian,
|
|
68
|
+
connectionId: "con_…",
|
|
69
|
+
agentName: "billing-agent",
|
|
70
|
+
mode: "inProcess",
|
|
71
|
+
},
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
await generateText({ model, tools, prompt });
|
|
76
|
+
} catch (err) {
|
|
77
|
+
if (err instanceof GuardianApprovalPending) {
|
|
78
|
+
// err.requestId — surface to a human approver, then:
|
|
79
|
+
const { output, receipt } = await err.resume();
|
|
80
|
+
} else if (err instanceof GuardianDenied) {
|
|
81
|
+
// err.reasonCode — refused before execution
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## What the triad means here
|
|
87
|
+
|
|
88
|
+
- `ALLOW` — Guardian mints a single-use capability. Remote: `client.execute`
|
|
89
|
+
performs the catalog call and returns the receipt. In-process: the local
|
|
90
|
+
impl runs, then `client.execute` redeems + records it. A failed
|
|
91
|
+
redemption throws `GuardianExecutionFailed` — and in `inProcess` mode the
|
|
92
|
+
impl's own error propagates before the record call.
|
|
93
|
+
- `ASK` — throws `GuardianApprovalPending` carrying `requestId`. After the
|
|
94
|
+
human approves in Guardian, `pending.resume()` claims the capability and
|
|
95
|
+
completes the call. With `onAsk: "result"` the tool instead returns a
|
|
96
|
+
serializable `{ guardian: { decision: "ASK", requestId, … } }` to the
|
|
97
|
+
model.
|
|
98
|
+
- `DENY` — throws `GuardianDenied` carrying `reasonCode` (or returns
|
|
99
|
+
`{ guardian: { decision: "DENY", … } }` with `onDeny: "result"`).
|
|
100
|
+
|
|
101
|
+
Nothing runs before a decision, and no tool ever runs without a capability
|
|
102
|
+
issued for that exact request.
|
|
103
|
+
|
|
104
|
+
Options: `client`, `connectionId`, `adapterId?`, `agentName?`, `mode?`,
|
|
105
|
+
`modes?`, `installRecordTransport?`, `purpose?` (string or
|
|
106
|
+
`(toolName, input) => string`), `onAsk?`, `onDeny?`, `onReceipt?` (called
|
|
107
|
+
with `{ toolName, requestId, receipt }` after each `ALLOW`).
|
|
108
|
+
|
|
109
|
+
## License
|
|
110
|
+
|
|
111
|
+
Apache-2.0
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
// src/core.ts
|
|
2
|
+
var GuardianDenied = class extends Error {
|
|
3
|
+
decision = "DENY";
|
|
4
|
+
toolName;
|
|
5
|
+
reasonCode;
|
|
6
|
+
requestId;
|
|
7
|
+
constructor(args) {
|
|
8
|
+
super(
|
|
9
|
+
`Guardian denied "${args.toolName}" (reasonCode=${args.reasonCode})` + (args.requestId ? ` requestId=${args.requestId}` : "")
|
|
10
|
+
);
|
|
11
|
+
this.name = "GuardianDenied";
|
|
12
|
+
this.toolName = args.toolName;
|
|
13
|
+
this.reasonCode = args.reasonCode;
|
|
14
|
+
this.requestId = args.requestId;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var GuardianExecutionFailed = class extends Error {
|
|
18
|
+
toolName;
|
|
19
|
+
requestId;
|
|
20
|
+
reasonCode;
|
|
21
|
+
constructor(args) {
|
|
22
|
+
super(
|
|
23
|
+
`Guardian execution of "${args.toolName}" failed (requestId=${args.requestId}, reasonCode=${args.reasonCode})`
|
|
24
|
+
);
|
|
25
|
+
this.name = "GuardianExecutionFailed";
|
|
26
|
+
this.toolName = args.toolName;
|
|
27
|
+
this.requestId = args.requestId;
|
|
28
|
+
this.reasonCode = args.reasonCode;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
var GuardianRecordTransportRequired = class extends Error {
|
|
32
|
+
toolName;
|
|
33
|
+
constructor(args) {
|
|
34
|
+
super(
|
|
35
|
+
`Guardian in-process mode for "${args.toolName}" requires a record-transport catalog entry (transport: "record"), which needs the updated Guardian control plane \u2014 auto-install was rejected by the client before it reached the network`
|
|
36
|
+
);
|
|
37
|
+
this.name = "GuardianRecordTransportRequired";
|
|
38
|
+
this.toolName = args.toolName;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var GuardianApprovalPending = class extends Error {
|
|
42
|
+
decision = "ASK";
|
|
43
|
+
requestId;
|
|
44
|
+
toolName;
|
|
45
|
+
input;
|
|
46
|
+
#resume;
|
|
47
|
+
constructor(args, resume) {
|
|
48
|
+
super(
|
|
49
|
+
`Guardian held "${args.toolName}" for human approval (requestId=${args.requestId})`
|
|
50
|
+
);
|
|
51
|
+
this.name = "GuardianApprovalPending";
|
|
52
|
+
this.requestId = args.requestId;
|
|
53
|
+
this.toolName = args.toolName;
|
|
54
|
+
this.input = args.input;
|
|
55
|
+
this.#resume = resume;
|
|
56
|
+
}
|
|
57
|
+
/** Claim + execute + finish after the human approves. */
|
|
58
|
+
resume() {
|
|
59
|
+
return this.#resume();
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
function createGuardianContext(options) {
|
|
63
|
+
return { options, ensured: /* @__PURE__ */ new Set() };
|
|
64
|
+
}
|
|
65
|
+
function toolModeFor(options, toolName) {
|
|
66
|
+
return options.modes?.[toolName] ?? options.mode ?? "remote";
|
|
67
|
+
}
|
|
68
|
+
function toArgumentsRecord(input) {
|
|
69
|
+
if (input !== null && typeof input === "object" && !Array.isArray(input)) {
|
|
70
|
+
return input;
|
|
71
|
+
}
|
|
72
|
+
return input === void 0 ? {} : { input };
|
|
73
|
+
}
|
|
74
|
+
function resolvePurpose(options, toolName, input) {
|
|
75
|
+
if (typeof options.purpose === "function") {
|
|
76
|
+
return options.purpose(toolName, input);
|
|
77
|
+
}
|
|
78
|
+
if (typeof options.purpose === "string") {
|
|
79
|
+
return options.purpose;
|
|
80
|
+
}
|
|
81
|
+
const agent = options.agentName ?? "agent";
|
|
82
|
+
return `${agent} invoked ${toolName}`;
|
|
83
|
+
}
|
|
84
|
+
function deny(options, toolName, reasonCode, requestId) {
|
|
85
|
+
if (options.onDeny === "result") {
|
|
86
|
+
return {
|
|
87
|
+
guardian: {
|
|
88
|
+
decision: "DENY",
|
|
89
|
+
toolName,
|
|
90
|
+
reasonCode,
|
|
91
|
+
...requestId ? { requestId } : {},
|
|
92
|
+
message: `Guardian denied ${toolName} (${reasonCode}). Do not retry the same call.`
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
throw new GuardianDenied({
|
|
97
|
+
toolName,
|
|
98
|
+
reasonCode,
|
|
99
|
+
...requestId ? { requestId } : {}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function isLocalValidationError(err) {
|
|
103
|
+
return typeof err === "object" && err !== null && Array.isArray(err.issues);
|
|
104
|
+
}
|
|
105
|
+
async function ensureRecordTransport(ctx, toolName, input, runTool) {
|
|
106
|
+
const { options } = ctx;
|
|
107
|
+
if (options.installRecordTransport === false) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const key = `${options.connectionId}:${toolName}`;
|
|
111
|
+
if (ctx.ensured.has(key)) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
let result;
|
|
115
|
+
try {
|
|
116
|
+
result = await options.client.request({
|
|
117
|
+
action: "mcp.install",
|
|
118
|
+
connectionId: options.connectionId,
|
|
119
|
+
tool: {
|
|
120
|
+
name: toolName,
|
|
121
|
+
description: `In-process tool "${toolName}" \u2014 evidence record only (registered by a Guardian framework adapter)`,
|
|
122
|
+
transport: "record"
|
|
123
|
+
},
|
|
124
|
+
...options.adapterId ? { adapterId: options.adapterId } : {},
|
|
125
|
+
purpose: `Register in-process tool ${toolName} for evidence recording`
|
|
126
|
+
});
|
|
127
|
+
} catch (err) {
|
|
128
|
+
if (isLocalValidationError(err)) {
|
|
129
|
+
throw new GuardianRecordTransportRequired({ toolName });
|
|
130
|
+
}
|
|
131
|
+
throw err;
|
|
132
|
+
}
|
|
133
|
+
if (!result.ok) {
|
|
134
|
+
if (result.reasonCode === "TOOL_ALREADY_INSTALLED") {
|
|
135
|
+
ctx.ensured.add(key);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
return deny(options, toolName, result.reasonCode, void 0);
|
|
139
|
+
}
|
|
140
|
+
if (result.decision === "ALLOW" && result.capabilityToken) {
|
|
141
|
+
const executed = await options.client.execute({
|
|
142
|
+
requestId: result.requestId,
|
|
143
|
+
capabilityToken: result.capabilityToken
|
|
144
|
+
});
|
|
145
|
+
if (!executed.ok) {
|
|
146
|
+
throw new GuardianExecutionFailed({
|
|
147
|
+
toolName,
|
|
148
|
+
requestId: result.requestId,
|
|
149
|
+
reasonCode: executed.reasonCode
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
ctx.ensured.add(key);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (result.decision === "ASK") {
|
|
156
|
+
const requestId = result.requestId;
|
|
157
|
+
if (options.onAsk === "result") {
|
|
158
|
+
return {
|
|
159
|
+
guardian: {
|
|
160
|
+
decision: "ASK",
|
|
161
|
+
requestId,
|
|
162
|
+
toolName,
|
|
163
|
+
message: `Installing the record-transport catalog entry for ${toolName} needs human approval (requestId ${requestId}). Retry the tool call after approval.`
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
const resumeInstall = async () => {
|
|
168
|
+
const claimed = await options.client.claim(requestId);
|
|
169
|
+
if (claimed.ok && claimed.decision === "ALLOW" && claimed.capabilityToken) {
|
|
170
|
+
const executed = await options.client.execute({
|
|
171
|
+
requestId: claimed.requestId,
|
|
172
|
+
capabilityToken: claimed.capabilityToken
|
|
173
|
+
});
|
|
174
|
+
if (!executed.ok) {
|
|
175
|
+
throw new GuardianExecutionFailed({
|
|
176
|
+
toolName,
|
|
177
|
+
requestId: claimed.requestId,
|
|
178
|
+
reasonCode: executed.reasonCode
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
ctx.ensured.add(key);
|
|
182
|
+
const output = await runThroughGuardian(ctx, toolName, input, runTool);
|
|
183
|
+
return {
|
|
184
|
+
requestId: claimed.requestId,
|
|
185
|
+
receipt: executed.receipt,
|
|
186
|
+
output
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
if (claimed.ok && claimed.decision === "ASK") {
|
|
190
|
+
throw new GuardianApprovalPending(
|
|
191
|
+
{ requestId: claimed.requestId, toolName, input },
|
|
192
|
+
resumeInstall
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
throw new GuardianDenied({
|
|
196
|
+
toolName,
|
|
197
|
+
reasonCode: claimed.ok ? claimed.reasonCode ?? "MISSING_CAPABILITY" : claimed.reasonCode,
|
|
198
|
+
...claimed.ok ? { requestId: claimed.requestId } : {}
|
|
199
|
+
});
|
|
200
|
+
};
|
|
201
|
+
throw new GuardianApprovalPending(
|
|
202
|
+
{ requestId, toolName, input },
|
|
203
|
+
resumeInstall
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
return deny(
|
|
207
|
+
options,
|
|
208
|
+
toolName,
|
|
209
|
+
result.reasonCode ?? "MISSING_CAPABILITY",
|
|
210
|
+
result.requestId
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
async function settle(ctx, toolName, input, result, runTool) {
|
|
214
|
+
const { options } = ctx;
|
|
215
|
+
const mode = toolModeFor(options, toolName);
|
|
216
|
+
if (!result.ok) {
|
|
217
|
+
return deny(options, toolName, result.reasonCode, void 0);
|
|
218
|
+
}
|
|
219
|
+
if (result.decision === "ALLOW" && result.capabilityToken) {
|
|
220
|
+
const requestId = result.requestId;
|
|
221
|
+
if (mode === "remote") {
|
|
222
|
+
const executed2 = await options.client.execute({
|
|
223
|
+
requestId,
|
|
224
|
+
capabilityToken: result.capabilityToken
|
|
225
|
+
});
|
|
226
|
+
if (!executed2.ok) {
|
|
227
|
+
throw new GuardianExecutionFailed({
|
|
228
|
+
toolName,
|
|
229
|
+
requestId,
|
|
230
|
+
reasonCode: executed2.reasonCode
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
await options.onReceipt?.({
|
|
234
|
+
toolName,
|
|
235
|
+
requestId,
|
|
236
|
+
receipt: executed2.receipt
|
|
237
|
+
});
|
|
238
|
+
return {
|
|
239
|
+
guardian: {
|
|
240
|
+
decision: "ALLOW",
|
|
241
|
+
requestId,
|
|
242
|
+
toolName,
|
|
243
|
+
receipt: executed2.receipt
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
const output = await runTool();
|
|
248
|
+
const executed = await options.client.execute({
|
|
249
|
+
requestId,
|
|
250
|
+
capabilityToken: result.capabilityToken
|
|
251
|
+
});
|
|
252
|
+
if (!executed.ok) {
|
|
253
|
+
throw new GuardianExecutionFailed({
|
|
254
|
+
toolName,
|
|
255
|
+
requestId,
|
|
256
|
+
reasonCode: executed.reasonCode
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
await options.onReceipt?.({ toolName, requestId, receipt: executed.receipt });
|
|
260
|
+
return output;
|
|
261
|
+
}
|
|
262
|
+
if (result.decision === "ASK") {
|
|
263
|
+
const resume = async () => {
|
|
264
|
+
const claimed = await options.client.claim(result.requestId);
|
|
265
|
+
let receipt;
|
|
266
|
+
const output = await settle(
|
|
267
|
+
{
|
|
268
|
+
...ctx,
|
|
269
|
+
options: {
|
|
270
|
+
...options,
|
|
271
|
+
onReceipt: async (event) => {
|
|
272
|
+
receipt = event.receipt;
|
|
273
|
+
await options.onReceipt?.(event);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
toolName,
|
|
278
|
+
input,
|
|
279
|
+
claimed,
|
|
280
|
+
runTool
|
|
281
|
+
);
|
|
282
|
+
return { requestId: result.requestId, receipt, output };
|
|
283
|
+
};
|
|
284
|
+
if (options.onAsk === "result") {
|
|
285
|
+
return {
|
|
286
|
+
guardian: {
|
|
287
|
+
decision: "ASK",
|
|
288
|
+
requestId: result.requestId,
|
|
289
|
+
toolName,
|
|
290
|
+
message: `Held for human approval. After approval, claim requestId ${result.requestId} and re-run the tool.`
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
throw new GuardianApprovalPending(
|
|
295
|
+
{ requestId: result.requestId, toolName, input },
|
|
296
|
+
resume
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
return deny(
|
|
300
|
+
options,
|
|
301
|
+
toolName,
|
|
302
|
+
result.reasonCode ?? "MISSING_CAPABILITY",
|
|
303
|
+
result.requestId
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
async function runThroughGuardian(ctx, toolName, input, runTool) {
|
|
307
|
+
const { options } = ctx;
|
|
308
|
+
if (toolModeFor(options, toolName) === "inProcess") {
|
|
309
|
+
const gate = await ensureRecordTransport(ctx, toolName, input, runTool);
|
|
310
|
+
if (gate !== void 0) {
|
|
311
|
+
return gate;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
const result = await options.client.request({
|
|
315
|
+
action: "tool.invoke",
|
|
316
|
+
connectionId: options.connectionId,
|
|
317
|
+
toolName,
|
|
318
|
+
arguments: toArgumentsRecord(input),
|
|
319
|
+
...options.adapterId ? { adapterId: options.adapterId } : {},
|
|
320
|
+
purpose: resolvePurpose(options, toolName, input)
|
|
321
|
+
});
|
|
322
|
+
return settle(ctx, toolName, input, result, runTool);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// src/index.ts
|
|
326
|
+
function withGuardian(tools, options) {
|
|
327
|
+
const ctx = createGuardianContext(options);
|
|
328
|
+
const wrapped = {};
|
|
329
|
+
for (const [toolName, definition] of Object.entries(tools)) {
|
|
330
|
+
const execute = definition.execute;
|
|
331
|
+
wrapped[toolName] = typeof execute === "function" ? {
|
|
332
|
+
...definition,
|
|
333
|
+
execute: (input, callOptions) => runThroughGuardian(
|
|
334
|
+
ctx,
|
|
335
|
+
toolName,
|
|
336
|
+
input,
|
|
337
|
+
() => execute(input, callOptions)
|
|
338
|
+
)
|
|
339
|
+
} : definition;
|
|
340
|
+
}
|
|
341
|
+
return wrapped;
|
|
342
|
+
}
|
|
343
|
+
export {
|
|
344
|
+
GuardianApprovalPending,
|
|
345
|
+
GuardianDenied,
|
|
346
|
+
GuardianExecutionFailed,
|
|
347
|
+
GuardianRecordTransportRequired,
|
|
348
|
+
toArgumentsRecord,
|
|
349
|
+
withGuardian
|
|
350
|
+
};
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import type { GuardianClient, GuardianRequestResult } from "@odingard/guardian-sdk";
|
|
2
|
+
/**
|
|
3
|
+
* Shared triad semantics for the framework adapters — identical to
|
|
4
|
+
* mcp-server/src/dispatch.ts: a tool never runs unless Guardian issued a
|
|
5
|
+
* capability for this exact request.
|
|
6
|
+
*
|
|
7
|
+
* Two execution modes:
|
|
8
|
+
*
|
|
9
|
+
* - `remote` (default): the tool is a registered catalog entry — a bounded
|
|
10
|
+
* HTTPS call Guardian executes itself. `client.execute` IS the execution;
|
|
11
|
+
* the local `execute`/`func` implementation is never run.
|
|
12
|
+
* - `inProcess` (opt-in): the local implementation is the tool. After ALLOW
|
|
13
|
+
* the impl runs first, then `client.execute` redeems the capability and
|
|
14
|
+
* records the evidence — which requires a `transport: "record"` catalog
|
|
15
|
+
* entry on the connection (auto-installed via `mcp.install`; needs the
|
|
16
|
+
* WO-021 control plane).
|
|
17
|
+
*/
|
|
18
|
+
/** Thrown (or returned) when Guardian refuses an action before execution. */
|
|
19
|
+
export declare class GuardianDenied extends Error {
|
|
20
|
+
readonly decision: "DENY";
|
|
21
|
+
readonly toolName: string;
|
|
22
|
+
readonly reasonCode: string;
|
|
23
|
+
readonly requestId: string | undefined;
|
|
24
|
+
constructor(args: {
|
|
25
|
+
toolName: string;
|
|
26
|
+
reasonCode: string;
|
|
27
|
+
requestId?: string;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/** ALLOW was decided but redeeming the capability failed. */
|
|
31
|
+
export declare class GuardianExecutionFailed extends Error {
|
|
32
|
+
readonly toolName: string;
|
|
33
|
+
readonly requestId: string;
|
|
34
|
+
readonly reasonCode: string;
|
|
35
|
+
constructor(args: {
|
|
36
|
+
toolName: string;
|
|
37
|
+
requestId: string;
|
|
38
|
+
reasonCode: string;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* `inProcess` mode needs a record-transport catalog entry on the tool
|
|
43
|
+
* connection so `execute` commits evidence without an HTTP call. Thrown when
|
|
44
|
+
* the auto-install proposal could not even be formed — the SDK/control
|
|
45
|
+
* plane in use predates the `transport: "record"` tool kind (WO-021).
|
|
46
|
+
*/
|
|
47
|
+
export declare class GuardianRecordTransportRequired extends Error {
|
|
48
|
+
readonly toolName: string;
|
|
49
|
+
constructor(args: {
|
|
50
|
+
toolName: string;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
export type GuardianResume<Output> = () => Promise<{
|
|
54
|
+
requestId: string;
|
|
55
|
+
receipt: unknown;
|
|
56
|
+
output: Output | GuardianDecisionResult;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Guardian held the action for human approval (`ASK`). Carries the requestId
|
|
60
|
+
* the app needs to surface to the approver; `resume()` claims the approved
|
|
61
|
+
* capability, executes it, and finishes the call — never before approval.
|
|
62
|
+
*/
|
|
63
|
+
export declare class GuardianApprovalPending<Output = unknown> extends Error {
|
|
64
|
+
#private;
|
|
65
|
+
readonly decision: "ASK";
|
|
66
|
+
readonly requestId: string;
|
|
67
|
+
readonly toolName: string;
|
|
68
|
+
readonly input: unknown;
|
|
69
|
+
constructor(args: {
|
|
70
|
+
requestId: string;
|
|
71
|
+
toolName: string;
|
|
72
|
+
input: unknown;
|
|
73
|
+
}, resume: GuardianResume<Output>);
|
|
74
|
+
/** Claim + execute + finish after the human approves. */
|
|
75
|
+
resume(): Promise<{
|
|
76
|
+
requestId: string;
|
|
77
|
+
receipt: unknown;
|
|
78
|
+
output: GuardianDecisionResult | Output;
|
|
79
|
+
}>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Serializable decision handed back to the model: ASK/DENY when mode is
|
|
83
|
+
* "result", plus the ALLOW receipt a remote-mode call resolves to.
|
|
84
|
+
*/
|
|
85
|
+
export type GuardianDecisionResult = {
|
|
86
|
+
guardian: {
|
|
87
|
+
decision: "ALLOW";
|
|
88
|
+
requestId: string;
|
|
89
|
+
toolName: string;
|
|
90
|
+
receipt: unknown;
|
|
91
|
+
};
|
|
92
|
+
} | {
|
|
93
|
+
guardian: {
|
|
94
|
+
decision: "ASK";
|
|
95
|
+
requestId: string;
|
|
96
|
+
toolName: string;
|
|
97
|
+
message: string;
|
|
98
|
+
};
|
|
99
|
+
} | {
|
|
100
|
+
guardian: {
|
|
101
|
+
decision: "DENY";
|
|
102
|
+
toolName: string;
|
|
103
|
+
reasonCode: string;
|
|
104
|
+
requestId?: string;
|
|
105
|
+
message: string;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
export type GuardianMode = "throw" | "result";
|
|
109
|
+
/**
|
|
110
|
+
* `remote`: the tool name is a registered Guardian catalog entry and the
|
|
111
|
+
* server performs the bounded HTTPS call — the local impl never runs.
|
|
112
|
+
* `inProcess`: the local impl IS the tool; it runs only after the capability
|
|
113
|
+
* is issued and its evidence is recorded via execute afterwards.
|
|
114
|
+
*/
|
|
115
|
+
export type GuardianToolMode = "remote" | "inProcess";
|
|
116
|
+
export type GuardianAdapterOptions = Readonly<{
|
|
117
|
+
client: GuardianClient;
|
|
118
|
+
/** Tool connection id the proposals are authorized against. */
|
|
119
|
+
connectionId: string;
|
|
120
|
+
/** Adapter audience for executes; defaults to the tool adapter. */
|
|
121
|
+
adapterId?: string;
|
|
122
|
+
/** Human label for the agent in audit + default purpose strings. */
|
|
123
|
+
agentName?: string;
|
|
124
|
+
/** Static purpose or per-call purpose shown to approvers. */
|
|
125
|
+
purpose?: string | ((toolName: string, input: unknown) => string);
|
|
126
|
+
/**
|
|
127
|
+
* Execution mode applied to every wrapped tool: "remote" (default) defers
|
|
128
|
+
* execution to the Guardian catalog entry; "inProcess" runs the local
|
|
129
|
+
* implementation and records the evidence. See `modes` for per-tool
|
|
130
|
+
* overrides.
|
|
131
|
+
*/
|
|
132
|
+
mode?: GuardianToolMode;
|
|
133
|
+
/** Per-tool-name mode overrides, e.g. `{ refund_order: "remote" }`. */
|
|
134
|
+
modes?: Readonly<Record<string, GuardianToolMode>>;
|
|
135
|
+
/**
|
|
136
|
+
* inProcess only: auto-propose `mcp.install` of a `transport: "record"`
|
|
137
|
+
* catalog entry for each wrapped tool that lacks one. Default true;
|
|
138
|
+
* requires the WO-021 control plane — a pre-WO-021 SDK raises
|
|
139
|
+
* `GuardianRecordTransportRequired` before any network call.
|
|
140
|
+
*/
|
|
141
|
+
installRecordTransport?: boolean;
|
|
142
|
+
/** What ASK does inside the wrapped call. Default "throw". */
|
|
143
|
+
onAsk?: GuardianMode;
|
|
144
|
+
/** What DENY does inside the wrapped call. Default "throw". */
|
|
145
|
+
onDeny?: GuardianMode;
|
|
146
|
+
/** Called with the execution receipt after every ALLOW. */
|
|
147
|
+
onReceipt?: (event: {
|
|
148
|
+
toolName: string;
|
|
149
|
+
requestId: string;
|
|
150
|
+
receipt: unknown;
|
|
151
|
+
}) => void | PromiseLike<void>;
|
|
152
|
+
}>;
|
|
153
|
+
/** Per-wrapper state: which record-transport entries were already ensured. */
|
|
154
|
+
export type GuardianContext = {
|
|
155
|
+
options: GuardianAdapterOptions;
|
|
156
|
+
ensured: Set<string>;
|
|
157
|
+
};
|
|
158
|
+
export declare function createGuardianContext(options: GuardianAdapterOptions): GuardianContext;
|
|
159
|
+
export declare function toolModeFor(options: GuardianAdapterOptions, toolName: string): GuardianToolMode;
|
|
160
|
+
export declare function toArgumentsRecord(input: unknown): Record<string, unknown>;
|
|
161
|
+
/**
|
|
162
|
+
* The triad applied to an already-answered request (request or claim).
|
|
163
|
+
* remote: ALLOW → execute (Guardian performs the call) → receipt is the
|
|
164
|
+
* output; the local impl never runs.
|
|
165
|
+
* inProcess: ALLOW → run the impl → execute redeems + records → impl output.
|
|
166
|
+
* ASK → pending handle; DENY → typed denial.
|
|
167
|
+
*/
|
|
168
|
+
export declare function settle<Output>(ctx: GuardianContext, toolName: string, input: unknown, result: GuardianRequestResult, runTool: () => Output | PromiseLike<Output>): Promise<Output | GuardianDecisionResult>;
|
|
169
|
+
/** Ensure the record-transport entry (inProcess), propose, settle. */
|
|
170
|
+
export declare function runThroughGuardian<Output>(ctx: GuardianContext, toolName: string, input: unknown, runTool: () => Output | PromiseLike<Output>): Promise<Output | GuardianDecisionResult>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ToolSet } from "ai";
|
|
2
|
+
import { type GuardianAdapterOptions } from "./core.js";
|
|
3
|
+
export { GuardianApprovalPending, GuardianDenied, GuardianExecutionFailed, GuardianRecordTransportRequired, toArgumentsRecord, type GuardianAdapterOptions, type GuardianDecisionResult, type GuardianMode, type GuardianToolMode, } from "./core.js";
|
|
4
|
+
export type GuardianVercelAIOptions = GuardianAdapterOptions;
|
|
5
|
+
/**
|
|
6
|
+
* Wrap a Vercel AI SDK tool set so every tool's `execute` routes through
|
|
7
|
+
* Guardian.
|
|
8
|
+
*
|
|
9
|
+
* - mode "remote" (default): the tool name is a registered Guardian catalog
|
|
10
|
+
* entry — `client.execute` performs the bounded HTTPS call and the local
|
|
11
|
+
* `execute` impl never runs; the call resolves to the ALLOW receipt.
|
|
12
|
+
* - mode "inProcess" (opt-in, `mode`/`modes` options): the local impl IS the
|
|
13
|
+
* tool — it runs only once ALLOW issues the capability, and `execute`
|
|
14
|
+
* redeems + records the evidence afterwards (auto-installs a
|
|
15
|
+
* `transport: "record"` catalog entry via `mcp.install`; WO-021).
|
|
16
|
+
*
|
|
17
|
+
* ASK throws `GuardianApprovalPending` (or a result object with
|
|
18
|
+
* onAsk: "result"); DENY throws `GuardianDenied` (or a result object with
|
|
19
|
+
* onDeny: "result"). Tools without an `execute` pass through unchanged.
|
|
20
|
+
*/
|
|
21
|
+
export declare function withGuardian<T extends ToolSet>(tools: T, options: GuardianVercelAIOptions): T;
|
package/package.json
CHANGED
|
@@ -1,6 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@odingard/guardian-vercel-ai",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Vercel AI SDK adapter — route an agent's tool calls through Guardian for a deterministic ALLOW/ASK/DENY decision before anything executes.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist-dts/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"dist-dts",
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE"
|
|
18
|
+
],
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "esbuild src/index.ts --bundle --platform=node --format=esm --target=node22 --external:ai --external:@odingard/guardian-sdk --outfile=dist/index.js && tsc -p tsconfig.build.json",
|
|
24
|
+
"test": "vitest run",
|
|
25
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
26
|
+
"prepublishOnly": "npm run build && npm test"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@odingard/guardian-sdk": "^0.1.0",
|
|
30
|
+
"ai": "^5.0.0 || ^6.0.0 || ^7.0.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@odingard/guardian-sdk": "^0.1.0",
|
|
34
|
+
"@types/node": "^22.20.5",
|
|
35
|
+
"ai": "^7.0.159",
|
|
36
|
+
"esbuild": "^0.28.2",
|
|
37
|
+
"typescript": "^5.9.3",
|
|
38
|
+
"vitest": "^3.2.4"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=20"
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"guardian",
|
|
45
|
+
"ai-agents",
|
|
46
|
+
"authorization",
|
|
47
|
+
"authority",
|
|
48
|
+
"vercel-ai-sdk",
|
|
49
|
+
"human-in-the-loop"
|
|
50
|
+
],
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "https://github.com/Odingard/guardian-sdk.git",
|
|
54
|
+
"directory": "packages/vercel-ai"
|
|
55
|
+
},
|
|
56
|
+
"homepage": "https://guardian.odingard.com"
|
|
57
|
+
}
|