Skip to content

Commit e0eda24

Browse files
committed
fix(contracts): keep daemon-http a leaf module
The client-side request refusal imported kernel/errors into daemon-http, which grew its eager import closure from 1 module to 3. The refusal now lives in daemon-client-rpc, which already loads kernel/errors, and daemon-http keeps only the limit constant. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
1 parent c4cf97c commit e0eda24

3 files changed

Lines changed: 20 additions & 17 deletions

File tree

‎packages/contracts/src/daemon-http.ts‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import path from 'node:path';
2-
import { AppError } from '@agent-device/kernel/errors';
32

43
// The daemon HTTP wire vocabulary shared by the daemon server, the remote
54
// proxy, and every client that talks to them: the base path, the tenant, lease
@@ -75,20 +74,6 @@ export const DAEMON_RPC_PROTOCOL_VERSION = 2;
7574
*/
7675
export const DAEMON_REQUEST_MAX_BYTES = 64 * 1024 * 1024;
7776

78-
/** Throws before sending a serialized request that no daemon transport would read. */
79-
export function refuseOversizedDaemonRequest(payload: string, requestId: string | undefined): void {
80-
const requestBytes = Buffer.byteLength(payload, 'utf8');
81-
if (requestBytes <= DAEMON_REQUEST_MAX_BYTES) return;
82-
throw new AppError('INVALID_ARGS', 'Daemon request exceeds the size limit', {
83-
reason: 'daemon_request_too_large',
84-
requestBytes,
85-
maxBytes: DAEMON_REQUEST_MAX_BYTES,
86-
requestId,
87-
daemonRequestSent: false,
88-
hint: 'Split the replay suite or flow into smaller runs.',
89-
});
90-
}
91-
9277
export const DAEMON_HTTP_INSTANCE_HEADER = 'x-agent-device-instance';
9378
export const DAEMON_HTTP_UPSTREAM_INSTANCE_HEADER = 'x-agent-device-upstream-instance';
9479
export const DAEMON_HTTP_INSTANCE_MISMATCH_HEADER = 'x-agent-device-instance-mismatch';

‎packages/daemon-client/src/daemon-client-rpc.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { createRequestId } from '@agent-device/host-kit/diagnostics';
1313
import { materializeRemoteArtifacts } from '@agent-device/remote/daemon-artifacts';
1414
import { localizeRemoteDaemonError } from '@agent-device/remote/remote-request-diagnostics';
1515
import type { DaemonInfo } from './daemon-client-metadata.ts';
16+
import { DAEMON_REQUEST_MAX_BYTES } from '@agent-device/contracts/daemon-http';
1617
import { buildDaemonRpcRequest, leaseScopeFromRequest } from '@agent-device/contracts/lease-scope';
1718

1819
export function handleDaemonHttpResponseBody(
@@ -192,3 +193,17 @@ export function buildHttpRpcPayload(
192193
includeTokenParam: options.includeTokenParam,
193194
});
194195
}
196+
197+
/** Throws before sending a serialized request that no daemon transport would read. */
198+
export function refuseOversizedDaemonRequest(payload: string, requestId: string | undefined): void {
199+
const requestBytes = Buffer.byteLength(payload, 'utf8');
200+
if (requestBytes <= DAEMON_REQUEST_MAX_BYTES) return;
201+
throw new AppError('INVALID_ARGS', 'Daemon request exceeds the size limit', {
202+
reason: 'daemon_request_too_large',
203+
requestBytes,
204+
maxBytes: DAEMON_REQUEST_MAX_BYTES,
205+
requestId,
206+
daemonRequestSent: false,
207+
hint: 'Split the replay suite or flow into smaller runs.',
208+
});
209+
}

‎packages/daemon-client/src/daemon-client-transport.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ import {
2121
DAEMON_HTTP_INSTANCE_MISMATCH_HEADER,
2222
DAEMON_HTTP_UPSTREAM_INSTANCE_HEADER,
2323
DAEMON_RPC_PROTOCOL_VERSION,
24-
refuseOversizedDaemonRequest,
2524
} from '@agent-device/contracts/daemon-http';
26-
import { buildHttpRpcPayload, handleDaemonHttpResponseBody } from './daemon-client-rpc.ts';
25+
import {
26+
buildHttpRpcPayload,
27+
handleDaemonHttpResponseBody,
28+
refuseOversizedDaemonRequest,
29+
} from './daemon-client-rpc.ts';
2730
import { handleRequestTimeout } from './daemon-client-timeout.ts';
2831
import { isRemoteDaemon, type DaemonInfo } from './daemon-client-metadata.ts';
2932
import type { HostEnvironment } from '@agent-device/kernel/source-value';

0 commit comments

Comments
 (0)