@agimon-ai/po-core 0.0.0-alpha.2 → 0.0.0-alpha.21

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 (1149) hide show
  1. package/LICENSE +149 -21
  2. package/NOTICE +41 -0
  3. package/dist/agentModel.cjs +1 -1
  4. package/dist/agentModel.d.mts +2 -2
  5. package/dist/agentModel.mjs +1 -2
  6. package/dist/apiContracts.cjs +623 -802
  7. package/dist/apiContracts.cjs.map +1 -1
  8. package/dist/apiContracts.d.mts +277 -615
  9. package/dist/apiContracts.d.mts.map +1 -1
  10. package/dist/apiContracts.mjs +617 -794
  11. package/dist/apiContracts.mjs.map +1 -1
  12. package/dist/askUser.cjs +2 -2
  13. package/dist/askUser.d.mts +2 -2
  14. package/dist/askUser.mjs +1 -2
  15. package/dist/authorTools.mjs +1 -2
  16. package/dist/backgroundWork.cjs +3 -3
  17. package/dist/backgroundWork.d.mts +2 -2
  18. package/dist/backgroundWork.mjs +1 -2
  19. package/dist/bundleAssetPolicy.mjs +1 -2
  20. package/dist/chatgptAuth.cjs +3 -2
  21. package/dist/chatgptAuth.d.mts +3 -2
  22. package/dist/chatgptAuth.mjs +2 -1
  23. package/dist/childProcess.cjs +1 -1
  24. package/dist/childProcess.d.mts +2 -2
  25. package/dist/childProcess.mjs +1 -2
  26. package/dist/childSession.cjs +11 -6
  27. package/dist/childSession.d.mts +3 -3
  28. package/dist/childSession.mjs +3 -3
  29. package/dist/cockpitContainer.mjs +1 -2
  30. package/dist/config.cjs +1 -1
  31. package/dist/config.d.mts +3 -3
  32. package/dist/config.mjs +1 -2
  33. package/dist/contextApi.cjs +1 -0
  34. package/dist/contextApi.d.mts +2 -2
  35. package/dist/contextApi.mjs +2 -2
  36. package/dist/contextContributions.cjs +4 -4
  37. package/dist/contextContributions.d.mts +3 -3
  38. package/dist/contextContributions.mjs +3 -3
  39. package/dist/contextDetailStore.cjs +7 -5
  40. package/dist/contextDetailStore.cjs.map +1 -1
  41. package/dist/contextDetailStore.d.mts +2 -1
  42. package/dist/contextDetailStore.d.mts.map +1 -1
  43. package/dist/contextDetailStore.mjs +6 -4
  44. package/dist/contextDetailStore.mjs.map +1 -1
  45. package/dist/contextProjection.cjs +7 -2
  46. package/dist/contextProjection.cjs.map +1 -1
  47. package/dist/contextProjection.d.mts +4 -1
  48. package/dist/contextProjection.d.mts.map +1 -1
  49. package/dist/contextProjection.mjs +5 -2
  50. package/dist/contextProjection.mjs.map +1 -1
  51. package/dist/cordisHost.cjs +11 -11
  52. package/dist/cordisHost.d.mts +2 -2
  53. package/dist/cordisHost.mjs +1 -2
  54. package/dist/delegation.cjs +8 -8
  55. package/dist/delegation.d.mts +2 -2
  56. package/dist/delegation.mjs +1 -2
  57. package/dist/executionBudget.cjs +4 -3
  58. package/dist/executionBudget.cjs.map +1 -1
  59. package/dist/executionBudget.d.mts +2 -2
  60. package/dist/executionBudget.d.mts.map +1 -1
  61. package/dist/executionBudget.mjs +4 -3
  62. package/dist/executionBudget.mjs.map +1 -1
  63. package/dist/extensionFile.cjs +5 -0
  64. package/dist/extensionFile.d.mts +4 -2
  65. package/dist/extensionFile.mjs +4 -2
  66. package/dist/footer.d.mts +2 -2
  67. package/dist/footer.mjs +1 -2
  68. package/dist/headless.cjs +14 -14
  69. package/dist/headless.d.mts +2 -2
  70. package/dist/headless.mjs +1 -2
  71. package/dist/headlessHub.cjs +308 -109
  72. package/dist/headlessHub.cjs.map +1 -1
  73. package/dist/headlessHub.d.mts +71 -36
  74. package/dist/headlessHub.d.mts.map +1 -1
  75. package/dist/headlessHub.mjs +309 -110
  76. package/dist/headlessHub.mjs.map +1 -1
  77. package/dist/headlessProtocol.cjs +327 -0
  78. package/dist/headlessProtocol.cjs.map +1 -0
  79. package/dist/headlessProtocol.d.mts +30 -0
  80. package/dist/headlessProtocol.d.mts.map +1 -0
  81. package/dist/headlessProtocol.mjs +326 -0
  82. package/dist/headlessProtocol.mjs.map +1 -0
  83. package/dist/headlessServer.cjs +166 -151
  84. package/dist/headlessServer.cjs.map +1 -1
  85. package/dist/headlessServer.d.mts +13 -5
  86. package/dist/headlessServer.d.mts.map +1 -1
  87. package/dist/headlessServer.mjs +166 -151
  88. package/dist/headlessServer.mjs.map +1 -1
  89. package/dist/headlessSessionHost.d.mts +58 -21
  90. package/dist/headlessSessionHost.d.mts.map +1 -1
  91. package/dist/help.cjs +20 -20
  92. package/dist/help.d.mts +2 -2
  93. package/dist/help.mjs +2 -2
  94. package/dist/history.cjs +16 -20
  95. package/dist/history.d.mts +9 -7
  96. package/dist/history.mjs +6 -7
  97. package/dist/historyOwnership.cjs.map +1 -1
  98. package/dist/historyOwnership.d.mts +1 -1
  99. package/dist/historyOwnership.mjs.map +1 -1
  100. package/dist/hubChannel.cjs +9 -0
  101. package/dist/hubChannel.d.mts +3 -2
  102. package/dist/hubChannel.mjs +3 -2
  103. package/dist/index.cjs +26 -28
  104. package/dist/index.d.mts +6 -6
  105. package/dist/index.mjs +6 -6
  106. package/dist/interop/chord.mjs +1 -0
  107. package/dist/interop/chordContext.mjs +1 -0
  108. package/dist/json.cjs +11 -5
  109. package/dist/json.d.mts +4 -2
  110. package/dist/json.mjs +4 -2
  111. package/dist/kernel.cjs +1 -1
  112. package/dist/kernel.d.mts +3 -3
  113. package/dist/kernel.mjs +1 -2
  114. package/dist/leader.d.mts +2 -2
  115. package/dist/leader.mjs +1 -2
  116. package/dist/logSinkTelemetry.mjs +1 -2
  117. package/dist/machineApi.cjs +80 -74
  118. package/dist/machineApi.cjs.map +1 -1
  119. package/dist/machineApi.d.mts +5 -2
  120. package/dist/machineApi.d.mts.map +1 -1
  121. package/dist/machineApi.mjs +78 -71
  122. package/dist/machineApi.mjs.map +1 -1
  123. package/dist/main.cjs +2 -1
  124. package/dist/main.d.mts +2 -1
  125. package/dist/main.mjs +2 -1
  126. package/dist/mcpFacet.d.mts +3 -3
  127. package/dist/mcpProjection.cjs +13 -13
  128. package/dist/mcpProjection.d.mts +2 -2
  129. package/dist/mcpProjection.mjs +1 -2
  130. package/dist/mcpSchemaCost.cjs +4 -4
  131. package/dist/mcpSchemaCost.cjs.map +1 -1
  132. package/dist/mcpSchemaCost.d.mts +2 -2
  133. package/dist/mcpSchemaCost.mjs +4 -4
  134. package/dist/mcpSchemaCost.mjs.map +1 -1
  135. package/dist/mcpSession.cjs +7 -7
  136. package/dist/mcpSession.d.mts +2 -2
  137. package/dist/mcpSession.mjs +1 -2
  138. package/dist/mcpStatus.cjs +2 -2
  139. package/dist/mcpStatus.d.mts +2 -2
  140. package/dist/mcpStatus.mjs +1 -2
  141. package/dist/mcpToolResolver.cjs +3 -3
  142. package/dist/mcpToolResolver.d.mts +2 -2
  143. package/dist/mcpToolResolver.mjs +1 -2
  144. package/dist/mcpWidget.d.mts +2 -2
  145. package/dist/moduleResolution.cjs +43 -8
  146. package/dist/moduleResolution.cjs.map +1 -1
  147. package/dist/moduleResolution.d.mts +10 -1
  148. package/dist/moduleResolution.d.mts.map +1 -1
  149. package/dist/moduleResolution.mjs +40 -7
  150. package/dist/moduleResolution.mjs.map +1 -1
  151. package/dist/narration.cjs +3 -3
  152. package/dist/narration.d.mts +2 -2
  153. package/dist/narration.mjs +1 -2
  154. package/dist/native.cjs +9 -0
  155. package/dist/native.d.mts +4 -3
  156. package/dist/native.mjs +3 -2
  157. package/dist/nodePlatform.cjs +77 -0
  158. package/dist/nodePlatform.cjs.map +1 -0
  159. package/dist/nodePlatform.d.mts +17 -0
  160. package/dist/nodePlatform.d.mts.map +1 -0
  161. package/dist/nodePlatform.mjs +72 -0
  162. package/dist/nodePlatform.mjs.map +1 -0
  163. package/dist/notification.cjs +15 -15
  164. package/dist/notification.d.mts +2 -2
  165. package/dist/notification.mjs +1 -2
  166. package/dist/packageApi.cjs +11 -11
  167. package/dist/packageApi.d.mts +2 -2
  168. package/dist/packageApi.mjs +2 -2
  169. package/dist/packageApiServer.cjs +45 -27
  170. package/dist/packageApiServer.cjs.map +1 -1
  171. package/dist/packageApiServer.d.mts +36 -26
  172. package/dist/packageApiServer.d.mts.map +1 -1
  173. package/dist/packageApiServer.mjs +44 -26
  174. package/dist/packageApiServer.mjs.map +1 -1
  175. package/dist/piSettings.cjs +41 -20
  176. package/dist/piSettings.d.mts +4 -2
  177. package/dist/piSettings.mjs +4 -2
  178. package/dist/platform.cjs +62 -0
  179. package/dist/platform.d.mts +10 -0
  180. package/dist/platform.mjs +10 -0
  181. package/dist/pluginProtocol.cjs +7 -8
  182. package/dist/pluginProtocol.d.mts +2 -2
  183. package/dist/pluginProtocol.mjs +1 -2
  184. package/dist/poPackage.cjs +12 -0
  185. package/dist/poPackage.d.mts +3 -0
  186. package/dist/poPackage.mjs +3 -0
  187. package/dist/profileIdentity.cjs +1 -1
  188. package/dist/profileIdentity.d.mts +2 -2
  189. package/dist/profileIdentity.mjs +1 -2
  190. package/dist/protocol.cjs +3 -3
  191. package/dist/protocol.d.mts +2 -2
  192. package/dist/protocol.mjs +1 -2
  193. package/dist/readiness.cjs +6 -6
  194. package/dist/readiness.d.mts +2 -2
  195. package/dist/readiness.mjs +1 -2
  196. package/dist/remoteApi.cjs.map +1 -1
  197. package/dist/remoteApi.d.mts +2 -2
  198. package/dist/remoteApi.mjs.map +1 -1
  199. package/dist/remoteRuntime.cjs +42 -65
  200. package/dist/remoteRuntime.cjs.map +1 -1
  201. package/dist/remoteRuntime.d.mts +3 -2
  202. package/dist/remoteRuntime.d.mts.map +1 -1
  203. package/dist/remoteRuntime.mjs +41 -62
  204. package/dist/remoteRuntime.mjs.map +1 -1
  205. package/dist/runtimeConfig.cjs +4 -4
  206. package/dist/runtimeConfig.cjs.map +1 -1
  207. package/dist/runtimeConfig.d.mts +10 -9
  208. package/dist/runtimeConfig.d.mts.map +1 -1
  209. package/dist/runtimeConfig.mjs +4 -4
  210. package/dist/runtimeConfig.mjs.map +1 -1
  211. package/dist/runtimeContextApi.cjs +10 -3
  212. package/dist/runtimeContextApi.cjs.map +1 -1
  213. package/dist/runtimeContextApi.d.mts +3 -3
  214. package/dist/runtimeContextApi.d.mts.map +1 -1
  215. package/dist/runtimeContextApi.mjs +10 -3
  216. package/dist/runtimeContextApi.mjs.map +1 -1
  217. package/dist/runtimeCordisHost.cjs +46 -46
  218. package/dist/runtimeCordisHost.cjs.map +1 -1
  219. package/dist/runtimeCordisHost.d.mts +29 -28
  220. package/dist/runtimeCordisHost.d.mts.map +1 -1
  221. package/dist/runtimeCordisHost.mjs +42 -42
  222. package/dist/runtimeCordisHost.mjs.map +1 -1
  223. package/dist/runtimeIdentity.cjs +6 -9
  224. package/dist/runtimeIdentity.cjs.map +1 -1
  225. package/dist/runtimeIdentity.d.mts +5 -1
  226. package/dist/runtimeIdentity.d.mts.map +1 -1
  227. package/dist/runtimeIdentity.mjs +5 -8
  228. package/dist/runtimeIdentity.mjs.map +1 -1
  229. package/dist/runtimeJson.cjs +10 -45
  230. package/dist/runtimeJson.d.mts +3 -22
  231. package/dist/runtimeJson.mjs +3 -39
  232. package/dist/runtimeLogSinkTelemetry.cjs +19 -19
  233. package/dist/runtimeLogSinkTelemetry.cjs.map +1 -1
  234. package/dist/runtimeLogSinkTelemetry.d.mts +19 -19
  235. package/dist/runtimeLogSinkTelemetry.mjs +19 -19
  236. package/dist/runtimeLogSinkTelemetry.mjs.map +1 -1
  237. package/dist/runtimePackages.cjs +7 -2
  238. package/dist/runtimePackages.cjs.map +1 -1
  239. package/dist/runtimePackages.d.mts +4 -1
  240. package/dist/runtimePackages.d.mts.map +1 -1
  241. package/dist/runtimePackages.mjs +7 -2
  242. package/dist/runtimePackages.mjs.map +1 -1
  243. package/dist/runtimePiSettings.cjs +40 -263
  244. package/dist/runtimePiSettings.d.mts +3 -72
  245. package/dist/runtimePiSettings.mjs +3 -241
  246. package/dist/runtimeProtocol.cjs +19 -19
  247. package/dist/runtimeProtocol.cjs.map +1 -1
  248. package/dist/runtimeProtocol.d.mts +7 -7
  249. package/dist/runtimeProtocol.d.mts.map +1 -1
  250. package/dist/runtimeProtocol.mjs +17 -17
  251. package/dist/runtimeProtocol.mjs.map +1 -1
  252. package/dist/runtimeTransition.cjs +9 -9
  253. package/dist/runtimeTransition.cjs.map +1 -1
  254. package/dist/runtimeTransition.d.mts +10 -10
  255. package/dist/runtimeTransition.d.mts.map +1 -1
  256. package/dist/runtimeTransition.mjs +7 -7
  257. package/dist/runtimeTransition.mjs.map +1 -1
  258. package/dist/sandboxHarness.mjs +1 -2
  259. package/dist/server.cjs +3 -7
  260. package/dist/server.d.mts +6 -6
  261. package/dist/server.mjs +3 -4
  262. package/dist/serverPlugin.cjs +39 -0
  263. package/dist/serverPlugin.d.mts +12 -0
  264. package/dist/serverPlugin.mjs +11 -0
  265. package/dist/serverTelemetry.cjs +1 -1
  266. package/dist/serverTelemetry.cjs.map +1 -1
  267. package/dist/serverTelemetry.d.mts +2 -2
  268. package/dist/serverTelemetry.mjs +2 -2
  269. package/dist/serverTelemetry.mjs.map +1 -1
  270. package/dist/sessionFilesApi.cjs +41 -37
  271. package/dist/sessionFilesApi.cjs.map +1 -1
  272. package/dist/sessionFilesApi.d.mts +6 -3
  273. package/dist/sessionFilesApi.d.mts.map +1 -1
  274. package/dist/sessionFilesApi.mjs +41 -36
  275. package/dist/sessionFilesApi.mjs.map +1 -1
  276. package/dist/sessionProtocol.cjs +31 -6
  277. package/dist/sessionProtocol.d.mts +8 -3
  278. package/dist/sessionProtocol.mjs +8 -2
  279. package/dist/skills.cjs +5 -5
  280. package/dist/skills.d.mts +2 -2
  281. package/dist/skills.mjs +1 -2
  282. package/dist/sqliteSessionStorage.cjs +28 -50
  283. package/dist/sqliteSessionStorage.cjs.map +1 -1
  284. package/dist/sqliteSessionStorage.d.mts +13 -20
  285. package/dist/sqliteSessionStorage.d.mts.map +1 -1
  286. package/dist/sqliteSessionStorage.mjs +25 -48
  287. package/dist/sqliteSessionStorage.mjs.map +1 -1
  288. package/dist/src/constants/agentSettled.cjs +7 -0
  289. package/dist/src/constants/agentSettled.cjs.map +1 -0
  290. package/dist/src/constants/agentSettled.mjs +7 -0
  291. package/dist/src/constants/agentSettled.mjs.map +1 -0
  292. package/dist/src/constants/contextApi.cjs +3 -1
  293. package/dist/src/constants/contextApi.cjs.map +1 -1
  294. package/dist/src/constants/contextApi.d.mts +2 -1
  295. package/dist/src/constants/contextApi.d.mts.map +1 -1
  296. package/dist/src/constants/contextApi.mjs +3 -2
  297. package/dist/src/constants/contextApi.mjs.map +1 -1
  298. package/dist/src/constants/voiceTools.cjs +6 -6
  299. package/dist/src/constants/voiceTools.cjs.map +1 -1
  300. package/dist/src/constants/voiceTools.d.mts +3 -3
  301. package/dist/src/constants/voiceTools.mjs +4 -4
  302. package/dist/src/constants/voiceTools.mjs.map +1 -1
  303. package/dist/src/extensions/extensionFile.cjs +22 -5
  304. package/dist/src/extensions/extensionFile.cjs.map +1 -1
  305. package/dist/src/extensions/extensionFile.d.mts +17 -4
  306. package/dist/src/extensions/extensionFile.d.mts.map +1 -1
  307. package/dist/src/extensions/extensionFile.mjs +22 -6
  308. package/dist/src/extensions/extensionFile.mjs.map +1 -1
  309. package/dist/src/extensions/serverPlugin.cjs +231 -92
  310. package/dist/src/extensions/serverPlugin.cjs.map +1 -1
  311. package/dist/src/extensions/serverPlugin.d.mts +2 -2
  312. package/dist/src/extensions/serverPlugin.d.mts.map +1 -1
  313. package/dist/src/extensions/serverPlugin.mjs +232 -93
  314. package/dist/src/extensions/serverPlugin.mjs.map +1 -1
  315. package/dist/src/pi/piSessionRuntime.cjs +349 -142
  316. package/dist/src/pi/piSessionRuntime.cjs.map +1 -1
  317. package/dist/src/pi/piSessionRuntime.d.mts +18 -17
  318. package/dist/src/pi/piSessionRuntime.d.mts.map +1 -1
  319. package/dist/src/pi/piSessionRuntime.mjs +342 -135
  320. package/dist/src/pi/piSessionRuntime.mjs.map +1 -1
  321. package/dist/src/schemas/agentModel.cjs +2 -2
  322. package/dist/src/schemas/agentModel.cjs.map +1 -1
  323. package/dist/src/schemas/agentModel.d.mts +1 -1
  324. package/dist/src/schemas/agentModel.mjs +2 -2
  325. package/dist/src/schemas/agentModel.mjs.map +1 -1
  326. package/dist/src/schemas/apiContracts.d.mts +2 -2
  327. package/dist/src/schemas/apiContracts.d.mts.map +1 -1
  328. package/dist/src/schemas/askUser.cjs +4 -4
  329. package/dist/src/schemas/askUser.cjs.map +1 -1
  330. package/dist/src/schemas/askUser.d.mts +4 -4
  331. package/dist/src/schemas/askUser.d.mts.map +1 -1
  332. package/dist/src/schemas/askUser.mjs +3 -3
  333. package/dist/src/schemas/askUser.mjs.map +1 -1
  334. package/dist/src/schemas/backgroundWork.cjs +10 -10
  335. package/dist/src/schemas/backgroundWork.cjs.map +1 -1
  336. package/dist/src/schemas/backgroundWork.d.mts +9 -9
  337. package/dist/src/schemas/backgroundWork.d.mts.map +1 -1
  338. package/dist/src/schemas/backgroundWork.mjs +8 -8
  339. package/dist/src/schemas/backgroundWork.mjs.map +1 -1
  340. package/dist/src/schemas/childProcess.cjs +5 -5
  341. package/dist/src/schemas/childProcess.cjs.map +1 -1
  342. package/dist/src/schemas/childProcess.d.mts +2 -2
  343. package/dist/src/schemas/childProcess.mjs +5 -5
  344. package/dist/src/schemas/childProcess.mjs.map +1 -1
  345. package/dist/src/schemas/contextContributions.cjs +10 -10
  346. package/dist/src/schemas/contextContributions.cjs.map +1 -1
  347. package/dist/src/schemas/contextContributions.d.mts +16 -16
  348. package/dist/src/schemas/contextContributions.d.mts.map +1 -1
  349. package/dist/src/schemas/contextContributions.mjs +8 -8
  350. package/dist/src/schemas/contextContributions.mjs.map +1 -1
  351. package/dist/src/schemas/delegation.cjs +17 -17
  352. package/dist/src/schemas/delegation.cjs.map +1 -1
  353. package/dist/src/schemas/delegation.d.mts +16 -16
  354. package/dist/src/schemas/delegation.d.mts.map +1 -1
  355. package/dist/src/schemas/delegation.mjs +10 -10
  356. package/dist/src/schemas/delegation.mjs.map +1 -1
  357. package/dist/src/schemas/extensionFile.d.mts +23 -19
  358. package/dist/src/schemas/extensionFile.d.mts.map +1 -1
  359. package/dist/src/schemas/footer.cjs.map +1 -1
  360. package/dist/src/schemas/footer.d.mts +5 -5
  361. package/dist/src/schemas/footer.d.mts.map +1 -1
  362. package/dist/src/schemas/footer.mjs.map +1 -1
  363. package/dist/src/schemas/headless.cjs +37 -37
  364. package/dist/src/schemas/headless.cjs.map +1 -1
  365. package/dist/src/schemas/headless.d.mts +100 -101
  366. package/dist/src/schemas/headless.d.mts.map +1 -1
  367. package/dist/src/schemas/headless.mjs +24 -24
  368. package/dist/src/schemas/headless.mjs.map +1 -1
  369. package/dist/src/schemas/help.cjs +60 -60
  370. package/dist/src/schemas/help.cjs.map +1 -1
  371. package/dist/src/schemas/help.d.mts +43 -43
  372. package/dist/src/schemas/help.d.mts.map +1 -1
  373. package/dist/src/schemas/help.mjs +41 -41
  374. package/dist/src/schemas/help.mjs.map +1 -1
  375. package/dist/src/schemas/home.cjs +127 -0
  376. package/dist/src/schemas/home.cjs.map +1 -0
  377. package/dist/src/schemas/home.d.mts +63 -0
  378. package/dist/src/schemas/home.d.mts.map +1 -0
  379. package/dist/src/schemas/home.mjs +121 -0
  380. package/dist/src/schemas/home.mjs.map +1 -0
  381. package/dist/src/schemas/httpApiContracts.cjs +441 -0
  382. package/dist/src/schemas/httpApiContracts.cjs.map +1 -0
  383. package/dist/src/schemas/httpApiContracts.d.mts +78 -0
  384. package/dist/src/schemas/httpApiContracts.d.mts.map +1 -0
  385. package/dist/src/schemas/httpApiContracts.mjs +434 -0
  386. package/dist/src/schemas/httpApiContracts.mjs.map +1 -0
  387. package/dist/src/schemas/hubChannel.cjs +3 -0
  388. package/dist/src/schemas/hubChannel.cjs.map +1 -1
  389. package/dist/src/schemas/hubChannel.d.mts +84 -60
  390. package/dist/src/schemas/hubChannel.d.mts.map +1 -1
  391. package/dist/src/schemas/hubChannel.mjs +3 -1
  392. package/dist/src/schemas/hubChannel.mjs.map +1 -1
  393. package/dist/src/schemas/leader.cjs.map +1 -1
  394. package/dist/src/schemas/leader.d.mts +3 -3
  395. package/dist/src/schemas/leader.d.mts.map +1 -1
  396. package/dist/src/schemas/leader.mjs.map +1 -1
  397. package/dist/src/schemas/mcpBundle.d.mts +3 -3
  398. package/dist/src/schemas/mcpFacet.cjs.map +1 -1
  399. package/dist/src/schemas/mcpFacet.d.mts +22 -22
  400. package/dist/src/schemas/mcpFacet.d.mts.map +1 -1
  401. package/dist/src/schemas/mcpFacet.mjs.map +1 -1
  402. package/dist/src/schemas/mcpProjection.cjs +41 -41
  403. package/dist/src/schemas/mcpProjection.cjs.map +1 -1
  404. package/dist/src/schemas/mcpProjection.d.mts +31 -30
  405. package/dist/src/schemas/mcpProjection.d.mts.map +1 -1
  406. package/dist/src/schemas/mcpProjection.mjs +29 -29
  407. package/dist/src/schemas/mcpProjection.mjs.map +1 -1
  408. package/dist/src/schemas/mcpSession.cjs +23 -23
  409. package/dist/src/schemas/mcpSession.cjs.map +1 -1
  410. package/dist/src/schemas/mcpSession.d.mts +12 -12
  411. package/dist/src/schemas/mcpSession.d.mts.map +1 -1
  412. package/dist/src/schemas/mcpSession.mjs +18 -18
  413. package/dist/src/schemas/mcpSession.mjs.map +1 -1
  414. package/dist/src/schemas/mcpStatus.cjs +5 -5
  415. package/dist/src/schemas/mcpStatus.cjs.map +1 -1
  416. package/dist/src/schemas/mcpStatus.d.mts +4 -4
  417. package/dist/src/schemas/mcpStatus.d.mts.map +1 -1
  418. package/dist/src/schemas/mcpStatus.mjs +4 -4
  419. package/dist/src/schemas/mcpStatus.mjs.map +1 -1
  420. package/dist/src/schemas/mcpToolResolver.cjs +9 -9
  421. package/dist/src/schemas/mcpToolResolver.cjs.map +1 -1
  422. package/dist/src/schemas/mcpToolResolver.d.mts +7 -7
  423. package/dist/src/schemas/mcpToolResolver.d.mts.map +1 -1
  424. package/dist/src/schemas/mcpToolResolver.mjs +7 -7
  425. package/dist/src/schemas/mcpToolResolver.mjs.map +1 -1
  426. package/dist/src/schemas/narration.cjs +9 -9
  427. package/dist/src/schemas/narration.cjs.map +1 -1
  428. package/dist/src/schemas/narration.d.mts +5 -5
  429. package/dist/src/schemas/narration.d.mts.map +1 -1
  430. package/dist/src/schemas/narration.mjs +7 -7
  431. package/dist/src/schemas/narration.mjs.map +1 -1
  432. package/dist/src/schemas/notification.cjs +45 -45
  433. package/dist/src/schemas/notification.cjs.map +1 -1
  434. package/dist/src/schemas/notification.d.mts +22 -22
  435. package/dist/src/schemas/notification.d.mts.map +1 -1
  436. package/dist/src/schemas/notification.mjs +31 -31
  437. package/dist/src/schemas/notification.mjs.map +1 -1
  438. package/dist/src/schemas/packageApi.cjs +28 -28
  439. package/dist/src/schemas/packageApi.cjs.map +1 -1
  440. package/dist/src/schemas/packageApi.d.mts +91 -65
  441. package/dist/src/schemas/packageApi.d.mts.map +1 -1
  442. package/dist/src/schemas/packageApi.mjs +18 -18
  443. package/dist/src/schemas/packageApi.mjs.map +1 -1
  444. package/dist/src/schemas/platform.cjs +34 -0
  445. package/dist/src/schemas/platform.cjs.map +1 -0
  446. package/dist/src/schemas/platform.d.mts +75 -0
  447. package/dist/src/schemas/platform.d.mts.map +1 -0
  448. package/dist/src/schemas/platform.mjs +27 -0
  449. package/dist/src/schemas/platform.mjs.map +1 -0
  450. package/dist/src/schemas/pluginContributions.cjs.map +1 -1
  451. package/dist/src/schemas/pluginContributions.d.mts +12 -12
  452. package/dist/src/schemas/pluginContributions.d.mts.map +1 -1
  453. package/dist/src/schemas/pluginContributions.mjs.map +1 -1
  454. package/dist/src/schemas/pluginProtocol.cjs +24 -27
  455. package/dist/src/schemas/pluginProtocol.cjs.map +1 -1
  456. package/dist/src/schemas/pluginProtocol.d.mts +21 -21
  457. package/dist/src/schemas/pluginProtocol.d.mts.map +1 -1
  458. package/dist/src/schemas/pluginProtocol.mjs +18 -20
  459. package/dist/src/schemas/pluginProtocol.mjs.map +1 -1
  460. package/dist/src/schemas/profileIdentity.cjs +2 -2
  461. package/dist/src/schemas/profileIdentity.cjs.map +1 -1
  462. package/dist/src/schemas/profileIdentity.d.mts +1 -1
  463. package/dist/src/schemas/profileIdentity.mjs +2 -2
  464. package/dist/src/schemas/profileIdentity.mjs.map +1 -1
  465. package/dist/src/schemas/protocolChannelsContract.cjs +27 -0
  466. package/dist/src/schemas/protocolChannelsContract.cjs.map +1 -0
  467. package/dist/src/schemas/protocolChannelsContract.d.mts +37 -0
  468. package/dist/src/schemas/protocolChannelsContract.d.mts.map +1 -0
  469. package/dist/src/schemas/protocolChannelsContract.mjs +25 -0
  470. package/dist/src/schemas/protocolChannelsContract.mjs.map +1 -0
  471. package/dist/src/schemas/protocolContracts.cjs +168 -0
  472. package/dist/src/schemas/protocolContracts.cjs.map +1 -0
  473. package/dist/src/schemas/protocolContracts.d.mts +69 -0
  474. package/dist/src/schemas/protocolContracts.d.mts.map +1 -0
  475. package/dist/src/schemas/protocolContracts.mjs +164 -0
  476. package/dist/src/schemas/protocolContracts.mjs.map +1 -0
  477. package/dist/src/schemas/protocolHubContract.cjs +51 -0
  478. package/dist/src/schemas/protocolHubContract.cjs.map +1 -0
  479. package/dist/src/schemas/protocolHubContract.d.mts +218 -0
  480. package/dist/src/schemas/protocolHubContract.d.mts.map +1 -0
  481. package/dist/src/schemas/protocolHubContract.mjs +49 -0
  482. package/dist/src/schemas/protocolHubContract.mjs.map +1 -0
  483. package/dist/src/schemas/protocolSessionContract.cjs +22 -0
  484. package/dist/src/schemas/protocolSessionContract.cjs.map +1 -0
  485. package/dist/src/schemas/protocolSessionContract.d.mts +324 -0
  486. package/dist/src/schemas/protocolSessionContract.d.mts.map +1 -0
  487. package/dist/src/schemas/protocolSessionContract.mjs +22 -0
  488. package/dist/src/schemas/protocolSessionContract.mjs.map +1 -0
  489. package/dist/src/schemas/protocolThreadContract.cjs +21 -0
  490. package/dist/src/schemas/protocolThreadContract.cjs.map +1 -0
  491. package/dist/src/schemas/protocolThreadContract.d.mts +29 -0
  492. package/dist/src/schemas/protocolThreadContract.d.mts.map +1 -0
  493. package/dist/src/schemas/protocolThreadContract.mjs +20 -0
  494. package/dist/src/schemas/protocolThreadContract.mjs.map +1 -0
  495. package/dist/src/schemas/readiness.cjs +36 -36
  496. package/dist/src/schemas/readiness.cjs.map +1 -1
  497. package/dist/src/schemas/readiness.d.mts +37 -37
  498. package/dist/src/schemas/readiness.d.mts.map +1 -1
  499. package/dist/src/schemas/readiness.mjs +31 -31
  500. package/dist/src/schemas/readiness.mjs.map +1 -1
  501. package/dist/src/schemas/serverBundle.d.mts +5 -5
  502. package/dist/src/schemas/serverPlugin.cjs +103 -0
  503. package/dist/src/schemas/serverPlugin.cjs.map +1 -0
  504. package/dist/src/schemas/serverPlugin.d.mts +176 -0
  505. package/dist/src/schemas/serverPlugin.d.mts.map +1 -0
  506. package/dist/src/schemas/serverPlugin.mjs +95 -0
  507. package/dist/src/schemas/serverPlugin.mjs.map +1 -0
  508. package/dist/src/schemas/serverScope.cjs +37 -0
  509. package/dist/src/schemas/serverScope.cjs.map +1 -0
  510. package/dist/src/schemas/serverScope.d.mts +77 -0
  511. package/dist/src/schemas/serverScope.d.mts.map +1 -0
  512. package/dist/src/schemas/serverScope.mjs +33 -0
  513. package/dist/src/schemas/serverScope.mjs.map +1 -0
  514. package/dist/src/schemas/sessionApiContracts.cjs +320 -0
  515. package/dist/src/schemas/sessionApiContracts.cjs.map +1 -0
  516. package/dist/src/schemas/sessionApiContracts.mjs +318 -0
  517. package/dist/src/schemas/sessionApiContracts.mjs.map +1 -0
  518. package/dist/src/schemas/sessionProtocol.cjs +20 -13
  519. package/dist/src/schemas/sessionProtocol.cjs.map +1 -1
  520. package/dist/src/schemas/sessionProtocol.d.mts +37 -54
  521. package/dist/src/schemas/sessionProtocol.d.mts.map +1 -1
  522. package/dist/src/schemas/sessionProtocol.mjs +17 -8
  523. package/dist/src/schemas/sessionProtocol.mjs.map +1 -1
  524. package/dist/src/schemas/skills.cjs +16 -16
  525. package/dist/src/schemas/skills.cjs.map +1 -1
  526. package/dist/src/schemas/skills.d.mts +7 -7
  527. package/dist/src/schemas/skills.d.mts.map +1 -1
  528. package/dist/src/schemas/skills.mjs +12 -12
  529. package/dist/src/schemas/skills.mjs.map +1 -1
  530. package/dist/src/schemas/toolOverrides.cjs +9 -9
  531. package/dist/src/schemas/toolOverrides.cjs.map +1 -1
  532. package/dist/src/schemas/toolOverrides.d.mts +8 -8
  533. package/dist/src/schemas/toolOverrides.d.mts.map +1 -1
  534. package/dist/src/schemas/toolOverrides.mjs +7 -7
  535. package/dist/src/schemas/toolOverrides.mjs.map +1 -1
  536. package/dist/src/schemas/toolSurface.cjs +9 -9
  537. package/dist/src/schemas/toolSurface.cjs.map +1 -1
  538. package/dist/src/schemas/toolSurface.d.mts +13 -13
  539. package/dist/src/schemas/toolSurface.d.mts.map +1 -1
  540. package/dist/src/schemas/toolSurface.mjs +7 -7
  541. package/dist/src/schemas/toolSurface.mjs.map +1 -1
  542. package/dist/src/schemas/uiHub.cjs +9 -9
  543. package/dist/src/schemas/uiHub.cjs.map +1 -1
  544. package/dist/src/schemas/uiHub.d.mts +12 -12
  545. package/dist/src/schemas/uiHub.d.mts.map +1 -1
  546. package/dist/src/schemas/uiHub.mjs +7 -7
  547. package/dist/src/schemas/uiHub.mjs.map +1 -1
  548. package/dist/src/server/directHarnessRuntime.cjs +691 -775
  549. package/dist/src/server/directHarnessRuntime.cjs.map +1 -1
  550. package/dist/src/server/directHarnessRuntime.d.mts +5 -1
  551. package/dist/src/server/directHarnessRuntime.d.mts.map +1 -0
  552. package/dist/src/server/directHarnessRuntime.mjs +671 -754
  553. package/dist/src/server/directHarnessRuntime.mjs.map +1 -1
  554. package/dist/src/server/largeFrameLink.cjs +47 -0
  555. package/dist/src/server/largeFrameLink.cjs.map +1 -0
  556. package/dist/src/server/largeFrameLink.mjs +47 -0
  557. package/dist/src/server/largeFrameLink.mjs.map +1 -0
  558. package/dist/src/server/liveImport.cjs +1 -1
  559. package/dist/src/server/liveImport.cjs.map +1 -1
  560. package/dist/src/server/liveImport.d.mts +1 -1
  561. package/dist/src/server/liveImport.mjs +1 -1
  562. package/dist/src/server/liveImport.mjs.map +1 -1
  563. package/dist/src/server/mcpBundleLoader.cjs.map +1 -1
  564. package/dist/src/server/mcpBundleLoader.d.mts +6 -6
  565. package/dist/src/server/mcpBundleLoader.d.mts.map +1 -1
  566. package/dist/src/server/mcpBundleLoader.mjs.map +1 -1
  567. package/dist/src/server/serverPackages.cjs +60 -0
  568. package/dist/src/server/serverPackages.cjs.map +1 -0
  569. package/dist/src/server/serverPackages.d.mts +44 -0
  570. package/dist/src/server/serverPackages.d.mts.map +1 -0
  571. package/dist/src/server/serverPackages.mjs +59 -0
  572. package/dist/src/server/serverPackages.mjs.map +1 -0
  573. package/dist/src/server/serverScope.cjs +510 -0
  574. package/dist/src/server/serverScope.cjs.map +1 -0
  575. package/dist/src/server/serverScope.d.mts +123 -0
  576. package/dist/src/server/serverScope.d.mts.map +1 -0
  577. package/dist/src/server/serverScope.mjs +510 -0
  578. package/dist/src/server/serverScope.mjs.map +1 -0
  579. package/dist/src/server/sessionMcpHandler.cjs +3 -3
  580. package/dist/src/server/sessionMcpHandler.cjs.map +1 -1
  581. package/dist/src/server/sessionMcpHandler.mjs +4 -4
  582. package/dist/src/server/sessionMcpHandler.mjs.map +1 -1
  583. package/dist/src/server/sessionMcpRoutes.cjs +2 -1
  584. package/dist/src/server/sessionMcpRoutes.cjs.map +1 -1
  585. package/dist/src/server/sessionMcpRoutes.mjs +2 -1
  586. package/dist/src/server/sessionMcpRoutes.mjs.map +1 -1
  587. package/dist/src/server/threadJournals.cjs +38 -107
  588. package/dist/src/server/threadJournals.cjs.map +1 -1
  589. package/dist/src/server/threadJournals.mjs +38 -104
  590. package/dist/src/server/threadJournals.mjs.map +1 -1
  591. package/dist/src/services/apiSurfaceAssert/index.cjs +1 -1
  592. package/dist/src/services/apiSurfaceAssert/index.cjs.map +1 -1
  593. package/dist/src/services/apiSurfaceAssert/index.d.mts +6 -6
  594. package/dist/src/services/apiSurfaceAssert/index.mjs +1 -1
  595. package/dist/src/services/apiSurfaceAssert/index.mjs.map +1 -1
  596. package/dist/src/services/chatgptAuth/index.cjs +1 -220
  597. package/dist/src/services/chatgptAuth/index.cjs.map +1 -1
  598. package/dist/src/services/chatgptAuth/index.d.mts +0 -18
  599. package/dist/src/services/chatgptAuth/index.d.mts.map +1 -1
  600. package/dist/src/services/chatgptAuth/index.mjs +1 -217
  601. package/dist/src/services/chatgptAuth/index.mjs.map +1 -1
  602. package/dist/src/services/chatgptImages/index.cjs +1 -1
  603. package/dist/src/services/chatgptImages/index.cjs.map +1 -1
  604. package/dist/src/services/chatgptImages/index.mjs +1 -1
  605. package/dist/src/services/chatgptImages/index.mjs.map +1 -1
  606. package/dist/src/services/chatgptLogin/index.cjs +230 -0
  607. package/dist/src/services/chatgptLogin/index.cjs.map +1 -0
  608. package/dist/src/services/chatgptLogin/index.d.mts +21 -0
  609. package/dist/src/services/chatgptLogin/index.d.mts.map +1 -0
  610. package/dist/src/services/chatgptLogin/index.mjs +227 -0
  611. package/dist/src/services/chatgptLogin/index.mjs.map +1 -0
  612. package/dist/src/services/chatgptWebSearch/index.cjs +1 -1
  613. package/dist/src/services/chatgptWebSearch/index.cjs.map +1 -1
  614. package/dist/src/services/chatgptWebSearch/index.mjs +1 -1
  615. package/dist/src/services/chatgptWebSearch/index.mjs.map +1 -1
  616. package/dist/src/services/contextContributions/index.cjs +8 -8
  617. package/dist/src/services/contextContributions/index.cjs.map +1 -1
  618. package/dist/src/services/contextContributions/index.d.mts +3 -3
  619. package/dist/src/services/contextContributions/index.d.mts.map +1 -1
  620. package/dist/src/services/contextContributions/index.mjs +8 -8
  621. package/dist/src/services/contextContributions/index.mjs.map +1 -1
  622. package/dist/src/services/devProxyStore/devProxyRecords.cjs +59 -0
  623. package/dist/src/services/devProxyStore/devProxyRecords.cjs.map +1 -0
  624. package/dist/src/services/devProxyStore/devProxyRecords.mjs +56 -0
  625. package/dist/src/services/devProxyStore/devProxyRecords.mjs.map +1 -0
  626. package/dist/src/services/devProxyStore/index.cjs +7 -101
  627. package/dist/src/services/devProxyStore/index.cjs.map +1 -1
  628. package/dist/src/services/devProxyStore/index.mjs +7 -101
  629. package/dist/src/services/devProxyStore/index.mjs.map +1 -1
  630. package/dist/src/services/devProxyStore/sync.cjs +66 -0
  631. package/dist/src/services/devProxyStore/sync.cjs.map +1 -0
  632. package/dist/src/services/devProxyStore/sync.mjs +63 -0
  633. package/dist/src/services/devProxyStore/sync.mjs.map +1 -0
  634. package/dist/src/services/durableNavigation/docs.cjs +15 -0
  635. package/dist/src/services/durableNavigation/docs.cjs.map +1 -0
  636. package/dist/src/services/durableNavigation/docs.mjs +16 -0
  637. package/dist/src/services/durableNavigation/docs.mjs.map +1 -0
  638. package/dist/src/services/durableNavigation/index.cjs +3 -18
  639. package/dist/src/services/durableNavigation/index.cjs.map +1 -1
  640. package/dist/src/services/durableNavigation/index.mjs +2 -17
  641. package/dist/src/services/durableNavigation/index.mjs.map +1 -1
  642. package/dist/src/services/durableQueue/docs.cjs +12 -0
  643. package/dist/src/services/durableQueue/docs.cjs.map +1 -0
  644. package/dist/src/services/durableQueue/docs.mjs +13 -0
  645. package/dist/src/services/durableQueue/docs.mjs.map +1 -0
  646. package/dist/src/services/durableQueue/index.cjs +151 -0
  647. package/dist/src/services/durableQueue/index.cjs.map +1 -0
  648. package/dist/src/services/durableQueue/index.mjs +149 -0
  649. package/dist/src/services/durableQueue/index.mjs.map +1 -0
  650. package/dist/src/services/durableRequestReceipts/docs.cjs +11 -0
  651. package/dist/src/services/durableRequestReceipts/docs.cjs.map +1 -0
  652. package/dist/src/services/durableRequestReceipts/docs.mjs +12 -0
  653. package/dist/src/services/durableRequestReceipts/docs.mjs.map +1 -0
  654. package/dist/src/services/{requestReceipts → durableRequestReceipts}/index.cjs +10 -16
  655. package/dist/src/services/durableRequestReceipts/index.cjs.map +1 -0
  656. package/dist/src/services/durableRequestReceipts/index.d.mts +12 -0
  657. package/dist/src/services/durableRequestReceipts/index.d.mts.map +1 -0
  658. package/dist/src/services/{requestReceipts → durableRequestReceipts}/index.mjs +7 -13
  659. package/dist/src/services/durableRequestReceipts/index.mjs.map +1 -0
  660. package/dist/src/services/durableSession/docs.cjs +65 -0
  661. package/dist/src/services/durableSession/docs.cjs.map +1 -0
  662. package/dist/src/services/durableSession/docs.d.mts +17 -0
  663. package/dist/src/services/durableSession/docs.d.mts.map +1 -0
  664. package/dist/src/services/durableSession/docs.mjs +60 -0
  665. package/dist/src/services/durableSession/docs.mjs.map +1 -0
  666. package/dist/src/services/durableSession/index.cjs +21 -0
  667. package/dist/src/services/durableSession/index.cjs.map +1 -0
  668. package/dist/src/services/durableSession/index.d.mts +13 -0
  669. package/dist/src/services/durableSession/index.d.mts.map +1 -0
  670. package/dist/src/services/durableSession/index.mjs +20 -0
  671. package/dist/src/services/durableSession/index.mjs.map +1 -0
  672. package/dist/src/services/durableSubagents/docs.cjs +15 -0
  673. package/dist/src/services/durableSubagents/docs.cjs.map +1 -0
  674. package/dist/src/services/durableSubagents/docs.mjs +16 -0
  675. package/dist/src/services/durableSubagents/docs.mjs.map +1 -0
  676. package/dist/src/services/durableSubagents/extension.cjs +11 -0
  677. package/dist/src/services/durableSubagents/extension.cjs.map +1 -0
  678. package/dist/src/services/durableSubagents/extension.mjs +12 -0
  679. package/dist/src/services/durableSubagents/extension.mjs.map +1 -0
  680. package/dist/src/services/durableSubagents/index.cjs +95 -0
  681. package/dist/src/services/durableSubagents/index.cjs.map +1 -0
  682. package/dist/src/services/durableSubagents/index.mjs +90 -0
  683. package/dist/src/services/durableSubagents/index.mjs.map +1 -0
  684. package/dist/src/services/durableSubagents/tasks.cjs +25 -0
  685. package/dist/src/services/durableSubagents/tasks.cjs.map +1 -0
  686. package/dist/src/services/durableSubagents/tasks.mjs +26 -0
  687. package/dist/src/services/durableSubagents/tasks.mjs.map +1 -0
  688. package/dist/src/services/headlessClient/index.cjs +20 -13
  689. package/dist/src/services/headlessClient/index.cjs.map +1 -1
  690. package/dist/src/services/headlessClient/index.mjs +21 -14
  691. package/dist/src/services/headlessClient/index.mjs.map +1 -1
  692. package/dist/src/services/historyOwnership/type.d.mts +15 -0
  693. package/dist/src/services/historyOwnership/type.d.mts.map +1 -0
  694. package/dist/src/services/hubChannelHarness/index.cjs +2 -2
  695. package/dist/src/services/hubChannelHarness/index.cjs.map +1 -1
  696. package/dist/src/services/hubChannelHarness/index.d.mts +8 -8
  697. package/dist/src/services/hubChannelHarness/index.d.mts.map +1 -1
  698. package/dist/src/services/hubChannelHarness/index.mjs +2 -2
  699. package/dist/src/services/hubChannelHarness/index.mjs.map +1 -1
  700. package/dist/src/services/json/core.cjs +30 -0
  701. package/dist/src/services/json/core.cjs.map +1 -0
  702. package/dist/src/services/json/core.d.mts +21 -0
  703. package/dist/src/services/json/core.d.mts.map +1 -0
  704. package/dist/src/services/json/core.mjs +26 -0
  705. package/dist/src/services/json/core.mjs.map +1 -0
  706. package/dist/src/services/json/sync.cjs +48 -0
  707. package/dist/src/services/json/sync.cjs.map +1 -0
  708. package/dist/src/services/json/sync.d.mts +22 -0
  709. package/dist/src/services/json/sync.d.mts.map +1 -0
  710. package/dist/src/services/json/sync.mjs +43 -0
  711. package/dist/src/services/json/sync.mjs.map +1 -0
  712. package/dist/src/services/kernel/index.cjs +2 -2
  713. package/dist/src/services/kernel/index.cjs.map +1 -1
  714. package/dist/src/services/kernel/index.d.mts +3 -3
  715. package/dist/src/services/kernel/index.d.mts.map +1 -1
  716. package/dist/src/services/kernel/index.mjs +2 -2
  717. package/dist/src/services/kernel/index.mjs.map +1 -1
  718. package/dist/src/services/nativeChildTools/index.cjs +16 -0
  719. package/dist/src/services/nativeChildTools/index.cjs.map +1 -0
  720. package/dist/src/services/nativeChildTools/index.mjs +16 -0
  721. package/dist/src/services/nativeChildTools/index.mjs.map +1 -0
  722. package/dist/src/services/nodeHost/index.cjs +30 -0
  723. package/dist/src/services/nodeHost/index.cjs.map +1 -0
  724. package/dist/src/services/nodeHost/index.d.mts +16 -0
  725. package/dist/src/services/nodeHost/index.d.mts.map +1 -0
  726. package/dist/src/services/nodeHost/index.mjs +27 -0
  727. package/dist/src/services/nodeHost/index.mjs.map +1 -0
  728. package/dist/src/services/nodeModelDependencies/index.cjs +89 -0
  729. package/dist/src/services/nodeModelDependencies/index.cjs.map +1 -0
  730. package/dist/src/services/nodeModelDependencies/index.mjs +86 -0
  731. package/dist/src/services/nodeModelDependencies/index.mjs.map +1 -0
  732. package/dist/src/services/openSessionRegistry/index.cjs +6 -128
  733. package/dist/src/services/openSessionRegistry/index.cjs.map +1 -1
  734. package/dist/src/services/openSessionRegistry/index.d.mts +5 -36
  735. package/dist/src/services/openSessionRegistry/index.mjs +6 -128
  736. package/dist/src/services/openSessionRegistry/index.mjs.map +1 -1
  737. package/dist/src/services/openSessionRegistry/openSessionRecords.cjs +87 -0
  738. package/dist/src/services/openSessionRegistry/openSessionRecords.cjs.map +1 -0
  739. package/dist/src/services/openSessionRegistry/openSessionRecords.d.mts +30 -0
  740. package/dist/src/services/openSessionRegistry/openSessionRecords.d.mts.map +1 -0
  741. package/dist/src/services/openSessionRegistry/openSessionRecords.mjs +81 -0
  742. package/dist/src/services/openSessionRegistry/openSessionRecords.mjs.map +1 -0
  743. package/dist/src/services/openSessionRegistry/sync.cjs +71 -0
  744. package/dist/src/services/openSessionRegistry/sync.cjs.map +1 -0
  745. package/dist/src/services/openSessionRegistry/sync.d.mts +14 -0
  746. package/dist/src/services/openSessionRegistry/sync.d.mts.map +1 -0
  747. package/dist/src/services/openSessionRegistry/sync.mjs +68 -0
  748. package/dist/src/services/openSessionRegistry/sync.mjs.map +1 -0
  749. package/dist/src/services/packageApiHarness/index.cjs +1 -1
  750. package/dist/src/services/packageApiHarness/index.cjs.map +1 -1
  751. package/dist/src/services/packageApiHarness/index.d.mts +6 -6
  752. package/dist/src/services/packageApiHarness/index.d.mts.map +1 -1
  753. package/dist/src/services/packageApiHarness/index.mjs +2 -2
  754. package/dist/src/services/packageApiHarness/index.mjs.map +1 -1
  755. package/dist/src/services/piArgs/index.cjs +53 -0
  756. package/dist/src/services/piArgs/index.cjs.map +1 -0
  757. package/dist/src/services/piArgs/index.d.mts +6 -0
  758. package/dist/src/services/piArgs/index.d.mts.map +1 -0
  759. package/dist/src/services/piArgs/index.mjs +53 -0
  760. package/dist/src/services/piArgs/index.mjs.map +1 -0
  761. package/dist/src/services/piExtensionHost/index.cjs +47 -39
  762. package/dist/src/services/piExtensionHost/index.cjs.map +1 -1
  763. package/dist/src/services/piExtensionHost/index.d.mts +83 -0
  764. package/dist/src/services/piExtensionHost/index.d.mts.map +1 -0
  765. package/dist/src/services/piExtensionHost/index.mjs +47 -38
  766. package/dist/src/services/piExtensionHost/index.mjs.map +1 -1
  767. package/dist/src/services/piHelpTools/index.cjs +5 -5
  768. package/dist/src/services/piHelpTools/index.cjs.map +1 -1
  769. package/dist/src/services/piHelpTools/index.d.mts.map +1 -1
  770. package/dist/src/services/piHelpTools/index.mjs +7 -7
  771. package/dist/src/services/piHelpTools/index.mjs.map +1 -1
  772. package/dist/src/services/piMessages/index.cjs +106 -0
  773. package/dist/src/services/piMessages/index.cjs.map +1 -0
  774. package/dist/src/services/piMessages/index.mjs +105 -0
  775. package/dist/src/services/piMessages/index.mjs.map +1 -0
  776. package/dist/src/services/piSessionEntries/index.cjs +4 -4
  777. package/dist/src/services/piSessionEntries/index.cjs.map +1 -1
  778. package/dist/src/services/piSessionEntries/index.mjs +3 -3
  779. package/dist/src/services/piSessionEntries/index.mjs.map +1 -1
  780. package/dist/src/services/piSettings/core.cjs +308 -0
  781. package/dist/src/services/piSettings/core.cjs.map +1 -0
  782. package/dist/src/services/piSettings/core.d.mts +102 -0
  783. package/dist/src/services/piSettings/core.d.mts.map +1 -0
  784. package/dist/src/services/piSettings/core.mjs +276 -0
  785. package/dist/src/services/piSettings/core.mjs.map +1 -0
  786. package/dist/src/services/piSettings/sync.cjs +119 -0
  787. package/dist/src/services/piSettings/sync.cjs.map +1 -0
  788. package/dist/src/services/piSettings/sync.d.mts +44 -0
  789. package/dist/src/services/piSettings/sync.d.mts.map +1 -0
  790. package/dist/src/services/piSettings/sync.mjs +110 -0
  791. package/dist/src/services/piSettings/sync.mjs.map +1 -0
  792. package/dist/src/services/piSummary/index.cjs +7 -0
  793. package/dist/src/services/piSummary/index.cjs.map +1 -0
  794. package/dist/src/services/piSummary/index.mjs +7 -0
  795. package/dist/src/services/piSummary/index.mjs.map +1 -0
  796. package/dist/src/services/platformFiles/index.cjs +44 -0
  797. package/dist/src/services/platformFiles/index.cjs.map +1 -0
  798. package/dist/src/services/platformFiles/index.d.mts +16 -0
  799. package/dist/src/services/platformFiles/index.d.mts.map +1 -0
  800. package/dist/src/services/platformFiles/index.mjs +39 -0
  801. package/dist/src/services/platformFiles/index.mjs.map +1 -0
  802. package/dist/src/services/pluginLifecycle/index.cjs +19 -13
  803. package/dist/src/services/pluginLifecycle/index.cjs.map +1 -1
  804. package/dist/src/services/pluginLifecycle/index.d.mts +2 -0
  805. package/dist/src/services/pluginLifecycle/index.d.mts.map +1 -1
  806. package/dist/src/services/pluginLifecycle/index.mjs +19 -14
  807. package/dist/src/services/pluginLifecycle/index.mjs.map +1 -1
  808. package/dist/src/services/poPackage/core.cjs +73 -0
  809. package/dist/src/services/poPackage/core.cjs.map +1 -0
  810. package/dist/src/services/poPackage/core.d.mts +32 -0
  811. package/dist/src/services/poPackage/core.d.mts.map +1 -0
  812. package/dist/src/services/poPackage/core.mjs +66 -0
  813. package/dist/src/services/poPackage/core.mjs.map +1 -0
  814. package/dist/src/services/poPackage/sync.cjs +55 -0
  815. package/dist/src/services/poPackage/sync.cjs.map +1 -0
  816. package/dist/src/services/poPackage/sync.d.mts +21 -0
  817. package/dist/src/services/poPackage/sync.d.mts.map +1 -0
  818. package/dist/src/services/poPackage/sync.mjs +50 -0
  819. package/dist/src/services/poPackage/sync.mjs.map +1 -0
  820. package/dist/src/services/providerAuth/index.cjs +11 -7
  821. package/dist/src/services/providerAuth/index.cjs.map +1 -1
  822. package/dist/src/services/providerAuth/index.mjs +11 -7
  823. package/dist/src/services/providerAuth/index.mjs.map +1 -1
  824. package/dist/src/services/publicFileShares/index.cjs +1 -1
  825. package/dist/src/services/publicFileShares/index.cjs.map +1 -1
  826. package/dist/src/services/publicFileShares/index.d.mts +2 -2
  827. package/dist/src/services/publicFileShares/index.mjs +2 -2
  828. package/dist/src/services/publicFileShares/index.mjs.map +1 -1
  829. package/dist/src/services/remoteAccess/index.d.mts +1 -0
  830. package/dist/src/services/remoteAccess/index.d.mts.map +1 -1
  831. package/dist/src/services/remoteAccessStore/index.cjs +8 -190
  832. package/dist/src/services/remoteAccessStore/index.cjs.map +1 -1
  833. package/dist/src/services/remoteAccessStore/index.d.mts +2 -0
  834. package/dist/src/services/remoteAccessStore/index.mjs +7 -187
  835. package/dist/src/services/remoteAccessStore/index.mjs.map +1 -1
  836. package/dist/src/services/remoteAccessStore/remoteAccessRecords.cjs +98 -0
  837. package/dist/src/services/remoteAccessStore/remoteAccessRecords.cjs.map +1 -0
  838. package/dist/src/services/remoteAccessStore/remoteAccessRecords.mjs +88 -0
  839. package/dist/src/services/remoteAccessStore/remoteAccessRecords.mjs.map +1 -0
  840. package/dist/src/services/remoteAccessStore/sync.cjs +111 -0
  841. package/dist/src/services/remoteAccessStore/sync.cjs.map +1 -0
  842. package/dist/src/services/remoteAccessStore/sync.mjs +108 -0
  843. package/dist/src/services/remoteAccessStore/sync.mjs.map +1 -0
  844. package/dist/src/services/runtimeIdentity/sync.cjs +23 -0
  845. package/dist/src/services/runtimeIdentity/sync.cjs.map +1 -0
  846. package/dist/src/services/runtimeIdentity/sync.d.mts +9 -0
  847. package/dist/src/services/runtimeIdentity/sync.d.mts.map +1 -0
  848. package/dist/src/services/runtimeIdentity/sync.mjs +20 -0
  849. package/dist/src/services/runtimeIdentity/sync.mjs.map +1 -0
  850. package/dist/src/services/serialRunner/index.cjs +25 -0
  851. package/dist/src/services/serialRunner/index.cjs.map +1 -0
  852. package/dist/src/services/serialRunner/index.d.mts +10 -0
  853. package/dist/src/services/serialRunner/index.d.mts.map +1 -0
  854. package/dist/src/services/serialRunner/index.mjs +25 -0
  855. package/dist/src/services/serialRunner/index.mjs.map +1 -0
  856. package/dist/src/services/{serverFacet → serverHost}/index.cjs +5 -5
  857. package/dist/src/services/serverHost/index.cjs.map +1 -0
  858. package/dist/src/services/serverHost/index.d.mts +31 -0
  859. package/dist/src/services/serverHost/index.d.mts.map +1 -0
  860. package/dist/src/services/{serverFacet → serverHost}/index.mjs +5 -5
  861. package/dist/src/services/serverHost/index.mjs.map +1 -0
  862. package/dist/src/services/sessionAttachments/index.cjs +4 -3
  863. package/dist/src/services/sessionAttachments/index.cjs.map +1 -1
  864. package/dist/src/services/sessionAttachments/index.d.mts +1 -6
  865. package/dist/src/services/sessionAttachments/index.d.mts.map +1 -1
  866. package/dist/src/services/sessionAttachments/index.mjs +3 -2
  867. package/dist/src/services/sessionAttachments/index.mjs.map +1 -1
  868. package/dist/src/services/sessionAttachments/type.d.mts +9 -0
  869. package/dist/src/services/sessionAttachments/type.d.mts.map +1 -0
  870. package/dist/src/services/sessionFiles/index.cjs +96 -0
  871. package/dist/src/services/sessionFiles/index.cjs.map +1 -0
  872. package/dist/src/services/sessionFiles/index.d.mts +33 -0
  873. package/dist/src/services/sessionFiles/index.d.mts.map +1 -0
  874. package/dist/src/services/sessionFiles/index.mjs +89 -0
  875. package/dist/src/services/sessionFiles/index.mjs.map +1 -0
  876. package/dist/src/services/sessionFiles/sessionDirectory.cjs +66 -0
  877. package/dist/src/services/sessionFiles/sessionDirectory.cjs.map +1 -0
  878. package/dist/src/services/sessionFiles/sessionDirectory.mjs +62 -0
  879. package/dist/src/services/sessionFiles/sessionDirectory.mjs.map +1 -0
  880. package/dist/src/services/sessionGitStatus/index.cjs +31 -33
  881. package/dist/src/services/sessionGitStatus/index.cjs.map +1 -1
  882. package/dist/src/services/sessionGitStatus/index.mjs +31 -33
  883. package/dist/src/services/sessionGitStatus/index.mjs.map +1 -1
  884. package/dist/src/services/sessionPresentation/index.cjs +3 -27
  885. package/dist/src/services/sessionPresentation/index.cjs.map +1 -1
  886. package/dist/src/services/sessionPresentation/index.mjs +3 -27
  887. package/dist/src/services/sessionPresentation/index.mjs.map +1 -1
  888. package/dist/src/services/skillPrompt/index.cjs +11 -0
  889. package/dist/src/services/skillPrompt/index.cjs.map +1 -0
  890. package/dist/src/services/skillPrompt/index.mjs +11 -0
  891. package/dist/src/services/skillPrompt/index.mjs.map +1 -0
  892. package/dist/src/services/sqliteSessionHistory/index.cjs +44 -30
  893. package/dist/src/services/sqliteSessionHistory/index.cjs.map +1 -1
  894. package/dist/src/services/sqliteSessionHistory/index.d.mts +7 -4
  895. package/dist/src/services/sqliteSessionHistory/index.d.mts.map +1 -1
  896. package/dist/src/services/sqliteSessionHistory/index.mjs +43 -28
  897. package/dist/src/services/sqliteSessionHistory/index.mjs.map +1 -1
  898. package/dist/src/services/sqliteTranscriptReader/index.cjs +21 -45
  899. package/dist/src/services/sqliteTranscriptReader/index.cjs.map +1 -1
  900. package/dist/src/services/sqliteTranscriptReader/index.d.mts +3 -2
  901. package/dist/src/services/sqliteTranscriptReader/index.d.mts.map +1 -1
  902. package/dist/src/services/sqliteTranscriptReader/index.mjs +16 -38
  903. package/dist/src/services/sqliteTranscriptReader/index.mjs.map +1 -1
  904. package/dist/src/services/testMode/index.cjs +162 -0
  905. package/dist/src/services/testMode/index.cjs.map +1 -0
  906. package/dist/src/services/testMode/index.d.mts +17 -0
  907. package/dist/src/services/testMode/index.d.mts.map +1 -0
  908. package/dist/src/services/testMode/index.mjs +155 -0
  909. package/dist/src/services/testMode/index.mjs.map +1 -0
  910. package/dist/src/services/toolOverrides/index.cjs +6 -6
  911. package/dist/src/services/toolOverrides/index.cjs.map +1 -1
  912. package/dist/src/services/toolOverrides/index.d.mts +3 -3
  913. package/dist/src/services/toolOverrides/index.d.mts.map +1 -1
  914. package/dist/src/services/toolOverrides/index.mjs +6 -6
  915. package/dist/src/services/toolOverrides/index.mjs.map +1 -1
  916. package/dist/src/services/toolPrompt/index.d.mts +17 -0
  917. package/dist/src/services/toolPrompt/index.d.mts.map +1 -0
  918. package/dist/src/services/toolSurface/index.cjs +3 -3
  919. package/dist/src/services/toolSurface/index.cjs.map +1 -1
  920. package/dist/src/services/toolSurface/index.d.mts +3 -3
  921. package/dist/src/services/toolSurface/index.d.mts.map +1 -1
  922. package/dist/src/services/toolSurface/index.mjs +4 -4
  923. package/dist/src/services/toolSurface/index.mjs.map +1 -1
  924. package/dist/src/services/traceContext/index.cjs.map +1 -1
  925. package/dist/src/services/traceContext/index.mjs.map +1 -1
  926. package/dist/src/services/transcriptPages/index.cjs +159 -33
  927. package/dist/src/services/transcriptPages/index.cjs.map +1 -1
  928. package/dist/src/services/transcriptPages/index.mjs +158 -34
  929. package/dist/src/services/transcriptPages/index.mjs.map +1 -1
  930. package/dist/src/services/voiceToolsContract/index.cjs +7 -7
  931. package/dist/src/services/voiceToolsContract/index.cjs.map +1 -1
  932. package/dist/src/services/voiceToolsContract/index.d.mts +4 -4
  933. package/dist/src/services/voiceToolsContract/index.d.mts.map +1 -1
  934. package/dist/src/services/voiceToolsContract/index.mjs +7 -7
  935. package/dist/src/services/voiceToolsContract/index.mjs.map +1 -1
  936. package/dist/src/services/workspaceRegistry/index.cjs +9 -179
  937. package/dist/src/services/workspaceRegistry/index.cjs.map +1 -1
  938. package/dist/src/services/workspaceRegistry/index.d.mts +5 -47
  939. package/dist/src/services/workspaceRegistry/index.mjs +7 -176
  940. package/dist/src/services/workspaceRegistry/index.mjs.map +1 -1
  941. package/dist/src/services/workspaceRegistry/sync.cjs +148 -0
  942. package/dist/src/services/workspaceRegistry/sync.cjs.map +1 -0
  943. package/dist/src/services/workspaceRegistry/sync.d.mts +34 -0
  944. package/dist/src/services/workspaceRegistry/sync.d.mts.map +1 -0
  945. package/dist/src/services/workspaceRegistry/sync.mjs +140 -0
  946. package/dist/src/services/workspaceRegistry/sync.mjs.map +1 -0
  947. package/dist/src/services/workspaceRegistry/workspaceRecords.cjs +114 -0
  948. package/dist/src/services/workspaceRegistry/workspaceRecords.cjs.map +1 -0
  949. package/dist/src/services/workspaceRegistry/workspaceRecords.d.mts +31 -0
  950. package/dist/src/services/workspaceRegistry/workspaceRecords.d.mts.map +1 -0
  951. package/dist/src/services/workspaceRegistry/workspaceRecords.mjs +101 -0
  952. package/dist/src/services/workspaceRegistry/workspaceRecords.mjs.map +1 -0
  953. package/dist/src/systems/child/adapters/headlessChildSessionService.cjs +339 -202
  954. package/dist/src/systems/child/adapters/headlessChildSessionService.cjs.map +1 -1
  955. package/dist/src/systems/child/adapters/headlessChildSessionService.d.mts +16 -21
  956. package/dist/src/systems/child/adapters/headlessChildSessionService.d.mts.map +1 -1
  957. package/dist/src/systems/child/adapters/headlessChildSessionService.mjs +329 -191
  958. package/dist/src/systems/child/adapters/headlessChildSessionService.mjs.map +1 -1
  959. package/dist/src/systems/child/services/childSession/index.cjs +94 -20
  960. package/dist/src/systems/child/services/childSession/index.cjs.map +1 -1
  961. package/dist/src/systems/child/services/childSession/index.d.mts +12 -3
  962. package/dist/src/systems/child/services/childSession/index.d.mts.map +1 -1
  963. package/dist/src/systems/child/services/childSession/index.mjs +94 -20
  964. package/dist/src/systems/child/services/childSession/index.mjs.map +1 -1
  965. package/dist/src/systems/child/types/childSession.cjs +33 -13
  966. package/dist/src/systems/child/types/childSession.cjs.map +1 -1
  967. package/dist/src/systems/child/types/childSession.d.mts +143 -80
  968. package/dist/src/systems/child/types/childSession.d.mts.map +1 -1
  969. package/dist/src/systems/child/types/childSession.mjs +24 -9
  970. package/dist/src/systems/child/types/childSession.mjs.map +1 -1
  971. package/dist/src/systems/main/adapters/headlessHost.cjs +30 -27
  972. package/dist/src/systems/main/adapters/headlessHost.cjs.map +1 -1
  973. package/dist/src/systems/main/adapters/headlessHost.d.mts +22 -22
  974. package/dist/src/systems/main/adapters/headlessHost.d.mts.map +1 -1
  975. package/dist/src/systems/main/adapters/headlessHost.mjs +33 -30
  976. package/dist/src/systems/main/adapters/headlessHost.mjs.map +1 -1
  977. package/dist/src/systems/main/adapters/headlessSessionHost.cjs +248 -229
  978. package/dist/src/systems/main/adapters/headlessSessionHost.cjs.map +1 -1
  979. package/dist/src/systems/main/adapters/headlessSessionHost.d.mts +4 -5
  980. package/dist/src/systems/main/adapters/headlessSessionHost.d.mts.map +1 -1
  981. package/dist/src/systems/main/adapters/headlessSessionHost.mjs +239 -219
  982. package/dist/src/systems/main/adapters/headlessSessionHost.mjs.map +1 -1
  983. package/dist/src/systems/main/types/headlessHost.d.mts +16 -14
  984. package/dist/src/systems/main/types/headlessHost.d.mts.map +1 -1
  985. package/dist/src/testing/pi/testHost.cjs +2 -2
  986. package/dist/src/testing/pi/testHost.cjs.map +1 -1
  987. package/dist/src/testing/pi/testHost.d.mts +3 -2
  988. package/dist/src/testing/pi/testHost.mjs +3 -3
  989. package/dist/src/testing/pi/testHost.mjs.map +1 -1
  990. package/dist/src/types/config.d.mts +1 -1
  991. package/dist/src/types/config.d.mts.map +1 -1
  992. package/dist/src/types/kernel.d.mts +3 -3
  993. package/dist/src/types/server/directHarnessRuntime.d.mts +54 -25
  994. package/dist/src/types/server/directHarnessRuntime.d.mts.map +1 -1
  995. package/dist/src/types/server/sessionToolSurface.d.mts +9 -9
  996. package/dist/src/web/services/apiClient/index.d.mts +1 -0
  997. package/dist/src/web/services/apiPaths/index.cjs.map +1 -1
  998. package/dist/src/web/services/apiPaths/index.d.mts +1 -1
  999. package/dist/src/web/services/apiPaths/index.mjs.map +1 -1
  1000. package/dist/src/web/services/mcpWidget.cjs.map +1 -1
  1001. package/dist/src/web/services/mcpWidget.d.mts +2 -2
  1002. package/dist/src/web/services/mcpWidget.d.mts.map +1 -1
  1003. package/dist/src/web/services/mcpWidget.mjs.map +1 -1
  1004. package/dist/src/web/services/testing/templateRail.cjs +3 -0
  1005. package/dist/src/web/services/testing/templateRail.cjs.map +1 -1
  1006. package/dist/src/web/services/testing/templateRail.mjs +3 -0
  1007. package/dist/src/web/services/testing/templateRail.mjs.map +1 -1
  1008. package/dist/src/web/types/mcpWidget.d.mts +1 -1
  1009. package/dist/src/web/types/nativeTemplate.d.mts +1 -1
  1010. package/dist/src/web/types/nativeTemplate.d.mts.map +1 -1
  1011. package/dist/src/web/types/template.d.mts +8 -0
  1012. package/dist/src/web/types/template.d.mts.map +1 -1
  1013. package/dist/src/web/types/webPlugin.d.mts +17 -5
  1014. package/dist/src/web/types/webPlugin.d.mts.map +1 -1
  1015. package/dist/testMode.cjs +4 -0
  1016. package/dist/testMode.d.mts +2 -0
  1017. package/dist/testMode.mjs +1 -0
  1018. package/dist/testing.cjs +1 -1
  1019. package/dist/testing.d.mts +2 -2
  1020. package/dist/testing.mjs +2 -2
  1021. package/dist/toolInventory.cjs.map +1 -1
  1022. package/dist/toolInventory.mjs.map +1 -1
  1023. package/dist/toolNames.mjs +1 -2
  1024. package/dist/toolOverrides.cjs +4 -4
  1025. package/dist/toolOverrides.d.mts +3 -3
  1026. package/dist/toolOverrides.mjs +3 -3
  1027. package/dist/toolSurface.cjs +4 -4
  1028. package/dist/toolSurface.d.mts +3 -3
  1029. package/dist/toolSurface.mjs +3 -3
  1030. package/dist/transition.cjs +3 -3
  1031. package/dist/transition.d.cjs +3 -3
  1032. package/dist/transition.d.mts +2 -2
  1033. package/dist/transition.mjs +1 -2
  1034. package/dist/transitionClassifier.cjs.map +1 -1
  1035. package/dist/transitionClassifier.d.mts +2 -2
  1036. package/dist/transitionClassifier.d.mts.map +1 -1
  1037. package/dist/transitionClassifier.mjs.map +1 -1
  1038. package/dist/transitionCoordinator.cjs +3 -3
  1039. package/dist/transitionCoordinator.cjs.map +1 -1
  1040. package/dist/transitionCoordinator.d.mts +4 -4
  1041. package/dist/transitionCoordinator.d.mts.map +1 -1
  1042. package/dist/transitionCoordinator.mjs +3 -3
  1043. package/dist/transitionCoordinator.mjs.map +1 -1
  1044. package/dist/typesContextApi.d.mts +2 -1
  1045. package/dist/typesContextApi.d.mts.map +1 -1
  1046. package/dist/uiHub.cjs +3 -3
  1047. package/dist/uiHub.d.mts +2 -2
  1048. package/dist/uiHub.mjs +1 -2
  1049. package/dist/voiceTools.cjs +5 -5
  1050. package/dist/voiceTools.d.mts +3 -3
  1051. package/dist/voiceTools.mjs +3 -3
  1052. package/dist/web.cjs +8 -0
  1053. package/dist/web.d.mts +3 -2
  1054. package/dist/web.mjs +2 -1
  1055. package/dist/webCompositions.cjs.map +1 -1
  1056. package/dist/webCompositions.d.mts +7 -7
  1057. package/dist/webCompositions.d.mts.map +1 -1
  1058. package/dist/webCompositions.mjs.map +1 -1
  1059. package/licenses/Codex-Apache-2.0.txt +201 -0
  1060. package/package.json +58 -53
  1061. package/dist/doomPackage.cjs +0 -61
  1062. package/dist/doomPackage.cjs.map +0 -1
  1063. package/dist/doomPackage.d.mts +0 -17
  1064. package/dist/doomPackage.d.mts.map +0 -1
  1065. package/dist/doomPackage.mjs +0 -54
  1066. package/dist/doomPackage.mjs.map +0 -1
  1067. package/dist/jsonlSessionRepo.cjs +0 -44
  1068. package/dist/jsonlSessionRepo.cjs.map +0 -1
  1069. package/dist/jsonlSessionRepo.d.mts +0 -7
  1070. package/dist/jsonlSessionRepo.d.mts.map +0 -1
  1071. package/dist/jsonlSessionRepo.mjs +0 -42
  1072. package/dist/jsonlSessionRepo.mjs.map +0 -1
  1073. package/dist/runtimeJson.cjs.map +0 -1
  1074. package/dist/runtimeJson.d.mts.map +0 -1
  1075. package/dist/runtimeJson.mjs.map +0 -1
  1076. package/dist/runtimePiSettings.cjs.map +0 -1
  1077. package/dist/runtimePiSettings.d.mts.map +0 -1
  1078. package/dist/runtimePiSettings.mjs.map +0 -1
  1079. package/dist/serverFacet.cjs +0 -34
  1080. package/dist/serverFacet.d.mts +0 -10
  1081. package/dist/serverFacet.mjs +0 -9
  1082. package/dist/src/pi/piWebSocketListener.cjs +0 -115
  1083. package/dist/src/pi/piWebSocketListener.cjs.map +0 -1
  1084. package/dist/src/pi/piWebSocketListener.mjs +0 -115
  1085. package/dist/src/pi/piWebSocketListener.mjs.map +0 -1
  1086. package/dist/src/schemas/serverFacet.cjs +0 -111
  1087. package/dist/src/schemas/serverFacet.cjs.map +0 -1
  1088. package/dist/src/schemas/serverFacet.d.mts +0 -152
  1089. package/dist/src/schemas/serverFacet.d.mts.map +0 -1
  1090. package/dist/src/schemas/serverFacet.mjs +0 -101
  1091. package/dist/src/schemas/serverFacet.mjs.map +0 -1
  1092. package/dist/src/schemas/sessionUpdates.d.mts +0 -34
  1093. package/dist/src/schemas/sessionUpdates.d.mts.map +0 -1
  1094. package/dist/src/server/headlessProtocol.cjs +0 -382
  1095. package/dist/src/server/headlessProtocol.cjs.map +0 -1
  1096. package/dist/src/server/headlessProtocol.mjs +0 -382
  1097. package/dist/src/server/headlessProtocol.mjs.map +0 -1
  1098. package/dist/src/server/nativeChildTranscriptReader.cjs +0 -20
  1099. package/dist/src/server/nativeChildTranscriptReader.cjs.map +0 -1
  1100. package/dist/src/server/nativeChildTranscriptReader.mjs +0 -18
  1101. package/dist/src/server/nativeChildTranscriptReader.mjs.map +0 -1
  1102. package/dist/src/server/serverFacetLoader.cjs +0 -214
  1103. package/dist/src/server/serverFacetLoader.cjs.map +0 -1
  1104. package/dist/src/server/serverFacetLoader.d.mts +0 -72
  1105. package/dist/src/server/serverFacetLoader.d.mts.map +0 -1
  1106. package/dist/src/server/serverFacetLoader.mjs +0 -212
  1107. package/dist/src/server/serverFacetLoader.mjs.map +0 -1
  1108. package/dist/src/services/acpSessionUpdates/index.cjs +0 -129
  1109. package/dist/src/services/acpSessionUpdates/index.cjs.map +0 -1
  1110. package/dist/src/services/acpSessionUpdates/index.mjs +0 -129
  1111. package/dist/src/services/acpSessionUpdates/index.mjs.map +0 -1
  1112. package/dist/src/services/historyImport/index.cjs +0 -8
  1113. package/dist/src/services/historyImport/index.cjs.map +0 -1
  1114. package/dist/src/services/historyImport/index.d.mts +0 -68
  1115. package/dist/src/services/historyImport/index.d.mts.map +0 -1
  1116. package/dist/src/services/historyImport/index.mjs +0 -8
  1117. package/dist/src/services/historyImport/index.mjs.map +0 -1
  1118. package/dist/src/services/openSessionRegistry/index.d.mts.map +0 -1
  1119. package/dist/src/services/requestReceipts/index.cjs.map +0 -1
  1120. package/dist/src/services/requestReceipts/index.d.mts +0 -11
  1121. package/dist/src/services/requestReceipts/index.d.mts.map +0 -1
  1122. package/dist/src/services/requestReceipts/index.mjs.map +0 -1
  1123. package/dist/src/services/rpcTranscript/index.cjs +0 -633
  1124. package/dist/src/services/rpcTranscript/index.cjs.map +0 -1
  1125. package/dist/src/services/rpcTranscript/index.d.mts +0 -50
  1126. package/dist/src/services/rpcTranscript/index.d.mts.map +0 -1
  1127. package/dist/src/services/rpcTranscript/index.mjs +0 -632
  1128. package/dist/src/services/rpcTranscript/index.mjs.map +0 -1
  1129. package/dist/src/services/serverFacet/index.cjs.map +0 -1
  1130. package/dist/src/services/serverFacet/index.d.mts +0 -31
  1131. package/dist/src/services/serverFacet/index.d.mts.map +0 -1
  1132. package/dist/src/services/serverFacet/index.mjs.map +0 -1
  1133. package/dist/src/services/workspaceRegistry/index.d.mts.map +0 -1
  1134. package/dist/src/systems/child/adapters/nativeChildRuntimes.cjs +0 -28
  1135. package/dist/src/systems/child/adapters/nativeChildRuntimes.cjs.map +0 -1
  1136. package/dist/src/systems/child/adapters/nativeChildRuntimes.mjs +0 -25
  1137. package/dist/src/systems/child/adapters/nativeChildRuntimes.mjs.map +0 -1
  1138. package/dist/terminalPiChildSessionService.cjs +0 -324
  1139. package/dist/terminalPiChildSessionService.cjs.map +0 -1
  1140. package/dist/terminalPiChildSessionService.d.mts +0 -46
  1141. package/dist/terminalPiChildSessionService.d.mts.map +0 -1
  1142. package/dist/terminalPiChildSessionService.mjs +0 -318
  1143. package/dist/terminalPiChildSessionService.mjs.map +0 -1
  1144. package/dist/v3Export.cjs +0 -10
  1145. package/dist/v3Export.cjs.map +0 -1
  1146. package/dist/v3Export.d.mts +0 -35
  1147. package/dist/v3Export.d.mts.map +0 -1
  1148. package/dist/v3Export.mjs +0 -9
  1149. package/dist/v3Export.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["path","fs","crypto"],"sources":["../../../../src/services/workspaceRegistry/index.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nconst REGISTRY_FILE = 'workspaces.json';\nconst GIT_DIRECTORY = '.git';\nconst COMMON_DIRECTORY_FILE = 'commondir';\n\nfunction canonicalPath(target: string): string {\n const absolute = path.resolve(target);\n try {\n return fs.realpathSync.native(absolute);\n } catch {\n const parent = path.dirname(absolute);\n if (parent === absolute) return absolute;\n return path.join(canonicalPath(parent), path.basename(absolute));\n }\n}\n\nfunction readGitDirectory(repositoryRoot: string): string | undefined {\n const gitPath = path.join(repositoryRoot, GIT_DIRECTORY);\n try {\n const stat = fs.statSync(gitPath);\n if (stat.isDirectory()) return canonicalPath(gitPath);\n if (!stat.isFile()) return undefined;\n const match = /^gitdir:\\s*(.+)$/imu.exec(fs.readFileSync(gitPath, 'utf8').trim());\n return match?.[1] ? canonicalPath(path.resolve(repositoryRoot, match[1].trim())) : undefined;\n } catch {\n // Not a git checkout, or one this process cannot read: it has no git data to share.\n return undefined;\n }\n}\n\n/** The git data directory shared by every worktree of a repository, if the root is a git checkout. */\nexport function gitCommonDirectory(repositoryRoot: string): string | undefined {\n const gitDirectory = readGitDirectory(repositoryRoot);\n if (!gitDirectory) return undefined;\n try {\n const relative = fs.readFileSync(path.join(gitDirectory, COMMON_DIRECTORY_FILE), 'utf8').trim();\n return relative ? canonicalPath(path.resolve(gitDirectory, relative)) : gitDirectory;\n } catch {\n // A plain checkout has no commondir file; its own git directory is the common one.\n return gitDirectory;\n }\n}\n/** Kept in the repository's git data, which moves with the checkout and is shared by its worktrees. */\nconst WORKSPACE_MARKER_FILE = 'po-workspace-id';\nconst DIRECTORY_MODE = 0o700;\nconst FILE_MODE = 0o600;\n\nexport interface WorkspaceRecord {\n id: string;\n root: string;\n /** Display name chosen when the workspace was added; the folder basename stands in when absent. */\n name?: string;\n}\n\nexport interface WorkspaceRegistry {\n list(): readonly WorkspaceRecord[];\n add(record: WorkspaceRecord): void;\n remove(id: string): void;\n}\n\nexport interface WorkspaceRegistryOptions {\n directory: string;\n onNotice?: (message: string) => void;\n}\n\nfunction parseRecord(value: unknown): WorkspaceRecord | undefined {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return undefined;\n const record = value as Record<string, unknown>;\n if (typeof record.id !== 'string' || record.id === '') return undefined;\n if (typeof record.root !== 'string' || !path.isAbsolute(record.root)) return undefined;\n const name = typeof record.name === 'string' && record.name.trim() !== '' ? record.name : undefined;\n return { id: record.id, root: record.root, ...(name === undefined ? {} : { name }) };\n}\n\n/** Durable workspace membership, independent of whether a workspace can currently mount. */\nexport function createWorkspaceRegistry(options: WorkspaceRegistryOptions): WorkspaceRegistry {\n const notice = options.onNotice ?? ((): void => {});\n const filePath = path.join(options.directory, REGISTRY_FILE);\n\n const load = (): WorkspaceRecord[] => {\n let raw: string;\n try {\n raw = fs.readFileSync(filePath, 'utf8');\n } catch (error) {\n if (error instanceof Error && 'code' in error && error.code === 'ENOENT') return [];\n notice(`${filePath} could not be read: ${error instanceof Error ? error.message : String(error)}`);\n return [];\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n notice(`workspaces at ${filePath} are not valid JSON; none will be restored`);\n return [];\n }\n if (!Array.isArray(parsed)) {\n notice(`workspaces at ${filePath} are not a list; none will be restored`);\n return [];\n }\n const records: WorkspaceRecord[] = [];\n for (const entry of parsed) {\n const record = parseRecord(entry);\n if (record === undefined) notice(`workspaces at ${filePath} contain an unusable entry; skipping it`);\n else if (!records.some((candidate) => candidate.id === record.id)) records.push(record);\n }\n return records;\n };\n\n let current = load();\n\n const persist = (next: readonly WorkspaceRecord[]): void => {\n const temporary = `${filePath}.${String(process.pid)}.tmp`;\n try {\n fs.mkdirSync(options.directory, { recursive: true, mode: DIRECTORY_MODE });\n fs.writeFileSync(temporary, `${JSON.stringify(next, undefined, 2)}\\n`, { mode: FILE_MODE });\n fs.renameSync(temporary, filePath);\n } catch (error) {\n try {\n fs.rmSync(temporary, { force: true });\n } catch (cleanupError) {\n notice(\n `${temporary} could not be removed: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`,\n );\n }\n throw new Error(`${filePath} could not be saved`, { cause: error });\n }\n };\n\n return {\n list: () => current,\n // Each write starts from the file, not from memory: another process (a sync, a second\n // server) may have changed it since this one last read, and its entries must survive.\n add(record) {\n if (record.id === '' || !path.isAbsolute(record.root)) throw new Error('Invalid workspace record.');\n const latest = load();\n // Replaced in place: registry order is the tie-break when checkouts are matched to workspaces.\n const next = latest.some((held) => held.id === record.id)\n ? latest.map((held) => (held.id === record.id ? record : held))\n : [...latest, record];\n persist(next);\n current = next;\n },\n remove(id) {\n const latest = load();\n const next = latest.filter((held) => held.id !== id);\n if (next.length !== latest.length) persist(next);\n current = next;\n },\n };\n}\n\n/** The workspace id recorded in a checkout's git data, if any. */\nexport function readWorkspaceMarker(checkoutRoot: string): string | undefined {\n const commonDirectory = gitCommonDirectory(checkoutRoot);\n if (commonDirectory === undefined) return undefined;\n try {\n const id = fs.readFileSync(path.join(commonDirectory, WORKSPACE_MARKER_FILE), 'utf8').trim();\n return id === '' ? undefined : id;\n } catch (error) {\n if (error instanceof Error && 'code' in error && error.code === 'ENOENT') return undefined;\n throw error;\n }\n}\n\n/**\n * Records a workspace id in a checkout's git data so the workspace keeps its id when the\n * repository moves. A checkout without git data has nowhere to keep it; returns false.\n */\nexport function writeWorkspaceMarker(checkoutRoot: string, id: string): boolean {\n const commonDirectory = gitCommonDirectory(checkoutRoot);\n if (commonDirectory === undefined) return false;\n fs.writeFileSync(path.join(commonDirectory, WORKSPACE_MARKER_FILE), `${id}\\n`, { mode: FILE_MODE });\n return true;\n}\n\nexport interface WorkspaceIdentity {\n readonly id: string;\n /** The workspace root. Differs from the checkout when the checkout joins an existing workspace. */\n readonly root: string;\n /** The recorded root no longer exists and this checkout takes its place. */\n readonly moved: boolean;\n}\n\n/**\n * Decides which workspace a checkout belongs to. An exact root match wins. Otherwise the id\n * in the repository's git data names the workspace: a checkout of a workspace whose root still\n * exists joins it, and one whose recorded root is gone is that workspace, moved. Anything else\n * is a new workspace.\n */\nexport function identifyWorkspace(input: {\n readonly records: readonly WorkspaceRecord[];\n readonly checkoutRoot: string;\n readonly marker?: string;\n readonly exists?: (root: string) => boolean;\n readonly newId?: () => string;\n}): WorkspaceIdentity {\n const exact = input.records.find((record) => record.root === input.checkoutRoot);\n if (exact !== undefined) return { id: exact.id, root: exact.root, moved: false };\n const owner = input.marker === undefined ? undefined : input.records.find((record) => record.id === input.marker);\n if (owner !== undefined) {\n const exists = input.exists ?? fs.existsSync;\n return exists(owner.root)\n ? { id: owner.id, root: owner.root, moved: false }\n : { id: owner.id, root: input.checkoutRoot, moved: true };\n }\n return { id: input.marker ?? (input.newId ?? crypto.randomUUID)(), root: input.checkoutRoot, moved: false };\n}\n"],"mappings":";;;;;;;;AAIA,MAAM,gBAAgB;AACtB,MAAM,gBAAgB;AACtB,MAAM,wBAAwB;AAE9B,SAAS,cAAc,QAAwB;CAC7C,MAAM,WAAWA,UAAAA,QAAK,QAAQ,MAAM;CACpC,IAAI;EACF,OAAOC,QAAAA,QAAG,aAAa,OAAO,QAAQ;CACxC,QAAQ;EACN,MAAM,SAASD,UAAAA,QAAK,QAAQ,QAAQ;EACpC,IAAI,WAAW,UAAU,OAAO;EAChC,OAAOA,UAAAA,QAAK,KAAK,cAAc,MAAM,GAAGA,UAAAA,QAAK,SAAS,QAAQ,CAAC;CACjE;AACF;AAEA,SAAS,iBAAiB,gBAA4C;CACpE,MAAM,UAAUA,UAAAA,QAAK,KAAK,gBAAgB,aAAa;CACvD,IAAI;EACF,MAAM,OAAOC,QAAAA,QAAG,SAAS,OAAO;EAChC,IAAI,KAAK,YAAY,GAAG,OAAO,cAAc,OAAO;EACp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,KAAK,iBAAiB,qBAAqB,GAAG,GAAG,GAAG,KAAK,EAAE,MAAM,UAAU,CAAC;CAClG,OAAO;AACT;;;;;;;AAgBA,SAAgB,kBAAkB,OAMZ;CACpB,MAAM,QAAQ,MAAM,QAAQ,MAAM,WAAW,OAAO,SAAS,MAAM,YAAY;CAC/E,IAAI,UAAU,KAAA,GAAW,OAAO;EAAE,IAAI,MAAM;EAAI,MAAM,MAAM;EAAM,OAAO;CAAM;CAC/E,MAAM,QAAQ,MAAM,WAAW,KAAA,IAAY,KAAA,IAAY,MAAM,QAAQ,MAAM,WAAW,OAAO,OAAO,MAAM,MAAM;CAChH,IAAI,UAAU,KAAA,GAEZ,QADe,MAAM,UAAUC,QAAAA,QAAG,WAAA,CACpB,MAAM,IAAI,IACpB;EAAE,IAAI,MAAM;EAAI,MAAM,MAAM;EAAM,OAAO;CAAM,IAC/C;EAAE,IAAI,MAAM;EAAI,MAAM,MAAM;EAAc,OAAO;CAAK;CAE5D,OAAO;EAAE,IAAI,MAAM,WAAW,MAAM,SAASC,YAAAA,QAAO,WAAA,CAAY;EAAG,MAAM,MAAM;EAAc,OAAO;CAAM;AAC5G"}
