@axonflow/sdk 4.1.0 → 4.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.
Files changed (38) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/adapters/langgraph.d.ts +284 -0
  3. package/dist/cjs/adapters/langgraph.d.ts.map +1 -0
  4. package/dist/cjs/adapters/langgraph.js +364 -0
  5. package/dist/cjs/adapters/langgraph.js.map +1 -0
  6. package/dist/cjs/client.d.ts +82 -2
  7. package/dist/cjs/client.d.ts.map +1 -1
  8. package/dist/cjs/client.js +173 -2
  9. package/dist/cjs/client.js.map +1 -1
  10. package/dist/cjs/index.d.ts +3 -1
  11. package/dist/cjs/index.d.ts.map +1 -1
  12. package/dist/cjs/index.js +6 -1
  13. package/dist/cjs/index.js.map +1 -1
  14. package/dist/cjs/telemetry.js +1 -1
  15. package/dist/cjs/telemetry.js.map +1 -1
  16. package/dist/cjs/types/gateway.d.ts +65 -0
  17. package/dist/cjs/types/gateway.d.ts.map +1 -1
  18. package/dist/cjs/version.d.ts +1 -1
  19. package/dist/cjs/version.js +1 -1
  20. package/dist/esm/adapters/langgraph.d.ts +284 -0
  21. package/dist/esm/adapters/langgraph.d.ts.map +1 -0
  22. package/dist/esm/adapters/langgraph.js +358 -0
  23. package/dist/esm/adapters/langgraph.js.map +1 -0
  24. package/dist/esm/client.d.ts +82 -2
  25. package/dist/esm/client.d.ts.map +1 -1
  26. package/dist/esm/client.js +173 -2
  27. package/dist/esm/client.js.map +1 -1
  28. package/dist/esm/index.d.ts +3 -1
  29. package/dist/esm/index.d.ts.map +1 -1
  30. package/dist/esm/index.js +2 -0
  31. package/dist/esm/index.js.map +1 -1
  32. package/dist/esm/telemetry.js +1 -1
  33. package/dist/esm/telemetry.js.map +1 -1
  34. package/dist/esm/types/gateway.d.ts +65 -0
  35. package/dist/esm/types/gateway.d.ts.map +1 -1
  36. package/dist/esm/version.d.ts +1 -1
  37. package/dist/esm/version.js +1 -1
  38. package/package.json +1 -1
package/README.md CHANGED
@@ -804,7 +804,7 @@ console.log('Message sent:', result.success);
804
804
  | Amadeus GDS | Travel | Flight/hotel booking |
805
805
  | Cassandra | NoSQL | Distributed database |
806
806
 
