@makinbakin/sdk 0.0.1-rc.20 → 0.0.1-rc.21

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 (110) hide show
  1. package/_internal/app/components/agent-select.d.ts +10 -1
  2. package/_internal/app/components/asset-picker.d.ts +25 -0
  3. package/_internal/app/components/charts/bar-chart.d.ts +16 -0
  4. package/_internal/app/components/charts/chart-data-table.d.ts +31 -0
  5. package/_internal/app/components/charts/chart-explainer.d.ts +9 -0
  6. package/_internal/app/components/charts/chart-tooltip.d.ts +8 -0
  7. package/_internal/app/components/charts/line-chart.d.ts +13 -0
  8. package/_internal/app/components/charts/palette.d.ts +24 -0
  9. package/_internal/app/components/charts/sparkline.d.ts +12 -0
  10. package/_internal/app/components/charts/stacked-column-chart.d.ts +40 -0
  11. package/_internal/app/components/confirm-dialog.d.ts +23 -2
  12. package/_internal/app/components/conversation/activity-group.d.ts +15 -0
  13. package/_internal/app/components/conversation/agent-turn.d.ts +36 -0
  14. package/_internal/app/components/conversation/attention.d.ts +56 -0
  15. package/_internal/app/components/conversation/composer.d.ts +35 -0
  16. package/_internal/app/components/conversation/conversation-empty-state.d.ts +8 -0
  17. package/_internal/app/components/conversation/conversation-panel.d.ts +33 -0
  18. package/_internal/app/components/conversation/conversation.d.ts +14 -0
  19. package/_internal/app/components/conversation/fold.d.ts +129 -0
  20. package/_internal/app/components/conversation/notification-sound.d.ts +8 -0
  21. package/_internal/app/components/conversation/relative-time.d.ts +8 -0
  22. package/_internal/app/components/conversation/reply-toast.d.ts +15 -0
  23. package/_internal/app/components/conversation/thread-id.d.ts +8 -0
  24. package/_internal/app/components/conversation/tool-call-drawer.d.ts +7 -0
  25. package/_internal/app/components/conversation/turn-recorder.d.ts +37 -0
  26. package/_internal/app/components/conversation/use-conversation-attention.d.ts +64 -0
  27. package/_internal/app/components/conversation/use-conversation-thread.d.ts +55 -0
  28. package/_internal/app/components/conversation/user-message.d.ts +11 -0
  29. package/_internal/app/components/danger-zone.d.ts +28 -0
  30. package/_internal/app/components/empty-state.d.ts +5 -2
  31. package/_internal/app/components/plugin-header.d.ts +4 -3
  32. package/_internal/app/components/save-bar.d.ts +32 -0
  33. package/_internal/app/components/score-overlay.d.ts +33 -0
  34. package/_internal/app/components/search-degraded-chip.d.ts +4 -0
  35. package/_internal/app/components/search-partial-chip.d.ts +13 -0
  36. package/_internal/app/components/search-unavailable.d.ts +12 -0
  37. package/_internal/app/components/section-card.d.ts +22 -0
  38. package/_internal/app/components/segmented-control.d.ts +28 -0
  39. package/_internal/app/components/stat-tile.d.ts +26 -0
  40. package/_internal/app/components/status-badge.d.ts +19 -0
  41. package/_internal/app/components/turn-output-view.d.ts +57 -0
  42. package/_internal/app/components/ui/button.d.ts +1 -1
  43. package/_internal/app/components/underline-tabs.d.ts +6 -2
  44. package/_internal/app/components/unsaved-changes-guard.d.ts +34 -0
  45. package/_internal/app/core/conversation-turns.d.ts +148 -0
  46. package/_internal/app/core/logger.d.ts +1 -0
  47. package/_internal/app/hooks/use-file-drop.d.ts +25 -0
  48. package/_internal/app/hooks/use-history-back.d.ts +1 -0
  49. package/_internal/app/hooks/use-json-fetch.d.ts +5 -0
  50. package/_internal/app/hooks/use-query-state.d.ts +2 -0
  51. package/_internal/app/hooks/use-schedule.d.ts +45 -0
  52. package/_internal/app/hooks/use-search.d.ts +27 -8
  53. package/_internal/app/hooks/use-toast.d.ts +3 -3
  54. package/_internal/app/lib/browser-notify.d.ts +12 -1
  55. package/_internal/core/adapters/runtime/concepts.d.ts +547 -49
  56. package/_internal/core/adapters/runtime/errors.d.ts +13 -1
  57. package/_internal/core/adapters/runtime/helpers.d.ts +19 -0
  58. package/_internal/core/adapters/runtime/index.d.ts +5 -2
  59. package/_internal/core/adapters/runtime/testing.d.ts +79 -0
  60. package/_internal/core/adapters/runtime/turn-activity.d.ts +23 -0
  61. package/_internal/core/adapters/shared.d.ts +122 -12
  62. package/_internal/core/content-dir.d.ts +8 -0
  63. package/_internal/core/docs/route.d.ts +1 -1
  64. package/_internal/core/format/structured.d.ts +44 -0
  65. package/_internal/core/format.d.ts +5 -1
  66. package/_internal/core/media/downscale.d.ts +18 -0
  67. package/_internal/core/media/sharp-loader.d.ts +36 -0
  68. package/_internal/core/plugin-types.d.ts +102 -39
  69. package/_internal/core/routing/define.d.ts +26 -3
  70. package/_internal/core/routing/dispatcher.d.ts +15 -6
  71. package/_internal/core/routing/index.d.ts +1 -1
  72. package/_internal/core/routing/types.d.ts +13 -70
  73. package/_internal/core/storage/atomic-write.d.ts +11 -0
  74. package/_internal/core/tasks/store.d.ts +129 -0
  75. package/_internal/core/tasks/testing.d.ts +2 -0
  76. package/_internal/{plugins/workflows/lib → core/workflows}/notification-channel-registry.d.ts +1 -1
  77. package/_internal/plugins/team/types.d.ts +47 -0
  78. package/_internal/plugins/workflows/hooks/use-notification-channels.d.ts +1 -1
  79. package/components/index.d.ts +87 -19
  80. package/components/index.js +32904 -15368
  81. package/hooks/index.d.ts +24 -4
  82. package/hooks/index.js +837 -561
  83. package/hooks/router.d.ts +20 -4
  84. package/index.d.ts +5 -50
  85. package/index.js +223 -406
  86. package/internal/index.d.ts +70 -0
  87. package/internal/index.js +409 -0
  88. package/package.json +9 -2
  89. package/register.d.ts +19 -1
  90. package/routing/index.js +175 -147
  91. package/slots/index.js +20 -1
  92. package/testing/index.d.ts +122 -0
  93. package/testing/index.js +21874 -0
  94. package/types/index.d.ts +4 -0
  95. package/types/index.js +16 -0
  96. package/utils/index.d.ts +28 -25
  97. package/utils/index.js +279 -263
  98. package/_internal/app/components/integrated-brainstorm/activity.d.ts +0 -23
  99. package/_internal/app/components/integrated-brainstorm/collapsed-header.d.ts +0 -14
  100. package/_internal/app/components/integrated-brainstorm/empty-state.d.ts +0 -5
  101. package/_internal/app/components/integrated-brainstorm/index.d.ts +0 -8
  102. package/_internal/app/components/integrated-brainstorm/input-row.d.ts +0 -16
  103. package/_internal/app/components/integrated-brainstorm/message-list.d.ts +0 -8
  104. package/_internal/app/components/integrated-brainstorm/session.d.ts +0 -16
  105. package/_internal/app/components/integrated-brainstorm/sse.d.ts +0 -8
  106. package/_internal/app/components/integrated-brainstorm/thinking-indicator.d.ts +0 -19
  107. package/_internal/app/components/integrated-brainstorm/types.d.ts +0 -63
  108. package/_internal/app/components/integrated-brainstorm/use-auto-grow.d.ts +0 -6
  109. package/_internal/app/components/integrated-brainstorm/use-brainstorm-state.d.ts +0 -21
  110. /package/_internal/{plugins/models → app}/hooks/use-available-models.d.ts +0 -0
