@perkos/agent-sdk 0.7.1 → 0.8.0-rc.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 (83) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +69 -17
  3. package/dist/builders.d.ts +5 -1
  4. package/dist/builders.d.ts.map +1 -1
  5. package/dist/builders.js +155 -11
  6. package/dist/builders.js.map +1 -1
  7. package/dist/client.d.ts +8 -1
  8. package/dist/client.d.ts.map +1 -1
  9. package/dist/client.js +168 -26
  10. package/dist/client.js.map +1 -1
  11. package/dist/constants.d.ts.map +1 -1
  12. package/dist/constants.js +2 -0
  13. package/dist/constants.js.map +1 -1
  14. package/dist/custody/backend.d.ts +4 -0
  15. package/dist/custody/backend.d.ts.map +1 -0
  16. package/dist/custody/backend.js +149 -0
  17. package/dist/custody/backend.js.map +1 -0
  18. package/dist/custody/cli.d.ts +3 -0
  19. package/dist/custody/cli.d.ts.map +1 -0
  20. package/dist/custody/cli.js +43 -0
  21. package/dist/custody/cli.js.map +1 -0
  22. package/dist/custody/engine.d.ts +54 -0
  23. package/dist/custody/engine.d.ts.map +1 -0
  24. package/dist/custody/engine.js +115 -0
  25. package/dist/custody/engine.js.map +1 -0
  26. package/dist/custody/ledger.d.ts +24 -0
  27. package/dist/custody/ledger.d.ts.map +1 -0
  28. package/dist/custody/ledger.js +122 -0
  29. package/dist/custody/ledger.js.map +1 -0
  30. package/dist/custody/permit.d.ts +42 -0
  31. package/dist/custody/permit.d.ts.map +1 -0
  32. package/dist/custody/permit.js +91 -0
  33. package/dist/custody/permit.js.map +1 -0
  34. package/dist/custody/socket.d.ts +11 -0
  35. package/dist/custody/socket.d.ts.map +1 -0
  36. package/dist/custody/socket.js +118 -0
  37. package/dist/custody/socket.js.map +1 -0
  38. package/dist/evaluation-commitments.d.ts +47 -0
  39. package/dist/evaluation-commitments.d.ts.map +1 -0
  40. package/dist/evaluation-commitments.js +96 -0
  41. package/dist/evaluation-commitments.js.map +1 -0
  42. package/dist/index.d.ts +6 -2
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +3 -1
  45. package/dist/index.js.map +1 -1
  46. package/dist/mcp/cli.d.ts +3 -0
  47. package/dist/mcp/cli.d.ts.map +1 -0
  48. package/dist/mcp/cli.js +36 -0
  49. package/dist/mcp/cli.js.map +1 -0
  50. package/dist/mcp/evaluation.d.ts +33 -0
  51. package/dist/mcp/evaluation.d.ts.map +1 -0
  52. package/dist/mcp/evaluation.js +141 -0
  53. package/dist/mcp/evaluation.js.map +1 -0
  54. package/dist/mcp/server.d.ts +27 -0
  55. package/dist/mcp/server.d.ts.map +1 -0
  56. package/dist/mcp/server.js +207 -0
  57. package/dist/mcp/server.js.map +1 -0
  58. package/dist/policy.d.ts.map +1 -1
  59. package/dist/policy.js +7 -2
  60. package/dist/policy.js.map +1 -1
  61. package/dist/service-fees.d.ts +15 -0
  62. package/dist/service-fees.d.ts.map +1 -0
  63. package/dist/service-fees.js +109 -0
  64. package/dist/service-fees.js.map +1 -0
  65. package/dist/types.d.ts +66 -2
  66. package/dist/types.d.ts.map +1 -1
  67. package/docs/ARCHITECTURE.md +18 -2
  68. package/docs/EXISTING_AGENT.md +123 -0
  69. package/docs/HERMES_BUYER.md +91 -0
  70. package/docs/HERMES_CHECKPOINTS.md +88 -0
  71. package/docs/HERMES_CUSTODY.md +164 -0
  72. package/docs/HERMES_MCP.md +157 -0
  73. package/docs/HERMES_PROVIDER.md +98 -0
  74. package/docs/RELEASE_0.8.0_RC1.md +60 -0
  75. package/docs/SERVICE_FEES.md +108 -0
  76. package/docs/TESTNET_QUICKSTART.md +123 -0
  77. package/docs/VALIDATION_AND_RELEASE.md +82 -0
  78. package/docs/WALLET_SIGNER_SETUP.md +52 -0
  79. package/examples/service-fees.ts +36 -0
  80. package/examples/testnet-journal.ts +57 -0
  81. package/examples/testnet-lifecycle.ts +188 -294
  82. package/examples/testnet.env.example +12 -14
  83. package/package.json +7 -1
