@fleetless/contracts 8.2.0 → 9.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/artifacts/openapi.json +284 -22
  3. package/artifacts/routes.json +52 -4
  4. package/artifacts/schema/action-config.schema.json +2 -2
  5. package/artifacts/schema/app-auth-config.schema.json +30 -0
  6. package/artifacts/schema/cloud-config.schema.json +8 -8
  7. package/artifacts/schema/config-draft-response.schema.json +8 -8
  8. package/artifacts/schema/config-version-response.schema.json +8 -8
  9. package/artifacts/schema/datapoint-config.schema.json +3 -3
  10. package/artifacts/schema/legal-acceptance-list-query.schema.json +26 -0
  11. package/artifacts/schema/legal-acceptance-list-response.schema.json +127 -0
  12. package/artifacts/schema/legal-acceptance-version-row.schema.json +101 -0
  13. package/artifacts/schema/legal-document-reference.schema.json +28 -0
  14. package/artifacts/schema/legal-text-references.schema.json +72 -0
  15. package/artifacts/schema/parameter-spec.schema.json +1 -1
  16. package/artifacts/schema/publisher-config.schema.json +1 -1
  17. package/artifacts/schema/put-app-auth-urls-request.schema.json +31 -1
  18. package/artifacts/schema/robot-config-doc.schema.json +8 -8
  19. package/artifacts/schema/service-config.schema.json +1 -1
  20. package/artifacts/schema/support-renew-fail-refusal.schema.json +141 -0
  21. package/artifacts/schema/support-renew-fail-request.schema.json +28 -0
  22. package/artifacts/schema/waitlist-request.schema.json +9 -1
  23. package/dist/app-users.d.ts +12 -5
  24. package/dist/app-users.js +29 -6
  25. package/dist/client-robots.d.ts +1 -1
  26. package/dist/client-robots.js +1 -1
  27. package/dist/config.d.ts +1 -1
  28. package/dist/config.js +7 -7
  29. package/dist/errors.js +19 -15
  30. package/dist/identity.d.ts +5 -2
  31. package/dist/identity.js +10 -3
  32. package/dist/index.d.ts +7 -3
  33. package/dist/index.js +4 -2
  34. package/dist/legal-acceptances.d.ts +54 -0
  35. package/dist/legal-acceptances.js +22 -0
  36. package/dist/legal.d.ts +31 -0
  37. package/dist/legal.js +29 -0
  38. package/dist/mcp.d.ts +13 -10
  39. package/dist/mcp.js +13 -10
  40. package/dist/routes.js +44 -6
  41. package/dist/support.d.ts +42 -0
  42. package/dist/support.js +15 -0
  43. package/package.json +1 -1
