@fleetless/sdk 4.6.1 → 5.1.0

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
@@ -3,8 +3,8 @@ import { z } from 'zod';
3
3
 
4
4
 
5
5
  /**
6
- * One exposure of a robot, as `robots.describe` and the console's per-role
7
- * preview list it. Every exposure the role grants is listed —
6
+ * One exposure of a robot, as `robots.describe` and `GET /api/robots/:id/datasheet`
7
+ * list it. Every exposure the caller's role grants is listed —
8
8
  * a missing `description` is shown as `null`, never used to hide the entry.
9
9
  *
10
10
  * `input_schema` is a JSON Schema document generated from an action's,
@@ -27,9 +27,9 @@ declare const mcpExposure: z.ZodObject<{
27
27
  input_schema: z.ZodNullable<z.ZodUnknown>;
28
28
  }, z.core.$strip>;
29
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. */
30
+ /** The two capabilities of a robot as a whole that a tool can need beyond a slug: its past jobs and its asset files. */
31
31
  declare const mcpCapabilities: z.ZodObject<{
32
- action_history: z.ZodBoolean;
32
+ job_history: z.ZodBoolean;
33
33
  assets: z.ZodBoolean;
34
34
  }, z.core.$strip>;
35
35
  type McpCapabilities$1 = z.infer<typeof mcpCapabilities>;
@@ -43,7 +43,7 @@ declare const mcpRobotDatasheet: z.ZodObject<{
43
43
  robot_id: z.ZodUUID;
44
44
  robot_name: z.ZodString;
45
45
  capabilities: z.ZodObject<{
46
- action_history: z.ZodBoolean;
46
+ job_history: z.ZodBoolean;
47
47
  assets: z.ZodBoolean;
48
48
  }, z.core.$strip>;
49
49
  exposures: z.ZodArray<z.ZodObject<{
@@ -464,6 +464,70 @@ declare const datapointEvent: z.ZodObject<{
464
464
  timestamp_ms: z.ZodNumber;
465
465
  }, z.core.$strip>;
466
466
  type DatapointEvent = z.infer<typeof datapointEvent>;
467
+ /**
468
+ * One change to a record the subscriber can see. `record` is the whole record,
469
+ * up to 1 MB, in the shape the REST routes answer.
470
+ *
471
+ * **A client that cannot keep up is disconnected, not skipped.** A socket whose
472
+ * send buffer holds more than 8 MiB, or that has more than 2,000 collection
473
+ * changes waiting to be delivered (a bulk import into a big collection does
474
+ * that), is closed with code 1013 ("try again later"). The client reconnects,
475
+ * subscribes again and lists again.
476
+ */
477
+ declare const collectionEvent: z.ZodObject<{
478
+ type: z.ZodLiteral<"collection_event">;
479
+ request_id: z.ZodString;
480
+ event: z.ZodEnum<{
481
+ deleted: "deleted";
482
+ created: "created";
483
+ updated: "updated";
484
+ removed: "removed";
485
+ entered: "entered";
486
+ }>;
487
+ id: z.ZodUUID;
488
+ record: z.ZodOptional<z.ZodObject<{
489
+ id: z.ZodUUID;
490
+ robot_id: z.ZodNullable<z.ZodUUID>;
491
+ created_at: z.ZodISODateTime;
492
+ created_by: z.ZodObject<{
493
+ kind: z.ZodEnum<{
494
+ developer: "developer";
495
+ fleetless: "fleetless";
496
+ server_key: "server_key";
497
+ app_user: "app_user";
498
+ }>;
499
+ id: z.ZodUUID;
500
+ label: z.ZodString;
501
+ }, z.core.$strip>;
502
+ updated_at: z.ZodISODateTime;
503
+ updated_by: z.ZodObject<{
504
+ kind: z.ZodEnum<{
505
+ developer: "developer";
506
+ fleetless: "fleetless";
507
+ server_key: "server_key";
508
+ app_user: "app_user";
509
+ }>;
510
+ id: z.ZodUUID;
511
+ label: z.ZodString;
512
+ }, z.core.$strip>;
513
+ revision: z.ZodNumber;
514
+ display: z.ZodString;
515
+ missing_required: z.ZodOptional<z.ZodArray<z.ZodString>>;
516
+ values: z.ZodRecord<z.ZodString, z.ZodUnknown>;
517
+ deleted_at: z.ZodOptional<z.ZodISODateTime>;
518
+ deleted_by: z.ZodOptional<z.ZodObject<{
519
+ kind: z.ZodEnum<{
520
+ developer: "developer";
521
+ fleetless: "fleetless";
522
+ server_key: "server_key";
523
+ app_user: "app_user";
524
+ }>;
525
+ id: z.ZodUUID;
526
+ label: z.ZodString;
527
+ }, z.core.$strip>>;
528
+ }, z.core.$strip>>;
529
+ }, z.core.$strict>;
530
+ type CollectionEvent$1 = z.infer<typeof collectionEvent>;
467
531
 
468
532
 
469
533
  /**
@@ -608,7 +672,7 @@ type McpConsentGrant = z.infer<typeof mcpConsentGrant>;
608
672
  * client API and appears in the audit as the developer, and the console's own
609
673
  * live views subscribe on `/realtime` as one. A developer is **org-scoped, not
610
674
  * app-scoped** — they own the configuration of every robot in their org — so
611
- * `app_id` and `role_id` are null for them, and roles do not filter what they
675
+ * `app_id` and `role` are null for them, and roles do not filter what they
612
676
  * see. `kind` states this explicitly rather than leaving it to be inferred from
613
677
  * which id happens to be set.
614
678
  *
@@ -635,7 +699,10 @@ declare const clientIdentity: z.ZodObject<{
635
699
  app_user_id: z.ZodNullable<z.ZodUUID>;
636
700
  server_key_id: z.ZodNullable<z.ZodUUID>;
637
701
  app_id: z.ZodNullable<z.ZodUUID>;
638
- role_id: z.ZodNullable<z.ZodUUID>;
702
+ role: z.ZodNullable<z.ZodObject<{
703
+ key: z.ZodString;
704
+ name: z.ZodString;
705
+ }, z.core.$strip>>;
639
706
  email: z.ZodNullable<z.ZodEmail>;
640
707
  two_factor_enabled: z.ZodNullable<z.ZodBoolean>;
641
708
  }, z.core.$strip>;
@@ -649,7 +716,7 @@ type ClientIdentity = z.infer<typeof clientIdentity>;
649
716
  *
650
717
  * Deliberately not `robotListItem`: that one carries `exposes`, the per-kind
651
718
  * counts a developer's list shows, which are a configuration fact rather than
652
- * something an app user's role grants. What an app user is entitled to is the
719
+ * something an app user's role decides. What an app user is entitled to is the
653
720
  * robot, its bridge state, and whether anything is published on it yet.
654
721
  */
655
722
  declare const clientRobotListItem: z.ZodObject<{
@@ -737,6 +804,10 @@ declare const assetSyncStatus: z.ZodObject<{
737
804
  used_bytes: z.ZodNumber;
738
805
  size_bytes: z.ZodNumber;
739
806
  }, z.core.$strip>>>;
807
+ file_limit: z.ZodOptional<z.ZodNullable<z.ZodObject<{
808
+ max_bytes: z.ZodNumber;
809
+ size_bytes: z.ZodNullable<z.ZodNumber>;
810
+ }, z.core.$strip>>>;
740
811
  }, z.core.$strip>>;
741
812
  reason: z.ZodNullable<z.ZodString>;
742
813
  stored: z.ZodNullable<z.ZodNumber>;
@@ -782,6 +853,10 @@ declare const assetListResponse: z.ZodObject<{
782
853
  used_bytes: z.ZodNumber;
783
854
  size_bytes: z.ZodNumber;
784
855
  }, z.core.$strip>>>;
856
+ file_limit: z.ZodOptional<z.ZodNullable<z.ZodObject<{
857
+ max_bytes: z.ZodNumber;
858
+ size_bytes: z.ZodNullable<z.ZodNumber>;
859
+ }, z.core.$strip>>>;
785
860
  }, z.core.$strip>>;
786
861
  reason: z.ZodNullable<z.ZodString>;
787
862
  stored: z.ZodNullable<z.ZodNumber>;
@@ -862,14 +937,492 @@ declare const cancelRejectedDetails: z.ZodObject<{
862
937
  }, z.core.$strip>>;
863
938
  }, z.core.$strip>;
864
939
  type CancelRejectedDetails = z.infer<typeof cancelRejectedDetails>;
