@makinbakin/sdk 0.0.1-rc.4 → 0.0.1-rc.40
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 +248 -3
- package/_internal/app/components/agent-avatar.d.ts +2 -1
- package/_internal/app/components/conversation/attention.d.ts +56 -0
- package/_internal/app/components/conversation/fold.d.ts +3 -0
- package/_internal/app/components/conversation/notification-sound.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/turn-recorder.d.ts +37 -0
- package/_internal/app/components/conversation/use-conversation-attention.d.ts +61 -0
- package/_internal/app/components/drawer.d.ts +27 -0
- package/_internal/app/components/ui/button.d.ts +2 -8
- package/_internal/app/components/ui/dialog.d.ts +2 -17
- package/_internal/app/components/ui/sheet.d.ts +2 -14
- package/_internal/app/core/conversation-turns.d.ts +229 -0
- package/_internal/app/core/logger.d.ts +1 -0
- package/_internal/app/core/tool-access.d.ts +42 -0
- package/_internal/app/hooks/use-available-models.d.ts +25 -0
- package/_internal/app/hooks/use-content-store.d.ts +0 -9
- package/_internal/app/hooks/use-history-back.d.ts +5 -0
- package/_internal/app/hooks/use-horizontal-resize.d.ts +21 -0
- package/_internal/app/hooks/use-json-fetch.d.ts +36 -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 +3 -12
- package/_internal/app/hooks/use-resizable-pane.d.ts +35 -0
- package/_internal/app/hooks/use-runtime-status.d.ts +22 -6
- 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 +13 -3
- package/_internal/app/lib/browser-notify.d.ts +12 -1
- package/_internal/app/types/index.d.ts +1 -105
- package/_internal/core/adapters/runtime/channels.d.ts +231 -0
- package/_internal/core/adapters/runtime/concepts.d.ts +794 -235
- package/_internal/core/adapters/runtime/errors.d.ts +105 -0
- package/_internal/core/adapters/runtime/helpers.d.ts +19 -0
- package/_internal/core/adapters/runtime/index.d.ts +8 -2
- package/_internal/core/adapters/runtime/skill-files.d.ts +12 -0
- package/_internal/core/adapters/runtime/testing.d.ts +99 -0
- package/_internal/core/adapters/runtime/turn-activity.d.ts +23 -0
- package/_internal/core/adapters/shared.d.ts +133 -12
- package/_internal/core/content-dir.d.ts +11 -0
- package/_internal/core/delivery/bridge.d.ts +36 -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 +25 -1
- package/_internal/core/health/observation-builders.d.ts +42 -0
- package/_internal/core/media/downscale.d.ts +18 -0
- package/_internal/core/media/pin-data.d.ts +36 -0
- package/_internal/core/media/pin.d.ts +22 -0
- package/_internal/core/media/sharp-import.d.ts +10 -0
- package/_internal/core/media/sharp-loader.d.ts +41 -0
- package/_internal/core/media/store.d.ts +21 -0
- package/_internal/core/plugin-types.d.ts +248 -500
- package/_internal/core/routing/define.d.ts +33 -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/host/ui/action-status.d.ts +13 -0
- package/_internal/host/ui/modals.d.ts +5 -0
- package/_internal/host/ui/resize.d.ts +2 -0
- package/_internal/plugins/team/types.d.ts +61 -4
- package/_internal/plugins/workflows/hooks/use-notification-channels.d.ts +1 -1
- package/_internal/ui/behaviors/clipboard.d.ts +10 -0
- package/_internal/ui/behaviors/resize-handle.d.ts +15 -0
- package/_internal/ui/behaviors/selection-navigation.d.ts +5 -0
- package/_internal/ui/behaviors/use-persisted-leading-edge-resize.d.ts +31 -0
- package/_internal/ui/charts/area-chart.d.ts +27 -0
- package/_internal/ui/charts/axis.d.ts +13 -0
- package/_internal/ui/charts/bar-chart.d.ts +21 -0
- package/_internal/ui/charts/chart-data-table.d.ts +61 -0
- package/_internal/ui/charts/chart-explainer.d.ts +4 -0
- package/_internal/ui/charts/chart-tooltip.d.ts +8 -0
- package/_internal/ui/charts/composition-bar.d.ts +46 -0
- package/_internal/ui/charts/index.d.ts +24 -0
- package/_internal/ui/charts/line-chart.d.ts +26 -0
- package/_internal/ui/charts/monotone-curve.d.ts +23 -0
- package/_internal/ui/charts/palette.d.ts +32 -0
- package/_internal/ui/charts/pie-chart.d.ts +80 -0
- package/_internal/ui/charts/ranked-bar-chart.d.ts +41 -0
- package/_internal/ui/charts/sparkline.d.ts +16 -0
- package/_internal/ui/charts/stacked-column-chart.d.ts +33 -0
- package/_internal/ui/content/code-block.d.ts +43 -0
- package/_internal/ui/content/index.d.ts +2 -0
- package/_internal/ui/conversation/activity-group.d.ts +27 -0
- package/_internal/ui/conversation/agent-turn.d.ts +47 -0
- package/_internal/ui/conversation/composer.d.ts +62 -0
- package/_internal/ui/conversation/context-meter.d.ts +37 -0
- package/_internal/ui/conversation/conversation-empty-state.d.ts +13 -0
- package/_internal/ui/conversation/conversation-header.d.ts +26 -0
- package/_internal/ui/conversation/conversation-panel.d.ts +61 -0
- package/_internal/ui/conversation/conversation.d.ts +37 -0
- package/_internal/ui/conversation/fold.d.ts +150 -0
- package/_internal/ui/conversation/glyphs.d.ts +30 -0
- package/_internal/ui/conversation/index.d.ts +31 -0
- package/_internal/ui/conversation/queued-message-list.d.ts +22 -0
- package/_internal/ui/conversation/relative-time.d.ts +8 -0
- package/_internal/ui/conversation/tool-call-drawer.d.ts +14 -0
- package/_internal/ui/conversation/turn-controls.d.ts +9 -0
- package/_internal/ui/conversation/turn-output.d.ts +42 -0
- package/_internal/ui/conversation/turn-usage.d.ts +16 -0
- package/_internal/ui/conversation/user-message.d.ts +13 -0
- package/_internal/ui/forms/field.d.ts +30 -0
- package/_internal/ui/forms/fieldset.d.ts +10 -0
- package/_internal/ui/forms/form.d.ts +19 -0
- package/_internal/ui/forms/index.d.ts +6 -0
- package/_internal/ui/index.d.ts +89 -0
- package/_internal/ui/layout/bounded-overflow.d.ts +42 -0
- package/_internal/ui/layout/disclosure-panel.d.ts +24 -0
- package/_internal/ui/layout/flow.d.ts +27 -0
- package/_internal/ui/layout/grid.d.ts +16 -0
- package/_internal/ui/layout/index.d.ts +14 -0
- package/_internal/ui/layout/page-shell.d.ts +11 -0
- package/_internal/ui/layout/panel.d.ts +28 -0
- package/_internal/ui/layout/section.d.ts +15 -0
- package/_internal/ui/layout/sticky-overflow-scrollbar.d.ts +11 -0
- package/_internal/ui/layout/utils.d.ts +1 -0
- package/_internal/ui/patterns/agent-filter.d.ts +21 -0
- package/_internal/ui/patterns/calendar-grid.d.ts +80 -0
- package/_internal/ui/patterns/calendar-item.d.ts +42 -0
- package/_internal/ui/patterns/calendar-nav.d.ts +21 -0
- package/_internal/ui/patterns/confirm-dialog.d.ts +29 -0
- package/_internal/ui/patterns/copy-button.d.ts +15 -0
- package/_internal/ui/patterns/danger-zone.d.ts +17 -0
- package/_internal/ui/patterns/data-table.d.ts +157 -0
- package/_internal/ui/patterns/drawer-section.d.ts +11 -0
- package/_internal/ui/patterns/facet-filter.d.ts +22 -0
- package/_internal/ui/patterns/filter-indicator.d.ts +3 -0
- package/_internal/ui/patterns/guide-card.d.ts +33 -0
- package/_internal/ui/patterns/index.d.ts +75 -0
- package/_internal/ui/patterns/inspector-panel.d.ts +39 -0
- package/_internal/ui/patterns/kanban.d.ts +70 -0
- package/_internal/ui/patterns/key-value.d.ts +35 -0
- package/_internal/ui/patterns/list-rows.d.ts +111 -0
- package/_internal/ui/patterns/nav-list.d.ts +41 -0
- package/_internal/ui/patterns/node-card.d.ts +37 -0
- package/_internal/ui/patterns/page-aside.d.ts +49 -0
- package/_internal/ui/patterns/page-body.d.ts +49 -0
- package/_internal/ui/patterns/page-canvas.d.ts +12 -0
- package/_internal/ui/patterns/page-composer.d.ts +8 -0
- package/_internal/ui/patterns/page-controls.d.ts +33 -0
- package/_internal/ui/patterns/page-header.d.ts +40 -0
- package/_internal/ui/patterns/page-timeline.d.ts +18 -0
- package/_internal/ui/patterns/page.d.ts +32 -0
- package/_internal/ui/patterns/pagination.d.ts +23 -0
- package/_internal/ui/patterns/save-bar.d.ts +21 -0
- package/_internal/ui/patterns/search-input.d.ts +20 -0
- package/_internal/ui/patterns/segmented-control.d.ts +22 -0
- package/_internal/ui/patterns/sortable-head.d.ts +13 -0
- package/_internal/ui/patterns/stat-group.d.ts +8 -0
- package/_internal/ui/patterns/stat-tile.d.ts +25 -0
- package/_internal/ui/patterns/status-badge.d.ts +15 -0
- package/_internal/ui/patterns/status-marker.d.ts +10 -0
- package/_internal/ui/patterns/timeline.d.ts +59 -0
- package/_internal/ui/patterns/unsaved-changes-dialog.d.ts +22 -0
- package/_internal/ui/patterns/workspace-page.d.ts +76 -0
- package/_internal/ui/primitives/alert.d.ts +17 -0
- package/_internal/ui/primitives/avatar.d.ts +13 -0
- package/_internal/ui/primitives/badge.d.ts +27 -0
- package/_internal/ui/primitives/button.d.ts +32 -0
- package/_internal/ui/primitives/card.d.ts +55 -0
- package/_internal/ui/primitives/checkbox.d.ts +3 -0
- package/_internal/ui/primitives/collapsible.d.ts +7 -0
- package/_internal/ui/primitives/color-input.d.ts +21 -0
- package/_internal/ui/primitives/combobox.d.ts +40 -0
- package/_internal/ui/primitives/command.d.ts +36 -0
- package/_internal/ui/primitives/control-styles.d.ts +10 -0
- package/_internal/ui/primitives/dialog.d.ts +31 -0
- package/_internal/ui/primitives/dropdown-menu.d.ts +54 -0
- package/_internal/ui/primitives/file-input.d.ts +33 -0
- package/_internal/ui/primitives/input-group.d.ts +30 -0
- package/_internal/ui/primitives/input.d.ts +10 -0
- package/_internal/ui/primitives/interactive-surface.d.ts +24 -0
- package/_internal/ui/primitives/label.d.ts +3 -0
- package/_internal/ui/primitives/modal-context.d.ts +9 -0
- package/_internal/ui/primitives/option-list.d.ts +10 -0
- package/_internal/ui/primitives/popover.d.ts +18 -0
- package/_internal/ui/primitives/portal-ownership.d.ts +11 -0
- package/_internal/ui/primitives/progress.d.ts +38 -0
- package/_internal/ui/primitives/radio-group.d.ts +12 -0
- package/_internal/ui/primitives/select.d.ts +35 -0
- package/_internal/ui/primitives/separator.d.ts +7 -0
- package/_internal/ui/primitives/sheet.d.ts +34 -0
- package/_internal/ui/primitives/shimmer-text.d.ts +13 -0
- package/_internal/ui/primitives/skeleton.d.ts +6 -0
- package/_internal/ui/primitives/spinner.d.ts +31 -0
- package/_internal/ui/primitives/switch.d.ts +6 -0
- package/_internal/{app/components/ui → ui/primitives}/tabs.d.ts +1 -1
- package/_internal/ui/primitives/text.d.ts +43 -0
- package/_internal/ui/primitives/textarea.d.ts +19 -0
- package/_internal/ui/primitives/tooltip.d.ts +14 -0
- package/_internal/ui/primitives/use-textarea-autosize.d.ts +3 -0
- package/_internal/ui/private-ui-boundary-probe.d.ts +9 -0
- package/_internal/ui/states/banner.d.ts +15 -0
- package/_internal/ui/states/index.d.ts +6 -0
- package/_internal/ui/states/system-state.d.ts +88 -0
- package/_internal/ui/states/toast.d.ts +26 -0
- package/_internal/ui/utils.d.ts +14 -0
- package/bin/bakin-plugin-test-ui.js +6854 -0
- package/charts/index.d.ts +3 -0
- package/charts/index.js +2 -0
- package/content/index.d.ts +14 -0
- package/content/index.js +38 -0
- package/content/markdown-comparison.d.ts +12 -0
- package/content/markdown-content.d.ts +18 -0
- package/content/markdown-document.d.ts +4 -0
- package/content/markdown-editor.d.ts +35 -0
- package/conversation/index.d.ts +50 -0
- package/conversation/index.js +4 -0
- package/conversation/use-conversation-thread.d.ts +73 -0
- package/hooks/index.d.ts +86 -11
- package/hooks/index.js +1 -1747
- package/hooks/router.d.ts +4 -36
- package/index.d.ts +30 -6
- package/index.js +10 -14210
- package/internal/index.d.ts +74 -0
- package/internal/index.js +2 -0
- package/internal/lazy.d.ts +58 -0
- package/internal/plugin-ownership.d.ts +18 -0
- package/internal/private-ui-boundary-probe.d.ts +2 -0
- package/layout/index.d.ts +9 -0
- package/layout/index.js +2 -0
- package/metadata/index.d.ts +14 -1
- package/metadata/index.js +1 -30
- package/navigation/history-back.d.ts +5 -0
- package/navigation/index.d.ts +23 -0
- package/navigation/index.js +2 -0
- package/navigation/plugin-link.d.ts +11 -0
- package/navigation/query-state.d.ts +7 -0
- package/navigation/router.d.ts +35 -0
- package/navigation/search-params.d.ts +7 -0
- package/navigation/unsaved-changes-guard.d.ts +35 -0
- package/package.json +63 -10
- package/patterns/agent-patterns.d.ts +81 -0
- package/patterns/asset-library-picker.d.ts +38 -0
- package/patterns/channel-patterns.d.ts +32 -0
- package/patterns/index.d.ts +40 -0
- package/patterns/index.js +47 -0
- package/patterns/picker-patterns.d.ts +108 -0
- package/patterns/plugin-settings-renderer.d.ts +41 -0
- package/patterns/presentation-color.d.ts +2 -0
- package/patterns/search-patterns.d.ts +51 -0
- package/register.d.ts +63 -9
- package/routing/index.d.ts +6 -1
- package/routing/index.js +10 -14014
- package/slots/index.d.ts +12 -24
- package/slots/index.js +1 -91
- package/slots/registry.d.ts +45 -0
- package/styles.css +2 -0
- package/testing/index.d.ts +122 -0
- package/testing/index.js +93 -0
- package/testing/ui/conformance/cli.d.ts +2 -0
- package/testing/ui/conformance/contracts.d.ts +73 -0
- package/testing/ui/conformance/index.d.ts +11 -0
- package/testing/ui/conformance/index.js +85 -0
- package/testing/ui/conformance/plugin-css.d.ts +37 -0
- package/testing/ui/conformance/plugin-id.d.ts +6 -0
- package/testing/ui/conformance/runner.d.ts +13 -0
- package/testing/ui/index.d.ts +24 -0
- package/testing/ui/index.js +2 -0
- package/testing/ui/plugin-ui-fixture-host.d.ts +36 -0
- package/testing/ui/runtime.d.ts +70 -0
- package/types/api-route.d.ts +89 -0
- package/types/context.d.ts +166 -0
- package/types/conversation-turns.d.ts +229 -0
- package/types/events.d.ts +10 -0
- package/types/health.d.ts +376 -0
- package/types/index.d.ts +19 -919
- package/types/index.js +1 -0
- package/types/manifest.d.ts +255 -0
- package/types/primitives.d.ts +33 -0
- package/types/registration.d.ts +281 -0
- package/types/runtime.d.ts +292 -0
- package/types/scheduled-events.d.ts +80 -0
- package/types/services.d.ts +599 -0
- package/ui/index.d.ts +73 -31
- package/ui/index.js +38 -28704
- package/utils/asset-id.d.ts +15 -0
- package/utils/index.d.ts +27 -7
- package/utils/index.js +4 -2098
- package/utils/plugin-fetch.d.ts +44 -0
- package/_internal/app/components/agent-filter.d.ts +0 -8
- package/_internal/app/components/agent-select.d.ts +0 -15
- package/_internal/app/components/agent-status.d.ts +0 -8
- package/_internal/app/components/bakin-drawer.d.ts +0 -23
- package/_internal/app/components/color-picker.d.ts +0 -7
- package/_internal/app/components/empty-state.d.ts +0 -10
- package/_internal/app/components/error-banner.d.ts +0 -6
- package/_internal/app/components/error-state.d.ts +0 -8
- package/_internal/app/components/facet-filter.d.ts +0 -17
- 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/components/markdown-content.d.ts +0 -3
- package/_internal/app/components/markdown-editor.d.ts +0 -11
- package/_internal/app/components/model-select.d.ts +0 -9
- package/_internal/app/components/page-layout.d.ts +0 -9
- package/_internal/app/components/plugin-header.d.ts +0 -16
- package/_internal/app/components/plugin-settings-renderer.d.ts +0 -9
- package/_internal/app/components/sortable-head.d.ts +0 -13
- package/_internal/app/components/ui/alert.d.ts +0 -10
- package/_internal/app/components/ui/avatar.d.ts +0 -11
- package/_internal/app/components/ui/badge.d.ts +0 -7
- package/_internal/app/components/ui/card.d.ts +0 -11
- package/_internal/app/components/ui/checkbox.d.ts +0 -3
- package/_internal/app/components/ui/collapsible.d.ts +0 -5
- package/_internal/app/components/ui/command.d.ts +0 -19
- package/_internal/app/components/ui/dropdown-menu.d.ts +0 -29
- package/_internal/app/components/ui/form.d.ts +0 -23
- package/_internal/app/components/ui/input-group.d.ts +0 -18
- package/_internal/app/components/ui/input.d.ts +0 -3
- package/_internal/app/components/ui/label.d.ts +0 -3
- package/_internal/app/components/ui/popover.d.ts +0 -9
- package/_internal/app/components/ui/progress.d.ts +0 -7
- package/_internal/app/components/ui/select.d.ts +0 -15
- package/_internal/app/components/ui/separator.d.ts +0 -3
- package/_internal/app/components/ui/skeleton.d.ts +0 -2
- package/_internal/app/components/ui/switch.d.ts +0 -5
- package/_internal/app/components/ui/textarea.d.ts +0 -3
- package/_internal/app/components/ui/tooltip.d.ts +0 -6
- package/_internal/app/components/underline-tabs.d.ts +0 -15
- package/_internal/app/hooks/use-assets.d.ts +0 -25
- package/_internal/app/hooks/use-form-guard.d.ts +0 -5
- package/_internal/app/hooks/use-vertical-resize.d.ts +0 -22
- package/_internal/app/lib/utils.d.ts +0 -2
- package/_internal/plugins/workflows/hooks/channel-icon.d.ts +0 -6
- package/components/index.d.ts +0 -34
- package/components/index.js +0 -40175
- /package/_internal/{app/components/ui → ui/primitives}/table.d.ts +0 -0
|
@@ -0,0 +1,105 @@
|
|
|
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
|
+
* The provider deterministically rejected the MODEL ID for this account
|
|
23
|
+
* (retired/unentitled model — the #852 class). Not a cooldown: waiting
|
|
24
|
+
* never fixes it, so it is never retried. `providerInfo.model` carries the
|
|
25
|
+
* qualified rejected id; core records it as availability evidence.
|
|
26
|
+
*/
|
|
27
|
+
| 'model_not_supported'
|
|
28
|
+
/**
|
|
29
|
+
* The caller intentionally cancelled the turn (MessageArgs.signal) —
|
|
30
|
+
* terminal: never retried, never diagnosed, never enters the recovery
|
|
31
|
+
* ladder.
|
|
32
|
+
*/
|
|
33
|
+
| 'aborted'
|
|
34
|
+
/**
|
|
35
|
+
* A CRUD mutation addressed an entity (agent, skill, cron job) that does
|
|
36
|
+
* not exist on the runtime. Reads return `null` for absence; only
|
|
37
|
+
* mutations reject with this kind (R28).
|
|
38
|
+
*/
|
|
39
|
+
| 'not_found';
|
|
40
|
+
/**
|
|
41
|
+
* Structured provider metadata for `provider_cooldown` failures, extracted by
|
|
42
|
+
* the adapter from provider-specific error payloads so core never parses
|
|
43
|
+
* provider strings.
|
|
44
|
+
*/
|
|
45
|
+
export interface RuntimeProviderInfo {
|
|
46
|
+
provider?: string;
|
|
47
|
+
model?: string;
|
|
48
|
+
/** e.g. 'timeout' when the provider entered cooldown after a timeout. */
|
|
49
|
+
cooldownReason?: string;
|
|
50
|
+
/** No auth profile was available (vs. an active profile in cooldown). */
|
|
51
|
+
authProfileUnavailable?: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface RuntimeErrorOptions {
|
|
54
|
+
kind: RuntimeErrorKind;
|
|
55
|
+
cause?: unknown;
|
|
56
|
+
providerInfo?: RuntimeProviderInfo;
|
|
57
|
+
}
|
|
58
|
+
export declare class RuntimeError extends Error {
|
|
59
|
+
readonly kind: RuntimeErrorKind;
|
|
60
|
+
readonly providerInfo?: RuntimeProviderInfo;
|
|
61
|
+
constructor(message: string, options: RuntimeErrorOptions);
|
|
62
|
+
}
|
|
63
|
+
export type RuntimeTurnFailureReason =
|
|
64
|
+
/** session.ended with a non-success status that was not a runtime timeout. */
|
|
65
|
+
'session_interrupted'
|
|
66
|
+
/** The session/turn genuinely timed out server-side. */
|
|
67
|
+
| 'runtime_timeout';
|
|
68
|
+
/**
|
|
69
|
+
* Post-mortem of a dead provider turn, assembled entirely inside the runtime
|
|
70
|
+
* adapter (Bakin core never reads provider files). Every field is optional
|
|
71
|
+
* evidence — a partial diagnosis is still more useful than a generic timeout.
|
|
72
|
+
*/
|
|
73
|
+
export interface RuntimeTurnDiagnosis {
|
|
74
|
+
reason: RuntimeTurnFailureReason;
|
|
75
|
+
/** Provider session id the turn ran in. */
|
|
76
|
+
sessionId?: string;
|
|
77
|
+
/** Raw provider session end status, e.g. 'interrupted'. */
|
|
78
|
+
sessionStatus?: string;
|
|
79
|
+
/** Provider-reported timeout flag from the session end event. */
|
|
80
|
+
timedOut?: boolean;
|
|
81
|
+
/** Total bytes of the final assistant output that killed the turn. */
|
|
82
|
+
completionBytes?: number;
|
|
83
|
+
/** Provider truncated the recorded completion (trajectory size limit). */
|
|
84
|
+
outputTruncated?: boolean;
|
|
85
|
+
/** completionBytes exceeded the configured oversized-output threshold. */
|
|
86
|
+
oversizedOutput?: boolean;
|
|
87
|
+
/** Last tool the agent invoked before the turn died. */
|
|
88
|
+
lastToolCall?: string;
|
|
89
|
+
/** Truncated completion text preserved for salvage (capped by the adapter). */
|
|
90
|
+
salvagedText?: string;
|
|
91
|
+
/** Token usage recorded for the fatal completion, when available. */
|
|
92
|
+
usage?: {
|
|
93
|
+
input?: number;
|
|
94
|
+
output?: number;
|
|
95
|
+
total?: number;
|
|
96
|
+
};
|
|
97
|
+
/** One-line human-readable diagnosis. */
|
|
98
|
+
detail?: string;
|
|
99
|
+
}
|
|
100
|
+
export declare class RuntimeTurnError extends RuntimeError {
|
|
101
|
+
readonly diagnosis: RuntimeTurnDiagnosis;
|
|
102
|
+
constructor(diagnosis: RuntimeTurnDiagnosis, options?: {
|
|
103
|
+
cause?: unknown;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
@@ -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,5 +1,11 @@
|
|
|
1
|
-
export type { AdapterAuditEvent,
|
|
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';
|
|
6
|
+
export { RuntimeError, RuntimeTurnError } from './errors';
|
|
7
|
+
export type { RuntimeErrorKind, RuntimeErrorOptions, RuntimeProviderInfo, RuntimeTurnDiagnosis, RuntimeTurnFailureReason, } from './errors';
|
|
4
8
|
export { getRuntimeMainAgent, getRuntimeMainAgentId, getRuntimeMainAgentName, selectRuntimeMainAgent, } from './helpers';
|
|
5
|
-
export type { AgentRuntimeAdapter, ApprovalDelivery, ApprovalOption, ApprovalPatch, ApprovalRenderRef, ApprovalRenderResult, ApprovalResolveEvent, ApprovalResponse, CancelApprovalArgs, ChannelInfo,
|
|
9
|
+
export type { AgentRuntimeAdapter, ApprovalDelivery, ApprovalOption, ApprovalPatch, ApprovalRenderRef, ApprovalRenderResult, ApprovalResolveEvent, ApprovalResponse, CancelApprovalArgs, ChannelInfo, ChannelMessageArgs, ChatChunk, ChatTextFormat, ContentDeliveryArgs, CreateApprovalArgs, CreateThreadArgs, CreatedThread, CreateCronJobInput, CreateRuntimeAgentInput, CronJob, CronRun, DeliveryResult, DurableApprovalRecord, EditApprovalArgs, EditChannelMessageArgs, InboundChannelAttachment, InboundChannelMessage, MessageArgs, MessageAttachment, MessageResult, MessageUsage, NotificationArgs, ResolveApprovalArgs, RuntimeAgent, RuntimeAllowlistPatch, RuntimeToolActivity, RuntimeAvailableModel, RuntimeCapabilities, CapabilityMode, ToolAccessStyle, RuntimeToolAccess, ToolAccessProvisioningStatus, RuntimeCredentialStatus, ProviderCredentialStatus, ProviderCredentialInventory, RuntimeConfigChangeKind, RestartAdvice, 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, RuntimeSessionContextStats, RuntimeSkill, UpdateCronJobInput, UpdateRuntimeAgentInput, WorkspaceFile, WorkspaceFileStat, } from './concepts';
|
|
10
|
+
export { RUNTIME_MEDIA_URI_SCHEME, DEFAULT_OVERSIZED_OUTPUT_BYTES } from './concepts';
|
|
11
|
+
export { isSafeSkillFilePath, isExecutableSkillFile, readSkillTree, SKILL_SIDECAR_NAMES } from './skill-files';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Relative path inside a skill dir: no absolute, no backslash, no `..`/empty segments. */
|
|
2
|
+
export declare function isSafeSkillFilePath(path: string): boolean;
|
|
3
|
+
/** Metadata sidecars — never part of a skill's file map. */
|
|
4
|
+
export declare const SKILL_SIDECAR_NAMES: Set<string>;
|
|
5
|
+
/** Scripts get the executable bit at projection: shebang or a script extension. */
|
|
6
|
+
export declare function isExecutableSkillFile(path: string, content: string): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Read a skill directory into a relative-path→content map, skipping
|
|
9
|
+
* symlinks and the metadata sidecars (`.installedBy`/`.userEdited`) at any
|
|
10
|
+
* depth. Unreadable roots read as empty.
|
|
11
|
+
*/
|
|
12
|
+
export declare function readSkillTree(root: string): Record<string, string>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { AgentRuntimeAdapter, ProviderCredentialStatus, RestartAdvice } 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 status-only credential inventory for the mock (#907 / #378 slice).
|
|
14
|
+
* `credentials` is an optional contract member, so the DEFAULT mock omits
|
|
15
|
+
* it — eligibility code must feature-detect and treat absence as
|
|
16
|
+
* "credential evidence unavailable" (models read `unknown`, never
|
|
17
|
+
* `ineligible`). Pass `evidence: 'partial'` to exercise the honest-partial
|
|
18
|
+
* branch (OpenClaw's CLI probe failing).
|
|
19
|
+
*
|
|
20
|
+
* Usage: `createMockRuntimeAdapter({ credentials: mockCredentials([{ providerId: 'mock', configured: true }]) })`
|
|
21
|
+
*/
|
|
22
|
+
export declare function mockCredentials(providers?: ProviderCredentialStatus[], evidence?: 'complete' | 'partial'): NonNullable<AgentRuntimeAdapter['credentials']>;
|
|
23
|
+
/**
|
|
24
|
+
* Opt-in restart advice for the mock (#878). Optional member; the default
|
|
25
|
+
* mock omits it so the Models banner's generic-fallback path is what mock
|
|
26
|
+
* consumers see unless they opt in. The same advice is returned for every
|
|
27
|
+
* change kind unless a per-kind map is given.
|
|
28
|
+
*
|
|
29
|
+
* Usage: `createMockRuntimeAdapter({ restartAdvice: mockRestartAdvice({ needed: false }) })`
|
|
30
|
+
*/
|
|
31
|
+
export declare function mockRestartAdvice(advice: RestartAdvice | Partial<Record<'model-config' | 'roster' | 'routing-policy', RestartAdvice>>): NonNullable<AgentRuntimeAdapter['restartAdvice']>;
|
|
32
|
+
/**
|
|
33
|
+
* Opt-in cron surface for the mock — same rationale as mockChannels():
|
|
34
|
+
* `cron` is an optional contract member (Pi omits it), so the default mock
|
|
35
|
+
* omits it and consumers feature-detect.
|
|
36
|
+
*
|
|
37
|
+
* Usage: `createMockRuntimeAdapter({ cron: mockCron() })`
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* Filename the isolation-honoring mock drops into each turn's runWorkspace —
|
|
41
|
+
* the conformance isolation probe's observable (same-agent-concurrency D1).
|
|
42
|
+
*/
|
|
43
|
+
export declare const MOCK_ISOLATION_PROBE = "cwd-probe.txt";
|
|
44
|
+
/**
|
|
45
|
+
* Opt-in same-agent-turn isolation for the mock: declares
|
|
46
|
+
* `concurrency.sameAgentTurns: 'isolated'` and honors
|
|
47
|
+
* `MessageArgs.runWorkspace` by dropping MOCK_ISOLATION_PROBE into the
|
|
48
|
+
* handed directory before delegating — the minimal observable proof the
|
|
49
|
+
* conformance isolation check requires. The DEFAULT mock stays
|
|
50
|
+
* 'serialized' (minimal shape).
|
|
51
|
+
*
|
|
52
|
+
* Usage: `withMockIsolation(createMockRuntimeAdapter())`
|
|
53
|
+
*/
|
|
54
|
+
export declare function withMockIsolation(base: AgentRuntimeAdapter): AgentRuntimeAdapter;
|
|
55
|
+
export declare function mockCron(): NonNullable<AgentRuntimeAdapter['cron']>;
|
|
56
|
+
export declare function createMockRuntimeAdapter(overrides?: Partial<AgentRuntimeAdapter>): AgentRuntimeAdapter;
|
|
57
|
+
/**
|
|
58
|
+
* Opt-in image-input capability override for attachment tests:
|
|
59
|
+
* `createMockRuntimeAdapter({ capabilities: mockImageInputCapabilities() })`.
|
|
60
|
+
* The default mock declares `imageInput: false` (minimal shape); streams
|
|
61
|
+
* still echo attachments in the reply text so pass-through is assertable
|
|
62
|
+
* either way.
|
|
63
|
+
*/
|
|
64
|
+
export declare function mockImageInputCapabilities(): (opts?: {
|
|
65
|
+
agentId?: string;
|
|
66
|
+
}) => Promise<ReturnType<typeof mockCapabilities>>;
|
|
67
|
+
declare function mockCapabilities(deliveryNative: boolean): {
|
|
68
|
+
toolCalling: {
|
|
69
|
+
mode: "native";
|
|
70
|
+
access: {
|
|
71
|
+
style: "mcp";
|
|
72
|
+
mcpServerTemplate: string;
|
|
73
|
+
perTurnExecToolFiltering: boolean;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
delivery: {
|
|
77
|
+
mode: "unavailable" | "native";
|
|
78
|
+
};
|
|
79
|
+
imageGen: {
|
|
80
|
+
mode: "unavailable";
|
|
81
|
+
};
|
|
82
|
+
memory: {
|
|
83
|
+
mode: "native";
|
|
84
|
+
};
|
|
85
|
+
sessions: {
|
|
86
|
+
mode: "native";
|
|
87
|
+
};
|
|
88
|
+
workspaceFiles: {
|
|
89
|
+
mode: "native";
|
|
90
|
+
};
|
|
91
|
+
input: {
|
|
92
|
+
imageInput: boolean;
|
|
93
|
+
audioInput: boolean;
|
|
94
|
+
};
|
|
95
|
+
concurrency: {
|
|
96
|
+
sameAgentTurns: "serialized";
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
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,5 @@
|
|
|
1
|
+
import type { ActivityClass } from '@makinbakin/sdk/types';
|
|
2
|
+
import type { ChannelBridge } from '../delivery/bridge';
|
|
1
3
|
export type Unsubscribe = () => void;
|
|
2
4
|
export interface AdapterLogger {
|
|
3
5
|
debug(message: string, data?: unknown): void;
|
|
@@ -12,26 +14,145 @@ export interface AdapterAuditEvent {
|
|
|
12
14
|
data?: Record<string, unknown>;
|
|
13
15
|
at?: string;
|
|
14
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* One Bakin exec tool as offered across the adapter boundary. The zod
|
|
19
|
+
* shapes stay core-side; adapters receive plain JSON Schema so no
|
|
20
|
+
* validation library leaks into the contract.
|
|
21
|
+
*/
|
|
22
|
+
export interface RuntimeExecToolDescriptor {
|
|
23
|
+
name: string;
|
|
24
|
+
description: string;
|
|
25
|
+
/** JSON Schema (object) for the tool's parameters. */
|
|
26
|
+
parametersSchema: Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
export interface RuntimeExecToolInvokeResult {
|
|
29
|
+
ok: boolean;
|
|
30
|
+
/** Model-facing result text (JSON on success, `ERROR: …` on failure). */
|
|
31
|
+
text: string;
|
|
32
|
+
}
|
|
33
|
+
/** Token usage for one agent turn, when the runtime reports it. */
|
|
34
|
+
export interface MessageUsage {
|
|
35
|
+
input?: number;
|
|
36
|
+
output?: number;
|
|
37
|
+
total?: number;
|
|
38
|
+
/** Cached-input tokens read (priced far below fresh input when known). */
|
|
39
|
+
cacheRead?: number;
|
|
40
|
+
/** Cached-input tokens written (cache creation). */
|
|
41
|
+
cacheWrite?: number;
|
|
42
|
+
/** Resolved model the runtime ran, when known. */
|
|
43
|
+
model?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* One normalized runtime-native tool lifecycle event observed by an adapter.
|
|
47
|
+
* The host uses result events for cross-runtime observability; call events are
|
|
48
|
+
* included so it can derive duration when the runtime does not report one.
|
|
49
|
+
*/
|
|
50
|
+
interface AdapterToolActivityBase {
|
|
51
|
+
agentId: string;
|
|
52
|
+
/** Producer-assigned classification from the originating runtime turn. */
|
|
53
|
+
activityClass: ActivityClass;
|
|
54
|
+
/** Owning adapter turn; required so terminal reconciliation cannot silently opt out. */
|
|
55
|
+
turnId: string;
|
|
56
|
+
threadId?: string;
|
|
57
|
+
callId?: string;
|
|
58
|
+
toolName: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* One normalized tool lifecycle event. Runtime-private status aliases must be
|
|
62
|
+
* resolved by the adapter before crossing this boundary.
|
|
63
|
+
*/
|
|
64
|
+
export type AdapterToolActivityEvent = AdapterToolActivityBase & {
|
|
65
|
+
phase: 'call';
|
|
66
|
+
status: 'running';
|
|
67
|
+
} | AdapterToolActivityBase & {
|
|
68
|
+
phase: 'result';
|
|
69
|
+
status: 'completed' | 'failed' | 'aborted';
|
|
70
|
+
durationMs?: number;
|
|
71
|
+
};
|
|
72
|
+
interface AdapterTurnActivityBase {
|
|
73
|
+
agentId: string;
|
|
74
|
+
/** Producer-assigned classification from the originating runtime turn. */
|
|
75
|
+
activityClass: ActivityClass;
|
|
76
|
+
threadId?: string;
|
|
77
|
+
/** Messaging surface that owns the turn. */
|
|
78
|
+
operation: 'send' | 'stream';
|
|
79
|
+
/** Adapter-generated identity shared by this turn's start and result. */
|
|
80
|
+
turnId: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* One normalized messaging turn lifecycle event observed at the adapter
|
|
84
|
+
* boundary. Every executed send/stream emits exactly one start and one result.
|
|
85
|
+
* Result identity and usage are present when the messaging surface reports
|
|
86
|
+
* them (currently send); adapters never fabricate usage.
|
|
87
|
+
*/
|
|
88
|
+
export type AdapterTurnActivityEvent = AdapterTurnActivityBase & {
|
|
89
|
+
phase: 'start';
|
|
90
|
+
status: 'running';
|
|
91
|
+
} | AdapterTurnActivityBase & {
|
|
92
|
+
phase: 'result';
|
|
93
|
+
status: 'completed' | 'failed' | 'aborted';
|
|
94
|
+
durationMs: number;
|
|
95
|
+
resultId?: string;
|
|
96
|
+
usage?: MessageUsage;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Bakin's exec-tool registry offered to runtimes that deliver tools
|
|
100
|
+
* in-process (Pi registers these as native session tools). Out-of-band
|
|
101
|
+
* runtimes (OpenClaw reaches the same registry over its native MCP client)
|
|
102
|
+
* ignore it. `list()` reads the LIVE registry — call it at session build
|
|
103
|
+
* time so late plugin registrations and hot reloads are visible.
|
|
104
|
+
* Usage recording + audit happen inside `invoke`; adapters add nothing.
|
|
105
|
+
*/
|
|
106
|
+
export interface RuntimeExecToolProvider {
|
|
107
|
+
list(): RuntimeExecToolDescriptor[];
|
|
108
|
+
invoke(name: string, params: Record<string, unknown>, agentId: string): Promise<RuntimeExecToolInvokeResult>;
|
|
109
|
+
}
|
|
15
110
|
export interface AdapterInitOpts {
|
|
16
111
|
contentDir: string;
|
|
112
|
+
/**
|
|
113
|
+
* Optional runtime-neutral channel bridge (issue #669). Runtimes without a
|
|
114
|
+
* native delivery layer (Pi) expose `runtime.channels` by delegating to
|
|
115
|
+
* this handle when `isConfigured()`; natively-delivering runtimes ignore
|
|
116
|
+
* it. This is a HANDLE only — the server owns `boot()`/`shutdown()`;
|
|
117
|
+
* adapters never connect transports.
|
|
118
|
+
*/
|
|
119
|
+
channelBridge?: ChannelBridge;
|
|
17
120
|
settings?: Record<string, unknown>;
|
|
121
|
+
/**
|
|
122
|
+
* LIVE view of the adapter-private settings bag. `settings` is a boot-time
|
|
123
|
+
* snapshot; surfaces whose behavior must track settings edits WITHOUT a
|
|
124
|
+
* restart (extension trust policy, per-turn knobs) read through this.
|
|
125
|
+
* Optional: tests and thin callers may omit it (snapshot semantics).
|
|
126
|
+
*/
|
|
127
|
+
getLiveSettings?: () => Record<string, unknown> | undefined;
|
|
18
128
|
logger?: AdapterLogger;
|
|
19
129
|
audit?: (event: AdapterAuditEvent) => void;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
130
|
+
execTools?: RuntimeExecToolProvider;
|
|
131
|
+
/**
|
|
132
|
+
* Best-effort host observability tap for tool activity across every runtime
|
|
133
|
+
* messaging surface. Adapters contain callback failures so telemetry can
|
|
134
|
+
* never fail an agent turn.
|
|
135
|
+
*/
|
|
136
|
+
onToolActivity?: (event: AdapterToolActivityEvent) => void;
|
|
137
|
+
/**
|
|
138
|
+
* Best-effort host observability tap for every messaging send/stream turn.
|
|
139
|
+
* Adapters contain callback failures so telemetry can never fail a turn.
|
|
140
|
+
*/
|
|
141
|
+
onTurnActivity?: (event: AdapterTurnActivityEvent) => void;
|
|
142
|
+
/**
|
|
143
|
+
* Base URL of Bakin's MCP server (e.g. `http://localhost:3737`) — the seam
|
|
144
|
+
* a runtime whose agents reach Bakin over MCP (OpenClaw) needs to write its
|
|
145
|
+
* per-agent server entries during `provisionToolAccess`. Core knows the
|
|
146
|
+
* port; the adapter does not, so it is threaded here. In-process runtimes
|
|
147
|
+
* (Pi) ignore it.
|
|
148
|
+
*/
|
|
149
|
+
bakinMcpBaseUrl?: string;
|
|
150
|
+
/** Host-issued credential scoped to a single agent; never log this value. */
|
|
151
|
+
getMcpCredential?: (agentId: string) => string;
|
|
32
152
|
}
|
|
33
153
|
export interface AdapterVersionInfo {
|
|
34
154
|
readonly name: string;
|
|
35
155
|
readonly version: string;
|
|
36
156
|
readonly requiredCoreVersion?: string;
|
|
37
157
|
}
|
|
158
|
+
export {};
|
|
@@ -28,8 +28,19 @@ 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;
|
|
39
|
+
db: string;
|
|
40
|
+
/** Bakin-owned bin dir for capability-pack binaries; prepended to PATH at server boot. */
|
|
41
|
+
bin: string;
|
|
42
|
+
/** Media prebuild store (sharp for compiled binaries, #889) — versioned dirs + receipt. */
|
|
43
|
+
media: string;
|
|
33
44
|
}
|
|
34
45
|
export declare function getBakinPaths(): BakinPaths;
|
|
35
46
|
/**
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime-neutral channel bridge contract (issue #669).
|
|
3
|
+
*
|
|
4
|
+
* A ChannelBridge gives a runtime WITHOUT a native channel/delivery layer
|
|
5
|
+
* (Pi) a `runtime.channels` surface by delegation. The concrete Discord
|
|
6
|
+
* implementation lives in `src/core/delivery/` — app code; this package only
|
|
7
|
+
* defines the seam so adapter packages can accept a bridge without importing
|
|
8
|
+
* app modules (adapters never import `src/`).
|
|
9
|
+
*
|
|
10
|
+
* Lifecycle: the HANDLE is threaded through `AdapterInitOpts.channelBridge`
|
|
11
|
+
* at adapter init (cheap, no I/O); `boot()`/`shutdown()` are called by the
|
|
12
|
+
* server only — never inside `createAppServices()`, which read-only CLI
|
|
13
|
+
* paths also call. `isConfigured()` must be side-effect-free and callable
|
|
14
|
+
* before boot: adapters use it to decide whether to expose `channels` and
|
|
15
|
+
* whether `capabilities().delivery.mode` reports `'shimmed'` or
|
|
16
|
+
* `'unavailable'`.
|
|
17
|
+
*/
|
|
18
|
+
import type { RuntimeChannelSurface } from '../adapters/runtime/channels';
|
|
19
|
+
/** The full channel surface, contract-identical to a native adapter's. */
|
|
20
|
+
export type ChannelSurface = RuntimeChannelSurface;
|
|
21
|
+
export interface ChannelBridge {
|
|
22
|
+
/**
|
|
23
|
+
* True when non-secret config AND the transport secret are present.
|
|
24
|
+
* Side-effect-free; the gate for exposing `channels` on an adapter.
|
|
25
|
+
*/
|
|
26
|
+
isConfigured(): boolean;
|
|
27
|
+
/** Connect transports. Server-boot only; idempotent. */
|
|
28
|
+
boot(): Promise<void>;
|
|
29
|
+
/** Disconnect and release transports. Safe when never booted. */
|
|
30
|
+
shutdown(): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* The delegated channel surface. Only meaningful when `isConfigured()`;
|
|
33
|
+
* adapters must not expose it otherwise.
|
|
34
|
+
*/
|
|
35
|
+
channels: ChannelSurface;
|
|
36
|
+
}
|
|
@@ -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;
|
|
@@ -1,6 +1,30 @@
|
|
|
1
|
+
export interface FormatAgeOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Resolve below a minute ("42s ago") instead of flattening to "just now".
|
|
4
|
+
*
|
|
5
|
+
* Live-status surfaces need it: on a heartbeat or an activity feed the
|
|
6
|
+
* difference between five seconds and fifty is the signal, and minute
|
|
7
|
+
* granularity erases it. Everything under ten seconds still reads
|
|
8
|
+
* "just now" so a ticking feed does not flicker through 1s/2s/3s.
|
|
9
|
+
*/
|
|
10
|
+
precise?: boolean;
|
|
11
|
+
}
|
|
1
12
|
/** Human-readable relative time from an ISO timestamp */
|
|
2
|
-
export declare function formatAge(timestamp: string): string;
|
|
13
|
+
export declare function formatAge(timestamp: string, options?: FormatAgeOptions): string;
|
|
14
|
+
/**
|
|
15
|
+
* Human-readable absolute date+time with calendar awareness:
|
|
16
|
+
* "Today 3:45 PM" / "Yesterday 9:02 AM" / "Jan 5 3:45 PM", carrying the year
|
|
17
|
+
* only for prior-year timestamps (a bare "Jan 5" is ambiguous once runs and
|
|
18
|
+
* completions outlive the calendar). Falls back to the raw input if unparseable.
|
|
19
|
+
*/
|
|
20
|
+
export declare function formatDateTime(timestamp: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Human-readable elapsed duration from a millisecond count, rolling up through
|
|
23
|
+
* units ("850ms" / "42s" / "3m 5s" / "2h 5m" / "3d 2h"); null when undefined.
|
|
24
|
+
*/
|
|
25
|
+
export declare function formatDuration(ms?: number): string | null;
|
|
3
26
|
/** Human-readable file size */
|
|
4
27
|
export declare function formatSize(bytes: number): string;
|
|
5
28
|
/** Check if a heartbeat timestamp is stale (> 15 min) */
|
|
6
29
|
export declare function isStale(timestamp: string, thresholdMs?: number): boolean;
|
|
30
|
+
export { humanizeKey, formatStructured, summarizeStructured, unwrapToolResult, type FormatStructuredOptions, } from './format/structured';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Health observation builders — the ONE construction path for check
|
|
3
|
+
* output, shared by plugins (via `@makinbakin/sdk/utils`, which
|
|
4
|
+
* re-exports these) and adapter packages (which depend only on
|
|
5
|
+
* `@bakin/core`).
|
|
6
|
+
*
|
|
7
|
+
* The builders CLAMP copy to the health contract's bounds instead of
|
|
8
|
+
* letting an overlong or blank string invalidate the whole run: a check
|
|
9
|
+
* that interpolated a long runtime error into its summary used to fail
|
|
10
|
+
* contract validation wholesale, turning real evidence into a useless
|
|
11
|
+
* "could not be verified" card (field-diagnosed 2026-07-22). Truncated
|
|
12
|
+
* copy is honest; discarded evidence is not. Constructing observations
|
|
13
|
+
* as raw object literals bypasses this protection — always build through
|
|
14
|
+
* these helpers.
|
|
15
|
+
*/
|
|
16
|
+
import type { ErrorObservationInput, HealthNonEmptyArray, HealthObservationInput, HealthyObservationInput, NotApplicableHealthCheckRunInput, ObservedHealthCheckRunInput, UnknownObservationInput, WarningObservationInput } from '../plugin-types';
|
|
17
|
+
type HealthyObservationFields = Omit<HealthyObservationInput, 'status'>;
|
|
18
|
+
type WarningObservationFields = Omit<WarningObservationInput, 'status'>;
|
|
19
|
+
type ErrorObservationFields = Omit<ErrorObservationInput, 'status'>;
|
|
20
|
+
type UnknownObservationFields = Omit<UnknownObservationInput, 'status'>;
|
|
21
|
+
/** Build a healthy observation. Healthy observations cannot carry incidents. */
|
|
22
|
+
export declare function healthHealthy(input: HealthyObservationFields): HealthyObservationInput;
|
|
23
|
+
/** Build a warning observation with an explicit advisory/watch/action disposition. */
|
|
24
|
+
export declare function healthWarning(input: WarningObservationFields): WarningObservationInput;
|
|
25
|
+
/** Build an error observation. Its incident must require operator action. */
|
|
26
|
+
export declare function healthError(input: ErrorObservationFields): ErrorObservationInput;
|
|
27
|
+
/** Build an Unknown verification observation (watch, or advisory when it self-resolves). */
|
|
28
|
+
export declare function healthUnknown(input: UnknownObservationFields): UnknownObservationInput;
|
|
29
|
+
/** Build a successful observed run. Empty diagnostic output is unrepresentable. */
|
|
30
|
+
export declare function healthObserved(observations: HealthNonEmptyArray<HealthObservationInput>): ObservedHealthCheckRunInput;
|
|
31
|
+
/** Build an explicit successful not-applicable run. */
|
|
32
|
+
export declare function healthNotApplicable(reason: string): NotApplicableHealthCheckRunInput;
|
|
33
|
+
/**
|
|
34
|
+
* Deterministically coerce arbitrary text (a filesystem path, a table
|
|
35
|
+
* name, a task id) into the contract's stable resource-id format
|
|
36
|
+
* (`^[a-z0-9][a-z0-9._:-]{0,127}$`). A raw path used as a resource id
|
|
37
|
+
* failed contract validation and nuked a REAL finding into a generic
|
|
38
|
+
* "could not be verified" card for three releases (field-diagnosed
|
|
39
|
+
* 2026-07-23). Put the human-readable original in `label`, never in `id`.
|
|
40
|
+
*/
|
|
41
|
+
export declare function healthResourceId(raw: string): string;
|
|
42
|
+
export {};
|
|
@@ -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;
|