@loopman/langchain-sdk 1.17.2 → 1.17.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/README.md CHANGED
@@ -342,6 +342,33 @@ const workflow = new StateGraph(LoopmanGraphState)
342
342
  const app = workflow.compile({ checkpointer: new MemorySaver() });
343
343
  ```
344
344
 
345
+ #### Task Options
346
+
347
+ Pass task-specific options when invoking the validation node:
348
+
349
+ ```typescript
350
+ const validationNode = createLoopmanValidationNode({
351
+ apiKey: process.env.LOOPMAN_API_KEY!,
352
+ workflowId: "my-workflow",
353
+ debug: true,
354
+ });
355
+
356
+ workflow.addNode("loopman_validation", (state, config) =>
357
+ validationNode(state, {
358
+ taskTitle: `Approve ${state.currentAction}`,
359
+ taskMessage: `Review action for user ${state.userId}`,
360
+ businessContext: (s) => `Risk: ${s.riskLevel}, Cost: $${s.estimatedCost}`,
361
+ proposedDecision: (s) => `Execute ${s.currentAction} on ${s.targetResource}`,
362
+ })
363
+ );
364
+ ```
365
+
366
+ **Options:**
367
+ - `taskTitle`, `taskMessage` - Custom task information
368
+ - `businessContext`, `proposedDecision`, `decisionReasoning` - Context (string or function)
369
+ - `formatState` - Custom formatter
370
+ - `includeFullState` - Include state (default: `true`)
371
+
345
372
  **šŸ”„ Feedback Loop in Action:**
346
373
 
347
374
  When a human rejects a decision with status `NEEDS_CHANGES`:
@@ -531,15 +558,28 @@ Creates a LangGraph node that loads guidelines and decision history.
531
558
 
532
559
  Creates a LangGraph node that handles human validation.
533
560
 
534
- **Parameters:**
561
+ **Configuration:**
535
562
 
536
- - `config.apiKey` (string, required): Loopman API key
537
- - `config.workflowId` (string, required): Workflow identifier
538
- - `config.timeout` (number, optional): Decision timeout in ms (default: 5 minutes)
539
- - `config.pollingInterval` (number, optional): Polling interval in ms (default: 5 seconds)
540
- - `config.debug` (boolean, optional): Enable debug logging
563
+ - `apiKey` (string, required): Loopman API key
564
+ - `workflowId` (string, required): Workflow identifier
565
+ - `executionId` (string, optional): Execution ID (auto-generated)
566
+ - `category` (string, optional): Category filter for guidelines
567
+ - `timeout` (number, optional): Timeout in ms (default: 5 min)
568
+ - `pollingInterval` (number, optional): Polling interval (default: 5 sec)
569
+ - `debug` (boolean, optional): Enable debug logging
541
570
 
542
- **Returns:** LangGraph node function
571
+ **Task Options (passed at invocation):**
572
+
573
+ - `taskTitle` (string): Task title
574
+ - `taskMessage` (string): Task description
575
+ - `businessContext` (string | function): Business context
576
+ - `proposedDecision` (string | function): Proposed decision
577
+ - `decisionReasoning` (string | function): Decision reasoning
578
+ - `includeFullState` (boolean): Include state (default: true)
579
+ - `formatState` (function): Custom state formatter
580
+ - `extractToolCall` (function): Custom tool call extractor
581
+
582
+ **Returns:** Node function `(state, options?) => Promise<StateUpdate>`
543
583
 
544
584
  #### `createLoopmanConditionalEdge(config)`
545
585
 
@@ -7,7 +7,7 @@
7
7
  export { LoopmanGraphState } from "./types";
8
8
  export type { LoopmanGuideline, LoopmanDecision } from "./types";
9
9
  export { createLoopmanValidationNode } from "./loopman-validation-node";
10
- export type { LoopmanValidationNodeConfig } from "./loopman-validation-node";
10
+ export type { LoopmanValidationNodeConfig, LoopmanValidationTaskOptions, } from "./loopman-validation-node";
11
11
  export { createLoopmanConditionalEdge } from "./loopman-conditional-edge";
12
12
  export { createLoopmanContextNode } from "./loopman-context-node";
13
13
  export type { LoopmanContextNodeConfig } from "./loopman-context-node";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/langgraph/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAGjE,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AACxE,YAAY,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAG7E,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAG1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAClE,YAAY,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAGvE,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/langgraph/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAGjE,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AACxE,YAAY,EACV,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAG1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAClE,YAAY,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAGvE,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/langgraph/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,yBAAyB;AACzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG5C,yBAAyB;AACzB,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAGxE,0BAA0B;AAC1B,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAE1E,sBAAsB;AACtB,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAGlE,0BAA0B;AAC1B,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/langgraph/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,yBAAyB;AACzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG5C,yBAAyB;AACzB,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAMxE,0BAA0B;AAC1B,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAE1E,sBAAsB;AACtB,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAGlE,0BAA0B;AAC1B,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,WAAW,CAAC"}
@@ -9,7 +9,7 @@
9
9
  */
10
10
  import { TaskInformation } from "../types";
11
11
  /**
12
- * Configuration for Loopman validation node
12
+ * Configuration for Loopman validation node (service-level config)
13
13
  */
14
14
  export interface LoopmanValidationNodeConfig {
15
15
  /** Loopman API key for authentication */
@@ -26,6 +26,11 @@ export interface LoopmanValidationNodeConfig {
26
26
  pollingInterval?: number;
27
27
  /** Enable debug logging */
28
28
  debug?: boolean;
29
+ }
30
+ /**
31
+ * Task-specific options that can be passed when invoking the validation node
32
+ */
33
+ export interface LoopmanValidationTaskOptions {
29
34
  /** Custom title for the task (default: "Tool validation") */
30
35
  taskTitle?: string;
31
36
  /** Custom message/description to display when creating task */
@@ -76,56 +81,34 @@ export interface LoopmanValidationNodeConfig {
76
81
  * **Decision Context**: You can provide business context, proposed decisions, and
77
82
  * reasoning either as static strings or as functions that extract from the state.
78
83
  *
79
- * @example Basic usage with LoopmanGraphState
84
+ * @example Basic usage
80
85
  * ```typescript
