@onesi/genesis-cli 0.0.0-stage → 0.1.13

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 (49) hide show
  1. package/README.md +36 -2
  2. package/bin/genesis.js +3 -0
  3. package/dist/auth.d.ts +30 -0
  4. package/dist/auth.js +273 -0
  5. package/dist/beacons.d.ts +3 -0
  6. package/dist/beacons.js +94 -0
  7. package/dist/device-login.d.ts +25 -0
  8. package/dist/device-login.js +173 -0
  9. package/dist/dials.d.ts +7 -0
  10. package/dist/dials.js +96 -0
  11. package/dist/fleets.d.ts +4 -0
  12. package/dist/fleets.js +72 -0
  13. package/dist/flocks.d.ts +3 -0
  14. package/dist/flocks.js +72 -0
  15. package/dist/function-input.d.ts +3 -0
  16. package/dist/function-input.js +49 -0
  17. package/dist/henry.d.ts +3 -0
  18. package/dist/henry.js +26 -0
  19. package/dist/hives-marketplace.d.ts +10 -0
  20. package/dist/hives-marketplace.js +29 -0
  21. package/dist/hives-node-transport.d.ts +6 -0
  22. package/dist/hives-node-transport.js +147 -0
  23. package/dist/hives-operations.d.ts +9 -0
  24. package/dist/hives-operations.js +61 -0
  25. package/dist/hives-resources.d.ts +9 -0
  26. package/dist/hives-resources.js +94 -0
  27. package/dist/index.d.ts +21 -0
  28. package/dist/index.js +640 -0
  29. package/dist/lifeid-native.d.ts +24 -0
  30. package/dist/lifeid-native.js +113 -0
  31. package/dist/minds-owner.d.ts +3 -0
  32. package/dist/minds-owner.js +42 -0
  33. package/dist/minds.d.ts +3 -0
  34. package/dist/minds.js +90 -0
  35. package/dist/output.d.ts +28 -0
  36. package/dist/output.js +46 -0
  37. package/dist/products.d.ts +14 -0
  38. package/dist/products.js +85 -0
  39. package/dist/relays-enrollment.d.ts +3 -0
  40. package/dist/relays-enrollment.js +7 -0
  41. package/dist/runner.d.ts +4 -0
  42. package/dist/runner.js +55 -0
  43. package/dist/secret-input.d.ts +14 -0
  44. package/dist/secret-input.js +85 -0
  45. package/dist/store.d.ts +39 -0
  46. package/dist/store.js +33 -0
  47. package/dist/wasm-input.d.ts +2 -0
  48. package/dist/wasm-input.js +31 -0
  49. package/package.json +51 -3
