402mob-runtime 0.3.0 → 0.3.1

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/README.md CHANGED
@@ -7,14 +7,14 @@ An owner-controlled Base USDC signer, delegated buyer and text-statistics seller
7
7
  Use Node.js 24+ on Linux or macOS. Check https://evidence.contact/agent-runtime-release.json for this version's publication status. Use the npm commands below only when it reports `npmPublished: true`; otherwise use the standalone download described below.
8
8
 
9
9
  ```sh
10
- npm exec --yes --package=402mob-runtime@0.3.0 -- 402mob-runtime wallet web \
10
+ npm exec --yes --package=402mob-runtime@0.3.1 -- 402mob-runtime wallet web \
11
11
  --dir "$HOME/.local/share/402mob/runtime-owner"
12
12
  ```
13
13
 
14
14
  For a persistent CLI, install into your own prefix:
15
15
 
16
16
  ```sh
17
- npm install --prefix "$HOME/.local/share/402mob/runtime-cli" --ignore-scripts 402mob-runtime@0.3.0
17
+ npm install --prefix "$HOME/.local/share/402mob/runtime-cli" --ignore-scripts 402mob-runtime@0.3.1
18
18
  export PATH="$HOME/.local/share/402mob/runtime-cli/node_modules/.bin:$PATH"
19
19
  ```
20
20
 
@@ -44,7 +44,9 @@ Load the copied connection’s `token` into `MOB_RUNTIME_TOKEN` and `gateway` in
44
44
 
45
45
  Use `buyer prepare` for text-statistics Work Tickets. Use `buyer inspect` and `buyer prepare-artifact` for exact prepared offers or pinned Payment Links. `buyer run` submits the retained request and may spend within its delegation. It checks settlement and result bytes and records a receipt. Repeat the same saved request to recover an interrupted purchase.
46
46
 
47
- For CLI-only setup, `wallet grant --dir DIR --name "Agent"` prints a private connection JSON. Add `--max-usdc` for an optional cap, `--file` for an advanced policy instead of `--name`, or `--out` for an optional private file. Use one owner signer per wallet directory.
47
+ For CLI-only setup, `wallet grant --dir DIR --name "Agent"` prints a private connection JSON. Add `--max-usdc` for an optional cap, `--file` for an advanced policy instead of `--name`, or `--out` for an optional private file. Stdout and file exports both include `gateway`, defaulting to `http://127.0.0.1:4031`. Set `wallet grant --gateway http://127.0.0.1:PORT` when your signer uses another port; buyer commands can override a saved destination with `--gateway`. Use one owner signer per wallet directory.
48
+
49
+ Offer inspection fetches only the exact published offer share, so a large seller catalog does not block inspection. The wallet console uses the compact merchant identity response.
48
50
 
49
51
  Worker discovery returns at most five full profiles per page. Follow `nextCursor` until it is null, even if policy filtering leaves a page empty.
50
52
 
@@ -64,7 +66,7 @@ Run `402mob-runtime --help` for all commands. Full guides: https://evidence.cont
64
66
 
65
67
  `local_port_in_use` means another process already owns the named local port. If it is your signer, press Enter in its original terminal for a new pairing link, or stop it with Ctrl+C and restart with the same `--dir`. Do not start a second signer for the same wallet on different ports. The CLI preserves wallet state and closes any listener opened during a failed startup. Version 0.2.0 reported this condition as `adapter_failure`.
66
68
 
67
- If the local console page returns `adapter_failure` while the hosted console works, upgrade from 0.2.0 or 0.2.1 to 0.3.0. Those versions incorrectly blocked page assets beneath hidden installation directories such as `.npm` and `.local`. Stop the old signer, restart the upgraded version with the same wallet `--dir`, and use its new pairing link.
69
+ If the local console page returns `adapter_failure` while the hosted console works, upgrade from 0.2.0 or 0.2.1 to 0.3.1. Those versions incorrectly blocked page assets beneath hidden installation directories such as `.npm` and `.local`. Stop the old signer, restart the upgraded version with the same wallet `--dir`, and use its new pairing link.
68
70
 
69
71
  ## Recovery and custody
70
72
 
