Skip to content

Commit 794fe4b

Browse files
committed
refactor(host-kit): one narrow capability port per export
The four technical barrels (exec/fs/values/request) grouped by category rather than by capability, so a consumer needing one mechanic evaluated unrelated ones. Each export is now a single capability over the host machine: command, process, diagnostics, retry, archive, file, request, version. A port re-exports only what a consumer of that capability uses, and every port carries its own eager-closure row. Most of the old values barrel was never host mechanics. Pure record readers, config-source values, result text, memoization, async scoping, coordinate validation, and device-scope parsing touch no process, file, or environment, so they join kernel's other primitives instead. Closures fall accordingly: capture-kit's png-worker-client from 20 to 10, png-resize from 28 to 18, session-teardown from 79 to 68, and the CLI from 386 to 380. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018VngeKZH6zBuJzNBk5YzUH
1 parent 56039fe commit 794fe4b

436 files changed

Lines changed: 1250 additions & 835 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/adr/0019-request-bound-platform-runtime.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,18 @@ selection, R11/R13 package enumeration, and the composite typecheck project list
137137
> exports maps) forces every shared file onto a declared domain owner, and the paragraph above
138138
> is amended to name that layout rather than let capture-kit absorb it:
139139
>
140-
> - `@agent-device/host-kit` owns generic host mechanics — process execution, supervision, and
141-
> diagnostics; archives, streams, atomic files, locks, and path/device isolation; small host
142-
> value helpers; request-scoped plumbing — behind a small deep surface of exactly four seams:
143-
> `exec`, `fs`, `values`, `request`. Modules under `src/internal/` are reachable only through
144-
> those seams; consumers import a seam, never an internal module.
140+
> - `@agent-device/host-kit` owns mechanics that act on the host machine, and nothing else. Each
141+
> export is one narrow capability port, not a category barrel: `command` (running host
142+
> commands), `process` (observing and owning host processes), `diagnostics`, `retry`
143+
> (deadline/backoff/sleep), `archive` (bounded extraction and byte limits), `file` (atomic
144+
> publishes, locks, path resolution), `request` (request-scoped cancellation and progress),
145+
> and `version` (the installed version off disk). Modules under `src/internal/` are reachable
146+
> only through a port, and a port may only hold mechanics a consumer of that capability
147+
> needs — the eager-closure row per port is what keeps that honest.
148+
> - A helper that touches no process, file, or environment is not host mechanics and does not
149+
> belong here: pure record readers, config-source values, result text, memoization, async
150+
> scoping, coordinate validation, and device-scope parsing live in `@agent-device/kernel`
151+
> beside its other primitives.
145152
> - `@agent-device/capture-kit` owns capture, snapshot, and recording behavior — PNG tooling,
146153
> screenshot density and pixel diffing, snapshot occlusion, mobile snapshot semantics,
147154
> quality verdicts and backend capability tables. Snapshot *behavior* is capture domain, not

packages/capture-kit/src/png-worker-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Worker } from 'node:worker_threads';
2-
import { emitDiagnostic } from '@agent-device/host-kit/exec';
2+
import { emitDiagnostic } from '@agent-device/host-kit/diagnostics';
33
import { AppError, toAppErrorCode } from '@agent-device/kernel/errors';
44
import { resolveInternalEntryModulePath } from './internal-entry.ts';
55
import { decodePng, PNG } from './png.ts';

