@onesi/genesis 0.0.1-stage → 0.2.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 (113) hide show
  1. package/README.md +29 -0
  2. package/dist/auto.d.ts +1010 -0
  3. package/dist/auto.js +125 -0
  4. package/dist/beacons.d.ts +145 -0
  5. package/dist/beacons.js +148 -0
  6. package/dist/blinds-owner-enrollment.d.ts +280 -0
  7. package/dist/blinds-owner-enrollment.js +169 -0
  8. package/dist/client.d.ts +52 -0
  9. package/dist/client.js +384 -0
  10. package/dist/context.d.ts +50 -0
  11. package/dist/context.js +153 -0
  12. package/dist/dials.d.ts +299 -0
  13. package/dist/dials.js +100 -0
  14. package/dist/errors.d.ts +35 -0
  15. package/dist/errors.js +66 -0
  16. package/dist/flares.d.ts +202 -0
  17. package/dist/flares.js +61 -0
  18. package/dist/fleets.d.ts +218 -0
  19. package/dist/fleets.js +189 -0
  20. package/dist/flocks.d.ts +439 -0
  21. package/dist/flocks.js +98 -0
  22. package/dist/foundry-billing.d.ts +97 -0
  23. package/dist/foundry-billing.js +107 -0
  24. package/dist/foundry.d.ts +424 -0
  25. package/dist/foundry.js +133 -0
  26. package/dist/garden.d.ts +754 -0
  27. package/dist/garden.js +76 -0
  28. package/dist/gateway.d.ts +365 -0
  29. package/dist/gateway.js +82 -0
  30. package/dist/gears.d.ts +226 -0
  31. package/dist/gears.js +42 -0
  32. package/dist/generated/operations.d.ts +4 -0
  33. package/dist/generated/operations.js +65134 -0
  34. package/dist/generated/schema.d.ts +87658 -0
  35. package/dist/generated/schema.js +1 -0
  36. package/dist/genesis.d.ts +9574 -0
  37. package/dist/genesis.js +271 -0
  38. package/dist/genesis.openapi.json +128522 -0
  39. package/dist/henry.d.ts +369 -0
  40. package/dist/henry.js +268 -0
  41. package/dist/hives-cells.d.ts +127 -0
  42. package/dist/hives-cells.js +151 -0
  43. package/dist/hives-environment.d.ts +37 -0
  44. package/dist/hives-environment.js +80 -0
  45. package/dist/hives-functions.d.ts +36 -0
  46. package/dist/hives-functions.js +185 -0
  47. package/dist/hives-marketplace.d.ts +128 -0
  48. package/dist/hives-marketplace.js +187 -0
  49. package/dist/hives-node.d.ts +9 -0
  50. package/dist/hives-node.js +155 -0
  51. package/dist/hives-operations.d.ts +451 -0
  52. package/dist/hives-operations.js +43 -0
  53. package/dist/hives-platform.d.ts +149 -0
  54. package/dist/hives-platform.js +183 -0
  55. package/dist/hives-queue-consumer.d.ts +56 -0
  56. package/dist/hives-queue-consumer.js +95 -0
  57. package/dist/hives-queue-funding.d.ts +28 -0
  58. package/dist/hives-queue-funding.js +81 -0
  59. package/dist/hives-queues.d.ts +137 -0
  60. package/dist/hives-queues.js +143 -0
  61. package/dist/hives-resources-transport.d.ts +23 -0
  62. package/dist/hives-resources-transport.js +204 -0
  63. package/dist/hives-response.d.ts +2 -0
  64. package/dist/hives-response.js +32 -0
  65. package/dist/hives-runtimes.d.ts +34 -0
  66. package/dist/hives-runtimes.js +32 -0
  67. package/dist/hives-sse.d.ts +24 -0
  68. package/dist/hives-sse.js +111 -0
  69. package/dist/hives-topics.d.ts +51 -0
  70. package/dist/hives-topics.js +79 -0
  71. package/dist/hives-upload.d.ts +9 -0
  72. package/dist/hives-upload.js +23 -0
  73. package/dist/hives-volumes.d.ts +64 -0
  74. package/dist/hives-volumes.js +117 -0
  75. package/dist/iam-directory.d.ts +8 -0
  76. package/dist/iam-directory.js +23 -0
  77. package/dist/iam.d.ts +391 -0
  78. package/dist/iam.js +92 -0
  79. package/dist/idempotency.d.ts +7 -0
  80. package/dist/idempotency.js +39 -0
  81. package/dist/index.d.ts +47 -0
  82. package/dist/index.js +37 -0
  83. package/dist/instances.d.ts +200 -0
  84. package/dist/instances.js +43 -0
  85. package/dist/lanes.d.ts +267 -0
  86. package/dist/lanes.js +41 -0
  87. package/dist/minds-agent.d.ts +88 -0
  88. package/dist/minds-agent.js +233 -0
  89. package/dist/minds-engine.d.ts +394 -0
  90. package/dist/minds-engine.js +555 -0
  91. package/dist/minds-owner.d.ts +110 -0
  92. package/dist/minds-owner.js +226 -0
  93. package/dist/minds.d.ts +377 -0
  94. package/dist/minds.js +228 -0
  95. package/dist/orgs.d.ts +405 -0
  96. package/dist/orgs.js +63 -0
  97. package/dist/relays-enrollment.d.ts +33 -0
  98. package/dist/relays-enrollment.js +115 -0
  99. package/dist/runner-grant.d.ts +10 -0
  100. package/dist/runner-grant.js +133 -0
  101. package/dist/runner.d.ts +72 -0
  102. package/dist/runner.js +117 -0
  103. package/dist/scopes.d.ts +310 -0
  104. package/dist/scopes.js +40 -0
  105. package/dist/taps.d.ts +118 -0
  106. package/dist/taps.js +45 -0
  107. package/dist/traces.d.ts +574 -0
  108. package/dist/traces.js +97 -0
  109. package/dist/types.d.ts +98 -0
  110. package/dist/types.js +1 -0
  111. package/dist/urls.d.ts +6 -0
  112. package/dist/urls.js +31 -0
  113. package/package.json +49 -1
