@loopman/langchain-sdk 1.0.9

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 (55) hide show
  1. package/LICENSE +374 -0
  2. package/README.md +594 -0
  3. package/dist/agents/loopman-agent.d.ts +29 -0
  4. package/dist/agents/loopman-agent.d.ts.map +1 -0
  5. package/dist/agents/loopman-agent.js +441 -0
  6. package/dist/agents/loopman-agent.js.map +1 -0
  7. package/dist/client/loopman-api.d.ts +123 -0
  8. package/dist/client/loopman-api.d.ts.map +1 -0
  9. package/dist/client/loopman-api.js +407 -0
  10. package/dist/client/loopman-api.js.map +1 -0
  11. package/dist/helpers/prompt-orchestrator.d.ts +12 -0
  12. package/dist/helpers/prompt-orchestrator.d.ts.map +1 -0
  13. package/dist/helpers/prompt-orchestrator.js +133 -0
  14. package/dist/helpers/prompt-orchestrator.js.map +1 -0
  15. package/dist/index.d.ts +17 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +22 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/loopman-agent-wrapper.d.ts +70 -0
  20. package/dist/loopman-agent-wrapper.d.ts.map +1 -0
  21. package/dist/loopman-agent-wrapper.js +157 -0
  22. package/dist/loopman-agent-wrapper.js.map +1 -0
  23. package/dist/loopman-middleware.d.ts +78 -0
  24. package/dist/loopman-middleware.d.ts.map +1 -0
  25. package/dist/loopman-middleware.js +367 -0
  26. package/dist/loopman-middleware.js.map +1 -0
  27. package/dist/mcp/loopman-mcp-client.d.ts +17 -0
  28. package/dist/mcp/loopman-mcp-client.d.ts.map +1 -0
  29. package/dist/mcp/loopman-mcp-client.js +76 -0
  30. package/dist/mcp/loopman-mcp-client.js.map +1 -0
  31. package/dist/mcp/tool-registry.d.ts +29 -0
  32. package/dist/mcp/tool-registry.d.ts.map +1 -0
  33. package/dist/mcp/tool-registry.js +143 -0
  34. package/dist/mcp/tool-registry.js.map +1 -0
  35. package/dist/services/index.d.ts +12 -0
  36. package/dist/services/index.d.ts.map +1 -0
  37. package/dist/services/index.js +9 -0
  38. package/dist/services/index.js.map +1 -0
  39. package/dist/services/logger.service.d.ts +107 -0
  40. package/dist/services/logger.service.d.ts.map +1 -0
  41. package/dist/services/logger.service.js +173 -0
  42. package/dist/services/logger.service.js.map +1 -0
  43. package/dist/services/loopman.service.d.ts +72 -0
  44. package/dist/services/loopman.service.d.ts.map +1 -0
  45. package/dist/services/loopman.service.js +271 -0
  46. package/dist/services/loopman.service.js.map +1 -0
  47. package/dist/services/polling.service.d.ts +136 -0
  48. package/dist/services/polling.service.d.ts.map +1 -0
  49. package/dist/services/polling.service.js +428 -0
  50. package/dist/services/polling.service.js.map +1 -0
  51. package/dist/types.d.ts +242 -0
  52. package/dist/types.d.ts.map +1 -0
  53. package/dist/types.js +35 -0
  54. package/dist/types.js.map +1 -0
  55. package/package.json +58 -0
