@skrr-ai/cli 0.1.155 → 0.1.157

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.
Files changed (148) hide show
  1. package/dist/base-command.js +64 -16
  2. package/dist/commands/activity/list.d.ts +13 -0
  3. package/dist/commands/activity/list.js +50 -0
  4. package/dist/commands/activity/show.d.ts +18 -0
  5. package/dist/commands/activity/show.js +125 -0
  6. package/dist/commands/agent/message/send.js +64 -19
  7. package/dist/commands/agents/always-on/held-messages.js +24 -1
  8. package/dist/commands/agents/always-on/status.js +6 -1
  9. package/dist/commands/agents/mini-computer/app/reset.d.ts +13 -0
  10. package/dist/commands/agents/mini-computer/app/reset.js +35 -0
  11. package/dist/commands/agents/mini-computer/app/set.d.ts +16 -0
  12. package/dist/commands/agents/mini-computer/app/set.js +70 -0
  13. package/dist/commands/agents/mini-computer/layout/change.d.ts +14 -0
  14. package/dist/commands/agents/mini-computer/layout/change.js +44 -0
  15. package/dist/commands/agents/mini-computer/layout/folder.d.ts +14 -0
  16. package/dist/commands/agents/mini-computer/layout/folder.js +35 -0
  17. package/dist/commands/agents/mini-computer/layout/move.d.ts +14 -0
  18. package/dist/commands/agents/mini-computer/layout/move.js +32 -0
  19. package/dist/commands/agents/mini-computer/layout/pin.d.ts +14 -0
  20. package/dist/commands/agents/mini-computer/layout/pin.js +35 -0
  21. package/dist/commands/agents/mini-computer/layout/remove.d.ts +13 -0
  22. package/dist/commands/agents/mini-computer/layout/remove.js +27 -0
  23. package/dist/commands/agents/mini-computer/layout/restore.d.ts +13 -0
  24. package/dist/commands/agents/mini-computer/layout/restore.js +27 -0
  25. package/dist/commands/agents/mini-computer/layout/unfolder.d.ts +13 -0
  26. package/dist/commands/agents/mini-computer/layout/unfolder.js +27 -0
  27. package/dist/commands/agents/mini-computer/layout/unpin.d.ts +14 -0
  28. package/dist/commands/agents/mini-computer/layout/unpin.js +34 -0
  29. package/dist/commands/agents/mini-computer/show.d.ts +13 -0
  30. package/dist/commands/agents/mini-computer/show.js +60 -0
  31. package/dist/commands/agents/mini-computer/tasks-view.d.ts +29 -0
  32. package/dist/commands/agents/mini-computer/tasks-view.js +100 -0
  33. package/dist/commands/apps/auto-apply.d.ts +14 -0
  34. package/dist/commands/apps/auto-apply.js +53 -0
  35. package/dist/commands/apps/check.js +4 -1
  36. package/dist/commands/apps/create.js +11 -6
  37. package/dist/commands/apps/data/batch.d.ts +15 -0
  38. package/dist/commands/apps/data/batch.js +59 -0
  39. package/dist/commands/apps/data/collections.d.ts +12 -0
  40. package/dist/commands/apps/data/collections.js +44 -0
  41. package/dist/commands/apps/data/delete.d.ts +15 -0
  42. package/dist/commands/apps/data/delete.js +57 -0
  43. package/dist/commands/apps/data/patch.d.ts +17 -0
  44. package/dist/commands/apps/data/patch.js +70 -0
  45. package/dist/commands/apps/data/put.js +1 -1
  46. package/dist/commands/apps/data/query.js +1 -1
  47. package/dist/commands/apps/installations/diff.d.ts +14 -0
  48. package/dist/commands/apps/installations/diff.js +45 -0
  49. package/dist/commands/apps/installations/events.d.ts +23 -0
  50. package/dist/commands/apps/installations/events.js +104 -0
  51. package/dist/commands/apps/installations/snapshot.d.ts +18 -0
  52. package/dist/commands/apps/installations/snapshot.js +60 -0
  53. package/dist/commands/apps/installations/versions.d.ts +12 -0
  54. package/dist/commands/apps/installations/versions.js +38 -0
  55. package/dist/commands/apps/logs.js +3 -0
  56. package/dist/commands/apps/preview.js +4 -2
  57. package/dist/commands/apps/pull.js +10 -1
  58. package/dist/commands/apps/push.js +36 -12
  59. package/dist/commands/apps/reference.d.ts +26 -0
  60. package/dist/commands/apps/reference.js +56 -0
  61. package/dist/commands/apps/rollback.d.ts +13 -0
  62. package/dist/commands/apps/rollback.js +47 -0
  63. package/dist/commands/apps/version/create.js +5 -0
  64. package/dist/commands/duties/accounting.js +6 -0
  65. package/dist/commands/duties/analytics/detail.js +6 -0
  66. package/dist/commands/duties/analytics/index.js +14 -0
  67. package/dist/commands/duties/analytics/replay.js +6 -0
  68. package/dist/commands/duties/cost.js +6 -0
  69. package/dist/commands/duties/delete.js +22 -19
  70. package/dist/commands/duties/doctor.d.ts +2 -1
  71. package/dist/commands/duties/doctor.js +17 -3
  72. package/dist/commands/duties/goals/link.js +4 -0
  73. package/dist/commands/duties/goals/unlink.js +4 -0
  74. package/dist/commands/duties/lineage.js +6 -1
  75. package/dist/commands/duties/links/list.js +6 -0
  76. package/dist/commands/duties/metrics.js +10 -0
  77. package/dist/commands/duties/observations.js +12 -0
  78. package/dist/commands/duties/operating-review.d.ts +4 -30
  79. package/dist/commands/duties/operating-review.js +28 -141
  80. package/dist/commands/duties/receipt-metrics.js +7 -0
  81. package/dist/commands/duties/receipt.js +7 -0
  82. package/dist/commands/duties/roster.js +14 -8
  83. package/dist/commands/duties/show.js +27 -9
  84. package/dist/commands/duties/status.js +18 -9
  85. package/dist/commands/duties/trigger-status.d.ts +2 -0
  86. package/dist/commands/duties/trigger-status.js +19 -1
  87. package/dist/commands/duties/wake-capabilities.d.ts +2 -0
  88. package/dist/commands/duties/wake-capabilities.js +32 -2
  89. package/dist/commands/followups/act.js +3 -0
  90. package/dist/commands/followups/remind.js +12 -3
  91. package/dist/commands/followups/show.js +6 -0
  92. package/dist/commands/harnesses/quota.js +1 -1
  93. package/dist/commands/spaces/notebook.d.ts +3 -7
  94. package/dist/commands/spaces/notebook.js +32 -8
  95. package/dist/commands/tasks/create.d.ts +2 -2
  96. package/dist/commands/tasks/create.js +3 -3
  97. package/dist/commands/tasks/list.d.ts +3 -41
  98. package/dist/commands/tasks/list.js +5 -53
  99. package/dist/generated/agent-guides.json +424 -101
  100. package/dist/generated/managed-instruction-guides.json +1 -1
  101. package/dist/lib/agent-activity.d.ts +68 -0
  102. package/dist/lib/agent-activity.js +106 -0
  103. package/dist/lib/always-on-runtime.d.ts +9 -0
  104. package/dist/lib/always-on-runtime.js +20 -0
  105. package/dist/lib/api-fetch.d.ts +10 -0
  106. package/dist/lib/api-fetch.js +12 -2
  107. package/dist/lib/appData.d.ts +28 -1
  108. package/dist/lib/appData.js +111 -9
  109. package/dist/lib/appInstallations.d.ts +9 -1
  110. package/dist/lib/appInstallations.js +100 -0
  111. package/dist/lib/apps-command.d.ts +1 -0
  112. package/dist/lib/apps-command.js +11 -0
  113. package/dist/lib/apps.d.ts +12 -0
  114. package/dist/lib/apps.js +28 -1
  115. package/dist/lib/appsAssets.d.ts +17 -0
  116. package/dist/lib/appsAssets.js +15 -0
  117. package/dist/lib/appsCheck.d.ts +1 -0
  118. package/dist/lib/appsCheck.js +1 -0
  119. package/dist/lib/appsFs.d.ts +18 -1
  120. package/dist/lib/appsFs.js +76 -19
  121. package/dist/lib/compasses.js +6 -0
  122. package/dist/lib/duties.d.ts +25 -2
  123. package/dist/lib/duties.js +58 -3
  124. package/dist/lib/duty-analytics.d.ts +2 -0
  125. package/dist/lib/duty-analytics.js +26 -0
  126. package/dist/lib/duty-goal-propagation.d.ts +2 -0
  127. package/dist/lib/duty-goal-propagation.js +18 -0
  128. package/dist/lib/duty-history-source.d.ts +4 -0
  129. package/dist/lib/duty-history-source.js +12 -0
  130. package/dist/lib/duty-ledgers.d.ts +4 -0
  131. package/dist/lib/duty-ledgers.js +4 -0
  132. package/dist/lib/duty-receipt-source.d.ts +4 -0
  133. package/dist/lib/duty-receipt-source.js +19 -0
  134. package/dist/lib/followups.d.ts +20 -0
  135. package/dist/lib/followups.js +10 -0
  136. package/dist/lib/held-messages.d.ts +22 -0
  137. package/dist/lib/held-messages.js +55 -0
  138. package/dist/lib/list-workspace.d.ts +40 -0
  139. package/dist/lib/list-workspace.js +58 -0
  140. package/dist/lib/miniComputer.d.ts +59 -0
  141. package/dist/lib/miniComputer.js +224 -0
  142. package/dist/lib/miniComputerCommand.d.ts +13 -0
  143. package/dist/lib/miniComputerCommand.js +48 -0
  144. package/dist/lib/roles.d.ts +3 -3
  145. package/dist/lib/space-notebook.js +15 -4
  146. package/dist/node_modules/@skrr-ai/data-provider/index.js +10465 -8383
  147. package/oclif.manifest.json +2789 -533
  148. package/package.json +14 -2
