@atbash/atbash-langgraph 0.0.5-dev.1 → 0.0.5-dev.3

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 { AtbashClient, AgentAuth, ClientOpts } from '@atbash/sdk';
4
+ import { Atbash } from '@atbash/sdk';
5
5
  import * as _langchain_core_tools from '@langchain/core/tools';
6
6
  import { z } from 'zod';
7
7
 
@@ -15,18 +15,16 @@ declare const AtbashStateAnnotation: _langchain_langgraph.AnnotationRoot<{
15
15
  type AtbashState = typeof AtbashStateAnnotation.State;
16
16
 
17
17
  interface GuardNodeOptions {
18
- client: AtbashClient;
18
+ client: Atbash;
19
19
  }
20
20
  declare function createGuardNode(opts: GuardNodeOptions): (state: AtbashState) => Promise<Partial<AtbashState>>;
21
21
 
22
22
  interface AuditNodeOptions {
23
- agent: AgentAuth;
24
- clientOpts?: ClientOpts;
23
+ client: Atbash;
25
24
  }
26
25
  declare function createAuditNode(opts: AuditNodeOptions): (state: AtbashState) => Promise<Partial<AtbashState>>;
27
26
 
28
27
  interface AtbashSafetyOptions {
29
- agent?: AgentAuth;
30
28
  privkey?: string;
31
29
  endpoint?: string;
32
30
  toolsNode?: string;
@@ -52,7 +50,7 @@ declare function addAtbashSafety(builder: StateGraph<AtbashState>, opts: AtbashS
52
50
  messages: _langchain_langgraph.BaseChannel<_langchain_core_messages.BaseMessage<_langchain_core_messages.MessageStructure<_langchain_core_messages.MessageToolSet>, _langchain_core_messages.MessageType>[], _langchain_langgraph.OverwriteValue<_langchain_core_messages.BaseMessage<_langchain_core_messages.MessageStructure<_langchain_core_messages.MessageToolSet>, _langchain_core_messages.MessageType>[]> | _langchain_langgraph.Messages, unknown>;
53
51
  }>>, "__start__", _langchain_langgraph.StateDefinition, _langchain_langgraph.StateDefinition, _langchain_langgraph.StateDefinition, unknown, unknown, unknown>;
54
52
 
55
- declare function createJudgeTool(agent: AgentAuth, endpoint?: string): _langchain_core_tools.DynamicStructuredTool<z.ZodObject<{
53
+ declare function createJudgeTool(client: Atbash): _langchain_core_tools.DynamicStructuredTool<z.ZodObject<{
56
54
  action: z.ZodString;
57
55
  context: z.ZodString;
58
56
  }, "strip", z.ZodTypeAny, {
package/dist/index.js CHANGED
@@ -54,6 +54,26 @@ function createGuardNode(opts) {
54
54
  atbashConfidence: null
55
55
  };
56
56
  }
57
+ if (decision.verdict === "HOLD") {
58
+ const holdParts = [
59
+ "Action held for operator review. The agent will not be jailed \u2014 please approve or reject this request from the Atbash dashboard, then ask the agent to try again.",
60
+ `Reason: ${decision.reason ?? ""}`
61
+ ];
62
+ if (decision.toolCallId) holdParts.push(`Tool Call ID: ${decision.toolCallId}`);
63
+ const holdMessage = holdParts.join("\n");
64
+ return {
65
+ messages: toolCalls.map(
66
+ (toolCall) => new ToolMessage({
67
+ tool_call_id: toolCall.id,
68
+ content: holdMessage
69
+ })
70
+ ),
71
+ atbashVerdict: "HOLD",
72
+ atbashReason: decision.reason ?? "held for review",
73
+ atbashToolCallId: decision.toolCallId,
74
+ atbashConfidence: null
75
+ };
76
+ }
57
77
  return {
58
78
  atbashVerdict: "ALLOW",
59
79
  atbashReason: decision.reason,
@@ -81,9 +101,6 @@ function createGuardNode(opts) {
81
101
  };
82
102
  }
83
103
 
84
- // src/nodes/auditNode.ts
85
- import { judgeAction } from "@atbash/sdk";
86
-
87
104
  // src/utils.ts
88
105
  function truncateText(value, max = 500) {
89
106
  return value.length <= max ? value : `${value.slice(0, max - 3)}...`;
@@ -91,15 +108,14 @@ function truncateText(value, max = 500) {
91
108
 
92
109
  // src/nodes/auditNode.ts
93
110
  function createAuditNode(opts) {
111
+ const { client } = opts;
94
112
  return async (state) => {
95
113
  const lastMessage = state.messages[state.messages.length - 1];
96
114
  const content = typeof lastMessage?.content === "string" ? lastMessage.content : JSON.stringify(lastMessage?.content ?? "");
97
115
  try {
98
- await judgeAction(
116
+ await client.logToolCall(
99
117
  truncateText(content, 500),
100
- "LangGraph tool execution completed",
101
- opts.agent,
102
- opts.clientOpts
118
+ "LangGraph tool execution completed"
103
119
  );
104
120
  } catch {
105
121
  }
@@ -109,8 +125,7 @@ function createAuditNode(opts) {
109
125
 
110
126
  // src/builder.ts
111
127
  import {
112
- createAtbashClient,
113
- loadAgent,
128
+ Atbash,
114
129
  setupTelemetry,
115
130
  shutdownTelemetry
116
131
  } from "@atbash/sdk";
@@ -119,18 +134,15 @@ function addAtbashSafety(builder, opts) {
119
134
  process.once("beforeExit", () => shutdownTelemetry());
120
135
  process.once("SIGINT", () => shutdownTelemetry().finally(() => process.exit(0)));
121
136
  process.once("SIGTERM", () => shutdownTelemetry().finally(() => process.exit(0)));
122
- const privkey = opts.privkey ?? process.env.ATBASH_AGENT_PRIVKEY;
123
- const agent = opts.agent ?? loadAgent(privkey ?? "");
124
- const clientOpts = opts.endpoint ? { endpoint: opts.endpoint } : void 0;
125
- const client = createAtbashClient({
126
- keyPair: { privKey: agent.privkey, pubKey: agent.pubkey },
127
- judge: opts.endpoint ? { endpoint: opts.endpoint } : void 0
128
- });
137
+ const privkey = opts.privkey ?? process.env.ATBASH_AGENT_PRIVKEY ?? "";
138
+ const clientOpts = {};
139
+ if (opts.endpoint) clientOpts.endpoint = opts.endpoint;
140
+ const client = new Atbash(privkey, clientOpts);
129
141
  const graph = builder;
130
142
  const toolsNode = opts.toolsNode ?? "tools";
131
143
  const agentNode = opts.agentNode ?? "agent";
132
144
  graph.addNode("atbash_guard", createGuardNode({ client }));
133
- graph.addNode("atbash_audit", createAuditNode({ agent, clientOpts }));
145
+ graph.addNode("atbash_audit", createAuditNode({ client }));
134
146
  graph.addConditionalEdges("atbash_guard", (state) => {
135
147
  return state.atbashVerdict === "ALLOW" ? toolsNode : agentNode;
136
148
  });
@@ -140,23 +152,21 @@ function addAtbashSafety(builder, opts) {
140
152
  }
141
153
 
142
154
  // src/tools/judgeTool.ts
143
- import { judgeAction as judgeAction2 } from "@atbash/sdk";
144
155
  import { tool } from "@langchain/core/tools";
145
156
  import { z } from "zod";
146
- function createJudgeTool(agent, endpoint) {
157
+ function createJudgeTool(client) {
147
158
  return tool(
148
159
  async ({ action, context }) => {
149
- const result = await judgeAction2(
150
- action,
151
- context,
152
- agent,
153
- endpoint ? { endpoint } : void 0
154
- );
160
+ const decision = await client.auditToolCall({
161
+ toolName: "atbash_safety_check",
162
+ args: { action },
163
+ context
164
+ });
155
165
  return JSON.stringify({
156
- verdict: result.verdict,
157
- reason: result.reason,
158
- confidence: result.confidence,
159
- tool_call_id: result.tool_call_id
166
+ verdict: decision.verdict,
167
+ allow: decision.allow,
168
+ reason: decision.reason,
169
+ tool_call_id: decision.toolCallId
160
170
  });
161
171
  },
162
172
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atbash/atbash-langgraph",
3
- "version": "0.0.5-dev.1",
3
+ "version": "0.0.5-dev.3",
4
4
  "description": "Atbash safety guard and audit nodes for LangGraph workflows",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -34,12 +34,10 @@
34
34
  },
35
35
  "scripts": {
36
36
  "build": "tsup src/index.ts --format esm --dts --clean",
37
- "prepublishOnly": "npm run build",
38
- "publish:prod": "npm publish --tag latest --access public",
39
- "publish:dev": "node scripts/publish-dev.mjs"
37
+ "prepublishOnly": "npm run build"
40
38
  },
41
39
  "dependencies": {
42
- "@atbash/sdk": "*",
40
+ "@atbash/sdk": "0.5.3-dev.0",
43
41
  "zod": "^3.25.76"
44
42
  },
45
43
  "peerDependencies": {