@@ -17,7 +17,19 @@ export type RuntimeErrorKind =
17
17
  /** Provider/auth cooldown — model provider unavailable, retry later. */
18
18
  | 'provider_cooldown'
19
19
  /** Structured runtime failure (HTTP-status class, CLI exit, protocol). */
20
- | 'runtime_failed';
20
+ | 'runtime_failed'
21
+ /**
22
+ * The caller intentionally cancelled the turn (MessageArgs.signal) —
23
+ * terminal: never retried, never diagnosed, never enters the recovery
24
+ * ladder.
25
+ */
26
+ | 'aborted'
27
+ /**
28
+ * A CRUD mutation addressed an entity (agent, skill, cron job) that does
29
+ * not exist on the runtime. Reads return `null` for absence; only
30
+ * mutations reject with this kind (R28).
31
+ */
32
+ | 'not_found';
21
33
  /**
22
34
  * Structured provider metadata for `provider_cooldown` failures, extracted by
23
35
  * the adapter from provider-specific error payloads so core never parses
@@ -1,5 +1,24 @@
1
1
  import type { AgentRuntimeAdapter, RuntimeAgent } from './concepts';
2
+ /**
3
+ * Resolve the runtime's ORCHESTRATOR from its roster (P2.6) — a
4
+ * runtime-declared fact, never a baked constant. Ladder:
5
+ *
6
+ * 1. id 'main' — the declared-id convention both adapters seed.
7
+ * 2. role 'orchestrator' — the declared-role generalization: a runtime
8
+ * whose orchestrator has a different id resolves here.
9
+ * 3. first agent — degraded last resort so single-agent rosters
10
+ * always resolve.
11
+ *
12
+ * The id rung leads deliberately: role text is fuzzy (OpenClaw derives it
13
+ * from IDENTITY.md, which agent packages can set) — an installed persona
14
+ * claiming "Orchestrator" must never outrank the declared main agent.
15
+ */
2
16
  export declare function selectRuntimeMainAgent(agents: RuntimeAgent[]): RuntimeAgent | null;
