@rine-network/cli 0.11.7 → 0.11.8

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 (3) hide show
  1. package/README.md +2 -1
  2. package/dist/main.js +81 -70
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -56,7 +56,8 @@ npx @rine-network/cli onboard --email you@example.com --name "My Org" --slug my-
56
56
  | `rine keys ...` | Status, generate, rotate, export, import E2EE key pairs |
57
57
  | `rine send / read / inbox / reply` | Messaging (with `--payload-file` for file/stdin input) |
58
58
  | `rine group ...` | Group CRUD, join, invite, vote, members |
59
- | `rine webhook ...` | Webhook management |
59
+ | `rine webhook ...` | Outbound webhook management (rine → a URL you host) |
60
+ | `rine hook ... / rine relay` | Inbound webhook Funnel — hook CRUD + the relay daemon (`--tier zero-trust\|shared-edge`) |
60
61
  | `rine discover ...` | Browse and search the agent directory |
61
62
  | `rine poll-token` | Generate or revoke inbox polling token |
62
63
  | `rine stream` | SSE real-time stream with lifecycle events, persistent mode, heartbeat timeout |
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, 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, 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";
4
4
  import readline from "node:readline";
5
5
  import * as fs from "node:fs";
6
6
  import { readFileSync } from "node:fs";
@@ -924,7 +924,7 @@ function resolveTier(raw) {
924
924
  }
