@atbash/atbash-langgraph 0.0.10 → 0.0.11
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/dist/index.d.ts +2 -1
- package/dist/index.js +39 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _langchain_core_messages from '@langchain/core/messages';
|
|
2
2
|
import * as _langchain_langgraph from '@langchain/langgraph';
|
|
3
3
|
import { StateGraph } from '@langchain/langgraph';
|
|
4
|
-
import { Atbash } from '@atbash/sdk';
|
|
4
|
+
import { Atbash, MemoryGuardManager } from '@atbash/sdk';
|
|
5
5
|
import * as _langchain_core_tools from '@langchain/core/tools';
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
|
|
@@ -16,6 +16,7 @@ type AtbashState = typeof AtbashStateAnnotation.State;
|
|
|
16
16
|
|
|
17
17
|
interface GuardNodeOptions {
|
|
18
18
|
client: Atbash;
|
|
19
|
+
guardManager?: MemoryGuardManager;
|
|
19
20
|
}
|
|
20
21
|
declare function createGuardNode(opts: GuardNodeOptions): (state: AtbashState) => Promise<Partial<AtbashState>>;
|
|
21
22
|
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,45 @@ function createGuardNode(opts) {
|
|
|
33
33
|
atbashReason: "No tool calls detected"
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
+
if (opts.guardManager) {
|
|
37
|
+
for (const tc of toolCalls) {
|
|
38
|
+
let memDecision;
|
|
39
|
+
try {
|
|
40
|
+
memDecision = await opts.guardManager.handleBeforeToolCall(
|
|
41
|
+
{ toolName: tc.name, args: tc.args },
|
|
42
|
+
{}
|
|
43
|
+
);
|
|
44
|
+
} catch (err) {
|
|
45
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
46
|
+
return {
|
|
47
|
+
messages: toolCalls.map(
|
|
48
|
+
(toolCall) => new ToolMessage({
|
|
49
|
+
tool_call_id: toolCall.id,
|
|
50
|
+
content: toolCall.id === tc.id ? `Memory guard error: ${reason}` : "Blocked \u2014 memory safety check failed for another tool call"
|
|
51
|
+
})
|
|
52
|
+
),
|
|
53
|
+
atbashVerdict: "BLOCK",
|
|
54
|
+
atbashReason: `Memory guard error: ${reason}`,
|
|
55
|
+
atbashToolCallId: null,
|
|
56
|
+
atbashConfidence: null
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
if (memDecision !== null && memDecision.block) {
|
|
60
|
+
return {
|
|
61
|
+
messages: toolCalls.map(
|
|
62
|
+
(toolCall) => new ToolMessage({
|
|
63
|
+
tool_call_id: toolCall.id,
|
|
64
|
+
content: toolCall.id === tc.id ? `Memory write blocked by Atbash: ${memDecision.blockReason ?? ""}` : "Blocked \u2014 another tool call was blocked by memory safety"
|
|
65
|
+
})
|
|
66
|
+
),
|
|
67
|
+
atbashVerdict: "BLOCK",
|
|
68
|
+
atbashReason: memDecision.blockReason ?? "memory write blocked",
|
|
69
|
+
atbashToolCallId: null,
|
|
70
|
+
atbashConfidence: null
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
36
75
|
const actionText = toolCalls.map((toolCall) => `${toolCall.name}(${JSON.stringify(toolCall.args)})`).join("; ");
|
|
37
76
|
try {
|
|
38
77
|
const decision = await opts.client.auditToolCall({
|