3
17
  export declare function getRuntimeMainAgent(runtime: AgentRuntimeAdapter): Promise<RuntimeAgent | null>;
18
+ /**
19
+ * Resolved orchestrator id. The `fallback` applies ONLY to an empty/unreadable
20
+ * roster (degraded mode: runtime down mid-flight) — callers that can degrade
21
+ * differently should pass their own.
22
+ */
4
23
  export declare function getRuntimeMainAgentId(runtime: AgentRuntimeAdapter, fallback?: string): Promise<string>;
5
24
  export declare function getRuntimeMainAgentName(runtime: AgentRuntimeAdapter, fallback?: string): Promise<string>;
@@ -1,7 +1,10 @@
1
- export type { AdapterAuditEvent, AdapterHealthCheckDefinition, AdapterHealthCheckResult, AdapterInitOpts, AdapterLogger, Unsubscribe, } from '../shared';
1
+ export type { AdapterAuditEvent, AdapterInitOpts, AdapterLogger, AdapterToolActivityEvent, AdapterTurnActivityEvent, RuntimeExecToolDescriptor, RuntimeExecToolInvokeResult, RuntimeExecToolProvider, Unsubscribe, } from '../shared';
2
+ export { beginAdapterTurnActivity } from './turn-activity';
3
+ export type { AdapterTurnActivityReporter, BeginAdapterTurnActivityOptions } from './turn-activity';
2
4
  export type { ChannelCapability } from './capabilities';
3
5
  export { hasChannelCapability } from './capabilities';
4
6
  export { RuntimeError, RuntimeTurnError } from './errors';
5
7
  export type { RuntimeErrorKind, RuntimeErrorOptions, RuntimeProviderInfo, RuntimeTurnDiagnosis, RuntimeTurnFailureReason, } from './errors';
6
8
  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, 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';
