@memberjunction/core-entities-server 5.40.2 → 5.42.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 (54) hide show
  1. package/dist/custom/MJAIAgentCoAgentEntityServer.server.d.ts +78 -0
  2. package/dist/custom/MJAIAgentCoAgentEntityServer.server.d.ts.map +1 -0
  3. package/dist/custom/MJAIAgentCoAgentEntityServer.server.js +224 -0
  4. package/dist/custom/MJAIAgentCoAgentEntityServer.server.js.map +1 -0
  5. package/dist/custom/MJAIAgentEntityServer.server.d.ts +50 -0
  6. package/dist/custom/MJAIAgentEntityServer.server.d.ts.map +1 -0
  7. package/dist/custom/MJAIAgentEntityServer.server.js +126 -0
  8. package/dist/custom/MJAIAgentEntityServer.server.js.map +1 -0
  9. package/dist/custom/MJAIAgentNoteEntityServer.server.d.ts +6 -3
  10. package/dist/custom/MJAIAgentNoteEntityServer.server.d.ts.map +1 -1
  11. package/dist/custom/MJAIAgentNoteEntityServer.server.js +10 -7
  12. package/dist/custom/MJAIAgentNoteEntityServer.server.js.map +1 -1
  13. package/dist/custom/MJAIAgentSessionBridgeEntityServer.server.d.ts +50 -0
  14. package/dist/custom/MJAIAgentSessionBridgeEntityServer.server.d.ts.map +1 -0
  15. package/dist/custom/MJAIAgentSessionBridgeEntityServer.server.js +133 -0
  16. package/dist/custom/MJAIAgentSessionBridgeEntityServer.server.js.map +1 -0
  17. package/dist/custom/MJAIAgentSessionBridgeParticipantEntityServer.server.d.ts +33 -0
  18. package/dist/custom/MJAIAgentSessionBridgeParticipantEntityServer.server.d.ts.map +1 -0
  19. package/dist/custom/MJAIAgentSessionBridgeParticipantEntityServer.server.js +90 -0
  20. package/dist/custom/MJAIAgentSessionBridgeParticipantEntityServer.server.js.map +1 -0
  21. package/dist/custom/MJAIBridgeAgentIdentityEntityServer.server.d.ts +49 -0
  22. package/dist/custom/MJAIBridgeAgentIdentityEntityServer.server.d.ts.map +1 -0
  23. package/dist/custom/MJAIBridgeAgentIdentityEntityServer.server.js +152 -0
  24. package/dist/custom/MJAIBridgeAgentIdentityEntityServer.server.js.map +1 -0
  25. package/dist/custom/MJAIBridgeProviderChannelEntityServer.server.d.ts +33 -0
  26. package/dist/custom/MJAIBridgeProviderChannelEntityServer.server.d.ts.map +1 -0
  27. package/dist/custom/MJAIBridgeProviderChannelEntityServer.server.js +90 -0
  28. package/dist/custom/MJAIBridgeProviderChannelEntityServer.server.js.map +1 -0
  29. package/dist/custom/MJAIBridgeProviderEntityServer.server.d.ts +52 -0
  30. package/dist/custom/MJAIBridgeProviderEntityServer.server.d.ts.map +1 -0
  31. package/dist/custom/MJAIBridgeProviderEntityServer.server.js +154 -0
  32. package/dist/custom/MJAIBridgeProviderEntityServer.server.js.map +1 -0
  33. package/dist/custom/MJAIRemoteBrowserProviderEntityServer.server.d.ts +63 -0
  34. package/dist/custom/MJAIRemoteBrowserProviderEntityServer.server.d.ts.map +1 -0
  35. package/dist/custom/MJAIRemoteBrowserProviderEntityServer.server.js +212 -0
  36. package/dist/custom/MJAIRemoteBrowserProviderEntityServer.server.js.map +1 -0
  37. package/dist/custom/MJDuplicateRunEntityServer.server.d.ts.map +1 -1
  38. package/dist/custom/MJDuplicateRunEntityServer.server.js +6 -2
  39. package/dist/custom/MJDuplicateRunEntityServer.server.js.map +1 -1
  40. package/dist/custom/MJRecordProcessEntityServer.server.d.ts +61 -0
  41. package/dist/custom/MJRecordProcessEntityServer.server.d.ts.map +1 -0
  42. package/dist/custom/MJRecordProcessEntityServer.server.js +152 -0
  43. package/dist/custom/MJRecordProcessEntityServer.server.js.map +1 -0
  44. package/dist/custom/json-schema-lite.d.ts +36 -0
  45. package/dist/custom/json-schema-lite.d.ts.map +1 -0
  46. package/dist/custom/json-schema-lite.js +125 -0
  47. package/dist/custom/json-schema-lite.js.map +1 -0
  48. package/dist/custom/query-extraction/sync.js +40 -19
  49. package/dist/custom/query-extraction/sync.js.map +1 -1
  50. package/dist/index.d.ts +10 -0
  51. package/dist/index.d.ts.map +1 -1
  52. package/dist/index.js +10 -0
  53. package/dist/index.js.map +1 -1
  54. package/package.json +24 -24