940
+ /**
941
+ * The `details` of a `409 record_referenced` refusal. Counts only: the caller
942
+ * may not be allowed to read the records that point here, so neither their
943
+ * ids nor their values are told. Nor is the key of a collection the caller may
944
+ * not read, for the reason `collection_not_found` is answered for one: the list
945
+ * names only collections the caller may read, and it is empty when every
946
+ * collection that points here is one they may not.
947
+ */
948
+ declare const recordReferencedDetails: z.ZodObject<{
949
+ references: z.ZodArray<z.ZodObject<{
950
+ collection: z.ZodString;
951
+ count: z.ZodNumber;
952
+ }, z.core.$strict>>;
953
+ }, z.core.$strict>;
954
+ type RecordReferencedDetails = z.infer<typeof recordReferencedDetails>;
955
+ /** The `details` of a `409 record_changed` refusal: the revision the record is at now, for the caller to read it again. */
956
+ declare const recordChangedDetails: z.ZodObject<{
957
+ revision: z.ZodNumber;
958
+ }, z.core.$strict>;
959
+ type RecordChangedDetails = z.infer<typeof recordChangedDetails>;
960
+ /** The `details` of a `400 reference_invalid` refusal: which reference field, and why its value was refused. */
961
+ declare const referenceInvalidDetails: z.ZodObject<{
962
+ field: z.ZodString;
963
+ reason: z.ZodEnum<{
964
+ missing: "missing";
965
+ other_robot: "other_robot";
966
+ not_readable: "not_readable";
967
+ }>;
968
+ }, z.core.$strict>;
969
+ type ReferenceInvalidDetails = z.infer<typeof referenceInvalidDetails>;
970
+ /** The `details` of a `400 required_missing` refusal: every required field the write would leave empty. */
971
+ declare const requiredMissingDetails: z.ZodObject<{
972
+ fields: z.ZodArray<z.ZodString>;
973
+ }, z.core.$strict>;
974
+ type RequiredMissingDetails = z.infer<typeof requiredMissingDetails>;
865
975
  /**
866
976
  * The codes in use today. The wire deliberately allows any string — this
867
977
  * list is the shared vocabulary, not a closed set, so a new refusal never
868
978
  * needs a contracts release before it can be reported honestly.
869
979
  */
870
- declare const ERROR_CODES: readonly ["not_found", "validation_error", "bad_request", "unknown_datapoint", "invalid_token", "protocol_mismatch", "bridge_too_old", "invalid_frame", "duplicate_slug", "reserved_slug", "unknown_slug", "unknown_field_path", "unknown_type", "unknown_topic", "invalid_rate", "invalid_range", "config_conflict", "no_data", "robot_offline", "bridge_timeout", "unauthorized", "forbidden", "invalid_credentials", "token_expired", "token_revoked", "email_taken", "identifier_taken", "weak_password", "account_blocked", "busy", "parameter_invalid", "cancel_rejected", "job_lost", "operator_verified_stopped", "job_unknown_to_bridge", "action_server_lost", "action_failed", "goal_rejected", "goal_send_failed", "result_failed", "goal_uncontrollable", "bridge_disconnected", "config_changed", "publisher_busy", "unknown_command", "not_subscribable", "camera_offline", "no_snapshot_yet", "live_unavailable", "wrong_kind", "not_recorded", "not_aggregatable", "quota_exceeded", "credential_in_use", "goal_timeout", "robot_in_use", "robot_deletion_partial", "job_queue_full", "invalid_uuid", "rate_limited", "tier_required", "token_spent", "service_timeout", "asset_missing", "dynamic_registration_disabled", "client_limit_reached", "idp_unavailable", "mcp_disabled", "tool_not_available", "capability_required", "last_owner", "role_name_taken", "role_in_use", "last_role", "target_state_conflict", "job_state_conflict", "signup_closed", "draft_not_a_document", "internal_error", "not_cancellable", "unsupported_media_type", "wrong_browser", "invalid_yaml", "unstorable_yaml", "registration_closed", "domain_not_allowed", "email_unverified", "origin_not_allowed", "template_invalid", "provider_disabled", "provider_misconfigured", "invalid_redirect_uri", "interaction_expired", "invalid_code", "method_not_allowed", "plan_limit", "plan_required", "org_locked", "file_too_large", "billing_unavailable", "payment_provider_unavailable", "history_migrating", "billing_documents_unavailable", "support_read_only", "support_forbidden"];
980
+ declare const ERROR_CODES: readonly ["not_found", "validation_error", "bad_request", "unknown_datapoint", "invalid_token", "protocol_mismatch", "bridge_too_old", "invalid_frame", "duplicate_slug", "reserved_slug", "unknown_slug", "unknown_field_path", "unknown_type", "unknown_topic", "invalid_rate", "invalid_range", "config_conflict", "no_data", "robot_offline", "bridge_timeout", "unauthorized", "forbidden", "invalid_credentials", "token_expired", "token_revoked", "email_taken", "identifier_taken", "weak_password", "account_blocked", "busy", "parameter_invalid", "cancel_rejected", "job_lost", "operator_verified_stopped", "job_unknown_to_bridge", "action_server_lost", "action_failed", "goal_rejected", "goal_send_failed", "result_failed", "goal_uncontrollable", "bridge_disconnected", "config_changed", "publisher_busy", "unknown_command", "not_subscribable", "camera_offline", "no_snapshot_yet", "live_unavailable", "wrong_kind", "not_recorded", "not_aggregatable", "quota_exceeded", "credential_in_use", "goal_timeout", "robot_in_use", "robot_deletion_partial", "job_queue_full", "invalid_uuid", "rate_limited", "tier_required", "token_spent", "service_timeout", "asset_missing", "dynamic_registration_disabled", "client_limit_reached", "idp_unavailable", "mcp_disabled", "tool_not_available", "capability_required", "last_owner", "role_cycle", "role_key_taken", "confirmation_required", "target_state_conflict", "job_state_conflict", "signup_closed", "draft_not_a_document", "internal_error", "not_cancellable", "unsupported_media_type", "wrong_browser", "invalid_yaml", "unstorable_yaml", "registration_closed", "domain_not_allowed", "email_unverified", "origin_not_allowed", "template_invalid", "provider_disabled", "provider_misconfigured", "invalid_redirect_uri", "interaction_expired", "invalid_code", "method_not_allowed", "plan_limit", "plan_required", "org_locked", "file_too_large", "billing_unavailable", "legal_offer_unavailable", "payment_provider_unavailable", "history_migrating", "billing_documents_unavailable", "support_read_only", "support_forbidden", "record_referenced", "record_changed", "collection_not_found", "collection_removed", "reference_invalid", "required_missing", "robot_not_attached"];
871
981
  type ErrorCode = (typeof ERROR_CODES)[number];
872
982
 