9
+ export type { AgentRuntimeAdapter, ApprovalDelivery, ApprovalOption, ApprovalPatch, ApprovalRenderRef, ApprovalRenderResult, ApprovalResolveEvent, ApprovalResponse, CancelApprovalArgs, ChannelInfo, ChannelMessageArgs, ChatChunk, ChatTextFormat, ContentDeliveryArgs, CreateApprovalArgs, CreateCronJobInput, CreateRuntimeAgentInput, CronJob, CronRun, DeliveryResult, DurableApprovalRecord, EditApprovalArgs, MessageArgs, MessageAttachment, MessageResult, MessageUsage, NotificationArgs, ResolveApprovalArgs, RuntimeAgent, RuntimeAllowlistPatch, RuntimeToolActivity, RuntimeAvailableModel, RuntimeCapabilities, CapabilityMode, ToolAccessStyle, RuntimeToolAccess, ToolAccessProvisioningStatus, RuntimeCredentialStatus, RuntimeRoutingPolicy, RuntimeRoutingSupport, CapabilitySet, RuntimeImageBackground, RuntimeImageEditInput, RuntimeImageFile, RuntimeImageGenerateInput, RuntimeImageGenerationResult, RuntimeImageOutputFormat, RuntimeImageProvider, RuntimeImageProviderCapabilities, RuntimeImagesAccess, RuntimeExtensionInfo, RuntimeExtensionsAccess, RuntimeMemoryEntry, RuntimeMemoryEntryStat, RuntimeMemoryPathMatch, RuntimeMemoryReadRange, RuntimeMemorySearchResult, RuntimeMemoryTier, RuntimeMessageToolPolicy, RuntimeMessageToolsMode, RuntimeMetadata, RawCronSnapshot, RuntimeSession, RuntimeSessionStoreStats, RuntimeSkill, UpdateCronJobInput, UpdateRuntimeAgentInput, WorkspaceFile, WorkspaceFileStat, } from './concepts';
10
+ export { RUNTIME_MEDIA_URI_SCHEME, DEFAULT_OVERSIZED_OUTPUT_BYTES } from './concepts';
@@ -0,0 +1,79 @@
1
+ import type { AgentRuntimeAdapter } from './concepts';
2
+ /**
3
+ * Opt-in channels surface for the mock (delivery capability pairs with it —
4
+ * see createMockRuntimeAdapter). The DEFAULT mock omits `channels` entirely:
5
+ * it is an optional contract member (Pi omits it in production), so plugin
6
+ * code must feature-detect. A bare `runtime.channels.x()` against the default
7
+ * mock now throws instead of silently passing (audit finding H2).
8
+ *
9
+ * Usage: `createMockRuntimeAdapter({ channels: mockChannels() })`
10
+ */
11
+ export declare function mockChannels(): NonNullable<AgentRuntimeAdapter['channels']>;
12
+ /**
13
+ * Opt-in cron surface for the mock — same rationale as mockChannels():
14
+ * `cron` is an optional contract member (Pi omits it), so the default mock
15
+ * omits it and consumers feature-detect.
16
+ *
17
+ * Usage: `createMockRuntimeAdapter({ cron: mockCron() })`
18
+ */
19
+ /**
20
+ * Filename the isolation-honoring mock drops into each turn's runWorkspace —
21
+ * the conformance isolation probe's observable (same-agent-concurrency D1).
22
+ */
23
+ export declare const MOCK_ISOLATION_PROBE = "cwd-probe.txt";
24
+ /**
25
+ * Opt-in same-agent-turn isolation for the mock: declares
26
+ * `concurrency.sameAgentTurns: 'isolated'` and honors
27
+ * `MessageArgs.runWorkspace` by dropping MOCK_ISOLATION_PROBE into the
28
+ * handed directory before delegating — the minimal observable proof the
29
+ * conformance isolation check requires. The DEFAULT mock stays
30
+ * 'serialized' (minimal shape).
31
+ *
32
+ * Usage: `withMockIsolation(createMockRuntimeAdapter())`
33
+ */
34
+ export declare function withMockIsolation(base: AgentRuntimeAdapter): AgentRuntimeAdapter;
35
+ export declare function mockCron(): NonNullable<AgentRuntimeAdapter['cron']>;
36
+ export declare function createMockRuntimeAdapter(overrides?: Partial<AgentRuntimeAdapter>): AgentRuntimeAdapter;
37
+ /**
38
+ * Opt-in image-input capability override for attachment tests:
39
+ * `createMockRuntimeAdapter({ capabilities: mockImageInputCapabilities() })`.
40
+ * The default mock declares `imageInput: false` (minimal shape); streams
41
+ * still echo attachments in the reply text so pass-through is assertable
42
+ * either way.
43
+ */
44
+ export declare function mockImageInputCapabilities(): (opts?: {
45
+ agentId?: string;
46
+ }) => Promise<ReturnType<typeof mockCapabilities>>;
47
+ declare function mockCapabilities(deliveryNative: boolean): {
48
+ toolCalling: {
49
+ mode: "native";
50
+ access: {
51
+ style: "mcp";
52
+ mcpServerTemplate: string;
53
+ perTurnExecToolFiltering: boolean;
54
+ };
55
+ };
56
+ delivery: {
57
+ mode: "unavailable" | "native";
58
+ };
59
+ imageGen: {
60
+ mode: "unavailable";
61
+ };
62
+ memory: {
63
+ mode: "native";
64
+ };
65
+ sessions: {
66
+ mode: "native";
67
+ };
68
+ workspaceFiles: {
69
+ mode: "native";
70
+ };
71
+ input: {
72
+ imageInput: boolean;
73
+ audioInput: boolean;
74
+ };
75
+ concurrency: {
76
+ sameAgentTurns: "serialized";
77
+ };
78
+ };
79
+ export {};
@@ -0,0 +1,23 @@
1
+ import type { AdapterTurnActivityEvent } from '../shared';
2
+ type TurnResultEvent = Extract<AdapterTurnActivityEvent, {
3
+ phase: 'result';
4
+ }>;
5
+ export interface AdapterTurnActivityReporter {
6
+ readonly turnId: string;
7
+ finish(result: Pick<TurnResultEvent, 'status'> & Partial<Pick<TurnResultEvent, 'resultId' | 'usage'>>): void;
8
+ }
9
+ export interface BeginAdapterTurnActivityOptions {
10
+ onActivity?: (event: AdapterTurnActivityEvent) => void;
11
+ onCallbackError?: (error: unknown) => void;
12
+ agentId: string;
13
+ activityClass: AdapterTurnActivityEvent['activityClass'];
14
+ threadId?: string;
15
+ operation: AdapterTurnActivityEvent['operation'];
16
+ }
17
+ /**
18
+ * Start one adapter messaging lifecycle and return its exactly-once finisher.
19
+ * Both the observer and its error reporter are contained: observability is
20
+ * never allowed to change a turn's outcome.
21
+ */
22
+ export declare function beginAdapterTurnActivity(options: BeginAdapterTurnActivityOptions): AdapterTurnActivityReporter;
23
+ export {};
@@ -1,3 +1,4 @@
1
+ import type { ActivityClass } from '@makinbakin/sdk/types';
1
2
  export type Unsubscribe = () => void;
