@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.
Files changed (40) hide show
  1. package/dist/{chunk-SXSMKZSK.js → chunk-4L2JYSVK.js} +4 -1
  2. package/dist/chunk-4L2JYSVK.js.map +1 -0
  3. package/dist/{chunk-4RSJL5V4.js → chunk-E6CDPMEQ.js} +4 -1
  4. package/dist/chunk-E6CDPMEQ.js.map +1 -0
  5. package/dist/chunk-JMRBIQNX.js +96 -0
  6. package/dist/chunk-JMRBIQNX.js.map +1 -0
  7. package/dist/index.cjs +196 -38
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +3 -1
  10. package/dist/index.d.ts +3 -1
  11. package/dist/index.js +69 -2
  12. package/dist/index.js.map +1 -1
  13. package/dist/models/document.model.cjs +128 -0
  14. package/dist/models/document.model.cjs.map +1 -0
  15. package/dist/models/document.model.d.cts +87 -0
  16. package/dist/models/document.model.d.ts +87 -0
  17. package/dist/models/document.model.js +9 -0
  18. package/dist/models/document.model.js.map +1 -0
  19. package/dist/models/messages.model.d.cts +9 -9
  20. package/dist/models/messages.model.d.ts +9 -9
  21. package/dist/models/threads.model.d.cts +6 -6
  22. package/dist/models/threads.model.d.ts +6 -6
  23. package/dist/models/user-workflow.model.cjs +3 -0
  24. package/dist/models/user-workflow.model.cjs.map +1 -1
  25. package/dist/models/user-workflow.model.d.cts +7 -3
  26. package/dist/models/user-workflow.model.d.ts +7 -3
  27. package/dist/models/user-workflow.model.js +1 -1
  28. package/dist/models/workflow-template.model.cjs +3 -0
  29. package/dist/models/workflow-template.model.cjs.map +1 -1
  30. package/dist/models/workflow-template.model.d.cts +7 -3
  31. package/dist/models/workflow-template.model.d.ts +7 -3
  32. package/dist/models/workflow-template.model.js +1 -1
  33. package/implements/base.memory.ts +12 -1
  34. package/implements/document.memory.ts +88 -0
  35. package/models/document.model.ts +113 -0
  36. package/models/user-workflow.model.ts +4 -0
  37. package/models/workflow-template.model.ts +4 -0
  38. package/package.json +3 -3
  39. package/dist/chunk-4RSJL5V4.js.map +0 -1
  40. package/dist/chunk-SXSMKZSK.js.map +0 -1
@@ -23,42 +23,42 @@ declare const MessageObjectSchema: Schema<any, mongoose.Model<any, any, any, any
23
23
  createdAt: NativeDate;
24
24
  updatedAt: NativeDate;