@@ -2,7 +2,7 @@
2
2
  "oversky-task-management": {
3
3
  "key": "oversky-task-management",
4
4
  "name": "skrr Task Management",
5
- "templateVersion": 23,
5
+ "templateVersion": 24,
6
6
  "body": "## OverSky Task Management\n\nUse `skrr` as the durable record for work that must outlive this conversation.\n\n### One concept, one record\n\n- **Task** says what is owed and where it stands.\n- **Expectation** says what must be true before the Task can close.\n- **Update** says what meaningfully changed during execution.\n- **Resume Point** says where one Run can safely continue after interruption.\n- **Result** says what the work concluded or returned.\n- **Deliverable** identifies a concrete Resource version produced by the work.\n- **Review** says whether another actor accepted one exact Result.\n- **Comment** is replyable collaboration.\n- **Activity** is the immutable audit projection. A Run transcript is detailed telemetry, not Activity.\n\nDo not put a Result in a Comment, use an Update as a transcript, or use review words such as\n“approved” for a domain conclusion such as NO-SHIP.\n\nThe platform derives Human, Agent, Run, session, and recording provenance from the authenticated\nruntime. Never supply or invent an Agent identity. An Update has one author; a multi-Agent summary\nmay cite contributors and their source Runs or Updates.\n\n### During execution: write Updates at meaningful boundaries\n\nDo not log routine reads, tool calls, heartbeats, token counts, or repeated “still working” narration.\nRecord an Update only when a future reader or replacement Run needs to know that shared state changed:\n\nEach type has a REQUIRED `--data` shape, and the array fields are required even when empty.\nOptional fields are marked `?`. The server rejects a missing required field, so guessing from the\nprose costs a round trip:\n\n- `progress`: a material part is complete.\n `{completedSinceLast: string[], nextActions: string[], currentFocus?}`\n- `finding`: a newly discovered fact. `impact` is optional; the evidence references are not.\n `{finding, evidenceRefs: [], impact?, severity?}`\n- `decision`: a choice now constrains the work.\n `{decision, rationale, alternativesConsidered?: string[]}`\n- `blocker`: work cannot continue. `nextOwner` is a principal OBJECT, not a name.\n `{cause, requiredAction, nextOwner: {kind: \"human\", userId}}`\n- `verification`: a claim was checked. `result` is one of `passed`, `failed`, `inconclusive`.\n `{claim, result, evidenceRefs: []}`\n- `ready_for_review`: created by Result submission; do not author it separately.\n\n`--reference <kind>:<id>` sets the Update's OWN references. It does not populate\n`data.evidenceRefs`, which belongs inside `--data`.\n\nUse one stable idempotency key only for retries of the identical write. Reusing it for different\ncontent is rejected.\n\nExample:\n\n```bash\nskrr tasks updates add <task-id> \\\n --type progress \\\n --summary \"Migration review complete\" \\\n --data '{\"completedSinceLast\":[\"Checked migrations 001-014\"],\"currentFocus\":\"Authorization review\",\"nextActions\":[\"Inspect legacy adapters\"]}' \\\n --idempotency-key \"<task-id>:migration-review\"\n```\n\nFor a decision:\n\n```bash\nskrr tasks updates add <task-id> \\\n --type decision \\\n --summary \"Use a first-class Resource identity\" \\\n --data '{\"decision\":\"Use WorkResource plus immutable versions\",\"rationale\":\"A URL can move and cannot identify the version a reviewer accepted\"}' \\\n --idempotency-key \"<task-id>:resource-model\"\n```\n\nFor a finding — `evidenceRefs` is required and may be empty:\n\n```bash\nskrr tasks updates add <task-id> \\\n --type finding \\\n --summary \"The closure gate reads assessments by exact specVersion\" \\\n --data '{\"finding\":\"A cosmetic title edit bumps specVersion, so every prior assessment stops counting\",\"impact\":\"A task with expectations cannot be closed after a rename\",\"evidenceRefs\":[{\"kind\":\"code\",\"uri\":\"api/server/services/TaskClosurePolicy/index.js\"}]}' \\\n --idempotency-key \"<task-id>:spec-bump-revocation\"\n```\n\nFor a blocker — `nextOwner` is a principal object:\n\n```bash\nskrr tasks updates add <task-id> \\\n --type blocker \\\n --summary \"Waiting on production database credentials\" \\\n --data '{\"cause\":\"The migration needs write access to the prod cluster\",\"requiredAction\":\"Grant the deploy role write access, or run the migration yourself\",\"nextOwner\":{\"kind\":\"human\",\"userId\":\"<user-id>\"}}' \\\n --idempotency-key \"<task-id>:needs-prod-credentials\"\n```\n\nFor a verification:\n\n```bash\nskrr tasks updates add <task-id> \\\n --type verification \\\n --summary \"Re-ran the closure flow end to end after the fix\" \\\n --data '{\"claim\":\"A renamed task with one assessed expectation can close\",\"result\":\"passed\",\"evidenceRefs\":[{\"kind\":\"task\",\"id\":\"<task-id>\"}]}' \\\n --idempotency-key \"<task-id>:closure-reverify\"\n```\n\n### Media: screenshots and recordings\n\n`--attach <path>` (repeatable) on `updates add`, `result submit`, `complete`, or `comments add`\nuploads a file as a Task asset and cites it; identical bytes dedupe. In-run proof goes on a\n`verification` or `progress` Update, the final before/after on the Result, never the description.\nAn upload is `self_reported` evidence and counts toward the storage quota. Images keep full\nresolution minus metadata (Runs get a model-sized copy); undecodable bytes get 422, a type the bytes\ncontradict 415, and SVG downloads as a file. An agent uploads evidence (the default) or\n`--role deliverable`; `input` is refused (403): ask a person to run `attachments set-role`. Cite a\ndeliverable as `--evidence task_attachment:<asset-id>` when you assess its Expectation.\n\n### Recovery: Update delta and Resume Point snapshot\n\nWhen a semantic boundary should also be resumable, add `--run-id` and `--resume` to the same Update\ncommand. The server commits the visible Update and the Run-bound Resume Point together. The snapshot\nmust be self-contained enough for another capable Agent to continue without replaying the transcript:\ncompleted work, current focus, next actions, open questions, and references to decisions, evidence,\nDeliverables, and durable workspace state.\n\nThe runtime may save a silent crash-safety snapshot with:\n\n```bash\nskrr tasks resume save <task-id> --run-id <run-id> --snapshot '<resume-json>'\n```\n\nNever put credentials, secrets, permission grants, bearer tokens, or leases in a Resume Point. A\nresumed Run reloads the current Task Revision, re-authorizes, validates referenced files/commits, and\nreads Updates recorded after the snapshot:\n\n```bash\nskrr tasks resume show <task-id> --run-id <run-id>\n```\n\n### Deliverables: lightweight input, first-class identity\n\nA user may provide one coordinate, but the platform records a WorkResource, its exact version, the\nTask relationship, and an evidence-backed availability observation. External reference is the\ndefault; OverSky-managed content is used only when retention, stable access, preview/search, or\npolicy requires a copy.\n\n```bash\nskrr tasks deliverable add <task-id> \\\n file/markdown:docs/reviews/report.md@docs/reviews/report.md \\\n --status in_review\n```\n\nA recording made by its producer is always self-reported; the caller cannot promote itself to a\nHuman confirmation, system observation, or provider receipt. A local path is only local availability. A commit, provider revision, digest, or managed object\nfreezes the exact version. Do not call “in the conversation” a Deliverable.\n\nA Human confirms the exact linked version, not a retyped URL or name:\n\n```bash\nskrr tasks deliverable confirm <task-id> <task-resource-link-id> --reason \"Opened and checked this exact version\"\n```\n\n### Result and Review are separate\n\nSubmit the finished answer once:\n\n```bash\nskrr tasks result submit <task-id> \\\n --summary \"NO-SHIP until remediation Gates A-D pass\" \\\n --conclusion-type release_recommendation \\\n --conclusion-json '{\"posture\":\"no_ship\"}' \\\n --deliverable <task-resource-link-id>\n```\n\nAn amendment creates a new Result version and explicitly supersedes the previous one. There is one\ncurrent Result; old versions remain in Activity and are not ordinary Updates.\n\nOnly another actor records acceptance, against that exact Result:\n\n```bash\nskrr tasks review <task-id> --result-id <result-id> --decision accepted --rationale \"Evidence checked\"\n```\n\n“Accepted” means the submitted work was accepted. NO-SHIP, BUY, REJECT, root cause, experiment\ndecision, and similar subject-matter conclusions belong in `Result.conclusion`, never in Review.\n\nUse `skrr tasks complete` only when submitting the Result and advancing workflow in one closeout.\nDo not call `tasks report` before or after it; `tasks complete` already creates the canonical Result.\n\nSubmitting a Result is not the same as closing the Task, and being an Agent is not by itself a\nreason to stop. Closing is always the closer's call — unmet Expectations or a Changes-requested\nReview do not prevent it; they are RECORDED on the close (`resolution.closure`), so closing over\nthem hides nothing and settles nothing. The one exception is an owner-declared required Review\n(`--review-policy required`): a non-owner cannot close without it — unless they close with\n`--force`, which records the override on the resolution — and the owner always can.\n\nSo do not predict the outcome. `result submit` reports where the Task stands after the write —\nread that, and if you need to ask again later:\n\n```bash\nskrr tasks expectations <task-id> # what is owed, and why the Result cannot be accepted yet\n```\n\nSay “ready for review” only when something you read actually said so.\n\n### Expectations\n\nExpectations are free text first. A typed check explains how the statement can be assessed; it never\nreplaces the sentence.\n\nAn Expectation is an obligation, not a lock: it does not stop a close, it is recorded on one — and\nclosing over it settles nothing. Write each one so it can\nbe judged — say what would satisfy it and how that could be checked — because an Expectation authored\nwithout a thought about verification is one you will later be unable to settle honestly. When you\ncreate several across several Tasks, say how many you created and who they fall to; a set of gates\nnobody was told about is work assigned by accident. A Deliverable requirement is one typed Expectation, not a second\n`requiredDeliverables` list. Actual Deliverables are recorded only after something exists.\n\nRead what is owed, then settle it — never rewrite the declaration to make it settleable:\n\n```bash\nskrr tasks expectations <task-id> # what is owed, and how far each one got\nskrr tasks expectations assess <task-id> <expectation-id> \\\n --decision met \\\n --reason \"Ran the suite named in the statement; 49/49 pass\" \\\n --evidence code:<commit>\nskrr tasks expectations assess <task-id> --all \\\n --decision met --reason \"...\" # every one still awaiting a judgement\n```\n\n**You may assess any Expectation that takes a judgement.** A `deliverable` Expectation is not one —\nit settles through its linked Resource and evidence, so record the Deliverable rather than\nassessing it. The assessment is recorded as YOURS — every surface shows `met (agent)` against\n`met (person)` — and a human can override it. The control is attribution, not permission, so what\nyou owe is not restraint but evidence: cite what you actually checked, and prefer `--evidence` and\n`--resource-link-id` over prose.\n\nAssess what you VERIFIED. Not what you intended, not what you inferred from having finished the\nwork. “I could not check this” is a real and useful answer — record it `unmet` with the reason\nrather than leaving it silent, because an unassessed Expectation and one you tried and failed to\nverify send the next reader to different places.\n\nA waiver is a judgement about scope — that this is no longer owed — and it stays a person's call:\nif the honest answer is \"this should be waived,\" say so in an Update or Comment and let a person\nrecord it. Do not delete the Expectation to hide that it was owed.\n\nChanging an Expectation's wording advances the Task specification and **revokes every assessment\nalready recorded** — fix the statement before people start settling it, not after.\n\n### Labels — say what PROGRAM this belongs to\n\nA label is cross-cutting classification: which recurring program a Space or Task\nbelongs to (`dogfood`, `incident`, `experiment`, `migration`), not what state it\nis in. Status, priority and assignee are first-class fields and already answer\ntheir own questions — a label that restates one is noise that will drift out of\nsync with the field it copies.\n\nThe vocabulary is DECLARED, not invented. Read it before you use it:\n\n```bash\nskrr labels list\n```\n\nAttach from that list, never a name you made up. A second spelling of an\nexisting label (`dog-food` beside `dogfood`) is worse than no label at all,\nbecause the whole value of one is that filtering on it returns everything:\n\n```bash\nskrr spaces labels add <space-id> --label <label-id>\nskrr tasks labels attach <task-id> --label <label-id>\n```\n\nCreate a label only when the program it names is real and recurring, and say\nwhich entities it applies to — a label created without `--applicable-to space`\ncannot be attached to a Space, which is how a vocabulary comes to exist that\nnothing can use:\n\n```bash\nskrr labels create --name <name> --applicable-to space --applicable-to task\n```\n\nWhen you create a Space or Task for a recurring program, label it as you create\nit (`--label <id>` on `spaces`, `tasks` and `goals create`). The create\nresponse carries a `_labelGuidance` hint naming the applicable vocabulary WITH\nITS IDS when you attached none — read it, and attach in one follow-up call if\none of them fits. It may also carry `suggested` — a proposal, not a decision;\nattach is your call. `skrr tasks labels suggest <task-id>` asks it of a Task.\n\nIf nothing in the vocabulary fits, attach nothing. \"No label\" is a correct\nanswer and a wrong label is not.\n\n### Comments and blockers\n\nUse a Comment only for a question, answer, or review discussion where a reply is useful. For a\nblocker, first record the typed blocker Update, then move the Task to blocked. Add a Comment only if\nsomeone actually needs to respond.\n\n### Creating and placing Tasks\n\nCreate a Task without asking when work needs tracking across meaningful steps, sessions, or\nfollow-up. Avoid duplicates and do not create Tasks for trivial actions that finish immediately.\n\n```bash\nskrr tasks list --q \"<relevant title>\"\nskrr tasks create --title \"<concise requested result>\" --description \"<scope and constraints>\" --json\nskrr tasks move <task-id> --status in_progress\n```\n\nA Space is a durable ownership, collaboration, and authorization boundary. Use an identified Space\nwhen the work clearly belongs there; otherwise create the Task unscoped. Ask before creating a new\nSpace. An Agent works a Task in a Space only as a Space member, or when it is shared with no one\nelse and its owner assigns and starts it; anything else is refused. Do not widen Agent membership\nmerely to force one task assignment.\n\n### Closing a Task out\n\nThe model above says what each record IS. This is the order they go in, and what each step can\nrefuse:\n\n1. **Record what exists** — `skrr tasks deliverable add`, binding it to the Expectation it answers\n with `--expectation <id>` whenever one applies. Evidence that arrives bound is evidence the next\n reader does not have to reconstruct.\n2. **Submit the answer** — `skrr tasks result submit`. This does not close the Task. Read what it\n reports back.\n3. **Read what is still owed** — `skrr tasks expectations <task-id>`.\n4. **Settle what you verified** — `skrr tasks expectations assess`, citing evidence. `--all` covers\n every Expectation still awaiting a judgement.\n5. **Read the Task state again and report THAT** — not what you intended it to be.\n\nTwo things still matter regardless of how complete the work is: an unmet Expectation, and a\n`changes_requested` Review. Neither blocks a close — but both are stamped onto it\n(`resolution.closure`), so closing over them is a recorded choice, not a clean finish. Neither is\na failure state; both are somebody's turn.\n\nStep 5 is the one that goes wrong quietly, and not only here: before reporting a check as passed,\nconfirm you measured what you think you measured. A pipeline's exit status is the LAST command's, so\n`cmd | tail` reports on `tail`. A filter may match something other than what you meant — a path\npattern can match the directory you are working in. When a result will be reported to a person as\nfact, re-run it in the simplest form that can only mean one thing.\n\nAcross a whole Space, `skrr tasks review-queue --space <space-id>` names every outstanding\njudgement at once, with its evidence and the command that settles it.\n\n### Share readable links and close the loop\n\nShare clickable Task, Space, Goal, and Duty URLs, never bare IDs. Use the URL returned by the\nCLI; do not construct one. If needed:\n\n```bash\nskrr tasks show <task-id> --json\nskrr spaces show <space-id> --json\nskrr goals show <goal-id> --json\nskrr duties show <duty-id> --json\n```\n\nBefore your final response, verify every Task you created or touched reflects reality. If work is\nready for independent review, leave it in review. If blocked, record the blocker and required action.\nIf genuinely complete and accepted under the Task's policy, close it. Include the Task URL in the\nfinal handoff. Never claim a write succeeded unless the CLI returned success.\n\n### Coming back later\n\nYou can arrange to return to something. Four shapes, and picking the right one\nmatters more than the wording:\n\n**Reminder** — the user asked to be reminded. Keep their words; a reminder you\nhave rephrased into your own voice is no longer the thing they asked for.\n\n**Watch** — something has an asynchronous tail: CI, a review, an approval, a\nlong job, a metric. If the condition is machine-checkable (an endpoint plus a\npredicate), say so — that costs nothing and is guaranteed to terminate. Only\nwrite a prose check recipe when the check genuinely needs your judgement or your\ntools, because that one burns a full turn every time it runs. Always give it an\nabort condition: a watch that cannot stop is a leak.\n\n**Check-in** — you decided the conversation is worth returning to. This is\npermission AND restraint. Come back when you will have something worth saying —\na result that will have arrived, a decision that will be ripe, a thread you left\ngenuinely open. When you see one, arrange the return yourself and say in one\nline when you will look again. Do not ask whether you should: that hands the\nperson a decision they did not come to make. Do not come back to ask how it is\ngoing. A legacy check-in holds one pending return per conversation. For a sequence\nof checks, use one scheduled lookback plan with 1–10 lifetime steps. When you\nwake, read the original goal, current state and earlier outcomes. Saying\nnothing is a legitimate outcome and often the right one. Stop or cancel\nremaining checks when the work resolves, becomes obsolete or the person cancels.\n\n**Act** — a specific action you already know how to take and the user has already\nagreed to. Not for anything you would still need to ask about.\n\nSettle what you arranged. When you wake and the thing resolved, say so and close\nit out; when it did not, either come back once more with a reason or hand it to\nthe person. Leaving one armed forever is the failure mode here.\n\nFrom a local session, arrange these with `skrr followups` —\n`remind`, `watch`, `checkin`, `act` — and settle them with\n`skrr followups resolve <id> --outcome resolved`.\nFor a bounded lookback plan, use `skrr followups plans create --from-json plan.json`\nand inspect, revise or cancel it with `skrr followups plans` (read `--help`).\nUse 1–10 concrete checks, relative offsets from the completed reply or explicit\nabsolute/local times, and a stop condition. Omit a plan when none is useful.\nA saved plan is not necessarily armed; read the returned receipt before promising a return.\n",
7
7
  "hash": "6804d01c68782b97a16920c43f6b9104a8b0c0a512514b25a7622b371055f669"
8
8
  }
