@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.
- package/LICENSE +374 -0
- package/README.md +594 -0
- package/dist/agents/loopman-agent.d.ts +29 -0
- package/dist/agents/loopman-agent.d.ts.map +1 -0
- package/dist/agents/loopman-agent.js +441 -0
- package/dist/agents/loopman-agent.js.map +1 -0
- package/dist/client/loopman-api.d.ts +123 -0
- package/dist/client/loopman-api.d.ts.map +1 -0
- package/dist/client/loopman-api.js +407 -0
- package/dist/client/loopman-api.js.map +1 -0
- package/dist/helpers/prompt-orchestrator.d.ts +12 -0
- package/dist/helpers/prompt-orchestrator.d.ts.map +1 -0
- package/dist/helpers/prompt-orchestrator.js +133 -0
- package/dist/helpers/prompt-orchestrator.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/loopman-agent-wrapper.d.ts +70 -0
- package/dist/loopman-agent-wrapper.d.ts.map +1 -0
- package/dist/loopman-agent-wrapper.js +157 -0
- package/dist/loopman-agent-wrapper.js.map +1 -0
- package/dist/loopman-middleware.d.ts +78 -0
- package/dist/loopman-middleware.d.ts.map +1 -0
- package/dist/loopman-middleware.js +367 -0
- package/dist/loopman-middleware.js.map +1 -0
- package/dist/mcp/loopman-mcp-client.d.ts +17 -0
- package/dist/mcp/loopman-mcp-client.d.ts.map +1 -0
- package/dist/mcp/loopman-mcp-client.js +76 -0
- package/dist/mcp/loopman-mcp-client.js.map +1 -0
- package/dist/mcp/tool-registry.d.ts +29 -0
- package/dist/mcp/tool-registry.d.ts.map +1 -0
- package/dist/mcp/tool-registry.js +143 -0
- package/dist/mcp/tool-registry.js.map +1 -0
- package/dist/services/index.d.ts +12 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +9 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/logger.service.d.ts +107 -0
- package/dist/services/logger.service.d.ts.map +1 -0
- package/dist/services/logger.service.js +173 -0
- package/dist/services/logger.service.js.map +1 -0
- package/dist/services/loopman.service.d.ts +72 -0
- package/dist/services/loopman.service.d.ts.map +1 -0
- package/dist/services/loopman.service.js +271 -0
- package/dist/services/loopman.service.js.map +1 -0
- package/dist/services/polling.service.d.ts +136 -0
- package/dist/services/polling.service.d.ts.map +1 -0
- package/dist/services/polling.service.js +428 -0
- package/dist/services/polling.service.js.map +1 -0
- package/dist/types.d.ts +242 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +35 -0
- package/dist/types.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { DynamicStructuredTool } from "@langchain/core/tools";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export class LoopmanToolRegistry {
|
|
4
|
+
config;
|
|
5
|
+
constructor(config) {
|
|
6
|
+
this.config = config;
|
|
7
|
+
}
|
|
8
|
+
toDynamicTools(mcpTools) {
|
|
9
|
+
return mcpTools.map((tool) => this.createTool(tool));
|
|
10
|
+
}
|
|
11
|
+
createTool(tool) {
|
|
12
|
+
const schema = this.resolveSchema(tool);
|
|
13
|
+
if (this.config.debug) {
|
|
14
|
+
console.log(`[LoopmanToolRegistry] Creating tool ${tool.name} with schema:`, schema);
|
|
15
|
+
}
|
|
16
|
+
return new DynamicStructuredTool({
|
|
17
|
+
name: tool.name,
|
|
18
|
+
description: this.buildDescription(tool, schema),
|
|
19
|
+
schema,
|
|
20
|
+
returnDirect: tool.name === "submitForHumanReview",
|
|
21
|
+
func: async (input) => {
|
|
22
|
+
const args = this.prepareArgs(tool.name, input);
|
|
23
|
+
if (this.config.debug) {
|
|
24
|
+
console.log(`[LoopmanTool] Executing ${tool.name}`, args);
|
|
25
|
+
}
|
|
26
|
+
const result = await tool.func(args);
|
|
27
|
+
if (this.config.debug) {
|
|
28
|
+
console.log(`[LoopmanTool] Result for ${tool.name}`, result);
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
resolveSchema(tool) {
|
|
35
|
+
// Override empty schema for submitForHumanReview with explicit schema
|
|
36
|
+
// This is needed because @langchain/mcp-adapters doesn't correctly convert JSON Schema to Zod
|
|
37
|
+
if (tool.name === "submitForHumanReview") {
|
|
38
|
+
return z.object({
|
|
39
|
+
title: z.string().describe("Brief description of the action"),
|
|
40
|
+
description: z
|
|
41
|
+
.string()
|
|
42
|
+
.describe("Brief description of the decision being requested"),
|
|
43
|
+
proposedDecision: z.string().describe("The exact action you propose"),
|
|
44
|
+
decisionReasoning: z
|
|
45
|
+
.string()
|
|
46
|
+
.describe("Detailed explanation of why you made this decision based on guidelines"),
|
|
47
|
+
businessContext: z
|
|
48
|
+
.string()
|
|
49
|
+
.describe("Background context about the situation - explain the circumstances like you're writing to your supervisor"),
|
|
50
|
+
information: z
|
|
51
|
+
.array(z.object({
|
|
52
|
+
type: z
|
|
53
|
+
.enum(["text", "url", "image", "bulletPoints"])
|
|
54
|
+
.describe("Type of information for proper display formatting"),
|
|
55
|
+
label: z
|
|
56
|
+
.string()
|
|
57
|
+
.optional()
|
|
58
|
+
.describe("Descriptive title for this information item (e.g., 'Original Article Content', 'Email Body', 'Document to Review')"),
|
|
59
|
+
value: z
|
|
60
|
+
.union([z.string(), z.array(z.string())])
|
|
61
|
+
.describe("The actual information content. IMPORTANT: Include ALL relevant data that the human reviewer needs to make an informed decision. For content workflows (summarizing, reviewing, publishing), always include the COMPLETE original content/document/article text, not just metadata or excerpts. The human needs to see the full context to verify accuracy."),
|
|
62
|
+
importance: z
|
|
63
|
+
.number()
|
|
64
|
+
.min(0)
|
|
65
|
+
.max(10)
|
|
66
|
+
.optional()
|
|
67
|
+
.describe("Optional importance level (0-10)"),
|
|
68
|
+
ruleIds: z
|
|
69
|
+
.array(z.string())
|
|
70
|
+
.optional()
|
|
71
|
+
.describe("Optional rule identifiers from guidelines"),
|
|
72
|
+
}))
|
|
73
|
+
.describe("Array of information items providing ALL context and data needed for human review. Include complete content, not just summaries or metadata."),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (tool.schema && this.isZodSchema(tool.schema)) {
|
|
77
|
+
return tool.schema;
|
|
78
|
+
}
|
|
79
|
+
if (tool.inputSchema && this.isZodSchema(tool.inputSchema)) {
|
|
80
|
+
return tool.inputSchema;
|
|
81
|
+
}
|
|
82
|
+
return z.object({});
|
|
83
|
+
}
|
|
84
|
+
prepareArgs(toolName, input) {
|
|
85
|
+
const args = { ...input };
|
|
86
|
+
if (toolName === "submitForHumanReview") {
|
|
87
|
+
// Debug: log the actual input received
|
|
88
|
+
if (this.config.debug) {
|
|
89
|
+
console.log("[LoopmanToolRegistry] submitForHumanReview input:", JSON.stringify(input, null, 2));
|
|
90
|
+
}
|
|
91
|
+
// Only inject workflow metadata, don't validate (MCP will validate)
|
|
92
|
+
args.workflowIdentifier ??= this.config.workflowId;
|
|
93
|
+
args.executionIdentifier ??= this.config.executionId;
|
|
94
|
+
args.category ??= this.config.category;
|
|
95
|
+
if (this.config.channelId) {
|
|
96
|
+
args.channelId ??= this.config.channelId;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (toolName === "getHumanGuidelines") {
|
|
100
|
+
args.workflow_id ??= this.config.workflowId;
|
|
101
|
+
args.execution_id ??= this.config.executionId;
|
|
102
|
+
args.category ??= this.config.category ?? "general";
|
|
103
|
+
}
|
|
104
|
+
if (toolName === "getDecisionContext") {
|
|
105
|
+
args.workflow_id ??= this.config.workflowId;
|
|
106
|
+
args.execution_id ??= this.config.executionId;
|
|
107
|
+
}
|
|
108
|
+
return args;
|
|
109
|
+
}
|
|
110
|
+
buildDescription(tool, schema) {
|
|
111
|
+
const description = tool.description ?? "Loopman MCP tool";
|
|
112
|
+
const schemaDescription = this.describeSchema(schema);
|
|
113
|
+
return `${description}\n\nInput Schema:\n${schemaDescription}`;
|
|
114
|
+
}
|
|
115
|
+
describeSchema(schema) {
|
|
116
|
+
if (!schema || !this.isZodSchema(schema)) {
|
|
117
|
+
return "(no schema documentation available)";
|
|
118
|
+
}
|
|
119
|
+
const zodObject = schema;
|
|
120
|
+
if (!zodObject._def || typeof zodObject._def.shape !== "function") {
|
|
121
|
+
return "(schema not available)";
|
|
122
|
+
}
|
|
123
|
+
const shape = zodObject._def.shape();
|
|
124
|
+
const entries = Object.entries(shape).map(([key, value]) => {
|
|
125
|
+
const typeAny = value;
|
|
126
|
+
const isOptionalFn = typeof typeAny.isOptional === "function";
|
|
127
|
+
const required = isOptionalFn
|
|
128
|
+
? !typeAny.isOptional()
|
|
129
|
+
: typeAny._def?.typeName !== "ZodOptional";
|
|
130
|
+
const typeName = typeAny._def?.typeName ?? "unknown";
|
|
131
|
+
const description = typeAny._def?.description ?? "";
|
|
132
|
+
return `- ${key}: ${typeName} ${required ? "(required)" : "(optional)"} ${description}`;
|
|
133
|
+
});
|
|
134
|
+
if (entries.length === 0) {
|
|
135
|
+
return "(no fields)";
|
|
136
|
+
}
|
|
137
|
+
return entries.join("\n");
|
|
138
|
+
}
|
|
139
|
+
isZodSchema(schema) {
|
|
140
|
+
return (Boolean(schema) && typeof schema === "object" && "_def" in schema);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=tool-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-registry.js","sourceRoot":"","sources":["../../src/mcp/tool-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAkBxB,MAAM,OAAO,mBAAmB;IACD;IAA7B,YAA6B,MAAiC;QAAjC,WAAM,GAAN,MAAM,CAA2B;IAAG,CAAC;IAElE,cAAc,CAAC,QAAmB;QAChC,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,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AC,CAAE,OAAe,CAAC,UAAU,EAAE;gBAChC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,KAAK,aAAa,CAAC;YAC7C,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,EAAE,QAAQ,IAAI,SAAS,CAAC;YACrD,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,EAAE,WAAW,IAAI,EAAE,CAAC;YACpD,OAAO,KAAK,GAAG,KAAK,QAAQ,IAC1B,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAC5B,IAAI,WAAW,EAAE,CAAC;QACpB,CAAC,CAAC,CAAC;QAEH,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,aAAa,CAAC;QACvB,CAAC;QAED,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAEO,WAAW,CAAC,MAAe;QACjC,OAAO,CACL,OAAO,CAAC,MAAM,CAAC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,IAAK,MAAc,CAC3E,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loopman Services
|
|
3
|
+
*
|
|
4
|
+
* Core services for interacting with the Loopman API
|
|
5
|
+
*/
|
|
6
|
+
export type { CreateTaskRequest, DecisionContextEntry, DecisionContextResponse, Guideline, GuidelinesResponse, LoopmanDecisionResponse, LoopmanServiceConfig, LoopmanTaskResponse, LoopmanTaskStatus, TaskInformation, } from "../types";
|
|
7
|
+
export { LoopmanService } from "./loopman.service";
|
|
8
|
+
export { PollingService } from "./polling.service";
|
|
9
|
+
export type { DecisionStatusResponse, PollingOptions, PollingResult, } from "./polling.service";
|
|
10
|
+
export { LoggerService } from "./logger.service";
|
|
11
|
+
export type { LoggerConfig, LogLevel } from "./logger.service";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EACV,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,SAAS,EACT,kBAAkB,EAClB,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,GAChB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,YAAY,EACV,sBAAsB,EACtB,cAAc,EACd,aAAa,GACd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loopman Services
|
|
3
|
+
*
|
|
4
|
+
* Core services for interacting with the Loopman API
|
|
5
|
+
*/
|
|
6
|
+
export { LoopmanService } from "./loopman.service";
|
|
7
|
+
export { PollingService } from "./polling.service";
|
|
8
|
+
export { LoggerService } from "./logger.service";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAOnD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { LoopmanApiClient } from "../client/loopman-api";
|
|
2
|
+
/**
|
|
3
|
+
* Log levels supported by the logger
|
|
4
|
+
*/
|
|
5
|
+
export type LogLevel = "debug" | "info" | "warn" | "error";
|
|
6
|
+
/**
|
|
7
|
+
* Configuration for LoggerService
|
|
8
|
+
*/
|
|
9
|
+
export interface LoggerConfig {
|
|
10
|
+
/** API client for sending logs to Loopman */
|
|
11
|
+
apiClient: LoopmanApiClient;
|
|
12
|
+
/** API key for authentication */
|
|
13
|
+
apiKey: string;
|
|
14
|
+
/** Workflow ID for context */
|
|
15
|
+
workflowId: string;
|
|
16
|
+
/** Execution ID for context */
|
|
17
|
+
executionId: string;
|
|
18
|
+
/** Task ID for context (optional, can be set after task creation) */
|
|
19
|
+
taskId?: string;
|
|
20
|
+
/** Logger name/source (e.g., "PollingService", "Middleware") */
|
|
21
|
+
source: string;
|
|
22
|
+
/** Enable debug logging to console */
|
|
23
|
+
debug?: boolean;
|
|
24
|
+
/** Enable sending logs to Loopman API */
|
|
25
|
+
enableRemoteLogs?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Centralized logging service for Loopman SDK
|
|
29
|
+
*
|
|
30
|
+
* Features:
|
|
31
|
+
* - Logs to console (when debug mode is enabled)
|
|
32
|
+
* - Sends logs to Loopman API (non-blocking)
|
|
33
|
+
* - Adds context automatically (workflow, execution, source)
|
|
34
|
+
* - Handles errors gracefully
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const logger = new LoggerService({
|
|
39
|
+
* apiClient,
|
|
40
|
+
* apiKey: "key",
|
|
41
|
+
* workflowId: "workflow-1",
|
|
42
|
+
* executionId: "exec-1",
|
|
43
|
+
* source: "PollingService",
|
|
44
|
+
* debug: true,
|
|
45
|
+
* });
|
|
46
|
+
*
|
|
47
|
+
* logger.info("Polling started", { decisionId: "dec_123" });
|
|
48
|
+
* logger.error("Failed to poll", error);
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare class LoggerService {
|
|
52
|
+
private config;
|
|
53
|
+
constructor(config: LoggerConfig);
|
|
54
|
+
/**
|
|
55
|
+
* Update logger configuration (e.g., to add taskId after task creation)
|
|
56
|
+
*/
|
|
57
|
+
setTaskId(taskId: string): void;
|
|
58
|
+
/**
|
|
59
|
+
* Log debug message (only shown if debug mode is enabled)
|
|
60
|
+
*/
|
|
61
|
+
debug(message: string, data?: any): void;
|
|
62
|
+
/**
|
|
63
|
+
* Log info message
|
|
64
|
+
*/
|
|
65
|
+
info(message: string, data?: any): void;
|
|
66
|
+
/**
|
|
67
|
+
* Log warning message (always shown to console)
|
|
68
|
+
*/
|
|
69
|
+
warn(message: string, data?: any): void;
|
|
70
|
+
/**
|
|
71
|
+
* Log error message (always shown to console)
|
|
72
|
+
*/
|
|
73
|
+
error(message: string, data?: any): void;
|
|
74
|
+
/**
|
|
75
|
+
* Generic log method
|
|
76
|
+
*/
|
|
77
|
+
private log;
|
|
78
|
+
/**
|
|
79
|
+
* Log to console based on level and debug mode
|
|
80
|
+
*/
|
|
81
|
+
private logToConsole;
|
|
82
|
+
/**
|
|
83
|
+
* Send log to Loopman API (non-blocking, fails silently)
|
|
84
|
+
*/
|
|
85
|
+
private sendToLoopman;
|
|
86
|
+
/**
|
|
87
|
+
* Async method to send log to Loopman API
|
|
88
|
+
*/
|
|
89
|
+
private sendLogAsync;
|
|
90
|
+
/**
|
|
91
|
+
* Create a child logger with a different source
|
|
92
|
+
* Useful for creating sub-loggers within a service
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* const mainLogger = new LoggerService({ source: "PollingService", ... });
|
|
97
|
+
* const sessionLogger = mainLogger.child("PollingSession");
|
|
98
|
+
* sessionLogger.info("Session started"); // [PollingSession] Session started
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
child(source: string): LoggerService;
|
|
102
|
+
/**
|
|
103
|
+
* Update logger configuration (e.g., toggle debug mode)
|
|
104
|
+
*/
|
|
105
|
+
updateConfig(updates: Partial<LoggerConfig>): void;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=logger.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.service.d.ts","sourceRoot":"","sources":["../../src/services/logger.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,6CAA6C;IAC7C,SAAS,EAAE,gBAAgB,CAAC;IAC5B,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,+BAA+B;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,MAAM,EAAE,MAAM,CAAC;IACf,sCAAsC;IACtC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,yCAAyC;IACzC,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAe;gBAEjB,MAAM,EAAE,YAAY;IAQhC;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI/B;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;IAIxC;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;IAIvC;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;IAIvC;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;IAIxC;;OAEG;IACH,OAAO,CAAC,GAAG;IAUX;;OAEG;IACH,OAAO,CAAC,YAAY;IA+BpB;;OAEG;IACH,OAAO,CAAC,aAAa;IAarB;;OAEG;YACW,YAAY;IAqC1B;;;;;;;;;;OAUG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa;IAOpC;;OAEG;IACH,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;CAMnD"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized logging service for Loopman SDK
|
|
3
|
+
*
|
|
4
|
+
* Features:
|
|
5
|
+
* - Logs to console (when debug mode is enabled)
|
|
6
|
+
* - Sends logs to Loopman API (non-blocking)
|
|
7
|
+
* - Adds context automatically (workflow, execution, source)
|
|
8
|
+
* - Handles errors gracefully
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const logger = new LoggerService({
|
|
13
|
+
* apiClient,
|
|
14
|
+
* apiKey: "key",
|
|
15
|
+
* workflowId: "workflow-1",
|
|
16
|
+
* executionId: "exec-1",
|
|
17
|
+
* source: "PollingService",
|
|
18
|
+
* debug: true,
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* logger.info("Polling started", { decisionId: "dec_123" });
|
|
22
|
+
* logger.error("Failed to poll", error);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export class LoggerService {
|
|
26
|
+
config;
|
|
27
|
+
constructor(config) {
|
|
28
|
+
this.config = {
|
|
29
|
+
debug: false,
|
|
30
|
+
enableRemoteLogs: true,
|
|
31
|
+
...config,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Update logger configuration (e.g., to add taskId after task creation)
|
|
36
|
+
*/
|
|
37
|
+
setTaskId(taskId) {
|
|
38
|
+
this.config.taskId = taskId;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Log debug message (only shown if debug mode is enabled)
|
|
42
|
+
*/
|
|
43
|
+
debug(message, data) {
|
|
44
|
+
this.log("debug", message, data);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Log info message
|
|
48
|
+
*/
|
|
49
|
+
info(message, data) {
|
|
50
|
+
this.log("info", message, data);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Log warning message (always shown to console)
|
|
54
|
+
*/
|
|
55
|
+
warn(message, data) {
|
|
56
|
+
this.log("warn", message, data);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Log error message (always shown to console)
|
|
60
|
+
*/
|
|
61
|
+
error(message, data) {
|
|
62
|
+
this.log("error", message, data);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Generic log method
|
|
66
|
+
*/
|
|
67
|
+
log(level, message, data) {
|
|
68
|
+
// Console logging
|
|
69
|
+
this.logToConsole(level, message, data);
|
|
70
|
+
// Remote logging (non-blocking)
|
|
71
|
+
if (this.config.enableRemoteLogs && level !== "debug") {
|
|
72
|
+
this.sendToLoopman(level, message, data);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Log to console based on level and debug mode
|
|
77
|
+
*/
|
|
78
|
+
logToConsole(level, message, data) {
|
|
79
|
+
const prefix = `[${this.config.source}]`;
|
|
80
|
+
const logData = data !== undefined ? data : "";
|
|
81
|
+
switch (level) {
|
|
82
|
+
case "debug":
|
|
83
|
+
// Debug only shown if debug mode is enabled
|
|
84
|
+
if (this.config.debug) {
|
|
85
|
+
console.log(prefix, message, logData);
|
|
86
|
+
}
|
|
87
|
+
break;
|
|
88
|
+
case "info":
|
|
89
|
+
// Info only shown if debug mode is enabled
|
|
90
|
+
if (this.config.debug) {
|
|
91
|
+
console.log(prefix, message, logData);
|
|
92
|
+
}
|
|
93
|
+
break;
|
|
94
|
+
case "warn":
|
|
95
|
+
// Warnings always shown
|
|
96
|
+
console.warn(prefix, message, logData);
|
|
97
|
+
break;
|
|
98
|
+
case "error":
|
|
99
|
+
// Errors always shown
|
|
100
|
+
console.error(prefix, message, logData);
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Send log to Loopman API (non-blocking, fails silently)
|
|
106
|
+
*/
|
|
107
|
+
sendToLoopman(level, message, data) {
|
|
108
|
+
// Fire and forget - don't await or block on this
|
|
109
|
+
this.sendLogAsync(level, message, data).catch((error) => {
|
|
110
|
+
// Silent fail - only log to console in debug mode
|
|
111
|
+
if (this.config.debug) {
|
|
112
|
+
console.error(`[${this.config.source}] Failed to send log to Loopman:`, error);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Async method to send log to Loopman API
|
|
118
|
+
*/
|
|
119
|
+
async sendLogAsync(level, message, data) {
|
|
120
|
+
try {
|
|
121
|
+
const payload = {
|
|
122
|
+
comment: message,
|
|
123
|
+
category: "SDK_OPERATION",
|
|
124
|
+
workflowId: this.config.workflowId,
|
|
125
|
+
workflowIdentifier: this.config.workflowId,
|
|
126
|
+
executionIdentifier: this.config.executionId,
|
|
127
|
+
counter: 0,
|
|
128
|
+
data: {
|
|
129
|
+
level,
|
|
130
|
+
source: this.config.source,
|
|
131
|
+
timestamp: new Date().toISOString(),
|
|
132
|
+
rawData: data,
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
// Add taskId if available
|
|
136
|
+
if (this.config.taskId) {
|
|
137
|
+
payload.taskId = this.config.taskId;
|
|
138
|
+
}
|
|
139
|
+
await this.config.apiClient.post(this.config.apiKey, "/api/v1/logs", payload);
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
// Silent fail - already handled in sendToLoopman
|
|
143
|
+
throw error;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Create a child logger with a different source
|
|
148
|
+
* Useful for creating sub-loggers within a service
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```typescript
|
|
152
|
+
* const mainLogger = new LoggerService({ source: "PollingService", ... });
|
|
153
|
+
* const sessionLogger = mainLogger.child("PollingSession");
|
|
154
|
+
* sessionLogger.info("Session started"); // [PollingSession] Session started
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
child(source) {
|
|
158
|
+
return new LoggerService({
|
|
159
|
+
...this.config,
|
|
160
|
+
source,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Update logger configuration (e.g., toggle debug mode)
|
|
165
|
+
*/
|
|
166
|
+
updateConfig(updates) {
|
|
167
|
+
this.config = {
|
|
168
|
+
...this.config,
|
|
169
|
+
...updates,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=logger.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.service.js","sourceRoot":"","sources":["../../src/services/logger.service.ts"],"names":[],"mappings":"AA6BA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,aAAa;IAChB,MAAM,CAAe;IAE7B,YAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG;YACZ,KAAK,EAAE,KAAK;YACZ,gBAAgB,EAAE,IAAI;YACtB,GAAG,MAAM;SACV,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,MAAc;QACtB,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAe,EAAE,IAAU;QAC/B,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,OAAe,EAAE,IAAU;QAC9B,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,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,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;gBACvB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;YACtC,CAAC;YAED,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAC9B,IAAI,CAAC,MAAM,CAAC,MAAM,EAClB,cAAc,EACd,OAAO,CACR,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,iDAAiD;YACjD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,MAAc;QAClB,OAAO,IAAI,aAAa,CAAC;YACvB,GAAG,IAAI,CAAC,MAAM;YACd,MAAM;SACP,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,OAA8B;QACzC,IAAI,CAAC,MAAM,GAAG;YACZ,GAAG,IAAI,CAAC,MAAM;YACd,GAAG,OAAO;SACX,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { DecisionContextResponse, GuidelinesResponse, LoopmanServiceConfig, LoopmanTaskResponse } from "../types";
|
|
2
|
+
import { LoggerService } from "./logger.service";
|
|
3
|
+
import { PollingService, type PollingOptions } from "./polling.service";
|
|
4
|
+
/**
|
|
5
|
+
* Service to interact with Loopman Backoffice API
|
|
6
|
+
* Handles logs, decisions, and polling
|
|
7
|
+
*/
|
|
8
|
+
export declare class LoopmanService {
|
|
9
|
+
private apiClient;
|
|
10
|
+
private config;
|
|
11
|
+
readonly polling: PollingService;
|
|
12
|
+
readonly logger: LoggerService;
|
|
13
|
+
constructor(config: LoopmanServiceConfig);
|
|
14
|
+
/**
|
|
15
|
+
* Send a log to Loopman API
|
|
16
|
+
* @deprecated Use logger.info(), logger.warn(), etc. instead
|
|
17
|
+
*/
|
|
18
|
+
sendLog(level: "debug" | "info" | "warn" | "error", message: string): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Get current user information
|
|
21
|
+
*/
|
|
22
|
+
getCurrentUser(): Promise<import("..").LoopmanUser>;
|
|
23
|
+
/**
|
|
24
|
+
* Get guidelines for the current workflow
|
|
25
|
+
* @param category - Optional category filter
|
|
26
|
+
* @returns Guidelines response with list of guidelines
|
|
27
|
+
*/
|
|
28
|
+
getGuidelines(category?: string): Promise<GuidelinesResponse>;
|
|
29
|
+
/**
|
|
30
|
+
* Get decision context (history of decisions) for the current workflow execution
|
|
31
|
+
* @returns Decision context with history of previous decisions
|
|
32
|
+
*/
|
|
33
|
+
getDecisionContext(): Promise<DecisionContextResponse>;
|
|
34
|
+
/**
|
|
35
|
+
* Get workflow categories
|
|
36
|
+
* Returns available categories for guidelines in this workflow
|
|
37
|
+
* @returns Array of category names
|
|
38
|
+
*/
|
|
39
|
+
getWorkflowCategories(): Promise<string[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Convert tool arguments to structured information items
|
|
42
|
+
* Formats tool parameters for human-readable display in Loopman UI
|
|
43
|
+
*/
|
|
44
|
+
private convertToolArgsToInformation;
|
|
45
|
+
/**
|
|
46
|
+
* Create a task in Loopman for human review of a tool call
|
|
47
|
+
* Maps tool call data to a task that humans can validate/reject/modify
|
|
48
|
+
*
|
|
49
|
+
* @param toolName - Name of the tool to be validated
|
|
50
|
+
* @param toolArgs - Arguments for the tool call
|
|
51
|
+
* @param description - Optional description of the action
|
|
52
|
+
* @param toolCallId - Optional unique ID from LangChain tool call
|
|
53
|
+
* @param businessContext - Optional business context explaining the action
|
|
54
|
+
* @param parentTaskId - Optional parent task ID to create hierarchical link
|
|
55
|
+
* @param proposedDecision - Optional proposed decision from parent task
|
|
56
|
+
* @param decisionReasoning - Optional decision reasoning from parent task
|
|
57
|
+
* @returns The created task response from Loopman API
|
|
58
|
+
*/
|
|
59
|
+
createTaskForValidation(toolName: string, toolArgs: any, description?: string, toolCallId?: string, businessContext?: string, parentTaskId?: string, proposedDecision?: string, decisionReasoning?: string): Promise<LoopmanTaskResponse>;
|
|
60
|
+
/**
|
|
61
|
+
* Get the current status of a task
|
|
62
|
+
* @param taskId - The ID of the task to check
|
|
63
|
+
* @returns The task response from Loopman API
|
|
64
|
+
*/
|
|
65
|
+
getTask(taskId: string): Promise<LoopmanTaskResponse>;
|
|
66
|
+
/**
|
|
67
|
+
* Get polling options with current configuration
|
|
68
|
+
* Helper method to construct PollingOptions for direct PollingService usage
|
|
69
|
+
*/
|
|
70
|
+
getPollingOptions(taskId: string, abortSignal?: AbortSignal): PollingOptions;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=loopman.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loopman.service.d.ts","sourceRoot":"","sources":["../../src/services/loopman.service.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EAEpB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExE;;;GAGG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,SAAS,CAAmB;IACpC,OAAO,CAAC,MAAM,CAAuB;IAGrC,SAAgB,OAAO,EAAE,cAAc,CAAC;IACxC,SAAgB,MAAM,EAAE,aAAa,CAAC;gBAE1B,MAAM,EAAE,oBAAoB;IAkCxC;;;OAGG;IACG,OAAO,CACX,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,EAC1C,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC;IAKhB;;OAEG;IACG,cAAc;IAIpB;;;;OAIG;IACG,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA6BnE;;;OAGG;IACG,kBAAkB,IAAI,OAAO,CAAC,uBAAuB,CAAC;IA0B5D;;;;O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