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

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 (154) hide show
  1. package/dist/.makaio-build.json +2 -2
  2. package/dist/adapter-BRxCc72E.mjs +1 -0
  3. package/dist/adapters/index.d.mts +11 -2
  4. package/dist/adapters/index.mjs +1 -1
  5. package/dist/adapters/node.d.mts +1 -1
  6. package/dist/{base-orchestrator-Cw0vpNgB.d.mts → base-orchestrator-BNysGvaM.d.mts} +70 -2
  7. package/dist/bus/index.d.mts +39 -1
  8. package/dist/bus/index.mjs +1 -1
  9. package/dist/bus-D-ioC0DE.mjs +1 -0
  10. package/dist/bus-rgUFuO2a.mjs +2 -0
  11. package/dist/{client-BcfR-LJC.mjs → client-BgUjVbXX.mjs} +1 -1
  12. package/dist/contracts/adapter/index.d.mts +1 -1
  13. package/dist/contracts/adapter/index.mjs +1 -1
  14. package/dist/contracts/adapter/schemas/session-lineage.d.mts +1 -1
  15. package/dist/contracts/artifact/index.d.mts +1 -1
  16. package/dist/contracts/client/index.d.mts +1 -1
  17. package/dist/contracts/client/index.mjs +1 -1
  18. package/dist/contracts/config/index.d.mts +6 -6
  19. package/dist/contracts/extension/index.d.mts +2 -2
  20. package/dist/contracts/facet/index.d.mts +1 -1
  21. package/dist/contracts/index.d.mts +14 -14
  22. package/dist/contracts/index.mjs +1 -1
  23. package/dist/contracts/materialization/index.d.mts +3 -3
  24. package/dist/contracts/provider/index.d.mts +1 -1
  25. package/dist/contracts/session/index.d.mts +3 -3
  26. package/dist/contracts/session/index.mjs +1 -1
  27. package/dist/contracts/workflow/index.d.mts +2 -2
  28. package/dist/contracts/workflow/index.mjs +1 -1
  29. package/dist/{definition-DePb3ke-.d.mts → definition-b9jyJqPD.d.mts} +1 -1
  30. package/dist/drizzle/0021_m_mr8e1j84.sql +3 -0
  31. package/dist/drizzle/0022_m_mr8i4ky3.sql +43 -0
  32. package/dist/drizzle/meta/_journal.json +14 -0
  33. package/dist/{handler-2bPhRn0u.mjs → handler-BFNvtv5t.mjs} +1 -1
  34. package/dist/handlers-v47Gbsr1.mjs +57 -0
  35. package/dist/hooks/index.d.mts +8 -0
  36. package/dist/hooks/index.mjs +1 -1
  37. package/dist/{index-BhOLtp0B.d.mts → index-31vR1sxk.d.mts} +47 -29
  38. package/dist/{index-Clqt7Nm3.d.mts → index-3J0HZlPH.d.mts} +372 -87
  39. package/dist/{index-D4gn93gL.d.mts → index-3X0368CL.d.mts} +12 -12
  40. package/dist/{index-gAFwNiJT.d.mts → index-BYfSAJRC.d.mts} +64 -0
  41. package/dist/{index-B1XsbrAr.d.mts → index-BwGfdbI0.d.mts} +6 -6
  42. package/dist/{index-D8ScOpus.d.mts → index-C5C1tk9f.d.mts} +222 -9
  43. package/dist/{index-Cvjnj7Zh.d.mts → index-C6Ys8pxt.d.mts} +5 -5
  44. package/dist/{index-mU2lnU7O.d.mts → index-CqCe7Phc.d.mts} +6 -6
  45. package/dist/{index-Cyi7y_aG.d.mts → index-D6aAzr32.d.mts} +20 -20
  46. package/dist/{index-wfSedMR9.d.mts → index-D7rWAEY0.d.mts} +2 -1
  47. package/dist/{index-CYHWOXUm.d.mts → index-DEzdNQum.d.mts} +1 -1
  48. package/dist/{index-DsLpP5ek.d.mts → index-DQYj8-53.d.mts} +1 -1
  49. package/dist/{index-0WhPbKnH.d.mts → index-DV4nRk0h.d.mts} +21 -21
  50. package/dist/{index-C6SLILCZ.d.mts → index-DvHYpi-J.d.mts} +378 -176
  51. package/dist/{index-BMbmoarE.d.mts → index-O08Q2ikz.d.mts} +8 -8
  52. package/dist/kernel/extension/index.d.mts +1 -1
  53. package/dist/kernel/index.d.mts +2 -2
  54. package/dist/kernel/observability/index.d.mts +1 -1
  55. package/dist/{lib-Ba55od_d.mjs → lib-BOmKyjWD.mjs} +1 -1
  56. package/dist/{lib-CM_BUxN8.mjs → lib-DLZYp5z3.mjs} +1 -1
  57. package/dist/{loop-gate-handlers-BLoGCWMQ.mjs → loop-gate-handlers-Bjmat-K3.mjs} +1 -1
  58. package/dist/{namespace-CGxFYDlK.d.mts → namespace-B4cV_pk3.d.mts} +32 -32
  59. package/dist/{namespace-LUNf8zo5.d.mts → namespace-D1_9WVCo.d.mts} +157 -0
  60. package/dist/{namespace-BsYKEMd8.d.mts → namespace-DAj_riOn.d.mts} +138 -0
  61. package/dist/{namespace-BeMGmLrp.d.mts → namespace-DhDY0juT.d.mts} +75 -9
  62. package/dist/{namespace-Bmi5bjm4.d.mts → namespace-DmqoDDRD.d.mts} +156 -20
  63. package/dist/namespace-dFBD2ZmS.mjs +1 -0
  64. package/dist/node/transports/index.d.mts +8 -0
  65. package/dist/node/transports/index.mjs +2 -2
  66. package/dist/orchestrator-shared-ChygCvR1.mjs +1 -0
  67. package/dist/{orchestrator-shared-ChOdIgh6.d.mts → orchestrator-shared-DFLb1otg.d.mts} +9 -3
  68. package/dist/package-BmRhhi-3.mjs +1 -0
  69. package/dist/package.json +1 -1
  70. package/dist/runtime-node/index.mjs +1 -1
  71. package/dist/schema-7aKBGB7S.mjs +1 -0
  72. package/dist/{schema-DHlTAy0N.mjs → schema-CHp6I33k.mjs} +1 -1
  73. package/dist/{schema-Bf_ZNjif.d.mts → schema-DLNBajAV.d.mts} +23 -1
  74. package/dist/{schemas-D512XweP.d.mts → schemas-DMMWmWjq.d.mts} +4 -4
  75. package/dist/schemas-DZGnr9Tl.mjs +1 -0
  76. package/dist/{schemas-C6TVJ80V2.d.mts → schemas-DuuVuhHX2.d.mts} +2 -2
  77. package/dist/schemas-ftgVeWIG.mjs +1 -0
  78. package/dist/scoped-bus-CZId-Df8.mjs +1 -0
  79. package/dist/services/adapter-subsystem/index.d.mts +2 -2
  80. package/dist/services/adapter-subsystem/namespace.d.mts +1 -1
  81. package/dist/services/execution-target/index.d.mts +1 -1
  82. package/dist/services/filesystem/namespace.d.mts +6 -6
  83. package/dist/services/filesystem/schemas.d.mts +3 -3
  84. package/dist/services/harness/index.d.mts +1 -1
  85. package/dist/services/harness/index.mjs +1 -1
  86. package/dist/services/index.d.mts +103 -34
  87. package/dist/services/index.mjs +1 -1
  88. package/dist/services/log-import/browser.d.mts +2 -2
  89. package/dist/services/log-import/index.d.mts +73 -6
  90. package/dist/services/log-import/index.mjs +2 -2
  91. package/dist/services/log-import/log-import.d.mts +1 -1
  92. package/dist/services/log-import/log-import.mjs +1 -1
  93. package/dist/services/log-import/namespace.d.mts +56 -2
  94. package/dist/services/log-import/namespace.mjs +1 -1
  95. package/dist/services/log-import/schemas.d.mts +45 -1
  96. package/dist/services/log-import/schemas.mjs +1 -1
  97. package/dist/services/session/handlers/index.d.mts +1 -1
  98. package/dist/services/session/handlers/index.mjs +1 -1
  99. package/dist/services/session/index.d.mts +8 -8
  100. package/dist/services/session/index.mjs +1 -1
  101. package/dist/services/session/messages/namespace.mjs +1 -1
  102. package/dist/services/session/orchestrator-testing/index.d.mts +1 -1
  103. package/dist/services/session/orchestrator-testing/index.mjs +1 -1
  104. package/dist/services/session/session-events/namespace.d.mts +1 -1
  105. package/dist/services/session/session-events/namespace.mjs +1 -1
  106. package/dist/services/session/storage/namespace.d.mts +1 -1
  107. package/dist/services/session/storage/schema.d.mts +1 -1
  108. package/dist/services/session/storage/schema.mjs +1 -1
  109. package/dist/services/session/testing/index.mjs +9 -4
  110. package/dist/services/session/testing/orchestrator-shared.d.mts +1 -1
  111. package/dist/services/session/testing/orchestrator-shared.mjs +1 -1
  112. package/dist/services/session/turns/namespace.d.mts +1 -1
  113. package/dist/services/session/turns/namespace.mjs +1 -1
  114. package/dist/services/settings/namespace.d.mts +5 -5
  115. package/dist/services/settings/storage/extension-configs/namespace.d.mts +3 -3
  116. package/dist/services/subagent-template/index.d.mts +1 -1
  117. package/dist/services/subagent-template/schemas.d.mts +1 -1
  118. package/dist/services/tool-approval/index.mjs +1 -1
  119. package/dist/services/tools/index.mjs +1 -1
  120. package/dist/services/turn/index.d.mts +1 -1
  121. package/dist/services/turn/namespace.d.mts +1 -1
  122. package/dist/services/turn/schemas.d.mts +89 -0
  123. package/dist/services/turn/schemas.mjs +1 -1
  124. package/dist/session-CKWfn3oc.mjs +1 -0
  125. package/dist/session-DCbJwYEU.mjs +69 -0
  126. package/dist/{session-lineage-5-wRBzuC.d.mts → session-lineage-DR-9DU-U.d.mts} +1 -1
  127. package/dist/storage/drizzle/index.d.mts +1 -1
  128. package/dist/storage/drizzle/index.mjs +1 -1
  129. package/dist/{tool-approval-service-DEQiipxj.mjs → tool-approval-service-MU_DmJsf.mjs} +1 -1
  130. package/dist/tools-BrNm-een.mjs +1 -0
  131. package/dist/{transition-CBjccCMw.d.mts → transition-Dq41YCkc.d.mts} +1 -1
  132. package/dist/{types-InWSdi-V.d.mts → types-BMlzmWp6.d.mts} +11 -1
  133. package/dist/{types-8rhArs_K.d.mts → types-C76EP81O.d.mts} +136 -93
  134. package/dist/ui-components/index.mjs +1 -1
  135. package/dist/{workflow-BqH6ar-D.mjs → workflow-C1z7I5CI.mjs} +1 -1
  136. package/dist/workflow-engine/index.d.mts +12 -12
  137. package/dist/workflow-engine/index.mjs +1 -1
  138. package/dist/workflow-engine/package.mjs +1 -1
  139. package/dist/workflow-engine/workflow-orchestrator.mjs +1 -1
  140. package/package.json +1 -1
  141. package/dist/adapter-DaQqmKOJ.mjs +0 -1
  142. package/dist/bus-BgodbPl9.mjs +0 -2
  143. package/dist/bus-HgaFcCZ1.mjs +0 -1
  144. package/dist/handlers-BAycjV02.mjs +0 -41
  145. package/dist/namespace-C-piH3w4.mjs +0 -1
  146. package/dist/orchestrator-shared-Cxk3x8Vs.mjs +0 -1
  147. package/dist/package-B1AXe-oz.mjs +0 -1
  148. package/dist/schema-D6WAI8OL.mjs +0 -1
  149. package/dist/schemas-ArqQTC0Q.mjs +0 -1
  150. package/dist/schemas-uID59wR8.mjs +0 -1
  151. package/dist/scoped-bus-H3xMYR0E.mjs +0 -1
  152. package/dist/session-0nWT4st6.mjs +0 -39
  153. package/dist/session-DH-ja8Ka.mjs +0 -1
  154. package/dist/tools-DFOsOboy.mjs +0 -1
@@ -1,9 +1,9 @@
1
- import { i as LogImportSettings, t as LogImporterInfo } from "../../index-wfSedMR9.mjs";
2
- import { a as OrchestratorFactory, i as OrchestratorEntry, n as LogImportServiceInstance, o as LogImportRegistry, r as LogImporterRegistration, t as LogImportRegistryOptions } from "../../types-InWSdi-V.mjs";
1
+ import { i as LogImportSettings, t as LogImporterInfo } from "../../index-D7rWAEY0.mjs";
2
+ import { a as OrchestratorFactory, i as OrchestratorEntry, n as LogImportServiceInstance, o as LogImportRegistry, r as LogImporterRegistration, t as LogImportRegistryOptions } from "../../types-BMlzmWp6.mjs";
3
3
  import { LogImportNamespace, LogImportSubjects } from "./namespace.mjs";
4
4
  import { IMakaioBus } from "@makaio/framework/bus";
5
5
  import * as _$_makaio_contracts0 from "@makaio/framework/contracts";
6
- import { MakaioNodeExtension } from "@makaio/framework/contracts";
6
+ import { MakaioNodeExtension, TurnIngestionMarker } from "@makaio/framework/contracts";
7
7
  import * as _$drizzle_orm_sqlite_core0 from "drizzle-orm/sqlite-core";
8
8
  import { MakaioDatabase } from "@makaio/framework/storage/drizzle";
9
9
  import { LogImporter, ProcessLogFileResult } from "@makaio/framework/adapters";
