@makaio/framework 1.0.0-dev-1783355411417 → 1.0.0-dev-1783477169057

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 (153) hide show
  1. package/dist/.makaio-build.json +2 -2
  2. package/dist/adapter-Lx6K7yQS.mjs +1 -0
  3. package/dist/adapter-subsystem/index.mjs +1 -1
  4. package/dist/adapters/config/index.d.mts +1 -1
  5. package/dist/adapters/index.d.mts +219 -40
  6. package/dist/adapters/index.mjs +6 -6
  7. package/dist/adapters/node.d.mts +1 -1
  8. package/dist/adapters/node.mjs +4 -4
  9. package/dist/{base-orchestrator-BNysGvaM.d.mts → base-orchestrator-J1WKAUkF.d.mts} +32 -3
  10. package/dist/bus/index.d.mts +22 -22
  11. package/dist/bus/index.mjs +1 -1
  12. package/dist/client-l1Rq5p6X.mjs +1 -0
  13. package/dist/clients/index.d.mts +30 -0
  14. package/dist/clients/index.mjs +2 -2
  15. package/dist/contracts/adapter/index.d.mts +2 -2
  16. package/dist/contracts/adapter/index.mjs +1 -1
  17. package/dist/contracts/adapter/schemas/session-lineage.d.mts +1 -1
  18. package/dist/contracts/adapter/schemas/session-lineage.mjs +1 -1
  19. package/dist/contracts/artifact/index.d.mts +1 -1
  20. package/dist/contracts/canonical-model/index.d.mts +1 -1
  21. package/dist/contracts/client/index.d.mts +2 -2
  22. package/dist/contracts/client/index.mjs +1 -1
  23. package/dist/contracts/config/index.d.mts +12 -12
  24. package/dist/contracts/extension/index.d.mts +3 -3
  25. package/dist/contracts/facet/index.d.mts +1 -1
  26. package/dist/contracts/harness/index.d.mts +1 -1
  27. package/dist/contracts/index.d.mts +454 -276
  28. package/dist/contracts/index.mjs +1 -1
  29. package/dist/contracts/materialization/index.d.mts +3 -3
  30. package/dist/contracts/provider/index.d.mts +1 -1
  31. package/dist/contracts/session/index.d.mts +3 -3
  32. package/dist/contracts/session/index.mjs +1 -1
  33. package/dist/contracts/shared/index.d.mts +1 -1
  34. package/dist/contracts/skill/index.d.mts +1 -1
  35. package/dist/contracts/variant/index.d.mts +1 -1
  36. package/dist/contracts/workflow/index.d.mts +2 -2
  37. package/dist/{definition-b9jyJqPD.d.mts → definition-DePb3ke-.d.mts} +1 -1
  38. package/dist/drizzle/0023_m_mr9gc37m.sql +1 -0
  39. package/dist/drizzle/meta/_journal.json +7 -0
  40. package/dist/handlers-B74FvKlA.mjs +57 -0
  41. package/dist/hooks/index.d.mts +19 -2
  42. package/dist/{identity-BarL3JYI.mjs → identity-DC3Pk0ps.mjs} +1 -1
  43. package/dist/{index-BwGfdbI0.d.mts → index-2fK9iSHI.d.mts} +9 -9
  44. package/dist/{index-D7rWAEY0.d.mts → index-B-6DtLLz.d.mts} +1 -1
  45. package/dist/{index-4eP9DRL_.d.mts → index-B3fjN5HX.d.mts} +7 -7
  46. package/dist/{index-O08Q2ikz.d.mts → index-BMbmoarE.d.mts} +8 -8
  47. package/dist/{index-DV4nRk0h.d.mts → index-BX1MxwFr.d.mts} +28 -28
  48. package/dist/{index-CqCe7Phc.d.mts → index-BcwOnvUh.d.mts} +6 -6
  49. package/dist/{index-D6aAzr32.d.mts → index-BeouVICp.d.mts} +36 -36
  50. package/dist/{index-DQYj8-53.d.mts → index-BjO4Zkap.d.mts} +1 -1
  51. package/dist/{index-B5w-0Gg9.d.mts → index-Bl42SCEI.d.mts} +8 -8
  52. package/dist/{index-BYfSAJRC.d.mts → index-BvTd61i5.d.mts} +151 -29
  53. package/dist/{index-3X0368CL.d.mts → index-CA-AJbq6.d.mts} +4 -4
  54. package/dist/{index-C5C1tk9f.d.mts → index-CQQcnpev.d.mts} +41 -41
  55. package/dist/{index-BKZhnb2B.d.mts → index-C_xQM96Y.d.mts} +802 -422
  56. package/dist/{index-31vR1sxk.d.mts → index-CwFSL4xI.d.mts} +144 -21
  57. package/dist/{index-WHUV7neB.d.mts → index-DMz-2ACU.d.mts} +105 -105
  58. package/dist/{index-3J0HZlPH.d.mts → index-DScUb-hF.d.mts} +334 -13
  59. package/dist/{index-DEzdNQum.d.mts → index-Di84JjS0.d.mts} +2 -2
  60. package/dist/{index-DvHYpi-J.d.mts → index-Dv4oGVZK.d.mts} +1246 -397
  61. package/dist/{index-CaerrEDH.d.mts → index-NkNbYFud.d.mts} +1 -1
  62. package/dist/{index-D9-vOJvZ.d.mts → index-h5go5Dtd.d.mts} +1 -1
  63. package/dist/{index-DLNRgZPo2.d.mts → index-j_X5xefv2.d.mts} +26 -26
  64. package/dist/{index-C6Ys8pxt.d.mts → index-uM4KZopE.d.mts} +9 -9
  65. package/dist/kernel/extension/index.d.mts +1 -1
  66. package/dist/kernel/index.d.mts +2 -2
  67. package/dist/kernel/observability/index.d.mts +1 -1
  68. package/dist/{namespace-j7vFsmYL.d.mts → namespace-3yGm4WF9.d.mts} +2 -2
  69. package/dist/{namespace-D8P8Sxce2.d.mts → namespace-6sIu5nBI2.d.mts} +2 -2
  70. package/dist/{namespace-B3ol3pc-.d.mts → namespace-BigVYQyx.d.mts} +12 -0
  71. package/dist/{namespace-DmqoDDRD.d.mts → namespace-Boh42UoL.d.mts} +66 -22
  72. package/dist/{namespace-CfvtDD_U.d.mts → namespace-COEUMuHL.d.mts} +156 -156
  73. package/dist/{namespace-B4cV_pk3.d.mts → namespace-D94HrTtq.d.mts} +58 -58
  74. package/dist/{namespace-DhDY0juT.d.mts → namespace-OLAh9wHU.d.mts} +375 -27
  75. package/dist/{namespace-Bm77p82L.d.mts → namespace-TPbegIMi.d.mts} +27 -27
  76. package/dist/{package-MmQvNJ3u.d.mts → package-B6mEMD8r.d.mts} +5 -0
  77. package/dist/{package-BmRhhi-3.mjs → package-BQn_RTo7.mjs} +1 -1
  78. package/dist/package.json +1 -1
  79. package/dist/{schema-DLNBajAV.d.mts → schema-B5vHi7Uu.d.mts} +28 -1
  80. package/dist/{schemas-CoFCV42v.d.mts → schemas-CDBn9MTz.d.mts} +156 -156
  81. package/dist/schemas-CkOigLAT.mjs +1 -0
  82. package/dist/{schemas-lnE9YoG7.d.mts → schemas-CscdPqCt.d.mts} +3 -3
  83. package/dist/{schemas-DMMWmWjq.d.mts → schemas-D512XweP.d.mts} +4 -4
  84. package/dist/{schemas-DuuVuhHX2.d.mts → schemas-DOV4UouN2.d.mts} +13 -13
  85. package/dist/{schemas-DmGRSeIq.d.mts → schemas-t6h9oSct.d.mts} +28 -1
  86. package/dist/services/adapter-runtime/index.d.mts +4 -4
  87. package/dist/services/adapter-runtime/index.mjs +1 -1
  88. package/dist/services/adapter-runtime/namespace.d.mts +1 -1
  89. package/dist/services/adapter-runtime/schemas.d.mts +2 -2
  90. package/dist/services/adapter-runtime/schemas.mjs +1 -1
  91. package/dist/services/adapter-subsystem/index.d.mts +2 -2
  92. package/dist/services/adapter-subsystem/namespace.d.mts +1 -1
  93. package/dist/services/agent-runtime/index.d.mts +2 -2
  94. package/dist/services/agent-runtime/namespace.d.mts +1 -1
  95. package/dist/services/agent-runtime/schemas.d.mts +1 -1
  96. package/dist/services/context-rules/index.d.mts +8 -8
  97. package/dist/services/execution-target/index.d.mts +1 -1
  98. package/dist/services/filesystem/namespace.d.mts +12 -12
  99. package/dist/services/filesystem/schemas.d.mts +6 -6
  100. package/dist/services/git/namespace.d.mts +2 -2
  101. package/dist/services/git/schemas.d.mts +1 -1
  102. package/dist/services/harness/index.d.mts +3 -3
  103. package/dist/services/index.d.mts +147 -140
  104. package/dist/services/index.mjs +1 -1
  105. package/dist/services/log-import/browser.d.mts +2 -2
  106. package/dist/services/log-import/index.d.mts +15 -2
  107. package/dist/services/log-import/index.mjs +2 -2
  108. package/dist/services/log-import/log-import.d.mts +1 -1
  109. package/dist/services/log-import/namespace.d.mts +2 -2
  110. package/dist/services/log-import/schemas.d.mts +1 -1
  111. package/dist/services/session/handlers/index.d.mts +1 -1
  112. package/dist/services/session/handlers/index.mjs +1 -1
  113. package/dist/services/session/index.d.mts +7 -7
  114. package/dist/services/session/index.mjs +1 -1
  115. package/dist/services/session/messages/namespace.d.mts +1 -1
  116. package/dist/services/session/session-events/namespace.d.mts +1 -1
  117. package/dist/services/session/storage/namespace.d.mts +1 -1
  118. package/dist/services/session/storage/schema.d.mts +1 -1
  119. package/dist/services/session/storage/schema.mjs +1 -1
  120. package/dist/services/session/testing/index.mjs +3 -2
  121. package/dist/services/session-editor/index.d.mts +1 -1
  122. package/dist/services/settings/namespace.d.mts +10 -10
  123. package/dist/services/settings/storage/extension-configs/namespace.d.mts +3 -3
  124. package/dist/services/subagent-template/index.d.mts +2 -2
  125. package/dist/services/subagent-template/namespace.d.mts +1 -1
  126. package/dist/services/subagent-template/schemas.d.mts +1 -1
  127. package/dist/services/tool-approval/index.mjs +1 -1
  128. package/dist/services/tools/index.mjs +1 -1
  129. package/dist/services/tray-menu/index.d.mts +2 -2
  130. package/dist/services/tray-menu/namespace.d.mts +1 -1
  131. package/dist/services/tray-menu/schemas.d.mts +1 -1
  132. package/dist/session-CoGaTin6.mjs +69 -0
  133. package/dist/session-Dp7z5N1d.mjs +1 -0
  134. package/dist/{session-lineage-DR-9DU-U.d.mts → session-lineage-C1M7-O3C.d.mts} +3 -3
  135. package/dist/{tool-approval-service-MU_DmJsf.mjs → tool-approval-service-BNXgr-az.mjs} +1 -1
  136. package/dist/tools-BaO4GYj0.mjs +1 -0
  137. package/dist/{transition-Dq41YCkc.d.mts → transition-Bbjlwv5K.d.mts} +1 -1
  138. package/dist/{types-BMS6yfLS.d.mts → types-BNW5n6qm.d.mts} +1 -1
  139. package/dist/{types-BMlzmWp6.d.mts → types-CNkx2awa.d.mts} +12 -1
  140. package/dist/{types-Cse8s_cD.d.mts → types-D7W0ntGr.d.mts} +45 -18
  141. package/dist/{types-C76EP81O.d.mts → types-jruUn6oW.d.mts} +694 -282
  142. package/dist/workflow-engine/index.d.mts +41 -41
  143. package/dist/workflow-engine/index.mjs +1 -1
  144. package/dist/workflow-engine/package.d.mts +1 -1
  145. package/dist/workflow-engine/package.mjs +1 -1
  146. package/package.json +1 -1
  147. package/dist/adapter-BRxCc72E.mjs +0 -1
  148. package/dist/client-BgUjVbXX.mjs +0 -1
  149. package/dist/handlers-v47Gbsr1.mjs +0 -57
  150. package/dist/schemas-ftgVeWIG.mjs +0 -1
  151. package/dist/session-CKWfn3oc.mjs +0 -1
  152. package/dist/session-DCbJwYEU.mjs +0 -69
  153. package/dist/tools-BrNm-een.mjs +0 -1
