@fleetless/sdk 3.0.3 → 3.1.1

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.ts CHANGED
@@ -2,6 +2,68 @@
2
2
  import { z } from 'zod';
3
3
 
4
4
 
5
+ /**
6
+ * One exposure of a robot, as `robot_describe` and the console's per-role
7
+ * preview list it. Every exposure the role grants is listed —
8
+ * a missing `description` is shown as `null`, never used to hide the entry.
9
+ *
10
+ * `input_schema` is a JSON Schema document generated from an action's,
11
+ * service's or publisher's `parameters`; `null` for the other kinds. It is
12
+ * `unknown` for the same reason the retired `mcpToolPreview.input_schema`
13
+ * was: pinning it would mean maintaining a zod description of JSON Schema.
14
+ */
15
+ declare const mcpExposure: z.ZodObject<{
16
+ slug: z.ZodString;
17
+ kind: z.ZodEnum<{
18
+ datapoint: "datapoint";
19
+ action: "action";
20
+ service: "service";
21
+ publisher: "publisher";
22
+ camera: "camera";
23
+ }>;
24
+ description: z.ZodNullable<z.ZodString>;
25
+ unit: z.ZodNullable<z.ZodString>;
26
+ decimals: z.ZodNullable<z.ZodNumber>;
27
+ input_schema: z.ZodNullable<z.ZodUnknown>;
28
+ }, z.core.$strip>;
29
+ type McpExposure$1 = z.infer<typeof mcpExposure>;
30
+ /** The two role capabilities a robot tool can need beyond a slug grant. `presence` is a stream and has no tool. */
31
+ declare const mcpCapabilities: z.ZodObject<{
32
+ action_history: z.ZodBoolean;
33
+ assets: z.ZodBoolean;
34
+ }, z.core.$strip>;
35
+ type McpCapabilities$1 = z.infer<typeof mcpCapabilities>;
36
+ /**
37
+ * What one caller may do on one robot — the answer to `robot_describe`, and
38
+ * since 1.1.0 to `GET /api/robots/:id/datasheet` as well. One schema for both
39
+ * surfaces on purpose: an app and an AI tool read the same description of the
40
+ * same grant. The `mcp` prefix is history, not scope.
41
+ */
42
+ declare const mcpRobotDatasheet: z.ZodObject<{
43
+ robot_id: z.ZodUUID;
44
+ robot_name: z.ZodString;
45
+ capabilities: z.ZodObject<{
46
+ action_history: z.ZodBoolean;
47
+ assets: z.ZodBoolean;
48
+ }, z.core.$strip>;
49
+ exposures: z.ZodArray<z.ZodObject<{
50
+ slug: z.ZodString;
51
+ kind: z.ZodEnum<{
52
+ datapoint: "datapoint";
53
+ action: "action";
54
+ service: "service";
55
+ publisher: "publisher";
56
+ camera: "camera";
57
+ }>;
58
+ description: z.ZodNullable<z.ZodString>;
59
+ unit: z.ZodNullable<z.ZodString>;
60
+ decimals: z.ZodNullable<z.ZodNumber>;
61
+ input_schema: z.ZodNullable<z.ZodUnknown>;
62
+ }, z.core.$strip>>;
63
+ }, z.core.$strip>;
64
+ type McpRobotDatasheet = z.infer<typeof mcpRobotDatasheet>;
65
+
66
+
5
67
  /**
6
68
  * Jobs: one running unit of work on a robot — an action
7
69
  * goal or a service call — with an id both sides know, so bridge and cloud
@@ -116,6 +178,94 @@ declare const busyDetails: z.ZodObject<{
116
178
  }, z.core.$strip>;
117
179
  }, z.core.$strip>;
118
180
  type BusyDetails = z.infer<typeof busyDetails>;
181
+ /**
182
+ * One durable record of one invocation. One row per run, never one per event:
183
+ * the per-event timeline's write rate
184
+ * is set by the bridge, and a throttled log that cannot say it was throttled is
185
+ * an instrument that cannot say what it does not know. The live timeline is
186
+ * delivered in full by realtime, for as long as somebody is watching.
187
+ */
188
+ declare const jobRun: z.ZodObject<{
189
+ id: z.ZodUUID;
190
+ robot_id: z.ZodUUID;
191
+ slug: z.ZodString;
192
+ kind: z.ZodEnum<{
193
+ action: "action";
194
+ service: "service";
195
+ }>;
196
+ state: z.ZodEnum<{
197
+ failed: "failed";
198
+ running: "running";
199
+ succeeded: "succeeded";
200
+ cancelled: "cancelled";
201
+ lost: "lost";
202
+ }>;
203
+ started_at: z.ZodISODateTime;
204
+ ended_at: z.ZodNullable<z.ZodISODateTime>;
205
+ duration_ms: z.ZodNullable<z.ZodNumber>;
206
+ result: z.ZodNullable<z.ZodUnknown>;
207
+ error: z.ZodNullable<z.ZodObject<{
208
+ code: z.ZodString;
209
+ message: z.ZodString;
210
+ details: z.ZodOptional<z.ZodUnknown>;
211
+ }, z.core.$strip>>;
212
+ actor: z.ZodObject<{
213
+ kind: z.ZodEnum<{
214
+ developer: "developer";
215
+ server_key: "server_key";
216
+ end_user: "end_user";
217
+ app_user: "app_user";
218
+ }>;
219
+ id: z.ZodUUID;
220
+ label: z.ZodString;
221
+ }, z.core.$strip>;
222
+ seq: z.ZodNumber;
223
+ progress: z.ZodNullable<z.ZodNumber>;
224
+ feedback: z.ZodNullable<z.ZodUnknown>;
225
+ }, z.core.$strip>;
226
+ type JobRun = z.infer<typeof jobRun>;
227
+ declare const jobRunListResponse: z.ZodObject<{
228
+ runs: z.ZodArray<z.ZodObject<{
229
+ id: z.ZodUUID;
230
+ robot_id: z.ZodUUID;
231
+ slug: z.ZodString;
232
+ kind: z.ZodEnum<{
233
+ action: "action";
234
+ service: "service";
235
+ }>;
236
+ state: z.ZodEnum<{
237
+ failed: "failed";
238
+ running: "running";
239
+ succeeded: "succeeded";
240
+ cancelled: "cancelled";
241
+ lost: "lost";
242
+ }>;
243
+ started_at: z.ZodISODateTime;
244
+ ended_at: z.ZodNullable<z.ZodISODateTime>;
245
+ duration_ms: z.ZodNullable<z.ZodNumber>;
246
+ result: z.ZodNullable<z.ZodUnknown>;
247
+ error: z.ZodNullable<z.ZodObject<{
248
+ code: z.ZodString;
249
+ message: z.ZodString;
250
+ details: z.ZodOptional<z.ZodUnknown>;
251
+ }, z.core.$strip>>;
252
+ actor: z.ZodObject<{
253
+ kind: z.ZodEnum<{
254
+ developer: "developer";
255
+ server_key: "server_key";
256
+ end_user: "end_user";
257
+ app_user: "app_user";
258
+ }>;
259
+ id: z.ZodUUID;
260
+ label: z.ZodString;
261
+ }, z.core.$strip>;
262
+ seq: z.ZodNumber;
263
+ progress: z.ZodNullable<z.ZodNumber>;
264
+ feedback: z.ZodNullable<z.ZodUnknown>;
265
+ }, z.core.$strip>>;
266
+ next_cursor: z.ZodNullable<z.ZodNumber>;
267
+ }, z.core.$strip>;
268
+ type JobRunListResponse = z.infer<typeof jobRunListResponse>;
119
269
 