@@ -60,12 +60,29 @@ interface SessionCompactedEventInput {
60
60
  declare function appendSessionCompactedEvent(bus: IMakaioBus, event: SessionCompactedEventInput): Promise<void>;
61
61
  //#endregion
62
62
  //#region services/log-import/src/import-types.d.ts
63
+ /** Result of a file import operation. */
64
+ interface ImportFromFileContentResult {
65
+ /** Makaio session ID that was populated. */
66
+ sessionId: string;
67
+ /** Number of messages written (created + already-present). */
68
+ messageCount: number;
69
+ /**
70
+ * Number of NEWLY created turns across the segment tree in this call.
71
+ * Re-imported turns (anchor already present) do not count.
72
+ */
73
+ turnCount: number;
74
+ }
63
75
  /** Result returned after persisting an imported segment subtree. */
64
76
  interface ImportSegmentTreeResult {
65
77
  /** Makaio session ID created or reused for the imported segment. */
66
78
  sessionId: string;
67
79
  /** Total messages persisted across the segment subtree. */
68
80
  messageCount: number;
81
+ /**
82
+ * Number of NEWLY created turns across the segment subtree in this call.
83
+ * Re-imported turns (anchor already present) do not count.
84
+ */
85
+ turnCount: number;
69
86
  }
70
87
  /** Minimal caller context required to persist a processed import result tree. */
71
88
  interface PersistImportResultContext {
@@ -75,6 +92,12 @@ interface PersistImportResultContext {
75
92
  adapterName: string;
76
93
  /** Log file path on disk; only the root segment owns it. */
77
94
  logFilePath?: string | null;
95
+ /**
96
+ * Marker stamped on the `session.turn.*` events emitted for ingested turns.
97
+ * Defaults to `'backfill'` (historical/watcher imports); hook-triggered
98
+ * live ingestion passes `'live'`.
99
+ */
100
+ ingestionMarker?: TurnIngestionMarker;
78
101
  }
79
102
  //#endregion
80
103
  //#region services/log-import/src/generic-import-handlers.d.ts
@@ -85,10 +108,54 @@ interface PersistImportResultContext {
85
108
  * session creation, message persistence, compaction events, and status finalization.
86
109
  * @param bus - Bus instance
87
110
  * @param result - Fully processed importer result for one log file
88
- * @param ctx - Adapter identity and optional root log file path
89
- * @returns Makaio session ID and total persisted message count
111
+ * @param ctx - Adapter identity, optional root log file path, and optional ingestion marker
112
+ * @returns Makaio session ID, total persisted message count, and newly created turn count
90
113
  */
91
114
  declare function persistImportResultTree(bus: IMakaioBus, result: ProcessLogFileResult, ctx: PersistImportResultContext): Promise<ImportSegmentTreeResult>;
115
+ /**
116
+ * Parse, extract, and store all messages from log file content.
117
+ *
118
+ * Core reusable import logic shared by the upload and lazy-load handlers.
119
+ * This function marks the session import status as `'imported'` after subtree persistence succeeds.
120
+ *
121
+ * When the importer produces `compressChildren` (from compaction boundary
122
+ * detection), each child is processed in order after the parent. Children
123
+ * use `logFilePath: null` — only the parent session owns the file reference.
124
+ * @param params - Import parameters
125
+ * @returns The Makaio session ID and total message count
126
+ * @throws Error if no valid records are found in the content
127
+ */
128
+ declare function importFromFileContent(params: {
129
+ bus: IMakaioBus;
130
+ importer: LogImporter<unknown>;
131
+ content: string;
132
+ isJsonl: boolean;
133
+ adapterName: string;
134
+ adapterId: string;
135
+ sourceFilePath?: string;
136
+ persistedLogFilePath?: string;
137
+ /**
138
+ * Marker stamped on `session.turn.*` events emitted for ingested turns.
139
+ * Defaults to `'backfill'` (applied at the {@link importSegmentTree} boundary).
140
+ */
141
+ ingestionMarker?: TurnIngestionMarker;
142
+ }): Promise<ImportFromFileContentResult>;
143
+ //#endregion
144
+ //#region services/log-import/src/import-file-handler.d.ts
145
+ /**
146
+ * Register the importFile handler.
147
+ *
148
+ * Responds to `log-import.importFile` by parsing the given transcript file
149
+ * with the registered importer for `adapterName` and persisting the resulting
150
+ * segment tree (sessions, messages, turns). Per the subject's
151
+ * graceful-absence contract, a missing importer registration or a missing
152
+ * file yields a `skipped` result instead of an error; genuine importer or
153
+ * storage failures propagate.
154
+ * @param bus - Bus instance for communication
155
+ * @param getRegistration - Function to look up a registration by adapter name
156
+ * @returns Cleanup function to unsubscribe the handler
157
+ */
158
+ declare function registerImportFileHandler(bus: IMakaioBus, getRegistration: (adapterName: string) => LogImporterRegistration | undefined): () => void;
92
159
  //#endregion
93
160
  //#region services/log-import/src/import-phase.d.ts
94
161
  /**
@@ -265,4 +332,4 @@ declare function rowToSettings(row: SelectLogImportSettings): LogImportSettings;
265
332
  */
266
333
  declare function registerDrizzleLogImportStorage(bus: IMakaioBus, db: MakaioDatabase): () => void;
267
334
  //#endregion
268
- export { ImportPhase, type ImportPhaseValue, LogImportNamespace, LogImportRegistry, type LogImportRegistryOptions, LogImportRegistryToken, type LogImportServiceInstance, LogImportSubjects, type LogImporterInfo, type LogImporterRegistration, type OrchestratorEntry, type OrchestratorFactory, type PersistImportResultContext, type SessionCompactedEventInput, appendSessionCompactedEvent, createLogImportContributionProcessor, logImportRegistryPackage, persistImportResultTree, registerDrizzleLogImportStorage, rowToSettings };
335
+ export { ImportPhase, type ImportPhaseValue, LogImportNamespace, LogImportRegistry, type LogImportRegistryOptions, LogImportRegistryToken, type LogImportServiceInstance, LogImportSubjects, type LogImporterInfo, type LogImporterRegistration, type OrchestratorEntry, type OrchestratorFactory, type PersistImportResultContext, type SessionCompactedEventInput, appendSessionCompactedEvent, createLogImportContributionProcessor, importFromFileContent, logImportRegistryPackage, persistImportResultTree, registerDrizzleLogImportStorage, registerImportFileHandler, rowToSettings };
@@ -1,2 +1,2 @@
1
- import{LogImportNamespace as e,LogImportSubjects as t}from"./namespace.mjs";import{z as n}from"zod";import*as r from"node:fs/promises";import{basename as i,dirname as a,isAbsolute as o,join as s,relative as c,resolve as l,sep as u}from"node:path";import{MakaioBus as d}from"@makaio/framework/bus";import{COMPRESS_SESSION_LINEAGE_KIND as f,CapabilitySubjects as p,FORK_SESSION_LINEAGE_KIND as m,ROOT_SESSION_LINEAGE_KIND as ee,SUBAGENT_SESSION_LINEAGE_KIND as h,extensionToken as g}from"@makaio/framework/contracts";import{defineDialectSchema as _,defineDualTable as te,resolveSchema as v}from"@makaio/framework/storage/drizzle";import{eq as ne}from"drizzle-orm";import{ImportCursorStorageSubjects as re,toImportSegment as ie}from"@makaio/framework/adapters";import{MessageStorageSubjects as ae,SessionEventStorageSubjects as y,SessionStorageSubjects as b,toSessionLineage as x}from"@makaio/framework/services/session";const S=n.discriminatedUnion(`kind`,[n.object({adapterSessionId:n.string(),kind:n.literal(ee),parentAdapterSessionId:n.null().default(null),forkPointMessageId:n.null().default(null),model:n.string().nullable().default(null),cwd:n.string().nullable().default(null),startedAt:n.number().finite().optional()}),n.object({adapterSessionId:n.string(),kind:n.literal(m),parentAdapterSessionId:n.string(),forkPointMessageId:n.string(),model:n.string().nullable().default(null),cwd:n.string().nullable().default(null),startedAt:n.number().finite().optional()}),n.object({adapterSessionId:n.string(),kind:n.literal(h),parentAdapterSessionId:n.string(),forkPointMessageId:n.null().default(null),model:n.string().nullable().default(null),cwd:n.string().nullable().default(null),startedAt:n.number().finite().optional()}),n.object({adapterSessionId:n.string(),kind:n.literal(f),parentAdapterSessionId:n.string(),forkPointMessageId:n.null().default(null),model:n.string().nullable().default(null),cwd:n.string().nullable().default(null),startedAt:n.number().finite().optional()})]);function C(e){return S.parse(e.payload)}function w(e,t,n,r,i,a,o){let s=x(e);return{externalSessionId:e.adapterSessionId,source:t,cwd:n,...r===void 0?{}:{logFilePath:r},...i===void 0?{}:{startedAt:i},...a===void 0?{}:{adapterId:a},...o===void 0?{}:{clientId:o},...s}}function oe(e,t,n){let r={adapterSessionId:e.adapterSessionId,model:t,cwd:n};switch(e.lineage.kind){case`root`:return{...r,kind:`root`,parentAdapterSessionId:null,forkPointMessageId:null};case`fork`:if(e.lineage.parentAdapterSessionId==null)throw Error(`Fork segment ${e.adapterSessionId} missing parentAdapterSessionId`);if(e.lineage.forkPointMessageId==null)throw Error(`Fork segment ${e.adapterSessionId} missing forkPointMessageId`);return{...r,kind:`fork`,parentAdapterSessionId:e.lineage.parentAdapterSessionId,forkPointMessageId:e.lineage.forkPointMessageId};case`subagent`:if(e.lineage.parentAdapterSessionId==null)throw Error(`Subagent segment ${e.adapterSessionId} missing parentAdapterSessionId`);return{...r,kind:`subagent`,parentAdapterSessionId:e.lineage.parentAdapterSessionId,forkPointMessageId:null};case`compress`:if(e.lineage.parentAdapterSessionId==null)throw Error(`Compress segment ${e.adapterSessionId} missing parentAdapterSessionId`);return{...r,kind:`compress`,parentAdapterSessionId:e.lineage.parentAdapterSessionId,forkPointMessageId:null};default:{let t=e.lineage.kind;throw Error(`Unknown lineage kind: ${String(t)}`)}}}async function T(e,t){let{events:n}=await e.request(y.getByIds,{sessionId:t.sessionId,eventIds:[t.eventId]});if(!(n.length>0))try{await e.request(y.append,{event:{sessionId:t.sessionId,eventId:t.eventId,timestamp:t.timestamp,type:`session.compacted`,payload:{trigger:t.trigger,preTokens:t.preTokens,summary:t.summary,compressChildSessionId:t.compressChildSessionId}}})}catch(n){let{events:r}=await e.request(y.getByIds,{sessionId:t.sessionId,eventIds:[t.eventId]});if(r.length>0)return;throw n}}const E=new Map,D=`MAKAIO_GLOBSTAR_DIR`,O=`MAKAIO_GLOBSTAR`,k=`MAKAIO_STAR`;function A(e){return e.replace(/[\\/]+/g,`/`).replace(/^\.\/+/,``)}function se(e,t){let n=A(e),r=A(t),a=r.includes(`/`)?n:i(n);if(r.length>200)return!1;if(!r.includes(`*`))return a===r;let o=0;for(let e of r)if(e===`*`&&(o+=1,o>64))return!1;let s=E.get(r);if(s)return E.delete(r),E.set(r,s),s.test(a);let c=r.replace(/\*\*\//g,D).replace(/\*\*/g,O).replace(/\*/g,k).replace(/[.+^${}()|[\]\\]/g,`\\$&`).replaceAll(D,`(?:.*/)?`).replaceAll(O,`.*`).replaceAll(k,`[^/]*`),l=RegExp(`^${c}$`);if(E.size>=512){let e=E.keys().next();e.done||E.delete(e.value)}return E.set(r,l),l.test(a)}async function j(e,t,n=e){let i=[];try{let a=await r.readdir(e,{withFileTypes:!0});for(let r of a){let a=s(e,r.name);if(r.isDirectory()){let e=await j(a,t,n);i.push(...e)}else if(r.isFile()){if(!se(c(n,a).split(u).join(`/`),t))continue;i.push(a)}}}catch{}return i}function ce(e,t,n){if(e!==void 0){if(o(e))return e;if(t&&o(t))return l(a(t),e);if(n&&o(n))return l(n,e)}}function M(e,t,n=!0,r){let i=[];if(n){let n=e.split(`
2
- `).filter(e=>e.trim());for(let e of n){let n=t.parseRecord(e,r);n&&i.push(n)}}else{let n=t.parseRecord(e,r);n&&i.push(n)}return i}function N(e,n){return e.on(t.scan,async t=>{let{adapterName:i}=t.payload,a=n(i);if(!a){t.setResult({adapterName:i,sessionsFound:0,newSessions:0});return}let{importer:o,logFilePattern:s,adapterName:c}=a,l=o.getLogDirectory();try{await r.access(l)}catch{t.setResult({adapterName:i,sessionsFound:0,newSessions:0});return}let u=s.endsWith(`.jsonl`),d=await j(l,s),f=0,p=0;for(let t of d)try{let n=M(await r.readFile(t,`utf8`),o,u,t);if(n.length===0)continue;let i=C(o.extractSessionContext(n).sessionEvent);f++;let{created:a}=await e.request(b.importUpsert,w(i,c,i.cwd,t,i.startedAt));a&&p++}catch(e){console.warn(`[LogImportRegistry] Failed to process ${t}:`,e instanceof Error?e.message:e)}t.setResult({adapterName:i,sessionsFound:f,newSessions:p})})}async function P(e,t,n,i,a,o){try{let a=await r.stat(i),s=t.extractSessionContext(n),c={adapterSessionId:o,model:s.model,cwd:s.cwd,sessionEvent:s.sessionEvent,startedEvent:s.startedEvent,state:t.serializeState(s.state)};await e.request(re.set,{filePath:i,bytesRead:a.size,lastModified:a.mtime.toISOString(),sessionContext:c})}catch(e){console.warn(`[importFromFileContent] Failed to persist import cursor`,{adapterName:a,adapterSessionId:o,filePath:i,error:e instanceof Error?e.message:String(e),stack:e instanceof Error?e.stack:void 0})}}async function F(e,t,n,r,i){let a=i.find(e=>e.origin===`compact`),o=a?.contentText??null,s=r.timestamp??a?.timestamp??Date.now();await T(e,{sessionId:t,eventId:`session-compacted:${t}:${n}`,timestamp:s,trigger:r.trigger,preTokens:r.preTokens,summary:o,compressChildSessionId:n})}async function I(e,t,n){for(let r of n)await e.request(ae.upsertByAdapterMessageId,{sessionId:t,turnId:null,adapterMessageId:r.adapterMessageId,role:r.role,contentText:r.contentText,blocks:r.blocks,agentId:r.agentId,adapterSessionId:r.adapterSessionId,timestamp:r.timestamp,...r.origin!==void 0&&{origin:r.origin}})}async function L(e,t,n,r){let i=oe(t,n.model,n.cwd),a=t.messages.length>0?t.messages.reduce((e,t)=>Math.min(e,t.timestamp),1/0):void 0,{sessionId:o}=await e.request(b.importUpsert,w(i,n.adapterName,n.cwd,n.logFilePath,a,n.adapterId));await I(e,o,t.messages),r!==void 0&&t.compaction!==void 0&&await F(e,r,o,t.compaction,t.messages);let s=t.messages.length,c={adapterId:n.adapterId,adapterName:n.adapterName,model:n.model,cwd:n.cwd,logFilePath:null};for(let n of t.children??[]){let t=await L(e,n,c,o);s+=t.messageCount}return await e.request(b.updateImportStatus,{sessionId:o,importStatus:`imported`}),{sessionId:o,messageCount:s}}async function R(e,t,n){let r=C(t.sessionEvent);return L(e,ie(t),{adapterId:n.adapterId,adapterName:n.adapterName,model:r.model,cwd:r.cwd,logFilePath:n.logFilePath})}async function z(e){let{bus:t,importer:n,content:r,isJsonl:i,adapterName:a,adapterId:o,sourceFilePath:s,persistedLogFilePath:c}=e,l=M(r,n,i,s);if(l.length===0)throw Error(`No valid records found`);let u=n.processLogFile(l),d=ce(c,s,C(u.sessionEvent).cwd),{sessionId:f,messageCount:p}=await R(t,u,{adapterId:o,adapterName:a,logFilePath:d});return d!==void 0&&await P(t,n,l,d,a,u.adapterSessionId),{sessionId:f,messageCount:p}}function B(e,n){return e.on(t.uploadFiles,async t=>{let{adapterName:r,files:i}=t.payload,a=n(r);if(!a){t.setResult({adapterName:r,filesProcessed:i.length,sessionsImported:0,errors:i.map(e=>({filename:e.filename,error:`No importer registered for this adapter`}))});return}let{importer:o,logFilePattern:s,adapterName:c,id:l}=a,u=s.endsWith(`.jsonl`),d=0,f=[];for(let t of i)try{await z({bus:e,importer:o,content:Buffer.from(t.contentBase64,`base64`).toString(`utf8`),isJsonl:u,adapterName:c,adapterId:l,sourceFilePath:t.filename}),d++}catch(e){f.push({filename:t.filename,error:e instanceof Error?e.message:String(e)})}t.setResult({adapterName:r,filesProcessed:i.length,sessionsImported:d,errors:f})})}function V(e,n){return e.on(t.importSession,async t=>{let{adapterSessionId:i,adapterName:a}=t.payload,{session:o}=await e.request(b.getByAdapterSessionId,{adapterSessionId:i,source:a});if(!o)throw Error(`Session not found for external ID: ${i}`);if(o.source!==a)throw Error(`Session '${i}' belongs to adapter '${o.source}', not '${a}'`);if(!o.logFilePath)throw Error(`No log file path recorded for session with external ID '${i}'. Re-run a discovery scan to populate the file path.`);let s=n(a);if(!s)throw Error(`No importer registered for adapter '${a}'`);let{importer:c,logFilePattern:l,adapterName:u,id:d}=s,f=l.endsWith(`.jsonl`),{sessionId:p,messageCount:m}=await z({bus:e,importer:c,content:await r.readFile(o.logFilePath,`utf8`),isJsonl:f,adapterName:u,adapterId:d,sourceFilePath:o.logFilePath,persistedLogFilePath:o.logFilePath});t.setResult({sessionId:p,messageCount:m})})}function H(e){return e.hasAdapterContribution?`adapter`:`extension`}function U(e){if(!e||typeof e!=`object`)return!1;let t=e,n=t.registration;return typeof t.id==`string`&&typeof t.displayName==`string`&&typeof t.adapterName==`string`&&!!n&&typeof n==`object`&&typeof n.LogImporterClass==`function`&&typeof n.logFilePattern==`string`&&(n.LogOrchestratorClass===void 0||typeof n.LogOrchestratorClass==`function`)&&(n.LogDiscoveryOrchestratorClass===void 0||typeof n.LogDiscoveryOrchestratorClass==`function`)}function W(e,t,n){return{enabled:n?.enabled??!0,pollIntervalMs:n?.pollIntervalMs,eventsPerSecond:n?.eventsPerSecond,adapterId:e,adapterName:t,checkMakaioManaged:n?.checkMakaioManaged}}function G(e,t,n,r,i){if(!r&&!i)return null;let a=W(e,t,n);return e=>a.enabled?e===`discover`&&i?new i(a):e===`import`&&r?new r(a):null:null}async function le(e,n,r,i){try{let a=await r.requestOptional(t.getMode,{adapterName:n});if(!a.handled)return;let{mode:o}=a.data;if(o===`disabled`)return;await i(e,o)}catch(e){console.warn(`[LogImport] Failed to restore persisted mode for '${n}':`,e)}}async function K(e,t,n){if(!U(e)||n.getImporter(e.id)!==void 0)return;await n.register({id:e.id,adapterName:e.adapterName,displayName:e.displayName,source:H({hasAdapterContribution:!0}),importer:new e.registration.LogImporterClass({adapterId:e.id,adapterName:e.adapterName}),logFilePattern:e.registration.logFilePattern});let r=G(e.id,e.adapterName,e.logImportConfig,e.registration.LogOrchestratorClass,e.registration.LogDiscoveryOrchestratorClass);r&&n.setOrchestratorFactory(e.id,r),await le(e.id,e.adapterName,t,(e,t)=>n.switchMode(e,t))}async function ue(e,t,n){let r=e.on(p.register,async t=>{await K(t.payload.provider,e,n)},{filter:{capabilityId:`log-import`}});for(let r of t?.getProviders(`log-import`)??[])await K(r,e,n);return r}async function q(e,t){let n=e.get(t);if(n)try{n.orchestrator.isRunning()&&await n.orchestrator.stop()}finally{try{await n.orchestrator.dispose()}finally{e.delete(t)}}}async function de(e,t){try{await e.start()}catch(n){try{try{e.isRunning()&&await e.stop()}finally{await e.dispose()}}catch(e){console.warn(`[LogImportRegistry] Failed to clean up orchestrator after start failure for '${t}'.`,e instanceof Error?e.message:String(e))}throw n}}var J=class{bus;capabilityService;registrations=new Map;orchestrators=new Map;cleanupHandlers=[];initialized=!1;constructor(e){this.bus=e?.bus??d,this.capabilityService=e?.capabilityService}async init(){if(this.initialized)return;let e=this.bus.on(t.listImporters,e=>{let t=this.listImporters();e.setResult({importers:t})});this.cleanupHandlers.push(e);let n=N(this.bus,e=>this.getImporterByAdapterName(e));this.cleanupHandlers.push(n);let r=B(this.bus,e=>this.getImporterByAdapterName(e));this.cleanupHandlers.push(r);let i=V(this.bus,e=>this.getImporterByAdapterName(e));this.cleanupHandlers.push(i);let a=await ue(this.bus,this.capabilityService,this);this.cleanupHandlers.push(a),this.initialized=!0}async register(e){if(this.registrations.has(e.id))throw Error(`Log importer '${e.id}' is already registered`);this.registrations.set(e.id,e)}async unregister(e){if(!this.registrations.has(e))throw Error(`Log importer '${e}' is not registered`);await q(this.orchestrators,e),this.registrations.delete(e)}async startImporter(e){if(!this.registrations.get(e))throw Error(`Log importer '${e}' is not registered`);let t=this.orchestrators.get(e);if(!t)throw Error(`No orchestrator available for '${e}'. Orchestrators must be created and provided by the adapter or extension before starting.`);t.orchestrator.isRunning()||(await t.orchestrator.start(),t.isManaged=!0)}async stopImporter(e){let t=this.orchestrators.get(e);t&&(t.orchestrator.isRunning()&&await t.orchestrator.stop(),t.isManaged=!1)}async switchMode(e,t){let n=this.registrations.get(e);if(!n)throw Error(`Log importer '${e}' is not registered`);if(await q(this.orchestrators,e),t===`disabled`||!n.orchestratorFactory)return;let r=n.orchestratorFactory(t);r&&(await de(r,e),this.orchestrators.set(e,{orchestrator:r,isManaged:!0}))}async startDiscovery(e){return this.switchMode(e,`discover`)}setOrchestratorFactory(e,t){let n=this.registrations.get(e);if(!n)throw Error(`Cannot set orchestrator factory for unregistered importer '${e}'`);this.registrations.set(e,{...n,orchestratorFactory:t})}listImporters(){let e=[];for(let[,t]of this.registrations){let n=this.orchestrators.get(t.id)?.orchestrator.isRunning()??!1;e.push({id:t.id,adapterName:t.adapterName,displayName:t.displayName,source:t.source,logFilePattern:t.logFilePattern,isRunning:n,supportsManualImport:t.supportsManualImport??!0})}return e}getImporter(e){let t=this.registrations.get(e);return t?{...t}:void 0}getImporterByAdapterName(e){for(let t of this.registrations.values())if(t.adapterName===e)return{...t}}detectImporter(e){let t,n=0;for(let r of this.registrations.values()){let i=r.importer.canHandle(e);if(i===!1)continue;let a=i===!0?1:i.confidence;a>n&&(n=a,t=r)}return t}async registerOrchestrator(e,t){if(!this.registrations.has(e))throw Error(`Cannot register orchestrator for unregistered importer '${e}'`);await q(this.orchestrators,e),this.orchestrators.set(e,{orchestrator:t,isManaged:!1})}async destroy(){if(!(!this.initialized&&this.orchestrators.size===0&&this.cleanupHandlers.length===0)){for(let[e]of this.orchestrators)await q(this.orchestrators,e);for(let e of this.cleanupHandlers)e();this.cleanupHandlers.length=0,this.initialized=!1}}};const Y=g(`log-import-registry`),fe={name:Y.name,displayName:`Log Import Registry`,version:`0.1.0`,critical:!0,namespaces:[e],create:e=>new J({bus:e.bus})};function pe(e,t,n){return{enabled:n?.enabled??!0,pollIntervalMs:n?.pollIntervalMs,eventsPerSecond:n?.eventsPerSecond,adapterId:e,adapterName:t,checkMakaioManaged:n?.checkMakaioManaged}}function me(e,t,n){if(!n.LogOrchestratorClass&&!n.LogDiscoveryOrchestratorClass)return null;let r=pe(e,t,n.logImportConfig);return e=>r.enabled?e===`discover`&&n.LogDiscoveryOrchestratorClass?new n.LogDiscoveryOrchestratorClass(r):e===`import`&&n.LogOrchestratorClass?new n.LogOrchestratorClass(r):null:null}function X(){let e=new Map;return{filter:e=>!!e.logImport,processActivated:async(t,n,r)=>{let{logImport:i}=n;if(!i)return;let a=r.getService(Y);if(!a)throw Error(`[LogImportContributionProcessor] LogImportRegistry is not available. Ensure '${Y.name}' is listed as a dependency before activating '${t}'.`);let{adapterName:o,displayName:s,config:c}=i,l=c,u=`package:${t}`,d=H({hasAdapterContribution:!!n.adapters?.length}),f=new l.LogImporterClass({adapterId:u,adapterName:o});await a.register({id:u,adapterName:o,displayName:s,source:d,importer:f,logFilePattern:l.logFilePattern??``,supportsManualImport:l.supportsManualImport});try{let e=me(u,o,l);e&&a.setOrchestratorFactory(u,e)}catch(e){try{await a.unregister(u)}catch(e){console.error(`[LogImportContributionProcessor] Rollback of log importer '${u}' failed:`,e)}throw e}console.info(`[LogImportContributionProcessor] Registered log importer '${o}' from package: ${t}`),e.set(u,async()=>{try{await a.unregister(u)}catch(e){console.error(`[LogImportContributionProcessor] Failed to unregister log importer '${u}' during cleanup:`,e)}})},processStopped:async t=>{let n=`package:${t}`,r=e.get(n);r&&(e.delete(n),await r())}}}const he={linked:`linked`,persisted:`persisted`,finalized:`finalized`},Z=te(`log_import_settings`,e=>({adapterName:e.text(`adapter_name`).primaryKey(),mode:e.textEnum(`mode`,{enum:[`disabled`,`discover`,`import`]}).notNull().default(`disabled`),createdAt:e.epochMs(`created_at`).notNull(),updatedAt:e.epochMs(`updated_at`).notNull()})),ge=Z.sqlite,_e=Z.postgres,Q=_({logImportSettings:ge},{logImportSettings:_e});function $(e){return{adapterName:e.adapterName,mode:e.mode,createdAt:e.createdAt,updatedAt:e.updatedAt}}function ve(e){let{bus:n,db:r}=e,{logImportSettings:i}=v(r,Q);return n.on(t.getMode,async e=>{let{adapterName:t}=e.payload,[n]=await r.select().from(i).where(ne(i.adapterName,t)).limit(1);e.setResult({mode:n?.mode??`disabled`})})}function ye(e){let{bus:n,db:r}=e,{logImportSettings:i}=v(r,Q);return n.on(t.setMode,async e=>{let{adapterName:t,mode:n}=e.payload,a=Date.now();await r.insert(i).values({adapterName:t,mode:n,createdAt:a,updatedAt:a}).onConflictDoUpdate({target:i.adapterName,set:{mode:n,updatedAt:a}}),e.setResult({success:!0})})}function be(e){let{bus:n,db:r}=e,{logImportSettings:i}=v(r,Q);return n.on(t.listSettings,async e=>{let t=await r.select().from(i);e.setResult({settings:t.map($)})})}function xe(e,t){let n={bus:e,db:t},r=[ve(n),ye(n),be(n)];return()=>r.forEach(e=>e())}export{he as ImportPhase,e as LogImportNamespace,J as LogImportRegistry,Y as LogImportRegistryToken,t as LogImportSubjects,T as appendSessionCompactedEvent,X as createLogImportContributionProcessor,fe as logImportRegistryPackage,R as persistImportResultTree,xe as registerDrizzleLogImportStorage,$ as rowToSettings};
1
+ import{LogImportNamespace as e,LogImportSubjects as t}from"./namespace.mjs";import{z as n}from"zod";import*as r from"node:fs/promises";import{basename as i,dirname as a,isAbsolute as o,join as s,relative as c,resolve as l,sep as u}from"node:path";import{MakaioBus as d}from"@makaio/framework/bus";import{COMPRESS_SESSION_LINEAGE_KIND as f,CapabilitySubjects as p,FORK_SESSION_LINEAGE_KIND as m,ROOT_SESSION_LINEAGE_KIND as h,SUBAGENT_SESSION_LINEAGE_KIND as ee,extensionToken as te}from"@makaio/framework/contracts";import{defineDialectSchema as ne,defineDualTable as g,resolveSchema as _}from"@makaio/framework/storage/drizzle";import{eq as re}from"drizzle-orm";import{ImportCursorStorageSubjects as v,toImportSegment as ie}from"@makaio/framework/adapters";import{MessageStorageSubjects as ae,SessionEventStorageSubjects as y,SessionStorageSubjects as b,ingestCompletedTurn as oe,isPolicyDiscoveredObservedSession as se,toSessionLineage as x}from"@makaio/framework/services/session";function S(e,t){return t===void 0?{}:{[e]:t}}const ce=n.discriminatedUnion(`kind`,[n.object({adapterSessionId:n.string(),kind:n.literal(h),parentAdapterSessionId:n.null().default(null),forkPointMessageId:n.null().default(null),model:n.string().nullable().default(null),cwd:n.string().nullable().default(null),startedAt:n.number().finite().optional()}),n.object({adapterSessionId:n.string(),kind:n.literal(m),parentAdapterSessionId:n.string(),forkPointMessageId:n.string(),model:n.string().nullable().default(null),cwd:n.string().nullable().default(null),startedAt:n.number().finite().optional()}),n.object({adapterSessionId:n.string(),kind:n.literal(ee),parentAdapterSessionId:n.string(),forkPointMessageId:n.null().default(null),model:n.string().nullable().default(null),cwd:n.string().nullable().default(null),startedAt:n.number().finite().optional()}),n.object({adapterSessionId:n.string(),kind:n.literal(f),parentAdapterSessionId:n.string(),forkPointMessageId:n.null().default(null),model:n.string().nullable().default(null),cwd:n.string().nullable().default(null),startedAt:n.number().finite().optional()})]);function C(e){return ce.parse(e.payload)}function w(e,t,n,r,i,a,o,s){let c=x(e);return{externalSessionId:e.adapterSessionId,source:t,cwd:n,...S(`logFilePath`,r),...S(`startedAt`,i),...S(`adapterId`,a),...S(`clientId`,o),...S(`isSidechain`,s),...c}}function T(e,t,n){let r={adapterSessionId:e.adapterSessionId,model:t,cwd:n};switch(e.lineage.kind){case`root`:return{...r,kind:`root`,parentAdapterSessionId:null,forkPointMessageId:null};case`fork`:if(e.lineage.parentAdapterSessionId==null)throw Error(`Fork segment ${e.adapterSessionId} missing parentAdapterSessionId`);if(e.lineage.forkPointMessageId==null)throw Error(`Fork segment ${e.adapterSessionId} missing forkPointMessageId`);return{...r,kind:`fork`,parentAdapterSessionId:e.lineage.parentAdapterSessionId,forkPointMessageId:e.lineage.forkPointMessageId};case`subagent`:if(e.lineage.parentAdapterSessionId==null)throw Error(`Subagent segment ${e.adapterSessionId} missing parentAdapterSessionId`);return{...r,kind:`subagent`,parentAdapterSessionId:e.lineage.parentAdapterSessionId,forkPointMessageId:null};case`compress`:if(e.lineage.parentAdapterSessionId==null)throw Error(`Compress segment ${e.adapterSessionId} missing parentAdapterSessionId`);return{...r,kind:`compress`,parentAdapterSessionId:e.lineage.parentAdapterSessionId,forkPointMessageId:null};default:{let t=e.lineage.kind;throw Error(`Unknown lineage kind: ${String(t)}`)}}}async function E(e,t){let{events:n}=await e.request(y.getByIds,{sessionId:t.sessionId,eventIds:[t.eventId]});if(!(n.length>0))try{await e.request(y.append,{event:{sessionId:t.sessionId,eventId:t.eventId,timestamp:t.timestamp,type:`session.compacted`,payload:{trigger:t.trigger,preTokens:t.preTokens,summary:t.summary,compressChildSessionId:t.compressChildSessionId}}})}catch(n){let{events:r}=await e.request(y.getByIds,{sessionId:t.sessionId,eventIds:[t.eventId]});if(r.length>0)return;throw n}}const D=new Map,O=`MAKAIO_GLOBSTAR_DIR`,k=`MAKAIO_GLOBSTAR`,A=`MAKAIO_STAR`;function j(e){return e.replace(/[\\/]+/g,`/`).replace(/^\.\/+/,``)}function le(e,t){let n=j(e),r=j(t),a=r.includes(`/`)?n:i(n);if(r.length>200)return!1;if(!r.includes(`*`))return a===r;let o=0;for(let e of r)if(e===`*`&&(o+=1,o>64))return!1;let s=D.get(r);if(s)return D.delete(r),D.set(r,s),s.test(a);let c=r.replace(/\*\*\//g,O).replace(/\*\*/g,k).replace(/\*/g,A).replace(/[.+^${}()|[\]\\]/g,`\\$&`).replaceAll(O,`(?:.*/)?`).replaceAll(k,`.*`).replaceAll(A,`[^/]*`),l=RegExp(`^${c}$`);if(D.size>=512){let e=D.keys().next();e.done||D.delete(e.value)}return D.set(r,l),l.test(a)}async function M(e,t,n=e){let i=[];try{let a=await r.readdir(e,{withFileTypes:!0});for(let r of a){let a=s(e,r.name);if(r.isDirectory()){let e=await M(a,t,n);i.push(...e)}else if(r.isFile()){if(!le(c(n,a).split(u).join(`/`),t))continue;i.push(a)}}}catch{}return i}function ue(e,t,n){if(e!==void 0){if(o(e))return e;if(t&&o(t))return l(a(t),e);if(n&&o(n))return l(n,e)}}function N(e,t,n=!0,r){let i=[];if(n){let n=e.split(`
2
+ `).filter(e=>e.trim());for(let e of n){let n=t.parseRecord(e,r);n&&i.push(n)}}else{let n=t.parseRecord(e,r);n&&i.push(n)}return i}function de(e,n){return e.on(t.scan,async t=>{let{adapterName:i}=t.payload,a=n(i);if(!a){t.setResult({adapterName:i,sessionsFound:0,newSessions:0});return}let{importer:o,logFilePattern:s,adapterName:c}=a,l=o.getLogDirectory();try{await r.access(l)}catch{t.setResult({adapterName:i,sessionsFound:0,newSessions:0});return}let u=s.endsWith(`.jsonl`),d=await M(l,s),f=0,p=0;for(let t of d)try{let n=N(await r.readFile(t,`utf8`),o,u,t);if(n.length===0)continue;let i=C(o.extractSessionContext(n).sessionEvent);f++;let{created:a}=await e.request(b.importUpsert,w(i,c,i.cwd,t,i.startedAt));a&&p++}catch(e){console.warn(`[LogImportRegistry] Failed to process ${t}:`,e instanceof Error?e.message:e)}t.setResult({adapterName:i,sessionsFound:f,newSessions:p})})}async function P(e,t,n,i,a,o,s){try{let o=await r.stat(a),c=o.size===i,l=t.extractSessionContext(n);t.processRecords(n,l);let u={adapterSessionId:s,model:l.model,cwd:l.cwd,sessionEvent:l.sessionEvent,startedEvent:l.startedEvent,state:t.serializeState(l.state)};await e.request(v.set,{filePath:a,bytesRead:i,lastModified:c?o.mtime.toISOString():new Date(0).toISOString(),sessionContext:u})}catch(e){console.warn(`[importFromFileContent] Failed to persist import cursor`,{adapterName:o,adapterSessionId:s,filePath:a,error:e instanceof Error?e.message:String(e),stack:e instanceof Error?e.stack:void 0})}}async function F(e,t,n,r,i){let a=i.find(e=>e.origin===`compact`),o=a?.contentText??null,s=r.timestamp??a?.timestamp??Date.now();await E(e,{sessionId:t,eventId:`session-compacted:${t}:${n}`,timestamp:s,trigger:r.trigger,preTokens:r.preTokens,summary:o,compressChildSessionId:n})}async function I(e,t,n){for(let r of n)await e.request(ae.upsertByAdapterMessageId,{sessionId:t,turnId:null,adapterMessageId:r.adapterMessageId,role:r.role,contentText:r.contentText,blocks:r.blocks,agentId:r.agentId,adapterSessionId:r.adapterSessionId,timestamp:r.timestamp,...r.origin!==void 0&&{origin:r.origin}})}function L(e){return{adapterMessageId:e.adapterMessageId,role:e.role,contentText:e.contentText,blocks:e.blocks,agentId:e.agentId,adapterSessionId:e.adapterSessionId,timestamp:e.timestamp,...e.origin!==void 0&&{origin:e.origin}}}async function R(e,t,n,r,i){let a=new Map(n.messages.map(e=>[e.adapterMessageId,e])),o=new Set,s=0;for(let[n,c]of r.entries()){let l=[],u=new Set;for(let e of c.adapterMessageIds){let t=a.get(e);if(t===void 0){console.warn(`[importSegmentTree] Turn ${n+1}/${r.length} references an unknown member; skipping it`);continue}u.add(e),l.push(L(t))}if(!u.has(c.turnAnchorId)){console.warn(`[importSegmentTree] Turn ${n+1}/${r.length} is missing its anchor; skipping turn`);continue}(await oe(e,{sessionId:t,turnAnchorId:c.turnAnchorId,startedAt:c.startedAt,completedAt:c.completedAt,status:c.status??`completed`,ingestionMarker:i,messages:l})).created&&(s+=1);for(let e of u)o.add(e)}return{turnMemberIds:o,createdTurnCount:s}}async function z(e,t,n,r){let i=n.ingestionMarker??`backfill`,a=T(t,n.model,n.cwd),o=t.messages.length>0?t.messages.reduce((e,t)=>Math.min(e,t.timestamp),1/0):void 0,s=await e.requestOptional(b.getByAdapterSessionId,{adapterSessionId:a.adapterSessionId,source:n.adapterName});if(s.handled&&s.data.session!==null){let e=s.data.session;if(se(e))return{sessionId:e.sessionId,messageCount:0,turnCount:0}}let{sessionId:c}=await e.request(b.importUpsert,w(a,n.adapterName,n.cwd,n.logFilePath,o,n.adapterId,void 0,t.isSidechain)),l=0;if(t.turns!==void 0&&t.turns.length>0){let{turnMemberIds:n,createdTurnCount:r}=await R(e,c,t,t.turns,i);l+=r,await I(e,c,t.messages.filter(e=>!n.has(e.adapterMessageId)))}else await I(e,c,t.messages);r!==void 0&&t.compaction!==void 0&&await F(e,r,c,t.compaction,t.messages);let u=t.messages.length,d={adapterId:n.adapterId,adapterName:n.adapterName,model:n.model,cwd:n.cwd,logFilePath:null,ingestionMarker:i};for(let n of t.children??[]){let t=await z(e,n,d,c);u+=t.messageCount,l+=t.turnCount}return await e.request(b.updateImportStatus,{sessionId:c,importStatus:`imported`}),{sessionId:c,messageCount:u,turnCount:l}}async function B(e,t,n){let r=C(t.sessionEvent);return z(e,ie(t),{adapterId:n.adapterId,adapterName:n.adapterName,model:r.model,cwd:r.cwd,logFilePath:n.logFilePath,ingestionMarker:n.ingestionMarker})}async function V(e){let{bus:t,importer:n,content:r,isJsonl:i,adapterName:a,adapterId:o,sourceFilePath:s,persistedLogFilePath:c}=e,l=N(r,n,i,s);if(l.length===0)throw Error(`No valid records found`);let u=n.processLogFile(l),d=ue(c,s,C(u.sessionEvent).cwd),{sessionId:f,messageCount:p,turnCount:m}=await B(t,u,{adapterId:o,adapterName:a,logFilePath:d,ingestionMarker:e.ingestionMarker});return d!==void 0&&await P(t,n,l,Buffer.byteLength(r,`utf8`),d,a,u.adapterSessionId),{sessionId:f,messageCount:p,turnCount:m}}function H(e,n){return e.on(t.uploadFiles,async t=>{let{adapterName:r,files:i}=t.payload,a=n(r);if(!a){t.setResult({adapterName:r,filesProcessed:i.length,sessionsImported:0,errors:i.map(e=>({filename:e.filename,error:`No importer registered for this adapter`}))});return}let{importer:o,logFilePattern:s,adapterName:c,id:l}=a,u=s.endsWith(`.jsonl`),d=0,f=[];for(let t of i)try{await V({bus:e,importer:o,content:Buffer.from(t.contentBase64,`base64`).toString(`utf8`),isJsonl:u,adapterName:c,adapterId:l,sourceFilePath:t.filename}),d++}catch(e){f.push({filename:t.filename,error:e instanceof Error?e.message:String(e)})}t.setResult({adapterName:r,filesProcessed:i.length,sessionsImported:d,errors:f})})}function U(e,n){return e.on(t.importSession,async t=>{let{adapterSessionId:i,adapterName:a,ingestionMarker:o}=t.payload,{session:s}=await e.request(b.getByAdapterSessionId,{adapterSessionId:i,source:a});if(!s)throw Error(`Session not found for external ID: ${i}`);if(s.source!==a)throw Error(`Session '${i}' belongs to adapter '${s.source}', not '${a}'`);if(!s.logFilePath)throw Error(`No log file path recorded for session with external ID '${i}'. Re-run a discovery scan to populate the file path.`);let c=n(a);if(!c)throw Error(`No importer registered for adapter '${a}'`);let{importer:l,logFilePattern:u,adapterName:d,id:f}=c,p=u.endsWith(`.jsonl`),{sessionId:m,messageCount:h}=await V({bus:e,importer:l,content:await r.readFile(s.logFilePath,`utf8`),isJsonl:p,adapterName:d,adapterId:f,sourceFilePath:s.logFilePath,persistedLogFilePath:s.logFilePath,ingestionMarker:o??`backfill`});t.setResult({sessionId:m,messageCount:h})})}const W=new Map;async function fe(e,t,n){let{filePath:i,adapterName:a}=n,o=t(a);if(o===void 0)return{status:`skipped`,reason:`no-importer`};try{await r.stat(i)}catch{return{status:`skipped`,reason:`file-missing`}}let s=await r.readFile(i,`utf8`),c=o.logFilePattern.endsWith(`.jsonl`),{sessionId:l,messageCount:u,turnCount:d}=await V({bus:e,importer:o.importer,content:s,isJsonl:c,adapterName:o.adapterName,adapterId:o.id,sourceFilePath:i,persistedLogFilePath:i,ingestionMarker:n.ingestionMarker??`live`});return{status:`imported`,sessionId:l,messageCount:u,turnCount:d}}function G(e,n){return e.on(t.importFile,async t=>{let{filePath:r}=t.payload,i=(W.get(r)??Promise.resolve()).then(()=>fe(e,n,t.payload)),a=i.then(()=>void 0,()=>void 0);W.set(r,a),a.then(()=>{W.get(r)===a&&W.delete(r)}),t.setResult(await i)})}function K(e){return e.hasAdapterContribution?`adapter`:`extension`}function pe(e){if(!e||typeof e!=`object`)return!1;let t=e,n=t.registration;return typeof t.id==`string`&&typeof t.displayName==`string`&&typeof t.adapterName==`string`&&!!n&&typeof n==`object`&&typeof n.LogImporterClass==`function`&&typeof n.logFilePattern==`string`&&(n.LogOrchestratorClass===void 0||typeof n.LogOrchestratorClass==`function`)&&(n.LogDiscoveryOrchestratorClass===void 0||typeof n.LogDiscoveryOrchestratorClass==`function`)}function me(e,t,n){return{enabled:n?.enabled??!0,pollIntervalMs:n?.pollIntervalMs,eventsPerSecond:n?.eventsPerSecond,adapterId:e,adapterName:t,checkMakaioManaged:n?.checkMakaioManaged}}function he(e,t,n,r,i){if(!r&&!i)return null;let a=me(e,t,n);return e=>a.enabled?e===`discover`&&i?new i(a):e===`import`&&r?new r(a):null:null}async function ge(e,n,r,i){try{let a=await r.requestOptional(t.getMode,{adapterName:n});if(!a.handled)return;let{mode:o}=a.data;if(o===`disabled`)return;await i(e,o)}catch(e){console.warn(`[LogImport] Failed to restore persisted mode for '${n}':`,e)}}async function q(e,t,n){if(!pe(e)||n.getImporter(e.id)!==void 0)return;await n.register({id:e.id,adapterName:e.adapterName,displayName:e.displayName,source:K({hasAdapterContribution:!0}),importer:new e.registration.LogImporterClass({adapterId:e.id,adapterName:e.adapterName}),logFilePattern:e.registration.logFilePattern,clientId:e.registration.clientId});let r=he(e.id,e.adapterName,e.logImportConfig,e.registration.LogOrchestratorClass,e.registration.LogDiscoveryOrchestratorClass);r&&n.setOrchestratorFactory(e.id,r),await ge(e.id,e.adapterName,t,(e,t)=>n.switchMode(e,t))}async function _e(e,t,n){let r=e.on(p.register,async t=>{await q(t.payload.provider,e,n)},{filter:{capabilityId:`log-import`}});for(let r of t?.getProviders(`log-import`)??[])await q(r,e,n);return r}async function J(e,t){let n=e.get(t);if(n)try{n.orchestrator.isRunning()&&await n.orchestrator.stop()}finally{try{await n.orchestrator.dispose()}finally{e.delete(t)}}}async function ve(e,t){try{await e.start()}catch(n){try{try{e.isRunning()&&await e.stop()}finally{await e.dispose()}}catch(e){console.warn(`[LogImportRegistry] Failed to clean up orchestrator after start failure for '${t}'.`,e instanceof Error?e.message:String(e))}throw n}}var Y=class{bus;capabilityService;registrations=new Map;orchestrators=new Map;cleanupHandlers=[];initialized=!1;constructor(e){this.bus=e?.bus??d,this.capabilityService=e?.capabilityService}async init(){if(this.initialized)return;let e=this.bus.on(t.listImporters,e=>{let t=this.listImporters();e.setResult({importers:t})});this.cleanupHandlers.push(e);let n=de(this.bus,e=>this.getImporterByAdapterName(e));this.cleanupHandlers.push(n);let r=H(this.bus,e=>this.getImporterByAdapterName(e));this.cleanupHandlers.push(r);let i=U(this.bus,e=>this.getImporterByAdapterName(e));this.cleanupHandlers.push(i);let a=G(this.bus,e=>this.getImporterByAdapterName(e));this.cleanupHandlers.push(a);let o=await _e(this.bus,this.capabilityService,this);this.cleanupHandlers.push(o),this.initialized=!0}async register(e){if(this.registrations.has(e.id))throw Error(`Log importer '${e.id}' is already registered`);this.registrations.set(e.id,e)}async unregister(e){if(!this.registrations.has(e))throw Error(`Log importer '${e}' is not registered`);await J(this.orchestrators,e),this.registrations.delete(e)}async startImporter(e){if(!this.registrations.get(e))throw Error(`Log importer '${e}' is not registered`);let t=this.orchestrators.get(e);if(!t)throw Error(`No orchestrator available for '${e}'. Orchestrators must be created and provided by the adapter or extension before starting.`);t.orchestrator.isRunning()||(await t.orchestrator.start(),t.isManaged=!0)}async stopImporter(e){let t=this.orchestrators.get(e);t&&(t.orchestrator.isRunning()&&await t.orchestrator.stop(),t.isManaged=!1)}async switchMode(e,t){let n=this.registrations.get(e);if(!n)throw Error(`Log importer '${e}' is not registered`);if(await J(this.orchestrators,e),t===`disabled`||!n.orchestratorFactory)return;let r=n.orchestratorFactory(t);r&&(await ve(r,e),this.orchestrators.set(e,{orchestrator:r,isManaged:!0}))}async startDiscovery(e){return this.switchMode(e,`discover`)}setOrchestratorFactory(e,t){let n=this.registrations.get(e);if(!n)throw Error(`Cannot set orchestrator factory for unregistered importer '${e}'`);this.registrations.set(e,{...n,orchestratorFactory:t})}listImporters(){let e=[];for(let[,t]of this.registrations){let n=this.orchestrators.get(t.id)?.orchestrator.isRunning()??!1;e.push({id:t.id,adapterName:t.adapterName,displayName:t.displayName,source:t.source,logFilePattern:t.logFilePattern,isRunning:n,supportsManualImport:t.supportsManualImport??!0,...t.clientId!==void 0&&{clientId:t.clientId}})}return e}getImporter(e){let t=this.registrations.get(e);return t?{...t}:void 0}getImporterByAdapterName(e){for(let t of this.registrations.values())if(t.adapterName===e)return{...t}}detectImporter(e){let t,n=0;for(let r of this.registrations.values()){let i=r.importer.canHandle(e);if(i===!1)continue;let a=i===!0?1:i.confidence;a>n&&(n=a,t=r)}return t}async registerOrchestrator(e,t){if(!this.registrations.has(e))throw Error(`Cannot register orchestrator for unregistered importer '${e}'`);await J(this.orchestrators,e),this.orchestrators.set(e,{orchestrator:t,isManaged:!1})}async destroy(){if(!(!this.initialized&&this.orchestrators.size===0&&this.cleanupHandlers.length===0)){for(let[e]of this.orchestrators)await J(this.orchestrators,e);for(let e of this.cleanupHandlers)e();this.cleanupHandlers.length=0,this.initialized=!1}}};const X=te(`log-import-registry`),ye={name:X.name,displayName:`Log Import Registry`,version:`0.1.0`,critical:!0,namespaces:[e],create:e=>new Y({bus:e.bus})};function be(e,t,n){return{enabled:n?.enabled??!0,pollIntervalMs:n?.pollIntervalMs,eventsPerSecond:n?.eventsPerSecond,adapterId:e,adapterName:t,checkMakaioManaged:n?.checkMakaioManaged}}function xe(e,t,n){if(!n.LogOrchestratorClass&&!n.LogDiscoveryOrchestratorClass)return null;let r=be(e,t,n.logImportConfig);return e=>r.enabled?e===`discover`&&n.LogDiscoveryOrchestratorClass?new n.LogDiscoveryOrchestratorClass(r):e===`import`&&n.LogOrchestratorClass?new n.LogOrchestratorClass(r):null:null}function Se(){let e=new Map;return{filter:e=>!!e.logImport,processActivated:async(t,n,r)=>{let{logImport:i}=n;if(!i)return;let a=r.getService(X);if(!a)throw Error(`[LogImportContributionProcessor] LogImportRegistry is not available. Ensure '${X.name}' is listed as a dependency before activating '${t}'.`);let{adapterName:o,displayName:s,config:c}=i,l=c,u=`package:${t}`,d=K({hasAdapterContribution:!!n.adapters?.length}),f=new l.LogImporterClass({adapterId:u,adapterName:o});await a.register({id:u,adapterName:o,displayName:s,source:d,importer:f,logFilePattern:l.logFilePattern??``,clientId:l.clientId,supportsManualImport:l.supportsManualImport});try{let e=xe(u,o,l);e&&a.setOrchestratorFactory(u,e)}catch(e){try{await a.unregister(u)}catch(e){console.error(`[LogImportContributionProcessor] Rollback of log importer '${u}' failed:`,e)}throw e}console.info(`[LogImportContributionProcessor] Registered log importer '${o}' from package: ${t}`),e.set(u,async()=>{try{await a.unregister(u)}catch(e){console.error(`[LogImportContributionProcessor] Failed to unregister log importer '${u}' during cleanup:`,e)}})},processStopped:async t=>{let n=`package:${t}`,r=e.get(n);r&&(e.delete(n),await r())}}}const Ce={linked:`linked`,persisted:`persisted`,finalized:`finalized`},Z=g(`log_import_settings`,e=>({adapterName:e.text(`adapter_name`).primaryKey(),mode:e.textEnum(`mode`,{enum:[`disabled`,`discover`,`import`]}).notNull().default(`disabled`),createdAt:e.epochMs(`created_at`).notNull(),updatedAt:e.epochMs(`updated_at`).notNull()})),we=Z.sqlite,Te=Z.postgres,Q=ne({logImportSettings:we},{logImportSettings:Te});function $(e){return{adapterName:e.adapterName,mode:e.mode,createdAt:e.createdAt,updatedAt:e.updatedAt}}function Ee(e){let{bus:n,db:r}=e,{logImportSettings:i}=_(r,Q);return n.on(t.getMode,async e=>{let{adapterName:t}=e.payload,[n]=await r.select().from(i).where(re(i.adapterName,t)).limit(1);e.setResult({mode:n?.mode??`disabled`})})}function De(e){let{bus:n,db:r}=e,{logImportSettings:i}=_(r,Q);return n.on(t.setMode,async e=>{let{adapterName:t,mode:n}=e.payload,a=Date.now();await r.insert(i).values({adapterName:t,mode:n,createdAt:a,updatedAt:a}).onConflictDoUpdate({target:i.adapterName,set:{mode:n,updatedAt:a}}),e.setResult({success:!0})})}function Oe(e){let{bus:n,db:r}=e,{logImportSettings:i}=_(r,Q);return n.on(t.listSettings,async e=>{let t=await r.select().from(i);e.setResult({settings:t.map($)})})}function ke(e,t){let n={bus:e,db:t},r=[Ee(n),De(n),Oe(n)];return()=>r.forEach(e=>e())}export{Ce as ImportPhase,e as LogImportNamespace,Y as LogImportRegistry,X as LogImportRegistryToken,t as LogImportSubjects,E as appendSessionCompactedEvent,Se as createLogImportContributionProcessor,V as importFromFileContent,ye as logImportRegistryPackage,B as persistImportResultTree,ke as registerDrizzleLogImportStorage,G as registerImportFileHandler,$ as rowToSettings};
@@ -1,3 +1,3 @@
1
- import { n as IMPORT_LAST_SCAN_CATEGORY, r as LogImportMode, t as LogImporterInfo } from "../../index-wfSedMR9.mjs";
1
+ import { n as IMPORT_LAST_SCAN_CATEGORY, r as LogImportMode, t as LogImporterInfo } from "../../index-D7rWAEY0.mjs";
2
2
  import { LogImportSubjects } from "./namespace.mjs";
3
3
  export { IMPORT_LAST_SCAN_CATEGORY, type LogImportMode, LogImportSubjects, type LogImporterInfo };
@@ -1 +1 @@
1
- import{n as e}from"../../schemas-ArqQTC0Q.mjs";import{LogImportSubjects as t}from"./namespace.mjs";export{e as IMPORT_LAST_SCAN_CATEGORY,t as LogImportSubjects};
1
+ import{n as e}from"../../schemas-DZGnr9Tl.mjs";import{LogImportSubjects as t}from"./namespace.mjs";export{e as IMPORT_LAST_SCAN_CATEGORY,t as LogImportSubjects};
@@ -74,12 +74,13 @@ declare const LogImportNamespace: _$_makaio_core0.BusNamespaceDefinition<"log-im
74
74
  adapterName: _$zod.ZodString;
75
75
  displayName: _$zod.ZodString;
76
76
  source: _$zod.ZodEnum<{
77
- extension: "extension";
78
77
  adapter: "adapter";
78
+ extension: "extension";
79
79
  }>;
80
80
  logFilePattern: _$zod.ZodString;
81
81
  isRunning: _$zod.ZodBoolean;
82
82
  supportsManualImport: _$zod.ZodDefault<_$zod.ZodBoolean>;
83
+ clientId: _$zod.ZodOptional<_$zod.ZodString>;
83
84
  }, _$zod_v4_core0.$strip>>;
84
85
  }, _$zod_v4_core0.$strip>;
85
86
  };
@@ -116,12 +117,38 @@ declare const LogImportNamespace: _$_makaio_core0.BusNamespaceDefinition<"log-im
116
117
  request: _$zod.ZodObject<{
117
118
  adapterSessionId: _$zod.ZodString;
118
119
  adapterName: _$zod.ZodString;
120
+ ingestionMarker: _$zod.ZodOptional<_$zod.ZodEnum<{
121
+ live: "live";
122
+ backfill: "backfill";
123
+ }>>;
119
124
  }, _$zod_v4_core0.$strip>;
120
125
  response: _$zod.ZodObject<{
121
126
  sessionId: _$zod.ZodString;
122
127
  messageCount: _$zod.ZodNumber;
123
128
  }, _$zod_v4_core0.$strip>;
124
129
  };
130
+ importFile: {
131
+ request: _$zod.ZodObject<{
132
+ filePath: _$zod.ZodString;
133
+ adapterName: _$zod.ZodString;
134
+ ingestionMarker: _$zod.ZodOptional<_$zod.ZodEnum<{
135
+ live: "live";
136
+ backfill: "backfill";
137
+ }>>;
138
+ }, _$zod_v4_core0.$strip>;
139
+ response: _$zod.ZodDiscriminatedUnion<[_$zod.ZodObject<{
140
+ status: _$zod.ZodLiteral<"imported">;
141
+ sessionId: _$zod.ZodString;
142
+ messageCount: _$zod.ZodNumber;
143
+ turnCount: _$zod.ZodNumber;
144
+ }, _$zod_v4_core0.$strip>, _$zod.ZodObject<{
145
+ status: _$zod.ZodLiteral<"skipped">;
146
+ reason: _$zod.ZodEnum<{
147
+ "no-importer": "no-importer";
148
+ "file-missing": "file-missing";
149
+ }>;
150
+ }, _$zod_v4_core0.$strip>], "status">;
151
+ };
125
152
  getMode: {
126
153
  request: _$zod.ZodObject<{
127
154
  adapterName: _$zod.ZodString;
@@ -234,12 +261,13 @@ declare const LogImportSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.Fla
234
261
  adapterName: _$zod.ZodString;
235
262
  displayName: _$zod.ZodString;
236
263
  source: _$zod.ZodEnum<{
237
- extension: "extension";
238
264
  adapter: "adapter";
265
+ extension: "extension";
239
266
  }>;
240
267
  logFilePattern: _$zod.ZodString;
241
268
  isRunning: _$zod.ZodBoolean;
242
269
  supportsManualImport: _$zod.ZodDefault<_$zod.ZodBoolean>;
270
+ clientId: _$zod.ZodOptional<_$zod.ZodString>;
243
271
  }, _$zod_v4_core0.$strip>>;
244
272
  }, _$zod_v4_core0.$strip>;
245
273
  };
@@ -276,12 +304,38 @@ declare const LogImportSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.Fla
276
304
  request: _$zod.ZodObject<{
277
305
  adapterSessionId: _$zod.ZodString;
278
306
  adapterName: _$zod.ZodString;
307
+ ingestionMarker: _$zod.ZodOptional<_$zod.ZodEnum<{
308
+ live: "live";
309
+ backfill: "backfill";
310
+ }>>;
279
311
  }, _$zod_v4_core0.$strip>;
280
312
  response: _$zod.ZodObject<{
281
313
  sessionId: _$zod.ZodString;
282
314
  messageCount: _$zod.ZodNumber;
283
315
  }, _$zod_v4_core0.$strip>;
284
316
  };
317
+ importFile: {
318
+ request: _$zod.ZodObject<{
319
+ filePath: _$zod.ZodString;
320
+ adapterName: _$zod.ZodString;
321
+ ingestionMarker: _$zod.ZodOptional<_$zod.ZodEnum<{
322
+ live: "live";
323
+ backfill: "backfill";
324
+ }>>;
325
+ }, _$zod_v4_core0.$strip>;
326
+ response: _$zod.ZodDiscriminatedUnion<[_$zod.ZodObject<{
327
+ status: _$zod.ZodLiteral<"imported">;
328
+ sessionId: _$zod.ZodString;
329
+ messageCount: _$zod.ZodNumber;
330
+ turnCount: _$zod.ZodNumber;
331
+ }, _$zod_v4_core0.$strip>, _$zod.ZodObject<{
332
+ status: _$zod.ZodLiteral<"skipped">;
333
+ reason: _$zod.ZodEnum<{
334
+ "no-importer": "no-importer";
335
+ "file-missing": "file-missing";
336
+ }>;
337
+ }, _$zod_v4_core0.$strip>], "status">;
338
+ };
285
339
  getMode: {
286
340
  request: _$zod.ZodObject<{
287
341
  adapterName: _$zod.ZodString;
@@ -1 +1 @@
1
- import{t as e}from"../../schemas-ArqQTC0Q.mjs";import{createBusNamespace as t}from"@makaio/framework/core";const n=t(`log-import`,e),r=n.subjects;export{n as LogImportNamespace,r as LogImportSubjects};
1
+ import{t as e}from"../../schemas-DZGnr9Tl.mjs";import{createBusNamespace as t}from"@makaio/framework/core";const n=t(`log-import`,e),r=n.subjects;export{n as LogImportNamespace,r as LogImportSubjects};
@@ -90,12 +90,13 @@ declare const LogImportSchemas: {
90
90
  adapterName: z.ZodString;
91
91
  displayName: z.ZodString;
92
92
  source: z.ZodEnum<{
93
- extension: "extension";
94
93
  adapter: "adapter";
94
+ extension: "extension";
95
95
  }>;
96
96
  logFilePattern: z.ZodString;
97
97
  isRunning: z.ZodBoolean;
98
98
  supportsManualImport: z.ZodDefault<z.ZodBoolean>;
99
+ clientId: z.ZodOptional<z.ZodString>;
99
100
  }, z.core.$strip>>;
100
101
  }, z.core.$strip>;
101
102
  };
@@ -139,12 +140,55 @@ declare const LogImportSchemas: {
139
140
  request: z.ZodObject<{
140
141
  adapterSessionId: z.ZodString;
141
142
  adapterName: z.ZodString;
143
+ ingestionMarker: z.ZodOptional<z.ZodEnum<{
144
+ live: "live";
145
+ backfill: "backfill";
146
+ }>>;
142
147
  }, z.core.$strip>;
143
148
  response: z.ZodObject<{
144
149
  sessionId: z.ZodString;
145
150
  messageCount: z.ZodNumber;
146
151
  }, z.core.$strip>;
147
152
  };
153
+ /**
154
+ * Import a transcript file by path, addressable without prior discovery.
155
+ *
156
+ * Subject: `log-import.importFile`
157
+ * Type: Request (RPC)
158
+ * Purpose: Parses the given transcript file with the named importer and
159
+ * persists the resulting segment tree (messages + turns).
160
+ *
161
+ * **Graceful-absence contract:** unlike `importSession`, this subject NEVER
162
+ * throws for a missing importer registration — framework-only hosts (no
163
+ * product importers contributed) receive a `skipped` status with reason
164
+ * `no-importer`. It is addressable by file path directly (no prior
165
+ * discovery stub required) and performs a full re-parse from byte 0,
166
+ * relying on message/turn idempotency (import cursors do not persist parser
167
+ * state across restarts). Concurrent calls for the same `filePath` are
168
+ * serialized by the handler.
169
+ */
170
+ importFile: {
171
+ request: z.ZodObject<{
172
+ filePath: z.ZodString;
173
+ adapterName: z.ZodString;
174
+ ingestionMarker: z.ZodOptional<z.ZodEnum<{
175
+ live: "live";
176
+ backfill: "backfill";
177
+ }>>;
178
+ }, z.core.$strip>;
179
+ response: z.ZodDiscriminatedUnion<[z.ZodObject<{
180
+ status: z.ZodLiteral<"imported">;
181
+ sessionId: z.ZodString;
182
+ messageCount: z.ZodNumber;
183
+ turnCount: z.ZodNumber;
184
+ }, z.core.$strip>, z.ZodObject<{
185
+ status: z.ZodLiteral<"skipped">;
186
+ reason: z.ZodEnum<{
187
+ "no-importer": "no-importer";
188
+ "file-missing": "file-missing";
189
+ }>;
190
+ }, z.core.$strip>], "status">;
191
+ };
148
192
  /**
149
193
  * Resolve the effective global import mode for a given adapter.
150
194
  *
@@ -1 +1 @@
1
- import{t as e}from"../../schemas-ArqQTC0Q.mjs";export{e as LogImportSchemas};
1
+ import{t as e}from"../../schemas-DZGnr9Tl.mjs";export{e as LogImportSchemas};
@@ -1,2 +1,2 @@
1
- import { a as registerCompressHandler, i as registerForkHandler, n as routeToAgents, o as registerAttachHandler, r as registerMergeHandler, s as registerAbandonHandler, t as routeToAgentsCore } from "../../../index-gAFwNiJT.mjs";
1
+ import { a as registerCompressHandler, i as registerForkHandler, n as routeToAgents, o as registerAttachHandler, r as registerMergeHandler, s as registerAbandonHandler, t as routeToAgentsCore } from "../../../index-BYfSAJRC.mjs";
2
2
  export { registerAbandonHandler, registerAttachHandler, registerCompressHandler, registerForkHandler, registerMergeHandler, routeToAgents, routeToAgentsCore };
@@ -1 +1 @@
1
- import{a as e,c as t,i as n,l as r,r as i,t as a,u as o}from"../../../handlers-BAycjV02.mjs";export{t as registerAbandonHandler,o as registerAttachHandler,e as registerCompressHandler,n as registerForkHandler,i as registerMergeHandler,a as routeToAgents,r as routeToAgentsCore};
1
+ import{a as e,c as t,i as n,l as r,r as i,t as a,u as o}from"../../../handlers-v47Gbsr1.mjs";export{t as registerAbandonHandler,o as registerAttachHandler,e as registerCompressHandler,n as registerForkHandler,i as registerMergeHandler,a as routeToAgents,r as routeToAgentsCore};
@@ -1,10 +1,10 @@
1
- import { $ as fetchMessageCountsBySession, A as registerMemoryTurnStorage, At as RecoveryConfig, B as registerMemorySessionEventStorage, Bt as findTurnByAgent, C as messages, Ct as registerGetStatusCountsHandler, D as SelectTurn, Dt as ContextWindowTrackerConfig, E as InsertTurn, Et as AgentContextState, F as importCursorsDual, Ft as verifyAndRecoverAgents, G as getSessionAncestorChain, Gt as TurnContextEnricher, H as SelectSessionEvent, Ht as resolveTargetAgents, I as EventTransform, It as buildRecoveryContext, J as mapAgentsBySession, Jt as SessionOrchestrator, K as SessionPreviewMaps, Kt as AdapterRegistry, L as SessionLogger, Lt as resolveAdapterId, M as EmbeddingIndexManager, Mt as ensureAgentCwd, N as registerDrizzleImportCursorStorage, Nt as ensureAgentModel, O as turns, Ot as SessionContextWindowState, P as importCursors, Pt as recoverAgent, Q as fetchAgentsBySession, R as SessionLoggerOptions, Rt as resolveExecutionTarget, S as SelectMessage, St as actionRegistry, T as registerDrizzleMessageStorage, Tt as ContextWindowTracker, U as sessionEvents, Ut as extractTextContent, V as InsertSessionEvent, Vt as getOrCreateSession, W as sessionEventsDual, Wt as normalizeToBlocks, X as SearchFilters, Xt as MakaioSessionService, Y as mapToSession, Yt as registerCoreSessionServiceHandlers, Z as SearchSessionRow, _ as messageRoutingDual, _t as normalizeSelectionString, a as kindToBranchKind, at as registerMemoryAgentStorage, b as MessageRoutingSubjects, bt as registerBuiltInActions, c as registerSpawningToolCallResolver, ct as AgentStorageNamespace, d as MakaioSession, dt as createSessionExtensionContext, et as fetchPreviewBySession, f as MakaioSessionConfig, ft as SessionBridge, g as messageRouting, gt as CONNECTOR_SWAP_DEFAULT_PIPELINE, h as SelectMessageRouting, ht as pickFallbackRuntimeOptions, i as ContextAssemblyResult, it as registerDrizzleAgentStorage, j as registerDrizzleTurnStorage, jt as buildRecoveryContextWithPipeline, k as turnsDual, kt as buildTurnInitiator, l as registerCompressLineageResolver, lt as AgentStorageSubjects, m as InsertMessageRouting, mt as FallbackRuntimeOptions, n as buildSessionContext, nt as parseForkTransforms, o as toSessionLineage, ot as registerDrizzleSessionStorage, p as StartTurnOptions, pt as assembleForkContext, q as fetchSessionPreviewMaps, qt as ISessionOrchestrator, r as BuildContextOptions, rt as registerFtsSearchHandler, s as registerSessionDiscoveredHandler, st as registerMemorySessionStorage, t as getFullConversation, tt as mapRowToSession, u as registerParentResolver, ut as SessionExtensionContextImpl, v as registerDrizzleMessageRoutingStorage, vt as resolveAdapterNameById, w as registerMemoryMessageStorage, wt as registerResumeHandler, x as InsertMessage, xt as resetBuiltInActionsRegistration, y as MessageRoutingNamespace, yt as registerListActionsHandler, z as registerDrizzleSessionEventStorage, zt as resolveModelCapabilities } from "../../index-Clqt7Nm3.mjs";
2
- import { a as registerCompressHandler, c as SessionTurnManager, d as Turn, f as TurnConfig, h as TurnStateChange, i as registerForkHandler, l as TurnCompleteCallback, m as TurnResult, n as routeToAgents, o as registerAttachHandler, p as TurnContext, r as registerMergeHandler, s as registerAbandonHandler, t as routeToAgentsCore, u as TurnCompletionResult } from "../../index-gAFwNiJT.mjs";
1
+ import { $ as emitSessionTurnStarted, $t as resolveAdapterId, A as registerMemoryTurnStorage, At as FallbackRuntimeOptions, B as ObservedSessionIngestionPolicyInput, Bt as registerResumeHandler, C as messages, Ct as registerMemorySessionStorage, D as SelectTurn, Dt as createSessionExtensionContext, E as InsertTurn, Et as SessionExtensionContextImpl, F as importCursorsDual, Ft as registerListActionsHandler, G as IngestCompletedTurnParams, Gt as buildTurnInitiator, H as unregisterObservedSessionIngestionPolicyProvider, Ht as AgentContextState, I as IObservedSessionIngestionPolicyProvider, It as registerBuiltInActions, J as ingestCompletedTurn, Jt as ensureAgentCwd, K as IngestCompletedTurnResult, Kt as RecoveryConfig, L as OBSERVED_SESSION_INGESTION_POLICY_CAPABILITY_ID, Lt as resetBuiltInActionsRegistration, M as EmbeddingIndexManager, Mt as CONNECTOR_SWAP_DEFAULT_PIPELINE, N as registerDrizzleImportCursorStorage, Nt as normalizeSelectionString, O as turns, Ot as SessionBridge, P as importCursors, Pt as resolveAdapterNameById, Q as appendSessionLifecycleEvent, Qt as buildRecoveryContext, R as ObservedSessionIngestionPolicyDecision, Rt as actionRegistry, S as SelectMessage, St as registerDrizzleSessionStorage, T as registerDrizzleMessageStorage, Tt as AgentStorageSubjects, U as LogImportTriggerSubjects, Ut as ContextWindowTrackerConfig, V as registerObservedSessionIngestionPolicyProvider, Vt as ContextWindowTracker, W as isPolicyDiscoveredObservedSession, Wt as SessionContextWindowState, X as SessionLifecycleEventArgs, Xt as recoverAgent, Y as EventTransform, Yt as ensureAgentModel, Z as SessionTurnStartedPayload, Zt as verifyAndRecoverAgents, _ as messageRoutingDual, _t as mapRowToSession, a as kindToBranchKind, an as extractTextContent, at as sessionEvents, b as MessageRoutingSubjects, bt as registerDrizzleAgentStorage, c as registerSpawningToolCallResolver, cn as AdapterRegistry, ct as SessionPreviewMaps, d as MakaioSession, dn as registerCoreSessionServiceHandlers, dt as mapToSession, en as resolveExecutionTarget, et as registerSessionLifecycleEventWriters, f as MakaioSessionConfig, fn as MakaioSessionService, ft as SearchFilters, g as messageRouting, gt as fetchPreviewBySession, h as SelectMessageRouting, ht as fetchMessageCountsBySession, i as ContextAssemblyResult, in as resolveTargetAgents, it as SelectSessionEvent, j as registerDrizzleTurnStorage, jt as pickFallbackRuntimeOptions, k as turnsDual, kt as assembleForkContext, l as registerCompressLineageResolver, ln as ISessionOrchestrator, lt as fetchSessionPreviewMaps, m as InsertMessageRouting, mt as fetchAgentsBySession, n as buildSessionContext, nn as findTurnByAgent, nt as registerMemorySessionEventStorage, o as toSessionLineage, on as normalizeToBlocks, ot as sessionEventsDual, p as StartTurnOptions, pt as SearchSessionRow, q as IngestTurnMessage, qt as buildRecoveryContextWithPipeline, r as BuildContextOptions, rn as getOrCreateSession, rt as InsertSessionEvent, s as registerSessionDiscoveredHandler, sn as TurnContextEnricher, st as getSessionAncestorChain, t as getFullConversation, tn as resolveModelCapabilities, tt as registerDrizzleSessionEventStorage, u as registerParentResolver, un as SessionOrchestrator, ut as mapAgentsBySession, v as registerDrizzleMessageRoutingStorage, vt as parseForkTransforms, w as registerMemoryMessageStorage, wt as AgentStorageNamespace, x as InsertMessage, xt as registerMemoryAgentStorage, y as MessageRoutingNamespace, yt as registerFtsSearchHandler, z as ObservedSessionIngestionPolicyImportStatus, zt as registerGetStatusCountsHandler } from "../../index-3J0HZlPH.mjs";
2
+ import { a as registerCompressHandler, c as SessionTurnManager, d as Turn, f as TurnConfig, h as TurnStateChange, i as registerForkHandler, l as TurnCompleteCallback, m as TurnResult, n as routeToAgents, o as registerAttachHandler, p as TurnContext, r as registerMergeHandler, s as registerAbandonHandler, t as routeToAgentsCore, u as TurnCompletionResult } from "../../index-BYfSAJRC.mjs";
3
3
  import { r as buildProviderContext } from "../../index-DtwGhFFQ.mjs";
4
- import { i as SessionStorageSubjects, r as SessionStorageNamespace } from "../../namespace-Bmi5bjm4.mjs";
5
- import { a as agents, c as sessionsDual, o as agentsDual, s as sessions } from "../../schema-Bf_ZNjif.mjs";
6
- import { n as SessionEventStorageSubjects, t as SessionEventStorageNamespace } from "../../namespace-BeMGmLrp.mjs";
7
- import { t as TurnStorageNamespace } from "../../namespace-LUNf8zo5.mjs";
8
- import { n as TurnStorageSubjects } from "../../namespace-BsYKEMd8.mjs";
4
+ import { i as SessionStorageSubjects, r as SessionStorageNamespace } from "../../namespace-DmqoDDRD.mjs";
5
+ import { a as agents, c as sessionsDual, o as agentsDual, s as sessions } from "../../schema-DLNBajAV.mjs";
6
+ import { n as SessionEventStorageSubjects, t as SessionEventStorageNamespace } from "../../namespace-DhDY0juT.mjs";
7
+ import { t as TurnStorageNamespace } from "../../namespace-D1_9WVCo.mjs";
8
+ import { n as TurnStorageSubjects } from "../../namespace-DAj_riOn.mjs";
9
9
  import { i as MessageStorageSubjects, r as MessageStorageNamespace } from "../../namespace-Bm77p82L.mjs";
10
- export { AdapterRegistry, AgentContextState, AgentStorageNamespace, AgentStorageSubjects, BuildContextOptions, CONNECTOR_SWAP_DEFAULT_PIPELINE, ContextAssemblyResult, ContextWindowTracker, ContextWindowTrackerConfig, EmbeddingIndexManager, EventTransform, FallbackRuntimeOptions, ISessionOrchestrator, InsertMessage, InsertMessageRouting, InsertSessionEvent, InsertTurn, MakaioSession, MakaioSessionConfig, MakaioSessionService, MessageRoutingNamespace, MessageRoutingSubjects, MessageStorageNamespace, MessageStorageSubjects, RecoveryConfig, SearchFilters, SearchSessionRow, SelectMessage, SelectMessageRouting, SelectSessionEvent, SelectTurn, SessionBridge, SessionContextWindowState, SessionEventStorageNamespace, SessionEventStorageSubjects, SessionExtensionContextImpl, SessionLogger, SessionLoggerOptions, SessionOrchestrator, SessionPreviewMaps, SessionStorageNamespace, SessionStorageSubjects, SessionTurnManager, StartTurnOptions, Turn, TurnCompleteCallback, TurnCompletionResult, TurnConfig, TurnContext, TurnContextEnricher, TurnResult, TurnStateChange, TurnStorageNamespace, TurnStorageSubjects, actionRegistry, agents, agentsDual, assembleForkContext, buildProviderContext, buildRecoveryContext, buildRecoveryContextWithPipeline, buildSessionContext, buildTurnInitiator, createSessionExtensionContext, ensureAgentCwd, ensureAgentModel, extractTextContent, fetchAgentsBySession, fetchMessageCountsBySession, fetchPreviewBySession, fetchSessionPreviewMaps, findTurnByAgent, getFullConversation, getOrCreateSession, getSessionAncestorChain, importCursors, importCursorsDual, kindToBranchKind, mapAgentsBySession, mapRowToSession, mapToSession, messageRouting, messageRoutingDual, messages, normalizeSelectionString, normalizeToBlocks, parseForkTransforms, pickFallbackRuntimeOptions, recoverAgent, registerAbandonHandler, registerAttachHandler, registerBuiltInActions, registerCompressHandler, registerCompressLineageResolver, registerCoreSessionServiceHandlers, registerDrizzleAgentStorage, registerDrizzleImportCursorStorage, registerDrizzleMessageRoutingStorage, registerDrizzleMessageStorage, registerDrizzleSessionEventStorage, registerDrizzleSessionStorage, registerDrizzleTurnStorage, registerForkHandler, registerFtsSearchHandler, registerGetStatusCountsHandler, registerListActionsHandler, registerMemoryAgentStorage, registerMemoryMessageStorage, registerMemorySessionEventStorage, registerMemorySessionStorage, registerMemoryTurnStorage, registerMergeHandler, registerParentResolver, registerResumeHandler, registerSessionDiscoveredHandler, registerSpawningToolCallResolver, resetBuiltInActionsRegistration, resolveAdapterId, resolveAdapterNameById, resolveExecutionTarget, resolveModelCapabilities, resolveTargetAgents, routeToAgents, routeToAgentsCore, sessionEvents, sessionEventsDual, sessions, sessionsDual, toSessionLineage, turns, turnsDual, verifyAndRecoverAgents };
10
+ export { AdapterRegistry, AgentContextState, AgentStorageNamespace, AgentStorageSubjects, BuildContextOptions, CONNECTOR_SWAP_DEFAULT_PIPELINE, ContextAssemblyResult, ContextWindowTracker, ContextWindowTrackerConfig, EmbeddingIndexManager, EventTransform, FallbackRuntimeOptions, IObservedSessionIngestionPolicyProvider, ISessionOrchestrator, IngestCompletedTurnParams, IngestCompletedTurnResult, IngestTurnMessage, InsertMessage, InsertMessageRouting, InsertSessionEvent, InsertTurn, LogImportTriggerSubjects, MakaioSession, MakaioSessionConfig, MakaioSessionService, MessageRoutingNamespace, MessageRoutingSubjects, MessageStorageNamespace, MessageStorageSubjects, OBSERVED_SESSION_INGESTION_POLICY_CAPABILITY_ID, ObservedSessionIngestionPolicyDecision, ObservedSessionIngestionPolicyImportStatus, ObservedSessionIngestionPolicyInput, RecoveryConfig, SearchFilters, SearchSessionRow, SelectMessage, SelectMessageRouting, SelectSessionEvent, SelectTurn, SessionBridge, SessionContextWindowState, SessionEventStorageNamespace, SessionEventStorageSubjects, SessionExtensionContextImpl, SessionLifecycleEventArgs, SessionOrchestrator, SessionPreviewMaps, SessionStorageNamespace, SessionStorageSubjects, SessionTurnManager, SessionTurnStartedPayload, StartTurnOptions, Turn, TurnCompleteCallback, TurnCompletionResult, TurnConfig, TurnContext, TurnContextEnricher, TurnResult, TurnStateChange, TurnStorageNamespace, TurnStorageSubjects, actionRegistry, agents, agentsDual, appendSessionLifecycleEvent, assembleForkContext, buildProviderContext, buildRecoveryContext, buildRecoveryContextWithPipeline, buildSessionContext, buildTurnInitiator, createSessionExtensionContext, emitSessionTurnStarted, ensureAgentCwd, ensureAgentModel, extractTextContent, fetchAgentsBySession, fetchMessageCountsBySession, fetchPreviewBySession, fetchSessionPreviewMaps, findTurnByAgent, getFullConversation, getOrCreateSession, getSessionAncestorChain, importCursors, importCursorsDual, ingestCompletedTurn, isPolicyDiscoveredObservedSession, kindToBranchKind, mapAgentsBySession, mapRowToSession, mapToSession, messageRouting, messageRoutingDual, messages, normalizeSelectionString, normalizeToBlocks, parseForkTransforms, pickFallbackRuntimeOptions, recoverAgent, registerAbandonHandler, registerAttachHandler, registerBuiltInActions, registerCompressHandler, registerCompressLineageResolver, registerCoreSessionServiceHandlers, registerDrizzleAgentStorage, registerDrizzleImportCursorStorage, registerDrizzleMessageRoutingStorage, registerDrizzleMessageStorage, registerDrizzleSessionEventStorage, registerDrizzleSessionStorage, registerDrizzleTurnStorage, registerForkHandler, registerFtsSearchHandler, registerGetStatusCountsHandler, registerListActionsHandler, registerMemoryAgentStorage, registerMemoryMessageStorage, registerMemorySessionEventStorage, registerMemorySessionStorage, registerMemoryTurnStorage, registerMergeHandler, registerObservedSessionIngestionPolicyProvider, registerParentResolver, registerResumeHandler, registerSessionDiscoveredHandler, registerSessionLifecycleEventWriters, registerSpawningToolCallResolver, resetBuiltInActionsRegistration, resolveAdapterId, resolveAdapterNameById, resolveExecutionTarget, resolveModelCapabilities, resolveTargetAgents, routeToAgents, routeToAgentsCore, sessionEvents, sessionEventsDual, sessions, sessionsDual, toSessionLineage, turns, turnsDual, unregisterObservedSessionIngestionPolicyProvider, verifyAndRecoverAgents };
@@ -1 +1 @@
1
- import{TurnStorageSubjects as e}from"../turn/namespace.mjs";import{agents as t,agentsDual as n,sessions as r,sessionsDual as i}from"./storage/schema.mjs";import{n as a,t as o}from"../../schema-DHlTAy0N.mjs";import{t as s}from"../../schema-D6WAI8OL.mjs";import{i as c,n as l,r as u,t as d}from"../../namespace-C-piH3w4.mjs";import{SessionStorageNamespace as f,SessionStorageSubjects as p}from"./storage/namespace.mjs";import{A as m,C as h,D as g,E as _,F as v,M as y,N as b,O as x,P as S,S as C,T as w,_ as T,a as E,b as D,c as O,d as k,f as A,g as j,h as M,i as N,j as P,k as F,l as I,m as L,n as R,o as z,p as B,r as V,s as H,t as U,u as W,v as G,w as K,x as q,y as J}from"../../handlers-BAycjV02.mjs";import{A as Y,B as X,C as Z,D as Q,E as $,F as ee,G as te,H as ne,I as re,J as ie,K as ae,L as oe,M as se,N as ce,O as le,P as ue,R as de,S as fe,T as pe,U as me,V as he,W as ge,X as _e,Y as ve,_ as ye,a as be,b as xe,c as Se,d as Ce,f as we,g as Te,h as Ee,i as De,j as Oe,k as ke,l as Ae,m as je,n as Me,o as Ne,p as Pe,q as Fe,r as Ie,s as Le,t as Re,u as ze,v as Be,w as Ve,x as He,y as Ue,z as We}from"../../session-0nWT4st6.mjs";import{r as Ge}from"../../provider-context-DC_eq7es.mjs";import{MessageStorageNamespace as Ke,MessageStorageSubjects as qe}from"./messages/namespace.mjs";import{TurnStorageNamespace as Je}from"./turns/namespace.mjs";export{ie as AdapterRegistry,S as AgentStorageNamespace,v as AgentStorageSubjects,se as CONNECTOR_SWAP_DEFAULT_PIPELINE,Re as ContextWindowTracker,Le as EmbeddingIndexManager,Ne as MakaioSession,ve as MakaioSessionService,X as MessageRoutingNamespace,he as MessageRoutingSubjects,Ke as MessageStorageNamespace,qe as MessageStorageSubjects,Y as SessionBridge,d as SessionEventStorageNamespace,l as SessionEventStorageSubjects,le as SessionExtensionContextImpl,Ce as SessionLogger,oe as SessionOrchestrator,f as SessionStorageNamespace,p as SessionStorageSubjects,de as SessionTurnManager,J as Turn,re as TurnContextEnricher,Je as TurnStorageNamespace,e as TurnStorageSubjects,F as actionRegistry,t as agents,n as agentsDual,R as assembleForkContext,Ge as buildProviderContext,g as buildRecoveryContext,C as buildRecoveryContextWithPipeline,m as buildSessionContext,B as buildTurnInitiator,ke as createSessionExtensionContext,h as ensureAgentCwd,K as ensureAgentModel,T as extractTextContent,je as fetchAgentsBySession,Ee as fetchMessageCountsBySession,Te as fetchPreviewBySession,He as fetchSessionPreviewMaps,L as findTurnByAgent,x as getFullConversation,M as getOrCreateSession,we as getSessionAncestorChain,Ae as importCursors,ze as importCursorsDual,$ as kindToBranchKind,fe as mapAgentsBySession,ye as mapRowToSession,Z as mapToSession,ne as messageRouting,me as messageRoutingDual,s as messages,k as normalizeSelectionString,G as normalizeToBlocks,Be as parseForkTransforms,Oe as pickFallbackRuntimeOptions,w as recoverAgent,O as registerAbandonHandler,W as registerAttachHandler,z as registerBuiltInActions,E as registerCompressHandler,De as registerCompressLineageResolver,_e as registerCoreSessionServiceHandlers,Ve as registerDrizzleAgentStorage,Se as registerDrizzleImportCursorStorage,We as registerDrizzleMessageRoutingStorage,te as registerDrizzleMessageStorage,ae as registerDrizzleSessionEventStorage,xe as registerDrizzleSessionStorage,q as registerDrizzleTurnStorage,N as registerForkHandler,Pe as registerFtsSearchHandler,ue as registerGetStatusCountsHandler,ce as registerListActionsHandler,Ue as registerMemoryAgentStorage,ge as registerMemoryMessageStorage,Fe as registerMemorySessionEventStorage,pe as registerMemorySessionStorage,D as registerMemoryTurnStorage,V as registerMergeHandler,be as registerParentResolver,ee as registerResumeHandler,Me as registerSessionDiscoveredHandler,Ie as registerSpawningToolCallResolver,H as resetBuiltInActionsRegistration,P as resolveAdapterId,A as resolveAdapterNameById,y as resolveExecutionTarget,b as resolveModelCapabilities,j as resolveTargetAgents,U as routeToAgents,I as routeToAgentsCore,u as sessionEvents,c as sessionEventsDual,r as sessions,i as sessionsDual,Q as toSessionLineage,o as turns,a as turnsDual,_ as verifyAndRecoverAgents};
1
+ import{agents as e,agentsDual as t,sessions as n,sessionsDual as r}from"./storage/schema.mjs";import{n as i,t as a}from"../../schema-CHp6I33k.mjs";import{t as o}from"../../schema-7aKBGB7S.mjs";import{i as s,n as c,r as l,t as u}from"../../namespace-dFBD2ZmS.mjs";import{A as d,B as f,C as p,D as m,E as h,F as g,I as _,L as v,M as y,N as b,O as x,P as S,R as C,S as w,T,_ as E,a as D,b as O,c as k,d as A,f as j,g as M,h as N,i as P,j as F,k as I,l as L,m as R,n as z,o as B,p as V,r as H,s as U,t as W,u as G,v as K,w as q,x as J,y as Y,z as X}from"../../handlers-v47Gbsr1.mjs";import{TurnStorageSubjects as Z}from"../turn/namespace.mjs";import{SessionStorageNamespace as Q,SessionStorageSubjects as $}from"./storage/namespace.mjs";import{$ as ee,A as te,B as ne,C as re,D as ie,E as ae,F as oe,G as se,H as ce,I as le,J as ue,K as de,L as fe,M as pe,N as me,O as he,P as ge,Q as _e,R as ve,S as ye,T as be,U as xe,V as Se,W as Ce,X as we,Y as Te,Z as Ee,_ as De,a as Oe,b as ke,c as Ae,d as je,et as Me,g as Ne,h as Pe,i as Fe,j as Ie,k as Le,l as Re,m as ze,n as Be,o as Ve,p as He,q as Ue,r as We,s as Ge,t as Ke,u as qe,v as Je,w as Ye,x as Xe,y as Ze,z as Qe}from"../../session-DCbJwYEU.mjs";import{r as $e}from"../../provider-context-DC_eq7es.mjs";import{MessageStorageNamespace as et,MessageStorageSubjects as tt}from"./messages/namespace.mjs";import{TurnStorageNamespace as nt}from"./turns/namespace.mjs";export{_e as AdapterRegistry,S as AgentStorageNamespace,g as AgentStorageSubjects,ve as CONNECTOR_SWAP_DEFAULT_PIPELINE,Ke as ContextWindowTracker,Ge as EmbeddingIndexManager,je as LogImportTriggerSubjects,Ve as MakaioSession,ee as MakaioSessionService,de as MessageRoutingNamespace,Ue as MessageRoutingSubjects,et as MessageStorageNamespace,tt as MessageStorageSubjects,ze as OBSERVED_SESSION_INGESTION_POLICY_CAPABILITY_ID,le as SessionBridge,u as SessionEventStorageNamespace,c as SessionEventStorageSubjects,ge as SessionExtensionContextImpl,xe as SessionOrchestrator,Q as SessionStorageNamespace,$ as SessionStorageSubjects,Ce as SessionTurnManager,Y as Turn,ce as TurnContextEnricher,nt as TurnStorageNamespace,Z as TurnStorageSubjects,I as actionRegistry,e as agents,t as agentsDual,_ as appendSessionLifecycleEvent,z as assembleForkContext,$e as buildProviderContext,m as buildRecoveryContext,w as buildRecoveryContextWithPipeline,d as buildSessionContext,V as buildTurnInitiator,oe as createSessionExtensionContext,v as emitSessionTurnStarted,p as ensureAgentCwd,q as ensureAgentModel,E as extractTextContent,ke as fetchAgentsBySession,Xe as fetchMessageCountsBySession,ye as fetchPreviewBySession,ie as fetchSessionPreviewMaps,R as findTurnByAgent,x as getFullConversation,N as getOrCreateSession,Je as getSessionAncestorChain,Re as importCursors,qe as importCursorsDual,De as ingestCompletedTurn,He as isPolicyDiscoveredObservedSession,pe as kindToBranchKind,he as mapAgentsBySession,re as mapRowToSession,Le as mapToSession,ue as messageRouting,Te as messageRoutingDual,o as messages,A as normalizeSelectionString,K as normalizeToBlocks,Ye as parseForkTransforms,fe as pickFallbackRuntimeOptions,T as recoverAgent,k as registerAbandonHandler,G as registerAttachHandler,B as registerBuiltInActions,D as registerCompressHandler,Fe as registerCompressLineageResolver,Me as registerCoreSessionServiceHandlers,te as registerDrizzleAgentStorage,Ae as registerDrizzleImportCursorStorage,se as registerDrizzleMessageRoutingStorage,Ee as registerDrizzleMessageStorage,X as registerDrizzleSessionEventStorage,ae as registerDrizzleSessionStorage,J as registerDrizzleTurnStorage,P as registerForkHandler,Ze as registerFtsSearchHandler,ne as registerGetStatusCountsHandler,Qe as registerListActionsHandler,be as registerMemoryAgentStorage,we as registerMemoryMessageStorage,f as registerMemorySessionEventStorage,Ie as registerMemorySessionStorage,O as registerMemoryTurnStorage,H as registerMergeHandler,Pe as registerObservedSessionIngestionPolicyProvider,Oe as registerParentResolver,Se as registerResumeHandler,Be as registerSessionDiscoveredHandler,C as registerSessionLifecycleEventWriters,We as registerSpawningToolCallResolver,U as resetBuiltInActionsRegistration,F as resolveAdapterId,j as resolveAdapterNameById,y as resolveExecutionTarget,b as resolveModelCapabilities,M as resolveTargetAgents,W as routeToAgents,L as routeToAgentsCore,l as sessionEvents,s as sessionEventsDual,n as sessions,r as sessionsDual,me as toSessionLineage,a as turns,i as turnsDual,Ne as unregisterObservedSessionIngestionPolicyProvider,h as verifyAndRecoverAgents};
@@ -1 +1 @@
1
- import{t as e}from"../../../schema-D6WAI8OL.mjs";import{MessagePageCursorSchema as t,MessageStorageNamespace as n,MessageStorageSubjects as r}from"@makaio/framework/contracts";const i={...n,extensions:{drizzle:{messages:e}}};export{t as MessagePageCursorSchema,i as MessageStorageNamespace,r as MessageStorageSubjects};
1
+ import{t as e}from"../../../schema-7aKBGB7S.mjs";import{MessagePageCursorSchema as t,MessageStorageNamespace as n,MessageStorageSubjects as r}from"@makaio/framework/contracts";const i={...n,extensions:{drizzle:{messages:e}}};export{t as MessagePageCursorSchema,i as MessageStorageNamespace,r as MessageStorageSubjects};
@@ -1,2 +1,2 @@
1
- import { C as collectUserMessageAcknowledgedEvents, D as getStoredEvents, E as emitAdapterInitialized, O as resetBusHandlers, S as collectTurnStartedEvents, T as collectUserMessageSentEvents, _ as registerSendMessageHandler, a as emitAgentComplete, b as UnsubscribeFunction, c as registerCapturingStartAgentHandler, d as registerFailingSendMessageHandler, f as registerFailingStartAgentHandler, g as registerRehydrateAgentHandler, h as registerModelChangeHandler, i as emitAgentAdded, k as waitForAsync, l as registerCreateSessionHandler, m as registerGetSessionHandler, n as createMockAgent, o as emitAgentError, p as registerGetAgentHandler, r as createMockSession, s as registerAgentAddedHandler, t as MockSessionConfig, u as registerCwdChangeHandler, v as registerStartAgentHandler, w as collectUserMessageCompletedEvents, x as collectTurnCompletedEvents, y as EventCollector } from "../../../orchestrator-shared-ChOdIgh6.mjs";
1
+ import { C as collectUserMessageAcknowledgedEvents, D as getStoredEvents, E as emitAdapterInitialized, O as resetBusHandlers, S as collectTurnStartedEvents, T as collectUserMessageSentEvents, _ as registerSendMessageHandler, a as emitAgentComplete, b as UnsubscribeFunction, c as registerCapturingStartAgentHandler, d as registerFailingSendMessageHandler, f as registerFailingStartAgentHandler, g as registerRehydrateAgentHandler, h as registerModelChangeHandler, i as emitAgentAdded, k as waitForAsync, l as registerCreateSessionHandler, m as registerGetSessionHandler, n as createMockAgent, o as emitAgentError, p as registerGetAgentHandler, r as createMockSession, s as registerAgentAddedHandler, t as MockSessionConfig, u as registerCwdChangeHandler, v as registerStartAgentHandler, w as collectUserMessageCompletedEvents, x as collectTurnCompletedEvents, y as EventCollector } from "../../../orchestrator-shared-DFLb1otg.mjs";
2
2
  export { type EventCollector, type MockSessionConfig, type UnsubscribeFunction, collectTurnCompletedEvents, collectTurnStartedEvents, collectUserMessageAcknowledgedEvents, collectUserMessageCompletedEvents, collectUserMessageSentEvents, createMockAgent, createMockSession, emitAdapterInitialized, emitAgentAdded, emitAgentComplete, emitAgentError, getStoredEvents, registerAgentAddedHandler, registerCapturingStartAgentHandler, registerCreateSessionHandler, registerCwdChangeHandler, registerFailingSendMessageHandler, registerFailingStartAgentHandler, registerGetAgentHandler, registerGetSessionHandler, registerModelChangeHandler, registerRehydrateAgentHandler, registerSendMessageHandler, registerStartAgentHandler, resetBusHandlers, waitForAsync };
@@ -1 +1 @@
1
- import{C as e,E as t,S as n,T as r,_ as i,a,b as o,c as s,d as c,f as l,g as u,h as d,i as f,l as p,m,n as h,o as g,p as _,r as v,s as y,t as b,u as x,v as S,w as C,x as w,y as T}from"../../../orchestrator-shared-Cxk3x8Vs.mjs";export{S as collectTurnCompletedEvents,T as collectTurnStartedEvents,o as collectUserMessageAcknowledgedEvents,w as collectUserMessageCompletedEvents,n as collectUserMessageSentEvents,b as createMockAgent,h as createMockSession,e as emitAdapterInitialized,v as emitAgentAdded,f as emitAgentComplete,a as emitAgentError,C as getStoredEvents,g as registerAgentAddedHandler,y as registerCapturingStartAgentHandler,s as registerCreateSessionHandler,p as registerCwdChangeHandler,x as registerFailingSendMessageHandler,c as registerFailingStartAgentHandler,l as registerGetAgentHandler,_ as registerGetSessionHandler,m as registerModelChangeHandler,d as registerRehydrateAgentHandler,u as registerSendMessageHandler,i as registerStartAgentHandler,r as resetBusHandlers,t as waitForAsync};
1
+ import{C as e,E as t,S as n,T as r,_ as i,a,b as o,c as s,d as c,f as l,g as u,h as d,i as f,l as p,m,n as h,o as g,p as _,r as v,s as y,t as b,u as x,v as S,w as C,x as w,y as T}from"../../../orchestrator-shared-ChygCvR1.mjs";export{S as collectTurnCompletedEvents,T as collectTurnStartedEvents,o as collectUserMessageAcknowledgedEvents,w as collectUserMessageCompletedEvents,n as collectUserMessageSentEvents,b as createMockAgent,h as createMockSession,e as emitAdapterInitialized,v as emitAgentAdded,f as emitAgentComplete,a as emitAgentError,C as getStoredEvents,g as registerAgentAddedHandler,y as registerCapturingStartAgentHandler,s as registerCreateSessionHandler,p as registerCwdChangeHandler,x as registerFailingSendMessageHandler,c as registerFailingStartAgentHandler,l as registerGetAgentHandler,_ as registerGetSessionHandler,m as registerModelChangeHandler,d as registerRehydrateAgentHandler,u as registerSendMessageHandler,i as registerStartAgentHandler,r as resetBusHandlers,t as waitForAsync};
@@ -1,2 +1,2 @@
1
- import { n as SessionEventStorageSubjects, t as SessionEventStorageNamespace } from "../../../namespace-BeMGmLrp.mjs";
1
+ import { n as SessionEventStorageSubjects, t as SessionEventStorageNamespace } from "../../../namespace-DhDY0juT.mjs";
2
2
  export { SessionEventStorageNamespace, SessionEventStorageSubjects };
@@ -1 +1 @@
1
- import{n as e,t}from"../../../namespace-C-piH3w4.mjs";export{t as SessionEventStorageNamespace,e as SessionEventStorageSubjects};
1
+ import{n as e,t}from"../../../namespace-dFBD2ZmS.mjs";export{t as SessionEventStorageNamespace,e as SessionEventStorageSubjects};
@@ -1,2 +1,2 @@
1
- import { a as SessionWithPreview, i as SessionStorageSubjects, n as SessionPreviewDataSchema, o as SessionWithPreviewSchema, r as SessionStorageNamespace, t as SessionPreviewData } from "../../../namespace-Bmi5bjm4.mjs";
1
+ import { a as SessionWithPreview, i as SessionStorageSubjects, n as SessionPreviewDataSchema, o as SessionWithPreviewSchema, r as SessionStorageNamespace, t as SessionPreviewData } from "../../../namespace-DmqoDDRD.mjs";
2
2
  export { SessionPreviewData, SessionPreviewDataSchema, SessionStorageNamespace, SessionStorageSubjects, SessionWithPreview, SessionWithPreviewSchema };
@@ -1,2 +1,2 @@
1
- import { a as agents, c as sessionsDual, i as SelectSession, n as InsertSession, o as agentsDual, r as SelectAgent, s as sessions, t as InsertAgent } from "../../../schema-Bf_ZNjif.mjs";
1
+ import { a as agents, c as sessionsDual, i as SelectSession, n as InsertSession, o as agentsDual, r as SelectAgent, s as sessions, t as InsertAgent } from "../../../schema-DLNBajAV.mjs";
2
2
  export { InsertAgent, InsertSession, SelectAgent, SelectSession, agents, agentsDual, sessions, sessionsDual };
@@ -1 +1 @@
1
- import{check as e,index as t,uniqueIndex as n}from"drizzle-orm/sqlite-core";import{check as r,index as i,uniqueIndex as a}from"drizzle-orm/pg-core";import{defineDualTable as o}from"@makaio/framework/storage/drizzle";import{sql as s}from"drizzle-orm";const c=o(`sessions`,e=>({sessionId:e.text(`session_id`).primaryKey(),createdAt:e.epochMs(`created_at`).notNull(),lastActivityAt:e.epochMs(`last_activity_at`).notNull(),status:e.textEnum(`status`,{enum:[`active`,`closed`,`archived`,`discovered`]}).notNull(),leadAgentId:e.text(`lead_agent_id`),parentSessionId:e.text(`parent_session_id`),contextInheritance:e.textEnum(`context_inheritance`,{enum:[`parent-history`,`none`]}),rootSessionId:e.text(`root_session_id`),forkPointMessageId:e.text(`fork_point_message_id`),branchKind:e.textEnum(`branch_kind`,{enum:[`fork`,`branch`,`subagent`,`compress`,`rewrite`,`coordinator`,`aside`]}),adapterName:e.text(`adapter_name`),adapterSessionId:e.text(`adapter_session_id`),adapterId:e.text(`adapter_id`),clientId:e.text(`client_id`),clientAccountId:e.text(`client_account_id`),lastClientIdentityObservation:e.text(`last_client_identity_observation`),isOrchestrated:e.bool(`is_orchestrated`).default(!1),title:e.text(`title`),summary:e.text(`summary`),summaryUpdatedAt:e.epochMs(`summary_updated_at`),isImported:e.bool(`is_imported`).default(!1),forkTransforms:e.text(`fork_transforms`),targetWorkingDirectory:e.text(`target_working_directory`),executionTargetId:e.text(`execution_target_id`),approvalPolicyOverride:e.textEnum(`approval_policy_override`,{enum:[`reject`,`always-ask`,`full-access`]}),metadata:e.jsonCol(`metadata`),spawningToolCallId:e.text(`spawning_tool_call_id`),source:e.text(`source`),parentExternalSessionId:e.text(`parent_external_session_id`),logFilePath:e.text(`log_file_path`),discoveredAt:e.epochMs(`discovered_at`),importStatus:e.textEnum(`import_status`,{enum:[`discovered`,`imported`,`tracking`]})}),{sqlite:r=>[n(`uniq_sessions_source_adapter_session_id`).on(r.source,r.adapterSessionId),n(`uniq_sessions_log_file_path`).on(r.logFilePath),t(`sessions_adapter_session_id_idx`).on(r.adapterSessionId),t(`idx_sessions_import_status`).on(r.importStatus),t(`sessions_execution_target_id_idx`).on(r.executionTargetId),t(`idx_sessions_parent_session_id`).on(r.parentSessionId),e(`sessions_import_status_check`,s`${r.importStatus} IS NULL OR ${r.importStatus} IN ('discovered', 'imported', 'tracking')`),e(`sessions_context_inheritance_check`,s`${r.contextInheritance} IS NULL OR ${r.contextInheritance} IN ('parent-history', 'none')`)],postgres:e=>[a(`uniq_sessions_source_adapter_session_id`).on(e.source,e.adapterSessionId),a(`uniq_sessions_log_file_path`).on(e.logFilePath),i(`sessions_adapter_session_id_idx`).on(e.adapterSessionId),i(`idx_sessions_import_status`).on(e.importStatus),i(`sessions_execution_target_id_idx`).on(e.executionTargetId),i(`idx_sessions_parent_session_id`).on(e.parentSessionId),r(`sessions_import_status_check`,s`${e.importStatus} IS NULL OR ${e.importStatus} IN ('discovered', 'imported', 'tracking')`),r(`sessions_context_inheritance_check`,s`${e.contextInheritance} IS NULL OR ${e.contextInheritance} IN ('parent-history', 'none')`)]}),l=c.sqlite,u=o(`agents`,e=>({agentId:e.text(`agent_id`).primaryKey(),adapterId:e.text(`adapter_id`).notNull(),adapterName:e.text(`adapter_name`).notNull(),sessionId:e.text(`session_id`).notNull().references(()=>c.columnPair(`sessionId`),{onDelete:`cascade`}),adapterSessionId:e.text(`adapter_session_id`),model:e.text(`model`),cwd:e.text(`cwd`),allowedDirectories:e.jsonCol(`allowed_directories`),providerConfigId:e.text(`provider_config_id`),personaId:e.text(`persona_id`),profileId:e.text(`profile_id`),harnessId:e.text(`harness_id`),clientId:e.text(`client_id`),compressionMode:e.text(`compression_mode`),role:e.textEnum(`role`,{enum:[`lead`,`member`]}).notNull(),status:e.textEnum(`status`,{enum:[`idle`,`active`,`dead`,`disposed`]}).notNull(),createdAt:e.epochMs(`created_at`).notNull(),lastActivityAt:e.epochMs(`last_activity_at`).notNull()}),{sqlite:e=>[t(`agents_session_id_idx`).on(e.sessionId),t(`agents_adapter_name_idx`).on(e.adapterName),t(`agents_status_idx`).on(e.status),t(`agents_client_id_idx`).on(e.clientId)],postgres:e=>[i(`agents_session_id_idx`).on(e.sessionId),i(`agents_adapter_name_idx`).on(e.adapterName),i(`agents_status_idx`).on(e.status),i(`agents_client_id_idx`).on(e.clientId)]}),d=u.sqlite;export{d as agents,u as agentsDual,l as sessions,c as sessionsDual};
1
+ import{check as e,index as t,uniqueIndex as n}from"drizzle-orm/sqlite-core";import{check as r,index as i,uniqueIndex as a}from"drizzle-orm/pg-core";import{defineDualTable as o}from"@makaio/framework/storage/drizzle";import{sql as s}from"drizzle-orm";const c=o(`sessions`,e=>({sessionId:e.text(`session_id`).primaryKey(),createdAt:e.epochMs(`created_at`).notNull(),lastActivityAt:e.epochMs(`last_activity_at`).notNull(),status:e.textEnum(`status`,{enum:[`active`,`closed`,`archived`,`discovered`]}).notNull(),leadAgentId:e.text(`lead_agent_id`),parentSessionId:e.text(`parent_session_id`),contextInheritance:e.textEnum(`context_inheritance`,{enum:[`parent-history`,`none`]}),rootSessionId:e.text(`root_session_id`),forkPointMessageId:e.text(`fork_point_message_id`),branchKind:e.textEnum(`branch_kind`,{enum:[`fork`,`branch`,`subagent`,`compress`,`rewrite`,`coordinator`,`aside`]}),adapterName:e.text(`adapter_name`),adapterSessionId:e.text(`adapter_session_id`),adapterId:e.text(`adapter_id`),clientId:e.text(`client_id`),clientAccountId:e.text(`client_account_id`),lastClientIdentityObservation:e.text(`last_client_identity_observation`),isOrchestrated:e.bool(`is_orchestrated`).default(!1),title:e.text(`title`),summary:e.text(`summary`),summaryUpdatedAt:e.epochMs(`summary_updated_at`),isImported:e.bool(`is_imported`).default(!1),forkTransforms:e.text(`fork_transforms`),targetWorkingDirectory:e.text(`target_working_directory`),executionTargetId:e.text(`execution_target_id`),approvalPolicyOverride:e.textEnum(`approval_policy_override`,{enum:[`reject`,`always-ask`,`full-access`]}),metadata:e.jsonCol(`metadata`),spawningToolCallId:e.text(`spawning_tool_call_id`),source:e.text(`source`),parentExternalSessionId:e.text(`parent_external_session_id`),logFilePath:e.text(`log_file_path`),discoveredAt:e.epochMs(`discovered_at`),importStatus:e.textEnum(`import_status`,{enum:[`discovered`,`imported`,`tracking`]}),isSidechain:e.bool(`is_sidechain`)}),{sqlite:r=>[n(`uniq_sessions_source_adapter_session_id`).on(r.source,r.adapterSessionId),n(`uniq_sessions_log_file_path`).on(r.logFilePath),t(`sessions_adapter_session_id_idx`).on(r.adapterSessionId),t(`idx_sessions_import_status`).on(r.importStatus),t(`sessions_execution_target_id_idx`).on(r.executionTargetId),t(`idx_sessions_parent_session_id`).on(r.parentSessionId),e(`sessions_import_status_check`,s`${r.importStatus} IS NULL OR ${r.importStatus} IN ('discovered', 'imported', 'tracking')`),e(`sessions_context_inheritance_check`,s`${r.contextInheritance} IS NULL OR ${r.contextInheritance} IN ('parent-history', 'none')`)],postgres:e=>[a(`uniq_sessions_source_adapter_session_id`).on(e.source,e.adapterSessionId),a(`uniq_sessions_log_file_path`).on(e.logFilePath),i(`sessions_adapter_session_id_idx`).on(e.adapterSessionId),i(`idx_sessions_import_status`).on(e.importStatus),i(`sessions_execution_target_id_idx`).on(e.executionTargetId),i(`idx_sessions_parent_session_id`).on(e.parentSessionId),r(`sessions_import_status_check`,s`${e.importStatus} IS NULL OR ${e.importStatus} IN ('discovered', 'imported', 'tracking')`),r(`sessions_context_inheritance_check`,s`${e.contextInheritance} IS NULL OR ${e.contextInheritance} IN ('parent-history', 'none')`)]}),l=c.sqlite,u=o(`agents`,e=>({agentId:e.text(`agent_id`).primaryKey(),adapterId:e.text(`adapter_id`).notNull(),adapterName:e.text(`adapter_name`).notNull(),sessionId:e.text(`session_id`).notNull().references(()=>c.columnPair(`sessionId`),{onDelete:`cascade`}),adapterSessionId:e.text(`adapter_session_id`),model:e.text(`model`),cwd:e.text(`cwd`),allowedDirectories:e.jsonCol(`allowed_directories`),providerConfigId:e.text(`provider_config_id`),personaId:e.text(`persona_id`),profileId:e.text(`profile_id`),harnessId:e.text(`harness_id`),clientId:e.text(`client_id`),compressionMode:e.text(`compression_mode`),role:e.textEnum(`role`,{enum:[`lead`,`member`]}).notNull(),status:e.textEnum(`status`,{enum:[`idle`,`active`,`dead`,`disposed`]}).notNull(),createdAt:e.epochMs(`created_at`).notNull(),lastActivityAt:e.epochMs(`last_activity_at`).notNull()}),{sqlite:e=>[t(`agents_session_id_idx`).on(e.sessionId),t(`agents_adapter_name_idx`).on(e.adapterName),t(`agents_status_idx`).on(e.status),t(`agents_client_id_idx`).on(e.clientId)],postgres:e=>[i(`agents_session_id_idx`).on(e.sessionId),i(`agents_adapter_name_idx`).on(e.adapterName),i(`agents_status_idx`).on(e.status),i(`agents_client_id_idx`).on(e.clientId)]}),d=u.sqlite;export{d as agents,u as agentsDual,l as sessions,c as sessionsDual};