@ainetwork/adk-provider-memory-mongodb 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-SJ2FHHN6.js → chunk-4RSJL5V4.js} +4 -1
- package/dist/chunk-4RSJL5V4.js.map +1 -0
- package/dist/{chunk-RC275GLE.js → chunk-SXSMKZSK.js} +4 -1
- package/dist/chunk-SXSMKZSK.js.map +1 -0
- package/dist/index.cjs +6 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/models/user-workflow.model.cjs +3 -0
- package/dist/models/user-workflow.model.cjs.map +1 -1
- package/dist/models/user-workflow.model.d.cts +6 -7
- package/dist/models/user-workflow.model.d.ts +6 -7
- package/dist/models/user-workflow.model.js +1 -1
- package/dist/models/workflow-template.model.cjs +3 -0
- package/dist/models/workflow-template.model.cjs.map +1 -1
- package/dist/models/workflow-template.model.d.cts +6 -7
- package/dist/models/workflow-template.model.d.ts +6 -7
- package/dist/models/workflow-template.model.js +1 -1
- package/models/user-workflow.model.ts +9 -10
- package/models/workflow-template.model.ts +9 -10
- package/package.json +3 -3
- package/dist/chunk-RC275GLE.js.map +0 -1
- package/dist/chunk-SJ2FHHN6.js.map +0 -1
|
@@ -25,6 +25,9 @@ var WorkflowTemplateObjectSchema = new Schema(
|
|
|
25
25
|
type: String,
|
|
26
26
|
required: true
|
|
27
27
|
},
|
|
28
|
+
definition: {
|
|
29
|
+
type: Schema.Types.Mixed
|
|
30
|
+
},
|
|
28
31
|
variables: {
|
|
29
32
|
type: Schema.Types.Mixed
|
|
30
33
|
}
|
|
@@ -42,4 +45,4 @@ export {
|
|
|
42
45
|
WorkflowTemplateObjectSchema,
|
|
43
46
|
WorkflowTemplateModel
|
|
44
47
|
};
|
|
45
|
-
//# sourceMappingURL=chunk-
|
|
48
|
+
//# sourceMappingURL=chunk-4RSJL5V4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../models/workflow-template.model.ts"],"sourcesContent":["import type {\n\tWorkflowDefinition,\n\tWorkflowVariable,\n} from \"@ainetwork/adk/types/memory\";\nimport { type Document, Schema } from \"mongoose\";\nimport mongoose from \"mongoose\";\n\nexport const WorkflowTemplateObjectSchema = new Schema(\n\t{\n\t\ttemplateId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tunique: true,\n\t\t},\n\t\ttitle: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tdescription: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tactive: {\n\t\t\ttype: Boolean,\n\t\t\trequired: true,\n\t\t\tdefault: false,\n\t\t},\n\t\tcontent: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tdefinition: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t\tvariables: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t},\n\t{\n\t\ttimestamps: true,\n\t}\n);\n\nexport interface WorkflowTemplateDocument extends Document {\n\ttemplateId: string;\n\ttitle: string;\n\tdescription: string;\n\tactive: boolean;\n\tcontent: string;\n\tdefinition?: WorkflowDefinition;\n\tvariables?: Record<string, WorkflowVariable>;\n}\n\nexport const WorkflowTemplateModel = mongoose.model<WorkflowTemplateDocument>(\n\t\"WorkflowTemplate\",\n\tWorkflowTemplateObjectSchema\n);\n"],"mappings":";AAIA,SAAwB,cAAc;AACtC,OAAO,cAAc;AAEd,IAAM,+BAA+B,IAAI;AAAA,EAC/C;AAAA,IACC,YAAY;AAAA,MACX,MAAM;AAAA,MACN,UAAU;AAAA,MACV,QAAQ;AAAA,IACT;AAAA,IACA,OAAO;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,aAAa;AAAA,MACZ,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,QAAQ;AAAA,MACP,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,IACV;AAAA,IACA,SAAS;AAAA,MACR,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,YAAY;AAAA,MACX,MAAM,OAAO,MAAM;AAAA,IACpB;AAAA,IACA,WAAW;AAAA,MACV,MAAM,OAAO,MAAM;AAAA,IACpB;AAAA,EACD;AAAA,EACA;AAAA,IACC,YAAY;AAAA,EACb;AACD;AAYO,IAAM,wBAAwB,SAAS;AAAA,EAC7C;AAAA,EACA;AACD;","names":[]}
|
|
@@ -32,6 +32,9 @@ var UserWorkflowObjectSchema = new Schema(
|
|
|
32
32
|
type: String,
|
|
33
33
|
required: true
|
|
34
34
|
},
|
|
35
|
+
definition: {
|
|
36
|
+
type: Schema.Types.Mixed
|
|
37
|
+
},
|
|
35
38
|
variables: {
|
|
36
39
|
type: Schema.Types.Mixed
|
|
37
40
|
},
|
|
@@ -67,4 +70,4 @@ export {
|
|
|
67
70
|
UserWorkflowObjectSchema,
|
|
68
71
|
UserWorkflowModel
|
|
69
72
|
};
|
|
70
|
-
//# sourceMappingURL=chunk-
|
|
73
|
+
//# sourceMappingURL=chunk-SXSMKZSK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../models/user-workflow.model.ts"],"sourcesContent":["import type {\n\tWorkflowDefinition,\n\tWorkflowVariable,\n} from \"@ainetwork/adk/types/memory\";\nimport { type Document, Schema } from \"mongoose\";\nimport mongoose from \"mongoose\";\n\nexport const UserWorkflowObjectSchema = new Schema(\n\t{\n\t\tworkflowId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tunique: true,\n\t\t},\n\t\tuserId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t},\n\t\ttitle: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tdescription: {\n\t\t\ttype: String,\n\t\t},\n\t\tactive: {\n\t\t\ttype: Boolean,\n\t\t\trequired: true,\n\t\t\tdefault: false,\n\t\t},\n\t\ttemplateId: {\n\t\t\ttype: String,\n\t\t},\n\t\tcontent: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tdefinition: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t\tvariables: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t\tvariableValues: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t\tschedule: {\n\t\t\ttype: String,\n\t\t},\n\t\ttimezone: {\n\t\t\ttype: String,\n\t\t},\n\t\tlastRunAt: {\n\t\t\ttype: Number,\n\t\t},\n\t\tnextRunAt: {\n\t\t\ttype: Number,\n\t\t},\n\t\tlastThreadId: {\n\t\t\ttype: String,\n\t\t},\n\t},\n\t{\n\t\ttimestamps: true,\n\t}\n);\n\nexport interface UserWorkflowDocument extends Document {\n\tworkflowId: string;\n\tuserId: string;\n\ttitle: string;\n\tdescription?: string;\n\tactive: boolean;\n\ttemplateId?: string;\n\tcontent: string;\n\tdefinition?: WorkflowDefinition;\n\tvariables?: Record<string, WorkflowVariable>;\n\tvariableValues?: Record<string, string>;\n\tschedule?: string;\n\ttimezone?: string;\n\tlastRunAt?: number;\n\tnextRunAt?: number;\n\tlastThreadId?: string;\n}\n\nexport const UserWorkflowModel = mongoose.model<UserWorkflowDocument>(\n\t\"UserWorkflow\",\n\tUserWorkflowObjectSchema\n);\n"],"mappings":";AAIA,SAAwB,cAAc;AACtC,OAAO,cAAc;AAEd,IAAM,2BAA2B,IAAI;AAAA,EAC3C;AAAA,IACC,YAAY;AAAA,MACX,MAAM;AAAA,MACN,UAAU;AAAA,MACV,QAAQ;AAAA,IACT;AAAA,IACA,QAAQ;AAAA,MACP,MAAM;AAAA,MACN,UAAU;AAAA,MACV,OAAO;AAAA,IACR;AAAA,IACA,OAAO;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,aAAa;AAAA,MACZ,MAAM;AAAA,IACP;AAAA,IACA,QAAQ;AAAA,MACP,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,IACV;AAAA,IACA,YAAY;AAAA,MACX,MAAM;AAAA,IACP;AAAA,IACA,SAAS;AAAA,MACR,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,YAAY;AAAA,MACX,MAAM,OAAO,MAAM;AAAA,IACpB;AAAA,IACA,WAAW;AAAA,MACV,MAAM,OAAO,MAAM;AAAA,IACpB;AAAA,IACA,gBAAgB;AAAA,MACf,MAAM,OAAO,MAAM;AAAA,IACpB;AAAA,IACA,UAAU;AAAA,MACT,MAAM;AAAA,IACP;AAAA,IACA,UAAU;AAAA,MACT,MAAM;AAAA,IACP;AAAA,IACA,WAAW;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,WAAW;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,cAAc;AAAA,MACb,MAAM;AAAA,IACP;AAAA,EACD;AAAA,EACA;AAAA,IACC,YAAY;AAAA,EACb;AACD;AAoBO,IAAM,oBAAoB,SAAS;AAAA,EACzC;AAAA,EACA;AACD;","names":[]}
|
package/dist/index.cjs
CHANGED
|
@@ -480,6 +480,9 @@ var UserWorkflowObjectSchema = new import_mongoose8.Schema(
|
|
|
480
480
|
type: String,
|
|
481
481
|
required: true
|
|
482
482
|
},
|
|
483
|
+
definition: {
|
|
484
|
+
type: import_mongoose8.Schema.Types.Mixed
|
|
485
|
+
},
|
|
483
486
|
variables: {
|
|
484
487
|
type: import_mongoose8.Schema.Types.Mixed
|
|
485
488
|
},
|
|
@@ -598,6 +601,9 @@ var WorkflowTemplateObjectSchema = new import_mongoose10.Schema(
|
|
|
598
601
|
type: String,
|
|
599
602
|
required: true
|
|
600
603
|
},
|
|
604
|
+
definition: {
|
|
605
|
+
type: import_mongoose10.Schema.Types.Mixed
|
|
606
|
+
},
|
|
601
607
|
variables: {
|
|
602
608
|
type: import_mongoose10.Schema.Types.Mixed
|
|
603
609
|
}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../index.ts","../implements/base.memory.ts","../models/agent.model.ts","../implements/agent.memory.ts","../models/intent.model.ts","../implements/intent.memory.ts","../models/threads.model.ts","../models/messages.model.ts","../implements/thread.memory.ts","../models/user-workflow.model.ts","../implements/user-workflow.memory.ts","../models/workflow-template.model.ts","../implements/workflow-template.memory.ts"],"sourcesContent":["export { MongoDBMemory } from \"./implements/base.memory\";\nexport type { MongoDBMemoryConfig } from \"./implements/base.memory\";","import { IAgentMemory, IIntentMemory, IMemory, IUserWorkflowMemory, IThreadMemory, IWorkflowTemplateMemory } from \"@ainetwork/adk/modules\";\nimport mongoose from \"mongoose\";\nimport { loggers } from \"@ainetwork/adk/utils/logger\";\nimport { MongoDBAgent } from \"./agent.memory\";\nimport { MongoDBIntent } from \"./intent.memory\";\nimport { MongoDBThread } from \"./thread.memory\";\nimport { MongoDBUserWorkflow } from \"./user-workflow.memory\";\nimport { MongoDBWorkflowTemplate } from \"./workflow-template.memory\";\nimport { MessageModel } from \"../models/messages.model\";\n\nexport interface MongoDBMemoryConfig {\n uri: string;\n maxReconnectAttempts?: number;\n reconnectInterval?: number;\n maxPoolSize?: number;\n serverSelectionTimeoutMS?: number;\n socketTimeoutMS?: number;\n connectTimeoutMS?: number;\n operationTimeoutMS?: number; // Timeout for database operations\n threadTTLSeconds?: number; // TTL for thread documents (in seconds). Orphaned messages are periodically cleaned up.\n}\n\nexport class MongoDBMemory implements IMemory {\n private static instance: MongoDBMemory;\n private uri: string;\n private connected: boolean = false;\n private reconnectAttempts: number = 0;\n private maxReconnectAttempts: number;\n private reconnectInterval: number;\n private reconnecting: boolean = false;\n private connectionConfig: mongoose.ConnectOptions;\n private eventListenersSetup: boolean = false;\n private operationTimeoutMS: number;\n private threadTTLSeconds?: number;\n private orphanCleanupTimer?: ReturnType<typeof setInterval>;\n\n private agentMemory: MongoDBAgent;\n private intentMemory: MongoDBIntent;\n private threadMemory: MongoDBThread;\n private workflowTemplateMemory: MongoDBWorkflowTemplate;\n private userWorkflowMemory: MongoDBUserWorkflow;\n\n constructor(config: string | MongoDBMemoryConfig) {\n const cfg = typeof config === 'string' ? { uri: config } : config;\n\n this.uri = cfg.uri;\n this.maxReconnectAttempts = cfg.maxReconnectAttempts ?? 5;\n this.reconnectInterval = cfg.reconnectInterval ?? 5000;\n this.operationTimeoutMS = cfg.operationTimeoutMS ?? 10000; // Default 10 seconds\n if (cfg.threadTTLSeconds !== undefined && cfg.threadTTLSeconds > 0) {\n this.threadTTLSeconds = cfg.threadTTLSeconds;\n }\n this.connectionConfig = {\n maxPoolSize: cfg.maxPoolSize ?? 10,\n minPoolSize: 0,\n maxIdleTimeMS: 30000,\n serverSelectionTimeoutMS: cfg.serverSelectionTimeoutMS ?? 30000,\n socketTimeoutMS: cfg.socketTimeoutMS ?? 45000,\n connectTimeoutMS: cfg.connectTimeoutMS ?? 30000,\n bufferCommands: false,\n };\n\n if (!MongoDBMemory.instance) {\n MongoDBMemory.instance = this;\n this.setupMongooseEventListeners();\n } else {\n // Use existing instance's connection state\n this.connected = MongoDBMemory.instance.connected;\n this.operationTimeoutMS = MongoDBMemory.instance.operationTimeoutMS;\n }\n\n\t\tthis.agentMemory = new MongoDBAgent(\n\t\t\tthis.executeWithRetry.bind(this),\n\t\t\tthis.getOperationTimeout.bind(this)\n\t\t);\n\n\t\tthis.threadMemory = new MongoDBThread(\n\t\t\tthis.executeWithRetry.bind(this),\n\t\t\tthis.getOperationTimeout.bind(this)\n\t\t);\n\n\t\tthis.intentMemory = new MongoDBIntent(\n\t\t\tthis.executeWithRetry.bind(this),\n\t\t\tthis.getOperationTimeout.bind(this)\n\t\t);\n\n\t\tthis.workflowTemplateMemory = new MongoDBWorkflowTemplate(\n\t\t\tthis.executeWithRetry.bind(this),\n\t\t\tthis.getOperationTimeout.bind(this)\n\t\t);\n\n\t\tthis.userWorkflowMemory = new MongoDBUserWorkflow(\n\t\t\tthis.executeWithRetry.bind(this),\n\t\t\tthis.getOperationTimeout.bind(this)\n\t\t);\n }\n\n public getAgentMemory(): IAgentMemory {\n return this.agentMemory;\n }\n\n public getThreadMemory(): IThreadMemory {\n return this.threadMemory;\n }\n\n public getIntentMemory(): IIntentMemory {\n return this.intentMemory;\n }\n\n public getWorkflowTemplateMemory(): IWorkflowTemplateMemory {\n return this.workflowTemplateMemory;\n }\n\n public getUserWorkflowMemory(): IUserWorkflowMemory {\n return this.userWorkflowMemory;\n }\n\n private setupMongooseEventListeners(): void {\n if (this.eventListenersSetup) return;\n\n this.eventListenersSetup = true;\n\n mongoose.connection.on(\"connected\", () => {\n this.connected = true;\n this.reconnectAttempts = 0;\n this.reconnecting = false;\n loggers.agent.info(\"MongoDB connected successfully\");\n });\n\n mongoose.connection.on(\"disconnected\", () => {\n this.connected = false;\n loggers.agent.warn(\"MongoDB disconnected\");\n this.handleDisconnection();\n });\n\n mongoose.connection.on(\"error\", (error) => {\n this.connected = false;\n loggers.agent.error(\"MongoDB connection error:\", error);\n this.handleDisconnection();\n });\n\n mongoose.connection.on(\"reconnected\", () => {\n this.connected = true;\n this.reconnectAttempts = 0;\n this.reconnecting = false;\n loggers.agent.info(\"MongoDB reconnected successfully\");\n });\n }\n\n private async handleDisconnection(): Promise<void> {\n if (this.reconnecting) {\n return;\n }\n\n this.reconnecting = true;\n\n while (this.reconnectAttempts < this.maxReconnectAttempts && !this.connected) {\n this.reconnectAttempts++;\n loggers.agent.info(\n `Attempting to reconnect to MongoDB (${this.reconnectAttempts}/${this.maxReconnectAttempts})...`\n );\n\n try {\n await mongoose.connect(this.uri, this.connectionConfig);\n this.connected = true;\n this.reconnectAttempts = 0;\n this.reconnecting = false;\n loggers.agent.info(\"MongoDB reconnection successful\");\n return;\n } catch (error) {\n loggers.agent.error(\n `Reconnection attempt ${this.reconnectAttempts} failed:`,\n error\n );\n\n if (this.reconnectAttempts < this.maxReconnectAttempts) {\n await new Promise((resolve) =>\n setTimeout(resolve, this.reconnectInterval)\n );\n }\n }\n }\n\n this.reconnecting = false;\n\n if (!this.connected) {\n loggers.agent.error(\n `Failed to reconnect to MongoDB after ${this.maxReconnectAttempts} attempts`\n );\n }\n }\n\n public async connect(): Promise<void> {\n if (this.connected) {\n return;\n }\n\n try {\n await mongoose.connect(this.uri, this.connectionConfig);\n this.connected = true;\n this.reconnectAttempts = 0;\n await this.setupTTLIndex();\n this.startOrphanCleanup();\n } catch (error) {\n loggers.agent.error(\"Failed to connect to MongoDB:\", error);\n throw error;\n }\n }\n\n public async disconnect(): Promise<void> {\n if (!this.connected) {\n return;\n }\n\n try {\n if (this.orphanCleanupTimer) {\n clearInterval(this.orphanCleanupTimer);\n this.orphanCleanupTimer = undefined;\n }\n await mongoose.disconnect();\n this.connected = false;\n } catch (error) {\n loggers.agent.error(\"Failed to disconnect from MongoDB:\", error);\n throw error;\n }\n }\n\n public isConnected(): boolean {\n return this.connected;\n }\n\n private async ensureConnection(): Promise<void> {\n if (!this.connected && !this.reconnecting) {\n await this.connect();\n }\n\n // Wait for reconnection if in progress\n const maxWaitTime = 30000; // 30 seconds\n const startTime = Date.now();\n while (this.reconnecting && Date.now() - startTime < maxWaitTime) {\n await new Promise((resolve) => setTimeout(resolve, 100));\n }\n\n if (!this.connected) {\n throw new Error(\"MongoDB is not connected and reconnection failed\");\n }\n }\n\n private async setupTTLIndex(): Promise<void> {\n if (this.threadTTLSeconds === undefined) return;\n\n try {\n const db = mongoose.connection.db;\n if (!db) return;\n\n const collection = db.collection('threads');\n const indexes = await collection.indexes();\n const existingTTL = indexes.find(\n (idx) => idx.key?.updatedAt !== undefined && idx.expireAfterSeconds !== undefined\n );\n\n if (existingTTL) {\n if (existingTTL.expireAfterSeconds !== this.threadTTLSeconds) {\n await db.command({\n collMod: 'threads',\n index: { keyPattern: { updatedAt: 1 }, expireAfterSeconds: this.threadTTLSeconds },\n });\n loggers.agent.info(`Thread TTL index updated to ${this.threadTTLSeconds} seconds`);\n }\n } else {\n await collection.createIndex(\n { updatedAt: 1 },\n { expireAfterSeconds: this.threadTTLSeconds },\n );\n loggers.agent.info(`Thread TTL index created with ${this.threadTTLSeconds} seconds`);\n }\n } catch (error) {\n loggers.agent.error('Failed to setup TTL index:', error);\n }\n }\n\n private startOrphanCleanup(): void {\n if (this.threadTTLSeconds === undefined) return;\n if (this.orphanCleanupTimer) return;\n\n // Run cleanup at half the TTL interval, with a minimum of 60s and maximum of 1 hour\n const intervalMs = Math.max(60_000, Math.min(this.threadTTLSeconds * 500, 3_600_000));\n this.orphanCleanupTimer = setInterval(() => {\n this.cleanupOrphanedMessages().catch((error) => {\n loggers.agent.error('Orphaned message cleanup failed:', error);\n });\n }, intervalMs);\n\n loggers.agent.info(`Orphaned message cleanup scheduled every ${Math.round(intervalMs / 1000)}s`);\n }\n\n private async cleanupOrphanedMessages(): Promise<void> {\n if (!this.connected) return;\n\n try {\n const db = mongoose.connection.db;\n if (!db) return;\n\n const existingThreadIds = await db.collection('threads').distinct('threadId');\n const result = await MessageModel.deleteMany({\n threadId: { $nin: existingThreadIds },\n });\n\n if (result.deletedCount > 0) {\n loggers.agent.info(`Cleaned up ${result.deletedCount} orphaned messages`);\n }\n } catch (error) {\n loggers.agent.error('Failed to cleanup orphaned messages:', error);\n }\n }\n\n /**\n * Get the operation timeout in milliseconds\n */\n protected getOperationTimeout(): number {\n return this.operationTimeoutMS;\n }\n\n /**\n * Execute a database operation with automatic retry on connection errors\n * Note: Use mongoose's maxTimeMS option in queries for timeout control\n */\n protected async executeWithRetry<T>(\n operation: () => Promise<T>,\n operationName: string = \"Database operation\"\n ): Promise<T> {\n await this.ensureConnection();\n\n try {\n return await operation();\n } catch (error: any) {\n // Check if it's a timeout error from MongoDB\n if (error.code === 50 || error.message?.includes(\"operation exceeded time limit\")) {\n loggers.agent.error(`${operationName} exceeded time limit`);\n throw error;\n }\n\n // Check if it's a TooManyLogicalSessions error\n if (error.code === 261 || error.codeName === \"TooManyLogicalSessions\") {\n loggers.agent.warn(\n `${operationName} failed due to too many sessions, disconnecting to release sessions...`\n );\n\n try {\n await mongoose.disconnect();\n this.connected = false;\n } catch (disconnectError) {\n loggers.agent.error(\"Failed to disconnect during session cleanup:\", disconnectError);\n }\n\n await new Promise((resolve) => setTimeout(resolve, 5000));\n await this.ensureConnection();\n\n try {\n return await operation();\n } catch (retryError: any) {\n loggers.agent.error(`${operationName} failed after session cleanup retry:`, retryError);\n throw retryError;\n }\n }\n\n // Check if it's a connection-related error\n if (\n error.name === \"MongoNetworkError\" ||\n error.name === \"MongoServerError\" ||\n error.message?.includes(\"connection\") ||\n error.message?.includes(\"disconnect\")\n ) {\n loggers.agent.warn(\n `${operationName} failed due to connection issue, attempting reconnection...`\n );\n\n await this.ensureConnection();\n\n // Retry the operation once after reconnection\n try {\n return await operation();\n } catch (retryError: any) {\n loggers.agent.error(`${operationName} failed after retry:`, retryError);\n throw retryError;\n }\n }\n\n // If it's not a connection error, just throw it\n throw error;\n }\n }\n}\n","import { type Document, Schema } from \"mongoose\";\nimport mongoose from \"mongoose\";\n\nexport const AgentObjectSchema = new Schema(\n\t{\n\t\tid: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tunique: true,\n\t\t},\n\t\tprompt: {\n\t\t\ttype: String,\n\t\t},\n\t},\n);\n\nexport interface AgentDocument extends Document {\n\tid: string;\n\tprompt: string;\n}\n\nexport const AgentModel = mongoose.model<AgentDocument>(\"Agent\", AgentObjectSchema);\n","import { IAgentMemory } from \"@ainetwork/adk/modules\";\nimport { AgentModel } from \"../models/agent.model\";\n\nexport type ExecuteWithRetryFn = <T>(\n operation: () => Promise<T>,\n operationName?: string\n) => Promise<T>;\n\nexport type GetOperationTimeoutFn = () => number;\n\ntype PromptDocument = {\n id: string;\n prompt: string;\n}\n\nexport class MongoDBAgent implements IAgentMemory {\n private executeWithRetry: ExecuteWithRetryFn;\n private getOperationTimeout: GetOperationTimeoutFn;\n\n constructor(\n executeWithRetry: ExecuteWithRetryFn,\n getOperationTimeout: GetOperationTimeoutFn\n ) {\n this.executeWithRetry = executeWithRetry;\n this.getOperationTimeout = getOperationTimeout;\n }\n\n public async getAgentPrompt(): Promise<string> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const metadata = await AgentModel.findOne({\n id: \"agent_prompt\"\n }).maxTimeMS(timeout)\n .lean<PromptDocument>();\n return metadata?.prompt || \"\";\n }, \"getAgentPrompt()\");\n };\n \n public async updateAgentPrompt(prompt: string): Promise<void> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n await AgentModel.updateOne({\n id: \"agent_prompt\",\n }, { \"prompt\": prompt }, { upsert: true }).maxTimeMS(timeout);\n }, \"updateAgentPrompt()\");\n };\n\n public async getAggregatePrompt(): Promise<string> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const metadata = await AgentModel.findOne({\n id: \"aggregate_prompt\"\n }).maxTimeMS(timeout)\n .lean<PromptDocument>();\n return metadata?.prompt || \"\";\n }, \"getAggregatePrompt()\");\n };\n\n public async getGenerateTitlePrompt(): Promise<string> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const metadata = await AgentModel.findOne({\n id: \"generate_title_prompt\"\n }).maxTimeMS(timeout)\n .lean<PromptDocument>();\n return metadata?.prompt || \"\";\n }, \"getGenerateTitlePrompt()\");\n };\n\n public async getSingleTriggerPrompt(): Promise<string> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const metadata = await AgentModel.findOne({\n id: \"single_trigger_prompt\"\n }).maxTimeMS(timeout)\n .lean<PromptDocument>();\n return metadata?.prompt || \"\";\n }, \"getSingleTriggerPrompt()\");\n };\n\n public async getMultiTriggerPrompt(): Promise<string> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const metadata = await AgentModel.findOne({\n id: \"multi_trigger_prompt\"\n }).maxTimeMS(timeout)\n .lean<PromptDocument>();\n return metadata?.prompt || \"\";\n }, \"getMultiTriggerPrompt()\");\n };\n\n public async getToolSelectPrompt(): Promise<string> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const metadata = await AgentModel.findOne({\n id: \"tool_select_prompt\"\n }).maxTimeMS(timeout)\n .lean<PromptDocument>();\n return metadata?.prompt || \"\";\n }, \"getToolSelectPrompt()\");\n };\n\n public async getPIIDetectPrompt(): Promise<string> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const metadata = await AgentModel.findOne({\n id: \"pii_detect_prompt\"\n }).maxTimeMS(timeout)\n .lean<PromptDocument>();\n return metadata?.prompt || \"\";\n }, \"getPIIDetectPrompt()\");\n };\n\n public async getPIIFilterPrompt(): Promise<string> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const metadata = await AgentModel.findOne({\n id: \"pii_filter_prompt\"\n }).maxTimeMS(timeout)\n .lean<PromptDocument>();\n return metadata?.prompt || \"\";\n }, \"getPIIFilterPrompt()\");\n };\n}\n","import { Intent } from \"@ainetwork/adk/types/memory\";\nimport mongoose, { type Document, Schema } from \"mongoose\";\n\nconst IntentObjectSchema = new Schema(\n\t{\n\t\tid: { \n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t\tunique: true,\n\t\t},\n\t\tname: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t},\n\t\tdescription: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tprompt: {\n\t\t\ttype: String,\n\t\t\trequired: false,\n\t\t},\n\t\tstatus: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\ttriggeringSentences: {\n\t\t\ttype: [String],\n\t\t\trequired: false,\n\t\t},\n\t\ttags: {\n\t\t\ttype: [String],\n\t\t\trequired: false,\n\t\t},\n\t\ttoolChoice: {\n\t\t\ttype: String,\n\t\t\tenum: [\"auto\", \"required\"],\n\t\t\trequired: false,\n\t\t},\n\t},\n);\n\nexport interface IntentDocument extends Omit<Document, 'id'>, Omit<Intent, 'id'> {\n\tid: string;\n}\n\nexport const IntentModel = mongoose.model<IntentDocument>(\"Intent\", IntentObjectSchema);","import type { Intent } from \"@ainetwork/adk/types/memory\";\nimport { IIntentMemory } from \"@ainetwork/adk/modules\";\nimport { IntentModel } from \"../models/intent.model\";\n\nexport type ExecuteWithRetryFn = <T>(\n operation: () => Promise<T>,\n operationName?: string\n) => Promise<T>;\n\nexport type GetOperationTimeoutFn = () => number;\n\nexport class MongoDBIntent implements IIntentMemory {\n private executeWithRetry: ExecuteWithRetryFn;\n private getOperationTimeout: GetOperationTimeoutFn;\n\n constructor(\n executeWithRetry: ExecuteWithRetryFn,\n getOperationTimeout: GetOperationTimeoutFn\n ) {\n this.executeWithRetry = executeWithRetry;\n this.getOperationTimeout = getOperationTimeout;\n }\n\n public async getIntent(intentId: string): Promise<Intent | undefined> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const intent = await IntentModel.findOne({ id: intentId })\n .maxTimeMS(timeout)\n .lean<Intent>();\n return intent || undefined;\n }, `getIntent(${intentId})`);\n };\n\n public async getIntentByName(intentName: string): Promise<Intent | undefined> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const intent = await IntentModel.findOne({ name: intentName })\n .maxTimeMS(timeout)\n .lean<Intent>();\n return intent || undefined;\n }, `getIntentByName(${intentName})`);\n }\n\n public async saveIntent(intent: Intent): Promise<void> {\n return this.executeWithRetry(async () => {\n await IntentModel.create(intent);\n }, `saveIntent(${intent.id})`);\n };\n\n public async updateIntent(intentId: string, intent: Intent): Promise<void> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n await IntentModel.updateOne({\n id: intentId,\n }, intent).maxTimeMS(timeout);\n }, `updateIntent(${intentId})`);\n };\n\n public async deleteIntent(intentId: string): Promise<void> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n await IntentModel.deleteOne({ id: intentId }).maxTimeMS(timeout);\n }, `deleteIntent(${intentId})`);\n };\n\n public async listIntents(): Promise<Intent[]> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const intents = await IntentModel.find()\n .maxTimeMS(timeout)\n .lean<Intent[]>();\n return intents;\n }, `listIntents()`);\n };\n}\n","import { ThreadType } from \"@ainetwork/adk/types/memory\";\nimport { type Document, Schema } from \"mongoose\";\nimport mongoose from \"mongoose\";\n\nexport const ThreadObjectSchema = new Schema(\n\t{\n\t\ttype: {\n\t\t\ttype: String,\n\t\t\tenum: Object.values(ThreadType),\n\t\t\trequired: true,\n\t\t},\n\t\tthreadId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t},\n\t\tuserId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t},\n\t\ttitle: {\n\t\t\ttype: String,\n\t\t\trequired: false,\n\t\t},\n\t\tisPinned: {\n\t\t\ttype: Boolean,\n\t\t\trequired: false,\n\t\t\tdefault: false,\n\t\t},\n\t\tworkflowId: {\n\t\t\ttype: String,\n\t\t\trequired: false,\n\t\t\tindex: true,\n\t\t},\n\t},\n\t{\n\t\ttimestamps: true,\n\t},\n);\n\nexport interface ThreadDocument extends Document {\n\ttype: ThreadType;\n\tthreadId: string;\n\tuserId: string;\n\ttitle: string;\n\tisPinned: boolean;\n\tworkflowId?: string;\n\tcreatedAt: Date;\n\tupdatedAt: Date;\n}\n\nexport const ThreadModel = mongoose.model<ThreadDocument>(\"Thread\", ThreadObjectSchema);\n","import { MessageRole } from \"@ainetwork/adk/types/memory\";\nimport { type Document, Schema } from \"mongoose\";\nimport mongoose from \"mongoose\";\n\n// MessageContentObject schema\nexport const MessageContentObjectSchema = new Schema(\n\t{\n\t\ttype: { type: String, required: true },\n\t\tparts: { type: [Schema.Types.Mixed], required: true },\n\t},\n\t{ _id: false },\n);\n\n// MessageObject schema - 개별 문서로 저장\nexport const MessageObjectSchema = new Schema(\n\t{\n\t\tmessageId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t},\n\t\tthreadId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t},\n\t\tuserId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t},\n\t\trole: {\n\t\t\ttype: String,\n\t\t\tenum: Object.values(MessageRole),\n\t\t\trequired: true,\n\t\t},\n\t\tcontent: {\n\t\t\ttype: MessageContentObjectSchema,\n\t\t\trequired: true,\n\t\t},\n\t\ttimestamp: {\n\t\t\ttype: Number,\n\t\t\trequired: true,\n\t\t},\n\t\tmetadata: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t\tdefault: {},\n\t\t},\n\t},\n\t{\n\t\ttimestamps: true,\n\t},\n);\n\nMessageObjectSchema.index({ threadId: 1, messageId: 1 }, { unique: true });\n\n// Message Document interface\nexport interface MessageDocument extends Document {\n\tmessageId: string;\n\tthreadId: string;\n\tuserId: string;\n\trole: MessageRole;\n\tcontent: {\n\t\ttype: string;\n\t\tparts: any[];\n\t};\n\ttimestamp: number;\n\tcreatedAt: Date;\n\tupdatedAt: Date;\n\tmetadata?: { [key: string]: unknown };\n}\n\nexport const MessageModel = mongoose.model<MessageDocument>(\"Message\", MessageObjectSchema);","import type { MessageObject, ThreadMetadata, ThreadObject, ThreadType, ThreadFilter } from \"@ainetwork/adk/types/memory\";\nimport { MessageRole } from \"@ainetwork/adk/types/memory\";\nimport { IThreadMemory } from \"@ainetwork/adk/modules\";\nimport { ThreadDocument, ThreadModel } from \"../models/threads.model\";\nimport { MessageDocument, MessageModel } from \"../models/messages.model\";\nimport { loggers } from \"@ainetwork/adk/utils/logger\";\n\nexport type ExecuteWithRetryFn = <T>(\n operation: () => Promise<T>,\n operationName?: string\n) => Promise<T>;\n\nexport type GetOperationTimeoutFn = () => number;\n\nexport class MongoDBThread implements IThreadMemory {\n private executeWithRetry: ExecuteWithRetryFn;\n private getOperationTimeout: GetOperationTimeoutFn;\n\n constructor(\n executeWithRetry: ExecuteWithRetryFn,\n getOperationTimeout: GetOperationTimeoutFn\n ) {\n this.executeWithRetry = executeWithRetry;\n this.getOperationTimeout = getOperationTimeout;\n }\n\n public async getThread(\n userId: string,\n threadId: string\n ): Promise<ThreadObject | undefined> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const thread = await ThreadModel.findOne({ threadId, userId }).maxTimeMS(timeout);\n const messages = await MessageModel.find({ threadId, userId })\n .sort({ timestamp: 1 })\n .maxTimeMS(timeout);\n\n if (!thread) return undefined;\n\n loggers.agent.debug(`Found ${messages.length} messages for thread ${threadId}`);\n\n const threadObject: ThreadObject = {\n threadId: thread.threadId,\n userId: thread.userId,\n type: thread.type as ThreadType,\n title: thread.title || \"New thread\",\n isPinned: thread.isPinned ?? false,\n workflowId: thread.workflowId,\n messages: []\n };\n messages.forEach((message: MessageDocument) => {\n threadObject.messages.push({\n messageId: message.messageId,\n role: message.role as MessageRole,\n content: message.content,\n timestamp: message.timestamp,\n metadata: message.metadata,\n });\n });\n\n return threadObject;\n }, `getThread(${userId}, ${threadId})`);\n };\n\n public async createThread(\n type: ThreadType,\n userId: string,\n threadId: string,\n title: string,\n workflowId?: string,\n ): Promise<ThreadObject> {\n return this.executeWithRetry(async () => {\n await ThreadModel.create({\n type,\n userId,\n threadId,\n title,\n workflowId,\n });\n\n return { type, userId, threadId, title, workflowId, messages: []};\n }, `createThread(${userId}, ${threadId})`);\n };\n\n public async addMessagesToThread(\n userId: string,\n threadId: string,\n messages: MessageObject[]\n ): Promise<void> {\n return this.executeWithRetry(async () => {\n if (messages.length > 0) {\n const messageIds = messages.map((m) => m.messageId);\n await MessageModel.deleteMany({ threadId, userId, messageId: { $in: messageIds } });\n await MessageModel.insertMany(\n messages.map((message) => ({\n threadId,\n messageId: message.messageId,\n userId,\n role: message.role,\n content: message.content,\n timestamp: message.timestamp,\n metadata: message.metadata,\n }))\n );\n }\n await ThreadModel.updateOne(\n { threadId, userId },\n { $set: { updatedAt: new Date() } }\n );\n }, `addMessagesToThread(${userId}, ${threadId})`);\n };\n\n public async deleteThread(userId: string, threadId: string): Promise<void> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n\n // Delete all messages for this thread\n await MessageModel.deleteMany({ userId, threadId }).maxTimeMS(timeout);\n\n // Delete the thread itself\n await ThreadModel.deleteOne({ userId, threadId }).maxTimeMS(timeout);\n }, `deleteThread(${userId}, ${threadId})`);\n };\n\n public async listThreads(userId: string, filter?: ThreadFilter): Promise<ThreadMetadata[]> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const query: Record<string, any> = { userId };\n if (filter?.workflowId) query.workflowId = filter.workflowId;\n if (filter?.type) query.type = filter.type;\n const threads = await ThreadModel.find(query)\n .sort({ updatedAt: -1 })\n .maxTimeMS(timeout);\n const data: ThreadMetadata[] = threads.map((thread: ThreadDocument) => {\n return {\n type: thread.type,\n userId,\n threadId: thread.threadId,\n title: thread.title,\n isPinned: thread.isPinned ?? false,\n workflowId: thread.workflowId,\n createdAt: thread.createdAt?.toISOString(),\n updatedAt: thread.updatedAt?.toISOString(),\n } as ThreadMetadata;\n })\n return data;\n }, `listThreads(${userId})`);\n };\n\n public async updateThreadPin(\n userId: string,\n threadId: string,\n isPinned: boolean\n ): Promise<void> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n await ThreadModel.updateOne(\n { threadId, userId },\n { $set: { isPinned } }\n ).maxTimeMS(timeout);\n }, `updateThreadPin(${userId}, ${threadId})`);\n };\n}\n","import { type Document, Schema } from \"mongoose\";\nimport mongoose from \"mongoose\";\n\nexport const UserWorkflowObjectSchema = new Schema(\n\t{\n\t\tworkflowId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tunique: true,\n\t\t},\n\t\tuserId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t},\n\t\ttitle: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tdescription: {\n\t\t\ttype: String,\n\t\t},\n\t\tactive: {\n\t\t\ttype: Boolean,\n\t\t\trequired: true,\n\t\t\tdefault: false,\n\t\t},\n\t\ttemplateId: {\n\t\t\ttype: String,\n\t\t},\n\t\tcontent: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tvariables: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t\tvariableValues: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t\tschedule: {\n\t\t\ttype: String,\n\t\t},\n\t\ttimezone: {\n\t\t\ttype: String,\n\t\t},\n\t\tlastRunAt: {\n\t\t\ttype: Number,\n\t\t},\n\t\tnextRunAt: {\n\t\t\ttype: Number,\n\t\t},\n\t\tlastThreadId: {\n\t\t\ttype: String,\n\t\t},\n\t},\n\t{\n\t\ttimestamps: true,\n\t}\n);\n\nexport interface UserWorkflowDocument extends Document {\n\tworkflowId: string;\n\tuserId: string;\n\ttitle: string;\n\tdescription?: string;\n\tactive: boolean;\n\ttemplateId?: string;\n\tcontent: string;\n\tvariables?: Record<\n\t\tstring,\n\t\t{\n\t\t\tid: string;\n\t\t\tlabel: string;\n\t\t\ttype: \"select\" | \"date_range\" | \"date_parts\" | \"text\" | \"number\";\n\t\t\toptions?: Array<string>;\n\t\t\tresolveAt?: \"creation\" | \"execution\";\n\t\t}\n\t>;\n\tvariableValues?: Record<string, string>;\n\tschedule?: string;\n\ttimezone?: string;\n\tlastRunAt?: number;\n\tnextRunAt?: number;\n\tlastThreadId?: string;\n}\n\nexport const UserWorkflowModel = mongoose.model<UserWorkflowDocument>(\n\t\"UserWorkflow\",\n\tUserWorkflowObjectSchema\n);\n","import type { IUserWorkflowMemory } from \"@ainetwork/adk/modules\";\nimport type { UserWorkflow } from \"@ainetwork/adk/types/memory\";\nimport { UserWorkflowModel } from \"../models/user-workflow.model\";\n\nexport type ExecuteWithRetryFn = <T>(\n operation: () => Promise<T>,\n operationName?: string\n) => Promise<T>;\n\nexport type GetOperationTimeoutFn = () => number;\n\nexport class MongoDBUserWorkflow implements IUserWorkflowMemory {\n private executeWithRetry: ExecuteWithRetryFn;\n private getOperationTimeout: GetOperationTimeoutFn;\n\n constructor(\n executeWithRetry: ExecuteWithRetryFn,\n getOperationTimeout: GetOperationTimeoutFn\n ) {\n this.executeWithRetry = executeWithRetry;\n this.getOperationTimeout = getOperationTimeout;\n }\n\n public async createUserWorkflow(workflow: UserWorkflow): Promise<UserWorkflow> {\n return this.executeWithRetry(async () => {\n const created = await UserWorkflowModel.create(workflow);\n return created.toObject() as UserWorkflow;\n }, \"createUserWorkflow()\");\n }\n\n public async getUserWorkflow(workflowId: string): Promise<UserWorkflow | undefined> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const workflow = await UserWorkflowModel.findOne({ workflowId })\n .maxTimeMS(timeout)\n .lean<UserWorkflow>();\n return workflow || undefined;\n }, \"getUserWorkflow()\");\n }\n\n public async updateUserWorkflow(workflowId: string, updates: Partial<UserWorkflow>): Promise<void> {\n if (!updates.userId) {\n throw new Error(\"userId is required for updateUserWorkflow\");\n }\n\n const { userId, workflowId: _workflowId, ...mutableUpdates } = updates;\n\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n await UserWorkflowModel.updateOne(\n { workflowId, userId },\n { $set: mutableUpdates }\n ).maxTimeMS(timeout);\n }, \"updateUserWorkflow()\");\n }\n\n public async deleteUserWorkflow(workflowId: string, userId: string): Promise<void> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n await UserWorkflowModel.deleteOne({ workflowId, userId }).maxTimeMS(timeout);\n }, \"deleteUserWorkflow()\");\n }\n\n public async listUserWorkflows(userId?: string): Promise<UserWorkflow[]> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const query = userId ? { userId } : {};\n const workflows = await UserWorkflowModel.find(query)\n .maxTimeMS(timeout)\n .lean<UserWorkflow[]>();\n return workflows;\n }, \"listUserWorkflows()\");\n }\n\n public async listActiveScheduledWorkflows(): Promise<UserWorkflow[]> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const workflows = await UserWorkflowModel.find({\n active: true,\n schedule: { $exists: true, $ne: null },\n })\n .maxTimeMS(timeout)\n .lean<UserWorkflow[]>();\n return workflows;\n }, \"listActiveScheduledWorkflows()\");\n }\n}\n","import { type Document, Schema } from \"mongoose\";\nimport mongoose from \"mongoose\";\n\nexport const WorkflowTemplateObjectSchema = new Schema(\n\t{\n\t\ttemplateId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tunique: true,\n\t\t},\n\t\ttitle: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tdescription: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tactive: {\n\t\t\ttype: Boolean,\n\t\t\trequired: true,\n\t\t\tdefault: false,\n\t\t},\n\t\tcontent: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tvariables: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t},\n\t{\n\t\ttimestamps: true,\n\t}\n);\n\nexport interface WorkflowTemplateDocument extends Document {\n\ttemplateId: string;\n\ttitle: string;\n\tdescription: string;\n\tactive: boolean;\n\tcontent: string;\n\tvariables?: Record<\n\t\tstring,\n\t\t{\n\t\t\tid: string;\n\t\t\tlabel: string;\n\t\t\ttype: \"select\" | \"date_range\" | \"date_parts\" | \"text\" | \"number\";\n\t\t\toptions?: Array<string>;\n\t\t\tresolveAt?: \"creation\" | \"execution\";\n\t\t}\n\t>;\n}\n\nexport const WorkflowTemplateModel = mongoose.model<WorkflowTemplateDocument>(\n\t\"WorkflowTemplate\",\n\tWorkflowTemplateObjectSchema\n);\n","import type { IWorkflowTemplateMemory } from \"@ainetwork/adk/modules\";\nimport type { WorkflowTemplate } from \"@ainetwork/adk/types/memory\";\nimport { WorkflowTemplateModel } from \"../models/workflow-template.model\";\n\nexport type ExecuteWithRetryFn = <T>(\n operation: () => Promise<T>,\n operationName?: string\n) => Promise<T>;\n\nexport type GetOperationTimeoutFn = () => number;\n\nexport class MongoDBWorkflowTemplate implements IWorkflowTemplateMemory {\n private executeWithRetry: ExecuteWithRetryFn;\n private getOperationTimeout: GetOperationTimeoutFn;\n\n constructor(\n executeWithRetry: ExecuteWithRetryFn,\n getOperationTimeout: GetOperationTimeoutFn\n ) {\n this.executeWithRetry = executeWithRetry;\n this.getOperationTimeout = getOperationTimeout;\n }\n\n public async createTemplate(template: WorkflowTemplate): Promise<WorkflowTemplate> {\n return this.executeWithRetry(async () => {\n const created = await WorkflowTemplateModel.create(template);\n return created.toObject() as WorkflowTemplate;\n }, \"createTemplate()\");\n }\n\n public async getTemplate(templateId: string): Promise<WorkflowTemplate | undefined> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const template = await WorkflowTemplateModel.findOne({ templateId })\n .maxTimeMS(timeout)\n .lean<WorkflowTemplate>();\n return template || undefined;\n }, \"getTemplate()\");\n }\n\n public async updateTemplate(templateId: string, updates: Partial<WorkflowTemplate>): Promise<void> {\n const { templateId: _templateId, ...mutableUpdates } = updates;\n\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n await WorkflowTemplateModel.updateOne(\n { templateId },\n { $set: mutableUpdates }\n ).maxTimeMS(timeout);\n }, \"updateTemplate()\");\n }\n\n public async deleteTemplate(templateId: string): Promise<void> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n await WorkflowTemplateModel.deleteOne({ templateId }).maxTimeMS(timeout);\n }, \"deleteTemplate()\");\n }\n\n public async listTemplates(): Promise<WorkflowTemplate[]> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const templates = await WorkflowTemplateModel.find()\n .maxTimeMS(timeout)\n .lean<WorkflowTemplate[]>();\n return templates;\n }, \"listTemplates()\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;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AEnB,UAAI,MAAM,SAAS,MAAM,MAAM,SAAS,SAAS,+BAA+B,GAAG;AACjF,+BAAQ,MAAM,MAAM,GAAG,aAAa,sBAAsB;AAC1D,cAAM;AAAA,MACR;AAGA,UAAI,MAAM,SAAS,OAAO,MAAM,aAAa,0BAA0B;AACrE,+BAAQ,MAAM;AAAA,UACZ,GAAG,aAAa;AAAA,QAClB;AAEA,YAAI;AACF,gBAAM,kBAAAA,QAAS,WAAW;AAC1B,eAAK,YAAY;AAAA,QACnB,SAAS,iBAAiB;AACxB,iCAAQ,MAAM,MAAM,gDAAgD,eAAe;AAAA,QACrF;AAEA,cAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,GAAI,CAAC;AACxD,cAAM,KAAK,iBAAiB;AAE5B,YAAI;AACF,iBAAO,MAAM,UAAU;AAAA,QACzB,SAAS,YAAiB;AACxB,iCAAQ,MAAM,MAAM,GAAG,aAAa,wCAAwC,UAAU;AACtF,gBAAM;AAAA,QACR;AAAA,MACF;AAGA,UACE,MAAM,SAAS,uBACf,MAAM,SAAS,sBACf,MAAM,SAAS,SAAS,YAAY,KACpC,MAAM,SAAS,SAAS,YAAY,GACpC;AACA,+BAAQ,MAAM;AAAA,UACZ,GAAG,aAAa;AAAA,QAClB;AAEA,cAAM,KAAK,iBAAiB;AAG5B,YAAI;AACF,iBAAO,MAAM,UAAU;AAAA,QACzB,SAAS,YAAiB;AACxB,iCAAQ,MAAM,MAAM,GAAG,aAAa,wBAAwB,UAAU;AACtE,gBAAM;AAAA,QACR;AAAA,MACF;AAGA,YAAM;AAAA,IACR;AAAA,EACF;AACF;","names":["import_mongoose","import_logger","import_mongoose","mongoose","import_mongoose","mongoose","import_mongoose","mongoose","import_memory","import_mongoose","mongoose","import_mongoose","mongoose","import_mongoose","mongoose","mongoose"]}
|
|
1
|
+
{"version":3,"sources":["../index.ts","../implements/base.memory.ts","../models/agent.model.ts","../implements/agent.memory.ts","../models/intent.model.ts","../implements/intent.memory.ts","../models/threads.model.ts","../models/messages.model.ts","../implements/thread.memory.ts","../models/user-workflow.model.ts","../implements/user-workflow.memory.ts","../models/workflow-template.model.ts","../implements/workflow-template.memory.ts"],"sourcesContent":["export { MongoDBMemory } from \"./implements/base.memory\";\nexport type { MongoDBMemoryConfig } from \"./implements/base.memory\";","import { IAgentMemory, IIntentMemory, IMemory, IUserWorkflowMemory, IThreadMemory, IWorkflowTemplateMemory } from \"@ainetwork/adk/modules\";\nimport mongoose from \"mongoose\";\nimport { loggers } from \"@ainetwork/adk/utils/logger\";\nimport { MongoDBAgent } from \"./agent.memory\";\nimport { MongoDBIntent } from \"./intent.memory\";\nimport { MongoDBThread } from \"./thread.memory\";\nimport { MongoDBUserWorkflow } from \"./user-workflow.memory\";\nimport { MongoDBWorkflowTemplate } from \"./workflow-template.memory\";\nimport { MessageModel } from \"../models/messages.model\";\n\nexport interface MongoDBMemoryConfig {\n uri: string;\n maxReconnectAttempts?: number;\n reconnectInterval?: number;\n maxPoolSize?: number;\n serverSelectionTimeoutMS?: number;\n socketTimeoutMS?: number;\n connectTimeoutMS?: number;\n operationTimeoutMS?: number; // Timeout for database operations\n threadTTLSeconds?: number; // TTL for thread documents (in seconds). Orphaned messages are periodically cleaned up.\n}\n\nexport class MongoDBMemory implements IMemory {\n private static instance: MongoDBMemory;\n private uri: string;\n private connected: boolean = false;\n private reconnectAttempts: number = 0;\n private maxReconnectAttempts: number;\n private reconnectInterval: number;\n private reconnecting: boolean = false;\n private connectionConfig: mongoose.ConnectOptions;\n private eventListenersSetup: boolean = false;\n private operationTimeoutMS: number;\n private threadTTLSeconds?: number;\n private orphanCleanupTimer?: ReturnType<typeof setInterval>;\n\n private agentMemory: MongoDBAgent;\n private intentMemory: MongoDBIntent;\n private threadMemory: MongoDBThread;\n private workflowTemplateMemory: MongoDBWorkflowTemplate;\n private userWorkflowMemory: MongoDBUserWorkflow;\n\n constructor(config: string | MongoDBMemoryConfig) {\n const cfg = typeof config === 'string' ? { uri: config } : config;\n\n this.uri = cfg.uri;\n this.maxReconnectAttempts = cfg.maxReconnectAttempts ?? 5;\n this.reconnectInterval = cfg.reconnectInterval ?? 5000;\n this.operationTimeoutMS = cfg.operationTimeoutMS ?? 10000; // Default 10 seconds\n if (cfg.threadTTLSeconds !== undefined && cfg.threadTTLSeconds > 0) {\n this.threadTTLSeconds = cfg.threadTTLSeconds;\n }\n this.connectionConfig = {\n maxPoolSize: cfg.maxPoolSize ?? 10,\n minPoolSize: 0,\n maxIdleTimeMS: 30000,\n serverSelectionTimeoutMS: cfg.serverSelectionTimeoutMS ?? 30000,\n socketTimeoutMS: cfg.socketTimeoutMS ?? 45000,\n connectTimeoutMS: cfg.connectTimeoutMS ?? 30000,\n bufferCommands: false,\n };\n\n if (!MongoDBMemory.instance) {\n MongoDBMemory.instance = this;\n this.setupMongooseEventListeners();\n } else {\n // Use existing instance's connection state\n this.connected = MongoDBMemory.instance.connected;\n this.operationTimeoutMS = MongoDBMemory.instance.operationTimeoutMS;\n }\n\n\t\tthis.agentMemory = new MongoDBAgent(\n\t\t\tthis.executeWithRetry.bind(this),\n\t\t\tthis.getOperationTimeout.bind(this)\n\t\t);\n\n\t\tthis.threadMemory = new MongoDBThread(\n\t\t\tthis.executeWithRetry.bind(this),\n\t\t\tthis.getOperationTimeout.bind(this)\n\t\t);\n\n\t\tthis.intentMemory = new MongoDBIntent(\n\t\t\tthis.executeWithRetry.bind(this),\n\t\t\tthis.getOperationTimeout.bind(this)\n\t\t);\n\n\t\tthis.workflowTemplateMemory = new MongoDBWorkflowTemplate(\n\t\t\tthis.executeWithRetry.bind(this),\n\t\t\tthis.getOperationTimeout.bind(this)\n\t\t);\n\n\t\tthis.userWorkflowMemory = new MongoDBUserWorkflow(\n\t\t\tthis.executeWithRetry.bind(this),\n\t\t\tthis.getOperationTimeout.bind(this)\n\t\t);\n }\n\n public getAgentMemory(): IAgentMemory {\n return this.agentMemory;\n }\n\n public getThreadMemory(): IThreadMemory {\n return this.threadMemory;\n }\n\n public getIntentMemory(): IIntentMemory {\n return this.intentMemory;\n }\n\n public getWorkflowTemplateMemory(): IWorkflowTemplateMemory {\n return this.workflowTemplateMemory;\n }\n\n public getUserWorkflowMemory(): IUserWorkflowMemory {\n return this.userWorkflowMemory;\n }\n\n private setupMongooseEventListeners(): void {\n if (this.eventListenersSetup) return;\n\n this.eventListenersSetup = true;\n\n mongoose.connection.on(\"connected\", () => {\n this.connected = true;\n this.reconnectAttempts = 0;\n this.reconnecting = false;\n loggers.agent.info(\"MongoDB connected successfully\");\n });\n\n mongoose.connection.on(\"disconnected\", () => {\n this.connected = false;\n loggers.agent.warn(\"MongoDB disconnected\");\n this.handleDisconnection();\n });\n\n mongoose.connection.on(\"error\", (error) => {\n this.connected = false;\n loggers.agent.error(\"MongoDB connection error:\", error);\n this.handleDisconnection();\n });\n\n mongoose.connection.on(\"reconnected\", () => {\n this.connected = true;\n this.reconnectAttempts = 0;\n this.reconnecting = false;\n loggers.agent.info(\"MongoDB reconnected successfully\");\n });\n }\n\n private async handleDisconnection(): Promise<void> {\n if (this.reconnecting) {\n return;\n }\n\n this.reconnecting = true;\n\n while (this.reconnectAttempts < this.maxReconnectAttempts && !this.connected) {\n this.reconnectAttempts++;\n loggers.agent.info(\n `Attempting to reconnect to MongoDB (${this.reconnectAttempts}/${this.maxReconnectAttempts})...`\n );\n\n try {\n await mongoose.connect(this.uri, this.connectionConfig);\n this.connected = true;\n this.reconnectAttempts = 0;\n this.reconnecting = false;\n loggers.agent.info(\"MongoDB reconnection successful\");\n return;\n } catch (error) {\n loggers.agent.error(\n `Reconnection attempt ${this.reconnectAttempts} failed:`,\n error\n );\n\n if (this.reconnectAttempts < this.maxReconnectAttempts) {\n await new Promise((resolve) =>\n setTimeout(resolve, this.reconnectInterval)\n );\n }\n }\n }\n\n this.reconnecting = false;\n\n if (!this.connected) {\n loggers.agent.error(\n `Failed to reconnect to MongoDB after ${this.maxReconnectAttempts} attempts`\n );\n }\n }\n\n public async connect(): Promise<void> {\n if (this.connected) {\n return;\n }\n\n try {\n await mongoose.connect(this.uri, this.connectionConfig);\n this.connected = true;\n this.reconnectAttempts = 0;\n await this.setupTTLIndex();\n this.startOrphanCleanup();\n } catch (error) {\n loggers.agent.error(\"Failed to connect to MongoDB:\", error);\n throw error;\n }\n }\n\n public async disconnect(): Promise<void> {\n if (!this.connected) {\n return;\n }\n\n try {\n if (this.orphanCleanupTimer) {\n clearInterval(this.orphanCleanupTimer);\n this.orphanCleanupTimer = undefined;\n }\n await mongoose.disconnect();\n this.connected = false;\n } catch (error) {\n loggers.agent.error(\"Failed to disconnect from MongoDB:\", error);\n throw error;\n }\n }\n\n public isConnected(): boolean {\n return this.connected;\n }\n\n private async ensureConnection(): Promise<void> {\n if (!this.connected && !this.reconnecting) {\n await this.connect();\n }\n\n // Wait for reconnection if in progress\n const maxWaitTime = 30000; // 30 seconds\n const startTime = Date.now();\n while (this.reconnecting && Date.now() - startTime < maxWaitTime) {\n await new Promise((resolve) => setTimeout(resolve, 100));\n }\n\n if (!this.connected) {\n throw new Error(\"MongoDB is not connected and reconnection failed\");\n }\n }\n\n private async setupTTLIndex(): Promise<void> {\n if (this.threadTTLSeconds === undefined) return;\n\n try {\n const db = mongoose.connection.db;\n if (!db) return;\n\n const collection = db.collection('threads');\n const indexes = await collection.indexes();\n const existingTTL = indexes.find(\n (idx) => idx.key?.updatedAt !== undefined && idx.expireAfterSeconds !== undefined\n );\n\n if (existingTTL) {\n if (existingTTL.expireAfterSeconds !== this.threadTTLSeconds) {\n await db.command({\n collMod: 'threads',\n index: { keyPattern: { updatedAt: 1 }, expireAfterSeconds: this.threadTTLSeconds },\n });\n loggers.agent.info(`Thread TTL index updated to ${this.threadTTLSeconds} seconds`);\n }\n } else {\n await collection.createIndex(\n { updatedAt: 1 },\n { expireAfterSeconds: this.threadTTLSeconds },\n );\n loggers.agent.info(`Thread TTL index created with ${this.threadTTLSeconds} seconds`);\n }\n } catch (error) {\n loggers.agent.error('Failed to setup TTL index:', error);\n }\n }\n\n private startOrphanCleanup(): void {\n if (this.threadTTLSeconds === undefined) return;\n if (this.orphanCleanupTimer) return;\n\n // Run cleanup at half the TTL interval, with a minimum of 60s and maximum of 1 hour\n const intervalMs = Math.max(60_000, Math.min(this.threadTTLSeconds * 500, 3_600_000));\n this.orphanCleanupTimer = setInterval(() => {\n this.cleanupOrphanedMessages().catch((error) => {\n loggers.agent.error('Orphaned message cleanup failed:', error);\n });\n }, intervalMs);\n\n loggers.agent.info(`Orphaned message cleanup scheduled every ${Math.round(intervalMs / 1000)}s`);\n }\n\n private async cleanupOrphanedMessages(): Promise<void> {\n if (!this.connected) return;\n\n try {\n const db = mongoose.connection.db;\n if (!db) return;\n\n const existingThreadIds = await db.collection('threads').distinct('threadId');\n const result = await MessageModel.deleteMany({\n threadId: { $nin: existingThreadIds },\n });\n\n if (result.deletedCount > 0) {\n loggers.agent.info(`Cleaned up ${result.deletedCount} orphaned messages`);\n }\n } catch (error) {\n loggers.agent.error('Failed to cleanup orphaned messages:', error);\n }\n }\n\n /**\n * Get the operation timeout in milliseconds\n */\n protected getOperationTimeout(): number {\n return this.operationTimeoutMS;\n }\n\n /**\n * Execute a database operation with automatic retry on connection errors\n * Note: Use mongoose's maxTimeMS option in queries for timeout control\n */\n protected async executeWithRetry<T>(\n operation: () => Promise<T>,\n operationName: string = \"Database operation\"\n ): Promise<T> {\n await this.ensureConnection();\n\n try {\n return await operation();\n } catch (error: any) {\n // Check if it's a timeout error from MongoDB\n if (error.code === 50 || error.message?.includes(\"operation exceeded time limit\")) {\n loggers.agent.error(`${operationName} exceeded time limit`);\n throw error;\n }\n\n // Check if it's a TooManyLogicalSessions error\n if (error.code === 261 || error.codeName === \"TooManyLogicalSessions\") {\n loggers.agent.warn(\n `${operationName} failed due to too many sessions, disconnecting to release sessions...`\n );\n\n try {\n await mongoose.disconnect();\n this.connected = false;\n } catch (disconnectError) {\n loggers.agent.error(\"Failed to disconnect during session cleanup:\", disconnectError);\n }\n\n await new Promise((resolve) => setTimeout(resolve, 5000));\n await this.ensureConnection();\n\n try {\n return await operation();\n } catch (retryError: any) {\n loggers.agent.error(`${operationName} failed after session cleanup retry:`, retryError);\n throw retryError;\n }\n }\n\n // Check if it's a connection-related error\n if (\n error.name === \"MongoNetworkError\" ||\n error.name === \"MongoServerError\" ||\n error.message?.includes(\"connection\") ||\n error.message?.includes(\"disconnect\")\n ) {\n loggers.agent.warn(\n `${operationName} failed due to connection issue, attempting reconnection...`\n );\n\n await this.ensureConnection();\n\n // Retry the operation once after reconnection\n try {\n return await operation();\n } catch (retryError: any) {\n loggers.agent.error(`${operationName} failed after retry:`, retryError);\n throw retryError;\n }\n }\n\n // If it's not a connection error, just throw it\n throw error;\n }\n }\n}\n","import { type Document, Schema } from \"mongoose\";\nimport mongoose from \"mongoose\";\n\nexport const AgentObjectSchema = new Schema(\n\t{\n\t\tid: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tunique: true,\n\t\t},\n\t\tprompt: {\n\t\t\ttype: String,\n\t\t},\n\t},\n);\n\nexport interface AgentDocument extends Document {\n\tid: string;\n\tprompt: string;\n}\n\nexport const AgentModel = mongoose.model<AgentDocument>(\"Agent\", AgentObjectSchema);\n","import { IAgentMemory } from \"@ainetwork/adk/modules\";\nimport { AgentModel } from \"../models/agent.model\";\n\nexport type ExecuteWithRetryFn = <T>(\n operation: () => Promise<T>,\n operationName?: string\n) => Promise<T>;\n\nexport type GetOperationTimeoutFn = () => number;\n\ntype PromptDocument = {\n id: string;\n prompt: string;\n}\n\nexport class MongoDBAgent implements IAgentMemory {\n private executeWithRetry: ExecuteWithRetryFn;\n private getOperationTimeout: GetOperationTimeoutFn;\n\n constructor(\n executeWithRetry: ExecuteWithRetryFn,\n getOperationTimeout: GetOperationTimeoutFn\n ) {\n this.executeWithRetry = executeWithRetry;\n this.getOperationTimeout = getOperationTimeout;\n }\n\n public async getAgentPrompt(): Promise<string> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const metadata = await AgentModel.findOne({\n id: \"agent_prompt\"\n }).maxTimeMS(timeout)\n .lean<PromptDocument>();\n return metadata?.prompt || \"\";\n }, \"getAgentPrompt()\");\n };\n \n public async updateAgentPrompt(prompt: string): Promise<void> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n await AgentModel.updateOne({\n id: \"agent_prompt\",\n }, { \"prompt\": prompt }, { upsert: true }).maxTimeMS(timeout);\n }, \"updateAgentPrompt()\");\n };\n\n public async getAggregatePrompt(): Promise<string> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const metadata = await AgentModel.findOne({\n id: \"aggregate_prompt\"\n }).maxTimeMS(timeout)\n .lean<PromptDocument>();\n return metadata?.prompt || \"\";\n }, \"getAggregatePrompt()\");\n };\n\n public async getGenerateTitlePrompt(): Promise<string> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const metadata = await AgentModel.findOne({\n id: \"generate_title_prompt\"\n }).maxTimeMS(timeout)\n .lean<PromptDocument>();\n return metadata?.prompt || \"\";\n }, \"getGenerateTitlePrompt()\");\n };\n\n public async getSingleTriggerPrompt(): Promise<string> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const metadata = await AgentModel.findOne({\n id: \"single_trigger_prompt\"\n }).maxTimeMS(timeout)\n .lean<PromptDocument>();\n return metadata?.prompt || \"\";\n }, \"getSingleTriggerPrompt()\");\n };\n\n public async getMultiTriggerPrompt(): Promise<string> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const metadata = await AgentModel.findOne({\n id: \"multi_trigger_prompt\"\n }).maxTimeMS(timeout)\n .lean<PromptDocument>();\n return metadata?.prompt || \"\";\n }, \"getMultiTriggerPrompt()\");\n };\n\n public async getToolSelectPrompt(): Promise<string> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const metadata = await AgentModel.findOne({\n id: \"tool_select_prompt\"\n }).maxTimeMS(timeout)\n .lean<PromptDocument>();\n return metadata?.prompt || \"\";\n }, \"getToolSelectPrompt()\");\n };\n\n public async getPIIDetectPrompt(): Promise<string> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const metadata = await AgentModel.findOne({\n id: \"pii_detect_prompt\"\n }).maxTimeMS(timeout)\n .lean<PromptDocument>();\n return metadata?.prompt || \"\";\n }, \"getPIIDetectPrompt()\");\n };\n\n public async getPIIFilterPrompt(): Promise<string> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const metadata = await AgentModel.findOne({\n id: \"pii_filter_prompt\"\n }).maxTimeMS(timeout)\n .lean<PromptDocument>();\n return metadata?.prompt || \"\";\n }, \"getPIIFilterPrompt()\");\n };\n}\n","import { Intent } from \"@ainetwork/adk/types/memory\";\nimport mongoose, { type Document, Schema } from \"mongoose\";\n\nconst IntentObjectSchema = new Schema(\n\t{\n\t\tid: { \n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t\tunique: true,\n\t\t},\n\t\tname: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t},\n\t\tdescription: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tprompt: {\n\t\t\ttype: String,\n\t\t\trequired: false,\n\t\t},\n\t\tstatus: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\ttriggeringSentences: {\n\t\t\ttype: [String],\n\t\t\trequired: false,\n\t\t},\n\t\ttags: {\n\t\t\ttype: [String],\n\t\t\trequired: false,\n\t\t},\n\t\ttoolChoice: {\n\t\t\ttype: String,\n\t\t\tenum: [\"auto\", \"required\"],\n\t\t\trequired: false,\n\t\t},\n\t},\n);\n\nexport interface IntentDocument extends Omit<Document, 'id'>, Omit<Intent, 'id'> {\n\tid: string;\n}\n\nexport const IntentModel = mongoose.model<IntentDocument>(\"Intent\", IntentObjectSchema);","import type { Intent } from \"@ainetwork/adk/types/memory\";\nimport { IIntentMemory } from \"@ainetwork/adk/modules\";\nimport { IntentModel } from \"../models/intent.model\";\n\nexport type ExecuteWithRetryFn = <T>(\n operation: () => Promise<T>,\n operationName?: string\n) => Promise<T>;\n\nexport type GetOperationTimeoutFn = () => number;\n\nexport class MongoDBIntent implements IIntentMemory {\n private executeWithRetry: ExecuteWithRetryFn;\n private getOperationTimeout: GetOperationTimeoutFn;\n\n constructor(\n executeWithRetry: ExecuteWithRetryFn,\n getOperationTimeout: GetOperationTimeoutFn\n ) {\n this.executeWithRetry = executeWithRetry;\n this.getOperationTimeout = getOperationTimeout;\n }\n\n public async getIntent(intentId: string): Promise<Intent | undefined> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const intent = await IntentModel.findOne({ id: intentId })\n .maxTimeMS(timeout)\n .lean<Intent>();\n return intent || undefined;\n }, `getIntent(${intentId})`);\n };\n\n public async getIntentByName(intentName: string): Promise<Intent | undefined> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const intent = await IntentModel.findOne({ name: intentName })\n .maxTimeMS(timeout)\n .lean<Intent>();\n return intent || undefined;\n }, `getIntentByName(${intentName})`);\n }\n\n public async saveIntent(intent: Intent): Promise<void> {\n return this.executeWithRetry(async () => {\n await IntentModel.create(intent);\n }, `saveIntent(${intent.id})`);\n };\n\n public async updateIntent(intentId: string, intent: Intent): Promise<void> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n await IntentModel.updateOne({\n id: intentId,\n }, intent).maxTimeMS(timeout);\n }, `updateIntent(${intentId})`);\n };\n\n public async deleteIntent(intentId: string): Promise<void> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n await IntentModel.deleteOne({ id: intentId }).maxTimeMS(timeout);\n }, `deleteIntent(${intentId})`);\n };\n\n public async listIntents(): Promise<Intent[]> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const intents = await IntentModel.find()\n .maxTimeMS(timeout)\n .lean<Intent[]>();\n return intents;\n }, `listIntents()`);\n };\n}\n","import { ThreadType } from \"@ainetwork/adk/types/memory\";\nimport { type Document, Schema } from \"mongoose\";\nimport mongoose from \"mongoose\";\n\nexport const ThreadObjectSchema = new Schema(\n\t{\n\t\ttype: {\n\t\t\ttype: String,\n\t\t\tenum: Object.values(ThreadType),\n\t\t\trequired: true,\n\t\t},\n\t\tthreadId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t},\n\t\tuserId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t},\n\t\ttitle: {\n\t\t\ttype: String,\n\t\t\trequired: false,\n\t\t},\n\t\tisPinned: {\n\t\t\ttype: Boolean,\n\t\t\trequired: false,\n\t\t\tdefault: false,\n\t\t},\n\t\tworkflowId: {\n\t\t\ttype: String,\n\t\t\trequired: false,\n\t\t\tindex: true,\n\t\t},\n\t},\n\t{\n\t\ttimestamps: true,\n\t},\n);\n\nexport interface ThreadDocument extends Document {\n\ttype: ThreadType;\n\tthreadId: string;\n\tuserId: string;\n\ttitle: string;\n\tisPinned: boolean;\n\tworkflowId?: string;\n\tcreatedAt: Date;\n\tupdatedAt: Date;\n}\n\nexport const ThreadModel = mongoose.model<ThreadDocument>(\"Thread\", ThreadObjectSchema);\n","import { MessageRole } from \"@ainetwork/adk/types/memory\";\nimport { type Document, Schema } from \"mongoose\";\nimport mongoose from \"mongoose\";\n\n// MessageContentObject schema\nexport const MessageContentObjectSchema = new Schema(\n\t{\n\t\ttype: { type: String, required: true },\n\t\tparts: { type: [Schema.Types.Mixed], required: true },\n\t},\n\t{ _id: false },\n);\n\n// MessageObject schema - 개별 문서로 저장\nexport const MessageObjectSchema = new Schema(\n\t{\n\t\tmessageId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t},\n\t\tthreadId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t},\n\t\tuserId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t},\n\t\trole: {\n\t\t\ttype: String,\n\t\t\tenum: Object.values(MessageRole),\n\t\t\trequired: true,\n\t\t},\n\t\tcontent: {\n\t\t\ttype: MessageContentObjectSchema,\n\t\t\trequired: true,\n\t\t},\n\t\ttimestamp: {\n\t\t\ttype: Number,\n\t\t\trequired: true,\n\t\t},\n\t\tmetadata: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t\tdefault: {},\n\t\t},\n\t},\n\t{\n\t\ttimestamps: true,\n\t},\n);\n\nMessageObjectSchema.index({ threadId: 1, messageId: 1 }, { unique: true });\n\n// Message Document interface\nexport interface MessageDocument extends Document {\n\tmessageId: string;\n\tthreadId: string;\n\tuserId: string;\n\trole: MessageRole;\n\tcontent: {\n\t\ttype: string;\n\t\tparts: any[];\n\t};\n\ttimestamp: number;\n\tcreatedAt: Date;\n\tupdatedAt: Date;\n\tmetadata?: { [key: string]: unknown };\n}\n\nexport const MessageModel = mongoose.model<MessageDocument>(\"Message\", MessageObjectSchema);","import type { MessageObject, ThreadMetadata, ThreadObject, ThreadType, ThreadFilter } from \"@ainetwork/adk/types/memory\";\nimport { MessageRole } from \"@ainetwork/adk/types/memory\";\nimport { IThreadMemory } from \"@ainetwork/adk/modules\";\nimport { ThreadDocument, ThreadModel } from \"../models/threads.model\";\nimport { MessageDocument, MessageModel } from \"../models/messages.model\";\nimport { loggers } from \"@ainetwork/adk/utils/logger\";\n\nexport type ExecuteWithRetryFn = <T>(\n operation: () => Promise<T>,\n operationName?: string\n) => Promise<T>;\n\nexport type GetOperationTimeoutFn = () => number;\n\nexport class MongoDBThread implements IThreadMemory {\n private executeWithRetry: ExecuteWithRetryFn;\n private getOperationTimeout: GetOperationTimeoutFn;\n\n constructor(\n executeWithRetry: ExecuteWithRetryFn,\n getOperationTimeout: GetOperationTimeoutFn\n ) {\n this.executeWithRetry = executeWithRetry;\n this.getOperationTimeout = getOperationTimeout;\n }\n\n public async getThread(\n userId: string,\n threadId: string\n ): Promise<ThreadObject | undefined> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const thread = await ThreadModel.findOne({ threadId, userId }).maxTimeMS(timeout);\n const messages = await MessageModel.find({ threadId, userId })\n .sort({ timestamp: 1 })\n .maxTimeMS(timeout);\n\n if (!thread) return undefined;\n\n loggers.agent.debug(`Found ${messages.length} messages for thread ${threadId}`);\n\n const threadObject: ThreadObject = {\n threadId: thread.threadId,\n userId: thread.userId,\n type: thread.type as ThreadType,\n title: thread.title || \"New thread\",\n isPinned: thread.isPinned ?? false,\n workflowId: thread.workflowId,\n messages: []\n };\n messages.forEach((message: MessageDocument) => {\n threadObject.messages.push({\n messageId: message.messageId,\n role: message.role as MessageRole,\n content: message.content,\n timestamp: message.timestamp,\n metadata: message.metadata,\n });\n });\n\n return threadObject;\n }, `getThread(${userId}, ${threadId})`);\n };\n\n public async createThread(\n type: ThreadType,\n userId: string,\n threadId: string,\n title: string,\n workflowId?: string,\n ): Promise<ThreadObject> {\n return this.executeWithRetry(async () => {\n await ThreadModel.create({\n type,\n userId,\n threadId,\n title,\n workflowId,\n });\n\n return { type, userId, threadId, title, workflowId, messages: []};\n }, `createThread(${userId}, ${threadId})`);\n };\n\n public async addMessagesToThread(\n userId: string,\n threadId: string,\n messages: MessageObject[]\n ): Promise<void> {\n return this.executeWithRetry(async () => {\n if (messages.length > 0) {\n const messageIds = messages.map((m) => m.messageId);\n await MessageModel.deleteMany({ threadId, userId, messageId: { $in: messageIds } });\n await MessageModel.insertMany(\n messages.map((message) => ({\n threadId,\n messageId: message.messageId,\n userId,\n role: message.role,\n content: message.content,\n timestamp: message.timestamp,\n metadata: message.metadata,\n }))\n );\n }\n await ThreadModel.updateOne(\n { threadId, userId },\n { $set: { updatedAt: new Date() } }\n );\n }, `addMessagesToThread(${userId}, ${threadId})`);\n };\n\n public async deleteThread(userId: string, threadId: string): Promise<void> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n\n // Delete all messages for this thread\n await MessageModel.deleteMany({ userId, threadId }).maxTimeMS(timeout);\n\n // Delete the thread itself\n await ThreadModel.deleteOne({ userId, threadId }).maxTimeMS(timeout);\n }, `deleteThread(${userId}, ${threadId})`);\n };\n\n public async listThreads(userId: string, filter?: ThreadFilter): Promise<ThreadMetadata[]> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const query: Record<string, any> = { userId };\n if (filter?.workflowId) query.workflowId = filter.workflowId;\n if (filter?.type) query.type = filter.type;\n const threads = await ThreadModel.find(query)\n .sort({ updatedAt: -1 })\n .maxTimeMS(timeout);\n const data: ThreadMetadata[] = threads.map((thread: ThreadDocument) => {\n return {\n type: thread.type,\n userId,\n threadId: thread.threadId,\n title: thread.title,\n isPinned: thread.isPinned ?? false,\n workflowId: thread.workflowId,\n createdAt: thread.createdAt?.toISOString(),\n updatedAt: thread.updatedAt?.toISOString(),\n } as ThreadMetadata;\n })\n return data;\n }, `listThreads(${userId})`);\n };\n\n public async updateThreadPin(\n userId: string,\n threadId: string,\n isPinned: boolean\n ): Promise<void> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n await ThreadModel.updateOne(\n { threadId, userId },\n { $set: { isPinned } }\n ).maxTimeMS(timeout);\n }, `updateThreadPin(${userId}, ${threadId})`);\n };\n}\n","import type {\n\tWorkflowDefinition,\n\tWorkflowVariable,\n} from \"@ainetwork/adk/types/memory\";\nimport { type Document, Schema } from \"mongoose\";\nimport mongoose from \"mongoose\";\n\nexport const UserWorkflowObjectSchema = new Schema(\n\t{\n\t\tworkflowId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tunique: true,\n\t\t},\n\t\tuserId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t},\n\t\ttitle: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tdescription: {\n\t\t\ttype: String,\n\t\t},\n\t\tactive: {\n\t\t\ttype: Boolean,\n\t\t\trequired: true,\n\t\t\tdefault: false,\n\t\t},\n\t\ttemplateId: {\n\t\t\ttype: String,\n\t\t},\n\t\tcontent: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tdefinition: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t\tvariables: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t\tvariableValues: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t\tschedule: {\n\t\t\ttype: String,\n\t\t},\n\t\ttimezone: {\n\t\t\ttype: String,\n\t\t},\n\t\tlastRunAt: {\n\t\t\ttype: Number,\n\t\t},\n\t\tnextRunAt: {\n\t\t\ttype: Number,\n\t\t},\n\t\tlastThreadId: {\n\t\t\ttype: String,\n\t\t},\n\t},\n\t{\n\t\ttimestamps: true,\n\t}\n);\n\nexport interface UserWorkflowDocument extends Document {\n\tworkflowId: string;\n\tuserId: string;\n\ttitle: string;\n\tdescription?: string;\n\tactive: boolean;\n\ttemplateId?: string;\n\tcontent: string;\n\tdefinition?: WorkflowDefinition;\n\tvariables?: Record<string, WorkflowVariable>;\n\tvariableValues?: Record<string, string>;\n\tschedule?: string;\n\ttimezone?: string;\n\tlastRunAt?: number;\n\tnextRunAt?: number;\n\tlastThreadId?: string;\n}\n\nexport const UserWorkflowModel = mongoose.model<UserWorkflowDocument>(\n\t\"UserWorkflow\",\n\tUserWorkflowObjectSchema\n);\n","import type { IUserWorkflowMemory } from \"@ainetwork/adk/modules\";\nimport type { UserWorkflow } from \"@ainetwork/adk/types/memory\";\nimport { UserWorkflowModel } from \"../models/user-workflow.model\";\n\nexport type ExecuteWithRetryFn = <T>(\n operation: () => Promise<T>,\n operationName?: string\n) => Promise<T>;\n\nexport type GetOperationTimeoutFn = () => number;\n\nexport class MongoDBUserWorkflow implements IUserWorkflowMemory {\n private executeWithRetry: ExecuteWithRetryFn;\n private getOperationTimeout: GetOperationTimeoutFn;\n\n constructor(\n executeWithRetry: ExecuteWithRetryFn,\n getOperationTimeout: GetOperationTimeoutFn\n ) {\n this.executeWithRetry = executeWithRetry;\n this.getOperationTimeout = getOperationTimeout;\n }\n\n public async createUserWorkflow(workflow: UserWorkflow): Promise<UserWorkflow> {\n return this.executeWithRetry(async () => {\n const created = await UserWorkflowModel.create(workflow);\n return created.toObject() as UserWorkflow;\n }, \"createUserWorkflow()\");\n }\n\n public async getUserWorkflow(workflowId: string): Promise<UserWorkflow | undefined> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const workflow = await UserWorkflowModel.findOne({ workflowId })\n .maxTimeMS(timeout)\n .lean<UserWorkflow>();\n return workflow || undefined;\n }, \"getUserWorkflow()\");\n }\n\n public async updateUserWorkflow(workflowId: string, updates: Partial<UserWorkflow>): Promise<void> {\n if (!updates.userId) {\n throw new Error(\"userId is required for updateUserWorkflow\");\n }\n\n const { userId, workflowId: _workflowId, ...mutableUpdates } = updates;\n\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n await UserWorkflowModel.updateOne(\n { workflowId, userId },\n { $set: mutableUpdates }\n ).maxTimeMS(timeout);\n }, \"updateUserWorkflow()\");\n }\n\n public async deleteUserWorkflow(workflowId: string, userId: string): Promise<void> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n await UserWorkflowModel.deleteOne({ workflowId, userId }).maxTimeMS(timeout);\n }, \"deleteUserWorkflow()\");\n }\n\n public async listUserWorkflows(userId?: string): Promise<UserWorkflow[]> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const query = userId ? { userId } : {};\n const workflows = await UserWorkflowModel.find(query)\n .maxTimeMS(timeout)\n .lean<UserWorkflow[]>();\n return workflows;\n }, \"listUserWorkflows()\");\n }\n\n public async listActiveScheduledWorkflows(): Promise<UserWorkflow[]> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const workflows = await UserWorkflowModel.find({\n active: true,\n schedule: { $exists: true, $ne: null },\n })\n .maxTimeMS(timeout)\n .lean<UserWorkflow[]>();\n return workflows;\n }, \"listActiveScheduledWorkflows()\");\n }\n}\n","import type {\n\tWorkflowDefinition,\n\tWorkflowVariable,\n} from \"@ainetwork/adk/types/memory\";\nimport { type Document, Schema } from \"mongoose\";\nimport mongoose from \"mongoose\";\n\nexport const WorkflowTemplateObjectSchema = new Schema(\n\t{\n\t\ttemplateId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tunique: true,\n\t\t},\n\t\ttitle: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tdescription: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tactive: {\n\t\t\ttype: Boolean,\n\t\t\trequired: true,\n\t\t\tdefault: false,\n\t\t},\n\t\tcontent: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tdefinition: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t\tvariables: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t},\n\t{\n\t\ttimestamps: true,\n\t}\n);\n\nexport interface WorkflowTemplateDocument extends Document {\n\ttemplateId: string;\n\ttitle: string;\n\tdescription: string;\n\tactive: boolean;\n\tcontent: string;\n\tdefinition?: WorkflowDefinition;\n\tvariables?: Record<string, WorkflowVariable>;\n}\n\nexport const WorkflowTemplateModel = mongoose.model<WorkflowTemplateDocument>(\n\t\"WorkflowTemplate\",\n\tWorkflowTemplateObjectSchema\n);\n","import type { IWorkflowTemplateMemory } from \"@ainetwork/adk/modules\";\nimport type { WorkflowTemplate } from \"@ainetwork/adk/types/memory\";\nimport { WorkflowTemplateModel } from \"../models/workflow-template.model\";\n\nexport type ExecuteWithRetryFn = <T>(\n operation: () => Promise<T>,\n operationName?: string\n) => Promise<T>;\n\nexport type GetOperationTimeoutFn = () => number;\n\nexport class MongoDBWorkflowTemplate implements IWorkflowTemplateMemory {\n private executeWithRetry: ExecuteWithRetryFn;\n private getOperationTimeout: GetOperationTimeoutFn;\n\n constructor(\n executeWithRetry: ExecuteWithRetryFn,\n getOperationTimeout: GetOperationTimeoutFn\n ) {\n this.executeWithRetry = executeWithRetry;\n this.getOperationTimeout = getOperationTimeout;\n }\n\n public async createTemplate(template: WorkflowTemplate): Promise<WorkflowTemplate> {\n return this.executeWithRetry(async () => {\n const created = await WorkflowTemplateModel.create(template);\n return created.toObject() as WorkflowTemplate;\n }, \"createTemplate()\");\n }\n\n public async getTemplate(templateId: string): Promise<WorkflowTemplate | undefined> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const template = await WorkflowTemplateModel.findOne({ templateId })\n .maxTimeMS(timeout)\n .lean<WorkflowTemplate>();\n return template || undefined;\n }, \"getTemplate()\");\n }\n\n public async updateTemplate(templateId: string, updates: Partial<WorkflowTemplate>): Promise<void> {\n const { templateId: _templateId, ...mutableUpdates } = updates;\n\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n await WorkflowTemplateModel.updateOne(\n { templateId },\n { $set: mutableUpdates }\n ).maxTimeMS(timeout);\n }, \"updateTemplate()\");\n }\n\n public async deleteTemplate(templateId: string): Promise<void> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n await WorkflowTemplateModel.deleteOne({ templateId }).maxTimeMS(timeout);\n }, \"deleteTemplate()\");\n }\n\n public async listTemplates(): Promise<WorkflowTemplate[]> {\n return this.executeWithRetry(async () => {\n const timeout = this.getOperationTimeout();\n const templates = await WorkflowTemplateModel.find()\n .maxTimeMS(timeout)\n .lean<WorkflowTemplate[]>();\n return templates;\n }, \"listTemplates()\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,IAAAA,oBAAqB;AACrB,IAAAC,iBAAwB;;;ACFxB,sBAAsC;AACtC,IAAAC,mBAAqB;AAEd,IAAM,oBAAoB,IAAI;AAAA,EACpC;AAAA,IACC,IAAI;AAAA,MACH,MAAM;AAAA,M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B,GAAG;AACjF,+BAAQ,MAAM,MAAM,GAAG,aAAa,sBAAsB;AAC1D,cAAM;AAAA,MACR;AAGA,UAAI,MAAM,SAAS,OAAO,MAAM,aAAa,0BAA0B;AACrE,+BAAQ,MAAM;AAAA,UACZ,GAAG,aAAa;AAAA,QAClB;AAEA,YAAI;AACF,gBAAM,kBAAAA,QAAS,WAAW;AAC1B,eAAK,YAAY;AAAA,QACnB,SAAS,iBAAiB;AACxB,iCAAQ,MAAM,MAAM,gDAAgD,eAAe;AAAA,QACrF;AAEA,cAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,GAAI,CAAC;AACxD,cAAM,KAAK,iBAAiB;AAE5B,YAAI;AACF,iBAAO,MAAM,UAAU;AAAA,QACzB,SAAS,YAAiB;AACxB,iCAAQ,MAAM,MAAM,GAAG,aAAa,wCAAwC,UAAU;AACtF,gBAAM;AAAA,QACR;AAAA,MACF;AAGA,UACE,MAAM,SAAS,uBACf,MAAM,SAAS,sBACf,MAAM,SAAS,SAAS,YAAY,KACpC,MAAM,SAAS,SAAS,YAAY,GACpC;AACA,+BAAQ,MAAM;AAAA,UACZ,GAAG,aAAa;AAAA,QAClB;AAEA,cAAM,KAAK,iBAAiB;AAG5B,YAAI;AACF,iBAAO,MAAM,UAAU;AAAA,QACzB,SAAS,YAAiB;AACxB,iCAAQ,MAAM,MAAM,GAAG,aAAa,wBAAwB,UAAU;AACtE,gBAAM;AAAA,QACR;AAAA,MACF;AAGA,YAAM;AAAA,IACR;AAAA,EACF;AACF;","names":["import_mongoose","import_logger","import_mongoose","mongoose","import_mongoose","mongoose","import_mongoose","mongoose","import_memory","import_mongoose","mongoose","import_mongoose","mongoose","import_mongoose","mongoose","mongoose"]}
|
package/dist/index.js
CHANGED
|
@@ -12,10 +12,10 @@ import {
|
|
|
12
12
|
} from "./chunk-2XJ6S2W5.js";
|
|
13
13
|
import {
|
|
14
14
|
UserWorkflowModel
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-SXSMKZSK.js";
|
|
16
16
|
import {
|
|
17
17
|
WorkflowTemplateModel
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-4RSJL5V4.js";
|
|
19
19
|
|
|
20
20
|
// implements/base.memory.ts
|
|
21
21
|
import mongoose from "mongoose";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../models/user-workflow.model.ts"],"sourcesContent":["import { type Document, Schema } from \"mongoose\";\nimport mongoose from \"mongoose\";\n\nexport const UserWorkflowObjectSchema = new Schema(\n\t{\n\t\tworkflowId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tunique: true,\n\t\t},\n\t\tuserId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t},\n\t\ttitle: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tdescription: {\n\t\t\ttype: String,\n\t\t},\n\t\tactive: {\n\t\t\ttype: Boolean,\n\t\t\trequired: true,\n\t\t\tdefault: false,\n\t\t},\n\t\ttemplateId: {\n\t\t\ttype: String,\n\t\t},\n\t\tcontent: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tvariables: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t\tvariableValues: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t\tschedule: {\n\t\t\ttype: String,\n\t\t},\n\t\ttimezone: {\n\t\t\ttype: String,\n\t\t},\n\t\tlastRunAt: {\n\t\t\ttype: Number,\n\t\t},\n\t\tnextRunAt: {\n\t\t\ttype: Number,\n\t\t},\n\t\tlastThreadId: {\n\t\t\ttype: String,\n\t\t},\n\t},\n\t{\n\t\ttimestamps: true,\n\t}\n);\n\nexport interface UserWorkflowDocument extends Document {\n\tworkflowId: string;\n\tuserId: string;\n\ttitle: string;\n\tdescription?: string;\n\tactive: boolean;\n\ttemplateId?: string;\n\tcontent: string;\n\
|
|
1
|
+
{"version":3,"sources":["../../models/user-workflow.model.ts"],"sourcesContent":["import type {\n\tWorkflowDefinition,\n\tWorkflowVariable,\n} from \"@ainetwork/adk/types/memory\";\nimport { type Document, Schema } from \"mongoose\";\nimport mongoose from \"mongoose\";\n\nexport const UserWorkflowObjectSchema = new Schema(\n\t{\n\t\tworkflowId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tunique: true,\n\t\t},\n\t\tuserId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t},\n\t\ttitle: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tdescription: {\n\t\t\ttype: String,\n\t\t},\n\t\tactive: {\n\t\t\ttype: Boolean,\n\t\t\trequired: true,\n\t\t\tdefault: false,\n\t\t},\n\t\ttemplateId: {\n\t\t\ttype: String,\n\t\t},\n\t\tcontent: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tdefinition: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t\tvariables: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t\tvariableValues: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t\tschedule: {\n\t\t\ttype: String,\n\t\t},\n\t\ttimezone: {\n\t\t\ttype: String,\n\t\t},\n\t\tlastRunAt: {\n\t\t\ttype: Number,\n\t\t},\n\t\tnextRunAt: {\n\t\t\ttype: Number,\n\t\t},\n\t\tlastThreadId: {\n\t\t\ttype: String,\n\t\t},\n\t},\n\t{\n\t\ttimestamps: true,\n\t}\n);\n\nexport interface UserWorkflowDocument extends Document {\n\tworkflowId: string;\n\tuserId: string;\n\ttitle: string;\n\tdescription?: string;\n\tactive: boolean;\n\ttemplateId?: string;\n\tcontent: string;\n\tdefinition?: WorkflowDefinition;\n\tvariables?: Record<string, WorkflowVariable>;\n\tvariableValues?: Record<string, string>;\n\tschedule?: string;\n\ttimezone?: string;\n\tlastRunAt?: number;\n\tnextRunAt?: number;\n\tlastThreadId?: string;\n}\n\nexport const UserWorkflowModel = mongoose.model<UserWorkflowDocument>(\n\t\"UserWorkflow\",\n\tUserWorkflowObjectSchema\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,sBAAsC;AACtC,IAAAA,mBAAqB;AAEd,IAAM,2BAA2B,IAAI;AAAA,EAC3C;AAAA,IACC,YAAY;AAAA,MACX,MAAM;AAAA,MACN,UAAU;AAAA,MACV,QAAQ;AAAA,IACT;AAAA,IACA,QAAQ;AAAA,MACP,MAAM;AAAA,MACN,UAAU;AAAA,MACV,OAAO;AAAA,IACR;AAAA,IACA,OAAO;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,aAAa;AAAA,MACZ,MAAM;AAAA,IACP;AAAA,IACA,QAAQ;AAAA,MACP,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,IACV;AAAA,IACA,YAAY;AAAA,MACX,MAAM;AAAA,IACP;AAAA,IACA,SAAS;AAAA,MACR,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,YAAY;AAAA,MACX,MAAM,uBAAO,MAAM;AAAA,IACpB;AAAA,IACA,WAAW;AAAA,MACV,MAAM,uBAAO,MAAM;AAAA,IACpB;AAAA,IACA,gBAAgB;AAAA,MACf,MAAM,uBAAO,MAAM;AAAA,IACpB;AAAA,IACA,UAAU;AAAA,MACT,MAAM;AAAA,IACP;AAAA,IACA,UAAU;AAAA,MACT,MAAM;AAAA,IACP;AAAA,IACA,WAAW;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,WAAW;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,cAAc;AAAA,MACb,MAAM;AAAA,IACP;AAAA,EACD;AAAA,EACA;AAAA,IACC,YAAY;AAAA,EACb;AACD;AAoBO,IAAM,oBAAoB,iBAAAC,QAAS;AAAA,EACzC;AAAA,EACA;AACD;","names":["import_mongoose","mongoose"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WorkflowDefinition, WorkflowVariable } from '@ainetwork/adk/types/memory';
|
|
1
2
|
import mongoose, { Schema, Document } from 'mongoose';
|
|
2
3
|
|
|
3
4
|
declare const UserWorkflowObjectSchema: Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
@@ -13,6 +14,7 @@ declare const UserWorkflowObjectSchema: Schema<any, mongoose.Model<any, any, any
|
|
|
13
14
|
active: boolean;
|
|
14
15
|
description?: string | null | undefined;
|
|
15
16
|
templateId?: string | null | undefined;
|
|
17
|
+
definition?: any;
|
|
16
18
|
variables?: any;
|
|
17
19
|
variableValues?: any;
|
|
18
20
|
schedule?: string | null | undefined;
|
|
@@ -31,6 +33,7 @@ declare const UserWorkflowObjectSchema: Schema<any, mongoose.Model<any, any, any
|
|
|
31
33
|
active: boolean;
|
|
32
34
|
description?: string | null | undefined;
|
|
33
35
|
templateId?: string | null | undefined;
|
|
36
|
+
definition?: any;
|
|
34
37
|
variables?: any;
|
|
35
38
|
variableValues?: any;
|
|
36
39
|
schedule?: string | null | undefined;
|
|
@@ -49,6 +52,7 @@ declare const UserWorkflowObjectSchema: Schema<any, mongoose.Model<any, any, any
|
|
|
49
52
|
active: boolean;
|
|
50
53
|
description?: string | null | undefined;
|
|
51
54
|
templateId?: string | null | undefined;
|
|
55
|
+
definition?: any;
|
|
52
56
|
variables?: any;
|
|
53
57
|
variableValues?: any;
|
|
54
58
|
schedule?: string | null | undefined;
|
|
@@ -69,13 +73,8 @@ interface UserWorkflowDocument extends Document {
|
|
|
69
73
|
active: boolean;
|
|
70
74
|
templateId?: string;
|
|
71
75
|
content: string;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
label: string;
|
|
75
|
-
type: "select" | "date_range" | "date_parts" | "text" | "number";
|
|
76
|
-
options?: Array<string>;
|
|
77
|
-
resolveAt?: "creation" | "execution";
|
|
78
|
-
}>;
|
|
76
|
+
definition?: WorkflowDefinition;
|
|
77
|
+
variables?: Record<string, WorkflowVariable>;
|
|
79
78
|
variableValues?: Record<string, string>;
|
|
80
79
|
schedule?: string;
|
|
81
80
|
timezone?: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WorkflowDefinition, WorkflowVariable } from '@ainetwork/adk/types/memory';
|
|
1
2
|
import mongoose, { Schema, Document } from 'mongoose';
|
|
2
3
|
|
|
3
4
|
declare const UserWorkflowObjectSchema: Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
@@ -13,6 +14,7 @@ declare const UserWorkflowObjectSchema: Schema<any, mongoose.Model<any, any, any
|
|
|
13
14
|
active: boolean;
|
|
14
15
|
description?: string | null | undefined;
|
|
15
16
|
templateId?: string | null | undefined;
|
|
17
|
+
definition?: any;
|
|
16
18
|
variables?: any;
|
|
17
19
|
variableValues?: any;
|
|
18
20
|
schedule?: string | null | undefined;
|
|
@@ -31,6 +33,7 @@ declare const UserWorkflowObjectSchema: Schema<any, mongoose.Model<any, any, any
|
|
|
31
33
|
active: boolean;
|
|
32
34
|
description?: string | null | undefined;
|
|
33
35
|
templateId?: string | null | undefined;
|
|
36
|
+
definition?: any;
|
|
34
37
|
variables?: any;
|
|
35
38
|
variableValues?: any;
|
|
36
39
|
schedule?: string | null | undefined;
|
|
@@ -49,6 +52,7 @@ declare const UserWorkflowObjectSchema: Schema<any, mongoose.Model<any, any, any
|
|
|
49
52
|
active: boolean;
|
|
50
53
|
description?: string | null | undefined;
|
|
51
54
|
templateId?: string | null | undefined;
|
|
55
|
+
definition?: any;
|
|
52
56
|
variables?: any;
|
|
53
57
|
variableValues?: any;
|
|
54
58
|
schedule?: string | null | undefined;
|
|
@@ -69,13 +73,8 @@ interface UserWorkflowDocument extends Document {
|
|
|
69
73
|
active: boolean;
|
|
70
74
|
templateId?: string;
|
|
71
75
|
content: string;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
label: string;
|
|
75
|
-
type: "select" | "date_range" | "date_parts" | "text" | "number";
|
|
76
|
-
options?: Array<string>;
|
|
77
|
-
resolveAt?: "creation" | "execution";
|
|
78
|
-
}>;
|
|
76
|
+
definition?: WorkflowDefinition;
|
|
77
|
+
variables?: Record<string, WorkflowVariable>;
|
|
79
78
|
variableValues?: Record<string, string>;
|
|
80
79
|
schedule?: string;
|
|
81
80
|
timezone?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../models/workflow-template.model.ts"],"sourcesContent":["import { type Document, Schema } from \"mongoose\";\nimport mongoose from \"mongoose\";\n\nexport const WorkflowTemplateObjectSchema = new Schema(\n\t{\n\t\ttemplateId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tunique: true,\n\t\t},\n\t\ttitle: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tdescription: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tactive: {\n\t\t\ttype: Boolean,\n\t\t\trequired: true,\n\t\t\tdefault: false,\n\t\t},\n\t\tcontent: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tvariables: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t},\n\t{\n\t\ttimestamps: true,\n\t}\n);\n\nexport interface WorkflowTemplateDocument extends Document {\n\ttemplateId: string;\n\ttitle: string;\n\tdescription: string;\n\tactive: boolean;\n\tcontent: string;\n\
|
|
1
|
+
{"version":3,"sources":["../../models/workflow-template.model.ts"],"sourcesContent":["import type {\n\tWorkflowDefinition,\n\tWorkflowVariable,\n} from \"@ainetwork/adk/types/memory\";\nimport { type Document, Schema } from \"mongoose\";\nimport mongoose from \"mongoose\";\n\nexport const WorkflowTemplateObjectSchema = new Schema(\n\t{\n\t\ttemplateId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tunique: true,\n\t\t},\n\t\ttitle: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tdescription: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tactive: {\n\t\t\ttype: Boolean,\n\t\t\trequired: true,\n\t\t\tdefault: false,\n\t\t},\n\t\tcontent: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tdefinition: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t\tvariables: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t},\n\t{\n\t\ttimestamps: true,\n\t}\n);\n\nexport interface WorkflowTemplateDocument extends Document {\n\ttemplateId: string;\n\ttitle: string;\n\tdescription: string;\n\tactive: boolean;\n\tcontent: string;\n\tdefinition?: WorkflowDefinition;\n\tvariables?: Record<string, WorkflowVariable>;\n}\n\nexport const WorkflowTemplateModel = mongoose.model<WorkflowTemplateDocument>(\n\t\"WorkflowTemplate\",\n\tWorkflowTemplateObjectSchema\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,sBAAsC;AACtC,IAAAA,mBAAqB;AAEd,IAAM,+BAA+B,IAAI;AAAA,EAC/C;AAAA,IACC,YAAY;AAAA,MACX,MAAM;AAAA,MACN,UAAU;AAAA,MACV,QAAQ;AAAA,IACT;AAAA,IACA,OAAO;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,aAAa;AAAA,MACZ,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,QAAQ;AAAA,MACP,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,IACV;AAAA,IACA,SAAS;AAAA,MACR,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,YAAY;AAAA,MACX,MAAM,uBAAO,MAAM;AAAA,IACpB;AAAA,IACA,WAAW;AAAA,MACV,MAAM,uBAAO,MAAM;AAAA,IACpB;AAAA,EACD;AAAA,EACA;AAAA,IACC,YAAY;AAAA,EACb;AACD;AAYO,IAAM,wBAAwB,iBAAAC,QAAS;AAAA,EAC7C;AAAA,EACA;AACD;","names":["import_mongoose","mongoose"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WorkflowDefinition, WorkflowVariable } from '@ainetwork/adk/types/memory';
|
|
1
2
|
import mongoose, { Schema, Document } from 'mongoose';
|
|
2
3
|
|
|
3
4
|
declare const WorkflowTemplateObjectSchema: Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
@@ -11,6 +12,7 @@ declare const WorkflowTemplateObjectSchema: Schema<any, mongoose.Model<any, any,
|
|
|
11
12
|
content: string;
|
|
12
13
|
active: boolean;
|
|
13
14
|
templateId: string;
|
|
15
|
+
definition?: any;
|
|
14
16
|
variables?: any;
|
|
15
17
|
}, Document<unknown, {}, mongoose.FlatRecord<{
|
|
16
18
|
createdAt: NativeDate;
|
|
@@ -21,6 +23,7 @@ declare const WorkflowTemplateObjectSchema: Schema<any, mongoose.Model<any, any,
|
|
|
21
23
|
content: string;
|
|
22
24
|
active: boolean;
|
|
23
25
|
templateId: string;
|
|
26
|
+
definition?: any;
|
|
24
27
|
variables?: any;
|
|
25
28
|
}>, {}> & mongoose.FlatRecord<{
|
|
26
29
|
createdAt: NativeDate;
|
|
@@ -31,6 +34,7 @@ declare const WorkflowTemplateObjectSchema: Schema<any, mongoose.Model<any, any,
|
|
|
31
34
|
content: string;
|
|
32
35
|
active: boolean;
|
|
33
36
|
templateId: string;
|
|
37
|
+
definition?: any;
|
|
34
38
|
variables?: any;
|
|
35
39
|
}> & {
|
|
36
40
|
_id: mongoose.Types.ObjectId;
|
|
@@ -43,13 +47,8 @@ interface WorkflowTemplateDocument extends Document {
|
|
|
43
47
|
description: string;
|
|
44
48
|
active: boolean;
|
|
45
49
|
content: string;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
label: string;
|
|
49
|
-
type: "select" | "date_range" | "date_parts" | "text" | "number";
|
|
50
|
-
options?: Array<string>;
|
|
51
|
-
resolveAt?: "creation" | "execution";
|
|
52
|
-
}>;
|
|
50
|
+
definition?: WorkflowDefinition;
|
|
51
|
+
variables?: Record<string, WorkflowVariable>;
|
|
53
52
|
}
|
|
54
53
|
declare const WorkflowTemplateModel: mongoose.Model<WorkflowTemplateDocument, {}, {}, {}, Document<unknown, {}, WorkflowTemplateDocument, {}> & WorkflowTemplateDocument & Required<{
|
|
55
54
|
_id: unknown;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WorkflowDefinition, WorkflowVariable } from '@ainetwork/adk/types/memory';
|
|
1
2
|
import mongoose, { Schema, Document } from 'mongoose';
|
|
2
3
|
|
|
3
4
|
declare const WorkflowTemplateObjectSchema: Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
@@ -11,6 +12,7 @@ declare const WorkflowTemplateObjectSchema: Schema<any, mongoose.Model<any, any,
|
|
|
11
12
|
content: string;
|
|
12
13
|
active: boolean;
|
|
13
14
|
templateId: string;
|
|
15
|
+
definition?: any;
|
|
14
16
|
variables?: any;
|
|
15
17
|
}, Document<unknown, {}, mongoose.FlatRecord<{
|
|
16
18
|
createdAt: NativeDate;
|
|
@@ -21,6 +23,7 @@ declare const WorkflowTemplateObjectSchema: Schema<any, mongoose.Model<any, any,
|
|
|
21
23
|
content: string;
|
|
22
24
|
active: boolean;
|
|
23
25
|
templateId: string;
|
|
26
|
+
definition?: any;
|
|
24
27
|
variables?: any;
|
|
25
28
|
}>, {}> & mongoose.FlatRecord<{
|
|
26
29
|
createdAt: NativeDate;
|
|
@@ -31,6 +34,7 @@ declare const WorkflowTemplateObjectSchema: Schema<any, mongoose.Model<any, any,
|
|
|
31
34
|
content: string;
|
|
32
35
|
active: boolean;
|
|
33
36
|
templateId: string;
|
|
37
|
+
definition?: any;
|
|
34
38
|
variables?: any;
|
|
35
39
|
}> & {
|
|
36
40
|
_id: mongoose.Types.ObjectId;
|
|
@@ -43,13 +47,8 @@ interface WorkflowTemplateDocument extends Document {
|
|
|
43
47
|
description: string;
|
|
44
48
|
active: boolean;
|
|
45
49
|
content: string;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
label: string;
|
|
49
|
-
type: "select" | "date_range" | "date_parts" | "text" | "number";
|
|
50
|
-
options?: Array<string>;
|
|
51
|
-
resolveAt?: "creation" | "execution";
|
|
52
|
-
}>;
|
|
50
|
+
definition?: WorkflowDefinition;
|
|
51
|
+
variables?: Record<string, WorkflowVariable>;
|
|
53
52
|
}
|
|
54
53
|
declare const WorkflowTemplateModel: mongoose.Model<WorkflowTemplateDocument, {}, {}, {}, Document<unknown, {}, WorkflowTemplateDocument, {}> & WorkflowTemplateDocument & Required<{
|
|
55
54
|
_id: unknown;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
WorkflowDefinition,
|
|
3
|
+
WorkflowVariable,
|
|
4
|
+
} from "@ainetwork/adk/types/memory";
|
|
1
5
|
import { type Document, Schema } from "mongoose";
|
|
2
6
|
import mongoose from "mongoose";
|
|
3
7
|
|
|
@@ -32,6 +36,9 @@ export const UserWorkflowObjectSchema = new Schema(
|
|
|
32
36
|
type: String,
|
|
33
37
|
required: true,
|
|
34
38
|
},
|
|
39
|
+
definition: {
|
|
40
|
+
type: Schema.Types.Mixed,
|
|
41
|
+
},
|
|
35
42
|
variables: {
|
|
36
43
|
type: Schema.Types.Mixed,
|
|
37
44
|
},
|
|
@@ -67,16 +74,8 @@ export interface UserWorkflowDocument extends Document {
|
|
|
67
74
|
active: boolean;
|
|
68
75
|
templateId?: string;
|
|
69
76
|
content: string;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
{
|
|
73
|
-
id: string;
|
|
74
|
-
label: string;
|
|
75
|
-
type: "select" | "date_range" | "date_parts" | "text" | "number";
|
|
76
|
-
options?: Array<string>;
|
|
77
|
-
resolveAt?: "creation" | "execution";
|
|
78
|
-
}
|
|
79
|
-
>;
|
|
77
|
+
definition?: WorkflowDefinition;
|
|
78
|
+
variables?: Record<string, WorkflowVariable>;
|
|
80
79
|
variableValues?: Record<string, string>;
|
|
81
80
|
schedule?: string;
|
|
82
81
|
timezone?: string;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
WorkflowDefinition,
|
|
3
|
+
WorkflowVariable,
|
|
4
|
+
} from "@ainetwork/adk/types/memory";
|
|
1
5
|
import { type Document, Schema } from "mongoose";
|
|
2
6
|
import mongoose from "mongoose";
|
|
3
7
|
|
|
@@ -25,6 +29,9 @@ export const WorkflowTemplateObjectSchema = new Schema(
|
|
|
25
29
|
type: String,
|
|
26
30
|
required: true,
|
|
27
31
|
},
|
|
32
|
+
definition: {
|
|
33
|
+
type: Schema.Types.Mixed,
|
|
34
|
+
},
|
|
28
35
|
variables: {
|
|
29
36
|
type: Schema.Types.Mixed,
|
|
30
37
|
},
|
|
@@ -40,16 +47,8 @@ export interface WorkflowTemplateDocument extends Document {
|
|
|
40
47
|
description: string;
|
|
41
48
|
active: boolean;
|
|
42
49
|
content: string;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
{
|
|
46
|
-
id: string;
|
|
47
|
-
label: string;
|
|
48
|
-
type: "select" | "date_range" | "date_parts" | "text" | "number";
|
|
49
|
-
options?: Array<string>;
|
|
50
|
-
resolveAt?: "creation" | "execution";
|
|
51
|
-
}
|
|
52
|
-
>;
|
|
50
|
+
definition?: WorkflowDefinition;
|
|
51
|
+
variables?: Record<string, WorkflowVariable>;
|
|
53
52
|
}
|
|
54
53
|
|
|
55
54
|
export const WorkflowTemplateModel = mongoose.model<WorkflowTemplateDocument>(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ainetwork/adk-provider-memory-mongodb",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"author": "AI Network (https://ainetwork.ai)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"mongoose": "^8.16.5"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@ainetwork/adk": "^0.
|
|
34
|
+
"@ainetwork/adk": "^0.6.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"typescript": "^5.0.0"
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "e3e922e5b932ce07902d0ad5b3460a22aae23960"
|
|
44
44
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../models/user-workflow.model.ts"],"sourcesContent":["import { type Document, Schema } from \"mongoose\";\nimport mongoose from \"mongoose\";\n\nexport const UserWorkflowObjectSchema = new Schema(\n\t{\n\t\tworkflowId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tunique: true,\n\t\t},\n\t\tuserId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t},\n\t\ttitle: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tdescription: {\n\t\t\ttype: String,\n\t\t},\n\t\tactive: {\n\t\t\ttype: Boolean,\n\t\t\trequired: true,\n\t\t\tdefault: false,\n\t\t},\n\t\ttemplateId: {\n\t\t\ttype: String,\n\t\t},\n\t\tcontent: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tvariables: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t\tvariableValues: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t\tschedule: {\n\t\t\ttype: String,\n\t\t},\n\t\ttimezone: {\n\t\t\ttype: String,\n\t\t},\n\t\tlastRunAt: {\n\t\t\ttype: Number,\n\t\t},\n\t\tnextRunAt: {\n\t\t\ttype: Number,\n\t\t},\n\t\tlastThreadId: {\n\t\t\ttype: String,\n\t\t},\n\t},\n\t{\n\t\ttimestamps: true,\n\t}\n);\n\nexport interface UserWorkflowDocument extends Document {\n\tworkflowId: string;\n\tuserId: string;\n\ttitle: string;\n\tdescription?: string;\n\tactive: boolean;\n\ttemplateId?: string;\n\tcontent: string;\n\tvariables?: Record<\n\t\tstring,\n\t\t{\n\t\t\tid: string;\n\t\t\tlabel: string;\n\t\t\ttype: \"select\" | \"date_range\" | \"date_parts\" | \"text\" | \"number\";\n\t\t\toptions?: Array<string>;\n\t\t\tresolveAt?: \"creation\" | \"execution\";\n\t\t}\n\t>;\n\tvariableValues?: Record<string, string>;\n\tschedule?: string;\n\ttimezone?: string;\n\tlastRunAt?: number;\n\tnextRunAt?: number;\n\tlastThreadId?: string;\n}\n\nexport const UserWorkflowModel = mongoose.model<UserWorkflowDocument>(\n\t\"UserWorkflow\",\n\tUserWorkflowObjectSchema\n);\n"],"mappings":";AAAA,SAAwB,cAAc;AACtC,OAAO,cAAc;AAEd,IAAM,2BAA2B,IAAI;AAAA,EAC3C;AAAA,IACC,YAAY;AAAA,MACX,MAAM;AAAA,MACN,UAAU;AAAA,MACV,QAAQ;AAAA,IACT;AAAA,IACA,QAAQ;AAAA,MACP,MAAM;AAAA,MACN,UAAU;AAAA,MACV,OAAO;AAAA,IACR;AAAA,IACA,OAAO;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,aAAa;AAAA,MACZ,MAAM;AAAA,IACP;AAAA,IACA,QAAQ;AAAA,MACP,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,IACV;AAAA,IACA,YAAY;AAAA,MACX,MAAM;AAAA,IACP;AAAA,IACA,SAAS;AAAA,MACR,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,WAAW;AAAA,MACV,MAAM,OAAO,MAAM;AAAA,IACpB;AAAA,IACA,gBAAgB;AAAA,MACf,MAAM,OAAO,MAAM;AAAA,IACpB;AAAA,IACA,UAAU;AAAA,MACT,MAAM;AAAA,IACP;AAAA,IACA,UAAU;AAAA,MACT,MAAM;AAAA,IACP;AAAA,IACA,WAAW;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,WAAW;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,cAAc;AAAA,MACb,MAAM;AAAA,IACP;AAAA,EACD;AAAA,EACA;AAAA,IACC,YAAY;AAAA,EACb;AACD;AA4BO,IAAM,oBAAoB,SAAS;AAAA,EACzC;AAAA,EACA;AACD;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../models/workflow-template.model.ts"],"sourcesContent":["import { type Document, Schema } from \"mongoose\";\nimport mongoose from \"mongoose\";\n\nexport const WorkflowTemplateObjectSchema = new Schema(\n\t{\n\t\ttemplateId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tunique: true,\n\t\t},\n\t\ttitle: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tdescription: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tactive: {\n\t\t\ttype: Boolean,\n\t\t\trequired: true,\n\t\t\tdefault: false,\n\t\t},\n\t\tcontent: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tvariables: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t},\n\t{\n\t\ttimestamps: true,\n\t}\n);\n\nexport interface WorkflowTemplateDocument extends Document {\n\ttemplateId: string;\n\ttitle: string;\n\tdescription: string;\n\tactive: boolean;\n\tcontent: string;\n\tvariables?: Record<\n\t\tstring,\n\t\t{\n\t\t\tid: string;\n\t\t\tlabel: string;\n\t\t\ttype: \"select\" | \"date_range\" | \"date_parts\" | \"text\" | \"number\";\n\t\t\toptions?: Array<string>;\n\t\t\tresolveAt?: \"creation\" | \"execution\";\n\t\t}\n\t>;\n}\n\nexport const WorkflowTemplateModel = mongoose.model<WorkflowTemplateDocument>(\n\t\"WorkflowTemplate\",\n\tWorkflowTemplateObjectSchema\n);\n"],"mappings":";AAAA,SAAwB,cAAc;AACtC,OAAO,cAAc;AAEd,IAAM,+BAA+B,IAAI;AAAA,EAC/C;AAAA,IACC,YAAY;AAAA,MACX,MAAM;AAAA,MACN,UAAU;AAAA,MACV,QAAQ;AAAA,IACT;AAAA,IACA,OAAO;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,aAAa;AAAA,MACZ,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,QAAQ;AAAA,MACP,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,IACV;AAAA,IACA,SAAS;AAAA,MACR,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,WAAW;AAAA,MACV,MAAM,OAAO,MAAM;AAAA,IACpB;AAAA,EACD;AAAA,EACA;AAAA,IACC,YAAY;AAAA,EACb;AACD;AAoBO,IAAM,wBAAwB,SAAS;AAAA,EAC7C;AAAA,EACA;AACD;","names":[]}
|