@@ -87,6 +87,8 @@ declare class Turn$1 {
87
87
  private readonly _agentIds;
88
88
  /** Messages sent during this turn */
89
89
  private readonly _messageIds;
90
+ /** Message IDs currently claiming this turn while their storage append is in-flight. */
91
+ private readonly _pendingMessageAppends;
90
92
  /** Agents that have completed successfully */
91
93
  private readonly _completedAgents;
92
94
  /** Agents that errored (agentId → error message) */
@@ -108,6 +110,11 @@ declare class Turn$1 {
108
110
  * @returns Immutable array of message IDs
109
111
  */
110
112
  get messageIds(): readonly string[];
113
+ /**
114
+ * Whether a user message has claimed this turn before its storage append completes.
115
+ * @returns True when at least one message append is in-flight
116
+ */
117
+ get hasPendingMessageAppends(): boolean;
111
118
  /**
112
119
  * Agents that have completed successfully.
113
120
  * @returns Read-only set of completed agent IDs
@@ -123,6 +130,16 @@ declare class Turn$1 {
123
130
  * @param messageId - The message ID to add
124
131
  */
125
132
  addMessage(messageId: string): void;
133
+ /**
134
+ * Claim this turn for a message whose durable append has started.
135
+ * @param messageId - Message ID whose append is in-flight
136
+ */
137
+ claimMessageAppend(messageId: string): void;
138
+ /**
139
+ * Release a failed message append claim without adding the message.
140
+ * @param messageId - Message ID whose append failed
141
+ */
142
+ releaseMessageAppend(messageId: string): void;
126
143
  /**
127
144
  * Mark an agent as completed successfully.
128
145
  * @param agentId - The agent that completed
@@ -165,6 +182,12 @@ declare class Turn$1 {
165
182
  * @returns Turn context with turnId and the specified messageId
166
183
  */
167
184
  getContextForMessage(messageId: string): TurnContext;
185
+ /**
186
+ * Return the recorded terminal outcome for an agent, if any.
187
+ * @param agentId - Agent ID to inspect.
188
+ * @returns Terminal outcome already recorded for the agent.
189
+ */
190
+ private getAgentTerminalOutcome;
168
191
  /**
169
192
  * Check if turn should complete and return appropriate state change.
170
193
  * @returns State change indicating completion status and result if complete
@@ -216,10 +239,14 @@ declare class SessionTurnManager {
216
239
  private readonly bus;
217
240
  /** Active turns keyed by sessionId (one turn per session). */
218
241
  private readonly activeTurns;
219
- /** Per-session usage accumulators, parallel to activeTurns. */
242
+ /** Per-turn usage accumulators, keyed by turnId. */
220
243
  private readonly usageAccumulators;
221
- /** Sessions currently persisting turn completion (prevents concurrent writes). */
222
- private readonly completingSessions;
244
+ /** Turns currently persisting completion (prevents concurrent writes). */
245
+ private readonly completingTurnIds;
246
+ /** Completing turns retained for usage correlation after active routing is cleared. */
247
+ private readonly completingTurns;
248
+ /** Pending terminal completions keyed by turnId; value records whether turn storage handled the transition. */
249
+ private readonly pendingTerminalCompletions;
223
250
  /** Usage events received while completion persistence is in-flight. */
224
251
  private readonly bufferedUsageDuringCompletion;
225
252
  /**
@@ -265,12 +292,25 @@ declare class SessionTurnManager {
265
292
  /**
266
293
  * Discard active in-memory state for a turn that failed before routing began.
267
294
  *
268
- * The storage contract has no turn-delete operation, so this only rolls back
269
- * the active manager state that would otherwise make the next user message
270
- * reuse a turn whose first message was never persisted.
295
+ * Use when no durable turn row needs a terminal status transition.
271
296
  * @param turn - Newly created active turn to discard
272
297
  */
273
298
  discardActiveTurn(turn: Turn$1): void;
299
+ /**
300
+ * Mark an unclaimed newly created turn as failed and discard its active in-memory state.
301
+ *
302
+ * This preserves the durable turn lifecycle invariant when setup fails after
303
+ * `storage:turn.create` has already assigned a turn number.
304
+ * @param turn - Newly created active turn whose setup failed before any message claimed it
305
+ * @param error - Durable error code to store on the terminal turn
306
+ */
307
+ failActiveTurnSetup(turn: Turn$1, error: string): Promise<void>;
308
+ /**
309
+ * Remove a turn from the active routing index when it is no longer routable.
310
+ * @param turn - Turn to remove when it still owns the session slot
311
+ * @returns Whether the turn owned and cleared the active routing slot
312
+ */
313
+ private clearActiveRoutingTurn;
274
314
  /**
275
315
  * Register bus listeners for `agent.usage` and `agent.complete` events.
276
316
  *
@@ -301,6 +341,12 @@ declare class SessionTurnManager {
301
341
  * @param result - Turn result (success status and error messages)
302
342
  */
303
343
  completeTurn(turn: Turn$1, result: TurnCompletionResult): Promise<void>;
344
+ /**
345
+ * Clear in-memory state retained only while a turn completion is in progress.
346
+ * @param turn - Turn whose completion state should be removed
347
+ * @param usageAccumulator - Optional accumulator retained for late usage merges
348
+ */
349
+ private clearCompletionState;
304
350
  /**
305
351
  * Get the active turn for a session, if any.
306
352
  * @param sessionId - Session identifier
@@ -340,14 +386,58 @@ declare class SessionTurnManager {
340
386
  * @param success - Whether the agent completed successfully
341
387
  * @param error - Error message if the agent failed
342
388
  * @param onTurnComplete - Callback to invoke when the turn is complete
389
+ * @param completionTurnId - Turn identifier supplied by the adapter completion event
343
390
  */
344
391
  private handleAgentCompletion;
345
392
  /**
346
393
  * Buffer a usage event that arrived while turn completion persistence is in-flight.
347
- * @param sessionId - Session whose turn is currently completing
394
+ * @param turnId - Turn whose completion is currently being persisted
348
395
  * @param usageEvent - Usage event to defer until after persistence
349
396
  */
350
397
  private bufferUsageDuringCompletion;
398
+ /**
399
+ * Find a turn that may still accept usage by turnId.
400
+ * @param turnId - Turn identifier from an agent usage event
401
+ * @returns Active or completing turn, if usage can still be recorded
402
+ */
403
+ private findTurnForUsage;
404
+ /**
405
+ * Find a turn that may still accept agent completion by turnId.
406
+ * @param turnId - Turn identifier from an agent completion event
407
+ * @returns Active or completing turn, if completion can still be correlated
408
+ */
409
+ private findTurnForCompletion;
410
+ /**
411
+ * Find the active turn for a legacy completion event without turnId.
412
+ * @param agentId - Agent ID from the completion event.
413
+ * @returns Active turn to mutate, or undefined when the event is ambiguous.
414
+ */
415
+ private findTurnForUncorrelatedCompletion;
416
+ /**
417
+ * Check whether a terminal outcome has already been recorded for an agent.
418
+ * @param turn - Turn being completed.
419
+ * @param agentId - Agent ID from the terminal event.
420
+ * @returns Whether the agent already has a terminal outcome on the turn.
421
+ */
422
+ private hasTerminalOutcome;
423
+ /**
424
+ * Persist a turn's terminal status and optional usage snapshot.
425
+ * @param turn - Turn being completed
426
+ * @param result - Completion result to persist
427
+ * @param usage - Usage snapshot to include, when available
428
+ * @param expectedStatus - Optional status guard for the first terminal transition
429
+ * @returns Whether turn storage handled the request and terminalized the turn
430
+ */
431
+ private persistTurnCompletion;
432
+ /**
433
+ * Merge buffered usage and persist the updated snapshot.
434
+ * @param turn - Turn whose buffered usage should be merged
435
+ * @param result - Completion result for the turn
436
+ * @param usageAccumulator - Usage accumulator captured by the completing turn
437
+ * @param currentUsage - Current completed usage snapshot
438
+ * @returns Updated usage snapshot
439
+ */
440
+ private flushBufferedUsageDuringCompletion;
351
441
  /**
352
442
  * Subscribe to `storage:message.stored` and count stored assistant messages
353
443
  * per turnId, resolving any pending barrier waiter on each increment.
@@ -423,9 +513,10 @@ declare function registerCompressHandler(bus: IMakaioBus): () => void;
423
513
  * Creates a new session with parent reference. The forked session starts
424
514
  * empty - its full conversation is assembled by traversing the parent chain.
425
515
  * @param bus - Bus instance for communication
516
+ * @param machineId - Stable runtime machine identity to stamp on child sessions
426
517
  * @returns Cleanup function to unsubscribe
427
518
  */
428
- declare function registerForkHandler(bus: IMakaioBus): () => void;
519
+ declare function registerForkHandler(bus: IMakaioBus, machineId?: string): () => void;
429
520
  //#endregion
430
521
  //#region services/core/src/session/handlers/merge-handler.d.ts
431
522
  /**
@@ -449,6 +540,50 @@ interface CwdSwapMeta {
449
540
  previousCwd: string;
450
541
  newCwd: string;
451
542
  }
543
+ /**
544
+ * Options for routing a message to target agents.
545
+ */
546
+ interface RouteToAgentsOptions {
547
+ /** Bus instance for communication. */
548
+ readonly bus: IMakaioBus;
549
+ /** Session metadata (for fork detection). */
550
+ readonly session: IMakaioSession;
551
+ /** Target agents to route to. */
552
+ readonly agents: MakaioSessionAgent[];
553
+ /** Message content to send. */
554
+ readonly message: MessageInput;
555
+ /** Message identifier. */
556
+ readonly messageId: string;
557
+ /** Turn tracking object. */
558
+ readonly turn: Turn$1;
559
+ /** How to deliver the message. */
560
+ readonly deliveryMode: 'enqueue' | 'immediate' | undefined;
561
+ /** Callback when turn completes (all agents done). */
562
+ readonly onTurnComplete: (turn: Turn$1, result: {
563
+ success: boolean;
564
+ errors: string[];
565
+ }) => Promise<void>;
566
+ /** Session context with curated messageHistory and decision signals. */
567
+ readonly sessionContext?: SessionContext;
568
+ /** Optional enricher for immediate message context. */
569
+ readonly turnContextEnricher?: ITurnContextEnricher;
570
+ /** Whether this is the first message in a new turn. */
571
+ readonly isNewTurn?: boolean;
572
+ /** Context enriched with messageHistory for agents that were just recovered. */
573
+ readonly recoveryContext?: SessionContext;
574
+ /** Set of agent IDs that were recovered in this handler invocation. */
575
+ readonly recoveredAgentIds?: ReadonlySet<string>;
576
+ /** Set of agent IDs that swapped connector due to cwd mismatch. */
577
+ readonly swappedAgentIds?: ReadonlySet<string>;
578
+ /** Previous/new cwd metadata keyed by agent ID. */
579
+ readonly swappedAgentCwd?: ReadonlyMap<string, CwdSwapMeta>;
580
+ /** Curated history for agents forced into fresh mode. */
581
+ readonly freshMessageHistory?: Message[];
582
+ /** Optional structured output descriptor for the turn. */
583
+ readonly responseSchema?: ResponseSchemaDescriptor;
584
+ /** Stable machine identity of the current host process for locality evaluation. */
585
+ readonly localMachineId?: string;
586
+ }
452
587
  /**
453
588
  * Route a message to target agents via agent.sendMessage.
454
589
  *
@@ -456,28 +591,9 @@ interface CwdSwapMeta {
456
591
  * and checks for turn completion.
457
592
  *
458
593
  * For fork sessions on their first turn, assembles projected context from parent chain.
459
- * @param bus - Bus instance for communication
460
- * @param session - Session metadata (for fork detection)
461
- * @param agents - Target agents to route to
462
- * @param message - Message content to send
463
- * @param messageId - Message identifier
464
- * @param turn - Turn tracking object
465
- * @param deliveryMode - How to deliver the message
466
- * @param onTurnComplete - Callback when turn completes (all agents done)
467
- * @param sessionContext - Session context with curated messageHistory and decision signals
468
- * @param turnContextEnricher - Optional enricher for immediate message context
469
- * @param isNewTurn - Whether this is the first message in a new turn
470
- * @param recoveryContext - Context enriched with messageHistory for agents that were just recovered
471
- * @param recoveredAgentIds - Set of agent IDs that were recovered in this handler invocation
472
- * @param swappedAgentIds - Set of agent IDs that swapped connector due to cwd mismatch
473
- * @param swappedAgentCwd - Previous/new cwd metadata keyed by agent ID
474
- * @param freshMessageHistory - Curated history for agents forced into fresh mode
475
- * @param responseSchema - Optional structured output descriptor for the turn
594
+ * @param options - Routing options including bus, session, agents, message, and lifecycle dependencies
476
595
  */
477
- declare function routeToAgents(bus: IMakaioBus, session: IMakaioSession, agents: MakaioSessionAgent[], message: MessageInput, messageId: string, turn: Turn$1, deliveryMode: 'enqueue' | 'immediate' | undefined, onTurnComplete: (turn: Turn$1, result: {
478
- success: boolean;
479
- errors: string[];
480
- }) => Promise<void>, sessionContext?: SessionContext, turnContextEnricher?: ITurnContextEnricher, isNewTurn?: boolean, recoveryContext?: SessionContext, recoveredAgentIds?: ReadonlySet<string>, swappedAgentIds?: ReadonlySet<string>, swappedAgentCwd?: ReadonlyMap<string, CwdSwapMeta>, freshMessageHistory?: Message[], responseSchema?: ResponseSchemaDescriptor): Promise<void>;
596
+ declare function routeToAgents(options: RouteToAgentsOptions): Promise<void>;
481
597
  //#endregion
482
598
  //#region services/core/src/session/handlers/route-to-agents-core.d.ts
483
599
  /**
@@ -486,6 +602,12 @@ declare function routeToAgents(bus: IMakaioBus, session: IMakaioSession, agents:
486
602
  * Fans out to all agents in parallel. On routing failure, marks the agent
487
603
  * as errored and checks for turn completion. On `HookAbortError`, marks
488
604
  * the agent as completed with `cancelled` outcome.
605
+ *
606
+ * Contract: `sessionContext` must not carry a `nativeFork` directive. This
607
+ * function dispatches exclusively via `agent.sendMessage`, which never
608
+ * consumes the directive — fork directives are consumed only on the
609
+ * `startAgent` path. Callers assembling fork contexts must degrade them to
610
+ * fresh-with-history first (see `routeToAgents`).
489
611
  * @param bus - Bus instance for communication
490
612
  * @param session - Session metadata (for session ID)
491
613
  * @param agents - Target agents to route to
@@ -488,8 +488,8 @@ declare const ExtensionNamespace: _$_makaio_core0.BusNamespaceDefinition<"kernel
488
488
  extensionName: z.ZodString;
489
489
  warnings: z.ZodArray<z.ZodObject<{
490
490
  severity: z.ZodEnum<{
491
- degraded: "degraded";
492
491
  info: "info";
492
+ degraded: "degraded";
493
493
  recommended: "recommended";
494
494
  }>;
495
495
  title: z.ZodString;
@@ -528,8 +528,8 @@ declare const ExtensionNamespace: _$_makaio_core0.BusNamespaceDefinition<"kernel
528
528
  extensionName: z.ZodString;
529
529
  warnings: z.ZodArray<z.ZodObject<{
530
530
  severity: z.ZodEnum<{
531
- degraded: "degraded";
532
531
  info: "info";
532
+ degraded: "degraded";
533
533
  recommended: "recommended";
534
534
  }>;
535
535
  title: z.ZodString;
@@ -943,8 +943,8 @@ declare const ExtensionSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.Fla
943
943
  extensionName: z.ZodString;
944
944
  warnings: z.ZodArray<z.ZodObject<{
945
945
  severity: z.ZodEnum<{
946
- degraded: "degraded";
947
946
  info: "info";
947
+ degraded: "degraded";
948
948
  recommended: "recommended";
949
949
  }>;
950
950
  title: z.ZodString;
@@ -983,8 +983,8 @@ declare const ExtensionSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.Fla
983
983
  extensionName: z.ZodString;
984
984
  warnings: z.ZodArray<z.ZodObject<{
985
985
  severity: z.ZodEnum<{
986
- degraded: "degraded";
987
986
  info: "info";
987
+ degraded: "degraded";
988
988
  recommended: "recommended";
989
989
  }>;
990
990
  title: z.ZodString;