@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.
Files changed (42) hide show
  1. package/README.md +1 -0
  2. package/_internal/app/components/agent-select.d.ts +7 -2
  3. package/_internal/app/components/confirm-dialog.d.ts +33 -0
  4. package/_internal/app/components/empty-state.d.ts +14 -5
  5. package/_internal/app/components/ui/badge.d.ts +1 -1
  6. package/_internal/app/components/ui/button.d.ts +1 -1
  7. package/_internal/app/hooks/use-content-store.d.ts +0 -9
  8. package/_internal/app/hooks/use-horizontal-resize.d.ts +22 -0
  9. package/_internal/app/hooks/use-json-fetch.d.ts +21 -0
  10. package/_internal/app/hooks/use-nav-badge.d.ts +13 -0
  11. package/_internal/app/hooks/use-plugin-event.d.ts +19 -0
  12. package/_internal/app/hooks/use-resizable-pane.d.ts +35 -0
  13. package/_internal/app/hooks/use-schedule.d.ts +2 -1
  14. package/_internal/app/hooks/use-task-run-history.d.ts +26 -0
  15. package/_internal/app/hooks/use-vertical-resize.d.ts +6 -7
  16. package/_internal/app/types/index.d.ts +1 -105
  17. package/_internal/core/adapters/runtime/concepts.d.ts +141 -67
  18. package/_internal/core/adapters/runtime/errors.d.ts +86 -0
  19. package/_internal/core/adapters/runtime/index.d.ts +3 -1
  20. package/_internal/core/content-dir.d.ts +1 -0
  21. package/_internal/core/format.d.ts +9 -0
  22. package/_internal/core/plugin-types.d.ts +124 -470
  23. package/_internal/plugins/models/hooks/use-available-models.d.ts +5 -0
  24. package/_internal/plugins/team/types.d.ts +14 -4
  25. package/components/index.d.ts +40 -2
  26. package/components/index.js +15897 -1678
  27. package/hooks/index.d.ts +69 -8
  28. package/hooks/index.js +14589 -369
  29. package/index.d.ts +64 -2
  30. package/index.js +228 -7
  31. package/metadata/index.d.ts +14 -1
  32. package/package.json +1 -1
  33. package/register.d.ts +45 -9
  34. package/routing/index.d.ts +6 -1
  35. package/routing/index.js +13 -1
  36. package/slots/index.d.ts +16 -24
  37. package/slots/index.js +196 -30
  38. package/types/index.d.ts +15 -919
  39. package/ui/index.js +2 -1
  40. package/utils/index.d.ts +40 -3
  41. package/utils/index.js +57 -0
  42. package/_internal/app/hooks/use-assets.d.ts +0 -25
