@makinbakin/sdk 0.0.1-rc.4 → 0.0.1-rc.40

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 (342) hide show
  1. package/README.md +248 -3
  2. package/_internal/app/components/agent-avatar.d.ts +2 -1
  3. package/_internal/app/components/conversation/attention.d.ts +56 -0
  4. package/_internal/app/components/conversation/fold.d.ts +3 -0
  5. package/_internal/app/components/conversation/notification-sound.d.ts +8 -0
  6. package/_internal/app/components/conversation/reply-toast.d.ts +15 -0
  7. package/_internal/app/components/conversation/thread-id.d.ts +8 -0
  8. package/_internal/app/components/conversation/turn-recorder.d.ts +37 -0
  9. package/_internal/app/components/conversation/use-conversation-attention.d.ts +61 -0
  10. package/_internal/app/components/drawer.d.ts +27 -0
  11. package/_internal/app/components/ui/button.d.ts +2 -8
  12. package/_internal/app/components/ui/dialog.d.ts +2 -17
  13. package/_internal/app/components/ui/sheet.d.ts +2 -14
  14. package/_internal/app/core/conversation-turns.d.ts +229 -0
  15. package/_internal/app/core/logger.d.ts +1 -0
  16. package/_internal/app/core/tool-access.d.ts +42 -0
  17. package/_internal/app/hooks/use-available-models.d.ts +25 -0
  18. package/_internal/app/hooks/use-content-store.d.ts +0 -9
  19. package/_internal/app/hooks/use-history-back.d.ts +5 -0
  20. package/_internal/app/hooks/use-horizontal-resize.d.ts +21 -0
  21. package/_internal/app/hooks/use-json-fetch.d.ts +36 -0
  22. package/_internal/app/hooks/use-nav-badge.d.ts +13 -0
  23. package/_internal/app/hooks/use-plugin-event.d.ts +19 -0
  24. package/_internal/app/hooks/use-query-state.d.ts +3 -12
  25. package/_internal/app/hooks/use-resizable-pane.d.ts +35 -0
  26. package/_internal/app/hooks/use-runtime-status.d.ts +22 -6
  27. package/_internal/app/hooks/use-schedule.d.ts +47 -1
  28. package/_internal/app/hooks/use-search.d.ts +27 -8
  29. package/_internal/app/hooks/use-task-run-history.d.ts +26 -0
  30. package/_internal/app/hooks/use-toast.d.ts +13 -3
  31. package/_internal/app/lib/browser-notify.d.ts +12 -1
  32. package/_internal/app/types/index.d.ts +1 -105
  33. package/_internal/core/adapters/runtime/channels.d.ts +231 -0
  34. package/_internal/core/adapters/runtime/concepts.d.ts +794 -235
  35. package/_internal/core/adapters/runtime/errors.d.ts +105 -0
  36. package/_internal/core/adapters/runtime/helpers.d.ts +19 -0
  37. package/_internal/core/adapters/runtime/index.d.ts +8 -2
  38. package/_internal/core/adapters/runtime/skill-files.d.ts +12 -0
  39. package/_internal/core/adapters/runtime/testing.d.ts +99 -0
  40. package/_internal/core/adapters/runtime/turn-activity.d.ts +23 -0
  41. package/_internal/core/adapters/shared.d.ts +133 -12
  42. package/_internal/core/content-dir.d.ts +11 -0
  43. package/_internal/core/delivery/bridge.d.ts +36 -0
  44. package/_internal/core/docs/route.d.ts +1 -1
  45. package/_internal/core/format/structured.d.ts +44 -0
  46. package/_internal/core/format.d.ts +25 -1
  47. package/_internal/core/health/observation-builders.d.ts +42 -0
  48. package/_internal/core/media/downscale.d.ts +18 -0
  49. package/_internal/core/media/pin-data.d.ts +36 -0
  50. package/_internal/core/media/pin.d.ts +22 -0
  51. package/_internal/core/media/sharp-import.d.ts +10 -0
  52. package/_internal/core/media/sharp-loader.d.ts +41 -0
  53. package/_internal/core/media/store.d.ts +21 -0
  54. package/_internal/core/plugin-types.d.ts +248 -500
  55. package/_internal/core/routing/define.d.ts +33 -3
  56. package/_internal/core/routing/dispatcher.d.ts +15 -6
  57. package/_internal/core/routing/index.d.ts +1 -1
  58. package/_internal/core/routing/types.d.ts +13 -70
  59. package/_internal/core/storage/atomic-write.d.ts +11 -0
  60. package/_internal/core/tasks/store.d.ts +129 -0
  61. package/_internal/core/tasks/testing.d.ts +2 -0
  62. package/_internal/{plugins/workflows/lib → core/workflows}/notification-channel-registry.d.ts +1 -1
  63. package/_internal/host/ui/action-status.d.ts +13 -0
  64. package/_internal/host/ui/modals.d.ts +5 -0
  65. package/_internal/host/ui/resize.d.ts +2 -0
  66. package/_internal/plugins/team/types.d.ts +61 -4
  67. package/_internal/plugins/workflows/hooks/use-notification-channels.d.ts +1 -1
  68. package/_internal/ui/behaviors/clipboard.d.ts +10 -0
  69. package/_internal/ui/behaviors/resize-handle.d.ts +15 -0
  70. package/_internal/ui/behaviors/selection-navigation.d.ts +5 -0
  71. package/_internal/ui/behaviors/use-persisted-leading-edge-resize.d.ts +31 -0
  72. package/_internal/ui/charts/area-chart.d.ts +27 -0
  73. package/_internal/ui/charts/axis.d.ts +13 -0
  74. package/_internal/ui/charts/bar-chart.d.ts +21 -0
  75. package/_internal/ui/charts/chart-data-table.d.ts +61 -0
  76. package/_internal/ui/charts/chart-explainer.d.ts +4 -0
  77. package/_internal/ui/charts/chart-tooltip.d.ts +8 -0
  78. package/_internal/ui/charts/composition-bar.d.ts +46 -0
  79. package/_internal/ui/charts/index.d.ts +24 -0
  80. package/_internal/ui/charts/line-chart.d.ts +26 -0
  81. package/_internal/ui/charts/monotone-curve.d.ts +23 -0
  82. package/_internal/ui/charts/palette.d.ts +32 -0
  83. package/_internal/ui/charts/pie-chart.d.ts +80 -0
  84. package/_internal/ui/charts/ranked-bar-chart.d.ts +41 -0
  85. package/_internal/ui/charts/sparkline.d.ts +16 -0
  86. package/_internal/ui/charts/stacked-column-chart.d.ts +33 -0
  87. package/_internal/ui/content/code-block.d.ts +43 -0
  88. package/_internal/ui/content/index.d.ts +2 -0
  89. package/_internal/ui/conversation/activity-group.d.ts +27 -0
  90. package/_internal/ui/conversation/agent-turn.d.ts +47 -0
  91. package/_internal/ui/conversation/composer.d.ts +62 -0
  92. package/_internal/ui/conversation/context-meter.d.ts +37 -0
  93. package/_internal/ui/conversation/conversation-empty-state.d.ts +13 -0
  94. package/_internal/ui/conversation/conversation-header.d.ts +26 -0
  95. package/_internal/ui/conversation/conversation-panel.d.ts +61 -0
  96. package/_internal/ui/conversation/conversation.d.ts +37 -0
  97. package/_internal/ui/conversation/fold.d.ts +150 -0
  98. package/_internal/ui/conversation/glyphs.d.ts +30 -0
  99. package/_internal/ui/conversation/index.d.ts +31 -0
  100. package/_internal/ui/conversation/queued-message-list.d.ts +22 -0
  101. package/_internal/ui/conversation/relative-time.d.ts +8 -0
  102. package/_internal/ui/conversation/tool-call-drawer.d.ts +14 -0
  103. package/_internal/ui/conversation/turn-controls.d.ts +9 -0
  104. package/_internal/ui/conversation/turn-output.d.ts +42 -0
  105. package/_internal/ui/conversation/turn-usage.d.ts +16 -0
  106. package/_internal/ui/conversation/user-message.d.ts +13 -0
  107. package/_internal/ui/forms/field.d.ts +30 -0
  108. package/_internal/ui/forms/fieldset.d.ts +10 -0
  109. package/_internal/ui/forms/form.d.ts +19 -0
  110. package/_internal/ui/forms/index.d.ts +6 -0
  111. package/_internal/ui/index.d.ts +89 -0
  112. package/_internal/ui/layout/bounded-overflow.d.ts +42 -0
  113. package/_internal/ui/layout/disclosure-panel.d.ts +24 -0
  114. package/_internal/ui/layout/flow.d.ts +27 -0
  115. package/_internal/ui/layout/grid.d.ts +16 -0
  116. package/_internal/ui/layout/index.d.ts +14 -0
  117. package/_internal/ui/layout/page-shell.d.ts +11 -0
  118. package/_internal/ui/layout/panel.d.ts +28 -0
  119. package/_internal/ui/layout/section.d.ts +15 -0
  120. package/_internal/ui/layout/sticky-overflow-scrollbar.d.ts +11 -0
  121. package/_internal/ui/layout/utils.d.ts +1 -0
  122. package/_internal/ui/patterns/agent-filter.d.ts +21 -0
  123. package/_internal/ui/patterns/calendar-grid.d.ts +80 -0
  124. package/_internal/ui/patterns/calendar-item.d.ts +42 -0
  125. package/_internal/ui/patterns/calendar-nav.d.ts +21 -0
  126. package/_internal/ui/patterns/confirm-dialog.d.ts +29 -0
  127. package/_internal/ui/patterns/copy-button.d.ts +15 -0
  128. package/_internal/ui/patterns/danger-zone.d.ts +17 -0
  129. package/_internal/ui/patterns/data-table.d.ts +157 -0
  130. package/_internal/ui/patterns/drawer-section.d.ts +11 -0
  131. package/_internal/ui/patterns/facet-filter.d.ts +22 -0
  132. package/_internal/ui/patterns/filter-indicator.d.ts +3 -0
  133. package/_internal/ui/patterns/guide-card.d.ts +33 -0
  134. package/_internal/ui/patterns/index.d.ts +75 -0
  135. package/_internal/ui/patterns/inspector-panel.d.ts +39 -0
  136. package/_internal/ui/patterns/kanban.d.ts +70 -0
  137. package/_internal/ui/patterns/key-value.d.ts +35 -0
  138. package/_internal/ui/patterns/list-rows.d.ts +111 -0
  139. package/_internal/ui/patterns/nav-list.d.ts +41 -0
  140. package/_internal/ui/patterns/node-card.d.ts +37 -0
  141. package/_internal/ui/patterns/page-aside.d.ts +49 -0
  142. package/_internal/ui/patterns/page-body.d.ts +49 -0
  143. package/_internal/ui/patterns/page-canvas.d.ts +12 -0
  144. package/_internal/ui/patterns/page-composer.d.ts +8 -0
  145. package/_internal/ui/patterns/page-controls.d.ts +33 -0
  146. package/_internal/ui/patterns/page-header.d.ts +40 -0
  147. package/_internal/ui/patterns/page-timeline.d.ts +18 -0
  148. package/_internal/ui/patterns/page.d.ts +32 -0
  149. package/_internal/ui/patterns/pagination.d.ts +23 -0
  150. package/_internal/ui/patterns/save-bar.d.ts +21 -0
  151. package/_internal/ui/patterns/search-input.d.ts +20 -0
  152. package/_internal/ui/patterns/segmented-control.d.ts +22 -0
  153. package/_internal/ui/patterns/sortable-head.d.ts +13 -0
  154. package/_internal/ui/patterns/stat-group.d.ts +8 -0
  155. package/_internal/ui/patterns/stat-tile.d.ts +25 -0
  156. package/_internal/ui/patterns/status-badge.d.ts +15 -0
  157. package/_internal/ui/patterns/status-marker.d.ts +10 -0
  158. package/_internal/ui/patterns/timeline.d.ts +59 -0
  159. package/_internal/ui/patterns/unsaved-changes-dialog.d.ts +22 -0
  160. package/_internal/ui/patterns/workspace-page.d.ts +76 -0
  161. package/_internal/ui/primitives/alert.d.ts +17 -0
  162. package/_internal/ui/primitives/avatar.d.ts +13 -0
  163. package/_internal/ui/primitives/badge.d.ts +27 -0
  164. package/_internal/ui/primitives/button.d.ts +32 -0
  165. package/_internal/ui/primitives/card.d.ts +55 -0
  166. package/_internal/ui/primitives/checkbox.d.ts +3 -0
  167. package/_internal/ui/primitives/collapsible.d.ts +7 -0
  168. package/_internal/ui/primitives/color-input.d.ts +21 -0
  169. package/_internal/ui/primitives/combobox.d.ts +40 -0
  170. package/_internal/ui/primitives/command.d.ts +36 -0
  171. package/_internal/ui/primitives/control-styles.d.ts +10 -0
  172. package/_internal/ui/primitives/dialog.d.ts +31 -0
  173. package/_internal/ui/primitives/dropdown-menu.d.ts +54 -0
  174. package/_internal/ui/primitives/file-input.d.ts +33 -0
  175. package/_internal/ui/primitives/input-group.d.ts +30 -0
  176. package/_internal/ui/primitives/input.d.ts +10 -0
  177. package/_internal/ui/primitives/interactive-surface.d.ts +24 -0
  178. package/_internal/ui/primitives/label.d.ts +3 -0
  179. package/_internal/ui/primitives/modal-context.d.ts +9 -0
  180. package/_internal/ui/primitives/option-list.d.ts +10 -0
  181. package/_internal/ui/primitives/popover.d.ts +18 -0
  182. package/_internal/ui/primitives/portal-ownership.d.ts +11 -0
  183. package/_internal/ui/primitives/progress.d.ts +38 -0
  184. package/_internal/ui/primitives/radio-group.d.ts +12 -0
  185. package/_internal/ui/primitives/select.d.ts +35 -0
  186. package/_internal/ui/primitives/separator.d.ts +7 -0
  187. package/_internal/ui/primitives/sheet.d.ts +34 -0
  188. package/_internal/ui/primitives/shimmer-text.d.ts +13 -0
  189. package/_internal/ui/primitives/skeleton.d.ts +6 -0
  190. package/_internal/ui/primitives/spinner.d.ts +31 -0
  191. package/_internal/ui/primitives/switch.d.ts +6 -0
  192. package/_internal/{app/components/ui → ui/primitives}/tabs.d.ts +1 -1
  193. package/_internal/ui/primitives/text.d.ts +43 -0
  194. package/_internal/ui/primitives/textarea.d.ts +19 -0
  195. package/_internal/ui/primitives/tooltip.d.ts +14 -0
  196. package/_internal/ui/primitives/use-textarea-autosize.d.ts +3 -0
  197. package/_internal/ui/private-ui-boundary-probe.d.ts +9 -0
  198. package/_internal/ui/states/banner.d.ts +15 -0
  199. package/_internal/ui/states/index.d.ts +6 -0
  200. package/_internal/ui/states/system-state.d.ts +88 -0
  201. package/_internal/ui/states/toast.d.ts +26 -0
  202. package/_internal/ui/utils.d.ts +14 -0
  203. package/bin/bakin-plugin-test-ui.js +6854 -0
  204. package/charts/index.d.ts +3 -0
  205. package/charts/index.js +2 -0
  206. package/content/index.d.ts +14 -0
  207. package/content/index.js +38 -0
  208. package/content/markdown-comparison.d.ts +12 -0
  209. package/content/markdown-content.d.ts +18 -0
  210. package/content/markdown-document.d.ts +4 -0
  211. package/content/markdown-editor.d.ts +35 -0
  212. package/conversation/index.d.ts +50 -0
  213. package/conversation/index.js +4 -0
  214. package/conversation/use-conversation-thread.d.ts +73 -0
  215. package/hooks/index.d.ts +86 -11
  216. package/hooks/index.js +1 -1747
  217. package/hooks/router.d.ts +4 -36
  218. package/index.d.ts +30 -6
  219. package/index.js +10 -14210
  220. package/internal/index.d.ts +74 -0
  221. package/internal/index.js +2 -0
  222. package/internal/lazy.d.ts +58 -0
  223. package/internal/plugin-ownership.d.ts +18 -0
  224. package/internal/private-ui-boundary-probe.d.ts +2 -0
  225. package/layout/index.d.ts +9 -0
  226. package/layout/index.js +2 -0
  227. package/metadata/index.d.ts +14 -1
  228. package/metadata/index.js +1 -30
  229. package/navigation/history-back.d.ts +5 -0
  230. package/navigation/index.d.ts +23 -0
  231. package/navigation/index.js +2 -0
  232. package/navigation/plugin-link.d.ts +11 -0
  233. package/navigation/query-state.d.ts +7 -0
  234. package/navigation/router.d.ts +35 -0
  235. package/navigation/search-params.d.ts +7 -0
  236. package/navigation/unsaved-changes-guard.d.ts +35 -0
  237. package/package.json +63 -10
  238. package/patterns/agent-patterns.d.ts +81 -0
  239. package/patterns/asset-library-picker.d.ts +38 -0
  240. package/patterns/channel-patterns.d.ts +32 -0
  241. package/patterns/index.d.ts +40 -0
  242. package/patterns/index.js +47 -0
  243. package/patterns/picker-patterns.d.ts +108 -0
  244. package/patterns/plugin-settings-renderer.d.ts +41 -0
  245. package/patterns/presentation-color.d.ts +2 -0
  246. package/patterns/search-patterns.d.ts +51 -0
  247. package/register.d.ts +63 -9
  248. package/routing/index.d.ts +6 -1
  249. package/routing/index.js +10 -14014
  250. package/slots/index.d.ts +12 -24
  251. package/slots/index.js +1 -91
  252. package/slots/registry.d.ts +45 -0
  253. package/styles.css +2 -0
  254. package/testing/index.d.ts +122 -0
  255. package/testing/index.js +93 -0
  256. package/testing/ui/conformance/cli.d.ts +2 -0
  257. package/testing/ui/conformance/contracts.d.ts +73 -0
  258. package/testing/ui/conformance/index.d.ts +11 -0
  259. package/testing/ui/conformance/index.js +85 -0
  260. package/testing/ui/conformance/plugin-css.d.ts +37 -0
  261. package/testing/ui/conformance/plugin-id.d.ts +6 -0
  262. package/testing/ui/conformance/runner.d.ts +13 -0
  263. package/testing/ui/index.d.ts +24 -0
  264. package/testing/ui/index.js +2 -0
  265. package/testing/ui/plugin-ui-fixture-host.d.ts +36 -0
  266. package/testing/ui/runtime.d.ts +70 -0
  267. package/types/api-route.d.ts +89 -0
  268. package/types/context.d.ts +166 -0
  269. package/types/conversation-turns.d.ts +229 -0
  270. package/types/events.d.ts +10 -0
  271. package/types/health.d.ts +376 -0
  272. package/types/index.d.ts +19 -919
  273. package/types/index.js +1 -0
  274. package/types/manifest.d.ts +255 -0
  275. package/types/primitives.d.ts +33 -0
  276. package/types/registration.d.ts +281 -0
  277. package/types/runtime.d.ts +292 -0
  278. package/types/scheduled-events.d.ts +80 -0
  279. package/types/services.d.ts +599 -0
  280. package/ui/index.d.ts +73 -31
  281. package/ui/index.js +38 -28704
  282. package/utils/asset-id.d.ts +15 -0
  283. package/utils/index.d.ts +27 -7
  284. package/utils/index.js +4 -2098
  285. package/utils/plugin-fetch.d.ts +44 -0
  286. package/_internal/app/components/agent-filter.d.ts +0 -8
  287. package/_internal/app/components/agent-select.d.ts +0 -15
  288. package/_internal/app/components/agent-status.d.ts +0 -8
  289. package/_internal/app/components/bakin-drawer.d.ts +0 -23
  290. package/_internal/app/components/color-picker.d.ts +0 -7
  291. package/_internal/app/components/empty-state.d.ts +0 -10
  292. package/_internal/app/components/error-banner.d.ts +0 -6
  293. package/_internal/app/components/error-state.d.ts +0 -8
  294. package/_internal/app/components/facet-filter.d.ts +0 -17
  295. package/_internal/app/components/integrated-brainstorm/activity.d.ts +0 -23
  296. package/_internal/app/components/integrated-brainstorm/collapsed-header.d.ts +0 -14
  297. package/_internal/app/components/integrated-brainstorm/empty-state.d.ts +0 -5
  298. package/_internal/app/components/integrated-brainstorm/index.d.ts +0 -8
  299. package/_internal/app/components/integrated-brainstorm/input-row.d.ts +0 -16
  300. package/_internal/app/components/integrated-brainstorm/message-list.d.ts +0 -8
  301. package/_internal/app/components/integrated-brainstorm/session.d.ts +0 -16
  302. package/_internal/app/components/integrated-brainstorm/sse.d.ts +0 -8
  303. package/_internal/app/components/integrated-brainstorm/thinking-indicator.d.ts +0 -19
  304. package/_internal/app/components/integrated-brainstorm/types.d.ts +0 -63
  305. package/_internal/app/components/integrated-brainstorm/use-auto-grow.d.ts +0 -6
  306. package/_internal/app/components/integrated-brainstorm/use-brainstorm-state.d.ts +0 -21
  307. package/_internal/app/components/markdown-content.d.ts +0 -3
  308. package/_internal/app/components/markdown-editor.d.ts +0 -11
  309. package/_internal/app/components/model-select.d.ts +0 -9
  310. package/_internal/app/components/page-layout.d.ts +0 -9
  311. package/_internal/app/components/plugin-header.d.ts +0 -16
  312. package/_internal/app/components/plugin-settings-renderer.d.ts +0 -9
  313. package/_internal/app/components/sortable-head.d.ts +0 -13
  314. package/_internal/app/components/ui/alert.d.ts +0 -10
  315. package/_internal/app/components/ui/avatar.d.ts +0 -11
  316. package/_internal/app/components/ui/badge.d.ts +0 -7
  317. package/_internal/app/components/ui/card.d.ts +0 -11
  318. package/_internal/app/components/ui/checkbox.d.ts +0 -3
  319. package/_internal/app/components/ui/collapsible.d.ts +0 -5
  320. package/_internal/app/components/ui/command.d.ts +0 -19
  321. package/_internal/app/components/ui/dropdown-menu.d.ts +0 -29
  322. package/_internal/app/components/ui/form.d.ts +0 -23
  323. package/_internal/app/components/ui/input-group.d.ts +0 -18
  324. package/_internal/app/components/ui/input.d.ts +0 -3
  325. package/_internal/app/components/ui/label.d.ts +0 -3
  326. package/_internal/app/components/ui/popover.d.ts +0 -9
  327. package/_internal/app/components/ui/progress.d.ts +0 -7
  328. package/_internal/app/components/ui/select.d.ts +0 -15
  329. package/_internal/app/components/ui/separator.d.ts +0 -3
  330. package/_internal/app/components/ui/skeleton.d.ts +0 -2
  331. package/_internal/app/components/ui/switch.d.ts +0 -5
  332. package/_internal/app/components/ui/textarea.d.ts +0 -3
  333. package/_internal/app/components/ui/tooltip.d.ts +0 -6
  334. package/_internal/app/components/underline-tabs.d.ts +0 -15
  335. package/_internal/app/hooks/use-assets.d.ts +0 -25
  336. package/_internal/app/hooks/use-form-guard.d.ts +0 -5
  337. package/_internal/app/hooks/use-vertical-resize.d.ts +0 -22
  338. package/_internal/app/lib/utils.d.ts +0 -2
  339. package/_internal/plugins/workflows/hooks/channel-icon.d.ts +0 -6
  340. package/components/index.d.ts +0 -34
  341. package/components/index.js +0 -40175
  342. /package/_internal/{app/components/ui → ui/primitives}/table.d.ts +0 -0
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Typed runtime-failure contracts crossing the adapter boundary.
3
+ *
4
+ * Adapters map every provider failure to a `RuntimeError` with a structural
5
+ * `kind` before it leaves the adapter package. Core (dispatch) classifies on
6
+ * `kind` exclusively — never on error-message text. The original provider
7
+ * error is always preserved on `cause` so transport-level codes
8
+ * (ECONNRESET, AbortError, …) survive the boundary for logging/diagnostics.
9
+ */
10
+ export type RuntimeErrorKind =
11
+ /** Socket drop, disconnect, not-connected, fetch failure — transient. */
12
+ 'transport'
13
+ /** An RPC/transport timer fired without a final response. */
14
+ | 'timeout'
15
+ /** The provider session died mid-turn; carries a RuntimeTurnDiagnosis. */
16
+ | 'session_death'
17
+ /** Provider/auth cooldown — model provider unavailable, retry later. */
18
+ | 'provider_cooldown'
19
+ /** Structured runtime failure (HTTP-status class, CLI exit, protocol). */
20
+ | 'runtime_failed'
21
+ /**
22
+ * The provider deterministically rejected the MODEL ID for this account
23
+ * (retired/unentitled model — the #852 class). Not a cooldown: waiting
24
+ * never fixes it, so it is never retried. `providerInfo.model` carries the
25
+ * qualified rejected id; core records it as availability evidence.
26
+ */
27
+ | 'model_not_supported'
28
+ /**
29
+ * The caller intentionally cancelled the turn (MessageArgs.signal) —
30
+ * terminal: never retried, never diagnosed, never enters the recovery
31
+ * ladder.
32
+ */
33
+ | 'aborted'
34
+ /**
35
+ * A CRUD mutation addressed an entity (agent, skill, cron job) that does
36
+ * not exist on the runtime. Reads return `null` for absence; only
37
+ * mutations reject with this kind (R28).
38
+ */
39
+ | 'not_found';
40
+ /**
41
+ * Structured provider metadata for `provider_cooldown` failures, extracted by
42
+ * the adapter from provider-specific error payloads so core never parses
43
+ * provider strings.
44
+ */
45
+ export interface RuntimeProviderInfo {
46
+ provider?: string;
47
+ model?: string;
48
+ /** e.g. 'timeout' when the provider entered cooldown after a timeout. */
49
+ cooldownReason?: string;
50
+ /** No auth profile was available (vs. an active profile in cooldown). */
51
+ authProfileUnavailable?: boolean;
52
+ }
53
+ export interface RuntimeErrorOptions {
54
+ kind: RuntimeErrorKind;
55
+ cause?: unknown;
56
+ providerInfo?: RuntimeProviderInfo;
57
+ }
58
+ export declare class RuntimeError extends Error {
59
+ readonly kind: RuntimeErrorKind;
60
+ readonly providerInfo?: RuntimeProviderInfo;
61
+ constructor(message: string, options: RuntimeErrorOptions);
62
+ }
63
+ export type RuntimeTurnFailureReason =
64
+ /** session.ended with a non-success status that was not a runtime timeout. */
65
+ 'session_interrupted'
66
+ /** The session/turn genuinely timed out server-side. */
67
+ | 'runtime_timeout';
68
+ /**
69
+ * Post-mortem of a dead provider turn, assembled entirely inside the runtime
70
+ * adapter (Bakin core never reads provider files). Every field is optional
71
+ * evidence — a partial diagnosis is still more useful than a generic timeout.
72
+ */
73
+ export interface RuntimeTurnDiagnosis {
74
+ reason: RuntimeTurnFailureReason;
75
+ /** Provider session id the turn ran in. */
76
+ sessionId?: string;
77
+ /** Raw provider session end status, e.g. 'interrupted'. */
78
+ sessionStatus?: string;
79
+ /** Provider-reported timeout flag from the session end event. */
80
+ timedOut?: boolean;
81
+ /** Total bytes of the final assistant output that killed the turn. */
82
+ completionBytes?: number;
83
+ /** Provider truncated the recorded completion (trajectory size limit). */
84
+ outputTruncated?: boolean;
85
+ /** completionBytes exceeded the configured oversized-output threshold. */
86
+ oversizedOutput?: boolean;
87
+ /** Last tool the agent invoked before the turn died. */
88
+ lastToolCall?: string;
89
+ /** Truncated completion text preserved for salvage (capped by the adapter). */
90
+ salvagedText?: string;
91
+ /** Token usage recorded for the fatal completion, when available. */
92
+ usage?: {
93
+ input?: number;
94
+ output?: number;
95
+ total?: number;
96
+ };
97
+ /** One-line human-readable diagnosis. */
98
+ detail?: string;
99
+ }
100
+ export declare class RuntimeTurnError extends RuntimeError {
101
+ readonly diagnosis: RuntimeTurnDiagnosis;
102
+ constructor(diagnosis: RuntimeTurnDiagnosis, options?: {
103
+ cause?: unknown;
104
+ });
105
+ }
@@ -1,5 +1,24 @@
1
1
  import type { AgentRuntimeAdapter, RuntimeAgent } from './concepts';
