@rine-network/cli 0.11.8 → 0.13.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.
Files changed (2) hide show
  1. package/dist/main.js +57 -3
  2. package/package.json +2 -2
package/dist/main.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from "node:module";
2
2
  import { Command, Option } from "commander";
3
- import { FUNNEL_TIERS, HttpClient, IdempotencyStore, RineApiError, UUID_RE, addMlsGroupMember, agentKeysExist, agentLabel, buildIssueCertDeps, cacheToken, connectTunnel, decryptGroupMessage, decryptMessage, deleteHookSecret, encryptGroupMessage, encryptMessage, encryptMlsGroupMessage, ensureCert, externalJoinMlsGroup, fetchAgents, fetchAndIngestPendingSKDistributions, fetchOAuthToken, fetchRecipientKeys, formatError, fromBase64Url, generateAgentKeys, generateHookSecret, generatePqKeyPair, getAgentPublicKeys, getCredentialEntry, getOrCreateSenderKey, getOrRefreshToken, handleWebhookRequest, ingestSenderKeyDistribution, initMlsGroup, isBareAgentName, isValidHookName, listMyInvites, loadAgentKeys, loadCredentials, loadHookSecret, loadMeta, loadMlsState, loadTokenCache, makeEdgePipeFactory, normalizeHandle, performAgentCreation, performRegistration, processMlsWelcomes, renewalDueWithJitter, resolveAgent, resolveApiUrl, resolveConfigDir, resolveHandleViaWebFinger, resolveToUuid, saveAgentKeys, saveCredentials, saveHookSecret, savePqEncryptionKey, saveTokenCache, sendGroupInviteNotification, startTlsListener, syncMlsGroup, toBase64Url, validateEncryptionKey, validateSigningKey, validateSlug } from "@rine-network/core";
3
+ import { FUNNEL_TIERS, HttpClient, IdempotencyStore, RineApiError, UUID_RE, addMlsGroupMember, agentKeysExist, agentLabel, buildIssueCertDeps, cacheToken, connectTunnel, decryptGroupMessage, decryptMessage, decryptThreadRow, deleteHookSecret, encryptGroupMessage, encryptMessage, encryptMlsGroupMessage, ensureCert, externalJoinMlsGroup, fetchAgents, fetchAndIngestPendingSKDistributions, fetchOAuthToken, fetchRecipientKeys, formatError, fromBase64Url, generateAgentKeys, generateHookSecret, generatePqKeyPair, getAgentPublicKeys, getCredentialEntry, getOrCreateSenderKey, getOrRefreshToken, handleWebhookRequest, hasSpiffeEndpoint, ingestSenderKeyDistribution, initMlsGroup, isBareAgentName, isValidHookName, listMyInvites, loadAgentKeys, loadCredentials, loadHookSecret, loadMeta, loadMlsState, loadTokenCache, makeEdgePipeFactory, normalizeHandle, performAgentCreation, performRegistration, processMlsWelcomes, renewalDueWithJitter, resolveAgent, resolveApiUrl, resolveConfigDir, resolveHandleViaWebFinger, resolveToUuid, saveAgentKeys, saveCredentials, saveHookSecret, savePqEncryptionKey, saveTokenCache, sendGroupInviteNotification, startTlsListener, syncMlsGroup, toBase64Url, validateEncryptionKey, validateSigningKey, validateSlug, verifyIdentitySpiffe } from "@rine-network/core";
4
4
  import readline from "node:readline";
5
5
  import * as fs from "node:fs";
6
6
  import { readFileSync } from "node:fs";
@@ -329,6 +329,11 @@ function registerAgent(program) {
329
329
  console.log("E2EE keys generated and stored locally.");
330
330
  if (data.verification_words) console.log(`Verification words: ${data.verification_words}`);
331
331
  if (data.poll_url) console.log(`Poll URL: ${data.poll_url}`);
332
+ if (data.identity) console.log(`SPIFFE identity verified: ${data.identity.spiffe_id} (trust tier ${data.identity.trust_tier})`);
333
+ }
334
+ if (data.identityError) {
335
+ printError(`Agent created, but SPIFFE identity verification failed: ${data.identityError}\nRetry with: rine verify-identity --agent ${data.id} --svid <jwt>`);
336
+ process.exitCode = 1;
332
337
  }
333
338
  }));
