@makinbakin/sdk 0.0.0-bootstrap.0 → 0.0.1-rc.10
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 +21 -10
- package/_internal/app/components/agent-select.d.ts +7 -2
- package/_internal/app/components/integrated-brainstorm/activity.d.ts +23 -0
- package/_internal/app/components/integrated-brainstorm/index.d.ts +6 -1
- package/_internal/app/components/integrated-brainstorm/session.d.ts +16 -0
- package/_internal/app/components/integrated-brainstorm/sse.d.ts +8 -0
- package/_internal/app/components/integrated-brainstorm/types.d.ts +7 -5
- package/_internal/app/components/ui/badge.d.ts +1 -1
- package/_internal/app/components/ui/button.d.ts +1 -1
- package/_internal/app/hooks/use-content-store.d.ts +2 -0
- package/_internal/app/hooks/use-nav-badge.d.ts +13 -0
- package/_internal/app/types/index.d.ts +0 -42
- package/_internal/core/adapters/runtime/concepts.d.ts +119 -2
- package/_internal/core/adapters/runtime/index.d.ts +1 -1
- package/_internal/core/constants.d.ts +15 -0
- package/_internal/core/content-dir.d.ts +42 -0
- package/_internal/core/generated-version.d.ts +1 -0
- package/_internal/core/logger.d.ts +8 -0
- package/_internal/core/plugin-types.d.ts +168 -37
- package/_internal/core/routing/index.d.ts +1 -1
- package/_internal/plugins/team/types.d.ts +12 -2
- package/components/index.d.ts +39 -3
- package/components/index.js +16257 -1550
- package/hooks/index.d.ts +58 -9
- package/hooks/index.js +14414 -413
- package/index.d.ts +43 -10
- package/index.js +400 -1
- package/metadata/index.d.ts +16 -3
- package/package.json +2 -2
- package/register.d.ts +20 -9
- package/routing/index.d.ts +8 -3
- package/routing/index.js +327 -0
- package/slots/index.d.ts +1 -1
- package/slots/index.js +20 -1
- package/types/index.d.ts +431 -50
- package/ui/index.d.ts +2 -2
- package/ui/index.js +2 -1
- package/utils/index.d.ts +24 -2
- package/utils/index.js +269 -1
- package/_internal/app/hooks/use-assets.d.ts +0 -25
package/types/index.d.ts
CHANGED
|
@@ -2,14 +2,18 @@
|
|
|
2
2
|
* Public Bakin plugin contract types.
|
|
3
3
|
*
|
|
4
4
|
* This module is intentionally self-contained. External plugins must be able
|
|
5
|
-
* to typecheck against `@
|
|
5
|
+
* to typecheck against `@makinbakin/sdk/types` without resolving `@bakin/core`,
|
|
6
6
|
* Bakin source aliases, adapter packages, or another plugin's internals.
|
|
7
7
|
*/
|
|
8
8
|
import type { ComponentType } from 'react';
|
|
9
9
|
import type { ZodRawShape } from 'zod';
|
|
10
|
+
/** HTTP method literal used in route and contribution definitions. */
|
|
10
11
|
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
12
|
+
/** Visibility tier for a documented contract (route, hook, tool, etc.). */
|
|
11
13
|
export type ContractVisibility = 'public' | 'internal' | 'experimental';
|
|
14
|
+
/** Stability tier for a documented contract. */
|
|
12
15
|
export type ContractStability = 'stable' | 'beta' | 'experimental' | 'deprecated';
|
|
16
|
+
/** Minimal interface a validation schema must satisfy (Zod-compatible). */
|
|
13
17
|
export interface SchemaLike<T = unknown> {
|
|
14
18
|
parse(data: unknown): T;
|
|
15
19
|
safeParse?(data: unknown): {
|
|
@@ -20,11 +24,13 @@ export interface SchemaLike<T = unknown> {
|
|
|
20
24
|
error: unknown;
|
|
21
25
|
};
|
|
22
26
|
}
|
|
27
|
+
/** Pointer to a symbol's source file location, used in generated docs. */
|
|
23
28
|
export interface SourceLocation {
|
|
24
29
|
file: string;
|
|
25
30
|
symbol?: string;
|
|
26
31
|
line?: number;
|
|
27
32
|
}
|
|
33
|
+
/** Reference example for a documented contract (request/response or code snippet). */
|
|
28
34
|
export interface DocsExample {
|
|
29
35
|
title: string;
|
|
30
36
|
description?: string;
|
|
@@ -34,12 +40,25 @@ export interface DocsExample {
|
|
|
34
40
|
test?: 'automated' | 'schema' | 'illustrative';
|
|
35
41
|
reason?: string;
|
|
36
42
|
}
|
|
37
|
-
|
|
43
|
+
/** Capability a plugin can request in its manifest (gates access to APIs). */
|
|
44
|
+
export type PluginPermission = 'storage.read' | 'storage.write' | 'events.emit' | 'runtime.read' | 'runtime.agents' | 'runtime.messaging' | 'runtime.channels' | 'runtime.cron' | 'runtime.skills' | 'runtime.models' | 'runtime.images' | 'tasks.read' | 'tasks.write' | 'search.read' | 'search.write' | 'assets.read' | 'assets.write';
|
|
45
|
+
/** Runtime feature a plugin declares it needs (used by doctor/health checks). */
|
|
38
46
|
export type RuntimeCapability = 'agents' | 'messaging' | 'channels.message' | 'channels.rich-content' | 'channels.interactive-approval' | 'channels.threaded-replies' | 'cron' | 'skills' | 'models' | 'tasks' | 'search';
|
|
47
|
+
/** Server and client entry-point file paths for a plugin. */
|
|
39
48
|
export interface PluginEntryPoints {
|
|
40
49
|
server: string;
|
|
41
50
|
client?: string;
|
|
42
51
|
}
|
|
52
|
+
/** Secret (env var) a plugin declares it needs (rendered in setup/health). */
|
|
53
|
+
export interface SecretDeclaration {
|
|
54
|
+
/** Canonical environment variable name, for example `ANTHROPIC_API_KEY`. */
|
|
55
|
+
name: string;
|
|
56
|
+
/** Human-readable setup note. Never include a secret value here. */
|
|
57
|
+
description: string;
|
|
58
|
+
/** Missing required secrets should be reported by setup/health checks. Defaults to true. */
|
|
59
|
+
required: boolean;
|
|
60
|
+
}
|
|
61
|
+
/** Manifest declaration of an HTTP route the plugin exposes. */
|
|
43
62
|
export interface ApiRouteContribution {
|
|
44
63
|
method: HttpMethod;
|
|
45
64
|
/** Plugin-relative path. Exposed as `/api/plugins/{pluginId}{path}`. */
|
|
@@ -55,7 +74,9 @@ export interface ApiRouteContribution {
|
|
|
55
74
|
responses?: Record<string, ApiResponseContribution>;
|
|
56
75
|
permissions?: PluginPermission[];
|
|
57
76
|
}
|
|
77
|
+
/** Raw JSON Schema object embedded in API contributions. */
|
|
58
78
|
export type JsonSchemaContribution = Record<string, unknown>;
|
|
79
|
+
/** Path/query/header/cookie parameter declaration for an API route. */
|
|
59
80
|
export interface ApiParameterContribution {
|
|
60
81
|
name: string;
|
|
61
82
|
in: 'path' | 'query' | 'header' | 'cookie';
|
|
@@ -64,6 +85,7 @@ export interface ApiParameterContribution {
|
|
|
64
85
|
schema?: JsonSchemaContribution;
|
|
65
86
|
example?: unknown;
|
|
66
87
|
}
|
|
88
|
+
/** Request body declaration for an API route. */
|
|
67
89
|
export interface ApiRequestBodyContribution {
|
|
68
90
|
description?: string;
|
|
69
91
|
required?: boolean;
|
|
@@ -71,24 +93,28 @@ export interface ApiRequestBodyContribution {
|
|
|
71
93
|
schema?: JsonSchemaContribution;
|
|
72
94
|
example?: unknown;
|
|
73
95
|
}
|
|
96
|
+
/** Response declaration for one HTTP status code on an API route. */
|
|
74
97
|
export interface ApiResponseContribution {
|
|
75
98
|
description: string;
|
|
76
99
|
contentType?: string;
|
|
77
100
|
schema?: JsonSchemaContribution;
|
|
78
101
|
example?: unknown;
|
|
79
102
|
}
|
|
103
|
+
/** Manifest declaration of a client-side route the plugin contributes. */
|
|
80
104
|
export interface ClientRouteContribution {
|
|
81
105
|
/** Absolute app route, e.g. `/messaging/calendar`. */
|
|
82
106
|
path: string;
|
|
83
107
|
summary: string;
|
|
84
108
|
slot?: string;
|
|
85
109
|
}
|
|
110
|
+
/** Manifest declaration of an MCP exec tool the plugin exposes. */
|
|
86
111
|
export interface ExecToolContribution {
|
|
87
112
|
name: string;
|
|
88
113
|
summary: string;
|
|
89
114
|
description?: string;
|
|
90
115
|
permissions?: PluginPermission[];
|
|
91
116
|
}
|
|
117
|
+
/** Manifest declaration of a CLI command the plugin contributes. */
|
|
92
118
|
export interface CliCommandContribution {
|
|
93
119
|
name: string;
|
|
94
120
|
usage: string;
|
|
@@ -108,21 +134,31 @@ export interface CliCommandContribution {
|
|
|
108
134
|
name: string;
|
|
109
135
|
};
|
|
110
136
|
}
|
|
137
|
+
/** Manifest declaration of a settings key the plugin owns. */
|
|
111
138
|
export interface SettingsContribution {
|
|
112
139
|
key: string;
|
|
113
140
|
summary: string;
|
|
114
141
|
}
|
|
142
|
+
/** Manifest declaration of the plugin's docs page slug. */
|
|
115
143
|
export interface DocsContribution {
|
|
116
144
|
slug: string;
|
|
117
145
|
}
|
|
146
|
+
/** The full contributions block in `bakin-plugin.json` — everything a plugin adds to the host. */
|
|
118
147
|
export interface PluginContributions {
|
|
148
|
+
/** HTTP routes the plugin exposes under `/api/plugins/{id}/...`. */
|
|
119
149
|
apiRoutes?: ApiRouteContribution[];
|
|
150
|
+
/** Client-side routes the plugin renders (sidebar nav targets). */
|
|
120
151
|
clientRoutes?: ClientRouteContribution[];
|
|
152
|
+
/** MCP exec tools agents can call. */
|
|
121
153
|
execTools?: ExecToolContribution[];
|
|
154
|
+
/** CLI commands the plugin contributes to the `bakin` binary. */
|
|
122
155
|
cliCommands?: CliCommandContribution[];
|
|
156
|
+
/** Settings keys this plugin owns in the settings UI. */
|
|
123
157
|
settings?: SettingsContribution[];
|
|
158
|
+
/** Optional docs page slug. */
|
|
124
159
|
docs?: DocsContribution;
|
|
125
160
|
}
|
|
161
|
+
/** Optional Ed25519 signature block proving manifest authenticity. */
|
|
126
162
|
export interface PluginManifestSignature {
|
|
127
163
|
algorithm: 'ed25519';
|
|
128
164
|
/** Human-readable signer label. Trust is bound to publicKey/fingerprint, not this label. */
|
|
@@ -132,23 +168,40 @@ export interface PluginManifestSignature {
|
|
|
132
168
|
/** Base64-encoded signature over the canonical manifest without this signature block. */
|
|
133
169
|
signature: string;
|
|
134
170
|
}
|
|
171
|
+
/** The `bakin-plugin.json` manifest. Required for every plugin. */
|
|
135
172
|
export interface PluginManifest {
|
|
173
|
+
/** Unique plugin identifier (kebab-case). */
|
|
136
174
|
id: string;
|
|
175
|
+
/** Human-readable plugin name. */
|
|
137
176
|
name: string;
|
|
177
|
+
/** Plugin version (semver). */
|
|
138
178
|
version: string;
|
|
179
|
+
/** Minimum Bakin version this plugin supports. */
|
|
139
180
|
bakin: string;
|
|
181
|
+
/** One-line summary shown in the plugin manager. */
|
|
140
182
|
description: string;
|
|
183
|
+
/** Server + optional client entry-point file paths. */
|
|
141
184
|
entry: PluginEntryPoints;
|
|
185
|
+
/** Static content files the plugin ships (rendered as docs/pages). */
|
|
142
186
|
contentFiles?: string[];
|
|
143
|
-
secrets
|
|
187
|
+
/** Environment-variable secrets the plugin requires. */
|
|
188
|
+
secrets?: SecretDeclaration[];
|
|
189
|
+
/** Path to a test entry-point (for `bakin plugins test`). */
|
|
144
190
|
tests?: string;
|
|
191
|
+
/** Other plugin IDs this plugin depends on. */
|
|
145
192
|
dependencies?: string[];
|
|
193
|
+
/** Capabilities this plugin requests access to. */
|
|
146
194
|
permissions?: PluginPermission[];
|
|
195
|
+
/** Runtime features this plugin needs to function. */
|
|
147
196
|
runtimeCapabilities?: RuntimeCapability[];
|
|
197
|
+
/** Everything the plugin adds to the host (routes, tools, settings, etc.). */
|
|
148
198
|
contributes?: PluginContributions;
|
|
199
|
+
/** File globs that trigger a hot reload in dev. */
|
|
149
200
|
devWatch?: string[];
|
|
201
|
+
/** Optional Ed25519 signature for authenticity. */
|
|
150
202
|
signature?: PluginManifestSignature;
|
|
151
203
|
}
|
|
204
|
+
/** File metadata returned by storage adapter `stat()`. */
|
|
152
205
|
export interface StorageStat {
|
|
153
206
|
path: string;
|
|
154
207
|
size: number;
|
|
@@ -156,6 +209,7 @@ export interface StorageStat {
|
|
|
156
209
|
isFile: boolean;
|
|
157
210
|
isDirectory: boolean;
|
|
158
211
|
}
|
|
212
|
+
/** Plugin-scoped filesystem adapter passed via `ctx.storage`. */
|
|
159
213
|
export interface StorageAdapter {
|
|
160
214
|
read(path: string): string | null;
|
|
161
215
|
write(path: string, content: string): void;
|
|
@@ -170,11 +224,13 @@ export interface StorageAdapter {
|
|
|
170
224
|
writeJson?(path: string, value: unknown): void;
|
|
171
225
|
searchPath?(path: string): string;
|
|
172
226
|
}
|
|
227
|
+
/** Cross-plugin event bus. Emit and subscribe by pattern. */
|
|
173
228
|
export interface EventBus {
|
|
174
229
|
emit(event: string, data?: Record<string, unknown>): void;
|
|
175
230
|
on(pattern: string, handler: (event: string, data: Record<string, unknown>) => void): () => void;
|
|
176
231
|
once(pattern: string, handler: (event: string, data: Record<string, unknown>) => void): () => void;
|
|
177
232
|
}
|
|
233
|
+
/** Activity feed + structured audit log API exposed on the plugin context. */
|
|
178
234
|
export interface ActivityAPI {
|
|
179
235
|
log(agent: string, message: string, opts?: {
|
|
180
236
|
taskId?: string;
|
|
@@ -182,6 +238,14 @@ export interface ActivityAPI {
|
|
|
182
238
|
}): void;
|
|
183
239
|
audit(event: string, agent: string, data?: Record<string, unknown>): void;
|
|
184
240
|
}
|
|
241
|
+
/** Plugin-scoped structured logger (writes to server log + stdout). */
|
|
242
|
+
export interface PluginLogger {
|
|
243
|
+
debug(message: string, data?: Record<string, unknown>): void;
|
|
244
|
+
info(message: string, data?: Record<string, unknown>): void;
|
|
245
|
+
warn(message: string, errorOrData?: unknown, data?: Record<string, unknown>): void;
|
|
246
|
+
error(message: string, errorOrData?: unknown, data?: Record<string, unknown>): void;
|
|
247
|
+
}
|
|
248
|
+
/** Cross-plugin RPC/event/waterfall hook registry. */
|
|
185
249
|
export interface HookAPI {
|
|
186
250
|
register(name: string, handler: (data: unknown) => unknown, metadata?: HookRegistrationMetadata): () => void;
|
|
187
251
|
call<T>(name: string, data: T): Promise<T>;
|
|
@@ -189,6 +253,7 @@ export interface HookAPI {
|
|
|
189
253
|
has(name: string): boolean;
|
|
190
254
|
invoke<R>(name: string, data: unknown): Promise<R | undefined>;
|
|
191
255
|
}
|
|
256
|
+
/** Optional documentation metadata for a registered hook. */
|
|
192
257
|
export interface HookRegistrationMetadata {
|
|
193
258
|
label?: string;
|
|
194
259
|
summary: string;
|
|
@@ -200,39 +265,85 @@ export interface HookRegistrationMetadata {
|
|
|
200
265
|
stability?: ContractStability;
|
|
201
266
|
examples?: DocsExample[];
|
|
202
267
|
}
|
|
268
|
+
/** Hook semantics: single-return RPC, fire-and-forget event, or input transform waterfall. */
|
|
203
269
|
export type HookKind = 'rpc' | 'event' | 'waterfall';
|
|
270
|
+
/** Visual tone for a {@link NavBadge}. Maps to a fixed palette in the sidebar.
|
|
271
|
+
* Ordered by severity: `error` (red) is the most urgent and wins rollups. */
|
|
272
|
+
export type NavBadgeTone = 'error' | 'attention' | 'info' | 'success';
|
|
273
|
+
/**
|
|
274
|
+
* Runtime badge attached to a nav item. Both fields are optional:
|
|
275
|
+
* - `count` present → renders as a small pill (clamped at `99+`).
|
|
276
|
+
* - `count` omitted but object present → renders as a small dot.
|
|
277
|
+
* - `count: 0` or passing `null` to `setNavBadge` clears the badge.
|
|
278
|
+
* `tone` defaults to `'attention'`.
|
|
279
|
+
*/
|
|
280
|
+
export interface NavBadge {
|
|
281
|
+
count?: number;
|
|
282
|
+
tone?: NavBadgeTone;
|
|
283
|
+
}
|
|
284
|
+
/** Sidebar navigation item registered by a plugin via `ctx.registerNav()`. */
|
|
204
285
|
export interface NavItem {
|
|
286
|
+
/** Unique nav item id (used for active-state tracking and badge keying). */
|
|
205
287
|
id: string;
|
|
288
|
+
/** Display label in the sidebar. */
|
|
206
289
|
label: string;
|
|
207
|
-
icon
|
|
208
|
-
|
|
290
|
+
/** Lucide icon name (e.g. "tasks", "calendar"). */
|
|
291
|
+
icon?: string;
|
|
292
|
+
/** Target route path. */
|
|
293
|
+
href?: string;
|
|
294
|
+
/** Sort order within the parent group. Lower renders first. */
|
|
209
295
|
order?: number;
|
|
296
|
+
/** Optional nested nav items for groups. */
|
|
210
297
|
children?: NavItem[];
|
|
298
|
+
/** If true, the group cannot be collapsed. */
|
|
211
299
|
alwaysExpanded?: boolean;
|
|
212
|
-
|
|
300
|
+
/**
|
|
301
|
+
* Initial badge state. Runtime updates flow through `setNavBadge` — the
|
|
302
|
+
* rendered badge for an item is `runtimeRegistry.get(id) ?? item.badge`.
|
|
303
|
+
* Most plugins leave this undefined and set badges purely at runtime.
|
|
304
|
+
*/
|
|
305
|
+
badge?: NavBadge;
|
|
306
|
+
}
|
|
307
|
+
/** HTTP route handler registered by a plugin via `ctx.registerRoute()`. */
|
|
213
308
|
export interface APIRoute {
|
|
309
|
+
/** Route path relative to `/api/plugins/{pluginId}`. */
|
|
214
310
|
path: string;
|
|
311
|
+
/** HTTP method. */
|
|
215
312
|
method: HttpMethod;
|
|
313
|
+
/** Request handler. Receives a standard Request and the plugin context. */
|
|
216
314
|
handler: (req: Request, ctx: PluginContext) => Response | Promise<Response>;
|
|
315
|
+
/** One-line summary for docs. */
|
|
217
316
|
summary?: string;
|
|
317
|
+
/** Full description for docs. */
|
|
218
318
|
description?: string;
|
|
319
|
+
/** Path param descriptor (e.g. ":id"). */
|
|
219
320
|
params?: string;
|
|
321
|
+
/** Input schema for validation and docs. */
|
|
220
322
|
input?: SchemaLike;
|
|
323
|
+
/** Output schema for docs. */
|
|
221
324
|
output?: SchemaLike;
|
|
325
|
+
/** Visibility tier (public/internal/experimental). */
|
|
222
326
|
visibility?: ContractVisibility;
|
|
327
|
+
/** Stability tier. */
|
|
223
328
|
stability?: ContractStability;
|
|
329
|
+
/** Reference examples for the docs site. */
|
|
224
330
|
examples?: DocsExample[];
|
|
331
|
+
/** Source location for generated docs back-references. */
|
|
225
332
|
source?: SourceLocation;
|
|
333
|
+
/** Permissions required to call this route. */
|
|
226
334
|
permissions?: string[];
|
|
227
335
|
}
|
|
336
|
+
/** Slot registration record: place a component at a named extension point. */
|
|
228
337
|
export interface UISlotRegistration {
|
|
229
338
|
slot: string;
|
|
230
339
|
component: ComponentType<Record<string, unknown>>;
|
|
231
340
|
order?: number;
|
|
232
341
|
}
|
|
342
|
+
/** Static content file shipped with a plugin (e.g. README, docs page). */
|
|
233
343
|
export interface ContentFile {
|
|
234
344
|
path: string;
|
|
235
345
|
}
|
|
346
|
+
/** An agent registered with the runtime (OpenClaw, etc.). */
|
|
236
347
|
export interface RuntimeAgent {
|
|
237
348
|
id: string;
|
|
238
349
|
name: string;
|
|
@@ -241,6 +352,7 @@ export interface RuntimeAgent {
|
|
|
241
352
|
status?: 'active' | 'inactive' | 'unknown';
|
|
242
353
|
metadata?: Record<string, unknown>;
|
|
243
354
|
}
|
|
355
|
+
/** A messaging channel (Discord, Slack, email, etc.) registered with the runtime. */
|
|
244
356
|
export interface RuntimeChannel {
|
|
245
357
|
id: string;
|
|
246
358
|
platform: string;
|
|
@@ -248,22 +360,57 @@ export interface RuntimeChannel {
|
|
|
248
360
|
capabilities: string[];
|
|
249
361
|
metadata?: Record<string, unknown>;
|
|
250
362
|
}
|
|
251
|
-
|
|
363
|
+
/** Whether to expose runtime-native tools for this agent turn. */
|
|
364
|
+
export type RuntimeMessageToolsMode = 'auto' | 'none';
|
|
365
|
+
/** Per-turn policy for which runtime tools the agent may call. */
|
|
366
|
+
export interface RuntimeMessageToolPolicy {
|
|
367
|
+
/**
|
|
368
|
+
* Controls whether runtime-native tools are available for this agent turn.
|
|
369
|
+
* `none` disables tools. Omit or use `auto` for runtime/provider defaults.
|
|
370
|
+
*/
|
|
371
|
+
toolsMode?: RuntimeMessageToolsMode;
|
|
372
|
+
/** Optional runtime-native tool allowlist for this turn. */
|
|
373
|
+
toolsAllow?: string[];
|
|
374
|
+
/** Optional runtime-native tool denylist for this turn. */
|
|
375
|
+
toolsDeny?: string[];
|
|
376
|
+
}
|
|
377
|
+
/** Arguments for a single message dispatched to an agent. */
|
|
378
|
+
export interface RuntimeMessageArgs extends RuntimeMessageToolPolicy {
|
|
252
379
|
agentId: string;
|
|
253
380
|
content: string;
|
|
381
|
+
/**
|
|
382
|
+
* Adapter-neutral durable conversation key. Runtime adapters should map the
|
|
383
|
+
* same agentId + threadId pair to the same provider/runtime session.
|
|
384
|
+
*/
|
|
254
385
|
threadId?: string;
|
|
255
386
|
metadata?: Record<string, unknown>;
|
|
256
387
|
}
|
|
388
|
+
/** Result returned by a non-streaming runtime message. */
|
|
257
389
|
export interface RuntimeMessageResult {
|
|
258
390
|
id: string;
|
|
259
391
|
content?: string;
|
|
260
392
|
metadata?: Record<string, unknown>;
|
|
261
393
|
}
|
|
394
|
+
/** Tool call/result event surfaced during a streaming agent turn. */
|
|
395
|
+
export interface RuntimeToolActivity {
|
|
396
|
+
phase: 'call' | 'result';
|
|
397
|
+
callId?: string;
|
|
398
|
+
toolName: string;
|
|
399
|
+
status?: 'running' | 'completed' | 'failed' | string;
|
|
400
|
+
summary?: string;
|
|
401
|
+
inputPreview?: string;
|
|
402
|
+
outputPreview?: string;
|
|
403
|
+
durationMs?: number;
|
|
404
|
+
exitCode?: number;
|
|
405
|
+
metadata?: Record<string, unknown>;
|
|
406
|
+
}
|
|
407
|
+
/** One chunk in a streaming agent response (text, tool, status, done, error). */
|
|
262
408
|
export interface RuntimeChatChunk {
|
|
263
409
|
type: 'text' | 'tool' | 'status' | 'done' | 'error';
|
|
264
410
|
content?: string;
|
|
265
|
-
data?: unknown;
|
|
411
|
+
data?: Record<string, unknown> | RuntimeToolActivity;
|
|
266
412
|
}
|
|
413
|
+
/** A cron-scheduled job tracked by the runtime. */
|
|
267
414
|
export interface CronJob {
|
|
268
415
|
id: string;
|
|
269
416
|
name: string;
|
|
@@ -273,6 +420,7 @@ export interface CronJob {
|
|
|
273
420
|
toolsAllow?: string[];
|
|
274
421
|
metadata?: Record<string, unknown>;
|
|
275
422
|
}
|
|
423
|
+
/** Execution record for a single cron job run. */
|
|
276
424
|
export interface CronRun {
|
|
277
425
|
id: string;
|
|
278
426
|
jobId: string;
|
|
@@ -282,14 +430,17 @@ export interface CronRun {
|
|
|
282
430
|
output?: string;
|
|
283
431
|
error?: string;
|
|
284
432
|
}
|
|
433
|
+
/** A skill (runtime-side capability) registered with an agent. */
|
|
285
434
|
export interface RuntimeSkill {
|
|
286
435
|
name: string;
|
|
287
436
|
description?: string;
|
|
288
437
|
}
|
|
438
|
+
/** A file in an agent's runtime workspace. */
|
|
289
439
|
export interface WorkspaceFile {
|
|
290
440
|
path: string;
|
|
291
441
|
content?: string;
|
|
292
442
|
}
|
|
443
|
+
/** Provider-agnostic interface for agent runtime adapters (OpenClaw, etc.). */
|
|
293
444
|
export interface AgentRuntimeAdapter {
|
|
294
445
|
agents: {
|
|
295
446
|
list(): Promise<RuntimeAgent[]>;
|
|
@@ -322,7 +473,11 @@ export interface AgentRuntimeAdapter {
|
|
|
322
473
|
title: string;
|
|
323
474
|
body?: string;
|
|
324
475
|
url?: string;
|
|
325
|
-
files?:
|
|
476
|
+
files?: Array<{
|
|
477
|
+
name: string;
|
|
478
|
+
path: string;
|
|
479
|
+
contentType?: string;
|
|
480
|
+
}>;
|
|
326
481
|
metadata?: Record<string, unknown>;
|
|
327
482
|
};
|
|
328
483
|
}): Promise<{
|
|
@@ -363,12 +518,14 @@ export interface AgentRuntimeAdapter {
|
|
|
363
518
|
}): Promise<AvailableModel[]>;
|
|
364
519
|
};
|
|
365
520
|
}
|
|
521
|
+
/** One entry in a task's activity log. */
|
|
366
522
|
export interface TaskLogEntry {
|
|
367
523
|
timestamp: string;
|
|
368
524
|
author: string;
|
|
369
525
|
message: string;
|
|
370
526
|
data?: Record<string, unknown>;
|
|
371
527
|
}
|
|
528
|
+
/** A task on the Bakin board. */
|
|
372
529
|
export interface Task {
|
|
373
530
|
id: string;
|
|
374
531
|
title: string;
|
|
@@ -385,10 +542,21 @@ export interface Task {
|
|
|
385
542
|
workflowId?: string;
|
|
386
543
|
scheduleJobId?: string;
|
|
387
544
|
projectId?: string;
|
|
545
|
+
availableAt?: string;
|
|
546
|
+
dueAt?: string;
|
|
547
|
+
source?: TaskSource;
|
|
388
548
|
order?: number;
|
|
389
549
|
createdAt?: string;
|
|
390
550
|
updatedAt?: string;
|
|
391
551
|
}
|
|
552
|
+
/** Identifies the plugin/entity that originated a task. */
|
|
553
|
+
export interface TaskSource {
|
|
554
|
+
pluginId?: string;
|
|
555
|
+
entityType?: string;
|
|
556
|
+
entityId?: string;
|
|
557
|
+
purpose?: string;
|
|
558
|
+
}
|
|
559
|
+
/** The seven task board columns. */
|
|
392
560
|
export interface TaskColumns {
|
|
393
561
|
backlog: Task[];
|
|
394
562
|
inProgress: Task[];
|
|
@@ -398,11 +566,14 @@ export interface TaskColumns {
|
|
|
398
566
|
blocked: Task[];
|
|
399
567
|
archived: Task[];
|
|
400
568
|
}
|
|
569
|
+
/** The full task board snapshot (columns + timestamp). */
|
|
401
570
|
export interface TaskBoard {
|
|
402
571
|
columns: TaskColumns;
|
|
403
572
|
timestamp?: string;
|
|
404
573
|
}
|
|
574
|
+
/** Valid task column identifier (keyof TaskColumns). */
|
|
405
575
|
export type ColumnId = keyof TaskColumns;
|
|
576
|
+
/** Payload for `tasks.create()`. */
|
|
406
577
|
export interface TaskCreateInput {
|
|
407
578
|
id?: string;
|
|
408
579
|
title: string;
|
|
@@ -414,8 +585,12 @@ export interface TaskCreateInput {
|
|
|
414
585
|
workflowId?: string;
|
|
415
586
|
projectId?: string;
|
|
416
587
|
parentId?: string | null;
|
|
588
|
+
availableAt?: string;
|
|
589
|
+
dueAt?: string;
|
|
590
|
+
source?: TaskSource;
|
|
417
591
|
skipWorkflowReason?: string;
|
|
418
592
|
}
|
|
593
|
+
/** Patch payload for `tasks.update()`. Nullable fields explicitly clear. */
|
|
419
594
|
export interface TaskUpdateInput {
|
|
420
595
|
title?: string;
|
|
421
596
|
description?: string;
|
|
@@ -429,7 +604,11 @@ export interface TaskUpdateInput {
|
|
|
429
604
|
scheduleJobId?: string;
|
|
430
605
|
projectId?: string;
|
|
431
606
|
parentId?: string | null;
|
|
607
|
+
availableAt?: string | null;
|
|
608
|
+
dueAt?: string | null;
|
|
609
|
+
source?: TaskSource | null;
|
|
432
610
|
}
|
|
611
|
+
/** CRUD service for tasks, exposed via `ctx.tasks`. */
|
|
433
612
|
export interface TaskService {
|
|
434
613
|
create(input: TaskCreateInput): Promise<Task>;
|
|
435
614
|
update(id: string, patch: TaskUpdateInput): Promise<Task>;
|
|
@@ -443,9 +622,11 @@ export interface TaskService {
|
|
|
443
622
|
}): Promise<Task[]>;
|
|
444
623
|
appendLog(id: string, entry: TaskLogEntry): Promise<void>;
|
|
445
624
|
}
|
|
625
|
+
/** Field schema entry for a search content type. */
|
|
446
626
|
export interface SearchSchemaField {
|
|
447
627
|
type: 'text' | 'keyword' | 'number' | 'boolean' | 'datetime' | 'array';
|
|
448
628
|
}
|
|
629
|
+
/** Named index definition (embedder + chunker config) for a content type. */
|
|
449
630
|
export interface SearchIndexDefinition {
|
|
450
631
|
name: string;
|
|
451
632
|
embedderRef: string;
|
|
@@ -457,6 +638,7 @@ export interface SearchIndexDefinition {
|
|
|
457
638
|
overlapTokens?: number;
|
|
458
639
|
};
|
|
459
640
|
}
|
|
641
|
+
/** Full content-type definition: schema, indexes, facets, reindex generator. */
|
|
460
642
|
export interface SearchContentTypeDefinition {
|
|
461
643
|
table: string;
|
|
462
644
|
schema: Record<string, SearchSchemaField>;
|
|
@@ -478,18 +660,22 @@ export interface SearchContentTypeDefinition {
|
|
|
478
660
|
}>;
|
|
479
661
|
verifyExists: (key: string) => Promise<boolean>;
|
|
480
662
|
}
|
|
663
|
+
/** File glob + mappers used by file-backed search content types. */
|
|
481
664
|
export interface FilePatternMapper {
|
|
482
665
|
pattern: string;
|
|
483
666
|
fileToId: (relPath: string) => string | null;
|
|
484
667
|
fileToDoc: (relPath: string, content: string) => Promise<Record<string, unknown> | null>;
|
|
485
668
|
}
|
|
669
|
+
/** File-backed content type: indexes documents derived from on-disk files. */
|
|
486
670
|
export interface FileBackedContentTypeDefinition extends SearchContentTypeDefinition {
|
|
487
671
|
filePatterns: FilePatternMapper[];
|
|
488
672
|
excludePatterns?: string[];
|
|
489
673
|
onSync?: (relPath: string, content: string) => Promise<void>;
|
|
490
674
|
onUnlink?: (relPath: string) => Promise<void>;
|
|
491
675
|
buildOnStartup?: boolean;
|
|
676
|
+
preserveVirtualDocuments?: boolean;
|
|
492
677
|
}
|
|
678
|
+
/** Query payload for `search.query()` — filters, facets, paging, strategy. */
|
|
493
679
|
export interface SearchQueryParams {
|
|
494
680
|
q: string;
|
|
495
681
|
filters?: Record<string, string | boolean | number>;
|
|
@@ -500,13 +686,17 @@ export interface SearchQueryParams {
|
|
|
500
686
|
aggregations?: Record<string, unknown>;
|
|
501
687
|
strategy?: 'rrf' | 'semantic_only' | 'full_text_only';
|
|
502
688
|
}
|
|
689
|
+
/** A single search hit with score and field projection. */
|
|
503
690
|
export interface SearchResult {
|
|
504
691
|
id: string;
|
|
505
692
|
table: string;
|
|
506
693
|
score: number;
|
|
507
694
|
fields: Record<string, unknown>;
|
|
508
695
|
rerankScore?: number;
|
|
696
|
+
/** Per-index score breakdown (e.g. full_text / text-embedding / visual). */
|
|
697
|
+
indexScores?: Record<string, number>;
|
|
509
698
|
}
|
|
699
|
+
/** Full search response: results, aggregations, and query metadata. */
|
|
510
700
|
export interface SearchResponse {
|
|
511
701
|
results: SearchResult[];
|
|
512
702
|
aggregations?: Record<string, Array<{
|
|
@@ -521,6 +711,7 @@ export interface SearchResponse {
|
|
|
521
711
|
source: 'search' | 'fallback';
|
|
522
712
|
};
|
|
523
713
|
}
|
|
714
|
+
/** Health snapshot reported by the search adapter (per-table state). */
|
|
524
715
|
export interface SearchHealthSnapshot {
|
|
525
716
|
enabled: boolean;
|
|
526
717
|
tables: Array<{
|
|
@@ -530,11 +721,13 @@ export interface SearchHealthSnapshot {
|
|
|
530
721
|
healthy: boolean;
|
|
531
722
|
}>;
|
|
532
723
|
}
|
|
724
|
+
/** Atomic transform operation applied to an indexed document. */
|
|
533
725
|
export interface SearchTransformOp {
|
|
534
726
|
op: '$set' | '$inc' | '$push';
|
|
535
727
|
field?: string;
|
|
536
728
|
value: unknown;
|
|
537
729
|
}
|
|
730
|
+
/** Search API exposed via `ctx.search` — index, query, transform documents. */
|
|
538
731
|
export interface SearchAPI {
|
|
539
732
|
registerContentType(def: SearchContentTypeDefinition): void;
|
|
540
733
|
registerFileBackedContentType(def: FileBackedContentTypeDefinition): void;
|
|
@@ -544,97 +737,176 @@ export interface SearchAPI {
|
|
|
544
737
|
query(params: SearchQueryParams): Promise<SearchResponse>;
|
|
545
738
|
health?(): Promise<SearchHealthSnapshot>;
|
|
546
739
|
}
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
740
|
+
/** The asset type taxonomy (mirrors ASSET_TYPES in the assets plugin). */
|
|
741
|
+
export type AssetTypeName = 'text' | 'images' | 'video' | 'audio' | 'plans' | 'research' | 'pdf' | 'data' | 'other';
|
|
742
|
+
/** Per-version generation provenance (matches the manifest's `generation` block). */
|
|
743
|
+
export interface AssetGenerationInfo {
|
|
744
|
+
provider: string;
|
|
745
|
+
model: string;
|
|
746
|
+
surface: string;
|
|
747
|
+
quality: string;
|
|
748
|
+
routeSource: string;
|
|
749
|
+
routeReason?: string;
|
|
750
|
+
}
|
|
751
|
+
/** Create a new versioned asset (v1) from a source file. */
|
|
752
|
+
export interface AssetCreateInput {
|
|
753
|
+
sourceFilePath: string;
|
|
754
|
+
type: AssetTypeName;
|
|
755
|
+
agent: string;
|
|
756
|
+
taskId: string | null;
|
|
757
|
+
slug?: string;
|
|
758
|
+
op?: 'generate' | 'upload' | 'import';
|
|
759
|
+
tool?: string | null;
|
|
760
|
+
prompt?: string | null;
|
|
761
|
+
promptHash?: string | null;
|
|
762
|
+
description?: string;
|
|
763
|
+
tags?: string[];
|
|
764
|
+
source?: {
|
|
765
|
+
kind: 'generated' | 'upload' | 'import' | 'clipboard' | 'workspace-file';
|
|
766
|
+
path: string | null;
|
|
767
|
+
};
|
|
768
|
+
generation?: AssetGenerationInfo | null;
|
|
769
|
+
}
|
|
770
|
+
/** Append a new version to an existing asset. */
|
|
771
|
+
export interface AssetVersionCreateInput {
|
|
772
|
+
sourceFilePath: string;
|
|
773
|
+
op?: 'edit' | 'generate' | 'upload' | 'import';
|
|
774
|
+
tool?: string | null;
|
|
775
|
+
prompt?: string | null;
|
|
776
|
+
promptHash?: string | null;
|
|
777
|
+
description?: string;
|
|
778
|
+
tags?: string[];
|
|
779
|
+
generation?: AssetGenerationInfo | null;
|
|
780
|
+
}
|
|
781
|
+
/** Render a derived export of a version (keyed/idempotent by surface). */
|
|
782
|
+
export interface AssetExportRequest {
|
|
783
|
+
fromVersion?: number;
|
|
784
|
+
surface: string;
|
|
785
|
+
format: 'jpg' | 'png' | 'webp';
|
|
786
|
+
width: number;
|
|
787
|
+
height: number;
|
|
788
|
+
quality?: number;
|
|
789
|
+
}
|
|
790
|
+
/** Reference to a versioned asset: its stable id and the version just written. */
|
|
791
|
+
export interface VersionedAssetRef {
|
|
792
|
+
assetId: string;
|
|
793
|
+
version: number;
|
|
553
794
|
}
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
type: 'text' | 'images' | 'video' | 'audio' | 'plans' | 'research' | 'pdf' | 'data' | 'other';
|
|
795
|
+
/** Resolved on-disk location of a specific asset version, for reads/serving. */
|
|
796
|
+
export interface AssetVersionFileRef {
|
|
797
|
+
absPath: string;
|
|
558
798
|
mimeType: string;
|
|
559
|
-
|
|
560
|
-
mtimeMs?: number;
|
|
561
|
-
metadata: {
|
|
562
|
-
agent: string;
|
|
563
|
-
taskId: string | null;
|
|
564
|
-
created: string;
|
|
565
|
-
tool?: string;
|
|
566
|
-
description?: string;
|
|
567
|
-
tags?: string[];
|
|
568
|
-
originalFilename?: string;
|
|
569
|
-
};
|
|
570
|
-
variants?: AssetVariantMeta[];
|
|
799
|
+
version: number;
|
|
571
800
|
}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
type:
|
|
801
|
+
/** Current-version summary of an asset, addressed by id. */
|
|
802
|
+
export interface AssetSummary {
|
|
803
|
+
assetId: string;
|
|
804
|
+
type: AssetTypeName;
|
|
805
|
+
agent: string;
|
|
806
|
+
taskId: string | null;
|
|
807
|
+
created: string;
|
|
808
|
+
updated: string;
|
|
809
|
+
currentVersion: number;
|
|
810
|
+
versionCount: number;
|
|
811
|
+
description: string;
|
|
812
|
+
tags: string[];
|
|
576
813
|
mimeType: string;
|
|
814
|
+
width: number | null;
|
|
815
|
+
height: number | null;
|
|
577
816
|
size: number;
|
|
578
|
-
|
|
579
|
-
expiresAt: string;
|
|
580
|
-
metadata: AssetMeta['metadata'] | null;
|
|
581
|
-
}
|
|
582
|
-
export interface AssetFileRef {
|
|
583
|
-
kind: 'asset';
|
|
584
|
-
filename: string;
|
|
585
|
-
mimeType?: string;
|
|
817
|
+
hasThumb: boolean;
|
|
586
818
|
}
|
|
819
|
+
/** Assets API exposed via `ctx.assets` — versioned asset-as-directory surface. */
|
|
587
820
|
export interface AssetsAPI {
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
821
|
+
createAsset(input: AssetCreateInput): Promise<VersionedAssetRef>;
|
|
822
|
+
/** Read an asset's current-version summary by id (type/description/tags/etc.), or null. */
|
|
823
|
+
getAsset(assetId: string): Promise<AssetSummary | null>;
|
|
824
|
+
addVersion(assetId: string, input: AssetVersionCreateInput): Promise<VersionedAssetRef>;
|
|
825
|
+
addExport(assetId: string, input: AssetExportRequest): Promise<{
|
|
826
|
+
name: string;
|
|
827
|
+
file: string;
|
|
828
|
+
}>;
|
|
829
|
+
resolveVersionFile(assetId: string, version?: number): Promise<AssetVersionFileRef | null>;
|
|
595
830
|
}
|
|
831
|
+
/** Result returned from an exec tool handler. */
|
|
596
832
|
export interface ExecToolResult {
|
|
597
833
|
ok: boolean;
|
|
598
834
|
error?: string;
|
|
599
835
|
details?: unknown;
|
|
600
836
|
[key: string]: unknown;
|
|
601
837
|
}
|
|
838
|
+
/** Context passed to an exec tool handler. Subset of PluginContext sans UI registration. */
|
|
602
839
|
export interface PluginToolContext {
|
|
840
|
+
/** Plugin-scoped storage adapter. */
|
|
603
841
|
storage: StorageAdapter;
|
|
842
|
+
/** Cross-plugin event bus. */
|
|
604
843
|
events: EventBus;
|
|
844
|
+
/** ID of the plugin owning this tool. */
|
|
605
845
|
pluginId: string;
|
|
846
|
+
/** Agent runtime adapter (messaging, agents, channels, cron). */
|
|
606
847
|
runtime: AgentRuntimeAdapter;
|
|
848
|
+
/** Task CRUD service. */
|
|
607
849
|
tasks: TaskService;
|
|
850
|
+
/** Search API. */
|
|
608
851
|
search: SearchAPI;
|
|
852
|
+
/** Assets API. */
|
|
609
853
|
assets: AssetsAPI;
|
|
854
|
+
/** Hook registry. */
|
|
610
855
|
hooks: HookAPI;
|
|
856
|
+
/** Activity feed and audit log. */
|
|
611
857
|
activity: ActivityAPI;
|
|
858
|
+
/** Read this plugin's persisted settings. */
|
|
612
859
|
getSettings<T = Record<string, unknown>>(): T;
|
|
613
860
|
}
|
|
861
|
+
/** MCP exec tool definition registered via `ctx.registerExecTool()`. */
|
|
614
862
|
export interface ExecToolDefinition {
|
|
863
|
+
/** Tool name. Convention: `bakin_exec_{pluginId}_{action}`. */
|
|
615
864
|
name: string;
|
|
865
|
+
/** Description shown to the agent (used for tool selection). */
|
|
616
866
|
description: string;
|
|
867
|
+
/** Optional UI label for the activity feed. */
|
|
617
868
|
label?: string;
|
|
869
|
+
/** If true, this tool can fire multiple times in a single agent turn. */
|
|
618
870
|
activityDuplicate?: boolean;
|
|
871
|
+
/** Zod raw shape describing the tool's parameters. */
|
|
619
872
|
parameters: ZodRawShape;
|
|
873
|
+
/** Handler that executes the tool. */
|
|
620
874
|
handler: (params: Record<string, unknown>, agent: string, ctx?: PluginToolContext) => Promise<ExecToolResult>;
|
|
875
|
+
/** Optional source-file path for generated docs. */
|
|
621
876
|
source?: string;
|
|
622
877
|
}
|
|
878
|
+
/** Runtime skill definition registered via `ctx.registerSkill()`. */
|
|
623
879
|
export interface SkillDefinition {
|
|
624
880
|
name: string;
|
|
625
881
|
instructions: string;
|
|
626
882
|
output_schema?: Record<string, unknown>;
|
|
627
883
|
source?: string;
|
|
884
|
+
/** Absolute source markdown file path when the skill was loaded from a managed package/plugin file. */
|
|
885
|
+
sourcePath?: string;
|
|
886
|
+
}
|
|
887
|
+
/** Layout hints for a workflow's canvas rendering. */
|
|
888
|
+
export interface WorkflowLayoutInput {
|
|
889
|
+
positions?: Record<string, {
|
|
890
|
+
x: number;
|
|
891
|
+
y: number;
|
|
892
|
+
[key: string]: unknown;
|
|
893
|
+
}>;
|
|
894
|
+
[key: string]: unknown;
|
|
628
895
|
}
|
|
896
|
+
/** Plugin-contributed workflow definition input shape. */
|
|
629
897
|
export interface WorkflowDefinitionInput {
|
|
630
898
|
id?: string;
|
|
631
899
|
name: string;
|
|
632
900
|
description: string;
|
|
633
901
|
version: number;
|
|
634
902
|
inputs?: Record<string, unknown>;
|
|
903
|
+
layout?: WorkflowLayoutInput;
|
|
635
904
|
steps: unknown[];
|
|
905
|
+
[key: string]: unknown;
|
|
636
906
|
}
|
|
907
|
+
/** Field types supported by FormField. */
|
|
637
908
|
export type FormFieldType = 'string' | 'text' | 'number' | 'boolean' | 'select' | 'agent' | 'skill' | 'list';
|
|
909
|
+
/** Form field descriptor for plugin-contributed workflow nodes. */
|
|
638
910
|
export interface FormField {
|
|
639
911
|
name: string;
|
|
640
912
|
type: FormFieldType;
|
|
@@ -645,33 +917,75 @@ export interface FormField {
|
|
|
645
917
|
label: string;
|
|
646
918
|
}[];
|
|
647
919
|
}
|
|
920
|
+
/** Edge constraints for a plugin-contributed workflow node type. */
|
|
648
921
|
export interface EdgeRules {
|
|
649
922
|
maxInbound?: number;
|
|
650
923
|
maxOutbound?: number;
|
|
651
924
|
}
|
|
925
|
+
/** Workflow node type contributed by a plugin (custom step kind). */
|
|
652
926
|
export interface PluginNodeTypeInput<T = unknown> {
|
|
653
927
|
kind: string;
|
|
654
928
|
zodSchema: SchemaLike<T>;
|
|
655
929
|
formFields: FormField[];
|
|
656
930
|
edgeRules?: EdgeRules;
|
|
657
931
|
}
|
|
932
|
+
/** Notification channel definition contributed by a plugin. */
|
|
658
933
|
export interface PluginNotificationChannelInput {
|
|
659
934
|
id: string;
|
|
660
935
|
label: string;
|
|
661
936
|
initials?: string;
|
|
662
937
|
icon?: string;
|
|
663
938
|
}
|
|
939
|
+
/** Result row returned by a health check (doctor). */
|
|
664
940
|
export interface HealthCheckResult {
|
|
941
|
+
/** Stable check identifier. */
|
|
665
942
|
check: string;
|
|
943
|
+
/** Severity of the result. */
|
|
666
944
|
status: 'ok' | 'warn' | 'error' | 'fixed';
|
|
945
|
+
/** Human-readable message describing the finding. */
|
|
667
946
|
message: string;
|
|
947
|
+
/** Whether the issue can be auto-fixed by an attached repair handler. */
|
|
668
948
|
autoFixable: boolean;
|
|
669
949
|
}
|
|
950
|
+
/** Repair safety tier: safe (auto), manual (needs review), destructive (data-affecting). */
|
|
951
|
+
export type HealthRepairSafety = 'safe' | 'manual' | 'destructive';
|
|
952
|
+
/** Single change a repair plan will apply. */
|
|
953
|
+
export interface HealthRepairChange {
|
|
954
|
+
kind: 'file' | 'setting' | 'service' | 'runtime' | 'task' | 'other';
|
|
955
|
+
target: string;
|
|
956
|
+
action: 'create' | 'update' | 'delete' | 'install' | 'invoke';
|
|
957
|
+
description: string;
|
|
958
|
+
}
|
|
959
|
+
/** One item in a repair plan: what will change and why. */
|
|
960
|
+
export interface HealthRepairPlanItem {
|
|
961
|
+
id: string;
|
|
962
|
+
checkId: string;
|
|
963
|
+
title: string;
|
|
964
|
+
reason: string;
|
|
965
|
+
safety: HealthRepairSafety;
|
|
966
|
+
requiresConfirmation: boolean;
|
|
967
|
+
changes: HealthRepairChange[];
|
|
968
|
+
}
|
|
969
|
+
/** Result of applying a single repair plan item. */
|
|
970
|
+
export interface HealthRepairApplyResult {
|
|
971
|
+
id: string;
|
|
972
|
+
checkId: string;
|
|
973
|
+
status: 'applied' | 'skipped' | 'failed';
|
|
974
|
+
message: string;
|
|
975
|
+
changes: HealthRepairChange[];
|
|
976
|
+
}
|
|
977
|
+
/** Two-phase repair handler attached to a health check. */
|
|
978
|
+
export interface HealthRepairHandler {
|
|
979
|
+
plan(rows: HealthCheckResult[]): Promise<HealthRepairPlanItem[]>;
|
|
980
|
+
apply(items: HealthRepairPlanItem[]): Promise<HealthRepairApplyResult[]>;
|
|
981
|
+
}
|
|
982
|
+
/** Health check registration input passed to `ctx.registerHealthCheck()`. */
|
|
670
983
|
export interface PluginHealthCheckInput {
|
|
671
984
|
id: string;
|
|
672
985
|
name: string;
|
|
673
986
|
run: () => Promise<HealthCheckResult[]>;
|
|
674
987
|
autoFix?: boolean;
|
|
988
|
+
repair?: HealthRepairHandler;
|
|
675
989
|
}
|
|
676
990
|
interface BaseSettingsField {
|
|
677
991
|
key: string;
|
|
@@ -679,18 +993,22 @@ interface BaseSettingsField {
|
|
|
679
993
|
description?: string;
|
|
680
994
|
required?: boolean;
|
|
681
995
|
}
|
|
996
|
+
/** Single-line text settings field. */
|
|
682
997
|
export interface StringSettingsField extends BaseSettingsField {
|
|
683
998
|
type: 'string';
|
|
684
999
|
default?: string;
|
|
685
1000
|
}
|
|
1001
|
+
/** Numeric settings field with optional default. */
|
|
686
1002
|
export interface NumberSettingsField extends BaseSettingsField {
|
|
687
1003
|
type: 'number';
|
|
688
1004
|
default?: number;
|
|
689
1005
|
}
|
|
1006
|
+
/** Boolean toggle settings field. */
|
|
690
1007
|
export interface BooleanSettingsField extends BaseSettingsField {
|
|
691
1008
|
type: 'boolean';
|
|
692
1009
|
default?: boolean;
|
|
693
1010
|
}
|
|
1011
|
+
/** Dropdown settings field with predefined options. */
|
|
694
1012
|
export interface SelectSettingsField extends BaseSettingsField {
|
|
695
1013
|
type: 'select';
|
|
696
1014
|
options: {
|
|
@@ -699,6 +1017,7 @@ export interface SelectSettingsField extends BaseSettingsField {
|
|
|
699
1017
|
}[];
|
|
700
1018
|
default?: string;
|
|
701
1019
|
}
|
|
1020
|
+
/** Repeatable list settings field with per-item shape. */
|
|
702
1021
|
export interface ListSettingsField extends BaseSettingsField {
|
|
703
1022
|
type: 'list';
|
|
704
1023
|
itemShape: Record<string, StringSettingsField | NumberSettingsField | BooleanSettingsField | SelectSettingsField>;
|
|
@@ -708,80 +1027,130 @@ export interface ListSettingsField extends BaseSettingsField {
|
|
|
708
1027
|
maxItems?: number;
|
|
709
1028
|
uniqueField?: string;
|
|
710
1029
|
}
|
|
1030
|
+
/** Union of all supported settings field types. */
|
|
711
1031
|
export type SettingsField = StringSettingsField | NumberSettingsField | BooleanSettingsField | SelectSettingsField | ListSettingsField;
|
|
1032
|
+
/** Plugin settings schema — declares fields rendered on the settings page. */
|
|
712
1033
|
export interface PluginSettingsSchema {
|
|
1034
|
+
/** Ordered list of settings fields for the form. */
|
|
713
1035
|
fields: SettingsField[];
|
|
714
1036
|
}
|
|
1037
|
+
/** The activation context passed to a plugin's `activate(ctx)` method.
|
|
1038
|
+
* This is the primary API surface for plugin authors. Everything a plugin
|
|
1039
|
+
* needs to register with the host — routes, tools, nav, slots, health checks,
|
|
1040
|
+
* settings — flows through this object. */
|
|
715
1041
|
export interface PluginContext {
|
|
1042
|
+
/** Plugin-scoped filesystem storage adapter. */
|
|
716
1043
|
storage: StorageAdapter;
|
|
1044
|
+
/** Cross-plugin event bus. */
|
|
717
1045
|
events: EventBus;
|
|
1046
|
+
/** ID of the plugin this context belongs to. */
|
|
718
1047
|
pluginId: string;
|
|
1048
|
+
/** Agent runtime adapter (agents, messaging, channels, cron, skills). */
|
|
719
1049
|
runtime: AgentRuntimeAdapter;
|
|
1050
|
+
/** Task CRUD service. */
|
|
720
1051
|
tasks: TaskService;
|
|
1052
|
+
/** Assets API for asset metadata + file lookups. */
|
|
721
1053
|
assets: AssetsAPI;
|
|
1054
|
+
/** Register sidebar navigation items. */
|
|
722
1055
|
registerNav(items: NavItem[]): void;
|
|
1056
|
+
/** Register an HTTP route under `/api/plugins/{pluginId}`. */
|
|
723
1057
|
registerRoute(route: APIRoute): void;
|
|
1058
|
+
/** Register a component for a named slot (legacy — prefer `<Slot>` from `/slots`). */
|
|
724
1059
|
registerSlot(registration: UISlotRegistration): void;
|
|
1060
|
+
/** Register an MCP exec tool agents can call. */
|
|
725
1061
|
registerExecTool(tool: ExecToolDefinition): void;
|
|
1062
|
+
/** Register a runtime skill (capability definition). */
|
|
726
1063
|
registerSkill(skill: SkillDefinition): void;
|
|
1064
|
+
/** Register a workflow definition (or template) the plugin ships. */
|
|
727
1065
|
registerWorkflow(definition: WorkflowDefinitionInput, opts?: {
|
|
728
1066
|
readOnly?: boolean;
|
|
729
1067
|
}): void;
|
|
1068
|
+
/** Register a custom workflow node type (step kind). */
|
|
730
1069
|
registerNodeType<T = unknown>(def: PluginNodeTypeInput<T>): string;
|
|
1070
|
+
/** Register a notification channel the runtime can deliver to. */
|
|
731
1071
|
registerNotificationChannel(def: PluginNotificationChannelInput): string;
|
|
1072
|
+
/** Register a health check that runs on `bakin doctor`. */
|
|
732
1073
|
registerHealthCheck(def: PluginHealthCheckInput): string;
|
|
1074
|
+
/** Subscribe to file globs for live updates (Chokidar-based). */
|
|
733
1075
|
watchFiles(patterns: string[]): void;
|
|
1076
|
+
/** Read this plugin's persisted settings. */
|
|
734
1077
|
getSettings<T = Record<string, unknown>>(): T;
|
|
1078
|
+
/** Patch this plugin's persisted settings. */
|
|
735
1079
|
updateSettings(patch: Record<string, unknown>): void;
|
|
1080
|
+
/** Activity feed + audit log API. */
|
|
736
1081
|
activity: ActivityAPI;
|
|
1082
|
+
/** Plugin-scoped structured logger. Optional — falls back to console. */
|
|
1083
|
+
log?: PluginLogger;
|
|
1084
|
+
/** Cross-plugin hook registry. */
|
|
737
1085
|
hooks: HookAPI;
|
|
1086
|
+
/** Search API for indexing and querying. */
|
|
738
1087
|
search: SearchAPI;
|
|
739
1088
|
}
|
|
1089
|
+
/** The main plugin interface. The default export of a plugin's `index.ts`. */
|
|
740
1090
|
export interface BakinPlugin {
|
|
1091
|
+
/** Unique plugin identifier (matches manifest `id`). */
|
|
741
1092
|
id: string;
|
|
1093
|
+
/** Display name. */
|
|
742
1094
|
name: string;
|
|
1095
|
+
/** Plugin version (semver). */
|
|
743
1096
|
version: string;
|
|
1097
|
+
/** Called once at plugin load. Register routes/tools/nav/etc. here. */
|
|
744
1098
|
activate(ctx: PluginContext): void | Promise<void>;
|
|
1099
|
+
/** Called after all plugins have activated. Useful for cross-plugin setup. */
|
|
745
1100
|
onReady?(): void | Promise<void>;
|
|
1101
|
+
/** Called when the server shuts down or the plugin is hot-swapped out. */
|
|
746
1102
|
onShutdown?(): void | Promise<void>;
|
|
1103
|
+
/** Called when this plugin's settings are persisted. */
|
|
747
1104
|
onSettingsChange?(settings: Record<string, unknown>): void | Promise<void>;
|
|
1105
|
+
/** Called when the plugin is uninstalled — clean up persisted data here. */
|
|
748
1106
|
onUninstall?(ctx: PluginContext): void | Promise<void>;
|
|
1107
|
+
/** Settings schema rendered on this plugin's settings page. */
|
|
749
1108
|
settingsSchema?: PluginSettingsSchema;
|
|
1109
|
+
/** Convenience: nav items to auto-register at activation. */
|
|
750
1110
|
navItems?: NavItem[];
|
|
1111
|
+
/** Convenience: static content files declared at construction. */
|
|
751
1112
|
contentFiles?: ContentFile[];
|
|
752
1113
|
}
|
|
1114
|
+
/** Single calendar event (time + text). */
|
|
753
1115
|
export interface CalendarEvent {
|
|
754
1116
|
time?: string;
|
|
755
1117
|
text: string;
|
|
756
1118
|
}
|
|
1119
|
+
/** One day on an agent's calendar (date + list of events). */
|
|
757
1120
|
export interface CalendarDay {
|
|
758
1121
|
date: string;
|
|
759
1122
|
label?: string;
|
|
760
1123
|
events: CalendarEvent[];
|
|
761
1124
|
}
|
|
1125
|
+
/** A recurring event (cron expression + display text). */
|
|
762
1126
|
export interface RecurringEvent {
|
|
763
1127
|
schedule: string;
|
|
764
1128
|
text: string;
|
|
765
1129
|
}
|
|
1130
|
+
/** Single memory entry (decision, learned-thing, or freeform note). */
|
|
766
1131
|
export interface MemoryEntry {
|
|
767
1132
|
type: 'decision' | 'learned' | 'note';
|
|
768
1133
|
text: string;
|
|
769
1134
|
}
|
|
1135
|
+
/** Memory entries grouped by day. */
|
|
770
1136
|
export interface MemoryDay {
|
|
771
1137
|
date: string;
|
|
772
1138
|
entries: MemoryEntry[];
|
|
773
1139
|
}
|
|
1140
|
+
/** Agent heartbeat snapshot (status + current task + timestamp). */
|
|
774
1141
|
export interface Heartbeat {
|
|
775
1142
|
status: 'working' | 'idle' | 'down';
|
|
776
1143
|
currentTask?: string;
|
|
777
1144
|
timestamp: string;
|
|
778
1145
|
}
|
|
1146
|
+
/** Project metadata loaded from a markdown project file. */
|
|
779
1147
|
export interface ProjectMeta {
|
|
780
1148
|
filename: string;
|
|
781
1149
|
title: string;
|
|
782
1150
|
status?: string;
|
|
783
1151
|
content: string;
|
|
784
1152
|
}
|
|
1153
|
+
/** A model available in the models catalog (LLM, image, or video). */
|
|
785
1154
|
export interface AvailableModel {
|
|
786
1155
|
id: string;
|
|
787
1156
|
name?: string;
|
|
@@ -806,6 +1175,7 @@ export interface AvailableModel {
|
|
|
806
1175
|
providerBrandIconSlug?: string;
|
|
807
1176
|
providerBrandColor?: string;
|
|
808
1177
|
}
|
|
1178
|
+
/** A workflow definition stored on disk (YAML or programmatic). */
|
|
809
1179
|
export interface WorkflowDefinition {
|
|
810
1180
|
id?: string;
|
|
811
1181
|
name: string;
|
|
@@ -814,27 +1184,38 @@ export interface WorkflowDefinition {
|
|
|
814
1184
|
steps: unknown[];
|
|
815
1185
|
[key: string]: unknown;
|
|
816
1186
|
}
|
|
1187
|
+
/** A running instance of a workflow attached to a task. */
|
|
817
1188
|
export interface WorkflowInstance {
|
|
818
1189
|
id: string;
|
|
819
1190
|
taskId?: string;
|
|
820
1191
|
status?: string;
|
|
821
1192
|
[key: string]: unknown;
|
|
822
1193
|
}
|
|
1194
|
+
/** One step in a workflow definition or instance. */
|
|
823
1195
|
export interface WorkflowStep {
|
|
824
1196
|
id: string;
|
|
825
1197
|
type: string;
|
|
826
1198
|
[key: string]: unknown;
|
|
827
1199
|
}
|
|
1200
|
+
/** Alias for WorkflowDefinition when used as a reusable template. */
|
|
828
1201
|
export type WorkflowTemplate = WorkflowDefinition;
|
|
1202
|
+
/** The `bakin.config.ts` shape — root configuration for a Bakin installation. */
|
|
829
1203
|
export interface BakinConfig {
|
|
1204
|
+
/** Plugins to load at startup. */
|
|
830
1205
|
plugins: PluginEntry[];
|
|
1206
|
+
/** Theme overrides for CSS custom properties. */
|
|
831
1207
|
theme?: Record<string, string>;
|
|
1208
|
+
/** Storage configuration. */
|
|
832
1209
|
storage?: {
|
|
1210
|
+
/** Override the default content directory. */
|
|
833
1211
|
contentDir?: string;
|
|
834
1212
|
};
|
|
835
1213
|
}
|
|
1214
|
+
/** A plugin entry in `bakin.config.ts`. */
|
|
836
1215
|
export interface PluginEntry {
|
|
1216
|
+
/** Path or package specifier resolving to the plugin's entry file. */
|
|
837
1217
|
path: string;
|
|
1218
|
+
/** If false, the plugin is loaded but not activated. Default true. */
|
|
838
1219
|
enabled?: boolean;
|
|
839
1220
|
}
|
|
840
1221
|
export {};
|