983
+
984
+ /**
985
+ * How a collection relates to robots. A property of the collection and not a
986
+ * field type, so a record's robot can neither be left out of a robot-bound
987
+ * collection nor changed afterwards.
988
+ */
989
+ declare const collectionBinding: z.ZodEnum<{
990
+ global: "global";
991
+ per_robot: "per_robot";
992
+ one_per_robot: "one_per_robot";
993
+ }>;
994
+ type CollectionBinding = z.infer<typeof collectionBinding>;
995
+ /**
996
+ * One field definition, discriminated on `type`. A union and not one object
997
+ * with every option optional: `max_length` on a `number` would otherwise parse
998
+ * and mean nothing.
999
+ */
1000
+ declare const collectionField: z.ZodDiscriminatedUnion<[z.ZodObject<{
1001
+ max_length: z.ZodOptional<z.ZodNumber>;
1002
+ pattern: z.ZodOptional<z.ZodString>;
1003
+ searchable: z.ZodOptional<z.ZodBoolean>;
1004
+ label: z.ZodOptional<z.ZodString>;
1005
+ description: z.ZodOptional<z.ZodString>;
1006
+ required: z.ZodOptional<z.ZodBoolean>;
1007
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1008
+ default: z.ZodOptional<z.ZodUnknown>;
1009
+ type: z.ZodLiteral<"text">;
1010
+ }, z.core.$strict>, z.ZodObject<{
1011
+ max_length: z.ZodOptional<z.ZodNumber>;
1012
+ searchable: z.ZodOptional<z.ZodBoolean>;
1013
+ label: z.ZodOptional<z.ZodString>;
1014
+ description: z.ZodOptional<z.ZodString>;
1015
+ required: z.ZodOptional<z.ZodBoolean>;
1016
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1017
+ default: z.ZodOptional<z.ZodUnknown>;
1018
+ type: z.ZodLiteral<"long_text">;
1019
+ }, z.core.$strict>, z.ZodObject<{
1020
+ integer: z.ZodOptional<z.ZodBoolean>;
1021
+ min: z.ZodOptional<z.ZodNumber>;
1022
+ max: z.ZodOptional<z.ZodNumber>;
1023
+ unit: z.ZodOptional<z.ZodString>;
1024
+ label: z.ZodOptional<z.ZodString>;
1025
+ description: z.ZodOptional<z.ZodString>;
1026
+ required: z.ZodOptional<z.ZodBoolean>;
1027
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1028
+ default: z.ZodOptional<z.ZodUnknown>;
1029
+ type: z.ZodLiteral<"number">;
1030
+ }, z.core.$strict>, z.ZodObject<{
1031
+ label: z.ZodOptional<z.ZodString>;
1032
+ description: z.ZodOptional<z.ZodString>;
1033
+ required: z.ZodOptional<z.ZodBoolean>;
1034
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1035
+ default: z.ZodOptional<z.ZodUnknown>;
1036
+ type: z.ZodLiteral<"boolean">;
1037
+ }, z.core.$strict>, z.ZodObject<{
1038
+ options: z.ZodArray<z.ZodObject<{
1039
+ value: z.ZodString;
1040
+ label: z.ZodOptional<z.ZodString>;
1041
+ }, z.core.$strict>>;
1042
+ multiple: z.ZodOptional<z.ZodBoolean>;
1043
+ searchable: z.ZodOptional<z.ZodBoolean>;
1044
+ label: z.ZodOptional<z.ZodString>;
1045
+ description: z.ZodOptional<z.ZodString>;
1046
+ required: z.ZodOptional<z.ZodBoolean>;
1047
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1048
+ default: z.ZodOptional<z.ZodUnknown>;
1049
+ type: z.ZodLiteral<"select">;
1050
+ }, z.core.$strict>, z.ZodObject<{
1051
+ label: z.ZodOptional<z.ZodString>;
1052
+ description: z.ZodOptional<z.ZodString>;
1053
+ required: z.ZodOptional<z.ZodBoolean>;
1054
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1055
+ default: z.ZodOptional<z.ZodUnknown>;
1056
+ type: z.ZodLiteral<"date">;
1057
+ }, z.core.$strict>, z.ZodObject<{
1058
+ label: z.ZodOptional<z.ZodString>;
1059
+ description: z.ZodOptional<z.ZodString>;
1060
+ required: z.ZodOptional<z.ZodBoolean>;
1061
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1062
+ default: z.ZodOptional<z.ZodUnknown>;
1063
+ type: z.ZodLiteral<"datetime">;
1064
+ }, z.core.$strict>, z.ZodObject<{
1065
+ schema: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
1066
+ label: z.ZodOptional<z.ZodString>;
1067
+ description: z.ZodOptional<z.ZodString>;
1068
+ required: z.ZodOptional<z.ZodBoolean>;
1069
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1070
+ default: z.ZodOptional<z.ZodUnknown>;
1071
+ type: z.ZodLiteral<"json">;
1072
+ }, z.core.$strict>, z.ZodObject<{
1073
+ to: z.ZodString;
1074
+ on_delete: z.ZodOptional<z.ZodEnum<{
1075
+ prevent: "prevent";
1076
+ clear: "clear";
1077
+ }>>;
1078
+ label: z.ZodOptional<z.ZodString>;
1079
+ description: z.ZodOptional<z.ZodString>;
1080
+ required: z.ZodOptional<z.ZodBoolean>;
1081
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1082
+ default: z.ZodOptional<z.ZodUnknown>;
1083
+ type: z.ZodLiteral<"reference">;
1084
+ }, z.core.$strict>], "type">;
1085
+ type CollectionField = z.infer<typeof collectionField>;
1086
+
1087
+
1088
+ /**
1089
+ * Who made a change. `fleetless` is the platform itself (a schema change, an
1090
+ * automatic record) and always carries the nil id. `label` is worked out when
1091
+ * the record is read, from the person's display name, so a user who has since
1092
+ * been deleted reads `Deleted user` instead of leaving the record with a
1093
+ * dangling id. An email address is the fallback only for a reader who may see
1094
+ * it: a developer or a server key reading a person without a name, and an app
1095
+ * user reading their own label.
1096
+ */
1097
+ declare const collectionActor: z.ZodObject<{
1098
+ kind: z.ZodEnum<{
1099
+ developer: "developer";
1100
+ fleetless: "fleetless";
1101
+ server_key: "server_key";
1102
+ app_user: "app_user";
1103
+ }>;
1104
+ id: z.ZodUUID;
1105
+ label: z.ZodString;
1106
+ }, z.core.$strip>;
1107
+ type CollectionActor = z.infer<typeof collectionActor>;
1108
+ /**
1109
+ * One record. `display` is the collection's display template rendered for this
1110
+ * record, so a list can name its rows without knowing the template.
1111
+ */
1112
+ declare const collectionRecord: z.ZodObject<{
1113
+ id: z.ZodUUID;
1114
+ robot_id: z.ZodNullable<z.ZodUUID>;
1115
+ created_at: z.ZodISODateTime;
1116
+ created_by: z.ZodObject<{
1117
+ kind: z.ZodEnum<{
1118
+ developer: "developer";
1119
+ fleetless: "fleetless";
1120
+ server_key: "server_key";
1121
+ app_user: "app_user";
1122
+ }>;
1123
+ id: z.ZodUUID;
1124
+ label: z.ZodString;
1125
+ }, z.core.$strip>;
1126
+ updated_at: z.ZodISODateTime;
1127
+ updated_by: z.ZodObject<{
1128
+ kind: z.ZodEnum<{
1129
+ developer: "developer";
1130
+ fleetless: "fleetless";
1131
+ server_key: "server_key";
1132
+ app_user: "app_user";
1133
+ }>;
1134
+ id: z.ZodUUID;
1135
+ label: z.ZodString;
1136
+ }, z.core.$strip>;
1137
+ revision: z.ZodNumber;
1138
+ display: z.ZodString;
1139
+ missing_required: z.ZodOptional<z.ZodArray<z.ZodString>>;
1140
+ values: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1141
+ deleted_at: z.ZodOptional<z.ZodISODateTime>;
1142
+ deleted_by: z.ZodOptional<z.ZodObject<{
1143
+ kind: z.ZodEnum<{
1144
+ developer: "developer";
1145
+ fleetless: "fleetless";
1146
+ server_key: "server_key";
1147
+ app_user: "app_user";
1148
+ }>;
1149
+ id: z.ZodUUID;
1150
+ label: z.ZodString;
1151
+ }, z.core.$strip>>;
1152
+ }, z.core.$strip>;
1153
+ type CollectionRecord$1 = z.infer<typeof collectionRecord>;
1154
+ /**
1155
+ * One entry of a record's history. `changes` holds each changed field with its
1156
+ * old and new value, `null` standing for no value. A `delete` revision carries
1157
+ * the whole record so that a deleted record can be seen and brought back.
1158
+ */
1159
+ declare const collectionRevision: z.ZodObject<{
1160
+ seq: z.ZodNumber;
1161
+ op: z.ZodEnum<{
1162
+ create: "create";
1163
+ update: "update";
1164
+ delete: "delete";
1165
+ restore: "restore";
1166
+ }>;
1167
+ at: z.ZodISODateTime;
1168
+ actor: z.ZodObject<{
1169
+ kind: z.ZodEnum<{
1170
+ developer: "developer";
1171
+ fleetless: "fleetless";
1172
+ server_key: "server_key";
1173
+ app_user: "app_user";
1174
+ }>;
1175
+ id: z.ZodUUID;
1176
+ label: z.ZodString;
1177
+ }, z.core.$strip>;
1178
+ reason: z.ZodNullable<z.ZodString>;
1179
+ revision: z.ZodNumber;
1180
+ changes: z.ZodRecord<z.ZodString, z.ZodObject<{
1181
+ old: z.ZodUnknown;
1182
+ new: z.ZodUnknown;
1183
+ }, z.core.$strip>>;
1184
+ record: z.ZodNullable<z.ZodObject<{
1185
+ id: z.ZodUUID;
1186
+ robot_id: z.ZodNullable<z.ZodUUID>;
1187
+ created_at: z.ZodISODateTime;
1188
+ created_by: z.ZodObject<{
1189
+ kind: z.ZodEnum<{
1190
+ developer: "developer";
1191
+ fleetless: "fleetless";
1192
+ server_key: "server_key";
1193
+ app_user: "app_user";
1194
+ }>;
1195
+ id: z.ZodUUID;
1196
+ label: z.ZodString;
1197
+ }, z.core.$strip>;
1198
+ updated_at: z.ZodISODateTime;
1199
+ updated_by: z.ZodObject<{
1200
+ kind: z.ZodEnum<{
1201
+ developer: "developer";
1202
+ fleetless: "fleetless";
1203
+ server_key: "server_key";
1204
+ app_user: "app_user";
1205
+ }>;
1206
+ id: z.ZodUUID;
1207
+ label: z.ZodString;
1208
+ }, z.core.$strip>;
1209
+ revision: z.ZodNumber;
1210
+ display: z.ZodString;
1211
+ missing_required: z.ZodOptional<z.ZodArray<z.ZodString>>;
1212
+ values: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1213
+ deleted_at: z.ZodOptional<z.ZodISODateTime>;
1214
+ deleted_by: z.ZodOptional<z.ZodObject<{
1215
+ kind: z.ZodEnum<{
1216
+ developer: "developer";
1217
+ fleetless: "fleetless";
1218
+ server_key: "server_key";
1219
+ app_user: "app_user";
1220
+ }>;
1221
+ id: z.ZodUUID;
1222
+ label: z.ZodString;
1223
+ }, z.core.$strip>>;
1224
+ }, z.core.$strip>>;
1225
+ }, z.core.$strip>;
1226
+ type CollectionRevision$1 = z.infer<typeof collectionRevision>;
1227
+ declare const collectionRecordHistoryResponse: z.ZodObject<{
1228
+ revisions: z.ZodArray<z.ZodObject<{
1229
+ seq: z.ZodNumber;
1230
+ op: z.ZodEnum<{
1231
+ create: "create";
1232
+ update: "update";
1233
+ delete: "delete";
1234
+ restore: "restore";
1235
+ }>;
1236
+ at: z.ZodISODateTime;
1237
+ actor: z.ZodObject<{
1238
+ kind: z.ZodEnum<{
1239
+ developer: "developer";
1240
+ fleetless: "fleetless";
1241
+ server_key: "server_key";
1242
+ app_user: "app_user";
1243
+ }>;
1244
+ id: z.ZodUUID;
1245
+ label: z.ZodString;
1246
+ }, z.core.$strip>;
1247
+ reason: z.ZodNullable<z.ZodString>;
1248
+ revision: z.ZodNumber;
1249
+ changes: z.ZodRecord<z.ZodString, z.ZodObject<{
1250
+ old: z.ZodUnknown;
1251
+ new: z.ZodUnknown;
1252
+ }, z.core.$strip>>;
1253
+ record: z.ZodNullable<z.ZodObject<{
1254
+ id: z.ZodUUID;
1255
+ robot_id: z.ZodNullable<z.ZodUUID>;
1256
+ created_at: z.ZodISODateTime;
1257
+ created_by: z.ZodObject<{
1258
+ kind: z.ZodEnum<{
1259
+ developer: "developer";
1260
+ fleetless: "fleetless";
1261
+ server_key: "server_key";
1262
+ app_user: "app_user";
1263
+ }>;
1264
+ id: z.ZodUUID;
1265
+ label: z.ZodString;
1266
+ }, z.core.$strip>;
1267
+ updated_at: z.ZodISODateTime;
1268
+ updated_by: z.ZodObject<{
1269
+ kind: z.ZodEnum<{
1270
+ developer: "developer";
1271
+ fleetless: "fleetless";
1272
+ server_key: "server_key";
1273
+ app_user: "app_user";
1274
+ }>;
1275
+ id: z.ZodUUID;
1276
+ label: z.ZodString;
1277
+ }, z.core.$strip>;
1278
+ revision: z.ZodNumber;
1279
+ display: z.ZodString;
1280
+ missing_required: z.ZodOptional<z.ZodArray<z.ZodString>>;
1281
+ values: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1282
+ deleted_at: z.ZodOptional<z.ZodISODateTime>;
1283
+ deleted_by: z.ZodOptional<z.ZodObject<{
1284
+ kind: z.ZodEnum<{
1285
+ developer: "developer";
1286
+ fleetless: "fleetless";
1287
+ server_key: "server_key";
1288
+ app_user: "app_user";
1289
+ }>;
1290
+ id: z.ZodUUID;
1291
+ label: z.ZodString;
1292
+ }, z.core.$strip>>;
1293
+ }, z.core.$strip>>;
1294
+ }, z.core.$strip>>;
1295
+ next_before_seq: z.ZodNullable<z.ZodNumber>;
1296
+ purged: z.ZodNullable<z.ZodObject<{
1297
+ before: z.ZodISODateTime;
1298
+ by: z.ZodObject<{
1299
+ kind: z.ZodEnum<{
1300
+ developer: "developer";
1301
+ fleetless: "fleetless";
1302
+ server_key: "server_key";
1303
+ app_user: "app_user";
1304
+ }>;
1305
+ id: z.ZodUUID;
1306
+ label: z.ZodString;
1307
+ }, z.core.$strip>;
1308
+ at: z.ZodISODateTime;
1309
+ }, z.core.$strip>>;
1310
+ }, z.core.$strip>;
1311
+ type CollectionRecordHistoryResponse = z.infer<typeof collectionRecordHistoryResponse>;
1312
+ /** The collections the caller can read, with their fields: what a client needs to build a form. */
1313
+ declare const collectionDefinitionsResponse: z.ZodObject<{
1314
+ version: z.ZodNullable<z.ZodNumber>;
1315
+ collections: z.ZodArray<z.ZodObject<{
1316
+ key: z.ZodString;
1317
+ label: z.ZodString;
1318
+ description: z.ZodString;
1319
+ binding: z.ZodEnum<{
1320
+ global: "global";
1321
+ per_robot: "per_robot";
1322
+ one_per_robot: "one_per_robot";
1323
+ }>;
1324
+ display: z.ZodString;
1325
+ fields: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
1326
+ max_length: z.ZodOptional<z.ZodNumber>;
1327
+ pattern: z.ZodOptional<z.ZodString>;
1328
+ searchable: z.ZodOptional<z.ZodBoolean>;
1329
+ label: z.ZodOptional<z.ZodString>;
1330
+ description: z.ZodOptional<z.ZodString>;
1331
+ required: z.ZodOptional<z.ZodBoolean>;
1332
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1333
+ default: z.ZodOptional<z.ZodUnknown>;
1334
+ type: z.ZodLiteral<"text">;
1335
+ }, z.core.$strict>, z.ZodObject<{
1336
+ max_length: z.ZodOptional<z.ZodNumber>;
1337
+ searchable: z.ZodOptional<z.ZodBoolean>;
1338
+ label: z.ZodOptional<z.ZodString>;
1339
+ description: z.ZodOptional<z.ZodString>;
1340
+ required: z.ZodOptional<z.ZodBoolean>;
1341
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1342
+ default: z.ZodOptional<z.ZodUnknown>;
1343
+ type: z.ZodLiteral<"long_text">;
1344
+ }, z.core.$strict>, z.ZodObject<{
1345
+ integer: z.ZodOptional<z.ZodBoolean>;
1346
+ min: z.ZodOptional<z.ZodNumber>;
1347
+ max: z.ZodOptional<z.ZodNumber>;
1348
+ unit: z.ZodOptional<z.ZodString>;
1349
+ label: z.ZodOptional<z.ZodString>;
1350
+ description: z.ZodOptional<z.ZodString>;
1351
+ required: z.ZodOptional<z.ZodBoolean>;
1352
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1353
+ default: z.ZodOptional<z.ZodUnknown>;
1354
+ type: z.ZodLiteral<"number">;
1355
+ }, z.core.$strict>, z.ZodObject<{
1356
+ label: z.ZodOptional<z.ZodString>;
1357
+ description: z.ZodOptional<z.ZodString>;
1358
+ required: z.ZodOptional<z.ZodBoolean>;
1359
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1360
+ default: z.ZodOptional<z.ZodUnknown>;
1361
+ type: z.ZodLiteral<"boolean">;
1362
+ }, z.core.$strict>, z.ZodObject<{
1363
+ options: z.ZodArray<z.ZodObject<{
1364
+ value: z.ZodString;
1365
+ label: z.ZodOptional<z.ZodString>;
1366
+ }, z.core.$strict>>;
1367
+ multiple: z.ZodOptional<z.ZodBoolean>;
1368
+ searchable: z.ZodOptional<z.ZodBoolean>;
1369
+ label: z.ZodOptional<z.ZodString>;
1370
+ description: z.ZodOptional<z.ZodString>;
1371
+ required: z.ZodOptional<z.ZodBoolean>;
1372
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1373
+ default: z.ZodOptional<z.ZodUnknown>;
1374
+ type: z.ZodLiteral<"select">;
1375
+ }, z.core.$strict>, z.ZodObject<{
1376
+ label: z.ZodOptional<z.ZodString>;
1377
+ description: z.ZodOptional<z.ZodString>;
1378
+ required: z.ZodOptional<z.ZodBoolean>;
1379
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1380
+ default: z.ZodOptional<z.ZodUnknown>;
1381
+ type: z.ZodLiteral<"date">;
1382
+ }, z.core.$strict>, z.ZodObject<{
1383
+ label: z.ZodOptional<z.ZodString>;
1384
+ description: z.ZodOptional<z.ZodString>;
1385
+ required: z.ZodOptional<z.ZodBoolean>;
1386
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1387
+ default: z.ZodOptional<z.ZodUnknown>;
1388
+ type: z.ZodLiteral<"datetime">;
1389
+ }, z.core.$strict>, z.ZodObject<{
1390
+ schema: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
1391
+ label: z.ZodOptional<z.ZodString>;
1392
+ description: z.ZodOptional<z.ZodString>;
1393
+ required: z.ZodOptional<z.ZodBoolean>;
1394
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1395
+ default: z.ZodOptional<z.ZodUnknown>;
1396
+ type: z.ZodLiteral<"json">;
1397
+ }, z.core.$strict>, z.ZodObject<{
1398
+ to: z.ZodString;
1399
+ on_delete: z.ZodOptional<z.ZodEnum<{
1400
+ prevent: "prevent";
1401
+ clear: "clear";
1402
+ }>>;
1403
+ label: z.ZodOptional<z.ZodString>;
1404
+ description: z.ZodOptional<z.ZodString>;
1405
+ required: z.ZodOptional<z.ZodBoolean>;
1406
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1407
+ default: z.ZodOptional<z.ZodUnknown>;
1408
+ type: z.ZodLiteral<"reference">;
1409
+ }, z.core.$strict>], "type">>;
1410
+ can: z.ZodObject<{
1411
+ read: z.ZodBoolean;
1412
+ create: z.ZodBoolean;
1413
+ update: z.ZodUnion<readonly [z.ZodEnum<{
1414
+ all: "all";
1415
+ own: "own";
1416
+ }>, z.ZodLiteral<false>]>;
1417
+ delete: z.ZodUnion<readonly [z.ZodEnum<{
1418
+ all: "all";
1419
+ own: "own";
1420
+ }>, z.ZodLiteral<false>]>;
1421
+ }, z.core.$strip>;
1422
+ }, z.core.$strip>>;
1423
+ }, z.core.$strip>;
1424
+ type CollectionDefinitionsResponse = z.infer<typeof collectionDefinitionsResponse>;
1425
+
873
1426
  /**
874
1427
  * Codes the SDK produces itself rather than relaying from the server. Kept
875
1428
  * out of `@fleetless/contracts`' `ERROR_CODES` deliberately — that list is
@@ -890,12 +1443,13 @@ type ErrorCode = (typeof ERROR_CODES)[number];
890
1443
  * to wait forever for that.
891
1444
  * - `command_outcome_unknown`: worse than a timeout, and told apart from it
892
1445
  * on purpose — the connection that carried the command was replaced by a
893
- * new one (a reconnect) before any reply arrived. The server, if it
894
- * answered at all, answered a socket that no longer exists, so the
895
- * command may or may not have run. Never retried automatically — that
896
- * could run an action twice — the caller recovers by reading the job
897
- * (e.g. `actions.subscribe`), since state is observed by slug regardless
898
- * of which connection asked for it.
1446
+ * new one (a reconnect), or ended because its credential is no longer
1447
+ * valid, before any reply arrived. The server, if it answered at all,
1448
+ * answered a socket that no longer exists, so the command may or may not
1449
+ * have run. Never retried automatically — that could run an action
1450
+ * twice — the caller recovers by reading the job (e.g.
1451
+ * `actions.subscribe`), since state is observed by slug regardless of which
1452
+ * connection asked for it.
899
1453
  * - `unexpected_response`: the server answered `ok:true` but left out
900
1454
  * something the command is defined to always return (e.g. no `job` on a
901
1455
  * successful `invoke`) — a contract violation the SDK noticed, not a
@@ -915,9 +1469,17 @@ type ErrorCode = (typeof ERROR_CODES)[number];
915
1469
  * built with a `serverKey` — `register`, `login`, `logout`, the password
916
1470
  * and invitation calls, both OIDC calls, the two MCP decisions and the two
917
1471
  * grant calls. Those threw a bare `Error` before, which a caller could only
918
- * catch by message. All of them are refused
919
- * before any request is sent — as a rejection, since every one of those
920
- * methods is `async`. A client-side mistake to fix, not something a
1472
+ * catch by message. **A fifth:** an id, slug or key that is only dots (`.`
1473
+ * or `..`) in any call that puts one into a path. It cannot name anything,
1474
+ * and as a path segment it would climb out of its route; no spelling of it
1475
+ * survives the URL parser. **A sixth:** a `collections.list` or
1476
+ * `collections.subscribe` `filter` that is not plain JSON (a BigInt, a
1477
+ * function, a number that is not finite, a cycle). **A seventh:** a
1478
+ * `collections.subscribe` whose frame, with its filter, is larger than the
1479
+ * 16,384 bytes the cloud takes on its realtime socket; the cloud would close
1480
+ * the connection for it, and again after every reconnect. All of them are
1481
+ * refused before any request is sent — as a rejection, since those methods
1482
+ * are `async`; `subscribe` is not, so it throws. A client-side mistake to fix, not something a
921
1483
  * server response could ever produce, which is why this code belongs here
922
1484
  * and not in `@fleetless/contracts`' `ERROR_CODES`.
923
1485
  * - `untrusted_absolute_url`: the SDK refused to fetch an absolute URL
@@ -1926,6 +2488,11 @@ interface AuthApi {
1926
2488
  * Who the caller turned out to be, without decoding a token client-side —
1927
2489
  * which is how apps end up trusting claims nobody verified.
1928
2490
  *
2491
+ * `role` is `{ key, name }` of the organization role the caller holds, and
2492
+ * `null` when there is none to name: a developer, a server key, and an app
2493
+ * user whose role has since been deleted, who can still sign in but reaches
2494
+ * nothing. Show `name`; compare `key`.
2495
+ *
1929
2496
  * Throws the SDK's own `no_session` **before any request is sent** when
1930
2497
  * nothing is stored — which is exactly the state a sign-in step leaves a
1931
2498
  * caller in while a second factor is still pending (see `SignInResult`):
@@ -2285,6 +2852,346 @@ interface CamerasApi {
2285
2852
  live(robotId: string, slug: string): Promise<CameraLiveSession>;
2286
2853
  }
2287
2854
 
2855
+ /**
2856
+ * One change to a record, as `collections.subscribe` hands it to its
2857
+ * callback.
2858
+ *
2859
+ * - `event` is `created`, `updated` or `deleted` when the record was written,
2860
+ * and `removed` or `entered` when it left or came into view of this
2861
+ * subscription without being deleted or created: its values stopped or
2862
+ * started matching the subscription's filter, the caller's role lost or
2863
+ * gained the right to read it, or its robot was detached or attached.
2864
+ * - `id` is the record's id.
2865
+ * - `record` is the whole record: as it is now for `created`, `updated`,
2866
+ * `entered` and `removed`, and as it was for `deleted`. It is absent only on
2867
+ * a `removed` event for a record the caller may no longer read, so that its
2868
+ * values are not told; the `id` still is.
2869
+ *
2870
+ * The wire frame is contracts' `collectionEvent`; the SDK hands over the
2871
+ * change itself, without the frame's `type` and `request_id`.
2872
+ */
2873
+ type CollectionEvent = Omit<CollectionEvent$1, 'type' | 'request_id'>;
2874
+ /**
2875
+ * What `collections.subscribe` takes besides the collection and the change
2876
+ * callback. Every field is optional.
2877
+ */
2878
+ interface CollectionSubscribeOptions {
2879
+ /** Only the records of this robot, in a collection that belongs to robots. */
2880
+ robot?: string;
2881
+ /**
2882
+ * Only records matching this filter are delivered. It is the `filter` of
2883
+ * `collections.list` — the same grammar, at most 3 levels and 50
2884
+ * conditions — and a record that stops matching is announced once as
2885
+ * `removed`. The SDK keeps a copy, so changing the object afterwards
2886
+ * changes nothing; a reactive proxy (Vue, Svelte, MobX) is fine. The filter
2887
+ * has to be plain JSON: a value JSON cannot hold (a BigInt, a function, a
2888
+ * number that is not finite, a cycle) makes `subscribe` throw
2889
+ * `invalid_option` before anything is sent.
2890
+ *
2891
+ * The whole subscription frame, filter included, may be at most 16,384
2892
+ * bytes (UTF-8): the cloud closes the connection for a larger one. A filter
2893
+ * of a few dozen conditions fits; many long values in `in` lists may not.
2894
+ * `subscribe` throws `invalid_option` for a frame over that, before anything
2895
+ * is sent, so narrow the filter or follow the collection by `robot`.
2896
+ */
2897
+ filter?: Record<string, unknown>;
2898
+ /**
2899
+ * Called when the cloud refuses the subscription (`collection_not_found`
2900
+ * for a collection that does not exist or that the caller may not read,
2901
+ * `forbidden`, `robot_not_attached`, `validation_error` for a filter it
2902
+ * cannot read, `internal_error` when it could not check), and when a
2903
+ * running one ends: `collection_removed` after a publish removed the
2904
+ * collection, or `forbidden` / `robot_not_attached` when a role change or a
2905
+ * detached robot no longer allows it. The subscription is over then and
2906
+ * delivers nothing more; subscribe again to follow the collection.
2907
+ *
2908
+ * Also called, without ending the subscription, when the channel cannot
2909
+ * authenticate at all (`no_session`, for instance) and when the cloud ends
2910
+ * the connection because its credential is no longer valid
2911
+ * (`token_revoked`). Nothing reconnects after that, and the subscription
2912
+ * stays registered: if the app opens the channel again (by signing in and
2913
+ * making a new subscription or command), it is sent again and `onReady`
2914
+ * is called once the cloud has confirmed it.
2915
+ */
2916
+ onError?(error: FleetlessError): void;
2917
+ /**
2918
+ * Called each time the cloud has confirmed the subscription: the first time
2919
+ * it is accepted, and again after every reconnect, once the subscription
2920
+ * was sent again on the new connection and accepted. From that moment on
2921
+ * every change the subscription covers reaches `onEvent`, so this is the
2922
+ * place to read the records that exist: call `collections.list` here and
2923
+ * show its result, then apply the events to it. An event can arrive while
2924
+ * the list is still being read, and may or may not be in its result; a
2925
+ * record's `revision` tells a newer state from an older one, so apply an
2926
+ * event only when it is newer than what the list returned for that `id`.
2927
+ *
2928
+ * The same code serves the first load and every later one. The cloud does
2929
+ * not replay what changed while the connection was down, so after a
2930
+ * reconnect the records the app holds may be stale: read them again here
2931
+ * and replace them.
2932
+ *
2933
+ * Not called before the cloud has answered, for a subscription it refuses
2934
+ * (that is `onError`), for one that ended (`unsubscribe`, or `onError` for
2935
+ * an ended one), nor when the app ends the subscription before the answer
2936
+ * arrives. A cloud that does not know this answer never calls it.
2937
+ */
2938
+ onReady?(): void;
2939
+ /**
2940
+ * Called with the schema version now in force when a developer publishes or
2941
+ * restores the app's collections. Rights, fields and collections may have
2942
+ * changed: read `collections.definitions` again.
2943
+ */
2944
+ onSchemaPublished?(version: number): void;
2945
+ }
2946
+
2947
+ /**
2948
+ * One record of a collection: its system fields (`id`, `robot_id`, who made
2949
+ * it and when, `revision`), `display` (the collection's display template
2950
+ * filled in for this record), `missing_required` (required fields that are
2951
+ * empty because the schema changed after the record was written; absent when
2952
+ * nothing is missing) and `values`, the record's own fields by key. A field
2953
+ * without a value is absent from `values`. With `expand`, a reference field
2954
+ * holds the referenced record in this same shape instead of its id, when the
2955
+ * caller may read that collection.
2956
+ *
2957
+ * The wire shape is contracts' `collectionRecord`; the alias exists so the
2958
+ * reference can describe it.
2959
+ */
2960
+ type CollectionRecord = CollectionRecord$1;
2961
+ /**
2962
+ * One change in the history of a record: `seq` (the position to page and
2963
+ * restore by), the operation (`create`, `update`, `delete` or `restore`), the
2964
+ * actor, `reason` (`schema v5`, `import`, `restore v4`, or `null` for an
2965
+ * ordinary write), the record's `revision` afterwards, `changes` (each touched
2966
+ * field with its old and new value) and, on a `delete`, the whole record.
2967
+ *
2968
+ * The wire shape is contracts' `collectionRevision`.
2969
+ */
2970
+ type CollectionRevision = CollectionRevision$1;
2971
+ /**
2972
+ * A collection as the caller may use it, from `collections.definitions`:
2973
+ * `key`, `label`, `description`, `binding` (`global`, `per_robot` or
2974
+ * `one_per_robot`), the `display` template, every field's definition under
2975
+ * `fields`, and `can`, what the caller may do with the records (`read`,
2976
+ * `create`, and for `update` and `delete` `'all'`, `'own'` or `false`) — the
2977
+ * answer to "which buttons do I draw".
2978
+ *
2979
+ * The wire shape is one entry of `collections` in contracts'
2980
+ * `collectionDefinitionsResponse`.
2981
+ */
2982
+ type CollectionDefinition = CollectionDefinitionsResponse['collections'][number];
2983
+ /**
2984
+ * What `collections.definitions` resolves with: `collections`, the collections
2985
+ * the caller may read (see `CollectionDefinition`), and `version`, the schema
2986
+ * version they belong to, `null` while the app has published none. Compare it
2987
+ * with the version `onSchemaPublished` hands over to tell whether what you hold
2988
+ * is current.
2989
+ *
2990
+ * The wire shape is contracts' `collectionDefinitionsResponse`.
2991
+ */
2992
+ type CollectionDefinitions = CollectionDefinitionsResponse;
2993
+ /**
2994
+ * What `collections.list` reads. Every field is optional; the wire names are
2995
+ * snake_case or encoded (`filter` is JSON text, `sort` and `expand` are
2996
+ * comma-separated) and this SDK spells them the way its other options are
2997
+ * spelt, leaving out whatever the caller did not set.
2998
+ */
2999
+ interface CollectionListOptions {
3000
+ /**
3001
+ * Words that must all occur, in any letter case, in at least one searchable
3002
+ * field of the record. At most 10 words, separated by whitespace.
3003
+ */
3004
+ search?: string;
3005
+ /**
3006
+ * A filter: `{ "<field>": { "<op>": value } }`, combined with
3007
+ * `{ and: [...] }` and `{ or: [...] }`. The operators are `eq`, `ne`, `lt`,
3008
+ * `lte`, `gt`, `gte`, `contains`, `in` and `empty`. A field is a field key,
3009
+ * `reference.field` to go one hop through a reference field, or one of the
3010
+ * system fields `id`, `robot_id`, `created_at`, `updated_at` and
3011
+ * `created_by`. Nested at most 3 levels, 50 conditions in all. A filter the
3012
+ * cloud cannot read rejects `validation_error` naming the part that is wrong.
3013
+ * The filter has to be plain JSON; a reactive proxy (Vue, Svelte, MobX) is
3014
+ * fine, and a value JSON cannot hold (a BigInt, a function, a number that is
3015
+ * not finite, a cycle) rejects `invalid_option` before anything is sent.
3016
+ */
3017
+ filter?: Record<string, unknown>;
3018
+ /**
3019
+ * Up to 3 fields to sort by, a leading `-` for descending, for example
3020
+ * `['-created_at']`. Ties are broken by `id`, so a page boundary is exact.
3021
+ */
3022
+ sort?: string[];
3023
+ /** How many records to return, 1 to 500; absent means 50. Above the cap the cloud refuses with `validation_error` rather than trimming. */
3024
+ limit?: number;
3025
+ /** The previous page's `nextCursor`. Send it back rather than computing one; it stays valid while records are written. */
3026
+ cursor?: string;
3027
+ /** `true` makes the page carry `total`, the number of records that match. */
3028
+ count?: boolean;
3029
+ /** Reference fields to embed as records instead of ids, one hop. A record is embedded only when the caller may read its collection; otherwise the id stays. */
3030
+ expand?: string[];
3031
+ /** Only the records of this robot, in a collection that belongs to robots. */
3032
+ robot?: string;
3033
+ /** `true` lists deleted records instead, newest deletion first. Needs the right to create records in the collection. */
3034
+ deleted?: boolean;
3035
+ }
3036
+ /**
3037
+ * One page of `collections.list`.
3038
+ *
3039
+ * **Page until `nextCursor` is `null`, never until a page looks short.** The
3040
+ * cloud only knows a page is the last one when there is nothing behind it.
3041
+ */
3042
+ interface CollectionPage {
3043
+ /** The records of this page, in the requested order. */
3044
+ records: CollectionRecord[];
3045
+ /** Pass it as `cursor` to read the next page; `null` on the last page. */
3046
+ nextCursor: string | null;
3047
+ /** The number of records that match the whole query. Present only when the call asked for it with `count: true`. */
3048
+ total?: number;
3049
+ }
3050
+ /** The window of `collections.history`: both fields optional, newest revisions first. */
3051
+ interface CollectionHistoryOptions {
3052
+ /** How many revisions to return, 1 to 500. */
3053
+ limit?: number;
3054
+ /** The previous page's `nextBeforeSeq`: only revisions older than this `seq`. */
3055
+ beforeSeq?: number;
3056
+ }
3057
+ /**
3058
+ * One page of a record's history, newest revision first. `purged` is set when
3059
+ * an organization owner removed the older part of the history: it starts with
3060
+ * a note saying which revisions went, who removed them and when.
3061
+ */
3062
+ interface CollectionHistoryPage {
3063
+ /** The revisions of this page, newest first. */
3064
+ revisions: CollectionRevision[];
3065
+ /** Pass it as `beforeSeq` to read older revisions; `null` when there are none. */
3066
+ nextBeforeSeq: number | null;
3067
+ /** The removal of the older history, or `null` when none happened. `by` is the owner who removed it, an actor with a `label` like a record's `created_by`. */
3068
+ purged: CollectionRecordHistoryResponse['purged'];
3069
+ }
3070
+ /**
3071
+ * The records of an app's collections, reachable as `client.collections`: the
3072
+ * app's own data model, written by a developer as a schema in the console and
3073
+ * read and written here with the caller's role.
3074
+ *
3075
+ * Every call is checked against the caller's rights on the collection and,
3076
+ * for a collection that belongs to robots, against the robots the caller
3077
+ * reaches. A collection the caller may not read at all rejects
3078
+ * `collection_not_found`, exactly as one that does not exist; one the caller
3079
+ * may read but not write rejects `forbidden`. The refusals specific to
3080
+ * records keep the cloud's codes, with `error.details` in the shape each
3081
+ * exported schema describes:
3082
+ *
3083
+ * - `required_missing` (400): `requiredMissingDetails` — the required fields left empty.
3084
+ * - `reference_invalid` (400): `referenceInvalidDetails` — the reference field and why it was refused.
3085
+ * - `record_changed` (409): `recordChangedDetails` — the revision the record is at now.
3086
+ * - `record_referenced` (409): `recordReferencedDetails` — the collections that still point at the record, with counts.
3087
+ * - `validation_error` (400) and `plan_limit` (409) as elsewhere.
3088
+ * - `rate_limited` (429): `RateLimitDetails` — `retry_after_ms`, how long to wait before writing again. Surfaced, never retried.
3089
+ */
3090
+ interface CollectionsApi {
3091
+ /**
3092
+ * The collections the caller may read, with their field definitions and
3093
+ * what the caller may do with each — what a screen needs to draw a list or
3094
+ * a form without hard-coding the schema — and the schema `version` they
3095
+ * belong to. `collections` is `[]` for an app that has published none, or
3096
+ * whose roles grant this caller none.
3097
+ *
3098
+ * The schema can change under a running app; a realtime subscription's
3099
+ * `onSchemaPublished` says when to read this again, and hands over the
3100
+ * version to compare with.
3101
+ */
3102
+ definitions(): Promise<CollectionDefinitions>;
3103
+ /**
3104
+ * One page of a collection's records, filtered, searched and sorted by the
3105
+ * cloud. In a collection that belongs to robots the caller sees only the
3106
+ * records of robots they reach.
3107
+ *
3108
+ * Rejects `invalid_option`, before anything is sent, for a `filter` that is
3109
+ * not plain JSON.
3110
+ */
3111
+ list(collection: string, options?: CollectionListOptions): Promise<CollectionPage>;
3112
+ /**
3113
+ * One record by id. Rejects `not_found` when there is no such record or
3114
+ * the caller may not see it. `expand` embeds reference fields, one hop.
3115
+ */
3116
+ get(collection: string, id: string, options?: {
3117
+ expand?: string[];
3118
+ }): Promise<CollectionRecord>;
3119
+ /**
3120
+ * The record of one robot in a `one_per_robot` collection, which always
3121
+ * has exactly one. Rejects `robot_not_attached` when the robot is not
3122
+ * attached to the app or the caller does not reach it, and `not_found`
3123
+ * when the collection holds no record for it. Use it on a `one_per_robot`
3124
+ * collection only: on a `per_robot` collection, which holds many records
3125
+ * per robot, it returns the first of them.
3126
+ */
3127
+ get(collection: string, by: {
3128
+ robot: string;
3129
+ }, options?: {
3130
+ expand?: string[];
3131
+ }): Promise<CollectionRecord>;
3132
+ /**
3133
+ * Creates a record. `values` holds the fields by key and must set every
3134
+ * required one. A collection that belongs to robots takes `robot`, the id
3135
+ * of the robot the record belongs to, which cannot change afterwards.
3136
+ * Rejects `required_missing`, `reference_invalid` or `validation_error`
3137
+ * for values the schema refuses, and `plan_limit` when the organization is
3138
+ * at its record or storage limit. A `one_per_robot` collection takes no
3139
+ * creates (`validation_error`): the platform keeps one record for every
3140
+ * attached robot already.
3141
+ */
3142
+ create(collection: string, values: Record<string, unknown>, options?: {
3143
+ robot?: string;
3144
+ }): Promise<CollectionRecord>;
3145
+ /**
3146
+ * Changes the fields in `values` and leaves the others alone; a `null`
3147
+ * clears a field. With `expectedRevision` (the `revision` you last read)
3148
+ * the write is refused with `record_changed` if the record has moved on, so
3149
+ * two editors do not silently overwrite each other.
3150
+ */
3151
+ update(collection: string, id: string, values: Record<string, unknown>, options?: {
3152
+ expectedRevision?: number;
3153
+ }): Promise<CollectionRecord>;
3154
+ /**
3155
+ * Deletes a record; its history is kept. Rejects `record_referenced` while
3156
+ * a record of another collection points at it with `on_delete: prevent`.
3157
+ * A `one_per_robot` collection takes no deletes (`validation_error`).
3158
+ */
3159
+ delete(collection: string, id: string): Promise<void>;
3160
+ /**
3161
+ * A record's history, newest revision first. Needs the right to update the
3162
+ * record.
3163
+ */
3164
+ history(collection: string, id: string, options?: CollectionHistoryOptions): Promise<CollectionHistoryPage>;
3165
+ /**
3166
+ * Follows a collection's changes live over the client's realtime channel:
3167
+ * `onEvent` is called for every record that is created, updated, deleted,
3168
+ * or comes into or leaves the view of this subscription (see
3169
+ * `CollectionEvent`). `options.robot` and `options.filter` narrow it; the
3170
+ * caller's rights are checked on every event, not only when subscribing.
3171
+ *
3172
+ * **There is no first snapshot, but the cloud confirms the subscription.**
3173
+ * Once it has accepted and registered it, `options.onReady` is called, and
3174
+ * from then on every change reaches `onEvent`. To show the records that
3175
+ * exist, `list` in `onReady`, so that no change can fall between the list
3176
+ * and the events; then apply the events to what the list returned. A
3177
+ * refusal is answered through `options.onError` and `onReady` is not called.
3178
+ *
3179
+ * Opens the channel if it is not open, and subscribes again by itself after
3180
+ * every reconnect. Changes made while the connection was down are not
3181
+ * replayed, but `onReady` is called again once the cloud has confirmed the
3182
+ * subscription on the new connection: the same `list` in the same place
3183
+ * refreshes what the app holds.
3184
+ *
3185
+ * Returns the function that ends the subscription. It is safe to call more
3186
+ * than once, and after the cloud ended the subscription itself.
3187
+ *
3188
+ * Throws `invalid_option`, before anything is sent, for a `filter` that is
3189
+ * not plain JSON, and for a subscription whose frame, with its filter, is
3190
+ * larger than the 16,384 bytes the cloud takes.
3191
+ */
3192
+ subscribe(collection: string, options: CollectionSubscribeOptions, onEvent: (event: CollectionEvent) => void): () => void;
3193
+ }
3194
+
2288
3195
  /**
2289
3196
  * The callbacks `datapoints.subscribe` reports through: one for values, one
2290
3197
  * for a refusal. `onEvent` fires immediately with the current value and
@@ -2470,10 +3377,10 @@ interface JobsApi {
2470
3377
  *
2471
3378
  * At most one entry per slug: the current job there, same as a per-slug
2472
3379
  * read would answer. Not a history endpoint — that is `history` below.
2473
- * Grant-filtered same as `cameras.list`/`datapoints` — an end user or
2474
- * server key sees only jobs on slugs their role grants, a developer
2475
- * session sees every job on the robot. Never empty-vs-missing ambiguity:
2476
- * a robot doing nothing resolves `[]`.
3380
+ * Grant-filtered same as `cameras.list`/`datapoints` — an end user sees
3381
+ * only jobs on slugs their role grants, a server key every job on slugs its
3382
+ * app does not lock, a developer session every job on the robot. Never
3383
+ * empty-vs-missing ambiguity: a robot doing nothing resolves `[]`.
2477
3384
  *
2478
3385
  * **Ordered newest first by `started_at`, with `job.seq` as the
2479
3386
  * tiebreaker** (`started_at` alone is not a total order — two jobs minted
@@ -2491,7 +3398,7 @@ interface JobsApi {
2491
3398
  * durable `seq`, with its actor, its outcome and its `duration_ms`, kept
2492
3399
  * for 90 days. The durable counterpart of `list`.
2493
3400
  *
2494
- * **Needs the `action_history` capability** on the caller's role, or it
3401
+ * **Needs the `job_history` capability** for the caller's role, or it
2495
3402
  * rejects `capability_required`. An app user sees only runs on the slugs
2496
3403
  * their role grants; a developer session sees the whole robot.
2497
3404
  *
@@ -2543,9 +3450,11 @@ interface PublishersApi {
2543
3450
  */
