@memberjunction/server 6.1.0-edge.0 → 6.1.0-edge.2

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 (175) hide show
  1. package/dist/auth/exampleNewUserSubClass.js +1 -1
  2. package/dist/auth/exampleNewUserSubClass.js.map +1 -1
  3. package/dist/auth/index.d.ts.map +1 -1
  4. package/dist/auth/index.js +9 -5
  5. package/dist/auth/index.js.map +1 -1
  6. package/dist/auth/magicLink/MagicLinkService.js +1 -1
  7. package/dist/auth/magicLink/MagicLinkService.js.map +1 -1
  8. package/dist/auth/newUsers.js +1 -1
  9. package/dist/auth/newUsers.js.map +1 -1
  10. package/dist/context.js +2 -2
  11. package/dist/context.js.map +1 -1
  12. package/dist/generated/generated.d.ts +208 -646
  13. package/dist/generated/generated.d.ts.map +1 -1
  14. package/dist/generated/generated.js +1123 -3773
  15. package/dist/generated/generated.js.map +1 -1
  16. package/dist/generic/ResolverBase.d.ts +19 -3
  17. package/dist/generic/ResolverBase.d.ts.map +1 -1
  18. package/dist/generic/ResolverBase.js +51 -17
  19. package/dist/generic/ResolverBase.js.map +1 -1
  20. package/dist/index.d.ts +6 -2
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +100 -42
  23. package/dist/index.js.map +1 -1
  24. package/dist/logging/secretRedactor.d.ts +9 -0
  25. package/dist/logging/secretRedactor.d.ts.map +1 -1
  26. package/dist/logging/secretRedactor.js +39 -0
  27. package/dist/logging/secretRedactor.js.map +1 -1
  28. package/dist/middleware/BaseServerMiddleware.d.ts +5 -0
  29. package/dist/middleware/BaseServerMiddleware.d.ts.map +1 -1
  30. package/dist/middleware/BaseServerMiddleware.js +5 -0
  31. package/dist/middleware/BaseServerMiddleware.js.map +1 -1
  32. package/dist/realtimeWidget/WidgetSessionService.js +1 -1
  33. package/dist/realtimeWidget/WidgetSessionService.js.map +1 -1
  34. package/dist/realtimeWidget/widgetGuestElevation.js +1 -1
  35. package/dist/realtimeWidget/widgetGuestElevation.js.map +1 -1
  36. package/dist/resolvers/ActionResolver.d.ts.map +1 -1
  37. package/dist/resolvers/ActionResolver.js +12 -0
  38. package/dist/resolvers/ActionResolver.js.map +1 -1
  39. package/dist/resolvers/ComponentRegistryResolver.js +1 -1
  40. package/dist/resolvers/ComponentRegistryResolver.js.map +1 -1
  41. package/dist/resolvers/EntityPermissionResolver.js +1 -1
  42. package/dist/resolvers/EntityPermissionResolver.js.map +1 -1
  43. package/dist/resolvers/IntegrationDiscoveryResolver.d.ts +9 -0
  44. package/dist/resolvers/IntegrationDiscoveryResolver.d.ts.map +1 -1
  45. package/dist/resolvers/IntegrationDiscoveryResolver.js +3 -1
  46. package/dist/resolvers/IntegrationDiscoveryResolver.js.map +1 -1
  47. package/dist/resolvers/PotentialDuplicateRecordResolver.js +1 -1
  48. package/dist/resolvers/PotentialDuplicateRecordResolver.js.map +1 -1
  49. package/dist/resolvers/RealtimeClientSessionResolver.d.ts +10 -0
  50. package/dist/resolvers/RealtimeClientSessionResolver.d.ts.map +1 -1
  51. package/dist/resolvers/RealtimeClientSessionResolver.js +5 -0
  52. package/dist/resolvers/RealtimeClientSessionResolver.js.map +1 -1
  53. package/dist/resolvers/SearchEntitiesResolver.js +1 -1
  54. package/dist/resolvers/SearchEntitiesResolver.js.map +1 -1
  55. package/dist/resolvers/SqlLoggingConfigResolver.d.ts.map +1 -1
  56. package/dist/resolvers/SqlLoggingConfigResolver.js +1 -1
  57. package/dist/resolvers/SqlLoggingConfigResolver.js.map +1 -1
  58. package/dist/resolvers/SyncRolesUsersResolver.js +2 -2
  59. package/dist/resolvers/SyncRolesUsersResolver.js.map +1 -1
  60. package/dist/resolvers/TaskGraphFrameResolver.d.ts +85 -0
  61. package/dist/resolvers/TaskGraphFrameResolver.d.ts.map +1 -0
  62. package/dist/resolvers/TaskGraphFrameResolver.js +163 -0
  63. package/dist/resolvers/TaskGraphFrameResolver.js.map +1 -0
  64. package/dist/resolvers/UserFavoriteResolver.js +1 -1
  65. package/dist/resolvers/UserFavoriteResolver.js.map +1 -1
  66. package/dist/rest/OAuthCallbackHandler.js +1 -1
  67. package/dist/rest/OAuthCallbackHandler.js.map +1 -1
  68. package/dist/rest/RESTEndpointHandler.d.ts +0 -4
  69. package/dist/rest/RESTEndpointHandler.d.ts.map +1 -1
  70. package/dist/rest/RESTEndpointHandler.js +1 -15
  71. package/dist/rest/RESTEndpointHandler.js.map +1 -1
  72. package/dist/rest/SignatureWebhookHandler.js +1 -1
  73. package/dist/rest/SignatureWebhookHandler.js.map +1 -1
  74. package/dist/services/DurableEntityActionTaskSubmitter.d.ts +26 -0
  75. package/dist/services/DurableEntityActionTaskSubmitter.d.ts.map +1 -0
  76. package/dist/services/DurableEntityActionTaskSubmitter.js +55 -0
  77. package/dist/services/DurableEntityActionTaskSubmitter.js.map +1 -0
  78. package/dist/services/ScheduledJobsService.js +1 -1
  79. package/dist/services/ScheduledJobsService.js.map +1 -1
  80. package/dist/services/StartTaskGraphDispatcher.d.ts +33 -0
  81. package/dist/services/StartTaskGraphDispatcher.d.ts.map +1 -0
  82. package/dist/services/StartTaskGraphDispatcher.js +46 -0
  83. package/dist/services/StartTaskGraphDispatcher.js.map +1 -0
  84. package/dist/services/TaskGraphActionRunner.d.ts +34 -0
  85. package/dist/services/TaskGraphActionRunner.d.ts.map +1 -0
  86. package/dist/services/TaskGraphActionRunner.js +95 -0
  87. package/dist/services/TaskGraphActionRunner.js.map +1 -0
  88. package/dist/services/TaskGraphAgentRunner.d.ts +28 -0
  89. package/dist/services/TaskGraphAgentRunner.d.ts.map +1 -0
  90. package/dist/services/TaskGraphAgentRunner.js +104 -0
  91. package/dist/services/TaskGraphAgentRunner.js.map +1 -0
  92. package/dist/services/TaskGraphContinuationDeliverer.d.ts +70 -0
  93. package/dist/services/TaskGraphContinuationDeliverer.d.ts.map +1 -0
  94. package/dist/services/TaskGraphContinuationDeliverer.js +162 -0
  95. package/dist/services/TaskGraphContinuationDeliverer.js.map +1 -0
  96. package/dist/services/TaskGraphPromptRunner.d.ts +31 -0
  97. package/dist/services/TaskGraphPromptRunner.d.ts.map +1 -0
  98. package/dist/services/TaskGraphPromptRunner.js +134 -0
  99. package/dist/services/TaskGraphPromptRunner.js.map +1 -0
  100. package/dist/services/TaskGraphProviderFactory.d.ts +39 -0
  101. package/dist/services/TaskGraphProviderFactory.d.ts.map +1 -0
  102. package/dist/services/TaskGraphProviderFactory.js +28 -0
  103. package/dist/services/TaskGraphProviderFactory.js.map +1 -0
  104. package/dist/telephony/RingCentralTelephonyService.js +1 -1
  105. package/dist/telephony/RingCentralTelephonyService.js.map +1 -1
  106. package/dist/telephony/TwilioTelephonyRouter.js +1 -1
  107. package/dist/telephony/TwilioTelephonyRouter.js.map +1 -1
  108. package/dist/telephony/VonageTelephonyRouter.js +1 -1
  109. package/dist/telephony/VonageTelephonyRouter.js.map +1 -1
  110. package/package.json +92 -89
  111. package/src/__tests__/RealtimeClientSessionResolver.test.ts +1 -1
  112. package/src/__tests__/ResolverBase.frozenRecordMapping.test.ts +133 -0
  113. package/src/__tests__/ResolverBase.transportMapping.test.ts +289 -0
  114. package/src/__tests__/SessionManager.test.ts +1 -1
  115. package/src/__tests__/TaskGraphContinuationDeliverer.test.ts +249 -0
  116. package/src/__tests__/TaskGraphFrameResolver.test.ts +136 -0
  117. package/src/__tests__/WidgetSessionService.test.ts +1 -1
  118. package/src/__tests__/databaseAbstraction.test.ts +1 -1
  119. package/src/__tests__/magicLinkService.provisionLog.test.ts +1 -1
  120. package/src/__tests__/resolverBase.rls.test.ts +3 -0
  121. package/src/__tests__/secretRedactor.failOpen.test.ts +135 -0
  122. package/src/__tests__/widgetGuestElevation.test.ts +1 -1
  123. package/src/auth/exampleNewUserSubClass.ts +1 -1
  124. package/src/auth/index.ts +10 -6
  125. package/src/auth/magicLink/MagicLinkService.ts +1 -1
  126. package/src/auth/newUsers.ts +1 -1
  127. package/src/context.ts +2 -2
  128. package/src/generated/generated.ts +955 -2735
  129. package/src/generic/ResolverBase.ts +52 -17
  130. package/src/index.ts +108 -43
  131. package/src/logging/secretRedactor.ts +43 -0
  132. package/src/middleware/BaseServerMiddleware.ts +5 -0
  133. package/src/realtimeWidget/WidgetSessionService.ts +1 -1
  134. package/src/realtimeWidget/widgetGuestElevation.ts +1 -1
  135. package/src/resolvers/ActionResolver.ts +13 -0
  136. package/src/resolvers/ComponentRegistryResolver.ts +1 -1
  137. package/src/resolvers/EntityPermissionResolver.ts +1 -1
  138. package/src/resolvers/IntegrationDiscoveryResolver.ts +12 -2
  139. package/src/resolvers/PotentialDuplicateRecordResolver.ts +1 -1
  140. package/src/resolvers/RealtimeClientSessionResolver.ts +13 -0
  141. package/src/resolvers/SearchEntitiesResolver.ts +1 -1
  142. package/src/resolvers/SqlLoggingConfigResolver.ts +1 -2
  143. package/src/resolvers/SyncRolesUsersResolver.ts +2 -2
  144. package/src/resolvers/TaskGraphFrameResolver.ts +160 -0
  145. package/src/resolvers/UserFavoriteResolver.ts +1 -1
  146. package/src/rest/OAuthCallbackHandler.ts +1 -1
  147. package/src/rest/RESTEndpointHandler.ts +1 -15
  148. package/src/rest/SignatureWebhookHandler.ts +1 -1
  149. package/src/services/DurableEntityActionTaskSubmitter.ts +78 -0
  150. package/src/services/ScheduledJobsService.ts +1 -1
  151. package/src/services/StartTaskGraphDispatcher.ts +78 -0
  152. package/src/services/TaskGraphActionRunner.ts +99 -0
  153. package/src/services/TaskGraphAgentRunner.ts +115 -0
  154. package/src/services/TaskGraphContinuationDeliverer.ts +181 -0
  155. package/src/services/TaskGraphPromptRunner.ts +144 -0
  156. package/src/services/TaskGraphProviderFactory.ts +53 -0
  157. package/src/telephony/RingCentralTelephonyService.ts +1 -1
  158. package/src/telephony/TwilioTelephonyRouter.ts +1 -1
  159. package/src/telephony/VonageTelephonyRouter.ts +1 -1
  160. package/dist/resolvers/ReportResolver.d.ts +0 -24
  161. package/dist/resolvers/ReportResolver.d.ts.map +0 -1
  162. package/dist/resolvers/ReportResolver.js +0 -198
  163. package/dist/resolvers/ReportResolver.js.map +0 -1
  164. package/dist/resolvers/TaskResolver.d.ts +0 -31
  165. package/dist/resolvers/TaskResolver.d.ts.map +0 -1
  166. package/dist/resolvers/TaskResolver.js +0 -157
  167. package/dist/resolvers/TaskResolver.js.map +0 -1
  168. package/dist/services/TaskOrchestrator.d.ts +0 -130
  169. package/dist/services/TaskOrchestrator.d.ts.map +0 -1
  170. package/dist/services/TaskOrchestrator.js +0 -692
  171. package/dist/services/TaskOrchestrator.js.map +0 -1
  172. package/src/resolvers/ReportResolver.ts +0 -165
  173. package/src/resolvers/TaskResolver.ts +0 -148
  174. package/src/resolvers/__tests__/ReportResolver.test.ts +0 -279
  175. package/src/services/TaskOrchestrator.ts +0 -873
