@timurproko/a1 0.1.0

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 (455) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +68 -0
  3. package/bin/addone-supervisor.js +7 -0
  4. package/bin/addone-ui.js +20 -0
  5. package/bin/addone.js +26 -0
  6. package/dist/src/cli/dispatch.d.ts +26 -0
  7. package/dist/src/cli/dispatch.d.ts.map +1 -0
  8. package/dist/src/cli/dispatch.js +35 -0
  9. package/dist/src/cli/dispatch.js.map +1 -0
  10. package/dist/src/cli/index.d.ts +4 -0
  11. package/dist/src/cli/index.d.ts.map +1 -0
  12. package/dist/src/cli/index.js +4 -0
  13. package/dist/src/cli/index.js.map +1 -0
  14. package/dist/src/cli/version-stats.d.ts +17 -0
  15. package/dist/src/cli/version-stats.d.ts.map +1 -0
  16. package/dist/src/cli/version-stats.js +68 -0
  17. package/dist/src/cli/version-stats.js.map +1 -0
  18. package/dist/src/cli/version.d.ts +3 -0
  19. package/dist/src/cli/version.d.ts.map +1 -0
  20. package/dist/src/cli/version.js +23 -0
  21. package/dist/src/cli/version.js.map +1 -0
  22. package/dist/src/features/launch/development-launch.d.ts +9 -0
  23. package/dist/src/features/launch/development-launch.d.ts.map +1 -0
  24. package/dist/src/features/launch/development-launch.js +27 -0
  25. package/dist/src/features/launch/development-launch.js.map +1 -0
  26. package/dist/src/features/launch/index.d.ts +8 -0
  27. package/dist/src/features/launch/index.d.ts.map +1 -0
  28. package/dist/src/features/launch/index.js +8 -0
  29. package/dist/src/features/launch/index.js.map +1 -0
  30. package/dist/src/features/launch/initialize-profile.d.ts +7 -0
  31. package/dist/src/features/launch/initialize-profile.d.ts.map +1 -0
  32. package/dist/src/features/launch/initialize-profile.js +59 -0
  33. package/dist/src/features/launch/initialize-profile.js.map +1 -0
  34. package/dist/src/features/launch/intent.d.ts +8 -0
  35. package/dist/src/features/launch/intent.d.ts.map +1 -0
  36. package/dist/src/features/launch/intent.js +5 -0
  37. package/dist/src/features/launch/intent.js.map +1 -0
  38. package/dist/src/features/launch/prepare-launch.d.ts +14 -0
  39. package/dist/src/features/launch/prepare-launch.d.ts.map +1 -0
  40. package/dist/src/features/launch/prepare-launch.js +22 -0
  41. package/dist/src/features/launch/prepare-launch.js.map +1 -0
  42. package/dist/src/features/launch/profile-paths.d.ts +16 -0
  43. package/dist/src/features/launch/profile-paths.d.ts.map +1 -0
  44. package/dist/src/features/launch/profile-paths.js +30 -0
  45. package/dist/src/features/launch/profile-paths.js.map +1 -0
  46. package/dist/src/features/launch/profiles.d.ts +13 -0
  47. package/dist/src/features/launch/profiles.d.ts.map +1 -0
  48. package/dist/src/features/launch/profiles.js +27 -0
  49. package/dist/src/features/launch/profiles.js.map +1 -0
  50. package/dist/src/features/launch/runtime-selection.d.ts +15 -0
  51. package/dist/src/features/launch/runtime-selection.d.ts.map +1 -0
  52. package/dist/src/features/launch/runtime-selection.js +14 -0
  53. package/dist/src/features/launch/runtime-selection.js.map +1 -0
  54. package/dist/src/features/owned-ui/customization.d.ts +36 -0
  55. package/dist/src/features/owned-ui/customization.d.ts.map +1 -0
  56. package/dist/src/features/owned-ui/customization.js +110 -0
  57. package/dist/src/features/owned-ui/customization.js.map +1 -0
  58. package/dist/src/features/owned-ui/diagnostics.d.ts +34 -0
  59. package/dist/src/features/owned-ui/diagnostics.d.ts.map +1 -0
  60. package/dist/src/features/owned-ui/diagnostics.js +95 -0
  61. package/dist/src/features/owned-ui/diagnostics.js.map +1 -0
  62. package/dist/src/features/owned-ui/index.d.ts +5 -0
  63. package/dist/src/features/owned-ui/index.d.ts.map +1 -0
  64. package/dist/src/features/owned-ui/index.js +5 -0
  65. package/dist/src/features/owned-ui/index.js.map +1 -0
  66. package/dist/src/features/owned-ui/pi-session-shell.d.ts +97 -0
  67. package/dist/src/features/owned-ui/pi-session-shell.d.ts.map +1 -0
  68. package/dist/src/features/owned-ui/pi-session-shell.js +1437 -0
  69. package/dist/src/features/owned-ui/pi-session-shell.js.map +1 -0
  70. package/dist/src/features/owned-ui/run.d.ts +9 -0
  71. package/dist/src/features/owned-ui/run.d.ts.map +1 -0
  72. package/dist/src/features/owned-ui/run.js +21 -0
  73. package/dist/src/features/owned-ui/run.js.map +1 -0
  74. package/dist/src/features/workspace/capabilities.d.ts +32 -0
  75. package/dist/src/features/workspace/capabilities.d.ts.map +1 -0
  76. package/dist/src/features/workspace/capabilities.js +76 -0
  77. package/dist/src/features/workspace/capabilities.js.map +1 -0
  78. package/dist/src/features/workspace/index.d.ts +7 -0
  79. package/dist/src/features/workspace/index.d.ts.map +1 -0
  80. package/dist/src/features/workspace/index.js +7 -0
  81. package/dist/src/features/workspace/index.js.map +1 -0
  82. package/dist/src/features/workspace/presentation.d.ts +31 -0
  83. package/dist/src/features/workspace/presentation.d.ts.map +1 -0
  84. package/dist/src/features/workspace/presentation.js +69 -0
  85. package/dist/src/features/workspace/presentation.js.map +1 -0
  86. package/dist/src/features/workspace/reconciliation.d.ts +16 -0
  87. package/dist/src/features/workspace/reconciliation.d.ts.map +1 -0
  88. package/dist/src/features/workspace/reconciliation.js +83 -0
  89. package/dist/src/features/workspace/reconciliation.js.map +1 -0
  90. package/dist/src/features/workspace/reducer.d.ts +43 -0
  91. package/dist/src/features/workspace/reducer.d.ts.map +1 -0
  92. package/dist/src/features/workspace/reducer.js +214 -0
  93. package/dist/src/features/workspace/reducer.js.map +1 -0
  94. package/dist/src/features/workspace/router.d.ts +32 -0
  95. package/dist/src/features/workspace/router.d.ts.map +1 -0
  96. package/dist/src/features/workspace/router.js +125 -0
  97. package/dist/src/features/workspace/router.js.map +1 -0
  98. package/dist/src/features/workspace/store.d.ts +18 -0
  99. package/dist/src/features/workspace/store.d.ts.map +1 -0
  100. package/dist/src/features/workspace/store.js +55 -0
  101. package/dist/src/features/workspace/store.js.map +1 -0
  102. package/dist/src/foundation/lifecycle/index.d.ts +3 -0
  103. package/dist/src/foundation/lifecycle/index.d.ts.map +1 -0
  104. package/dist/src/foundation/lifecycle/index.js +3 -0
  105. package/dist/src/foundation/lifecycle/index.js.map +1 -0
  106. package/dist/src/foundation/lifecycle/model.d.ts +101 -0
  107. package/dist/src/foundation/lifecycle/model.d.ts.map +1 -0
  108. package/dist/src/foundation/lifecycle/model.js +40 -0
  109. package/dist/src/foundation/lifecycle/model.js.map +1 -0
  110. package/dist/src/foundation/lifecycle/paths.d.ts +11 -0
  111. package/dist/src/foundation/lifecycle/paths.d.ts.map +1 -0
  112. package/dist/src/foundation/lifecycle/paths.js +26 -0
  113. package/dist/src/foundation/lifecycle/paths.js.map +1 -0
  114. package/dist/src/foundation/native-host-protocol/codec.d.ts +12 -0
  115. package/dist/src/foundation/native-host-protocol/codec.d.ts.map +1 -0
  116. package/dist/src/foundation/native-host-protocol/codec.js +57 -0
  117. package/dist/src/foundation/native-host-protocol/codec.js.map +1 -0
  118. package/dist/src/foundation/native-host-protocol/evidence.d.ts +68 -0
  119. package/dist/src/foundation/native-host-protocol/evidence.d.ts.map +1 -0
  120. package/dist/src/foundation/native-host-protocol/evidence.js +141 -0
  121. package/dist/src/foundation/native-host-protocol/evidence.js.map +1 -0
  122. package/dist/src/foundation/native-host-protocol/index.d.ts +5 -0
  123. package/dist/src/foundation/native-host-protocol/index.d.ts.map +1 -0
  124. package/dist/src/foundation/native-host-protocol/index.js +5 -0
  125. package/dist/src/foundation/native-host-protocol/index.js.map +1 -0
  126. package/dist/src/foundation/native-host-protocol/messages.d.ts +57 -0
  127. package/dist/src/foundation/native-host-protocol/messages.d.ts.map +1 -0
  128. package/dist/src/foundation/native-host-protocol/messages.js +149 -0
  129. package/dist/src/foundation/native-host-protocol/messages.js.map +1 -0
  130. package/dist/src/foundation/native-host-protocol/proof-gate.d.ts +14 -0
  131. package/dist/src/foundation/native-host-protocol/proof-gate.d.ts.map +1 -0
  132. package/dist/src/foundation/native-host-protocol/proof-gate.js +34 -0
  133. package/dist/src/foundation/native-host-protocol/proof-gate.js.map +1 -0
  134. package/dist/src/foundation/owned-ui-contracts/extension-ui.d.ts +303 -0
  135. package/dist/src/foundation/owned-ui-contracts/extension-ui.d.ts.map +1 -0
  136. package/dist/src/foundation/owned-ui-contracts/extension-ui.js +69 -0
  137. package/dist/src/foundation/owned-ui-contracts/extension-ui.js.map +1 -0
  138. package/dist/src/foundation/owned-ui-contracts/index.d.ts +4 -0
  139. package/dist/src/foundation/owned-ui-contracts/index.d.ts.map +1 -0
  140. package/dist/src/foundation/owned-ui-contracts/index.js +4 -0
  141. package/dist/src/foundation/owned-ui-contracts/index.js.map +1 -0
  142. package/dist/src/foundation/owned-ui-contracts/model.d.ts +242 -0
  143. package/dist/src/foundation/owned-ui-contracts/model.d.ts.map +1 -0
  144. package/dist/src/foundation/owned-ui-contracts/model.js +2 -0
  145. package/dist/src/foundation/owned-ui-contracts/model.js.map +1 -0
  146. package/dist/src/foundation/owned-ui-contracts/validation.d.ts +12 -0
  147. package/dist/src/foundation/owned-ui-contracts/validation.d.ts.map +1 -0
  148. package/dist/src/foundation/owned-ui-contracts/validation.js +396 -0
  149. package/dist/src/foundation/owned-ui-contracts/validation.js.map +1 -0
  150. package/dist/src/foundation/pi-component-adapter/components.d.ts +5 -0
  151. package/dist/src/foundation/pi-component-adapter/components.d.ts.map +1 -0
  152. package/dist/src/foundation/pi-component-adapter/components.js +65 -0
  153. package/dist/src/foundation/pi-component-adapter/components.js.map +1 -0
  154. package/dist/src/foundation/pi-component-adapter/conformance.d.ts +17 -0
  155. package/dist/src/foundation/pi-component-adapter/conformance.d.ts.map +1 -0
  156. package/dist/src/foundation/pi-component-adapter/conformance.js +63 -0
  157. package/dist/src/foundation/pi-component-adapter/conformance.js.map +1 -0
  158. package/dist/src/foundation/pi-component-adapter/index.d.ts +13 -0
  159. package/dist/src/foundation/pi-component-adapter/index.d.ts.map +1 -0
  160. package/dist/src/foundation/pi-component-adapter/index.js +13 -0
  161. package/dist/src/foundation/pi-component-adapter/index.js.map +1 -0
  162. package/dist/src/foundation/pi-component-adapter/shell-components.d.ts +7 -0
  163. package/dist/src/foundation/pi-component-adapter/shell-components.d.ts.map +1 -0
  164. package/dist/src/foundation/pi-component-adapter/shell-components.js +7 -0
  165. package/dist/src/foundation/pi-component-adapter/shell-components.js.map +1 -0
  166. package/dist/src/foundation/pi-component-adapter/shell-editor-autocomplete.d.ts +12 -0
  167. package/dist/src/foundation/pi-component-adapter/shell-editor-autocomplete.d.ts.map +1 -0
  168. package/dist/src/foundation/pi-component-adapter/shell-editor-autocomplete.js +165 -0
  169. package/dist/src/foundation/pi-component-adapter/shell-editor-autocomplete.js.map +1 -0
  170. package/dist/src/foundation/pi-component-adapter/shell-extension-ui.d.ts +36 -0
  171. package/dist/src/foundation/pi-component-adapter/shell-extension-ui.d.ts.map +1 -0
  172. package/dist/src/foundation/pi-component-adapter/shell-extension-ui.js +280 -0
  173. package/dist/src/foundation/pi-component-adapter/shell-extension-ui.js.map +1 -0
  174. package/dist/src/foundation/pi-component-adapter/shell-footer-status.d.ts +8 -0
  175. package/dist/src/foundation/pi-component-adapter/shell-footer-status.d.ts.map +1 -0
  176. package/dist/src/foundation/pi-component-adapter/shell-footer-status.js +246 -0
  177. package/dist/src/foundation/pi-component-adapter/shell-footer-status.js.map +1 -0
  178. package/dist/src/foundation/pi-component-adapter/shell-presenters-transcript.d.ts +43 -0
  179. package/dist/src/foundation/pi-component-adapter/shell-presenters-transcript.d.ts.map +1 -0
  180. package/dist/src/foundation/pi-component-adapter/shell-presenters-transcript.js +397 -0
  181. package/dist/src/foundation/pi-component-adapter/shell-presenters-transcript.js.map +1 -0
  182. package/dist/src/foundation/pi-component-adapter/shell-selectors-dialogs.d.ts +106 -0
  183. package/dist/src/foundation/pi-component-adapter/shell-selectors-dialogs.d.ts.map +1 -0
  184. package/dist/src/foundation/pi-component-adapter/shell-selectors-dialogs.js +234 -0
  185. package/dist/src/foundation/pi-component-adapter/shell-selectors-dialogs.js.map +1 -0
  186. package/dist/src/foundation/pi-component-adapter/shell-shared-facade.d.ts +117 -0
  187. package/dist/src/foundation/pi-component-adapter/shell-shared-facade.d.ts.map +1 -0
  188. package/dist/src/foundation/pi-component-adapter/shell-shared-facade.js +88 -0
  189. package/dist/src/foundation/pi-component-adapter/shell-shared-facade.js.map +1 -0
  190. package/dist/src/foundation/pi-component-adapter/theme.d.ts +2 -0
  191. package/dist/src/foundation/pi-component-adapter/theme.d.ts.map +1 -0
  192. package/dist/src/foundation/pi-component-adapter/theme.js +2 -0
  193. package/dist/src/foundation/pi-component-adapter/theme.js.map +1 -0
  194. package/dist/src/foundation/pi-component-adapter/upstream/adjacent/core/keybindings.d.ts +423 -0
  195. package/dist/src/foundation/pi-component-adapter/upstream/adjacent/core/keybindings.d.ts.map +1 -0
  196. package/dist/src/foundation/pi-component-adapter/upstream/adjacent/core/keybindings.js +297 -0
  197. package/dist/src/foundation/pi-component-adapter/upstream/adjacent/core/keybindings.js.map +1 -0
  198. package/dist/src/foundation/pi-component-adapter/upstream/components/countdown-timer.d.ts +11 -0
  199. package/dist/src/foundation/pi-component-adapter/upstream/components/countdown-timer.d.ts.map +1 -0
  200. package/dist/src/foundation/pi-component-adapter/upstream/components/countdown-timer.js +30 -0
  201. package/dist/src/foundation/pi-component-adapter/upstream/components/countdown-timer.js.map +1 -0
  202. package/dist/src/foundation/pi-component-adapter/upstream/components/custom-entry.d.ts +18 -0
  203. package/dist/src/foundation/pi-component-adapter/upstream/components/custom-entry.d.ts.map +1 -0
  204. package/dist/src/foundation/pi-component-adapter/upstream/components/custom-entry.js +52 -0
  205. package/dist/src/foundation/pi-component-adapter/upstream/components/custom-entry.js.map +1 -0
  206. package/dist/src/foundation/pi-component-adapter/upstream/components/daxnuts.d.ts +23 -0
  207. package/dist/src/foundation/pi-component-adapter/upstream/components/daxnuts.d.ts.map +1 -0
  208. package/dist/src/foundation/pi-component-adapter/upstream/components/daxnuts.js +143 -0
  209. package/dist/src/foundation/pi-component-adapter/upstream/components/daxnuts.js.map +1 -0
  210. package/dist/src/foundation/pi-component-adapter/upstream/components/earendil-announcement.d.ts +5 -0
  211. package/dist/src/foundation/pi-component-adapter/upstream/components/earendil-announcement.d.ts.map +1 -0
  212. package/dist/src/foundation/pi-component-adapter/upstream/components/earendil-announcement.js +43 -0
  213. package/dist/src/foundation/pi-component-adapter/upstream/components/earendil-announcement.js.map +1 -0
  214. package/dist/src/foundation/pi-component-adapter/upstream/components/extension-editor.d.ts +18 -0
  215. package/dist/src/foundation/pi-component-adapter/upstream/components/extension-editor.d.ts.map +1 -0
  216. package/dist/src/foundation/pi-component-adapter/upstream/components/extension-editor.js +82 -0
  217. package/dist/src/foundation/pi-component-adapter/upstream/components/extension-editor.js.map +1 -0
  218. package/dist/src/foundation/pi-component-adapter/upstream/components/first-time-setup.d.ts +25 -0
  219. package/dist/src/foundation/pi-component-adapter/upstream/components/first-time-setup.d.ts.map +1 -0
  220. package/dist/src/foundation/pi-component-adapter/upstream/components/first-time-setup.js +106 -0
  221. package/dist/src/foundation/pi-component-adapter/upstream/components/first-time-setup.js.map +1 -0
  222. package/dist/src/foundation/pi-component-adapter/upstream/components/markdown-transform.d.ts +3 -0
  223. package/dist/src/foundation/pi-component-adapter/upstream/components/markdown-transform.d.ts.map +1 -0
  224. package/dist/src/foundation/pi-component-adapter/upstream/components/markdown-transform.js +19 -0
  225. package/dist/src/foundation/pi-component-adapter/upstream/components/markdown-transform.js.map +1 -0
  226. package/dist/src/foundation/pi-component-adapter/upstream/components/mermaid.d.ts +10 -0
  227. package/dist/src/foundation/pi-component-adapter/upstream/components/mermaid.d.ts.map +1 -0
  228. package/dist/src/foundation/pi-component-adapter/upstream/components/mermaid.js +78 -0
  229. package/dist/src/foundation/pi-component-adapter/upstream/components/mermaid.js.map +1 -0
  230. package/dist/src/foundation/pi-component-adapter/upstream/components/scoped-models-selector.d.ts +56 -0
  231. package/dist/src/foundation/pi-component-adapter/upstream/components/scoped-models-selector.d.ts.map +1 -0
  232. package/dist/src/foundation/pi-component-adapter/upstream/components/scoped-models-selector.js +343 -0
  233. package/dist/src/foundation/pi-component-adapter/upstream/components/scoped-models-selector.js.map +1 -0
  234. package/dist/src/foundation/pi-component-adapter/upstream/components/session-selector-search.d.ts +23 -0
  235. package/dist/src/foundation/pi-component-adapter/upstream/components/session-selector-search.d.ts.map +1 -0
  236. package/dist/src/foundation/pi-component-adapter/upstream/components/session-selector-search.js +160 -0
  237. package/dist/src/foundation/pi-component-adapter/upstream/components/session-selector-search.js.map +1 -0
  238. package/dist/src/foundation/pi-component-adapter/upstream/components/session-selector.d.ts +96 -0
  239. package/dist/src/foundation/pi-component-adapter/upstream/components/session-selector.d.ts.map +1 -0
  240. package/dist/src/foundation/pi-component-adapter/upstream/components/session-selector.js +890 -0
  241. package/dist/src/foundation/pi-component-adapter/upstream/components/session-selector.js.map +1 -0
  242. package/dist/src/foundation/pi-component-adapter/upstream/components/skill-invocation-message.d.ts +20 -0
  243. package/dist/src/foundation/pi-component-adapter/upstream/components/skill-invocation-message.d.ts.map +1 -0
  244. package/dist/src/foundation/pi-component-adapter/upstream/components/skill-invocation-message.js +45 -0
  245. package/dist/src/foundation/pi-component-adapter/upstream/components/skill-invocation-message.js.map +1 -0
  246. package/dist/src/foundation/pi-component-adapter/upstream/components/status-indicator.d.ts +31 -0
  247. package/dist/src/foundation/pi-component-adapter/upstream/components/status-indicator.d.ts.map +1 -0
  248. package/dist/src/foundation/pi-component-adapter/upstream/components/status-indicator.js +60 -0
  249. package/dist/src/foundation/pi-component-adapter/upstream/components/status-indicator.js.map +1 -0
  250. package/dist/src/foundation/pi-component-adapter/upstream/components/tree-selector.d.ts +99 -0
  251. package/dist/src/foundation/pi-component-adapter/upstream/components/tree-selector.d.ts.map +1 -0
  252. package/dist/src/foundation/pi-component-adapter/upstream/components/tree-selector.js +1273 -0
  253. package/dist/src/foundation/pi-component-adapter/upstream/components/tree-selector.js.map +1 -0
  254. package/dist/src/foundation/pi-component-adapter/upstream/components/trust-selector.d.ts +34 -0
  255. package/dist/src/foundation/pi-component-adapter/upstream/components/trust-selector.d.ts.map +1 -0
  256. package/dist/src/foundation/pi-component-adapter/upstream/components/trust-selector.js +77 -0
  257. package/dist/src/foundation/pi-component-adapter/upstream/components/trust-selector.js.map +1 -0
  258. package/dist/src/foundation/pi-component-adapter/upstream/external-editor.d.ts +10 -0
  259. package/dist/src/foundation/pi-component-adapter/upstream/external-editor.d.ts.map +1 -0
  260. package/dist/src/foundation/pi-component-adapter/upstream/external-editor.js +40 -0
  261. package/dist/src/foundation/pi-component-adapter/upstream/external-editor.js.map +1 -0
  262. package/dist/src/foundation/pi-component-adapter/upstream/model-search.d.ts +16 -0
  263. package/dist/src/foundation/pi-component-adapter/upstream/model-search.d.ts.map +1 -0
  264. package/dist/src/foundation/pi-component-adapter/upstream/model-search.js +15 -0
  265. package/dist/src/foundation/pi-component-adapter/upstream/model-search.js.map +1 -0
  266. package/dist/src/foundation/pi-component-adapter/upstream/theme/theme-controller.d.ts +26 -0
  267. package/dist/src/foundation/pi-component-adapter/upstream/theme/theme-controller.d.ts.map +1 -0
  268. package/dist/src/foundation/pi-component-adapter/upstream/theme/theme-controller.js +118 -0
  269. package/dist/src/foundation/pi-component-adapter/upstream/theme/theme-controller.js.map +1 -0
  270. package/dist/src/foundation/pi-component-adapter/upstream/theme/theme.d.ts +54 -0
  271. package/dist/src/foundation/pi-component-adapter/upstream/theme/theme.d.ts.map +1 -0
  272. package/dist/src/foundation/pi-component-adapter/upstream/theme/theme.js +311 -0
  273. package/dist/src/foundation/pi-component-adapter/upstream/theme/theme.js.map +1 -0
  274. package/dist/src/foundation/pi-engine-adapter/adapter.d.ts +343 -0
  275. package/dist/src/foundation/pi-engine-adapter/adapter.d.ts.map +1 -0
  276. package/dist/src/foundation/pi-engine-adapter/adapter.js +2365 -0
  277. package/dist/src/foundation/pi-engine-adapter/adapter.js.map +1 -0
  278. package/dist/src/foundation/pi-engine-adapter/conformance.d.ts +14 -0
  279. package/dist/src/foundation/pi-engine-adapter/conformance.d.ts.map +1 -0
  280. package/dist/src/foundation/pi-engine-adapter/conformance.js +85 -0
  281. package/dist/src/foundation/pi-engine-adapter/conformance.js.map +1 -0
  282. package/dist/src/foundation/pi-engine-adapter/index.d.ts +4 -0
  283. package/dist/src/foundation/pi-engine-adapter/index.d.ts.map +1 -0
  284. package/dist/src/foundation/pi-engine-adapter/index.js +4 -0
  285. package/dist/src/foundation/pi-engine-adapter/index.js.map +1 -0
  286. package/dist/src/foundation/pi-engine-adapter/workflows.d.ts +165 -0
  287. package/dist/src/foundation/pi-engine-adapter/workflows.d.ts.map +1 -0
  288. package/dist/src/foundation/pi-engine-adapter/workflows.js +61 -0
  289. package/dist/src/foundation/pi-engine-adapter/workflows.js.map +1 -0
  290. package/dist/src/foundation/pi-tui-runtime-adapter/adapter.d.ts +34 -0
  291. package/dist/src/foundation/pi-tui-runtime-adapter/adapter.d.ts.map +1 -0
  292. package/dist/src/foundation/pi-tui-runtime-adapter/adapter.js +485 -0
  293. package/dist/src/foundation/pi-tui-runtime-adapter/adapter.js.map +1 -0
  294. package/dist/src/foundation/pi-tui-runtime-adapter/conformance.d.ts +14 -0
  295. package/dist/src/foundation/pi-tui-runtime-adapter/conformance.d.ts.map +1 -0
  296. package/dist/src/foundation/pi-tui-runtime-adapter/conformance.js +132 -0
  297. package/dist/src/foundation/pi-tui-runtime-adapter/conformance.js.map +1 -0
  298. package/dist/src/foundation/pi-tui-runtime-adapter/contracts.d.ts +122 -0
  299. package/dist/src/foundation/pi-tui-runtime-adapter/contracts.d.ts.map +1 -0
  300. package/dist/src/foundation/pi-tui-runtime-adapter/contracts.js +2 -0
  301. package/dist/src/foundation/pi-tui-runtime-adapter/contracts.js.map +1 -0
  302. package/dist/src/foundation/pi-tui-runtime-adapter/index.d.ts +4 -0
  303. package/dist/src/foundation/pi-tui-runtime-adapter/index.d.ts.map +1 -0
  304. package/dist/src/foundation/pi-tui-runtime-adapter/index.js +4 -0
  305. package/dist/src/foundation/pi-tui-runtime-adapter/index.js.map +1 -0
  306. package/dist/src/foundation/protocol/client.d.ts +17 -0
  307. package/dist/src/foundation/protocol/client.d.ts.map +1 -0
  308. package/dist/src/foundation/protocol/client.js +127 -0
  309. package/dist/src/foundation/protocol/client.js.map +1 -0
  310. package/dist/src/foundation/protocol/index.d.ts +3 -0
  311. package/dist/src/foundation/protocol/index.d.ts.map +1 -0
  312. package/dist/src/foundation/protocol/index.js +3 -0
  313. package/dist/src/foundation/protocol/index.js.map +1 -0
  314. package/dist/src/foundation/protocol/messages.d.ts +90 -0
  315. package/dist/src/foundation/protocol/messages.d.ts.map +1 -0
  316. package/dist/src/foundation/protocol/messages.js +99 -0
  317. package/dist/src/foundation/protocol/messages.js.map +1 -0
  318. package/dist/src/foundation/release/bootstrap.d.ts +30 -0
  319. package/dist/src/foundation/release/bootstrap.d.ts.map +1 -0
  320. package/dist/src/foundation/release/bootstrap.js +283 -0
  321. package/dist/src/foundation/release/bootstrap.js.map +1 -0
  322. package/dist/src/foundation/release/cohort-selection.d.ts +40 -0
  323. package/dist/src/foundation/release/cohort-selection.d.ts.map +1 -0
  324. package/dist/src/foundation/release/cohort-selection.js +76 -0
  325. package/dist/src/foundation/release/cohort-selection.js.map +1 -0
  326. package/dist/src/foundation/release/cohort-state.d.ts +68 -0
  327. package/dist/src/foundation/release/cohort-state.d.ts.map +1 -0
  328. package/dist/src/foundation/release/cohort-state.js +201 -0
  329. package/dist/src/foundation/release/cohort-state.js.map +1 -0
  330. package/dist/src/foundation/release/development-preview-release.d.ts +49 -0
  331. package/dist/src/foundation/release/development-preview-release.d.ts.map +1 -0
  332. package/dist/src/foundation/release/development-preview-release.js +113 -0
  333. package/dist/src/foundation/release/development-preview-release.js.map +1 -0
  334. package/dist/src/foundation/release/index.d.ts +12 -0
  335. package/dist/src/foundation/release/index.d.ts.map +1 -0
  336. package/dist/src/foundation/release/index.js +12 -0
  337. package/dist/src/foundation/release/index.js.map +1 -0
  338. package/dist/src/foundation/release/process-cleanup.d.ts +15 -0
  339. package/dist/src/foundation/release/process-cleanup.d.ts.map +1 -0
  340. package/dist/src/foundation/release/process-cleanup.js +67 -0
  341. package/dist/src/foundation/release/process-cleanup.js.map +1 -0
  342. package/dist/src/foundation/release/release-gc.d.ts +6 -0
  343. package/dist/src/foundation/release/release-gc.d.ts.map +1 -0
  344. package/dist/src/foundation/release/release-gc.js +17 -0
  345. package/dist/src/foundation/release/release-gc.js.map +1 -0
  346. package/dist/src/foundation/release/release-store.d.ts +11 -0
  347. package/dist/src/foundation/release/release-store.d.ts.map +1 -0
  348. package/dist/src/foundation/release/release-store.js +115 -0
  349. package/dist/src/foundation/release/release-store.js.map +1 -0
  350. package/dist/src/foundation/release/release.d.ts +24 -0
  351. package/dist/src/foundation/release/release.d.ts.map +1 -0
  352. package/dist/src/foundation/release/release.js +151 -0
  353. package/dist/src/foundation/release/release.js.map +1 -0
  354. package/dist/src/foundation/release/stable-release.d.ts +30 -0
  355. package/dist/src/foundation/release/stable-release.d.ts.map +1 -0
  356. package/dist/src/foundation/release/stable-release.js +38 -0
  357. package/dist/src/foundation/release/stable-release.js.map +1 -0
  358. package/dist/src/foundation/release/update-transaction.d.ts +31 -0
  359. package/dist/src/foundation/release/update-transaction.d.ts.map +1 -0
  360. package/dist/src/foundation/release/update-transaction.js +88 -0
  361. package/dist/src/foundation/release/update-transaction.js.map +1 -0
  362. package/dist/src/foundation/release/update.d.ts +55 -0
  363. package/dist/src/foundation/release/update.d.ts.map +1 -0
  364. package/dist/src/foundation/release/update.js +316 -0
  365. package/dist/src/foundation/release/update.js.map +1 -0
  366. package/dist/src/foundation/storage/control-store.d.ts +61 -0
  367. package/dist/src/foundation/storage/control-store.d.ts.map +1 -0
  368. package/dist/src/foundation/storage/control-store.js +459 -0
  369. package/dist/src/foundation/storage/control-store.js.map +1 -0
  370. package/dist/src/foundation/storage/index.d.ts +2 -0
  371. package/dist/src/foundation/storage/index.d.ts.map +1 -0
  372. package/dist/src/foundation/storage/index.js +2 -0
  373. package/dist/src/foundation/storage/index.js.map +1 -0
  374. package/dist/src/foundation/structured-agent-runtime/backpressure.d.ts +47 -0
  375. package/dist/src/foundation/structured-agent-runtime/backpressure.d.ts.map +1 -0
  376. package/dist/src/foundation/structured-agent-runtime/backpressure.js +119 -0
  377. package/dist/src/foundation/structured-agent-runtime/backpressure.js.map +1 -0
  378. package/dist/src/foundation/structured-agent-runtime/commands.d.ts +53 -0
  379. package/dist/src/foundation/structured-agent-runtime/commands.d.ts.map +1 -0
  380. package/dist/src/foundation/structured-agent-runtime/commands.js +165 -0
  381. package/dist/src/foundation/structured-agent-runtime/commands.js.map +1 -0
  382. package/dist/src/foundation/structured-agent-runtime/handshake.d.ts +42 -0
  383. package/dist/src/foundation/structured-agent-runtime/handshake.d.ts.map +1 -0
  384. package/dist/src/foundation/structured-agent-runtime/handshake.js +151 -0
  385. package/dist/src/foundation/structured-agent-runtime/handshake.js.map +1 -0
  386. package/dist/src/foundation/structured-agent-runtime/index.d.ts +6 -0
  387. package/dist/src/foundation/structured-agent-runtime/index.d.ts.map +1 -0
  388. package/dist/src/foundation/structured-agent-runtime/index.js +6 -0
  389. package/dist/src/foundation/structured-agent-runtime/index.js.map +1 -0
  390. package/dist/src/foundation/structured-agent-runtime/reconnection.d.ts +38 -0
  391. package/dist/src/foundation/structured-agent-runtime/reconnection.d.ts.map +1 -0
  392. package/dist/src/foundation/structured-agent-runtime/reconnection.js +130 -0
  393. package/dist/src/foundation/structured-agent-runtime/reconnection.js.map +1 -0
  394. package/dist/src/foundation/structured-agent-runtime/state.d.ts +57 -0
  395. package/dist/src/foundation/structured-agent-runtime/state.d.ts.map +1 -0
  396. package/dist/src/foundation/structured-agent-runtime/state.js +119 -0
  397. package/dist/src/foundation/structured-agent-runtime/state.js.map +1 -0
  398. package/dist/src/foundation/supervision/index.d.ts +4 -0
  399. package/dist/src/foundation/supervision/index.d.ts.map +1 -0
  400. package/dist/src/foundation/supervision/index.js +4 -0
  401. package/dist/src/foundation/supervision/index.js.map +1 -0
  402. package/dist/src/foundation/supervision/main.d.ts +2 -0
  403. package/dist/src/foundation/supervision/main.d.ts.map +1 -0
  404. package/dist/src/foundation/supervision/main.js +40 -0
  405. package/dist/src/foundation/supervision/main.js.map +1 -0
  406. package/dist/src/foundation/supervision/paths.d.ts +2 -0
  407. package/dist/src/foundation/supervision/paths.d.ts.map +1 -0
  408. package/dist/src/foundation/supervision/paths.js +2 -0
  409. package/dist/src/foundation/supervision/paths.js.map +1 -0
  410. package/dist/src/foundation/supervision/server.d.ts +21 -0
  411. package/dist/src/foundation/supervision/server.d.ts.map +1 -0
  412. package/dist/src/foundation/supervision/server.js +283 -0
  413. package/dist/src/foundation/supervision/server.js.map +1 -0
  414. package/dist/src/foundation/transparent-terminal/command-resolution.d.ts +14 -0
  415. package/dist/src/foundation/transparent-terminal/command-resolution.d.ts.map +1 -0
  416. package/dist/src/foundation/transparent-terminal/command-resolution.js +70 -0
  417. package/dist/src/foundation/transparent-terminal/command-resolution.js.map +1 -0
  418. package/dist/src/foundation/transparent-terminal/foreground-broker.d.ts +33 -0
  419. package/dist/src/foundation/transparent-terminal/foreground-broker.d.ts.map +1 -0
  420. package/dist/src/foundation/transparent-terminal/foreground-broker.js +88 -0
  421. package/dist/src/foundation/transparent-terminal/foreground-broker.js.map +1 -0
  422. package/dist/src/foundation/transparent-terminal/index.d.ts +4 -0
  423. package/dist/src/foundation/transparent-terminal/index.d.ts.map +1 -0
  424. package/dist/src/foundation/transparent-terminal/index.js +4 -0
  425. package/dist/src/foundation/transparent-terminal/index.js.map +1 -0
  426. package/dist/src/foundation/transparent-terminal/main.d.ts +10 -0
  427. package/dist/src/foundation/transparent-terminal/main.d.ts.map +1 -0
  428. package/dist/src/foundation/transparent-terminal/main.js +107 -0
  429. package/dist/src/foundation/transparent-terminal/main.js.map +1 -0
  430. package/dist/src/foundation/transparent-terminal/native-launcher.d.ts +26 -0
  431. package/dist/src/foundation/transparent-terminal/native-launcher.d.ts.map +1 -0
  432. package/dist/src/foundation/transparent-terminal/native-launcher.js +147 -0
  433. package/dist/src/foundation/transparent-terminal/native-launcher.js.map +1 -0
  434. package/dist/src/foundation/workspace-contracts/index.d.ts +3 -0
  435. package/dist/src/foundation/workspace-contracts/index.d.ts.map +1 -0
  436. package/dist/src/foundation/workspace-contracts/index.js +3 -0
  437. package/dist/src/foundation/workspace-contracts/index.js.map +1 -0
  438. package/dist/src/foundation/workspace-contracts/model.d.ts +249 -0
  439. package/dist/src/foundation/workspace-contracts/model.d.ts.map +1 -0
  440. package/dist/src/foundation/workspace-contracts/model.js +3 -0
  441. package/dist/src/foundation/workspace-contracts/model.js.map +1 -0
  442. package/dist/src/foundation/workspace-contracts/validation.d.ts +14 -0
  443. package/dist/src/foundation/workspace-contracts/validation.d.ts.map +1 -0
  444. package/dist/src/foundation/workspace-contracts/validation.js +336 -0
  445. package/dist/src/foundation/workspace-contracts/validation.js.map +1 -0
  446. package/docs/architecture/boundaries.md +46 -0
  447. package/docs/architecture/project-structure.md +81 -0
  448. package/docs/architecture/resource-and-data-policy.md +55 -0
  449. package/docs/architecture/terminal-host-proof-gate.md +32 -0
  450. package/docs/architecture/terminal-host-provenance.md +69 -0
  451. package/docs/architecture/terminal-host-spike-evidence.md +39 -0
  452. package/docs/architecture/toolchain.md +66 -0
  453. package/docs/features/launch-profiles.md +50 -0
  454. package/docs/manual-transparent-checkpoint.md +53 -0
  455. package/package.json +73 -0