2544
3451
  type McpExposure = McpExposure$1;
2545
3452
  /**
2546
- * The two role capabilities a datasheet names beyond slugs: `action_history`
2547
- * (may `jobs.history` be read) and `assets` (may the URDF and meshes be read).
2548
- * The wire shape is contracts' `mcpCapabilities`.
3453
+ * The two capabilities of a robot as a whole that a datasheet names beyond
3454
+ * slugs: `job_history` (may `jobs.history` be read) and `assets` (may the URDF
3455
+ * and meshes be read). The robot's `access` section decides which roles hold
3456
+ * them, else the organization's defaults, less what the app locks. The wire
3457
+ * shape is contracts' `mcpCapabilities`.
2549
3458
  */
2550
3459
  type McpCapabilities = McpCapabilities$1;
2551
3460
  /**
@@ -2563,18 +3472,19 @@ interface RobotsApi {
2563
3472
  * The robots this caller reaches, in name order with the id as the tiebreak.
2564
3473
  *
2565
3474
  * An app user reaches the robots their app attaches on which their role
2566
- * grants at least one slug or capability; a server key reaches every robot
2567
- * its app attaches. A robot the role grants nothing on is absent rather
2568
- * than listed empty — reach is a grant, not an attachment — so a new app
2569
- * whose built-in roles grant nothing yet resolves `[]`, and that is the
2570
- * console's Roles tab talking, not a broken login.
3475
+ * holds at least one slug or capability once the app's locks are taken off;
3476
+ * a server key reaches every robot its app attaches that the locks leave
3477
+ * something on. A robot nothing is granted on is absent rather than listed
3478
+ * empty — reach is a grant, not an attachment — so an app user whose role
3479
+ * holds nothing resolves `[]`, which is the robots' access rules talking, not
3480
+ * a broken login.
2571
3481
  */
