@onesi/genesis 0.1.13 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +1 -1
  2. package/dist/auto.d.ts +1010 -0
  3. package/dist/auto.js +125 -0
  4. package/dist/beacons.d.ts +42 -0
  5. package/dist/beacons.js +71 -0
  6. package/dist/blinds-owner-enrollment.d.ts +121 -0
  7. package/dist/blinds-owner-enrollment.js +23 -2
  8. package/dist/boxes.d.ts +1074 -0
  9. package/dist/boxes.js +338 -0
  10. package/dist/client.d.ts +3 -19947
  11. package/dist/client.js +127 -18
  12. package/dist/errors.d.ts +6 -0
  13. package/dist/errors.js +38 -3
  14. package/dist/flares.d.ts +32 -0
  15. package/dist/flares.js +5 -0
  16. package/dist/fleets.d.ts +32 -0
  17. package/dist/fleets.js +59 -6
  18. package/dist/flocks.d.ts +334 -1
  19. package/dist/flocks.js +85 -0
  20. package/dist/foundry.d.ts +429 -0
  21. package/dist/foundry.js +135 -0
  22. package/dist/garden.d.ts +754 -0
  23. package/dist/garden.js +76 -0
  24. package/dist/gateway.d.ts +365 -0
  25. package/dist/gateway.js +82 -0
  26. package/dist/gears.d.ts +121 -2
  27. package/dist/gears.js +24 -2
  28. package/dist/generated/operations.d.ts +3 -19948
  29. package/dist/generated/operations.js +64214 -13423
  30. package/dist/generated/schema.d.ts +85708 -17364
  31. package/dist/genesis.d.ts +9041 -1250
  32. package/dist/genesis.js +92 -25
  33. package/dist/genesis.openapi.json +133172 -31267
  34. package/dist/henry.d.ts +202 -1
  35. package/dist/henry.js +223 -0
  36. package/dist/hives-cells.d.ts +8 -3
  37. package/dist/hives-cells.js +17 -4
  38. package/dist/hives-environment.d.ts +9 -0
  39. package/dist/hives-environment.js +22 -0
  40. package/dist/hives-node.js +4 -1
  41. package/dist/hives-operations.d.ts +121 -3
  42. package/dist/hives-operations.js +2 -0
  43. package/dist/hives-platform.d.ts +149 -0
  44. package/dist/hives-platform.js +183 -0
  45. package/dist/hives-resources-transport.d.ts +7 -1
  46. package/dist/hives-resources-transport.js +10 -2
  47. package/dist/hives-sse.d.ts +24 -0
  48. package/dist/hives-sse.js +111 -0
  49. package/dist/hives-topics.d.ts +4 -3
  50. package/dist/hives-topics.js +9 -4
  51. package/dist/iam-directory.d.ts +8 -0
  52. package/dist/iam-directory.js +23 -0
  53. package/dist/iam.d.ts +397 -0
  54. package/dist/iam.js +92 -0
  55. package/dist/idempotency.d.ts +3 -0
  56. package/dist/idempotency.js +27 -0
  57. package/dist/index.d.ts +22 -6
  58. package/dist/index.js +19 -5
  59. package/dist/instances.d.ts +177 -2
  60. package/dist/instances.js +37 -5
  61. package/dist/minds-agent.d.ts +28 -0
  62. package/dist/minds-agent.js +53 -10
  63. package/dist/minds-engine.d.ts +394 -0
  64. package/dist/minds-engine.js +555 -0
  65. package/dist/minds.d.ts +109 -1
  66. package/dist/minds.js +49 -14
  67. package/dist/orgs.d.ts +405 -0
  68. package/dist/orgs.js +63 -0
  69. package/dist/redact.d.ts +37 -0
  70. package/dist/redact.js +330 -0
  71. package/dist/runner.d.ts +4 -0
  72. package/dist/runner.js +1 -0
  73. package/dist/scopes.d.ts +316 -0
  74. package/dist/scopes.js +40 -0
  75. package/dist/taps.d.ts +118 -0
  76. package/dist/taps.js +45 -0
  77. package/dist/traces.d.ts +574 -0
  78. package/dist/traces.js +97 -0
  79. package/dist/types.d.ts +12 -1
  80. package/package.json +1 -1
