@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
@@ -1,8 +1,24 @@
1
1
  /**
2
- * Plugin system type definitions for Bakin.
3
- * All plugin interfaces are defined here — no behavioral changes.
2
+ * Plugin system type definitions for Bakin (the internal, in-process surface).
3
+ *
4
+ * Two-tier contract — read before "deduplicating" against the SDK:
5
+ * `@makinbakin/sdk/types` is the PUBLISHED, self-contained, deliberately
6
+ * NARROWER plugin-author surface; this file is the INTERNAL surface that
7
+ * in-process core plugins actually receive. They are NOT a fork to collapse.
8
+ * Concretely:
9
+ * - `PluginContext.runtime` here is the FULL `AgentRuntimeAdapter`
10
+ * (adapters/runtime/concepts.ts: agents×11, tools, sessions, memory,
11
+ * config, images, media, restart…). Core plugins use ~15 full-only
12
+ * methods. The SDK exposes a curated subset.
13
+ * - `ctx.tasks` here returns the `PluginTask` projection; the SDK returns
14
+ * `Task`. `BakinPlugin` here adds `routes?`. `StorageAdapter`/`NavItem`/
15
+ * `APIRoute`/`HookAPI`/`SkillDefinition` are intentionally fuller here.
16
+ * Genuinely-identical LEAF data types (health, exec-result, search, manifest,
17
+ * EventBus/ActivityAPI/PluginLogger, TaskLogEntry, …) ARE single-homed in the
18
+ * SDK and re-exported below. Collapsing the boundary itself is WS2 work.
4
19
  */
5
- import type { ZodRawShape, ZodType } from 'zod';
20
+ import type { z, ZodRawShape, ZodType } from 'zod';
21
+ import type { ActivityAPI, ActivityClass, ConversationTurnsAPI, EventBus, ExecToolResult, HealthCheckRegistrationInput, HealthOwner, HealthRepairActionDefinition, PluginLogger, SearchAPI, TaskLogEntry } from '@makinbakin/sdk/types';
6
22
  import type { ContractStability, ContractVisibility, DocsExample, SchemaLike, SourceLocation } from './docs';
7
23
  import type { AgentRuntimeAdapter } from './adapters/runtime';
8
24
  import type { APIRoute as DeclarativeAPIRoute, PluginContextLite } from './routing/types';
@@ -12,23 +28,25 @@ export interface ApprovalActor {
12
28
  source: 'channel' | 'web' | 'system';
13
29
  }