925
925
  function registerHook(program) {
926
926
  const hook = program.command("hook").description("Manage inbound webhook funnel hooks");
927
- hook.command("create").description("Allocate a funnel hook and print its GitHub setup (secret shown once)").option("--agent <id>", "Agent ID (defaults to your agent)").option("--name <name>", "Hook name (default: default)", "default").addOption(new Option("--tier <tier>", "TLS-termination override").hideHelp()).action(withClient(program, async ({ client, gOpts, apiUrl, configDir }, opts) => {
927
+ hook.command("create").description("Allocate a funnel hook and print its GitHub setup (secret shown once)").option("--agent <id>", "Agent ID (defaults to your agent)").option("--name <name>", "Hook name (default: default)", "default").addOption(new Option("--tier <tier>", "Termination tier: zero-trust (your relay terminates TLS; rine never sees the cleartext) or shared-edge (rine's broker terminates TLS for high-scale delivery; brief in-memory cleartext, never stored). Default: by trust tier.").choices(Object.keys(TIER_CLI_TO_WIRE))).action(withClient(program, async ({ client, gOpts, apiUrl, configDir }, opts) => {
928
928
  if (!isValidHookName(opts.name)) {
929
929
  printError(`Invalid hook name '${opts.name}': use lowercase letters, digits and hyphens (max 32).`);
930
930
  process.exitCode = 2;
@@ -960,6 +960,7 @@ function registerHook(program) {
960
960
  else printTable(data.items.map((h) => ({
961
961
  Name: h.hook_name,
962
962
  Hostname: h.hostname,
963
+ Tier: h.termination.replace("_", "-"),
963
964
  Active: h.active,
964
965
  Created: h.created_at
965
966
  })));
@@ -991,7 +992,8 @@ function printCreated(created, secret, json) {
991
992
  hook: {
992
993
  name: created.hook_name,
993
994
  hostname: created.hostname,
994
- agent_id: created.agent_id
995
+ agent_id: created.agent_id,
996
+ tier: created.termination
995
997
  },
996
998
  public_url: publicUrl,
997
999
  secret,
@@ -1009,6 +1011,10 @@ function printCreated(created, secret, json) {
1009
1011
  Field: "Hostname",
1010
1012
  Value: created.hostname
1011
1013
  },
1014
+ {
1015
+ Field: "Tier",
1016
+ Value: created.termination.replace("_", "-")
1017
+ },
1012
1018
  {
1013
1019
  Field: "Payload URL",
1014
1020
  Value: publicUrl
@@ -1028,6 +1034,7 @@ function printCreated(created, secret, json) {
1028
1034
  ]);
1029
1035
  console.log(`\nGitHub: Settings → Webhooks → Payload URL = ${publicUrl}, Content type = ${CONTENT_TYPE}, Secret = the secret above.`);
1030
1036
  console.log("Save this secret now — it is not stored on rine and cannot be retrieved.");
1037
+ if (created.termination === "shared_edge") console.log("\nThis hook uses the shared-edge tier: rine's broker briefly handles the decrypted request in memory (never logged or stored) before your relay verifies and re-encrypts it. For delivery where rine never sees the cleartext, recreate with --tier zero-trust.");
1031
1038
  }
1032
1039
  //#endregion
1033
1040
  //#region src/commands/keys.ts
@@ -1770,33 +1777,55 @@ async function runRelayLoop(ctx) {
1770
1777
  try {
1771
1778
  const hook = await resolveHook(client, agentId, opts.hook);
1772
1779
  const { hostname, control_ws_url: controlWsUrl } = hook;
1773
- assertZeroTrustTier(hook);
1774
- certHandle = agentLabel(hostname);
1775
- lastDeps = await buildIssueCertDeps({
1780
+ const onRequest = (req) => handleWebhookRequest({
1776
1781
  configDir,
1777
- options,
1778
- http: client,
1779
- agentId
1780
- });
1781
- certBusy = true;
1782
- let cert;
1783
- try {
1784
- cert = await ensureCert({
1785
- handle: certHandle,
1786
- agentId,
1787
- delegationId: certHandle,
1782
+ agentId,
1783
+ hookName: opts.hook,
1784
+ secret,
1785
+ client,
1786
+ idempotency,
1787
+ emitLifecycle: (ev) => json && console.log(JSON.stringify(ev))
1788
+ }, req).then(() => void 0);
1789
+ const ref = {};
1790
+ let ztCert;
1791
+ let openLocalPipe;
1792
+ if (hook.termination === "shared_edge") {
1793
+ certHandle = void 0;
1794
+ openLocalPipe = makeEdgePipeFactory({ onRequest });
1795
+ emitLifecycle$1(json, {
1796
+ state: "shared_edge_ready",
1797
+ hostname
1798
+ });
1799
+ } else if (hook.termination === "zero_trust") {
1800
+ certHandle = agentLabel(hostname);
1801
+ lastDeps = await buildIssueCertDeps({
1788
1802
  configDir,
1789
1803
  options,
1790
- deps: lastDeps
1804
+ http: client,
1805
+ agentId
1791
1806
  });
1792
- } finally {
1793
- certBusy = false;
1794
- }
1795
- emitLifecycle$1(json, {
1796
- state: "cert_ready",
1797
- hostname
1798
- });
1799
- const ref = {};
1807
+ certBusy = true;
1808
+ try {
1809
+ ztCert = await ensureCert({
1810
+ handle: certHandle,
1811
+ agentId,
1812
+ delegationId: certHandle,
1813
+ configDir,
1814
+ options,
1815
+ deps: lastDeps
1816
+ });
1817
+ } finally {
1818
+ certBusy = false;
1819
+ }
1820
+ emitLifecycle$1(json, {
1821
+ state: "cert_ready",
1822
+ hostname
1823
+ });
1824
+ openLocalPipe = (frame) => {
1825
+ if (!ref.live) throw new Error("listener not ready");
1826
+ return ref.live.openLocalPipe(frame);
1827
+ };
1828
+ } else throw new UnsupportedTierError(hook.termination);
1800
1829
  const tunnel = await connectTunnel({
1801
1830
  controlWsUrl,
1802
1831
  token: await getOrRefreshToken(configDir, apiUrl, entry, profileName, {
@@ -1805,38 +1834,29 @@ async function runRelayLoop(ctx) {
1805
1834
  }),
1806
1835
  agentId,
1807
1836
  hostname,
1808
- openLocalPipe: (frame) => {
1809
- if (!ref.live) throw new Error("listener not ready");
1810
- return ref.live.openLocalPipe(frame);
1811
- }
1837
+ openLocalPipe
1812
1838
  });
1813
1839
  emitLifecycle$1(json, { state: "tunnel_connected" });
1814
- const live = await startTlsListener({
1815
- port,
1816
- certPem: cert.certPem,
1817
- keyPem: cert.keyPem,
1818
- onRequest: (req) => handleWebhookRequest({
1819
- configDir,
1820
- agentId,
1821
- hookName: opts.hook,
1822
- secret,
1823
- client,
1824
- idempotency,
1825
- emitLifecycle: (ev) => json && console.log(JSON.stringify(ev))
1826
- }, req).then(() => void 0)
1827
- });
1828
- listener = live;
1829
- ref.live = live;
1830
- await assertAgentARecord(hostname, json);
1831
- emitLifecycle$1(json, {
1832
- state: "listener_ready",
1833
- port: live.port
1834
- });
1835
- startRenewalTimer();
1840
+ if (hook.termination === "zero_trust" && ztCert) {
1841
+ const live = await startTlsListener({
1842
+ port,
1843
+ certPem: ztCert.certPem,
1844
+ keyPem: ztCert.keyPem,
1845
+ onRequest
1846
+ });
1847
+ listener = live;
1848
+ ref.live = live;
1849
+ await assertAgentARecord(hostname, json);
1850
+ emitLifecycle$1(json, {
1851
+ state: "listener_ready",
1852
+ port: live.port
1853
+ });
1854
+ startRenewalTimer();
1855
+ }
1836
1856
  backoff = 1;
1837
1857
  const close = await waitForClose(tunnel, () => stopped);
1838
1858
  tunnel.close();
1839
- live.close();
1859
+ listener?.close();
1840
1860
  if (stopped) break;
1841
1861
  if (close?.clean !== false) {
1842
1862
  emitLifecycle$1(json, {
@@ -1860,7 +1880,7 @@ async function runRelayLoop(ctx) {
1860
1880
  } catch (err) {
1861
1881
  listener?.close();
1862
1882
  if (stopped) break;
1863
- if (err instanceof SharedEdgeNotSupportedError) {
1883
+ if (err instanceof UnsupportedTierError) {
1864
1884
  if (renewalTimer) clearInterval(renewalTimer);
1865
1885
  printError(err.message);
1866
1886
  process.exitCode = 2;
@@ -1922,26 +1942,17 @@ async function resolveHook(client, agentId, hookName) {
1922
1942
  return hook;
1923
1943
  }
1924
1944
  /**
1925
- * Fatal — this build serves only the zero-trust tier. Thrown (not retried) for a
1926
- * shared-edge hook so the relay never enters a backoff loop it cannot escape.
1945
+ * Fatal — this build implements the zero-trust and shared-edge tiers; an UNKNOWN
1946
+ * `termination` value from a newer backend is thrown (not retried) so the relay
1947
+ * never enters a backoff loop it cannot escape. Upgrade the CLI to serve it.
1927
1948
  */
1928
- var SharedEdgeNotSupportedError = class extends Error {
1929
- constructor() {
1930
- super("This hook was created with a TLS-termination mode this relay build does not support. Delete the hook and create a new one, or upgrade the CLI to a newer build.");
1931
- this.name = "SharedEdgeNotSupportedError";
1949
+ var UnsupportedTierError = class extends Error {
1950
+ constructor(tier) {
1951
+ super(`This hook uses a TLS-termination mode ('${tier}') this relay build does not support. Upgrade the CLI to a newer build, or recreate the hook with a supported --tier.`);
1952
+ this.name = "UnsupportedTierError";
1932
1953
  }
1933
1954
  };
1934
1955
  /**
1935
- * Gate the relay to the zero-trust tier (REQ-TIER-03). The relay branches ONCE on
1936
- * `hook.termination` and this build implements only zero-trust — the relay
1937
- * terminates TLS with a per-agent wildcard cert. Shared-edge is broker-terminated
1938
- * (Phase B); fail LOUD here, BEFORE any `.hook` label/FQDN derivation, so a
1939
- * `.edge` host is never fed to the zero-trust agentLabel deriver (relay F-4).
1940
- */
1941
- function assertZeroTrustTier(hook) {
1942
- if (hook.termination !== "zero_trust") throw new SharedEdgeNotSupportedError();
1943
- }
1944
- /**
1945
1956
  * (AUD-A1) Assert the zero-trust hostname resolves to an A record before
1946
1957
  * declaring the listener ready. The per-agent `*.{agentLabel}.hook` A is a
1947
1958
  * DELIVERY prerequisite written best-effort by the backend (REQ-OPS-04); a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rine-network/cli",
3
- "version": "0.11.7",
3
+ "version": "0.11.8",
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.4",
31
+ "@rine-network/core": "^0.6.5",
32
32
  "commander": "^12.0.0",
33
33
  "eventsource-client": "^1.1.0"
34
34
  },