mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
refactor(cli): organize command dispatch and orchestration owners (#41562)
* refactor(cli): organize command dispatch and orchestration owners * test(orchestration): retire superseded unbound mail refusal case
This commit is contained in:
@@ -97,7 +97,7 @@ jobs:
|
||||
src/main/computer/macos-native/macos-native-provider-client.test.ts
|
||||
src/main/providers/windows-shell-preflight-runtime.windows.test.ts
|
||||
src/main/computer/desktop-script/actions/desktop-script-provider-actions.test.ts
|
||||
src/cli/command-result-output.test.ts
|
||||
src/cli/output/command-result-output.test.ts
|
||||
src/cli/computer/computer-state-formatting.test.ts
|
||||
src/cli/index.test.ts
|
||||
src/cli/runtime/envelope-schema.test.ts
|
||||
|
||||
@@ -297,7 +297,7 @@
|
||||
1 test-no-real-time-wait:tests/e2e/markdown-table-row-backspace.spec.ts
|
||||
1 test-no-real-time-wait:tests/e2e/native-chat-history-prepend-anchor.spec.ts
|
||||
3 test-no-real-time-wait:tests/e2e/notification-sound-replay.spec.ts
|
||||
5 test-no-real-time-wait:tests/e2e/orchestration-idle-mail-delivery.spec.ts
|
||||
4 test-no-real-time-wait:tests/e2e/orchestration-idle-mail-delivery.spec.ts
|
||||
1 test-no-real-time-wait:tests/e2e/orchestration-idle-mail-restore.spec.ts
|
||||
4 test-no-real-time-wait:tests/e2e/paced-terminal-typing.ts
|
||||
1 test-no-real-time-wait:tests/e2e/paired-client-hosted-browser-double-restart.spec.ts
|
||||
@@ -716,7 +716,7 @@
|
||||
1 test-timeout-needs-reason:tests/e2e/markdown-review-selection-performance.spec.ts
|
||||
1 test-timeout-needs-reason:tests/e2e/mobile-subscribe-idle-hidden-pane-fit.spec.ts
|
||||
1 test-timeout-needs-reason:tests/e2e/orcad-serve-open-url-on-desktop.spec.ts
|
||||
10 test-timeout-needs-reason:tests/e2e/orchestration-idle-mail-delivery.spec.ts
|
||||
9 test-timeout-needs-reason:tests/e2e/orchestration-idle-mail-delivery.spec.ts
|
||||
1 test-timeout-needs-reason:tests/e2e/orchestration-idle-mail-restore.spec.ts
|
||||
1 test-timeout-needs-reason:tests/e2e/orchestration-legacy-worker-missing-terminal-recovery.spec.ts
|
||||
1 test-timeout-needs-reason:tests/e2e/orchestration-worker-settlement-release-cli.spec.ts
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
# Existing production source files importing child_process at runtime outside @orca/process-host.
|
||||
# Migration debt: this list may only shrink; new callers use the package public API.
|
||||
src/cli/handlers/core.ts
|
||||
src/cli/runtime/cli-lifecycle-handlers.ts
|
||||
src/cli/accounts/interactive-login-interruption.ts
|
||||
src/cli/runtime/launch.ts
|
||||
src/main/agent-hooks/installation/locking/managed-hook-owner-identity.ts
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# collector (file-wide). Not counted: destructuring off a global object, a self-rescheduling setTimeout (it must back off or pause while hidden).
|
||||
# This is a RATCHET: counts may only go DOWN.
|
||||
# Prune after removing intervals: pnpm check:recurring-timer-ratchet --prune
|
||||
1 src/cli/handlers/orchestration/check-keepalive.ts
|
||||
1 src/cli/orchestration/messages/check-keepalive.ts
|
||||
1 src/cli/runtime/mac-app-update-bundle.ts
|
||||
1 src/cli/runtime/serve-supervised-service.ts
|
||||
1 src/main/agent-hooks/server/server-opencode-binder.ts
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -492,7 +492,7 @@ export const PR_E2E_SOURCE_ROUTES = [
|
||||
matches: (file) =>
|
||||
file === 'tests/e2e/helpers/connector-fake-claude.ts' ||
|
||||
(isProductSource(file) &&
|
||||
/^src\/(?:main\/external-conversations\/|main\/runtime\/rpc\/methods\/connector\.ts$|cli\/(?:handlers|specs)\/connector\.ts$|shared\/rpc-contract\/connector-params\.ts$)/.test(
|
||||
/^src\/(?:main\/external-conversations\/|main\/runtime\/rpc\/methods\/connector\.ts$|cli\/(?:connectors|specs)\/connector\.ts$|shared\/rpc-contract\/connector-params\.ts$)/.test(
|
||||
file
|
||||
))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { HandlerContext } from '../dispatch'
|
||||
import { printResult } from '../command-result-output'
|
||||
import type { HandlerContext } from '../dispatch/dispatch'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import { ANTIGRAVITY_ACCOUNTS_RUNTIME_CAPABILITY } from '../../shared/account-runtime-capabilities'
|
||||
import type {
|
||||
|
||||
@@ -52,8 +52,8 @@ vi.mock('../../shared/windows-console-input', () => ({
|
||||
}))
|
||||
|
||||
import { ACCOUNT_HANDLERS } from './account'
|
||||
import { REPEATED_FLAG_SEPARATOR } from '../args'
|
||||
import type { HandlerContext } from '../dispatch'
|
||||
import { REPEATED_FLAG_SEPARATOR } from '../arguments/args'
|
||||
import type { HandlerContext } from '../dispatch/dispatch'
|
||||
import type { RuntimeClient } from '../runtime/client'
|
||||
import {
|
||||
ACCOUNT_IMPORT_RUNTIME_CAPABILITY,
|
||||
|
||||
@@ -2,11 +2,11 @@ import { spawnProcess } from '@orca/process-host'
|
||||
import { mkdtempSync, rmSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { delimiter, join } from 'node:path'
|
||||
import type { CommandHandler, HandlerContext } from '../dispatch'
|
||||
import { printResult } from '../command-result-output'
|
||||
import type { CommandHandler, HandlerContext } from '../dispatch/dispatch'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import { stripElectronRunAsNode } from '../runtime/orca-app-executable'
|
||||
import { rejectRemoteSelectionFlags } from '../remote-selection-flag-rejection'
|
||||
import { rejectRemoteSelectionFlags } from '../dispatch/remote-selection-flag-rejection'
|
||||
import { buildWslExecArgs, buildWslLoginShellCommand } from '../../shared/wsl-login-shell-command'
|
||||
import { quotePosixShell } from '../../shared/shell/launch/shell-argument-quoting'
|
||||
import { isWindowsFnmDefaultAliasDir } from '../../shared/fnm-default-alias-dirs'
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { mkdtempSync, rmSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import type { HandlerContext } from '../dispatch'
|
||||
import { REPEATED_FLAG_SEPARATOR } from '../args'
|
||||
import { printResult } from '../command-result-output'
|
||||
import type { HandlerContext } from '../dispatch/dispatch'
|
||||
import { REPEATED_FLAG_SEPARATOR } from '../arguments/args'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import { DATA_ACCOUNT_RUNTIME_CAPABILITY } from '../../shared/account-runtime-capabilities'
|
||||
import type { RuntimeStatus } from '../../shared/runtime-session-contracts'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { join } from 'node:path'
|
||||
import type { CommandHandler } from '../dispatch'
|
||||
import { printResult } from '../command-result-output'
|
||||
import { rejectRemoteSelectionFlags } from '../remote-selection-flag-rejection'
|
||||
import type { CommandHandler } from '../dispatch/dispatch'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import { rejectRemoteSelectionFlags } from '../dispatch/remote-selection-flag-rejection'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import type { RuntimeClient } from '../runtime/client'
|
||||
import type { RuntimeRpcSuccess } from '../../shared/runtime-rpc-envelope'
|
||||
@@ -30,7 +30,7 @@ async function getSettingsPath(): Promise<string> {
|
||||
}
|
||||
|
||||
async function getProfileStateLocation(): Promise<ProfileStateOfflineLocation | undefined> {
|
||||
const { getActiveProfileStateLocation } = await import('../profile-state-location.js')
|
||||
const { getActiveProfileStateLocation } = await import('../profiles/profile-state-location.js')
|
||||
return getActiveProfileStateLocation()
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { classifyAgentLaunchReplayRefusal } from '../../shared/agent-launch/cont
|
||||
import {
|
||||
recoverableOrchestrationArgs,
|
||||
resolveOrchestrationCliExecutable
|
||||
} from '../runtime/orchestration-recovery-command'
|
||||
} from '../orchestration/recovery/orchestration-recovery-command'
|
||||
|
||||
/** A lost reply never authorizes a new launch, even on hosts without a replay ledger. */
|
||||
export async function withCliAgentLaunchRecovery<T>(
|
||||
|
||||
@@ -27,7 +27,7 @@ import {
|
||||
getRequiredStringFlag,
|
||||
getRequiredStringFlagAllowingEmpty,
|
||||
rejectValuelessFlag
|
||||
} from '../flags'
|
||||
} from '../arguments/flags'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import type { RuntimeClient } from '../runtime/client'
|
||||
import type { RuntimeRpcSuccess } from '../../shared/runtime-rpc-envelope'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { AGENT_LAUNCH_RUNTIME_CAPABILITIES } from '../../shared/agent-launch/contracts/agent-launch-runtime-capability'
|
||||
import { okFixture } from '../test-fixtures'
|
||||
import { okFixture } from '../runtime/fixtures/runtime-rpc-fixtures'
|
||||
|
||||
export function agentLaunchHostFixture() {
|
||||
return okFixture('req_status', { capabilities: [...AGENT_LAUNCH_RUNTIME_CAPABILITIES] })
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { CommandHandler } from '../dispatch'
|
||||
import type { CommandHandler } from '../dispatch/dispatch'
|
||||
import {
|
||||
callAgentLaunch,
|
||||
formatAgentLaunch,
|
||||
@@ -6,8 +6,8 @@ import {
|
||||
parseCliAgent,
|
||||
readCliAgentLaunch
|
||||
} from './agent-launch-request'
|
||||
import { getRequiredStringFlag } from '../flags'
|
||||
import { printResult } from '../command-result-output'
|
||||
import { getRequiredStringFlag } from '../arguments/flags'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import {
|
||||
getRequiredWorktreeSelector,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { CommandHandler } from '../dispatch'
|
||||
import { getPresentStringFlag, getRequiredStringFlag } from '../flags'
|
||||
import { printResult } from '../command-result-output'
|
||||
import type { CommandHandler } from '../dispatch/dispatch'
|
||||
import { getPresentStringFlag, getRequiredStringFlag } from '../arguments/flags'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import { readInjectedAgentSessionId } from '../../shared/agent-session/lifecycle/agent-session-caller-env'
|
||||
|
||||
|
||||
+2
-24
@@ -1,11 +1,6 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
parseArgs,
|
||||
validateCommandAndFlags,
|
||||
REPEATED_FLAG_SEPARATOR,
|
||||
specPaths,
|
||||
type CommandSpec
|
||||
} from './args'
|
||||
import { parseArgs, validateCommandAndFlags } from './args'
|
||||
import { specPaths, type CommandSpec } from '../discovery/command-spec'
|
||||
|
||||
const leaf: CommandSpec = {
|
||||
path: ['example', 'search'],
|
||||
@@ -30,22 +25,11 @@ function flags(argv: string[]) {
|
||||
}
|
||||
|
||||
describe('command-scoped repeatable flags', () => {
|
||||
it.each(specPaths(leaf))('keeps values before and between %s %s command words', (...path) => {
|
||||
const parsed = flags(['--agent', 'a', path[0], '--agent=b', path[1], '--agent', 'c'])
|
||||
expect(parsed.get('agent')).toBe(['a', 'b', 'c'].join(REPEATED_FLAG_SEPARATOR))
|
||||
})
|
||||
|
||||
it('uses the leaf rules for all flags even when the parent has different rules', () => {
|
||||
const parsed = flags(['--path', '/a', 'example', '--path', '/b', 'search', '--path', '/c'])
|
||||
expect(parsed.get('path')).toBe('/c')
|
||||
})
|
||||
|
||||
it('still uses the parent rules when the parent itself is invoked', () => {
|
||||
expect(flags(['--path', '/a', 'example', '--path=/b']).get('path')).toBe(
|
||||
['/a', '/b'].join(REPEATED_FLAG_SEPARATOR)
|
||||
)
|
||||
})
|
||||
|
||||
it.each([
|
||||
['--agent', '--agent=b'],
|
||||
['--agent=a', '--agent', '--agent=b'],
|
||||
@@ -65,10 +49,4 @@ describe('command-scoped repeatable flags', () => {
|
||||
`Flag --${flag} requires a value.`
|
||||
)
|
||||
})
|
||||
|
||||
it('preserves empty values and equals signs without reinterpreting flag-like values', () => {
|
||||
expect(
|
||||
flags(['example', 'search', '--agent=', '--agent=--help', '--agent=a=b']).get('agent')
|
||||
).toBe(['', '--help', 'a=b'].join(REPEATED_FLAG_SEPARATOR))
|
||||
})
|
||||
})
|
||||
@@ -1,8 +1,7 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import type { CommandSpec } from './args'
|
||||
import type { CommandSpec } from '../discovery/command-spec'
|
||||
import {
|
||||
REPEATED_FLAG_SEPARATOR,
|
||||
findCommandSpec,
|
||||
normalizeCommandPositionals,
|
||||
parseArgs,
|
||||
@@ -153,12 +152,6 @@ describe('parseArgs', () => {
|
||||
expect(parsed.positionalFlagConflicts).toEqual([])
|
||||
})
|
||||
|
||||
it('preserves repeated string flags', () => {
|
||||
const parsed = parseArgs(['linear', 'label', 'add', '--label', 'Bug', '--label=Regression'])
|
||||
|
||||
expect(parsed.flags.get('label')).toBe(`Bug${REPEATED_FLAG_SEPARATOR}Regression`)
|
||||
})
|
||||
|
||||
it('does not apply repeated flag encoding to ordinary string flags', () => {
|
||||
const parsed = parseArgs(['linear', 'list', '--workspace', 'old', '--workspace', 'new'])
|
||||
|
||||
@@ -219,19 +212,6 @@ describe('validateCommandAndFlags', () => {
|
||||
}
|
||||
]
|
||||
|
||||
it('allows global runtime selector flags even when the command spec omits them', () => {
|
||||
const parsed = parseArgs([
|
||||
'demo',
|
||||
'--pairing-code',
|
||||
'remote-runtime',
|
||||
'--environment',
|
||||
'server',
|
||||
'--json'
|
||||
])
|
||||
|
||||
expect(() => validateCommandAndFlags(specs, parsed)).not.toThrow()
|
||||
})
|
||||
|
||||
it.each(['environment', 'pairing-code'])('rejects --%s without a value', (flag) => {
|
||||
const parsed = parseArgs([`--${flag}`, 'demo'], [['demo']])
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
import { RuntimeClientError } from './runtime/types'
|
||||
import { unknownCommandData, unknownFlagData } from './command-suggestion'
|
||||
import { specPaths, type CommandSpec } from './command-spec'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import { unknownCommandData, unknownFlagData } from '../discovery/command-suggestion'
|
||||
import { specPaths, type CommandSpec } from '../discovery/command-spec'
|
||||
import {
|
||||
CLI_BOOLEAN_FLAGS,
|
||||
CLI_GLOBAL_FLAGS,
|
||||
CLI_GLOBAL_VALUE_FLAGS,
|
||||
findCliCommandIndex
|
||||
} from '../shared/cli-argument-boundary'
|
||||
|
||||
export { specPaths }
|
||||
export type { CommandSpec }
|
||||
} from '../../shared/cli-argument-boundary'
|
||||
|
||||
export type ParsedArgs = {
|
||||
commandPath: string[]
|
||||
@@ -17,11 +14,11 @@ export type ParsedArgs = {
|
||||
positionalFlagConflicts?: string[]
|
||||
}
|
||||
|
||||
export const GLOBAL_FLAGS = CLI_GLOBAL_FLAGS
|
||||
const GLOBAL_FLAGS = CLI_GLOBAL_FLAGS
|
||||
const GLOBAL_VALUE_FLAGS = new Set(CLI_GLOBAL_VALUE_FLAGS)
|
||||
/** Global flags a local-only command offers; it still accepts the remote selectors, only to refuse them. */
|
||||
export const LOCAL_COMMAND_FLAGS = GLOBAL_FLAGS.filter((flag) => !GLOBAL_VALUE_FLAGS.has(flag))
|
||||
export const BOOLEAN_FLAGS = CLI_BOOLEAN_FLAGS
|
||||
const BOOLEAN_FLAGS = CLI_BOOLEAN_FLAGS
|
||||
|
||||
export const REPEATED_FLAG_SEPARATOR = '\u0000'
|
||||
const REPEATABLE_STRING_FLAGS = new Set(['label', 'skill'])
|
||||
@@ -1,7 +1,7 @@
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import { isAbsolute, join } from 'node:path'
|
||||
import { getRequiredStringFlag, getRequiredStringFlagAllowingEmpty } from './flags'
|
||||
import { RuntimeClientError } from './runtime-client'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
|
||||
type BodyOptions = {
|
||||
required: boolean
|
||||
@@ -1,7 +1,7 @@
|
||||
import { RuntimeClientError } from './runtime/types'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import { REPEATED_FLAG_SEPARATOR } from './args'
|
||||
import { describeQuoteStrippedJsonFlag } from './quote-stripped-json-flag'
|
||||
import type { RepoKind } from '../shared/repo-types'
|
||||
import type { RepoKind } from '../../shared/repo-types'
|
||||
|
||||
export function getOptionalRepoKind(flags: Map<string, string | boolean>): RepoKind | undefined {
|
||||
const kind = getOptionalStringFlag(flags, 'kind')
|
||||
@@ -1,4 +1,4 @@
|
||||
import { quotePosixShell } from '../shared/shell/launch/shell-argument-quoting'
|
||||
import { quotePosixShell } from '../../shared/shell/launch/shell-argument-quoting'
|
||||
|
||||
export function quoteCliCommandArgument(value: string): string {
|
||||
if (/^[a-zA-Z0-9._:/@-]+$/.test(value)) {
|
||||
@@ -17,11 +17,11 @@ import {
|
||||
ARTIFACT_SHARING_DISABLED_MESSAGE,
|
||||
ARTIFACT_SHARING_DISABLED_NEXT_STEPS
|
||||
} from '../../shared/artifacts/artifact-sharing-gate'
|
||||
import type { CommandHandler, HandlerContext } from '../dispatch'
|
||||
import { rejectRemoteSelectionFlags } from '../remote-selection-flag-rejection'
|
||||
import type { CommandHandler, HandlerContext } from '../dispatch/dispatch'
|
||||
import { rejectRemoteSelectionFlags } from '../dispatch/remote-selection-flag-rejection'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import { formatArtifactListPage, formatArtifactShared } from './artifact-format'
|
||||
import { printResult } from '../command-result-output'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
|
||||
function stringFlag(ctx: HandlerContext, name: string): string | undefined {
|
||||
const value = ctx.flags.get(name)
|
||||
|
||||
@@ -7,7 +7,7 @@ import type { AutomationOwnerPrecondition } from '../../shared/automations/owner
|
||||
import { getAutomationLegacyRepoId } from '../../shared/automations/history/automation-run-identity'
|
||||
import { formatAutomationPrecheckTimeout } from '../../shared/automations/launch/automation-precheck'
|
||||
import { formatAutomationSchedule } from '../../shared/automations/scheduling/automation-schedules'
|
||||
import { quoteCliCommandArgument } from '../shell-command-quote'
|
||||
import { quoteCliCommandArgument } from '../arguments/shell-command-quote'
|
||||
|
||||
export type AutomationListPayload = {
|
||||
automations: Automation[]
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
getOptionalPositiveIntegerFlag,
|
||||
getOptionalStringFlag,
|
||||
getRequiredStringFlag
|
||||
} from '../flags'
|
||||
} from '../arguments/flags'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
|
||||
const PRESET_TRIGGERS = new Set<AutomationSchedulePreset>(['hourly', 'daily', 'weekdays', 'weekly'])
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
} from '../../shared/work-items/task-source-context'
|
||||
import type { AutomationDestination } from '../../shared/automations/ownership/automation-owner-precondition'
|
||||
import type { ProjectHostSetup } from '../../shared/project-types'
|
||||
import type { CommandHandler } from '../dispatch'
|
||||
import type { CommandHandler } from '../dispatch/dispatch'
|
||||
import {
|
||||
formatAutomationList,
|
||||
formatAutomationRemoved,
|
||||
@@ -20,12 +20,12 @@ import {
|
||||
formatAutomationShow,
|
||||
type AutomationShowPayload
|
||||
} from './automation-format'
|
||||
import { printResult } from '../command-result-output'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import {
|
||||
getOptionalPositiveIntegerFlag,
|
||||
getOptionalStringFlag,
|
||||
getRequiredStringFlag
|
||||
} from '../flags'
|
||||
} from '../arguments/flags'
|
||||
import { resolveAutomationDestination, routeAutomationCreate } from './automation-destination'
|
||||
import {
|
||||
AUTOMATION_RUNS_PAGE_SIZE,
|
||||
|
||||
@@ -7,9 +7,9 @@ import type {
|
||||
BrowserInterceptedRequest,
|
||||
BrowserNetworkLogResult
|
||||
} from '../../shared/browser/runtime/runtime-browser-contracts'
|
||||
import type { CommandHandler } from '../dispatch'
|
||||
import { printResult } from '../command-result-output'
|
||||
import { getOptionalPositiveIntegerFlag, getOptionalStringFlag } from '../flags'
|
||||
import type { CommandHandler } from '../dispatch/dispatch'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import { getOptionalPositiveIntegerFlag, getOptionalStringFlag } from '../arguments/flags'
|
||||
import { getBrowserCommandTarget } from './browser-command-target'
|
||||
|
||||
export const BROWSER_CAPTURE_HANDLERS: Record<string, CommandHandler> = {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { BROWSER_EXPECT_URL_RUNTIME_CAPABILITY } from '../../shared/browser/runtime/browser-runtime-capabilities'
|
||||
import type { RuntimeStatus } from '../../shared/runtime-types'
|
||||
import { getOptionalStringFlag, getPresentStringFlag } from '../flags'
|
||||
import type { RuntimeClient } from '../runtime-client'
|
||||
import { getOptionalStringFlag, getPresentStringFlag } from '../arguments/flags'
|
||||
import type { RuntimeClient } from '../runtime/client'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import { assertLocalCwdWorktreeSelector } from '../hosts/local-environment-selector'
|
||||
import {
|
||||
|
||||
@@ -3,13 +3,13 @@ import type {
|
||||
BrowserCookieGetResult,
|
||||
BrowserCookieSetResult
|
||||
} from '../../shared/browser/runtime/runtime-browser-contracts'
|
||||
import type { CommandHandler } from '../dispatch'
|
||||
import { printResult } from '../command-result-output'
|
||||
import type { CommandHandler } from '../dispatch/dispatch'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import {
|
||||
getOptionalStringFlag,
|
||||
getRequiredStringFlag,
|
||||
getRequiredStringFlagAllowingEmpty
|
||||
} from '../flags'
|
||||
} from '../arguments/flags'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import { getBrowserCommandTarget } from './browser-command-target'
|
||||
|
||||
|
||||
@@ -1,49 +1,17 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import type * as RuntimeTypes from '../runtime/types'
|
||||
|
||||
const callMock = vi.fn()
|
||||
|
||||
vi.mock('../runtime/types', () => {
|
||||
class RuntimeClientError extends Error {
|
||||
readonly code: string
|
||||
|
||||
constructor(code: string, message: string) {
|
||||
super(message)
|
||||
this.code = code
|
||||
}
|
||||
}
|
||||
|
||||
class RuntimeRpcFailureError extends RuntimeClientError {
|
||||
readonly response: unknown
|
||||
|
||||
constructor(response: unknown) {
|
||||
super('runtime_error', 'runtime_error')
|
||||
this.response = response
|
||||
}
|
||||
}
|
||||
|
||||
return { RuntimeClientError, RuntimeRpcFailureError }
|
||||
})
|
||||
|
||||
vi.mock('../runtime-client', async () => {
|
||||
vi.mock('../runtime/client', () => {
|
||||
class RuntimeClient {
|
||||
call = callMock
|
||||
getCliStatus = vi.fn()
|
||||
openOrca = vi.fn()
|
||||
}
|
||||
|
||||
const { RuntimeClientError, RuntimeRpcFailureError } =
|
||||
await vi.importMock<typeof RuntimeTypes>('../runtime/types')
|
||||
|
||||
return {
|
||||
RuntimeClient,
|
||||
RuntimeClientError,
|
||||
RuntimeRpcFailureError
|
||||
}
|
||||
return { RuntimeClient }
|
||||
})
|
||||
|
||||
import { main } from '../index'
|
||||
import { okFixture, queueFixtures } from '../test-fixtures'
|
||||
|
||||
describe('orca cli storage set preserves an empty value', () => {
|
||||
beforeEach(() => {
|
||||
@@ -55,57 +23,7 @@ describe('orca cli storage set preserves an empty value', () => {
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
it('passes an empty --value through to browser.storage.local.set', async () => {
|
||||
queueFixtures(callMock, okFixture('req_storage_local_set', { success: true }))
|
||||
vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
|
||||
await main(
|
||||
['storage', 'local', 'set', '--key', 'flag', '--value', '', '--worktree', 'all', '--json'],
|
||||
'/tmp/not-an-orca-worktree'
|
||||
)
|
||||
|
||||
expect(callMock).toHaveBeenCalledTimes(1)
|
||||
expect(callMock).toHaveBeenCalledWith('browser.storage.local.set', {
|
||||
key: 'flag',
|
||||
value: '',
|
||||
worktree: undefined
|
||||
})
|
||||
})
|
||||
|
||||
it('passes an empty --value through to browser.storage.session.set', async () => {
|
||||
queueFixtures(callMock, okFixture('req_storage_session_set', { success: true }))
|
||||
vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
|
||||
await main(
|
||||
['storage', 'session', 'set', '--key', 'flag', '--value', '', '--worktree', 'all', '--json'],
|
||||
'/tmp/not-an-orca-worktree'
|
||||
)
|
||||
|
||||
expect(callMock).toHaveBeenCalledTimes(1)
|
||||
expect(callMock).toHaveBeenCalledWith('browser.storage.session.set', {
|
||||
key: 'flag',
|
||||
value: '',
|
||||
worktree: undefined
|
||||
})
|
||||
})
|
||||
|
||||
// PowerShell 5.1 drops empty native arguments; equals form preserves them.
|
||||
it('passes an empty --value= (equals form) through to browser.storage.local.set', async () => {
|
||||
queueFixtures(callMock, okFixture('req_storage_local_set', { success: true }))
|
||||
vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
|
||||
await main(
|
||||
['storage', 'local', 'set', '--key=flag', '--value=', '--worktree', 'all', '--json'],
|
||||
'/tmp/not-an-orca-worktree'
|
||||
)
|
||||
|
||||
expect(callMock).toHaveBeenCalledTimes(1)
|
||||
expect(callMock).toHaveBeenCalledWith('browser.storage.local.set', {
|
||||
key: 'flag',
|
||||
value: '',
|
||||
worktree: undefined
|
||||
})
|
||||
})
|
||||
|
||||
it('still rejects an empty --key before RPC dispatch', async () => {
|
||||
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
|
||||
@@ -150,40 +68,6 @@ describe('orca cli cookie set and set credentials preserve an empty value', () =
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
it('passes an empty --value through to browser.cookie.set', async () => {
|
||||
queueFixtures(callMock, okFixture('req_cookie_set', { success: true }))
|
||||
vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
|
||||
await main(
|
||||
['cookie', 'set', '--name', 'sid', '--value', '', '--worktree', 'all', '--json'],
|
||||
'/tmp/not-an-orca-worktree'
|
||||
)
|
||||
|
||||
expect(callMock).toHaveBeenCalledTimes(1)
|
||||
expect(callMock).toHaveBeenCalledWith('browser.cookie.set', {
|
||||
name: 'sid',
|
||||
value: '',
|
||||
worktree: undefined
|
||||
})
|
||||
})
|
||||
|
||||
it('passes an empty --pass through to browser.setCredentials', async () => {
|
||||
queueFixtures(callMock, okFixture('req_set_credentials', { success: true }))
|
||||
vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
|
||||
await main(
|
||||
['set', 'credentials', '--user', 'token', '--pass', '', '--worktree', 'all', '--json'],
|
||||
'/tmp/not-an-orca-worktree'
|
||||
)
|
||||
|
||||
expect(callMock).toHaveBeenCalledTimes(1)
|
||||
expect(callMock).toHaveBeenCalledWith('browser.setCredentials', {
|
||||
user: 'token',
|
||||
pass: '',
|
||||
worktree: undefined
|
||||
})
|
||||
})
|
||||
|
||||
it('still rejects an empty --name before RPC dispatch', async () => {
|
||||
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
|
||||
const priorExitCode = process.exitCode
|
||||
@@ -216,34 +100,3 @@ describe('orca cli cookie set and set credentials preserve an empty value', () =
|
||||
process.exitCode = priorExitCode
|
||||
})
|
||||
})
|
||||
|
||||
describe('orca cli fill and select preserve an empty value', () => {
|
||||
beforeEach(() => {
|
||||
callMock.mockReset()
|
||||
process.exitCode = undefined
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
it.each([
|
||||
['fill', 'browser.fill', { filled: 'ref_1' }],
|
||||
['select', 'browser.select', { selected: 'ref_1' }]
|
||||
])('passes an empty --value through %s to %s', async (command, method, result) => {
|
||||
queueFixtures(callMock, okFixture(`req_${command}`, result))
|
||||
vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
|
||||
await main(
|
||||
[command, '--element', 'ref_1', '--value', '', '--worktree', 'all', '--json'],
|
||||
'/tmp/not-an-orca-worktree'
|
||||
)
|
||||
|
||||
expect(callMock).toHaveBeenCalledTimes(1)
|
||||
expect(callMock).toHaveBeenCalledWith(method, {
|
||||
element: 'ref_1',
|
||||
value: '',
|
||||
worktree: undefined
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -2,15 +2,15 @@ import type {
|
||||
BrowserGeolocationResult,
|
||||
BrowserViewportResult
|
||||
} from '../../shared/browser/runtime/runtime-browser-contracts'
|
||||
import type { CommandHandler } from '../dispatch'
|
||||
import { printResult } from '../command-result-output'
|
||||
import type { CommandHandler } from '../dispatch/dispatch'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import {
|
||||
getOptionalStringFlag,
|
||||
getRequiredFiniteNumber,
|
||||
getRequiredPositiveNumber,
|
||||
getRequiredStringFlag,
|
||||
getRequiredStringFlagAllowingEmpty
|
||||
} from '../flags'
|
||||
} from '../arguments/flags'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import { getBrowserCommandTarget } from './browser-command-target'
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ const { callMock, runtimeClientConstructorMock, serveOrcaAppMock, getDefaultUser
|
||||
getDefaultUserDataPathMock: vi.fn(() => '/tmp/orca-user-data')
|
||||
}))
|
||||
|
||||
vi.mock('../runtime-client', async () => {
|
||||
vi.mock('../runtime/client', async () => {
|
||||
const { createRuntimeClientModuleMock } = await import('../index-test-harness.js')
|
||||
return createRuntimeClientModuleMock({
|
||||
callMock,
|
||||
@@ -18,62 +18,24 @@ vi.mock('../runtime-client', async () => {
|
||||
})
|
||||
})
|
||||
|
||||
vi.mock('../runtime/launch', async (importOriginal) => ({
|
||||
...(await importOriginal<Record<string, unknown>>()),
|
||||
serveOrcaApp: serveOrcaAppMock
|
||||
}))
|
||||
|
||||
vi.mock('../runtime/metadata', async (importOriginal) => ({
|
||||
...(await importOriginal<Record<string, unknown>>()),
|
||||
getDefaultUserDataPath: getDefaultUserDataPathMock
|
||||
}))
|
||||
|
||||
import { BROWSER_EXPECT_URL_RUNTIME_CAPABILITY } from '../../shared/browser/runtime/browser-runtime-capabilities'
|
||||
import { RPC_PARAMS_BY_METHOD } from '../../shared/rpc-contract/rpc-params-catalog.generated'
|
||||
|
||||
import { main } from '../index'
|
||||
import { okFixture } from '../test-fixtures'
|
||||
import { okFixture } from '../runtime/fixtures/runtime-rpc-fixtures'
|
||||
|
||||
const EXPECT_URL = 'https://example.com/chat/a'
|
||||
|
||||
// Every guarded command, with arguments that reach its RPC and the RPC it must carry the URL on.
|
||||
const GUARDED_COMMANDS: Record<
|
||||
string,
|
||||
{ args: string[]; method: keyof typeof RPC_PARAMS_BY_METHOD }
|
||||
> = {
|
||||
back: { args: [], method: 'browser.back' },
|
||||
check: { args: ['--element', '@e1'], method: 'browser.check' },
|
||||
clear: { args: ['--element', '@e1'], method: 'browser.clear' },
|
||||
click: { args: ['--element', '@e1'], method: 'browser.click' },
|
||||
dblclick: { args: ['--element', '@e1'], method: 'browser.dblclick' },
|
||||
'dialog accept': { args: [], method: 'browser.dialogAccept' },
|
||||
'dialog dismiss': { args: [], method: 'browser.dialogDismiss' },
|
||||
download: { args: ['--selector', '@e1', '--path', '/tmp/f'], method: 'browser.download' },
|
||||
drag: { args: ['--from', '@e1', '--to', '@e2'], method: 'browser.drag' },
|
||||
eval: { args: ['--expression', '1'], method: 'browser.eval' },
|
||||
fill: { args: ['--element', '@e1', '--value', 'x'], method: 'browser.fill' },
|
||||
find: {
|
||||
args: ['--locator', 'role', '--value', 'button', '--action', 'click'],
|
||||
method: 'browser.find'
|
||||
},
|
||||
focus: { args: ['--element', '@e1'], method: 'browser.focus' },
|
||||
forward: { args: [], method: 'browser.forward' },
|
||||
goto: { args: ['--url', 'https://example.com/b'], method: 'browser.goto' },
|
||||
hover: { args: ['--element', '@e1'], method: 'browser.hover' },
|
||||
inserttext: { args: ['--text', 'x'], method: 'browser.keyboardInsertText' },
|
||||
keypress: { args: ['--key', 'Enter'], method: 'browser.keypress' },
|
||||
'mouse down': { args: [], method: 'browser.mouseDown' },
|
||||
'mouse move': { args: ['--x', '1', '--y', '2'], method: 'browser.mouseMove' },
|
||||
'mouse up': { args: [], method: 'browser.mouseUp' },
|
||||
'mouse wheel': { args: ['--dy', '1'], method: 'browser.mouseWheel' },
|
||||
reload: { args: [], method: 'browser.reload' },
|
||||
scroll: { args: ['--direction', 'down'], method: 'browser.scroll' },
|
||||
scrollintoview: { args: ['--element', '@e1'], method: 'browser.scrollIntoView' },
|
||||
select: { args: ['--element', '@e1', '--value', 'x'], method: 'browser.select' },
|
||||
'select-all': { args: ['--element', '@e1'], method: 'browser.selectAll' },
|
||||
'storage local clear': { args: [], method: 'browser.storage.local.clear' },
|
||||
'storage local set': {
|
||||
args: ['--key', 'k', '--value', 'v'],
|
||||
method: 'browser.storage.local.set'
|
||||
},
|
||||
'storage session clear': { args: [], method: 'browser.storage.session.clear' },
|
||||
'storage session set': {
|
||||
args: ['--key', 'k', '--value', 'v'],
|
||||
method: 'browser.storage.session.set'
|
||||
},
|
||||
type: { args: ['--input', 'x'], method: 'browser.type' },
|
||||
uncheck: { args: ['--element', '@e1'], method: 'browser.check' },
|
||||
upload: { args: ['--element', '@e1', '--files', '/tmp/f'], method: 'browser.upload' }
|
||||
}
|
||||
|
||||
function answerRuntime(capabilities: string[]): void {
|
||||
callMock.mockImplementation(async (method: string) =>
|
||||
@@ -96,24 +58,6 @@ describe('--expect-url', () => {
|
||||
process.exitCode = undefined
|
||||
})
|
||||
|
||||
it.each(Object.entries(GUARDED_COMMANDS))(
|
||||
'%s sends the URL on an RPC whose schema keeps it',
|
||||
async (path, { args, method }) => {
|
||||
answerRuntime([BROWSER_EXPECT_URL_RUNTIME_CAPABILITY])
|
||||
|
||||
await main(
|
||||
[...path.split(' '), ...args, '--page', 'page-1', '--expect-url', EXPECT_URL, '--json'],
|
||||
'/tmp/not-an-orca-worktree'
|
||||
)
|
||||
|
||||
const call = callMock.mock.calls.find(([called]) => called === method)
|
||||
expect(call?.[1]).toMatchObject({ page: 'page-1', expectUrl: EXPECT_URL })
|
||||
expect(RPC_PARAMS_BY_METHOD[method]?.parse(call?.[1])).toMatchObject({
|
||||
expectUrl: EXPECT_URL
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
it('refuses before acting when the runtime would drop the field', async () => {
|
||||
answerRuntime(['runtime.v1'])
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ import type {
|
||||
BrowserExtensionSummaryListResult,
|
||||
BrowserExtensionReloadResult
|
||||
} from '../../shared/browser/extensions/browser-extension-types'
|
||||
import type { CommandHandler } from '../dispatch'
|
||||
import { getPresentStringFlag } from '../flags'
|
||||
import { printResult } from '../command-result-output'
|
||||
import type { CommandHandler } from '../dispatch/dispatch'
|
||||
import { getPresentStringFlag } from '../arguments/flags'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import { resolveRepoPathArgument } from '../projects/repo-path-arguments'
|
||||
|
||||
export const BROWSER_EXTENSION_HANDLERS: Record<string, CommandHandler> = {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { readBrowserActionEffects } from '../../shared/browser-action-effects'
|
||||
import { formatBrowserPasskeyRequest } from '../../shared/browser-passkey-request'
|
||||
import { writeCliScreenshotTempFile } from '../cli-screenshot-temp-file'
|
||||
import { writeCliScreenshotTempFile } from '../screenshots/cli-screenshot-temp-file'
|
||||
import type { RuntimeRpcSuccess } from '../../shared/runtime-rpc-envelope'
|
||||
import { formatBrowserAnnotationsAsMarkdown } from '../../shared/browser/annotations/browser-annotation-output'
|
||||
import type {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ORCA_BROWSER_CLI_COMMAND_KEYS } from '../../shared/orca-browser-cli-commands'
|
||||
import type { HandlerGroup } from '../handler-group-manifest'
|
||||
import type { HandlerGroup } from '../dispatch/handler-group-manifest'
|
||||
|
||||
export const BROWSER_HANDLER_GROUPS: readonly HandlerGroup[] = [
|
||||
{
|
||||
|
||||
@@ -5,9 +5,9 @@ import type {
|
||||
} from '../../shared/browser-user-agent-mode'
|
||||
import { BROWSER_IDENTITY_RUNTIME_CAPABILITY } from '../../shared/browser/runtime/browser-runtime-capabilities'
|
||||
import type { RuntimeStatus } from '../../shared/runtime-session-contracts'
|
||||
import type { CommandHandler, HandlerContext } from '../dispatch'
|
||||
import { getRequiredStringFlag } from '../flags'
|
||||
import { printResult } from '../command-result-output'
|
||||
import type { CommandHandler, HandlerContext } from '../dispatch/dispatch'
|
||||
import { getRequiredStringFlag } from '../arguments/flags'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
|
||||
async function assertBrowserIdentitySupported({ client }: HandlerContext): Promise<void> {
|
||||
|
||||
@@ -12,16 +12,16 @@ import type {
|
||||
BrowserTypeResult,
|
||||
BrowserUploadResult
|
||||
} from '../../shared/browser/runtime/runtime-browser-contracts'
|
||||
import type { CommandHandler } from '../dispatch'
|
||||
import type { CommandHandler } from '../dispatch/dispatch'
|
||||
import { resolveRepoPathArgument } from '../projects/repo-path-arguments'
|
||||
import { printResult } from '../command-result-output'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import {
|
||||
getOptionalNumberFlag,
|
||||
getOptionalStringFlag,
|
||||
getRequiredFiniteNumber,
|
||||
getRequiredStringFlag,
|
||||
getRequiredStringFlagAllowingEmpty
|
||||
} from '../flags'
|
||||
} from '../arguments/flags'
|
||||
import { getBrowserCommandTarget } from './browser-command-target'
|
||||
|
||||
const checkHandler =
|
||||
|
||||
@@ -10,14 +10,14 @@ import type {
|
||||
BrowserSnapshotResult,
|
||||
BrowserWaitResult
|
||||
} from '../../shared/browser/runtime/runtime-browser-contracts'
|
||||
import type { CommandHandler } from '../dispatch'
|
||||
import type { CommandHandler } from '../dispatch/dispatch'
|
||||
import { formatScreenshot, formatSnapshot, saveBrowserScreenshot } from './browser-format'
|
||||
import { printResult } from '../command-result-output'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import {
|
||||
getOptionalPositiveIntegerFlag,
|
||||
getOptionalStringFlag,
|
||||
getRequiredStringFlag
|
||||
} from '../flags'
|
||||
} from '../arguments/flags'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import { getBrowserCommandTarget } from './browser-command-target'
|
||||
import { browserWaitRequestTimeoutMs } from '../../shared/browser-wait-timeout'
|
||||
|
||||
@@ -6,14 +6,14 @@ import type {
|
||||
BrowserTabProfileShowResult,
|
||||
BrowserTabSetProfileResult
|
||||
} from '../../shared/browser/runtime/runtime-browser-contracts'
|
||||
import type { CommandHandler } from '../dispatch'
|
||||
import { getOptionalStringFlag, getRequiredStringFlag } from '../flags'
|
||||
import type { CommandHandler } from '../dispatch/dispatch'
|
||||
import { getOptionalStringFlag, getRequiredStringFlag } from '../arguments/flags'
|
||||
import {
|
||||
formatBrowserProfileList,
|
||||
formatTabProfileClone,
|
||||
formatTabProfileShow
|
||||
} from './browser-format'
|
||||
import { printResult } from '../command-result-output'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import { getBrowserCommandTarget } from './browser-command-target'
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { CommandHandler } from '../dispatch'
|
||||
import { printResult } from '../command-result-output'
|
||||
import { getRequiredStringFlag, getRequiredStringFlagAllowingEmpty } from '../flags'
|
||||
import type { CommandHandler } from '../dispatch/dispatch'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import { getRequiredStringFlag, getRequiredStringFlagAllowingEmpty } from '../arguments/flags'
|
||||
import { getBrowserCommandTarget } from './browser-command-target'
|
||||
|
||||
export const BROWSER_STORAGE_HANDLERS: Record<string, CommandHandler> = {
|
||||
|
||||
@@ -5,20 +5,20 @@ import type {
|
||||
BrowserTabShowResult,
|
||||
BrowserTabSwitchResult
|
||||
} from '../../shared/browser/runtime/runtime-browser-contracts'
|
||||
import type { CommandHandler } from '../dispatch'
|
||||
import type { CommandHandler } from '../dispatch/dispatch'
|
||||
import {
|
||||
formatTabAnnotations,
|
||||
formatTabList,
|
||||
formatTabListWithProfiles,
|
||||
formatTabShow
|
||||
} from './browser-format'
|
||||
import { printResult } from '../command-result-output'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import {
|
||||
getOptionalNonNegativeIntegerFlag,
|
||||
getOptionalStringFlag,
|
||||
getPresentStringFlag,
|
||||
getRequiredStringFlag
|
||||
} from '../flags'
|
||||
} from '../arguments/flags'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import { isBrowserTabSplitDirection } from '../../shared/browser-tab-split-direction'
|
||||
import { getBrowserWorktreeSelector } from '../workspace-selection/workspace-selector'
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
getOptionalStringFlag,
|
||||
getRequiredStringFlag,
|
||||
getRequiredStringFlagAllowingEmpty
|
||||
} from '../flags'
|
||||
} from '../arguments/flags'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import {
|
||||
validateDragTarget,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { ComputerAppQuery } from '../../shared/computer-use-runtime-types'
|
||||
import type { RuntimeClient } from '../runtime/client'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import { getOptionalStringFlag, getRequiredStringFlag } from '../flags'
|
||||
import { getOptionalStringFlag, getRequiredStringFlag } from '../arguments/flags'
|
||||
import { getBrowserWorktreeSelector } from '../workspace-selection/workspace-selector'
|
||||
|
||||
export type ComputerCliTarget = {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { writeCliScreenshotTempFile } from '../cli-screenshot-temp-file'
|
||||
import { formatBase64PayloadByteCount } from '../base64-payload-byte-count'
|
||||
import { quoteCliCommandArgument } from '../shell-command-quote'
|
||||
import { writeCliScreenshotTempFile } from '../screenshots/cli-screenshot-temp-file'
|
||||
import { formatBase64PayloadByteCount } from '../screenshots/base64-payload-byte-count'
|
||||
import { quoteCliCommandArgument } from '../arguments/shell-command-quote'
|
||||
import type {
|
||||
ComputerActionMetadata,
|
||||
ComputerActionResult,
|
||||
|
||||
@@ -16,7 +16,7 @@ vi.mock('../runtime/client', () => {
|
||||
})
|
||||
|
||||
import { main } from '../index'
|
||||
import { okFixture, queueFixtures } from '../test-fixtures'
|
||||
import { okFixture, queueFixtures } from '../runtime/fixtures/runtime-rpc-fixtures'
|
||||
|
||||
describe('orca computer get-app-state formatting', () => {
|
||||
let screenshotDirectory: string
|
||||
|
||||
@@ -5,12 +5,12 @@ import type {
|
||||
ComputerProviderCapabilities,
|
||||
ComputerSnapshotResult
|
||||
} from '../../shared/computer-use-runtime-types'
|
||||
import type { CommandHandler } from '../dispatch'
|
||||
import type { CommandHandler } from '../dispatch/dispatch'
|
||||
import {
|
||||
getOptionalPositiveIntegerFlag,
|
||||
getOptionalStringFlag,
|
||||
getRequiredStringFlag
|
||||
} from '../flags'
|
||||
} from '../arguments/flags'
|
||||
import { queryComputerTreeText } from './computer-tree-query'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import {
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
formatListApps,
|
||||
formatListWindows
|
||||
} from './computer-format'
|
||||
import { printResult } from '../command-result-output'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import { getComputerCommandTarget } from './computer-command-target'
|
||||
import {
|
||||
getComputerActionObserveFlags,
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { randomUUID } from 'node:crypto'
|
||||
import { ORCA_SCRUB_SAFE_PANE_ENV } from '../../shared/agent-hook-listener/transport/agent-hook-scrub-safe-env'
|
||||
import { CONNECTOR_REPLY_UNAVAILABLE } from '../../shared/rpc-contract/connector-params'
|
||||
import type { CommandHandler, HandlerContext } from '../dispatch'
|
||||
import type { CommandHandler, HandlerContext } from '../dispatch/dispatch'
|
||||
import {
|
||||
getOptionalNonNegativeIntegerFlag,
|
||||
getOptionalStringFlag,
|
||||
getRequiredStringFlag
|
||||
} from '../flags'
|
||||
import { printResult } from '../command-result-output'
|
||||
import { RuntimeClientError } from '../runtime-client'
|
||||
} from '../arguments/flags'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import { getRequiredWorktreeSelector } from '../workspace-selection/workspace-selector'
|
||||
|
||||
type ConnectorDelivery = { outcome: string; reason?: string; reopened?: boolean }
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { MemorySnapshot } from '../../shared/process-stats-types'
|
||||
import type { CommandHandler } from '../dispatch'
|
||||
import { formatMemorySnapshot } from '../diagnostics/memory-snapshot-format'
|
||||
import { printResult } from '../command-result-output'
|
||||
import type { CommandHandler } from '../dispatch/dispatch'
|
||||
import { formatMemorySnapshot } from './memory-snapshot-format'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import { TERMINAL_DAEMON_HANDLERS } from '../terminals/terminal-daemon'
|
||||
|
||||
export const DIAGNOSTICS_HANDLERS: Record<string, CommandHandler> = {
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { CommandHandler } from '../dispatch'
|
||||
import { COMMAND_SPECS } from '../specs'
|
||||
import { buildAgentContext, formatAgentContextSummary } from '../agent-context'
|
||||
import type { CommandHandler } from '../dispatch/dispatch'
|
||||
import { COMMAND_SPECS } from '../specs/index'
|
||||
import { buildAgentContext, formatAgentContextSummary } from './agent-context'
|
||||
|
||||
export const INTROSPECTION_HANDLERS: Record<string, CommandHandler> = {
|
||||
// Keep schema output runtime-free so it works offline and over SSH.
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { CommandSpec } from './args'
|
||||
import { effectiveAllowedFlags } from './args'
|
||||
import type { CommandSpec } from './command-spec'
|
||||
import { effectiveAllowedFlags } from '../arguments/args'
|
||||
|
||||
const SCHEMA_VERSION = 1
|
||||
|
||||
+1
-24
@@ -1,8 +1,7 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import * as distance from '../shared/edit-distance'
|
||||
|
||||
import { suggestCommands, unknownFlagData } from './command-suggestion'
|
||||
import type { CommandSpec } from './command-spec'
|
||||
import { COMMAND_SPECS } from './specs'
|
||||
|
||||
const specs: CommandSpec[] = [
|
||||
{ path: ['list'], summary: '', usage: '', allowedFlags: [] },
|
||||
@@ -12,28 +11,6 @@ const specs: CommandSpec[] = [
|
||||
afterEach(() => vi.restoreAllMocks())
|
||||
|
||||
describe('suggestion distance work', () => {
|
||||
it('does no distance calculations for a long command, including destructive intent', () => {
|
||||
const spy = vi.spyOn(distance, 'levenshtein')
|
||||
expect(suggestCommands(specs, ['x'.repeat(32_768)])).toEqual([])
|
||||
expect(spy).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('keeps the live destructive alias registry out of long-input distance work', () => {
|
||||
const spy = vi.spyOn(distance, 'levenshtein')
|
||||
expect(suggestCommands(COMMAND_SPECS, ['emulator', 'x'.repeat(32_768)])).toEqual([])
|
||||
expect(spy).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('does no distance calculations for a long flag but still lists valid flags', () => {
|
||||
const spy = vi.spyOn(distance, 'levenshtein')
|
||||
expect(unknownFlagData('x'.repeat(32_768), ['worktree', 'json'])).toEqual({
|
||||
validFlags: ['json', 'worktree'],
|
||||
suggestions: [],
|
||||
nextSteps: ['Valid flags: --json, --worktree']
|
||||
})
|
||||
expect(spy).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('keeps the inclusive three-edit suggestion boundary', () => {
|
||||
expect(suggestCommands(specs, ['listxxx'])).toEqual(['list'])
|
||||
expect(unknownFlagData('jsonxxx', ['json']).suggestions).toEqual(['json'])
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { normalizeCommandPositionals, parseArgs, validateCommandAndFlags } from './args'
|
||||
import { normalizeCommandPositionals, parseArgs, validateCommandAndFlags } from '../arguments/args'
|
||||
import type { CommandSpec } from './command-spec'
|
||||
import { suggestCommands, unknownCommandData } from './command-suggestion'
|
||||
import { COMMAND_SPECS } from './specs'
|
||||
import { COMMAND_SPECS } from '../specs/index'
|
||||
|
||||
const blocked = [
|
||||
['orchestration resume', 'orchestration reset'],
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import type { CommandSpec } from './args'
|
||||
import type { CommandSpec } from './command-spec'
|
||||
import { suggestCommands } from './command-suggestion'
|
||||
|
||||
const specs: CommandSpec[] = [
|
||||
@@ -1,6 +1,6 @@
|
||||
import { specPaths, type CommandSpec } from './command-spec'
|
||||
import { levenshtein } from '../shared/edit-distance'
|
||||
import { isTerminalHandle } from '../shared/terminal-handle-prefix'
|
||||
import { levenshtein } from '../../shared/edit-distance'
|
||||
import { isTerminalHandle } from '../../shared/terminal-handle-prefix'
|
||||
|
||||
const SUGGESTION_THRESHOLD = 3
|
||||
const MAX_SUGGESTIONS = 3
|
||||
@@ -1,5 +1,10 @@
|
||||
import type { CommandSpec } from './args'
|
||||
import { findCommandSpec, isCommandGroup, matches, supportsBrowserPageFlag } from './args'
|
||||
import type { CommandSpec } from './command-spec'
|
||||
import {
|
||||
findCommandSpec,
|
||||
isCommandGroup,
|
||||
matches,
|
||||
supportsBrowserPageFlag
|
||||
} from '../arguments/args'
|
||||
import { unknownCommandData } from './command-suggestion'
|
||||
import { formatCommandScopedFlagHelp } from './command-scoped-flag-help'
|
||||
import { FLAG_HELP_TEXT } from './flag-help-text'
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { CommandSpec } from './args'
|
||||
import type { CommandSpec } from './command-spec'
|
||||
|
||||
// Grandfather existing verb divergences to avoid breaking compatibility.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { RuntimeClient } from './runtime-client'
|
||||
import { RuntimeClientError } from './runtime/types'
|
||||
import type { RuntimeClient } from '../runtime/client'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import { HANDLER_GROUPS, type HandlerGroup } from './handler-group-manifest'
|
||||
|
||||
export type HandlerContext = {
|
||||
@@ -1,12 +1,12 @@
|
||||
import type { CommandHandler } from './dispatch'
|
||||
import { BROWSER_HANDLER_GROUPS } from './browser/browser-handler-groups'
|
||||
import { JIRA_HANDLER_GROUP } from './jira/jira-handler-group'
|
||||
import { LINEAR_HANDLER_GROUP } from './linear/linear-handler-group'
|
||||
import { REFERENCE_HANDLER_GROUP } from './reference-handler-group'
|
||||
import { SERVE_PAIRING_HANDLER_GROUPS } from './server/serve-pairing-handler-groups'
|
||||
import { PLUGIN_HANDLER_GROUPS } from './plugins/plugin-handler-groups'
|
||||
import { HOST_HANDLER_GROUPS } from './hosts/host-handler-groups'
|
||||
import { WORKTREE_HANDLER_GROUPS } from './workspaces/worktree-handler-groups'
|
||||
import { BROWSER_HANDLER_GROUPS } from '../browser/browser-handler-groups'
|
||||
import { JIRA_HANDLER_GROUP } from '../jira/jira-handler-group'
|
||||
import { LINEAR_HANDLER_GROUP } from '../linear/linear-handler-group'
|
||||
import { REFERENCE_HANDLER_GROUP } from '../references/reference-handler-group'
|
||||
import { SERVE_PAIRING_HANDLER_GROUPS } from '../server/serve-pairing-handler-groups'
|
||||
import { PLUGIN_HANDLER_GROUPS } from '../plugins/plugin-handler-groups'
|
||||
import { HOST_HANDLER_GROUPS } from '../hosts/host-handler-groups'
|
||||
import { WORKTREE_HANDLER_GROUPS } from '../workspaces/worktree-handler-groups'
|
||||
|
||||
export type HandlerGroup = {
|
||||
name: string
|
||||
@@ -22,24 +22,24 @@ export const HANDLER_GROUPS: readonly HandlerGroup[] = [
|
||||
{
|
||||
name: 'core',
|
||||
keys: ['claude-teams', 'open', 'serve', 'status'],
|
||||
load: async () => (await import('./handlers/core.js')).CORE_HANDLERS
|
||||
load: async () => (await import('../runtime/cli-lifecycle-handlers.js')).CORE_HANDLERS
|
||||
},
|
||||
...SERVE_PAIRING_HANDLER_GROUPS,
|
||||
{
|
||||
name: 'serve-reset-identity',
|
||||
keys: ['serve reset-identity'],
|
||||
load: async () =>
|
||||
(await import('./server/serve-reset-identity.js')).SERVE_RESET_IDENTITY_HANDLERS
|
||||
(await import('../server/serve-reset-identity.js')).SERVE_RESET_IDENTITY_HANDLERS
|
||||
},
|
||||
{
|
||||
name: 'serve-service',
|
||||
keys: ['serve service install', 'serve service status', 'serve service uninstall'],
|
||||
load: async () => (await import('./server/serve-service.js')).SERVE_SERVICE_HANDLERS
|
||||
load: async () => (await import('../server/serve-service.js')).SERVE_SERVICE_HANDLERS
|
||||
},
|
||||
{
|
||||
name: 'account',
|
||||
keys: ['account add', 'account list', 'account select', 'account rm'],
|
||||
load: async () => (await import('./accounts/account.js')).ACCOUNT_HANDLERS
|
||||
load: async () => (await import('../accounts/account.js')).ACCOUNT_HANDLERS
|
||||
},
|
||||
{
|
||||
name: 'artifacts',
|
||||
@@ -50,7 +50,7 @@ export const HANDLER_GROUPS: readonly HandlerGroup[] = [
|
||||
'artifacts unshare',
|
||||
'artifacts delete'
|
||||
],
|
||||
load: async () => (await import('./artifacts/artifacts.js')).ARTIFACT_HANDLERS
|
||||
load: async () => (await import('../artifacts/artifacts.js')).ARTIFACT_HANDLERS
|
||||
},
|
||||
{
|
||||
name: 'automations',
|
||||
@@ -63,7 +63,7 @@ export const HANDLER_GROUPS: readonly HandlerGroup[] = [
|
||||
'automations run',
|
||||
'automations runs'
|
||||
],
|
||||
load: async () => (await import('./automations/automations.js')).AUTOMATION_HANDLERS
|
||||
load: async () => (await import('../automations/automations.js')).AUTOMATION_HANDLERS
|
||||
},
|
||||
{
|
||||
name: 'project',
|
||||
@@ -76,7 +76,7 @@ export const HANDLER_GROUPS: readonly HandlerGroup[] = [
|
||||
'project setup-update',
|
||||
'project setup-delete'
|
||||
],
|
||||
load: async () => (await import('./projects/project.js')).PROJECT_HANDLERS
|
||||
load: async () => (await import('../projects/project.js')).PROJECT_HANDLERS
|
||||
},
|
||||
{
|
||||
name: 'repo',
|
||||
@@ -90,13 +90,13 @@ export const HANDLER_GROUPS: readonly HandlerGroup[] = [
|
||||
'repo set-base-ref',
|
||||
'repo search-refs'
|
||||
],
|
||||
load: async () => (await import('./projects/repo.js')).REPO_HANDLERS
|
||||
load: async () => (await import('../projects/repo.js')).REPO_HANDLERS
|
||||
},
|
||||
...WORKTREE_HANDLER_GROUPS,
|
||||
{
|
||||
name: 'file',
|
||||
keys: ['file open', 'file diff', 'file open-changed'],
|
||||
load: async () => (await import('./files/file.js')).FILE_HANDLERS
|
||||
load: async () => (await import('../files/file.js')).FILE_HANDLERS
|
||||
},
|
||||
{
|
||||
name: 'terminal',
|
||||
@@ -114,7 +114,7 @@ export const HANDLER_GROUPS: readonly HandlerGroup[] = [
|
||||
'terminal close',
|
||||
'terminal split'
|
||||
],
|
||||
load: async () => (await import('./terminals/terminal.js')).TERMINAL_HANDLERS
|
||||
load: async () => (await import('../terminals/terminal.js')).TERMINAL_HANDLERS
|
||||
},
|
||||
...BROWSER_HANDLER_GROUPS,
|
||||
{
|
||||
@@ -154,7 +154,8 @@ export const HANDLER_GROUPS: readonly HandlerGroup[] = [
|
||||
'orchestration gate-list',
|
||||
'orchestration reset'
|
||||
],
|
||||
load: async () => (await import('./handlers/orchestration.js')).ORCHESTRATION_HANDLERS
|
||||
load: async () =>
|
||||
(await import('../orchestration/orchestration-handlers.js')).ORCHESTRATION_HANDLERS
|
||||
},
|
||||
{
|
||||
name: 'emulator',
|
||||
@@ -176,7 +177,7 @@ export const HANDLER_GROUPS: readonly HandlerGroup[] = [
|
||||
'emulator ax',
|
||||
'emulator logcat'
|
||||
],
|
||||
load: async () => (await import('./emulator/emulator.js')).EMULATOR_HANDLERS
|
||||
load: async () => (await import('../emulator/emulator.js')).EMULATOR_HANDLERS
|
||||
},
|
||||
{
|
||||
name: 'computer',
|
||||
@@ -196,22 +197,22 @@ export const HANDLER_GROUPS: readonly HandlerGroup[] = [
|
||||
'computer paste-text',
|
||||
'computer set-value'
|
||||
],
|
||||
load: async () => (await import('./computer/computer.js')).COMPUTER_HANDLERS
|
||||
load: async () => (await import('../computer/computer.js')).COMPUTER_HANDLERS
|
||||
},
|
||||
{
|
||||
name: 'agent-hooks',
|
||||
keys: ['agent hooks prepare-codex', 'agent hooks status', 'agent hooks off', 'agent hooks on'],
|
||||
load: async () => (await import('./agents/agent-hooks.js')).AGENT_HOOK_HANDLERS
|
||||
load: async () => (await import('../agents/agent-hooks.js')).AGENT_HOOK_HANDLERS
|
||||
},
|
||||
{
|
||||
name: 'agent-launch',
|
||||
keys: ['agent launch'],
|
||||
load: async () => (await import('./agents/agent-launch.js')).AGENT_LAUNCH_HANDLERS
|
||||
load: async () => (await import('../agents/agent-launch.js')).AGENT_LAUNCH_HANDLERS
|
||||
},
|
||||
{
|
||||
name: 'chat',
|
||||
keys: ['chat rename'],
|
||||
load: async () => (await import('./agents/chat.js')).CHAT_HANDLERS
|
||||
load: async () => (await import('../agents/chat.js')).CHAT_HANDLERS
|
||||
},
|
||||
{
|
||||
name: 'connector',
|
||||
@@ -224,48 +225,49 @@ export const HANDLER_GROUPS: readonly HandlerGroup[] = [
|
||||
'connector watch',
|
||||
'connector reply'
|
||||
],
|
||||
load: async () => (await import('./handlers/connector.js')).CONNECTOR_HANDLERS
|
||||
load: async () => (await import('../connectors/connector.js')).CONNECTOR_HANDLERS
|
||||
},
|
||||
{
|
||||
name: 'profile-state',
|
||||
keys: ['profile state exports', 'profile state rollback'],
|
||||
load: async () => (await import('./handlers/profile-state.js')).PROFILE_STATE_HANDLERS
|
||||
load: async () => (await import('../profiles/profile-state.js')).PROFILE_STATE_HANDLERS
|
||||
},
|
||||
{
|
||||
name: 'diagnostics',
|
||||
keys: ['diagnostics memory', 'terminal-daemon status', 'terminal-daemon restart'],
|
||||
load: async () => (await import('./handlers/diagnostics.js')).DIAGNOSTICS_HANDLERS
|
||||
load: async () => (await import('../diagnostics/diagnostics.js')).DIAGNOSTICS_HANDLERS
|
||||
},
|
||||
{
|
||||
name: 'speech',
|
||||
keys: ['speech openai-key status', 'speech openai-key set', 'speech openai-key clear'],
|
||||
load: async () => (await import('./handlers/speech.js')).SPEECH_HANDLERS
|
||||
load: async () => (await import('../speech/speech.js')).SPEECH_HANDLERS
|
||||
},
|
||||
{
|
||||
name: 'introspection',
|
||||
keys: ['agent-context'],
|
||||
load: async () => (await import('./handlers/introspection.js')).INTROSPECTION_HANDLERS
|
||||
load: async () =>
|
||||
(await import('../discovery/agent-context-handlers.js')).INTROSPECTION_HANDLERS
|
||||
},
|
||||
...HOST_HANDLER_GROUPS,
|
||||
{
|
||||
name: 'skill-sharing',
|
||||
keys: ['skills installed', 'skills share'],
|
||||
load: async () => (await import('./skills/skill-sharing.js')).SKILL_SHARING_HANDLERS
|
||||
load: async () => (await import('../skills/skill-sharing.js')).SKILL_SHARING_HANDLERS
|
||||
},
|
||||
...PLUGIN_HANDLER_GROUPS,
|
||||
{
|
||||
name: 'skills',
|
||||
keys: ['skills list', 'skills get', 'skills install', 'skills update'],
|
||||
load: async () => (await import('./skills/skills.js')).SKILL_HANDLERS
|
||||
load: async () => (await import('../skills/skills.js')).SKILL_HANDLERS
|
||||
},
|
||||
{
|
||||
name: 'search',
|
||||
keys: ['search'],
|
||||
load: async () => (await import('./session-search/search.js')).SEARCH_HANDLERS
|
||||
load: async () => (await import('../session-search/search.js')).SEARCH_HANDLERS
|
||||
},
|
||||
{
|
||||
name: 'ports',
|
||||
keys: ['ports'],
|
||||
load: async () => (await import('./workspace-ports/ports.js')).PORTS_HANDLERS
|
||||
load: async () => (await import('../workspace-ports/ports.js')).PORTS_HANDLERS
|
||||
}
|
||||
]
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { RuntimeClientError } from './runtime/types'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
|
||||
// Local-only command families reject explicit runtime selectors rather than silently ignoring them.
|
||||
export const REMOTE_SELECTION_FLAGS = ['environment', 'pairing-code'] as const
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { RuntimeClient } from '../runtime/client'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import { assertLocalCwdWorktreeSelector } from '../hosts/local-environment-selector'
|
||||
import { getOptionalStringFlag } from '../flags'
|
||||
import { getOptionalStringFlag } from '../arguments/flags'
|
||||
import {
|
||||
resolveCallerPaneWorktreeSelector,
|
||||
type WorkspaceSelectionPurpose
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getOptionalStringFlag, getRequiredStringFlag } from '../flags'
|
||||
import { getOptionalStringFlag, getRequiredStringFlag } from '../arguments/flags'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
|
||||
export type EmulatorPermissionRequest = {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import type { CommandHandler } from '../dispatch'
|
||||
import type { CommandHandler } from '../dispatch/dispatch'
|
||||
import { formatLogcat } from './emulator-logcat-format'
|
||||
import { parseEmulatorPermissionRequest } from './emulator-permissions-args'
|
||||
import { printResult } from '../command-result-output'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import { resolveRepoPathArgument } from '../projects/repo-path-arguments'
|
||||
import {
|
||||
getOptionalPositiveIntegerFlag,
|
||||
getOptionalStringFlag,
|
||||
getRequiredFiniteNumber,
|
||||
getRequiredStringFlag
|
||||
} from '../flags'
|
||||
} from '../arguments/flags'
|
||||
import { getEmulatorCommandTarget } from './emulator-command-target'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import { EMULATOR_ATTACH_RPC_TIMEOUT_MS } from '../../shared/emulator-attach-timeouts'
|
||||
|
||||
@@ -14,7 +14,7 @@ vi.mock('../runtime/client', () => {
|
||||
})
|
||||
|
||||
import { main } from '../index'
|
||||
import { buildWorktree, okFixture, queueFixtures } from '../test-fixtures'
|
||||
import { buildWorktree, okFixture, queueFixtures } from '../runtime/fixtures/runtime-rpc-fixtures'
|
||||
|
||||
describe('absolute file CLI paths', () => {
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { RuntimeFileOpenResult } from '../../shared/file-access/runtime-editor-file-open'
|
||||
import type { HandlerContext } from '../dispatch'
|
||||
import type { HandlerContext } from '../dispatch/dispatch'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import type { RuntimeRpcSuccess } from '../../shared/runtime-rpc-envelope'
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { RuntimeFileOpenPosition } from '../../shared/file-access/runtime-editor-file-open'
|
||||
import { getOptionalPositiveIntegerFlag } from '../flags'
|
||||
import { getOptionalPositiveIntegerFlag } from '../arguments/flags'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
|
||||
export function getFileOpenPosition(
|
||||
|
||||
@@ -5,9 +5,9 @@ import type { RuntimeWorktreeRecord } from '../../shared/runtime-worktree-contra
|
||||
import type { RuntimeNavigationTarget } from '../../shared/runtime-navigation'
|
||||
import { isRuntimePathAbsolute, relativePathInsideRoot } from '../../shared/cross-platform-path'
|
||||
import { isWslUncPath, parseWslUncPath, toWindowsWslPath } from '../../shared/wsl-paths'
|
||||
import type { CommandHandler, HandlerContext } from '../dispatch'
|
||||
import { getOptionalStringFlag, getRequiredStringFlag } from '../flags'
|
||||
import { printResult } from '../command-result-output'
|
||||
import type { CommandHandler, HandlerContext } from '../dispatch/dispatch'
|
||||
import { getOptionalStringFlag, getRequiredStringFlag } from '../arguments/flags'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import { callFileOpen } from './file-open-call'
|
||||
import {
|
||||
|
||||
@@ -1,204 +0,0 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const { spawnMock, reclaimStaleLockMock, printReclaimResultMock } = vi.hoisted(() => ({
|
||||
spawnMock: vi.fn(),
|
||||
reclaimStaleLockMock: vi.fn(),
|
||||
printReclaimResultMock: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('node:child_process', () => ({ spawn: spawnMock }))
|
||||
vi.mock('../../main/orcad/orcad-stale-lock-reclaim.js', () => ({
|
||||
reclaimStaleOrcadInstanceLock: reclaimStaleLockMock,
|
||||
printOrcadStaleLockReclaimResult: printReclaimResultMock
|
||||
}))
|
||||
|
||||
// Exclude the socket runtime graph; this handler needs only errors and serveOrcaApp.
|
||||
vi.mock('../runtime-client', () => ({
|
||||
RuntimeClientError: class RuntimeClientError extends Error {
|
||||
readonly code: string
|
||||
constructor(code: string, message: string) {
|
||||
super(message)
|
||||
this.code = code
|
||||
}
|
||||
},
|
||||
serveOrcaApp: vi.fn()
|
||||
}))
|
||||
|
||||
import { CORE_HANDLERS } from './core'
|
||||
import type { HandlerContext } from '../dispatch'
|
||||
import type { RuntimeClient } from '../runtime-client'
|
||||
|
||||
type SpawnEnv = Record<string, string | undefined>
|
||||
|
||||
// Emit exit on the next microtask so the spawned-process promise settles deterministically.
|
||||
function mockClaudeChild(): { once: (event: string, cb: (...args: unknown[]) => void) => unknown } {
|
||||
const child = {
|
||||
once(event: string, cb: (...args: unknown[]) => void) {
|
||||
if (event === 'exit') {
|
||||
queueMicrotask(() => cb(0, null))
|
||||
}
|
||||
return child
|
||||
}
|
||||
}
|
||||
return child
|
||||
}
|
||||
|
||||
describe('orca claude-teams CLI handler', () => {
|
||||
const isWindows = process.platform === 'win32'
|
||||
let previousRunAsNode: string | undefined
|
||||
let previousPaneKey: string | undefined
|
||||
let previousExitCode: typeof process.exitCode
|
||||
|
||||
const callMock = vi.fn()
|
||||
const client = { call: callMock } as unknown as RuntimeClient
|
||||
|
||||
function runClaudeTeams(): Promise<void> {
|
||||
const ctx: HandlerContext = {
|
||||
flags: new Map(),
|
||||
client,
|
||||
cwd: '/tmp/repo',
|
||||
json: false,
|
||||
rawArgs: []
|
||||
}
|
||||
return CORE_HANDLERS['claude-teams'](ctx)
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
reclaimStaleLockMock.mockReset()
|
||||
reclaimStaleLockMock.mockRejectedValue(new Error('Unexpected stale-lock reclaim'))
|
||||
printReclaimResultMock.mockReset()
|
||||
spawnMock.mockReset()
|
||||
spawnMock.mockImplementation(() => mockClaudeChild())
|
||||
callMock.mockReset()
|
||||
callMock.mockResolvedValue({
|
||||
result: {
|
||||
launch: { env: { CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS: '1', PATH: '/shim:/usr/bin' } }
|
||||
}
|
||||
})
|
||||
previousRunAsNode = process.env.ELECTRON_RUN_AS_NODE
|
||||
previousPaneKey = process.env.ORCA_PANE_KEY
|
||||
previousExitCode = process.exitCode
|
||||
// Reproduce the Electron-as-Node flag inherited from the orca launcher.
|
||||
process.env.ELECTRON_RUN_AS_NODE = '1'
|
||||
process.env.ORCA_PANE_KEY = 'tab-1:leaf-1'
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
if (previousRunAsNode === undefined) {
|
||||
delete process.env.ELECTRON_RUN_AS_NODE
|
||||
} else {
|
||||
process.env.ELECTRON_RUN_AS_NODE = previousRunAsNode
|
||||
}
|
||||
if (previousPaneKey === undefined) {
|
||||
delete process.env.ORCA_PANE_KEY
|
||||
} else {
|
||||
process.env.ORCA_PANE_KEY = previousPaneKey
|
||||
}
|
||||
process.exitCode = previousExitCode
|
||||
})
|
||||
|
||||
// Windows refuses the command before reaching child-process creation.
|
||||
it.skipIf(isWindows)(
|
||||
'does not leak ELECTRON_RUN_AS_NODE into the spawned claude child',
|
||||
async () => {
|
||||
await runClaudeTeams()
|
||||
|
||||
expect(spawnMock).toHaveBeenCalledWith('claude', expect.any(Array), expect.any(Object))
|
||||
const spawnEnv = spawnMock.mock.calls.at(-1)?.[2].env as SpawnEnv
|
||||
expect(spawnEnv.ELECTRON_RUN_AS_NODE).toBeUndefined()
|
||||
|
||||
const prepareLaunchEnv = (callMock.mock.calls[0][1] as { env: SpawnEnv }).env
|
||||
expect(prepareLaunchEnv.ELECTRON_RUN_AS_NODE).toBeUndefined()
|
||||
}
|
||||
)
|
||||
|
||||
it.skipIf(isWindows)(
|
||||
'still forwards non-Electron parent env and prepareLaunch env to claude',
|
||||
async () => {
|
||||
const previousMarker = process.env.ORCA_TEST_MARKER
|
||||
process.env.ORCA_TEST_MARKER = 'keep-me'
|
||||
try {
|
||||
await runClaudeTeams()
|
||||
} finally {
|
||||
if (previousMarker === undefined) {
|
||||
delete process.env.ORCA_TEST_MARKER
|
||||
} else {
|
||||
process.env.ORCA_TEST_MARKER = previousMarker
|
||||
}
|
||||
}
|
||||
|
||||
const spawnEnv = spawnMock.mock.calls.at(-1)?.[2].env as SpawnEnv
|
||||
expect(spawnEnv.ORCA_TEST_MARKER).toBe('keep-me')
|
||||
expect(spawnEnv.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS).toBe('1')
|
||||
expect(spawnEnv.PATH).toBe('/shim:/usr/bin')
|
||||
}
|
||||
)
|
||||
|
||||
it.skipIf(isWindows)('removes managed auth variables before spawning Claude', async () => {
|
||||
const previousApiKey = process.env.ANTHROPIC_API_KEY
|
||||
process.env.ANTHROPIC_API_KEY = 'sk-ant-inherited'
|
||||
callMock.mockResolvedValueOnce({
|
||||
result: {
|
||||
launch: {
|
||||
env: {
|
||||
CLAUDE_CONFIG_DIR: '/managed/claude',
|
||||
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS: '1'
|
||||
},
|
||||
envToDelete: ['ANTHROPIC_API_KEY']
|
||||
}
|
||||
}
|
||||
})
|
||||
try {
|
||||
await runClaudeTeams()
|
||||
} finally {
|
||||
if (previousApiKey === undefined) {
|
||||
delete process.env.ANTHROPIC_API_KEY
|
||||
} else {
|
||||
process.env.ANTHROPIC_API_KEY = previousApiKey
|
||||
}
|
||||
}
|
||||
|
||||
const spawnEnv = spawnMock.mock.calls.at(-1)?.[2].env as SpawnEnv
|
||||
expect(spawnEnv.ANTHROPIC_API_KEY).toBeUndefined()
|
||||
expect(spawnEnv.CLAUDE_CONFIG_DIR).toBe('/managed/claude')
|
||||
})
|
||||
|
||||
it.skipIf(isWindows)('preserves API-key auth when no managed deletion is requested', async () => {
|
||||
const previousApiKey = process.env.ANTHROPIC_API_KEY
|
||||
process.env.ANTHROPIC_API_KEY = 'sk-ant-system'
|
||||
try {
|
||||
await runClaudeTeams()
|
||||
} finally {
|
||||
if (previousApiKey === undefined) {
|
||||
delete process.env.ANTHROPIC_API_KEY
|
||||
} else {
|
||||
process.env.ANTHROPIC_API_KEY = previousApiKey
|
||||
}
|
||||
}
|
||||
|
||||
const spawnEnv = spawnMock.mock.calls.at(-1)?.[2].env as SpawnEnv
|
||||
expect(spawnEnv.ANTHROPIC_API_KEY).toBe('sk-ant-system')
|
||||
})
|
||||
|
||||
// #32177: an empty --data-root must never fall back to the default profile's lock.
|
||||
it('refuses `orca serve --reclaim-stale-lock` with a --data-root that names no directory', async () => {
|
||||
const ctx: HandlerContext = {
|
||||
flags: new Map<string, string | boolean>([
|
||||
['reclaim-stale-lock', true],
|
||||
['data-root', true],
|
||||
['yes', true]
|
||||
]),
|
||||
client,
|
||||
cwd: '/tmp',
|
||||
json: true,
|
||||
rawArgs: []
|
||||
}
|
||||
await expect(CORE_HANDLERS.serve(ctx)).rejects.toMatchObject({
|
||||
code: 'invalid_argument',
|
||||
message:
|
||||
'--data-root expects a directory. Usage: orca serve --reclaim-stale-lock [--data-root <dir>] [--yes] [--json]'
|
||||
})
|
||||
expect(reclaimStaleLockMock).not.toHaveBeenCalled()
|
||||
expect(printReclaimResultMock).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
@@ -1,197 +0,0 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const { callMock, getTerminalHandleMock } = vi.hoisted(() => ({
|
||||
callMock: vi.fn(),
|
||||
getTerminalHandleMock: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('../runtime/client', async () => {
|
||||
// Error formatting uses instanceof, so preserve the production error classes.
|
||||
const { RuntimeClientError, RuntimeRpcFailureError } = await import('../runtime/types.js')
|
||||
class RuntimeClient {
|
||||
readonly isRemote = false
|
||||
call = callMock
|
||||
getCliStatus = vi.fn()
|
||||
openOrca = vi.fn()
|
||||
}
|
||||
return {
|
||||
RuntimeClient,
|
||||
RuntimeClientError,
|
||||
RuntimeRpcFailureError,
|
||||
serveOrcaApp: vi.fn(),
|
||||
getDefaultUserDataPath: vi.fn(() => '/tmp/orca-user-data')
|
||||
}
|
||||
})
|
||||
|
||||
vi.mock('../runtime/metadata', async (importOriginal) => ({
|
||||
...(await importOriginal<Record<string, unknown>>()),
|
||||
getDefaultUserDataPath: vi.fn(() => '/tmp/orca-user-data')
|
||||
}))
|
||||
|
||||
vi.mock('../runtime/launch', async (importOriginal) => ({
|
||||
...(await importOriginal<Record<string, unknown>>()),
|
||||
serveOrcaApp: vi.fn()
|
||||
}))
|
||||
vi.mock('../terminals/terminal-selector', async (importOriginal) => ({
|
||||
...(await importOriginal<Record<string, unknown>>()),
|
||||
getTerminalHandle: getTerminalHandleMock
|
||||
}))
|
||||
|
||||
import { main } from '../index'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import { okFixture, queueFixtures } from '../test-fixtures'
|
||||
|
||||
const originalTerminalHandle = process.env.ORCA_TERMINAL_HANDLE
|
||||
const originalPaneKey = process.env.ORCA_PANE_KEY
|
||||
// Isolate inherited session markers so the runner cannot change the refusal branch.
|
||||
const originalStructuredSession = process.env.ORCA_STRUCTURED_SESSION
|
||||
const originalCodexThreadId = process.env.CODEX_THREAD_ID
|
||||
|
||||
const restoreEnv = (name: string, value: string | undefined): void => {
|
||||
if (value === undefined) {
|
||||
delete process.env[name]
|
||||
} else {
|
||||
process.env[name] = value
|
||||
}
|
||||
}
|
||||
|
||||
describe('orchestration gate commands carry caller identity', () => {
|
||||
let logSpy: ReturnType<typeof vi.spyOn>
|
||||
let errorSpy: ReturnType<typeof vi.spyOn>
|
||||
|
||||
beforeEach(() => {
|
||||
callMock.mockReset()
|
||||
getTerminalHandleMock.mockReset()
|
||||
logSpy = vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
|
||||
delete process.env.ORCA_TERMINAL_HANDLE
|
||||
delete process.env.ORCA_PANE_KEY
|
||||
delete process.env.ORCA_STRUCTURED_SESSION
|
||||
delete process.env.CODEX_THREAD_ID
|
||||
process.exitCode = 0
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
logSpy.mockRestore()
|
||||
errorSpy.mockRestore()
|
||||
restoreEnv('ORCA_TERMINAL_HANDLE', originalTerminalHandle)
|
||||
restoreEnv('ORCA_PANE_KEY', originalPaneKey)
|
||||
restoreEnv('ORCA_STRUCTURED_SESSION', originalStructuredSession)
|
||||
restoreEnv('CODEX_THREAD_ID', originalCodexThreadId)
|
||||
process.exitCode = 0
|
||||
})
|
||||
|
||||
const paramsFor = (method: string): Record<string, unknown> =>
|
||||
callMock.mock.calls.find((call) => call[0] === method)?.[1] as Record<string, unknown>
|
||||
|
||||
it('inspects a named Run without resolving a caller terminal', async () => {
|
||||
getTerminalHandleMock.mockRejectedValue(
|
||||
new RuntimeClientError('no_active_terminal', 'no active terminal')
|
||||
)
|
||||
queueFixtures(
|
||||
callMock,
|
||||
okFixture('req_list', {
|
||||
gates: [
|
||||
{
|
||||
id: 'gate_1',
|
||||
task_id: 'task_1',
|
||||
question: 'ship?',
|
||||
options: '["yes","no"]',
|
||||
status: 'pending',
|
||||
resolution: null,
|
||||
created_at: '2026-10-31 00:00:00'
|
||||
}
|
||||
],
|
||||
count: 1
|
||||
})
|
||||
)
|
||||
|
||||
await main(['orchestration', 'gate-list', '--run', 'run_adopted', '--json'], '/tmp/repo')
|
||||
|
||||
expect(process.exitCode).toBe(0)
|
||||
expect(JSON.parse(String(logSpy.mock.calls[0]?.[0])).result.gates).toEqual([
|
||||
{
|
||||
id: 'gate_1',
|
||||
taskId: 'task_1',
|
||||
status: 'pending',
|
||||
question: 'ship?',
|
||||
options: '["yes","no"]'
|
||||
}
|
||||
])
|
||||
expect(getTerminalHandleMock).not.toHaveBeenCalled()
|
||||
expect(paramsFor('orchestration.gateList')).toEqual(
|
||||
expect.objectContaining({ run: 'run_adopted', from: undefined })
|
||||
)
|
||||
})
|
||||
|
||||
it('fails an unbound gate-create with an actionable error and no mutation', async () => {
|
||||
getTerminalHandleMock.mockRejectedValue(
|
||||
new RuntimeClientError('no_active_terminal', 'no active terminal')
|
||||
)
|
||||
|
||||
await main(
|
||||
['orchestration', 'gate-create', '--task', 'task_1', '--question', 'ship?'],
|
||||
'/tmp/repo'
|
||||
)
|
||||
|
||||
expect(process.exitCode).toBe(1)
|
||||
const stderr = errorSpy.mock.calls.map((call) => String(call[0])).join('\n')
|
||||
expect(stderr).toContain("Pass --from with your own terminal's handle")
|
||||
expect(callMock).not.toHaveBeenCalledWith('orchestration.gateCreate', expect.anything())
|
||||
})
|
||||
|
||||
it('reports idempotent recovery when a mutation connection drops', async () => {
|
||||
process.env.ORCA_TERMINAL_HANDLE = 'term_coord'
|
||||
callMock
|
||||
.mockResolvedValueOnce(
|
||||
okFixture('req_identity', { identity: { handle: 'term_coord', live: true } })
|
||||
)
|
||||
.mockRejectedValueOnce(
|
||||
new RuntimeClientError(
|
||||
'runtime_unavailable',
|
||||
'The Orca runtime closed the connection before responding. Restart Orca and try again. Orchestration mutation request ID: mutation_1.',
|
||||
{
|
||||
orchestrationRequestId: 'mutation_1',
|
||||
originalCommand: [
|
||||
'orca',
|
||||
'orchestration',
|
||||
'gate-create',
|
||||
'--task',
|
||||
'task_1',
|
||||
'--question',
|
||||
'ship?',
|
||||
'--json'
|
||||
],
|
||||
failedStage: 'dispatch_input',
|
||||
residualResources: [
|
||||
{ kind: 'worktree', id: 'repo::child' },
|
||||
{ kind: 'terminal', id: 'term_worker' }
|
||||
]
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
await main(
|
||||
['orchestration', 'gate-create', '--task', 'task_1', '--question', 'ship?', '--json'],
|
||||
'/tmp/repo'
|
||||
)
|
||||
|
||||
expect(process.exitCode).toBe(1)
|
||||
const output = JSON.parse(String(logSpy.mock.calls[0]?.[0])) as {
|
||||
error: { message: string; data: Record<string, unknown> }
|
||||
}
|
||||
expect(output.error.message).toContain('--retry-request mutation_1')
|
||||
expect(output.error.message).toContain('may already have taken effect')
|
||||
expect(output.error.message).toContain('Failed stage: dispatch_input')
|
||||
expect(output.error.message).toMatch(/Residual resources:.*repo::child.*term_worker/)
|
||||
expect(output.error.message).not.toMatch(/restart Orca/i)
|
||||
expect(output.error.data).toMatchObject({
|
||||
orchestrationRequestId: 'mutation_1',
|
||||
failedStage: 'dispatch_input',
|
||||
residualResources: expect.arrayContaining([
|
||||
expect.objectContaining({ kind: 'worktree', id: 'repo::child' }),
|
||||
expect.objectContaining({ kind: 'terminal', id: 'term_worker' })
|
||||
])
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,51 +0,0 @@
|
||||
import { afterEach, expect, it, vi } from 'vitest'
|
||||
import { reportCliError } from '../cli-error'
|
||||
import { ORCHESTRATION_HANDLERS } from './orchestration'
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
it('prints a rejected lifecycle verdict as a JSON failure envelope', async () => {
|
||||
const log = vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
const client = {
|
||||
call: vi.fn().mockResolvedValue({
|
||||
result: {
|
||||
message: { id: 'msg_rejected' },
|
||||
lifecycle: {
|
||||
action: 'rejected',
|
||||
code: 'sender_not_assignee',
|
||||
reason: 'dispatch ctx_1 expected the assigned pane'
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
let rejection: unknown
|
||||
try {
|
||||
await ORCHESTRATION_HANDLERS['orchestration send']({
|
||||
flags: new Map([
|
||||
['from', 'term_foreign'],
|
||||
['to', 'term_coord'],
|
||||
['subject', 'done'],
|
||||
['type', 'worker_done'],
|
||||
['outcome', 'succeeded']
|
||||
]),
|
||||
client,
|
||||
cwd: '/tmp/repo',
|
||||
json: true
|
||||
} as never)
|
||||
} catch (error) {
|
||||
rejection = error
|
||||
}
|
||||
|
||||
expect(rejection).toBeDefined()
|
||||
reportCliError(rejection, true, { commandPath: ['orchestration', 'send'] })
|
||||
|
||||
expect(JSON.parse(String(log.mock.calls[0]?.[0]))).toMatchObject({
|
||||
ok: false,
|
||||
error: {
|
||||
code: 'sender_not_assignee',
|
||||
message: 'dispatch ctx_1 expected the assigned pane'
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -1,34 +0,0 @@
|
||||
import type { CommandHandler } from '../dispatch'
|
||||
import { ORCHESTRATION_CHECK_HANDLER } from './orchestration/message-check-handler'
|
||||
import {
|
||||
ORCHESTRATION_DISPATCH_HANDLER,
|
||||
ORCHESTRATION_DISPATCH_INSPECTION_HANDLERS
|
||||
} from './orchestration/dispatch-handlers'
|
||||
import { ORCHESTRATION_GATE_HANDLERS } from './orchestration/gate-handlers'
|
||||
import { ORCHESTRATION_INBOX_HANDLERS } from './orchestration/message-inbox-handlers'
|
||||
import { ORCHESTRATION_QUESTION_HANDLER } from './orchestration/question-handler'
|
||||
import { ORCHESTRATION_REQUEST_SHOW_HANDLER } from './orchestration/mutation-request-show-handler'
|
||||
import { ORCHESTRATION_RESET_HANDLER } from './orchestration/reset-handler'
|
||||
import { ORCHESTRATION_RUN_HANDLERS } from './orchestration/run-handlers'
|
||||
import { ORCHESTRATION_SEND_HANDLER } from './orchestration/message-send-handler'
|
||||
import { ORCHESTRATION_TASK_HANDLERS } from './orchestration/task-handlers'
|
||||
import { ORCHESTRATION_WORKER_LAUNCH_HANDLER } from './orchestration/worker-launch-handler'
|
||||
import { ORCHESTRATION_WORKER_OBSERVATION_HANDLERS } from './orchestration/worker-observation-handlers'
|
||||
import { ORCHESTRATION_WORKER_TERMINAL_HANDLERS } from './orchestration/worker-terminal-handlers'
|
||||
|
||||
export const ORCHESTRATION_HANDLERS: Record<string, CommandHandler> = {
|
||||
...ORCHESTRATION_RUN_HANDLERS,
|
||||
...ORCHESTRATION_SEND_HANDLER,
|
||||
...ORCHESTRATION_CHECK_HANDLER,
|
||||
...ORCHESTRATION_INBOX_HANDLERS,
|
||||
...ORCHESTRATION_TASK_HANDLERS,
|
||||
...ORCHESTRATION_WORKER_LAUNCH_HANDLER,
|
||||
...ORCHESTRATION_WORKER_OBSERVATION_HANDLERS,
|
||||
...ORCHESTRATION_WORKER_TERMINAL_HANDLERS,
|
||||
...ORCHESTRATION_DISPATCH_HANDLER,
|
||||
...ORCHESTRATION_QUESTION_HANDLER,
|
||||
...ORCHESTRATION_DISPATCH_INSPECTION_HANDLERS,
|
||||
...ORCHESTRATION_REQUEST_SHOW_HANDLER,
|
||||
...ORCHESTRATION_GATE_HANDLERS,
|
||||
...ORCHESTRATION_RESET_HANDLER
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { ORCHESTRATION_HANDLERS } from '../orchestration'
|
||||
import { RuntimeClient } from '../../runtime-client'
|
||||
import { okFixture } from '../../test-fixtures'
|
||||
|
||||
const client = new RuntimeClient('/tmp/orca-implicit-coordinator', 60_000, null, null)
|
||||
const COORDINATOR_WORKTREE = { id: 'repo::/tmp/coord', repoId: 'repo', path: '/tmp/coord' }
|
||||
|
||||
describe('worker-start infers its coordinator from the caller, not the worker placement (#33579)', () => {
|
||||
const calls: { method: string; params: unknown }[] = []
|
||||
|
||||
beforeEach(() => {
|
||||
calls.length = 0
|
||||
vi.stubEnv('ORCA_TERMINAL_HANDLE', '')
|
||||
vi.stubEnv('ORCA_PANE_KEY', '')
|
||||
vi.stubEnv('ORCA_AGENT_SESSION_ID', undefined)
|
||||
vi.stubEnv('ORCA_STRUCTURED_SESSION', '')
|
||||
vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
vi.spyOn(client, 'call').mockImplementation(async (method: string, params?: unknown) => {
|
||||
calls.push({ method, params })
|
||||
if (method === 'worktree.list') {
|
||||
return okFixture('req_list', { worktrees: [COORDINATOR_WORKTREE] })
|
||||
}
|
||||
if (method === 'folderWorkspace.list') {
|
||||
return okFixture('req_folders', { folderWorkspaces: [] })
|
||||
}
|
||||
if (method === 'terminal.resolveActive') {
|
||||
const worktree =
|
||||
params && typeof params === 'object' && 'worktree' in params ? params.worktree : undefined
|
||||
if (worktree !== `id:${COORDINATOR_WORKTREE.id}`) {
|
||||
throw Object.assign(new Error('selector_not_found'), { code: 'selector_not_found' })
|
||||
}
|
||||
return okFixture('req_active', { handle: 'term_coord' })
|
||||
}
|
||||
if (method === 'orchestration.workerStart') {
|
||||
return okFixture('req_start', { state: 'ready', effects: [], residualResources: [] })
|
||||
}
|
||||
throw new Error(`Unexpected RPC: ${method}`)
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllEnvs()
|
||||
vi.restoreAllMocks()
|
||||
process.exitCode = undefined
|
||||
})
|
||||
|
||||
const placements: [string, Record<string, string>][] = [
|
||||
['an exact worktree on another server', { on: 'wsl', worktree: 'id:remote::/srv/app' }],
|
||||
['a new child worktree', { worktree: 'new-child' }],
|
||||
['a reused worker terminal', { worktree: 'id:repo::/tmp/other', terminal: 'term_worker' }]
|
||||
]
|
||||
|
||||
it.each(placements)('for %s', async (_label, placement) => {
|
||||
await ORCHESTRATION_HANDLERS['orchestration worker-start']({
|
||||
flags: new Map<string, string | boolean>([['spec', 'audit'], ...Object.entries(placement)]),
|
||||
client,
|
||||
cwd: '/tmp/coord/src',
|
||||
json: true
|
||||
})
|
||||
|
||||
expect(calls.find((call) => call.method === 'orchestration.workerStart')?.params).toMatchObject(
|
||||
{ from: 'term_coord', ...placement }
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { CommandHandler } from '../dispatch'
|
||||
import type { CommandHandler } from '../dispatch/dispatch'
|
||||
import { formatEnvironment, formatEnvironmentList } from './environment-format'
|
||||
import { formatHostList, formatHostName, type HostNameResult } from './host-format'
|
||||
import { printResult } from '../command-result-output'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import { parseHostFlag } from './execution-host-flag'
|
||||
import {
|
||||
fetchSshTargetSummaries,
|
||||
@@ -15,7 +15,7 @@ import { RuntimeClientError } from '../runtime/types'
|
||||
import type { RuntimeClient } from '../runtime/client'
|
||||
import type { RuntimeRpcSuccess } from '../../shared/runtime-rpc-envelope'
|
||||
|
||||
import { rejectRemoteSelectionFlags } from '../remote-selection-flag-rejection'
|
||||
import { rejectRemoteSelectionFlags } from '../dispatch/remote-selection-flag-rejection'
|
||||
import { redactRuntimeEnvironment } from '../../shared/remote-runtime/host-catalog/runtime-environments'
|
||||
import type { RuntimeStatus } from '../../shared/runtime-session-contracts'
|
||||
import {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HandlerGroup } from '../handler-group-manifest'
|
||||
import type { HandlerGroup } from '../dispatch/handler-group-manifest'
|
||||
|
||||
// The machines Orca reaches: saved hosts and paired environments, the Orca servers it manages on
|
||||
// them, and recipe VMs.
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { listSshTargets } from './host-selector-alternatives'
|
||||
import { RuntimeClient } from '../runtime/client'
|
||||
import { okFixture } from '../test-fixtures'
|
||||
|
||||
const SSH_TARGETS = [{ id: 'ssh-1755000000000-a1b2c3', label: 'openclaw' }]
|
||||
|
||||
afterEach(() => vi.restoreAllMocks())
|
||||
|
||||
function clientWithCall(call: RuntimeClient['call']): RuntimeClient {
|
||||
const client = new RuntimeClient('/tmp/orca-host-alternatives-test', 60_000, null, null)
|
||||
vi.spyOn(client, 'call').mockImplementation(call)
|
||||
return client
|
||||
}
|
||||
|
||||
describe('listSshTargets', () => {
|
||||
it('enriches legacy target rows from host-owned connection state', async () => {
|
||||
const { RuntimeClientError } = await import('../runtime/types.js')
|
||||
const call = vi
|
||||
.fn()
|
||||
.mockRejectedValueOnce(new RuntimeClientError('method_not_found', 'Unknown method'))
|
||||
.mockResolvedValueOnce(okFixture('targets', { targets: SSH_TARGETS }))
|
||||
.mockResolvedValueOnce(
|
||||
okFixture('state', {
|
||||
state: { status: 'connected', remotePlatform: 'win32' }
|
||||
})
|
||||
)
|
||||
|
||||
await expect(listSshTargets(clientWithCall(call))).resolves.toEqual([
|
||||
{ ...SSH_TARGETS[0], connected: true, connectionStatus: 'connected', remotePlatform: 'win32' }
|
||||
])
|
||||
expect(call).toHaveBeenCalledWith('ssh.getState', { targetId: SSH_TARGETS[0].id })
|
||||
})
|
||||
})
|
||||
@@ -1,7 +1,7 @@
|
||||
import { normalizeTypedName } from '../../shared/typed-name-normalization'
|
||||
import type { RuntimeClient } from '../runtime/client'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import { quoteCliCommandArgument } from '../shell-command-quote'
|
||||
import { quoteCliCommandArgument } from '../arguments/shell-command-quote'
|
||||
|
||||
/** `--environment local`: the caller's own Orca, even over an ambient ORCA_ENVIRONMENT or pairing code. */
|
||||
export const LOCAL_ENVIRONMENT = 'local'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Updates can close this connection mid-call; report the outcome from status after the runtime returns.
|
||||
import type { OrcadManagedRuntimeStatus } from '../../shared/orcad-managed-runtime'
|
||||
import type { HandlerContext } from '../dispatch'
|
||||
import { printResult } from '../command-result-output'
|
||||
import type { HandlerContext } from '../dispatch/dispatch'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import type { RuntimeRpcSuccess } from '../../shared/runtime-rpc-envelope'
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@ import type {
|
||||
import { ORCAD_RECOVERY_CHANGED_STATE_CODE } from '../../shared/orcad-managed-runtime'
|
||||
import { MANAGED_SERVER_RUNTIME_CAPABILITY } from '../../shared/host-runtime-capabilities'
|
||||
import type { RuntimeStatus } from '../../shared/runtime-session-contracts'
|
||||
import type { CommandHandler, HandlerContext } from '../dispatch'
|
||||
import { getRequiredStringFlag } from '../flags'
|
||||
import { printResult } from '../command-result-output'
|
||||
import type { CommandHandler, HandlerContext } from '../dispatch/dispatch'
|
||||
import { getRequiredStringFlag } from '../arguments/flags'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import type { RuntimeRpcSuccess } from '../../shared/runtime-rpc-envelope'
|
||||
import { formatManagedServerStatus } from './managed-server-format'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { resolve } from 'node:path'
|
||||
import type { CommandHandler } from '../dispatch'
|
||||
import type { CommandHandler } from '../dispatch/dispatch'
|
||||
import {
|
||||
formatEnvironmentDoctorChecks,
|
||||
type EnvironmentDoctorResult
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { existsSync, readFileSync } from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
import type { CommandHandler } from '../dispatch'
|
||||
import type { CommandHandler } from '../dispatch/dispatch'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
import { parseOrcaYaml } from '../../shared/orca-yaml'
|
||||
import {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { readableWslDistroHoldText } from '../shared/wsl-distro-stopped-hold'
|
||||
import { parseWslUncPath } from '../shared/wsl-paths'
|
||||
import { readableWslDistroHoldText } from '../../shared/wsl-distro-stopped-hold'
|
||||
import { parseWslUncPath } from '../../shared/wsl-paths'
|
||||
|
||||
const FOLDER_UNAVAILABLE_PREFIX = 'folder_workspace_path_unavailable:'
|
||||
|
||||
@@ -18,7 +18,7 @@ const {
|
||||
spawnMock: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('./runtime-client', async () => {
|
||||
vi.mock('./runtime/client', async () => {
|
||||
const { createRuntimeClientModuleMock } = await import('./index-test-harness.js')
|
||||
return createRuntimeClientModuleMock({
|
||||
callMock,
|
||||
@@ -28,6 +28,16 @@ vi.mock('./runtime-client', async () => {
|
||||
})
|
||||
})
|
||||
|
||||
vi.mock('./runtime/launch', async (importOriginal) => ({
|
||||
...(await importOriginal<Record<string, unknown>>()),
|
||||
serveOrcaApp: serveOrcaAppMock
|
||||
}))
|
||||
|
||||
vi.mock('./runtime/metadata', async (importOriginal) => ({
|
||||
...(await importOriginal<Record<string, unknown>>()),
|
||||
getDefaultUserDataPath: getDefaultUserDataPathMock
|
||||
}))
|
||||
|
||||
vi.mock('./runtime/environments', () => ({
|
||||
addEnvironmentFromPairingCode: addEnvironmentFromPairingCodeMock,
|
||||
removeEnvironment: vi.fn(),
|
||||
@@ -44,8 +54,8 @@ vi.mock('child_process', async () => {
|
||||
})
|
||||
|
||||
import { main } from './index'
|
||||
import { RuntimeClientError, RuntimeRpcFailureError } from './runtime-client'
|
||||
import { queueFixtures } from './test-fixtures'
|
||||
import { RuntimeClientError, RuntimeRpcFailureError } from './runtime/types'
|
||||
import { queueFixtures } from './runtime/fixtures/runtime-rpc-fixtures'
|
||||
import { useWorktreeAwarenessEnvironment } from './index-test-harness'
|
||||
import { agentLaunchHostFixture } from './agents/agent-launch-test-fixtures'
|
||||
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
callMock: vi.fn(),
|
||||
runtimeClientConstructorMock: vi.fn(),
|
||||
serveOrcaAppMock: vi.fn(),
|
||||
getDefaultUserDataPathMock: vi.fn(() => '/tmp/orca-user-data')
|
||||
}))
|
||||
vi.mock('./runtime-client', async () => {
|
||||
const { createRuntimeClientModuleMock } = await import('./index-test-harness.js')
|
||||
return createRuntimeClientModuleMock(mocks)
|
||||
})
|
||||
|
||||
import { main } from './index'
|
||||
import { okFixture } from './test-fixtures'
|
||||
import { RuntimeRpcFailureError } from './runtime/types'
|
||||
|
||||
function headlessRefusal(): RuntimeRpcFailureError {
|
||||
return new RuntimeRpcFailureError({
|
||||
id: 'req_open',
|
||||
ok: false,
|
||||
error: { code: 'runtime_error', message: 'renderer_unavailable' },
|
||||
_meta: { runtimeId: 'runtime-1' }
|
||||
})
|
||||
}
|
||||
|
||||
describe('file commands on a server with no app window', () => {
|
||||
const priorExitCode = process.exitCode
|
||||
afterEach(() => {
|
||||
process.exitCode = priorExitCode
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
beforeEach(() => {
|
||||
vi.restoreAllMocks()
|
||||
mocks.callMock.mockReset()
|
||||
process.exitCode = undefined
|
||||
vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
vi.spyOn(console, 'error').mockImplementation(() => {})
|
||||
})
|
||||
|
||||
it('stops open-changed at the first refusal with the same explanation', async () => {
|
||||
mocks.callMock
|
||||
.mockResolvedValueOnce(
|
||||
okFixture('req_status', {
|
||||
entries: [
|
||||
{ path: 'a.ts', status: 'modified', area: 'unstaged' },
|
||||
{ path: 'b.ts', status: 'modified', area: 'unstaged' }
|
||||
]
|
||||
})
|
||||
)
|
||||
.mockRejectedValueOnce(headlessRefusal())
|
||||
|
||||
await main(['file', 'open-changed', '--worktree', 'id:wt-1'], '/tmp/repo')
|
||||
|
||||
expect(mocks.callMock.mock.calls).toEqual([
|
||||
['git.status', { worktree: 'id:wt-1' }],
|
||||
[
|
||||
'files.openDiff',
|
||||
{ worktree: 'id:wt-1', relativePath: 'a.ts', staged: false, navigation: 'caller' }
|
||||
]
|
||||
])
|
||||
|
||||
expect(String(vi.mocked(console.error).mock.calls[0]?.[0])).toContain(
|
||||
'This Orca server has no app window'
|
||||
)
|
||||
})
|
||||
})
|
||||
+12
-2
@@ -18,7 +18,7 @@ const {
|
||||
spawnMock: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('./runtime-client', async () => {
|
||||
vi.mock('./runtime/client', async () => {
|
||||
const { createRuntimeClientModuleMock } = await import('./index-test-harness.js')
|
||||
return createRuntimeClientModuleMock({
|
||||
callMock,
|
||||
@@ -28,6 +28,16 @@ vi.mock('./runtime-client', async () => {
|
||||
})
|
||||
})
|
||||
|
||||
vi.mock('./runtime/launch', async (importOriginal) => ({
|
||||
...(await importOriginal<Record<string, unknown>>()),
|
||||
serveOrcaApp: serveOrcaAppMock
|
||||
}))
|
||||
|
||||
vi.mock('./runtime/metadata', async (importOriginal) => ({
|
||||
...(await importOriginal<Record<string, unknown>>()),
|
||||
getDefaultUserDataPath: getDefaultUserDataPathMock
|
||||
}))
|
||||
|
||||
vi.mock('./runtime/environments', () => ({
|
||||
addEnvironmentFromPairingCode: addEnvironmentFromPairingCodeMock,
|
||||
removeEnvironment: vi.fn(),
|
||||
@@ -44,7 +54,7 @@ vi.mock('child_process', async () => {
|
||||
})
|
||||
|
||||
import { main } from './index'
|
||||
import { okFixture, queueFixtures } from './test-fixtures'
|
||||
import { okFixture, queueFixtures } from './runtime/fixtures/runtime-rpc-fixtures'
|
||||
|
||||
describe('command aliases dispatch to the canonical handler', () => {
|
||||
let logSpy: ReturnType<typeof vi.spyOn>
|
||||
|
||||
+11
-13
@@ -5,37 +5,35 @@ import {
|
||||
normalizeCommandPositionals,
|
||||
parseArgs,
|
||||
resolveHelpPath,
|
||||
specPaths,
|
||||
validateCommandAndFlags
|
||||
} from './args'
|
||||
} from './arguments/args'
|
||||
import { specPaths } from './discovery/command-spec'
|
||||
import { readOrcaCliVersion } from './cli-version'
|
||||
import { dispatch } from './dispatch'
|
||||
import { dispatch } from './dispatch/dispatch'
|
||||
import {
|
||||
resolveEnvironmentSelectorForStore,
|
||||
resolveHostFlagEnvironmentId
|
||||
} from './hosts/execution-host-flag'
|
||||
import { fetchSshTargetSummaries, listSshTargets } from './hosts/host-selector-alternatives'
|
||||
import { reportCliError } from './cli-error'
|
||||
import { reportCliError } from './output/cli-error'
|
||||
import { RuntimeClientError } from './runtime/types'
|
||||
import { cliErrorExitCode } from './cli-exit-code'
|
||||
import { printHelp } from './help'
|
||||
import type { RuntimeClient } from './runtime-client'
|
||||
import { cliErrorExitCode } from './output/cli-exit-code'
|
||||
import { printHelp } from './discovery/help'
|
||||
import type { RuntimeClient } from './runtime/client'
|
||||
import { COMMAND_SPECS } from './specs'
|
||||
import { resolveOrchestrationCliExecutable } from './runtime/orchestration-recovery-command'
|
||||
import { refuseConflictingSessionCallerFlags } from './session-caller-flags'
|
||||
import { ignoresRemoteSelection } from './remote-selection-scope'
|
||||
import { resolveOrchestrationCliExecutable } from './orchestration/recovery/orchestration-recovery-command'
|
||||
import { refuseConflictingSessionCallerFlags } from './orchestration/identity/session-caller-flags'
|
||||
import { ignoresRemoteSelection } from './dispatch/remote-selection-scope'
|
||||
import {
|
||||
isLocalEnvironmentSelector,
|
||||
refuseLocalManagementSelector
|
||||
} from './hosts/local-environment-selector'
|
||||
|
||||
export { COMMAND_SPECS } from './specs'
|
||||
|
||||
const COMMAND_PATHS = COMMAND_SPECS.flatMap((spec) => specPaths(spec))
|
||||
|
||||
// Defer the runtime graph until after help and validation; await it to keep ctx.client synchronous.
|
||||
async function loadRuntimeClientClass(): Promise<typeof RuntimeClient> {
|
||||
return (await import('./runtime-client.js')).RuntimeClient
|
||||
return (await import('./runtime/client.js')).RuntimeClient
|
||||
}
|
||||
|
||||
// The SSH bridge runs here, but ORCA_CLI_CWD carries the remote caller's directory.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HandlerGroup } from '../handler-group-manifest'
|
||||
import type { HandlerGroup } from '../dispatch/handler-group-manifest'
|
||||
|
||||
export const JIRA_HANDLER_GROUP: HandlerGroup = {
|
||||
name: 'jira',
|
||||
|
||||
@@ -6,8 +6,8 @@ import {
|
||||
JIRA_ISSUE_KEY_PATTERN,
|
||||
parseJiraIssueUrl
|
||||
} from '../../shared/jira/jira-issue-url'
|
||||
import type { HandlerContext } from '../dispatch'
|
||||
import { getOptionalStringFlag } from '../flags'
|
||||
import type { HandlerContext } from '../dispatch/dispatch'
|
||||
import { getOptionalStringFlag } from '../arguments/flags'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
|
||||
export function resolveJiraTarget(
|
||||
|
||||
@@ -6,15 +6,15 @@ import type {
|
||||
JiraProject,
|
||||
JiraTransition
|
||||
} from '../../shared/jira/jira-types'
|
||||
import type { CommandHandler, HandlerContext } from '../dispatch'
|
||||
import { readCommandBody } from '../command-body-input'
|
||||
import type { CommandHandler, HandlerContext } from '../dispatch/dispatch'
|
||||
import { readCommandBody } from '../arguments/command-body-input'
|
||||
import {
|
||||
getOptionalJsonFlag,
|
||||
getOptionalStringFlag,
|
||||
getRepeatedStringFlag,
|
||||
getRequiredStringFlag
|
||||
} from '../flags'
|
||||
import { printResult } from '../command-result-output'
|
||||
} from '../arguments/flags'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import { formatJiraCreate } from './jira-format'
|
||||
import { resolveJiraTarget } from './jira-target'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
|
||||
@@ -11,13 +11,13 @@ import type {
|
||||
JiraUser
|
||||
} from '../../shared/jira/jira-types'
|
||||
import { isResolvedJiraIssueMatch, parseJiraIssueUrl } from '../../shared/jira/jira-issue-url'
|
||||
import type { CommandHandler, HandlerContext } from '../dispatch'
|
||||
import type { CommandHandler, HandlerContext } from '../dispatch/dispatch'
|
||||
import {
|
||||
getOptionalPositiveIntegerFlag,
|
||||
getOptionalStringFlag,
|
||||
getRequiredStringFlag
|
||||
} from '../flags'
|
||||
import { printResult } from '../command-result-output'
|
||||
} from '../arguments/flags'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import {
|
||||
formatJiraCommentList,
|
||||
formatJiraIssue,
|
||||
|
||||
@@ -6,9 +6,9 @@ import type {
|
||||
LinearCommentEditResult
|
||||
} from '../../shared/linear/agent-access'
|
||||
import type { LinearCommentAddResult } from '../../shared/linear/agent-result-types'
|
||||
import type { CommandHandler } from '../dispatch'
|
||||
import { getOptionalStringFlag, getRequiredStringFlag } from '../flags'
|
||||
import { printResult } from '../command-result-output'
|
||||
import type { CommandHandler } from '../dispatch/dispatch'
|
||||
import { getOptionalStringFlag, getRequiredStringFlag } from '../arguments/flags'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import {
|
||||
formatLinearCommentAdd,
|
||||
formatLinearCommentDelete,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HandlerGroup } from '../handler-group-manifest'
|
||||
import type { HandlerGroup } from '../dispatch/handler-group-manifest'
|
||||
|
||||
export const LINEAR_HANDLER_GROUP: HandlerGroup = {
|
||||
name: 'linear',
|
||||
|
||||
@@ -2,13 +2,13 @@ import type {
|
||||
LinearMcpIssueListRequest,
|
||||
LinearMcpIssueListResult
|
||||
} from '../../shared/linear/mcp-issue-list'
|
||||
import type { CommandHandler } from '../dispatch'
|
||||
import type { CommandHandler } from '../dispatch/dispatch'
|
||||
import {
|
||||
getOptionalNonNegativeIntegerFlag,
|
||||
getOptionalPositiveIntegerFlag,
|
||||
getOptionalStringFlag
|
||||
} from '../flags'
|
||||
import { printResult } from '../command-result-output'
|
||||
} from '../arguments/flags'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import { formatLinearMcpIssueList, printLinearMcpIssueListWarnings } from './linear-format'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ import type {
|
||||
LinearIssueRelationWriteRequest,
|
||||
LinearIssueRelationWriteResult
|
||||
} from '../../shared/linear/issue-relation-write'
|
||||
import type { CommandHandler } from '../dispatch'
|
||||
import { getRequiredStringFlag } from '../flags'
|
||||
import { printResult } from '../command-result-output'
|
||||
import type { CommandHandler } from '../dispatch/dispatch'
|
||||
import { getRequiredStringFlag } from '../arguments/flags'
|
||||
import { printResult } from '../output/command-result-output'
|
||||
import { formatLinearRelationWrite } from './linear-format'
|
||||
import { buildWriteTargetRequest } from './linear-request-builders'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { readCommandBody } from '../command-body-input'
|
||||
import { readCommandBody } from '../arguments/command-body-input'
|
||||
import type {
|
||||
LinearIssueInclude,
|
||||
LinearIssueListRequest,
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
getOptionalStringFlag,
|
||||
getRepeatedStringFlag,
|
||||
getRequiredStringFlag
|
||||
} from '../flags'
|
||||
} from '../arguments/flags'
|
||||
import { RuntimeClientError } from '../runtime/types'
|
||||
|
||||
const LINEAR_PRIORITY_VALUES = new Map([
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user