@@ -0,0 +1,111 @@
1
+ import { GenesisError } from './errors.js';
2
+ const bound = (value, fallback, max, name) => {
3
+ if (value === undefined)
4
+ return fallback;
5
+ if (!Number.isInteger(value) || value < 1 || value > max) {
6
+ throw new GenesisError({ status: 0, type: 'invalid_request', message: `${name} must be an integer from 1 to ${max}.` });
7
+ }
8
+ return value;
9
+ };
10
+ function parse(lines) {
11
+ let event = 'message';
12
+ let id;
13
+ const data = [];
14
+ for (const line of lines) {
15
+ if (!line || line.startsWith(':'))
16
+ continue; // comments carry keepalives only
17
+ const colon = line.indexOf(':');
18
+ const field = colon < 0 ? line : line.slice(0, colon);
19
+ let value = colon < 0 ? '' : line.slice(colon + 1);
20
+ if (value.startsWith(' '))
21
+ value = value.slice(1);
22
+ if (field === 'event')
23
+ event = value;
24
+ else if (field === 'id')
25
+ id = value;
26
+ else if (field === 'data')
27
+ data.push(value);
28
+ }
29
+ if (!data.length)
30
+ return undefined;
31
+ const text = data.join('\n');
32
+ let value = text;
33
+ try {
34
+ value = JSON.parse(text);
35
+ }
36
+ catch { /* keepalive text such as "ping" */ }
37
+ return { event, ...(id === undefined ? {} : { id }), data: value };
38
+ }
39
+ /**
40
+ * Read one bounded window of a Server-Sent Events response (for example
41
+ * `await genesis.raw('hives_stream_deployment_logs', {...})`) and close the connection.
42
+ * Never buffers the whole body: an SSE stream does not end on its own.
43
+ */
44
+ export async function hivesSseWindow(response, options = {}) {
45
+ const maxEvents = bound(options.maxEvents, 100, 1000, 'maxEvents');
46
+ const seconds = bound(options.seconds, 10, 15, 'seconds');
47
+ const reader = response.body?.getReader();
48
+ const events = [];
49
+ if (!reader)
50
+ return { events, ended: 'closed' };
51
+ const decoder = new TextDecoder();
52
+ let buffer = '';
53
+ let lines = [];
54
+ let ended;
55
+ const stop = (why) => { ended ??= why; void reader.cancel().catch(() => { }); };
56
+ const timer = setTimeout(() => stop('time'), seconds * 1000);
57
+ const abort = () => stop('aborted');
58
+ options.signal?.addEventListener('abort', abort, { once: true });
59
+ if (options.signal?.aborted)
60
+ abort();
61
+ try {
62
+ while (!ended) {
63
+ let chunk;
64
+ try {
65
+ chunk = await reader.read();
66
+ }
67
+ catch (error) {
68
+ if (ended)
69
+ break;
70
+ throw error;
71
+ }
72
+ if (ended)
73
+ break;
74
+ if (chunk.done) {
75
+ buffer += decoder.decode();
76
+ ended = 'closed';
77
+ }
78
+ else
79
+ buffer += decoder.decode(chunk.value, { stream: true });
80
+ let index;
81
+ while ((index = buffer.search(/\r\n|\r|\n/)) >= 0) {
82
+ const line = buffer.slice(0, index);
83
+ buffer = buffer.slice(index + (buffer.startsWith('\r\n', index) ? 2 : 1));
84
+ if (line !== '') {
85
+ lines.push(line);
86
+ continue;
87
+ }
88
+ const event = parse(lines);
89
+ lines = [];
90
+ if (event)
91
+ events.push(event);
92
+ if (events.length >= maxEvents) {
93
+ stop('max_events');
94
+ break;
95
+ }
96
+ }
97
+ if (ended === 'closed' && events.length < maxEvents) {
98
+ const tail = parse(buffer ? [...lines, buffer] : lines);
99
+ if (tail)
100
+ events.push(tail);
101
+ }
102
+ }
103
+ }
104
+ finally {
105
+ clearTimeout(timer);
106
+ options.signal?.removeEventListener('abort', abort);
107
+ if (ended !== 'closed')
108
+ void reader.cancel().catch(() => { });
109
+ }
110
+ return { events, ended: ended ?? 'closed' };
111
+ }
@@ -1,5 +1,5 @@
1
1
  import type { GenesisClient } from './client.js';
