@deepdockai/cli 1.1.2 → 1.4.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.4.0
4
+
5
+ - Device API format 11: the error code `system_version_unverified` and the error fields `version` and `reason` are gone, and a system's `writes` state in `GET /v1/devices/{deviceId}` is replaced by `blockedActions` (the actions this device's client cannot run yet; each answers `device_outdated` until the client updates). An action whose system runs a program version Deepdock has not yet approved for it answers the new `409 version_not_covered` (CLI exit 2): nothing ran, retrying gets the same answer, and it works once Deepdock approves that version or the customer runs an approved one. The bundled TypeScript and Python clients, the skill's error reference and the device types follow. This needs the API from the Deepdock release that carries these changes.
6
+ - `deepdock devices` and `deepdock incidents list` read the organisation's lists as `{ "data": [...], "nextCursor": ... }`, the form `/v1` already uses (was `{ "data": { "items": [...], "nextCursor": ... } }`). They need the API from the next Deepdock release; an older API answers the old form, which this version does not read.
7
+ - The CLI follows the API's British spelling and its renamed code: `GET /partner/organisations` (was `/partner/orgs`), the error code `organisation_required` (was `organization_required`) and `cli_outdated` (was `client_outdated`, still exit 4). The bundled device types and the skill's error reference include them. These need the API from the next Deepdock release.
8
+ - The command group `org` is now `orgs` (`deepdock orgs list`, `deepdock orgs select`); the old name is gone, with no alias.
9
+ - A device is named `<deviceId>` in every usage string, help text, the README and the bundled skill (`devices rename|release|systems <deviceId>`, `actions list <deviceId> <system>`).
10
+ - The README and the bundled skill advise reusing one HTTP connection for calls (keep-alive), because a fresh connection can hit a cold start.
11
+ - The docs, the bundled skill and the device API pin say "pair" for taking a device into your organisation (was "claim"); the `rate_limited` and `pairing_code_invalid` texts follow, and `requestId` is described as present on every error body. Field names and error codes are unchanged (`claimedAt` stays).
12
+
13
+ ## 1.2.0
14
+
15
+ - Every `/v1` answer uses one `data` envelope. A list (a `many` action read, `GET /v1/devices`) answers `{ "data": [...], "nextCursor": ... }` (was `{ "data": { "items": [...], "nextCursor": ... } }`); `nextCursor` sits beside `data` and appears only on a list that pages. A single-record read (`cardinality: one`) answers `{ "data": { ...record } }` and a record that is not found answers `404 not_found`. Writes and error bodies are unchanged.
16
+ - Every refused action input (type, length, enum, bounds, a missing or unknown field, a bad `limit` or `cursor`) answers `422 invalid_input` with `error.fields`; `400 invalid_request` is for a malformed request only.
17
+ - The bundled TypeScript and Python clients read the new shape (`Page.items` keeps its name and holds `data`) and gain `readOne` / `read_one` for a single-record read. The skill and its references show the new answers.
18
+ - The bundled TypeScript and Python clients gain `download` for a file action (`file: true` in the action index): it posts the inputs like a read and returns the bytes, the content type and the file name from `Content-Disposition` (`filename*` first). A body shorter than its `Content-Length` throws `DeepdockTransportError`; a refusal is a `DeepdockError` as for any action, and `503 target_busy` is retried the same way. The skill describes file actions in `calling-actions.md`.
19
+
3
20
  ## 1.1.2
4
21
 
5
22
  - The bundled TypeScript and Python clients wait 35 seconds per attempt (was 30): a call can wait up to 10 seconds for the device's slot and then up to 20 seconds on the device. They also retry `503 target_busy` up to three attempts (`maxAttempts` / `max_attempts`), waiting the `Retry-After` seconds (at most 15, one second without the header) and sending the same request, so a write keeps its idempotency key. `DeepdockError` carries the header as `retryAfter` / `retry_after`.
package/README.md CHANGED
@@ -48,7 +48,7 @@ Signed in as anna.mueller@muster-it.example.
48
48
  Choose the organisation to work in, then look around:
49
49
 
50
50
  ```bash
51
- deepdock org select muster-it # the default for every later command
51
+ deepdock orgs select muster-it # the default for every later command
52
52
  deepdock devices list # paired devices, their status and systems
53
53
  deepdock systems list # the systems and actions assigned to you
54
54
  deepdock systems openapi example-erp > example-erp.openapi.json
@@ -82,29 +82,29 @@ knowledge into your coding agent.
82
82
  deepdock auth login | status | logout
83
83
  deepdock org list | select [slug]
84
84
  deepdock systems list | openapi <system>
85
- deepdock devices list | pair <code> | rename <id> <label> | release <id> | systems <id>
86
- deepdock actions list <device> <system>
85
+ deepdock devices list | pair <code> | rename <deviceId> <label> | release <deviceId> | systems <deviceId>
86
+ deepdock actions list <deviceId> <system>
87
87
  deepdock keys list | create <name> | revoke <id>
88
88
  deepdock incidents list
89
89
  deepdock skill
90
90
  ```
91
91
 
