import * as pathModule from 'path'; /** * Pick the first operand that is an existing local file or directory. * * Adopts the natural `gsk aidrive upload ` bare operand as the upload * source when the caller gave neither `--local_file` nor `--file_content`. * Directories are accepted and expanded into stable relative file paths by * `collectUploadFiles` before each file is streamed. */ export declare function pickExistingUploadOperand(operands: readonly string[]): string | undefined; /** * Name the operands of `gsk drive upload []`. * The local source is `--local_file` or else the first operand that exists * on disk (none with `--file_content`); the destination is `--path`/`-p` or * the operand left over. Before this, a destination operand was dropped and * the file landed at the drive root. Anything ambiguous is refused, with * nothing sent: a second destination beside `--upload_path`, a stray * operand, a destination operand that also exists on this disk (which of * the two is the upload?), and a disk's root as the local source. A drive * spelling (`/mnt/aidrive/…`, `aidrive://…`) is never read off this disk: * in a sandbox the drive itself is mounted there. */ export declare function resolveAidriveUploadOperands(opts: { operands: readonly string[]; localFile?: string; inline: boolean; path?: string; uploadPath?: string; }): { localFile?: string; destination?: string; error?: string; }; /** * The destination operand that also exists on this disk, which makes it * unclear which of two is the upload. With the source adopted from the * operands, any operand on disk (but `/`) could be the upload; beside * --local_file or inline content, a file is suspect, and so is a folder * spelled as a local path (`./site`), while a folder like /tmp may well * name a drive folder. A drive spelling (`/mnt/aidrive/…`) is never read * off this disk: in a sandbox the drive itself is mounted there. */ export declare function operandOnDisk(operands: readonly string[], opts: { adopted: boolean; localFile?: string; }, probe?: { exists: (candidate: string) => boolean; isFile: (candidate: string) => boolean; }): string | undefined; /** Whether a local path is the root of its disk: `/`, or `C:\\` on Windows, * where `resolve('/')` is the drive root and a `=== '/'` test never matched. */ export declare function isDiskRoot(candidate: string, paths?: typeof pathModule): boolean; /** * A drive path as the upload endpoint takes it: `aidrive:///a/b`, the * sandbox mount `/mnt/aidrive/a/b` and `/aidrive/a/b` all mean `/a/b`, as * the tool lane reads them; the file lane stored them as literal folders. * A URL is refused: a Drive link names a folder through `--url`, not as a * path. So is a Windows drive path, which names this disk. */ export declare function normalizeUploadDestination(destination: string): { path?: string; error?: string; }; /** * Where an upload lands when its destination was an operand or `--path`: * the folder that receives it (created if missing), unless the last name is * the upload's own: the same name, or for a file one with the same * extension, which renames it (`/Reports/q3-final.pdf`). A trailing `/` * always means a folder. A last name with a different extension, or with * one when the file has none, is refused: read as a folder it became * `/Photos/beach.jpg/photo.jpeg`. The upload is named after its resolved * local path, so `..` cannot collapse the destination. */ export declare function uploadPathForDestination(destination: string, localPath: string, isDirectory: boolean): { uploadPath?: string; error?: string; }; /** * What is wrong with an upload's same-name answer, or '' when nothing: an * unknown `--on-conflict` (the server read one as rename, so a typo landed * a `name(1)` copy), and `--on-conflict overwrite` beside `--overwrite * false`. Inline content has no rename: a taken name is refused or replaced. */ export declare function uploadConflictProblem(conflict: { onConflict?: string; error?: string; }, args: Record, inline: boolean): string; export interface UploadFile { absolutePath: string; relativePath: string; } export declare function collectUploadFiles(root: string): UploadFile[]; /** Entry-id / URL addressing for the streaming upload lane (mirrors the * server's --id/--owner/--url on the aidrive tool: a folder id is the * destination base, upload_path is relative to it). */ export interface UploadLocator { id?: string; owner?: string; url?: string; } /** Query string for POST /api/tool_cli/aidrive/upload — exported so the * parameter contract is testable without streaming a file. */ export declare function buildAidriveUploadQuery(opts: { uploadPath: string; workspace: string; override?: boolean; onConflict?: string; source?: string; locator?: UploadLocator; }): URLSearchParams; /** How a same-name collision is answered on the streaming lane, from the * three spellings a caller may use: the tool schema's `--overwrite true` * (the one every prompt teaches), the CLI's older `--override` flag, and * `--on-conflict error|rename|overwrite`. Overwrite keeps the entry's id, * so its share link stays valid — the point of editing a file in place. * Two spellings that disagree are refused rather than silently ranked: * a renamed copy under a new id is exactly the outcome the caller was * trying to avoid. The lane never forwards tool args, so `--overwrite` * has to be read here. */ /** The lane's conflict answer read off what Commander parsed: `opts` holds * the CLI-only flags (`--override`, `--on-conflict`), `args` the tool * schema's (`--overwrite`, which Commander parses to a boolean). */ export declare function uploadConflictFromCli(opts: Record, args: Record): { onConflict?: string; error?: string; }; /** The share args an upload carries along (`--to`, `--general_access`, …), * or an empty object when the caller asked for no share. */ export declare function shareArgsFromUpload(args: Record): Record; /** Why `--to` / `--general_access` cannot ride this upload, or '' when * they can: the share verb the lane runs next is the My Drive one, so a * shared destination (a workspace other than My Drive, a `--source`, * which selects one whatever the workspace says, a folder id / URL, * which may be anyone's, or a shared drive's web address) is refused up * front — its sharing has its own verb and admin gate. A folder upload * has no single file to share. */ export declare function uploadShareRefusal(opts: { workspace: string; source?: string; addressedById?: boolean; isDirectory: boolean; uploadPath?: string; }): string; interface ToolReply { status: 'ok' | 'error'; message: string; data: unknown; session_state?: Record | null; } /** One reply for "uploaded, then shared": the share's human summary joins * the upload message (replacing the upload's "share it like so" hint, * which the share just did), and its structured answer rides in * `data.share`. A share failure keeps the upload result — the file is * there, so the reply stays `ok` (an `error` would send a retrying agent * back through the upload, landing a second copy) and `data.share.status` * plus the message say the sharing failed. A tool reply carries its * summary in `data.result` and the structured answer in * `session_state.aidrive_result`. */ export declare function mergeShareIntoUpload(upload: ToolReply, shared: ToolReply): ToolReply; export declare function resolveUploadConflict(opts: { override?: boolean; overwrite?: boolean; onConflict?: string; }): { onConflict?: string; error?: string; }; /** * Headers for the raw streaming AI Drive upload. This lane bypasses * ApiClient (it streams the file body itself), so it must pick the request * credential the same way: the per-turn `GSK_TURN_TOKEN` when present, else * the api key — `aidrive` is owner-gated, and without the turn credential a * parallel-turn sandbox would be denied as unattributable. */ export declare function aidriveUploadHeaders(opts: { apiKey?: string; projectId?: string; contentType: string; env?: NodeJS.ProcessEnv; }): Record; export {}; //# sourceMappingURL=aidrive-upload.d.ts.map