> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tuturuuu.com/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI Drive commands

> Upload files and inspect read-only workspace Drive metadata from ttr using short-lived scoped Drive sessions

Use `ttr drive` to upload local files and inspect directory listings or object
metadata in Tuturuuu Drive with your signed-in operator CLI session.

## Commands

```bash theme={null}
ttr drive upload <local-file> --workspace <wsId> [--path <folder>] [--name <name>] [--json]
ttr drive list --workspace <wsId> [--path <folder>] [--search <query>] [--limit <n>] [--offset <n>] [--sort-by name|created_at|updated_at|size] [--sort-order asc|desc] [--json]
ttr drive stat <path> --workspace <wsId> [--json]
```

Use `internal` for the root workspace, `personal` for your personal workspace,
or a workspace UUID.

### Upload

* Streams the local file to the workspace's configured storage provider through
  the signed upload intent flow (`upload-url` → `PUT` → `finalize-upload`).
* Enforces the same 100 MB file-size limit and allowed-type rules as the Drive
  UI, verifies the server-side stored size on finalization, and prints
  `{ path, size, sha256 }` with `--json`.
* Creates no public or signed share link. Uploaded files inherit normal
  workspace Drive permissions only; Wiki pages can reference them via the
  per-request share redirect `/api/v1/workspaces/<wsId>/storage/share?path=<path>`.

### Read-only inspection

* `ttr drive list` lists files and folders under `--path` (or the Drive root).
* `ttr drive stat <path>` returns `{ path, size, contentType, updatedAt, provider }`
  for a single Drive object without generating a download link.

## Scoped Drive session security model

Raw CLI sessions (`target_app: "platform"`, `cli:access`) are refused directly
on every workspace storage route (`upload-url`, `finalize-upload`, `list`,
`stat`, `share`, `object`, `move`, `rename`, `folders`, `analytics`).

Instead, each `ttr drive` invocation exchanges the operator's CLI session at
`POST /api/v1/workspaces/<wsId>/storage/cli-session` for a short-lived
`drive`-target app session:

| Control | Behavior |
| - | - |
| Target app | `drive`, without the broad `internal-app:session` scope so it cannot be used on general Drive, satellite, or account endpoints. Any `origin_app: "cli"` bearer is refused outside this scoped path and never falls through to browser Drive auth. |
| Parent session check | Issuance verifies the parent `private.cli_sessions` row is registered, unrevoked, and unexpired (`401` if missing/revoked; `503` fail-closed if unavailable). |
| Workspace scope | Bound to a single normalized workspace UUID (`workspace_id`); using it on another or unresolvable workspace returns HTTP `403`. |
| Operation scope | Bound to the requested subset of `drive:storage:upload`, `drive:storage:list`, and `drive:storage:stat`; out-of-scope operations return HTTP `403`. |
| Lifetime | Default 5 minutes, hard ceiling 15 minutes (900 seconds), clamped to `min(now + ttl, parent CLI exp)` at issuance and enforced at verification. `ttr drive upload` mints a fresh short-lived session before `finalize-upload` so slow large uploads do not fail at finalization. |
| Permissions & limits | Issuance and every storage route require live `manage_drive` permission on the target workspace, check account suspension (fail-closed), enforce fail-closed per-user rate limits on issuance, upload, and read (`list`/`stat`) routes, and block private/reserved roots and finance transaction namespaces. |
| Token handling | Held in memory only for the command; never written to disk, never printed to stdout/stderr, and never sent to third-party storage provider URLs. |
| Audit | Records `private.storage_access_events` (`sign` on `cli-session`, `upload` on `upload-url`/`finalize-upload`, `list` on `list`/`stat`) and structured native `console.info('[audit] drive.cli', ...)` entries for both `allowed` and `denied` outcomes using distinct ops (`session_issue`, `upload_intent`, `upload_finalized`, `list`, `stat`) with actor, workspace, target app, path, verified size, and `clientSha256` (client-reported; never tokens). |

## Regression coverage

* `packages/auth/src/cli-drive-session.test.ts`
* `apps/web/src/app/api/v1/workspaces/[wsId]/storage/cli-session/route.test.ts`
* `apps/web/src/app/api/v1/workspaces/[wsId]/storage/drive-upload-auth.test.ts`
* `apps/web/src/app/api/v1/workspaces/[wsId]/storage/stat/route.test.ts`
* `packages/sdk/src/cli/drive.test.ts`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.