@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
package/dist/flocks.d.ts CHANGED
@@ -1,5 +1,17 @@
1
1
  import type { GenesisClient } from './client.js';
2
- import type { OperationInput } from './types.js';
2
+ import type { OperationInput, OperationOutput } from './types.js';
3
+ /** Options for account mutations. */
4
+ export interface FlocksWriteOptions {
5
+ signal?: AbortSignal;
6
+ }
7
+ export interface WaitForJobOptions {
8
+ intervalMs?: number;
9
+ timeoutMs?: number;
10
+ signal?: AbortSignal;
11
+ onUpdate?: (job: FlocksJob) => void;
12
+ }
13
+ export type FlocksJob = OperationOutput<'flocks_getAccountJob'>;
14
+ export type FlocksRun = OperationOutput<'flocks_getRun'>;
3
15
  /** Org scope comes from the One account credential verified by the gateway. */
4
16
  export declare function flocksModule(client: GenesisClient): {
5
17
  readiness: {
@@ -18,7 +30,18 @@ export declare function flocksModule(client: GenesisClient): {
18
30
  state: "enrolled" | "revoked";
19
31
  last_seen_at: number;
20
32
  enrolled_at: number;
33
+ labels?: {
34
+ [key: string]: string;
35
+ };
36
+ accounts?: import("./index.js").components["schemas"]["Flocks.HeartbeatAccount"][];
37
+ accounts_supported?: boolean;
21
38
  }[]>;
39
+ /** One node's presence (online, heartbeat age, harnesses) and a page of the runs recorded on it, newest first. */
40
+ activity: (id: string, query?: Omit<OperationInput<"flocks_getNodeActivity">, "id">) => Promise<{
41
+ node: import("./index.js").components["schemas"]["Flocks.NodePresence"];
42
+ items: import("./index.js").components["schemas"]["Flocks.Run"][];
43
+ next_cursor: string | null;
44
+ }>;
22
45
  rename: (id: string, nickname: string) => Promise<{
23
46
  id: string;
24
47
  name: string;
@@ -28,6 +51,27 @@ export declare function flocksModule(client: GenesisClient): {
28
51
  state: "enrolled" | "revoked";
29
52
  last_seen_at: number;
30
53
  enrolled_at: number;
54
+ labels?: {
55
+ [key: string]: string;
56
+ };
57
+ accounts?: import("./index.js").components["schemas"]["Flocks.HeartbeatAccount"][];
58
+ accounts_supported?: boolean;
59
+ }>;
60
+ /** Set an instance nickname and/or labels (the label key `flock` groups instances). */
61
+ update: (id: string, body: OperationInput<"flocks_renameNode">["body"]) => Promise<{
62
+ id: string;
63
+ name: string;
64
+ nickname: string;
65
+ platform: string;
66
+ cpu_count: number;
67
+ state: "enrolled" | "revoked";
68
+ last_seen_at: number;
69
+ enrolled_at: number;
70
+ labels?: {
71
+ [key: string]: string;
72
+ };
73
+ accounts?: import("./index.js").components["schemas"]["Flocks.HeartbeatAccount"][];
74
+ accounts_supported?: boolean;
31
75
  }>;
32
76
  revoke: (id: string) => Promise<{
33
77
  id: string;
@@ -38,6 +82,11 @@ export declare function flocksModule(client: GenesisClient): {
38
82
  state: "enrolled" | "revoked";
39
83
  last_seen_at: number;
40
84
  enrolled_at: number;
85
+ labels?: {
86
+ [key: string]: string;
87
+ };
88
+ accounts?: import("./index.js").components["schemas"]["Flocks.HeartbeatAccount"][];
89
+ accounts_supported?: boolean;
41
90
  }>;
42
91
  heartbeat: (id: string, nodeBinding: string) => Promise<{
43
92
  accepted: boolean;
@@ -119,6 +168,34 @@ export declare function flocksModule(client: GenesisClient): {
119
168
  expiresAtMs: number;
120
169
  }>;
121
170
  };
171
+ /** Your recent agent sessions and events; needs a signed-in session (the gateway forwards the human bearer for this read only). */
172
+ activity: {
173
+ get: () => Promise<{
174
+ sessions: ({
175
+ session_id: string;
176
+ agent_id?: string;
177
+ provider: string;
178
+ title?: string;
179
+ status: string;
180
+ roost_url?: string;
181
+ updated_at: string;
182
+ } & {
183
+ [key: string]: unknown;
184
+ })[];
185
+ events: ({
186
+ event_id: string;
187
+ session_id?: string;
188
+ provider: string;
189
+ type: string;
190
+ text: string;
191
+ login_url?: string;
192
+ login_code?: string;
193
+ created_at: string;
194
+ } & {
195
+ [key: string]: unknown;
196
+ })[];
197
+ }>;
198
+ };
122
199
  runs: {
123
200
  list: (query?: OperationInput<"flocks_listRuns">) => Promise<{
124
201
  items: import("./index.js").components["schemas"]["Flocks.Run"][];
@@ -135,7 +212,34 @@ export declare function flocksModule(client: GenesisClient): {
135
212
  owner_subject?: string;
136
213
  created_at: number;
137
214
  updated_at: number;
215
+ inference_account_id: string | null;
216
+ account_owner_org: string | null;
217
+ grantee_org: string | null;
218
+ run_seconds: number | null;
219
+ }>;
220
+ /** Starts a run of an agent (202 Run). `node_id` overrides the agent's pinned node for this run. */
221
+ create: (agent_id: string, body: OperationInput<"flocks_createRun">["body"], o?: {
222
+ signal?: AbortSignal;
223
+ }) => Promise<{
224
+ id: string;
225
+ agent_id: string;
226
+ harness: string;
227
+ node_id: string | null;
228
+ task: string;
229
+ state: "pending" | "running" | "completed" | "failed";
230
+ error_code: string | null;
231
+ owner_subject?: string;
232
+ created_at: number;
233
+ updated_at: number;
234
+ inference_account_id: string | null;
235
+ account_owner_org: string | null;
236
+ grantee_org: string | null;
237
+ run_seconds: number | null;
138
238
  }>;
239
+ /** Polls a run until it is completed or failed. Rejects with a timeout error after `timeoutMs` (default 30 minutes). */
240
+ wait: (run_id: string, o?: WaitForJobOptions & {
241
+ onUpdate?: (run: FlocksRun) => void;
242
+ }) => Promise<FlocksRun>;
139
243
  };
140
244
  joinTokens: {
141
245
  exchange: (body: OperationInput<"flocks_exchangeJoinToken">["body"]) => Promise<{
@@ -152,4 +256,233 @@ export declare function flocksModule(client: GenesisClient): {
152
256
  expires_at: number;
153
257
  }>;
154
258
  };
259
+ /** Providers (claude, codex) with the login kinds each supports and plain guidance on which plans fit sharing one login. */
260
+ providers: {
261
+ list: () => Promise<{
262
+ items: import("./index.js").components["schemas"]["Flocks.Provider"][];
263
+ }>;
264
+ };
265
+ /** Inference accounts your org owns, plus accounts granted to it. The service never returns a credential. */
266
+ accounts: {
267
+ list: (query?: OperationInput<"flocks_listAccounts">) => Promise<{
268
+ items: import("./index.js").components["schemas"]["Flocks.Account"][];
269
+ next_cursor: string | null;
270
+ }>;
271
+ create: (body: OperationInput<"flocks_createAccount">["body"], o?: FlocksWriteOptions) => Promise<{
272
+ id: string;
273
+ provider: string;
274
+ label: string;
275
+ auth_kind: "subscription_oauth" | "api_key";
276
+ identity: string | null;
277
+ status: "pending_login" | "active" | "needs_login" | "revoked" | "deleted";
278
+ owner_org: string;
279
+ granted: boolean;
280
+ created_by: string;
281
+ created_at: number;
282
+ updated_at: number;
283
+ bound_instances?: number;
284
+ }>;
285
+ get: (id: string) => Promise<{
286
+ id: string;
287
+ provider: string;
288
+ label: string;
289
+ auth_kind: "subscription_oauth" | "api_key";
290
+ identity: string | null;
291
+ status: "pending_login" | "active" | "needs_login" | "revoked" | "deleted";
292
+ owner_org: string;
293
+ granted: boolean;
294
+ created_by: string;
295
+ created_at: number;
296
+ updated_at: number;
297
+ bound_instances?: number;
298
+ }>;
299
+ /** Owner only: clears the recorded identity (the next verified switch on one of your own instances records it again). */
300
+ resetIdentity: (id: string, o?: FlocksWriteOptions) => Promise<{
301
+ id: string;
302
+ provider: string;
303
+ label: string;
304
+ auth_kind: "subscription_oauth" | "api_key";
305
+ identity: string | null;
306
+ status: "pending_login" | "active" | "needs_login" | "revoked" | "deleted";
307
+ owner_org: string;
308
+ granted: boolean;
309
+ created_by: string;
310
+ created_at: number;
311
+ updated_at: number;
312
+ bound_instances?: number;
313
+ }>;
314
+ /** Signs the account out of every bound instance, then revokes the credential. Returns { account, job_id }. */
315
+ delete: (id: string, o?: FlocksWriteOptions) => Promise<{
316
+ account: import("./index.js").components["schemas"]["Flocks.Account"];
317
+ job_id: string;
318
+ }>;
319
+ /** Starts a login on one of your instances; the device url and code appear on the job item for you only. */
320
+ login: (id: string, instance_id: string, o?: FlocksWriteOptions) => Promise<{
321
+ id: string;
322
+ kind: "login" | "switch" | "logout";
323
+ state: "running" | "succeeded" | "partial" | "failed";
324
+ account_id: string | null;
325
+ provider: string;
326
+ concurrency: number;
327
+ force: boolean;
328
+ totals: {
329
+ queued: number;
330
+ dispatched: number;
331
+ succeeded: number;
332
+ failed: number;
333
+ timed_out: number;
334
+ rolled_back: number;
335
+ unsupported: number;
336
+ };
337
+ items: import("./index.js").components["schemas"]["Flocks.JobItem"][];
338
+ created_at: number;
339
+ updated_at: number;
340
+ }>;
341
+ };
342
+ /** Grants let another org bind its own instances to one of your accounts; revoking signs them out at once. */
343
+ grants: {
344
+ list: (query?: OperationInput<"flocks_listGrants">) => Promise<{
345
+ items: import("./index.js").components["schemas"]["Flocks.Grant"][];
346
+ }>;
347
+ create: (account_id: string, body: OperationInput<"flocks_createGrant">["body"], o?: FlocksWriteOptions) => Promise<{
348
+ id: string;
349
+ account_id: string;
350
+ owner_org: string;
351
+ grantee_org: string;
352
+ status: "active" | "revoked";
353
+ note: string;
354
+ created_by: string;
355
+ created_at: number;
356
+ revoked_at: number | null;
357
+ }>;
358
+ revoke: (grant_id: string, o?: FlocksWriteOptions) => Promise<{
359
+ grant: import("./index.js").components["schemas"]["Flocks.Grant"];
360
+ job_id: string | null;
361
+ }>;
362
+ };
363
+ /** Which account each instance runs under, and asynchronous switch and sign-out jobs. */
364
+ instances: {
365
+ getAccount: (id: string) => Promise<{
366
+ instance_id: string;
367
+ accounts: import("./index.js").components["schemas"]["Flocks.InstanceAccount"][];
368
+ }>;
369
+ switchAccount: (id: string, body: OperationInput<"flocks_switchInstanceAccount">["body"], o?: FlocksWriteOptions) => Promise<{
370
+ id: string;
371
+ kind: "login" | "switch" | "logout";
372
+ state: "running" | "succeeded" | "partial" | "failed";
373
+ account_id: string | null;
374
+ provider: string;
375
+ concurrency: number;
376
+ force: boolean;
377
+ totals: {
378
+ queued: number;
379
+ dispatched: number;
380
+ succeeded: number;
381
+ failed: number;
382
+ timed_out: number;
383
+ rolled_back: number;
384
+ unsupported: number;
385
+ };
386
+ items: import("./index.js").components["schemas"]["Flocks.JobItem"][];
387
+ created_at: number;
388
+ updated_at: number;
389
+ }>;
390
+ bulkSwitchAccount: (body: OperationInput<"flocks_bulkSwitchInstanceAccount">["body"], o?: FlocksWriteOptions) => Promise<{
391
+ id: string;
392
+ kind: "login" | "switch" | "logout";
393
+ state: "running" | "succeeded" | "partial" | "failed";
394
+ account_id: string | null;
395
+ provider: string;
396
+ concurrency: number;
397
+ force: boolean;
398
+ totals: {
399
+ queued: number;
400
+ dispatched: number;
401
+ succeeded: number;
402
+ failed: number;
403
+ timed_out: number;
404
+ rolled_back: number;
405
+ unsupported: number;
406
+ };
407
+ items: import("./index.js").components["schemas"]["Flocks.JobItem"][];
408
+ created_at: number;
409
+ updated_at: number;
410
+ }>;
411
+ /** `force` cancels in-flight runs instead of waiting for them. */
412
+ logout: (id: string, provider: string, force?: boolean, o?: FlocksWriteOptions) => Promise<{
413
+ id: string;
414
+ kind: "login" | "switch" | "logout";
415
+ state: "running" | "succeeded" | "partial" | "failed";
416
+ account_id: string | null;
417
+ provider: string;
418
+ concurrency: number;
419
+ force: boolean;
420
+ totals: {
421
+ queued: number;
422
+ dispatched: number;
423
+ succeeded: number;
424
+ failed: number;
425
+ timed_out: number;
426
+ rolled_back: number;
427
+ unsupported: number;
428
+ };
429
+ items: import("./index.js").components["schemas"]["Flocks.JobItem"][];
430
+ created_at: number;
431
+ updated_at: number;
432
+ }>;
433
+ bulkLogout: (body: OperationInput<"flocks_bulkLogoutInstanceAccount">["body"], o?: FlocksWriteOptions) => Promise<{
434
+ id: string;
435
+ kind: "login" | "switch" | "logout";
436
+ state: "running" | "succeeded" | "partial" | "failed";
437
+ account_id: string | null;
438
+ provider: string;
439
+ concurrency: number;
440
+ force: boolean;
441
+ totals: {
442
+ queued: number;
443
+ dispatched: number;
444
+ succeeded: number;
445
+ failed: number;
446
+ timed_out: number;
447
+ rolled_back: number;
448
+ unsupported: number;
449
+ };
450
+ items: import("./index.js").components["schemas"]["Flocks.JobItem"][];
451
+ created_at: number;
452
+ updated_at: number;
453
+ }>;
454
+ };
455
+ jobs: {
456
+ get: (id: string, o?: {
457
+ signal?: AbortSignal;
458
+ }) => Promise<{
459
+ id: string;
460
+ kind: "login" | "switch" | "logout";
461
+ state: "running" | "succeeded" | "partial" | "failed";
462
+ account_id: string | null;
463
+ provider: string;
464
+ concurrency: number;
465
+ force: boolean;
466
+ totals: {
467
+ queued: number;
468
+ dispatched: number;
469
+ succeeded: number;
470
+ failed: number;
471
+ timed_out: number;
472
+ rolled_back: number;
473
+ unsupported: number;
474
+ };
475
+ items: import("./index.js").components["schemas"]["Flocks.JobItem"][];
476
+ created_at: number;
477
+ updated_at: number;
478
+ }>;
479
+ /** Sends the pasted sign-in code to a login job that is waiting for it (initiator only). The code is never stored or returned. */
480
+ submitLoginInput: (id: string, instance_id: string, code: string, o?: FlocksWriteOptions) => Promise<{
481
+ accepted: true;
482
+ } & {
483
+ [key: string]: unknown;
484
+ }>;
485
+ /** Polls a job until its state is no longer `running`. Rejects with a timeout error after `timeoutMs` (default 10 minutes). */
486
+ wait: (id: string, o?: WaitForJobOptions) => Promise<FlocksJob>;
487
+ };
155
488
  };
package/dist/flocks.js CHANGED
@@ -1,13 +1,30 @@
1
+ import { GenesisError } from './errors.js';
2
+ /** Sleeps `ms`, rejecting early on abort; the abort listener is removed when the timer fires. */
3
+ function pause(ms, signal) {
4
+ return new Promise((resolve, reject) => {
5
+ const onAbort = () => { clearTimeout(t); reject(signal.reason ?? new Error('aborted')); };
6
+ const t = setTimeout(() => { signal?.removeEventListener('abort', onAbort); resolve(); }, ms);
7
+ if (signal?.aborted)
8
+ return onAbort();
9
+ signal?.addEventListener('abort', onAbort, { once: true });
10
+ });
11
+ }
1
12
  /** Org scope comes from the One account credential verified by the gateway. */
2
13
  export function flocksModule(client) {
3
14
  const nodePath = (id) => ({ id });
15
+ const write = async (id, input, o = {}) => client.request(id, input, o.signal ? { signal: o.signal } : undefined);
16
+ const getJob = (id, o = {}) => client.request('flocks_getAccountJob', { id }, o.signal ? { signal: o.signal } : undefined);
4
17
  return {
5
18
  readiness: {
6
19
  get: () => client.request('flocks_getEnrollmentReadiness'),
7
20
  },
8
21
  nodes: {
9
22
  list: () => client.request('flocks_listNodes'),
23
+ /** One node's presence (online, heartbeat age, harnesses) and a page of the runs recorded on it, newest first. */
24
+ activity: (id, query = {}) => client.request('flocks_getNodeActivity', { id, ...query }),
10
25
  rename: (id, nickname) => client.request('flocks_renameNode', { ...nodePath(id), body: { nickname } }),
26
+ /** Set an instance nickname and/or labels (the label key `flock` groups instances). */
27
+ update: (id, body) => client.request('flocks_renameNode', { ...nodePath(id), body }),
11
28
  revoke: (id) => client.request('flocks_revokeNode', nodePath(id)),
12
29
  heartbeat: (id, nodeBinding) => client.request('flocks_heartbeatNode', { ...nodePath(id), body: { node_binding: nodeBinding } }),
13
30
  enroll: (body) => client.request('flocks_enrollNode', { body }),
@@ -27,13 +44,81 @@ export function flocksModule(client) {
27
44
  status: (agent_id) => client.request('flocks_getAgentStatus', { agent_id }),
28
45
  cancel: (agent_id, idempotency_key) => client.request('flocks_cancelAgent', { agent_id, body: { idempotency_key } }),
29
46
  },
47
+ /** Your recent agent sessions and events; needs a signed-in session (the gateway forwards the human bearer for this read only). */
48
+ activity: {
49
+ get: () => client.request('flocks_getActivity'),
50
+ },
30
51
  runs: {
31
52
  list: (query = {}) => client.request('flocks_listRuns', query),
32
53
  get: (run_id) => client.request('flocks_getRun', { run_id }),
54
+ /** Starts a run of an agent (202 Run). `node_id` overrides the agent's pinned node for this run. */
55
+ create: (agent_id, body, o = {}) => client.request('flocks_createRun', { agent_id, body }, o.signal ? { signal: o.signal } : undefined),
56
+ /** Polls a run until it is completed or failed. Rejects with a timeout error after `timeoutMs` (default 30 minutes). */
57
+ wait: async (run_id, o = {}) => {
58
+ const interval = o.intervalMs ?? 2000, deadline = Date.now() + (o.timeoutMs ?? 1_800_000);
59
+ for (;;) {
60
+ const run = await client.request('flocks_getRun', { run_id }, o.signal ? { signal: o.signal } : undefined);
61
+ o.onUpdate?.(run);
62
+ if (run.state === 'completed' || run.state === 'failed')
63
+ return run;
64
+ if (Date.now() + interval > deadline)
65
+ throw new GenesisError({ status: 0, type: 'timeout', operationId: 'flocks_getRun', message: `Run ${run_id} was still ${run.state} after ${o.timeoutMs ?? 1_800_000} ms; poll runs.get again.` });
66
+ await pause(interval, o.signal);
67
+ }
68
+ },
33
69
  },
34
70
  joinTokens: {
35
71
  exchange: (body) => client.request('flocks_exchangeJoinToken', { body }),
36
72
  create: (ttlSeconds = 600) => client.request('flocks_createJoinToken', { body: { ttl_seconds: ttlSeconds } }),
37
73
  },
74
+ /** Providers (claude, codex) with the login kinds each supports and plain guidance on which plans fit sharing one login. */
75
+ providers: {
76
+ list: () => client.request('flocks_listProviders'),
77
+ },
78
+ /** Inference accounts your org owns, plus accounts granted to it. The service never returns a credential. */
79
+ accounts: {
80
+ list: (query = {}) => client.request('flocks_listAccounts', query),
81
+ create: (body, o) => write('flocks_createAccount', { body }, o),
82
+ get: (id) => client.request('flocks_getAccount', { id }),
83
+ /** Owner only: clears the recorded identity (the next verified switch on one of your own instances records it again). */
84
+ resetIdentity: (id, o) => write('flocks_resetAccountIdentity', { id }, o),
85
+ /** Signs the account out of every bound instance, then revokes the credential. Returns { account, job_id }. */
86
+ delete: (id, o) => write('flocks_deleteAccount', { id }, o),
87
+ /** Starts a login on one of your instances; the device url and code appear on the job item for you only. */
88
+ login: (id, instance_id, o) => write('flocks_loginAccount', { id, body: { instance_id } }, o),
89
+ },
90
+ /** Grants let another org bind its own instances to one of your accounts; revoking signs them out at once. */
91
+ grants: {
92
+ list: (query = {}) => client.request('flocks_listGrants', query),
93
+ create: (account_id, body, o) => write('flocks_createGrant', { id: account_id, body }, o),
94
+ revoke: (grant_id, o) => write('flocks_revokeGrant', { grant_id }, o),
95
+ },
96
+ /** Which account each instance runs under, and asynchronous switch and sign-out jobs. */
97
+ instances: {
98
+ getAccount: (id) => client.request('flocks_getInstanceAccount', { id }),
99
+ switchAccount: (id, body, o) => write('flocks_switchInstanceAccount', { id, body }, o),
100
+ bulkSwitchAccount: (body, o) => write('flocks_bulkSwitchInstanceAccount', { body }, o),
101
+ /** `force` cancels in-flight runs instead of waiting for them. */
102
+ logout: (id, provider, force, o) => write('flocks_logoutInstanceAccount', { id, body: { provider, ...(force ? { force: true } : {}) } }, o),
103
+ bulkLogout: (body, o) => write('flocks_bulkLogoutInstanceAccount', { body }, o),
104
+ },
105
+ jobs: {
106
+ get: getJob,
107
+ /** Sends the pasted sign-in code to a login job that is waiting for it (initiator only). The code is never stored or returned. */
108
+ submitLoginInput: (id, instance_id, code, o) => write('flocks_submitAccountLoginInput', { id, body: { instance_id, code } }, o),
109
+ /** Polls a job until its state is no longer `running`. Rejects with a timeout error after `timeoutMs` (default 10 minutes). */
110
+ wait: async (id, o = {}) => {
111
+ const interval = o.intervalMs ?? 2000, deadline = Date.now() + (o.timeoutMs ?? 600_000);
112
+ for (;;) {
113
+ const job = await getJob(id, o.signal ? { signal: o.signal } : {});
114
+ o.onUpdate?.(job);
115
+ if (job.state !== 'running')
116
+ return job;
117
+ if (Date.now() + interval > deadline)
118
+ throw new GenesisError({ status: 0, type: 'timeout', operationId: 'flocks_getAccountJob', message: `Job ${id} was still running after ${o.timeoutMs ?? 600_000} ms; poll jobs.get again.` });
119
+ await pause(interval, o.signal);
120
+ }
121
+ },
122
+ },
38
123
  };
39
124
  }