@fleetless/sdk 3.0.1 → 3.0.3

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/dist/index.d.cts CHANGED
@@ -1,7 +1,6 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  import { z } from 'zod';
3
3
 
4
- // SPDX-License-Identifier: Apache-2.0
5
4
 
6
5
  /**
7
6
  * Jobs: one running unit of work on a robot — an action
@@ -234,7 +233,6 @@ declare const historyBucketsResponse: z.ZodObject<{
234
233
  }, z.core.$strip>;
235
234
  type HistoryBucketsResponse = z.infer<typeof historyBucketsResponse>;
236
235
 
237
- // SPDX-License-Identifier: Apache-2.0
238
236
 
239
237
  /**
240
238
  * One datapoint sample pushed to a subscriber. The current value arrives
@@ -250,7 +248,6 @@ declare const datapointEvent: z.ZodObject<{
250
248
  }, z.core.$strip>;
251
249
  type DatapointEvent = z.infer<typeof datapointEvent>;
252
250
 
253
- // SPDX-License-Identifier: Apache-2.0
254
251
 
255
252
  /**
256
253
  * Access plus refresh. The access token is short-lived; the
@@ -267,7 +264,6 @@ declare const sessionTokens: z.ZodObject<{
267
264
  }, z.core.$strip>;
268
265
  type SessionTokens = z.infer<typeof sessionTokens>;
269
266
 
270
- // SPDX-License-Identifier: Apache-2.0
271
267
 
272
268
  /**
273
269
  * **Why a federated sign-in ended without a session, in a code the app can
@@ -416,7 +412,6 @@ declare const clientIdentity: z.ZodObject<{
416
412
  }, z.core.$strip>;
417
413
  type ClientIdentity = z.infer<typeof clientIdentity>;
418
414
 
419
- // SPDX-License-Identifier: Apache-2.0
420
415
 
421
416
  declare const asset: z.ZodObject<{
422
417
  id: z.ZodUUID;
@@ -551,7 +546,6 @@ declare const assetListResponse: z.ZodObject<{
551
546
  }, z.core.$strip>;
552
547
  type AssetListResponse = z.infer<typeof assetListResponse>;
553
548
 
554
- // SPDX-License-Identifier: Apache-2.0
555
549
 
556
550
  /**
557
551
  * One violated parameter rule. `details` on the envelope stays `unknown` — codes
@@ -613,13 +607,13 @@ type ErrorCode = (typeof ERROR_CODES)[number];
613
607
  * later on the same socket — nobody knows — but the caller cannot be made
614
608
  * to wait forever for that.
615
609
  * - `command_outcome_unknown`: worse than a timeout, and told apart from it
616
- * on purpose — the realtime connection that carried the command was
617
- * replaced by a new one (a reconnect) before any reply arrived. A reply
618
- * can now never come: the server, if it answered at all, answered a
619
- * socket that no longer exists. The command may or may not have run.
620
- * Never retried automatically — that could run an action twice — the
621
- * caller recovers by reading the job (e.g. `actions.subscribe`), since
622
- * state is observed by slug regardless of which connection asked for it.
610
+ * on purpose — the connection that carried the command was replaced by a
611
+ * new one (a reconnect) before any reply arrived. The server, if it
612
+ * answered at all, answered a socket that no longer exists, so the
613
+ * command may or may not have run. Never retried automatically — that
614
+ * could run an action twice — the caller recovers by reading the job
615
+ * (e.g. `actions.subscribe`), since state is observed by slug regardless
616
+ * of which connection asked for it.
623
617
  * - `unexpected_response`: the server answered `ok:true` but left out
624
618
  * something the command is defined to always return (e.g. no `job` on a
625
619
  * successful `invoke`) — a contract violation the SDK noticed, not a
@@ -807,20 +801,19 @@ interface JobSubscriptionHandlers {
807
801
  interface JobSubscription {
808
802
  /**
809
803
  * Stops this subscription. The `unsubscribe` frame reaches the server only
810
- * when this was the **last** holder of the robot and slug pair, and only if
811
- * the channel is connected — subscriptions are reference-counted across
812
- * kinds, so releasing this one while a second `actions.subscribe`, a
813
- * `datapoints.subscribe` or an in-flight `services.call` still holds the
814
- * same pair leaves that one's stream running untouched. Safe to call more
815
- * than once.
804
+ * when this was the **last** holder of the robot/slug pair and the channel
805
+ * is connected — subscriptions are reference-counted across kinds, so a
806
+ * second `actions.subscribe`, `datapoints.subscribe` or in-flight
807
+ * `services.call` on the same pair keeps its stream running. Safe to call
808
+ * more than once.
816
809
  */
