@c4roa0/agentpay-user 0.0.0-stage → 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.
Files changed (175) 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 +85 -2
  6. package/SECURITY.md +16 -0
  7. package/doc/README.md +52 -0
  8. package/doc/TODO.md +107 -0
  9. package/doc/architecture.md +99 -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 +103 -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 +103 -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 +210 -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 +1233 -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 +316 -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/protocol-package.mjs +25 -0
  145. package/src/readiness-profile.mjs +30 -0
  146. package/src/renew-policy.mjs +605 -0
  147. package/src/repair-market-wallet.mjs +137 -0
  148. package/src/restore-wallet.mjs +255 -0
  149. package/src/result-cache-view.mjs +276 -0
  150. package/src/runtime-client.mjs +1145 -0
  151. package/src/runtime-connection-settings.mjs +101 -0
  152. package/src/runtime-recovery.mjs +667 -0
  153. package/src/runtime-status.mjs +32 -0
  154. package/src/safe-owner-anvil.mjs +115 -0
  155. package/src/safe-policy-plan.mjs +195 -0
  156. package/src/service-reference.mjs +233 -0
  157. package/src/service-url.mjs +52 -0
  158. package/src/settlement-response.mjs +69 -0
  159. package/src/setup-autostart.mjs +197 -0
  160. package/src/setup-demo.mjs +152 -0
  161. package/src/skill-bundle.mjs +142 -0
  162. package/src/skill-client.mjs +198 -0
  163. package/src/skill-install-prompt.mjs +31 -0
  164. package/src/skill-package.mjs +50 -0
  165. package/src/skill-zip.mjs +220 -0
  166. package/src/software-versions.mjs +48 -0
  167. package/src/status-panel.mjs +603 -0
  168. package/src/transport.mjs +48 -0
  169. package/src/uninstall-local.mjs +299 -0
  170. package/src/user-cli.mjs +354 -0
  171. package/src/user-setup-guide.mjs +193 -0
  172. package/src/wallet-control.mjs +182 -0
  173. package/src/wallet-ipc-error.mjs +16 -0
  174. package/src/wallet-package.mjs +28 -0
  175. package/update-pair.json +6 -0