package/README.md ADDED
@@ -0,0 +1,594 @@
1
+ # Loopman SDK TypeScript
2
+
3
+ A TypeScript SDK demonstrating AI agent development with LangChain v1.0 and Human-in-the-Loop (HITL) validation patterns.
4
+
5
+ ## 📋 Table of Contents
6
+
7
+ - [Overview](#overview)
8
+ - [Features](#features)
9
+ - [Prerequisites](#prerequisites)
10
+ - [Installation](#installation)
11
+ - [Quick Start](#quick-start)
12
+ - [Examples](#examples)
13
+ - [Loopman Middleware](#loopman-middleware)
14
+ - [Debugging](#debugging)
15
+ - [Project Structure](#project-structure)
16
+ - [API Reference](#api-reference)
17
+ - [Development](#development)
18
+ - [License](#license)
19
+
20
+ ---
21
+
22
+ ## 🎯 Overview
23
+
24
+ This SDK provides a comprehensive demonstration of building AI agents with LangChain v1.0, featuring:
25
+
26
+ - **Simple Agent Pattern**: Basic tool usage with conversational memory
27
+ - **Human-in-the-Loop Validation**: Using LangChain's native `humanInTheLoopMiddleware`
28
+ - **Loopman Integration**: Custom middleware for Loopman platform integration
29
+
30
+ Perfect for learning agent patterns, HITL workflows, and building production-ready AI assistants.
31
+
32
+ ---
33
+
34
+ ## ✨ Features
35
+
36
+ ### 🤖 Agent Capabilities
37
+
38
+ - ✅ **Tool Calling**: Dynamic tool execution with Zod validation
39
+ - ✅ **Conversational Memory**: Stateful conversations with checkpointers
40
+ - ✅ **Multi-turn Interactions**: Context-aware dialogue management
41
+ - ✅ **Streaming Support**: Real-time response streaming
42
+
43
+ ### 🛡️ Human-in-the-Loop
44
+
45
+ - ✅ **Native HITL Middleware**: LangChain's `humanInTheLoopMiddleware`
46
+ - ✅ **Custom Loopman Middleware**: Platform-specific integration
47
+ - ✅ **Decision Types**: Approve, Edit, Reject workflows
48
+ - ✅ **Selective Interruption**: Per-tool configuration
49
+ - ✅ **Double Validation Layer**: Global MCP validation + tool-specific validation
50
+ - ✅ **Flexible Execution Modes**: Auto-execution or manual control after approval
51
+
52
+ ### 🔧 Developer Experience
53
+
54
+ - ✅ **TypeScript**: Full type safety with TSDoc comments
55
+ - ✅ **Debugging**: VSCode launch configurations
56
+ - ✅ **Examples**: Three complete working examples
57
+ - ✅ **Documentation**: Inline comments and guides
58
+
59
+ ---
60
+
61
+ ## 📦 Prerequisites
62
+
63
+ - **Node.js**: 18+
64
+ - **OpenAI API Key**: Required for model calls
65
+ - **npm/yarn**: Package manager
66
+
67
+ ---
68
+
69
+ ## 🚀 Installation
70
+
71
+ ### 1. Install Dependencies
72
+
73
+ ```bash
74
+ npm install
75
+ ```
76
+
77
+ ### 2. Configure Environment
78
+
79
+ Create a `.env` file in the project root:
80
+
81
+ ```bash
82
+ cp env.example .env
83
+ ```
84
+
85
+ Edit `.env` and add your API keys:
86
+
87
+ ```env
88
+ OPENAI_API_KEY=sk-your-openai-api-key-here
89
+ LOOPMAN_API_KEY=your-loopman-api-key-here # Optional
90
+ ```
91
+
92
+ ---
93
+
94
+ ## ⚡ Quick Start
95
+
96
+ ### Basic Agent
97
+
98
+ ```typescript
99
+ import { createAgent, tool } from "langchain";
100
+ import { MemorySaver } from "@langchain/langgraph";
101
+ import * as z from "zod";
102
+
103
+ // Define a tool
104
+ const greetTool = tool(({ name }) => `Hello, ${name}!`, {
105
+ name: "greet",
106
+ description: "Greet a user by name",
107
+ schema: z.object({
108
+ name: z.string(),
109
+ }),
110
+ });
111
+
112
+ // Create agent
113
+ const agent = createAgent({
114
+ model: "openai:gpt-4o-mini",
115
+ tools: [greetTool],
116
+ checkpointer: new MemorySaver(),
117
+ });
118
+
119
+ // Run agent
120
+ const result = await agent.invoke(
121
+ {
122
+ messages: [{ role: "user", content: "Greet Alice" }],
123
+ },
124
+ { configurable: { thread_id: "demo" } }
125
+ );
126
+ ```
127
+
128
+ ### Human-in-the-Loop Agent
129
+
130
+ ```typescript
131
+ import { humanInTheLoopMiddleware } from "langchain";
132
+
133
+ const agent = createAgent({
134
+ model: "openai:gpt-4o-mini",
135
+ tools: [sendEmail],
136
+ middleware: [
137
+ humanInTheLoopMiddleware({
138
+ interruptOn: {
139
+ send_email: {
140
+ allowedDecisions: ["approve", "edit", "reject"],
141
+ description: "⚠️ Email requires approval",
142
+ },
143
+ },
144
+ }),
145
+ ],
146
+ checkpointer: new MemorySaver(),
147
+ });
148
+ ```
149
+
150
+ ### Loopman Platform Integration
151
+
152
+ ```typescript
153
+ import { loopmanMiddleware } from "./src/loopman-middleware";
154
+
155
+ const agent = createAgent({
156
+ model: "openai:gpt-4o-mini",
157
+ tools: [sendEmail],
158
+ middleware: [
159
+ loopmanMiddleware({
160
+ apiKey: process.env.LOOPMAN_API_KEY!,
161
+ workflowId: "email-workflow",
162
+ interruptOn: {
163
+ send_email: true, // Requires validation
164
+ read_email: false, // Auto-approved
165
+ },
166
+ pollingInterval: 5000, // Poll every 5 seconds
167
+ timeout: 300000, // 5 minutes
168
+ }),
169
+ ],
170
+ checkpointer: new MemorySaver(),
171
+ });
172
+
173
+ // Usage - No manual interruption handling needed!
174
+ const result = await agent.invoke(
175
+ {
176
+ messages: [{ role: "user", content: "Send email to alice" }],
177
+ },
178
+ { configurable: { thread_id: "demo" } }
179
+ );
180
+ // ✅ Middleware handles HITL transparently
181
+ ```
182
+
183
+ ---
184
+
185
+ ## 📚 Examples
186
+
187
+ Comprehensive examples are organized in the `examples/` directory by complexity level:
188
+
189
+ ### Quick Start Examples
190
+
191
+ **1. Basics** (`examples/1-basics/`)
192
+
193
+ - `01-simple-agent.ts` - Basic agent with tools and memory
194
+ - `02-memory-and-context.ts` - Conversational memory deep dive
195
+ - `03-langchain-native-hitl.ts` - LangChain's native HITL middleware
196
+
197
+ **2. Loopman Integration** (`examples/2-loopman-integration/`)
198
+
199
+ - `01-middleware-basic.ts` - Transparent HITL with Loopman middleware
200
+ - `02-middleware-modes.ts` - Three operation modes (tool-validation, prompt-enhancement, full)
201
+ - `03-loopman-agent.ts` - High-level Loopman agent API
202
+ - `04-loopman-agent-and-tool-validation.ts` - Double validation layer
203
+
204
+ **3. Real-World Examples** (`examples/3-real-world-examples/`)
205
+
206
+ - `task-management/task-approval.ts` - CRUD operations with selective approval
207
+ - `data-processing/data-validation.ts` - ETL with quality checks
208
+ - `content-workflow/content-review.ts` - Draft/publish workflow
209
+ - `content-workflow/reddit-news-writer.ts` - Automated news curation
210
+
211
+ **4. Advanced Patterns** (`examples/4-advanced-patterns/`)
212
+
213
+ - `conditional-hitl.ts` - Context-aware, intelligent validation
214
+
215
+ ### Running Examples
216
+
217
+ ```bash
218
+ # Basics
219
+ npx tsx examples/1-basics/01-simple-agent.ts
220
+ npx tsx examples/1-basics/03-langchain-native-hitl.ts
221
+
222
+ # Loopman Integration
223
+ npx tsx examples/2-loopman-integration/01-middleware-basic.ts
224
+ npx tsx examples/2-loopman-integration/03-loopman-agent.ts
225
+
226
+ # Real-World
227
+ npx tsx examples/3-real-world-examples/content-workflow/reddit-news-writer.ts
228
+ npx tsx examples/3-real-world-examples/task-management/task-approval.ts
229
+
230
+ # Advanced
231
+ npx tsx examples/4-advanced-patterns/conditional-hitl.ts
232
+ ```
233
+
234
+ See [Examples README](./examples/README.md) for detailed documentation and learning paths.
235
+
236
+ ---
237
+
238
+ **Key Features Demonstrated:**
239
+
240
+ - **Transparent validation**: No manual interruption handling
241
+ - **Automatic polling**: Middleware polls for decisions
242
+ - **Timeout handling**: Built-in timeout and retry logic
243
+ - **Fallback mechanism**: Auto-approval on API errors
244
+ - **Clean code**: Simple invoke() calls, HITL happens behind the scenes
245
+ - Debug logging for development
246
+
247
+ ---
248
+
249
+ ## 🔌 Loopman Middleware
250
+
251
+ Custom middleware for integrating with the Loopman Human-in-the-Loop platform.
252
+
253
+ ### Key Feature: Transparent Validation
254
+
255
+ **The middleware handles everything automatically!** No need to manually check for interruptions or poll for decisions.
256
+
257
+ ```typescript
258
+ // Just invoke the agent - HITL happens transparently!
259
+ const result = await agent.invoke(
260
+ {
261
+ messages: [{ role: "user", content: "Send email to alice" }],
262
+ },
263
+ config
264
+ );
265
+ // ✅ Decision already validated by human (if required)
266
+ ```
267
+
268
+ ### Configuration
269
+
270
+ ```typescript
271
+ import { loopmanMiddleware } from "./src/loopman-middleware";
272
+
273
+ loopmanMiddleware({
274
+ // Required
275
+ apiKey: "your-loopman-api-key",
276
+ workflowId: "email-workflow",
277
+
278
+ // Optional
279
+ executionId: "custom-execution-id", // Auto-generated if not provided
280
+ apiBaseUrl: "https://api.loopman.io", // Default
281
+ timeout: 5 * 60 * 1000, // 5 minutes
282
+ pollingInterval: 5000, // Poll every 5 seconds
283
+ debug: true, // Enable logging
284
+
285
+ // Tool configuration
286
+ interruptOn: {
287
+ send_email: true, // Requires validation
288
+ read_email: false, // Auto-approved
289
+ },
290
+ });
291
+ ```
292
+
293
+ ### Decision Flow (Automatic)
294
+
295
+ ```mermaid
296
+ graph TD
297
+ A[Agent calls tool] --> B{Requires validation?}
298
+ B -->|No| C[Execute immediately]
299
+ B -->|Yes| D[Middleware sends to Loopman API]
300
+ D --> E[Middleware polls for decision]
301
+ E --> F[Notify user via mobile/web]
302
+ F --> G{Human decision}
303
+ G -->|Approve| H[Middleware executes as-is]
304
+ G -->|Edit| I[Middleware executes with modifications]
305
+ G -->|Reject| J[Middleware returns error message]
306
+ H --> K[Return result to application]
307
+ I --> K
308
+ J --> K
309
+ style D fill:#90EE90
310
+ style E fill:#90EE90
311
+ style H fill:#90EE90
312
+ style I fill:#90EE90
313
+ style J fill:#90EE90
314
+ ```
315
+
316
+ **Note:** Green boxes = Handled by middleware (transparent to your code)
317
+
318
+ ### Response Types
319
+
320
+ ```typescript
321
+ // Approve
322
+ { type: "approve" }
323
+
324
+ // Edit/Modify
325
+ {
326
+ type: "edit",
327
+ editedAction: {
328
+ name: "send_email",
329
+ args: { to: "alice@example.com", subject: "Modified" }
330
+ }
331
+ }
332
+
333
+ // Reject
334
+ {
335
+ type: "reject",
336
+ message: "Reason for rejection"
337
+ }
338
+ ```
339
+
340
+ ---
341
+
342
+ ## 🐛 Debugging
343
+
344
+ VSCode launch configurations are provided in `.vscode/launch.json`.
345
+
346
+ ### Available Configurations
347
+
348
+ 1. **Debug Current Example**: Debug the currently open TypeScript file
349
+ 2. **Debug Simple Agent**: Launch `examples/1-basics/01-simple-agent.ts`
350
+ 3. **Debug HITL Agent**: Launch `examples/1-basics/03-langchain-native-hitl.ts`
351
+ 4. **Debug Loopman Middleware**: Launch `examples/2-loopman-integration/01-middleware-basic.ts`
352
+
353
+ ### Usage
354
+
355
+ 1. Open an example file
356
+ 2. Press `F5` or click the debug icon
357
+ 3. Select a configuration
358
+ 4. Set breakpoints as needed
359
+
360
+ ---
361
+
362
+ ## 📁 Project Structure
363
+
364
+ ```
365
+ loopman-langchain-sdk-typescript/
366
+ ├── src/
367
+ │ ├── agents/
368
+ │ │ └── loopman-agent.ts # High-level Loopman agent API
369
+ │ ├── client/
370
+ │ │ └── loopman-api.ts # Loopman API client
371
+ │ ├── helpers/
372
+ │ │ └── prompt-orchestrator.ts # Prompt building utilities
373
+ │ ├── mcp/
374
+ │ │ ├── loopman-mcp-client.ts # MCP client integration
375
+ │ │ └── tool-registry.ts # Tool registry for MCP
376
+ │ ├── services/
377
+ │ │ ├── loopman.service.ts # Main Loopman service
378
+ │ │ ├── polling.service.ts # Polling logic
379
+ │ │ └── logger.service.ts # Logging service
380
+ │ ├── loopman-middleware.ts # Core middleware implementation
381
+ │ ├── loopman-agent-wrapper.ts # Wrapper helpers (invokeWithRetry)
382
+ │ ├── index.ts # Main export entry point
383
+ │ └── types.ts # TypeScript type definitions
384
+ ├── examples/
385
+ │ ├── 1-basics/ # LangChain fundamentals
386
+ │ ├── 2-loopman-integration/ # Loopman HITL integration
387
+ │ ├── 3-real-world-examples/ # Production use cases
388
+ │ └── 4-advanced-patterns/ # Advanced HITL patterns
389
+ ├── docs/ # Detailed documentation
390
+ ├── dist/ # Compiled JavaScript (generated)
391
+ ├── .env # Environment variables (root)
392
+ ├── env.example # Example environment file
393
+ ├── package.json # Dependencies and scripts
394
+ ├── tsconfig.json # TypeScript configuration
395
+ └── README.md # This file
396
+ ```
397
+
398
+ ---
399
+
400
+ ## 📖 API Reference
401
+
402
+ ### Loopman Middleware API
403
+
404
+ #### `loopmanMiddleware(config)`
405
+
406
+ Creates a LangChain middleware for Loopman integration.
407
+
408
+ **Parameters:**
409
+
410
+ - `config.apiKey` (string, required): Loopman API key
411
+ - `config.workflowId` (string, required): Workflow identifier
412
+ - `config.executionId` (string, optional): Execution ID
413
+ - `config.channelId` (string, optional): Channel ID for task routing
414
+ - `config.mode` (string, optional): Operation mode (`tool-validation`, `prompt-enhancement`, `full`)
415
+ - `config.interruptOn` (Record<string, boolean>, optional): Tool validation config
416
+ - `config.timeout` (number, optional): Decision timeout in ms
417
+ - `config.pollingInterval` (number, optional): Polling interval in ms
418
+ - `config.debug` (boolean, optional): Enable debug logging
419
+
420
+ **Returns:** `AgentMiddleware`
421
+
422
+ **Example:**
423
+
424
+ ```typescript
425
+ const middleware = loopmanMiddleware({
426
+ apiKey: process.env.LOOPMAN_API_KEY!,
427
+ workflowId: "my-workflow",
428
+ interruptOn: { send_email: true },
429
+ debug: true,
430
+ });
431
+ ```
432
+
433
+ ### Loopman Agent API
434
+
435
+ #### `createLoopmanAgent(config)`
436
+
437
+ Creates a complete Loopman agent with MCP integration and double validation layer.
438
+
439
+ **Parameters:**
440
+
441
+ - `config.apiKey` (string, required): Loopman API key
442
+ - `config.workflowId` (string, required): Workflow identifier
443
+ - `config.model` (string, required): Model identifier (e.g., `"openai:gpt-4o-mini"`)
444
+ - `config.systemPrompt` (string, required): System prompt for the agent
445
+ - `config.additionalTools` (array, optional): Custom tools to add
446
+ - `config.category` (string, optional): Category for guidelines organization
447
+ - `config.channelId` (string, optional): Channel ID for task routing
448
+ - `config.language` (string, optional): Language for human review interface
449
+ - `config.requireApprovalForTools` (array, optional): Tools requiring approval (`['*']` for all)
450
+ - `config.manualExecutionMode` (boolean, optional): Manual execution mode
451
+ - `config.pollingIntervalMs` (number, optional): Polling interval
452
+ - `config.pollingTimeoutMs` (number, optional): Polling timeout
453
+ - `config.debug` (boolean, optional): Enable debug logging
454
+
455
+ **Returns:** `LoopmanAgent`
456
+
457
+ **Example:**
458
+
459
+ ```typescript
460
+ const agent = createLoopmanAgent({
461
+ apiKey: process.env.LOOPMAN_API_KEY!,
462
+ workflowId: "my-workflow",
463
+ model: "openai:gpt-4o-mini",
464
+ systemPrompt: "Your instructions...",
465
+ additionalTools: [myTool],
466
+ debug: true,
467
+ });
468
+
469
+ const result = await agent.processWithHumanValidation({
470
+ input: "Your task...",
471
+ });
472
+ ```
473
+
474
+ See [Loopman Agent Guide](./docs/LOOPMAN_AGENT.md) for complete API documentation.
475
+
476
+ ---
477
+
478
+ ## 🛠️ Development
479
+
480
+ ### Scripts
481
+
482
+ ```bash
483
+ # Development
484
+ npm run build # Compile TypeScript to JavaScript
485
+ npm run clean # Remove dist/ folder
486
+
487
+ # Examples (run directly with tsx)
488
+ npx tsx examples/1-basics/01-simple-agent.ts
489
+ npx tsx examples/2-loopman-integration/01-middleware-basic.ts
490
+ npx tsx examples/3-real-world-examples/content-workflow/reddit-news-writer.ts
491
+ ```
492
+
493
+ ### Adding New Tools
494
+
495
+ 1. Define the tool with Zod schema:
496
+
497
+ ```typescript
498
+ const myTool = tool(
499
+ ({ param }) => {
500
+ // Tool logic here
501
+ return "result";
502
+ },
503
+ {
504
+ name: "my_tool",
505
+ description: "What the tool does",
506
+ schema: z.object({
507
+ param: z.string().describe("Parameter description"),
508
+ }),
509
+ }
510
+ );
511
+ ```
512
+
513
+ 2. Add to agent:
514
+
515
+ ```typescript
516
+ const agent = createAgent({
517
+ model: "openai:gpt-4o-mini",
518
+ tools: [myTool, ...otherTools],
519
+ // ... other config
520
+ });
521
+ ```
522
+
523
+ ### Extending Loopman Middleware
524
+
525
+ The Loopman middleware is fully implemented with:
526
+
527
+ - ✅ Real Loopman API integration via HTTP calls
528
+ - ✅ Polling for decision responses with configurable intervals
529
+ - ✅ Timeout and retry logic
530
+ - ✅ Comprehensive error handling and logging
531
+ - ✅ Support for multiple operation modes (tool-validation, prompt-enhancement, full)
532
+
533
+ See `src/loopman-middleware.ts` for the complete implementation.
534
+
535
+ ---
536
+
537
+ ## 🔗 Related Resources
538
+
539
+ ### LangChain Documentation
540
+
541
+ - [LangChain v1.0 Quickstart](https://docs.langchain.com/oss/javascript/langchain/quickstart)
542
+ - [Human-in-the-Loop Guide](https://docs.langchain.com/oss/javascript/langchain/human-in-the-loop)
543
+ - [Tools Documentation](https://docs.langchain.com/oss/javascript/langchain/tools)
544
+
545
+ ### Loopman Platform
546
+
547
+ - [Loopman LangChain SDK](../loopman-langchain-sdk) - Production HITL SDK
548
+ - [Loopman Web App](../loopman-web) - Web interface
549
+ - [Loopman Mobile App](../loopman-application) - Flutter mobile app
550
+
551
+ ---
552
+
553
+ ## 📄 License
554
+
555
+ ISC
556
+
557
+ ---
558
+
559
+ ## 🤝 Contributing
560
+
561
+ This is a demonstration project. For production use, see the [Loopman LangChain SDK](../loopman-langchain-sdk).
562
+
563
+ ---
564
+
565
+ ## 💡 Tips
566
+
567
+ ### Environment Variables
568
+
569
+ - Keep `.env` files out of version control
570
+ - Use `env.example` as a template
571
+ - Store sensitive keys in environment variables
572
+
573
+ ### Debugging
574
+
575
+ - Use VSCode debug configurations for step-through debugging
576
+ - Enable `debug: true` in middleware for detailed logging
577
+ - Check `console.log` output for tool execution details
578
+
579
+ ### Performance
580
+
581
+ - Use `MemorySaver` for development only
582
+ - Use persistent checkpointers (PostgreSQL) in production
583
+ - Consider timeout values for HITL workflows
584
+
585
+ ### Best Practices
586
+
587
+ - Always validate tool schemas with Zod
588
+ - Handle errors gracefully in tools
589
+ - Use descriptive tool names and descriptions
590
+ - Test HITL workflows thoroughly
591
+
592
+ ---
593
+
594
+ **Built with ❤️ using LangChain v1.0 and TypeScript**
@@ -0,0 +1,29 @@
1
+ import { CreateLoopmanAgentParams, LoopmanAgentConfig, LoopmanAgentInput, LoopmanAgentOutput } from "../types";
2
+ export declare class LoopmanAgent {
3
+ private readonly config;
4
+ private readonly hasFixedExecutionId;
5
+ private readonly baseExecutionId?;
6
+ private readonly maxRetries;
7
+ private readonly debug;
8
+ private readonly additionalTools;
9
+ private agent;
10
+ private mcpClient;
11
+ private toolRegistry;
12
+ private loopmanService;
13
+ private cachedTools;
14
+ private middlewareConfig;
15
+ constructor(config: LoopmanAgentConfig);
16
+ processWithHumanValidation(input: LoopmanAgentInput): Promise<LoopmanAgentOutput>;
17
+ disconnect(): Promise<void>;
18
+ private normalizeMessageContent;
19
+ private ensureAgent;
20
+ private buildMessages;
21
+ /**
22
+ * Build execution messages by continuing the conversation history
23
+ * This ensures the agent has full context of what was proposed and approved
24
+ */
25
+ private buildExecutionMessages;
26
+ private extractAgentOutput;
27
+ }
28
+ export declare function createLoopmanAgent(config: CreateLoopmanAgentParams): LoopmanAgent;
29
+ //# sourceMappingURL=loopman-agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loopman-agent.d.ts","sourceRoot":"","sources":["../../src/agents/loopman-agent.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAElB,qBAAa,YAAY;IAcX,OAAO,CAAC,QAAQ,CAAC,MAAM;IAbnC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAU;IAC9C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAS;IAC1C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAU;IAChC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAQ;IAExC,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,SAAS,CAAmB;IACpC,OAAO,CAAC,YAAY,CAAsB;IAC1C,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,WAAW,CAAsB;IACzC,OAAO,CAAC,gBAAgB,CAAa;gBAER,MAAM,EAAE,kBAAkB;IAoBjD,0BAA0B,CAC9B,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC,kBAAkB,CAAC;IAgTxB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAIjC,OAAO,CAAC,uBAAuB;YAwBjB,WAAW;IAkIzB,OAAO,CAAC,aAAa;IAkBrB;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAsC9B,OAAO,CAAC,kBAAkB;CAW3B;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,wBAAwB,GAC/B,YAAY,CAWd"}