334
339
  agent.command("list").description("List all agents").option("--include-revoked", "Include revoked agents").action(withClient(program, async ({ client, gOpts }, opts) => {
@@ -1284,6 +1289,18 @@ function inboxRow(m) {
1284
1289
  Created: m.created_at
1285
1290
  };
1286
1291
  }
1292
+ /** One thread turn rendered as a role-tagged row (`[sent]` you / `[received]`). */
1293
+ function threadRow(e) {
1294
+ const who = e.direction === "sent" ? "you" : e.sender_handle ?? "unknown";
1295
+ return {
1296
+ Direction: `[${e.direction}]`,
1297
+ From: who,
1298
+ Type: e.type,
1299
+ Verified: e.verification_status === "verified" ? "✓" : e.verification_status === "invalid" ? "✗ INVALID" : "?",
1300
+ Text: e.text,
1301
+ Created: e.created_at
1302
+ };
1303
+ }
1287
1304
  function resolvePayload(payload, payloadFile) {
1288
1305
  if (payload !== void 0 && payloadFile !== void 0) return { error: "--payload and --payload-file are mutually exclusive" };
1289
1306
  if (payload === void 0 && payloadFile === void 0) return { error: "Provide --payload or --payload-file" };
@@ -1478,6 +1495,15 @@ function addMessageCommands(parent, program) {
1478
1495
  process.exitCode = 1;
1479
1496
  }
1480
1497
  }));
1498
+ parent.command("thread").description("Show the both-sided, decrypted transcript of a conversation (role-tagged)").argument("<conversation-id>", "Conversation ID").option("--agent <id>", "Agent ID (defaults to your agent)").option("--limit <n>", "Max turns to return (most-recent window)").action(withClient(program, async ({ client, gOpts, configDir, apiUrl }, conversationId, opts) => {
1499
+ const agentId = await resolveAgent(apiUrl, await fetchAgents(client), opts.agent, gOpts.as);
1500
+ const params = {};
1501
+ if (opts.limit) params.limit = opts.limit;
1502
+ const data = await client.get(`/conversations/${conversationId}/messages`, params, { "X-Rine-Agent": agentId });
1503
+ const entries = await Promise.all((data.messages ?? []).map((row) => decryptThreadRow(configDir, agentId, row, client)));
1504
+ if (gOpts.json) printJson(entries);
1505
+ else printTable(entries.map(threadRow));
1506
+ }));
1481
1507
  }
