@makinbakin/sdk 0.0.1-rc.20 → 0.0.1-rc.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/_internal/app/components/agent-select.d.ts +10 -1
  2. package/_internal/app/components/asset-picker.d.ts +25 -0
  3. package/_internal/app/components/charts/bar-chart.d.ts +16 -0
  4. package/_internal/app/components/charts/chart-data-table.d.ts +31 -0
  5. package/_internal/app/components/charts/chart-explainer.d.ts +9 -0
  6. package/_internal/app/components/charts/chart-tooltip.d.ts +8 -0
  7. package/_internal/app/components/charts/line-chart.d.ts +13 -0
  8. package/_internal/app/components/charts/palette.d.ts +24 -0
  9. package/_internal/app/components/charts/sparkline.d.ts +12 -0
  10. package/_internal/app/components/charts/stacked-column-chart.d.ts +40 -0
  11. package/_internal/app/components/confirm-dialog.d.ts +23 -2
  12. package/_internal/app/components/conversation/activity-group.d.ts +15 -0
  13. package/_internal/app/components/conversation/agent-turn.d.ts +36 -0
  14. package/_internal/app/components/conversation/attention.d.ts +56 -0
  15. package/_internal/app/components/conversation/composer.d.ts +35 -0
  16. package/_internal/app/components/conversation/conversation-empty-state.d.ts +8 -0
  17. package/_internal/app/components/conversation/conversation-panel.d.ts +33 -0
  18. package/_internal/app/components/conversation/conversation.d.ts +14 -0
  19. package/_internal/app/components/conversation/fold.d.ts +129 -0
  20. package/_internal/app/components/conversation/notification-sound.d.ts +8 -0
  21. package/_internal/app/components/conversation/relative-time.d.ts +8 -0
  22. package/_internal/app/components/conversation/reply-toast.d.ts +15 -0
  23. package/_internal/app/components/conversation/thread-id.d.ts +8 -0
  24. package/_internal/app/components/conversation/tool-call-drawer.d.ts +7 -0
  25. package/_internal/app/components/conversation/turn-recorder.d.ts +37 -0
  26. package/_internal/app/components/conversation/use-conversation-attention.d.ts +64 -0
  27. package/_internal/app/components/conversation/use-conversation-thread.d.ts +55 -0
  28. package/_internal/app/components/conversation/user-message.d.ts +11 -0
  29. package/_internal/app/components/danger-zone.d.ts +28 -0
  30. package/_internal/app/components/empty-state.d.ts +5 -2
  31. package/_internal/app/components/plugin-header.d.ts +4 -3
  32. package/_internal/app/components/save-bar.d.ts +32 -0
  33. package/_internal/app/components/score-overlay.d.ts +33 -0
  34. package/_internal/app/components/search-degraded-chip.d.ts +4 -0
  35. package/_internal/app/components/search-partial-chip.d.ts +13 -0
  36. package/_internal/app/components/search-unavailable.d.ts +12 -0
  37. package/_internal/app/components/section-card.d.ts +22 -0
  38. package/_internal/app/components/segmented-control.d.ts +28 -0
  39. package/_internal/app/components/stat-tile.d.ts +26 -0
  40. package/_internal/app/components/status-badge.d.ts +19 -0
  41. package/_internal/app/components/turn-output-view.d.ts +57 -0
  42. package/_internal/app/components/ui/button.d.ts +1 -1
  43. package/_internal/app/components/underline-tabs.d.ts +6 -2
  44. package/_internal/app/components/unsaved-changes-guard.d.ts +34 -0
  45. package/_internal/app/core/conversation-turns.d.ts +148 -0
  46. package/_internal/app/core/logger.d.ts +1 -0
  47. package/_internal/app/hooks/use-file-drop.d.ts +25 -0
  48. package/_internal/app/hooks/use-history-back.d.ts +1 -0
  49. package/_internal/app/hooks/use-json-fetch.d.ts +5 -0
  50. package/_internal/app/hooks/use-query-state.d.ts +2 -0
  51. package/_internal/app/hooks/use-schedule.d.ts +45 -0
  52. package/_internal/app/hooks/use-search.d.ts +27 -8
  53. package/_internal/app/hooks/use-toast.d.ts +3 -3
  54. package/_internal/app/lib/browser-notify.d.ts +12 -1
  55. package/_internal/core/adapters/runtime/concepts.d.ts +547 -49
  56. package/_internal/core/adapters/runtime/errors.d.ts +13 -1
  57. package/_internal/core/adapters/runtime/helpers.d.ts +19 -0
  58. package/_internal/core/adapters/runtime/index.d.ts +5 -2
  59. package/_internal/core/adapters/runtime/testing.d.ts +79 -0
  60. package/_internal/core/adapters/runtime/turn-activity.d.ts +23 -0
  61. package/_internal/core/adapters/shared.d.ts +122 -12
  62. package/_internal/core/content-dir.d.ts +8 -0
  63. package/_internal/core/docs/route.d.ts +1 -1
  64. package/_internal/core/format/structured.d.ts +44 -0
  65. package/_internal/core/format.d.ts +5 -1
  66. package/_internal/core/media/downscale.d.ts +18 -0
  67. package/_internal/core/media/sharp-loader.d.ts +36 -0
  68. package/_internal/core/plugin-types.d.ts +102 -39
  69. package/_internal/core/routing/define.d.ts +26 -3
  70. package/_internal/core/routing/dispatcher.d.ts +15 -6
  71. package/_internal/core/routing/index.d.ts +1 -1
  72. package/_internal/core/routing/types.d.ts +13 -70
  73. package/_internal/core/storage/atomic-write.d.ts +11 -0
  74. package/_internal/core/tasks/store.d.ts +129 -0
  75. package/_internal/core/tasks/testing.d.ts +2 -0
  76. package/_internal/{plugins/workflows/lib → core/workflows}/notification-channel-registry.d.ts +1 -1
  77. package/_internal/plugins/team/types.d.ts +47 -0
  78. package/_internal/plugins/workflows/hooks/use-notification-channels.d.ts +1 -1
  79. package/components/index.d.ts +87 -19
  80. package/components/index.js +32904 -15368
  81. package/hooks/index.d.ts +24 -4
  82. package/hooks/index.js +837 -561
  83. package/hooks/router.d.ts +20 -4
  84. package/index.d.ts +5 -50
  85. package/index.js +223 -406
  86. package/internal/index.d.ts +70 -0
  87. package/internal/index.js +409 -0
  88. package/package.json +9 -2
  89. package/register.d.ts +19 -1
  90. package/routing/index.js +175 -147
  91. package/slots/index.js +20 -1
  92. package/testing/index.d.ts +122 -0
  93. package/testing/index.js +21874 -0
  94. package/types/index.d.ts +4 -0
  95. package/types/index.js +16 -0
  96. package/utils/index.d.ts +28 -25
  97. package/utils/index.js +279 -263
  98. package/_internal/app/components/integrated-brainstorm/activity.d.ts +0 -23
  99. package/_internal/app/components/integrated-brainstorm/collapsed-header.d.ts +0 -14
  100. package/_internal/app/components/integrated-brainstorm/empty-state.d.ts +0 -5
  101. package/_internal/app/components/integrated-brainstorm/index.d.ts +0 -8
  102. package/_internal/app/components/integrated-brainstorm/input-row.d.ts +0 -16
  103. package/_internal/app/components/integrated-brainstorm/message-list.d.ts +0 -8
  104. package/_internal/app/components/integrated-brainstorm/session.d.ts +0 -16
  105. package/_internal/app/components/integrated-brainstorm/sse.d.ts +0 -8
  106. package/_internal/app/components/integrated-brainstorm/thinking-indicator.d.ts +0 -19
  107. package/_internal/app/components/integrated-brainstorm/types.d.ts +0 -63
  108. package/_internal/app/components/integrated-brainstorm/use-auto-grow.d.ts +0 -6
  109. package/_internal/app/components/integrated-brainstorm/use-brainstorm-state.d.ts +0 -21
  110. /package/_internal/{plugins/models → app}/hooks/use-available-models.d.ts +0 -0
