Typebar over REST (curl): one command per job
Each shell command costs you a model turn, so do a whole job in ONE command: every instruction in one message, targets named by section and content. Never open, read, grep or diff the documents yourself. Every curl has--max-time. Never re-send a POST that timed out (it bills a second job): re-run
only the GET wait. Never use pkill, killall or kill.
Key (once)
Reuse~/.superdocs/agent_credentials.json if it exists. Otherwise sign up, which accepts the Terms
(typebar.ai/terms): only if the user’s instruction says so; otherwise ask the user first.
Edit a file: one command
A=(); while IFS= read -r f; do A+=(-F "sources=@\"$f\""); done < <(find ./data ./context -type f ! -path '*/.*' 2>/dev/null)
before the curl and replace -F "file=@\"./INPUT.docx\"" with "${A[@]}"; the message is the brief. (Keep the \"…\":
unquoted, curl reads ; and , as options.)
The reply
response: what was done per ask.download: a 15-minute link (-F export_format=pdffor PDF).- HTTP 202 or a timeout: still running. Run ONE wait (again on another 202) with the printed session:
Then the same
python3andread U Nlines. The wait also re-lists held lines; guess no other endpoint. [edited: false]printed: nothing was edited; run the edit command again (a new session). Any other failure may have edited: give the user itsresponsebefore sending again.- HELD lines (
requires_approval): nothing from this turn is applied yet; the savedOUTPUT-before-this-turn.docxpredates it (a held create has none: seedownload.error).requires_reviewlines need the user’s own go; never approve one without it. If you can ask, ask BEFORE the approve call; put the ids they approve inOK(space-separated). If you cannot ask and every line isrequires_review, stop: give the user the held lines and that one decision.- A note saying it could not be verified, or goes beyond the request: deny it (id in
NO), finish, then re-ask that change alone: the edit command onOUTPUT.docx, quoting verbatim from the document (the one exception) the exact text to keep or the anchor. Never stop without the final file. - Otherwise approve in ONE call, then wait and download. Lines it does not name are declined: never applied, never approvable later. Until held lines are decided, a new chat answers 409.
Then the same two lines. Tell the user which held changes were NOT applied, naming each (they can ask again).- STILL HELD ids need their own call and the user’s go: for each they approved, POST
{"job_id": J, "change_id": ID, "approved": true}the same way, then wait; name the rest to the user. Never wait on a held job without deciding. APPROVE FAILED: do what its message says.
- Follow-up:
POST $API/v1/chat, JSON: samesession_id,message,"response_mode": "summary","export_format": "docx". - Undo:
POST $API/v1/sessions/$SID/revertwith{"turn_index": N, "response_mode": "summary"}(N from the reply). Redo (right after an undo):POST $API/v1/sessions/$SID/redowith{"turn_index": N, "redo_checkpoint_id": "ID", "response_mode": "summary"}(ID from the undo reply).
Related
- For AI Agents: sign-up, the API key and handing the account to a human.
- Human-in-the-Loop: how held changes work.
- Agent Editing Playbook: editing patterns, placement, verification and billing.