@makinbakin/sdk 0.0.1-rc.18 → 0.0.1-rc.19

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.
@@ -0,0 +1,33 @@
1
+ import type { ReactNode } from 'react';
2
+ export interface ConfirmDialogProps {
3
+ /** Whether the dialog is shown. Controlled by the caller (e.g. `open={!!target}`). */
4
+ open: boolean;
5
+ title: ReactNode;
6
+ /** Body copy. Rendered inside DialogDescription (a `<p>`) — pass inline content; use `<span className="block">` for secondary lines. */
7
+ description?: ReactNode;
8
+ /** Confirm button label (default "Delete"). */
9
+ confirmLabel?: string;
10
+ /** Confirm label while busy (default = confirmLabel); a spinner is prepended. */
11
+ busyLabel?: string;
12
+ /** Cancel button label (default "Cancel"). */
13
+ cancelLabel?: string;
14
+ /** Cancel button variant (default "outline"). */
15
+ cancelVariant?: 'outline' | 'ghost';
16
+ /** Disables both buttons and shows a spinner on confirm while the action is in flight. */
17
+ busy?: boolean;
18
+ /** Inline error shown above the footer. */
19
+ error?: string | null;
20
+ /** Test id forwarded to the confirm button. */
21
+ confirmTestId?: string;
22
+ /** DialogContent className override (default width is `sm:max-w-sm`). */
23
+ className?: string;
24
+ onConfirm: () => void;
25
+ onCancel: () => void;
26
+ }
27
+ /**
28
+ * A controlled confirmation dialog for destructive actions — the consolidation of
29
+ * six near-identical hand-rolled delete dialogs. The caller owns visibility (`open`)
30
+ * and the busy/error state of the in-flight action; the dialog never closes itself
31
+ * while `busy` so an action can't be cancelled mid-flight.
32
+ */
33
+ export declare function ConfirmDialog({ open, title, description, confirmLabel, busyLabel, cancelLabel, cancelVariant, busy, error, confirmTestId, className, onConfirm, onCancel, }: ConfirmDialogProps): import("react/jsx-runtime").JSX.Element;
@@ -1,10 +1,19 @@
1
- import type { LucideIcon } from 'lucide-react';
1
+ import type { ComponentType, ReactNode } from 'react';
2
2
  interface EmptyStateProps {
3
- icon?: LucideIcon;
3
+ icon?: ComponentType<{
4
+ className?: string;
5
+ }>;
4
6
  title: string;
5
- description?: string;
6
- action?: React.ReactNode;
7
+ description?: ReactNode;
8
+ action?: ReactNode;
7
9
  className?: string;
10
+ /**
11
+ * Visual size.
12
+ * - `default` — compact rounded chip + small title (the original SDK look).
13
+ * - `panel` — larger rounded-2xl chip + semibold title for full-tab empty
14
+ * surfaces (folded in from the team plugin's former local variant).
15
+ */
16
+ variant?: 'default' | 'panel';
8
17
  }
9
- export declare function EmptyState({ icon: Icon, title, description, action, className }: EmptyStateProps): import("react/jsx-runtime").JSX.Element;
18
+ export declare function EmptyState({ icon: Icon, title, description, action, className, variant }: EmptyStateProps): import("react/jsx-runtime").JSX.Element;
10
19
  export {};
@@ -5,19 +5,12 @@ interface AuditEntry {
5
5
  agent: string;
6
6
  data: Record<string, unknown>;
7
7
  }
