mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 19:07:41 +00:00
* plugins: commands[].replaces lets a worker command take over a built-in action A worker command with replaces: <action> (the declarative action list, engines >=1.4.248, needs main) runs in place of that built-in from its shortcut, plugin aliases and the sidebar menus; a failed or silent (2 s) worker falls back to Orca's own. The install screen names each replacement, the plugin page has a per-action switch (settings.pluginReplacementsOff), and when two plugins replace one action the one installed first wins and the other's log says so. Update review counts replaces as new access. * fix(plugins): narrow replaced action ids before looking up their titles * plugins: harden command replaces after review - Consent includes the replaced actions, so adding replaces to a dev folder needs a new approval; CLI approval and update review name each takeover. - Shortcuts main intercepts (Tasks, Workspace Board, history), search with a selection and floating maximize now go through the replacement too. - A worker that only starts after the 2 s fallback no longer runs the command as well: main refuses to start it past the deadline. - A workspace-only command does not replace an action without a workspace. - An update keeps the plugin's first install time, so it keeps its takeover. - Drop the commands.run promise until Orca offers it. * plugins: commands.run always runs the built-in, never a replacement A5b's commands.run dispatches with the 'plugin-host' source; the app dispatcher now builds handlers that run Orca's own action for it, so a plugin that replaces an action and calls commands.run cannot loop. Docs and schema describe wrapping the built-in with commands.run; regenerated.
57 lines
2.4 KiB
TypeScript
57 lines
2.4 KiB
TypeScript
/** The plugin system's switches, approvals and dev paths, composed into GlobalSettings. */
|
|
export type PluginSystemSettings = {
|
|
/** Master switch for the plugin system. On by default; false means no
|
|
* discovery, no panels, no plugin code paths run at all. */
|
|
pluginSystemEnabled: boolean
|
|
/** One-shot guard for the default-on rollout: a saved false from the old
|
|
* default flips on once; later explicit false (e.g. policy) sticks. */
|
|
pluginSystemDefaultedOn?: boolean
|
|
/** Qualified plugin keys (`publisher.id`) the user disabled. Discovered
|
|
* plugins stay listed but are not activated. */
|
|
disabledPlugins: string[]
|
|
/** Consent records: qualified plugin key → capability/worker-trust fingerprint.
|
|
* A plugin whose current fingerprint differs is pending again, so an update
|
|
* crossing either trust boundary re-prompts before code runs. Absent key =
|
|
* never consented. */
|
|
pluginConsents: Record<string, string>
|
|
/** Local directories loaded as dev-mode plugins (manifest hot-reload). */
|
|
devPluginPaths: string[]
|
|
/** Built-in action ids the person keeps for Orca: no plugin command runs in their place. */
|
|
pluginReplacementsOff?: string[]
|
|
/** Qualified plugin key → hosts the person always allows its frames to open. Main-only. */
|
|
pluginExternalHostGrants?: Record<string, string[]>
|
|
}
|
|
|
|
type PluginSystemDefaultOnSettings = Pick<
|
|
PluginSystemSettings,
|
|
'pluginSystemEnabled' | 'pluginSystemDefaultedOn'
|
|
>
|
|
|
|
export function normalizePluginSystemEnabledDefaultOn(
|
|
settings: Partial<PluginSystemDefaultOnSettings> | undefined
|
|
): Required<PluginSystemDefaultOnSettings> {
|
|
return {
|
|
// Pre-rollout false was the old default, not an opt-out.
|
|
pluginSystemEnabled:
|
|
settings?.pluginSystemDefaultedOn === true ? settings.pluginSystemEnabled !== false : true,
|
|
pluginSystemDefaultedOn: true
|
|
}
|
|
}
|
|
|
|
/** Whether `plugin:<key>/<name>` content comes from a plugin that is switched off. */
|
|
export function isPluginContentSwitchedOff(
|
|
settings:
|
|
| Partial<Pick<PluginSystemSettings, 'pluginSystemEnabled' | 'disabledPlugins'>>
|
|
| undefined,
|
|
contentId: string
|
|
): boolean {
|
|
if (!contentId.startsWith('plugin:')) {
|
|
return false
|
|
}
|
|
const pluginKey = contentId.slice('plugin:'.length, contentId.lastIndexOf('/'))
|
|
return (
|
|
settings?.pluginSystemEnabled === false ||
|
|
(Array.isArray(settings?.disabledPlugins) && settings.disabledPlugins.includes(pluginKey))
|
|
)
|
|
}
|