@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
@@ -1,12 +1,12 @@
1
1
  import { r as ExecutionTarget } from "./schemas-D4zaFE2p.mjs";
2
- import { d as Turn$1 } from "./index-BYfSAJRC.mjs";
3
- import { a as PipelineStep, o as SessionEditorAction, t as ActionCategory } from "./types-BMS6yfLS.mjs";
2
+ import { d as Turn$1 } from "./index-BvTd61i5.mjs";
3
+ import { a as PipelineStep, o as SessionEditorAction, t as ActionCategory } from "./types-BNW5n6qm.mjs";
4
4
  import { z } from "zod";
5
5
  import * as _$_makaio_core0 from "@makaio/framework/core";
6
6
  import { ExtractSubjectPayload, SubjectDefinition } from "@makaio/framework/core";
7
7
  import { IMakaioBus } from "@makaio/framework/bus";
8
8
  import * as _$_makaio_contracts0 from "@makaio/framework/contracts";
9
- import { AIReasoningLevel, AdapterRuntimeOptions, BranchKind, ContextWindowState, ForkOptions, ForkTransforms, ICapabilityProvider, IMakaioSession, JsonValue, MakaioSessionAgent, MakaioSessionEvent, Message, MessageBlock, MessageInput, ReasoningLevelMap, SessionContext, SessionEventType, SessionExtensionContext, SessionLineage, SessionLineageKind, SessionMessage, SessionMessageBlock, SessionMessageOrigin, SessionSubjects, TurnIngestionMarker, TurnInitiator, TurnUsage } from "@makaio/framework/contracts";
9
+ import { AIReasoningLevel, AdapterRuntimeOptions, BranchKind, ContextWindowState, ForkOptions, ForkTransforms, ICapabilityProvider, IMakaioSession, JsonValue, MakaioSessionAgent, MakaioSessionEvent, Message, MessageBlock, MessageInput, NativeLocalityVerdict, ReasoningLevelMap, SessionContext, SessionEventType, SessionExtensionContext, SessionLineage, SessionLineageKind, SessionMessage, SessionMessageBlock, SessionMessageOrigin, SessionSubjects, TurnIngestionMarker, TurnInitiator, TurnUsage } from "@makaio/framework/contracts";
10
10
  import { BaseService } from "@makaio/framework/service-base";
11
11
  import * as _$drizzle_orm_sqlite_core0 from "drizzle-orm/sqlite-core";
12
12
  import * as _$drizzle_orm_pg_core0 from "drizzle-orm/pg-core";