14
30
  export interface StorageAdapter {
31
+ /** Absolute private root when backed by a local filesystem. Not browser assets. */
32
+ readonly localRoot?: string;
15
33
  read(path: string): string | null;
16
34
  write(path: string, content: string): void;
17
35
  append(path: string, content: string): void;
18
36
  exists(path: string): boolean;
19
37
  readAll(): Record<string, string>;
20
- list?(path?: string): string[];
21
- remove?(path: string): void;
22
- rename?(from: string, to: string): void;
23
- stat?(path: string): {
38
+ list(path?: string): string[];
39
+ remove(path: string): void;
40
+ rename(from: string, to: string): void;
41
+ stat(path: string): {
24
42
  path: string;
25
43
  size: number;
26
44
  mtimeMs: number;
27
45
  isFile: boolean;
28
46
  isDirectory: boolean;
29
47
  } | null;
30
- readJson?<T = unknown>(path: string): T | null;
31
- writeJson?(path: string, value: unknown): void;
48
+ readJson<T = unknown>(path: string): T | null;
49
+ writeJson(path: string, value: unknown): void;
32
50
  /**
33
51
  * Convert a plugin-storage-relative path or glob to the content-dir-relative
34
52
  * path seen by file-backed search/watch APIs. Implementations never return
@@ -36,11 +54,8 @@ export interface StorageAdapter {
36
54
  */
37
55
  searchPath?(path: string): string;
38
56
  }
39
- export interface EventBus {
40
- emit(event: string, data?: Record<string, unknown>): void;
41
- on(pattern: string, handler: (event: string, data: Record<string, unknown>) => void): () => void;
42
- once(pattern: string, handler: (event: string, data: Record<string, unknown>) => void): () => void;
43
- }
57
+ export type { EventBus } from '@makinbakin/sdk/types';
58
+ export type NavSection = 'plan-and-automate' | 'create' | 'operations';
44
59
  export interface NavItem {
45
60
  id: string;
46
61
  label: string;
@@ -48,9 +63,17 @@ export interface NavItem {
48
63
  href: string;
49
64
  order?: number;
50
65
  children?: NavItem[];
51
- alwaysExpanded?: boolean;
66
+ section?: NavSection;
52
67
  }
53
- export interface APIRoute {
68
+ /**
69
+ * INTERNAL registered-route record — the erased shape routes take inside the
70
+ * plugin registry's state after declarative registration (typed schemas
71
+ * survive as extra fields the dispatcher reads). NOT a public authoring
72
+ * type: plugin authors declare routes with `defineRoute()` and the
73
+ * declarative-generic `APIRoute<C, P, Q, B>` from `@bakin/core/routing` /
74
+ * `@makinbakin/sdk` (audit 2026-07 H3 collapsed the two same-named types).
75
+ */
76
+ export interface RegisteredAPIRoute {
54
77
  path: string;
55
78
  method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
56
79
  handler: (req: Request, ctx: PluginContext) => Response | Promise<Response>;
@@ -64,6 +87,7 @@ export interface APIRoute {
64
87
  examples?: DocsExample[];
65
88
  source?: SourceLocation;
66
89
  permissions?: string[];
90
+ activityClass?: ActivityClass;
67
91
  }
68
92
  export interface UISlotRegistration {
69
93
  slot: string;
@@ -73,16 +97,14 @@ export interface UISlotRegistration {
73
97
  export interface ContentFile {
74
98
  path: string;
75
99
  }
76
- /** Result returned by execution tool handlers */
77
- export interface ExecToolResult {
78
- ok: boolean;
79
- error?: string;
80
- details?: unknown;
81
- [key: string]: unknown;
82
- }
100
+ export type { ExecToolResult } from '@makinbakin/sdk/types';
83
101
  /** Definition for a registerable execution tool */
84
102
  /** Context available to exec tool handlers — provides access to plugin services */
85
103
  export interface PluginToolContext {
104
+ /** Set only by a verified transport, never from tool parameters. */
105
+ invocation?: {
106
+ agentId: string;
107
+ };
86
108
  storage: StorageAdapter;
87
109
  events: EventBus;
88
110
  pluginId: string;
@@ -94,13 +116,17 @@ export interface PluginToolContext {
94
116
  activity: ActivityAPI;
95
117
  getSettings<T = Record<string, unknown>>(): T;
96
118
  }
97
- export interface ExecToolDefinition {
119
+ export interface ExecToolDefinition<Shape extends ZodRawShape = ZodRawShape> {
120
+ /** Reject unverified HTTP/MCP callers before invoking the handler. */
121
+ requiresVerifiedAgent?: boolean;
98
122
  name: string;
99
123
  description: string;
100
124
  label?: string;
101
125
  activityDuplicate?: boolean;
102
- parameters: ZodRawShape;
103
- handler: (params: Record<string, unknown>, agent: string, ctx?: PluginToolContext) => Promise<ExecToolResult>;
126
+ activityClass?: ActivityClass;
127
+ parameters: Shape;
128
+ /** Params are inferred from `parameters` — declare the shape once, get typed params. */
129
+ handler: (params: z.infer<z.ZodObject<Shape>>, agent: string, ctx?: PluginToolContext) => Promise<ExecToolResult>;
104
130
  source?: string;
105
131
  }
106
132
  /** A skill that can be registered by plugins or loaded from disk */
@@ -109,6 +135,16 @@ export interface SkillDefinition {
109
135
  instructions: string;
110
136
  output_schema?: Record<string, unknown>;
111
137
  source?: string;
138
+ /** Absolute source markdown file path when the skill was loaded from a managed package/plugin file. */
139
+ sourcePath?: string;
140
+ }
141
+ export interface WorkflowLayoutInput {
142
+ positions?: Record<string, {
143
+ x: number;
144
+ y: number;
145
+ [key: string]: unknown;
146
+ }>;
147
+ [key: string]: unknown;
112
148
  }
113
149
  export interface WorkflowDefinitionInput {
114
150
  /** Stable workflow id. Falls back to slug(name) when omitted. */
@@ -117,23 +153,11 @@ export interface WorkflowDefinitionInput {
117
153
  description: string;
118
154
  version: number;
119
155
  inputs?: Record<string, unknown>;
156
+ layout?: WorkflowLayoutInput;
120
157
  steps: unknown[];
158
+ [key: string]: unknown;
121
159
  }
122
- export interface ActivityAPI {
123
- /** Log a human-readable message to the live activity feed */
124
- log(agent: string, message: string, opts?: {
125
- taskId?: string;
126
- category?: string;
127
- }): void;
128
- /** Log a structured audit event */
129
- audit(event: string, agent: string, data?: Record<string, unknown>): void;
130
- }
131
- export interface PluginLogger {
132
- debug(message: string, data?: Record<string, unknown>): void;
133
- info(message: string, data?: Record<string, unknown>): void;
134
- warn(message: string, errorOrData?: unknown, data?: Record<string, unknown>): void;
135
- error(message: string, errorOrData?: unknown, data?: Record<string, unknown>): void;
136
- }
160
+ export type { ActivityAPI, PluginLogger } from '@makinbakin/sdk/types';
137
161
  export interface HookAPI {
138
162
  /** Register a handler for a named hook. Returns unsubscribe function. */
139
163
  register(name: string, handler: (data: any) => any, metadata?: HookRegistrationMetadata): () => void;
@@ -200,7 +224,7 @@ export interface PluginNodeTypeInput<T = unknown> {
200
224
  * is prepended to `id` automatically (`{pluginId}.{id}`), matching the node-
201
225
  * type precedent. Built-in workflows-plugin runtime channels (general,
202
226
  * announcements, alerts, email) self-register at module load in
203
- * `plugins/workflows/lib/notification-channel-registry.ts`.
227
+ * `packages/core/src/workflows/notification-channel-registry.ts`.
204
228
  */
205
229
  export interface PluginNotificationChannelInput {
206
230
  id: string;
@@ -215,71 +239,18 @@ export interface NotificationChannelDef extends PluginNotificationChannelInput {
215
239
  /** Set when runtime === 'plugin'; identifies the owning plugin. */
216
240
  pluginId?: string;
217
241
  }
218
- /**
219
- * Canonical result shape for a single doctor check row.
220
- */
221
- export interface HealthCheckResult {
222
- check: string;
223
- status: 'ok' | 'warn' | 'error' | 'fixed';
224
- message: string;
225
- autoFixable: boolean;
226
- }
227
- export type HealthRepairSafety = 'safe' | 'manual' | 'destructive';
228
- export interface HealthRepairChange {
229
- kind: 'file' | 'setting' | 'service' | 'runtime' | 'task' | 'other';
230
- target: string;
231
- action: 'create' | 'update' | 'delete' | 'install' | 'invoke';
232
- description: string;
233
- }
234
- export interface HealthRepairPlanItem {
242
+ export type { ActionIncidentInput, AdvisoryIncidentInput, CanonicalErrorObservation, CanonicalHealthyObservation, CanonicalUnknownObservation, CanonicalWarningObservation, ErrorObservationInput, HealthCheckExecution, HealthCheckRegistrationInput, HealthCheckRunContext, HealthCheckRunInput, HealthCheckSnapshot, HealthCheckState, HealthDisposition, HealthFullSweep, HealthGroup, HealthIncident, HealthIncidentInput, HealthInstructionsResolution, HealthNavigateResolution, HealthNonEmptyArray, HealthObservation, HealthObservationInput, HealthObservationStatus, HealthOwner, HealthOwnerKind, HealthRepairActionDefinition, HealthRepairApplyRequest, HealthRepairApplyResult, HealthRepairSafety, HealthRepairChange, HealthRepairPlanItem, HealthRepairPlan, HealthRepairPrecondition, HealthRepairResolution, HealthRepairTarget, HealthReport, HealthReportStatus, HealthReportSummary, HealthResolution, HealthResource, HealthResourceKind, HealthRerunResolution, HealthyObservationInput, JsonObject, JsonValue, NotApplicableHealthCheckRunInput, ObservedHealthCheckRunInput, SearchReadiness, SearchReadinessStage, SearchReadinessStageKey, SearchReadinessStatus, SearchStageStatus, UnknownObservationInput, WarningObservationInput, WatchIncidentInput, } from '@makinbakin/sdk/types';
243
+ /** Core-internal canonical registration with its resolved owner and local id. */
244
+ export interface HealthCheckDef extends HealthCheckRegistrationInput {
235
245
  id: string;
236
- checkId: string;
237
- title: string;
238
- reason: string;
239
- safety: HealthRepairSafety;
240
- requiresConfirmation: boolean;
241
- changes: HealthRepairChange[];
246
+ localId: string;
247
+ owner: HealthOwner;
242
248
  }
243
- export interface HealthRepairApplyResult {
249
+ /** Core-internal canonical repair action with its resolved owner and local id. */
250
+ export interface HealthRepairActionDef extends HealthRepairActionDefinition {
244
251
  id: string;
245
- checkId: string;
246
- status: 'applied' | 'skipped' | 'failed';
247
- message: string;
248
- changes: HealthRepairChange[];
249
- }
250
- export interface HealthRepairHandler {
251
- plan(rows: HealthCheckResult[]): Promise<HealthRepairPlanItem[]>;
252
- apply(items: HealthRepairPlanItem[]): Promise<HealthRepairApplyResult[]>;
253
- }
254
- /**
255
- * Input shape plugins pass to `ctx.registerHealthCheck`. The plugin id is
256
- * auto-namespaced as `{pluginId}.{id}`. `run()` returns an array so one
257
- * registered check can contribute multiple result rows (mirrors how the
258
- * existing `checkPersonas` returns one per agent).
259
- */
260
- export interface PluginHealthCheckInput {
261
- id: string;
262
- name: string;
263
- /**
264
- * Runs the check, returns any number of result rows. Throws/rejects are
265
- * caught by the doctor orchestrator and converted to a synthetic error
266
- * result — a single bad handler never crashes the sweep.
267
- */
268
- run: () => Promise<HealthCheckResult[]>;
269
- /**
270
- * Legacy advisory flag for older admin surfaces. New code should derive
271
- * repairability from `repair`.
272
- */
273
- autoFix?: boolean;
274
- /**
275
- * Optional explicit repair contract. Diagnostics call only `run()`; repair
276
- * flows call `plan()` first, then `apply()` after explicit confirmation.
277
- */
278
- repair?: HealthRepairHandler;
279
- }
280
- export interface HealthCheckDef extends PluginHealthCheckInput {
281
- runtime: 'plugin';
282
- pluginId: string;
252
+ localId: string;
253
+ owner: HealthOwner;
283
254
  }
284
255
  export interface PluginContext {
285
256
  storage: StorageAdapter;
@@ -289,25 +260,17 @@ export interface PluginContext {
289
260
  tasks: PluginTaskService;
290
261
  assets: AssetsAPI;
291
262
  registerNav(items: NavItem[]): void;
292
- /**
293
- * @deprecated Use `definePlugin({ routes: [defineRoute({...})] })` to declare
294
- * routes. This adapter remains during the migration window for any
295
- * out-of-tree plugin that still calls `ctx.registerRoute(...)` from
296
- * `activate()`. In-repo plugins migrated in T6–T13 / T20 — none of them
297
- * call this. The dispatcher adapts the legacy shape (input → body,
298
- * output → responses[200]) when invoked through this path.
299
- */
300
- registerRoute(route: APIRoute): void;
301
263
  registerSlot(registration: UISlotRegistration): void;
302
- registerExecTool(tool: ExecToolDefinition): void;
264
+ registerExecTool<Shape extends ZodRawShape>(tool: ExecToolDefinition<Shape>): void;
303
265
  registerSkill(skill: SkillDefinition): void;
304
266
  /**
305
267
  * Register a workflow definition shipped by this plugin. Disk-resident
306
268
  * user definitions in `~/.bakin/workflows/definitions/` always win on id
307
269
  * collision (user-wins). A second plugin claiming an id already taken by
308
- * another plugin is a containment error: it's logged but does not throw
309
- * out of `activate()`. Re-registering the same id from the same plugin
310
- * is idempotent (newer wins) so hot reload works.
270
+ * another plugin THROWS out of `activate()` (R18 — the activation fails
271
+ * and the plugin's partial registrations are swept). Re-registering the
272
+ * same id from the same plugin is an update (newer wins) so hot reload
273
+ * works.
311
274
  */
312
275
  registerWorkflow(definition: WorkflowDefinitionInput, opts?: {
313
276
  readOnly?: boolean;
@@ -334,7 +297,9 @@ export interface PluginContext {
334
297
  * sweep — throws are isolated, a single bad check never crashes the
335
298
  * doctor. Returns the namespaced id.
336
299
  */
337
- registerHealthCheck(def: PluginHealthCheckInput): string;
300
+ registerHealthCheck(def: HealthCheckRegistrationInput): string;
301
+ /** Register an owner-local repair action referenced by Health observations. */
302
+ registerHealthRepairAction(def: HealthRepairActionDefinition): string;
338
303
  watchFiles(patterns: string[]): void;
339
304
  /** Read this plugin's persisted settings */
340
305
  getSettings<T = Record<string, unknown>>(): T;
@@ -342,12 +307,14 @@ export interface PluginContext {
342
307
  updateSettings(patch: Record<string, unknown>): void;
343
308
  /** Structured activity logging */
344
309
  activity: ActivityAPI;
345
- /** Plugin-scoped server log. Prefer this over console.* for lifecycle logs. */
346
- log?: PluginLogger;
310
+ /** Plugin-scoped server log. Always provided; prefer over console.*. */
311
+ log: PluginLogger;
347
312
  /** Cross-plugin hook registration */
348
313
  hooks: HookAPI;
349
314
  /** Adapter-backed search — register content types, index, query */
350
315
  search: SearchAPI;
316
+ /** Shared conversation turn engine — background turns for chat-like surfaces (#703) */
317
+ conversations: ConversationTurnsAPI;
351
318
  }
352
319
  export type PluginTaskColumn = 'backlog' | 'todo' | 'inProgress' | 'review' | 'done' | 'blocked' | 'archived';
353
320
  export interface PluginTask {
@@ -366,6 +333,7 @@ export interface PluginTask {
366
333
  workflowId?: string;
367
334
  scheduleJobId?: string;
368
335
  projectId?: string;
336
+ brandId?: string;
369
337
  availableAt?: string;
370
338
  dueAt?: string;
371
339
  source?: PluginTaskSource;
@@ -379,12 +347,7 @@ export interface PluginTaskSource {
379
347
  entityId?: string;
380
348
  purpose?: string;
381
349
  }
382
- export interface TaskLogEntry {
383
- timestamp: string;
384
- author: string;
385
- message: string;
386
- data?: Record<string, unknown>;
387
- }
350
+ export type { TaskLogEntry } from '@makinbakin/sdk/types';
388
351
  export interface PluginTaskCreateInput {
389
352
  id?: string;
390
353
  title: string;
@@ -395,6 +358,7 @@ export interface PluginTaskCreateInput {
395
358
  date?: string;
396
359
  workflowId?: string;
397
360
  projectId?: string;
361
+ brandId?: string;
398
362
  parentId?: string | null;
399
363
  availableAt?: string;
400
364
  dueAt?: string;
@@ -413,6 +377,7 @@ export interface PluginTaskUpdateInput {
413
377
  workflowId?: string;
414
378
  scheduleJobId?: string;
415
379
  projectId?: string;
380
+ brandId?: string;
416
381
  parentId?: string | null;
417
382
  availableAt?: string | null;
418
383
  dueAt?: string | null;
@@ -428,349 +393,154 @@ export interface PluginTaskService {
428
393
  column?: PluginTaskColumn;
429
394
  agent?: string;
430
395
  projectId?: string;
396
+ brandId?: string;
431
397
  }): Promise<PluginTask[]>;
432
398
  appendLog(id: string, entry: TaskLogEntry): Promise<void>;
433
399
  }
434
- export interface AssetVariantMeta {
435
- role: 'thumbnail' | 'optimized' | 'webp';
436
- path: string;
437
- filename: string;
438
- size: number;
439
- mimeType: string;
440
- }
441
- export interface AssetMeta {
442
- path: string;
443
- filename: string;
444
- type: 'text' | 'images' | 'video' | 'audio' | 'plans' | 'research' | 'pdf' | 'data' | 'other';
445
- mimeType: string;
446
- size: number;
447
- mtimeMs?: number;
448
- metadata: {
449
- agent: string;
450
- taskId: string | null;
451
- created: string;
452
- tool?: string;
453
- description?: string;
454
- tags?: string[];
455
- originalFilename?: string;
400
+ /** The asset type taxonomy (mirrors ASSET_TYPES in the assets plugin). */
401
+ export type AssetTypeName = 'text' | 'images' | 'video' | 'audio' | 'plans' | 'research' | 'pdf' | 'data' | 'other';
402
+ /** Per-version generation provenance (matches the manifest's `generation` block). */
403
+ export interface AssetGenerationInfo {
404
+ provider: string;
405
+ model: string;
406
+ surface: string;
407
+ /** Honored only on the shim path; native generations omit it (#379). */
408
+ quality?: string;
409
+ routeSource: string;
410
+ routeReason?: string;
411
+ /** Reference/context images that conditioned this generation (#418). */
412
+ references?: Array<{
413
+ assetId: string;
414
+ version: number;
415
+ }>;
416
+ /** Brand provenance (#419): brand id + content fingerprint as-used. */
417
+ brandId?: string;
418
+ brandFingerprint?: string;
419
+ }
420
+ /** Create a new versioned asset (v1) from a source file. */
421
+ export interface AssetCreateInput {
422
+ sourceFilePath: string;
423
+ type: AssetTypeName;
424
+ agent: string;
425
+ taskId: string | null;
426
+ slug?: string;
427
+ op?: 'generate' | 'upload' | 'import';
428
+ tool?: string | null;
429
+ prompt?: string | null;
430
+ promptHash?: string | null;
431
+ description?: string;
432
+ tags?: string[];
433
+ source?: {
434
+ kind: 'generated' | 'upload' | 'import' | 'clipboard' | 'workspace-file';
435
+ path: string | null;
456
436
  };
457
- variants?: AssetVariantMeta[];
458
- }
459
- export interface AssetFileRef {
460
- kind: 'asset';
461
- filename: string;
462
- mimeType?: string;
463
- }
464
- export interface AssetsAPI {
465
- getByFilename(filename: string): Promise<AssetMeta | null>;
466
- list(filter?: {
467
- type?: AssetMeta['type'];
468
- taskId?: string | null;
469
- }): Promise<AssetMeta[]>;
470
- exists(filename: string): Promise<boolean>;
471
- fileRef(filename: string): Promise<AssetFileRef>;
472
- }
473
- /** Field type for search content type schemas */
474
- export interface SearchSchemaField {
475
- type: 'text' | 'keyword' | 'number' | 'boolean' | 'datetime' | 'array';
437
+ generation?: AssetGenerationInfo | null;
476
438
  }
477
439
  /**
478
- * One vector index on a search table. A content type can declare multiple
479
- * indexes to embed the same document into several vector spaces — e.g. a
480
- * text index using BGE and a visual index using CLIP on the assets table.
481
- * Each index has its own embedder (resolved via embedderRef), input
482
- * declaration, and optional chunker config.
440
+ * Append a new version to an existing asset. Note: no `tags` — tags are an
441
+ * asset-level organizational namespace that versioning never touches.
483
442
  */
484
- export interface SearchIndexDefinition {
485
- /** Index name as stored by the search adapter. Must be stable across restarts. */
486
- name: string;
487
- /** Ref into settings.search.settings.embedders — 'default', 'visual', or custom. */
488
- embedderRef: string;
489
- /** Handlebars template for this index's text embedding input. */
490
- embeddingTemplate?: string;
491
- /**
492
- * Document field containing a URL to media bytes for visual/multimodal
493
- * embedding input. The search adapter owns provider-specific helper syntax.
494
- */
495
- mediaUrlField?: string;
496
- /** Per-index chunker config, overrides any table-level default. */
497
- chunker?: {
498
- enabled: boolean;
499
- targetTokens?: number;
500
- overlapTokens?: number;
501
- };
502
- }
503
- /** Definition for a searchable content type registered by a plugin */
504
- export interface SearchContentTypeDefinition {
505
- /** Table name — auto-prefixed with `bakin_`. E.g., 'tasks' → 'bakin_tasks' */
506
- table: string;
507
- /** Schema for the document fields */
508
- schema: Record<string, SearchSchemaField>;
509
- /** Fields to include in full-text search */
510
- searchableFields: string[];
511
- /**
512
- * Handlebars template for embedding generation. Used when `indexes` is
513
- * not provided — the registry synthesizes a single default index named
514
- * `embeddings` with this template and the default embedder.
515
- */
516
- embeddingTemplate: string;
517
- /**
518
- * Optional per-index definitions. When provided, overrides
519
- * `embeddingTemplate` and creates one embedding index per entry with
520
- * its own embedder. Used by content types that want multimodal indexing
521
- * (e.g. assets with both a text index and a visual index).
522
- */
523
- indexes?: SearchIndexDefinition[];
524
- /** Fields to expose as aggregatable facets */
525
- facets?: string[];
526
- /**
527
- * Document field to use as input for the cross-encoder reranker. When
528
- * set, queries against this content type attach the configured reranker
529
- * and score the query-document pair using the value at this field.
530
- * When unset, queries skip reranking for this content type.
531
- */
532
- rerankField?: string;
533
- /** TTL duration (Go format: '24h', '7d', '30d') */
534
- ttl?: string;
535
- /** TTL field (defaults to 'created_at') */
536
- ttlField?: string;
537
- /** Chunking config for long documents — used by the synthesized default index. */
538
- chunker?: {
539
- enabled: boolean;
540
- targetTokens?: number;
541
- overlapTokens?: number;
542
- };
543
- /**
544
- * Backfill function — called during full/per-table reindex.
545
- * Must yield ALL documents for this content type from source.
546
- */
547
- reindex: () => AsyncGenerator<{
548
- key: string;
549
- doc: Record<string, unknown>;
550
- }>;
551
- /**
552
- * Existence check — called during orphan cleanup.
553
- * Returns true if the source document for this key still exists.
554
- */
555
- verifyExists: (key: string) => Promise<boolean>;
556
- }
557
- /** Parameters for a search query */
558
- export interface SearchQueryParams {
559
- /** Search query string */
560
- q: string;
561
- /** Structured keyword filters */
562
- filters?: Record<string, string | boolean | number>;
563
- /** Facets to include in aggregations */
564
- facets?: string[];
565
- /** Max results */
566
- limit?: number;
567
- /** Result offset for pagination */
568
- offset?: number;
569
- /**
570
- * Whether to run the cross-encoder reranker on results. Defaults to
571
- * true when the reranker is enabled in settings. Set false for latency-
572
- * sensitive paths (facet-only queries, ID lookups, bulk scans) where
573
- * the extra ~100-500ms isn't worth it.
574
- */
575
- rerank?: boolean;
576
- /**
577
- * Raw adapter-specific aggregations passed through unchanged to the query layer.
578
- * Use for date histograms, range buckets, stats aggregations, or any
579
- * other shape beyond the term-facet convenience in `facets`. Merged
580
- * with facet-derived aggregations (these win on key collision).
581
- * See the active search adapter docs for the aggregation schema.
582
- */
583
- aggregations?: Record<string, unknown>;
584
- /**
585
- * Search strategy override. Defaults to the site-wide search strategy.
586
- * Pass 'full_text_only' for filter-driven
587
- * counts or ID lookups — semantic search rejects `limit: 0` queries
588
- * with the "semantic search requires topk limit to be positive" error.
589
- */
590
- strategy?: 'rrf' | 'semantic_only' | 'full_text_only';
591
- }
592
- /** A single search result */
593
- export interface SearchResult {
594
- id: string;
595
- table: string;
596
- score: number;
597
- fields: Record<string, unknown>;
598
- /** Cross-encoder reranker score (present when a reranker was used). */
599
- rerankScore?: number;
600
- }
601
- /** Search response from a query */
602
- export interface SearchResponse {
603
- results: SearchResult[];
604
- /**
605
- * Mapped term-facet aggregations — keyed by facet field, each a list
606
- * of { value, count }. Populated from `params.facets` for convenience.
607
- */
608
- aggregations?: Record<string, Array<{
609
- value: string;
610
- count: number;
611
- }>>;
612
- /**
613
- * Raw aggregation response from the search adapter, unmodified. Populated whenever
614
- * the underlying query returned aggregations — use this for non-term
615
- * shapes like date_histogram, range, stats, etc.
616
- */
617
- rawAggregations?: Record<string, unknown>;
618
- meta: {
619
- query: string;
620
- total: number;
621
- took_ms: number;
622
- source: 'search' | 'fallback';
623
- };
624
- }
625
- export interface SearchHealthIndex {
626
- name: string;
627
- type: string;
628
- totalIndexed: number;
629
- walBacklog: number;
630
- error?: string;
631
- rebuilding: boolean;
632
- backfillProgress?: number;
633
- }
634
- export interface SearchHealthTable {
635
- table: string;
636
- pluginId: string;
637
- stats: Record<string, unknown> | null;
638
- indexHealth?: SearchHealthIndex[];
639
- healthy: boolean;
640
- }
641
- export interface SearchHealthSnapshot {
642
- enabled: boolean;
643
- tables: SearchHealthTable[];
443
+ export interface AssetVersionCreateInput {
444
+ sourceFilePath: string;
445
+ op?: 'edit' | 'generate' | 'upload' | 'import';
446
+ tool?: string | null;
447
+ prompt?: string | null;
448
+ promptHash?: string | null;
449
+ description?: string;
450
+ generation?: AssetGenerationInfo | null;
451
+ }
452
+ /** Render a derived export of a version (keyed/idempotent by surface). */
453
+ export interface AssetExportRequest {
454
+ fromVersion?: number;
455
+ surface: string;
456
+ format: 'jpg' | 'png' | 'webp';
457
+ width: number;
458
+ height: number;
459
+ quality?: number;
460
+ }
461
+ export interface VersionedAssetRef {
462
+ assetId: string;
463
+ version: number;
644
464
  }
645
- /** Atomic transform operation (update fields without re-embedding) */
646
- export interface SearchTransformOp {
647
- op: '$set' | '$inc' | '$push';
648
- field?: string;
649
- value: unknown;
465
+ export interface AssetVersionFileRef {
466
+ absPath: string;
467
+ mimeType: string;
468
+ version: number;
650
469
  }
651
- /**
652
- * One file-pattern → mapper pair used by `FileBackedContentTypeDefinition`.
653
- * A registration may carry multiple of these when a single content type
654
- * draws from several distinct file shapes (e.g. workflows store
655
- * definitions as `.yaml` and instances as `.json`, both indexed into the
656
- * same `bakin_workflows` table with different key prefixes).
657
- */
658
- export interface FilePatternMapper {
659
- /** Glob pattern relative to contentDir. First-match-wins across the patterns array. */
660
- pattern: string;
661
- /**
662
- * Derive the search key for a file matching this pattern. Return null
663
- * to skip the file (e.g. it matches the glob but is missing required
664
- * companion data).
665
- */
666
- fileToId: (relPath: string) => string | null;
667
- /**
668
- * Build the search document for a file matching this pattern.
669
- * `content` is the raw file bytes as a UTF-8 string (empty for binary
670
- * assets, which the watcher recognizes by their `assets/` prefix).
671
- * Return null to skip indexing (e.g. derived state isn't ready yet).
672
- */
673
- fileToDoc: (relPath: string, content: string) => Promise<Record<string, unknown> | null>;
470
+ /** Current-version summary of an asset, addressed by id. */
471
+ export interface AssetSummary {
472
+ assetId: string;
473
+ type: AssetTypeName;
474
+ agent: string;
475
+ taskId: string | null;
476
+ created: string;
477
+ updated: string;
478
+ currentVersion: number;
479
+ versionCount: number;
480
+ description: string;
481
+ tags: string[];
482
+ mimeType: string;
483
+ width: number | null;
484
+ height: number | null;
485
+ size: number;
486
+ hasThumb: boolean;
674
487
  }
675
488
  /**
676
- * A content type whose source of truth is one or more files under
677
- * `~/.bakin/`. Registering via `registerFileBackedContentType` wires up:
678
- *
679
- * 1. Standard `registerContentType` (table creation, schema, reindex).
680
- * 2. A watcher sync hook that re-indexes on add/change.
681
- * 3. A watcher unlink hook that removes on delete.
682
- * 4. A startup reconcile that detects mtime drift and corrects it.
683
- *
684
- * Plugins should reach for this helper first. Use raw `registerContentType`
685
- * only when the source of truth is NOT the filesystem (e.g. SQLite,
686
- * external API, runtime adapter).
489
+ * Per-version detail of a versioned asset (mirrors the manifest's version
490
+ * entries — provenance fields are null when the version wasn't produced by a
491
+ * generation tool).
687
492
  */
688
- export interface FileBackedContentTypeDefinition extends SearchContentTypeDefinition {
689
- /**
690
- * One or more file-pattern mappers. Patterns should not overlap;
691
- * first match wins. A file that matches no pattern is ignored.
692
- */
693
- filePatterns: FilePatternMapper[];
694
- /**
695
- * Optional exclude patterns applied BEFORE any mapper matches. Useful
696
- * for skipping subdirectories like `assets/**\/.trash/**` or sidecar
697
- * files like `**\/*.meta.json`.
698
- */
699
- excludePatterns?: string[];
700
- /**
701
- * Escape hatch for sync events. When provided, the helper invokes
702
- * this instead of the default `fileToDoc → ctx.search.index` flow for
703
- * any file matching this content type's patterns. The plugin takes
704
- * full responsibility for indexing.
705
- *
706
- * Use when pairing logic (e.g. assets' binary↔sidecar coupling) can't
707
- * be expressed as a single mapper. The matched `FilePatternMapper` is
708
- * still consulted for `fileToId` if the plugin needs the canonical key.
709
- */
710
- onSync?: (relPath: string, content: string) => Promise<void>;
711
- /**
712
- * Escape hatch for unlink events. Same story as `onSync`. If unset,
713
- * the helper calls the matched mapper's `fileToId(relPath)` and then
714
- * `ctx.search.remove(id)`.
715
- */
716
- onUnlink?: (relPath: string) => Promise<void>;
717
- /**
718
- * Whether to run the startup reconcile loop on plugin activation.
719
- * Defaults to true. Set false only when the plugin wants to drive its
720
- * own initial population (rare).
721
- */
722
- buildOnStartup?: boolean;
493
+ export interface AssetVersionDetail {
494
+ version: number;
495
+ /** Version file name inside the asset directory (e.g. `v2.png`). */
496
+ file: string;
497
+ width: number | null;
498
+ height: number | null;
499
+ op: 'generate' | 'edit' | 'upload' | 'import';
500
+ tool: string | null;
501
+ prompt: string | null;
502
+ promptHash: string | null;
503
+ generation: AssetGenerationInfo | null;
723
504
  }
724
- /** Search API provided to plugins via ctx.search */
725
- export interface SearchAPI {
726
- /**
727
- * Register a content type this plugin will index.
728
- * Must be called during activate(). Creates the search table if needed.
729
- *
730
- * Prefer `registerFileBackedContentType` when the source of truth is
731
- * a file under `~/.bakin/` — it wires up watcher hooks and startup
732
- * reconcile automatically. Use this raw form only for non-filesystem
733
- * sources (SQLite, external APIs, runtime adapters).
734
- */
735
- registerContentType(def: SearchContentTypeDefinition): void;
736
- /**
737
- * Register a file-backed content type. Wraps `registerContentType` and
738
- * additionally wires watcher sync + unlink hooks scoped to the declared
739
- * file patterns, plus a startup reconcile that detects mtime drift on
740
- * boot. This is the blessed API for any plugin whose data lives in the
741
- * filesystem under `~/.bakin/`.
742
- */
743
- registerFileBackedContentType(def: FileBackedContentTypeDefinition): void;
744
- /** Index or update a document. Fire-and-forget. */
745
- index(key: string, doc: Record<string, unknown>): Promise<void>;
746
- /** Remove a document from the index. */
747
- remove(key: string): Promise<void>;
748
- /** Atomic field update without re-embedding. For metadata-only changes. */
749
- transform(key: string, operations: SearchTransformOp[]): Promise<void>;
750
- /** Search this plugin's content type. */
751
- query(params: SearchQueryParams): Promise<SearchResponse>;
752
- /** Global search adapter and registered-table health snapshot. */
753
- health?(): Promise<SearchHealthSnapshot>;
505
+ export interface AssetsAPI {
506
+ createAsset(input: AssetCreateInput): Promise<VersionedAssetRef>;
507
+ /** Read an asset's current-version summary by id (metadata: type/description/tags/etc.), or null. */
508
+ getAsset(assetId: string): Promise<AssetSummary | null>;
509
+ addVersion(assetId: string, input: AssetVersionCreateInput): Promise<VersionedAssetRef>;
510
+ addExport(assetId: string, input: AssetExportRequest): Promise<{
511
+ name: string;
512
+ file: string;
513
+ }>;
514
+ resolveVersionFile(assetId: string, version?: number): Promise<AssetVersionFileRef | null>;
515
+ /** List asset summaries, optionally filtered by type and/or owning task. */
516
+ listAssets(filter?: {
517
+ type?: AssetTypeName;
518
+ taskId?: string;
519
+ }): Promise<AssetSummary[]>;
520
+ /** Read an asset's version history (current pointer + per-version detail), or null. */
521
+ getAssetVersions(assetId: string): Promise<{
522
+ currentVersion: number;
523
+ versions: AssetVersionDetail[];
524
+ } | null>;
525
+ /**
526
+ * Source-path-keyed upsert: create v1 if no asset tracks `sourcePath`,
527
+ * append a version if its content changed, or no-op if identical
528
+ * (`changed: false`). A path inside the asset store reflects to the asset
529
+ * it already belongs to — never a duplicate.
530
+ */
531
+ upsertFromSource(sourcePath: string, input: AssetCreateInput): Promise<VersionedAssetRef & {
532
+ changed: boolean;
533
+ }>;
754
534
  /**
755
- * Plugin-scoped maintenance operations for indexers that own non-file-backed
756
- * tables. This is intentionally narrower than the raw adapter: callers can
757
- * only touch their own registered content type.
535
+ * Map an absolute path INSIDE the asset store back to its asset identity.
536
+ * `absPath` in the result is always the REAL version file (never the thumb).
537
+ * Null for anything outside the store or store-internal non-version files.
758
538
  */
759
- maintenance?: SearchMaintenanceAPI;
760
- }
761
- export interface SearchMaintenanceAPI {
762
- /** Whether the backing search service is reachable. */
763
- available(): Promise<boolean>;
764
- /** Iterate every document in this plugin's registered content type. */
765
- scan(): AsyncIterable<{
766
- key: string;
767
- document: Record<string, unknown>;
768
- }>;
769
- /** Remove several documents from this plugin's registered content type. */
770
- batchRemove(keys: string[]): Promise<number>;
771
- /** Drop and recreate this plugin's registered content type table. */
772
- resetContentType(): Promise<void>;
539
+ resolveStoreFile(absPath: string): Promise<(VersionedAssetRef & {
540
+ absPath: string;
541
+ }) | null>;
773
542
  }
543
+ export type { SearchSchemaField, SearchIndexDefinition, SearchContentTypeDefinition, SearchQueryParams, SearchResult, SearchResponse, SearchHealthIndex, SearchHealthTable, SearchHealthSnapshot, SearchReindexItem, SearchTransformOp, SearchScanOptions, FilePatternMapper, FileBackedContentTypeDefinition, SearchAPI, SearchMaintenanceAPI, } from '@makinbakin/sdk/types';
774
544
  interface BaseSettingsField {
775
545
  key: string;
776
546
  label: string;
@@ -818,7 +588,16 @@ export interface ListSettingsField extends BaseSettingsField {
818
588
  */
819
589
  uniqueField?: string;
820
590
  }
821
- export type SettingsField = StringSettingsField | NumberSettingsField | BooleanSettingsField | SelectSettingsField | ListSettingsField;
591
+ /**
592
+ * Per-agent on/off grid. Renders every roster agent with its avatar and a
593
+ * toggle; the persisted value is the array of enabled agent ids. Reusable by
594
+ * any plugin that gates a feature per agent.
595
+ */
596
+ export interface AgentTogglesSettingsField extends BaseSettingsField {
597
+ type: 'agent-toggles';
598
+ default?: string[];
599
+ }
600
+ export type SettingsField = StringSettingsField | NumberSettingsField | BooleanSettingsField | SelectSettingsField | ListSettingsField | AgentTogglesSettingsField;
822
601
  export interface PluginSettingsSchema {
823
602
  fields: SettingsField[];
824
603
  }
@@ -833,6 +612,18 @@ export interface BakinPlugin {
833
612
  onShutdown?(): void | Promise<void>;
834
613
  /** Called when this plugin's settings are updated */
835
614
  onSettingsChange?(settings: Record<string, unknown>): void | Promise<void>;
615
+ /**
616
+ * Validate a whole settings document BEFORE the generic
617
+ * `PUT /api/plugin-settings/{id}` writes it. A plugin whose settings are
618
+ * money or policy (the spend plugin) refuses documents its own routes
619
+ * would refuse, so no side door can leave an invalid file on disk.
620
+ */
621
+ validateSettings?(value: unknown): {
622
+ ok: true;
623
+ } | {
624
+ ok: false;
625
+ error: string;
626
+ };
836
627
  /**
837
628
  * Called by `bakin plugins remove` BEFORE Bakin tears down the plugin's
838
629
  * own bookkeeping (registry rows, settings JSON, plugin dir, etc.).
@@ -846,6 +637,8 @@ export interface BakinPlugin {
846
637
  * a half-removed state.
847
638
  */
848
639
  onUninstall?(ctx: PluginContext): void | Promise<void>;
640
+ /** Preflight before destructive removal. A rejection aborts removal. */
641
+ beforeUninstall?(ctx: PluginContext): void | Promise<void>;
849
642
  /** Declarative settings schema for auto-generated settings UI */
850
643
  settingsSchema?: PluginSettingsSchema;
851
644
  navItems?: NavItem[];
@@ -859,52 +652,7 @@ export interface BakinPlugin {
859
652
  * a bare `routes: APIRoute[]` annotation widens types and breaks the
860
653
  * per-route inference that drives the dispatcher's typed `parsed` argument.
861
654
  *
862
- * Optional during the migration window (T1–T16); plugins still using
863
- * `ctx.registerRoute(...)` from `activate()` continue to work via the
864
- * dispatcher adapter.
865
655
  */
866
656
  routes?: ReadonlyArray<DeclarativeAPIRoute<PluginContextLite, any, any, any>>;
867
657
  }
868
- export interface PluginManifestSignature {
869
- algorithm: 'ed25519';
870
- signer: string;
871
- publicKey: string;
872
- signature: string;
873
- }
874
- export interface SecretDeclaration {
875
- /** Canonical environment variable name, for example `ANTHROPIC_API_KEY`. */
876
- name: string;
877
- /** Human-readable setup note. Never include a secret value here. */
878
- description: string;
879
- /** Missing required secrets should be reported by setup/health checks. Defaults to true. */
880
- required: boolean;
881
- }
882
- export interface PluginManifest {
883
- id: string;
884
- name: string;
885
- version: string;
886
- bakin: string;
887
- description: string;
888
- entry: {
889
- server: string;
890
- client?: string;
891
- };
892
- contentFiles?: string[];
893
- secrets?: SecretDeclaration[];
894
- tests?: string;
895
- dependencies?: string[];
896
- permissions?: string[];
897
- signature?: PluginManifestSignature;
898
- }
899
- export interface PluginEntry {
900
- path: string;
901
- enabled?: boolean;
902
- }
903
- export interface BakinConfig {
904
- plugins: PluginEntry[];
905
- theme?: Record<string, string>;
906
- storage?: {
907
- contentDir?: string;
908
- };
909
- }
910
- export {};
658
+ export type { PluginManifestSignature, SecretDeclaration, PluginManifest, PluginEntry, BakinConfig, } from '@makinbakin/sdk/types';