@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/CHANGELOG.md +101 -10
- package/CONTRIBUTING.md +76 -70
- package/README.md +65 -319
- package/SECURITY.md +11 -11
- package/dist/index.cjs +44 -45
- package/dist/index.d.cts +80 -99
- package/dist/index.d.ts +80 -99
- package/dist/index.js +44 -45
- package/package.json +7 -6
package/dist/index.d.ts
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
|
|
617
|
-
*
|
|
618
|
-
*
|
|
619
|
-
*
|
|
620
|
-
*
|
|
621
|
-
*
|
|
622
|
-
*
|
|
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
|
|
811
|
-
*
|
|
812
|
-
*
|
|
813
|
-
* `
|
|
814
|
-
*
|
|
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,
|
|
823
|
-
*
|
|
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
|
|
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. **
|
|
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
|
-
/**
|
|
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
|
|
1690
|
-
*
|
|
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,
|
|
1702
|
-
*
|
|
1703
|
-
*
|
|
1704
|
-
*
|
|
1705
|
-
*
|
|
1706
|
-
*
|
|
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
|
|
1763
|
-
*
|
|
1764
|
-
*
|
|
1765
|
-
*
|
|
1766
|
-
*
|
|
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
|
|
1776
|
-
*
|
|
1777
|
-
*
|
|
1778
|
-
*
|
|
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
|
|
1791
|
-
* samples or
|
|
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.
|
|
1833
|
-
*
|
|
1834
|
-
*
|
|
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
|
|
1849
|
-
*
|
|
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
|
|
1885
|
-
*
|
|
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`
|
|
1893
|
-
* route those build on
|
|
1894
|
-
*
|
|
1895
|
-
*
|
|
1896
|
-
*
|
|
1897
|
-
*
|
|
1898
|
-
*
|
|
1899
|
-
*
|
|
1900
|
-
*
|
|
1901
|
-
*
|
|
1902
|
-
*
|
|
1903
|
-
*
|
|
1904
|
-
*
|
|
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
|
-
*
|
|
1930
|
-
*
|
|
1931
|
-
*
|
|
1932
|
-
*
|
|
1933
|
-
*
|
|
1934
|
-
*
|
|
1935
|
-
*
|
|
1936
|
-
*
|
|
1937
|
-
*
|
|
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
|
|
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
|
|
1958
|
-
*
|
|
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`
|
|
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
|
|
1996
|
-
*
|
|
1997
|
-
*
|
|
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
|
|
2061
|
-
*
|
|
2062
|
-
*
|
|
2063
|
-
*
|
|
2064
|
-
*
|
|
2065
|
-
*
|
|
2066
|
-
*
|
|
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
|
}
|