@@ -182,13 +182,16 @@ declare class SessionOrchestrator implements ISessionOrchestrator {
182
182
  private readonly bus;
183
183
  private readonly turnManager;
184
184
  private readonly adapterRegistry;
185
+ private readonly machineId;
185
186
  /** Cleanup functions for bus subscriptions. */
186
187
  private readonly cleanups;
187
188
  /**
188
189
  * @param bus - Event bus used for handler registration and message routing
189
- * @param _machineId - Machine identifier (reserved for future routing use)
190
+ * @param machineId - Stable machine identity forwarded to the attach handler
191
+ * to drive native-locality decisions (resume locality evaluation, adapter
192
+ * instance resolution).
190
193
  */
191
- constructor(bus: IMakaioBus | undefined, _machineId: string);
194
+ constructor(bus: IMakaioBus | undefined, machineId: string);
192
195
  /**
193
196
  * Register the `session.sendMessage` RPC handler.
194
197
  *
@@ -357,9 +360,10 @@ declare function normalizeToBlocks(message: MessageInput): SessionMessageBlock[]
357
360
  * @param providedSessionId - Session ID to look up
358
361
  * @param _sessionContext - Optional session context (scope fields removed in W1-A)
359
362
  * @param originWindowId - Window ID that initiated the session creation
363
+ * @param machineId - Machine identity to stamp on the session at creation time
360
364
  * @returns Session ID and session object
361
365
  */
362
- declare function getOrCreateSession(bus: IMakaioBus, providedSessionId: string, _sessionContext?: SessionContext, originWindowId?: string): Promise<{
366
+ declare function getOrCreateSession(bus: IMakaioBus, providedSessionId: string, _sessionContext?: SessionContext, originWindowId?: string, machineId?: string): Promise<{
363
367
  sessionId: string;
364
368
  session: IMakaioSession;
365
369
  }>;
@@ -436,6 +440,15 @@ interface RecoveryConfig {
436
440
  cwd?: string;
437
441
  /** Model identifier (e.g., 'claude-sonnet-4-20250514', 'gpt-4o') */
438
442
  model?: string;
443
+ /**
444
+ * Provider-native session ID to resume.
445
+ *
446
+ * When set, the adapter creates the connector in native-resume mode so the
447
+ * provider session continues from where it left off. The caller is responsible
448
+ * for evaluating locality (machine identity, adapter capability, CWD match)
449
+ * before setting this field.
450
+ */
451
+ resumeAdapterSessionId?: string;
439
452
  }
440
453
  /**
441
454
  * Ensure agent cwd matches desired cwd, swapping connector if needed.
@@ -797,15 +810,24 @@ type FallbackRuntimeOptions = Pick<AdapterRuntimeOptions, 'cwd' | 'systemPrompt'
797
810
  declare function pickFallbackRuntimeOptions(payload: Partial<Pick<AdapterRuntimeOptions, 'cwd' | 'systemPrompt' | 'allowedTools' | 'disallowedTools'>>): FallbackRuntimeOptions;
798
811
  //#endregion
799
812
  //#region services/core/src/session/context/assemble-fork-context.d.ts
813
+ /** Adapter capability signals required before emitting a native fork directive. */
814
+ interface AssembleForkContextCapabilities {
815
+ /** Adapter declares provider-native fork support for the selected target. */
816
+ readonly adapterSupportsNativeFork: boolean;
817
+ /** Adapter declares support for provider-native mid-history/checkpoint fork. */
818
+ readonly midHistoryForkSupported: boolean;
819
+ }
800
820
  /**
801
821
  * Assemble fork context for a session's first turn.
802
822
  *
803
823
  * For fork sessions on their first turn, this:
804
824
  * 1. Detects if this is a fork session (has parentSessionId)
805
825
  * 2. Checks if this is the first turn (via isNewTurn flag + storage query)
806
- * 3. Calls getFullConversation() to get projected context with transforms
807
- * 4. Converts SessionMessage[] to Message[] format
808
- * 5. Returns enriched SessionContext with messageHistory
826
+ * 3. Evaluates native locality for the source (parent) session
827
+ * 4a. If native: returns a fork directive without message history injection
828
+ * 4b. Otherwise: calls getFullConversation() to get projected context with transforms,
829
+ * converts SessionMessage[] to Message[] format, and attaches the locality verdict
830
+ * 5. Returns enriched SessionContext
809
831
  *
810
832
  * If not a fork first turn, returns the original sessionContext unchanged.
811
833
  * @param bus - Bus instance for RPC calls
@@ -813,9 +835,24 @@ declare function pickFallbackRuntimeOptions(payload: Partial<Pick<AdapterRuntime
813
835
  * @param sessionId - Session ID
814
836
  * @param originalContext - Original sessionContext from payload
815
837
  * @param isNewTurn - Whether this is a new turn (avoids race with just-created turn record)
838
+ * @param localMachineId - Stable machine identity of the current host process
839
+ * @param capabilities - Adapter capability signals resolved by the caller
840
+ * @param targetCwd - Effective working directory for the new agent, overriding
841
+ * `session.targetWorkingDirectory` in the locality check. Callers that resolve
842
+ * a per-request cwd override (e.g. a send payload `cwd` field) must pass the
843
+ * resolved value here so the native-fork evaluation and the eventual
844
+ * `startAgent` call operate on the same cwd — preventing a mismatch where
845
+ * locality is approved against the stored session cwd but the agent starts in
846
+ * a different directory.
847
+ * @param targetAdapterName - Stable adapter type name of the target adapter.
848
+ * Compared against the source session's adapterName to prevent cross-adapter
849
+ * fork — sending a provider session ID to a different adapter type would
850
+ * corrupt the conversation. Undefined when the caller cannot determine the
851
+ * target adapter (e.g. route-to-agents with mixed adapters); in that case the
852
+ * adapter-mismatch check is skipped.
816
853
  * @returns Enriched or original SessionContext
817
854
  */
818
- declare function assembleForkContext(bus: IMakaioBus, session: IMakaioSession, sessionId: string, originalContext?: SessionContext, isNewTurn?: boolean): Promise<SessionContext | undefined>;
855
+ declare function assembleForkContext(bus: IMakaioBus, session: IMakaioSession, sessionId: string, originalContext?: SessionContext, isNewTurn?: boolean, localMachineId?: string, capabilities?: AssembleForkContextCapabilities, targetCwd?: string, targetAdapterName?: string): Promise<SessionContext | undefined>;
819
856
  //#endregion
820
857
  //#region services/core/src/session/session-bridge.d.ts
821
858
  declare class SessionBridge {
@@ -1159,6 +1196,7 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
1159
1196
  request: z.ZodObject<{
1160
1197
  agentId: z.ZodString;
1161
1198
  adapterId: z.ZodOptional<z.ZodString>;
1199
+ adapterSessionId: z.ZodOptional<z.ZodString>;
1162
1200
  cwd: z.ZodOptional<z.ZodString>;
1163
1201
  model: z.ZodOptional<z.ZodString>;
1164
1202
  allowedDirectories: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -1768,6 +1806,7 @@ declare const AgentStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.
1768
1806
  request: z.ZodObject<{
1769
1807
  agentId: z.ZodString;
1770
1808
  adapterId: z.ZodOptional<z.ZodString>;
1809
+ adapterSessionId: z.ZodOptional<z.ZodString>;
1771
1810
  cwd: z.ZodOptional<z.ZodString>;
1772
1811
  model: z.ZodOptional<z.ZodString>;
1773
1812
  allowedDirectories: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -2020,7 +2059,7 @@ declare const sessionStorageSchema: _$_makaio_storage_drizzle0.DialectSchema<{
2020
2059
  tableName: "sessions";
2021
2060
  dataType: "string";
2022
2061
  columnType: "SQLiteText";
2023
- data: "fork" | "subagent" | "compress" | "branch" | "rewrite" | "coordinator" | "aside";
2062
+ data: "fork" | "subagent" | "branch" | "compress" | "rewrite" | "coordinator" | "aside";
2024
2063
  driverParam: string;
2025
2064
  notNull: false;
2026
2065
  hasDefault: false;
@@ -2461,6 +2500,25 @@ declare const sessionStorageSchema: _$_makaio_storage_drizzle0.DialectSchema<{
2461
2500
  identity: undefined;
2462
2501
  generated: undefined;
2463
2502
  }, {}, {}>;
2503
+ machineId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2504
+ name: "machine_id";
2505
+ tableName: "sessions";
2506
+ dataType: "string";
2507
+ columnType: "SQLiteText";
2508
+ data: string;
2509
+ driverParam: string;
2510
+ notNull: false;
2511
+ hasDefault: false;
2512
+ isPrimaryKey: false;
2513
+ isAutoincrement: false;
2514
+ hasRuntimeDefault: false;
2515
+ enumValues: [string, ...string[]];
2516
+ baseColumn: never;
2517
+ identity: undefined;
2518
+ generated: undefined;
2519
+ }, {}, {
2520
+ length: number | undefined;
2521
+ }>;
2464
2522
  };
2465
2523
  dialect: "sqlite";
2466
2524
  }>;
@@ -2880,6 +2938,7 @@ type SearchSessionRow = {
2880
2938
  fork_transforms: string | null;
2881
2939
  target_working_directory: string | null;
2882
2940
  metadata: Record<string, JsonValue> | string | null;
2941
+ machine_id: string | null;
2883
2942
  };
2884
2943
  /**
2885
2944
  * Filter parameters accepted by FTS search queries.
@@ -3674,6 +3733,194 @@ declare const LogImportTriggerSubjects: _$_makaio_core0.BusSubjects<_$_makaio_co
3674
3733
  * @returns True when content import must be suppressed
3675
3734
  */
3676
3735
  declare function isPolicyDiscoveredObservedSession(session: Pick<IMakaioSession, 'clientId' | 'importStatus'>): boolean;
3736
+ /**
3737
+ * Check whether a stored session is a hook-first tracking stub.
3738
+ *
3739
+ * A tracking stub is the session row created by
3740
+ * `ObservedSessionIngestionService.handleSessionStarted` when the
3741
+ * `SessionStart` hook fires before the suppression gate is populated.
3742
+ * Its fingerprint is:
3743
+ * - `isImported: true` (set by `importUpsert`)
3744
+ * - `importStatus: 'tracking'` (live-followed observed session)
3745
+ * - `clientId` is present (hook-observed, not watcher-discovered)
3746
+ *
3747
+ * This predicate is the single source of truth for stub identification
3748
+ * across reconciliation and diagnostic paths. Externally observed
3749
+ * terminal sessions share this fingerprint, but they never trigger
3750
+ * `client.runtime.started` — the caller discriminates by context.
3751
+ * @param session - Stored session row to inspect
3752
+ * @returns True when the session matches the tracking-stub fingerprint
3753
+ */
3754
+ declare function isTrackingStub(session: Pick<IMakaioSession, 'isImported' | 'importStatus' | 'clientId'>): boolean;
3755
+ /**
3756
+ * Bridges observed client sessions into the canonical session model.
3757
+ *
3758
+ * Responsibilities:
3759
+ * - Register observed sessions on `client.session.started` through the
3760
+ * unified registration seam (`storage:session.importUpsert`), keyed on the
3761
+ * importer's adapter name so hook-first registration and later transcript
3762
+ * imports converge on the same `(source, adapterSessionId)` identity.
3763
+ * - Trigger targeted transcript imports on `client.session.turn.completed`
3764
+ * (`log-import.importFile` when the transcript path is known, discovery
3765
+ * fallback via `log-import.importSession` otherwise).
3766
+ * - Suppress all work for adapter-managed sessions: sessions the managed
3767
+ * orchestration path drives already flow through the orchestrator and must
3768
+ * not be double-ingested (gate fed by `client.runtime.started`).
3769
+ *
3770
+ * Non-responsibilities:
3771
+ * - Holds NO turn state — turn boundaries and content come exclusively from
3772
+ * the transcript reconstruction during import (design Principle 4).
3773
+ * - Never emits `session.*` subjects itself — the turn lifecycle ingestion
3774
+ * seam is the single emitter (design Principle 2).
3775
+ *
3776
+ * The component is client-agnostic: client and importer identities come from
3777
+ * event payloads and the log-import registry, never from hard-coded client
3778
+ * ids. A single subscription per subject on the global `client` namespace
3779
+ * covers every emitting client; `clientId` in the payload is the
3780
+ * discriminator. When no log-import service or no matching importer is
3781
+ * registered (framework-only mode), all work is skipped silently.
3782
+ */
3783
+ declare class ObservedSessionIngestionService {
3784
+ private readonly bus;
3785
+ /**
3786
+ * Adapter session IDs owned by the managed orchestration path.
3787
+ *
3788
+ * FIFO-capped at {@link MANAGED_SESSION_CAP}; insertion order is the
3789
+ * eviction order (mirrors the client services' gate).
3790
+ */
3791
+ private readonly managedAdapterSessionIds;
3792
+ /**
3793
+ * Importer resolutions per client id.
3794
+ *
3795
+ * Importers register at boot and do not un-register mid-session, so this
3796
+ * cache (including misses) is valid for the lifetime of the service instance.
3797
+ */
3798
+ private readonly importerByClientId;
3799
+ /** Client ids already debug-logged as unresolvable (one log per client id). */
3800
+ private readonly unresolvedClientIds;
3801
+ /** Registered optional policy providers; deny/discovered decisions win. */
3802
+ private readonly policyProviders;
3803
+ private readonly cleanups;
3804
+ /**
3805
+ * Create the service and subscribe to the observed-session subjects.
3806
+ * @param bus - Application bus instance
3807
+ */
3808
+ constructor(bus?: IMakaioBus);
3809
+ /** Unsubscribe all bus handlers. */
3810
+ destroy(): void;
3811
+ /**
3812
+ * Record adapter-managed sessions in the suppression gate and reconcile
3813
+ * any hook-first tracking stub.
3814
+ *
3815
+ * Unlike the per-client gates inside the client services, this component
3816
+ * does not filter by `clientId`: it is client-agnostic, and an adapter
3817
+ * session ID marked as managed must suppress observed ingestion regardless
3818
+ * of which client runtime reported it. Non-adapter source layers (e.g.
3819
+ * `'supervisor'`, `'statusline'`) never suppress — they observe sessions
3820
+ * the managed path does not own.
3821
+ *
3822
+ * **Stub reconciliation:** When the `SessionStart` hook fires before this
3823
+ * gate is populated (hook-first ingestion race), `handleSessionStarted`
3824
+ * creates a tracking stub via `importUpsert`. This stub and the live
3825
+ * session row coexist as duplicates. `client.runtime.started` is the
3826
+ * authoritative, guaranteed-to-arrive signal that the adapter session is
3827
+ * managed. On arrival, any existing tracking stub for the same
3828
+ * `(source, adapterSessionId)` is reconciled: deleted when inert, or
3829
+ * preserved when it already carries imported messages (native takeover
3830
+ * of an externally observed session — see the content guard below).
3831
+ *
3832
+ * Externally observed terminal sessions share the same storage fingerprint
3833
+ * (`isImported: true`, `importStatus: 'tracking'`, `clientId` set) but
3834
+ * never trigger `client.runtime.started` for their `adapterSessionId` —
3835
+ * they are observed via hooks only, without a `client.runtime.observe`
3836
+ * preceding them. Therefore `client.runtime.started` itself is the
3837
+ * discriminator: if we receive it for an adapterSessionId, the session is
3838
+ * adapter-managed and any tracking stub is a racy artifact.
3839
+ * @param payload - `client.runtime.started` payload
3840
+ */
3841
+ private handleRuntimeStarted;
3842
+ /**
3843
+ * Reconcile a hook-first tracking stub for a managed adapter session.
3844
+ *
3845
+ * Looks up a tracking stub by `(source, adapterSessionId)` and deletes it
3846
+ * when it carries no imported messages (pure race artifact). Stubs with
3847
+ * content are preserved (native takeover of an externally observed session).
3848
+ * When message storage is unavailable (unhandled lookup), the stub is
3849
+ * preserved defensively to avoid data loss.
3850
+ *
3851
+ * Called from two sites to close the in-flight importUpsert window:
3852
+ * - `handleRuntimeStarted`: runtime side adds to gate, then reconciles.
3853
+ * - `handleSessionStarted`: hook side writes storage, then reconciles
3854
+ * (post-upsert double-check when the gate was populated concurrently).
3855
+ * @param clientId - Client identity for importer resolution
3856
+ * @param adapterSessionId - External adapter session ID to reconcile
3857
+ */
3858
+ private reconcileTrackingStub;
3859
+ /**
3860
+ * Resolve the log-import importer responsible for a client's sessions.
3861
+ *
3862
+ * Bridges the correlation gap between hook identity and import identity:
3863
+ * hooks report the client id (e.g. `'claude-code'`) while the import path
3864
+ * keys sessions on the importer's adapter name. Registrations advertise
3865
+ * their `clientId` via `log-import.listImporters`.
3866
+ *
3867
+ * Graceful absence: `null` means framework-only mode (no log-import
3868
+ * service, or no importer registered for this client) — callers skip
3869
+ * silently. At most one debug log is emitted per unresolved client id.
3870
+ * @param clientId - Stable client id from the observed event payload
3871
+ * @returns Importer adapter name, or `null` when no importer is registered
3872
+ */
3873
+ private resolveImporter;
3874
+ /**
3875
+ * Debug-log an unresolved client id at most once.
3876
+ * @param clientId - Client id that could not be resolved to an importer
3877
+ * @param reason - Why resolution failed
3878
+ */
3879
+ private debugUnresolved;
3880
+ /**
3881
+ * Register an observed session through the unified registration seam.
3882
+ *
3883
+ * Skipped for managed sessions and when no importer is resolvable — a
3884
+ * session that can never receive imported content must not create a
3885
+ * dangling stub. The registration `source` is the importer's adapter name,
3886
+ * NOT the raw client id: the `(source, adapterSessionId)` upsert key must
3887
+ * match what the import path writes, otherwise hook-first registration
3888
+ * would fork the session identity and every import would create a
3889
+ * duplicate session.
3890
+ * @param payload - `client.session.started` payload
3891
+ */
3892
+ private handleSessionStarted;
3893
+ /**
3894
+ * Trigger a targeted transcript import for a completed observed turn.
3895
+ *
3896
+ * Preferred trigger: `log-import.importFile` with the transcript path from
3897
+ * the hook payload (no prior discovery stub required). Fallback when the
3898
+ * payload carries no path: `log-import.importSession`, which requires an
3899
+ * existing discovery stub and throws otherwise — tolerated and
3900
+ * debug-logged, because the polling watcher ingests the turn on its next
3901
+ * pass either way. If hook payloads prove to lack the transcript path at
3902
+ * fire time in practice, resolving the path from the statusline cache is
3903
+ * the candidate follow-up seam.
3904
+ * @param payload - `client.session.turn.completed` payload
3905
+ */
3906
+ private handleTurnCompleted;
3907
+ /**
3908
+ * Evaluate registered policy providers for an observed session.
3909
+ *
3910
+ * No provider means the current default: content tracking. When multiple
3911
+ * providers are present, `discovered` wins so independent policy modules can
3912
+ * only restrict content import, not override each other's deny decisions.
3913
+ * @param input - Observed session identity and importer context
3914
+ * @returns Import status for the registration
3915
+ */
3916
+ private decideImportStatus;
3917
+ /**
3918
+ * Determine whether a completed observed turn may trigger content import.
3919
+ * @param input - Observed turn identity and importer context
3920
+ * @returns True when content import should run
3921
+ */
3922
+ private shouldImportObservedContent;
3923
+ }
3677
3924
  //#endregion
3678
3925
  //#region services/core/src/session/observed-session-ingestion-policy.d.ts
3679
3926
  /** Capability id used for observed-session ingestion policy providers. */
@@ -4556,7 +4803,7 @@ declare const messages: _$drizzle_orm_sqlite_core0.SQLiteTableWithColumns<{
4556
4803
  tableName: "messages";
4557
4804
  dataType: "string";
4558
4805
  columnType: "SQLiteText";
4559
- data: "text" | "voice" | "compact";
4806
+ data: "text" | "compact" | "voice";
4560
4807
  driverParam: string;
4561
4808
  notNull: false;
4562
4809
  hasDefault: false;
@@ -5283,4 +5530,78 @@ declare function buildSessionContext(bus: IMakaioBus, options: BuildContextOptio
5283
5530
  */
5284
5531
  declare function getFullConversation(bus: IMakaioBus, sessionId: string): Promise<ContextAssemblyResult>;
5285
5532
  //#endregion
5286
- export { emitSessionTurnStarted as $, resolveAdapterId as $t, registerMemoryTurnStorage as A, FallbackRuntimeOptions as At, ObservedSessionIngestionPolicyInput as B, registerResumeHandler as Bt, messages as C, registerMemorySessionStorage as Ct, SelectTurn as D, createSessionExtensionContext as Dt, InsertTurn as E, SessionExtensionContextImpl as Et, importCursorsDual as F, registerListActionsHandler as Ft, IngestCompletedTurnParams as G, buildTurnInitiator as Gt, unregisterObservedSessionIngestionPolicyProvider as H, AgentContextState as Ht, IObservedSessionIngestionPolicyProvider as I, registerBuiltInActions as It, ingestCompletedTurn as J, ensureAgentCwd as Jt, IngestCompletedTurnResult as K, RecoveryConfig as Kt, OBSERVED_SESSION_INGESTION_POLICY_CAPABILITY_ID as L, resetBuiltInActionsRegistration as Lt, EmbeddingIndexManager as M, CONNECTOR_SWAP_DEFAULT_PIPELINE as Mt, registerDrizzleImportCursorStorage as N, normalizeSelectionString as Nt, turns as O, SessionBridge as Ot, importCursors as P, resolveAdapterNameById as Pt, appendSessionLifecycleEvent as Q, buildRecoveryContext as Qt, ObservedSessionIngestionPolicyDecision as R, actionRegistry as Rt, SelectMessage as S, registerDrizzleSessionStorage as St, registerDrizzleMessageStorage as T, AgentStorageSubjects as Tt, LogImportTriggerSubjects as U, ContextWindowTrackerConfig as Ut, registerObservedSessionIngestionPolicyProvider as V, ContextWindowTracker as Vt, isPolicyDiscoveredObservedSession as W, SessionContextWindowState as Wt, SessionLifecycleEventArgs as X, recoverAgent as Xt, EventTransform as Y, ensureAgentModel as Yt, SessionTurnStartedPayload as Z, verifyAndRecoverAgents as Zt, messageRoutingDual as _, mapRowToSession as _t, kindToBranchKind as a, extractTextContent as an, sessionEvents as at, MessageRoutingSubjects as b, registerDrizzleAgentStorage as bt, registerSpawningToolCallResolver as c, AdapterRegistry as cn, SessionPreviewMaps as ct, MakaioSession as d, registerCoreSessionServiceHandlers as dn, mapToSession as dt, resolveExecutionTarget as en, registerSessionLifecycleEventWriters as et, MakaioSessionConfig as f, MakaioSessionService as fn, SearchFilters as ft, messageRouting as g, fetchPreviewBySession as gt, SelectMessageRouting as h, fetchMessageCountsBySession as ht, ContextAssemblyResult as i, resolveTargetAgents as in, SelectSessionEvent as it, registerDrizzleTurnStorage as j, pickFallbackRuntimeOptions as jt, turnsDual as k, assembleForkContext as kt, registerCompressLineageResolver as l, ISessionOrchestrator as ln, fetchSessionPreviewMaps as lt, InsertMessageRouting as m, fetchAgentsBySession as mt, buildSessionContext as n, findTurnByAgent as nn, registerMemorySessionEventStorage as nt, toSessionLineage as o, normalizeToBlocks as on, sessionEventsDual as ot, StartTurnOptions as p, SearchSessionRow as pt, IngestTurnMessage as q, buildRecoveryContextWithPipeline as qt, BuildContextOptions as r, getOrCreateSession as rn, InsertSessionEvent as rt, registerSessionDiscoveredHandler as s, TurnContextEnricher as sn, getSessionAncestorChain as st, getFullConversation as t, resolveModelCapabilities as tn, registerDrizzleSessionEventStorage as tt, registerParentResolver as u, SessionOrchestrator as un, mapAgentsBySession as ut, registerDrizzleMessageRoutingStorage as v, parseForkTransforms as vt, registerMemoryMessageStorage as w, AgentStorageNamespace as wt, InsertMessage as x, registerMemoryAgentStorage as xt, MessageRoutingNamespace as y, registerFtsSearchHandler as yt, ObservedSessionIngestionPolicyImportStatus as z, registerGetStatusCountsHandler as zt };
5533
+ //#region services/core/src/session/native-locality.d.ts
5534
+ /**
5535
+ * Describes whether the session resume/fork intent is a native continuation
5536
+ * or a new fork branching from an existing session.
5537
+ */
5538
+ type NativeLocalityIntent = 'resume' | 'fork';
5539
+ /**
5540
+ * All inputs required for the native locality evaluator.
5541
+ */
5542
+ interface NativeLocalityInput {
5543
+ /** Whether this is a resume or fork operation. */
5544
+ readonly intent: NativeLocalityIntent;
5545
+ /** The session being resumed or forked. */
5546
+ readonly session: IMakaioSession;
5547
+ /**
5548
+ * The stable machine identity of the current host process.
5549
+ * Undefined when the framework host has not yet resolved machine identity.
5550
+ */
5551
+ readonly localMachineId: string | undefined;
5552
+ /**
5553
+ * Whether the adapter for this session declares native resume/fork capability.
5554
+ * Adapters that cannot natively replay/branch must always inject history.
5555
+ */
5556
+ readonly adapterSupportsNative: boolean;
5557
+ /**
5558
+ * Stable adapter type name of the target adapter (e.g. 'claude-code', 'codex-mcp').
5559
+ *
5560
+ * Compared against `session.adapterName` to prevent cross-adapter resume/fork:
5561
+ * sending a Claude provider session ID to a Codex adapter (or vice versa) would
5562
+ * corrupt the provider conversation. When the session has no stored adapterName
5563
+ * (legacy records, sessions created before adapter identity tracking), the check
5564
+ * is skipped — the downstream adapter will reject an incompatible session ID.
5565
+ */
5566
+ readonly targetAdapterName: string;
5567
+ /**
5568
+ * Working directory of the current adapter instance.
5569
+ * Only relevant when `targetCwd` is also supplied.
5570
+ */
5571
+ readonly currentCwd?: string;
5572
+ /**
5573
+ * Requested working directory for the resumed or forked session.
5574
+ * When it differs from `currentCwd`, native operation cannot reuse the
5575
+ * existing connector.
5576
+ */
5577
+ readonly targetCwd?: string;
5578
+ /**
5579
+ * Turn-scoped context signals produced by the session orchestrator.
5580
+ * Used to detect compression, connector swaps, and pending transforms.
5581
+ */
5582
+ readonly sessionContext?: SessionContext;
5583
+ /**
5584
+ * Whether the underlying adapter supports forking at a mid-history message.
5585
+ * Required when `session.forkPointMessageId` is set and `intent === 'fork'`.
5586
+ */
5587
+ readonly midHistoryForkSupported?: boolean;
5588
+ }
5589
+ /**
5590
+ * Evaluates whether a session can use native resume or fork, or must fall back
5591
+ * to history injection.
5592
+ *
5593
+ * Checks are ordered from cheapest/most common disqualifier to most specific so
5594
+ * that callers pay no cost for conditions that are almost never hit:
5595
+ *
5596
+ * 1. Adapter capability declaration
5597
+ * 2. Provider-native session ID presence
5598
+ * 3. Machine identity availability and ownership
5599
+ * 4. Structural constraints (imports + orchestration, compression, transforms,
5600
+ * connector swap, CWD mismatch)
5601
+ * 5. Mid-history fork support
5602
+ * @param input - All signals needed to determine locality
5603
+ * @returns A {@link NativeLocalityVerdict} describing the outcome
5604
+ */
5605
+ declare function evaluateNativeLocality(input: NativeLocalityInput): NativeLocalityVerdict;
5606
+ //#endregion
5607
+ export { ingestCompletedTurn as $, ensureAgentCwd as $t, SelectTurn as A, AgentStorageSubjects as At, OBSERVED_SESSION_INGESTION_POLICY_CAPABILITY_ID as B, registerListActionsHandler as Bt, MessageRoutingSubjects as C, parseForkTransforms as Ct, registerMemoryMessageStorage as D, registerDrizzleSessionStorage as Dt, messages as E, registerMemoryAgentStorage as Et, EmbeddingIndexManager as F, FallbackRuntimeOptions as Ft, unregisterObservedSessionIngestionPolicyProvider as G, registerResumeHandler as Gt, ObservedSessionIngestionPolicyImportStatus as H, resetBuiltInActionsRegistration as Ht, registerDrizzleImportCursorStorage as I, pickFallbackRuntimeOptions as It, isPolicyDiscoveredObservedSession as J, ContextWindowTrackerConfig as Jt, LogImportTriggerSubjects as K, ContextWindowTracker as Kt, importCursors as L, CONNECTOR_SWAP_DEFAULT_PIPELINE as Lt, turnsDual as M, createSessionExtensionContext as Mt, registerMemoryTurnStorage as N, SessionBridge as Nt, registerDrizzleMessageStorage as O, registerMemorySessionStorage as Ot, registerDrizzleTurnStorage as P, assembleForkContext as Pt, IngestTurnMessage as Q, buildRecoveryContextWithPipeline as Qt, importCursorsDual as R, normalizeSelectionString as Rt, MessageRoutingNamespace as S, mapRowToSession as St, SelectMessage as T, registerDrizzleAgentStorage as Tt, ObservedSessionIngestionPolicyInput as U, actionRegistry as Ut, ObservedSessionIngestionPolicyDecision as V, registerBuiltInActions as Vt, registerObservedSessionIngestionPolicyProvider as W, registerGetStatusCountsHandler as Wt, IngestCompletedTurnParams as X, buildTurnInitiator as Xt, isTrackingStub as Y, SessionContextWindowState as Yt, IngestCompletedTurnResult as Z, RecoveryConfig as Zt, InsertMessageRouting as _, MakaioSessionService as _n, SearchFilters as _t, buildSessionContext as a, resolveExecutionTarget as an, registerSessionLifecycleEventWriters as at, messageRoutingDual as b, fetchMessageCountsBySession as bt, kindToBranchKind as c, getOrCreateSession as cn, InsertSessionEvent as ct, registerSpawningToolCallResolver as d, normalizeToBlocks as dn, sessionEventsDual as dt, ensureAgentModel as en, EventTransform as et, registerCompressLineageResolver as f, TurnContextEnricher as fn, getSessionAncestorChain as ft, StartTurnOptions as g, registerCoreSessionServiceHandlers as gn, mapToSession as gt, MakaioSessionConfig as h, SessionOrchestrator as hn, mapAgentsBySession as ht, getFullConversation as i, resolveAdapterId as in, emitSessionTurnStarted as it, turns as j, SessionExtensionContextImpl as jt, InsertTurn as k, AgentStorageNamespace as kt, toSessionLineage as l, resolveTargetAgents as ln, SelectSessionEvent as lt, MakaioSession as m, ISessionOrchestrator as mn, fetchSessionPreviewMaps as mt, NativeLocalityIntent as n, verifyAndRecoverAgents as nn, SessionTurnStartedPayload as nt, BuildContextOptions as o, resolveModelCapabilities as on, registerDrizzleSessionEventStorage as ot, registerParentResolver as p, AdapterRegistry as pn, SessionPreviewMaps as pt, ObservedSessionIngestionService as q, AgentContextState as qt, evaluateNativeLocality as r, buildRecoveryContext as rn, appendSessionLifecycleEvent as rt, ContextAssemblyResult as s, findTurnByAgent as sn, registerMemorySessionEventStorage as st, NativeLocalityInput as t, recoverAgent as tn, SessionLifecycleEventArgs as tt, registerSessionDiscoveredHandler as u, extractTextContent as un, sessionEvents as ut, SelectMessageRouting as v, SearchSessionRow as vt, InsertMessage as w, registerFtsSearchHandler as wt, registerDrizzleMessageRoutingStorage as x, fetchPreviewBySession as xt, messageRouting as y, fetchAgentsBySession as yt, IObservedSessionIngestionPolicyProvider as z, resolveAdapterNameById as zt };
@@ -9,9 +9,9 @@ import { z } from "zod";
9
9
  * - `visible` — Model is usable and shown in the AgentPicker UI.
10
10
  */
11
11
  declare const ModelVisibilitySchema: z.ZodEnum<{
12
- disabled: "disabled";
13
- enabled: "enabled";
14
12
  visible: "visible";
13
+ enabled: "enabled";
14
+ disabled: "disabled";
15
15
  }>;
16
16
  type ModelVisibility = z.infer<typeof ModelVisibilitySchema>;
17
17
  /**