@@ -0,0 +1,68 @@
1
+ import type { ResolvedCredential } from './credential-resolver';
2
+ export type ActivityScope = 'user' | 'agent' | 'duty';
3
+ export interface ActivitySourceRef {
4
+ kind: string;
5
+ keys: Record<string, string>;
6
+ }
7
+ export interface ActivityItem {
8
+ id: string;
9
+ sourceKind: string;
10
+ timestamp: string;
11
+ status: string;
12
+ title: string;
13
+ sourceRef: ActivitySourceRef;
14
+ agentId?: string;
15
+ dutyId?: string;
16
+ /** Task executions only: what the ledger proves about handing the run to its executor. */
17
+ dispatch?: {
18
+ state: string;
19
+ };
20
+ runtime?: {
21
+ state: string;
22
+ selectedMachineProduct?: string;
23
+ /** The resolver's trace of the targets it weighed (the table shows how many, `--json` the rest). */
24
+ considered?: Array<{
25
+ index: number;
26
+ outcome: string;
27
+ machineProduct?: string;
28
+ category?: string;
29
+ }>;
30
+ };
31
+ content?: {
32
+ state: string;
33
+ };
34
+ }
35
+ export interface ActivityResponse {
36
+ object: 'agent_activity';
37
+ scope: ActivityScope;
38
+ items: ActivityItem[];
39
+ hasMore: boolean;
40
+ nextCursor: string | null;
41
+ ordering: string;
42
+ coverage: Array<{
43
+ source: string;
44
+ state: string;
45
+ reason?: string;
46
+ }>;
47
+ }
48
+ /** The API authorizes each source; a source reference is never an access grant. */
49
+ export declare function listAgentActivity(options: {
50
+ scope: ActivityScope;
51
+ agentId?: string;
52
+ dutyId?: string;
53
+ limit?: number;
54
+ cursor?: string;
55
+ }, credential?: ResolvedCredential): Promise<ActivityResponse>;
56
+ /**
57
+ * Show source keys without synthesizing commands from untrusted identifiers.
58
+ * Whether details are available depends on the individual source.
59
+ */
60
+ export declare function sourceLabel(ref: ActivitySourceRef | undefined): string;
61
+ /**
62
+ * The RUNTIME cell: the placement state, then what the server knows beyond it. A run says where it
63
+ * was bound and how many targets the resolver weighed; a Task execution says what its hand-off
64
+ * proves. A queue acknowledgement is acceptance, never a provider start, so it is worded as such.
65
+ * Every value is untrusted text and goes through `formatCell`.
66
+ */
67
+ export declare function runtimeCell(item: ActivityItem): string;
68
+ export declare function renderAgentActivity(response: ActivityResponse, log: (line: string) => void): void;
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listAgentActivity = listAgentActivity;
4
+ exports.sourceLabel = sourceLabel;
5
+ exports.runtimeCell = runtimeCell;
6
+ exports.renderAgentActivity = renderAgentActivity;
7
+ const api_fetch_1 = require("./api-fetch");
8
+ const format_1 = require("./format");
9
+ /** The API authorizes each source; a source reference is never an access grant. */
10
+ function listAgentActivity(options, credential) {
11
+ const query = new URLSearchParams({ scope: options.scope });
12
+ if (options.agentId)
13
+ query.set('agentId', options.agentId);
14
+ if (options.dutyId)
15
+ query.set('dutyId', options.dutyId);
16
+ if (options.limit !== undefined)
17
+ query.set('limit', String(options.limit));
18
+ if (options.cursor)
19
+ query.set('cursor', options.cursor);
20
+ return (0, api_fetch_1.apiFetch)(`/api/agent-activity?${query.toString()}`, { credential });
21
+ }
22
+ /**
23
+ * Show source keys without synthesizing commands from untrusted identifiers.
24
+ * Whether details are available depends on the individual source.
25
+ */
26
+ function sourceLabel(ref) {
27
+ if (!ref?.keys || typeof ref.keys !== 'object')
28
+ return 'unavailable';
29
+ const pairs = Object.entries(ref.keys).map(([key, value]) => `${key}=${(0, format_1.formatCell)(value)}`);
30
+ return pairs.length ? pairs.join(' ') : 'unavailable';
31
+ }
32
+ /**
33
+ * The RUNTIME cell: the placement state, then what the server knows beyond it. A run says where it
34
+ * was bound and how many targets the resolver weighed; a Task execution says what its hand-off
35
+ * proves. A queue acknowledgement is acceptance, never a provider start, so it is worded as such.
36
+ * Every value is untrusted text and goes through `formatCell`.
37
+ */
38
+ function runtimeCell(item) {
39
+ const runtime = item.runtime;
40
+ const parts = [(0, format_1.formatCell)(runtime?.state, 'unknown')];
41
+ if (runtime?.selectedMachineProduct)
42
+ parts.push((0, format_1.formatCell)(runtime.selectedMachineProduct));
43
+ const considered = runtime?.considered;
44
+ const weighed = Array.isArray(considered) ? considered.length : 0;
45
+ if (weighed > 1 || (weighed === 1 && runtime?.state === 'not_bound')) {
46
+ parts.push(`${weighed} weighed`);
47
+ }
48
+ const handoff = item.dispatch?.state;
49
+ if (handoff && handoff !== 'unknown')
50
+ parts.push(`hand-off ${(0, format_1.formatCell)(handoff)}`);
51
+ return parts.join(' · ');
52
+ }
53
+ function renderAgentActivity(response, log) {
54
+ log(`Activity · ${response.scope}`);
55
+ const items = Array.isArray(response.items) ? response.items : [];
56
+ if (items.length) {
57
+ (0, format_1.renderTable)(items.map((item) => ({
58
+ when: (0, format_1.localTime)(item.timestamp),
59
+ source: (0, format_1.formatCell)(item.sourceKind),
60
+ status: (0, format_1.formatCell)(item.status, 'unknown'),
61
+ title: (0, format_1.formatCell)(item.title),
62
+ reference: sourceLabel(item.sourceRef),
63
+ runtime: runtimeCell(item),
64
+ content: (0, format_1.formatCell)(item.content?.state, 'unknown'),
65
+ })), [
66
+ { key: 'when', header: 'WHEN' },
67
+ { key: 'source', header: 'SOURCE' },
68
+ { key: 'status', header: 'STATUS' },
69
+ { key: 'title', header: 'ACTIVITY', maxWidth: 36 },
70
+ { key: 'reference', header: 'SOURCE REFERENCE', verbatim: true },
71
+ { key: 'runtime', header: 'RUNTIME' },
72
+ { key: 'content', header: 'CONTENT' },
73
+ ], log);
74
+ }
75
+ else {
76
+ log('No activity returned for the available sources.');
77
+ }
78
+ // No result from a source that failed or is not implemented is not proof of
79
+ // no activity. Always print the server's coverage, even on an empty page.
80
+ if (items.length) {
81
+ log('');
82
+ log('Detail: activity show --trigger <triggerId> --fire <occurrenceId>,');
83
+ log(' or activity show --duty <dutyId>.');
84
+ log('Task run content is not connected to Activity; open the Task for its authorized history.');
85
+ log('Chat source: messages show <conversationId> <messageId> (subject to conversation access).');
86
+ }
87
+ log('');
88
+ const coverage = Array.isArray(response.coverage) ? response.coverage : [];
89
+ if (!coverage.length)
90
+ log('Coverage: unknown');
91
+ else {
92
+ log('Coverage:');
93
+ for (const item of coverage) {
94
+ log(` ${(0, format_1.formatCell)(item.source)}: ${(0, format_1.formatCell)(item.state, 'unknown')}${item.reason ? ` (${(0, format_1.formatCell)(item.reason)})` : ''}`);
95
+ }
96
+ }
97
+ if (response.hasMore && response.nextCursor) {
98
+ log('');
99
+ log(`Next cursor: ${response.nextCursor}`);
100
+ log('Pass this cursor with the same scope and filters to read the next page.');
101
+ }
102
+ else if (response.hasMore) {
103
+ log('');
104
+ log('More activity may be available, but the server did not return a cursor.');
105
+ }
106
+ }
@@ -1,3 +1,4 @@
1
+ import type { AlwaysOnExecutionReadiness } from '@skrr-ai/data-provider';
1
2
  /**
2
3
  * Where an Always-On Agent's work has to run, as `skrr agents always-on status`
3
4
  * prints it (OSK-22347).
@@ -28,4 +29,12 @@ export declare function runtimeFromAgent(agent: AgentRuntimeFields | null | unde
28
29
  export declare const RUNTIME_READ_FAILED: AlwaysOnRuntimeRead;
29
30
  /** Lines to print under `Operational:`; empty when there is no machine involved. */
