@fleetless/sdk 4.0.0 → 4.2.0-next.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.js CHANGED
@@ -410,7 +410,7 @@ function createAssetsApi(http) {
410
410
  };
411
411
  }
412
412
 
413
- // node_modules/.pnpm/@fleetless+contracts@2.0.0/node_modules/@fleetless/contracts/dist/common.js
413
+ // node_modules/.pnpm/@fleetless+contracts@5.1.0-next.1/node_modules/@fleetless/contracts/dist/common.js
414
414
  import { z } from "zod";
415
415
  var SLUG_RULE = "A name is lower-case: it starts with a letter, continues with letters and digits, and joins further words with a single underscore \u2014 `battery_voltage`. Capitals, dashes, dots, spaces, a leading digit and a doubled or trailing underscore are all refused.";
416
416
  var slug = z.string().min(2).max(63).regex(/^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/, SLUG_RULE);
@@ -441,7 +441,7 @@ var applyError = z.object({
441
441
  details: z.record(z.string(), z.unknown()).optional()
442
442
  });
443
443
 
444
- // node_modules/.pnpm/@fleetless+contracts@2.0.0/node_modules/@fleetless/contracts/dist/mcp.js
444
+ // node_modules/.pnpm/@fleetless+contracts@5.1.0-next.1/node_modules/@fleetless/contracts/dist/mcp.js
445
445
  import { z as z2 } from "zod";