2
- import { type HivesResourceOptions } from './hives-resources-transport.js';
2
+ import { type HivesFundedWriteOptions, type HivesResourceOptions } from './hives-resources-transport.js';
3
3
  export interface HivesTopic {
4
4
  id: string;
5
5
  projectId: string;
@@ -46,6 +46,7 @@ export declare function hivesTopics(client: GenesisClient): {
46
46
  deleted: true;
47
47
  }>;
48
48
  };
49
- /** Persists one delivery per subscription atomically. Never retried after an unknown outcome. */
50
- publish(project: string, id: string, body: HivesTopicPublish, options?: HivesResourceOptions): Promise<HivesTopicPublication>;
49
+ /** Persists one delivery per subscription atomically. Never retried after an unknown outcome. Carries one
50
+ * Idempotency-Key (options.idempotencyKey, or a fresh one); reuse that key only to replay this publication. */
51
+ publish(project: string, id: string, body: HivesTopicPublish, options?: HivesFundedWriteOptions): Promise<HivesTopicPublication>;
51
52
  };
@@ -1,5 +1,5 @@
1
1
  import { hivesQueueBody } from './hives-queues.js';
2
- import { HIVES_QUEUE_BYTES, hivesResourceCall, hivesResourceId, resourceError } from './hives-resources-transport.js';
2
+ import { HIVES_QUEUE_BYTES, hivesFundedWriteHeaders, hivesResourceCall, hivesResourceId, resourceError } from './hives-resources-transport.js';
3
3
  const invalid = () => resourceError(0);
4
4
  const object = (v) => { if (!v || typeof v !== 'object' || Array.isArray(v))
5
5
  throw invalid(); return v; };
@@ -46,7 +46,7 @@ function publishInput(value) {
46
46
  }