package/index.js CHANGED
@@ -13,6 +13,19 @@ var __export = (target, all) => {
13
13
  set: __exportSetter.bind(all, name)
14
14
  });
15
15
  };
16
+ // packages/sdk/src/types/health.ts
17
+ var HEALTH_INCIDENT_CLASSES = [
18
+ "service_failure",
19
+ "data_integrity",
20
+ "budget_block",
21
+ "evidence_gap",
22
+ "usage_anomaly",
23
+ "unattributed_usage",
24
+ "runaway_usage",
25
+ "cleanup_backlog",
26
+ "policy_denial",
27
+ "unsupported_surface"
28
+ ];
16
29
  // packages/sdk/src/slots/registry.ts
17
30
  function getRegistry() {
18
31
  const g = globalThis;
@@ -28,16 +41,6 @@ function registerSlot(name, component, order = 100, owner) {
28
41
  entries.sort((a, b) => a.order - b.order);
29
42
  reg.set(name, entries);
30
43
  }
31
- function clearSlotsOwnedBy(pluginId) {
32
- const reg = getRegistry();
33
- for (const [name, entries] of reg.entries()) {
34
- const filtered = entries.filter((e) => e.owner !== pluginId);
35
- if (filtered.length === 0)
36
- reg.delete(name);
37
- else
38
- reg.set(name, filtered);
39
- }
40
- }
41
44
 
42
45
  // packages/sdk/src/register.ts
43
46
  "use client";
@@ -66,7 +69,10 @@ function getRegistry2() {
66
69
  listeners: new Set,
67
70
  badgesByPlugin: new Map,
68
71
  badgesSnapshot: new Map,
69
- badgeListeners: new Set
72
+ badgeListeners: new Set,
73
+ hitRenderersByPlugin: new Map,
74
+ hitRenderersSnapshot: new Map,
75
+ hitRendererListeners: new Set
70
76
  };
71
77
  }