2
+ /**
3
+ * Resolve the runtime's ORCHESTRATOR from its roster (P2.6) — a
4
+ * runtime-declared fact, never a baked constant. Ladder:
5
+ *
6
+ * 1. id 'main' — the declared-id convention both adapters seed.
7
+ * 2. role 'orchestrator' — the declared-role generalization: a runtime
8
+ * whose orchestrator has a different id resolves here.
9
+ * 3. first agent — degraded last resort so single-agent rosters
10
+ * always resolve.
11
+ *
12
+ * The id rung leads deliberately: role text is fuzzy (OpenClaw derives it
13
+ * from IDENTITY.md, which agent packages can set) — an installed persona
14
+ * claiming "Orchestrator" must never outrank the declared main agent.
15
+ */
2
16
  export declare function selectRuntimeMainAgent(agents: RuntimeAgent[]): RuntimeAgent | null;
3
17
  export declare function getRuntimeMainAgent(runtime: AgentRuntimeAdapter): Promise<RuntimeAgent | null>;
18
+ /**
19
+ * Resolved orchestrator id. The `fallback` applies ONLY to an empty/unreadable
20
+ * roster (degraded mode: runtime down mid-flight) — callers that can degrade
21
+ * differently should pass their own.
22
+ */
4
23
  export declare function getRuntimeMainAgentId(runtime: AgentRuntimeAdapter, fallback?: string): Promise<string>;