817
810
  unsubscribe(): void;
818
811
  }
819
812
 
820
813
  /**
821
814
  * Long-running work on a robot, reachable as `client.actions`. An action is
822
- * a ROS action the developer exposed under a slug: it is invoked, it runs
823
- * for as long as it runs, and it reports back while it does.
815
+ * a ROS action the developer exposed under a slug: it is invoked, runs as
816
+ * long as it runs, and reports back while it does.
824
817
  */
825
818
  interface ActionsApi {
826
819
  /**
@@ -828,7 +821,7 @@ interface ActionsApi {
828
821
  * — the job id is informative, not the result. Feedback, progress and the
829
822
  * eventual result arrive separately over `subscribe`. A second invoke of
830
823
  * the same slug while one is already running is refused `busy`, with
831
- * `error.details.running` naming the job that is running.
824
+ * `error.details.running` naming the running job.
832
825
  *
833
826
  * `options.patienceMs` bounds goal *acceptance* only — once a goal
834
827
  * is accepted this call has already resolved; the job then runs as long
@@ -1112,7 +1105,7 @@ interface AssetsApi {
1112
1105
  * **Do not also install `createMeshLoader` on the same manager.** The two
1113
1106
  * consume different URDF sources — this method fetches the URDF's *raw*
1114
1107
  * bytes, `createMeshLoader` is meant to pair with `urdf()`'s
1115
- * cloud-rewritten text. **It is not that every mesh gets fetched twice.**
1108
+ * cloud-rewritten text. **Not a double-fetch.**
1116
1109
  * What actually happens is asymmetric breakage,
1117
1110
  * whichever URDF text the combination ends up parsing: paired with
1118
1111
  * *this* method's raw text, `createMeshLoader` receives urdf-loader's
@@ -1242,7 +1235,7 @@ interface TokenStore {
1242
1235
  /** The default store: works out of the box, forgets the session on reload. */
1243
1236
  declare class InMemoryTokenStore implements TokenStore {
1244
1237
  #private;
1245
- /** Creates an empty store. Nothing is loaded from anywhere — a client built with it starts logged out. */
1238
+ /** Nothing is loaded from anywhere — a client built with it starts logged out. */
1246
1239
  constructor();
1247
1240
  /** Returns the session held in memory, or `null` if there is none. */
1248
1241
  load(): StoredSession | null;
@@ -1686,8 +1679,8 @@ interface CameraLiveSession {
1686
1679
  * courteous fast path; the robot actually stops publishing once every
1687
1680
  * viewer's LiveKit `Room` has disconnected, which the SFU notices on its
1688
1681
  * own with no cooperation required. **Always pair this with disconnecting
1689
- * the `Room` you connected with `url`/`token`** — see the README's
1690
- * Cameras section for the paired cleanup pattern; a `release()` that ran
1682
+ * the `Room` you connected with `url`/`token`** — see the Cameras
1683
+ * section of the SDK reference for the paired cleanup pattern; a `release()` that ran
1691
1684
  * alone while the `Room` stayed connected would stop nothing.
1692
1685
  *
1693
1686
  * Safe to call more than once (only the first call does anything) and
@@ -1698,14 +1691,12 @@ interface CameraLiveSession {
1698
1691
  * from `beforeunload`, where a call that could throw would be a liability.
1699
1692
  *
1700
1693
  * **A failed DELETE here is not observable anywhere** — not as a
1701
- * rejection, not as a realtime event, not as a field on this object. This
1702
- * is a deliberate decision, not an oversight: the only
1703
- * consumer of that information would be code deciding whether to retry,
1704
- * and the backstop this comment already describes — the cloud's own
1705
- * LiveKit-participation reconciliation — makes a retry unnecessary for
1706
- * correctness. If a future caller needs to know "did my release actually
1707
- * reach the cloud" (telemetry, say), that is a new, additive signal to
1708
- * design, not a change to this method's contract.
1694
+ * rejection, a realtime event, or a field on this object. Deliberate, not
1695
+ * an oversight: the only consumer of that information would be code
1696
+ * deciding whether to retry, and the reconciliation backstop described
1697
+ * above already makes a retry unnecessary for correctness. A future need
1698
+ * to know "did my release actually reach the cloud" (telemetry, say) is a
1699
+ * new, additive signal to design, not a change to this method's contract.
1709
1700
  */
1710
1701
  release(): Promise<void>;
1711
1702
  }
@@ -1759,12 +1750,11 @@ interface DatapointSubscriptionHandlers {
1759
1750
  interface DatapointSubscription {
1760
1751
  /**
1761
1752
  * Stops this subscription. The `unsubscribe` frame reaches the server only
1762
- * when this was the **last** holder of the robot and slug pair, and only if
1763
- * the channel is connected — subscriptions are reference-counted across
1764
- * kinds, so releasing this one while a second `datapoints.subscribe`, an
1765
- * `actions.subscribe` or an in-flight `services.call` still holds the same
1766
- * pair leaves that one's stream running untouched. Safe to call more than
1767
- * once.
1753
+ * when this was the **last** holder of the robot/slug pair and the channel
1754
+ * is connected — subscriptions are reference-counted across kinds, so
1755
+ * releasing this one while a `datapoints.subscribe`, `actions.subscribe` or
1756
+ * in-flight `services.call` still holds the same pair leaves that one's
1757
+ * stream running. Safe to call more than once.
1768
1758
  */
1769
1759
  unsubscribe(): void;
1770
1760
  }
@@ -1772,11 +1762,10 @@ interface DatapointSubscription {
1772
1762
  * Window aggregation for `datapoints.history`. `window` and `agg` always
1773
1763
  * travel together on the wire — the cloud refuses one without the other
1774
1764
  * rather than defaulting either, since a silently chosen aggregation is a
1775
- * chart that lies quietly — so they live in one object here instead of two
1776
- * independent optional fields a caller could set only one of. The same
1777
- * reasoning as `cameraSource` being a discriminated union rather than
1778
- * optional fields: make the impossible combination unrepresentable, not
1779
- * merely rejected.
1765
+ * chart that lies quietly — so they live in one object instead of two
1766
+ * optional fields a caller could set only one of. Same reasoning as
1767
+ * `cameraSource`'s discriminated union: make the impossible combination
1768
+ * unrepresentable, not merely rejected.
1780
1769
  */
1781
1770
  interface HistoryAggregation {
1782
1771
  /** Bucket width, e.g. `10s`, `1m`. */
@@ -1787,9 +1776,8 @@ interface HistoryAggregation {
1787
1776
  field?: string;
1788
1777
  }
1789
1778
  /**
1790
- * The window `datapoints.history` reads, and whether it comes back as raw
1791
- * samples or as aggregated buckets. `aggregate` is what decides which of
1792
- * the two responses you get.
1779
+ * The window `datapoints.history` reads. `aggregate` decides whether the
1780
+ * response is raw samples or aggregated buckets.
1793
1781
  */
1794
1782
  interface HistoryOptions {
1795
1783
  /**
@@ -1829,9 +1817,9 @@ interface DatapointsApi {
1829
1817
  * Reference-counted per `(robotId, slug)`: two subscriptions to the same
1830
1818
  * pair share one wire subscription. Unsubscribing one never affects the
1831
1819
  * other — the `unsubscribe` frame is sent only when the last subscriber
1832
- * on that pair goes away. This matters in practice: two widgets showing
1833
- * the same battery value, or a component mounted twice under React
1834
- * StrictMode, both subscribe to the same key. That count is shared with
1820
+ * on that pair goes away. In practice: two widgets showing the same
1821
+ * battery value, or a component mounted twice under React StrictMode,
1822
+ * subscribe to the same key. That count is shared with
1835
1823
  * `actions.subscribe` and `services.call` — a slug is one namespace across
1836
1824
  * kinds, and so is its subscription.
1837
1825
  */
@@ -1844,10 +1832,9 @@ interface DatapointsApi {
1844
1832
  * reduced by `aggregate.agg`. Leave `aggregate` out and the other overload
1845
1833
  * gives you raw samples instead.
1846
1834
  *
1847
- * Two overloads rather than one union so a caller who already knows which
1848
- * they asked for isn't forced to narrow something they determined
1849
- * themselves. `kind` still carries the same information on both, so code
1850
- * holding the result dynamically can still branch on it.
1835
+ * Two overloads rather than one union, so a caller who already knows which
1836
+ * one they asked for isn't forced to narrow it. `kind` carries the same
1837
+ * information either way, so dynamic code can still branch on it.
1851
1838
  *
1852
1839
  * **Rejects, does not silently empty out, two specific refusals** —
1853
1840
  * unlike `cameras.snapshot`'s absorption of `no_snapshot_yet` into a null
@@ -1881,28 +1868,26 @@ interface DatapointsApi {
1881
1868
  }
1882
1869
 
1883
1870
  /**
1884
- * Robot-wide job reads, reachable as `client.jobs`. Everything here is
1885
- * addressed by robot rather than by slug, which is what `actions` and
1886
- * `services` cannot do.
1871
+ * Robot-wide job reads, reachable as `client.jobs` — addressed by robot,
1872
+ * not slug, which `actions` and `services` cannot do.
1887
1873
  */
1888
1874
  interface JobsApi {
1889
1875
  /**
1890
1876
  * Every job the platform currently believes this robot has.
1891
1877
  *
1892
- * `actions.subscribe`/`services.call` and `GET /jobs/:slug` (the per-slug
1893
- * route those build on) all require already knowing the slug. That is not
1894
- * always true: a reconnecting bridge can name a job the cloud only
1895
- * *adopted*, and a configuration change can leave a job on a slug the
1896
- * published document no longer contains. Both are jobs no slug can name,
1897
- * which is exactly what this method is for — an app developer has no
1898
- * other way to reach them.
1899
- *
1900
- * At most one entry per slug: the current job there, exactly what a
1901
- * per-slug read would answer for that slug. Not a history endpoint.
1902
- * Grant-filtered same as `cameras.list`/`datapoints` — an end user or
1903
- * server key sees only jobs on slugs their role grants; a developer
1904
- * session sees every job on the robot. Never empty-vs-missing ambiguity:
1905
- * a robot doing nothing resolves `[]`.
1878
+ * `actions.subscribe`/`services.call` and `GET /jobs/:slug` — the per-slug
1879
+ * route those build on — all require knowing the slug already. Two cases
1880
+ * don't: a reconnecting bridge naming a job the cloud only *adopted*, and
1881
+ * a config change leaving a job on a slug the published document no
1882
+ * longer contains. Neither has a slug to give — this method is the only
1883
+ * way an app developer reaches them.
1884
+ *
1885
+ * At most one entry per slug: the current job there, same as a per-slug
1886
+ * read would answer. Not a history endpoint. Grant-filtered same as
1887
+ * `cameras.list`/`datapoints` — an end user or server key sees only jobs
1888
+ * on slugs their role grants, a developer session sees every job on the
1889
+ * robot. Never empty-vs-missing ambiguity: a robot doing nothing
1890
+ * resolves `[]`.
1906
1891
  *
1907
1892
  * **Ordered newest first by `started_at`, with `job.seq` as the
1908
1893
  * tiebreaker** (`started_at` alone is not a total order — two jobs minted
@@ -1926,16 +1911,15 @@ interface PublishersApi {
1926
1911
  /**
1927
1912
  * Publishes one message to a publisher.
1928
1913
  *
1929
- * This is a plain method call — there is deliberately no deadman switch,
1930
- * rate governor or "takt" helper here. The bridge's own
1931
- * `timeout_ms` failsafe is the platform's safety primitive: if messages
1932
- * stop arriving — including because this process crashed — the bridge
1933
- * publishes the configured failsafe message itself. That does **not**
1934
- * mean the SDK protects a caller who stops calling `publish` on purpose
1935
- * without stopping cleanly (e.g. no repeated call at a safe rate): the
1936
- * safety pattern for *how often* and *when* to publish belongs in the
1937
- * app, not here. See the README's "Publishers, and no teleop helpers"
1938
- * section before building a publisher-driven control loop.
1914
+ * A plain method call — deliberately no deadman switch, rate governor or
1915
+ * "takt" helper. The bridge's own `timeout_ms` failsafe is the platform's
1916
+ * safety primitive: when messages stop arriving, crash included, the
1917
+ * bridge publishes its configured failsafe message. That does **not**
1918
+ * cover a caller who stops calling `publish` on purpose without stopping
1919
+ * cleanly (e.g. no repeated call at a safe rate) — how often and when to
1920
+ * publish is the app's pattern, not the SDK's. See the Publishers
1921
+ * section of the SDK reference before building a
1922
+ * publisher-driven control loop.
1939
1923
  *
1940
1924
  * Rejects `publisher_busy` while a different user is publishing and has
1941
1925
  * not been quiet for its configured quiet timeout yet — whoever publishes
@@ -1946,16 +1930,15 @@ interface PublishersApi {
1946
1930
 
1947
1931
  /**
1948
1932
  * Request/response calls to a robot, reachable as `client.services`. A
1949
- * service answers once and is done, which is why this namespace has a
1950
- * single method and nothing to subscribe to.
1933
+ * service answers once and is done — one method, nothing to subscribe to.
1951
1934
  */
1952
1935
  interface ServicesApi {
1953
1936
  /**
1954
1937
  * Calls a service and resolves with its result. A service call is a job
1955
1938
  * underneath — the same `job_id` exchange and disconnect survival as an
1956
1939
  * action — but that is deliberately invisible here: the caller gets a
1957
- * plain `Promise<result>`, matching the REST `serviceCallResponse` shape's
1958
- * developer experience. There is nothing to subscribe to for a service —
1940
+ * plain `Promise<result>`, matching the REST `serviceCallResponse` shape.
1941
+ * There is nothing to subscribe to for a service —
1959
1942
  * no feedback, no progress, no cancel — so this call already waits for
1960
1943
  * the terminal state internally.
1961
1944
  *
@@ -1968,8 +1951,7 @@ interface ServicesApi {
1968
1951
  * call — the ack that a job was created, plus however much of the
1969
1952
  * budget is left for it to then reach a terminal state — not two
1970
1953
  * separate `timeoutMs`-length windows back to back. A caller who sets
1971
- * `timeoutMs: 5000` is bounding total latency at ~5s, not ~10s; the
1972
- * number means what it says, once, for the whole call.
1954
+ * `timeoutMs: 5000` bounds total latency at ~5s, not ~10s.
1973
1955
  *
1974
1956
  * It is also **not independent** of `patienceMs`: left unset, it
1975
1957
  * is derived from `patienceMs` so this SDK's local clock cannot fire
@@ -1992,10 +1974,9 @@ interface FleetlessClientOptions {
1992
1974
  /** The app's identifier (the slug shown in the console), sent on every login. */
1993
1975
  appIdentifier: string;
1994
1976
  /**
1995
- * Where refresh/access tokens are kept between calls. Defaults to an
1996
- * in-memory store — pass your own (localStorage, a cookie, a native
1997
- * keystore) to persist a session across reloads. The SDK never assumes a
1998
- * browser exists.
1977
+ * Where refresh/access tokens live between calls. Defaults to in-memory —
1978
+ * pass your own (localStorage, a cookie, a native keystore) to persist a
1979
+ * session across reloads. The SDK never assumes a browser exists.
1999
1980
  */
2000
1981
  tokenStore?: TokenStore;
2001
1982
  /**
@@ -2057,13 +2038,13 @@ interface FleetlessClient {
2057
2038
  /** URDF and mesh reads — list/get/urdf, plus the `urdf-loader` mesh callback. */
2058
2039
  readonly assets: AssetsApi;
2059
2040
  /**
2060
- * Closes the realtime channel and stops it from reconnecting. Safe to
2061
- * call whether or not any subscription was ever made, and safe to call
2062
- * more than once. A Node script (the exact use case `serverKey` is for)
2063
- * that never calls this after subscribing will not exit on its own — an
2064
- * open WebSocket keeps the event loop alive. `auth.logout()` calls this
2065
- * automatically; call it yourself too if the process should exit without
2066
- * logging out (e.g. a server-side caller shutting down).
2041
+ * Closes the realtime channel and stops it from reconnecting. Safe with
2042
+ * no subscription ever made, and safe to call twice. A Node script (the
2043
+ * exact use case `serverKey` is for) that never calls this after
2044
+ * subscribing will not exit on its own — an open WebSocket keeps the
2045
+ * event loop alive. `auth.logout()` calls this automatically; call it
2046
+ * yourself if the process should exit without logging out (e.g. a
2047
+ * server-side shutdown).
2067
2048
  */
2068
2049
  close(): void;
2069
2050
  }