packages/host-kit/package.json

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.0",
44
"private": true,
55
"type": "module",
6-
"description": "Private generic host mechanics behind four deep seams: process execution and supervision (exec), filesystem and archive guards (fs), pure value helpers (values), and request-scoped plumbing (request). Internal workspace package bundled into the published agent-device artifact.",
6+
"description": "Private host-mechanics package: each export is one narrow capability port over the host machine \u2014 running commands, observing and owning processes, diagnostics, retry/deadline, archive extraction, durable files and locks, request-scoped plumbing, and the installed version.",
77
"dependencies": {
88
"@agent-device/contracts": "workspace:*",
99
"@agent-device/kernel": "workspace:*",
@@ -15,21 +15,37 @@
1515
"@types/yauzl": "^3.4.0"
1616
},
1717
"exports": {
18-
"./exec": {
19-
"types": "./src/exec.ts",
20-
"default": "./src/exec.ts"
18+
"./archive": {
19+
"types": "./src/archive.ts",
20+
"default": "./src/archive.ts"
2121
},
22-
"./fs": {
23-
"types": "./src/fs.ts",
24-
"default": "./src/fs.ts"
22+
"./command": {
23+
"types": "./src/command.ts",
24+
"default": "./src/command.ts"
25+
},
26+
"./diagnostics": {
27+
"types": "./src/diagnostics.ts",
28+
"default": "./src/diagnostics.ts"
29+
},
30+
"./file": {
31+
"types": "./src/file.ts",
32+
"default": "./src/file.ts"
33+
},
34+
"./process": {
35+
"types": "./src/process.ts",
36+
"default": "./src/process.ts"
2537
},
2638
"./request": {
2739
"types": "./src/request.ts",
2840
"default": "./src/request.ts"
2941
},
30-
"./values": {
31-
"types": "./src/values.ts",
32-
"default": "./src/values.ts"
42+
"./retry": {
43+
"types": "./src/retry.ts",
44+
"default": "./src/retry.ts"
45+
},
46+
"./version": {
47+
"types": "./src/version.ts",
48+
"default": "./src/version.ts"
3349
}
3450
}
3551
}

packages/host-kit/src/archive.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export { archiveTypeFromPath, extractArchiveSafely } from './internal/archive-extraction.ts';
2+
export { ArchiveBudget, type ArchiveManifestEntry } from './internal/archive-safety.ts';
3+
export { MAX_ARTIFACT_COMPRESSED_BYTES } from './internal/artifact-limits.ts';
4+
export { createByteLimitStream } from './internal/byte-limit-stream.ts';

packages/host-kit/src/command.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export {
2+
coerceExecResult,
3+
type CommandExecutorOverride,
4+
type ExecBackgroundOptions,
5+
type ExecBackgroundResult,
6+
type ExecDetachedExit,
7+
execFailureDetails,
8+
type ExecOptions,
9+
type ExecResult,
10+
isExecutablePath,
11+
requireExecSuccess,
12+
resolveExecutableOverridePath,
13+
resolveFileOverridePath,
14+
runCmd,
15+
runCmdBackground,
16+
runCmdDetached,
17+
runCmdDetachedMonitored,
18+
runCmdStreaming,
19+
runCmdSync,
20+
whichCmd,
21+
withCommandExecutorOverride,
22+
withoutCommandExecutorOverride,
23+
} from './internal/exec.ts';
24+
export { shellQuote, shellQuoteIfNeeded } from './internal/shell-quote.ts';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export {
2+
countDiagnosticEventsByPhase,
3+
createRequestId,
4+
emitDiagnostic,
5+
flushDiagnosticsToSessionFile,
6+
getDiagnosticsMeta,
7+
registerDiagnosticSensitiveValue,
8+
updateDiagnosticsScope,
9+
withDiagnosticsScope,
10+
withDiagnosticTimer,
11+
} from './internal/diagnostics.ts';

packages/host-kit/src/exec.ts

Lines changed: 0 additions & 77 deletions
This file was deleted.

packages/host-kit/src/file.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export {
2+
isAtomicPublishTemporaryPath,
3+
publishFileSync,
4+
withAtomicPublishTempPathSync,
5+
} from './internal/atomic-file.ts';
6+
export { expandUserHomePath, resolveUserPath } from './internal/path-resolution.ts';
7+
export { acquireProcessLock, type ProcessLockOwner } from './internal/process-lock.ts';

packages/host-kit/src/fs.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

packages/host-kit/src/internal/env-map.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)