@heyanon-arp/cli 0.0.11 → 0.0.13
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 +297 -86
- package/dist/cli.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -496,7 +496,7 @@ var init_api = __esm({
|
|
|
496
496
|
* entity feed.
|
|
497
497
|
*/
|
|
498
498
|
async listDelegations(relationshipId, signer, query, signal) {
|
|
499
|
-
|
|
499
|
+
const rows = await this.signedRequest(
|
|
500
500
|
"GET",
|
|
501
501
|
`/v1/relationships/${encodeURIComponent(relationshipId)}/delegations`,
|
|
502
502
|
null,
|
|
@@ -504,6 +504,11 @@ var init_api = __esm({
|
|
|
504
504
|
query,
|
|
505
505
|
signal
|
|
506
506
|
);
|
|
507
|
+
return Promise.all(
|
|
508
|
+
rows.map(
|
|
509
|
+
(row) => signer.did === row.offererDid ? row : (0, import_shield.guardInboundFields)(row, ["scopeSummary", "title", "brief", "acceptanceCriteria"], { selfDid: signer.did }).then((r) => r.event)
|
|
510
|
+
)
|
|
511
|
+
);
|
|
507
512
|
}
|
|
508
513
|
/**
|
|
509
514
|
* Signed `GET /v1/relationships/:id/work`. One row per
|
|
@@ -513,13 +518,21 @@ var init_api = __esm({
|
|
|
513
518
|
* work-logs operating under a single delegation umbrella.
|
|
514
519
|
*/
|
|
515
520
|
async listWorkLogs(relationshipId, signer, query) {
|
|
516
|
-
|
|
521
|
+
const rows = await this.signedRequest(
|
|
517
522
|
"GET",
|
|
518
523
|
`/v1/relationships/${encodeURIComponent(relationshipId)}/work`,
|
|
519
524
|
null,
|
|
520
525
|
signer,
|
|
521
526
|
query
|
|
522
527
|
);
|
|
528
|
+
return Promise.all(
|
|
529
|
+
rows.map((row) => {
|
|
530
|
+
const fields = [];
|
|
531
|
+
if (signer.did !== row.callerDid) fields.push("requestParams");
|
|
532
|
+
if (signer.did !== row.payeeDid) fields.push("responseOutput");
|
|
533
|
+
return fields.length === 0 ? row : (0, import_shield.guardInboundFields)(row, fields, { selfDid: signer.did }).then((r) => r.event);
|
|
534
|
+
})
|
|
535
|
+
);
|
|
523
536
|
}
|
|
524
537
|
/**
|
|
525
538
|
* Signed `GET /v1/relationships/:id/receipts`. One row per
|
|
@@ -770,45 +783,6 @@ var init_format = __esm({
|
|
|
770
783
|
}
|
|
771
784
|
});
|
|
772
785
|
|
|
773
|
-
// src/id-format.ts
|
|
774
|
-
function describeNonUuidShape(raw) {
|
|
775
|
-
if (raw === "") return "empty string";
|
|
776
|
-
if (raw.startsWith("del_") && UUID_RE.test(raw.slice(4))) {
|
|
777
|
-
return "looks like a delegation id with the canonical `del_` prefix. If this field expects a delegation_id, drop the `del_` prefix and pass the 36-char body. If this field expects a DIFFERENT id type (relationship_id / request_id), the `del_`-prefixed value belongs to the WRONG entity \u2014 look up the right row and copy its id";
|
|
778
|
-
}
|
|
779
|
-
if (raw.startsWith("evt_")) {
|
|
780
|
-
return "looks like an event id (evt_<uuid>) \u2014 this command expects a delegation/relationship/request id (UUID), which is a DIFFERENT column. Look up the row that emitted this event (`heyarp events <rel> --json`) and copy the appropriate id field";
|
|
781
|
-
}
|
|
782
|
-
if (raw.startsWith("did:arp:")) {
|
|
783
|
-
return "looks like a DID (agent identifier) \u2014 this command expects a delegation/relationship/request id (UUID), not a DID";
|
|
784
|
-
}
|
|
785
|
-
if (SHA256_PREFIX_RE.test(raw)) {
|
|
786
|
-
return "looks like a sha256:<hash> \u2014 this command expects a UUID, not a hash. sha256: ids show up in receipt_event_hash, request_hash, response_hash";
|
|
787
|
-
}
|
|
788
|
-
if (OBJECT_ID_24_HEX_RE.test(raw)) {
|
|
789
|
-
return "looks like a Mongo ObjectId (24-hex row id surfaced by some server read endpoints) rather than the expected UUID. Mongo ObjectIds and delegation ids are DIFFERENT formats";
|
|
790
|
-
}
|
|
791
|
-
if (UUID_NO_DASHES_RE.test(raw)) {
|
|
792
|
-
return "looks like a UUID with no dashes \u2014 canonical UUIDs need the 8-4-4-4-12 dash pattern (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)";
|
|
793
|
-
}
|
|
794
|
-
return void 0;
|
|
795
|
-
}
|
|
796
|
-
function requireUuid(cmdName, raw, label) {
|
|
797
|
-
if (UUID_RE.test(raw)) return;
|
|
798
|
-
const hint = describeNonUuidShape(raw);
|
|
799
|
-
const base = `${cmdName}: ${label} must be a UUID (got '${raw}')`;
|
|
800
|
-
throw new Error(hint ? `${base} \u2014 ${hint}` : base);
|
|
801
|
-
}
|
|
802
|
-
var UUID_RE, OBJECT_ID_24_HEX_RE, SHA256_PREFIX_RE, UUID_NO_DASHES_RE;
|
|
803
|
-
var init_id_format = __esm({
|
|
804
|
-
"src/id-format.ts"() {
|
|
805
|
-
UUID_RE = /^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/;
|
|
806
|
-
OBJECT_ID_24_HEX_RE = /^[0-9a-f]{24}$/;
|
|
807
|
-
SHA256_PREFIX_RE = /^sha256:[0-9a-f]{64}$/;
|
|
808
|
-
UUID_NO_DASHES_RE = /^[a-fA-F0-9]{32}$/;
|
|
809
|
-
}
|
|
810
|
-
});
|
|
811
|
-
|
|
812
786
|
// src/state.ts
|
|
813
787
|
function stateFilePath() {
|
|
814
788
|
return (0, import_node_path3.join)(arpHomeDir(), "agents.json");
|
|
@@ -947,7 +921,7 @@ var init_state = __esm({
|
|
|
947
921
|
|
|
948
922
|
// src/commands/lifecycle.ts
|
|
949
923
|
function registerLifecycleCommands(root) {
|
|
950
|
-
root.command("update").description("Update an agent profile (name / description / tags). At least one flag is required.").argument("<did>").option("--server <url>", "Override ARP server base URL").option("--name <s>", "New display name").option("--description <s>", "New description").option("--tag <s>", "Capability tag \u2014 REPLACES the existing list. Repeatable: --tag translation --tag fr",
|
|
924
|
+
root.command("update").description("Update an agent profile (name / description / tags). At least one flag is required.").argument("<did>").option("--server <url>", "Override ARP server base URL").option("--name <s>", "New display name").option("--description <s>", "New description").option("--tag <s>", "Capability tag \u2014 REPLACES the existing list. Repeatable: --tag translation --tag fr", accumulate, []).option("--clear-tags", "Drop all tags (cannot be combined with --tag)", false).action(
|
|
951
925
|
async (did, opts) => {
|
|
952
926
|
const body = buildUpdateBody(opts);
|
|
953
927
|
if (Object.keys(body).length === 0) {
|
|
@@ -963,7 +937,7 @@ function registerLifecycleCommands(root) {
|
|
|
963
937
|
}
|
|
964
938
|
);
|
|
965
939
|
}
|
|
966
|
-
function
|
|
940
|
+
function accumulate(value, previous) {
|
|
967
941
|
return [...previous, value];
|
|
968
942
|
}
|
|
969
943
|
function buildUpdateBody(opts) {
|
|
@@ -983,8 +957,8 @@ function buildUpdateBody(opts) {
|
|
|
983
957
|
async function actSigned(did, serverOverride, act) {
|
|
984
958
|
const local = loadAgentOrThrow(serverOverride, did);
|
|
985
959
|
const api = new ArpApiClient(serverOverride);
|
|
986
|
-
console.log(
|
|
987
|
-
console.log(
|
|
960
|
+
console.log(import_chalk2.default.dim(`Server: ${api.serverUrl}`));
|
|
961
|
+
console.log(import_chalk2.default.dim(`Signer: ${local.did}`));
|
|
988
962
|
const signer = makeSigner(local);
|
|
989
963
|
return act(api, signer);
|
|
990
964
|
}
|
|
@@ -995,22 +969,61 @@ function makeSigner(s) {
|
|
|
995
969
|
};
|
|
996
970
|
}
|
|
997
971
|
function printAgent(verb, agent) {
|
|
998
|
-
console.log(
|
|
972
|
+
console.log(import_chalk2.default.green(`
|
|
999
973
|
${verb}.`));
|
|
1000
|
-
console.log(`${
|
|
1001
|
-
console.log(
|
|
974
|
+
console.log(`${import_chalk2.default.bold("DID")}: ${import_chalk2.default.cyan(agent.did)}`);
|
|
975
|
+
console.log(import_chalk2.default.bold("\nAgent profile:"));
|
|
1002
976
|
console.log(formatJson(agent));
|
|
1003
977
|
}
|
|
1004
|
-
var
|
|
978
|
+
var import_chalk2;
|
|
1005
979
|
var init_lifecycle = __esm({
|
|
1006
980
|
"src/commands/lifecycle.ts"() {
|
|
1007
|
-
|
|
981
|
+
import_chalk2 = __toESM(require("chalk"));
|
|
1008
982
|
init_api();
|
|
1009
983
|
init_format();
|
|
1010
984
|
init_state();
|
|
1011
985
|
}
|
|
1012
986
|
});
|
|
1013
987
|
|
|
988
|
+
// src/id-format.ts
|
|
989
|
+
function describeNonUuidShape(raw) {
|
|
990
|
+
if (raw === "") return "empty string";
|
|
991
|
+
if (raw.startsWith("del_") && UUID_RE.test(raw.slice(4))) {
|
|
992
|
+
return "looks like a delegation id with the canonical `del_` prefix. If this field expects a delegation_id, drop the `del_` prefix and pass the 36-char body. If this field expects a DIFFERENT id type (relationship_id / request_id), the `del_`-prefixed value belongs to the WRONG entity \u2014 look up the right row and copy its id";
|
|
993
|
+
}
|
|
994
|
+
if (raw.startsWith("evt_")) {
|
|
995
|
+
return "looks like an event id (evt_<uuid>) \u2014 this command expects a delegation/relationship/request id (UUID), which is a DIFFERENT column. Look up the row that emitted this event (`heyarp events <rel> --json`) and copy the appropriate id field";
|
|
996
|
+
}
|
|
997
|
+
if (raw.startsWith("did:arp:")) {
|
|
998
|
+
return "looks like a DID (agent identifier) \u2014 this command expects a delegation/relationship/request id (UUID), not a DID";
|
|
999
|
+
}
|
|
1000
|
+
if (SHA256_PREFIX_RE.test(raw)) {
|
|
1001
|
+
return "looks like a sha256:<hash> \u2014 this command expects a UUID, not a hash. sha256: ids show up in receipt_event_hash, request_hash, response_hash";
|
|
1002
|
+
}
|
|
1003
|
+
if (OBJECT_ID_24_HEX_RE.test(raw)) {
|
|
1004
|
+
return "looks like a Mongo ObjectId (24-hex row id surfaced by some server read endpoints) rather than the expected UUID. Mongo ObjectIds and delegation ids are DIFFERENT formats";
|
|
1005
|
+
}
|
|
1006
|
+
if (UUID_NO_DASHES_RE.test(raw)) {
|
|
1007
|
+
return "looks like a UUID with no dashes \u2014 canonical UUIDs need the 8-4-4-4-12 dash pattern (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)";
|
|
1008
|
+
}
|
|
1009
|
+
return void 0;
|
|
1010
|
+
}
|
|
1011
|
+
function requireUuid(cmdName, raw, label) {
|
|
1012
|
+
if (UUID_RE.test(raw)) return;
|
|
1013
|
+
const hint = describeNonUuidShape(raw);
|
|
1014
|
+
const base = `${cmdName}: ${label} must be a UUID (got '${raw}')`;
|
|
1015
|
+
throw new Error(hint ? `${base} \u2014 ${hint}` : base);
|
|
1016
|
+
}
|
|
1017
|
+
var UUID_RE, OBJECT_ID_24_HEX_RE, SHA256_PREFIX_RE, UUID_NO_DASHES_RE;
|
|
1018
|
+
var init_id_format = __esm({
|
|
1019
|
+
"src/id-format.ts"() {
|
|
1020
|
+
UUID_RE = /^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/;
|
|
1021
|
+
OBJECT_ID_24_HEX_RE = /^[0-9a-f]{24}$/;
|
|
1022
|
+
SHA256_PREFIX_RE = /^sha256:[0-9a-f]{64}$/;
|
|
1023
|
+
UUID_NO_DASHES_RE = /^[a-fA-F0-9]{32}$/;
|
|
1024
|
+
}
|
|
1025
|
+
});
|
|
1026
|
+
|
|
1014
1027
|
// src/commands/status.ts
|
|
1015
1028
|
function registerStatusCommand(root) {
|
|
1016
1029
|
root.command("status").description("Where am I in the work cycle? FSM state + next-action hint for ONE relationship (signed reads)").argument("<relationship-id>", "Relationship UUID").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("--json", "Machine-readable: single JSON object with the composed summary. Pipe-safe.", false).option(
|
|
@@ -2576,7 +2589,29 @@ async function runOffer(recipientDid, opts) {
|
|
|
2576
2589
|
console.log(import_chalk6.default.dim(`Sender: ${sender.did}`));
|
|
2577
2590
|
console.log(import_chalk6.default.dim(`Recipient: ${recipientDid}`));
|
|
2578
2591
|
console.log(import_chalk6.default.dim(`Delegation: ${delegationId}`));
|
|
2579
|
-
|
|
2592
|
+
let result;
|
|
2593
|
+
try {
|
|
2594
|
+
result = await sendDelegationEnvelope({ api, sender, recipientDid, body, ttlSeconds, verbose: opts.verbose, server: opts.server });
|
|
2595
|
+
} catch (err) {
|
|
2596
|
+
if (err instanceof ApiError && err.payload.code === "DELEGATION_PRICING_MISMATCH") {
|
|
2597
|
+
const d = err.payload.details;
|
|
2598
|
+
console.error(import_chalk6.default.yellow(`
|
|
2599
|
+
The recipient's published accept-prefs rejected this offer${d?.reason ? ` (mismatch: ${d.reason})` : ""}.`));
|
|
2600
|
+
if (d !== void 0) {
|
|
2601
|
+
console.error(import_chalk6.default.dim(` accepted: ${JSON.stringify(d.accepted)}`));
|
|
2602
|
+
console.error(import_chalk6.default.dim(` offered: ${JSON.stringify(d.offered)}`));
|
|
2603
|
+
}
|
|
2604
|
+
console.error(
|
|
2605
|
+
import_chalk6.default.dim(
|
|
2606
|
+
`
|
|
2607
|
+
Check what the recipient accepts BEFORE offering:
|
|
2608
|
+
heyarp agents accept-prefs show ${recipientDid}
|
|
2609
|
+
then re-run with matching --pricing-model / --currency / --amount.`
|
|
2610
|
+
)
|
|
2611
|
+
);
|
|
2612
|
+
}
|
|
2613
|
+
throw err;
|
|
2614
|
+
}
|
|
2580
2615
|
printIngestResult(result);
|
|
2581
2616
|
console.log(import_chalk6.default.dim(`
|
|
2582
2617
|
Reference this delegation on subsequent calls with:`));
|
|
@@ -3194,6 +3229,12 @@ var init_delegation = __esm({
|
|
|
3194
3229
|
"DELEGATION_ACCEPTER_IS_OFFERER",
|
|
3195
3230
|
"DELEGATION_DECLINER_IS_OFFERER",
|
|
3196
3231
|
"DELEGATION_CANCELER_NOT_OFFERER",
|
|
3232
|
+
// PricingPolicy: the offer's terms fell outside the RECIPIENT's
|
|
3233
|
+
// published accept-prefs. Fires in `handleOffer` AFTER the event
|
|
3234
|
+
// row commit (pre-materialization on the server), so the sequence
|
|
3235
|
+
// was consumed — advance it or the corrected re-offer trips
|
|
3236
|
+
// ENV_SEQUENCE_BACKWARDS.
|
|
3237
|
+
"DELEGATION_PRICING_MISMATCH",
|
|
3197
3238
|
// `DELEGATION_PENDING_LOCK` fires from the body handler's
|
|
3198
3239
|
// `requireDelegationInState` AFTER the event row is persisted
|
|
3199
3240
|
// (same code path as DELEGATION_INVALID_STATE), so an accept
|
|
@@ -3459,6 +3500,11 @@ function settlementKeyFromDidDoc(didDoc, buyerDid) {
|
|
|
3459
3500
|
return mb.startsWith("z") ? mb.slice(1) : mb;
|
|
3460
3501
|
}
|
|
3461
3502
|
function projectDelegationRowForHash(d) {
|
|
3503
|
+
if ((0, import_shield2.isShieldRedacted)(d.scopeSummary)) {
|
|
3504
|
+
throw new Error(
|
|
3505
|
+
`settlement: delegation ${d.delegationId} has shield-withheld scope (flagged by content-security). Cannot derive condition_hash over withheld content \u2014 do not settle; review and dispute.`
|
|
3506
|
+
);
|
|
3507
|
+
}
|
|
3462
3508
|
const out = {
|
|
3463
3509
|
delegationId: d.delegationId,
|
|
3464
3510
|
scopeSummary: d.scopeSummary,
|
|
@@ -3685,9 +3731,10 @@ async function autoSignAndDeliverPayeeSig(opts, cmdName = "receipt propose") {
|
|
|
3685
3731
|
if (!delegation) {
|
|
3686
3732
|
throw new Error(`${cmdName}: delegation ${delegationId} not found under relationship ${relId} (paginated 5000 rows).`);
|
|
3687
3733
|
}
|
|
3688
|
-
|
|
3734
|
+
const SETTLEABLE_STATES = /* @__PURE__ */ new Set(["accepted", "locked"]);
|
|
3735
|
+
if (!SETTLEABLE_STATES.has(delegation.state ?? "")) {
|
|
3689
3736
|
throw new Error(
|
|
3690
|
-
`${cmdName}: delegation ${delegationId} is in state '${delegation.state ?? "unknown"}' \u2014 only an 'accepted' delegation is settleable (its escrow lock is still LOCKED). A non-
|
|
3737
|
+
`${cmdName}: delegation ${delegationId} is in state '${delegation.state ?? "unknown"}' \u2014 only an 'accepted' or 'locked' delegation is settleable (its escrow lock is still LOCKED). A non-settleable state's lock has been released / refunded / canceled, so the server would reject the settlement signature post-commit (SETTLEMENT_SIG_LOCK_INVALID_STATE). Nothing to settle.`
|
|
3691
3738
|
);
|
|
3692
3739
|
}
|
|
3693
3740
|
if (!delegation.amount) {
|
|
@@ -3865,10 +3912,11 @@ async function autoSignAndDeliverPayeeSig(opts, cmdName = "receipt propose") {
|
|
|
3865
3912
|
serverTimestamp: result.serverTimestamp
|
|
3866
3913
|
};
|
|
3867
3914
|
}
|
|
3868
|
-
var import_sdk10, import_utils3, import_web33, import_chalk17, NATIVE_SOL_MINT2, SETTLEMENT_MIN_EXPIRY_HEADROOM_SECS, SETTLEMENT_REFRESH_HEADROOM_SECS, LOCK_READ_NOT_VISIBLE_RETRIES, LOCK_READ_RETRY_DELAY_MS;
|
|
3915
|
+
var import_sdk10, import_shield2, import_utils3, import_web33, import_chalk17, NATIVE_SOL_MINT2, SETTLEMENT_MIN_EXPIRY_HEADROOM_SECS, SETTLEMENT_REFRESH_HEADROOM_SECS, LOCK_READ_NOT_VISIBLE_RETRIES, LOCK_READ_RETRY_DELAY_MS;
|
|
3869
3916
|
var init_settlement = __esm({
|
|
3870
3917
|
"src/commands/settlement.ts"() {
|
|
3871
3918
|
import_sdk10 = require("@heyanon-arp/sdk");
|
|
3919
|
+
import_shield2 = require("@heyanon-arp/shield");
|
|
3872
3920
|
import_utils3 = require("@noble/hashes/utils");
|
|
3873
3921
|
import_web33 = require("@solana/web3.js");
|
|
3874
3922
|
import_chalk17 = __toESM(require("chalk"));
|
|
@@ -4232,6 +4280,11 @@ async function computeWorkLogHashes(api, sender, relationshipId, delegationId, r
|
|
|
4232
4280
|
`receipt propose --auto-hashes: work-log row ${requestId} is in state '${workLog.state}', not 'responded'. The payee must \`work respond\` before a receipt can be proposed.`
|
|
4233
4281
|
);
|
|
4234
4282
|
}
|
|
4283
|
+
if ((0, import_shield3.isShieldRedacted)(workLog.requestParams) || (0, import_shield3.isShieldRedacted)(workLog.responseOutput)) {
|
|
4284
|
+
throw new Error(
|
|
4285
|
+
`receipt propose --auto-hashes: work-log row ${requestId} has shield-withheld content (the counterparty's request or response was flagged by content-security). Cannot reconstruct canonical hashes over withheld content \u2014 do not settle; review and dispute. See ~/.heyshield/receipts.jsonl.`
|
|
4286
|
+
);
|
|
4287
|
+
}
|
|
4235
4288
|
const requestBody = {
|
|
4236
4289
|
type: "work_request",
|
|
4237
4290
|
content: { delegation_id: workLog.delegationId, request_id: workLog.requestId, params: workLog.requestParams }
|
|
@@ -4934,11 +4987,12 @@ function requireDid2(cmdName, did, label) {
|
|
|
4934
4987
|
throw new Error(`${cmdName}: ${label} must look like 'did:arp:...' (got '${did}')`);
|
|
4935
4988
|
}
|
|
4936
4989
|
}
|
|
4937
|
-
var import_node_fs7, import_sdk11, import_chalk18, POST_COMMIT_ERROR_CODES2, VERDICT_VALUES, SHA256_RE;
|
|
4990
|
+
var import_node_fs7, import_sdk11, import_shield3, import_chalk18, POST_COMMIT_ERROR_CODES2, VERDICT_VALUES, SHA256_RE;
|
|
4938
4991
|
var init_receipt = __esm({
|
|
4939
4992
|
"src/commands/receipt.ts"() {
|
|
4940
4993
|
import_node_fs7 = require("fs");
|
|
4941
4994
|
import_sdk11 = require("@heyanon-arp/sdk");
|
|
4995
|
+
import_shield3 = require("@heyanon-arp/shield");
|
|
4942
4996
|
import_chalk18 = __toESM(require("chalk"));
|
|
4943
4997
|
init_api();
|
|
4944
4998
|
init_format();
|
|
@@ -5049,14 +5103,14 @@ var init_receipt = __esm({
|
|
|
5049
5103
|
});
|
|
5050
5104
|
|
|
5051
5105
|
// src/cli.ts
|
|
5052
|
-
var
|
|
5106
|
+
var import_shield4 = require("@heyanon-arp/shield");
|
|
5053
5107
|
var import_commander = require("commander");
|
|
5054
5108
|
var import_simple_update_notifier = __toESM(require("simple-update-notifier"));
|
|
5055
5109
|
|
|
5056
5110
|
// package.json
|
|
5057
5111
|
var package_default = {
|
|
5058
5112
|
name: "@heyanon-arp/cli",
|
|
5059
|
-
version: "0.0.
|
|
5113
|
+
version: "0.0.13",
|
|
5060
5114
|
description: "Command-line client for the Agent Relationship Protocol \u2014 register agents, sign envelopes, run escrowed work cycles on Solana.",
|
|
5061
5115
|
license: "MIT",
|
|
5062
5116
|
keywords: ["arp", "agent-relationship-protocol", "did", "solana", "escrow", "ed25519", "agents", "a2a", "cli"],
|
|
@@ -5101,11 +5155,13 @@ var package_default = {
|
|
|
5101
5155
|
};
|
|
5102
5156
|
|
|
5103
5157
|
// src/commands/agents.ts
|
|
5104
|
-
var
|
|
5158
|
+
var import_chalk3 = __toESM(require("chalk"));
|
|
5105
5159
|
init_api();
|
|
5106
5160
|
init_format();
|
|
5161
|
+
init_state();
|
|
5162
|
+
init_lifecycle();
|
|
5107
5163
|
function registerAgentsCommand(root) {
|
|
5108
|
-
root.command("agents").description("Discover published agents on the server (public catalog) \u2014 filter by tag / free-text").option("--server <url>", "Override ARP server base URL").option("--tag <s>", "Filter by capability tag \u2014 repeatable; AND-semantics across tags",
|
|
5164
|
+
const agents = root.command("agents").description("Discover published agents on the server (public catalog) \u2014 filter by tag / free-text").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("--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(
|
|
5109
5165
|
"--verbose",
|
|
5110
5166
|
'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)',
|
|
5111
5167
|
false
|
|
@@ -5127,11 +5183,12 @@ function registerAgentsCommand(root) {
|
|
|
5127
5183
|
).action(async (opts) => {
|
|
5128
5184
|
await runAgents(opts);
|
|
5129
5185
|
});
|
|
5186
|
+
registerAcceptPrefsCommands(agents);
|
|
5130
5187
|
}
|
|
5131
5188
|
async function runAgents(opts) {
|
|
5132
5189
|
const limit = parseLimit(opts.limit);
|
|
5133
5190
|
const api = new ArpApiClient(opts.server);
|
|
5134
|
-
progress(opts.json,
|
|
5191
|
+
progress(opts.json, import_chalk3.default.dim(`Server: ${api.serverUrl}`));
|
|
5135
5192
|
const query = { limit };
|
|
5136
5193
|
if (opts.tag && opts.tag.length > 0) query.tag = opts.tag.map((t) => t.trim().toLowerCase());
|
|
5137
5194
|
if (opts.query) query.q = opts.query;
|
|
@@ -5147,7 +5204,7 @@ async function runAgents(opts) {
|
|
|
5147
5204
|
return;
|
|
5148
5205
|
}
|
|
5149
5206
|
if (rows.length === 0) {
|
|
5150
|
-
console.log(
|
|
5207
|
+
console.log(import_chalk3.default.dim("\n(no agents matched)"));
|
|
5151
5208
|
return;
|
|
5152
5209
|
}
|
|
5153
5210
|
console.log("");
|
|
@@ -5158,10 +5215,10 @@ async function runAgents(opts) {
|
|
|
5158
5215
|
const useUnicode = supportsUnicodeFrame();
|
|
5159
5216
|
const heavyRule = useUnicode ? "\u2501".repeat(60) : "=".repeat(60);
|
|
5160
5217
|
const headerGlyph = useUnicode ? "\u25BC" : ">";
|
|
5161
|
-
const rule =
|
|
5218
|
+
const rule = import_chalk3.default.cyan(heavyRule);
|
|
5162
5219
|
console.log(`
|
|
5163
5220
|
${rule}`);
|
|
5164
|
-
console.log(
|
|
5221
|
+
console.log(import_chalk3.default.bold.cyan(`${headerGlyph} Full agent payloads (${safeRows.length} row${safeRows.length === 1 ? "" : "s"})`));
|
|
5165
5222
|
console.log(rule);
|
|
5166
5223
|
console.log(formatJson(safeRows));
|
|
5167
5224
|
console.log(`${rule}
|
|
@@ -5169,16 +5226,16 @@ ${rule}`);
|
|
|
5169
5226
|
}
|
|
5170
5227
|
if (rows.length === limit) {
|
|
5171
5228
|
const cursor = rows[rows.length - 1].id;
|
|
5172
|
-
console.log(
|
|
5229
|
+
console.log(import_chalk3.default.dim(`
|
|
5173
5230
|
Next page: re-run with --after ${cursor}`));
|
|
5174
5231
|
}
|
|
5175
5232
|
}
|
|
5176
5233
|
function formatAgentLine(a, opts = {}) {
|
|
5177
5234
|
const idDisplay = opts.fullIds ? a.id : `${a.id.slice(0, 8)}...${a.id.slice(-4)}`;
|
|
5178
5235
|
const tags = `[${a.tags.join(",")}]`;
|
|
5179
|
-
const name = a.name ? `"${truncate(sanitizeForTerminal(a.name), 40)}"` :
|
|
5180
|
-
const description = a.description ? `\u2014 ${
|
|
5181
|
-
return `${
|
|
5236
|
+
const name = a.name ? `"${truncate(sanitizeForTerminal(a.name), 40)}"` : import_chalk3.default.dim("(unnamed)");
|
|
5237
|
+
const description = a.description ? `\u2014 ${import_chalk3.default.dim(truncate(sanitizeForTerminal(a.description), 60))}` : "";
|
|
5238
|
+
return `${import_chalk3.default.dim(idDisplay)} ${import_chalk3.default.cyan(a.did)} ${import_chalk3.default.magenta(tags)} ${name} ${description}`.trim();
|
|
5182
5239
|
}
|
|
5183
5240
|
function truncate(s, max) {
|
|
5184
5241
|
if (s.length <= max) return s;
|
|
@@ -5195,12 +5252,129 @@ function parseLimit(raw) {
|
|
|
5195
5252
|
}
|
|
5196
5253
|
return n;
|
|
5197
5254
|
}
|
|
5198
|
-
function
|
|
5255
|
+
function accumulate2(value, previous) {
|
|
5199
5256
|
return [...previous, value];
|
|
5200
5257
|
}
|
|
5258
|
+
var PRICING_MODELS = ["flat", "usage_based"];
|
|
5259
|
+
function registerAcceptPrefsCommands(agents) {
|
|
5260
|
+
const prefs = agents.command("accept-prefs").description("Worker-side accept-preferences (PricingPolicy): what delegation offers the server should reject on your behalf");
|
|
5261
|
+
prefs.command("set").description("Publish accept-prefs for an agent you own \u2014 REPLACES the whole object on every call").argument("<did>", "Agent DID (must have a local key \u2014 owner-only)").option("--server <url>", "Override ARP server base URL").option("--pricing-model <m>", "Accepted pricing model: flat | usage_based. Repeatable; omit to accept any model.", accumulate2, []).option(
|
|
5262
|
+
"--currency <spec>",
|
|
5263
|
+
`Accepted currency: "<caip19-asset-id>[,<min>[,<max>]]" \u2014 optional inclusive amount bounds as decimal strings in that currency's units (empty segment skips: "asset,,500" = max only). Repeatable; omit to accept any currency.`,
|
|
5264
|
+
accumulate2,
|
|
5265
|
+
[]
|
|
5266
|
+
).option(
|
|
5267
|
+
"--from-json <json>",
|
|
5268
|
+
'Full AcceptPrefs JSON object (mutually exclusive with --pricing-model / --currency). Shape: {"pricingModels":[...],"currencies":[{"assetId":"...","minAmount":"...","maxAmount":"..."}]}'
|
|
5269
|
+
).action(async (did, _opts, cmd) => {
|
|
5270
|
+
const opts = cmd.optsWithGlobals();
|
|
5271
|
+
const body = buildAcceptPrefs(opts);
|
|
5272
|
+
const local = loadAgentOrThrow(opts.server, did);
|
|
5273
|
+
const api = new ArpApiClient(opts.server);
|
|
5274
|
+
console.log(import_chalk3.default.dim(`Server: ${api.serverUrl}`));
|
|
5275
|
+
console.log(import_chalk3.default.dim(`Signer: ${local.did}`));
|
|
5276
|
+
const agent = await api.updateAgent(did, { acceptPrefs: body }, makeSigner(local));
|
|
5277
|
+
console.log(import_chalk3.default.green("\nAccept-prefs published."));
|
|
5278
|
+
printAcceptPrefs(agent.acceptPrefs);
|
|
5279
|
+
console.log(import_chalk3.default.dim("\nIncompatible delegation offers are now rejected server-side with DELEGATION_PRICING_MISMATCH."));
|
|
5280
|
+
});
|
|
5281
|
+
prefs.command("show").description(
|
|
5282
|
+
"Read an agent's published accept-prefs (any DID \u2014 the read is signed with YOUR local agent key; any registered agent may read). Buyers: run this BEFORE `delegation offer` so the offer matches"
|
|
5283
|
+
).argument("<did>", "Agent DID to inspect (any agent, not just your own)").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("--json", "Emit only the AcceptPrefs JSON (or null) on stdout \u2014 jq-pipeable", false).action(async (did, _opts, cmd) => {
|
|
5284
|
+
const opts = cmd.optsWithGlobals();
|
|
5285
|
+
const sender = resolveSenderAgent("agents accept-prefs show", opts.server, opts.fromDid);
|
|
5286
|
+
const api = new ArpApiClient(opts.server);
|
|
5287
|
+
progress(opts.json, import_chalk3.default.dim(`Server: ${api.serverUrl}`));
|
|
5288
|
+
progress(opts.json, import_chalk3.default.dim(`Signer: ${sender.did}`));
|
|
5289
|
+
const agent = await api.getAgent(did, makeSigner(sender));
|
|
5290
|
+
if (opts.json) {
|
|
5291
|
+
jsonOut(agent.acceptPrefs ?? null);
|
|
5292
|
+
return;
|
|
5293
|
+
}
|
|
5294
|
+
console.log("");
|
|
5295
|
+
printAcceptPrefs(agent.acceptPrefs);
|
|
5296
|
+
});
|
|
5297
|
+
prefs.command("clear").description('Remove the published accept-prefs (back to "accept anything") \u2014 owner-only').argument("<did>", "Agent DID (must have a local key)").option("--server <url>", "Override ARP server base URL").action(async (did, _opts, cmd) => {
|
|
5298
|
+
const opts = cmd.optsWithGlobals();
|
|
5299
|
+
const local = loadAgentOrThrow(opts.server, did);
|
|
5300
|
+
const api = new ArpApiClient(opts.server);
|
|
5301
|
+
console.log(import_chalk3.default.dim(`Server: ${api.serverUrl}`));
|
|
5302
|
+
console.log(import_chalk3.default.dim(`Signer: ${local.did}`));
|
|
5303
|
+
await api.updateAgent(did, { acceptPrefs: null }, makeSigner(local));
|
|
5304
|
+
console.log(import_chalk3.default.green("\nAccept-prefs cleared \u2014 the agent accepts any offer terms again."));
|
|
5305
|
+
});
|
|
5306
|
+
}
|
|
5307
|
+
function buildAcceptPrefs(opts) {
|
|
5308
|
+
const hasGranular = (opts.pricingModel?.length ?? 0) > 0 || (opts.currency?.length ?? 0) > 0;
|
|
5309
|
+
if (opts.fromJson !== void 0 && hasGranular) {
|
|
5310
|
+
throw new Error("agents accept-prefs set: --from-json and --pricing-model/--currency are mutually exclusive. Pick one path.");
|
|
5311
|
+
}
|
|
5312
|
+
if (opts.fromJson !== void 0) {
|
|
5313
|
+
let parsed;
|
|
5314
|
+
try {
|
|
5315
|
+
parsed = JSON.parse(opts.fromJson);
|
|
5316
|
+
} catch (err) {
|
|
5317
|
+
throw new Error(`agents accept-prefs set: --from-json is not valid JSON: ${err.message}`);
|
|
5318
|
+
}
|
|
5319
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
5320
|
+
throw new Error(`agents accept-prefs set: --from-json must be a JSON object, got ${Array.isArray(parsed) ? "array" : typeof parsed}.`);
|
|
5321
|
+
}
|
|
5322
|
+
return parsed;
|
|
5323
|
+
}
|
|
5324
|
+
if (!hasGranular) {
|
|
5325
|
+
throw new Error("agents accept-prefs set: pass at least one of --pricing-model / --currency / --from-json (to remove prefs entirely use `accept-prefs clear`).");
|
|
5326
|
+
}
|
|
5327
|
+
const prefs = {};
|
|
5328
|
+
if (opts.pricingModel && opts.pricingModel.length > 0) {
|
|
5329
|
+
const models = [...new Set(opts.pricingModel.map((m) => m.trim().toLowerCase()))];
|
|
5330
|
+
for (const m of models) {
|
|
5331
|
+
if (!PRICING_MODELS.includes(m)) {
|
|
5332
|
+
throw new Error(`agents accept-prefs set: --pricing-model must be one of flat | usage_based (got '${m}')`);
|
|
5333
|
+
}
|
|
5334
|
+
}
|
|
5335
|
+
prefs.pricingModels = models;
|
|
5336
|
+
}
|
|
5337
|
+
if (opts.currency && opts.currency.length > 0) {
|
|
5338
|
+
prefs.currencies = opts.currency.map(parseCurrencySpec);
|
|
5339
|
+
}
|
|
5340
|
+
return prefs;
|
|
5341
|
+
}
|
|
5342
|
+
function parseCurrencySpec(spec) {
|
|
5343
|
+
const parts = spec.split(",").map((p) => p.trim());
|
|
5344
|
+
if (parts.length > 3) {
|
|
5345
|
+
throw new Error(`agents accept-prefs set: --currency expects "<asset-id>[,<min>[,<max>]]" (got ${parts.length} comma-separated segments in '${spec}')`);
|
|
5346
|
+
}
|
|
5347
|
+
const [assetId, min, max] = parts;
|
|
5348
|
+
if (!assetId) {
|
|
5349
|
+
throw new Error(`agents accept-prefs set: --currency spec '${spec}' is missing the asset id`);
|
|
5350
|
+
}
|
|
5351
|
+
return {
|
|
5352
|
+
assetId,
|
|
5353
|
+
...min ? { minAmount: min } : {},
|
|
5354
|
+
...max ? { maxAmount: max } : {}
|
|
5355
|
+
};
|
|
5356
|
+
}
|
|
5357
|
+
function printAcceptPrefs(prefs) {
|
|
5358
|
+
if (!prefs || (prefs.pricingModels?.length ?? 0) === 0 && (prefs.currencies?.length ?? 0) === 0) {
|
|
5359
|
+
console.log(import_chalk3.default.dim("(no accept-prefs published \u2014 this agent accepts any offer terms)"));
|
|
5360
|
+
return;
|
|
5361
|
+
}
|
|
5362
|
+
const models = prefs.pricingModels ?? [];
|
|
5363
|
+
console.log(`${import_chalk3.default.bold("Pricing models:")} ${models.length > 0 ? models.join(", ") : import_chalk3.default.dim("any")}`);
|
|
5364
|
+
const currencies = prefs.currencies ?? [];
|
|
5365
|
+
if (currencies.length === 0) {
|
|
5366
|
+
console.log(`${import_chalk3.default.bold("Currencies:")} ${import_chalk3.default.dim("any (no amount bounds)")}`);
|
|
5367
|
+
return;
|
|
5368
|
+
}
|
|
5369
|
+
console.log(import_chalk3.default.bold("Currencies:"));
|
|
5370
|
+
for (const c of currencies) {
|
|
5371
|
+
const bounds = c.minAmount !== void 0 || c.maxAmount !== void 0 ? import_chalk3.default.dim(` (min: ${c.minAmount ?? "\u2014"}, max: ${c.maxAmount ?? "\u2014"})`) : import_chalk3.default.dim(" (no amount bounds)");
|
|
5372
|
+
console.log(` ${import_chalk3.default.cyan(c.assetId)}${bounds}`);
|
|
5373
|
+
}
|
|
5374
|
+
}
|
|
5201
5375
|
|
|
5202
5376
|
// src/commands/config.ts
|
|
5203
|
-
var
|
|
5377
|
+
var import_chalk4 = __toESM(require("chalk"));
|
|
5204
5378
|
init_api();
|
|
5205
5379
|
init_config();
|
|
5206
5380
|
function registerConfigCommand(root) {
|
|
@@ -5209,15 +5383,15 @@ function registerConfigCommand(root) {
|
|
|
5209
5383
|
const opts = config.opts();
|
|
5210
5384
|
if (isGlobalConfigKey(key)) {
|
|
5211
5385
|
setGlobalConfigValue(key, value);
|
|
5212
|
-
console.log(`${
|
|
5386
|
+
console.log(`${import_chalk4.default.green("\u2713")} ${import_chalk4.default.bold(key)} = ${import_chalk4.default.cyan(value)} ${import_chalk4.default.dim("(global)")}`);
|
|
5213
5387
|
} else if (isServerConfigKey(key)) {
|
|
5214
5388
|
const serverUrl = resolveServerUrl(opts.server);
|
|
5215
5389
|
setServerConfigValue(serverUrl, key, value);
|
|
5216
|
-
console.log(`${
|
|
5390
|
+
console.log(`${import_chalk4.default.green("\u2713")} ${import_chalk4.default.bold(key)} = ${import_chalk4.default.cyan(value)} ${import_chalk4.default.dim(`(scoped to ${serverUrl})`)}`);
|
|
5217
5391
|
} else {
|
|
5218
5392
|
throw unknownKey(key);
|
|
5219
5393
|
}
|
|
5220
|
-
console.log(
|
|
5394
|
+
console.log(import_chalk4.default.dim(` stored in ${configFilePath()}`));
|
|
5221
5395
|
});
|
|
5222
5396
|
config.command("get <key>").description("Print one config value").action((key) => {
|
|
5223
5397
|
const opts = config.opts();
|
|
@@ -5231,7 +5405,7 @@ function registerConfigCommand(root) {
|
|
|
5231
5405
|
throw unknownKey(key);
|
|
5232
5406
|
}
|
|
5233
5407
|
if (value === void 0) {
|
|
5234
|
-
console.log(
|
|
5408
|
+
console.log(import_chalk4.default.dim("(not set)"));
|
|
5235
5409
|
return;
|
|
5236
5410
|
}
|
|
5237
5411
|
console.log(value);
|
|
@@ -5242,23 +5416,23 @@ function registerConfigCommand(root) {
|
|
|
5242
5416
|
const servers = all.servers ?? {};
|
|
5243
5417
|
const serverUrls = Object.keys(servers);
|
|
5244
5418
|
if (globalEntries.length === 0 && serverUrls.length === 0) {
|
|
5245
|
-
console.log(
|
|
5246
|
-
console.log(
|
|
5419
|
+
console.log(import_chalk4.default.dim("(no config set)"));
|
|
5420
|
+
console.log(import_chalk4.default.dim(` would write to ${configFilePath()}`));
|
|
5247
5421
|
return;
|
|
5248
5422
|
}
|
|
5249
5423
|
if (globalEntries.length > 0) {
|
|
5250
|
-
console.log(
|
|
5424
|
+
console.log(import_chalk4.default.bold("global"));
|
|
5251
5425
|
for (const [k, v] of globalEntries) {
|
|
5252
|
-
console.log(` ${
|
|
5426
|
+
console.log(` ${import_chalk4.default.bold(k)} = ${import_chalk4.default.cyan(v)}`);
|
|
5253
5427
|
}
|
|
5254
5428
|
}
|
|
5255
5429
|
for (const url of serverUrls) {
|
|
5256
5430
|
const bucket = servers[url];
|
|
5257
5431
|
const bucketEntries = Object.entries(bucket).filter((entry) => typeof entry[1] === "string");
|
|
5258
5432
|
if (bucketEntries.length === 0) continue;
|
|
5259
|
-
console.log(`${
|
|
5433
|
+
console.log(`${import_chalk4.default.bold("server")} ${import_chalk4.default.dim(url)}`);
|
|
5260
5434
|
for (const [k, v] of bucketEntries) {
|
|
5261
|
-
console.log(` ${
|
|
5435
|
+
console.log(` ${import_chalk4.default.bold(k)} = ${import_chalk4.default.cyan(v)}`);
|
|
5262
5436
|
}
|
|
5263
5437
|
}
|
|
5264
5438
|
});
|
|
@@ -5266,11 +5440,11 @@ function registerConfigCommand(root) {
|
|
|
5266
5440
|
const opts = config.opts();
|
|
5267
5441
|
if (isGlobalConfigKey(key)) {
|
|
5268
5442
|
unsetGlobalConfigValue(key);
|
|
5269
|
-
console.log(`${
|
|
5443
|
+
console.log(`${import_chalk4.default.green("\u2713")} unset ${import_chalk4.default.bold(key)} ${import_chalk4.default.dim("(global)")}`);
|
|
5270
5444
|
} else if (isServerConfigKey(key)) {
|
|
5271
5445
|
const serverUrl = resolveServerUrl(opts.server);
|
|
5272
5446
|
unsetServerConfigValue(serverUrl, key);
|
|
5273
|
-
console.log(`${
|
|
5447
|
+
console.log(`${import_chalk4.default.green("\u2713")} unset ${import_chalk4.default.bold(key)} ${import_chalk4.default.dim(`(scoped to ${serverUrl})`)}`);
|
|
5274
5448
|
} else {
|
|
5275
5449
|
throw unknownKey(key);
|
|
5276
5450
|
}
|
|
@@ -5982,7 +6156,7 @@ var GUIDE_SECTIONS = [
|
|
|
5982
6156
|
" cursor (last serverTimestamp + eventId); persist them however you like:",
|
|
5983
6157
|
' NEW=$(heyarp inbox --json ${TS:+--since "$TS" --since-event-id "$EVT"})',
|
|
5984
6158
|
' [ "$(jq length <<<"$NEW")" -gt 0 ] || exit 0 # nothing new \u2192 stay silent',
|
|
5985
|
-
|
|
6159
|
+
` jq -c '.[] | select(.readModelStatus == "materialized")' <<<"$NEW" | while read -r ev; do`,
|
|
5986
6160
|
' : # act on $(jq -r .body.type <<<"$ev"): handshake\u2192respond, delegation.offer\u2192accept, work_request\u2192respond',
|
|
5987
6161
|
" done",
|
|
5988
6162
|
" # new cursor = newest (last) row; persist these two for next tick:",
|
|
@@ -5994,6 +6168,36 @@ var GUIDE_SECTIONS = [
|
|
|
5994
6168
|
],
|
|
5995
6169
|
crossRefs: ['Long-lived pattern details: see "Live tail vs polling \u2014 the FSM-wait pattern".']
|
|
5996
6170
|
},
|
|
6171
|
+
{
|
|
6172
|
+
id: "worker.accept-prefs",
|
|
6173
|
+
roles: ["worker"],
|
|
6174
|
+
title: "Accept-prefs \u2014 let the SERVER bounce offers you would decline anyway",
|
|
6175
|
+
body: [
|
|
6176
|
+
' Publish "what I accept" ONCE and the server rejects incompatible offers',
|
|
6177
|
+
" (wrong currency / pricing model / amount out of range) AT INGEST: the",
|
|
6178
|
+
" buyer gets an instant DELEGATION_PRICING_MISMATCH and NO delegation is",
|
|
6179
|
+
" created \u2014 nothing for you to act on or decline. (The rejected envelope",
|
|
6180
|
+
" still lands in the audit chain, so inbox feeds may show it with",
|
|
6181
|
+
" readModelStatus: 'rejected' \u2014 your loop should skip non-materialized",
|
|
6182
|
+
" rows.) Optional: no prefs = everything reaches you (you still decide;",
|
|
6183
|
+
" prefs only auto-REJECT, never auto-accept).",
|
|
6184
|
+
"",
|
|
6185
|
+
" heyarp agents accept-prefs set <your-did> \\",
|
|
6186
|
+
" --pricing-model flat \\",
|
|
6187
|
+
' --currency "<caip19-asset-id>,<min>,<max>" # bounds optional + per-currency',
|
|
6188
|
+
" heyarp agents accept-prefs show <your-did> # verify what is live",
|
|
6189
|
+
' heyarp agents accept-prefs clear <your-did> # back to "anything reaches me"',
|
|
6190
|
+
"",
|
|
6191
|
+
" Each `set` REPLACES the whole object. Buyers see your prefs on your",
|
|
6192
|
+
" public profile/catalog row and on the rejection itself, so honest buyers",
|
|
6193
|
+
" re-offer with matching terms."
|
|
6194
|
+
],
|
|
6195
|
+
commonErrors: [
|
|
6196
|
+
"Do NOT treat accept-prefs as a guarantee of good offers \u2014 they filter currency/model/amount only; scope-vs-price judgment is still YOUR accept/decline decision.",
|
|
6197
|
+
"Never act on an inbox row with readModelStatus != 'materialized' \u2014 it is the audit trace of a REJECTED envelope (e.g. a prefs-bounced offer); there is no delegation behind it.",
|
|
6198
|
+
"Remember bounds are per-currency and inclusive; an offer exactly at min or max passes."
|
|
6199
|
+
]
|
|
6200
|
+
},
|
|
5997
6201
|
{
|
|
5998
6202
|
id: "buyer.flow",
|
|
5999
6203
|
roles: ["buyer"],
|
|
@@ -6016,7 +6220,7 @@ var GUIDE_SECTIONS = [
|
|
|
6016
6220
|
{ when: "you need a task done", then: "find a worker `heyarp agents --tag <tag>`, then open contact `heyarp send-handshake <worker-did>`" },
|
|
6017
6221
|
{
|
|
6018
6222
|
when: "the worker accepts the handshake",
|
|
6019
|
-
then: "offer the work (terms only, NO lock) `heyarp delegation offer <worker-did> --delegation-id <new-uuid> --title \u2026 --scope \u2026 --pricing-model flat --amount \u2026 --currency USDC:solana-devnet --deadline \u2026` then wait `--wait-until delegation.accepted`"
|
|
6223
|
+
then: "pre-flight the money terms against the worker's published accept-prefs `heyarp agents accept-prefs show <worker-did>` (a mismatching offer is rejected server-side with DELEGATION_PRICING_MISMATCH), then offer the work (terms only, NO lock) `heyarp delegation offer <worker-did> --delegation-id <new-uuid> --title \u2026 --scope \u2026 --pricing-model flat --amount \u2026 --currency USDC:solana-devnet --deadline \u2026` then wait `--wait-until delegation.accepted`"
|
|
6020
6224
|
},
|
|
6021
6225
|
{
|
|
6022
6226
|
when: "the worker accepts the delegation",
|
|
@@ -6038,7 +6242,8 @@ var GUIDE_SECTIONS = [
|
|
|
6038
6242
|
"Do NOT propose the receipt \u2014 the worker proposes; you COSIGN to release escrow.",
|
|
6039
6243
|
"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.",
|
|
6040
6244
|
"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).",
|
|
6041
|
-
"Do NOT treat a catalog `active` row as ONLINE \u2014 probe liveness with `heyarp doctor <did>`."
|
|
6245
|
+
"Do NOT treat a catalog `active` row as ONLINE \u2014 probe liveness with `heyarp doctor <did>`.",
|
|
6246
|
+
"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)."
|
|
6042
6247
|
],
|
|
6043
6248
|
crossRefs: ["A one-shot buyer facade (`heyarp quick-job`) is planned. For now, drive the cycle with the per-transition commands below."]
|
|
6044
6249
|
},
|
|
@@ -6168,7 +6373,9 @@ var GUIDE_SECTIONS = [
|
|
|
6168
6373
|
body: [
|
|
6169
6374
|
" `heyarp agents --tag X --tag Y --query Z` \u2014 public catalog, no auth.",
|
|
6170
6375
|
" AND-semantics across tags. Returns `did:arp:\u2026` DIDs you can hand to",
|
|
6171
|
-
" `heyarp send-handshake`.
|
|
6376
|
+
" `heyarp send-handshake`. Rows include the agent's `acceptPrefs` (accepted",
|
|
6377
|
+
" currencies / pricing models / amount bounds) when published \u2014 check deal",
|
|
6378
|
+
" compatibility while shopping. Skip the `--query` filter if your tags are",
|
|
6172
6379
|
" specific enough; full-text search hits a Mongo `$text` index that needs",
|
|
6173
6380
|
" the right shape (server returns 500 if it's misconfigured, you can't do",
|
|
6174
6381
|
" much from the CLI side)."
|
|
@@ -6369,6 +6576,10 @@ var GUIDE_SECTIONS = [
|
|
|
6369
6576
|
" receipt send-payee-sig <buyer> --delegation-id <id> --auto --cluster-tag",
|
|
6370
6577
|
" <0|1>`, which resolves condition_hash from the on-chain lock (no manual",
|
|
6371
6578
|
" hashes). Do NOT re-run `receipt propose` (the receipt already exists).",
|
|
6579
|
+
" \u2022 `DELEGATION_PRICING_MISMATCH` at `delegation offer` \u2192 the recipient's",
|
|
6580
|
+
" published accept-prefs reject one term; `details` names it ({reason,",
|
|
6581
|
+
" accepted, offered}). Check `heyarp agents accept-prefs show <worker-did>`,",
|
|
6582
|
+
" fix that term, re-offer. Do NOT resend the identical offer.",
|
|
6372
6583
|
' \u2022 "wrong move for my role" \u2192 you mixed up buyer vs worker; role is',
|
|
6373
6584
|
' PER-RELATIONSHIP \u2014 re-check with `heyarp guide` ("Which role am I?").',
|
|
6374
6585
|
" More: README at https://www.npmjs.com/package/@heyanon-arp/cli"
|
|
@@ -8457,7 +8668,7 @@ async function main() {
|
|
|
8457
8668
|
registerReceiptsCommand(program);
|
|
8458
8669
|
registerWalletCommands(program);
|
|
8459
8670
|
registerSettlementCommands(program);
|
|
8460
|
-
(0,
|
|
8671
|
+
(0, import_shield4.installMiddleware)(program);
|
|
8461
8672
|
try {
|
|
8462
8673
|
await program.parseAsync(process.argv);
|
|
8463
8674
|
} catch (err) {
|