2
3
  export interface AdapterLogger {
3
4
  debug(message: string, data?: unknown): void;
@@ -12,26 +13,135 @@ export interface AdapterAuditEvent {
12
13
  data?: Record<string, unknown>;
13
14
  at?: string;
14
15
  }
16
+ /**
17
+ * One Bakin exec tool as offered across the adapter boundary. The zod
18
+ * shapes stay core-side; adapters receive plain JSON Schema so no
19
+ * validation library leaks into the contract.
20
+ */
21
+ export interface RuntimeExecToolDescriptor {
22
+ name: string;
23
+ description: string;
24
+ /** JSON Schema (object) for the tool's parameters. */
25
+ parametersSchema: Record<string, unknown>;
26
+ }
27
+ export interface RuntimeExecToolInvokeResult {
28
+ ok: boolean;
29
+ /** Model-facing result text (JSON on success, `ERROR: …` on failure). */
30
+ text: string;
31
+ }
32
+ /** Token usage for one agent turn, when the runtime reports it. */
33
+ export interface MessageUsage {
34
+ input?: number;
35
+ output?: number;
36
+ total?: number;
37
+ /** Cached-input tokens read (priced far below fresh input when known). */
38
+ cacheRead?: number;
39
+ /** Cached-input tokens written (cache creation). */
40
+ cacheWrite?: number;
41
+ /** Resolved model the runtime ran, when known. */
42
+ model?: string;
43
+ }
44
+ /**
45
+ * One normalized runtime-native tool lifecycle event observed by an adapter.
46
+ * The host uses result events for cross-runtime observability; call events are
47
+ * included so it can derive duration when the runtime does not report one.
48
+ */
49
+ interface AdapterToolActivityBase {
50
+ agentId: string;
51
+ /** Producer-assigned classification from the originating runtime turn. */
52
+ activityClass: ActivityClass;
53
+ /** Owning adapter turn; required so terminal reconciliation cannot silently opt out. */
54
+ turnId: string;
55
+ threadId?: string;
56
+ callId?: string;
57
+ toolName: string;
58
+ }
59
+ /**
60
+ * One normalized tool lifecycle event. Runtime-private status aliases must be
61
+ * resolved by the adapter before crossing this boundary.
62
+ */
63
+ export type AdapterToolActivityEvent = AdapterToolActivityBase & {
64
+ phase: 'call';
65
+ status: 'running';
66
+ } | AdapterToolActivityBase & {
67
+ phase: 'result';
68
+ status: 'completed' | 'failed' | 'aborted';
69
+ durationMs?: number;
70
+ };
71
+ interface AdapterTurnActivityBase {
72
+ agentId: string;
73
+ /** Producer-assigned classification from the originating runtime turn. */
74
+ activityClass: ActivityClass;
75
+ threadId?: string;
76
+ /** Messaging surface that owns the turn. */
77
+ operation: 'send' | 'stream';
78
+ /** Adapter-generated identity shared by this turn's start and result. */
79
+ turnId: string;
80
+ }
81
+ /**
82
+ * One normalized messaging turn lifecycle event observed at the adapter
83
+ * boundary. Every executed send/stream emits exactly one start and one result.
84
+ * Result identity and usage are present when the messaging surface reports
85
+ * them (currently send); adapters never fabricate usage.
86
+ */
87
+ export type AdapterTurnActivityEvent = AdapterTurnActivityBase & {
88
+ phase: 'start';
89
+ status: 'running';
90
+ } | AdapterTurnActivityBase & {
91
+ phase: 'result';
92
+ status: 'completed' | 'failed' | 'aborted';
93
+ durationMs: number;
94
+ resultId?: string;
95
+ usage?: MessageUsage;
96
+ };
97
+ /**
98
+ * Bakin's exec-tool registry offered to runtimes that deliver tools
99
+ * in-process (Pi registers these as native session tools). Out-of-band
100
+ * runtimes (OpenClaw reaches the same registry over its native MCP client)
101
+ * ignore it. `list()` reads the LIVE registry — call it at session build
102
+ * time so late plugin registrations and hot reloads are visible.
103
+ * Usage recording + audit happen inside `invoke`; adapters add nothing.
104
+ */
105
+ export interface RuntimeExecToolProvider {
106
+ list(): RuntimeExecToolDescriptor[];
107
+ invoke(name: string, params: Record<string, unknown>, agentId: string): Promise<RuntimeExecToolInvokeResult>;
108
+ }
15
109
  export interface AdapterInitOpts {
16
110
  contentDir: string;
17
111
  settings?: Record<string, unknown>;
112
+ /**
113
+ * LIVE view of the adapter-private settings bag. `settings` is a boot-time
114
+ * snapshot; surfaces whose behavior must track settings edits WITHOUT a
115
+ * restart (extension trust policy, per-turn knobs) read through this.
116
+ * Optional: tests and thin callers may omit it (snapshot semantics).
117
+ */
118
+ getLiveSettings?: () => Record<string, unknown> | undefined;
18
119
  logger?: AdapterLogger;
19
120
  audit?: (event: AdapterAuditEvent) => void;
20
- }
21
- export interface AdapterHealthCheckResult {
22
- check: string;
23
- status: 'ok' | 'warn' | 'error' | 'fixed';
24
- message: string;
25
- autoFixable: boolean;
26
- }
27
- export interface AdapterHealthCheckDefinition {
28
- id: string;
29
- name: string;
30
- run(): Promise<AdapterHealthCheckResult[]>;
31
- autoFix?: boolean;
121
+ execTools?: RuntimeExecToolProvider;
122
+ /**
123
+ * Best-effort host observability tap for tool activity across every runtime
124
+ * messaging surface. Adapters contain callback failures so telemetry can
125
+ * never fail an agent turn.
126
+ */
127
+ onToolActivity?: (event: AdapterToolActivityEvent) => void;
128
+ /**
129
+ * Best-effort host observability tap for every messaging send/stream turn.
130
+ * Adapters contain callback failures so telemetry can never fail a turn.
131
+ */
132
+ onTurnActivity?: (event: AdapterTurnActivityEvent) => void;
133
+ /**
134
+ * Base URL of Bakin's MCP server (e.g. `http://localhost:3737`) — the seam
135
+ * a runtime whose agents reach Bakin over MCP (OpenClaw) needs to write its
136
+ * per-agent server entries during `provisionToolAccess`. Core knows the
137
+ * port; the adapter does not, so it is threaded here. In-process runtimes
138
+ * (Pi) ignore it.
139
+ */
140
+ bakinMcpBaseUrl?: string;
32
141
  }
33
142
  export interface AdapterVersionInfo {
34
143
  readonly name: string;
35
144
  readonly version: string;
36
145
  readonly requiredCoreVersion?: string;
37
146
  }
147
+ export {};
@@ -28,9 +28,17 @@ export interface BakinPaths {
28
28
  inbox: string;
29
29
  tasks: string;
30
30
  workflows: string;
31
+ /** Brand records — per-brand dirs with manifest + guidelines + lessons (#419). */
32
+ brands: string;
33
+ /** Chat plugin transcripts + index (Bakin-owned UI data). */
34
+ chat: string;
31
35
  settings: string;
32
36
  logs: string;
37
+ /** Data dir for Bakin's private antfly instance (created on demand by the adapter). */
38
+ antfly: string;
33
39
  db: string;
40
+ /** Bakin-owned bin dir for capability-pack binaries; prepended to PATH at server boot. */
41
+ bin: string;
34
42
  }
35
43
  export declare function getBakinPaths(): BakinPaths;
36
44
  /**
@@ -1,4 +1,4 @@
1
- import type { APIRoute } from '../plugin-types';
1
+ import type { RegisteredAPIRoute as APIRoute } from '../plugin-types';
2
2
  export type DocsAwareAPIRoute = APIRoute & {
3
3
  summary: string;
4
4
  description: string;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Human-readable rendering of structured (JSON-ish) values — the shared home
3
+ * (#608) so UI surfaces, channels, and tool-activity feeds never dump raw
4
+ * JSON blobs at people. Client + server safe (pure, no deps).
5
+ *
6
+ * Variants:
7
+ * - formatStructured(value, { markdown }) → labeled multi-line prose
8
+ * (`Label: value`, nested objects indented; markdown bolds the labels
9
+ * for channel messages).
10
+ * - summarizeStructured(value, cap) → ONE compact line for chips/badges.
11
+ * - unwrapToolResult(value) → peel a runtime tool-result envelope
12
+ * (`{content:[{type:'text',text}]}`) down to its meaningful payload,
13
+ * parsing an inner JSON string when present.
14
+ */
15
+ export declare function humanizeKey(key: string): string;
16
+ export interface FormatStructuredOptions {
17
+ /** Bold labels for markdown surfaces (channel messages). */
18
+ markdown?: boolean;
19
+ /** Override the section heading; a blank line follows it. Omit for no heading. */
20
+ heading?: string;
21
+ /** Cap the rendered body; appends a truncation marker when exceeded. */
22
+ cap?: number;
23
+ }
24
+ /**
25
+ * Labeled prose for a structured value. Returns '' when there's nothing
26
+ * human-reviewable (empty object / all-empty fields) — callers show nothing
27
+ * rather than a bare "{}". A scalar renders as itself.
28
+ */
29
+ export declare function formatStructured(value: unknown, opts?: FormatStructuredOptions): string;
30
+ /**
31
+ * ONE compact line for chips/badges. Skips status noise (`ok: true` is shown
32
+ * by the chip's color, not its text), prefers a descriptive field, and
33
+ * describes collections by count rather than dropping them.
34
+ */
35
+ export declare function summarizeStructured(value: unknown, cap?: number): string;
36
+ /**
37
+ * Peel a runtime tool-result envelope to its meaningful payload:
38
+ * { content: [{ type:'text', text }] } → the joined text, JSON-parsed when
39
+ * the text is itself a JSON document (bakin exec tools return JSON strings).
40
+ * Peels REPEATEDLY — an agent that shells a tool via bash produces a
41
+ * doubly-wrapped envelope (runtime content → shell stdout → MCP content).
42
+ * Non-envelope values pass through unchanged. Never throws.
43
+ */
44
+ export declare function unwrapToolResult(value: unknown, depth?: number): unknown;
@@ -7,9 +7,13 @@ export declare function formatAge(timestamp: string): string;
7
7
  * completions outlive the calendar). Falls back to the raw input if unparseable.
