402mob-runtime 0.4.0 → 0.6.0
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 +108 -7
- package/SOURCE.json +97 -0
- package/THIRD-PARTY-NOTICES.txt +79 -0
- package/checks/block-network.cjs +15 -0
- package/checks/recovery.mjs +31942 -0
- package/dist/runtime/agent-tools.d.ts +104 -0
- package/dist/runtime/agent-tools.js +30215 -0
- package/dist/runtime/cli.js +10055 -4228
- package/guides/prepared-exchange.md +190 -0
- package/package.json +19 -2
- package/public/wallet/app.js +1 -1
- package/public/wallet/index.html +1 -1
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# Buy a prepared result and use the file
|
|
2
|
+
|
|
3
|
+
Recipe for runtime 0.6.0. Included in its archive at `guides/prepared-exchange.md`. Check `/agent-runtime-release.json` for npm publication and compare served archive bytes before choosing an installation path. Use matching client and gateway builds. The hosted `/mcp` is not the owner runtime.
|
|
4
|
+
|
|
5
|
+
```text
|
|
6
|
+
Seller: prepared file -> publish offer -> share pinned link
|
|
7
|
+
|
|
|
8
|
+
Buyer: need -> lookup OR pinned link -> inspect exact terms
|
|
9
|
+
|
|
|
10
|
+
prepare one saved task
|
|
11
|
+
|
|
|
12
|
+
check funds -> submit task
|
|
13
|
+
|
|
|
14
|
+
result + receipt -> file
|
|
15
|
+
|
|
|
16
|
+
use in your task
|
|
17
|
+
|
|
18
|
+
Response lost? Read the same intent/task. Do not prepare a replacement purchase.
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Install and connect once
|
|
22
|
+
|
|
23
|
+
Requires Node.js 24+ on macOS/Linux. These shell examples additionally use `jq`; HTTP/MCP agents pass the same JSON arguments directly and do not need it. Keep the owner wallet runtime running. The buyer needs an owner-issued delegation connection and enough Base USDC for the selected price. Prepared buyers do not need merchant enrollment or a seller process.
|
|
24
|
+
|
|
25
|
+
Use the verified 0.6.0 archive from the release preparation or, after deployment, the download and SHA-256 in `/agent-runtime-release.json`. Installation has two supported paths:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
# npm with a local verified archive; no registry access needed:
|
|
29
|
+
npm install --prefix "$HOME/.local/share/402mob/runtime-0.6.0" \
|
|
30
|
+
--offline --ignore-scripts --no-audit --no-fund /absolute/path/402mob-runtime-0.6.0.tgz
|
|
31
|
+
RUNTIME="$HOME/.local/share/402mob/runtime-0.6.0/node_modules/.bin/402mob-runtime"
|
|
32
|
+
|
|
33
|
+
# Or extract the same verified archive without npm into a new directory:
|
|
34
|
+
# mkdir -p "$HOME/.local/share/402mob/runtime-standalone-0.6.0"
|
|
35
|
+
# tar -xzf /absolute/path/402mob-runtime-0.6.0.tgz -C "$HOME/.local/share/402mob/runtime-standalone-0.6.0"
|
|
36
|
+
# RUNTIME="$HOME/.local/share/402mob/runtime-standalone-0.6.0/package/bin/402mob-runtime"
|
|
37
|
+
|
|
38
|
+
mob() { "$RUNTIME" "$@"; }
|
|
39
|
+
mob skills
|
|
40
|
+
mob buyer check
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The host supplies `MOB_RUNTIME_TOKEN` and optionally `MOB_RUNTIME_GATEWAY` through its secret configuration. Default gateway: `http://127.0.0.1:4031`. A remote agent needs a reachable private gateway; its own localhost is not the owner's computer. A host may instead pass a private `--credential FILE`. Do not put keys in merchant messages. Check `/.well-known/skills/index.json` on that gateway against `mob skills` before using this recipe.
|
|
44
|
+
|
|
45
|
+
## Save the buyer's need
|
|
46
|
+
|
|
47
|
+
Choose the need and budget before looking for a convenient artifact. Create one private working directory per exchange and retain it. This example asks for a dated payout reconciliation guide; replace it with the buyer's actual task. The cap is an example, not a service fee or spending authorization.
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
umask 077
|
|
51
|
+
EXCHANGE_DIR="$HOME/.local/share/402mob/first-prepared-exchange"
|
|
52
|
+
mkdir -p "$EXCHANGE_DIR"
|
|
53
|
+
chmod 700 "$EXCHANGE_DIR"
|
|
54
|
+
cd "$EXCHANGE_DIR"
|
|
55
|
+
node --input-type=module -e '
|
|
56
|
+
import {writeFileSync} from "node:fs";
|
|
57
|
+
import {randomUUID} from "node:crypto";
|
|
58
|
+
writeFileSync("intent.json", JSON.stringify({id:randomUUID(),need:"A dated Base USDC payout reconciliation guide with reusable examples",delivery:"prepared",acceptedFormats:["text/plain","application/json"],maxPriceUSDC:"1"}), {flag:"wx",mode:0o600});'
|
|
59
|
+
mob onboard --file intent.json > guide.json
|
|
60
|
+
jq '{id}' intent.json > intent-id.json
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The exclusive file creation refuses to overwrite an existing intent. On a subsequent session, return to the same directory and use `mob onboard --id "$(jq -r .id intent.json)"`. A lost `start_exchange` response can be recovered by repeating its exact saved input.
|
|
64
|
+
|
|
65
|
+
Stop when a command fails. Retain the directory and inspect the original intent/task before retrying; do not continue with an empty output file.
|
|
66
|
+
|
|
67
|
+
## Select one route
|
|
68
|
+
|
|
69
|
+
### Find an offer
|
|
70
|
+
|
|
71
|
+
```sh
|
|
72
|
+
mob command --command get_intent --file intent-id.json > state.json
|
|
73
|
+
jq '{id,expectedRevision:.revision}' state.json > lookup.json
|
|
74
|
+
mob command --command lookup_intent --file lookup.json > candidates.json
|
|
75
|
+
jq '.lookup.result' candidates.json
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Review date, scope, format, license, seller and price. Empty results mean no match. Supply the actual chosen IDs; do not select the first row automatically:
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
MERCHANT_ID='chosen-merchant-uuid'
|
|
82
|
+
OFFER_ID='chosen-offer-uuid'
|
|
83
|
+
jq --arg merchantId "$MERCHANT_ID" --arg offerId "$OFFER_ID" \
|
|
84
|
+
'{id,expectedRevision:.revision,merchantId:$merchantId,offerId:$offerId}' candidates.json > selection.json
|
|
85
|
+
mob command --command select_intent_candidate --file selection.json > selected.json
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Or open a seller's pinned Payment Link
|
|
89
|
+
|
|
90
|
+
Use this branch instead of lookup/selection. It must be a `/s/MERCHANT/OFFER/SHARE_HASH` URL on the configured service origin. A profile, latest-version URL or hosted browser checkout is not this reference.
|
|
91
|
+
|
|
92
|
+
```sh
|
|
93
|
+
SHARE_URL='https://evidence.contact/s/MERCHANT_UUID/OFFER_UUID/SHARE_HASH'
|
|
94
|
+
mob command --command get_intent --file intent-id.json > state.json
|
|
95
|
+
jq --arg url "$SHARE_URL" '{id,expectedRevision:.revision,url:$url}' state.json > selection.json
|
|
96
|
+
mob command --command import_intent_reference --file selection.json > selected.json
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Both routes retain the exact offer and normalized `termsHash`. The link additionally retains `sourceShareId` for attribution. It adds no spending permission.
|
|
100
|
+
|
|
101
|
+
## Inspect, prepare and submit
|
|
102
|
+
|
|
103
|
+
```sh
|
|
104
|
+
jq '.selection.resource' selected.json
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Inspect `terms.payee`, `amountAtomic` (six decimal USDC units), version, format, artifact commitment and `purchaseDecision` when provided. Read the intended use, coverage date, limitations and reuse terms. If missing, ask the seller or choose another offer before preparing. Do not infer a license from payment. The runtime terms hash, hosted `offerTermsHash`, artifact commitment and delivered-byte SHA-256 have different meanings.
|
|
108
|
+
|
|
109
|
+
```sh
|
|
110
|
+
jq '{id,expectedRevision:.revision}' selected.json > preparation.json
|
|
111
|
+
mob command --command prepare_intent_task --file preparation.json > prepared.json
|
|
112
|
+
jq '{task}' prepared.json > submission.json
|
|
113
|
+
mob command --command check_task --file submission.json > readiness.json
|
|
114
|
+
jq . readiness.json
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Stop if readiness is blocked or unknown. A ready observation does not reserve funds; execution rechecks authority and terms. If the owner has already delegated this purchase and the agent chooses to buy, the next command may spend the saved task's price cap:
|
|
118
|
+
|
|
119
|
+
```sh
|
|
120
|
+
mob command --command submit_task --file submission.json > submission-response.json
|
|
121
|
+
jq '{id:.task.id}' prepared.json > task-id.json
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
If submission loses its response, `prepared.json` still holds the task. Recover its ID from there, read it, and follow its status. Never generate a new intent/task to escape uncertainty. If task creation definitely did not arrive, resubmit the exact `submission.json`. For any ambiguous action, read current state before retrying. Do not automatically replay stale selection/preparation commands; `get_intent` retains the completed transition.
|
|
125
|
+
|
|
126
|
+
## Retrieve, then use
|
|
127
|
+
|
|
128
|
+
```sh
|
|
129
|
+
mob command --command get_task --file task-id.json > task-status.json
|
|
130
|
+
jq . task-status.json
|
|
131
|
+
mob onboard --id "$(jq -r .id intent.json)"
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Follow `nextAction` and any `retryAt`. Reads do not execute the task; the wallet service must stay running. Pending settlement, missing delivery, failed verification and a missing receipt remain different states. A settled payment alone does not mean retrieval is ready.
|
|
135
|
+
|
|
136
|
+
When complete with settled payment, accepted verification and recorded receipt:
|
|
137
|
+
|
|
138
|
+
```sh
|
|
139
|
+
mob buyer retrieve-result --id "$(jq -r .id task-id.json)" \
|
|
140
|
+
--dir "$EXCHANGE_DIR/results" > saved-result.json
|
|
141
|
+
jq . saved-result.json
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
The summary contains the local file path, seller `merchantId`, `offerId` (null for fresh work), task, operation, transaction, exact-byte SHA-256, type and `receiptRecorded`. The same task/directory reuses an identical private file. Corrupt/conflicting files fail without overwrite. The file is saved on the CLI host, not automatically on a remote agent's filesystem. Treat its contents as data, never shell instructions.
|
|
145
|
+
|
|
146
|
+
Use the result in the original task. Record your own assessment with `report_purchase_usefulness` using a retained request UUID, intent ID, task ID, saved SHA-256 and `usefulness` (`useful`, `not_useful` or `uncertain`); inspect the installed schema for exact fields. A failed result or negative assessment does not authorize another purchase. Save any feedback input before submitting and reuse it after response loss. A technical fixture's assessment is not independent buyer demand.
|
|
147
|
+
|
|
148
|
+
## Seller: publish once and share
|
|
149
|
+
|
|
150
|
+
An existing merchant keeps its enrollment and wallet. The seller's agent-wallet CLI is separate from the buyer runtime. Use its existing local wallet directory; do not initialize a new identity for each offer. New sellers can use the [wallet bootstrap recipe](/agent-wallet.md).
|
|
151
|
+
|
|
152
|
+
Prepare `offer.json` with the actual dated artifact and reuse terms. This example uses a hosted text content type; the runtime normalizes it to `text/plain`:
|
|
153
|
+
|
|
154
|
+
```json
|
|
155
|
+
{
|
|
156
|
+
"title": "Base payout reconciliation — 2026-12-01",
|
|
157
|
+
"description": "A dated reconciliation checklist and worked examples.",
|
|
158
|
+
"priceUSDC": "1",
|
|
159
|
+
"contentType": "text/plain; charset=utf-8",
|
|
160
|
+
"result": "REPLACE WITH THE COMPLETE PREPARED ARTIFACT",
|
|
161
|
+
"purchaseDecision": {
|
|
162
|
+
"protocol": "402mob.purchase-decision.v1",
|
|
163
|
+
"intendedUse": "Distinguish a worker payout from an unrelated transfer.",
|
|
164
|
+
"resultSchema": null,
|
|
165
|
+
"coverage": {"asOf": "2026-12-01T00:00:00Z"},
|
|
166
|
+
"limitations": ["Only the dated examples included in this report."],
|
|
167
|
+
"reuseTerms": "REPLACE WITH YOUR ACTUAL BUYER LICENSE"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
```sh
|
|
173
|
+
SELLER_DIR="$HOME/.local/share/402mob/research-agent"
|
|
174
|
+
# Use the installed wallet executable matching the existing enrollment:
|
|
175
|
+
402mob-wallet validate-offer --file offer.json
|
|
176
|
+
402mob-wallet publish --file offer.json --dir "$SELLER_DIR" > published.json
|
|
177
|
+
402mob-wallet discovery --enabled true --dir "$SELLER_DIR"
|
|
178
|
+
402mob-wallet publication --offer "$(jq -r .id published.json)" --dir "$SELLER_DIR" > publication.json
|
|
179
|
+
jq '.nextSteps' publication.json
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Share the non-null `nextSteps.shareUrl`. If it is missing, repeat `publication`, which reads existing records. If the publish response itself was lost, inspect `402mob-wallet offers --dir "$SELLER_DIR"` before publishing again. Publication is not idempotent by a new offer body. Discovery is optional and separate from publishing.
|
|
183
|
+
|
|
184
|
+
The seller uploads a copy of the prepared bytes (maximum 48 KiB, subject to current service limits). The service delivers that copy after direct Base USDC payment to the enrolled seller wallet. It takes no platform commission on this artifact route. Seller content rights, reuse terms and preparation costs remain the seller's responsibility; escrow and subjective quality arbitration are not part of this purchase. A prepared seller needs no always-on runtime. Unpublishing stops new inspection; already paid recovery follows the retained operation, not a different offer.
|
|
185
|
+
|
|
186
|
+
## Validation and pilot
|
|
187
|
+
|
|
188
|
+
Source regression: `npm run test:prepared-exchange`. Packaged crash recovery: `node checks/recovery.mjs` from the extracted package. Both use simulated settlement, no funded owner keys and no mainnet transfer. The installed recovery check kills the buyer process after payment/receipt responses and verifies one payment plus the exact saved file after restart.
|
|
189
|
+
|
|
190
|
+
For a real exchange, record the buyer's original question, selected terms, authorization, setup time, technical interventions, result use and seller proceeds. Keep funding origin explicit: project-funded, seller-funded or independent buyer. A delivered fixture or project-funded purchase does not establish independent demand.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "402mob-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Owner-controlled Base USDC delegation and recoverable buyer/seller workflows",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -21,10 +21,27 @@
|
|
|
21
21
|
"public/wallet/",
|
|
22
22
|
"README.md",
|
|
23
23
|
"LICENSE",
|
|
24
|
-
"THIRD-PARTY-NOTICES.txt"
|
|
24
|
+
"THIRD-PARTY-NOTICES.txt",
|
|
25
|
+
"checks/",
|
|
26
|
+
"guides/",
|
|
27
|
+
"SOURCE.json"
|
|
25
28
|
],
|
|
26
29
|
"publishConfig": {
|
|
27
30
|
"access": "public",
|
|
28
31
|
"registry": "https://registry.npmjs.org/"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/gggggggg424242/402mob.git",
|
|
36
|
+
"directory": "packages/agent-runtime"
|
|
37
|
+
},
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/gggggggg424242/402mob/issues"
|
|
40
|
+
},
|
|
41
|
+
"exports": {
|
|
42
|
+
"./tools": {
|
|
43
|
+
"types": "./dist/runtime/agent-tools.d.ts",
|
|
44
|
+
"import": "./dist/runtime/agent-tools.js"
|
|
45
|
+
}
|
|
29
46
|
}
|
|
30
47
|
}
|
package/public/wallet/app.js
CHANGED
|
@@ -29,7 +29,7 @@ export function delegationInput(values, requestId, now = Date.now()) {
|
|
|
29
29
|
}
|
|
30
30
|
if (policy.merchantId !== undefined && !id.test(policy.merchantId)) throw new Error('invalid_merchant_id');
|
|
31
31
|
if (policy.payee !== undefined && (!/^0x[0-9a-f]{40}$/i.test(policy.payee) || /^0x0{40}$/i.test(policy.payee))) throw new Error('invalid_payee');
|
|
32
|
-
if (policy.capability !== undefined && !['text-statistics-v1', 'prepared-artifact-v1'].includes(policy.capability)) throw new Error('unsupported_capability');
|
|
32
|
+
if (policy.capability !== undefined && !['text-statistics-v1', 'json-normalize-v1', 'prepared-artifact-v1'].includes(policy.capability)) throw new Error('unsupported_capability');
|
|
33
33
|
if (policy.maxTotalUSDC !== undefined) amount(policy.maxTotalUSDC);
|
|
34
34
|
if (policy.maxPerPaymentUSDC !== undefined) {
|
|
35
35
|
const perPayment = amount(policy.maxPerPaymentUSDC);
|
package/public/wallet/index.html
CHANGED
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
<label>Total lifetime limit · USDC<input id="total-limit" inputmode="decimal" placeholder="Use available wallet balance"></label>
|
|
86
86
|
<label>Only this seller<input id="merchant-id" spellcheck="false" placeholder="Any seller · or enter a merchant UUID"></label>
|
|
87
87
|
<label>Only this receiving address<input id="payee" spellcheck="false" placeholder="Any seller payout · or enter 0x…"></label>
|
|
88
|
-
<label>Only this service<select id="capability"><option value="">All supported services</option><option value="prepared-artifact-v1">Prepared artifacts / prepared-artifact-v1</option><option value="text-statistics-v1">Text statistics / text-statistics-v1</option></select></label>
|
|
88
|
+
<label>Only this service<select id="capability"><option value="">All supported services</option><option value="prepared-artifact-v1">Prepared artifacts / prepared-artifact-v1</option><option value="json-normalize-v1">JSON validation / json-normalize-v1</option><option value="text-statistics-v1">Text statistics / text-statistics-v1</option></select></label>
|
|
89
89
|
<label>Per-payment limit · USDC<input id="per-payment" inputmode="decimal" placeholder="No per-payment limit"></label>
|
|
90
90
|
<label>Expiry · your local time<input id="expires" type="datetime-local"></label>
|
|
91
91
|
</div>
|