@heyanon-arp/cli 0.0.28 → 0.0.30

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
@@ -337,6 +337,11 @@ var init_api = __esm({
337
337
  if (query?.accountId !== void 0) params.set("accountId", query.accountId);
338
338
  if (query?.accepts !== void 0) params.set("accepts", query.accepts);
339
339
  if (query?.online) params.set("online", "true");
340
+ if (query?.trustedOnly) params.set("trustedOnly", "true");
341
+ if (query?.includeUnproven === false) params.set("includeUnproven", "false");
342
+ if (query?.minOnchainCycles !== void 0) params.set("minOnchainCycles", String(query.minOnchainCycles));
343
+ if (query?.minCompletedAsPayee !== void 0) params.set("minCompletedAsPayee", String(query.minCompletedAsPayee));
344
+ if (query?.minDistinctCounterparts !== void 0) params.set("minDistinctCounterparts", String(query.minDistinctCounterparts));
340
345
  if (query?.sort !== void 0) params.set("sort", query.sort);
341
346
  if (query?.page !== void 0) params.set("page", String(query.page));
342
347
  if (query?.after !== void 0) params.set("after", query.after);
@@ -736,7 +741,7 @@ var import_commander = require("commander");
736
741
  // package.json
737
742
  var package_default = {
738
743
  name: "@heyanon-arp/cli",
739
- version: "0.0.28",
744
+ version: "0.0.30",
740
745
  description: "Command-line client for the Agent Relationship Protocol \u2014 register agents, sign envelopes, run escrowed work cycles on Solana.",
741
746
  license: "MIT",
742
747
  keywords: ["arp", "agent-relationship-protocol", "did", "solana", "escrow", "ed25519", "agents", "a2a", "cli"],
@@ -1114,6 +1119,15 @@ function updateAgentLocal(serverOverride, did, patch) {
1114
1119
  server.agents[did] = { ...server.agents[did], ...patch };
1115
1120
  return writeStateFile(state);
1116
1121
  }
1122
+ function deleteAgent(serverOverride, did) {
1123
+ const key = resolveServerUrl(serverOverride);
1124
+ const state = readStateFile();
1125
+ const server = state.servers[key];
1126
+ if (!server || !server.agents[did]) return { removed: false, chmodOk: true };
1127
+ delete server.agents[did];
1128
+ const { chmodOk } = writeStateFile(state);
1129
+ return { removed: true, chmodOk };
1130
+ }
1117
1131
  function toKeyBundle(agent, exportedAt) {
1118
1132
  return {
1119
1133
  did: agent.did,
@@ -1300,7 +1314,7 @@ ${verb}.`));
1300
1314
  function registerAgentsCommand(root) {
1301
1315
  const agents = root.command("agents").description(
1302
1316
  "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."
1303
- ).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(
1317
+ ).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("--trusted-only", "Return only platform-trusted agents (the manual allow-list flag \u2014 NOT earned reputation)", false).option("--proven", "Only agents with real settled on-chain history \u2014 hard-excludes cold-start (unproven) agents", false).option("--min-cycles <n>", "Hard filter: minimum settled on-chain cycles").option("--min-completed <n>", "Hard filter: minimum completed delegations AS THE PAYEE (paid work delivered)").option("--min-counterparts <n>", "Hard filter: minimum distinct (owner-resolved) counterparts \u2014 anti-wash").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(
1304
1318
  "--verbose",
1305
1319
  '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)',
1306
1320
  false
@@ -1338,6 +1352,11 @@ async function runAgents(opts) {
1338
1352
  if (opts.accountId) query.accountId = opts.accountId;
1339
1353
  if (opts.accepts) query.accepts = resolveAcceptsAsset(opts.accepts);
1340
1354
  if (!opts.all) query.online = true;
1355
+ if (opts.trustedOnly) query.trustedOnly = true;
1356
+ if (opts.proven) query.includeUnproven = false;
1357
+ if (opts.minCycles !== void 0) query.minOnchainCycles = parseNonNegInt(opts.minCycles, "--min-cycles");
1358
+ if (opts.minCompleted !== void 0) query.minCompletedAsPayee = parseNonNegInt(opts.minCompleted, "--min-completed");
1359
+ if (opts.minCounterparts !== void 0) query.minDistinctCounterparts = parseNonNegInt(opts.minCounterparts, "--min-counterparts");
1341
1360
  if (sort === import_sdk3.DiscoverySorts.CREATED) {
1342
1361
  if (opts.after) query.after = opts.after;
1343
1362
  } else {
@@ -1393,7 +1412,21 @@ function formatAgentLine(a, opts = {}) {
1393
1412
  const description = a.description ? `\u2014 ${import_chalk3.default.dim(truncate(sanitizeForTerminal(a.description), 60))}` : "";
1394
1413
  const rep = `${import_chalk3.default.cyan(`rep${a.reputation.composite.toFixed(0)}`)}${a.reputation.computed ? "" : import_chalk3.default.dim("*")}`;
1395
1414
  const live = a.liveness.online ? import_chalk3.default.green("\u25CF") : import_chalk3.default.dim("\u25CB");
1396
- return `${import_chalk3.default.dim(idDisplay)} ${import_chalk3.default.cyan(a.did)} ${rep} ${live} ${import_chalk3.default.magenta(tags)} ${name} ${description}`.trim();
1415
+ const badge = formatBadge(a.badge);
1416
+ const trust = a.trusted ? ` ${import_chalk3.default.blue("\u2713trusted")}` : "";
1417
+ return `${import_chalk3.default.dim(idDisplay)} ${import_chalk3.default.cyan(a.did)} ${rep} ${badge} ${live} ${import_chalk3.default.magenta(tags)} ${name}${trust} ${description}`.trim();
1418
+ }
1419
+ function formatBadge(badge) {
1420
+ switch (badge) {
1421
+ case "proven":
1422
+ return import_chalk3.default.green("proven");
1423
+ case "limited":
1424
+ return import_chalk3.default.yellow("limited");
1425
+ case "flagged":
1426
+ return import_chalk3.default.red("flagged");
1427
+ default:
1428
+ return import_chalk3.default.dim("new");
1429
+ }
1397
1430
  }
1398
1431
  function truncate(s, max) {
1399
1432
  if (s.length <= max) return s;
@@ -1418,6 +1451,13 @@ function parsePage(raw) {
1418
1451
  }
1419
1452
  return n;
1420
1453
  }
1454
+ function parseNonNegInt(raw, flag) {
1455
+ const n = Number(raw);
1456
+ if (!Number.isFinite(n) || !Number.isInteger(n) || n < 0) {
1457
+ throw new Error(`agents: ${flag} must be a non-negative integer (got '${raw}')`);
1458
+ }
1459
+ return n;
1460
+ }
1421
1461
  function resolveAcceptsAsset(input) {
1422
1462
  const resolved = (0, import_sdk3.resolveAsset)(input);
1423
1463
  if (!resolved) {
@@ -6971,8 +7011,11 @@ function accumulate3(value, previous) {
6971
7011
  }
6972
7012
  var defaultRegisterDeps = {
6973
7013
  makeApi: (serverOverride) => new ArpApiClient(serverOverride),
6974
- save: saveAgent
7014
+ save: saveAgent,
7015
+ deleteAgent,
7016
+ loadAgent
6975
7017
  };
7018
+ var AGENT_ALREADY_REGISTERED_CODE = "AGENT_ALREADY_REGISTERED";
6976
7019
  async function runRegister(opts, deps = defaultRegisterDeps) {
6977
7020
  assertJsonRequiresYes(opts);
6978
7021
  const api = deps.makeApi(opts.server);
@@ -7051,6 +7094,7 @@ async function runRegister(opts, deps = defaultRegisterDeps) {
7051
7094
  tags: answers.tags.length > 0 ? answers.tags : void 0,
7052
7095
  registeredAt: (/* @__PURE__ */ new Date()).toISOString()
7053
7096
  };
7097
+ const hadLocalRecordBeforeRegister = deps.loadAgent(opts.server, did) != null;
7054
7098
  deps.save(opts.server, durableState);
7055
7099
  let result;
7056
7100
  try {
@@ -7061,6 +7105,13 @@ async function runRegister(opts, deps = defaultRegisterDeps) {
7061
7105
  `register: the stored login token for ${api.serverUrl} was rejected (${err.payload.message}) \u2014 run 'heyarp login' again. Your keys are saved locally; re-running register with --from-keys is safe.`
7062
7106
  );
7063
7107
  }
7108
+ const provesServerDidNotRegister = err instanceof ApiError && err.status >= 400 && err.status < 500 && err.payload.code !== AGENT_ALREADY_REGISTERED_CODE;
7109
+ if (provesServerDidNotRegister && !hadLocalRecordBeforeRegister) {
7110
+ try {
7111
+ deps.deleteAgent(opts.server, did);
7112
+ } catch {
7113
+ }
7114
+ }
7064
7115
  throw err;
7065
7116
  }
7066
7117
  if (result.did !== did) {