@@ -0,0 +1,55 @@
1
+ import { LogError } from '@memberjunction/core';
2
+ import { TaskNode } from '@memberjunction/ai-core-plus';
3
+ import { MJEnvironmentEntityExtended } from '@memberjunction/core-entities';
4
+ import { TaskGraphService } from '@memberjunction/task-graph';
5
+ export class DurableEntityActionTaskSubmitter {
6
+ /**
7
+ * @param environmentID which environment the tasks belong to. Defaults to the platform default
8
+ * because a save has no environment of its own to inherit — the record's entity is global, and
9
+ * inventing a per-save environment would put a durable dispatch somewhere nobody looks.
10
+ */
11
+ constructor(providerFactory, environmentID = MJEnvironmentEntityExtended.DefaultEnvironmentID) {
12
+ this.providerFactory = providerFactory;
13
+ this.environmentID = environmentID;
14
+ }
15
+ async Submit(request) {
16
+ try {
17
+ const spec = {
18
+ workflowName: `${request.ActionName} — ${request.EntityName}`,
19
+ reasoning: `Durable dispatch of entity action binding ${request.EntityActionID} on ` +
20
+ `${request.EntityName} (${request.RecordID}), fired by ${request.InvocationType}.`,
21
+ tasks: [
22
+ TaskNode.Action({
23
+ tempId: 'action',
24
+ name: request.ActionName,
25
+ description: `Run ${request.ActionName} for ${request.EntityName} ${request.RecordID}.`,
26
+ dependsOn: [],
27
+ inputPayload: request.RedactedParams,
28
+ }, { actionName: request.ActionName }),
29
+ ],
30
+ // Nothing to say to anyone: this graph exists because a record was saved, not
31
+ // because a person asked a question. Defaulting to 'message' would post an
32
+ // orphaned result into whichever conversation happened to be nearby.
33
+ continuation: 'none',
34
+ // The point of the exercise. A one-node graph constant-folds to in-run execution by
35
+ // default (D9), which is exactly the fire-and-forget behaviour being escaped.
36
+ durable: true,
37
+ };
38
+ const provider = await this.providerFactory.CreateProvider();
39
+ const result = await new TaskGraphService().Submit(spec, {
40
+ EnvironmentID: this.environmentID,
41
+ ContextUser: request.ContextUser,
42
+ Provider: provider,
43
+ });
44
+ return result.Success
45
+ ? { Success: true, ParentTaskID: result.ParentTaskID }
46
+ : { Success: false, ErrorMessage: result.ErrorMessage };
47
+ }
48
+ catch (e) {
49
+ const message = e instanceof Error ? e.message : String(e);
50
+ LogError(`[DurableEntityActionTaskSubmitter] Submission failed for binding ${request.EntityActionID}: ${message}`);
51
+ return { Success: false, ErrorMessage: message };
52
+ }
53
+ }
54
+ }
55
+ //# sourceMappingURL=DurableEntityActionTaskSubmitter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DurableEntityActionTaskSubmitter.js","sourceRoot":"","sources":["../../src/services/DurableEntityActionTaskSubmitter.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAsB,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAwB,MAAM,4BAA4B,CAAC;AAEpF,MAAM,OAAO,gCAAgC;IACzC;;;;OAIG;IACH,YACqB,eAAgC,EAChC,gBAAwB,2BAA2B,CAAC,oBAAoB;QADxE,oBAAe,GAAf,eAAe,CAAiB;QAChC,kBAAa,GAAb,aAAa,CAA2D;IAC1F,CAAC;IAEG,KAAK,CAAC,MAAM,CAAC,OAAmC;QACnD,IAAI,CAAC;YACD,MAAM,IAAI,GAAkB;g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AO,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC3D,QAAQ,CAAC,oEAAoE,OAAO,CAAC,cAAc,KAAK,OAAO,EAAE,CAAC,CAAC;YACnH,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC;QACrD,CAAC;IACL,CAAC;CACJ"}
@@ -3,7 +3,7 @@
3
3
  * @module MJServer/services