@@ -0,0 +1,78 @@
1
+ import { ValidationErrorInfo, ValidationResult } from '@memberjunction/core';
2
+ import { MJAIAgentCoAgentEntity } from '@memberjunction/core-entities';
3
+ /**
4
+ * Server-side `MJ: AI Agent Co Agents` entity enforcing the affinity invariants the migration
5
+ * documents (see `V202606121723__v5.41.x__AI_Agent_Sessions_Channels.sql`):
6
+ *
7
+ * 1. For `Type = 'CoAgent'` rows, `CoAgentID` must reference an **Active** agent of the
8
+ * **Realtime** agent type — only Realtime-type agents drive realtime sessions, so
9
+ * pairing rows for anything else are metadata mistakes caught at write time. Reserved
10
+ * relationship types (Peer/Delegate/Fallback/Reviewer/Observer) skip this check — their
11
+ * owner semantics will be defined when those features ship.
12
+ * 2. **At most one `IsDefault = 1` row per (CoAgentID, Type)** — the default is the target
13
+ * a session falls back to when no runtime target is supplied (agent rows) or the type's
14
+ * default co-agent (type rows); two defaults would be ambiguous. Cross-record invariant
15
+ * checked via RunView (the BASE_ENTITY_SERVER_PATTERNS recipe — `ValidateAsync`, NOT a
16
+ * DB trigger).
17
+ * 3. **No duplicate relationship**: (CoAgentID, target side, Type) must be unique. The DB
18
+ * cannot express this as a UNIQUE constraint across the two nullable target columns, so
19
+ * it lives here per the migration's documentation.
20
+ * 4. `CoAgentID ≠ TargetAgentID` — defense in depth over the table CHECK constraint and the
21
+ * generated sync validator (an agent cannot front itself). The exactly-one-target rule
22
+ * is covered by the table CHECK + the generated validator.
23
+ *
24
+ * Affinity rows are OPT-IN: a co-agent with zero rows stays universal — these checks only
25
+ * govern rows being written, never mandate that any exist.
26
+ */
27
+ export declare class MJAIAgentCoAgentEntityServer extends MJAIAgentCoAgentEntity {
28
+ /** Enable async validation so the cross-record pairing invariants run. */
29
+ get DefaultSkipAsyncValidation(): boolean;
30
+ ValidateAsync(): Promise<ValidationResult>;
31
+ /**
32
+ * Loads the co-agent (and its type) through the request-scoped provider and returns the
33
+ * invariant violations: missing agent, non-Active status, or non-Realtime type.
34
+ */
35
+ private validateCoAgentIsActiveRealtime;
36
+ /**
37
+ * Counts OTHER `IsDefault = 1` rows for this (co-agent, Type) — excluding this row when
38
+ * updating. A failed query counts as 0 (fail-open; the invariant re-checks on next save).
39
+ */
40
+ private countOtherDefaultRows;
41
+ /**
42
+ * Counts OTHER rows expressing the SAME relationship — same co-agent, same Type, same
43
+ * target side (TargetAgentID or TargetAgentTypeID) — excluding this row when updating.
44
+ */
45
+ private countDuplicateRelationshipRows;
46
+ /** Shared cross-record counter: runs the filter (plus self-exclusion) and returns the row count. */
47
+ private countRows;
48
+ /** Escapes a UUID/string for safe inclusion in an ExtraFilter literal. */
49
+ private safeID;
50
+ }
51
+ /**
52
+ * PURE invariant: an agent cannot be paired as its own co-agent. Returns the error, or `null`.
53
+ * Case/whitespace-insensitive UUID comparison (SQL Server vs PostgreSQL casing).
54
+ */
55
+ export declare function BuildSelfPairingError(coAgentID: string | null, targetAgentID: string | null): ValidationErrorInfo | null;
56
+ /**
57
+ * PURE invariant core for the co-agent reference (exported for unit tests): the referenced
58
+ * agent must exist, be Active, and be of the Realtime agent type.
59
+ *
60
+ * @param coAgentID The referenced co-agent id.
61
+ * @param status The loaded co-agent's Status, or `null` when the agent could not be loaded.
62
+ * @param typeName The loaded co-agent's TYPE name, or `null` when missing/unresolvable.
63
+ * @param agentName The loaded co-agent's display name (for friendlier messages).
64
+ * @returns The violations (empty array = valid).
65
+ */
66
+ export declare function BuildCoAgentInvariantErrors(coAgentID: string, status: string | null, typeName: string | null, agentName?: string): ValidationErrorInfo[];
67
+ /**
68
+ * PURE invariant: at most one `IsDefault = 1` row per (co-agent, relationship Type). Returns
69
+ * the error when `existingDefaultCount` other default rows already exist, else `null`.
70
+ */
71
+ export declare function BuildDuplicateDefaultError(coAgentID: string | null, existingDefaultCount: number): ValidationErrorInfo | null;
72
+ /**
73
+ * PURE invariant: a (CoAgentID, target side, Type) relationship may exist only once — the DB
74
+ * cannot enforce uniqueness across the two nullable target columns. Returns the error when
75
+ * `duplicateCount` other identical rows already exist, else `null`.
76
+ */
77
+ export declare function BuildDuplicateRelationshipError(coAgentID: string | null, relationshipType: string, duplicateCount: number): ValidationErrorInfo | null;
78
+ //# sourceMappingURL=MJAIAgentCoAgentEntityServer.server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MJAIAgentCoAgentEntityServer.server.d.ts","sourceRoot":"","sources":["../../src/custom/MJAIAgentCoAgentEntityServer.server.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,mBAAmB,EAAuB,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE1I,OAAO,EAAmB,sBAAsB,EAAuB,MAAM,+BAA+B,CAAC;AAK7G;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBACa,4BAA6B,SAAQ,sBAAsB;IACpE,0EAA0E;IAC1E,IAAoB,0BAA0B,IAAI,OAAO,CAExD;IAEqB,aAAa,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAmDhE;;;OAGG;YACW,+BAA+B;IAmB7C;;;OAGG;YACW,qBAAqB;IAQnC;;;OAGG;YACW,8BAA8B;IAW5C,oGAAoG;YACtF,SAAS;IAoBvB,0EAA0E;IAC1E,OAAO,CAAC,MAAM;CAGjB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,mBAAmB,GAAG,IAAI,CAaxH;AAED;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CACvC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,SAAS,CAAC,EAAE,MAAM,GACnB,mBAAmB,EAAE,CAmCvB;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,oBAAoB,EAAE,MAAM,GAAG,mBAAmB,GAAG,IAAI,CAW7H;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC3C,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,gBAAgB,EAAE,MAAM,EACxB,cAAc,EAAE,MAAM,GACvB,mBAAmB,GAAG,IAAI,CAW5B"}
@@ -0,0 +1,224 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { BaseEntity, RunView, ValidationErrorInfo, ValidationErrorType } from '@memberjunction/core';
8
+ import { RegisterClass } from '@memberjunction/global';
9
+ import { MJAIAgentCoAgentEntity } from '@memberjunction/core-entities';
10
+ /** The seeded name of the Realtime agent type — a co-agent must be of this type. */
11
+ const REALTIME_AGENT_TYPE_NAME = 'Realtime';
12
+ /**
13
+ * Server-side `MJ: AI Agent Co Agents` entity enforcing the affinity invariants the migration
14
+ * documents (see `V202606121723__v5.41.x__AI_Agent_Sessions_Channels.sql`):
15
+ *
16
+ * 1. For `Type = 'CoAgent'` rows, `CoAgentID` must reference an **Active** agent of the
17
+ * **Realtime** agent type — only Realtime-type agents drive realtime sessions, so
18
+ * pairing rows for anything else are metadata mistakes caught at write time. Reserved
19
+ * relationship types (Peer/Delegate/Fallback/Reviewer/Observer) skip this check — their
20
+ * owner semantics will be defined when those features ship.
21
+ * 2. **At most one `IsDefault = 1` row per (CoAgentID, Type)** — the default is the target
22
+ * a session falls back to when no runtime target is supplied (agent rows) or the type's
23
+ * default co-agent (type rows); two defaults would be ambiguous. Cross-record invariant
24
+ * checked via RunView (the BASE_ENTITY_SERVER_PATTERNS recipe — `ValidateAsync`, NOT a
25
+ * DB trigger).
26
+ * 3. **No duplicate relationship**: (CoAgentID, target side, Type) must be unique. The DB
27
+ * cannot express this as a UNIQUE constraint across the two nullable target columns, so
28
+ * it lives here per the migration's documentation.
29
+ * 4. `CoAgentID ≠ TargetAgentID` — defense in depth over the table CHECK constraint and the
30
+ * generated sync validator (an agent cannot front itself). The exactly-one-target rule
31
+ * is covered by the table CHECK + the generated validator.
32
+ *
33
+ * Affinity rows are OPT-IN: a co-agent with zero rows stays universal — these checks only
34
+ * govern rows being written, never mandate that any exist.
35
+ */
36
+ let MJAIAgentCoAgentEntityServer = class MJAIAgentCoAgentEntityServer extends MJAIAgentCoAgentEntity {
37
+ /** Enable async validation so the cross-record pairing invariants run. */
38
+ get DefaultSkipAsyncValidation() {
39
+ return false;
40
+ }
41
+ async ValidateAsync() {
42
+ const result = await super.ValidateAsync();
43
+ if (!result.Success)
44
+ return result;
45
+ // (3) Self-pairing — cheap, always checked (defense in depth over the CHECK constraint).
46
+ const selfPairError = BuildSelfPairingError(this.CoAgentID, this.TargetAgentID);
47
+ if (selfPairError) {
48
+ result.Errors.push(selfPairError);
49
+ result.Success = false;
50
+ return result;
51
+ }
52
+ // (1) Co-agent must be an Active, Realtime-type agent — Type='CoAgent' rows only,
53
+ // and only when new or CoAgentID/Type changed.
54
+ const coAgentDirty = this.GetFieldByName('CoAgentID')?.Dirty ?? false;
55
+ const typeDirty = this.GetFieldByName('Type')?.Dirty ?? false;
56
+ if (this.Type === 'CoAgent' && (!this.IsSaved || coAgentDirty || typeDirty)) {
57
+ const coAgentErrors = await this.validateCoAgentIsActiveRealtime();
58
+ if (coAgentErrors.length > 0) {
59
+ result.Errors.push(...coAgentErrors);
60
+ result.Success = false;
61
+ return result;
62
+ }
63
+ }
64
+ // (2) At most one IsDefault row per (CoAgentID, Type) — only when this row claims the default.
65
+ const isDefaultDirty = this.GetFieldByName('IsDefault')?.Dirty ?? false;
66
+ if (this.IsDefault && (!this.IsSaved || isDefaultDirty || coAgentDirty || typeDirty)) {
67
+ const conflict = await this.countOtherDefaultRows();
68
+ const defaultError = BuildDuplicateDefaultError(this.CoAgentID, conflict);
69
+ if (defaultError) {
70
+ result.Errors.push(defaultError);
71
+ result.Success = false;
72
+ }
73
+ }
74
+ // (3) No duplicate (CoAgentID, target side, Type) relationship.
75
+ const targetDirty = (this.GetFieldByName('TargetAgentID')?.Dirty ?? false) ||
76
+ (this.GetFieldByName('TargetAgentTypeID')?.Dirty ?? false);
77
+ if (!this.IsSaved || coAgentDirty || typeDirty || targetDirty) {
78
+ const duplicates = await this.countDuplicateRelationshipRows();
79
+ const duplicateError = BuildDuplicateRelationshipError(this.CoAgentID, this.Type, duplicates);
80
+ if (duplicateError) {
81
+ result.Errors.push(duplicateError);
82
+ result.Success = false;
83
+ }
84
+ }
85
+ return result;
86
+ }
87
+ /**
88
+ * Loads the co-agent (and its type) through the request-scoped provider and returns the
89
+ * invariant violations: missing agent, non-Active status, or non-Realtime type.
90
+ */
91
+ async validateCoAgentIsActiveRealtime() {
92
+ if (!this.CoAgentID) {
93
+ return []; // required-field violation is sync Validate()'s job
94
+ }
95
+ const md = this.ProviderToUse;
96
+ const coAgent = await md.GetEntityObject('MJ: AI Agents', this.ContextCurrentUser);
97
+ if (!(await coAgent.Load(this.CoAgentID))) {
98
+ return BuildCoAgentInvariantErrors(this.CoAgentID, null, null);
99
+ }
100
+ let typeName = null;
101
+ if (coAgent.TypeID) {
102
+ const type = await md.GetEntityObject('MJ: AI Agent Types', this.ContextCurrentUser);
103
+ if (await type.Load(coAgent.TypeID)) {
104
+ typeName = type.Name ?? null;
105
+ }
106
+ }
107
+ return BuildCoAgentInvariantErrors(this.CoAgentID, coAgent.Status ?? null, typeName, coAgent.Name ?? undefined);
108
+ }
109
+ /**
110
+ * Counts OTHER `IsDefault = 1` rows for this (co-agent, Type) — excluding this row when
111
+ * updating. A failed query counts as 0 (fail-open; the invariant re-checks on next save).
112
+ */
113
+ async countOtherDefaultRows() {
114
+ if (!this.CoAgentID) {
115
+ return 0;
116
+ }
117
+ const safeType = this.Type.replace(/'/g, "''");
118
+ return this.countRows(`CoAgentID='${this.safeID(this.CoAgentID)}' AND Type='${safeType}' AND IsDefault=1`);
119
+ }
120
+ /**
121
+ * Counts OTHER rows expressing the SAME relationship — same co-agent, same Type, same
122
+ * target side (TargetAgentID or TargetAgentTypeID) — excluding this row when updating.
123
+ */
124
+ async countDuplicateRelationshipRows() {
125
+ if (!this.CoAgentID || (!this.TargetAgentID && !this.TargetAgentTypeID)) {
126
+ return 0; // missing-target violation is the CHECK/sync validator's job
127
+ }
128
+ const safeType = this.Type.replace(/'/g, "''");
129
+ const targetFilter = this.TargetAgentID
130
+ ? `TargetAgentID='${this.safeID(this.TargetAgentID)}'`
131
+ : `TargetAgentTypeID='${this.safeID(this.TargetAgentTypeID)}'`;
132
+ return this.countRows(`CoAgentID='${this.safeID(this.CoAgentID)}' AND Type='${safeType}' AND ${targetFilter}`);
133
+ }
134
+ /** Shared cross-record counter: runs the filter (plus self-exclusion) and returns the row count. */
135
+ async countRows(filter) {
136
+ try {
137
+ const md = this.ProviderToUse;
138
+ const selfExclusion = this.IsSaved ? ` AND ID <> '${this.safeID(this.ID)}'` : '';
139
+ const rv = RunView.FromMetadataProvider(md);
140
+ const result = await rv.RunView({
141
+ EntityName: 'MJ: AI Agent Co Agents',
142
+ ExtraFilter: `${filter}${selfExclusion}`,
143
+ Fields: ['ID'],
144
+ ResultType: 'simple',
145
+ }, this.ContextCurrentUser);
146
+ return result.Success ? (result.Results?.length ?? 0) : 0;
147
+ }
148
+ catch {
149
+ return 0;
150
+ }
151
+ }
152
+ /** Escapes a UUID/string for safe inclusion in an ExtraFilter literal. */
153
+ safeID(value) {
154
+ return value.replace(/'/g, "''");
155
+ }
156
+ };
157
+ MJAIAgentCoAgentEntityServer = __decorate([
158
+ RegisterClass(BaseEntity, 'MJ: AI Agent Co Agents')
159
+ ], MJAIAgentCoAgentEntityServer);
160
+ export { MJAIAgentCoAgentEntityServer };
161
+ /**
162
+ * PURE invariant: an agent cannot be paired as its own co-agent. Returns the error, or `null`.
163
+ * Case/whitespace-insensitive UUID comparison (SQL Server vs PostgreSQL casing).
164
+ */
165
+ export function BuildSelfPairingError(coAgentID, targetAgentID) {
166
+ if (!coAgentID || !targetAgentID) {
167
+ return null;
168
+ }
169
+ if (coAgentID.trim().toLowerCase() !== targetAgentID.trim().toLowerCase()) {
170
+ return null;
171
+ }
172
+ return new ValidationErrorInfo('CoAgentID', 'The co-agent cannot be the same as the target agent — an agent cannot front itself in a realtime session.', coAgentID, ValidationErrorType.Failure);
173
+ }
174
+ /**
175
+ * PURE invariant core for the co-agent reference (exported for unit tests): the referenced
176
+ * agent must exist, be Active, and be of the Realtime agent type.
177
+ *
178
+ * @param coAgentID The referenced co-agent id.
179
+ * @param status The loaded co-agent's Status, or `null` when the agent could not be loaded.
180
+ * @param typeName The loaded co-agent's TYPE name, or `null` when missing/unresolvable.
181
+ * @param agentName The loaded co-agent's display name (for friendlier messages).
182
+ * @returns The violations (empty array = valid).
183
+ */
184
+ export function BuildCoAgentInvariantErrors(coAgentID, status, typeName, agentName) {
185
+ if (status === null) {
186
+ return [
187
+ new ValidationErrorInfo('CoAgentID', `CoAgentID references agent '${coAgentID}' but no such agent exists.`, coAgentID, ValidationErrorType.Failure),
188
+ ];
189
+ }
190
+ const errors = [];
191
+ const label = agentName ? `'${agentName}'` : `'${coAgentID}'`;
192
+ if (status.trim().toLowerCase() !== 'active') {
193
+ errors.push(new ValidationErrorInfo('CoAgentID', `Co-agent ${label} must be Active to be paired (current Status: ${status}).`, coAgentID, ValidationErrorType.Failure));
194
+ }
195
+ if ((typeName ?? '').trim().toLowerCase() !== REALTIME_AGENT_TYPE_NAME.toLowerCase()) {
196
+ errors.push(new ValidationErrorInfo('CoAgentID', `Co-agent ${label} must be of the '${REALTIME_AGENT_TYPE_NAME}' agent type to drive realtime sessions ` +
197
+ `(current type: ${typeName ?? 'none'}).`, coAgentID, ValidationErrorType.Failure));
198
+ }
199
+ return errors;
200
+ }
201
+ /**
202
+ * PURE invariant: at most one `IsDefault = 1` row per (co-agent, relationship Type). Returns
203
+ * the error when `existingDefaultCount` other default rows already exist, else `null`.
204
+ */
205
+ export function BuildDuplicateDefaultError(coAgentID, existingDefaultCount) {
206
+ if (existingDefaultCount <= 0) {
207
+ return null;
208
+ }
209
+ return new ValidationErrorInfo('IsDefault', `Co-agent '${coAgentID}' already has a default paired target (${existingDefaultCount} IsDefault row(s) exist). ` +
210
+ 'Clear the existing default before marking this pairing as the default.', true, ValidationErrorType.Failure);
211
+ }
212
+ /**
213
+ * PURE invariant: a (CoAgentID, target side, Type) relationship may exist only once — the DB
214
+ * cannot enforce uniqueness across the two nullable target columns. Returns the error when
215
+ * `duplicateCount` other identical rows already exist, else `null`.
216
+ */
217
+ export function BuildDuplicateRelationshipError(coAgentID, relationshipType, duplicateCount) {
218
+ if (duplicateCount <= 0) {
219
+ return null;
220
+ }
221
+ return new ValidationErrorInfo('TargetAgentID', `An identical '${relationshipType}' relationship already exists for co-agent '${coAgentID}' and this target ` +
222
+ `(${duplicateCount} duplicate row(s)). Edit the existing row instead of creating another.`, coAgentID, ValidationErrorType.Failure);
223
+ }
224
+ //# sourceMappingURL=MJAIAgentCoAgentEntityServer.server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MJAIAgentCoAgentEntityServer.server.js","sourceRoot":"","sources":["../../src/custom/MJAIAgentCoAgentEntityServer.server.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAqB,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAoB,MAAM,sBAAsB,CAAC;AAC1I,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAmB,sBAAsB,EAAuB,MAAM,+BAA+B,CAAC;AAE7G,oFAAoF;AACpF,MAAM,wBAAw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Ac,wEAAwE,EAC9F,SAAS,EACT,mBAAmB,CAAC,OAAO,CAC9B,CAAC;AACN,CAAC"}
@@ -0,0 +1,50 @@
1
+ import { ValidationErrorInfo, ValidationResult } from '@memberjunction/core';
2
+ import { MJAIAgentEntityExtended } from '@memberjunction/ai-core-plus';
3
+ /**
4
+ * Server-side AI Agent entity that validates `TypeConfiguration` on save:
5
+ *
6
+ * 1. When non-empty, `TypeConfiguration` must parse as a JSON OBJECT (it is the per-agent
7
+ * layer of the effective-configuration merge — arrays/scalars are never valid layers).
8
+ * 2. When the agent's TYPE publishes a `ConfigSchema` (JSON Schema subset), the parsed
9
+ * configuration must conform to it — checked with the dependency-free
10
+ * {@link ValidateJsonAgainstSchemaLite} validator (type / required / properties / enum /
11
+ * items / additionalProperties). A type WITHOUT a published schema leaves the
12
+ * configuration freeform (rule 1 still applies).
13
+ *
14
+ * A malformed/unparseable `ConfigSchema` is a METADATA bug on the type row, not the agent
15
+ * being saved — it surfaces as a WARNING (the save proceeds) rather than blocking every agent
16
+ * of that type. Extends `MJAIAgentEntityExtended` so all client-side extended behavior is
17
+ * preserved; registered last, so the ClassFactory prefers it server-side.
18
+ */
19
+ export declare class MJAIAgentEntityServer extends MJAIAgentEntityExtended {
20
+ /** Enable async validation so the TypeConfiguration ⊨ ConfigSchema check runs. */
21
+ get DefaultSkipAsyncValidation(): boolean;
22
+ /**
23
+ * Async invariant: `TypeConfiguration` must be a JSON object conforming to the agent
24
+ * type's published `ConfigSchema`. Cheap fast-path — only runs when the configuration is
25
+ * present AND (the record is new, or `TypeConfiguration`/`TypeID` is dirty).
26
+ */
27
+ ValidateAsync(): Promise<ValidationResult>;
28
+ /**
29
+ * Loads the agent type's `ConfigSchema` through the same request-scoped provider that owns
30
+ * this entity. Returns `null` (freeform) when the agent has no type, the type row cannot be
31
+ * loaded, or no schema is published.
32
+ */
33
+ private loadTypeConfigSchema;
34
+ }
35
+ /**
36
+ * PURE validation core for the `TypeConfiguration` ⊨ `ConfigSchema` invariant (exported for
37
+ * unit tests and reuse):
38
+ *
39
+ * - unparseable / non-object `typeConfigurationJson` → one **Failure** on `TypeConfiguration`;
40
+ * - absent/blank `configSchemaJson` → no further checks (freeform configuration);
41
+ * - unparseable / non-object `configSchemaJson` → one **Warning** (metadata bug on the TYPE row
42
+ * — agent saves must not be bricked by it);
43
+ * - schema violations → one **Failure** per violation, with the JSON-path-ish location.
44
+ *
45
+ * @param typeConfigurationJson The agent's `TypeConfiguration` JSON (non-empty).
46
+ * @param configSchemaJson The type's `ConfigSchema` JSON Schema, or `null` when unpublished.
47
+ * @returns Validation errors/warnings (empty array = valid).
48
+ */
49
+ export declare function BuildTypeConfigurationValidationErrors(typeConfigurationJson: string, configSchemaJson: string | null): ValidationErrorInfo[];
50
+ //# sourceMappingURL=MJAIAgentEntityServer.server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MJAIAgentEntityServer.server.d.ts","sourceRoot":"","sources":["../../src/custom/MJAIAgentEntityServer.server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,mBAAmB,EAAuB,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAGjI,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAGvE;;;;;;;;;;;;;;;GAeG;AACH,qBACa,qBAAsB,SAAQ,uBAAuB;IAC9D,kFAAkF;IAClF,IAAoB,0BAA0B,IAAI,OAAO,CAExD;IAED;;;;OAIG;IACmB,aAAa,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAwBhE;;;;OAIG;YACW,oBAAoB;CAWrC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sCAAsC,CAClD,qBAAqB,EAAE,MAAM,EAC7B,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAChC,mBAAmB,EAAE,CAwDvB"}
@@ -0,0 +1,126 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { BaseEntity, ValidationErrorInfo, ValidationErrorType } from '@memberjunction/core';
8
+ import { RegisterClass } from '@memberjunction/global';
9
+ import { MJAIAgentEntityExtended } from '@memberjunction/ai-core-plus';
10
+ import { ValidateJsonAgainstSchemaLite } from './json-schema-lite.js';
11
+ /**
12
+ * Server-side AI Agent entity that validates `TypeConfiguration` on save:
13
+ *
14
+ * 1. When non-empty, `TypeConfiguration` must parse as a JSON OBJECT (it is the per-agent
15
+ * layer of the effective-configuration merge — arrays/scalars are never valid layers).
16
+ * 2. When the agent's TYPE publishes a `ConfigSchema` (JSON Schema subset), the parsed
17
+ * configuration must conform to it — checked with the dependency-free
18
+ * {@link ValidateJsonAgainstSchemaLite} validator (type / required / properties / enum /
19
+ * items / additionalProperties). A type WITHOUT a published schema leaves the
20
+ * configuration freeform (rule 1 still applies).
21
+ *
22
+ * A malformed/unparseable `ConfigSchema` is a METADATA bug on the type row, not the agent
23
+ * being saved — it surfaces as a WARNING (the save proceeds) rather than blocking every agent
24
+ * of that type. Extends `MJAIAgentEntityExtended` so all client-side extended behavior is
25
+ * preserved; registered last, so the ClassFactory prefers it server-side.
26
+ */
27
+ let MJAIAgentEntityServer = class MJAIAgentEntityServer extends MJAIAgentEntityExtended {
28
+ /** Enable async validation so the TypeConfiguration ⊨ ConfigSchema check runs. */
29
+ get DefaultSkipAsyncValidation() {
30
+ return false;
31
+ }
32
+ /**
33
+ * Async invariant: `TypeConfiguration` must be a JSON object conforming to the agent
34
+ * type's published `ConfigSchema`. Cheap fast-path — only runs when the configuration is
35
+ * present AND (the record is new, or `TypeConfiguration`/`TypeID` is dirty).
36
+ */
37
+ async ValidateAsync() {
38
+ const result = await super.ValidateAsync();
39
+ if (!result.Success)
40
+ return result;
41
+ const configJson = this.TypeConfiguration;
42
+ if (!configJson || configJson.trim().length === 0) {
43
+ return result; // null/empty = type defaults apply; nothing to validate
44
+ }
45
+ const configDirty = this.GetFieldByName('TypeConfiguration')?.Dirty ?? false;
46
+ const typeDirty = this.GetFieldByName('TypeID')?.Dirty ?? false;
47
+ if (this.IsSaved && !configDirty && !typeDirty) {
48
+ return result; // unchanged configuration against an unchanged type — already validated
49
+ }
50
+ const schemaJson = await this.loadTypeConfigSchema();
51
+ const errors = BuildTypeConfigurationValidationErrors(configJson, schemaJson);
52
+ if (errors.length > 0) {
53
+ result.Errors.push(...errors);
54
+ result.Success = errors.every((e) => e.Type !== ValidationErrorType.Failure);
55
+ }
56
+ return result;
57
+ }
58
+ /**
59
+ * Loads the agent type's `ConfigSchema` through the same request-scoped provider that owns
60
+ * this entity. Returns `null` (freeform) when the agent has no type, the type row cannot be
61
+ * loaded, or no schema is published.
62
+ */
63
+ async loadTypeConfigSchema() {
64
+ if (!this.TypeID) {
65
+ return null;
66
+ }
67
+ const md = this.ProviderToUse;
68
+ const type = await md.GetEntityObject('MJ: AI Agent Types', this.ContextCurrentUser);
69
+ if (!(await type.Load(this.TypeID))) {
70
+ return null; // dangling TypeID is the FK constraint's problem, not this check's
71
+ }
72
+ return type.ConfigSchema ?? null;
73
+ }
74
+ };
75
+ MJAIAgentEntityServer = __decorate([
76
+ RegisterClass(BaseEntity, 'MJ: AI Agents')
77
+ ], MJAIAgentEntityServer);
78
+ export { MJAIAgentEntityServer };
79
+ /**
80
+ * PURE validation core for the `TypeConfiguration` ⊨ `ConfigSchema` invariant (exported for
81
+ * unit tests and reuse):
82
+ *
83
+ * - unparseable / non-object `typeConfigurationJson` → one **Failure** on `TypeConfiguration`;
84
+ * - absent/blank `configSchemaJson` → no further checks (freeform configuration);
85
+ * - unparseable / non-object `configSchemaJson` → one **Warning** (metadata bug on the TYPE row
86
+ * — agent saves must not be bricked by it);
87
+ * - schema violations → one **Failure** per violation, with the JSON-path-ish location.
88
+ *
89
+ * @param typeConfigurationJson The agent's `TypeConfiguration` JSON (non-empty).
90
+ * @param configSchemaJson The type's `ConfigSchema` JSON Schema, or `null` when unpublished.
91
+ * @returns Validation errors/warnings (empty array = valid).
92
+ */
93
+ export function BuildTypeConfigurationValidationErrors(typeConfigurationJson, configSchemaJson) {
94
+ let config;
95
+ try {
96
+ config = JSON.parse(typeConfigurationJson);
97
+ }
98
+ catch (error) {
99
+ return [
100
+ new ValidationErrorInfo('TypeConfiguration', `TypeConfiguration is not valid JSON: ${error instanceof Error ? error.message : String(error)}`, typeConfigurationJson, ValidationErrorType.Failure),
101
+ ];
102
+ }
103
+ if (config === null || typeof config !== 'object' || Array.isArray(config)) {
104
+ return [
105
+ new ValidationErrorInfo('TypeConfiguration', 'TypeConfiguration must be a JSON object (arrays and scalars are not valid configuration payloads).', typeConfigurationJson, ValidationErrorType.Failure),
106
+ ];
107
+ }
108
+ if (!configSchemaJson || configSchemaJson.trim().length === 0) {
109
+ return []; // no published schema — freeform configuration
110
+ }
111
+ let schema;
112
+ try {
113
+ schema = JSON.parse(configSchemaJson);
114
+ }
115
+ catch {
116
+ schema = null;
117
+ }
118
+ if (schema === null || typeof schema !== 'object' || Array.isArray(schema)) {
119
+ return [
120
+ new ValidationErrorInfo('TypeConfiguration', "The agent type's ConfigSchema is not a parseable JSON Schema object — schema conformance was NOT " +
121
+ 'checked (fix the ConfigSchema on the agent type row).', configSchemaJson, ValidationErrorType.Warning),
122
+ ];
123
+ }
124
+ return ValidateJsonAgainstSchemaLite(config, schema).map((violation) => new ValidationErrorInfo('TypeConfiguration', `TypeConfiguration does not conform to the agent type's ConfigSchema: ${violation}`, typeConfigurationJson, ValidationErrorType.Failure));
125
+ }
126
+ //# sourceMappingURL=MJAIAgentEntityServer.server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MJAIAgentEntityServer.server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import { MJAIAgentNoteEntity } from "@memberjunction/core-entities";
5
5
  * 1. Auto-generates an embedding when the Note field is new or dirty.
6
6
  * 2. Keeps `AIEngine._noteVectorService` in sync with the note's persisted Status.
7
7
  * Invariant: the vector service contains an entry for a note iff its current Status
8
- * is 'Active' AND it has a non-empty EmbeddingVector. This write-side invariant lets
9
- * the retrieval filters (`composeNoteFilters`) be pure scope filters — they don't
10
- * need to consult any additional cache to decide whether a vector hit is still valid.
8
+ * is injectable ('Active' or 'Provisional' — see INJECTABLE_NOTE_STATUSES in
9
+ * @memberjunction/core-entities) AND it has a non-empty EmbeddingVector. This
10
+ * write-side invariant lets the retrieval filters (`composeNoteFilters`) be pure
11
+ * scope filters — they don't need to consult any additional cache to decide
12
+ * whether a vector hit is still valid. Provisional notes (written in-flight by
13
+ * agents) are deliberately injectable immediately, pending Memory Manager hardening.
11
14
  */
12
15
  export declare class MJAIAgentNoteEntityServer extends MJAIAgentNoteEntity {
13
16
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"MJAIAgentNoteEntityServer.server.d.ts","sourceRoot":"","sources":["../../src/custom/MJAIAgentNoteEntityServer.server.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,mBAAmB,EAAE,iBAAiB,EAAY,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC3H,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAIpE;;;;;;;;GAQG;AACH,qBACa,yBAA0B,SAAQ,mBAAmB;IAC9D;;OAEG;cACsB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAI7E,IAAI,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;IAyCnD,MAAM,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;CAQzE"}
1
+ {"version":3,"file":"MJAIAgentNoteEntityServer.server.d.ts","sourceRoot":"","sources":["../../src/custom/MJAIAgentNoteEntityServer.server.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,mBAAmB,EAAE,iBAAiB,EAAY,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC3H,OAAO,EAAE,mBAAmB,EAA0B,MAAM,+BAA+B,CAAC;AAI5F;;;;;;;;;;;GAWG;AACH,qBACa,yBAA0B,SAAQ,mBAAmB;IAC9D;;OAEG;cACsB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAI7E,IAAI,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;IAyCnD,MAAM,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;CAQzE"}
@@ -6,7 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import { RegisterClass } from "@memberjunction/global";
8
8
  import { BaseEntity, LogError } from "@memberjunction/core";
9
- import { MJAIAgentNoteEntity } from "@memberjunction/core-entities";
9
+ import { MJAIAgentNoteEntity, IsInjectableNoteStatus } from "@memberjunction/core-entities";
10
10
  import { EmbedTextLocalHelper } from "./util.js";
11
11
  import { AIEngine } from "@memberjunction/aiengine";
12
12
  /**
@@ -14,9 +14,12 @@ import { AIEngine } from "@memberjunction/aiengine";
14
14
  * 1. Auto-generates an embedding when the Note field is new or dirty.
15
15
  * 2. Keeps `AIEngine._noteVectorService` in sync with the note's persisted Status.
16
16
  * Invariant: the vector service contains an entry for a note iff its current Status
17
- * is 'Active' AND it has a non-empty EmbeddingVector. This write-side invariant lets
18
- * the retrieval filters (`composeNoteFilters`) be pure scope filters — they don't
19
- * need to consult any additional cache to decide whether a vector hit is still valid.
17
+ * is injectable ('Active' or 'Provisional' — see INJECTABLE_NOTE_STATUSES in
18
+ * @memberjunction/core-entities) AND it has a non-empty EmbeddingVector. This
19
+ * write-side invariant lets the retrieval filters (`composeNoteFilters`) be pure
20
+ * scope filters — they don't need to consult any additional cache to decide
21
+ * whether a vector hit is still valid. Provisional notes (written in-flight by
22
+ * agents) are deliberately injectable immediately, pending Memory Manager hardening.
20
23
  */
21
24
  let MJAIAgentNoteEntityServer = class MJAIAgentNoteEntityServer extends MJAIAgentNoteEntity {
22
25
  /**
@@ -43,8 +46,8 @@ let MJAIAgentNoteEntityServer = class MJAIAgentNoteEntityServer extends MJAIAgen
43
46
  if (!saved)
44
47
  return false;
45
48
  // 3. Sync the in-memory vector service with the just-persisted Status.
46
- // - Active + has embedding → (re)insert so retrieval can find it.
47
- // - Anything else (Revoked/Archived, or cleared embedding) → drop the vector
49
+ // - Injectable (Active/Provisional) + has embedding → (re)insert so retrieval can find it.
50
+ // - Anything else (Revoked/Archived/Pending, or cleared embedding) → drop the vector
48
51
  // entry. The original vector metadata still holds a reference to the stale
49
52
  // entity instance, so leaving it would leak into future retrievals.
50
53
  //
@@ -52,7 +55,7 @@ let MJAIAgentNoteEntityServer = class MJAIAgentNoteEntityServer extends MJAIAgen
52
55
  // background load completes, the underlying vector service is null and the
53
56
  // update would silently no-op. EnsureLoaded blocks until the engine is ready.
54
57
  await AIEngine.Instance.EnsureLoaded();
55
- if (this.Status === 'Active' && this.EmbeddingVector) {
58
+ if (IsInjectableNoteStatus(this.Status) && this.EmbeddingVector) {
56
59
  AIEngine.Instance.AddOrUpdateSingleNoteEmbedding(this);
57
60
  }
58
61
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"MJAIAgentNoteEntityServer.server.js","sourceRoot":"","sources":["../../src/custom/MJAIAgentNoteEntityServer.server.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,EAA0C,QAAQ,EAAyB,MAAM,sBAAsB,CAAC;AAC3H,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE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