@heyanon-arp/cli 0.0.24 → 0.0.25

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/dist/cli.js CHANGED
@@ -733,7 +733,7 @@ var import_commander = require("commander");
733
733
  // package.json
734
734
  var package_default = {
735
735
  name: "@heyanon-arp/cli",
736
- version: "0.0.24",
736
+ version: "0.0.25",
737
737
  description: "Command-line client for the Agent Relationship Protocol \u2014 register agents, sign envelopes, run escrowed work cycles on Solana.",
738
738
  license: "MIT",
739
739
  keywords: ["arp", "agent-relationship-protocol", "did", "solana", "escrow", "ed25519", "agents", "a2a", "cli"],
@@ -822,6 +822,14 @@ function optionPlacementHelpNote() {
822
822
  ` ${import_chalk.default.cyan("heyarp <command> [options]")} ${import_chalk.default.dim("e.g. heyarp relationships --json --from-did did:arp:\u2026")}`
823
823
  ].join("\n");
824
824
  }
825
+ var CliError = class extends Error {
826
+ constructor(code, message, details) {
827
+ super(message);
828
+ this.code = code;
829
+ this.details = details;
830
+ this.name = "CliError";
831
+ }
832
+ };
825
833
  function toCliErrorJson(err, includeStack = false) {
826
834
  const { ApiError: ApiError2 } = (init_api(), __toCommonJS(api_exports));
827
835
  if (err instanceof ApiError2) {
@@ -830,6 +838,12 @@ function toCliErrorJson(err, includeStack = false) {
830
838
  if (details !== void 0) out2.details = details;
831
839
  return out2;
832
840
  }
841
+ if (err instanceof CliError) {
842
+ const out2 = { code: err.code, message: err.message };
843
+ if (err.details) out2.details = err.details;
844
+ if (includeStack && err.stack) out2.details = { ...out2.details, stack: err.stack };
845
+ return out2;
846
+ }
833
847
  if (err instanceof Error && err.code === "OUTBOUND_BLOCKED") {
834
848
  const e = err;
835
849
  const reasons = e.verdict?.reasons ?? e.reasons;
@@ -1281,7 +1295,9 @@ ${verb}.`));
1281
1295
 
1282
1296
  // src/commands/agents.ts
1283
1297
  function registerAgentsCommand(root) {
1284
- const agents = root.command("agents").description("Search published agents (reputation-ranked) \u2014 filter by tag / text / creator account / accepted asset / online").option("--server <url>", "Override ARP server base URL").option("--tag <s>", "Filter by capability tag \u2014 repeatable; AND-semantics across tags", accumulate2, []).option("--query <s>", "Full-text search over name + description").option("--account-id <wallet>", "Filter to a creator account (owner wallet, base58)").option("--accepts <asset>", "Filter to agents that accept this asset \u2014 shorthand (SOL:solana-devnet) or CAIP-19. Matches accept-anything agents too.").option("--online", "Only agents seen within the liveness window", false).option("--sort <mode>", "reputation (default) | recent | created", "reputation").option("--page <n>", "Zero-based page index (reputation/recent sorts)", "0").option("--after <id>", "Cursor for --sort created: the previous page's last `id`").option("--limit <n>", "Max rows to return (1..100)", "20").option(
1298
+ const agents = root.command("agents").description(
1299
+ "Search published agents (reputation-ranked) \u2014 ONLINE-only by default (seen within the liveness window); --all includes offline. Filter by tag / text / creator account / accepted asset."
1300
+ ).option("--server <url>", "Override ARP server base URL").option("--tag <s>", "Filter by capability tag \u2014 repeatable; AND-semantics across tags", accumulate2, []).option("--query <s>", "Full-text search over name + description").option("--account-id <wallet>", "Filter to a creator account (owner wallet, base58)").option("--accepts <asset>", "Filter to agents that accept this asset \u2014 shorthand (SOL:solana-devnet) or CAIP-19. Matches accept-anything agents too.").option("--all", "Include offline agents too \u2014 by default only agents seen within the ~5-min liveness window are listed", false).option("--sort <mode>", "reputation (default) | recent | created", "reputation").option("--page <n>", "Zero-based page index (reputation/recent sorts)", "0").option("--after <id>", "Cursor for --sort created: the previous page's last `id`").option("--limit <n>", "Max rows to return (1..100)", "20").option(
1285
1301
  "--verbose",
1286
1302
  'After the one-line summaries, print a framed "Full agent payloads (N rows)" block containing the JSON array of all rows (with owner-string sanitisation for terminal safety)',
1287
1303
  false
@@ -1318,7 +1334,7 @@ async function runAgents(opts) {
1318
1334
  if (opts.query) query.q = opts.query;
1319
1335
  if (opts.accountId) query.accountId = opts.accountId;
1320
1336
  if (opts.accepts) query.accepts = resolveAcceptsAsset(opts.accepts);
1321
- if (opts.online) query.online = true;
1337
+ if (!opts.all) query.online = true;
1322
1338
  if (sort === import_sdk3.DiscoverySorts.CREATED) {
1323
1339
  if (opts.after) query.after = opts.after;
1324
1340
  } else {
@@ -1705,8 +1721,8 @@ function unknownKey(key) {
1705
1721
 
1706
1722
  // src/commands/delegation.ts
1707
1723
  var import_node_fs4 = require("fs");
1708
- var import_sdk12 = require("@heyanon-arp/sdk");
1709
- var import_chalk9 = __toESM(require("chalk"));
1724
+ var import_sdk13 = require("@heyanon-arp/sdk");
1725
+ var import_chalk11 = __toESM(require("chalk"));
1710
1726
  init_api();
1711
1727
 
1712
1728
  // src/id-format.ts
@@ -1744,30 +1760,181 @@ function requireUuid(cmdName, raw, label) {
1744
1760
  throw new Error(hint ? `${base} \u2014 ${hint}` : base);
1745
1761
  }
1746
1762
 
1747
- // src/resolve-recipient.ts
1763
+ // src/recipient-liveness.ts
1764
+ var import_chalk8 = __toESM(require("chalk"));
1765
+
1766
+ // src/commands/doctor.ts
1748
1767
  var import_sdk7 = require("@heyanon-arp/sdk");
1749
1768
  var import_chalk7 = __toESM(require("chalk"));
1750
1769
  init_api();
1770
+ function registerDoctorCommand(root) {
1771
+ root.command("doctor").description("Liveness probe for a counterparty: resolve DID document + read protocol activity. No auth.").argument("<did>", "did:arp:<base58btc> of the agent to probe").option("--server <url>", "Override ARP server base URL").option("--json", "Machine-readable: single JSON object on stdout. Pipe-safe.", false).action(async (did, opts) => {
1772
+ await runDoctor(did, opts);
1773
+ });
1774
+ }
1775
+ var LISTENING_THRESHOLD_SECONDS = 15 * 60;
1776
+ async function runDoctor(did, opts) {
1777
+ if (!(0, import_sdk7.isValidDid)(did)) {
1778
+ throw new Error(`'${did}' is not a syntactically valid did:arp identifier`);
1779
+ }
1780
+ const api = new ArpApiClient(opts.server);
1781
+ const result = await probe(api, did);
1782
+ if (opts.json) {
1783
+ console.log(JSON.stringify(result));
1784
+ } else {
1785
+ console.log(formatDoctorReport(result));
1786
+ }
1787
+ if (result.verdict !== "LISTENING") {
1788
+ process.exitCode = 1;
1789
+ }
1790
+ }
1791
+ async function probe(api, did) {
1792
+ const base = {
1793
+ did,
1794
+ server: api.serverUrl,
1795
+ didDocument: { found: false },
1796
+ verdict: "UNKNOWN",
1797
+ reason: ""
1798
+ };
1799
+ let doc;
1800
+ try {
1801
+ doc = await api.getDidDocument(did);
1802
+ } catch (err) {
1803
+ if (err instanceof ApiError && err.status === 404) {
1804
+ return { ...base, verdict: "UNKNOWN", reason: "DID not registered on this server" };
1805
+ }
1806
+ return { ...base, verdict: "UNKNOWN", reason: `DID document fetch failed: ${err.message}` };
1807
+ }
1808
+ base.didDocument = { found: true, registeredAt: doc.metadata?.registered_at };
1809
+ let activity;
1810
+ try {
1811
+ const summary = await api.getActivitySummary(did);
1812
+ const asOfMs = new Date(summary.asOf).getTime();
1813
+ const lastMs = summary.lastEventAt ? new Date(summary.lastEventAt).getTime() : null;
1814
+ const ageSeconds = lastMs !== null ? Math.max(0, Math.floor((asOfMs - lastMs) / 1e3)) : null;
1815
+ const seenMs = summary.lastSeenAt ? new Date(summary.lastSeenAt).getTime() : null;
1816
+ const seenAgeSeconds = seenMs !== null ? Math.max(0, Math.floor((asOfMs - seenMs) / 1e3)) : null;
1817
+ activity = {
1818
+ lastEventAt: summary.lastEventAt,
1819
+ asOf: summary.asOf,
1820
+ ageSeconds,
1821
+ lastSeenAt: summary.lastSeenAt ?? null,
1822
+ seenAgeSeconds,
1823
+ inboxStreamActive: summary.inboxStreamActive
1824
+ };
1825
+ } catch {
1826
+ return { ...base, verdict: "UNKNOWN", reason: "DID resolves but the server does not expose an activity summary \u2014 cannot assess liveness" };
1827
+ }
1828
+ const recentlyActive = activity.ageSeconds !== null && activity.ageSeconds !== void 0 && activity.ageSeconds <= LISTENING_THRESHOLD_SECONDS;
1829
+ const recentlySeen = activity.seenAgeSeconds !== null && activity.seenAgeSeconds !== void 0 && activity.seenAgeSeconds <= LISTENING_THRESHOLD_SECONDS;
1830
+ const inboxStreamActive = activity.inboxStreamActive === true;
1831
+ const result = { ...base, activity };
1832
+ if (inboxStreamActive) {
1833
+ return {
1834
+ ...result,
1835
+ verdict: "LISTENING",
1836
+ reason: "inbox-stream attached (active SSE subscription on the central server) \u2014 protocol-reachable; worker is actively waiting for envelopes"
1837
+ };
1838
+ }
1839
+ if (recentlySeen) {
1840
+ const seenStr = activity.seenAgeSeconds !== void 0 && activity.seenAgeSeconds !== null ? `${activity.seenAgeSeconds}s ago` : "recently";
1841
+ return {
1842
+ ...result,
1843
+ verdict: "LISTENING",
1844
+ reason: `recently seen (signed API request ${seenStr}) \u2014 agent is polling the server (cron-mode worker)`
1845
+ };
1846
+ }
1847
+ if (recentlyActive) {
1848
+ const ageStr = activity.ageSeconds !== void 0 && activity.ageSeconds !== null ? `${activity.ageSeconds}s ago` : "recently";
1849
+ return {
1850
+ ...result,
1851
+ verdict: "LISTENING",
1852
+ reason: `inbox-active (last event ${ageStr}) \u2014 protocol-reachable via the central ARP server`
1853
+ };
1854
+ }
1855
+ const ageNote = activity.lastEventAt === null ? "no events ever" : `last event ${activity.ageSeconds}s ago`;
1856
+ const seenNote = activity.lastSeenAt === null || activity.lastSeenAt === void 0 ? "never seen polling" : `last seen ${activity.seenAgeSeconds}s ago`;
1857
+ return { ...result, verdict: "DORMANT", reason: `no open inbox stream, ${seenNote}, and ${ageNote} \u2014 agent appears idle (cross-check before relying on it)` };
1858
+ }
1859
+ function formatDoctorReport(r) {
1860
+ const lines = [];
1861
+ lines.push(`${import_chalk7.default.dim("Server:")} ${r.server}`);
1862
+ lines.push(`${import_chalk7.default.dim("Target DID:")} ${r.did}`);
1863
+ if (!r.didDocument.found) {
1864
+ lines.push(`${import_chalk7.default.dim("DID doc:")} ${import_chalk7.default.red("\u2717")} not found`);
1865
+ } else {
1866
+ const registered = r.didDocument.registeredAt ? ` (registered ${r.didDocument.registeredAt})` : "";
1867
+ lines.push(`${import_chalk7.default.dim("DID doc:")} ${import_chalk7.default.green("\u2713")} resolved${registered}`);
1868
+ }
1869
+ if (r.activity) {
1870
+ if (r.activity.lastEventAt === null) {
1871
+ lines.push(`${import_chalk7.default.dim("Activity:")} ${import_chalk7.default.dim("(no events ever \u2014 fresh agent)")}`);
1872
+ } else {
1873
+ const ageMin = r.activity.ageSeconds !== null ? Math.floor(r.activity.ageSeconds / 60) : null;
1874
+ const ageStr = ageMin !== null && ageMin > 0 ? `${ageMin}m ago` : `${r.activity.ageSeconds}s ago`;
1875
+ lines.push(`${import_chalk7.default.dim("Activity:")} last event ${ageStr} (${r.activity.lastEventAt})`);
1876
+ }
1877
+ if (r.activity.lastSeenAt !== null && r.activity.lastSeenAt !== void 0) {
1878
+ const seenMin = r.activity.seenAgeSeconds !== null && r.activity.seenAgeSeconds !== void 0 ? Math.floor(r.activity.seenAgeSeconds / 60) : null;
1879
+ const seenStr = seenMin !== null && seenMin > 0 ? `${seenMin}m ago` : `${r.activity.seenAgeSeconds}s ago`;
1880
+ lines.push(`${import_chalk7.default.dim("Last seen:")} signed request ${seenStr} (${r.activity.lastSeenAt})`);
1881
+ }
1882
+ if (r.activity.inboxStreamActive === true) {
1883
+ lines.push(`${import_chalk7.default.dim("Inbox SSE:")} ${import_chalk7.default.green("\u2713")} active subscription on the central server`);
1884
+ }
1885
+ }
1886
+ const verdictColor = r.verdict === "LISTENING" ? import_chalk7.default.green : r.verdict === "DORMANT" ? import_chalk7.default.red : import_chalk7.default.yellow;
1887
+ lines.push("");
1888
+ lines.push(`${import_chalk7.default.bold("Verdict:")} ${verdictColor(r.verdict)} \u2014 ${r.reason}`);
1889
+ return lines.join("\n");
1890
+ }
1891
+
1892
+ // src/recipient-liveness.ts
1893
+ async function guardRecipientReachable(api, recipientDid, opts) {
1894
+ let verdict;
1895
+ let reason;
1896
+ try {
1897
+ const result = await probe(api, recipientDid);
1898
+ verdict = result.verdict;
1899
+ reason = result.reason;
1900
+ } catch {
1901
+ return;
1902
+ }
1903
+ if (verdict === "LISTENING") return;
1904
+ if (verdict === "UNKNOWN" && !opts.requireOnline) return;
1905
+ const state = verdict === "DORMANT" ? "appears offline (idle)" : "has undetermined liveness";
1906
+ const detail = `recipient ${recipientDid} ${state} \u2014 ${reason}`;
1907
+ if (opts.requireOnline) {
1908
+ throw new CliError("CLI_RECIPIENT_OFFLINE", `${detail}. Aborted because --require-online is set.`, { recipientDid, verdict });
1909
+ }
1910
+ console.error(import_chalk8.default.yellow(`\u26A0 ${detail}`));
1911
+ console.error(import_chalk8.default.dim(" Sending anyway \u2014 it will wait in their inbox. Pass --require-online to abort instead."));
1912
+ }
1913
+
1914
+ // src/resolve-recipient.ts
1915
+ var import_sdk8 = require("@heyanon-arp/sdk");
1916
+ var import_chalk9 = __toESM(require("chalk"));
1917
+ init_api();
1751
1918
  async function resolveRecipient(serverOverride, cmdName, input, opts = {}) {
1752
1919
  if (input.startsWith("did:arp:")) {
1753
- if (!(0, import_sdk7.isValidDid)(input)) {
1920
+ if (!(0, import_sdk8.isValidDid)(input)) {
1754
1921
  throw new Error(`${cmdName}: '${input}' starts with did:arp: but is not a valid DID (base58btc-encoded 32-byte Ed25519 pubkey).`);
1755
1922
  }
1756
1923
  return input;
1757
1924
  }
1758
- const name = (0, import_sdk7.normalizeName)(input);
1759
- if (!(0, import_sdk7.isValidAgentName)(name)) {
1925
+ const name = (0, import_sdk8.normalizeName)(input);
1926
+ if (!(0, import_sdk8.isValidAgentName)(name)) {
1760
1927
  throw new Error(`${cmdName}: '${input}' is neither a DID (did:arp:...) nor a valid agent name (lowercase a-z0-9_, 3-32 chars).`);
1761
1928
  }
1762
1929
  const api = new ArpApiClient(serverOverride);
1763
1930
  const profile = await api.discoverByName(name);
1764
- warn(opts.json, import_chalk7.default.dim(`Resolved ${import_chalk7.default.cyan(name)} \u2192 ${profile.did}${profile.description ? ` (${profile.description})` : ""}`));
1931
+ warn(opts.json, import_chalk9.default.dim(`Resolved ${import_chalk9.default.cyan(name)} \u2192 ${profile.did}${profile.description ? ` (${profile.description})` : ""}`));
1765
1932
  return profile.did;
1766
1933
  }
1767
1934
 
1768
1935
  // src/commands/status.ts
1769
- var import_sdk8 = require("@heyanon-arp/sdk");
1770
- var import_chalk8 = __toESM(require("chalk"));
1936
+ var import_sdk9 = require("@heyanon-arp/sdk");
1937
+ var import_chalk10 = __toESM(require("chalk"));
1771
1938
  init_api();
1772
1939
  var UNTIL_PHASES = [
1773
1940
  "delegation.offered",
@@ -1822,9 +1989,9 @@ async function runStatus(relationshipId, opts) {
1822
1989
  const api = new ArpApiClient(opts.server);
1823
1990
  const sender = resolveSenderAgent("status", opts.server, opts.fromDid, opts.from);
1824
1991
  if (!opts.json) {
1825
- console.log(import_chalk8.default.dim(`Server: ${api.serverUrl}`));
1826
- console.log(import_chalk8.default.dim(`Signer: ${sender.did}`));
1827
- console.log(import_chalk8.default.dim(`Relationship: ${relationshipId}`));
1992
+ console.log(import_chalk10.default.dim(`Server: ${api.serverUrl}`));
1993
+ console.log(import_chalk10.default.dim(`Signer: ${sender.did}`));
1994
+ console.log(import_chalk10.default.dim(`Relationship: ${relationshipId}`));
1828
1995
  }
1829
1996
  const signer = makeSigner(sender);
1830
1997
  if (!opts.wait) {
@@ -1856,7 +2023,7 @@ async function runStatus(relationshipId, opts) {
1856
2023
  async function awaitFsmTransitionAfterAction(input) {
1857
2024
  const { api, signerDid, signer, relationshipId, untilPhase, waitIntervalSec, waitTimeoutSec, waitVerbose, json } = input;
1858
2025
  if (!json) {
1859
- console.log(import_chalk8.default.dim(`
2026
+ console.log(import_chalk10.default.dim(`
1860
2027
  [--wait-until ${untilPhase}] polling relationship ${relationshipId} (interval=${waitIntervalSec}s timeout=${waitTimeoutSec}s)`));
1861
2028
  }
1862
2029
  const outcome = await runWaitLoop({
@@ -1873,13 +2040,13 @@ async function awaitFsmTransitionAfterAction(input) {
1873
2040
  }
1874
2041
  }
1875
2042
  async function runWaitLoop(opts) {
1876
- const isTerminal = (s) => s.cycleComplete || s.relationshipState === import_sdk8.RelationshipStates.CLOSED || s.relationshipState === "not_found";
2043
+ const isTerminal = (s) => s.cycleComplete || s.relationshipState === import_sdk9.RelationshipStates.CLOSED || s.relationshipState === "not_found";
1877
2044
  const isActionable = (s) => {
1878
2045
  if (s.nextActionOwner === "me") {
1879
2046
  if (s.relationshipState === "unknown") return false;
1880
2047
  return true;
1881
2048
  }
1882
- if (s.nextActionOwner === "either" && s.relationshipState === import_sdk8.RelationshipStates.ACTIVE) {
2049
+ if (s.nextActionOwner === "either" && s.relationshipState === import_sdk9.RelationshipStates.ACTIVE) {
1883
2050
  return true;
1884
2051
  }
1885
2052
  return false;
@@ -1895,7 +2062,7 @@ async function runWaitLoop(opts) {
1895
2062
  }
1896
2063
  if (isUntilReached !== null && isUntilReached(initial)) {
1897
2064
  if (opts.json) opts.log(JSON.stringify(initial));
1898
- else opts.log(import_chalk8.default.dim(`
2065
+ else opts.log(import_chalk10.default.dim(`
1899
2066
  [--wait] Phase '${opts.until}' already reached \u2014 exiting without polling.`));
1900
2067
  return { timedOut: false, last: initial };
1901
2068
  }
@@ -1906,13 +2073,13 @@ async function runWaitLoop(opts) {
1906
2073
  else {
1907
2074
  if (opts.until !== void 0) {
1908
2075
  opts.log(
1909
- import_chalk8.default.yellow(
2076
+ import_chalk10.default.yellow(
1910
2077
  `
1911
2078
  [--wait] Terminal state (${initial.relationshipState}, cycleComplete=${initial.cycleComplete}) reached before phase '${opts.until}' \u2014 exiting; phase unreachable.`
1912
2079
  )
1913
2080
  );
1914
2081
  } else {
1915
- opts.log(import_chalk8.default.dim(`
2082
+ opts.log(import_chalk10.default.dim(`
1916
2083
  [--wait] Already terminal \u2014 exiting.`));
1917
2084
  }
1918
2085
  }
@@ -1920,15 +2087,15 @@ async function runWaitLoop(opts) {
1920
2087
  }
1921
2088
  if (opts.until === void 0 && isActionable(initial)) {
1922
2089
  if (opts.json) opts.log(JSON.stringify(initial));
1923
- else opts.log(import_chalk8.default.dim(`
2090
+ else opts.log(import_chalk10.default.dim(`
1924
2091
  [--wait] Your turn already (nextActionOwner=${initial.nextActionOwner}) \u2014 exiting without polling.`));
1925
2092
  return { timedOut: false, last: initial };
1926
2093
  }
1927
2094
  if (!opts.json) {
1928
2095
  const blockerLabel = opts.until !== void 0 ? `Awaiting phase '${opts.until}'` : initial.nextActionOwner === "counterparty" ? "Counterparty owes the next move" : initial.nextActionOwner === "either" ? "Either side may act" : `Awaiting state change (currently ${initial.relationshipState}, nextActionOwner=${initial.nextActionOwner})`;
1929
- opts.log(import_chalk8.default.dim(`
2096
+ opts.log(import_chalk10.default.dim(`
1930
2097
  [--wait] ${blockerLabel}. Polling every ${opts.waitIntervalSec}s, timeout ${opts.waitTimeoutSec}s.`));
1931
- opts.log(import_chalk8.default.dim(`[--wait] Initial hint: ${initial.nextActionHint}`));
2098
+ opts.log(import_chalk10.default.dim(`[--wait] Initial hint: ${initial.nextActionHint}`));
1932
2099
  }
1933
2100
  const startedAt = localNow();
1934
2101
  const deadline = startedAt + opts.waitTimeoutSec * 1e3;
@@ -1948,7 +2115,7 @@ async function runWaitLoop(opts) {
1948
2115
  } else {
1949
2116
  target = `nextActionOwner=${next.nextActionOwner}`;
1950
2117
  }
1951
- opts.log(import_chalk8.default.dim(`[--wait tick ${tickIndex}/${maxTicks}] state=${next.relationshipState}, ${formatPhaseSnapshot(next)} (${target})`));
2118
+ opts.log(import_chalk10.default.dim(`[--wait tick ${tickIndex}/${maxTicks}] state=${next.relationshipState}, ${formatPhaseSnapshot(next)} (${target})`));
1952
2119
  }
1953
2120
  if (exitPredicate(next)) {
1954
2121
  const phaseReached = isUntilReached !== null ? isUntilReached(next) : false;
@@ -1958,16 +2125,16 @@ async function runWaitLoop(opts) {
1958
2125
  opts.log("");
1959
2126
  if (opts.until !== void 0) {
1960
2127
  if (phaseReached) {
1961
- opts.log(import_chalk8.default.green(`[--wait] Phase '${opts.until}' reached.`));
2128
+ opts.log(import_chalk10.default.green(`[--wait] Phase '${opts.until}' reached.`));
1962
2129
  } else {
1963
2130
  opts.log(
1964
- import_chalk8.default.yellow(
2131
+ import_chalk10.default.yellow(
1965
2132
  `[--wait] Terminal state (${next.relationshipState}, cycleComplete=${next.cycleComplete}) reached before phase '${opts.until}' \u2014 phase unreachable.`
1966
2133
  )
1967
2134
  );
1968
2135
  }
1969
2136
  } else {
1970
- opts.log(import_chalk8.default.green(`[--wait] ${isTerminal(next) ? "Cycle terminated" : `Your turn (owner=${next.nextActionOwner})`}.`));
2137
+ opts.log(import_chalk10.default.green(`[--wait] ${isTerminal(next) ? "Cycle terminated" : `Your turn (owner=${next.nextActionOwner})`}.`));
1971
2138
  }
1972
2139
  opts.log(formatStatusReport(next));
1973
2140
  }
@@ -1980,14 +2147,14 @@ async function runWaitLoop(opts) {
1980
2147
  } else {
1981
2148
  if (opts.until !== void 0) {
1982
2149
  opts.log(
1983
- import_chalk8.default.yellow(
2150
+ import_chalk10.default.yellow(
1984
2151
  `
1985
2152
  [--wait] Timed out after ${opts.waitTimeoutSec}s without reaching phase '${opts.until}' (latest state: ${last.relationshipState}, hint: ${last.nextActionHint}).`
1986
2153
  )
1987
2154
  );
1988
2155
  } else {
1989
2156
  opts.log(
1990
- import_chalk8.default.yellow(`
2157
+ import_chalk10.default.yellow(`
1991
2158
  [--wait] Timed out after ${opts.waitTimeoutSec}s without an actionable or terminal transition (your turn never came, cycle still in flight).`)
1992
2159
  );
1993
2160
  }
@@ -2042,41 +2209,41 @@ function parseUntilPhase(raw) {
2042
2209
  function isPhaseTerminallyUnreachable(phase, s) {
2043
2210
  if (untilPhaseMatched(phase, s)) return false;
2044
2211
  if (s.relationshipState === "not_found") return true;
2045
- if (s.relationshipState === import_sdk8.RelationshipStates.CLOSED && phase !== "relationship.closed") return true;
2212
+ if (s.relationshipState === import_sdk9.RelationshipStates.CLOSED && phase !== "relationship.closed") return true;
2046
2213
  return false;
2047
2214
  }
2048
2215
  function untilPhaseMatched(phase, s) {
2049
2216
  switch (phase) {
2050
2217
  case "delegation.offered":
2051
- return s.latestDelegation?.state === import_sdk8.DelegationStates.OFFERED;
2218
+ return s.latestDelegation?.state === import_sdk9.DelegationStates.OFFERED;
2052
2219
  case "delegation.accepted":
2053
- return s.latestDelegation?.state === import_sdk8.DelegationStates.ACCEPTED;
2220
+ return s.latestDelegation?.state === import_sdk9.DelegationStates.ACCEPTED;
2054
2221
  case "delegation.locked":
2055
- return s.latestDelegation?.state === import_sdk8.DelegationStates.LOCKED;
2222
+ return s.latestDelegation?.state === import_sdk9.DelegationStates.LOCKED;
2056
2223
  case "delegation.disputing":
2057
- return s.latestDelegation?.state === import_sdk8.DelegationStates.DISPUTING;
2224
+ return s.latestDelegation?.state === import_sdk9.DelegationStates.DISPUTING;
2058
2225
  case "delegation.canceled":
2059
- return s.latestDelegation?.state === import_sdk8.DelegationStates.CANCELED;
2226
+ return s.latestDelegation?.state === import_sdk9.DelegationStates.CANCELED;
2060
2227
  case "delegation.declined":
2061
- return s.latestDelegation?.state === import_sdk8.DelegationStates.DECLINED;
2228
+ return s.latestDelegation?.state === import_sdk9.DelegationStates.DECLINED;
2062
2229
  case "work.requested":
2063
- return s.latestWorkLog?.state === import_sdk8.WorkLogStates.REQUESTED;
2230
+ return s.latestWorkLog?.state === import_sdk9.WorkLogStates.REQUESTED;
2064
2231
  case "work.responded":
2065
- return s.latestWorkLog?.state === import_sdk8.WorkLogStates.RESPONDED;
2232
+ return s.latestWorkLog?.state === import_sdk9.WorkLogStates.RESPONDED;
2066
2233
  case "receipt.proposed":
2067
2234
  return s.latestReceipt != null;
2068
2235
  case "relationship.pending":
2069
- return s.relationshipState === import_sdk8.RelationshipStates.PENDING;
2236
+ return s.relationshipState === import_sdk9.RelationshipStates.PENDING;
2070
2237
  case "relationship.active":
2071
- return s.relationshipState === import_sdk8.RelationshipStates.ACTIVE;
2238
+ return s.relationshipState === import_sdk9.RelationshipStates.ACTIVE;
2072
2239
  case "relationship.paused":
2073
- return s.relationshipState === import_sdk8.RelationshipStates.PAUSED;
2240
+ return s.relationshipState === import_sdk9.RelationshipStates.PAUSED;
2074
2241
  case "relationship.closed":
2075
- return s.relationshipState === import_sdk8.RelationshipStates.CLOSED;
2242
+ return s.relationshipState === import_sdk9.RelationshipStates.CLOSED;
2076
2243
  case "cycle.complete":
2077
2244
  return s.cycleComplete;
2078
2245
  case "cycle.released":
2079
- return s.latestDelegation?.state === import_sdk8.DelegationStates.COMPLETED;
2246
+ return s.latestDelegation?.state === import_sdk9.DelegationStates.COMPLETED;
2080
2247
  }
2081
2248
  }
2082
2249
  function parseWaitInterval(raw) {
@@ -2127,7 +2294,7 @@ async function composeStatus(api, signerDid, relationshipId, signer) {
2127
2294
  const relationship = relationships.find((r) => r.relationshipId === relationshipId);
2128
2295
  const counterpartyDid = relationship ? relationship.pairDidA === signerDid ? relationship.pairDidB : relationship.pairDidA : inferCounterpartyFromEntities(signerDid, allDelegations);
2129
2296
  const delegations = allDelegations;
2130
- const latestDelegation = pickLatestLive(delegations, [...import_sdk8.DELEGATION_ACTIVE_STATES]);
2297
+ const latestDelegation = pickLatestLive(delegations, [...import_sdk9.DELEGATION_ACTIVE_STATES]);
2131
2298
  const [workLogs, receipts] = await Promise.all([
2132
2299
  latestDelegation ? fetchAllPages(
2133
2300
  (after) => api.listWorkLogs(relationshipId, signer, { limit: 100, delegationId: latestDelegation.delegationId, ...after ? { after } : {} })
@@ -2191,8 +2358,8 @@ function findReceiptForWorkLog(receipts, workLog, allWorkLogs = [workLog]) {
2191
2358
  };
2192
2359
  const responseBody = workLog.responseOutput !== void 0 ? { type: "work_response", content: { delegation_id: workLog.delegationId, request_id: workLog.requestId, output: workLog.responseOutput } } : workLog.responseError !== void 0 ? { type: "work_response", content: { delegation_id: workLog.delegationId, request_id: workLog.requestId, error: workLog.responseError } } : null;
2193
2360
  if (!responseBody) return null;
2194
- const expectedRequestHash = (0, import_sdk8.canonicalSha256Hex)(requestBody);
2195
- const expectedResponseHash = (0, import_sdk8.canonicalSha256Hex)(responseBody);
2361
+ const expectedRequestHash = (0, import_sdk9.canonicalSha256Hex)(requestBody);
2362
+ const expectedResponseHash = (0, import_sdk9.canonicalSha256Hex)(responseBody);
2196
2363
  const matches = receipts.filter((r) => r.requestHash === expectedRequestHash && r.responseHash === expectedResponseHash);
2197
2364
  if (matches.length > 0) return pickLatest(matches);
2198
2365
  const respondedSiblings = allWorkLogs.filter((wl) => wl.delegationId === workLog.delegationId && (wl.responseOutput !== void 0 || wl.responseError !== void 0)).length;
@@ -2234,49 +2401,49 @@ function nextAction(input) {
2234
2401
  complete: false
2235
2402
  };
2236
2403
  }
2237
- if (relationship.state === import_sdk8.RelationshipStates.PENDING) {
2404
+ if (relationship.state === import_sdk9.RelationshipStates.PENDING) {
2238
2405
  return {
2239
2406
  hint: "Relationship is PENDING \u2014 one side owes `heyarp send-handshake-response <peer> --decision accept | decline`",
2240
2407
  owner: "either",
2241
2408
  complete: false
2242
2409
  };
2243
2410
  }
2244
- if (relationship.state === import_sdk8.RelationshipStates.PAUSED) {
2411
+ if (relationship.state === import_sdk9.RelationshipStates.PAUSED) {
2245
2412
  return { hint: "Relationship is PAUSED \u2014 owner must `heyarp unpause` before any envelopes flow", owner: "either", complete: false };
2246
2413
  }
2247
- if (relationship.state === import_sdk8.RelationshipStates.CLOSED) {
2414
+ if (relationship.state === import_sdk9.RelationshipStates.CLOSED) {
2248
2415
  return { hint: "Relationship is CLOSED \u2014 terminal state, no further action possible. Start a fresh handshake to reopen.", owner: "none", complete: false };
2249
2416
  }
2250
- if (!latestDelegation || latestDelegation.state === import_sdk8.DelegationStates.DECLINED || latestDelegation.state === import_sdk8.DelegationStates.CANCELED) {
2417
+ if (!latestDelegation || latestDelegation.state === import_sdk9.DelegationStates.DECLINED || latestDelegation.state === import_sdk9.DelegationStates.CANCELED) {
2251
2418
  return {
2252
2419
  hint: "No live delegation \u2014 buyer offers (terms only, no lock) `heyarp delegation offer <peer> --delegation-id <new-uuid> --title \u2026 --scope \u2026 --amount \u2026 --currency SOL:solana-devnet --deadline \u2026`, then funds the escrow lock AFTER the worker accepts via `heyarp delegation fund <del-id> --escrow-lock-from-file <path>`",
2253
2420
  owner: "either",
2254
2421
  complete: false
2255
2422
  };
2256
2423
  }
2257
- if (latestDelegation.state === import_sdk8.DelegationStates.DISPUTING) {
2424
+ if (latestDelegation.state === import_sdk9.DelegationStates.DISPUTING) {
2258
2425
  return {
2259
2426
  hint: `Delegation ${latestDelegation.delegationId} is DISPUTING \u2014 the buyer opened an on-chain dispute (their stake is escrowed too). The operator may rule until the dispute window lapses; after that either party closes with \`heyarp escrow dispute close ${latestDelegation.delegationId}\` (escrow returns to the buyer, both stakes return). Deadline: \`heyarp escrow show ${latestDelegation.delegationId}\`. No envelopes to send meanwhile.`,
2260
2427
  owner: "none",
2261
2428
  complete: false
2262
2429
  };
2263
2430
  }
2264
- if (latestDelegation.state === import_sdk8.DelegationStates.COMPLETED) {
2431
+ if (latestDelegation.state === import_sdk9.DelegationStates.COMPLETED) {
2265
2432
  return {
2266
2433
  hint: "Cycle COMPLETE \u2014 payment claimed on chain (lock paid; the receipt carries releaseStatus=paid)",
2267
2434
  owner: "none",
2268
2435
  complete: true
2269
2436
  };
2270
2437
  }
2271
- if (latestDelegation.state === import_sdk8.DelegationStates.FAILED || latestDelegation.state === import_sdk8.DelegationStates.REFUNDED || latestDelegation.state === import_sdk8.DelegationStates.DISPUTE_RESOLVED) {
2438
+ if (latestDelegation.state === import_sdk9.DelegationStates.FAILED || latestDelegation.state === import_sdk9.DelegationStates.REFUNDED || latestDelegation.state === import_sdk9.DelegationStates.DISPUTE_RESOLVED) {
2272
2439
  const stateLabel = latestDelegation.state.toUpperCase();
2273
- const reason = latestDelegation.state === import_sdk8.DelegationStates.FAILED ? "on-chain escrow lock failed to finalise (typical causes: insufficient payer funds, wrong program-id, ProgramState PDA uninitialised \u2014 check `heyarp delegations <rel-id> --json | jq .[].escrowError` for the worker-side reason)" : latestDelegation.state === import_sdk8.DelegationStates.REFUNDED ? (
2440
+ const reason = latestDelegation.state === import_sdk9.DelegationStates.FAILED ? "on-chain escrow lock failed to finalise (typical causes: insufficient payer funds, wrong program-id, ProgramState PDA uninitialised \u2014 check `heyarp delegations <rel-id> --json | jq .[].escrowError` for the worker-side reason)" : latestDelegation.state === import_sdk9.DelegationStates.REFUNDED ? (
2274
2441
  // Keyed on the DELEGATION row's releaseStatus, not the
2275
2442
  // receipt's: in the claim-expired path the worker never
2276
2443
  // submitted anything, so no receipt row exists to carry
2277
2444
  // the outcome — the delegation copy is always present
2278
2445
  // on indexer-driven terminals.
2279
- latestDelegation.releaseStatus === import_sdk8.LockStates.DISPUTE_CLOSED ? "the dispute window lapsed without an operator ruling and the dispute was closed \u2014 escrow returned to the buyer, both stakes returned (work was delivered but not paid)" : latestDelegation.releaseStatus === import_sdk8.LockStates.REVOKED ? "the work window lapsed without an on-chain submit \u2014 the buyer reclaimed the escrow AND the worker stake (claim_expired_work)" : "lock was refunded after expiry \u2014 no work was delivered against this delegation"
2446
+ latestDelegation.releaseStatus === import_sdk9.LockStates.DISPUTE_CLOSED ? "the dispute window lapsed without an operator ruling and the dispute was closed \u2014 escrow returned to the buyer, both stakes returned (work was delivered but not paid)" : latestDelegation.releaseStatus === import_sdk9.LockStates.REVOKED ? "the work window lapsed without an on-chain submit \u2014 the buyer reclaimed the escrow AND the worker stake (claim_expired_work)" : "lock was refunded after expiry \u2014 no work was delivered against this delegation"
2280
2447
  ) : "admin closed the delegation via the dispute-resolution path";
2281
2448
  return {
2282
2449
  hint: `Delegation ${latestDelegation.delegationId} is ${stateLabel} (terminal) \u2014 ${reason}. Issue a fresh \`heyarp delegation offer <peer> --delegation-id <new-uuid> \u2026\` to retry (FSM does not auto-retry).`,
@@ -2284,7 +2451,7 @@ function nextAction(input) {
2284
2451
  complete: false
2285
2452
  };
2286
2453
  }
2287
- if (latestDelegation.state === import_sdk8.DelegationStates.OFFERED) {
2454
+ if (latestDelegation.state === import_sdk9.DelegationStates.OFFERED) {
2288
2455
  const iAmOfferer = latestDelegation.offererDid === signerDid;
2289
2456
  const stateLabel = "OFFERED";
2290
2457
  return {
@@ -2293,7 +2460,7 @@ function nextAction(input) {
2293
2460
  complete: false
2294
2461
  };
2295
2462
  }
2296
- if (latestDelegation.state === import_sdk8.DelegationStates.ACCEPTED && !latestWorkLog) {
2463
+ if (latestDelegation.state === import_sdk9.DelegationStates.ACCEPTED && !latestWorkLog) {
2297
2464
  const iAmOfferer = latestDelegation.offererDid === signerDid;
2298
2465
  return {
2299
2466
  hint: iAmOfferer ? `Delegation ${latestDelegation.delegationId} is ACCEPTED \u2014 you (buyer) owe \`heyarp wallet create-lock --delegation-id ${latestDelegation.delegationId} --condition-hash <hex> ... > lock.json\` then \`heyarp delegation fund ${latestDelegation.delegationId} --escrow-lock-from-file lock.json\` (fund the escrow lock; work begins once it is LOCKED on chain)` : `Delegation ${latestDelegation.delegationId} is ACCEPTED \u2014 counterparty (the buyer) owes \`heyarp delegation fund\` to lock the escrow; wait for the delegation to reach LOCKED before working`,
@@ -2301,7 +2468,7 @@ function nextAction(input) {
2301
2468
  complete: false
2302
2469
  };
2303
2470
  }
2304
- if (latestDelegation.state === import_sdk8.DelegationStates.PENDING_LOCK_FINALIZATION && !latestWorkLog) {
2471
+ if (latestDelegation.state === import_sdk9.DelegationStates.PENDING_LOCK_FINALIZATION && !latestWorkLog) {
2305
2472
  return {
2306
2473
  hint: `Delegation ${latestDelegation.delegationId} is PENDING_LOCK_FINALIZATION \u2014 the escrow lock was funded and is awaiting on-chain confirmation; both sides wait (auto-advances to LOCKED). Poll with \`heyarp status ${relationship.relationshipId} --wait --until delegation.locked\`.`,
2307
2474
  owner: "none",
@@ -2316,7 +2483,7 @@ function nextAction(input) {
2316
2483
  complete: false
2317
2484
  };
2318
2485
  }
2319
- if (latestWorkLog.state === import_sdk8.WorkLogStates.REQUESTED) {
2486
+ if (latestWorkLog.state === import_sdk9.WorkLogStates.REQUESTED) {
2320
2487
  const iAmPayee = latestWorkLog.payeeDid === signerDid;
2321
2488
  return {
2322
2489
  hint: iAmPayee ? `work_request ${latestWorkLog.requestId} is REQUESTED \u2014 you owe \`heyarp work respond\` (output OR --error)` : `work_request ${latestWorkLog.requestId} is REQUESTED \u2014 counterparty (payee) owes \`heyarp work respond\``,
@@ -2367,84 +2534,84 @@ function formatStatusReport(s) {
2367
2534
  const lines = [];
2368
2535
  lines.push(cycleHeadline(s));
2369
2536
  lines.push("");
2370
- lines.push(import_chalk8.default.bold("Relationship"));
2537
+ lines.push(import_chalk10.default.bold("Relationship"));
2371
2538
  lines.push(` state: ${stateColor(s.relationshipState)}`);
2372
- if (s.counterpartyDid) lines.push(` counterparty: ${import_chalk8.default.cyan(s.counterpartyDid)}`);
2539
+ if (s.counterpartyDid) lines.push(` counterparty: ${import_chalk10.default.cyan(s.counterpartyDid)}`);
2373
2540
  lines.push("");
2374
- lines.push(import_chalk8.default.bold("Latest delegation"));
2541
+ lines.push(import_chalk10.default.bold("Latest delegation"));
2375
2542
  if (s.latestDelegation) {
2376
2543
  lines.push(` ${s.latestDelegation.delegationId} state=${stateColor(s.latestDelegation.state)}`);
2377
- lines.push(` offerer: ${import_chalk8.default.cyan(s.latestDelegation.offererDid)}`);
2544
+ lines.push(` offerer: ${import_chalk10.default.cyan(s.latestDelegation.offererDid)}`);
2378
2545
  if (s.latestDelegation.title) lines.push(` title: ${s.latestDelegation.title}`);
2379
2546
  if (s.latestDelegation.scopeSummary) lines.push(` scope: ${s.latestDelegation.scopeSummary}`);
2380
2547
  } else {
2381
- lines.push(import_chalk8.default.dim(" (none)"));
2548
+ lines.push(import_chalk10.default.dim(" (none)"));
2382
2549
  }
2383
2550
  lines.push("");
2384
- lines.push(import_chalk8.default.bold("Latest work_log"));
2551
+ lines.push(import_chalk10.default.bold("Latest work_log"));
2385
2552
  if (s.latestWorkLog) {
2386
2553
  lines.push(` request_id=${s.latestWorkLog.requestId} state=${stateColor(s.latestWorkLog.state)}`);
2387
2554
  } else {
2388
- lines.push(import_chalk8.default.dim(" (none)"));
2555
+ lines.push(import_chalk10.default.dim(" (none)"));
2389
2556
  }
2390
2557
  lines.push("");
2391
- lines.push(import_chalk8.default.bold("Latest receipt"));
2558
+ lines.push(import_chalk10.default.bold("Latest receipt"));
2392
2559
  if (s.latestReceipt) {
2393
2560
  lines.push(` ${stateColor("proposed")} verdict=${s.latestReceipt.verdictProposed}`);
2394
2561
  } else {
2395
- lines.push(import_chalk8.default.dim(" (none)"));
2562
+ lines.push(import_chalk10.default.dim(" (none)"));
2396
2563
  }
2397
2564
  lines.push("");
2398
- lines.push(import_chalk8.default.bold("Next action"));
2399
- const ownerLabel = s.nextActionOwner === "me" ? import_chalk8.default.green("me") : s.nextActionOwner === "counterparty" ? import_chalk8.default.yellow("counterparty") : s.nextActionOwner === "either" ? import_chalk8.default.cyan("either side") : import_chalk8.default.dim("\u2014");
2565
+ lines.push(import_chalk10.default.bold("Next action"));
2566
+ const ownerLabel = s.nextActionOwner === "me" ? import_chalk10.default.green("me") : s.nextActionOwner === "counterparty" ? import_chalk10.default.yellow("counterparty") : s.nextActionOwner === "either" ? import_chalk10.default.cyan("either side") : import_chalk10.default.dim("\u2014");
2400
2567
  lines.push(` whose turn: ${ownerLabel}`);
2401
2568
  lines.push(` hint: ${s.nextActionHint}`);
2402
- if (s.cycleComplete) lines.push(` ${import_chalk8.default.green("\u2713 Cycle complete.")}`);
2569
+ if (s.cycleComplete) lines.push(` ${import_chalk10.default.green("\u2713 Cycle complete.")}`);
2403
2570
  return lines.join("\n");
2404
2571
  }
2405
2572
  function cycleHeadline(s) {
2406
2573
  if (s.cycleComplete) {
2407
- return `${import_chalk8.default.bold("Cycle:")} ${import_chalk8.default.green.bold("COMPLETE")} ${import_chalk8.default.dim("\u2014 payment proven on chain")}`;
2574
+ return `${import_chalk10.default.bold("Cycle:")} ${import_chalk10.default.green.bold("COMPLETE")} ${import_chalk10.default.dim("\u2014 payment proven on chain")}`;
2408
2575
  }
2409
2576
  switch (s.relationshipState) {
2410
2577
  case "not_found":
2411
- return `${import_chalk8.default.bold("Cycle:")} ${import_chalk8.default.red.bold("NOT FOUND")} ${import_chalk8.default.dim("\u2014 relationship missing or signer is not a member")}`;
2578
+ return `${import_chalk10.default.bold("Cycle:")} ${import_chalk10.default.red.bold("NOT FOUND")} ${import_chalk10.default.dim("\u2014 relationship missing or signer is not a member")}`;
2412
2579
  case "unknown":
2413
- return `${import_chalk8.default.bold("Cycle:")} ${import_chalk8.default.yellow.bold("UNKNOWN")} ${import_chalk8.default.dim("\u2014 state probe inconclusive; hint below is advisory")}`;
2414
- case import_sdk8.RelationshipStates.CLOSED:
2415
- return `${import_chalk8.default.bold("Cycle:")} ${import_chalk8.default.red.bold("CLOSED")} ${import_chalk8.default.dim("\u2014 relationship terminal, no further protocol action")}`;
2416
- case import_sdk8.RelationshipStates.PAUSED:
2417
- return `${import_chalk8.default.bold("Cycle:")} ${import_chalk8.default.yellow.bold("PAUSED")} ${import_chalk8.default.dim("\u2014 relationship soft-disabled, resume to continue")}`;
2418
- case import_sdk8.RelationshipStates.PENDING:
2419
- return `${import_chalk8.default.bold("Cycle:")} ${import_chalk8.default.yellow.bold("PENDING")} ${import_chalk8.default.dim("\u2014 awaiting handshake_response")}`;
2420
- case import_sdk8.RelationshipStates.ACTIVE:
2580
+ return `${import_chalk10.default.bold("Cycle:")} ${import_chalk10.default.yellow.bold("UNKNOWN")} ${import_chalk10.default.dim("\u2014 state probe inconclusive; hint below is advisory")}`;
2581
+ case import_sdk9.RelationshipStates.CLOSED:
2582
+ return `${import_chalk10.default.bold("Cycle:")} ${import_chalk10.default.red.bold("CLOSED")} ${import_chalk10.default.dim("\u2014 relationship terminal, no further protocol action")}`;
2583
+ case import_sdk9.RelationshipStates.PAUSED:
2584
+ return `${import_chalk10.default.bold("Cycle:")} ${import_chalk10.default.yellow.bold("PAUSED")} ${import_chalk10.default.dim("\u2014 relationship soft-disabled, resume to continue")}`;
2585
+ case import_sdk9.RelationshipStates.PENDING:
2586
+ return `${import_chalk10.default.bold("Cycle:")} ${import_chalk10.default.yellow.bold("PENDING")} ${import_chalk10.default.dim("\u2014 awaiting handshake_response")}`;
2587
+ case import_sdk9.RelationshipStates.ACTIVE:
2421
2588
  default:
2422
- return `${import_chalk8.default.bold("Cycle:")} ${import_chalk8.default.cyan.bold("ACTIVE")} ${import_chalk8.default.dim('\u2014 work in progress; see "Next action" below')}`;
2589
+ return `${import_chalk10.default.bold("Cycle:")} ${import_chalk10.default.cyan.bold("ACTIVE")} ${import_chalk10.default.dim('\u2014 work in progress; see "Next action" below')}`;
2423
2590
  }
2424
2591
  }
2425
2592
  function stateColor(state) {
2426
- const c = state === "active" || state === "accepted" || state === "locked" || state === "responded" || state === "completed" ? import_chalk8.default.green : state === "pending" || state === "requested" || state === "offered" || state === "pending_lock_finalization" ? import_chalk8.default.yellow : state === "closed" || state === "declined" || state === "canceled" || state === "replaced" || state === "not_found" || // Terminal failure states deserve the same red
2593
+ const c = state === "active" || state === "accepted" || state === "locked" || state === "responded" || state === "completed" ? import_chalk10.default.green : state === "pending" || state === "requested" || state === "offered" || state === "pending_lock_finalization" ? import_chalk10.default.yellow : state === "closed" || state === "declined" || state === "canceled" || state === "replaced" || state === "not_found" || // Terminal failure states deserve the same red
2427
2594
  // treatment as declined/canceled so an operator
2428
2595
  // scanning `heyarp status` immediately sees
2429
2596
  // "this is dead, don't follow the hint blindly".
2430
- state === "failed" || state === "refunded" || state === "dispute_resolved" ? import_chalk8.default.red : import_chalk8.default.cyan;
2597
+ state === "failed" || state === "refunded" || state === "dispute_resolved" ? import_chalk10.default.red : import_chalk10.default.cyan;
2431
2598
  return c(state);
2432
2599
  }
2433
2600
 
2434
2601
  // src/commands/wallet.ts
2435
- var import_sdk11 = require("@heyanon-arp/sdk");
2602
+ var import_sdk12 = require("@heyanon-arp/sdk");
2436
2603
  var import_utils = require("@noble/hashes/utils");
2437
2604
  var import_web3 = require("@solana/web3.js");
2438
2605
  init_api();
2439
2606
  init_config();
2440
2607
 
2441
2608
  // src/solana/escrow-ix.ts
2442
- var import_sdk9 = require("@heyanon-arp/sdk");
2609
+ var import_sdk10 = require("@heyanon-arp/sdk");
2443
2610
 
2444
2611
  // src/commands/token-amount.ts
2445
- var import_sdk10 = require("@heyanon-arp/sdk");
2612
+ var import_sdk11 = require("@heyanon-arp/sdk");
2446
2613
  function toBaseUnits(amountDecimal, decimals) {
2447
- if (!(0, import_sdk10.isDecimalAmountString)(amountDecimal)) {
2614
+ if (!(0, import_sdk11.isDecimalAmountString)(amountDecimal)) {
2448
2615
  throw new Error(`amount '${amountDecimal}' is not a non-negative decimal number`);
2449
2616
  }
2450
2617
  if (!Number.isInteger(decimals) || decimals < 0 || decimals > 255) {
@@ -2473,8 +2640,8 @@ function normaliseDelegationId(raw) {
2473
2640
  }
2474
2641
  throw new Error(`wallet: --delegation-id must be either 'del_<uuid>' or a bare canonical-lowercase UUID (got '${raw}')`);
2475
2642
  }
2476
- var SPL_TOKEN_PROGRAM_ID2 = new import_web3.PublicKey(import_sdk11.SPL_TOKEN_PROGRAM_ID_BASE58);
2477
- var ASSOCIATED_TOKEN_PROGRAM_ID2 = new import_web3.PublicKey(import_sdk11.ASSOCIATED_TOKEN_PROGRAM_ID_BASE58);
2643
+ var SPL_TOKEN_PROGRAM_ID2 = new import_web3.PublicKey(import_sdk12.SPL_TOKEN_PROGRAM_ID_BASE58);
2644
+ var ASSOCIATED_TOKEN_PROGRAM_ID2 = new import_web3.PublicKey(import_sdk12.ASSOCIATED_TOKEN_PROGRAM_ID_BASE58);
2478
2645
  var FALLBACK_RPC_URL = "https://api.mainnet-beta.solana.com";
2479
2646
  function resolveRpcUrl(opts) {
2480
2647
  if (opts.rpcUrl !== void 0 && opts.rpcUrl !== "") return opts.rpcUrl;
@@ -2494,7 +2661,7 @@ function redactRpcUrl(url) {
2494
2661
  return "<redacted>";
2495
2662
  }
2496
2663
  }
2497
- var FALLBACK_PROGRAM_ID = import_sdk11.ESCROW_PROGRAM_ID_BASE58;
2664
+ var FALLBACK_PROGRAM_ID = import_sdk12.ESCROW_PROGRAM_ID_BASE58;
2498
2665
  async function resolveProgramIdWithSource(api, opts) {
2499
2666
  if (opts.programId !== void 0 && opts.programId !== "") {
2500
2667
  return { programId: opts.programId, source: "flag" };
@@ -2578,7 +2745,7 @@ async function derivePdasHandler(opts) {
2578
2745
  const normalisedDelegationId = normaliseDelegationId(opts.delegationId);
2579
2746
  const api = new ArpApiClient(opts.server);
2580
2747
  const programId = new import_web3.PublicKey(await resolveProgramIdStrict(api, opts, "wallet derive-pdas"));
2581
- const lockIdBytes = (0, import_sdk11.deriveLockId)(normalisedDelegationId);
2748
+ const lockIdBytes = (0, import_sdk12.deriveLockId)(normalisedDelegationId);
2582
2749
  const lockIdSeed = Buffer.from(lockIdBytes);
2583
2750
  const lockIdHex = Buffer.from(lockIdBytes).toString("hex");
2584
2751
  const [lockPda] = import_web3.PublicKey.findProgramAddressSync([Buffer.from("lock"), lockIdSeed], programId);
@@ -2597,11 +2764,11 @@ async function derivePdasHandler(opts) {
2597
2764
  };
2598
2765
  }
2599
2766
  var TERMINAL_METHOD = {
2600
- [import_sdk11.LockStates.PAID]: "claim_work_payment",
2601
- [import_sdk11.LockStates.CANCELED]: "cancel_lock",
2602
- [import_sdk11.LockStates.REVOKED]: "claim_expired_work",
2603
- [import_sdk11.LockStates.DISPUTE_RESOLVED]: "resolve_dispute",
2604
- [import_sdk11.LockStates.DISPUTE_CLOSED]: "close_dispute"
2767
+ [import_sdk12.LockStates.PAID]: "claim_work_payment",
2768
+ [import_sdk12.LockStates.CANCELED]: "cancel_lock",
2769
+ [import_sdk12.LockStates.REVOKED]: "claim_expired_work",
2770
+ [import_sdk12.LockStates.DISPUTE_RESOLVED]: "resolve_dispute",
2771
+ [import_sdk12.LockStates.DISPUTE_CLOSED]: "close_dispute"
2605
2772
  };
2606
2773
  function registerVerifyRelease(cmd) {
2607
2774
  cmd.command("verify-release").description(
@@ -2646,10 +2813,10 @@ async function verifyReleaseHandler(opts) {
2646
2813
  const programId = new import_web3.PublicKey(await resolveProgramIdStrict(api, opts));
2647
2814
  const rpcUrl = resolveRpcUrlStrict(opts);
2648
2815
  const conn = new import_web3.Connection(rpcUrl, "confirmed");
2649
- const fetched = await (0, import_sdk9.fetchLockAccount)(conn, programId, normalisedDelegationId);
2650
- const lockId = (0, import_sdk11.deriveLockId)(normalisedDelegationId);
2651
- const lockPda = (0, import_sdk9.deriveLockPda)(programId, lockId);
2652
- const escrowPda = (0, import_sdk9.deriveEscrowPda)(programId, lockId);
2816
+ const fetched = await (0, import_sdk10.fetchLockAccount)(conn, programId, normalisedDelegationId);
2817
+ const lockId = (0, import_sdk12.deriveLockId)(normalisedDelegationId);
2818
+ const lockPda = (0, import_sdk10.deriveLockPda)(programId, lockId);
2819
+ const escrowPda = (0, import_sdk10.deriveEscrowPda)(programId, lockId);
2653
2820
  if (!fetched) {
2654
2821
  return {
2655
2822
  delegation_id: normalisedDelegationId,
@@ -2668,7 +2835,7 @@ async function verifyReleaseHandler(opts) {
2668
2835
  lock_pda: lockPda.toBase58(),
2669
2836
  escrow_pda: escrowPda.toBase58(),
2670
2837
  lock_account_exists: true,
2671
- released: status === import_sdk11.LockStates.PAID,
2838
+ released: status === import_sdk12.LockStates.PAID,
2672
2839
  status,
2673
2840
  ...TERMINAL_METHOD[status] !== void 0 ? { release_method: TERMINAL_METHOD[status] } : {},
2674
2841
  lock_state: lock.stateByte,
@@ -2678,23 +2845,23 @@ async function verifyReleaseHandler(opts) {
2678
2845
  }
2679
2846
  function renderStatusLine(status) {
2680
2847
  switch (status) {
2681
- case import_sdk11.LockStates.PAID:
2848
+ case import_sdk12.LockStates.PAID:
2682
2849
  return "\u2713 paid \u2014 claim_work_payment landed (buyer approval or post-review self-claim); the payee was paid net of any protocol fee";
2683
- case import_sdk11.LockStates.CREATED:
2850
+ case import_sdk12.LockStates.CREATED:
2684
2851
  return "\u2717 created \u2014 funded, awaiting the worker accept_lock (stake) \u2014 or a buyer cancel";
2685
- case import_sdk11.LockStates.IN_PROGRESS:
2852
+ case import_sdk12.LockStates.IN_PROGRESS:
2686
2853
  return "\u2717 in_progress \u2014 worker accepted + staked; work window running";
2687
- case import_sdk11.LockStates.SUBMITTED:
2854
+ case import_sdk12.LockStates.SUBMITTED:
2688
2855
  return "\u2717 submitted \u2014 work delivered on-chain; review window running (buyer claims to approve, disputes to refuse; worker self-claims after expiry)";
2689
- case import_sdk11.LockStates.DISPUTING:
2856
+ case import_sdk12.LockStates.DISPUTING:
2690
2857
  return "\u2717 disputing \u2014 buyer disputed; operator has the dispute window to rule, after that either party can close";
2691
- case import_sdk11.LockStates.CANCELED:
2858
+ case import_sdk12.LockStates.CANCELED:
2692
2859
  return "\u2717 canceled \u2014 buyer canceled pre-accept; escrow returned";
2693
- case import_sdk11.LockStates.REVOKED:
2860
+ case import_sdk12.LockStates.REVOKED:
2694
2861
  return "\u2717 revoked \u2014 work window lapsed unsubmitted; buyer reclaimed the escrow + the worker stake";
2695
- case import_sdk11.LockStates.DISPUTE_RESOLVED:
2862
+ case import_sdk12.LockStates.DISPUTE_RESOLVED:
2696
2863
  return "\u2717 dispute_resolved \u2014 operator ruled; winner took the escrow per the on-chain split";
2697
- case import_sdk11.LockStates.DISPUTE_CLOSED:
2864
+ case import_sdk12.LockStates.DISPUTE_CLOSED:
2698
2865
  return "\u2717 dispute_closed \u2014 dispute window lapsed unresolved; escrow returned to the buyer, stakes returned";
2699
2866
  case "lock_never_created":
2700
2867
  return "\u2717 lock_never_created \u2014 no Lock PDA on this cluster/program; create_lock never fired (or wrong --rpc-url/--program-id)";
@@ -2880,7 +3047,7 @@ async function createLockHandler(opts) {
2880
3047
  if (clusterTag !== 0 && clusterTag !== 1) {
2881
3048
  throw new Error(`--cluster-tag must be 0 (devnet) or 1 (mainnet) (got ${clusterTag})`);
2882
3049
  }
2883
- const clusterCaip2 = clusterTag === 1 ? import_sdk11.SOLANA_CLUSTER_IDS["solana-mainnet"] : import_sdk11.SOLANA_CLUSTER_IDS["solana-devnet"];
3050
+ const clusterCaip2 = clusterTag === 1 ? import_sdk12.SOLANA_CLUSTER_IDS["solana-mainnet"] : import_sdk12.SOLANA_CLUSTER_IDS["solana-devnet"];
2884
3051
  const expectedLockAsset = typeof opts.mintPubkey === "string" && opts.mintPubkey !== "" ? { kind: "spl", mint: parsePubkey(opts.mintPubkey, "--mint-pubkey").toBase58(), cluster: clusterCaip2 } : { kind: "native" };
2885
3052
  if (!offlineMode) {
2886
3053
  await preflightLockCurrency(api, agent, normalisedDelegationId, expectedLockAsset);
@@ -2890,8 +3057,8 @@ async function createLockHandler(opts) {
2890
3057
  const conn = new import_web3.Connection(rpcUrl, "confirmed");
2891
3058
  const asset = await resolveCreateLockAsset(conn, opts, payerKp.publicKey, clusterCaip2);
2892
3059
  const amount = asset.amount;
2893
- const lockIdBytes = (0, import_sdk11.deriveLockId)(normalisedDelegationId);
2894
- const ix = (0, import_sdk9.buildCreateLockIx)({
3060
+ const lockIdBytes = (0, import_sdk12.deriveLockId)(normalisedDelegationId);
3061
+ const ix = (0, import_sdk10.buildCreateLockIx)({
2895
3062
  programId,
2896
3063
  lockId: lockIdBytes,
2897
3064
  payer: payerKp.publicKey,
@@ -2982,7 +3149,7 @@ function registerDelegationCommands(root) {
2982
3149
  registerCancel(cmd);
2983
3150
  }
2984
3151
  function registerOffer(parent) {
2985
- parent.command("offer").description("Open a new delegation addressed to <recipient-did> with the agreed terms INLINE (no escrow lock \u2014 fund AFTER acceptance via `delegation fund`).").argument("<recipient>", "Recipient \u2014 agent name (handle) or DID (did:arp:...)").option("--server <url>", "Override ARP server base URL").option("--from-did <did>", "Sender DID \u2014 required only if multiple agents are registered against this server").option("--from <name>", "Signer agent NAME (handle) \u2014 alternative to --from-did, resolved against your local agents").option("--delegation-id <uuid>", "Override the auto-generated delegation id (UUID). Reuse the SAME id at `heyarp delegation fund` time. Useful for replay / scripting.").option("--title <s>", "Required: human-readable title for the offer").option("--brief <json>", "Optional structured brief (JSON object)").option("--criterion <s>", "acceptance_criteria \u2014 repeatable; pass --criterion once per bullet", collectRepeated, []).option("--deadline <rfc3339>", 'Optional RFC 3339 deadline (e.g. "2026-12-31T23:59:59Z")').option("--scope <text>", "scope_summary \u2014 short prose describing the agreed work. Required.").option("--amount <s>", 'Optional decimal-as-string amount (e.g. "10.00"). REQUIRES --currency if set.').option("--currency <s>", `Asset identifier: shorthand (${import_sdk12.WELL_KNOWN_ASSET_KEYS.join("|")}) OR raw CAIP-19 string.`).option("--currency-decimals <n>", "Decimal places for base-unit conversion (0-18). Required only when --currency is raw CAIP-19.").option("--currency-symbol <s>", 'Optional UI hint ("USDC", "SOL"). Max 16 chars.').option("--ttl <seconds>", `Envelope TTL in seconds (max ${import_sdk12.MAX_ENVELOPE_TTL_SECONDS} = 24h)`, "3600").option("--verbose", "Print the full envelope before sending and the full server response. Mutually exclusive with --json.", false).option(
3152
+ parent.command("offer").description("Open a new delegation addressed to <recipient-did> with the agreed terms INLINE (no escrow lock \u2014 fund AFTER acceptance via `delegation fund`).").argument("<recipient>", "Recipient \u2014 agent name (handle) or DID (did:arp:...)").option("--server <url>", "Override ARP server base URL").option("--from-did <did>", "Sender DID \u2014 required only if multiple agents are registered against this server").option("--from <name>", "Signer agent NAME (handle) \u2014 alternative to --from-did, resolved against your local agents").option("--delegation-id <uuid>", "Override the auto-generated delegation id (UUID). Reuse the SAME id at `heyarp delegation fund` time. Useful for replay / scripting.").option("--title <s>", "Required: human-readable title for the offer").option("--brief <json>", "Optional structured brief (JSON object)").option("--criterion <s>", "acceptance_criteria \u2014 repeatable; pass --criterion once per bullet", collectRepeated, []).option("--deadline <rfc3339>", 'Optional RFC 3339 deadline (e.g. "2026-12-31T23:59:59Z")').option("--scope <text>", "scope_summary \u2014 short prose describing the agreed work. Required.").option("--amount <s>", 'Optional decimal-as-string amount (e.g. "10.00"). REQUIRES --currency if set.').option("--currency <s>", `Asset identifier: shorthand (${import_sdk13.WELL_KNOWN_ASSET_KEYS.join("|")}) OR raw CAIP-19 string.`).option("--currency-decimals <n>", "Decimal places for base-unit conversion (0-18). Required only when --currency is raw CAIP-19.").option("--currency-symbol <s>", 'Optional UI hint ("USDC", "SOL"). Max 16 chars.').option("--ttl <seconds>", `Envelope TTL in seconds (max ${import_sdk13.MAX_ENVELOPE_TTL_SECONDS} = 24h)`, "3600").option("--require-online", "Abort (exit 1, CLI_RECIPIENT_OFFLINE) if the recipient is not reachable now, instead of warning and sending to their inbox", false).option("--verbose", "Print the full envelope before sending and the full server response. Mutually exclusive with --json.", false).option(
2986
3153
  "--json",
2987
3154
  'Machine-readable mode \u2014 emit a single JSON object on stdout ({ok, action:"offer", delegationId, eventId, relationshipId, relationshipEventIndex, serverTimestamp, serverEventHash}). Prelude + the "reference this delegation" hints move to stderr; on failure stderr carries `{code, message}`. Mutually exclusive with --verbose.',
2988
3155
  false
@@ -3107,9 +3274,9 @@ async function runOffer(recipientDid, opts) {
3107
3274
  }
3108
3275
  const terms = parseOfferTerms("delegation offer", opts);
3109
3276
  const offeredAssetId = terms.currency?.asset_id;
3110
- if (offeredAssetId && !(0, import_sdk12.isWhitelistedAssetId)(offeredAssetId)) {
3277
+ if (offeredAssetId && !(0, import_sdk13.isWhitelistedAssetId)(offeredAssetId)) {
3111
3278
  console.error(
3112
- import_chalk9.default.yellow(
3279
+ import_chalk11.default.yellow(
3113
3280
  `warning: currency '${offeredAssetId}' is not in the static payment whitelist \u2014 the server will reject the offer (DELEGATION_ASSET_NOT_ALLOWED) unless its deploy registers this asset. See 'heyarp assets'.`
3114
3281
  )
3115
3282
  );
@@ -3128,43 +3295,44 @@ async function runOffer(recipientDid, opts) {
3128
3295
  const api = new ArpApiClient(opts.server);
3129
3296
  const sender = resolveSenderAgent("delegation offer", opts.server, opts.fromDid, opts.from);
3130
3297
  const content = {
3131
- action: import_sdk12.DelegationActions.OFFER,
3298
+ action: import_sdk13.DelegationActions.OFFER,
3132
3299
  delegation_id: delegationId,
3133
3300
  title: opts.title,
3134
3301
  ...terms
3135
3302
  };
3136
3303
  const body = { type: "delegation", content };
3137
- progress(opts.json, import_chalk9.default.dim(`Server: ${api.serverUrl}`));
3138
- progress(opts.json, import_chalk9.default.dim(`Sender: ${sender.did}`));
3139
- progress(opts.json, import_chalk9.default.dim(`Recipient: ${recipientDid}`));
3140
- progress(opts.json, import_chalk9.default.dim(`Delegation: ${delegationId}`));
3304
+ progress(opts.json, import_chalk11.default.dim(`Server: ${api.serverUrl}`));
3305
+ progress(opts.json, import_chalk11.default.dim(`Sender: ${sender.did}`));
3306
+ progress(opts.json, import_chalk11.default.dim(`Recipient: ${recipientDid}`));
3307
+ progress(opts.json, import_chalk11.default.dim(`Delegation: ${delegationId}`));
3308
+ await guardRecipientReachable(api, recipientDid, { requireOnline: opts.requireOnline });
3141
3309
  let result;
3142
3310
  try {
3143
3311
  result = await sendDelegationEnvelope({ api, sender, recipientDid, body, ttlSeconds, verbose: opts.verbose, server: opts.server });
3144
3312
  } catch (err) {
3145
- if (err instanceof ApiError && err.payload.code === import_sdk12.DelegationOfferRejectionCodes.ASSET_NOT_ALLOWED) {
3313
+ if (err instanceof ApiError && err.payload.code === import_sdk13.DelegationOfferRejectionCodes.ASSET_NOT_ALLOWED) {
3146
3314
  const d = err.payload.details;
3147
- console.error(import_chalk9.default.yellow(`
3315
+ console.error(import_chalk11.default.yellow(`
3148
3316
  The server's payment-asset whitelist rejected this currency.`));
3149
3317
  if (d !== void 0) {
3150
- console.error(import_chalk9.default.dim(` offered: ${JSON.stringify(d.offered)}`));
3151
- console.error(import_chalk9.default.dim(` accepted: ${JSON.stringify(d.accepted)}`));
3318
+ console.error(import_chalk11.default.dim(` offered: ${JSON.stringify(d.offered)}`));
3319
+ console.error(import_chalk11.default.dim(` accepted: ${JSON.stringify(d.accepted)}`));
3152
3320
  }
3153
- console.error(import_chalk9.default.dim(`
3321
+ console.error(import_chalk11.default.dim(`
3154
3322
  See the whitelist (shorthand keys + canonical decimals):
3155
3323
  heyarp assets
3156
3324
  then re-offer with a whitelisted --currency.`));
3157
3325
  }
3158
- if (err instanceof ApiError && err.payload.code === import_sdk12.DelegationOfferRejectionCodes.PRICING_MISMATCH) {
3326
+ if (err instanceof ApiError && err.payload.code === import_sdk13.DelegationOfferRejectionCodes.PRICING_MISMATCH) {
3159
3327
  const d = err.payload.details;
3160
- console.error(import_chalk9.default.yellow(`
3328
+ console.error(import_chalk11.default.yellow(`
3161
3329
  The recipient's published accept-prefs rejected this offer${d?.reason ? ` (mismatch: ${d.reason})` : ""}.`));
3162
3330
  if (d !== void 0) {
3163
- console.error(import_chalk9.default.dim(` accepted: ${JSON.stringify(d.accepted)}`));
3164
- console.error(import_chalk9.default.dim(` offered: ${JSON.stringify(d.offered)}`));
3331
+ console.error(import_chalk11.default.dim(` accepted: ${JSON.stringify(d.accepted)}`));
3332
+ console.error(import_chalk11.default.dim(` offered: ${JSON.stringify(d.offered)}`));
3165
3333
  }
3166
3334
  console.error(
3167
- import_chalk9.default.dim(
3335
+ import_chalk11.default.dim(
3168
3336
  `
3169
3337
  Check what the recipient accepts BEFORE offering:
3170
3338
  heyarp agents accept-prefs show ${recipientDid}
@@ -3172,12 +3340,12 @@ then re-run with matching --currency / --amount.`
3172
3340
  )
3173
3341
  );
3174
3342
  }
3175
- if (err instanceof ApiError && err.payload.code === import_sdk12.DelegationOfferRejectionCodes.CAPACITY_EXCEEDED) {
3343
+ if (err instanceof ApiError && err.payload.code === import_sdk13.DelegationOfferRejectionCodes.CAPACITY_EXCEEDED) {
3176
3344
  const d = err.payload.details;
3177
3345
  const cap = d?.maxActive === 0 ? "closed for new offers (busy)" : `at capacity (${d?.currentActive}/${d?.maxActive} active delegations)`;
3178
- console.error(import_chalk9.default.yellow(`
3346
+ console.error(import_chalk11.default.yellow(`
3179
3347
  The recipient is ${cap}.`));
3180
- console.error(import_chalk9.default.dim("\nThis is TRANSIENT \u2014 your terms are fine. Retry the same offer later, or pick another worker (`heyarp agents --tag \u2026`)."));
3348
+ console.error(import_chalk11.default.dim("\nThis is TRANSIENT \u2014 your terms are fine. Retry the same offer later, or pick another worker (`heyarp agents --tag \u2026`)."));
3181
3349
  }
3182
3350
  throw err;
3183
3351
  }
@@ -3195,15 +3363,15 @@ The recipient is ${cap}.`));
3195
3363
  });
3196
3364
  } else {
3197
3365
  printIngestResult(result);
3198
- console.log(import_chalk9.default.dim(`
3366
+ console.log(import_chalk11.default.dim(`
3199
3367
  Reference this delegation on subsequent calls with:`));
3200
- console.log(import_chalk9.default.dim(` heyarp delegation accept ${result.relationshipId} ${delegationId}`));
3201
- console.log(import_chalk9.default.dim(` heyarp delegation decline ${result.relationshipId} ${delegationId}`));
3202
- console.log(import_chalk9.default.dim(` heyarp delegation cancel ${result.relationshipId} ${delegationId}`));
3203
- console.log(import_chalk9.default.dim(`
3368
+ console.log(import_chalk11.default.dim(` heyarp delegation accept ${result.relationshipId} ${delegationId}`));
3369
+ console.log(import_chalk11.default.dim(` heyarp delegation decline ${result.relationshipId} ${delegationId}`));
3370
+ console.log(import_chalk11.default.dim(` heyarp delegation cancel ${result.relationshipId} ${delegationId}`));
3371
+ console.log(import_chalk11.default.dim(`
3204
3372
  After the worker accepts, fund the escrow lock:`));
3205
- console.log(import_chalk9.default.dim(` heyarp wallet create-lock --delegation-id ${delegationId} --condition-hash <hex> ... > lock.json`));
3206
- console.log(import_chalk9.default.dim(` heyarp delegation fund ${delegationId} --escrow-lock-from-file lock.json`));
3373
+ console.log(import_chalk11.default.dim(` heyarp wallet create-lock --delegation-id ${delegationId} --condition-hash <hex> ... > lock.json`));
3374
+ console.log(import_chalk11.default.dim(` heyarp delegation fund ${delegationId} --escrow-lock-from-file lock.json`));
3207
3375
  }
3208
3376
  if (opts.waitUntil && !opts.json) {
3209
3377
  const untilPhase = parseUntilPhase(opts.waitUntil);
@@ -3226,7 +3394,7 @@ After the worker accepts, fund the escrow lock:`));
3226
3394
  }
3227
3395
  }
3228
3396
  function registerFund(parent) {
3229
- parent.command("fund").description("Fund an ACCEPTED delegation with the escrow lock (buyer-only). Run AFTER the worker accepts the offer.").argument("<delegation-id>", "Delegation UUID (the one you offered + the worker accepted)").option("--server <url>", "Override ARP server base URL").option("--from-did <did>", "Sender DID \u2014 required only if multiple agents are registered against this server").option("--from <name>", "Signer agent NAME (handle) \u2014 alternative to --from-did, resolved against your local agents").option("--ttl <seconds>", `Envelope TTL in seconds (max ${import_sdk12.MAX_ENVELOPE_TTL_SECONDS} = 24h)`, "3600").option("--verbose", "Print the full envelope before sending and the full server response. Mutually exclusive with --json.", false).option(
3397
+ parent.command("fund").description("Fund an ACCEPTED delegation with the escrow lock (buyer-only). Run AFTER the worker accepts the offer.").argument("<delegation-id>", "Delegation UUID (the one you offered + the worker accepted)").option("--server <url>", "Override ARP server base URL").option("--from-did <did>", "Sender DID \u2014 required only if multiple agents are registered against this server").option("--from <name>", "Signer agent NAME (handle) \u2014 alternative to --from-did, resolved against your local agents").option("--ttl <seconds>", `Envelope TTL in seconds (max ${import_sdk13.MAX_ENVELOPE_TTL_SECONDS} = 24h)`, "3600").option("--verbose", "Print the full envelope before sending and the full server response. Mutually exclusive with --json.", false).option(
3230
3398
  "--json",
3231
3399
  'Machine-readable mode \u2014 emit a single JSON object on stdout ({ok, action:"fund", delegationId, eventId, relationshipId, relationshipEventIndex, serverTimestamp, serverEventHash}). Prelude moves off stdout; on failure stderr carries `{code, message}`. Mutually exclusive with --verbose.',
3232
3400
  false
@@ -3287,23 +3455,23 @@ async function runFund(delegationId, opts) {
3287
3455
  }
3288
3456
  if (result2.kind === "skipped_no_expected_program_id") {
3289
3457
  console.error(
3290
- import_chalk9.default.yellow(
3458
+ import_chalk11.default.yellow(
3291
3459
  "\u26A0 delegation fund: no authoritative expected program-id available (--program-id missing, ARP_ESCROW_PROGRAM_ID env unset, server protocol-fee unreachable). Pre-flight skipped; server-side ESC_LOCK_TX_PROGRAM_ID_MISMATCH check is the only backstop. Set ARP_ESCROW_PROGRAM_ID or pass --program-id to enable pre-flight."
3292
3460
  )
3293
3461
  );
3294
3462
  }
3295
3463
  }
3296
- const content = { action: import_sdk12.DelegationActions.FUND, delegation_id: delegationId };
3464
+ const content = { action: import_sdk13.DelegationActions.FUND, delegation_id: delegationId };
3297
3465
  const body = { type: "delegation", content };
3298
3466
  const attachments = { escrow_lock: escrowResult.attachment };
3299
- progress(opts.json, import_chalk9.default.dim(`Server: ${api.serverUrl}`));
3300
- progress(opts.json, import_chalk9.default.dim(`Sender: ${sender.did}`));
3301
- progress(opts.json, import_chalk9.default.dim(`Recipient: ${resolved.recipientDid}`));
3302
- progress(opts.json, import_chalk9.default.dim(`Relationship: ${resolved.relationshipId}`));
3303
- progress(opts.json, import_chalk9.default.dim(`Delegation: ${delegationId} (action=fund)`));
3467
+ progress(opts.json, import_chalk11.default.dim(`Server: ${api.serverUrl}`));
3468
+ progress(opts.json, import_chalk11.default.dim(`Sender: ${sender.did}`));
3469
+ progress(opts.json, import_chalk11.default.dim(`Recipient: ${resolved.recipientDid}`));
3470
+ progress(opts.json, import_chalk11.default.dim(`Relationship: ${resolved.relationshipId}`));
3471
+ progress(opts.json, import_chalk11.default.dim(`Delegation: ${delegationId} (action=fund)`));
3304
3472
  {
3305
3473
  const a = escrowResult.attachment;
3306
- progress(opts.json, import_chalk9.default.dim(`Escrow lock attached: lock_id=${a.lock_id} amount=${a.amount} asset_id=${a.asset_id}`));
3474
+ progress(opts.json, import_chalk11.default.dim(`Escrow lock attached: lock_id=${a.lock_id} amount=${a.amount} asset_id=${a.asset_id}`));
3307
3475
  }
3308
3476
  const result = await sendDelegationEnvelope({
3309
3477
  api,
@@ -3329,7 +3497,7 @@ async function runFund(delegationId, opts) {
3329
3497
  });
3330
3498
  } else {
3331
3499
  printIngestResult(result);
3332
- console.log(import_chalk9.default.dim("\nThe worker waits for the on-chain lock to confirm (LOCKED), then begins work."));
3500
+ console.log(import_chalk11.default.dim("\nThe worker waits for the on-chain lock to confirm (LOCKED), then begins work."));
3333
3501
  }
3334
3502
  if (opts.waitUntil && !opts.json) {
3335
3503
  const untilPhase = parseUntilPhase(opts.waitUntil);
@@ -3394,7 +3562,7 @@ function registerDecline(parent) {
3394
3562
  "--reason <code>",
3395
3563
  // surface the closed enum at help time so operators
3396
3564
  // don't have to read source to find acceptable values.
3397
- `Required: decline reason code (one of: ${import_sdk12.DECLINE_REASONS.join(", ")}). Carried in body.content.reason so the counterparty's reactor can branch on it.`
3565
+ `Required: decline reason code (one of: ${import_sdk13.DECLINE_REASONS.join(", ")}). Carried in body.content.reason so the counterparty's reactor can branch on it.`
3398
3566
  ).option("--reason-detail <s>", 'Optional free-text elaboration alongside --reason (e.g. "rate floor 0.20 USDC"). Max 512 chars.').option("--verbose", "Print the full envelope before sending and the full server response. Mutually exclusive with --json.", false).option(
3399
3567
  "--json",
3400
3568
  'Machine-readable mode \u2014 emit a single JSON object on stdout ({ok, action:"decline", delegationId, eventId, relationshipId, relationshipEventIndex, serverTimestamp, serverEventHash}). Prelude + pending-lock poll chatter move off stdout; on failure stderr carries `{code, message}`. Mutually exclusive with --verbose.',
@@ -3431,7 +3599,7 @@ async function runFollowupAction(relationshipId, delegationId, action, opts) {
3431
3599
  const lockWaitTimeoutSec = parseLockWaitTimeout(cmdName, opts.lockWaitTimeout);
3432
3600
  const lockWaitIntervalSec = parseLockWaitInterval(cmdName, opts.lockWaitInterval);
3433
3601
  let declinePayload = null;
3434
- if (action === import_sdk12.DelegationActions.DECLINE) {
3602
+ if (action === import_sdk13.DelegationActions.DECLINE) {
3435
3603
  const reason = parseDeclineReason(cmdName, opts.reason);
3436
3604
  const validatedDetail = parseReasonDetail(cmdName, opts.reasonDetail);
3437
3605
  declinePayload = validatedDetail ? { reason, reasonDetail: validatedDetail } : { reason };
@@ -3440,7 +3608,7 @@ async function runFollowupAction(relationshipId, delegationId, action, opts) {
3440
3608
  const sender = resolveSenderAgent(cmdName, opts.server, opts.fromDid, opts.from);
3441
3609
  const signer = makeSigner(sender);
3442
3610
  const resolved = await resolveDelegationRefs(cmdName, api, signer, { relationshipId, delegationId, action, selfDid: sender.did });
3443
- if (resolved.state === import_sdk12.DelegationStates.PENDING_LOCK_FINALIZATION && opts.waitForLock !== false) {
3611
+ if (resolved.state === import_sdk13.DelegationStates.PENDING_LOCK_FINALIZATION && opts.waitForLock !== false) {
3444
3612
  await awaitDelegationLockFinalized(cmdName, api, signer, {
3445
3613
  relationshipId,
3446
3614
  delegationId,
@@ -3462,10 +3630,10 @@ async function runFollowupAction(relationshipId, delegationId, action, opts) {
3462
3630
  if (declinePayload.reasonDetail) content.reason_detail = declinePayload.reasonDetail;
3463
3631
  }
3464
3632
  const body = { type: "delegation", content };
3465
- progress(opts.json, import_chalk9.default.dim(`Server: ${api.serverUrl}`));
3466
- progress(opts.json, import_chalk9.default.dim(`Sender: ${sender.did}`));
3467
- progress(opts.json, import_chalk9.default.dim(`Relationship: ${relationshipId}`));
3468
- progress(opts.json, import_chalk9.default.dim(`Delegation: ${delegationId} (action=${action}${action === import_sdk12.DelegationActions.DECLINE ? `, reason=${content.reason}` : ""})`));
3633
+ progress(opts.json, import_chalk11.default.dim(`Server: ${api.serverUrl}`));
3634
+ progress(opts.json, import_chalk11.default.dim(`Sender: ${sender.did}`));
3635
+ progress(opts.json, import_chalk11.default.dim(`Relationship: ${relationshipId}`));
3636
+ progress(opts.json, import_chalk11.default.dim(`Delegation: ${delegationId} (action=${action}${action === import_sdk13.DelegationActions.DECLINE ? `, reason=${content.reason}` : ""})`));
3469
3637
  const result = await sendDelegationEnvelope({
3470
3638
  api,
3471
3639
  sender,
@@ -3494,9 +3662,9 @@ async function runFollowupAction(relationshipId, delegationId, action, opts) {
3494
3662
  async function sendDelegationEnvelope(args) {
3495
3663
  const nextSequence = (args.sender.lastSenderSequence ?? 0) + 1;
3496
3664
  const protectedBlock = {
3497
- protocol_version: import_sdk12.CURRENT_PROTOCOL_VERSION,
3498
- purpose: import_sdk12.Purpose.ENVELOPE,
3499
- message_id: (0, import_sdk12.uuidV4)(),
3665
+ protocol_version: import_sdk13.CURRENT_PROTOCOL_VERSION,
3666
+ purpose: import_sdk13.Purpose.ENVELOPE,
3667
+ message_id: (0, import_sdk13.uuidV4)(),
3500
3668
  sender_did: args.sender.did,
3501
3669
  recipient_did: args.recipientDid,
3502
3670
  // `relationship_id: null` matches the handshake
@@ -3505,20 +3673,20 @@ async function sendDelegationEnvelope(args) {
3505
3673
  // existing relationship row.
3506
3674
  relationship_id: null,
3507
3675
  sender_sequence: nextSequence,
3508
- sender_nonce: (0, import_sdk12.senderNonce)(),
3509
- timestamp: (0, import_sdk12.rfc3339)(),
3510
- expires_at: (0, import_sdk12.expiresAt)(args.ttlSeconds),
3676
+ sender_nonce: (0, import_sdk13.senderNonce)(),
3677
+ timestamp: (0, import_sdk13.rfc3339)(),
3678
+ expires_at: (0, import_sdk13.expiresAt)(args.ttlSeconds),
3511
3679
  delivery_id: null
3512
3680
  };
3513
3681
  const signer = makeSigner(args.sender);
3514
- const envelope = (0, import_sdk12.signEnvelope)({
3682
+ const envelope = (0, import_sdk13.signEnvelope)({
3515
3683
  protected: protectedBlock,
3516
3684
  body: args.body,
3517
3685
  identitySecretKey: signer.identitySecretKey,
3518
3686
  attachments: args.attachments
3519
3687
  });
3520
3688
  if (args.verbose) {
3521
- console.log(import_chalk9.default.bold("\nEnvelope (pre-send):"));
3689
+ console.log(import_chalk11.default.bold("\nEnvelope (pre-send):"));
3522
3690
  console.log(formatJson(envelope));
3523
3691
  }
3524
3692
  try {
@@ -3526,7 +3694,7 @@ async function sendDelegationEnvelope(args) {
3526
3694
  updateAgentLocal(args.server, args.sender.did, { lastSenderSequence: nextSequence });
3527
3695
  return result;
3528
3696
  } catch (err) {
3529
- if (err instanceof ApiError && (0, import_sdk12.isPostCommitErrorCode)(err.payload.code)) {
3697
+ if (err instanceof ApiError && (0, import_sdk13.isPostCommitErrorCode)(err.payload.code)) {
3530
3698
  updateAgentLocal(args.server, args.sender.did, { lastSenderSequence: nextSequence });
3531
3699
  }
3532
3700
  throw err;
@@ -3548,7 +3716,7 @@ async function resolveDelegationRefs(cmdName, api, signer, args) {
3548
3716
  );
3549
3717
  }
3550
3718
  let recipientDid;
3551
- if (args.action === import_sdk12.DelegationActions.CANCEL) {
3719
+ if (args.action === import_sdk13.DelegationActions.CANCEL) {
3552
3720
  const firstEvents = await api.listEvents(args.relationshipId, signer, { since: 0, limit: 1 });
3553
3721
  const handshake = firstEvents[0];
3554
3722
  if (!handshake) {
@@ -3573,7 +3741,7 @@ async function resolveDelegationRefs(cmdName, api, signer, args) {
3573
3741
  async function awaitDelegationLockFinalized(cmdName, api, signer, args) {
3574
3742
  const log = args.log ?? ((line) => console.log(line));
3575
3743
  log(
3576
- import_chalk9.default.dim(
3744
+ import_chalk11.default.dim(
3577
3745
  `
3578
3746
  [--wait-for-lock] delegation ${args.delegationId} is awaiting on-chain lock confirmation; polling until ready (interval=${args.intervalSec}s timeout=${args.timeoutSec}s)`
3579
3747
  )
@@ -3588,7 +3756,7 @@ async function awaitDelegationLockFinalized(cmdName, api, signer, args) {
3588
3756
  after = page[page.length - 1].id;
3589
3757
  }
3590
3758
  };
3591
- const outcome = await (0, import_sdk12.pollUntil)({
3759
+ const outcome = await (0, import_sdk13.pollUntil)({
3592
3760
  fetch: fetchRow,
3593
3761
  // Match on either "row not found at all" OR "state moved
3594
3762
  // past pending_lock_finalization". The post-poll branch
@@ -3598,7 +3766,7 @@ async function awaitDelegationLockFinalized(cmdName, api, signer, args) {
3598
3766
  // rows return cleanly. Polling on null would loop pointlessly
3599
3767
  // until the deadline fires and surface a misleading "timed
3600
3768
  // out" message for what's actually a wrong-id problem.
3601
- predicate: (row2) => row2 === null || row2.state !== import_sdk12.DelegationStates.PENDING_LOCK_FINALIZATION,
3769
+ predicate: (row2) => row2 === null || row2.state !== import_sdk13.DelegationStates.PENDING_LOCK_FINALIZATION,
3602
3770
  intervalMs: args.intervalSec * 1e3,
3603
3771
  timeoutMs: args.timeoutSec * 1e3,
3604
3772
  // Swallow ONLY transient errors. A 4xx during the poll is a
@@ -3612,7 +3780,7 @@ async function awaitDelegationLockFinalized(cmdName, api, signer, args) {
3612
3780
  if (err instanceof ApiError && err.status >= 400 && err.status < 500) {
3613
3781
  throw err;
3614
3782
  }
3615
- log(import_chalk9.default.dim(` poll: transient fetch error (${err instanceof Error ? err.message : String(err)})`));
3783
+ log(import_chalk11.default.dim(` poll: transient fetch error (${err instanceof Error ? err.message : String(err)})`));
3616
3784
  }
3617
3785
  });
3618
3786
  if (outcome.kind === "timeout") {
@@ -3629,12 +3797,12 @@ async function awaitDelegationLockFinalized(cmdName, api, signer, args) {
3629
3797
  `${cmdName}: delegation ${args.delegationId} disappeared from relationship ${args.relationshipId} during --wait-for-lock pre-flight. Re-check the delegation id with \`heyarp delegations ${args.relationshipId}\`.`
3630
3798
  );
3631
3799
  }
3632
- if (row.state !== import_sdk12.DelegationStates.OFFERED) {
3800
+ if (row.state !== import_sdk13.DelegationStates.OFFERED) {
3633
3801
  throw new Error(
3634
3802
  `${cmdName}: delegation ${args.delegationId} transitioned to '${row.state}' while waiting for on-chain lock confirmation; cannot ${args.action}. Re-read the delegation timeline with \`heyarp delegations ${args.relationshipId}\` to see the latest state.`
3635
3803
  );
3636
3804
  }
3637
- log(import_chalk9.default.dim(`[--wait-for-lock] delegation ${args.delegationId} ready (state=${row.state}); proceeding with ${args.action}.`));
3805
+ log(import_chalk11.default.dim(`[--wait-for-lock] delegation ${args.delegationId} ready (state=${row.state}); proceeding with ${args.action}.`));
3638
3806
  return row;
3639
3807
  }
3640
3808
  function parseLockWaitTimeout(cmdName, raw) {
@@ -3660,12 +3828,12 @@ function parseLockWaitInterval(cmdName, raw) {
3660
3828
  return n;
3661
3829
  }
3662
3830
  function printIngestResult(result) {
3663
- console.log(import_chalk9.default.green("\nDelivered."));
3664
- console.log(`${import_chalk9.default.bold("Event id")}: ${import_chalk9.default.cyan(result.eventId)}`);
3665
- console.log(`${import_chalk9.default.bold("Relationship id")}: ${import_chalk9.default.cyan(result.relationshipId)}`);
3666
- console.log(`${import_chalk9.default.bold("Chain index")}: ${import_chalk9.default.cyan(String(result.relationshipEventIndex))}`);
3667
- console.log(`${import_chalk9.default.bold("Server timestamp")}: ${import_chalk9.default.cyan(result.serverTimestamp)}`);
3668
- console.log(`${import_chalk9.default.bold("Server event hash")}: ${import_chalk9.default.cyan(result.serverEventHash)}`);
3831
+ console.log(import_chalk11.default.green("\nDelivered."));
3832
+ console.log(`${import_chalk11.default.bold("Event id")}: ${import_chalk11.default.cyan(result.eventId)}`);
3833
+ console.log(`${import_chalk11.default.bold("Relationship id")}: ${import_chalk11.default.cyan(result.relationshipId)}`);
3834
+ console.log(`${import_chalk11.default.bold("Chain index")}: ${import_chalk11.default.cyan(String(result.relationshipEventIndex))}`);
3835
+ console.log(`${import_chalk11.default.bold("Server timestamp")}: ${import_chalk11.default.cyan(result.serverTimestamp)}`);
3836
+ console.log(`${import_chalk11.default.bold("Server event hash")}: ${import_chalk11.default.cyan(result.serverEventHash)}`);
3669
3837
  }
3670
3838
  function parseOfferTerms(cmdName, opts) {
3671
3839
  const out = {};
@@ -3689,7 +3857,7 @@ function parseOfferTerms(cmdName, opts) {
3689
3857
  if (opts.amount) {
3690
3858
  out.amount = opts.amount;
3691
3859
  if (!opts.currency) {
3692
- throw new Error(`${cmdName}: --amount requires --currency. Shorthand: ${import_sdk12.WELL_KNOWN_ASSET_KEYS.join(", ")}, or raw CAIP-19 + --currency-decimals.`);
3860
+ throw new Error(`${cmdName}: --amount requires --currency. Shorthand: ${import_sdk13.WELL_KNOWN_ASSET_KEYS.join(", ")}, or raw CAIP-19 + --currency-decimals.`);
3693
3861
  }
3694
3862
  out.currency = buildAssetIdentifier(cmdName, DELEGATION_CURRENCY_FLAGS, opts.currency, opts.currencyDecimals, opts.currencySymbol);
3695
3863
  } else if (opts.currency) {
@@ -3712,7 +3880,7 @@ function resolveOfferDelegationId(rawCliId, escrow) {
3712
3880
  cliId = rawCliId.toLowerCase();
3713
3881
  }
3714
3882
  if (escrow === void 0) {
3715
- return cliId ?? (0, import_sdk12.uuidV4)();
3883
+ return cliId ?? (0, import_sdk13.uuidV4)();
3716
3884
  }
3717
3885
  if (escrow.delegationIdFromLock !== void 0) {
3718
3886
  const fileId = escrow.delegationIdFromLock;
@@ -3742,10 +3910,10 @@ function collectRepeated(value, previous) {
3742
3910
  }
3743
3911
  function parseDeclineReason(cmdName, raw) {
3744
3912
  if (raw === void 0 || raw === "") {
3745
- throw new Error(`${cmdName}: --reason is required when declining (one of: ${import_sdk12.DECLINE_REASONS.join(", ")})`);
3913
+ throw new Error(`${cmdName}: --reason is required when declining (one of: ${import_sdk13.DECLINE_REASONS.join(", ")})`);
3746
3914
  }
3747
- if (!(0, import_sdk12.isDeclineReason)(raw)) {
3748
- throw new Error(`${cmdName}: --reason must be one of ${import_sdk12.DECLINE_REASONS.join(", ")} (got '${raw}')`);
3915
+ if (!(0, import_sdk13.isDeclineReason)(raw)) {
3916
+ throw new Error(`${cmdName}: --reason must be one of ${import_sdk13.DECLINE_REASONS.join(", ")} (got '${raw}')`);
3749
3917
  }
3750
3918
  return raw;
3751
3919
  }
@@ -3760,10 +3928,10 @@ function parseReasonDetail(cmdName, raw) {
3760
3928
  return raw;
3761
3929
  }
3762
3930
  function buildAssetIdentifier(cmdName, labels, rawCurrency, rawDecimals, rawSymbol) {
3763
- const resolved = (0, import_sdk12.resolveAsset)(rawCurrency);
3931
+ const resolved = (0, import_sdk13.resolveAsset)(rawCurrency);
3764
3932
  if (!resolved) {
3765
3933
  throw new Error(
3766
- `${cmdName}: ${labels.currencyFlag} '${rawCurrency}' is not a known shorthand or a valid CAIP-19 string. Shorthand: ${import_sdk12.WELL_KNOWN_ASSET_KEYS.join(", ")}. Or pass a raw CAIP-19 id (e.g. "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/spl:EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v") with ${labels.decimalsFlag}.`
3934
+ `${cmdName}: ${labels.currencyFlag} '${rawCurrency}' is not a known shorthand or a valid CAIP-19 string. Shorthand: ${import_sdk13.WELL_KNOWN_ASSET_KEYS.join(", ")}. Or pass a raw CAIP-19 id (e.g. "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/spl:EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v") with ${labels.decimalsFlag}.`
3767
3935
  );
3768
3936
  }
3769
3937
  let decimals = resolved.decimals;
@@ -3772,20 +3940,20 @@ function buildAssetIdentifier(cmdName, labels, rawCurrency, rawDecimals, rawSymb
3772
3940
  throw new Error(`${cmdName}: ${labels.currencyFlag} is a raw CAIP-19 string; ${labels.decimalsFlag} (0-18) is required to convert amounts to base units.`);
3773
3941
  }
3774
3942
  const parsed = Number(rawDecimals);
3775
- if (!Number.isInteger(parsed) || parsed < import_sdk12.ASSET_DECIMALS_MIN || parsed > import_sdk12.ASSET_DECIMALS_MAX) {
3943
+ if (!Number.isInteger(parsed) || parsed < import_sdk13.ASSET_DECIMALS_MIN || parsed > import_sdk13.ASSET_DECIMALS_MAX) {
3776
3944
  throw new Error(`${cmdName}: ${labels.decimalsFlag} must be an integer in [0, 18] (got '${rawDecimals}').`);
3777
3945
  }
3778
3946
  decimals = parsed;
3779
3947
  } else if (rawDecimals !== void 0) {
3780
3948
  const parsed = Number(rawDecimals);
3781
- if (!Number.isInteger(parsed) || parsed < import_sdk12.ASSET_DECIMALS_MIN || parsed > import_sdk12.ASSET_DECIMALS_MAX) {
3949
+ if (!Number.isInteger(parsed) || parsed < import_sdk13.ASSET_DECIMALS_MIN || parsed > import_sdk13.ASSET_DECIMALS_MAX) {
3782
3950
  throw new Error(`${cmdName}: ${labels.decimalsFlag} must be an integer in [0, 18] (got '${rawDecimals}').`);
3783
3951
  }
3784
3952
  decimals = parsed;
3785
3953
  }
3786
3954
  let symbol = resolved.symbol;
3787
3955
  if (rawSymbol !== void 0) {
3788
- if (rawSymbol.length < import_sdk12.ASSET_SYMBOL_MIN_LEN || rawSymbol.length > import_sdk12.ASSET_SYMBOL_MAX_LEN) {
3956
+ if (rawSymbol.length < import_sdk13.ASSET_SYMBOL_MIN_LEN || rawSymbol.length > import_sdk13.ASSET_SYMBOL_MAX_LEN) {
3789
3957
  throw new Error(`${cmdName}: ${labels.symbolFlag} must be 1-16 chars (got length ${rawSymbol.length}).`);
3790
3958
  }
3791
3959
  symbol = rawSymbol;
@@ -3799,10 +3967,10 @@ var DELEGATION_CURRENCY_FLAGS = {
3799
3967
  };
3800
3968
 
3801
3969
  // src/commands/delegations.ts
3802
- var import_sdk13 = require("@heyanon-arp/sdk");
3803
- var import_chalk10 = __toESM(require("chalk"));
3970
+ var import_sdk14 = require("@heyanon-arp/sdk");
3971
+ var import_chalk12 = __toESM(require("chalk"));
3804
3972
  init_api();
3805
- var ALLOWED_STATES = /* @__PURE__ */ new Set([import_sdk13.DelegationStates.OFFERED, import_sdk13.DelegationStates.ACCEPTED, import_sdk13.DelegationStates.DECLINED, import_sdk13.DelegationStates.CANCELED]);
3973
+ var ALLOWED_STATES = /* @__PURE__ */ new Set([import_sdk14.DelegationStates.OFFERED, import_sdk14.DelegationStates.ACCEPTED, import_sdk14.DelegationStates.DECLINED, import_sdk14.DelegationStates.CANCELED]);
3806
3974
  function registerDelegationsCommand(root) {
3807
3975
  root.command("delegations").description("List delegations for a relationship (one row per delegationId, oldest-first)").argument("<relationship-id>", "Relationship UUID").option("--server <url>", "Override ARP server base URL").option("--state <s>", "Filter by exact state (offered|accepted|declined|canceled)").option("--after <id>", "Cursor: pass the previous page's last `id` to fetch the next page").option("--limit <n>", "Max rows to return (1..100)", "20").option("--from-did <did>", "Signer DID \u2014 required only if multiple agents are registered against this server").option("--from <name>", "Signer agent NAME (handle) \u2014 alternative to --from-did, resolved against your local agents").option(
3808
3976
  "--verbose",
@@ -3822,9 +3990,9 @@ async function runDelegations(relationshipId, opts) {
3822
3990
  const state = parseState(opts.state);
3823
3991
  const api = new ArpApiClient(opts.server);
3824
3992
  const sender = resolveSenderAgent("delegations", opts.server, opts.fromDid, opts.from);
3825
- progress(opts.json, import_chalk10.default.dim(`Server: ${api.serverUrl}`));
3826
- progress(opts.json, import_chalk10.default.dim(`Signer: ${sender.did}`));
3827
- progress(opts.json, import_chalk10.default.dim(`Relationship: ${relationshipId}`));
3993
+ progress(opts.json, import_chalk12.default.dim(`Server: ${api.serverUrl}`));
3994
+ progress(opts.json, import_chalk12.default.dim(`Signer: ${sender.did}`));
3995
+ progress(opts.json, import_chalk12.default.dim(`Relationship: ${relationshipId}`));
3828
3996
  const query = { limit };
3829
3997
  if (state) query.state = state;
3830
3998
  if (opts.after) query.after = opts.after;
@@ -3835,7 +4003,7 @@ async function runDelegations(relationshipId, opts) {
3835
4003
  return;
3836
4004
  }
3837
4005
  if (rows.length === 0) {
3838
- console.log(import_chalk10.default.dim("\n(no delegations for this relationship)"));
4006
+ console.log(import_chalk12.default.dim("\n(no delegations for this relationship)"));
3839
4007
  return;
3840
4008
  }
3841
4009
  console.log("");
@@ -3851,19 +4019,19 @@ async function runDelegations(relationshipId, opts) {
3851
4019
  }));
3852
4020
  }
3853
4021
  const lastId = rows[rows.length - 1].id;
3854
- console.log(import_chalk10.default.dim(`
4022
+ console.log(import_chalk12.default.dim(`
3855
4023
  ${rows.length} delegation row(s). Paginate with --after ${lastId}.`));
3856
4024
  }
3857
4025
  function formatDelegationLine(d, selfDid, opts = {}) {
3858
- const idHead_ = import_chalk10.default.bold(opts.fullIds ? d.delegationId : idHead(d.delegationId));
4026
+ const idHead_ = import_chalk12.default.bold(opts.fullIds ? d.delegationId : idHead(d.delegationId));
3859
4027
  const state = colorState(d.state).padEnd(stateColumnWidth());
3860
- const offerer = d.offererDid === selfDid ? import_chalk10.default.bold("me") : import_chalk10.default.dim(opts.fullIds ? d.offererDid : didHead(d.offererDid));
4028
+ const offerer = d.offererDid === selfDid ? import_chalk12.default.bold("me") : import_chalk12.default.dim(opts.fullIds ? d.offererDid : didHead(d.offererDid));
3861
4029
  const amount = formatAmount(d);
3862
- const title = d.title ? import_chalk10.default.dim(`"${truncate2(d.title, 40)}"`) : import_chalk10.default.dim("(no title)");
4030
+ const title = d.title ? import_chalk12.default.dim(`"${truncate2(d.title, 40)}"`) : import_chalk12.default.dim("(no title)");
3863
4031
  let declineSuffix = "";
3864
- if (d.state === import_sdk13.DelegationStates.DECLINED && d.declineReason) {
4032
+ if (d.state === import_sdk14.DelegationStates.DECLINED && d.declineReason) {
3865
4033
  const detail = d.declineReasonDetail ? `: ${truncate2(d.declineReasonDetail, 40)}` : "";
3866
- declineSuffix = ` ${import_chalk10.default.dim(`(reason: ${d.declineReason}${detail})`)}`;
4034
+ declineSuffix = ` ${import_chalk12.default.dim(`(reason: ${d.declineReason}${detail})`)}`;
3867
4035
  }
3868
4036
  return `${idHead_} ${state} ${offerer} ${amount} ${title}${declineSuffix}`;
3869
4037
  }
@@ -3876,35 +4044,35 @@ function colorState(s) {
3876
4044
  // returns `undefined` and `formatDelegationLine` crashes with
3877
4045
  // `TypeError: Cannot read properties of undefined (reading
3878
4046
  // 'padEnd')` on any listing containing such a row.
3879
- case import_sdk13.DelegationStates.OFFERED:
3880
- return import_chalk10.default.yellow("offered");
3881
- case import_sdk13.DelegationStates.PENDING_LOCK_FINALIZATION:
3882
- return import_chalk10.default.yellow("pending_lock");
3883
- case import_sdk13.DelegationStates.ACCEPTED:
3884
- return import_chalk10.default.green("accepted");
4047
+ case import_sdk14.DelegationStates.OFFERED:
4048
+ return import_chalk12.default.yellow("offered");
4049
+ case import_sdk14.DelegationStates.PENDING_LOCK_FINALIZATION:
4050
+ return import_chalk12.default.yellow("pending_lock");
4051
+ case import_sdk14.DelegationStates.ACCEPTED:
4052
+ return import_chalk12.default.green("accepted");
3885
4053
  // The on-chain escrow lock is confirmed. Distinct branch so a
3886
4054
  // LOCKED row renders without hitting the defensive fallback
3887
4055
  // (which would otherwise echo the raw state).
3888
- case import_sdk13.DelegationStates.LOCKED:
3889
- return import_chalk10.default.green("locked");
3890
- case import_sdk13.DelegationStates.DECLINED:
3891
- return import_chalk10.default.red("declined");
3892
- case import_sdk13.DelegationStates.CANCELED:
3893
- return import_chalk10.default.dim("canceled");
4056
+ case import_sdk14.DelegationStates.LOCKED:
4057
+ return import_chalk12.default.green("locked");
4058
+ case import_sdk14.DelegationStates.DECLINED:
4059
+ return import_chalk12.default.red("declined");
4060
+ case import_sdk14.DelegationStates.CANCELED:
4061
+ return import_chalk12.default.dim("canceled");
3894
4062
  // Terminal escrow outcomes: completed = payee paid;
3895
4063
  // failed = create_lock never landed; refunded = funds returned
3896
4064
  // to the buyer (work expired / dispute closed);
3897
4065
  // dispute_resolved = operator ruled.
3898
- case import_sdk13.DelegationStates.COMPLETED:
3899
- return import_chalk10.default.green("completed");
3900
- case import_sdk13.DelegationStates.FAILED:
3901
- return import_chalk10.default.red("failed");
3902
- case import_sdk13.DelegationStates.REFUNDED:
3903
- return import_chalk10.default.red("refunded");
3904
- case import_sdk13.DelegationStates.DISPUTING:
3905
- return import_chalk10.default.yellow("disputing");
3906
- case import_sdk13.DelegationStates.DISPUTE_RESOLVED:
3907
- return import_chalk10.default.red("dispute_resolved");
4066
+ case import_sdk14.DelegationStates.COMPLETED:
4067
+ return import_chalk12.default.green("completed");
4068
+ case import_sdk14.DelegationStates.FAILED:
4069
+ return import_chalk12.default.red("failed");
4070
+ case import_sdk14.DelegationStates.REFUNDED:
4071
+ return import_chalk12.default.red("refunded");
4072
+ case import_sdk14.DelegationStates.DISPUTING:
4073
+ return import_chalk12.default.yellow("disputing");
4074
+ case import_sdk14.DelegationStates.DISPUTE_RESOLVED:
4075
+ return import_chalk12.default.red("dispute_resolved");
3908
4076
  default: {
3909
4077
  const _exhaustive = s;
3910
4078
  void _exhaustive;
@@ -3916,9 +4084,9 @@ function stateColumnWidth() {
3916
4084
  return 12;
3917
4085
  }
3918
4086
  function formatAmount(d) {
3919
- if (!d.amount) return import_chalk10.default.dim("(no amount)");
4087
+ if (!d.amount) return import_chalk12.default.dim("(no amount)");
3920
4088
  const currency = d.currency ? d.currency.symbol ?? d.currency.assetId : "?";
3921
- return import_chalk10.default.cyan(`${d.amount} ${currency}`);
4089
+ return import_chalk12.default.cyan(`${d.amount} ${currency}`);
3922
4090
  }
3923
4091
  function idHead(id) {
3924
4092
  if (id.length <= 12) return id;
@@ -3949,7 +4117,7 @@ function parseLimit2(raw) {
3949
4117
  }
3950
4118
 
3951
4119
  // src/commands/did-doc.ts
3952
- var import_sdk14 = require("@heyanon-arp/sdk");
4120
+ var import_sdk15 = require("@heyanon-arp/sdk");
3953
4121
  init_api();
3954
4122
  function registerDidDocCommand(root) {
3955
4123
  root.command("did-doc").description(
@@ -3958,7 +4126,7 @@ function registerDidDocCommand(root) {
3958
4126
  "--field <path>",
3959
4127
  "Extract a single value via a dotted path. Supports object property access (`id`), numeric array indexes (`verificationMethod.0`), and `#fragment` array selectors that match a verification-method or service entry by its `id` suffix (`verificationMethod.#settlement.publicKeyMultibase`). Two well-known shortcuts skip the path entirely AND strip the multibase prefix: `settlementPublicKey` / `identityPublicKey` emit the raw base58 pubkey ready for flags like `--recipient-pubkey`. Scalar values (string / number / boolean) emit raw to stdout for shell composition (`KEY=$(heyarp did-doc ... --field ...)`); objects / arrays emit as pretty-printed JSON. Mutually exclusive with `--json` since `--field` already controls the shape."
3960
4128
  ).action(async (did, opts) => {
3961
- if (!(0, import_sdk14.isValidDid)(did)) {
4129
+ if (!(0, import_sdk15.isValidDid)(did)) {
3962
4130
  throw new Error(`'${did}' is not a syntactically valid did:arp identifier`);
3963
4131
  }
3964
4132
  if (opts.json && opts.field !== void 0) {
@@ -4069,134 +4237,8 @@ function describeShape(value) {
4069
4237
  return typeof value;
4070
4238
  }
4071
4239
 
4072
- // src/commands/doctor.ts
4073
- var import_sdk15 = require("@heyanon-arp/sdk");
4074
- var import_chalk11 = __toESM(require("chalk"));
4075
- init_api();
4076
- function registerDoctorCommand(root) {
4077
- root.command("doctor").description("Liveness probe for a counterparty: resolve DID document + read protocol activity. No auth.").argument("<did>", "did:arp:<base58btc> of the agent to probe").option("--server <url>", "Override ARP server base URL").option("--json", "Machine-readable: single JSON object on stdout. Pipe-safe.", false).action(async (did, opts) => {
4078
- await runDoctor(did, opts);
4079
- });
4080
- }
4081
- var LISTENING_THRESHOLD_SECONDS = 15 * 60;
4082
- async function runDoctor(did, opts) {
4083
- if (!(0, import_sdk15.isValidDid)(did)) {
4084
- throw new Error(`'${did}' is not a syntactically valid did:arp identifier`);
4085
- }
4086
- const api = new ArpApiClient(opts.server);
4087
- const result = await probe(api, did);
4088
- if (opts.json) {
4089
- console.log(JSON.stringify(result));
4090
- } else {
4091
- console.log(formatDoctorReport(result));
4092
- }
4093
- if (result.verdict !== "LISTENING") {
4094
- process.exitCode = 1;
4095
- }
4096
- }
4097
- async function probe(api, did) {
4098
- const base = {
4099
- did,
4100
- server: api.serverUrl,
4101
- didDocument: { found: false },
4102
- verdict: "UNKNOWN",
4103
- reason: ""
4104
- };
4105
- let doc;
4106
- try {
4107
- doc = await api.getDidDocument(did);
4108
- } catch (err) {
4109
- if (err instanceof ApiError && err.status === 404) {
4110
- return { ...base, verdict: "UNKNOWN", reason: "DID not registered on this server" };
4111
- }
4112
- return { ...base, verdict: "UNKNOWN", reason: `DID document fetch failed: ${err.message}` };
4113
- }
4114
- base.didDocument = { found: true, registeredAt: doc.metadata?.registered_at };
4115
- let activity;
4116
- try {
4117
- const summary = await api.getActivitySummary(did);
4118
- const asOfMs = new Date(summary.asOf).getTime();
4119
- const lastMs = summary.lastEventAt ? new Date(summary.lastEventAt).getTime() : null;
4120
- const ageSeconds = lastMs !== null ? Math.max(0, Math.floor((asOfMs - lastMs) / 1e3)) : null;
4121
- const seenMs = summary.lastSeenAt ? new Date(summary.lastSeenAt).getTime() : null;
4122
- const seenAgeSeconds = seenMs !== null ? Math.max(0, Math.floor((asOfMs - seenMs) / 1e3)) : null;
4123
- activity = {
4124
- lastEventAt: summary.lastEventAt,
4125
- asOf: summary.asOf,
4126
- ageSeconds,
4127
- lastSeenAt: summary.lastSeenAt ?? null,
4128
- seenAgeSeconds,
4129
- inboxStreamActive: summary.inboxStreamActive
4130
- };
4131
- } catch {
4132
- return { ...base, verdict: "UNKNOWN", reason: "DID resolves but the server does not expose an activity summary \u2014 cannot assess liveness" };
4133
- }
4134
- const recentlyActive = activity.ageSeconds !== null && activity.ageSeconds !== void 0 && activity.ageSeconds <= LISTENING_THRESHOLD_SECONDS;
4135
- const recentlySeen = activity.seenAgeSeconds !== null && activity.seenAgeSeconds !== void 0 && activity.seenAgeSeconds <= LISTENING_THRESHOLD_SECONDS;
4136
- const inboxStreamActive = activity.inboxStreamActive === true;
4137
- const result = { ...base, activity };
4138
- if (inboxStreamActive) {
4139
- return {
4140
- ...result,
4141
- verdict: "LISTENING",
4142
- reason: "inbox-stream attached (active SSE subscription on the central server) \u2014 protocol-reachable; worker is actively waiting for envelopes"
4143
- };
4144
- }
4145
- if (recentlySeen) {
4146
- const seenStr = activity.seenAgeSeconds !== void 0 && activity.seenAgeSeconds !== null ? `${activity.seenAgeSeconds}s ago` : "recently";
4147
- return {
4148
- ...result,
4149
- verdict: "LISTENING",
4150
- reason: `recently seen (signed API request ${seenStr}) \u2014 agent is polling the server (cron-mode worker)`
4151
- };
4152
- }
4153
- if (recentlyActive) {
4154
- const ageStr = activity.ageSeconds !== void 0 && activity.ageSeconds !== null ? `${activity.ageSeconds}s ago` : "recently";
4155
- return {
4156
- ...result,
4157
- verdict: "LISTENING",
4158
- reason: `inbox-active (last event ${ageStr}) \u2014 protocol-reachable via the central ARP server`
4159
- };
4160
- }
4161
- const ageNote = activity.lastEventAt === null ? "no events ever" : `last event ${activity.ageSeconds}s ago`;
4162
- const seenNote = activity.lastSeenAt === null || activity.lastSeenAt === void 0 ? "never seen polling" : `last seen ${activity.seenAgeSeconds}s ago`;
4163
- return { ...result, verdict: "DORMANT", reason: `no open inbox stream, ${seenNote}, and ${ageNote} \u2014 agent appears idle (cross-check before relying on it)` };
4164
- }
4165
- function formatDoctorReport(r) {
4166
- const lines = [];
4167
- lines.push(`${import_chalk11.default.dim("Server:")} ${r.server}`);
4168
- lines.push(`${import_chalk11.default.dim("Target DID:")} ${r.did}`);
4169
- if (!r.didDocument.found) {
4170
- lines.push(`${import_chalk11.default.dim("DID doc:")} ${import_chalk11.default.red("\u2717")} not found`);
4171
- } else {
4172
- const registered = r.didDocument.registeredAt ? ` (registered ${r.didDocument.registeredAt})` : "";
4173
- lines.push(`${import_chalk11.default.dim("DID doc:")} ${import_chalk11.default.green("\u2713")} resolved${registered}`);
4174
- }
4175
- if (r.activity) {
4176
- if (r.activity.lastEventAt === null) {
4177
- lines.push(`${import_chalk11.default.dim("Activity:")} ${import_chalk11.default.dim("(no events ever \u2014 fresh agent)")}`);
4178
- } else {
4179
- const ageMin = r.activity.ageSeconds !== null ? Math.floor(r.activity.ageSeconds / 60) : null;
4180
- const ageStr = ageMin !== null && ageMin > 0 ? `${ageMin}m ago` : `${r.activity.ageSeconds}s ago`;
4181
- lines.push(`${import_chalk11.default.dim("Activity:")} last event ${ageStr} (${r.activity.lastEventAt})`);
4182
- }
4183
- if (r.activity.lastSeenAt !== null && r.activity.lastSeenAt !== void 0) {
4184
- const seenMin = r.activity.seenAgeSeconds !== null && r.activity.seenAgeSeconds !== void 0 ? Math.floor(r.activity.seenAgeSeconds / 60) : null;
4185
- const seenStr = seenMin !== null && seenMin > 0 ? `${seenMin}m ago` : `${r.activity.seenAgeSeconds}s ago`;
4186
- lines.push(`${import_chalk11.default.dim("Last seen:")} signed request ${seenStr} (${r.activity.lastSeenAt})`);
4187
- }
4188
- if (r.activity.inboxStreamActive === true) {
4189
- lines.push(`${import_chalk11.default.dim("Inbox SSE:")} ${import_chalk11.default.green("\u2713")} active subscription on the central server`);
4190
- }
4191
- }
4192
- const verdictColor = r.verdict === "LISTENING" ? import_chalk11.default.green : r.verdict === "DORMANT" ? import_chalk11.default.red : import_chalk11.default.yellow;
4193
- lines.push("");
4194
- lines.push(`${import_chalk11.default.bold("Verdict:")} ${verdictColor(r.verdict)} \u2014 ${r.reason}`);
4195
- return lines.join("\n");
4196
- }
4197
-
4198
4240
  // src/commands/envelope.ts
4199
- var import_chalk12 = __toESM(require("chalk"));
4241
+ var import_chalk13 = __toESM(require("chalk"));
4200
4242
  init_api();
4201
4243
  function registerEnvelopeCommand(root) {
4202
4244
  root.command("envelope").description("Fetch one canonical envelope by eventId \u2014 full body for inspection (signed read)").argument("<event-id>", "Event UUID \u2014 copy from `heyarp inbox`, `heyarp events`, or a counterparty citation").option("--server <url>", "Override ARP server base URL").option("--from-did <did>", "Signer DID \u2014 required only if multiple agents are registered against this server").option("--from <name>", "Signer agent NAME (handle) \u2014 alternative to --from-did, resolved against your local agents").option("--json", "Machine-readable: emit only the envelope JSON object on stdout (no prelude, no chalk). Pipe-safe.", false).action(async (eventId, opts) => {
@@ -4207,9 +4249,9 @@ async function runEnvelope(eventId, opts) {
4207
4249
  const api = new ArpApiClient(opts.server);
4208
4250
  const sender = resolveSenderAgent("envelope", opts.server, opts.fromDid, opts.from);
4209
4251
  if (!opts.json) {
4210
- console.log(import_chalk12.default.dim(`Server: ${api.serverUrl}`));
4211
- console.log(import_chalk12.default.dim(`Signer: ${sender.did}`));
4212
- console.log(import_chalk12.default.dim(`Event: ${eventId}`));
4252
+ console.log(import_chalk13.default.dim(`Server: ${api.serverUrl}`));
4253
+ console.log(import_chalk13.default.dim(`Signer: ${sender.did}`));
4254
+ console.log(import_chalk13.default.dim(`Event: ${eventId}`));
4213
4255
  }
4214
4256
  const signer = makeSigner(sender);
4215
4257
  const event = await api.getEvent(sender.did, eventId, signer);
@@ -4218,24 +4260,24 @@ async function runEnvelope(eventId, opts) {
4218
4260
  return;
4219
4261
  }
4220
4262
  console.log("");
4221
- console.log(import_chalk12.default.bold("Envelope:"));
4263
+ console.log(import_chalk13.default.bold("Envelope:"));
4222
4264
  console.log(formatJson(event));
4223
4265
  console.log("");
4224
4266
  console.log(formatHints(event));
4225
4267
  }
4226
4268
  function formatHints(event) {
4227
4269
  const lines = [];
4228
- lines.push(`${import_chalk12.default.dim("relationshipId:")} ${import_chalk12.default.cyan(event.relationshipId)}`);
4229
- lines.push(`${import_chalk12.default.dim("serverEventHash:")} ${import_chalk12.default.cyan(event.serverEventHash)}`);
4230
- lines.push(`${import_chalk12.default.dim("eventId:")} ${import_chalk12.default.cyan(event.eventId)}`);
4231
- lines.push(`${import_chalk12.default.dim("relationshipEventIndex:")} ${import_chalk12.default.cyan(String(event.relationshipEventIndex))}`);
4270
+ lines.push(`${import_chalk13.default.dim("relationshipId:")} ${import_chalk13.default.cyan(event.relationshipId)}`);
4271
+ lines.push(`${import_chalk13.default.dim("serverEventHash:")} ${import_chalk13.default.cyan(event.serverEventHash)}`);
4272
+ lines.push(`${import_chalk13.default.dim("eventId:")} ${import_chalk13.default.cyan(event.eventId)}`);
4273
+ lines.push(`${import_chalk13.default.dim("relationshipEventIndex:")} ${import_chalk13.default.cyan(String(event.relationshipEventIndex))}`);
4232
4274
  return lines.join("\n");
4233
4275
  }
4234
4276
 
4235
4277
  // src/commands/escrow.ts
4236
4278
  var import_sdk17 = require("@heyanon-arp/sdk");
4237
4279
  var import_utils2 = require("@noble/hashes/utils");
4238
- var import_chalk13 = __toESM(require("chalk"));
4280
+ var import_chalk14 = __toESM(require("chalk"));
4239
4281
  init_api();
4240
4282
 
4241
4283
  // src/commands/escrow-actions.ts
@@ -4252,9 +4294,9 @@ async function setup(cmd, delegationIdArg, opts) {
4252
4294
  const rpcUrl = resolveRpcUrlStrict(opts, cmd);
4253
4295
  const conn = new import_web32.Connection(rpcUrl, "confirmed");
4254
4296
  const delegationId = normaliseDelegationId(delegationIdArg);
4255
- const fetched = await (0, import_sdk9.fetchLockAccount)(conn, programId, delegationId);
4297
+ const fetched = await (0, import_sdk10.fetchLockAccount)(conn, programId, delegationId);
4256
4298
  if (!fetched) {
4257
- const lockPda = (0, import_sdk9.deriveLockPda)(programId, (0, import_sdk16.deriveLockId)(delegationId)).toBase58();
4299
+ const lockPda = (0, import_sdk10.deriveLockPda)(programId, (0, import_sdk16.deriveLockId)(delegationId)).toBase58();
4258
4300
  throw new Error(
4259
4301
  `${cmd}: no on-chain Lock for delegation ${delegationId} (PDA ${lockPda} not found on ${rpcUrl}). Either the buyer hasn't funded yet (delegation fund \u2192 server relays create_lock), or you're pointing at the wrong cluster/program.`
4260
4302
  );
@@ -4346,7 +4388,7 @@ async function acceptHandler(delegationId, opts) {
4346
4388
  const stake = ctx.lock.workerStakeAtLock;
4347
4389
  await preflightLamports(ctx, stake, `the worker stake (${stake} lamports, returned when the lock settles in your favour)`);
4348
4390
  progress(ctx.opts.json, `accepting lock ${ctx.lock.lockId.slice(0, 16)}\u2026 \u2014 staking ${stake} lamports from ${ctx.keypair.publicKey.toBase58()}`);
4349
- const sig = await sendIx(ctx, (0, import_sdk9.buildAcceptLockIx)({ programId: ctx.programId, lockId: ctx.lockId, payee: ctx.keypair.publicKey }));
4391
+ const sig = await sendIx(ctx, (0, import_sdk10.buildAcceptLockIx)({ programId: ctx.programId, lockId: ctx.lockId, payee: ctx.keypair.publicKey }));
4350
4392
  emit(ctx, "accept", sig, { worker_stake: stake.toString() });
4351
4393
  }
4352
4394
  async function submitWorkHandler(delegationId, opts) {
@@ -4358,10 +4400,10 @@ async function submitWorkHandler(delegationId, opts) {
4358
4400
  `escrow submit-work: the work window expired at ${expiryIso(ctx)} \u2014 the chain will reject submit_work and the buyer can claim the escrow back (claim_expired_work). Nothing to salvage on-chain.`
4359
4401
  );
4360
4402
  }
4361
- const sig = await sendIx(ctx, (0, import_sdk9.buildSubmitWorkIx)({ programId: ctx.programId, lockId: ctx.lockId, payee: ctx.keypair.publicKey }));
4403
+ const sig = await sendIx(ctx, (0, import_sdk10.buildSubmitWorkIx)({ programId: ctx.programId, lockId: ctx.lockId, payee: ctx.keypair.publicKey }));
4362
4404
  let reviewDeadline = null;
4363
4405
  try {
4364
- const fresh = await (0, import_sdk9.fetchLockAccount)(ctx.conn, ctx.programId, ctx.delegationId);
4406
+ const fresh = await (0, import_sdk10.fetchLockAccount)(ctx.conn, ctx.programId, ctx.delegationId);
4365
4407
  if (fresh && fresh.lock.state === import_sdk16.LockStates.SUBMITTED && fresh.lock.expiry > 0n) {
4366
4408
  reviewDeadline = new Date(Number(fresh.lock.expiry) * 1e3).toISOString();
4367
4409
  }
@@ -4396,7 +4438,7 @@ async function claimHandler(delegationId, opts) {
4396
4438
  );
4397
4439
  const sig = await sendIx(
4398
4440
  ctx,
4399
- (0, import_sdk9.buildClaimWorkPaymentIx)({
4441
+ (0, import_sdk10.buildClaimWorkPaymentIx)({
4400
4442
  programId: ctx.programId,
4401
4443
  lockId: ctx.lockId,
4402
4444
  authority: ctx.keypair.publicKey,
@@ -4414,7 +4456,7 @@ async function cancelHandler(delegationId, opts) {
4414
4456
  requireSigner(ctx, "payer", ctx.lock.payer);
4415
4457
  const sig = await sendIx(
4416
4458
  ctx,
4417
- (0, import_sdk9.buildCancelLockIx)({
4459
+ (0, import_sdk10.buildCancelLockIx)({
4418
4460
  programId: ctx.programId,
4419
4461
  lockId: ctx.lockId,
4420
4462
  payer: ctx.keypair.publicKey,
@@ -4432,7 +4474,7 @@ async function claimExpiredHandler(delegationId, opts) {
4432
4474
  }
4433
4475
  const sig = await sendIx(
4434
4476
  ctx,
4435
- (0, import_sdk9.buildClaimExpiredWorkIx)({
4477
+ (0, import_sdk10.buildClaimExpiredWorkIx)({
4436
4478
  programId: ctx.programId,
4437
4479
  lockId: ctx.lockId,
4438
4480
  payer: ctx.keypair.publicKey,
@@ -4453,7 +4495,7 @@ async function disputeOpenHandler(delegationId, opts) {
4453
4495
  const stake = ctx.lock.workerStakeAtLock;
4454
4496
  await preflightLamports(ctx, stake, `the dispute stake (${stake} lamports \u2014 returned if the operator rules for you or the dispute times out)`);
4455
4497
  progress(ctx.opts.json, `opening dispute \u2014 staking ${stake} lamports; the operator has the dispute window to rule, after that either party can close`);
4456
- const sig = await sendIx(ctx, (0, import_sdk9.buildOpenDisputeIx)({ programId: ctx.programId, lockId: ctx.lockId, payer: ctx.keypair.publicKey }));
4498
+ const sig = await sendIx(ctx, (0, import_sdk10.buildOpenDisputeIx)({ programId: ctx.programId, lockId: ctx.lockId, payer: ctx.keypair.publicKey }));
4457
4499
  emit(ctx, "dispute-open", sig, { buyer_stake: stake.toString() });
4458
4500
  }
4459
4501
  async function disputeCloseHandler(delegationId, opts) {
@@ -4470,7 +4512,7 @@ async function disputeCloseHandler(delegationId, opts) {
4470
4512
  }
4471
4513
  const sig = await sendIx(
4472
4514
  ctx,
4473
- (0, import_sdk9.buildCloseDisputeIx)({
4515
+ (0, import_sdk10.buildCloseDisputeIx)({
4474
4516
  programId: ctx.programId,
4475
4517
  lockId: ctx.lockId,
4476
4518
  authority: ctx.keypair.publicKey,
@@ -4502,7 +4544,7 @@ async function disputeResolveHandler(delegationId, opts) {
4502
4544
  const disputeId = Uint8Array.from(Buffer.from(disputeUuid.replace(/-/g, ""), "hex"));
4503
4545
  const sig = await sendIx(
4504
4546
  ctx,
4505
- (0, import_sdk9.buildResolveDisputeIx)({
4547
+ (0, import_sdk10.buildResolveDisputeIx)({
4506
4548
  programId: ctx.programId,
4507
4549
  lockId: ctx.lockId,
4508
4550
  operator: ctx.keypair.publicKey,
@@ -4522,12 +4564,12 @@ async function showHandler(delegationId, opts) {
4522
4564
  const rpcUrl = resolveRpcUrlStrict(opts, "escrow show");
4523
4565
  const conn = new import_web32.Connection(rpcUrl, "confirmed");
4524
4566
  const normalised = normaliseDelegationId(delegationId);
4525
- const fetched = await (0, import_sdk9.fetchLockAccount)(conn, programId, normalised);
4567
+ const fetched = await (0, import_sdk10.fetchLockAccount)(conn, programId, normalised);
4526
4568
  if (!fetched) {
4527
4569
  jsonOut({
4528
4570
  delegation_id: normalised.slice("del_".length),
4529
4571
  lock_exists: false,
4530
- lock_pda: (0, import_sdk9.deriveLockPda)(programId, (0, import_sdk16.deriveLockId)(normalised)).toBase58(),
4572
+ lock_pda: (0, import_sdk10.deriveLockPda)(programId, (0, import_sdk16.deriveLockId)(normalised)).toBase58(),
4531
4573
  rpc_url: redactRpcUrl(rpcUrl)
4532
4574
  });
4533
4575
  return;
@@ -4648,7 +4690,7 @@ async function runEscrowInfo(opts) {
4648
4690
  const api = new ArpApiClient(opts.server);
4649
4691
  const status = await api.getEscrowConfig();
4650
4692
  if (opts.json) {
4651
- progress(true, import_chalk13.default.dim(`Server: ${api.serverUrl}`));
4693
+ progress(true, import_chalk14.default.dim(`Server: ${api.serverUrl}`));
4652
4694
  jsonOut(status);
4653
4695
  } else {
4654
4696
  console.log(formatEscrowConfigStatus(api.serverUrl, status));
@@ -4657,35 +4699,35 @@ async function runEscrowInfo(opts) {
4657
4699
  function formatEscrowConfigStatus(serverUrl, s) {
4658
4700
  const lines = [];
4659
4701
  const win = (secs) => secs % 3600 === 0 ? `${secs / 3600}h` : secs % 60 === 0 ? `${secs / 60}m` : `${secs}s`;
4660
- lines.push(`${import_chalk13.default.dim("Server:")} ${serverUrl}`);
4661
- lines.push(`${import_chalk13.default.dim("Program ID:")} ${s.programId}`);
4662
- lines.push(`${import_chalk13.default.dim("Admin:")} ${s.admin}`);
4663
- lines.push(`${import_chalk13.default.dim("Treasury:")} ${s.treasury}`);
4664
- lines.push(`${import_chalk13.default.dim("Paused:")} ${s.paused ? import_chalk13.default.yellow("YES (new locks rejected)") : import_chalk13.default.green("no")}`);
4702
+ lines.push(`${import_chalk14.default.dim("Server:")} ${serverUrl}`);
4703
+ lines.push(`${import_chalk14.default.dim("Program ID:")} ${s.programId}`);
4704
+ lines.push(`${import_chalk14.default.dim("Admin:")} ${s.admin}`);
4705
+ lines.push(`${import_chalk14.default.dim("Treasury:")} ${s.treasury}`);
4706
+ lines.push(`${import_chalk14.default.dim("Paused:")} ${s.paused ? import_chalk14.default.yellow("YES (new locks rejected)") : import_chalk14.default.green("no")}`);
4665
4707
  lines.push("");
4666
- lines.push(import_chalk13.default.bold("Windows (rolling deadlines):"));
4667
- lines.push(` ${import_chalk13.default.dim("work:")} ${win(s.workWindowSecs)} ${import_chalk13.default.dim("(accept \u2192 submit_work)")}`);
4668
- lines.push(` ${import_chalk13.default.dim("review:")} ${win(s.reviewWindowSecs)} ${import_chalk13.default.dim("(submit_work \u2192 buyer approve / worker self-claim)")}`);
4669
- lines.push(` ${import_chalk13.default.dim("dispute:")} ${win(s.disputeWindowSecs)} ${import_chalk13.default.dim("(open_dispute \u2192 operator resolve / timeout close)")}`);
4708
+ lines.push(import_chalk14.default.bold("Windows (rolling deadlines):"));
4709
+ lines.push(` ${import_chalk14.default.dim("work:")} ${win(s.workWindowSecs)} ${import_chalk14.default.dim("(accept \u2192 submit_work)")}`);
4710
+ lines.push(` ${import_chalk14.default.dim("review:")} ${win(s.reviewWindowSecs)} ${import_chalk14.default.dim("(submit_work \u2192 buyer approve / worker self-claim)")}`);
4711
+ lines.push(` ${import_chalk14.default.dim("dispute:")} ${win(s.disputeWindowSecs)} ${import_chalk14.default.dim("(open_dispute \u2192 operator resolve / timeout close)")}`);
4670
4712
  lines.push("");
4671
- lines.push(import_chalk13.default.bold("Stakes:"));
4672
- lines.push(` ${import_chalk13.default.dim("worker stake:")} ${s.workerStakeLamports} lamports ${import_chalk13.default.dim("(escrowed at accept_lock, returned on completion)")}`);
4673
- lines.push(` ${import_chalk13.default.dim("operator dispute fee:")} ${s.operatorDisputeFeeLamports} lamports`);
4713
+ lines.push(import_chalk14.default.bold("Stakes:"));
4714
+ lines.push(` ${import_chalk14.default.dim("worker stake:")} ${s.workerStakeLamports} lamports ${import_chalk14.default.dim("(escrowed at accept_lock, returned on completion)")}`);
4715
+ lines.push(` ${import_chalk14.default.dim("operator dispute fee:")} ${s.operatorDisputeFeeLamports} lamports`);
4674
4716
  lines.push("");
4675
- lines.push(import_chalk13.default.bold("Protocol fee:"));
4717
+ lines.push(import_chalk14.default.bold("Protocol fee:"));
4676
4718
  if (!s.feeEnabled || s.feeBps === 0) {
4677
- lines.push(` ${import_chalk13.default.green("DISABLED")}`);
4678
- lines.push(` ${import_chalk13.default.dim("fee_bps:")} ${s.feeBps}`);
4679
- lines.push(` ${import_chalk13.default.dim("fee_recipient:")} ${s.feeRecipient}`);
4719
+ lines.push(` ${import_chalk14.default.green("DISABLED")}`);
4720
+ lines.push(` ${import_chalk14.default.dim("fee_bps:")} ${s.feeBps}`);
4721
+ lines.push(` ${import_chalk14.default.dim("fee_recipient:")} ${s.feeRecipient}`);
4680
4722
  lines.push("");
4681
- lines.push(import_chalk13.default.dim(` New locks will snapshot fee_bps=0 \u2014 payee receives 100% on claim.`));
4723
+ lines.push(import_chalk14.default.dim(` New locks will snapshot fee_bps=0 \u2014 payee receives 100% on claim.`));
4682
4724
  } else {
4683
4725
  const pct = (s.feeBps / 100).toFixed(2);
4684
- lines.push(` ${import_chalk13.default.yellow("ENABLED")} \u2014 ${pct}% of payee slice (${s.feeBps} bps)`);
4685
- lines.push(` ${import_chalk13.default.dim("fee_recipient:")} ${s.feeRecipient}`);
4726
+ lines.push(` ${import_chalk14.default.yellow("ENABLED")} \u2014 ${pct}% of payee slice (${s.feeBps} bps)`);
4727
+ lines.push(` ${import_chalk14.default.dim("fee_recipient:")} ${s.feeRecipient}`);
4686
4728
  lines.push("");
4687
- lines.push(import_chalk13.default.dim(` New locks will snapshot fee_bps=${s.feeBps} onto themselves.`));
4688
- lines.push(import_chalk13.default.dim(` Existing locks keep their lock-time snapshot \u2014 no retroactive change.`));
4729
+ lines.push(import_chalk14.default.dim(` New locks will snapshot fee_bps=${s.feeBps} onto themselves.`));
4730
+ lines.push(import_chalk14.default.dim(` Existing locks keep their lock-time snapshot \u2014 no retroactive change.`));
4689
4731
  }
4690
4732
  return lines.join("\n");
4691
4733
  }
@@ -4710,8 +4752,8 @@ async function runDeriveConditionHash(opts) {
4710
4752
  }
4711
4753
  const api = new ArpApiClient(opts.server);
4712
4754
  const sender = resolveSenderAgent(cmdName, opts.server, opts.fromDid, opts.from);
4713
- progress(opts.json, import_chalk13.default.dim(`Server: ${api.serverUrl}`));
4714
- progress(opts.json, import_chalk13.default.dim(`Signer: ${sender.did}`));
4755
+ progress(opts.json, import_chalk14.default.dim(`Server: ${api.serverUrl}`));
4756
+ progress(opts.json, import_chalk14.default.dim(`Signer: ${sender.did}`));
4715
4757
  const subset = projectDelegationForHash(cmdName, opts, delegationId);
4716
4758
  const hashBytes = (0, import_sdk17.deriveDelegationConditionHash)(subset);
4717
4759
  const hex = (0, import_utils2.bytesToHex)(hashBytes);
@@ -4723,14 +4765,14 @@ async function runDeriveConditionHash(opts) {
4723
4765
  });
4724
4766
  return;
4725
4767
  }
4726
- console.log(import_chalk13.default.dim(`Delegation: ${delegationId}`));
4727
- console.log(import_chalk13.default.dim("Subset hashed:"));
4728
- console.log(import_chalk13.default.dim(` scopeSummary: ${subset.scopeSummary ?? "(unset)"}`));
4729
- if (subset.currency !== void 0) console.log(import_chalk13.default.dim(` currency.asset_id: ${subset.currency.asset_id}`));
4768
+ console.log(import_chalk14.default.dim(`Delegation: ${delegationId}`));
4769
+ console.log(import_chalk14.default.dim("Subset hashed:"));
4770
+ console.log(import_chalk14.default.dim(` scopeSummary: ${subset.scopeSummary ?? "(unset)"}`));
4771
+ if (subset.currency !== void 0) console.log(import_chalk14.default.dim(` currency.asset_id: ${subset.currency.asset_id}`));
4730
4772
  console.log("");
4731
- console.log(`${import_chalk13.default.bold("condition_hash:")} ${hex}`);
4773
+ console.log(`${import_chalk14.default.bold("condition_hash:")} ${hex}`);
4732
4774
  console.log("");
4733
- console.log(import_chalk13.default.dim(`Pass to: heyarp wallet create-lock --delegation-id ${delegationId} --condition-hash ${hex} ...`));
4775
+ console.log(import_chalk14.default.dim(`Pass to: heyarp wallet create-lock --delegation-id ${delegationId} --condition-hash ${hex} ...`));
4734
4776
  }
4735
4777
  function classifyRecoverOutcome(local, server) {
4736
4778
  if (local === server) return { kind: "in-sync", value: local };
@@ -4763,32 +4805,32 @@ async function runRecoverSequence(opts) {
4763
4805
  applied: opts.apply === true && outcome.kind === "behind"
4764
4806
  });
4765
4807
  } else {
4766
- console.log(import_chalk13.default.dim(`DID: ${sender.did}`));
4767
- console.log(import_chalk13.default.dim(`Server: ${api.serverUrl}`));
4808
+ console.log(import_chalk14.default.dim(`DID: ${sender.did}`));
4809
+ console.log(import_chalk14.default.dim(`Server: ${api.serverUrl}`));
4768
4810
  console.log("");
4769
- console.log(`${import_chalk13.default.bold("Local lastSenderSequence:")} ${local}`);
4770
- console.log(`${import_chalk13.default.bold("Server lastSenderSequence:")} ${server}`);
4811
+ console.log(`${import_chalk14.default.bold("Local lastSenderSequence:")} ${local}`);
4812
+ console.log(`${import_chalk14.default.bold("Server lastSenderSequence:")} ${server}`);
4771
4813
  console.log("");
4772
4814
  if (outcome.kind === "in-sync") {
4773
- console.log(import_chalk13.default.green("\u2713 In sync \u2014 no recovery needed."));
4815
+ console.log(import_chalk14.default.green("\u2713 In sync \u2014 no recovery needed."));
4774
4816
  } else if (outcome.kind === "behind") {
4775
- console.log(import_chalk13.default.yellow(`\u26A0 Local is BEHIND by ${outcome.drift}. Server has accepted envelopes the CLI didn't classify as post-commit.`));
4817
+ console.log(import_chalk14.default.yellow(`\u26A0 Local is BEHIND by ${outcome.drift}. Server has accepted envelopes the CLI didn't classify as post-commit.`));
4776
4818
  if (opts.apply) {
4777
- console.log(import_chalk13.default.dim("Writing server value to local state..."));
4819
+ console.log(import_chalk14.default.dim("Writing server value to local state..."));
4778
4820
  } else {
4779
- console.log(import_chalk13.default.dim("Dry-run. Pass --apply to update local state to match server."));
4821
+ console.log(import_chalk14.default.dim("Dry-run. Pass --apply to update local state to match server."));
4780
4822
  }
4781
4823
  } else {
4782
- console.log(import_chalk13.default.red(`\u2717 Local is AHEAD of server by ${outcome.drift}. This should not happen under normal protocol flow.`));
4783
- console.log(import_chalk13.default.dim("NOT applying \u2014 manual investigation needed. Possible causes:"));
4784
- console.log(import_chalk13.default.dim(" - Local agents.json edited by hand to a wrong value"));
4785
- console.log(import_chalk13.default.dim(" - Server data lost / rolled back"));
4786
- console.log(import_chalk13.default.dim(" - HEYARP_HOME pointed at a wrong account"));
4824
+ console.log(import_chalk14.default.red(`\u2717 Local is AHEAD of server by ${outcome.drift}. This should not happen under normal protocol flow.`));
4825
+ console.log(import_chalk14.default.dim("NOT applying \u2014 manual investigation needed. Possible causes:"));
4826
+ console.log(import_chalk14.default.dim(" - Local agents.json edited by hand to a wrong value"));
4827
+ console.log(import_chalk14.default.dim(" - Server data lost / rolled back"));
4828
+ console.log(import_chalk14.default.dim(" - HEYARP_HOME pointed at a wrong account"));
4787
4829
  }
4788
4830
  }
4789
4831
  if (outcome.kind === "behind" && opts.apply) {
4790
4832
  updateAgentLocal(opts.server, sender.did, { lastSenderSequence: outcome.server });
4791
- if (!opts.json) console.log(import_chalk13.default.green(`\u2713 Local lastSenderSequence updated: ${local} \u2192 ${outcome.server}`));
4833
+ if (!opts.json) console.log(import_chalk14.default.green(`\u2713 Local lastSenderSequence updated: ${local} \u2192 ${outcome.server}`));
4792
4834
  }
4793
4835
  if (outcome.kind === "behind" && !opts.apply) process.exitCode = 1;
4794
4836
  if (outcome.kind === "ahead") process.exitCode = 2;
@@ -4796,7 +4838,7 @@ async function runRecoverSequence(opts) {
4796
4838
 
4797
4839
  // src/commands/events.ts
4798
4840
  var import_sdk18 = require("@heyanon-arp/sdk");
4799
- var import_chalk14 = __toESM(require("chalk"));
4841
+ var import_chalk15 = __toESM(require("chalk"));
4800
4842
  init_api();
4801
4843
  function registerEventsCommand(root) {
4802
4844
  root.command("events").description("List events for a relationship (chain order, ascending index)").argument("<relationship-id>", "Relationship UUID").option("--server <url>", "Override ARP server base URL").option("--since <n>", "Cursor: only events with relationshipEventIndex >= since").option("--limit <n>", "Max events to return (1..100)", "20").option("--from-did <did>", "Signer DID \u2014 required only if multiple agents are registered against this server").option("--from <name>", "Signer agent NAME (handle) \u2014 alternative to --from-did, resolved against your local agents").option(
@@ -4840,9 +4882,9 @@ async function runEvents(relationshipId, opts) {
4840
4882
  const api = new ArpApiClient(opts.server);
4841
4883
  const sender = resolveSenderAgent("events", opts.server, opts.fromDid, opts.from);
4842
4884
  if (!opts.json) {
4843
- console.log(import_chalk14.default.dim(`Server: ${api.serverUrl}`));
4844
- console.log(import_chalk14.default.dim(`Signer: ${sender.did}`));
4845
- console.log(import_chalk14.default.dim(`Relationship: ${relationshipId}`));
4885
+ console.log(import_chalk15.default.dim(`Server: ${api.serverUrl}`));
4886
+ console.log(import_chalk15.default.dim(`Signer: ${sender.did}`));
4887
+ console.log(import_chalk15.default.dim(`Relationship: ${relationshipId}`));
4846
4888
  }
4847
4889
  const query = { limit };
4848
4890
  if (since !== void 0) query.since = since;
@@ -4855,7 +4897,7 @@ async function runEvents(relationshipId, opts) {
4855
4897
  return;
4856
4898
  }
4857
4899
  if (events.length === 0) {
4858
- console.log(import_chalk14.default.dim("\n(no events for this relationship)"));
4900
+ console.log(import_chalk15.default.dim("\n(no events for this relationship)"));
4859
4901
  return;
4860
4902
  }
4861
4903
  console.log("");
@@ -4871,20 +4913,20 @@ async function runEvents(relationshipId, opts) {
4871
4913
  }));
4872
4914
  }
4873
4915
  const lastIndex = events[events.length - 1].relationshipEventIndex;
4874
- console.log(import_chalk14.default.dim(`
4916
+ console.log(import_chalk15.default.dim(`
4875
4917
  ${events.length} event(s). Paginate with --since ${lastIndex + 1}.`));
4876
4918
  }
4877
4919
  function formatEventLine(ev, selfDid, opts = {}) {
4878
- const idx = import_chalk14.default.bold(`#${ev.relationshipEventIndex}`);
4920
+ const idx = import_chalk15.default.bold(`#${ev.relationshipEventIndex}`);
4879
4921
  const eventId = opts.fullIds ? ev.eventId : eventIdHead(ev.eventId);
4880
4922
  const type = ev.type.padEnd(20);
4881
4923
  const direction = directionLabel(ev, selfDid, opts);
4882
4924
  const hash = opts.fullIds ? ev.serverEventHash : hashHead(ev.serverEventHash);
4883
4925
  const extra = extraDetail(ev);
4884
- const tail = extra ? ` ${import_chalk14.default.dim(`(${extra})`)}` : "";
4926
+ const tail = extra ? ` ${import_chalk15.default.dim(`(${extra})`)}` : "";
4885
4927
  const status = ev.readModelStatus ?? import_sdk18.ReadModelStatuses.MATERIALIZED;
4886
- const statusGlyph = status === import_sdk18.ReadModelStatuses.REJECTED ? `${import_chalk14.default.red("\u2717")} ` : " ";
4887
- return `${statusGlyph}${idx} ${import_chalk14.default.cyan(eventId)} ${type} ${direction} ${import_chalk14.default.cyan(hash)}${tail}`;
4928
+ const statusGlyph = status === import_sdk18.ReadModelStatuses.REJECTED ? `${import_chalk15.default.red("\u2717")} ` : " ";
4929
+ return `${statusGlyph}${idx} ${import_chalk15.default.cyan(eventId)} ${type} ${direction} ${import_chalk15.default.cyan(hash)}${tail}`;
4888
4930
  }
4889
4931
  function eventIdHead(eventId) {
4890
4932
  if (eventId.length <= 20) return eventId;
@@ -4893,9 +4935,9 @@ function eventIdHead(eventId) {
4893
4935
  function directionLabel(ev, selfDid, opts = {}) {
4894
4936
  const senderHead = opts.fullIds ? ev.senderDid : didHead2(ev.senderDid);
4895
4937
  const recipientHead = opts.fullIds ? ev.recipientDid : didHead2(ev.recipientDid);
4896
- if (ev.senderDid === selfDid) return `${import_chalk14.default.bold("me")} \u2192 ${import_chalk14.default.dim(recipientHead)}`;
4897
- if (ev.recipientDid === selfDid) return `${import_chalk14.default.dim(senderHead)} \u2192 ${import_chalk14.default.bold("me")}`;
4898
- return `${import_chalk14.default.dim(senderHead)} \u2192 ${import_chalk14.default.dim(recipientHead)}`;
4938
+ if (ev.senderDid === selfDid) return `${import_chalk15.default.bold("me")} \u2192 ${import_chalk15.default.dim(recipientHead)}`;
4939
+ if (ev.recipientDid === selfDid) return `${import_chalk15.default.dim(senderHead)} \u2192 ${import_chalk15.default.bold("me")}`;
4940
+ return `${import_chalk15.default.dim(senderHead)} \u2192 ${import_chalk15.default.dim(recipientHead)}`;
4899
4941
  }
4900
4942
  function extraDetail(ev) {
4901
4943
  if (ev.type === "handshake_response") {
@@ -4932,7 +4974,7 @@ function parseSince(raw) {
4932
4974
  }
4933
4975
 
4934
4976
  // src/commands/guide.ts
4935
- var import_chalk15 = __toESM(require("chalk"));
4977
+ var import_chalk16 = __toESM(require("chalk"));
4936
4978
 
4937
4979
  // src/guide/source.ts
4938
4980
  var GUIDE_TITLE = "HeyARP CLI \u2014 agent guide";
@@ -5161,7 +5203,7 @@ var GUIDE_SECTIONS = [
5161
5203
  "Do NOT propose the receipt \u2014 the worker proposes; YOUR approval is the on-chain `escrow claim`, not any envelope.",
5162
5204
  "Do NOT fund (`delegation fund`) before the worker has ACCEPTED \u2014 the server rejects a fund against a non-accepted delegation. Offer first, wait for accept, THEN fund.",
5163
5205
  "Do NOT let the offer terms drift from the condition_hash \u2014 at fund time hash the SAME scope/pricing/currency you put in the offer, or the lock is rejected (ESC_LOCK_CONDITION_HASH_MISMATCH).",
5164
- "Do NOT treat a discovery row as ONLINE just because it is listed \u2014 `heyarp agents --online` / the per-row online dot is a coarse durable-liveness hint (recent signed request); probe the definitive instant state with `heyarp doctor <did>`.",
5206
+ "`heyarp agents` lists ONLINE agents by default (durable ~5-min liveness: a recent signed request); pass `--all` to include offline ones. That online flag is COARSER than instant reachability \u2014 `send-handshake` / `delegation offer` auto-probe the recipient and WARN if it looks idle (the envelope still lands in their inbox); add `--require-online` to abort (CLI_RECIPIENT_OFFLINE) instead. For the definitive instant state, `heyarp doctor <did>`.",
5165
5207
  "On DELEGATION_PRICING_MISMATCH read `details` ({reason, accepted, offered}), fix that ONE term and re-offer \u2014 do NOT retry the identical offer (same result, burns a sequence each time).",
5166
5208
  "DELEGATION_CAPACITY_EXCEEDED is the OPPOSITE: your terms are fine, the worker is just full (or closed with max-active 0). Retry the SAME offer later or pick another worker \u2014 do NOT change terms."
5167
5209
  ],
@@ -5290,7 +5332,8 @@ var GUIDE_SECTIONS = [
5290
5332
  " --accepts <asset> only agents that take this asset (shorthand",
5291
5333
  " SOL:solana-devnet or CAIP-19; accept-anything",
5292
5334
  " agents match too) \u2014 pre-filter deal compatibility",
5293
- " --online only agents seen within the liveness window",
5335
+ " (online-only by default \u2014 seen within the liveness window)",
5336
+ " --all include OFFLINE agents too (default hides them)",
5294
5337
  " Sort: `--sort reputation` (default, composite desc) | `recent` |",
5295
5338
  " `created` (oldest-first, stable `--after <id>` cursor for full",
5296
5339
  " enumeration); reputation/recent paginate by `--page N`.",
@@ -5367,11 +5410,13 @@ var GUIDE_SECTIONS = [
5367
5410
  roles: ["buyer"],
5368
5411
  title: "Listed vs live worker + autonomous worker latency",
5369
5412
  body: [
5370
- " `heyarp agents` rows are LISTED (registered + discoverable). The online",
5371
- " dot / `--online` filter is durable-liveness (a recent signed request) \u2014",
5372
- " a coarse hint, NOT a guarantee the worker is processing right now.",
5373
- " Probe the definitive state with `heyarp doctor <did>` (LISTENING /",
5374
- " DORMANT / UNKNOWN).",
5413
+ " `heyarp agents` rows are LISTED (registered + discoverable) and, by",
5414
+ " default, ONLINE \u2014 but that online dot is durable-liveness (a recent",
5415
+ " signed request), a coarse hint, NOT a guarantee the worker is",
5416
+ " processing right now. `delegation offer` / `send-handshake` auto-probe",
5417
+ " the recipient and warn (or, with `--require-online`, abort) if idle.",
5418
+ " Probe the definitive state yourself with `heyarp doctor <did>`",
5419
+ " (LISTENING / DORMANT / UNKNOWN).",
5375
5420
  " Autonomous LLM workers respond in 30s\u20138min typically; treat silence",
5376
5421
  ' > 15min as "try someone else". Parse inbox events as JSON:',
5377
5422
  " heyarp inbox --json | jq '.[0].body.content.delegation_id' # paginated",
@@ -5573,7 +5618,7 @@ function renderCommand(c) {
5573
5618
  ${c.description}`;
5574
5619
  }
5575
5620
  function renderSection(s) {
5576
- const lines = [import_chalk15.default.bold(s.title)];
5621
+ const lines = [import_chalk16.default.bold(s.title)];
5577
5622
  if (s.body && s.body.length > 0) lines.push(...s.body);
5578
5623
  if (s.nextActions && s.nextActions.length > 0) {
5579
5624
  lines.push(" Commands:");
@@ -5600,21 +5645,21 @@ function modeHeader(mode) {
5600
5645
  ""
5601
5646
  ];
5602
5647
  case "role":
5603
- return [import_chalk15.default.dim(`(${mode.role} guide \u2014 your slice only; run \`heyarp guide\` for the overview)`), ""];
5648
+ return [import_chalk16.default.dim(`(${mode.role} guide \u2014 your slice only; run \`heyarp guide\` for the overview)`), ""];
5604
5649
  case "setup":
5605
- return [import_chalk15.default.dim("(setup \u2014 role-agnostic; run `heyarp guide` for the overview)"), ""];
5650
+ return [import_chalk16.default.dim("(setup \u2014 role-agnostic; run `heyarp guide` for the overview)"), ""];
5606
5651
  case "troubleshoot":
5607
- return [import_chalk15.default.dim("(troubleshooting \u2014 role-agnostic)"), ""];
5652
+ return [import_chalk16.default.dim("(troubleshooting \u2014 role-agnostic)"), ""];
5608
5653
  }
5609
5654
  }
5610
5655
  function modeFooter(mode) {
5611
5656
  if (mode.kind === "overview") {
5612
- return ["", import_chalk15.default.dim("Full reference per role: `heyarp guide --role worker|buyer`. Docs: https://www.npmjs.com/package/@heyanon-arp/cli")];
5657
+ return ["", import_chalk16.default.dim("Full reference per role: `heyarp guide --role worker|buyer`. Docs: https://www.npmjs.com/package/@heyanon-arp/cli")];
5613
5658
  }
5614
5659
  return [];
5615
5660
  }
5616
5661
  function renderGuide(mode = { kind: "overview" }) {
5617
- const blocks = [import_chalk15.default.bold(GUIDE_TITLE), "", ...modeHeader(mode)];
5662
+ const blocks = [import_chalk16.default.bold(GUIDE_TITLE), "", ...modeHeader(mode)];
5618
5663
  for (const s of selectSections(mode)) {
5619
5664
  blocks.push(renderSection(s), "");
5620
5665
  }
@@ -5664,7 +5709,7 @@ function renderPrompt(mode, opts = { concise: false }) {
5664
5709
  // src/commands/homes.ts
5665
5710
  var import_node_fs6 = require("fs");
5666
5711
  var import_node_path6 = require("path");
5667
- var import_chalk16 = __toESM(require("chalk"));
5712
+ var import_chalk17 = __toESM(require("chalk"));
5668
5713
  var import_prompts = __toESM(require("prompts"));
5669
5714
 
5670
5715
  // src/homes.ts
@@ -5758,27 +5803,27 @@ function runHomes(opts) {
5758
5803
  return;
5759
5804
  }
5760
5805
  if (rows.length === 0) {
5761
- console.log(import_chalk16.default.dim("(no HEYARP_HOME directories registered yet \u2014 run `heyarp register` once and the registry populates itself)"));
5762
- console.log(import_chalk16.default.dim(` registry path: ${homesRegistryPath()}`));
5806
+ console.log(import_chalk17.default.dim("(no HEYARP_HOME directories registered yet \u2014 run `heyarp register` once and the registry populates itself)"));
5807
+ console.log(import_chalk17.default.dim(` registry path: ${homesRegistryPath()}`));
5763
5808
  return;
5764
5809
  }
5765
5810
  const header = ["Path", "Agents", "Last seen", "Status"];
5766
5811
  const data = rows.map((r) => [
5767
- r.path + (r.isCurrent ? import_chalk16.default.green(" (current)") : ""),
5812
+ r.path + (r.isCurrent ? import_chalk17.default.green(" (current)") : ""),
5768
5813
  String(r.agentCount),
5769
5814
  formatRelativeTime(r.lastSeenAt),
5770
- r.exists ? import_chalk16.default.green("ok") : import_chalk16.default.red("missing")
5815
+ r.exists ? import_chalk17.default.green("ok") : import_chalk17.default.red("missing")
5771
5816
  ]);
5772
5817
  console.log("");
5773
5818
  console.log(formatTable(header, data));
5774
- console.log(import_chalk16.default.dim(`
5819
+ console.log(import_chalk17.default.dim(`
5775
5820
  Registry path: ${homesRegistryPath()}`));
5776
- console.log(import_chalk16.default.dim(`Set HEYARP_HOME=<path> in a shell to switch between homes; run \`heyarp homes forget <path>\` to drop a stale entry.`));
5821
+ console.log(import_chalk17.default.dim(`Set HEYARP_HOME=<path> in a shell to switch between homes; run \`heyarp homes forget <path>\` to drop a stale entry.`));
5777
5822
  }
5778
5823
  async function runForget(path, opts) {
5779
5824
  if (!opts.yes) {
5780
- console.log(import_chalk16.default.yellow(`About to remove '${path}' from the homes registry.`));
5781
- console.log(import_chalk16.default.dim(" Note: this only forgets the registry entry; the directory + its agents.json are NOT touched."));
5825
+ console.log(import_chalk17.default.yellow(`About to remove '${path}' from the homes registry.`));
5826
+ console.log(import_chalk17.default.dim(" Note: this only forgets the registry entry; the directory + its agents.json are NOT touched."));
5782
5827
  const answer = await (0, import_prompts.default)(
5783
5828
  {
5784
5829
  type: "confirm",
@@ -5788,21 +5833,21 @@ async function runForget(path, opts) {
5788
5833
  },
5789
5834
  {
5790
5835
  onCancel: () => {
5791
- console.log(import_chalk16.default.yellow("Aborted."));
5836
+ console.log(import_chalk17.default.yellow("Aborted."));
5792
5837
  process.exit(130);
5793
5838
  }
5794
5839
  }
5795
5840
  );
5796
5841
  if (!answer.confirm) {
5797
- console.log(import_chalk16.default.dim("Aborted (no changes)."));
5842
+ console.log(import_chalk17.default.dim("Aborted (no changes)."));
5798
5843
  return;
5799
5844
  }
5800
5845
  }
5801
5846
  const removed = forgetHome(path);
5802
5847
  if (removed) {
5803
- console.log(import_chalk16.default.green(`\u2713 forgot ${path}`));
5848
+ console.log(import_chalk17.default.green(`\u2713 forgot ${path}`));
5804
5849
  } else {
5805
- console.log(import_chalk16.default.dim(`(no entry for ${path} in the registry \u2014 already absent)`));
5850
+ console.log(import_chalk17.default.dim(`(no entry for ${path} in the registry \u2014 already absent)`));
5806
5851
  }
5807
5852
  }
5808
5853
  function countAgents(homePath) {
@@ -5827,13 +5872,13 @@ function formatTable(header, data) {
5827
5872
  const padding = " ".repeat(Math.max(0, widths[i] - lengths[i]));
5828
5873
  return cell + padding;
5829
5874
  }).join(" ");
5830
- const headerLine = import_chalk16.default.bold(
5875
+ const headerLine = import_chalk17.default.bold(
5831
5876
  pad(
5832
5877
  header,
5833
5878
  header.map((s) => s.length)
5834
5879
  )
5835
5880
  );
5836
- const sepLine = import_chalk16.default.dim(
5881
+ const sepLine = import_chalk17.default.dim(
5837
5882
  pad(
5838
5883
  widths.map((w) => "-".repeat(w)),
5839
5884
  widths
@@ -5860,7 +5905,7 @@ function formatRelativeTime(iso) {
5860
5905
  }
5861
5906
 
5862
5907
  // src/commands/inbox.ts
5863
- var import_chalk17 = __toESM(require("chalk"));
5908
+ var import_chalk18 = __toESM(require("chalk"));
5864
5909
  init_api();
5865
5910
  function formatTailStartedPing(input) {
5866
5911
  const ping = {
@@ -5907,8 +5952,8 @@ async function runInbox(positionalDid, opts) {
5907
5952
  }
5908
5953
  const api = new ArpApiClient(opts.server);
5909
5954
  if (!opts.json) {
5910
- console.log(import_chalk17.default.dim(`Server: ${api.serverUrl}`));
5911
- console.log(import_chalk17.default.dim(`Signer: ${local.did}`));
5955
+ console.log(import_chalk18.default.dim(`Server: ${api.serverUrl}`));
5956
+ console.log(import_chalk18.default.dim(`Signer: ${local.did}`));
5912
5957
  }
5913
5958
  const query = { limit };
5914
5959
  if (opts.before) query.before = opts.before;
@@ -5922,7 +5967,7 @@ async function runInbox(positionalDid, opts) {
5922
5967
  return;
5923
5968
  }
5924
5969
  if (events.length === 0) {
5925
- console.log(import_chalk17.default.dim("\n(no events addressed to me \u2014 `heyarp events <relationship-id>` shows the chain-wide listing)"));
5970
+ console.log(import_chalk18.default.dim("\n(no events addressed to me \u2014 `heyarp events <relationship-id>` shows the chain-wide listing)"));
5926
5971
  return;
5927
5972
  }
5928
5973
  console.log("");
@@ -5937,16 +5982,16 @@ async function runInbox(positionalDid, opts) {
5937
5982
  secondary: `eventId=${ev.eventId} serverEventHash=${ev.serverEventHash}`
5938
5983
  }));
5939
5984
  }
5940
- const addressedToMeHint = import_chalk17.default.dim(" (envelopes addressed to me \u2014 for the full chain see `heyarp events <relationship-id>`)");
5985
+ const addressedToMeHint = import_chalk18.default.dim(" (envelopes addressed to me \u2014 for the full chain see `heyarp events <relationship-id>`)");
5941
5986
  if (opts.since && !opts.before) {
5942
5987
  console.log(
5943
- import_chalk17.default.dim(
5988
+ import_chalk18.default.dim(
5944
5989
  `
5945
5990
  ${events.length} event(s) (oldest-first).${addressedToMeHint} Advance the forward cursor with --since <serverTimestamp> --since-event-id <eventId> using the LAST row above.`
5946
5991
  )
5947
5992
  );
5948
5993
  } else {
5949
- console.log(import_chalk17.default.dim(`
5994
+ console.log(import_chalk18.default.dim(`
5950
5995
  ${events.length} event(s).${addressedToMeHint} Paginate with --before <serverTimestamp> --before-event-id <eventId> using the LAST row above.`));
5951
5996
  }
5952
5997
  }
@@ -5961,7 +6006,7 @@ async function runInboxTail(did, local, opts) {
5961
6006
  } else {
5962
6007
  warn(
5963
6008
  opts.json,
5964
- import_chalk17.default.yellow(
6009
+ import_chalk18.default.yellow(
5965
6010
  "\u26A0 inbox --tail: stdout is piped but `process.stdout._handle.setBlocking` is unavailable in this Node runtime. Buffered writes may delay event delivery. Fall back to polling (`heyarp inbox --json`) if events stop arriving."
5966
6011
  )
5967
6012
  );
@@ -5971,9 +6016,9 @@ async function runInboxTail(did, local, opts) {
5971
6016
  if (opts.json) {
5972
6017
  console.log(formatTailStartedPing({ server: api.serverUrl, signer: local.did, stdoutBlockingApplied }));
5973
6018
  } else {
5974
- console.log(import_chalk17.default.dim(`Server: ${api.serverUrl}`));
5975
- console.log(import_chalk17.default.dim(`Signer: ${local.did}`));
5976
- console.log(import_chalk17.default.dim("Mode: --tail (live SSE, Ctrl-C to stop)"));
6019
+ console.log(import_chalk18.default.dim(`Server: ${api.serverUrl}`));
6020
+ console.log(import_chalk18.default.dim(`Signer: ${local.did}`));
6021
+ console.log(import_chalk18.default.dim("Mode: --tail (live SSE, Ctrl-C to stop)"));
5977
6022
  }
5978
6023
  const controller = new AbortController();
5979
6024
  let userAborted = false;
@@ -5992,7 +6037,7 @@ async function runInboxTail(did, local, opts) {
5992
6037
  }
5993
6038
  if (event.type === "heartbeat") continue;
5994
6039
  if (event.type === "connected") {
5995
- console.log(import_chalk17.default.green("\u25CF stream open \u2014 listening for envelopes..."));
6040
+ console.log(import_chalk18.default.green("\u25CF stream open \u2014 listening for envelopes..."));
5996
6041
  continue;
5997
6042
  }
5998
6043
  if (event.type === "envelope") {
@@ -6006,7 +6051,7 @@ async function runInboxTail(did, local, opts) {
6006
6051
  }
6007
6052
  continue;
6008
6053
  }
6009
- console.log(import_chalk17.default.dim(`(unknown event: ${event.type})`));
6054
+ console.log(import_chalk18.default.dim(`(unknown event: ${event.type})`));
6010
6055
  }
6011
6056
  if (!userAborted) {
6012
6057
  throw new Error("inbox --tail: stream ended unexpectedly (server may have restarted, or change stream errored). Re-run to reconnect.");
@@ -6014,7 +6059,7 @@ async function runInboxTail(did, local, opts) {
6014
6059
  } catch (err) {
6015
6060
  const name = err.name;
6016
6061
  if (name === "AbortError" || userAborted) {
6017
- if (!opts.json) console.log(import_chalk17.default.dim("\nstream closed."));
6062
+ if (!opts.json) console.log(import_chalk18.default.dim("\nstream closed."));
6018
6063
  return;
6019
6064
  }
6020
6065
  throw err;
@@ -6034,15 +6079,15 @@ function formatInboxTable(events, opts = {}) {
6034
6079
  ]);
6035
6080
  const widths = header.map((h, i) => Math.max(h.length, ...data.map((row) => row[i].length)));
6036
6081
  const pad = (cells) => cells.map((c, i) => c.padEnd(widths[i])).join(" ");
6037
- const lines = [import_chalk17.default.bold(pad(header)), import_chalk17.default.dim(pad(widths.map((w) => "-".repeat(w)))), ...data.map((row) => pad(row))];
6038
- const detail = events.map((ev) => ` ${import_chalk17.default.dim("eventId:")} ${import_chalk17.default.cyan(ev.eventId)} ${import_chalk17.default.dim("serverTimestamp:")} ${import_chalk17.default.cyan(ev.serverTimestamp)}`).join("\n");
6082
+ const lines = [import_chalk18.default.bold(pad(header)), import_chalk18.default.dim(pad(widths.map((w) => "-".repeat(w)))), ...data.map((row) => pad(row))];
6083
+ const detail = events.map((ev) => ` ${import_chalk18.default.dim("eventId:")} ${import_chalk18.default.cyan(ev.eventId)} ${import_chalk18.default.dim("serverTimestamp:")} ${import_chalk18.default.cyan(ev.serverTimestamp)}`).join("\n");
6039
6084
  return `${lines.join("\n")}
6040
6085
 
6041
- ${import_chalk17.default.bold("Pagination cursors")} (last \u2192 first):
6086
+ ${import_chalk18.default.bold("Pagination cursors")} (last \u2192 first):
6042
6087
  ${detail}`;
6043
6088
  }
6044
6089
  function hashHead2(hash) {
6045
- if (!hash) return import_chalk17.default.dim("(none)");
6090
+ if (!hash) return import_chalk18.default.dim("(none)");
6046
6091
  if (hash.length <= 14) return hash;
6047
6092
  return `${hash.slice(0, 14)}...`;
6048
6093
  }
@@ -6059,7 +6104,7 @@ function parseLimit4(raw) {
6059
6104
  var import_node_crypto2 = require("crypto");
6060
6105
  var import_node_fs7 = require("fs");
6061
6106
  var import_sdk19 = require("@heyanon-arp/sdk");
6062
- var import_chalk18 = __toESM(require("chalk"));
6107
+ var import_chalk19 = __toESM(require("chalk"));
6063
6108
  function writeSecretFile(path, body) {
6064
6109
  const tmp = `${path}.tmp.${(0, import_node_crypto2.randomBytes)(8).toString("hex")}`;
6065
6110
  const fd = (0, import_node_fs7.openSync)(tmp, "wx", 384);
@@ -6089,16 +6134,16 @@ function registerKeysCommand(root) {
6089
6134
  const identity = (0, import_sdk19.generateKeyPair)();
6090
6135
  const settlement = (0, import_sdk19.generateKeyPair)();
6091
6136
  const out = [
6092
- import_chalk18.default.bold("Identity key (Ed25519)"),
6093
- ` public (base58btc): ${import_chalk18.default.cyan((0, import_sdk19.base58btcEncode)(identity.publicKey))}`,
6094
- ` secret (base64) : ${import_chalk18.default.yellow(Buffer.from(identity.secretKey).toString("base64"))}`,
6137
+ import_chalk19.default.bold("Identity key (Ed25519)"),
6138
+ ` public (base58btc): ${import_chalk19.default.cyan((0, import_sdk19.base58btcEncode)(identity.publicKey))}`,
6139
+ ` secret (base64) : ${import_chalk19.default.yellow(Buffer.from(identity.secretKey).toString("base64"))}`,
6095
6140
  "",
6096
- import_chalk18.default.bold("Settlement key (Ed25519)"),
6097
- ` public (base58btc): ${import_chalk18.default.cyan((0, import_sdk19.base58btcEncode)(settlement.publicKey))}`,
6098
- ` secret (base64) : ${import_chalk18.default.yellow(Buffer.from(settlement.secretKey).toString("base64"))}`,
6141
+ import_chalk19.default.bold("Settlement key (Ed25519)"),
6142
+ ` public (base58btc): ${import_chalk19.default.cyan((0, import_sdk19.base58btcEncode)(settlement.publicKey))}`,
6143
+ ` secret (base64) : ${import_chalk19.default.yellow(Buffer.from(settlement.secretKey).toString("base64"))}`,
6099
6144
  "",
6100
- import_chalk18.default.bold("Resulting DID"),
6101
- ` ${import_chalk18.default.cyan((0, import_sdk19.formatDid)(identity.publicKey))}`
6145
+ import_chalk19.default.bold("Resulting DID"),
6146
+ ` ${import_chalk19.default.cyan((0, import_sdk19.formatDid)(identity.publicKey))}`
6102
6147
  ];
6103
6148
  console.log(out.join("\n"));
6104
6149
  });
@@ -6107,11 +6152,11 @@ function registerKeysCommand(root) {
6107
6152
  const json = JSON.stringify(toKeyBundle(agent, (/* @__PURE__ */ new Date()).toISOString()), null, 2);
6108
6153
  if (opts.out) {
6109
6154
  writeSecretFile(opts.out, json);
6110
- process.stderr.write(import_chalk18.default.yellow(`\u26A0 wrote SECRET key bundle to ${opts.out} (mode 0600) \u2014 keep it offline; anyone with this file can operate ${did}.
6155
+ process.stderr.write(import_chalk19.default.yellow(`\u26A0 wrote SECRET key bundle to ${opts.out} (mode 0600) \u2014 keep it offline; anyone with this file can operate ${did}.
6111
6156
  `));
6112
6157
  console.log(opts.out);
6113
6158
  } else {
6114
- process.stderr.write(import_chalk18.default.yellow("\u26A0 this is a SECRET key bundle \u2014 redirect to a file and keep it offline.\n"));
6159
+ process.stderr.write(import_chalk19.default.yellow("\u26A0 this is a SECRET key bundle \u2014 redirect to a file and keep it offline.\n"));
6115
6160
  console.log(json);
6116
6161
  }
6117
6162
  });
@@ -6119,8 +6164,8 @@ function registerKeysCommand(root) {
6119
6164
  const seed = decodeSeed(secretKeyB64);
6120
6165
  const pub = (0, import_sdk19.getPublicKey)(seed);
6121
6166
  const did = (0, import_sdk19.formatDid)(pub);
6122
- console.log(`${import_chalk18.default.bold("DID")}: ${import_chalk18.default.cyan(did)}`);
6123
- console.log(`${import_chalk18.default.bold("Identity public key (base58btc)")}: ${import_chalk18.default.cyan((0, import_sdk19.base58btcEncode)(pub))}`);
6167
+ console.log(`${import_chalk19.default.bold("DID")}: ${import_chalk19.default.cyan(did)}`);
6168
+ console.log(`${import_chalk19.default.bold("Identity public key (base58btc)")}: ${import_chalk19.default.cyan((0, import_sdk19.base58btcEncode)(pub))}`);
6124
6169
  });
6125
6170
  }
6126
6171
  function decodeSeed(b64) {
@@ -6137,7 +6182,7 @@ function decodeSeed(b64) {
6137
6182
  }
6138
6183
 
6139
6184
  // src/commands/list.ts
6140
- var import_chalk19 = __toESM(require("chalk"));
6185
+ var import_chalk20 = __toESM(require("chalk"));
6141
6186
  function registerListCommand(root) {
6142
6187
  root.command("list").description("List agents registered locally (~/.heyarp/agents.json)").option("--json", "Machine-readable mode \u2014 emit the local agents as a single JSON array on stdout ({serverUrl, did, name, tags, registeredAt}[]).", false).action((opts) => {
6143
6188
  const rows = listAgents();
@@ -6146,7 +6191,7 @@ function registerListCommand(root) {
6146
6191
  return;
6147
6192
  }
6148
6193
  if (rows.length === 0) {
6149
- console.log(import_chalk19.default.dim(`No local agents. State file: ${stateFilePath()}`));
6194
+ console.log(import_chalk20.default.dim(`No local agents. State file: ${stateFilePath()}`));
6150
6195
  return;
6151
6196
  }
6152
6197
  const grouped = /* @__PURE__ */ new Map();
@@ -6158,7 +6203,7 @@ function registerListCommand(root) {
6158
6203
  for (const [serverUrl, group] of grouped) {
6159
6204
  if (!first) console.log("");
6160
6205
  first = false;
6161
- console.log(import_chalk19.default.bold(`Server: ${serverUrl}`));
6206
+ console.log(import_chalk20.default.bold(`Server: ${serverUrl}`));
6162
6207
  console.log(formatAgentsTable(group.map(({ agent }) => ({ did: agent.did, name: agent.name, tags: agent.tags, registeredAt: agent.registeredAt }))));
6163
6208
  }
6164
6209
  });
@@ -6166,7 +6211,7 @@ function registerListCommand(root) {
6166
6211
 
6167
6212
  // src/commands/login.ts
6168
6213
  var import_node_crypto3 = require("crypto");
6169
- var import_chalk20 = __toESM(require("chalk"));
6214
+ var import_chalk21 = __toESM(require("chalk"));
6170
6215
  init_api();
6171
6216
  var POLL_INTERVAL_MS = 2e3;
6172
6217
  var POLL_TIMEOUT_MS = 11 * 6e4;
@@ -6236,9 +6281,9 @@ function registerLoginCommand(root) {
6236
6281
  jsonOut({ serverUrl: result.serverUrl, wallet: result.wallet, credentialsPath: credentialsFilePath() });
6237
6282
  } else {
6238
6283
  console.log("");
6239
- console.log(`${import_chalk20.default.green("Logged in as")} ${import_chalk20.default.cyan(result.wallet)}`);
6240
- console.log(import_chalk20.default.dim(`If that is not the wallet you approved with, run heyarp logout immediately.`));
6241
- console.log(import_chalk20.default.dim(`Credential saved to ${credentialsFilePath()} (mode 0600).`));
6284
+ console.log(`${import_chalk21.default.green("Logged in as")} ${import_chalk21.default.cyan(result.wallet)}`);
6285
+ console.log(import_chalk21.default.dim(`If that is not the wallet you approved with, run heyarp logout immediately.`));
6286
+ console.log(import_chalk21.default.dim(`Credential saved to ${credentialsFilePath()} (mode 0600).`));
6242
6287
  }
6243
6288
  } catch (err) {
6244
6289
  emitActionError(err, cmd);
@@ -6248,7 +6293,7 @@ function registerLoginCommand(root) {
6248
6293
  }
6249
6294
 
6250
6295
  // src/commands/logout.ts
6251
- var import_chalk21 = __toESM(require("chalk"));
6296
+ var import_chalk22 = __toESM(require("chalk"));
6252
6297
  init_api();
6253
6298
  function registerLogoutCommand(root) {
6254
6299
  root.command("logout").description("Log out of the ARP server: revoke the stored CLI auth token (best-effort) and delete the local credential for this server.").option("--server <url>", "Override ARP server base URL").option("--json", "machine-readable output ({ serverUrl, loggedOut, wallet? })", false).action(async (opts, cmd) => {
@@ -6273,7 +6318,7 @@ function registerLogoutCommand(root) {
6273
6318
  if (opts.json) {
6274
6319
  jsonOut({ serverUrl: api.serverUrl, loggedOut: true, wallet: credential.wallet });
6275
6320
  } else {
6276
- console.log(`${import_chalk21.default.green("Logged out of")} ${api.serverUrl} ${import_chalk21.default.dim(`(was ${credential.wallet})`)}`);
6321
+ console.log(`${import_chalk22.default.green("Logged out of")} ${api.serverUrl} ${import_chalk22.default.dim(`(was ${credential.wallet})`)}`);
6277
6322
  }
6278
6323
  } catch (err) {
6279
6324
  emitActionError(err, cmd);
@@ -6284,7 +6329,7 @@ function registerLogoutCommand(root) {
6284
6329
 
6285
6330
  // src/commands/name.ts
6286
6331
  var import_sdk20 = require("@heyanon-arp/sdk");
6287
- var import_chalk22 = __toESM(require("chalk"));
6332
+ var import_chalk23 = __toESM(require("chalk"));
6288
6333
  init_api();
6289
6334
  function registerNameCommand(root) {
6290
6335
  const name = root.command("name").description("Agent name (handle) utilities.");
@@ -6307,7 +6352,7 @@ async function runNameCheck(input, opts) {
6307
6352
  return { name, available: false, reason: "reserved" };
6308
6353
  }
6309
6354
  const api = new ArpApiClient(opts.server);
6310
- progress(opts.json, import_chalk22.default.dim(`Server: ${api.serverUrl}`));
6355
+ progress(opts.json, import_chalk23.default.dim(`Server: ${api.serverUrl}`));
6311
6356
  try {
6312
6357
  const profile = await api.discoverByName(name);
6313
6358
  return { name, available: false, reason: "taken", did: profile.did };
@@ -6321,22 +6366,22 @@ async function runNameCheck(input, opts) {
6321
6366
  function printNameCheck(input, r) {
6322
6367
  switch (r.reason) {
6323
6368
  case "invalid":
6324
- console.log(`${import_chalk22.default.red("\u2717")} '${input}' is not a valid handle \u2014 must be lowercase a-z0-9_, 3-32 chars.`);
6369
+ console.log(`${import_chalk23.default.red("\u2717")} '${input}' is not a valid handle \u2014 must be lowercase a-z0-9_, 3-32 chars.`);
6325
6370
  break;
6326
6371
  case "reserved":
6327
- console.log(`${import_chalk22.default.red("\u2717")} '${r.name}' is reserved and cannot be registered.`);
6372
+ console.log(`${import_chalk23.default.red("\u2717")} '${r.name}' is reserved and cannot be registered.`);
6328
6373
  break;
6329
6374
  case "taken":
6330
- console.log(`${import_chalk22.default.yellow("\u2717")} '${r.name}' is taken \u2192 ${import_chalk22.default.cyan(r.did ?? "(unknown DID)")}`);
6375
+ console.log(`${import_chalk23.default.yellow("\u2717")} '${r.name}' is taken \u2192 ${import_chalk23.default.cyan(r.did ?? "(unknown DID)")}`);
6331
6376
  break;
6332
6377
  default:
6333
- console.log(`${import_chalk22.default.green("\u2713")} '${r.name}' is available.`);
6378
+ console.log(`${import_chalk23.default.green("\u2713")} '${r.name}' is available.`);
6334
6379
  }
6335
6380
  }
6336
6381
 
6337
6382
  // src/commands/profile.ts
6338
6383
  var import_sdk21 = require("@heyanon-arp/sdk");
6339
- var import_chalk23 = __toESM(require("chalk"));
6384
+ var import_chalk24 = __toESM(require("chalk"));
6340
6385
  init_api();
6341
6386
  function registerProfileCommand(root) {
6342
6387
  root.command("profile").description("Composed agent profile: public fields + reputation + liveness, in one read.").argument("<did>", "did:arp:<base58btc> identifier").option("--server <url>", "Override ARP server base URL").option("--json", "Emit the profile as JSON on stdout.", false).action(async (did, opts) => {
@@ -6351,26 +6396,26 @@ function registerProfileCommand(root) {
6351
6396
  }
6352
6397
  const j = false;
6353
6398
  const s = p.reputation.scores;
6354
- const live = p.liveness.online ? import_chalk23.default.green("\u25CF online") : import_chalk23.default.dim("\u25CB offline");
6399
+ const live = p.liveness.online ? import_chalk24.default.green("\u25CF online") : import_chalk24.default.dim("\u25CB offline");
6355
6400
  const tags = p.tags.map(sanitizeForTerminal).filter((t) => t.length > 0);
6356
- progress(j, import_chalk23.default.bold(`${p.name ? sanitizeForTerminal(p.name) : "(unnamed)"} ${import_chalk23.default.dim(p.did)}`));
6357
- if (p.description) progress(j, import_chalk23.default.dim(` ${sanitizeForTerminal(p.description)}`));
6358
- progress(j, ` ${live}${p.liveness.inboxStreamActive ? import_chalk23.default.green(" \xB7 stream attached") : ""} \xB7 last seen ${p.liveness.lastSeenAt ?? "\u2014"}`);
6359
- progress(j, ` tags: ${tags.length ? tags.join(", ") : import_chalk23.default.dim("none")}`);
6401
+ progress(j, import_chalk24.default.bold(`${p.name ? sanitizeForTerminal(p.name) : "(unnamed)"} ${import_chalk24.default.dim(p.did)}`));
6402
+ if (p.description) progress(j, import_chalk24.default.dim(` ${sanitizeForTerminal(p.description)}`));
6403
+ progress(j, ` ${live}${p.liveness.inboxStreamActive ? import_chalk24.default.green(" \xB7 stream attached") : ""} \xB7 last seen ${p.liveness.lastSeenAt ?? "\u2014"}`);
6404
+ progress(j, ` tags: ${tags.length ? tags.join(", ") : import_chalk24.default.dim("none")}`);
6360
6405
  progress(j, "");
6361
- progress(j, import_chalk23.default.bold(" Reputation") + import_chalk23.default.dim(" (informational)"));
6406
+ progress(j, import_chalk24.default.bold(" Reputation") + import_chalk24.default.dim(" (informational)"));
6362
6407
  progress(
6363
6408
  j,
6364
6409
  ` composite ${s.composite.toFixed(2)} \xB7 reliability ${s.reliability.toFixed(2)} \xB7 settlement ${s.settlement.toFixed(2)} \xB7 dispute-health ${s.disputeHealth.toFixed(2)}`
6365
6410
  );
6366
- progress(j, import_chalk23.default.dim(` ${p.reputation.computed ? `computed ${p.reputation.lastComputedAt}` : "never computed (neutral cold-start)"}`));
6411
+ progress(j, import_chalk24.default.dim(` ${p.reputation.computed ? `computed ${p.reputation.lastComputedAt}` : "never computed (neutral cold-start)"}`));
6367
6412
  });
6368
6413
  }
6369
6414
 
6370
6415
  // src/commands/receipt.ts
6371
6416
  var import_sdk22 = require("@heyanon-arp/sdk");
6372
6417
  var import_shield2 = require("@heyanon-arp/shield");
6373
- var import_chalk24 = __toESM(require("chalk"));
6418
+ var import_chalk25 = __toESM(require("chalk"));
6374
6419
  init_api();
6375
6420
  function registerReceiptCommands(root) {
6376
6421
  const cmd = root.command("receipt").description("Receipt envelopes \u2014 the payee proposes a delivery record (payment consent is on-chain via claim_work_payment)");
@@ -6397,7 +6442,7 @@ function registerPropose(parent) {
6397
6442
  } catch (err) {
6398
6443
  emitActionError(err, cmd);
6399
6444
  if (!opts.json && err instanceof ApiError && err.payload.code === "RECEIPT_ALREADY_EXISTS") {
6400
- console.error(import_chalk24.default.dim(" This receipt already exists (a prior propose committed it). Do NOT re-propose \u2014 payment consent is on-chain (claim_work_payment)."));
6445
+ console.error(import_chalk25.default.dim(" This receipt already exists (a prior propose committed it). Do NOT re-propose \u2014 payment consent is on-chain (claim_work_payment)."));
6401
6446
  }
6402
6447
  process.exitCode = 1;
6403
6448
  }
@@ -6423,7 +6468,7 @@ async function runPropose(recipientDid, delegationId, requestHashArg, responseHa
6423
6468
  opts.relId = await resolveAutoRelId(api, sender, delegationId);
6424
6469
  progress(
6425
6470
  opts.json,
6426
- import_chalk24.default.dim(`[auto-rel-id] resolved --rel-id=${opts.relId} (delegation found in exactly one of your relationships; pass --rel-id explicitly to override)`)
6471
+ import_chalk25.default.dim(`[auto-rel-id] resolved --rel-id=${opts.relId} (delegation found in exactly one of your relationships; pass --rel-id explicitly to override)`)
6427
6472
  );
6428
6473
  }
6429
6474
  if (opts.relId) {
@@ -6439,7 +6484,7 @@ async function runPropose(recipientDid, delegationId, requestHashArg, responseHa
6439
6484
  opts.requestId = await resolveAutoRequestId(api, sender, opts.relId, delegationId);
6440
6485
  progress(
6441
6486
  opts.json,
6442
- import_chalk24.default.dim(
6487
+ import_chalk25.default.dim(
6443
6488
  `[auto-request-id] resolved --request-id=${opts.requestId} (unique 'responded' work_log under this delegation; pass --request-id explicitly to override)`
6444
6489
  )
6445
6490
  );
@@ -6458,8 +6503,8 @@ async function runPropose(recipientDid, delegationId, requestHashArg, responseHa
6458
6503
  }
6459
6504
  requestHash = computed.requestHash;
6460
6505
  responseHash = computed.responseHash;
6461
- progress(opts.json, import_chalk24.default.dim(`[auto-hashes] request_hash: ${requestHash} (from work-log ${opts.relId}/${delegationId}/${opts.requestId})`));
6462
- progress(opts.json, import_chalk24.default.dim(`[auto-hashes] response_hash: ${responseHash}`));
6506
+ progress(opts.json, import_chalk25.default.dim(`[auto-hashes] request_hash: ${requestHash} (from work-log ${opts.relId}/${delegationId}/${opts.requestId})`));
6507
+ progress(opts.json, import_chalk25.default.dim(`[auto-hashes] response_hash: ${responseHash}`));
6463
6508
  } else {
6464
6509
  if (requestHashArg === void 0 || responseHashArg === void 0) {
6465
6510
  throw new Error("receipt propose: <request-hash> and <response-hash> are required (or pass --auto-hashes + --rel-id + --request-id to derive them from the work-log)");
@@ -6479,11 +6524,11 @@ async function runPropose(recipientDid, delegationId, requestHashArg, responseHa
6479
6524
  if (opts.deliverableHash) content.deliverable_hash = opts.deliverableHash;
6480
6525
  if (usage) content.usage = usage;
6481
6526
  const body = { type: "receipt", content };
6482
- progress(opts.json, import_chalk24.default.dim(`Server: ${api.serverUrl}`));
6483
- progress(opts.json, import_chalk24.default.dim(`Sender (payee): ${sender.did}`));
6484
- progress(opts.json, import_chalk24.default.dim(`Recipient (caller): ${recipientDid}`));
6485
- progress(opts.json, import_chalk24.default.dim(`Delegation: ${delegationId}`));
6486
- progress(opts.json, import_chalk24.default.dim(`Verdict (proposed): ${verdict}`));
6527
+ progress(opts.json, import_chalk25.default.dim(`Server: ${api.serverUrl}`));
6528
+ progress(opts.json, import_chalk25.default.dim(`Sender (payee): ${sender.did}`));
6529
+ progress(opts.json, import_chalk25.default.dim(`Recipient (caller): ${recipientDid}`));
6530
+ progress(opts.json, import_chalk25.default.dim(`Delegation: ${delegationId}`));
6531
+ progress(opts.json, import_chalk25.default.dim(`Verdict (proposed): ${verdict}`));
6487
6532
  const result = await sendReceiptEnvelope({ api, sender, recipientDid, body, attachments: void 0, ttlSeconds, verbose: opts.verbose, server: opts.server });
6488
6533
  if (opts.json) {
6489
6534
  const json = {
@@ -6504,10 +6549,10 @@ async function runPropose(recipientDid, delegationId, requestHashArg, responseHa
6504
6549
  return;
6505
6550
  }
6506
6551
  printIngestResult2(result);
6507
- console.log(import_chalk24.default.dim(`
6508
- Receipt event hash: ${import_chalk24.default.cyan(result.serverEventHash)}`));
6509
- console.log(import_chalk24.default.dim("Receipt recorded. Payment consent is ON-CHAIN now: the buyer approves by"));
6510
- console.log(import_chalk24.default.dim("sending claim_work_payment (or you self-claim after the review window)."));
6552
+ console.log(import_chalk25.default.dim(`
6553
+ Receipt event hash: ${import_chalk25.default.cyan(result.serverEventHash)}`));
6554
+ console.log(import_chalk25.default.dim("Receipt recorded. Payment consent is ON-CHAIN now: the buyer approves by"));
6555
+ console.log(import_chalk25.default.dim("sending claim_work_payment (or you self-claim after the review window)."));
6511
6556
  }
6512
6557
  async function assertSenderIsReceiptPayee(api, sender, relationshipId, delegationId) {
6513
6558
  const signer = makeSigner(sender);
@@ -6618,7 +6663,7 @@ async function sendReceiptEnvelope(args) {
6618
6663
  attachments: args.attachments
6619
6664
  });
6620
6665
  if (args.verbose) {
6621
- console.log(import_chalk24.default.bold("\nEnvelope (pre-send):"));
6666
+ console.log(import_chalk25.default.bold("\nEnvelope (pre-send):"));
6622
6667
  console.log(formatJson(envelope));
6623
6668
  }
6624
6669
  try {
@@ -6633,12 +6678,12 @@ async function sendReceiptEnvelope(args) {
6633
6678
  }
6634
6679
  }
6635
6680
  function printIngestResult2(result) {
6636
- console.log(import_chalk24.default.green("\nDelivered."));
6637
- console.log(`${import_chalk24.default.bold("Event id")}: ${import_chalk24.default.cyan(result.eventId)}`);
6638
- console.log(`${import_chalk24.default.bold("Relationship id")}: ${import_chalk24.default.cyan(result.relationshipId)}`);
6639
- console.log(`${import_chalk24.default.bold("Chain index")}: ${import_chalk24.default.cyan(String(result.relationshipEventIndex))}`);
6640
- console.log(`${import_chalk24.default.bold("Server timestamp")}: ${import_chalk24.default.cyan(result.serverTimestamp)}`);
6641
- console.log(`${import_chalk24.default.bold("Server event hash")}: ${import_chalk24.default.cyan(result.serverEventHash)}`);
6681
+ console.log(import_chalk25.default.green("\nDelivered."));
6682
+ console.log(`${import_chalk25.default.bold("Event id")}: ${import_chalk25.default.cyan(result.eventId)}`);
6683
+ console.log(`${import_chalk25.default.bold("Relationship id")}: ${import_chalk25.default.cyan(result.relationshipId)}`);
6684
+ console.log(`${import_chalk25.default.bold("Chain index")}: ${import_chalk25.default.cyan(String(result.relationshipEventIndex))}`);
6685
+ console.log(`${import_chalk25.default.bold("Server timestamp")}: ${import_chalk25.default.cyan(result.serverTimestamp)}`);
6686
+ console.log(`${import_chalk25.default.bold("Server event hash")}: ${import_chalk25.default.cyan(result.serverEventHash)}`);
6642
6687
  }
6643
6688
  function parseVerdict(cmdName, raw) {
6644
6689
  if (raw === void 0 || raw === "") return import_sdk22.ReceiptVerdicts.ACCEPTED;
@@ -6683,7 +6728,7 @@ function requireSha256(cmdName, raw, label) {
6683
6728
 
6684
6729
  // src/commands/receipts.ts
6685
6730
  var import_sdk23 = require("@heyanon-arp/sdk");
6686
- var import_chalk25 = __toESM(require("chalk"));
6731
+ var import_chalk26 = __toESM(require("chalk"));
6687
6732
  init_api();
6688
6733
  function registerReceiptsCommand(root) {
6689
6734
  root.command("receipts").description(
@@ -6706,9 +6751,9 @@ async function runReceipts(relationshipId, opts) {
6706
6751
  const api = new ArpApiClient(opts.server);
6707
6752
  const sender = resolveSenderAgent("receipts", opts.server, opts.fromDid, opts.from);
6708
6753
  if (!opts.json) {
6709
- console.log(import_chalk25.default.dim(`Server: ${api.serverUrl}`));
6710
- console.log(import_chalk25.default.dim(`Signer: ${sender.did}`));
6711
- console.log(import_chalk25.default.dim(`Relationship: ${relationshipId}`));
6754
+ console.log(import_chalk26.default.dim(`Server: ${api.serverUrl}`));
6755
+ console.log(import_chalk26.default.dim(`Signer: ${sender.did}`));
6756
+ console.log(import_chalk26.default.dim(`Relationship: ${relationshipId}`));
6712
6757
  }
6713
6758
  const query = { limit };
6714
6759
  if (opts.delegationId) query.delegationId = opts.delegationId;
@@ -6720,7 +6765,7 @@ async function runReceipts(relationshipId, opts) {
6720
6765
  return;
6721
6766
  }
6722
6767
  if (rows.length === 0) {
6723
- console.log(import_chalk25.default.dim("\n(no receipts for this relationship)"));
6768
+ console.log(import_chalk26.default.dim("\n(no receipts for this relationship)"));
6724
6769
  return;
6725
6770
  }
6726
6771
  console.log("");
@@ -6737,29 +6782,29 @@ async function runReceipts(relationshipId, opts) {
6737
6782
  }));
6738
6783
  }
6739
6784
  const lastId = rows[rows.length - 1].id;
6740
- console.log(import_chalk25.default.dim(`
6785
+ console.log(import_chalk26.default.dim(`
6741
6786
  ${rows.length} receipt row(s). Paginate with --after ${lastId}.`));
6742
6787
  }
6743
6788
  function formatReceiptLine(r, selfDid, opts = {}) {
6744
6789
  const delegationPart = opts.fullIds ? r.delegationId : idHead2(r.delegationId);
6745
6790
  const requestHashPart = opts.fullIds ? r.requestHash : hashHead3(r.requestHash);
6746
- const id = import_chalk25.default.bold(`${delegationPart}/${requestHashPart}`);
6791
+ const id = import_chalk26.default.bold(`${delegationPart}/${requestHashPart}`);
6747
6792
  const callerHead = opts.fullIds ? r.callerDid : didHead3(r.callerDid);
6748
6793
  const payeeHead = opts.fullIds ? r.payeeDid : didHead3(r.payeeDid);
6749
- const direction = r.payeeDid === selfDid ? `${import_chalk25.default.bold("me")}(payee) \u2192 ${import_chalk25.default.dim(callerHead)}` : `${import_chalk25.default.dim(payeeHead)}(payee) \u2192 ${import_chalk25.default.bold("me")}`;
6794
+ const direction = r.payeeDid === selfDid ? `${import_chalk26.default.bold("me")}(payee) \u2192 ${import_chalk26.default.dim(callerHead)}` : `${import_chalk26.default.dim(payeeHead)}(payee) \u2192 ${import_chalk26.default.bold("me")}`;
6750
6795
  const verdict = formatVerdict(r);
6751
6796
  const responseTail = opts.fullIds ? `
6752
- ${import_chalk25.default.dim("responseHash:")} ${import_chalk25.default.cyan(r.responseHash)}` : "";
6797
+ ${import_chalk26.default.dim("responseHash:")} ${import_chalk26.default.cyan(r.responseHash)}` : "";
6753
6798
  return `${id} ${direction} ${verdict}${responseTail}`;
6754
6799
  }
6755
6800
  function formatVerdict(r) {
6756
6801
  switch (r.verdictProposed) {
6757
6802
  case import_sdk23.ReceiptVerdicts.ACCEPTED:
6758
- return import_chalk25.default.green("accepted");
6803
+ return import_chalk26.default.green("accepted");
6759
6804
  case import_sdk23.ReceiptVerdicts.ACCEPTED_WITH_NOTES:
6760
- return import_chalk25.default.yellow("accepted_with_notes");
6805
+ return import_chalk26.default.yellow("accepted_with_notes");
6761
6806
  case import_sdk23.ReceiptVerdicts.REJECTED:
6762
- return import_chalk25.default.red("rejected");
6807
+ return import_chalk26.default.red("rejected");
6763
6808
  }
6764
6809
  }
6765
6810
  function idHead2(id) {
@@ -6786,7 +6831,7 @@ function parseLimit5(raw) {
6786
6831
  // src/commands/recover.ts
6787
6832
  var import_node_fs8 = require("fs");
6788
6833
  var import_sdk24 = require("@heyanon-arp/sdk");
6789
- var import_chalk26 = __toESM(require("chalk"));
6834
+ var import_chalk27 = __toESM(require("chalk"));
6790
6835
  init_api();
6791
6836
  function registerRecoverCommand(root) {
6792
6837
  root.command("recover").description(
@@ -6822,7 +6867,7 @@ async function runRecover(opts) {
6822
6867
  }
6823
6868
  if (bundle.ownerWallet && bundle.ownerWallet !== credential.wallet) {
6824
6869
  process.stderr.write(
6825
- import_chalk26.default.yellow(
6870
+ import_chalk27.default.yellow(
6826
6871
  `\u26A0 this bundle was exported under wallet ${bundle.ownerWallet}, but you are logged in as ${credential.wallet}. The server will reject the recover unless the agent is yours.
6827
6872
  `
6828
6873
  )
@@ -6839,7 +6884,7 @@ async function runRecover(opts) {
6839
6884
  lastSenderSequence = seq.lastSenderSequence;
6840
6885
  } catch (err) {
6841
6886
  process.stderr.write(
6842
- import_chalk26.default.yellow(
6887
+ import_chalk27.default.yellow(
6843
6888
  `\u26A0 could not read the sender sequence from the server (${err.message}). If sends are rejected as backwards, run \`heyarp escrow recover-sequence --apply\`.
6844
6889
  `
6845
6890
  )
@@ -6867,14 +6912,14 @@ async function runRecover(opts) {
6867
6912
  jsonOut({ recovered: true, did: derivedDid, name: row.name });
6868
6913
  return;
6869
6914
  }
6870
- console.log(import_chalk26.default.green(`\u2713 Recovered ${row.name ? `${row.name} ` : ""}${derivedDid} into local state \u2014 you can operate it now.`));
6915
+ console.log(import_chalk27.default.green(`\u2713 Recovered ${row.name ? `${row.name} ` : ""}${derivedDid} into local state \u2014 you can operate it now.`));
6871
6916
  }
6872
6917
 
6873
6918
  // src/commands/register.ts
6874
6919
  var import_node_crypto4 = require("crypto");
6875
6920
  var import_node_fs9 = require("fs");
6876
6921
  var import_sdk25 = require("@heyanon-arp/sdk");
6877
- var import_chalk27 = __toESM(require("chalk"));
6922
+ var import_chalk28 = __toESM(require("chalk"));
6878
6923
  var import_prompts2 = __toESM(require("prompts"));
6879
6924
  init_api();
6880
6925
  init_paths();
@@ -6928,7 +6973,7 @@ var defaultRegisterDeps = {
6928
6973
  async function runRegister(opts, deps = defaultRegisterDeps) {
6929
6974
  assertJsonRequiresYes(opts);
6930
6975
  const api = deps.makeApi(opts.server);
6931
- if (!opts.json) console.log(import_chalk27.default.dim(`Server: ${api.serverUrl}`));
6976
+ if (!opts.json) console.log(import_chalk28.default.dim(`Server: ${api.serverUrl}`));
6932
6977
  const credential = requireCredential("register", api.serverUrl);
6933
6978
  if (!opts.json) {
6934
6979
  warnIfAgentsAlreadyRegistered(opts.server);
@@ -6936,10 +6981,10 @@ async function runRegister(opts, deps = defaultRegisterDeps) {
6936
6981
  }
6937
6982
  const keys = opts.fromKeys ? loadKeysFromFile(opts.fromKeys) : freshKeys();
6938
6983
  const did = (0, import_sdk25.formatDid)(keys.identityPublicKey);
6939
- if (!opts.json) console.log(import_chalk27.default.dim(`DID will be: ${did}`));
6984
+ if (!opts.json) console.log(import_chalk28.default.dim(`DID will be: ${did}`));
6940
6985
  const answers = await mergeAnswers(opts);
6941
6986
  const scryptSalt = (0, import_node_crypto4.randomBytes)(16);
6942
- if (!opts.json) console.log(import_chalk27.default.dim("Deriving scrypt key, this may take a moment..."));
6987
+ if (!opts.json) console.log(import_chalk28.default.dim("Deriving scrypt key, this may take a moment..."));
6943
6988
  const scryptKey = (0, import_sdk25.deriveScryptKey)(answers.password, new Uint8Array(scryptSalt));
6944
6989
  const challenge = await api.issueChallenge("register");
6945
6990
  const challengeBytes = base64UrlNoPadDecode(challenge.challengeB64);
@@ -7027,19 +7072,19 @@ async function runRegister(opts, deps = defaultRegisterDeps) {
7027
7072
  try {
7028
7073
  recordHome(arpHomeDir());
7029
7074
  } catch (registryErr) {
7030
- if (!opts.json) console.log(import_chalk27.default.dim(`(homes registry write failed: ${registryErr.message})`));
7075
+ if (!opts.json) console.log(import_chalk28.default.dim(`(homes registry write failed: ${registryErr.message})`));
7031
7076
  }
7032
7077
  if (!opts.json) {
7033
- console.log(import_chalk27.default.green("\nRegistered."));
7034
- console.log(`${import_chalk27.default.bold("DID")}: ${import_chalk27.default.cyan(result.did)}`);
7035
- console.log(`${import_chalk27.default.bold("Settlement pubkey")} ${import_chalk27.default.dim("(fund with SOL)")}: ${import_chalk27.default.cyan(settlementPublicKeyB58)}`);
7036
- console.log(`${import_chalk27.default.bold("Owner account")}: ${import_chalk27.default.cyan(credential.wallet)}`);
7037
- console.log(import_chalk27.default.bold("DID document:"));
7078
+ console.log(import_chalk28.default.green("\nRegistered."));
7079
+ console.log(`${import_chalk28.default.bold("DID")}: ${import_chalk28.default.cyan(result.did)}`);
7080
+ console.log(`${import_chalk28.default.bold("Settlement pubkey")} ${import_chalk28.default.dim("(fund with SOL)")}: ${import_chalk28.default.cyan(settlementPublicKeyB58)}`);
7081
+ console.log(`${import_chalk28.default.bold("Owner account")}: ${import_chalk28.default.cyan(credential.wallet)}`);
7082
+ console.log(import_chalk28.default.bold("DID document:"));
7038
7083
  console.log(formatJson(result.didDocument));
7039
7084
  }
7040
- if (!opts.json) console.log(import_chalk27.default.green(`
7085
+ if (!opts.json) console.log(import_chalk28.default.green(`
7041
7086
  \u2713 Discoverable now via \`heyarp agents\`.`));
7042
- if (!opts.json) console.log(import_chalk27.default.dim(`
7087
+ if (!opts.json) console.log(import_chalk28.default.dim(`
7043
7088
  Local state saved to ${arpHomeDir()}/agents.json (mode 0600).`));
7044
7089
  if (opts.json) {
7045
7090
  console.log(
@@ -7112,7 +7157,7 @@ async function mergeAnswers(opts) {
7112
7157
  }
7113
7158
  const prompted = promptDefs.length > 0 ? await (0, import_prompts2.default)(promptDefs, {
7114
7159
  onCancel: () => {
7115
- console.log(import_chalk27.default.yellow("\nAborted."));
7160
+ console.log(import_chalk28.default.yellow("\nAborted."));
7116
7161
  process.exit(130);
7117
7162
  }
7118
7163
  }) : {};
@@ -7144,16 +7189,16 @@ function warnIfOrphanHomesPresent() {
7144
7189
  try {
7145
7190
  others = listHomes().filter((h) => h.path !== current);
7146
7191
  } catch (registryErr) {
7147
- console.log(import_chalk27.default.dim(`(homes registry unreadable, skipping orphan-home check: ${registryErr.message})`));
7192
+ console.log(import_chalk28.default.dim(`(homes registry unreadable, skipping orphan-home check: ${registryErr.message})`));
7148
7193
  return;
7149
7194
  }
7150
7195
  if (others.length === 0) return;
7151
- const list = others.map((h) => ` \u2022 ${import_chalk27.default.cyan(h.path)} ${import_chalk27.default.dim(`(last seen ${h.lastSeenAt})`)}`).join("\n");
7152
- console.log(import_chalk27.default.yellow(`
7196
+ const list = others.map((h) => ` \u2022 ${import_chalk28.default.cyan(h.path)} ${import_chalk28.default.dim(`(last seen ${h.lastSeenAt})`)}`).join("\n");
7197
+ console.log(import_chalk28.default.yellow(`
7153
7198
  \u26A0 HEYARP_HOME is unset, but other agent homes are registered on this machine:`));
7154
7199
  console.log(list);
7155
7200
  console.log(
7156
- import_chalk27.default.dim(
7201
+ import_chalk28.default.dim(
7157
7202
  ` Registering will create a NEW agent under ${current}.
7158
7203
  If you meant to add to an existing home, abort (Ctrl-C) and re-run with:
7159
7204
  HEYARP_HOME=<path> heyarp register \u2026
@@ -7166,11 +7211,11 @@ function warnIfAgentsAlreadyRegistered(serverOverride) {
7166
7211
  const targetServer = resolveServerUrl(serverOverride);
7167
7212
  const existing = listAgents().filter((row) => row.serverUrl === targetServer);
7168
7213
  if (existing.length === 0) return;
7169
- const list = existing.map((row) => ` \u2022 ${import_chalk27.default.cyan(row.agent.did)}${row.agent.name ? import_chalk27.default.dim(` (${row.agent.name})`) : ""}`).join("\n");
7170
- console.log(import_chalk27.default.yellow("\n\u26A0 ~/.heyarp/agents.json already has agent(s) for this server:"));
7214
+ const list = existing.map((row) => ` \u2022 ${import_chalk28.default.cyan(row.agent.did)}${row.agent.name ? import_chalk28.default.dim(` (${row.agent.name})`) : ""}`).join("\n");
7215
+ console.log(import_chalk28.default.yellow("\n\u26A0 ~/.heyarp/agents.json already has agent(s) for this server:"));
7171
7216
  console.log(list);
7172
7217
  console.log(
7173
- import_chalk27.default.dim(
7218
+ import_chalk28.default.dim(
7174
7219
  " After this register completes, you will have multiple local DIDs sharing one state file.\n To keep their state isolated, run with HEYARP_HOME pointing at a per-agent dir, e.g.\n HEYARP_HOME=/tmp/agent-alice heyarp register \u2026\n Otherwise, pass --from-did <did> explicitly on every signed command.\n"
7175
7220
  )
7176
7221
  );
@@ -7226,7 +7271,7 @@ function assertJsonRequiresYes(opts) {
7226
7271
 
7227
7272
  // src/commands/relationships.ts
7228
7273
  var import_sdk26 = require("@heyanon-arp/sdk");
7229
- var import_chalk28 = __toESM(require("chalk"));
7274
+ var import_chalk29 = __toESM(require("chalk"));
7230
7275
  init_api();
7231
7276
  var ALLOWED_STATES2 = new Set(import_sdk26.RELATIONSHIP_STATE_NAMES);
7232
7277
  function registerRelationshipsCommand(root) {
@@ -7255,8 +7300,8 @@ async function runRelationships(positionalDid, opts) {
7255
7300
  const local = explicitDid !== void 0 ? loadAgentOrThrow(opts.server, explicitDid) : resolveSenderAgent("relationships", opts.server, void 0, opts.from);
7256
7301
  const did = local.did;
7257
7302
  const api = new ArpApiClient(opts.server);
7258
- progress(opts.json, import_chalk28.default.dim(`Server: ${api.serverUrl}`));
7259
- progress(opts.json, import_chalk28.default.dim(`Signer: ${local.did}`));
7303
+ progress(opts.json, import_chalk29.default.dim(`Server: ${api.serverUrl}`));
7304
+ progress(opts.json, import_chalk29.default.dim(`Signer: ${local.did}`));
7260
7305
  const query = { limit };
7261
7306
  if (state) query.state = state;
7262
7307
  const signer = makeSigner(local);
@@ -7266,18 +7311,18 @@ async function runRelationships(positionalDid, opts) {
7266
7311
  return;
7267
7312
  }
7268
7313
  if (rows.length === 0) {
7269
- console.log(import_chalk28.default.dim("\n(no relationships)"));
7314
+ console.log(import_chalk29.default.dim("\n(no relationships)"));
7270
7315
  return;
7271
7316
  }
7272
7317
  console.log("");
7273
7318
  console.log(formatRelationshipsTable(rows, did));
7274
7319
  if (opts.verbose) {
7275
- console.log(import_chalk28.default.bold("\nFull relationships:"));
7320
+ console.log(import_chalk29.default.bold("\nFull relationships:"));
7276
7321
  for (const r of rows) {
7277
7322
  console.log(formatJson(r));
7278
7323
  }
7279
7324
  }
7280
- console.log(import_chalk28.default.dim(`
7325
+ console.log(import_chalk29.default.dim(`
7281
7326
  ${rows.length} relationship(s).`));
7282
7327
  }
7283
7328
  function formatRelationshipsTable(rows, selfDid) {
@@ -7285,7 +7330,7 @@ function formatRelationshipsTable(rows, selfDid) {
7285
7330
  const data = rows.map((r) => [r.relationshipId, otherPair(r, selfDid), r.state, r.lastEventAt ?? "(none)", String(r.lastEventIndex)]);
7286
7331
  const widths = header.map((h, i) => Math.max(h.length, ...data.map((row) => row[i].length)));
7287
7332
  const pad = (cells) => cells.map((c, i) => c.padEnd(widths[i])).join(" ");
7288
- return [import_chalk28.default.bold(pad(header)), import_chalk28.default.dim(pad(widths.map((w) => "-".repeat(w)))), ...data.map((row) => pad(row))].join("\n");
7333
+ return [import_chalk29.default.bold(pad(header)), import_chalk29.default.dim(pad(widths.map((w) => "-".repeat(w)))), ...data.map((row) => pad(row))].join("\n");
7289
7334
  }
7290
7335
  function otherPair(r, selfDid) {
7291
7336
  if (r.pairDidA === selfDid) return r.pairDidB;
@@ -7310,7 +7355,7 @@ function parseLimit6(raw) {
7310
7355
 
7311
7356
  // src/commands/reputation.ts
7312
7357
  var import_sdk27 = require("@heyanon-arp/sdk");
7313
- var import_chalk29 = __toESM(require("chalk"));
7358
+ var import_chalk30 = __toESM(require("chalk"));
7314
7359
  init_api();
7315
7360
  function registerReputationCommand(root) {
7316
7361
  root.command("reputation").description("Show an agent's informational reputation (composite + component scores + raw counters). Public, no auth. NOT a money/eligibility gate.").argument("<did>", "did:arp:<base58btc> identifier").option("--server <url>", "Override ARP server base URL").option("--json", "Emit the reputation as JSON on stdout.", false).action(async (did, opts) => {
@@ -7326,10 +7371,10 @@ function registerReputationCommand(root) {
7326
7371
  const s = rep.scores;
7327
7372
  const c = rep.counters;
7328
7373
  const j = false;
7329
- progress(j, import_chalk29.default.bold(`Reputation \u2014 ${did}`));
7374
+ progress(j, import_chalk30.default.bold(`Reputation \u2014 ${did}`));
7330
7375
  progress(
7331
7376
  j,
7332
- import_chalk29.default.dim(` ${rep.informational ? "INFORMATIONAL" : "GATING"} \xB7 ${rep.computed ? `computed ${rep.lastComputedAt}` : "never computed (neutral cold-start)"}`)
7377
+ import_chalk30.default.dim(` ${rep.informational ? "INFORMATIONAL" : "GATING"} \xB7 ${rep.computed ? `computed ${rep.lastComputedAt}` : "never computed (neutral cold-start)"}`)
7333
7378
  );
7334
7379
  progress(j, "");
7335
7380
  progress(j, ` composite ${bar(s.composite)} ${s.composite.toFixed(2)}`);
@@ -7337,17 +7382,17 @@ function registerReputationCommand(root) {
7337
7382
  progress(j, ` settlement ${bar(s.settlement)} ${s.settlement.toFixed(2)}`);
7338
7383
  progress(j, ` dispute health ${bar(s.disputeHealth)} ${s.disputeHealth.toFixed(2)}`);
7339
7384
  progress(j, "");
7340
- progress(j, import_chalk29.default.dim(" evidence:"));
7385
+ progress(j, import_chalk30.default.dim(" evidence:"));
7341
7386
  progress(
7342
7387
  j,
7343
- import_chalk29.default.dim(
7388
+ import_chalk30.default.dim(
7344
7389
  ` on-chain cycles ${c.onchainCycles} \xB7 completed ${c.completedDelegations} (payer ${c.completedAsPayer} / payee ${c.completedAsPayee}) \xB7 failed ${c.failedDelegations}`
7345
7390
  )
7346
7391
  );
7347
- progress(j, import_chalk29.default.dim(` escrows settled ${c.settledEscrows} / refunded ${c.refundedEscrows} \xB7 disputed ${c.disputedEscrows} (adverse ${c.disputesAdverse})`));
7348
- progress(j, import_chalk29.default.dim(` distinct counterparts ${c.distinctCounterparts} \xB7 active relationships ${c.activeRelationships}`));
7392
+ progress(j, import_chalk30.default.dim(` escrows settled ${c.settledEscrows} / refunded ${c.refundedEscrows} \xB7 disputed ${c.disputedEscrows} (adverse ${c.disputesAdverse})`));
7393
+ progress(j, import_chalk30.default.dim(` distinct counterparts ${c.distinctCounterparts} \xB7 active relationships ${c.activeRelationships}`));
7349
7394
  progress(j, "");
7350
- progress(j, import_chalk29.default.dim(" Informational only \u2014 a discovery-sort signal, not a money or eligibility gate."));
7395
+ progress(j, import_chalk30.default.dim(" Informational only \u2014 a discovery-sort signal, not a money or eligibility gate."));
7351
7396
  });
7352
7397
  }
7353
7398
  function bar(score) {
@@ -7357,10 +7402,10 @@ function bar(score) {
7357
7402
 
7358
7403
  // src/commands/send-handshake.ts
7359
7404
  var import_sdk28 = require("@heyanon-arp/sdk");
7360
- var import_chalk30 = __toESM(require("chalk"));
7405
+ var import_chalk31 = __toESM(require("chalk"));
7361
7406
  init_api();
7362
7407
  function registerSendHandshakeCommand(root) {
7363
- root.command("send-handshake").description("Send a handshake envelope to a recipient (agent name or DID). Server creates the relationship row on first contact.").argument("<recipient>", "Recipient \u2014 agent name (handle) or DID (did:arp:...)").option("--server <url>", "Override ARP server base URL").option("--from-did <did>", "Sender DID \u2014 required only if multiple agents are registered against this server").option("--from <name>", "Signer agent NAME (handle) \u2014 alternative to --from-did, resolved against your local agents").option("--greeting <s>", "Optional greeting text included in body.content").option("--intent <s>", "Optional intent text included in body.content").option("--ttl <seconds>", `Envelope TTL in seconds (max ${import_sdk28.MAX_ENVELOPE_TTL_SECONDS} = 24h)`, "3600").option("--verbose", "Print the full envelope before sending and the full server response. Mutually exclusive with --json.", false).option(
7408
+ root.command("send-handshake").description("Send a handshake envelope to a recipient (agent name or DID). Server creates the relationship row on first contact.").argument("<recipient>", "Recipient \u2014 agent name (handle) or DID (did:arp:...)").option("--server <url>", "Override ARP server base URL").option("--from-did <did>", "Sender DID \u2014 required only if multiple agents are registered against this server").option("--from <name>", "Signer agent NAME (handle) \u2014 alternative to --from-did, resolved against your local agents").option("--greeting <s>", "Optional greeting text included in body.content").option("--intent <s>", "Optional intent text included in body.content").option("--ttl <seconds>", `Envelope TTL in seconds (max ${import_sdk28.MAX_ENVELOPE_TTL_SECONDS} = 24h)`, "3600").option("--require-online", "Abort (exit 1, CLI_RECIPIENT_OFFLINE) if the recipient is not reachable now, instead of warning and sending to their inbox", false).option("--verbose", "Print the full envelope before sending and the full server response. Mutually exclusive with --json.", false).option(
7364
7409
  "--json",
7365
7410
  "Machine-readable mode \u2014 emit a single JSON object on stdout ({ok, eventId, relationshipId, relationshipEventIndex, serverTimestamp, signedMessageHash, serverEventHash, prevServerEventHash, senderSequence}). The Server/Sender/Recipient prelude moves to stderr so `--json | jq` stays byte-pure. Mutually exclusive with --verbose.",
7366
7411
  false
@@ -7377,10 +7422,11 @@ async function runSendHandshake(recipientDid, opts) {
7377
7422
  recipientDid = await resolveRecipient(opts.server, "send-handshake", recipientDid, { json: opts.json });
7378
7423
  const ttlSeconds = parseTtl3(opts.ttl);
7379
7424
  const api = new ArpApiClient(opts.server);
7380
- progress(opts.json, import_chalk30.default.dim(`Server: ${api.serverUrl}`));
7425
+ progress(opts.json, import_chalk31.default.dim(`Server: ${api.serverUrl}`));
7381
7426
  const sender = resolveSenderAgent("send-handshake", opts.server, opts.fromDid, opts.from);
7382
- progress(opts.json, import_chalk30.default.dim(`Sender: ${sender.did}`));
7383
- progress(opts.json, import_chalk30.default.dim(`Recipient: ${recipientDid}`));
7427
+ progress(opts.json, import_chalk31.default.dim(`Sender: ${sender.did}`));
7428
+ progress(opts.json, import_chalk31.default.dim(`Recipient: ${recipientDid}`));
7429
+ await guardRecipientReachable(api, recipientDid, { requireOnline: opts.requireOnline });
7384
7430
  const content = {};
7385
7431
  if (opts.greeting) content.greeting = opts.greeting;
7386
7432
  if (opts.intent) content.intent = opts.intent;
@@ -7406,7 +7452,7 @@ async function runSendHandshake(recipientDid, opts) {
7406
7452
  identitySecretKey: signer.identitySecretKey
7407
7453
  });
7408
7454
  if (opts.verbose) {
7409
- console.log(import_chalk30.default.bold("\nEnvelope (pre-send):"));
7455
+ console.log(import_chalk31.default.bold("\nEnvelope (pre-send):"));
7410
7456
  console.log(formatJson(envelope));
7411
7457
  }
7412
7458
  const result = await api.ingest(envelope);
@@ -7426,23 +7472,23 @@ async function runSendHandshake(recipientDid, opts) {
7426
7472
  });
7427
7473
  return;
7428
7474
  }
7429
- console.log(import_chalk30.default.green("\nDelivered."));
7430
- console.log(`${import_chalk30.default.bold("Event id")}: ${import_chalk30.default.cyan(result.eventId)}`);
7431
- console.log(`${import_chalk30.default.bold("Relationship id")}: ${import_chalk30.default.cyan(result.relationshipId)}`);
7432
- console.log(`${import_chalk30.default.bold("Chain index")}: ${import_chalk30.default.cyan(String(result.relationshipEventIndex))}`);
7433
- console.log(`${import_chalk30.default.bold("Server timestamp")}: ${import_chalk30.default.cyan(result.serverTimestamp)}`);
7434
- console.log(`${import_chalk30.default.bold("Signed message hash")}: ${import_chalk30.default.cyan(result.signedMessageHash)}`);
7435
- console.log(`${import_chalk30.default.bold("Server event hash")}: ${import_chalk30.default.cyan(result.serverEventHash)}`);
7475
+ console.log(import_chalk31.default.green("\nDelivered."));
7476
+ console.log(`${import_chalk31.default.bold("Event id")}: ${import_chalk31.default.cyan(result.eventId)}`);
7477
+ console.log(`${import_chalk31.default.bold("Relationship id")}: ${import_chalk31.default.cyan(result.relationshipId)}`);
7478
+ console.log(`${import_chalk31.default.bold("Chain index")}: ${import_chalk31.default.cyan(String(result.relationshipEventIndex))}`);
7479
+ console.log(`${import_chalk31.default.bold("Server timestamp")}: ${import_chalk31.default.cyan(result.serverTimestamp)}`);
7480
+ console.log(`${import_chalk31.default.bold("Signed message hash")}: ${import_chalk31.default.cyan(result.signedMessageHash)}`);
7481
+ console.log(`${import_chalk31.default.bold("Server event hash")}: ${import_chalk31.default.cyan(result.serverEventHash)}`);
7436
7482
  if (result.prevServerEventHash) {
7437
- console.log(`${import_chalk30.default.bold("Prev server event hash")}: ${import_chalk30.default.cyan(result.prevServerEventHash)}`);
7483
+ console.log(`${import_chalk31.default.bold("Prev server event hash")}: ${import_chalk31.default.cyan(result.prevServerEventHash)}`);
7438
7484
  } else {
7439
- console.log(`${import_chalk30.default.bold("Prev server event hash")}: ${import_chalk30.default.dim("(null \u2014 first event of this relationship)")}`);
7485
+ console.log(`${import_chalk31.default.bold("Prev server event hash")}: ${import_chalk31.default.dim("(null \u2014 first event of this relationship)")}`);
7440
7486
  }
7441
7487
  if (opts.verbose) {
7442
- console.log(import_chalk30.default.bold("\nFull server response:"));
7488
+ console.log(import_chalk31.default.bold("\nFull server response:"));
7443
7489
  console.log(formatJson(result));
7444
7490
  }
7445
- console.log(import_chalk30.default.dim(`
7491
+ console.log(import_chalk31.default.dim(`
7446
7492
  Local sender_sequence advanced to ${nextSequence}.`));
7447
7493
  }
7448
7494
  function parseTtl3(raw) {
@@ -7456,7 +7502,7 @@ function parseTtl3(raw) {
7456
7502
 
7457
7503
  // src/commands/send-handshake-response.ts
7458
7504
  var import_sdk29 = require("@heyanon-arp/sdk");
7459
- var import_chalk31 = __toESM(require("chalk"));
7505
+ var import_chalk32 = __toESM(require("chalk"));
7460
7506
  init_api();
7461
7507
  var ALLOWED_DECISIONS = new Set(import_sdk29.HANDSHAKE_DECISIONS);
7462
7508
  function registerSendHandshakeResponseCommand(root) {
@@ -7497,11 +7543,11 @@ async function runSendHandshakeResponse(recipientDid, opts) {
7497
7543
  declinePayload = detail ? { reason, reasonDetail: detail } : { reason };
7498
7544
  }
7499
7545
  const api = new ArpApiClient(opts.server);
7500
- progress(opts.json, import_chalk31.default.dim(`Server: ${api.serverUrl}`));
7546
+ progress(opts.json, import_chalk32.default.dim(`Server: ${api.serverUrl}`));
7501
7547
  const sender = resolveSenderAgent("send-handshake-response", opts.server, opts.fromDid, opts.from);
7502
- progress(opts.json, import_chalk31.default.dim(`Sender: ${sender.did}`));
7503
- progress(opts.json, import_chalk31.default.dim(`Recipient: ${recipientDid}`));
7504
- progress(opts.json, import_chalk31.default.dim(`Decision: ${decision}`));
7548
+ progress(opts.json, import_chalk32.default.dim(`Sender: ${sender.did}`));
7549
+ progress(opts.json, import_chalk32.default.dim(`Recipient: ${recipientDid}`));
7550
+ progress(opts.json, import_chalk32.default.dim(`Decision: ${decision}`));
7505
7551
  const signer = makeSigner(sender);
7506
7552
  if (!opts.force) {
7507
7553
  try {
@@ -7531,13 +7577,13 @@ async function runSendHandshakeResponse(recipientDid, opts) {
7531
7577
  });
7532
7578
  return;
7533
7579
  }
7534
- progress(opts.json, import_chalk31.default.yellow(`
7580
+ progress(opts.json, import_chalk32.default.yellow(`
7535
7581
  [--idempotency] Relationship ${existing.relationshipId} with ${recipientDid} is already 'active'.`));
7536
7582
  progress(
7537
7583
  opts.json,
7538
- import_chalk31.default.dim(`A previous accept from this signer (event ${previousResponseFromMe.eventId}) landed successfully. Skipping re-send (use --force to override).`)
7584
+ import_chalk32.default.dim(`A previous accept from this signer (event ${previousResponseFromMe.eventId}) landed successfully. Skipping re-send (use --force to override).`)
7539
7585
  );
7540
- progress(opts.json, import_chalk31.default.dim(`Last event index: ${existing.lastEventIndex}, last server event hash: ${existing.lastServerEventHash ?? "(none)"}`));
7586
+ progress(opts.json, import_chalk32.default.dim(`Last event index: ${existing.lastEventIndex}, last server event hash: ${existing.lastServerEventHash ?? "(none)"}`));
7541
7587
  return;
7542
7588
  }
7543
7589
  throw new Error(
@@ -7548,7 +7594,7 @@ async function runSendHandshakeResponse(recipientDid, opts) {
7548
7594
  if (probeErr instanceof Error && /CLOSED|terminated|already 'active' from a previous ACCEPT|original initiator/i.test(probeErr.message)) {
7549
7595
  throw probeErr;
7550
7596
  }
7551
- progress(opts.json, import_chalk31.default.dim(`(idempotency probe failed; proceeding anyway: ${probeErr.message})`));
7597
+ progress(opts.json, import_chalk32.default.dim(`(idempotency probe failed; proceeding anyway: ${probeErr.message})`));
7552
7598
  }
7553
7599
  }
7554
7600
  const content = { decision };
@@ -7578,7 +7624,7 @@ async function runSendHandshakeResponse(recipientDid, opts) {
7578
7624
  identitySecretKey: signer.identitySecretKey
7579
7625
  });
7580
7626
  if (opts.verbose) {
7581
- console.log(import_chalk31.default.bold("\nEnvelope (pre-send):"));
7627
+ console.log(import_chalk32.default.bold("\nEnvelope (pre-send):"));
7582
7628
  console.log(formatJson(envelope));
7583
7629
  }
7584
7630
  const result = await api.ingest(envelope);
@@ -7599,23 +7645,23 @@ async function runSendHandshakeResponse(recipientDid, opts) {
7599
7645
  });
7600
7646
  return;
7601
7647
  }
7602
- console.log(import_chalk31.default.green("\nDelivered."));
7603
- console.log(`${import_chalk31.default.bold("Event id")}: ${import_chalk31.default.cyan(result.eventId)}`);
7604
- console.log(`${import_chalk31.default.bold("Relationship id")}: ${import_chalk31.default.cyan(result.relationshipId)}`);
7605
- console.log(`${import_chalk31.default.bold("Chain index")}: ${import_chalk31.default.cyan(String(result.relationshipEventIndex))}`);
7606
- console.log(`${import_chalk31.default.bold("Server timestamp")}: ${import_chalk31.default.cyan(result.serverTimestamp)}`);
7607
- console.log(`${import_chalk31.default.bold("Signed message hash")}: ${import_chalk31.default.cyan(result.signedMessageHash)}`);
7608
- console.log(`${import_chalk31.default.bold("Server event hash")}: ${import_chalk31.default.cyan(result.serverEventHash)}`);
7648
+ console.log(import_chalk32.default.green("\nDelivered."));
7649
+ console.log(`${import_chalk32.default.bold("Event id")}: ${import_chalk32.default.cyan(result.eventId)}`);
7650
+ console.log(`${import_chalk32.default.bold("Relationship id")}: ${import_chalk32.default.cyan(result.relationshipId)}`);
7651
+ console.log(`${import_chalk32.default.bold("Chain index")}: ${import_chalk32.default.cyan(String(result.relationshipEventIndex))}`);
7652
+ console.log(`${import_chalk32.default.bold("Server timestamp")}: ${import_chalk32.default.cyan(result.serverTimestamp)}`);
7653
+ console.log(`${import_chalk32.default.bold("Signed message hash")}: ${import_chalk32.default.cyan(result.signedMessageHash)}`);
7654
+ console.log(`${import_chalk32.default.bold("Server event hash")}: ${import_chalk32.default.cyan(result.serverEventHash)}`);
7609
7655
  if (result.prevServerEventHash) {
7610
- console.log(`${import_chalk31.default.bold("Prev server event hash")}: ${import_chalk31.default.cyan(result.prevServerEventHash)}`);
7656
+ console.log(`${import_chalk32.default.bold("Prev server event hash")}: ${import_chalk32.default.cyan(result.prevServerEventHash)}`);
7611
7657
  } else {
7612
- console.log(`${import_chalk31.default.bold("Prev server event hash")}: ${import_chalk31.default.dim("(null \u2014 first event of this relationship)")}`);
7658
+ console.log(`${import_chalk32.default.bold("Prev server event hash")}: ${import_chalk32.default.dim("(null \u2014 first event of this relationship)")}`);
7613
7659
  }
7614
7660
  if (opts.verbose) {
7615
- console.log(import_chalk31.default.bold("\nFull server response:"));
7661
+ console.log(import_chalk32.default.bold("\nFull server response:"));
7616
7662
  console.log(formatJson(result));
7617
7663
  }
7618
- console.log(import_chalk31.default.dim(`
7664
+ console.log(import_chalk32.default.dim(`
7619
7665
  Local sender_sequence advanced to ${nextSequence}.`));
7620
7666
  }
7621
7667
  function parseDecision(raw) {
@@ -7666,7 +7712,7 @@ async function findExistingRelationship(api, signer, senderDid, recipientDid) {
7666
7712
  }
7667
7713
 
7668
7714
  // src/commands/watch.ts
7669
- var import_chalk32 = __toESM(require("chalk"));
7715
+ var import_chalk33 = __toESM(require("chalk"));
7670
7716
  init_api();
7671
7717
  function registerWatchCommand(root) {
7672
7718
  root.command("watch").description("Live tail filtered to a single relationship (SSE). Server-side $match; only envelopes belonging to <rel-id> are streamed.").argument("<relationship-id>", "Relationship UUID to watch").option("--server <url>", "Override ARP server base URL").option("--from-did <did>", "Signer DID \u2014 required only if multiple agents are registered against this server").option("--from <name>", "Signer agent NAME (handle) \u2014 alternative to --from-did, resolved against your local agents").option("--verbose", "After each envelope, print the full JSON with a per-row label including eventId + serverEventHash", false).option("--json", "Machine-readable: one NDJSON object per line. Pipe-safe into `jq -c`.", false).option("--full-ids", "Print DIDs + serverEventHash in full (no truncation).", false).action(async (relationshipId, opts) => {
@@ -7677,9 +7723,9 @@ async function runWatch(relationshipId, opts) {
7677
7723
  const local = resolveSenderAgent("watch", opts.server, opts.fromDid, opts.from);
7678
7724
  const api = new ArpApiClient(opts.server);
7679
7725
  if (!opts.json) {
7680
- console.log(import_chalk32.default.dim(`Server: ${api.serverUrl}`));
7681
- console.log(import_chalk32.default.dim(`Signer: ${local.did}`));
7682
- console.log(import_chalk32.default.dim(`Watching: ${relationshipId}`));
7726
+ console.log(import_chalk33.default.dim(`Server: ${api.serverUrl}`));
7727
+ console.log(import_chalk33.default.dim(`Signer: ${local.did}`));
7728
+ console.log(import_chalk33.default.dim(`Watching: ${relationshipId}`));
7683
7729
  }
7684
7730
  const controller = new AbortController();
7685
7731
  let userAborted = false;
@@ -7698,7 +7744,7 @@ async function runWatch(relationshipId, opts) {
7698
7744
  }
7699
7745
  if (event.type === "heartbeat") continue;
7700
7746
  if (event.type === "connected") {
7701
- console.log(import_chalk32.default.green(`\u25CF stream open \u2014 watching ${relationshipId}`));
7747
+ console.log(import_chalk33.default.green(`\u25CF stream open \u2014 watching ${relationshipId}`));
7702
7748
  continue;
7703
7749
  }
7704
7750
  if (event.type === "envelope") {
@@ -7712,7 +7758,7 @@ async function runWatch(relationshipId, opts) {
7712
7758
  }
7713
7759
  continue;
7714
7760
  }
7715
- console.log(import_chalk32.default.dim(`(unknown event: ${event.type})`));
7761
+ console.log(import_chalk33.default.dim(`(unknown event: ${event.type})`));
7716
7762
  }
7717
7763
  if (!userAborted) {
7718
7764
  throw new Error(`watch ${relationshipId}: stream ended unexpectedly (server may have restarted, or the change stream errored). Re-run to reconnect.`);
@@ -7720,7 +7766,7 @@ async function runWatch(relationshipId, opts) {
7720
7766
  } catch (err) {
7721
7767
  const name = err.name;
7722
7768
  if (name === "AbortError" || userAborted) {
7723
- if (!opts.json) console.log(import_chalk32.default.dim("\nstream closed."));
7769
+ if (!opts.json) console.log(import_chalk33.default.dim("\nstream closed."));
7724
7770
  return;
7725
7771
  }
7726
7772
  throw err;
@@ -7734,21 +7780,21 @@ function formatWatchLine(ev, selfDid, opts = {}) {
7734
7780
  const type = ev.type.padEnd(20);
7735
7781
  const direction = directionLabel2(ev, selfDid, opts);
7736
7782
  const hash = opts.fullIds ? ev.serverEventHash : hashHead4(ev.serverEventHash);
7737
- return `${import_chalk32.default.dim(`[${ts}]`)} ${type} ${direction} ${import_chalk32.default.cyan(hash)}`;
7783
+ return `${import_chalk33.default.dim(`[${ts}]`)} ${type} ${direction} ${import_chalk33.default.cyan(hash)}`;
7738
7784
  }
7739
7785
  function directionLabel2(ev, selfDid, opts = {}) {
7740
7786
  const senderHead = opts.fullIds ? ev.senderDid : didHead4(ev.senderDid);
7741
7787
  const recipientHead = opts.fullIds ? ev.recipientDid : didHead4(ev.recipientDid);
7742
- if (ev.senderDid === selfDid) return `${import_chalk32.default.bold("me")} \u2192 ${import_chalk32.default.dim(recipientHead)}`;
7743
- if (ev.recipientDid === selfDid) return `${import_chalk32.default.dim(senderHead)} \u2192 ${import_chalk32.default.bold("me")}`;
7744
- return `${import_chalk32.default.dim(senderHead)} \u2192 ${import_chalk32.default.dim(recipientHead)}`;
7788
+ if (ev.senderDid === selfDid) return `${import_chalk33.default.bold("me")} \u2192 ${import_chalk33.default.dim(recipientHead)}`;
7789
+ if (ev.recipientDid === selfDid) return `${import_chalk33.default.dim(senderHead)} \u2192 ${import_chalk33.default.bold("me")}`;
7790
+ return `${import_chalk33.default.dim(senderHead)} \u2192 ${import_chalk33.default.dim(recipientHead)}`;
7745
7791
  }
7746
7792
  function didHead4(did) {
7747
7793
  if (did.length <= 20) return did;
7748
7794
  return `${did.slice(0, 20)}...`;
7749
7795
  }
7750
7796
  function hashHead4(hash) {
7751
- if (!hash) return import_chalk32.default.dim("(none)");
7797
+ if (!hash) return import_chalk33.default.dim("(none)");
7752
7798
  if (hash.length <= 14) return hash;
7753
7799
  return `${hash.slice(0, 14)}...`;
7754
7800
  }
@@ -7760,7 +7806,7 @@ function formatClock(iso) {
7760
7806
  }
7761
7807
 
7762
7808
  // src/commands/whoami.ts
7763
- var import_chalk33 = __toESM(require("chalk"));
7809
+ var import_chalk34 = __toESM(require("chalk"));
7764
7810
  init_api();
7765
7811
  function registerWhoamiCommand(root) {
7766
7812
  root.command("whoami").description(
@@ -7791,12 +7837,12 @@ function registerWhoamiCommand(root) {
7791
7837
  if (opts.json) {
7792
7838
  console.log(formatJson({ ...localJson, account: credential ? { wallet: credential.wallet } : null }));
7793
7839
  } else {
7794
- console.log(import_chalk33.default.bold("Local agent:"));
7795
- console.log(` DID: ${import_chalk33.default.cyan(local.did)}`);
7796
- console.log(` Settlement pubkey: ${import_chalk33.default.cyan(local.settlementPublicKeyB58)}`);
7797
- console.log(` Identity pubkey: ${import_chalk33.default.cyan(local.identityPublicKeyB58)}`);
7840
+ console.log(import_chalk34.default.bold("Local agent:"));
7841
+ console.log(` DID: ${import_chalk34.default.cyan(local.did)}`);
7842
+ console.log(` Settlement pubkey: ${import_chalk34.default.cyan(local.settlementPublicKeyB58)}`);
7843
+ console.log(` Identity pubkey: ${import_chalk34.default.cyan(local.identityPublicKeyB58)}`);
7798
7844
  if (local.name) console.log(` Name: ${local.name}`);
7799
- console.log(` Account: ${credential ? import_chalk33.default.cyan(credential.wallet) : import_chalk33.default.dim("not logged in (heyarp login)")}`);
7845
+ console.log(` Account: ${credential ? import_chalk34.default.cyan(credential.wallet) : import_chalk34.default.dim("not logged in (heyarp login)")}`);
7800
7846
  }
7801
7847
  return;
7802
7848
  }
@@ -7814,19 +7860,19 @@ function registerWhoamiCommand(root) {
7814
7860
  if (opts.json) {
7815
7861
  console.log(formatJson({ local: localJson, account, server: agent }));
7816
7862
  } else {
7817
- console.log(import_chalk33.default.dim(`Server: ${api.serverUrl}`));
7818
- console.log(import_chalk33.default.bold("\nLocal agent:"));
7819
- console.log(` DID: ${import_chalk33.default.cyan(local.did)}`);
7820
- console.log(` Settlement pubkey: ${import_chalk33.default.cyan(local.settlementPublicKeyB58)}`);
7821
- console.log(` Identity pubkey: ${import_chalk33.default.cyan(local.identityPublicKeyB58)}`);
7822
- console.log(import_chalk33.default.bold("\nAccount:"));
7863
+ console.log(import_chalk34.default.dim(`Server: ${api.serverUrl}`));
7864
+ console.log(import_chalk34.default.bold("\nLocal agent:"));
7865
+ console.log(` DID: ${import_chalk34.default.cyan(local.did)}`);
7866
+ console.log(` Settlement pubkey: ${import_chalk34.default.cyan(local.settlementPublicKeyB58)}`);
7867
+ console.log(` Identity pubkey: ${import_chalk34.default.cyan(local.identityPublicKeyB58)}`);
7868
+ console.log(import_chalk34.default.bold("\nAccount:"));
7823
7869
  if (account) {
7824
- console.log(` Wallet: ${import_chalk33.default.cyan(account.wallet)}`);
7870
+ console.log(` Wallet: ${import_chalk34.default.cyan(account.wallet)}`);
7825
7871
  console.log(` Agents registered: ${account.agentCount}`);
7826
7872
  } else {
7827
- console.log(` ${import_chalk33.default.dim("not logged in (heyarp login)")}`);
7873
+ console.log(` ${import_chalk34.default.dim("not logged in (heyarp login)")}`);
7828
7874
  }
7829
- console.log(import_chalk33.default.bold("\nServer profile:"));
7875
+ console.log(import_chalk34.default.bold("\nServer profile:"));
7830
7876
  console.log(formatJson(agent));
7831
7877
  }
7832
7878
  } catch (err) {
@@ -7838,12 +7884,12 @@ function registerWhoamiCommand(root) {
7838
7884
 
7839
7885
  // src/commands/whois.ts
7840
7886
  var import_sdk30 = require("@heyanon-arp/sdk");
7841
- var import_chalk34 = __toESM(require("chalk"));
7887
+ var import_chalk35 = __toESM(require("chalk"));
7842
7888
  init_api();
7843
7889
  function registerWhoisCommand(root) {
7844
7890
  root.command("whois").description("Resolve an agent name (handle) or DID to its public profile \u2014 DID, description, reputation, liveness.").argument("<name-or-did>", "Agent name (handle) or DID (did:arp:...)").option("--server <url>", "Override ARP server base URL").option("--json", "Emit the full composed profile (DiscoveryProfile) as a single JSON object on stdout.", false).action(async (input, opts) => {
7845
7891
  const api = new ArpApiClient(opts.server);
7846
- progress(opts.json, import_chalk34.default.dim(`Server: ${api.serverUrl}`));
7892
+ progress(opts.json, import_chalk35.default.dim(`Server: ${api.serverUrl}`));
7847
7893
  const profile = await resolveProfile(api, input);
7848
7894
  if (opts.json) {
7849
7895
  jsonOut(profile);
@@ -7866,19 +7912,19 @@ async function resolveProfile(api, input) {
7866
7912
  return api.discoverByName(name);
7867
7913
  }
7868
7914
  function printProfile(p) {
7869
- console.log(`${import_chalk34.default.bold("Name")}: ${import_chalk34.default.cyan(p.name ?? "(unnamed)")}`);
7870
- console.log(`${import_chalk34.default.bold("DID")}: ${import_chalk34.default.cyan(p.did)}`);
7871
- if (p.description) console.log(`${import_chalk34.default.bold("Description")}: ${p.description}`);
7872
- if (p.tags.length > 0) console.log(`${import_chalk34.default.bold("Tags")}: ${p.tags.join(", ")}`);
7873
- console.log(`${import_chalk34.default.bold("Registered")}: ${p.registeredAt}`);
7915
+ console.log(`${import_chalk35.default.bold("Name")}: ${import_chalk35.default.cyan(p.name ?? "(unnamed)")}`);
7916
+ console.log(`${import_chalk35.default.bold("DID")}: ${import_chalk35.default.cyan(p.did)}`);
7917
+ if (p.description) console.log(`${import_chalk35.default.bold("Description")}: ${p.description}`);
7918
+ if (p.tags.length > 0) console.log(`${import_chalk35.default.bold("Tags")}: ${p.tags.join(", ")}`);
7919
+ console.log(`${import_chalk35.default.bold("Registered")}: ${p.registeredAt}`);
7874
7920
  const rep = p.reputation;
7875
- console.log(`${import_chalk34.default.bold("Reputation")}: composite ${rep.scores.composite}/100${rep.computed ? "" : import_chalk34.default.dim(" (cold-start \u2014 no settled cycles yet)")}`);
7876
- console.log(`${import_chalk34.default.bold("Online")}: ${p.liveness.online ? import_chalk34.default.green("yes") : import_chalk34.default.dim("no")}`);
7921
+ console.log(`${import_chalk35.default.bold("Reputation")}: composite ${rep.scores.composite}/100${rep.computed ? "" : import_chalk35.default.dim(" (cold-start \u2014 no settled cycles yet)")}`);
7922
+ console.log(`${import_chalk35.default.bold("Online")}: ${p.liveness.online ? import_chalk35.default.green("yes") : import_chalk35.default.dim("no")}`);
7877
7923
  }
7878
7924
 
7879
7925
  // src/commands/work.ts
7880
7926
  var import_sdk31 = require("@heyanon-arp/sdk");
7881
- var import_chalk35 = __toESM(require("chalk"));
7927
+ var import_chalk36 = __toESM(require("chalk"));
7882
7928
  init_api();
7883
7929
  function registerWorkCommands(root) {
7884
7930
  const cmd = root.command("work").description("Work envelopes inside an ACCEPTED delegation: request / respond");
@@ -7919,11 +7965,11 @@ async function runRequest(recipientDid, delegationId, opts) {
7919
7965
  params
7920
7966
  };
7921
7967
  const body = { type: "work_request", content };
7922
- progress(opts.json, import_chalk35.default.dim(`Server: ${api.serverUrl}`));
7923
- progress(opts.json, import_chalk35.default.dim(`Sender: ${sender.did}`));
7924
- progress(opts.json, import_chalk35.default.dim(`Recipient: ${recipientDid}`));
7925
- progress(opts.json, import_chalk35.default.dim(`Delegation: ${delegationId}`));
7926
- progress(opts.json, import_chalk35.default.dim(`Request id: ${requestId}`));
7968
+ progress(opts.json, import_chalk36.default.dim(`Server: ${api.serverUrl}`));
7969
+ progress(opts.json, import_chalk36.default.dim(`Sender: ${sender.did}`));
7970
+ progress(opts.json, import_chalk36.default.dim(`Recipient: ${recipientDid}`));
7971
+ progress(opts.json, import_chalk36.default.dim(`Delegation: ${delegationId}`));
7972
+ progress(opts.json, import_chalk36.default.dim(`Request id: ${requestId}`));
7927
7973
  const result = await sendWorkEnvelope({ api, sender, recipientDid, body, ttlSeconds, verbose: opts.verbose, server: opts.server });
7928
7974
  if (opts.json) {
7929
7975
  jsonOut({
@@ -7940,10 +7986,10 @@ async function runRequest(recipientDid, delegationId, opts) {
7940
7986
  });
7941
7987
  } else {
7942
7988
  printIngestResult3(result);
7943
- console.log(import_chalk35.default.dim(`
7989
+ console.log(import_chalk36.default.dim(`
7944
7990
  The payee can reply with:`));
7945
- console.log(import_chalk35.default.dim(` heyarp work respond ${result.relationshipId} ${delegationId} ${requestId} --output '<json>'`));
7946
- console.log(import_chalk35.default.dim(` heyarp work respond ${result.relationshipId} ${delegationId} ${requestId} --error CODE:message`));
7991
+ console.log(import_chalk36.default.dim(` heyarp work respond ${result.relationshipId} ${delegationId} ${requestId} --output '<json>'`));
7992
+ console.log(import_chalk36.default.dim(` heyarp work respond ${result.relationshipId} ${delegationId} ${requestId} --error CODE:message`));
7947
7993
  }
7948
7994
  }
7949
7995
  function registerRespond(parent) {
@@ -7978,13 +8024,13 @@ async function runRespond(relationshipId, delegationId, requestId, opts) {
7978
8024
  ...responsePayload
7979
8025
  };
7980
8026
  const body = { type: "work_response", content };
7981
- progress(opts.json, import_chalk35.default.dim(`Server: ${api.serverUrl}`));
7982
- progress(opts.json, import_chalk35.default.dim(`Sender: ${sender.did}`));
7983
- progress(opts.json, import_chalk35.default.dim(`Recipient: ${recipientDid}`));
7984
- progress(opts.json, import_chalk35.default.dim(`Relationship: ${relationshipId}`));
7985
- progress(opts.json, import_chalk35.default.dim(`Delegation: ${delegationId}`));
7986
- progress(opts.json, import_chalk35.default.dim(`Request id: ${requestId}`));
7987
- progress(opts.json, import_chalk35.default.dim(`Outcome: ${responsePayload.output ? "success" : "error"}`));
8027
+ progress(opts.json, import_chalk36.default.dim(`Server: ${api.serverUrl}`));
8028
+ progress(opts.json, import_chalk36.default.dim(`Sender: ${sender.did}`));
8029
+ progress(opts.json, import_chalk36.default.dim(`Recipient: ${recipientDid}`));
8030
+ progress(opts.json, import_chalk36.default.dim(`Relationship: ${relationshipId}`));
8031
+ progress(opts.json, import_chalk36.default.dim(`Delegation: ${delegationId}`));
8032
+ progress(opts.json, import_chalk36.default.dim(`Request id: ${requestId}`));
8033
+ progress(opts.json, import_chalk36.default.dim(`Outcome: ${responsePayload.output ? "success" : "error"}`));
7988
8034
  const result = await sendWorkEnvelope({ api, sender, recipientDid, body, ttlSeconds, verbose: opts.verbose, server: opts.server });
7989
8035
  if (opts.json) {
7990
8036
  jsonOut({
@@ -8025,7 +8071,7 @@ async function sendWorkEnvelope(args) {
8025
8071
  identitySecretKey: signer.identitySecretKey
8026
8072
  });
8027
8073
  if (args.verbose) {
8028
- console.log(import_chalk35.default.bold("\nEnvelope (pre-send):"));
8074
+ console.log(import_chalk36.default.bold("\nEnvelope (pre-send):"));
8029
8075
  console.log(formatJson(envelope));
8030
8076
  }
8031
8077
  try {
@@ -8065,12 +8111,12 @@ async function resolveResponseRecipient(cmdName, api, signer, args) {
8065
8111
  );
8066
8112
  }
8067
8113
  function printIngestResult3(result) {
8068
- console.log(import_chalk35.default.green("\nDelivered."));
8069
- console.log(`${import_chalk35.default.bold("Event id")}: ${import_chalk35.default.cyan(result.eventId)}`);
8070
- console.log(`${import_chalk35.default.bold("Relationship id")}: ${import_chalk35.default.cyan(result.relationshipId)}`);
8071
- console.log(`${import_chalk35.default.bold("Chain index")}: ${import_chalk35.default.cyan(String(result.relationshipEventIndex))}`);
8072
- console.log(`${import_chalk35.default.bold("Server timestamp")}: ${import_chalk35.default.cyan(result.serverTimestamp)}`);
8073
- console.log(`${import_chalk35.default.bold("Server event hash")}: ${import_chalk35.default.cyan(result.serverEventHash)}`);
8114
+ console.log(import_chalk36.default.green("\nDelivered."));
8115
+ console.log(`${import_chalk36.default.bold("Event id")}: ${import_chalk36.default.cyan(result.eventId)}`);
8116
+ console.log(`${import_chalk36.default.bold("Relationship id")}: ${import_chalk36.default.cyan(result.relationshipId)}`);
8117
+ console.log(`${import_chalk36.default.bold("Chain index")}: ${import_chalk36.default.cyan(String(result.relationshipEventIndex))}`);
8118
+ console.log(`${import_chalk36.default.bold("Server timestamp")}: ${import_chalk36.default.cyan(result.serverTimestamp)}`);
8119
+ console.log(`${import_chalk36.default.bold("Server event hash")}: ${import_chalk36.default.cyan(result.serverEventHash)}`);
8074
8120
  }
8075
8121
  function parseJsonObject(cmdName, flagName, raw) {
8076
8122
  let parsed;
@@ -8172,7 +8218,7 @@ function parseRequestId(cmdName, raw) {
8172
8218
 
8173
8219
  // src/commands/work-list.ts
8174
8220
  var import_sdk32 = require("@heyanon-arp/sdk");
8175
- var import_chalk36 = __toESM(require("chalk"));
8221
+ var import_chalk37 = __toESM(require("chalk"));
8176
8222
  init_api();
8177
8223
  var ALLOWED_STATES3 = new Set(import_sdk32.WORK_LOG_STATES);
8178
8224
  function registerWorkListCommand(root) {
@@ -8199,9 +8245,9 @@ async function runWorkList(relationshipId, opts) {
8199
8245
  const api = new ArpApiClient(opts.server);
8200
8246
  const sender = resolveSenderAgent("work-list", opts.server, opts.fromDid, opts.from);
8201
8247
  if (!opts.json) {
8202
- console.log(import_chalk36.default.dim(`Server: ${api.serverUrl}`));
8203
- console.log(import_chalk36.default.dim(`Signer: ${sender.did}`));
8204
- console.log(import_chalk36.default.dim(`Relationship: ${relationshipId}`));
8248
+ console.log(import_chalk37.default.dim(`Server: ${api.serverUrl}`));
8249
+ console.log(import_chalk37.default.dim(`Signer: ${sender.did}`));
8250
+ console.log(import_chalk37.default.dim(`Relationship: ${relationshipId}`));
8205
8251
  }
8206
8252
  const query = { limit };
8207
8253
  if (state) query.state = state;
@@ -8214,7 +8260,7 @@ async function runWorkList(relationshipId, opts) {
8214
8260
  return;
8215
8261
  }
8216
8262
  if (rows.length === 0) {
8217
- console.log(import_chalk36.default.dim("\n(no work-logs for this relationship)"));
8263
+ console.log(import_chalk37.default.dim("\n(no work-logs for this relationship)"));
8218
8264
  return;
8219
8265
  }
8220
8266
  console.log("");
@@ -8231,36 +8277,36 @@ async function runWorkList(relationshipId, opts) {
8231
8277
  }));
8232
8278
  }
8233
8279
  const lastId = rows[rows.length - 1].id;
8234
- console.log(import_chalk36.default.dim(`
8280
+ console.log(import_chalk37.default.dim(`
8235
8281
  ${rows.length} work-log row(s). Paginate with --after ${lastId}.`));
8236
8282
  }
8237
8283
  function formatWorkLogLine(w, selfDid, opts = {}) {
8238
8284
  const delegationPart = opts.fullIds ? w.delegationId : idHead3(w.delegationId);
8239
8285
  const requestPart = opts.fullIds ? w.requestId : truncate3(w.requestId, 16);
8240
- const id = import_chalk36.default.bold(`${delegationPart}/${requestPart}`);
8286
+ const id = import_chalk37.default.bold(`${delegationPart}/${requestPart}`);
8241
8287
  const state = colorState2(w.state).padEnd(stateColumnWidth2());
8242
8288
  const peerCallerHead = opts.fullIds ? w.callerDid : didHead5(w.callerDid);
8243
8289
  const peerPayeeHead = opts.fullIds ? w.payeeDid : didHead5(w.payeeDid);
8244
- const direction = w.callerDid === selfDid ? `${import_chalk36.default.bold("me")} \u2192 ${import_chalk36.default.dim(peerPayeeHead)}` : `${import_chalk36.default.dim(peerCallerHead)} \u2192 ${import_chalk36.default.bold("me")}`;
8290
+ const direction = w.callerDid === selfDid ? `${import_chalk37.default.bold("me")} \u2192 ${import_chalk37.default.dim(peerPayeeHead)}` : `${import_chalk37.default.dim(peerCallerHead)} \u2192 ${import_chalk37.default.bold("me")}`;
8245
8291
  const outcome = formatOutcome(w);
8246
8292
  return `${id} ${state} ${direction} ${outcome}`;
8247
8293
  }
8248
8294
  function colorState2(s) {
8249
8295
  switch (s) {
8250
8296
  case import_sdk32.WorkLogStates.REQUESTED:
8251
- return import_chalk36.default.yellow("requested");
8297
+ return import_chalk37.default.yellow("requested");
8252
8298
  case import_sdk32.WorkLogStates.RESPONDED:
8253
- return import_chalk36.default.green("responded");
8299
+ return import_chalk37.default.green("responded");
8254
8300
  }
8255
8301
  }
8256
8302
  function stateColumnWidth2() {
8257
8303
  return 9;
8258
8304
  }
8259
8305
  function formatOutcome(w) {
8260
- if (w.state === import_sdk32.WorkLogStates.REQUESTED) return import_chalk36.default.dim("(in flight)");
8261
- if (w.responseError) return import_chalk36.default.red(`error ${w.responseError.code}: ${truncate3(w.responseError.message, 32)}`);
8262
- if (w.responseOutput) return import_chalk36.default.cyan("ok");
8263
- return import_chalk36.default.dim("(empty response)");
8306
+ if (w.state === import_sdk32.WorkLogStates.REQUESTED) return import_chalk37.default.dim("(in flight)");
8307
+ if (w.responseError) return import_chalk37.default.red(`error ${w.responseError.code}: ${truncate3(w.responseError.message, 32)}`);
8308
+ if (w.responseOutput) return import_chalk37.default.cyan("ok");
8309
+ return import_chalk37.default.dim("(empty response)");
8264
8310
  }
8265
8311
  function idHead3(id) {
8266
8312
  if (id.length <= 12) return id;