@makinbakin/sdk 0.0.0-bootstrap.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +107 -0
- package/_internal/app/components/agent-avatar.d.ts +11 -0
- package/_internal/app/components/agent-filter.d.ts +8 -0
- package/_internal/app/components/agent-select.d.ts +15 -0
- package/_internal/app/components/agent-status.d.ts +8 -0
- package/_internal/app/components/bakin-drawer.d.ts +23 -0
- package/_internal/app/components/color-picker.d.ts +7 -0
- package/_internal/app/components/empty-state.d.ts +10 -0
- package/_internal/app/components/error-banner.d.ts +6 -0
- package/_internal/app/components/error-state.d.ts +8 -0
- package/_internal/app/components/facet-filter.d.ts +17 -0
- package/_internal/app/components/integrated-brainstorm/collapsed-header.d.ts +14 -0
- package/_internal/app/components/integrated-brainstorm/empty-state.d.ts +5 -0
- package/_internal/app/components/integrated-brainstorm/index.d.ts +3 -0
- package/_internal/app/components/integrated-brainstorm/input-row.d.ts +16 -0
- package/_internal/app/components/integrated-brainstorm/message-list.d.ts +8 -0
- package/_internal/app/components/integrated-brainstorm/thinking-indicator.d.ts +19 -0
- package/_internal/app/components/integrated-brainstorm/types.d.ts +61 -0
- package/_internal/app/components/integrated-brainstorm/use-auto-grow.d.ts +6 -0
- package/_internal/app/components/integrated-brainstorm/use-brainstorm-state.d.ts +21 -0
- package/_internal/app/components/markdown-content.d.ts +3 -0
- package/_internal/app/components/markdown-editor.d.ts +11 -0
- package/_internal/app/components/model-select.d.ts +9 -0
- package/_internal/app/components/page-layout.d.ts +9 -0
- package/_internal/app/components/plugin-header.d.ts +16 -0
- package/_internal/app/components/plugin-settings-renderer.d.ts +9 -0
- package/_internal/app/components/sortable-head.d.ts +13 -0
- package/_internal/app/components/ui/alert.d.ts +10 -0
- package/_internal/app/components/ui/avatar.d.ts +11 -0
- package/_internal/app/components/ui/badge.d.ts +7 -0
- package/_internal/app/components/ui/button.d.ts +8 -0
- package/_internal/app/components/ui/card.d.ts +11 -0
- package/_internal/app/components/ui/checkbox.d.ts +3 -0
- package/_internal/app/components/ui/collapsible.d.ts +5 -0
- package/_internal/app/components/ui/command.d.ts +19 -0
- package/_internal/app/components/ui/dialog.d.ts +17 -0
- package/_internal/app/components/ui/dropdown-menu.d.ts +29 -0
- package/_internal/app/components/ui/form.d.ts +23 -0
- package/_internal/app/components/ui/input-group.d.ts +18 -0
- package/_internal/app/components/ui/input.d.ts +3 -0
- package/_internal/app/components/ui/label.d.ts +3 -0
- package/_internal/app/components/ui/popover.d.ts +9 -0
- package/_internal/app/components/ui/progress.d.ts +7 -0
- package/_internal/app/components/ui/select.d.ts +15 -0
- package/_internal/app/components/ui/separator.d.ts +3 -0
- package/_internal/app/components/ui/sheet.d.ts +14 -0
- package/_internal/app/components/ui/skeleton.d.ts +2 -0
- package/_internal/app/components/ui/switch.d.ts +5 -0
- package/_internal/app/components/ui/table.d.ts +10 -0
- package/_internal/app/components/ui/tabs.d.ts +10 -0
- package/_internal/app/components/ui/textarea.d.ts +3 -0
- package/_internal/app/components/ui/tooltip.d.ts +6 -0
- package/_internal/app/components/underline-tabs.d.ts +15 -0
- package/_internal/app/hooks/use-assets.d.ts +25 -0
- package/_internal/app/hooks/use-content-store.d.ts +36 -0
- package/_internal/app/hooks/use-debug.d.ts +1 -0
- package/_internal/app/hooks/use-form-guard.d.ts +5 -0
- package/_internal/app/hooks/use-query-state.d.ts +14 -0
- package/_internal/app/hooks/use-runtime-status.d.ts +12 -0
- package/_internal/app/hooks/use-schedule.d.ts +63 -0
- package/_internal/app/hooks/use-search.d.ts +65 -0
- package/_internal/app/hooks/use-sidebar.d.ts +4 -0
- package/_internal/app/hooks/use-sse.d.ts +1 -0
- package/_internal/app/hooks/use-toast.d.ts +16 -0
- package/_internal/app/hooks/use-vertical-resize.d.ts +22 -0
- package/_internal/app/lib/browser-notify.d.ts +5 -0
- package/_internal/app/lib/map-audit-message.d.ts +7 -0
- package/_internal/app/lib/utils.d.ts +2 -0
- package/_internal/app/types/index.d.ts +126 -0
- package/_internal/core/adapters/runtime/capabilities.d.ts +2 -0
- package/_internal/core/adapters/runtime/concepts.d.ts +458 -0
- package/_internal/core/adapters/runtime/helpers.d.ts +5 -0
- package/_internal/core/adapters/runtime/index.d.ts +5 -0
- package/_internal/core/adapters/shared.d.ts +37 -0
- package/_internal/core/docs/index.d.ts +2 -0
- package/_internal/core/docs/metadata.d.ts +92 -0
- package/_internal/core/docs/route.d.ts +9 -0
- package/_internal/core/format.d.ts +6 -0
- package/_internal/core/openapi/errors.d.ts +29 -0
- package/_internal/core/openapi/zod-to-openapi.d.ts +14 -0
- package/_internal/core/plugin-types.d.ts +849 -0
- package/_internal/core/routing/define.d.ts +34 -0
- package/_internal/core/routing/dispatcher.d.ts +44 -0
- package/_internal/core/routing/index.d.ts +15 -0
- package/_internal/core/routing/operation-id.d.ts +9 -0
- package/_internal/core/routing/registry.d.ts +52 -0
- package/_internal/core/routing/search-route.d.ts +26 -0
- package/_internal/core/routing/types.d.ts +123 -0
- package/_internal/plugins/team/hooks/use-agent-store.d.ts +49 -0
- package/_internal/plugins/team/types.d.ts +131 -0
- package/_internal/plugins/workflows/hooks/channel-icon.d.ts +6 -0
- package/_internal/plugins/workflows/hooks/use-notification-channels.d.ts +13 -0
- package/_internal/plugins/workflows/lib/notification-channel-registry.d.ts +26 -0
- package/components/index.d.ts +33 -0
- package/components/index.js +39522 -0
- package/hooks/index.d.ts +25 -0
- package/hooks/index.js +1738 -0
- package/hooks/router.d.ts +38 -0
- package/index.d.ts +27 -0
- package/index.js +13917 -0
- package/metadata/index.d.ts +16 -0
- package/metadata/index.js +31 -0
- package/package.json +88 -0
- package/register.d.ts +103 -0
- package/routing/index.d.ts +11 -0
- package/routing/index.js +13721 -0
- package/slots/index.d.ts +55 -0
- package/slots/index.js +92 -0
- package/types/index.d.ts +840 -0
- package/types/index.js +1 -0
- package/ui/index.d.ts +34 -0
- package/ui/index.js +28713 -0
- package/utils/index.d.ts +9 -0
- package/utils/index.js +1832 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authoring helpers for the routing module.
|
|
3
|
+
*
|
|
4
|
+
* `defineRoute`, `defineCoreRoute`, and `definePlugin` exist to preserve
|
|
5
|
+
* precise per-route type inference that bare `APIRoute<...>[]` annotations
|
|
6
|
+
* widen and lose. The function signatures explicitly take separate generics
|
|
7
|
+
* for path-params (P), query (Q), and body (B) so TypeScript can infer them
|
|
8
|
+
* from the schemas in the route literal.
|
|
9
|
+
*/
|
|
10
|
+
import type { APIRoute, CoreContext, PluginContextLite } from './types';
|
|
11
|
+
/**
|
|
12
|
+
* Declare a plugin route. Handler `ctx` is bound to `PluginContextLite`. The
|
|
13
|
+
* three generics (P/Q/B) are inferred from `params`, `query`, and `body`
|
|
14
|
+
* schemas respectively; they default to `undefined` when those fields are
|
|
15
|
+
* omitted, which causes `ParsedInput` to omit the corresponding key.
|
|
16
|
+
*/
|
|
17
|
+
export declare function defineRoute<P = undefined, Q = undefined, B = undefined>(route: APIRoute<PluginContextLite, P, Q, B>): APIRoute<PluginContextLite, P, Q, B>;
|
|
18
|
+
/**
|
|
19
|
+
* Declare a core (host) route. Handler `ctx` is bound to `CoreContext`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function defineCoreRoute<P = undefined, Q = undefined, B = undefined>(route: APIRoute<CoreContext, P, Q, B>): APIRoute<CoreContext, P, Q, B>;
|
|
22
|
+
/** Lower-bound shape every plugin definition must satisfy. */
|
|
23
|
+
export interface DefinePluginInput {
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
version: string;
|
|
27
|
+
routes?: ReadonlyArray<APIRoute<PluginContextLite, any, any, any>>;
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Declare a plugin. Returns the input unchanged. Use this instead of a bare
|
|
32
|
+
* `BakinPlugin` annotation so `routes` keeps per-element inference.
|
|
33
|
+
*/
|
|
34
|
+
export declare function definePlugin<const T extends DefinePluginInput>(plugin: T): T;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Route dispatcher — runs a registered route against a Web Request.
|
|
3
|
+
*
|
|
4
|
+
* Responsibilities:
|
|
5
|
+
* - Parse path params (provided by the registry's match), query string,
|
|
6
|
+
* and request body against the route's Zod schemas.
|
|
7
|
+
* - On parse failure, return `400 { error, issues }` without invoking the
|
|
8
|
+
* handler.
|
|
9
|
+
* - On body content-type mismatch, return `415 { error }`.
|
|
10
|
+
* - Call the handler with the typed `parsed` object.
|
|
11
|
+
* - In dev / test, validate the response body against `responses[status]`
|
|
12
|
+
* and surface mismatches (test → throw, dev → console.warn).
|
|
13
|
+
*
|
|
14
|
+
* Adapter mapping: legacy `APIRoute.input` is treated as a JSON `body` schema
|
|
15
|
+
* and legacy `APIRoute.output` is treated as `responses[200]`. This keeps
|
|
16
|
+
* routes registered via the migration-window `ctx.registerRoute({...})` shim
|
|
17
|
+
* flowing through the same validation path.
|
|
18
|
+
*/
|
|
19
|
+
import { z } from 'zod';
|
|
20
|
+
import type { BodySpec, ResponseSpec } from './types';
|
|
21
|
+
/**
|
|
22
|
+
* Loose route shape accepted by the dispatcher. Concrete `APIRoute<...>`
|
|
23
|
+
* types from `defineRoute(...)` are assignable to this — the variance issue
|
|
24
|
+
* with strongly-typed handler signatures is sidestepped by typing `handler`
|
|
25
|
+
* as the most-permissive shape.
|
|
26
|
+
*/
|
|
27
|
+
export interface DispatchableRoute {
|
|
28
|
+
path: string;
|
|
29
|
+
method: string;
|
|
30
|
+
params?: z.ZodType<unknown>;
|
|
31
|
+
query?: z.ZodType<unknown>;
|
|
32
|
+
body?: BodySpec<unknown>;
|
|
33
|
+
responses?: Partial<Record<string | number, ResponseSpec>>;
|
|
34
|
+
handler: (req: Request, ctx: any, parsed?: any) => Response | Promise<Response>;
|
|
35
|
+
input?: z.ZodType<unknown>;
|
|
36
|
+
output?: z.ZodType<unknown>;
|
|
37
|
+
}
|
|
38
|
+
export interface DispatchInput {
|
|
39
|
+
req: Request;
|
|
40
|
+
ctx: unknown;
|
|
41
|
+
route: DispatchableRoute;
|
|
42
|
+
params: Record<string, string>;
|
|
43
|
+
}
|
|
44
|
+
export declare function dispatchRoute(input: DispatchInput): Promise<Response>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@bakin/core/routing` — typed route contracts.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the route types and authoring helpers used by both the host and
|
|
5
|
+
* plugin authors (via `@bakin/sdk/routing`).
|
|
6
|
+
*/
|
|
7
|
+
export type { HttpMethod, HttpStatus, RouteContext, PluginContextLite, CoreContext, JsonBodySpec, MultipartBodySpec, RawBodySpec, NoBodySpec, BodySpec, JsonResponseSpec, NoContentResponseSpec, NonJsonResponseSpec, ResponseSpec, ParsedInput, APIRoute, PluginWithRoutes, } from './types';
|
|
8
|
+
export { defineRoute, defineCoreRoute, definePlugin } from './define';
|
|
9
|
+
export type { DefinePluginInput } from './define';
|
|
10
|
+
export { RouteRegistry } from './registry';
|
|
11
|
+
export type { RouteScope, RegisteredRoute, RouteMatch } from './registry';
|
|
12
|
+
export { operationIdFor } from './operation-id';
|
|
13
|
+
export { dispatchRoute } from './dispatcher';
|
|
14
|
+
export type { DispatchInput } from './dispatcher';
|
|
15
|
+
export { searchRoute } from './search-route';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derives a stable OpenAPI `operationId` from `<scope, method, path>`.
|
|
3
|
+
*
|
|
4
|
+
* Convention: `<scope>.<methodLower>.<slug(path)>` where `slug` is the path
|
|
5
|
+
* with `/` and `:`/`{}` placeholder syntax normalized to a kebab-case
|
|
6
|
+
* identifier. Routes that declare their own `operationId` use that value
|
|
7
|
+
* verbatim; this helper is the default for routes that don't.
|
|
8
|
+
*/
|
|
9
|
+
export declare function operationIdFor(scope: string, method: string, path: string): string;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Route registry — single source of truth for HTTP route dispatch.
|
|
3
|
+
*
|
|
4
|
+
* Routes register here at boot (core first, then plugins, then user plugins).
|
|
5
|
+
* The dispatcher (T4) looks up routes by <method, url> against this table.
|
|
6
|
+
* Docs generation reads `all()` to emit OpenAPI from the in-memory registry.
|
|
7
|
+
*
|
|
8
|
+
* Path matching uses radix-style precedence: literal segments beat `:param`,
|
|
9
|
+
* and `:param` beats wildcards. Duplicates throw at registration so boot
|
|
10
|
+
* fails loudly on a misconfiguration rather than silently shadowing.
|
|
11
|
+
*/
|
|
12
|
+
import type { APIRoute, RouteContext } from './types';
|
|
13
|
+
export type RouteScope = {
|
|
14
|
+
scope: 'core';
|
|
15
|
+
route: APIRoute<any, any, any, any>;
|
|
16
|
+
} | {
|
|
17
|
+
scope: 'plugin';
|
|
18
|
+
pluginId: string;
|
|
19
|
+
route: APIRoute<any, any, any, any>;
|
|
20
|
+
};
|
|
21
|
+
/** A route as stored in the registry, with derived metadata. */
|
|
22
|
+
export interface RegisteredRoute {
|
|
23
|
+
route: APIRoute<RouteContext, any, any, any>;
|
|
24
|
+
scope: 'core' | string;
|
|
25
|
+
fullPath: string;
|
|
26
|
+
operationId: string;
|
|
27
|
+
}
|
|
28
|
+
export interface RouteMatch {
|
|
29
|
+
route: APIRoute<RouteContext, any, any, any>;
|
|
30
|
+
scope: 'core' | string;
|
|
31
|
+
fullPath: string;
|
|
32
|
+
operationId: string;
|
|
33
|
+
params: Record<string, string>;
|
|
34
|
+
}
|
|
35
|
+
export declare class RouteRegistry {
|
|
36
|
+
private byMethod;
|
|
37
|
+
private operationIds;
|
|
38
|
+
private fullPaths;
|
|
39
|
+
/**
|
|
40
|
+
* Register a route. Throws on duplicate <method, fullPath> or operationId.
|
|
41
|
+
*/
|
|
42
|
+
register(input: RouteScope): RegisteredRoute;
|
|
43
|
+
/**
|
|
44
|
+
* Match a request against the registered routes. Returns the most specific
|
|
45
|
+
* match or null. Path is the full URL pathname (e.g., `/api/plugins/tasks/abc`).
|
|
46
|
+
*/
|
|
47
|
+
match(method: string, path: string): RouteMatch | null;
|
|
48
|
+
/** Return every registered route. Used by docs generation. */
|
|
49
|
+
all(): RegisteredRoute[];
|
|
50
|
+
/** Reset state. Tests must call this in beforeEach when reusing the registry. */
|
|
51
|
+
clear(): void;
|
|
52
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `searchRoute({ table })` — factory for the per-plugin `GET /search` route.
|
|
3
|
+
*
|
|
4
|
+
* Replaces the auto-wired search route that `ctx.search.registerContentType`
|
|
5
|
+
* historically created as a side effect during `activate()`. Plugins now
|
|
6
|
+
* include this in their declarative `routes: [...]` array — the schemas
|
|
7
|
+
* are bound at module scope, but the handler reads `ctx.search` at request
|
|
8
|
+
* time (no closure over `activate()`-initialized services).
|
|
9
|
+
*/
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
import type { APIRoute, PluginContextLite } from './types';
|
|
12
|
+
declare const searchQuery: z.ZodObject<{
|
|
13
|
+
q: z.ZodString;
|
|
14
|
+
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
15
|
+
offset: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
16
|
+
facets: z.ZodOptional<z.ZodString>;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
/**
|
|
19
|
+
* Returns the standard `GET /search` route for a plugin's content type.
|
|
20
|
+
* Plugins consume it by including the result in their `routes` array.
|
|
21
|
+
*/
|
|
22
|
+
export declare function searchRoute(opts: {
|
|
23
|
+
table: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
}): APIRoute<PluginContextLite, undefined, z.infer<typeof searchQuery>, undefined>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Routing primitives — typed route contracts that drive runtime dispatch and
|
|
3
|
+
* OpenAPI emission from a single source.
|
|
4
|
+
*
|
|
5
|
+
* The legacy `APIRoute` interface in `../plugin-types.ts` remains during the
|
|
6
|
+
* migration window; this module's `APIRoute<C, P, Q, B>` is the new
|
|
7
|
+
* declarative shape that plugins move to under T6–T16. The two coexist via the
|
|
8
|
+
* `ctx.registerRoute` adapter wired in T4.
|
|
9
|
+
*/
|
|
10
|
+
import type { z } from 'zod';
|
|
11
|
+
import type { ContractStability, ContractVisibility, DocsExample, SourceLocation } from '../docs';
|
|
12
|
+
import type { AgentRuntimeAdapter } from '../adapters/runtime';
|
|
13
|
+
import type { StorageAdapter, EventBus, SearchAPI, ActivityAPI, HookAPI, AssetsAPI, PluginTaskService } from '../plugin-types';
|
|
14
|
+
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
15
|
+
export type HttpStatus = 200 | 201 | 202 | 204 | 301 | 302 | 304 | 400 | 401 | 403 | 404 | 409 | 410 | 415 | 422 | 429 | 500 | 502 | 503 | 504;
|
|
16
|
+
/**
|
|
17
|
+
* Common surface every route handler can rely on, regardless of origin.
|
|
18
|
+
* `PluginContext` and `CoreContext` extend this with their own additions.
|
|
19
|
+
*
|
|
20
|
+
* Types here mirror the plugin-context surface so a plugin handler that
|
|
21
|
+
* declares `ctx: PluginContextLite` can call `ctx.search.index(...)`,
|
|
22
|
+
* `ctx.activity.log(...)`, etc. without casting.
|
|
23
|
+
*/
|
|
24
|
+
export interface RouteContext {
|
|
25
|
+
runtime: AgentRuntimeAdapter;
|
|
26
|
+
search: SearchAPI;
|
|
27
|
+
storage: StorageAdapter;
|
|
28
|
+
events: EventBus;
|
|
29
|
+
activity: ActivityAPI;
|
|
30
|
+
hooks: HookAPI;
|
|
31
|
+
assets: AssetsAPI;
|
|
32
|
+
tasks: PluginTaskService;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Lite plugin context — the public-facing slice every plugin route handler
|
|
36
|
+
* receives. The full `PluginContext` (in `../plugin-types.ts`) extends this
|
|
37
|
+
* with the imperative `registerRoute`/`registerExecTool`/etc. surface that
|
|
38
|
+
* `activate()` uses; route handlers don't need that surface at request time.
|
|
39
|
+
*/
|
|
40
|
+
export interface PluginContextLite extends RouteContext {
|
|
41
|
+
pluginId: string;
|
|
42
|
+
getSettings<T = Record<string, unknown>>(): T;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Core (host) context — host-only surface for routes registered under
|
|
46
|
+
* `packages/host/src/core-routes/`.
|
|
47
|
+
*/
|
|
48
|
+
export type CoreContext = RouteContext;
|
|
49
|
+
export interface JsonBodySpec<B = unknown> {
|
|
50
|
+
contentType: 'application/json';
|
|
51
|
+
schema: z.ZodType<B>;
|
|
52
|
+
}
|
|
53
|
+
export interface MultipartBodySpec<B = unknown> {
|
|
54
|
+
contentType: 'multipart/form-data';
|
|
55
|
+
schema?: z.ZodType<B>;
|
|
56
|
+
}
|
|
57
|
+
export interface RawBodySpec<B = unknown> {
|
|
58
|
+
contentType: '*/*';
|
|
59
|
+
schema?: z.ZodType<B>;
|
|
60
|
+
}
|
|
61
|
+
export interface NoBodySpec {
|
|
62
|
+
contentType: 'none';
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* `body` declaration:
|
|
66
|
+
* - `z.ZodType` shorthand → JSON body validated against the schema.
|
|
67
|
+
* - explicit JSON spec → same, content-type stated.
|
|
68
|
+
* - multipart / raw → handler reads `req.formData()` / `req.body` itself.
|
|
69
|
+
* - none → dispatcher rejects non-empty bodies with 415.
|
|
70
|
+
*
|
|
71
|
+
* Omit the field entirely on routes that don't consume a body.
|
|
72
|
+
*/
|
|
73
|
+
export type BodySpec<B = unknown> = z.ZodType<B> | JsonBodySpec<B> | MultipartBodySpec<B> | RawBodySpec<B> | NoBodySpec;
|
|
74
|
+
export interface JsonResponseSpec {
|
|
75
|
+
contentType: 'application/json';
|
|
76
|
+
schema: z.ZodType;
|
|
77
|
+
}
|
|
78
|
+
export interface NoContentResponseSpec {
|
|
79
|
+
contentType: 'none';
|
|
80
|
+
}
|
|
81
|
+
export interface NonJsonResponseSpec {
|
|
82
|
+
contentType: 'text/event-stream' | 'text/html' | 'text/plain' | 'application/octet-stream' | 'image/png' | 'image/jpeg' | 'image/svg+xml' | (string & Record<never, never>);
|
|
83
|
+
schema?: z.ZodType;
|
|
84
|
+
}
|
|
85
|
+
export type ResponseSpec = z.ZodType | JsonResponseSpec | NoContentResponseSpec | NonJsonResponseSpec;
|
|
86
|
+
/** Helper: `{ body: B }` if B is declared (non-undefined), else no fields. */
|
|
87
|
+
type Field<K extends string, T> = [T] extends [undefined] ? unknown : {
|
|
88
|
+
[P in K]: T;
|
|
89
|
+
};
|
|
90
|
+
type Normalize<T> = {
|
|
91
|
+
[K in keyof T]: T[K];
|
|
92
|
+
};
|
|
93
|
+
export type ParsedInput<P, Q, B> = Normalize<Field<'params', P> & Field<'query', Q> & Field<'body', B>>;
|
|
94
|
+
export interface APIRoute<C extends RouteContext = RouteContext, P = undefined, Q = undefined, B = undefined> {
|
|
95
|
+
path: string;
|
|
96
|
+
method: HttpMethod;
|
|
97
|
+
summary?: string;
|
|
98
|
+
description?: string;
|
|
99
|
+
params?: z.ZodType<P>;
|
|
100
|
+
query?: z.ZodType<Q>;
|
|
101
|
+
body?: P extends never ? never : BodySpec<B>;
|
|
102
|
+
responses?: Partial<Record<HttpStatus, ResponseSpec>>;
|
|
103
|
+
visibility?: ContractVisibility;
|
|
104
|
+
stability?: ContractStability;
|
|
105
|
+
permissions?: string[];
|
|
106
|
+
examples?: DocsExample[];
|
|
107
|
+
operationId?: string;
|
|
108
|
+
tags?: string[];
|
|
109
|
+
source?: SourceLocation;
|
|
110
|
+
handler: (req: Request, ctx: C, parsed: ParsedInput<P, Q, B>) => Response | Promise<Response>;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Subset of plugin metadata `definePlugin` cares about. The full `BakinPlugin`
|
|
114
|
+
* interface lives in `../plugin-types.ts`; this declares the new fields the
|
|
115
|
+
* routing module needs to typecheck without circular imports.
|
|
116
|
+
*/
|
|
117
|
+
export interface PluginWithRoutes {
|
|
118
|
+
id: string;
|
|
119
|
+
name: string;
|
|
120
|
+
version: string;
|
|
121
|
+
routes?: ReadonlyArray<APIRoute<PluginContextLite, any, any, any>>;
|
|
122
|
+
}
|
|
123
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { AgentMeta, AgentDisplaySettings, AgentDisplaySettingsMap, AgentWithStatus, OrgTeam, PackageStateRow } from '../types';
|
|
2
|
+
interface AgentStore {
|
|
3
|
+
/** Lightweight agent list (for dropdowns, badges, avatars) */
|
|
4
|
+
agents: AgentMeta[];
|
|
5
|
+
/** Pre-computed ID list (stable reference for selectors) */
|
|
6
|
+
agentIds: string[];
|
|
7
|
+
/** Lookup map by ID */
|
|
8
|
+
agentMap: Record<string, AgentMeta>;
|
|
9
|
+
/** Agents with runtime status (for team grid) */
|
|
10
|
+
agentsWithStatus: AgentWithStatus[];
|
|
11
|
+
/** Display settings (colors, display names, team assignments — Bakin-owned) */
|
|
12
|
+
displaySettings: AgentDisplaySettingsMap;
|
|
13
|
+
/** Organizational teams */
|
|
14
|
+
teams: OrgTeam[];
|
|
15
|
+
/**
|
|
16
|
+
* Agent-package state per agent id, sourced from `/api/agent-packages`.
|
|
17
|
+
* Fetched in parallel with the roster on `load()`. Empty map when the
|
|
18
|
+
* endpoint fails — agent-packages is optional context, not load-blocking.
|
|
19
|
+
*/
|
|
20
|
+
packageStates: Record<string, PackageStateRow>;
|
|
21
|
+
/** Canonical main/orchestrator agent id (resolved server-side from the runtime adapter) */
|
|
22
|
+
mainAgentId: string | null;
|
|
23
|
+
/** Whether initial load has completed */
|
|
24
|
+
loaded: boolean;
|
|
25
|
+
/** Fetch agents + display settings + package states from the API */
|
|
26
|
+
load: () => Promise<void>;
|
|
27
|
+
/** Re-fetch only `/api/agent-packages` — used after Adopt to invalidate staleness */
|
|
28
|
+
refreshPackageStates: () => Promise<void>;
|
|
29
|
+
/** Update display settings for a single agent */
|
|
30
|
+
updateDisplay: (agentId: string, patch: Partial<AgentDisplaySettings>) => Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
export declare const useAgentStore: import("zustand").UseBoundStore<import("zustand").StoreApi<AgentStore>>;
|
|
33
|
+
/** Get a single agent's meta by ID */
|
|
34
|
+
export declare function useAgent(agentId: string): AgentMeta | undefined;
|
|
35
|
+
/** Get the full agent list */
|
|
36
|
+
export declare function useAgentList(): AgentMeta[];
|
|
37
|
+
/** Get an agent's accent color (hex). Falls back to zinc if unknown. */
|
|
38
|
+
export declare function useAgentColor(agentId: string): string;
|
|
39
|
+
/** Get an agent's package state row. Undefined when the API hasn't reported one. */
|
|
40
|
+
export declare function usePackageState(agentId: string): PackageStateRow | undefined;
|
|
41
|
+
/** Get an agent's display name override, if any. */
|
|
42
|
+
export declare function useAgentDisplayName(agentId: string): string | undefined;
|
|
43
|
+
/** Get all agent IDs (stable reference) */
|
|
44
|
+
export declare function useAgentIds(): string[];
|
|
45
|
+
/** Get the canonical main/orchestrator agent id. Null until the store has loaded. */
|
|
46
|
+
export declare function useMainAgentId(): string | null;
|
|
47
|
+
/** Utility: convert hex to rgba with opacity */
|
|
48
|
+
export declare function hexToMuted(hex: string, opacity?: number): string;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/** Lightweight agent info for badges, dropdowns, selectors */
|
|
2
|
+
export interface AgentMeta {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
emoji: string;
|
|
6
|
+
role: string;
|
|
7
|
+
headshot: string;
|
|
8
|
+
}
|
|
9
|
+
/** Full agent profile merged from runtime config + workspace files */
|
|
10
|
+
export interface AgentProfile extends AgentMeta {
|
|
11
|
+
model: string;
|
|
12
|
+
workspacePath: string;
|
|
13
|
+
soul: string | null;
|
|
14
|
+
identity: string | null;
|
|
15
|
+
rules: string | null;
|
|
16
|
+
tools: string | null;
|
|
17
|
+
heartbeatMd: string | null;
|
|
18
|
+
subagentPerms: string[] | null;
|
|
19
|
+
}
|
|
20
|
+
/** Agent with runtime status */
|
|
21
|
+
export interface AgentWithStatus extends AgentMeta {
|
|
22
|
+
status: 'online' | 'working' | 'available' | 'offline';
|
|
23
|
+
model: string;
|
|
24
|
+
heartbeat: HeartbeatData | null;
|
|
25
|
+
heartbeatAge: number | null;
|
|
26
|
+
}
|
|
27
|
+
export interface HeartbeatData {
|
|
28
|
+
timestamp: string;
|
|
29
|
+
status: string;
|
|
30
|
+
currentTask?: string;
|
|
31
|
+
}
|
|
32
|
+
/** Display-only settings owned by Bakin */
|
|
33
|
+
export interface AgentDisplaySettings {
|
|
34
|
+
displayName?: string;
|
|
35
|
+
accentColor?: string;
|
|
36
|
+
teamId?: string;
|
|
37
|
+
}
|
|
38
|
+
export type AgentDisplaySettingsMap = Record<string, AgentDisplaySettings>;
|
|
39
|
+
/** Organizational team — Bakin-owned grouping layer */
|
|
40
|
+
export interface OrgTeam {
|
|
41
|
+
id: string;
|
|
42
|
+
label: string;
|
|
43
|
+
/**
|
|
44
|
+
* Agent ID this team reports to, or `null` to indicate "reports to the
|
|
45
|
+
* main orchestrator". Stored as `null` whenever the incoming value
|
|
46
|
+
* matches the current main agent id so team.json stays decoupled from
|
|
47
|
+
* the specific orchestrator name.
|
|
48
|
+
*/
|
|
49
|
+
reportsTo: string | null;
|
|
50
|
+
color?: string;
|
|
51
|
+
order?: number;
|
|
52
|
+
}
|
|
53
|
+
/** Full team settings stored in team.json */
|
|
54
|
+
export interface TeamPluginSettings {
|
|
55
|
+
displaySettings: AgentDisplaySettingsMap;
|
|
56
|
+
teams: OrgTeam[];
|
|
57
|
+
}
|
|
58
|
+
/** Skill summary from workspace skills/ directory */
|
|
59
|
+
export interface SkillSummary {
|
|
60
|
+
id: string;
|
|
61
|
+
name: string;
|
|
62
|
+
hasSkillMd: boolean;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Per-agent agent-package state, sourced from `/api/agent-packages`. Mirrors
|
|
66
|
+
* the server-side `AgentStateInfo` shape but stays self-contained so the
|
|
67
|
+
* client doesn't reach across the package boundary for types.
|
|
68
|
+
*
|
|
69
|
+
* The server today returns 4 states (`absent | unmanaged | adopted | managed`).
|
|
70
|
+
* `drifted` and `update-available` are declared on the badge component for
|
|
71
|
+
* forward-compat — wiring handles them but the API doesn't yet emit them.
|
|
72
|
+
*/
|
|
73
|
+
export interface PackageStateRow {
|
|
74
|
+
agentId: string;
|
|
75
|
+
state: 'absent' | 'unmanaged' | 'adopted' | 'managed' | 'drifted' | 'update-available';
|
|
76
|
+
packageId?: string;
|
|
77
|
+
entry?: {
|
|
78
|
+
source: string;
|
|
79
|
+
ref: string;
|
|
80
|
+
commitSha: string;
|
|
81
|
+
installedAt: string;
|
|
82
|
+
version?: string;
|
|
83
|
+
dependencies?: string[];
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Single message from a runtime session JSONL. Used by the Active Context
|
|
88
|
+
* tab to render what the agent has actually been sent + has produced.
|
|
89
|
+
*/
|
|
90
|
+
export interface SessionMessage {
|
|
91
|
+
/** system / user / assistant / tool — drives the role badge color */
|
|
92
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
93
|
+
/** Raw text content. JSON tool calls are pretty-printed by the renderer. */
|
|
94
|
+
content: string;
|
|
95
|
+
/** Model id present on assistant messages when usage was recorded. */
|
|
96
|
+
model?: string;
|
|
97
|
+
/** ISO timestamp when present; absent on synthetic system messages. */
|
|
98
|
+
ts?: string;
|
|
99
|
+
/** Tool name for `role: 'tool'` entries. */
|
|
100
|
+
toolName?: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Latest-session transcript surfaced through `/api/plugins/team/:id/active-context`.
|
|
104
|
+
* `truncated` is true when the underlying JSONL had more than the requested
|
|
105
|
+
* cap (default 200) and we returned the most-recent N.
|
|
106
|
+
*/
|
|
107
|
+
export interface SessionTranscript {
|
|
108
|
+
sessionId: string;
|
|
109
|
+
sessionStarted: string | null;
|
|
110
|
+
messages: SessionMessage[];
|
|
111
|
+
truncated: boolean;
|
|
112
|
+
totalMessages: number;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Per-agent activity counts pulled from the in-memory `recordUsage` recorder.
|
|
116
|
+
* Resets on server restart — `sinceServerStart` exists so the UI can frame
|
|
117
|
+
* the numbers honestly rather than claim lifetime totals.
|
|
118
|
+
*/
|
|
119
|
+
export interface RecentActivity {
|
|
120
|
+
windowMs: Record<'5m' | '1h' | '24h', number>;
|
|
121
|
+
errors: Record<'5m' | '1h' | '24h', number>;
|
|
122
|
+
sinceServerStart: string;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Raw heartbeat surface — the markdown body the agent wrote to its heartbeat
|
|
126
|
+
* file plus the file mtime. The Heartbeat tab renders this view-only.
|
|
127
|
+
*/
|
|
128
|
+
export interface HeartbeatRaw {
|
|
129
|
+
content: string;
|
|
130
|
+
lastUpdated: string | null;
|
|
131
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { NotificationChannelDef } from '../lib/notification-channel-registry';
|
|
2
|
+
export declare function useNotificationChannels(): NotificationChannelDef[];
|
|
3
|
+
export declare function getChannelLabel(id: string, channels: NotificationChannelDef[]): string;
|
|
4
|
+
/**
|
|
5
|
+
* Returns the 2-character badge for a channel id, with uppercase-prefix
|
|
6
|
+
* fallback for unknown ids. Part of the public client surface (compact
|
|
7
|
+
* chips in admin UIs, CLI listings, etc) — no core consumer uses it today
|
|
8
|
+
* now that the drawer renders icon+label pairs, but it's still the right
|
|
9
|
+
* shape when a caller wants the compact form.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getChannelInitials(id: string, channels: NotificationChannelDef[]): string;
|
|
12
|
+
/** Test-only: reset the module-level cache so tests run with a clean slate. */
|
|
13
|
+
export declare function __resetNotificationChannelsCache(): void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notification-channel registry — single source of truth for the set of
|
|
3
|
+
* channels a workflow can notify (gate alerts, messaging publishes, etc).
|
|
4
|
+
*
|
|
5
|
+
* Builtins self-register at the bottom of this module, matching the
|
|
6
|
+
* node-type-registry precedent. Plugins register their own channels via
|
|
7
|
+
* `ctx.registerNotificationChannel()`, which calls `registerPluginNotificationChannel()`
|
|
8
|
+
* here. Plugin ids are auto-namespaced as `{pluginId}.{id}` to avoid
|
|
9
|
+
* cross-plugin collisions with the shared builtin ids.
|
|
10
|
+
*/
|
|
11
|
+
import type { NotificationChannelDef, PluginNotificationChannelInput } from '../../../core/plugin-types';
|
|
12
|
+
export type { NotificationChannelDef, PluginNotificationChannelInput };
|
|
13
|
+
export declare function registerNotificationChannel(def: NotificationChannelDef): void;
|
|
14
|
+
export declare function getNotificationChannel(id: string): NotificationChannelDef | undefined;
|
|
15
|
+
export declare function listNotificationChannels(): NotificationChannelDef[];
|
|
16
|
+
/** Remove a single registration. Useful for test cleanup. */
|
|
17
|
+
export declare function unregisterNotificationChannel(id: string): void;
|
|
18
|
+
/** Remove every channel owned by a plugin. Called at plugin teardown / hot reload. */
|
|
19
|
+
export declare function unregisterPluginNotificationChannels(pluginId: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Register a plugin-owned notification channel. The id is auto-namespaced
|
|
22
|
+
* to `{pluginId}.{id}` so two plugins can ship the same unprefixed id
|
|
23
|
+
* without colliding. Returns the namespaced id so callers can reference
|
|
24
|
+
* it from downstream code and tests.
|
|
25
|
+
*/
|
|
26
|
+
export declare function registerPluginNotificationChannel(pluginId: string, input: PluginNotificationChannelInput): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@bakin/sdk/components` — shared layout + compound components.
|
|
3
|
+
*
|
|
4
|
+
* Plugin-author-visible components that wrap shadcn primitives with Bakin-
|
|
5
|
+
* specific behavior (headers, filters, markdown, agent displays, etc.). Does
|
|
6
|
+
* not include layout chrome (sidebar, header, toaster) — those are Bakin's
|
|
7
|
+
* shell, not plugin-author territory.
|
|
8
|
+
*/
|
|
9
|
+
export { AgentAvatar } from '../_internal/app/components/agent-avatar';
|
|
10
|
+
export { AgentFilter } from '../_internal/app/components/agent-filter';
|
|
11
|
+
export { AgentSelect } from '../_internal/app/components/agent-select';
|
|
12
|
+
export { AgentDot, AgentStatus } from '../_internal/app/components/agent-status';
|
|
13
|
+
export { BakinDrawer } from '../_internal/app/components/bakin-drawer';
|
|
14
|
+
export { ColorPicker } from '../_internal/app/components/color-picker';
|
|
15
|
+
export { EmptyState } from '../_internal/app/components/empty-state';
|
|
16
|
+
export { ErrorBanner } from '../_internal/app/components/error-banner';
|
|
17
|
+
export { ErrorState } from '../_internal/app/components/error-state';
|
|
18
|
+
export { FacetFilter } from '../_internal/app/components/facet-filter';
|
|
19
|
+
export type { FacetOption } from '../_internal/app/components/facet-filter';
|
|
20
|
+
export { IntegratedBrainstorm } from '../_internal/app/components/integrated-brainstorm';
|
|
21
|
+
export type { BrainstormMessage, IntegratedBrainstormProps, BrainstormOnSend, SendContext, AssistantTransformed, } from '../_internal/app/components/integrated-brainstorm';
|
|
22
|
+
export { MarkdownContent } from '../_internal/app/components/markdown-content';
|
|
23
|
+
export { MarkdownEditor } from '../_internal/app/components/markdown-editor';
|
|
24
|
+
export { ModelSelect } from '../_internal/app/components/model-select';
|
|
25
|
+
export { PageLayout } from '../_internal/app/components/page-layout';
|
|
26
|
+
export { PluginHeader } from '../_internal/app/components/plugin-header';
|
|
27
|
+
export { PluginSettingsRenderer } from '../_internal/app/components/plugin-settings-renderer';
|
|
28
|
+
export type { PluginSettingsSchema } from '../_internal/app/components/plugin-settings-renderer';
|
|
29
|
+
export { SortableHead } from '../_internal/app/components/sortable-head';
|
|
30
|
+
export type { SortDir } from '../_internal/app/components/sortable-head';
|
|
31
|
+
export { UnderlineTabs } from '../_internal/app/components/underline-tabs';
|
|
32
|
+
export type { UnderlineTab } from '../_internal/app/components/underline-tabs';
|
|
33
|
+
export { ChannelIcon } from '../_internal/plugins/workflows/hooks/channel-icon';
|