@@ -0,0 +1,9 @@
1
+ import { Command } from 'commander';
2
+ import type { Genesis } from '@onesi/genesis';
3
+ type Deps = {
4
+ client: () => Promise<Genesis>;
5
+ emit: (data: unknown, pretty: () => string) => void;
6
+ readRequest?: (path: string, limit: number) => Promise<Record<string, unknown>>;
7
+ };
8
+ export declare function registerHivesResources(hives: Command, deps: Deps): void;
9
+ export {};
@@ -0,0 +1,94 @@
1
+ import { registerHivesMarketplace } from './hives-marketplace.js';
2
+ import { createReadStream } from 'node:fs';
3
+ import { stat, writeFile } from 'node:fs/promises';
4
+ import { readFunctionJson } from './function-input.js';
5
+ async function bytes(path) {
6
+ const metadata = await stat(path);
7
+ if (!metadata.isFile() || metadata.size > 10 * 1024 * 1024)
8
+ throw new Error('Choose a regular file of at most 10 MiB.');
9
+ const stream = createReadStream(path);
10
+ const chunks = [];
11
+ let total = 0;
12
+ try {
13
+ for await (const chunk of stream) {
14
+ const value = Buffer.from(chunk);
15
+ total += value.byteLength;
16
+ if (total > 10 * 1024 * 1024)
17
+ throw new Error('Object file exceeds 10 MiB.');
18
+ chunks.push(value);
19
+ }
20
+ }
21
+ finally {
22
+ stream.destroy();
23
+ }
24
+ return Uint8Array.from(Buffer.concat(chunks, total));
25
+ }
26
+ function number(value, min, max) { if (value === undefined)
27
+ return undefined; if (!/^\d+$/.test(value) || !Number.isSafeInteger(Number(value)) || Number(value) < min || Number(value) > max)
28
+ throw new Error('Invalid bounded numeric option.'); return Number(value); }
29
+ export function registerHivesResources(hives, deps) {
30
+ registerHivesMarketplace(hives, deps);
31
+ const output = (data) => deps.emit(data, () => JSON.stringify(data, null, 2));
32
+ const read = deps.readRequest ?? readFunctionJson;
33
+ const cells = hives.command('cells').description('Owned GCS buckets and objects; uncertain mutations require readback/reconciliation');
34
+ cells.command('list <project_id>').option('--page <number>').option('--per-page <number>').action(async (project, o) => output(await (await deps.client()).hives.cells.list(project, { page: number(o.page, 1, 10000), per_page: number(o.perPage, 1, 100) })));
35
+ cells.command('get <project_id> <bucket_id>').action(async (project, id) => output(await (await deps.client()).hives.cells.get(project, id)));
36
+ cells.command('create <project_id>').requiredOption('--request-file <path>', 'JSON name, region, visibility and CORS').action(async (project, o) => output(await (await deps.client()).hives.cells.create(project, await read(o.requestFile, 512 * 1024))));
37
+ for (const action of ['remove', 'reconcile'])
38
+ cells.command(`${action} <project_id> <bucket_id>`).action(async (project, id) => output(await (await deps.client()).hives.cells[action](project, id)));
39
+ const cors = cells.command('cors');
40
+ cors.command('get <project_id> <bucket_id>').action(async (project, id) => output(await (await deps.client()).hives.cells.cors.get(project, id)));
41
+ cors.command('set <project_id> <bucket_id>').requiredOption('--request-file <path>', 'JSON object with rules array').action(async (project, id, o) => { const body = await read(o.requestFile, 512 * 1024); if (!Array.isArray(body.rules))
42
+ throw new Error('CORS JSON requires rules.'); output(await (await deps.client()).hives.cells.cors.set(project, id, body.rules)); });
43
+ const objects = cells.command('objects');
44
+ objects.command('list <project_id> <bucket_id>').option('--prefix <value>').option('--delimiter <value>').option('--continuation-token <value>').option('--max-keys <number>').action(async (project, id, o) => output(await (await deps.client()).hives.cells.objects.list(project, id, { prefix: o.prefix, delimiter: o.delimiter, continuation_token: o.continuationToken, max_keys: number(o.maxKeys, 1, 1000) })));
45
+ for (const action of ['put', 'put-flat'])
46
+ objects.command(`${action} <project_id> <bucket_id> <key>`).requiredOption('--file <path>', 'Exact binary bytes up to 10 MiB').option('--content-type <value>').action(async (project, id, key, o) => { const client = await deps.client(); output(await client.hives.cells.objects[action === 'put' ? 'put' : 'putFlat'](project, id, key, await bytes(o.file), { content_type: o.contentType })); });
47
+ for (const action of ['remove', 'remove-flat'])
48
+ objects.command(`${action} <project_id> <bucket_id> <key>`).action(async (project, id, key) => { await (await deps.client()).hives.cells.objects[action === 'remove' ? 'remove' : 'removeFlat'](project, id, key); output({ acknowledged: true }); });
49
+ objects.command('download <project_id> <bucket_id> <key>').requiredOption('--output-file <path>', 'Create a new file; existing files are never overwritten').action(async (project, id, key, o) => { const response = await (await deps.client()).hives.cells.objects.download(project, id, key); const data = new Uint8Array(await response.arrayBuffer()); await writeFile(o.outputFile, data, { flag: 'wx', mode: 0o600 }); output({ saved: true, bytes: data.byteLength }); });
50
+ cells.command('presign <project_id> <bucket_id>').requiredOption('--request-file <path>', 'Explicit GET/PUT capability request; PUT requires exact content_length').action(async (project, id, o) => output(await (await deps.client()).hives.cells.presign(project, id, await read(o.requestFile, 64 * 1024))));
51
+ const queues = hives.command('queues').description('Buzz durable messages and possessed temporary delivery receipts');
52
+ const consumer = queues.command('consumer').description('Persisted standard-queue function binding; inspect state after an unknown mutation outcome');
53
+ for (const action of ['get', 'remove'])
54
+ consumer.command(`${action} <project_id> <queue_id>`).action(async (project, id) => output(await (await deps.client()).hives.queues.consumer[action](project, id)));
55
+ consumer.command('configure <project_id> <queue_id>').requiredOption('--request-file <path>', 'Exact existing queue delivery settings and owned active function').action(async (project, id, o) => output(await (await deps.client()).hives.queues.consumer.configure(project, id, await read(o.requestFile, 4096))));
56
+ for (const action of ['list'])
57
+ queues.command(`${action} <project_id>`).action(async (project) => output(await (await deps.client()).hives.queues[action](project)));
58
+ for (const action of ['get', 'stats', 'consumers', 'pause', 'resume', 'purge', 'remove', 'dead-letter-stats', 'purge-dead-letters']) {
59
+ const names = { 'dead-letter-stats': 'deadLetterStats', 'purge-dead-letters': 'purgeDeadLetters' };
60
+ queues.command(`${action} <project_id> <queue_id>`).action(async (project, id) => { const client = await deps.client(); const method = action in names ? names[action] : action; output(await client.hives.queues[method](project, id)); });
61
+ }
62
+ queues.command('create <project_id>').requiredOption('--request-file <path>', 'Queue name, standard/dead_letter/fifo type and optional delivery settings').action(async (project, o) => output(await (await deps.client()).hives.queues.create(project, await read(o.requestFile, 512 * 1024))));
63
+ queues.command('configure <project_id> <queue_id>').requiredOption('--request-file <path>').action(async (project, id, o) => output(await (await deps.client()).hives.queues.configure(project, id, await read(o.requestFile, 512 * 1024))));
64
+ queues.command('send <project_id> <queue_id>').requiredOption('--request-file <path>', 'Exactly body or body_base64; decoded body 256 KiB. FIFO retains its separate message_group_id and deduplication_id contract').option('--idempotency-key <key>', 'Persist the original key for a funded standard-queue send; never change it after uncertainty').action(async (project, id, o) => output(await (await deps.client()).hives.queues.send(project, id, await read(o.requestFile, 512 * 1024), { idempotencyKey: o.idempotencyKey })));
65
+ queues.command('operations').description('Read original queue operation status without sending another message').command('get <project_id> <queue_id> <operation_id>').action(async (project, id, operation) => output(await (await deps.client()).hives.queues.operations.get(project, id, operation)));
66
+ queues.command('receive <project_id> <queue_id>').option('--max-messages <number>').option('--wait-seconds <number>').action(async (project, id, o) => output(await (await deps.client()).hives.queues.receive(project, id, { maxMessages: number(o.maxMessages, 1, 10), waitSeconds: number(o.waitSeconds, 0, 10) })));
67
+ for (const action of ['ack', 'nack'])
68
+ queues.command(`${action} <project_id> <queue_id> <message_id>`).requiredOption('--receipt-file <path>', 'JSON receiptHandle; not a credential/header/query').action(async (project, id, message, o) => { const body = await read(o.receiptFile, 4096); if (typeof body.receiptHandle !== 'string')
69
+ throw new Error('Receipt JSON requires receiptHandle.'); output(await (await deps.client()).hives.queues[action](project, id, message, body.receiptHandle)); });
70
+ queues.command('dead-letters <project_id> <queue_id>').option('--limit <number>').option('--offset <number>').action(async (project, id, o) => output(await (await deps.client()).hives.queues.deadLetters(project, id, { limit: number(o.limit, 1, 10), offset: number(o.offset, 0, 8192) })));
71
+ for (const action of ['replay', 'delete-dead-letter'])
72
+ queues.command(`${action} <project_id> <queue_id> <message_id>`).action(async (project, id, message) => output(await (await deps.client()).hives.queues[action === 'replay' ? 'replay' : 'deleteDeadLetter'](project, id, message)));
73
+ const topics = hives.command('topics').description('Owned Buzz topics; publication persists deliveries, never retries an unknown outcome');
74
+ topics.command('list <project_id>').action(async (project) => output(await (await deps.client()).hives.topics.list(project)));
75
+ for (const action of ['get', 'remove'])
76
+ topics.command(`${action} <project_id> <topic_id>`).action(async (project, id) => output(await (await deps.client()).hives.topics[action](project, id)));
77
+ topics.command('create <project_id>').requiredOption('--request-file <path>', 'JSON topic name').action(async (project, o) => output(await (await deps.client()).hives.topics.create(project, await read(o.requestFile, 4096))));
78
+ topics.command('publish <project_id> <topic_id>').requiredOption('--request-file <path>', 'Exactly body or body_base64 plus optional string attributes; no automatic retry').action(async (project, id, o) => output(await (await deps.client()).hives.topics.publish(project, id, await read(o.requestFile, 512 * 1024))));
79
+ const subscriptions = topics.command('subscriptions').description('Same-project standard queue destinations; removing a subscription retains queued messages');
80
+ subscriptions.command('list <project_id> <topic_id>').action(async (project, id) => output(await (await deps.client()).hives.topics.subscriptions.list(project, id)));
81
+ subscriptions.command('add <project_id> <topic_id> <queue_id>').action(async (project, id, queue) => output(await (await deps.client()).hives.topics.subscriptions.add(project, id, queue)));
82
+ subscriptions.command('remove <project_id> <topic_id> <subscription_id>').action(async (project, id, subscription) => output(await (await deps.client()).hives.topics.subscriptions.remove(project, id, subscription)));
83
+ const volumes = hives.command('volumes').description('Persistent local storage; refresh saved state after an uncertain acknowledgement');
84
+ volumes.command('list <project_id>').option('--page <number>').option('--per-page <number>').action(async (project, o) => output(await (await deps.client()).hives.volumes.list(project, { page: number(o.page, 1, 10000), per_page: number(o.perPage, 1, 100) })));
85
+ for (const action of ['get', 'unmount', 'remove'])
86
+ volumes.command(`${action} <project_id> <volume_id>`).action(async (project, id) => output(await (await deps.client()).hives.volumes[action](project, id)));
87
+ volumes.command('create <project_id>').requiredOption('--request-file <path>', 'JSON name and size_mib (32–1024); local read_write_once only').action(async (project, o) => output(await (await deps.client()).hives.volumes.create(project, await read(o.requestFile, 4096))));
88
+ volumes.command('mount <project_id> <volume_id>').requiredOption('--request-file <path>', 'JSON target_id, mount_path and explicit read_only; preserve these values when reconnecting').action(async (project, id, o) => output(await (await deps.client()).hives.volumes.mount(project, id, await read(o.requestFile, 4096))));
89
+ const runtime = hives.command('runtimes').description('Compiled serving implementation metadata; not available capacity');
90
+ runtime.command('list').action(async () => output(await (await deps.client()).hives.runtimes.list()));
91
+ runtime.command('project <project_id>').action(async (project) => output(await (await deps.client()).hives.runtimes.project(project)));
92
+ runtime.command('get <name>').action(async (name) => output(await (await deps.client()).hives.runtimes.get(name)));
93
+ runtime.command('select').requiredOption('--wasi <value>').requiredOption('--runner <value>').requiredOption('--artifact <value>').action(async (input) => output(await (await deps.client()).hives.runtimes.select(input)));
94
+ }
@@ -0,0 +1,21 @@
1
+ import { Command } from 'commander';
2
+ import { type CredentialStore } from './store.js';
3
+ import { type Out } from './output.js';
4
+ import { type SecretInputOptions } from './secret-input.js';
5
+ export interface Deps {
6
+ out?: Out;
7
+ store?: () => Promise<CredentialStore>;
8
+ fetch?: typeof fetch;
9
+ /** Cancel Hives calls through response-body completion; other products retain their transport. */
10
+ signal?: AbortSignal;
11
+ env?: Record<string, string | undefined>;
12
+ openBrowser?: (url: string) => void;
13
+ sleep?: (ms: number) => Promise<void>;
14
+ readSecretInput?: (options: SecretInputOptions, limit: number) => Promise<string>;
15
+ readWasmFile?: (path: string) => Promise<Blob>;
16
+ writeBytes?: (bytes: Uint8Array) => void;
17
+ writeOutputFile?: (path: string, bytes: Uint8Array) => Promise<void>;
18
+ readHivesRequest?: (path: string, limit: number) => Promise<Record<string, unknown>>;
19
+ }
20
+ export declare function buildProgram(deps?: Deps): Command;
21
+ export declare function main(argv: string[], deps?: Deps): Promise<number>;