@lucid-agents/taskmarket 1.12.1 → 1.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +27 -27
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -2690,7 +2690,7 @@ var ApiError = class extends Error {
2690
2690
  * The backend's machine-readable classification of the failure (ADR-0058).
2691
2691
  *
2692
2692
  * Before it existed the CLI rendered every failure identically, which is why
2693
- * `docs/CLI_GUIDE.md` had to tell script authors never to auto-retry a paid command: there was
2693
+ * `docs/guides/CLI_GUIDE.md` had to tell script authors never to auto-retry a paid command: there was
2694
2694
  * no way to tell a write that is still landing from one that was definitively rejected, and
2695
2695
  * retrying the first is a second payment. `reason` is that way.
2696
2696
  *
@@ -2819,13 +2819,13 @@ async function apiDelete(path7, options) {
2819
2819
  }
2820
2820
 
2821
2821
  // src/lib/x402-errors.ts
2822
- var ExternalX402Error = class extends Error {
2822
+ var X402PayError = class extends Error {
2823
2823
  payment;
2824
2824
  pending;
2825
2825
  status;
2826
2826
  constructor(message, options = {}) {
2827
2827
  super(message, options.cause === void 0 ? void 0 : { cause: options.cause });
2828
- this.name = "ExternalX402Error";
2828
+ this.name = "X402PayError";
2829
2829
  this.payment = options.payment;
2830
2830
  this.pending = options.pending;
2831
2831
  this.status = options.status;
@@ -2842,18 +2842,18 @@ function printResult(data, options) {
2842
2842
  function renderFailure(error, options) {
2843
2843
  const message = error instanceof Error ? error.message : options?.fallback ?? String(error);
2844
2844
  const apiError = error instanceof ApiError ? error : void 0;
2845
- const externalX402Error = error instanceof ExternalX402Error ? error : void 0;
2845
+ const x402PayError = error instanceof X402PayError ? error : void 0;
2846
2846
  const idempotencyKey = options?.idempotencyKey ?? apiError?.idempotencyKey ?? idempotencyKeyForError(error);
2847
2847
  const envelope = apiError?.envelope;
2848
2848
  process.stderr.write(
2849
2849
  JSON.stringify({
2850
2850
  ok: false,
2851
2851
  error: message,
2852
- ...apiError !== void 0 ? { status: apiError.status } : externalX402Error?.status !== void 0 ? { status: externalX402Error.status } : {},
2852
+ ...apiError !== void 0 ? { status: apiError.status } : x402PayError?.status !== void 0 ? { status: x402PayError.status } : {},
2853
2853
  ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
2854
2854
  ...envelope !== void 0 ? { ...envelope, pending: isInFlightApiError(envelope) } : {},
2855
- ...externalX402Error?.pending !== void 0 ? { pending: externalX402Error.pending } : {},
2856
- ...externalX402Error?.payment !== void 0 ? { payment: externalX402Error.payment } : {},
2855
+ ...x402PayError?.pending !== void 0 ? { pending: x402PayError.pending } : {},
2856
+ ...x402PayError?.payment !== void 0 ? { payment: x402PayError.payment } : {},
2857
2857
  ...options?.details ?? {}
2858
2858
  }) + "\n"
2859
2859
  );
@@ -7696,7 +7696,7 @@ async function confirmManualResolution() {
7696
7696
  return answer.trim().toLowerCase() === "resolve";
7697
7697
  }
7698
7698
  var x402PaymentsCommand = new Command71("payments").description(
7699
- "Inspect and reconcile external x402 payment records"
7699
+ "Inspect and reconcile X402 Pay payment records"
7700
7700
  );
7701
7701
  x402PaymentsCommand.command("list").description("List current payment records").addOption(new Option2("--state <state>", "Filter by state").choices(PAYMENT_STATES)).action(async (options) => {
7702
7702
  const payments = await listX402Payments({ state: options.state });
@@ -7746,7 +7746,7 @@ async function confirmUnattendedRule(rule) {
7746
7746
  return answer.trim().toLowerCase() === "authorize";
7747
7747
  }
7748
7748
  var x402PolicyCommand = new Command72("policy").description(
7749
- "Manage local external x402 spending policy"
7749
+ "Manage local X402 Pay spending policy"
7750
7750
  );
7751
7751
  x402PolicyCommand.command("init").description("Create a deny-all policy file").action(async () => {
7752
7752
  const policy = await initializeX402Policy();
@@ -7784,7 +7784,7 @@ for (const enabled of [true, false]) {
7784
7784
  import { Command as Command73, Option as Option3 } from "commander";
7785
7785
  import { createInterface as createInterface5 } from "readline";
7786
7786
 
7787
- // src/lib/external-x402-client.ts
7787
+ // src/lib/x402-pay-client.ts
7788
7788
  import { x402Client } from "@x402/core/client";
7789
7789
  import { ExactEvmScheme } from "@x402/evm/exact/client";
7790
7790
  import { UptoEvmScheme } from "@x402/evm/upto/client";
@@ -7807,7 +7807,7 @@ var FORBIDDEN_HEADERS = /* @__PURE__ */ new Set([
7807
7807
  "payment-signature",
7808
7808
  "transfer-encoding"
7809
7809
  ]);
7810
- function parseExternalX402Url(raw) {
7810
+ function parseX402PayUrl(raw) {
7811
7811
  let url;
7812
7812
  try {
7813
7813
  url = new URL(raw);
@@ -7842,7 +7842,7 @@ function isPrivateNetworkAddress(address) {
7842
7842
  if (family === 6) return isPrivateIpv6(address);
7843
7843
  return true;
7844
7844
  }
7845
- async function validateExternalX402Destination(url, options) {
7845
+ async function validateX402PayDestination(url, options) {
7846
7846
  const resolve = options.resolve ?? dns.lookup;
7847
7847
  const addresses = await resolve(url.hostname, { all: true, verbatim: true });
7848
7848
  if (addresses.length === 0)
@@ -7914,7 +7914,7 @@ async function loadExternalHeaders(input) {
7914
7914
  return result;
7915
7915
  }
7916
7916
  async function prepareX402HttpRequest(input) {
7917
- const url = parseExternalX402Url(input.rawUrl);
7917
+ const url = parseX402PayUrl(input.rawUrl);
7918
7918
  const method = input.method.toUpperCase();
7919
7919
  if (method !== "GET" && method !== "POST") throw new Error("x402 method must be GET or POST");
7920
7920
  if (input.json !== void 0 && input.bodyFile) {
@@ -8321,7 +8321,7 @@ function authorizationKindFromPaymentPayload(payload) {
8321
8321
  return void 0;
8322
8322
  }
8323
8323
 
8324
- // src/lib/external-x402-client.ts
8324
+ // src/lib/x402-pay-client.ts
8325
8325
  function sameRequirement(left, right) {
8326
8326
  return left.scheme === right.scheme && left.network === right.network && left.amount === right.amount && left.asset.toLowerCase() === right.asset.toLowerCase() && left.payTo.toLowerCase() === right.payTo.toLowerCase();
8327
8327
  }
@@ -8438,7 +8438,7 @@ function signerFor(account) {
8438
8438
  signTypedData: async (typedData) => account.signTypedData(typedData)
8439
8439
  };
8440
8440
  }
8441
- async function executeExternalX402Request(options) {
8441
+ async function executeX402PayRequest(options) {
8442
8442
  const nonInteractive = Boolean(options.nonInteractive);
8443
8443
  const request = await prepareX402HttpRequest({
8444
8444
  rawUrl: options.rawUrl,
@@ -8456,7 +8456,7 @@ async function executeExternalX402Request(options) {
8456
8456
  request,
8457
8457
  requestedRuleId: options.policyRuleId
8458
8458
  });
8459
- await validateExternalX402Destination(request.url, { allowPrivateNetwork });
8459
+ await validateX402PayDestination(request.url, { allowPrivateNetwork });
8460
8460
  const account = options.account ?? await createWalletAccountFromKeystore(await loadKeystore());
8461
8461
  const rpcOptions = rpcConfigurationByChainId(policy);
8462
8462
  let selectedAuthorization;
@@ -8637,7 +8637,7 @@ async function executeExternalX402Request(options) {
8637
8637
  const guardedFetch = async (input, init) => {
8638
8638
  const outgoing = new Request(input, { ...init, redirect: "error" });
8639
8639
  const isPaid = outgoing.headers.has("payment-signature") || outgoing.headers.has("x-payment");
8640
- await validateExternalX402Destination(request.url, { allowPrivateNetwork });
8640
+ await validateX402PayDestination(request.url, { allowPrivateNetwork });
8641
8641
  if (isPaid) {
8642
8642
  if (!paymentRecord) throw new Error("Paid x402 request has no journal reservation");
8643
8643
  paidRequestDispatched = true;
@@ -8651,7 +8651,7 @@ async function executeExternalX402Request(options) {
8651
8651
  state: "unknown",
8652
8652
  error: error instanceof Error ? error.message : String(error)
8653
8653
  });
8654
- throw new ExternalX402Error("External x402 outcome is unknown; do not retry", {
8654
+ throw new X402PayError("External x402 outcome is unknown; do not retry", {
8655
8655
  cause: error,
8656
8656
  payment: paymentRecord,
8657
8657
  pending: true
@@ -8670,7 +8670,7 @@ async function executeExternalX402Request(options) {
8670
8670
  redirect: "error"
8671
8671
  });
8672
8672
  } catch (error) {
8673
- if (error instanceof ExternalX402Error) throw error;
8673
+ if (error instanceof X402PayError) throw error;
8674
8674
  if (paymentRecord) {
8675
8675
  const current = await getX402Payment(paymentRecord.id);
8676
8676
  if (["ready", "dispatched", "unknown"].includes(current.state) || paidRequestDispatched) {
@@ -8678,14 +8678,14 @@ async function executeExternalX402Request(options) {
8678
8678
  state: "unknown",
8679
8679
  error: error instanceof Error ? error.message : String(error)
8680
8680
  });
8681
- throw new ExternalX402Error("External x402 outcome is unknown; do not retry", {
8681
+ throw new X402PayError("External x402 outcome is unknown; do not retry", {
8682
8682
  cause: error,
8683
8683
  payment: paymentRecord,
8684
8684
  pending: true
8685
8685
  });
8686
8686
  }
8687
8687
  }
8688
- throw new ExternalX402Error(
8688
+ throw new X402PayError(
8689
8689
  error instanceof Error ? error.message : "External x402 request failed",
8690
8690
  { cause: error, payment: paymentRecord, pending: false }
8691
8691
  );
@@ -8693,7 +8693,7 @@ async function executeExternalX402Request(options) {
8693
8693
  if (paymentRecord) {
8694
8694
  paymentRecord = await getX402Payment(paymentRecord.id);
8695
8695
  if (paymentRecord.state !== "settled") {
8696
- throw new ExternalX402Error("External x402 outcome is unknown; do not retry", {
8696
+ throw new X402PayError("External x402 outcome is unknown; do not retry", {
8697
8697
  payment: paymentRecord,
8698
8698
  pending: true,
8699
8699
  status: response.status
@@ -8705,7 +8705,7 @@ async function executeExternalX402Request(options) {
8705
8705
  responseData = await externalResponseData(response, { outputPath: options.outputPath });
8706
8706
  } catch (error) {
8707
8707
  if (paymentRecord) {
8708
- throw new ExternalX402Error(
8708
+ throw new X402PayError(
8709
8709
  error instanceof Error ? error.message : "Failed to process external response",
8710
8710
  { cause: error, payment: paymentRecord, pending: false, status: response.status }
8711
8711
  );
@@ -8713,7 +8713,7 @@ async function executeExternalX402Request(options) {
8713
8713
  throw error;
8714
8714
  }
8715
8715
  if (!response.ok) {
8716
- throw new ExternalX402Error(`External service returned HTTP ${response.status}`, {
8716
+ throw new X402PayError(`External service returned HTTP ${response.status}`, {
8717
8717
  payment: paymentRecord,
8718
8718
  pending: false,
8719
8719
  status: response.status
@@ -8739,7 +8739,7 @@ async function confirm(lines) {
8739
8739
  readline.close();
8740
8740
  return answer.trim().toLowerCase() === "yes";
8741
8741
  }
8742
- var x402RequestCommand = new Command73("request").description("Request and pay for a direct external x402 HTTP resource").argument("<url>", "HTTPS resource URL").addOption(new Option3("--method <method>", "HTTP method").choices(["GET", "POST"]).default("GET")).option("--json <json>", "Inline JSON POST body").option("--body-file <path>", "Read JSON POST body from a file").option("--headers-file <path>", "Read request headers from an owner-only JSON file").option(
8742
+ var x402RequestCommand = new Command73("request").description("Request and pay for a direct x402 HTTP resource (X402 Pay)").argument("<url>", "HTTPS resource URL").addOption(new Option3("--method <method>", "HTTP method").choices(["GET", "POST"]).default("GET")).option("--json <json>", "Inline JSON POST body").option("--body-file <path>", "Read JSON POST body from a file").option("--headers-file <path>", "Read request headers from an owner-only JSON file").option(
8743
8743
  "--header-env <header=ENV_VAR>",
8744
8744
  "Read one request header from an environment variable (repeatable)",
8745
8745
  collect2,
@@ -8750,7 +8750,7 @@ var x402RequestCommand = new Command73("request").description("Request and pay f
8750
8750
  headersFile: options.headersFile,
8751
8751
  headerEnv: options.headerEnv
8752
8752
  });
8753
- const result = await executeExternalX402Request({
8753
+ const result = await executeX402PayRequest({
8754
8754
  rawUrl: url,
8755
8755
  method: options.method,
8756
8756
  json: options.json,
@@ -8784,7 +8784,7 @@ var x402RequestCommand = new Command73("request").description("Request and pay f
8784
8784
 
8785
8785
  // src/commands/x402/index.ts
8786
8786
  var x402Command = new Command74("x402").description(
8787
- "Pay external x402 services with local spending policies"
8787
+ "Pay x402 services with local spending policies (X402 Pay)"
8788
8788
  );
8789
8789
  x402Command.addCommand(x402RequestCommand);
8790
8790
  x402Command.addCommand(x402PolicyCommand);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucid-agents/taskmarket",
3
- "version": "1.12.1",
3
+ "version": "1.12.2",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "taskmarket": "./dist/index.js"
@@ -42,6 +42,6 @@
42
42
  "test": "vitest run",
43
43
  "test:watch": "vitest watch",
44
44
  "smoke:xmtp-live": "tsx scripts/smoke-xmtp-live.ts",
45
- "smoke:x402-external": "tsx scripts/smoke-external-x402.ts"
45
+ "smoke:x402-pay": "tsx scripts/smoke-x402-pay.ts"
46
46
  }
47
47
  }