402mob-runtime 0.3.0 → 0.3.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.
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.2 -- 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.2
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.2. 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
 
@@ -63917,9 +63917,12 @@ var BaseUsdcReader = class {
63917
63917
  try {
63918
63918
  requireThat(await this.client.getChainId() === 8453, "wrong_rpc_chain");
63919
63919
  const r = await this.client.getTransactionReceipt({ hash: proof2.transaction });
63920
+ requireThat(r.transactionHash.toLowerCase() === proof2.transaction.toLowerCase(), "transaction_mismatch");
63920
63921
  requireThat(r.status === "success", "transaction_reverted");
63921
- const tip = await this.client.getBlockNumber();
63922
+ const tip = await this.client.getBlockNumber({ cacheTime: 0 });
63922
63923
  if (tip < r.blockNumber + 2n) throw new RuntimeFault("chain_confirming", true);
63924
+ const block = await this.client.getBlock({ blockNumber: r.blockNumber });
63925
+ if (!block.hash || block.hash.toLowerCase() !== r.blockHash.toLowerCase()) throw new RuntimeFault("chain_confirming", true);
63923
63926
  const matches = r.logs.filter((log) => {
63924
63927
  if (log.address.toLowerCase() !== USDC.toLowerCase()) return false;
63925
63928
  try {
@@ -64206,38 +64209,26 @@ var RuntimeCatalog = class {
64206
64209
  const match = url2.pathname.match(/^\/s\/([^/]+)\/([^/]+)\/([a-f0-9]{64})$/);
64207
64210
  requireThat(match, "invalid_share_url");
64208
64211
  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 });
64212
+ const { resource, shareId } = await this.readOffer(merchantId, offerId);
64213
+ requireThat(shareId === match[3], "share_terms_changed");
64214
+ return inspectedResource.parse({ ...resource, sourceShareId: shareId });
64214
64215
  }
64215
64216
  async inspect(merchantId, offerId) {
64217
+ return (await this.readOffer(merchantId, offerId)).resource;
64218
+ }
64219
+ async readOffer(merchantId, offerId) {
64216
64220
  uuid3.parse(merchantId);
64217
64221
  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
- });
64222
+ 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());
64223
+ requireThat(raw.origin === this.http.origin && sha256(JSON.stringify({ schema: raw.schema, origin: raw.origin, offer: raw.offer })) === raw.id, "share_terms_changed");
64224
+ const terms = resourceTerms.extend({ version: offer.shape.version }).parse(Object.fromEntries(Object.entries(raw.offer).filter(([key]) => !["amountUSDC", "resultSizeKnownBeforePayment", "checkout"].includes(key))));
64225
+ 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");
64226
+ requireThat(raw.schema === "402mob.checkout-share.v4" ? Boolean(terms.purchaseDecision && terms.offerTermsHash) : !terms.purchaseDecision && !terms.offerTermsHash, "offer_terms_mismatch");
64236
64227
  if (terms.purchaseDecision || terms.offerTermsHash) {
64237
64228
  const { offerTermsHash, ...document2 } = terms;
64238
64229
  requireThat(terms.purchaseDecision && offerTermsHash === sha256(canonical({ schema: "402mob.offer-terms.v1", ...document2 })), "offer_terms_mismatch");
64239
64230
  }
64240
- return inspectedResource.parse({ terms, termsHash: sha256(canonical(terms)) });
64231
+ return { resource: inspectedResource.parse({ terms, termsHash: sha256(canonical(terms)) }), shareId: raw.id };
64241
64232
  }
64242
64233
  };
64243
64234
 
@@ -65473,7 +65464,7 @@ var WalletWebService = class {
65473
65464
  return this.state();
65474
65465
  }
65475
65466
  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() }));
65467
+ const response = await new RuntimeHttp(this.serviceOrigin, this.fetcher).json("/v1/merchants/" + uuid3.parse(id) + "?includeOffers=false", external_exports.object({ merchant: webMerchant.passthrough() }));
65477
65468
  requireThat(response.merchant.id === id, "merchant_identity_mismatch");
65478
65469
  return webMerchant.parse({ id: response.merchant.id, name: response.merchant.name, payoutAddress: response.merchant.payoutAddress });
65479
65470
  }
@@ -65764,6 +65755,7 @@ Owner commands:
65764
65755
  wallet status --dir DIR
65765
65756
  wallet grant --dir DIR --name "Agent" [--max-usdc 1] [--out credential.json]
65766
65757
  Optional advanced policy: --file policy.json instead of --name.
65758
+ --gateway URL sets the private connection destination (default http://127.0.0.1:4031).
65767
65759
  wallet limit --dir DIR --file limit-update.json
65768
65760
  wallet allocation --dir DIR --id DELEGATION_UUID --file allocation-update.json
65769
65761
  wallet revoke --dir DIR --id DELEGATION_UUID
@@ -65802,7 +65794,7 @@ Keep directories and credentials private. Funding is an owner transfer of native
65802
65794
  Base USDC to the generated address; creating a wallet or grant moves no money.
65803
65795
  The local wallet enforces policy in software. It is not an on-chain session wallet.
65804
65796
  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.
65797
+ Optional model admission: add --model-config FILE to wallet serve/web or seller once/run.
65806
65798
  It sends task input to OpenRouter and incurs inference costs. Omit it for deterministic execution.
65807
65799
  `;
65808
65800
  var { positionals, values: v } = parseArgs({ allowPositionals: true, strict: true, options: {
@@ -66001,16 +65993,18 @@ async function main() {
66001
65993
  const file2 = v.out;
66002
65994
  if (file2) requireThat(!existsSync2(file2), "credential_file_exists");
66003
65995
  requireThat(!v.file || !v.name && !v["max-usdc"], "choose_policy_file_or_name");
65996
+ const gateway = origin(v.gateway ?? "http://127.0.0.1:4031");
66004
65997
  const grant = wallet2.grant(v.file ? readJson(v.file) : { name: needed("name"), ...v["max-usdc"] ? { maxTotalUSDC: v["max-usdc"] } : {} }, randomUUID5());
65998
+ const connection = { ...grant, gateway };
66005
65999
  if (file2) {
66006
66000
  try {
66007
- out(file2, grant);
66001
+ out(file2, connection);
66008
66002
  } catch (e) {
66009
66003
  wallet2.revoke(grant.id);
66010
66004
  throw e;
66011
66005
  }
66012
66006
  print({ delegationId: grant.id, credentialFile: resolve2(file2), wallet: wallet2.address, policy: grant.policy });
66013
- } else print({ ...grant, gateway: "http://127.0.0.1:4031" });
66007
+ } else print(connection);
66014
66008
  return;
66015
66009
  }
66016
66010
  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.2",
4
4
  "description": "Owner-controlled Base USDC delegation and recoverable buyer/seller workflows",
5
5
  "license": "MIT",
6
6
  "type": "module",