@makinbakin/sdk 0.0.1-rc.2 → 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.
- package/README.md +1 -0
- package/_internal/app/components/agent-select.d.ts +16 -2
- package/_internal/app/components/asset-picker.d.ts +25 -0
- package/_internal/app/components/charts/bar-chart.d.ts +16 -0
- package/_internal/app/components/charts/chart-data-table.d.ts +31 -0
- package/_internal/app/components/charts/chart-explainer.d.ts +9 -0
- package/_internal/app/components/charts/chart-tooltip.d.ts +8 -0
- package/_internal/app/components/charts/line-chart.d.ts +13 -0
- package/_internal/app/components/charts/palette.d.ts +24 -0
- package/_internal/app/components/charts/sparkline.d.ts +12 -0
- package/_internal/app/components/charts/stacked-column-chart.d.ts +40 -0
- package/_internal/app/components/confirm-dialog.d.ts +54 -0
- package/_internal/app/components/conversation/activity-group.d.ts +15 -0
- package/_internal/app/components/conversation/agent-turn.d.ts +36 -0
- package/_internal/app/components/conversation/attention.d.ts +56 -0
- package/_internal/app/components/conversation/composer.d.ts +35 -0
- package/_internal/app/components/conversation/conversation-empty-state.d.ts +8 -0
- package/_internal/app/components/conversation/conversation-panel.d.ts +33 -0
- package/_internal/app/components/conversation/conversation.d.ts +14 -0
- package/_internal/app/components/conversation/fold.d.ts +129 -0
- package/_internal/app/components/conversation/notification-sound.d.ts +8 -0
- package/_internal/app/components/conversation/relative-time.d.ts +8 -0
- package/_internal/app/components/conversation/reply-toast.d.ts +15 -0
- package/_internal/app/components/conversation/thread-id.d.ts +8 -0
- package/_internal/app/components/conversation/tool-call-drawer.d.ts +7 -0
- package/_internal/app/components/conversation/turn-recorder.d.ts +37 -0
- package/_internal/app/components/conversation/use-conversation-attention.d.ts +64 -0
- package/_internal/app/components/conversation/use-conversation-thread.d.ts +55 -0
- package/_internal/app/components/conversation/user-message.d.ts +11 -0
- package/_internal/app/components/danger-zone.d.ts +28 -0
- package/_internal/app/components/empty-state.d.ts +18 -6
- package/_internal/app/components/plugin-header.d.ts +4 -3
- package/_internal/app/components/save-bar.d.ts +32 -0
- package/_internal/app/components/score-overlay.d.ts +33 -0
- package/_internal/app/components/search-degraded-chip.d.ts +4 -0
- package/_internal/app/components/search-partial-chip.d.ts +13 -0
- package/_internal/app/components/search-unavailable.d.ts +12 -0
- package/_internal/app/components/section-card.d.ts +22 -0
- package/_internal/app/components/segmented-control.d.ts +28 -0
- package/_internal/app/components/stat-tile.d.ts +26 -0
- package/_internal/app/components/status-badge.d.ts +19 -0
- package/_internal/app/components/turn-output-view.d.ts +57 -0
- package/_internal/app/components/ui/badge.d.ts +1 -1
- package/_internal/app/components/ui/button.d.ts +1 -1
- package/_internal/app/components/underline-tabs.d.ts +6 -2
- package/_internal/app/components/unsaved-changes-guard.d.ts +34 -0
- package/_internal/app/core/conversation-turns.d.ts +148 -0
- package/_internal/app/core/logger.d.ts +1 -0
- package/_internal/app/hooks/use-available-models.d.ts +5 -0
- package/_internal/app/hooks/use-content-store.d.ts +0 -9
- package/_internal/app/hooks/use-file-drop.d.ts +25 -0
- package/_internal/app/hooks/use-history-back.d.ts +1 -0
- package/_internal/app/hooks/use-horizontal-resize.d.ts +22 -0
- package/_internal/app/hooks/use-json-fetch.d.ts +26 -0
- package/_internal/app/hooks/use-nav-badge.d.ts +13 -0
- package/_internal/app/hooks/use-plugin-event.d.ts +19 -0
- package/_internal/app/hooks/use-query-state.d.ts +2 -0
- package/_internal/app/hooks/use-resizable-pane.d.ts +35 -0
- package/_internal/app/hooks/use-schedule.d.ts +47 -1
- package/_internal/app/hooks/use-search.d.ts +27 -8
- package/_internal/app/hooks/use-task-run-history.d.ts +26 -0
- package/_internal/app/hooks/use-toast.d.ts +3 -3
- package/_internal/app/hooks/use-vertical-resize.d.ts +6 -7
- package/_internal/app/lib/browser-notify.d.ts +12 -1
- package/_internal/app/types/index.d.ts +1 -105
- package/_internal/core/adapters/runtime/concepts.d.ts +671 -99
- package/_internal/core/adapters/runtime/errors.d.ts +98 -0
- package/_internal/core/adapters/runtime/helpers.d.ts +19 -0
- package/_internal/core/adapters/runtime/index.d.ts +7 -2
- package/_internal/core/adapters/runtime/testing.d.ts +79 -0
- package/_internal/core/adapters/runtime/turn-activity.d.ts +23 -0
- package/_internal/core/adapters/shared.d.ts +122 -12
- package/_internal/core/content-dir.d.ts +9 -0
- package/_internal/core/docs/route.d.ts +1 -1
- package/_internal/core/format/structured.d.ts +44 -0
- package/_internal/core/format.d.ts +13 -0
- package/_internal/core/media/downscale.d.ts +18 -0
- package/_internal/core/media/sharp-loader.d.ts +36 -0
- package/_internal/core/plugin-types.d.ts +216 -499
- package/_internal/core/routing/define.d.ts +26 -3
- package/_internal/core/routing/dispatcher.d.ts +15 -6
- package/_internal/core/routing/index.d.ts +1 -1
- package/_internal/core/routing/types.d.ts +13 -70
- package/_internal/core/storage/atomic-write.d.ts +11 -0
- package/_internal/core/tasks/store.d.ts +129 -0
- package/_internal/core/tasks/testing.d.ts +2 -0
- package/_internal/{plugins/workflows/lib → core/workflows}/notification-channel-registry.d.ts +1 -1
- package/_internal/plugins/team/types.d.ts +61 -4
- package/_internal/plugins/workflows/hooks/use-notification-channels.d.ts +1 -1
- package/components/index.d.ts +111 -5
- package/components/index.js +61815 -30060
- package/hooks/index.d.ts +90 -9
- package/hooks/index.js +15181 -685
- package/hooks/router.d.ts +20 -4
- package/index.d.ts +20 -3
- package/index.js +297 -259
- package/internal/index.d.ts +70 -0
- package/internal/index.js +409 -0
- package/metadata/index.d.ts +14 -1
- package/package.json +9 -2
- package/register.d.ts +63 -9
- package/routing/index.d.ts +6 -1
- package/routing/index.js +187 -147
- package/slots/index.d.ts +16 -24
- package/slots/index.js +215 -30
- package/testing/index.d.ts +122 -0
- package/testing/index.js +21874 -0
- package/types/index.d.ts +19 -919
- package/types/index.js +16 -0
- package/ui/index.js +2 -1
- package/utils/index.d.ts +46 -6
- package/utils/index.js +322 -249
- package/_internal/app/components/integrated-brainstorm/activity.d.ts +0 -23
- package/_internal/app/components/integrated-brainstorm/collapsed-header.d.ts +0 -14
- package/_internal/app/components/integrated-brainstorm/empty-state.d.ts +0 -5
- package/_internal/app/components/integrated-brainstorm/index.d.ts +0 -8
- package/_internal/app/components/integrated-brainstorm/input-row.d.ts +0 -16
- package/_internal/app/components/integrated-brainstorm/message-list.d.ts +0 -8
- package/_internal/app/components/integrated-brainstorm/session.d.ts +0 -16
- package/_internal/app/components/integrated-brainstorm/sse.d.ts +0 -8
- package/_internal/app/components/integrated-brainstorm/thinking-indicator.d.ts +0 -19
- package/_internal/app/components/integrated-brainstorm/types.d.ts +0 -63
- package/_internal/app/components/integrated-brainstorm/use-auto-grow.d.ts +0 -6
- package/_internal/app/components/integrated-brainstorm/use-brainstorm-state.d.ts +0 -21
- package/_internal/app/hooks/use-assets.d.ts +0 -25
package/index.js
CHANGED
|
@@ -13,10 +13,20 @@ var __export = (target, all) => {
|
|
|
13
13
|
set: __exportSetter.bind(all, name)
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
|
-
// packages/sdk/src/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
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
|
+
];
|
|
29
|
+
// packages/sdk/src/slots/registry.ts
|
|
20
30
|
function getRegistry() {
|
|
21
31
|
const g = globalThis;
|
|
22
32
|
if (!g.__bakinSlotRegistry) {
|
|
@@ -31,21 +41,16 @@ function registerSlot(name, component, order = 100, owner) {
|
|
|
31
41
|
entries.sort((a, b) => a.order - b.order);
|
|
32
42
|
reg.set(name, entries);
|
|
33
43
|
}
|
|
34
|
-
function clearSlotsOwnedBy(pluginId) {
|
|
35
|
-
const reg = getRegistry();
|
|
36
|
-
for (const [name, entries] of reg.entries()) {
|
|
37
|
-
const filtered = entries.filter((e) => e.owner !== pluginId);
|
|
38
|
-
if (filtered.length === 0)
|
|
39
|
-
reg.delete(name);
|
|
40
|
-
else
|
|
41
|
-
reg.set(name, filtered);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
44
|
|
|
45
45
|
// packages/sdk/src/register.ts
|
|
46
46
|
"use client";
|
|
47
47
|
function buildNavItemsSnapshot(registry) {
|
|
48
48
|
const items = [];
|
|
49
|
+
for (const [pluginId, navItems] of registry.manifestNavByPlugin.entries()) {
|
|
50
|
+
if (registry.navByPlugin.has(pluginId))
|
|
51
|
+
continue;
|
|
52
|
+
items.push(...navItems);
|
|
53
|
+
}
|
|
49
54
|
for (const navItems of registry.navByPlugin.values()) {
|
|
50
55
|
items.push(...navItems);
|
|
51
56
|
}
|
|
@@ -56,19 +61,82 @@ function getRegistry2() {
|
|
|
56
61
|
if (!g.__bakinClientRegistry) {
|
|
57
62
|
g.__bakinClientRegistry = {
|
|
58
63
|
navByPlugin: new Map,
|
|
64
|
+
manifestNavByPlugin: new Map,
|
|
59
65
|
routesByPlugin: new Map,
|
|
60
66
|
cleanupByPlugin: new Map,
|
|
61
67
|
navItemsSnapshot: [],
|
|
62
68
|
version: 0,
|
|
63
|
-
listeners: new Set
|
|
69
|
+
listeners: new Set,
|
|
70
|
+
badgesByPlugin: new Map,
|
|
71
|
+
badgesSnapshot: new Map,
|
|
72
|
+
badgeListeners: new Set,
|
|
73
|
+
hitRenderersByPlugin: new Map,
|
|
74
|
+
hitRenderersSnapshot: new Map,
|
|
75
|
+
hitRendererListeners: new Set
|
|
64
76
|
};
|
|
65
77
|
}
|
|
66
78
|
const registry = g.__bakinClientRegistry;
|
|
79
|
+
if (!registry.manifestNavByPlugin)
|
|
80
|
+
registry.manifestNavByPlugin = new Map;
|
|
67
81
|
if (!Array.isArray(registry.navItemsSnapshot)) {
|
|
68
82
|
registry.navItemsSnapshot = buildNavItemsSnapshot(registry);
|
|
69
83
|
}
|
|
84
|
+
if (!registry.badgesByPlugin)
|
|
85
|
+
registry.badgesByPlugin = new Map;
|
|
86
|
+
if (!registry.badgesSnapshot)
|
|
87
|
+
registry.badgesSnapshot = buildBadgesSnapshot(registry);
|
|
88
|
+
if (!registry.badgeListeners)
|
|
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;
|
|
70
96
|
return registry;
|
|
71
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
|
+
}
|
|
119
|
+
function buildBadgesSnapshot(registry) {
|
|
120
|
+
const snapshot = new Map;
|
|
121
|
+
for (const byNavItemId of registry.badgesByPlugin.values()) {
|
|
122
|
+
for (const [navItemId, badge] of byNavItemId) {
|
|
123
|
+
if (!snapshot.has(navItemId))
|
|
124
|
+
snapshot.set(navItemId, badge);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return snapshot;
|
|
128
|
+
}
|
|
129
|
+
function bumpBadges() {
|
|
130
|
+
const registry = getRegistry2();
|
|
131
|
+
registry.badgesSnapshot = buildBadgesSnapshot(registry);
|
|
132
|
+
for (const l of registry.badgeListeners) {
|
|
133
|
+
try {
|
|
134
|
+
l();
|
|
135
|
+
} catch (err) {
|
|
136
|
+
console.error("[bakin] badge listener threw:", err);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
72
140
|
function bumpVersion() {
|
|
73
141
|
const registry = getRegistry2();
|
|
74
142
|
registry.navItemsSnapshot = buildNavItemsSnapshot(registry);
|
|
@@ -98,24 +166,10 @@ function registerPlugin(reg) {
|
|
|
98
166
|
registerSlot(slotName, component, 100, reg.id);
|
|
99
167
|
}
|
|
100
168
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const registry = getRegistry2();
|
|
105
|
-
const cleanups = registry.cleanupByPlugin.get(id);
|
|
106
|
-
if (cleanups) {
|
|
107
|
-
for (const fn of cleanups) {
|
|
108
|
-
try {
|
|
109
|
-
fn();
|
|
110
|
-
} catch (err) {
|
|
111
|
-
console.error(`[bakin] cleanup fn for ${id} threw:`, err);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
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();
|
|
115
172
|
}
|
|
116
|
-
registry.navByPlugin.delete(id);
|
|
117
|
-
registry.routesByPlugin.delete(id);
|
|
118
|
-
clearSlotsOwnedBy(id);
|
|
119
173
|
bumpVersion();
|
|
120
174
|
}
|
|
121
175
|
function registerPluginCleanup(id, fn) {
|
|
@@ -124,226 +178,30 @@ function registerPluginCleanup(id, fn) {
|
|
|
124
178
|
list.push(fn);
|
|
125
179
|
registry.cleanupByPlugin.set(id, list);
|
|
126
180
|
}
|
|
127
|
-
function
|
|
128
|
-
return getRegistry2().version;
|
|
129
|
-
}
|
|
130
|
-
function subscribeRegistry(listener) {
|
|
131
|
-
const registry = getRegistry2();
|
|
132
|
-
registry.listeners.add(listener);
|
|
133
|
-
return () => {
|
|
134
|
-
registry.listeners.delete(listener);
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
function getAllNavItems() {
|
|
138
|
-
return [...getRegistry2().navItemsSnapshot];
|
|
139
|
-
}
|
|
140
|
-
function getNavItemsSnapshot() {
|
|
141
|
-
return getRegistry2().navItemsSnapshot;
|
|
142
|
-
}
|
|
143
|
-
function getPluginNavItems(pluginId) {
|
|
144
|
-
return getRegistry2().navByPlugin.get(pluginId) ?? [];
|
|
145
|
-
}
|
|
146
|
-
function normalizePattern(pattern) {
|
|
147
|
-
return pattern.split("/").filter(Boolean);
|
|
148
|
-
}
|
|
149
|
-
function matchRoutePattern(pattern, pathname) {
|
|
150
|
-
const patternSegments = normalizePattern(pattern);
|
|
151
|
-
const pathSegments = normalizePattern(pathname);
|
|
152
|
-
if (patternSegments.length !== pathSegments.length)
|
|
153
|
-
return null;
|
|
154
|
-
const params = {};
|
|
155
|
-
let score = 0;
|
|
156
|
-
for (let i = 0;i < patternSegments.length; i++) {
|
|
157
|
-
const patternSegment = patternSegments[i];
|
|
158
|
-
const pathSegment = pathSegments[i];
|
|
159
|
-
const bracket = patternSegment.match(/^\[([^\]]+)\]$/);
|
|
160
|
-
const isColon = patternSegment.startsWith(":");
|
|
161
|
-
const isDollar = patternSegment.startsWith("$");
|
|
162
|
-
if (bracket || isColon || isDollar) {
|
|
163
|
-
const key = bracket?.[1] ?? patternSegment.slice(1);
|
|
164
|
-
params[key] = decodeURIComponent(pathSegment);
|
|
165
|
-
continue;
|
|
166
|
-
}
|
|
167
|
-
if (patternSegment !== pathSegment)
|
|
168
|
-
return null;
|
|
169
|
-
score += 1;
|
|
170
|
-
}
|
|
171
|
-
return { params, score };
|
|
172
|
-
}
|
|
173
|
-
function getPluginRoute(pathname) {
|
|
181
|
+
function setNavBadge(pluginId, navItemId, badge) {
|
|
174
182
|
const registry = getRegistry2();
|
|
175
|
-
let
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
path: route2.path,
|
|
185
|
-
component: route2.component,
|
|
186
|
-
params: match.params,
|
|
187
|
-
score: match.score
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
}
|
|
183
|
+
let plugin = registry.badgesByPlugin.get(pluginId);
|
|
184
|
+
if (badge === null) {
|
|
185
|
+
if (!plugin?.has(navItemId))
|
|
186
|
+
return;
|
|
187
|
+
plugin.delete(navItemId);
|
|
188
|
+
if (plugin.size === 0)
|
|
189
|
+
registry.badgesByPlugin.delete(pluginId);
|
|
190
|
+
bumpBadges();
|
|
191
|
+
return;
|
|
191
192
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
const registry = getRegistry2();
|
|
199
|
-
if (pluginId)
|
|
200
|
-
return registry.routesByPlugin.get(pluginId) ?? [];
|
|
201
|
-
return [...registry.routesByPlugin.values()].flat();
|
|
202
|
-
}
|
|
203
|
-
// packages/core/src/routing/define.ts
|
|
204
|
-
function defineRoute(route) {
|
|
205
|
-
return route;
|
|
206
|
-
}
|
|
207
|
-
function defineCoreRoute(route) {
|
|
208
|
-
return route;
|
|
209
|
-
}
|
|
210
|
-
function definePlugin(plugin) {
|
|
211
|
-
return plugin;
|
|
212
|
-
}
|
|
213
|
-
// packages/core/src/routing/operation-id.ts
|
|
214
|
-
function operationIdFor(scope, method, path) {
|
|
215
|
-
return `${scope}.${method.toLowerCase()}.${slugifyPath(path)}`;
|
|
216
|
-
}
|
|
217
|
-
function slugifyPath(path) {
|
|
218
|
-
const trimmed = path.replace(/^\/+/, "").replace(/\/+$/, "");
|
|
219
|
-
if (trimmed === "")
|
|
220
|
-
return "root";
|
|
221
|
-
const segments = trimmed.split("/").map((seg) => {
|
|
222
|
-
if (seg.startsWith(":"))
|
|
223
|
-
return camelToKebab(seg.slice(1));
|
|
224
|
-
if (seg.startsWith("{") && seg.endsWith("}"))
|
|
225
|
-
return camelToKebab(seg.slice(1, -1));
|
|
226
|
-
return camelToKebab(seg);
|
|
227
|
-
}).filter(Boolean);
|
|
228
|
-
return segments.join("-");
|
|
229
|
-
}
|
|
230
|
-
function camelToKebab(input) {
|
|
231
|
-
return input.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[^a-zA-Z0-9-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").toLowerCase();
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
// packages/core/src/routing/registry.ts
|
|
235
|
-
function parseSegments(path) {
|
|
236
|
-
return path.split("/").filter(Boolean).map((seg) => {
|
|
237
|
-
if (seg === "*" || seg.startsWith("..."))
|
|
238
|
-
return { kind: "wildcard" };
|
|
239
|
-
if (seg.startsWith(":"))
|
|
240
|
-
return { kind: "param", name: seg.slice(1) };
|
|
241
|
-
if (seg.startsWith("{") && seg.endsWith("}")) {
|
|
242
|
-
return { kind: "param", name: seg.slice(1, -1) };
|
|
243
|
-
}
|
|
244
|
-
return { kind: "literal", value: seg };
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
function specificityScore(segments) {
|
|
248
|
-
let score = 0;
|
|
249
|
-
for (const seg of segments) {
|
|
250
|
-
if (seg.kind === "literal")
|
|
251
|
-
score += 2;
|
|
252
|
-
else if (seg.kind === "param")
|
|
253
|
-
score += 1;
|
|
193
|
+
const prev = plugin?.get(navItemId);
|
|
194
|
+
if (prev && prev.count === badge.count && prev.tone === badge.tone)
|
|
195
|
+
return;
|
|
196
|
+
if (!plugin) {
|
|
197
|
+
plugin = new Map;
|
|
198
|
+
registry.badgesByPlugin.set(pluginId, plugin);
|
|
254
199
|
}
|
|
255
|
-
|
|
200
|
+
plugin.set(navItemId, { count: badge.count, tone: badge.tone });
|
|
201
|
+
bumpBadges();
|
|
256
202
|
}
|
|
257
|
-
function
|
|
258
|
-
|
|
259
|
-
if (!lastIsWildcard && pathSegments.length !== routeSegments.length)
|
|
260
|
-
return null;
|
|
261
|
-
if (lastIsWildcard && pathSegments.length < routeSegments.length - 1)
|
|
262
|
-
return null;
|
|
263
|
-
const params = {};
|
|
264
|
-
for (let i = 0;i < routeSegments.length; i++) {
|
|
265
|
-
const rseg = routeSegments[i];
|
|
266
|
-
if (rseg.kind === "wildcard")
|
|
267
|
-
return params;
|
|
268
|
-
const pseg = pathSegments[i];
|
|
269
|
-
if (rseg.kind === "literal") {
|
|
270
|
-
if (rseg.value !== pseg)
|
|
271
|
-
return null;
|
|
272
|
-
} else {
|
|
273
|
-
params[rseg.name] = pseg;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
return params;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
class RouteRegistry {
|
|
280
|
-
byMethod = new Map;
|
|
281
|
-
operationIds = new Set;
|
|
282
|
-
fullPaths = new Set;
|
|
283
|
-
register(input) {
|
|
284
|
-
const { route } = input;
|
|
285
|
-
const pluginId = input.scope === "plugin" ? input.pluginId : null;
|
|
286
|
-
const fullPath = pluginId !== null ? `/api/plugins/${pluginId}${route.path}` : route.path;
|
|
287
|
-
const operationId = route.operationId ?? operationIdFor(pluginId ?? "core", route.method, route.path);
|
|
288
|
-
const dupKey = `${route.method} ${fullPath}`;
|
|
289
|
-
if (this.fullPaths.has(dupKey)) {
|
|
290
|
-
throw new Error(`duplicate route registration: ${dupKey}`);
|
|
291
|
-
}
|
|
292
|
-
if (this.operationIds.has(operationId)) {
|
|
293
|
-
throw new Error(`duplicate operationId: ${operationId} (route: ${dupKey})`);
|
|
294
|
-
}
|
|
295
|
-
this.fullPaths.add(dupKey);
|
|
296
|
-
this.operationIds.add(operationId);
|
|
297
|
-
const segments = parseSegments(fullPath);
|
|
298
|
-
const indexed = {
|
|
299
|
-
registered: {
|
|
300
|
-
route,
|
|
301
|
-
scope: pluginId ?? "core",
|
|
302
|
-
fullPath,
|
|
303
|
-
operationId
|
|
304
|
-
},
|
|
305
|
-
segments,
|
|
306
|
-
score: specificityScore(segments)
|
|
307
|
-
};
|
|
308
|
-
let bucket = this.byMethod.get(route.method);
|
|
309
|
-
if (!bucket) {
|
|
310
|
-
bucket = [];
|
|
311
|
-
this.byMethod.set(route.method, bucket);
|
|
312
|
-
}
|
|
313
|
-
bucket.push(indexed);
|
|
314
|
-
bucket.sort((a, b) => b.score - a.score);
|
|
315
|
-
return indexed.registered;
|
|
316
|
-
}
|
|
317
|
-
match(method, path) {
|
|
318
|
-
const bucket = this.byMethod.get(method);
|
|
319
|
-
if (!bucket)
|
|
320
|
-
return null;
|
|
321
|
-
const normalized = path.replace(/\/+$/, "") || "/";
|
|
322
|
-
const pathSegments = normalized.split("/").filter(Boolean);
|
|
323
|
-
for (const indexed of bucket) {
|
|
324
|
-
const params = matchSegments(pathSegments, indexed.segments);
|
|
325
|
-
if (params !== null) {
|
|
326
|
-
return {
|
|
327
|
-
...indexed.registered,
|
|
328
|
-
params
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
return null;
|
|
333
|
-
}
|
|
334
|
-
all() {
|
|
335
|
-
const out = [];
|
|
336
|
-
for (const bucket of this.byMethod.values()) {
|
|
337
|
-
for (const entry of bucket)
|
|
338
|
-
out.push(entry.registered);
|
|
339
|
-
}
|
|
340
|
-
return out;
|
|
341
|
-
}
|
|
342
|
-
clear() {
|
|
343
|
-
this.byMethod.clear();
|
|
344
|
-
this.operationIds.clear();
|
|
345
|
-
this.fullPaths.clear();
|
|
346
|
-
}
|
|
203
|
+
function getNavBadge(navItemId) {
|
|
204
|
+
return getRegistry2().badgesSnapshot.get(navItemId);
|
|
347
205
|
}
|
|
348
206
|
// node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/external.js
|
|
349
207
|
var exports_external = {};
|
|
@@ -13946,8 +13804,13 @@ function getBakinPaths() {
|
|
|
13946
13804
|
inbox: join(home, "inbox"),
|
|
13947
13805
|
tasks: join(home, "tasks"),
|
|
13948
13806
|
workflows: join(home, "workflows"),
|
|
13807
|
+
brands: join(home, "brands"),
|
|
13808
|
+
chat: join(home, "chat"),
|
|
13949
13809
|
settings: join(home, "settings.json"),
|
|
13950
|
-
logs: join(home, "logs")
|
|
13810
|
+
logs: join(home, "logs"),
|
|
13811
|
+
antfly: join(home, "antfly"),
|
|
13812
|
+
db: join(home, "bakin.db"),
|
|
13813
|
+
bin: join(home, "bin")
|
|
13951
13814
|
};
|
|
13952
13815
|
}
|
|
13953
13816
|
|
|
@@ -14111,11 +13974,21 @@ function suppressPrettyInfo(entry) {
|
|
|
14111
13974
|
}
|
|
14112
13975
|
return [
|
|
14113
13976
|
"search-registry",
|
|
13977
|
+
"search-registry-core",
|
|
13978
|
+
"search-plugin-api",
|
|
13979
|
+
"search-reindex",
|
|
13980
|
+
"search-query",
|
|
14114
13981
|
"search-reconcile",
|
|
14115
13982
|
"search-cleanup",
|
|
13983
|
+
"search-startup",
|
|
14116
13984
|
"hot-reload-coordinator",
|
|
14117
|
-
"mcporter",
|
|
14118
13985
|
"dispatch",
|
|
13986
|
+
"dispatch-state",
|
|
13987
|
+
"dispatch-turns",
|
|
13988
|
+
"dispatch-session-death",
|
|
13989
|
+
"dispatch-workflow",
|
|
13990
|
+
"dispatch-cycle",
|
|
13991
|
+
"dispatch-single",
|
|
14119
13992
|
"watchdog",
|
|
14120
13993
|
"doctor",
|
|
14121
13994
|
"lifecycle"
|
|
@@ -14209,6 +14082,176 @@ function createLogger(module) {
|
|
|
14209
14082
|
|
|
14210
14083
|
// packages/core/src/routing/dispatcher.ts
|
|
14211
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
|
+
}
|
|
14212
14255
|
// packages/core/src/routing/search-route.ts
|
|
14213
14256
|
var searchQuery = exports_external.object({
|
|
14214
14257
|
q: exports_external.string().min(1),
|
|
@@ -14228,17 +14271,12 @@ var searchResponse = exports_external.object({
|
|
|
14228
14271
|
});
|
|
14229
14272
|
var errorResponse = exports_external.object({ error: exports_external.string() });
|
|
14230
14273
|
export {
|
|
14231
|
-
|
|
14232
|
-
subscribeRegistry,
|
|
14274
|
+
setNavBadge,
|
|
14233
14275
|
registerPluginCleanup,
|
|
14234
14276
|
registerPlugin,
|
|
14235
|
-
|
|
14236
|
-
getPluginRoutes,
|
|
14237
|
-
getPluginRoute,
|
|
14238
|
-
getPluginNavItems,
|
|
14239
|
-
getNavItemsSnapshot,
|
|
14240
|
-
getAllNavItems,
|
|
14277
|
+
getNavBadge,
|
|
14241
14278
|
defineRoute,
|
|
14242
14279
|
definePlugin,
|
|
14243
|
-
defineCoreRoute
|
|
14280
|
+
defineCoreRoute,
|
|
14281
|
+
HEALTH_INCIDENT_CLASSES
|
|
14244
14282
|
};
|