diff --git a/docs/adr/0030-process-lock-exclusion.md b/docs/adr/0030-process-lock-exclusion.md index 324c9f4c57..55b7f403e9 100644 --- a/docs/adr/0030-process-lock-exclusion.md +++ b/docs/adr/0030-process-lock-exclusion.md @@ -65,7 +65,7 @@ require the same confirmation for every process using their own paths. ## Registration operations -[Shared retirement](../../src/daemon-registration-owner.ts) owns verified termination, protected +[Shared retirement](../../packages/daemon-contracts/src/daemon-registration-owner.ts) owns verified termination, protected metadata inspection and removal, and release. Takeover, failed startup, replay cleanup, timeout reset and manual stop await its result. Abandoned recovery uses the same protected retirement sequence without signaling a live process. Daemon publication and shutdown use functions bound diff --git a/docs/adr/0033-collocation-decision-table.md b/docs/adr/0033-collocation-decision-table.md index 1fc9078e2d..4baf38c59f 100644 --- a/docs/adr/0033-collocation-decision-table.md +++ b/docs/adr/0033-collocation-decision-table.md @@ -123,25 +123,28 @@ already owns the operations behind the vocabulary. ### (root) `#3288` assigns every process-root module a logical zone in -`scripts/layering/root-module-zones.ts` (`daemon-contracts` rank 2, `command-runtime` rank 3, +`scripts/layering/root-module-zones.ts` (`command-runtime` rank 3, `platform-runtime` rank 4, …) while leaving the files physically in place. Per the maintainer design decision, that reclassification is **not** completed collocation: the physical moves under #3294 (child of #3276) replace each file's row with folder-derived ownership. -`daemon-diagnostics-scope.ts` has moved into `src/daemon-contracts/`; the runtime assembly pair -`runtime-command-surface.ts` / `runtime-factory.ts` has moved into `src/command-runtime/`. -The other rows below are keeps: the -daemon ⇄ client shared files (`daemon-policy-file.ts`, `provider-credential-fingerprint.ts`, -`request-progress-protocol.ts`) trace to #2559, which relocated the shared contracts **to the -process root** so the client stops importing `src/daemon/` at all; R78 keeps any client→daemon +The runtime assembly pair +`runtime-command-surface.ts` / `runtime-factory.ts` has moved into `src/command-runtime/`, and +the whole `daemon-contracts` zone has moved into `packages/daemon-contracts` — the folder and +package derive the zone, so every moved file's `ROOT_MODULE_ZONES` row is gone. +The daemon ⇄ client shared files that remain here (`provider-credential-fingerprint.ts`) trace +to #2559, which relocated the shared contracts **to the process root** so the client stops +importing `src/daemon/` at all; R78 keeps any client→daemon edge at zero runtime and a five-line recorded type-only residue, and #3288's `daemon-contracts` -zone is the declaration of that shared-below-both ownership. Rows on path-keyed evidence alone -(the `platform-runtime-*` seams) say "retain for this batch": a guard's current path lists -constrain a relocation, they are not independent proof the placement is optimal. +zone was the declaration of that shared-below-both ownership — the extraction makes it +physical, with R11 and the package's dependency edges holding the same boundary. Rows on +path-keyed evidence alone (the `platform-runtime-*` seams) say "retain for this batch": a guard's +current path lists constrain a relocation, they are not independent proof the placement is +optimal. | File | Decision | Reason | | --- | --- | --- | -| `src/daemon-diagnostics-scope.ts` | moved → `src/daemon-contracts/daemon-diagnostics-scope.ts` ([#3297](https://github.com/callstack/agent-device/pull/3297)) | Physical move landed: the helper now lives under the folder that derives its `daemon-contracts` zone, so `topFolder` replaces the per-file `ROOT_MODULE_ZONES` row and an internal rename needs no ownership-table edit. | -| `src/daemon-policy-file.ts` | keep | Daemon ⇄ client shared contract from #2559, declared `daemon-contracts` by #3288 — the shared-below-both ownership the spine needs, since daemon-client (rank 5) dynamically imports it. | +| `src/daemon-diagnostics-scope.ts` | moved → `packages/daemon-contracts/src/daemon-diagnostics-scope.ts` ([#3297](https://github.com/callstack/agent-device/pull/3297) into `src/daemon-contracts/`, then the package extraction) | The whole `daemon-contracts` zone now lives as `packages/daemon-contracts`, so the package directory derives the zone and the per-file `ROOT_MODULE_ZONES` row stays deleted; an internal rename needs no ownership-table edit. | +| `src/daemon-policy-file.ts` | moved → `packages/daemon-contracts/src/daemon-policy-file.ts` | Daemon ⇄ client shared contract from #2559, declared `daemon-contracts` by #3288 — the shared-below-both ownership the spine needs, since daemon-client (rank 5) dynamically imports it. The extraction makes that placement physical: the package sits below both sides and its manifest exports own the boundary. | | `src/daemon.ts` | keep | Entry point (`internal/daemon` bundle entry); composition roots stay in root by umbrella §4. | | `src/platform-runtime-apple-runner-owner.ts` | retain for this batch | `platform-runtime-*` composition seam: R13's exact-importer rule and the ADR 0022 R76 inventory key on its path, so relocation requires coordinated ownership changes to both declarations — the rules constrain the move, they do not independently prove the placement. | | `src/platform-runtime-daemon-lifecycle.ts` | retain for this batch | Same path-keyed R13/ADR 0022 seam: relocation is possible only with coordinated changes to those declarations. | @@ -149,7 +152,7 @@ constrain a relocation, they are not independent proof the placement is optimal. | `src/platform-runtime-resource-cleanup.ts` | retain for this batch | Same path-keyed R13/ADR 0022 seam. | | `src/provider-credential-fingerprint.ts` | keep | Daemon ⇄ client shared contract from the same #2559 decision as `daemon-policy-file.ts`; #3288 declares its zone beside the provider composition that reads the credentials it fingerprints. | | `src/provider-limrun-runtime.ts` | keep | Proposed → provider-limrun, but there is no seam: the class's constructor self-builds the root dependency factory (`src/sdk/limrun-runtime-dependencies.ts`), which is the ADR 0019 composition seam — it loads the root's adb-host binder, core Android interactor, and platform-runtime app-state helpers that the package must not import. Moving the class means moving that composition, which is design, not a move. | -| `src/request-progress-protocol.ts` | keep | Daemon ⇄ client shared contract from the same #2559 decision — the client reads it statically (`daemon-client-progress.ts`) and the server through `src/daemon/server/`, so only #2559's shared-placement boundary and the wire-compat ledgers pin it; declared `daemon-contracts` by #3288. Contracts was considered and R18 keeps contracts free of envelope validation mechanics. | +| `src/request-progress-protocol.ts` | moved → `packages/daemon-contracts/src/request-progress-protocol.ts` | Daemon ⇄ client shared contract from the same #2559 decision — the client reads it statically (`daemon-client-progress.ts`) and the server through `src/daemon/server/`, so only #2559's shared-placement boundary and the wire-compat ledgers pin it; declared `daemon-contracts` by #3288 and now physically placed by the extraction. Contracts was considered and R18 keeps contracts free of envelope validation mechanics. The wire-ledger keys moved with the file. | | `src/runtime-command-surface.ts` | moved → `src/command-runtime/runtime-command-surface.ts` ([#3299](https://github.com/callstack/agent-device/pull/3299)) | Physical move landed with `runtime-factory.ts` as one assembly group: the command-surface binding sits beside the factory it composes, under the folder that derives its `command-runtime` zone, so `topFolder` replaces the per-file `ROOT_MODULE_ZONES` row. | | `src/runtime-factory.ts` | moved → `src/command-runtime/runtime-factory.ts` ([#3299](https://github.com/callstack/agent-device/pull/3299)) | Physical move landed: the runtime assembly now lives under the folder that derives its `command-runtime` zone, with the same row deletion through folder-derived ownership. | @@ -173,12 +176,17 @@ files have no seam (published facade, public-type collision, root dependency fac ## Follow-ups (tracked on #3281) - Physical root-pass moves under [#3294](https://github.com/callstack/agent-device/issues/3294) - (child of #3276): `daemon-diagnostics-scope.ts` has moved into `src/daemon-contracts/` - ([#3297](https://github.com/callstack/agent-device/pull/3297)); the runtime assembly pair + (child of #3276): the runtime assembly pair `runtime-command-surface.ts` / `runtime-factory.ts` is collocated in `src/command-runtime/` ([#3299](https://github.com/callstack/agent-device/pull/3299)). Each folder derives its zone, replacing the moved files' `ROOT_MODULE_ZONES` rows; #3288's zone assignments alone were - classification, and each landed move completes its own file's collocation. + classification, and each landed move completes its own file's collocation. The + `daemon-contracts` side landed as a workspace package: the zone's ten files (`daemon-owner-cleanup`, + `daemon-policy-file`, `daemon-process`, `daemon-registration-owner`, `daemon-registration`, + `daemon-resolution`, `daemon-shutdown-report`, `request-progress-protocol`, + `session-repair-tombstone`, and `daemon-diagnostics-scope` from `src/daemon-contracts/`, first + moved there by [#3297](https://github.com/callstack/agent-device/pull/3297)) are now + `packages/daemon-contracts/src/` behind narrow per-file subpath exports. ## Refuted alternatives diff --git a/examples/sdk/tsconfig.json b/examples/sdk/tsconfig.json index 9ad9c220f9..2e55f68281 100644 --- a/examples/sdk/tsconfig.json +++ b/examples/sdk/tsconfig.json @@ -39,6 +39,7 @@ { "path": "../../packages/capture-kit" }, { "path": "../../packages/command-registry" }, { "path": "../../packages/contracts" }, + { "path": "../../packages/daemon-contracts" }, { "path": "../../packages/device-selection" }, { "path": "../../packages/host-kit" }, { "path": "../../packages/kernel" }, diff --git a/package.json b/package.json index 31d81c8bea..3f39214c44 100644 --- a/package.json +++ b/package.json @@ -293,6 +293,7 @@ "@agent-device/capture-kit": "workspace:*", "@agent-device/command-registry": "workspace:*", "@agent-device/contracts": "workspace:*", + "@agent-device/daemon-contracts": "workspace:*", "@agent-device/device-selection": "workspace:*", "@agent-device/host-kit": "workspace:*", "@agent-device/kernel": "workspace:*", diff --git a/packages/contracts/src/request-progress.ts b/packages/contracts/src/request-progress.ts index 4d5adbe926..be8d34ad17 100644 --- a/packages/contracts/src/request-progress.ts +++ b/packages/contracts/src/request-progress.ts @@ -1,7 +1,7 @@ /** * Progress events the daemon streams to a connected client while a request runs. * - * These are wire values: `src/request-progress-protocol.ts` serializes them onto the + * These are wire values: `packages/daemon-contracts/src/request-progress-protocol.ts` serializes them onto the * response stream and the CLI reconstructs them before handing them to the replay-test * reporter registry. They therefore belong to neither side — the daemon's request-global * progress plumbing carries them, and the replay-test scheduler produces and interprets diff --git a/packages/daemon-contracts/package.json b/packages/daemon-contracts/package.json new file mode 100644 index 0000000000..7dfa565d62 --- /dev/null +++ b/packages/daemon-contracts/package.json @@ -0,0 +1,59 @@ +{ + "name": "@agent-device/daemon-contracts", + "version": "0.0.0", + "private": true, + "type": "module", + "description": "On-disk and wire contracts a daemon process shares with its clients (#2559): state-dir and transport resolution, registration and ownership, process liveness, shutdown reports, the repair tombstone, progress-envelope framing, the diagnostics scope, and owner-cleanup vocabulary. Internal workspace package bundled into the published agent-device artifact.", + "dependencies": { + "@agent-device/command-registry": "workspace:*", + "@agent-device/contracts": "workspace:*", + "@agent-device/host-kit": "workspace:*", + "@agent-device/kernel": "workspace:*" + }, + "exports": { + "./daemon-diagnostics-scope": { + "types": "./src/daemon-diagnostics-scope.ts", + "default": "./src/daemon-diagnostics-scope.ts" + }, + "./daemon-owner-cleanup": { + "types": "./src/daemon-owner-cleanup.ts", + "default": "./src/daemon-owner-cleanup.ts" + }, + "./daemon-policy-file": { + "types": "./src/daemon-policy-file.ts", + "default": "./src/daemon-policy-file.ts" + }, + "./daemon-process": { + "types": "./src/daemon-process.ts", + "default": "./src/daemon-process.ts" + }, + "./daemon-registration": { + "types": "./src/daemon-registration.ts", + "default": "./src/daemon-registration.ts" + }, + "./daemon-registration-fixtures": { + "types": "./src/daemon-registration.fixtures.ts", + "default": "./src/daemon-registration.fixtures.ts" + }, + "./daemon-registration-owner": { + "types": "./src/daemon-registration-owner.ts", + "default": "./src/daemon-registration-owner.ts" + }, + "./daemon-resolution": { + "types": "./src/daemon-resolution.ts", + "default": "./src/daemon-resolution.ts" + }, + "./daemon-shutdown-report": { + "types": "./src/daemon-shutdown-report.ts", + "default": "./src/daemon-shutdown-report.ts" + }, + "./request-progress-protocol": { + "types": "./src/request-progress-protocol.ts", + "default": "./src/request-progress-protocol.ts" + }, + "./session-repair-tombstone": { + "types": "./src/session-repair-tombstone.ts", + "default": "./src/session-repair-tombstone.ts" + } + } +} diff --git a/src/daemon-contracts/daemon-diagnostics-scope.test.ts b/packages/daemon-contracts/src/daemon-diagnostics-scope.test.ts similarity index 96% rename from src/daemon-contracts/daemon-diagnostics-scope.test.ts rename to packages/daemon-contracts/src/daemon-diagnostics-scope.test.ts index 830672f674..0ee86269d4 100644 --- a/src/daemon-contracts/daemon-diagnostics-scope.test.ts +++ b/packages/daemon-contracts/src/daemon-diagnostics-scope.test.ts @@ -4,7 +4,7 @@ import path from 'node:path'; import { afterEach, beforeEach, test } from 'vitest'; import { emitDiagnostic } from '@agent-device/host-kit/diagnostics'; import { withDaemonDiagnosticsScope } from './daemon-diagnostics-scope.ts'; -import { mkdtempForTestSync } from '../__tests__/test-utils/tmp-dir.ts'; +import { mkdtempForTestSync } from './tmp-dir.fixtures.ts'; let dir: string; let logPath: string; diff --git a/src/daemon-contracts/daemon-diagnostics-scope.ts b/packages/daemon-contracts/src/daemon-diagnostics-scope.ts similarity index 100% rename from src/daemon-contracts/daemon-diagnostics-scope.ts rename to packages/daemon-contracts/src/daemon-diagnostics-scope.ts diff --git a/src/daemon-owner-cleanup.ts b/packages/daemon-contracts/src/daemon-owner-cleanup.ts similarity index 100% rename from src/daemon-owner-cleanup.ts rename to packages/daemon-contracts/src/daemon-owner-cleanup.ts diff --git a/src/__tests__/daemon-policy-file.test.ts b/packages/daemon-contracts/src/daemon-policy-file.test.ts similarity index 97% rename from src/__tests__/daemon-policy-file.test.ts rename to packages/daemon-contracts/src/daemon-policy-file.test.ts index 8a29c90bf3..3ebae4206b 100644 --- a/src/__tests__/daemon-policy-file.test.ts +++ b/packages/daemon-contracts/src/daemon-policy-file.test.ts @@ -4,8 +4,8 @@ import path from 'node:path'; import { expect, test } from 'vitest'; import { commandDescriptors } from '@agent-device/command-registry/registry'; import type { CommandDescriptor } from '@agent-device/command-registry/types'; -import { mkdtempForTestSync } from './test-utils/tmp-dir.ts'; -import { DAEMON_POLICY_ENV, loadDaemonPolicy, parseDaemonPolicy } from '../daemon-policy-file.ts'; +import { mkdtempForTestSync } from './tmp-dir.fixtures.ts'; +import { DAEMON_POLICY_ENV, loadDaemonPolicy, parseDaemonPolicy } from './daemon-policy-file.ts'; const SOURCE = '/etc/agent-device/policy.json'; diff --git a/src/daemon-policy-file.ts b/packages/daemon-contracts/src/daemon-policy-file.ts similarity index 100% rename from src/daemon-policy-file.ts rename to packages/daemon-contracts/src/daemon-policy-file.ts diff --git a/src/__tests__/daemon-process-takeover.test.ts b/packages/daemon-contracts/src/daemon-process-takeover.test.ts similarity index 99% rename from src/__tests__/daemon-process-takeover.test.ts rename to packages/daemon-contracts/src/daemon-process-takeover.test.ts index 99292988f6..bc7a33e55a 100644 --- a/src/__tests__/daemon-process-takeover.test.ts +++ b/packages/daemon-contracts/src/daemon-process-takeover.test.ts @@ -6,7 +6,7 @@ import os from 'node:os'; import path from 'node:path'; import { afterEach, test } from 'vitest'; import { isProcessAlive, readProcessStartTime } from '@agent-device/host-kit/process'; -import { isAgentDeviceDaemonProcess, stopDaemonProcess } from '../daemon-process.ts'; +import { isAgentDeviceDaemonProcess, stopDaemonProcess } from './daemon-process.ts'; const TAKEOVER_TIMEOUTS = { termTimeoutMs: 5_000, killTimeoutMs: 2_000 }; const spawnedChildren: { child: ChildProcess; exited: Promise }[] = []; diff --git a/src/__tests__/daemon-process.test.ts b/packages/daemon-contracts/src/daemon-process.test.ts similarity index 96% rename from src/__tests__/daemon-process.test.ts rename to packages/daemon-contracts/src/daemon-process.test.ts index 291e63150d..3e683c7192 100644 --- a/src/__tests__/daemon-process.test.ts +++ b/packages/daemon-contracts/src/daemon-process.test.ts @@ -1,6 +1,6 @@ import assert from 'node:assert/strict'; import { test } from 'vitest'; -import { isAgentDeviceDaemonCommand } from '../daemon-process.ts'; +import { isAgentDeviceDaemonCommand } from './daemon-process.ts'; test('isAgentDeviceDaemonCommand matches expected daemon command', () => { assert.equal(isAgentDeviceDaemonCommand('node /tmp/agent-device/dist/src/daemon.js'), true); diff --git a/src/daemon-process.ts b/packages/daemon-contracts/src/daemon-process.ts similarity index 100% rename from src/daemon-process.ts rename to packages/daemon-contracts/src/daemon-process.ts diff --git a/src/daemon-registration-owner.ts b/packages/daemon-contracts/src/daemon-registration-owner.ts similarity index 99% rename from src/daemon-registration-owner.ts rename to packages/daemon-contracts/src/daemon-registration-owner.ts index b353cb7a06..c2276c9f2d 100644 --- a/src/daemon-registration-owner.ts +++ b/packages/daemon-contracts/src/daemon-registration-owner.ts @@ -22,7 +22,7 @@ import { type ProcessLockAcquisition, } from '@agent-device/host-kit/file'; import { emitDiagnostic } from '@agent-device/host-kit/diagnostics'; -import { withDaemonDiagnosticsScope } from './daemon-contracts/daemon-diagnostics-scope.ts'; +import { withDaemonDiagnosticsScope } from './daemon-diagnostics-scope.ts'; import type { DaemonCodeOrigin } from '@agent-device/host-kit/code-signature'; import { resolveDaemonPaths, diff --git a/packages/daemon-contracts/src/daemon-registration.fixtures.ts b/packages/daemon-contracts/src/daemon-registration.fixtures.ts new file mode 100644 index 0000000000..daefbb5cb7 --- /dev/null +++ b/packages/daemon-contracts/src/daemon-registration.fixtures.ts @@ -0,0 +1,23 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import type { OwnerIdentity } from '@agent-device/host-kit/process'; + +/** + * Publishes the daemon registration a running daemon writes for its state dir. + * Claim ownership is only reachable through the daemon named there, so tests + * that exercise reachability have to stand one in. + */ +export function publishDaemonRegistration(stateDir: string, owner: OwnerIdentity): void { + fs.mkdirSync(stateDir, { recursive: true }); + fs.writeFileSync( + path.join(stateDir, 'daemon.json'), + JSON.stringify({ + port: 1, + transport: 'socket', + token: 'test-token', + pid: owner.pid, + ...(owner.startTime === null ? {} : { processStartTime: owner.startTime }), + stateDir, + }), + ); +} diff --git a/src/__tests__/daemon-registration.test.ts b/packages/daemon-contracts/src/daemon-registration.test.ts similarity index 97% rename from src/__tests__/daemon-registration.test.ts rename to packages/daemon-contracts/src/daemon-registration.test.ts index 2df32f3cee..40cf1e3100 100644 --- a/src/__tests__/daemon-registration.test.ts +++ b/packages/daemon-contracts/src/daemon-registration.test.ts @@ -6,9 +6,9 @@ import { isSupersededDaemonOwner, readRegisteredDaemonIdentity, readRegisteredDaemonOwnership, -} from '../daemon-registration.ts'; -import { publishDaemonRegistration } from './test-utils/device-claim-store.ts'; -import { mkdtempForTestSync } from './test-utils/tmp-dir.ts'; +} from './daemon-registration.ts'; +import { publishDaemonRegistration } from './daemon-registration.fixtures.ts'; +import { mkdtempForTestSync } from './tmp-dir.fixtures.ts'; const roots: string[] = []; diff --git a/src/daemon-registration.ts b/packages/daemon-contracts/src/daemon-registration.ts similarity index 100% rename from src/daemon-registration.ts rename to packages/daemon-contracts/src/daemon-registration.ts diff --git a/src/daemon-resolution.ts b/packages/daemon-contracts/src/daemon-resolution.ts similarity index 100% rename from src/daemon-resolution.ts rename to packages/daemon-contracts/src/daemon-resolution.ts diff --git a/src/__tests__/daemon-shutdown-report.test.ts b/packages/daemon-contracts/src/daemon-shutdown-report.test.ts similarity index 92% rename from src/__tests__/daemon-shutdown-report.test.ts rename to packages/daemon-contracts/src/daemon-shutdown-report.test.ts index 0e6e555561..6aa1bec8d9 100644 --- a/src/__tests__/daemon-shutdown-report.test.ts +++ b/packages/daemon-contracts/src/daemon-shutdown-report.test.ts @@ -1,9 +1,9 @@ import fs from 'node:fs'; import path from 'node:path'; import { expect, test } from 'vitest'; -import { readDaemonShutdownReport, buildDaemonShutdownReport } from '../daemon-shutdown-report.ts'; -import { LeaseRegistry } from '../daemon/lease-registry.ts'; -import { mkdtempForTestSync } from './test-utils/tmp-dir.ts'; +import type { DeviceLease } from '@agent-device/contracts/device'; +import { readDaemonShutdownReport, buildDaemonShutdownReport } from './daemon-shutdown-report.ts'; +import { mkdtempForTestSync } from './tmp-dir.fixtures.ts'; const claim = { deviceKey: 'local:android:none:emulator-5554', @@ -14,11 +14,16 @@ const claim = { test('round-trips provider release and device claim records without lease credentials', () => { const stateDir = mkdtempForTestSync('agent-device-shutdown-report-'); - const lease = new LeaseRegistry().allocateLease({ + const lease: DeviceLease = { + leaseId: 'lease-1', tenantId: 'tenant-a', runId: 'run-1', + backend: 'android-instance', leaseProvider: 'limrun', - }); + createdAt: 0, + heartbeatAt: 0, + expiresAt: 0, + }; try { const report = buildDaemonShutdownReport({ diff --git a/src/daemon-shutdown-report.ts b/packages/daemon-contracts/src/daemon-shutdown-report.ts similarity index 100% rename from src/daemon-shutdown-report.ts rename to packages/daemon-contracts/src/daemon-shutdown-report.ts diff --git a/src/request-progress-protocol.ts b/packages/daemon-contracts/src/request-progress-protocol.ts similarity index 100% rename from src/request-progress-protocol.ts rename to packages/daemon-contracts/src/request-progress-protocol.ts diff --git a/src/session-repair-tombstone.test.ts b/packages/daemon-contracts/src/session-repair-tombstone.test.ts similarity index 97% rename from src/session-repair-tombstone.test.ts rename to packages/daemon-contracts/src/session-repair-tombstone.test.ts index 444faf2e0f..aaf252c0bb 100644 --- a/src/session-repair-tombstone.test.ts +++ b/packages/daemon-contracts/src/session-repair-tombstone.test.ts @@ -3,7 +3,7 @@ import fs from 'node:fs'; import path from 'node:path'; import { expect, test } from 'vitest'; import { AppError } from '@agent-device/kernel/errors'; -import { mkdtempForTestSync } from './__tests__/test-utils/tmp-dir.ts'; +import { mkdtempForTestSync } from './tmp-dir.fixtures.ts'; import { findUnrecoveredRepairCommitFailure, readRepairTombstoneFile, diff --git a/src/session-repair-tombstone.ts b/packages/daemon-contracts/src/session-repair-tombstone.ts similarity index 100% rename from src/session-repair-tombstone.ts rename to packages/daemon-contracts/src/session-repair-tombstone.ts diff --git a/packages/daemon-contracts/src/tmp-dir.fixtures.ts b/packages/daemon-contracts/src/tmp-dir.fixtures.ts new file mode 100644 index 0000000000..6df3c9f35c --- /dev/null +++ b/packages/daemon-contracts/src/tmp-dir.fixtures.ts @@ -0,0 +1,12 @@ +import fs from 'node:fs'; +import fsPromises from 'node:fs/promises'; +import os from 'node:os'; +import path from 'node:path'; + +export async function mkdtempForTest(prefix: string): Promise { + return fsPromises.mkdtemp(path.join(os.tmpdir(), prefix)); +} + +export function mkdtempForTestSync(prefix: string): string { + return fs.mkdtempSync(path.join(os.tmpdir(), prefix)); +} diff --git a/packages/daemon-contracts/tsconfig.json b/packages/daemon-contracts/tsconfig.json new file mode 100644 index 0000000000..e6eb415c43 --- /dev/null +++ b/packages/daemon-contracts/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "composite": true, + "noEmit": false, + "emitDeclarationOnly": true, + "declaration": true, + "declarationDir": "./dist-types", + "rootDir": "./src", + "tsBuildInfoFile": "./dist-types/index.tsbuildinfo" + }, + "include": ["src"], + "references": [ + { "path": "../command-registry" }, + { "path": "../contracts" }, + { "path": "../host-kit" }, + { "path": "../kernel" } + ] +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 34e0b32221..77225c38e2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -31,6 +31,9 @@ importers: '@agent-device/contracts': specifier: workspace:* version: link:packages/contracts + '@agent-device/daemon-contracts': + specifier: workspace:* + version: link:packages/daemon-contracts '@agent-device/device-selection': specifier: workspace:* version: link:packages/device-selection @@ -265,6 +268,21 @@ importers: specifier: ^4.9.0 version: 4.9.0 + packages/daemon-contracts: + dependencies: + '@agent-device/command-registry': + specifier: workspace:* + version: link:../command-registry + '@agent-device/contracts': + specifier: workspace:* + version: link:../contracts + '@agent-device/host-kit': + specifier: workspace:* + version: link:../host-kit + '@agent-device/kernel': + specifier: workspace:* + version: link:../kernel + packages/device-selection: dependencies: '@agent-device/contracts': diff --git a/scripts/clean-daemon.ts b/scripts/clean-daemon.ts index efd775881a..ce3c39ce00 100644 --- a/scripts/clean-daemon.ts +++ b/scripts/clean-daemon.ts @@ -2,12 +2,12 @@ import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; import { AppError } from '@agent-device/kernel/errors'; -import { resolveDaemonPaths } from '../src/daemon-resolution.ts'; -import { readRegisteredDaemonIdentity } from '../src/daemon-registration.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; +import { readRegisteredDaemonIdentity } from '@agent-device/daemon-contracts/daemon-registration'; import { stopAndRetireDaemon, recoverAbandonedDaemonRegistration, -} from '../src/daemon-registration-owner.ts'; +} from '@agent-device/daemon-contracts/daemon-registration-owner'; const DAEMON_TERM_TIMEOUT_MS = 15_000; const DAEMON_KILL_TIMEOUT_MS = 2_000; diff --git a/scripts/ios-snapshot-benchmark/cell-admission.ts b/scripts/ios-snapshot-benchmark/cell-admission.ts index 875f112b55..685eee23b5 100644 --- a/scripts/ios-snapshot-benchmark/cell-admission.ts +++ b/scripts/ios-snapshot-benchmark/cell-admission.ts @@ -1,7 +1,7 @@ import fs from 'node:fs'; -import { resolveDaemonPaths } from '../../src/daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { readDaemonInfo } from '../../src/daemon-client/daemon-client-metadata.ts'; -import { isAgentDeviceDaemonProcess } from '../../src/daemon-process.ts'; +import { isAgentDeviceDaemonProcess } from '@agent-device/daemon-contracts/daemon-process'; import { openFixture, pressFixtureTarget, diff --git a/scripts/layering/daemon-client-entry.test.ts b/scripts/layering/daemon-client-entry.test.ts index 7bf5f64587..6027e5fef3 100644 --- a/scripts/layering/daemon-client-entry.test.ts +++ b/scripts/layering/daemon-client-entry.test.ts @@ -37,7 +37,11 @@ test('the recorded wire-only edges are the accepted residue', () => { test('a client import of a non-daemon module is not daemon-client entry surface', () => { const edges = [ ...recordedWireEdges(), - clientEdge('src/daemon-client/daemon-client-metadata.ts', 'src/daemon-process.ts', 'value'), + clientEdge( + 'src/daemon-client/daemon-client-metadata.ts', + 'packages/daemon-contracts/src/daemon-process.ts', + 'value', + ), clientEdge('src/daemon-client/daemon-client-lifecycle.ts', 'src/config.ts', 'value'), ]; assert.deepEqual(checkDaemonClientEntry(edges), []); diff --git a/scripts/layering/daemon-client-entry.ts b/scripts/layering/daemon-client-entry.ts index 16b687df4f..1b04c923e7 100644 --- a/scripts/layering/daemon-client-entry.ts +++ b/scripts/layering/daemon-client-entry.ts @@ -4,7 +4,8 @@ import type { LayeringViolation, ResolvedImportEdge } from './model.ts'; // daemon over the network, not over its module graph, so it is NOT an entry point into daemon // internals: the process root composition is. Every on-disk or protocol contract the client shares // with the daemon (state-dir/transport resolution, pidfile liveness, the repair tombstone, the -// progress framing) therefore lives at the process root, not under `src/daemon/`, and the client +// progress framing) therefore lives below both sides — since the daemon-contracts extraction, in +// `packages/daemon-contracts` — not under `src/daemon/`, and the client // reaches it there. What remains is the client reading the daemon's request/response vocabulary — // the `DaemonRequest`/`DaemonResponse` types that anchor the ADR 0006 wire surface — recorded here, // per measured `file -> target` edge, and only as a type-only import. A runtime (value or dynamic) @@ -80,8 +81,8 @@ type MeasuredEdge = { file: string; target: string; line: number; runtimeKind: s * Catches: the client reaching daemon internals again — a runtime import of any daemon module, or a * new type-only import that was not measured and recorded. The runtime half is the regression this * gate exists for: #2559 relocated the shared contracts to the process root specifically so the - * client stops value-importing `config.ts`, `daemon-process.ts`, `session-repair-tombstone.ts`, - * and `request-progress-protocol.ts`. The mirror failure — a recorded edge whose import is gone — + * client stops value-importing `config.ts` or the shared contracts now owned by + * `packages/daemon-contracts`. The mirror failure — a recorded edge whose import is gone — * is caught too, so a repair cannot leave the door open. * Evidence: #2559 measured 13 client→daemon pairs (8 runtime) at the #2557 tip; the runtime half is * now 0 and the 5 wire-only type edges are the residue recorded above. @@ -119,8 +120,9 @@ export function checkDaemonClientEntry(edges: readonly ResolvedImportEdge[]): La line: entry.line, message: `the daemon client ${entry.runtimeKind} daemon internals: ${key}. The client composes the ` + - `daemon over the network, not its module graph. Move the shared contract to the process ` + - `root (or read the DaemonRequest/DaemonResponse types in src/daemon/daemon-request.ts as a type).`, + `daemon over the network, not its module graph. Move the shared contract to ` + + `packages/daemon-contracts (or read the DaemonRequest/DaemonResponse types in ` + + `src/daemon/daemon-request.ts as a type).`, }); seen.add(key); continue; diff --git a/scripts/layering/daemon-layer-manifest.json b/scripts/layering/daemon-layer-manifest.json index 53a53c7dac..09f744d822 100644 --- a/scripts/layering/daemon-layer-manifest.json +++ b/scripts/layering/daemon-layer-manifest.json @@ -25,6 +25,7 @@ "src/daemon/managed-session-artifact-path.ts", "src/daemon/platform-owner-lifecycle.ts", "src/daemon/platform-resource-cleanup.ts", + "src/daemon/platform-services.ts", "src/daemon/provider-device-admission.ts", "src/daemon/recording-gesture-events.ts", "src/daemon/recording-gestures.ts", @@ -72,6 +73,7 @@ "src/daemon/app-log-start-preflight.ts", "src/daemon/app-log.ts", "src/daemon/artifact-tracking.ts", + "src/daemon/device/claim-recovery-gateway.ts", "src/daemon/device/device-claim-admission.ts", "src/daemon/device/device-claim-conflict.ts", "src/daemon/device/device-claim-inspection.ts", diff --git a/scripts/layering/root-module-zones.ts b/scripts/layering/root-module-zones.ts index 2783280554..e25608a69e 100644 --- a/scripts/layering/root-module-zones.ts +++ b/scripts/layering/root-module-zones.ts @@ -9,7 +9,7 @@ * This reduces `(root)` in the logical graph only: the declared modules still live directly under * `src/`, and classifying them is not collocating them. The table bridges that layout and should * shrink. When a group moves into a folder named for its zone (`src/command-runtime/`, - * `src/daemon-contracts/`, ...) or into a package, `topFolder` derives the same zone and the + * `packages/daemon-contracts/`, ...) or into a package, `topFolder` derives the same zone and the * group's rows are deleted. The end state: renaming a module within its owner needs no edit here, * while a forbidden dependency still fails R5 or R80. * @@ -21,19 +21,6 @@ export const ROOT_MODULE_ZONES: Readonly> = { '(root)': ['src/bin.ts', 'src/cli.ts', 'src/daemon.ts'], // Imported by core's interactor resolution, so they sit at core's rank. core: ['src/platform-runtime-android-adb-host.ts', 'src/provider-device-runtime.ts'], - // On-disk and wire contracts a daemon process shares with its clients (#2559): the client - // reaches the daemon over the network, so both sides read these from below. - 'daemon-contracts': [ - 'src/daemon-owner-cleanup.ts', - 'src/daemon-policy-file.ts', - 'src/daemon-process.ts', - 'src/daemon-registration-owner.ts', - 'src/daemon-registration.ts', - 'src/daemon-resolution.ts', - 'src/daemon-shutdown-report.ts', - 'src/request-progress-protocol.ts', - 'src/session-repair-tombstone.ts', - ], // The in-process command runtime: the backend and artifact contracts it drives and the // assemblies that bind command families onto it. The daemon executes commands through it. 'command-runtime': [ diff --git a/scripts/print-daemon-state-dir.ts b/scripts/print-daemon-state-dir.ts index 9bd2deffb5..a7dcc3260f 100644 --- a/scripts/print-daemon-state-dir.ts +++ b/scripts/print-daemon-state-dir.ts @@ -1,4 +1,4 @@ -import { resolveDaemonPaths } from '../src/daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; const paths = resolveDaemonPaths(process.env.AGENT_DEVICE_STATE_DIR); diff --git a/src/__tests__/cli-device-status.test.ts b/src/__tests__/cli-device-status.test.ts index 34ac4f1221..b153e8b7aa 100644 --- a/src/__tests__/cli-device-status.test.ts +++ b/src/__tests__/cli-device-status.test.ts @@ -4,7 +4,7 @@ import path from 'node:path'; import { test, vi } from 'vitest'; import { readCurrentOwnerIdentity } from '@agent-device/host-kit/process'; import { runCliCapture } from './cli-capture.ts'; -import { publishDaemonRegistration } from './test-utils/device-claim-store.ts'; +import { publishDaemonRegistration } from '@agent-device/daemon-contracts/daemon-registration-fixtures'; import { mkdtempForTestSync } from './test-utils/tmp-dir.ts'; vi.mock('@agent-device/host-kit/process', async (importOriginal) => diff --git a/src/__tests__/cli-diagnostics.test.ts b/src/__tests__/cli-diagnostics.test.ts index 830f91ed94..95a4d11a2b 100644 --- a/src/__tests__/cli-diagnostics.test.ts +++ b/src/__tests__/cli-diagnostics.test.ts @@ -3,7 +3,7 @@ import assert from 'node:assert/strict'; import fs from 'node:fs'; import path from 'node:path'; import type { DaemonResponse } from '../daemon-client/daemon-client.ts'; -import { resolveDaemonPaths } from '../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { runCliCapture as captureCli, type CapturedCliRun, diff --git a/src/__tests__/cli-exit-paths.test.ts b/src/__tests__/cli-exit-paths.test.ts index 91bae3a036..561ab1eb95 100644 --- a/src/__tests__/cli-exit-paths.test.ts +++ b/src/__tests__/cli-exit-paths.test.ts @@ -12,7 +12,7 @@ vi.mock('../cli/commands/web.ts', async (importOriginal) => { import { runCli } from '../cli.ts'; import { runWebCommand } from '../cli/commands/web.ts'; import { installIsolatedCliTestEnv } from './cli-test-env.ts'; -import { resolveDaemonPaths } from '../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import type { DaemonResponse } from '../daemon-client/daemon-client.ts'; import { mkdtempForTestSync } from './test-utils/tmp-dir.ts'; diff --git a/src/__tests__/client-metro.test.ts b/src/__tests__/client-metro.test.ts index 2a486eec6a..79f1197663 100644 --- a/src/__tests__/client-metro.test.ts +++ b/src/__tests__/client-metro.test.ts @@ -11,7 +11,7 @@ import { prepareMetroRuntime, reloadMetro } from '../metro/client-metro.ts'; import { resolveMetroReloadEndpoints } from '../metro/metro-reload-endpoints.ts'; import { createAgentDeviceClient } from '../agent-device-client.ts'; import { readMetroSessionHints } from '../metro/metro-session-hints.ts'; -import { resolveDaemonPaths } from '../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { AppError } from '@agent-device/kernel/errors'; import { isProcessAlive, waitForProcessExit } from '@agent-device/host-kit/process'; import { mkdtempForTestSync } from './test-utils/tmp-dir.ts'; diff --git a/src/__tests__/daemon-entrypoint.test.ts b/src/__tests__/daemon-entrypoint.test.ts index 52e4b3a085..74a49056a8 100644 --- a/src/__tests__/daemon-entrypoint.test.ts +++ b/src/__tests__/daemon-entrypoint.test.ts @@ -5,7 +5,7 @@ import fs from 'node:fs'; import http from 'node:http'; import path from 'node:path'; import { test } from 'vitest'; -import { resolveDaemonPaths } from '../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { startDaemonRuntime } from '../daemon/server/daemon-runtime.ts'; import { cleanupDownloadableArtifact, diff --git a/src/__tests__/daemon-exit-wait.test.ts b/src/__tests__/daemon-exit-wait.test.ts index deaa03e829..68cd3ebc0d 100644 --- a/src/__tests__/daemon-exit-wait.test.ts +++ b/src/__tests__/daemon-exit-wait.test.ts @@ -1,5 +1,8 @@ import { afterEach, beforeEach, expect, test, vi } from 'vitest'; -import { stopDaemonProcess, waitForDaemonExit } from '../daemon-process.ts'; +import { + stopDaemonProcess, + waitForDaemonExit, +} from '@agent-device/daemon-contracts/daemon-process'; const DAEMON_COMMAND = '/opt/checkout/dist/src/internal/daemon.js'; const OURS = 'Mon Aug 24 10:00:00 2026'; diff --git a/src/__tests__/daemon-registration-owner.test.ts b/src/__tests__/daemon-registration-owner.test.ts index f504445479..47a0bdbf3b 100644 --- a/src/__tests__/daemon-registration-owner.test.ts +++ b/src/__tests__/daemon-registration-owner.test.ts @@ -13,10 +13,13 @@ import { launchDaemonProcess, type DaemonRetirementResult, type OwnedReplayStateDir, -} from '../daemon-registration-owner.ts'; -import { resolveDaemonPaths, type DaemonPaths } from '../daemon-resolution.ts'; -import { readRegisteredDaemonOwnership } from '../daemon-registration.ts'; -import { readDaemonShutdownReport } from '../daemon-shutdown-report.ts'; +} from '@agent-device/daemon-contracts/daemon-registration-owner'; +import { + resolveDaemonPaths, + type DaemonPaths, +} from '@agent-device/daemon-contracts/daemon-resolution'; +import { readRegisteredDaemonOwnership } from '@agent-device/daemon-contracts/daemon-registration'; +import { readDaemonShutdownReport } from '@agent-device/daemon-contracts/daemon-shutdown-report'; import { mkdtempForTestSync } from './test-utils/tmp-dir.ts'; import { registeredDaemonFixtureArgs, @@ -28,7 +31,7 @@ import { ensureDaemon, resolveClientSettings } from '../daemon-client/daemon-cli import { inspectProcessLock } from '@agent-device/host-kit/file'; import { AppError } from '@agent-device/kernel/errors'; import { sleep } from '@agent-device/host-kit/retry'; -import { stopDaemonProcess } from '../daemon-process.ts'; +import { stopDaemonProcess } from '@agent-device/daemon-contracts/daemon-process'; import { stopDaemon } from '../daemon/daemon-stop.ts'; const fields = { diff --git a/src/__tests__/test-utils/device-claim-store.ts b/src/__tests__/test-utils/device-claim-store.ts index 7777f80a48..51ccda9d10 100644 --- a/src/__tests__/test-utils/device-claim-store.ts +++ b/src/__tests__/test-utils/device-claim-store.ts @@ -3,7 +3,6 @@ import path from 'node:path'; import { afterEach } from 'vitest'; import { mkdtempForTestSync } from './tmp-dir.ts'; import type { DeviceClaimReconciler } from '../../daemon/device/device-claims.ts'; -import { type OwnerIdentity } from '@agent-device/host-kit/process'; export type IsolatedDeviceClaimStore = { /** Temporary root holding both the claim store and the daemon state dir. */ @@ -38,23 +37,3 @@ export const retainOrphanedDeviceClaims: DeviceClaimReconciler = async () => ({ status: 'retained', reason: 'test-live-owner', }); - -/** - * Publishes the daemon registration a running daemon writes for its state dir. - * Claim ownership is only reachable through the daemon named there, so tests - * that exercise reachability have to stand one in. - */ -export function publishDaemonRegistration(stateDir: string, owner: OwnerIdentity): void { - fs.mkdirSync(stateDir, { recursive: true }); - fs.writeFileSync( - path.join(stateDir, 'daemon.json'), - JSON.stringify({ - port: 1, - transport: 'socket', - token: 'test-token', - pid: owner.pid, - ...(owner.startTime === null ? {} : { processStartTime: owner.startTime }), - stateDir, - }), - ); -} diff --git a/src/__tests__/test-utils/legacy-daemon-fixture.ts b/src/__tests__/test-utils/legacy-daemon-fixture.ts index b5b40ff06a..47b8474b60 100644 --- a/src/__tests__/test-utils/legacy-daemon-fixture.ts +++ b/src/__tests__/test-utils/legacy-daemon-fixture.ts @@ -3,8 +3,8 @@ import fs from 'node:fs'; import path from 'node:path'; import { runCmdDetachedMonitored } from '@agent-device/host-kit/command'; import { readProcessStartTime } from '@agent-device/host-kit/process'; -import { stopDaemonProcess } from '../../daemon-process.ts'; -import type { DaemonPaths } from '../../daemon-resolution.ts'; +import { stopDaemonProcess } from '@agent-device/daemon-contracts/daemon-process'; +import type { DaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; // c237027737: server-lifecycle.ts readLockInfo/acquireDaemonLock/releaseDaemonLock. const legacyLockProtocol = ` @@ -49,7 +49,10 @@ export function spawnLegacyDaemonFixture(paths: DaemonPaths, acquisitionBarrier? const entry = path.join(codeDir, 'dist', 'src', 'internal', 'daemon.js'); fs.mkdirSync(path.dirname(entry), { recursive: true }); fs.writeFileSync(path.join(codeDir, 'package.json'), '{"type":"module"}'); - const processUrl = new URL('../../daemon-process.ts', import.meta.url).href; + const processUrl = new URL( + '../../../packages/daemon-contracts/src/daemon-process.ts', + import.meta.url, + ).href; const hostProcessUrl = new URL('../../../packages/host-kit/src/process.ts', import.meta.url).href; fs.writeFileSync( entry, diff --git a/src/__tests__/test-utils/registered-daemon-fixture.test.ts b/src/__tests__/test-utils/registered-daemon-fixture.test.ts index e4e265f4af..61ec9fd315 100644 --- a/src/__tests__/test-utils/registered-daemon-fixture.test.ts +++ b/src/__tests__/test-utils/registered-daemon-fixture.test.ts @@ -1,8 +1,8 @@ import assert from 'node:assert/strict'; import fs from 'node:fs'; import { test } from 'vitest'; -import { resolveDaemonPaths } from '../../daemon-resolution.ts'; -import { stopDaemonProcess } from '../../daemon-process.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; +import { stopDaemonProcess } from '@agent-device/daemon-contracts/daemon-process'; import { mkdtempForTestSync } from './tmp-dir.ts'; import { spawnRegisteredDaemonFixture, diff --git a/src/__tests__/test-utils/registered-daemon-fixture.ts b/src/__tests__/test-utils/registered-daemon-fixture.ts index 9131617410..a4240ce539 100644 --- a/src/__tests__/test-utils/registered-daemon-fixture.ts +++ b/src/__tests__/test-utils/registered-daemon-fixture.ts @@ -5,9 +5,9 @@ import { vi } from 'vitest'; import type { runCmdDetachedMonitored, ExecDetachedExit } from '@agent-device/host-kit/command'; import { readDaemonInfo, type DaemonInfo } from '../../daemon-client/daemon-client-metadata.ts'; import { readProcessStartTime } from '@agent-device/host-kit/process'; -import { stopDaemonProcess } from '../../daemon-process.ts'; -import type { DaemonPaths } from '../../daemon-resolution.ts'; -import type { DaemonRegistrationFields } from '../../daemon-registration-owner.ts'; +import { stopDaemonProcess } from '@agent-device/daemon-contracts/daemon-process'; +import type { DaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; +import type { DaemonRegistrationFields } from '@agent-device/daemon-contracts/daemon-registration-owner'; const actualCommand = await vi.importActual( '@agent-device/host-kit/command', @@ -26,7 +26,10 @@ export function registeredDaemonFixtureArgs( const entry = path.join(paths.baseDir, 'dist', 'src', 'internal', 'daemon.js'); fs.mkdirSync(path.dirname(entry), { recursive: true }); fs.writeFileSync(path.join(paths.baseDir, 'package.json'), '{"type":"module"}'); - const registrationUrl = new URL('../../daemon-registration-owner.ts', import.meta.url).href; + const registrationUrl = new URL( + '../../../packages/daemon-contracts/src/daemon-registration-owner.ts', + import.meta.url, + ).href; fs.writeFileSync( entry, `import fs from 'node:fs'; diff --git a/src/agent-device-client.ts b/src/agent-device-client.ts index 0ac20595e3..a23449959a 100644 --- a/src/agent-device-client.ts +++ b/src/agent-device-client.ts @@ -63,7 +63,7 @@ import { } from './commands/command-projection.ts'; import type { CommandResult } from '@agent-device/command-registry/command-result'; import { sendToDaemon } from './daemon-client/daemon-client.ts'; -import { resolveDaemonPaths } from './daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { resolveMetroServerUrl } from './metro/metro-reload-endpoints.ts'; import { prepareMetroRuntime, reloadMetro } from './metro/client-metro.ts'; import { diff --git a/src/cli.ts b/src/cli.ts index e5c7ce568a..3fb705fe68 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -36,7 +36,7 @@ import { registerDiagnosticSensitiveValue, withDiagnosticsScope, } from '@agent-device/host-kit/diagnostics'; -import { resolveDaemonPaths } from './daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { applyDefaultPlatformBinding, resolveBindingSettings } from './cli/session-binding.ts'; import { resolveCliOptions } from './cli/resolve-cli-options.ts'; import { maybeRunUpgradeNotifier } from './cli/update-check.ts'; diff --git a/src/cli/commands/__tests__/daemon.test.ts b/src/cli/commands/__tests__/daemon.test.ts index f608a20585..09f0be8224 100644 --- a/src/cli/commands/__tests__/daemon.test.ts +++ b/src/cli/commands/__tests__/daemon.test.ts @@ -16,7 +16,7 @@ vi.mock('../../../daemon/daemon-stop.ts', () => ({ readDaemonStopIdentity: mocks.readDaemonStopIdentity, stopDaemon: mocks.stopDaemon, })); -vi.mock('../../../daemon-shutdown-report.ts', () => ({ +vi.mock('@agent-device/daemon-contracts/daemon-shutdown-report', () => ({ readDaemonShutdownReport: mocks.readDaemonShutdownReport, })); vi.mock('../../../platform-runtime-daemon-owner-cleanup.ts', () => ({ diff --git a/src/cli/commands/auth.ts b/src/cli/commands/auth.ts index 37ac9f2ab8..ca41919870 100644 --- a/src/cli/commands/auth.ts +++ b/src/cli/commands/auth.ts @@ -1,4 +1,4 @@ -import { resolveDaemonPaths } from '../../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { AppError } from '@agent-device/kernel/errors'; import { loginWithDeviceAuth, removeCliSession, summarizeCliSession } from '../auth-session.ts'; import { writeCommandOutput } from './shared.ts'; diff --git a/src/cli/commands/connection-runtime.ts b/src/cli/commands/connection-runtime.ts index f0e610b4a6..055da012ee 100644 --- a/src/cli/commands/connection-runtime.ts +++ b/src/cli/commands/connection-runtime.ts @@ -1,5 +1,5 @@ import type { MetroBridgeScope } from '@agent-device/contracts/remote'; -import { resolveDaemonPaths } from '../../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { stopReactDevtoolsCompanion } from '../../client/client-react-devtools-companion.ts'; import { stopMetroTunnel } from '../../metro/metro.ts'; import { resolveRemoteConfigProfile } from '../../remote/remote-config.ts'; diff --git a/src/cli/commands/connection.ts b/src/cli/commands/connection.ts index e02cb91188..1ce2c5e61e 100644 --- a/src/cli/commands/connection.ts +++ b/src/cli/commands/connection.ts @@ -2,7 +2,7 @@ import type { CloudArtifact, CloudProviderSessionResult, } from '@agent-device/contracts/observability'; -import { resolveDaemonPaths } from '../../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { resolveRemoteConfigProfile } from '../../remote/remote-config.ts'; import { readActiveConnectionState, diff --git a/src/cli/commands/daemon.ts b/src/cli/commands/daemon.ts index 211b64b49d..fd9c1d301f 100644 --- a/src/cli/commands/daemon.ts +++ b/src/cli/commands/daemon.ts @@ -1,10 +1,10 @@ -import { resolveDaemonPaths } from '../../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { readDaemonStopIdentity, stopDaemon, type DaemonStopResult, } from '../../daemon/daemon-stop.ts'; -import { readDaemonShutdownReport } from '../../daemon-shutdown-report.ts'; +import { readDaemonShutdownReport } from '@agent-device/daemon-contracts/daemon-shutdown-report'; import { AppError } from '@agent-device/kernel/errors'; import { writeCommandOutput } from './shared.ts'; import type { ClientCommandHandler } from './router-types.ts'; diff --git a/src/cli/connection/limrun-profile.ts b/src/cli/connection/limrun-profile.ts index ab8e60a8ef..87cc8f0d12 100644 --- a/src/cli/connection/limrun-profile.ts +++ b/src/cli/connection/limrun-profile.ts @@ -1,4 +1,4 @@ -import { resolveDaemonPaths } from '../../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import type { RemoteConfigProfile } from '../../remote/remote-config-schema.ts'; import { AppError } from '@agent-device/kernel/errors'; import type { CliFlags } from '@agent-device/contracts/command'; diff --git a/src/daemon-client/__tests__/boundary-fault-acceptance.test.ts b/src/daemon-client/__tests__/boundary-fault-acceptance.test.ts index af0ae39df3..e3c7c0304f 100644 --- a/src/daemon-client/__tests__/boundary-fault-acceptance.test.ts +++ b/src/daemon-client/__tests__/boundary-fault-acceptance.test.ts @@ -5,7 +5,7 @@ import { test } from 'vitest'; import { AppError } from '@agent-device/kernel/errors'; import { assertRejectsAppError } from '../../__tests__/test-utils/app-error.ts'; import { mkdtempForTestSync } from '../../__tests__/test-utils/tmp-dir.ts'; -import type { DaemonPaths } from '../../daemon-resolution.ts'; +import type { DaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import type { DaemonRequest } from '../../daemon/daemon-request.ts'; import { sendRequest } from '../daemon-client-transport.ts'; diff --git a/src/daemon-client/__tests__/boundary-fault-transport.test.ts b/src/daemon-client/__tests__/boundary-fault-transport.test.ts index cff373a906..a875e7f950 100644 --- a/src/daemon-client/__tests__/boundary-fault-transport.test.ts +++ b/src/daemon-client/__tests__/boundary-fault-transport.test.ts @@ -11,7 +11,7 @@ import { type LoopbackServer, } from '../../__tests__/test-utils/loopback.ts'; import { mkdtempForTestSync } from '../../__tests__/test-utils/tmp-dir.ts'; -import type { DaemonPaths } from '../../daemon-resolution.ts'; +import type { DaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import type { DaemonRequest } from '../../daemon/daemon-request.ts'; import { sendRequest } from '../daemon-client-transport.ts'; diff --git a/src/daemon-client/__tests__/daemon-client-abort-timeout.test.ts b/src/daemon-client/__tests__/daemon-client-abort-timeout.test.ts index 9c017ef986..91c188b4d7 100644 --- a/src/daemon-client/__tests__/daemon-client-abort-timeout.test.ts +++ b/src/daemon-client/__tests__/daemon-client-abort-timeout.test.ts @@ -19,7 +19,7 @@ import { getRequestSignal } from '@agent-device/host-kit/request'; import type { DaemonInvokeFn, DaemonRequest, DaemonResponse } from '../../daemon/daemon-request.ts'; import { createSocketServer, listenNetServer } from '../../daemon/server/transport.ts'; import { sendRequest } from '../daemon-client-transport.ts'; -import { resolveDaemonPaths } from '../../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { closeLoopbackServer, listenOnLoopback, diff --git a/src/daemon-client/__tests__/daemon-client-abort.test.ts b/src/daemon-client/__tests__/daemon-client-abort.test.ts index 37e3805b34..526a3ef0f0 100644 --- a/src/daemon-client/__tests__/daemon-client-abort.test.ts +++ b/src/daemon-client/__tests__/daemon-client-abort.test.ts @@ -16,7 +16,7 @@ import type { DaemonInvokeFn, DaemonRequest, DaemonResponse } from '../../daemon import { createDaemonHttpServer } from '../../daemon/server/http-server.ts'; import { createSocketServer, listenNetServer } from '../../daemon/server/transport.ts'; import { sendRequest } from '../daemon-client-transport.ts'; -import { resolveDaemonPaths } from '../../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { closeLoopbackServer, listenOnLoopback, diff --git a/src/daemon-client/__tests__/daemon-client-developer-dir.test.ts b/src/daemon-client/__tests__/daemon-client-developer-dir.test.ts index 66e8b261c9..501d1ae732 100644 --- a/src/daemon-client/__tests__/daemon-client-developer-dir.test.ts +++ b/src/daemon-client/__tests__/daemon-client-developer-dir.test.ts @@ -6,7 +6,7 @@ import net from 'node:net'; import { readProcessStartTime } from '@agent-device/host-kit/process'; import { readVersion } from '@agent-device/host-kit/version'; import { sendToDaemon } from '../daemon-client.ts'; -import { resolveDaemonPaths } from '../../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { currentDaemonCodeSignature } from '../../__tests__/test-utils/daemon-http-fixture.ts'; import { closeLoopbackServer, diff --git a/src/daemon-client/__tests__/daemon-client-lease-beat.test.ts b/src/daemon-client/__tests__/daemon-client-lease-beat.test.ts index 7d1a01d995..27aff68aae 100644 --- a/src/daemon-client/__tests__/daemon-client-lease-beat.test.ts +++ b/src/daemon-client/__tests__/daemon-client-lease-beat.test.ts @@ -3,7 +3,7 @@ import assert from 'node:assert/strict'; import net from 'node:net'; import { AppError } from '@agent-device/kernel/errors'; import { closeLoopbackServer, listenOnLoopback } from '../../__tests__/test-utils/loopback.ts'; -import { resolveDaemonPaths } from '../../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { buildLeaseHeartbeatRequest, buildUploadLeaseHeartbeat, diff --git a/src/daemon-client/__tests__/daemon-client-lifecycle.test.ts b/src/daemon-client/__tests__/daemon-client-lifecycle.test.ts index 0d16a79520..a566cb4462 100644 --- a/src/daemon-client/__tests__/daemon-client-lifecycle.test.ts +++ b/src/daemon-client/__tests__/daemon-client-lifecycle.test.ts @@ -22,8 +22,8 @@ vi.mock('@agent-device/host-kit/retry', async (importOriginal) => ({ ...(await importOriginal()), sleep: vi.fn(async () => {}), })); - -import { resolveDaemonPaths, type DaemonPaths } from '../../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; +import type { DaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { sendToDaemon } from '../daemon-client.ts'; import { closeLoopbackServer, diff --git a/src/daemon-client/__tests__/daemon-client-metadata.test.ts b/src/daemon-client/__tests__/daemon-client-metadata.test.ts index bae4084103..a5cf39c929 100644 --- a/src/daemon-client/__tests__/daemon-client-metadata.test.ts +++ b/src/daemon-client/__tests__/daemon-client-metadata.test.ts @@ -4,9 +4,9 @@ import path from 'node:path'; import { test } from 'vitest'; import type { DaemonCodeOrigin } from '@agent-device/host-kit/code-signature'; import { mkdtempForTestSync } from '../../__tests__/test-utils/tmp-dir.ts'; -import { tryAcquireDaemonRegistration } from '../../daemon-registration-owner.ts'; +import { tryAcquireDaemonRegistration } from '@agent-device/daemon-contracts/daemon-registration-owner'; import { readDaemonInfo, type DaemonInfo } from '../daemon-client-metadata.ts'; -import { resolveDaemonPaths } from '../../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; // The reuse decision is only as good as the identity that survives the round trip // through `daemon.json`: a client cannot compare what the file lost (#2458). diff --git a/src/daemon-client/__tests__/daemon-client-newer-daemon.test.ts b/src/daemon-client/__tests__/daemon-client-newer-daemon.test.ts index 368d7a4755..4d507c4a41 100644 --- a/src/daemon-client/__tests__/daemon-client-newer-daemon.test.ts +++ b/src/daemon-client/__tests__/daemon-client-newer-daemon.test.ts @@ -10,7 +10,7 @@ vi.mock('@agent-device/host-kit/command', async (importOriginal) => ({ runCmdSync: vi.fn(() => ({ exitCode: 1, stdout: '', stderr: '' })), })); -import { resolveDaemonPaths } from '../../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { sendToDaemon } from '../daemon-client.ts'; import { closeLoopbackServer, supportsLoopbackBind } from '../../__tests__/test-utils/loopback.ts'; import { diff --git a/src/daemon-client/__tests__/daemon-client-policy-reuse.test.ts b/src/daemon-client/__tests__/daemon-client-policy-reuse.test.ts index f6e510494f..b78e3dbae6 100644 --- a/src/daemon-client/__tests__/daemon-client-policy-reuse.test.ts +++ b/src/daemon-client/__tests__/daemon-client-policy-reuse.test.ts @@ -18,8 +18,8 @@ import { } from '../../__tests__/test-utils/daemon-http-fixture.ts'; import { closeLoopbackServer, supportsLoopbackBind } from '../../__tests__/test-utils/loopback.ts'; import { mkdtempForTestSync } from '../../__tests__/test-utils/tmp-dir.ts'; -import { loadDaemonPolicy } from '../../daemon-policy-file.ts'; -import { resolveDaemonPaths } from '../../daemon-resolution.ts'; +import { loadDaemonPolicy } from '@agent-device/daemon-contracts/daemon-policy-file'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { sendToDaemon } from '../daemon-client.ts'; // ADR 0029: a caller that names a daemon policy must not use a daemon that enforces another one. diff --git a/src/daemon-client/__tests__/daemon-client-provider-credentials.test.ts b/src/daemon-client/__tests__/daemon-client-provider-credentials.test.ts index 52a769d2b4..c31ea84e30 100644 --- a/src/daemon-client/__tests__/daemon-client-provider-credentials.test.ts +++ b/src/daemon-client/__tests__/daemon-client-provider-credentials.test.ts @@ -4,7 +4,7 @@ import net from 'node:net'; import { readProcessStartTime } from '@agent-device/host-kit/process'; import { readVersion } from '@agent-device/host-kit/version'; import { sendToDaemon } from '../daemon-client.ts'; -import { resolveDaemonPaths } from '../../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { currentDaemonCodeSignature, startHttpDaemonFixture, diff --git a/src/daemon-client/__tests__/daemon-client-stalled-probe.test.ts b/src/daemon-client/__tests__/daemon-client-stalled-probe.test.ts index 6005159793..f08c31dda7 100644 --- a/src/daemon-client/__tests__/daemon-client-stalled-probe.test.ts +++ b/src/daemon-client/__tests__/daemon-client-stalled-probe.test.ts @@ -12,7 +12,7 @@ import { waitForProcessExit, } from '@agent-device/host-kit/process'; import { findProjectRoot, readVersion } from '@agent-device/host-kit/version'; -import { resolveDaemonPaths } from '../../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { sendToDaemon } from '../daemon-client.ts'; import { closeLoopbackServer, diff --git a/src/daemon-client/__tests__/daemon-client-startup-race.test.ts b/src/daemon-client/__tests__/daemon-client-startup-race.test.ts index ea258d73a0..d5a622b3d4 100644 --- a/src/daemon-client/__tests__/daemon-client-startup-race.test.ts +++ b/src/daemon-client/__tests__/daemon-client-startup-race.test.ts @@ -20,10 +20,13 @@ import { currentDaemonCodeSignature, } from '../../__tests__/test-utils/daemon-http-fixture.ts'; import { closeLoopbackServer, supportsLoopbackBind } from '../../__tests__/test-utils/loopback.ts'; -import { resolveDaemonPaths, type DaemonPaths } from '../../daemon-resolution.ts'; +import { + resolveDaemonPaths, + type DaemonPaths, +} from '@agent-device/daemon-contracts/daemon-resolution'; import { sendToDaemon } from '../daemon-client.ts'; import * as lifecycle from '../daemon-client-lifecycle.ts'; -import { DAEMON_STARTUP_EXIT_CODES } from '../../daemon-registration-owner.ts'; +import { DAEMON_STARTUP_EXIT_CODES } from '@agent-device/daemon-contracts/daemon-registration-owner'; vi.mock('@agent-device/host-kit/command', async (importOriginal) => ({ ...(await importOriginal()), diff --git a/src/daemon-client/__tests__/daemon-client-timeout-route.test.ts b/src/daemon-client/__tests__/daemon-client-timeout-route.test.ts index 69a5ddd8ac..c9d2670227 100644 --- a/src/daemon-client/__tests__/daemon-client-timeout-route.test.ts +++ b/src/daemon-client/__tests__/daemon-client-timeout-route.test.ts @@ -40,7 +40,7 @@ import { PUBLIC_COMMANDS } from '@agent-device/command-registry/catalog'; import { sendRequest } from '../daemon-client-transport.ts'; import type { DaemonRequest } from '../../daemon/daemon-request.ts'; import type { DaemonInfo } from '../daemon-client-metadata.ts'; -import type { DaemonPaths } from '../../daemon-resolution.ts'; +import type { DaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { mkdtempForTestSync } from '../../__tests__/test-utils/tmp-dir.ts'; import { closeLoopbackServer, diff --git a/src/daemon-client/__tests__/daemon-client-transport.test.ts b/src/daemon-client/__tests__/daemon-client-transport.test.ts index c5f3d9d773..0d33a6a78d 100644 --- a/src/daemon-client/__tests__/daemon-client-transport.test.ts +++ b/src/daemon-client/__tests__/daemon-client-transport.test.ts @@ -20,7 +20,7 @@ import { isDaemonTransportUnavailableError, sendRequest, } from '../daemon-client-transport.ts'; -import { resolveDaemonPaths } from '../../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { createDaemonProxyServer } from '@agent-device/proxy'; import { closeLoopbackServer, diff --git a/src/daemon-client/__tests__/daemon-client.test.ts b/src/daemon-client/__tests__/daemon-client.test.ts index cca31e8a26..9e3db1e2d1 100644 --- a/src/daemon-client/__tests__/daemon-client.test.ts +++ b/src/daemon-client/__tests__/daemon-client.test.ts @@ -19,7 +19,7 @@ import { downloadRemoteArtifact } from '../../remote/daemon-artifacts.ts'; import { resolveDaemonStartupHint } from '../daemon-client-metadata.ts'; import { canConnectSocket } from '../daemon-client-transport.ts'; import { DAEMON_RPC_PROTOCOL_VERSION } from '@agent-device/contracts/daemon-http'; -import { resolveDaemonPaths } from '../../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { readVersion } from '@agent-device/host-kit/version'; import { mkdtempForTestSync } from '../../__tests__/test-utils/tmp-dir.ts'; diff --git a/src/daemon-client/daemon-client-lifecycle.ts b/src/daemon-client/daemon-client-lifecycle.ts index acef7bbf85..002e3e09da 100644 --- a/src/daemon-client/daemon-client-lifecycle.ts +++ b/src/daemon-client/daemon-client-lifecycle.ts @@ -1,6 +1,6 @@ import { attachActiveSessionAddressHint } from './daemon-client-address-hints.ts'; import fs from 'node:fs'; -import { processLockHoldsDaemonIdentity } from '../daemon-registration.ts'; +import { processLockHoldsDaemonIdentity } from '@agent-device/daemon-contracts/daemon-registration'; import net from 'node:net'; import { AppError, normalizeError, type NormalizedError } from '@agent-device/kernel/errors'; import { readReplayDivergenceResume } from '@agent-device/ad-replay/divergence'; @@ -12,7 +12,7 @@ import { isProcessAlive } from '@agent-device/host-kit/process'; import { sleep } from '@agent-device/host-kit/retry'; import { inspectProcessLock, type ProcessLockInspection } from '@agent-device/host-kit/file'; -import type { findUnrecoveredRepairCommitFailure } from '../session-repair-tombstone.ts'; +import type { findUnrecoveredRepairCommitFailure } from '@agent-device/daemon-contracts/session-repair-tombstone'; import { DAEMON_STARTUP_EXIT_CODES, createOwnedReplayStateDir, @@ -22,7 +22,7 @@ import { stopAndRetireDaemon, type OwnedReplayStateDir, type DaemonStartupLaunch, -} from '../daemon-registration-owner.ts'; +} from '@agent-device/daemon-contracts/daemon-registration-owner'; import { resolveDaemonPaths, resolveDaemonServerMode, @@ -30,7 +30,7 @@ import { type DaemonPaths, type DaemonServerMode, type DaemonTransportPreference, -} from '../daemon-resolution.ts'; +} from '@agent-device/daemon-contracts/daemon-resolution'; import { resolveDaemonLaunchSpec, resolveDaemonTakeover, @@ -305,7 +305,7 @@ async function canReachReusableDaemon( */ async function assertDaemonPolicyMatches(existing: DaemonInfo, stateDir: string): Promise { if (!process.env.AGENT_DEVICE_DAEMON_POLICY?.trim()) return; - const { loadDaemonPolicy } = await import('../daemon-policy-file.ts'); + const { loadDaemonPolicy } = await import('@agent-device/daemon-contracts/daemon-policy-file'); const expected = loadDaemonPolicy(process.env)?.digest; if (expected === existing.policyDigest) return; throw new AppError( diff --git a/src/daemon-client/daemon-client-metadata.ts b/src/daemon-client/daemon-client-metadata.ts index 718ed7b1cc..5f35583f15 100644 --- a/src/daemon-client/daemon-client-metadata.ts +++ b/src/daemon-client/daemon-client-metadata.ts @@ -7,7 +7,7 @@ import { resolveDaemonPaths, type DaemonPaths, type DaemonServerMode, -} from '../daemon-resolution.ts'; +} from '@agent-device/daemon-contracts/daemon-resolution'; export type DaemonInfo = { port?: number; diff --git a/src/daemon-client/daemon-client-progress.ts b/src/daemon-client/daemon-client-progress.ts index 1fe9e28156..1e15ab9b2a 100644 --- a/src/daemon-client/daemon-client-progress.ts +++ b/src/daemon-client/daemon-client-progress.ts @@ -10,7 +10,7 @@ import { isDaemonProgressEnvelope, isDaemonResponseEnvelope, shouldStreamRequestProgress, -} from '../request-progress-protocol.ts'; +} from '@agent-device/daemon-contracts/request-progress-protocol'; type ProgressLineReader = { handleLine(line: string): boolean; diff --git a/src/daemon-client/daemon-client-timeout.ts b/src/daemon-client/daemon-client-timeout.ts index 5ae3336658..ffbf596c34 100644 --- a/src/daemon-client/daemon-client-timeout.ts +++ b/src/daemon-client/daemon-client-timeout.ts @@ -1,9 +1,9 @@ import { AppError } from '@agent-device/kernel/errors'; import { emitDiagnostic } from '@agent-device/host-kit/diagnostics'; -import type { DaemonRetirementResult } from '../daemon-registration-owner.ts'; +import type { DaemonRetirementResult } from '@agent-device/daemon-contracts/daemon-registration-owner'; import { PUBLIC_COMMANDS } from '@agent-device/command-registry/catalog'; import { resolveCommandTimeoutPolicy } from '@agent-device/command-registry/registry'; -import type { DaemonPaths } from '../daemon-resolution.ts'; +import type { DaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import type { PlatformSelector } from '@agent-device/kernel/device'; import type { DaemonInfo } from './daemon-client-metadata.ts'; @@ -53,7 +53,8 @@ export async function handleRequestTimeout( const unresponsive = probeAnswered === false; let retirement: DaemonRetirementResult | undefined; if (unresponsive) { - const { stopAndRetireDaemon } = await import('../daemon-registration-owner.ts'); + const { stopAndRetireDaemon } = + await import('@agent-device/daemon-contracts/daemon-registration-owner'); retirement = await stopAndRetireDaemon({ paths: statePaths, observed: { pid: info.pid, startTime: info.processStartTime ?? null }, diff --git a/src/daemon-client/daemon-client-transport.ts b/src/daemon-client/daemon-client-transport.ts index 1db53a047d..f291b3e118 100644 --- a/src/daemon-client/daemon-client-transport.ts +++ b/src/daemon-client/daemon-client-transport.ts @@ -4,7 +4,10 @@ import { AppError, createRequestCanceledError } from '@agent-device/kernel/error import { loadNodeHttpRequester, readNodeHttpResponseBody } from '@agent-device/host-kit/transport'; import type { DaemonRequest, DaemonResponse } from '../daemon/daemon-request.ts'; import { emitDiagnostic } from '@agent-device/host-kit/diagnostics'; -import type { DaemonPaths, DaemonTransportPreference } from '../daemon-resolution.ts'; +import type { + DaemonPaths, + DaemonTransportPreference, +} from '@agent-device/daemon-contracts/daemon-resolution'; import { readDaemonHttpProgressResponse, readDaemonSocketProgressResponse, diff --git a/src/daemon-client/daemon-launch-spec.ts b/src/daemon-client/daemon-launch-spec.ts index 102cdf3332..22c30f5315 100644 --- a/src/daemon-client/daemon-launch-spec.ts +++ b/src/daemon-client/daemon-launch-spec.ts @@ -170,7 +170,7 @@ export async function resolveDaemonTakeover( * directory one takeover after an upgrade. * * The two trees rarely meet: a checkout keeps its daemon in a worktree-scoped state - * directory and an installed client in the shared one (`src/daemon-resolution.ts`, same + * directory and an installed client in the shared one (`@agent-device/daemon-contracts/daemon-resolution`, same * test). An explicit `--state-dir` is what puts them together, and that is where this * pair has to hold. */ diff --git a/src/daemon/__tests__/atomic-publish-ownership.test.ts b/src/daemon/__tests__/atomic-publish-ownership.test.ts index dd902b99e9..cc98d69066 100644 --- a/src/daemon/__tests__/atomic-publish-ownership.test.ts +++ b/src/daemon/__tests__/atomic-publish-ownership.test.ts @@ -5,7 +5,7 @@ import { test } from 'vitest'; const SIMPLE_PUBLISHERS = [ // device-claims.ts delegates every write to device-claim-store.ts's writeDeviceClaim. new URL('../device/device-claim-store.ts', import.meta.url), - new URL('../../daemon-registration-owner.ts', import.meta.url), + new URL('../../../packages/daemon-contracts/src/daemon-registration-owner.ts', import.meta.url), new URL('../provider-lease-expiry.ts', import.meta.url), new URL('../session-script-writer.ts', import.meta.url), new URL('../../../packages/platform-apple/src/runner/runner-lease.ts', import.meta.url), diff --git a/src/daemon/__tests__/config.test.ts b/src/daemon/__tests__/config.test.ts index 334251fd7a..e3fdedba27 100644 --- a/src/daemon/__tests__/config.test.ts +++ b/src/daemon/__tests__/config.test.ts @@ -2,7 +2,7 @@ import assert from 'node:assert/strict'; import fs from 'node:fs'; import path from 'node:path'; import { test } from 'vitest'; -import { resolveDaemonPaths } from '../../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { mkdtempForTestSync } from '../../__tests__/test-utils/tmp-dir.ts'; test('resolveDaemonPaths keeps explicit state directories authoritative', () => { diff --git a/src/daemon/__tests__/daemon-policy.test.ts b/src/daemon/__tests__/daemon-policy.test.ts index 502188fb52..76ca96a706 100644 --- a/src/daemon/__tests__/daemon-policy.test.ts +++ b/src/daemon/__tests__/daemon-policy.test.ts @@ -11,7 +11,7 @@ import { createTestDeviceInventoryGateways } from '../../__tests__/test-utils/de import { makeIosSession } from '../../__tests__/test-utils/session-factories.ts'; import { makeSessionStore } from '../../__tests__/test-utils/store-factory.ts'; import { mkdtempForTestSync } from '../../__tests__/test-utils/tmp-dir.ts'; -import { parseDaemonPolicy } from '../../daemon-policy-file.ts'; +import { parseDaemonPolicy } from '@agent-device/daemon-contracts/daemon-policy-file'; import { assertDaemonPolicyAdmitsRequest } from '../daemon-policy.ts'; import type { DaemonRequest } from '../daemon-request.ts'; import { LeaseRegistry } from '../lease-registry.ts'; diff --git a/src/daemon/__tests__/daemon-stop.test.ts b/src/daemon/__tests__/daemon-stop.test.ts index 13ac6851d4..fbaeeda0e6 100644 --- a/src/daemon/__tests__/daemon-stop.test.ts +++ b/src/daemon/__tests__/daemon-stop.test.ts @@ -3,11 +3,11 @@ import { afterEach, expect, test, vi } from 'vitest'; import { mkdtempForTestSync } from '../../__tests__/test-utils/tmp-dir.ts'; const mocks = vi.hoisted(() => ({ stopAndRetireDaemon: vi.fn() })); -vi.mock('../../daemon-registration-owner.ts', () => ({ +vi.mock('@agent-device/daemon-contracts/daemon-registration-owner', () => ({ stopAndRetireDaemon: mocks.stopAndRetireDaemon, })); -import { resolveDaemonPaths } from '../../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { stopDaemon } from '../daemon-stop.ts'; afterEach(() => { diff --git a/src/daemon/__tests__/filesystem-boundary-faults.test.ts b/src/daemon/__tests__/filesystem-boundary-faults.test.ts index bf19ec91b4..24b44f0b33 100644 --- a/src/daemon/__tests__/filesystem-boundary-faults.test.ts +++ b/src/daemon/__tests__/filesystem-boundary-faults.test.ts @@ -9,8 +9,8 @@ import type { DeviceInfo } from '@agent-device/kernel/device'; import { acquireDeviceClaim } from '../device/device-claims.ts'; import { canonicalLocalDeviceKey } from '../device/device-claim-paths.ts'; import { createDurableCaptureResourceStore } from '@agent-device/capture-kit/durable-capture'; -import { tryAcquireDaemonRegistration } from '../../daemon-registration-owner.ts'; -import { resolveDaemonPaths } from '../../daemon-resolution.ts'; +import { tryAcquireDaemonRegistration } from '@agent-device/daemon-contracts/daemon-registration-owner'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { SessionScriptWriter, type SessionScriptWriteResult } from '../session-script-writer.ts'; import { SessionStore } from '../session-store.ts'; import { diff --git a/src/daemon/__tests__/request-admission.test.ts b/src/daemon/__tests__/request-admission.test.ts index 2205f374fc..07ef2cfc96 100644 --- a/src/daemon/__tests__/request-admission.test.ts +++ b/src/daemon/__tests__/request-admission.test.ts @@ -1,7 +1,7 @@ import { test } from 'vitest'; import assert from 'node:assert/strict'; import { makeIosSession, makeMacOsSession } from '../../__tests__/test-utils/session-factories.ts'; -import { parseDaemonPolicy } from '../../daemon-policy-file.ts'; +import { parseDaemonPolicy } from '@agent-device/daemon-contracts/daemon-policy-file'; import { LeaseRegistry } from '../lease-registry.ts'; import { assertRequestLeaseAdmission } from '../request-admission.ts'; import type { DaemonRequest } from '../daemon-request.ts'; diff --git a/src/daemon/__tests__/request-execution-scope-macos-app-lease.test.ts b/src/daemon/__tests__/request-execution-scope-macos-app-lease.test.ts index 27052c4e23..31969c0d62 100644 --- a/src/daemon/__tests__/request-execution-scope-macos-app-lease.test.ts +++ b/src/daemon/__tests__/request-execution-scope-macos-app-lease.test.ts @@ -5,7 +5,7 @@ import { } from './platform-services-fixture.ts'; import { makeMacOsSession } from '../../__tests__/test-utils/session-factories.ts'; import { makeSessionStore } from '../../__tests__/test-utils/store-factory.ts'; -import { parseDaemonPolicy } from '../../daemon-policy-file.ts'; +import { parseDaemonPolicy } from '@agent-device/daemon-contracts/daemon-policy-file'; import type { DaemonRequest } from '../daemon-request.ts'; import { LeaseRegistry } from '../lease-registry.ts'; import { createRequestExecutionScope } from '../request-execution-scope.ts'; diff --git a/src/daemon/__tests__/request-router-open.test.ts b/src/daemon/__tests__/request-router-open.test.ts index 405d701375..443eadd381 100644 --- a/src/daemon/__tests__/request-router-open.test.ts +++ b/src/daemon/__tests__/request-router-open.test.ts @@ -98,7 +98,7 @@ import { readProcessStartTime, } from '@agent-device/host-kit/process'; import { createDurableResourceEnvelope } from '@agent-device/capture-kit'; -import { resolveDaemonPaths } from '../../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { screenRecordingDurableResource } from '@agent-device/capture-kit/screen-recording-session-resource'; import { makeAndroidDevice, diff --git a/src/daemon/__tests__/session-store-lifetime.test.ts b/src/daemon/__tests__/session-store-lifetime.test.ts index 80ca833207..fe6fe62d16 100644 --- a/src/daemon/__tests__/session-store-lifetime.test.ts +++ b/src/daemon/__tests__/session-store-lifetime.test.ts @@ -9,7 +9,7 @@ import { authoringPublication, } from '../../__tests__/test-utils/session-factories.ts'; import { makeSessionStore, storeSessionForTest } from '../../__tests__/test-utils/store-factory.ts'; -import { resolveRepairTombstonePath } from '../../session-repair-tombstone.ts'; +import { resolveRepairTombstonePath } from '@agent-device/daemon-contracts/session-repair-tombstone'; const ADDRESS = 'cwd:worktree:default'; diff --git a/src/daemon/config.ts b/src/daemon/config.ts index 45f80de665..d815dc24ea 100644 --- a/src/daemon/config.ts +++ b/src/daemon/config.ts @@ -3,7 +3,7 @@ import type { SessionIsolationMode } from '@agent-device/kernel/contracts'; export type { SessionIsolationMode }; // The request-scoping rules only the daemon applies. What the client shares with it — state-dir, -// server-mode, and transport resolution — lives at the process root in `src/daemon-resolution.ts`, +// server-mode, and transport resolution — lives at the process root in `@agent-device/daemon-contracts/daemon-resolution`, // which both sides import directly. Composing those helpers back in here would cost every importer // that only needs a state dir one extra evaluated module, which ADR 0019's eager-closure probe // caught at `src/cli.ts`. diff --git a/src/daemon/daemon-policy.ts b/src/daemon/daemon-policy.ts index 76871d3714..2413802b64 100644 --- a/src/daemon/daemon-policy.ts +++ b/src/daemon/daemon-policy.ts @@ -11,13 +11,13 @@ import { resolveDaemonPolicyCommandName, type DaemonPolicy, type DaemonPolicyCapability, -} from '../daemon-policy-file.ts'; +} from '@agent-device/daemon-contracts/daemon-policy-file'; import type { DaemonRequest } from './daemon-request.ts'; /** * ADR 0029 enforcement: every request the daemon admits, including `batch` steps and `replay` * actions, which re-enter request admission rather than the HTTP edge. The policy file itself is - * loaded and validated by `src/daemon-policy-file.ts`. + * loaded and validated by `@agent-device/daemon-contracts/daemon-policy-file`. */ /** Refuses a request the policy denies before it resolves a device or takes a lock. */ diff --git a/src/daemon/daemon-stop.ts b/src/daemon/daemon-stop.ts index c5e53eefcf..f9482dc2a7 100644 --- a/src/daemon/daemon-stop.ts +++ b/src/daemon/daemon-stop.ts @@ -1,10 +1,13 @@ import { AppError } from '@agent-device/kernel/errors'; -import type { DaemonRetirementResult } from '../daemon-registration-owner.ts'; +import type { DaemonRetirementResult } from '@agent-device/daemon-contracts/daemon-registration-owner'; import type { OwnerIdentity } from '@agent-device/host-kit/process'; -import type { DaemonPaths } from '../daemon-resolution.ts'; -import { readRegisteredDaemonIdentity } from '../daemon-registration.ts'; -import type { DeviceClaimRecord, ProviderReleaseRecord } from '../daemon-shutdown-report.ts'; +import type { DaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; +import { readRegisteredDaemonIdentity } from '@agent-device/daemon-contracts/daemon-registration'; +import type { + DeviceClaimRecord, + ProviderReleaseRecord, +} from '@agent-device/daemon-contracts/daemon-shutdown-report'; const DAEMON_STOP_GRACE_TIMEOUT_MS = 10_000; const DAEMON_STOP_KILL_TIMEOUT_MS = 2_000; @@ -43,7 +46,8 @@ export async function stopDaemon(params: { }): Promise { const info = readRegisteredDaemonIdentity(params.paths.infoPath); if (!info) return notRunningResult(); - const { stopAndRetireDaemon } = await import('../daemon-registration-owner.ts'); + const { stopAndRetireDaemon } = + await import('@agent-device/daemon-contracts/daemon-registration-owner'); const retirement = await stopAndRetireDaemon({ paths: params.paths, observed: info, diff --git a/src/daemon/device/__tests__/device-claim-prune.test.ts b/src/daemon/device/__tests__/device-claim-prune.test.ts index e90c2cc42e..f0f2e01b3e 100644 --- a/src/daemon/device/__tests__/device-claim-prune.test.ts +++ b/src/daemon/device/__tests__/device-claim-prune.test.ts @@ -7,7 +7,7 @@ import { reconcileOrphanedDeviceClaims } from '../device-claims.ts'; import { resolveDeviceClaimPath } from '../device-claim-paths.ts'; import { acquireProcessLock } from '@agent-device/host-kit/file'; import { readCurrentOwnerIdentity } from '@agent-device/host-kit/process'; -import { publishDaemonRegistration } from '../../../__tests__/test-utils/device-claim-store.ts'; +import { publishDaemonRegistration } from '@agent-device/daemon-contracts/daemon-registration-fixtures'; import { mkdtempForTestSync } from '../../../__tests__/test-utils/tmp-dir.ts'; diff --git a/src/daemon/device/__tests__/device-claim-settlement.test.ts b/src/daemon/device/__tests__/device-claim-settlement.test.ts index a8c89e3cc4..7c32ef7d18 100644 --- a/src/daemon/device/__tests__/device-claim-settlement.test.ts +++ b/src/daemon/device/__tests__/device-claim-settlement.test.ts @@ -9,7 +9,7 @@ import { inspectDeviceClaims } from '../device-claim-inspection.ts'; import type { DeviceBootObservationService } from '@agent-device/contracts/device-boot'; import type { DeviceInfo } from '@agent-device/kernel/device'; import { mkdtempForTestSync } from '../../../__tests__/test-utils/tmp-dir.ts'; -import { publishDaemonRegistration } from '../../../__tests__/test-utils/device-claim-store.ts'; +import { publishDaemonRegistration } from '@agent-device/daemon-contracts/daemon-registration-fixtures'; vi.mock('@agent-device/host-kit/process', async (importOriginal) => (await import('../../../__tests__/test-utils/host-process-mock.ts')).pinOwnProcessStartTime( importOriginal, diff --git a/src/daemon/device/__tests__/device-claims.test.ts b/src/daemon/device/__tests__/device-claims.test.ts index f0e475d736..b5c4ac9691 100644 --- a/src/daemon/device/__tests__/device-claims.test.ts +++ b/src/daemon/device/__tests__/device-claims.test.ts @@ -14,7 +14,7 @@ import { canonicalLocalDeviceKey } from '../device-claim-paths.ts'; import { inspectDeviceClaims } from '../device-claim-inspection.ts'; import type { DeviceInfo } from '@agent-device/kernel/device'; import { mkdtempForTestSync } from '../../../__tests__/test-utils/tmp-dir.ts'; -import { publishDaemonRegistration } from '../../../__tests__/test-utils/device-claim-store.ts'; +import { publishDaemonRegistration } from '@agent-device/daemon-contracts/daemon-registration-fixtures'; import { readCurrentOwnerIdentity } from '@agent-device/host-kit/process'; import { acquireProcessLock } from '@agent-device/host-kit/file'; diff --git a/src/daemon/device/device-claim-inspection.ts b/src/daemon/device/device-claim-inspection.ts index f1a7d6110f..fdecfb89c7 100644 --- a/src/daemon/device/device-claim-inspection.ts +++ b/src/daemon/device/device-claim-inspection.ts @@ -7,7 +7,7 @@ import { readHostProcessIdentityObservations, } from '@agent-device/host-kit/process'; -import { isSupersededDaemonOwner } from '../../daemon-registration.ts'; +import { isSupersededDaemonOwner } from '@agent-device/daemon-contracts/daemon-registration'; import { resolveDeviceClaimRoot } from './device-claim-paths.ts'; import { decodeStoredDeviceClaim, type DeviceClaim } from './device-claim-record.ts'; diff --git a/src/daemon/device/device-claim-owner-recovery.ts b/src/daemon/device/device-claim-owner-recovery.ts index 977561e2df..2cb4100105 100644 --- a/src/daemon/device/device-claim-owner-recovery.ts +++ b/src/daemon/device/device-claim-owner-recovery.ts @@ -1,6 +1,6 @@ import type { PlatformRequestScope } from '@agent-device/contracts/platform-runtime-host'; import { createOwnedProcessRecordStore } from '@agent-device/host-kit/process'; -import { resolveDaemonPaths } from '../../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { createDeviceClaimReconciler } from './device-claim-reconciliation.ts'; import type { DeviceClaimReconciler } from './device-claims.ts'; import type { ClaimRecoveryGatewayFactory } from './claim-recovery-gateway.ts'; diff --git a/src/daemon/device/device-claim-reconciliation.ts b/src/daemon/device/device-claim-reconciliation.ts index fa45f94174..96b0ca9e04 100644 --- a/src/daemon/device/device-claim-reconciliation.ts +++ b/src/daemon/device/device-claim-reconciliation.ts @@ -4,7 +4,7 @@ import type { PlatformRequestScope } from '@agent-device/contracts/platform-runt import type { PlatformRuntimeOperations } from '@agent-device/contracts/platform-runtime-operations'; import { sameDeviceIdentity } from '@agent-device/kernel/device'; import { emitDiagnostic } from '@agent-device/host-kit/diagnostics'; -import { resolveDaemonPaths } from '../../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { appLogDurableResource } from '../app-log-session-resource.ts'; import { recoverAppLogResourceAfterDaemonLock } from '../app-log-resource-recovery.ts'; import type { DeviceClaim } from './device-claim-record.ts'; diff --git a/src/daemon/lease-lifecycle.ts b/src/daemon/lease-lifecycle.ts index d4fff4d04c..4a432e04a3 100644 --- a/src/daemon/lease-lifecycle.ts +++ b/src/daemon/lease-lifecycle.ts @@ -13,7 +13,7 @@ import type { SessionStore } from './session-store.ts'; import type { DaemonRequest } from './daemon-request.ts'; import type { SessionRef, SessionState } from './session-state.ts'; import { providerSessionIdFromData } from './provider-session-ownership.ts'; -import type { DaemonPolicy } from '../daemon-policy-file.ts'; +import type { DaemonPolicy } from '@agent-device/daemon-contracts/daemon-policy-file'; export type ExpiredProviderLeaseRecovery = (lease: DeviceLease) => Promise; diff --git a/src/daemon/request-admission.ts b/src/daemon/request-admission.ts index 5b23e0aca8..1b61a57a9e 100644 --- a/src/daemon/request-admission.ts +++ b/src/daemon/request-admission.ts @@ -19,7 +19,7 @@ import type { DaemonRequest } from './daemon-request.ts'; import type { SessionState } from './session-state.ts'; import { assertMacOsAppLeaseAdmitsRequest } from './macos-app-lease.ts'; import { assertDaemonPolicyAdmitsLease } from './daemon-policy.ts'; -import type { DaemonPolicy } from '../daemon-policy-file.ts'; +import type { DaemonPolicy } from '@agent-device/daemon-contracts/daemon-policy-file'; export function scopeRequestSession(req: DaemonRequest): DaemonRequest { const isolation = resolveSessionIsolationMode( diff --git a/src/daemon/request-execution-scope.ts b/src/daemon/request-execution-scope.ts index ec083ddfcc..2dab75935f 100644 --- a/src/daemon/request-execution-scope.ts +++ b/src/daemon/request-execution-scope.ts @@ -72,7 +72,7 @@ import { assertDaemonPolicyAdmitsDevice, assertDaemonPolicyAdmitsRequest, } from './daemon-policy.ts'; -import type { DaemonPolicy } from '../daemon-policy-file.ts'; +import type { DaemonPolicy } from '@agent-device/daemon-contracts/daemon-policy-file'; import { requestDispatchLedger, type RequestDispatchLedger } from './request-dispatch-ledger.ts'; // Production daemon wiring owns one LeaseRegistry per process; scoping locks by registry keeps diff --git a/src/daemon/request-router.ts b/src/daemon/request-router.ts index 9e1f6e9fae..08b0615685 100644 --- a/src/daemon/request-router.ts +++ b/src/daemon/request-router.ts @@ -94,7 +94,7 @@ import type { PlatformResourceCleanup } from './platform-resource-cleanup.ts'; import type { DaemonPlatformServices } from './platform-services.ts'; import type { DaemonProviderCredentials } from '../provider-credential-fingerprint.ts'; import { restrictDeviceInventoryToDaemonPolicy } from './daemon-policy.ts'; -import type { DaemonPolicy } from '../daemon-policy-file.ts'; +import type { DaemonPolicy } from '@agent-device/daemon-contracts/daemon-policy-file'; // --------------------------------------------------------------------------- // Request handler API diff --git a/src/daemon/server/daemon-metadata-loss.test.ts b/src/daemon/server/daemon-metadata-loss.test.ts index f561bf874c..b97247ac4d 100644 --- a/src/daemon/server/daemon-metadata-loss.test.ts +++ b/src/daemon/server/daemon-metadata-loss.test.ts @@ -3,7 +3,7 @@ import fs from 'node:fs'; import path from 'node:path'; import { describe, test, vi } from 'vitest'; import { mkdtempForTestSync } from '../../__tests__/test-utils/tmp-dir.ts'; -import { publishDaemonRegistration } from '../../__tests__/test-utils/device-claim-store.ts'; +import { publishDaemonRegistration } from '@agent-device/daemon-contracts/daemon-registration-fixtures'; import { readDaemonMetadataLoss, watchDaemonMetadataLoss, diff --git a/src/daemon/server/daemon-metadata-loss.ts b/src/daemon/server/daemon-metadata-loss.ts index 7411d8920e..9b39df5a53 100644 --- a/src/daemon/server/daemon-metadata-loss.ts +++ b/src/daemon/server/daemon-metadata-loss.ts @@ -3,7 +3,7 @@ import type { OwnerIdentity } from '@agent-device/host-kit/process'; import { readRegisteredDaemonOwnership, type RegisteredDaemonOwnership, -} from '../../daemon-registration.ts'; +} from '@agent-device/daemon-contracts/daemon-registration'; /** A registration this daemon no longer owns, naming the successor when the record does. */ export type DaemonMetadataLoss = Readonly<{ diff --git a/src/daemon/server/daemon-runtime-idle-reap.test.ts b/src/daemon/server/daemon-runtime-idle-reap.test.ts index 83f9580770..8174fc2f49 100644 --- a/src/daemon/server/daemon-runtime-idle-reap.test.ts +++ b/src/daemon/server/daemon-runtime-idle-reap.test.ts @@ -16,7 +16,7 @@ vi.mock('../lease-registry.ts', async (importOriginal) => { return { ...actual, LeaseRegistry: RecordedLeaseRegistry }; }); -import { resolveDaemonPaths } from '../../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { startDaemonRuntime } from './daemon-runtime.ts'; import { mkdtempForTestSync } from '../../__tests__/test-utils/tmp-dir.ts'; diff --git a/src/daemon/server/daemon-runtime-interactor-composition.test.ts b/src/daemon/server/daemon-runtime-interactor-composition.test.ts index 0d4f923b33..af6d730cca 100644 --- a/src/daemon/server/daemon-runtime-interactor-composition.test.ts +++ b/src/daemon/server/daemon-runtime-interactor-composition.test.ts @@ -10,8 +10,8 @@ import { providerCredentialFingerprint } from '../../provider-credential-fingerp import { DAEMON_STARTUP_EXIT_CODES, tryAcquireDaemonRegistration, -} from '../../daemon-registration-owner.ts'; -import { resolveDaemonPaths } from '../../daemon-resolution.ts'; +} from '@agent-device/daemon-contracts/daemon-registration-owner'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { interactorResolution } from '../interactor-resolution.ts'; vi.mock('../../platform-runtime.ts', () => ({ diff --git a/src/daemon/server/daemon-runtime-lifecycle-shutdown.test.ts b/src/daemon/server/daemon-runtime-lifecycle-shutdown.test.ts index 4594591de0..1730253d16 100644 --- a/src/daemon/server/daemon-runtime-lifecycle-shutdown.test.ts +++ b/src/daemon/server/daemon-runtime-lifecycle-shutdown.test.ts @@ -133,7 +133,7 @@ import { retainOrphanedDeviceClaims, } from '../../__tests__/test-utils/device-claim-store.ts'; import { sendRequest } from '../../daemon-client/daemon-client-transport.ts'; -import { resolveDaemonPaths } from '../../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { startDaemonRuntime, teardownDaemonSessionForShutdown } from './daemon-runtime.ts'; import { makeIosSession } from '../../__tests__/test-utils/session-factories.ts'; import { makeSessionStore } from '../../__tests__/test-utils/store-factory.ts'; diff --git a/src/daemon/server/daemon-runtime-metadata-ownership.test.ts b/src/daemon/server/daemon-runtime-metadata-ownership.test.ts index 82da792bed..f195effdfc 100644 --- a/src/daemon/server/daemon-runtime-metadata-ownership.test.ts +++ b/src/daemon/server/daemon-runtime-metadata-ownership.test.ts @@ -2,7 +2,7 @@ import fs from 'node:fs'; import path from 'node:path'; import { afterEach, expect, test, vi } from 'vitest'; import { mkdtempForTestSync } from '../../__tests__/test-utils/tmp-dir.ts'; -import { publishDaemonRegistration } from '../../__tests__/test-utils/device-claim-store.ts'; +import { publishDaemonRegistration } from '@agent-device/daemon-contracts/daemon-registration-fixtures'; const lifecycleEvents = vi.hoisted(() => [] as string[]); const startupFailure = vi.hoisted(() => ({ active: false })); @@ -58,7 +58,7 @@ vi.mock('../../platform-runtime-daemon-lifecycle.ts', () => ({ })); import { startDaemonRuntime } from './daemon-runtime.ts'; -import { resolveDaemonPaths } from '../../daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; type DaemonPaths = ReturnType; diff --git a/src/daemon/server/daemon-runtime.ts b/src/daemon/server/daemon-runtime.ts index 4826b3b6b6..09bf431ec5 100644 --- a/src/daemon/server/daemon-runtime.ts +++ b/src/daemon/server/daemon-runtime.ts @@ -2,7 +2,10 @@ import crypto from 'node:crypto'; import { asAppError, AppError, normalizeError } from '@agent-device/kernel/errors'; import { SessionStore } from '../session-store.ts'; import { resolveSessionRequestLogPath } from '../session-artifact-paths.ts'; -import { resolveDaemonPaths, resolveDaemonServerMode } from '../../daemon-resolution.ts'; +import { + resolveDaemonPaths, + resolveDaemonServerMode, +} from '@agent-device/daemon-contracts/daemon-resolution'; import { createDaemonHttpServer } from './http-server.ts'; import { trackDownloadableArtifact } from '../artifact-tracking.ts'; import { @@ -11,7 +14,10 @@ import { } from '../../provider-device-runtime.ts'; import { installProviderDeviceAdmission } from '../provider-device-admission.ts'; import { assertDaemonPolicyAllowsCapability } from '../daemon-policy.ts'; -import { loadDaemonPolicy, type DaemonPolicy } from '../../daemon-policy-file.ts'; +import { + loadDaemonPolicy, + type DaemonPolicy, +} from '@agent-device/daemon-contracts/daemon-policy-file'; import { getInteractor } from '../../core/interactors.ts'; import { installInteractorResolution } from '../interactor-resolution.ts'; import { @@ -39,7 +45,7 @@ import type { DaemonInvokeFn } from '../daemon-request.ts'; import type { SessionRef, SessionState } from '../session-state.ts'; import type { RuntimeHintValues } from '@agent-device/contracts/application-lifecycle-runtime'; import { createDaemonIdleReap } from './daemon-idle-reap.ts'; -import { withDaemonDiagnosticsScope } from '../../daemon-contracts/daemon-diagnostics-scope.ts'; +import { withDaemonDiagnosticsScope } from '@agent-device/daemon-contracts/daemon-diagnostics-scope'; import { createSessionIdleExpiry } from './daemon-session-idle-expiry.ts'; import { resolveSessionIdleExpiryMs } from '../session-idle-expiry.ts'; import { finalizeDaemonLeases } from './daemon-lease-finalizer.ts'; @@ -73,7 +79,7 @@ import { tryAcquireDaemonRegistration, DAEMON_STARTUP_EXIT_CODES, type DaemonRegistrationOwner, -} from '../../daemon-registration-owner.ts'; +} from '@agent-device/daemon-contracts/daemon-registration-owner'; import { watchDaemonMetadataLoss, type DaemonMetadataLoss } from './daemon-metadata-loss.ts'; import { createSocketServer, diff --git a/src/daemon/server/daemon-shutdown-claims.ts b/src/daemon/server/daemon-shutdown-claims.ts index fc070a623c..5207dda372 100644 --- a/src/daemon/server/daemon-shutdown-claims.ts +++ b/src/daemon/server/daemon-shutdown-claims.ts @@ -1,7 +1,7 @@ import { publicPlatformString } from '@agent-device/kernel/device'; import { emitDiagnostic } from '@agent-device/host-kit/diagnostics'; import { clearDeviceClaim, type DeviceClaimClearOutcome } from '../device/device-claims.ts'; -import type { DeviceClaimRecord } from '../../daemon-shutdown-report.ts'; +import type { DeviceClaimRecord } from '@agent-device/daemon-contracts/daemon-shutdown-report'; import type { SessionState } from '../session-state.ts'; export type DaemonShutdownClaims = { diff --git a/src/daemon/server/http-rpc-envelope.ts b/src/daemon/server/http-rpc-envelope.ts index f627c81d2e..52099d2a0b 100644 --- a/src/daemon/server/http-rpc-envelope.ts +++ b/src/daemon/server/http-rpc-envelope.ts @@ -6,7 +6,7 @@ import type { JsonRpcId, JsonRpcRequestEnvelope } from '@agent-device/kernel/con import { serializeDaemonProgressEnvelope, serializeDaemonRpcResponseEnvelope, -} from '../../request-progress-protocol.ts'; +} from '@agent-device/daemon-contracts/request-progress-protocol'; import { statusCodeForNormalizedError } from '../http-errors.ts'; type JsonRpcRequest = JsonRpcRequestEnvelope; diff --git a/src/daemon/server/http-server.ts b/src/daemon/server/http-server.ts index 98996aa03d..1a48749344 100644 --- a/src/daemon/server/http-server.ts +++ b/src/daemon/server/http-server.ts @@ -32,7 +32,7 @@ import { tryHandleHostAdminHttpRoute } from '../host-lease-http.ts'; import { resolveTrustedTenant, tenantTrustRejectionError } from './tenant-trust.ts'; import { refuseStaleDaemonInstance } from './http-instance-precondition.ts'; import type { LeaseRegistry } from '../lease-registry.ts'; -import { shouldStreamRequestProgress } from '../../request-progress-protocol.ts'; +import { shouldStreamRequestProgress } from '@agent-device/daemon-contracts/request-progress-protocol'; import { createRpcError, jsonRpcCodeForNormalizedError, diff --git a/src/daemon/server/transport.ts b/src/daemon/server/transport.ts index 0688ab58bb..a411f65cde 100644 --- a/src/daemon/server/transport.ts +++ b/src/daemon/server/transport.ts @@ -17,7 +17,7 @@ import { serializeDaemonProgressEnvelope, serializeDaemonResponseEnvelope, shouldStreamRequestProgress, -} from '../../request-progress-protocol.ts'; +} from '@agent-device/daemon-contracts/request-progress-protocol'; export type DaemonServer = (net.Server | HttpServer) & { destroyConnections?: () => void; diff --git a/src/daemon/session-idle-tombstone.ts b/src/daemon/session-idle-tombstone.ts index 0cdb2c569a..c10a3c9d8a 100644 --- a/src/daemon/session-idle-tombstone.ts +++ b/src/daemon/session-idle-tombstone.ts @@ -7,7 +7,7 @@ import path from 'node:path'; * session is gone and its device released, instead of the bare "Run open first" that reads like the * agent never opened anything. * - * Same shape and lifetime as the repair tombstone (`src/session-repair-tombstone.ts`): keyed by the + * Same shape and lifetime as the repair tombstone (`@agent-device/daemon-contracts/session-repair-tombstone`): keyed by the * session's own store key, and bounded by `expiresAt` so an old marker never shadows an unrelated * future session that happens to reuse the name. */ diff --git a/src/daemon/session-store.ts b/src/daemon/session-store.ts index 996ec78211..62a4cba8bf 100644 --- a/src/daemon/session-store.ts +++ b/src/daemon/session-store.ts @@ -15,7 +15,7 @@ import { clearRepairTombstoneFile, resolveRepairTombstonePath, type RepairSessionTombstone, -} from '../session-repair-tombstone.ts'; +} from '@agent-device/daemon-contracts/session-repair-tombstone'; import { readIdleSessionTombstoneFile, resolveIdleSessionTombstonePath, diff --git a/src/platform-runtime-daemon-owner-cleanup.ts b/src/platform-runtime-daemon-owner-cleanup.ts index 6e8ed29443..a09e727ab6 100644 --- a/src/platform-runtime-daemon-owner-cleanup.ts +++ b/src/platform-runtime-daemon-owner-cleanup.ts @@ -1,4 +1,4 @@ -import type { DaemonOwnerCleanup } from './daemon-owner-cleanup.ts'; +import type { DaemonOwnerCleanup } from '@agent-device/daemon-contracts/daemon-owner-cleanup'; /** * Root composition for owner-scoped host cleanup. The CLI names only the neutral service; Apple diff --git a/test/integration/android-emulator-e2e/live-observability-scenario.ts b/test/integration/android-emulator-e2e/live-observability-scenario.ts index 8c39e1e754..bd2cfc28fc 100644 --- a/test/integration/android-emulator-e2e/live-observability-scenario.ts +++ b/test/integration/android-emulator-e2e/live-observability-scenario.ts @@ -4,7 +4,7 @@ import path from 'node:path'; import { PUBLIC_COMMANDS } from '@agent-device/command-registry/catalog'; import { readDaemonInfo } from '../../../src/daemon-client/daemon-client-metadata.ts'; -import { resolveDaemonPaths } from '../../../src/daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { collectPagedEventTimeline, type EventTimelinePage, diff --git a/test/integration/daemon-replace-exit-flush.test.ts b/test/integration/daemon-replace-exit-flush.test.ts index a1034da385..b909b0798a 100644 --- a/test/integration/daemon-replace-exit-flush.test.ts +++ b/test/integration/daemon-replace-exit-flush.test.ts @@ -5,7 +5,7 @@ import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; import { skipWhenLoopbackUnavailable } from '../../src/__tests__/test-utils/loopback.ts'; -import { stopDaemonProcess } from '../../src/daemon-process.ts'; +import { stopDaemonProcess } from '@agent-device/daemon-contracts/daemon-process'; import { isProcessAlive } from '@agent-device/host-kit/process'; import { assertNoDaemonLeaks } from './support/daemon-leak-oracle.ts'; import { runCliJson } from './test-helpers.ts'; diff --git a/test/integration/ios-simulator-e2e/live-harness.ts b/test/integration/ios-simulator-e2e/live-harness.ts index a1f4fcb16a..f448989f02 100644 --- a/test/integration/ios-simulator-e2e/live-harness.ts +++ b/test/integration/ios-simulator-e2e/live-harness.ts @@ -2,7 +2,7 @@ import assert from 'node:assert/strict'; import fs from 'node:fs'; import path from 'node:path'; -import { resolveDaemonPaths } from '../../../src/daemon-resolution.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { PRE_DISPATCH_REFUSAL_REASONS } from '@agent-device/kernel/errors'; import type { CliJsonResult } from '../cli-json.ts'; import { diff --git a/test/integration/provider-scenarios/daemon-lifecycle.test.ts b/test/integration/provider-scenarios/daemon-lifecycle.test.ts index b85bc32a36..fe78be0525 100644 --- a/test/integration/provider-scenarios/daemon-lifecycle.test.ts +++ b/test/integration/provider-scenarios/daemon-lifecycle.test.ts @@ -3,8 +3,8 @@ import fs from 'node:fs'; import path from 'node:path'; import { test } from 'vitest'; import { parseIntegerEnv } from '../../../src/daemon/server/server-lifecycle.ts'; -import { tryAcquireDaemonRegistration } from '../../../src/daemon-registration-owner.ts'; -import { resolveDaemonPaths } from '../../../src/daemon-resolution.ts'; +import { tryAcquireDaemonRegistration } from '@agent-device/daemon-contracts/daemon-registration-owner'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { mkdtempForTestSync } from '../../../src/__tests__/test-utils/tmp-dir.ts'; test('Provider-backed integration daemon lifecycle writes metadata and protects acquisitions', async () => { diff --git a/test/integration/smoke-daemon-clean.test.ts b/test/integration/smoke-daemon-clean.test.ts index a8f0dde5ab..6940be1ab8 100644 --- a/test/integration/smoke-daemon-clean.test.ts +++ b/test/integration/smoke-daemon-clean.test.ts @@ -7,8 +7,8 @@ import path from 'node:path'; import { skipWhenLoopbackUnavailable } from '../../src/__tests__/test-utils/loopback.ts'; import { runCmdSync } from '@agent-device/host-kit/command'; import { isProcessAlive, readProcessStartTime } from '@agent-device/host-kit/process'; -import { stopAndRetireDaemon } from '../../src/daemon-registration-owner.ts'; -import { resolveDaemonPaths } from '../../src/daemon-resolution.ts'; +import { stopAndRetireDaemon } from '@agent-device/daemon-contracts/daemon-registration-owner'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { assertNoDaemonLeaks } from './support/daemon-leak-oracle.ts'; import { runCliJson } from './test-helpers.ts'; diff --git a/test/integration/smoke-daemon-http.test.ts b/test/integration/smoke-daemon-http.test.ts index f0052464ed..969f670683 100644 --- a/test/integration/smoke-daemon-http.test.ts +++ b/test/integration/smoke-daemon-http.test.ts @@ -6,7 +6,7 @@ import os from 'node:os'; import path from 'node:path'; import { DAEMON_RPC_PROTOCOL_VERSION } from '@agent-device/contracts/daemon-http'; import { skipWhenLoopbackUnavailable } from '../../src/__tests__/test-utils/loopback.ts'; -import { stopDaemonProcess } from '../../src/daemon-process.ts'; +import { stopDaemonProcess } from '@agent-device/daemon-contracts/daemon-process'; import { formatResultDebug } from './cli-json.ts'; import { assertNoDaemonLeaks } from './support/daemon-leak-oracle.ts'; import { runCliJson } from './test-helpers.ts'; diff --git a/test/integration/smoke-web-platform.test.ts b/test/integration/smoke-web-platform.test.ts index a9a3751eb2..e0243f7206 100644 --- a/test/integration/smoke-web-platform.test.ts +++ b/test/integration/smoke-web-platform.test.ts @@ -20,7 +20,7 @@ import { stopDaemonProcess, waitForDaemonExit, type DaemonProcessIdentity, -} from '../../src/daemon-process.ts'; +} from '@agent-device/daemon-contracts/daemon-process'; import { expandProcessTree, isProcessAlive, diff --git a/test/integration/support/daemon-test-cleanup.test.ts b/test/integration/support/daemon-test-cleanup.test.ts index 35e64b8768..9fc260c27f 100644 --- a/test/integration/support/daemon-test-cleanup.test.ts +++ b/test/integration/support/daemon-test-cleanup.test.ts @@ -6,8 +6,8 @@ import { readHostProcessIdentityObservations, } from '@agent-device/host-kit/process'; import { cleanupDaemonTestState } from './daemon-test-cleanup.ts'; -import { resolveDaemonPaths } from '../../../src/daemon-resolution.ts'; -import { stopDaemonProcess } from '../../../src/daemon-process.ts'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; +import { stopDaemonProcess } from '@agent-device/daemon-contracts/daemon-process'; import { mkdtempForTestSync } from '../../../src/__tests__/test-utils/tmp-dir.ts'; import { spawnRegisteredDaemonFixture, diff --git a/test/integration/support/daemon-test-cleanup.ts b/test/integration/support/daemon-test-cleanup.ts index 0f1febc50f..9743c06016 100644 --- a/test/integration/support/daemon-test-cleanup.ts +++ b/test/integration/support/daemon-test-cleanup.ts @@ -6,12 +6,12 @@ import { ownerIdentityMatches, type OwnerIdentity, } from '@agent-device/host-kit/process'; -import { stopDaemonProcess } from '../../../src/daemon-process.ts'; -import { resolveDaemonPaths } from '../../../src/daemon-resolution.ts'; +import { stopDaemonProcess } from '@agent-device/daemon-contracts/daemon-process'; +import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { readRegisteredDaemonIdentity, readRegisteredDaemonOwnership, -} from '../../../src/daemon-registration.ts'; +} from '@agent-device/daemon-contracts/daemon-registration'; type TestDaemonIdentity = { pid: number; processStartTime?: string }; diff --git a/test/wire-compat/ledger.json b/test/wire-compat/ledger.json index 4d5756e073..8e8077de80 100644 --- a/test/wire-compat/ledger.json +++ b/test/wire-compat/ledger.json @@ -88,14 +88,14 @@ "src/daemon/request-diagnostics-http.ts#RequestDiagnosticsHttpOptions": "sha256:cd2c0dda77d2bc434857aea07206a5491ce5f0b82cb86628569f607d6c2cebcf", "src/daemon/request-diagnostics-http.ts#handleRequestDiagnostics": "sha256:32c3d100176dd99ecbb61f8050d05b1cda64b7be1944a2cd16633e83fa78660b", "src/daemon/request-diagnostics-http.ts#resolveRequestDiagnosticsHttpRoute": "sha256:4ff07623b27a6f7461e1addb87aabd149904da63f7462149ae4114d14336cde0", - "src/request-progress-protocol.ts#DaemonProgressEnvelope": "sha256:16162d01cfc43fc6a0198dbba3358981c1a278a70f7494ebe70d051f517cfb22", - "src/request-progress-protocol.ts#DaemonResponseEnvelope": "sha256:202ae64836af890549a1d95963903f9a506294b80bd0862c1b708e72d7f286d0", - "src/request-progress-protocol.ts#isDaemonProgressEnvelope": "sha256:e38ec26b64d20e257ff00860548e9c12ac22faf5a6308749d4715129814b381f", - "src/request-progress-protocol.ts#isDaemonResponseEnvelope": "sha256:d754aee28bdba524a4b5ea71cc0a2393a7ecc5103a30a2c57c56706a8b0ceb52", - "src/request-progress-protocol.ts#serializeDaemonProgressEnvelope": "sha256:c48467b58393d88c947a89559f704c0c8fdbbbdf36cf5381936b6b5136c57442", - "src/request-progress-protocol.ts#serializeDaemonResponseEnvelope": "sha256:bc2b651df28446c51d8b92b7fd47a3bced9fade9ae50e2cd73e453ba89fd33b5", - "src/request-progress-protocol.ts#serializeDaemonRpcResponseEnvelope": "sha256:e244291bef44cedfb59ad07c45337bb8e5fdde00b712ebdf5ca9627f6355f111", - "src/request-progress-protocol.ts#shouldStreamRequestProgress": "sha256:cf7b26ccea9cd5c33c93477f783a3bdb9a1b0ce629da8b77fef0d49d6c6f4112", + "packages/daemon-contracts/src/request-progress-protocol.ts#DaemonProgressEnvelope": "sha256:16162d01cfc43fc6a0198dbba3358981c1a278a70f7494ebe70d051f517cfb22", + "packages/daemon-contracts/src/request-progress-protocol.ts#DaemonResponseEnvelope": "sha256:202ae64836af890549a1d95963903f9a506294b80bd0862c1b708e72d7f286d0", + "packages/daemon-contracts/src/request-progress-protocol.ts#isDaemonProgressEnvelope": "sha256:e38ec26b64d20e257ff00860548e9c12ac22faf5a6308749d4715129814b381f", + "packages/daemon-contracts/src/request-progress-protocol.ts#isDaemonResponseEnvelope": "sha256:d754aee28bdba524a4b5ea71cc0a2393a7ecc5103a30a2c57c56706a8b0ceb52", + "packages/daemon-contracts/src/request-progress-protocol.ts#serializeDaemonProgressEnvelope": "sha256:c48467b58393d88c947a89559f704c0c8fdbbbdf36cf5381936b6b5136c57442", + "packages/daemon-contracts/src/request-progress-protocol.ts#serializeDaemonResponseEnvelope": "sha256:bc2b651df28446c51d8b92b7fd47a3bced9fade9ae50e2cd73e453ba89fd33b5", + "packages/daemon-contracts/src/request-progress-protocol.ts#serializeDaemonRpcResponseEnvelope": "sha256:e244291bef44cedfb59ad07c45337bb8e5fdde00b712ebdf5ca9627f6355f111", + "packages/daemon-contracts/src/request-progress-protocol.ts#shouldStreamRequestProgress": "sha256:cf7b26ccea9cd5c33c93477f783a3bdb9a1b0ce629da8b77fef0d49d6c6f4112", "src/daemon/resumable-upload.ts#BeginResumableUploadOptions": "sha256:ef804e321b8cd1f23a51566919fc0cda79c1b0ef82aeceed54ce3f2a398d8457", "src/daemon/server/http-rpc-methods.ts#COMMAND_RPC_METHODS": "sha256:4b675a84ef475c2fe0e864457c254c2e888de942e4ae428d5b3e1fa72101e97b", "src/daemon/server/http-authorization.ts#HttpAuthDecision": "sha256:a7fc2a91f998ce62b107b14dd9b6fcf1f4ca5abe2e30d4df5a0896d56a0a52f8", diff --git a/test/wire-compat/surface.ts b/test/wire-compat/surface.ts index d81c936be9..62aeab19a3 100644 --- a/test/wire-compat/surface.ts +++ b/test/wire-compat/surface.ts @@ -55,7 +55,7 @@ const REQUEST_DIAGNOSTICS_HTTP = 'src/daemon/request-diagnostics-http.ts'; const SESSION_TENANT_SCOPE = 'src/daemon/session-tenant-scope.ts'; const HTTP_REQUEST_TARGET = 'src/daemon/http-request-target.ts'; const REMOTE_REQUEST_DIAGNOSTICS = 'src/remote/remote-request-diagnostics.ts'; -const PROGRESS_PROTOCOL = 'src/request-progress-protocol.ts'; +const PROGRESS_PROTOCOL = 'packages/daemon-contracts/src/request-progress-protocol.ts'; const CLIENT_RPC = 'src/daemon-client/daemon-client-rpc.ts'; const CLIENT_PROGRESS = 'src/daemon-client/daemon-client-progress.ts'; const CLIENT_TRANSPORT = 'src/daemon-client/daemon-client-transport.ts'; diff --git a/test/wire-compat/wire-mutations.test.ts b/test/wire-compat/wire-mutations.test.ts index 40a2c373a2..c3513637e1 100644 --- a/test/wire-compat/wire-mutations.test.ts +++ b/test/wire-compat/wire-mutations.test.ts @@ -86,7 +86,7 @@ const MUTATIONS: readonly WireMutation[] = [ }, { breakClass: 'response serialization: the RPC envelope stops being newline-framed', - file: 'src/request-progress-protocol.ts', + file: 'packages/daemon-contracts/src/request-progress-protocol.ts', name: 'serializeDaemonRpcResponseEnvelope', from: '}\\n`', to: '}`', @@ -156,7 +156,7 @@ const MUTATIONS: readonly WireMutation[] = [ }, { breakClass: 'progress framing: the envelope discriminant is renamed', - file: 'src/request-progress-protocol.ts', + file: 'packages/daemon-contracts/src/request-progress-protocol.ts', name: 'DaemonProgressEnvelope', from: "type: 'progress';", to: "kind: 'progress';", diff --git a/tsconfig.json b/tsconfig.json index 2738155612..50b9907337 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -34,6 +34,7 @@ { "path": "packages/capture-kit" }, { "path": "packages/command-registry" }, { "path": "packages/contracts" }, + { "path": "packages/daemon-contracts" }, { "path": "packages/device-selection" }, { "path": "packages/host-kit" }, { "path": "packages/kernel" }, diff --git a/vitest.config.ts b/vitest.config.ts index 7abf9d88c2..6ea6ec7b54 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -11,7 +11,7 @@ const MUTATION_EXCLUDED_SUBPROCESS_TESTS: readonly string[] = [ 'scripts/fuzz/harness.test.ts', // The daemon takeover test launches a branch-named daemon per case to prove // that worktree identity does not strand the predecessor (#1545). - 'src/__tests__/daemon-process-takeover.test.ts', + 'packages/daemon-contracts/src/daemon-process-takeover.test.ts', ]; // The fuzz corpus replay, which must not run under V8 coverage instrumentation.