72
78
  const registry = g.__bakinClientRegistry;
@@ -81,8 +87,35 @@ function getRegistry2() {
81
87
  registry.badgesSnapshot = buildBadgesSnapshot(registry);
82
88
  if (!registry.badgeListeners)
83
89
  registry.badgeListeners = new Set;
90
+ if (!registry.hitRenderersByPlugin)
91
+ registry.hitRenderersByPlugin = new Map;
92
+ if (!registry.hitRenderersSnapshot)
93
+ registry.hitRenderersSnapshot = buildHitRenderersSnapshot(registry);
94
+ if (!registry.hitRendererListeners)
95
+ registry.hitRendererListeners = new Set;
84
96
  return registry;
85
97
  }
98
+ function buildHitRenderersSnapshot(registry) {
99
+ const snapshot = new Map;
100
+ for (const byType of registry.hitRenderersByPlugin.values()) {
101
+ for (const [type, renderer] of byType) {
102
+ if (!snapshot.has(type))
103
+ snapshot.set(type, renderer);
104
+ }
105
+ }
106
+ return snapshot;
107
+ }
108
+ function bumpHitRenderers() {
109
+ const registry = getRegistry2();
110
+ registry.hitRenderersSnapshot = buildHitRenderersSnapshot(registry);
111
+ for (const l of registry.hitRendererListeners) {
112
+ try {
113
+ l();
114
+ } catch (err) {
115
+ console.error("[bakin] hit-renderer listener threw:", err);
116
+ }
117
+ }
118
+ }
86
119
  function buildBadgesSnapshot(registry) {
87
120
  const snapshot = new Map;
88
121
  for (const byNavItemId of registry.badgesByPlugin.values()) {
@@ -133,28 +166,11 @@ function registerPlugin(reg) {
133
166
  registerSlot(slotName, component, 100, reg.id);
134
167
  }
135
168
  }
136
- bumpVersion();
137
- }
138
- function unregisterPlugin(id) {
139
- const registry = getRegistry2();
140
- const cleanups = registry.cleanupByPlugin.get(id);
141
- if (cleanups) {
142
- for (const fn of cleanups) {
143
- try {
144
- fn();
145
- } catch (err) {
146
- console.error(`[bakin] cleanup fn for ${id} threw:`, err);
147
- }
148
- }
149
- registry.cleanupByPlugin.delete(id);
169
+ if (reg.search?.hitRenderers && Object.keys(reg.search.hitRenderers).length > 0) {
170
+ registry.hitRenderersByPlugin.set(reg.id, new Map(Object.entries(reg.search.hitRenderers)));
171
+ bumpHitRenderers();
150
172
  }
151
- registry.navByPlugin.delete(id);
152
- registry.routesByPlugin.delete(id);
153
- clearSlotsOwnedBy(id);
154
- const hadBadges = registry.badgesByPlugin.delete(id);
155
173
  bumpVersion();
156
- if (hadBadges)
157
- bumpBadges();
158
174
  }
159
175
  function registerPluginCleanup(id, fn) {
160
176
  const registry = getRegistry2();
@@ -162,42 +178,6 @@ function registerPluginCleanup(id, fn) {
162
178
  list.push(fn);
163
179
  registry.cleanupByPlugin.set(id, list);
164
180
  }
165
- function setManifestNav(pluginId, navItems) {
166
- const registry = getRegistry2();
167
- if (!navItems || navItems.length === 0) {
168
- if (!registry.manifestNavByPlugin.delete(pluginId))
169
- return;
170
- bumpVersion();
171
- return;
172
- }
173
- const prev = registry.manifestNavByPlugin.get(pluginId);
174
- if (prev && JSON.stringify(prev) === JSON.stringify(navItems))
175
- return;
176
- registry.manifestNavByPlugin.set(pluginId, navItems);
177
- bumpVersion();
178
- }
179
- function getManifestNav(pluginId) {
180
- return getRegistry2().manifestNavByPlugin.get(pluginId) ?? [];
181
- }
182
- function getRegistryVersion() {
183
- return getRegistry2().version;
184
- }
185
- function subscribeRegistry(listener) {
186
- const registry = getRegistry2();
187
- registry.listeners.add(listener);
188
- return () => {
189
- registry.listeners.delete(listener);
190
- };
191
- }
192
- function getAllNavItems() {
193
- return [...getRegistry2().navItemsSnapshot];
194
- }
195
- function getNavItemsSnapshot() {
196
- return getRegistry2().navItemsSnapshot;
197
- }
198
- function getPluginNavItems(pluginId) {
199
- return getRegistry2().navByPlugin.get(pluginId) ?? [];
200
- }
201
181
  function setNavBadge(pluginId, navItemId, badge) {
202
182
  const registry = getRegistry2();
203
183
  let plugin = registry.badgesByPlugin.get(pluginId);
@@ -223,319 +203,6 @@ function setNavBadge(pluginId, navItemId, badge) {
223
203
  function getNavBadge(navItemId) {
224
204
  return getRegistry2().badgesSnapshot.get(navItemId);
225
205
  }
226
- function getNavBadgesSnapshot() {
227
- return getRegistry2().badgesSnapshot;
228
- }
229
- function subscribeNavBadges(listener) {
230
- const registry = getRegistry2();
231
- registry.badgeListeners.add(listener);
232
- return () => {
233
- registry.badgeListeners.delete(listener);
234
- };
235
- }
236
- function normalizePattern(pattern) {
237
- return pattern.split("/").filter(Boolean);
238
- }
239
- function matchRoutePattern(pattern, pathname) {
240
- const patternSegments = normalizePattern(pattern);
241
- const pathSegments = normalizePattern(pathname);
242
- if (patternSegments.length !== pathSegments.length)
243
- return null;
244
- const params = {};
245
- let score = 0;
246
- for (let i = 0;i < patternSegments.length; i++) {
247
- const patternSegment = patternSegments[i];
248
- const pathSegment = pathSegments[i];
249
- const bracket = patternSegment.match(/^\[([^\]]+)\]$/);
250
- const isColon = patternSegment.startsWith(":");
251
- const isDollar = patternSegment.startsWith("$");
252
- if (bracket || isColon || isDollar) {
253
- const key = bracket?.[1] ?? patternSegment.slice(1);
254
- params[key] = decodeURIComponent(pathSegment);
255
- continue;
256
- }
257
- if (patternSegment !== pathSegment)
258
- return null;
259
- score += 1;
260
- }
261
- return { params, score };
262
- }
263
- function getPluginRoute(pathname) {
264
- const registry = getRegistry2();
265
- let best = null;
266
- for (const [pluginId, routes] of registry.routesByPlugin.entries()) {
267
- for (const route2 of routes) {
268
- const match = matchRoutePattern(route2.path, pathname);
269
- if (!match)
270
- continue;
271
- if (!best || match.score > best.score) {
272
- best = {
273
- pluginId,
274
- path: route2.path,
275
- component: route2.component,
276
- params: match.params,
277
- score: match.score
278
- };
279
- }
280
- }
281
- }
282
- if (!best)
283
- return null;
284
- const { score: _score, ...route } = best;
285
- return route;
286
- }
287
- function getPluginRoutes(pluginId) {
288
- const registry = getRegistry2();
289
- if (pluginId)
290
- return registry.routesByPlugin.get(pluginId) ?? [];
291
- return [...registry.routesByPlugin.values()].flat();
292
- }
293
- // packages/sdk/src/lazy.ts
294
- "use client";
295
- function getStore() {
296
- const g = globalThis;
297
- if (!g.__bakinLazyPluginStore) {
298
- g.__bakinLazyPluginStore = {
299
- ownersBySlot: new Map,
300
- routeOwners: [],
301
- states: new Map,
302
- errors: new Map,
303
- loader: null,
304
- version: 0,
305
- listeners: new Set
306
- };
307
- }
308
- return g.__bakinLazyPluginStore;
309
- }
310
- function bump() {
311
- const store = getStore();
312
- store.version++;
313
- for (const l of store.listeners) {
314
- try {
315
- l();
316
- } catch (err) {
317
- console.error("[bakin] lazy-plugin listener threw:", err);
318
- }
319
- }
320
- }
321
- function configureLazyPlugins(index) {
322
- const store = getStore();
323
- store.ownersBySlot = new Map(index.slotOwners);
324
- store.routeOwners = [...index.routeOwners];
325
- bump();
326
- }
327
- function setLazyPluginLoader(loader) {
328
- getStore().loader = loader;
329
- }
330
- function setPluginLoadState(pluginId, state, error) {
331
- const store = getStore();
332
- if (store.states.get(pluginId) === state && store.errors.get(pluginId) === error)
333
- return;
334
- store.states.set(pluginId, state);
335
- if (state === "error" && error)
336
- store.errors.set(pluginId, error);
337
- else
338
- store.errors.delete(pluginId);
339
- bump();
340
- }
341
- function getPluginLoadState(pluginId) {
342
- return getStore().states.get(pluginId) ?? "idle";
343
- }
344
- function getPluginLoadError(pluginId) {
345
- return getStore().errors.get(pluginId);
346
- }
347
- function getSlotOwners(name) {
348
- return getStore().ownersBySlot.get(name) ?? [];
349
- }
350
- function getRouteOwners(pathname) {
351
- const owners = [];
352
- for (const { pattern, pluginId } of getStore().routeOwners) {
353
- if (matchRoutePattern(pattern, pathname) && !owners.includes(pluginId)) {
354
- owners.push(pluginId);
355
- }
356
- }
357
- return owners;
358
- }
359
- function demand(pluginIds) {
360
- const store = getStore();
361
- if (!store.loader)
362
- return;
363
- for (const pluginId of pluginIds) {
364
- if ((store.states.get(pluginId) ?? "idle") !== "idle")
365
- continue;
366
- store.loader(pluginId);
367
- }
368
- }
369
- function requestSlotPlugins(name) {
370
- demand(getSlotOwners(name));
371
- }
372
- function requestRoutePlugins(pathname) {
373
- demand(getRouteOwners(pathname));
374
- }
375
- function retryPluginLoad(pluginId) {
376
- const store = getStore();
377
- if (store.states.get(pluginId) !== "error")
378
- return;
379
- store.states.set(pluginId, "idle");
380
- store.errors.delete(pluginId);
381
- bump();
382
- demand([pluginId]);
383
- }
384
- function getLazyPluginsVersion() {
385
- return getStore().version;
386
- }
387
- function subscribeLazyPlugins(listener) {
388
- const store = getStore();
389
- store.listeners.add(listener);
390
- return () => {
391
- store.listeners.delete(listener);
392
- };
393
- }
394
- // packages/core/src/routing/define.ts
395
- function defineRoute(route) {
396
- return route;
397
- }
398
- function defineCoreRoute(route) {
399
- return route;
400
- }
401
- function definePlugin(plugin) {
402
- return plugin;
403
- }
404
- // packages/core/src/routing/operation-id.ts
405
- function operationIdFor(scope, method, path) {
406
- return `${scope}.${method.toLowerCase()}.${slugifyPath(path)}`;
407
- }
408
- function slugifyPath(path) {
409
- const trimmed = path.replace(/^\/+/, "").replace(/\/+$/, "");
410
- if (trimmed === "")
411
- return "root";
412
- const segments = trimmed.split("/").map((seg) => {
413
- if (seg.startsWith(":"))
414
- return camelToKebab(seg.slice(1));
415
- if (seg.startsWith("{") && seg.endsWith("}"))
416
- return camelToKebab(seg.slice(1, -1));
417
- return camelToKebab(seg);
418
- }).filter(Boolean);
419
- return segments.join("-");
420
- }
421
- function camelToKebab(input) {
422
- return input.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[^a-zA-Z0-9-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").toLowerCase();
423
- }
424
-
425
- // packages/core/src/routing/registry.ts
426
- function parseSegments(path) {
427
- return path.split("/").filter(Boolean).map((seg) => {
428
- if (seg === "*" || seg.startsWith("..."))
429
- return { kind: "wildcard" };
430
- if (seg.startsWith(":"))
431
- return { kind: "param", name: seg.slice(1) };
432
- if (seg.startsWith("{") && seg.endsWith("}")) {
433
- return { kind: "param", name: seg.slice(1, -1) };
434
- }
435
- return { kind: "literal", value: seg };
436
- });
437
- }
438
- function specificityScore(segments) {
439
- let score = 0;
440
- for (const seg of segments) {
441
- if (seg.kind === "literal")
442
- score += 2;
443
- else if (seg.kind === "param")
444
- score += 1;
445
- }
446
- return score;
447
- }
448
- function matchSegments(pathSegments, routeSegments) {
449
- const lastIsWildcard = routeSegments.length > 0 && routeSegments[routeSegments.length - 1].kind === "wildcard";
450
- if (!lastIsWildcard && pathSegments.length !== routeSegments.length)
451
- return null;
452
- if (lastIsWildcard && pathSegments.length < routeSegments.length - 1)
453
- return null;
454
- const params = {};
455
- for (let i = 0;i < routeSegments.length; i++) {
456
- const rseg = routeSegments[i];
457
- if (rseg.kind === "wildcard")
458
- return params;
459
- const pseg = pathSegments[i];
460
- if (rseg.kind === "literal") {
461
- if (rseg.value !== pseg)
462
- return null;
463
- } else {
464
- params[rseg.name] = pseg;
465
- }
466
- }
467
- return params;
468
- }
469
-
470
- class RouteRegistry {
471
- byMethod = new Map;
472
- operationIds = new Set;
473
- fullPaths = new Set;
474
- register(input) {
475
- const { route } = input;
476
- const pluginId = input.scope === "plugin" ? input.pluginId : null;
477
- const fullPath = pluginId !== null ? `/api/plugins/${pluginId}${route.path}` : route.path;
478
- const operationId = route.operationId ?? operationIdFor(pluginId ?? "core", route.method, route.path);
479
- const dupKey = `${route.method} ${fullPath}`;
480
- if (this.fullPaths.has(dupKey)) {
481
- throw new Error(`duplicate route registration: ${dupKey}`);
482
- }
483
- if (this.operationIds.has(operationId)) {
484
- throw new Error(`duplicate operationId: ${operationId} (route: ${dupKey})`);
485
- }
486
- this.fullPaths.add(dupKey);
487
- this.operationIds.add(operationId);
488
- const segments = parseSegments(fullPath);
489
- const indexed = {
490
- registered: {
491
- route,
492
- scope: pluginId ?? "core",
493
- fullPath,
494
- operationId
495
- },
496
- segments,
497
- score: specificityScore(segments)
498
- };
499
- let bucket = this.byMethod.get(route.method);
500
- if (!bucket) {
501
- bucket = [];
502
- this.byMethod.set(route.method, bucket);
503
- }
504
- bucket.push(indexed);
505
- bucket.sort((a, b) => b.score - a.score);
506
- return indexed.registered;
507
- }
508
- match(method, path) {
509
- const bucket = this.byMethod.get(method);
510
- if (!bucket)
511
- return null;
512
- const normalized = path.replace(/\/+$/, "") || "/";
513
- const pathSegments = normalized.split("/").filter(Boolean);
514
- for (const indexed of bucket) {
515
- const params = matchSegments(pathSegments, indexed.segments);
516
- if (params !== null) {
517
- return {
518
- ...indexed.registered,
519
- params
520
- };
521
- }
522
- }
523
- return null;
524
- }
525
- all() {
526
- const out = [];
527
- for (const bucket of this.byMethod.values()) {
528
- for (const entry of bucket)
529
- out.push(entry.registered);
530
- }
531
- return out;
532
- }
533
- clear() {
534
- this.byMethod.clear();
535
- this.operationIds.clear();
536
- this.fullPaths.clear();
537
- }
538
- }
539
206
  // node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/external.js
540
207
  var exports_external = {};
541
208
  __export(exports_external, {
@@ -14137,9 +13804,13 @@ function getBakinPaths() {
14137
13804
  inbox: join(home, "inbox"),
14138
13805
  tasks: join(home, "tasks"),
14139
13806
  workflows: join(home, "workflows"),
13807
+ brands: join(home, "brands"),
13808
+ chat: join(home, "chat"),
14140
13809
  settings: join(home, "settings.json"),
14141
13810
  logs: join(home, "logs"),
14142
- db: join(home, "bakin.db")
13811
+ antfly: join(home, "antfly"),
13812
+ db: join(home, "bakin.db"),
13813
+ bin: join(home, "bin")
14143
13814
  };
14144
13815
  }
14145
13816
 
@@ -14311,7 +13982,6 @@ function suppressPrettyInfo(entry) {
14311
13982
  "search-cleanup",
14312
13983
  "search-startup",
14313
13984
  "hot-reload-coordinator",
14314
- "mcporter",
14315
13985
  "dispatch",
14316
13986
  "dispatch-state",
14317
13987
  "dispatch-turns",
@@ -14412,6 +14082,176 @@ function createLogger(module) {
14412
14082
 
14413
14083
  // packages/core/src/routing/dispatcher.ts
14414
14084
  var log = createLogger("dispatcher");
14085
+ var VALID_BODY_CONTENT_TYPES = ["application/json", "multipart/form-data", "*/*", "none"];
14086
+ function assertValidBodySpec(body, label) {
14087
+ if (body === undefined || body === null)
14088
+ return;
14089
+ if (isZodType(body))
14090
+ return;
14091
+ if (typeof body !== "object" || !("contentType" in body)) {
14092
+ throw new Error(`route ${label}: body spec must be a zod schema or declare a contentType (got ${JSON.stringify(body)})`);
14093
+ }
14094
+ const ct = body.contentType;
14095
+ if (!VALID_BODY_CONTENT_TYPES.includes(ct)) {
14096
+ throw new Error(`route ${label}: unknown body contentType '${String(ct)}' \u2014 valid values: ${VALID_BODY_CONTENT_TYPES.join(", ")}`);
14097
+ }
14098
+ if (ct === "application/json" && !isZodType(body.schema)) {
14099
+ throw new Error(`route ${label}: contentType 'application/json' requires a zod schema`);
14100
+ }
14101
+ }
14102
+ function isZodType(value) {
14103
+ if (!value || typeof value !== "object")
14104
+ return false;
14105
+ return value instanceof exports_external.ZodType || typeof value._zod === "object" && value._zod !== null;
14106
+ }
14107
+
14108
+ // packages/core/src/routing/define.ts
14109
+ function defineRoute(route) {
14110
+ assertValidBodySpec(route.body, `${route.method} ${route.path}`);
14111
+ return route;
14112
+ }
14113
+ function defineCoreRoute(route) {
14114
+ assertValidBodySpec(route.body, `${route.method} ${route.path}`);
14115
+ return route;
14116
+ }
14117
+ function definePlugin(plugin) {
14118
+ return plugin;
14119
+ }
14120
+ // packages/core/src/routing/operation-id.ts
14121
+ function operationIdFor(scope, method, path) {
14122
+ return `${scope}.${method.toLowerCase()}.${slugifyPath(path)}`;
14123
+ }
14124
+ function slugifyPath(path) {
14125
+ const trimmed = path.replace(/^\/+/, "").replace(/\/+$/, "");
14126
+ if (trimmed === "")
14127
+ return "root";
14128
+ const segments = trimmed.split("/").map((seg) => {
14129
+ if (seg.startsWith(":"))
14130
+ return camelToKebab(seg.slice(1));
14131
+ if (seg.startsWith("{") && seg.endsWith("}"))
14132
+ return camelToKebab(seg.slice(1, -1));
14133
+ return camelToKebab(seg);
14134
+ }).filter(Boolean);
14135
+ return segments.join("-");
14136
+ }
14137
+ function camelToKebab(input) {
14138
+ return input.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[^a-zA-Z0-9-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").toLowerCase();
14139
+ }
14140
+
14141
+ // packages/core/src/routing/registry.ts
14142
+ function parseSegments(path) {
14143
+ return path.split("/").filter(Boolean).map((seg) => {
14144
+ if (seg === "*" || seg.startsWith("..."))
14145
+ return { kind: "wildcard" };
14146
+ if (seg.startsWith(":"))
14147
+ return { kind: "param", name: seg.slice(1) };
14148
+ if (seg.startsWith("{") && seg.endsWith("}")) {
14149
+ return { kind: "param", name: seg.slice(1, -1) };
14150
+ }
14151
+ return { kind: "literal", value: seg };
14152
+ });
14153
+ }
14154
+ function specificityScore(segments) {
14155
+ let score = 0;
14156
+ for (const seg of segments) {
14157
+ if (seg.kind === "literal")
14158
+ score += 2;
14159
+ else if (seg.kind === "param")
14160
+ score += 1;
14161
+ }
14162
+ return score;
14163
+ }
14164
+ function matchSegments(pathSegments, routeSegments) {
14165
+ const lastIsWildcard = routeSegments.length > 0 && routeSegments[routeSegments.length - 1].kind === "wildcard";
14166
+ if (!lastIsWildcard && pathSegments.length !== routeSegments.length)
14167
+ return null;
14168
+ if (lastIsWildcard && pathSegments.length < routeSegments.length - 1)
14169
+ return null;
14170
+ const params = {};
14171
+ for (let i = 0;i < routeSegments.length; i++) {
14172
+ const rseg = routeSegments[i];
14173
+ if (rseg.kind === "wildcard")
14174
+ return params;
14175
+ const pseg = pathSegments[i];
14176
+ if (rseg.kind === "literal") {
14177
+ if (rseg.value !== pseg)
14178
+ return null;
14179
+ } else {
14180
+ params[rseg.name] = pseg;
14181
+ }
14182
+ }
14183
+ return params;
14184
+ }
14185
+
14186
+ class RouteRegistry {
14187
+ byMethod = new Map;
14188
+ operationIds = new Set;
14189
+ fullPaths = new Set;
14190
+ register(input) {
14191
+ const { route } = input;
14192
+ const pluginId = input.scope === "plugin" ? input.pluginId : null;
14193
+ const fullPath = pluginId !== null ? `/api/plugins/${pluginId}${route.path}` : route.path;
14194
+ const operationId = route.operationId ?? operationIdFor(pluginId ?? "core", route.method, route.path);
14195
+ const dupKey = `${route.method} ${fullPath}`;
14196
+ if (this.fullPaths.has(dupKey)) {
14197
+ throw new Error(`duplicate route registration: ${dupKey}`);
14198
+ }
14199
+ if (this.operationIds.has(operationId)) {
14200
+ throw new Error(`duplicate operationId: ${operationId} (route: ${dupKey})`);
14201
+ }
14202
+ this.fullPaths.add(dupKey);
14203
+ this.operationIds.add(operationId);
14204
+ const segments = parseSegments(fullPath);
14205
+ const indexed = {
14206
+ registered: {
14207
+ route,
14208
+ scope: pluginId ?? "core",
14209
+ fullPath,
14210
+ operationId
14211
+ },
14212
+ segments,
14213
+ score: specificityScore(segments)
14214
+ };
14215
+ let bucket = this.byMethod.get(route.method);
14216
+ if (!bucket) {
14217
+ bucket = [];
14218
+ this.byMethod.set(route.method, bucket);
14219
+ }
14220
+ bucket.push(indexed);
14221
+ bucket.sort((a, b) => b.score - a.score);
14222
+ return indexed.registered;
14223
+ }
14224
+ match(method, path) {
14225
+ const bucket = this.byMethod.get(method);
14226
+ if (!bucket)
14227
+ return null;
14228
+ const normalized = path.replace(/\/+$/, "") || "/";
14229
+ const pathSegments = normalized.split("/").filter(Boolean);
14230
+ for (const indexed of bucket) {
14231
+ const params = matchSegments(pathSegments, indexed.segments);
14232
+ if (params !== null) {
14233
+ return {
14234
+ ...indexed.registered,
14235
+ params
14236
+ };
14237
+ }
14238
+ }
14239
+ return null;
14240
+ }
14241
+ all() {
14242
+ const out = [];
14243
+ for (const bucket of this.byMethod.values()) {
14244
+ for (const entry of bucket)
14245
+ out.push(entry.registered);
14246
+ }
14247
+ return out;
14248
+ }
14249
+ clear() {
14250
+ this.byMethod.clear();
14251
+ this.operationIds.clear();
14252
+ this.fullPaths.clear();
14253
+ }
14254
+ }
14415
14255
  // packages/core/src/routing/search-route.ts
14416
14256
  var searchQuery = exports_external.object({
14417
14257
  q: exports_external.string().min(1),
@@ -14431,35 +14271,12 @@ var searchResponse = exports_external.object({
14431
14271
  });
14432
14272
  var errorResponse = exports_external.object({ error: exports_external.string() });
14433
14273
  export {
14434
- unregisterPlugin,
14435
- subscribeRegistry,
14436
- subscribeNavBadges,
14437
- subscribeLazyPlugins,
14438
- setPluginLoadState,
14439
14274
  setNavBadge,
14440
- setManifestNav,
14441
- setLazyPluginLoader,
14442
- retryPluginLoad,
14443
- requestSlotPlugins,
14444
- requestRoutePlugins,
14445
14275
  registerPluginCleanup,
14446
14276
  registerPlugin,
14447
- getSlotOwners,
14448
- getRouteOwners,
14449
- getRegistryVersion,
14450
- getPluginRoutes,
14451
- getPluginRoute,
14452
- getPluginNavItems,
14453
- getPluginLoadState,
14454
- getPluginLoadError,
14455
- getNavItemsSnapshot,
14456
- getNavBadgesSnapshot,
14457
14277
  getNavBadge,
14458
- getManifestNav,
14459
- getLazyPluginsVersion,
14460
- getAllNavItems,
14461
14278
  defineRoute,
14462
14279
  definePlugin,
14463
14280
  defineCoreRoute,
14464
- configureLazyPlugins
14281
+ HEALTH_INCIDENT_CLASSES
14465
14282
  };