@@ -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 {
@@ -82,11 +105,6 @@ export interface ChatChunk {
82
105
  content?: string;
83
106
  data?: RuntimeMetadata | RuntimeToolActivity;
84
107
  }
85
- export interface ToolDefinition {
86
- name: string;
87
- description?: string;
88
- inputSchema?: unknown;
89
- }
90
108
  export interface ToolResult {
91
109
  ok: boolean;
92
110
  output?: unknown;
@@ -203,31 +221,6 @@ export interface ApprovalResolveEvent {
203
221
  response: ApprovalResponse;
204
222
  channelId: string;
205
223
  }
206
- export interface ChannelMessageEvent {
207
- channelId: string;
208
- messageId: string;
209
- actor: {
210
- type: 'agent' | 'human';
211
- id: string;
212
- displayName?: string;
213
- };
214
- body: string;
215
- threadId?: string;
216
- receivedAt: string;
217
- metadata?: RuntimeMetadata;
218
- }
219
- export interface ChannelInteractionEvent {
220
- channelId: string;
221
- interactionId: string;
222
- actor: {
223
- type: 'agent' | 'human';
224
- id: string;
225
- displayName?: string;
226
- };
227
- kind: string;
228
- payload: RuntimeMetadata;
229
- receivedAt: string;
230
- }
231
224
  export interface DurableApprovalRecord {
232
225
  approvalId: string;
233
226
  owner: {
@@ -259,6 +252,19 @@ export interface RuntimeSession {
259
252
  updatedAt?: string;
260
253
  metadata?: RuntimeMetadata;
261
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
+ }
262
268
  export interface RuntimeMemoryTier {
263
269
  id: string;
264
270
  label: string;
@@ -308,38 +314,100 @@ export interface RuntimeAvailableModel {
308
314
  tags?: string[];
309
315
  metadata?: RuntimeMetadata;
310
316
  }
311
- export interface TaskDispatchArgs {
312
- bakinTaskId: string;
313
- agentId?: string;
314
- title: string;
315
- description?: string;
317
+ export type RuntimeImageOutputFormat = 'png' | 'jpeg' | 'jpg' | 'webp';
318
+ export type RuntimeImageBackground = 'transparent' | 'opaque' | 'auto';
319
+ /**
320
+ * Image capability is intentionally all-optional. A thin runtime that exposes a
321
+ * single image tool maps on by filling minimal fields (e.g. one synthesized
322
+ * provider with a defaultModel); a rich runtime fills more. Consumers MUST
323
+ * treat a sparse capability as normal and never require a field a thin runtime
324
+ * cannot provide — gaps are filled below, in the adapter/shim, not pushed up
325
+ * into plugins. See .claude/knowledge/media-generation-adapter-architecture.md.
326
+ */
327
+ export interface RuntimeImageProviderCapabilities {
328
+ generate?: {
329
+ maxCount?: number;
330
+ supportsSize?: boolean;
331
+ supportsAspectRatio?: boolean;
332
+ supportsResolution?: boolean;
333
+ };
334
+ edit?: {
335
+ enabled?: boolean;
336
+ maxCount?: number;
337
+ maxInputImages?: number;
338
+ supportsSize?: boolean;
339
+ supportsAspectRatio?: boolean;
340
+ supportsResolution?: boolean;
341
+ };
342
+ geometry?: {
343
+ sizes?: string[];
344
+ aspectRatios?: string[];
345
+ resolutions?: string[];
346
+ };
347
+ output?: {
348
+ formats?: string[];
349
+ qualities?: string[];
350
+ backgrounds?: string[];
351
+ };
316
352
  metadata?: RuntimeMetadata;
317
353
  }
318
- export interface TaskDispatchResult {
319
- flowId: string;
320
- }
321
- export interface TaskExecutionStatus {
322
- flowId: string;
323
- bakinTaskId?: string;
324
- state: 'queued' | 'running' | 'blocked' | 'succeeded' | 'failed' | 'cancelled' | 'unknown';
325
- currentStep?: string | null;
326
- blockingReason?: string | null;
327
- retryCount?: number;
328
- startedAt?: string | null;
329
- endedAt?: string | null;
330
- updatedAt?: string | null;
354
+ export interface RuntimeImageProvider {
355
+ id: string;
356
+ label?: string;
357
+ defaultModel?: string;
358
+ models?: string[];
359
+ available?: boolean;
360
+ configured?: boolean;
361
+ selected?: boolean;
362
+ capabilities?: RuntimeImageProviderCapabilities;
331
363
  metadata?: RuntimeMetadata;
332
364
  }
333
- export interface ListExecutionsOpts {
334
- bakinTaskId?: string;
335
- agentId?: string;
336
- state?: TaskExecutionStatus['state'];
337
- limit?: number;
365
+ export interface RuntimeImageGenerateInput {
366
+ prompt: string;
367
+ provider?: string;
368
+ model?: string;
369
+ count?: number;
370
+ width?: number;
371
+ height?: number;
372
+ size?: string;
373
+ aspectRatio?: string;
374
+ resolution?: string;
375
+ outputFormat?: RuntimeImageOutputFormat;
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[];
384
+ timeoutMs?: number;
385
+ metadata?: RuntimeMetadata;
338
386
  }
339
- export interface TaskExecutionEvent {
340
- flowId: string;
341
- bakinTaskId?: string;
342
- status: TaskExecutionStatus;
387
+ export interface RuntimeImageEditInput extends RuntimeImageGenerateInput {
388
+ files: string[];
389
+ }
390
+ export interface RuntimeImageFile {
391
+ filePath: string;
392
+ mimeType?: string;
393
+ width?: number;
394
+ height?: number;
395
+ provider?: string;
396
+ model?: string;
397
+ url?: string;
398
+ metadata?: RuntimeMetadata;
399
+ }
400
+ export interface RuntimeImageGenerationResult {
401
+ images: RuntimeImageFile[];
402
+ provider?: string;
403
+ model?: string;
404
+ providerText?: string;
405
+ metadata?: RuntimeMetadata;
406
+ }
407
+ export interface RuntimeImagesAccess {
408
+ providers(): Promise<RuntimeImageProvider[]>;
409
+ generate(input: RuntimeImageGenerateInput): Promise<RuntimeImageGenerationResult>;
410
+ edit(input: RuntimeImageEditInput): Promise<RuntimeImageGenerationResult>;
343
411
  }
344
412
  export interface CronJob {
345
413
  id: string;
@@ -403,7 +471,6 @@ export interface AgentRuntimeAdapter {
403
471
  removeWorkspaceFile(agentId: string, path: string): Promise<void>;
404
472
  updatePermissions(agentId: string, patch: RuntimePermissionPatch): Promise<void>;
405
473
  updateAllowlist(agentId: string, patch: RuntimeAllowlistPatch): Promise<void>;
406
- heartbeat(agentId: string): Promise<boolean>;
407
474
  };
408
475
  messaging: {
409
476
  send(args: MessageArgs): Promise<MessageResult>;
@@ -411,7 +478,6 @@ export interface AgentRuntimeAdapter {
411
478
  };
412
479
  tools: {
413
480
  invoke(agentId: string, name: string, args: unknown): Promise<ToolResult>;
414
- list(agentId: string): Promise<ToolDefinition[]>;
415
481
  };
416
482
  channels: {
417
483
  list(): Promise<ChannelInfo[]>;
@@ -423,8 +489,6 @@ export interface AgentRuntimeAdapter {
423
489
  cancelApproval(args: CancelApprovalArgs): Promise<void>;
424
490
  resolveApproval(args: ResolveApprovalArgs): Promise<void>;
425
491
  subscribeApprovalResponses(handler: (event: ApprovalResolveEvent) => void): Unsubscribe;
426
- onMessage(handler: (event: ChannelMessageEvent) => void): Unsubscribe;
427
- onInteraction(handler: (event: ChannelInteractionEvent) => void): Unsubscribe;
428
492
  };
429
493
  skills: {
430
494
  list(agentId?: string): Promise<RuntimeSkill[]>;
@@ -435,6 +499,12 @@ export interface AgentRuntimeAdapter {
435
499
  sessions: {
436
500
  list(agentId?: string): Promise<RuntimeSession[]>;
437
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[]>;
438
508
  };
439
509
  memory: {
440
510
  listTiers(): Promise<RuntimeMemoryTier[]>;
@@ -464,12 +534,16 @@ export interface AgentRuntimeAdapter {
464
534
  includeUnavailable?: boolean;
465
535
  }): Promise<RuntimeAvailableModel[]>;
466
536
  };
467
- tasks: {
468
- dispatch(args: TaskDispatchArgs): Promise<TaskDispatchResult>;
469
- getExecutionStatus(flowId: string): Promise<TaskExecutionStatus>;
470
- listExecutions(opts?: ListExecutionsOpts): Promise<TaskExecutionStatus[]>;
471
- cancelExecution(flowId: string): Promise<void>;
472
- subscribeExecutionUpdates(handler: (event: TaskExecutionEvent) => void): Unsubscribe;
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>;
473
547
  };
474
548
  cron: {
475
549
  list(): Promise<CronJob[]>;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Typed runtime-failure contracts crossing the adapter boundary.
3
+ *
4
+ * Adapters map every provider failure to a `RuntimeError` with a structural
5
+ * `kind` before it leaves the adapter package. Core (dispatch) classifies on
6
+ * `kind` exclusively — never on error-message text. The original provider
7
+ * error is always preserved on `cause` so transport-level codes
8
+ * (ECONNRESET, AbortError, …) survive the boundary for logging/diagnostics.
9
+ */
10
+ export type RuntimeErrorKind =
11
+ /** Socket drop, disconnect, not-connected, fetch failure — transient. */
12
+ 'transport'
13
+ /** An RPC/transport timer fired without a final response. */
14
+ | 'timeout'
15
+ /** The provider session died mid-turn; carries a RuntimeTurnDiagnosis. */
16
+ | 'session_death'
17
+ /** Provider/auth cooldown — model provider unavailable, retry later. */
18
+ | 'provider_cooldown'
19
+ /** Structured runtime failure (HTTP-status class, CLI exit, protocol). */
20
+ | 'runtime_failed';
21
+ /**
22
+ * Structured provider metadata for `provider_cooldown` failures, extracted by
23
+ * the adapter from provider-specific error payloads so core never parses
24
+ * provider strings.
25
+ */
26
+ export interface RuntimeProviderInfo {
27
+ provider?: string;
28
+ model?: string;
29
+ /** e.g. 'timeout' when the provider entered cooldown after a timeout. */
30
+ cooldownReason?: string;
31
+ /** No auth profile was available (vs. an active profile in cooldown). */
32
+ authProfileUnavailable?: boolean;
33
+ }
34
+ export interface RuntimeErrorOptions {
35
+ kind: RuntimeErrorKind;
36
+ cause?: unknown;
37
+ providerInfo?: RuntimeProviderInfo;
38
+ }
39
+ export declare class RuntimeError extends Error {
40
+ readonly kind: RuntimeErrorKind;
41
+ readonly providerInfo?: RuntimeProviderInfo;
42
+ constructor(message: string, options: RuntimeErrorOptions);
43
+ }
44
+ export type RuntimeTurnFailureReason =
45
+ /** session.ended with a non-success status that was not a runtime timeout. */
46
+ 'session_interrupted'
47
+ /** The session/turn genuinely timed out server-side. */
48
+ | 'runtime_timeout';
49
+ /**
50
+ * Post-mortem of a dead provider turn, assembled entirely inside the runtime
51
+ * adapter (Bakin core never reads provider files). Every field is optional
52
+ * evidence — a partial diagnosis is still more useful than a generic timeout.
53
+ */
54
+ export interface RuntimeTurnDiagnosis {
55
+ reason: RuntimeTurnFailureReason;
56
+ /** Provider session id the turn ran in. */
57
+ sessionId?: string;
58
+ /** Raw provider session end status, e.g. 'interrupted'. */
59
+ sessionStatus?: string;
60
+ /** Provider-reported timeout flag from the session end event. */
61
+ timedOut?: boolean;
62
+ /** Total bytes of the final assistant output that killed the turn. */
63
+ completionBytes?: number;
64
+ /** Provider truncated the recorded completion (trajectory size limit). */
65
+ outputTruncated?: boolean;
66
+ /** completionBytes exceeded the configured oversized-output threshold. */
67
+ oversizedOutput?: boolean;
68
+ /** Last tool the agent invoked before the turn died. */
69
+ lastToolCall?: string;
70
+ /** Truncated completion text preserved for salvage (capped by the adapter). */
71
+ salvagedText?: string;
72
+ /** Token usage recorded for the fatal completion, when available. */
73
+ usage?: {
74
+ input?: number;
75
+ output?: number;
76
+ total?: number;
77
+ };
78
+ /** One-line human-readable diagnosis. */
79
+ detail?: string;
80
+ }
81
+ export declare class RuntimeTurnError extends RuntimeError {
82
+ readonly diagnosis: RuntimeTurnDiagnosis;
83
+ constructor(diagnosis: RuntimeTurnDiagnosis, options?: {
84
+ cause?: unknown;
85
+ });
86
+ }
@@ -1,5 +1,7 @@
1
1
  export type { AdapterAuditEvent, AdapterHealthCheckDefinition, AdapterHealthCheckResult, AdapterInitOpts, AdapterLogger, Unsubscribe, } from '../shared';
2
2
  export type { ChannelCapability } from './capabilities';
3
3
  export { hasChannelCapability } from './capabilities';
4
+ export { RuntimeError, RuntimeTurnError } from './errors';
5
+ export type { RuntimeErrorKind, RuntimeErrorOptions, RuntimeProviderInfo, RuntimeTurnDiagnosis, RuntimeTurnFailureReason, } from './errors';
4
6
  export { getRuntimeMainAgent, getRuntimeMainAgentId, getRuntimeMainAgentName, selectRuntimeMainAgent, } from './helpers';
5
- export type { AgentRuntimeAdapter, ApprovalDelivery, ApprovalOption, ApprovalPatch, ApprovalRenderRef, ApprovalRenderResult, ApprovalResolveEvent, ApprovalResponse, CancelApprovalArgs, ChannelInfo, ChannelInteractionEvent, ChannelMessageArgs, ChannelMessageEvent, ChatChunk, ContentDeliveryArgs, CreateApprovalArgs, CreateCronJobInput, CreateRuntimeAgentInput, CronJob, CronRun, DeliveryResult, DurableApprovalRecord, EditApprovalArgs, ListExecutionsOpts, MessageArgs, MessageResult, NotificationArgs, ResolveApprovalArgs, RuntimeAgent, RuntimeAllowlistPatch, RuntimeToolActivity, RuntimeAvailableModel, RuntimeConfigAccess, RuntimeMemoryEntry, RuntimeMemoryEntryStat, RuntimeMemoryPathMatch, RuntimeMemoryReadRange, RuntimeMemorySearchResult, RuntimeMemoryTier, RuntimeMessageToolPolicy, RuntimeMessageToolsMode, RuntimeMetadata, RuntimePermissionPatch, RawCronSnapshot, RuntimeSession, RuntimeSkill, TaskDispatchArgs, TaskDispatchResult, TaskExecutionEvent, TaskExecutionStatus, ToolDefinition, 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';
@@ -30,6 +30,7 @@ export interface BakinPaths {
30
30
  workflows: string;
31
31
  settings: string;
32
32
  logs: string;
33
+ db: string;
33
34
  }
34
35
  export declare function getBakinPaths(): BakinPaths;
35
36
  /**
@@ -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) */