120
270
  /**
121
271
  * The REST read of one datapoint. For bridge-captured data `timestamp_ms`
@@ -413,6 +563,29 @@ declare const clientIdentity: z.ZodObject<{
413
563
  type ClientIdentity = z.infer<typeof clientIdentity>;
414
564
 
415
565
 
566
+ /**
567
+ * One robot as `GET /api/client/robots` lists it — the REST twin of the MCP
568
+ * tool `robots_list`, and the one robot question no robot-scoped route can
569
+ * answer: which robots may I name at all.
570
+ *
571
+ * Deliberately not `robotListItem`: that one carries `exposes`, the per-kind
572
+ * counts a developer's list shows, which are a configuration fact rather than
573
+ * something an app user's role grants. What an app user is entitled to is the
574
+ * robot, its bridge state, and whether anything is published on it yet.
575
+ */
576
+ declare const clientRobotListItem: z.ZodObject<{
577
+ bridge_state: z.ZodObject<{
578
+ online: z.ZodBoolean;
579
+ latency_ms: z.ZodNullable<z.ZodNumber>;
580
+ }, z.core.$strip>;
581
+ published_version: z.ZodNullable<z.ZodNumber>;
582
+ id: z.ZodUUID;
583
+ name: z.ZodString;
584
+ created_at: z.ZodISODateTime;
585
+ }, z.core.$strip>;
586
+ type ClientRobotListItem = z.infer<typeof clientRobotListItem>;
587
+
588
+
416
589
  declare const asset: z.ZodObject<{
417
590
  id: z.ZodUUID;
418
591
  robot_id: z.ZodUUID;
@@ -555,10 +728,10 @@ type AssetListResponse = z.infer<typeof assetListResponse>;
555
728
  * console renders a third, and each is right in its own tests.
556
729
  *
557
730
  * `field` is the **flat key exactly as the caller sent it** — the same string
558
- * as the `parameterSpec.name` it violated. That is the entire justification
559
- * for the flat parameter form: a refusal has to name something the caller can
560
- * find in what they typed, and a console can attach the error to that one
561
- * input rather than to the form.
731
+ * as the `parameterSpec.name` it violated. That is why the parameter form
732
+ * stays flat: a refusal has to name something the caller can find in what
733
+ * they typed, and a console can attach the error to that one input rather
734
+ * than to the form.
562
735
  */
563
736
  declare const parameterViolation: z.ZodObject<{
564
737
  field: z.ZodString;
@@ -1867,6 +2040,30 @@ interface DatapointsApi {
1867
2040
  }): Promise<HistorySamplesResponse>;
1868
2041
  }