30
31
  export declare function runtimeLines(runtime: AlwaysOnRuntimeRead, desiredEnabled: boolean): string[];
32
+ /**
33
+ * One line when Always-On is wanted and the status read says the machine is online but its Skrr
34
+ * cannot run the Agent's scheduled work (`capability_missing`), and nothing otherwise. Any other
35
+ * reason an execution target is `blocked` has its own lines or none here, a server that did not
36
+ * send the field says nothing either way, and an Agent that is off has no scheduled work to fail.
37
+ * The words are the server's (fixed platform text, never a machine's).
38
+ */
39
+ export declare function executionReadinessLines(readiness: AlwaysOnExecutionReadiness | null | undefined, desiredEnabled: boolean): string[];
31
40
  export {};
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RUNTIME_READ_FAILED = void 0;
4
4
  exports.runtimeFromAgent = runtimeFromAgent;
5
5
  exports.runtimeLines = runtimeLines;
6
+ exports.executionReadinessLines = executionReadinessLines;
6
7
  function runtimeFromAgent(agent) {
7
8
  // An Agent with no harness runs in the cloud: there is no machine to be off.
8
9
  if (!agent || !agent.harnessId)
@@ -37,3 +38,22 @@ function runtimeLines(runtime, desiredEnabled) {
37
38
  return [`Runtime: online${label}`];
38
39
  return [`Runtime: unknown${runtime.readFailed ? ' (could not read the Agent)' : label}`];
39
40
  }
41
+ /**
42
+ * One line when Always-On is wanted and the status read says the machine is online but its Skrr
43
+ * cannot run the Agent's scheduled work (`capability_missing`), and nothing otherwise. Any other
44
+ * reason an execution target is `blocked` has its own lines or none here, a server that did not
45
+ * send the field says nothing either way, and an Agent that is off has no scheduled work to fail.
46
+ * The words are the server's (fixed platform text, never a machine's).
47
+ */
48
+ function executionReadinessLines(readiness, desiredEnabled) {
49
+ if (!desiredEnabled || readiness?.state !== 'blocked')
50
+ return [];
51
+ const constraints = Array.isArray(readiness.constraints) ? readiness.constraints : [];
52
+ const missing = constraints.find((c) => c?.code === 'capability_missing');
53
+ if (!missing)
54
+ return [];
55
+ const text = [missing.message, missing.requiredAction]
56
+ .filter((part) => typeof part === 'string' && part.length > 0)
57
+ .join(' ');
58
+ return [`Execution: blocked${text ? ` — ${text}` : ''}`];
59
+ }
@@ -14,6 +14,16 @@ export interface ApiFetchOptions {
14
14
  * without one.
15
15
  */
16
16
  headers?: Record<string, string>;
17
+ /**
18
+ * A body sent as it is: the bytes of a file, with `Content-Type: application/octet-stream`, not JSON (Dynamic Agent Apps'
19
+ * upload door for an image or a font). Used INSTEAD of `body`; a caller that passes both gets the raw bytes.
20
+ */
21
+ rawBody?: Uint8Array;
22
+ /**
23
+ * What the answer is. `json` (the default) is what every endpoint here returns; `bytes` returns the response body as a
24
+ * `Uint8Array` (a download of a file). An error response is read as text and thrown either way.
25
+ */
26
+ responseAs?: 'json' | 'bytes';
17
27
  /**
18
28
  * Caller-owned cancellation. Added for OSK-3892: `skrr code`'s managed-session
19
29
  * acquisition promises the user ONE bound for the whole handshake, and without
@@ -130,8 +130,12 @@ async function apiFetch(pathOrUrl, opts = {}) {
130
130
  // (tasks attachments) need this on the session-scoped path, which is not
131
131
  // in dataService.
132
132
  const isFormData = typeof FormData !== 'undefined' && opts.body instanceof FormData;
133
+ const isRaw = opts.rawBody !== undefined && method !== 'GET';
133
134
  let body;
134
- if (opts.body !== undefined && method !== 'GET') {
135
+ if (isRaw) {
136
+ body = opts.rawBody;
137
+ }
138
+ else if (opts.body !== undefined && method !== 'GET') {
135
139
  body = isFormData ? opts.body : JSON.stringify(opts.body);
136
140
  }
137
141
  // Same rule as every `dataService` write (`@skrr-ai/data-provider`
@@ -182,7 +186,10 @@ async function apiFetch(pathOrUrl, opts = {}) {
182
186
  Accept: 'application/json',
183
187
  'X-Oversky-Origin': (0, refresh_1.getCliOrigin)(),
184
188
  };
185
- if (opts.body !== undefined && method !== 'GET' && !isFormData) {
189
+ if (isRaw) {
190
+ headers['Content-Type'] = 'application/octet-stream';
191
+ }
192
+ else if (opts.body !== undefined && method !== 'GET' && !isFormData) {
186
193
  headers['Content-Type'] = 'application/json';
187
194
  }
188
195
  if (credential.token) {
@@ -309,6 +316,9 @@ async function apiFetch(pathOrUrl, opts = {}) {
309
316
  error.retryAfterMs = lastRetryAfterMs;
310
317
  throw error;
311
318
  }
319
+ if (opts.responseAs === 'bytes') {
320
+ return new Uint8Array(await res.arrayBuffer());
321
+ }
312
322
  // 204/205 carry no body by definition; an empty body has no content-type
313
323
  // worth judging. Neither is an error.
314
324
  if (res.status === 204 || res.status === 205) {
@@ -1,4 +1,4 @@
1
- import type { AppPersonDataRefusal, AppStoreConflict, AppStoreDocView, AppStoreQueryResult } from '@skrr-ai/data-provider';
1
+ import type { AppInstallationDataCatalog, AppPersonDataRefusal, AppStoreConflict, AppStoreDocView, AppStoreQueryResult } from '@skrr-ai/data-provider';
2
2
  /** Why the input could not be used; never carries what was in it. */
3
3
  export declare class AppDataInputError extends Error {
4
4
  readonly code: 'APP_DATA_SOURCE' | 'APP_DATA_NOT_JSON' | 'APP_DATA_NOT_OBJECT' | 'APP_DATA_WHERE';
@@ -27,6 +27,8 @@ export type PersonDataFailure = {
27
27
  conflict: AppStoreConflict;
28
28
  status?: number;
29
29
  currentRev?: number;
30
+ /** A batch: which write (by position) could not apply. */
31
+ index?: number;
30
32
  };
31
33
  /**
32
34
  * What the person channel answered, read out of an API error: a refusal (`{ error, code, message }`, the code from
@@ -56,7 +58,27 @@ export declare function describePersonDataConflict(failure: Extract<PersonDataFa
56
58
  installation: string;
57
59
  collection: string;
58
60
  id: string;
61
+ verb?: 'put' | 'patch' | 'delete' | 'batch';
59
62
  }, bin: string): string;
63
+ /** The `set` of a patch (a JSON object of path -> value) and the `unset` paths. What a path may be is the server's parser's to say. */
64
+ export declare function readPatchInput(input: {
65
+ set?: string;
66
+ unset?: string[];
67
+ }): {
68
+ set?: Record<string, unknown>;
69
+ unset?: string[];
70
+ };
71
+ /**
72
+ * The writes of a batch, from exactly one of `--writes`, `--from-file` and `--stdin`: a JSON list, or `{ "writes": [...] }`.
73
+ * Each write is `{ op: "put" | "patch" | "delete", collection, ... }`; the server's parser says what each may hold.
74
+ */
75
+ export declare function readBatchInput(input: {
76
+ writes?: string;
77
+ fromFile?: string;
78
+ stdin?: boolean;
79
+ }): Promise<{
80
+ writes: Array<Record<string, unknown>>;
81
+ }>;
60
82
  /**
61
83
  * Text that came from an app's data, safe to print: a control character, a C1 control, a line or paragraph separator,
62
84
  * a bidirectional override and a character that draws nothing (a zero-width character, a variation selector, a Unicode tag character:
@@ -73,3 +95,8 @@ export declare function formatQueryResult(result: AppStoreQueryResult, target: {
73
95
  }, bin: string): string[];
74
96
  /** The limit the reference and this help text share, so a number is never typed twice. */
75
97
  export declare const PERSON_DATA_QUERY_LIMIT_MAX: 200;
98
+ /**
99
+ * The catalog of an installation's collections as lines for a terminal. Every name and description is the app author's
100
+ * words, so each goes through {@link safeForTerminal}; the catalog's notice (they are not instructions) ends it.
101
+ */
102
+ export declare function formatCollections(catalog: AppInstallationDataCatalog): string[];
@@ -8,9 +8,12 @@ exports.personDataFailureExit = personDataFailureExit;
8
8
  exports.personDataFailureRetryable = personDataFailureRetryable;
9
9
  exports.describePersonDataRefusal = describePersonDataRefusal;
10
10
  exports.describePersonDataConflict = describePersonDataConflict;
11
+ exports.readPatchInput = readPatchInput;
12
+ exports.readBatchInput = readBatchInput;
11
13
  exports.safeForTerminal = safeForTerminal;
12
14
  exports.formatDocument = formatDocument;
13
15
  exports.formatQueryResult = formatQueryResult;
16
+ exports.formatCollections = formatCollections;
14
17
  /**
15
18
  * `skrr apps data put | query`: what the commands that write and read an installed app's OWN documents, as the
16
19
  * signed-in person, share. The domain lib of the person channel; the authoring loop's is `lib/apps.ts` and the
@@ -137,6 +140,7 @@ function readPersonDataFailure(error) {
137
140
  conflict,
138
141
  ...status,
139
142
  ...(typeof body.currentRev === 'number' ? { currentRev: body.currentRev } : {}),
143
+ ...(typeof body.index === 'number' ? { index: body.index } : {}),
140
144
  };
141
145
  }
142
146
  const code = data_provider_1.APP_PERSON_DATA_REFUSALS.includes(body.code)
@@ -180,9 +184,9 @@ function personDataFailureRetryable(failure) {
180
184
  return failure.kind === 'refusal' && (failure.code === 'rate' || failure.code === 'unavailable');
181
185
  }
182
186
  const REFUSAL_WORDS = {
183
- human_only: (bin) => `Only a signed-in person can write an app's data this way. This credential is not one (an agent's, a workload's or an access token). Sign in as yourself with \`${bin} login\`.`,
187
+ human_only: (bin) => `Only a signed-in person, or an Agent's credential on a machine (the one the platform gives a harness it launched, or a Hosted Machine's own sign-in), can use an app's data this way. This credential is neither (an access token). Sign in as yourself with \`${bin} login\`.`,
184
188
  not_found: () => 'There is no such installation that you can see.',
185
- not_granted: () => 'A person may not write this collection here. The running version must list it in capabilities.store and name "person" in its write list, and the person who installed the app must have approved that. Nothing was written.',
189
+ not_granted: () => 'This credential may not write this collection here. The running version must list it in capabilities.store and name the writer you are in its write list ("person" for a signed-in person, "agent" for an Agent\'s credential), and the person who installed the app must have approved that. Nothing was written.',
186
190
  forbidden_by_viewer: () => 'You do not have permission to do this on the agent this app is installed on (writing needs edit access, reading needs view access). Nothing was written.',
187
191
  grant_stale: (bin) => `This app changed since it was approved. Approve it again with \`${bin} apps reconsent <installation>\` and try again.`,
188
192
  schema: () => 'The request does not fit this operation (the collection name, the document id, the document, or a query parameter). Nothing was written.',
@@ -204,28 +208,98 @@ function describePersonDataRefusal(failure, bin) {
204
208
  */
205
209
  function describePersonDataConflict(failure, target, bin) {
206
210
  const read = `${bin} apps data query ${target.installation} ${target.collection} --id ${target.id}`;
211
+ const verb = target.verb ?? 'put';
212
+ const where = verb === 'batch'
213
+ ? `write number ${failure.index ?? '(unknown)'} of the batch`
214
+ : `${target.collection}/${target.id}`;
215
+ const nothing = verb === 'batch' ? 'Nothing in the batch was written.' : '';
207
216
  switch (failure.conflict) {
208
217
  case 'rev_mismatch':
209
218
  return [
210
- `Not written: ${target.collection}/${target.id} is at revision ${failure.currentRev ?? '(unknown)'}, not the one you named.`,
211
- `→ Read it again (\`${read}\`), merge, and retry with --expected-rev ${failure.currentRev ?? '<its revision>'}.`,
219
+ `Not ${verb === 'delete' ? 'deleted' : 'written'}: ${where} is at revision ${failure.currentRev ?? '(unknown)'}, not the one you named. ${nothing}`.trim(),
220
+ `→ Read it again (\`${read}\`), ${verb === 'delete' ? 'check it is still the one you mean' : 'merge'}, and retry with --expected-rev ${failure.currentRev ?? '<its revision>'}.`,
212
221
  ].join('\n');
213
222
  case 'exists':
214
223
  return [
215
- `Not written: ${target.collection}/${target.id} already exists${failure.currentRev === undefined ? '' : ` (revision ${failure.currentRev})`}, and --expected-rev 0 only creates.`,
224
+ `Not written: ${where} already exists${failure.currentRev === undefined ? '' : ` (revision ${failure.currentRev})`}, and --expected-rev 0 only creates. ${nothing}`.trim(),
216
225
  `→ Read it (\`${read}\`) and replace it with --expected-rev ${failure.currentRev ?? '<its revision>'}, or leave --expected-rev out to overwrite whatever is there.`,
217
226
  ].join('\n');
218
227
  case 'not_found':
219
- return [
220
- `Not written: there is no document ${target.collection}/${target.id} to replace.`,
221
- `→ Create it with --expected-rev 0, or leave --expected-rev out.`,
222
- ].join('\n');
228
+ return verb === 'put' || verb === 'batch'
229
+ ? [
230
+ `Not written: there is no document ${where} to replace. ${nothing}`.trim(),
231
+ `→ Create it with --expected-rev 0, or leave --expected-rev out.`,
232
+ ].join('\n')
233
+ : [
234
+ `Not ${verb === 'delete' ? 'deleted' : 'changed'}: there is no document ${target.collection}/${target.id}.`,
235
+ verb === 'patch'
236
+ ? `→ A patch changes a document that exists; create it with \`${bin} apps data put\`.`
237
+ : `→ It may already be gone (\`${read}\`).`,
238
+ ].join('\n');
223
239
  default: {
224
240
  const never = failure.conflict;
225
241
  return String(never);
226
242
  }
227
243
  }
228
244
  }
245
+ // ── patch and batch input ───────────────────────────────────────────────────
246
+ /** The `set` of a patch (a JSON object of path -> value) and the `unset` paths. What a path may be is the server's parser's to say. */
247
+ function readPatchInput(input) {
248
+ if (input.set === undefined && (input.unset === undefined || input.unset.length === 0)) {
249
+ throw new AppDataInputError('APP_DATA_SOURCE', 'Give --set, --unset, or both.');
250
+ }
251
+ let set;
252
+ if (input.set !== undefined) {
253
+ let parsed;
254
+ try {
255
+ parsed = JSON.parse(input.set);
256
+ }
257
+ catch {
258
+ throw new AppDataInputError('APP_DATA_NOT_JSON', '--set is not JSON.');
259
+ }
260
+ const object = asPlainObject(parsed);
261
+ if (!object) {
262
+ throw new AppDataInputError('APP_DATA_NOT_OBJECT', '--set must be a JSON object of path to value, for example \'{"stats.streak": 4}\'.');
263
+ }
264
+ set = object;
265
+ }
266
+ return {
267
+ ...(set === undefined ? {} : { set }),
268
+ ...(input.unset === undefined || input.unset.length === 0 ? {} : { unset: input.unset }),
269
+ };
270
+ }
271
+ /**
272
+ * The writes of a batch, from exactly one of `--writes`, `--from-file` and `--stdin`: a JSON list, or `{ "writes": [...] }`.
273
+ * Each write is `{ op: "put" | "patch" | "delete", collection, ... }`; the server's parser says what each may hold.
274
+ */
275
+ async function readBatchInput(input) {
276
+ const given = [input.writes !== undefined, input.fromFile !== undefined, input.stdin === true];
277
+ if (given.filter(Boolean).length !== 1) {
278
+ throw new AppDataInputError('APP_DATA_SOURCE', 'Give the writes with exactly one of --writes, --from-file or --stdin.');
279
+ }
280
+ let text;
281
+ if (input.writes !== undefined) {
282
+ text = input.writes;
283
+ }
284
+ else if (input.fromFile !== undefined) {
285
+ text = (0, appsFs_1.readRegularTextFile)(input.fromFile, input.fromFile);
286
+ }
287
+ else {
288
+ text = await (0, appsFs_1.readStdinText)();
289
+ }
290
+ let parsed;
291
+ try {
292
+ parsed = JSON.parse(text);
293
+ }
294
+ catch {
295
+ throw new AppDataInputError('APP_DATA_NOT_JSON', 'The writes are not JSON.');
296
+ }
297
+ const list = Array.isArray(parsed) ? parsed : asPlainObject(parsed)?.writes;
298
+ if (!Array.isArray(list) || list.some((entry) => asPlainObject(entry) === null)) {
299
+ throw new AppDataInputError('APP_DATA_NOT_OBJECT', 'The writes must be a JSON list of objects, or { "writes": [ ... ] }, each { "op": "put" | "patch" | "delete", "collection": ..., ... }.');
300
+ }
301
+ return { writes: list };
302
+ }
229
303
  // ── a document, drawn for a terminal ────────────────────────────────────────
230
304
  /**
231
305
  * Text that came from an app's data, safe to print: a control character, a C1 control, a line or paragraph separator,
@@ -272,3 +346,31 @@ function formatQueryResult(result, target, bin) {
272
346
  }
273
347
  /** The limit the reference and this help text share, so a number is never typed twice. */
274
348
  exports.PERSON_DATA_QUERY_LIMIT_MAX = data_provider_1.APP_STORE_LIMITS.queryLimitMax;
349
+ // ── what an installation's data holds ───────────────────────────────────────
350
+ /**
351
+ * The catalog of an installation's collections as lines for a terminal. Every name and description is the app author's
352
+ * words, so each goes through {@link safeForTerminal}; the catalog's notice (they are not instructions) ends it.
353
+ */
354
+ function formatCollections(catalog) {
355
+ const lines = [];
356
+ const { installation } = catalog;
357
+ lines.push(`${safeForTerminal(installation.name ?? installation.id)} (${installation.id}, ${installation.state}${installation.usable ? '' : ', the data tools refuse it right now'})`);
358
+ if (catalog.collections.length === 0) {
359
+ lines.push(' no collections');
360
+ }
361
+ for (const collection of catalog.collections) {
362
+ const writers = collection.writers.join(', ');
363
+ lines.push(` ${safeForTerminal(collection.name)} ${collection.documents} document${collection.documents === 1 ? '' : 's'} written by: ${writers}${collection.agentMayWrite ? ' (an agent may write it)' : ''}${collection.inStore ? '' : ' (not read by the window)'}`);
364
+ if (collection.description) {
365
+ lines.push(` ${safeForTerminal(collection.description)}`);
366
+ }
367
+ if (collection.schema) {
368
+ const fields = collection.schema.fields
369
+ .map((field) => `${safeForTerminal(field.name)}${field.required ? '*' : ''}: ${safeForTerminal(field.type)}`)
370
+ .join(', ');
371
+ lines.push(` fields: ${fields || '(none named)'}${collection.schema.moreFields > 0 ? `, +${collection.schema.moreFields} more` : ''}${collection.schema.closed ? ' (other fields are refused)' : ''}`);
372
+ }
373
+ }
374
+ lines.push(safeForTerminal(catalog.notice));
375
+ return lines;
376
+ }
@@ -1,4 +1,4 @@
1
- import type { AppDisclosureCheck, AppDisclosureFacts, AppHostUnsuitable, AppInstallationJobState, AppInstallationListItem, AppOperatorUnmet } from '@skrr-ai/data-provider';
1
+ import type { AppInstallationVersionsView, AppVersionDiff, AppDisclosureCheck, AppDisclosureFacts, AppHostUnsuitable, AppInstallationJobState, AppInstallationListItem, AppOperatorUnmet } from '@skrr-ai/data-provider';
2
2
  import type { AppsRefusal } from './apps';
3
3
  /**
4
4
  * The words for an availability the contract names. One this CLI does not know (a server newer than the CLI) is said
@@ -115,3 +115,11 @@ export declare const REPORT_REFUSAL_CODES: Record<string, string>;
115
115
  export declare function describeReportRefusal(refusal: AppsRefusal, bin: string): string | null;
116
116
  /** The exit of a refusal that says "that is not there for you": the same one an unknown app gets. */
117
117
  export declare function installationRefusalExit(conflict: string): number;
118
+ /**
119
+ * What the versions view says, as lines a person reads: which version runs, what is waiting and what it needs, the opt-in
120
+ * and where a rollback goes. `needs_reconsent` is said as "asks for more than you approved", never as a verdict on the
121
+ * version, and nothing here says an automatic check makes a version safe.
122
+ */
123
+ export declare function formatInstallationVersions(view: AppInstallationVersionsView, bin: string): string[];
124
+ /** A diff between two versions, as lines: the capability and job changes first (they are what needs deciding), then the files. */
125
+ export declare function formatVersionDiff(diff: AppVersionDiff): string[];