@onesi/genesis-cli 0.2.13 → 0.2.14
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/agents.d.ts +13 -0
- package/dist/agents.js +41 -0
- package/dist/dials.js +2 -0
- package/dist/index.js +6 -4
- package/package.json +2 -2
package/README.md
CHANGED
package/dist/agents.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
import { type Genesis } from '@onesi/genesis';
|
|
3
|
+
type Dependencies = {
|
|
4
|
+
client: () => Promise<Genesis>;
|
|
5
|
+
emit: (data: unknown, pretty: () => string) => void;
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* `genesis agents search <q...>` and `genesis agents sitemap`: public agent search (Live agents their owners made
|
|
10
|
+
* public). No login is needed; no credential is sent and nothing is metered.
|
|
11
|
+
*/
|
|
12
|
+
export declare function registerAgents(program: Command, deps: Dependencies): void;
|
|
13
|
+
export {};
|
package/dist/agents.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AGENT_SEARCH_LIMIT_MAX, AGENT_SEARCH_Q_MAX } from '@onesi/genesis';
|
|
2
|
+
import { c, safe, table } from './output.js';
|
|
3
|
+
/** One hit as the terminal prints it; every server-provided field goes through safe(). */
|
|
4
|
+
function hitLines(hit) {
|
|
5
|
+
const head = `${c.bold(safe(hit.name ?? hit.agentId))} ${c.dim(safe(hit.agentId))}${hit.owner ? ` ${safe(hit.owner.name)}` : ''}`;
|
|
6
|
+
const lines = [head, ` ${c.dim(safe(hit.did))}`];
|
|
7
|
+
if (hit.description)
|
|
8
|
+
lines.push(` ${safe(hit.description)}`);
|
|
9
|
+
if (hit.createdAt)
|
|
10
|
+
lines.push(` ${c.dim(`created ${new Date(hit.createdAt).toISOString().slice(0, 10)}`)}`);
|
|
11
|
+
return lines.join('\n');
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* `genesis agents search <q...>` and `genesis agents sitemap`: public agent search (Live agents their owners made
|
|
15
|
+
* public). No login is needed; no credential is sent and nothing is metered.
|
|
16
|
+
*/
|
|
17
|
+
export function registerAgents(program, deps) {
|
|
18
|
+
const agents = program.command('agents').description('Public agent search: Live agents their owners made public (no login needed, never metered)');
|
|
19
|
+
agents.command('search <q...>')
|
|
20
|
+
.description(`Search public agents (GET /v1/agents/search); the words are joined into one query of 1 to ${AGENT_SEARCH_Q_MAX} characters`)
|
|
21
|
+
.option('--limit <n>', `most results, 1 to ${AGENT_SEARCH_LIMIT_MAX} (default ${AGENT_SEARCH_LIMIT_MAX})`)
|
|
22
|
+
.action(async (words, o) => {
|
|
23
|
+
const q = words.join(' ');
|
|
24
|
+
if (q.trim() === '' || q.length > AGENT_SEARCH_Q_MAX)
|
|
25
|
+
throw new Error(`The query must be 1 to ${AGENT_SEARCH_Q_MAX} characters.`);
|
|
26
|
+
let limit;
|
|
27
|
+
if (o.limit !== undefined) {
|
|
28
|
+
if (!/^[0-9]{1,2}$/.test(o.limit) || Number(o.limit) < 1 || Number(o.limit) > AGENT_SEARCH_LIMIT_MAX)
|
|
29
|
+
throw new Error(`--limit must be an integer from 1 to ${AGENT_SEARCH_LIMIT_MAX}.`);
|
|
30
|
+
limit = Number(o.limit);
|
|
31
|
+
}
|
|
32
|
+
const result = await (await deps.client()).agents.search(q, { ...(limit === undefined ? {} : { limit }), ...(deps.signal ? { signal: deps.signal } : {}) });
|
|
33
|
+
deps.emit(result, () => result.results.length ? result.results.map(hitLines).join('\n\n') : c.dim('(no public agents match)'));
|
|
34
|
+
});
|
|
35
|
+
agents.command('sitemap')
|
|
36
|
+
.description('Every public agent id with when it last changed (GET /v1/agents/sitemap)')
|
|
37
|
+
.action(async () => {
|
|
38
|
+
const result = await (await deps.client()).agents.sitemap(deps.signal ? { signal: deps.signal } : {});
|
|
39
|
+
deps.emit(result, () => table(result.agents.map(a => ({ agentId: a.agentId, updatedAt: new Date(a.updatedAt).toISOString() })), ['agentId', 'updatedAt']));
|
|
40
|
+
});
|
|
41
|
+
}
|
package/dist/dials.js
CHANGED
|
@@ -76,6 +76,8 @@ export function registerDials(program, dependencies) {
|
|
|
76
76
|
workflows.command('list', { isDefault: true }).action(async () => { const { client, scope } = await context(); emit(await client.dials.workflows.list(scope)); });
|
|
77
77
|
workflows.command('deploy').requiredOption('--body <json-or-@file>', 'Workflow graph and actorId')
|
|
78
78
|
.action(async (options) => { const { client, scope } = await context(); const body = await readBody(options.body); emit(await client.call('dials_deployWorkflow', { body: { ...body, scope } })); });
|
|
79
|
+
workflows.command('delete').requiredOption('--workflow <id>', 'Owned workflow ID; deletes it and its routing descriptor (409 while a held number is assigned)')
|
|
80
|
+
.action(async (options) => { const { client, scope } = await context(); emit(await client.dials.workflows.delete(options.workflow, { scope })); });
|
|
79
81
|
numbers.command('delete').requiredOption('--number <id>', 'Owned number ID to release at the carrier').requiredOption('--actor <id>', 'Actual actorId').option('--reason <text>', 'Release reason').option('--platform <id>', 'Selected data platform; omitted defaults to dials')
|
|
80
82
|
.action(async (options) => { const { client, scope } = await context(); emit(await client.dials.numbers.delete({ ...scope, ...(options.platform !== undefined ? { platformId: options.platform } : {}), number_id: options.number, actorId: options.actor, ...(options.reason !== undefined ? { reason: options.reason } : {}) })); });
|
|
81
83
|
const calls = dials.command('calls').description('Call activity and approved outbound calls');
|
package/dist/index.js
CHANGED
|
@@ -7,6 +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 { registerConnections } from './connections.js';
|
|
10
|
+
import { registerAgents } from './agents.js';
|
|
10
11
|
import { Command, CommanderError } from 'commander';
|
|
11
12
|
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';
|
|
12
13
|
import { authConfig, completeLogin, selectSavedContext, savedLoginProvider, startLogin } from './auth.js';
|
|
@@ -48,7 +49,7 @@ export function buildProgram(deps = {}) {
|
|
|
48
49
|
const auth = { ...authConfig(env, f), sleep: deps.sleep };
|
|
49
50
|
const program = new Command('genesis')
|
|
50
51
|
.description('One CLI for every Genesis service.')
|
|
51
|
-
.version('0.2.
|
|
52
|
+
.version('0.2.14')
|
|
52
53
|
.option('--json', 'machine-readable JSON output')
|
|
53
54
|
.option('--api-key <key>', 'use this API key (default: GENESIS_API_KEY, then your `genesis login`)')
|
|
54
55
|
.option('--base-url <url>', 'gateway URL (default: GENESIS_BASE_URL or https://os.one.ml/api)')
|
|
@@ -64,7 +65,7 @@ export function buildProgram(deps = {}) {
|
|
|
64
65
|
const opts = {
|
|
65
66
|
apiKey: o.apiKey ?? env.GENESIS_API_KEY, token: env.GENESIS_TOKEN,
|
|
66
67
|
baseUrl: o.baseUrl ?? env.GENESIS_BASE_URL, routing: o.direct || env.GENESIS_ROUTING === 'direct' ? 'direct' : 'gateway',
|
|
67
|
-
fetch: f, userAgent: 'genesis-cli/0.2.
|
|
68
|
+
fetch: f, userAgent: 'genesis-cli/0.2.14',
|
|
68
69
|
credentials: store ? savedLoginProvider(auth, store) : undefined,
|
|
69
70
|
};
|
|
70
71
|
return new Genesis(hivesTransport ? { ...opts, fetch: createHivesNodeTransport(opts, deps.signal) } : opts);
|
|
@@ -276,6 +277,7 @@ export function buildProgram(deps = {}) {
|
|
|
276
277
|
registerProducts(program, { client, emit, signal: deps.signal });
|
|
277
278
|
registerOrgs(program, { client, emit, signal: deps.signal });
|
|
278
279
|
registerConnections(program, { client, emit, signal: deps.signal });
|
|
280
|
+
registerAgents(program, { client, emit, signal: deps.signal });
|
|
279
281
|
// Agent enrollment sends only the grant's enrollment key (mek_...), never this CLI's login or API key.
|
|
280
282
|
(program.commands.find(c => c.name() === 'iam').commands.find(c => c.name() === 'agents')).command('enroll')
|
|
281
283
|
.description('Enroll an agent under an agent enrollment grant (POST /v1/iam/agents/enroll); the credential secret is shown once')
|
|
@@ -286,7 +288,7 @@ export function buildProgram(deps = {}) {
|
|
|
286
288
|
if (!key)
|
|
287
289
|
throw new Error('Give the enrollment key with --key-file, --key-stdin or GENESIS_ENROLLMENT_KEY; it is never accepted as an argument.');
|
|
288
290
|
const body = await readFunctionJson(o.bodyFile, 16 * 1024);
|
|
289
|
-
const result = await new Genesis({ baseUrl: g().baseUrl ?? env.GENESIS_BASE_URL, fetch: f, userAgent: 'genesis-cli/0.2.
|
|
291
|
+
const result = await new Genesis({ baseUrl: g().baseUrl ?? env.GENESIS_BASE_URL, fetch: f, userAgent: 'genesis-cli/0.2.14' }).iam.agents.enroll(key, body);
|
|
290
292
|
emit(result, () => JSON.stringify(result, null, 2));
|
|
291
293
|
});
|
|
292
294
|
// ---- auth ------------------------------------------------------------
|
|
@@ -838,7 +840,7 @@ export function buildProgram(deps = {}) {
|
|
|
838
840
|
const url = `${base.href.replace(/\/+$/, '')}/v1/status`;
|
|
839
841
|
let response;
|
|
840
842
|
try {
|
|
841
|
-
response = await f(url, { method: 'GET', headers: { accept: 'application/json', 'user-agent': 'genesis-cli/0.2.
|
|
843
|
+
response = await f(url, { method: 'GET', headers: { accept: 'application/json', 'user-agent': 'genesis-cli/0.2.14' }, signal: AbortSignal.timeout(15_000) });
|
|
842
844
|
}
|
|
843
845
|
catch (e) {
|
|
844
846
|
throw new Error(`Gateway unreachable at ${safe(url)}: ${safe(e.message)}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onesi/genesis-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.14",
|
|
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.14"
|
|
37
37
|
},
|
|
38
38
|
"optionalDependencies": {
|
|
39
39
|
"@napi-rs/keyring": "^1.2.0"
|