807
- For complete connector documentation, see [https://docs.getaxonflow.com/mcp](https://docs.getaxonflow.com/mcp)
807
+ For complete connector documentation, see [https://docs.getaxonflow.com/docs/mcp/overview](https://docs.getaxonflow.com/docs/mcp/overview)
808
808
 
809
809
  ## MCP Policy Features (v3.3.0)
810
810
 
@@ -0,0 +1,284 @@
1
+ /**
2
+ * LangGraph Adapter for AxonFlow Workflow Control Plane.
3
+ *
4
+ * This adapter wraps LangGraph workflows with AxonFlow governance gates,
5
+ * providing policy enforcement at step transitions.
6
+ *
7
+ * "LangGraph runs the workflow. AxonFlow decides when it's allowed to move forward."
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { AxonFlow, AxonFlowLangGraphAdapter } from '@axonflow/sdk';
12
+ *
13
+ * const client = new AxonFlow({ endpoint: 'http://localhost:8080' });
14
+ * const adapter = new AxonFlowLangGraphAdapter(client, 'my-workflow');
15
+ *
16
+ * // Start workflow and register with AxonFlow
17
+ * await adapter.startWorkflow();
18
+ *
19
+ * // Before each step, check the gate
20
+ * if (await adapter.checkGate('generate_code', 'llm_call', { model: 'gpt-4' })) {
21
+ * const result = await executeStep();
22
+ * await adapter.stepCompleted('generate_code');
23
+ * }
24
+ *
25
+ * // Complete workflow
26
+ * await adapter.completeWorkflow();
27
+ * ```
28
+ */
29
+ import { AxonFlow } from '../client';
30
+ import { AxonFlowError } from '../errors';
31
+ import type { StepType, ToolContext, WorkflowSource } from '../types/workflows';
32
+ /**
33
+ * Error thrown when a workflow step is blocked by policy.
34
+ */
35
+ export declare class WorkflowBlockedError extends AxonFlowError {
36
+ readonly stepId?: string;
37
+ readonly reason?: string;
38
+ readonly policyIds: string[];
39
+ constructor(message: string, stepId?: string, reason?: string, policyIds?: string[]);
40
+ }
41
+ /**
42
+ * Error thrown when a workflow step requires approval.
43
+ */
44
+ export declare class WorkflowApprovalRequiredError extends AxonFlowError {
45
+ readonly stepId?: string;
46
+ readonly approvalUrl?: string;
47
+ readonly reason?: string;
48
+ constructor(message: string, stepId?: string, approvalUrl?: string, reason?: string);
49
+ }
50
+ /**
51
+ * Options for the MCP tool interceptor.
52
+ */
53
+ export interface MCPInterceptorOptions {
54
+ /**
55
+ * Optional function that maps an MCP request to a connector type string.
56
+ * Defaults to `${request.serverName}.${request.name}`.
57
+ */
58
+ connectorTypeFn?: (request: any) => string;
59
+ /**
60
+ * Operation type passed to mcp_check_input.
61
+ * Defaults to "execute". Set to "query" for known read-only tool calls.
62
+ */
63
+ operation?: string;
64
+ }
65
+ /**
66
+ * Options for the LangGraph adapter constructor.
67
+ */
68
+ export interface LangGraphAdapterOptions {
69
+ /** Workflow source (defaults to 'langgraph') */
70
+ source?: WorkflowSource;
71
+ /**
72
+ * If true, checkGate raises WorkflowBlockedError on block.
73
+ * If false, returns false and caller handles it.
74
+ * Defaults to true.
75
+ */
76
+ autoBlock?: boolean;
77
+ }
78
+ /**
79
+ * Options for checkGate method.
80
+ */
81
+ export interface CheckGateOptions {
82
+ /** Optional step ID (auto-generated if not provided) */
83
+ stepId?: string;
84
+ /** Input data for the step (for policy evaluation) */
85
+ stepInput?: Record<string, unknown>;
86
+ /** LLM model being used */
87
+ model?: string;
88
+ /** LLM provider being used */
89
+ provider?: string;
90
+ /** Tool context for per-tool governance within tool_call steps */
91
+ toolContext?: ToolContext;
92
+ }
93
+ /**
94
+ * Options for stepCompleted method.
95
+ */
96
+ export interface StepCompletedOptions {
97
+ /** Optional step ID (must match the one used in checkGate) */
98
+ stepId?: string;
99
+ /** Output data from the step */
100
+ output?: Record<string, unknown>;
101
+ /** Additional metadata */
102
+ metadata?: Record<string, unknown>;
103
+ /** Input tokens consumed */
104
+ tokensIn?: number;
105
+ /** Output tokens produced */
106
+ tokensOut?: number;
107
+ /** Cost in USD */
108
+ costUsd?: number;
109
+ }
110
+ /**
111
+ * Options for checkToolGate method.
112
+ */
113
+ export interface CheckToolGateOptions {
114
+ /** Step name (defaults to "tools/{toolName}") */
115
+ stepName?: string;
116
+ /** Optional step ID (auto-generated if not provided) */
117
+ stepId?: string;
118
+ /** Input arguments for the tool */
119
+ toolInput?: Record<string, unknown>;
120
+ /** LLM model being used */
121
+ model?: string;
122
+ /** LLM provider being used */
123
+ provider?: string;
124
+ }
125
+ /**
126
+ * Options for toolCompleted method.
127
+ */
128
+ export interface ToolCompletedOptions {
129
+ /** Step name (defaults to "tools/{toolName}") */
130
+ stepName?: string;
131
+ /** Optional step ID (must match the one used in checkToolGate) */
132
+ stepId?: string;
133
+ /** Output data from the tool */
134
+ output?: Record<string, unknown>;
135
+ /** Input tokens consumed */
136
+ tokensIn?: number;
137
+ /** Output tokens produced */
138
+ tokensOut?: number;
139
+ /** Cost in USD */
140
+ costUsd?: number;
141
+ }
142
+ /**
143
+ * Options for waitForApproval method.
144
+ */
145
+ export interface WaitForApprovalOptions {
146
+ /** Seconds between polls (default 5) */
147
+ pollInterval?: number;
148
+ /** Maximum seconds to wait (default 300) */
149
+ timeout?: number;
150
+ }
151
+ /**
152
+ * Wraps LangGraph workflows with AxonFlow governance gates.
153
+ *
154
+ * This adapter provides a simple interface for integrating AxonFlow's
155
+ * Workflow Control Plane with LangGraph workflows. It handles workflow
156
+ * registration, step gate checks, and workflow lifecycle management.
157
+ *
158
+ * @example
159
+ * ```typescript
160
+ * const adapter = new AxonFlowLangGraphAdapter(client, 'code-review-pipeline');
161
+ * await adapter.startWorkflow();
162
+ *
163
+ * // Before each LangGraph node execution
164
+ * if (await adapter.checkGate('analyze', 'llm_call')) {
165
+ * const result = await analyzeCode(state);
166
+ * await adapter.stepCompleted('analyze');
167
+ * }
168
+ * ```
169
+ */
170
+ export declare class AxonFlowLangGraphAdapter {
171
+ readonly client: AxonFlow;
172
+ readonly workflowName: string;
173
+ readonly source: WorkflowSource;
174
+ workflowId: string | null;
175
+ private _stepCounter;
176
+ private readonly _autoBlock;
177
+ constructor(client: AxonFlow, workflowName: string, options?: LangGraphAdapterOptions);
178
+ /**
179
+ * Register the workflow with AxonFlow.
180
+ *
181
+ * Call this at the start of your LangGraph workflow execution.
182
+ *
183
+ * @param metadata - Additional workflow metadata
184
+ * @param traceId - External trace ID for correlation (Langsmith, Datadog, OTel)
185
+ * @returns The assigned workflow ID
186
+ */
187
+ startWorkflow(metadata?: Record<string, unknown>, traceId?: string): Promise<string>;
188
+ /**
189
+ * Check if a step is allowed to proceed.
190
+ *
191
+ * Call this before executing each LangGraph node to check policy approval.
192
+ *
193
+ * @param stepName - Human-readable step name
194
+ * @param stepType - Type of step (llm_call, tool_call, connector_call, human_task)
195
+ * @param opts - Additional options
196
+ * @returns True if step is allowed, false if blocked (when autoBlock=false)
197
+ * @throws WorkflowBlockedError if step is blocked and autoBlock=true
198
+ * @throws WorkflowApprovalRequiredError if step requires approval
199
+ * @throws Error if workflow not started
200
+ */
201
+ checkGate(stepName: string, stepType: StepType, opts?: CheckGateOptions): Promise<boolean>;
202
+ /**
203
+ * Mark a step as completed.
204
+ *
205
+ * Call this after successfully executing a LangGraph node.
206
+ *
207
+ * @param stepName - Step name (used to generate step_id if not provided)
208
+ * @param opts - Additional options
209
+ */
210
+ stepCompleted(stepName: string, opts?: StepCompletedOptions): Promise<void>;
211
+ /**
212
+ * Check if a specific tool invocation is allowed.
213
+ *
214
+ * Convenience wrapper around checkGate() that sets step_type='tool_call'
215
+ * and includes ToolContext for per-tool governance.
216
+ *
217
+ * @param toolName - Name of the tool being invoked
218
+ * @param toolType - Tool type (function, mcp, api)
219
+ * @param opts - Additional options
220
+ * @returns True if tool invocation is allowed, false if blocked (when autoBlock=false)
221
+ */
222
+ checkToolGate(toolName: string, toolType?: string, opts?: CheckToolGateOptions): Promise<boolean>;
223
+ /**
224
+ * Mark a tool invocation as completed.
225
+ *
226
+ * Convenience wrapper around stepCompleted() for tool-level tracking.
227
+ *
228
+ * @param toolName - Name of the tool that was invoked
229
+ * @param opts - Additional options
230
+ */
231
+ toolCompleted(toolName: string, opts?: ToolCompletedOptions): Promise<void>;
232
+ /**
233
+ * Mark the workflow as completed.
234
+ *
235
+ * Call this when your LangGraph workflow finishes successfully.
236
+ */
237
+ completeWorkflow(): Promise<void>;
238
+ /**
239
+ * Abort the workflow.
240
+ *
241
+ * Call this when your LangGraph workflow fails or is cancelled.
242
+ *
243
+ * @param reason - Reason for aborting
244
+ */
245
+ abortWorkflow(reason?: string): Promise<void>;
246
+ /**
247
+ * Fail the workflow.
248
+ *
249
+ * Call this when your LangGraph workflow has encountered an unrecoverable error.
250
+ *
251
+ * @param reason - Reason for the failure
252
+ */
253
+ failWorkflow(reason?: string): Promise<void>;
254
+ /**
255
+ * Wait for a step to be approved.
256
+ *
257
+ * Poll the workflow status until the step is approved or rejected.
258
+ *
259
+ * @param stepId - Step ID to wait for
260
+ * @param opts - Polling options
261
+ * @returns True if approved, false if rejected
262
+ * @throws Error if approval not received within timeout
263
+ */
264
+ waitForApproval(stepId: string, opts?: WaitForApprovalOptions): Promise<boolean>;
265
+ /**
266
+ * Return an async MCP tool interceptor for use with MultiServerMCPClient.
267
+ *
268
+ * The interceptor enforces AxonFlow input and output policies around every
269
+ * MCP tool call.
270
+ *
271
+ * @example
272
+ * ```typescript
273
+ * const mcp = new MultiServerMCPClient(
274
+ * { 'my-server': { url: '...', transport: 'http' } },
275
+ * { toolInterceptors: [adapter.mcpToolInterceptor()] },
276
+ * );
277
+ * ```
278
+ *
279
+ * @param opts - Optional interceptor options
280
+ * @returns An async callable (request, handler) => result
281
+ */
282
+ mcpToolInterceptor(opts?: MCPInterceptorOptions): (request: any, handler: (request: any) => Promise<any>) => Promise<any>;
283
+ }
284
+ //# sourceMappingURL=langgraph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"langgraph.d.ts","sourceRoot":"","sources":["../../../src/adapters/langgraph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;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AAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAYjF;;;;OAIG;IACG,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAOvC;;;;;;OAMG;IACG,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOnD;;;;;;OAMG;IACG,YAAY,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOlD;;;;;;;;;OASG;IACG,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,OAAO,CAAC;IAoCtF;;;;;;;;;;;;;;;;OAgBG;IACH,kBAAkB,CAChB,IAAI,CAAC,EAAE,qBAAqB,GAC3B,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,KAAK,OAAO,CAAC,GAAG,CAAC;CAyD3E"}
@@ -0,0 +1,364 @@
1
+ "use strict";
2
+ /**
3
+ * LangGraph Adapter for AxonFlow Workflow Control Plane.
4
+ *
5
+ * This adapter wraps LangGraph workflows with AxonFlow governance gates,
6
+ * providing policy enforcement at step transitions.
7
+ *
8
+ * "LangGraph runs the workflow. AxonFlow decides when it's allowed to move forward."
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { AxonFlow, AxonFlowLangGraphAdapter } from '@axonflow/sdk';
13
+ *
14
+ * const client = new AxonFlow({ endpoint: 'http://localhost:8080' });
15
+ * const adapter = new AxonFlowLangGraphAdapter(client, 'my-workflow');
16
+ *
17
+ * // Start workflow and register with AxonFlow
18
+ * await adapter.startWorkflow();
19
+ *
20
+ * // Before each step, check the gate
21
+ * if (await adapter.checkGate('generate_code', 'llm_call', { model: 'gpt-4' })) {
22
+ * const result = await executeStep();
23
+ * await adapter.stepCompleted('generate_code');
24
+ * }
25
+ *
26
+ * // Complete workflow
27
+ * await adapter.completeWorkflow();
28
+ * ```
29
+ */
30
+ Object.defineProperty(exports, "__esModule", { value: true });
31
+ exports.AxonFlowLangGraphAdapter = exports.WorkflowApprovalRequiredError = exports.WorkflowBlockedError = void 0;
32
+ const errors_1 = require("../errors");
33
+ /**
34
+ * Error thrown when a workflow step is blocked by policy.
35
+ */
36
+ class WorkflowBlockedError extends errors_1.AxonFlowError {
37
+ constructor(message, stepId, reason, policyIds) {
38
+ super(message, { stepId, reason, policyIds: policyIds || [] });
39
+ this.name = 'WorkflowBlockedError';
40
+ this.stepId = stepId;
41
+ this.reason = reason;
42
+ this.policyIds = policyIds || [];
43
+ Object.setPrototypeOf(this, WorkflowBlockedError.prototype);
44
+ }
45
+ }
46
+ exports.WorkflowBlockedError = WorkflowBlockedError;
47
+ /**
48
+ * Error thrown when a workflow step requires approval.
49
+ */
50
+ class WorkflowApprovalRequiredError extends errors_1.AxonFlowError {
51
+ constructor(message, stepId, approvalUrl, reason) {
52
+ super(message, { stepId, approvalUrl, reason });
53
+ this.name = 'WorkflowApprovalRequiredError';
54
+ this.stepId = stepId;
55
+ this.approvalUrl = approvalUrl;
56
+ this.reason = reason;
57
+ Object.setPrototypeOf(this, WorkflowApprovalRequiredError.prototype);
58
+ }
59
+ }
60
+ exports.WorkflowApprovalRequiredError = WorkflowApprovalRequiredError;
61
+ /**
62
+ * Wraps LangGraph workflows with AxonFlow governance gates.
63
+ *
64
+ * This adapter provides a simple interface for integrating AxonFlow's
65
+ * Workflow Control Plane with LangGraph workflows. It handles workflow
66
+ * registration, step gate checks, and workflow lifecycle management.
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * const adapter = new AxonFlowLangGraphAdapter(client, 'code-review-pipeline');
71
+ * await adapter.startWorkflow();
72
+ *
73
+ * // Before each LangGraph node execution
74
+ * if (await adapter.checkGate('analyze', 'llm_call')) {
75
+ * const result = await analyzeCode(state);
76
+ * await adapter.stepCompleted('analyze');
77
+ * }
78
+ * ```
79
+ */
80
+ class AxonFlowLangGraphAdapter {
81
+ constructor(client, workflowName, options) {
82
+ this.workflowId = null;
83
+ this._stepCounter = 0;
84
+ this.client = client;
85
+ this.workflowName = workflowName;
86
+ this.source = options?.source ?? 'langgraph';
87
+ this._autoBlock = options?.autoBlock ?? true;
88
+ }
89
+ /**
90
+ * Register the workflow with AxonFlow.
91
+ *
92
+ * Call this at the start of your LangGraph workflow execution.
93
+ *
94
+ * @param metadata - Additional workflow metadata
95
+ * @param traceId - External trace ID for correlation (Langsmith, Datadog, OTel)
96
+ * @returns The assigned workflow ID
97
+ */
98
+ async startWorkflow(metadata, traceId) {
99
+ const response = await this.client.createWorkflow({
100
+ workflow_name: this.workflowName,
101
+ source: this.source,
102
+ metadata: metadata || {},
103
+ trace_id: traceId,
104
+ });
105
+ this.workflowId = response.workflow_id;
106
+ return this.workflowId;
107
+ }
108
+ /**
109
+ * Check if a step is allowed to proceed.
110
+ *
111
+ * Call this before executing each LangGraph node to check policy approval.
112
+ *
113
+ * @param stepName - Human-readable step name
114
+ * @param stepType - Type of step (llm_call, tool_call, connector_call, human_task)
115
+ * @param opts - Additional options
116
+ * @returns True if step is allowed, false if blocked (when autoBlock=false)
117
+ * @throws WorkflowBlockedError if step is blocked and autoBlock=true
118
+ * @throws WorkflowApprovalRequiredError if step requires approval
119
+ * @throws Error if workflow not started
120
+ */
121
+ async checkGate(stepName, stepType, opts) {
122
+ if (!this.workflowId) {
123
+ throw new Error('Workflow not started. Call startWorkflow() first.');
124
+ }
125
+ // Generate step ID if not provided
126
+ let stepId = opts?.stepId;
127
+ if (!stepId) {
128
+ this._stepCounter += 1;
129
+ const safeName = stepName.toLowerCase().replace(/ /g, '-').replace(/\//g, '-');
130
+ stepId = `step-${this._stepCounter}-${safeName}`;
131
+ }
132
+ const response = await this.client.stepGate(this.workflowId, stepId, {
133
+ step_name: stepName,
134
+ step_type: stepType,
135
+ step_input: opts?.stepInput || {},
136
+ model: opts?.model,
137
+ provider: opts?.provider,
138
+ tool_context: opts?.toolContext,
139
+ });
140
+ if (response.decision === 'block') {
141
+ if (this._autoBlock) {
142
+ throw new WorkflowBlockedError(`Step '${stepName}' blocked: ${response.reason}`, response.step_id, response.reason, response.policy_ids);
143
+ }
144
+ return false;
145
+ }
146
+ if (response.decision === 'require_approval') {
147
+ throw new WorkflowApprovalRequiredError(`Step '${stepName}' requires approval`, response.step_id, response.approval_url, response.reason);
148
+ }
149
+ return true;
150
+ }
151
+ /**
152
+ * Mark a step as completed.
153
+ *
154
+ * Call this after successfully executing a LangGraph node.
155
+ *
156
+ * @param stepName - Step name (used to generate step_id if not provided)
157
+ * @param opts - Additional options
158
+ */
159
+ async stepCompleted(stepName, opts) {
160
+ if (!this.workflowId) {
161
+ throw new Error('Workflow not started. Call startWorkflow() first.');
162
+ }
163
+ // Generate step ID if not provided (must match checkGate)
164
+ let stepId = opts?.stepId;
165
+ if (!stepId) {
166
+ const safeName = stepName.toLowerCase().replace(/ /g, '-').replace(/\//g, '-');
167
+ stepId = `step-${this._stepCounter}-${safeName}`;
168
+ }
169
+ await this.client.markStepCompleted(this.workflowId, stepId, {
170
+ output: opts?.output || {},
171
+ metadata: opts?.metadata || {},
172
+ tokens_in: opts?.tokensIn,
173
+ tokens_out: opts?.tokensOut,
174
+ cost_usd: opts?.costUsd,
175
+ });
176
+ }
177
+ /**
178
+ * Check if a specific tool invocation is allowed.
179
+ *
180
+ * Convenience wrapper around checkGate() that sets step_type='tool_call'
181
+ * and includes ToolContext for per-tool governance.
182
+ *
183
+ * @param toolName - Name of the tool being invoked
184
+ * @param toolType - Tool type (function, mcp, api)
185
+ * @param opts - Additional options
186
+ * @returns True if tool invocation is allowed, false if blocked (when autoBlock=false)
187
+ */
188
+ async checkToolGate(toolName, toolType, opts) {
189
+ const stepName = opts?.stepName ?? `tools/${toolName}`;
190
+ const toolContext = {
191
+ tool_name: toolName,
192
+ tool_type: toolType,
193
+ tool_input: opts?.toolInput || {},
194
+ };
195
+ return this.checkGate(stepName, 'tool_call', {
196
+ stepId: opts?.stepId,
197
+ model: opts?.model,
198
+ provider: opts?.provider,
199
+ toolContext,
200
+ });
201
+ }
202
+ /**
203
+ * Mark a tool invocation as completed.
204
+ *
205
+ * Convenience wrapper around stepCompleted() for tool-level tracking.
206
+ *
207
+ * @param toolName - Name of the tool that was invoked
208
+ * @param opts - Additional options
209
+ */
210
+ async toolCompleted(toolName, opts) {
211
+ const stepName = opts?.stepName ?? `tools/${toolName}`;
212
+ await this.stepCompleted(stepName, {
213
+ stepId: opts?.stepId,
214
+ output: opts?.output,
215
+ tokensIn: opts?.tokensIn,
216
+ tokensOut: opts?.tokensOut,
217
+ costUsd: opts?.costUsd,
218
+ });
219
+ }
220
+ /**
221
+ * Mark the workflow as completed.
222
+ *
223
+ * Call this when your LangGraph workflow finishes successfully.
224
+ */
225
+ async completeWorkflow() {
226
+ if (!this.workflowId) {
227
+ throw new Error('Workflow not started. Call startWorkflow() first.');
228
+ }
229
+ await this.client.completeWorkflow(this.workflowId);
230
+ }
231
+ /**
232
+ * Abort the workflow.
233
+ *
234
+ * Call this when your LangGraph workflow fails or is cancelled.
235
+ *
236
+ * @param reason - Reason for aborting
237
+ */
238
+ async abortWorkflow(reason) {
239
+ if (!this.workflowId) {
240
+ throw new Error('Workflow not started. Call startWorkflow() first.');
241
+ }
242
+ await this.client.abortWorkflow(this.workflowId, reason);
243
+ }
244
+ /**
245
+ * Fail the workflow.
246
+ *
247
+ * Call this when your LangGraph workflow has encountered an unrecoverable error.
248
+ *
249
+ * @param reason - Reason for the failure
250
+ */
251
+ async failWorkflow(reason) {
252
+ if (!this.workflowId) {
253
+ throw new Error('Workflow not started. Call startWorkflow() first.');
254
+ }
255
+ await this.client.failWorkflow(this.workflowId, reason);
256
+ }
257
+ /**
258
+ * Wait for a step to be approved.
259
+ *
260
+ * Poll the workflow status until the step is approved or rejected.
261
+ *
262
+ * @param stepId - Step ID to wait for
263
+ * @param opts - Polling options
264
+ * @returns True if approved, false if rejected
265
+ * @throws Error if approval not received within timeout
266
+ */
267
+ async waitForApproval(stepId, opts) {
268
+ if (!this.workflowId) {
269
+ throw new Error('Workflow not started. Call startWorkflow() first.');
270
+ }
271
+ const pollInterval = opts?.pollInterval ?? 5;
272
+ const timeout = opts?.timeout ?? 300;
273
+ let elapsed = 0;
274
+ while (elapsed < timeout) {
275
+ const status = await this.client.getWorkflow(this.workflowId);
276
+ // Find the step
277
+ if (status.steps) {
278
+ for (const step of status.steps) {
279
+ if (step.step_id === stepId) {
280
+ if (step.approval_status) {
281
+ if (step.approval_status === 'approved') {
282
+ return true;
283
+ }
284
+ if (step.approval_status === 'rejected') {
285
+ return false;
286
+ }
287
+ }
288
+ break;
289
+ }
290
+ }
291
+ }
292
+ await new Promise(resolve => setTimeout(resolve, pollInterval * 1000));
293
+ elapsed += pollInterval;
294
+ }
295
+ throw new errors_1.TimeoutError(timeout * 1000);
296
+ }
297
+ /**
298
+ * Return an async MCP tool interceptor for use with MultiServerMCPClient.
299
+ *
300
+ * The interceptor enforces AxonFlow input and output policies around every
301
+ * MCP tool call.
302
+ *
303
+ * @example
304
+ * ```typescript
305
+ * const mcp = new MultiServerMCPClient(
306
+ * { 'my-server': { url: '...', transport: 'http' } },
307
+ * { toolInterceptors: [adapter.mcpToolInterceptor()] },
308
+ * );
309
+ * ```
310
+ *
311
+ * @param opts - Optional interceptor options
312
+ * @returns An async callable (request, handler) => result
313
+ */
314
+ mcpToolInterceptor(opts) {
315
+ const operation = opts?.operation ?? 'execute';
316
+ const defaultConnectorType = (request) => {
317
+ return `${request.serverName}.${request.name}`;
318
+ };
319
+ const resolveConnectorType = opts?.connectorTypeFn ?? defaultConnectorType;
320
+ return async (request, handler) => {
321
+ const connectorType = resolveConnectorType(request);
322
+ let argsStr = '{}';
323
+ if (request.args) {
324
+ try {
325
+ argsStr = JSON.stringify(request.args);
326
+ }
327
+ catch {
328
+ argsStr = String(request.args);
329
+ }
330
+ }
331
+ const statement = `${connectorType}(${argsStr})`;
332
+ const preCheck = await this.client.mcpCheckInput({
333
+ connectorType,
334
+ statement,
335
+ operation,
336
+ parameters: request.args,
337
+ });
338
+ if (!preCheck.allowed) {
339
+ throw new errors_1.PolicyViolationError(preCheck.block_reason || 'Tool call blocked by policy');
340
+ }
341
+ const result = await handler(request);
342
+ let resultStr;
343
+ try {
344
+ resultStr = JSON.stringify(result);
345
+ }
346
+ catch {
347
+ resultStr = String(result);
348
+ }
349
+ const outputCheck = await this.client.mcpCheckOutput({
350
+ connectorType,
351
+ message: resultStr,
352
+ });
353
+ if (!outputCheck.allowed) {
354
+ throw new errors_1.PolicyViolationError(outputCheck.block_reason || 'Tool result blocked by policy');
355
+ }
356
+ if (outputCheck.redacted_data !== undefined && outputCheck.redacted_data !== null) {
357
+ return outputCheck.redacted_data;
358
+ }
359
+ return result;
360
+ };
361
+ }
362
+ }
363
+ exports.AxonFlowLangGraphAdapter = AxonFlowLangGraphAdapter;
364
+ //# sourceMappingURL=langgraph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"langgraph.js","sourceRoot":"","sources":["../../../src/adapters/langgraph.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;;AAGH,sCAImB;AAGnB;;GAEG;AACH,MAAa,oBAAqB,SAAQ,sBAAa;IAKrD,YAAY,OAAe,EAAE,MAAe,EAAE,MAAe,EAAE,SAAoB;QACjF,KAAK,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,IAAI,EAAE,EAAE,CAAC,CAAC;QAC/D,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,EAAE,CAAC;QACjC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,oBAAoB,CAAC,SAAS,C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