@c4roa0/agentpay-user 0.0.0-stage → 0.3.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.
Files changed (173) hide show
  1. package/AGENTS.md +137 -0
  2. package/CONTRIBUTING.md +16 -0
  3. package/LICENSE +373 -0
  4. package/NOTICE.md +20 -0
  5. package/README.md +84 -2
  6. package/SECURITY.md +16 -0
  7. package/doc/README.md +52 -0
  8. package/doc/TODO.md +97 -0
  9. package/doc/architecture.md +96 -0
  10. package/doc/design.md +60 -0
  11. package/doc/develope.md +68 -0
  12. package/doc/plans/user-wallet-distribution.md +91 -0
  13. package/doc/reference/harness-skill-runtime.md +120 -0
  14. package/doc/reference/local-cache-foundation.md +176 -0
  15. package/doc/reference/local-safe-owner-ui.md +25 -0
  16. package/doc/reference/local-update.md +18 -0
  17. package/doc/reference/multi-service-runtime.md +119 -0
  18. package/doc/reference/npm-integration-verification.md +67 -0
  19. package/doc/reference/onboarding-writing.md +48 -0
  20. package/doc/reference/original-order-recovery.md +97 -0
  21. package/doc/reference/private-anvil-onboarding-config.example.json +18 -0
  22. package/doc/reference/public-deployment-settings.md +56 -0
  23. package/doc/reference/random-skill-contract.md +18 -0
  24. package/doc/reference/result-file-cache.md +166 -0
  25. package/doc/reference/runtime-address-recovery.md +42 -0
  26. package/doc/reference/runtime-result-cache.md +157 -0
  27. package/doc/reference/runtime-startup-recovery.md +141 -0
  28. package/doc/reference/skill-input-output-cache.md +93 -0
  29. package/doc/reference/wallet-identity-policy-history.md +23 -0
  30. package/doc/runbooks/commands.md +89 -0
  31. package/doc/runbooks/deployment-authorization-update.md +42 -0
  32. package/doc/runbooks/emergency-payment-stop.md +80 -0
  33. package/doc/runbooks/local-autostart.md +212 -0
  34. package/doc/runbooks/local-cache.md +115 -0
  35. package/doc/runbooks/local-update.md +84 -0
  36. package/doc/runbooks/market-connection.md +73 -0
  37. package/doc/runbooks/npm-publication.md +56 -0
  38. package/doc/runbooks/official-test-package.md +62 -0
  39. package/doc/runbooks/order-cancellation.md +56 -0
  40. package/doc/runbooks/order-support.md +41 -0
  41. package/doc/runbooks/policy-renewal.md +80 -0
  42. package/doc/runbooks/private-anvil-terminal-setup.md +58 -0
  43. package/doc/runbooks/runtime-skill-client.md +155 -0
  44. package/doc/runbooks/safe-owner-web.md +104 -0
  45. package/doc/runbooks/safe-policy-migration.md +36 -0
  46. package/doc/runbooks/safe-policy-setup.md +52 -0
  47. package/doc/runbooks/terminal-authorization-preview.md +38 -0
  48. package/doc/runbooks/unlock-wallet.md +68 -0
  49. package/doc/runbooks/user-onboarding.md +87 -0
  50. package/doc/runbooks/wallet-identity.md +59 -0
  51. package/doc/security/public-source-review-2026-11-06.md +71 -0
  52. package/doc/usage.md +54 -0
  53. package/package.json +49 -4
  54. package/progress.md +178 -0
  55. package/run +29 -0
  56. package/scripts/agentpay-cli.mjs +11 -0
  57. package/scripts/authorize-existing-safe.mjs +211 -0
  58. package/scripts/autostart.mjs +186 -0
  59. package/scripts/cancel-order.mjs +76 -0
  60. package/scripts/check-installation.mjs +26 -0
  61. package/scripts/check-official-test-package.mjs +35 -0
  62. package/scripts/check-purchase-readiness.mjs +275 -0
  63. package/scripts/configure-runtime-client.mjs +16 -0
  64. package/scripts/guide-policy.mjs +64 -0
  65. package/scripts/initialize-caller-credential.mjs +11 -0
  66. package/scripts/install-skill-bundle.mjs +176 -0
  67. package/scripts/install-user.mjs +24 -0
  68. package/scripts/local-service.mjs +60 -0
  69. package/scripts/lock.mjs +11 -0
  70. package/scripts/login-notify.mjs +39 -0
  71. package/scripts/migrate-safe-policy.mjs +165 -0
  72. package/scripts/official-paid-test.mjs +9 -0
  73. package/scripts/poll-unconfirmed-notice.mjs +75 -0
  74. package/scripts/prepare-onboarding.mjs +33 -0
  75. package/scripts/preview-policy.mjs +65 -0
  76. package/scripts/random-model-ack-smoke.mjs +235 -0
  77. package/scripts/random-reject-smoke.mjs +147 -0
  78. package/scripts/renew.mjs +9 -0
  79. package/scripts/repair.mjs +10 -0
  80. package/scripts/revoke.mjs +9 -0
  81. package/scripts/select-skill-bundle.mjs +39 -0
  82. package/scripts/setup-local.mjs +199 -0
  83. package/scripts/status.mjs +13 -0
  84. package/scripts/test-package.mjs +35 -0
  85. package/scripts/unlock.mjs +13 -0
  86. package/scripts/update.mjs +7 -0
  87. package/scripts/user-setup.mjs +219 -0
  88. package/scripts/verify-npm-release.mjs +32 -0
  89. package/src/active-skill.mjs +160 -0
  90. package/src/anvil-onboarding-state.mjs +96 -0
  91. package/src/anvil-onboarding.mjs +1036 -0
  92. package/src/authorization-question-checkpoint.mjs +114 -0
  93. package/src/autostart-files.mjs +50 -0
  94. package/src/cache-management-cli.mjs +302 -0
  95. package/src/cache-management.mjs +47 -0
  96. package/src/caller-auth.mjs +58 -0
  97. package/src/client-request-lock.mjs +44 -0
  98. package/src/connect-market.mjs +408 -0
  99. package/src/demo-unlock-secret.mjs +64 -0
  100. package/src/deployment-status.mjs +198 -0
  101. package/src/file-cache-cli.mjs +83 -0
  102. package/src/file-cache-owner.mjs +74 -0
  103. package/src/file-cache-settings.mjs +50 -0
  104. package/src/file-cache.mjs +790 -0
  105. package/src/file-download.mjs +281 -0
  106. package/src/finalization-disclosure.mjs +16 -0
  107. package/src/guided-setup.mjs +194 -0
  108. package/src/index.mjs +1231 -0
  109. package/src/install-and-setup.mjs +38 -0
  110. package/src/install-preflight.mjs +201 -0
  111. package/src/install-user.mjs +279 -0
  112. package/src/installation-paths.mjs +31 -0
  113. package/src/invocation-result.mjs +148 -0
  114. package/src/invocation-store.mjs +385 -0
  115. package/src/local-data-directory.mjs +117 -0
  116. package/src/local-info.mjs +181 -0
  117. package/src/local-services.mjs +156 -0
  118. package/src/local-time.mjs +36 -0
  119. package/src/local-update.mjs +306 -0
  120. package/src/local-wallet-ipc.mjs +93 -0
  121. package/src/login-reminder.mjs +28 -0
  122. package/src/market-download-url.mjs +21 -0
  123. package/src/node-version.mjs +12 -0
  124. package/src/npm-update.mjs +126 -0
  125. package/src/official-paid-test.mjs +407 -0
  126. package/src/official-test-package.mjs +41 -0
  127. package/src/official-test-update.mjs +162 -0
  128. package/src/order-cancellation.mjs +241 -0
  129. package/src/order-closure.mjs +42 -0
  130. package/src/order-list-panel.mjs +110 -0
  131. package/src/order-review.mjs +424 -0
  132. package/src/order-status-panel.mjs +65 -0
  133. package/src/order-support.mjs +365 -0
  134. package/src/owner-approval-server.mjs +332 -0
  135. package/src/owner-signer.mjs +67 -0
  136. package/src/policy-info.mjs +38 -0
  137. package/src/policy-migration.mjs +84 -0
  138. package/src/policy-operations.mjs +67 -0
  139. package/src/policy-preview-server.mjs +236 -0
  140. package/src/policy-terminal-guide.mjs +377 -0
  141. package/src/prepare-local-services.mjs +143 -0
  142. package/src/prepare-onboarding.mjs +210 -0
  143. package/src/private-journal-files.mjs +29 -0
  144. package/src/readiness-profile.mjs +30 -0
  145. package/src/renew-policy.mjs +605 -0
  146. package/src/repair-market-wallet.mjs +137 -0
  147. package/src/restore-wallet.mjs +255 -0
  148. package/src/result-cache-view.mjs +276 -0
  149. package/src/runtime-client.mjs +1145 -0
  150. package/src/runtime-connection-settings.mjs +101 -0
  151. package/src/runtime-recovery.mjs +667 -0
  152. package/src/runtime-status.mjs +32 -0
  153. package/src/safe-owner-anvil.mjs +115 -0
  154. package/src/safe-policy-plan.mjs +195 -0
  155. package/src/service-reference.mjs +233 -0
  156. package/src/service-url.mjs +52 -0
  157. package/src/settlement-response.mjs +69 -0
  158. package/src/setup-autostart.mjs +197 -0
  159. package/src/setup-demo.mjs +152 -0
  160. package/src/skill-bundle.mjs +142 -0
  161. package/src/skill-client.mjs +198 -0
  162. package/src/skill-install-prompt.mjs +31 -0
  163. package/src/skill-package.mjs +50 -0
  164. package/src/skill-zip.mjs +220 -0
  165. package/src/status-panel.mjs +589 -0
  166. package/src/transport.mjs +48 -0
  167. package/src/uninstall-local.mjs +299 -0
  168. package/src/user-cli.mjs +354 -0
  169. package/src/user-setup-guide.mjs +193 -0
  170. package/src/wallet-control.mjs +182 -0
  171. package/src/wallet-ipc-error.mjs +16 -0
  172. package/src/wallet-package.mjs +22 -0
  173. package/update-pair.json +6 -0