1869
2042
 
2043
+ /**
2044
+ * The filters `jobs.history` reads. Every field is optional; the wire names
2045
+ * are snake_case and this SDK spells them the way its other options are
2046
+ * spelt. `fromMs`/`toMs` are unix milliseconds, a half-open window
2047
+ * `[from, to)` so adjacent windows never both contain the run on their
2048
+ * boundary. `limit` above the platform's page cap is refused with
2049
+ * `validation_error`, not quietly reduced.
2050
+ */
2051
+ interface JobHistoryOptions {
2052
+ /** Only runs of this action or service. */
2053
+ slug?: string;
2054
+ /** Only runs in this state: `running`, `succeeded`, `failed`, `cancelled` or `lost`. */
2055
+ state?: JobState;
2056
+ /** Only `action` runs, or only `service` runs. */
2057
+ kind?: 'action' | 'service';
2058
+ /** How many runs to return, 1 to 200; absent means 100. Above the cap the platform refuses with `validation_error` rather than trimming. */
2059
+ limit?: number;
2060
+ /** The previous page's `next_cursor`. Send it back rather than computing one. */
2061
+ beforeSeq?: number;
2062
+ /** Only runs that started at or after this unix timestamp in milliseconds; with `toMs` the window is half-open, `[from, to)`. */
2063
+ fromMs?: number;
2064
+ /** Only runs that started before this unix timestamp in milliseconds. */
2065
+ toMs?: number;
2066
+ }
1870
2067
  /**
1871
2068
  * Robot-wide job reads, reachable as `client.jobs` — addressed by robot,
1872
2069
  * not slug, which `actions` and `services` cannot do.
@@ -1883,11 +2080,11 @@ interface JobsApi {
1883
2080
  * way an app developer reaches them.
1884
2081
  *
1885
2082
  * 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 `[]`.
2083
+ * read would answer. Not a history endpoint — that is `history` below.
2084
+ * Grant-filtered same as `cameras.list`/`datapoints` — an end user or
2085
+ * server key sees only jobs on slugs their role grants, a developer
2086
+ * session sees every job on the robot. Never empty-vs-missing ambiguity:
2087
+ * a robot doing nothing resolves `[]`.
1891
2088
  *
1892
2089
  * **Ordered newest first by `started_at`, with `job.seq` as the
1893
2090
  * tiebreaker** (`started_at` alone is not a total order — two jobs minted
@@ -1900,6 +2097,26 @@ interface JobsApi {
1900
2097
  * hour-long one was only just adopted.
1901
2098
  */
1902
2099
  list(robotId: string): Promise<Job[]>;
