@axonflow/sdk 4.0.1 → 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 (44) 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 +107 -2
  7. package/dist/cjs/client.d.ts.map +1 -1
  8. package/dist/cjs/client.js +231 -2
  9. package/dist/cjs/client.js.map +1 -1
  10. package/dist/cjs/index.d.ts +9 -4
  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.d.ts.map +1 -1
  15. package/dist/cjs/telemetry.js +69 -19
  16. package/dist/cjs/telemetry.js.map +1 -1
  17. package/dist/cjs/types/gateway.d.ts +105 -0
  18. package/dist/cjs/types/gateway.d.ts.map +1 -1
  19. package/dist/cjs/version.d.ts +6 -3
  20. package/dist/cjs/version.d.ts.map +1 -1
  21. package/dist/cjs/version.js +7 -3
  22. package/dist/cjs/version.js.map +1 -1
  23. package/dist/esm/adapters/langgraph.d.ts +284 -0
  24. package/dist/esm/adapters/langgraph.d.ts.map +1 -0
  25. package/dist/esm/adapters/langgraph.js +358 -0
  26. package/dist/esm/adapters/langgraph.js.map +1 -0
  27. package/dist/esm/client.d.ts +107 -2
  28. package/dist/esm/client.d.ts.map +1 -1
  29. package/dist/esm/client.js +231 -2
  30. package/dist/esm/client.js.map +1 -1
  31. package/dist/esm/index.d.ts +9 -4
  32. package/dist/esm/index.d.ts.map +1 -1
  33. package/dist/esm/index.js +2 -0
  34. package/dist/esm/index.js.map +1 -1
  35. package/dist/esm/telemetry.d.ts.map +1 -1
  36. package/dist/esm/telemetry.js +69 -19
  37. package/dist/esm/telemetry.js.map +1 -1
  38. package/dist/esm/types/gateway.d.ts +105 -0
  39. package/dist/esm/types/gateway.d.ts.map +1 -1
  40. package/dist/esm/version.d.ts +6 -3
  41. package/dist/esm/version.d.ts.map +1 -1
  42. package/dist/esm/version.js +7 -3
  43. package/dist/esm/version.js.map +1 -1
  44. package/package.json +4 -2
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EACL,aAAa,EAGd,MAAM,WAAW,CAAC;AACnB,OAAO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,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,358 @@
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 { AxonFlowError, PolicyViolationError, TimeoutError as AxonFlowTimeoutError, } from '../errors';
30
+ /**
31
+ * Error thrown when a workflow step is blocked by policy.
32
+ */
33
+ export class WorkflowBlockedError extends AxonFlowError {
34
+ constructor(message, stepId, reason, policyIds) {
35
+ super(message, { stepId, reason, policyIds: policyIds || [] });
36
+ this.name = 'WorkflowBlockedError';
37
+ this.stepId = stepId;
38
+ this.reason = reason;
39
+ this.policyIds = policyIds || [];
40
+ Object.setPrototypeOf(this, WorkflowBlockedError.prototype);
41
+ }
42
+ }
43
+ /**
44
+ * Error thrown when a workflow step requires approval.
45
+ */
46
+ export class WorkflowApprovalRequiredError extends AxonFlowError {
47
+ constructor(message, stepId, approvalUrl, reason) {
48
+ super(message, { stepId, approvalUrl, reason });
49
+ this.name = 'WorkflowApprovalRequiredError';
50
+ this.stepId = stepId;
51
+ this.approvalUrl = approvalUrl;
52
+ this.reason = reason;
53
+ Object.setPrototypeOf(this, WorkflowApprovalRequiredError.prototype);
54
+ }
55
+ }
56
+ /**
57
+ * Wraps LangGraph workflows with AxonFlow governance gates.
58
+ *
59
+ * This adapter provides a simple interface for integrating AxonFlow's
60
+ * Workflow Control Plane with LangGraph workflows. It handles workflow
61
+ * registration, step gate checks, and workflow lifecycle management.
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * const adapter = new AxonFlowLangGraphAdapter(client, 'code-review-pipeline');
66
+ * await adapter.startWorkflow();
67
+ *
68
+ * // Before each LangGraph node execution
69
+ * if (await adapter.checkGate('analyze', 'llm_call')) {
70
+ * const result = await analyzeCode(state);
71
+ * await adapter.stepCompleted('analyze');
72
+ * }
73
+ * ```
74
+ */
75
+ export class AxonFlowLangGraphAdapter {
76
+ constructor(client, workflowName, options) {
77
+ this.workflowId = null;
78
+ this._stepCounter = 0;
79
+ this.client = client;
80
+ this.workflowName = workflowName;
81
+ this.source = options?.source ?? 'langgraph';
82
+ this._autoBlock = options?.autoBlock ?? true;
83
+ }
84
+ /**
85
+ * Register the workflow with AxonFlow.
86
+ *
87
+ * Call this at the start of your LangGraph workflow execution.
88
+ *
89
+ * @param metadata - Additional workflow metadata
90
+ * @param traceId - External trace ID for correlation (Langsmith, Datadog, OTel)
91
+ * @returns The assigned workflow ID
92
+ */
93
+ async startWorkflow(metadata, traceId) {
94
+ const response = await this.client.createWorkflow({
95
+ workflow_name: this.workflowName,
96
+ source: this.source,
97
+ metadata: metadata || {},
98
+ trace_id: traceId,
99
+ });
100
+ this.workflowId = response.workflow_id;
101
+ return this.workflowId;
102
+ }
103
+ /**
104
+ * Check if a step is allowed to proceed.
105
+ *
106
+ * Call this before executing each LangGraph node to check policy approval.
107
+ *
108
+ * @param stepName - Human-readable step name
109
+ * @param stepType - Type of step (llm_call, tool_call, connector_call, human_task)
110
+ * @param opts - Additional options
111
+ * @returns True if step is allowed, false if blocked (when autoBlock=false)
112
+ * @throws WorkflowBlockedError if step is blocked and autoBlock=true
113
+ * @throws WorkflowApprovalRequiredError if step requires approval
114
+ * @throws Error if workflow not started
115
+ */
116
+ async checkGate(stepName, stepType, opts) {
117
+ if (!this.workflowId) {
118
+ throw new Error('Workflow not started. Call startWorkflow() first.');
119
+ }
120
+ // Generate step ID if not provided
121
+ let stepId = opts?.stepId;
122
+ if (!stepId) {
123
+ this._stepCounter += 1;
124
+ const safeName = stepName.toLowerCase().replace(/ /g, '-').replace(/\//g, '-');
125
+ stepId = `step-${this._stepCounter}-${safeName}`;
126
+ }
127
+ const response = await this.client.stepGate(this.workflowId, stepId, {
128
+ step_name: stepName,
129
+ step_type: stepType,
130
+ step_input: opts?.stepInput || {},
131
+ model: opts?.model,
132
+ provider: opts?.provider,
133
+ tool_context: opts?.toolContext,
134
+ });
135
+ if (response.decision === 'block') {
136
+ if (this._autoBlock) {
137
+ throw new WorkflowBlockedError(`Step '${stepName}' blocked: ${response.reason}`, response.step_id, response.reason, response.policy_ids);
138
+ }
139
+ return false;
140
+ }
141
+ if (response.decision === 'require_approval') {
142
+ throw new WorkflowApprovalRequiredError(`Step '${stepName}' requires approval`, response.step_id, response.approval_url, response.reason);
143
+ }
144
+ return true;
145
+ }
146
+ /**
147
+ * Mark a step as completed.
148
+ *
149
+ * Call this after successfully executing a LangGraph node.
150
+ *
151
+ * @param stepName - Step name (used to generate step_id if not provided)
152
+ * @param opts - Additional options
153
+ */
154
+ async stepCompleted(stepName, opts) {
155
+ if (!this.workflowId) {
156
+ throw new Error('Workflow not started. Call startWorkflow() first.');
157
+ }
158
+ // Generate step ID if not provided (must match checkGate)
159
+ let stepId = opts?.stepId;
160
+ if (!stepId) {
161
+ const safeName = stepName.toLowerCase().replace(/ /g, '-').replace(/\//g, '-');
162
+ stepId = `step-${this._stepCounter}-${safeName}`;
163
+ }
164
+ await this.client.markStepCompleted(this.workflowId, stepId, {
165
+ output: opts?.output || {},
166
+ metadata: opts?.metadata || {},
167
+ tokens_in: opts?.tokensIn,
168
+ tokens_out: opts?.tokensOut,
169
+ cost_usd: opts?.costUsd,
170
+ });
171
+ }
172
+ /**
173
+ * Check if a specific tool invocation is allowed.
174
+ *
175
+ * Convenience wrapper around checkGate() that sets step_type='tool_call'
176
+ * and includes ToolContext for per-tool governance.
177
+ *
178
+ * @param toolName - Name of the tool being invoked
179
+ * @param toolType - Tool type (function, mcp, api)
180
+ * @param opts - Additional options
181
+ * @returns True if tool invocation is allowed, false if blocked (when autoBlock=false)
182
+ */
183
+ async checkToolGate(toolName, toolType, opts) {
184
+ const stepName = opts?.stepName ?? `tools/${toolName}`;
185
+ const toolContext = {
186
+ tool_name: toolName,
187
+ tool_type: toolType,
188
+ tool_input: opts?.toolInput || {},
189
+ };
190
+ return this.checkGate(stepName, 'tool_call', {
191
+ stepId: opts?.stepId,
192
+ model: opts?.model,
193
+ provider: opts?.provider,
194
+ toolContext,
195
+ });
196
+ }
197
+ /**
198
+ * Mark a tool invocation as completed.
199
+ *
200
+ * Convenience wrapper around stepCompleted() for tool-level tracking.
201
+ *
202
+ * @param toolName - Name of the tool that was invoked
203
+ * @param opts - Additional options
204
+ */
205
+ async toolCompleted(toolName, opts) {
206
+ const stepName = opts?.stepName ?? `tools/${toolName}`;
207
+ await this.stepCompleted(stepName, {
208
+ stepId: opts?.stepId,
209
+ output: opts?.output,
210
+ tokensIn: opts?.tokensIn,
211
+ tokensOut: opts?.tokensOut,
212
+ costUsd: opts?.costUsd,
213
+ });
214
+ }
215
+ /**
216
+ * Mark the workflow as completed.
217
+ *
218
+ * Call this when your LangGraph workflow finishes successfully.
219
+ */
220
+ async completeWorkflow() {
221
+ if (!this.workflowId) {
222
+ throw new Error('Workflow not started. Call startWorkflow() first.');
223
+ }
224
+ await this.client.completeWorkflow(this.workflowId);
225
+ }
226
+ /**
227
+ * Abort the workflow.
228
+ *
229
+ * Call this when your LangGraph workflow fails or is cancelled.
230
+ *
231
+ * @param reason - Reason for aborting
232
+ */
233
+ async abortWorkflow(reason) {
234
+ if (!this.workflowId) {
235
+ throw new Error('Workflow not started. Call startWorkflow() first.');
236
+ }
237
+ await this.client.abortWorkflow(this.workflowId, reason);
238
+ }
239
+ /**
240
+ * Fail the workflow.
241
+ *
242
+ * Call this when your LangGraph workflow has encountered an unrecoverable error.
243
+ *
244
+ * @param reason - Reason for the failure
245
+ */
246
+ async failWorkflow(reason) {
247
+ if (!this.workflowId) {
248
+ throw new Error('Workflow not started. Call startWorkflow() first.');
249
+ }
250
+ await this.client.failWorkflow(this.workflowId, reason);
251
+ }
252
+ /**
253
+ * Wait for a step to be approved.
254
+ *
255
+ * Poll the workflow status until the step is approved or rejected.
256
+ *
257
+ * @param stepId - Step ID to wait for
258
+ * @param opts - Polling options
259
+ * @returns True if approved, false if rejected
260
+ * @throws Error if approval not received within timeout
261
+ */
262
+ async waitForApproval(stepId, opts) {
263
+ if (!this.workflowId) {
264
+ throw new Error('Workflow not started. Call startWorkflow() first.');
265
+ }
266
+ const pollInterval = opts?.pollInterval ?? 5;
267
+ const timeout = opts?.timeout ?? 300;
268
+ let elapsed = 0;
269
+ while (elapsed < timeout) {
270
+ const status = await this.client.getWorkflow(this.workflowId);
271
+ // Find the step
272
+ if (status.steps) {
273
+ for (const step of status.steps) {
274
+ if (step.step_id === stepId) {
275
+ if (step.approval_status) {
276
+ if (step.approval_status === 'approved') {
277
+ return true;
278
+ }
279
+ if (step.approval_status === 'rejected') {
280
+ return false;
281
+ }
282
+ }
283
+ break;
284
+ }
285
+ }
286
+ }
287
+ await new Promise(resolve => setTimeout(resolve, pollInterval * 1000));
288
+ elapsed += pollInterval;
289
+ }
290
+ throw new AxonFlowTimeoutError(timeout * 1000);
291
+ }
292
+ /**
293
+ * Return an async MCP tool interceptor for use with MultiServerMCPClient.
294
+ *
295
+ * The interceptor enforces AxonFlow input and output policies around every
296
+ * MCP tool call.
297
+ *
298
+ * @example
299
+ * ```typescript
300
+ * const mcp = new MultiServerMCPClient(
301
+ * { 'my-server': { url: '...', transport: 'http' } },
302
+ * { toolInterceptors: [adapter.mcpToolInterceptor()] },
303
+ * );
304
+ * ```
305
+ *
306
+ * @param opts - Optional interceptor options
307
+ * @returns An async callable (request, handler) => result
308
+ */
309
+ mcpToolInterceptor(opts) {
310
+ const operation = opts?.operation ?? 'execute';
311
+ const defaultConnectorType = (request) => {
312
+ return `${request.serverName}.${request.name}`;
313
+ };
314
+ const resolveConnectorType = opts?.connectorTypeFn ?? defaultConnectorType;
315
+ return async (request, handler) => {
316
+ const connectorType = resolveConnectorType(request);
317
+ let argsStr = '{}';
318
+ if (request.args) {
319
+ try {
320
+ argsStr = JSON.stringify(request.args);
321
+ }
322
+ catch {
323
+ argsStr = String(request.args);
324
+ }
325
+ }
326
+ const statement = `${connectorType}(${argsStr})`;
327
+ const preCheck = await this.client.mcpCheckInput({
328
+ connectorType,
329
+ statement,
330
+ operation,
331
+ parameters: request.args,
332
+ });
333
+ if (!preCheck.allowed) {
334
+ throw new PolicyViolationError(preCheck.block_reason || 'Tool call blocked by policy');
335
+ }
336
+ const result = await handler(request);
337
+ let resultStr;
338
+ try {
339
+ resultStr = JSON.stringify(result);
340
+ }
341
+ catch {
342
+ resultStr = String(result);
343
+ }
344
+ const outputCheck = await this.client.mcpCheckOutput({
345
+ connectorType,
346
+ message: resultStr,
347
+ });
348
+ if (!outputCheck.allowed) {
349
+ throw new PolicyViolationError(outputCheck.block_reason || 'Tool result blocked by policy');
350
+ }
351
+ if (outputCheck.redacted_data !== undefined && outputCheck.redacted_data !== null) {
352
+ return outputCheck.redacted_data;
353
+ }
354
+ return result;
355
+ };
356
+ }
357
+ }
358
+ //# sourceMappingURL=langgraph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"langgraph.js","sourceRoot":"","sources":["../../../src/adapters/langgraph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,YAAY,IAAI,oBAAoB,GACrC,MAAM,WAAW,CAAC;AAGnB;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,aAAa;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,CAAC,CAAC;IAC9D,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,6BAA8B,SAAQ,aAAa;IAK9D,YAAY,OAAe,EAAE,MAAe,EAAE,WAAoB,EAAE,MAAe;QACjF,KAAK,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI,GAAG,+BAA+B,CAAC;QAC5C,I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