47
47
  export function hivesTopics(client) {
48
48
  const ids = (project, id) => ({ project_id: hivesResourceId(project), ...(id === undefined ? {} : { topic_id: hivesResourceId(id) }) });
49
- const call = (operation, input, options, status = 200) => hivesResourceCall(client, operation, input, options, 'json', 2 * 1024 * 1024, 20_000, status);
49
+ const call = (operation, input, options, status = 200, headers) => hivesResourceCall(client, operation, input, options, 'json', 2 * 1024 * 1024, 20_000, status, headers && { headers });
50
50
  const removed = (value) => { if (object(value).deleted !== true)
51
51
  throw invalid(); return { deleted: true }; };
52
52
  return {
@@ -64,10 +64,15 @@ export function hivesTopics(client) {
64
64
  async add(project, id, queueId, options) { const queue = hivesResourceId(queueId); return subscription(await call('hives_subscribe_native_topic', { ...ids(project, id), body: { queueId: queue } }, options, 201), project, id, queue); },
65
65
  async remove(project, id, subscriptionId, options) { return removed(await call('hives_unsubscribe_native_topic', { ...ids(project, id), subscription_id: hivesResourceId(subscriptionId) }, options)); },
66
66
  },
67
- /** Persists one delivery per subscription atomically. Never retried after an unknown outcome. */
67
+ /** Persists one delivery per subscription atomically. Never retried after an unknown outcome. Carries one
68
+ * Idempotency-Key (options.idempotencyKey, or a fresh one); reuse that key only to replay this publication. */
68
69
  async publish(project, id, body, options) {
69
70
  publishInput(body);
70
- const v = object(await call('hives_publish_native_topic', { ...ids(project, id), body }, options, 201));
71
+ const headers = hivesFundedWriteHeaders(options, 'hives_publish_native_topic');
72
+ const v = object(await call('hives_publish_native_topic', { ...ids(project, id), body }, options, 201, headers));
73
+ // A funded publication answers with its settled operation receipt, which carries the same publication fields.
74
+ if (v.object !== undefined && (v.object !== 'pubsub_publish_operation' || v.state !== 'settled'))
75
+ throw invalid();
71
76
  if (!Array.isArray(v.deliveries) || v.deliveries.length > 32)
72
77
  throw invalid();
73
78
  const deliveries = v.deliveries.map(raw => { const d = object(raw); return { subscription_id: nativeId(d.subscription_id, 'sub'), queue_id: hivesResourceId(d.queue_id), message_id: hivesResourceId(d.message_id) }; });
@@ -0,0 +1,8 @@
1
+ export declare const iamDirectoryOperations: readonly string[];
2
+ export declare const isIamDirectoryOperation: (operationId: string) => boolean;
3
+ /**
4
+ * The actionable form of a directory refusal; any other error is returned unchanged. The gateway, not the client, exchanges
5
+ * the One account session for an organization context at Auth and forwards the short-lived child to IAM. The client sends
6
+ * one request, never changes a session or its selected context, and only explains what came back.
7
+ */
8
+ export declare function iamDirectoryFailure(e: unknown, org: string, operationId: string): unknown;
@@ -0,0 +1,23 @@
1
+ import { GenesisError, errorCatalog } from './errors.js';
2
+ /** The IAM v4 organization directory: projects and workspaces at /v1/iam/orgs/{org_id}/... */
3
+ const READS = ['iam_listProjects', 'iam_getProject', 'iam_listWorkspaces', 'iam_getWorkspace'];
4
+ const WRITES = ['iam_createProject', 'iam_updateProject', 'iam_deleteProject', 'iam_createWorkspace', 'iam_updateWorkspace', 'iam_deleteWorkspace'];
5
+ export const iamDirectoryOperations = [...READS, ...WRITES];
6
+ export const isIamDirectoryOperation = (operationId) => iamDirectoryOperations.includes(operationId);
7
+ const codeOf = (e) => errorCatalog(e).code?.toUpperCase();
8
+ /**
9
+ * The actionable form of a directory refusal; any other error is returned unchanged. The gateway, not the client, exchanges
10
+ * the One account session for an organization context at Auth and forwards the short-lived child to IAM. The client sends
11
+ * one request, never changes a session or its selected context, and only explains what came back.
12
+ */
13
+ export function iamDirectoryFailure(e, org, operationId) {
14
+ if (!(e instanceof GenesisError))
15
+ return e;
16
+ const keep = (message) => new GenesisError({ status: e.status, type: e.type, code: e.code, requestId: e.requestId, operationId, body: e.body, message });
17
+ const code = codeOf(e);
18
+ if (code === 'TENANT_REQUIRED')
19
+ return keep(`IAM sees no organization on your One account session for ${org}. Use the Console to manage projects and workspaces for now.`);
20
+ if (WRITES.includes(operationId) && code === 'SCOPE_MISSING' && errorCatalog(e).required_scope === 'iam:write')
21
+ return keep(`This credential cannot change projects and workspaces in ${org}: a login needs the organization owner or manager role in IAM, and an API key needs iam:write. Use the Console.`);
22
+ return e;
23
+ }
package/dist/iam.d.ts ADDED
@@ -0,0 +1,397 @@
1
+ import type { GenesisClient } from './client.js';
2
+ import type { OperationId } from './generated/operations.js';
3
+ import type { OperationInput } from './types.js';
4
+ type Body<K extends OperationId> = OperationInput<K> extends {
5
+ body?: infer B;
6
+ } ? NonNullable<B> : never;
7
+ type Query<K extends OperationId> = Omit<OperationInput<K>, 'body'>;
8
+ /**
9
+ * IAM v4 tenant operations at /v1/iam/... (iam.l1fe.ai). Use a One account login or an organization API key with iam:read
10
+ * (reads) or iam:write (changes). The gateway exchanges either at Auth for a short-lived IAM token and forwards only that;
11
+ * IAM decides authority (owner or manager for most changes). `org_id` must be your own organization.
12
+ *
13
+ * Inviting members, changing member roles, removing members, Mind API keys and enterprise settings are not here: they stay
14
+ * with a person in the Console. Projects and workspaces are `genesis.projects` and `genesis.workspaces`.
15
+ */
16
+ export declare function iamModule(client: GenesisClient): {
17
+ orgs: {
18
+ list: (query?: Query<"iam_listOrgs">) => Promise<{
19
+ items: import("./index.js").components["schemas"]["Iam.Organization"][];
20
+ next_cursor?: string | null;
21
+ }>;
22
+ get: (org_id: string) => Promise<{
23
+ id: string;
24
+ name: string;
25
+ slug: string;
26
+ owner_human_principal_id?: string;
27
+ metadata?: {
28
+ [key: string]: unknown;
29
+ };
30
+ created_at: number;
31
+ role?: string;
32
+ }>;
33
+ update: (org_id: string, body: Body<"iam_updateOrg">) => Promise<{
34
+ id: string;
35
+ name: string;
36
+ slug: string;
37
+ owner_human_principal_id?: string;
38
+ metadata?: {
39
+ [key: string]: unknown;
40
+ };
41
+ created_at: number;
42
+ role?: string;
43
+ }>;
44
+ members: (org_id: string, query?: Omit<Query<"iam_listMembers">, "org_id">) => Promise<{
45
+ items: import("./index.js").components["schemas"]["Iam.Member"][];
46
+ total?: number;
47
+ nextCursor?: string | null;
48
+ complete?: boolean;
49
+ canManageMembers?: boolean;
50
+ }>;
51
+ entitlements: (org_id: string, environment_id?: "live" | "sandbox") => Promise<{
52
+ items: import("./index.js").components["schemas"]["Iam.Entitlement"][];
53
+ next_cursor?: string | null;
54
+ snapshotVersion?: unknown;
55
+ snapshotGeneratedAt?: unknown;
56
+ snapshotValidUntil?: unknown;
57
+ environmentId?: string;
58
+ }>;
59
+ };
60
+ fleets: {
61
+ list: (org_id: string) => Promise<{
62
+ items: import("./index.js").components["schemas"]["Iam.Fleet"][];
63
+ next_cursor?: string | null;
64
+ }>;
65
+ get: (org_id: string, fleet_id: string) => Promise<{
66
+ id: string;
67
+ organizationId: string;
68
+ projectId?: string;
69
+ workspaceId?: string;
70
+ name: string;
71
+ slug: string;
72
+ metadata?: {
73
+ [key: string]: unknown;
74
+ };
75
+ createdAt: number;
76
+ updatedAt: number;
77
+ }>;
78
+ /** Reuse the same idempotencyKey to replay an uncertain create instead of making a second fleet. */
79
+ create: (org_id: string, body: Body<"iam_createFleet">, idempotencyKey: string) => Promise<{
80
+ id: string;
81
+ organizationId: string;
82
+ projectId?: string;
83
+ workspaceId?: string;
84
+ name: string;
85
+ slug: string;
86
+ metadata?: {
87
+ [key: string]: unknown;
88
+ };
89
+ createdAt: number;
90
+ updatedAt: number;
91
+ }>;
92
+ update: (org_id: string, fleet_id: string, body: Body<"iam_updateFleet">) => Promise<{
93
+ id: string;
94
+ organizationId: string;
95
+ projectId?: string;
96
+ workspaceId?: string;
97
+ name: string;
98
+ slug: string;
99
+ metadata?: {
100
+ [key: string]: unknown;
101
+ };
102
+ createdAt: number;
103
+ updatedAt: number;
104
+ }>;
105
+ /** Permanent; IAM refuses while grants reference the fleet. */
106
+ delete: (org_id: string, fleet_id: string) => Promise<void>;
107
+ };
108
+ agents: {
109
+ list: (org_id: string) => Promise<{
110
+ items: import("./index.js").components["schemas"]["Iam.Agent"][];
111
+ next_cursor?: string | null;
112
+ agents?: import("./index.js").components["schemas"]["Iam.Agent"][];
113
+ }>;
114
+ get: (org_id: string, agent_did: string) => Promise<{
115
+ agent: import("./index.js").components["schemas"]["Iam.Agent"];
116
+ }>;
117
+ /** Without `publicKey` IAM generates a key pair and returns `privateKey` once. */
118
+ create: (org_id: string, body: Body<"iam_createAgent">) => Promise<{
119
+ agent: import("./index.js").components["schemas"]["Iam.Agent"];
120
+ did: string;
121
+ publicKey?: string | null;
122
+ privateKey?: string | null;
123
+ }>;
124
+ /** Revokes the agent (status `revoked`); the record stays. */
125
+ delete: (org_id: string, agent_did: string) => Promise<{
126
+ agent: import("./index.js").components["schemas"]["Iam.Agent"];
127
+ }>;
128
+ suspend: (org_id: string, agent_did: string) => Promise<{
129
+ agent: import("./index.js").components["schemas"]["Iam.Agent"];
130
+ }>;
131
+ resume: (org_id: string, agent_did: string) => Promise<{
132
+ agent: import("./index.js").components["schemas"]["Iam.Agent"];
133
+ }>;
134
+ rotate: (org_id: string, agent_did: string, body?: Body<"iam_rotateAgentKey">) => Promise<{
135
+ did: string;
136
+ publicKey?: string | null;
137
+ privateKey?: string | null;
138
+ }>;
139
+ acts: {
140
+ list: (org_id: string, agent_did: string) => Promise<{
141
+ acts: {
142
+ [key: string]: unknown;
143
+ }[];
144
+ }>;
145
+ issue: (org_id: string, agent_did: string, body: Body<"iam_issueAgentAct">) => Promise<{
146
+ id: string;
147
+ act: string;
148
+ scopes: string[];
149
+ issuedAt: string;
150
+ expiresAt: string;
151
+ subjectDid: string;
152
+ }>;
153
+ };
154
+ publication: (org_id: string, agent_id: string) => Promise<{
155
+ agentId: string;
156
+ state: "private" | "published" | "withdrawn";
157
+ version: number;
158
+ }>;
159
+ orbitMsgsGrant: (org_id: string, agent_id: string) => Promise<{
160
+ schemaVersion?: number;
161
+ requestId?: string;
162
+ agentId: string;
163
+ organizationId: string;
164
+ profile?: string;
165
+ ownerGeneration?: number;
166
+ grant?: {
167
+ grantId?: string;
168
+ grantVersion?: number;
169
+ actions?: string[];
170
+ expiresAtMs?: number;
171
+ status?: "active" | "expired" | "revoked";
172
+ } | null;
173
+ }>;
174
+ /** A published agent's public card (anonymous). */
175
+ publicCard: (agent_id: string) => Promise<{
176
+ schemaVersion?: number;
177
+ principalId: string;
178
+ kind: string;
179
+ publicationVersion?: number;
180
+ canonicalAgentDid?: string;
181
+ handle?: string | null;
182
+ handleStatus?: string;
183
+ contact?: {
184
+ [key: string]: unknown;
185
+ };
186
+ operatingCompany?: Record<string, never> | null;
187
+ }>;
188
+ /** Agents enrolled for a Mind with a currently valid credential. */
189
+ forMind: (org_id: string, mind_id: string) => Promise<{
190
+ items: {
191
+ agent: import("./index.js").components["schemas"]["Iam.Agent"];
192
+ mindId: string;
193
+ scopes?: string[];
194
+ sharedNamespaces?: string[];
195
+ credentialExpiresAt?: number;
196
+ }[];
197
+ }>;
198
+ enrollmentGrants: (org_id: string) => Promise<{
199
+ items: import("./index.js").components["schemas"]["Iam.AgentEnrollmentGrant"][];
200
+ }>;
201
+ /**
202
+ * Enroll an agent under an agent enrollment grant. Only the grant's enrollment key (`mek_...`) is sent, as the bearer;
203
+ * this client's own Genesis credential is not. The credential secret in the answer is returned once.
204
+ */
205
+ enroll: (enrollmentKey: string, body: Body<"iam_enrollAgent">) => Promise<{
206
+ agent: {
207
+ id: string;
208
+ did: string;
209
+ displayName?: string;
210
+ status?: string;
211
+ organizationId: string;
212
+ projectId?: string;
213
+ };
214
+ created: boolean;
215
+ credential: {
216
+ id: string;
217
+ secret: string;
218
+ mindId?: string;
219
+ scopes?: string[];
220
+ sharedNamespaces?: string[];
221
+ expiresAt?: number;
222
+ };
223
+ }>;
224
+ };
225
+ roles: {
226
+ list: (org_id: string) => Promise<{
227
+ items: import("./index.js").components["schemas"]["Iam.Role"][];
228
+ next_cursor?: string | null;
229
+ }>;
230
+ get: (org_id: string, role_id: string) => Promise<{
231
+ id: string;
232
+ organization_id?: string;
233
+ name: string;
234
+ description?: string;
235
+ permissions: string[];
236
+ metadata?: {
237
+ [key: string]: unknown;
238
+ };
239
+ }>;
240
+ create: (org_id: string, body: Body<"iam_createRole">) => Promise<{
241
+ id: string;
242
+ organization_id?: string;
243
+ name: string;
244
+ description?: string;
245
+ permissions: string[];
246
+ metadata?: {
247
+ [key: string]: unknown;
248
+ };
249
+ }>;
250
+ update: (org_id: string, role_id: string, body: Body<"iam_updateRole">) => Promise<{
251
+ id: string;
252
+ organization_id?: string;
253
+ name: string;
254
+ description?: string;
255
+ permissions: string[];
256
+ metadata?: {
257
+ [key: string]: unknown;
258
+ };
259
+ }>;
260
+ delete: (org_id: string, role_id: string) => Promise<void>;
261
+ };
262
+ grants: {
263
+ list: (query?: Query<"iam_listGrants">) => Promise<{
264
+ items: import("./index.js").components["schemas"]["Iam.Grant"][];
265
+ next_cursor?: string | null;
266
+ }>;
267
+ get: (grant_id: string) => Promise<{
268
+ id: string;
269
+ principal_id: string;
270
+ organization_id: string;
271
+ project_id?: string;
272
+ platform_id?: string;
273
+ workspace_id?: string;
274
+ environmentId?: "live" | "sandbox";
275
+ role_ids: string[];
276
+ permissions?: string[];
277
+ expires_at?: number;
278
+ metadata?: {
279
+ [key: string]: unknown;
280
+ };
281
+ created_at: number;
282
+ }>;
283
+ /** `organization_id` must be your organization. With an idempotencyKey a retry returns the original grant. */
284
+ create: (body: Body<"iam_createGrant">, idempotencyKey?: string) => Promise<{
285
+ id: string;
286
+ principal_id: string;
287
+ organization_id: string;
288
+ project_id?: string;
289
+ platform_id?: string;
290
+ workspace_id?: string;
291
+ environmentId?: "live" | "sandbox";
292
+ role_ids: string[];
293
+ permissions?: string[];
294
+ expires_at?: number;
295
+ metadata?: {
296
+ [key: string]: unknown;
297
+ };
298
+ created_at: number;
299
+ }>;
300
+ update: (grant_id: string, body: Body<"iam_updateGrant">) => Promise<{
301
+ id: string;
302
+ principal_id: string;
303
+ organization_id: string;
304
+ project_id?: string;
305
+ platform_id?: string;
306
+ workspace_id?: string;
307
+ environmentId?: "live" | "sandbox";
308
+ role_ids: string[];
309
+ permissions?: string[];
310
+ expires_at?: number;
311
+ metadata?: {
312
+ [key: string]: unknown;
313
+ };
314
+ created_at: number;
315
+ }>;
316
+ delete: (grant_id: string) => Promise<void>;
317
+ };
318
+ capabilities: {
319
+ get: (capability_id: string) => Promise<{
320
+ id: string;
321
+ issuer_principal_id: string;
322
+ subject_principal_id: string;
323
+ organization_id: string;
324
+ permissions: string[];
325
+ constraints: import("./index.js").components["schemas"]["Iam.CapabilityConstraints"];
326
+ created_at: number;
327
+ revoked_at?: number;
328
+ revoke_reason?: string;
329
+ }>;
330
+ /** You are always the issuer; `organization_id` must be your organization. */
331
+ create: (body: Body<"iam_createCapability">, idempotencyKey?: string) => Promise<{
332
+ id: string;
333
+ issuer_principal_id: string;
334
+ subject_principal_id: string;
335
+ organization_id: string;
336
+ permissions: string[];
337
+ constraints: import("./index.js").components["schemas"]["Iam.CapabilityConstraints"];
338
+ created_at: number;
339
+ revoked_at?: number;
340
+ revoke_reason?: string;
341
+ }>;
342
+ update: (capability_id: string, body: Body<"iam_updateCapability">) => Promise<{
343
+ id: string;
344
+ issuer_principal_id: string;
345
+ subject_principal_id: string;
346
+ organization_id: string;
347
+ permissions: string[];
348
+ constraints: import("./index.js").components["schemas"]["Iam.CapabilityConstraints"];
349
+ created_at: number;
350
+ revoked_at?: number;
351
+ revoke_reason?: string;
352
+ }>;
353
+ /** Revoke (issuer only), with an optional recorded reason. */
354
+ delete: (capability_id: string, reason?: string) => Promise<void>;
355
+ verify: (body: Body<"iam_verifyCapability">) => Promise<{
356
+ valid: boolean;
357
+ grant?: import("./index.js").components["schemas"]["Iam.Capability"];
358
+ reason_invalid?: "expired" | "revoked" | "scope_mismatch" | "tenant_mismatch" | "not_found";
359
+ }>;
360
+ };
361
+ platforms: () => Promise<{
362
+ items: import("./index.js").components["schemas"]["Iam.Platform"][];
363
+ next_cursor?: string | null;
364
+ }>;
365
+ tenantContext: () => Promise<{
366
+ organizationId: string;
367
+ projectId: string;
368
+ platformId: string;
369
+ workspaceId?: string;
370
+ fleetId?: string;
371
+ organizationName?: string;
372
+ environmentId?: string;
373
+ }>;
374
+ checkPermission: (body: Body<"iam_checkPermission">) => Promise<{
375
+ allowed: boolean;
376
+ evaluated_at?: number;
377
+ via?: string;
378
+ environmentId?: string;
379
+ }>;
380
+ requirePermission: (body: Body<"iam_requirePermission">) => Promise<{
381
+ allowed: boolean;
382
+ evaluated_at?: number;
383
+ via?: string;
384
+ environmentId?: string;
385
+ }>;
386
+ checkEntitlement: (body: Body<"iam_checkEntitlement">) => Promise<{
387
+ key: string;
388
+ organization_id: string;
389
+ enabled: boolean;
390
+ quota?: number | null;
391
+ remaining?: number | null;
392
+ evaluated_at?: number;
393
+ source?: string;
394
+ environmentId?: string;
395
+ }>;
396
+ };
397
+ export {};