@@ -0,0 +1,119 @@
1
+ import { assertStructuredCapability, } from "../workspace-contracts/index.js";
2
+ export class StructuredBackpressureController {
3
+ adapterId;
4
+ #budgets;
5
+ #usage = {
6
+ events: { units: 0, bytes: 0 },
7
+ commands: { units: 0, bytes: 0 },
8
+ snapshots: { units: 0, bytes: 0 },
9
+ attachments: { units: 0, bytes: 0 },
10
+ "reconnect-replay": { units: 0, bytes: 0 },
11
+ };
12
+ #leases = new Map();
13
+ #nextLeaseSequence = 0;
14
+ #replayExhausted = false;
15
+ constructor(adapterId, capability) {
16
+ this.adapterId = adapterId;
17
+ assertStructuredCapability(capability);
18
+ if (!adapterId || adapterId !== capability.adapterId)
19
+ throw new TypeError("structured backpressure adapter identity is invalid");
20
+ this.#budgets = Object.freeze({
21
+ events: budget(capability.flow.maxQueuedEvents, capability.flow.maxQueuedEvents * capability.flow.maxEventBytes, capability.flow.maxEventBytes, "pause-adapter"),
22
+ commands: budget(capability.flow.maxConcurrentCommands, capability.flow.maxConcurrentCommands * capability.flow.maxEventBytes, capability.flow.maxEventBytes, "reject-request"),
23
+ snapshots: budget(1, capability.flow.maxSnapshotBytes, capability.flow.maxSnapshotBytes, "reject-request"),
24
+ attachments: budget(capability.flow.maxConcurrentCommands, capability.flow.maxAttachmentBytes, capability.flow.maxAttachmentBytes, "reject-request"),
25
+ "reconnect-replay": budget(capability.flow.maxReconnectEvents, capability.flow.maxReconnectEvents * capability.flow.maxEventBytes, capability.flow.maxEventBytes, "disconnect-adapter"),
26
+ });
27
+ }
28
+ acquire(resource, units = 1, bytes = 0) {
29
+ const budget = this.#budget(resource);
30
+ if (!isPositiveSafeInteger(units) || !isSafeNonNegativeInteger(bytes)) {
31
+ return this.#reject(resource, "invalid-request", "reject-request", "resource units and bytes must be bounded safe integers");
32
+ }
33
+ if (bytes > budget.perPayloadByteLimit) {
34
+ return this.#reject(resource, "payload-too-large", "reject-payload", `${resource} payload exceeds its negotiated ${budget.perPayloadByteLimit} byte limit`);
35
+ }
36
+ if (resource === "reconnect-replay" && this.#replayExhausted) {
37
+ return this.#reject(resource, "replay-exhausted", "disconnect-adapter", "reconnect replay is already exhausted for this adapter");
38
+ }
39
+ const usage = this.#usage[resource];
40
+ if (usage.units + units > budget.unitLimit || usage.bytes + bytes > budget.byteLimit) {
41
+ if (resource === "reconnect-replay") {
42
+ this.#replayExhausted = true;
43
+ return this.#reject(resource, "replay-exhausted", "disconnect-adapter", "reconnect replay exceeded its negotiated event or byte window");
44
+ }
45
+ return this.#reject(resource, "resource-exhausted", budget.action, `${resource} exceeded its negotiated count or byte window`);
46
+ }
47
+ usage.units += units;
48
+ usage.bytes += bytes;
49
+ this.#nextLeaseSequence += 1;
50
+ const lease = Object.freeze({
51
+ id: `lease-${this.adapterId}-${this.#nextLeaseSequence}`,
52
+ resource,
53
+ units,
54
+ bytes,
55
+ });
56
+ this.#leases.set(lease.id, lease);
57
+ return { kind: "accepted", lease, usage: this.usage(resource) };
58
+ }
59
+ release(lease) {
60
+ if (!lease || typeof lease.id !== "string" || !isPositiveSafeInteger(lease.units) || !isSafeNonNegativeInteger(lease.bytes)) {
61
+ return { kind: "rejected", code: "invalid-request", diagnostic: "resource lease is malformed" };
62
+ }
63
+ const owned = this.#leases.get(lease.id);
64
+ if (!owned || owned.resource !== lease.resource || owned.units !== lease.units || owned.bytes !== lease.bytes) {
65
+ return { kind: "rejected", code: "unknown-lease", diagnostic: `resource lease is unknown: ${lease.id}` };
66
+ }
67
+ this.#leases.delete(lease.id);
68
+ const usage = this.#usage[lease.resource];
69
+ usage.units -= lease.units;
70
+ usage.bytes -= lease.bytes;
71
+ return { kind: "released", usage: this.usage(lease.resource) };
72
+ }
73
+ resetReconnectReplay() {
74
+ const usage = this.#usage["reconnect-replay"];
75
+ usage.units = 0;
76
+ usage.bytes = 0;
77
+ this.#replayExhausted = false;
78
+ for (const [id, lease] of this.#leases) {
79
+ if (lease.resource === "reconnect-replay")
80
+ this.#leases.delete(id);
81
+ }
82
+ }
83
+ usage(resource) {
84
+ const usage = this.#usage[resource];
85
+ const budget = this.#budget(resource);
86
+ return Object.freeze({
87
+ resource,
88
+ units: usage.units,
89
+ bytes: usage.bytes,
90
+ unitLimit: budget.unitLimit,
91
+ byteLimit: budget.byteLimit,
92
+ });
93
+ }
94
+ leaseCount() {
95
+ return this.#leases.size;
96
+ }
97
+ replayExhausted() {
98
+ return this.#replayExhausted;
99
+ }
100
+ #budget(resource) {
101
+ const budget = this.#budgets[resource];
102
+ if (!budget)
103
+ throw new TypeError(`unknown structured backpressure resource: ${String(resource)}`);
104
+ return budget;
105
+ }
106
+ #reject(resource, code, action, diagnostic) {
107
+ return { kind: "rejected", code, action, usage: this.usage(resource), diagnostic };
108
+ }
109
+ }
110
+ function budget(unitLimit, byteLimit, perPayloadByteLimit, action) {
111
+ return Object.freeze({ unitLimit, byteLimit, perPayloadByteLimit, action });
112
+ }
113
+ function isPositiveSafeInteger(value) {
114
+ return Number.isSafeInteger(value) && value > 0;
115
+ }
116
+ function isSafeNonNegativeInteger(value) {
117
+ return Number.isSafeInteger(value) && value >= 0;
118
+ }
119
+ //# sourceMappingURL=backpressure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backpressure.js","sourceRoot":"","sources":["../../../../src/foundation/structured-agent-runtime/backpressure.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,GAE3B,MAAM,iCAAiC,CAAC;AA8CzC,MAAM,OAAO,gCAAgC;IAatB;IAZZ,QAAQ,CAAmE;IAC3E,MAAM,GAAyD;QACtE,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;QAC9B,QAAQ,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;QAChC,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;QACjC,WAAW,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;QACnC,kBAAkB,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;KAC3C,CAAC;IACO,OAAO,GAAG,IAAI,GAAG,EAAmC,CAAC;IAC9D,kBAAkB,GAAG,CAAC,CAAC;IACvB,gBAAgB,GAAG,KAAK,CAAC;IAEzB,YAAqB,SAAiB,EAAE,UAAwC;QAA3D,cAAS,GAAT,SAAS,CAAQ;QACpC,0BAA0B,CAAC,UAAU,CAAC,CAAC;QACvC,IAAI,CAAC,SAAS,IAAI,SAAS,KAAK,UAAU,CAAC,SAAS;YAAE,MAAM,IAAI,SAAS,CAAC,qDAAqD,CAAC,CAA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C,MAAM;YAAE,MAAM,IAAI,SAAS,CAAC,6CAA6C,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAClG,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO,CACL,QAAwC,EACxC,IAAyF,EACzF,MAAqD,EACrD,UAAkB;QAElB,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAC;IACrF,CAAC;CACF;AAED,SAAS,MAAM,CAAC,SAAiB,EAAE,SAAiB,EAAE,mBAA2B,EAAE,MAAgC;IACjH,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAa;IAC1C,OAAO,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,wBAAwB,CAAC,KAAa;IAC7C,OAAO,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AACnD,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { type StructuredCapabilityContract, type WorkspaceCommand } from "../workspace-contracts/index.js";
2
+ export type StructuredCommandRequest = Extract<WorkspaceCommand, {
3
+ readonly type: "structured-command";
4
+ }>;
5
+ export type StructuredCancelRequest = Extract<WorkspaceCommand, {
6
+ readonly type: "cancel-structured-command";
7
+ }>;
8
+ export type StructuredCommandTerminalOutcome = "completed" | "failed" | "timed-out" | "cancelled";
9
+ export interface StructuredCommandRecord {
10
+ readonly agentId: string;
11
+ readonly correlationId: string;
12
+ readonly command: string;
13
+ readonly payload: unknown;
14
+ readonly startedAt: number;
15
+ readonly terminalAt: number | null;
16
+ readonly outcome: "active" | StructuredCommandTerminalOutcome;
17
+ readonly revision: number;
18
+ }
19
+ export type StructuredCommandStartResult = {
20
+ readonly kind: "accepted";
21
+ readonly record: StructuredCommandRecord;
22
+ readonly activeCount: number;
23
+ } | {
24
+ readonly kind: "outcome";
25
+ readonly record: StructuredCommandRecord;
26
+ readonly idempotent: true;
27
+ } | {
28
+ readonly kind: "rejected";
29
+ readonly code: string;
30
+ readonly diagnostic: string;
31
+ };
32
+ export type StructuredCommandOutcomeResult = {
33
+ readonly kind: "outcome";
34
+ readonly record: StructuredCommandRecord;
35
+ readonly idempotent: boolean;
36
+ } | {
37
+ readonly kind: "rejected";
38
+ readonly code: string;
39
+ readonly diagnostic: string;
40
+ };
41
+ export declare class StructuredCommandTracker {
42
+ #private;
43
+ readonly agentId: string;
44
+ constructor(agentId: string, capability: StructuredCapabilityContract, commandTimeoutMs?: number);
45
+ start(command: StructuredCommandRequest, startedAt?: number): StructuredCommandStartResult;
46
+ complete(correlationId: string, outcome: "completed" | "failed", completedAt?: number): StructuredCommandOutcomeResult;
47
+ cancel(request: StructuredCancelRequest, cancelledAt?: number): StructuredCommandOutcomeResult;
48
+ expire(now: number): readonly StructuredCommandRecord[];
49
+ outcomeFor(correlationId: string): StructuredCommandRecord | null;
50
+ activeCount(): number;
51
+ terminalCount(): number;
52
+ }
53
+ //# sourceMappingURL=commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../../src/foundation/structured-agent-runtime/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,4BAA4B,EACjC,KAAK,gBAAgB,EACtB,MAAM,iCAAiC,CAAC;AAEzC,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAAC,gBAAgB,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAA;CAAE,CAAC,CAAC;AAC1G,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,2BAA2B,CAAA;CAAE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AC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAatF,qBAAa,wBAAwB;;IAOjC,QAAQ,CAAC,OAAO,EAAE,MAAM;gBAAf,OAAO,EAAE,MAAM,EACxB,UAAU,EAAE,4BAA4B,EACxC,gBAAgB,SAAS;IAS3B,KAAK,CAAC,OAAO,EAAE,wBAAwB,EAAE,SAAS,SAAI,GAAG,4BAA4B;IA4CrF,QAAQ,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,QAAQ,EAAE,WAAW,SAAI,GAAG,8BAA8B;IAYjH,MAAM,CAAC,OAAO,EAAE,uBAAuB,EAAE,WAAW,SAAI,GAAG,8BAA8B;IAkBzF,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,uBAAuB,EAAE;IAYvD,UAAU,CAAC,aAAa,EAAE,MAAM,GAAG,uBAAuB,GAAG,IAAI;IAKjE,WAAW,IAAI,MAAM;IAMrB,aAAa,IAAI,MAAM;CAuBxB"}
@@ -0,0 +1,165 @@
1
+ import { assertStructuredCapability, assertWorkspaceCommand, } from "../workspace-contracts/index.js";
2
+ export class StructuredCommandTracker {
3
+ agentId;
4
+ #capability;
5
+ #commandTimeoutMs;
6
+ #records = new Map();
7
+ #terminalOrder = [];
8
+ constructor(agentId, capability, commandTimeoutMs = 30_000) {
9
+ this.agentId = agentId;
10
+ assertStructuredCapability(capability);
11
+ if (!agentId || agentId.includes("\0"))
12
+ throw new TypeError("structured command agent id is invalid");
13
+ if (!Number.isSafeInteger(commandTimeoutMs) || commandTimeoutMs <= 0)
14
+ throw new RangeError("structured command timeout must be positive");
15
+ this.#capability = capability;
16
+ this.#commandTimeoutMs = commandTimeoutMs;
17
+ }
18
+ start(command, startedAt = 0) {
19
+ try {
20
+ assertWorkspaceCommand(command);
21
+ }
22
+ catch (error) {
23
+ return rejected("malformed-command", error);
24
+ }
25
+ if (command.agentId !== this.agentId)
26
+ return rejected("agent-mismatch", new Error("structured command agent does not match the tracker identity"));
27
+ if (!this.#capability.commands.includes(command.command)) {
28
+ return rejected("unsupported-command", new Error(`structured command is not negotiated: ${command.command}`));
29
+ }
30
+ if (payloadBytes(command.payload) > this.#capability.flow.maxEventBytes) {
31
+ return rejected("command-too-large", new Error(`structured command exceeds the negotiated ${this.#capability.flow.maxEventBytes} byte payload limit`));
32
+ }
33
+ try {
34
+ assertTime(startedAt, "command start time");
35
+ }
36
+ catch (error) {
37
+ return rejected("invalid-time", error);
38
+ }
39
+ const existing = this.#records.get(command.correlationId);
40
+ if (existing) {
41
+ if (existing.outcome !== "active" && existing.command === command.command && stableJson(existing.payload) === stableJson(command.payload)) {
42
+ return { kind: "outcome", record: freezeRecord(existing), idempotent: true };
43
+ }
44
+ return rejected(existing.outcome === "active" ? "duplicate-correlation" : "correlation-conflict", new Error(`structured correlation id is already in use: ${command.correlationId}`));
45
+ }
46
+ if (this.activeCount() >= this.#capability.flow.maxConcurrentCommands) {
47
+ return rejected("concurrency-limit", new Error(`structured command concurrency exceeds the negotiated ${this.#capability.flow.maxConcurrentCommands} command limit`));
48
+ }
49
+ const record = {
50
+ agentId: command.agentId,
51
+ correlationId: command.correlationId,
52
+ command: command.command,
53
+ payload: command.payload,
54
+ startedAt,
55
+ terminalAt: null,
56
+ outcome: "active",
57
+ revision: 1,
58
+ };
59
+ this.#records.set(record.correlationId, record);
60
+ return { kind: "accepted", record: freezeRecord(record), activeCount: this.activeCount() };
61
+ }
62
+ complete(correlationId, outcome, completedAt = 0) {
63
+ if (outcome !== "completed" && outcome !== "failed")
64
+ return rejected("malformed-outcome", new Error("structured completion outcome is invalid"));
65
+ try {
66
+ assertTime(completedAt, "command completion time");
67
+ }
68
+ catch (error) {
69
+ return rejected("invalid-time", error);
70
+ }
71
+ const record = this.#records.get(correlationId);
72
+ if (!record)
73
+ return rejected("unknown-correlation", new Error(`structured correlation id is unknown: ${correlationId}`));
74
+ return this.#settle(record, outcome, completedAt);
75
+ }
76
+ cancel(request, cancelledAt = 0) {
77
+ try {
78
+ assertWorkspaceCommand(request);
79
+ }
80
+ catch (error) {
81
+ return rejected("malformed-cancellation", error);
82
+ }
83
+ if (request.agentId !== this.agentId)
84
+ return rejected("agent-mismatch", new Error("structured cancellation agent does not match the tracker identity"));
85
+ if (this.#capability.cancellation !== "correlated")
86
+ return rejected("cancellation-unsupported", new Error("the negotiated adapter capability does not support correlated cancellation"));
87
+ try {
88
+ assertTime(cancelledAt, "command cancellation time");
89
+ }
90
+ catch (error) {
91
+ return rejected("invalid-time", error);
92
+ }
93
+ const record = this.#records.get(request.targetCorrelationId);
94
+ if (!record)
95
+ return rejected("unknown-correlation", new Error(`structured correlation id is unknown: ${request.targetCorrelationId}`));
96
+ return this.#settle(record, "cancelled", cancelledAt);
97
+ }
98
+ expire(now) {
99
+ assertTime(now, "command timeout clock");
100
+ const expired = [];
101
+ for (const record of this.#records.values()) {
102
+ if (record.outcome === "active" && now - record.startedAt >= this.#commandTimeoutMs) {
103
+ const result = this.#settle(record, "timed-out", record.startedAt + this.#commandTimeoutMs);
104
+ if (result.kind === "outcome")
105
+ expired.push(result.record);
106
+ }
107
+ }
108
+ return Object.freeze(expired);
109
+ }
110
+ outcomeFor(correlationId) {
111
+ const record = this.#records.get(correlationId);
112
+ return record ? freezeRecord(record) : null;
113
+ }
114
+ activeCount() {
115
+ let count = 0;
116
+ for (const record of this.#records.values())
117
+ if (record.outcome === "active")
118
+ count += 1;
119
+ return count;
120
+ }
121
+ terminalCount() {
122
+ return this.#terminalOrder.length;
123
+ }
124
+ #settle(record, outcome, at) {
125
+ if (record.outcome !== "active")
126
+ return { kind: "outcome", record: freezeRecord(record), idempotent: true };
127
+ if (at < record.startedAt)
128
+ return rejected("invalid-time", new Error("structured command outcome cannot precede its start"));
129
+ record.outcome = outcome;
130
+ record.terminalAt = at;
131
+ record.revision += 1;
132
+ this.#terminalOrder.push(record.correlationId);
133
+ this.#boundTerminalOutcomes();
134
+ return { kind: "outcome", record: freezeRecord(record), idempotent: false };
135
+ }
136
+ #boundTerminalOutcomes() {
137
+ const retention = this.#capability.flow.maxQueuedEvents;
138
+ while (this.#terminalOrder.length > retention) {
139
+ const oldest = this.#terminalOrder.shift();
140
+ if (oldest === undefined)
141
+ return;
142
+ this.#records.delete(oldest);
143
+ }
144
+ }
145
+ }
146
+ function rejected(code, error) {
147
+ return { kind: "rejected", code, diagnostic: error instanceof Error ? error.message : String(error) };
148
+ }
149
+ function freezeRecord(record) {
150
+ return Object.freeze({ ...record });
151
+ }
152
+ function assertTime(value, name) {
153
+ if (!Number.isSafeInteger(value) || value < 0)
154
+ throw new RangeError(`${name} must be a non-negative safe integer`);
155
+ }
156
+ function payloadBytes(payload) {
157
+ return new TextEncoder().encode(stableJson(payload)).byteLength;
158
+ }
159
+ function stableJson(value) {
160
+ const encoded = JSON.stringify(value);
161
+ if (encoded === undefined)
162
+ throw new TypeError("structured payload must be JSON serializable");
163
+ return encoded;
164
+ }
165
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.js","sourceRoot":"","sources":["../../../../src/foundation/structured-agent-runtime/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,GAGvB,MAAM,iCAAiC,CAAC;AAqCzC,MAAM,OAAO,wBAAwB;IAOxB;IANF,WAAW,CAA+B;IAC1C,iBAAiB,CAAS;IAC1B,QAAQ,GAAG,IAAI,GAAG,EAAgC,CAAC;IACnD,cAAc,GAAa,EAAE,CAAC;IAEvC,YACW,OAAe,EACxB,UAAwC,EACxC,gBAAgB,GAAG,MAAM;QAFhB,YAAO,GAAP,OAAO,CAAQ;QAIxB,0BAA0B,CAAC,UAAU,CAAC,CAAC;QACvC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,MAAM,IAAI,SAAS,CAAC,wCAAwC,CAAC,CAAC;QACtG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,gBAAgB,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racts/index.js";
2
+ export declare const STRUCTURED_ADAPTER_ENVELOPE: "addone-structured-adapter";
3
+ export declare const STRUCTURED_ADAPTER_ENVELOPE_REVISION: 1;
4
+ export declare const REQUIRED_STRUCTURED_FEATURES: readonly ["identity.adapter.v1", "commands.correlated.v1", "events.typed.v1", "flow-control.limits.v1"];
5
+ export declare const OPTIONAL_STRUCTURED_FEATURES: readonly ["snapshots.authoritative.v1", "resume.position.v1", "resume.snapshot.v1", "commands.cancellable.v1", "attachments.typed.v1"];
6
+ export type StructuredProtocolFeature = typeof REQUIRED_STRUCTURED_FEATURES[number] | typeof OPTIONAL_STRUCTURED_FEATURES[number];
7
+ export declare const ADDONE_STRUCTURED_FLOW_LIMITS: StructuredFlowLimits;
8
+ export interface StructuredAdapterHello {
9
+ readonly envelope: typeof STRUCTURED_ADAPTER_ENVELOPE;
10
+ readonly envelopeRevision: typeof STRUCTURED_ADAPTER_ENVELOPE_REVISION;
11
+ readonly adapterId: AdapterId;
12
+ readonly buildId: string;
13
+ readonly requiredFeatures: readonly string[];
14
+ readonly optionalFeatures: readonly string[];
15
+ readonly capability: StructuredCapabilityContract;
16
+ }
17
+ export interface StructuredAdapterPeerHello {
18
+ readonly envelope: typeof STRUCTURED_ADAPTER_ENVELOPE;
19
+ readonly envelopeRevision: typeof STRUCTURED_ADAPTER_ENVELOPE_REVISION;
20
+ readonly requiredFeatures: readonly string[];
21
+ readonly optionalFeatures: readonly string[];
22
+ readonly flowLimits: StructuredFlowLimits;
23
+ }
24
+ export type StructuredHandshakeErrorCode = "invalid-message" | "unsupported-version" | "invalid-identity" | "invalid-capability" | "unsupported-feature" | "incompatible-features";
25
+ export interface StructuredHandshakeAccepted {
26
+ readonly accepted: true;
27
+ readonly adapterId: AdapterId;
28
+ readonly negotiatedFeatures: readonly string[];
29
+ readonly capability: StructuredCapabilityContract;
30
+ readonly diagnostic: string;
31
+ }
32
+ export interface StructuredHandshakeRejected {
33
+ readonly accepted: false;
34
+ readonly code: StructuredHandshakeErrorCode;
35
+ readonly missingFromAdapter: readonly string[];
36
+ readonly missingFromServer: readonly string[];
37
+ readonly diagnostic: string;
38
+ }
39
+ export type StructuredHandshakeResult = StructuredHandshakeAccepted | StructuredHandshakeRejected;
40
+ export declare function localStructuredAdapterHello(): StructuredAdapterPeerHello;
41
+ export declare function negotiateStructuredAdapter(value: unknown, server?: StructuredAdapterPeerHello): StructuredHandshakeResult;
42
+ //# sourceMappingURL=handshake.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handshake.d.ts","sourceRoot":"","sources":["../../../../src/foundation/structured-agent-runtime/handshake.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,4BAA4B,EACjC,KAAK,oBAAoB,EAC1B,MAAM,iCAAiC,CAAC;AAEzC,eAAO,MAAM,2BAA2B,EAAG,2BAAoC,CAAC;AAChF,eAAO,MAAM,oCAAoC,EAAG,CAAU,CAAC;AAC/D,eAAO,MAAM,4BAA4B,yGAK/B,CAAC;AACX,eAAO,MAAM,4BAA4B,wIAM/B,CAAC;AACX,MAAM,MAAM,yBAAyB,GAAG,OAAO,4BAA4B,CAAC,MAAM,CAAC,GAAG,OAAO,4BAA4B,CAAC,MAAM,CAAC,CAAC;AAElI,eAAO,MAAM,6BAA6B,EAAE,oBAO1C,CAAC;AAEH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,QAAQ,EAAE,OAAO,2BAA2B,CAAC;IACtD,QAAQ,CAAC,gBAAgB,EAAE,OAAO,oCAAoC,CAAC;IACvE,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C,QAAQ,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C,QAAQ,CAAC,UAAU,EAAE,4BAA4B,CAAC;CACnD;AAED,MAAM,WAAW,0B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ace-contracts/index.js";
2
+ export const STRUCTURED_ADAPTER_ENVELOPE = "addone-structured-adapter";
3
+ export const STRUCTURED_ADAPTER_ENVELOPE_REVISION = 1;
4
+ export const REQUIRED_STRUCTURED_FEATURES = [
5
+ "identity.adapter.v1",
6
+ "commands.correlated.v1",
7
+ "events.typed.v1",
8
+ "flow-control.limits.v1",
9
+ ];
10
+ export const OPTIONAL_STRUCTURED_FEATURES = [
11
+ "snapshots.authoritative.v1",
12
+ "resume.position.v1",
13
+ "resume.snapshot.v1",
14
+ "commands.cancellable.v1",
15
+ "attachments.typed.v1",
16
+ ];
17
+ export const ADDONE_STRUCTURED_FLOW_LIMITS = Object.freeze({
18
+ maxEventBytes: 64 * 1024,
19
+ maxSnapshotBytes: 1024 * 1024,
20
+ maxAttachmentBytes: 2 * 1024 * 1024,
21
+ maxQueuedEvents: 256,
22
+ maxConcurrentCommands: 4,
23
+ maxReconnectEvents: 1024,
24
+ });
25
+ export function localStructuredAdapterHello() {
26
+ return {
27
+ envelope: STRUCTURED_ADAPTER_ENVELOPE,
28
+ envelopeRevision: STRUCTURED_ADAPTER_ENVELOPE_REVISION,
29
+ requiredFeatures: REQUIRED_STRUCTURED_FEATURES,
30
+ optionalFeatures: OPTIONAL_STRUCTURED_FEATURES,
31
+ flowLimits: ADDONE_STRUCTURED_FLOW_LIMITS,
32
+ };
33
+ }
34
+ export function negotiateStructuredAdapter(value, server = localStructuredAdapterHello()) {
35
+ if (!isStructuredAdapterHello(value)) {
36
+ return reject("invalid-message", [], [], "adapter hello is malformed or omits required identity, feature, or capability fields");
37
+ }
38
+ if (value.envelope !== server.envelope || value.envelopeRevision !== server.envelopeRevision) {
39
+ return reject("unsupported-version", [], [], `structured adapter envelope mismatch: adapter ${String(value.envelope)}/${String(value.envelopeRevision)}; AddOne ${server.envelope}/${server.envelopeRevision}`);
40
+ }
41
+ if (!isValidIdentityText(value.adapterId) || !isValidBuildId(value.buildId)) {
42
+ return reject("invalid-identity", [], [], "adapter identity and build identity must be bounded non-empty values");
43
+ }
44
+ if (value.capability.adapterId !== value.adapterId) {
45
+ return reject("invalid-identity", [], [], "adapter capability identity must match the hello identity");
46
+ }
47
+ try {
48
+ assertStructuredCapability(value.capability);
49
+ }
50
+ catch (error) {
51
+ return reject("invalid-capability", [], [], `adapter capability is invalid: ${error instanceof Error ? error.message : String(error)}`);
52
+ }
53
+ const advertised = featureSet(value.requiredFeatures, value.optionalFeatures);
54
+ if (advertised.error)
55
+ return advertised.error;
56
+ const serverFeatures = new Set([...server.requiredFeatures, ...server.optionalFeatures]);
57
+ const adapterRequired = new Set(value.requiredFeatures);
58
+ const unknownRequired = [...adapterRequired].filter(feature => !serverFeatures.has(feature));
59
+ if (unknownRequired.length > 0) {
60
+ return reject("unsupported-feature", [], unknownRequired.sort(), `adapter requires unsupported structured features: ${unknownRequired.sort().join(", ")}`);
61
+ }
62
+ const missingFromAdapter = server.requiredFeatures.filter(feature => !advertised.features.has(feature)).sort();
63
+ const missingFromServer = [...adapterRequired].filter(feature => !serverFeatures.has(feature)).sort();
64
+ if (missingFromAdapter.length > 0 || missingFromServer.length > 0) {
65
+ return reject("incompatible-features", missingFromAdapter, missingFromServer, `required structured features are unavailable; adapter missing [${missingFromAdapter.join(", ")}], AddOne missing [${missingFromServer.join(", ")}]`);
66
+ }
67
+ const capabilityFeatures = requiredFeaturesForCapability(value.capability);
68
+ const undeclared = capabilityFeatures.filter(feature => !advertised.features.has(feature));
69
+ if (undeclared.length > 0) {
70
+ return reject("invalid-capability", undeclared.sort(), [], `adapter capability requires undeclared features: ${undeclared.sort().join(", ")}`);
71
+ }
72
+ const negotiatedFeatures = [...advertised.features].filter(feature => serverFeatures.has(feature)).sort();
73
+ const capability = {
74
+ ...value.capability,
75
+ adapterId: value.adapterId,
76
+ flow: negotiateFlow(value.capability.flow, server.flowLimits),
77
+ };
78
+ return {
79
+ accepted: true,
80
+ adapterId: value.adapterId,
81
+ negotiatedFeatures,
82
+ capability,
83
+ diagnostic: `structured adapter ready; negotiated ${negotiatedFeatures.join(", ")}`,
84
+ };
85
+ }
86
+ function requiredFeaturesForCapability(capability) {
87
+ const features = [];
88
+ if (capability.snapshots === "authoritative")
89
+ features.push("snapshots.authoritative.v1");
90
+ if (capability.resume === "position")
91
+ features.push("resume.position.v1");
92
+ if (capability.resume === "snapshot")
93
+ features.push("resume.snapshot.v1");
94
+ if (capability.cancellation === "correlated")
95
+ features.push("commands.cancellable.v1");
96
+ if (capability.attachmentTypes.length > 0)
97
+ features.push("attachments.typed.v1");
98
+ return features;
99
+ }
100
+ function negotiateFlow(adapter, addone) {
101
+ return Object.freeze({
102
+ maxEventBytes: Math.min(adapter.maxEventBytes, addone.maxEventBytes),
103
+ maxSnapshotBytes: Math.min(adapter.maxSnapshotBytes, addone.maxSnapshotBytes),
104
+ maxAttachmentBytes: Math.min(adapter.maxAttachmentBytes, addone.maxAttachmentBytes),
105
+ maxQueuedEvents: Math.min(adapter.maxQueuedEvents, addone.maxQueuedEvents),
106
+ maxConcurrentCommands: Math.min(adapter.maxConcurrentCommands, addone.maxConcurrentCommands),
107
+ maxReconnectEvents: Math.min(adapter.maxReconnectEvents, addone.maxReconnectEvents),
108
+ });
109
+ }
110
+ function isStructuredAdapterHello(value) {
111
+ if (!isRecord(value))
112
+ return false;
113
+ return typeof value.envelope === "string"
114
+ && typeof value.envelopeRevision === "number"
115
+ && typeof value.adapterId === "string"
116
+ && typeof value.buildId === "string"
117
+ && isStringArray(value.requiredFeatures)
118
+ && isStringArray(value.optionalFeatures)
119
+ && isRecord(value.capability)
120
+ && value.capability.kind === "structured"
121
+ && typeof value.capability.protocolVersion === "number";
122
+ }
123
+ function featureSet(required, optional) {
124
+ const features = new Set();
125
+ for (const feature of [...required, ...optional]) {
126
+ if (!isValidIdentityText(feature)) {
127
+ return { features, error: reject("invalid-message", [], [], `structured feature name is invalid: ${feature}`) };
128
+ }
129
+ if (features.has(feature)) {
130
+ return { features, error: reject("invalid-message", [], [], `structured feature is declared more than once: ${feature}`) };
131
+ }
132
+ features.add(feature);
133
+ }
134
+ return { features, error: null };
135
+ }
136
+ function reject(code, missingFromAdapter, missingFromServer, diagnostic) {
137
+ return { accepted: false, code, missingFromAdapter, missingFromServer, diagnostic };
138
+ }
139
+ function isValidIdentityText(value) {
140
+ return value.length > 0 && value.length <= 128 && !value.includes("\0");
141
+ }
142
+ function isValidBuildId(value) {
143
+ return value.length > 0 && value.length <= 256 && !value.includes("\0");
144
+ }
145
+ function isRecord(value) {
146
+ return typeof value === "object" && value !== null;
147
+ }
148
+ function isStringArray(value) {
149
+ return Array.isArray(value) && value.every(item => typeof item === "string");
150
+ }
151
+ //# sourceMappingURL=handshake.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handshake.js","sourceRoot":"","sources":["../../../../src/foundation/structured-agent-runtime/handshake.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,GAI3B,MAAM,iCAAiC,CAAC;AAEzC,MAAM,CAAC,MAAM,2BAA2B,GAAG,2BAAoC,CAAC;AAChF,MAAM,CAAC,MAAM,oCAAoC,GAAG,CAAU,CAAC;AAC/D,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,qBAAqB;IACrB,wBAAwB;IACxB,iBAAiB;IACjB,wBAAwB;CAChB,CAAC;AACX,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,4BAA4B;IAC5B,oBAAoB;IACpB,oBAAoB;IACpB,yBAAyB;IACzB,sBAAsB;CACd,CAAC;AAGX,MAAM,CAAC,MAAM,6BAA6B,GAAyB,MAAM,CAAC,MAAM,CAAC;IAC/E,aAAa,EAAE,EAAE,GAAG,IAAI;IACxB,gBAAgB,EAAE,IAAI,GAAG,IAAI;IAC7B,kBAAkB,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI;IACnC,eAAe,EAAE,GAAG;IACpB,qBAAqB,EAAE,CAAC;IACxB,kBAAkB,EAAE,IAAI;CACzB,CAAC,CAAC;AA8CH,MAAM,UAAU,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kDAAkD,OAAO,EAAE,CAAC,EAAE,CAAC;QAC7H,CAAC;QACD,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACnC,CAAC;AAED,SAAS,MAAM,CACb,IAAkC,EAClC,kBAAqC,EACrC,iBAAoC,EACpC,UAAkB;IAElB,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,UAAU,EAAE,CAAC;AACtF,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAa;IACxC,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC1E,CAAC;AAED,SAAS,cAAc,CAAC,KAAa;IACnC,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC1E,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC;AAC/E,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from "./backpressure.js";
2
+ export * from "./commands.js";
3
+ export * from "./handshake.js";
4
+ export * from "./reconnection.js";
5
+ export * from "./state.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/foundation/structured-agent-runtime/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from "./backpressure.js";
2
+ export * from "./commands.js";
3
+ export * from "./handshake.js";
4
+ export * from "./reconnection.js";
5
+ export * from "./state.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/foundation/structured-agent-runtime/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}