diff --git a/fallow-baselines/health.json b/fallow-baselines/health.json index 52fe7fdb4..3f25e1070 100644 --- a/fallow-baselines/health.json +++ b/fallow-baselines/health.json @@ -1,5 +1,10 @@ { "finding_counts": { + "packages/command-registry/src/batch.ts": { + "complexity_moderate": { + "count": 1 + } + }, "src/__tests__/cli-config.test.ts": { "crap_high": { "count": 1 @@ -89,11 +94,6 @@ "count": 1 } }, - "src/core/batch.ts": { - "complexity_moderate": { - "count": 1 - } - }, "src/core/dispatch.ts": { "complexity_critical": { "count": 1 diff --git a/packages/command-registry/package.json b/packages/command-registry/package.json index 04f9add51..cc6e4723d 100644 --- a/packages/command-registry/package.json +++ b/packages/command-registry/package.json @@ -7,6 +7,7 @@ "description": "The command descriptor registry: the single declaration of every command's surface, runtime-use, batch, timeout, and platform-execution traits, plus the catalogs and projections derived from it.", "dependencies": { "@agent-device/contracts": "workspace:*", + "@agent-device/kernel": "workspace:*", "@agent-device/selectors": "workspace:*" }, "exports": { @@ -61,6 +62,14 @@ "./wait-positionals": { "types": "./src/wait-positionals.ts", "default": "./src/wait-positionals.ts" + }, + "./batch": { + "types": "./src/batch.ts", + "default": "./src/batch.ts" + }, + "./batch-policy": { + "types": "./src/batch-policy.ts", + "default": "./src/batch-policy.ts" } } } diff --git a/src/core/__tests__/batch.test.ts b/packages/command-registry/src/__tests__/batch.test.ts similarity index 100% rename from src/core/__tests__/batch.test.ts rename to packages/command-registry/src/__tests__/batch.test.ts diff --git a/src/core/batch-policy.ts b/packages/command-registry/src/batch-policy.ts similarity index 96% rename from src/core/batch-policy.ts rename to packages/command-registry/src/batch-policy.ts index a52ecc249..fc5b371f8 100644 --- a/src/core/batch-policy.ts +++ b/packages/command-registry/src/batch-policy.ts @@ -1,5 +1,5 @@ -import { deriveStructuredBatchCommandNames } from '@agent-device/command-registry/derive'; -import { commandDescriptors } from '@agent-device/command-registry/registry'; +import { deriveStructuredBatchCommandNames } from './derive.ts'; +import { commandDescriptors } from './registry.ts'; import { AppError } from '@agent-device/kernel/errors'; /** diff --git a/src/core/batch.ts b/packages/command-registry/src/batch.ts similarity index 100% rename from src/core/batch.ts rename to packages/command-registry/src/batch.ts diff --git a/packages/contracts/src/batch-step.ts b/packages/contracts/src/batch-step.ts index 2c2c281e3..11f617edb 100644 --- a/packages/contracts/src/batch-step.ts +++ b/packages/contracts/src/batch-step.ts @@ -3,9 +3,11 @@ import type { SessionRuntimeHints } from '@agent-device/kernel/contracts'; /** * One step of a daemon batch, as submitted. * - * Declared here rather than in `core/batch.ts` because the public API vocabulary - * (`contracts/client-replay.ts`) is stated in terms of it, and `core/` sits above contracts. The - * `runtime` field used to be written as `DaemonRequest['runtime']`, which pulled the whole daemon + * Declared here rather than in `@agent-device/command-registry/batch` because the public API + * vocabulary (`contracts/client-replay.ts`) is stated in terms of it, and contracts sits below + * command-registry. + * + * The `runtime` field used to be written as `DaemonRequest['runtime']`, which pulled the whole daemon * request type in to say `SessionRuntimeHints` — the same type, one zone lower. */ export type DaemonBatchStep = { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f6df69220..a803c846e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -231,6 +231,9 @@ importers: '@agent-device/contracts': specifier: workspace:* version: link:../contracts + '@agent-device/kernel': + specifier: workspace:* + version: link:../kernel '@agent-device/selectors': specifier: workspace:* version: link:../selectors diff --git a/src/__tests__/command-descriptor-parity.test.ts b/src/__tests__/command-descriptor-parity.test.ts index 1cc762876..69cab6746 100644 --- a/src/__tests__/command-descriptor-parity.test.ts +++ b/src/__tests__/command-descriptor-parity.test.ts @@ -1,6 +1,6 @@ import assert from 'node:assert/strict'; import { test } from 'vitest'; -import { STRUCTURED_BATCH_COMMAND_NAMES } from '../core/batch-policy.ts'; +import { STRUCTURED_BATCH_COMMAND_NAMES } from '@agent-device/command-registry/batch-policy'; import { INTERNAL_COMMANDS, listCliCommandNames, diff --git a/src/cli/batch-steps.ts b/src/cli/batch-steps.ts index d1349a0c1..5202c4744 100644 --- a/src/cli/batch-steps.ts +++ b/src/cli/batch-steps.ts @@ -9,7 +9,7 @@ import { AppError } from '@agent-device/kernel/errors'; import { BATCH_AVAILABLE_COMMANDS_HINT, readStructuredBatchCommandName, -} from '../core/batch-policy.ts'; +} from '@agent-device/command-registry/batch-policy'; import { assertAllowedKeys } from '../commands/input-readers.ts'; /** diff --git a/src/client/client-types.ts b/src/client/client-types.ts index e2a612855..05523a35b 100644 --- a/src/client/client-types.ts +++ b/src/client/client-types.ts @@ -46,7 +46,7 @@ export type { AlertAction } from '@agent-device/contracts/alert-contract'; export type { AppleOS } from '@agent-device/kernel/device'; // fallow-ignore-next-line unused-type export type { JsonObject } from '@agent-device/contracts/client'; -export type { BatchRunResult } from '../core/batch.ts'; +export type { BatchRunResult } from '@agent-device/command-registry/batch'; import type { AgentDeviceCapabilitiesResult, @@ -138,7 +138,7 @@ import type { MetroReloadResult, } from '@agent-device/contracts/remote'; -import type { BatchRunResult } from '../core/batch.ts'; +import type { BatchRunResult } from '@agent-device/command-registry/batch'; import type { AgentArtifactsResult, diff --git a/src/commands/batch/index.ts b/src/commands/batch/index.ts index 0b3257899..276f552f2 100644 --- a/src/commands/batch/index.ts +++ b/src/commands/batch/index.ts @@ -6,7 +6,7 @@ import { defineCommandFacet, defineCommandFamilyFromFacets } from '../family/typ import { commonToClientOptions } from '../common-input-fields.ts'; import { batchCliOutputFormatters } from './output.ts'; import { createBatchCommandMetadata, type BatchCommandStep, type BatchInput } from './metadata.ts'; -import { STRUCTURED_BATCH_COMMAND_NAMES } from '../../core/batch-policy.ts'; +import { STRUCTURED_BATCH_COMMAND_NAMES } from '@agent-device/command-registry/batch-policy'; import { createBatchDaemonWriter } from './projection.ts'; const batchCommandMetadata = createBatchCommandMetadata(); diff --git a/src/commands/batch/metadata.ts b/src/commands/batch/metadata.ts index b2521aa61..63ba96aba 100644 --- a/src/commands/batch/metadata.ts +++ b/src/commands/batch/metadata.ts @@ -12,7 +12,7 @@ import { type SessionRuntimeHints } from '@agent-device/kernel/contracts'; import { STRUCTURED_BATCH_COMMAND_NAMES, readStructuredBatchCommandName, -} from '../../core/batch-policy.ts'; +} from '@agent-device/command-registry/batch-policy'; import { type CommandMetadata, type JsonSchema } from '../command-contract.ts'; import { customField, diff --git a/src/commands/batch/output.ts b/src/commands/batch/output.ts index 4dc6da946..f2a014fa5 100644 --- a/src/commands/batch/output.ts +++ b/src/commands/batch/output.ts @@ -1,4 +1,4 @@ -import type { BatchRunResult, BatchStepResult } from '../../core/batch.ts'; +import type { BatchRunResult, BatchStepResult } from '@agent-device/command-registry/batch'; import { readCommandMessage } from '@agent-device/kernel/success-text'; import type { CliOutput } from '../command-contract.ts'; import { resultOutput, type CliOutputFormatter } from '../output-common.ts'; diff --git a/src/commands/batch/projection.ts b/src/commands/batch/projection.ts index 69e542e65..353dae549 100644 --- a/src/commands/batch/projection.ts +++ b/src/commands/batch/projection.ts @@ -2,7 +2,7 @@ import { PUBLIC_COMMANDS } from '@agent-device/command-registry/catalog'; import { STRUCTURED_BATCH_COMMAND_NAMES, readStructuredBatchCommandName, -} from '../../core/batch-policy.ts'; +} from '@agent-device/command-registry/batch-policy'; import { parseBatchStepRuntime, readBatchStepInputObject, diff --git a/src/daemon/handlers/session-batch.ts b/src/daemon/handlers/session-batch.ts index 79c2f2f6e..16ade23c6 100644 --- a/src/daemon/handlers/session-batch.ts +++ b/src/daemon/handlers/session-batch.ts @@ -1,4 +1,4 @@ -import { runBatch } from '../../core/batch.ts'; +import { runBatch } from '@agent-device/command-registry/batch'; import type { DaemonInvokeFn, DaemonRequest, DaemonResponse } from '../daemon-request.ts'; export async function runBatchCommands( diff --git a/src/daemon/replay/internal/session-replay-action-runtime.ts b/src/daemon/replay/internal/session-replay-action-runtime.ts index bc9918288..06e2d8db2 100644 --- a/src/daemon/replay/internal/session-replay-action-runtime.ts +++ b/src/daemon/replay/internal/session-replay-action-runtime.ts @@ -1,7 +1,7 @@ import type { SessionAction } from '@agent-device/contracts/session'; import type { CommandFlags } from '@agent-device/contracts/command'; import type { DaemonInvokeFn, DaemonRequest, DaemonResponse } from '../../daemon-request.ts'; -import { mergeParentFlags } from '../../../core/batch.ts'; +import { mergeParentFlags } from '@agent-device/command-registry/batch'; import { AppError, normalizeError } from '@agent-device/kernel/errors'; import { gesturePayloadFromPositionals, diff --git a/src/mcp/__tests__/command-tools-nested-admission.test.ts b/src/mcp/__tests__/command-tools-nested-admission.test.ts index 03041530f..84ea824aa 100644 --- a/src/mcp/__tests__/command-tools-nested-admission.test.ts +++ b/src/mcp/__tests__/command-tools-nested-admission.test.ts @@ -1,7 +1,7 @@ import assert from 'node:assert/strict'; import { test } from 'vitest'; import type { AgentDeviceClient } from '../../client/client-types.ts'; -import { STRUCTURED_BATCH_COMMAND_NAMES } from '../../core/batch-policy.ts'; +import { STRUCTURED_BATCH_COMMAND_NAMES } from '@agent-device/command-registry/batch-policy'; import { findCommandMetadata } from '../../commands/command-metadata.ts'; import { createCommandToolExecutor } from '../command-tools.ts'; diff --git a/src/mcp/command-tools.ts b/src/mcp/command-tools.ts index 3109caa96..fc364d7f1 100644 --- a/src/mcp/command-tools.ts +++ b/src/mcp/command-tools.ts @@ -12,7 +12,7 @@ import { type CommandName, } from '../commands/command-metadata.ts'; import { mcpBody } from '../commands/command-text.ts'; -import { resolveStructuredBatchCommandName } from '../core/batch-policy.ts'; +import { resolveStructuredBatchCommandName } from '@agent-device/command-registry/batch-policy'; import { resolveCommandRecordsSessionAction, resolveCommandTimeoutPolicy, diff --git a/src/sdk/batch.ts b/src/sdk/batch.ts index 89fc6e59c..851a4adc4 100644 --- a/src/sdk/batch.ts +++ b/src/sdk/batch.ts @@ -1 +1 @@ -export { runBatch } from '../core/batch.ts'; +export { runBatch } from '@agent-device/command-registry/batch'; diff --git a/tsdown.config.ts b/tsdown.config.ts index 9e368d46c..d519fcb75 100644 --- a/tsdown.config.ts +++ b/tsdown.config.ts @@ -32,8 +32,16 @@ const publicSdkChunkGroups = [ /packages[\\/]kernel[\\/]src[\\/]snapshot\.ts$/, ], ['sdk-io', /src[\\/]io\.d\.[cm]?ts$/, /src[\\/]io\.ts$/], - ['sdk-batch', /src[\\/]batch-policy\.d\.[cm]?ts$/, /src[\\/]batch-policy\.ts$/], - ['sdk-batch-runner', /src[\\/]core[\\/]batch\.d\.[cm]?ts$/, /src[\\/]core[\\/]batch\.ts$/], + [ + 'sdk-batch', + /packages[\\/]command-registry[\\/]src[\\/]batch-policy\.d\.[cm]?ts$/, + /packages[\\/]command-registry[\\/]src[\\/]batch-policy\.ts$/, + ], + [ + 'sdk-batch-runner', + /packages[\\/]command-registry[\\/]src[\\/]batch\.d\.[cm]?ts$/, + /packages[\\/]command-registry[\\/]src[\\/]batch\.ts$/, + ], ['sdk-finders', /src[\\/]finders\.d\.[cm]?ts$/, /src[\\/]finders\.ts$/], [ 'sdk-android-adb',