4
4
  */
5
5
  import { LogError, LogStatus, LogStatusEx } from '@memberjunction/core';
6
- import { UserCache } from '@memberjunction/sqlserver-dataprovider';
6
+ import { UserCache } from '@memberjunction/generic-database-provider';
7
7
  import { SchedulingEngine } from '@memberjunction/scheduling-engine';
8
8
  /**
9
9
  * Service for managing scheduled jobs lifecycle
@@ -1 +1 @@
1
- {"version":3,"file":"ScheduledJobsService.js","sourceRoot":"","sources":["../../src/services/ScheduledJobsService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAY,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAGrE;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IAM7B,YAAY,MAA2B;QAJ/B,eAAU,GAAoB,IAAI,CAAC;QACnC,cAAS,GAAY,KAAK,CAAC;QAI/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,gBAAgB,CAAC,QAAQ,CAAC;IAC5C,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,UAAU;QACnB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACvB,SAAS,CAAC,qEAAqE,CAAC,CAAC;YACjF,OAAO;QACX,CAAC;QAED,IAA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CAAC,aAAa;QACvB,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC;QAEpD,mCAAmC;QACnC,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAClC,CAAC,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,eAAe,CAAC,WAAW,EAAE,CAC3D,CAAC;QAEF,IAAI,IAAI,EAAE,CAAC;YACP,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,QAAQ,CAAC,4DAA4D,eAAe,EAAE,CAAC,CAAC;QACxF,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,SAAS;QAMZ,OAAO;YACH,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO;YAC5B,OAAO,EAAE,IAAI,CAAC,SAAS;YACvB,UAAU,EAAE,IAAI,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;YACnD,eAAe,EAAE,IAAI,CAAC,MAAM,EAAE,qBAAqB,IAAI,CAAC;SAC3D,CAAC;IACN,CAAC;IAED;;OAEG;IACH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;CACJ"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @fileoverview Boots the durable task-graph dispatcher inside MJServer.
3
+ *
4
+ * Phase 2 landed the dispatcher and the submission path but never started anything, so a submitted
5
+ * graph persisted correctly and then sat in `Pending` forever. Submission being durable is only
6
+ * half the promise — something has to *pick the work up*.
7
+ *
8
+ * The continuation deliverer is supplied here for the same reason the agent runner is: posting into
9
+ * a conversation is a host concern the package deliberately refuses to know about.
10
+ *
11
+ * Registration of the package's Remote Operations is a separate concern handled by the generated
12
+ * class-registration manifests (`ServerBootstrap` / `ServerBootstrapLite`), which import the
13
+ * subclasses so their `@RegisterClass` decorators run. `LoadTaskGraphOperations` is called here
14
+ * anyway as a cheap guard: a host that starts a dispatcher but never loaded a manifest would accept
15
+ * submissions that route to the CodeGen contract-only base and silently do nothing.
16
+ *
17
+ * @module @memberjunction/server
18
+ */
19
+ import { UserInfo } from '@memberjunction/core';
20
+ import { TaskGraphDispatcher } from '@memberjunction/task-graph';
21
+ import sql from 'mssql';
22
+ /**
23
+ * Starts one dispatcher for this process and returns it.
24
+ *
25
+ * The instance ID must be stable for the process lifetime and distinct per instance — it is what
26
+ * lets reconciliation tell "my own orphaned work, reclaim it" from "another live instance's work,
27
+ * leave it alone". `pid` plus hostname satisfies both: stable while the process lives, and never
28
+ * reused by a peer.
29
+ *
30
+ * The dispatcher self-registers with `ShutdownRegistry`, so the caller does not wire teardown.
31
+ */
32
+ export declare function StartTaskGraphDispatcher(pool: sql.ConnectionPool, contextUser: UserInfo, instanceID?: string): Promise<TaskGraphDispatcher>;
33
+ //# sourceMappingURL=StartTaskGraphDispatcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StartTaskGraphDispatcher.d.ts","sourceRoot":"","sources":["../../src/services/StartTaskGraphDispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAA2B,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAE1F,OAAO,GAAG,MAAM,OAAO,CAAC;AAUxB;;;;;;;;;GASG;AACH,wBAAsB,wBAAwB,CAC1C,IAAI,EAAE,GAAG,CAAC,cAAc,EACxB,WAAW,EAAE,QAAQ,EACrB,UAAU,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,mBAAmB,CAAC,CAgC9B"}
@@ -0,0 +1,46 @@
1
+ import { LoadTaskGraphOperations, TaskGraphDispatcher } from '@memberjunction/task-graph';
2
+ import { TaskGraphPromptRunner } from './TaskGraphPromptRunner.js';
3
+ import { DurableEntityActionRegistry } from '@memberjunction/actions-base';
4
+ import { CreateTaskGraphProviderFactory } from './TaskGraphProviderFactory.js';
5
+ import { TaskGraphActionRunner } from './TaskGraphActionRunner.js';
6
+ import { TaskGraphAgentRunner } from './TaskGraphAgentRunner.js';
7
+ import { DurableEntityActionTaskSubmitter } from './DurableEntityActionTaskSubmitter.js';
8
+ import { TaskGraphContinuationDeliverer } from './TaskGraphContinuationDeliverer.js';
9
+ import { PubSubManager } from '../generic/PubSubManager.js';
10
+ import { TaskGraphFrameBroadcaster } from '../resolvers/TaskGraphFrameResolver.js';
11
+ /**
12
+ * Starts one dispatcher for this process and returns it.
13
+ *
14
+ * The instance ID must be stable for the process lifetime and distinct per instance — it is what
15
+ * lets reconciliation tell "my own orphaned work, reclaim it" from "another live instance's work,
16
+ * leave it alone". `pid` plus hostname satisfies both: stable while the process lives, and never
17
+ * reused by a peer.
18
+ *
19
+ * The dispatcher self-registers with `ShutdownRegistry`, so the caller does not wire teardown.
20
+ */
21
+ export async function StartTaskGraphDispatcher(pool, contextUser, instanceID) {
22
+ LoadTaskGraphOperations();
23
+ const providerFactory = CreateTaskGraphProviderFactory(pool);
24
+ const pubSub = PubSubManager.Instance.PubSubEngine;
25
+ const dispatcher = new TaskGraphDispatcher(providerFactory, new TaskGraphAgentRunner(), contextUser, { InstanceID: instanceID ?? `${process.env.HOSTNAME ?? 'mjapi'}-${process.pid}` },
26
+ // Without this the dispatcher had nowhere to deliver: a finished graph logged its outcome,
27
+ // marked itself delivered, and said nothing to the conversation that asked for it.
28
+ new TaskGraphContinuationDeliverer(providerFactory, contextUser),
29
+ // Live signal. Supplied only when a PubSub engine exists — in a worker or a test there is
30
+ // nobody to publish to, and the dispatcher runs identically without one.
31
+ pubSub ? new TaskGraphFrameBroadcaster(pubSub) : undefined,
32
+ // Action nodes — the third execution shape, beside agents and people. Durable After* entity
33
+ // actions land as these.
34
+ new TaskGraphActionRunner(),
35
+ // Prompt nodes. Without this a Flow agent with a Prompt step submits and then
36
+ // stalls on a task nothing can execute — which is why the shipped User Onboarding
37
+ // Flow Agent could not run at all before this seam existed.
38
+ new TaskGraphPromptRunner());
39
+ await dispatcher.Start();
40
+ // Registered only AFTER the dispatcher is running, and only here. A submitter without a
41
+ // dispatcher writes Task rows nobody picks up — strictly worse than staying inline, because the
42
+ // work is now both undone and invisible in the place it used to be logged.
43
+ DurableEntityActionRegistry.Instance.Register(new DurableEntityActionTaskSubmitter(providerFactory));
44
+ return dispatcher;
45
+ }
46
+ //# sourceMappingURL=StartTaskGraphDispatcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StartTaskGraphDispatcher.js","sourceRoot":"","sources":["../../src/services/StartTaskGraphDispatcher.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAC1F,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AACzF,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AAEnF;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC1C,IAAwB,EACxB,WAAqB,EACrB,UAAmB;IAEnB,uBAAuB,EAAE,CAAC;IAE1B,MAAM,eAAe,GAAG,8BAA8B,CAAC,IAAI,CAAC,CAAC;IAC7D,MAAM,MAAM,GAAG,aAAa,CAAC,QAAQ,CAAC,YAAY,CAAC;IACnD,MAAM,UAAU,GAAG,IAAI,mBAAmB,CACtC,eAAe,EACf,IAAI,oBAAoB,EAAE,EAC1B,WAAW,EACX,EAAE,UAAU,EAAE,UAAU,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,OAAO,IAAI,OAAO,CAAC,GAAG,EAAE,EAAE;IACjF,2FAA2F;IAC3F,mFAAmF;IACnF,IAAI,8BAA8B,CAAC,eAAe,EAAE,WAAW,CAAC;IAChE,0FAA0F;IAC1F,yEAAyE;IACzE,MAAM,CAAC,CAAC,CAAC,IAAI,yBAAyB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;IAC1D,4FAA4F;IAC5F,yBAAyB;IACzB,IAAI,qBAAqB,EAAE;IAC3B,8EAA8E;IAC9E,kFAAkF;IAClF,4DAA4D;IAC5D,IAAI,qBAAqB,EAAE,CAC9B,CAAC;IACF,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;IAEzB,wFAAwF;IACxF,gGAAgG;IAChG,2EAA2E;IAC3E,2BAA2B,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,gCAAgC,CAAC,eAAe,CAAC,CAAC,CAAC;IAErG,OAAO,UAAU,CAAC;AACtB,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { TaskActionRunner, TaskActionRunParams, TaskActionRunResult } from '@memberjunction/task-graph';
2
+ export declare class TaskGraphActionRunner implements TaskActionRunner {
3
+ RunActionForTask(params: TaskActionRunParams): Promise<TaskActionRunResult>;
4
+ /**
5
+ * Projects the action's parameters onto the flat result a workflow step is expected to produce.
6
+ *
7
+ * **Why not return `result.Params` as-is.** That is an `ActionParam[]`, and every consumer of a
8
+ * step's output addresses fields BY NAME: an output mapping says `{"CurrentPrice": "stockPrice"}`,
9
+ * and a branch condition then reads `payload.stockPrice`. Handed an array, the mapping finds no
10
+ * `CurrentPrice`, writes nothing, and the condition evaluates against `undefined` — which is
11
+ * falsy rather than erroneous, so the workflow takes the other branch and reports success. That
12
+ * is exactly what the Demo workflow did: step 1 completed with an output payload of `{}` and
13
+ * every downstream branch was skipped, with nothing anywhere reporting a problem.
14
+ *
15
+ * Only `Output` and `Both` params are included. Echoing the inputs back would let a step's own
16
+ * parameters masquerade as its results, so an output mapping could "succeed" by reading the
17
+ * value the step was given rather than the one it produced.
18
+ */
19
+ private buildOutput;
20
+ /**
21
+ * Rebuilds the action's parameters from the task's stored payload.
22
+ *
23
+ * **The values here have been through redaction**, because `Task.InputPayload` is persistent,
24
+ * user-visible storage and nothing writes a raw `ActionParam[]` there. A parameter the binding
25
+ * marked as not-logged therefore arrives absent rather than secret — the action sees a missing
26
+ * value, which is the honest consequence of choosing not to persist it, and the reason durable
27
+ * dispatch is opt-in per binding rather than the default.
28
+ *
29
+ * Dependency outputs are merged underneath the task's own input so a node's explicit parameters
30
+ * always win over an upstream node that happened to emit the same key.
31
+ */
32
+ private buildParams;
33
+ }
34
+ //# sourceMappingURL=TaskGraphActionRunner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TaskGraphActionRunner.d.ts","sourceRoot":"","sources":["../../src/services/TaskGraphActionRunner.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAE7G,qBAAa,qBAAsB,YAAW,gBAAgB;IAC7C,gBAAgB,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAmCxF;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,WAAW;IAQnB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,WAAW;CAUtB"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * @fileoverview MJServer's implementation of the task-graph `TaskActionRunner` seam.
3
+ *
4
+ * The counterpart to {@link TaskGraphAgentRunner}: the dispatcher knows *when* an action-assigned
5
+ * node should run and nothing about how an action executes, so execution is injected. Keeping it
6
+ * here rather than in `@memberjunction/task-graph` is not tidiness — the action engine depends on
7
+ * the entity layer the dispatcher also builds on, and importing it there would make every consumer
8
+ * of durable execution load the action engine as well.
9
+ *
10
+ * @module @memberjunction/server
11
+ */
12
+ import { ActionEngineServer } from '@memberjunction/actions';
13
+ import { LogError } from '@memberjunction/core';
14
+ import { UUIDsEqual } from '@memberjunction/global';
15
+ export class TaskGraphActionRunner {
16
+ async RunActionForTask(params) {
17
+ try {
18
+ await ActionEngineServer.Instance.Config(false, params.ContextUser);
19
+ const action = ActionEngineServer.Instance.Actions.find((a) => UUIDsEqual(a.ID, params.ActionID));
20
+ if (!action) {
21
+ return { Success: false, ErrorMessage: `Action ${params.ActionID} is not in the engine's metadata.` };
22
+ }
23
+ const result = await ActionEngineServer.Instance.RunAction({
24
+ Action: action,
25
+ ContextUser: params.ContextUser,
26
+ Params: this.buildParams(params),
27
+ // No Filters. A durable node is work that a filter ALREADY let through — the entity
28
+ // action's gate ran at dispatch time, on the change context that no longer exists by
29
+ // the time the dispatcher picks the task up. Re-evaluating here would ask a
30
+ // transition question with nothing to answer it, and fail closed on every retry.
31
+ Filters: [],
32
+ });
33
+ return {
34
+ Success: result.Success,
35
+ Output: this.buildOutput(result.Params),
36
+ ErrorMessage: result.Success ? undefined : result.Message,
37
+ // The engine already wrote the log; this is the only place its id is in hand. Without
38
+ // carrying it out, a workflow's action step has no path back to its own execution
39
+ // record — the one thing anyone wants when an action misbehaves.
40
+ ActionLogID: result.LogEntry?.ID,
41
+ };
42
+ }
43
+ catch (e) {
44
+ const message = e instanceof Error ? e.message : String(e);
45
+ LogError(`[TaskGraphActionRunner] Task ${params.TaskID} failed: ${message}`);
46
+ return { Success: false, ErrorMessage: message };
47
+ }
48
+ }
49
+ /**
50
+ * Projects the action's parameters onto the flat result a workflow step is expected to produce.
51
+ *
52
+ * **Why not return `result.Params` as-is.** That is an `ActionParam[]`, and every consumer of a
53
+ * step's output addresses fields BY NAME: an output mapping says `{"CurrentPrice": "stockPrice"}`,
54
+ * and a branch condition then reads `payload.stockPrice`. Handed an array, the mapping finds no
55
+ * `CurrentPrice`, writes nothing, and the condition evaluates against `undefined` — which is
56
+ * falsy rather than erroneous, so the workflow takes the other branch and reports success. That
57
+ * is exactly what the Demo workflow did: step 1 completed with an output payload of `{}` and
58
+ * every downstream branch was skipped, with nothing anywhere reporting a problem.
59
+ *
60
+ * Only `Output` and `Both` params are included. Echoing the inputs back would let a step's own
61
+ * parameters masquerade as its results, so an output mapping could "succeed" by reading the
62
+ * value the step was given rather than the one it produced.
63
+ */
64
+ buildOutput(actionParams) {
65
+ const output = {};
66
+ for (const p of actionParams ?? []) {
67
+ if (p.Type === 'Output' || p.Type === 'Both')
68
+ output[p.Name] = p.Value;
69
+ }
70
+ return output;
71
+ }
72
+ /**
73
+ * Rebuilds the action's parameters from the task's stored payload.
74
+ *
75
+ * **The values here have been through redaction**, because `Task.InputPayload` is persistent,
76
+ * user-visible storage and nothing writes a raw `ActionParam[]` there. A parameter the binding
77
+ * marked as not-logged therefore arrives absent rather than secret — the action sees a missing
78
+ * value, which is the honest consequence of choosing not to persist it, and the reason durable
79
+ * dispatch is opt-in per binding rather than the default.
80
+ *
81
+ * Dependency outputs are merged underneath the task's own input so a node's explicit parameters
82
+ * always win over an upstream node that happened to emit the same key.
83
+ */
84
+ buildParams(params) {
85
+ const merged = {};
86
+ for (const [name, value] of params.DependencyOutputs) {
87
+ merged[name] = value;
88
+ }
89
+ if (params.InputPayload && typeof params.InputPayload === 'object') {
90
+ Object.assign(merged, params.InputPayload);
91
+ }
92
+ return Object.entries(merged).map(([Name, Value]) => ({ Name, Value, Type: 'Input' }));
93
+ }
94
+ }
95
+ //# sourceMappingURL=TaskGraphActionRunner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TaskGraphActionRunner.js","sourceRoot":"","sources":["../../src/services/TaskGraphActionRunner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBA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AI,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IAC3F,CAAC;CACJ"}
@@ -0,0 +1,28 @@
1
+ import type { TaskAgentRunner, TaskAgentRunParams, TaskAgentRunResult } from '@memberjunction/task-graph';
2
+ export declare class TaskGraphAgentRunner implements TaskAgentRunner {
3
+ RunAgentForTask(params: TaskAgentRunParams): Promise<TaskAgentRunResult>;
4
+ /**
5
+ * The run that submitted this graph, as the entity `RunAgent` wants for `parentRun`.
6
+ *
7
+ * **Why this link is worth a load.** It sets `ParentRunID` on the spawned run, which turns a
8
+ * workflow's total cost into one indexed sum over `RootParentRunID` rather than a walk of the
9
+ * graph, and gives the run a "started by" trail someone can follow back. Without it every
10
+ * dispatched run looks like it began from nowhere.
11
+ *
12
+ * Undefined — never a throw — when there is no submitting run or it cannot be read. A graph
13
+ * submitted by a schedule, by MCP, or by a person genuinely has no parent run, and failing the
14
+ * step because its provenance is unavailable would trade real work for a bookkeeping detail.
15
+ */
16
+ private loadSubmittingRun;
17
+ /**
18
+ * Builds the agent's instruction from the task's own input plus its dependencies' outputs.
19
+ *
20
+ * Dependency outputs are included inline because a task's whole reason for depending on another
21
+ * is to consume what it produced. They are rendered as labelled JSON rather than prose so the
22
+ * agent can parse them reliably rather than inferring structure from formatting.
23
+ */
24
+ private buildPrompt;
25
+ /** Prefers a structured payload over prose, so downstream tasks get data rather than text. */
26
+ private extractOutput;
27
+ }
28
+ //# sourceMappingURL=TaskGraphAgentRunner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TaskGraphAgentRunner.d.ts","sourceRoot":"","sources":["../../src/services/TaskGraphAgentRunner.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAE1G,qBAAa,oBAAqB,YAAW,eAAe;IAC3C,eAAe,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA+BrF;;;;;;;;;;;OAWG;YACW,iBAAiB;IAkB/B;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAmBnB,8FAA8F;IAC9F,OAAO,CAAC,aAAa;CAKxB"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * @fileoverview MJServer's implementation of the task-graph `TaskAgentRunner` seam.
3
+ *
4
+ * The dispatcher knows *when* a task should run and *what* it depends on, but nothing about how an
5
+ * agent executes. That is injected, so the package stays testable without standing up the agent
6
+ * framework and so a host with a different execution strategy (a queue, a remote worker) can
7
+ * substitute its own.
8
+ *
9
+ * This adapter is the thin translation between the two: it turns a task's input payload and its
10
+ * dependencies' outputs into agent messages, runs the agent, and maps the result back into the
11
+ * shape the dispatcher persists.
12
+ *
13
+ * @module @memberjunction/server
14
+ */
15
+ import { AgentRunner } from '@memberjunction/ai-agents';
16
+ import { ChatMessageRole } from '@memberjunction/ai';
17
+ import { LogError } from '@memberjunction/core';
18
+ export class TaskGraphAgentRunner {
19
+ async RunAgentForTask(params) {
20
+ try {
21
+ const agent = await params.Provider.GetEntityObject('MJ: AI Agents', params.ContextUser);
22
+ if (!(await agent.Load(params.AgentID))) {
23
+ return { Success: false, ErrorMessage: `Agent ${params.AgentID} could not be loaded.` };
24
+ }
25
+ const result = await new AgentRunner().RunAgent({
26
+ agent,
27
+ conversationMessages: [{ role: ChatMessageRole.user, content: this.buildPrompt(params) }],
28
+ contextUser: params.ContextUser,
29
+ // Inherited from the graph, so a graph this run goes on to emit is one hop deeper
30
+ // rather than starting the chain over. Without it MAX_REINVOKE_DEPTH never fires.
31
+ continuationDepth: params.ContinuationDepth ?? 0,
32
+ parentRun: await this.loadSubmittingRun(params),
33
+ });
34
+ const success = result?.success === true;
35
+ return {
36
+ Success: success,
37
+ Output: this.extractOutput(result),
38
+ ErrorMessage: success ? undefined : (result?.agentRun?.ErrorMessage ?? 'Agent execution failed'),
39
+ AgentRunID: result?.agentRun?.ID,
40
+ };
41
+ }
42
+ catch (e) {
43
+ const message = e instanceof Error ? e.message : String(e);
44
+ LogError(`[TaskGraphAgentRunner] Task ${params.TaskID} failed: ${message}`);
45
+ return { Success: false, ErrorMessage: message };
46
+ }
47
+ }
48
+ /**
49
+ * The run that submitted this graph, as the entity `RunAgent` wants for `parentRun`.
50
+ *
51
+ * **Why this link is worth a load.** It sets `ParentRunID` on the spawned run, which turns a
52
+ * workflow's total cost into one indexed sum over `RootParentRunID` rather than a walk of the
53
+ * graph, and gives the run a "started by" trail someone can follow back. Without it every
54
+ * dispatched run looks like it began from nowhere.
55
+ *
56
+ * Undefined — never a throw — when there is no submitting run or it cannot be read. A graph
57
+ * submitted by a schedule, by MCP, or by a person genuinely has no parent run, and failing the
58
+ * step because its provenance is unavailable would trade real work for a bookkeeping detail.
59
+ */
60
+ async loadSubmittingRun(params) {
61
+ if (!params.SubmittingAgentRunID)
62
+ return undefined;
63
+ try {
64
+ const run = await params.Provider.GetEntityObject('MJ: AI Agent Runs', params.ContextUser);
65
+ return (await run.Load(params.SubmittingAgentRunID)) ? run : undefined;
66
+ }
67
+ catch (e) {
68
+ LogError(`[TaskGraphAgentRunner] Task ${params.TaskID}: submitting run ` +
69
+ `${params.SubmittingAgentRunID} could not be loaded; the spawned run will have no ` +
70
+ `parent link. ${e instanceof Error ? e.message : String(e)}`);
71
+ return undefined;
72
+ }
73
+ }
74
+ /**
75
+ * Builds the agent's instruction from the task's own input plus its dependencies' outputs.
76
+ *
77
+ * Dependency outputs are included inline because a task's whole reason for depending on another
78
+ * is to consume what it produced. They are rendered as labelled JSON rather than prose so the
79
+ * agent can parse them reliably rather than inferring structure from formatting.
80
+ */
81
+ buildPrompt(params) {
82
+ const sections = [];
83
+ if (params.InputPayload != null) {
84
+ sections.push(`## Task input\n\`\`\`json\n${JSON.stringify(params.InputPayload, null, 2)}\n\`\`\``);
85
+ }
86
+ if (params.DependencyOutputs.size > 0) {
87
+ const rendered = [...params.DependencyOutputs.entries()]
88
+ .map(([taskID, output]) => `### Output of task ${taskID}\n\`\`\`json\n${JSON.stringify(output, null, 2)}\n\`\`\``)
89
+ .join('\n\n');
90
+ sections.push(`## Results from prerequisite tasks\n\n${rendered}`);
91
+ }
92
+ return sections.length > 0
93
+ ? sections.join('\n\n')
94
+ : 'Execute this task.';
95
+ }
96
+ /** Prefers a structured payload over prose, so downstream tasks get data rather than text. */
97
+ extractOutput(result) {
98
+ const r = result;
99
+ if (r?.payload != null)
100
+ return r.payload;
101
+ return r?.agentRun?.Message ?? null;
102
+ }
103
+ }
104
+ //# sourceMappingURL=TaskGraphAgentRunner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TaskGraphAgentRunner.js","sourceRoot":"","sources":["../../src/services/TaskGraphAgentRunner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIhD,MAAM,OAAO,oBAAoB;IACtB,KAAK,CAAC,eAAe,CAAC,MAA0B;QACnD,IAAI,CAAC;YACD,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,eAAe,CAA0B,eAAe,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;YAClH,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;gBACtC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,MAAM,CAAC,OAAO,uBAAuB,EAAE,CAAC;YAC5F,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,IAAI,WAAW,EAAE,CAAC,QAAQ,CAAC;gBAC5C,KAAK;gBACL,oBAAoB,EAAE,CAAC,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC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C;IAED,8FAA8F;IACtF,aAAa,CAAC,MAAe;QACjC,MAAM,CAAC,GAAG,MAAuE,CAAC;QAClF,IAAI,CAAC,EAAE,OAAO,IAAI,IAAI;YAAE,OAAO,CAAC,CAAC,OAAO,CAAC;QACzC,OAAO,CAAC,EAAE,QAAQ,EAAE,OAAO,IAAI,IAAI,CAAC;IACxC,CAAC;CACJ"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * @fileoverview MJServer's implementation of the task-graph `TaskContinuationDeliverer` seam.
3
+ *
4
+ * **The dispatcher shipped with nowhere to deliver.** `StartTaskGraphDispatcher` constructed it
5
+ * without a deliverer at all, so a graph that finished logged its outcome, marked itself delivered,
6
+ * and said nothing to the conversation that asked for it. Durable execution nobody hears about is
7
+ * half a promise — the same shape as Phase 2's dispatcher that ran nothing.
8
+ *
9
+ * Posting into a conversation is a host concern by design: the task-graph package must not depend on
10
+ * the conversation layer, and cannot depend on the agent framework at all without a cycle (agents
11
+ * submit graphs). This adapter is where those dependencies are allowed to live.
12
+ *
13
+ * @module @memberjunction/server
14
+ */
15
+ import { type UserInfo } from '@memberjunction/core';
16
+ import type { ProviderFactory, TaskContinuationDeliverer, TaskContinuationParams } from '@memberjunction/task-graph';
17
+ /**
18
+ * Delivers a finished graph's outcome — as a conversation message, or by starting the submitting
19
+ * agent a fresh turn.
20
+ *
21
+ * **The chain is bounded, and that is what took a schema change to make true.** A graph may declare
22
+ * `continuation: 'reinvoke'`, and the agent it restarts can emit another graph, which can reinvoke
23
+ * again. The guard for that (`MAX_REINVOKE_DEPTH`) shipped in Phase 3, but the number it compared
24
+ * was permanently zero: `TaskGraphService.Submit` reads `ReinvokeDepth` from its caller, and a
25
+ * reinvoked agent had no way to know it *was* a continuation. `AIAgentRun.ContinuationDepth` closes
26
+ * that loop — this stamps depth + 1 on the run it starts, `BaseAgent` passes it into any graph that
27
+ * run submits, and the cap finally compares against something real.
28
+ */
29
+ export declare class TaskGraphContinuationDeliverer implements TaskContinuationDeliverer {
30
+ private readonly providerFactory;
31
+ private readonly contextUser;
32
+ /**
33
+ * @param providerFactory mints a fresh provider per delivery, for the same reason the dispatcher
34
+ * does: deliveries run outside any request and concurrently with task execution, so
35
+ * sharing one provider would share one transaction scope across unrelated work.
36
+ */
37
+ constructor(providerFactory: ProviderFactory, contextUser: UserInfo);
38
+ /**
39
+ * Posts the roll-up as an AI-role message in the graph's conversation.
40
+ *
41
+ * Never throws. The dispatcher calls this inside the compare-and-swap that marks a completion
42
+ * delivered; an error escaping would either abort that guard or leave the graph looking
43
+ * undelivered and re-notifying on every later sweep.
44
+ */
45
+ PostMessage(params: TaskContinuationParams): Promise<void>;
46
+ /**
47
+ * Starts the submitting agent a fresh turn carrying the graph's outcome.
48
+ *
49
+ * Never throws, for the same reason `PostMessage` does not: the dispatcher calls this inside the
50
+ * compare-and-swap that marks a completion delivered.
51
+ *
52
+ * The new run records `ReinvokeDepth + 1` so the chain is bounded. The dispatcher has already
53
+ * refused to call this when the cap is reached — it degrades to `PostMessage` — so arriving here
54
+ * means there is budget left, and stamping the depth is what keeps that true for the next hop.
55
+ */
56
+ Reinvoke(params: TaskContinuationParams): Promise<void>;
57
+ /** The conversation a detail belongs to. */
58
+ private resolveConversationID;
59
+ /**
60
+ * Renders the outcome as Markdown.
61
+ *
62
+ * Per-task lines rather than one aggregate status: a graph where nine of ten steps succeeded is a
63
+ * materially different message from one that failed outright, and the roll-up alone cannot say
64
+ * which step went wrong. Long graphs truncate so a fifty-step workflow does not bury the
65
+ * conversation — the task rows remain the complete record.
66
+ */
67
+ private renderMessage;
68
+ private statusIcon;
69
+ }
70
+ //# sourceMappingURL=TaskGraphContinuationDeliverer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TaskGraphContinuationDeliverer.d.ts","sourceRoot":"","sources":["../../src/services/TaskGraphContinuationDeliverer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAA+C,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAKlG,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAKrH;;;;;;;;;;;GAWG;AACH,qBAAa,8BAA+B,YAAW,yBAAyB;IAOxE,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,WAAW;IAPhC;;;;OAIG;gBAEkB,eAAe,EAAE,eAAe,EAChC,WAAW,EAAE,QAAQ;IAG1C;;;;;;OAMG;IACU,WAAW,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAsCvE;;;;;;;;;OASG;IACU,QAAQ,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAuCpE,4CAA4C;YAC9B,qBAAqB;IAKnC;;;;;;;OAOG;IACH,OAAO,CAAC,aAAa;IAiBrB,OAAO,CAAC,UAAU;CAQrB"}