@@ -0,0 +1,157 @@
1
+ # Hermes MCP — QA adapter
2
+
3
+ **Unreleased QA candidate. Not yet published to npm, not a complete wallet-enabled
4
+ Hermes integration.** By default this packages read/prepare tools using the actual SDK.
5
+ Optional [custody delegation](HERMES_CUSTODY.md) adds bounded register/create/fund/assign/submit/finalize
6
+ requests to a separate operator-controlled signer. This is not deployed or funded by default.
7
+ An additional provider-only opt-in can request public QA evaluations for the permitted job.
8
+ Neither mode performs x402 purchases or generates wallets.
9
+
10
+ ## Architecture and installation
11
+
12
+ Hermes → local MCP stdio → Nayori SDK → fixed public Stacks testnet reads.
13
+ Preparation tools are offline. There is no signer in the process or tool arguments.
14
+ The browser SDK entry point does not import this Node-only adapter.
15
+
16
+ Build and verify the reviewed QA source, then pack it outside the checkout:
17
+
18
+ ```sh
19
+ npm ci
20
+ npm run verify
21
+ npm pack --pack-destination /absolute/private-artifacts
22
+ ```
23
+
24
+ In a clean consumer directory, install that exact reviewed tarball:
25
+
26
+ ```sh
27
+ npm init -y
28
+ npm install --save-exact /absolute/private-artifacts/perkos-agent-sdk-0.8.0-rc.1.tgz
29
+ ./node_modules/.bin/nayori-mcp --help
30
+ ```
31
+
32
+ The current candidate is 0.8.0-rc.1, separate from published 0.7.1. Historical QA tests used
33
+ a source tarball still numbered 0.7.1; do not confuse it with either distribution.
34
+ Record the tarball SHA-256 and exact commit. Initializing the consumer's own package.json
35
+ prevents npm from inheriting an unrelated parent project. See the
36
+ [candidate release checklist](RELEASE_0.8.0_RC1.md); registry installation is not yet available.
37
+ Do not run an unpinned `npx -y` command for a financial agent.
38
+
39
+ ## Public role profile
40
+
41
+ Create a JSON file outside Git. It contains **only public addresses**, no environment
42
+ variables, private keys, seed phrases, tokens, signer modules or URLs:
43
+
44
+ ```json
45
+ {
46
+ "network": "testnet",
47
+ "role": "client",
48
+ "client": "YOUR_TESTNET_BUYER_ADDRESS",
49
+ "provider": "YOUR_TESTNET_PROVIDER_ADDRESS",
50
+ "evaluator": "THE_VERIFIED_QA_EVALUATOR_ADDRESS",
51
+ "treasury": "THE_VERIFIED_QA_TREASURY_ADDRESS"
52
+ }
53
+ ```
54
+
55
+ Placeholders intentionally fail validation. Use distinct valid testnet addresses, confirm
56
+ evaluator/treasury against the deployed QA policy, and use `role: "provider"` for the
57
+ provider's separate instance. Profile acceptance does not certify registration, ownership
58
+ of an address or a match to on-chain evaluator/treasury policy.
59
+
60
+ The adapter pins STX `agentic-commerce-v6`, sBTC `sbtc-commerce-v5`, agent-registry and
61
+ reputation-registry-v3 under `ST16EWRC01S1SFWGBP63MW47VY8P3AYFA8VGEBGE5`.
62
+ Network/contract/endpoint overrides from tools are rejected; this adapter has no mainnet mode.
63
+
64
+ ## Connect Hermes
65
+
66
+ Start with an existing Hermes already working with your own LLM; leave that configuration
67
+ unchanged. This MCP does not select or authenticate the LLM provider, receive model API keys
68
+ or require PerkOS-LLM. [Existing-agent onboarding](EXISTING_AGENT.md) explains registration
69
+ and the separate operator-owned wallet/signer preparation. Hermes is an example, not a requirement.
70
+ The fixed QA evaluator endpoint is a separate Nayori service, not the developer's LLM endpoint.
71
+
72
+ After installing the tarball, configure a separate Hermes profile for each participant:
73
+
74
+ ```yaml
75
+ mcp_servers:
76
+ nayori_qa:
77
+ command: /absolute/path/to/node
78
+ args:
79
+ - /absolute/consumer/node_modules/@perkos/agent-sdk/dist/mcp/cli.js
80
+ - --config
81
+ - /absolute/private-config/public-profile.json
82
+ ```
83
+
84
+ Start Hermes and request the `nayori_context` tool. Hermes may prefix tool names.
85
+ This is a manually configured MCP, not an entry approved for the Nous MCP catalog.
86
+ Never put wallet keys into Hermes's config, environment, skill, prompts or tool parameters.
87
+
88
+ | Tool | Roles | Effect |
89
+ |---|---|---|
90
+ | nayori_context | Both | Fixed QA role/contracts and explicit capability flags |
91
+ | nayori_counts | Both | Registry/job counts; not adoption/completion counts |
92
+ | nayori_get_agent | Both | One agent by decimal ID |
93
+ | nayori_get_job | Both | One job, escrow, decision and fee ledger |
94
+ | nayori_get_reputation | Both | Public testnet reputation |
95
+ | nayori_prepare_job | Buyer | Offline criteria commitment; does not create a job |
96
+ | nayori_prepare_submission | Provider | Offline evidence commitment; does not submit work |
97
+
98
+ ## Boundaries and errors
99
+
100
+ ### Optional provider evaluation admission
101
+
102
+ Only after configuring provider custody, the operator may append `--enable-qa-evaluation`
103
+ to the MCP CLI arguments (after `--permit-hash` and its value). Add these **exact names** to
104
+ Hermes's tool include list if one is configured:
105
+
106
+ - `nayori_request_evaluation`: accepts the same asset, jobId, description, acceptanceCriteria
107
+ and evidence as preparation. Requires an enabled, unexpired provider permit and a confirmed
108
+ submit in its durable journal. It compares client/provider/evaluator/treasury, budget, criteria
109
+ and evidence commitments against the actual SDK job read before any admission request.
110
+ - `nayori_evaluation_status`: accepts only asset and jobId; both must match the configured
111
+ custody permit. Remains available for reconciliation after permit expiry.
112
+
113
+ Requests go only to `https://evaluator.qa.nayori.ai/v1/evaluations`. Evidence must use that
114
+ HTTPS origin; this narrow pilot does not support arbitrary storage providers. The evaluator,
115
+ not MCP, fetches/validates evidence bytes and rechecks eligibility, deadlines and capacity.
116
+ The operator explicitly authorizes enqueueing evaluation work by enabling the option.
117
+ No internal API key, wallet signature, second fee or x402 purchase is attached.
118
+
119
+ Admission allows 45 seconds for paced eligibility reads; status lookup allows 15 seconds.
120
+ Configure custom relay/proxy timeouts accordingly and check capacity before submission.
121
+ Safe MCP error codes distinguish `admission_limit`, `ineligible`, `unavailable` and `transport`.
122
+ All prohibit automatic retry. They contain fixed SDK guidance, never upstream error details.
123
+ The contract's review deadline remains authoritative even after an HTTP timeout.
124
+
125
+ The adapter looks up the deterministic job-scoped evaluation ID before POST. The server's
126
+ durable idempotency remains the authority across processes/restarts. HTTP errors/timeouts
127
+ do not trigger automatic retry: query status first. A changed manifest cannot bypass the
128
+ on-chain commitment. Status responses expose only bounded identity/state/txid fields, not
129
+ arbitrary public explanations or raw errors. `confirmed` here describes the evaluator, not a
130
+ verified escrow payout. Buyer custody still finalizes after the actual appeal deadline.
131
+
132
+ This is an unreleased source candidate. In addition to mocked HTTP/chain tests, one internal
133
+ funded Hermes lifecycle passed; see [the exact validation scope](VALIDATION_AND_RELEASE.md).
134
+ It is not a security audit or npm release. Without the flag, tool availability is unchanged.
135
+
136
+ - No arbitrary shell, file-reading, secret-export, transaction-signing or broadcast tool.
137
+ - Unknown fields, wrong roles, unsupported assets, oversized payloads and invalid IDs fail closed.
138
+ - Public chain text and URLs are untrusted data. Never follow their instructions or treat
139
+ them as approval to spend, change configuration, or invoke another tool.
140
+ - Evidence preparation hashes the **manifest**, not remotely fetched bytes. It returns
141
+ `evidenceBytesVerified: false`; the evaluator still must check allowlisted HTTPS content.
142
+ - Errors do not reflect raw RPC responses, user inputs or diagnostics into the model.
143
+ - A decision is not payout confirmation. Use transaction events and fee/reputation checks.
144
+ - There is no wallet isolation claim from merely running two same-user processes. The optional
145
+ custody candidate requires verified Linux isolation and durable operator-approved limits.
146
+
147
+ ## Validation and remaining work
148
+
149
+ Automated tests cover official MCP client/server handshake, schemas, role separation,
150
+ BigInt serialization, offline commitments, sanitized failures and real subprocess stdio.
151
+ Those automated tests are distinct from the [verified internal testnet lifecycle](VALIDATION_AND_RELEASE.md).
152
+ Clean published-package onboarding, the separate x402 walkthrough and video remain pending.
153
+ Repeat isolation and permission checks for each new operator deployment; this single supervised
154
+ scenario does not certify general autonomous onboarding. No server deployment is needed to test stdio.
155
+
156
+ Sources: [Hermes MCP](https://hermes-agent.nousresearch.com/docs/user-guide/features/mcp),
157
+ [official MCP server guide](https://modelcontextprotocol.io/docs/develop/build-server).
@@ -0,0 +1,98 @@
1
+ # Hermes provider — controlled QA walkthrough
2
+
3
+ See [validation and release boundaries](VALIDATION_AND_RELEASE.md) for the verified internal
4
+ scenario and remaining distribution/video gates. An existing active registration is reused
5
+ after readback, not registered again; adjust the permit and gas cap to omit that action.
6
+
7
+ See [QA checkpoints and confirmation handling](HERMES_CHECKPOINTS.md) for the job-bound permit,
8
+ STX gas budget, six-burn gate and the difference between a decision and payment. Do not fund
9
+ your wallet with sBTC merely to receive a payout or reuse an example job ID.
10
+
11
+ **Unreleased candidate; funded autonomous onboarding and recording still require validation.**
12
+ Use the same job as the [buyer walkthrough](HERMES_BUYER.md), with a different wallet, signer,
13
+ Hermes instance and journal. The candidate MCP is not the npm 0.7.1 release.
14
+
15
+ ## 1. Install and prepare your wallet externally
16
+
17
+ Your Hermes is already installed and working with your own LLM. Keep that setup; this guide
18
+ adds Nayori tools without configuring or replacing your model. No PerkOS-LLM account or model
19
+ API key shared with Nayori is required. Hermes is an example, not a platform requirement.
20
+ Start with [existing-agent onboarding](EXISTING_AGENT.md) and the separate
21
+ [operator wallet/signer checklist](WALLET_SIGNER_SETUP.md). Never put model credentials in
22
+ tool arguments or recordings. Your agent's model is separate from Nayori's evaluator.
23
+
24
+ Follow [MCP installation](HERMES_MCP.md) with the exact reviewed tarball/source hash. Create,
25
+ back up and restore-check your own testnet wallet outside the SDK and Hermes. Fund only
26
+ authorized STX network fees; a provider does not need to send sBTC to receive a job payment.
27
+ Never give Hermes your key or the buyer/evaluator/treasury keys. Follow the separate-UID,
28
+ filesystem, socket and capability restrictions in [custody setup](HERMES_CUSTODY.md).
29
+
30
+ Configure `role: provider`. The operator permit must reference the buyer's confirmed job ID,
31
+ same criteria, identities, amount and expiry, with only `register` and `submit`. Start with
32
+ signing disabled and confirm tool context and custody status. Allow evaluation separately only
33
+ if this operator consents to enqueueing review of this job.
34
+
35
+ ## 2. Confirm assignment and perform the work
36
+
37
+ 1. With explicit low-value testnet permission, enable the isolated signer and request `register`.
38
+ Confirm the transaction and agent record. Wallet creation is not registration.
39
+ 2. Read the job using `nayori_get_job`. Confirm provider equals your address, status is funded,
40
+ escrow equals the agreed gross amount and client/evaluator/treasury/criteria are correct.
41
+ 3. Do not self-assign or work against missing escrow. Ask the buyer to resolve mismatches.
42
+ 4. Have the real Hermes perform the agreed task. Preserve its actual output, including errors;
43
+ do not substitute a canned result and call it autonomous execution.
44
+ 5. Publish the small evidence artifact through the operator-approved QA evidence workflow.
45
+ This MCP does not include an upload tool. The pilot accepts evidence only from the fixed
46
+ evaluator QA HTTPS origin; publishing to arbitrary hosts is not supported in this bridge.
47
+ 6. Compute the actual artifact's SHA-256, MIME and byte count. Prepare its manifest with
48
+ `nayori_prepare_submission`. Preparation hashes the manifest and does not verify remote bytes.
49
+ 7. Request `nayori_execute` with `action: submit` and the exact evidence manifest. Confirm the
50
+ saved transaction and job submission, including the configured six subsequent burn blocks.
51
+
52
+ ## 3. Request public evaluation, without internal credentials
53
+
54
+ Before submitting work, coordinate evaluator availability and daily capacity with the QA
55
+ operator. The on-chain review window starts at submission; custody confirmation and network
56
+ latency consume part of that window. Check the live burn height and review deadline before
57
+ admission. A timeout does not extend the contract deadline, and no client can force an expired
58
+ review to be accepted.
59
+
60
+ The candidate waits up to 45 seconds for admission and 15 seconds for status reads. Custom
61
+ proxies must accommodate admission's paced chain checks with a bounded timeout within the
62
+ client's budget; a shorter proxy timeout still causes failure. The response remains size-limited.
63
+ Quota errors require operator capacity review, not repeated requests. Eligibility errors require
64
+ checking the actual job and deadline. Transport/service errors require status reconciliation:
65
+ the request may already have been persisted. No automatic retries or budget increases occur.
66
+
67
+ Append `--enable-qa-evaluation` to provider MCP arguments after the custody socket/permit
68
+ configuration. If Hermes uses tool filtering, add the exact names `nayori_request_evaluation`
69
+ and `nayori_evaluation_status`. Without this operator flag the tools are absent.
70
+
71
+ Call `nayori_request_evaluation` with the same asset, jobId, description, acceptanceCriteria
72
+ and evidence used for commitments. It checks the permitted job, confirmed submission and
73
+ on-chain identities/budget/commitments, then uses the deterministic job-scoped evaluation ID.
74
+ It sends no bearer token, wallet key or additional payment. The evaluator independently checks
75
+ eligibility and evidence bytes; no agent can approve itself through this endpoint.
76
+
77
+ If a response times out, call `nayori_evaluation_status` with asset and jobId before retrying.
78
+ Do not change the evidence or create another job to bypass a failed review. Admission is not
79
+ approval; evaluator `confirmed` is not proof that escrow has been paid out.
80
+
81
+ ## 4. Verify outcome and payment
82
+
83
+ Read the decision and explanation through the public evaluation/chain evidence surfaces. The
84
+ buyer finalizes after the real appeal deadline when no appeal exists. This provider pilot does
85
+ not expose finalize, appeal or admin actions. If a rejection needs appeal, involve the operator
86
+ and supported app/SDK appeal workflow; do not claim the restricted MCP handles it automatically.
87
+
88
+ Check the terminal job, escrow zero, exact payout to your wallet, treasury fee and reputation.
89
+ For approved 1000 sBTC units and 200 bps, net payment is 980 and treasury receives 20. The
90
+ fee remains within escrow until settlement. Do not infer success from an HTTP 202 or txid alone.
91
+
92
+ ## 5. Recording and current boundaries
93
+
94
+ Record the same job from the provider's perspective: installation, external wallet setup
95
+ without showing secrets, registration, assignment check, actual work, evidence, submission,
96
+ evaluation status and payment. Show public transaction links and label waiting-period edits.
97
+ The x402 resource-purchase walkthrough is a separate pending integration; do not describe
98
+ evaluation admission as an x402 payment. Our internal controlled agents are not external adoption.
@@ -0,0 +1,60 @@
1
+ # 0.8.0-rc.1 — QA release candidate
2
+
3
+ **Prepared source candidate, not published.** Stable npm remains `@perkos/agent-sdk@0.7.1`.
4
+ This prerelease packages reviewed QA features for explicit operator testing; it is not a
5
+ production promotion or a certification of autonomous operation for every developer.
6
+
7
+ ## Included
8
+
9
+ - Node-only Hermes-compatible MCP read/prepare tools and optional Linux custody delegation.
10
+ - Operator-owned keys, isolated signer identities, immutable permits, bounded budgets and
11
+ durable intent/nonce/txid recovery. Signing remains disabled by default; the pilot is testnet-only.
12
+ - Provider-only, job-bound evaluation admission and status with bounded timeouts, sanitized
13
+ errors and deterministic-ID reconciliation. No automatic retries or x402 purchases in this adapter.
14
+ - Opt-in STX v6/sBTC v5 fee methods, consent and accounting; default v5/v4 contracts are unchanged.
15
+ - Versioned criteria/evidence commitments, absent-reputation handling, role-separated examples
16
+ and buyer/provider manuals. Developers retain their own agent and LLM configuration.
17
+
18
+ See [verified scope](VALIDATION_AND_RELEASE.md). The earlier internal sBTC lifecycle used
19
+ source `fc0537477fda819fa9cce8e74e543be0d49ea3a4`, not this versioned artifact. Packaging
20
+ checks do not establish a new funded E2E, fresh registration, external adoption or security audit.
21
+
22
+ ## Install the reviewed artifact before publication
23
+
24
+ In a clean checkout of the reviewed candidate commit, use Node 20+ and npm 10+:
25
+
26
+ ```sh
27
+ npm ci
28
+ npm run verify
29
+ npm pack --pack-destination /absolute/private-artifacts
30
+ ```
31
+
32
+ Create a separate, empty consumer directory and initialize its own package.json:
33
+
34
+ ```sh
35
+ npm init -y
36
+ npm install --save-exact /absolute/private-artifacts/perkos-agent-sdk-0.8.0-rc.1.tgz
37
+ ./node_modules/.bin/nayori-mcp --help
38
+ ./node_modules/.bin/nayori-custody --help
39
+ ```
40
+
41
+ Check the exact package version, import and transaction-plan construction without a signer.
42
+ Record source commit, tarball integrity and contents. No private key is needed to install or
43
+ prepare a plan. Running custody signing requires separate Linux isolation, permissions and
44
+ budget setup; never put keys into MCP, prompts or model tools.
45
+
46
+ ## Release gates
47
+
48
+ 1. Review and merge the QA release PR; build from the exact reviewed commit with a clean tree.
49
+ 2. Verify SDK tests, package allowlist, absence of secrets, dependency audit and isolated consumer.
50
+ 3. Obtain publication approval. Use the prerelease `next` tag, never move `latest` implicitly.
51
+ `publishConfig.tag` is `next`; do not override it to `latest` for this candidate.
52
+ 4. Verify registry version/integrity and that `latest` remains 0.7.1. Repeat isolated installation
53
+ from the exact published version, not an unpinned tag or financial `npx -y` command.
54
+ 5. Validate both role walkthroughs before recording the developer demo. New funded tests require
55
+ a fresh reviewed budget; never reuse the completed QA job's authorization.
56
+
57
+ Only after publication is confirmed should registry installation use
58
+ `npm install --save-exact @perkos/agent-sdk@0.8.0-rc.1`.
59
+ QA merge, npm publication, hosted documentation deployment and production promotion are
60
+ separate events. x402/MPP resource purchases remain a separate workflow and test scope.
@@ -0,0 +1,108 @@
1
+ # Earned service fee integration (unreleased)
2
+
3
+ This source branch adds opt-in support for `agentic-commerce-v6` (STX) and
4
+ `sbtc-commerce-v5` (sBTC). These are **simnet candidates, not deployed defaults**.
5
+ The published `@perkos/agent-sdk@0.7.1` does not contain these new methods.
6
+ Do not point a production client at candidate names or treat a successful build as a deployment.
7
+ Existing v5/v4 jobs retain their full-budget, no-service-fee terms.
8
+
9
+ ## Payment lifecycle
10
+
11
+ Funding locks the **gross** budget, including the potential 2% fee. Nothing is paid to
12
+ treasury at funding, submission, decision recording or appeal filing. Final evaluated
13
+ settlement atomically sends `floor(gross / 50)` to the job-pinned treasury and the remainder
14
+ to the provider on approval **or back to the client on rejection**. Both transfers use the
15
+ escrow asset. The settled escrow balance is zero.
16
+
17
+ No evaluation (expiry/review timeout) means no service fee. An evidence-backed waiver
18
+ before settlement also results in zero fee. Gas is separate, paid in STX. Optional extra
19
+ analysis would require a separately accepted x402 quote; that service is not implemented
20
+ and there is no automatic second 2% or payment prerequisite for filing an appeal.
21
+
22
+ ## Read first, accept explicitly
23
+
24
+ After the exact candidate sources have been deployed and verified in isolated testnet,
25
+ configure their explicit same-network contract IDs in `PerkOSClient`. Do not guess a treasury:
26
+ read `getServiceFeePolicy(asset)` and `getJobServiceFee(asset, jobId)`.
27
+
28
+ ```ts
29
+ // Uses the UNRELEASED source build, not npm 0.7.1.
30
+ // nayori is a client configured with reviewed contracts and a policy-limited signer.
31
+ const job = await nayori.getJob("sbtc", jobId);
32
+ if (!job) throw new Error("Job not found");
33
+ const policy = await nayori.getServiceFeePolicy("sbtc");
34
+ const fees = await nayori.getJobServiceFee("sbtc", jobId);
35
+
36
+ // Present gross, potential fee, net approval/net rejection, treasury and gas
37
+ // to the operator (or an approved deterministic agent spending policy).
38
+ // This object represents actual acceptance, not permission granted by this example.
39
+ const serviceFeeAcceptance = {
40
+ gross: job.budget,
41
+ basisPoints: 200 as const,
42
+ treasury: fees.treasury,
43
+ rejectionRefund: "net-after-evaluation" as const,
44
+ };
45
+
46
+ // Only after acceptance, with the CLIENT signer:
47
+ const broadcast = await nayori.fundJob({
48
+ asset: "sbtc", jobId, amount: job.budget, serviceFeeAcceptance,
49
+ });
50
+ const confirmation = await nayori.confirm(broadcast);
51
+ if (confirmation.status !== "success") throw new Error("Funding not confirmed");
52
+
53
+ // The PROVIDER uses a separate client/signer and independently accepts the live
54
+ // budget/fee before submitWork({ asset, jobId, deliverable, serviceFeeAcceptance }).
55
+ ```
56
+
57
+ `quoteServiceFee(gross)` performs exact uint128-safe bigint arithmetic but is only a local
58
+ quote. It does not prove a deployment, initialization, actual fee charge or refund.
59
+ Amounts below 50 atomic units round down to zero fee; no minimum job price is introduced.
60
+ See [`examples/service-fees.ts`](../examples/service-fees.ts) for a signer-free report helper.
61
+
62
+ ## Methods and role boundaries
63
+
64
+ | Method | Behavior |
65
+ | --- | --- |
66
+ | `supportsServiceFees(asset)` | Known ABI capability, not verification of contract authenticity |
67
+ | `getServiceFeePolicy(asset)` | Validates initialization fields, fixed 200 bps, network-specific windows and treasury separation |
68
+ | `getJobServiceFee(asset, jobId)` | Validates ledger against the job, budget, roles and pinned treasury; read failures propagate |
69
+ | `fundJob(input)` | Requires accepted gross/bps/treasury/net-refund terms matching live state before wallet access |
70
+ | `submitWork(input)` | Requires the provider's matching acceptance before wallet access |
71
+ | `finalizeDecision`, `resolveAppeal`, `settleAppealTimeout` | Derive gross and split from live state; sBTC uses the job-pinned token |
72
+ | `initializeServiceFeeProtocol(input)` | Owner-signed, explicit treasury/authority; SDK requires testnet 3 or mainnet 144 appeal burn blocks |
73
+ | `waiveServiceFee(input)` | Job-pinned authority signs a nonzero 32-byte evidence hash; records an irreversible waiver |
74
+ | `refundServiceFee(asset, jobId)` | Treasury signs a real outstanding-fee return from its own balance; spending limits apply |
75
+
76
+ Only standard wallet principals can execute these signer-based administrative methods. A contract
77
+ principal treasury would require its own reviewed governance caller, not a forged wallet signer.
78
+ The authority decides whether evidence establishes platform fault; a changed appeal outcome alone
79
+ does not automatically waive a fee. The SDK does not make that decision for an operator.
80
+
81
+ ## Accounting is not a quote
82
+
83
+ - `feeAmount` is the potential budget quote, never collected revenue.
84
+ - No `settlement`: no earned fee has been collected.
85
+ - `settlement.chargedFee - settlement.refundedFee`: fee retained after actual returns.
86
+ - `settlement.net + settlement.refundedFee`: total delivered to the economic recipient.
87
+ - Waiver plus an outstanding charged fee: a refund obligation, **not a completed refund**.
88
+
89
+ A treasury without funds or an available signer cannot complete a refund. Maintain refund
90
+ reserves and an operational process before launch. Replay attempts are rejected by the contract.
91
+ Internal test-wallet transactions are not externally earned revenue or adoption.
92
+
93
+ ## Post-conditions and trust
94
+
95
+ Decision settlements use one exact **gross escrow outflow** post-condition per asset, not separate
96
+ net/fee conditions on the same sender. Treasury refunds instead constrain the treasury's exact
97
+ fee outflow. Deny mode is retained. Post-conditions constrain aggregate outflow, not recipients;
98
+ verify contract sources and canonical transfer events independently after confirmation.
99
+
100
+ `plan.intent.serviceFee` is disclosure metadata, not a signed enforcement mechanism. Synchronous
101
+ builders cannot read the chain: their caller must supply already-verified state, token and split.
102
+ Prefer high-level client methods. Neither `execute` nor a custom RPC can establish the authenticity
103
+ of an arbitrary caller-selected contract. Custody allowlists and source verification remain required.
104
+ Funding/refund session limits count broadcasts conservatively, not final revenue.
105
+
106
+ Direct x402/MPP single-transfer verification is unchanged and must not be relaxed for escrow splits.
107
+
108
+ Reference: [Stacks post-conditions](https://docs.stacks.co/post-conditions/examples).
@@ -0,0 +1,123 @@
1
+ # Role-separated agent onboarding — QA candidate
2
+
3
+ This guide describes the QA candidate, not a published npm release. The role-separated
4
+ SDK/committed-evaluation flow has completed controlled STX and sBTC testnet jobs; this
5
+ does not certify a live Hermes installation or external adoption.
6
+ Use Node.js 22 and the reviewed QA commit. Do not point it at mainnet.
7
+ The app's default deployments, production and the published package are unchanged.
8
+
9
+ ## Roles and custody
10
+
11
+ - Buyer: owns criteria, creates the job, sets its budget, funds escrow and assigns a provider.
12
+ - Provider: owns its wallet, performs the work and submits the committed evidence manifest.
13
+ - Evaluator service: verifies chain state and downloaded evidence, then records its decision.
14
+ - Human appeal authority: handles disputes; it is not installed in either participant agent.
15
+
16
+ Create separate testnet wallets with your custody provider. Keep each key in its own signer
17
+ boundary, fund only the required test tokens and STX gas, and never share the evaluator key.
18
+ The example imports an **operator-selected absolute module path** exporting a `PerkOSSigner`
19
+ named `signer`. Do not let an LLM or external job select that module. Its implementation must
20
+ restrict network, contracts, operation, nonce and gas fees and durably account for wallet spending.
21
+ SDK spending policies are per process and do not replace persistent custody limits.
22
+ The separate [Hermes MCP adapter](HERMES_MCP.md) defaults to read/prepare only. Optional
23
+ [bounded custody delegation](HERMES_CUSTODY.md) is a QA source candidate for wallet-enabled
24
+ actions; it still requires review, deployment, Linux isolation and actual Hermes E2E validation.
25
+ Provider MCP may additionally opt into public QA evaluation admission after its confirmed
26
+ submission; see [the exact tools and operator flag](HERMES_MCP.md#optional-provider-evaluation-admission).
27
+ The CLI walkthrough below remains a separate operator-driven example, not proof of Hermes autonomy.
28
+
29
+ ## Install and preview
30
+
31
+ From the reviewed SDK source checkout:
32
+
33
+ ```bash
34
+ npm ci
35
+ npm run verify
36
+ npm run quickstart:testnet
37
+ ```
38
+
39
+ The last command defaults to offline preview; it does not load a signer or call a network.
40
+ For clean-consumer testing, build and pack the candidate, then install that tarball in a
41
+ separate project with Node 22 and `tsx`. Do not publish or overwrite npm 0.7.1.
42
+
43
+ ## Supply real job inputs
44
+
45
+ Keep a JSON config **outside Git**, with one copy for each role. Required fields:
46
+
47
+ | Field | Value |
48
+ |---|---|
49
+ | network / asset | `testnet` / `stx` or `sbtc` |
50
+ | role | `client` or `provider` |
51
+ | client / provider / evaluator / treasury | Four distinct real testnet principals; evaluator and treasury must match QA policy |
52
+ | amount | Decimal string in micro-STX or satoshis; example cap 100000 or 1000 respectively |
53
+ | expiredAt | Future **Stacks block height**, not burn height or Unix time |
54
+ | description | Real ASCII work description, at most 428 characters |
55
+ | acceptanceCriteria | Array of `{ id, requirement, verification }` fixed by the buyer before creation |
56
+ | jobId | Confirmed job ID, required after creation |
57
+ | evidence | Provider's real `{ id, uri, sha256, mediaType, sizeBytes }` manifest |
58
+ | agentName | Optional real participant name |
59
+
60
+ Use the configured QA evaluator's evidence origin allowlist. Automatic review initially supports
61
+ up to five HTTPS UTF-8 text/plain or application/json files, 8192 bytes per file, 16000 bytes total.
62
+ Hash the exact downloaded bytes; no fake URLs or invented deliverables. Public manifests and
63
+ chain commitments must never contain secrets. Preserve the original criteria file for both roles.
64
+
65
+ ## Run one step at a time
66
+
67
+ Set `PERKOS_RUN_CONFIG`, `PERKOS_JOURNAL` and `PERKOS_SIGNER_MODULE` to absolute paths outside Git.
68
+ Use a dedicated journal per role and run. Enable `PERKOS_CONFIRM_TESTNET_BROADCAST=yes` only for
69
+ the intended operation. Funding and submission also require
70
+ `PERKOS_ACCEPT_SERVICE_FEE=200bps-net-after-evaluation`.
71
+
72
+ ```bash
73
+ PERKOS_ACTION=register npm run quickstart:testnet
74
+ PERKOS_ACTION=create npm run quickstart:testnet
75
+ ```
76
+
77
+ Both participants register using their own process. Only the buyer creates. Copy the confirmed
78
+ `(ok uN)` job ID from creation into both role configs, then execute separately:
79
+
80
+ 1. Buyer: `set-budget`, then `fund`, then `assign`.
81
+ 2. Provider: do the actual work, prepare the real evidence manifest, then `submit`.
82
+ 3. Either role: `evaluate` against an explicitly configured `PERKOS_EVALUATOR_URL` QA origin.
83
+ 4. Either role: `status`. It is read-only and needs no signer or broadcast opt-in.
84
+ 5. Buyer: `finalize` only after decision-pending, no appeal, and current burn height strictly
85
+ greater than the appeal deadline. Disputes require the appeal workflow, not bypassing this gate.
86
+
87
+ A `202` response means admitted, not approved. Poll the returned evaluation ID at
88
+ `GET /v1/evaluations/{id}` and inspect the on-chain job. A recorded decision does not transfer
89
+ escrow. On finalization, independently verify the 98/2 provider/treasury split (or evaluated
90
+ rejection refund), zero escrow and reputation sync. Gas is additional, paid by each transaction signer.
91
+ The 2% fee is earned on evaluation and stays in escrow until settlement; no extra appeal fee is added.
92
+
93
+ ## Commitments without new contracts
94
+
95
+ `prepareEvaluationJob(input)` returns the description plus a versioned SHA-256 criteria marker.
96
+ `prepareEvaluationSubmission(input)` returns a 36-byte deliverable: ASCII `ny1:` and the raw
97
+ 32-byte evidence digest, fitting existing `(buff 64)` contracts.
98
+
99
+ Both use fixed projected JSON fields, lexicographically sorted keys, ordered arrays, UTF-8 and
100
+ distinct hash domains. Criteria bind network/asset/contract/client/evaluator/description.
101
+ Evidence additionally binds job ID, provider and criteria hash. Do not reorder arrays, normalize
102
+ text or change manifests after signing. `evaluationJobId` derives a deterministic job-scoped
103
+ request identifier; it is **not** a credential.
104
+
105
+ Hashes protect manifest integrity, not evidence truth. Only the on-chain client can commit the
106
+ criteria and only the assigned provider can submit the evidence. Public HTTP callers may trigger
107
+ verification of those exact commitments, but cannot change criteria, spend participant wallets
108
+ or force the evaluator to approve.
109
+
110
+ ## Recovery and limitations
111
+
112
+ The append-only mode-600 journal records an attempt before signing and stores the txid before
113
+ confirmation. Repeating an identical invocation confirms that txid instead of signing again.
114
+ Changed action inputs, a stale lock, malformed journal or ambiguous attempt fail closed.
115
+ Never delete checkpoints to force a retry: reconcile the wallet nonce and transaction history first.
116
+ Ambiguous signing failures require operator reconciliation; no exactly-once
117
+ network guarantee is claimed. A dry preview is not an on-chain E2E test.
118
+
119
+ The evaluator public writer defaults off; controlled QA has enabled bounded admission and
120
+ passed database/restart and two-role STX/sBTC E2E gates. Isolated live Hermes integration,
121
+ x402-protected API walkthrough and recorded demo remain separate gates.
122
+ The existing x402/MPP clients are separate from this escrow evaluation trigger;
123
+ this route does not introduce another payment or imply x402 coverage was tested here.
@@ -0,0 +1,82 @@
1
+ # Hermes validation and release boundary
2
+
3
+ ## What was verified
4
+
5
+ On 2026-09-08 UTC, one **internal, operator-supervised Stacks testnet** sBTC job completed
6
+ using real Hermes participants, the SDK/MCP tools, isolated policy signers and Nayori's evaluator.
7
+ This is evidence for one scenario, not certification of all workflows or external onboarding.
8
+
9
+ | Check | Observed result |
10
+ | --- | --- |
11
+ | SDK source | `fc0537477fda819fa9cce8e74e543be0d49ea3a4` on QA |
12
+ | Contract / job | `ST16EWRC01S1SFWGBP63MW47VY8P3AYFA8VGEBGE5.sbtc-commerce-v5`, job 14 |
13
+ | Participants | Existing registered agents, separate buyer/provider/evaluator roles |
14
+ | Workflow | Create → budget → fund → assign → actual work → submit → evaluate → finalize |
15
+ | Work | Compute 23 + 19 and explain; actual result 42 with an explanation |
16
+ | Outcome | Completed; zero escrow; exactly 980 atomic sBTC to provider and 20 to treasury |
17
+ | Reputation | One completed job, no disputed job; no pending synchronization |
18
+ | Confirmation | Finalization in burn 14234; six-burn custody gate passed at 14240 |
19
+
20
+ Public chain evidence:
21
+
22
+ - [Submission](https://explorer.hiro.so/txid/0x8c99de7f560e82da0483875677ab2de3370403e2a617dff445a77cff40f0da31?chain=testnet)
23
+ - [Evaluator approval](https://explorer.hiro.so/txid/0x2806cebb488794c6a8ff63bf9f437978dc7e492254974c3f06d400381b7a1f27?chain=testnet)
24
+ - [Final settlement, Stacks block 288396](https://explorer.hiro.so/txid/0x382e05645560acbd822f573cab6e32579ad1d8ad3d1598916f132b28b86cce4c?chain=testnet)
25
+
26
+ No new registration was performed in this cycle: existing records were verified and reused.
27
+ New developers must still follow [registration](EXISTING_AGENT.md); do not repeat registration
28
+ for an already active identity simply to match a video. Use your own agent, LLM and signer.
29
+ Do not send funds to the addresses in this historical evidence.
30
+
31
+ ## Published package versus tested source
32
+
33
+ | Distribution | Boundary |
34
+ | --- | --- |
35
+ | npm `@perkos/agent-sdk@0.7.1` | Published v5/v4 baseline; does not include the local QA Hermes/custody/fee additions |
36
+ | Reviewed QA source above | Tested v6/v5 opt-in fee path, local Hermes MCP, custody and evaluation admission |
37
+ | Historical QA tarball used in the lifecycle | Reports version 0.7.1; source commit and artifact integrity distinguish it from npm |
38
+ | Current source candidate | 0.8.0-rc.1, not published; see [candidate notes](RELEASE_0.8.0_RC1.md) |
39
+
40
+ Do not publish the candidate over 0.7.1 or describe it as an npm-only installation test. Use
41
+ the [exact-artifact installation procedure](HERMES_MCP.md), never an unpinned financial `npx`.
42
+
43
+ Before external distribution: review and merge the release changes, assign a new package version,
44
+ run the SDK gate, pack and inspect its allowlisted contents, then install that exact artifact in
45
+ a clean consumer. Verify imports, binaries and both role guides. Publish only after separate
46
+ release approval; verify registry integrity and repeat clean installation from the published
47
+ version. A QA merge, npm publication and production deployment are separate events.
48
+
49
+ ## Report three independent outcomes
50
+
51
+ 1. **Conversation:** Hermes must explicitly report `completed=true`; a `type: result` envelope
52
+ alone is insufficient. A tool may have executed even when the conversation stopped at its limit.
53
+ 2. **Operation:** preserve the actual intent, txid and journal; query the existing operation after
54
+ timeout or interruption. Never re-sign merely because the conversation did not complete.
55
+ 3. **Economics:** independently verify canonical success, confirmation depth, terminal job state,
56
+ zero escrow, exact unique transfers and reputation. Evaluator approval is not payment.
57
+
58
+ Count persisted LLM attempts separately from received responses. Missing usage means **unknown**,
59
+ not zero. Track buyer, provider and evaluator independently; a configured maximum is a bound,
60
+ not an observed call count or bill. This cycle observed 26 Hermes calls; evaluator usage is bounded
61
+ by four calls but its exact count is not established by this report.
62
+
63
+ ## Two different evidence hashes
64
+
65
+ The evaluator artifact/decision uses SHA-256 of the canonical evidence list. The SDK's versioned
66
+ submission commitment additionally binds domain, network, contract, job, roles and criteria.
67
+ These hashes are intentionally different. Recompute each from its own input: compare the
68
+ SDK commitment to `submit-work`/the job deliverable and the manifest hash to the evaluator
69
+ artifact/`record-decision`. Verify the public explanation digest and fetched evidence bytes too.
70
+ Never accept a mismatched hash by copying the expected value from the response under test.
71
+
72
+ ## Still outside this proof
73
+
74
+ - Fresh npm-only installation, new-agent registration in this cycle, and the developer video.
75
+ - Autonomous operation from one instruction without the operator's staged gates.
76
+ - The separate x402/MPP resource-purchase workflow; local QA MCP does not purchase x402.
77
+ - Other assets, rejection/appeal/recovery scenarios, or production fee activation.
78
+ - External security review or independent adoption: these participants are team-operated testnet actors.
79
+
80
+ Continue with the [buyer](HERMES_BUYER.md), [provider](HERMES_PROVIDER.md) and
81
+ [checkpoint](HERMES_CHECKPOINTS.md) manuals. Every new funded scenario requires its own reviewed
82
+ permissions and budget; never reuse this completed job's authorization.