mirror of
https://github.com/stablyai/orca.git
synced 2026-11-15 18:37:24 +00:00
Plugins that track workspaces and terminals across Orca had to read the private runtime token or shell out to the CLI. Host API 1.7 gives them the same through consented methods: - workspace.readContext (and workspace.changed) carry `workspaceId`, the id workspace.list gives; workspace.created/removed and agent.status.changed add `workspaceListId` beside their existing raw `workspaceId`, which keeps its meaning. - workspace.list rows name their `projectId`; opt-in `includeStatus` joins each row's agent state, unread flag, live terminal count and last activity from worktree.ps. - project.list (workspace:read), terminal.list (workspace:read), terminal.focus (workspace:write, desktop only, steers only this window) and terminal.close (terminal:send, reports whether the process is known to have stopped). - Runtime refusals (unknown or ambiguous workspace, stale or exited terminal) reach plugins as fixed messages instead of runtime wording. - Consent copy for workspace:read, workspace:write and terminal:send says what they now allow; terminal.focus and terminal.close are audited by terminal id. - PLUGIN_SCHEMA_NEWEST_SINCE covers the editor typography and theme video floors it missed, and the provisional 1.7 floor, so development builds accept plugins requiring them.
73 lines
2.5 KiB
TypeScript
73 lines
2.5 KiB
TypeScript
import { z } from 'zod'
|
|
import {
|
|
pluginTerminalIdSchema,
|
|
pluginWorkspaceIdSchema
|
|
} from './plugin-host-api-workspace-methods'
|
|
import {
|
|
PLUGIN_WORKSPACE_LABEL_MAX_LENGTH,
|
|
PLUGIN_WORKSPACE_TERMINAL_LIMIT
|
|
} from './plugin-host-api-workspace-context'
|
|
import { spec, WORKER_ONLY } from './plugin-host-method-spec'
|
|
|
|
/** Terminals of any workspace, by the ids `terminal.read` and `terminal.sendText` take. Each runs
|
|
* the runtime method `orca terminal list|focus|close` runs, on the host that owns the terminal. */
|
|
|
|
const terminalListParams = z.strictObject({ workspaceId: pluginWorkspaceIdSchema })
|
|
const terminalListResult = z.object({
|
|
terminals: z
|
|
.array(
|
|
z.object({
|
|
id: pluginTerminalIdSchema,
|
|
/** The pane's name, or its terminal title; absent when it has neither. */
|
|
title: z.string().max(PLUGIN_WORKSPACE_LABEL_MAX_LENGTH).optional()
|
|
})
|
|
)
|
|
.max(PLUGIN_WORKSPACE_TERMINAL_LIMIT),
|
|
/** The workspace has more terminals than the list holds. */
|
|
truncated: z.boolean()
|
|
})
|
|
|
|
const terminalTargetParams = z.strictObject({ terminalId: pluginTerminalIdSchema })
|
|
const terminalFocusResult = z.object({ focused: z.literal(true) })
|
|
const terminalCloseResult = z.object({
|
|
closed: z.literal(true),
|
|
/** Nothing runs in the terminal any more. False when Orca could not confirm its process
|
|
* stopped: it may still run, as on an unreachable SSH host, where Orca stops it on reconnect. */
|
|
processExited: z.boolean()
|
|
})
|
|
|
|
export const PLUGIN_TERMINAL_ACTIONS_API = {
|
|
'terminal.list': spec({
|
|
summary: `Lists a workspace's terminals, at most ${PLUGIN_WORKSPACE_TERMINAL_LIMIT}; \`workspace.readContext\` lists the focused one's.`,
|
|
since: 7,
|
|
scope: 'any-workspace',
|
|
capability: 'workspace:read',
|
|
mutation: false,
|
|
surfaces: WORKER_ONLY,
|
|
params: terminalListParams,
|
|
result: terminalListResult
|
|
}),
|
|
'terminal.focus': spec({
|
|
summary:
|
|
"Shows a terminal's workspace and focuses its pane, as clicking it does; desktop app only.",
|
|
since: 7,
|
|
scope: 'explicit-terminal',
|
|
capability: 'workspace:write',
|
|
mutation: true,
|
|
surfaces: WORKER_ONLY,
|
|
params: terminalTargetParams,
|
|
result: terminalFocusResult
|
|
}),
|
|
'terminal.close': spec({
|
|
summary:
|
|
'Closes a terminal, stopping what runs in it (local or SSH), as `orca terminal close` does; closing its last pane closes the tab.',
|
|
since: 7,
|
|
scope: 'explicit-terminal',
|
|
capability: 'terminal:send',
|
|
mutation: true,
|
|
surfaces: WORKER_ONLY,
|
|
params: terminalTargetParams,
|
|
result: terminalCloseResult
|
|
})
|
|
}
|