@odingard/guardian-langchain 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 +1 -1
- package/dist/index.js +25 -2
- package/dist-dts/core.d.ts +7 -0
- package/package.json +4 -4
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -23,14 +23,21 @@ var GuardianExecutionFailed = class extends Error {
|
|
|
23
23
|
toolName;
|
|
24
24
|
requestId;
|
|
25
25
|
reasonCode;
|
|
26
|
+
/**
|
|
27
|
+
* inProcess only: the local tool already ran before Guardian's final
|
|
28
|
+
* redemption refused it. The effect happened without a recorded receipt;
|
|
29
|
+
* treat it as an incident, never as a successful governed action.
|
|
30
|
+
*/
|
|
31
|
+
localEffectRan;
|
|
26
32
|
constructor(args) {
|
|
27
33
|
super(
|
|
28
|
-
`Guardian execution of "${args.toolName}" failed (requestId=${args.requestId}, reasonCode=${args.reasonCode})`
|
|
34
|
+
`Guardian execution of "${args.toolName}" failed (requestId=${args.requestId}, reasonCode=${args.reasonCode}${args.localEffectRan ? ", localEffectRan=true" : ""})`
|
|
29
35
|
);
|
|
30
36
|
this.name = "GuardianExecutionFailed";
|
|
31
37
|
this.toolName = args.toolName;
|
|
32
38
|
this.requestId = args.requestId;
|
|
33
39
|
this.reasonCode = args.reasonCode;
|
|
40
|
+
this.localEffectRan = args.localEffectRan ?? false;
|
|
34
41
|
}
|
|
35
42
|
};
|
|
36
43
|
var GuardianRecordTransportRequired = class extends Error {
|
|
@@ -219,6 +226,21 @@ async function settle(ctx, toolName, input, result, runTool) {
|
|
|
219
226
|
const { options } = ctx;
|
|
220
227
|
const mode = toolModeFor(options, toolName);
|
|
221
228
|
if (!result.ok) {
|
|
229
|
+
const heldRequestId = result.requestId;
|
|
230
|
+
if (result.reasonCode === "APPROVAL_REQUIRED" && typeof heldRequestId === "string" && heldRequestId.length > 0) {
|
|
231
|
+
return settle(
|
|
232
|
+
ctx,
|
|
233
|
+
toolName,
|
|
234
|
+
input,
|
|
235
|
+
{
|
|
236
|
+
ok: true,
|
|
237
|
+
requestId: heldRequestId,
|
|
238
|
+
decision: "ASK",
|
|
239
|
+
reasonCode: result.reasonCode
|
|
240
|
+
},
|
|
241
|
+
runTool
|
|
242
|
+
);
|
|
243
|
+
}
|
|
222
244
|
return deny(options, toolName, result.reasonCode, void 0);
|
|
223
245
|
}
|
|
224
246
|
if (result.decision === "ALLOW" && result.capabilityToken) {
|
|
@@ -258,7 +280,8 @@ async function settle(ctx, toolName, input, result, runTool) {
|
|
|
258
280
|
throw new GuardianExecutionFailed({
|
|
259
281
|
toolName,
|
|
260
282
|
requestId,
|
|
261
|
-
reasonCode: executed.reasonCode
|
|
283
|
+
reasonCode: executed.reasonCode,
|
|
284
|
+
localEffectRan: true
|
|
262
285
|
});
|
|
263
286
|
}
|
|
264
287
|
await options.onReceipt?.({ toolName, requestId, receipt: executed.receipt });
|
package/dist-dts/core.d.ts
CHANGED
|
@@ -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-langchain",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "LangChain.js 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",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@langchain/core": ">=0.3.58 <2.0.0",
|
|
30
|
-
"@odingard/guardian-sdk": "^0.
|
|
30
|
+
"@odingard/guardian-sdk": "^0.2.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@langchain/core": "^1.3.2",
|
|
34
|
-
"@odingard/guardian-sdk": "^0.
|
|
34
|
+
"@odingard/guardian-sdk": "^0.2.0",
|
|
35
35
|
"@types/node": "^22.20.5",
|
|
36
36
|
"esbuild": "^0.28.2",
|
|
37
37
|
"typescript": "^5.9.3",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"zod": "^4.6.7"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
|
42
|
-
"node": ">=
|
|
42
|
+
"node": ">=22"
|
|
43
43
|
},
|
|
44
44
|
"keywords": [
|
|
45
45
|
"guardian",
|