81
86
  * import { createLoopmanValidationNode, LoopmanGraphState } from "loopman-langchain-sdk";
82
87
  *
83
88
  * const loopmanNode = createLoopmanValidationNode({
84
89
  * apiKey: process.env.LOOPMAN_API_KEY!,
85
90
  * workflowId: "my-workflow",
86
- * executionId: `exec-${Date.now()}`,
87
- * timeout: 5 * 60 * 1000,
88
- * pollingInterval: 5000,
89
91
  * debug: true,
90
- * taskTitle: "Email Validation", // Custom title
91
- * taskMessage: "Please review this action" // Custom description
92
92
  * });
93
93
  *
94
- * workflow.addNode("loopman_validation", loopmanNode);
94
+ * workflow.addNode("loopman_validation", (state, config) =>
95
+ * loopmanNode(state, {
96
+ * taskTitle: "Email Validation",
97
+ * taskMessage: "Please review this action",
98
+ * })
99
+ * );
95
100
  * ```
96
101
  *
97
- * @example With decision context (state included by default)
102
+ * @example With dynamic context
98
103
  * ```typescript
99
- * const loopmanNode = createLoopmanValidationNode({
100
- * apiKey: process.env.LOOPMAN_API_KEY!,
101
- * workflowId: "my-workflow",
102
- * businessContext: (state) => `Processing user request: ${state.userQuery}`,
103
- * proposedDecision: (state) => `Execute ${state.currentAction} on ${state.targetResource}`,
104
- * decisionReasoning: (state) => state.reasoning || "No specific reasoning provided",
105
- * });
106
- * ```
107
- *
108
- * @example Disable state inclusion
109
- * ```typescript
110
- * const loopmanNode = createLoopmanValidationNode({
111
- * apiKey: process.env.LOOPMAN_API_KEY!,
112
- * workflowId: "my-workflow",
113
- * includeFullState: false, // Don't include state in task
114
- * });
115
- * ```
116
- *
117
- * @example With custom state formatter (state included by default)
118
- * ```typescript
119
- * const loopmanNode = createLoopmanValidationNode({
120
- * apiKey: process.env.LOOPMAN_API_KEY!,
121
- * workflowId: "my-workflow",
122
- * formatState: (state) => [
123
- * { type: "text", label: "User", value: state.userId },
124
- * { type: "text", label: "Action", value: state.action },
125
- * { type: "bulletPoints", label: "Parameters", value: Object.keys(state.params) },
126
- * ],
127
- * });
104
+ * workflow.addNode("loopman_validation", (state, config) =>
105
+ * loopmanNode(state, {
106
+ * businessContext: (s) => `Processing user request: ${s.userQuery}`,
107
+ * proposedDecision: (s) => `Execute ${s.currentAction} on ${s.targetResource}`,
108
+ * includeFullState: state.riskLevel === "HIGH",
109
+ * })
110
+ * );
128
111
  * ```
129
112
  */
130
- export declare function createLoopmanValidationNode(config: LoopmanValidationNodeConfig): (state: any) => Promise<any>;
113
+ export declare function createLoopmanValidationNode(config: LoopmanValidationNodeConfig): (state: any, options?: LoopmanValidationTaskOptions) => Promise<any>;
131
114
  //# sourceMappingURL=loopman-validation-node.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"loopman-validation-node.d.ts","sourceRoot":"","sources":["../../src/langgraph/loopman-validation-node.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,0BAA0B;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4DAA4D;IAC5D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wDAAwD;IACxD,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,KAAK;QACrC,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,GAAG,CAAC;QACV,EAAE,EAAE,MAAM,CAAC;KACZ,GAAG,IAAI,CAAC;IACT,kFAAkF;IAClF,eAAe,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAC,CAAC;IACpD,mFAAmF;IACnF,gBAAgB,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAC,CAAC;IACrD,oFAAoF;IACpF,iBAAiB,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAC,CAAC;IACtD,wEAAwE;IACxE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,qGAAqG;IACrG,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,eAAe,EAAE,CAAC;CACjD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,2BAA2B,IAerB,OAAO,GAAG,kBAsMzB"}
1
+ {"version":3,"file":"loopman-validation-node.d.ts","sourceRoot":"","sources":["../../src/langgraph/loopman-validation-node.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,0BAA0B;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4DAA4D;IAC5D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wDAAwD;IACxD,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,KAAK;QACrC,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,GAAG,CAAC;QACV,EAAE,EAAE,MAAM,CAAC;KACZ,GAAG,IAAI,CAAC;IACT,kFAAkF;IAClF,eAAe,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAC,CAAC;IACpD,mFAAmF;IACnF,gBAAgB,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAC,CAAC;IACrD,oFAAoF;IACpF,iBAAiB,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAC,CAAC;IACtD,wEAAwE;IACxE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,qGAAqG;IACrG,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,eAAe,EAAE,CAAC;CACjD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,2BAA2B,IAerB,OAAO,GAAG,EAAE,UAAS,4BAAiC,kBAsMrE"}
@@ -39,55 +39,33 @@ import { createLoopmanContextNode } from "./loopman-context-node.js";
39
39
  * **Decision Context**: You can provide business context, proposed decisions, and
40
40
  * reasoning either as static strings or as functions that extract from the state.
41
41
  *
42
- * @example Basic usage with LoopmanGraphState
42
+ * @example Basic usage
43
43
  * ```typescript
44
44
  * import { createLoopmanValidationNode, LoopmanGraphState } from "loopman-langchain-sdk";
45
45
  *
46
46
  * const loopmanNode = createLoopmanValidationNode({
47
47
  * apiKey: process.env.LOOPMAN_API_KEY!,
48
48
  * workflowId: "my-workflow",
49
- * executionId: `exec-${Date.now()}`,
50
- * timeout: 5 * 60 * 1000,
51
- * pollingInterval: 5000,
52
49
  * debug: true,
53
- * taskTitle: "Email Validation", // Custom title
54
- * taskMessage: "Please review this action" // Custom description
55
50
  * });