5
24
  export declare function getRuntimeMainAgentName(runtime: AgentRuntimeAdapter, fallback?: string): Promise<string>;
@@ -1,5 +1,11 @@
1
- export type { AdapterAuditEvent, AdapterHealthCheckDefinition, AdapterHealthCheckResult, AdapterInitOpts, AdapterLogger, Unsubscribe, } from '../shared';
1
+ export type { AdapterAuditEvent, AdapterInitOpts, AdapterLogger, AdapterToolActivityEvent, AdapterTurnActivityEvent, RuntimeExecToolDescriptor, RuntimeExecToolInvokeResult, RuntimeExecToolProvider, Unsubscribe, } from '../shared';
2
+ export { beginAdapterTurnActivity } from './turn-activity';
3
+ export type { AdapterTurnActivityReporter, BeginAdapterTurnActivityOptions } from './turn-activity';
2
4
  export type { ChannelCapability } from './capabilities';
3
5
  export { hasChannelCapability } from './capabilities';
6
+ export { RuntimeError, RuntimeTurnError } from './errors';
7
+ export type { RuntimeErrorKind, RuntimeErrorOptions, RuntimeProviderInfo, RuntimeTurnDiagnosis, RuntimeTurnFailureReason, } from './errors';
4
8
  export { getRuntimeMainAgent, getRuntimeMainAgentId, getRuntimeMainAgentName, selectRuntimeMainAgent, } from './helpers';