2572
3482
  list(): Promise<ClientRobotListItem[]>;
2573
3483
  /**
2574
3484
  * Everything the caller's role lets them do on one robot: every granted
2575
3485
  * datapoint (with `unit` and `decimals`), action, service and publisher
2576
3486
  * (with the parameter JSON Schema under `input_schema`) and camera, plus
2577
- * the two capabilities that gate whole features, `action_history` and
3487
+ * the two capabilities that gate whole features, `job_history` and
2578
3488
  * `assets`. A robot with nothing published resolves an empty `exposures`
2579
3489
  * list. One the caller does not reach rejects `not_found`, exactly as a
2580
3490
  * robot that does not exist — never `forbidden`, which would say it exists.
@@ -2715,6 +3625,8 @@ interface FleetlessClient {
2715
3625
  readonly assets: AssetsApi;
2716
3626
  /** Which robots this caller reaches, and what their role lets them do on each — the calls every screen starts from. */
2717
3627
  readonly robots: RobotsApi;
3628
+ /** The app's own data: the records of the collections a developer defined, read and written with the caller's role, and followed live. */
3629
+ readonly collections: CollectionsApi;
2718
3630
  /**
2719
3631
  * Closes the realtime channel and stops it from reconnecting. Safe with
2720
3632
  * no subscription ever made, and safe to call twice. A Node script (the
@@ -2740,4 +3652,4 @@ interface FleetlessClient {
2740
3652
  */