package/dist/routes.js CHANGED
@@ -10,10 +10,11 @@ import { appAuthConfig, appInvitation, appInvitationListResponse, appMailTemplat
10
10
  import { controllerRegisterOrgResponse, controllerRegisterWrite } from './controller-register.js';
11
11
  import { acceptTeamInviteRequest, authMeResponse, createPasskeyRequest, createPasskeyResponse, createTeamInviteRequest, developerPasskey, developerTwoFactor, fleetlessUser, fleetlessUserListResponse, passwordChangeRequest, patchAuthMeRequest, patchFleetlessUserRequest, patchOrgRequest, patchOrgResponse, pendingTeamInviteListResponse, refreshRequest, sessionTokens, teamInvite, recoveryCodesResponse, renamePasskeyRequest, tierChangeRequest, totpConfirmRequest, totpConfirmResponse, twoFactorSetupResponse, waitlistRequest, webauthnOptionsResponse, } from './identity.js';
12
12
  import { jobRunListResponse, jobRunQuery, jobRunSummary, jobRunSummaryQuery } from './jobs.js';
13
+ import { legalAcceptanceListQuery, legalAcceptanceListResponse } from './legal-acceptances.js';
13
14
  import { MCP_APP_PATHS, mcpRobotDatasheet, mcpRolePreviewResponse } from './mcp.js';
14
15
  import { authorizationServerMetadata, dynamicClientRegistrationRequest, dynamicClientRegistrationResponse, oauthAuthorizeQuery, oauthRedirectResponse, oauthTokenRequest, oauthTokenResponse, protectedResourceMetadata, } from './oauth.js';
15
16
  import { adminPlanChangeRequest, orgPlan, planChangeRequest } from './plans.js';
16
- import { supportTokenRequest, supportTokenResponse } from './support.js';
17
+ import { supportRenewFailRequest, supportTokenRequest, supportTokenResponse } from './support.js';
17
18
  import { purchaseIntentLookupQuery, purchaseIntentConfirmRequest, purchaseIntentResponse, invoicePayRequest, billingCancelRequest, billingChangeRequest, billingChangeResponse, billingDetailsUpdate, billingDocumentDetail, billingDocumentFileQuery, billingDocumentList, billingView, chargePayRequest, checkoutRequest, checkoutResponse, checkoutStatus, paymentMethodChangeRequest, vatIdCheckRequest, vatIdCheckResponse, } from './billing.js';
18
19
  import { cameraListResponse, cancelRequest, configDraftResponse, configVersionResponse, configVersionsResponse, createRobotRequest, createRobotResponse, datapointListResponse, datapointValue, exposureListResponse, fetchTypesRequest, fetchTypesResponse, historyQuery, historyResponse, introspectionResponse, invokeOrServiceResponse, invokeRequest, jobResponse, liveSessionResponse, orgHealthQuery, orgLatencyQuery, orgLatencyResponse, orgQuotaUsage, orgUsageQuery, orgUsageResponse, patchRobotRequest, patchRobotResponse, publishConfigResponse, publishRequest, putConfigDraftRequest, putRobotDetailsRequest, putRobotDetailsResponse, robotTokenRotateResponse, jointStatePutRequest, jointStatePutResponse, releaseLiveQuery, renameSlugRequest, renameSlugResponse, robotDeleteQuery, resourceHealthListResponse, robotDeletionSummary, robotDetailResponse, robotJobsResponse, robotListResponse, slugUsageResponse, snapshotMetaResponse, typesResponse, } from './rest.js';
19
20
  export const ROUTE_SECTIONS = [
@@ -53,6 +54,9 @@ const APP_IDENTIFIER = {
53
54
  };
54
55
  /** The routes that verify a credential inside the handler; `auth: 'in_handler'` is refused elsewhere. */
55
56
  export const IN_HANDLER_ROUTES = [
57
+ // The old support bearer must reach the flow transaction after a newer
58
+ // generation wins; a generic current-generation guard would hide that race.
59
+ 'POST /console/support/renew/fail',
56
60
  'POST /mcp',
57
61
  // The per-app endpoint, all three verbs: the bearer decides which app user
58
62
  // is calling, and the path names none of that. Built from `MCP_APP` so the
@@ -464,6 +468,18 @@ export const ROUTES = [
464
468
  'capped by its own global ceiling, above which the row is still written and the mail is skipped.',
465
469
  },
466
470
  /* ---------------------------------------------------------------- org */
471
+ {
472
+ method: 'GET', path: '/api/org/legal/acceptances', section: 'org',
473
+ summary: "Lists the calling organization's accepted legal document versions, newest first.",
474
+ audience: 'developer', auth: 'developer', rateLimited: false, ownerTier: true, status: 200,
475
+ params: [], query: legalAcceptanceListQuery, request: null, response: legalAcceptanceListResponse,
476
+ errors: [...DEVELOPER_GUARD, 'tier_required', 'support_forbidden', 'validation_error'], transport: 'http',
477
+ notes: 'A real Owner reads only the authenticated organization; Developer and support sessions cannot read it. ' +
478
+ 'Rows carry stored Terms and applicable DPA references, never the current versions substituted for history. ' +
479
+ 'The default page limit is 50, maximum 100. The opaque cursor is unpadded base64url of UTF-8 JSON ' +
480
+ '`[accepted_at,id]`, with a six-digit UTC timestamp and lowercase UUID; Cloud rejects noncanonical tokens. ' +
481
+ 'Follow `next_cursor` until null. Equal timestamps sort by id descending; a new acceptance cannot displace older rows.',
482
+ },
467
483
  {
468
484
  method: 'GET', path: '/api/org/controller-register', section: 'org',
469
485
  summary: "Reads the calling owner's customer-confirmed controller register details.",
@@ -621,7 +637,7 @@ export const ROUTES = [
621
637
  ],
622
638
  query: null, request: null, response: mcpRolePreviewResponse,
623
639
  errors: [...DEVELOPER_GUARD, 'invalid_uuid', 'not_found'], transport: 'http',
624
- notes: 'Built by the same builder the MCP server\'s own `robot_describe` uses, so the two cannot drift. It answers what the role *would* be ' +
640
+ notes: 'Built by the same builder the MCP server\'s own `robots.describe` uses, so the two cannot drift. It answers what the role *would* be ' +
625
641
  'offered and consults nothing about any user\'s actual MCP entitlement. A robot the role grants nothing on still appears, with an empty ' +
626
642
  '`exposures` — dropping it would read as "not attached", which is a different fact.',
627
643
  },
@@ -1531,6 +1547,28 @@ export const ROUTES = [
1531
1547
  'session that outlives its ceiling is a new grant and a new exchange, not a renewal. The session starts in `read` mode; switching one to ' +
1532
1548
  '`edit` is the operator side\'s `support_session_edit` command, not anything this route does.',
1533
1549
  },
1550
+ {
1551
+ method: 'POST', path: '/console/support/renew/fail', section: 'developer-auth',
1552
+ summary: 'Ends a current-generation support session after Console proves renewal authority failed.',
1553
+ audience: 'internal', auth: 'in_handler', rateLimited: false, ownerTier: false, status: 204,
1554
+ params: [], query: null, request: supportRenewFailRequest, response: null,
1555
+ errors: ['validation_error', 'unauthorized', 'not_found', 'target_state_conflict'], transport: 'http',
1556
+ notes: 'Internal Console-to-Cloud POST only, no CORS. Console must first verify and consume signed Operator failure evidence ' +
1557
+ 'bound to its original browser flow, or let Cloud timeout/sweep close an uncompleted flow; browser flow_id or error alone ' +
1558
+ 'must never trigger this call. The evidence stays at Console: this strict Cloud request has no Operator or browser field. ' +
1559
+ 'Authorization: Bearer <original fl_support>; a valid old bearer must reach the ' +
1560
+ 'transaction even after another flow wins its generation, so a current-generation pre-handler must not intercept it. Cloud checks ' +
1561
+ 'signature, audience, original expiry, exact stored bearer hash, S256 verifier, and bound session, org, mode and immutable creator ' +
1562
+ 'subject. Lock session and flow in redemption order. After proof and before mutation, compare the saved credential generation: ' +
1563
+ 'stale_generation takes precedence and cannot touch the winner. Only a live, pending, unauthorised current-generation flow before ' +
1564
+ 'min(flow_created_at + 120 seconds, old credential expiry) atomically records failedAt, endedAt and audit/event. Success is 204 ' +
1565
+ 'with no body. Missing callback closes an unauthorised expired flow at the next session check or sweep under the same generation fence. ' +
1566
+ 'No failure extends a lease or compensates a committed redemption. Every refusal is Cache-Control: no-store with ' +
1567
+ 'supportRenewFailRefusal body: 400 validation_error/invalid_flow for malformed JSON; 401 unauthorized/invalid_authority for missing ' +
1568
+ 'or invalid bearer or proof; 404 not_found/invalid_flow for unknown or foreign flow, or /identity_mismatch for bound identity mismatch; ' +
1569
+ '409 target_state_conflict/expired, /replayed, /session_inactive or /stale_generation. No failure response sets or clears fl_support. ' +
1570
+ 'Network ambiguity is never a 204 and does not trigger an unconditional support_session.end.',
1571
+ },
1534
1572
  /* --------------------------------- the Fleetless-hosted app pages */
1535
1573
  ...HOSTED_APP_ROUTES,
1536
1574
  /* ---------------------------------------------------- mcp (the endpoint) */
@@ -1557,7 +1595,7 @@ export const ROUTES = [
1557
1595
  'the refusal has to carry a `WWW-Authenticate` challenge that a guard shared with the REST surface does not send. `Origin` is checked ' +
1558
1596
  'against the cloud\'s own, and a foreign one is the `403 forbidden` above. **Both catalogs, unconditionally**: every caller admitted ' +
1559
1597
  'here is a Fleetless user, so the tool list has nothing left to vary with and the admin-ness check on `tools/call` is gone — a console ' +
1560
- 'tool that is still narrower than the catalog refuses for itself (`console_robot_delete` answers `tier_required` to a non-Owner). ' +
1598
+ 'tool that is still narrower than the catalog refuses for itself (`console_robots_write.delete` answers `tier_required` to a non-Owner). ' +
1561
1599
  '`403 forbidden` is also what an `mcp_session` token whose subject is an **app user** gets: this endpoint serves the team only, and such ' +
1562
1600
  'a token belongs to its own app\'s endpoint. The code is `forbidden` rather than `mcp_disabled` because nothing is switched off — the ' +
1563
1601
  'caller is at the wrong server — and per-app sign-in mints exactly such tokens, so the two states must not share a word. ' +
@@ -2305,10 +2343,10 @@ export const ROUTES = [
2305
2343
  audience: 'client', auth: 'developer_or_client', rateLimited: false, ownerTier: false, status: 200,
2306
2344
  params: [], query: null, request: null, response: clientRobotListResponse,
2307
2345
  errors: [...CLIENT_GUARD], transport: 'http',
2308
- notes: '**The REST twin of the MCP tool `robots_list`**, and the one robot question no robot-scoped route can answer: which robots may I name ' +
2346
+ notes: '**The REST twin of the MCP action `robots.list`**, and the one robot question no robot-scoped route can answer: which robots may I name ' +
2309
2347
  'at all. An app user sees the robots their app attaches on which their role grants at least one slug or capability; a server key sees ' +
2310
2348
  'every robot its app attaches; a developer bearer sees the organisation\'s robots. Name order, id as the tiebreak. A robot on which the ' +
2311
- 'role grants nothing is absent rather than listed empty — the same answer `robots_list` gives, for the same reason: reach is a grant, ' +
2349
+ 'role grants nothing is absent rather than listed empty — the same answer `robots.list` gives, for the same reason: reach is a grant, ' +
2312
2350
  'not an attachment. Under `/api/client/` because it names no robot; every robot-scoped read stays under `/api/robots/:id/…`.',
2313
2351
  },
2314
2352
  {
@@ -2318,7 +2356,7 @@ export const ROUTES = [
2318
2356
  params: [{ name: 'id', description: 'The robot\'s uuid, as `GET /api/client/robots` lists it.' }],
2319
2357
  query: null, request: null, response: mcpRobotDatasheet,
2320
2358
  errors: [...CLIENT_GUARD, 'invalid_uuid', 'not_found'], transport: 'http',
2321
- notes: '**The REST twin of the MCP tool `robot_describe`**: one answer per robot — every datapoint, action, service, publisher and camera the ' +
2359
+ notes: '**The REST twin of the MCP action `robots.describe`**: one answer per robot — every datapoint, action, service, publisher and camera the ' +
2322
2360
  'role grants, each with its `input_schema` where it takes parameters, plus the two capabilities that gate whole features, ' +
2323
2361
  '`action_history` and `assets`. A robot with nothing published answers an empty `exposures` list, never a refusal. A robot the caller ' +
2324
2362
  'does not reach — not attached to their app, or attached with a role that grants nothing on it — answers `404` exactly as one that ' +
package/dist/support.d.ts CHANGED
@@ -78,6 +78,48 @@ export declare const supportTokenResponse: z.ZodObject<{
78
78
  }, z.core.$strict>;
79
79
  }, z.core.$strict>;
80
80
  export type SupportTokenResponse = z.infer<typeof supportTokenResponse>;
81
+ /** Cloud verifies Console's original bearer and server-held PKCE proof; Console first verifies signed Operator failure evidence. */
82
+ export declare const supportRenewFailRequest: z.ZodObject<{
83
+ flow_id: z.ZodUUID;
84
+ code_verifier: z.ZodString;
85
+ reason: z.ZodLiteral<"authority_failed">;
86
+ }, z.core.$strict>;
87
+ export type SupportRenewFailRequest = z.infer<typeof supportRenewFailRequest>;
88
+ /** Body of every non-204 renewal-failure response. HTTP status follows `code`; all refusals are no-store. */
89
+ export declare const supportRenewFailRefusal: z.ZodUnion<readonly [z.ZodObject<{
90
+ code: z.ZodLiteral<"validation_error">;
91
+ message: z.ZodString;
92
+ details: z.ZodObject<{
93
+ rule: z.ZodLiteral<"invalid_flow">;
94
+ }, z.core.$strict>;
95
+ }, z.core.$strict>, z.ZodObject<{
96
+ code: z.ZodLiteral<"unauthorized">;
97
+ message: z.ZodString;
98
+ details: z.ZodObject<{
99
+ rule: z.ZodLiteral<"invalid_authority">;
100
+ }, z.core.$strict>;
101
+ }, z.core.$strict>, z.ZodObject<{
102
+ code: z.ZodLiteral<"not_found">;
103
+ message: z.ZodString;
104
+ details: z.ZodObject<{
105
+ rule: z.ZodEnum<{
106
+ invalid_flow: "invalid_flow";
107
+ identity_mismatch: "identity_mismatch";
108
+ }>;
109
+ }, z.core.$strict>;
110
+ }, z.core.$strict>, z.ZodObject<{
111
+ code: z.ZodLiteral<"target_state_conflict">;
112
+ message: z.ZodString;
113
+ details: z.ZodObject<{
114
+ rule: z.ZodEnum<{
115
+ expired: "expired";
116
+ replayed: "replayed";
117
+ session_inactive: "session_inactive";
118
+ stale_generation: "stale_generation";
119
+ }>;
120
+ }, z.core.$strict>;
121
+ }, z.core.$strict>]>;
122
+ export type SupportRenewFailRefusal = z.infer<typeof supportRenewFailRefusal>;
81
123
  /**
82
124
  * What `GET /api/auth/me` answers **to a support token** — `authMeResponse`
83
125
  * with one more, optional field. The public route entry keeps `authMeResponse`
package/dist/support.js CHANGED
@@ -93,6 +93,21 @@ export const supportTokenResponse = z
93
93
  }),
94
94
  })
95
95
  .strict();
96
+ /** Cloud verifies Console's original bearer and server-held PKCE proof; Console first verifies signed Operator failure evidence. */
97
+ export const supportRenewFailRequest = z.object({
98
+ flow_id: z.uuid().meta({ description: 'The pending Cloud renewal flow created with the original support bearer.' }),
99
+ code_verifier: z.string().regex(/^[A-Za-z0-9._~-]{43,128}$/).meta({
100
+ description: 'The server-held RFC 7636 verifier matching the flow\'s S256 challenge; never sent to the browser.',
101
+ }),
102
+ reason: z.literal('authority_failed').meta({ description: 'A fixed category; browser and IdP error text is not forwarded.' }),
103
+ }).strict();
104
+ /** Body of every non-204 renewal-failure response. HTTP status follows `code`; all refusals are no-store. */
105
+ export const supportRenewFailRefusal = z.union([
106
+ z.object({ code: z.literal('validation_error'), message: z.string().min(1), details: z.object({ rule: z.literal('invalid_flow') }).strict() }).strict(),
107
+ z.object({ code: z.literal('unauthorized'), message: z.string().min(1), details: z.object({ rule: z.literal('invalid_authority') }).strict() }).strict(),
108
+ z.object({ code: z.literal('not_found'), message: z.string().min(1), details: z.object({ rule: z.enum(['invalid_flow', 'identity_mismatch']) }).strict() }).strict(),
109
+ z.object({ code: z.literal('target_state_conflict'), message: z.string().min(1), details: z.object({ rule: z.enum(['expired', 'replayed', 'session_inactive', 'stale_generation']) }).strict() }).strict(),
110
+ ]);
96
111
  /**
97
112
  * What `GET /api/auth/me` answers **to a support token** — `authMeResponse`
98
113
  * with one more, optional field. The public route entry keeps `authMeResponse`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fleetless/contracts",
3
- "version": "8.2.0",
3
+ "version": "9.1.0",
4
4
  "description": "Fleetless wire contracts: the bridge-cloud protocol, the REST API schemas and the error codes, as zod schemas with generated JSON Schema and OpenAPI artifacts.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Dehne Robotik GmbH",