diff --git a/packages/daemon/package.json b/packages/daemon/package.json index dddd2e3edb..a26ec86a75 100644 --- a/packages/daemon/package.json +++ b/packages/daemon/package.json @@ -18,6 +18,7 @@ "@agent-device/platform-android": "workspace:*", "@agent-device/platform-apple": "workspace:*", "@agent-device/platform-web": "workspace:*", + "@agent-device/proxy": "workspace:*", "@agent-device/replay-port": "workspace:*", "@agent-device/replay-test": "workspace:*", "@agent-device/selectors": "workspace:*", @@ -351,10 +352,6 @@ "types": "./src/server/http/http-server.ts", "default": "./src/server/http/http-server.ts" }, - "./testing/server/server-lifecycle": { - "types": "./src/server/http/server-lifecycle.ts", - "default": "./src/server/http/server-lifecycle.ts" - }, "./testing/server/server-shutdown": { "types": "./src/server/http/server-shutdown.ts", "default": "./src/server/http/server-shutdown.ts" diff --git a/packages/daemon/src/server/__tests__/http-server-rpc-lifetime.test.ts b/packages/daemon/src/server/__tests__/http-server-rpc-lifetime.test.ts index ad4198c377..109849ae0e 100644 --- a/packages/daemon/src/server/__tests__/http-server-rpc-lifetime.test.ts +++ b/packages/daemon/src/server/__tests__/http-server-rpc-lifetime.test.ts @@ -12,7 +12,7 @@ const TOKEN = 'lifetime-token'; // the rerun below would be refused as `duplicate_request_id`. The token gate refuses a call that // already registered — admission order is pinned in `http-server-rpc-admission.test.ts` — so // this is where that release is pinned. Disconnect and streaming releases live in -// `daemon-http-server.test.ts` and `daemon-http-boundary-cancellation.test.ts`. +// `daemon-http-server.test.ts` and `http-server-boundary-cancellation.test.ts`. test('an rpc request registers its tracking id while in flight and releases it once answered', async (t) => { if (await skipWhenLoopbackUnavailable(t)) return; const { port, server } = await startRpcServer(TOKEN, async (request) => { diff --git a/test/integration/provider-scenarios/daemon-http-boundary-cancellation.test.ts b/packages/daemon/src/server/http/http-server-boundary-cancellation.test.ts similarity index 97% rename from test/integration/provider-scenarios/daemon-http-boundary-cancellation.test.ts rename to packages/daemon/src/server/http/http-server-boundary-cancellation.test.ts index f8264f785f..cb635b9149 100644 --- a/test/integration/provider-scenarios/daemon-http-boundary-cancellation.test.ts +++ b/packages/daemon/src/server/http/http-server-boundary-cancellation.test.ts @@ -4,7 +4,7 @@ import assert from 'node:assert/strict'; import http from 'node:http'; import { test } from 'vitest'; import { getRequestSignal } from '@agent-device/host-kit/request'; -import { createDaemonHttpServer } from '@agent-device/daemon/testing/server/http-server'; +import { createDaemonHttpServer } from './http-server.ts'; import { closeLoopbackServer, listenOnLoopback, diff --git a/test/integration/provider-scenarios/daemon-http-disconnect.test.ts b/packages/daemon/src/server/http/http-server-disconnect.test.ts similarity index 99% rename from test/integration/provider-scenarios/daemon-http-disconnect.test.ts rename to packages/daemon/src/server/http/http-server-disconnect.test.ts index 1551450eac..fab916dd07 100644 --- a/test/integration/provider-scenarios/daemon-http-disconnect.test.ts +++ b/packages/daemon/src/server/http/http-server-disconnect.test.ts @@ -4,7 +4,7 @@ import assert from 'node:assert/strict'; import http from 'node:http'; import { test } from 'vitest'; import { getRequestSignal } from '@agent-device/host-kit/request'; -import { createDaemonHttpServer } from '@agent-device/daemon/testing/server/http-server'; +import { createDaemonHttpServer } from './http-server.ts'; import { closeLoopbackServer, listenOnLoopback, diff --git a/test/integration/provider-scenarios/daemon-http-lease-allocate.test.ts b/packages/daemon/src/server/http/http-server-lease-allocate.test.ts similarity index 96% rename from test/integration/provider-scenarios/daemon-http-lease-allocate.test.ts rename to packages/daemon/src/server/http/http-server-lease-allocate.test.ts index b988bd6f5d..769a458e7f 100644 --- a/test/integration/provider-scenarios/daemon-http-lease-allocate.test.ts +++ b/packages/daemon/src/server/http/http-server-lease-allocate.test.ts @@ -2,7 +2,7 @@ import type { DaemonWireRequest } from '@agent-device/contracts/command'; import type { DaemonResponse } from '@agent-device/kernel/contracts'; import assert from 'node:assert/strict'; import { test } from 'vitest'; -import { createDaemonHttpServer } from '@agent-device/daemon/testing/server/http-server'; +import { createDaemonHttpServer } from './http-server.ts'; import { closeLoopbackServer, listenOnLoopback, diff --git a/src/__tests__/daemon-proxy.test.ts b/packages/daemon/src/server/http/http-server-proxy.test.ts similarity index 99% rename from src/__tests__/daemon-proxy.test.ts rename to packages/daemon/src/server/http/http-server-proxy.test.ts index 5410d77b04..86332eb96c 100644 --- a/src/__tests__/daemon-proxy.test.ts +++ b/packages/daemon/src/server/http/http-server-proxy.test.ts @@ -3,7 +3,7 @@ import assert from 'node:assert/strict'; import crypto from 'node:crypto'; import http from 'node:http'; import { createDaemonProxyServer } from '@agent-device/proxy'; -import { createDaemonHttpServer } from '@agent-device/daemon/testing/server/http-server'; +import { createDaemonHttpServer } from './http-server.ts'; import { getRequestSignal } from '@agent-device/host-kit/request'; import { readHostCpuArch } from '@agent-device/host-kit/process'; import { executeRunScriptHttpRequest } from '@agent-device/maestro/run-script-http'; diff --git a/test/integration/provider-scenarios/daemon-http-resumable-upload.test.ts b/packages/daemon/src/server/http/http-server-resumable-upload.test.ts similarity index 95% rename from test/integration/provider-scenarios/daemon-http-resumable-upload.test.ts rename to packages/daemon/src/server/http/http-server-resumable-upload.test.ts index a94dea45a7..ffd3e4b47a 100644 --- a/test/integration/provider-scenarios/daemon-http-resumable-upload.test.ts +++ b/packages/daemon/src/server/http/http-server-resumable-upload.test.ts @@ -7,8 +7,8 @@ import { test } from 'vitest'; import { cleanupUploadedArtifact, prepareUploadedArtifact, -} from '@agent-device/daemon/testing/artifact-tracking'; -import { createDaemonHttpServer } from '@agent-device/daemon/testing/server/http-server'; +} from '../../resources/artifact-tracking.ts'; +import { createDaemonHttpServer } from './http-server.ts'; import { closeLoopbackServer, listenOnLoopback, diff --git a/test/integration/provider-scenarios/daemon-lifecycle.test.ts b/packages/daemon/src/server/http/server-lifecycle.test.ts similarity index 96% rename from test/integration/provider-scenarios/daemon-lifecycle.test.ts rename to packages/daemon/src/server/http/server-lifecycle.test.ts index 2abbfff01f..5c505ff137 100644 --- a/test/integration/provider-scenarios/daemon-lifecycle.test.ts +++ b/packages/daemon/src/server/http/server-lifecycle.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 { parseIntegerEnv } from '@agent-device/daemon/testing/server/server-lifecycle'; +import { parseIntegerEnv } from './server-lifecycle.ts'; import { tryAcquireDaemonRegistration } from '@agent-device/daemon-contracts/daemon-registration-owner'; import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution'; import { mkdtempForTestSync } from '@agent-device/test-kit/tmp-dir'; diff --git a/test/integration/provider-scenarios/daemon-transport.test.ts b/packages/daemon/src/server/http/transport.test.ts similarity index 97% rename from test/integration/provider-scenarios/daemon-transport.test.ts rename to packages/daemon/src/server/http/transport.test.ts index 3a51e5510c..7c12e8d9d6 100644 --- a/test/integration/provider-scenarios/daemon-transport.test.ts +++ b/packages/daemon/src/server/http/transport.test.ts @@ -1,14 +1,10 @@ -import type { DaemonRequest } from '@agent-device/daemon'; +import type { DaemonRequest } from '../../core/daemon-request.ts'; import type { DaemonResponse } from '@agent-device/kernel/contracts'; import assert from 'node:assert/strict'; import http from 'node:http'; import net from 'node:net'; import { test } from 'vitest'; -import { - createSocketServer, - listenHttpServer, - listenNetServer, -} from '@agent-device/daemon/testing/server/transport'; +import { createSocketServer, listenHttpServer, listenNetServer } from './transport.ts'; import { getRequestSignal } from '@agent-device/host-kit/request'; import { closeLoopbackServer, skipWhenLoopbackUnavailable } from '@agent-device/test-kit/loopback'; diff --git a/packages/daemon/tsconfig.json b/packages/daemon/tsconfig.json index 71114553ab..29a92493c5 100644 --- a/packages/daemon/tsconfig.json +++ b/packages/daemon/tsconfig.json @@ -50,6 +50,9 @@ { "path": "../platform-web" }, + { + "path": "../proxy" + }, { "path": "../replay-port" }, diff --git a/packages/test-kit/src/boundary-fault-matrix.ts b/packages/test-kit/src/boundary-fault-matrix.ts index c747da4584..8ce74ef7dd 100644 --- a/packages/test-kit/src/boundary-fault-matrix.ts +++ b/packages/test-kit/src/boundary-fault-matrix.ts @@ -78,22 +78,22 @@ export const BOUNDARY_FAULT_MATRIX = { cancellation: { mutation: { kind: 'covered', - evidence: ['test/integration/provider-scenarios/daemon-http-boundary-cancellation.test.ts'], + evidence: ['packages/daemon/src/server/http/http-server-boundary-cancellation.test.ts'], invariants: ['request-scoped-cancellation', 'request-signal-cleanup'], }, read: { kind: 'covered', - evidence: ['test/integration/provider-scenarios/daemon-http-boundary-cancellation.test.ts'], + evidence: ['packages/daemon/src/server/http/http-server-boundary-cancellation.test.ts'], invariants: ['request-scoped-cancellation', 'request-signal-cleanup'], }, 'artifact-producing': { kind: 'covered', - evidence: ['test/integration/provider-scenarios/daemon-http-boundary-cancellation.test.ts'], + evidence: ['packages/daemon/src/server/http/http-server-boundary-cancellation.test.ts'], invariants: ['request-scoped-cancellation', 'request-signal-cleanup'], }, 'session-lifecycle': { kind: 'covered', - evidence: ['test/integration/provider-scenarios/daemon-http-boundary-cancellation.test.ts'], + evidence: ['packages/daemon/src/server/http/http-server-boundary-cancellation.test.ts'], invariants: ['request-scoped-cancellation', 'request-signal-cleanup'], }, }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 72a443b3a2..9dea7d0e86 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -324,6 +324,9 @@ importers: '@agent-device/platform-web': specifier: workspace:* version: link:../platform-web + '@agent-device/proxy': + specifier: workspace:* + version: link:../proxy '@agent-device/replay-port': specifier: workspace:* version: link:../replay-port