@adelin-io/cli 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -2
- package/authoring-release.json +174 -0
- package/package.json +30 -4
- package/runtime-integrity.json +9 -0
- package/scripts/adelin.mjs +7768 -0
- package/scripts/assemble-checkout.mjs +93 -0
- package/scripts/local-save.mjs +513 -0
- package/scripts/materialize.mjs +319 -0
- package/scripts/runtime.mjs +8950 -0
- package/scripts/typecheck.mjs +72 -0
- package/scripts/workspace-state.mjs +183 -0
- package/skill/README.md +77 -0
- package/skill/SKILL.md +100 -0
- package/skill/authoring/access.md +193 -0
- package/skill/authoring/analytics.md +20 -0
- package/skill/authoring/app-memory.md +128 -0
- package/skill/authoring/app-requirements.md +99 -0
- package/skill/authoring/app-structure.md +265 -0
- package/skill/authoring/assets.md +117 -0
- package/skill/authoring/auth.md +263 -0
- package/skill/authoring/content-binding.md +26 -0
- package/skill/authoring/i18n.md +184 -0
- package/skill/authoring/language.md +503 -0
- package/skill/authoring/local-workflow.md +1667 -0
- package/skill/authoring/offline/connectivity.md +50 -0
- package/skill/authoring/offline/example.md +102 -0
- package/skill/authoring/offline/history-sync.md +39 -0
- package/skill/authoring/offline/index.md +29 -0
- package/skill/authoring/offline/package-storage.md +37 -0
- package/skill/authoring/offline/platforms.md +35 -0
- package/skill/authoring/offline/startup-navigation.md +53 -0
- package/skill/authoring/platform-files.md +616 -0
- package/skill/authoring/player/casting.md +47 -0
- package/skill/authoring/player/controls.md +95 -0
- package/skill/authoring/player/downloads.md +90 -0
- package/skill/authoring/player/drm.md +31 -0
- package/skill/authoring/player/index.md +39 -0
- package/skill/authoring/player/live-dvr.md +74 -0
- package/skill/authoring/player/platforms.md +47 -0
- package/skill/authoring/player/playback.md +43 -0
- package/skill/authoring/player/tracks-subtitles.md +32 -0
- package/skill/authoring/profiles.md +213 -0
- package/skill/authoring/remote-keys.md +139 -0
- package/skill/authoring/search.md +27 -0
- package/skill/authoring/store.md +85 -0
- package/skill/authoring/tv-text-entry.md +146 -0
- package/skill/design/approved/README.md +14 -0
- package/skill/design/approved/vesper-phone-home.jpg +0 -0
- package/skill/design/approved/vesper-tv-detail.jpg +0 -0
- package/skill/design/approved/vesper-tv-home.jpg +0 -0
- package/skill/design/design-guide.md +610 -0
- package/skill/design/edge-to-edge.md +66 -0
- package/skill/design/icons.md +50 -0
- package/skill/design/responsive-layout.md +175 -0
- package/skill/design/safe-area.md +221 -0
- package/skill/design/streaming-playbook.md +131 -0
- package/skill/design/visual-review.md +150 -0
- package/skill/examples/README.md +24 -0
- package/skill/examples/cinema/DESIGN.md +58 -0
- package/skill/examples/cinema/app.tsx +17 -0
- package/skill/examples/cinema/assets/logo.png +0 -0
- package/skill/examples/cinema/components/Action.tsx +40 -0
- package/skill/examples/cinema/components/Action.tv.tsx +44 -0
- package/skill/examples/cinema/components/CatalogGrid.tsx +31 -0
- package/skill/examples/cinema/components/ContinueRail.tsx +98 -0
- package/skill/examples/cinema/components/Feedback.tsx +28 -0
- package/skill/examples/cinema/components/Field.tsx +41 -0
- package/skill/examples/cinema/components/LibraryRail.tsx +46 -0
- package/skill/examples/cinema/components/PlayAction.tsx +29 -0
- package/skill/examples/cinema/components/Root.tsx +59 -0
- package/skill/examples/cinema/components/Shell.tsx +70 -0
- package/skill/examples/cinema/components/Tab.tsx +22 -0
- package/skill/examples/cinema/components/TitleCard.tsx +68 -0
- package/skill/examples/cinema/components/TitleMeta.tsx +36 -0
- package/skill/examples/cinema/locales/en.ts +211 -0
- package/skill/examples/cinema/locales/lt.ts +211 -0
- package/skill/examples/cinema/preview/phone-home.jpg +0 -0
- package/skill/examples/cinema/preview/tv-detail.jpg +0 -0
- package/skill/examples/cinema/preview/tv-home.jpg +0 -0
- package/skill/examples/cinema/screens/portrait/Account.tsx +110 -0
- package/skill/examples/cinema/screens/portrait/Browse.tsx +73 -0
- package/skill/examples/cinema/screens/portrait/Detail.tsx +159 -0
- package/skill/examples/cinema/screens/portrait/Home.tsx +196 -0
- package/skill/examples/cinema/screens/portrait/Player.tsx +299 -0
- package/skill/examples/cinema/screens/portrait/Search.tsx +46 -0
- package/skill/examples/cinema/screens/portrait/Search.tv.tsx +55 -0
- package/skill/examples/cinema/screens/portrait/SignIn.tsx +101 -0
- package/skill/examples/cinema/screens/portrait/SignUp.tsx +106 -0
- package/skill/examples/cinema/store.tsx +132 -0
- package/skill/examples/cinema/theme.ts +32 -0
- package/skill/examples/documentary/DESIGN.md +33 -0
- package/skill/examples/documentary/app.tsx +17 -0
- package/skill/examples/documentary/components/Action.tsx +43 -0
- package/skill/examples/documentary/components/CatalogGrid.tsx +47 -0
- package/skill/examples/documentary/components/Feedback.tsx +27 -0
- package/skill/examples/documentary/components/Field.tsx +33 -0
- package/skill/examples/documentary/components/LibraryRail.tsx +47 -0
- package/skill/examples/documentary/components/Root.tsx +62 -0
- package/skill/examples/documentary/components/Shell.tsx +93 -0
- package/skill/examples/documentary/components/StoryCard.tsx +53 -0
- package/skill/examples/documentary/components/StoryMeta.tsx +22 -0
- package/skill/examples/documentary/preview/phone-home.jpg +0 -0
- package/skill/examples/documentary/preview/tv-detail.jpg +0 -0
- package/skill/examples/documentary/preview/tv-home.jpg +0 -0
- package/skill/examples/documentary/screens/portrait/Account.tsx +97 -0
- package/skill/examples/documentary/screens/portrait/Browse.tsx +71 -0
- package/skill/examples/documentary/screens/portrait/Detail.tsx +133 -0
- package/skill/examples/documentary/screens/portrait/Home.tsx +89 -0
- package/skill/examples/documentary/screens/portrait/Player.tsx +116 -0
- package/skill/examples/documentary/screens/portrait/Search.tsx +48 -0
- package/skill/examples/documentary/screens/portrait/SignIn.tsx +96 -0
- package/skill/examples/documentary/screens/portrait/SignUp.tsx +101 -0
- package/skill/examples/documentary/store.tsx +115 -0
- package/skill/examples/documentary/theme.ts +20 -0
- package/skill/examples/series/DESIGN.md +55 -0
- package/skill/examples/series/app.tsx +17 -0
- package/skill/examples/series/components/Action.tsx +42 -0
- package/skill/examples/series/components/CatalogGrid.tsx +43 -0
- package/skill/examples/series/components/ContinueRail.tsx +78 -0
- package/skill/examples/series/components/Feedback.tsx +26 -0
- package/skill/examples/series/components/Field.tsx +34 -0
- package/skill/examples/series/components/LibraryRail.tsx +38 -0
- package/skill/examples/series/components/OutcomeNote.tsx +28 -0
- package/skill/examples/series/components/PlayAction.tsx +29 -0
- package/skill/examples/series/components/RestoreAction.tsx +33 -0
- package/skill/examples/series/components/Root.tsx +75 -0
- package/skill/examples/series/components/SaveTitle.tsx +34 -0
- package/skill/examples/series/components/Shell.tsx +75 -0
- package/skill/examples/series/components/TitleCard.tsx +62 -0
- package/skill/examples/series/components/UnlockAction.tsx +10 -0
- package/skill/examples/series/preview/phone-home.jpg +0 -0
- package/skill/examples/series/preview/tv-detail.jpg +0 -0
- package/skill/examples/series/preview/tv-home.jpg +0 -0
- package/skill/examples/series/screens/portrait/Account.tsx +125 -0
- package/skill/examples/series/screens/portrait/Browse.tsx +61 -0
- package/skill/examples/series/screens/portrait/Detail.tsx +231 -0
- package/skill/examples/series/screens/portrait/Home.tsx +109 -0
- package/skill/examples/series/screens/portrait/MyList.tsx +44 -0
- package/skill/examples/series/screens/portrait/Plans.tsx +131 -0
- package/skill/examples/series/screens/portrait/Player.tsx +138 -0
- package/skill/examples/series/screens/portrait/Profiles.tsx +103 -0
- package/skill/examples/series/screens/portrait/Search.tsx +50 -0
- package/skill/examples/series/screens/portrait/SignIn.tsx +94 -0
- package/skill/examples/series/screens/portrait/SignUp.tsx +100 -0
- package/skill/examples/series/store.tsx +192 -0
- package/skill/examples/series/theme.ts +32 -0
- package/skill/guides/final-pricing-capabilities.md +13 -0
- package/skill/reference/api.md +842 -0
- package/skill/reference/components.md +1782 -0
- package/skill/reference/packages.md +24 -0
- package/skill/scripts/assemble-checkout.mjs +93 -0
- package/skill/scripts/local-save.mjs +513 -0
- package/skill/scripts/materialize.mjs +319 -0
- package/skill/scripts/workspace-state.mjs +183 -0
- package/types/adelin-access.d.ts +70 -0
- package/types/adelin-analytics.d.ts +5 -0
- package/types/adelin-assets.d.ts +26 -0
- package/types/adelin-auth.d.ts +37 -0
- package/types/adelin-content.d.ts +120 -0
- package/types/adelin-device.d.ts +195 -0
- package/types/adelin-downloads.d.ts +47 -0
- package/types/adelin-env.d.ts +8 -0
- package/types/adelin-globals.d.ts +19 -0
- package/types/adelin-i18n.d.ts +31 -0
- package/types/adelin-native-stack.d.ts +178 -0
- package/types/adelin-navigation.d.ts +264 -0
- package/types/adelin-profiles.d.ts +51 -0
- package/types/adelin-react.d.ts +49 -0
- package/types/adelin-reanimated.d.ts +376 -0
- package/types/adelin-storage.d.ts +9 -0
- package/types/adelin-store.d.ts +74 -0
- package/types/adelin-ui.d.ts +1518 -0
- package/types/adelin-utils.d.ts +7 -0
- package/types/adelin-worklets.d.ts +15 -0
- package/workspace-tsconfig.json +53 -0
|
@@ -0,0 +1,1667 @@
|
|
|
1
|
+
# Local app workspace
|
|
2
|
+
|
|
3
|
+
The builder installs the Adelin CLI and runs `adelin setup` in the coding project. Setup links this entire skill folder to the CLI-owned release. The CLI owns browser sign-in, the local MCP connection, file transfer, and advisory TypeScript checking. Use that single local `adelin` MCP connection. Never request an OAuth token, build ticket, source bundle, or credential from the builder.
|
|
4
|
+
|
|
5
|
+
## Current guidance and project setup
|
|
6
|
+
|
|
7
|
+
Call `refresh_generation_context` before authoring and whenever a tool returns `GENERATION_CONTEXT_CHANGED`. Read its current entrypoint and the guides relevant to the task, even if an earlier conversation message contains older guidance. Read the returned project instructions too. Retrieving a new revision does not discard the builder's requirements or unsaved app edits.
|
|
8
|
+
|
|
9
|
+
On `UPDATE_REQUIRED`, allow the CLI to update, or run `adelin update` if automatic installation is disabled. When an update notice requests project repair, run `adelin setup` in that project or worktree. Reconcile an interrupted app save through its original operation before refreshing its support files; an ordinary media upload can keep running during repair. Setup remembers its coding clients, verifies the skill link and MCP configuration, and refreshes registered workspaces' managed types and compiler settings. A new worktree needs its own local setup. Report the update notice briefly; never claim setup succeeded after a conflict or pending-save refusal. Refresh generation context again after repair before continuing to author.
|
|
10
|
+
|
|
11
|
+
An older MCP connection that lacks `refresh_generation_context`, or reports `HOST_UPDATE_REQUIRED`, needs a coding-client reconnect after updating and running setup. Preserve app edits, pending journals, and background upload workers. Routine compatible runtime updates retain the existing edit session and preview.
|
|
12
|
+
|
|
13
|
+
The linked `SKILL.md` and its guides are shared CLI-owned content. Keep project-specific additions in the project's optional `.adelin/instructions.md`, or its existing user-owned instruction files. Do not append to or edit the linked skill. Preserve existing instructions when repairing setup.
|
|
14
|
+
|
|
15
|
+
The CLI supplies `adelin-*.d.ts` and compiler configuration. Fix authored app code against the current declarations and diagnostics; do not edit those support files to hide an error. If a save is pending, reconcile its original operation before refreshing support or starting another save. An update does not justify closing and reopening an active edit session, deleting its journal, or resetting the preview.
|
|
16
|
+
|
|
17
|
+
## Sign-in and credentials
|
|
18
|
+
|
|
19
|
+
The CLI stores sign-in per user in `adelin/auth.json` under the user config directory: `XDG_CONFIG_HOME` when set, otherwise `~/.config` on macOS and Linux; Windows uses `APPDATA`. The file and its directory have owner-only permissions. Separate `XDG_CONFIG_HOME` directories separate local sessions on macOS and Linux. Never read or print this file for an agent.
|
|
20
|
+
|
|
21
|
+
The CLI and background upload workers on the same host serialize every sign-in save, logout and token refresh through an exclusive loopback listener keyed by the canonical credential path. The listener exchanges no credential data, and the operating system releases it when its process exits or crashes. A second process reuses the rotated credential; logout waits for an active refresh, then removes only that server's sign-in so the refresh cannot recreate it. Another credential operation or an unrelated service occupying the same local port causes a wait with a 30-second deadline before a retry refusal. A loopback permission failure also refuses the operation without changing stored credentials.
|
|
22
|
+
|
|
23
|
+
Local byte transfers and live-key access require a native loopback connection requesting `local-transfer` and `live-credentials`. The sign-in page names the unverified requester and offers separate unchecked approvals for private file transfers and saving live keys locally. A client name never authenticates its publisher. Live-key approval requires local-transfer approval and a selected app with `live.manage`. These approvals belong to the current account, client and grant; removing or expiring consent denies subsequent sensitive actions. Existing development connections need a fresh `adelin login` to request these approvals.
|
|
24
|
+
|
|
25
|
+
`adelin logout` revokes the current connection and removes its local sign-in. `adelin logout --local-only` removes only the local sign-in; it does not revoke the app grant. Revoking the connection in account settings ends its app grants. Follow [private local output](#private-local-output) for deliberately written credential files, their handling and rotation.
|
|
26
|
+
|
|
27
|
+
## Choose and open an app
|
|
28
|
+
|
|
29
|
+
Sign in once for the account and explicitly approve the apps this connection can read and edit. Consent starts with no apps selected; connecting with zero apps is valid. Use Settings → Connected code agents → Manage apps to remove app access. Adding an app or capability requires a new login and explicit consent. Each connection has its own explicit capability snapshot. Gaining account permissions never widens an old connection. If permissions change during consent, login starts a fresh bound interaction with new PKCE and state; review and approve again. Current account permissions still apply, and new apps are never selected automatically.
|
|
30
|
+
|
|
31
|
+
Call `list_editable_apps` (`limit` 1–25, default 10, and `nextCursor` as `cursor`) or `select_app(app_id)` to choose an allowed app. `select_app` returns `app` or `APP_NOT_EDITABLE`. Arguments outside a tool's input schema, on any tool, return `{ok:false,error:{code:"INVALID_ARGUMENT",message}}` with `isError: true` and change nothing. The message names the first wrong field and what was expected, for example `mode is not accepted for entry.patch` or `payload.patch.title: expected string`, and never repeats the value sent; correct that field and call again. The `library_mutate` description lists each action's payload and which actions accept `mode`. Create apps in the dashboard, then enable them for this connection in Settings before opening them. App creation is unavailable through the public coding tools.
|
|
32
|
+
|
|
33
|
+
Call `open_app(app_id, workspace)` with an absolute or project-relative folder for local source. For a new workspace, the CLI transfers an authenticated checkout directly, verifies its chunks and app identity, and installs the files into an empty destination. For an existing workspace, it validates the app identity and reuses the files, base versions and pending journal. Reopening does not refresh or overwrite local edits. It opens the one edit session for that app and returns bounded outcomes without source bytes or lease credentials. If the builder has the app open in App Creator with an idle chat, opening it hands the app to you, and App Creator shows your work while you have it. An occupied app returns `conflict` with a retry time and a message naming who holds it (a chat reply in progress, another person, another agent); do not open a second editor to bypass it.
|
|
34
|
+
|
|
35
|
+
For content inspection without editing, use the bounded library reads below. A library-only account can approve `library.view` without `ai.manage`, open_app, a checkout or an edit lease. Do not use `list_editable_apps` as a library eligibility test. Supply the explicitly approved app ID on each call; editing selection does not supply it implicitly.
|
|
36
|
+
|
|
37
|
+
For opening, resuming, recording progress and correcting working context, follow the
|
|
38
|
+
[shared app-memory guide](app-memory.md). `open_app` returns fresh accepted requirements
|
|
39
|
+
and working memory even when reusing the local workspace. Use `read_app_requirements`,
|
|
40
|
+
`update_app_requirements`, `read_app_memory` and `mutate_app_memory` through the same
|
|
41
|
+
CLI-owned MCP connection; the CLI supplies current editing-session authority for writes.
|
|
42
|
+
|
|
43
|
+
## Check and build
|
|
44
|
+
|
|
45
|
+
In a local workspace, shared screens use `screens/Name.tsx`; distinct landscape screens use `screens/landscape/Name.tsx`. The `portrait` storage label is handled by the CLI. A local `screens/portrait/` directory is refused when building.
|
|
46
|
+
|
|
47
|
+
To publish HTML/CSS design concepts as hosted artifacts, follow
|
|
48
|
+
[publishing from a local agent](../design/design-guide.md#publishing-from-a-local-agent) before editing app code.
|
|
49
|
+
|
|
50
|
+
Edit authored files in the workspace. Call `check_app` for an advisory TypeScript check. It does not compile descriptors, save, or prove a server build. The installed CLI also offers `adelin check <workspace> <app-id>` for a terminal check.
|
|
51
|
+
|
|
52
|
+
Call `build_app` with no file arguments when the builder wants to save and preview. The CLI reads the app-bound manifest and sends Adelin only file hashes and sizes. It then uploads the changed authored files once to short-lived private storage named by the server, and the server queues the build for the next free compiler. It returns bounded outcomes and diagnostics. Upload URLs and credentials are handled by the CLI; never show them, ask the builder or agent to copy them, or reuse them. Every build client goes through the shared server queue, and source never enters the queue. If capacity is unavailable, the build returns rejected/not-saved outcomes with a retry hint; preserve local edits and wait before an explicit retry. Local checks are advisory and cannot prove that compilation will pass. A build accepts 1–50 changed files, up to 300000 characters per file and 1 MiB total source. A successful build activates the committed app preview directly; there is no separate file approval or rejection step. Its result includes `previewUrl`, the app's always-on preview address: it shows the latest working draft to people the builder has given access and updates in place after each build. Share that address with the builder rather than building one yourself. Publishing snapshots that committed preview. A persisted file advances its local base only after verified activation. Saved shared screens keep the same relative imports and workspace path as checkout. Rejected, stale, or locally changed files keep prior bases and local bytes.
|
|
53
|
+
|
|
54
|
+
Rate limits can refuse a request before the build is queued, even when compiler capacity is available. Preserve local edits and wait for the server's retry hint; do not create another session or account to bypass it. A temporarily unavailable service may need at least 65 seconds after a restart before accepting signed requests. For an interrupted build, reconcile before retrying. Never copy credentials or manually replay a captured signed request.
|
|
55
|
+
|
|
56
|
+
The CLI keeps a private pending journal until the result settles. After an interrupted build or `reconcile_required`, call `reconcile_build` before another build. A `terminal` receipt settles the prior operation; reconciliation can recover an activation whose response was lost. `receipt_absent` permits retry of the same operation only under its original current session. `retryable` means the prior operation was fenced: reopen under fresh authority and call `retry_build` only if the authoritative heads still match the submitted bases. A divergent head is an explicit conflict to resolve; never silently rebase or delete the journal.
|
|
57
|
+
|
|
58
|
+
`retry_build` refreshes the heartbeat and reconciles again before sending. A fenced retry atomically creates one replacement operation while retaining the exact previously submitted source. Newer unsaved local edits remain intact and belong to a later build. A lost response does not prove failure or permission to submit a duplicate. A successful compiler outcome means compilation finished; only the verified activation and receipt prove the save. Busy, unavailable, deadline, cancellation and stale outcomes do not prove activation.
|
|
59
|
+
|
|
60
|
+
## The builder can watch
|
|
61
|
+
|
|
62
|
+
While an app is open, the dashboard shows the session live to the builder and to teammates who can view the app. Adelin itself records each step it can see: opening the app, reading content, and each build with its saved and rejected screens. Do not report these steps separately.
|
|
63
|
+
|
|
64
|
+
Call `tell_builder(message)` at most once per step for what you are doing now, in one plain line of up to 140 characters, for example "Making the posters bigger, like you asked." Each call replaces the previous line. Never include file names, code, tool names, error text or anything from the private terminal conversation.
|
|
65
|
+
|
|
66
|
+
### Check the preview
|
|
67
|
+
|
|
68
|
+
After a build that saved files, the `preview_*` tools work at once on the browser preview of the open app, as the [visual review guide](../design/visual-review.md#inspect-what-viewers-get) describes. Pass `target` for another size or TV vendor. The first browser check may download a headless browser once when the machine has no Chrome or Edge, and says so. Fix what you find, build again and check again. Tell the builder what you checked with `tell_builder`.
|
|
69
|
+
|
|
70
|
+
The preview browser runs headless on the builder's computer from `open_app` until `close_app`; it never opens a window. When the builder wants to see or steer the preview, call `show_agent_view`. If App Creator is open on this computer, the builder already watches that same browser there and nothing new opens. Otherwise it opens a local page in the builder's default browser. That page's link grants full control, so the tool never returns it; if no page opened, tell the builder the link is in the Adelin MCP server's log. Their own clicks, scrolls and typing pause your next preview action, and Alt/Option-clicks reach you as "The builder pointed at:" lines; handle both as the [visual review guide](../design/visual-review.md#when-the-builder-shares-the-preview) says.
|
|
71
|
+
|
|
72
|
+
`request_device` is only for a check on a real cloud TV or phone. Call `request_device(platform)` with `tv` or `phone` and an optional one-line reason. The builder answers in the dashboard and can choose a cloud TV, a cloud phone or not now; cloud devices use their preview minutes. The call waits up to 45 seconds for an answer, then until the started device responds. If it returns `waiting` or `starting`, call `wait_for_device` with its `request_id`; `ended` means the builder turned the device off. Ask once per round of fixes, not before every build. When the answer is `ready`, the `preview_*` tools run on that device until it ends. A device action refused with "No device is running" means the builder ended the device test or it ran out of minutes; continue on the browser preview and do not ask for a device again in the same round.
|
|
73
|
+
|
|
74
|
+
The builder can stop the session from the dashboard, or take the app back in App Creator. Either ends the lease, so the next heartbeat reports `lease_lost` and later builds are refused. Keep local edits, stop working on the app, and ask in the terminal before reopening it.
|
|
75
|
+
|
|
76
|
+
## Session lifecycle
|
|
77
|
+
|
|
78
|
+
Removing an app stops later reads, saves and receipt recovery through this connection. If removal commits before activation, the save cannot activate. A save committed before removal stays saved, and subsequent work is denied. Cached tokens, delegations and old receipts never restore permission. Keep local source files and the pending journal when access is denied; review access in Settings before retrying. Revoke connection in Settings to end all app access for that connection while leaving dashboard access and other connections available.
|
|
79
|
+
|
|
80
|
+
The CLI renews the edit lease every 15 seconds while the workspace is open. A build keeps it active. Ten minutes without a source edit or build releases the lease even if the coding client remains open. Use `build_status` to inspect it and `close_app` when finished. A 65-second replay-store recovery pause can outlast the 60-second edit lease. Preserve the journal and edits, wait for signed requests to become available, then reopen and reconcile. A disconnected session can reopen directly; close other existing session states before reopening. Retry requires an active current session. The CLI's authorization is tied to the current account, app, and edit lease; signing out or revoking the connection stops later requests.
|
|
81
|
+
|
|
82
|
+
A newly created app can open as an empty local workspace with type declarations and project metadata. Author its screens, root component and app configuration before building. Checkout does not create a saved draft or make an empty app renderable; the first successful activated build does.
|
|
83
|
+
|
|
84
|
+
A saved `store.tsx` remains a workspace file even when it contains no slices. Keep it with the app's other root files when building or checking out the app.
|
|
85
|
+
|
|
86
|
+
If a first build fails and its receipt is abandoned, reconciliation can confirm that the app is still empty and allow a retry under a fresh edit session. Keep the pending journal: the retry preserves its exact submitted source. Files staged by a failed build are not activated files. An unavailable or changing draft remains unconfirmed; waiting or reopening alone does not resolve compiler diagnostics.
|
|
87
|
+
|
|
88
|
+
If compiler errors leave the first app incomplete, the build rejects all files after confirming that none were activated. Files that passed compilation explain that the incomplete app prevented activation. Local source stays intact. Reconcile an interrupted response, correct the diagnostics, then build the complete app again; the CLI settles the failed journal through its normal receipt handling.
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
A completed build can save some files and reject others. Reconciliation settles that as a mixed result: keep the saved files at their confirmed versions, fix the rejected files and build again. Before activating files, Adelin durably records compiler rejection reasons for that save. Reconciliation returns those original reasons for files proven unactivated, without recompiling or resending them. Older interrupted saves may lack retained diagnostics; if the receipt says they are unavailable, check the rejected source again. Do not clear the journal or resend files whose save is still unconfirmed.
|
|
92
|
+
|
|
93
|
+
File versions are allocated by the server. Failed attempts can leave gaps, so version 3 does not mean a file was successfully saved three times. Use the confirmed version returned by build or reconciliation, rather than counting attempts.
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
## Recovery
|
|
97
|
+
|
|
98
|
+
- [Interrupted builds and lost responses](#check-and-build)
|
|
99
|
+
- [Stale previews and combined-save recovery](#combined-save-and-recovery)
|
|
100
|
+
- [Re-consent and current app access](#choose-and-open-an-app)
|
|
101
|
+
- [Publishing revisions and retries](#revisions-retries-and-recovery)
|
|
102
|
+
- [Upload resume](#parts-resume-and-the-48-hour-window)
|
|
103
|
+
- [Busy or blocked sample imports](#sample-content-import)
|
|
104
|
+
- [Revoked access and session recovery](#session-lifecycle)
|
|
105
|
+
- [Entry file receipts and recovery](#receipts-retries-and-recovery)
|
|
106
|
+
- [Live conflicts and recovery](#conflicts-retries-and-recovery)
|
|
107
|
+
|
|
108
|
+
## Bounded library reads
|
|
109
|
+
|
|
110
|
+
Use the existing `adelin login` flow and explicitly approve the app and `library.view` capability. Current `library.view` permission is checked on every page. Manage permission never implies view permission, and a token or cursor never replaces current authority. Every CLI command requires `--app UUID`; every local MCP call requires `app_id: UUID`. Commands carry no server URL: the released CLI always talks to Adelin's server, and a development build of the CLI targets a local server and also accepts `--url`. Do not supply an actor, grant or credential in read arguments.
|
|
111
|
+
|
|
112
|
+
| CLI syntax | Local MCP operation | Result |
|
|
113
|
+
|---|---|---|
|
|
114
|
+
| `adelin library schema --app UUID --section fields` | `library_schema` | Binding definitions; section is fields (default), labels, technicalFields or languages |
|
|
115
|
+
| `adelin library tree --app UUID --section rows` | `library_tree` | Ordered hierarchy and ancestor context; section is rows (default), labels or tabCounts |
|
|
116
|
+
| `adelin library entry --app UUID --entry UUID` | `library_entry` | Entry core, revision and five section descriptors |
|
|
117
|
+
| `adelin library entry-section --app UUID --entry UUID --section contents` | `library_entry_section` | One independently paged section: contents, subtitles, fieldValues, audioTracks or pendingChangedKeys (staged keys with their published values) |
|
|
118
|
+
| `adelin library labels --app UUID` | `library_labels` | Label IDs, binding keys, names and usage |
|
|
119
|
+
| `adelin library fields --app UUID` | `library_fields` | Custom field IDs, keys, names, types and usage |
|
|
120
|
+
| `adelin library publish-candidates --app UUID --entry UUID` | `library_publish_candidates` | A folder's direct children with publish and schedule readiness |
|
|
121
|
+
| `adelin library collections --app UUID` | `library_collections` | Every curated collection in dashboard order with its path and counts |
|
|
122
|
+
| `adelin library collection --app UUID --collection UUID --section members` | `library_collection` | One collection; section is members (default) or children |
|
|
123
|
+
|
|
124
|
+
MCP uses `entry_id`, `section`, `limit` and `cursor` for the corresponding CLI flags, and each tool's input schema lists exactly the arguments it accepts. The tree always covers the whole library; to look inside one folder, page its `contents` section with `library_entry_section`, the direct children the dashboard's entry sheet lists. Tree also accepts `--media all|video|audio|live` (`media`), one `--label KEY` (`label`), `--status published|draft|pending|scheduled` (`status`) and `--search TEXT` (`q`, trimmed, at most 256 Unicode code points). Collections accept `--search TEXT` (`q`, at most 200 characters) and `--media all|video|audio`; collection takes `--collection UUID` (`collection_id`). Unknown arguments, duplicate scalar flags and invalid values fail. The existing server `get_content_schema` operation remains available through the shared schema workflow. `adelin --help`, `adelin library --help` and `adelin library tree --help` show command syntax.
|
|
125
|
+
|
|
126
|
+
Except entry, each command returns one page: `--limit N` / `limit` defaults to 50 and accepts 1 through 100. A successful page has `data.section`, `data.items` and `data.page` with limit, returned, total, nextCursor and snapshot. Use `nextCursor` explicitly with identical app, operation, filters, section and limit; stop when it is null. No hidden all-pages mode exists. A cursor is at most 2048 characters and expires after 900 seconds; restart or key rotation invalidates it. `INVALID_CURSOR` means restart from the first page. `STALE_CURSOR` means discard accumulated pages and restart against the changed library.
|
|
127
|
+
|
|
128
|
+
Entry core returns `data.entry`, `data.revision` and descriptors for contents, subtitles, fieldValues, audioTracks and pendingChangedKeys. Fetch large sections separately and compare their snapshot with the core revision; restart if revisions differ. Empty or nonapplicable sections return an empty page. Do not combine pages from different revisions.
|
|
129
|
+
|
|
130
|
+
Titles, descriptions and the names of labels, fields, sub-fields and collections are language maps in every read, such as `{"en": "Opening night", "lt": "Premjeros vakaras"}`. [Languages](#languages) explains them.
|
|
131
|
+
|
|
132
|
+
How file fields read on a published entry is described under Entry files.
|
|
133
|
+
|
|
134
|
+
A page stops adding rows once its JSON envelope would pass 32768 UTF-8 bytes (32 KiB), so a page fits a coding client's tool-output limit; about 45 tree rows fit. `returned` is then below `limit` while `nextCursor` is set: keep paging. Publish candidates page by `limit` alone. A page always carries at least one row, the complete envelope is limited to 262144 bytes (256 KiB), and each indivisible row or entry core to 65536 bytes (64 KiB). Each collection permits at most 5000 rows, and projected snapshots at most 8388608 bytes (8 MiB). Oversized items fail with `READ_ITEM_TOO_LARGE`; tree or snapshot overflow uses `LIBRARY_TREE_TOO_LARGE` or `READ_SNAPSHOT_TOO_LARGE`, never silent truncation. Transport responses are capped at 4194304 bytes with a 30-second deadline and at most one authentication refresh.
|
|
135
|
+
|
|
136
|
+
The CLI writes exactly one JSON envelope and newline to stdout: `{ok:true,operation,appId,data}` with exit 0, or `{ok:false,error:{code,message}}` with exit 1. Help is text with exit 0. MCP returns the same JSON in one text block and `isError: !ok`. Errors do not include raw remote text, credentials or internal diagnostics. `AUTH_REQUIRED` requires login; `ACCESS_DENIED` requires reviewing current app access; `RECONSENT_REQUIRED` requires fresh explicit capability approval. `APP_SELECTION_CHANGED` requires a new login interaction, and `INTERACTION_COMPLETED` means an old approval cannot be replayed. `NOT_FOUND` does not distinguish missing from foreign objects. Correct `INVALID_ARGUMENT` input; do not blindly retry size, stale-state or permission errors.
|
|
137
|
+
|
|
138
|
+
## Sample content import
|
|
139
|
+
|
|
140
|
+
Sample content is imported only when an app is created and is never re-imported. These commands inspect or resume that creation-time import; they never start an import, reset it or change categories. An app without an import returns `none:true` and explains that sample content is added only when the app is created. Viewing requires `library.view`; advancing requires `library.manage` and its current explicit consent.
|
|
141
|
+
|
|
142
|
+
Prepared sample entries publish automatically when their category finishes importing. While media or artwork is still being prepared, entries stay draft. A completed import does not republish entries the builder later returns to draft or restore deleted content; owner-controlled pending changes, schedules and skipped resources remain untouched.
|
|
143
|
+
|
|
144
|
+
Status lists each import's `importId`, categories, completed categories and state (`saving`, `awaiting_resources` or `complete`), plus saved/total/missing entries, ready/total/failed artwork and media, and admitted/total playback. `skipped:{artwork,media,playback}` counts owner-controlled work preserved during advance; these resources are never counted as ready or admitted. `stalled:true` means incomplete with no live resource lease. `busyUntil` means another advancer holds a lease; `next` is `advance`, `wait` or `none`. Failure details contain at most 20 safe `{stage,code,at}` records ordered by actual failure time, newest first. Status is read-only. Advance preserves edited, published or removed owner content, records conflicting attachments as skipped and continues healthy work without resetting or reimporting.
|
|
145
|
+
|
|
146
|
+
```sh
|
|
147
|
+
adelin library sample-import --app 33333333-3333-4333-8333-333333333333
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
```json
|
|
151
|
+
{"app_id":"33333333-3333-4333-8333-333333333333"}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
The paired local tool is `library_sample_import`. Resume an existing import with `library_sample_import_advance` or:
|
|
155
|
+
|
|
156
|
+
```sh
|
|
157
|
+
adelin library sample-import-advance --app 33333333-3333-4333-8333-333333333333 --import 44444444-4444-4444-8444-444444444444 --max-steps 20 --wait-seconds 60
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
```json
|
|
161
|
+
{"app_id":"33333333-3333-4333-8333-333333333333","import_id":"44444444-4444-4444-8444-444444444444","max_steps":20,"wait_seconds":60}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Both clients use one bounded loop: `max_steps` is 1–50 (default 20), `wait_seconds` is 0–120 (default 60). Each step makes one remote batch call. The remote tools `get_library_sample_import` and `mutate_library_sample_import` take only `{app_id}` and `{app_id, import_id}` respectively; local loop bounds never reach them. A busy lease is retried only after its expiry and within the wait budget. Conflict, temporary mutation failures and ingress throttling honor their retry delay in full; a delay beyond the budget stops the loop without another call.
|
|
165
|
+
|
|
166
|
+
The result carries the last `import`, `steps`, `stopReason` and `refresh:{operation:"library tree"}`. Stop reasons are `complete`, `blocked`, `busy`, `media_unavailable`, `budget` and `no_progress`. Two consecutive sample-media failures stop with `media_unavailable`; retry that existing import later. At a budget or no-progress stop, inspect status before deciding to resume. If an owner change occurs during an attachment step, advance reconciles its skipped disposition and returns current progress; resume the same import. Review skipped counts before treating the sample catalogue as fully populated. `SAMPLE_CATALOGUE_CHANGED` means the immutable catalogue differs: preserve saved content and stop. Access, missing-import and invalid-argument refusals stop immediately and require correction; no new import is created.
|
|
167
|
+
|
|
168
|
+
After progress, refresh with `adelin library tree --app UUID` or `library_tree`. Read all pages; on `STALE_CURSOR`, restart paging from the beginning. Imported items are drafts and can be published after the import completes.
|
|
169
|
+
|
|
170
|
+
## Private local output
|
|
171
|
+
|
|
172
|
+
Library reads return metadata and IDs, never file bytes, signed URLs, grants or live credentials. Do not turn IDs into guessed URLs or log authentication material.
|
|
173
|
+
|
|
174
|
+
`adelin library files get` and `library_files_get` write one artwork or subtitle file privately; see Private retrieval under Entry files.
|
|
175
|
+
|
|
176
|
+
Broadcast credentials (the RTMPS address and stream key, and the SRT address, stream id and passphrase) are written only by the Adelin CLI, never shown in an agent tool result, the terminal or a log. `adelin live credentials` and `adelin live reset` each write one new owner-only file (mode 0600) into `--out DIR` and print `{ok, written, path, kind, entryId}`, plus `operationId`, `outcome` and `warningCode` for a reset; give the user the printed `path`, never the file's content. `DIR` must be a directory only you can open: a missing one is created with mode 0700, while one others can read, a symlink anywhere in its path or an existing file with the same name is refused with `PRIVATE_OUTPUT_REFUSED` before anything is sent. Each call makes a new reply key, so only that CLI process can open the reply. The local MCP tool `live_credentials` always refuses with `LIVE_CREDENTIALS_CLI_ONLY` and names the command to run. The CLI sign-in must approve an app with `live.manage` and the separate permission to save live stream keys; without it both commands give `ACCESS_DENIED`.
|
|
177
|
+
|
|
178
|
+
`live_preview` and `adelin live preview --operation-id UUID` require an explicit operation id and current live management and sign-in authority. They return a private playback address (`hlsUrl`), `sessionId` and expiry (`expiresAt`, at most 60 seconds, possibly shorter). A preview uses finite LIVE delivery funding and may refuse with a `BILLING_` code. Treat the address as a secret: open it only in a player, never paste it into a chat, file or log. Retry a lost reply with the identical request and operation id; use a new id for a new preview. An expired preview cannot be extended.
|
|
179
|
+
|
|
180
|
+
## Library mutations at a glance
|
|
181
|
+
|
|
182
|
+
Every edit goes through `adelin library mutate` (CLI) or the `library_mutate` MCP tool with the same closed request: `{app_id, operation_id, expected_revision, action, payload, mode?, confirmation?, resumes_operation_id?}`. The CLI accepts simple flags for small edits, or `--input FILE` holding exactly that JSON object; MCP takes the same object as arguments. `adelin library mutate --help` lists every action and flag.
|
|
183
|
+
|
|
184
|
+
Two revisions exist. A read's `data.revision` identifies that read snapshot and binds its cursors. `data.mutationRevision` is the app-wide library revision: pass it as `expected_revision`. Any library change in the app, including an unrelated dashboard edit, advances it, so a stale value returns `CONFLICT` or `STALE_PREVIEW` instead of overwriting newer work.
|
|
185
|
+
|
|
186
|
+
| Action | Payload | Confirmation |
|
|
187
|
+
|---|---|---|
|
|
188
|
+
| `entry.create` | `{kind, mediaType, title, description?, parentId?}` | none |
|
|
189
|
+
| `entry.patch` | `{entry_id, patch: {title?, description?}}` | none |
|
|
190
|
+
| `entry.move` | `{entry_id, parent_id, position}` | none |
|
|
191
|
+
| `folder.replace` | `{folder_id, child_ids}` | preview + every page |
|
|
192
|
+
| `entry.delete` | `{entry_id}` | preview + every page |
|
|
193
|
+
| `label.create` | `{name, choice?}` | none |
|
|
194
|
+
| `label.rename` | `{key, name}` | none |
|
|
195
|
+
| `entry.label.set` / `entry.label.clear` | `{entry_id, label}` / `{entry_id}` | none |
|
|
196
|
+
| `field.create` / `field.rename` | `{name, typeSpec, choice?}` / `{key, name?, typeSpec?}` | none |
|
|
197
|
+
| `field.delete` | `{key}` | preview; blocked while used |
|
|
198
|
+
| `field.localized` | `{key, prop?, localized}` | preview + confirmation when turning translatable off |
|
|
199
|
+
| `entry.fields.patch` | `{entry_id, set?, clear?}` | none |
|
|
200
|
+
| `app.languages.set` | `{locales}` | preview + confirmation when a language is removed |
|
|
201
|
+
| `entry.save` | `{entry_id \| create, metadata?, assets?, label?, fields?, move?, replace?}` | whole-save preview when `replace` is present |
|
|
202
|
+
| `entry.publish` | `{entry_id, child_ids?}` | none |
|
|
203
|
+
| `entry.schedule` / `entry.schedule.cancel` | `{entry_id, at, child_ids?}` / `{entry_id}` | none |
|
|
204
|
+
| `entry.discard` | `{entry_id}` | preview + every page |
|
|
205
|
+
| `entry.draft` | `{entry_id}` | preview + every page |
|
|
206
|
+
| `entry.assets` | `{entry_id, main?, trailer?}` | none to attach or replace; preview + confirmation when a role is `null` (detach) |
|
|
207
|
+
| `entry.artwork.remove` | `{entry_id, slot, language?}` | preview + confirmation |
|
|
208
|
+
| `entry.subtitle.remove` | `{entry_id, file_id}` | preview + confirmation |
|
|
209
|
+
| `entry.subtitle.language` | `{entry_id, file_id, language}` | none |
|
|
210
|
+
| `collection.create` | `{name, note?, parent_id?, entry_ids?}` | none |
|
|
211
|
+
| `collection.update` | `{collection_id, name?, note?, parent_id?}` | none |
|
|
212
|
+
| `collection.delete` | `{collection_id}` | preview + every page |
|
|
213
|
+
| `collection.members.replace` | `{collection_id, entry_ids}` | preview + every page |
|
|
214
|
+
| `collection.members.add` | `{collection_id, entry_ids}` | none |
|
|
215
|
+
| `collection.members.remove` | `{collection_id, entry_ids}` | preview + every page |
|
|
216
|
+
| `preview.page` | `{app_id, action, preview_id, cursor}` only | read-only |
|
|
217
|
+
| `operation.inspect` | `{app_id, action, target_operation_id}` only | read-only |
|
|
218
|
+
|
|
219
|
+
A combined save as a CLI JSON file (`adelin library mutate --input save.json`) or identical `library_mutate` arguments:
|
|
220
|
+
|
|
221
|
+
```json
|
|
222
|
+
{
|
|
223
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
224
|
+
"operation_id": "2f1e0d9c-8b7a-4c6d-9e5f-4a3b2c1d0e9f",
|
|
225
|
+
"expected_revision": "42",
|
|
226
|
+
"action": "entry.save",
|
|
227
|
+
"payload": {
|
|
228
|
+
"entry_id": "5c4b3a29-1807-4f6e-8d5c-4b3a29180716",
|
|
229
|
+
"metadata": { "title": { "en": "Opening night" } },
|
|
230
|
+
"label": { "key": "premieres" },
|
|
231
|
+
"fields": { "set": { "running_minutes": 0 }, "clear": ["rating_note"] },
|
|
232
|
+
"move": { "parent_id": "9e8d7c6b-5a49-4382-a716-05f4e3d2c1b0", "position": 0 }
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
The entry file actions `entry.assets`, `entry.artwork.remove`, `entry.subtitle.remove` and `entry.subtitle.language`, with their CLI flags, are described under Entry files.
|
|
238
|
+
|
|
239
|
+
Success returns a short change summary with `affectedIds` (or `entryId` for saves) and the new `mutationRevision`; read commands give full detail. Failures use a fixed code: `CONFLICT`, `STALE_PREVIEW`, `CONFIRMATION_REQUIRED`, `NAME_CHOICE_REQUIRED`, `UNKNOWN_FIELD`, `INVALID_FIELD_VALUE`, `FIELD_IN_USE`, `FOLDER_NOT_EMPTY`, `LIVE_LIFECYCLE_REQUIRED`, `CHILD_NOT_ELIGIBLE`, `SCHEDULED_CHILDREN_UNLISTED`, `CHILDREN_NOT_ALLOWED`, `MAIN_NOT_PLAYABLE`, `ASSET_NOT_FOUND`, `ASSET_UNAVAILABLE`, `ASSET_KIND`, `ASSET_FAILED`, `SUBTITLE_LANGUAGE_EXISTS`, `TITLE_MISSING`, `NOT_FOLDER`, `NOT_DRAFT`, `SCHEDULE_ZONE_REQUIRED`, `SCHEDULE_ZONE_INVALID`, `SCHEDULE_TIME_NONEXISTENT`, `SCHEDULE_TIME_AMBIGUOUS`, `SCHEDULE_INVALID`, `SCHEDULE_NOT_ACTIVE`, `DUPLICATE_ENTRY`, `NOT_MEMBER`, `LIMIT_EXCEEDED`, `CYCLE`, `OPERATION_PAYLOAD_CONFLICT`, `OPERATION_SUPERSEDED`, `RETRYABLE_CONFLICT`, `MUTATION_UNAVAILABLE`, `INVALID_ARGUMENT`, `ACCESS_DENIED` or `NOT_FOUND`. Retry only `RETRYABLE_CONFLICT`, `MUTATION_UNAVAILABLE` and lost responses, and only with the identical request and operation ID; correct or re-read for everything else. Local test success never certifies hosted storage, live providers or devices.
|
|
240
|
+
|
|
241
|
+
## Create and edit library metadata
|
|
242
|
+
|
|
243
|
+
Approve both `library.view` and `library.manage` for the app. Read `data.mutationRevision` first, then use a new UUID as the operation ID. `adelin library mutate --app UUID --operation-id UUID --expected-revision REV --action entry.create --kind item --media-type video --title "Title" --language en` creates a draft. `--title` and `--description` set the one language `--language TAG` names, and a new entry needs a title in at least one app language. Supported pairs are item/video, item/audio, item/live and folder with no media type. Creating a live record does not provision an origin. Optional `--parent UUID` appends the new record using the canonical folder rules. `--description TEXT` sets its description.
|
|
244
|
+
|
|
245
|
+
For an existing record, use `--action entry.patch --entry UUID --language TAG` with `--title TEXT`, `--description TEXT`, or both; other languages keep their text. Omission preserves the value. An empty value removes that language's text. Published edits are staged. Kind and media type are immutable; patches do not move records, assign files, publish, or create labels or fields.
|
|
246
|
+
|
|
247
|
+
`library_mutate` accepts `{app_id, operation_id, expected_revision, action, payload}`. Create payloads use `{kind, mediaType, title, description?, parentId?}`; folders use `mediaType: null`. Patch payloads use `{entry_id, patch: {title?, description?}}`. `title` and `description` are language maps: a patch changes only the languages it names, and `null` removes one, as in `{"description": {"lt": null}}`. CLI `--input FILE` accepts the same complete request in a bounded regular JSON file and cannot be combined with editorial flags. In each language, titles trim whitespace and allow 1–300 UTF-16 code units; descriptions preserve whitespace and allow up to 5000.
|
|
248
|
+
|
|
249
|
+
Keep the original normalized request and operation ID when a response is lost. A replay returns the original saved identity and committed revision, even after later edits; it is not a current-state read. Distinct operation IDs may create equal titles. A `CONFLICT` commits no work for that attempt and reports the current revision and bounded state for review. A conflict on one entry (`entry.patch`, `entry.move`, `entry.delete`, `folder.replace`, `entry.label.set`, `entry.label.clear` or `entry.fields.patch`) returns `latestState: {id, title, status, description, reference, sections}`: `reference` holds the `library_entry` arguments and `sections` names the `library_entry_section` sections to page explicitly. Create, label and field-definition conflicts, and a target that no longer exists, return `{app_id}` for a fresh tree read. Do not silently resubmit using a newer revision. Replay still requires current authority.
|
|
250
|
+
|
|
251
|
+
Library hierarchy edits use `library mutate` / `library_mutate` with a current
|
|
252
|
+
`expected_revision` and a durable `operation_id`. `entry.move` takes `entry_id`,
|
|
253
|
+
`parent_id` (null for the root), and a zero-based `position`. `folder.replace`
|
|
254
|
+
takes `folder_id` and ordered `child_ids` (at most 1000); omitted children move to
|
|
255
|
+
the root according to canonical draft/published staging rules.
|
|
256
|
+
|
|
257
|
+
For `folder.replace` or `entry.delete` (`entry_id`), first send the complete
|
|
258
|
+
request with `mode: "preview"`. Read every returned page using
|
|
259
|
+
`{app_id, action: "preview.page", preview_id, cursor}`. Only the final page
|
|
260
|
+
contains `acknowledgement`. Commit the identical operation and payload with
|
|
261
|
+
`confirmation: {preview_id, digest, acknowledgement}` from that preview. In the
|
|
262
|
+
CLI, put the full request in an `--input` file, or keep the flags and pass
|
|
263
|
+
`--confirmation-file FILE` holding exactly that confirmation object. A boolean
|
|
264
|
+
cannot confirm a mutation.
|
|
265
|
+
Previews expire after 900 seconds; any same-app library revision change requires
|
|
266
|
+
a fresh preview. Pages are bound to this connection and include ordered hierarchy
|
|
267
|
+
changes, staged references, retained-upload counts and cleanup counts. They include affected entries, explicit targets and requested members, and their relevant parent/reference context; unrelated unchanged entries are omitted. No affected set is truncated.
|
|
268
|
+
|
|
269
|
+
Deleting a nonempty folder is refused. Provisioned live origins require live
|
|
270
|
+
lifecycle management and cannot be deleted through this operation. Uploads remain
|
|
271
|
+
retained. When a successful delete reports `cleanup.state: "pending"`, retry the
|
|
272
|
+
same `entry.delete` operation and payload to resume its remaining artwork/subtitle
|
|
273
|
+
cleanup; do not issue a new delete. Every retry requires current access. The
|
|
274
|
+
response exposes counts, never private object keys.
|
|
275
|
+
|
|
276
|
+
Library vocabulary uses `library mutate` / `library_mutate` with the same operation ID and expected revision as other edits. `label.create` takes `{name, choice?}`, where `name` is a language map holding at least one app language. `label.rename` takes `{key, name}` and changes only the languages `name` lists. `entry.label.set` takes `{entry_id, label: {key} | {name, choice?} | null}`; `entry.label.clear` takes `{entry_id}`. Keys and near-duplicate checks use the display name, the first app language in order that has one, and exact normalized names reuse their saved identity. `NAME_CHOICE_REQUIRED` returns bounded candidates: choose an existing key explicitly, or submit the original name with `choice: "create-distinct"`. No candidate is automatically selected.
|
|
277
|
+
|
|
278
|
+
`field.create` requires `{name, typeSpec, choice?}` using the declared canonical type. `field.rename` takes `{key, name?, typeSpec?}` and preserves key/type: `name` changes only the languages it lists, and `typeSpec` may change only sub-field names; exact or similar conflicts cannot merge definitions. Use an existing field key for value edits instead. `entry.fields.patch` takes `{entry_id, set?, clear?}`. Omitted keys remain unchanged; set and clear cannot overlap. Unknown keys require explicit typed creation. Explicit null/empty text/empty lists follow canonical unset normalization; zero and false remain values. Published edits stage over the effective pending map.
|
|
279
|
+
|
|
280
|
+
`field.delete` takes `{key}` and requires preview then confirmation, with `preview.page` for remaining usage pages. `FIELD_IN_USE` includes exact distinct-entry usageCount and current/pending flags, without an executable acknowledgement. Both stored current and pending values must be clear; a pending clear does not erase a published stored value. Existing dashboard publication/discard workflows may be needed before a new deletion preview can succeed. No force or value cascade is available. Simple vocabulary options include `--name` (with `--language`), `--key`, `--choice`, `--type-spec` (JSON), and `--prop` and `--localized` for `field.localized`; use `--input` for typed patches and confirmation. Translatable fields are under [Languages](#languages).
|
|
281
|
+
|
|
282
|
+
### Combined save and recovery
|
|
283
|
+
|
|
284
|
+
Use `entry.save` with the same mutation envelope and a payload containing either `entry_id` or `create` (the individual create payload). Optional steps are `metadata` (the metadata patch), `assets` (`main` and/or `trailer` asset UUIDs; it attaches or replaces only, and a `null` role is refused with `payload.assets.main: detach with entry.assets`, so detach with `entry.assets`), `label` (existing key, explicit name choice, or null), `fields` (`set`/`clear`), `move` (`parent_id`/`position`), and `replace` (exact ordered child IDs). Creation already supplies metadata; do not combine `create` with `metadata`. Field definitions must exist first. Execution order is create/metadata, assets, label, typed values, move, replacement; omitted steps do nothing. The same individual parsers, validators and transactions apply.
|
|
285
|
+
|
|
286
|
+
If `replace` is present, preview the **whole save** with `mode: "preview"` before any effect. Traverse all pages, including the proposed created identity, save steps and affected hierarchy, then confirm using the final page acknowledgement. The confirmation binds the whole original payload. Metadata and label creation also remain untouched until confirmation. An expired unstarted or stale preview needs a fresh preview.
|
|
287
|
+
|
|
288
|
+
Each committed step survives later failure. Results include `entryId`, `completedSteps`, `failedStep`, `remainingSteps`, `mutationRevision`, and the current authorized `latestState`. When the `assets` step attached media that is not playable yet, the result and its inspection also carry the `entry.assets` `warnings` with `ASSET_NOT_PLAYABLE`; a stop at the `assets` step names the asset refusal in `error`. Stop on the first error; do not assume whole-save rollback. Retry a transient stop or lost response using the **identical original request**, including original revision and confirmation, and the same operation ID. Progress resumes at the first incomplete step. Never replace the original revision with a newly read one on that operation, and never substitute a created identity. Concurrent edits stop the operation for review.
|
|
289
|
+
|
|
290
|
+
A save whose `expected_revision` is already stale is refused before admission. It returns `CONFLICT` (`STALE_PREVIEW` for a confirmed save) with `state: "refused"`, `completedSteps: []`, the planned `remainingSteps`, the current `mutationRevision` and `latestState`. For a create, `entryId` and `latestState` are null. Nothing changes and no operation is recorded: `operation.inspect` returns `NOT_FOUND` for it. Review the state, then submit again with a new operation ID and the reviewed revision, previewing again when `replace` is present.
|
|
291
|
+
|
|
292
|
+
Inspect without retrying through `library mutate --app ID --action operation.inspect --target-operation-id OPERATION_ID`, or `{app_id, action: "operation.inspect", target_operation_id}` via `library_mutate`. Inspection requires current `library.view` and the original connection's scoped operation ownership; replay still requires `library.manage`. Revoked access cannot disclose old outcomes.
|
|
293
|
+
|
|
294
|
+
To correct a terminal failure or accept a reviewed concurrent edit, use a **new** operation ID, `resumes_operation_id` naming the stopped operation, the caller-reviewed current `expected_revision`, and its persisted `entry_id`. Include only remaining steps; completed steps cannot be repeated. Child admission atomically supersedes the stopped parent's remaining work. A child that still replaces contents must obtain a fresh whole-save preview before admission. `OPERATION_SUPERSEDED` identifies the admitted child; inspect it to continue. CLI JSON files and local MCP use this same closed request contract.
|
|
295
|
+
|
|
296
|
+
## Publishing
|
|
297
|
+
|
|
298
|
+
Publishing is its own step after a save: `entry.save` never publishes or schedules. Publish, schedule, cancel, discard and return to draft each take the usual operation ID and `expected_revision` and need `library.manage`. Revisions, retries and recovery for them, and for collections, are under [Revisions, retries and recovery](#revisions-retries-and-recovery).
|
|
299
|
+
|
|
300
|
+
### Publish
|
|
301
|
+
|
|
302
|
+
Send `entry.publish` with `{entry_id, child_ids?}`. From the CLI: `adelin library mutate --app APP --operation-id OP --expected-revision REV --action entry.publish --entry ENTRY [--children CHILD,CHILD]`.
|
|
303
|
+
|
|
304
|
+
- A draft item needs a playable main file: assigned, ready and of the item's media type. Otherwise the result is `MAIN_NOT_PLAYABLE`. A successful publish returns `outcome: "published"`.
|
|
305
|
+
- A published entry with staged edits (read `publishing.state: "changes_pending"` and the `pendingChangedKeys` section) applies them: `outcome: "changes_published"`. A published entry with nothing staged returns `unchanged` and leaves `mutationRevision` as it was.
|
|
306
|
+
- A draft folder publishes only the children you list in `child_ids`: at most 200 distinct direct child items, in your order. There is no "all ready" shortcut, no sub-folders and no recursion. Every listed child must be a draft item that is not live, not scheduled on its own, and has a playable main file. The first listed child that fails returns `CHILD_NOT_ELIGIBLE` with `childId` and `reason` (`not_found`, `not_direct_child`, `not_item`, `not_draft`, `scheduled`, `live`, `no_main` or `main_not_playable`), and nothing changes. Unknown IDs and IDs from another app both report `not_found`.
|
|
307
|
+
- Children scheduled together with the folder may be listed. If any is left out, the publish returns `SCHEDULED_CHILDREN_UNLISTED` with their `childIds`, so nothing goes live unlisted. List them, or cancel their schedule first.
|
|
308
|
+
- `child_ids` on an item or on an already published folder returns `CHILDREN_NOT_ALLOWED`.
|
|
309
|
+
- A first publish needs a title in at least one app language. If the target or a listed child has none, the result is `TITLE_MISSING` with `entries: [{entryId, missingLanguages}]`, the target first and then the children in your order, and nothing changes. A refusal that cannot name the entries carries `missingLanguages` alone. Ask the builder for a title. Publishing changes to an entry that is already published is never blocked by a language; a missing title, description or field value shows another app language.
|
|
310
|
+
|
|
311
|
+
The receipt holds `outcome`, `affectedIds` (the target first, then the listed children), `children` (`{id, outcome}` per listed child), `changes`, `mutationRevision` and `cleanup: {state, remaining, retryAction: "entry.publish"}`.
|
|
312
|
+
|
|
313
|
+
A draft folder with two listed children, as a CLI JSON file or identical `library_mutate` arguments:
|
|
314
|
+
|
|
315
|
+
```json
|
|
316
|
+
{
|
|
317
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
318
|
+
"operation_id": "6d5c4b3a-2918-4a7b-8c6d-5e4f3a2b1c0d",
|
|
319
|
+
"expected_revision": "57",
|
|
320
|
+
"action": "entry.publish",
|
|
321
|
+
"payload": {
|
|
322
|
+
"entry_id": "9e8d7c6b-5a49-4382-a716-05f4e3d2c1b0",
|
|
323
|
+
"child_ids": ["5c4b3a29-1807-4f6e-8d5c-4b3a29180716", "1a2b3c4d-5e6f-4a7b-9c8d-0e1f2a3b4c5d"]
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### Choose children
|
|
329
|
+
|
|
330
|
+
Before publishing or scheduling a draft folder, read its direct children with `adelin library publish-candidates --app APP --entry FOLDER` or `library_publish_candidates` (`{app_id, entry_id, limit?, cursor?}`). Each item has `id`, `title`, `kind`, `mediaType`, `missingLanguages`, `publishState`, `schedule`, `scheduledWithThis`, `publishReadiness` and `scheduleReadiness`. A readiness of `ready` means the child can be listed; any other value is the reason the action would refuse it (`not_item`, `not_draft`, `scheduled`, `live`, `no_main` or `main_not_playable`). Publish and schedule apply the same rule, so list only `ready` children. `missingLanguages` lists the app languages the title lacks, so a `ready` child may still lack translations. A child that is otherwise ready but has no title in any app language reads `publishReadiness: "title_missing"`. Scheduling does not check titles, so a scheduled child that still has none fails when its time comes. A child with `scheduledWithThis: true` must also be listed, or its schedule cancelled, before the folder can publish. An item or unknown entry returns `NOT_FOLDER` or `NOT_FOUND`. Pages follow the usual cursor rules; a library change between pages returns `STALE_CURSOR`.
|
|
331
|
+
|
|
332
|
+
### Schedule and cancel
|
|
333
|
+
|
|
334
|
+
`entry.schedule` takes `{entry_id, at, child_ids?}`; `entry.schedule.cancel` takes `{entry_id}`. Neither uses a preview. Give the time in one of two explicit forms:
|
|
335
|
+
|
|
336
|
+
- `at: {utc: "YYYY-MM-DDTHH:MMZ"}`, a UTC instant. CLI: `--at YYYY-MM-DDTHH:MMZ`.
|
|
337
|
+
- `at: {wall: "YYYY-MM-DDTHH:MM", zone: "Europe/Vilnius"}`, a wall-clock time in an IANA zone. CLI: `--at YYYY-MM-DDTHH:MM --zone Europe/Vilnius`.
|
|
338
|
+
|
|
339
|
+
A time with no `Z` and no zone, or with a numeric offset such as `+03:00`, returns `SCHEDULE_ZONE_REQUIRED` before anything is sent: a bare time means different instants in different places, and an offset does not follow the zone's clock changes. An unknown zone returns `SCHEDULE_ZONE_INVALID`. A wall time skipped by a clock change returns `SCHEDULE_TIME_NONEXISTENT`; one that happens twice returns `SCHEDULE_TIME_AMBIGUOUS` with its two UTC `candidates`. Nothing is guessed: pick a different wall time, or resend one candidate as `{utc}`. The instant must be on a 5-minute step, in the future and at most 366 days ahead, or the result is `SCHEDULE_INVALID` with `reason` (`invalid_format`, `not_on_step`, `not_future` or `too_far`). Read the clock before you choose a time.
|
|
340
|
+
|
|
341
|
+
From the CLI: `adelin library mutate --app APP --operation-id OP --expected-revision REV --action entry.schedule --entry FOLDER --at WALL --zone ZONE --children CHILD,CHILD`, and `--action entry.schedule.cancel --entry ENTRY` to cancel.
|
|
342
|
+
|
|
343
|
+
- Only a draft can be scheduled; a published target returns `NOT_DRAFT`. A folder schedules exactly the children you list, with the publish rules for children (a child still processing may be listed). `child_ids` on an item returns `CHILDREN_NOT_ALLOWED`.
|
|
344
|
+
- Rescheduling replaces the child list. Any child scheduled with the folder that you leave out is detached: its schedule is cleared entirely and the receipt names it in `detachedIds`. Leaving out `child_ids` detaches them all.
|
|
345
|
+
- The receipt holds `outcome: "scheduled"`, `schedule: {publishAt, zone, wall, offset}`, `affectedIds` (the target, then the listed children), `detachedIds`, `changes`, `mutationRevision` and `cleanup` with `retryAction: "entry.schedule"`. `publishAt` is the UTC instant. `zone` and `wall` echo exactly what you sent, even for a zone that also has an older name (`Asia/Kathmandu` stays `Asia/Kathmandu`); the `{utc}` form echoes `UTC` and the UTC time. `offset` is the zone's offset at that instant, such as `UTC+02:00`. Check `publishAt` before you report the time.
|
|
346
|
+
- Cancel clears the target's schedule and the schedule of every child scheduled with it: `outcome: "cancelled"` with those IDs in `affectedIds`. With nothing scheduled the result is `unchanged` and `mutationRevision` does not move. A published entry returns `SCHEDULE_NOT_ACTIVE`.
|
|
347
|
+
- Entry reads show `publishing.state: "scheduled"`, `publishing.schedule.publishAt` and `publishing.scheduledWith` (the folder a child was scheduled with, or null). The candidates read shows `scheduledWithThis` and `scheduleReadiness`.
|
|
348
|
+
|
|
349
|
+
Publication runs in the background shortly after the time arrives, with the dashboard's rules, and advances `mutationRevision`. A child whose main file is not playable when the time comes, or that has no title in any app language, stays a draft, and its read shows `publishing.schedule.failure` with `code` (`main_not_playable`, `title_missing` or `publish_failed`), `message` and `at`. A failed schedule is not retried; fix the file or titles and schedule again, which clears the failure.
|
|
350
|
+
|
|
351
|
+
In the examples below, `YYYY-MM-DDTHH:MM` is a placeholder: replace it with a time computed from the current clock. A folder with two children at a Vilnius wall time:
|
|
352
|
+
|
|
353
|
+
```json
|
|
354
|
+
{
|
|
355
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
356
|
+
"operation_id": "0b1c2d3e-4f5a-4b6c-8d7e-9f0a1b2c3d4e",
|
|
357
|
+
"expected_revision": "58",
|
|
358
|
+
"action": "entry.schedule",
|
|
359
|
+
"payload": {
|
|
360
|
+
"entry_id": "9e8d7c6b-5a49-4382-a716-05f4e3d2c1b0",
|
|
361
|
+
"at": { "wall": "YYYY-MM-DDTHH:MM", "zone": "Europe/Vilnius" },
|
|
362
|
+
"child_ids": ["5c4b3a29-1807-4f6e-8d5c-4b3a29180716", "1a2b3c4d-5e6f-4a7b-9c8d-0e1f2a3b4c5d"]
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
An item at a UTC instant:
|
|
368
|
+
|
|
369
|
+
```json
|
|
370
|
+
{
|
|
371
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
372
|
+
"operation_id": "1c2d3e4f-5a6b-4c7d-9e8f-0a1b2c3d4e5f",
|
|
373
|
+
"expected_revision": "59",
|
|
374
|
+
"action": "entry.schedule",
|
|
375
|
+
"payload": {
|
|
376
|
+
"entry_id": "2b3c4d5e-6f7a-4b8c-9d0e-1f2a3b4c5d6e",
|
|
377
|
+
"at": { "utc": "YYYY-MM-DDTHH:MMZ" }
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
Cancelling the folder's schedule, which also clears its two children:
|
|
383
|
+
|
|
384
|
+
```json
|
|
385
|
+
{
|
|
386
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
387
|
+
"operation_id": "2d3e4f5a-6b7c-4d8e-8f9a-1b2c3d4e5f6a",
|
|
388
|
+
"expected_revision": "60",
|
|
389
|
+
"action": "entry.schedule.cancel",
|
|
390
|
+
"payload": { "entry_id": "9e8d7c6b-5a49-4382-a716-05f4e3d2c1b0" }
|
|
391
|
+
}
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
### Discard staged changes and return to draft
|
|
395
|
+
|
|
396
|
+
Both actions take `{entry_id}` and need a preview, then a confirmation, exactly like `entry.delete` above. From the CLI: `adelin library mutate --app APP --operation-id OP --expected-revision REV --action entry.draft --entry ENTRY --mode preview`, then the same flags with `--confirmation-file confirm.json` instead of `--mode preview`.
|
|
397
|
+
|
|
398
|
+
- Before a discard, read the entry's `pendingChangedKeys` section to tell the builder what viewers see now. Each item has `key`; `title`, `description`, `label` and `field:KEY` items also have `published`, the value viewers currently see (`null` for a label or field that is unset there), which is what the entry returns to after a discard. File, artwork, hierarchy and contents keys have no `published` value.
|
|
399
|
+
- `entry.discard` throws away a published entry's staged edits and staged files. The preview lists each lost edit as `{type: "pendingChange", key}` and each staged file as `{type: "stagedFile", id, family, slot | target, language, fileName, sizeBytes}`, with `cleanupCount` for the files to remove. The receipt's outcome is `discarded`. Afterwards the entry has `publishing.pending: null` and the live version stays as it was.
|
|
400
|
+
- `entry.draft` takes a published entry off viewers. The preview lists every entry viewers will stop seeing as `{type: "hidden", id, kind, title, role}`: the target first (`role: "target"`), then its published descendants (`role: "descendant"`). Descendants stay published, but their `hiddenBy` names the drafted ancestor until it is published again. Staged edits are not lost: `{type: "pendingApplied", key}` lists the ones that become the draft content. The receipt's outcome is `drafted` and it includes `hiddenCount`.
|
|
401
|
+
- Nothing to discard, or an entry that is already a draft, gives an empty preview and an `unchanged` commit that leaves `mutationRevision` as it was.
|
|
402
|
+
|
|
403
|
+
Receipts hold `outcome`, `affectedIds` (`[entry_id]`), `changes`, `mutationRevision` and `cleanup: {state, remaining, retryAction}`, where `retryAction` is the action you sent.
|
|
404
|
+
|
|
405
|
+
A return-to-draft confirmation, as a CLI JSON file or identical `library_mutate` arguments:
|
|
406
|
+
|
|
407
|
+
```json
|
|
408
|
+
{
|
|
409
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
410
|
+
"operation_id": "3c2b1a09-f8e7-4d6c-8b5a-49382716a5b4",
|
|
411
|
+
"expected_revision": "61",
|
|
412
|
+
"action": "entry.draft",
|
|
413
|
+
"payload": { "entry_id": "9e8d7c6b-5a49-4382-a716-05f4e3d2c1b0" },
|
|
414
|
+
"confirmation": {
|
|
415
|
+
"preview_id": "7f6e5d4c-3b2a-4190-8f7e-6d5c4b3a2918",
|
|
416
|
+
"digest": "4f1c9e0b7a3d5c2e8f6b1a9d0c7e3b5a2f8d6c4e1b9a7f3d5c0e2b8a6f4d1c9e",
|
|
417
|
+
"acknowledgement": "b2e8d4a6c0f1e3b5d7a9c2e4f6b8d0a1c3e5f7b9d2a4c6e8f0b1d3a5c7e9f2b4"
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
### Revisions, retries and recovery
|
|
423
|
+
|
|
424
|
+
- **Revision.** Every publish, schedule, cancel, discard, return to draft and collection change advances `mutationRevision`, and one action can advance it by more than one, so always continue from the returned value. Dashboard edits and background scheduled publishing advance it too.
|
|
425
|
+
- **Conflict.** A stale `expected_revision` returns `CONFLICT` with the current `mutationRevision` and a bounded `latestState`: `{id, status, publishState, schedule, pendingChangeCount}` for an entry, where `pendingChangeCount` is the number of keys its `pendingChangedKeys` section lists, `{id, name, parentId, memberCount}` for a collection, or `{app_id}` for a collection create or an unknown target. Nothing changes. Re-read, then send a new request with a new operation ID.
|
|
426
|
+
- **Previews.** Previews follow the rules under `folder.replace` and `entry.delete` above. Confirming before reading the last page, or with a wrong digest or acknowledgement, returns `CONFIRMATION_REQUIRED`. A library change after the preview, from the dashboard or another tool, a changed payload or an expired preview returns `STALE_PREVIEW`: read again and preview anew.
|
|
427
|
+
- **Busy library.** `RETRYABLE_CONFLICT` means another change to the same app's library, such as a dashboard edit or scheduled publishing, held it at that moment. Nothing changed. Wait a moment, then resend the identical request with the same operation ID.
|
|
428
|
+
- **Lost response and cleanup.** Resend the identical request with the same operation ID: it returns the stored receipt and repeats no effect. When `cleanup.state` is `pending`, the same identical request resumes the remaining cleanup.
|
|
429
|
+
- **Inspect.** `operation.inspect` returns the stored receipt with the current `mutationRevision`. It needs current `library.view`.
|
|
430
|
+
- **Changed payload.** Reusing an operation ID with a different request returns `OPERATION_PAYLOAD_CONFLICT`.
|
|
431
|
+
- **Revoked access.** Once access is removed, replay, inspect, reads and the next request return `ACCESS_DENIED`.
|
|
432
|
+
|
|
433
|
+
## Curated collections
|
|
434
|
+
|
|
435
|
+
A curated collection is a named, hand-ordered list of library entries, such as a row of picks on a home screen. It is separate from the folder tree: an entry keeps its folder and can belong to any number of collections. A collection with a `parentId` is a subcollection, and nesting can go several levels deep. Collection posters and backdrops are managed in the dashboard; these tools neither read nor change them.
|
|
436
|
+
|
|
437
|
+
### Read collections
|
|
438
|
+
|
|
439
|
+
`adelin library collections --app APP [--search TEXT] [--media all|video|audio]` or `library_collections` (`{app_id, q?, media?, limit?, cursor?}`) returns every collection in the dashboard's order. Each one has `id`, `name`, `note`, `parentId`, `path` (its ancestors from the top, each `{id, name}`), `memberCount`, `childCount` and `mediaTypes` (the media its members hold, subcollections included). An app with more than 1000 collections returns `READ_SNAPSHOT_TOO_LARGE`.
|
|
440
|
+
|
|
441
|
+
`adelin library collection --app APP --collection COLLECTION [--section members|children]` or `library_collection` (`{app_id, collection_id, section?, limit?, cursor?}`) returns one collection as `data.collection`. `section: "members"`, the default, pages its ordered members; `"children"` pages its direct subcollections (`id`, `name`, `memberCount`, `childCount`). Each member has `entryId`, `title`, `kind`, `mediaType`, `status`, `publishState`, `hiddenBy` and `visibleToViewers`. A draft member, or one under a draft folder (`hiddenBy`), stays in the collection, but viewers do not see it until it is published, so `visibleToViewers` is false. An unknown or foreign collection returns `NOT_FOUND`.
|
|
442
|
+
|
|
443
|
+
### Create, edit and delete
|
|
444
|
+
|
|
445
|
+
- `collection.create` takes `{name, note?, parent_id?, entry_ids?}`. The name is a language map holding at least one app language; each language's name is trimmed and must be 1 to 200 characters. The note is at most 2000 characters; an empty note reads back as `""`. `parent_id` is null or an existing collection. `entry_ids` lists at most 500 entries in display order. The receipt has `outcome: "created"`, `affectedIds: [newId]` and `changes: ["created"]`.
|
|
446
|
+
- `collection.update` takes `{collection_id}` plus at least one of `name`, `note` and `parent_id`; `name` changes only the languages it lists, and `null` removes one; `parent_id: null` moves the collection to the top level. Members change only through the `collection.members.*` actions below. The receipt has `outcome: "updated"`, `affectedIds: [collection_id]` and `changes` naming what you sent, in the order `name`, `note`, `parent`.
|
|
447
|
+
- `collection.delete` takes `{collection_id}` and needs a preview, then a confirmation. The preview lists the direct subcollections that move to the top level as `{type: "childCollection", id, name}`, and each page's `memberCount` says how many memberships are removed. Deeper subcollections stay under their own parent, and no entry is ever deleted. The receipt has `outcome: "deleted"` and `affectedIds` with the deleted collection first, then the subcollections that moved.
|
|
448
|
+
|
|
449
|
+
An unknown or foreign collection, parent or entry returns `NOT_FOUND`; the two cases look the same. A parent that is the collection itself or one of its subcollections returns `CYCLE`. An entry listed twice returns `DUPLICATE_ENTRY`. A name or note outside its bounds returns `INVALID_ARGUMENT`. None of these change anything.
|
|
450
|
+
|
|
451
|
+
### Membership
|
|
452
|
+
|
|
453
|
+
Membership is an ordered list of at most 500 entries. Each action takes `{collection_id, entry_ids}` and returns `outcome: "updated"`, `affectedIds: [collection_id]` and `counts`.
|
|
454
|
+
|
|
455
|
+
- `collection.members.replace` sets the whole list in the order given; `[]` empties it. It needs a preview, then a confirmation. The preview lists only entries that are added, removed or change position, as `{type: "member", entryId, beforeIndex, afterIndex}`; an added entry has `beforeIndex: null` and a removed one `afterIndex: null`. The receipt has `changes: ["members"]` and `counts: {added, removed, moved}`. "Moved" counts each entry whose position changed, so removing the first member through replace moves every later one. A replace with the current order previews no items and commits as `unchanged` with `changes: []` and no `counts`; it writes nothing and leaves `mutationRevision` as it was.
|
|
456
|
+
- `collection.members.add` appends 1 to 500 entries in the order given, with no preview. An entry that is already a member, or listed twice, returns `DUPLICATE_ENTRY` with that `entryId`. A result over 500 members returns `LIMIT_EXCEEDED`. The receipt has `changes: ["members_added"]` and `counts: {added}`.
|
|
457
|
+
- `collection.members.remove` removes 1 to 500 members. It needs a preview, then a confirmation. The preview lists every remaining member in its new order, then each removed member with `afterIndex: null`. An entry that is not a member returns `NOT_MEMBER` with that `entryId`. The receipt has `changes: ["members_removed"]` and `counts: {removed}`.
|
|
458
|
+
|
|
459
|
+
Replace and remove can drop members, so they always preview; add only appends, so it never does. A member preview over 100 items continues through `preview.page`, and only its last page carries the `acknowledgement`. Library entries are never deleted by these actions. Deleting a library entry removes it from every collection and keeps the order of the rest.
|
|
460
|
+
|
|
461
|
+
From the CLI: `adelin library mutate --app APP --operation-id OP --expected-revision REV --action collection.create --name NAME --language TAG --note TEXT --parent PARENT --entries ENTRY,ENTRY`. Update uses `--action collection.update --collection COLLECTION` with any of `--name` (with `--language`), `--note` and `--parent` (`--parent null` for the top level). Delete uses `--action collection.delete --collection COLLECTION --mode preview`, then the same flags with `--confirmation-file confirm.json`. All three membership actions take `--collection COLLECTION --entries ENTRY,ENTRY`; replace and remove add `--mode preview`, then `--confirmation-file confirm.json`. `--entries ''` sends an empty list to replace.
|
|
462
|
+
|
|
463
|
+
A new collection, as a CLI JSON file or identical `library_mutate` arguments:
|
|
464
|
+
|
|
465
|
+
```json
|
|
466
|
+
{
|
|
467
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
468
|
+
"operation_id": "6d5c4b3a-2918-4f7e-8d6c-5b4a39281706",
|
|
469
|
+
"expected_revision": "73",
|
|
470
|
+
"action": "collection.create",
|
|
471
|
+
"payload": {
|
|
472
|
+
"name": { "en": "Weekend picks" },
|
|
473
|
+
"note": "Refresh on Fridays",
|
|
474
|
+
"parent_id": null,
|
|
475
|
+
"entry_ids": ["5c4b3a29-1807-4f6e-8d5c-4b3a29180716", "1a2b3c4d-5e6f-4a7b-9c8d-0e1f2a3b4c5d"]
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
The preview step of a membership replace that reorders two members and adds a third. Read every page, then send the same request without `mode` and with the last page's `confirmation`:
|
|
481
|
+
|
|
482
|
+
```json
|
|
483
|
+
{
|
|
484
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
485
|
+
"operation_id": "4e5f6a7b-8c9d-4e0f-9a1b-2c3d4e5f6a7b",
|
|
486
|
+
"expected_revision": "74",
|
|
487
|
+
"action": "collection.members.replace",
|
|
488
|
+
"mode": "preview",
|
|
489
|
+
"payload": {
|
|
490
|
+
"collection_id": "3f4a5b6c-7d8e-4f9a-8b0c-1d2e3f4a5b6c",
|
|
491
|
+
"entry_ids": ["1a2b3c4d-5e6f-4a7b-9c8d-0e1f2a3b4c5d", "5c4b3a29-1807-4f6e-8d5c-4b3a29180716", "2b3c4d5e-6f7a-4b8c-9d0e-1f2a3b4c5d6e"]
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
## Entry files
|
|
497
|
+
|
|
498
|
+
An entry's files are its main and trailer media, its artwork (poster, backdrop and logo) and its subtitles. Media are uploads from the media library, attached with `library_mutate`. Artwork and subtitle bytes move with `adelin library files` on the CLI or the matching local MCP tools, straight from this computer to Adelin and never through the agent. Each transfer runs under a short-lived, single-use grant that only the local process holds, and no result carries file content, a signed URL, a token, a grant or a storage key. `adelin library files --help` lists every command and `adelin library files <command> --help` shows one.
|
|
499
|
+
|
|
500
|
+
### Entry files at a glance
|
|
501
|
+
|
|
502
|
+
| Command | Local MCP tool or `library_mutate` action | Approval | Confirmation |
|
|
503
|
+
|---|---|---|---|
|
|
504
|
+
| `adelin library mutate --action entry.assets` | `entry.assets` | `library.manage` | none to attach or replace; preview, then `confirmation`, to detach |
|
|
505
|
+
| `adelin library mutate --input FILE` | `entry.save` with an `assets` step | `library.manage` | none; a whole-save preview only when `replace` is present |
|
|
506
|
+
| `adelin library files put-artwork` | `library_files_put_artwork` | `library.manage` and the Adelin CLI sign-in | none, also when it replaces |
|
|
507
|
+
| `adelin library mutate --action entry.artwork.remove` | `entry.artwork.remove` | `library.manage` | preview, then `confirmation` |
|
|
508
|
+
| `adelin library files add-subtitle` | `library_files_add_subtitle` | `library.manage` and the Adelin CLI sign-in | none |
|
|
509
|
+
| `adelin library files replace-subtitle` | `library_files_replace_subtitle` | `library.manage` and the Adelin CLI sign-in | none |
|
|
510
|
+
| `adelin library mutate --action entry.subtitle.language` | `entry.subtitle.language` | `library.manage` | none |
|
|
511
|
+
| `adelin library mutate --action entry.subtitle.remove` | `entry.subtitle.remove` | `library.manage` | preview, then `confirmation` |
|
|
512
|
+
| `adelin library files get` | `library_files_get` | `library.view` and the Adelin CLI sign-in | none |
|
|
513
|
+
| `adelin library files check` | `library_files_check` | none; runs on this computer | none |
|
|
514
|
+
| `adelin library mutate --action operation.inspect` | `operation.inspect` | `library.view` | read-only |
|
|
515
|
+
|
|
516
|
+
The Adelin CLI sign-in is the one described under Media library; another code agent connection gets `ACCESS_DENIED` for the byte commands. Every change takes `operation_id` (a new UUID for each change) and `expected_revision` (`data.mutationRevision` from the latest library read). `library_mutate` examples below are a CLI JSON file (`adelin library mutate --input FILE`) or identical `library_mutate` arguments. Each `adelin library files` example is followed by the same request as local MCP arguments.
|
|
517
|
+
|
|
518
|
+
Every removal needs a preview and the confirmation from it, on drafts and published entries alike: a detach, `entry.artwork.remove` and `entry.subtitle.remove`. Send the request with `mode: "preview"`, then the identical request without `mode` and with `confirmation: {preview_id, digest, acknowledgement}` from the preview; on the CLI keep the flags and add `--confirmation-file FILE`. Previews follow the rules under `folder.replace` and `entry.delete`. Replacing an attachment or a file is not a removal and needs no preview.
|
|
519
|
+
|
|
520
|
+
Atomic subtitle language edits use `entry.subtitle.languages` with `payload: {entry_id, languages: {FILE_UUID: "fr", OTHER_FILE_UUID: "en"}}`. Send the complete mutation JSON with `adelin library mutate --input FILE` or through `library_mutate`. Between one and 100 distinct files can change together, including language swaps. The final set must have one subtitle per language per target. A missing file or duplicate final language refuses the whole batch; no prefix applies. The receipt returns `files: [{fileId, target, language}]`. File identities and stored bytes stay unchanged; published changes are staged. Existing duplicate-language files can be repaired by explicitly retagging them to distinct languages without deleting either file.
|
|
521
|
+
|
|
522
|
+
### Drafts and published entries
|
|
523
|
+
|
|
524
|
+
A draft entry changes at once. A published entry stages each change until `entry.publish`: a reply's `outcome` is `live` or `saved` for a draft and `staged` for a published entry. Entry core, `subtitles` and the artwork and assets fields show the staged side: what viewers get once the entry's changes publish. `pendingChangedKeys` puts the published value next to each staged key. Metadata and field keys carry the published value. `main` and `trailer` carry `published: {assetId, name, status}`, or null when nothing is attached. `artwork:poster`, `artwork:backdrop` and `artwork:logo` carry `published: {fileId, fileName}` or null, and a key such as `artwork:poster:lt` does the same for one language's image. `subtitles` carries `published: {liveCount}`, the number of subtitles viewers have now. `parent`, `mediaType` and `contents` carry no published value. Collection members carry `posterFileId`, the poster's file id or null. `entry.discard` drops staged files along with the other staged changes.
|
|
525
|
+
|
|
526
|
+
### Attach, replace and detach media
|
|
527
|
+
|
|
528
|
+
`entry.assets` attaches, replaces or detaches the main and trailer media of one entry: give `main`, `trailer` or both as an asset UUID, or `null` to detach. CLI flags are `--action entry.assets --entry UUID --main UUID|null --trailer UUID|null`. Items take a main and a trailer; folders take a trailer only. The main must match the item's media type, the trailer must be a video, and the asset must belong to the same app. An asset that is still processing can be attached: the reply carries `warnings` with `ASSET_NOT_PLAYABLE`, and publishing refuses with `MAIN_NOT_PLAYABLE` until the main is playable. A failed asset is refused with `ASSET_FAILED`; other refusals are `ASSET_NOT_FOUND`, `ASSET_UNAVAILABLE` and `ASSET_KIND`. `entry.assets` accepts `mode` and `confirmation` only when a role is `null`; an attach-only request that sends either is refused with `INVALID_ARGUMENT`. The receipt is `{operationId, state, outcome, affectedIds, changes, mutationRevision, warnings?}`; detaching an empty role commits as `unchanged`.
|
|
529
|
+
|
|
530
|
+
Attach a main and a trailer:
|
|
531
|
+
|
|
532
|
+
```json
|
|
533
|
+
{
|
|
534
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
535
|
+
"operation_id": "1b2c3d4e-5f60-4718-8a9b-0c1d2e3f4a5b",
|
|
536
|
+
"expected_revision": "42",
|
|
537
|
+
"action": "entry.assets",
|
|
538
|
+
"payload": {
|
|
539
|
+
"entry_id": "5c4b3a29-1807-4f6e-8d5c-4b3a29180716",
|
|
540
|
+
"main": "7b6a5948-3726-4150-9e8d-7c6b5a493827",
|
|
541
|
+
"trailer": "0f1e2d3c-4b5a-4697-8877-665544332211"
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
Preview a trailer detach. Each preview item is `{type: "asset", role, assetId, name, status, effect}`, where `effect` is `detached` on a draft and `staged_detach` on a published entry:
|
|
547
|
+
|
|
548
|
+
```json
|
|
549
|
+
{
|
|
550
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
551
|
+
"operation_id": "6d5c4b3a-2918-4706-a5f4-e3d2c1b0a998",
|
|
552
|
+
"expected_revision": "43",
|
|
553
|
+
"action": "entry.assets",
|
|
554
|
+
"mode": "preview",
|
|
555
|
+
"payload": { "entry_id": "5c4b3a29-1807-4f6e-8d5c-4b3a29180716", "trailer": null }
|
|
556
|
+
}
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
Commit it with the same operation, revision and payload and the preview's confirmation:
|
|
560
|
+
|
|
561
|
+
```json
|
|
562
|
+
{
|
|
563
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
564
|
+
"operation_id": "6d5c4b3a-2918-4706-a5f4-e3d2c1b0a998",
|
|
565
|
+
"expected_revision": "43",
|
|
566
|
+
"action": "entry.assets",
|
|
567
|
+
"confirmation": {
|
|
568
|
+
"preview_id": "2e3f4a5b-6c7d-4e8f-9a0b-1c2d3e4f5a6b",
|
|
569
|
+
"digest": "3e2d1c0b9a8f7e6d5c4b3a291807f6e5d4c3b2a1908f7e6d5c4b3a2918071625",
|
|
570
|
+
"acknowledgement": "c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2"
|
|
571
|
+
},
|
|
572
|
+
"payload": { "entry_id": "5c4b3a29-1807-4f6e-8d5c-4b3a29180716", "trailer": null }
|
|
573
|
+
}
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
`entry.save` can attach or replace media in its `assets` step, between metadata and label (see Combined save and recovery):
|
|
577
|
+
|
|
578
|
+
```json
|
|
579
|
+
{
|
|
580
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
581
|
+
"operation_id": "2c3d4e5f-6071-4829-9bac-1d2e3f4a5b6c",
|
|
582
|
+
"expected_revision": "44",
|
|
583
|
+
"action": "entry.save",
|
|
584
|
+
"payload": {
|
|
585
|
+
"entry_id": "5c4b3a29-1807-4f6e-8d5c-4b3a29180716",
|
|
586
|
+
"metadata": { "title": { "en": "Opening night" } },
|
|
587
|
+
"assets": { "main": "7b6a5948-3726-4150-9e8d-7c6b5a493827" }
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
### Artwork
|
|
593
|
+
|
|
594
|
+
`adelin library files put-artwork --app UUID --entry UUID --slot poster|backdrop|logo --file PATH --operation-id UUID --expected-revision REV` or `library_files_put_artwork {app_id, entry_id, slot, path, operation_id, expected_revision}` adds one artwork slot. Uploading into a filled slot replaces it: the receipt names the old file in `replacedFileId`. Artwork is a PNG or JPEG (checked by its first bytes, named `.png`, `.jpg` or `.jpeg`) of at most 10 MB. Posters are 2:3 and at least 400×600; backdrops are 16:9 and at least 1280×720, each within 2%. A logo may have any shape up to 4096 pixels a side; a transparent PNG logo is trimmed to its visible content, and a fully transparent one is refused with `LIBRARY_ARTWORK_EMPTY`.
|
|
595
|
+
|
|
596
|
+
`--language TAG` (`language`) uploads the image for one app language, such as a poster with a translated title on it, and replaces only that language's image: `adelin library files put-artwork --app APP --entry ENTRY --slot poster --language lt --file /home/me/art/poster-lt.png --operation-id OP --expected-revision REV`. The tag must be one of the app's languages, written as the languages read returns it; without it the image is the first language's. Which image a viewer sees is under [Languages](#languages). Entry reads show `artwork` as `{slot: {language: image}}`, and the receipt's `file.language` names the image's language.
|
|
597
|
+
|
|
598
|
+
```sh
|
|
599
|
+
adelin library files put-artwork --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --entry 5c4b3a29-1807-4f6e-8d5c-4b3a29180716 --slot poster --file /home/me/art/poster.png --operation-id 3d4e5f60-7182-493a-acbd-2e3f4a5b6c7d --expected-revision 45
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
The same upload as `library_files_put_artwork` arguments:
|
|
603
|
+
|
|
604
|
+
```json
|
|
605
|
+
{
|
|
606
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
607
|
+
"entry_id": "5c4b3a29-1807-4f6e-8d5c-4b3a29180716",
|
|
608
|
+
"slot": "poster",
|
|
609
|
+
"path": "/home/me/art/poster.png",
|
|
610
|
+
"operation_id": "3d4e5f60-7182-493a-acbd-2e3f4a5b6c7d",
|
|
611
|
+
"expected_revision": "45"
|
|
612
|
+
}
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
Remove artwork with `entry.artwork.remove` (`--action entry.artwork.remove --entry UUID --slot SLOT`); add `--language TAG` (`language`) to remove that language's image, while leaving it out removes the first language's. Its preview item is `{type: "artwork", slot, language, fileId, fileName, sizeBytes, effect}`; an empty slot returns `NOT_FOUND`. Preview removing the backdrop:
|
|
616
|
+
|
|
617
|
+
```json
|
|
618
|
+
{
|
|
619
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
620
|
+
"operation_id": "4e5f6071-8293-4a4b-bdce-3f4a5b6c7d8e",
|
|
621
|
+
"expected_revision": "46",
|
|
622
|
+
"action": "entry.artwork.remove",
|
|
623
|
+
"mode": "preview",
|
|
624
|
+
"payload": { "entry_id": "5c4b3a29-1807-4f6e-8d5c-4b3a29180716", "slot": "backdrop" }
|
|
625
|
+
}
|
|
626
|
+
```
|
|
627
|
+
|
|
628
|
+
### Subtitles
|
|
629
|
+
|
|
630
|
+
Subtitles are WebVTT (`.vtt`) or SubRip (`.srt`) in strict UTF-8, at most 2 MB before and after conversion. SubRip is converted to WebVTT and the receipt says `converted: true`. Subtitles sit on an item's main or trailer and on a folder's trailer, including trailer subtitles on items; a folder has no main. Each target holds one subtitle per language; several different languages on one target are fine. Adding, or changing a subtitle to, a language that target already has returns `SUBTITLE_LANGUAGE_EXISTS` with the `fileId` that holds it: replace that file instead of adding a second one.
|
|
631
|
+
|
|
632
|
+
`adelin library files add-subtitle --app UUID --entry UUID --target main|trailer --language TAG --file PATH --operation-id UUID --expected-revision REV` or `library_files_add_subtitle {app_id, entry_id, target, language, path, operation_id, expected_revision}` adds a subtitle in one language, such as `en` or `pt-BR`:
|
|
633
|
+
|
|
634
|
+
```sh
|
|
635
|
+
adelin library files add-subtitle --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --entry 5c4b3a29-1807-4f6e-8d5c-4b3a29180716 --target main --language en --file /home/me/captions/en.srt --operation-id 5f607182-93a4-4b5c-8edf-4a5b6c7d8e9f --expected-revision 47
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
The same subtitle as `library_files_add_subtitle` arguments:
|
|
639
|
+
|
|
640
|
+
```json
|
|
641
|
+
{
|
|
642
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
643
|
+
"entry_id": "5c4b3a29-1807-4f6e-8d5c-4b3a29180716",
|
|
644
|
+
"target": "main",
|
|
645
|
+
"language": "en",
|
|
646
|
+
"path": "/home/me/captions/en.srt",
|
|
647
|
+
"operation_id": "5f607182-93a4-4b5c-8edf-4a5b6c7d8e9f",
|
|
648
|
+
"expected_revision": "47"
|
|
649
|
+
}
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
`adelin library files replace-subtitle --app UUID --entry UUID --subtitle UUID --file PATH --operation-id UUID --expected-revision REV` or `library_files_replace_subtitle {app_id, entry_id, file_id, path, operation_id, expected_revision}` replaces one subtitle file; its target and language stay the same:
|
|
653
|
+
|
|
654
|
+
```sh
|
|
655
|
+
adelin library files replace-subtitle --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --entry 5c4b3a29-1807-4f6e-8d5c-4b3a29180716 --subtitle 3c2b1a09-8f7e-4d6c-9b5a-4f3e2d1c0b9a --file /home/me/captions/en-fixed.vtt --operation-id 60718293-a4b5-4c6d-9f01-5b6c7d8e9fa0 --expected-revision 48
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
The same replacement as `library_files_replace_subtitle` arguments:
|
|
659
|
+
|
|
660
|
+
```json
|
|
661
|
+
{
|
|
662
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
663
|
+
"entry_id": "5c4b3a29-1807-4f6e-8d5c-4b3a29180716",
|
|
664
|
+
"file_id": "3c2b1a09-8f7e-4d6c-9b5a-4f3e2d1c0b9a",
|
|
665
|
+
"path": "/home/me/captions/en-fixed.vtt",
|
|
666
|
+
"operation_id": "60718293-a4b5-4c6d-9f01-5b6c7d8e9fa0",
|
|
667
|
+
"expected_revision": "48"
|
|
668
|
+
}
|
|
669
|
+
```
|
|
670
|
+
|
|
671
|
+
`entry.subtitle.language` (`--action entry.subtitle.language --entry UUID --subtitle UUID --language TAG`) changes the language tag of one subtitle and takes no preview; its receipt carries `file: {fileId, target, language}`:
|
|
672
|
+
|
|
673
|
+
```json
|
|
674
|
+
{
|
|
675
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
676
|
+
"operation_id": "718293a4-b5c6-4d7e-a012-6c7d8e9fa0b1",
|
|
677
|
+
"expected_revision": "49",
|
|
678
|
+
"action": "entry.subtitle.language",
|
|
679
|
+
"payload": { "entry_id": "5c4b3a29-1807-4f6e-8d5c-4b3a29180716", "file_id": "3c2b1a09-8f7e-4d6c-9b5a-4f3e2d1c0b9a", "language": "pt-BR" }
|
|
680
|
+
}
|
|
681
|
+
```
|
|
682
|
+
|
|
683
|
+
`entry.subtitle.remove` (`--action entry.subtitle.remove --entry UUID --subtitle UUID`) removes one subtitle. Its preview item is `{type: "subtitle", fileId, target, language, fileName, sizeBytes, effect}`; an unknown file returns `NOT_FOUND`. Preview removing it:
|
|
684
|
+
|
|
685
|
+
```json
|
|
686
|
+
{
|
|
687
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
688
|
+
"operation_id": "8293a4b5-c6d7-4e8f-8123-7d8e9fa0b1c2",
|
|
689
|
+
"expected_revision": "50",
|
|
690
|
+
"action": "entry.subtitle.remove",
|
|
691
|
+
"mode": "preview",
|
|
692
|
+
"payload": { "entry_id": "5c4b3a29-1807-4f6e-8d5c-4b3a29180716", "file_id": "3c2b1a09-8f7e-4d6c-9b5a-4f3e2d1c0b9a" }
|
|
693
|
+
}
|
|
694
|
+
```
|
|
695
|
+
|
|
696
|
+
A removal's receipt carries `removed`, `cleanupCount` and `cleanup` with `retryAction`.
|
|
697
|
+
|
|
698
|
+
### Local checks
|
|
699
|
+
|
|
700
|
+
Every write runs the same checks on this computer before anything is sent and refuses with the code the server would return: `LIBRARY_ARTWORK_TYPE`, `LIBRARY_ARTWORK_TOO_LARGE`, `LIBRARY_ARTWORK_NOT_IMAGE`, `LIBRARY_ARTWORK_SHAPE`, `LIBRARY_SUBTITLE_TYPE`, `LIBRARY_SUBTITLE_TOO_LARGE`, `LIBRARY_SUBTITLE_ENCODING` or `LIBRARY_SUBTITLE_INVALID`. `adelin library files check --kind artwork --slot SLOT --file PATH`, `adelin library files check --kind subtitle --file PATH` or `library_files_check {kind, slot?, path}` runs those checks without sending anything. It returns `verdict` `pass`, `refuse` with that `code` and `message`, or `deferred` for a PNG logo, whose transparency only the server checks. The server decides in every case. The file must be a regular file, not a symlink or directory.
|
|
701
|
+
|
|
702
|
+
```sh
|
|
703
|
+
adelin library files check --kind artwork --slot poster --file /home/me/art/poster.png
|
|
704
|
+
```
|
|
705
|
+
|
|
706
|
+
The same check as `library_files_check` arguments:
|
|
707
|
+
|
|
708
|
+
```json
|
|
709
|
+
{
|
|
710
|
+
"kind": "artwork",
|
|
711
|
+
"slot": "poster",
|
|
712
|
+
"path": "/home/me/art/poster.png"
|
|
713
|
+
}
|
|
714
|
+
```
|
|
715
|
+
|
|
716
|
+
### Private retrieval
|
|
717
|
+
|
|
718
|
+
`adelin library files get --app UUID --file-id UUID --out DIR` or `library_files_get {app_id, file_id, directory}` writes one artwork or subtitle file into a directory you name and returns its path and metadata, never its content. File ids come from the entry read (`artwork.<slot>.fileId`), the `subtitles` section, tree rows and collection members (`posterFileId`); live and staged files can both be read. The directory must belong to you, carry no group or other permissions (mode 0700) and have no symlink anywhere in its path; otherwise the result is `PRIVATE_OUTPUT_REFUSED`. A missing directory is created with mode 0700. The file is named `<fileId>.png`, `<fileId>.jpg` or `<fileId>.vtt` from the content type, never from the stored file name, and is created new with mode 0600; a symlink at that name is never followed. Running the same get again returns the same result when an identical file is already there; a different file at that name gives `OUTPUT_EXISTS`. The download must match the granted size exactly and is at most 10485760 bytes (10 MiB); anything else is `INVALID_RESPONSE` and nothing is written. The result is `{written:true, path, fileId, family, slot | target and language, contentType, sizeBytes, scope}`, where `scope` is `live` or `staged`.
|
|
719
|
+
|
|
720
|
+
```sh
|
|
721
|
+
adelin library files get --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --file-id 9d8c7b6a-5f4e-4d3c-8b2a-190807f6e5d4 --out /home/me/adelin-files
|
|
722
|
+
```
|
|
723
|
+
|
|
724
|
+
The same read as `library_files_get` arguments:
|
|
725
|
+
|
|
726
|
+
```json
|
|
727
|
+
{
|
|
728
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
729
|
+
"file_id": "9d8c7b6a-5f4e-4d3c-8b2a-190807f6e5d4",
|
|
730
|
+
"directory": "/home/me/adelin-files"
|
|
731
|
+
}
|
|
732
|
+
```
|
|
733
|
+
|
|
734
|
+
### Receipts, retries and recovery
|
|
735
|
+
|
|
736
|
+
A file write's receipt is `{operationId, entryId, outcome, file: {fileId, fileName, contentType, sizeBytes, slot | target and language}, replacedFileId, converted, cleanupCount, mutationRevision, replayed}`. The file is read once and exactly those bytes are hashed and sent, so a file that changes is never half-sent; `FILE_CHANGED` means the bytes no longer matched what was granted: send it again. A byte request may take 30 seconds plus the file size at 128 KiB per second, at most 180 seconds.
|
|
737
|
+
|
|
738
|
+
Re-running the identical command with the same `operation_id` after a lost response returns the stored receipt with `replayed: true`, sends no bytes, and finishes removing a replaced file if that was interrupted. The same applies to `library_mutate` file actions, and a `cleanup.state` of `pending` resumes with the identical request. `operation.inspect` returns any of these stored receipts without retrying. Retry `RETRYABLE_CONFLICT`, `MUTATION_UNAVAILABLE`, `AGENT_FILES_RATE_LIMITED`, `AGENT_FILES_UNAVAILABLE`, `INVALID_REQUEST`, `REQUEST_TIMEOUT` and lost responses with the identical request. `CONFLICT` carries `latestState` with the entry's file state and the current `mutationRevision`: read again and send a new `operation_id`. Reusing an `operation_id` with a different file or payload returns `OPERATION_PAYLOAD_CONFLICT`. `BILLING_*` refusals carry `status` and `pointKey`; other refusals are `INVALID_ARGUMENT` naming the field, `ACCESS_DENIED`, `NOT_FOUND`, `AUTH_REQUIRED` and `FILE_TOO_LARGE`. A save stopped by a refused file is not rolled back: earlier steps stay, so correct the refused step and send it under a new `operation_id`.
|
|
739
|
+
|
|
740
|
+
## Languages
|
|
741
|
+
|
|
742
|
+
An app has 1 to 20 languages in order; the first is the primary language. Read them with `adelin library schema --app UUID --section languages` or `library_schema` with `section: "languages"`: each item is `{language, primary}`, in the app's order. Tags are canonical, such as `en`, `lt` or `pt-BR`. The rule on which translations you may write is in [content-binding.md](content-binding.md).
|
|
743
|
+
|
|
744
|
+
Titles, descriptions, label, field, sub-field and collection names, and translatable field values are language maps keyed by those tags. Creating needs at least one app language. An edit changes only the languages it names, `null` removes one, and a title or name always keeps at least one. Text in a language the app does not have is refused. Removing a language from the app is never refused and deletes all its text and images: an entry or collection titled only in it is left untitled (a published entry stays published, viewers see an empty title, and the dashboard flags it until a title is added), and a label, field or sub-field named only in it is renamed to its key in the new first language.
|
|
745
|
+
|
|
746
|
+
Viewers see their own language. A text value or artwork image missing in it comes from the next language that has one: the viewer's language, its regional parent and base language (`pt-BR`, then `pt`), the primary, then the other app languages in order. Every artwork image belongs to one app language; an upload without a language belongs to the first.
|
|
747
|
+
|
|
748
|
+
On the CLI, `--title`, `--description` and `--name` each set one language and need `--language TAG`; without it the command is refused and names the languages read. An empty value in an edit removes that language. Add a Lithuanian title:
|
|
749
|
+
|
|
750
|
+
`adelin library mutate --app APP --operation-id OP --expected-revision REV --action entry.patch --entry ENTRY --language lt --title "Žiemos sodas"`
|
|
751
|
+
|
|
752
|
+
To change several languages at once, send JSON. This adds Lithuanian and Polish titles and removes the Lithuanian description:
|
|
753
|
+
|
|
754
|
+
```json
|
|
755
|
+
{
|
|
756
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
757
|
+
"operation_id": "7a8b9c0d-1e2f-4a3b-8c4d-5e6f7a8b9c0d",
|
|
758
|
+
"expected_revision": "81",
|
|
759
|
+
"action": "entry.patch",
|
|
760
|
+
"payload": {
|
|
761
|
+
"entry_id": "5c4b3a29-1807-4f6e-8d5c-4b3a29180716",
|
|
762
|
+
"patch": { "title": { "lt": "Žiemos sodas", "pl": "Zimowy ogród" }, "description": { "lt": null } }
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
```
|
|
766
|
+
|
|
767
|
+
### Translatable fields
|
|
768
|
+
|
|
769
|
+
Text, a list of text and a text sub-field of a group can be translatable. Create the field with `localized: true` in its type, such as `{"k": "string", "localized": true}` or `{"k": "array", "of": {"k": "string"}, "localized": true}`. Its values are language maps, and a translatable list holds a whole list per language. `entry.fields.patch` `set` merges a translatable value per language like a name edit: `{"tagline": {"lt": "Pavasaris ateina"}}` changes only Lithuanian.
|
|
770
|
+
|
|
771
|
+
`field.localized` takes `{key, prop?, localized}`, with `prop` naming one sub-field of a group (`--key`, `--prop` and `--localized true|false` on the CLI). Turning translation on keeps every value as the primary language and needs no preview. Turning it off needs a preview and confirmation, because each value keeps only its first language in the app's order and the other languages are deleted:
|
|
772
|
+
|
|
773
|
+
```json
|
|
774
|
+
{
|
|
775
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
776
|
+
"operation_id": "8b9c0d1e-2f3a-4b4c-9d5e-6f7a8b9c0d1e",
|
|
777
|
+
"expected_revision": "82",
|
|
778
|
+
"action": "field.localized",
|
|
779
|
+
"mode": "preview",
|
|
780
|
+
"payload": { "key": "tagline", "localized": false }
|
|
781
|
+
}
|
|
782
|
+
```
|
|
783
|
+
|
|
784
|
+
### Translated names
|
|
785
|
+
|
|
786
|
+
`label.rename`, `field.rename` and `collection.update` edit names per language. A `field.rename` `typeSpec` may change only sub-field names, each a language map; the field's type stays. Add a Lithuanian label name:
|
|
787
|
+
|
|
788
|
+
```json
|
|
789
|
+
{
|
|
790
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
791
|
+
"operation_id": "9c0d1e2f-3a4b-4c5d-8e6f-7a8b9c0d1e2f",
|
|
792
|
+
"expected_revision": "83",
|
|
793
|
+
"action": "label.rename",
|
|
794
|
+
"payload": { "key": "kids", "name": { "lt": "Vaikams" } }
|
|
795
|
+
}
|
|
796
|
+
```
|
|
797
|
+
|
|
798
|
+
### App languages
|
|
799
|
+
|
|
800
|
+
`app.languages.set` takes `{locales}`: the complete ordered list of 1 to 20 distinct tags, the first being the primary language. On the CLI it comes only from `--input`. Adding or reordering languages, including choosing a new primary, commits at once. Removing a language permanently deletes data (see [Languages](#languages)), so it always takes two steps. A request that removes a language without a confirmation deletes nothing and returns `CONFIRMATION_REQUIRED` with `removal: {removed, translations, untitledEntries, untitledCollections, namesFromKeys, artwork}`: the languages, the entries, labels, fields and collections holding text in them, the entries and collections left untitled, the names that become their key, and the images deleted. The preview repeats these counts as a `languageImpact` item. Show the builder this impact in plain words and ask them to confirm; send the confirmation only after they agree. The receipt has `affectedIds: [app_id]`, the same `removal`, and `cleanup` with `retryAction: "app.languages.set"`; when `cleanup.state` is `"pending"`, retry the same operation and payload to finish removing files. The preview step of removing Polish:
|
|
801
|
+
|
|
802
|
+
```json
|
|
803
|
+
{
|
|
804
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
805
|
+
"operation_id": "0d1e2f3a-4b5c-4d6e-9f7a-8b9c0d1e2f3a",
|
|
806
|
+
"expected_revision": "84",
|
|
807
|
+
"action": "app.languages.set",
|
|
808
|
+
"mode": "preview",
|
|
809
|
+
"payload": { "locales": ["en", "lt"] }
|
|
810
|
+
}
|
|
811
|
+
```
|
|
812
|
+
|
|
813
|
+
Per-language artwork is under [Artwork](#artwork), and the first-publish title rule under [Publish](#publish).
|
|
814
|
+
|
|
815
|
+
## Media library
|
|
816
|
+
|
|
817
|
+
The media library holds the app's uploaded video and audio files and its transcode profiles. Every media command checks the app approval on each call. Replies carry metadata only: never a playable or signed URL, a storage key, a credential or file bytes. A remote reply that carries a URL or a signed query is refused as `MEDIA_UNAVAILABLE` instead of being shown. `adelin media --help` lists every command, and `adelin media <command> --help` shows one.
|
|
818
|
+
|
|
819
|
+
### Media at a glance
|
|
820
|
+
|
|
821
|
+
| Command | Local MCP tool or `media_mutate` action | Approval | Confirmation |
|
|
822
|
+
|---|---|---|---|
|
|
823
|
+
| `adelin media list` | `media_list` | `library.view` | none |
|
|
824
|
+
| `adelin media get` / `status` | `media_get` / `media_status` | `library.view` | none |
|
|
825
|
+
| `adelin media used-in` | `media_used_in` | `library.view` | none |
|
|
826
|
+
| `adelin media profiles` | `media_profiles` | `library.view` | none |
|
|
827
|
+
| `adelin media recently-deleted` | `media_recently_deleted` | `library.view` | none |
|
|
828
|
+
| `adelin media check FILE` | `media_check` | none; runs on this computer | none |
|
|
829
|
+
| `adelin media upload FILE` | `media_upload` | `library.manage` and the Adelin CLI sign-in | none |
|
|
830
|
+
| `adelin media upload status` | `media_upload_status` | none; reads the local job | none |
|
|
831
|
+
| `adelin media session` | `media_session` | `library.view` and the Adelin CLI sign-in | none |
|
|
832
|
+
| `adelin media cancel` | `media_cancel` | `library.manage` and the Adelin CLI sign-in | none |
|
|
833
|
+
| `adelin media complete` | `media_complete` | `library.manage` and the Adelin CLI sign-in | none |
|
|
834
|
+
| `adelin media rename` | `asset.rename` | `library.manage` | `expected_snapshot` |
|
|
835
|
+
| `adelin media delete` | `asset.delete` | `library.manage` | preview, then `confirmation` |
|
|
836
|
+
| `adelin media restore` | `asset.restore` | `library.manage` | the user asks for it |
|
|
837
|
+
| `adelin media transcode` | `asset.transcode` | `library.manage` | `expected_snapshot` |
|
|
838
|
+
| `adelin media delete-original` | `original.delete` | `library.manage` | preview, the user's yes in the chat, then `payload.preview_id` |
|
|
839
|
+
| `adelin media profile create` / `duplicate` | `profile.create` / `profile.duplicate` | `library.manage` | none |
|
|
840
|
+
| `adelin media profile update` / `delete` / `default` | `profile.update` / `profile.delete` / `profile.default` | `library.manage` | `expected_profiles_revision`; delete has no preview |
|
|
841
|
+
| `adelin media inspect` | `operation.inspect` | `library.view` | read-only |
|
|
842
|
+
| `adelin media preview-page` | `preview.page` | `library.manage` | read-only |
|
|
843
|
+
|
|
844
|
+
Upload commands require the explicit local-transfer approval described under [sign-in](#sign-in-and-credentials); a connection without it gets `ACCESS_DENIED`. `NOT_FOUND` never tells an unknown upload from one in another app. Removing the app or the approval makes the next call return `ACCESS_DENIED`. Invalid flags or arguments return `INVALID_ARGUMENT` naming the field before any request is sent. `RETRYABLE_CONFLICT` means another writer held the upload or the profiles for a moment. File-transfer commands retry the identical operation up to six times, waiting 2, 4, 8, 16 and 30 seconds; other media commands return the conflict for review. A failed asset cannot be completed again: `media complete` returns `UPLOAD_NOT_RESUMABLE` with reason `failed` or the canonical `abandoned` disposition, never an `uploaded` success.
|
|
845
|
+
|
|
846
|
+
Upload sessions belong to the authorized connection that started them. Use that connection to inspect a session, resume, sign parts, complete or cancel it; another connection receives `NOT_FOUND`. `media get` and `media status` remain authorized app reads. To cancel another connection's upload in an app you manage, use `media delete` with its preview and confirmation.
|
|
847
|
+
|
|
848
|
+
### Reads and filters
|
|
849
|
+
|
|
850
|
+
| CLI syntax | Local MCP tool | Result |
|
|
851
|
+
|---|---|---|
|
|
852
|
+
| `adelin media list --app UUID` | `media_list` | One page of uploads, plus `counts` (all, video, audio) and `totalBytes` |
|
|
853
|
+
| `adelin media get --app UUID --asset UUID` | `media_get` | One upload with technical details and its `snapshot` |
|
|
854
|
+
| `adelin media used-in --app UUID --asset UUID` | `media_used_in` | The entries that use an upload |
|
|
855
|
+
| `adelin media status --app UUID --asset UUID` | `media_status` | A compact status receipt, optionally after waiting for a change |
|
|
856
|
+
| `adelin media profiles --app UUID` | `media_profiles` | Transcode profiles with their `profilesRevision` |
|
|
857
|
+
| `adelin media recently-deleted --app UUID` | `media_recently_deleted` | Deletes that can still be undone |
|
|
858
|
+
|
|
859
|
+
`media_list` takes `{app_id, kind?, status?, q?, sort?, limit?, cursor?}`; the CLI flags are `--kind video|audio`, `--status`, `--search TEXT` (`q`, at most 200 characters, trimmed), `--sort newest|name|size` (newest is the default), `--limit 1..100` (default 50) and `--cursor`. The status filter is one of `uploading`, `probing`, `awaiting_options`, `queued`, `processing`, `ready` or `failed`. Each item has `id`, `name`, `originalFilename`, `kind`, `sizeBytes`, `status`, `stage`, `profileName`, `details`, `failureReason`, `canRetranscode`, `original`, `deleteOriginal`, `usedInCount`, up to five `usedIn` records and its `snapshot`.
|
|
860
|
+
|
|
861
|
+
Adelin keeps every original file until it is deleted (see [Deleting original files](#deleting-original-files)). `original` is `kept` or `deleted`. `deleteOriginal` says what deleting the original would do: `{effect, freesBytes, restorable}`, where `effect` is `original_only` when an entry uses the transcoded video (it keeps streaming) and `whole_upload` otherwise (the original and any transcoded output go). `restorable` is false while Adelin is still working on an unused upload: deleting it then takes effect at once and cannot be undone. It is null while the upload is uploading, probing, queued or processing, or when there is nothing to delete. The list leaves out uploads whose original was deleted, except failed ones; `media_get` still reads them by id.
|
|
862
|
+
|
|
863
|
+
`media_get` and `adelin media get --asset UUID` add `technical` (duration, resolution or channels, and audio tracks), `thumbnailCount`, `retranscodeFailureReason`, `createdAt`, `readyAt`, `playable` and `restorableUntil` (until when `asset.restore` can undo the upload's delete, or null). `media_recently_deleted` (`[--limit] [--cursor]`) pages `{uploadId, name, kind, sizeBytes, effect, restorableUntil}` for every delete that can still be undone, soonest deadline first. `media_used_in` (`--asset UUID [--limit] [--cursor]`) pages `{entryId, title, source}`: `source` is `live` when the published entry uses the upload and `pending` when only staged changes do. `media_profiles` returns the profiles in dashboard order (default first) as `{id, name, maxHeight, scrubPreviews, segmentSeconds, isDefault}`.
|
|
864
|
+
|
|
865
|
+
Pages follow the library rules: pass `nextCursor` back with the same filters and stop when it is null. A page stops early once it would pass 32 KiB, so `returned` can be below `limit` while `nextCursor` is set. Changed filters or sort on a cursor return `STALE_CURSOR`, as does a used-in cursor after the references change: restart from the first page. A malformed or expired cursor returns `INVALID_CURSOR`. One oversized item returns `READ_ITEM_TOO_LARGE`.
|
|
866
|
+
|
|
867
|
+
```sh
|
|
868
|
+
adelin media list --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --kind video --status ready --sort size --limit 20
|
|
869
|
+
```
|
|
870
|
+
|
|
871
|
+
The same read as `media_list` arguments:
|
|
872
|
+
|
|
873
|
+
```json
|
|
874
|
+
{
|
|
875
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
876
|
+
"kind": "video",
|
|
877
|
+
"status": "ready",
|
|
878
|
+
"sort": "size",
|
|
879
|
+
"limit": 20
|
|
880
|
+
}
|
|
881
|
+
```
|
|
882
|
+
|
|
883
|
+
### Snapshots and teardown
|
|
884
|
+
|
|
885
|
+
Each upload carries a `snapshot`, a token over its name, status, kind, size and transcode generation. Upload changes bind to it, so read again before acting when it changes. Stage changes during processing do not change it. `profilesRevision` does the same for the whole profile list.
|
|
886
|
+
|
|
887
|
+
An upload being cancelled or deleted reads as `removing`, and a finished one as `removed`, with no stage or failure reason. Lists never show them; `media_get` and `media_status` do.
|
|
888
|
+
|
|
889
|
+
### Waiting for status
|
|
890
|
+
|
|
891
|
+
`media_status` takes `{app_id, asset_id, wait_seconds?}`. With `wait_seconds` from 1 to 25 it waits up to that long for the next change of `status` or `stage`, then returns. The `stage` of a queued or processing upload is `queued`, `validating`, `downloading`, `transcoding`, `uploading` or `finalizing`; there is no percentage. The receipt is `{asset: {id, name, kind, status, stage, failureReason, retranscodeFailureReason, canRetranscode, original, playable, snapshot}, wait: {seconds, waitedSeconds, polls, changed, timedOut, from, lastError}}`. Call it again to keep waiting.
|
|
892
|
+
|
|
893
|
+
From the CLI, `adelin media status --asset UUID --wait [--timeout S]` waits up to S seconds (1 to 3600, default 120). Polls start 5 seconds apart and slow to one every 15 seconds. A busy or briefly unavailable service also slows polling to 15 seconds and is reported in `wait.lastError` if it lasts until the timeout. The observed transition is written to stderr as one JSON line, and stdout carries only the final receipt. `--timeout` without `--wait` is refused.
|
|
894
|
+
|
|
895
|
+
```sh
|
|
896
|
+
adelin media status --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --asset 5c4b3a29-1807-4f6e-8d5c-4b3a29180716 --wait --timeout 10
|
|
897
|
+
```
|
|
898
|
+
|
|
899
|
+
The same wait as `media_status` arguments:
|
|
900
|
+
|
|
901
|
+
```json
|
|
902
|
+
{
|
|
903
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
904
|
+
"asset_id": "5c4b3a29-1807-4f6e-8d5c-4b3a29180716",
|
|
905
|
+
"wait_seconds": 10
|
|
906
|
+
}
|
|
907
|
+
```
|
|
908
|
+
|
|
909
|
+
### Uploading files
|
|
910
|
+
|
|
911
|
+
Uploads run on this computer. The CLI reads the file and sends it straight to Adelin storage in parts; the agent only sees job ids, progress counts and receipts. File bytes, part links, storage keys, part checksums and credentials never appear in stdout, in MCP results, or in the local job and upload records.
|
|
912
|
+
|
|
913
|
+
| CLI syntax | Local MCP tool | Result |
|
|
914
|
+
|---|---|---|
|
|
915
|
+
| `adelin media check FILE` | `media_check` | The local pre-check verdict: `pass`, `refuse` with the server's code, or `deferred` |
|
|
916
|
+
| `adelin media upload FILE --app UUID [--name TEXT]` | `media_upload` | A background job: `{jobId, state: "queued", file: {name, size}, check}` |
|
|
917
|
+
| `adelin media upload status --job UUID [--wait [--timeout S]]` | `media_upload_status` | The job's state, progress, error and next step |
|
|
918
|
+
| `adelin media session --app UUID --asset UUID [--file PATH]` | `media_session` | The upload session on the server and whether this computer can resume it |
|
|
919
|
+
| `adelin media cancel --app UUID --asset UUID` | `media_cancel` | Cancels an upload in progress and stops its local job |
|
|
920
|
+
| `adelin media complete --app UUID --asset UUID [--file PATH]` | `media_complete` | Finishes an upload whose parts are all stored |
|
|
921
|
+
|
|
922
|
+
`media_check` takes `{path}`. It applies the media upload policy (extension, declared type, size), then, when `ffprobe` is on PATH, the server's probe rules. A refusal uses the server's code (`MEDIA_FILE_INVALID`, `MEDIA_EXTENSION_REQUIRED`, `MEDIA_EXTENSION_NOT_ALLOWED`, `MEDIA_MIME_NOT_ALLOWED`, `MEDIA_SIZE_INVALID`, `MEDIA_SIZE_EXCEEDED`, `SOURCE_UNSUPPORTED`, `SOURCE_TOO_SMALL`). Without `ffprobe` the verdict is `deferred`. Every local verdict is advisory; the server probe is final.
|
|
923
|
+
|
|
924
|
+
```sh
|
|
925
|
+
adelin media check /home/me/videos/trailer.mp4
|
|
926
|
+
```
|
|
927
|
+
|
|
928
|
+
The same check as `media_check` arguments:
|
|
929
|
+
|
|
930
|
+
```json
|
|
931
|
+
{
|
|
932
|
+
"path": "/home/me/videos/trailer.mp4"
|
|
933
|
+
}
|
|
934
|
+
```
|
|
935
|
+
|
|
936
|
+
`media_upload` takes `{app_id, path, name?, transcode?}`; `name` (1 to 200 characters) is the upload's title and defaults to the file name. It runs the same pre-check first, and a refusal starts nothing. Otherwise it writes a private job record (0600) and starts a background process, then returns at once. A relative path resolves against the working directory. `upload status` reads a job, so a file literally named `status` is passed as `./status`. The upload ends when the file is stored and the server probe is queued. Without `transcode` it never starts a transcode; see [Transcoding after an upload](#transcoding-after-an-upload).
|
|
937
|
+
|
|
938
|
+
```sh
|
|
939
|
+
adelin media upload /home/me/videos/trailer.mp4 --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --name Trailer
|
|
940
|
+
```
|
|
941
|
+
|
|
942
|
+
The same upload as `media_upload` arguments:
|
|
943
|
+
|
|
944
|
+
```json
|
|
945
|
+
{
|
|
946
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
947
|
+
"path": "/home/me/videos/trailer.mp4",
|
|
948
|
+
"name": "Trailer"
|
|
949
|
+
}
|
|
950
|
+
```
|
|
951
|
+
|
|
952
|
+
`media_upload_status` takes `{job_id, wait_seconds?}` (0 to 25) and returns `{jobId, state, assetId, file, bytesSent, partsDone, partCount, resumedParts, concurrency, error, next, outcome, transcode}`. `state` is `queued`, `hashing`, `starting`, `transferring`, `finalizing`, `uploaded`, `failed`, `cancelled` or `interrupted`. `bytesSent` and `partsDone` count every stored part, including `resumedParts`; `concurrency` is the number of parts in flight. With `wait_seconds` it waits for the next state change and adds `wait: {seconds, waitedSeconds, changed, timedOut}`; a finished job returns at once. It reads only the local job record, so polling it costs nothing remote. From the CLI, `--wait` waits up to `--timeout` seconds (1 to 3600, default 120). A finished job carries `outcome: {outcome: "uploaded", assetId, status, probe: "queued"|"deferred", transfer: {parts, bytes, resumedParts}}`; follow the probe with `media_status`.
|
|
953
|
+
|
|
954
|
+
```sh
|
|
955
|
+
adelin media upload status --job 2b7e1f0a-5c3d-4e9f-8a1b-6c5d4e3f2a10 --wait --timeout 25
|
|
956
|
+
```
|
|
957
|
+
|
|
958
|
+
The same read as `media_upload_status` arguments:
|
|
959
|
+
|
|
960
|
+
```json
|
|
961
|
+
{
|
|
962
|
+
"job_id": "2b7e1f0a-5c3d-4e9f-8a1b-6c5d4e3f2a10",
|
|
963
|
+
"wait_seconds": 25
|
|
964
|
+
}
|
|
965
|
+
```
|
|
966
|
+
|
|
967
|
+
#### Parts, resume and the 48-hour window
|
|
968
|
+
|
|
969
|
+
The CLI sends several parts at once and adapts how many to the connection (one to six), renews part links before they expire, retries each part a bounded number of times, and asks for at most 50 part links per request. When Adelin limits requests it backs off from 2 seconds, doubling to 30 seconds, and after six tries stops with `MEDIA_RATE_LIMITED`.
|
|
970
|
+
|
|
971
|
+
Each stored part is recorded in a private upload record on this computer, bound to the app, the file's size and SHA-256 hash, and the upload session. To resume, run the same upload again with the same file: it hashes the file, checks the session with the server, and sends only the missing parts. A file that changed never resumes into the old session; it starts a new upload. A file that changes while it is being read stops the job with `FILE_CHANGED` and nothing is completed. Stopping the process (Ctrl-C or a signal) saves the record and leaves the server session open; the job reads `interrupted` with the next step. A job whose process died also reads `interrupted`.
|
|
972
|
+
|
|
973
|
+
An unfinished upload session is kept for 48 hours from when the upload started, not from the last activity; sending parts does not extend it. A resume is refused with `UPLOAD_NOT_RESUMABLE` and a `reason`: `expired_window` in the last 10 minutes before that, `abandoned` after it, `cancelled` once the upload was cancelled, `state` when it already finished or failed, `upload_id` when the session was replaced, and `file_changed` when the given file is not the one recorded. Run the upload again to start a new one. Another upload of the same file already running on this computer returns `MEDIA_UPLOAD_IN_PROGRESS`.
|
|
974
|
+
|
|
975
|
+
#### Session, cancel and complete
|
|
976
|
+
|
|
977
|
+
`media_session` takes `{app_id, asset_id, path?}` and returns `{assetId, status, createdAt, abandonAt, partSize, partCount, serverParts, journal: {present, parts, matchesFile}, resumable, reason?}`. `serverParts` is the number of parts storage holds, and is null when this computer has no record of the session.
|
|
978
|
+
|
|
979
|
+
```sh
|
|
980
|
+
adelin media session --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --asset 5c4b3a29-1807-4f6e-8d5c-4b3a29180716 --file /home/me/videos/trailer.mp4
|
|
981
|
+
```
|
|
982
|
+
|
|
983
|
+
The same read as `media_session` arguments:
|
|
984
|
+
|
|
985
|
+
```json
|
|
986
|
+
{
|
|
987
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
988
|
+
"asset_id": "5c4b3a29-1807-4f6e-8d5c-4b3a29180716",
|
|
989
|
+
"path": "/home/me/videos/trailer.mp4"
|
|
990
|
+
}
|
|
991
|
+
```
|
|
992
|
+
|
|
993
|
+
`media_complete` takes `{app_id, asset_id, path?}` and sends no file data. It finishes an upload whose parts are all stored, using the parts storage reports or the local record. Use it when a job ended while finishing, for example after `REQUEST_TIMEOUT`, when the job's `next` says so. Completing again is safe: an upload that already finished returns its current status without a second completion. Missing parts return `MEDIA_UPLOAD_INCOMPLETE` with `missingParts`; run the upload again to send them. No local record returns `MEDIA_JOURNAL_MISSING`.
|
|
994
|
+
|
|
995
|
+
```sh
|
|
996
|
+
adelin media complete --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --asset 5c4b3a29-1807-4f6e-8d5c-4b3a29180716 --file /home/me/videos/trailer.mp4
|
|
997
|
+
```
|
|
998
|
+
|
|
999
|
+
The same completion as `media_complete` arguments:
|
|
1000
|
+
|
|
1001
|
+
```json
|
|
1002
|
+
{
|
|
1003
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
1004
|
+
"asset_id": "5c4b3a29-1807-4f6e-8d5c-4b3a29180716",
|
|
1005
|
+
"path": "/home/me/videos/trailer.mp4"
|
|
1006
|
+
}
|
|
1007
|
+
```
|
|
1008
|
+
|
|
1009
|
+
`media_cancel` takes `{app_id, asset_id}` and needs no preview. It stops a local job for that upload, cancels the session, and removes the local record; `stoppedJobs` counts the jobs it stopped. An upload used by an entry returns `MEDIA_ASSET_IN_USE`, and one that is no longer in progress returns `MEDIA_CANCEL_NOT_ALLOWED`. The reply carries `state` (`cancelling`, or `already_cancelled` when the upload was already cancelled) and `storageAbort`: `done` when storage stopped the upload at once, `deferred` when Adelin's cleanup will stop it, or `not_needed`. The upload then reads `removing` until cleanup finishes, and `removed` after it. Cancellation or revocation stops new links and blocks finalization immediately. Adelin records a create attempt before contacting storage and each exact-owned multipart ID before issuing a part link. If a create response is lost, cleanup repeatedly checks only that reserved source key after a 45-second grace period; an empty result keeps the recovery obligation. Cleanup fences attachment before aborting a retired upload and retries failed aborts. The next media reconciliation pass also aborts revoked uploads. Already issued links can remain usable until that abort succeeds, with their expiry as the fallback.
|
|
1010
|
+
|
|
1011
|
+
```sh
|
|
1012
|
+
adelin media cancel --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --asset 5c4b3a29-1807-4f6e-8d5c-4b3a29180716
|
|
1013
|
+
```
|
|
1014
|
+
|
|
1015
|
+
The same cancel as `media_cancel` arguments:
|
|
1016
|
+
|
|
1017
|
+
```json
|
|
1018
|
+
{
|
|
1019
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
1020
|
+
"asset_id": "5c4b3a29-1807-4f6e-8d5c-4b3a29180716"
|
|
1021
|
+
}
|
|
1022
|
+
```
|
|
1023
|
+
|
|
1024
|
+
Other refusals: `MEDIA_JOB_NOT_FOUND` for an unknown job id, `MEDIA_UPLOAD_PART_FAILED` when a part keeps failing (resume later), `MEDIA_JOURNAL_INVALID` when a local record is not private, `AUTH_REQUIRED` when the CLI is signed out, and `BILLING_*` with `status` 402, 403, 409 or 503 when the plan does not allow the upload.
|
|
1025
|
+
|
|
1026
|
+
### Changing and transcoding uploads
|
|
1027
|
+
|
|
1028
|
+
Upload changes go through `media_mutate`, or the matching CLI command:
|
|
1029
|
+
|
|
1030
|
+
| CLI syntax | `media_mutate` action | Result |
|
|
1031
|
+
|---|---|---|
|
|
1032
|
+
| `adelin media rename --app UUID --asset UUID --operation-id UUID --name TEXT --snapshot S` | `asset.rename` | `{operationId, state, assetId, name, snapshot}` |
|
|
1033
|
+
| `adelin media delete --app UUID --asset UUID --operation-id UUID [--mode preview\|commit] [--confirmation-file FILE]` | `asset.delete` | A preview, or `{operationId, state, assetId, outcome, restorableUntil?, storageCleanup}` |
|
|
1034
|
+
| `adelin media restore --app UUID --asset UUID --operation-id UUID` | `asset.restore` | `{operationId, state: "restored", assetId, effect}` |
|
|
1035
|
+
| `adelin media transcode --app UUID --asset UUID --operation-id UUID --profile UUID\|default --snapshot S [--wait [--timeout S]]` | `asset.transcode` | `{operationId, state: "queued", assetId, generation, profile: {id, name}, enqueue}` |
|
|
1036
|
+
| `adelin media delete-original --app UUID --asset UUID [--asset UUID ...] [--confirm PREVIEW_ID]` | `original.delete` | A preview `{state: "preview", uploads, skipped, totalFreesBytes, previewId, expiresAt, message}`, or `{state: "deleted" | "not_deleted", results, skipped, message}` |
|
|
1037
|
+
| `adelin media inspect --app UUID --operation UUID` | `operation.inspect` | The stored receipt of an earlier media change or upload start |
|
|
1038
|
+
| `adelin media preview-page --app UUID --preview UUID --cursor TOKEN` | `preview.page` | A page of a stored delete preview |
|
|
1039
|
+
|
|
1040
|
+
Every change except `original.delete` sends `{app_id, action, operation_id, payload}` and the reply is `{ok, action, appId, data}`. Use a new `operation_id` for each change. To retry after a timeout or a lost reply, resend the same request with the same `operation_id`: Adelin returns the stored receipt with `replayed: true` and changes nothing twice. The same `operation_id` with a different request returns `OPERATION_PAYLOAD_CONFLICT`. `--input FILE` passes the whole `media_mutate` request from a JSON file instead of flags; its `action` must match the command.
|
|
1041
|
+
|
|
1042
|
+
Changes bind to the upload's `snapshot` (`expected_snapshot`), never to the library revision. When the upload changed since your read, the change returns `CONFLICT` with `latestState: {id, status, name, snapshot}`; check it, then resend with the new snapshot and a new `operation_id`. Every upload change, including stage changes during processing, still advances the app's library revision, so read `mutationRevision` again before the next entry edit.
|
|
1043
|
+
|
|
1044
|
+
#### Rename
|
|
1045
|
+
|
|
1046
|
+
`asset.rename` takes `{asset_id, name, expected_snapshot}`. The name is trimmed and must be 1 to 200 characters. The receipt's `state` is `renamed`, or `unchanged` when the name was already the same, and carries the new `snapshot`.
|
|
1047
|
+
|
|
1048
|
+
```sh
|
|
1049
|
+
adelin media rename --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --asset 5c4b3a29-1807-4f6e-8d5c-4b3a29180716 --operation-id 0d9e8f7a-6b5c-4d3e-8f2a-1b0c9d8e7f6a --name Trailer --snapshot 3f2a1b0c9d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b2c1d0e9f8a7b6c5d4e3f2a
|
|
1050
|
+
```
|
|
1051
|
+
|
|
1052
|
+
The same rename as `media_mutate` arguments:
|
|
1053
|
+
|
|
1054
|
+
```json
|
|
1055
|
+
{
|
|
1056
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
1057
|
+
"action": "asset.rename",
|
|
1058
|
+
"operation_id": "0d9e8f7a-6b5c-4d3e-8f2a-1b0c9d8e7f6a",
|
|
1059
|
+
"payload": {
|
|
1060
|
+
"asset_id": "5c4b3a29-1807-4f6e-8d5c-4b3a29180716",
|
|
1061
|
+
"name": "Trailer",
|
|
1062
|
+
"expected_snapshot": "3f2a1b0c9d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b2c1d0e9f8a7b6c5d4e3f2a"
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
```
|
|
1066
|
+
|
|
1067
|
+
#### Delete with a preview
|
|
1068
|
+
|
|
1069
|
+
`asset.delete` takes `{asset_id}` and always starts with a preview. Send `mode: "preview"` first. The preview has one item, `{type: "asset", id, name, sizeBytes, kind, status, outcome, usedInCount}`, and carries `digest`, `acknowledgement` and a ready `data.confirmation` of `{preview_id, digest, acknowledgement}`.
|
|
1070
|
+
|
|
1071
|
+
```sh
|
|
1072
|
+
adelin media delete --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --asset 5c4b3a29-1807-4f6e-8d5c-4b3a29180716 --operation-id 1e0f9a8b-7c6d-4e5f-9a3b-2c1d0e9f8a7b --mode preview
|
|
1073
|
+
```
|
|
1074
|
+
|
|
1075
|
+
The same preview as `media_mutate` arguments:
|
|
1076
|
+
|
|
1077
|
+
```json
|
|
1078
|
+
{
|
|
1079
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
1080
|
+
"action": "asset.delete",
|
|
1081
|
+
"operation_id": "1e0f9a8b-7c6d-4e5f-9a3b-2c1d0e9f8a7b",
|
|
1082
|
+
"mode": "preview",
|
|
1083
|
+
"payload": {
|
|
1084
|
+
"asset_id": "5c4b3a29-1807-4f6e-8d5c-4b3a29180716"
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
```
|
|
1088
|
+
|
|
1089
|
+
Then send the same request with the same `operation_id`, without `mode` (or with `mode: "commit"`) and with `confirmation` set to `data.confirmation`. From the CLI, save `data.confirmation` to a file and pass it with `--confirmation-file`.
|
|
1090
|
+
|
|
1091
|
+
```sh
|
|
1092
|
+
adelin media delete --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --asset 5c4b3a29-1807-4f6e-8d5c-4b3a29180716 --operation-id 1e0f9a8b-7c6d-4e5f-9a3b-2c1d0e9f8a7b --confirmation-file confirm.json
|
|
1093
|
+
```
|
|
1094
|
+
|
|
1095
|
+
The same commit as `media_mutate` arguments, with `confirm.json` holding the `confirmation` object:
|
|
1096
|
+
|
|
1097
|
+
```json
|
|
1098
|
+
{
|
|
1099
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
1100
|
+
"action": "asset.delete",
|
|
1101
|
+
"operation_id": "1e0f9a8b-7c6d-4e5f-9a3b-2c1d0e9f8a7b",
|
|
1102
|
+
"confirmation": {
|
|
1103
|
+
"preview_id": "9b8a7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
|
|
1104
|
+
"digest": "4a3b2c1d0e9f8a7b6c5d4e3f2a1b0c9d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b",
|
|
1105
|
+
"acknowledgement": "5b4c3d2e1f0a9b8c7d6e5f4a3b2c1d0e9f8a7b6c5d4e3f2a1b0c9d8e7f6a5b4c"
|
|
1106
|
+
},
|
|
1107
|
+
"payload": {
|
|
1108
|
+
"asset_id": "5c4b3a29-1807-4f6e-8d5c-4b3a29180716"
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
```
|
|
1112
|
+
|
|
1113
|
+
The commit's `outcome` is `trashed` for a finished upload (ready, failed or awaiting options) with no work running, `cancelling` for an upload still sending and `deleting` for one still being probed, transcoded or with other work running; an upload that is still uploading, processing, or has work running is deleted at once, without the undo window. The preview shows which outcome applies. A trashed upload is gone everywhere straight away, but can be restored for 5 minutes, until `restorableUntil`; tell the user so. `storageCleanup` is `after_restore_window` for `trashed`, otherwise `pending`. The upload reads `removing` until its files are gone, then `removed`.
|
|
1114
|
+
|
|
1115
|
+
#### Restoring a delete
|
|
1116
|
+
|
|
1117
|
+
Deleting a finished upload or an original file can be undone for 5 minutes. Restore only when the user asks: `asset.restore` takes `{asset_id}` and an `operation_id`, and returns `{state: "restored", assetId, effect}`. `effect` `whole_upload` means the whole upload came back (with its original, if that was waiting to be deleted too); `original_only` means only the original file came back. After the time has passed, or for an upload that was never deleted, it returns `MEDIA_NOT_RESTORABLE`: tell the user it can no longer be restored. To find what can still be restored, including deletes made in the dashboard, read `media_recently_deleted`. Removing an upload's last use while its original is waiting to be deleted also moves the whole upload to the trash with the same deadline.
|
|
1118
|
+
|
|
1119
|
+
An upload used by an entry cannot be deleted: the preview returns `MEDIA_ASSET_IN_USE` with up to 20 `usedIn` records and `usedInTotal`, and stores no preview. Detach it from those entries first. An entry that starts using the upload between preview and commit also returns `MEDIA_ASSET_IN_USE`. A rename, a status change that alters the outcome, or a preview older than 15 minutes returns `STALE_PREVIEW`: preview again. A missing or mismatched confirmation returns `CONFIRMATION_REQUIRED`. Stage and progress changes keep a confirmation valid. To stop an upload that is still sending, use `media_cancel`, which needs no preview.
|
|
1120
|
+
|
|
1121
|
+
#### Transcode and wait
|
|
1122
|
+
|
|
1123
|
+
`asset.transcode` takes `{asset_id, profile_id, expected_snapshot}`; `profile_id` is a profile id from `media_profiles` or `default` for the current default profile. It starts from `awaiting_options` (a first transcode) or `ready` (a re-transcode) and queues one new generation per `operation_id`. `enqueue` is `done`, or `deferred` when the queue was briefly unavailable and Adelin will queue it shortly; a replayed receipt has no `enqueue`. `canRetranscode` in `media_get` tells you whether a ready upload can be transcoded again.
|
|
1124
|
+
|
|
1125
|
+
Follow a transcode through local MCP with `media_status` and `wait_seconds`. From the CLI, `--wait` follows it to the end: polls start 5 seconds apart and slow to one every 15 seconds, for up to `--timeout` seconds (1 to 3600, default 900). Each change of status or stage (`queued`, `validating`, `downloading`, `transcoding`, `uploading`, `finalizing`) goes to stderr as one JSON line, and stdout carries the receipt with `wait: {seconds, waitedSeconds, polls, timedOut, lastError, status, stage, outcome, reason, next}`. `outcome` is `ready`, `failed`, `removed`, or null when the wait timed out or a read was refused (`lastError`).
|
|
1126
|
+
|
|
1127
|
+
```sh
|
|
1128
|
+
adelin media transcode --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --asset 5c4b3a29-1807-4f6e-8d5c-4b3a29180716 --operation-id 2f1a0b9c-8d7e-4f6a-8b4c-3d2e1f0a9b8c --profile default --snapshot 3f2a1b0c9d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b2c1d0e9f8a7b6c5d4e3f2a --wait --timeout 600
|
|
1129
|
+
```
|
|
1130
|
+
|
|
1131
|
+
The same start as `media_mutate` arguments (MCP never waits inside the change; follow it with `media_status`):
|
|
1132
|
+
|
|
1133
|
+
```json
|
|
1134
|
+
{
|
|
1135
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
1136
|
+
"action": "asset.transcode",
|
|
1137
|
+
"operation_id": "2f1a0b9c-8d7e-4f6a-8b4c-3d2e1f0a9b8c",
|
|
1138
|
+
"payload": {
|
|
1139
|
+
"asset_id": "5c4b3a29-1807-4f6e-8d5c-4b3a29180716",
|
|
1140
|
+
"profile_id": "default",
|
|
1141
|
+
"expected_snapshot": "3f2a1b0c9d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b2c1d0e9f8a7b6c5d4e3f2a"
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
```
|
|
1145
|
+
|
|
1146
|
+
A failed first transcode cannot be retried: the upload stays `failed` with its `failureReason`. Upload the file again. A failed re-transcode keeps the previous output: the upload stays `ready` with `retranscodeFailureReason`, and `--wait` reports `outcome: "failed"`. You cannot cancel a running transcode; delete the upload instead if it is no longer needed. Re-transcoding needs the original file. Once it has been deleted, the change returns `MEDIA_ORIGINAL_GONE` with `originalRemovedAt` (null until the file is removed, or when the time is unknown). While the deleted original can still be restored, the refusal also carries `restorableUntil`: if the user wants to transcode, restore it first with `asset.restore`. Otherwise the user must upload the file again.
|
|
1147
|
+
|
|
1148
|
+
Other refusals keep their codes and carry an HTTP `status` where Adelin gives one: `MEDIA_TRANSCODE_NOT_ALLOWED` when the upload is not `awaiting_options` or `ready`, `MEDIA_PROFILE_NOT_FOUND` for a profile outside the app, `MEDIA_ENTITLEMENT_DENIED` when the plan does not allow the profile, `MEDIA_ORGANIZATION_NOT_FOUND` and `MEDIA_ORGANIZATION_PLAN_UNAVAILABLE` for organization and plan problems, `MEDIA_UPLOAD_STORAGE_UNAVAILABLE` when storage cannot be reached, and `BILLING_*` with `status` 402, 403, 409 or 503 and `pointKey` when billing refuses the transcode. None of them starts a generation.
|
|
1149
|
+
|
|
1150
|
+
`operation.inspect` (`adelin media inspect --operation UUID`) returns the stored receipt of a rename, delete, transcode, profile change or upload start for that operation id, so you can tell whether a change whose reply was lost took effect. An unknown operation, or one from another app or connection, returns `NOT_FOUND`.
|
|
1151
|
+
|
|
1152
|
+
#### Deleting original files
|
|
1153
|
+
|
|
1154
|
+
**Rule:** never delete an original file on your own initiative. Before any deletion, show the user what will be deleted, what each upload loses and the space freed, and delete only after they confirm in the chat. A yes from earlier in the conversation, or for a different preview, does not count.
|
|
1155
|
+
|
|
1156
|
+
`original.delete` takes `{app_id, action, payload: {asset_ids, preview_id?}}`: 1 to 100 distinct upload ids, and no `operation_id`. It always takes two calls.
|
|
1157
|
+
|
|
1158
|
+
1. Send it without `preview_id`. Nothing is deleted. The reply is a preview: each upload that can be deleted as `{uploadId, name, effect, freesBytes, restorable}`, `totalFreesBytes`, each upload left out as `{uploadId, error}`, a `previewId` with its `expiresAt`, and a `message` to relay. `effect` is `original_only` when an entry uses the transcoded video: it keeps streaming, but can never be transcoded again. It is `whole_upload` when no entry uses it: the original and any transcoded output go, so the whole video is gone. `restorable` false means Adelin is still working on that unused upload, so it is deleted at once and cannot be restored: say so before asking. A left-out upload has `error` `NOT_FOUND`, `MEDIA_ORIGINAL_BUSY` (still uploading, probing or transcoding) or `MEDIA_ORIGINAL_GONE` (already deleted). When none can be deleted, the call returns `MEDIA_ORIGINAL_NOT_DELETABLE` with `skipped`.
|
|
1159
|
+
2. Tell the user, in plain words, each upload's name, what it loses and the total space freed, and ask for a yes. Only after they say yes, send the same `asset_ids` with `payload.preview_id` set to the preview's `previewId`.
|
|
1160
|
+
|
|
1161
|
+
A preview lasts 15 minutes, confirms one deletion only, and works only for the connection that made it and the same `asset_ids`. Otherwise the call deletes nothing and returns `STALE_PREVIEW`: preview again, show the user the new preview and ask again.
|
|
1162
|
+
|
|
1163
|
+
The reply to the second call is `{state, results, skipped, message}`, with one result per upload. `state` is `deleted` when at least one result is ok, and `not_deleted` when every one failed, so nothing was deleted and nothing needs restoring. Each result is `{uploadId, ok: true, effect, restorableUntil}`, `{uploadId, ok: true, effect: "whole_upload"}` for an upload deleted at once, or `{uploadId, ok: false, error}` where `error` is `MEDIA_ASSET_NOT_FOUND`, `MEDIA_ORIGINAL_BUSY`, `MEDIA_ORIGINAL_GONE`, `MEDIA_ORIGINAL_EFFECT_CHANGED` or `MEDIA_ORIGINAL_DELETE_FAILED`. Tell the user which uploads failed, and that each deleted one with a `restorableUntil` can be restored until then (see Restoring a delete); one without it cannot be restored, so never offer to undo it. When anything changed since the preview (an effect, whether it can be restored, an upload that became busy or gone, or which uploads can be deleted), the call deletes nothing and returns `MEDIA_ORIGINAL_EFFECT_CHANGED` with a fresh `uploads`, `skipped`, `totalFreesBytes`, `previewId` and `expiresAt`: show the user the new preview and ask again.
|
|
1164
|
+
|
|
1165
|
+
The preview of deleting two originals:
|
|
1166
|
+
|
|
1167
|
+
```sh
|
|
1168
|
+
adelin media delete-original --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --asset 5c4b3a29-1807-4f6e-8d5c-4b3a29180716 --asset 6d5c4b3a-2918-4f07-9e6d-5c4b3a291807
|
|
1169
|
+
```
|
|
1170
|
+
|
|
1171
|
+
The same preview as `media_mutate` arguments:
|
|
1172
|
+
|
|
1173
|
+
```json
|
|
1174
|
+
{
|
|
1175
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
1176
|
+
"action": "original.delete",
|
|
1177
|
+
"payload": {
|
|
1178
|
+
"asset_ids": ["5c4b3a29-1807-4f6e-8d5c-4b3a29180716", "6d5c4b3a-2918-4f07-9e6d-5c4b3a291807"]
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
```
|
|
1182
|
+
|
|
1183
|
+
Its `data`, which you describe to the user before asking: "Trailer keeps streaming but can no longer be re-encoded; Rough cut is not used anywhere and goes completely. This frees 2.1 GB."
|
|
1184
|
+
|
|
1185
|
+
```
|
|
1186
|
+
{
|
|
1187
|
+
"state": "preview",
|
|
1188
|
+
"uploads": [
|
|
1189
|
+
{ "uploadId": "5c4b3a29-1807-4f6e-8d5c-4b3a29180716", "name": "Trailer", "effect": "original_only", "freesBytes": 1610612736, "restorable": true },
|
|
1190
|
+
{ "uploadId": "6d5c4b3a-2918-4f07-9e6d-5c4b3a291807", "name": "Rough cut", "effect": "whole_upload", "freesBytes": 644245094, "restorable": true }
|
|
1191
|
+
],
|
|
1192
|
+
"skipped": [],
|
|
1193
|
+
"totalFreesBytes": 2254857830,
|
|
1194
|
+
"previewId": "4f3e2d1c-0b9a-4f8e-8d6c-5b4a3f2e1d0c",
|
|
1195
|
+
"expiresAt": "2026-11-15T10:15:00.000Z",
|
|
1196
|
+
"message": "Show the user what will be deleted and ask them to confirm in the chat."
|
|
1197
|
+
}
|
|
1198
|
+
```
|
|
1199
|
+
|
|
1200
|
+
After the user says yes, the deletion:
|
|
1201
|
+
|
|
1202
|
+
```sh
|
|
1203
|
+
adelin media delete-original --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --asset 5c4b3a29-1807-4f6e-8d5c-4b3a29180716 --asset 6d5c4b3a-2918-4f07-9e6d-5c4b3a291807 --confirm 4f3e2d1c-0b9a-4f8e-8d6c-5b4a3f2e1d0c
|
|
1204
|
+
```
|
|
1205
|
+
|
|
1206
|
+
The same deletion as `media_mutate` arguments:
|
|
1207
|
+
|
|
1208
|
+
```json
|
|
1209
|
+
{
|
|
1210
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
1211
|
+
"action": "original.delete",
|
|
1212
|
+
"payload": {
|
|
1213
|
+
"asset_ids": ["5c4b3a29-1807-4f6e-8d5c-4b3a29180716", "6d5c4b3a-2918-4f07-9e6d-5c4b3a291807"],
|
|
1214
|
+
"preview_id": "4f3e2d1c-0b9a-4f8e-8d6c-5b4a3f2e1d0c"
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
```
|
|
1218
|
+
|
|
1219
|
+
#### Transcoding after an upload
|
|
1220
|
+
|
|
1221
|
+
`adelin media upload FILE --app UUID --transcode default|UUID`, or `media_upload` with `transcode`, records the request in the upload job. After the file is stored, the job reads the upload every 5 seconds or slower until the server probe reaches `awaiting_options`, for at most 180 seconds, then starts the transcode with the snapshot it read and an operation id it stored when the job began, so a restarted job resends the same start and never starts a second generation. It then follows the transcode until it is `ready` or `failed`.
|
|
1222
|
+
|
|
1223
|
+
```sh
|
|
1224
|
+
adelin media upload /home/me/videos/trailer.mp4 --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --name Trailer --transcode default
|
|
1225
|
+
```
|
|
1226
|
+
|
|
1227
|
+
The same upload as `media_upload` arguments:
|
|
1228
|
+
|
|
1229
|
+
```json
|
|
1230
|
+
{
|
|
1231
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
1232
|
+
"path": "/home/me/videos/trailer.mp4",
|
|
1233
|
+
"name": "Trailer",
|
|
1234
|
+
"transcode": "default"
|
|
1235
|
+
}
|
|
1236
|
+
```
|
|
1237
|
+
|
|
1238
|
+
`media_upload_status` then fills `transcode: {requested, operationId, state, stage, generation, profile, reason, failureReason, error, next}`; it is null without `--transcode`. The job `state` stays `uploaded` once the file is stored, and the job ends when `transcode.state` is `ready`, `failed`, `not_started` or `timed_out`. Waiting on the job also returns when the transcode state or stage changes. `not_started` carries a `reason`: `probe_failed` when the server probe refused the file (see `failureReason`), `probe_pending` when the probe had not finished after 180 seconds, `refused` with the refusal in `error` (for example `MEDIA_ENTITLEMENT_DENIED` with `status` 403 when the plan does not allow the profile, or a `BILLING_*` code), and `asset_removed` when the upload was deleted meanwhile. In each case start it yourself with `media transcode` when the upload reads `awaiting_options`. `interrupted` means the job process stopped; check `media inspect` with the `operationId` to see whether the start reached Adelin, and follow it with `media status`.
|
|
1239
|
+
|
|
1240
|
+
Queued jobs resume after a clean worker process restart. An explicit operator drain remains paused until the operator resumes it; unresolved work and pending update reservations keep their existing fences.
|
|
1241
|
+
|
|
1242
|
+
### Managing transcode profiles
|
|
1243
|
+
|
|
1244
|
+
Profile changes go through `media_mutate` too, with the same `operation_id` replay and `{ok, action, appId, data}` reply as upload changes. Read the profiles first with `media_profiles` (`adelin media profiles --app UUID`).
|
|
1245
|
+
|
|
1246
|
+
| CLI syntax | `media_mutate` action | Payload |
|
|
1247
|
+
|---|---|---|
|
|
1248
|
+
| `adelin media profile create --app UUID --operation-id UUID --name TEXT [--max-height source\|480\|720\|1080\|2160] [--scrub-previews\|--no-scrub-previews] [--segment-seconds 4\|6]` | `profile.create` | `{name, maxHeight, scrubPreviews, segmentSeconds}` |
|
|
1249
|
+
| `adelin media profile update --app UUID --operation-id UUID --profile UUID --revision R [settings]` | `profile.update` | `{profile_id}` plus at least one setting |
|
|
1250
|
+
| `adelin media profile duplicate --app UUID --operation-id UUID --profile UUID` | `profile.duplicate` | `{profile_id}` |
|
|
1251
|
+
| `adelin media profile delete --app UUID --operation-id UUID --profile UUID --revision R` | `profile.delete` | `{profile_id}` |
|
|
1252
|
+
| `adelin media profile default --app UUID --operation-id UUID --profile UUID --revision R` | `profile.default` | `{profile_id}` |
|
|
1253
|
+
|
|
1254
|
+
Settings follow the dashboard's rules. `name` is trimmed and must be 1 to 80 characters, unique in the app ignoring case. `maxHeight` is 2160, 1080, 720, 480, or null to match the source (`--max-height source`). `scrubPreviews` is true or false (`--scrub-previews` or `--no-scrub-previews`). `segmentSeconds` is 4 or 6. A CLI create without these flags sends the Standard settings: 1080, no scrub previews, 6-second segments. Values outside these return `INVALID_ARGUMENT` naming the field before anything is sent. If Adelin itself refuses a value, the code is `MEDIA_PROFILE_INVALID`. A name another profile already uses returns `MEDIA_PROFILE_NAME_TAKEN`. A profile can hold settings the plan does not allow; transcoding with it then returns `MEDIA_ENTITLEMENT_DENIED`.
|
|
1255
|
+
|
|
1256
|
+
`profile.update`, `profile.delete` and `profile.default` bind to the app's profile list: send `expected_profiles_revision` (`--revision`) set to the `profilesRevision` from your latest `media_profiles` read. When any profile changed since, the change returns `CONFLICT` with the current `profilesRevision` and changes nothing. Read the profiles again, then resend with the new revision; the same `operation_id` is fine after a `CONFLICT`. `profile.create` and `profile.duplicate` take no revision. Profile changes never change an upload's snapshot or the library revision.
|
|
1257
|
+
|
|
1258
|
+
Every receipt is `{operationId, state, profileId, defaultProfileId, defaultChanged, profilesRevision}`. All but delete also carry `profile: {id, name, maxHeight, scrubPreviews, segmentSeconds, isDefault}` as it now reads. `state` is `created` for create and duplicate, `updated` or `unchanged` for update (unchanged when the values were already the same), `deleted` for delete, and `defaulted` or `unchanged` for default (unchanged when it already was the default). `defaultProfileId` is the app's default after the change, and `defaultChanged` says whether the change moved it.
|
|
1259
|
+
|
|
1260
|
+
- The first profile in an app becomes the default. Later profiles never do until made default.
|
|
1261
|
+
- A duplicate copies the settings and is named `<name> copy`, then `<name> copy 2` and so on. It is never the default.
|
|
1262
|
+
- Delete has no preview and no in-use refusal: uploads keep the settings they were transcoded with, so their output and snapshot stay unchanged. Deleting the default makes the oldest remaining profile the default; the receipt names it in `defaultProfileId` with `defaultChanged: true`. The last profile in an app cannot be deleted: `MEDIA_PROFILE_LAST`.
|
|
1263
|
+
- `profile.default` changes which profile `default` means for the next transcode, including `media upload FILE --transcode default` and `asset.transcode` with `profile_id: "default"`.
|
|
1264
|
+
- An unknown profile, or one from another app, returns `MEDIA_PROFILE_NOT_FOUND`.
|
|
1265
|
+
|
|
1266
|
+
```sh
|
|
1267
|
+
adelin media profile create --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --operation-id 3a2b1c0d-9e8f-4a7b-8c6d-5e4f3a2b1c0d --name Phone --max-height 480 --segment-seconds 4
|
|
1268
|
+
```
|
|
1269
|
+
|
|
1270
|
+
The same create as `media_mutate` arguments:
|
|
1271
|
+
|
|
1272
|
+
```json
|
|
1273
|
+
{
|
|
1274
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
1275
|
+
"action": "profile.create",
|
|
1276
|
+
"operation_id": "3a2b1c0d-9e8f-4a7b-8c6d-5e4f3a2b1c0d",
|
|
1277
|
+
"payload": {
|
|
1278
|
+
"name": "Phone",
|
|
1279
|
+
"maxHeight": 480,
|
|
1280
|
+
"scrubPreviews": false,
|
|
1281
|
+
"segmentSeconds": 4
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
```
|
|
1285
|
+
|
|
1286
|
+
```sh
|
|
1287
|
+
adelin media profile update --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --operation-id 5c4d3e2f-1a0b-4c9d-8e7f-6a5b4c3d2e1f --profile 6d5c4b3a-2918-4706-9f5e-4d3c2b1a0918 --revision 7e6d5c4b3a2918f07e6d5c4b3a2918f07e6d5c4b3a2918f07e6d5c4b3a2918f0 --name Tablet --max-height 720
|
|
1288
|
+
```
|
|
1289
|
+
|
|
1290
|
+
The same update as `media_mutate` arguments:
|
|
1291
|
+
|
|
1292
|
+
```json
|
|
1293
|
+
{
|
|
1294
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
1295
|
+
"action": "profile.update",
|
|
1296
|
+
"operation_id": "5c4d3e2f-1a0b-4c9d-8e7f-6a5b4c3d2e1f",
|
|
1297
|
+
"expected_profiles_revision": "7e6d5c4b3a2918f07e6d5c4b3a2918f07e6d5c4b3a2918f07e6d5c4b3a2918f0",
|
|
1298
|
+
"payload": {
|
|
1299
|
+
"profile_id": "6d5c4b3a-2918-4706-9f5e-4d3c2b1a0918",
|
|
1300
|
+
"name": "Tablet",
|
|
1301
|
+
"maxHeight": 720
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
```
|
|
1305
|
+
|
|
1306
|
+
```sh
|
|
1307
|
+
adelin media profile default --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --operation-id 6d5e4f3a-2b1c-4d0e-9f8a-7b6c5d4e3f2a --profile 6d5c4b3a-2918-4706-9f5e-4d3c2b1a0918 --revision 7e6d5c4b3a2918f07e6d5c4b3a2918f07e6d5c4b3a2918f07e6d5c4b3a2918f0
|
|
1308
|
+
```
|
|
1309
|
+
|
|
1310
|
+
The same default as `media_mutate` arguments:
|
|
1311
|
+
|
|
1312
|
+
```json
|
|
1313
|
+
{
|
|
1314
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
1315
|
+
"action": "profile.default",
|
|
1316
|
+
"operation_id": "6d5e4f3a-2b1c-4d0e-9f8a-7b6c5d4e3f2a",
|
|
1317
|
+
"expected_profiles_revision": "7e6d5c4b3a2918f07e6d5c4b3a2918f07e6d5c4b3a2918f07e6d5c4b3a2918f0",
|
|
1318
|
+
"payload": {
|
|
1319
|
+
"profile_id": "6d5c4b3a-2918-4706-9f5e-4d3c2b1a0918"
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
```
|
|
1323
|
+
|
|
1324
|
+
```sh
|
|
1325
|
+
adelin media profile delete --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --operation-id 4b3c2d1e-0f9a-4b8c-9d7e-6f5a4b3c2d1e --profile 6d5c4b3a-2918-4706-9f5e-4d3c2b1a0918 --revision 7e6d5c4b3a2918f07e6d5c4b3a2918f07e6d5c4b3a2918f07e6d5c4b3a2918f0
|
|
1326
|
+
```
|
|
1327
|
+
|
|
1328
|
+
The same delete as `media_mutate` arguments:
|
|
1329
|
+
|
|
1330
|
+
```json
|
|
1331
|
+
{
|
|
1332
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
1333
|
+
"action": "profile.delete",
|
|
1334
|
+
"operation_id": "4b3c2d1e-0f9a-4b8c-9d7e-6f5a4b3c2d1e",
|
|
1335
|
+
"expected_profiles_revision": "7e6d5c4b3a2918f07e6d5c4b3a2918f07e6d5c4b3a2918f07e6d5c4b3a2918f0",
|
|
1336
|
+
"payload": {
|
|
1337
|
+
"profile_id": "6d5c4b3a-2918-4706-9f5e-4d3c2b1a0918"
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
```
|
|
1341
|
+
|
|
1342
|
+
Interrupted artwork and subtitle writes retain an exact-key cleanup reservation before storing bytes. Another upload of the same operation while its private lease is active returns `RETRYABLE_CONFLICT`; inspect and retry with the same operation ID. Once abandoned bytes have entered cleanup, `OPERATION_SUPERSEDED` requires a new operation ID. Completed operations still replay their original receipt. Scheduled publication queues replaced file keys transactionally; cleanup retries independently of the original login or grant.
|
|
1343
|
+
|
|
1344
|
+
|
|
1345
|
+
## Live streams
|
|
1346
|
+
|
|
1347
|
+
A live record is a library item with media type `live`. Its stream is set up on demand, and its broadcasts can be kept as recordings. Approve `live.view` for reads, viewer counts, recordings and `operation.inspect`, and `live.manage` for previews and every change. Approval is checked again on every call, and removing it stops the next one. `adelin live --help` lists every command, and `adelin live <command> --help` shows one. Results never carry stream keys, SRT stream ids or passphrases, provider ids or leases; a reply that would is refused as `INVALID_RESPONSE` instead of being shown. The only address any live result carries is the private preview's `hlsUrl`. Every example below runs as written through both the CLI and the local MCP tools, with your own ids.
|
|
1348
|
+
|
|
1349
|
+
### Live at a glance
|
|
1350
|
+
|
|
1351
|
+
| Command | Local MCP tool or `live_mutate` action | Approval | Confirmation |
|
|
1352
|
+
|---|---|---|---|
|
|
1353
|
+
| `adelin live list --app UUID` | `live_list` | `live.view` | none |
|
|
1354
|
+
| `adelin live get --app UUID --entry UUID` | `live_get` | `live.view` | none |
|
|
1355
|
+
| `adelin live viewers --app UUID --entry UUID` | `live_viewers` | `live.view` | none |
|
|
1356
|
+
| `adelin live recordings --app UUID` | `live_recordings` | `live.view` | none |
|
|
1357
|
+
| `adelin live saved-recordings --app UUID --entry UUID` | `live_saved_recordings` | `live.view` | none |
|
|
1358
|
+
| `adelin live preview --app UUID --entry UUID --operation-id UUID` | `live_preview` | `live.manage` | none |
|
|
1359
|
+
| `adelin live provision --app UUID --entry UUID` | `stream.provision` | `live.manage` | none |
|
|
1360
|
+
| `adelin live mutate --app UUID --action stream.options` | `stream.options` | `live.manage` | `expected_stream_revision` |
|
|
1361
|
+
| `adelin live mutate --app UUID --action stream.recording_settings` | `stream.recording_settings` | `live.manage` | `expected_stream_revision` |
|
|
1362
|
+
| `adelin live mutate --app UUID --action stream.reset --mode preview` | `stream.reset` | `live.manage` | preview here; the commit needs the CLI |
|
|
1363
|
+
| `adelin live credentials --app UUID --entry UUID --out DIR` | none; `live_credentials` refuses | `live.manage` + CLI sign-in | none |
|
|
1364
|
+
| `adelin live reset --app UUID --entry UUID --out DIR --operation-id OP --confirmation-file FILE` | none; `live_credentials` refuses | `live.manage` + CLI sign-in | the reset preview |
|
|
1365
|
+
| `adelin live delete --app UUID --entry UUID --recordings CHOICE` | `stream.delete` | `live.manage` | preview, then `confirmation` |
|
|
1366
|
+
| `adelin live schedule --app UUID --entry UUID --revision N --schedule FILE` | `schedule.set` | `live.manage` | `expected_schedule_revision` |
|
|
1367
|
+
| `adelin live mutate --app UUID --action schedule.clear` | `schedule.clear` | `live.manage` | `expected_schedule_revision` |
|
|
1368
|
+
| `adelin live promote --app UUID --recording UUID` | `recording.promote` | `live.manage` | none |
|
|
1369
|
+
| `adelin live mutate --app UUID --action recording.reconfigure` | `recording.reconfigure` | `live.manage` | `expected_recording_snapshot` |
|
|
1370
|
+
| `adelin live mutate --app UUID --action operation.inspect` | `operation.inspect` | `live.view` | read-only |
|
|
1371
|
+
| `adelin live mutate --app UUID --action preview.page` | `preview.page` | `live.view` | read-only |
|
|
1372
|
+
|
|
1373
|
+
`NOT_FOUND` never tells an unknown record from one in another app. `LIVE_ENTRY_UNAVAILABLE` means the record is not a live item, or it has no stream yet where one is needed. Wrong flags or arguments are refused with `INVALID_ARGUMENT` naming the field, before anything is sent.
|
|
1374
|
+
|
|
1375
|
+
### Reads
|
|
1376
|
+
|
|
1377
|
+
`live_list` (`{app_id, status?, limit?, cursor?}`) pages the streams with `--status live|offline|disabled`; each item is `{entryId, status, createdAt, desiredLatencyMode, latencyMode, latencyEffect, dvrEnabled, showViewerCount}`. `live_get` (`{app_id, entry_id}`) returns `{entryId, provisioning, stream, schedule}`. `provisioning` is `none` before a stream exists, then the setup state, `owned` once it is ready. `stream` is null until then; otherwise it adds `optionsPending`, `resetPending`, `deletePending`, `streamRevision` and `recordingSettings` (`{policy, folderId, captionPolicy}`). `schedule` is `{revision, schedule, announcement}`, where `announcement` is the next start as `{startsAt, timeZone}`, or null without a schedule.
|
|
1378
|
+
|
|
1379
|
+
Read one live record:
|
|
1380
|
+
|
|
1381
|
+
```sh
|
|
1382
|
+
adelin live get --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --entry 4d3c2b1a-0f9e-4d8c-8b7a-6f5e4d3c2b1a
|
|
1383
|
+
```
|
|
1384
|
+
|
|
1385
|
+
The same read as `live_get` arguments:
|
|
1386
|
+
|
|
1387
|
+
```json
|
|
1388
|
+
{
|
|
1389
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
1390
|
+
"entry_id": "4d3c2b1a-0f9e-4d8c-8b7a-6f5e4d3c2b1a"
|
|
1391
|
+
}
|
|
1392
|
+
```
|
|
1393
|
+
|
|
1394
|
+
`live_recordings` (`{app_id, limit?, cursor?}`) pages the app's completed broadcast recordings: `{id, appId, createdAt, completedAt, expiresAt, state, configurationError, videoId, assetId, captionNamespaceId, originDeleted, sourceState, importStatus, snapshot, settings, canSave}`. `canSave` is true while the recording is unsaved, its source is available and it has not expired. `live_saved_recordings` (`{app_id, entry_id, limit?, cursor?}`) pages `{entryId, title, completedAt}` for the recordings of one stream that were saved as library entries; an entry without a stream has none.
|
|
1395
|
+
|
|
1396
|
+
Pages hold 25 items by default (`--limit 1..100`) and stop early once they would pass 32 KiB, so `returned` can be below `limit` while `nextCursor` is set. Pass `nextCursor` back as `--cursor` with the same filters and stop when it is null. A cursor expires after 900 seconds and is tied to this sign-in; a changed filter gives `STALE_CURSOR`, and a foreign, altered or expired cursor gives `INVALID_CURSOR`. The CLI and local MCP cursors differ, so compare items, not cursors.
|
|
1397
|
+
|
|
1398
|
+
### Viewer counts
|
|
1399
|
+
|
|
1400
|
+
`live_viewers` (`{app_id, entry_id}`) returns `{entryId, source, unit, state, count?, observedAt?, summary}`; `unit` is concurrent viewers as the streaming provider reports them. `state` is `fresh` for a count observed within the last 15 seconds, `stale` when a refresh failed and the last count is between 15 and 60 seconds old, and `unavailable` otherwise. A count always comes with its state and `observedAt`; `unavailable` has neither. `summary` gives it in words, for example `7 concurrent viewers (stale observation from …; the latest refresh failed)`. Never show a stale count as current. The count is returned even when the stream hides it from viewers (`showViewerCount: false`). `LIVE_COUNTS_UNAVAILABLE` means the count could not be read at all.
|
|
1401
|
+
|
|
1402
|
+
### Private preview
|
|
1403
|
+
|
|
1404
|
+
`live_preview {app_id, entry_id, operation_id}` and `adelin live preview --app UUID --entry UUID --operation-id UUID` request a finite private preview for a stream that is live and not being deleted. Choose a lowercase UUID once for that intent, retain it, and resend the exact request with that same id after a timeout or lost reply. Neither client generates a preview operation id. A new preview needs a new id; changing a retained request is refused.
|
|
1405
|
+
|
|
1406
|
+
Only `LIVE_PREVIEW_OPERATION_EXPIRED` confirms that the retained preview operation has expired. Request a new preview explicitly with a new `operation_id`; the clients never create or retry a replacement automatically. A timeout, unknown failure, generic 410, `ACCESS_DENIED` or another 403 does not establish retained-operation expiry. Preserve the original operation id for recovery or the identical retry. Local clock or sign-in expiry alone does not confirm that retained operation's state.
|
|
1407
|
+
|
|
1408
|
+
The reply is `{entryId, hlsUrl, sessionId, expiresAt, expiresAtIso, expiresInSeconds, latencyMode, dvrEnabled, summary}`. `expiresAt` is in Unix seconds; the grant lasts at most 60 seconds and cannot outlive the current sign-in or finite funding promise. `summary` states when it ends. Open the `hlsUrl` only in a player, never paste it into a chat, file or log. It carries no stream key. Expired previews are not renewed. A stream that is offline or being deleted, or unavailable preview authority, gives `LIVE_PLAYBACK_UNAVAILABLE`; current authority loss gives `ACCESS_DENIED`, and a billing refusal keeps its `BILLING_` code. Ordinary stream/recording/count listings do not create preview funding.
|
|
1409
|
+
|
|
1410
|
+
### Changes
|
|
1411
|
+
|
|
1412
|
+
Every change goes through `live_mutate` or `adelin live`: `{app_id, action, operation_id, payload}`, plus `mode` and `confirmation` for the two preview actions. `operation_id` is a new UUID for each change; when it is left out one is made and returned as `operationId`. There is no `expected_revision`: the concurrency token travels in the payload. A change succeeds as `{ok:true, action, appId, operationId, data}`, where `data` is the receipt plus `policy` (`{saveMode, retentionHours, countSource, resetWarningCode, pricing}`); a refusal is `{ok:false, operationId, error:{code, message, ...details}}`.
|
|
1413
|
+
|
|
1414
|
+
| Action | Payload | Token |
|
|
1415
|
+
|---|---|---|
|
|
1416
|
+
| `stream.provision` | `{entry_id}` | none |
|
|
1417
|
+
| `stream.options` | `{entry_id, expected_stream_revision, options: {dvr_enabled?, show_viewer_count?}}` with at least one option | `streamRevision` from `live_get` |
|
|
1418
|
+
| `stream.recording_settings` | `{entry_id, expected_stream_revision, settings: {policy, folder_id}}` | `streamRevision` from `live_get` |
|
|
1419
|
+
| `stream.reset` | `{entry_id}` | preview |
|
|
1420
|
+
| `stream.delete` | `{entry_id, recordings: "keep-all" \| "delete-all" \| {entry_ids}}` | preview |
|
|
1421
|
+
| `schedule.set` | `{entry_id, expected_schedule_revision, schedule}` | `schedule.revision` from `live_get` |
|
|
1422
|
+
| `schedule.clear` | `{entry_id, expected_schedule_revision}` | `schedule.revision` from `live_get` |
|
|
1423
|
+
| `recording.promote` | `{recording_id}` | none |
|
|
1424
|
+
| `recording.reconfigure` | `{recording_id, expected_recording_snapshot, settings: {policy, folder_id}}` | `snapshot` from `live_recordings` |
|
|
1425
|
+
| `operation.inspect` | `{target_operation_id}` | none |
|
|
1426
|
+
| `preview.page` | `{preview_id, cursor}` | none |
|
|
1427
|
+
|
|
1428
|
+
`adelin live mutate --input FILE` takes the whole `live_mutate` request from a JSON file of at most 262144 bytes, exactly the arguments the tool gets, and no other request flag. The flag form builds the same request: `adelin live mutate --app UUID --action ACTION` reads only the payload from `--payload FILE`, with `--operation-id`, `--mode preview` and `--confirmation-file FILE` (the confirmation JSON) as flags. The shortcuts build it too: `adelin live provision --app UUID --entry UUID`, `adelin live delete --app UUID --entry UUID --recordings keep-all|delete-all|FILE` (FILE holds a JSON array of saved recording entry IDs), `adelin live schedule --app UUID --entry UUID --revision N` with `--schedule FILE` (FILE holds the schedule) and `adelin live promote --app UUID --recording UUID`. Symlinks and other file types are refused.
|
|
1429
|
+
|
|
1430
|
+
`stream.provision` sets up the stream for a live record and returns `{entryId, streamRevision}`. A fresh provision is checked against the plan's live allowance first and may be refused with a `BILLING_` code (with `pointKey`); retrying the same `operation_id` never asks again or creates a second stream. Refusals: `LIVE_ALREADY_PROVISIONED`, `LIVE_PROVISIONING_BLOCKED` with `state`, `LIVE_RECONCILIATION_REQUIRED` with `retryable` (see Conflicts, retries and recovery), and `LIVE_PROVISION_COMPENSATING`, which means an earlier attempt is being undone: try again later with a new `operation_id`.
|
|
1431
|
+
|
|
1432
|
+
Set up the stream for a live record:
|
|
1433
|
+
|
|
1434
|
+
```sh
|
|
1435
|
+
adelin live provision --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --entry 4d3c2b1a-0f9e-4d8c-8b7a-6f5e4d3c2b1a --operation-id 1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d
|
|
1436
|
+
```
|
|
1437
|
+
|
|
1438
|
+
The same change as a `live_mutate` request:
|
|
1439
|
+
|
|
1440
|
+
```json
|
|
1441
|
+
{
|
|
1442
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
1443
|
+
"action": "stream.provision",
|
|
1444
|
+
"operation_id": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
|
|
1445
|
+
"payload": {
|
|
1446
|
+
"entry_id": "4d3c2b1a-0f9e-4d8c-8b7a-6f5e4d3c2b1a"
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
```
|
|
1450
|
+
|
|
1451
|
+
`stream.options` atomically changes DVR and the viewer-count flag in stored settings, with at least one boolean option. It makes no provider request. `prefer_low_latency` is rejected; encoder segment settings use the dashboard encoder-policy contract. `LIVE_OPTIONS_INVALID` refuses options the stream cannot take. Bind each change to the current `streamRevision` from `live_get`; it covers encoder policy/settings revisions as well as DVR, viewer and recording settings. A stale token gives `CONFLICT`: read the stream and use a new `operation_id`. Repeating the same operation and payload replays its result after current authorization checks. Existing unresolved options or key-reset operations refuse the write until reconciled, with `LIVE_OPTIONS_RECONCILIATION_REQUIRED` or `LIVE_RESET_RECONCILIATION_REQUIRED`. `LIVE_OPTIONS_CONFLICT` also covers a changed encoder policy: refresh the stream and use a new operation ID. `LIVE_OPTIONS_UNSUPPORTED_SOURCE` requires correcting the encoder settings in the dashboard. `LIVE_PROFILE_POLICY_UNAVAILABLE` means the current policy could not be read; retry the identical request later.
|
|
1452
|
+
|
|
1453
|
+
Turn DVR on, bound to the `streamRevision` from `live_get`. Send it as `live_mutate` arguments, or save it to a file and run `adelin live mutate --input FILE`:
|
|
1454
|
+
|
|
1455
|
+
```json
|
|
1456
|
+
{
|
|
1457
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
1458
|
+
"action": "stream.options",
|
|
1459
|
+
"operation_id": "2b3c4d5e-6f7a-4b8c-9d0e-1f2a3b4c5d6e",
|
|
1460
|
+
"payload": {
|
|
1461
|
+
"entry_id": "4d3c2b1a-0f9e-4d8c-8b7a-6f5e4d3c2b1a",
|
|
1462
|
+
"expected_stream_revision": "9f8e7d6c5b4a39281706f5e4d3c2b1a09f8e7d6c5b4a39281706f5e4d3c2b1a0",
|
|
1463
|
+
"options": {
|
|
1464
|
+
"dvr_enabled": true
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
```
|
|
1469
|
+
|
|
1470
|
+
`stream.recording_settings` sets the policy and target folder for future recordings and returns `recordingSettings`; a missing folder gives `LIVE_RECORDING_SETTINGS_INVALID` with `reason`. Keep future recordings unsaved, to be saved into one folder:
|
|
1471
|
+
|
|
1472
|
+
```json
|
|
1473
|
+
{
|
|
1474
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
1475
|
+
"action": "stream.recording_settings",
|
|
1476
|
+
"operation_id": "3c4d5e6f-7a8b-4c9d-8e1f-2a3b4c5d6e7f",
|
|
1477
|
+
"payload": {
|
|
1478
|
+
"entry_id": "4d3c2b1a-0f9e-4d8c-8b7a-6f5e4d3c2b1a",
|
|
1479
|
+
"expected_stream_revision": "9f8e7d6c5b4a39281706f5e4d3c2b1a09f8e7d6c5b4a39281706f5e4d3c2b1a0",
|
|
1480
|
+
"settings": {
|
|
1481
|
+
"policy": "manual",
|
|
1482
|
+
"folder_id": "6c5b4a39-2817-46f5-a4d3-c2b1a0f9e8d7"
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
```
|
|
1487
|
+
|
|
1488
|
+
### Reset and credentials
|
|
1489
|
+
|
|
1490
|
+
Broadcast credentials never reach an agent. Read them with `adelin live credentials` and change them with `adelin live reset`; both are CLI-only and write the credentials to a private file whose path they print. These are generation-bound Adelin encoder endpoints and credentials. Use them unchanged; never construct a provider address or substitute provider keys. `stream.reset` through `live_mutate` or `adelin live mutate` only previews: send `mode: "preview"`, and the single page item says whether the stream is live now (`liveNow`), carries `LIVE_RESET_INTERRUPTS_BROADCAST` and describes the effect: the old credentials stop working and a running broadcast drops. The preview is required whether or not the stream is live. Sending `stream.reset` without `mode: "preview"` is refused with `LIVE_CREDENTIALS_CLI_ONLY` before anything is sent; its message names the command to run with your ids: `adelin live reset --app APP --entry ENTRY --out DIR --operation-id OP --confirmation-file FILE`, where FILE holds the preview's `data.confirmation`. A key reset elsewhere after that gives `LIVE_CREDENTIALS_SUPERSEDED`, and `LIVE_RESET_CONFLICT` means another reset is running.
|
|
1491
|
+
|
|
1492
|
+
Preview a key reset; FILE holds the payload `{"entry_id": …}`:
|
|
1493
|
+
|
|
1494
|
+
```sh
|
|
1495
|
+
adelin live mutate --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --action stream.reset --mode preview --payload /home/me/reset.json --operation-id 5e6f7a8b-9c0d-4e1f-8a3b-4c5d6e7f8a9b
|
|
1496
|
+
```
|
|
1497
|
+
|
|
1498
|
+
The same preview as a `live_mutate` request:
|
|
1499
|
+
|
|
1500
|
+
```json
|
|
1501
|
+
{
|
|
1502
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
1503
|
+
"action": "stream.reset",
|
|
1504
|
+
"operation_id": "5e6f7a8b-9c0d-4e1f-8a3b-4c5d6e7f8a9b",
|
|
1505
|
+
"mode": "preview",
|
|
1506
|
+
"payload": {
|
|
1507
|
+
"entry_id": "4d3c2b1a-0f9e-4d8c-8b7a-6f5e4d3c2b1a"
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
```
|
|
1511
|
+
|
|
1512
|
+
`adelin live credentials --app UUID --entry UUID --out DIR` retrieves the stream's current encoder credentials without a reset preview. The first read can finish a pending broadcast setup; it reuses that setup and never invents a reset. A stopped broadcast needs a newly previewed and confirmed reset before new credentials are available. `adelin live reset --app UUID --entry UUID --out DIR --operation-id OP --confirmation-file FILE` commits a reset: preview it first, read its page, save the preview's `data.confirmation` to FILE and pass the preview's `operationId` as `--operation-id`. Both write `live-credentials-ENTRY-TIME.json` (TIME in UTC, such as `20261105T031500Z`) into DIR as described under Private local output, and the credentials do not appear anywhere else. A reset prints `outcome` `reset` with `LIVE_RESET_INTERRUPTS_BROADCAST`, or `replayed` when the same `--operation-id` already reset the key: a lost reply or a refused write can be retried with the same command while that operation still owns the current broadcast generation, so a `PRIVATE_OUTPUT_REFUSED` after a reset carries `retryable: true` and `operationId`. Refusals print no path and write no file: `STALE_PREVIEW`, `CONFIRMATION_REQUIRED`, `LIVE_CREDENTIALS_SUPERSEDED`, `LIVE_RESET_RECONCILIATION_REQUIRED` (with `retryable`), `LIVE_RESET_CONFLICT`, `LIVE_ENTRY_UNAVAILABLE` (no stream yet), `ACCESS_DENIED` and `INVALID_ARGUMENT` naming the flag. A reply that is altered, bound to another request or cannot be opened is `INVALID_RESPONSE`, and nothing is written.
|
|
1513
|
+
|
|
1514
|
+
A pending broadcast change must finish before another change starts. `LIVE_BROADCAST_PROVISION_PENDING` means retry the identical request with its original operation ID. `LIVE_BROADCAST_PROVISION_CONFLICT` means recover the original request rather than creating a replacement ID. `LIVE_BROADCAST_RESTART_REQUIRED` needs a fresh reset preview and confirmation. `LIVE_BROADCAST_OUT_OF_CREDIT` means the organization has no credit left for live broadcasting; tell the builder to buy credit or upgrade the plan, and do not retry. `LIVE_BROADCAST_UNAVAILABLE` and `LIVE_BROADCAST_PROVISION_UNAVAILABLE` mean setup is unavailable; do not bypass the refusal with a provider endpoint. Refusals write no credential file.
|
|
1515
|
+
|
|
1516
|
+
Read the current credentials into a private file:
|
|
1517
|
+
|
|
1518
|
+
```sh
|
|
1519
|
+
adelin live credentials --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --entry 4d3c2b1a-0f9e-4d8c-8b7a-6f5e4d3c2b1a --out /home/me/live-credentials
|
|
1520
|
+
```
|
|
1521
|
+
|
|
1522
|
+
`live_credentials` with the same ids writes nothing and refuses with `LIVE_CREDENTIALS_CLI_ONLY`, naming that command:
|
|
1523
|
+
|
|
1524
|
+
```json
|
|
1525
|
+
{
|
|
1526
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
1527
|
+
"entry_id": "4d3c2b1a-0f9e-4d8c-8b7a-6f5e4d3c2b1a"
|
|
1528
|
+
}
|
|
1529
|
+
```
|
|
1530
|
+
|
|
1531
|
+
Commit the previewed reset with the preview's operation id and its saved confirmation:
|
|
1532
|
+
|
|
1533
|
+
```sh
|
|
1534
|
+
adelin live reset --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --entry 4d3c2b1a-0f9e-4d8c-8b7a-6f5e4d3c2b1a --out /home/me/live-credentials --operation-id 5e6f7a8b-9c0d-4e1f-8a3b-4c5d6e7f8a9b --confirmation-file /home/me/reset-confirmation.json
|
|
1535
|
+
```
|
|
1536
|
+
|
|
1537
|
+
The agent side refuses the commit the same way:
|
|
1538
|
+
|
|
1539
|
+
```json
|
|
1540
|
+
{
|
|
1541
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
1542
|
+
"entry_id": "4d3c2b1a-0f9e-4d8c-8b7a-6f5e4d3c2b1a"
|
|
1543
|
+
}
|
|
1544
|
+
```
|
|
1545
|
+
|
|
1546
|
+
### Deleting a stream
|
|
1547
|
+
|
|
1548
|
+
`stream.delete` removes the live record and its stream and needs an explicit choice for the saved recordings: `"keep-all"` keeps them, `"delete-all"` deletes them with it, and `{entry_ids}` deletes exactly the listed saved recording entries (1 to 100, each once). One deletion removes at most 100 saved recordings: a longer list gives `LIVE_DELETE_SELECTION_TOO_LARGE`, and `delete-all` is refused with `LIVE_DELETE_SELECTION_TOO_LARGE` as well when the stream has more than 100 saved recordings. Then delete some of them through the library first, or keep them with `keep-all`. Leaving the choice out is refused as `INVALID_ARGUMENT` naming `payload.recordings`. Preview first with `mode: "preview"`: the pages list the live item (`provisioned`, `liveNow`, and `LIVE_DELETE_INTERRUPTS_BROADCAST` when it is broadcasting), every saved recording with `selected`, and the count of unsaved recordings that go with the stream. Pages hold up to 100 items; read every page with `preview.page` (`{preview_id, cursor}` from `nextCursor`), then send the same request without `mode` and with the last page's `data.confirmation`, which holds its `acknowledgement`. On the CLI, save it to a file and pass `--confirmation-file`. A changed stream or saved set gives `STALE_PREVIEW`, and a missing or wrong confirmation gives `CONFIRMATION_REQUIRED`; previews expire after 900 seconds.
|
|
1549
|
+
|
|
1550
|
+
Preview deleting a stream while keeping its saved recordings:
|
|
1551
|
+
|
|
1552
|
+
```sh
|
|
1553
|
+
adelin live delete --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --entry 4d3c2b1a-0f9e-4d8c-8b7a-6f5e4d3c2b1a --recordings keep-all --mode preview --operation-id 7a8b9c0d-1e2f-4a3b-8c5d-6e7f8a9b0c1d
|
|
1554
|
+
```
|
|
1555
|
+
|
|
1556
|
+
The same preview as a `live_mutate` request:
|
|
1557
|
+
|
|
1558
|
+
```json
|
|
1559
|
+
{
|
|
1560
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
1561
|
+
"action": "stream.delete",
|
|
1562
|
+
"operation_id": "7a8b9c0d-1e2f-4a3b-8c5d-6e7f8a9b0c1d",
|
|
1563
|
+
"mode": "preview",
|
|
1564
|
+
"payload": {
|
|
1565
|
+
"entry_id": "4d3c2b1a-0f9e-4d8c-8b7a-6f5e4d3c2b1a",
|
|
1566
|
+
"recordings": "keep-all"
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
```
|
|
1570
|
+
|
|
1571
|
+
Commit it with the same operation and payload and the last page's confirmation, as `live_mutate` arguments or from a file with `adelin live mutate --input FILE`:
|
|
1572
|
+
|
|
1573
|
+
```json
|
|
1574
|
+
{
|
|
1575
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
1576
|
+
"action": "stream.delete",
|
|
1577
|
+
"operation_id": "7a8b9c0d-1e2f-4a3b-8c5d-6e7f8a9b0c1d",
|
|
1578
|
+
"confirmation": {
|
|
1579
|
+
"preview_id": "8b9c0d1e-2f3a-4b4c-9d6e-7f8a9b0c1d2e",
|
|
1580
|
+
"digest": "3e2d1c0b9a8f7e6d3e2d1c0b9a8f7e6d3e2d1c0b9a8f7e6d3e2d1c0b9a8f7e6d",
|
|
1581
|
+
"acknowledgement": "a5b6c7d8e9f0a1b2a5b6c7d8e9f0a1b2a5b6c7d8e9f0a1b2a5b6c7d8e9f0a1b2"
|
|
1582
|
+
},
|
|
1583
|
+
"payload": {
|
|
1584
|
+
"entry_id": "4d3c2b1a-0f9e-4d8c-8b7a-6f5e4d3c2b1a",
|
|
1585
|
+
"recordings": "keep-all"
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
```
|
|
1589
|
+
|
|
1590
|
+
The receipt is `{deleted: {entryId}, entryResults, warningCode}`, where each `entryResults` item has `status` `deleted`, `not_found` (already gone, which counts as done) or `retry-required`. After `retry-required` or `LIVE_DELETE_RETRY_REQUIRED`, send the same request again with the same `operation_id` to finish. A record whose stream was never set up is deleted like any library entry under the same receipt. `LIVE_PROVISIONING_PENDING` means its setup is still running, `LIVE_DELETE_SELECTION_INVALID` that the list names an entry that is not a saved recording of this stream, and `LIVE_DELETE_CONFLICT` that another delete with a different choice is running.
|
|
1591
|
+
|
|
1592
|
+
### Schedules
|
|
1593
|
+
|
|
1594
|
+
A schedule announces when a stream goes live. `schedule.set` takes a `once` or `weekly` schedule, always with an IANA `time_zone`. `once` takes `at: {utc}`, a time ending in `Z`, or `at: {wall}`, a local `YYYY-MM-DDTHH:MM` in that zone. A time without a zone or with a numeric offset, or both forms at once, gives `SCHEDULE_ZONE_REQUIRED` before anything is sent; an unknown zone gives `SCHEDULE_ZONE_INVALID`. A wall time skipped by a clock change gives `SCHEDULE_TIME_NONEXISTENT`, and one that happens twice gives `SCHEDULE_TIME_AMBIGUOUS` with two `candidates`: send one as `utc`. `weekly` takes `days: [{weekday, times}]`, weekday 1 (Monday) to 7, each with up to 48 `HH:MM` times; the server's rules for it give `LIVE_SCHEDULE_INVALID` with the `field`. The receipt is `{entryId, revision, schedule, announcement}`, with the next start as `announcement: {startsAt, timeZone, local}`: UTC, the zone and the local wall time there. `schedule.clear` removes it (`schedule` and `announcement` null).
|
|
1595
|
+
|
|
1596
|
+
Announce one broadcast at a local time, bound to the `schedule.revision` from `live_get`; FILE holds the `schedule` object:
|
|
1597
|
+
|
|
1598
|
+
```sh
|
|
1599
|
+
adelin live schedule --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --entry 4d3c2b1a-0f9e-4d8c-8b7a-6f5e4d3c2b1a --revision 0 --schedule /home/me/schedule.json --operation-id 4d5e6f7a-8b9c-4d0e-9f2a-3b4c5d6e7f8a
|
|
1600
|
+
```
|
|
1601
|
+
|
|
1602
|
+
The same change as a `live_mutate` request:
|
|
1603
|
+
|
|
1604
|
+
```json
|
|
1605
|
+
{
|
|
1606
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
1607
|
+
"action": "schedule.set",
|
|
1608
|
+
"operation_id": "4d5e6f7a-8b9c-4d0e-9f2a-3b4c5d6e7f8a",
|
|
1609
|
+
"payload": {
|
|
1610
|
+
"entry_id": "4d3c2b1a-0f9e-4d8c-8b7a-6f5e4d3c2b1a",
|
|
1611
|
+
"expected_schedule_revision": 0,
|
|
1612
|
+
"schedule": {
|
|
1613
|
+
"kind": "once",
|
|
1614
|
+
"time_zone": "Europe/Vilnius",
|
|
1615
|
+
"at": {
|
|
1616
|
+
"wall": "2030-06-12T19:30"
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
```
|
|
1622
|
+
|
|
1623
|
+
Both bind to `expected_schedule_revision`, the `schedule.revision` from `live_get`. When the schedule changed since, the change returns `CONFLICT` with the current `{revision, schedule, announcement}` in `latestState`; `LIVE_SCHEDULE_CONFLICT` reports the same race. A `once` schedule is cleared when a broadcast starts, which raises the revision.
|
|
1624
|
+
|
|
1625
|
+
### Recordings
|
|
1626
|
+
|
|
1627
|
+
Each broadcast leaves a recording that is kept for 24 hours (`expiresAt`). The stream's recording `policy` decides what happens at the end of a broadcast: `manual` keeps it unsaved until you save it with `recording.promote` within those 24 hours, while `draft` and `publish` save it automatically when the broadcast completes, into the configured folder; `publish` also publishes the entry once its import finishes. `recording.promote` creates the draft video entry and returns the recording with `state: "accepted"` and its `importStatus`. `accepted` means the save is recorded and the entry exists; `importStatus` stays `pending` until the recording has been copied into the library. Saving the same recording again replays.
|
|
1628
|
+
|
|
1629
|
+
Save one recording:
|
|
1630
|
+
|
|
1631
|
+
```sh
|
|
1632
|
+
adelin live promote --app 8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b --recording 7f6e5d4c-3b2a-4190-8f7e-6d5c4b3a2918 --operation-id 6f7a8b9c-0d1e-4f2a-9b4c-5d6e7f8a9b0c
|
|
1633
|
+
```
|
|
1634
|
+
|
|
1635
|
+
The same change as a `live_mutate` request:
|
|
1636
|
+
|
|
1637
|
+
```json
|
|
1638
|
+
{
|
|
1639
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
1640
|
+
"action": "recording.promote",
|
|
1641
|
+
"operation_id": "6f7a8b9c-0d1e-4f2a-9b4c-5d6e7f8a9b0c",
|
|
1642
|
+
"payload": {
|
|
1643
|
+
"recording_id": "7f6e5d4c-3b2a-4190-8f7e-6d5c4b3a2918"
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
```
|
|
1647
|
+
|
|
1648
|
+
A recording whose settings broke, for example because its folder was deleted, is in state `configuration_error` with `configurationError` (such as `collection_missing`) and `canSave: false`, and `recording.promote` refuses it with `LIVE_RECORDING_SETTINGS_INVALID` (the dashboard says `LIVE_RECORDING_CONFIGURATION_ERROR`); repair it with `recording.reconfigure`, sending its current `snapshot` and settings that work. Reconfiguring also changes the stream's recording settings while the stream exists, so the reply carries `streamSettingsChanged` and the stream's `streamRevision` changes. Refusals: `LIVE_RECORDING_UNAVAILABLE`, `LIVE_RECORDING_EXPIRED`, `LIVE_RECORDING_INCOMPLETE`, `LIVE_RECORDING_CONFLICT` (already saved or being removed), `LIVE_RECORDING_SETTINGS_INVALID` and `CONFLICT` with the recording as `latestState` when its `snapshot` changed.
|
|
1649
|
+
|
|
1650
|
+
### Conflicts, retries and recovery
|
|
1651
|
+
|
|
1652
|
+
A `CONFLICT` changes nothing and carries `latestState`: the stream (with `streamRevision`), the schedule or the recording as it now reads. Use its token, or read again, and resend; the same `operation_id` is fine after a `CONFLICT`. Resending an identical request with the same `operation_id` returns the stored outcome without repeating the change, so retry lost responses, `RETRYABLE_CONFLICT` and `MUTATION_UNAVAILABLE` that way. Reusing an `operation_id` for a different request gives `OPERATION_PAYLOAD_CONFLICT`. Changes that reach the stream can answer `state: "running"` while they finish: resend the same request, or read the stored outcome with `operation.inspect` (`{target_operation_id}`), which needs only `live.view`.
|
|
1653
|
+
|
|
1654
|
+
Read the stored outcome of the provision above:
|
|
1655
|
+
|
|
1656
|
+
```json
|
|
1657
|
+
{
|
|
1658
|
+
"app_id": "8a6f2c1e-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
|
|
1659
|
+
"action": "operation.inspect",
|
|
1660
|
+
"operation_id": "8c9d0e1f-2a3b-4c4d-8e6f-7a8b9c0d1e2f",
|
|
1661
|
+
"payload": {
|
|
1662
|
+
"target_operation_id": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d"
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
```
|
|
1666
|
+
|
|
1667
|
+
A change that reaches the stream may not be confirmed at once. Resend the identical request with the same `operation_id`; an already dispatched effect is never sent twice. While a request may still be in flight, reconciliation remains retryable. A stale provision with no correlated input stops with `state: "stopped", outcome: "cancelled"`; its intent remains available for cleanup if a late provider input appears. Replay that ID to inspect the cancellation, or use a new operation ID to provision again. An uncertain latency change or key reset is read back from the provider: an applied effect finishes, and an unchanged effect after its lease plus the provider timeout stops with `outcome: "not_applied"`. A worker-settled latency change also closes the original receipt. A stopped reset writes no credentials. `LIVE_DELETE_RETRY_REQUIRED` means the delete did not finish; the same request resumes it.
|