The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
fix(cli): a media target that is not a string is a bad request, not a TypeError
0xken15e7736e268fe6
diff --git a/cli/src/lib/mediaPreview.spec.ts b/cli/src/lib/mediaPreview.spec.tsindex a14c93bf6..4e36db19d 100644--- a/cli/src/lib/mediaPreview.spec.ts+++ b/cli/src/lib/mediaPreview.spec.ts@@ -55,6 +55,11 @@ describe('remote media preview reads', () => {expect(Buffer.from((await readMediaPreviewChunk(root, filename, 0)).contentBase64, 'base64')).toEqual(bytes)})+ it.each([123, {}, ['image.png'], true, null])('refuses a target that is not a string: %s', async (target) => {+ // The payload is whatever the client sent; a bad type is a refusal, never a raw TypeError.+ await expect(readMediaPreviewChunk(root, target as never, 0)).rejects.toThrow('MEDIA_INVALID_REQUEST')+ })+it('refuses an absolute path that lands outside every root', async () => {// A real media file the daemon can read, in a folder that is neither the workspace nor a temp one.const elsewhere = await mkdtemp(join(tmpdir(), 'harness-media-elsewhere-'))diff --git a/cli/src/lib/mediaPreview.ts b/cli/src/lib/mediaPreview.tsindex f66ca63b8..f0d79f190 100644--- a/cli/src/lib/mediaPreview.ts+++ b/cli/src/lib/mediaPreview.ts@@ -31,7 +31,9 @@ function fail(code: string): never { throw new MediaPreviewError(code) }* relative path is a promise about the workspace and is held to it, while an absolute one may name* an artifact the agent dropped elsewhere. Either way the promise is measured on the real path. */function resolveTarget(root: string, target: string): { path: string; workspaceOnly: boolean } {- if (!target || target.length > 4096 || /[\x00-\x1f\x7f]/.test(target)) fail('MEDIA_INVALID_REQUEST')+ // Typed as a string, but it arrives off the wire: a number or an object is a bad request, not a+ // TypeError thrown from whichever string method happens to be reached first.+ if (typeof target !== 'string' || !target || target.length > 4096 || /[\x00-\x1f\x7f]/.test(target)) fail('MEDIA_INVALID_REQUEST')let path = targetif (/^file:/i.test(path)) {try {