446
446
  function mcpAppEndpointPath(appIdentifier2) {
447
447
  return `/mcp/${appIdentifier2}`;
@@ -490,10 +490,10 @@ var mcpRolePreviewResponse = z2.object({
490
490
  });
491
491
  var MCP_ASSET_LINK_TTL_MS = 15 * 60 * 1e3;
492
492
 
493
- // node_modules/.pnpm/@fleetless+contracts@2.0.0/node_modules/@fleetless/contracts/dist/protocol.js
493
+ // node_modules/.pnpm/@fleetless+contracts@5.1.0-next.1/node_modules/@fleetless/contracts/dist/protocol.js
494
494
  import { z as z8 } from "zod";
495
495
 
496
- // node_modules/.pnpm/@fleetless+contracts@2.0.0/node_modules/@fleetless/contracts/dist/assets.js
496
+ // node_modules/.pnpm/@fleetless+contracts@5.1.0-next.1/node_modules/@fleetless/contracts/dist/assets.js
497
497
  import { z as z3 } from "zod";
498
498
  var assetKind = z3.enum(["urdf", "mesh", "texture"]);
499
499
  var asset = z3.object({
@@ -813,10 +813,10 @@ var assetSyncBusyDetails = z3.object({
813
813
  started_at_ms: z3.number().int().nonnegative()
814
814
  });
815
815
 
816
- // node_modules/.pnpm/@fleetless+contracts@2.0.0/node_modules/@fleetless/contracts/dist/config.js
816
+ // node_modules/.pnpm/@fleetless+contracts@5.1.0-next.1/node_modules/@fleetless/contracts/dist/config.js
817
817
  import { z as z5 } from "zod";
818
818
 
819
- // node_modules/.pnpm/@fleetless+contracts@2.0.0/node_modules/@fleetless/contracts/dist/alerts.js
819
+ // node_modules/.pnpm/@fleetless+contracts@5.1.0-next.1/node_modules/@fleetless/contracts/dist/alerts.js
820
820
  import { z as z4 } from "zod";
821
821
  var alertRowCondition = z4.discriminatedUnion("kind", [
822
822
  z4.strictObject({
@@ -886,7 +886,7 @@ var putDatapointDisplayRequest = z4.object({
886
886
  y_max: z4.number().finite().nullable()
887
887
  }).strict();
888
888
 
889
- // node_modules/.pnpm/@fleetless+contracts@2.0.0/node_modules/@fleetless/contracts/dist/config.js
889
+ // node_modules/.pnpm/@fleetless+contracts@5.1.0-next.1/node_modules/@fleetless/contracts/dist/config.js
890
890
  var RTSP_URL_RULE = "The URL has to begin with `rtsp://` or `rtsps://` \u2014 `rtsp://cam-1.plant.local/stream1`. No other scheme is accepted: the bridge opens this with a library that would equally honour `file:`.";
891
891
  var MJPEG_URL_RULE = "The URL has to begin with `http://` or `https://` \u2014 `http://cam-1.plant.local/video.mjpg`. No other scheme is accepted: the bridge opens this with a library that would equally serve `file:`.";
892
892
  var DEVICE_PATH_RULE = "A capture device is a path under `/dev/`, and the character straight after it is a letter or a digit \u2014 `/dev/video0`, or a stable `/dev/v4l/by-id/...` symlink. Nothing outside `/dev/` is accepted: the string reaches OpenCV, which would as happily open an ordinary file.";
@@ -1978,7 +1978,7 @@ var configState = z5.object({
1978
1978
  applied_errors: z5.array(applyError).nullable()
1979
1979
  });
1980
1980
 
1981
- // node_modules/.pnpm/@fleetless+contracts@2.0.0/node_modules/@fleetless/contracts/dist/introspection.js
1981
+ // node_modules/.pnpm/@fleetless+contracts@5.1.0-next.1/node_modules/@fleetless/contracts/dist/introspection.js
1982
1982
  import { z as z6 } from "zod";
1983
1983
  var rosGraphEntry = z6.object({
1984
1984
  name: rosName,
@@ -2017,9 +2017,11 @@ var typeDefinition = z6.discriminatedUnion("kind", [
2017
2017
  })
2018
2018
  ]);
2019
2019
 
2020
- // node_modules/.pnpm/@fleetless+contracts@2.0.0/node_modules/@fleetless/contracts/dist/jobs.js
2020
+ // node_modules/.pnpm/@fleetless+contracts@5.1.0-next.1/node_modules/@fleetless/contracts/dist/jobs.js
2021
2021
  import { z as z7 } from "zod";
2022
- var jobState = z7.enum(["running", "succeeded", "failed", "cancelled", "lost"]);
2022
+ var jobState = z7.enum(["running", "unknown", "succeeded", "failed", "cancelled", "lost"]);
2023
+ var reportedJobState = jobState.exclude(["unknown"]);
2024
+ var jobOrigin = z7.enum(["fleetless", "external"]);
2023
2025
  var job = z7.object({
2024
2026
  id: z7.uuid().meta({
2025
2027
  description: "The job's id, minted by the cloud when the invocation is accepted. Informative \u2014 state is observed by slug; a cancel names this id to stop one specific job rather than whatever is running."
@@ -2029,7 +2031,10 @@ var job = z7.object({
2029
2031
  description: "The action or service this job is running, as the published configuration exposes it. One slug carries one job at a time, so every observer of that slug sees the same one."
2030
2032
  }),
2031
2033
  state: jobState.meta({
2032
- description: "Where the job stands: `running`, `succeeded`, `failed`, `cancelled` or `lost`. `lost` is a real outcome \u2014 the bridge restarted mid-job and the result is gone \u2014 stated rather than left reading `running` by default."
2034
+ description: "Where the job stands: `running`, `unknown`, `succeeded`, `failed`, `cancelled` or `lost`. `unknown` is not an outcome \u2014 the robot went offline or silent and the cloud does not know yet; the slug stays occupied and the bridge's next statement resolves it, `error` naming why the cloud lost sight of it. `lost` is final: the bridge stated it does not know the job and nothing else runs on its action, or the action server vanished mid-goal."
2035
+ }),
2036
+ origin: jobOrigin.meta({
2037
+ description: "Who started this job. `fleetless` for everything minted by the cloud; `external` for a goal the bridge found active on a published action without having sent it \u2014 no parameters, no starter, never written to `job_runs`."
2033
2038
  }),
2034
2039
  started_at: z7.iso.datetime().meta({
2035
2040
  description: "When the cloud minted this job, as an ISO 8601 timestamp. For a job adopted from a reconnecting bridge, this is **adoption time**, not the real start \u2014 the cloud never minted it."
@@ -2048,7 +2053,7 @@ var job = z7.object({
2048
2053
  * exists for the same reason on the audit log.
2049
2054
  *
2050
2055
  * **Scoped honestly: per cloud process, per run.** Job state lives in memory
2051
- * — that is why `lost` exists at all — so this counter restarts when
2056
+ * — that is why `unknown` and `lost` exist at all — so this counter restarts when
2052
2057
  * the cloud does, alongside the jobs it orders. Sound, because it only ever
2053
2058
  * orders jobs that coexist in one registry — and stated, because a reader
2054
2059
  * who assumed `auditEvent.seq`'s durable semantics would be wrong.
@@ -2083,7 +2088,7 @@ var job = z7.object({
2083
2088
  description: "The structured payload belonging to `code`, for the codes that document one \u2014 `job_queue_full` carries its `limit` and its `queued` count here. Absent for a failure with nothing structured to add, which is most of them."
2084
2089
  })
2085
2090
  }).nullable().meta({
2086
- description: "Why the job failed: a human `message`, a `code` where one exists, and `details` for the codes that carry a documented payload. `null` unless `state` is `failed`."
2091
+ description: "Why the job failed, or why the cloud does not know how it stands: a human `message`, a `code` where one exists, and `details` for the codes that carry a documented payload. Set on `failed` and `lost`, and on `unknown` \u2014 where `code` is `bridge_disconnected` or `bridge_timeout`, the cloud's own reason for not knowing, cleared when the bridge reports the job running again."
2087
2092
  })
2088
2093
  });
2089
2094
  var jobEvent = z7.object({
@@ -2142,16 +2147,16 @@ var jobRun = z7.object({
2142
2147
  description: "Whether the slug was an `action` or a `service`."
2143
2148
  }),
2144
2149
  state: jobState.meta({
2145
- description: "How the run ended, or `running` while it is still going. `lost` means the bridge restarted mid-run and the outcome is unknowable rather than unknown."
2150
+ description: "How the run ended, or `running` while it is still going. `unknown` while the robot has not accounted for it \u2014 offline or silent \u2014 and updated once the bridge says how it stands. `lost` is final: the bridge did not know the run and nothing else ran on its action, so the outcome is unknowable rather than unknown."
2146
2151
  }),
2147
2152
  started_at: z7.iso.datetime().meta({
2148
2153
  description: "When the run started, as an ISO 8601 timestamp. Runs are listed and filtered by this instant."
2149
2154
  }),
2150
2155
  ended_at: z7.iso.datetime().nullable().meta({
2151
- description: "When the run finished, as an ISO 8601 timestamp. `null` while it is still `running` \u2014 a run has an end only once it has one."
2156
+ description: "When the run finished, as an ISO 8601 timestamp. `null` while it is still `running` or `unknown` \u2014 a run has an end only once it has one."
2152
2157
  }),
2153
2158
  duration_ms: z7.number().int().nonnegative().nullable().meta({
2154
- description: 'How long the run took, in milliseconds. `null` while it is still `running`, never `0` standing in for "nothing so far".'
2159
+ description: 'How long the run took, in milliseconds. `null` while it is still `running` or `unknown`, never `0` standing in for "nothing so far".'
2155
2160
  }),
2156
2161
  result: z7.unknown().nullable().meta({
2157
2162
  description: "What the action or service returned once it succeeded, shaped by ROS itself. `null` otherwise."
@@ -2201,7 +2206,7 @@ var jobRunQuery = z7.object({
2201
2206
  description: "Only runs of this action or service."
2202
2207
  }),
2203
2208
  state: jobState.optional().meta({
2204
- description: "Only runs in this state \u2014 `running`, `succeeded`, `failed`, `cancelled` or `lost`."
2209
+ description: "Only runs in this state \u2014 `running`, `unknown`, `succeeded`, `failed`, `cancelled` or `lost`."
2205
2210
  }),
2206
2211
  kind: jobRunKind.optional().meta({
2207
2212
  description: "Only `action` runs, or only `service` runs."
@@ -2235,14 +2240,14 @@ var jobRunSummary = z7.object({
2235
2240
  since_ms: z7.number().int().nonnegative()
2236
2241
  });
2237
2242
 
2238
- // node_modules/.pnpm/@fleetless+contracts@2.0.0/node_modules/@fleetless/contracts/dist/protocol.js
2243
+ // node_modules/.pnpm/@fleetless+contracts@5.1.0-next.1/node_modules/@fleetless/contracts/dist/protocol.js
2239
2244
  var DAY_MS = 24 * 60 * 60 * 1e3;
2240
2245
  var MAX_PATIENCE_MS = 12e4;
2241
2246
  var MIN_PATIENCE_MS = 1e3;
2242
2247
  var activeJob = z8.object({
2243
2248
  job_id: z8.uuid(),
2244
2249
  slug,
2245
- state: jobState
2250
+ state: reportedJobState
2246
2251
  });
2247
2252
  var bridgeHello = z8.object({
2248
2253
  type: z8.literal("hello"),
@@ -2253,16 +2258,14 @@ var bridgeHello = z8.object({
2253
2258
  * Every job this bridge still knows about, right now.
2254
2259
  *
2255
2260
  * A reconnect and a restart look **identical** on the wire — same token,
2256
- * same version, same frame — but must end differently: after a dropped
2257
- * connection the running jobs are still running, after a restart their
2258
- * results are gone forever. Enumerating what the bridge still has settles
2259
- * it without either side guessing: the cloud marks every job it believed
2260
- * running that is *not* named here as `lost`.
2261
- *
2262
- * Deliberately needs no persistence at the bridge: a live process lists its
2263
- * live jobs, a process that just started lists none — exactly the truth
2264
- * the cloud needs. A breadcrumb file would only add a window in which the
2265
- * crash beat the write.
2261
+ * same version, same frame — so the bridge enumerates what it still has:
2262
+ * its live jobs, and after a restart every job whose goal it recognised
2263
+ * again from its persisted job-to-goal mapping. A job the cloud holds
2264
+ * `running` or `unknown` that is *not* named here is "not known to the
2265
+ * bridge"; it becomes `lost` (`job_unknown_to_bridge`) only once the
2266
+ * bridge's goal reports show its action free of goals it cannot
2267
+ * attribute — one of those may be that very job — and at once for a
2268
+ * service job, which has no goals to look at.
2266
2269
  *
2267
2270
  * Defaulted, so a bridge that sends no such field still parses; no jobs
2268
2271
  * and no report both mean the same thing to the cloud: nothing to keep
@@ -2368,9 +2371,28 @@ var cloudInvoke = z8.object({
2368
2371
  });
2369
2372
  var cloudCancel = z8.object({
2370
2373
  type: z8.literal("cancel"),
2374
+ request_id: z8.string().min(1).max(64),
2371
2375
  slug,
2372
2376
  job_id: z8.uuid().nullable()
2373
2377
  });
2378
+ var CANCEL_RETURN_CODES = { none: 0, rejected: 1, unknown_goal_id: 2, goal_terminated: 3 };
2379
+ var cancelReturnCode = z8.number().int().min(0).max(3);
2380
+ var bridgeCancelResultEntry = z8.object({
2381
+ /** The job the goal belongs to — the bridge's own, or an external goal's derived id. */
2382
+ job_id: z8.uuid(),
2383
+ /** The ROS 2 goal id the cancel was sent for. */
2384
+ goal_id: z8.string().min(1),
2385
+ /** `null` when the action server did not answer the cancel request within the bridge's own bound. */
2386
+ return_code: cancelReturnCode.nullable()
2387
+ });
2388
+ var bridgeCancelResult = z8.object({
2389
+ type: z8.literal("cancel_result"),
2390
+ request_id: z8.string().min(1).max(64),
2391
+ slug,
2392
+ goals: z8.array(bridgeCancelResultEntry),
2393
+ /** Set when the bridge could not send the cancel at all (no such slug, a service, the server gone). */
2394
+ error: z8.object({ code: z8.string().min(1), message: z8.string().min(1) }).nullable()
2395
+ });
2374
2396
  var cloudPublish = z8.object({
2375
2397
  type: z8.literal("publish"),
2376
2398
  slug,
@@ -2390,7 +2412,11 @@ var bridgeJobUpdate = z8.object({
2390
2412
  type: z8.literal("job_update"),
2391
2413
  job_id: z8.uuid(),
2392
2414
  slug,
2393
- state: jobState,
2415
+ /** Never `unknown`: that is the cloud's word for not having heard. */
2416
+ state: reportedJobState,
2417
+ origin: jobOrigin,
2418
+ /** The ROS 2 goal id; `null` for a service job, which has no goal. */
2419
+ goal_id: z8.string().min(1).nullable(),
2394
2420
  feedback: z8.unknown().nullable(),
2395
2421
  progress: z8.number().min(0).max(1).nullable(),
2396
2422
  result: z8.unknown().nullable(),
@@ -2400,7 +2426,29 @@ var bridgeJobUpdate = z8.object({
2400
2426
  });
2401
2427
  var bridgeJobLost = z8.object({
2402
2428
  type: z8.literal("job_lost"),
2403
- job_ids: z8.array(z8.uuid())
2429
+ job_ids: z8.array(z8.uuid()),
2430
+ error: z8.object({ code: z8.string().min(1), message: z8.string().min(1) }).optional()
2431
+ });
2432
+ var cloudJobQuery = z8.object({
2433
+ type: z8.literal("job_query"),
2434
+ request_id: z8.string().min(1).max(64),
2435
+ job_ids: z8.array(z8.uuid()).min(1)
2436
+ });
2437
+ var bridgeJobStatusEntry = z8.object({
2438
+ job_id: z8.uuid(),
2439
+ /** Never `unknown` — the bridge only ever states a definite fact about a job it recognises. */
2440
+ state: reportedJobState,
2441
+ feedback: z8.unknown().nullable(),
2442
+ progress: z8.number().min(0).max(1).nullable(),
2443
+ result: z8.unknown().nullable(),
2444
+ /** Same shape as `job.error`, `details` included — see `jobs.ts`. */
2445
+ error: z8.object({ code: z8.string().min(1), message: z8.string().min(1), details: z8.unknown().optional() }).nullable()
2446
+ });
2447
+ var bridgeJobStatus = z8.object({
2448
+ type: z8.literal("job_status"),
2449
+ request_id: z8.string().min(1).max(64),
2450
+ jobs: z8.array(bridgeJobStatusEntry),
2451
+ unknown_job_ids: z8.array(z8.uuid())
2404
2452
  });
2405
2453
  var cloudIntrospectRequest = z8.object({
2406
2454
  type: z8.literal("introspect_request"),
@@ -2589,11 +2637,11 @@ var bridgeCameraState = z8.object({
2589
2637
  request_id: z8.string().min(1).max(64).nullable()
2590
2638
  });
2591
2639
 
2592
- // node_modules/.pnpm/@fleetless+contracts@2.0.0/node_modules/@fleetless/contracts/dist/config-issues.js
2640
+ // node_modules/.pnpm/@fleetless+contracts@5.1.0-next.1/node_modules/@fleetless/contracts/dist/config-issues.js
2593
2641
  var EXPOSURE_SECTIONS = ["datapoints", "actions", "services", "publishers", "cameras"];
2594
2642
  var EXPOSURE_SECTION_NAMES = new Set(EXPOSURE_SECTIONS);
2595
2643
 
2596
- // node_modules/.pnpm/@fleetless+contracts@2.0.0/node_modules/@fleetless/contracts/dist/rest.js
2644
+ // node_modules/.pnpm/@fleetless+contracts@5.1.0-next.1/node_modules/@fleetless/contracts/dist/rest.js
2597
2645
  import { z as z9 } from "zod";
2598
2646
  var robot = z9.object({
2599
2647
  id: z9.uuid().meta({
@@ -3358,13 +3406,13 @@ var slugUsageResponse = z9.object({
3358
3406
  alert_count: z9.number().int().nonnegative()
3359
3407
  });
3360
3408
 
3361
- // node_modules/.pnpm/@fleetless+contracts@2.0.0/node_modules/@fleetless/contracts/dist/realtime.js
3409
+ // node_modules/.pnpm/@fleetless+contracts@5.1.0-next.1/node_modules/@fleetless/contracts/dist/realtime.js
3362
3410
  import { z as z14 } from "zod";
3363
3411
 
3364
- // node_modules/.pnpm/@fleetless+contracts@2.0.0/node_modules/@fleetless/contracts/dist/client-auth.js
3412
+ // node_modules/.pnpm/@fleetless+contracts@5.1.0-next.1/node_modules/@fleetless/contracts/dist/client-auth.js
3365
3413
  import { z as z13 } from "zod";
3366
3414
 
3367
- // node_modules/.pnpm/@fleetless+contracts@2.0.0/node_modules/@fleetless/contracts/dist/apps.js
3415
+ // node_modules/.pnpm/@fleetless+contracts@5.1.0-next.1/node_modules/@fleetless/contracts/dist/apps.js
3368
3416
  import { z as z10 } from "zod";
3369
3417
  var appIdentifier = slug;
3370
3418
  var app = z10.object({
@@ -3424,6 +3472,26 @@ var appListResponse = z10.object({
3424
3472
  description: "Every app of the caller's organisation, oldest first by `created_at`. The org scope is the whole filter \u2014 there is no id to narrow by and nothing to refuse."
3425
3473
  })
3426
3474
  });
3475
+ var appDeletionSummary = z10.object({
3476
+ user_count: z10.number().int().nonnegative().meta({
3477
+ description: "App users deleted with the app. They are the developer's own customers, not Fleetless users, and exist in no other app."
3478
+ }),
3479
+ role_count: z10.number().int().nonnegative().meta({
3480
+ description: "Roles deleted with the app, each with its per-robot slug grants."
3481
+ }),
3482
+ server_key_count: z10.number().int().nonnegative().meta({
3483
+ description: "Server keys deleted with the app. A client still holding one is refused at its next request."
3484
+ }),
3485
+ invitation_count: z10.number().int().nonnegative().meta({
3486
+ description: "Outstanding invitations \u2014 unspent and unexpired \u2014 that will never be accepted."
3487
+ }),
3488
+ oidc_provider_count: z10.number().int().nonnegative().meta({
3489
+ description: "Identity providers configured for this app. The providers themselves are somebody else's; only this app's configuration of them goes."
3490
+ }),
3491
+ mail_template_count: z10.number().int().nonnegative().meta({
3492
+ description: "Custom mail templates, of at most three. A kind using the Fleetless default text is not counted \u2014 there is no row to lose."
3493
+ })
3494
+ });
3427
3495
  var createAppRequest = z10.object({
3428
3496
  name: z10.string().min(1).max(120),
3429
3497
  identifier: appIdentifier,
@@ -3546,10 +3614,10 @@ var rolePermissions = z10.object({
3546
3614
  })
3547
3615
  });
3548
3616
 
3549
- // node_modules/.pnpm/@fleetless+contracts@2.0.0/node_modules/@fleetless/contracts/dist/app-users.js
3617
+ // node_modules/.pnpm/@fleetless+contracts@5.1.0-next.1/node_modules/@fleetless/contracts/dist/app-users.js
3550
3618
  import { z as z12 } from "zod";
3551
3619
 
3552
- // node_modules/.pnpm/@fleetless+contracts@2.0.0/node_modules/@fleetless/contracts/dist/identity.js
3620
+ // node_modules/.pnpm/@fleetless+contracts@5.1.0-next.1/node_modules/@fleetless/contracts/dist/identity.js
3553
3621
  import { z as z11 } from "zod";
3554
3622
  var password = z11.string().min(12).max(256);
3555
3623
  var USER_DISPLAY_NAME_MAX = 120;
@@ -3711,7 +3779,7 @@ var authMeResponse = z11.object({ org, user: fleetlessUser });
3711
3779
  var patchOrgRequest = z11.object({ name: z11.string().min(1).max(120) }).strict();
3712
3780
  var patchAuthMeRequest = z11.object({ display_name: z11.string().min(1).max(USER_DISPLAY_NAME_MAX).nullable() }).strict();
3713
3781
 
3714
- // node_modules/.pnpm/@fleetless+contracts@2.0.0/node_modules/@fleetless/contracts/dist/app-users.js
3782
+ // node_modules/.pnpm/@fleetless+contracts@5.1.0-next.1/node_modules/@fleetless/contracts/dist/app-users.js
3715
3783
  var APP_USER_DISPLAY_NAME_MAX = 120;
3716
3784
  var providerSlug = z12.string().max(40).regex(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/, "must be lowercase and hyphen-separated, starting with a letter");
3717
3785
  var appUserStatus = z12.enum(["pending_verification", "active", "blocked"]);
@@ -3930,7 +3998,9 @@ var appAuthConfig = z12.object({
3930
3998
  }),
3931
3999
  updated_at: z12.iso.datetime().meta({ description: "When the configuration was last written, as an ISO 8601 timestamp." })
3932
4000
  });
3933
- var putAppAuthConfigRequest = appAuthConfig.omit({ oidc_callback_url: true, updated_at: true }).strict();
4001
+ var putAppAuthRegistrationRequest = appAuthConfig.pick({ self_registration: true, allowed_domains: true, allowed_origins: true }).strict();
4002
+ var putAppAuthUrlsRequest = appAuthConfig.pick({ invite_url: true, verify_url: true, reset_url: true }).strict();
4003
+ var putAppAuthMcpRequest = appAuthConfig.pick({ mcp_enabled: true, mcp_login_url: true }).strict();
3934
4004
  var mailTemplateKind = z12.enum(["invite", "verify", "reset"]);
3935
4005
  var appMailTemplate = z12.object({
3936
4006
  kind: mailTemplateKind.meta({ description: "Which of the three mails this template replaces." }),
@@ -3962,7 +4032,7 @@ var mailOutcome = z12.object({
3962
4032
  })
3963
4033
  });
3964
4034
 
3965
- // node_modules/.pnpm/@fleetless+contracts@2.0.0/node_modules/@fleetless/contracts/dist/client-auth.js
4035
+ // node_modules/.pnpm/@fleetless+contracts@5.1.0-next.1/node_modules/@fleetless/contracts/dist/client-auth.js
3966
4036
  var clientLoginRequest = z13.object({
3967
4037
  app_identifier: appIdentifier.meta({
3968
4038
  description: "The app being logged in to: its globally unique, lowercase, underscore-separated identifier, chosen by the developer at creation. There is no organisation context at login, so this is what decides which app the credentials are checked for."
@@ -4151,7 +4221,7 @@ var clientIdentity = z13.object({
4151
4221
  })
4152
4222
  });
4153
4223
 
4154
- // node_modules/.pnpm/@fleetless+contracts@2.0.0/node_modules/@fleetless/contracts/dist/realtime.js
4224
+ // node_modules/.pnpm/@fleetless+contracts@5.1.0-next.1/node_modules/@fleetless/contracts/dist/realtime.js
4155
4225
  var clientAuth = z14.object({
4156
4226
  type: z14.literal("auth"),
4157
4227
  token: z14.string().min(1)
@@ -4429,7 +4499,7 @@ var orgEventDropped = z14.object({
4429
4499
  dropped: z14.number().int().positive()
4430
4500
  }).strict();
4431
4501
 
4432
- // node_modules/.pnpm/@fleetless+contracts@2.0.0/node_modules/@fleetless/contracts/dist/client-robots.js
4502
+ // node_modules/.pnpm/@fleetless+contracts@5.1.0-next.1/node_modules/@fleetless/contracts/dist/client-robots.js
4433
4503
  import { z as z15 } from "zod";
4434
4504
  var clientRobotListItem = z15.object({
4435
4505
  ...robot.shape,
@@ -4446,7 +4516,7 @@ var clientRobotListResponse = z15.object({
4446
4516
  })
4447
4517
  });
4448
4518
 
4449
- // node_modules/.pnpm/@fleetless+contracts@2.0.0/node_modules/@fleetless/contracts/dist/audit.js
4519
+ // node_modules/.pnpm/@fleetless+contracts@5.1.0-next.1/node_modules/@fleetless/contracts/dist/audit.js
4450
4520
  import { z as z16 } from "zod";
4451
4521
  var auditActor = z16.object({
4452
4522
  kind: z16.enum(["developer", "end_user", "app_user", "server_key", "bridge"]),
@@ -4576,7 +4646,7 @@ var auditListResponse = z16.object({
4576
4646
  next_cursor: z16.number().int().positive().nullable()
4577
4647
  });
4578
4648
 
4579
- // node_modules/.pnpm/@fleetless+contracts@2.0.0/node_modules/@fleetless/contracts/dist/errors.js
4649
+ // node_modules/.pnpm/@fleetless+contracts@5.1.0-next.1/node_modules/@fleetless/contracts/dist/errors.js
4580
4650
  import { z as z17 } from "zod";
4581
4651
  var apiError = z17.object({
4582
4652
  code: z17.string().min(1),
@@ -4592,8 +4662,11 @@ var parameterViolation = z17.object({
4592
4662
  var parameterInvalidDetails = z17.object({
4593
4663
  violations: z17.array(parameterViolation).min(1)
4594
4664
  });
4665
+ var cancelRejectedDetails = z17.object({
4666
+ goals: z17.array(bridgeCancelResultEntry).min(1)
4667
+ });
4595
4668
 
4596
- // node_modules/.pnpm/@fleetless+contracts@2.0.0/node_modules/@fleetless/contracts/dist/oauth.js
4669
+ // node_modules/.pnpm/@fleetless+contracts@5.1.0-next.1/node_modules/@fleetless/contracts/dist/oauth.js
4597
4670
  import { z as z18 } from "zod";
4598
4671
  var oauthErrorCode = z18.enum([
4599
4672
  "invalid_request",
@@ -4833,7 +4906,7 @@ var oauthAuthorizeQuery = z18.object({
4833
4906
  description: "The authorization request an MCP client sends, per RFC 6749 \xA74.1.1 with mandatory PKCE. The handler reads it parameter by parameter rather than through one parse, because the answers differ: `client_id` and `redirect_uri` are refused flat, with no redirect, since until both are confirmed there is no trusted target to bounce a browser to, and everything after them is reported to the client's own callback as query parameters."
4834
4907
  });
4835
4908
 
4836
- // node_modules/.pnpm/@fleetless+contracts@2.0.0/node_modules/@fleetless/contracts/dist/routes.js
4909
+ // node_modules/.pnpm/@fleetless+contracts@5.1.0-next.1/node_modules/@fleetless/contracts/dist/routes.js
4837
4910
  var MCP_APP = MCP_APP_PATHS(":appIdentifier");
4838
4911
  var APP_IDENTIFIER = {
4839
4912
  name: "appIdentifier",
@@ -5203,6 +5276,42 @@ var ROUTES = [
5203
5276
  transport: "http",
5204
5277
  notes: "A `default_role_id` naming a role of another app is refused: it is the one cross-app authorization check this shape can carry. Changing the robot set closes every live subscription the app's users hold, since a grant may no longer name a reachable robot."
5205
5278
  },
5279
+ {
5280
+ method: "GET",
5281
+ path: "/api/apps/:id/deletion-preview",
5282
+ section: "apps",
5283
+ summary: "Reports what deleting the app would destroy, without destroying it.",
5284
+ audience: "developer",
5285
+ auth: "developer",
5286
+ rateLimited: false,
5287
+ ownerTier: false,
5288
+ status: 200,
5289
+ params: [{ name: "id", description: "The app's uuid, as returned by `POST /api/apps` or listed by `GET /api/apps`." }],
5290
+ query: null,
5291
+ request: null,
5292
+ response: appDeletionSummary,
5293
+ errors: [...DEVELOPER_GUARD, "invalid_uuid", "not_found"],
5294
+ transport: "http",
5295
+ notes: "The same shape the delete's own audit event carries, computed by the same function on purpose: the confirmation dialog and the eventual receipt agree by construction, and any difference between them is real drift rather than two estimates that quietly disagree. \n\n**No `force` parameter, unlike the robot pair this is modelled on.** A robot's open live session is a single nameable state whose interruption is its own hazard, which is why that route makes the caller pass `force` explicitly. An app has no equivalent state to force past, and inventing one would be a guess wearing a guard's clothes \u2014 this preview is the guard."
5296
+ },
5297
+ {
5298
+ method: "DELETE",
5299
+ path: "/api/apps/:id",
5300
+ section: "apps",
5301
+ summary: "Deletes an app and everything it produced.",
5302
+ audience: "developer",
5303
+ auth: "developer",
5304
+ rateLimited: false,
5305
+ ownerTier: true,
5306
+ status: 204,
5307
+ params: [{ name: "id", description: "The app's uuid, as returned by `POST /api/apps` or listed by `GET /api/apps`." }],
5308
+ query: null,
5309
+ request: null,
5310
+ response: null,
5311
+ errors: [...DEVELOPER_GUARD, "tier_required", "invalid_uuid", "not_found"],
5312
+ transport: "http",
5313
+ notes: "Owner tier, and the gate runs **after** the org-scoped lookup: a developer-tier admin therefore sees the same `404` a stranger would for an app outside their org, rather than a tier refusal that confirms the id exists. A full cascade \u2014 its users, roles, server keys, invitations, OIDC provider configuration and mail templates all go, recorded once as `app.deleted` carrying an `appDeletionSummary`. Its robots are untouched: they belong to the org, not to the app. \n\n**No `force` parameter** \u2014 see `GET /api/apps/:id/deletion-preview`."
5314
+ },
5206
5315
  {
5207
5316
  method: "POST",
5208
5317
  path: "/api/apps/:id/roles",
@@ -5709,13 +5818,31 @@ var ROUTES = [
5709
5818
  response: appAuthConfig,
5710
5819
  errors: [...DEVELOPER_GUARD, "invalid_uuid", "not_found"],
5711
5820
  transport: "http",
5712
- notes: "One row per app, created with the app and never absent \u2014 an app that has configured nothing reads back the defaults rather than a `404`. `oidc_callback_url` is in the answer and not in the request: it is minted by the cloud from its own public base URL, is the same for every app and every provider, and is the value a developer registers at their identity provider."
5821
+ notes: "One row per app, created with the app and never absent \u2014 an app that has configured nothing reads back the defaults rather than a `404`. `oidc_callback_url` is in the answer and not in the request: it is minted by the cloud from its own public base URL, is the same for every app and every provider, and is the value a developer registers at their identity provider. It stays read-only on every slice write below for a second reason: a writable callback URL would let a caller point the return leg of an OIDC sign-in, which carries an authorization code, at a host they own. `updated_at` is read-only for a duller one: the server stamps it on every write, and a client-supplied value would be a lie about when the row last changed."
5713
5822
  },
5714
5823
  {
5715
5824
  method: "PUT",
5716
- path: "/api/apps/:id/auth-config",
5825
+ path: "/api/apps/:id/auth-config/registration",
5826
+ section: "apps",
5827
+ summary: "Replaces who may self-register, and from where.",
5828
+ audience: "developer",
5829
+ auth: "developer",
5830
+ rateLimited: false,
5831
+ ownerTier: false,
5832
+ status: 200,
5833
+ params: [{ name: "id", description: "The app's uuid, as returned by `POST /api/apps` or listed by `GET /api/apps`." }],
5834
+ query: null,
5835
+ request: putAppAuthRegistrationRequest,
5836
+ response: appAuthConfig,
5837
+ errors: [...DEVELOPER_GUARD, "invalid_uuid", "validation_error", "not_found"],
5838
+ transport: "http",
5839
+ notes: "**A replace, not a merge, and `.strict()`**: `self_registration`, `allowed_domains` and `allowed_origins` all arrive or the write is refused, so a client built against an older shape cannot silently clear a setting it does not know about. `oidc_callback_url` and `updated_at` are the server's, refused in this body as in every slice's \u2014 see `GET`'s notes for why. \n\n`400 validation_error` is where the two field rules land: an entry in `allowed_domains` must be lowercase, since a capitalised one can never match a lowercased address, and an entry in `allowed_origins` must be a bare scheme-host-port with no path, since a browser sends nothing longer in its `Origin` header. Each refuses at configuration time rather than failing silently later. \n\nThe merge is server-side against the stored row, so this write never disturbs the urls or mcp slice."
5840
+ },
5841
+ {
5842
+ method: "PUT",
5843
+ path: "/api/apps/:id/auth-config/urls",
5717
5844
  section: "apps",
5718
- summary: "Replaces the app's auth settings in one write.",
5845
+ summary: "Replaces the three pages Fleetless's mails point at.",
5719
5846
  audience: "developer",
5720
5847
  auth: "developer",
5721
5848
  rateLimited: false,
@@ -5723,11 +5850,29 @@ var ROUTES = [
5723
5850
  status: 200,
5724
5851
  params: [{ name: "id", description: "The app's uuid, as returned by `POST /api/apps` or listed by `GET /api/apps`." }],
5725
5852
  query: null,
5726
- request: putAppAuthConfigRequest,
5853
+ request: putAppAuthUrlsRequest,
5727
5854
  response: appAuthConfig,
5728
5855
  errors: [...DEVELOPER_GUARD, "invalid_uuid", "validation_error", "not_found"],
5729
5856
  transport: "http",
5730
- notes: "**A replace, not a merge, and `.strict()`**: every field arrives or the write is refused, so a client built against an older shape cannot silently clear a setting it does not know about. `oidc_callback_url` and `updated_at` are refused in the body \u2014 a writable callback URL would let a caller point the return leg of an OIDC sign-in, which carries an authorization code, at a host they own. \n\n`400 validation_error` is where the three field rules land: a URL template must be https (or `http` on `localhost`) and carry its placeholder exactly once, an origin must be a bare scheme-host-port with no path, and a domain must be lowercase. Each refuses at configuration time because each would otherwise fail silently later \u2014 a second placeholder leaves one occurrence literal in a mailed link, an origin with a path can never equal a browser's `Origin` header, and a capitalised domain can never match a lowercased address."
5857
+ notes: "**A replace, not a merge, and `.strict()`**: `invite_url`, `verify_url` and `reset_url` all arrive or the write is refused, so a client built against an older shape cannot silently clear a setting it does not know about. `oidc_callback_url` and `updated_at` are the server's, refused in this body as in every slice's \u2014 see `GET`'s notes for why. \n\n`400 validation_error` is where the field rule lands: a URL template must be https (or `http` on `localhost`) and carry its placeholder exactly once \u2014 a second occurrence leaves one literal in a mailed link, refused here rather than failing silently once the mail is sent. \n\nThe merge is server-side against the stored row, so this write never disturbs the registration or mcp slice."
5858
+ },
5859
+ {
5860
+ method: "PUT",
5861
+ path: "/api/apps/:id/auth-config/mcp",
5862
+ section: "apps",
5863
+ summary: "Replaces the MCP switch and its login URL together.",
5864
+ audience: "developer",
5865
+ auth: "developer",
5866
+ rateLimited: false,
5867
+ ownerTier: false,
5868
+ status: 200,
5869
+ params: [{ name: "id", description: "The app's uuid, as returned by `POST /api/apps` or listed by `GET /api/apps`." }],
5870
+ query: null,
5871
+ request: putAppAuthMcpRequest,
5872
+ response: appAuthConfig,
5873
+ errors: [...DEVELOPER_GUARD, "invalid_uuid", "validation_error", "not_found"],
5874
+ transport: "http",
5875
+ notes: "**A replace, not a merge, and `.strict()`**: `mcp_enabled` and `mcp_login_url` both arrive or the write is refused, so a client built against an older shape cannot silently clear a setting it does not know about. `oidc_callback_url` and `updated_at` are the server's, refused in this body as in every slice's \u2014 see `GET`'s notes for why. \n\n`mcp_login_url` answers to the same rule as the `urls` slice's three templates \u2014 https (or `http` on `localhost`), its placeholder exactly once \u2014 refused as `400 validation_error` rather than left to fail mid-OAuth, in a client's browser where no console screen is watching. \n\nThe merge is server-side against the stored row, so this write never disturbs the registration or urls slice."
5731
5876
  },
5732
5877
  {
5733
5878
  method: "GET",
@@ -7520,7 +7665,7 @@ var ROUTES = [
7520
7665
  "internal_error"
7521
7666
  ],
7522
7667
  transport: "http",
7523
- notes: "**One route for both kinds**, because a path segment naming the kind would demand a fact a role grant does not carry. An action answers `202` with an `invokeResponse` the moment the job exists; a service answers `200` with a `serviceCallResponse` once the result is in \u2014 two shapes, carried by one union (`invokeOrServiceResponse`) and told apart by whether `kind` or a bare `result` arrives. Parameters are checked **before** anything about the world (offline, busy): the same request must get the same verdict whether or not the robot happens to be reachable, or a developer testing against an offline robot never learns their parameters were wrong. A service the robot reports as failed answers `502` carrying **the job's own error code**, which is an open set and not one of the codes above."
7668
+ notes: "**One route for both kinds**, because a path segment naming the kind would demand a fact a role grant does not carry. An action answers `202` with an `invokeResponse` the moment the job exists; a service answers `200` with a `serviceCallResponse` once the result is in \u2014 two shapes, carried by one union (`invokeOrServiceResponse`) and told apart by whether `kind` or a bare `result` arrives. Parameters are checked **before** anything about the world (offline, busy): the same request must get the same verdict whether or not the robot happens to be reachable, or a developer testing against an offline robot never learns their parameters were wrong. A slug is `409 busy` while it holds a `running` job, an `unknown` one the robot has not accounted for yet, or an `external` goal someone else started; the refusal's `details.running` names that job, `state` and `origin` included. A service the robot reports as failed answers `502` carrying **the job's own error code**, which is an open set and not one of the codes above."
7524
7669
  },
7525
7670
  {
7526
7671
  method: "GET",
@@ -7561,9 +7706,21 @@ var ROUTES = [
7561
7706
  request: cancelRequest,
7562
7707
  requestOptional: true,
7563
7708
  response: jobResponse,
7564
- errors: [...CLIENT_GUARD, "invalid_uuid", "not_found", "validation_error", "not_cancellable", "robot_offline"],
7709
+ errors: [
7710
+ ...CLIENT_GUARD,
7711
+ "invalid_uuid",
7712
+ "not_found",
7713
+ "validation_error",
7714
+ "not_cancellable",
7715
+ "robot_offline",
7716
+ "cancel_rejected",
7717
+ "bridge_timeout",
7718
+ "unknown_slug",
7719
+ "action_server_lost",
7720
+ "internal_error"
7721
+ ],
7565
7722
  transport: "http",
7566
- notes: 'The body is optional: a bodyless `POST` was every caller\'s shape before `job_id` existed, and absent or `job_id: null` both mean "cancel whatever is running". A named `job_id` that is **not** what is running cancels nothing and answers `404` \u2014 the caller named an id and thereby ruled the other one out. A service is `422 not_cancellable`: a service call has no goal to cancel. Nothing running is a `200` with `job: null`.'
7723
+ notes: "The body is optional: a bodyless `POST` was every caller's shape before `job_id` existed, and absent or `job_id: null` both mean \"cancel whatever is running\". A named `job_id` that is **not** what is running cancels nothing and answers `404` \u2014 the caller named an id and thereby ruled the other one out. An `external` job is cancelled the same way, through its goal id. Cancelling an `unknown` job also cancels every external goal on its action, since one of them may be that job. A service is `422 not_cancellable`: a service call has no goal to cancel. Nothing running is a `200` with `job: null`. The answer waits for the bridge's `cancel_result`: a `200` means the action server accepted the cancel request, not that the goal has ended \u2014 the job's end arrives as its own update. Any goal answered `ERROR_REJECTED` makes it `409 cancel_rejected`, with every goal and its `return_code` in `details.goals`; no answer within `JOB_HEARTBEAT_TIMEOUT_MS` is `504 bridge_timeout`; a cancel the bridge could not send at all is `502` carrying the bridge's own code (`unknown_slug`, `action_server_lost`, `internal_error`)."
7567
7724
  },
7568
7725
  {
7569
7726
  method: "POST",
@@ -9168,9 +9325,11 @@ function deriveRealtimeUrl(apiUrl) {
9168
9325
  return url.toString();
9169
9326
  }
9170
9327
  export {
9328
+ CANCEL_RETURN_CODES,
9171
9329
  FleetlessError,
9172
9330
  InMemoryTokenStore,
9173
9331
  SDK_ERROR_CODES,
9332
+ cancelRejectedDetails,
9174
9333
  createClient,
9175
9334
  parameterInvalidDetails
9176
9335
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fleetless/sdk",
3
- "version": "4.0.0",
3
+ "version": "4.2.0-next.1",
4
4
  "description": "The official TypeScript SDK for Fleetless client apps — a ROS 2 robot as a REST and realtime API, cameras, jobs, and the app's own user accounts, federated sign-in and MCP consent.",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -76,7 +76,7 @@
76
76
  "zod": "^4.0.0"
77
77
  },
78
78
  "devDependencies": {
79
- "@fleetless/contracts": "2.0.0",
79
+ "@fleetless/contracts": "5.1.0-next.1",
80
80
  "@types/node": "^22.20.1",
81
81
  "tsup": "^8.3.0",
82
82
  "typedoc": "0.28.20",