1482
1508
  function registerMessages(program) {
1483
1509
  addMessageCommands(program, program);
@@ -1486,7 +1512,7 @@ function registerMessages(program) {
1486
1512
  //#endregion
1487
1513
  //#region src/commands/onboard.ts
1488
1514
  function registerOnboard(program) {
1489
- program.command("onboard").description("Register a new organization and create your first agent").requiredOption("--email <email>", "Email address").requiredOption("--name <name>", "Organization name").requiredOption("--slug <slug>", "Organization slug").requiredOption("--agent <agent-name>", "Name for the first agent").option("--[no-]human-oversight", "Require human oversight (default: true)").option("--unlisted", "Mark agent as unlisted (not in public directory)").action(withErrorHandler(program, async (gOpts, opts) => {
1515
+ program.command("onboard").description("Register a new organization and create your first agent").requiredOption("--email <email>", "Email address").requiredOption("--name <name>", "Organization name").requiredOption("--slug <slug>", "Organization slug").requiredOption("--agent <agent-name>", "Name for the first agent").option("--[no-]human-oversight", "Require human oversight (default: true)").option("--unlisted", "Mark agent as unlisted (not in public directory)").option("--verify-identity", "After creating the agent, prove a SPIFFE identity (auto-runs when SPIFFE_ENDPOINT_SOCKET is set)").option("--svid <jwt>", "SPIFFE JWT-SVID to use for --verify-identity (when no Workload API auto-fetch is available)").action(withErrorHandler(program, async (gOpts, opts) => {
1490
1516
  const profile = gOpts.profile ?? "default";
1491
1517
  const configDir = resolveConfigDir();
1492
1518
  const apiUrl = resolveApiUrl();
@@ -1528,13 +1554,17 @@ function registerOnboard(program) {
1528
1554
  const agent = await performAgentCreation(client, configDir, profile, {
1529
1555
  name: opts.agent,
1530
1556
  humanOversight: opts.humanOversight,
1531
- unlisted: opts.unlisted
1557
+ unlisted: opts.unlisted,
1558
+ verifyIdentity: opts.verifyIdentity || Boolean(opts.svid) || hasSpiffeEndpoint(),
1559
+ svid: opts.svid
1532
1560
  });
1533
1561
  if (gOpts.json) printJson({
1534
1562
  org_id: regResult.org_id,
1535
1563
  client_id: regResult.client_id,
1536
1564
  agent,
1537
1565
  poll_url: agent.poll_url,
1566
+ identity: agent.identity,
1567
+ identity_error: agent.identityError,
1538
1568
  config_dir: configDir
1539
1569
  });
1540
1570
  else {
@@ -1545,6 +1575,11 @@ function registerOnboard(program) {
1545
1575
  console.log(`\nAgent '${agent.name}' created — reachable at ${agent.handle}`);
1546
1576
  if (agent.verification_words) console.log(`Verification words: ${agent.verification_words}`);
1547
1577
  if (agent.poll_url) console.log(`Poll URL: ${agent.poll_url}`);
1578
+ if (agent.identity) console.log(`SPIFFE identity verified: ${agent.identity.spiffe_id} (trust tier ${agent.identity.trust_tier})`);
1579
+ }
1580
+ if (agent.identityError) {
1581
+ printError(`Agent created, but SPIFFE identity verification failed: ${agent.identityError}\nRetry with: rine verify-identity --agent ${agent.id} --svid <jwt>`);
1582
+ process.exitCode = 1;
1548
1583
  }
1549
1584
  }));
1550
1585
  }
@@ -2218,6 +2253,24 @@ function registerStream(program) {
2218
2253
  });
2219
2254
  }
2220
2255
  //#endregion
2256
+ //#region src/commands/verify-identity.ts
2257
+ function printResult(result) {
2258
+ console.log(`SPIFFE identity verified for agent ${result.agent_id}`);
2259
+ console.log(` SPIFFE ID: ${result.spiffe_id}`);
2260
+ console.log(` Trust domain: ${result.trust_domain}`);
2261
+ console.log(` Trust tier: ${result.trust_tier}`);
2262
+ console.log(` Verified at: ${result.verified_at}`);
2263
+ }
2264
+ function registerVerifyIdentity(program) {
2265
+ program.command("verify-identity").description("Prove control of a SPIFFE identity for an agent (elevates the org to trust tier 2)").option("--agent <id>", "Agent UUID, handle, or name (defaults to the only agent)").option("--svid <jwt>", "A SPIFFE JWT-SVID. Required unless a Workload API auto-fetch is available.").action(withClient(program, async (ctx, opts) => {
2266
+ const agents = await fetchAgents(ctx.client);
2267
+ const agentId = await resolveAgent(ctx.apiUrl, agents, opts.agent, ctx.gOpts.as);
2268
+ const result = await verifyIdentitySpiffe(ctx.client, agentId, { svid: opts.svid });
2269
+ if (ctx.gOpts.json) printJson(result);
2270
+ else printResult(result);
2271
+ }));
2272
+ }
2273
+ //#endregion
2221
2274
  //#region src/commands/webhook.ts
2222
2275
  function registerWebhook(program) {
2223
2276
  const webhook = program.command("webhook").description("Manage webhooks");
@@ -2306,6 +2359,7 @@ registerKeys(program);
2306
2359
  registerStream(program);
2307
2360
  registerRelay(program);
2308
2361
  registerPollToken(program);
2362
+ registerVerifyIdentity(program);
2309
2363
  program.parse();
2310
2364
  //#endregion
2311
2365
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rine-network/cli",
3
- "version": "0.11.8",
3
+ "version": "0.13.0",
4
4
  "description": "CLI client for rine.network \u2014 EU-first messaging infrastructure for AI agents",
5
5
  "author": "mmmbs <mmmbs@proton.me>",
6
6
  "license": "EUPL-1.2",
@@ -28,7 +28,7 @@
28
28
  "dev": "tsx src/main.ts"
29
29
  },
30
30
  "dependencies": {
31
- "@rine-network/core": "^0.6.5",
31
+ "@rine-network/core": "^0.8.0",
32
32
  "commander": "^12.0.0",
33
33
  "eventsource-client": "^1.1.0"
34
34
  },