8
8
  */
9
9
  export declare function formatDateTime(timestamp: string): string;
10
- /** Human-readable elapsed duration from a millisecond count ("850ms" / "42s" / "3m 5s"); null when undefined. */
10
+ /**
11
+ * Human-readable elapsed duration from a millisecond count, rolling up through
12
+ * units ("850ms" / "42s" / "3m 5s" / "2h 5m" / "3d 2h"); null when undefined.
13
+ */
11
14
  export declare function formatDuration(ms?: number): string | null;
12
15
  /** Human-readable file size */
13
16
  export declare function formatSize(bytes: number): string;
14
17
  /** Check if a heartbeat timestamp is stale (> 15 min) */
15
18
  export declare function isStale(timestamp: string, thresholdMs?: number): boolean;
19
+ export { humanizeKey, formatStructured, summarizeStructured, unwrapToolResult, type FormatStructuredOptions, } from './format/structured';
@@ -0,0 +1,18 @@
1
+ export declare const INLINE_ATTACHMENT_LIMIT_BYTES = 2000000;
2
+ export interface PreparedAttachment {
3
+ path: string;
4
+ mimeType: string;
5
+ downscaled: boolean;
6
+ }
7
+ /**
8
+ * Returns the original when it already fits; otherwise a downscaled temp
9
+ * JPEG. Throws (loudly, with the silent-degradation rationale) when the
10
+ * image cannot be brought under the cap — never sends an oversized file.
11
+ */
12
+ export declare function prepareImageAttachment(path: string, mimeType: string): Promise<PreparedAttachment>;
13
+ /**
14
+ * Remove the temp dir a downscale created. Callers own the lifetime — e.g.
15
+ * the enrichment engine calls this after its LAST send (the corrective
16
+ * re-ask reuses the file). No-op for originals.
17
+ */
18
+ export declare function cleanupPreparedAttachment(prepared: PreparedAttachment): void;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The subset of the sharp API Bakin uses, typed STRUCTURALLY — a
3
+ * `typeof` import of the sharp module here would put the sharp package
4
+ * into the declaration graph of everything that can reach this file
5
+ * (including the published SDK testing bundle since #703), and sharp
6
+ * deliberately has no declared version anywhere. Extend this interface
7
+ * when new call sites need more of sharp's surface.
8
+ */
9
+ export interface SharpResizeOptions {
10
+ width?: number;
11
+ height?: number;
12
+ fit?: 'inside' | 'cover' | 'contain' | 'fill' | 'outside';
13
+ withoutEnlargement?: boolean;
14
+ }
15
+ export interface SharpPipeline {
16
+ rotate(): SharpPipeline;
17
+ resize(options: SharpResizeOptions): SharpPipeline;
18
+ resize(width?: number, height?: number, options?: SharpResizeOptions): SharpPipeline;
19
+ jpeg(options?: {
20
+ quality?: number;
21
+ }): SharpPipeline;
22
+ png(options?: {
23
+ quality?: number;
24
+ }): SharpPipeline;
25
+ webp(options?: {
26
+ quality?: number;
27
+ }): SharpPipeline;
28
+ metadata(): Promise<{
29
+ width?: number;
30
+ height?: number;
31
+ format?: string;
32
+ }>;
33
+ toFile(path: string): Promise<unknown>;
34
+ }
35
+ export type Sharp = (input: string) => SharpPipeline;
36
+ export declare function loadSharp(): Promise<Sharp | null>;