2741
3653
  declare function createClient(options: FleetlessClientOptions): FleetlessClient;
2742
3654
 
2743
- export { type AcceptInvitationOptions, type ActionsApi, type Asset, type AssetBytes, type AssetListResponse, type AssetsApi, type AuthApi, type BeginOidcLoginOptions, type BeginTwoFactorSetupOptions, type BusyDetails, CANCEL_RETURN_CODES, type CameraDescriptor, type CameraLiveSession, type CameraSnapshot, type CameraSnapshotMeta, type CamerasApi, type CancelRejectedDetails, type CancelReturnCode, type ClientIdentity, type ClientMcpInteraction, type ClientOidcErrorCode, type ClientRobotListItem, type CompleteOidcLoginOptions, type ConfirmTwoFactorSetupOptions, type CreateMeshLoaderOptions, type CredentialSource, 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 JobOrigin, 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 SignInMethods, type SignInResult, type StoredSession, type TokenStore, type TwoFactorSetup, type TwoFactorSetupConfirmation, type UrdfCompleteness, type UrdfSceneManager, type UrdfSceneResources, type VerifyTwoFactorOptions, cancelRejectedDetails, createClient, parameterInvalidDetails };
3655
+ export { type AcceptInvitationOptions, type ActionsApi, type Asset, type AssetBytes, type AssetListResponse, type AssetsApi, type AuthApi, type BeginOidcLoginOptions, type BeginTwoFactorSetupOptions, type BusyDetails, CANCEL_RETURN_CODES, type CameraDescriptor, type CameraLiveSession, type CameraSnapshot, type CameraSnapshotMeta, type CamerasApi, type CancelRejectedDetails, type CancelReturnCode, type ClientIdentity, type ClientMcpInteraction, type ClientOidcErrorCode, type ClientRobotListItem, type CollectionActor, type CollectionBinding, type CollectionDefinition, type CollectionDefinitions, type CollectionEvent, type CollectionField, type CollectionHistoryOptions, type CollectionHistoryPage, type CollectionListOptions, type CollectionPage, type CollectionRecord, type CollectionRevision, type CollectionSubscribeOptions, type CollectionsApi, type CompleteOidcLoginOptions, type ConfirmTwoFactorSetupOptions, type CreateMeshLoaderOptions, type CredentialSource, 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 JobOrigin, 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 RecordChangedDetails, type RecordReferencedDetails, type ReferenceInvalidDetails, type RegisterOptions, type RequiredMissingDetails, type RobotsApi, SDK_ERROR_CODES, type SdkErrorCode, type SendCommandOptions, type ServicesApi, type SignInMethods, type SignInResult, type StoredSession, type TokenStore, type TwoFactorSetup, type TwoFactorSetupConfirmation, type UrdfCompleteness, type UrdfSceneManager, type UrdfSceneResources, type VerifyTwoFactorOptions, cancelRejectedDetails, createClient, parameterInvalidDetails, recordChangedDetails, recordReferencedDetails, referenceInvalidDetails, requiredMissingDetails };