92
- | Command | What it does |
93
- | ----------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
94
- | `auth login` | sign in as yourself, approved in the browser; the sign-in lasts 90 days |
95
- | `auth status` | who is signed in, the organisations, and the keys this CLI created (id, name, prefix, expiry, file; never the value); exits 5 when not signed in, like `gh auth status` |
96
- | `auth logout [--keep-keys]` | revoke the sign-in and every key this CLI created (`--keep-keys`: only the sign-in) |
97
- | `org list`, `org select [slug]` | your organisations; set the default one |
98
- | `systems list` | the systems and actions assigned to your organisation |
99
- | `systems openapi <system>` | a system's OpenAPI document on stdout, bare when redirected; save it to a file |
100
- | `devices list` | paired devices with id, label, status, systems and last seen |
101
- | `devices pair <code> [--label <text>]` | claim a device by the code on its screen |
102
- | `devices rename <id> <label>`, `devices release <id>` | rename a device; unpair it from the organisation (admin) |
103
- | `devices systems <id>` | a device's live systems and action state, paused reasons included |
104
- | `actions list <device> <system>` | every action a device offers, with its operation and fields |
105
- | `keys list`, `keys create <name>`, `keys revoke <id>` | the organisation's API keys (create and revoke: admin) |
106
- | `incidents list` | open incidents, and those closed within the last 30 days |
107
- | `skill [--agent claude\|codex\|cursor\|all]` | install the agent skill into the current directory |
92
+ | Command | What it does |
93
+ | ----------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
94
+ | `auth login` | sign in as yourself, approved in the browser; the sign-in lasts 90 days |
95
+ | `auth status` | who is signed in, the organisations, and the keys this CLI created (id, name, prefix, expiry, file; never the value); exits 5 when not signed in, like `gh auth status` |
96
+ | `auth logout [--keep-keys]` | revoke the sign-in and every key this CLI created (`--keep-keys`: only the sign-in) |
97
+ | `orgs list`, `orgs select [slug]` | your organisations; set the default one |
98
+ | `systems list` | the systems and actions assigned to your organisation |
99
+ | `systems openapi <system>` | a system's OpenAPI document on stdout, bare when redirected; save it to a file |
100
+ | `devices list` | paired devices with id, label, status, systems and last seen |
101
+ | `devices pair <code> [--label <text>]` | pair a device by the code on its screen |
102
+ | `devices rename <deviceId> <label>`, `devices release <deviceId>` | rename a device; unpair it from the organisation (admin) |
103
+ | `devices systems <deviceId>` | a device's live systems and action state, paused reasons included |
104
+ | `actions list <deviceId> <system>` | every action a device offers, with its operation and fields |
105
+ | `keys list`, `keys create <name>`, `keys revoke <id>` | the organisation's API keys (create and revoke: admin) |
106
+ | `incidents list` | open incidents, and those closed within the last 30 days |
107
+ | `skill [--agent claude\|codex\|cursor\|all]` | install the agent skill into the current directory |
108
108
 
109
109
  Global flags: `--org <slug>` and `--json` on every command, `--yes` to confirm `devices release`
110
110
  and `keys revoke` without a question, `-h, --help` everywhere and `-v, --version` at the root.
@@ -112,7 +112,7 @@ and `keys revoke` without a question, `-h, --help` everywhere and `-v, --version
112
112
 
113
113
  Two things are never guessed. A device is always named by its full id: no default device, no
114
114
  lookup by label. The organisation comes from `--org`, then `DEEPDOCK_ORG`, then the default
115
- chosen with `deepdock org select`. With exactly one organisation it is used without asking (and
115
+ chosen with `deepdock orgs select`. With exactly one organisation it is used without asking (and
116
116
  named on stderr); with several and none chosen the command stops and lists them.
117
117
 
118
118
  ## The approval flow
@@ -150,18 +150,18 @@ On a terminal you get tables and plain sentences. When stdout is not a terminal,
150
150
  `systems openapi` is the one exception off a terminal: it prints the OpenAPI document itself, so
151
151
  `deepdock systems openapi <system> > openapi.json` saves a document a generator can read (`--json`
152
152
  gives the envelope). For list and show commands `data` is the API's answer unchanged, so what the CLI shows is what
153
- your code will receive; `auth`, `org select` and `keys create` build it from named fields. A
153
+ your code will receive; `auth`, `orgs select` and `keys create` build it from named fields. A
154
154
  failure is one document on stderr, `{ "error": { "code", "message" }, "meta": { "hint" } }`,
155
155
  with the API's error object unchanged. Switch on `code` or on the exit code, never on `message`.
156
156
 
157
- | Exit | Meaning |
158
- | ---- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
159
- | 0 | done |
160
- | 1 | something on the command line to fix (`invalid_usage`, `org_required`) |
161
- | 2 | the API refused the request; do not repeat it unchanged (`invalid_request`, `not_found`, `forbidden`, `rate_limited` and the other refusals) |
162
- | 3 | retry later (`device_offline`, `device_syncing`, `device_outdated`, `system_version_unverified`, `action_paused`, `access_outdated`, `access_missing`, `credentials_rejected`, `certificate_changed`, `system_unavailable`, `target_busy`, `temporarily_unavailable`, `internal_error`, `outcome_unknown`, `connection_lost`) |
163
- | 4 | the CLI is too old for the API (`client_outdated`): run `npx @deepdockai/cli@latest` |
164
- | 5 | sign-in needed (`sign_in_needed`, `approval_denied`, `approval_expired`); `auth status` when nobody is signed in |
157
+ | Exit | Meaning |
158
+ | ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
159
+ | 0 | done |
160
+ | 1 | something on the command line to fix (`invalid_usage`, `org_required`) |
161
+ | 2 | the API refused the request; do not repeat it unchanged (`invalid_request`, `not_found`, `forbidden`, `rate_limited` and the other refusals) |
162
+ | 3 | retry later (`device_offline`, `device_syncing`, `device_outdated`, `action_paused`, `access_outdated`, `access_missing`, `credentials_rejected`, `certificate_changed`, `system_unavailable`, `target_busy`, `temporarily_unavailable`, `internal_error`, `outcome_unknown`, `connection_lost`) |
163
+ | 4 | the CLI is too old for the API (`cli_outdated`): run `npx @deepdockai/cli@latest` |
164
+ | 5 | sign-in needed (`sign_in_needed`, `approval_denied`, `approval_expired`); `auth status` when nobody is signed in |
165
165
 
166
166
  The CLI never retries on its own: exit 3 says retry, you decide when. `deepdock commands --json`
167
167
  prints the whole command tree.
@@ -173,7 +173,7 @@ Deepdock model (organisation, API key, device, system, action), the recipe from
173
173
  tested integration, how to read the OpenAPI document instead of guessing field names, writes
174
174
  with `Idempotency-Key`, every error code and whether to retry it, and the rule that it never
175
175
  asks for, reads or prints an API key value. It ships with reference clients in TypeScript and
176
- Python.
176
+ Python. Calls are fastest over one reused HTTP connection (keep-alive), because a fresh connection can hit a cold start.
177
177
 
178
178
  ```bash