1
+ {"version":3,"file":"index.cjs","names":["createSerialRunner"],"sources":["../../../../src/services/workspaceRegistry/index.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport path from 'node:path';\n\nimport type { Context } from '@earendil-works/chord';\nimport { getOrThrow, type FileSystem } from '@earendil-works/pi-durable/env';\n\nimport { nodeHost } from '../nodeHost';\nimport { readTextIfExists, writeFileAtomic } from '../platformFiles';\nimport { createSerialRunner } from '../serialRunner';\nimport {\n assertWorkspaceRecord,\n COMMON_DIRECTORY_FILE,\n DIRECTORY_MODE,\n FILE_MODE,\n GIT_DIRECTORY,\n gitFileTarget,\n matchWorkspace,\n parseWorkspaceMarker,\n parseWorkspaceRecords,\n REGISTRY_FILE,\n resolveWorkspaceIdentity,\n serializeWorkspaceRecords,\n withWorkspaceRecord,\n WORKSPACE_MARKER_FILE,\n type WorkspaceIdentity,\n type WorkspaceIdentityInput,\n type WorkspaceRecord,\n type WorkspaceRegistryOptions,\n} from './workspaceRecords';\n\nexport type {\n WorkspaceIdentity,\n WorkspaceIdentityInput,\n WorkspaceRecord,\n WorkspaceRegistry,\n WorkspaceRegistryOptions,\n} from './workspaceRecords';\nexport {\n createWorkspaceRegistry,\n gitCommonDirectory,\n identifyWorkspace,\n readWorkspaceMarker,\n writeWorkspaceMarker,\n} from './sync';\n\n/** One queue per registry file, so concurrent read-modify-write cycles in this process never interleave. */\nconst registryWrites = createSerialRunner();\n\nexport interface WorkspaceRegistryAsync {\n list(): readonly WorkspaceRecord[];\n add(record: WorkspaceRecord): Promise<void>;\n remove(id: string): Promise<void>;\n}\n\nfunction errorText(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nasync function canonicalPathAsync(fs: FileSystem, target: string, context: Context): Promise<string> {\n const absolute = path.resolve(target);\n const resolved = await fs.canonicalPath(absolute, context);\n if (resolved.ok) return resolved.value;\n const parent = path.dirname(absolute);\n if (parent === absolute) return absolute;\n return path.join(await canonicalPathAsync(fs, parent, context), path.basename(absolute));\n}\n\nasync function readGitDirectoryAsync(\n fs: FileSystem,\n repositoryRoot: string,\n context: Context,\n): Promise<string | undefined> {\n const gitPath = path.join(repositoryRoot, GIT_DIRECTORY);\n try {\n // fileInfo does not follow links; the canonical path does, as statSync did.\n const info = await fs.fileInfo(await canonicalPathAsync(fs, gitPath, context), context);\n if (!info.ok) return undefined;\n if (info.value.kind === 'directory') return await canonicalPathAsync(fs, gitPath, context);\n if (info.value.kind !== 'file') return undefined;\n const content = await fs.readTextFile(gitPath, context);\n if (!content.ok) return undefined;\n const target = gitFileTarget(repositoryRoot, content.value);\n return target === undefined ? undefined : await canonicalPathAsync(fs, target, context);\n } catch {\n // Not a git checkout, or one this process cannot read: it has no git data to share.\n return undefined;\n }\n}\n\n/** The git data directory shared by every worktree of a repository, if the root is a git checkout. */\nexport async function gitCommonDirectoryAsync(\n fs: FileSystem,\n repositoryRoot: string,\n context: Context,\n): Promise<string | undefined> {\n const gitDirectory = await readGitDirectoryAsync(fs, repositoryRoot, context);\n if (!gitDirectory) return undefined;\n const content = await fs.readTextFile(path.join(gitDirectory, COMMON_DIRECTORY_FILE), context);\n // A plain checkout has no commondir file; its own git directory is the common one.\n if (!content.ok) return gitDirectory;\n const relative = content.value.trim();\n return relative ? canonicalPathAsync(fs, path.resolve(gitDirectory, relative), context) : gitDirectory;\n}\n\n/**\n * Durable workspace membership, independent of whether a workspace can currently mount.\n * Writes in this process serialise per registry file and publish through a uniquely named\n * temporary file, so concurrent adds and removes never lose an entry or tear the file.\n */\nexport async function createWorkspaceRegistryAsync(\n fs: FileSystem,\n options: WorkspaceRegistryOptions,\n context: Context,\n): Promise<WorkspaceRegistryAsync> {\n const notice = options.onNotice ?? ((): void => {});\n const filePath = path.join(options.directory, REGISTRY_FILE);\n const serial = registryWrites.forKey(filePath);\n\n const load = async (): Promise<WorkspaceRecord[]> => {\n let raw: string | undefined;\n try {\n raw = await readTextIfExists(fs, filePath, context);\n } catch (error) {\n notice(`${filePath} could not be read: ${errorText(error)}`);\n return [];\n }\n return raw === undefined ? [] : parseWorkspaceRecords(raw, filePath, notice);\n };\n\n let current = await load();\n\n const persist = async (next: readonly WorkspaceRecord[]): Promise<void> => {\n try {\n const existed = getOrThrow(await fs.exists(options.directory, context));\n if (!existed) {\n getOrThrow(await fs.createDir(options.directory, { recursive: true }, context));\n await nodeHost.setMode(options.directory, DIRECTORY_MODE);\n }\n await writeFileAtomic(fs, filePath, serializeWorkspaceRecords(next), context);\n await nodeHost.setMode(filePath, FILE_MODE);\n } catch (error) {\n throw new Error(`${filePath} could not be saved`, { cause: error });\n }\n };\n\n return {\n list: () => current,\n // Each write starts from the file, not from memory: another process (a sync, a second\n // server) may have changed it since this one last read, and its entries must survive.\n add: (record) =>\n serial(async () => {\n assertWorkspaceRecord(record);\n const next = withWorkspaceRecord(await load(), record);\n await persist(next);\n current = next;\n }),\n remove: (id) =>\n serial(async () => {\n const latest = await load();\n const next = latest.filter((held) => held.id !== id);\n if (next.length !== latest.length) await persist(next);\n current = next;\n }),\n };\n}\n\n/** The workspace id recorded in a checkout's git data, if any. */\nexport async function readWorkspaceMarkerAsync(\n fs: FileSystem,\n checkoutRoot: string,\n context: Context,\n): Promise<string | undefined> {\n const commonDirectory = await gitCommonDirectoryAsync(fs, checkoutRoot, context);\n if (commonDirectory === undefined) return undefined;\n const content = await readTextIfExists(fs, path.join(commonDirectory, WORKSPACE_MARKER_FILE), context);\n return content === undefined ? undefined : parseWorkspaceMarker(content);\n}\n\n/**\n * Records a workspace id in a checkout's git data so the workspace keeps its id when the\n * repository moves. A checkout without git data has nowhere to keep it; returns false.\n */\nexport async function writeWorkspaceMarkerAsync(\n fs: FileSystem,\n checkoutRoot: string,\n id: string,\n context: Context,\n): Promise<boolean> {\n const commonDirectory = await gitCommonDirectoryAsync(fs, checkoutRoot, context);\n if (commonDirectory === undefined) return false;\n const markerPath = path.join(commonDirectory, WORKSPACE_MARKER_FILE);\n getOrThrow(await fs.writeFile(markerPath, `${id}\\n`, context));\n await nodeHost.setMode(markerPath, FILE_MODE);\n return true;\n}\n\n/**\n * Decides which workspace a checkout belongs to. An exact root match wins. Otherwise the id\n * in the repository's git data names the workspace: a checkout of a workspace whose root still\n * exists joins it, and one whose recorded root is gone is that workspace, moved. Anything else\n * is a new workspace.\n */\nexport async function identifyWorkspaceAsync(\n fs: FileSystem,\n input: WorkspaceIdentityInput,\n context: Context,\n): Promise<WorkspaceIdentity> {\n const match = matchWorkspace(input);\n const ownerExists = match?.kind === 'owner' && getOrThrow(await fs.exists(match.record.root, context));\n return resolveWorkspaceIdentity(input, match, ownerExists, crypto.randomUUID);\n}\n"],"mappings":";;;;;;;;;AA8CuBA,gBAAAA,mBAAmB"}
@@ -1,47 +1,5 @@
1
- //#region src/services/workspaceRegistry/index.d.ts
2
- export interface WorkspaceRecord {
3
- id: string;
4
- root: string;
5
- /** Display name chosen when the workspace was added; the folder basename stands in when absent. */
6
- name?: string;
7
- }
8
- export interface WorkspaceRegistry {
9
- list(): readonly WorkspaceRecord[];
10
- add(record: WorkspaceRecord): void;
11
- remove(id: string): void;
12
- }
13
- export interface WorkspaceRegistryOptions {
14
- directory: string;
15
- onNotice?: (message: string) => void;
16
- }
17
- /** Durable workspace membership, independent of whether a workspace can currently mount. */
18
- export declare function createWorkspaceRegistry(options: WorkspaceRegistryOptions): WorkspaceRegistry;
19
- /** The workspace id recorded in a checkout's git data, if any. */
20
- export declare function readWorkspaceMarker(checkoutRoot: string): string | undefined;
21
- /**
22
- * Records a workspace id in a checkout's git data so the workspace keeps its id when the
23
- * repository moves. A checkout without git data has nowhere to keep it; returns false.
24
- */
25
- export declare function writeWorkspaceMarker(checkoutRoot: string, id: string): boolean;
26
- export interface WorkspaceIdentity {
27
- readonly id: string;
28
- /** The workspace root. Differs from the checkout when the checkout joins an existing workspace. */
29
- readonly root: string;
30
- /** The recorded root no longer exists and this checkout takes its place. */
31
- readonly moved: boolean;
32
- }
33
- /**
34
- * Decides which workspace a checkout belongs to. An exact root match wins. Otherwise the id
35
- * in the repository's git data names the workspace: a checkout of a workspace whose root still
36
- * exists joins it, and one whose recorded root is gone is that workspace, moved. Anything else
37
- * is a new workspace.
38
- */
39
- export declare function identifyWorkspace(input: {
40
- readonly records: readonly WorkspaceRecord[];
41
- readonly checkoutRoot: string;
42
- readonly marker?: string;
43
- readonly exists?: (root: string) => boolean;
44
- readonly newId?: () => string;
45
- }): WorkspaceIdentity;
46
- //#endregion
47
- //# sourceMappingURL=index.d.mts.map
1
+ import { WorkspaceIdentity, WorkspaceIdentityInput, WorkspaceRecord, WorkspaceRegistry, WorkspaceRegistryOptions } from "./workspaceRecords.mjs";
2
+ import { createWorkspaceRegistry, identifyWorkspace, readWorkspaceMarker, writeWorkspaceMarker } from "./sync.mjs";
3
+ import { FileSystem } from "@earendil-works/pi-durable/env";
4
+ import { Context } from "@earendil-works/chord";
5
+ export { type WorkspaceIdentity, type WorkspaceRecord, type WorkspaceRegistry, type WorkspaceRegistryOptions, createWorkspaceRegistry, identifyWorkspace, readWorkspaceMarker, writeWorkspaceMarker };
@@ -1,179 +1,10 @@
1
- import crypto from "node:crypto";
2
- import fs from "node:fs";
3
- import path from "node:path";
4
- //#region src/services/workspaceRegistry/index.ts
5
- const REGISTRY_FILE = "workspaces.json";
6
- const GIT_DIRECTORY = ".git";
7
- const COMMON_DIRECTORY_FILE = "commondir";
8
- function canonicalPath(target) {
9
- const absolute = path.resolve(target);
10
- try {
11
- return fs.realpathSync.native(absolute);
12
- } catch {
13
- const parent = path.dirname(absolute);
14
- if (parent === absolute) return absolute;
15
- return path.join(canonicalPath(parent), path.basename(absolute));
16
- }
17
- }
18
- function readGitDirectory(repositoryRoot) {
19
- const gitPath = path.join(repositoryRoot, GIT_DIRECTORY);
20
- try {
21
- const stat = fs.statSync(gitPath);
22
- if (stat.isDirectory()) return canonicalPath(gitPath);
23
- if (!stat.isFile()) return void 0;
24
- const match = /^gitdir:\s*(.+)$/imu.exec(fs.readFileSync(gitPath, "utf8").trim());
25
- return match?.[1] ? canonicalPath(path.resolve(repositoryRoot, match[1].trim())) : void 0;
26
- } catch {
27
- return;
28
- }
29
- }
30
- /** The git data directory shared by every worktree of a repository, if the root is a git checkout. */
31
- function gitCommonDirectory(repositoryRoot) {
32
- const gitDirectory = readGitDirectory(repositoryRoot);
33
- if (!gitDirectory) return void 0;
34
- try {
35
- const relative = fs.readFileSync(path.join(gitDirectory, COMMON_DIRECTORY_FILE), "utf8").trim();
36
- return relative ? canonicalPath(path.resolve(gitDirectory, relative)) : gitDirectory;
37
- } catch {
38
- return gitDirectory;
39
- }
40
- }
41
- /** Kept in the repository's git data, which moves with the checkout and is shared by its worktrees. */
42
- const WORKSPACE_MARKER_FILE = "po-workspace-id";
43
- const DIRECTORY_MODE = 448;
44
- const FILE_MODE = 384;
45
- function parseRecord(value) {
46
- if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
47
- const record = value;
48
- if (typeof record.id !== "string" || record.id === "") return void 0;
49
- if (typeof record.root !== "string" || !path.isAbsolute(record.root)) return void 0;
50
- const name = typeof record.name === "string" && record.name.trim() !== "" ? record.name : void 0;
51
- return {
52
- id: record.id,
53
- root: record.root,
54
- ...name === void 0 ? {} : { name }
55
- };
56
- }
57
- /** Durable workspace membership, independent of whether a workspace can currently mount. */
58
- function createWorkspaceRegistry(options) {
59
- const notice = options.onNotice ?? (() => {});
60
- const filePath = path.join(options.directory, REGISTRY_FILE);
61
- const load = () => {
62
- let raw;
63
- try {
64
- raw = fs.readFileSync(filePath, "utf8");
65
- } catch (error) {
66
- if (error instanceof Error && "code" in error && error.code === "ENOENT") return [];
67
- notice(`${filePath} could not be read: ${error instanceof Error ? error.message : String(error)}`);
68
- return [];
69
- }
70
- let parsed;
71
- try {
72
- parsed = JSON.parse(raw);
73
- } catch {
74
- notice(`workspaces at ${filePath} are not valid JSON; none will be restored`);
75
- return [];
76
- }
77
- if (!Array.isArray(parsed)) {
78
- notice(`workspaces at ${filePath} are not a list; none will be restored`);
79
- return [];
80
- }
81
- const records = [];
82
- for (const entry of parsed) {
83
- const record = parseRecord(entry);
84
- if (record === void 0) notice(`workspaces at ${filePath} contain an unusable entry; skipping it`);
85
- else if (!records.some((candidate) => candidate.id === record.id)) records.push(record);
86
- }
87
- return records;
88
- };
89
- let current = load();
90
- const persist = (next) => {
91
- const temporary = `${filePath}.${String(process.pid)}.tmp`;
92
- try {
93
- fs.mkdirSync(options.directory, {
94
- recursive: true,
95
- mode: DIRECTORY_MODE
96
- });
97
- fs.writeFileSync(temporary, `${JSON.stringify(next, void 0, 2)}\n`, { mode: FILE_MODE });
98
- fs.renameSync(temporary, filePath);
99
- } catch (error) {
100
- try {
101
- fs.rmSync(temporary, { force: true });
102
- } catch (cleanupError) {
103
- notice(`${temporary} could not be removed: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`);
104
- }
105
- throw new Error(`${filePath} could not be saved`, { cause: error });
106
- }
107
- };
108
- return {
109
- list: () => current,
110
- add(record) {
111
- if (record.id === "" || !path.isAbsolute(record.root)) throw new Error("Invalid workspace record.");
112
- const latest = load();
113
- const next = latest.some((held) => held.id === record.id) ? latest.map((held) => held.id === record.id ? record : held) : [...latest, record];
114
- persist(next);
115
- current = next;
116
- },
117
- remove(id) {
118
- const latest = load();
119
- const next = latest.filter((held) => held.id !== id);
120
- if (next.length !== latest.length) persist(next);
121
- current = next;
122
- }
123
- };
124
- }
125
- /** The workspace id recorded in a checkout's git data, if any. */
126
- function readWorkspaceMarker(checkoutRoot) {
127
- const commonDirectory = gitCommonDirectory(checkoutRoot);
128
- if (commonDirectory === void 0) return void 0;
129
- try {
130
- const id = fs.readFileSync(path.join(commonDirectory, WORKSPACE_MARKER_FILE), "utf8").trim();
131
- return id === "" ? void 0 : id;
132
- } catch (error) {
133
- if (error instanceof Error && "code" in error && error.code === "ENOENT") return void 0;
134
- throw error;
135
- }
136
- }
137
- /**
138
- * Records a workspace id in a checkout's git data so the workspace keeps its id when the
139
- * repository moves. A checkout without git data has nowhere to keep it; returns false.
140
- */
141
- function writeWorkspaceMarker(checkoutRoot, id) {
142
- const commonDirectory = gitCommonDirectory(checkoutRoot);
143
- if (commonDirectory === void 0) return false;
144
- fs.writeFileSync(path.join(commonDirectory, WORKSPACE_MARKER_FILE), `${id}\n`, { mode: FILE_MODE });
145
- return true;
146
- }
147
- /**
148
- * Decides which workspace a checkout belongs to. An exact root match wins. Otherwise the id
149
- * in the repository's git data names the workspace: a checkout of a workspace whose root still
150
- * exists joins it, and one whose recorded root is gone is that workspace, moved. Anything else
151
- * is a new workspace.
152
- */
153
- function identifyWorkspace(input) {
154
- const exact = input.records.find((record) => record.root === input.checkoutRoot);
155
- if (exact !== void 0) return {
156
- id: exact.id,
157
- root: exact.root,
158
- moved: false
159
- };
160
- const owner = input.marker === void 0 ? void 0 : input.records.find((record) => record.id === input.marker);
161
- if (owner !== void 0) return (input.exists ?? fs.existsSync)(owner.root) ? {
162
- id: owner.id,
163
- root: owner.root,
164
- moved: false
165
- } : {
166
- id: owner.id,
167
- root: input.checkoutRoot,
168
- moved: true
169
- };
170
- return {
171
- id: input.marker ?? (input.newId ?? crypto.randomUUID)(),
172
- root: input.checkoutRoot,
173
- moved: false
174
- };
175
- }
1
+ import "../platformFiles/index.mjs";
2
+ import { createSerialRunner } from "../serialRunner/index.mjs";
176
3
  //#endregion
