@makinbakin/sdk 0.0.1-rc.2 → 0.0.1-rc.20
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 +7 -2
- package/_internal/app/components/confirm-dialog.d.ts +33 -0
- package/_internal/app/components/empty-state.d.ts +14 -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 +0 -9
- package/_internal/app/hooks/use-horizontal-resize.d.ts +22 -0
- package/_internal/app/hooks/use-json-fetch.d.ts +21 -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-resizable-pane.d.ts +35 -0
- package/_internal/app/hooks/use-schedule.d.ts +2 -1
- package/_internal/app/hooks/use-task-run-history.d.ts +26 -0
- package/_internal/app/hooks/use-vertical-resize.d.ts +6 -7
- package/_internal/app/types/index.d.ts +1 -105
- package/_internal/core/adapters/runtime/concepts.d.ts +141 -67
- package/_internal/core/adapters/runtime/errors.d.ts +86 -0
- package/_internal/core/adapters/runtime/index.d.ts +3 -1
- package/_internal/core/content-dir.d.ts +1 -0
- package/_internal/core/format.d.ts +9 -0
- package/_internal/core/plugin-types.d.ts +124 -470
- package/_internal/plugins/models/hooks/use-available-models.d.ts +5 -0
- package/_internal/plugins/team/types.d.ts +14 -4
- package/components/index.d.ts +40 -2
- package/components/index.js +15897 -1678
- package/hooks/index.d.ts +69 -8
- package/hooks/index.js +14589 -369
- package/index.d.ts +64 -2
- package/index.js +228 -7
- package/metadata/index.d.ts +14 -1
- package/package.json +1 -1
- package/register.d.ts +45 -9
- package/routing/index.d.ts +6 -1
- package/routing/index.js +13 -1
- package/slots/index.d.ts +16 -24
- package/slots/index.js +196 -30
- package/types/index.d.ts +15 -919
- package/ui/index.js +2 -1
- package/utils/index.d.ts +40 -3
- package/utils/index.js +57 -0
- package/_internal/app/hooks/use-assets.d.ts +0 -25
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Plugin system type definitions for Bakin.
|
|
3
|
-
*
|
|
2
|
+
* Plugin system type definitions for Bakin (the internal, in-process surface).
|
|
3
|
+
*
|
|
4
|
+
* Two-tier contract — read before "deduplicating" against the SDK:
|
|
5
|
+
* `@makinbakin/sdk/types` is the PUBLISHED, self-contained, deliberately
|
|
6
|
+
* NARROWER plugin-author surface; this file is the INTERNAL surface that
|
|
7
|
+
* in-process core plugins actually receive. They are NOT a fork to collapse.
|
|
8
|
+
* Concretely:
|
|
9
|
+
* - `PluginContext.runtime` here is the FULL `AgentRuntimeAdapter`
|
|
10
|
+
* (adapters/runtime/concepts.ts: agents×11, tools, sessions, memory,
|
|
11
|
+
* config, images, media, restart…). Core plugins use ~15 full-only
|
|
12
|
+
* methods. The SDK exposes a curated subset.
|
|
13
|
+
* - `ctx.tasks` here returns the `PluginTask` projection; the SDK returns
|
|
14
|
+
* `Task`. `BakinPlugin` here adds `routes?`. `StorageAdapter`/`NavItem`/
|
|
15
|
+
* `APIRoute`/`HookAPI`/`SkillDefinition` are intentionally fuller here.
|
|
16
|
+
* Genuinely-identical LEAF data types (health, exec-result, search, manifest,
|
|
17
|
+
* EventBus/ActivityAPI/PluginLogger, TaskLogEntry, …) ARE single-homed in the
|
|
18
|
+
* SDK and re-exported below. Collapsing the boundary itself is WS2 work.
|
|
4
19
|
*/
|
|
5
20
|
import type { ZodRawShape, ZodType } from 'zod';
|
|
21
|
+
import type { ActivityAPI, EventBus, ExecToolResult, PluginHealthCheckInput, PluginLogger, SearchAPI, TaskLogEntry } from '@makinbakin/sdk/types';
|
|
6
22
|
import type { ContractStability, ContractVisibility, DocsExample, SchemaLike, SourceLocation } from './docs';
|
|
7
23
|
import type { AgentRuntimeAdapter } from './adapters/runtime';
|
|
8
24
|
import type { APIRoute as DeclarativeAPIRoute, PluginContextLite } from './routing/types';
|
|
@@ -36,11 +52,7 @@ export interface StorageAdapter {
|
|
|
36
52
|
*/
|
|
37
53
|
searchPath?(path: string): string;
|
|
38
54
|
}
|
|
39
|
-
export
|
|
40
|
-
emit(event: string, data?: Record<string, unknown>): void;
|
|
41
|
-
on(pattern: string, handler: (event: string, data: Record<string, unknown>) => void): () => void;
|
|
42
|
-
once(pattern: string, handler: (event: string, data: Record<string, unknown>) => void): () => void;
|
|
43
|
-
}
|
|
55
|
+
export type { EventBus } from '@makinbakin/sdk/types';
|
|
44
56
|
export interface NavItem {
|
|
45
57
|
id: string;
|
|
46
58
|
label: string;
|
|
@@ -73,13 +85,7 @@ export interface UISlotRegistration {
|
|
|
73
85
|
export interface ContentFile {
|
|
74
86
|
path: string;
|
|
75
87
|
}
|
|
76
|
-
|
|
77
|
-
export interface ExecToolResult {
|
|
78
|
-
ok: boolean;
|
|
79
|
-
error?: string;
|
|
80
|
-
details?: unknown;
|
|
81
|
-
[key: string]: unknown;
|
|
82
|
-
}
|
|
88
|
+
export type { ExecToolResult } from '@makinbakin/sdk/types';
|
|
83
89
|
/** Definition for a registerable execution tool */
|
|
84
90
|
/** Context available to exec tool handlers — provides access to plugin services */
|
|
85
91
|
export interface PluginToolContext {
|
|
@@ -109,6 +115,16 @@ export interface SkillDefinition {
|
|
|
109
115
|
instructions: string;
|
|
110
116
|
output_schema?: Record<string, unknown>;
|
|
111
117
|
source?: string;
|
|
118
|
+
/** Absolute source markdown file path when the skill was loaded from a managed package/plugin file. */
|
|
119
|
+
sourcePath?: string;
|
|
120
|
+
}
|
|
121
|
+
export interface WorkflowLayoutInput {
|
|
122
|
+
positions?: Record<string, {
|
|
123
|
+
x: number;
|
|
124
|
+
y: number;
|
|
125
|
+
[key: string]: unknown;
|
|
126
|
+
}>;
|
|
127
|
+
[key: string]: unknown;
|
|
112
128
|
}
|
|
113
129
|
export interface WorkflowDefinitionInput {
|
|
114
130
|
/** Stable workflow id. Falls back to slug(name) when omitted. */
|
|
@@ -117,23 +133,11 @@ export interface WorkflowDefinitionInput {
|
|
|
117
133
|
description: string;
|
|
118
134
|
version: number;
|
|
119
135
|
inputs?: Record<string, unknown>;
|
|
136
|
+
layout?: WorkflowLayoutInput;
|
|
120
137
|
steps: unknown[];
|
|
138
|
+
[key: string]: unknown;
|
|
121
139
|
}
|
|
122
|
-
export
|
|
123
|
-
/** Log a human-readable message to the live activity feed */
|
|
124
|
-
log(agent: string, message: string, opts?: {
|
|
125
|
-
taskId?: string;
|
|
126
|
-
category?: string;
|
|
127
|
-
}): void;
|
|
128
|
-
/** Log a structured audit event */
|
|
129
|
-
audit(event: string, agent: string, data?: Record<string, unknown>): void;
|
|
130
|
-
}
|
|
131
|
-
export interface PluginLogger {
|
|
132
|
-
debug(message: string, data?: Record<string, unknown>): void;
|
|
133
|
-
info(message: string, data?: Record<string, unknown>): void;
|
|
134
|
-
warn(message: string, errorOrData?: unknown, data?: Record<string, unknown>): void;
|
|
135
|
-
error(message: string, errorOrData?: unknown, data?: Record<string, unknown>): void;
|
|
136
|
-
}
|
|
140
|
+
export type { ActivityAPI, PluginLogger } from '@makinbakin/sdk/types';
|
|
137
141
|
export interface HookAPI {
|
|
138
142
|
/** Register a handler for a named hook. Returns unsubscribe function. */
|
|
139
143
|
register(name: string, handler: (data: any) => any, metadata?: HookRegistrationMetadata): () => void;
|
|
@@ -215,68 +219,8 @@ export interface NotificationChannelDef extends PluginNotificationChannelInput {
|
|
|
215
219
|
/** Set when runtime === 'plugin'; identifies the owning plugin. */
|
|
216
220
|
pluginId?: string;
|
|
217
221
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
*/
|
|
221
|
-
export interface HealthCheckResult {
|
|
222
|
-
check: string;
|
|
223
|
-
status: 'ok' | 'warn' | 'error' | 'fixed';
|
|
224
|
-
message: string;
|
|
225
|
-
autoFixable: boolean;
|
|
226
|
-
}
|
|
227
|
-
export type HealthRepairSafety = 'safe' | 'manual' | 'destructive';
|
|
228
|
-
export interface HealthRepairChange {
|
|
229
|
-
kind: 'file' | 'setting' | 'service' | 'runtime' | 'task' | 'other';
|
|
230
|
-
target: string;
|
|
231
|
-
action: 'create' | 'update' | 'delete' | 'install' | 'invoke';
|
|
232
|
-
description: string;
|
|
233
|
-
}
|
|
234
|
-
export interface HealthRepairPlanItem {
|
|
235
|
-
id: string;
|
|
236
|
-
checkId: string;
|
|
237
|
-
title: string;
|
|
238
|
-
reason: string;
|
|
239
|
-
safety: HealthRepairSafety;
|
|
240
|
-
requiresConfirmation: boolean;
|
|
241
|
-
changes: HealthRepairChange[];
|
|
242
|
-
}
|
|
243
|
-
export interface HealthRepairApplyResult {
|
|
244
|
-
id: string;
|
|
245
|
-
checkId: string;
|
|
246
|
-
status: 'applied' | 'skipped' | 'failed';
|
|
247
|
-
message: string;
|
|
248
|
-
changes: HealthRepairChange[];
|
|
249
|
-
}
|
|
250
|
-
export interface HealthRepairHandler {
|
|
251
|
-
plan(rows: HealthCheckResult[]): Promise<HealthRepairPlanItem[]>;
|
|
252
|
-
apply(items: HealthRepairPlanItem[]): Promise<HealthRepairApplyResult[]>;
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Input shape plugins pass to `ctx.registerHealthCheck`. The plugin id is
|
|
256
|
-
* auto-namespaced as `{pluginId}.{id}`. `run()` returns an array so one
|
|
257
|
-
* registered check can contribute multiple result rows (mirrors how the
|
|
258
|
-
* existing `checkPersonas` returns one per agent).
|
|
259
|
-
*/
|
|
260
|
-
export interface PluginHealthCheckInput {
|
|
261
|
-
id: string;
|
|
262
|
-
name: string;
|
|
263
|
-
/**
|
|
264
|
-
* Runs the check, returns any number of result rows. Throws/rejects are
|
|
265
|
-
* caught by the doctor orchestrator and converted to a synthetic error
|
|
266
|
-
* result — a single bad handler never crashes the sweep.
|
|
267
|
-
*/
|
|
268
|
-
run: () => Promise<HealthCheckResult[]>;
|
|
269
|
-
/**
|
|
270
|
-
* Legacy advisory flag for older admin surfaces. New code should derive
|
|
271
|
-
* repairability from `repair`.
|
|
272
|
-
*/
|
|
273
|
-
autoFix?: boolean;
|
|
274
|
-
/**
|
|
275
|
-
* Optional explicit repair contract. Diagnostics call only `run()`; repair
|
|
276
|
-
* flows call `plan()` first, then `apply()` after explicit confirmation.
|
|
277
|
-
*/
|
|
278
|
-
repair?: HealthRepairHandler;
|
|
279
|
-
}
|
|
222
|
+
export type { HealthCheckResult, HealthRepairSafety, HealthRepairChange, HealthRepairPlanItem, HealthRepairApplyResult, HealthRepairHandler, PluginHealthCheckInput, } from '@makinbakin/sdk/types';
|
|
223
|
+
/** Core-internal: a registered plugin health check with its resolved owner. */
|
|
280
224
|
export interface HealthCheckDef extends PluginHealthCheckInput {
|
|
281
225
|
runtime: 'plugin';
|
|
282
226
|
pluginId: string;
|
|
@@ -379,12 +323,7 @@ export interface PluginTaskSource {
|
|
|
379
323
|
entityId?: string;
|
|
380
324
|
purpose?: string;
|
|
381
325
|
}
|
|
382
|
-
export
|
|
383
|
-
timestamp: string;
|
|
384
|
-
author: string;
|
|
385
|
-
message: string;
|
|
386
|
-
data?: Record<string, unknown>;
|
|
387
|
-
}
|
|
326
|
+
export type { TaskLogEntry } from '@makinbakin/sdk/types';
|
|
388
327
|
export interface PluginTaskCreateInput {
|
|
389
328
|
id?: string;
|
|
390
329
|
title: string;
|
|
@@ -431,346 +370,103 @@ export interface PluginTaskService {
|
|
|
431
370
|
}): Promise<PluginTask[]>;
|
|
432
371
|
appendLog(id: string, entry: TaskLogEntry): Promise<void>;
|
|
433
372
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
agent: string;
|
|
450
|
-
taskId: string | null;
|
|
451
|
-
created: string;
|
|
452
|
-
tool?: string;
|
|
453
|
-
description?: string;
|
|
454
|
-
tags?: string[];
|
|
455
|
-
originalFilename?: string;
|
|
456
|
-
};
|
|
457
|
-
variants?: AssetVariantMeta[];
|
|
458
|
-
}
|
|
459
|
-
export interface AssetFileRef {
|
|
460
|
-
kind: 'asset';
|
|
461
|
-
filename: string;
|
|
462
|
-
mimeType?: string;
|
|
463
|
-
}
|
|
464
|
-
export interface AssetsAPI {
|
|
465
|
-
getByFilename(filename: string): Promise<AssetMeta | null>;
|
|
466
|
-
list(filter?: {
|
|
467
|
-
type?: AssetMeta['type'];
|
|
468
|
-
taskId?: string | null;
|
|
469
|
-
}): Promise<AssetMeta[]>;
|
|
470
|
-
exists(filename: string): Promise<boolean>;
|
|
471
|
-
fileRef(filename: string): Promise<AssetFileRef>;
|
|
472
|
-
}
|
|
473
|
-
/** Field type for search content type schemas */
|
|
474
|
-
export interface SearchSchemaField {
|
|
475
|
-
type: 'text' | 'keyword' | 'number' | 'boolean' | 'datetime' | 'array';
|
|
476
|
-
}
|
|
477
|
-
/**
|
|
478
|
-
* One vector index on a search table. A content type can declare multiple
|
|
479
|
-
* indexes to embed the same document into several vector spaces — e.g. a
|
|
480
|
-
* text index using BGE and a visual index using CLIP on the assets table.
|
|
481
|
-
* Each index has its own embedder (resolved via embedderRef), input
|
|
482
|
-
* declaration, and optional chunker config.
|
|
483
|
-
*/
|
|
484
|
-
export interface SearchIndexDefinition {
|
|
485
|
-
/** Index name as stored by the search adapter. Must be stable across restarts. */
|
|
486
|
-
name: string;
|
|
487
|
-
/** Ref into settings.search.settings.embedders — 'default', 'visual', or custom. */
|
|
488
|
-
embedderRef: string;
|
|
489
|
-
/** Handlebars template for this index's text embedding input. */
|
|
490
|
-
embeddingTemplate?: string;
|
|
491
|
-
/**
|
|
492
|
-
* Document field containing a URL to media bytes for visual/multimodal
|
|
493
|
-
* embedding input. The search adapter owns provider-specific helper syntax.
|
|
494
|
-
*/
|
|
495
|
-
mediaUrlField?: string;
|
|
496
|
-
/** Per-index chunker config, overrides any table-level default. */
|
|
497
|
-
chunker?: {
|
|
498
|
-
enabled: boolean;
|
|
499
|
-
targetTokens?: number;
|
|
500
|
-
overlapTokens?: number;
|
|
501
|
-
};
|
|
502
|
-
}
|
|
503
|
-
/** Definition for a searchable content type registered by a plugin */
|
|
504
|
-
export interface SearchContentTypeDefinition {
|
|
505
|
-
/** Table name — auto-prefixed with `bakin_`. E.g., 'tasks' → 'bakin_tasks' */
|
|
506
|
-
table: string;
|
|
507
|
-
/** Schema for the document fields */
|
|
508
|
-
schema: Record<string, SearchSchemaField>;
|
|
509
|
-
/** Fields to include in full-text search */
|
|
510
|
-
searchableFields: string[];
|
|
511
|
-
/**
|
|
512
|
-
* Handlebars template for embedding generation. Used when `indexes` is
|
|
513
|
-
* not provided — the registry synthesizes a single default index named
|
|
514
|
-
* `embeddings` with this template and the default embedder.
|
|
515
|
-
*/
|
|
516
|
-
embeddingTemplate: string;
|
|
517
|
-
/**
|
|
518
|
-
* Optional per-index definitions. When provided, overrides
|
|
519
|
-
* `embeddingTemplate` and creates one embedding index per entry with
|
|
520
|
-
* its own embedder. Used by content types that want multimodal indexing
|
|
521
|
-
* (e.g. assets with both a text index and a visual index).
|
|
522
|
-
*/
|
|
523
|
-
indexes?: SearchIndexDefinition[];
|
|
524
|
-
/** Fields to expose as aggregatable facets */
|
|
525
|
-
facets?: string[];
|
|
526
|
-
/**
|
|
527
|
-
* Document field to use as input for the cross-encoder reranker. When
|
|
528
|
-
* set, queries against this content type attach the configured reranker
|
|
529
|
-
* and score the query-document pair using the value at this field.
|
|
530
|
-
* When unset, queries skip reranking for this content type.
|
|
531
|
-
*/
|
|
532
|
-
rerankField?: string;
|
|
533
|
-
/** TTL duration (Go format: '24h', '7d', '30d') */
|
|
534
|
-
ttl?: string;
|
|
535
|
-
/** TTL field (defaults to 'created_at') */
|
|
536
|
-
ttlField?: string;
|
|
537
|
-
/** Chunking config for long documents — used by the synthesized default index. */
|
|
538
|
-
chunker?: {
|
|
539
|
-
enabled: boolean;
|
|
540
|
-
targetTokens?: number;
|
|
541
|
-
overlapTokens?: number;
|
|
542
|
-
};
|
|
543
|
-
/**
|
|
544
|
-
* Backfill function — called during full/per-table reindex.
|
|
545
|
-
* Must yield ALL documents for this content type from source.
|
|
546
|
-
*/
|
|
547
|
-
reindex: () => AsyncGenerator<{
|
|
548
|
-
key: string;
|
|
549
|
-
doc: Record<string, unknown>;
|
|
373
|
+
/** The asset type taxonomy (mirrors ASSET_TYPES in the assets plugin). */
|
|
374
|
+
export type AssetTypeName = 'text' | 'images' | 'video' | 'audio' | 'plans' | 'research' | 'pdf' | 'data' | 'other';
|
|
375
|
+
/** Per-version generation provenance (matches the manifest's `generation` block). */
|
|
376
|
+
export interface AssetGenerationInfo {
|
|
377
|
+
provider: string;
|
|
378
|
+
model: string;
|
|
379
|
+
surface: string;
|
|
380
|
+
/** Honored only on the shim path; native generations omit it (#379). */
|
|
381
|
+
quality?: string;
|
|
382
|
+
routeSource: string;
|
|
383
|
+
routeReason?: string;
|
|
384
|
+
/** Reference/context images that conditioned this generation (#418). */
|
|
385
|
+
references?: Array<{
|
|
386
|
+
assetId: string;
|
|
387
|
+
version: number;
|
|
550
388
|
}>;
|
|
551
|
-
/**
|
|
552
|
-
* Existence check — called during orphan cleanup.
|
|
553
|
-
* Returns true if the source document for this key still exists.
|
|
554
|
-
*/
|
|
555
|
-
verifyExists: (key: string) => Promise<boolean>;
|
|
556
|
-
}
|
|
557
|
-
/** Parameters for a search query */
|
|
558
|
-
export interface SearchQueryParams {
|
|
559
|
-
/** Search query string */
|
|
560
|
-
q: string;
|
|
561
|
-
/** Structured keyword filters */
|
|
562
|
-
filters?: Record<string, string | boolean | number>;
|
|
563
|
-
/** Facets to include in aggregations */
|
|
564
|
-
facets?: string[];
|
|
565
|
-
/** Max results */
|
|
566
|
-
limit?: number;
|
|
567
|
-
/** Result offset for pagination */
|
|
568
|
-
offset?: number;
|
|
569
|
-
/**
|
|
570
|
-
* Whether to run the cross-encoder reranker on results. Defaults to
|
|
571
|
-
* true when the reranker is enabled in settings. Set false for latency-
|
|
572
|
-
* sensitive paths (facet-only queries, ID lookups, bulk scans) where
|
|
573
|
-
* the extra ~100-500ms isn't worth it.
|
|
574
|
-
*/
|
|
575
|
-
rerank?: boolean;
|
|
576
|
-
/**
|
|
577
|
-
* Raw adapter-specific aggregations passed through unchanged to the query layer.
|
|
578
|
-
* Use for date histograms, range buckets, stats aggregations, or any
|
|
579
|
-
* other shape beyond the term-facet convenience in `facets`. Merged
|
|
580
|
-
* with facet-derived aggregations (these win on key collision).
|
|
581
|
-
* See the active search adapter docs for the aggregation schema.
|
|
582
|
-
*/
|
|
583
|
-
aggregations?: Record<string, unknown>;
|
|
584
|
-
/**
|
|
585
|
-
* Search strategy override. Defaults to the site-wide search strategy.
|
|
586
|
-
* Pass 'full_text_only' for filter-driven
|
|
587
|
-
* counts or ID lookups — semantic search rejects `limit: 0` queries
|
|
588
|
-
* with the "semantic search requires topk limit to be positive" error.
|
|
589
|
-
*/
|
|
590
|
-
strategy?: 'rrf' | 'semantic_only' | 'full_text_only';
|
|
591
389
|
}
|
|
592
|
-
/**
|
|
593
|
-
export interface
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
aggregations?: Record<string, Array<{
|
|
609
|
-
value: string;
|
|
610
|
-
count: number;
|
|
611
|
-
}>>;
|
|
612
|
-
/**
|
|
613
|
-
* Raw aggregation response from the search adapter, unmodified. Populated whenever
|
|
614
|
-
* the underlying query returned aggregations — use this for non-term
|
|
615
|
-
* shapes like date_histogram, range, stats, etc.
|
|
616
|
-
*/
|
|
617
|
-
rawAggregations?: Record<string, unknown>;
|
|
618
|
-
meta: {
|
|
619
|
-
query: string;
|
|
620
|
-
total: number;
|
|
621
|
-
took_ms: number;
|
|
622
|
-
source: 'search' | 'fallback';
|
|
390
|
+
/** Create a new versioned asset (v1) from a source file. */
|
|
391
|
+
export interface AssetCreateInput {
|
|
392
|
+
sourceFilePath: string;
|
|
393
|
+
type: AssetTypeName;
|
|
394
|
+
agent: string;
|
|
395
|
+
taskId: string | null;
|
|
396
|
+
slug?: string;
|
|
397
|
+
op?: 'generate' | 'upload' | 'import';
|
|
398
|
+
tool?: string | null;
|
|
399
|
+
prompt?: string | null;
|
|
400
|
+
promptHash?: string | null;
|
|
401
|
+
description?: string;
|
|
402
|
+
tags?: string[];
|
|
403
|
+
source?: {
|
|
404
|
+
kind: 'generated' | 'upload' | 'import' | 'clipboard' | 'workspace-file';
|
|
405
|
+
path: string | null;
|
|
623
406
|
};
|
|
624
|
-
|
|
625
|
-
export interface SearchHealthIndex {
|
|
626
|
-
name: string;
|
|
627
|
-
type: string;
|
|
628
|
-
totalIndexed: number;
|
|
629
|
-
walBacklog: number;
|
|
630
|
-
error?: string;
|
|
631
|
-
rebuilding: boolean;
|
|
632
|
-
backfillProgress?: number;
|
|
633
|
-
}
|
|
634
|
-
export interface SearchHealthTable {
|
|
635
|
-
table: string;
|
|
636
|
-
pluginId: string;
|
|
637
|
-
stats: Record<string, unknown> | null;
|
|
638
|
-
indexHealth?: SearchHealthIndex[];
|
|
639
|
-
healthy: boolean;
|
|
640
|
-
}
|
|
641
|
-
export interface SearchHealthSnapshot {
|
|
642
|
-
enabled: boolean;
|
|
643
|
-
tables: SearchHealthTable[];
|
|
644
|
-
}
|
|
645
|
-
/** Atomic transform operation (update fields without re-embedding) */
|
|
646
|
-
export interface SearchTransformOp {
|
|
647
|
-
op: '$set' | '$inc' | '$push';
|
|
648
|
-
field?: string;
|
|
649
|
-
value: unknown;
|
|
407
|
+
generation?: AssetGenerationInfo | null;
|
|
650
408
|
}
|
|
651
409
|
/**
|
|
652
|
-
*
|
|
653
|
-
*
|
|
654
|
-
* draws from several distinct file shapes (e.g. workflows store
|
|
655
|
-
* definitions as `.yaml` and instances as `.json`, both indexed into the
|
|
656
|
-
* same `bakin_workflows` table with different key prefixes).
|
|
410
|
+
* Append a new version to an existing asset. Note: no `tags` — tags are an
|
|
411
|
+
* asset-level organizational namespace that versioning never touches.
|
|
657
412
|
*/
|
|
658
|
-
export interface
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
413
|
+
export interface AssetVersionCreateInput {
|
|
414
|
+
sourceFilePath: string;
|
|
415
|
+
op?: 'edit' | 'generate' | 'upload' | 'import';
|
|
416
|
+
tool?: string | null;
|
|
417
|
+
prompt?: string | null;
|
|
418
|
+
promptHash?: string | null;
|
|
419
|
+
description?: string;
|
|
420
|
+
generation?: AssetGenerationInfo | null;
|
|
421
|
+
}
|
|
422
|
+
/** Render a derived export of a version (keyed/idempotent by surface). */
|
|
423
|
+
export interface AssetExportRequest {
|
|
424
|
+
fromVersion?: number;
|
|
425
|
+
surface: string;
|
|
426
|
+
format: 'jpg' | 'png' | 'webp';
|
|
427
|
+
width: number;
|
|
428
|
+
height: number;
|
|
429
|
+
quality?: number;
|
|
430
|
+
}
|
|
431
|
+
export interface VersionedAssetRef {
|
|
432
|
+
assetId: string;
|
|
433
|
+
version: number;
|
|
674
434
|
}
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
* 1. Standard `registerContentType` (table creation, schema, reindex).
|
|
680
|
-
* 2. A watcher sync hook that re-indexes on add/change.
|
|
681
|
-
* 3. A watcher unlink hook that removes on delete.
|
|
682
|
-
* 4. A startup reconcile that detects mtime drift and corrects it.
|
|
683
|
-
*
|
|
684
|
-
* Plugins should reach for this helper first. Use raw `registerContentType`
|
|
685
|
-
* only when the source of truth is NOT the filesystem (e.g. SQLite,
|
|
686
|
-
* external API, runtime adapter).
|
|
687
|
-
*/
|
|
688
|
-
export interface FileBackedContentTypeDefinition extends SearchContentTypeDefinition {
|
|
689
|
-
/**
|
|
690
|
-
* One or more file-pattern mappers. Patterns should not overlap;
|
|
691
|
-
* first match wins. A file that matches no pattern is ignored.
|
|
692
|
-
*/
|
|
693
|
-
filePatterns: FilePatternMapper[];
|
|
694
|
-
/**
|
|
695
|
-
* Optional exclude patterns applied BEFORE any mapper matches. Useful
|
|
696
|
-
* for skipping subdirectories like `assets/**\/.trash/**` or sidecar
|
|
697
|
-
* files like `**\/*.meta.json`.
|
|
698
|
-
*/
|
|
699
|
-
excludePatterns?: string[];
|
|
700
|
-
/**
|
|
701
|
-
* Escape hatch for sync events. When provided, the helper invokes
|
|
702
|
-
* this instead of the default `fileToDoc → ctx.search.index` flow for
|
|
703
|
-
* any file matching this content type's patterns. The plugin takes
|
|
704
|
-
* full responsibility for indexing.
|
|
705
|
-
*
|
|
706
|
-
* Use when pairing logic (e.g. assets' binary↔sidecar coupling) can't
|
|
707
|
-
* be expressed as a single mapper. The matched `FilePatternMapper` is
|
|
708
|
-
* still consulted for `fileToId` if the plugin needs the canonical key.
|
|
709
|
-
*/
|
|
710
|
-
onSync?: (relPath: string, content: string) => Promise<void>;
|
|
711
|
-
/**
|
|
712
|
-
* Escape hatch for unlink events. Same story as `onSync`. If unset,
|
|
713
|
-
* the helper calls the matched mapper's `fileToId(relPath)` and then
|
|
714
|
-
* `ctx.search.remove(id)`.
|
|
715
|
-
*/
|
|
716
|
-
onUnlink?: (relPath: string) => Promise<void>;
|
|
717
|
-
/**
|
|
718
|
-
* Whether to run the startup reconcile loop on plugin activation.
|
|
719
|
-
* Defaults to true. Set false only when the plugin wants to drive its
|
|
720
|
-
* own initial population (rare).
|
|
721
|
-
*/
|
|
722
|
-
buildOnStartup?: boolean;
|
|
435
|
+
export interface AssetVersionFileRef {
|
|
436
|
+
absPath: string;
|
|
437
|
+
mimeType: string;
|
|
438
|
+
version: number;
|
|
723
439
|
}
|
|
724
|
-
/**
|
|
725
|
-
export interface
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
/**
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
/** Search this plugin's content type. */
|
|
751
|
-
query(params: SearchQueryParams): Promise<SearchResponse>;
|
|
752
|
-
/** Global search adapter and registered-table health snapshot. */
|
|
753
|
-
health?(): Promise<SearchHealthSnapshot>;
|
|
754
|
-
/**
|
|
755
|
-
* Plugin-scoped maintenance operations for indexers that own non-file-backed
|
|
756
|
-
* tables. This is intentionally narrower than the raw adapter: callers can
|
|
757
|
-
* only touch their own registered content type.
|
|
758
|
-
*/
|
|
759
|
-
maintenance?: SearchMaintenanceAPI;
|
|
760
|
-
}
|
|
761
|
-
export interface SearchMaintenanceAPI {
|
|
762
|
-
/** Whether the backing search service is reachable. */
|
|
763
|
-
available(): Promise<boolean>;
|
|
764
|
-
/** Iterate every document in this plugin's registered content type. */
|
|
765
|
-
scan(): AsyncIterable<{
|
|
766
|
-
key: string;
|
|
767
|
-
document: Record<string, unknown>;
|
|
440
|
+
/** Current-version summary of an asset, addressed by id. */
|
|
441
|
+
export interface AssetSummary {
|
|
442
|
+
assetId: string;
|
|
443
|
+
type: AssetTypeName;
|
|
444
|
+
agent: string;
|
|
445
|
+
taskId: string | null;
|
|
446
|
+
created: string;
|
|
447
|
+
updated: string;
|
|
448
|
+
currentVersion: number;
|
|
449
|
+
versionCount: number;
|
|
450
|
+
description: string;
|
|
451
|
+
tags: string[];
|
|
452
|
+
mimeType: string;
|
|
453
|
+
width: number | null;
|
|
454
|
+
height: number | null;
|
|
455
|
+
size: number;
|
|
456
|
+
hasThumb: boolean;
|
|
457
|
+
}
|
|
458
|
+
export interface AssetsAPI {
|
|
459
|
+
createAsset(input: AssetCreateInput): Promise<VersionedAssetRef>;
|
|
460
|
+
/** Read an asset's current-version summary by id (metadata: type/description/tags/etc.), or null. */
|
|
461
|
+
getAsset(assetId: string): Promise<AssetSummary | null>;
|
|
462
|
+
addVersion(assetId: string, input: AssetVersionCreateInput): Promise<VersionedAssetRef>;
|
|
463
|
+
addExport(assetId: string, input: AssetExportRequest): Promise<{
|
|
464
|
+
name: string;
|
|
465
|
+
file: string;
|
|
768
466
|
}>;
|
|
769
|
-
|
|
770
|
-
batchRemove(keys: string[]): Promise<number>;
|
|
771
|
-
/** Drop and recreate this plugin's registered content type table. */
|
|
772
|
-
resetContentType(): Promise<void>;
|
|
467
|
+
resolveVersionFile(assetId: string, version?: number): Promise<AssetVersionFileRef | null>;
|
|
773
468
|
}
|
|
469
|
+
export type { SearchSchemaField, SearchIndexDefinition, SearchContentTypeDefinition, SearchQueryParams, SearchResult, SearchResponse, SearchHealthIndex, SearchHealthTable, SearchHealthSnapshot, SearchTransformOp, FilePatternMapper, FileBackedContentTypeDefinition, SearchAPI, SearchMaintenanceAPI, } from '@makinbakin/sdk/types';
|
|
774
470
|
interface BaseSettingsField {
|
|
775
471
|
key: string;
|
|
776
472
|
label: string;
|
|
@@ -865,46 +561,4 @@ export interface BakinPlugin {
|
|
|
865
561
|
*/
|
|
866
562
|
routes?: ReadonlyArray<DeclarativeAPIRoute<PluginContextLite, any, any, any>>;
|
|
867
563
|
}
|
|
868
|
-
export
|
|
869
|
-
algorithm: 'ed25519';
|
|
870
|
-
signer: string;
|
|
871
|
-
publicKey: string;
|
|
872
|
-
signature: string;
|
|
873
|
-
}
|
|
874
|
-
export interface SecretDeclaration {
|
|
875
|
-
/** Canonical environment variable name, for example `ANTHROPIC_API_KEY`. */
|
|
876
|
-
name: string;
|
|
877
|
-
/** Human-readable setup note. Never include a secret value here. */
|
|
878
|
-
description: string;
|
|
879
|
-
/** Missing required secrets should be reported by setup/health checks. Defaults to true. */
|
|
880
|
-
required: boolean;
|
|
881
|
-
}
|
|
882
|
-
export interface PluginManifest {
|
|
883
|
-
id: string;
|
|
884
|
-
name: string;
|
|
885
|
-
version: string;
|
|
886
|
-
bakin: string;
|
|
887
|
-
description: string;
|
|
888
|
-
entry: {
|
|
889
|
-
server: string;
|
|
890
|
-
client?: string;
|
|
891
|
-
};
|
|
892
|
-
contentFiles?: string[];
|
|
893
|
-
secrets?: SecretDeclaration[];
|
|
894
|
-
tests?: string;
|
|
895
|
-
dependencies?: string[];
|
|
896
|
-
permissions?: string[];
|
|
897
|
-
signature?: PluginManifestSignature;
|
|
898
|
-
}
|
|
899
|
-
export interface PluginEntry {
|
|
900
|
-
path: string;
|
|
901
|
-
enabled?: boolean;
|
|
902
|
-
}
|
|
903
|
-
export interface BakinConfig {
|
|
904
|
-
plugins: PluginEntry[];
|
|
905
|
-
theme?: Record<string, string>;
|
|
906
|
-
storage?: {
|
|
907
|
-
contentDir?: string;
|
|
908
|
-
};
|
|
909
|
-
}
|
|
910
|
-
export {};
|
|
564
|
+
export type { PluginManifestSignature, SecretDeclaration, PluginManifest, PluginEntry, BakinConfig, } from '@makinbakin/sdk/types';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AvailableModel } from '@makinbakin/sdk/types';
|
|
2
|
+
/** The available-models catalog (empty array until loaded / on failure). */
|
|
3
|
+
export declare function useAvailableModels(): AvailableModel[];
|
|
4
|
+
/** Test-only: reset the module-level cache so tests run with a clean slate. */
|
|
5
|
+
export declare function __resetAvailableModelsCache(): void;
|