56
51
  *
57
- * workflow.addNode("loopman_validation", loopmanNode);
52
+ * workflow.addNode("loopman_validation", (state, config) =>
53
+ * loopmanNode(state, {
54
+ * taskTitle: "Email Validation",
55
+ * taskMessage: "Please review this action",
56
+ * })
57
+ * );
58
58
  * ```
59
59
  *
60
- * @example With decision context (state included by default)
60
+ * @example With dynamic context
61
61
  * ```typescript
62
- * const loopmanNode = createLoopmanValidationNode({
63
- * apiKey: process.env.LOOPMAN_API_KEY!,
64
- * workflowId: "my-workflow",
65
- * businessContext: (state) => `Processing user request: ${state.userQuery}`,
66
- * proposedDecision: (state) => `Execute ${state.currentAction} on ${state.targetResource}`,
67
- * decisionReasoning: (state) => state.reasoning || "No specific reasoning provided",
68
- * });
69
- * ```
70
- *
71
- * @example Disable state inclusion
72
- * ```typescript
73
- * const loopmanNode = createLoopmanValidationNode({
74
- * apiKey: process.env.LOOPMAN_API_KEY!,
75
- * workflowId: "my-workflow",
76
- * includeFullState: false, // Don't include state in task
77
- * });
78
- * ```
79
- *
80
- * @example With custom state formatter (state included by default)
81
- * ```typescript
82
- * const loopmanNode = createLoopmanValidationNode({
83
- * apiKey: process.env.LOOPMAN_API_KEY!,
84
- * workflowId: "my-workflow",
85
- * formatState: (state) => [
86
- * { type: "text", label: "User", value: state.userId },
87
- * { type: "text", label: "Action", value: state.action },
88
- * { type: "bulletPoints", label: "Parameters", value: Object.keys(state.params) },
89
- * ],
90
- * });
62
+ * workflow.addNode("loopman_validation", (state, config) =>
63
+ * loopmanNode(state, {
64
+ * businessContext: (s) => `Processing user request: ${s.userQuery}`,
65
+ * proposedDecision: (s) => `Execute ${s.currentAction} on ${s.targetResource}`,
66
+ * includeFullState: state.riskLevel === "HIGH",
67
+ * })
68
+ * );
91
69
  * ```
92
70
  */
93
71
  export function createLoopmanValidationNode(config) {
@@ -102,14 +80,14 @@ export function createLoopmanValidationNode(config) {
102
80
  pollingInterval: config.pollingInterval,
103
81
  debug: config.debug,
104
82
  });
105
- return async (state) => {
83
+ return async (state, options = {}) => {
106
84
  const { messages, loopmanTaskId } = state;
107
85
  const { debug } = config;
108
86
  const logger = loopmanService.logger;
109
87
  // Extract tool call from last message (optional - can be used without tool calls)
110
88
  const lastMessage = messages[messages.length - 1];
111
- const toolCall = config.extractToolCall
112
- ? config.extractToolCall(messages)
89
+ const toolCall = options.extractToolCall
90
+ ? options.extractToolCall(messages)
113
91
  : extractDefaultToolCall(lastMessage);
114
92
  // Step 1: Check if we're retrying an existing task (NEEDS_CHANGES scenario)
115
93
  const isRetry = !!loopmanTaskId;
@@ -132,28 +110,28 @@ export function createLoopmanValidationNode(config) {
132
110
  logger.debug("[LoopmanNode] No tool call found, creating generic validation task");
133
111
  }
134
112
  // Step 2: Create or update task in Loopman
135
- const taskTitle = config.taskTitle ||
113
+ const taskTitle = options.taskTitle ||
136
114
  (toolCall ? `Validation: ${toolCall.name}` : "Human validation required");
137
- const taskMessage = config.taskMessage ||
115
+ const taskMessage = options.taskMessage ||
138
116
  (toolCall
139
117
  ? `Validation required for tool: ${toolCall.name}`
140
118
  : "Human validation required for this decision");
141
119
  // Extract businessContext, proposedDecision, and decisionReasoning
142
- const businessContext = typeof config.businessContext === "function"
143
- ? config.businessContext(state)
144
- : config.businessContext;
145
- const proposedDecision = typeof config.proposedDecision === "function"
146
- ? config.proposedDecision(state)
147
- : config.proposedDecision;
148
- const decisionReasoning = typeof config.decisionReasoning === "function"
149
- ? config.decisionReasoning(state)
150
- : config.decisionReasoning;
120
+ const businessContext = typeof options.businessContext === "function"
121
+ ? options.businessContext(state)
122
+ : options.businessContext;
123
+ const proposedDecision = typeof options.proposedDecision === "function"
124
+ ? options.proposedDecision(state)
125
+ : options.proposedDecision;
126
+ const decisionReasoning = typeof options.decisionReasoning === "function"
127
+ ? options.decisionReasoning(state)
128
+ : options.decisionReasoning;
151
129
  // Prepare additional information from state (enabled by default)
152
130
  let additionalInformation;
153
- const shouldIncludeState = config.includeFullState !== false; // Default to true
131
+ const shouldIncludeState = options.includeFullState !== false; // Default to true
154
132
  if (shouldIncludeState) {
155
- if (config.formatState) {
156
- additionalInformation = config.formatState(state);
133
+ if (options.formatState) {
134
+ additionalInformation = options.formatState(state);
157
135
  }
158
136
  else {
159
137
  additionalInformation = convertStateToInformation(state);
@@ -1 +1 @@
1
- {"version":3,"file":"loopman-validation-node.js","sourceRoot":"","sources":["../../src/langgraph/loopman-validation-node.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AA0ClE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EG;AACH,MAAM,UAAU,2BAA2B,CACzC,MAAmC;IAEnC,8DAA8D;IAC9D,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,QAAQ,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;IAE/D,iEAAiE;IACjE,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC;QACxC,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,WAAW,EAAE,WAAW;QACxB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,eAAe,EAAE,MAAM,CAAC,eAAe;QACvC,KAAK,EAAE,M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ACvB,UAAmB;IAEnB,MAAM,YAAY,GAAG,CAAC,OAAe,EAAE,EAAE;QACvC,IAAI,UAAU,EAAE,CAAC;YACf,OAAO,IAAI,WAAW,CAAC;gBACrB,OAAO;gBACP,YAAY,EAAE,UAAU;aACzB,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAI,YAAY,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IACvC,CAAC,CAAC;IAEF,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,UAAU;YACb,OAAO;gBACL,YAAY,CACV,QAAQ;oBACN,CAAC,CAAC,0CAA0C,QAAQ,GAAG;oBACvD,CAAC,CAAC,qDAAqD,CAC1D;aACF,CAAC;QAEJ,KAAK,UAAU;YACb,OAAO;gBACL,YAAY,CACV,QAAQ;oBACN,CAAC,CAAC,wCAAwC,QAAQ,GAAG;oBACrD,CAAC,CAAC,wDAAwD,CAC7D;aACF,CAAC;QAEJ,KAAK,eAAe;YAClB,OAAO;gBACL,YAAY,CACV,QAAQ;oBACN,CAAC,CAAC,yCAAyC,QAAQ,GAAG;oBACtD,CAAC,CAAC,mEAAmE,CACxE;aACF,CAAC;QAEJ,KAAK,SAAS;YACZ,OAAO;gBACL,YAAY,CACV,0DAA0D,CAC3D;aACF,CAAC;QAEJ,KAAK,SAAS,CAAC;QACf,KAAK,OAAO,CAAC;QACb;YACE,OAAO,CAAC,YAAY,CAAC,sBAAsB,MAAM,EAAE,CAAC,CAAC,CAAC;IAC1D,CAAC;AACH,CAAC"}
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "langgraph-hello-world": {
3
3
  "index.ts": "import { HumanMessage, ToolMessage } from \"@langchain/core/messages\";\nimport { END, MemorySaver, START, StateGraph } from \"@langchain/langgraph\";\nimport { ChatOpenAI } from \"@langchain/openai\";\nimport { config } from \"dotenv\";\nimport { tool } from \"langchain\";\nimport * as z from \"zod\";\n\nimport {\n LoopmanGraphState,\n createLoopmanConditionalEdge,\n createLoopmanContextNode,\n createLoopmanValidationNode,\n enrichSystemPrompt,\n} from \"@loopman/langchain-sdk\";\n\nconfig();\n\n// Define your tools\nconst sayHello = tool(\n ({ name }) => {\n console.log(`Hello, ${name}!`);\n return `Hello, ${name}! Welcome to Loopman.`;\n },\n {\n name: \"say_hello\",\n description: \"Say hello to someone\",\n schema: z.object({\n name: z.string().describe(\"The name of the person to greet\"),\n }),\n }\n);\n\n// Agent node with context enrichment\nasync function agentNode(state: typeof LoopmanGraphState.State) {\n const { messages, guidelines, decisionContext } = state;\n\n // Enrich system prompt with guidelines and decision history\n const systemPrompt = enrichSystemPrompt(\n \"You are a helpful assistant that greets people ....\",\n { guidelines, decisionContext },\n { maxDecisions: 3 }\n );\n\n const model = new ChatOpenAI({ model: \"gpt-4o-mini\" });\n const modelWithTools = model.bindTools([sayHello]);\n\n const messagesWithContext =\n (guidelines && guidelines.length > 0) ||\n (decisionContext && decisionContext.length > 0)\n ? [{ role: \"system\", content: systemPrompt }, ...messages]\n : messages;\n\n const response = await modelWithTools.invoke(messagesWithContext);\n\n return {\n messages: [response],\n };\n}\n\n// Tool execution node\nasync function toolNode(state: typeof LoopmanGraphState.State) {\n const { messages } = state;\n const lastMessage = messages[messages.length - 1];\n\n if (!lastMessage.tool_calls || lastMessage.tool_calls.length === 0) {\n return {};\n }\n\n const toolCall = lastMessage.tool_calls[0];\n const result = await sayHello.invoke(toolCall.args);\n\n return {\n messages: [\n new ToolMessage({\n content: String(result),\n tool_call_id: toolCall.id,\n }),\n ],\n };\n}\n\n// Build the graph with context loading\nconst workflow = new StateGraph(LoopmanGraphState)\n .addNode(\n \"load_context\",\n createLoopmanContextNode({\n apiKey: process.env.LOOPMAN_API_KEY!,\n workflowId: \"hello-world-workflow\",\n category: \"hello-world\",\n debug: true,\n })\n )\n .addNode(\"agent\", agentNode)\n .addNode(\n \"loopman_validation\",\n createLoopmanValidationNode({\n apiKey: process.env.LOOPMAN_API_KEY!,\n workflowId: \"hello-world-workflow\",\n debug: true,\n })\n )\n .addNode(\"tools\", toolNode)\n .addEdge(START, \"load_context\")\n .addEdge(\"load_context\", \"agent\")\n .addEdge(\"agent\", \"loopman_validation\")\n .addConditionalEdges(\n \"loopman_validation\",\n createLoopmanConditionalEdge({ debug: true }),\n {\n execute: \"tools\",\n rejected: END,\n retry: \"agent\",\n timeout: END,\n error: END,\n }\n )\n .addEdge(\"tools\", END);\n\n// Compile and run\nconst checkpointer = new MemorySaver();\nconst app = workflow.compile({ checkpointer });\n\nasync function main() {\n const config = { configurable: { thread_id: \"hello-world-thread\" } };\n const inputs = {\n messages: [new HumanMessage(\"Say hello to Alice\")],\n };\n\n console.log(\"Starting LangGraph workflow with context enrichment...\");\n\n for await (const output of await app.stream(inputs, config)) {\n const nodeName = Object.keys(output)[0];\n console.log(`Step: ${nodeName}`);\n }\n\n const finalState = await app.getState(config);\n console.log(\"Final status:\", finalState.values.loopmanTaskStatus);\n console.log(\"Guidelines loaded:\", finalState.values.guidelines?.length || 0);\n console.log(\n \"Decision context loaded:\",\n finalState.values.decisionContext?.length || 0\n );\n console.log(\"Workflow completed!\");\n}\n\nmain().catch(console.error);\n",
4
- "package.json": "{\n \"name\": \"loopman-langgraph-hello-world\",\n \"version\": \"1.0.0\",\n \"description\": \"Loopman LangGraph Hello World Example\",\n \"main\": \"index.ts\",\n \"type\": \"module\",\n \"scripts\": {\n \"start\": \"tsx index.ts\",\n \"dev\": \"tsx index.ts\",\n \"build\": \"tsc\",\n \"run\": \"node dist/index.js\"\n },\n \"dependencies\": {\n \"@langchain/core\": \"^1.0.2\",\n \"@langchain/langgraph\": \"^1.0.7\",\n \"@langchain/openai\": \"^1.0.0\",\n \"@loopman/langchain-sdk\": \"^1.17.2\",\n \"dotenv\": \"^17.2.3\",\n \"langchain\": \"^1.0.2\",\n \"tsx\": \"^4.20.6\",\n \"typescript\": \"^5.9.3\",\n \"zod\": \"^3.25.76\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^24.9.2\"\n }\n}\n",
4
+ "package.json": "{\n \"name\": \"loopman-langgraph-hello-world\",\n \"version\": \"1.0.0\",\n \"description\": \"Loopman LangGraph Hello World Example\",\n \"main\": \"index.ts\",\n \"type\": \"module\",\n \"scripts\": {\n \"start\": \"tsx index.ts\",\n \"dev\": \"tsx index.ts\",\n \"build\": \"tsc\",\n \"run\": \"node dist/index.js\"\n },\n \"dependencies\": {\n \"@langchain/core\": \"^1.0.2\",\n \"@langchain/langgraph\": \"^1.0.7\",\n \"@langchain/openai\": \"^1.0.0\",\n \"@loopman/langchain-sdk\": \"^1.17.3\",\n \"dotenv\": \"^17.2.3\",\n \"langchain\": \"^1.0.2\",\n \"tsx\": \"^4.20.6\",\n \"typescript\": \"^5.9.3\",\n \"zod\": \"^3.25.76\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^24.9.2\"\n }\n}\n",
5
5
  "tsconfig.json": "{\n \"compilerOptions\": {\n \"target\": \"ES2022\",\n \"module\": \"ES2022\",\n \"lib\": [\"ES2022\"],\n \"moduleResolution\": \"bundler\",\n \"resolveJsonModule\": true,\n \"allowJs\": true,\n \"outDir\": \"./dist\",\n \"rootDir\": \"./\",\n \"strict\": true,\n \"esModuleInterop\": true,\n \"skipLibCheck\": true,\n \"forceConsistentCasingInFileNames\": true,\n \"declaration\": true,\n \"declarationMap\": true,\n \"sourceMap\": true,\n \"types\": [\"node\"]\n },\n \"include\": [\"**/*.ts\"],\n \"exclude\": [\"node_modules\", \"dist\"]\n}\n",
6
6
  "README.md": "# Loopman LangGraph Hello World\n\nThis project demonstrates how to integrate Loopman with LangGraph using Context Enrichment / Feedback Loop mode.\n\n## About LangGraph\n\nLangGraph is LangChain's official framework for building stateful, multi-actor applications with LLMs. It provides:\n\n- **Stateful workflows**: Explicit state management across nodes\n- **Conditional routing**: Dynamic edges based on state\n- **Streaming support**: Real-time updates during execution\n- **Visual debugging**: Graph visualization and inspection\n\n## Setup\n\n1. Install dependencies:\n```bash\nnpm install\n```\n\n2. Copy .env.example to .env and configure your keys:\n```bash\ncp .env.example .env\n```\n\nEdit the .env file and replace the placeholders with your actual values:\n- `OPENAI_API_KEY`: Your OpenAI API key\n- `LOOPMAN_API_KEY`: Your Loopman API key\n- `LOOPMAN_WORKFLOW_ID`: Your workflow ID from Loopman\n\n3. Run the example:\n```bash\nnpm start\n```\n\n## Graph Architecture\n\nThe workflow follows this pattern:\n\n```\nSTART\n ↓\nload_context (load guidelines and decision history)\n ↓\nagent (LLM decides action)\n ↓\nloopman_validation (create task + poll)\n ↓\n[conditional edge based on status]\n ↓\nā”œā”€ā†’ tools (APPROVED: execute)\nā”œā”€ā†’ agent (NEEDS_CHANGES: retry)\n└─→ END (REJECTED/TIMEOUT/ERROR: end)\n ↓\nEND\n```\n\n## Key Features\n\n- **Context Enrichment**: Loads validation guidelines and historical decisions\n- **Prompt Enhancement**: Automatically enriches system prompts with context\n- **Learning from History**: Agent learns from past human decisions\n- **Category Filtering**: Guidelines filtered by category for relevance\n- **Feedback Loop**: Human feedback is stored and used to improve future decisions\n\n## Learn More\n\n- [LangGraph Documentation](https://js.langchain.com/docs/langgraph/)\n- [Loopman LangGraph Integration Guide](https://github.com/loopman/loopman-langchain-sdk/blob/main/docs/LANGGRAPH_INTEGRATION.md)\n- [Loopman Documentation](https://loopman.dev/docs)\n\n"
7
7
  },
8
8
  "langchain-tool-validation": {
9
9
  "index.ts": "import { MemorySaver } from \"@langchain/langgraph\";\nimport { config } from \"dotenv\";\nimport { createAgent, tool } from \"langchain\";\nimport * as z from \"zod\";\nimport { loopmanMiddleware } from \"@loopman/langchain-sdk\";\n\n// Load environment variables\nconfig();\n\n// Simple hello world tool\nconst sayHello = tool(\n ({ name }) => {\n console.log(`Hello, ${name}!`);\n return `Hello, ${name}! Welcome to Loopman.`;\n },\n {\n name: \"say_hello\",\n description: \"Say hello to someone\",\n schema: z.object({\n name: z.string().describe(\"The name of the person to greet\"),\n }),\n }\n);\n\n// Create agent with Loopman middleware\nconst checkpointer = new MemorySaver();\n\nconst agent = createAgent({\n model: \"openai:gpt-4o-mini\",\n systemPrompt: \"You are a helpful assistant that greets people.\",\n tools: [sayHello],\n middleware: [\n loopmanMiddleware({\n apiKey: process.env.LOOPMAN_API_KEY!,\n workflowId: process.env.LOOPMAN_WORKFLOW_ID!,\n interruptOn: {\n say_hello: true, // Requires human validation\n },\n debug: true,\n }),\n ],\n checkpointer,\n});\n\n// Run the agent\nasync function main() {\n const config = { configurable: { thread_id: \"hello-world-thread\" } };\n\n const result = await agent.invoke(\n {\n messages: [\n {\n role: \"user\",\n content: \"Say hello to Alice\",\n },\n ],\n },\n config\n );\n\n console.log(\"Agent response:\", result.messages[result.messages.length - 1].content);\n}\n\nmain().catch(console.error);\n\n",
10
- "package.json": "{\n \"name\": \"loopman-langchain-tool-validation\",\n \"version\": \"1.0.0\",\n \"description\": \"Loopman LangChain Tool Validation Example\",\n \"main\": \"index.ts\",\n \"type\": \"module\",\n \"scripts\": {\n \"start\": \"tsx index.ts\",\n \"dev\": \"tsx index.ts\",\n \"build\": \"tsc\",\n \"run\": \"node dist/index.js\"\n },\n \"dependencies\": {\n \"@langchain/core\": \"^1.0.2\",\n \"@langchain/mcp-adapters\": \"^1.0.0\",\n \"@langchain/langgraph\": \"^1.0.7\",\n \"@langchain/openai\": \"^1.0.0\",\n \"@loopman/langchain-sdk\": \"^1.17.2\",\n \"dotenv\": \"^17.2.3\",\n \"langchain\": \"^1.0.2\",\n \"tsx\": \"^4.20.6\",\n \"typescript\": \"^5.9.3\",\n \"zod\": \"^3.25.76\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^24.9.2\"\n }\n}\n",
10
+ "package.json": "{\n \"name\": \"loopman-langchain-tool-validation\",\n \"version\": \"1.0.0\",\n \"description\": \"Loopman LangChain Tool Validation Example\",\n \"main\": \"index.ts\",\n \"type\": \"module\",\n \"scripts\": {\n \"start\": \"tsx index.ts\",\n \"dev\": \"tsx index.ts\",\n \"build\": \"tsc\",\n \"run\": \"node dist/index.js\"\n },\n \"dependencies\": {\n \"@langchain/core\": \"^1.0.2\",\n \"@langchain/mcp-adapters\": \"^1.0.0\",\n \"@langchain/langgraph\": \"^1.0.7\",\n \"@langchain/openai\": \"^1.0.0\",\n \"@loopman/langchain-sdk\": \"^1.17.3\",\n \"dotenv\": \"^17.2.3\",\n \"langchain\": \"^1.0.2\",\n \"tsx\": \"^4.20.6\",\n \"typescript\": \"^5.9.3\",\n \"zod\": \"^3.25.76\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^24.9.2\"\n }\n}\n",
11
11
  "tsconfig.json": "{\n \"compilerOptions\": {\n \"target\": \"ES2022\",\n \"module\": \"ES2022\",\n \"lib\": [\"ES2022\"],\n \"moduleResolution\": \"bundler\",\n \"resolveJsonModule\": true,\n \"allowJs\": true,\n \"outDir\": \"./dist\",\n \"rootDir\": \"./\",\n \"strict\": true,\n \"esModuleInterop\": true,\n \"skipLibCheck\": true,\n \"forceConsistentCasingInFileNames\": true,\n \"declaration\": true,\n \"declarationMap\": true,\n \"sourceMap\": true\n },\n \"include\": [\"**/*.ts\"],\n \"exclude\": [\"node_modules\", \"dist\"]\n}\n\n",
12
12
  "README.md": "# Loopman LangChain - Tool Validation Mode\n\nThis project demonstrates how to integrate Loopman with LangChain using **Tool Validation** mode.\n\n## About Tool Validation Mode\n\nIn this mode, Loopman middleware intercepts specific tool calls and requires human validation before execution. This is useful when:\n- Certain actions need human approval (e.g., sending emails, making payments)\n- You want to validate AI decisions before they affect real systems\n- Compliance requires human oversight for specific operations\n\n## Setup\n\n1. Install dependencies:\n```bash\nnpm install\n```\n\n2. Copy .env.example to .env and configure your keys:\n```bash\ncp .env.example .env\n```\n\nEdit the .env file and replace the placeholders with your actual values:\n- `OPENAI_API_KEY`: Your OpenAI API key\n- `LOOPMAN_API_KEY`: Your Loopman API key\n- `LOOPMAN_WORKFLOW_ID`: Your workflow ID from Loopman\n\n3. Run the example:\n```bash\nnpm start\n```\n\n## How It Works\n\n### 1. Define Tools\n\n```typescript\nconst sayHello = tool(\n ({ name }) => {\n console.log(`Hello, ${name}!`);\n return `Hello, ${name}! Welcome to Loopman.`;\n },\n {\n name: \"say_hello\",\n description: \"Say hello to someone\",\n schema: z.object({\n name: z.string().describe(\"The name of the person to greet\"),\n }),\n }\n);\n```\n\n### 2. Add Loopman Middleware\n\n```typescript\nconst agent = createAgent({\n model: \"openai:gpt-4o-mini\",\n tools: [sayHello],\n middleware: [\n loopmanMiddleware({\n apiKey: process.env.LOOPMAN_API_KEY!,\n workflowId: process.env.LOOPMAN_WORKFLOW_ID!,\n interruptOn: {\n say_hello: true, // Requires human validation\n },\n debug: true,\n }),\n ],\n checkpointer,\n});\n```\n\n### 3. Run the Agent\n\n```typescript\nconst result = await agent.invoke(\n {\n messages: [{ role: \"user\", content: \"Say hello to Alice\" }],\n },\n config\n);\n```\n\n## Key Features\n\n- **Selective Validation**: Only specified tools require approval\n- **Automatic Interception**: Middleware handles validation workflow\n- **Stateful**: Uses checkpointer to maintain conversation state\n- **Debug Mode**: Verbose logging for development\n\n## Workflow\n\n```\n1. User sends message\n ↓\n2. Agent generates tool call (say_hello)\n ↓\n3. Loopman middleware intercepts\n ↓\n4. Creates validation task\n ↓\n5. Waits for human decision\n ↓\n6. If approved → Execute tool\n If rejected → Return to agent with feedback\n```\n\n## Configuration Options\n\n### interruptOn\n\nSpecify which tools require validation:\n\n```typescript\ninterruptOn: {\n say_hello: true, // Always validate\n send_email: true, // Always validate\n get_weather: false, // Never validate (auto-execute)\n}\n```\n\n### debug\n\nEnable/disable verbose logging:\n\n```typescript\ndebug: true // Show detailed logs\ndebug: false // Production mode\n```\n\n## Learn More\n\n- [Loopman Middleware Documentation](https://github.com/loopman/loopman-langchain-sdk/blob/main/docs/TOOL_VALIDATION_MODE.md)\n- [LangChain Agent Documentation](https://js.langchain.com/docs/how_to/agent_executor)\n- [Loopman Documentation](https://loopman.dev/docs)\n\n"
13
13
  },
14
14
  "langchain-full-review": {
15
15
  "index.ts": "import { config } from \"dotenv\";\nimport { tool } from \"langchain\";\nimport * as z from \"zod\";\nimport { createLoopmanAgent } from \"@loopman/langchain-sdk\";\n\n// Load environment variables\nconfig();\n\n// Simple hello world tool\nconst sayHello = tool(\n ({ name }) => {\n console.log(`Hello, ${name}!`);\n return `Hello, ${name}! Welcome to Loopman.`;\n },\n {\n name: \"say_hello\",\n description: \"Say hello to someone\",\n schema: z.object({\n name: z.string().describe(\"The name of the person to greet\"),\n }),\n }\n);\n\n// Create Loopman agent with full human review process\nconst agent = createLoopmanAgent({\n apiKey: process.env.LOOPMAN_API_KEY!,\n workflowId: process.env.LOOPMAN_WORKFLOW_ID!,\n model: \"openai:gpt-4o-mini\",\n systemPrompt: \"You are a helpful assistant that greets people.\",\n category: \"hello-world\",\n additionalTools: [sayHello],\n requireApprovalForTools: [\"say_hello\"], // Requires validation\n debug: true,\n});\n\n// Run the agent\nasync function main() {\n const result = await agent.processWithHumanValidation({\n input: \"Say hello to Alice\",\n });\n\n console.log(\"Agent response:\", result.response);\n if (result.decision) {\n console.log(\"Decision status:\", result.decision.status);\n if (result.decision.feedback) {\n console.log(\"Human feedback:\", result.decision.feedback);\n }\n }\n\n await agent.disconnect();\n}\n\nmain().catch(console.error);\n\n",
16
- "package.json": "{\n \"name\": \"loopman-langchain-full-review\",\n \"version\": \"1.0.0\",\n \"description\": \"Loopman LangChain Full Human Review Example\",\n \"main\": \"index.ts\",\n \"type\": \"module\",\n \"scripts\": {\n \"start\": \"tsx index.ts\",\n \"dev\": \"tsx index.ts\",\n \"build\": \"tsc\",\n \"run\": \"node dist/index.js\"\n },\n \"dependencies\": {\n \"@langchain/core\": \"^1.0.2\",\n \"@langchain/mcp-adapters\": \"^1.0.0\",\n \"@langchain/langgraph\": \"^1.0.7\",\n \"@langchain/openai\": \"^1.0.0\",\n \"@loopman/langchain-sdk\": \"^1.17.2\",\n \"dotenv\": \"^17.2.3\",\n \"langchain\": \"^1.0.2\",\n \"tsx\": \"^4.20.6\",\n \"typescript\": \"^5.9.3\",\n \"zod\": \"^3.25.76\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^24.9.2\"\n }\n}\n",
16
+ "package.json": "{\n \"name\": \"loopman-langchain-full-review\",\n \"version\": \"1.0.0\",\n \"description\": \"Loopman LangChain Full Human Review Example\",\n \"main\": \"index.ts\",\n \"type\": \"module\",\n \"scripts\": {\n \"start\": \"tsx index.ts\",\n \"dev\": \"tsx index.ts\",\n \"build\": \"tsc\",\n \"run\": \"node dist/index.js\"\n },\n \"dependencies\": {\n \"@langchain/core\": \"^1.0.2\",\n \"@langchain/mcp-adapters\": \"^1.0.0\",\n \"@langchain/langgraph\": \"^1.0.7\",\n \"@langchain/openai\": \"^1.0.0\",\n \"@loopman/langchain-sdk\": \"^1.17.3\",\n \"dotenv\": \"^17.2.3\",\n \"langchain\": \"^1.0.2\",\n \"tsx\": \"^4.20.6\",\n \"typescript\": \"^5.9.3\",\n \"zod\": \"^3.25.76\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^24.9.2\"\n }\n}\n",
17
17
  "tsconfig.json": "{\n \"compilerOptions\": {\n \"target\": \"ES2022\",\n \"module\": \"ES2022\",\n \"lib\": [\"ES2022\"],\n \"moduleResolution\": \"bundler\",\n \"resolveJsonModule\": true,\n \"allowJs\": true,\n \"outDir\": \"./dist\",\n \"rootDir\": \"./\",\n \"strict\": true,\n \"esModuleInterop\": true,\n \"skipLibCheck\": true,\n \"forceConsistentCasingInFileNames\": true,\n \"declaration\": true,\n \"declarationMap\": true,\n \"sourceMap\": true\n },\n \"include\": [\"**/*.ts\"],\n \"exclude\": [\"node_modules\", \"dist\"]\n}\n\n",
18
18
  "README.md": "# Loopman LangChain - Full Human Review Mode\n\nThis project demonstrates how to integrate Loopman with LangChain using **Full Human Review Process** mode.\n\n## About Full Human Review Mode\n\nIn this mode, the Loopman Agent handles the entire workflow including:\n- Creating validation tasks\n- Waiting for human approval\n- Handling feedback and retries\n- Managing the complete lifecycle\n\nThis is useful when:\n- You want a complete HITL (Human-In-The-Loop) solution\n- The agent should wait for human decisions before proceeding\n- You need full control over the validation workflow\n\n## Setup\n\n1. Install dependencies:\n```bash\nnpm install\n```\n\n2. Copy .env.example to .env and configure your keys:\n```bash\ncp .env.example .env\n```\n\nEdit the .env file and replace the placeholders with your actual values:\n- `OPENAI_API_KEY`: Your OpenAI API key\n- `LOOPMAN_API_KEY`: Your Loopman API key\n- `LOOPMAN_WORKFLOW_ID`: Your workflow ID from Loopman\n\n3. Run the example:\n```bash\nnpm start\n```\n\n## How It Works\n\n### 1. Define Tools\n\n```typescript\nconst sayHello = tool(\n ({ name }) => {\n console.log(`Hello, ${name}!`);\n return `Hello, ${name}! Welcome to Loopman.`;\n },\n {\n name: \"say_hello\",\n description: \"Say hello to someone\",\n schema: z.object({\n name: z.string().describe(\"The name of the person to greet\"),\n }),\n }\n);\n```\n\n### 2. Create Loopman Agent\n\n```typescript\nconst agent = createLoopmanAgent({\n apiKey: process.env.LOOPMAN_API_KEY!,\n workflowId: process.env.LOOPMAN_WORKFLOW_ID!,\n model: \"openai:gpt-4o-mini\",\n systemPrompt: \"You are a helpful assistant that greets people.\",\n category: \"hello-world\",\n additionalTools: [sayHello],\n requireApprovalForTools: [\"say_hello\"],\n debug: true,\n});\n```\n\n### 3. Process with Human Validation\n\n```typescript\nconst result = await agent.processWithHumanValidation({\n input: \"Say hello to Alice\",\n});\n\nconsole.log(\"Agent response:\", result.response);\nif (result.decision) {\n console.log(\"Decision status:\", result.decision.status);\n console.log(\"Human feedback:\", result.decision.feedback);\n}\n```\n\n## Key Features\n\n- **Complete HITL Workflow**: Agent manages the entire validation lifecycle\n- **Automatic Polling**: Waits for human decisions\n- **Feedback Handling**: Processes human feedback and retries if needed\n- **Category Support**: Organize validations by category\n- **Debug Mode**: Verbose logging for development\n\n## Workflow\n\n```\n1. User sends message\n ↓\n2. Agent processes with LLM\n ↓\n3. Agent generates tool call\n ↓\n4. Creates Loopman validation task\n ↓\n5. Polls for human decision\n ↓\n6. If approved → Execute and return result\n If rejected → Process feedback and retry\n If timeout → Handle timeout\n```\n\n## Configuration Options\n\n### requireApprovalForTools\n\nSpecify which tools require validation:\n\n```typescript\nrequireApprovalForTools: [\"say_hello\", \"send_email\"]\n// Only these tools will require human approval\n```\n\n### category\n\nOrganize validations by category:\n\n```typescript\ncategory: \"hello-world\"\n// Helps filter and organize validation tasks\n```\n\n### debug\n\nEnable/disable verbose logging:\n\n```typescript\ndebug: true // Show detailed logs\ndebug: false // Production mode\n```\n\n## Response Structure\n\nThe `processWithHumanValidation` method returns:\n\n```typescript\n{\n response: string, // Final agent response\n decision?: {\n status: \"APPROVED\" | \"REJECTED\" | \"NEEDS_CHANGES\",\n feedback?: string, // Human feedback if provided\n createdAt: Date,\n updatedAt: Date,\n }\n}\n```\n\n## Learn More\n\n- [Loopman Agent Documentation](https://github.com/loopman/loopman-langchain-sdk/blob/main/docs/LOOPMAN_AGENT.md)\n- [LangChain Documentation](https://js.langchain.com/docs)\n- [Loopman Documentation](https://loopman.dev/docs)\n\n"
19
19
  }
@@ -15,7 +15,7 @@
15
15
  "@langchain/mcp-adapters": "^1.0.0",
16
16
  "@langchain/langgraph": "^1.0.7",
17
17
  "@langchain/openai": "^1.0.0",
18
- "@loopman/langchain-sdk": "^1.17.2",
18
+ "@loopman/langchain-sdk": "^1.17.3",
19
19
  "dotenv": "^17.2.3",
20
20
  "langchain": "^1.0.2",
21
21
  "tsx": "^4.20.6",
@@ -15,7 +15,7 @@
15
15
  "@langchain/mcp-adapters": "^1.0.0",
16
16
  "@langchain/langgraph": "^1.0.7",
17
17
  "@langchain/openai": "^1.0.0",
18
- "@loopman/langchain-sdk": "^1.17.2",
18
+ "@loopman/langchain-sdk": "^1.17.3",
19
19
  "dotenv": "^17.2.3",
20
20
  "langchain": "^1.0.2",
21
21
  "tsx": "^4.20.6",
@@ -14,7 +14,7 @@
14
14
  "@langchain/core": "^1.0.2",
15
15
  "@langchain/langgraph": "^1.0.7",
16
16
  "@langchain/openai": "^1.0.0",
17
- "@loopman/langchain-sdk": "^1.17.2",
17
+ "@loopman/langchain-sdk": "^1.17.3",
18
18
  "dotenv": "^17.2.3",
19
19
  "langchain": "^1.0.2",
20
20
  "tsx": "^4.20.6",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loopman/langchain-sdk",
3
- "version": "1.17.2",
3
+ "version": "1.17.3",
4
4
  "description": "LangChain TypeScript SDK - Human-in-the-Loop validation via Loopman platform",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",