@atbash/atbash-langgraph 0.0.10 → 0.0.12

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 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,11 +33,63 @@ function createGuardNode(opts) {
33
33
  atbashReason: "No tool calls detected"
34
34
  };
35
35
  }
36
- const actionText = toolCalls.map((toolCall) => `${toolCall.name}(${JSON.stringify(toolCall.args)})`).join("; ");
36
+ const memoryHandledIds = /* @__PURE__ */ new Set();
37
+ if (opts.guardManager) {
38
+ for (const tc of toolCalls) {
39
+ let memDecision;
40
+ try {
41
+ memDecision = await opts.guardManager.handleBeforeToolCall(
42
+ { toolName: tc.name, args: tc.args },
43
+ {}
44
+ );
45
+ } catch (err) {
46
+ const reason = err instanceof Error ? err.message : String(err);
47
+ return {
48
+ messages: toolCalls.map(
49
+ (toolCall) => new ToolMessage({
50
+ tool_call_id: toolCall.id,
51
+ content: toolCall.id === tc.id ? `Memory guard error: ${reason}` : "Blocked \u2014 memory safety check failed for another tool call"
52
+ })
53
+ ),
54
+ atbashVerdict: "BLOCK",
55
+ atbashReason: `Memory guard error: ${reason}`,
56
+ atbashToolCallId: null,
57
+ atbashConfidence: null
58
+ };
59
+ }
60
+ if (memDecision !== null) {
61
+ if (memDecision.block) {
62
+ return {
63
+ messages: toolCalls.map(
64
+ (toolCall) => new ToolMessage({
65
+ tool_call_id: toolCall.id,
66
+ content: toolCall.id === tc.id ? `Memory write blocked by Atbash: ${memDecision.blockReason ?? ""}` : "Blocked \u2014 another tool call was blocked by memory safety"
67
+ })
68
+ ),
69
+ atbashVerdict: "BLOCK",
70
+ atbashReason: memDecision.blockReason ?? "memory write blocked",
71
+ atbashToolCallId: null,
72
+ atbashConfidence: null
73
+ };
74
+ }
75
+ memoryHandledIds.add(tc.id);
76
+ }
77
+ }
78
+ }
79
+ const auditCalls = toolCalls.filter((tc) => !memoryHandledIds.has(tc.id));
80
+ if (auditCalls.length === 0) {
81
+ return {
82
+ atbashVerdict: "ALLOW",
83
+ atbashReason: "Memory operations validated by guard",
84
+ atbashToolCallId: null,
85
+ atbashConfidence: null
86
+ };
87
+ }
88
+ const actionText = auditCalls.map((toolCall) => `${toolCall.name}(${JSON.stringify(toolCall.args)})`).join("; ");
37
89
  try {
38
90
  const decision = await opts.client.auditToolCall({
39
- toolName: toolCalls.map((t) => t.name).join(",") || "langgraph_batch",
40
- args: toolCalls,
91
+ toolName: auditCalls.map((t) => t.name).join(",") || "langgraph_batch",
92
+ args: auditCalls,
41
93
  context: `LangGraph agent attempting: ${actionText}`
42
94
  });
43
95
  if (decision.verdict === "BLOCK" || decision.verdict === "ERROR") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atbash/atbash-langgraph",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "Atbash safety guard and audit nodes for LangGraph workflows",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",