package/dist/auto.js ADDED
@@ -0,0 +1,125 @@
1
+ import { idempotencyHeaders, ifMatchHeaders } from './idempotency.js';
2
+ /** Auto, your organization's operating structure: orgs, mandates, spend actions, approvals, the org structure (units, positions with
3
+ * delegated authority, occupants, goals and scorecards), how the org operates (budgets, policies, cadences,
4
+ * succession and acting appointments), verifiable authority (the authority check with its signed receipt,
5
+ * AuthorityCredentials, token verification) and the decision ledger. Auto never runs or controls an agent.
6
+ * Updates, archives, appointments, vacancies, succession and acting changes take the `version` you read
7
+ * (sent as If-Match); a stale one is a 409. */
8
+ export function autoModule(client) {
9
+ return {
10
+ whoami: () => client.request('auto_whoami'),
11
+ orgs: {
12
+ list: (includeArchived) => client.request('auto_listOrgs', includeArchived === undefined ? {} : { include_archived: includeArchived }),
13
+ get: (org) => client.request('auto_getOrg', { org }),
14
+ create: (body) => client.request('auto_createOrg', { body }),
15
+ update: (org, version, body) => client.request('auto_updateOrg', { org, body }, { headers: ifMatchHeaders('auto_updateOrg', version) }),
16
+ archive: (org, version) => client.request('auto_archiveOrg', { org }, { headers: ifMatchHeaders('auto_archiveOrg', version) }),
17
+ mandates: (org) => client.request('auto_listMandates', { org }),
18
+ createMandate: (org, body) => client.request('auto_createMandate', { org, body }),
19
+ recordDecision: (org, body) => client.request('auto_recordDecision', { org, body }),
20
+ ledger: (org, page = {}) => client.request('auto_getLedger', { org, ...page }),
21
+ verifyLedger: (org) => client.request('auto_verifyLedger', { org }),
22
+ approvals: (org, status) => client.request('auto_listApprovals', status ? { org, status } : { org }),
23
+ units: (org, includeArchived) => client.request('auto_listUnits', includeArchived === undefined ? { org } : { org, include_archived: includeArchived }),
24
+ createUnit: (org, body) => client.request('auto_createUnit', { org, body }),
25
+ positions: (org, filter = {}) => client.request('auto_listPositions', { org, ...filter }),
26
+ createPosition: (org, body) => client.request('auto_createPosition', { org, body }),
27
+ chart: (org) => client.request('auto_getOrgChart', { org }),
28
+ goals: (org, positionId) => client.request('auto_listGoals', positionId ? { org, position_id: positionId } : { org }),
29
+ createGoal: (org, body) => client.request('auto_createGoal', { org, body }),
30
+ scorecard: (org) => client.request('auto_getOrgScorecard', { org }),
31
+ budgets: (org, filter = {}) => client.request('auto_listBudgets', { org, ...filter }),
32
+ createBudget: (org, body) => client.request('auto_createBudget', { org, body }),
33
+ policies: (org, includeArchived) => client.request('auto_listPolicies', includeArchived === undefined ? { org } : { org, include_archived: includeArchived }),
34
+ createPolicy: (org, body) => client.request('auto_createPolicy', { org, body }),
35
+ cadences: (org, filter = {}) => client.request('auto_listCadences', { org, ...filter }),
36
+ createCadence: (org, body) => client.request('auto_createCadence', { org, body }),
37
+ /** Active cadences due within `withinHours` (default 24, at most 744), overdue first, with who runs each. */
38
+ dueCadences: (org, withinHours) => client.request('auto_listDueCadences', withinHours === undefined ? { org } : { org, within_hours: withinHours }),
39
+ /** Vacancies, successors and single points of spend. */
40
+ continuity: (org) => client.request('auto_getOrgContinuity', { org }),
41
+ credentials: (org, positionId) => client.request('auto_listCredentials', positionId ? { org, position_id: positionId } : { org }),
42
+ },
43
+ units: {
44
+ get: (unit) => client.request('auto_getUnit', { unit }),
45
+ update: (unit, version, body) => client.request('auto_updateUnit', { unit, body }, { headers: ifMatchHeaders('auto_updateUnit', version) }),
46
+ archive: (unit, version) => client.request('auto_archiveUnit', { unit }, { headers: ifMatchHeaders('auto_archiveUnit', version) }),
47
+ },
48
+ /** Positions hold delegated authority; it only flows down the reporting line. */
49
+ positions: {
50
+ get: (position) => client.request('auto_getPosition', { position }),
51
+ update: (position, version, body) => client.request('auto_updatePosition', { position, body }, { headers: ifMatchHeaders('auto_updatePosition', version) }),
52
+ archive: (position, version) => client.request('auto_archivePosition', { position }, { headers: ifMatchHeaders('auto_archivePosition', version) }),
53
+ /** Fill the position or swap its occupant (a person, or a Henry, Fleets or Flocks agent that Auto only references). */
54
+ appoint: (position, version, body) => client.request('auto_appointOccupant', { position, body }, { headers: ifMatchHeaders('auto_appointOccupant', version) }),
55
+ vacate: (position, version) => client.request('auto_vacatePosition', { position }, { headers: ifMatchHeaders('auto_vacatePosition', version) }),
56
+ terms: (position) => client.request('auto_listPositionTerms', { position }),
57
+ scorecard: (position) => client.request('auto_getPositionScorecard', { position }),
58
+ /** Replace the ordered successor list (up to 5 positions; empty clears it). */
59
+ setSuccession: (position, version, body) => client.request('auto_setPositionSuccession', { position, body }, { headers: ifMatchHeaders('auto_setPositionSuccession', version) }),
60
+ /** Someone (the occupant of `from_position_id`, or the first filled successor) acts for the position. */
61
+ startActing: (position, version, body) => client.request('auto_startActing', { position, body }, { headers: ifMatchHeaders('auto_startActing', version) }),
62
+ endActing: (position, version, reason) => client.request('auto_endActing', reason === undefined ? { position } : { position, reason }, { headers: ifMatchHeaders('auto_endActing', version) }),
63
+ /** A signed AuthorityCredential (JWT) for the position's holder; the `token` is returned only here. */
64
+ issueCredential: (position, body = {}) => client.request('auto_issuePositionCredential', { position, body }),
65
+ },
66
+ /** "May this principal, in this position, do this?" Ledgered, never metered; `auto:read` alone gets a dry run. */
67
+ authority: {
68
+ /** With an idempotency key, a repeat returns the first answer (`idempotent_replay: true`) instead of counting spend twice. */
69
+ check: (body, options = {}) => client.request('auto_checkAuthority', { body }, { headers: idempotencyHeaders('auto_checkAuthority', options.idempotencyKey) }),
70
+ getCheck: (check) => client.request('auto_getAuthorityCheck', { check }),
71
+ /** Spend that was allowed but did not happen stops counting against limits and budgets. Once per check. */
72
+ release: (check, reason) => client.request('auto_releaseAuthorityCheck', { check, body: reason === undefined ? {} : { reason } }),
73
+ /** Check a receipt or an AuthorityCredential: Auto's signature, expiry and revocation. */
74
+ verify: (token) => client.request('auto_verifyAuthorityToken', { body: { token } }),
75
+ },
76
+ goals: {
77
+ get: (goal) => client.request('auto_getGoal', { goal }),
78
+ update: (goal, version, body) => client.request('auto_updateGoal', { goal, body }, { headers: ifMatchHeaders('auto_updateGoal', version) }),
79
+ archive: (goal, version) => client.request('auto_archiveGoal', { goal }, { headers: ifMatchHeaders('auto_archiveGoal', version) }),
80
+ measure: (goal, body) => client.request('auto_recordGoalMeasurement', { goal, body }),
81
+ },
82
+ /** Spend caps for a unit (and every unit below it) or the whole org, enforced by the authority check. */
83
+ budgets: {
84
+ get: (budget) => client.request('auto_getBudget', { budget }),
85
+ update: (budget, version, body) => client.request('auto_updateBudget', { budget, body }, { headers: ifMatchHeaders('auto_updateBudget', version) }),
86
+ archive: (budget, version) => client.request('auto_archiveBudget', { budget }, { headers: ifMatchHeaders('auto_archiveBudget', version) }),
87
+ },
88
+ /** Rules that tighten every authority check (deny, or escalate to a named position). */
89
+ policies: {
90
+ get: (policy) => client.request('auto_getPolicy', { policy }),
91
+ update: (policy, version, body) => client.request('auto_updatePolicy', { policy, body }, { headers: ifMatchHeaders('auto_updatePolicy', version) }),
92
+ archive: (policy, version) => client.request('auto_archivePolicy', { policy }, { headers: ifMatchHeaders('auto_archivePolicy', version) }),
93
+ },
94
+ /** The meetings, reviews and reports the org keeps. Auto keeps the schedule and the record; it never holds the meeting. */
95
+ cadences: {
96
+ get: (cadence) => client.request('auto_getCadence', { cadence }),
97
+ update: (cadence, version, body) => client.request('auto_updateCadence', { cadence, body }, { headers: ifMatchHeaders('auto_updateCadence', version) }),
98
+ archive: (cadence, version) => client.request('auto_archiveCadence', { cadence }, { headers: ifMatchHeaders('auto_archiveCadence', version) }),
99
+ occurrences: (cadence, limit) => client.request('auto_listCadenceOccurrences', limit === undefined ? { cadence } : { cadence, limit }),
100
+ /** Record that the occurrence was held or skipped; the cadence moves to its next slot. */
101
+ record: (cadence, body) => client.request('auto_recordCadenceOccurrence', { cadence, body }),
102
+ },
103
+ credentials: {
104
+ get: (credential) => client.request('auto_getCredential', { credential }),
105
+ /** Public (no credential sent): the status any verifier reads from a credential's `credentialStatus` URL. */
106
+ status: (credential) => client.request('auto_getCredentialStatus', { credential }),
107
+ revoke: (credential, reason) => client.request('auto_revokeCredential', { credential, body: reason === undefined ? {} : { reason } }),
108
+ },
109
+ /** Public (no credential sent): Auto's signing keys and DID document, to verify receipts and credentials offline. */
110
+ keys: {
111
+ jwks: () => client.request('auto_getJwks'),
112
+ did: () => client.request('auto_getDidDocument'),
113
+ },
114
+ mandates: {
115
+ get: (mandate) => client.request('auto_getMandate', { mandate }),
116
+ update: (mandate, version, body) => client.request('auto_updateMandate', { mandate, body }, { headers: ifMatchHeaders('auto_updateMandate', version) }),
117
+ archive: (mandate, version) => client.request('auto_archiveMandate', { mandate }, { headers: ifMatchHeaders('auto_archiveMandate', version) }),
118
+ propose: (mandate, body) => client.request('auto_proposeAction', { mandate, body }),
119
+ },
120
+ approvals: {
121
+ get: (approval) => client.request('auto_getApproval', { approval }),
122
+ decide: (approval, body) => client.request('auto_decideApproval', { approval, body }),
123
+ },
124
+ };
125
+ }
@@ -0,0 +1,145 @@
1
+ import type { GenesisClient } from './client.js';
2
+ import type { OperationInput, OperationOutput } from './types.js';
3
+ type DashboardOptions = {
4
+ signal?: AbortSignal;
5
+ };
6
+ type PolicyConfig = OperationInput<'beacons_updateDashboardPolicy'>['body']['config'];
7
+ /** Configuration-record families Genesis admits (beacons-api native_resources.rs). */
8
+ export declare const BEACONS_RESOURCE_FAMILIES: readonly ["gateways", "private-gateways", "sims"];
9
+ export type BeaconsResourceFamily = typeof BEACONS_RESOURCE_FAMILIES[number];
10
+ type ResourceCreate = OperationInput<'beacons_createDashboardResource'>['body'];
11
+ type ResourceUpdate = OperationInput<'beacons_updateDashboardResource'>['body'];
12
+ /** Platforms with a Beacons agent client profile; the gateway and Beacons admit only these. */
13
+ export declare const BEACONS_CLIENT_PLATFORMS: readonly ["linux", "macos", "windows", "ios", "android"];
14
+ export type BeaconsClientPlatform = typeof BEACONS_CLIENT_PLATFORMS[number];
15
+ /** Beacons uses the authenticated Genesis organization; never supply an org header. */
16
+ export declare function beaconsModule(client: GenesisClient): {
17
+ fleets: {
18
+ /** Current human-authorized selected Sandbox scope; no caller tenant identifiers. */
19
+ list: (options?: DashboardOptions) => Promise<{
20
+ data: import("./index.js").components["schemas"]["Beacons.DashboardFleet"][];
21
+ }>;
22
+ update: (id: string, body: {
23
+ name: string;
24
+ }, options?: DashboardOptions) => Promise<{
25
+ data: import("./index.js").components["schemas"]["Beacons.DashboardFleet"];
26
+ }>;
27
+ peers: (id: string, options?: DashboardOptions) => Promise<{
28
+ data: import("./index.js").components["schemas"]["Beacons.DashboardPeer"][];
29
+ }>;
30
+ /** One peer's tunnel config: other live peers' public keys; never a private key. */
31
+ wireguardConfig: (id: string, peerId: string, options?: DashboardOptions) => Promise<{
32
+ data: import("./index.js").components["schemas"]["Beacons.DashboardWireguardConfig"];
33
+ }>;
34
+ /** One fleet in the current selection; 404 when it is outside it. */
35
+ get: (id: string, options?: DashboardOptions) => Promise<{
36
+ data: import("./index.js").components["schemas"]["Beacons.DashboardFleet"];
37
+ }>;
38
+ /** Mesh DNS map: one A record per live peer. */
39
+ dns: (id: string, options?: DashboardOptions) => Promise<{
40
+ data: import("./index.js").components["schemas"]["Beacons.DashboardDnsMap"];
41
+ }>;
42
+ /** Mesh discovery map: live peers' public keys and routes, DNS, signal and relay map. */
43
+ discovery: (id: string, options?: DashboardOptions) => Promise<{
44
+ data: import("./index.js").components["schemas"]["Beacons.DashboardDiscoveryMap"];
45
+ }>;
46
+ /** beacons-agent profile for one platform: API origin, DNS suffix and command line. */
47
+ clientProfile: (id: string, platform: BeaconsClientPlatform, options?: DashboardOptions) => Promise<{
48
+ data: import("./index.js").components["schemas"]["Beacons.DashboardClientProfile"];
49
+ }>;
50
+ policy: {
51
+ get: (id: string, options?: DashboardOptions) => Promise<{
52
+ data: {
53
+ fleet_id: string;
54
+ config: import("./index.js").components["schemas"]["Beacons.DashboardPolicyConfig"];
55
+ source: "default" | "persisted";
56
+ updated_at: string | null;
57
+ scope: import("./index.js").components["schemas"]["Beacons.DashboardScope"];
58
+ };
59
+ }>;
60
+ /** Future device admissions only; this never grants IAM rights or revokes an existing peer. */
61
+ update: (id: string, config: PolicyConfig, options?: DashboardOptions) => Promise<{
62
+ data: {
63
+ fleet_id: string;
64
+ config: import("./index.js").components["schemas"]["Beacons.DashboardPolicyConfig"];
65
+ source: "default" | "persisted";
66
+ updated_at: string | null;
67
+ scope: import("./index.js").components["schemas"]["Beacons.DashboardScope"];
68
+ };
69
+ }>;
70
+ };
71
+ /** Fleet configuration records (gateways, private-gateways, sims). Configuration only: nothing is provisioned or connected. */
72
+ resources: {
73
+ list: (id: string, kind: BeaconsResourceFamily, options?: DashboardOptions) => Promise<{
74
+ data: import("./index.js").components["schemas"]["Beacons.DashboardResource"][];
75
+ }>;
76
+ /** Not idempotent: a retry after an interrupted response creates a second record. */
77
+ create: (id: string, kind: BeaconsResourceFamily, body: ResourceCreate, options?: DashboardOptions) => Promise<{
78
+ data: import("./index.js").components["schemas"]["Beacons.DashboardResource"];
79
+ }>;
80
+ update: (id: string, kind: BeaconsResourceFamily, resourceId: string, body: ResourceUpdate, options?: DashboardOptions) => Promise<{
81
+ data: import("./index.js").components["schemas"]["Beacons.DashboardResource"];
82
+ }>;
83
+ delete: (id: string, kind: BeaconsResourceFamily, resourceId: string, options?: DashboardOptions) => Promise<void>;
84
+ };
85
+ /** Reuse the same request ID and body after an interrupted response. Creates metadata only. */
86
+ provision: (requestId: string, body?: {
87
+ name?: string;
88
+ }) => Promise<{
89
+ data: {
90
+ fleet_id: string;
91
+ organization_id: string;
92
+ workspace_id: string;
93
+ project_id: string;
94
+ environment_id: string;
95
+ metadata_only: true;
96
+ };
97
+ }>;
98
+ };
99
+ devices: {
100
+ revocations: (id: string) => Promise<{
101
+ data: import("./index.js").components["schemas"]["Beacons.DeviceRevocation"][];
102
+ }>;
103
+ acknowledge: (id: string, version: number, body: OperationInput<"beacons_acknowledgeBridgeDeviceRevocation">["body"]) => Promise<{
104
+ data: import("./index.js").components["schemas"]["Beacons.DeviceRevocation"];
105
+ }>;
106
+ challenge: (body: OperationInput<"beacons_issueBridgeDeviceChallenge">["body"]) => Promise<{
107
+ version: 1;
108
+ id: string;
109
+ nonce: string;
110
+ issuer: string;
111
+ organization: string;
112
+ principal: string;
113
+ workspace: string;
114
+ project: string;
115
+ environment: string;
116
+ binding_revision: string;
117
+ transport: string;
118
+ fleet_id: string;
119
+ proof_key: string;
120
+ tunnel_key: string;
121
+ issued_at: number;
122
+ expires_at: number;
123
+ }>;
124
+ enroll: (body: OperationInput<"beacons_enrollBridgeDevice">["body"]) => Promise<{
125
+ device_id: string;
126
+ fleet_id: string;
127
+ mesh: {
128
+ [key: string]: unknown;
129
+ };
130
+ }>;
131
+ list: () => Promise<{
132
+ data?: import("./index.js").components["schemas"]["Beacons.BridgeDevice"][];
133
+ }>;
134
+ update: (id: string, body: OperationInput<"beacons_updateBridgeDevice">["body"]) => Promise<{
135
+ id: string;
136
+ org_id: string;
137
+ name: string;
138
+ nicknames: string[];
139
+ created_at: string;
140
+ status: string;
141
+ }>;
142
+ revoke: (id: string) => Promise<OperationOutput<"beacons_revokeBridgeDevice"> | undefined>;
143
+ };
144
+ };
145
+ export {};
@@ -0,0 +1,148 @@
1
+ import { GenesisError } from './errors.js';
2
+ function invalidDashboard(operationId) {
3
+ throw new GenesisError({ status: 0, type: 'invalid_request', operationId,
4
+ message: 'Provide a canonical fleet UUID and only the documented Beacons fields.' });
5
+ }
6
+ function fleetId(id, operationId) {
7
+ if (typeof id !== 'string' || id.length !== 36 || !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(id)
8
+ || id === '00000000-0000-0000-0000-000000000000')
9
+ invalidDashboard(operationId);
10
+ return id;
11
+ }
12
+ function renameInput(body) {
13
+ const op = 'beacons_updateDashboardFleet';
14
+ if (!body || typeof body !== 'object' || Array.isArray(body)
15
+ || Object.keys(body).length !== 1 || !Object.hasOwn(body, 'name'))
16
+ invalidDashboard(op);
17
+ const suppliedName = body.name;
18
+ if (typeof suppliedName !== 'string')
19
+ invalidDashboard(op);
20
+ const name = suppliedName.trim();
21
+ if (!name || new TextEncoder().encode(name).length > 128 || /[\u0000-\u001f\u007f-\u009f]/.test(name))
22
+ invalidDashboard(op);
23
+ return { name };
24
+ }
25
+ function policyInput(config) {
26
+ const op = 'beacons_updateDashboardPolicy';
27
+ if (!config || typeof config !== 'object' || Array.isArray(config)
28
+ || Object.keys(config).some(key => !['device_enrollment', 'max_devices'].includes(key))
29
+ || !Object.hasOwn(config, 'device_enrollment'))
30
+ invalidDashboard(op);
31
+ const mode = config.device_enrollment;
32
+ const limit = config.max_devices;
33
+ if (!['allowed_with_permission', 'paused'].includes(mode)
34
+ || (limit !== undefined && (!Number.isInteger(limit) || limit < 1 || limit > 10000)))
35
+ invalidDashboard(op);
36
+ // Snapshot before the asynchronous credential provider can change the caller's object.
37
+ return { config: { device_enrollment: mode,
38
+ ...(limit === undefined ? {} : { max_devices: limit }) } };
39
+ }
40
+ /** Configuration-record families Genesis admits (beacons-api native_resources.rs). */
41
+ export const BEACONS_RESOURCE_FAMILIES = ['gateways', 'private-gateways', 'sims'];
42
+ const RESOURCE_STATUS = ['active', 'inactive', 'disabled', 'pending'];
43
+ function family(value, operationId) {
44
+ if (!BEACONS_RESOURCE_FAMILIES.includes(value))
45
+ invalidDashboard(operationId);
46
+ return value;
47
+ }
48
+ function plainObject(value) {
49
+ return !!value && typeof value === 'object' && !Array.isArray(value);
50
+ }
51
+ /** A shallow snapshot of the documented fields; the receiver validates every value. */
52
+ function resourceBody(value, operationId, create) {
53
+ if (!plainObject(value))
54
+ invalidDashboard(operationId);
55
+ const keys = Object.keys(value);
56
+ if (keys.some(key => !['name', 'status', 'config'].includes(key)) || (create ? keys.length !== 3 : keys.length === 0))
57
+ invalidDashboard(operationId);
58
+ const out = {};
59
+ if (Object.hasOwn(value, 'name')) {
60
+ if (typeof value.name !== 'string')
61
+ invalidDashboard(operationId);
62
+ const name = value.name.trim();
63
+ if (!name || new TextEncoder().encode(name).length > 128 || /[\u0000-\u001f\u007f-\u009f]/.test(name))
64
+ invalidDashboard(operationId);
65
+ out.name = name;
66
+ }
67
+ if (Object.hasOwn(value, 'status')) {
68
+ if (typeof value.status !== 'string' || !RESOURCE_STATUS.includes(value.status))
69
+ invalidDashboard(operationId);
70
+ out.status = value.status;
71
+ }
72
+ if (Object.hasOwn(value, 'config')) {
73
+ if (!plainObject(value.config) || Object.values(value.config).some(v => v === null || v === undefined))
74
+ invalidDashboard(operationId);
75
+ out.config = JSON.parse(JSON.stringify(value.config));
76
+ }
77
+ return out;
78
+ }
79
+ function provisioningInput(requestId, body) {
80
+ if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(requestId)
81
+ || requestId === '00000000-0000-0000-0000-000000000000'
82
+ || !body || typeof body !== 'object' || Array.isArray(body)
83
+ || Object.keys(body).some(key => key !== 'name')
84
+ || (body.name !== undefined && (typeof body.name !== 'string' || !body.name.trim()
85
+ || new TextEncoder().encode(body.name).length > 256 || /[\u0000-\u001f\u007f-\u009f]/.test(body.name)))) {
86
+ throw new GenesisError({ status: 0, type: 'invalid_request', operationId: 'beacons_provisionBridgeFleet', message: 'Provide a nonzero UUID request ID and an optional fleet name of up to 256 UTF-8 bytes.' });
87
+ }
88
+ return body.name === undefined ? {} : { name: body.name };
89
+ }
90
+ /** Platforms with a Beacons agent client profile; the gateway and Beacons admit only these. */
91
+ export const BEACONS_CLIENT_PLATFORMS = ['linux', 'macos', 'windows', 'ios', 'android'];
92
+ /** Beacons uses the authenticated Genesis organization; never supply an org header. */
93
+ export function beaconsModule(client) {
94
+ return {
95
+ fleets: {
96
+ /** Current human-authorized selected Sandbox scope; no caller tenant identifiers. */
97
+ list: (options = {}) => client.request('beacons_listDashboardFleets', {}, options),
98
+ update: (id, body, options = {}) => client.request('beacons_updateDashboardFleet', { fleet_id: fleetId(id, 'beacons_updateDashboardFleet'), body: renameInput(body) }, options),
99
+ peers: (id, options = {}) => client.request('beacons_listDashboardPeers', { fleet_id: fleetId(id, 'beacons_listDashboardPeers') }, options),
100
+ /** One peer's tunnel config: other live peers' public keys; never a private key. */
101
+ wireguardConfig: (id, peerId, options = {}) => client.request('beacons_getDashboardPeerWireguardConfig', { fleet_id: fleetId(id, 'beacons_getDashboardPeerWireguardConfig'),
102
+ peer_id: fleetId(peerId, 'beacons_getDashboardPeerWireguardConfig') }, options),
103
+ /** One fleet in the current selection; 404 when it is outside it. */
104
+ get: (id, options = {}) => client.request('beacons_getDashboardFleet', { fleet_id: fleetId(id, 'beacons_getDashboardFleet') }, options),
105
+ /** Mesh DNS map: one A record per live peer. */
106
+ dns: (id, options = {}) => client.request('beacons_getDashboardFleetDns', { fleet_id: fleetId(id, 'beacons_getDashboardFleetDns') }, options),
107
+ /** Mesh discovery map: live peers' public keys and routes, DNS, signal and relay map. */
108
+ discovery: (id, options = {}) => client.request('beacons_getDashboardFleetDiscovery', { fleet_id: fleetId(id, 'beacons_getDashboardFleetDiscovery') }, options),
109
+ /** beacons-agent profile for one platform: API origin, DNS suffix and command line. */
110
+ clientProfile: (id, platform, options = {}) => {
111
+ const op = 'beacons_getDashboardClientProfile';
112
+ if (!BEACONS_CLIENT_PLATFORMS.includes(platform))
113
+ invalidDashboard(op);
114
+ return client.request(op, { fleet_id: fleetId(id, op), platform }, options);
115
+ },
116
+ policy: {
117
+ get: (id, options = {}) => client.request('beacons_getDashboardPolicy', { fleet_id: fleetId(id, 'beacons_getDashboardPolicy') }, options),
118
+ /** Future device admissions only; this never grants IAM rights or revokes an existing peer. */
119
+ update: (id, config, options = {}) => client.request('beacons_updateDashboardPolicy', { fleet_id: fleetId(id, 'beacons_updateDashboardPolicy'), body: policyInput(config) }, options),
120
+ },
121
+ /** Fleet configuration records (gateways, private-gateways, sims). Configuration only: nothing is provisioned or connected. */
122
+ resources: {
123
+ list: (id, kind, options = {}) => client.request('beacons_listDashboardResources', { fleet_id: fleetId(id, 'beacons_listDashboardResources'),
124
+ family: family(kind, 'beacons_listDashboardResources') }, options),
125
+ /** Not idempotent: a retry after an interrupted response creates a second record. */
126
+ create: (id, kind, body, options = {}) => client.request('beacons_createDashboardResource', { fleet_id: fleetId(id, 'beacons_createDashboardResource'),
127
+ family: family(kind, 'beacons_createDashboardResource'), body: resourceBody(body, 'beacons_createDashboardResource', true) }, options),
128
+ update: (id, kind, resourceId, body, options = {}) => client.request('beacons_updateDashboardResource', { fleet_id: fleetId(id, 'beacons_updateDashboardResource'),
129
+ family: family(kind, 'beacons_updateDashboardResource'), resource_id: fleetId(resourceId, 'beacons_updateDashboardResource'),
130
+ body: resourceBody(body, 'beacons_updateDashboardResource', false) }, options),
131
+ delete: (id, kind, resourceId, options = {}) => client.request('beacons_deleteDashboardResource', { fleet_id: fleetId(id, 'beacons_deleteDashboardResource'),
132
+ family: family(kind, 'beacons_deleteDashboardResource'), resource_id: fleetId(resourceId, 'beacons_deleteDashboardResource') }, options)
133
+ .then(() => undefined),
134
+ },
135
+ /** Reuse the same request ID and body after an interrupted response. Creates metadata only. */
136
+ provision: (requestId, body = {}) => client.request('beacons_provisionBridgeFleet', { body: provisioningInput(requestId, body) }, { headers: { 'idempotency-key': requestId } }),
137
+ },
138
+ devices: {
139
+ revocations: (id) => client.request('beacons_listBridgeDeviceRevocations', { id }),
140
+ acknowledge: (id, version, body) => client.request('beacons_acknowledgeBridgeDeviceRevocation', { id, version, body }),
141
+ challenge: (body) => client.request('beacons_issueBridgeDeviceChallenge', { body }),
142
+ enroll: (body) => client.request('beacons_enrollBridgeDevice', { body }),
143
+ list: () => client.request('beacons_listBridgeDevices'),
144
+ update: (id, body) => client.request('beacons_updateBridgeDevice', { id, body }),
145
+ revoke: (id) => client.request('beacons_revokeBridgeDevice', { id }),
146
+ },
147
+ };
148
+ }