@@ -0,0 +1,176 @@
1
+ # Unified local cache foundation
2
+
3
+ Status, 2026-11-04: foundation and shared-client integration implemented. See
4
+ latest payment/file evidence (private historical evidence; not distributed),
5
+ neutrality resolution (private historical evidence; not distributed) and
6
+ [current usage](../runbooks/local-cache.md). Historical 61-test foundation evidence
7
+ is separate from subsequent runs. Paid binary-service participant acceptance is not
8
+ claimed. Text view does not change durable request/Order identities or cleanup rules.
9
+ Related: [Skill integration](skill-input-output-cache.md),
10
+ [current output cache](../reference/result-file-cache.md).
11
+
12
+ ## Existing code and reuse decision
13
+
14
+ `file-cache.mjs` already supplies private streaming storage, atomic index updates,
15
+ digest checks and Order-scoped output records. `file-download.mjs` owns HTTP/HTTPS
16
+ streaming, DNS/redirect checks and transfer bounds. `file-cache-owner.mjs` owns a
17
+ portable OS lock, loaded only for file operations. `file-cache-settings.mjs` owns
18
+ limits. Extend/extract these into one store; do not duplicate them for input files.
19
+
20
+ Current limitations found by inspection:
21
+
22
+ - Every record requires an Order ID and URL; an input may precede an Order and come
23
+ from a local file. Current file count is per Order, not per request.
24
+ - Only Order-scoped list/download/remove exist; no global summary, export or cleanup
25
+ preview. Configuration currently requires manually editing private JSON.
26
+ - A crash after marking a record removed but before unlink can leave physical bytes.
27
+ A failed index commit after publishing a binary can leave unaccounted-to-metadata
28
+ bytes. Physical usage is counted today, but repair/cleanup needs explicit states.
29
+ - Directory scanning and full-index parsing occur per operation; new management
30
+ listings must stay bounded and must not hash every binary just to display usage.
31
+ - Current total quota covers file-cache bytes, not existing JSON request/result
32
+ history. A unified screen must not misleadingly describe this as total User data.
33
+
34
+ ## File compatibility and identity
35
+
36
+ Store arbitrary bytes: text in any encoding, images, media, PDFs, archives, model
37
+ files and unknown formats. No format whitelist, automatic extraction, rendering,
38
+ transcoding or execution. MIME, Unicode display name and extension are descriptive;
39
+ control characters must be escaped in terminal output. Physical names are generated
40
+ identifiers, never filenames, source URLs or caller paths. Zero-byte files are valid.
41
+
42
+ Local import accepts an explicitly selected regular file, not a device, FIFO or
43
+ recursive directory. Stream from a checked handle and detect ordinary source changes
44
+ while copying. This cannot guarantee an atomic view of a concurrently modified source:
45
+ callers must provide stable files; the saved bytes and digest define the snapshot.
46
+ Do not hard-link source files: future writes must not mutate the snapshot. Directory
47
+ packaging and Provider-specific uploads remain Skill responsibilities.
48
+
49
+ Use a record identity derived from purpose (input/output), original request ID or
50
+ Order ID, and file key. Digest describes bytes, not ownership or payment authority.
51
+ No cross-request deduplication/refcounts in the first implementation: it complicates
52
+ cleanup and reference integrity for little demonstrated benefit. Equal bytes may
53
+ have independent copies. Runtime endpoint/port never enters record identity.
54
+
55
+ ## Storage and upgrade
56
+
57
+ Keep the existing managed root, `runtime/invocations.json.files/`, so existing outputs
58
+ do not require copying large files. Preserve existing output storage IDs and bytes.
59
+ Add input record namespace and a versioned index with explicit scope/purpose; retain
60
+ one writer lock and one quota account for both. No fake Order IDs for input entries.
61
+ No new database or background cache service is required.
62
+
63
+ Existing client JSON checkpoints and verified structured results stay where they
64
+ are; the cache manager does not duplicate or reinterpret them. Display their relation
65
+ where available, but do not delete financial/checkpoint history through file cleanup.
66
+
67
+ Before activation, a bounded one-time index upgrade validates old records and writes
68
+ new metadata atomically under the store lock. It must not require a running Wallet,
69
+ chain calls, byte re-download or new request. Unsupported/corrupt metadata blocks
70
+ file mutations with a concrete diagnostic, not an empty replacement index. Do not
71
+ keep dual writing or two active schema implementations. Failure leaves recoverable
72
+ old metadata; deployment must coordinate stopping old writers. Inspect actual saved
73
+ state before any operator migration; no data migration is executed by this document.
74
+
75
+ ## Record and transfer state
76
+
77
+ A record includes versioned scope, file key, display name, optional MIME/source,
78
+ expected and observed digest, byte count, created/updated Unix-millisecond timestamps,
79
+ state and safe failure code. Local paths and signed source URLs are private metadata;
80
+ routine listings/logs omit source credentials. Output provenance remains distinct
81
+ from local digest verification; a digest alone does not prove paid delivery.
82
+
83
+ Persist `writing` with a unique staging identity before creating partial bytes.
84
+ Write to a private temporary file, stream/hash, fsync, publish complete bytes, then
85
+ commit `available` metadata. Readers never consume partial bytes. Publishing errors
86
+ leave a recoverable record; retries reconcile published bytes before replacement.
87
+ Store mutation serializes only metadata/reservations, not entire network transfers.
88
+ Concurrent operations on the same record return busy/reuse, not duplicate writers.
89
+
90
+ Use `deleting` before removing bytes, then `removed` after durable removal. Restart
91
+ finishes interrupted deletion idempotently. A quota slot is not free until bytes are
92
+ actually removed. Failed or missing/corrupt copies retain their identity/digest.
93
+ An interrupted write is not available; remove only its owned staging files and retry
94
+ explicitly. No silent network transfer or service execution during startup repair.
95
+
96
+ Unrecognized files or corrupt metadata must not trigger recursive deletion. Account
97
+ for their physical occupancy and report them for inspection. Recovery scans happen
98
+ once under the writer lock; normal lists use bounded metadata pagination. Verify
99
+ hashes on reuse/export, not every display refresh. Portable OS locking is reused;
100
+ network-filesystem and untested OS support must not be claimed.
101
+
102
+ ## Limits and resource accounting
103
+
104
+ Start from existing configurable defaults: 100 MiB per file, 512 MiB total managed
105
+ file storage, 20 active files per input request or output Order, 2 transfers, 10,000
106
+ retained records, 8 MiB index bound and 15-minute transfer deadline. These are resource
107
+ limits, not format restrictions or Provider service deadlines. Increasing a limit
108
+ must be possible through the management command within documented supported bounds.
109
+
110
+ Charge input and output binaries, staging bytes and other physical files in the
111
+ managed directory; expose metadata overhead and transfer reservations separately.
112
+ Never double-count written staging bytes and their reservation. Known sizes reserve
113
+ bounded declared space; unknown sizes conservatively reserve the per-file ceiling.
114
+ Enforce actual streamed bytes even when a source lies about length. Disk ENOSPC or
115
+ permission failure must leave recoverable state and not stop Order reconciliation.
116
+ Export copies consume destination disk space outside the managed quota.
117
+
118
+ Lowering a cap below current use retains data, reports over-limit and blocks new
119
+ allocation; it must not make old records unreadable or prohibit cleanup. Metadata
120
+ limit stops creating records, not listing/removal. Settings updates are atomic and
121
+ validated; avoid restarting/locking Wallet just to change file-cache limits.
122
+
123
+ ## Management and cleanup
124
+
125
+ Implemented unified entry:
126
+
127
+ | Command | Behavior |
128
+ | --- | --- |
129
+ | `./run cache` | Managed bytes, input/output split, reserved space, limits, problems |
130
+ | `./run cache list` | Paginated records; filters for purpose, state, request/Order |
131
+ | `./run cache details ID` | Scope, file, integrity, timestamps, state and next action |
132
+ | `./run cache export ID PATH` | Verify and copy; never execute or overwrite silently |
133
+ | `./run cache clean` | Preview candidates and bytes, then deliberate confirmation |
134
+ | `./run cache settings` | Show/update validated resource limits |
135
+
136
+ CLI talks to the existing authenticated Runtime when running. When stopped, a local
137
+ management session must acquire the same OS lock; never race a live Runtime or read
138
+ a half-written index. Do not introduce another daemon/port. A capability marker or
139
+ shared dispatcher must prevent a failed HTTP request from causing unsafe offline
140
+ fallback. A held lock means retry through the owning Runtime, not delete the lock.
141
+
142
+ Preserve existing `/files/*` and installed-client behavior as adapters over the same
143
+ store during integration. The current entry is `./run orders files ORDER_ID`; legacy flat aliases are not
144
+ retained. New generic storage primitives must not expose arbitrary
145
+ path reads through an unauthenticated web route. Local import/export authority stays
146
+ within the existing local caller/OS boundary; not a claim of filesystem isolation.
147
+
148
+ Automatic cleanup is restricted to known abandoned temporary files and incomplete
149
+ deletions. Do not add age-based result eviction in the first implementation. Explicit
150
+ clean excludes active transfers and recovery-needed input. Unknown/unreconciled
151
+ requests remain protected. New input defaults to protected. Recovery integration releases protection only
152
+ after verifying a durable delivered result for its original request; no guessed
153
+ terminal states. Failed release checks retain protection.
154
+
155
+ Confirmation reports files and bytes, warns that original links may no longer work,
156
+ and says payments/Order history are unchanged. Revalidate eligibility under lock at
157
+ delete time; an old preview cannot delete a newly protected or replaced entry. Delete
158
+ exact approved identities/generations, not a fresh broad query after confirmation.
159
+ Retain removed metadata; metadata-cap exhaustion gives a concrete limit-setting action.
160
+ Full-data uninstall retains its existing explicit confirmation and stop-services step.
161
+
162
+ ## Verification gates before invocation integration
163
+
164
+ - Arbitrary-byte equality for empty, Unicode text, image/PDF/archive-like and binary
165
+ fixtures. No execution, parsing or business-specific branches.
166
+ - Bounded memory streaming with large maintained fixtures; deceptive lengths,
167
+ limits, ENOSPC/write failures, raised/lowered limits and shared input/output quota.
168
+ - Actual competing processes, transfer interruption, publication/index failure,
169
+ deletion crash and restart repair; existing output upgrade without byte rewriting.
170
+ - Corrupt/missing records, unsafe paths, export collisions, unknown files and source
171
+ changes. No destructive blanket cleanup or replacement purchase.
172
+ - Clean-preview race, active/protected inputs, pagination, friendly CLI output and
173
+ settings changes. Cache operations make zero Wallet signing/Order-creation calls.
174
+
175
+ Only after this gate passes attach input readiness and output declarations to Skill
176
+ calls. Actual paid acceptance and other-platform checks remain separate evidence.
@@ -0,0 +1,25 @@
1
+ # Local Safe owner approval boundary
2
+
3
+ `owner-approval-server.mjs` serves a temporary loopback page for a fixed public
4
+ operation plan. `web/owner-approval.js` connects an injected browser owner wallet,
5
+ checks the selected network/Safe and obtains the required Safe approvals/execution.
6
+ It does not hold the local Session Key or obtain Wallet administrator capability.
7
+
8
+ The terminal and page share the same saved operation identity. The page verifies
9
+ execution receipts/effects; the terminal independently checks chain state before
10
+ binding or advancing. Changed nonce, conflicting draft, incomplete signature count
11
+ or unknown effect must preserve the original plan for reconciliation.
12
+
13
+ Source supports sequential single-owner and multisig approval mechanics. The recorded
14
+ private MetaMask journey used one owner. Multi-owner, interrupted-signature and
15
+ portable-page participant acceptance remain separate gates. Supported Safe versions
16
+ are checked explicitly, not inferred from chain ID.
17
+
18
+ Headless users can forward the printed loopback port. Portable export contains a
19
+ fixed public plan and local server, not RPC credentials, keys or local tokens.
20
+ Browser RPC reachability/CORS must still be verified. Do not expose the temporary
21
+ approval service publicly or allow arbitrary transaction input.
22
+
23
+ See [user instructions](../runbooks/safe-owner-web.md),
24
+ [signer/deployment settings](public-deployment-settings.md) and
25
+ [emergency stop](../runbooks/emergency-payment-stop.md).
@@ -0,0 +1,18 @@
1
+ # Local software repair
2
+
3
+ Current operation: [update and uninstall runbook](../runbooks/local-update.md).
4
+
5
+ User resolves its exact Wallet dependency through public package exports. Repair
6
+ checks package versions and fingerprints User src/scripts and Wallet lib/bin, then
7
+ refreshes managed service paths under the installer lock. Existing client connection
8
+ URLs and caller credentials must match before a client-module path can be refreshed.
9
+ A mismatch stops preparation rather than rewriting transaction identity.
10
+
11
+ Installation checkpoints live in XDG state storage; old source-install checkpoints
12
+ are read to preserve a custom data-directory selection. Deployment settings are
13
+ copied into private User data only when no canonical file exists. Neither path
14
+ changes keys, Policies, requests or recovery records.
15
+
16
+ A successful managed restart loads the reviewed installed package. Package metadata
17
+ alone does not identify a previously running daemon. Explicit version negotiation
18
+ remains planned; this implementation does not claim arbitrary-version compatibility.
@@ -0,0 +1,119 @@
1
+ # Local multi-service Runtime contract
2
+
3
+ Current local interface; the Protocol dependency is pinned in package.json. This is a local
4
+ User interface, never a public platform listener. One Runtime routes many services
5
+ without installing a global active package for each call. The caller credential
6
+ is local and distinct from Wallet's Agent IPC capability. Wallet retains the key.
7
+
8
+ ## Service reference and trust
9
+
10
+ A manifest's service object uses agentpay.service-reference.v1 with skillId,
11
+ profileHash, profile and adapter. Protocol's normalizeServiceReference verifies
12
+ profileHash over the exact canonical public profile: Provider/service identity,
13
+ controlled MCP/payment endpoints, seller, network and asset. References have no
14
+ price or actual usage fields. Wallet/Settlement/Module independently enforce
15
+ Registry qualification and bounded authorization; a matching profile hash alone
16
+ does not grant admission or certify quality.
17
+
18
+ The common agentpay.json.v1 transport carries Protocol invocation/result metadata
19
+ and application-owned JSON. Runtime has no business-specific adapter. Runtime does
20
+ not download or execute caller-provided adapter code. Arbitrary HTTP, binary or
21
+ streaming APIs need an explicit integration; JSON may contain application-level
22
+ artifact references, whose actual bytes need their own business validation.
23
+
24
+ ## Local endpoints
25
+
26
+ All POSTs require Authorization: Bearer <local caller credential>. Reject before
27
+ parsing or touching Wallet when authentication fails.
28
+
29
+ POST /services/check accepts exactly {service}. It verifies the reference and
30
+ returns Runtime identity, the normalized reference, orderCreated=false and
31
+ purchaseReadinessChecked=false. It performs no Order, Wallet signature, online
32
+ qualification, balance or Quote reservation. Never describe it as payment readiness.
33
+
34
+ POST /services/invoke uses an Idempotency-Key and exactly:
35
+
36
+ ```json
37
+ {
38
+ "version": "agentpay.runtime-call.v1",
39
+ "service": "<the complete service-reference object>",
40
+ "request": {"text": "your private business input"},
41
+ "requestedMaxUsageUnits": "1"
42
+ }
43
+ ```
44
+
45
+ The service field above is an object, abbreviated as a string only in this
46
+ illustration. Input is bounded JSON: 256 KiB, depth 32. Requested usage is a
47
+ positive integer string and an upper bound, not a price or actual meter. The
48
+ local AGENTPAY_USER_MAX_REQUEST_USAGE_UNITS cap defaults to 1000000. Settlement
49
+ also constrains preparation by the authoritative Quote and Wallet's Policy.
50
+ Unknown top-level fields, including caller prices or payout overrides, fail.
51
+
52
+ Runtime hashes the canonical private input, prepares through Wallet, compares the
53
+ Order tuple/provider/network/asset/seller/usage with the profile before signing,
54
+ then uses the existing narrow commitment/payment/service-ready flow. It forwards
55
+ private JSON only to the bound Provider payment endpoint, refusing redirects.
56
+ Provider result orderId/requestHash/outputHash/usage must match the invocation and
57
+ accepted Settlement delivery evidence. Output hash verifies bytes, not quality.
58
+
59
+ The result version is agentpay.runtime-result.v1, with orderId, requestHash,
60
+ service {skillId, profileHash}, JSON output, outputHash, usageUnits,
61
+ deliveryEvidenceVerified, confirmationRequired, finalization and deadlines.
62
+ Settlement deadlines remain epoch milliseconds, with frozen chain-seconds fields
63
+ preserved by existing normalizers. Do not recompute schedules locally.
64
+
65
+ ## Durable recovery
66
+
67
+ The existing invocation store remains one serialized ledger, with per-call
68
+ serviceBinding and routingVersion on new generic entries. The same Idempotency-Key
69
+ cannot switch service, adapter, input or usage cap; old random entry identifiers
70
+ are not reinterpreted. Startup retains older requests for read-only reconciliation and explicit review.
71
+ They cannot create replacement purchases. Current entries are checked against their
72
+ own reference on every begin.
73
+
74
+ Verified results are fsynced before HTTP success under <state-file>.results,
75
+ owner-held mode 0600 in a 0700 directory. The Runtime returns saved output after
76
+ restart without another Wallet/Provider call. The shared client separately retains
77
+ request checkpoints and verified output. Neither layer stores Service Authorization
78
+ plaintext. Signed payment recovery material keeps its existing private boundary.
79
+
80
+ Default calls recover the matching current request or reuse its verified result.
81
+ --force explicitly starts another independent request, preserving old records.
82
+ Adapter/usage edits are not silently considered new intent: the old full binding
83
+ rejects the change unless explicitly forced. Force never bypasses Policy or Quote
84
+ checks. When several unfinished forced requests make recovery ambiguous, stop;
85
+ select a recorded identifier diagnostically. After a forced request succeeds,
86
+ default repeats reuse that result rather than unexpectedly funding older work.
87
+
88
+ Runtime has no selected service and does not load active-skill.json at startup.
89
+ That retained filename is only the official test material checkpoint. Its legacy
90
+ selection format must not be treated as general Runtime configuration. New test
91
+ checkpoints record routingVersion; older test requests pause for explicit recovery
92
+ review and are never reinterpreted as new generic purchases. The old random route
93
+ is removed. Deployment must gate on pending older requests and update User/Agent,
94
+ matching types and official package together. No silent state reset is allowed.
95
+
96
+ The invocation ledger is owned by one Runtime process. Multiple processes must
97
+ not share its state file. The result is a delivery-time snapshot, not a continuously
98
+ updated finalization/payout status.
99
+
100
+ ## Packaging and release
101
+
102
+ Use the publisher template: change package metadata, copy a registered Provider
103
+ reference, edit local validateRequest, business JSON and result.output handling.
104
+ Validate business input before any payment; Protocol JSON bounds are not a domain
105
+ schema. The shared User client does transport, credentials and recovery. A Skill
106
+ calling several services retains each step's input and resumes earlier paid steps.
107
+ All eligible calls share the existing bounded Policy; no new owner signature is
108
+ required merely because another qualified service is used.
109
+
110
+ The maintained template is published by AgentPay Agent and discovered by Market.
111
+ User's official executable test package has an independently pinned digest; template
112
+ availability does not authorize replacing that package. See
113
+ [official package maintenance](../runbooks/official-test-package.md).
114
+ Actual harness discovery and scoped deployed purchases need separate acceptance;
115
+ component tests with simulated Wallet evidence are not that.
116
+
117
+ Older routing records are preserved and shown for review without preventing the
118
+ Runtime process from starting. Invalid/corrupt history can still block paid activity.
119
+ Do not reset state or create replacement purchases to bypass an unresolved record.
@@ -0,0 +1,67 @@
1
+ # User npm integration verification — 2026-11-07
2
+
3
+ User 0.3.0 candidate consumes public Wallet 0.3.0 and Protocol 0.14.3 through
4
+ public exports. No sibling source or Wallet compiler is required. User remains
5
+ private/unpublished. No participant service or private data changed.
6
+
7
+ ## Checks completed
8
+
9
+ - Independent source copy with npm dependencies and no sibling Wallet: 366 tests
10
+ passed, no failures/skips. Real process and IPC checks are included; remote
11
+ platform/payment behavior uses controlled fixtures, not real financial acceptance.
12
+ - Final legacy data-location and repair-lock regressions, including local-update
13
+ tests: 21 passed. A competing installer and conflicting connection stop before
14
+ service changes.
15
+ - Packed User installed into a separate consumer directory: `agentpay help` worked;
16
+ installed preparation and exact Wallet version checks passed without invoking a
17
+ compiler or package manager. No source lockfile was needed.
18
+ - Real Wallet/Runtime started from the installed artifact: health answered, duplicate
19
+ Wallet startup was rejected, restart remained locked and preserved its encrypted
20
+ key. These two installed-package tests passed.
21
+ - Package allowlist includes runtime, public docs and licenses; no tests, private
22
+ state, credentials, sibling source or source lockfile. Git whitespace checks passed.
23
+
24
+ ## Implementation boundaries
25
+
26
+ Installation state uses XDG state storage. Setup configuration is stored with
27
+ private User data; old source checkpoints preserve custom data-directory selection.
28
+ A new npm installation cannot discover arbitrary old source directories: provide
29
+ AGENTPAY_USER_DATA_DIR when moving an old custom installation.
30
+
31
+ Repair checks exact installed versions, holds the installer lock across service
32
+ changes and updates only recognized managed units. Client-module relocation requires
33
+ matching Runtime URL and caller credential. Uninstall keeps data by default;
34
+ explicit --delete-data requires destructive confirmation. Neither renews permissions
35
+ nor creates purchases.
36
+
37
+ ## Still required
38
+
39
+ Participant setup/upgrade/restart/uninstall acceptance, running-daemon version
40
+ negotiation, User npm/OIDC publication and Market guidance. Package metadata alone
41
+ does not identify a previously running daemon; current repair performs a managed
42
+ restart and readiness checks. No systemd login, browser, real-network or production
43
+ acceptance is claimed. Exact pins remain until compatibility ranges are designed.
44
+
45
+ ## Review corrections and npm update
46
+
47
+ Relocation previously failed inside service preparation despite a permissive outer
48
+ preflight. Repair preparation now checks a relocation without writing it; only the
49
+ post-stop phase updates the client-module path. The real autostart script was tested
50
+ with old unit/client paths and a controlled systemctl command. Explicit purge now
51
+ removes matching legacy checkpoints/setup files so subsequent setup cannot reimport
52
+ them; unrelated source installation scope is not deleted.
53
+
54
+ After these corrections, the independent suite passed 374 tests. Final focused
55
+ checks passed 35, including cancellation, -f, installed-file changes during consent,
56
+ source-link rejection, install/repair failure, lock contention and retained data.
57
+
58
+ A real npm global installation under a temporary prefix was replaced from local
59
+ 0.3.0 and 0.3.1 candidate tarballs. A new Node process loaded the new repair/version
60
+ and retained the private fixture. Neither candidate was published. Registry metadata,
61
+ systemd/readiness and official download were controlled in this check: it proves
62
+ artifact replacement and process handoff, not live platform/paid or login acceptance.
63
+ The existing official-package tests cover pinned digest rejection and preservation.
64
+
65
+ The updater follows npm's [install](https://docs.npmjs.com/cli/v11/commands/npm-install/)
66
+ and [view](https://docs.npmjs.com/cli/v11/commands/npm-view/) command interfaces.
67
+ A released-version registry upgrade and participant recovery still need acceptance.
@@ -0,0 +1,48 @@
1
+ # Onboarding writing rules
2
+
3
+ Confirmed with the User on 2026-10-06 through review of the English terminal
4
+ setup demo. Apply these rules to user onboarding documents, terminal prompts
5
+ and future Market guidance. They describe presentation, not new authorization
6
+ or protocol requirements.
7
+
8
+ ## One action at a time
9
+
10
+ - Explain what the current step accomplishes and why it is needed.
11
+ - Keep the main screen focused on the current decision. Put technical addresses,
12
+ generated identifiers and transaction data behind an explicit `details` action.
13
+ - Place relevant reminders immediately before the operation they concern.
14
+ - State exactly what to enter; quote literal commands and give useful examples.
15
+ - Explain amounts with a named currency and duration in days from now.
16
+ - Before a permission or paid test, explain its scope, cost and effect, then ask
17
+ for agreement. Normal eligible purchases still use the existing bounded Policy
18
+ without another owner signature per Order.
19
+
20
+ ## Visual structure and recovery
21
+
22
+ - Separate each step with a consistent divider and a short title.
23
+ - Label action menus `> Choose an action`.
24
+ - Prefix the recommended action with `*` and retain `← next step`.
25
+ - Make progress labels agree with available actions and the completed steps.
26
+ - On invalid input, show allowed inputs and stay at the current prompt.
27
+ - Explain whether `q` cancels a step, returns to a menu or exits the program.
28
+ - Resume completed work without unnecessarily repeating it. State persistence
29
+ limits: current demo progress survives only within the same process.
30
+
31
+ ## Complete the first-use loop
32
+
33
+ Guide initialization → authorization → binding → startup → local checks →
34
+ official random Skill installation and connectivity test → explicit completion.
35
+ After the test passes, direct the user to Market to choose other Skills.
36
+ The test completion screen need not display the random number.
37
+
38
+ Current demo cost is explicitly an example: 0.001 demo USDC. Real integration
39
+ must display the validated current quote before test agreement; this example
40
+ is not a configured or guaranteed service price.
41
+
42
+ Clearly distinguish preview, simulation and executed operations. The demo
43
+ passes no real authorization, starts no process, installs no package and makes
44
+ no payment. Real onboarding must use actual command/API results. Write guides
45
+ against delivered scripts; mark remaining integrations explicitly.
46
+
47
+ English prompts and Linux with Node are the current scope. Browser opening
48
+ is not required; multilingual guidance and macOS verification remain deferred.
@@ -0,0 +1,97 @@
1
+ # Original-Policy and missing-Order recovery — 2026-11-02
2
+
3
+ ## Scope
4
+
5
+ Runtime starts even when history needs review. Background recovery only performs
6
+ bounded authenticated reads; it cannot prepare Orders, submit payment, confirm
7
+ receipt, invoke a Provider, or replace the current Policy.
8
+
9
+ New invocation records save recoveryScope (network, Module, Safe, Policy ID) before
10
+ Order preparation. Existing records are never assigned the current Policy merely
11
+ because their original scope is missing. Existing saved payment metadata can
12
+ supply its original Policy/Safe/network; the configured Module remains pinned and
13
+ Wallet independently checks the on-chain Policy delegate against its local key.
14
+ Different network/Module/Safe, revocation, future activation or unavailable key
15
+ cannot be bypassed. Expiry alone permits bounded historical order.read requests.
16
+
17
+ ## Interfaces
18
+
19
+ Wallet agent IPC readSettlementOrder accepts exactly one of orderId or
20
+ orderRequestId and an optional recoveryScope. No historical payment/action method
21
+ is added. Wallet obtains chain identity and Policy terms via its configured RPC,
22
+ signs order.read for the original Policy, and leaves policy.json unchanged.
23
+
24
+ Settlement order.read accepts exactly one selector. Request lookup uses existing
25
+ preparation rows scoped by Safe/Policy and joins Orders constrained by Module,
26
+ network and chain. It returns found=false with the original request ID, or found=true
27
+ with the ordinary buyer Order projection. Missing rows never trigger prepare().
28
+ The signed payload hash binds the chosen selector. Original orderId reads remain
29
+ unchanged. Auth, nonce consumption and expiry/revocation rules are retained.
30
+
31
+ Runtime validates returned request ID, request hash, service identity and any
32
+ saved payment commitment before attaching a recovered Order ID. The attachment
33
+ uses a compare-and-set under the local store lock so a foreground update is not
34
+ overwritten. A later scan reads its financial state. A missing lookup is not proof
35
+ of no on-chain payment; absent original scope and network errors stay distinct.
36
+ Original history is retained. New foreground preparations also pass expectedScope
37
+ to Wallet to prevent creating the original request under a different current Policy.
38
+
39
+ ## Verification and deployment boundary
40
+
41
+ Controlled tests cover historical signing without rebinding, wrong key/revoked/
42
+ foreign scope, read-only request selection, unavailable reads, response mismatch,
43
+ concurrent attachment, and two business payloads through the common Runtime path.
44
+ Wallet TypeScript compiles to a separate temporary build; live dist is untouched.
45
+ No SQL schema or contract changes. Deploy Settlement + Wallet + User together, then
46
+ restart ordinary-user services and unlock in the terminal. Participant checks of
47
+ original history were checked on 2026-11-02: revoked original Policy and missing
48
+ original scope remain explicit review. Local archive acceptance remains pending.
49
+ No actual purchase is needed for this acceptance.
50
+
51
+ An existing request lacking both an Order ID and original Policy may still require
52
+ manual investigation; this implementation does not fabricate its authorization.
53
+
54
+ ## Inspect and mark local records
55
+
56
+ ```sh
57
+ ./run orders list
58
+ ./run orders details <ORDER_OR_REQUEST_ID>
59
+ ./run orders status <ORDER_OR_REQUEST_ID>
60
+ ./run orders archive <ORDER_OR_REQUEST_ID>
61
+ ./run orders unarchive <ORDER_OR_REQUEST_ID>
62
+ ```
63
+
64
+ `status` keeps Order warnings brief and directs users to `orders`. The local list
65
+ shows saved status and a readable warning for each record, followed by details and
66
+ archive/unarchive commands. Unknown payment is never presented as unpaid.
67
+
68
+ `orders` includes unfinished requests with no saved Order ID. Use a full ID or an
69
+ unambiguous prefix (at least 10 hexadecimal characters after `0x`). `details` is
70
+ also the default action: it works offline while Wallet is locked. `status` performs
71
+ an authenticated read and needs an unlocked Wallet; it does not initiate payment.
72
+
73
+ Archive asks for a short review note and confirmation. It hides only the warning
74
+ matching the saved record and check result. A changed state or problem is shown
75
+ again. Notes live in `runtime/invocations.json.reviews.json`, beside the unchanged
76
+ invocation history. Unarchive restores the reminder and records the action.
77
+
78
+ Archive does not cancel an Order, prove payment/nonpayment, revoke authorization,
79
+ remove history, or stop work already in flight. It prevents further preparation or
80
+ payment submission for that archived request. Background read-only checks continue.
81
+ Do not create a replacement request to recover an unknown payment. Notes must not
82
+ contain secrets. Concurrent note updates fail closed; if a process is interrupted
83
+ while writing, preserve the files and ask support to inspect the review lock before
84
+ retrying. Do not delete invocation history to clear a warning.
85
+
86
+ ## Pending structured result persistence
87
+
88
+ A received, structurally valid Provider result is saved privately in
89
+ `runtime/invocations.json.pending-results/` before evidence polling. It cannot be
90
+ returned as a verified result until authenticated original-Order identity, output
91
+ hash and usage checks pass. Background recovery can perform this read-only promotion;
92
+ foreground same-request resume uses the saved copy before service/payment actions.
93
+ No service execution or new payment is used to promote a pending copy. An unavailable or mismatched original authorization remains a blocker;
94
+ spending expiry/revocation alone does not create replacement-purchase permission. Missing evidence retries with pending
95
+ state; mismatch/storage failure preserves the candidate and a distinct warning.
96
+ Verified records retain the existing `.results/` format. Both copies remain locally;
97
+ this loop does not implement automatic eviction or download files referenced by URL.
@@ -0,0 +1,18 @@
1
+ {
2
+ "mode": "private-anvil",
3
+ "chainId": 31337,
4
+ "source": "operator-reviewed private Anvil deployment",
5
+ "rpcUrl": "http://127.0.0.1:8547",
6
+ "module": "REPLACE_WITH_DEPLOYED_MODULE_ADDRESS",
7
+ "token": "REPLACE_WITH_DEPLOYED_TOKEN_ADDRESS",
8
+ "factory": "REPLACE_WITH_DEPLOYED_FACTORY_ADDRESS",
9
+ "registry": "REPLACE_WITH_DEPLOYED_REGISTRY_ADDRESS",
10
+ "tokenDecimals": 6,
11
+ "tokenSymbol": "USDC",
12
+ "ownerAddress": "REPLACE_WITH_TEST_SAFE_OWNER_ADDRESS",
13
+ "settlementUrl": "http://127.0.0.1:6572",
14
+ "runtimeUrl": "http://127.0.0.1:6490",
15
+ "marketBundleMetadataUrl": "http://127.0.0.1:6583/skills/bundles/REPLACE_WITH_MARKET_SERVICE_ID/metadata",
16
+ "bundleSha256": "REPLACE_WITH_PUBLISHED_BUNDLE_SHA256",
17
+ "maxUsageUnits": 1
18
+ }
@@ -0,0 +1,56 @@
1
+ # Public deployment settings and owner signer
2
+
3
+ ## Public facts
4
+
5
+ User settings published by Market retain the existing fields: mode, chainId,
6
+ source, rpcUrl, settlementUrl, module, token, factory, registry, tokenDecimals,
7
+ tokenSymbol and the official-test metadata URL/digest/usage fields.
8
+ Supported mode labels are private-anvil and production; neither chooses a signer.
9
+ chainId must be a positive safe integer. HTTPS and loopback HTTP are permitted;
10
+ URL credentials, queries and fragments are rejected. Token decimals are 0–36.
11
+ Addresses must be valid nonzero EVM addresses. No participant Safe, owner, secret
12
+ or ownerSigner is accepted in the public User settings.
13
+
14
+ Provider settings retain network as eip155:<chainId> and assetAddress rather than
15
+ renaming their existing wire fields. Their numeric network and token constraints
16
+ match User settings. The Provider no longer defaults missing network to 31337.
17
+ This aligns the role-specific projections; it does not add a Protocol wire version
18
+ or claim the deployment scripts already generate one authoritative manifest.
19
+
20
+ Official package metadata remains release-pinned by User. Accepting another
21
+ network configuration never authorizes a substituted executable package.
22
+
23
+ ## Local signer selection
24
+
25
+ Owner signing is selected independently of network:
26
+ - external: prepare operations for the Safe owner; never call an unlocked test account.
27
+ - anvil: explicit private test adapter; still requires chain 31337 and loopback HTTP.
28
+ The adapter also verifies the actual RPC chain and single-owner test Safe.
29
+
30
+ The initial private guide asks for this choice (default external) and saves it in
31
+ its local settings. When the participant confirms owner operations, it persists
32
+ runtime/owner-signer.json inside the User data directory as a private file:
33
+ `{"version":1,"kind":"external"}` or `{"version":1,"kind":"anvil"}`.
34
+ Renew/revoke read this local choice. AGENTPAY_OWNER_SIGNER can explicitly override
35
+ it for the current process. No record means external; existing installations are
36
+ not silently opted into test signing based on chain ID.
37
+
38
+ For an existing private installation with no saved selection, an operator may use
39
+ `AGENTPAY_OWNER_SIGNER=anvil ./run policy renew` (or revoke) only when that actual
40
+ authorization change is intended. Do not run either command merely to configure
41
+ the signer. No local Wallet Policy/key/history is changed by reading the selection.
42
+
43
+ ## Implemented approval and remaining acceptance
44
+
45
+ The common setup runner accepts configured EVM networks and uses the same draft,
46
+ plan, chain checks and Wallet binding. Its historical module/local settings filename
47
+ is retained for checkpoint continuity. External approval serves a temporary local
48
+ website for an injected owner wallet, with a portable export fallback. Setup, renewal
49
+ and revocation retain their operation plans and check actual chain effects before
50
+ continuing. An external signer can be selected on Anvil. See
51
+ [browser approval](../runbooks/safe-owner-web.md) for execution and recovery.
52
+ Single-owner private Anvil acceptance does not prove multisig, headless recovery or
53
+ public-network readiness; those acceptance gates remain in [TODO](../TODO.md).
54
+
55
+ The official test package/network map is still private-only. Another network pauses
56
+ before that package installation after retaining its verified authorization.
@@ -0,0 +1,18 @@
1
+ # Official random-service test example
2
+
3
+ The random service is the maintained post-setup payment connectivity example. Its
4
+ business input/output belongs to the reference Skill and Provider, not Runtime's
5
+ common protocol. Runtime accepts per-call service references and business JSON;
6
+ see [common invocation contract](multi-service-runtime.md).
7
+
8
+ The official test uses a release-pinned package digest from User. Market can supply
9
+ public download metadata but cannot replace trusted executable bytes. A new paid
10
+ test requires explicit quote confirmation; an interrupted test resumes its original
11
+ request. Normal startup, Orders, cache and Policy management do not require this
12
+ service to be selected globally.
13
+
14
+ The editable reference implementation is published in
15
+ [AgentPay Agent](https://github.com/c4rO-0/agentpay-agent). User's local test fixtures
16
+ are controlled copies for development, not a source of trusted production packages.
17
+ See [official package maintenance](../runbooks/official-test-package.md) and
18
+ [Skill author integration](../runbooks/runtime-skill-client.md).