@onesi/genesis-cli 0.2.3 → 0.2.5
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/fleets.js +4 -2
- package/dist/hives-project.d.ts +8 -0
- package/dist/hives-project.js +31 -0
- package/dist/index.js +10 -7
- package/dist/products.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
package/dist/fleets.js
CHANGED
|
@@ -76,9 +76,11 @@ export function registerFleets(program, client, emit, keyInput = readFoundryKey)
|
|
|
76
76
|
instances.command('start <instance_id>').description('Connect already admitted Henry compute').option('--idempotency-key <uuid>', 'canonical UUID4 to retain after an uncertain reply').action(async (id, options) => emit(await (await client()).fleets.instances.start(id, { idempotencyKey: options.idempotencyKey })));
|
|
77
77
|
const connection = fleets.command('connection').description('Organization-owned Foundry connection');
|
|
78
78
|
connection.command('get').action(async () => emit(await (await client()).fleets.connection.get()));
|
|
79
|
-
connection.command('set').description('Read a Foundry key from stdin and encrypt it with Genesis KMS')
|
|
79
|
+
connection.command('set').description('Read a Foundry key from stdin and encrypt it with Genesis KMS')
|
|
80
|
+
.option('--model <id>', 'Foundry model for this organization\'s tasks (must be listed by Foundry for the key); default gpt-4.1-mini')
|
|
81
|
+
.action(async (options) => {
|
|
80
82
|
const apiKey = await keyInput();
|
|
81
|
-
emit(await (await client()).fleets.connection.set(apiKey));
|
|
83
|
+
emit(await (await client()).fleets.connection.set(apiKey, options.model !== undefined ? { model: options.model } : {}));
|
|
82
84
|
});
|
|
83
85
|
connection.command('delete').action(async () => emit(await (await client()).fleets.connection.delete()));
|
|
84
86
|
const usage = fleets.command('usage').description('Usage observations derived from your tasks');
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
import { type Genesis } from '@onesi/genesis';
|
|
3
|
+
/**
|
|
4
|
+
* Every `genesis hives` command with a <project_id>: the help says "Hives project id (prj_…)"; a Genesis pr_… id of
|
|
5
|
+
* the selected context resolves to its Hives binding, and where project_id is the last argument of a command that
|
|
6
|
+
* does not delete or end anything it may be omitted. The binding is read once per invocation, before the action.
|
|
7
|
+
*/
|
|
8
|
+
export declare function registerHivesProjectDefault(hives: Command, client: () => Promise<Genesis>): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { HIVES_PROJECT_ID_DEFAULT, HIVES_PROJECT_ID_DESCRIPTION, isGenesisProjectId } from '@onesi/genesis';
|
|
2
|
+
/** Commands that delete or end something keep an explicit project id: an omitted one never defaults. */
|
|
3
|
+
const EXPLICIT = /^(?:delete|remove|purge|uninstall|destroy|stop|cancel|rollback|detach)/;
|
|
4
|
+
const projectArgument = (command) => command.registeredArguments.findIndex((a) => a.name() === 'project_id');
|
|
5
|
+
/**
|
|
6
|
+
* Every `genesis hives` command with a <project_id>: the help says "Hives project id (prj_…)"; a Genesis pr_… id of
|
|
7
|
+
* the selected context resolves to its Hives binding, and where project_id is the last argument of a command that
|
|
8
|
+
* does not delete or end anything it may be omitted. The binding is read once per invocation, before the action.
|
|
9
|
+
*/
|
|
10
|
+
export function registerHivesProjectDefault(hives, client) {
|
|
11
|
+
const visit = (command) => {
|
|
12
|
+
const at = projectArgument(command);
|
|
13
|
+
if (at >= 0 && command.parent?.name() !== 'context') {
|
|
14
|
+
const argument = command.registeredArguments[at];
|
|
15
|
+
const optional = at === command.registeredArguments.length - 1 && !argument.variadic && !EXPLICIT.test(command.name());
|
|
16
|
+
argument.description = optional ? `${HIVES_PROJECT_ID_DESCRIPTION}; ${HIVES_PROJECT_ID_DEFAULT}` : HIVES_PROJECT_ID_DESCRIPTION;
|
|
17
|
+
if (optional)
|
|
18
|
+
argument.required = false;
|
|
19
|
+
}
|
|
20
|
+
command.commands.forEach(visit);
|
|
21
|
+
};
|
|
22
|
+
hives.commands.forEach(visit);
|
|
23
|
+
hives.hook('preAction', async (_hooked, action) => {
|
|
24
|
+
const at = projectArgument(action);
|
|
25
|
+
if (at < 0 || action.parent?.name() === 'context')
|
|
26
|
+
return;
|
|
27
|
+
const value = action.processedArgs[at];
|
|
28
|
+
if (value === undefined || isGenesisProjectId(value))
|
|
29
|
+
action.processedArgs[at] = await (await client()).hives.resolveProject(value);
|
|
30
|
+
});
|
|
31
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { registerIamDirectory } from './iam-directory.js';
|
|
|
7
7
|
import { registerOperationCommands, registerProducts } from './products.js';
|
|
8
8
|
import { registerOrgs } from './orgs.js';
|
|
9
9
|
import { Command, CommanderError } from 'commander';
|
|
10
|
-
import { Genesis, GenesisError, errorBody, errorCatalog, errorOutcome, isMindsOperation, HivesOperationError, HivesQueueOperationError, MindsAgentError, MindsOwnerError, hivesResponseBytes, MAX_FUNCTION_BODY_BYTES, MAX_FUNCTION_JSON_BYTES, DEFAULT_BASE_URL, requireSecureUrl } from '@onesi/genesis';
|
|
10
|
+
import { Genesis, GenesisError, errorBody, errorCatalog, errorOutcome, isMindsOperation, HivesOperationError, HivesQueueOperationError, MindsAgentError, MindsOwnerError, hivesResponseBytes, MAX_FUNCTION_BODY_BYTES, MAX_FUNCTION_JSON_BYTES, DEFAULT_BASE_URL, requireSecureUrl, redactUserinfo } from '@onesi/genesis';
|
|
11
11
|
import { authConfig, completeLogin, selectSavedContext, savedLoginProvider, startLogin } from './auth.js';
|
|
12
12
|
import { completeDeviceLogin, startDeviceLogin } from './device-login.js';
|
|
13
13
|
import { keychainStore } from './store.js';
|
|
@@ -20,6 +20,7 @@ import { registerRunner } from './runner.js';
|
|
|
20
20
|
import { createHivesNodeTransport } from './hives-node-transport.js';
|
|
21
21
|
import { registerHivesOperations } from './hives-operations.js';
|
|
22
22
|
import { registerHivesCoverage } from './hives-coverage.js';
|
|
23
|
+
import { registerHivesProjectDefault } from './hives-project.js';
|
|
23
24
|
import { readFunctionFile, readFunctionJson, writeFunctionOutput } from './function-input.js';
|
|
24
25
|
import { basename } from 'node:path';
|
|
25
26
|
import { readWasmFile } from './wasm-input.js';
|
|
@@ -40,7 +41,7 @@ export function buildProgram(deps = {}) {
|
|
|
40
41
|
const auth = { ...authConfig(env, f), sleep: deps.sleep };
|
|
41
42
|
const program = new Command('genesis')
|
|
42
43
|
.description('One CLI for every Genesis service.')
|
|
43
|
-
.version('0.2.
|
|
44
|
+
.version('0.2.5')
|
|
44
45
|
.option('--json', 'machine-readable JSON output')
|
|
45
46
|
.option('--api-key <key>', 'use this API key (default: GENESIS_API_KEY, then your `genesis login`)')
|
|
46
47
|
.option('--base-url <url>', 'gateway URL (default: GENESIS_BASE_URL or https://os.one.ml/api)')
|
|
@@ -48,7 +49,7 @@ export function buildProgram(deps = {}) {
|
|
|
48
49
|
.option('--org <org_id>', 'organization to act on')
|
|
49
50
|
.showHelpAfterError()
|
|
50
51
|
.exitOverride()
|
|
51
|
-
.configureOutput({ writeOut: (s) => out.log(s.trimEnd()), writeErr: (s) => out.err(s.trimEnd()) });
|
|
52
|
+
.configureOutput({ writeOut: (s) => out.log(s.trimEnd()), writeErr: (s) => out.err(redactUserinfo(s.trimEnd())) });
|
|
52
53
|
const g = () => program.opts();
|
|
53
54
|
const client = async (hivesTransport = false) => {
|
|
54
55
|
const o = g();
|
|
@@ -56,7 +57,7 @@ export function buildProgram(deps = {}) {
|
|
|
56
57
|
const opts = {
|
|
57
58
|
apiKey: o.apiKey ?? env.GENESIS_API_KEY, token: env.GENESIS_TOKEN,
|
|
58
59
|
baseUrl: o.baseUrl ?? env.GENESIS_BASE_URL, routing: o.direct || env.GENESIS_ROUTING === 'direct' ? 'direct' : 'gateway',
|
|
59
|
-
fetch: f, userAgent: 'genesis-cli/0.2.
|
|
60
|
+
fetch: f, userAgent: 'genesis-cli/0.2.5',
|
|
60
61
|
credentials: store ? savedLoginProvider(auth, store) : undefined,
|
|
61
62
|
};
|
|
62
63
|
return new Genesis(hivesTransport ? { ...opts, fetch: createHivesNodeTransport(opts, deps.signal) } : opts);
|
|
@@ -277,7 +278,7 @@ export function buildProgram(deps = {}) {
|
|
|
277
278
|
if (!key)
|
|
278
279
|
throw new Error('Give the enrollment key with --key-file, --key-stdin or GENESIS_ENROLLMENT_KEY; it is never accepted as an argument.');
|
|
279
280
|
const body = await readFunctionJson(o.bodyFile, 16 * 1024);
|
|
280
|
-
const result = await new Genesis({ baseUrl: g().baseUrl ?? env.GENESIS_BASE_URL, fetch: f, userAgent: 'genesis-cli/0.2.
|
|
281
|
+
const result = await new Genesis({ baseUrl: g().baseUrl ?? env.GENESIS_BASE_URL, fetch: f, userAgent: 'genesis-cli/0.2.5' }).iam.agents.enroll(key, body);
|
|
281
282
|
emit(result, () => JSON.stringify(result, null, 2));
|
|
282
283
|
});
|
|
283
284
|
// ---- auth ------------------------------------------------------------
|
|
@@ -691,6 +692,8 @@ export function buildProgram(deps = {}) {
|
|
|
691
692
|
});
|
|
692
693
|
// Last: extends the hives groups defined above (flights, logs, env values, domain reads).
|
|
693
694
|
registerHivesCoverage(hives, { client: hivesClient, emit, readRequest: deps.readHivesRequest });
|
|
695
|
+
// After every hives command exists: prj_… help, and pr_… or omitted project ids resolved from the selected context.
|
|
696
|
+
registerHivesProjectDefault(hives, hivesClient);
|
|
694
697
|
// ---- relays ----------------------------------------------------------
|
|
695
698
|
const relays = program.command('relays').description('Relays: DNS zones and records');
|
|
696
699
|
registerRelaysEnrollment(relays, client, emit);
|
|
@@ -810,7 +813,7 @@ export function buildProgram(deps = {}) {
|
|
|
810
813
|
const url = `${base.href.replace(/\/+$/, '')}/v1/status`;
|
|
811
814
|
let response;
|
|
812
815
|
try {
|
|
813
|
-
response = await f(url, { method: 'GET', headers: { accept: 'application/json', 'user-agent': 'genesis-cli/0.2.
|
|
816
|
+
response = await f(url, { method: 'GET', headers: { accept: 'application/json', 'user-agent': 'genesis-cli/0.2.5' }, signal: AbortSignal.timeout(15_000) });
|
|
814
817
|
}
|
|
815
818
|
catch (e) {
|
|
816
819
|
throw new Error(`Gateway unreachable at ${safe(url)}: ${safe(e.message)}`);
|
|
@@ -823,7 +826,7 @@ export function buildProgram(deps = {}) {
|
|
|
823
826
|
const rows = report.services;
|
|
824
827
|
emit(report, () => [
|
|
825
828
|
table(rows.map((s) => ({ service: s.service, state: s.state, http_status: s.http_status, latency_ms: s.latency_ms, reason: s.reason })), ['service', 'state', 'http_status', 'latency_ms', 'reason']),
|
|
826
|
-
...(report.checked_at ? [c.dim(`checked ${safe(report.checked_at)} via ${safe(url)}`)] : []),
|
|
829
|
+
...(report.checked_at ? [c.dim(`checked ${safe(report.checked_at)} via ${safe(redactUserinfo(url))}`)] : []),
|
|
827
830
|
].join('\n'));
|
|
828
831
|
});
|
|
829
832
|
return program;
|
package/dist/products.js
CHANGED
|
@@ -236,7 +236,7 @@ export const PRODUCT_COMMANDS = {
|
|
|
236
236
|
} },
|
|
237
237
|
// `genesis minds engine <family> <verb> <mind_id> [params]`: every Minds engine route, generated from the grant table.
|
|
238
238
|
minds: { description: 'Minds: your Sandbox Minds (One account login)', commands: mindsEngineCommands },
|
|
239
|
-
boxes: { description: 'Boxes: mail, docs, files, sheets, slides, calendar and identity (org API key; GET boxes:read, writes boxes:write)', commands: {
|
|
239
|
+
boxes: { description: 'Boxes: mail, docs, files, sheets, slides, calendar and identity (org API key; GET boxes:read, writes boxes:write, mail domains boxes:admin)', commands: {
|
|
240
240
|
// boxes:begin
|
|
241
241
|
'mail addresses create': 'boxes_mail_addresses_create',
|
|
242
242
|
'mail addresses list': 'boxes_mail_addresses_list',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onesi/genesis-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/l1felabs/genesis-api.git",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"commander": "^14.0.0",
|
|
35
35
|
"undici": "6.29.0",
|
|
36
|
-
"@onesi/genesis": "0.2.
|
|
36
|
+
"@onesi/genesis": "0.2.5"
|
|
37
37
|
},
|
|
38
38
|
"optionalDependencies": {
|
|
39
39
|
"@napi-rs/keyring": "^1.2.0"
|