5
- export type { AgentRuntimeAdapter, ApprovalDelivery, ApprovalOption, ApprovalPatch, ApprovalRenderRef, ApprovalRenderResult, ApprovalResolveEvent, ApprovalResponse, CancelApprovalArgs, ChannelInfo, ChannelInteractionEvent, ChannelMessageArgs, ChannelMessageEvent, ChatChunk, ContentDeliveryArgs, CreateApprovalArgs, CreateCronJobInput, CreateRuntimeAgentInput, CronJob, CronRun, DeliveryResult, DurableApprovalRecord, EditApprovalArgs, ListExecutionsOpts, MessageArgs, MessageResult, NotificationArgs, ResolveApprovalArgs, RuntimeAgent, RuntimeAllowlistPatch, RuntimeToolActivity, RuntimeAvailableModel, RuntimeConfigAccess, RuntimeMemoryEntry, RuntimeMemoryEntryStat, RuntimeMemoryPathMatch, RuntimeMemoryReadRange, RuntimeMemorySearchResult, RuntimeMemoryTier, RuntimeMessageToolPolicy, RuntimeMessageToolsMode, RuntimeMetadata, RuntimePermissionPatch, RawCronSnapshot, RuntimeSession, RuntimeSkill, TaskDispatchArgs, TaskDispatchResult, TaskExecutionEvent, TaskExecutionStatus, ToolDefinition, ToolResult, UpdateCronJobInput, UpdateRuntimeAgentInput, WorkspaceFile, } from './concepts';
9
+ export type { AgentRuntimeAdapter, ApprovalDelivery, ApprovalOption, ApprovalPatch, ApprovalRenderRef, ApprovalRenderResult, ApprovalResolveEvent, ApprovalResponse, CancelApprovalArgs, ChannelInfo, ChannelMessageArgs, ChatChunk, ChatTextFormat, ContentDeliveryArgs, CreateApprovalArgs, CreateThreadArgs, CreatedThread, CreateCronJobInput, CreateRuntimeAgentInput, CronJob, CronRun, DeliveryResult, DurableApprovalRecord, EditApprovalArgs, EditChannelMessageArgs, InboundChannelAttachment, InboundChannelMessage, MessageArgs, MessageAttachment, MessageResult, MessageUsage, NotificationArgs, ResolveApprovalArgs, RuntimeAgent, RuntimeAllowlistPatch, RuntimeToolActivity, RuntimeAvailableModel, RuntimeCapabilities, CapabilityMode, ToolAccessStyle, RuntimeToolAccess, ToolAccessProvisioningStatus, RuntimeCredentialStatus, ProviderCredentialStatus, ProviderCredentialInventory, RuntimeConfigChangeKind, RestartAdvice, RuntimeRoutingPolicy, RuntimeRoutingSupport, CapabilitySet, RuntimeImageBackground, RuntimeImageEditInput, RuntimeImageFile, RuntimeImageGenerateInput, RuntimeImageGenerationResult, RuntimeImageOutputFormat, RuntimeImageProvider, RuntimeImageProviderCapabilities, RuntimeImagesAccess, RuntimeExtensionInfo, RuntimeExtensionsAccess, RuntimeMemoryEntry, RuntimeMemoryEntryStat, RuntimeMemoryPathMatch, RuntimeMemoryReadRange, RuntimeMemorySearchResult, RuntimeMemoryTier, RuntimeMessageToolPolicy, RuntimeMessageToolsMode, RuntimeMetadata, RawCronSnapshot, RuntimeSession, RuntimeSessionStoreStats, RuntimeSessionContextStats, RuntimeSkill, UpdateCronJobInput, UpdateRuntimeAgentInput, WorkspaceFile, WorkspaceFileStat, } from './concepts';
10
+ export { RUNTIME_MEDIA_URI_SCHEME, DEFAULT_OVERSIZED_OUTPUT_BYTES } from './concepts';
11
+ export { isSafeSkillFilePath, isExecutableSkillFile, readSkillTree, SKILL_SIDECAR_NAMES } from './skill-files';
@@ -0,0 +1,12 @@
1
+ /** Relative path inside a skill dir: no absolute, no backslash, no `..`/empty segments. */
2
+ export declare function isSafeSkillFilePath(path: string): boolean;
3
+ /** Metadata sidecars — never part of a skill's file map. */
4
+ export declare const SKILL_SIDECAR_NAMES: Set<string>;
5
+ /** Scripts get the executable bit at projection: shebang or a script extension. */
6
+ export declare function isExecutableSkillFile(path: string, content: string): boolean;
7
+ /**
8
+ * Read a skill directory into a relative-path→content map, skipping
9
+ * symlinks and the metadata sidecars (`.installedBy`/`.userEdited`) at any
10
+ * depth. Unreadable roots read as empty.
11
+ */
12
+ export declare function readSkillTree(root: string): Record<string, string>;
@@ -0,0 +1,99 @@
1
+ import type { AgentRuntimeAdapter, ProviderCredentialStatus, RestartAdvice } from './concepts';
2
+ /**
3
+ * Opt-in channels surface for the mock (delivery capability pairs with it —
4
+ * see createMockRuntimeAdapter). The DEFAULT mock omits `channels` entirely:
5
+ * it is an optional contract member (Pi omits it in production), so plugin
6
+ * code must feature-detect. A bare `runtime.channels.x()` against the default
7
+ * mock now throws instead of silently passing (audit finding H2).
8
+ *
9
+ * Usage: `createMockRuntimeAdapter({ channels: mockChannels() })`
10
+ */
11
+ export declare function mockChannels(): NonNullable<AgentRuntimeAdapter['channels']>;
12
+ /**
13
+ * Opt-in status-only credential inventory for the mock (#907 / #378 slice).
14
+ * `credentials` is an optional contract member, so the DEFAULT mock omits
15
+ * it — eligibility code must feature-detect and treat absence as
16
+ * "credential evidence unavailable" (models read `unknown`, never
17
+ * `ineligible`). Pass `evidence: 'partial'` to exercise the honest-partial
18
+ * branch (OpenClaw's CLI probe failing).
19
+ *
20
+ * Usage: `createMockRuntimeAdapter({ credentials: mockCredentials([{ providerId: 'mock', configured: true }]) })`
21
+ */
22
+ export declare function mockCredentials(providers?: ProviderCredentialStatus[], evidence?: 'complete' | 'partial'): NonNullable<AgentRuntimeAdapter['credentials']>;
23
+ /**
24
+ * Opt-in restart advice for the mock (#878). Optional member; the default
25
+ * mock omits it so the Models banner's generic-fallback path is what mock
26
+ * consumers see unless they opt in. The same advice is returned for every
27
+ * change kind unless a per-kind map is given.
28
+ *
29
+ * Usage: `createMockRuntimeAdapter({ restartAdvice: mockRestartAdvice({ needed: false }) })`
30
+ */
31
+ export declare function mockRestartAdvice(advice: RestartAdvice | Partial<Record<'model-config' | 'roster' | 'routing-policy', RestartAdvice>>): NonNullable<AgentRuntimeAdapter['restartAdvice']>;
32
+ /**
33
+ * Opt-in cron surface for the mock — same rationale as mockChannels():
34
+ * `cron` is an optional contract member (Pi omits it), so the default mock
35
+ * omits it and consumers feature-detect.
36
+ *
37
+ * Usage: `createMockRuntimeAdapter({ cron: mockCron() })`
38
+ */
39
+ /**
40
+ * Filename the isolation-honoring mock drops into each turn's runWorkspace —
41
+ * the conformance isolation probe's observable (same-agent-concurrency D1).
42
+ */
43
+ export declare const MOCK_ISOLATION_PROBE = "cwd-probe.txt";
44
+ /**
45
+ * Opt-in same-agent-turn isolation for the mock: declares
46
+ * `concurrency.sameAgentTurns: 'isolated'` and honors
47
+ * `MessageArgs.runWorkspace` by dropping MOCK_ISOLATION_PROBE into the
48
+ * handed directory before delegating — the minimal observable proof the
49
+ * conformance isolation check requires. The DEFAULT mock stays
50
+ * 'serialized' (minimal shape).
51
+ *
52
+ * Usage: `withMockIsolation(createMockRuntimeAdapter())`
53
+ */
54
+ export declare function withMockIsolation(base: AgentRuntimeAdapter): AgentRuntimeAdapter;
55
+ export declare function mockCron(): NonNullable<AgentRuntimeAdapter['cron']>;
56
+ export declare function createMockRuntimeAdapter(overrides?: Partial<AgentRuntimeAdapter>): AgentRuntimeAdapter;
57
+ /**
58
+ * Opt-in image-input capability override for attachment tests:
59
+ * `createMockRuntimeAdapter({ capabilities: mockImageInputCapabilities() })`.
60
+ * The default mock declares `imageInput: false` (minimal shape); streams
61
+ * still echo attachments in the reply text so pass-through is assertable
62
+ * either way.
63
+ */
64
+ export declare function mockImageInputCapabilities(): (opts?: {
65
+ agentId?: string;
66
+ }) => Promise<ReturnType<typeof mockCapabilities>>;
67
+ declare function mockCapabilities(deliveryNative: boolean): {
68
+ toolCalling: {
69
+ mode: "native";
70
+ access: {
71
+ style: "mcp";
72
+ mcpServerTemplate: string;
73
+ perTurnExecToolFiltering: boolean;
74
+ };
75
+ };
76
+ delivery: {
77
+ mode: "unavailable" | "native";
78
+ };
79
+ imageGen: {
80
+ mode: "unavailable";
81
+ };
82
+ memory: {
83
+ mode: "native";
84
+ };
85
+ sessions: {
86
+ mode: "native";
87
+ };
88
+ workspaceFiles: {
89
+ mode: "native";
90
+ };
91
+ input: {
92
+ imageInput: boolean;
93
+ audioInput: boolean;
94
+ };
95
+ concurrency: {
96
+ sameAgentTurns: "serialized";
97
+ };
98
+ };
99
+ export {};
@@ -0,0 +1,23 @@
1
+ import type { AdapterTurnActivityEvent } from '../shared';
2
+ type TurnResultEvent = Extract<AdapterTurnActivityEvent, {
3
+ phase: 'result';
4
+ }>;
5
+ export interface AdapterTurnActivityReporter {
6
+ readonly turnId: string;
7
+ finish(result: Pick<TurnResultEvent, 'status'> & Partial<Pick<TurnResultEvent, 'resultId' | 'usage'>>): void;
8
+ }
9
+ export interface BeginAdapterTurnActivityOptions {
10
+ onActivity?: (event: AdapterTurnActivityEvent) => void;
11
+ onCallbackError?: (error: unknown) => void;
12
+ agentId: string;
13
+ activityClass: AdapterTurnActivityEvent['activityClass'];
14
+ threadId?: string;
15
+ operation: AdapterTurnActivityEvent['operation'];
16
+ }
17
+ /**
18
+ * Start one adapter messaging lifecycle and return its exactly-once finisher.
19
+ * Both the observer and its error reporter are contained: observability is
20
+ * never allowed to change a turn's outcome.
21
+ */
22
+ export declare function beginAdapterTurnActivity(options: BeginAdapterTurnActivityOptions): AdapterTurnActivityReporter;
23
+ export {};
@@ -1,3 +1,5 @@
1
+ import type { ActivityClass } from '@makinbakin/sdk/types';
2
+ import type { ChannelBridge } from '../delivery/bridge';
1
3
  export type Unsubscribe = () => void;
