@ainetwork/adk-provider-memory-mongodb 0.6.1 → 0.7.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-SXSMKZSK.js → chunk-4L2JYSVK.js} +4 -1
- package/dist/chunk-4L2JYSVK.js.map +1 -0
- package/dist/{chunk-4RSJL5V4.js → chunk-E6CDPMEQ.js} +4 -1
- package/dist/chunk-E6CDPMEQ.js.map +1 -0
- package/dist/chunk-JMRBIQNX.js +96 -0
- package/dist/chunk-JMRBIQNX.js.map +1 -0
- package/dist/index.cjs +196 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +69 -2
- package/dist/index.js.map +1 -1
- package/dist/models/document.model.cjs +128 -0
- package/dist/models/document.model.cjs.map +1 -0
- package/dist/models/document.model.d.cts +87 -0
- package/dist/models/document.model.d.ts +87 -0
- package/dist/models/document.model.js +9 -0
- package/dist/models/document.model.js.map +1 -0
- package/dist/models/messages.model.d.cts +9 -9
- package/dist/models/messages.model.d.ts +9 -9
- package/dist/models/threads.model.d.cts +6 -6
- package/dist/models/threads.model.d.ts +6 -6
- 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 +7 -3
- package/dist/models/user-workflow.model.d.ts +7 -3
- 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 +7 -3
- package/dist/models/workflow-template.model.d.ts +7 -3
- package/dist/models/workflow-template.model.js +1 -1
- package/implements/base.memory.ts +12 -1
- package/implements/document.memory.ts +88 -0
- package/models/document.model.ts +113 -0
- package/models/user-workflow.model.ts +4 -0
- package/models/workflow-template.model.ts +4 -0
- package/package.json +3 -3
- package/dist/chunk-4RSJL5V4.js.map +0 -1
- package/dist/chunk-SXSMKZSK.js.map +0 -1
|
@@ -25,6 +25,9 @@ var UserWorkflowObjectSchema = new Schema(
|
|
|
25
25
|
required: true,
|
|
26
26
|
default: false
|
|
27
27
|
},
|
|
28
|
+
category: {
|
|
29
|
+
type: String
|
|
30
|
+
},
|
|
28
31
|
templateId: {
|
|
29
32
|
type: String
|
|
30
33
|
},
|
|
@@ -70,4 +73,4 @@ export {
|
|
|
70
73
|
UserWorkflowObjectSchema,
|
|
71
74
|
UserWorkflowModel
|
|
72
75
|
};
|
|
73
|
-
//# sourceMappingURL=chunk-
|
|
76
|
+
//# sourceMappingURL=chunk-4L2JYSVK.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\tcategory: {\n\t\t\ttype: String,\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\tcategory?: string;\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,UAAU;AAAA,MACT,MAAM;AAAA,IACP;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;AAqBO,IAAM,oBAAoB,SAAS;AAAA,EACzC;AAAA,EACA;AACD;","names":[]}
|
|
@@ -21,6 +21,9 @@ var WorkflowTemplateObjectSchema = new Schema(
|
|
|
21
21
|
required: true,
|
|
22
22
|
default: false
|
|
23
23
|
},
|
|
24
|
+
category: {
|
|
25
|
+
type: String
|
|
26
|
+
},
|
|
24
27
|
content: {
|
|
25
28
|
type: String,
|
|
26
29
|
required: true
|
|
@@ -45,4 +48,4 @@ export {
|
|
|
45
48
|
WorkflowTemplateObjectSchema,
|
|
46
49
|
WorkflowTemplateModel
|
|
47
50
|
};
|
|
48
|
-
//# sourceMappingURL=chunk-
|
|
51
|
+
//# sourceMappingURL=chunk-E6CDPMEQ.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\tcategory: {\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},\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\tcategory?: string;\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,UAAU;AAAA,MACT,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,EACD;AAAA,EACA;AAAA,IACC,YAAY;AAAA,EACb;AACD;AAaO,IAAM,wBAAwB,SAAS;AAAA,EAC7C;AAAA,EACA;AACD;","names":[]}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// models/document.model.ts
|
|
2
|
+
import {
|
|
3
|
+
DocumentFormat,
|
|
4
|
+
DocumentSource
|
|
5
|
+
} from "@ainetwork/adk/types/document";
|
|
6
|
+
import { Schema } from "mongoose";
|
|
7
|
+
import mongoose from "mongoose";
|
|
8
|
+
var DocumentObjectSchema = new Schema(
|
|
9
|
+
{
|
|
10
|
+
documentId: {
|
|
11
|
+
type: String,
|
|
12
|
+
required: true,
|
|
13
|
+
unique: true
|
|
14
|
+
},
|
|
15
|
+
userId: {
|
|
16
|
+
type: String,
|
|
17
|
+
required: true,
|
|
18
|
+
index: true
|
|
19
|
+
},
|
|
20
|
+
title: {
|
|
21
|
+
type: String,
|
|
22
|
+
required: true
|
|
23
|
+
},
|
|
24
|
+
format: {
|
|
25
|
+
type: String,
|
|
26
|
+
enum: Object.values(DocumentFormat),
|
|
27
|
+
required: true,
|
|
28
|
+
default: DocumentFormat.MARKDOWN
|
|
29
|
+
},
|
|
30
|
+
content: {
|
|
31
|
+
type: String,
|
|
32
|
+
required: true
|
|
33
|
+
},
|
|
34
|
+
blocks: {
|
|
35
|
+
type: Schema.Types.Mixed
|
|
36
|
+
},
|
|
37
|
+
slots: {
|
|
38
|
+
type: Schema.Types.Mixed
|
|
39
|
+
},
|
|
40
|
+
// Cached AI advice ({ content, generatedAt }). Free-form so the schema
|
|
41
|
+
// doesn't strip it on update (mongoose strict mode).
|
|
42
|
+
advice: {
|
|
43
|
+
type: Schema.Types.Mixed
|
|
44
|
+
},
|
|
45
|
+
// Faceted grouping (e.g. category/workplaceId/month). Stored as a free
|
|
46
|
+
// map; index specific keys (e.g. `labels.workplaceId`) if query volume
|
|
47
|
+
// warrants it.
|
|
48
|
+
labels: {
|
|
49
|
+
type: Schema.Types.Mixed
|
|
50
|
+
},
|
|
51
|
+
source: {
|
|
52
|
+
type: String,
|
|
53
|
+
enum: Object.values(DocumentSource),
|
|
54
|
+
required: true
|
|
55
|
+
},
|
|
56
|
+
workflowId: {
|
|
57
|
+
type: String,
|
|
58
|
+
index: true
|
|
59
|
+
},
|
|
60
|
+
threadId: {
|
|
61
|
+
type: String,
|
|
62
|
+
index: true
|
|
63
|
+
},
|
|
64
|
+
version: {
|
|
65
|
+
type: Number,
|
|
66
|
+
required: true,
|
|
67
|
+
default: 1
|
|
68
|
+
},
|
|
69
|
+
editedManually: {
|
|
70
|
+
type: Boolean
|
|
71
|
+
},
|
|
72
|
+
createdAt: {
|
|
73
|
+
type: String,
|
|
74
|
+
required: true
|
|
75
|
+
},
|
|
76
|
+
updatedAt: {
|
|
77
|
+
type: String,
|
|
78
|
+
required: true
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
// `createdAt`/`updatedAt` are caller-supplied ISO strings (see Document type),
|
|
82
|
+
// so mongoose's automatic Date timestamps are intentionally disabled.
|
|
83
|
+
{
|
|
84
|
+
timestamps: false
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
var DocumentModel = mongoose.model(
|
|
88
|
+
"Document",
|
|
89
|
+
DocumentObjectSchema
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
export {
|
|
93
|
+
DocumentObjectSchema,
|
|
94
|
+
DocumentModel
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=chunk-JMRBIQNX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../models/document.model.ts"],"sourcesContent":["import {\n\ttype DocumentAdvice,\n\tDocumentFormat,\n\ttype DocumentSlot,\n\tDocumentSource,\n} from \"@ainetwork/adk/types/document\";\nimport type { WorkflowRenderedBlock } from \"@ainetwork/adk/types/memory\";\nimport { type Document, Schema } from \"mongoose\";\nimport mongoose from \"mongoose\";\n\nexport const DocumentObjectSchema = new Schema(\n\t{\n\t\tdocumentId: {\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\tformat: {\n\t\t\ttype: String,\n\t\t\tenum: Object.values(DocumentFormat),\n\t\t\trequired: true,\n\t\t\tdefault: DocumentFormat.MARKDOWN,\n\t\t},\n\t\tcontent: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tblocks: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t\tslots: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t\t// Cached AI advice ({ content, generatedAt }). Free-form so the schema\n\t\t// doesn't strip it on update (mongoose strict mode).\n\t\tadvice: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t\t// Faceted grouping (e.g. category/workplaceId/month). Stored as a free\n\t\t// map; index specific keys (e.g. `labels.workplaceId`) if query volume\n\t\t// warrants it.\n\t\tlabels: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t},\n\t\tsource: {\n\t\t\ttype: String,\n\t\t\tenum: Object.values(DocumentSource),\n\t\t\trequired: true,\n\t\t},\n\t\tworkflowId: {\n\t\t\ttype: String,\n\t\t\tindex: true,\n\t\t},\n\t\tthreadId: {\n\t\t\ttype: String,\n\t\t\tindex: true,\n\t\t},\n\t\tversion: {\n\t\t\ttype: Number,\n\t\t\trequired: true,\n\t\t\tdefault: 1,\n\t\t},\n\t\teditedManually: {\n\t\t\ttype: Boolean,\n\t\t},\n\t\tcreatedAt: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tupdatedAt: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t},\n\t// `createdAt`/`updatedAt` are caller-supplied ISO strings (see Document type),\n\t// so mongoose's automatic Date timestamps are intentionally disabled.\n\t{\n\t\ttimestamps: false,\n\t}\n);\n\nexport interface DocumentDocument extends Document {\n\tdocumentId: string;\n\tuserId: string;\n\ttitle: string;\n\tformat: DocumentFormat;\n\tcontent: string;\n\tblocks?: WorkflowRenderedBlock[];\n\tslots?: DocumentSlot[];\n\tadvice?: DocumentAdvice;\n\tlabels?: Record<string, string>;\n\tsource: DocumentSource;\n\tworkflowId?: string;\n\tthreadId?: string;\n\tversion: number;\n\teditedManually?: boolean;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport const DocumentModel = mongoose.model<DocumentDocument>(\n\t\"Document\",\n\tDocumentObjectSchema\n);\n"],"mappings":";AAAA;AAAA,EAEC;AAAA,EAEA;AAAA,OACM;AAEP,SAAwB,cAAc;AACtC,OAAO,cAAc;AAEd,IAAM,uBAAuB,IAAI;AAAA,EACvC;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,QAAQ;AAAA,MACP,MAAM;AAAA,MACN,MAAM,OAAO,OAAO,cAAc;AAAA,MAClC,UAAU;AAAA,MACV,SAAS,eAAe;AAAA,IACzB;AAAA,IACA,SAAS;AAAA,MACR,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,QAAQ;AAAA,MACP,MAAM,OAAO,MAAM;AAAA,IACpB;AAAA,IACA,OAAO;AAAA,MACN,MAAM,OAAO,MAAM;AAAA,IACpB;AAAA;AAAA;AAAA,IAGA,QAAQ;AAAA,MACP,MAAM,OAAO,MAAM;AAAA,IACpB;AAAA;AAAA;AAAA;AAAA,IAIA,QAAQ;AAAA,MACP,MAAM,OAAO,MAAM;AAAA,IACpB;AAAA,IACA,QAAQ;AAAA,MACP,MAAM;AAAA,MACN,MAAM,OAAO,OAAO,cAAc;AAAA,MAClC,UAAU;AAAA,IACX;AAAA,IACA,YAAY;AAAA,MACX,MAAM;AAAA,MACN,OAAO;AAAA,IACR;AAAA,IACA,UAAU;AAAA,MACT,MAAM;AAAA,MACN,OAAO;AAAA,IACR;AAAA,IACA,SAAS;AAAA,MACR,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,IACV;AAAA,IACA,gBAAgB;AAAA,MACf,MAAM;AAAA,IACP;AAAA,IACA,WAAW;AAAA,MACV,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,WAAW;AAAA,MACV,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,EACD;AAAA;AAAA;AAAA,EAGA;AAAA,IACC,YAAY;AAAA,EACb;AACD;AAqBO,IAAM,gBAAgB,SAAS;AAAA,EACrC;AAAA,EACA;AACD;","names":[]}
|
package/dist/index.cjs
CHANGED
|
@@ -35,7 +35,7 @@ __export(index_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(index_exports);
|
|
36
36
|
|
|
37
37
|
// implements/base.memory.ts
|
|
38
|
-
var
|
|
38
|
+
var import_mongoose14 = __toESM(require("mongoose"), 1);
|
|
39
39
|
var import_logger2 = require("@ainetwork/adk/utils/logger");
|
|
40
40
|
|
|
41
41
|
// models/agent.model.ts
|
|
@@ -145,9 +145,153 @@ var MongoDBAgent = class {
|
|
|
145
145
|
}
|
|
146
146
|
};
|
|
147
147
|
|
|
148
|
+
// models/document.model.ts
|
|
149
|
+
var import_document = require("@ainetwork/adk/types/document");
|
|
150
|
+
var import_mongoose3 = require("mongoose");
|
|
151
|
+
var import_mongoose4 = __toESM(require("mongoose"), 1);
|
|
152
|
+
var DocumentObjectSchema = new import_mongoose3.Schema(
|
|
153
|
+
{
|
|
154
|
+
documentId: {
|
|
155
|
+
type: String,
|
|
156
|
+
required: true,
|
|
157
|
+
unique: true
|
|
158
|
+
},
|
|
159
|
+
userId: {
|
|
160
|
+
type: String,
|
|
161
|
+
required: true,
|
|
162
|
+
index: true
|
|
163
|
+
},
|
|
164
|
+
title: {
|
|
165
|
+
type: String,
|
|
166
|
+
required: true
|
|
167
|
+
},
|
|
168
|
+
format: {
|
|
169
|
+
type: String,
|
|
170
|
+
enum: Object.values(import_document.DocumentFormat),
|
|
171
|
+
required: true,
|
|
172
|
+
default: import_document.DocumentFormat.MARKDOWN
|
|
173
|
+
},
|
|
174
|
+
content: {
|
|
175
|
+
type: String,
|
|
176
|
+
required: true
|
|
177
|
+
},
|
|
178
|
+
blocks: {
|
|
179
|
+
type: import_mongoose3.Schema.Types.Mixed
|
|
180
|
+
},
|
|
181
|
+
slots: {
|
|
182
|
+
type: import_mongoose3.Schema.Types.Mixed
|
|
183
|
+
},
|
|
184
|
+
// Cached AI advice ({ content, generatedAt }). Free-form so the schema
|
|
185
|
+
// doesn't strip it on update (mongoose strict mode).
|
|
186
|
+
advice: {
|
|
187
|
+
type: import_mongoose3.Schema.Types.Mixed
|
|
188
|
+
},
|
|
189
|
+
// Faceted grouping (e.g. category/workplaceId/month). Stored as a free
|
|
190
|
+
// map; index specific keys (e.g. `labels.workplaceId`) if query volume
|
|
191
|
+
// warrants it.
|
|
192
|
+
labels: {
|
|
193
|
+
type: import_mongoose3.Schema.Types.Mixed
|
|
194
|
+
},
|
|
195
|
+
source: {
|
|
196
|
+
type: String,
|
|
197
|
+
enum: Object.values(import_document.DocumentSource),
|
|
198
|
+
required: true
|
|
199
|
+
},
|
|
200
|
+
workflowId: {
|
|
201
|
+
type: String,
|
|
202
|
+
index: true
|
|
203
|
+
},
|
|
204
|
+
threadId: {
|
|
205
|
+
type: String,
|
|
206
|
+
index: true
|
|
207
|
+
},
|
|
208
|
+
version: {
|
|
209
|
+
type: Number,
|
|
210
|
+
required: true,
|
|
211
|
+
default: 1
|
|
212
|
+
},
|
|
213
|
+
editedManually: {
|
|
214
|
+
type: Boolean
|
|
215
|
+
},
|
|
216
|
+
createdAt: {
|
|
217
|
+
type: String,
|
|
218
|
+
required: true
|
|
219
|
+
},
|
|
220
|
+
updatedAt: {
|
|
221
|
+
type: String,
|
|
222
|
+
required: true
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
// `createdAt`/`updatedAt` are caller-supplied ISO strings (see Document type),
|
|
226
|
+
// so mongoose's automatic Date timestamps are intentionally disabled.
|
|
227
|
+
{
|
|
228
|
+
timestamps: false
|
|
229
|
+
}
|
|
230
|
+
);
|
|
231
|
+
var DocumentModel = import_mongoose4.default.model(
|
|
232
|
+
"Document",
|
|
233
|
+
DocumentObjectSchema
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
// implements/document.memory.ts
|
|
237
|
+
var MongoDBDocument = class {
|
|
238
|
+
executeWithRetry;
|
|
239
|
+
getOperationTimeout;
|
|
240
|
+
constructor(executeWithRetry, getOperationTimeout) {
|
|
241
|
+
this.executeWithRetry = executeWithRetry;
|
|
242
|
+
this.getOperationTimeout = getOperationTimeout;
|
|
243
|
+
}
|
|
244
|
+
async getDocument(documentId) {
|
|
245
|
+
return this.executeWithRetry(async () => {
|
|
246
|
+
const timeout = this.getOperationTimeout();
|
|
247
|
+
const document = await DocumentModel.findOne({ documentId }).maxTimeMS(timeout).lean();
|
|
248
|
+
return document || void 0;
|
|
249
|
+
}, "getDocument()");
|
|
250
|
+
}
|
|
251
|
+
async createDocument(document) {
|
|
252
|
+
return this.executeWithRetry(async () => {
|
|
253
|
+
const created = await DocumentModel.create(document);
|
|
254
|
+
return created.toObject();
|
|
255
|
+
}, "createDocument()");
|
|
256
|
+
}
|
|
257
|
+
async updateDocument(documentId, document) {
|
|
258
|
+
const { documentId: _documentId, ...mutableUpdates } = document;
|
|
259
|
+
return this.executeWithRetry(async () => {
|
|
260
|
+
const timeout = this.getOperationTimeout();
|
|
261
|
+
await DocumentModel.updateOne(
|
|
262
|
+
{ documentId },
|
|
263
|
+
{ $set: mutableUpdates }
|
|
264
|
+
).maxTimeMS(timeout);
|
|
265
|
+
}, "updateDocument()");
|
|
266
|
+
}
|
|
267
|
+
async deleteDocument(documentId) {
|
|
268
|
+
return this.executeWithRetry(async () => {
|
|
269
|
+
const timeout = this.getOperationTimeout();
|
|
270
|
+
await DocumentModel.deleteOne({ documentId }).maxTimeMS(timeout);
|
|
271
|
+
}, "deleteDocument()");
|
|
272
|
+
}
|
|
273
|
+
async listDocuments(userId, filter) {
|
|
274
|
+
return this.executeWithRetry(async () => {
|
|
275
|
+
const timeout = this.getOperationTimeout();
|
|
276
|
+
const query = {};
|
|
277
|
+
if (userId) query.userId = userId;
|
|
278
|
+
if (filter?.workflowId) query.workflowId = filter.workflowId;
|
|
279
|
+
if (filter?.threadId) query.threadId = filter.threadId;
|
|
280
|
+
if (filter?.source) query.source = filter.source;
|
|
281
|
+
if (filter?.labels) {
|
|
282
|
+
for (const [key, value] of Object.entries(filter.labels)) {
|
|
283
|
+
query[`labels.${key}`] = value;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
const documents = await DocumentModel.find(query).maxTimeMS(timeout).lean();
|
|
287
|
+
return documents;
|
|
288
|
+
}, "listDocuments()");
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
|
|
148
292
|
// models/intent.model.ts
|
|
149
|
-
var
|
|
150
|
-
var IntentObjectSchema = new
|
|
293
|
+
var import_mongoose5 = __toESM(require("mongoose"), 1);
|
|
294
|
+
var IntentObjectSchema = new import_mongoose5.Schema(
|
|
151
295
|
{
|
|
152
296
|
id: {
|
|
153
297
|
type: String,
|
|
@@ -187,7 +331,7 @@ var IntentObjectSchema = new import_mongoose3.Schema(
|
|
|
187
331
|
}
|
|
188
332
|
}
|
|
189
333
|
);
|
|
190
|
-
var IntentModel =
|
|
334
|
+
var IntentModel = import_mongoose5.default.model("Intent", IntentObjectSchema);
|
|
191
335
|
|
|
192
336
|
// implements/intent.memory.ts
|
|
193
337
|
var MongoDBIntent = class {
|
|
@@ -241,9 +385,9 @@ var MongoDBIntent = class {
|
|
|
241
385
|
|
|
242
386
|
// models/threads.model.ts
|
|
243
387
|
var import_memory = require("@ainetwork/adk/types/memory");
|
|
244
|
-
var
|
|
245
|
-
var
|
|
246
|
-
var ThreadObjectSchema = new
|
|
388
|
+
var import_mongoose6 = require("mongoose");
|
|
389
|
+
var import_mongoose7 = __toESM(require("mongoose"), 1);
|
|
390
|
+
var ThreadObjectSchema = new import_mongoose6.Schema(
|
|
247
391
|
{
|
|
248
392
|
type: {
|
|
249
393
|
type: String,
|
|
@@ -279,20 +423,20 @@ var ThreadObjectSchema = new import_mongoose4.Schema(
|
|
|
279
423
|
timestamps: true
|
|
280
424
|
}
|
|
281
425
|
);
|
|
282
|
-
var ThreadModel =
|
|
426
|
+
var ThreadModel = import_mongoose7.default.model("Thread", ThreadObjectSchema);
|
|
283
427
|
|
|
284
428
|
// models/messages.model.ts
|
|
285
429
|
var import_memory2 = require("@ainetwork/adk/types/memory");
|
|
286
|
-
var
|
|
287
|
-
var
|
|
288
|
-
var MessageContentObjectSchema = new
|
|
430
|
+
var import_mongoose8 = require("mongoose");
|
|
431
|
+
var import_mongoose9 = __toESM(require("mongoose"), 1);
|
|
432
|
+
var MessageContentObjectSchema = new import_mongoose8.Schema(
|
|
289
433
|
{
|
|
290
434
|
type: { type: String, required: true },
|
|
291
|
-
parts: { type: [
|
|
435
|
+
parts: { type: [import_mongoose8.Schema.Types.Mixed], required: true }
|
|
292
436
|
},
|
|
293
437
|
{ _id: false }
|
|
294
438
|
);
|
|
295
|
-
var MessageObjectSchema = new
|
|
439
|
+
var MessageObjectSchema = new import_mongoose8.Schema(
|
|
296
440
|
{
|
|
297
441
|
messageId: {
|
|
298
442
|
type: String,
|
|
@@ -323,7 +467,7 @@ var MessageObjectSchema = new import_mongoose6.Schema(
|
|
|
323
467
|
required: true
|
|
324
468
|
},
|
|
325
469
|
metadata: {
|
|
326
|
-
type:
|
|
470
|
+
type: import_mongoose8.Schema.Types.Mixed,
|
|
327
471
|
default: {}
|
|
328
472
|
}
|
|
329
473
|
},
|
|
@@ -332,7 +476,7 @@ var MessageObjectSchema = new import_mongoose6.Schema(
|
|
|
332
476
|
}
|
|
333
477
|
);
|
|
334
478
|
MessageObjectSchema.index({ threadId: 1, messageId: 1 }, { unique: true });
|
|
335
|
-
var MessageModel =
|
|
479
|
+
var MessageModel = import_mongoose9.default.model("Message", MessageObjectSchema);
|
|
336
480
|
|
|
337
481
|
// implements/thread.memory.ts
|
|
338
482
|
var import_logger = require("@ainetwork/adk/utils/logger");
|
|
@@ -447,9 +591,9 @@ var MongoDBThread = class {
|
|
|
447
591
|
};
|
|
448
592
|
|
|
449
593
|
// models/user-workflow.model.ts
|
|
450
|
-
var
|
|
451
|
-
var
|
|
452
|
-
var UserWorkflowObjectSchema = new
|
|
594
|
+
var import_mongoose10 = require("mongoose");
|
|
595
|
+
var import_mongoose11 = __toESM(require("mongoose"), 1);
|
|
596
|
+
var UserWorkflowObjectSchema = new import_mongoose10.Schema(
|
|
453
597
|
{
|
|
454
598
|
workflowId: {
|
|
455
599
|
type: String,
|
|
@@ -473,6 +617,9 @@ var UserWorkflowObjectSchema = new import_mongoose8.Schema(
|
|
|
473
617
|
required: true,
|
|
474
618
|
default: false
|
|
475
619
|
},
|
|
620
|
+
category: {
|
|
621
|
+
type: String
|
|
622
|
+
},
|
|
476
623
|
templateId: {
|
|
477
624
|
type: String
|
|
478
625
|
},
|
|
@@ -481,13 +628,13 @@ var UserWorkflowObjectSchema = new import_mongoose8.Schema(
|
|
|
481
628
|
required: true
|
|
482
629
|
},
|
|
483
630
|
definition: {
|
|
484
|
-
type:
|
|
631
|
+
type: import_mongoose10.Schema.Types.Mixed
|
|
485
632
|
},
|
|
486
633
|
variables: {
|
|
487
|
-
type:
|
|
634
|
+
type: import_mongoose10.Schema.Types.Mixed
|
|
488
635
|
},
|
|
489
636
|
variableValues: {
|
|
490
|
-
type:
|
|
637
|
+
type: import_mongoose10.Schema.Types.Mixed
|
|
491
638
|
},
|
|
492
639
|
schedule: {
|
|
493
640
|
type: String
|
|
@@ -509,7 +656,7 @@ var UserWorkflowObjectSchema = new import_mongoose8.Schema(
|
|
|
509
656
|
timestamps: true
|
|
510
657
|
}
|
|
511
658
|
);
|
|
512
|
-
var UserWorkflowModel =
|
|
659
|
+
var UserWorkflowModel = import_mongoose11.default.model(
|
|
513
660
|
"UserWorkflow",
|
|
514
661
|
UserWorkflowObjectSchema
|
|
515
662
|
);
|
|
@@ -575,9 +722,9 @@ var MongoDBUserWorkflow = class {
|
|
|
575
722
|
};
|
|
576
723
|
|
|
577
724
|
// models/workflow-template.model.ts
|
|
578
|
-
var
|
|
579
|
-
var
|
|
580
|
-
var WorkflowTemplateObjectSchema = new
|
|
725
|
+
var import_mongoose12 = require("mongoose");
|
|
726
|
+
var import_mongoose13 = __toESM(require("mongoose"), 1);
|
|
727
|
+
var WorkflowTemplateObjectSchema = new import_mongoose12.Schema(
|
|
581
728
|
{
|
|
582
729
|
templateId: {
|
|
583
730
|
type: String,
|
|
@@ -597,22 +744,25 @@ var WorkflowTemplateObjectSchema = new import_mongoose10.Schema(
|
|
|
597
744
|
required: true,
|
|
598
745
|
default: false
|
|
599
746
|
},
|
|
747
|
+
category: {
|
|
748
|
+
type: String
|
|
749
|
+
},
|
|
600
750
|
content: {
|
|
601
751
|
type: String,
|
|
602
752
|
required: true
|
|
603
753
|
},
|
|
604
754
|
definition: {
|
|
605
|
-
type:
|
|
755
|
+
type: import_mongoose12.Schema.Types.Mixed
|
|
606
756
|
},
|
|
607
757
|
variables: {
|
|
608
|
-
type:
|
|
758
|
+
type: import_mongoose12.Schema.Types.Mixed
|
|
609
759
|
}
|
|
610
760
|
},
|
|
611
761
|
{
|
|
612
762
|
timestamps: true
|
|
613
763
|
}
|
|
614
764
|
);
|
|
615
|
-
var WorkflowTemplateModel =
|
|
765
|
+
var WorkflowTemplateModel = import_mongoose13.default.model(
|
|
616
766
|
"WorkflowTemplate",
|
|
617
767
|
WorkflowTemplateObjectSchema
|
|
618
768
|
);
|
|
@@ -682,6 +832,7 @@ var MongoDBMemory = class _MongoDBMemory {
|
|
|
682
832
|
threadMemory;
|
|
683
833
|
workflowTemplateMemory;
|
|
684
834
|
userWorkflowMemory;
|
|
835
|
+
documentMemory;
|
|
685
836
|
constructor(config) {
|
|
686
837
|
const cfg = typeof config === "string" ? { uri: config } : config;
|
|
687
838
|
this.uri = cfg.uri;
|
|
@@ -727,6 +878,10 @@ var MongoDBMemory = class _MongoDBMemory {
|
|
|
727
878
|
this.executeWithRetry.bind(this),
|
|
728
879
|
this.getOperationTimeout.bind(this)
|
|
729
880
|
);
|
|
881
|
+
this.documentMemory = new MongoDBDocument(
|
|
882
|
+
this.executeWithRetry.bind(this),
|
|
883
|
+
this.getOperationTimeout.bind(this)
|
|
884
|
+
);
|
|
730
885
|
}
|
|
731
886
|
getAgentMemory() {
|
|
732
887
|
return this.agentMemory;
|
|
@@ -743,26 +898,29 @@ var MongoDBMemory = class _MongoDBMemory {
|
|
|
743
898
|
getUserWorkflowMemory() {
|
|
744
899
|
return this.userWorkflowMemory;
|
|
745
900
|
}
|
|
901
|
+
getDocumentMemory() {
|
|
902
|
+
return this.documentMemory;
|
|
903
|
+
}
|
|
746
904
|
setupMongooseEventListeners() {
|
|
747
905
|
if (this.eventListenersSetup) return;
|
|
748
906
|
this.eventListenersSetup = true;
|
|
749
|
-
|
|
907
|
+
import_mongoose14.default.connection.on("connected", () => {
|
|
750
908
|
this.connected = true;
|
|
751
909
|
this.reconnectAttempts = 0;
|
|
752
910
|
this.reconnecting = false;
|
|
753
911
|
import_logger2.loggers.agent.info("MongoDB connected successfully");
|
|
754
912
|
});
|
|
755
|
-
|
|
913
|
+
import_mongoose14.default.connection.on("disconnected", () => {
|
|
756
914
|
this.connected = false;
|
|
757
915
|
import_logger2.loggers.agent.warn("MongoDB disconnected");
|
|
758
916
|
this.handleDisconnection();
|
|
759
917
|
});
|
|
760
|
-
|
|
918
|
+
import_mongoose14.default.connection.on("error", (error) => {
|
|
761
919
|
this.connected = false;
|
|
762
920
|
import_logger2.loggers.agent.error("MongoDB connection error:", error);
|
|
763
921
|
this.handleDisconnection();
|
|
764
922
|
});
|
|
765
|
-
|
|
923
|
+
import_mongoose14.default.connection.on("reconnected", () => {
|
|
766
924
|
this.connected = true;
|
|
767
925
|
this.reconnectAttempts = 0;
|
|
768
926
|
this.reconnecting = false;
|
|
@@ -780,7 +938,7 @@ var MongoDBMemory = class _MongoDBMemory {
|
|
|
780
938
|
`Attempting to reconnect to MongoDB (${this.reconnectAttempts}/${this.maxReconnectAttempts})...`
|
|
781
939
|
);
|
|
782
940
|
try {
|
|
783
|
-
await
|
|
941
|
+
await import_mongoose14.default.connect(this.uri, this.connectionConfig);
|
|
784
942
|
this.connected = true;
|
|
785
943
|
this.reconnectAttempts = 0;
|
|
786
944
|
this.reconnecting = false;
|
|
@@ -810,7 +968,7 @@ var MongoDBMemory = class _MongoDBMemory {
|
|
|
810
968
|
return;
|
|
811
969
|
}
|
|
812
970
|
try {
|
|
813
|
-
await
|
|
971
|
+
await import_mongoose14.default.connect(this.uri, this.connectionConfig);
|
|
814
972
|
this.connected = true;
|
|
815
973
|
this.reconnectAttempts = 0;
|
|
816
974
|
await this.setupTTLIndex();
|
|
@@ -829,7 +987,7 @@ var MongoDBMemory = class _MongoDBMemory {
|
|
|
829
987
|
clearInterval(this.orphanCleanupTimer);
|
|
830
988
|
this.orphanCleanupTimer = void 0;
|
|
831
989
|
}
|
|
832
|
-
await
|
|
990
|
+
await import_mongoose14.default.disconnect();
|
|
833
991
|
this.connected = false;
|
|
834
992
|
} catch (error) {
|
|
835
993
|
import_logger2.loggers.agent.error("Failed to disconnect from MongoDB:", error);
|
|
@@ -855,7 +1013,7 @@ var MongoDBMemory = class _MongoDBMemory {
|
|
|
855
1013
|
async setupTTLIndex() {
|
|
856
1014
|
if (this.threadTTLSeconds === void 0) return;
|
|
857
1015
|
try {
|
|
858
|
-
const db =
|
|
1016
|
+
const db = import_mongoose14.default.connection.db;
|
|
859
1017
|
if (!db) return;
|
|
860
1018
|
const collection = db.collection("threads");
|
|
861
1019
|
const indexes = await collection.indexes();
|
|
@@ -895,7 +1053,7 @@ var MongoDBMemory = class _MongoDBMemory {
|
|
|
895
1053
|
async cleanupOrphanedMessages() {
|
|
896
1054
|
if (!this.connected) return;
|
|
897
1055
|
try {
|
|
898
|
-
const db =
|
|
1056
|
+
const db = import_mongoose14.default.connection.db;
|
|
899
1057
|
if (!db) return;
|
|
900
1058
|
const existingThreadIds = await db.collection("threads").distinct("threadId");
|
|
901
1059
|
const result = await MessageModel.deleteMany({
|
|
@@ -932,7 +1090,7 @@ var MongoDBMemory = class _MongoDBMemory {
|
|
|
932
1090
|
`${operationName} failed due to too many sessions, disconnecting to release sessions...`
|
|
933
1091
|
);
|
|
934
1092
|
try {
|
|
935
|
-
await
|
|
1093
|
+
await import_mongoose14.default.disconnect();
|
|
936
1094
|
this.connected = false;
|
|
937
1095
|
} catch (disconnectError) {
|
|
938
1096
|
import_logger2.loggers.agent.error("Failed to disconnect during session cleanup:", disconnectError);
|