@makinbakin/sdk 0.0.1-rc.2 → 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.
- package/README.md +1 -0
- package/_internal/app/components/agent-select.d.ts +16 -2
- package/_internal/app/components/asset-picker.d.ts +25 -0
- package/_internal/app/components/charts/bar-chart.d.ts +16 -0
- package/_internal/app/components/charts/chart-data-table.d.ts +31 -0
- package/_internal/app/components/charts/chart-explainer.d.ts +9 -0
- package/_internal/app/components/charts/chart-tooltip.d.ts +8 -0
- package/_internal/app/components/charts/line-chart.d.ts +13 -0
- package/_internal/app/components/charts/palette.d.ts +24 -0
- package/_internal/app/components/charts/sparkline.d.ts +12 -0
- package/_internal/app/components/charts/stacked-column-chart.d.ts +40 -0
- package/_internal/app/components/confirm-dialog.d.ts +54 -0
- package/_internal/app/components/conversation/activity-group.d.ts +15 -0
- package/_internal/app/components/conversation/agent-turn.d.ts +36 -0
- package/_internal/app/components/conversation/attention.d.ts +56 -0
- package/_internal/app/components/conversation/composer.d.ts +35 -0
- package/_internal/app/components/conversation/conversation-empty-state.d.ts +8 -0
- package/_internal/app/components/conversation/conversation-panel.d.ts +33 -0
- package/_internal/app/components/conversation/conversation.d.ts +14 -0
- package/_internal/app/components/conversation/fold.d.ts +129 -0
- package/_internal/app/components/conversation/notification-sound.d.ts +8 -0
- package/_internal/app/components/conversation/relative-time.d.ts +8 -0
- package/_internal/app/components/conversation/reply-toast.d.ts +15 -0
- package/_internal/app/components/conversation/thread-id.d.ts +8 -0
- package/_internal/app/components/conversation/tool-call-drawer.d.ts +7 -0
- package/_internal/app/components/conversation/turn-recorder.d.ts +37 -0
- package/_internal/app/components/conversation/use-conversation-attention.d.ts +64 -0
- package/_internal/app/components/conversation/use-conversation-thread.d.ts +55 -0
- package/_internal/app/components/conversation/user-message.d.ts +11 -0
- package/_internal/app/components/danger-zone.d.ts +28 -0
- package/_internal/app/components/empty-state.d.ts +18 -6
- package/_internal/app/components/plugin-header.d.ts +4 -3
- package/_internal/app/components/save-bar.d.ts +32 -0
- package/_internal/app/components/score-overlay.d.ts +33 -0
- package/_internal/app/components/search-degraded-chip.d.ts +4 -0
- package/_internal/app/components/search-partial-chip.d.ts +13 -0
- package/_internal/app/components/search-unavailable.d.ts +12 -0
- package/_internal/app/components/section-card.d.ts +22 -0
- package/_internal/app/components/segmented-control.d.ts +28 -0
- package/_internal/app/components/stat-tile.d.ts +26 -0
- package/_internal/app/components/status-badge.d.ts +19 -0
- package/_internal/app/components/turn-output-view.d.ts +57 -0
- package/_internal/app/components/ui/badge.d.ts +1 -1
- package/_internal/app/components/ui/button.d.ts +1 -1
- package/_internal/app/components/underline-tabs.d.ts +6 -2
- package/_internal/app/components/unsaved-changes-guard.d.ts +34 -0
- package/_internal/app/core/conversation-turns.d.ts +148 -0
- package/_internal/app/core/logger.d.ts +1 -0
- package/_internal/app/hooks/use-available-models.d.ts +5 -0
- package/_internal/app/hooks/use-content-store.d.ts +0 -9
- package/_internal/app/hooks/use-file-drop.d.ts +25 -0
- package/_internal/app/hooks/use-history-back.d.ts +1 -0
- package/_internal/app/hooks/use-horizontal-resize.d.ts +22 -0
- package/_internal/app/hooks/use-json-fetch.d.ts +26 -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-query-state.d.ts +2 -0
- package/_internal/app/hooks/use-resizable-pane.d.ts +35 -0
- package/_internal/app/hooks/use-schedule.d.ts +47 -1
- package/_internal/app/hooks/use-search.d.ts +27 -8
- package/_internal/app/hooks/use-task-run-history.d.ts +26 -0
- package/_internal/app/hooks/use-toast.d.ts +3 -3
- package/_internal/app/hooks/use-vertical-resize.d.ts +6 -7
- package/_internal/app/lib/browser-notify.d.ts +12 -1
- package/_internal/app/types/index.d.ts +1 -105
- package/_internal/core/adapters/runtime/concepts.d.ts +671 -99
- package/_internal/core/adapters/runtime/errors.d.ts +98 -0
- package/_internal/core/adapters/runtime/helpers.d.ts +19 -0
- package/_internal/core/adapters/runtime/index.d.ts +7 -2
- package/_internal/core/adapters/runtime/testing.d.ts +79 -0
- package/_internal/core/adapters/runtime/turn-activity.d.ts +23 -0
- package/_internal/core/adapters/shared.d.ts +122 -12
- package/_internal/core/content-dir.d.ts +9 -0
- package/_internal/core/docs/route.d.ts +1 -1
- package/_internal/core/format/structured.d.ts +44 -0
- package/_internal/core/format.d.ts +13 -0
- package/_internal/core/media/downscale.d.ts +18 -0
- package/_internal/core/media/sharp-loader.d.ts +36 -0
- package/_internal/core/plugin-types.d.ts +216 -499
- package/_internal/core/routing/define.d.ts +26 -3
- package/_internal/core/routing/dispatcher.d.ts +15 -6
- package/_internal/core/routing/index.d.ts +1 -1
- package/_internal/core/routing/types.d.ts +13 -70
- package/_internal/core/storage/atomic-write.d.ts +11 -0
- package/_internal/core/tasks/store.d.ts +129 -0
- package/_internal/core/tasks/testing.d.ts +2 -0
- package/_internal/{plugins/workflows/lib → core/workflows}/notification-channel-registry.d.ts +1 -1
- package/_internal/plugins/team/types.d.ts +61 -4
- package/_internal/plugins/workflows/hooks/use-notification-channels.d.ts +1 -1
- package/components/index.d.ts +111 -5
- package/components/index.js +61815 -30060
- package/hooks/index.d.ts +90 -9
- package/hooks/index.js +15181 -685
- package/hooks/router.d.ts +20 -4
- package/index.d.ts +20 -3
- package/index.js +297 -259
- package/internal/index.d.ts +70 -0
- package/internal/index.js +409 -0
- package/metadata/index.d.ts +14 -1
- package/package.json +9 -2
- package/register.d.ts +63 -9
- package/routing/index.d.ts +6 -1
- package/routing/index.js +187 -147
- package/slots/index.d.ts +16 -24
- package/slots/index.js +215 -30
- package/testing/index.d.ts +122 -0
- package/testing/index.js +21874 -0
- package/types/index.d.ts +19 -919
- package/types/index.js +16 -0
- package/ui/index.js +2 -1
- package/utils/index.d.ts +46 -6
- package/utils/index.js +322 -249
- package/_internal/app/components/integrated-brainstorm/activity.d.ts +0 -23
- package/_internal/app/components/integrated-brainstorm/collapsed-header.d.ts +0 -14
- package/_internal/app/components/integrated-brainstorm/empty-state.d.ts +0 -5
- package/_internal/app/components/integrated-brainstorm/index.d.ts +0 -8
- package/_internal/app/components/integrated-brainstorm/input-row.d.ts +0 -16
- package/_internal/app/components/integrated-brainstorm/message-list.d.ts +0 -8
- package/_internal/app/components/integrated-brainstorm/session.d.ts +0 -16
- package/_internal/app/components/integrated-brainstorm/sse.d.ts +0 -8
- package/_internal/app/components/integrated-brainstorm/thinking-indicator.d.ts +0 -19
- package/_internal/app/components/integrated-brainstorm/types.d.ts +0 -63
- package/_internal/app/components/integrated-brainstorm/use-auto-grow.d.ts +0 -6
- package/_internal/app/components/integrated-brainstorm/use-brainstorm-state.d.ts +0 -21
- package/_internal/app/hooks/use-assets.d.ts +0 -25
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AdapterInitOpts, MessageUsage, RuntimeExecToolProvider, Unsubscribe } from '../shared';
|
|
2
|
+
import type { ActivityClass } from '@makinbakin/sdk/types';
|
|
2
3
|
import type { ChannelCapability } from './capabilities';
|
|
4
|
+
export type { MessageUsage } from '../shared';
|
|
3
5
|
export type RuntimeMetadata = Record<string, unknown>;
|
|
4
6
|
export interface RuntimeAgent {
|
|
5
7
|
id: string;
|
|
6
8
|
name: string;
|
|
7
9
|
role?: string;
|
|
8
10
|
model?: string;
|
|
11
|
+
/** Model this agent's spawned subagents use (runtimes with a subagent concept). */
|
|
12
|
+
subagentModel?: string;
|
|
9
13
|
status?: 'active' | 'inactive' | 'unknown';
|
|
10
14
|
metadata?: RuntimeMetadata;
|
|
11
15
|
}
|
|
@@ -19,14 +23,12 @@ export interface CreateRuntimeAgentInput {
|
|
|
19
23
|
export interface UpdateRuntimeAgentInput {
|
|
20
24
|
name?: string;
|
|
21
25
|
role?: string;
|
|
22
|
-
|
|
26
|
+
/** `null` clears the assignment (agent falls back to the routing default). */
|
|
27
|
+
model?: string | null;
|
|
28
|
+
/** `null` clears. Reject via routingSupport().perAgentSubagentModel=false runtimes. */
|
|
29
|
+
subagentModel?: string | null;
|
|
23
30
|
metadata?: RuntimeMetadata;
|
|
24
31
|
}
|
|
25
|
-
export interface RuntimePermissionPatch {
|
|
26
|
-
allow?: string[];
|
|
27
|
-
deny?: string[];
|
|
28
|
-
replace?: boolean;
|
|
29
|
-
}
|
|
30
32
|
export interface RuntimeAllowlistPatch {
|
|
31
33
|
add?: string[];
|
|
32
34
|
remove?: string[];
|
|
@@ -38,31 +40,132 @@ export interface WorkspaceFile {
|
|
|
38
40
|
updatedAt?: string;
|
|
39
41
|
metadata?: RuntimeMetadata;
|
|
40
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Size stats for one file the runtime loads at session start. Names + sizes
|
|
45
|
+
* only — content never crosses the adapter boundary (#357). `kind` is
|
|
46
|
+
* classified by the adapter so callers never re-derive runtime-private
|
|
47
|
+
* file conventions.
|
|
48
|
+
*/
|
|
49
|
+
export interface WorkspaceFileStat {
|
|
50
|
+
/** Path relative to the agent's workspace root (e.g. 'AGENTS.md', 'skills/foo/SKILL.md'). */
|
|
51
|
+
name: string;
|
|
52
|
+
bytes: number;
|
|
53
|
+
mtimeMs: number;
|
|
54
|
+
kind: 'canonical' | 'skill' | 'memory';
|
|
55
|
+
}
|
|
41
56
|
export type RuntimeMessageToolsMode = 'auto' | 'none';
|
|
42
57
|
export interface RuntimeMessageToolPolicy {
|
|
43
58
|
/**
|
|
44
59
|
* Controls whether runtime-native tools are available for this agent turn.
|
|
45
60
|
* `none` disables tools. Omit or use `auto` for runtime/provider defaults.
|
|
61
|
+
* Native tool policy beyond on/off is ADAPTER-PRIVATE — callers never name
|
|
62
|
+
* native tools.
|
|
46
63
|
*/
|
|
47
64
|
toolsMode?: RuntimeMessageToolsMode;
|
|
48
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* Per-turn allowlist of BAKIN EXEC TOOLS by exact name (e.g.
|
|
67
|
+
* `bakin_exec_tasks_get`). Scope is the exec-tool set ONLY — never
|
|
68
|
+
* runtime-native tools (audit M3: OpenClaw once forwarded these as native
|
|
69
|
+
* policy while Pi filtered exec tools, so `toolsAllow: ['read']` meant two
|
|
70
|
+
* different things). Enforcement is mechanism-dependent: in-process
|
|
71
|
+
* runtimes filter the tool bridge per turn; runtimes whose exec tools ride
|
|
72
|
+
* session-static transports (OpenClaw's per-agent MCP servers) cannot
|
|
73
|
+
* filter per-turn and must IGNORE the fields with a loud warning — never
|
|
74
|
+
* misapply them to native tools.
|
|
75
|
+
*/
|
|
49
76
|
toolsAllow?: string[];
|
|
50
|
-
/**
|
|
77
|
+
/** Per-turn denylist of Bakin exec tools by exact name (same scope/enforcement as `toolsAllow`). */
|
|
51
78
|
toolsDeny?: string[];
|
|
52
79
|
}
|
|
80
|
+
/** Local file offered to the runtime as model input for one turn. */
|
|
81
|
+
export interface MessageAttachment {
|
|
82
|
+
path: string;
|
|
83
|
+
mimeType: string;
|
|
84
|
+
}
|
|
53
85
|
export interface MessageArgs extends RuntimeMessageToolPolicy {
|
|
54
86
|
agentId: string;
|
|
55
87
|
content: string;
|
|
88
|
+
/** Producer-assigned usage class; omitted interactive turns default to user. */
|
|
89
|
+
activityClass?: ActivityClass;
|
|
90
|
+
/**
|
|
91
|
+
* Image attachments for the turn (runtime support is declared by
|
|
92
|
+
* `capabilities().imageInput`; adapters reject unsupported media loudly
|
|
93
|
+
* rather than silently dropping pixels).
|
|
94
|
+
*/
|
|
95
|
+
attachments?: MessageAttachment[];
|
|
96
|
+
/**
|
|
97
|
+
* Utility turn: ask the runtime to suppress visible session side effects
|
|
98
|
+
* (control-UI visibility, prompt persistence) where it supports them.
|
|
99
|
+
* The thread still exists for idempotency; it just stays out of the way.
|
|
100
|
+
*/
|
|
101
|
+
ephemeral?: boolean;
|
|
56
102
|
/**
|
|
57
103
|
* Adapter-neutral durable conversation key. Runtime adapters should map the
|
|
58
104
|
* same agentId + threadId pair to the same provider/runtime session.
|
|
59
105
|
*/
|
|
60
106
|
threadId?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Absolute path of a per-run working directory for this turn. Set ONLY by
|
|
109
|
+
* dispatch, only for runtimes declaring `concurrency.sameAgentTurns:
|
|
110
|
+
* 'isolated'` — core allocates the dir (under Bakin territory, never the
|
|
111
|
+
* runtime's home) and the adapter uses it as the session cwd, seeding its
|
|
112
|
+
* own context conventions (project context, skills, memory write paths) so
|
|
113
|
+
* the isolated turn loses nothing. Chat and ephemeral/system sends never
|
|
114
|
+
* carry it: the agent's shared workspace stays their cwd. Adapters that
|
|
115
|
+
* declare 'serialized' never receive the field.
|
|
116
|
+
*/
|
|
117
|
+
runWorkspace?: string;
|
|
118
|
+
/**
|
|
119
|
+
* Per-turn model override (`provider/model` id). Omit to use the agent's
|
|
120
|
+
* configured model. The caller (Bakin's routing policy) resolves it.
|
|
121
|
+
*/
|
|
122
|
+
model?: string;
|
|
123
|
+
/**
|
|
124
|
+
* Per-turn thinking level. Omit to use the runtime/agent default.
|
|
125
|
+
*/
|
|
126
|
+
thinking?: string;
|
|
127
|
+
/**
|
|
128
|
+
* Best-effort turn cancellation. On abort, adapters MUST reject the send
|
|
129
|
+
* promptly with RuntimeError kind 'aborted' and SHOULD cancel the
|
|
130
|
+
* provider-side run where the runtime supports it (fail-open: a provider
|
|
131
|
+
* that can't cancel still gets the local rejection).
|
|
132
|
+
*/
|
|
133
|
+
signal?: AbortSignal;
|
|
134
|
+
/**
|
|
135
|
+
* Best-effort live-activity tap for a `send()` turn (prelaunch-hardening
|
|
136
|
+
* R7/D-plan-1): invoked with `tool` and `status` chunks as the runtime
|
|
137
|
+
* surfaces them — text deltas do NOT flow here (use `messaging.stream`
|
|
138
|
+
* to render prose live). No delivery guarantee, no chunk is required to
|
|
139
|
+
* appear, and no ordering guarantee relative to the send() settle (a
|
|
140
|
+
* late-arriving frame may tap after the promise resolves). Adapters
|
|
141
|
+
* contain callback exceptions — a throwing tap never fails the turn.
|
|
142
|
+
* Ignored by `messaging.stream`, whose iterator already carries chunks.
|
|
143
|
+
*/
|
|
144
|
+
onActivity?: (chunk: ChatChunk) => void;
|
|
145
|
+
/**
|
|
146
|
+
* Byte threshold above which a died turn's completion counts as
|
|
147
|
+
* "oversized output" in its RuntimeTurnDiagnosis (the recovery ladder
|
|
148
|
+
* treats runaway-output deaths differently from ordinary interrupts).
|
|
149
|
+
* Dispatch passes `settings.dispatch.oversizedOutputBytes`; adapters fall
|
|
150
|
+
* back to their own default (128 KiB) when omitted. Typed here — NOT a
|
|
151
|
+
* metadata-bag key (audit M4: core policy must never ride the opaque bag).
|
|
152
|
+
*/
|
|
153
|
+
oversizedOutputBytes?: number;
|
|
61
154
|
metadata?: RuntimeMetadata;
|
|
62
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* Fallback for `MessageArgs.oversizedOutputBytes` when the caller omits it —
|
|
158
|
+
* THE single source both adapters and `settings.dispatch.oversizedOutputBytes`
|
|
159
|
+
* default from (previously duplicated per adapter; parity by reference, not
|
|
160
|
+
* by copy). Both adapters measure the same thing: UTF-8 bytes of the turn's
|
|
161
|
+
* assistant output text, strict `>`.
|
|
162
|
+
*/
|
|
163
|
+
export declare const DEFAULT_OVERSIZED_OUTPUT_BYTES: number;
|
|
63
164
|
export interface MessageResult {
|
|
64
165
|
id: string;
|
|
65
166
|
content?: string;
|
|
167
|
+
/** Per-turn token usage, omitted when the runtime reported none. */
|
|
168
|
+
usage?: MessageUsage;
|
|
66
169
|
metadata?: RuntimeMetadata;
|
|
67
170
|
}
|
|
68
171
|
export interface RuntimeToolActivity {
|
|
@@ -77,24 +180,69 @@ export interface RuntimeToolActivity {
|
|
|
77
180
|
exitCode?: number;
|
|
78
181
|
metadata?: RuntimeMetadata;
|
|
79
182
|
}
|
|
80
|
-
|
|
81
|
-
|
|
183
|
+
/** Render format for a text chunk's content. Absent means 'markdown'. */
|
|
184
|
+
export type ChatTextFormat = 'markdown' | 'plain' | 'code';
|
|
185
|
+
/**
|
|
186
|
+
* One chunk of a streaming agent turn — the turn-output normalization
|
|
187
|
+
* contract every adapter emits and every consumer renders against.
|
|
188
|
+
*
|
|
189
|
+
* Behavioral contract (pinned today by the per-adapter suites —
|
|
190
|
+
* tests/adapter-openclaw/stream-events.test.ts and
|
|
191
|
+
* tests/integration/pi/turn.test.ts; the cross-adapter conformance suite
|
|
192
|
+
* lands with prelaunch-hardening PR 3):
|
|
193
|
+
* - Chunk GRANULARITY may vary by adapter: per-token deltas, coalesced
|
|
194
|
+
* spans, or one chunk per turn are all legal. Consumers accumulate
|
|
195
|
+
* `text` content in arrival order and must not assume a cadence.
|
|
196
|
+
* - `done` is yielded EXACTLY ONCE, always last; no chunk of any kind
|
|
197
|
+
* follows it.
|
|
198
|
+
* - A DELIBERATE abort (the turn's `kind:'aborted'` settle) ends the
|
|
199
|
+
* stream with a clean `done` — never an `error` chunk. Abort is a
|
|
200
|
+
* clean end, not a failure.
|
|
201
|
+
* - `tool` and `status` chunks are BEST-EFFORT liveness: adapters emit
|
|
202
|
+
* what their runtime exposes, and none is guaranteed to appear.
|
|
203
|
+
* - Terminal failure ends the stream with an `error` chunk (its `data`
|
|
204
|
+
* carries `{ kind }` — the RuntimeError kind — when known) and NO
|
|
205
|
+
* `done`; the iterator itself never throws.
|
|
206
|
+
* - Adapters emit CLASSIFIED, STRUCTURED chunks only — never
|
|
207
|
+
* pre-rendered HTML/ANSI or raw JSON/shell dumps in `content`.
|
|
208
|
+
* Stripping runtime-specific noise is the adapter's job.
|
|
209
|
+
*/
|
|
210
|
+
export type ChatChunk =
|
|
211
|
+
/** Assistant text. `format` hints rendering; absent = markdown. */
|
|
212
|
+
{
|
|
213
|
+
type: 'text';
|
|
214
|
+
content: string;
|
|
215
|
+
format?: ChatTextFormat;
|
|
216
|
+
data?: RuntimeMetadata;
|
|
217
|
+
}
|
|
218
|
+
/** Tool activity; `data` is always the structured RuntimeToolActivity. */
|
|
219
|
+
| {
|
|
220
|
+
type: 'tool';
|
|
82
221
|
content?: string;
|
|
83
|
-
data
|
|
222
|
+
data: RuntimeToolActivity;
|
|
84
223
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
224
|
+
/** Turn lifecycle hint (e.g. 'thinking'). */
|
|
225
|
+
| {
|
|
226
|
+
type: 'status';
|
|
227
|
+
content?: string;
|
|
228
|
+
data?: RuntimeMetadata;
|
|
89
229
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
230
|
+
/** Clean turn end (success or deliberate abort) — exactly once, always last.
|
|
231
|
+
* `usage` carries the turn's token accounting when the runtime reports it —
|
|
232
|
+
* parity with `send()`: a runtime whose send results carry usage must
|
|
233
|
+
* attach it here too (conformance-pinned), so streamed turns are meterable. */
|
|
234
|
+
| {
|
|
235
|
+
type: 'done';
|
|
236
|
+
content?: string;
|
|
237
|
+
data?: RuntimeMetadata;
|
|
238
|
+
usage?: MessageUsage;
|
|
97
239
|
}
|
|
240
|
+
/** Terminal failure — `data.kind` carries the RuntimeError kind when known. */
|
|
241
|
+
| {
|
|
242
|
+
type: 'error';
|
|
243
|
+
content?: string;
|
|
244
|
+
data?: RuntimeMetadata;
|
|
245
|
+
};
|
|
98
246
|
export interface ChannelInfo {
|
|
99
247
|
id: string;
|
|
100
248
|
platform: string;
|
|
@@ -145,6 +293,28 @@ export interface ContentDeliveryArgs {
|
|
|
145
293
|
metadata?: RuntimeMetadata;
|
|
146
294
|
};
|
|
147
295
|
}
|
|
296
|
+
export interface CreateThreadArgs {
|
|
297
|
+
/** Channel ref the anchor message lives in (provider or provider:target). */
|
|
298
|
+
channel: string;
|
|
299
|
+
/** Delivery ref of the message to anchor the thread to (e.g. "message:<id>"). */
|
|
300
|
+
messageRef?: string;
|
|
301
|
+
name: string;
|
|
302
|
+
}
|
|
303
|
+
export interface CreatedThread {
|
|
304
|
+
threadId: string;
|
|
305
|
+
/**
|
|
306
|
+
* Provider-addressable channel ref for posting INTO the thread (opaque to
|
|
307
|
+
* callers — provider target syntax stays inside the adapter).
|
|
308
|
+
*/
|
|
309
|
+
channelRef: string;
|
|
310
|
+
}
|
|
311
|
+
export interface EditChannelMessageArgs {
|
|
312
|
+
/** Channel ref the message lives in (provider or provider:target). */
|
|
313
|
+
channel: string;
|
|
314
|
+
/** Delivery ref of the message to edit (e.g. "message:<id>"). */
|
|
315
|
+
messageRef: string;
|
|
316
|
+
body: string;
|
|
317
|
+
}
|
|
148
318
|
export interface ApprovalOption {
|
|
149
319
|
id: string;
|
|
150
320
|
label: string;
|
|
@@ -203,31 +373,6 @@ export interface ApprovalResolveEvent {
|
|
|
203
373
|
response: ApprovalResponse;
|
|
204
374
|
channelId: string;
|
|
205
375
|
}
|
|
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
376
|
export interface DurableApprovalRecord {
|
|
232
377
|
approvalId: string;
|
|
233
378
|
owner: {
|
|
@@ -259,6 +404,25 @@ export interface RuntimeSession {
|
|
|
259
404
|
updatedAt?: string;
|
|
260
405
|
metadata?: RuntimeMetadata;
|
|
261
406
|
}
|
|
407
|
+
export interface RuntimeSessionStoreStats {
|
|
408
|
+
agentId: string;
|
|
409
|
+
/** Live entries in the runtime's session store for this agent. */
|
|
410
|
+
storeEntries: number;
|
|
411
|
+
/**
|
|
412
|
+
* Top-level files in the agent's sessions directory (session artifacts,
|
|
413
|
+
* including the store itself) — cache subtrees are excluded so the
|
|
414
|
+
* orphaned-artifact ratio stays meaningful.
|
|
415
|
+
*/
|
|
416
|
+
fileCount: number;
|
|
417
|
+
/** Total bytes of the agent's sessions directory, subtrees included. */
|
|
418
|
+
diskBytes: number;
|
|
419
|
+
/**
|
|
420
|
+
* Adapter-owned operator guidance for shrinking this agent's store (CLI
|
|
421
|
+
* commands, config knobs). Health surfaces render it verbatim — provider
|
|
422
|
+
* specifics belong HERE, never hardcoded upstream of the adapter.
|
|
423
|
+
*/
|
|
424
|
+
remediation?: string;
|
|
425
|
+
}
|
|
262
426
|
export interface RuntimeMemoryTier {
|
|
263
427
|
id: string;
|
|
264
428
|
label: string;
|
|
@@ -298,6 +462,177 @@ export interface RuntimeMemorySearchResult {
|
|
|
298
462
|
results: unknown[];
|
|
299
463
|
metadata?: RuntimeMetadata;
|
|
300
464
|
}
|
|
465
|
+
/**
|
|
466
|
+
* What the runtime's ACTIVE configuration can accept as model input
|
|
467
|
+
* (spec: enrichment-runtime-fallback §3). Adapter-declared from the
|
|
468
|
+
* runtime's own model catalog for the SELECTED agent's effective model
|
|
469
|
+
* (default: the main agent) — conservative false on any ambiguity, never
|
|
470
|
+
* model-name heuristics.
|
|
471
|
+
*/
|
|
472
|
+
export interface RuntimeCapabilities {
|
|
473
|
+
imageInput: boolean;
|
|
474
|
+
audioInput: boolean;
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* One capability's provisioning state on a runtime:
|
|
478
|
+
* - 'native' — the runtime provides it directly.
|
|
479
|
+
* - 'shimmed' — the runtime doesn't, but a Bakin-owned shim fills it.
|
|
480
|
+
* - 'unavailable' — neither; degrade honestly + surface in the UI.
|
|
481
|
+
*/
|
|
482
|
+
export type CapabilityMode = 'native' | 'shimmed' | 'unavailable';
|
|
483
|
+
/**
|
|
484
|
+
* How agents on this runtime invoke Bakin exec tools:
|
|
485
|
+
* - 'in-process' — exec tools are first-class session tools; the agent calls
|
|
486
|
+
* `bakin_exec_*` directly (Pi's in-process bridge).
|
|
487
|
+
* - 'mcp' — the runtime's native MCP client reaches Bakin's MCP server;
|
|
488
|
+
* tools appear namespaced as `<mcpServerTemplate>.<tool>`.
|
|
489
|
+
* - 'cli-shim' — the agent shells `<shimCommand>` (inert extension point for
|
|
490
|
+
* a future runtime that can neither embed nor speak MCP).
|
|
491
|
+
*/
|
|
492
|
+
export type ToolAccessStyle = 'in-process' | 'mcp' | 'cli-shim';
|
|
493
|
+
export interface RuntimeToolAccess {
|
|
494
|
+
style: ToolAccessStyle;
|
|
495
|
+
/** 'mcp': per-agent server-name template, e.g. `bakin-<agent>`. */
|
|
496
|
+
mcpServerTemplate?: string;
|
|
497
|
+
/** 'cli-shim': shell command template. */
|
|
498
|
+
shimCommand?: string;
|
|
499
|
+
/** One canonical, style-appropriate example call. */
|
|
500
|
+
example?: string;
|
|
501
|
+
/**
|
|
502
|
+
* Whether this runtime can ENFORCE `MessageArgs.toolsAllow`/`toolsDeny`
|
|
503
|
+
* per turn. In-process runtimes filter their tool bridge per call (true);
|
|
504
|
+
* runtimes whose exec tools ride session-static transports (OpenClaw's
|
|
505
|
+
* per-agent MCP servers) cannot (false) — they ignore the fields with a
|
|
506
|
+
* loud warning. Callers needing a RESTRICTED turn must feature-detect
|
|
507
|
+
* this and refuse rather than degrade fail-open.
|
|
508
|
+
*/
|
|
509
|
+
perTurnExecToolFiltering?: boolean;
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Result of `verifyToolAccess()` — a runtime-neutral report on whether this
|
|
513
|
+
* runtime's tool-access wiring is currently in place, so core (onboarding,
|
|
514
|
+
* doctor) can surface drift WITHOUT knowing any provider's config shape.
|
|
515
|
+
* `in-process` runtimes report `ok: true` with no issues (nothing to
|
|
516
|
+
* provision); `mcp` runtimes report missing/stale server entries.
|
|
517
|
+
*/
|
|
518
|
+
export interface ToolAccessProvisioningStatus {
|
|
519
|
+
style: ToolAccessStyle;
|
|
520
|
+
ok: boolean;
|
|
521
|
+
/** Human-readable drift descriptions when `ok` is false. */
|
|
522
|
+
issues: string[];
|
|
523
|
+
details?: Record<string, unknown>;
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* The unified capability declaration — every runtime-provided capability that
|
|
527
|
+
* has a native/shim/gap choice. Bakin renders agent instructions from it,
|
|
528
|
+
* routes to shims when `shimmed`, degrades honestly when `unavailable`, and
|
|
529
|
+
* plugins query it instead of assuming. Always-Bakin-owned capabilities
|
|
530
|
+
* (scheduling, heartbeats, tasks, assets, audit) are NOT here — they have no
|
|
531
|
+
* native/shim choice. `input` folds in the former modality-only capabilities.
|
|
532
|
+
*/
|
|
533
|
+
export interface CapabilitySet {
|
|
534
|
+
toolCalling: {
|
|
535
|
+
mode: 'native';
|
|
536
|
+
access: RuntimeToolAccess;
|
|
537
|
+
};
|
|
538
|
+
delivery: {
|
|
539
|
+
mode: CapabilityMode;
|
|
540
|
+
};
|
|
541
|
+
imageGen: {
|
|
542
|
+
mode: CapabilityMode;
|
|
543
|
+
};
|
|
544
|
+
memory: {
|
|
545
|
+
mode: 'native' | 'unavailable';
|
|
546
|
+
};
|
|
547
|
+
sessions: {
|
|
548
|
+
mode: 'native' | 'unavailable';
|
|
549
|
+
};
|
|
550
|
+
workspaceFiles: {
|
|
551
|
+
mode: 'native' | 'unavailable';
|
|
552
|
+
};
|
|
553
|
+
input: RuntimeCapabilities;
|
|
554
|
+
/**
|
|
555
|
+
* Can two turns for ONE agent run simultaneously without colliding?
|
|
556
|
+
* - 'isolated' — the adapter honors `MessageArgs.runWorkspace` (per-turn
|
|
557
|
+
* cwd), so concurrent same-agent turns each work in their
|
|
558
|
+
* own directory; parallel-safe.
|
|
559
|
+
* - 'serialized' — the adapter/provider cannot isolate runs (one shared
|
|
560
|
+
* workspace per agent); dispatch clamps that agent to one
|
|
561
|
+
* turn at a time regardless of settings, with a visible
|
|
562
|
+
* receipt — never a silent drop.
|
|
563
|
+
* Conformance-pinned: declaring 'isolated' without actually honoring
|
|
564
|
+
* runWorkspace fails the runtime conformance suite.
|
|
565
|
+
*/
|
|
566
|
+
concurrency: {
|
|
567
|
+
sameAgentTurns: 'isolated' | 'serialized';
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Presence-only credential report (P2.2): WHICH LLM providers and channels
|
|
572
|
+
* have usable credentials configured in the runtime — names only, NEVER
|
|
573
|
+
* secret material. Drives the onboarding llm/channels checks; each adapter
|
|
574
|
+
* reads its own config internally so credential shapes never leak upstream.
|
|
575
|
+
*/
|
|
576
|
+
/**
|
|
577
|
+
* Presence-only credential KIND: 'api-key' = metered pay-per-use billing;
|
|
578
|
+
* 'oauth' = subscription login (plan quota). An entry carrying both reports
|
|
579
|
+
* 'api-key' — the key is what the provider bills. Never carries values.
|
|
580
|
+
*/
|
|
581
|
+
export type RuntimeCredentialKind = 'api-key' | 'oauth';
|
|
582
|
+
export interface RuntimeCredentialStatus {
|
|
583
|
+
/** Provider names with usable credentials (api key / token / OAuth). */
|
|
584
|
+
llmProviders: string[];
|
|
585
|
+
/**
|
|
586
|
+
* Per-provider credential kind (billing-lane detection, cost-control v2).
|
|
587
|
+
* Optional — consumers treat absence as unknown and stay conservative
|
|
588
|
+
* (unknown bills as metered, never silently uncapped-as-free).
|
|
589
|
+
*/
|
|
590
|
+
llmCredentials?: Array<{
|
|
591
|
+
provider: string;
|
|
592
|
+
kind: RuntimeCredentialKind;
|
|
593
|
+
}>;
|
|
594
|
+
/** Channel names with usable credentials. Empty on channel-less runtimes. */
|
|
595
|
+
channels: string[];
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Runtime-owned model routing policy (P2.3): the knobs the RUNTIME honors at
|
|
599
|
+
* session time — default model for agents without an assignment, failover
|
|
600
|
+
* order, subagent default, alias map. Bakin manages these through this
|
|
601
|
+
* neutral surface; each adapter maps to its native store, so a runtime's
|
|
602
|
+
* policy survives untouched while another runtime is active (round-trip by
|
|
603
|
+
* construction).
|
|
604
|
+
*/
|
|
605
|
+
export interface RuntimeRoutingPolicy {
|
|
606
|
+
/** Default model for agents without an explicit assignment. '' when unset. */
|
|
607
|
+
defaultModel: string;
|
|
608
|
+
/** Failover models tried in order when the default fails. */
|
|
609
|
+
fallbackModels: string[];
|
|
610
|
+
/** Default model for spawned subagents. Null when unset/unsupported. */
|
|
611
|
+
defaultSubagentModel: string | null;
|
|
612
|
+
/** Alias name → target model id. */
|
|
613
|
+
aliases: Record<string, string>;
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Which routing-policy fields this runtime actually HONORS. Static
|
|
617
|
+
* declaration (like describeToolAccess): UIs hide unsupported controls and
|
|
618
|
+
* `setRoutingPolicy` rejects patches carrying unsupported fields — a knob
|
|
619
|
+
* the runtime ignores must never be silently stored.
|
|
620
|
+
*/
|
|
621
|
+
export interface RuntimeRoutingSupport {
|
|
622
|
+
defaultModel: boolean;
|
|
623
|
+
fallbackModels: boolean;
|
|
624
|
+
defaultSubagentModel: boolean;
|
|
625
|
+
aliases: boolean;
|
|
626
|
+
/** Per-agent subagentModel via agents.update. */
|
|
627
|
+
perAgentSubagentModel: boolean;
|
|
628
|
+
/**
|
|
629
|
+
* Per-turn thinking levels this runtime HONORS on messaging.send. Bakin's
|
|
630
|
+
* routing layer clamps requested levels to this set (with receipt + audit
|
|
631
|
+
* evidence) before the send — an adapter must honor every level it
|
|
632
|
+
* declares and declare every level it honors (conformance-pinned).
|
|
633
|
+
*/
|
|
634
|
+
supportedThinkingLevels: readonly string[];
|
|
635
|
+
}
|
|
301
636
|
export interface RuntimeAvailableModel {
|
|
302
637
|
id: string;
|
|
303
638
|
name?: string;
|
|
@@ -308,38 +643,134 @@ export interface RuntimeAvailableModel {
|
|
|
308
643
|
tags?: string[];
|
|
309
644
|
metadata?: RuntimeMetadata;
|
|
310
645
|
}
|
|
311
|
-
export
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
646
|
+
export type RuntimeImageOutputFormat = 'png' | 'jpeg' | 'jpg' | 'webp';
|
|
647
|
+
export type RuntimeImageBackground = 'transparent' | 'opaque' | 'auto';
|
|
648
|
+
/**
|
|
649
|
+
* Image capability is intentionally all-optional. A thin runtime that exposes a
|
|
650
|
+
* single image tool maps on by filling minimal fields (e.g. one synthesized
|
|
651
|
+
* provider with a defaultModel); a rich runtime fills more. Consumers MUST
|
|
652
|
+
* treat a sparse capability as normal and never require a field a thin runtime
|
|
653
|
+
* cannot provide — gaps are filled below, in the adapter/shim, not pushed up
|
|
654
|
+
* into plugins. See .claude/knowledge/media-generation-adapter-architecture.md.
|
|
655
|
+
*/
|
|
656
|
+
export interface RuntimeImageProviderCapabilities {
|
|
657
|
+
generate?: {
|
|
658
|
+
maxCount?: number;
|
|
659
|
+
supportsSize?: boolean;
|
|
660
|
+
supportsAspectRatio?: boolean;
|
|
661
|
+
supportsResolution?: boolean;
|
|
662
|
+
};
|
|
663
|
+
edit?: {
|
|
664
|
+
enabled?: boolean;
|
|
665
|
+
maxCount?: number;
|
|
666
|
+
maxInputImages?: number;
|
|
667
|
+
supportsSize?: boolean;
|
|
668
|
+
supportsAspectRatio?: boolean;
|
|
669
|
+
supportsResolution?: boolean;
|
|
670
|
+
};
|
|
671
|
+
geometry?: {
|
|
672
|
+
sizes?: string[];
|
|
673
|
+
aspectRatios?: string[];
|
|
674
|
+
resolutions?: string[];
|
|
675
|
+
};
|
|
676
|
+
output?: {
|
|
677
|
+
formats?: string[];
|
|
678
|
+
qualities?: string[];
|
|
679
|
+
backgrounds?: string[];
|
|
680
|
+
};
|
|
681
|
+
metadata?: RuntimeMetadata;
|
|
682
|
+
}
|
|
683
|
+
export interface RuntimeImageProvider {
|
|
684
|
+
id: string;
|
|
685
|
+
label?: string;
|
|
686
|
+
defaultModel?: string;
|
|
687
|
+
models?: string[];
|
|
688
|
+
available?: boolean;
|
|
689
|
+
configured?: boolean;
|
|
690
|
+
selected?: boolean;
|
|
691
|
+
capabilities?: RuntimeImageProviderCapabilities;
|
|
316
692
|
metadata?: RuntimeMetadata;
|
|
317
693
|
}
|
|
318
|
-
export interface
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
694
|
+
export interface RuntimeImageGenerateInput {
|
|
695
|
+
prompt: string;
|
|
696
|
+
provider?: string;
|
|
697
|
+
model?: string;
|
|
698
|
+
count?: number;
|
|
699
|
+
width?: number;
|
|
700
|
+
height?: number;
|
|
701
|
+
size?: string;
|
|
702
|
+
aspectRatio?: string;
|
|
703
|
+
resolution?: string;
|
|
704
|
+
outputFormat?: RuntimeImageOutputFormat;
|
|
705
|
+
background?: RuntimeImageBackground;
|
|
706
|
+
/**
|
|
707
|
+
* Reference/context image file paths conditioning the generation. The caller
|
|
708
|
+
* (Bakin) resolves managed asset ids to concrete paths before the adapter
|
|
709
|
+
* sees them. Native generation has no file input, so a generate carrying
|
|
710
|
+
* references is routed through the edit-style invocation (#418).
|
|
711
|
+
*/
|
|
712
|
+
referenceImages?: string[];
|
|
713
|
+
timeoutMs?: number;
|
|
331
714
|
metadata?: RuntimeMetadata;
|
|
332
715
|
}
|
|
333
|
-
export interface
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
716
|
+
export interface RuntimeImageEditInput extends RuntimeImageGenerateInput {
|
|
717
|
+
files: string[];
|
|
718
|
+
}
|
|
719
|
+
export interface RuntimeImageFile {
|
|
720
|
+
filePath: string;
|
|
721
|
+
mimeType?: string;
|
|
722
|
+
width?: number;
|
|
723
|
+
height?: number;
|
|
724
|
+
provider?: string;
|
|
725
|
+
model?: string;
|
|
726
|
+
url?: string;
|
|
727
|
+
metadata?: RuntimeMetadata;
|
|
338
728
|
}
|
|
339
|
-
export interface
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
729
|
+
export interface RuntimeImageGenerationResult {
|
|
730
|
+
images: RuntimeImageFile[];
|
|
731
|
+
provider?: string;
|
|
732
|
+
model?: string;
|
|
733
|
+
providerText?: string;
|
|
734
|
+
metadata?: RuntimeMetadata;
|
|
735
|
+
}
|
|
736
|
+
export interface RuntimeImagesAccess {
|
|
737
|
+
providers(): Promise<RuntimeImageProvider[]>;
|
|
738
|
+
generate(input: RuntimeImageGenerateInput): Promise<RuntimeImageGenerationResult>;
|
|
739
|
+
edit(input: RuntimeImageEditInput): Promise<RuntimeImageGenerationResult>;
|
|
740
|
+
}
|
|
741
|
+
/**
|
|
742
|
+
* A runtime extension: third-party code the RUNTIME loads in-process during
|
|
743
|
+
* agent turns (Pi extensions today). Provider-neutral shape — ids/labels/
|
|
744
|
+
* paths only, never provider config. Discovery is INERT: listing never
|
|
745
|
+
* executes extension code.
|
|
746
|
+
*/
|
|
747
|
+
export interface RuntimeExtensionInfo {
|
|
748
|
+
/** Stable identifier used for allow/revoke — the real absolute module path. */
|
|
749
|
+
id: string;
|
|
750
|
+
label: string;
|
|
751
|
+
/** Where it came from, human-readable (e.g. "npm:some-pkg", "extensions dir"). */
|
|
752
|
+
source: string;
|
|
753
|
+
/** Real absolute load path (symlinks resolved) — half the trust identity. */
|
|
754
|
+
path: string;
|
|
755
|
+
/** Current content hash of the file — the other half of the trust identity. */
|
|
756
|
+
sha256: string;
|
|
757
|
+
/**
|
|
758
|
+
* pending — discovered but NOT loaded into turns (unapproved, or its
|
|
759
|
+
* content changed since approval)
|
|
760
|
+
* allowed — approved path+hash; loads into agent turns
|
|
761
|
+
* blocked — policy mode 'none': nothing loads
|
|
762
|
+
*/
|
|
763
|
+
status: 'allowed' | 'pending' | 'blocked';
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* OPTIONAL: trust management for runtime-loaded extensions. Runtimes without
|
|
767
|
+
* an extension mechanism OMIT the member; callers feature-detect
|
|
768
|
+
* (`runtime.extensions?.`). Listing is read-only and inert. The trust store
|
|
769
|
+
* itself (allowlist) is Bakin-owned settings — see
|
|
770
|
+
* `src/core/runtime-extensions.ts` for the ONE mutation engine.
|
|
771
|
+
*/
|
|
772
|
+
export interface RuntimeExtensionsAccess {
|
|
773
|
+
list(): Promise<RuntimeExtensionInfo[]>;
|
|
343
774
|
}
|
|
344
775
|
export interface CronJob {
|
|
345
776
|
id: string;
|
|
@@ -376,21 +807,48 @@ export interface RawCronSnapshot {
|
|
|
376
807
|
capturedAt: string;
|
|
377
808
|
snapshot: unknown;
|
|
378
809
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
810
|
+
/**
|
|
811
|
+
* URI scheme for runtime-private media references (`media://inbound/…`).
|
|
812
|
+
* The ONE place upstream code may learn the scheme: callers detect
|
|
813
|
+
* media references with this constant and hand them to `media.resolveUri`
|
|
814
|
+
* (feature-detected) — the adapter owns what the URI means.
|
|
815
|
+
*/
|
|
816
|
+
export declare const RUNTIME_MEDIA_URI_SCHEME = "media://";
|
|
385
817
|
export interface AgentRuntimeAdapter {
|
|
386
818
|
readonly name: string;
|
|
387
819
|
readonly version: string;
|
|
388
820
|
readonly requiredCoreVersion: string;
|
|
389
821
|
initialize(opts: AdapterInitOpts): Promise<void>;
|
|
390
822
|
shutdown(): Promise<void>;
|
|
823
|
+
/**
|
|
824
|
+
* "Can this runtime serve a turn?" — a CHEAP probe (an HTTP health hit, a
|
|
825
|
+
* credential-presence read; never an LLM call). Resolves `false` rather
|
|
826
|
+
* than throwing when the runtime cannot serve (unreachable process,
|
|
827
|
+
* uninitialized adapter, no LLM credentials). Deeper diagnostics are
|
|
828
|
+
* registered separately with the canonical Health registry.
|
|
829
|
+
*/
|
|
391
830
|
ping(): Promise<boolean>;
|
|
831
|
+
/**
|
|
832
|
+
* Re-read ALL durable config: credentials, model registry, settings,
|
|
833
|
+
* provisioned tool access. External-process runtimes may bounce the
|
|
834
|
+
* process; in-process runtimes must drop every cache so the next call
|
|
835
|
+
* re-reads disk. Callers (team/models plugins) invoke this after config
|
|
836
|
+
* writes and expect the next read to reflect them.
|
|
837
|
+
*/
|
|
392
838
|
restart(): Promise<void>;
|
|
393
|
-
|
|
839
|
+
/**
|
|
840
|
+
* CRUD error contract (R28): `get` returns `null` for a missing agent —
|
|
841
|
+
* absence is a value, never a throw. Mutations addressing a MISSING agent
|
|
842
|
+
* (`update`, `updateAllowlist`, `remove`) reject with a typed
|
|
843
|
+
* `RuntimeError` kind `'not_found'`. Workspace-file writes are exempt BY
|
|
844
|
+
* DESIGN: they provision the workspace directory on demand (creating an
|
|
845
|
+
* agent's first file is a legitimate provisioning step, not an error).
|
|
846
|
+
* Provider/runtime failures on these surfaces are typed `RuntimeError`s
|
|
847
|
+
* (adapters map them in their own errors module — core never classifies
|
|
848
|
+
* on message text); caller-INPUT validation (invalid names/paths,
|
|
849
|
+
* unsupported options) may throw plain `Error`s — those signal programmer
|
|
850
|
+
* error before any runtime interaction, not runtime state.
|
|
851
|
+
*/
|
|
394
852
|
agents: {
|
|
395
853
|
list(): Promise<RuntimeAgent[]>;
|
|
396
854
|
get(agentId: string): Promise<RuntimeAgent | null>;
|
|
@@ -401,19 +859,44 @@ export interface AgentRuntimeAdapter {
|
|
|
401
859
|
readWorkspaceFile(agentId: string, path: string): Promise<WorkspaceFile | null>;
|
|
402
860
|
writeWorkspaceFile(agentId: string, file: WorkspaceFile): Promise<void>;
|
|
403
861
|
removeWorkspaceFile(agentId: string, path: string): Promise<void>;
|
|
404
|
-
|
|
862
|
+
/**
|
|
863
|
+
* Read-only size stats for the files the runtime loads at session start
|
|
864
|
+
* (canonical bootstrap files, skills, memory notes). Null when the agent
|
|
865
|
+
* has no workspace. Optional: runtimes without a file-backed workspace
|
|
866
|
+
* omit it, and callers must treat absence as "stats unavailable" —
|
|
867
|
+
* skip, never error.
|
|
868
|
+
*/
|
|
869
|
+
workspaceFileStats?(agentId: string): Promise<WorkspaceFileStat[] | null>;
|
|
870
|
+
/**
|
|
871
|
+
* The SUBAGENT-DISPATCH allowlist: the patch strings are AGENT IDS this
|
|
872
|
+
* agent may dispatch subtasks to (P5.3 live incident: these were once fed
|
|
873
|
+
* into an exec-tool name filter — they are never tool names). OpenClaw
|
|
874
|
+
* writes `agents.list[].subagents.allowAgents` in its config; Pi stores
|
|
875
|
+
* the registry record's `allowlist`, consumed by its tool bridge when
|
|
876
|
+
* filtering subagent dispatch targets. Installer/team flows add every
|
|
877
|
+
* newly installed agent to its dispatchers here.
|
|
878
|
+
*/
|
|
405
879
|
updateAllowlist(agentId: string, patch: RuntimeAllowlistPatch): Promise<void>;
|
|
406
|
-
heartbeat(agentId: string): Promise<boolean>;
|
|
407
880
|
};
|
|
408
881
|
messaging: {
|
|
409
882
|
send(args: MessageArgs): Promise<MessageResult>;
|
|
883
|
+
/**
|
|
884
|
+
* Stream one agent turn as normalized ChatChunks. See the ChatChunk
|
|
885
|
+
* doc for the behavioral contract: adapter-varying granularity,
|
|
886
|
+
* `done` exactly once and last, best-effort tool/status liveness,
|
|
887
|
+
* terminal failure = `error` chunk then end (never a throw from
|
|
888
|
+
* iteration), classified/structured chunks only.
|
|
889
|
+
*/
|
|
410
890
|
stream(args: MessageArgs): AsyncIterable<ChatChunk>;
|
|
411
891
|
};
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
892
|
+
/**
|
|
893
|
+
* OPTIONAL capability (P2.1): runtimes without a channel/delivery layer
|
|
894
|
+
* (Pi) OMIT this member entirely — no throwing stubs. Callers MUST
|
|
895
|
+
* feature-detect (`runtime.channels?.…` or a guarded local) and degrade
|
|
896
|
+
* honestly: empty channel lists, log-only alerts, UI-only approval gates.
|
|
897
|
+
* `capabilities().delivery.mode` reports the same fact declaratively.
|
|
898
|
+
*/
|
|
899
|
+
channels?: {
|
|
417
900
|
list(): Promise<ChannelInfo[]>;
|
|
418
901
|
sendNotification(args: NotificationArgs): Promise<DeliveryResult>;
|
|
419
902
|
sendMessage(args: ChannelMessageArgs): Promise<DeliveryResult>;
|
|
@@ -423,8 +906,13 @@ export interface AgentRuntimeAdapter {
|
|
|
423
906
|
cancelApproval(args: CancelApprovalArgs): Promise<void>;
|
|
424
907
|
resolveApproval(args: ResolveApprovalArgs): Promise<void>;
|
|
425
908
|
subscribeApprovalResponses(handler: (event: ApprovalResolveEvent) => void): Unsubscribe;
|
|
426
|
-
|
|
427
|
-
|
|
909
|
+
/**
|
|
910
|
+
* Optional threading/editing capabilities. Adapters for providers without
|
|
911
|
+
* threads or message editing omit them; callers MUST feature-detect and
|
|
912
|
+
* fall back to flat channel messages — never error on absence.
|
|
913
|
+
*/
|
|
914
|
+
createThread?(args: CreateThreadArgs): Promise<CreatedThread | null>;
|
|
915
|
+
editMessage?(args: EditChannelMessageArgs): Promise<void>;
|
|
428
916
|
};
|
|
429
917
|
skills: {
|
|
430
918
|
list(agentId?: string): Promise<RuntimeSkill[]>;
|
|
@@ -435,6 +923,12 @@ export interface AgentRuntimeAdapter {
|
|
|
435
923
|
sessions: {
|
|
436
924
|
list(agentId?: string): Promise<RuntimeSession[]>;
|
|
437
925
|
get(sessionId: string): Promise<RuntimeSession | null>;
|
|
926
|
+
/**
|
|
927
|
+
* Per-agent session-store disk stats. Optional: runtimes without a
|
|
928
|
+
* file-backed session store omit it, and callers must treat absence
|
|
929
|
+
* as "stats unavailable" — skip, never error.
|
|
930
|
+
*/
|
|
931
|
+
storeStats?(): Promise<RuntimeSessionStoreStats[]>;
|
|
438
932
|
};
|
|
439
933
|
memory: {
|
|
440
934
|
listTiers(): Promise<RuntimeMemoryTier[]>;
|
|
@@ -463,15 +957,94 @@ export interface AgentRuntimeAdapter {
|
|
|
463
957
|
listAvailable(opts?: {
|
|
464
958
|
includeUnavailable?: boolean;
|
|
465
959
|
}): Promise<RuntimeAvailableModel[]>;
|
|
960
|
+
/** Static declaration of which routing-policy fields this runtime honors. */
|
|
961
|
+
routingSupport(): RuntimeRoutingSupport;
|
|
962
|
+
/** The runtime's current routing policy (unsupported fields empty). */
|
|
963
|
+
routingPolicy(): Promise<RuntimeRoutingPolicy>;
|
|
964
|
+
/**
|
|
965
|
+
* Merge a partial policy into the runtime's native store. MUST throw on
|
|
966
|
+
* a patch carrying a field `routingSupport()` declares unsupported.
|
|
967
|
+
* `reason` feeds the adapter's audit trail.
|
|
968
|
+
*/
|
|
969
|
+
setRoutingPolicy(patch: Partial<RuntimeRoutingPolicy>, reason: string): Promise<void>;
|
|
466
970
|
};
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
971
|
+
/**
|
|
972
|
+
* The unified capability declaration for this runtime, evaluated for
|
|
973
|
+
* `opts.agentId`'s effective model (default: the main agent) where
|
|
974
|
+
* model-dependent (input modality). Async: the report surface for the
|
|
975
|
+
* runtime-switch UI + plugin capability queries. `input` is conservative-
|
|
976
|
+
* false on any ambiguity, never model-name heuristics.
|
|
977
|
+
*
|
|
978
|
+
* Modes are HONEST: a static `'native'` declaration is acceptable only
|
|
979
|
+
* when the surface is unconditionally implemented (the standard the T28
|
|
980
|
+
* sessions fix restored — a declared-native stub is a contract violation,
|
|
981
|
+
* pinned by the runtime conformance suite's capability-honesty check).
|
|
982
|
+
*/
|
|
983
|
+
capabilities(opts?: {
|
|
984
|
+
agentId?: string;
|
|
985
|
+
}): Promise<CapabilitySet>;
|
|
986
|
+
/**
|
|
987
|
+
* How agents on this runtime invoke Bakin exec tools — drives the
|
|
988
|
+
* tool-usage wording of dispatch prompts + projected AGENTS.md. SYNC +
|
|
989
|
+
* static (declared wiring, not probed state) so it's callable from the
|
|
990
|
+
* synchronous prompt-assembly path; `capabilities().toolCalling.access`
|
|
991
|
+
* returns the same facts for the async report surface.
|
|
992
|
+
*/
|
|
993
|
+
describeToolAccess(): RuntimeToolAccess;
|
|
994
|
+
/**
|
|
995
|
+
* Presence-only credential report for the runtime's LLM providers and
|
|
996
|
+
* channels (P2.2). `opts.agentId` scopes provider credentials to one
|
|
997
|
+
* agent's profile where the runtime keys them per-agent (default: the
|
|
998
|
+
* main agent). Never returns secret material.
|
|
999
|
+
*/
|
|
1000
|
+
credentialStatus(opts?: {
|
|
1001
|
+
agentId?: string;
|
|
1002
|
+
}): Promise<RuntimeCredentialStatus>;
|
|
1003
|
+
/**
|
|
1004
|
+
* Wire up this runtime so its agents can reach Bakin's exec tools.
|
|
1005
|
+
* Idempotent + re-invokable: run at init AND whenever the agent roster or
|
|
1006
|
+
* exec-tool set changes (agent-create, plugin (un)load).
|
|
1007
|
+
* - in-process (Pi): no-op — tools are injected per session via the
|
|
1008
|
+
* `execTools` provider passed to `initialize`.
|
|
1009
|
+
* - mcp (OpenClaw): write `config.mcp.servers[bakin-<agent>]` for every
|
|
1010
|
+
* agent, pruning stale Bakin entries; needs `bakinMcpBaseUrl` (init opt).
|
|
1011
|
+
* - cli-shim: no-op stub.
|
|
1012
|
+
* The `execTools` provider reads the LIVE registry; runtimes that inject
|
|
1013
|
+
* tools by value re-read it here so late registrations become visible.
|
|
1014
|
+
*/
|
|
1015
|
+
provisionToolAccess(execTools?: RuntimeExecToolProvider): Promise<void>;
|
|
1016
|
+
/**
|
|
1017
|
+
* Tear down what `provisionToolAccess` wrote. in-process/cli-shim: no-op.
|
|
1018
|
+
* mcp: remove Bakin-owned `bakin-*` server entries. Called by the
|
|
1019
|
+
* runtime-switch flow (P3.2) on switch-away.
|
|
1020
|
+
*/
|
|
1021
|
+
deprovisionToolAccess(): Promise<void>;
|
|
1022
|
+
/**
|
|
1023
|
+
* Report whether tool-access provisioning is currently in place, WITHOUT
|
|
1024
|
+
* writing. Drives the onboarding/doctor drift surfaces through a
|
|
1025
|
+
* runtime-neutral status so core never inspects a provider's config shape.
|
|
1026
|
+
*/
|
|
1027
|
+
verifyToolAccess(): Promise<ToolAccessProvisioningStatus>;
|
|
1028
|
+
images?: RuntimeImagesAccess;
|
|
1029
|
+
extensions?: RuntimeExtensionsAccess;
|
|
1030
|
+
/**
|
|
1031
|
+
* Access to the runtime's private media store (e.g. channel attachments).
|
|
1032
|
+
* `resolveUri` maps a runtime-private URI (`RUNTIME_MEDIA_URI_SCHEME`-
|
|
1033
|
+
* prefixed) to an absolute local file path; null for unknown schemes or
|
|
1034
|
+
* missing files — never throws for not-found. Optional: runtimes without a
|
|
1035
|
+
* media store omit it, and callers must treat absence as "cannot resolve".
|
|
1036
|
+
*/
|
|
1037
|
+
media?: {
|
|
1038
|
+
resolveUri(uri: string): Promise<string | null>;
|
|
473
1039
|
};
|
|
474
|
-
|
|
1040
|
+
/**
|
|
1041
|
+
* OPTIONAL capability (P2.1): the RUNTIME's native cron surface (jobs the
|
|
1042
|
+
* runtime/agents create for themselves — Bakin surfaces them read-only and
|
|
1043
|
+
* can adopt them). Runtimes without one (Pi) OMIT the member; Bakin-owned
|
|
1044
|
+
* task scheduling (the schedule plugin's own tick scheduler) is unaffected.
|
|
1045
|
+
* Callers MUST feature-detect and treat absence as "no native jobs".
|
|
1046
|
+
*/
|
|
1047
|
+
cron?: {
|
|
475
1048
|
list(): Promise<CronJob[]>;
|
|
476
1049
|
get(id: string): Promise<CronJob | null>;
|
|
477
1050
|
create(input: CreateCronJobInput): Promise<CronJob>;
|
|
@@ -482,5 +1055,4 @@ export interface AgentRuntimeAdapter {
|
|
|
482
1055
|
getRaw(id: string, reason: string): Promise<unknown | null>;
|
|
483
1056
|
restoreRaw(id: string, snapshot: unknown, reason: string): Promise<CronJob>;
|
|
484
1057
|
};
|
|
485
|
-
config: RuntimeConfigAccess;
|
|
486
1058
|
}
|