mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
* plugins: contributes.statusBarItems with worker updates (statusBar.update)
A plugin declares status bar items { id, text?, icon?, tone?, tooltip?,
command? } (declarative profile, engines >=1.4.247); pressing one runs
its own command. A trusted worker changes them with the new worker-only
host method statusBar.update; main keeps the session's changes and
pushes snapshots to desktop windows over plugins:statusBarChanged.
Regenerates schemas, references, typings and the authoring skill.
* plugins: statusBarItems ship in 1.4.248, beside contributes.hooks
* plugins: clear a plugin's status bar changes when it is disabled, removed or updated
* plugins: list status bar items in the plugin page's Adds section
* plugins: count statusBarItems' since in the host's newest readable version
* i18n: add the plugin page's status bar row label to en.json
* plugins: status bar items respect workspace commands, dev reloads and catalog summaries
- An item whose command needs a workspace is disabled with no open workspace.
- A dev code edit (new devRevision) drops the old worker's status bar changes.
- Catalog summaries list status bar items, and marketplace details show them.
* plugins: authoring skill lists status bar items as buildable; approval lists them
The skill no longer calls status bar items reserved and gains a row for them. The
dev-load/inspect approval already lists them via the contribution summary; a test pins
that and the fingerprint binding.
* chore(plugins): regenerate the testing bundle after rebasing on main
148 lines
5.7 KiB
TypeScript
148 lines
5.7 KiB
TypeScript
import { PLUGIN_WORKSPACE_TERMINAL_LIMIT } from '../../../shared/plugins/workers/plugin-host-api'
|
|
import type { PluginHostServices } from './plugin-host-methods'
|
|
import type { PluginDesktopFrameServices } from './plugin-host-method-bindings'
|
|
import type { PluginPanelBridgeServices } from './plugin-host-panel-method-bindings'
|
|
import type { PluginStatusBarState } from '../status-bar/plugin-status-bar-state'
|
|
import {
|
|
pluginSettingValueIssue,
|
|
type PluginSettingContribution
|
|
} from '../../../shared/plugins/contributions/plugin-settings-contribution'
|
|
import { pluginSettingDefaults } from '../../../shared/plugins/contributions/plugin-settings-values'
|
|
import { PluginSecretsStore, pluginSecretsProtection } from '../plugin-secrets-store'
|
|
import { PluginKvStore } from '../plugin-storage-store'
|
|
import type { TerminalInputKind } from '../../../shared/terminal-input-kind'
|
|
import { pluginTerminalTitle, type PluginAgentStatusRow } from './plugin-workspace-projection'
|
|
|
|
export type PluginRuntimeDelegate = {
|
|
resolveActiveWorktreeContext(): Promise<{
|
|
worktreeId: string
|
|
path: string
|
|
branch: string
|
|
displayName: string
|
|
} | null>
|
|
listTerminals(
|
|
worktreeSelector?: string,
|
|
limit?: number,
|
|
opts?: { includeVisualLayouts?: boolean }
|
|
): Promise<{
|
|
terminals: {
|
|
handle: string
|
|
title: string | null
|
|
paneTitle?: string
|
|
tabId?: string
|
|
leafId?: string
|
|
}[]
|
|
}>
|
|
sendTerminal(
|
|
handle: string,
|
|
action: { text?: string; enter?: boolean },
|
|
options: { inputKind: TerminalInputKind }
|
|
): Promise<{ accepted: boolean }>
|
|
dispatchPluginNotification(input: {
|
|
pluginId: string
|
|
title: string
|
|
body?: string
|
|
}): Promise<{ delivered: boolean }>
|
|
/** The hook server's agent rows; absent where no hook server runs. */
|
|
listAgentStatuses?(): readonly PluginAgentStatusRow[]
|
|
}
|
|
|
|
export function bindPluginHostServices(input: {
|
|
delegate: PluginRuntimeDelegate
|
|
pluginsDataDir: string
|
|
desktop?: PluginDesktopFrameServices | null
|
|
panels?: PluginPanelBridgeServices | null
|
|
/** The calling plugin's `contributes.settings`: defaults and value checks. */
|
|
declaredSettings?: readonly PluginSettingContribution[]
|
|
statusBar?: PluginStatusBarState | null
|
|
/** Ids of the calling plugin's `contributes.statusBarItems`, and its install's revision. */
|
|
declaredStatusBarItemIds?: readonly string[]
|
|
statusBarRevision?: string
|
|
}): PluginHostServices {
|
|
const declared = new Map((input.declaredSettings ?? []).map((setting) => [setting.key, setting]))
|
|
const { delegate, pluginsDataDir } = input
|
|
return {
|
|
desktop: input.desktop ?? null,
|
|
panels: input.panels ?? null,
|
|
statusBar: input.statusBar
|
|
? statusBarServices(input.statusBar, input.declaredStatusBarItemIds, input.statusBarRevision)
|
|
: null,
|
|
resolveActiveWorktreeContext: async () => {
|
|
const context = await delegate.resolveActiveWorktreeContext()
|
|
if (!context) {
|
|
return null
|
|
}
|
|
// Retain path-bearing worktree IDs for host membership checks; public projections exclude them.
|
|
return {
|
|
worktreeId: context.worktreeId,
|
|
branch: context.branch,
|
|
displayName: context.displayName
|
|
}
|
|
},
|
|
listWorktreeTerminals: async (worktreeId) => {
|
|
const result = await delegate.listTerminals(
|
|
`id:${worktreeId}`,
|
|
PLUGIN_WORKSPACE_TERMINAL_LIMIT,
|
|
{ includeVisualLayouts: false }
|
|
)
|
|
return result.terminals.slice(0, PLUGIN_WORKSPACE_TERMINAL_LIMIT).map((terminal) => ({
|
|
id: terminal.handle,
|
|
title: pluginTerminalTitle(terminal),
|
|
...(terminal.tabId && terminal.leafId
|
|
? { paneKey: `${terminal.tabId}:${terminal.leafId}` }
|
|
: {})
|
|
}))
|
|
},
|
|
listAgentStatuses: () => delegate.listAgentStatuses?.() ?? [],
|
|
sendTerminalText: async (terminalId, action) => {
|
|
const result = await delegate.sendTerminal(terminalId, action, { inputKind: 'driving' })
|
|
return { accepted: result.accepted }
|
|
},
|
|
dispatchPluginNotification: (notification) => delegate.dispatchPluginNotification(notification),
|
|
storage: {
|
|
get: (key, itemKey) => new PluginKvStore(pluginsDataDir, key, 'storage.json').get(itemKey),
|
|
set: (key, itemKey, value) =>
|
|
new PluginKvStore(pluginsDataDir, key, 'storage.json').set(itemKey, value),
|
|
delete: (key, itemKey) =>
|
|
new PluginKvStore(pluginsDataDir, key, 'storage.json').delete(itemKey),
|
|
keys: (key) => new PluginKvStore(pluginsDataDir, key, 'storage.json').keys()
|
|
},
|
|
secrets: {
|
|
get: (key, itemKey) => new PluginSecretsStore(pluginsDataDir, key).get(itemKey),
|
|
set: (key, itemKey, value) => new PluginSecretsStore(pluginsDataDir, key).set(itemKey, value),
|
|
delete: (key, itemKey) => new PluginSecretsStore(pluginsDataDir, key).delete(itemKey),
|
|
protection: () => (pluginSecretsProtection().level === 'os' ? 'os-keyring' : 'unavailable')
|
|
},
|
|
settings: {
|
|
getAll: (key) => ({
|
|
...pluginSettingDefaults(declared.values()),
|
|
...new PluginKvStore(pluginsDataDir, key, 'settings.json').getAll()
|
|
}),
|
|
set: (key, itemKey, value) => {
|
|
const setting = declared.get(itemKey)
|
|
const issue = setting ? pluginSettingValueIssue(setting, value) : null
|
|
return issue
|
|
? { ok: false, error: `${itemKey} ${issue}` }
|
|
: new PluginKvStore(pluginsDataDir, key, 'settings.json').set(itemKey, value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function statusBarServices(
|
|
state: PluginStatusBarState,
|
|
declaredIds: readonly string[] = [],
|
|
revision = ''
|
|
): NonNullable<PluginHostServices['statusBar']> {
|
|
const declared = new Set(declaredIds)
|
|
return {
|
|
update: (pluginKey, itemId, patch) => {
|
|
if (!declared.has(itemId)) {
|
|
return false
|
|
}
|
|
state.update(pluginKey, revision, itemId, patch)
|
|
return true
|
|
}
|
|
}
|
|
}
|