177
- export { createWorkspaceRegistry, gitCommonDirectory, identifyWorkspace, readWorkspaceMarker, writeWorkspaceMarker };
4
+ export { createWorkspaceRegistry, identifyWorkspace, readWorkspaceMarker, writeWorkspaceMarker } from "./sync.mjs";
5
+ import "node:crypto";
6
+ import "node:path";
7
+ import "@earendil-works/pi-durable/env";
8
+ createSerialRunner();
178
9
 
179
10
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/services/workspaceRegistry/index.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nconst REGISTRY_FILE = 'workspaces.json';\nconst GIT_DIRECTORY = '.git';\nconst COMMON_DIRECTORY_FILE = 'commondir';\n\nfunction canonicalPath(target: string): string {\n const absolute = path.resolve(target);\n try {\n return fs.realpathSync.native(absolute);\n } catch {\n const parent = path.dirname(absolute);\n if (parent === absolute) return absolute;\n return path.join(canonicalPath(parent), path.basename(absolute));\n }\n}\n\nfunction readGitDirectory(repositoryRoot: string): string | undefined {\n const gitPath = path.join(repositoryRoot, GIT_DIRECTORY);\n try {\n const stat = fs.statSync(gitPath);\n if (stat.isDirectory()) return canonicalPath(gitPath);\n if (!stat.isFile()) return undefined;\n const match = /^gitdir:\\s*(.+)$/imu.exec(fs.readFileSync(gitPath, 'utf8').trim());\n return match?.[1] ? canonicalPath(path.resolve(repositoryRoot, match[1].trim())) : undefined;\n } catch {\n // Not a git checkout, or one this process cannot read: it has no git data to share.\n return undefined;\n }\n}\n\n/** The git data directory shared by every worktree of a repository, if the root is a git checkout. */\nexport function gitCommonDirectory(repositoryRoot: string): string | undefined {\n const gitDirectory = readGitDirectory(repositoryRoot);\n if (!gitDirectory) return undefined;\n try {\n const relative = fs.readFileSync(path.join(gitDirectory, COMMON_DIRECTORY_FILE), 'utf8').trim();\n return relative ? canonicalPath(path.resolve(gitDirectory, relative)) : gitDirectory;\n } catch {\n // A plain checkout has no commondir file; its own git directory is the common one.\n return gitDirectory;\n }\n}\n/** Kept in the repository's git data, which moves with the checkout and is shared by its worktrees. */\nconst WORKSPACE_MARKER_FILE = 'po-workspace-id';\nconst DIRECTORY_MODE = 0o700;\nconst FILE_MODE = 0o600;\n\nexport interface WorkspaceRecord {\n id: string;\n root: string;\n /** Display name chosen when the workspace was added; the folder basename stands in when absent. */\n name?: string;\n}\n\nexport interface WorkspaceRegistry {\n list(): readonly WorkspaceRecord[];\n add(record: WorkspaceRecord): void;\n remove(id: string): void;\n}\n\nexport interface WorkspaceRegistryOptions {\n directory: string;\n onNotice?: (message: string) => void;\n}\n\nfunction parseRecord(value: unknown): WorkspaceRecord | undefined {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return undefined;\n const record = value as Record<string, unknown>;\n if (typeof record.id !== 'string' || record.id === '') return undefined;\n if (typeof record.root !== 'string' || !path.isAbsolute(record.root)) return undefined;\n const name = typeof record.name === 'string' && record.name.trim() !== '' ? record.name : undefined;\n return { id: record.id, root: record.root, ...(name === undefined ? {} : { name }) };\n}\n\n/** Durable workspace membership, independent of whether a workspace can currently mount. */\nexport function createWorkspaceRegistry(options: WorkspaceRegistryOptions): WorkspaceRegistry {\n const notice = options.onNotice ?? ((): void => {});\n const filePath = path.join(options.directory, REGISTRY_FILE);\n\n const load = (): WorkspaceRecord[] => {\n let raw: string;\n try {\n raw = fs.readFileSync(filePath, 'utf8');\n } catch (error) {\n if (error instanceof Error && 'code' in error && error.code === 'ENOENT') return [];\n notice(`${filePath} could not be read: ${error instanceof Error ? error.message : String(error)}`);\n return [];\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n notice(`workspaces at ${filePath} are not valid JSON; none will be restored`);\n return [];\n }\n if (!Array.isArray(parsed)) {\n notice(`workspaces at ${filePath} are not a list; none will be restored`);\n return [];\n }\n const records: WorkspaceRecord[] = [];\n for (const entry of parsed) {\n const record = parseRecord(entry);\n if (record === undefined) notice(`workspaces at ${filePath} contain an unusable entry; skipping it`);\n else if (!records.some((candidate) => candidate.id === record.id)) records.push(record);\n }\n return records;\n };\n\n let current = load();\n\n const persist = (next: readonly WorkspaceRecord[]): void => {\n const temporary = `${filePath}.${String(process.pid)}.tmp`;\n try {\n fs.mkdirSync(options.directory, { recursive: true, mode: DIRECTORY_MODE });\n fs.writeFileSync(temporary, `${JSON.stringify(next, undefined, 2)}\\n`, { mode: FILE_MODE });\n fs.renameSync(temporary, filePath);\n } catch (error) {\n try {\n fs.rmSync(temporary, { force: true });\n } catch (cleanupError) {\n notice(\n `${temporary} could not be removed: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`,\n );\n }\n throw new Error(`${filePath} could not be saved`, { cause: error });\n }\n };\n\n return {\n list: () => current,\n // Each write starts from the file, not from memory: another process (a sync, a second\n // server) may have changed it since this one last read, and its entries must survive.\n add(record) {\n if (record.id === '' || !path.isAbsolute(record.root)) throw new Error('Invalid workspace record.');\n const latest = load();\n // Replaced in place: registry order is the tie-break when checkouts are matched to workspaces.\n const next = latest.some((held) => held.id === record.id)\n ? latest.map((held) => (held.id === record.id ? record : held))\n : [...latest, record];\n persist(next);\n current = next;\n },\n remove(id) {\n const latest = load();\n const next = latest.filter((held) => held.id !== id);\n if (next.length !== latest.length) persist(next);\n current = next;\n },\n };\n}\n\n/** The workspace id recorded in a checkout's git data, if any. */\nexport function readWorkspaceMarker(checkoutRoot: string): string | undefined {\n const commonDirectory = gitCommonDirectory(checkoutRoot);\n if (commonDirectory === undefined) return undefined;\n try {\n const id = fs.readFileSync(path.join(commonDirectory, WORKSPACE_MARKER_FILE), 'utf8').trim();\n return id === '' ? undefined : id;\n } catch (error) {\n if (error instanceof Error && 'code' in error && error.code === 'ENOENT') return undefined;\n throw error;\n }\n}\n\n/**\n * Records a workspace id in a checkout's git data so the workspace keeps its id when the\n * repository moves. A checkout without git data has nowhere to keep it; returns false.\n */\nexport function writeWorkspaceMarker(checkoutRoot: string, id: string): boolean {\n const commonDirectory = gitCommonDirectory(checkoutRoot);\n if (commonDirectory === undefined) return false;\n fs.writeFileSync(path.join(commonDirectory, WORKSPACE_MARKER_FILE), `${id}\\n`, { mode: FILE_MODE });\n return true;\n}\n\nexport interface WorkspaceIdentity {\n readonly id: string;\n /** The workspace root. Differs from the checkout when the checkout joins an existing workspace. */\n readonly root: string;\n /** The recorded root no longer exists and this checkout takes its place. */\n readonly moved: boolean;\n}\n\n/**\n * Decides which workspace a checkout belongs to. An exact root match wins. Otherwise the id\n * in the repository's git data names the workspace: a checkout of a workspace whose root still\n * exists joins it, and one whose recorded root is gone is that workspace, moved. Anything else\n * is a new workspace.\n */\nexport function identifyWorkspace(input: {\n readonly records: readonly WorkspaceRecord[];\n readonly checkoutRoot: string;\n readonly marker?: string;\n readonly exists?: (root: string) => boolean;\n readonly newId?: () => string;\n}): WorkspaceIdentity {\n const exact = input.records.find((record) => record.root === input.checkoutRoot);\n if (exact !== undefined) return { id: exact.id, root: exact.root, moved: false };\n const owner = input.marker === undefined ? undefined : input.records.find((record) => record.id === input.marker);\n if (owner !== undefined) {\n const exists = input.exists ?? fs.existsSync;\n return exists(owner.root)\n ? { id: owner.id, root: owner.root, moved: false }\n : { id: owner.id, root: input.checkoutRoot, moved: true };\n }\n return { id: input.marker ?? (input.newId ?? crypto.randomUUID)(), root: input.checkoutRoot, moved: false };\n}\n"],"mappings":";;;;AAIA,MAAM,gBAAgB;AACtB,MAAM,gBAAgB;AACtB,MAAM,wBAAwB;AAE9B,SAAS,cAAc,QAAwB;CAC7C,MAAM,WAAW,KAAK,QAAQ,M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A,IAAY;CACjC,SAAS,OAAO;EACd,IAAI,iBAAiB,SAAS,UAAU,SAAS,MAAM,SAAS,UAAU,OAAO,KAAA;EACjF,MAAM;CACR;AACF;;;;;AAMA,SAAgB,qBAAqB,cAAsB,IAAqB;CAC9E,MAAM,kBAAkB,mBAAmB,YAAY;CACvD,IAAI,oBAAoB,KAAA,GAAW,OAAO;CAC1C,GAAG,cAAc,KAAK,KAAK,iBAAiB,qBAAqB,GAAG,GAAG,GAAG,KAAK,EAAE,MAAM,UAAU,CAAC;CAClG,OAAO;AACT;;;;;;;AAgBA,SAAgB,kBAAkB,OAMZ;CACpB,MAAM,QAAQ,MAAM,QAAQ,MAAM,WAAW,OAAO,SAAS,MAAM,YAAY;CAC/E,IAAI,UAAU,KAAA,GAAW,OAAO;EAAE,IAAI,MAAM;EAAI,MAAM,MAAM;EAAM,OAAO;CAAM;CAC/E,MAAM,QAAQ,MAAM,WAAW,KAAA,IAAY,KAAA,IAAY,MAAM,QAAQ,MAAM,WAAW,OAAO,OAAO,MAAM,MAAM;CAChH,IAAI,UAAU,KAAA,GAEZ,QADe,MAAM,UAAU,GAAG,WAAA,CACpB,MAAM,IAAI,IACpB;EAAE,IAAI,MAAM;EAAI,MAAM,MAAM;EAAM,OAAO;CAAM,IAC/C;EAAE,IAAI,MAAM;EAAI,MAAM,MAAM;EAAc,OAAO;CAAK;CAE5D,OAAO;EAAE,IAAI,MAAM,WAAW,MAAM,SAAS,OAAO,WAAA,CAAY;EAAG,MAAM,MAAM;EAAc,OAAO;CAAM;AAC5G"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/services/workspaceRegistry/index.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport path from 'node:path';\n\nimport type { Context } from '@earendil-works/chord';\nimport { getOrThrow, type FileSystem } from '@earendil-works/pi-durable/env';\n\nimport { nodeHost } from '../nodeHost';\nimport { readTextIfExists, writeFileAtomic } from '../platformFiles';\nimport { createSerialRunner } from '../serialRunner';\nimport {\n assertWorkspaceRecord,\n COMMON_DIRECTORY_FILE,\n DIRECTORY_MODE,\n FILE_MODE,\n GIT_DIRECTORY,\n gitFileTarget,\n matchWorkspace,\n parseWorkspaceMarker,\n parseWorkspaceRecords,\n REGISTRY_FILE,\n resolveWorkspaceIdentity,\n serializeWorkspaceRecords,\n withWorkspaceRecord,\n WORKSPACE_MARKER_FILE,\n type WorkspaceIdentity,\n type WorkspaceIdentityInput,\n type WorkspaceRecord,\n type WorkspaceRegistryOptions,\n} from './workspaceRecords';\n\nexport type {\n WorkspaceIdentity,\n WorkspaceIdentityInput,\n WorkspaceRecord,\n WorkspaceRegistry,\n WorkspaceRegistryOptions,\n} from './workspaceRecords';\nexport {\n createWorkspaceRegistry,\n gitCommonDirectory,\n identifyWorkspace,\n readWorkspaceMarker,\n writeWorkspaceMarker,\n} from './sync';\n\n/** One queue per registry file, so concurrent read-modify-write cycles in this process never interleave. */\nconst registryWrites = createSerialRunner();\n\nexport interface WorkspaceRegistryAsync {\n list(): readonly WorkspaceRecord[];\n add(record: WorkspaceRecord): Promise<void>;\n remove(id: string): Promise<void>;\n}\n\nfunction errorText(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nasync function canonicalPathAsync(fs: FileSystem, target: string, context: Context): Promise<string> {\n const absolute = path.resolve(target);\n const resolved = await fs.canonicalPath(absolute, context);\n if (resolved.ok) return resolved.value;\n const parent = path.dirname(absolute);\n if (parent === absolute) return absolute;\n return path.join(await canonicalPathAsync(fs, parent, context), path.basename(absolute));\n}\n\nasync function readGitDirectoryAsync(\n fs: FileSystem,\n repositoryRoot: string,\n context: Context,\n): Promise<string | undefined> {\n const gitPath = path.join(repositoryRoot, GIT_DIRECTORY);\n try {\n // fileInfo does not follow links; the canonical path does, as statSync did.\n const info = await fs.fileInfo(await canonicalPathAsync(fs, gitPath, context), context);\n if (!info.ok) return undefined;\n if (info.value.kind === 'directory') return await canonicalPathAsync(fs, gitPath, context);\n if (info.value.kind !== 'file') return undefined;\n const content = await fs.readTextFile(gitPath, context);\n if (!content.ok) return undefined;\n const target = gitFileTarget(repositoryRoot, content.value);\n return target === undefined ? undefined : await canonicalPathAsync(fs, target, context);\n } catch {\n // Not a git checkout, or one this process cannot read: it has no git data to share.\n return undefined;\n }\n}\n\n/** The git data directory shared by every worktree of a repository, if the root is a git checkout. */\nexport async function gitCommonDirectoryAsync(\n fs: FileSystem,\n repositoryRoot: string,\n context: Context,\n): Promise<string | undefined> {\n const gitDirectory = await readGitDirectoryAsync(fs, repositoryRoot, context);\n if (!gitDirectory) return undefined;\n const content = await fs.readTextFile(path.join(gitDirectory, COMMON_DIRECTORY_FILE), context);\n // A plain checkout has no commondir file; its own git directory is the common one.\n if (!content.ok) return gitDirectory;\n const relative = content.value.trim();\n return relative ? canonicalPathAsync(fs, path.resolve(gitDirectory, relative), context) : gitDirectory;\n}\n\n/**\n * Durable workspace membership, independent of whether a workspace can currently mount.\n * Writes in this process serialise per registry file and publish through a uniquely named\n * temporary file, so concurrent adds and removes never lose an entry or tear the file.\n */\nexport async function createWorkspaceRegistryAsync(\n fs: FileSystem,\n options: WorkspaceRegistryOptions,\n context: Context,\n): Promise<WorkspaceRegistryAsync> {\n const notice = options.onNotice ?? ((): void => {});\n const filePath = path.join(options.directory, REGISTRY_FILE);\n const serial = registryWrites.forKey(filePath);\n\n const load = async (): Promise<WorkspaceRecord[]> => {\n let raw: string | undefined;\n try {\n raw = await readTextIfExists(fs, filePath, context);\n } catch (error) {\n notice(`${filePath} could not be read: ${errorText(error)}`);\n return [];\n }\n return raw === undefined ? [] : parseWorkspaceRecords(raw, filePath, notice);\n };\n\n let current = await load();\n\n const persist = async (next: readonly WorkspaceRecord[]): Promise<void> => {\n try {\n const existed = getOrThrow(await fs.exists(options.directory, context));\n if (!existed) {\n getOrThrow(await fs.createDir(options.directory, { recursive: true }, context));\n await nodeHost.setMode(options.directory, DIRECTORY_MODE);\n }\n await writeFileAtomic(fs, filePath, serializeWorkspaceRecords(next), context);\n await nodeHost.setMode(filePath, FILE_MODE);\n } catch (error) {\n throw new Error(`${filePath} could not be saved`, { cause: error });\n }\n };\n\n return {\n list: () => current,\n // Each write starts from the file, not from memory: another process (a sync, a second\n // server) may have changed it since this one last read, and its entries must survive.\n add: (record) =>\n serial(async () => {\n assertWorkspaceRecord(record);\n const next = withWorkspaceRecord(await load(), record);\n await persist(next);\n current = next;\n }),\n remove: (id) =>\n serial(async () => {\n const latest = await load();\n const next = latest.filter((held) => held.id !== id);\n if (next.length !== latest.length) await persist(next);\n current = next;\n }),\n };\n}\n\n/** The workspace id recorded in a checkout's git data, if any. */\nexport async function readWorkspaceMarkerAsync(\n fs: FileSystem,\n checkoutRoot: string,\n context: Context,\n): Promise<string | undefined> {\n const commonDirectory = await gitCommonDirectoryAsync(fs, checkoutRoot, context);\n if (commonDirectory === undefined) return undefined;\n const content = await readTextIfExists(fs, path.join(commonDirectory, WORKSPACE_MARKER_FILE), context);\n return content === undefined ? undefined : parseWorkspaceMarker(content);\n}\n\n/**\n * Records a workspace id in a checkout's git data so the workspace keeps its id when the\n * repository moves. A checkout without git data has nowhere to keep it; returns false.\n */\nexport async function writeWorkspaceMarkerAsync(\n fs: FileSystem,\n checkoutRoot: string,\n id: string,\n context: Context,\n): Promise<boolean> {\n const commonDirectory = await gitCommonDirectoryAsync(fs, checkoutRoot, context);\n if (commonDirectory === undefined) return false;\n const markerPath = path.join(commonDirectory, WORKSPACE_MARKER_FILE);\n getOrThrow(await fs.writeFile(markerPath, `${id}\\n`, context));\n await nodeHost.setMode(markerPath, FILE_MODE);\n return true;\n}\n\n/**\n * Decides which workspace a checkout belongs to. An exact root match wins. Otherwise the id\n * in the repository's git data names the workspace: a checkout of a workspace whose root still\n * exists joins it, and one whose recorded root is gone is that workspace, moved. Anything else\n * is a new workspace.\n */\nexport async function identifyWorkspaceAsync(\n fs: FileSystem,\n input: WorkspaceIdentityInput,\n context: Context,\n): Promise<WorkspaceIdentity> {\n const match = matchWorkspace(input);\n const ownerExists = match?.kind === 'owner' && getOrThrow(await fs.exists(match.record.root, context));\n return resolveWorkspaceIdentity(input, match, ownerExists, crypto.randomUUID);\n}\n"],"mappings":";;;;;;;AA8CuB,mBAAmB"}
@@ -0,0 +1,148 @@
1
+ const require_runtime = require("../../../_virtual/_rolldown/runtime.cjs");
2
+ const require_workspaceRecords = require("./workspaceRecords.cjs");
3
+ let node_crypto = require("node:crypto");
4
+ node_crypto = require_runtime.__toESM(node_crypto, 1);
5
+ let node_fs = require("node:fs");
6
+ node_fs = require_runtime.__toESM(node_fs, 1);
7
+ let node_path = require("node:path");
8
+ node_path = require_runtime.__toESM(node_path, 1);
9
+ //#region src/services/workspaceRegistry/sync.ts
10
+ function canonicalPath(target) {
11
+ const absolute = node_path.default.resolve(target);
12
+ try {
13
+ return node_fs.default.realpathSync.native(absolute);
14
+ } catch {
15
+ const parent = node_path.default.dirname(absolute);
16
+ if (parent === absolute) return absolute;
17
+ return node_path.default.join(canonicalPath(parent), node_path.default.basename(absolute));
18
+ }
19
+ }
20
+ function readGitDirectory(repositoryRoot) {
21
+ const gitPath = node_path.default.join(repositoryRoot, require_workspaceRecords.GIT_DIRECTORY);
22
+ try {
23
+ const stat = node_fs.default.statSync(gitPath);
24
+ if (stat.isDirectory()) return canonicalPath(gitPath);
25
+ if (!stat.isFile()) return void 0;
26
+ const target = require_workspaceRecords.gitFileTarget(repositoryRoot, node_fs.default.readFileSync(gitPath, "utf8"));
27
+ return target === void 0 ? void 0 : canonicalPath(target);
28
+ } catch {
29
+ return;
30
+ }
31
+ }
32
+ /**
33
+ * The git data directory shared by every worktree of a repository, if the root is a git checkout.
34
+ *
35
+ * @deprecated Node-only sync shim; use gitCommonDirectoryAsync. Removed in M2.
36
+ */
37
+ function gitCommonDirectory(repositoryRoot) {
38
+ const gitDirectory = readGitDirectory(repositoryRoot);
39
+ if (!gitDirectory) return void 0;
40
+ try {
41
+ const relative = node_fs.default.readFileSync(node_path.default.join(gitDirectory, require_workspaceRecords.COMMON_DIRECTORY_FILE), "utf8").trim();
42
+ return relative ? canonicalPath(node_path.default.resolve(gitDirectory, relative)) : gitDirectory;
43
+ } catch {
44
+ return gitDirectory;
45
+ }
46
+ }
47
+ /**
48
+ * Durable workspace membership, independent of whether a workspace can currently mount.
49
+ *
50
+ * @deprecated Node-only sync shim; use createWorkspaceRegistryAsync. Removed in M2.
51
+ */
52
+ function createWorkspaceRegistry(options) {
53
+ const notice = options.onNotice ?? (() => {});
54
+ const filePath = node_path.default.join(options.directory, require_workspaceRecords.REGISTRY_FILE);
55
+ const load = () => {
56
+ let raw;
57
+ try {
58
+ raw = node_fs.default.readFileSync(filePath, "utf8");
59
+ } catch (error) {
60
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") return [];
61
+ notice(`${filePath} could not be read: ${error instanceof Error ? error.message : String(error)}`);
62
+ return [];
63
+ }
64
+ return require_workspaceRecords.parseWorkspaceRecords(raw, filePath, notice);
65
+ };
66
+ let current = load();
67
+ const persist = (next) => {
68
+ const temporary = `${filePath}.${String(process.pid)}.tmp`;
69
+ try {
70
+ node_fs.default.mkdirSync(options.directory, {
71
+ recursive: true,
72
+ mode: 448
73
+ });
74
+ node_fs.default.writeFileSync(temporary, require_workspaceRecords.serializeWorkspaceRecords(next), { mode: 384 });
75
+ node_fs.default.renameSync(temporary, filePath);
76
+ } catch (error) {
77
+ try {
78
+ node_fs.default.rmSync(temporary, { force: true });
79
+ } catch (cleanupError) {
80
+ notice(`${temporary} could not be removed: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`);
81
+ }
82
+ throw new Error(`${filePath} could not be saved`, { cause: error });
83
+ }
84
+ };
85
+ return {
86
+ list: () => current,
87
+ add(record) {
88
+ require_workspaceRecords.assertWorkspaceRecord(record);
89
+ const next = require_workspaceRecords.withWorkspaceRecord(load(), record);
90
+ persist(next);
91
+ current = next;
92
+ },
93
+ remove(id) {
94
+ const latest = load();
95
+ const next = latest.filter((held) => held.id !== id);
96
+ if (next.length !== latest.length) persist(next);
97
+ current = next;
98
+ }
99
+ };
100
+ }
101
+ /**
102
+ * The workspace id recorded in a checkout's git data, if any.
103
+ *
104
+ * @deprecated Node-only sync shim; use readWorkspaceMarkerAsync. Removed in M2.
105
+ */
106
+ function readWorkspaceMarker(checkoutRoot) {
107
+ const commonDirectory = gitCommonDirectory(checkoutRoot);
108
+ if (commonDirectory === void 0) return void 0;
109
+ try {
110
+ return require_workspaceRecords.parseWorkspaceMarker(node_fs.default.readFileSync(node_path.default.join(commonDirectory, require_workspaceRecords.WORKSPACE_MARKER_FILE), "utf8"));
111
+ } catch (error) {
112
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") return void 0;
113
+ throw error;
114
+ }
115
+ }
116
+ /**
117
+ * Records a workspace id in a checkout's git data so the workspace keeps its id when the
118
+ * repository moves. A checkout without git data has nowhere to keep it; returns false.
119
+ *
120
+ * @deprecated Node-only sync shim; use writeWorkspaceMarkerAsync. Removed in M2.
121
+ */
122
+ function writeWorkspaceMarker(checkoutRoot, id) {
123
+ const commonDirectory = gitCommonDirectory(checkoutRoot);
124
+ if (commonDirectory === void 0) return false;
125
+ node_fs.default.writeFileSync(node_path.default.join(commonDirectory, require_workspaceRecords.WORKSPACE_MARKER_FILE), `${id}\n`, { mode: 384 });
126
+ return true;
127
+ }
128
+ /**
129
+ * Decides which workspace a checkout belongs to. An exact root match wins. Otherwise the id
130
+ * in the repository's git data names the workspace: a checkout of a workspace whose root still
131
+ * exists joins it, and one whose recorded root is gone is that workspace, moved. Anything else
132
+ * is a new workspace.
133
+ *
134
+ * @deprecated Node-only sync shim; use identifyWorkspaceAsync. Removed in M2.
135
+ */
136
+ function identifyWorkspace(input) {
137
+ const match = require_workspaceRecords.matchWorkspace(input);
138
+ const exists = input.exists ?? node_fs.default.existsSync;
139
+ return require_workspaceRecords.resolveWorkspaceIdentity(input, match, match?.kind === "owner" && exists(match.record.root), node_crypto.default.randomUUID);
140
+ }
141
+ //#endregion
142
+ exports.createWorkspaceRegistry = createWorkspaceRegistry;
143
+ exports.gitCommonDirectory = gitCommonDirectory;
144
+ exports.identifyWorkspace = identifyWorkspace;
145
+ exports.readWorkspaceMarker = readWorkspaceMarker;
146
+ exports.writeWorkspaceMarker = writeWorkspaceMarker;
147
+
148
+ //# sourceMappingURL=sync.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.cjs","names":["path","fs","GIT_DIRECTORY","gitFileTarget","COMMON_DIRECTORY_FILE","REGISTRY_FILE","parseWorkspaceRecords","serializeWorkspaceRecords","withWorkspaceRecord","parseWorkspaceMarker","WORKSPACE_MARKER_FILE","matchWorkspace","resolveWorkspaceIdentity","crypto"],"sources":["../../../../src/services/workspaceRegistry/sync.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport {\n assertWorkspaceRecord,\n COMMON_DIRECTORY_FILE,\n DIRECTORY_MODE,\n FILE_MODE,\n GIT_DIRECTORY,\n gitFileTarget,\n matchWorkspace,\n parseWorkspaceMarker,\n parseWorkspaceRecords,\n REGISTRY_FILE,\n resolveWorkspaceIdentity,\n serializeWorkspaceRecords,\n withWorkspaceRecord,\n WORKSPACE_MARKER_FILE,\n type WorkspaceIdentity,\n type WorkspaceIdentityInput,\n type WorkspaceRecord,\n type WorkspaceRegistry,\n type WorkspaceRegistryOptions,\n} from './workspaceRecords';\n\nfunction canonicalPath(target: string): string {\n const absolute = path.resolve(target);\n try {\n return fs.realpathSync.native(absolute);\n } catch {\n const parent = path.dirname(absolute);\n if (parent === absolute) return absolute;\n return path.join(canonicalPath(parent), path.basename(absolute));\n }\n}\n\nfunction readGitDirectory(repositoryRoot: string): string | undefined {\n const gitPath = path.join(repositoryRoot, GIT_DIRECTORY);\n try {\n const stat = fs.statSync(gitPath);\n if (stat.isDirectory()) return canonicalPath(gitPath);\n if (!stat.isFile()) return undefined;\n const target = gitFileTarget(repositoryRoot, fs.readFileSync(gitPath, 'utf8'));\n return target === undefined ? undefined : canonicalPath(target);\n } catch {\n // Not a git checkout, or one this process cannot read: it has no git data to share.\n return undefined;\n }\n}\n\n/**\n * The git data directory shared by every worktree of a repository, if the root is a git checkout.\n *\n * @deprecated Node-only sync shim; use gitCommonDirectoryAsync. Removed in M2.\n */\nexport function gitCommonDirectory(repositoryRoot: string): string | undefined {\n const gitDirectory = readGitDirectory(repositoryRoot);\n if (!gitDirectory) return undefined;\n try {\n const relative = fs.readFileSync(path.join(gitDirectory, COMMON_DIRECTORY_FILE), 'utf8').trim();\n return relative ? canonicalPath(path.resolve(gitDirectory, relative)) : gitDirectory;\n } catch {\n // A plain checkout has no commondir file; its own git directory is the common one.\n return gitDirectory;\n }\n}\n\n/**\n * Durable workspace membership, independent of whether a workspace can currently mount.\n *\n * @deprecated Node-only sync shim; use createWorkspaceRegistryAsync. Removed in M2.\n */\nexport function createWorkspaceRegistry(options: WorkspaceRegistryOptions): WorkspaceRegistry {\n const notice = options.onNotice ?? ((): void => {});\n const filePath = path.join(options.directory, REGISTRY_FILE);\n\n const load = (): WorkspaceRecord[] => {\n let raw: string;\n try {\n raw = fs.readFileSync(filePath, 'utf8');\n } catch (error) {\n if (error instanceof Error && 'code' in error && error.code === 'ENOENT') return [];\n notice(`${filePath} could not be read: ${error instanceof Error ? error.message : String(error)}`);\n return [];\n }\n return parseWorkspaceRecords(raw, filePath, notice);\n };\n\n let current = load();\n\n const persist = (next: readonly WorkspaceRecord[]): void => {\n const temporary = `${filePath}.${String(process.pid)}.tmp`;\n try {\n fs.mkdirSync(options.directory, { recursive: true, mode: DIRECTORY_MODE });\n fs.writeFileSync(temporary, serializeWorkspaceRecords(next), { mode: FILE_MODE });\n fs.renameSync(temporary, filePath);\n } catch (error) {\n try {\n fs.rmSync(temporary, { force: true });\n } catch (cleanupError) {\n notice(\n `${temporary} could not be removed: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`,\n );\n }\n throw new Error(`${filePath} could not be saved`, { cause: error });\n }\n };\n\n return {\n list: () => current,\n // Each write starts from the file, not from memory: another process (a sync, a second\n // server) may have changed it since this one last read, and its entries must survive.\n add(record) {\n assertWorkspaceRecord(record);\n const next = withWorkspaceRecord(load(), record);\n persist(next);\n current = next;\n },\n remove(id) {\n const latest = load();\n const next = latest.filter((held) => held.id !== id);\n if (next.length !== latest.length) persist(next);\n current = next;\n },\n };\n}\n\n/**\n * The workspace id recorded in a checkout's git data, if any.\n *\n * @deprecated Node-only sync shim; use readWorkspaceMarkerAsync. Removed in M2.\n */\nexport function readWorkspaceMarker(checkoutRoot: string): string | undefined {\n const commonDirectory = gitCommonDirectory(checkoutRoot);\n if (commonDirectory === undefined) return undefined;\n try {\n return parseWorkspaceMarker(fs.readFileSync(path.join(commonDirectory, WORKSPACE_MARKER_FILE), 'utf8'));\n } catch (error) {\n if (error instanceof Error && 'code' in error && error.code === 'ENOENT') return undefined;\n throw error;\n }\n}\n\n/**\n * Records a workspace id in a checkout's git data so the workspace keeps its id when the\n * repository moves. A checkout without git data has nowhere to keep it; returns false.\n *\n * @deprecated Node-only sync shim; use writeWorkspaceMarkerAsync. Removed in M2.\n */\nexport function writeWorkspaceMarker(checkoutRoot: string, id: string): boolean {\n const commonDirectory = gitCommonDirectory(checkoutRoot);\n if (commonDirectory === undefined) return false;\n fs.writeFileSync(path.join(commonDirectory, WORKSPACE_MARKER_FILE), `${id}\\n`, { mode: FILE_MODE });\n return true;\n}\n\n/**\n * Decides which workspace a checkout belongs to. An exact root match wins. Otherwise the id\n * in the repository's git data names the workspace: a checkout of a workspace whose root still\n * exists joins it, and one whose recorded root is gone is that workspace, moved. Anything else\n * is a new workspace.\n *\n * @deprecated Node-only sync shim; use identifyWorkspaceAsync. Removed in M2.\n */\nexport function identifyWorkspace(\n input: WorkspaceIdentityInput & { readonly exists?: (root: string) => boolean },\n): WorkspaceIdentity {\n const match = matchWorkspace(input);\n const exists = input.exists ?? fs.existsSync;\n return resolveWorkspaceIdentity(\n input,\n match,\n match?.kind === 'owner' && exists(match.record.root),\n crypto.randomUUID,\n );\n}\n"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;AACF;;;;;;AAOA,SAAgB,oBAAoB,cAA0C;CAC5E,MAAM,kBAAkB,mBAAmB,YAAY;CACvD,IAAI,oBAAoB,KAAA,GAAW,OAAO,KAAA;CAC1C,IAAI;EACF,OAAOC,yBAAAA,qBAAqBR,QAAAA,QAAG,aAAaD,UAAAA,QAAK,KAAK,iBAAiBU,yBAAAA,qBAAqB,GAAG,MAAM,CAAC;CACxG,SAAS,OAAO;EACd,IAAI,iBAAiB,SAAS,UAAU,SAAS,MAAM,SAAS,UAAU,OAAO,KAAA;EACjF,MAAM;CACR;AACF;;;;;;;AAQA,SAAgB,qBAAqB,cAAsB,IAAqB;CAC9E,MAAM,kBAAkB,mBAAmB,YAAY;CACvD,IAAI,oBAAoB,KAAA,GAAW,OAAO;CAC1C,QAAA,QAAG,cAAcV,UAAAA,QAAK,KAAK,iBAAiBU,yBAAAA,qBAAqB,GAAG,GAAG,GAAG,KAAK,EAAE,MAAA,IAAgB,CAAC;CAClG,OAAO;AACT;;;;;;;;;AAUA,SAAgB,kBACd,OACmB;CACnB,MAAM,QAAQC,yBAAAA,eAAe,KAAK;CAClC,MAAM,SAAS,MAAM,UAAUV,QAAAA,QAAG;CAClC,OAAOW,yBAAAA,yBACL,OACA,OACA,OAAO,SAAS,WAAW,OAAO,MAAM,OAAO,IAAI,GACnDC,YAAAA,QAAO,UACT;AACF"}
@@ -0,0 +1,34 @@
1
+ import { WorkspaceIdentity, WorkspaceIdentityInput, WorkspaceRegistry, WorkspaceRegistryOptions } from "./workspaceRecords.mjs";
2
+ //#region src/services/workspaceRegistry/sync.d.ts
3
+ /**
4
+ * Durable workspace membership, independent of whether a workspace can currently mount.
5
+ *
6
+ * @deprecated Node-only sync shim; use createWorkspaceRegistryAsync. Removed in M2.
7
+ */
8
+ export declare function createWorkspaceRegistry(options: WorkspaceRegistryOptions): WorkspaceRegistry;
9
+ /**
10
+ * The workspace id recorded in a checkout's git data, if any.
11
+ *
12
+ * @deprecated Node-only sync shim; use readWorkspaceMarkerAsync. Removed in M2.
13
+ */
14
+ export declare function readWorkspaceMarker(checkoutRoot: string): string | undefined;
15
+ /**
16
+ * Records a workspace id in a checkout's git data so the workspace keeps its id when the
17
+ * repository moves. A checkout without git data has nowhere to keep it; returns false.
18
+ *
19
+ * @deprecated Node-only sync shim; use writeWorkspaceMarkerAsync. Removed in M2.
20
+ */
21
+ export declare function writeWorkspaceMarker(checkoutRoot: string, id: string): boolean;
22
+ /**
23
+ * Decides which workspace a checkout belongs to. An exact root match wins. Otherwise the id
24
+ * in the repository's git data names the workspace: a checkout of a workspace whose root still
25
+ * exists joins it, and one whose recorded root is gone is that workspace, moved. Anything else
26
+ * is a new workspace.
27
+ *
28
+ * @deprecated Node-only sync shim; use identifyWorkspaceAsync. Removed in M2.
29
+ */
30
+ export declare function identifyWorkspace(input: WorkspaceIdentityInput & {
31
+ readonly exists?: (root: string) => boolean;
32
+ }): WorkspaceIdentity;
33
+ //#endregion
34
+ //# sourceMappingURL=sync.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.d.mts","names":[],"sources":["../../../../src/services/workspaceRegistry/sync.ts"],"mappings":";;;;;;;wBAyEgB,wBAAwB,SAAS,2BAA2B;;;;;;wBA4D5D,oBAAoB;;;;;;;wBAiBpB,qBAAqB,sBAAsB;;;;;;;;;wBAe3C,kBACd,OAAO;WAAoC,UAAU;IACpD"}