8
- interface ReindexProgressEntry {
9
- indexed: number;
10
- done: boolean;
11
- }
12
8
  interface ContentStore extends ContentState {
13
9
  loading: boolean;
14
10
  auditEntries: AuditEntry[];
15
11
  activityEvents: ActivityEvent[];
16
12
  sseConnected: boolean;
17
- taskboardVersion: number;
18
- doctorVersion: number;
19
13
  debug: boolean;
20
- reindexProgress: Record<string, ReindexProgressEntry>;
21
14
  setFiles: (files: Record<string, string>) => void;
22
15
  updateFile: (key: string, content: string) => void;
23
16
  setHeartbeats: (heartbeats: Record<string, Heartbeat>) => void;
@@ -26,12 +19,8 @@ interface ContentStore extends ContentState {
26
19
  appendActivityEvent: (event: ActivityEvent) => void;
27
20
  setActivityEvents: (events: ActivityEvent[]) => void;
28
21
  setSseConnected: (connected: boolean) => void;
29
- bumpTaskboard: () => void;
30
- bumpDoctor: () => void;
31
22
  setDebug: (debug: boolean) => void;
32
23
  toggleDebug: () => void;
33
- setReindexProgress: (table: string, indexed: number, done: boolean) => void;
34
- clearReindexProgress: () => void;
35
24
  initialize: () => Promise<void>;
36
25
  }
37
26
  export declare const useContentStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ContentStore>>;
@@ -0,0 +1,22 @@
1
+ import { type ResizeHandleProps } from './use-resizable-pane';
2
+ interface Options {
3
+ defaultWidth: number;
4
+ minWidth: number;
5
+ maxWidth: number;
6
+ /** When set, width is persisted in localStorage under `bakin-hresize:${storageKey}`. */
7
+ storageKey?: string;
8
+ }
9
+ interface Return {
10
+ width: number;
11
+ setWidth: (w: number) => void;
12
+ handleProps: ResizeHandleProps;
13
+ }
14
+ /**
15
+ * Resize a right-anchored panel by dragging its left edge. The handle lives at
16
+ * the left of the element; dragging left grows the panel, dragging right
17
+ * shrinks it. Keyboard: ArrowLeft/ArrowRight (Shift for a larger step). The
18
+ * companion to {@link useVerticalResize} for side-by-side split panes; both are
19
+ * thin wrappers over {@link useResizablePane}.
20
+ */
21
+ export declare function useHorizontalResize({ defaultWidth, minWidth, maxWidth, storageKey }: Options): Return;
22
+ export {};
@@ -0,0 +1,21 @@
1
+ export interface UseJsonFetchResult<T> {
2
+ /** Parsed JSON body, or null before the first successful load. */
3
+ data: T | null;
4
+ /** True while a request is in flight. */
5
+ loading: boolean;
6
+ /** Error message on a non-2xx response or a network/parse failure; null otherwise. */
7
+ error: string | null;
8
+ /** Re-run the fetch (e.g. after a mutation). */
9
+ refresh: () => void;
10
+ }
11
+ /**
12
+ * Cancellable JSON GET with the standard `{ data, loading, error, refresh }` lifecycle —
13
+ * the consolidation of the `let cancelled = false` fetch-in-useEffect boilerplate scattered
14
+ * across plugin components. Aborts the in-flight request on unmount or when `url` changes,
15
+ * so it never sets state after unmount.
16
+ *
17
+ * Pass `url = null` to skip fetching (e.g. until an id is known); `data` resets to null and
18
+ * `loading` is false while skipped. `opts` is read per-request but does NOT re-trigger on its
19
+ * own identity — change `url` or call `refresh()` to re-fetch.
20
+ */
21
+ export declare function useJsonFetch<T>(url: string | null, opts?: RequestInit): UseJsonFetchResult<T>;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Subscribe to server-pushed plugin events over the shell's SINGLE EventSource.
3
+ *
4
+ * The shell owns one `/api/events` connection (`use-sse.ts`) with reconnect +
5
+ * backoff. Plugins used to each open their own `new EventSource('/api/events')`
6
+ * — N connections, no reconnect. Instead the shell fans every
7
+ * `{ type: 'plugin-event', event, … }` payload into this process-global emitter,
8
+ * and components subscribe by event name here. The handler receives the full
9
+ * payload so it can filter on `assetId`/`taskId`/etc.
10
+ */
11
+ export type PluginEventPayload = Record<string, unknown> & {
12
+ event?: string;
13
+ };
14
+ type Handler = (payload: PluginEventPayload) => void;
15
+ /** Called by the shell SSE handler for every `plugin-event` payload. */
16
+ export declare function emitPluginEvent(payload: PluginEventPayload): void;
17
+ /** Run `handler` whenever the server pushes a plugin event named `event`. */
18
+ export declare function usePluginEvent(event: string, handler: Handler): void;
19
+ export {};
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Shared core for the two split-pane resize hooks. A pane is anchored to the
3
+ * trailing edge (bottom for 'y', right for 'x') and resized by dragging the
4
+ * divider on its leading edge — dragging toward that edge (up / left) grows it.
5
+ * {@link useVerticalResize} and {@link useHorizontalResize} are thin wrappers;
6
+ * keep all drag / persistence / a11y logic here so it lives in exactly one place.
7
+ */
8
+ export type ResizeAxis = 'x' | 'y';
9
+ interface CoreOptions {
10
+ axis: ResizeAxis;
11
+ defaultSize: number;
12
+ minSize: number;
13
+ maxSize: number;
14
+ /** localStorage key suffix; persisted under `${storagePrefix}${storageKey}`. */
15
+ storageKey?: string;
16
+ storagePrefix: string;
17
+ }
18
+ export interface ResizeHandleProps {
19
+ role: 'separator';
20
+ tabIndex: 0;
21
+ 'aria-orientation': 'horizontal' | 'vertical';
22
+ 'aria-valuenow': number;
23
+ 'aria-valuemin': number;
24
+ 'aria-valuemax': number;
25
+ onMouseDown: (e: React.MouseEvent) => void;
26
+ onTouchStart: (e: React.TouchEvent) => void;
27
+ onKeyDown: (e: React.KeyboardEvent) => void;
28
+ }
29
+ export interface ResizablePane {
30
+ size: number;
31
+ setSize: (n: number) => void;
32
+ handleProps: ResizeHandleProps;
33
+ }
34
+ export declare function useResizablePane({ axis, defaultSize, minSize, maxSize, storageKey, storagePrefix }: CoreOptions): ResizablePane;
35
+ export {};
@@ -1,3 +1,11 @@
1
+ /** Task-level terminal outcome (mirrors plugins/tasks TaskOutcome). */
2
+ export interface TaskOutcome {
3
+ state: 'done' | 'blocked' | 'archived' | 'in_progress';
4
+ /** Set when state === 'done' and a completion row exists. */
5
+ completedAt?: string;
6
+ /** Agent that recorded the completion, when known. */
7
+ agent?: string;
8
+ }
1
9
  /** One dispatch attempt for a task (mirrors plugins/tasks TaskRunEntry). */
2
10
  export interface TaskRunEntry {
3
11
  runId: string;
@@ -10,8 +18,9 @@ export interface TaskRunEntry {
10
18
  settleReason?: string;
11
19
  durationMs?: number;
12
20
  }
13
- /** Fetch a task's dispatch run history (newest-first) from the execution ledger. */
21
+ /** Fetch a task's dispatch run history (newest-first) + task outcome from the execution ledger. */
14
22
  export declare function useTaskRunHistory(taskId: string | null, limit?: number): {
15
23
  runs: TaskRunEntry[];
24
+ outcome: TaskOutcome | undefined;
16
25
  loading: boolean;
17
26
  };
@@ -1,3 +1,4 @@
1
+ import { type ResizeHandleProps } from './use-resizable-pane';
1
2
  interface Options {
2
3
  defaultHeight: number;
3
4
  minHeight: number;
@@ -5,18 +6,16 @@ interface Options {
5
6
  /** When set, height is persisted in localStorage under `bakin-vresize:${storageKey}`. */
6
7
  storageKey?: string;
7
8
  }
8
- interface HandleProps {
9
- onMouseDown: (e: React.MouseEvent) => void;
10
- onTouchStart: (e: React.TouchEvent) => void;
11
- }
12
9
  interface Return {
13
10
  height: number;
14
11
  setHeight: (h: number) => void;
15
- handleProps: HandleProps;
12
+ handleProps: ResizeHandleProps;
16
13
  }
17
14
  /**
18
- * Resize a panel by dragging its top edge. The handle lives at the top of the
19
- * element; dragging upward grows the panel, dragging downward shrinks it.
15
+ * Resize a bottom-anchored panel by dragging its top edge. The handle lives at
16
+ * the top of the element; dragging upward grows the panel, dragging downward
17
+ * shrinks it. Keyboard: ArrowUp/ArrowDown (Shift for a larger step). Thin
18
+ * wrapper over {@link useResizablePane}.
20
19
  */
21
20
  export declare function useVerticalResize({ defaultHeight, minHeight, maxHeight, storageKey }: Options): Return;
22
21
  export {};
@@ -1,72 +1,8 @@
1
- export interface TaskLogEntry {
2
- timestamp: string;
3
- author: string;
4
- message: string;
5
- data?: Record<string, unknown>;
6
- }
7
- export interface Task {
8
- id: string;
9
- title: string;
10
- agent?: string;
11
- checked: boolean;
12
- date?: string;
13
- blockedReason?: string;
14
- description?: string;
15
- log?: TaskLogEntry[];
16
- }
17
- export interface TaskColumns {
18
- inProgress: Task[];
19
- todo: Task[];
20
- done: Task[];
21
- blocked: Task[];
22
- }
23
- export interface TaskBoard {
24
- columns: TaskColumns;
25
- timestamp?: string;
26
- }
27
- export type ColumnId = keyof TaskColumns;
28
- export interface CalendarEvent {
29
- time?: string;
30
- text: string;
31
- }
32
- export interface CalendarDay {
33
- date: string;
34
- label?: string;
35
- events: CalendarEvent[];
36
- }
37
- export interface RecurringEvent {
38
- schedule: string;
39
- text: string;
40
- }
41
- export interface MemoryEntry {
42
- type: 'decision' | 'learned' | 'note';
43
- text: string;
44
- }
45
- export interface MemoryDay {
46
- date: string;
47
- entries: MemoryEntry[];
48
- }
49
1
  export interface Heartbeat {
50
2
  status: 'working' | 'idle' | 'down';
51
3
  currentTask?: string;
52
4
  timestamp: string;
53
5
  }
54
- export interface ProjectMeta {
55
- filename: string;
56
- title: string;
57
- status?: string;
58
- content: string;
59
- }
60
- export interface OfficeData {
61
- asciiMap: string;
62
- statusTable: {
63
- agent: string;
64
- status: string;
65
- task: string;
66
- heartbeat: string;
67
- }[];
68
- history: string[];
69
- }
70
6
  export interface ActivityEvent {
71
7
  id: string;
72
8
  ts: string;
@@ -58,11 +58,34 @@ export interface MessageArgs extends RuntimeMessageToolPolicy {
58
58
  * same agentId + threadId pair to the same provider/runtime session.
59
59
  */
60
60
  threadId?: string;
61
+ /**
62
+ * Per-turn model override (`provider/model` id). Omit to use the agent's
63
+ * configured model. The caller (Bakin's routing policy) resolves it.
64
+ */
65
+ model?: string;
66
+ /**
67
+ * Per-turn thinking level. Omit to use the runtime/agent default.
68
+ */
69
+ thinking?: string;
61
70
  metadata?: RuntimeMetadata;
62
71
  }
72
+ /** Token usage for one agent turn, when the runtime reports it. */
73
+ export interface MessageUsage {
74
+ input?: number;
75
+ output?: number;
76
+ total?: number;
77
+ /** Cached-input tokens read (priced far below fresh input when known). */
78
+ cacheRead?: number;
79
+ /** Cached-input tokens written (cache creation). */
80
+ cacheWrite?: number;
81
+ /** Resolved model the runtime ran, when known. */
82
+ model?: string;
83
+ }
63
84
  export interface MessageResult {
64
85
  id: string;
65
86
  content?: string;
87
+ /** Per-turn token usage, omitted when the runtime reported none. */
88
+ usage?: MessageUsage;
66
89
  metadata?: RuntimeMetadata;
67
90
  }
68
91
  export interface RuntimeToolActivity {
@@ -229,6 +252,19 @@ export interface RuntimeSession {
229
252
  updatedAt?: string;
230
253
  metadata?: RuntimeMetadata;
231
254
  }
255
+ export interface RuntimeSessionStoreStats {
256
+ agentId: string;
257
+ /** Live entries in the runtime's session store for this agent. */
258
+ storeEntries: number;
259
+ /**
260
+ * Top-level files in the agent's sessions directory (session artifacts,
261
+ * including the store itself) — cache subtrees are excluded so the
262
+ * orphaned-artifact ratio stays meaningful.
263
+ */
264
+ fileCount: number;
265
+ /** Total bytes of the agent's sessions directory, subtrees included. */
266
+ diskBytes: number;
267
+ }
232
268
  export interface RuntimeMemoryTier {
233
269
  id: string;
234
270
  label: string;
@@ -338,6 +374,13 @@ export interface RuntimeImageGenerateInput {
338
374
  resolution?: string;
339
375
  outputFormat?: RuntimeImageOutputFormat;
340
376
  background?: RuntimeImageBackground;
377
+ /**
378
+ * Reference/context image file paths conditioning the generation. The caller
379
+ * (Bakin) resolves managed asset ids to concrete paths before the adapter
380
+ * sees them. Native generation has no file input, so a generate carrying
381
+ * references is routed through the edit-style invocation (#418).
382
+ */
383
+ referenceImages?: string[];
341
384
  timeoutMs?: number;
342
385
  metadata?: RuntimeMetadata;
343
386
  }
@@ -456,6 +499,12 @@ export interface AgentRuntimeAdapter {
456
499
  sessions: {
457
500
  list(agentId?: string): Promise<RuntimeSession[]>;
458
501
  get(sessionId: string): Promise<RuntimeSession | null>;
502
+ /**
503
+ * Per-agent session-store disk stats. Optional: runtimes without a
504
+ * file-backed session store omit it, and callers must treat absence
505
+ * as "stats unavailable" — skip, never error.
506
+ */
507
+ storeStats?(): Promise<RuntimeSessionStoreStats[]>;
459
508
  };
460
509
  memory: {
461
510
  listTiers(): Promise<RuntimeMemoryTier[]>;
@@ -486,6 +535,16 @@ export interface AgentRuntimeAdapter {
486
535
  }): Promise<RuntimeAvailableModel[]>;
487
536
  };
488
537
  images?: RuntimeImagesAccess;
538
+ /**
539
+ * Access to the runtime's private media store (e.g. channel attachments).
540
+ * `resolveUri` maps a runtime-private URI (OpenClaw's `media://…`) to an
541
+ * absolute local file path; null for unknown schemes or missing files —
542
+ * never throws for not-found. Optional: runtimes without a media store
543
+ * omit it, and callers must treat absence as "cannot resolve".
544
+ */
545
+ media?: {
546
+ resolveUri(uri: string): Promise<string | null>;
547
+ };
489
548
  cron: {
490
549
  list(): Promise<CronJob[]>;
491
550
  get(id: string): Promise<CronJob | null>;
@@ -4,4 +4,4 @@ export { hasChannelCapability } from './capabilities';
4
4
  export { RuntimeError, RuntimeTurnError } from './errors';
5
5
  export type { RuntimeErrorKind, RuntimeErrorOptions, RuntimeProviderInfo, RuntimeTurnDiagnosis, RuntimeTurnFailureReason, } from './errors';
6
6
  export { getRuntimeMainAgent, getRuntimeMainAgentId, getRuntimeMainAgentName, selectRuntimeMainAgent, } from './helpers';
7
- export type { AgentRuntimeAdapter, ApprovalDelivery, ApprovalOption, ApprovalPatch, ApprovalRenderRef, ApprovalRenderResult, ApprovalResolveEvent, ApprovalResponse, CancelApprovalArgs, ChannelInfo, ChannelMessageArgs, ChatChunk, ContentDeliveryArgs, CreateApprovalArgs, CreateCronJobInput, CreateRuntimeAgentInput, CronJob, CronRun, DeliveryResult, DurableApprovalRecord, EditApprovalArgs, MessageArgs, MessageResult, NotificationArgs, ResolveApprovalArgs, RuntimeAgent, RuntimeAllowlistPatch, RuntimeToolActivity, RuntimeAvailableModel, RuntimeConfigAccess, RuntimeImageBackground, RuntimeImageEditInput, RuntimeImageFile, RuntimeImageGenerateInput, RuntimeImageGenerationResult, RuntimeImageOutputFormat, RuntimeImageProvider, RuntimeImageProviderCapabilities, RuntimeImagesAccess, RuntimeMemoryEntry, RuntimeMemoryEntryStat, RuntimeMemoryPathMatch, RuntimeMemoryReadRange, RuntimeMemorySearchResult, RuntimeMemoryTier, RuntimeMessageToolPolicy, RuntimeMessageToolsMode, RuntimeMetadata, RuntimePermissionPatch, RawCronSnapshot, RuntimeSession, RuntimeSkill, ToolResult, UpdateCronJobInput, UpdateRuntimeAgentInput, WorkspaceFile, } from './concepts';
7
+ export type { AgentRuntimeAdapter, ApprovalDelivery, ApprovalOption, ApprovalPatch, ApprovalRenderRef, ApprovalRenderResult, ApprovalResolveEvent, ApprovalResponse, CancelApprovalArgs, ChannelInfo, ChannelMessageArgs, ChatChunk, ContentDeliveryArgs, CreateApprovalArgs, CreateCronJobInput, CreateRuntimeAgentInput, CronJob, CronRun, DeliveryResult, DurableApprovalRecord, EditApprovalArgs, MessageArgs, MessageResult, MessageUsage, NotificationArgs, ResolveApprovalArgs, RuntimeAgent, RuntimeAllowlistPatch, RuntimeToolActivity, RuntimeAvailableModel, RuntimeConfigAccess, RuntimeImageBackground, RuntimeImageEditInput, RuntimeImageFile, RuntimeImageGenerateInput, RuntimeImageGenerationResult, RuntimeImageOutputFormat, RuntimeImageProvider, RuntimeImageProviderCapabilities, RuntimeImagesAccess, RuntimeMemoryEntry, RuntimeMemoryEntryStat, RuntimeMemoryPathMatch, RuntimeMemoryReadRange, RuntimeMemorySearchResult, RuntimeMemoryTier, RuntimeMessageToolPolicy, RuntimeMessageToolsMode, RuntimeMetadata, RuntimePermissionPatch, RawCronSnapshot, RuntimeSession, RuntimeSessionStoreStats, RuntimeSkill, ToolResult, UpdateCronJobInput, UpdateRuntimeAgentInput, WorkspaceFile, } from './concepts';
@@ -1,5 +1,14 @@
1
1
  /** Human-readable relative time from an ISO timestamp */
2
2
  export declare function formatAge(timestamp: string): string;
3
+ /**
4
+ * Human-readable absolute date+time with calendar awareness:
5
+ * "Today 3:45 PM" / "Yesterday 9:02 AM" / "Jan 5 3:45 PM", carrying the year
6
+ * only for prior-year timestamps (a bare "Jan 5" is ambiguous once runs and
7
+ * completions outlive the calendar). Falls back to the raw input if unparseable.
8
+ */
9
+ export declare function formatDateTime(timestamp: string): string;
10
+ /** Human-readable elapsed duration from a millisecond count ("850ms" / "42s" / "3m 5s"); null when undefined. */
11
+ export declare function formatDuration(ms?: number): string | null;
3
12
  /** Human-readable file size */
4
13
  export declare function formatSize(bytes: number): string;
5
14
  /** Check if a heartbeat timestamp is stale (> 15 min) */