2100
+ /**
2101
+ * What *has* run on this robot: one row per run, newest first by the
2102
+ * durable `seq`, with its actor, its outcome and its `duration_ms`, kept
2103
+ * for 90 days. The durable counterpart of `list`.
2104
+ *
2105
+ * **Needs the `action_history` capability** on the caller's role, or it
2106
+ * rejects `capability_required`. An app user sees only runs on the slugs
2107
+ * their role grants; a developer session sees the whole robot.
2108
+ *
2109
+ * **Page until `next_cursor` is `null`, never until a page looks short.**
2110
+ * The cloud applies the role's grants to the page it already read, so a
2111
+ * page can come back thin — or empty — with a perfectly good non-null
2112
+ * cursor behind it. `runs.length === 0` is not an end-of-data signal.
2113
+ *
2114
+ * It lags realtime by a moment, deliberately: a run watched to completion
2115
+ * over `actions.subscribe` can still read `running` here for an instant.
2116
+ * Render the outcome from the realtime job you already have; use this for
2117
+ * what you were not watching.
2118
+ */
2119
+ history(robotId: string, options?: JobHistoryOptions): Promise<JobRunListResponse>;
1903
2120
  }
1904
2121
 
1905
2122
  /**
@@ -1928,6 +2145,57 @@ interface PublishersApi {
1928
2145
  publish(robotId: string, slug: string, message: Record<string, unknown>, options?: SendCommandOptions): Promise<void>;
1929
2146
  }
1930
2147
 
2148
+ /**
2149
+ * One row of a datasheet's `exposures`: a granted datapoint, action, service,
2150
+ * publisher or camera, with its `slug`, `kind`, `description` (or `null`),
2151
+ * a datapoint's `unit` and `decimals`, and for anything that takes
2152
+ * parameters the JSON Schema under `input_schema`. The wire shape is
2153
+ * contracts' `mcpExposure`; the alias exists so the reference can describe it.
2154
+ */
2155
+ type McpExposure = McpExposure$1;
2156
+ /**
2157
+ * The two role capabilities a datasheet names beyond slugs: `action_history`
2158
+ * (may `jobs.history` be read) and `assets` (may the URDF and meshes be read).
2159
+ * The wire shape is contracts' `mcpCapabilities`.
2160
+ */
2161
+ type McpCapabilities = McpCapabilities$1;
2162
+ /**
2163
+ * Discovery, reachable as `client.robots`: which robots may I name at all,
2164
+ * and what may I do on one. The two calls every app screen starts from;
2165
+ * every other namespace takes a `robotId` that came from here.
2166
+ *
2167
+ * The answers are the caller's role made visible — the same rows and the
2168
+ * same datasheet the MCP tools `robots_list` and `robot_describe` answer,
2169
+ * from the same code on the server. There is no client-side filtering to
2170
+ * do and nothing to cache: a role change shows at the next call.
2171
+ */
2172
+ interface RobotsApi {
2173
+ /**
2174
+ * The robots this caller reaches, in name order with the id as the tiebreak.
2175
+ *
2176
+ * An app user reaches the robots their app attaches on which their role
2177
+ * grants at least one slug or capability; a server key reaches every robot
2178
+ * its app attaches. A robot the role grants nothing on is absent rather
2179
+ * than listed empty — reach is a grant, not an attachment — so a new app
2180
+ * whose built-in roles grant nothing yet resolves `[]`, and that is the
2181
+ * console's Roles tab talking, not a broken login.
2182
+ */
2183
+ list(): Promise<ClientRobotListItem[]>;
2184
+ /**
2185
+ * Everything the caller's role lets them do on one robot: every granted
2186
+ * datapoint (with `unit` and `decimals`), action, service and publisher
2187
+ * (with the parameter JSON Schema under `input_schema`) and camera, plus
2188
+ * the two capabilities that gate whole features, `action_history` and
2189
+ * `assets`. A robot with nothing published resolves an empty `exposures`
2190
+ * list. One the caller does not reach rejects `not_found`, exactly as a
2191
+ * robot that does not exist — never `forbidden`, which would say it exists.
2192
+ *
2193
+ * The type is `McpRobotDatasheet` because the MCP server answered it first;
2194
+ * the prefix is history, not scope.
2195
+ */
2196
+ describe(robotId: string): Promise<McpRobotDatasheet>;
2197
+ }
2198
+
1931
2199
  /**
1932
2200
  * Request/response calls to a robot, reachable as `client.services`. A
1933
2201
  * service answers once and is done — one method, nothing to subscribe to.
@@ -2037,6 +2305,8 @@ interface FleetlessClient {
2037
2305
  readonly jobs: JobsApi;
2038
2306
  /** URDF and mesh reads — list/get/urdf, plus the `urdf-loader` mesh callback. */
