@fleetless/sdk 3.0.0 → 3.0.2

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
@@ -4,6 +4,149 @@ All notable changes to `@fleetless/sdk`. The format follows Keep a Changelog; th
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [3.0.2] — 2026-09-07
8
+
9
+ No API change, and one documentation example that now compiles. The guard
10
+ that was supposed to prove 3.0.1 clean was **green over four internal
11
+ references still inside the published bundle**, so it was rebuilt around the
12
+ question rather than around three directory names.
13
+
14
+ ### Fixed
15
+
16
+ - **Four internal references in the published 3.0.1 bundle**, which the guard
17
+ could not see: an internal decision label in `dist/index.js` and
18
+ `dist/index.cjs`, and a sentence in both about how a defect class had been
19
+ found. Measured against the registry rather than against this tree — 3.0.1
20
+ scores 4, 3.0.2 scores 0, and 3.0.0 scores 423.
21
+ - **The README's error-handling example did not compile.** `details` is
22
+ `unknown` on `FleetlessError`, deliberately, and the block read fields off
23
+ it directly — two `TS2339`s in a TypeScript SDK's own README, in the block a
24
+ reader copies first. It now narrows before reading, and it is opted in to
25
+ the documentation type check so it cannot drift again.
26
+ - **`Node 20 or newer` was listed as a runtime for the whole SDK.** Node 20
27
+ has no global `WebSocket` — it is behind a flag there — so anything realtime
28
+ fails on it with the SDK's own `no_websocket`. The README names Node 22, and
29
+ says what to pass on Node 20 instead.
30
+ - **Everything published pointed at a public repository that does not exist
31
+ yet.** `repository`, `bugs.url`, the README, `CONTRIBUTING.md` and
32
+ `RELEASING.md` all named it, and its four relative links resolved to 404s on
33
+ the npm page. They point at the maintainer address until the repository is
34
+ opened.
35
+ - **`CONTRIBUTING.md` linked `RELEASING.md`, which the tarball did not
36
+ carry.** `RELEASING.md` ships now, and every relative link in every shipped
37
+ document is checked against the tarball's own entries.
38
+ - **Each published file declares exactly one licence.** The bundler inlines
39
+ `@fleetless/contracts`, which is Apache-2.0, and the declaration files
40
+ carried six of its SPDX identifiers below this package's MIT one. A licence
41
+ scan over `node_modules` reported Apache obligations for a package that
42
+ ships no Apache text. The inherited identifiers are stripped at build time.
43
+ - **A CI comment sent whoever was reading a red publish job to a README
44
+ section that does not exist**, and `RELEASING.md` told a maintainer the
45
+ suite runs against a fake `fetch` — which `CONTRIBUTING.md` devotes a
46
+ section to denying, and which is untrue of three of the nineteen suites.
47
+
48
+ ### Changed
49
+
50
+ - **The guard scans what becomes public, computed rather than named.** The
51
+ union of what `npm pack` reports, what `git ls-files` reports and a walk of
52
+ every directory in `files`. Ten tracked files were outside the previous
53
+ shape, two of them published bytes; one of those two had already carried an
54
+ internal host to the registry inside `devDependencies`.
55
+ - **Only the German scan strips anything**, and only URLs and single-token
56
+ code spans. Stripping links and backticks before every class made the six
57
+ shipped documents blind to an internal hostname inside a markdown link.
58
+ - **Eighteen detectors, each carrying its own two fixtures**, with a floor
59
+ over the count. Seven of the previous fifteen had no fixture proving they
60
+ could fire, and two could be deleted with the whole suite green.
61
+ - **The tarball guard asserts absence as well as presence**: nothing outside
62
+ `files`, no sourcemaps, no source. It reads every dependency section rather
63
+ than the runtime one alone, and runs the marker detectors over the packed
64
+ manifest.
65
+
66
+ ### Added
67
+
68
+ - **`test/readme-pointers.test.ts`**: every pointer from the code into the
69
+ README resolves to a heading that is there. That was the defect 3.0.1 fixed
70
+ and left unguarded, one of them inside a runtime error message.
71
+ - **`scripts/verify-commit-messages.mjs`**, wired into the verify job. A
72
+ commit message is public the moment it is pushed.
73
+
74
+ ## [3.0.1] — 2026-09-07
75
+
76
+ No API change. This release exists because **3.0.0 published internal material
77
+ to the registry**, and the only way to withdraw it is to publish a version
78
+ without it.
79
+
80
+ ### Fixed
81
+
82
+ - **The published bundle no longer carries internal text.** `tsup` inlines
83
+ `@fleetless/contracts` into `dist/index.js` and `dist/index.cjs` with its doc
84
+ comments intact, and it writes the path each inlined module came from as a
85
+ comment beside it. In 3.0.0 those paths encoded a `git+ssh://` dependency
86
+ specifier, so an internal hostname appeared **48 times** across the two
87
+ bundles; the inlined comments carried German paragraphs and internal defect
88
+ ids with them.
89
+
90
+ The table this entry first carried cited "the same seventeen detectors",
91
+ while the entry below it said the guard had fifteen classes and the guard
92
+ itself asserted fifteen. No seventeen-detector artefact ever existed, so
93
+ the numbers could not be reproduced from anything shipped. They are
94
+ replaced here by a measurement of the two **published tarballs** with the
95
+ guard as rebuilt in 3.0.2, which is a thing a reader can run:
96
+
97
+ | class | 3.0.0 | 3.0.1 |
98
+ |---|---:|---:|
99
+ | terse schedule label | 134 | 0 |
100
+ | German prose | 58 | 0 |
101
+ | internal host or workspace name | 49 | 0 |
102
+ | internal decision label | 44 | **2** |
103
+ | a reference to this package rather than the reader's | 30 | 0 |
104
+ | internal review codename | 28 | 0 |
105
+ | a reference to a document the reader does not have | 26 | 0 |
106
+ | longer schedule label | 16 | 0 |
107
+ | how the behaviour was found | 16 | **2** |
108
+ | internal defect id | 14 | 0 |
109
+ | internal feature id | 4 | 0 |
110
+ | the reference robot by name | 4 | 0 |
111
+ | **total** | **423** | **4** |
112
+
113
+ The four remaining in 3.0.1 are the subject of 3.0.2 below. They are here
114
+ rather than in that entry because this is the entry that claimed zero.
115
+
116
+ None of it appeared in this repository's own source, which is why no sweep of
117
+ the source had found it. The fix is the contracts pin — `@fleetless/contracts`
118
+ is a public npm package at an exact version now — plus a sweep of this
119
+ repository's own comments.
120
+
121
+ - **`publishers.publish`, `commands.cancel`, `cameras.live` and the error
122
+ re-exports pointed at README sections that did not exist.** One of them
123
+ (`cancel`'s upgrade message) is a **runtime error** telling a developer to
124
+ read "the README's Actions section" of a README whose sections were named
125
+ something else. The README now has *Actions*, *Errors*, and *Publishers, and
126
+ no teleop helpers*, and every pointer resolves.
127
+
128
+ ### Added
129
+
130
+ - **`SECURITY.md`, `CONTRIBUTING.md` and `CODE_OF_CONDUCT.md`**, and all three
131
+ ship inside the tarball, so the README's links resolve from `node_modules` and
132
+ from the npm page. `SECURITY.md` says what is in scope here — how this package
133
+ handles tokens, the PKCE verifier and the `state` value — and that the cloud
134
+ is not in this repository. Security reports go to **security@fleetless.dev**,
135
+ which the README now states literally rather than only by link.
136
+ - **`repository` and `bugs.url`** in `package.json`, pointing at
137
+ <https://github.com/fleetless/sdk>.
138
+ - **An `Errors` section in the README**, documenting the `FleetlessError` `code`
139
+ you branch on, that `rate_limited` is surfaced with its `retry_after_ms` and
140
+ never retried, and that `token_expired` is the one retry the SDK performs.
141
+ - **The SPDX header `// SPDX-License-Identifier: MIT`** on every source file and
142
+ on all four published `dist/` files. `test/license-headers.test.ts` asserts it
143
+ over the repository; `pnpm run test:pack` asserts it over the tarball's own
144
+ bytes, which is the only place that can tell a stamped build from a stamped
145
+ publish.
146
+ - **`test/published-prose.test.ts`**, which is what stops the top item here from
147
+ happening again: fifteen detector classes over `dist/`, `src/`, `test/`,
148
+ `scripts/` and the shipped markdown, with fixtures in both directions.
149
+
7
150
  ## [3.0.0] — 2026-09-06
8
151
 
9
152
  Fleetless shows an app user **no page**. The developer's own UI owns every
@@ -0,0 +1,83 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or advances of any kind
22
+ * Trolling, insulting or derogatory comments, and personal or political attacks
23
+ * Public or private harassment
24
+ * Publishing others' private information, such as a physical or email address, without their explicit permission
25
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
26
+
27
+ ## Enforcement Responsibilities
28
+
29
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
30
+
31
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
32
+
33
+ ## Scope
34
+
35
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
36
+
37
+ ## Enforcement
38
+
39
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at hello@fleetless.dev. All complaints will be reviewed and investigated promptly and fairly.
40
+
41
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
42
+
43
+ ## Enforcement Guidelines
44
+
45
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
46
+
47
+ ### 1. Correction
48
+
49
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
50
+
51
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
52
+
53
+ ### 2. Warning
54
+
55
+ **Community Impact**: A violation through a single incident or series of actions.
56
+
57
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
58
+
59
+ ### 3. Temporary Ban
60
+
61
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
62
+
63
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
64
+
65
+ ### 4. Permanent Ban
66
+
67
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
68
+
69
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
70
+
71
+ ## Attribution
72
+
73
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
74
+
75
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
76
+
77
+ For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at [https://www.contributor-covenant.org/translations][translations].
78
+
79
+ [homepage]: https://www.contributor-covenant.org
80
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
81
+ [Mozilla CoC]: https://github.com/mozilla/diversity
82
+ [FAQ]: https://www.contributor-covenant.org/faq
83
+ [translations]: https://www.contributor-covenant.org/translations
@@ -0,0 +1,131 @@
1
+ # Contributing to `@fleetless/sdk`
2
+
3
+ This package is the TypeScript client for the Fleetless API. It is what a
4
+ developer's own application calls, so a change here reaches every app built on
5
+ it, and a change to what a method *sends* reaches the platform as well.
6
+
7
+ ## Setup
8
+
9
+ Node 22 and pnpm (through corepack):
10
+
11
+ ```sh
12
+ nvm use 22
13
+ corepack enable
14
+ pnpm install
15
+ ```
16
+
17
+ There are no private dependencies. `pnpm install` works from a clean checkout
18
+ with nothing but a network connection to the npm registry — the wire schemas
19
+ come from `@fleetless/contracts`, which is a public package.
20
+
21
+ `pnpm install` runs `prepare`, which builds `dist/`. Some of the checks below
22
+ read the built bundle, so a fresh checkout is ready for them.
23
+
24
+ ## The checks
25
+
26
+ | Command | What it does |
27
+ |---|---|
28
+ | `pnpm typecheck` | `tsc --noEmit` over the whole project. |
29
+ | `pnpm test` | The vitest suite. No network beyond loopback. |
30
+ | `pnpm build` | `tsup` into `dist/` — ESM, CJS, and a declaration file for each. |
31
+ | `pnpm run test:pack` | Packs the tarball, asserts what is and is not inside it, then installs it into a scratch project and both typechecks and runs real code against it. |
32
+
33
+ To run one test file, use `pnpm vitest run test/<name>.test.ts`.
34
+
35
+ ## The rule this repository is most serious about: a real server, not a mocked `fetch`
36
+
37
+ **The auth suites drive the SDK's own default `fetch` against a real
38
+ `node:http` server** (`test/local-api.ts`), and no `fetch` option is passed to
39
+ `createClient` in them.
40
+
41
+ That is not ceremony. A suite that passes its own `fetch` never enters the code
42
+ that actually ships: `client.ts` resolves `globalThis.fetch.bind(globalThis)`,
43
+ and every assertion about "what the SDK sends" becomes an assertion about what
44
+ a `vi.fn()` was asked to pretend to send. The two most expensive defects this
45
+ package has had were both invisible to a mocked `fetch` and both obvious to a
46
+ socket:
47
+
48
+ - `createClient` defaulted to a **detached** `globalThis.fetch`. A real
49
+ browser's `fetch` is a Web IDL method that throws "Illegal invocation" unless
50
+ its receiver is the global object. Node's undici does not enforce that check,
51
+ so every test passed and every browser failed on the first call.
52
+ - A path segment shaped like `../../../admin` reached a real server as a
53
+ traversal, because the encoding was asserted against a double that never
54
+ parsed the URL.
55
+
56
+ So: **if your change is about what leaves the process, test it against
57
+ `test/local-api.ts`.** A double is fine for testing branching, refcounting,
58
+ timers and error mapping, and most of the suite uses one for exactly that.
59
+
60
+ `test/client.test.ts` carries a test named for this property on its own, so
61
+ that removing it is visible in a diff rather than silent.
62
+
63
+ ## Licence headers
64
+
65
+ Every source file carries the SPDX header `// SPDX-License-Identifier: MIT` as
66
+ its first line — a `#!` shebang is the only thing allowed above it.
67
+ `test/license-headers.test.ts` asserts this over the whole set, and it takes
68
+ that set from `git ls-files` rather than from a list of directories, so a file
69
+ added anywhere in the repository is swept the day it exists.
70
+
71
+ ## Nothing internal reaches the published bytes
72
+
73
+ `tsup` bundles `@fleetless/contracts` **into** `dist/index.js` and
74
+ `dist/index.cjs`, doc comments and all, and it writes the path each inlined
75
+ module came from as a comment beside it. A comment written for the people who
76
+ build this is therefore a comment an editor shows to somebody who installed it —
77
+ and for four published versions that included German paragraphs, internal
78
+ defect ids and an internal hostname, none of which appeared anywhere in this
79
+ repository's source.
80
+
81
+ Write a comment as what the code does for a caller. Never as how the behaviour
82
+ was found, on which machine, under which internal ticket, or in which language
83
+ the team happened to be thinking that day.
84
+
85
+ `test/published-prose.test.ts` enforces it over `dist/`, `src/`, `test/`,
86
+ `scripts/` and the shipped markdown, and it will tell you which class of thing
87
+ came back and on which line.
88
+
89
+ ## Pull requests
90
+
91
+ **The public repository is not open yet.** It will be, and this section
92
+ describes how it will work then. Until it exists, send patches and questions to
93
+ <hello@fleetless.dev>. Either way, raise anything that changes an existing
94
+ method signature or what a method sends before you write it, so we can say what
95
+ else has to move with it.
96
+
97
+ **CI runs on GitLab.** This repository is mirrored from an internal GitLab
98
+ instance, which is where the pipeline that verifies and publishes it lives. You
99
+ will not see a check run on your GitHub pull request; a maintainer runs the
100
+ same checks, and the result comes back as a review comment. Run
101
+ `pnpm typecheck && pnpm test && pnpm run test:pack` yourself before you open the
102
+ pull request and you will have seen everything CI would tell you.
103
+
104
+ ## The CLA
105
+
106
+ The first pull request you open will ask you to sign a Contributor Licence
107
+ Agreement. It grants Dehne Robotik GmbH the right to license your contribution
108
+ under terms other than MIT in future — that is the whole of what it is for, and
109
+ it is why the project can relicense its own code later without having to find
110
+ every past contributor. It does not take your copyright away and it does not
111
+ stop you from using your own contribution however you like.
112
+
113
+ ## Commit messages
114
+
115
+ [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/):
116
+ `feat:`, `fix:`, `docs:`, `chore:`, `ci:`, `refactor:`, `test:`. A change that
117
+ alters an existing method's signature or what it sends is a breaking change;
118
+ say so with a `!` and a `BREAKING CHANGE:` footer, because it decides the next
119
+ version number.
120
+
121
+ Everything in this repository is written in **English** — code, comments,
122
+ commit messages, documentation.
123
+
124
+ ## Code of conduct
125
+
126
+ By participating you agree to the [Code of Conduct](CODE_OF_CONDUCT.md).
127
+
128
+ ## Releasing (maintainers)
129
+
130
+ See [RELEASING.md](RELEASING.md). The pipeline publishes; `npm publish` from a
131
+ working tree is not how a version gets to the registry.
package/README.md CHANGED
@@ -12,8 +12,27 @@ behind roles. The SDK covers all of it: datapoints (read, subscribe, recorded
12
12
  history), actions, services, publishers, cameras, jobs, assets and URDF, and
13
13
  the whole client auth API your own sign-in UI calls. It is framework-agnostic,
14
14
  ships ESM and CJS with its own types, and runs wherever a `fetch` and a
15
- `WebSocket` exist — a browser, a mobile webview, Node 20 or newer, and
16
- server-side with a server key instead of a user session.
15
+ `WebSocket` exist — a browser, a mobile webview, Node 22 or newer, and
16
+ server-side with a server key instead of a user session. On Node 20 the REST
17
+ half works as it stands, but there is no global `WebSocket` (it is behind
18
+ `--experimental-websocket` there), so anything realtime needs one supplied:
19
+ `createClient({ …, WebSocket: (await import('ws')).WebSocket })`, or the flag.
20
+ Without it, `subscribe` calls `onError` with `no_websocket`.
21
+
22
+ **The mental model in one paragraph.** A robot runs the Fleetless bridge, a
23
+ ROS 2 node. In the [Fleetless Console](https://console.fleetless.dev) a
24
+ developer picks which topics, services and actions that robot exposes and gives
25
+ each one a stable `snake_case` slug and a role that may reach it. The cloud
26
+ turns those into REST and realtime endpoints. This package is the client for
27
+ those endpoints: you address a robot by its id and a capability by its slug,
28
+ you sign your own users in against your own app's user directory, and you never
29
+ see a ROS name, a topic type or a message definition. Renaming a node on the
30
+ robot is invisible to your app; changing a slug is not.
31
+
32
+ New here? The [getting-started guide](https://docs.fleetless.dev/getting-started/)
33
+ goes from a robot that has never connected to a value on a page, and the
34
+ [app-auth recipe](https://docs.fleetless.dev/recipes/app-auth/) is the
35
+ walkthrough for every sign-in screen.
17
36
 
18
37
  ## Why
19
38
 
@@ -202,7 +221,7 @@ const grants = await client.auth.listMcpGrants()
202
221
  await client.auth.revokeMcpGrant(grants[0].client_id)
203
222
  ```
204
223
 
205
- ### Running a job
224
+ ### Actions
206
225
 
207
226
  An action is a job with a lifecycle. `invoke` resolves as soon as the job
208
227
  exists; feedback, progress and the result arrive over `subscribe`.
@@ -230,6 +249,35 @@ sub.unsubscribe()
230
249
  `error.details.running`. A service is the same machinery with a plain result:
231
250
  `await client.services.call(robotId, 'set_mode', { mode: 'autonomous' })`.
232
251
 
252
+ ### Publishers, and no teleop helpers
253
+
254
+ `publishers.publish` sends **one** message. There is no `startPublishing`, no
255
+ rate helper, no joystick binding and no "hold this value" call, and that is a
256
+ decision rather than a gap.
257
+
258
+ The safety primitive lives on the robot. A publisher is configured with a
259
+ `timeout_ms` and a failsafe message; if messages stop arriving — including
260
+ because your process crashed, your tab closed, or the network went away — the
261
+ bridge publishes the failsafe itself. Nothing in your event loop has to survive
262
+ for that to happen.
263
+
264
+ A helper here would move the appearance of that guarantee into a browser, where
265
+ it is not true. So *how often* and *when* to publish is your application's
266
+ decision, made where it can see the user's intent:
267
+
268
+ ```ts
269
+ // A control loop is yours to write, and yours to stop. `speed` is your app's.
270
+ const timer = setInterval(() => {
271
+ void client.publishers.publish(robotId, 'cmd_vel', { 'linear.x': speed })
272
+ }, 100)
273
+
274
+ // Stop publishing and let the robot's own failsafe take over.
275
+ clearInterval(timer)
276
+ ```
277
+
278
+ `publish` rejects `publisher_busy` while a different user holds the publisher
279
+ and has not been quiet for its configured timeout.
280
+
233
281
  ### Cameras
234
282
 
235
283
  ```ts
@@ -250,6 +298,65 @@ await room.disconnect()
250
298
  await session.release()
251
299
  ```
252
300
 
301
+ ## Errors
302
+
303
+ Every refusal arrives as a `FleetlessError` with a stable `code`. Branch on the
304
+ code; never parse the message, which is written for a developer reading a
305
+ console and may change.
306
+
307
+ `error.details` is typed `unknown`, deliberately: it is whatever the server
308
+ sent, and the SDK does not pretend to have validated it. Narrow it before you
309
+ read a field. `BusyDetails` and `RateLimitDetails` are exported as types, and
310
+ `parameterInvalidDetails` as a runtime schema you can `parse`.
311
+
312
+ ```ts checked
313
+ import { createClient, FleetlessError } from '@fleetless/sdk'
314
+ import type { BusyDetails, RateLimitDetails } from '@fleetless/sdk'
315
+
316
+ declare function showRunning(job: BusyDetails['running'] | undefined): void
317
+ declare function showOffline(): void
318
+ declare function showNotAllowed(): void
319
+ declare function showRetryLater(ms: number | undefined): void
320
+ declare function showUnexpected(error: FleetlessError): void
321
+
322
+ const client = createClient({ apiUrl: 'https://api.fleetless.dev', appIdentifier: 'warehouse_dash' })
323
+ const robotId = '4f2c1a90-7b3e-4d51-9c86-0a1b2c3d4e5f'
324
+
325
+ /** `details` is server-shaped: check the field is there before reading it. */
326
+ const field = <T,>(details: unknown, key: string): T | undefined =>
327
+ typeof details === 'object' && details !== null && key in details
328
+ ? ((details as Record<string, unknown>)[key] as T)
329
+ : undefined
330
+
331
+ try {
332
+ await client.actions.invoke(robotId, 'dock', {})
333
+ } catch (error) {
334
+ if (!(error instanceof FleetlessError)) throw error
335
+ switch (error.code) {
336
+ case 'busy': showRunning(field<BusyDetails['running']>(error.details, 'running')); break
337
+ case 'robot_offline': showOffline(); break
338
+ case 'forbidden': showNotAllowed(); break
339
+ case 'rate_limited': showRetryLater(field<RateLimitDetails['retry_after_ms']>(error.details, 'retry_after_ms')); break
340
+ default: showUnexpected(error); break
341
+ }
342
+ }
343
+ ```
344
+
345
+ - **`rate_limited` is surfaced, never retried behind your back.** The SDK does
346
+ not sleep and re-send. `details.retry_after_ms` carries the wait the platform
347
+ asked for, when it sent one — read it defensively, since a refusal from an
348
+ intermediary may carry no `details` at all.
349
+ - **The one retry the SDK does perform is `token_expired`**, and only once: it
350
+ refreshes the session and re-sends the same request. That refresh is
351
+ single-flight, so ten concurrent calls meeting an expired token share one.
352
+ - **`command_outcome_unknown` is an honest answer, not a failure.** It means
353
+ the realtime connection cycled while a command was in flight and the SDK
354
+ cannot say whether the robot got it. Read the job back by slug through
355
+ `actions.subscribe` to find out.
356
+ - Some codes never reach the network at all — `invalid_option`,
357
+ `state_mismatch`, `no_session`, `untrusted_absolute_url`. They are the SDK
358
+ refusing to send something rather than the platform refusing to accept it.
359
+
253
360
  ## Documentation and help
254
361
 
255
362
  - **[SDK reference](https://docs.fleetless.dev/reference/sdk/)** — every method,
@@ -270,10 +377,27 @@ await session.release()
270
377
  Fleetless is in closed beta. The waiting list is at
271
378
  <https://fleetless.dev/#waiting-list>.
272
379
 
380
+ ## Reporting a security issue
381
+
382
+ Email **security@fleetless.dev**. Please do not open a public issue for a
383
+ security report. [SECURITY.md](SECURITY.md) says what is in scope here — how
384
+ this package handles tokens, the PKCE verifier and the `state` value — and what
385
+ belongs to the platform instead.
386
+
387
+ ## Contributing
388
+
389
+ The public repository is not open yet. Until it is, send patches and questions
390
+ to <hello@fleetless.dev>. Read
391
+ [CONTRIBUTING.md](CONTRIBUTING.md) first: it covers the setup, the checks, the
392
+ Contributor Licence Agreement, and the one rule this repository is strict about
393
+ — the auth suites drive the SDK's own `fetch` against a real `node:http`
394
+ server rather than a double, because a mocked `fetch` cannot see the bugs that
395
+ have actually shipped.
396
+
397
+ By participating you agree to the [Code of Conduct](CODE_OF_CONDUCT.md).
398
+
273
399
  ## Maintainers
274
400
 
275
- Maintained by [Dehne Robotik GmbH](https://dehne-robotik.de). The source
276
- repository is private and takes no outside contributions; questions and bug
277
- reports go to hello@fleetless.dev.
401
+ Maintained by [Dehne Robotik GmbH](https://dehne-robotik.de).
278
402
 
279
403
  MIT licensed — see [LICENSE](LICENSE).