aboutsummaryrefslogtreecommitdiff
path: root/src/domains/files.ts
diff options
context:
space:
mode:
authoramankumarsingh77 <amankumarsingh7702@gmal.com>2026-05-02 21:59:30 +0530
committeramankumarsingh77 <amankumarsingh7702@gmal.com>2026-05-02 21:59:30 +0530
commita1df2d3e0998e99176a4bfe3cffb83b9e6a2377e (patch)
treef84522e4f08fd6adeaf4954e09fc6e43a59d02f7 /src/domains/files.ts
parentc9d1605b1e3b8dbe88cd3674a9256aa0465f3e6d (diff)
release: v0.3.1 — audit fixes for list_tabs IDs, switch_tab prefix matching, download auto-mkdir, session recovery, docs updates
Bug fixes: - list_tabs: show full 32-char targetIds (was truncated to 8 chars) - switch_tab: prefix matching fallback for hex prefixes >= 8 chars - download: auto-create directory with mkdir -p - ensureAlive: Runtime.evaluate probe to recover from crashed page targets Docs: - dispatch_key: clarify DOM-only event behavior - navigate: warn about Google anti-bot limitation - network_log: update deprecated promptSnippet - SKILL.md: document actual daemon API (evaluateJs, pageInfo, session.call) - SKILL.md: add troubleshooting for sharp/maxDim and Google navigation - sharp: add to optionalDependencies for screenshot maxDim auto-resize
Diffstat (limited to 'src/domains/files.ts')
-rw-r--r--src/domains/files.ts10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/domains/files.ts b/src/domains/files.ts
index f0cb6b0..91f8761 100644
--- a/src/domains/files.ts
+++ b/src/domains/files.ts
@@ -1,4 +1,4 @@
-import { access, constants, stat, readFile, writeFile } from "node:fs/promises";
+import { mkdir, access, constants, stat, readFile, writeFile } from "node:fs/promises";
import { basename } from "node:path";
import { Type } from "typebox";
import type { BrowserClient } from "../client";
@@ -136,6 +136,14 @@ export const downloadTool = defineBrowserTool({
parameters: DownloadArgs,
async handler(args, { client }): Promise<Result<ToolOk, ToolErr>> {
try {
+ await mkdir(args.downloadPath, { recursive: true });
+ } catch (e) {
+ return err({
+ kind: "io_error",
+ message: `Cannot create download directory: ${args.downloadPath} (${e instanceof Error ? e.message : String(e)})`,
+ });
+ }
+ try {
const s = await stat(args.downloadPath);
if (!s.isDirectory()) {
return err({ kind: "io_error", message: `Not a directory: ${args.downloadPath}` });