@odingard/guardian-vercel-ai 0.1.0 → 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/README.md CHANGED
@@ -51,7 +51,7 @@ import {
51
51
  } from "@odingard/guardian-vercel-ai";
52
52
 
53
53
  const guardian = createGuardianClient({
54
- baseUrl: "https://api.guardian.odingard.com",
54
+ baseUrl: "https://guardian-api.odingard.com",
55
55
  credential: process.env.GUARDIAN_AGENT_CREDENTIAL!,
56
56
  });
57
57
 
package/dist/index.js CHANGED
@@ -18,14 +18,21 @@ var GuardianExecutionFailed = class extends Error {
18
18
  toolName;
19
19
  requestId;
20
20
  reasonCode;
21
+ /**
22
+ * inProcess only: the local tool already ran before Guardian's final
23
+ * redemption refused it. The effect happened without a recorded receipt;
24
+ * treat it as an incident, never as a successful governed action.
25
+ */
26
+ localEffectRan;
21
27
  constructor(args) {
22
28
  super(
23
- `Guardian execution of "${args.toolName}" failed (requestId=${args.requestId}, reasonCode=${args.reasonCode})`
29
+ `Guardian execution of "${args.toolName}" failed (requestId=${args.requestId}, reasonCode=${args.reasonCode}${args.localEffectRan ? ", localEffectRan=true" : ""})`
24
30
  );
25
31
  this.name = "GuardianExecutionFailed";
26
32
  this.toolName = args.toolName;
27
33
  this.requestId = args.requestId;
28
34
  this.reasonCode = args.reasonCode;
35
+ this.localEffectRan = args.localEffectRan ?? false;
29
36
  }
30
37
  };
31
38
  var GuardianRecordTransportRequired = class extends Error {
@@ -214,6 +221,21 @@ async function settle(ctx, toolName, input, result, runTool) {
214
221
  const { options } = ctx;
215
222
  const mode = toolModeFor(options, toolName);
216
223
  if (!result.ok) {
224
+ const heldRequestId = result.requestId;
225
+ if (result.reasonCode === "APPROVAL_REQUIRED" && typeof heldRequestId === "string" && heldRequestId.length > 0) {
226
+ return settle(
227
+ ctx,
228
+ toolName,
229
+ input,
230
+ {
231
+ ok: true,
232
+ requestId: heldRequestId,
233
+ decision: "ASK",
234
+ reasonCode: result.reasonCode
235
+ },
236
+ runTool
237
+ );
238
+ }
217
239
  return deny(options, toolName, result.reasonCode, void 0);
218
240
  }
219
241
  if (result.decision === "ALLOW" && result.capabilityToken) {
@@ -253,7 +275,8 @@ async function settle(ctx, toolName, input, result, runTool) {
253
275
  throw new GuardianExecutionFailed({
254
276
  toolName,
255
277
  requestId,
256
- reasonCode: executed.reasonCode
278
+ reasonCode: executed.reasonCode,
279
+ localEffectRan: true
257
280
  });
258
281
  }
259
282
  await options.onReceipt?.({ toolName, requestId, receipt: executed.receipt });
@@ -32,10 +32,17 @@ export declare class GuardianExecutionFailed extends Error {
32
32
  readonly toolName: string;
33
33
  readonly requestId: string;
34
34
  readonly reasonCode: string;
35
+ /**
36
+ * inProcess only: the local tool already ran before Guardian's final
37
+ * redemption refused it. The effect happened without a recorded receipt;
38
+ * treat it as an incident, never as a successful governed action.
39
+ */
40
+ readonly localEffectRan: boolean;
35
41
  constructor(args: {
36
42
  toolName: string;
37
43
  requestId: string;
38
44
  reasonCode: string;
45
+ localEffectRan?: boolean;
39
46
  });
40
47
  }
41
48
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odingard/guardian-vercel-ai",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
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
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -26,11 +26,11 @@
26
26
  "prepublishOnly": "npm run build && npm test"
27
27
  },
28
28
  "peerDependencies": {
29
- "@odingard/guardian-sdk": "^0.1.0",
29
+ "@odingard/guardian-sdk": "^0.2.0",
30
30
  "ai": "^5.0.0 || ^6.0.0 || ^7.0.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@odingard/guardian-sdk": "^0.1.0",
33
+ "@odingard/guardian-sdk": "^0.2.0",
34
34
  "@types/node": "^22.20.5",
35
35
  "ai": "^7.0.159",
36
36
  "esbuild": "^0.28.2",
@@ -38,7 +38,7 @@
38
38
  "vitest": "^3.2.4"
39
39
  },
40
40
  "engines": {
41
- "node": ">=20"
41
+ "node": ">=22"
42
42
  },
43
43
  "keywords": [
44
44
  "guardian",