@@ -0,0 +1,93 @@
1
+ # Skill glue and shared input/output persistence
2
+
3
+ Implemented design reference. Current release/participant gates are tracked in
4
+ [TODO](../TODO.md); this document is not new deployment or payment authorization.
5
+
6
+ ## Responsibilities
7
+
8
+ The editable Skill is glue: it validates application input, explicitly identifies
9
+ input/output files and adapts application data to its Provider interface. The
10
+ installed User client owns common persistence and recovery. Runtime continues to
11
+ own the existing bounded payment, service authorization and delivery verification
12
+ path. This work does not move those operations into arbitrary Skill callbacks.
13
+
14
+ Shared caching does not impose a common Provider business payload or result
15
+ format. Input remains supported bounded JSON, including arrays and nested data;
16
+ it is not necessarily text. Binary data belongs in separate files, not an enlarged
17
+ JSON/base64 payload. Only hashes and existing required metadata reach Settlement;
18
+ private content remains local or travels to the selected Provider.
19
+
20
+ ## Invocation lifecycle
21
+
22
+ 1. Validate input and select/preserve the original request ID. Persist explicit
23
+ file declarations and preparation state before copying files or submitting a
24
+ paid invocation. An incomplete snapshot cannot be mistaken for a file-free call.
25
+ 2. Save JSON using the existing checkpoint mechanism. Snapshot only files the
26
+ Skill explicitly declares; ordinary strings, paths and URLs are not instructions
27
+ to read or fetch. Record a stable file key, size and content digest. Write files
28
+ durably before marking the complete input snapshot ready.
29
+ 3. Application adaptation consumes the saved copies, not mutable original paths.
30
+ Preserve the exact final business request used for its existing request hash.
31
+ Provider-specific upload/reference construction must not be silently invented
32
+ by the common client. A changed or expired upload reference is not permission
33
+ to change an already submitted business request or create another Order.
34
+ 4. Continue through the existing Runtime payment/invocation path. Before the first
35
+ network submission, durably record that submission may occur; a crash or missing
36
+ local Order ID is not proof of non-payment.
37
+ 5. Retain the existing verified structured-result persistence. A Skill explicitly
38
+ selects output files for the existing Order-scoped cache. Cache/download failure
39
+ is distinct from paid service failure: retain the verified result and retry
40
+ caching only, without invoking the paid service again or confirming receipt.
41
+ 6. Resume by original request identity and saved inputs. A valid saved result can
42
+ be read without requiring its original input files to remain available. A resume
43
+ that still needs input bytes must stop if their snapshot is missing or corrupt.
44
+
45
+ Inputs are request-scoped because an Order may not exist yet. Outputs keep their
46
+ existing Order/evidence scope. Do not invent Order IDs for input caching or change
47
+ delivery hash rules to match cache digests. Runtime URLs are connection locations;
48
+ port changes do not create new request or file identities. The separate
49
+ [address recovery plan](runtime-address-recovery.md) still requires atomic
50
+ existing-only continuation when recovering potentially submitted requests.
51
+
52
+ ## Retry and storage boundaries
53
+
54
+ - Repeating a matching invocation selects its existing snapshot before reading
55
+ mutable sources. An edited/deleted original file does not replace saved bytes.
56
+ Deliberately using new input remains an explicit new request; `--force` retains
57
+ its existing additional-purchase meaning and never bypasses Policy limits.
58
+ - A missing snapshot after possible submission is a recovery problem, not a reason
59
+ to reconstruct from changed files. Legacy JSON-only requests remain JSON-only;
60
+ never infer missing file declarations from historical strings.
61
+ - Use bounded streaming, private local storage, atomic manifests and the existing
62
+ portable locking approach where appropriate. Do not introduce Linux-only process
63
+ identity checks or another lock protocol just for this feature.
64
+ - Reuse download validation for explicitly declared URL sources; do not assume
65
+ HTTPS-only Providers. Do not forward Wallet, Runtime or platform credentials to
66
+ file hosts. Do not follow symlinks or automatically inspect unrelated local files.
67
+ - Input and output usage must both be visible and bounded. Reusing numeric defaults
68
+ does not establish a shared quota unless accounting actually includes both stores.
69
+ Final limits and CLI presentation must be documented with implementation.
70
+ - Never automatically evict inputs needed by unresolved requests. Explicit deletion
71
+ must explain loss of local recovery, retain request/digest history, and prevent
72
+ future retries from silently substituting fresh input. Cache cleanup is not Order
73
+ cancellation. Existing uninstall confirmation covers deletion of local data.
74
+
75
+ ## Implementation sequence and acceptance
76
+
77
+ The user changed the sequence to **cache foundation first**. The detailed
78
+ [local cache design](local-cache-foundation.md) owns storage and management.
79
+
80
+ 1. Review existing storage; specify shared layout, formats, quotas, crash states,
81
+ cleanup and management. No payment/Skill integration in this loop.
82
+ 2. Implement the shared file store and management commands; reuse existing output
83
+ capabilities instead of running separate input/output storage engines.
84
+ 3. Verify the foundation with maintained arbitrary-byte fixtures, large streams,
85
+ concurrent operations, disk failures, process interruption and cleanup races.
86
+ 4. Attach input snapshots and existing verified results to request recovery;
87
+ implement address-independent original-record selection and atomic existing-only
88
+ continuation. Missing history must never create replacement purchases.
89
+ 5. Update editable templates and common Skill-client hooks, then verify two business
90
+ payloads through the same Runtime. Output-download retries must not repeat paid
91
+ execution. Participant deployment follows review and controlled verification.
92
+
93
+ No services, policies, stored purchases or public APIs are changed by this plan.
@@ -0,0 +1,23 @@
1
+ # Wallet identity and Policy history
2
+
3
+ Market display identity is network + Module + Safe + execution address (delegate).
4
+ The nickname belongs to that identity. Several individually verified Policies may
5
+ be attached, but each remains the access boundary for its own Orders. Same-key
6
+ copies with the same tuple are one Wallet, not separately verified machines.
7
+
8
+ User keeps one active local spending Policy and preserves original request scopes.
9
+ `./run market connect` proves the current Policy; renewal can continue connection
10
+ to the same Wallet. Failure to connect does not undo a successful on-chain renewal
11
+ or authorize recreating a Policy. Connection receipts are local metadata, not proof
12
+ of live website access.
13
+
14
+ Spending expiry, revocation and Module disablement stop the applicable new payments.
15
+ Original Order reads/support use their original verified scope and Order-specific
16
+ rules/deadlines; retaining history does not grant a different key access. Never
17
+ merge by Safe or nickname alone. Historical read verification does not change the
18
+ active binding or authorize a new purchase.
19
+
20
+ Use [Market connection](../runbooks/market-connection.md), [renewal](../runbooks/policy-renewal.md)
21
+ and [backup/restore](../runbooks/wallet-identity.md) for current user procedures.
22
+ Account grouping is not a revocation mechanism: consult
23
+ [emergency stop](../runbooks/emergency-payment-stop.md) for a compromised key.
@@ -0,0 +1,103 @@
1
+ # User command reference
2
+
3
+ Use `agentpay` after installing the package or linking a source checkout with
4
+ `npm link`. From a source folder, `./run` is the same entry; it uses Node on PATH
5
+ or `AGENTPAY_NODE`.
6
+
7
+ ```sh
8
+ agentpay help
9
+ agentpay status
10
+ ```
11
+
12
+ Top-level operations are `install --market URL`, `setup`, `repair [-f]`,
13
+ `update [-f]`, `uninstall [--delete-data]` and `status`.
14
+ Update checks npm and installs User with its pinned Wallet, then checks the official
15
+ test Skill. It asks before changes unless `-f` is given. Source/npm-link installations
16
+ use manual source updates followed by repair. Repair checks installed packages and
17
+ confirms service interruption; `-f` skips that prompt only. Uninstall removes
18
+ services and keeps data unless `--delete-data` is explicitly confirmed. Neither
19
+ operation revokes on-chain permission.
20
+
21
+ | Group | Operations |
22
+ | --- | --- |
23
+ | `wallet` | `info`, `unlock`, `lock`, `restore` |
24
+ | `policy` | `info`, `renew`, `revoke` |
25
+ | `service` | `start`, `stop`, `restart`, `autostart on/off`, `logs wallet/runtime` |
26
+ | `market` | `connect [--market URL]` |
27
+ | `orders` | `list`, `details ID`, `status ID`, `retrieve ID`, `case ID`, `archive ID`, `unarchive ID`, `files ID [remove KEY]` |
28
+ | `cache` | `info`, `list`, `details ID`, `export ID PATH`, `clean`, `settings [KEY VALUE]` |
29
+ | `payment` | `test` |
30
+
31
+ A group without an action shows help; it never unlocks, revokes or changes files.
32
+ Use `<group> help`, or `service autostart help`, to see focused instructions. Old
33
+ flat commands such as `unlock`, `renew`, `connect-market`, `order ID details` are
34
+ no longer accepted; use the grouped forms shown here.
35
+
36
+ ## Common tasks
37
+
38
+ ```sh
39
+ agentpay service start
40
+ agentpay wallet unlock
41
+ agentpay status
42
+ agentpay payment test
43
+
44
+ agentpay policy renew
45
+ agentpay policy revoke
46
+
47
+ agentpay orders list
48
+ agentpay orders details ORDER_ID
49
+ agentpay orders retrieve ORDER_ID
50
+
51
+ agentpay service autostart off
52
+ agentpay service stop
53
+ agentpay service logs runtime
54
+ ```
55
+
56
+ `policy renew` covers expired renewal and active replacement. Revoking permission
57
+ requires owner confirmation, and existing Orders retain their support rules.
58
+ Service stop/Wallet lock do not revoke permission. Archive hides a local warning;
59
+ it does not cancel or settle an Order. Retrieve requests the original result and
60
+ never buys a replacement. Cache removal only removes local copies.
61
+
62
+ Online Order operations require an unlocked Wallet. Start/unlock instructions and
63
+ `status` guide you to the next action; setup renews expired authorization first.
64
+
65
+ `status` includes a Policy section and expiry. “Within saved validity period” describes
66
+ local saved validity, not a new chain/payment-readiness check. Revocation records
67
+ are the last verification by this command suite. Unknown or conflicting scope is
68
+ shown as unconfirmed; use `policy info` for saved details.
69
+
70
+ `payment test` is the maintained end-to-end purchase check. In this release it uses
71
+ the reviewed private-Anvil official Skill. It shows the current price and service
72
+ time and asks before every new paid Order. If a test is unfinished, the same command
73
+ resumes its saved request instead of starting another purchase. Completed test records
74
+ are archived before a new one; the original onboarding test and Skill selection stay
75
+ untouched. After verified delivery, Wallet acknowledges receipt, which can bring
76
+ forward Provider payout.
77
+
78
+ The command checks payment, delivery and receipt acknowledgement. Provider payout
79
+ follows the Order’s settlement schedule; success does not claim final payout.
80
+
81
+
82
+ ### Order status sources
83
+
84
+ `agentpay orders status ID` reads the current Settlement record through Wallet.
85
+ It displays retrieval time and the record update time when available; it does not
86
+ independently query the chain. If querying fails, the command labels the last
87
+ local record and its saved check time. A successful query does not rewrite local
88
+ history; Runtime maintains its own recovery observations. Use
89
+ `agentpay orders details ID` for the saved local record.
90
+
91
+ ## Running-version checks (User 0.3.1)
92
+
93
+ `agentpay status` compares the installed User/Wallet pair with the versions reported
94
+ by the running processes. A mismatch leads to `agentpay repair`; missing reporting
95
+ requires a paired package update first. Repair only records success after both
96
+ processes report the expected package, local reporting interface and Protocol versions.
97
+ These checks do not change Policy validity, Order identity or payment permissions.
98
+ User 0.3.1 installs the required Wallet 0.3.1 dependency automatically.
99
+
100
+ Protocol reporting reads the installed package resolved by that process, rather than
101
+ copying its dependency declaration. User preflight checks both User's and Wallet's
102
+ resolved copies against the reviewed exact version, including nested dependencies.
103
+ Package version checks establish compatibility metadata, not file-integrity attestation.
@@ -0,0 +1,42 @@
1
+ # Update spending permission after contract changes
2
+
3
+ Run `./run setup` or `./run policy renew`. Both check the published deployment and
4
+ explain a mismatch before owner transactions. An existing Market connection supplies
5
+ the HTTPS (or private loopback) configuration source. Without one, the guide can
6
+ use the public deployment file downloaded by installation. `status` labels this
7
+ as downloaded evidence rather than a current platform check.
8
+
9
+ Review updated permission, using `details` to inspect old/new contracts. Factory and
10
+ Module changes are supported within the same network, Safe, execution key, token,
11
+ Registry and RPC. Network/token/Registry moves require separate review. Removing a
12
+ Module as an emergency stop is not silently undone by an ordinary renewal.
13
+
14
+ An update defaults to unspent allowance. Exhausted allowance has no automatic new
15
+ budget default. Remaining validity supplies the duration default; retaining that
16
+ default preserves the original expiry. Editing budget or duration deliberately
17
+ requests new limits, which the owner reviews before signing. Ordinary renewal
18
+ continues to offer a new budget and duration. No service-specific logic is involved.
19
+
20
+ Owner approval revokes the original Policy before creating its replacement, enabling
21
+ the destination Module if required. Wallet independently checks original revocation,
22
+ matching identity, destination chain data and zero destination spend before binding.
23
+ Original Policy scope and Orders remain in history. Temporary failure or leaving the
24
+ webpage resumes the saved plan; do not delete records or create replacement purchases.
25
+ A completed chain/binding operation with unfinished local synchronization retries
26
+ that synchronization before a subsequent fresh renewal.
27
+
28
+ After successful binding, setup settings/public Policy/draft projections are updated.
29
+ Previous setup/draft files are retained privately. Existing Market connection flow
30
+ continues; failure there does not undo authorization. No automatic login or new
31
+ spending authority is granted by merely downloading deployment settings.
32
+
33
+ `./run status` shares a 60-second success/error cache for deployment checks. A changed
34
+ deployment takes priority over local missing-result warnings; Orders retain their
35
+ warnings below. A failed check is unavailable, never healthy or proof of revocation.
36
+ Matching deployment does not guarantee a particular service or Order can be bought.
37
+
38
+ Development checks use controlled RPC/IPC fixtures. The recorded private participant
39
+ MetaMask renewal, payment journey and historical Order viewing passed within their
40
+ recorded scope. Full interruption/multisig and public-network acceptance remain
41
+ separate tasks in [TODO](../TODO.md); viewing history does not prove every support
42
+ mutation. No real-network compatibility is claimed by Anvil tests.
@@ -0,0 +1,80 @@
1
+ # Emergency stop: disable AgentPay payments from your Safe
2
+
3
+ Use this procedure if your computer or Wallet Session Key may be compromised.
4
+ Use another trusted device and your Safe owner wallet. Do not enter owner keys,
5
+ Session Keys or unlock passwords into Market or send them to support.
6
+
7
+ This procedure assumes the Safe owner signers remain under your control.
8
+ A compromised owner signer requires a separate Safe account recovery response;
9
+ disabling a Module alone is not sufficient if an attacker can enable it again.
10
+
11
+ ## What disabling the Module means
12
+
13
+ Your Safe permits the AgentPay Spending Module to execute bounded payments.
14
+ Removing that Module from this Safe stops all new payments through that Module,
15
+ across all its Policies and Wallet execution addresses. It does not disable the
16
+ Module for other users' Safes or shut down AgentPay.
17
+
18
+ A copied Session Key cannot bypass this stop: AgentPay funding calls the Safe's
19
+ module execution function, which requires the Module to remain enabled.
20
+ The stop takes effect only when the disabling transaction executes successfully
21
+ on-chain. A pending proposal or owner signature is not a completed stop; payments
22
+ may still execute before it.
23
+
24
+ ## Stop payments from a trusted device
25
+
26
+ 1. Open [Safe Wallet](https://app.safe.global/), select the correct network and Safe.
27
+ 2. Open Settings and find Modules (under advanced settings in some versions).
28
+ Identify the AgentPay Spending Module by its exact address, not only its label.
29
+ Your saved setup and `./run wallet info` expose that address, but information
30
+ displayed on the compromised computer must be independently checked.
31
+ 3. Select removal for that Module. Review the Safe, network and target Module.
32
+ Obtain the Safe's required owner approvals and execute the transaction.
33
+ 4. Confirm a successful chain receipt and verify
34
+ `isModuleEnabled(moduleAddress) == false` on the correct Safe.
35
+ 5. Check for other enabled AgentPay Module versions on this Safe, and repeat if
36
+ necessary. Each network and Safe must be handled separately.
37
+
38
+ Safe exposes this through `disableModule(prevModule, module)`, called by a Safe
39
+ transaction targeting the Safe itself. `prevModule` is the predecessor in its
40
+ enabled-module linked list, not a previous AgentPay release. Do not guess this
41
+ address or submit a direct owner-account call as a substitute for a Safe transaction.
42
+
43
+ Official references:
44
+ [Managing Modules](https://help.safe.global/articles/7039805766-add-a-module),
45
+ [disableModule](https://docs.safe.global/reference-smart-account/modules/disableModule).
46
+
47
+ ## What remains unchanged
48
+
49
+ - Safe owner operations remain available. Other unrelated enabled modules are not removed.
50
+ - Already-funded Order Vaults retain their delivery, cancellation, dispute, payout
51
+ and refund rules. This operation does not refund them.
52
+ - Policy records remain on-chain. Disabling does not revoke or delete them.
53
+ - Market Disconnect, sign-out, stopping Runtime or locking Wallet do not replace
54
+ this chain operation. An attacker may hold a copied key elsewhere.
55
+ - This is a payment stop, not revocation of every history/support credential.
56
+ Do not assume copied credentials lose all non-payment access.
57
+
58
+ ## Before restoring payments
59
+
60
+ Keep the Module disabled while investigating. Replace the compromised execution
61
+ key and revoke its still-valid Policies through the Safe owner before re-enabling
62
+ the Module. Review all relevant Policies, including ones absent from Market's
63
+ connected list. Re-enabling without this cleanup can restore an attacker's
64
+ remaining spending permission.
65
+
66
+ Use a trusted installation for the replacement Wallet. Do not restore a suspected
67
+ leaked key as a security remedy. Keep Order history and incident evidence; do not
68
+ repeat paid requests to recover missing results.
69
+
70
+ ## Current product and rehearsal limits
71
+
72
+ Market currently provides connection management and revocation documentation;
73
+ it does not execute this emergency Safe transaction. `./run policy revoke`
74
+ addresses the locally selected Policy, not every Policy or the entire Module.
75
+ See [Policy renewal and revocation](policy-renewal.md).
76
+
77
+ The private Anvil rehearsal is not available through the hosted Safe Wallet.
78
+ It needs a separately prepared owner-authorized Safe transaction and independent
79
+ chain checks. No emergency Module-disable rehearsal has been completed by writing
80
+ this guide. Do not send private rehearsal transactions to a real network.
@@ -0,0 +1,212 @@
1
+ # Local automatic startup (Linux)
2
+
3
+ Wallet and Runtime can start as systemd user services when you log in. Wallet starts
4
+ locked. Your Session Key and existing Safe Policy are reused; no password is saved.
5
+ This does not enable startup before login or require administrator access/linger.
6
+
7
+ ## Enable during setup
8
+
9
+ After the official connectivity test succeeds, the Linux terminal guide asks once
10
+ whether Wallet and Runtime should start automatically when you log in. Choosing yes
11
+ installs/enables the services and reminder without restarting current processes.
12
+ Choosing no keeps manual startup. Your choice is remembered; q leaves it undecided.
13
+ A saved yes is retried after partial installation failure without repeating consent
14
+ or creating another payment. Manual enable/disable updates the same preference.
15
+
16
+ The installer verifies that existing listeners belong to its matching guide processes
17
+ or existing user services. Missing/stale PID records, mismatched arguments/data paths,
18
+ and system-managed processes block automatic adoption. It never kills a PID from a
19
+ saved file. On the private shared host, operator services remain operator-managed.
20
+
21
+ ## Manage after setup
22
+
23
+ The terminal setup start step saves your public Runtime/Settlement addresses in
24
+ `runtime/local-services.json` under your remembered User data directory. From User:
25
+
26
+ ```bash
27
+ ./run service autostart on
28
+ ```
29
+
30
+ This installs and enables the services for the next login. It does not replace or
31
+ stop current terminal-started or operator-managed processes. Current guide processes are left running; the handoff is deferred until they exit
32
+ or the computer restarts. Do not run two managers for the same Wallet.
33
+ If a login happens while old processes still run, managed startup refuses the occupied
34
+ socket/port; inspect status and explicitly stop the old processes before using start.
35
+ After a clean login, use `./run wallet unlock` to resume signing.
36
+
37
+ If you completed setup before this feature, an operator can save the matching public
38
+ addresses once with `node scripts/autostart.mjs configure RUNTIME_URL SETTLEMENT_URL`.
39
+ Use your existing deployment, not arbitrary endpoints. This saves settings only.
40
+ Do not change endpoints to work around an incomplete request or Policy migration.
41
+
42
+ ## Manage
43
+
44
+ From User, `./run status` shows the services. Use `start` or
45
+ `stop` for these managed processes. Before manually starting them, stop any existing
46
+ terminal/operator-managed instance explicitly. A live Wallet socket or Runtime port
47
+ is rejected; it is never removed to take over an existing process.
48
+
49
+ `./run service autostart off` disables login startup without stopping current processes.
50
+ `./run service stop` stops them now without changing the login preference.
51
+ `./run service start` starts them manually; `./run service restart` restarts them locked.
52
+ `./run service logs runtime` shows recent Runtime service errors. Wallet data and history remain.
53
+ This is not on-chain revocation, deletion of the installation, or Order cancellation.
54
+
55
+ Files are installed under `~/.config/systemd/user/`: agentpay-local-wallet.service,
56
+ agentpay-local-runtime.service and agentpay-wallet-reminder.service. The installer
57
+ does not use or change `~/.config/autostart`, including its permissions or contents.
58
+ A conflicting existing file is preserved and reported. Services use absolute Node
59
+ and source paths; do not move/delete those paths before disabling/reconfiguring.
60
+ The current implementation uses the standard ~/.config location.
61
+
62
+ ## Login reminder
63
+
64
+ A systemd user oneshot, enabled for graphical-session.target, checks Wallet status
65
+ and sends one best-effort notification
66
+ if it is locked. It does not unlock, prompt for a password, open a terminal or make
67
+ a payment. The notification tells you to open User and run `./run wallet unlock`.
68
+ There is no click-to-unlock action in this first version.
69
+
70
+ Linux needs a desktop environment that starts systemd graphical-session.target and
71
+ imports its display/session environment, a notification service, and `notify-send`.
72
+ The reminder stays active until graphical logout (PartOf + RemainAfterExit) so normal
73
+ Wallet restarts do not repeat it. Manual service start starts only Wallet/Runtime. With SSH/headless
74
+ sessions, missing notification support or an already unlocked Wallet, no popup is
75
+ sent. Runtime/Skill locked errors still show the unlock command. A missed notification
76
+ does not grant authority or block service startup. If Wallet does not become available
77
+ during bounded checking, inspect service status; notification is not a health monitor.
78
+
79
+ ## Acceptance scope
80
+
81
+ Isolated process tests verify locked Wallet/Runtime startup, duplicate Wallet refusal,
82
+ stop/restart with unchanged test key and no invocation. Unit/CLI tests and systemd
83
+ file validation passed. The terminal installer now offers deferred automatic startup after its successful
84
+ connectivity test; it does not immediately replace guide processes. The participant reported successful Wallet restart/lock/unlock and a manually triggered
85
+ desktop reminder. Runtime exited with status 1; its journal is still required. Actual
86
+ login/reboot and complete Runtime recovery acceptance remain pending. macOS launchd support is pending.
87
+ Do not manually enable these user services on the shared rehearsal host while its operator
88
+ services use the same data/socket/port. No existing rehearsal service was changed.
89
+
90
+ The `startupChoice` field in local-services.json records the requested preference,
91
+ not proof that systemd enable/start succeeded. Use status to inspect actual services.
92
+ If setup reports automatic startup pending, current processes remain in place and
93
+ local keys/Policy/history remain unchanged; retry enable after correcting the problem.
94
+
95
+ Desktop environments without that systemd session integration may not show a reminder;
96
+ Wallet/Runtime still start through the user default target and locked-call guidance
97
+ remains available. No password is collected through the notification. The former
98
+ prototype desktop entry is not generated or automatically deleted by this version.
99
+
100
+ ## Uninstall
101
+
102
+ Run `./run uninstall` in an interactive terminal. It lists the selected local
103
+ installation and requires the exact phrase `DELETE LOCAL AGENTPAY DATA`.
104
+ Confirmation stops/removes its managed services and permanently deletes its local
105
+ Session Key, credentials, installed Skills, recovery history and installer settings.
106
+ It preserves the source repositories and tells you to delete User and Wallet folders
107
+ once cleanup succeeds. Other installations and unrelated startup files are preserved.
108
+ Unknown service definitions, active external listeners or unsafe paths block cleanup.
109
+
110
+ Uninstall does **not** revoke Safe authorization or cancel Orders. Resolve pending
111
+ Orders and revoke permission separately before retiring an installation. Reinstalling
112
+ cannot recover deleted keys or request history. Neither `stop` nor `autostart-off`
113
+ deletes data. Graphical password input is deferred; unlock remains a terminal command.
114
+
115
+ ## Private rehearsal networking
116
+
117
+ Current Anvil settings contain loopback RPC, Settlement and package URLs, and the
118
+ published reference package still uses a loopback Provider URL. A desktop using those
119
+ settings needs the arranged SSH tunnels. Existing nginx routes do not rewrite saved
120
+ configuration or package identities. Keep Anvil and local Wallet/Runtime private.
121
+ A production installation must use public HTTPS Market/Settlement/Provider URLs and
122
+ an appropriate chain RPC; SSH forwarding is not a normal user installation step.
123
+ Public settings/package handoff and production owner signing remain release work.
124
+
125
+ ## Startup self-check and historical Orders
126
+
127
+ Runtime starts its authenticated local listener before checking business history.
128
+ `./run status` shows process state, local inventory, Wallet availability and Order
129
+ check counts separately. A running process is not proof that a purchase is eligible.
130
+ The local `/status` endpoint requires the existing caller credential; `/health`
131
+ remains a minimal liveness endpoint.
132
+
133
+ The background task only reads Wallet status and original Settlement Orders. Locked
134
+ Wallets wait for unlock; unavailable services are retried with bounded backoff.
135
+ It does not create Orders, send payments, execute Provider work, confirm receipt or
136
+ cancel Orders. Existing Settlement workers retain their automatic refund duties.
137
+
138
+ Old invocation records stay unchanged. Known legacy requests cannot be replayed as
139
+ new purchases. Valid inventory permits unrelated requests through ordinary checks;
140
+ unreadable/missing/conflicting history or failed recovery-state writes pause new
141
+ paid calls without stopping the status listener. Missing caller authentication or
142
+ an occupied port still prevents unsafe startup.
143
+
144
+ Financial state and verified result availability are separate. A settled Order with
145
+ no verified local output is reported explicitly; Runtime will not re-execute that
146
+ settled service request to replace missing output. Unknown IDs, mismatched identities,
147
+ legacy output formats and unavailable original deployment access require review.
148
+ Do not delete history or add routing-version fields to bypass those protections.
149
+
150
+ Observations are saved privately beside `runtime/invocations.json` in
151
+ `runtime/invocations.json.recovery.json`; the original history, signed payloads and
152
+ result files are not migrated or erased. The observation file contains identifiers,
153
+ check times and conclusions, not private inputs, outputs or signatures. It is part
154
+ of the selected local data removed only by confirmed uninstall. Cached observations
155
+ are not a substitute for the Wallet/Settlement checks on each actual invocation.
156
+
157
+ The queue handles at most 4 records per pass, one read at a time. The IPC timeout allows Wallet's
158
+ 30-second HTTP deadline to finish before the next read. Passes wait about
159
+ 10–11 seconds after the previous pass; pending Orders are rechecked after 30 seconds, failed reads use
160
+ backoff up to five minutes, and terminal observations at most hourly. `./run status`
161
+ wakes a pass without bypassing per-Order backoff. Large inventories can take several
162
+ passes. All observed times are Unix milliseconds internally.
163
+
164
+ ### Reading status
165
+
166
+ `./run status` groups services, Orders and one suggested next command. A live Wallet
167
+ read takes precedence over an older background observation when describing lock state.
168
+ Green `[OK]`, yellow `[WAIT]` and red `[!]` distinguish normal, waiting and blocked
169
+ conditions in interactive terminals. Redirected output is plain text; `NO_COLOR` or
170
+ `TERM=dumb` also disables color. Labels remain readable without color.
171
+
172
+ Status layout wraps explanations for terminals of at least 40 columns, keeps service
173
+ columns aligned with or without color, and does not show zero Orders when inventory
174
+ is unavailable. A successful summary says local checks passed, not payment approved.
175
+
176
+ Login startup reports Enabled/Disabled only when systemd confirms that setting.
177
+ Not configured for this user means the corresponding user unit is absent; it does
178
+ not describe administrator-managed services. Could not check means the query did
179
+ not establish the setting. Temporary enablement and masking are shown separately.
180
+ Start/restart output confirms that systemd accepted a request, not that Runtime
181
+ finished self-check; use status next. Stop/off remain separate operations.
182
+
183
+ ### What to do next
184
+
185
+ | Status | Action |
186
+ | --- | --- |
187
+ | Runtime/Wallet stopped | Use the displayed start command, then check status. |
188
+ | Status unavailable | Inspect the indicated service log; do not reset history. |
189
+ | Locked | Run `./run wallet unlock`; background Order checks resume. |
190
+ | Permission missing | Run `./run setup`. An existing migration must follow its original update instructions instead. |
191
+ | Initial checks in progress | Leave services running; check after about 15 seconds. Large histories take longer. |
192
+ | Order check temporarily unavailable | Automatic backoff continues. If persistent, check network and Runtime logs. |
193
+ | Orders in progress | Keep services running and use the original Agent conversation. Only resume supported original requests with their original identifiers. |
194
+ | Identity/state/result conflict, unknown Order or missing Order ID | Preserve history; ask AgentPay support to review the Order/status. Do not share secrets or signed payloads. |
195
+ | Payment complete; local result unavailable | Check the original conversation, then ask the Provider using the Order ID. Repeated status checks cannot reconstruct the result; do not pay again to recover it. |
196
+ | Local checks passed | This check is finished. Normal checks still apply to each purchase. |
197
+
198
+ Mixed histories retain per-Order explanations; pending Orders continue automatic
199
+ checks even when another Order needs review. Background terminal-state rechecks
200
+ remain enabled; the guidance does not change recovery scheduling.
201
+
202
+ ## Missing startup settings
203
+
204
+ `./run service start` prepares missing user-service configuration for an initialized Wallet.
205
+ It reuses private User settings and asks for any missing endpoint in the terminal.
206
+ It never reads platform secret configuration or changes your Policy.
207
+ `./run market connect` uses the same preparation before rebuilding/restarting when
208
+ needed. Preparing services does not turn on login startup. Conflicting saved
209
+ addresses stop the flow for review; no new identity is generated.
210
+
211
+ An old system-level installation requires an operator handoff first; User does not
212
+ stop root services. Do not initialize another Wallet to fix process management.