2039
2307
  readonly assets: AssetsApi;
2308
+ /** Which robots this caller reaches, and what their role lets them do on each — the calls every screen starts from. */
2309
+ readonly robots: RobotsApi;
2040
2310
  /**
2041
2311
  * Closes the realtime channel and stops it from reconnecting. Safe with
2042
2312
  * no subscription ever made, and safe to call twice. A Node script (the
@@ -2060,4 +2330,4 @@ interface FleetlessClient {
2060
2330
  */
2061
2331
  declare function createClient(options: FleetlessClientOptions): FleetlessClient;
2062
2332
 
2063
- export { type AcceptInvitationOptions, type ActionsApi, type Asset, type AssetBytes, type AssetListResponse, type AssetsApi, type AuthApi, type BeginOidcLoginOptions, type BusyDetails, type CameraDescriptor, type CameraLiveSession, type CameraSnapshot, type CameraSnapshotMeta, type CamerasApi, type ClientIdentity, type ClientMcpInteraction, type ClientOidcErrorCode, type CompleteOidcLoginOptions, type CreateMeshLoaderOptions, type DatapointEvent, type DatapointSubscription, type DatapointSubscriptionHandlers, type DatapointValue, type DatapointsApi, type FleetlessClient, type FleetlessClientConfig, type FleetlessClientOptions, FleetlessError, type FleetlessErrorCode, type FleetlessErrorOptions, type HistoryAggregation, type HistoryBucketsResponse, type HistoryOptions, type HistorySamplesResponse, InMemoryTokenStore, type InvokeOptions, type Job, type JobEvent, type JobState, type JobSubscription, type JobSubscriptionHandlers, type JobsApi, type McpConsentGrant, type McpInteractionDecision, type MeshLoaderDelegate, type OidcLoginRequest, type ParameterInvalidDetails, type ParameterViolation, type PrepareUrdfSceneOptions, type ProviderButton, type PublishersApi, type RateLimitDetails, type RegisterOptions, SDK_ERROR_CODES, type SdkErrorCode, type SendCommandOptions, type ServicesApi, type StoredSession, type TokenStore, type UrdfCompleteness, type UrdfSceneManager, type UrdfSceneResources, createClient, parameterInvalidDetails };
2333
+ export { type AcceptInvitationOptions, type ActionsApi, type Asset, type AssetBytes, type AssetListResponse, type AssetsApi, type AuthApi, type BeginOidcLoginOptions, type BusyDetails, type CameraDescriptor, type CameraLiveSession, type CameraSnapshot, type CameraSnapshotMeta, type CamerasApi, type ClientIdentity, type ClientMcpInteraction, type ClientOidcErrorCode, type ClientRobotListItem, type CompleteOidcLoginOptions, type CreateMeshLoaderOptions, type DatapointEvent, type DatapointSubscription, type DatapointSubscriptionHandlers, type DatapointValue, type DatapointsApi, type FleetlessClient, type FleetlessClientConfig, type FleetlessClientOptions, FleetlessError, type FleetlessErrorCode, type FleetlessErrorOptions, type HistoryAggregation, type HistoryBucketsResponse, type HistoryOptions, type HistorySamplesResponse, InMemoryTokenStore, type InvokeOptions, type Job, type JobEvent, type JobHistoryOptions, type JobRun, type JobRunListResponse, type JobState, type JobSubscription, type JobSubscriptionHandlers, type JobsApi, type McpCapabilities, type McpConsentGrant, type McpExposure, type McpInteractionDecision, type McpRobotDatasheet, type MeshLoaderDelegate, type OidcLoginRequest, type ParameterInvalidDetails, type ParameterViolation, type PrepareUrdfSceneOptions, type ProviderButton, type PublishersApi, type RateLimitDetails, type RegisterOptions, type RobotsApi, SDK_ERROR_CODES, type SdkErrorCode, type SendCommandOptions, type ServicesApi, type StoredSession, type TokenStore, type UrdfCompleteness, type UrdfSceneManager, type UrdfSceneResources, createClient, parameterInvalidDetails };