25
25
  } & {
26
- threadId: string;
27
26
  userId: string;
28
- messageId: string;
29
- role: MessageRole;
30
27
  content: {
31
28
  type: string;
32
29
  parts: any[];
33
30
  };
31
+ threadId: string;
32
+ messageId: string;
33
+ role: MessageRole;
34
34
  timestamp: number;
35
35
  metadata: any;
36
36
  }, Document<unknown, {}, mongoose.FlatRecord<{
37
37
  createdAt: NativeDate;
38
38
  updatedAt: NativeDate;
39
39
  } & {
40
- threadId: string;
41
40
  userId: string;
42
- messageId: string;
43
- role: MessageRole;
44
41
  content: {
45
42
  type: string;
46
43
  parts: any[];
47
44
  };
45
+ threadId: string;
46
+ messageId: string;
47
+ role: MessageRole;
48
48
  timestamp: number;
49
49
  metadata: any;
50
50
  }>, {}> & mongoose.FlatRecord<{
51
51
  createdAt: NativeDate;
52
52
  updatedAt: NativeDate;
53
53
  } & {
54
- threadId: string;
55
54
  userId: string;
56
- messageId: string;
57
- role: MessageRole;
58
55
  content: {
59
56
  type: string;
60
57
  parts: any[];
61
58
  };
59
+ threadId: string;
60
+ messageId: string;
61
+ role: MessageRole;
62
62
  timestamp: number;
63
63
  metadata: any;
64
64
  }> & {
@@ -8,31 +8,31 @@ declare const ThreadObjectSchema: Schema<any, mongoose.Model<any, any, any, any,
8
8
  updatedAt: NativeDate;
9
9
  } & {
10
10
  type: ThreadType;
11
- threadId: string;
12
11
  userId: string;
12
+ threadId: string;
13
13
  title?: string | null | undefined;
14
- isPinned?: boolean | null | undefined;
15
14
  workflowId?: string | null | undefined;
15
+ isPinned?: boolean | null | undefined;
16
16
  }, Document<unknown, {}, mongoose.FlatRecord<{
17
17
  createdAt: NativeDate;
18
18
  updatedAt: NativeDate;
19
19
  } & {
20
20
  type: ThreadType;
21
- threadId: string;
22
21
  userId: string;
22
+ threadId: string;
23
23
  title?: string | null | undefined;
24
- isPinned?: boolean | null | undefined;
25
24
  workflowId?: string | null | undefined;
25
+ isPinned?: boolean | null | undefined;
26
26
  }>, {}> & mongoose.FlatRecord<{
27
27
  createdAt: NativeDate;
28
28
  updatedAt: NativeDate;
29
29
  } & {
30
30
  type: ThreadType;
31
- threadId: string;
32
31
  userId: string;
32
+ threadId: string;
33
33
  title?: string | null | undefined;
34
- isPinned?: boolean | null | undefined;
35
34
  workflowId?: string | null | undefined;
35
+ isPinned?: boolean | null | undefined;
36
36
  }> & {
37
37
  _id: mongoose.Types.ObjectId;
38
38
  } & {
@@ -8,31 +8,31 @@ declare const ThreadObjectSchema: Schema<any, mongoose.Model<any, any, any, any,
8
8
  updatedAt: NativeDate;
9
9
  } & {
10
10
  type: ThreadType;
11
- threadId: string;
12
11
  userId: string;
12
+ threadId: string;
13
13
  title?: string | null | undefined;
14
- isPinned?: boolean | null | undefined;
15
14
  workflowId?: string | null | undefined;
15
+ isPinned?: boolean | null | undefined;
16
16
  }, Document<unknown, {}, mongoose.FlatRecord<{
17
17
  createdAt: NativeDate;
18
18
  updatedAt: NativeDate;
19
19
  } & {
20
20
  type: ThreadType;
21
- threadId: string;
22
21
  userId: string;
22
+ threadId: string;
23
23
  title?: string | null | undefined;
24
- isPinned?: boolean | null | undefined;
25
24
  workflowId?: string | null | undefined;
25
+ isPinned?: boolean | null | undefined;
26
26
  }>, {}> & mongoose.FlatRecord<{
27
27
  createdAt: NativeDate;
28
28
  updatedAt: NativeDate;
29
29
  } & {
30
30
  type: ThreadType;
31
- threadId: string;
32
31
  userId: string;
32
+ threadId: string;
33
33
  title?: string | null | undefined;
34
- isPinned?: boolean | null | undefined;
35
34
  workflowId?: string | null | undefined;
35
+ isPinned?: boolean | null | undefined;
36
36
  }> & {
37
37
  _id: mongoose.Types.ObjectId;
38
38
  } & {
@@ -60,6 +60,9 @@ var UserWorkflowObjectSchema = new import_mongoose.Schema(
60
60
  required: true,
61
61
  default: false
62
62
  },
63
+ category: {
64
+ type: String
65
+ },
63
66
  templateId: {
64
67
  type: String
65
68
  },
@@ -1 +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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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
+ {"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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,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,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;AAqBO,IAAM,oBAAoB,iBAAAC,QAAS;AAAA,EACzC;AAAA,EACA;AACD;","names":["import_mongoose","mongoose"]}
@@ -9,10 +9,11 @@ declare const UserWorkflowObjectSchema: Schema<any, mongoose.Model<any, any, any
9
9
  } & {
10
10
  userId: string;
11
11
  title: string;
12
- workflowId: string;
13
12
  content: string;
13
+ workflowId: string;
14
14
  active: boolean;
15
15
  description?: string | null | undefined;
16
+ category?: string | null | undefined;
16
17
  templateId?: string | null | undefined;
17
18
  definition?: any;
18
19
  variables?: any;
@@ -28,10 +29,11 @@ declare const UserWorkflowObjectSchema: Schema<any, mongoose.Model<any, any, any
28
29
  } & {
29
30
  userId: string;
30
31
  title: string;
31
- workflowId: string;
32
32
  content: string;
33
+ workflowId: string;
33
34
  active: boolean;
34
35
  description?: string | null | undefined;
36
+ category?: string | null | undefined;
35
37
  templateId?: string | null | undefined;
36
38
  definition?: any;
37
39
  variables?: any;
@@ -47,10 +49,11 @@ declare const UserWorkflowObjectSchema: Schema<any, mongoose.Model<any, any, any
47
49
  } & {
48
50
  userId: string;
49
51
  title: string;
50
- workflowId: string;
51
52
  content: string;
53
+ workflowId: string;
52
54
  active: boolean;
53
55
  description?: string | null | undefined;
56
+ category?: string | null | undefined;
54
57
  templateId?: string | null | undefined;
55
58
  definition?: any;
56
59
  variables?: any;
@@ -71,6 +74,7 @@ interface UserWorkflowDocument extends Document {
71
74
  title: string;
72
75
  description?: string;
73
76
  active: boolean;
77
+ category?: string;
74
78
  templateId?: string;
75
79
  content: string;
76
80
  definition?: WorkflowDefinition;
@@ -9,10 +9,11 @@ declare const UserWorkflowObjectSchema: Schema<any, mongoose.Model<any, any, any
9
9
  } & {
10
10
  userId: string;
11
11
  title: string;
12
- workflowId: string;
13
12
  content: string;
13
+ workflowId: string;
14
14
  active: boolean;
15
15
  description?: string | null | undefined;
16
+ category?: string | null | undefined;
16
17
  templateId?: string | null | undefined;
17
18
  definition?: any;
18
19
  variables?: any;
@@ -28,10 +29,11 @@ declare const UserWorkflowObjectSchema: Schema<any, mongoose.Model<any, any, any
28
29
  } & {
29
30
  userId: string;
30
31
  title: string;
31
- workflowId: string;
32
32
  content: string;
33
+ workflowId: string;
33
34
  active: boolean;
34
35
  description?: string | null | undefined;
36
+ category?: string | null | undefined;
35
37
  templateId?: string | null | undefined;
36
38
  definition?: any;
37
39
  variables?: any;
@@ -47,10 +49,11 @@ declare const UserWorkflowObjectSchema: Schema<any, mongoose.Model<any, any, any
47
49
  } & {
48
50
  userId: string;
49
51
  title: string;
50
- workflowId: string;
51
52
  content: string;
53
+ workflowId: string;
52
54
  active: boolean;
53
55
  description?: string | null | undefined;
56
+ category?: string | null | undefined;
54
57
  templateId?: string | null | undefined;
55
58
  definition?: any;
56
59
  variables?: any;
@@ -71,6 +74,7 @@ interface UserWorkflowDocument extends Document {
71
74
  title: string;
72
75
  description?: string;
73
76
  active: boolean;
77
+ category?: string;
74
78
  templateId?: string;
75
79
  content: string;
76
80
  definition?: WorkflowDefinition;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  UserWorkflowModel,
3
3
  UserWorkflowObjectSchema
4
- } from "../chunk-SXSMKZSK.js";
4
+ } from "../chunk-4L2JYSVK.js";
5
5
  export {
6
6
  UserWorkflowModel,
7
7
  UserWorkflowObjectSchema
@@ -56,6 +56,9 @@ var WorkflowTemplateObjectSchema = new import_mongoose.Schema(
56
56
  required: true,
57
57
  default: false
58
58
  },
59
+ category: {
60
+ type: String
61
+ },
59
62
  content: {
60
63
  type: String,
61
64
  required: true
@@ -1 +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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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
+ {"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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,UAAU;AAAA,MACT,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,EACD;AAAA,EACA;AAAA,IACC,YAAY;AAAA,EACb;AACD;AAaO,IAAM,wBAAwB,iBAAAC,QAAS;AAAA,EAC7C;AAAA,EACA;AACD;","names":["import_mongoose","mongoose"]}
@@ -7,33 +7,36 @@ declare const WorkflowTemplateObjectSchema: Schema<any, mongoose.Model<any, any,
7
7
  createdAt: NativeDate;
8
8
  updatedAt: NativeDate;
9
9
  } & {
10
- title: string;
11
10
  description: string;
11
+ title: string;
12
12
  content: string;
13
13
  active: boolean;
14
14
  templateId: string;
15
+ category?: string | null | undefined;
15
16
  definition?: any;
16
17
  variables?: any;
17
18
  }, Document<unknown, {}, mongoose.FlatRecord<{
18
19
  createdAt: NativeDate;
19
20
  updatedAt: NativeDate;
20
21
  } & {
21
- title: string;
22
22
  description: string;
23
+ title: string;
23
24
  content: string;
24
25
  active: boolean;
25
26
  templateId: string;
27
+ category?: string | null | undefined;
26
28
  definition?: any;
27
29
  variables?: any;
28
30
  }>, {}> & mongoose.FlatRecord<{
29
31
  createdAt: NativeDate;
30
32
  updatedAt: NativeDate;
31
33
  } & {
32
- title: string;
33
34
  description: string;
35
+ title: string;
34
36
  content: string;
35
37
  active: boolean;
36
38
  templateId: string;
39
+ category?: string | null | undefined;
37
40
  definition?: any;
38
41
  variables?: any;
39
42
  }> & {
@@ -46,6 +49,7 @@ interface WorkflowTemplateDocument extends Document {
46
49
  title: string;
47
50
  description: string;
48
51
  active: boolean;
52
+ category?: string;
49
53
  content: string;
50
54
  definition?: WorkflowDefinition;
51
55
  variables?: Record<string, WorkflowVariable>;
@@ -7,33 +7,36 @@ declare const WorkflowTemplateObjectSchema: Schema<any, mongoose.Model<any, any,
7
7
  createdAt: NativeDate;
8
8
  updatedAt: NativeDate;
9
9
  } & {
10
- title: string;
11
10
  description: string;
11
+ title: string;
12
12
  content: string;
13
13
  active: boolean;
14
14
  templateId: string;
15
+ category?: string | null | undefined;
15
16
  definition?: any;
16
17
  variables?: any;
17
18
  }, Document<unknown, {}, mongoose.FlatRecord<{
18
19
  createdAt: NativeDate;
19
20
  updatedAt: NativeDate;
20
21
  } & {
21
- title: string;
22
22
  description: string;
23
+ title: string;
23
24
  content: string;
24
25
  active: boolean;
25
26
  templateId: string;
27
+ category?: string | null | undefined;
26
28
  definition?: any;
27
29
  variables?: any;
28
30
  }>, {}> & mongoose.FlatRecord<{
29
31
  createdAt: NativeDate;
30
32
  updatedAt: NativeDate;
31
33
  } & {
32
- title: string;
33
34
  description: string;
35
+ title: string;
34
36
  content: string;
35
37
  active: boolean;
36
38
  templateId: string;
39
+ category?: string | null | undefined;
37
40
  definition?: any;
38
41
  variables?: any;
39
42
  }> & {
@@ -46,6 +49,7 @@ interface WorkflowTemplateDocument extends Document {
46
49
  title: string;
47
50
  description: string;
48
51
  active: boolean;
52
+ category?: string;
49
53
  content: string;
50
54
  definition?: WorkflowDefinition;
51
55
  variables?: Record<string, WorkflowVariable>;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  WorkflowTemplateModel,
3
3
  WorkflowTemplateObjectSchema
4
- } from "../chunk-4RSJL5V4.js";
4
+ } from "../chunk-E6CDPMEQ.js";
5
5
  export {
6
6
  WorkflowTemplateModel,
7
7
  WorkflowTemplateObjectSchema
@@ -1,7 +1,8 @@
1
- import { IAgentMemory, IIntentMemory, IMemory, IUserWorkflowMemory, IThreadMemory, IWorkflowTemplateMemory } from "@ainetwork/adk/modules";
1
+ import { IAgentMemory, IDocumentMemory, IIntentMemory, IMemory, IUserWorkflowMemory, IThreadMemory, IWorkflowTemplateMemory } from "@ainetwork/adk/modules";
2
2
  import mongoose from "mongoose";
3
3
  import { loggers } from "@ainetwork/adk/utils/logger";
4
4
  import { MongoDBAgent } from "./agent.memory";
5
+ import { MongoDBDocument } from "./document.memory";
5
6
  import { MongoDBIntent } from "./intent.memory";
6
7
  import { MongoDBThread } from "./thread.memory";
7
8
  import { MongoDBUserWorkflow } from "./user-workflow.memory";
@@ -39,6 +40,7 @@ export class MongoDBMemory implements IMemory {
39
40
  private threadMemory: MongoDBThread;
40
41
  private workflowTemplateMemory: MongoDBWorkflowTemplate;
41
42
  private userWorkflowMemory: MongoDBUserWorkflow;
43
+ private documentMemory: MongoDBDocument;
42
44
 
43
45
  constructor(config: string | MongoDBMemoryConfig) {
44
46
  const cfg = typeof config === 'string' ? { uri: config } : config;
@@ -93,6 +95,11 @@ export class MongoDBMemory implements IMemory {
93
95
  this.executeWithRetry.bind(this),
94
96
  this.getOperationTimeout.bind(this)
95
97
  );
98
+
99
+ this.documentMemory = new MongoDBDocument(
100
+ this.executeWithRetry.bind(this),
101
+ this.getOperationTimeout.bind(this)
102
+ );
96
103
  }
97
104
 
98
105
  public getAgentMemory(): IAgentMemory {
@@ -115,6 +122,10 @@ export class MongoDBMemory implements IMemory {
115
122
  return this.userWorkflowMemory;
116
123
  }
117
124
 
125
+ public getDocumentMemory(): IDocumentMemory {
126
+ return this.documentMemory;
127
+ }
128
+
118
129
  private setupMongooseEventListeners(): void {
119
130
  if (this.eventListenersSetup) return;
120
131
 
@@ -0,0 +1,88 @@
1
+ import type { IDocumentMemory } from "@ainetwork/adk/modules";
2
+ import type { Document, DocumentFilter } from "@ainetwork/adk/types/document";
3
+ import { DocumentModel } from "../models/document.model";
4
+
5
+ export type ExecuteWithRetryFn = <T>(
6
+ operation: () => Promise<T>,
7
+ operationName?: string
8
+ ) => Promise<T>;
9
+
10
+ export type GetOperationTimeoutFn = () => number;
11
+
12
+ export class MongoDBDocument implements IDocumentMemory {
13
+ private executeWithRetry: ExecuteWithRetryFn;
14
+ private getOperationTimeout: GetOperationTimeoutFn;
15
+
16
+ constructor(
17
+ executeWithRetry: ExecuteWithRetryFn,
18
+ getOperationTimeout: GetOperationTimeoutFn
19
+ ) {
20
+ this.executeWithRetry = executeWithRetry;
21
+ this.getOperationTimeout = getOperationTimeout;
22
+ }
23
+
24
+ public async getDocument(documentId: string): Promise<Document | undefined> {
25
+ return this.executeWithRetry(async () => {
26
+ const timeout = this.getOperationTimeout();
27
+ const document = await DocumentModel.findOne({ documentId })
28
+ .maxTimeMS(timeout)
29
+ .lean<Document>();
30
+ return document || undefined;
31
+ }, "getDocument()");
32
+ }
33
+
34
+ public async createDocument(document: Document): Promise<Document> {
35
+ return this.executeWithRetry(async () => {
36
+ const created = await DocumentModel.create(document);
37
+ return created.toObject() as Document;
38
+ }, "createDocument()");
39
+ }
40
+
41
+ public async updateDocument(
42
+ documentId: string,
43
+ document: Partial<Document>
44
+ ): Promise<void> {
45
+ // `documentId` is immutable; never let a payload reassign it.
46
+ const { documentId: _documentId, ...mutableUpdates } = document;
47
+
48
+ return this.executeWithRetry(async () => {
49
+ const timeout = this.getOperationTimeout();
50
+ await DocumentModel.updateOne(
51
+ { documentId },
52
+ { $set: mutableUpdates }
53
+ ).maxTimeMS(timeout);
54
+ }, "updateDocument()");
55
+ }
56
+
57
+ public async deleteDocument(documentId: string): Promise<void> {
58
+ return this.executeWithRetry(async () => {
59
+ const timeout = this.getOperationTimeout();
60
+ await DocumentModel.deleteOne({ documentId }).maxTimeMS(timeout);
61
+ }, "deleteDocument()");
62
+ }
63
+
64
+ public async listDocuments(
65
+ userId?: string,
66
+ filter?: DocumentFilter
67
+ ): Promise<Document[]> {
68
+ return this.executeWithRetry(async () => {
69
+ const timeout = this.getOperationTimeout();
70
+ const query: Record<string, unknown> = {};
71
+ if (userId) query.userId = userId;
72
+ if (filter?.workflowId) query.workflowId = filter.workflowId;
73
+ if (filter?.threadId) query.threadId = filter.threadId;
74
+ if (filter?.source) query.source = filter.source;
75
+ if (filter?.labels) {
76
+ // Subset match: every provided label must equal the stored value.
77
+ for (const [key, value] of Object.entries(filter.labels)) {
78
+ query[`labels.${key}`] = value;
79
+ }
80
+ }
81
+
82
+ const documents = await DocumentModel.find(query)
83
+ .maxTimeMS(timeout)
84
+ .lean<Document[]>();
85
+ return documents;
86
+ }, "listDocuments()");
87
+ }
88
+ }
@@ -0,0 +1,113 @@
1
+ import {
2
+ type DocumentAdvice,
3
+ DocumentFormat,
4
+ type DocumentSlot,
5
+ DocumentSource,
6
+ } from "@ainetwork/adk/types/document";
7
+ import type { WorkflowRenderedBlock } from "@ainetwork/adk/types/memory";
8
+ import { type Document, Schema } from "mongoose";
9
+ import mongoose from "mongoose";
10
+
11
+ export const DocumentObjectSchema = new Schema(
12
+ {
13
+ documentId: {
14
+ type: String,
15
+ required: true,
16
+ unique: true,
17
+ },
18
+ userId: {
19
+ type: String,
20
+ required: true,
21
+ index: true,
22
+ },
23
+ title: {
24
+ type: String,
25
+ required: true,
26
+ },
27
+ format: {
28
+ type: String,
29
+ enum: Object.values(DocumentFormat),
30
+ required: true,
31
+ default: DocumentFormat.MARKDOWN,
32
+ },
33
+ content: {
34
+ type: String,
35
+ required: true,
36
+ },
37
+ blocks: {
38
+ type: Schema.Types.Mixed,
39
+ },
40
+ slots: {
41
+ type: Schema.Types.Mixed,
42
+ },
43
+ // Cached AI advice ({ content, generatedAt }). Free-form so the schema
44
+ // doesn't strip it on update (mongoose strict mode).
45
+ advice: {
46
+ type: Schema.Types.Mixed,
47
+ },
48
+ // Faceted grouping (e.g. category/workplaceId/month). Stored as a free
49
+ // map; index specific keys (e.g. `labels.workplaceId`) if query volume
50
+ // warrants it.
51
+ labels: {
52
+ type: Schema.Types.Mixed,
53
+ },
54
+ source: {
55
+ type: String,
56
+ enum: Object.values(DocumentSource),
57
+ required: true,
58
+ },
59
+ workflowId: {
60
+ type: String,
61
+ index: true,
62
+ },
63
+ threadId: {
64
+ type: String,
65
+ index: true,
66
+ },
67
+ version: {
68
+ type: Number,
69
+ required: true,
70
+ default: 1,
71
+ },
72
+ editedManually: {
73
+ type: Boolean,
74
+ },
75
+ createdAt: {
76
+ type: String,
77
+ required: true,
78
+ },
79
+ updatedAt: {
80
+ type: String,
81
+ required: true,
82
+ },
83
+ },
84
+ // `createdAt`/`updatedAt` are caller-supplied ISO strings (see Document type),
85
+ // so mongoose's automatic Date timestamps are intentionally disabled.
86
+ {
87
+ timestamps: false,
88
+ }
89
+ );
90
+
91
+ export interface DocumentDocument extends Document {
92
+ documentId: string;
93
+ userId: string;
94
+ title: string;
95
+ format: DocumentFormat;
96
+ content: string;
97
+ blocks?: WorkflowRenderedBlock[];
98
+ slots?: DocumentSlot[];
99
+ advice?: DocumentAdvice;
100
+ labels?: Record<string, string>;
101
+ source: DocumentSource;
102
+ workflowId?: string;
103
+ threadId?: string;
104
+ version: number;
105
+ editedManually?: boolean;
106
+ createdAt: string;
107
+ updatedAt: string;
108
+ }
109
+
110
+ export const DocumentModel = mongoose.model<DocumentDocument>(
111
+ "Document",
112
+ DocumentObjectSchema
113
+ );
@@ -29,6 +29,9 @@ export const UserWorkflowObjectSchema = new Schema(
29
29
  required: true,
30
30
  default: false,
31
31
  },
32
+ category: {
33
+ type: String,
34
+ },
32
35
  templateId: {
33
36
  type: String,
34
37
  },
@@ -72,6 +75,7 @@ export interface UserWorkflowDocument extends Document {
72
75
  title: string;
73
76
  description?: string;
74
77
  active: boolean;
78
+ category?: string;
75
79
  templateId?: string;
76
80
  content: string;
77
81
  definition?: WorkflowDefinition;
@@ -25,6 +25,9 @@ export const WorkflowTemplateObjectSchema = new Schema(
25
25
  required: true,
26
26
  default: false,
27
27
  },
28
+ category: {
29
+ type: String,
30
+ },
28
31
  content: {
29
32
  type: String,
30
33
  required: true,
@@ -46,6 +49,7 @@ export interface WorkflowTemplateDocument extends Document {
46
49
  title: string;
47
50
  description: string;
48
51
  active: boolean;
52
+ category?: string;
49
53
  content: string;
50
54
  definition?: WorkflowDefinition;
51
55
  variables?: Record<string, WorkflowVariable>;