@@ -64206,38 +64206,26 @@ var RuntimeCatalog = class {
64206
64206
  const match = url2.pathname.match(/^\/s\/([^/]+)\/([^/]+)\/([a-f0-9]{64})$/);
64207
64207
  requireThat(match, "invalid_share_url");
64208
64208
  const merchantId = uuid3.parse(match[1]), offerId = uuid3.parse(match[2]);
64209
- const raw = await this.http.json(`/v1/merchants/${merchantId}/offers/${offerId}/share`, external_exports.object({ schema: external_exports.enum(["402mob.checkout-share.v3", "402mob.checkout-share.v4"]), origin: external_exports.string(), offer: external_exports.record(external_exports.string(), external_exports.unknown()), id: digest }).strict());
64210
- requireThat(raw.origin === this.http.origin && raw.id === match[3] && sha256(JSON.stringify({ schema: raw.schema, origin: raw.origin, offer: raw.offer })) === raw.id, "share_terms_changed");
64211
- const resource = await this.inspect(merchantId, offerId), terms = resourceTerms.parse(Object.fromEntries(Object.entries(raw.offer).filter(([key]) => !["amountUSDC", "resultSizeKnownBeforePayment", "checkout"].includes(key))));
64212
- requireThat(canonical(terms) === canonical(resource.terms) && raw.offer.checkout === `${this.http.origin}/v1/merchants/${merchantId}/offers/${offerId}/checkout`, "share_terms_changed");
64213
- return inspectedResource.parse({ ...resource, sourceShareId: raw.id });
64209
+ const { resource, shareId } = await this.readOffer(merchantId, offerId);
64210
+ requireThat(shareId === match[3], "share_terms_changed");
64211
+ return inspectedResource.parse({ ...resource, sourceShareId: shareId });
64214
64212
  }
64215
64213
  async inspect(merchantId, offerId) {
64214
+ return (await this.readOffer(merchantId, offerId)).resource;
64215
+ }
64216
+ async readOffer(merchantId, offerId) {
64216
64217
  uuid3.parse(merchantId);
64217
64218
  uuid3.parse(offerId);
64218
- const profile = await this.http.json("/v1/merchants/" + merchantId, external_exports.object({ merchant, offers: external_exports.array(offer) }));
64219
- const selected = profile.offers.find((o) => o.id === offerId);
64220
- requireThat(profile.merchant.id === merchantId && selected, "offer_unavailable");
64221
- const terms = resourceTerms.parse({
64222
- merchantId,
64223
- offerId,
64224
- version: selected.version,
64225
- title: selected.title,
64226
- description: selected.description,
64227
- payee: profile.merchant.payoutAddress.toLowerCase(),
64228
- network: NETWORK,
64229
- asset: USDC.toLowerCase(),
64230
- amountAtomic: selected.amountAtomic,
64231
- contentType: selected.contentType === "application/json" ? "application/json" : "text/plain",
64232
- artifact: selected.artifact,
64233
- ...selected.purchaseDecision ? { purchaseDecision: selected.purchaseDecision } : {},
64234
- ...selected.offerTermsHash ? { offerTermsHash: selected.offerTermsHash } : {}
64235
- });
64219
+ const raw = await this.http.json(`/v1/merchants/${merchantId}/offers/${offerId}/share`, external_exports.object({ schema: external_exports.enum(["402mob.checkout-share.v3", "402mob.checkout-share.v4"]), origin: external_exports.string(), offer: external_exports.record(external_exports.string(), external_exports.unknown()), id: digest }).strict());
64220
+ requireThat(raw.origin === this.http.origin && sha256(JSON.stringify({ schema: raw.schema, origin: raw.origin, offer: raw.offer })) === raw.id, "share_terms_changed");
64221
+ const terms = resourceTerms.extend({ version: offer.shape.version }).parse(Object.fromEntries(Object.entries(raw.offer).filter(([key]) => !["amountUSDC", "resultSizeKnownBeforePayment", "checkout"].includes(key))));
64222
+ requireThat(terms.merchantId === merchantId && terms.offerId === offerId && terms.asset.toLowerCase() === USDC.toLowerCase() && raw.offer.checkout === `${this.http.origin}/v1/merchants/${merchantId}/offers/${offerId}/checkout` && raw.offer.resultSizeKnownBeforePayment === false && raw.offer.amountUSDC === `${BigInt(terms.amountAtomic) / 1000000n}.${String(BigInt(terms.amountAtomic) % 1000000n).padStart(6, "0")}`, "offer_terms_mismatch");
64223
+ requireThat(raw.schema === "402mob.checkout-share.v4" ? Boolean(terms.purchaseDecision && terms.offerTermsHash) : !terms.purchaseDecision && !terms.offerTermsHash, "offer_terms_mismatch");
64236
64224
  if (terms.purchaseDecision || terms.offerTermsHash) {
64237
64225
  const { offerTermsHash, ...document2 } = terms;
64238
64226
  requireThat(terms.purchaseDecision && offerTermsHash === sha256(canonical({ schema: "402mob.offer-terms.v1", ...document2 })), "offer_terms_mismatch");
64239
64227
  }
64240
- return inspectedResource.parse({ terms, termsHash: sha256(canonical(terms)) });
64228
+ return { resource: inspectedResource.parse({ terms, termsHash: sha256(canonical(terms)) }), shareId: raw.id };
64241
64229
  }
