@heyanon-arp/cli 0.0.25 → 0.0.26
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 +136 -76
- package/dist/cli.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -322,6 +322,9 @@ var init_api = __esm({
|
|
|
322
322
|
async getReputation(did) {
|
|
323
323
|
return this.get(`/v1/agents/${encodeURIComponent(did)}/reputation`);
|
|
324
324
|
}
|
|
325
|
+
async getStats(did) {
|
|
326
|
+
return this.get(`/v1/agents/${encodeURIComponent(did)}/stats`);
|
|
327
|
+
}
|
|
325
328
|
/**
|
|
326
329
|
* Public `GET /v1/discovery/search`. Reputation-ranked agent search
|
|
327
330
|
* with creator / liveness / accepted-asset filters. No auth.
|
|
@@ -733,7 +736,7 @@ var import_commander = require("commander");
|
|
|
733
736
|
// package.json
|
|
734
737
|
var package_default = {
|
|
735
738
|
name: "@heyanon-arp/cli",
|
|
736
|
-
version: "0.0.
|
|
739
|
+
version: "0.0.26",
|
|
737
740
|
description: "Command-line client for the Agent Relationship Protocol \u2014 register agents, sign envelopes, run escrowed work cycles on Solana.",
|
|
738
741
|
license: "MIT",
|
|
739
742
|
keywords: ["arp", "agent-relationship-protocol", "did", "solana", "escrow", "ed25519", "agents", "a2a", "cli"],
|
|
@@ -4722,8 +4725,8 @@ function formatEscrowConfigStatus(serverUrl, s) {
|
|
|
4722
4725
|
lines.push("");
|
|
4723
4726
|
lines.push(import_chalk14.default.dim(` New locks will snapshot fee_bps=0 \u2014 payee receives 100% on claim.`));
|
|
4724
4727
|
} else {
|
|
4725
|
-
const
|
|
4726
|
-
lines.push(` ${import_chalk14.default.yellow("ENABLED")} \u2014 ${
|
|
4728
|
+
const pct2 = (s.feeBps / 100).toFixed(2);
|
|
4729
|
+
lines.push(` ${import_chalk14.default.yellow("ENABLED")} \u2014 ${pct2}% of payee slice (${s.feeBps} bps)`);
|
|
4727
4730
|
lines.push(` ${import_chalk14.default.dim("fee_recipient:")} ${s.feeRecipient}`);
|
|
4728
4731
|
lines.push("");
|
|
4729
4732
|
lines.push(import_chalk14.default.dim(` New locks will snapshot fee_bps=${s.feeBps} onto themselves.`));
|
|
@@ -7711,9 +7714,65 @@ async function findExistingRelationship(api, signer, senderDid, recipientDid) {
|
|
|
7711
7714
|
return void 0;
|
|
7712
7715
|
}
|
|
7713
7716
|
|
|
7714
|
-
// src/commands/
|
|
7717
|
+
// src/commands/stats.ts
|
|
7715
7718
|
var import_chalk33 = __toESM(require("chalk"));
|
|
7716
7719
|
init_api();
|
|
7720
|
+
function registerStatsCommand(root) {
|
|
7721
|
+
root.command("stats").description("Show an agent's public stats \u2014 counters, 0..100 scores, derived rates, and settled on-chain volume by asset. Public, no auth.").argument("<agent>", "Agent name (handle) or did:arp:<base58btc>").option("--server <url>", "Override ARP server base URL").option("--json", "Emit the stats as JSON on stdout.", false).action(async (agent, opts) => {
|
|
7722
|
+
const did = await resolveRecipient(opts.server, "stats", agent, { json: opts.json });
|
|
7723
|
+
const api = new ArpApiClient(opts.server);
|
|
7724
|
+
const stats = await api.getStats(did);
|
|
7725
|
+
if (opts.json) {
|
|
7726
|
+
jsonOut(stats);
|
|
7727
|
+
return;
|
|
7728
|
+
}
|
|
7729
|
+
const j = false;
|
|
7730
|
+
const { counters: c, scores: s, rates: r, volume: v } = stats;
|
|
7731
|
+
progress(j, import_chalk33.default.bold(`Stats \u2014 ${did}`));
|
|
7732
|
+
progress(j, import_chalk33.default.dim(` ${stats.computed ? "computed" : "cold-start (no settled cycle yet)"}`));
|
|
7733
|
+
progress(j, "");
|
|
7734
|
+
progress(
|
|
7735
|
+
j,
|
|
7736
|
+
` scores composite ${s.composite.toFixed(0)} \xB7 reliability ${s.reliability.toFixed(0)} \xB7 settlement ${s.settlement.toFixed(0)} \xB7 disputeHealth ${s.disputeHealth.toFixed(0)}`
|
|
7737
|
+
);
|
|
7738
|
+
progress(j, ` rates completion ${pct(r.completionRate)} \xB7 dispute ${pct(r.disputeRate)} \xB7 adverse ${pct(r.adverseDisputeRate)}`);
|
|
7739
|
+
progress(
|
|
7740
|
+
j,
|
|
7741
|
+
` cycles on-chain ${c.onchainCycles} \xB7 completed ${c.completedDelegations} (payer ${c.completedAsPayer} / payee ${c.completedAsPayee}) \xB7 failed ${c.failedDelegations}`
|
|
7742
|
+
);
|
|
7743
|
+
progress(j, ` escrows settled ${c.settledEscrows} / refunded ${c.refundedEscrows} \xB7 disputed ${c.disputedEscrows} (adverse ${c.disputesAdverse})`);
|
|
7744
|
+
progress(j, ` network distinct counterparts ${c.distinctCounterparts} \xB7 active relationships ${c.activeRelationships}`);
|
|
7745
|
+
progress(j, "");
|
|
7746
|
+
progress(j, import_chalk33.default.dim(" earned (as payee):"));
|
|
7747
|
+
renderAssets(v.earnedByAsset);
|
|
7748
|
+
progress(j, import_chalk33.default.dim(" paid (as payer):"));
|
|
7749
|
+
renderAssets(v.paidByAsset);
|
|
7750
|
+
if (v.firstSettledAt || v.lastSettledAt) {
|
|
7751
|
+
progress(j, "");
|
|
7752
|
+
progress(j, import_chalk33.default.dim(` settled span: ${v.firstSettledAt ?? "?"} \u2192 ${v.lastSettledAt ?? "?"}`));
|
|
7753
|
+
}
|
|
7754
|
+
progress(j, "");
|
|
7755
|
+
progress(j, import_chalk33.default.dim(" Public, informational \u2014 derived from on-chain settlement; cached briefly."));
|
|
7756
|
+
});
|
|
7757
|
+
}
|
|
7758
|
+
function pct(r) {
|
|
7759
|
+
return r == null ? "n/a" : `${(r * 100).toFixed(0)}%`;
|
|
7760
|
+
}
|
|
7761
|
+
function renderAssets(assets) {
|
|
7762
|
+
if (assets.length === 0) {
|
|
7763
|
+
progress(false, import_chalk33.default.dim(" (none)"));
|
|
7764
|
+
return;
|
|
7765
|
+
}
|
|
7766
|
+
for (const a of assets) {
|
|
7767
|
+
const label = a.symbol ?? `${a.mint.slice(0, 6)}\u2026`;
|
|
7768
|
+
const amount = a.amountDecimal ?? `${a.amountBaseUnits} base-units`;
|
|
7769
|
+
progress(false, ` ${amount} ${label} ${import_chalk33.default.dim(`(${a.lockCount} lock${a.lockCount === 1 ? "" : "s"})`)}`);
|
|
7770
|
+
}
|
|
7771
|
+
}
|
|
7772
|
+
|
|
7773
|
+
// src/commands/watch.ts
|
|
7774
|
+
var import_chalk34 = __toESM(require("chalk"));
|
|
7775
|
+
init_api();
|
|
7717
7776
|
function registerWatchCommand(root) {
|
|
7718
7777
|
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) => {
|
|
7719
7778
|
await runWatch(relationshipId, opts);
|
|
@@ -7723,9 +7782,9 @@ async function runWatch(relationshipId, opts) {
|
|
|
7723
7782
|
const local = resolveSenderAgent("watch", opts.server, opts.fromDid, opts.from);
|
|
7724
7783
|
const api = new ArpApiClient(opts.server);
|
|
7725
7784
|
if (!opts.json) {
|
|
7726
|
-
console.log(
|
|
7727
|
-
console.log(
|
|
7728
|
-
console.log(
|
|
7785
|
+
console.log(import_chalk34.default.dim(`Server: ${api.serverUrl}`));
|
|
7786
|
+
console.log(import_chalk34.default.dim(`Signer: ${local.did}`));
|
|
7787
|
+
console.log(import_chalk34.default.dim(`Watching: ${relationshipId}`));
|
|
7729
7788
|
}
|
|
7730
7789
|
const controller = new AbortController();
|
|
7731
7790
|
let userAborted = false;
|
|
@@ -7744,7 +7803,7 @@ async function runWatch(relationshipId, opts) {
|
|
|
7744
7803
|
}
|
|
7745
7804
|
if (event.type === "heartbeat") continue;
|
|
7746
7805
|
if (event.type === "connected") {
|
|
7747
|
-
console.log(
|
|
7806
|
+
console.log(import_chalk34.default.green(`\u25CF stream open \u2014 watching ${relationshipId}`));
|
|
7748
7807
|
continue;
|
|
7749
7808
|
}
|
|
7750
7809
|
if (event.type === "envelope") {
|
|
@@ -7758,7 +7817,7 @@ async function runWatch(relationshipId, opts) {
|
|
|
7758
7817
|
}
|
|
7759
7818
|
continue;
|
|
7760
7819
|
}
|
|
7761
|
-
console.log(
|
|
7820
|
+
console.log(import_chalk34.default.dim(`(unknown event: ${event.type})`));
|
|
7762
7821
|
}
|
|
7763
7822
|
if (!userAborted) {
|
|
7764
7823
|
throw new Error(`watch ${relationshipId}: stream ended unexpectedly (server may have restarted, or the change stream errored). Re-run to reconnect.`);
|
|
@@ -7766,7 +7825,7 @@ async function runWatch(relationshipId, opts) {
|
|
|
7766
7825
|
} catch (err) {
|
|
7767
7826
|
const name = err.name;
|
|
7768
7827
|
if (name === "AbortError" || userAborted) {
|
|
7769
|
-
if (!opts.json) console.log(
|
|
7828
|
+
if (!opts.json) console.log(import_chalk34.default.dim("\nstream closed."));
|
|
7770
7829
|
return;
|
|
7771
7830
|
}
|
|
7772
7831
|
throw err;
|
|
@@ -7780,21 +7839,21 @@ function formatWatchLine(ev, selfDid, opts = {}) {
|
|
|
7780
7839
|
const type = ev.type.padEnd(20);
|
|
7781
7840
|
const direction = directionLabel2(ev, selfDid, opts);
|
|
7782
7841
|
const hash = opts.fullIds ? ev.serverEventHash : hashHead4(ev.serverEventHash);
|
|
7783
|
-
return `${
|
|
7842
|
+
return `${import_chalk34.default.dim(`[${ts}]`)} ${type} ${direction} ${import_chalk34.default.cyan(hash)}`;
|
|
7784
7843
|
}
|
|
7785
7844
|
function directionLabel2(ev, selfDid, opts = {}) {
|
|
7786
7845
|
const senderHead = opts.fullIds ? ev.senderDid : didHead4(ev.senderDid);
|
|
7787
7846
|
const recipientHead = opts.fullIds ? ev.recipientDid : didHead4(ev.recipientDid);
|
|
7788
|
-
if (ev.senderDid === selfDid) return `${
|
|
7789
|
-
if (ev.recipientDid === selfDid) return `${
|
|
7790
|
-
return `${
|
|
7847
|
+
if (ev.senderDid === selfDid) return `${import_chalk34.default.bold("me")} \u2192 ${import_chalk34.default.dim(recipientHead)}`;
|
|
7848
|
+
if (ev.recipientDid === selfDid) return `${import_chalk34.default.dim(senderHead)} \u2192 ${import_chalk34.default.bold("me")}`;
|
|
7849
|
+
return `${import_chalk34.default.dim(senderHead)} \u2192 ${import_chalk34.default.dim(recipientHead)}`;
|
|
7791
7850
|
}
|
|
7792
7851
|
function didHead4(did) {
|
|
7793
7852
|
if (did.length <= 20) return did;
|
|
7794
7853
|
return `${did.slice(0, 20)}...`;
|
|
7795
7854
|
}
|
|
7796
7855
|
function hashHead4(hash) {
|
|
7797
|
-
if (!hash) return
|
|
7856
|
+
if (!hash) return import_chalk34.default.dim("(none)");
|
|
7798
7857
|
if (hash.length <= 14) return hash;
|
|
7799
7858
|
return `${hash.slice(0, 14)}...`;
|
|
7800
7859
|
}
|
|
@@ -7806,7 +7865,7 @@ function formatClock(iso) {
|
|
|
7806
7865
|
}
|
|
7807
7866
|
|
|
7808
7867
|
// src/commands/whoami.ts
|
|
7809
|
-
var
|
|
7868
|
+
var import_chalk35 = __toESM(require("chalk"));
|
|
7810
7869
|
init_api();
|
|
7811
7870
|
function registerWhoamiCommand(root) {
|
|
7812
7871
|
root.command("whoami").description(
|
|
@@ -7837,12 +7896,12 @@ function registerWhoamiCommand(root) {
|
|
|
7837
7896
|
if (opts.json) {
|
|
7838
7897
|
console.log(formatJson({ ...localJson, account: credential ? { wallet: credential.wallet } : null }));
|
|
7839
7898
|
} else {
|
|
7840
|
-
console.log(
|
|
7841
|
-
console.log(` DID: ${
|
|
7842
|
-
console.log(` Settlement pubkey: ${
|
|
7843
|
-
console.log(` Identity pubkey: ${
|
|
7899
|
+
console.log(import_chalk35.default.bold("Local agent:"));
|
|
7900
|
+
console.log(` DID: ${import_chalk35.default.cyan(local.did)}`);
|
|
7901
|
+
console.log(` Settlement pubkey: ${import_chalk35.default.cyan(local.settlementPublicKeyB58)}`);
|
|
7902
|
+
console.log(` Identity pubkey: ${import_chalk35.default.cyan(local.identityPublicKeyB58)}`);
|
|
7844
7903
|
if (local.name) console.log(` Name: ${local.name}`);
|
|
7845
|
-
console.log(` Account: ${credential ?
|
|
7904
|
+
console.log(` Account: ${credential ? import_chalk35.default.cyan(credential.wallet) : import_chalk35.default.dim("not logged in (heyarp login)")}`);
|
|
7846
7905
|
}
|
|
7847
7906
|
return;
|
|
7848
7907
|
}
|
|
@@ -7860,19 +7919,19 @@ function registerWhoamiCommand(root) {
|
|
|
7860
7919
|
if (opts.json) {
|
|
7861
7920
|
console.log(formatJson({ local: localJson, account, server: agent }));
|
|
7862
7921
|
} else {
|
|
7863
|
-
console.log(
|
|
7864
|
-
console.log(
|
|
7865
|
-
console.log(` DID: ${
|
|
7866
|
-
console.log(` Settlement pubkey: ${
|
|
7867
|
-
console.log(` Identity pubkey: ${
|
|
7868
|
-
console.log(
|
|
7922
|
+
console.log(import_chalk35.default.dim(`Server: ${api.serverUrl}`));
|
|
7923
|
+
console.log(import_chalk35.default.bold("\nLocal agent:"));
|
|
7924
|
+
console.log(` DID: ${import_chalk35.default.cyan(local.did)}`);
|
|
7925
|
+
console.log(` Settlement pubkey: ${import_chalk35.default.cyan(local.settlementPublicKeyB58)}`);
|
|
7926
|
+
console.log(` Identity pubkey: ${import_chalk35.default.cyan(local.identityPublicKeyB58)}`);
|
|
7927
|
+
console.log(import_chalk35.default.bold("\nAccount:"));
|
|
7869
7928
|
if (account) {
|
|
7870
|
-
console.log(` Wallet: ${
|
|
7929
|
+
console.log(` Wallet: ${import_chalk35.default.cyan(account.wallet)}`);
|
|
7871
7930
|
console.log(` Agents registered: ${account.agentCount}`);
|
|
7872
7931
|
} else {
|
|
7873
|
-
console.log(` ${
|
|
7932
|
+
console.log(` ${import_chalk35.default.dim("not logged in (heyarp login)")}`);
|
|
7874
7933
|
}
|
|
7875
|
-
console.log(
|
|
7934
|
+
console.log(import_chalk35.default.bold("\nServer profile:"));
|
|
7876
7935
|
console.log(formatJson(agent));
|
|
7877
7936
|
}
|
|
7878
7937
|
} catch (err) {
|
|
@@ -7884,12 +7943,12 @@ function registerWhoamiCommand(root) {
|
|
|
7884
7943
|
|
|
7885
7944
|
// src/commands/whois.ts
|
|
7886
7945
|
var import_sdk30 = require("@heyanon-arp/sdk");
|
|
7887
|
-
var
|
|
7946
|
+
var import_chalk36 = __toESM(require("chalk"));
|
|
7888
7947
|
init_api();
|
|
7889
7948
|
function registerWhoisCommand(root) {
|
|
7890
7949
|
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) => {
|
|
7891
7950
|
const api = new ArpApiClient(opts.server);
|
|
7892
|
-
progress(opts.json,
|
|
7951
|
+
progress(opts.json, import_chalk36.default.dim(`Server: ${api.serverUrl}`));
|
|
7893
7952
|
const profile = await resolveProfile(api, input);
|
|
7894
7953
|
if (opts.json) {
|
|
7895
7954
|
jsonOut(profile);
|
|
@@ -7912,19 +7971,19 @@ async function resolveProfile(api, input) {
|
|
|
7912
7971
|
return api.discoverByName(name);
|
|
7913
7972
|
}
|
|
7914
7973
|
function printProfile(p) {
|
|
7915
|
-
console.log(`${
|
|
7916
|
-
console.log(`${
|
|
7917
|
-
if (p.description) console.log(`${
|
|
7918
|
-
if (p.tags.length > 0) console.log(`${
|
|
7919
|
-
console.log(`${
|
|
7974
|
+
console.log(`${import_chalk36.default.bold("Name")}: ${import_chalk36.default.cyan(p.name ?? "(unnamed)")}`);
|
|
7975
|
+
console.log(`${import_chalk36.default.bold("DID")}: ${import_chalk36.default.cyan(p.did)}`);
|
|
7976
|
+
if (p.description) console.log(`${import_chalk36.default.bold("Description")}: ${p.description}`);
|
|
7977
|
+
if (p.tags.length > 0) console.log(`${import_chalk36.default.bold("Tags")}: ${p.tags.join(", ")}`);
|
|
7978
|
+
console.log(`${import_chalk36.default.bold("Registered")}: ${p.registeredAt}`);
|
|
7920
7979
|
const rep = p.reputation;
|
|
7921
|
-
console.log(`${
|
|
7922
|
-
console.log(`${
|
|
7980
|
+
console.log(`${import_chalk36.default.bold("Reputation")}: composite ${rep.scores.composite}/100${rep.computed ? "" : import_chalk36.default.dim(" (cold-start \u2014 no settled cycles yet)")}`);
|
|
7981
|
+
console.log(`${import_chalk36.default.bold("Online")}: ${p.liveness.online ? import_chalk36.default.green("yes") : import_chalk36.default.dim("no")}`);
|
|
7923
7982
|
}
|
|
7924
7983
|
|
|
7925
7984
|
// src/commands/work.ts
|
|
7926
7985
|
var import_sdk31 = require("@heyanon-arp/sdk");
|
|
7927
|
-
var
|
|
7986
|
+
var import_chalk37 = __toESM(require("chalk"));
|
|
7928
7987
|
init_api();
|
|
7929
7988
|
function registerWorkCommands(root) {
|
|
7930
7989
|
const cmd = root.command("work").description("Work envelopes inside an ACCEPTED delegation: request / respond");
|
|
@@ -7965,11 +8024,11 @@ async function runRequest(recipientDid, delegationId, opts) {
|
|
|
7965
8024
|
params
|
|
7966
8025
|
};
|
|
7967
8026
|
const body = { type: "work_request", content };
|
|
7968
|
-
progress(opts.json,
|
|
7969
|
-
progress(opts.json,
|
|
7970
|
-
progress(opts.json,
|
|
7971
|
-
progress(opts.json,
|
|
7972
|
-
progress(opts.json,
|
|
8027
|
+
progress(opts.json, import_chalk37.default.dim(`Server: ${api.serverUrl}`));
|
|
8028
|
+
progress(opts.json, import_chalk37.default.dim(`Sender: ${sender.did}`));
|
|
8029
|
+
progress(opts.json, import_chalk37.default.dim(`Recipient: ${recipientDid}`));
|
|
8030
|
+
progress(opts.json, import_chalk37.default.dim(`Delegation: ${delegationId}`));
|
|
8031
|
+
progress(opts.json, import_chalk37.default.dim(`Request id: ${requestId}`));
|
|
7973
8032
|
const result = await sendWorkEnvelope({ api, sender, recipientDid, body, ttlSeconds, verbose: opts.verbose, server: opts.server });
|
|
7974
8033
|
if (opts.json) {
|
|
7975
8034
|
jsonOut({
|
|
@@ -7986,10 +8045,10 @@ async function runRequest(recipientDid, delegationId, opts) {
|
|
|
7986
8045
|
});
|
|
7987
8046
|
} else {
|
|
7988
8047
|
printIngestResult3(result);
|
|
7989
|
-
console.log(
|
|
8048
|
+
console.log(import_chalk37.default.dim(`
|
|
7990
8049
|
The payee can reply with:`));
|
|
7991
|
-
console.log(
|
|
7992
|
-
console.log(
|
|
8050
|
+
console.log(import_chalk37.default.dim(` heyarp work respond ${result.relationshipId} ${delegationId} ${requestId} --output '<json>'`));
|
|
8051
|
+
console.log(import_chalk37.default.dim(` heyarp work respond ${result.relationshipId} ${delegationId} ${requestId} --error CODE:message`));
|
|
7993
8052
|
}
|
|
7994
8053
|
}
|
|
7995
8054
|
function registerRespond(parent) {
|
|
@@ -8024,13 +8083,13 @@ async function runRespond(relationshipId, delegationId, requestId, opts) {
|
|
|
8024
8083
|
...responsePayload
|
|
8025
8084
|
};
|
|
8026
8085
|
const body = { type: "work_response", content };
|
|
8027
|
-
progress(opts.json,
|
|
8028
|
-
progress(opts.json,
|
|
8029
|
-
progress(opts.json,
|
|
8030
|
-
progress(opts.json,
|
|
8031
|
-
progress(opts.json,
|
|
8032
|
-
progress(opts.json,
|
|
8033
|
-
progress(opts.json,
|
|
8086
|
+
progress(opts.json, import_chalk37.default.dim(`Server: ${api.serverUrl}`));
|
|
8087
|
+
progress(opts.json, import_chalk37.default.dim(`Sender: ${sender.did}`));
|
|
8088
|
+
progress(opts.json, import_chalk37.default.dim(`Recipient: ${recipientDid}`));
|
|
8089
|
+
progress(opts.json, import_chalk37.default.dim(`Relationship: ${relationshipId}`));
|
|
8090
|
+
progress(opts.json, import_chalk37.default.dim(`Delegation: ${delegationId}`));
|
|
8091
|
+
progress(opts.json, import_chalk37.default.dim(`Request id: ${requestId}`));
|
|
8092
|
+
progress(opts.json, import_chalk37.default.dim(`Outcome: ${responsePayload.output ? "success" : "error"}`));
|
|
8034
8093
|
const result = await sendWorkEnvelope({ api, sender, recipientDid, body, ttlSeconds, verbose: opts.verbose, server: opts.server });
|
|
8035
8094
|
if (opts.json) {
|
|
8036
8095
|
jsonOut({
|
|
@@ -8071,7 +8130,7 @@ async function sendWorkEnvelope(args) {
|
|
|
8071
8130
|
identitySecretKey: signer.identitySecretKey
|
|
8072
8131
|
});
|
|
8073
8132
|
if (args.verbose) {
|
|
8074
|
-
console.log(
|
|
8133
|
+
console.log(import_chalk37.default.bold("\nEnvelope (pre-send):"));
|
|
8075
8134
|
console.log(formatJson(envelope));
|
|
8076
8135
|
}
|
|
8077
8136
|
try {
|
|
@@ -8111,12 +8170,12 @@ async function resolveResponseRecipient(cmdName, api, signer, args) {
|
|
|
8111
8170
|
);
|
|
8112
8171
|
}
|
|
8113
8172
|
function printIngestResult3(result) {
|
|
8114
|
-
console.log(
|
|
8115
|
-
console.log(`${
|
|
8116
|
-
console.log(`${
|
|
8117
|
-
console.log(`${
|
|
8118
|
-
console.log(`${
|
|
8119
|
-
console.log(`${
|
|
8173
|
+
console.log(import_chalk37.default.green("\nDelivered."));
|
|
8174
|
+
console.log(`${import_chalk37.default.bold("Event id")}: ${import_chalk37.default.cyan(result.eventId)}`);
|
|
8175
|
+
console.log(`${import_chalk37.default.bold("Relationship id")}: ${import_chalk37.default.cyan(result.relationshipId)}`);
|
|
8176
|
+
console.log(`${import_chalk37.default.bold("Chain index")}: ${import_chalk37.default.cyan(String(result.relationshipEventIndex))}`);
|
|
8177
|
+
console.log(`${import_chalk37.default.bold("Server timestamp")}: ${import_chalk37.default.cyan(result.serverTimestamp)}`);
|
|
8178
|
+
console.log(`${import_chalk37.default.bold("Server event hash")}: ${import_chalk37.default.cyan(result.serverEventHash)}`);
|
|
8120
8179
|
}
|
|
8121
8180
|
function parseJsonObject(cmdName, flagName, raw) {
|
|
8122
8181
|
let parsed;
|
|
@@ -8218,7 +8277,7 @@ function parseRequestId(cmdName, raw) {
|
|
|
8218
8277
|
|
|
8219
8278
|
// src/commands/work-list.ts
|
|
8220
8279
|
var import_sdk32 = require("@heyanon-arp/sdk");
|
|
8221
|
-
var
|
|
8280
|
+
var import_chalk38 = __toESM(require("chalk"));
|
|
8222
8281
|
init_api();
|
|
8223
8282
|
var ALLOWED_STATES3 = new Set(import_sdk32.WORK_LOG_STATES);
|
|
8224
8283
|
function registerWorkListCommand(root) {
|
|
@@ -8245,9 +8304,9 @@ async function runWorkList(relationshipId, opts) {
|
|
|
8245
8304
|
const api = new ArpApiClient(opts.server);
|
|
8246
8305
|
const sender = resolveSenderAgent("work-list", opts.server, opts.fromDid, opts.from);
|
|
8247
8306
|
if (!opts.json) {
|
|
8248
|
-
console.log(
|
|
8249
|
-
console.log(
|
|
8250
|
-
console.log(
|
|
8307
|
+
console.log(import_chalk38.default.dim(`Server: ${api.serverUrl}`));
|
|
8308
|
+
console.log(import_chalk38.default.dim(`Signer: ${sender.did}`));
|
|
8309
|
+
console.log(import_chalk38.default.dim(`Relationship: ${relationshipId}`));
|
|
8251
8310
|
}
|
|
8252
8311
|
const query = { limit };
|
|
8253
8312
|
if (state) query.state = state;
|
|
@@ -8260,7 +8319,7 @@ async function runWorkList(relationshipId, opts) {
|
|
|
8260
8319
|
return;
|
|
8261
8320
|
}
|
|
8262
8321
|
if (rows.length === 0) {
|
|
8263
|
-
console.log(
|
|
8322
|
+
console.log(import_chalk38.default.dim("\n(no work-logs for this relationship)"));
|
|
8264
8323
|
return;
|
|
8265
8324
|
}
|
|
8266
8325
|
console.log("");
|
|
@@ -8277,36 +8336,36 @@ async function runWorkList(relationshipId, opts) {
|
|
|
8277
8336
|
}));
|
|
8278
8337
|
}
|
|
8279
8338
|
const lastId = rows[rows.length - 1].id;
|
|
8280
|
-
console.log(
|
|
8339
|
+
console.log(import_chalk38.default.dim(`
|
|
8281
8340
|
${rows.length} work-log row(s). Paginate with --after ${lastId}.`));
|
|
8282
8341
|
}
|
|
8283
8342
|
function formatWorkLogLine(w, selfDid, opts = {}) {
|
|
8284
8343
|
const delegationPart = opts.fullIds ? w.delegationId : idHead3(w.delegationId);
|
|
8285
8344
|
const requestPart = opts.fullIds ? w.requestId : truncate3(w.requestId, 16);
|
|
8286
|
-
const id =
|
|
8345
|
+
const id = import_chalk38.default.bold(`${delegationPart}/${requestPart}`);
|
|
8287
8346
|
const state = colorState2(w.state).padEnd(stateColumnWidth2());
|
|
8288
8347
|
const peerCallerHead = opts.fullIds ? w.callerDid : didHead5(w.callerDid);
|
|
8289
8348
|
const peerPayeeHead = opts.fullIds ? w.payeeDid : didHead5(w.payeeDid);
|
|
8290
|
-
const direction = w.callerDid === selfDid ? `${
|
|
8349
|
+
const direction = w.callerDid === selfDid ? `${import_chalk38.default.bold("me")} \u2192 ${import_chalk38.default.dim(peerPayeeHead)}` : `${import_chalk38.default.dim(peerCallerHead)} \u2192 ${import_chalk38.default.bold("me")}`;
|
|
8291
8350
|
const outcome = formatOutcome(w);
|
|
8292
8351
|
return `${id} ${state} ${direction} ${outcome}`;
|
|
8293
8352
|
}
|
|
8294
8353
|
function colorState2(s) {
|
|
8295
8354
|
switch (s) {
|
|
8296
8355
|
case import_sdk32.WorkLogStates.REQUESTED:
|
|
8297
|
-
return
|
|
8356
|
+
return import_chalk38.default.yellow("requested");
|
|
8298
8357
|
case import_sdk32.WorkLogStates.RESPONDED:
|
|
8299
|
-
return
|
|
8358
|
+
return import_chalk38.default.green("responded");
|
|
8300
8359
|
}
|
|
8301
8360
|
}
|
|
8302
8361
|
function stateColumnWidth2() {
|
|
8303
8362
|
return 9;
|
|
8304
8363
|
}
|
|
8305
8364
|
function formatOutcome(w) {
|
|
8306
|
-
if (w.state === import_sdk32.WorkLogStates.REQUESTED) return
|
|
8307
|
-
if (w.responseError) return
|
|
8308
|
-
if (w.responseOutput) return
|
|
8309
|
-
return
|
|
8365
|
+
if (w.state === import_sdk32.WorkLogStates.REQUESTED) return import_chalk38.default.dim("(in flight)");
|
|
8366
|
+
if (w.responseError) return import_chalk38.default.red(`error ${w.responseError.code}: ${truncate3(w.responseError.message, 32)}`);
|
|
8367
|
+
if (w.responseOutput) return import_chalk38.default.cyan("ok");
|
|
8368
|
+
return import_chalk38.default.dim("(empty response)");
|
|
8310
8369
|
}
|
|
8311
8370
|
function idHead3(id) {
|
|
8312
8371
|
if (id.length <= 12) return id;
|
|
@@ -8508,6 +8567,7 @@ async function main() {
|
|
|
8508
8567
|
registerReceiptCommands(program);
|
|
8509
8568
|
registerReceiptsCommand(program);
|
|
8510
8569
|
registerReputationCommand(program);
|
|
8570
|
+
registerStatsCommand(program);
|
|
8511
8571
|
registerWalletCommands(program);
|
|
8512
8572
|
(0, import_shield3.installMiddleware)(program);
|
|
8513
8573
|
try {
|