179
179
  deepdock skill # all three agents
package/dist/deepdock.js CHANGED
@@ -10848,7 +10848,7 @@ var program = new Command;
10848
10848
  var EXIT_CODES = {
10849
10849
  invalid_usage: 1,
10850
10850
  org_required: 1,
10851
- organization_required: 1,
10851
+ organisation_required: 1,
10852
10852
  invalid_request: 2,
10853
10853
  forbidden: 2,
10854
10854
  partner_not_approved: 2,
@@ -10875,10 +10875,10 @@ var EXIT_CODES = {
10875
10875
  record_not_editable: 2,
10876
10876
  record_restricted: 2,
10877
10877
  payload_too_large: 2,
10878
+ version_not_covered: 2,
10878
10879
  device_offline: 3,
10879
10880
  device_syncing: 3,
10880
10881
  device_outdated: 3,
10881
- system_version_unverified: 3,
10882
10882
  action_paused: 3,
10883
10883
  access_outdated: 3,
10884
10884
  access_missing: 3,
@@ -10890,7 +10890,7 @@ var EXIT_CODES = {
10890
10890
  internal_error: 3,
10891
10891
  outcome_unknown: 3,
10892
10892
  connection_lost: 3,
10893
- client_outdated: 4,
10893
+ cli_outdated: 4,
10894
10894
  unauthenticated: 5,
10895
10895
  sign_in_needed: 5,
10896
10896
  approval_denied: 5,
@@ -11259,7 +11259,7 @@ var actionRow = (action) => {
11259
11259
  };
11260
11260
  var registerActions = (program, run) => {
11261
11261
  const actions = program.command("actions").description("List a device's actions and their fields");
11262
- actions.command("list").description("List the actions a device offers for a system, with every field").argument("<device>", "the full device id").argument("<system>", "the system name").action((device, system, _options, cmd) => run(cmd, async (ctx) => {
11262
+ actions.command("list").description("List the actions a device offers for a system, with every field").argument("<deviceId>", "the full device id").argument("<system>", "the system name").action((device, system, _options, cmd) => run(cmd, async (ctx) => {
11263
11263
  const deviceId = deviceIdArg(device);
11264
11264
  const name = systemArg(system);
11265
11265
  const response = await ctx.callInOrg({
@@ -11441,7 +11441,7 @@ import { spawn } from "node:child_process";
11441
11441
  import { homedir, hostname } from "node:os";
11442
11442
 
11443
11443
  // src/version.ts
11444
- var VERSION = "1.1.2";
11444
+ var VERSION = "1.4.0";
11445
11445
 
11446
11446
  // src/runtime.ts
11447
11447
  var DEFAULT_BASE_URL = "https://api.deepdock.ai";
@@ -11600,7 +11600,7 @@ var createApi = (rt) => {
11600
11600
  status: response.status
11601
11601
  });
11602
11602
  }
11603
- return { data: json.data, requestId: headerRequestId };
11603
+ return { data: json.data, nextCursor: json.nextCursor, requestId: headerRequestId };
11604
11604
  };
11605
11605
  return { request, latest: () => latest };
11606
11606
  };
@@ -11677,7 +11677,7 @@ var resolveOrg = (requested, orgs, fromStoredDefault = false) => {
11677
11677
  throw new CliError({
11678
11678
  code: "org_required",
11679
11679
  message: "No organisation chosen.",
11680
- hint: "Pass --org <slug> or run `deepdock org select`.",
11680
+ hint: "Pass --org <slug> or run `deepdock orgs select`.",
11681
11681
  organisations: slugs
11682
11682
  });
11683
11683
  }
@@ -11686,7 +11686,7 @@ var resolveOrg = (requested, orgs, fromStoredDefault = false) => {
11686
11686
  throw new CliError({
11687
11687
  code: "invalid_usage",
11688
11688
  message: `You are not a member of an organisation with the slug "${requested}".`,
11689
- hint: fromStoredDefault ? "That is your stored default. Run `deepdock org select` to choose another." : undefined,
11689
+ hint: fromStoredDefault ? "That is your stored default. Run `deepdock orgs select` to choose another." : undefined,
11690
11690
  organisations: slugs
11691
11691
  });
11692
11692
  }
@@ -12029,7 +12029,7 @@ var createContext = (rt, opts) => {
12029
12029
  const current = await config();
12030
12030
  if (!refresh && current.organisations)
12031
12031
  return current.organisations;
12032
- const response = await ctx.call({ method: "GET", path: "/partner/orgs" });
12032
+ const response = await ctx.call({ method: "GET", path: "/partner/organisations" });
12033
12033
  const orgs = await parseAnswer("orgs", response.data);
12034
12034
  await ctx.update((config) => {
12035
12035
  config.organisations = orgs;
@@ -12057,7 +12057,7 @@ var createContext = (rt, opts) => {
12057
12057
  try {
12058
12058
  return await ctx.call({ ...req, org: org.slug });
12059
12059
  } catch (error) {
12060
- if (error instanceof CliError && error.code === "organization_required") {
12060
+ if (error instanceof CliError && error.code === "organisation_required") {
12061
12061
  const refreshed = await ctx.organisations(true);
12062
12062
  const current = await config();
12063
12063
  const requested = requestedSlug(opts.org, rt.env, current);
@@ -12087,7 +12087,7 @@ Commands
12087
12087
  skill Install the Deepdock skill for your coding agent
12088
12088
 
12089
12089
  Global flags
12090
- --org <slug> The organisation to act in (default: DEEPDOCK_ORG, then \`deepdock org select\`)
12090
+ --org <slug> The organisation to act in (default: DEEPDOCK_ORG, then \`deepdock orgs select\`)
12091
12091
  --json JSON output (the default when stdout is not a terminal)
12092
12092
  --yes Answer the confirmation question of release and revoke with yes
12093
12093
  -h, --help Help for a command
@@ -12107,7 +12107,7 @@ var AUTH_LOGIN_HELP = `Sign in to Deepdock as yourself.
12107
12107
 
12108
12108
  Opens a link to the Deepdock dashboard. There you click Approve, and this CLI receives a
12109
12109
  sign-in valid for 90 days. The sign-in is yours, not an organisation's: afterwards you choose
12110
- an organisation with --org or \`deepdock org select\`.
12110
+ an organisation with --org or \`deepdock orgs select\`.
12111
12111
 
12112
12112
  The sign-in manages devices, keys and settings and lists what a device offers. It never runs
12113
12113
  an action; actions run from your code with an API key (\`deepdock keys create\`).
@@ -12171,18 +12171,18 @@ var EXIT_CODES_HELP = `Exit codes
12171
12171
  1 usage: something on the command line to fix (invalid_usage, org_required)
12172
12172
  2 the API refused the request; do not repeat it unchanged
12173
12173
  3 retry later (device_offline, device_syncing, device_outdated,
12174
- system_version_unverified, action_paused, access_outdated, access_missing,
12174
+ action_paused, access_outdated, access_missing,
12175
12175
  credentials_rejected, certificate_changed,
12176
12176
  system_unavailable, target_busy, temporarily_unavailable, internal_error,
12177
12177
  outcome_unknown, connection_lost)
12178
- 4 the CLI is too old for the API (client_outdated)
12178
+ 4 the CLI is too old for the API (cli_outdated)
12179
12179
  5 sign-in needed (sign_in_needed, approval_denied, approval_expired; auth status when nobody is signed in)
12180
12180
 
12181
12181
  With --json (or off a terminal) a failure is one JSON document on stderr:
12182
12182
  { "error": { "code", "message" }, "meta": { "hint" } }. Switch on \`code\`, never on \`message\`.
12183
12183
  `;
12184
12184
  var EXAMPLES = {
12185
- "org select": ["deepdock org select muster-it"],
12185
+ "orgs select": ["deepdock orgs select muster-it"],
12186
12186
  "devices pair": ['deepdock devices pair K7Q-4MX --label "Demo PC"'],
12187
12187
  "devices release": ["deepdock devices release 450c3f0e-7a1b-4c2d-9e8f-1a2b3c4d5e6f --yes"],
12188
12188
  "actions list": ["deepdock actions list 450c3f0e-7a1b-4c2d-9e8f-1a2b3c4d5e6f example-erp"],
@@ -12578,7 +12578,7 @@ var finishLogin = async (ctx, pending) => {
12578
12578
  if (sole && only.length === 1 && config.defaultOrg === sole.slug) {
12579
12579
  lines.push(`${paint(ctx.out, "success", "Selected")} ${sole.name} (${sole.slug}) as your organisation.`);
12580
12580
  } else {
12581
- lines.push("Choose one with `deepdock org select <slug>` or pass --org to each command.");
12581
+ lines.push("Choose one with `deepdock orgs select <slug>` or pass --org to each command.");
12582
12582
  }
12583
12583
  }
12584
12584
  return {
@@ -12652,7 +12652,7 @@ var status = async (ctx) => {
12652
12652
  let requestId;
12653
12653
  if (config.signIn && Date.parse(config.signIn.expiresAt) > ctx.rt.now().getTime()) {
12654
12654
  try {
12655
- const response = await ctx.call({ method: "GET", path: "/partner/orgs" });
12655
+ const response = await ctx.call({ method: "GET", path: "/partner/organisations" });
12656
12656
  const orgs = await parseAnswer("orgs", response.data);
12657
12657
  await ctx.update((current) => {
12658
12658
  current.organisations = orgs;
@@ -12682,7 +12682,7 @@ var status = async (ctx) => {
12682
12682
  if (baseUrl !== DEFAULT_BASE_URL)
12683
12683
  lines.push(ctx.out("yellow", `API: ${baseUrl} (not production)`));
12684
12684
  if (data.organisations.length > 0) {
12685
- lines.push("", "Organisations:", indented(orgTable(data.organisations, defaultOrg, ctx.out)), "", defaultOrg ? "Switch the default with `deepdock org select <slug>`." : "No default yet: choose one with `deepdock org select <slug>`.");
12685
+ lines.push("", "Organisations:", indented(orgTable(data.organisations, defaultOrg, ctx.out)), "", defaultOrg ? "Switch the default with `deepdock orgs select <slug>`." : "No default yet: choose one with `deepdock orgs select <slug>`.");
12686
12686
  }
12687
12687
  } else {
12688
12688
  lines.push(config.signIn ? "Your sign-in has expired. Run `deepdock auth login`." : "Not signed in. Run `deepdock auth login`.");
@@ -12859,13 +12859,13 @@ var readAllPages = async (ctx, path, org) => {
12859
12859
  query.set("cursor", cursor);
12860
12860
  const url = `${path}?${query.toString()}`;
12861
12861
  const response = org ? await ctx.call({ method: "GET", path: url, org }) : await ctx.callInOrg({ method: "GET", path: url });
12862
- const data = response.data;
12863
- if (!isRecord(data) || !Array.isArray(data.items))
12862
+ const rows = response.data;
12863
+ if (!Array.isArray(rows))
12864
12864
  throw unreadable();
12865
- const next = data.nextCursor;
12865
+ const next = response.nextCursor;
12866
12866
  if (next !== null && (typeof next !== "string" || next === ""))
12867
12867
  throw unreadable();
12868
- items.push(...data.items);
12868
+ items.push(...rows);
12869
12869
  requestId ??= response.requestId;
12870
12870
  if (next === null)
12871
12871
  return { items, requestId };
@@ -13003,9 +13003,9 @@ var registerDevices = (program, run) => {
13003
13003
  const devices = program.command("devices").description("Pair, list, rename and release devices");
13004
13004
  devices.command("list").description("List the devices paired to the organisation").action((_options, cmd) => run(cmd, list));
13005
13005
  devices.command("pair").description("Pair a device with the code shown on its screen").argument("<code>", "the pairing code").option("--label <text>", "a label for the device, 1 to 100 characters").action((code, options, cmd) => run(cmd, (ctx) => pair(ctx, code, options.label)));
13006
- devices.command("rename").description("Change a device's label").argument("<id>", "the full device id").argument("<label>", "the new label, 1 to 100 characters").action((id, label, _options, cmd) => run(cmd, (ctx) => rename(ctx, id, label)));
13007
- devices.command("release").description("Release a device from the organisation (admin)").argument("<id>", "the full device id").action((id, _options, cmd) => run(cmd, (ctx) => release(ctx, id)));
13008
- devices.command("systems").description("Show the systems a device runs and the state of their actions").argument("<id>", "the full device id").action((id, _options, cmd) => run(cmd, (ctx) => systemsOf(ctx, id)));
13006
+ devices.command("rename").description("Change a device's label").argument("<deviceId>", "the full device id").argument("<label>", "the new label, 1 to 100 characters").action((id, label, _options, cmd) => run(cmd, (ctx) => rename(ctx, id, label)));
13007
+ devices.command("release").description("Release a device from the organisation (admin)").argument("<deviceId>", "the full device id").action((id, _options, cmd) => run(cmd, (ctx) => release(ctx, id)));
13008
+ devices.command("systems").description("Show the systems a device runs and the state of their actions").argument("<deviceId>", "the full device id").action((id, _options, cmd) => run(cmd, (ctx) => systemsOf(ctx, id)));
13009
13009
  };
13010
13010
 
13011
13011
  // src/commands/incidents.ts
@@ -13235,7 +13235,7 @@ var registerKeys = (program, run) => {
13235
13235
 
13236
13236
  // src/commands/org.ts
13237
13237
  var list3 = async (ctx) => {
13238
- const response = await ctx.call({ method: "GET", path: "/partner/orgs" });
13238
+ const response = await ctx.call({ method: "GET", path: "/partner/organisations" });
13239
13239
  const orgs = await parseAnswer("orgs", response.data);
13240
13240
  const config = await ctx.update((current) => {
13241
13241
  current.organisations = orgs;
@@ -13244,7 +13244,7 @@ var list3 = async (ctx) => {
13244
13244
  const text = orgs.length === 0 ? "You are not a member of an organisation yet." : [
13245
13245
  orgTable(orgs, defaultOrg, ctx.out),
13246
13246
  "",
13247
- "Switch the default with `deepdock org select <slug>`."
13247
+ "Switch the default with `deepdock orgs select <slug>`."
13248
13248
  ].join(`
13249
13249
  `);
13250
13250
  return {
@@ -13254,7 +13254,7 @@ var list3 = async (ctx) => {
13254
13254
  };
13255
13255
  };
13256
13256
  var select = async (ctx, slug) => {
13257
- const response = await ctx.call({ method: "GET", path: "/partner/orgs" });
13257
+ const response = await ctx.call({ method: "GET", path: "/partner/organisations" });
13258
13258
  const orgs = await parseAnswer("orgs", response.data);
13259
13259
  const choices = selectableOrgs(orgs);
13260
13260
  const config = await ctx.config();
@@ -13265,7 +13265,7 @@ var select = async (ctx, slug) => {
13265
13265
  throw new CliError({
13266
13266
  code: "invalid_usage",
13267
13267
  message: "Choosing an organisation without a slug needs a terminal.",
13268
- hint: "Pass the slug: `deepdock org select <slug>`.",
13268
+ hint: "Pass the slug: `deepdock orgs select <slug>`.",
13269
13269
  organisations: slugs
13270
13270
  });
13271
13271
  }
@@ -13301,7 +13301,7 @@ var select = async (ctx, slug) => {
13301
13301
  };
13302
13302
  };
13303
13303
  var registerOrg = (program, run) => {
13304
- const org = program.command("org").description("List your organisations and choose the default one");
13304
+ const org = program.command("orgs").description("List your organisations and choose the default one");
13305
13305
  org.command("list").description("List the organisations you belong to").action((_options, cmd) => run(cmd, list3));
13306
13306
  org.command("select").description("Choose the default organisation (a pick-list on a terminal without a slug)").argument("[slug]", "the organisation slug").action((slug, _options, cmd) => run(cmd, (ctx) => select(ctx, slug)));
13307
13307
  };
@@ -13660,7 +13660,7 @@ var runCli = async (argv, rt) => {
13660
13660
  return 0;
13661
13661
  }
13662
13662
  const cliError = toCliError(error, program, argv);
13663
- if (cliError.code === "client_outdated") {
13663
+ if (cliError.code === "cli_outdated") {
13664
13664
  cliError.hint = `Run \`npx @deepdockai/cli@latest ${argv.join(" ")}\`.`;
13665
13665
  }
13666
13666
  const json = state.ctx?.json ?? wantsJson(rt, argv.includes("--json"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepdockai/cli",
3
- "version": "1.1.2",
3
+ "version": "1.4.0",
4
4
  "description": "Deepdock partner CLI: pair devices, see systems and actions, create the API key your code runs them with.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/skill/SKILL.md CHANGED
@@ -42,13 +42,13 @@ and what your code does with the result.
42
42
  1. **Sign in.** `deepdock auth login --json`: without a terminal the CLI prints the request and
43
43
  exits; show the human the link and wait for them to click Approve in the dashboard, then run
44
44
  `deepdock auth login --wait <request>`. You never see the resulting sign-in. Then pass
45
- `--org <slug>` on every command (`deepdock org list --json` shows the slugs).
45
+ `--org <slug>` on every command (`deepdock orgs list --json` shows the slugs).
46
46
  2. **See what you have.** `deepdock systems list --json` (the systems and actions assigned to your
47
47
  organisation) and `deepdock devices list --json` (your paired devices). If the human has a demo
48
48
  device that is not yet paired, they read the code off its screen and you run
49
49
  `deepdock devices pair <code> --label "Demo"`.
50
50
  3. **Fetch the schemas.** `deepdock systems openapi <system> --org <slug> > openapi/<system>.json`
51
- and read it; `deepdock actions list <device> <system> --json` shows the same fields per device.
51
+ and read it; `deepdock actions list <deviceId> <system> --json` shows the same fields per device.
52
52
  Check the document into the repository and refresh it with the same command. Write code only for
53
53
  actions that appear both in the document and in `systems list`.
54
54
  4. **Write the client.** A thin client in the project's own language: bearer header, envelope
@@ -107,7 +107,7 @@ and what your code does with the result.
107
107
  | [references/concepts.md](references/concepts.md) | you need the vocabulary: device, system, action, pause, incident, release |
108
108
  | [references/auth-and-keys.md](references/auth-and-keys.md) | creating, storing, sending or revoking a key; pairing or releasing a device |
109
109
  | [references/discovery.md](references/discovery.md) | reading the action index or the OpenAPI document |
110
- | [references/calling-actions.md](references/calling-actions.md) | writing the client: reads, writes, paging, authoring fields, timeouts |
110
+ | [references/calling-actions.md](references/calling-actions.md) | writing the client: reads, writes, paging, file downloads, authoring fields, timeouts |
111
111
  | [references/errors.md](references/errors.md) | handling any `error.code` |
112
112
  | [references/idempotency.md](references/idempotency.md) | retries, replays, unknown outcomes |
113
113
  | [references/cli.md](references/cli.md) | any `deepdock ...` command |
@@ -75,7 +75,7 @@ sent to a new site as is. The pairing code is what ties the device to your organ
75
75
  `ABCDEFGHJKMNPQRSTVWXYZ23456789`. Case and the dash do not matter.
76
76
  2. A code is valid for 10 minutes and is replaced shortly before it expires: read it off the screen
77
77
  when you pair.
78
- 3. Claim it:
78
+ 3. Pair it:
79
79
 
80
80
  ```bash
81
81
  curl -X POST "$BASE/v1/devices" \
@@ -88,7 +88,7 @@ curl -X POST "$BASE/v1/devices" \
88
88
  (`id`, `label`, `hostname`, `os`, `clientVersion`, `status`, `lastSeenAt`, `lastKnownAt`, `claimedAt`, `outdated`, `systems`,
89
89
  and `updateAvailable` when it runs an older build); `hostname`, `os` and `clientVersion` are `null`
90
90
  until the device has reported them. Keep `id`: it is the `deviceId` of every later call.
91
- `GET /v1/devices` lists your devices a page at a time (`{ items, nextCursor }`; pass `nextCursor` back as `cursor` until it is `null`, `limit` 1 to 500, default 100), and `GET /v1/devices/{deviceId}` reads one; each device has the same shape. `GET /v1/incidents` pages the same way.
91
+ `GET /v1/devices` lists your devices a page at a time (`{ data: [...], nextCursor }`; pass `nextCursor` back as `cursor` until it is `null`, `limit` 1 to 500, default 100), and `GET /v1/devices/{deviceId}` reads one; each device has the same shape. `GET /v1/incidents` pages the same way.
92
92
 
93
93
  4. Release with `DELETE /v1/devices/{deviceId}`; the device then shows a new code.
94
94
 
@@ -98,10 +98,10 @@ Pairing answers:
98
98
  |---|---|---|
99
99
  | `invalid_request` | 400 | the code is malformed; fix the input |
100
100
  | `pairing_code_invalid` | 404 | unknown, expired, replaced, already used, or the device is offline; ask for a fresh code |
101
- | `other_partner_build` | 409 | the device runs another partner's branded client; only that partner can claim it |
102
- | `rate_limited` | 429 | more than 5 failed claim attempts in 60 seconds with this key; wait up to a minute |
101
+ | `other_partner_build` | 409 | the device runs another partner's branded client; only that partner can pair it |
102
+ | `rate_limited` | 429 | more than 5 failed pairing attempts in 60 seconds with this key; wait up to a minute |
103
103
 
104
- Successful claims do not count against the limit; malformed codes are refused before counting.
104
+ Successful pairings do not count against the limit; malformed codes are refused before counting.
105
105
 
106
- With the CLI: `deepdock devices pair <code> [--label <text>]`, `deepdock devices release <id>`
106
+ With the CLI: `deepdock devices pair <code> [--label <text>]`, `deepdock devices release <deviceId>`
107
107
  (admin).
@@ -13,7 +13,7 @@ is refused, not run.
13
13
 
14
14
  Inputs are typed as the action's schema declares them and are never sent as text when they are not:
15
15
  an integer is a JSON number (`"patientId": 4711`, not `"4711"`; the text form is refused with
16
- `400 invalid_request`). Text is normalised to Unicode NFC before anything else happens; a composed
16
+ `422 invalid_input`). Text is normalised to Unicode NFC before anything else happens; a composed
17
17
  and a decomposed spelling are the same value.
18
18
 
19
19
  **Never put an input in the URL.** A value in a URL reaches request logs, proxies and browser
@@ -24,8 +24,8 @@ needs no escaping.
24
24
 
25
25
  ### Reads
26
26
 
27
- A read takes its inputs, and `limit` (a JSON integer from 1 to 250, default 25) and `cursor` (a
28
- string) for paging, in the same body. No `Idempotency-Key`: a repeated read changes nothing, and the
27
+ A read takes its inputs, and, when it can page, `limit` (a JSON integer from 1 to 250, default 25)
28
+ and `cursor` (a string), in the same body. No `Idempotency-Key`: a repeated read changes nothing, and the
29
29
  header is ignored.
30
30
 
31
31
  ```bash
@@ -36,20 +36,51 @@ curl -X POST "$BASE/v1/devices/$DEVICE/systems/example-erp/actions/searchCustome
36
36
  ```
37
37
 
38
38
  ```json
39
- { "data": { "items": [ { "customerId": 1001, "lastName": "Müller", "city": "Beispielstadt" } ], "nextCursor": null } }
39
+ { "data": [ { "customerId": 1001, "lastName": "Müller", "city": "Beispielstadt" } ], "nextCursor": null }
40
40
  ```
41
41
 
42
+ - A read with `cardinality: many` answers `data` as an array; `nextCursor` is a sibling of `data`
43
+ (present only on a read that can page). A read with `cardinality: one` (for example
44
+ `readPatient`) answers `data` as the record itself, `{ "data": { "customerId": 1001, ... } }`, and
45
+ answers `404 not_found` when no record matches.
42
46
  - Pass `nextCursor` back as `cursor` unchanged while it is not `null`, and stop only on `null`,
43
47
  never on a short page: a page of long entries (notes) ends before `limit` rows to keep the
44
48
  device's answer under 1 MiB and still carries a cursor. It is opaque: never parse, build or store
45
49
  it beyond the next request.
46
- - Items are the customer's records. Values can be `null` where the schema says so. Dates and other
50
+ - Rows are the customer's records. Values can be `null` where the schema says so. Dates and other
47
51
  non-numeric values arrive as text in the system's own format (the schema and description say
48
52
  which); numbers as JSON numbers.
49
53
  - A read's description may say a field is a **prefix match** and what it ignores (case,
50
54
  punctuation, umlaut spelling). Design your search UI around that rule rather than filtering
51
55
  client-side.
52
56
 
57
+ ### File actions
58
+
59
+ An action marked `file: true` in the action index (for example a document download) is a read
60
+ that answers with the file itself instead of JSON. Call it like a read: `POST` with its inputs in
61
+ the JSON body, no `limit` or `cursor`, no `Idempotency-Key`.
62
+
63
+ ```bash
64
+ curl -X POST "$BASE/v1/devices/$DEVICE/systems/example-erp/actions/downloadDocument" \
65
+ -H "Authorization: Bearer $DEEPDOCK_API_KEY" \
66
+ -H "Content-Type: application/json" \
67
+ -d '{"documentId":7}' -o document.pdf
68
+ ```
69
+
70
+ - `200` carries the bytes. `Content-Type` is the type the action declares (or
71
+ `application/octet-stream`), `Content-Disposition` names the file (`filename*` in UTF-8 beside
72
+ an ASCII `filename`), and `Content-Length` is sent when the size is known.
73
+ - A refusal before the file starts is the usual JSON error (`404 not_found` when there is no such
74
+ file, `503 target_busy`, `503 device_offline`, ...).
75
+ - Once the bytes flow, a failure can only end the body early: compare the bytes received with
76
+ `Content-Length` and treat a short body as a failed download, never as the file. Run it again.
77
+ - The file name is already safe to save on Windows, macOS and Linux, but it is the customer's data
78
+ (a document title can name a patient): store and show it like any other record value.
79
+ - The bundled clients do all of this in `download` (TypeScript: `{ bytes, contentType, filename }`;
80
+ Python: `Download(content, content_type, filename)`), and throw `DeepdockTransportError` for a
81
+ short body. A large file can take longer than 35 seconds to transfer, so their timeout bounds the
82
+ wait for the answer and each gap between two reads, not the whole transfer.
83
+
53
84
  ### Writes (create and update)
54
85
 
55
86
  Body: a flat JSON object with only the fields the schema lists (`additionalProperties: false`) and
@@ -95,7 +126,7 @@ Never invent an id, copy one from another device, or hard-code one from a test r
95
126
  - **Send each input as the type its schema declares.** An id the schema declares as an integer goes
96
127
  in as a JSON number (`"customerId": 1001`), one it declares as text goes in as text
97
128
  (`"customerId": "1001"`: digits only, no leading zero, at most 10 characters). A value of the
98
- wrong type is refused with `400 invalid_request`, never converted. Result field types also come
129
+ wrong type is refused with `422 invalid_input`, never converted. Result field types also come
99
130
  from the action's own output schema.
100
131
  - **Mark every test text `TEST-DEEPDOCK-<id>`** on the demo device only, and list what you created
101
132
  ([testing.md](testing.md)).
@@ -108,12 +139,13 @@ Never invent an id, copy one from another device, or hard-code one from a test r
108
139
  |---|---|---|
109
140
  | `405 invalid_request`, `Allow: POST` or `Allow: PATCH` | a method other than the action's own (for example `POST` to an update, or `PATCH` to a read or create) | use the method `Allow` names: `POST` for a read or create, `PATCH` for an update |
110
141
  | `400 invalid_request` | a query string on an action path | move every value into the JSON body |
111
- | `400 invalid_request` | an input of the wrong type, such as `"4711"` where an integer is declared | send the type the schema declares |
142
+ | `422 invalid_input` (`error.fields` names each input) | an input of the wrong type, such as `"4711"` where an integer is declared | send the type the schema declares |
112
143
 
113
144
  ## Timeouts and latency
114
145
 
115
146
  - Every action call is sent to the customer's PC and run there. Expect a read to take from a few
116
147
  hundred milliseconds to a few seconds; a write about the same plus its verification.
148
+ - Calls are fastest over one reused HTTP connection (keep-alive), because a fresh connection can hit a cold start.
117
149
  - A call can wait up to 10 seconds for the device's slot (`503 target_busy` with a `Retry-After`
118
150
  header when it stays taken), then gets up to 20 seconds on the device (`503 device_offline`), so
119
151
  the worst answer takes about 30 seconds. Set your HTTP client timeout to at least 35 seconds so
@@ -135,7 +167,7 @@ Each API key has its own budget on every `/v1` call: 600 calls per minute, and 1
135
167
  minute. A write (an action run that needs an `Idempotency-Key`) counts against both. Over a budget
136
168
  the call answers `429 rate_limited` with `Retry-After: 60` and `retryAfterSeconds: 60` in the error
137
169
  body. Honour it, back off and do not loop; a retried write keeps its `Idempotency-Key`. The numbers
138
- can change, so treat them as approximate. Pairing has a tighter limit of its own: 5 failed claim
170
+ can change, so treat them as approximate. Pairing has a tighter limit of its own: 5 failed pairing
139
171
  attempts per key per rolling 60 seconds, whose `429` carries neither the header nor the field.
140
172
 
141
173
  ## Response headers worth reading
@@ -15,16 +15,16 @@ the API key the CLI wrote to the app's env file.
15
15
  | `auth login` | opens a link to the dashboard where the human clicks Approve; prints `Signed in as <email>.` and the person's organisations; the sign-in lasts 90 days | anyone |
16
16
  | `auth status` | signed-in person, sign-in expiry, organisations, default organisation, the API keys this CLI created (id, prefix, expiry, where it was written); prints the same document and exits 5 when not signed in | anyone |
17
17
  | `auth logout [--keep-keys]` | revokes the sign-in and, unless `--keep-keys`, every API key this CLI created (on a terminal it lists them and asks, default keep; with `--json` or no terminal it revokes them unless `--keep-keys`); removes the entries it wrote, says what it revoked or kept | anyone |
18
- | `org list` | the person's organisations: slug, name, role, which one is the default | member |
19
- | `org select [slug]` | sets the default organisation; without a slug, a pick-list on a terminal | member |
18
+ | `orgs list` | the person's organisations: slug, name, role, which one is the default | member |
19
+ | `orgs select [slug]` | sets the default organisation; without a slug, a pick-list on a terminal | member |
20
20
  | `systems list` | the systems and actions assigned to the organisation | member |
21
21
  | `systems openapi <system>` | the system's OpenAPI document on stdout; redirect it to a file | member |
22
22
  | `devices list` | paired devices with id, label, status, systems, last seen | member |
23
- | `devices pair <code> [--label <text>]` | claim a device by the code on its screen | member |
24
- | `devices rename <id> <label>` | rename a device | member |
25
- | `devices release <id>` | release a device (asks on a terminal; `--yes` otherwise) | admin |
26
- | `devices systems <id>` | the device's live systems and action state, paused reasons included; `device_offline` is a normal answer | member |
27
- | `actions list <device> <system>` | the action index: every action with its operation and field schemas | member |
23
+ | `devices pair <code> [--label <text>]` | pair a device by the code on its screen | member |
24
+ | `devices rename <deviceId> <label>` | rename a device | member |
25
+ | `devices release <deviceId>` | release a device (asks on a terminal; `--yes` otherwise) | admin |
26
+ | `devices systems <deviceId>` | the device's live systems and action state, paused reasons included; `device_offline` is a normal answer | member |
27
+ | `actions list <deviceId> <system>` | the action index: every action with its operation and field schemas | member |
28
28
  | `keys list` | the organisation's API keys: name, prefix, created, last used, expires, status | member |
29
29
  | `keys create <name> --expires <7d\|30d\|90d> --write-env <file>` | create an API key: opens a link, a human approves "Create an API key in <Org>?", the CLI receives the key once and writes `DEEPDOCK_API_KEY=<key>` into the file. It keeps no copy and shows the value to nobody. Answers id, name, prefix, expiry and where it was written | admin |
30
30
  | `keys revoke <id>` | revoke a key (asks on a terminal; `--yes` otherwise); removes the env entry if this CLI wrote it | admin |
@@ -32,8 +32,8 @@ the API key the CLI wrote to the app's env file.
32
32
  | `skill [--agent claude\|codex\|cursor\|all]` | writes this skill into the current repository | anyone |
33
33
 
34
34
  Every command that acts in an organisation uses `--org <slug>` after the command, else
35
- `DEEPDOCK_ORG`, else the default from `org select`; if you belong to exactly one organisation it is used and named on
36
- stderr; with several and none chosen it stops with `org_required` and lists them. Always pass `--org` from an agent: `org select` changes the human's
35
+ `DEEPDOCK_ORG`, else the default from `orgs select`; if you belong to exactly one organisation it is used and named on
36
+ stderr; with several and none chosen it stops with `org_required` and lists them. Always pass `--org` from an agent: `orgs select` changes the human's
37
37
  default in every terminal.
38
38
 
39
39
  `auth login` and `keys create` also open the approval link in the human's browser on a terminal, unless `--no-browser`, `DEEPDOCK_NO_BROWSER=1`, `CI` or a missing display says otherwise.
@@ -84,8 +84,8 @@ A failure is one document on stderr: the API's error object unchanged plus what
84
84
  | 0 | done | |
85
85
  | 1 | something on the command line to fix | `invalid_usage` (a bad flag, an unknown slug, a question with no terminal and no `--yes`, an env file git does not ignore), `org_required` |
86
86
  | 2 | the API refused the request; do not repeat it unchanged | `invalid_request`, `not_found`, `device_not_found`, `pairing_code_invalid`, `other_partner_build`, `rate_limited`, `forbidden`, `conflict` and the other refusals (not `access_outdated` and `access_missing`, see exit 3) |
87
- | 3 | retry later (`access_outdated` and `access_missing`: after the customer repeats "Erneut einrichten" in the Deepdock client) | `device_offline`, `device_syncing`, `device_outdated`, `system_version_unverified`, `action_paused`, `access_outdated`, `access_missing`, `credentials_rejected`, `certificate_changed`, `system_unavailable`, `target_busy`, `temporarily_unavailable`, `internal_error`, `outcome_unknown`, `connection_lost` |
88
- | 4 | the CLI is too old for the API: run `npx @deepdockai/cli@latest` | `client_outdated` |
87
+ | 3 | retry later (`access_outdated` and `access_missing`: after the customer repeats "Erneut einrichten" in the Deepdock client) | `device_offline`, `device_syncing`, `device_outdated`, `action_paused`, `access_outdated`, `access_missing`, `credentials_rejected`, `certificate_changed`, `system_unavailable`, `target_busy`, `temporarily_unavailable`, `internal_error`, `outcome_unknown`, `connection_lost` |
88
+ | 4 | the CLI is too old for the API: run `npx @deepdockai/cli@latest` | `cli_outdated` |
89
89
  | 5 | sign-in needed: run `deepdock auth login` | `sign_in_needed`, `approval_denied`, `approval_expired` |
90
90
 
91
91
  Branch on the exit code or on `error.code`, never on `message`.