64242
64230
  };
64243
64231
 
@@ -65473,7 +65461,7 @@ var WalletWebService = class {
65473
65461
  return this.state();
65474
65462
  }
65475
65463
  async merchant(id) {
65476
- const response = await new RuntimeHttp(this.serviceOrigin, this.fetcher).json("/v1/merchants/" + uuid3.parse(id), external_exports.object({ merchant: webMerchant.passthrough() }));
65464
+ const response = await new RuntimeHttp(this.serviceOrigin, this.fetcher).json("/v1/merchants/" + uuid3.parse(id) + "?includeOffers=false", external_exports.object({ merchant: webMerchant.passthrough() }));
65477
65465
  requireThat(response.merchant.id === id, "merchant_identity_mismatch");
65478
65466
  return webMerchant.parse({ id: response.merchant.id, name: response.merchant.name, payoutAddress: response.merchant.payoutAddress });
65479
65467
  }
@@ -65764,6 +65752,7 @@ Owner commands:
65764
65752
  wallet status --dir DIR
65765
65753
  wallet grant --dir DIR --name "Agent" [--max-usdc 1] [--out credential.json]
65766
65754
  Optional advanced policy: --file policy.json instead of --name.
65755
+ --gateway URL sets the private connection destination (default http://127.0.0.1:4031).
65767
65756
  wallet limit --dir DIR --file limit-update.json
65768
65757
  wallet allocation --dir DIR --id DELEGATION_UUID --file allocation-update.json
65769
65758
  wallet revoke --dir DIR --id DELEGATION_UUID
@@ -65802,7 +65791,7 @@ Keep directories and credentials private. Funding is an owner transfer of native
65802
65791
  Base USDC to the generated address; creating a wallet or grant moves no money.
65803
65792
  The local wallet enforces policy in software. It is not an on-chain session wallet.
65804
65793
  Use the original request file and directories for retries. No command resets a ledger.
65805
- Optional model admission: add --model-config FILE to wallet serve or seller once/run.
65794
+ Optional model admission: add --model-config FILE to wallet serve/web or seller once/run.
65806
65795
  It sends task input to OpenRouter and incurs inference costs. Omit it for deterministic execution.
65807
65796
  `;
65808
65797
  var { positionals, values: v } = parseArgs({ allowPositionals: true, strict: true, options: {
@@ -66001,16 +65990,18 @@ async function main() {
66001
65990
  const file2 = v.out;
66002
65991
  if (file2) requireThat(!existsSync2(file2), "credential_file_exists");
66003
65992
  requireThat(!v.file || !v.name && !v["max-usdc"], "choose_policy_file_or_name");
65993
+ const gateway = origin(v.gateway ?? "http://127.0.0.1:4031");
66004
65994
  const grant = wallet2.grant(v.file ? readJson(v.file) : { name: needed("name"), ...v["max-usdc"] ? { maxTotalUSDC: v["max-usdc"] } : {} }, randomUUID5());
65995
+ const connection = { ...grant, gateway };
66005
65996
  if (file2) {
66006
65997
  try {
66007
- out(file2, grant);
65998
+ out(file2, connection);
66008
65999
  } catch (e) {
66009
66000
  wallet2.revoke(grant.id);
66010
66001
  throw e;
66011
66002
  }
66012
66003
  print({ delegationId: grant.id, credentialFile: resolve2(file2), wallet: wallet2.address, policy: grant.policy });
66013
- } else print({ ...grant, gateway: "http://127.0.0.1:4031" });
66004
+ } else print(connection);
66014
66005
  return;
66015
66006
  }
66016
66007
  if (command === "revoke") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "402mob-runtime",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Owner-controlled Base USDC delegation and recoverable buyer/seller workflows",
5
5
  "license": "MIT",
6
6
  "type": "module",