feat(sdk): export the client's option, result, and node types from the package root - #2959
Conversation
…e package root createAgentDeviceClient returned AgentDeviceClient, whose option and result types are all named in client-types.ts, but the root exported none of them. A consumer typed a client parameter as ReturnType<typeof createAgentDeviceClient>, a result as Awaited<ReturnType<...>>, and the nodes a snapshot returns by hand. The root now re-exports every client type, the kernel snapshot types a result is made of (SnapshotNode, RawSnapshotNode, SnapshotState, Rect, Point), and the error types normalizeAgentDeviceError answers in. Types only: the JavaScript entry is unchanged. The client example takes AgentDeviceClient and returns AgentDeviceDevice.
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="website/docs/docs/client-api.md">
<violation number="1" location="website/docs/docs/client-api.md:37">
P2: `sessions.artifacts()` returns `AgentArtifactsResult`, but the package root does not export that type, so the “every option and result type” claim points consumers to a nonexistent root import. Export `AgentArtifactsResult` from the root or narrow this documentation claim to the types actually exported.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
| - `createLocalArtifactAdapter(options?)` | ||
| - `AppError`, `isAgentDeviceError(error)`, `normalizeAgentDeviceError(error)` | ||
| - `centerOfRect(rect)` | ||
| - types: `AgentDeviceClient`, `AgentDeviceClientConfig`, and every option and result type of |
There was a problem hiding this comment.
P2: sessions.artifacts() returns AgentArtifactsResult, but the package root does not export that type, so the “every option and result type” claim points consumers to a nonexistent root import. Export AgentArtifactsResult from the root or narrow this documentation claim to the types actually exported.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At website/docs/docs/client-api.md, line 37:
<comment>`sessions.artifacts()` returns `AgentArtifactsResult`, but the package root does not export that type, so the “every option and result type” claim points consumers to a nonexistent root import. Export `AgentArtifactsResult` from the root or narrow this documentation claim to the types actually exported.</comment>
<file context>
@@ -34,6 +34,11 @@ Supported public entry points for Node consumers:
- `createLocalArtifactAdapter(options?)`
- `AppError`, `isAgentDeviceError(error)`, `normalizeAgentDeviceError(error)`
- `centerOfRect(rect)`
+ - types: `AgentDeviceClient`, `AgentDeviceClientConfig`, and every option and result type of
+ its methods (`AppOpenOptions`, `AppOpenResult`, `CaptureSnapshotOptions`,
+ `CaptureSnapshotResult`, `CaptureScreenshotResult`, `PressOptions`, `AgentDeviceDevice`, ...);
</file context>
…eads them The client-api drift guard reads an example's imports one statement at a time and strips a leading 'type ' only right after the brace, and it reads the doc's manifest one nested bullet line at a time. The example now imports the root types through an import type statement, and the manifest names each type on a line that starts with a bullet, AgentDeviceDevice included, instead of on the continuation lines of one bullet.
6e3de21 to
746d916
Compare
|
The code looks ready for human review at 6e3de21: the root re-exports the client's option, result, and node types with no naming collisions among the types it names. Not blocking: client-api.md's line saying the root exports "every option and result type" is wider than what's exported, since client-types.ts only All checks were still queued or in progress when I looked, so there's nothing to attribute yet; since this is a type-only export change plus one docs edit, the Typecheck & Package and command-docs-gate/client-api-examples-drift checks are the ones worth watching when they finish. I confirmed by reading client-types.ts, the contracts client-* type files, and kernel/snapshot.ts and errors.ts that every named type exists and no export name collides, but I didn't run pnpm build or check:production-exports, so the PR body's counts (68 unused-export warnings, 156 exported names) are unverified by me. I also didn't run client-api-examples-drift.test.ts or tsc -p examples/sdk, so the claim that those pass is unverified by me too. |
… import client-types.ts imports AgentArtifactsResult and CloudProviderSessionResult for its method signatures without re-exporting them, so the root wildcard could not reach them and the doc's 'every option and result type' was wider than the export. The root names them explicitly.
|
[claude-fable-5-1] responding on behalf of Oskar Thanks, taken in e13a949: |
|
Reviewed at e13a949.
I read the file contents at e13a949 and did not build the package; the type-only claim and re-export chain are confirmed by TypeScript module semantics, not a build artifact. I did not read every name in the 13-file, ~139-line facade — I spot-checked the ones whose names signal internal scope ( The Smoke Tests job is still in progress; the diff only touches Before merging, it would help to confirm with the author whether making |
The root's `export type *` chain reached `@agent-device/contracts/client`, which carried `InternalRequestOptions` and `CommandExecutionOptions`. Move both to `request-envelope.ts` under the command façade; the client façade keeps only `CommandRequestResult`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
createAgentDeviceClientreturnsAgentDeviceClient, and every option and result type of its methods is a named type insrc/client/client-types.ts, but the package root exported none of them. A consumer typed a client parameter asReturnType<typeof createAgentDeviceClient>, a result asAwaited<ReturnType<...>>, and re-declared the node shape a snapshot returns (the@e2edev/mobileengine carries its ownRawNode,RawSnapshot, andRawInstallResultfor that reason).The root now re-exports, types only:
client-types.ts(AgentDeviceClient,AgentDeviceClientConfig,AppOpenOptions,AppOpenResult,CaptureSnapshotResult,PressOptions,AgentDeviceDevice, ...);SnapshotNode,RawSnapshotNode,SnapshotState,Rect,Point;normalizeAgentDeviceErroranswers in:NormalizedError,AppErrorCode,KnownAppErrorCode,AppErrorDetails,ErrorCause.The JavaScript entry is unchanged.
examples/sdk/client-session.tstakesAgentDeviceClientand returnsAgentDeviceDeviceinstead of theReturnTypespelling, and the client API doc lists the type surface. 3 files.Validation
Tested at
e13a949920(third commit:AgentArtifactsResultandCloudProviderSessionResult, whichclient-types.tsimports for its signatures without re-exporting, are named at the root, so the doc's "every option and result type" holds;check:quick,pnpm build, and the client-api drift guard pass on it):pnpm check:affected --run --base c31cc49f6: all runnable checks passed (format, lint, typecheck, layering, fallow, build, related vitest, production exports, package gates).check:production-exportsreports 68 unused-export warnings, the same count as main without this change.dist/src/index.d.tsafterpnpm buildexports 156 names,AgentDeviceClient,AppOpenResult,SnapshotNode,RawSnapshotNode, andNormalizedErroramong them; the JavaScript bundle is byte-identical in what it exports.