2
4
  export interface AdapterLogger {
3
5
  debug(message: string, data?: unknown): void;
@@ -12,26 +14,145 @@ export interface AdapterAuditEvent {
12
14
  data?: Record<string, unknown>;
13
15
  at?: string;
14
16
  }
17
+ /**
18
+ * One Bakin exec tool as offered across the adapter boundary. The zod
19
+ * shapes stay core-side; adapters receive plain JSON Schema so no
20
+ * validation library leaks into the contract.
21
+ */
22
+ export interface RuntimeExecToolDescriptor {
23
+ name: string;
24
+ description: string;
25
+ /** JSON Schema (object) for the tool's parameters. */
26
+ parametersSchema: Record<string, unknown>;
27
+ }
28
+ export interface RuntimeExecToolInvokeResult {
29
+ ok: boolean;
30
+ /** Model-facing result text (JSON on success, `ERROR: …` on failure). */
31
+ text: string;
32
+ }
33
+ /** Token usage for one agent turn, when the runtime reports it. */
34
+ export interface MessageUsage {
35
+ input?: number;
36
+ output?: number;
37
+ total?: number;
38
+ /** Cached-input tokens read (priced far below fresh input when known). */
39
+ cacheRead?: number;
40
+ /** Cached-input tokens written (cache creation). */
41
+ cacheWrite?: number;
42
+ /** Resolved model the runtime ran, when known. */
43
+ model?: string;
44
+ }
45
+ /**
46
+ * One normalized runtime-native tool lifecycle event observed by an adapter.
47
+ * The host uses result events for cross-runtime observability; call events are
48
+ * included so it can derive duration when the runtime does not report one.
49
+ */
50
+ interface AdapterToolActivityBase {
51
+ agentId: string;
52
+ /** Producer-assigned classification from the originating runtime turn. */
53
+ activityClass: ActivityClass;
54
+ /** Owning adapter turn; required so terminal reconciliation cannot silently opt out. */
55
+ turnId: string;
56
+ threadId?: string;
57
+ callId?: string;
58
+ toolName: string;
59
+ }
60
+ /**
61
+ * One normalized tool lifecycle event. Runtime-private status aliases must be
62
+ * resolved by the adapter before crossing this boundary.
63
+ */
64
+ export type AdapterToolActivityEvent = AdapterToolActivityBase & {
65
+ phase: 'call';
66
+ status: 'running';
67
+ } | AdapterToolActivityBase & {
68
+ phase: 'result';
69
+ status: 'completed' | 'failed' | 'aborted';
70
+ durationMs?: number;
71
+ };
72
+ interface AdapterTurnActivityBase {
73
+ agentId: string;
74
+ /** Producer-assigned classification from the originating runtime turn. */
75
+ activityClass: ActivityClass;
76
+ threadId?: string;
77
+ /** Messaging surface that owns the turn. */
78
+ operation: 'send' | 'stream';
79
+ /** Adapter-generated identity shared by this turn's start and result. */
80
+ turnId: string;
81
+ }
82
+ /**
83
+ * One normalized messaging turn lifecycle event observed at the adapter
84
+ * boundary. Every executed send/stream emits exactly one start and one result.
85
+ * Result identity and usage are present when the messaging surface reports
86
+ * them (currently send); adapters never fabricate usage.
87
+ */
88
+ export type AdapterTurnActivityEvent = AdapterTurnActivityBase & {
89
+ phase: 'start';
90
+ status: 'running';
91
+ } | AdapterTurnActivityBase & {
92
+ phase: 'result';
93
+ status: 'completed' | 'failed' | 'aborted';
94
+ durationMs: number;
95
+ resultId?: string;
96
+ usage?: MessageUsage;
97
+ };
98
+ /**
99
+ * Bakin's exec-tool registry offered to runtimes that deliver tools
100
+ * in-process (Pi registers these as native session tools). Out-of-band
101
+ * runtimes (OpenClaw reaches the same registry over its native MCP client)
102
+ * ignore it. `list()` reads the LIVE registry — call it at session build
103
+ * time so late plugin registrations and hot reloads are visible.
104
+ * Usage recording + audit happen inside `invoke`; adapters add nothing.
105
+ */
106
+ export interface RuntimeExecToolProvider {
107
+ list(): RuntimeExecToolDescriptor[];
108
+ invoke(name: string, params: Record<string, unknown>, agentId: string): Promise<RuntimeExecToolInvokeResult>;
109
+ }
15
110
  export interface AdapterInitOpts {
16
111
  contentDir: string;
112
+ /**
113
+ * Optional runtime-neutral channel bridge (issue #669). Runtimes without a
114
+ * native delivery layer (Pi) expose `runtime.channels` by delegating to
115
+ * this handle when `isConfigured()`; natively-delivering runtimes ignore
116
+ * it. This is a HANDLE only — the server owns `boot()`/`shutdown()`;
117
+ * adapters never connect transports.
118
+ */
119
+ channelBridge?: ChannelBridge;
17
120
  settings?: Record<string, unknown>;
121
+ /**
122
+ * LIVE view of the adapter-private settings bag. `settings` is a boot-time
123
+ * snapshot; surfaces whose behavior must track settings edits WITHOUT a
124
+ * restart (extension trust policy, per-turn knobs) read through this.
125
+ * Optional: tests and thin callers may omit it (snapshot semantics).
126
+ */
127
+ getLiveSettings?: () => Record<string, unknown> | undefined;
18
128
  logger?: AdapterLogger;
19
129
  audit?: (event: AdapterAuditEvent) => void;
20
- }
21
- export interface AdapterHealthCheckResult {
22
- check: string;
23
- status: 'ok' | 'warn' | 'error' | 'fixed';
24
- message: string;
25
- autoFixable: boolean;
26
- }
27
- export interface AdapterHealthCheckDefinition {
28
- id: string;
29
- name: string;
30
- run(): Promise<AdapterHealthCheckResult[]>;
31
- autoFix?: boolean;
130
+ execTools?: RuntimeExecToolProvider;
131
+ /**
132
+ * Best-effort host observability tap for tool activity across every runtime
133
+ * messaging surface. Adapters contain callback failures so telemetry can
134
+ * never fail an agent turn.
135
+ */
136
+ onToolActivity?: (event: AdapterToolActivityEvent) => void;
137
+ /**
138
+ * Best-effort host observability tap for every messaging send/stream turn.
139
+ * Adapters contain callback failures so telemetry can never fail a turn.
140
+ */
141
+ onTurnActivity?: (event: AdapterTurnActivityEvent) => void;
142
+ /**
143
+ * Base URL of Bakin's MCP server (e.g. `http://localhost:3737`) — the seam
144
+ * a runtime whose agents reach Bakin over MCP (OpenClaw) needs to write its
145
+ * per-agent server entries during `provisionToolAccess`. Core knows the
146
+ * port; the adapter does not, so it is threaded here. In-process runtimes
147
+ * (Pi) ignore it.
148
+ */
149
+ bakinMcpBaseUrl?: string;
150
+ /** Host-issued credential scoped to a single agent; never log this value. */
151
+ getMcpCredential?: (agentId: string) => string;
32
152
  }
33
153
  export interface AdapterVersionInfo {
34
154
  readonly name: string;
35
155
  readonly version: string;
36
156
  readonly requiredCoreVersion?: string;
37
157
  }
158
+ export {};
@@ -28,8 +28,19 @@ export interface BakinPaths {
28
28
  inbox: string;
29
29
  tasks: string;
30
30
  workflows: string;
31
+ /** Brand records — per-brand dirs with manifest + guidelines + lessons (#419). */
32
+ brands: string;
33
+ /** Chat plugin transcripts + index (Bakin-owned UI data). */
34
+ chat: string;
31
35
  settings: string;
32
36
  logs: string;
37
+ /** Data dir for Bakin's private antfly instance (created on demand by the adapter). */
38
+ antfly: string;
39
+ db: string;
40
+ /** Bakin-owned bin dir for capability-pack binaries; prepended to PATH at server boot. */
41
+ bin: string;
42
+ /** Media prebuild store (sharp for compiled binaries, #889) — versioned dirs + receipt. */
43
+ media: string;
33
44
  }
34
45
  export declare function getBakinPaths(): BakinPaths;
35
46
  /**
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Runtime-neutral channel bridge contract (issue #669).
3
+ *
4
+ * A ChannelBridge gives a runtime WITHOUT a native channel/delivery layer
5
+ * (Pi) a `runtime.channels` surface by delegation. The concrete Discord
6
+ * implementation lives in `src/core/delivery/` — app code; this package only
7
+ * defines the seam so adapter packages can accept a bridge without importing
8
+ * app modules (adapters never import `src/`).
9
+ *
10
+ * Lifecycle: the HANDLE is threaded through `AdapterInitOpts.channelBridge`
11
+ * at adapter init (cheap, no I/O); `boot()`/`shutdown()` are called by the
12
+ * server only — never inside `createAppServices()`, which read-only CLI
13
+ * paths also call. `isConfigured()` must be side-effect-free and callable
14
+ * before boot: adapters use it to decide whether to expose `channels` and
15
+ * whether `capabilities().delivery.mode` reports `'shimmed'` or
16
+ * `'unavailable'`.
17
+ */
18
+ import type { RuntimeChannelSurface } from '../adapters/runtime/channels';
19
+ /** The full channel surface, contract-identical to a native adapter's. */
20
+ export type ChannelSurface = RuntimeChannelSurface;
21
+ export interface ChannelBridge {
22
+ /**
23
+ * True when non-secret config AND the transport secret are present.
24
+ * Side-effect-free; the gate for exposing `channels` on an adapter.
25
+ */
26
+ isConfigured(): boolean;
27
+ /** Connect transports. Server-boot only; idempotent. */
28
+ boot(): Promise<void>;
29
+ /** Disconnect and release transports. Safe when never booted. */
30
+ shutdown(): Promise<void>;
31
+ /**
32
+ * The delegated channel surface. Only meaningful when `isConfigured()`;
33
+ * adapters must not expose it otherwise.
34
+ */
35
+ channels: ChannelSurface;
36
+ }
@@ -1,4 +1,4 @@
1
- import type { APIRoute } from '../plugin-types';
1
+ import type { RegisteredAPIRoute as APIRoute } from '../plugin-types';
2
2
  export type DocsAwareAPIRoute = APIRoute & {
3
3
  summary: string;
4
4
  description: string;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Human-readable rendering of structured (JSON-ish) values — the shared home
3
+ * (#608) so UI surfaces, channels, and tool-activity feeds never dump raw
4
+ * JSON blobs at people. Client + server safe (pure, no deps).
5
+ *
6
+ * Variants:
7
+ * - formatStructured(value, { markdown }) → labeled multi-line prose
8
+ * (`Label: value`, nested objects indented; markdown bolds the labels
9
+ * for channel messages).
10
+ * - summarizeStructured(value, cap) → ONE compact line for chips/badges.
11
+ * - unwrapToolResult(value) → peel a runtime tool-result envelope
12
+ * (`{content:[{type:'text',text}]}`) down to its meaningful payload,
13
+ * parsing an inner JSON string when present.
14
+ */
15
+ export declare function humanizeKey(key: string): string;
16
+ export interface FormatStructuredOptions {
17
+ /** Bold labels for markdown surfaces (channel messages). */
18
+ markdown?: boolean;
19
+ /** Override the section heading; a blank line follows it. Omit for no heading. */
20
+ heading?: string;
21
+ /** Cap the rendered body; appends a truncation marker when exceeded. */
22
+ cap?: number;
23
+ }
24
+ /**
25
+ * Labeled prose for a structured value. Returns '' when there's nothing
26
+ * human-reviewable (empty object / all-empty fields) — callers show nothing
27
+ * rather than a bare "{}". A scalar renders as itself.
28
+ */
29
+ export declare function formatStructured(value: unknown, opts?: FormatStructuredOptions): string;
30
+ /**
31
+ * ONE compact line for chips/badges. Skips status noise (`ok: true` is shown
32
+ * by the chip's color, not its text), prefers a descriptive field, and
33
+ * describes collections by count rather than dropping them.
34
+ */
35
+ export declare function summarizeStructured(value: unknown, cap?: number): string;
36
+ /**
37
+ * Peel a runtime tool-result envelope to its meaningful payload:
38
+ * { content: [{ type:'text', text }] } → the joined text, JSON-parsed when
39
+ * the text is itself a JSON document (bakin exec tools return JSON strings).
40
+ * Peels REPEATEDLY — an agent that shells a tool via bash produces a
41
+ * doubly-wrapped envelope (runtime content → shell stdout → MCP content).
42
+ * Non-envelope values pass through unchanged. Never throws.
43
+ */
44
+ export declare function unwrapToolResult(value: unknown, depth?: number): unknown;
@@ -1,6 +1,30 @@
1
+ export interface FormatAgeOptions {
2
+ /**
3
+ * Resolve below a minute ("42s ago") instead of flattening to "just now".
4
+ *
5
+ * Live-status surfaces need it: on a heartbeat or an activity feed the
6
+ * difference between five seconds and fifty is the signal, and minute
7
+ * granularity erases it. Everything under ten seconds still reads
8
+ * "just now" so a ticking feed does not flicker through 1s/2s/3s.
9
+ */
10
+ precise?: boolean;
11
+ }
1
12
  /** Human-readable relative time from an ISO timestamp */
2
- export declare function formatAge(timestamp: string): string;
13
+ export declare function formatAge(timestamp: string, options?: FormatAgeOptions): string;
14
+ /**
15
+ * Human-readable absolute date+time with calendar awareness:
16
+ * "Today 3:45 PM" / "Yesterday 9:02 AM" / "Jan 5 3:45 PM", carrying the year
17
+ * only for prior-year timestamps (a bare "Jan 5" is ambiguous once runs and
18
+ * completions outlive the calendar). Falls back to the raw input if unparseable.
19
+ */
20
+ export declare function formatDateTime(timestamp: string): string;
21
+ /**
22
+ * Human-readable elapsed duration from a millisecond count, rolling up through
23
+ * units ("850ms" / "42s" / "3m 5s" / "2h 5m" / "3d 2h"); null when undefined.
24
+ */
25
+ export declare function formatDuration(ms?: number): string | null;
3
26
  /** Human-readable file size */
4
27
  export declare function formatSize(bytes: number): string;
5
28
  /** Check if a heartbeat timestamp is stale (> 15 min) */
6
29
  export declare function isStale(timestamp: string, thresholdMs?: number): boolean;
30
+ export { humanizeKey, formatStructured, summarizeStructured, unwrapToolResult, type FormatStructuredOptions, } from './format/structured';
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Health observation builders — the ONE construction path for check
3
+ * output, shared by plugins (via `@makinbakin/sdk/utils`, which
4
+ * re-exports these) and adapter packages (which depend only on
5
+ * `@bakin/core`).
6
+ *
7
+ * The builders CLAMP copy to the health contract's bounds instead of
8
+ * letting an overlong or blank string invalidate the whole run: a check
9
+ * that interpolated a long runtime error into its summary used to fail
10
+ * contract validation wholesale, turning real evidence into a useless
11
+ * "could not be verified" card (field-diagnosed 2026-07-22). Truncated
12
+ * copy is honest; discarded evidence is not. Constructing observations
13
+ * as raw object literals bypasses this protection — always build through
14
+ * these helpers.
15
+ */
16
+ import type { ErrorObservationInput, HealthNonEmptyArray, HealthObservationInput, HealthyObservationInput, NotApplicableHealthCheckRunInput, ObservedHealthCheckRunInput, UnknownObservationInput, WarningObservationInput } from '../plugin-types';
17
+ type HealthyObservationFields = Omit<HealthyObservationInput, 'status'>;
18
+ type WarningObservationFields = Omit<WarningObservationInput, 'status'>;
19
+ type ErrorObservationFields = Omit<ErrorObservationInput, 'status'>;
20
+ type UnknownObservationFields = Omit<UnknownObservationInput, 'status'>;
21
+ /** Build a healthy observation. Healthy observations cannot carry incidents. */
22
+ export declare function healthHealthy(input: HealthyObservationFields): HealthyObservationInput;
23
+ /** Build a warning observation with an explicit advisory/watch/action disposition. */
24
+ export declare function healthWarning(input: WarningObservationFields): WarningObservationInput;
25
+ /** Build an error observation. Its incident must require operator action. */
26
+ export declare function healthError(input: ErrorObservationFields): ErrorObservationInput;
27
+ /** Build an Unknown verification observation (watch, or advisory when it self-resolves). */
28
+ export declare function healthUnknown(input: UnknownObservationFields): UnknownObservationInput;
29
+ /** Build a successful observed run. Empty diagnostic output is unrepresentable. */
30
+ export declare function healthObserved(observations: HealthNonEmptyArray<HealthObservationInput>): ObservedHealthCheckRunInput;
31
+ /** Build an explicit successful not-applicable run. */
32
+ export declare function healthNotApplicable(reason: string): NotApplicableHealthCheckRunInput;
33
+ /**
34
+ * Deterministically coerce arbitrary text (a filesystem path, a table
35
+ * name, a task id) into the contract's stable resource-id format
36
+ * (`^[a-z0-9][a-z0-9._:-]{0,127}$`). A raw path used as a resource id
37
+ * failed contract validation and nuked a REAL finding into a generic
38
+ * "could not be verified" card for three releases (field-diagnosed
39
+ * 2026-07-23). Put the human-readable original in `label`, never in `id`.
40
+ */
41
+ export declare function healthResourceId(raw: string): string;
42
+ export {};
@@ -0,0 +1,18 @@
1
+ export declare const INLINE_ATTACHMENT_LIMIT_BYTES = 2000000;
2
+ export interface PreparedAttachment {
3
+ path: string;
4
+ mimeType: string;
5
+ downscaled: boolean;
6
+ }
7
+ /**
8
+ * Returns the original when it already fits; otherwise a downscaled temp
9
+ * JPEG. Throws (loudly, with the silent-degradation rationale) when the
10
+ * image cannot be brought under the cap — never sends an oversized file.
11
+ */
12
+ export declare function prepareImageAttachment(path: string, mimeType: string): Promise<PreparedAttachment>;
13
+ /**
14
+ * Remove the temp dir a downscale created. Callers own the lifetime — e.g.
15
+ * the enrichment engine calls this after its LAST send (the corrective
16
+ * re-ask reuses the file). No-op for originals.
17
+ */
18
+ export declare function cleanupPreparedAttachment(prepared: PreparedAttachment): void;