@onesi/genesis 0.1.13 → 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.
- package/README.md +1 -1
- package/dist/auto.d.ts +1010 -0
- package/dist/auto.js +125 -0
- package/dist/beacons.d.ts +42 -0
- package/dist/beacons.js +71 -0
- package/dist/blinds-owner-enrollment.d.ts +109 -0
- package/dist/blinds-owner-enrollment.js +21 -2
- package/dist/client.d.ts +3 -19947
- package/dist/client.js +124 -17
- package/dist/errors.js +1 -1
- package/dist/flares.d.ts +32 -0
- package/dist/flares.js +5 -0
- package/dist/fleets.d.ts +32 -0
- package/dist/fleets.js +59 -6
- package/dist/flocks.d.ts +285 -1
- package/dist/flocks.js +59 -0
- package/dist/foundry.d.ts +424 -0
- package/dist/foundry.js +133 -0
- package/dist/garden.d.ts +754 -0
- package/dist/garden.js +76 -0
- package/dist/gateway.d.ts +365 -0
- package/dist/gateway.js +82 -0
- package/dist/gears.d.ts +121 -2
- package/dist/gears.js +24 -2
- package/dist/generated/operations.d.ts +3 -19948
- package/dist/generated/operations.js +54590 -13302
- package/dist/generated/schema.d.ts +69793 -17548
- package/dist/genesis.d.ts +7908 -1260
- package/dist/genesis.js +90 -25
- package/dist/genesis.openapi.json +109121 -29920
- package/dist/henry.d.ts +202 -1
- package/dist/henry.js +223 -0
- package/dist/hives-environment.d.ts +9 -0
- package/dist/hives-environment.js +22 -0
- package/dist/hives-node.js +3 -0
- package/dist/hives-operations.d.ts +114 -0
- package/dist/hives-operations.js +2 -0
- package/dist/hives-platform.d.ts +149 -0
- package/dist/hives-platform.js +183 -0
- package/dist/hives-sse.d.ts +24 -0
- package/dist/hives-sse.js +111 -0
- package/dist/iam-directory.d.ts +8 -0
- package/dist/iam-directory.js +23 -0
- package/dist/iam.d.ts +391 -0
- package/dist/iam.js +92 -0
- package/dist/idempotency.d.ts +3 -0
- package/dist/idempotency.js +22 -0
- package/dist/index.d.ts +18 -4
- package/dist/index.js +16 -4
- package/dist/instances.d.ts +177 -2
- package/dist/instances.js +37 -5
- package/dist/minds-agent.d.ts +28 -0
- package/dist/minds-agent.js +53 -10
- package/dist/minds-engine.d.ts +394 -0
- package/dist/minds-engine.js +555 -0
- package/dist/minds.d.ts +109 -1
- package/dist/minds.js +49 -14
- package/dist/orgs.d.ts +405 -0
- package/dist/orgs.js +63 -0
- package/dist/runner.d.ts +4 -0
- package/dist/runner.js +1 -0
- package/dist/scopes.d.ts +310 -0
- package/dist/scopes.js +40 -0
- package/dist/taps.d.ts +118 -0
- package/dist/taps.js +45 -0
- package/dist/traces.d.ts +574 -0
- package/dist/traces.js +97 -0
- package/dist/types.d.ts +12 -1
- package/package.json +1 -1
package/dist/flocks.d.ts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
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'>;
|
|
3
14
|
/** Org scope comes from the One account credential verified by the gateway. */
|
|
4
15
|
export declare function flocksModule(client: GenesisClient): {
|
|
5
16
|
readiness: {
|
|
@@ -18,6 +29,11 @@ export declare function flocksModule(client: GenesisClient): {
|
|
|
18
29
|
state: "enrolled" | "revoked";
|
|
19
30
|
last_seen_at: number;
|
|
20
31
|
enrolled_at: number;
|
|
32
|
+
labels?: {
|
|
33
|
+
[key: string]: string;
|
|
34
|
+
};
|
|
35
|
+
accounts?: import("./index.js").components["schemas"]["Flocks.HeartbeatAccount"][];
|
|
36
|
+
accounts_supported?: boolean;
|
|
21
37
|
}[]>;
|
|
22
38
|
rename: (id: string, nickname: string) => Promise<{
|
|
23
39
|
id: string;
|
|
@@ -28,6 +44,27 @@ export declare function flocksModule(client: GenesisClient): {
|
|
|
28
44
|
state: "enrolled" | "revoked";
|
|
29
45
|
last_seen_at: number;
|
|
30
46
|
enrolled_at: number;
|
|
47
|
+
labels?: {
|
|
48
|
+
[key: string]: string;
|
|
49
|
+
};
|
|
50
|
+
accounts?: import("./index.js").components["schemas"]["Flocks.HeartbeatAccount"][];
|
|
51
|
+
accounts_supported?: boolean;
|
|
52
|
+
}>;
|
|
53
|
+
/** Set an instance nickname and/or labels (the label key `flock` groups instances). */
|
|
54
|
+
update: (id: string, body: OperationInput<"flocks_renameNode">["body"]) => Promise<{
|
|
55
|
+
id: string;
|
|
56
|
+
name: string;
|
|
57
|
+
nickname: string;
|
|
58
|
+
platform: string;
|
|
59
|
+
cpu_count: number;
|
|
60
|
+
state: "enrolled" | "revoked";
|
|
61
|
+
last_seen_at: number;
|
|
62
|
+
enrolled_at: number;
|
|
63
|
+
labels?: {
|
|
64
|
+
[key: string]: string;
|
|
65
|
+
};
|
|
66
|
+
accounts?: import("./index.js").components["schemas"]["Flocks.HeartbeatAccount"][];
|
|
67
|
+
accounts_supported?: boolean;
|
|
31
68
|
}>;
|
|
32
69
|
revoke: (id: string) => Promise<{
|
|
33
70
|
id: string;
|
|
@@ -38,6 +75,11 @@ export declare function flocksModule(client: GenesisClient): {
|
|
|
38
75
|
state: "enrolled" | "revoked";
|
|
39
76
|
last_seen_at: number;
|
|
40
77
|
enrolled_at: number;
|
|
78
|
+
labels?: {
|
|
79
|
+
[key: string]: string;
|
|
80
|
+
};
|
|
81
|
+
accounts?: import("./index.js").components["schemas"]["Flocks.HeartbeatAccount"][];
|
|
82
|
+
accounts_supported?: boolean;
|
|
41
83
|
}>;
|
|
42
84
|
heartbeat: (id: string, nodeBinding: string) => Promise<{
|
|
43
85
|
accepted: boolean;
|
|
@@ -119,6 +161,34 @@ export declare function flocksModule(client: GenesisClient): {
|
|
|
119
161
|
expiresAtMs: number;
|
|
120
162
|
}>;
|
|
121
163
|
};
|
|
164
|
+
/** Your recent agent sessions and events; needs a signed-in session (the gateway forwards the human bearer for this read only). */
|
|
165
|
+
activity: {
|
|
166
|
+
get: () => Promise<{
|
|
167
|
+
sessions: ({
|
|
168
|
+
session_id: string;
|
|
169
|
+
agent_id?: string;
|
|
170
|
+
provider: string;
|
|
171
|
+
title?: string;
|
|
172
|
+
status: string;
|
|
173
|
+
roost_url?: string;
|
|
174
|
+
updated_at: string;
|
|
175
|
+
} & {
|
|
176
|
+
[key: string]: unknown;
|
|
177
|
+
})[];
|
|
178
|
+
events: ({
|
|
179
|
+
event_id: string;
|
|
180
|
+
session_id?: string;
|
|
181
|
+
provider: string;
|
|
182
|
+
type: string;
|
|
183
|
+
text: string;
|
|
184
|
+
login_url?: string;
|
|
185
|
+
login_code?: string;
|
|
186
|
+
created_at: string;
|
|
187
|
+
} & {
|
|
188
|
+
[key: string]: unknown;
|
|
189
|
+
})[];
|
|
190
|
+
}>;
|
|
191
|
+
};
|
|
122
192
|
runs: {
|
|
123
193
|
list: (query?: OperationInput<"flocks_listRuns">) => Promise<{
|
|
124
194
|
items: import("./index.js").components["schemas"]["Flocks.Run"][];
|
|
@@ -152,4 +222,218 @@ export declare function flocksModule(client: GenesisClient): {
|
|
|
152
222
|
expires_at: number;
|
|
153
223
|
}>;
|
|
154
224
|
};
|
|
225
|
+
/** Providers (claude, codex) with the login kinds each supports and plain guidance on which plans fit sharing one login. */
|
|
226
|
+
providers: {
|
|
227
|
+
list: () => Promise<{
|
|
228
|
+
items: import("./index.js").components["schemas"]["Flocks.Provider"][];
|
|
229
|
+
}>;
|
|
230
|
+
};
|
|
231
|
+
/** Inference accounts your org owns, plus accounts granted to it. The service never returns a credential. */
|
|
232
|
+
accounts: {
|
|
233
|
+
list: (query?: OperationInput<"flocks_listAccounts">) => Promise<{
|
|
234
|
+
items: import("./index.js").components["schemas"]["Flocks.Account"][];
|
|
235
|
+
next_cursor: string | null;
|
|
236
|
+
}>;
|
|
237
|
+
create: (body: OperationInput<"flocks_createAccount">["body"], o?: FlocksWriteOptions) => Promise<{
|
|
238
|
+
id: string;
|
|
239
|
+
provider: string;
|
|
240
|
+
label: string;
|
|
241
|
+
auth_kind: "subscription_oauth" | "api_key";
|
|
242
|
+
identity: string | null;
|
|
243
|
+
status: "pending_login" | "active" | "needs_login" | "revoked" | "deleted";
|
|
244
|
+
owner_org: string;
|
|
245
|
+
granted: boolean;
|
|
246
|
+
created_by: string;
|
|
247
|
+
created_at: number;
|
|
248
|
+
updated_at: number;
|
|
249
|
+
bound_instances?: number;
|
|
250
|
+
}>;
|
|
251
|
+
get: (id: string) => Promise<{
|
|
252
|
+
id: string;
|
|
253
|
+
provider: string;
|
|
254
|
+
label: string;
|
|
255
|
+
auth_kind: "subscription_oauth" | "api_key";
|
|
256
|
+
identity: string | null;
|
|
257
|
+
status: "pending_login" | "active" | "needs_login" | "revoked" | "deleted";
|
|
258
|
+
owner_org: string;
|
|
259
|
+
granted: boolean;
|
|
260
|
+
created_by: string;
|
|
261
|
+
created_at: number;
|
|
262
|
+
updated_at: number;
|
|
263
|
+
bound_instances?: number;
|
|
264
|
+
}>;
|
|
265
|
+
/** Signs the account out of every bound instance, then revokes the credential. Returns { account, job_id }. */
|
|
266
|
+
delete: (id: string, o?: FlocksWriteOptions) => Promise<{
|
|
267
|
+
account: import("./index.js").components["schemas"]["Flocks.Account"];
|
|
268
|
+
job_id: string;
|
|
269
|
+
}>;
|
|
270
|
+
/** Starts a login on one of your instances; the device url and code appear on the job item for you only. */
|
|
271
|
+
login: (id: string, instance_id: string, o?: FlocksWriteOptions) => Promise<{
|
|
272
|
+
id: string;
|
|
273
|
+
kind: "login" | "switch" | "logout";
|
|
274
|
+
state: "running" | "succeeded" | "partial" | "failed";
|
|
275
|
+
account_id: string | null;
|
|
276
|
+
provider: string;
|
|
277
|
+
concurrency: number;
|
|
278
|
+
force: boolean;
|
|
279
|
+
totals: {
|
|
280
|
+
queued: number;
|
|
281
|
+
dispatched: number;
|
|
282
|
+
succeeded: number;
|
|
283
|
+
failed: number;
|
|
284
|
+
timed_out: number;
|
|
285
|
+
rolled_back: number;
|
|
286
|
+
unsupported: number;
|
|
287
|
+
};
|
|
288
|
+
items: import("./index.js").components["schemas"]["Flocks.JobItem"][];
|
|
289
|
+
created_at: number;
|
|
290
|
+
updated_at: number;
|
|
291
|
+
}>;
|
|
292
|
+
};
|
|
293
|
+
/** Grants let another org bind its own instances to one of your accounts; revoking signs them out at once. */
|
|
294
|
+
grants: {
|
|
295
|
+
list: (query?: OperationInput<"flocks_listGrants">) => Promise<{
|
|
296
|
+
items: import("./index.js").components["schemas"]["Flocks.Grant"][];
|
|
297
|
+
}>;
|
|
298
|
+
create: (account_id: string, body: OperationInput<"flocks_createGrant">["body"], o?: FlocksWriteOptions) => Promise<{
|
|
299
|
+
id: string;
|
|
300
|
+
account_id: string;
|
|
301
|
+
owner_org: string;
|
|
302
|
+
grantee_org: string;
|
|
303
|
+
status: "active" | "revoked";
|
|
304
|
+
note: string;
|
|
305
|
+
created_by: string;
|
|
306
|
+
created_at: number;
|
|
307
|
+
revoked_at: number | null;
|
|
308
|
+
}>;
|
|
309
|
+
revoke: (grant_id: string, o?: FlocksWriteOptions) => Promise<{
|
|
310
|
+
grant: import("./index.js").components["schemas"]["Flocks.Grant"];
|
|
311
|
+
job_id: string | null;
|
|
312
|
+
}>;
|
|
313
|
+
};
|
|
314
|
+
/** Which account each instance runs under, and asynchronous switch and sign-out jobs. */
|
|
315
|
+
instances: {
|
|
316
|
+
getAccount: (id: string) => Promise<{
|
|
317
|
+
instance_id: string;
|
|
318
|
+
accounts: import("./index.js").components["schemas"]["Flocks.InstanceAccount"][];
|
|
319
|
+
}>;
|
|
320
|
+
switchAccount: (id: string, body: OperationInput<"flocks_switchInstanceAccount">["body"], 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
|
+
bulkSwitchAccount: (body: OperationInput<"flocks_bulkSwitchInstanceAccount">["body"], o?: FlocksWriteOptions) => Promise<{
|
|
342
|
+
id: string;
|
|
343
|
+
kind: "login" | "switch" | "logout";
|
|
344
|
+
state: "running" | "succeeded" | "partial" | "failed";
|
|
345
|
+
account_id: string | null;
|
|
346
|
+
provider: string;
|
|
347
|
+
concurrency: number;
|
|
348
|
+
force: boolean;
|
|
349
|
+
totals: {
|
|
350
|
+
queued: number;
|
|
351
|
+
dispatched: number;
|
|
352
|
+
succeeded: number;
|
|
353
|
+
failed: number;
|
|
354
|
+
timed_out: number;
|
|
355
|
+
rolled_back: number;
|
|
356
|
+
unsupported: number;
|
|
357
|
+
};
|
|
358
|
+
items: import("./index.js").components["schemas"]["Flocks.JobItem"][];
|
|
359
|
+
created_at: number;
|
|
360
|
+
updated_at: number;
|
|
361
|
+
}>;
|
|
362
|
+
/** `force` cancels in-flight runs instead of waiting for them. */
|
|
363
|
+
logout: (id: string, provider: string, force?: boolean, o?: FlocksWriteOptions) => Promise<{
|
|
364
|
+
id: string;
|
|
365
|
+
kind: "login" | "switch" | "logout";
|
|
366
|
+
state: "running" | "succeeded" | "partial" | "failed";
|
|
367
|
+
account_id: string | null;
|
|
368
|
+
provider: string;
|
|
369
|
+
concurrency: number;
|
|
370
|
+
force: boolean;
|
|
371
|
+
totals: {
|
|
372
|
+
queued: number;
|
|
373
|
+
dispatched: number;
|
|
374
|
+
succeeded: number;
|
|
375
|
+
failed: number;
|
|
376
|
+
timed_out: number;
|
|
377
|
+
rolled_back: number;
|
|
378
|
+
unsupported: number;
|
|
379
|
+
};
|
|
380
|
+
items: import("./index.js").components["schemas"]["Flocks.JobItem"][];
|
|
381
|
+
created_at: number;
|
|
382
|
+
updated_at: number;
|
|
383
|
+
}>;
|
|
384
|
+
bulkLogout: (body: OperationInput<"flocks_bulkLogoutInstanceAccount">["body"], o?: FlocksWriteOptions) => Promise<{
|
|
385
|
+
id: string;
|
|
386
|
+
kind: "login" | "switch" | "logout";
|
|
387
|
+
state: "running" | "succeeded" | "partial" | "failed";
|
|
388
|
+
account_id: string | null;
|
|
389
|
+
provider: string;
|
|
390
|
+
concurrency: number;
|
|
391
|
+
force: boolean;
|
|
392
|
+
totals: {
|
|
393
|
+
queued: number;
|
|
394
|
+
dispatched: number;
|
|
395
|
+
succeeded: number;
|
|
396
|
+
failed: number;
|
|
397
|
+
timed_out: number;
|
|
398
|
+
rolled_back: number;
|
|
399
|
+
unsupported: number;
|
|
400
|
+
};
|
|
401
|
+
items: import("./index.js").components["schemas"]["Flocks.JobItem"][];
|
|
402
|
+
created_at: number;
|
|
403
|
+
updated_at: number;
|
|
404
|
+
}>;
|
|
405
|
+
};
|
|
406
|
+
jobs: {
|
|
407
|
+
get: (id: string, o?: {
|
|
408
|
+
signal?: AbortSignal;
|
|
409
|
+
}) => Promise<{
|
|
410
|
+
id: string;
|
|
411
|
+
kind: "login" | "switch" | "logout";
|
|
412
|
+
state: "running" | "succeeded" | "partial" | "failed";
|
|
413
|
+
account_id: string | null;
|
|
414
|
+
provider: string;
|
|
415
|
+
concurrency: number;
|
|
416
|
+
force: boolean;
|
|
417
|
+
totals: {
|
|
418
|
+
queued: number;
|
|
419
|
+
dispatched: number;
|
|
420
|
+
succeeded: number;
|
|
421
|
+
failed: number;
|
|
422
|
+
timed_out: number;
|
|
423
|
+
rolled_back: number;
|
|
424
|
+
unsupported: number;
|
|
425
|
+
};
|
|
426
|
+
items: import("./index.js").components["schemas"]["Flocks.JobItem"][];
|
|
427
|
+
created_at: number;
|
|
428
|
+
updated_at: number;
|
|
429
|
+
}>;
|
|
430
|
+
/** Sends the pasted sign-in code to a login job that is waiting for it (initiator only). The code is never stored or returned. */
|
|
431
|
+
submitLoginInput: (id: string, instance_id: string, code: string, o?: FlocksWriteOptions) => Promise<{
|
|
432
|
+
accepted: true;
|
|
433
|
+
} & {
|
|
434
|
+
[key: string]: unknown;
|
|
435
|
+
}>;
|
|
436
|
+
/** Polls a job until its state is no longer `running`. Rejects with a timeout error after `timeoutMs` (default 10 minutes). */
|
|
437
|
+
wait: (id: string, o?: WaitForJobOptions) => Promise<FlocksJob>;
|
|
438
|
+
};
|
|
155
439
|
};
|
package/dist/flocks.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { GenesisError } from './errors.js';
|
|
1
2
|
/** Org scope comes from the One account credential verified by the gateway. */
|
|
2
3
|
export function flocksModule(client) {
|
|
3
4
|
const nodePath = (id) => ({ id });
|
|
5
|
+
const write = async (id, input, o = {}) => client.request(id, input, o.signal ? { signal: o.signal } : undefined);
|
|
6
|
+
const getJob = (id, o = {}) => client.request('flocks_getAccountJob', { id }, o.signal ? { signal: o.signal } : undefined);
|
|
4
7
|
return {
|
|
5
8
|
readiness: {
|
|
6
9
|
get: () => client.request('flocks_getEnrollmentReadiness'),
|
|
@@ -8,6 +11,8 @@ export function flocksModule(client) {
|
|
|
8
11
|
nodes: {
|
|
9
12
|
list: () => client.request('flocks_listNodes'),
|
|
10
13
|
rename: (id, nickname) => client.request('flocks_renameNode', { ...nodePath(id), body: { nickname } }),
|
|
14
|
+
/** Set an instance nickname and/or labels (the label key `flock` groups instances). */
|
|
15
|
+
update: (id, body) => client.request('flocks_renameNode', { ...nodePath(id), body }),
|
|
11
16
|
revoke: (id) => client.request('flocks_revokeNode', nodePath(id)),
|
|
12
17
|
heartbeat: (id, nodeBinding) => client.request('flocks_heartbeatNode', { ...nodePath(id), body: { node_binding: nodeBinding } }),
|
|
13
18
|
enroll: (body) => client.request('flocks_enrollNode', { body }),
|
|
@@ -27,6 +32,10 @@ export function flocksModule(client) {
|
|
|
27
32
|
status: (agent_id) => client.request('flocks_getAgentStatus', { agent_id }),
|
|
28
33
|
cancel: (agent_id, idempotency_key) => client.request('flocks_cancelAgent', { agent_id, body: { idempotency_key } }),
|
|
29
34
|
},
|
|
35
|
+
/** Your recent agent sessions and events; needs a signed-in session (the gateway forwards the human bearer for this read only). */
|
|
36
|
+
activity: {
|
|
37
|
+
get: () => client.request('flocks_getActivity'),
|
|
38
|
+
},
|
|
30
39
|
runs: {
|
|
31
40
|
list: (query = {}) => client.request('flocks_listRuns', query),
|
|
32
41
|
get: (run_id) => client.request('flocks_getRun', { run_id }),
|
|
@@ -35,5 +44,55 @@ export function flocksModule(client) {
|
|
|
35
44
|
exchange: (body) => client.request('flocks_exchangeJoinToken', { body }),
|
|
36
45
|
create: (ttlSeconds = 600) => client.request('flocks_createJoinToken', { body: { ttl_seconds: ttlSeconds } }),
|
|
37
46
|
},
|
|
47
|
+
/** Providers (claude, codex) with the login kinds each supports and plain guidance on which plans fit sharing one login. */
|
|
48
|
+
providers: {
|
|
49
|
+
list: () => client.request('flocks_listProviders'),
|
|
50
|
+
},
|
|
51
|
+
/** Inference accounts your org owns, plus accounts granted to it. The service never returns a credential. */
|
|
52
|
+
accounts: {
|
|
53
|
+
list: (query = {}) => client.request('flocks_listAccounts', query),
|
|
54
|
+
create: (body, o) => write('flocks_createAccount', { body }, o),
|
|
55
|
+
get: (id) => client.request('flocks_getAccount', { id }),
|
|
56
|
+
/** Signs the account out of every bound instance, then revokes the credential. Returns { account, job_id }. */
|
|
57
|
+
delete: (id, o) => write('flocks_deleteAccount', { id }, o),
|
|
58
|
+
/** Starts a login on one of your instances; the device url and code appear on the job item for you only. */
|
|
59
|
+
login: (id, instance_id, o) => write('flocks_loginAccount', { id, body: { instance_id } }, o),
|
|
60
|
+
},
|
|
61
|
+
/** Grants let another org bind its own instances to one of your accounts; revoking signs them out at once. */
|
|
62
|
+
grants: {
|
|
63
|
+
list: (query = {}) => client.request('flocks_listGrants', query),
|
|
64
|
+
create: (account_id, body, o) => write('flocks_createGrant', { id: account_id, body }, o),
|
|
65
|
+
revoke: (grant_id, o) => write('flocks_revokeGrant', { grant_id }, o),
|
|
66
|
+
},
|
|
67
|
+
/** Which account each instance runs under, and asynchronous switch and sign-out jobs. */
|
|
68
|
+
instances: {
|
|
69
|
+
getAccount: (id) => client.request('flocks_getInstanceAccount', { id }),
|
|
70
|
+
switchAccount: (id, body, o) => write('flocks_switchInstanceAccount', { id, body }, o),
|
|
71
|
+
bulkSwitchAccount: (body, o) => write('flocks_bulkSwitchInstanceAccount', { body }, o),
|
|
72
|
+
/** `force` cancels in-flight runs instead of waiting for them. */
|
|
73
|
+
logout: (id, provider, force, o) => write('flocks_logoutInstanceAccount', { id, body: { provider, ...(force ? { force: true } : {}) } }, o),
|
|
74
|
+
bulkLogout: (body, o) => write('flocks_bulkLogoutInstanceAccount', { body }, o),
|
|
75
|
+
},
|
|
76
|
+
jobs: {
|
|
77
|
+
get: getJob,
|
|
78
|
+
/** Sends the pasted sign-in code to a login job that is waiting for it (initiator only). The code is never stored or returned. */
|
|
79
|
+
submitLoginInput: (id, instance_id, code, o) => write('flocks_submitAccountLoginInput', { id, body: { instance_id, code } }, o),
|
|
80
|
+
/** Polls a job until its state is no longer `running`. Rejects with a timeout error after `timeoutMs` (default 10 minutes). */
|
|
81
|
+
wait: async (id, o = {}) => {
|
|
82
|
+
const interval = o.intervalMs ?? 2000, deadline = Date.now() + (o.timeoutMs ?? 600_000);
|
|
83
|
+
for (;;) {
|
|
84
|
+
const job = await getJob(id, o.signal ? { signal: o.signal } : {});
|
|
85
|
+
o.onUpdate?.(job);
|
|
86
|
+
if (job.state !== 'running')
|
|
87
|
+
return job;
|
|
88
|
+
if (Date.now() + interval > deadline)
|
|
89
|
+
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.` });
|
|
90
|
+
await new Promise((resolve, reject) => {
|
|
91
|
+
const t = setTimeout(resolve, interval);
|
|
92
|
+
o.signal?.addEventListener('abort', () => { clearTimeout(t); reject(o.signal.reason ?? new Error('aborted')); }, { once: true });
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
},
|
|
38
97
|
};
|
|
39
98
|
}
|