@wowok/skills 1.2.3 → 1.2.5

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 (53) hide show
  1. package/README.md +34 -16
  2. package/dist/cli.js +6 -2
  3. package/dist/cli.js.map +1 -1
  4. package/dist/skills.d.ts +32 -1
  5. package/dist/skills.d.ts.map +1 -1
  6. package/dist/skills.js +63 -0
  7. package/dist/skills.js.map +1 -1
  8. package/dist/types.d.ts +8 -0
  9. package/dist/types.d.ts.map +1 -1
  10. package/examples/Insurance/Insurance.md +543 -475
  11. package/examples/MyShop/MyShop.md +865 -746
  12. package/examples/MyShop_Advanced/MyShop_Advanced.md +1520 -1376
  13. package/examples/ThreeBody_Signature/ThreeBody_Signature.md +891 -651
  14. package/examples/Travel/Travel.md +952 -848
  15. package/package.json +2 -2
  16. package/scripts/install.js +3 -17
  17. package/wowok-arbitrator/SKILL.md +18 -57
  18. package/wowok-auditor/SKILL.md +16 -12
  19. package/wowok-distill/SKILL.md +237 -0
  20. package/wowok-guard/SKILL.md +40 -354
  21. package/wowok-machine/SKILL.md +21 -127
  22. package/wowok-messenger/SKILL.md +14 -59
  23. package/wowok-onboard/SKILL.md +42 -12
  24. package/wowok-order/SKILL.md +20 -169
  25. package/wowok-output/SKILL.md +0 -10
  26. package/wowok-planner/SKILL.md +28 -9
  27. package/wowok-provider/SKILL.md +91 -49
  28. package/wowok-safety/SKILL.md +8 -80
  29. package/wowok-scenario/SKILL.md +63 -98
  30. package/wowok-tools/SKILL.md +111 -122
  31. package/references/glossary.ts +0 -297
  32. package/references/guard-scenario-ledger.md +0 -353
  33. package/references/guard-template-library.md +0 -481
  34. package/references/machine-design-reference.md +0 -398
  35. package/references/machine-scenario-ledger.md +0 -227
  36. package/references/machine-template-library.md +0 -522
  37. package/references/merchant-scenario-coordination.md +0 -383
  38. package/references/object-collaboration.md +0 -362
  39. package/references/onchain-constants.md +0 -81
  40. package/wowok-arbitrator/APPENDIX.md +0 -545
  41. package/wowok-auditor/APPENDIX.md +0 -487
  42. package/wowok-guard/APPENDIX.md +0 -428
  43. package/wowok-machine/APPENDIX.md +0 -407
  44. package/wowok-messenger/APPENDIX.md +0 -550
  45. package/wowok-onboard/APPENDIX.md +0 -500
  46. package/wowok-order/APPENDIX.md +0 -777
  47. package/wowok-output/APPENDIX.md +0 -575
  48. package/wowok-planner/APPENDIX.md +0 -724
  49. package/wowok-provider/APPENDIX.md +0 -453
  50. package/wowok-safety/APPENDIX.md +0 -561
  51. package/wowok-scenario/APPENDIX.md +0 -97
  52. package/wowok-scenario/MODE-DETAILS.md +0 -275
  53. package/wowok-tools/APPENDIX.md +0 -388
@@ -1,9 +1,10 @@
1
1
  ---
2
2
  name: wowok-tools
3
3
  description: |
4
- WoWok MCP tool reference — canonical documentation for all 13 MCP tools.
5
- Covers schema-inexpressible constraints, business rules, interaction patterns,
6
- and design decisions not captured by JSON Schema.
4
+ WoWok MCP tool reference — canonical documentation for the single unified
5
+ `wowok` tool and its 17 sub-tools. Covers schema-inexpressible constraints,
6
+ business rules, interaction patterns, and design decisions not captured by
7
+ JSON Schema.
7
8
 
8
9
  Core value: prevent common AI failures (wrong tool selection, incorrect
9
10
  parameter formats, missing structural wrappers, wrong discriminated unions).
@@ -17,13 +18,36 @@ always: true
17
18
 
18
19
  # WoWok MCP Tool Reference
19
20
 
20
- Canonical reference for all 13 MCP tools. Covers patterns, constraints, and design decisions that **JSON Schema cannot express**. For detailed business workflows, see the Domain and Business Skills below.
21
+ Canonical reference for the single unified `wowok` tool and its 17 sub-tools. Covers patterns, constraints, and design decisions that **JSON Schema cannot express**. For detailed business workflows, see the Domain and Business Skills below.
21
22
 
22
23
  > **Domain Skills**: [wowok-guard](../wowok-guard/SKILL.md) (validation logic), [wowok-messenger](../wowok-messenger/SKILL.md) (encrypted messaging), [wowok-machine](../wowok-machine/SKILL.md) (workflows), [wowok-safety](../wowok-safety/SKILL.md) (safety & naming)
23
24
  > **Business Skills**: [wowok-order](../wowok-order/SKILL.md) (customer), [wowok-provider](../wowok-provider/SKILL.md) (merchant), [wowok-arbitrator](../wowok-arbitrator/SKILL.md) (dispute resolution)
24
25
 
25
26
  ---
26
27
 
28
+ ## Single-Tool Interface (Schema-Gated Execution)
29
+
30
+ MCP `tools/list` returns **only one tool**: `wowok`. All operations go through it.
31
+
32
+ **Call pattern**: `wowok({ tool: "<sub-tool-name>", data: {<sub-tool params>} })`
33
+
34
+ When any skill (including this one) says "Call `onchain_operations`" or "Use `schema_query`", translate it to:
35
+ ```
36
+ wowok({ tool: "onchain_operations", data: { operation_type: "service", ... } })
37
+ wowok({ tool: "schema_query", data: { action: "get", name: "onchain_operations" } })
38
+ ```
39
+
40
+ **Schema-gated execution**: If `data` doesn't match the sub-tool's schema, the response includes:
41
+ - `result.status = "schema_mismatch"` — validation failed
42
+ - `result.errors` — specific field errors
43
+ - `result.hint` — instructions to fix and retry
44
+ - `schema.input` — the correct JSON schema for the sub-tool
45
+ - `schema.tool` — which sub-tool this schema belongs to
46
+
47
+ **Schema caching**: Each sub-tool has a different schema. When you receive a schema in a mismatch response, cache it in your context for future calls to the same sub-tool. You should only need to see each sub-tool's schema once per conversation.
48
+
49
+ ---
50
+
27
51
  ## 🔴 Gas and Faucet
28
52
 
29
53
  On-chain operations require gas. Transactions will fail if the account has insufficient balance.
@@ -32,15 +56,15 @@ On-chain operations require gas. Transactions will fail if the account has insuf
32
56
 
33
57
  When assisting users with WoWok operations:
34
58
 
35
- - After a user creates a new account, proactively call `account_operation` `faucet` to claim test tokens on their behalf
36
- - Before starting any on-chain workflow, check balance via `query_toolkit` `account_balance`
59
+ - After a user creates a new account, proactively call `wowok({ tool: "account_operation", data: { faucet: { ... } } })` to claim test tokens
60
+ - Before starting any on-chain workflow, check balance via `wowok({ tool: "query_toolkit", data: { query_type: "account_balance", ... } })`
37
61
  - If balance is below 1 WOW, automatically request faucet without asking the user
38
62
  - If a transaction fails due to gas, retry after claiming more tokens
39
63
 
40
64
  ### Tool Reference
41
65
 
42
- - **Claim tokens**: `account_operation` `faucet` (not `onchain_operations`)
43
- - **Check balance**: `query_toolkit` `account_balance`
66
+ - **Claim tokens**: `wowok({ tool: "account_operation", data: { faucet: { ... } } })` (not `onchain_operations`)
67
+ - **Check balance**: `wowok({ tool: "query_toolkit", data: { query_type: "account_balance", ... } })`
44
68
 
45
69
  Each faucet claim provides approximately 5 WOW, sufficient for dozens of transactions.
46
70
 
@@ -118,147 +142,120 @@ Step 3: MODIFY reward { object: "reward_v1", guard_add: [...] } // bind guard
118
142
 
119
143
  ---
120
144
 
121
- ## The 13 Tools
145
+ ## Sub-Tool Schema-Inexpressible Constraints
122
146
 
123
- ### 1. `onchain_operations`16 Sub-Types
147
+ > MCP schemas define field types/validation. The constraints below are business rules NOT expressible in schemas AI must know them before calling.
124
148
 
125
- > **Schema**: `schema_query({ name: "onchain_operations" })` for the full discriminated union. Per-type schemas: `onchain_operations_service`, `onchain_operations_machine`, etc.
149
+ ### `onchain_operations` (18 sub-types)
126
150
 
127
- | `operation_type` | Schema-Inexpressible Constraints |
151
+ | `operation_type` | Key Constraints (not in schema) |
128
152
  |-----------------|----------------------------------|
129
- | `service` | `machine` field must reference a **published** Machine. Allocators evaluated in array order (first-Guard-wins). Publish locks `machine`/`order_allocators`; `sales`/`discount`/`description` remain mutable. |
130
- | `machine` | Nodes immutable after publish. Forward requires ≥1 of `namedOperator`/`permissionIndex` (both empty = SDK error). Weight `u16` (0–65535), threshold `u32`. `""` = entry node. Full lifecycle → [wowok-machine](../wowok-machine/SKILL.md). |
131
- | `progress` | Two-phase advancement: `hold: true` (lock) → `hold: false` (submit). `adminUnhold: true` force-releases others' locks. SDK fetches Machine internally when resolving `object_address`. |
132
- | `arbitration` | MAX 20 propositions, 520 voters. Non-Finished withdrawal triggers 30-day mandatory wait. Verdict (state 2→3) is **irreversible** by arbitrator — only customer can object via `order.arb_objection`. Voting weight from Guard `b_submission:true` must be numeric (U8–U256→u32). Full workflow → [wowok-arbitrator](../wowok-arbitrator/SKILL.md). |
133
- | `guard` | Two creation modes: `root.type: "node"` (inline) or `"file"` (from JSON/Markdown). MAX 4 `rely` dependencies. Guards with `rep: false` **excluded** from other Guards' `rely` lists. Global system addresses (`0xaab` EntityRegistrar, `0xaaa` EntityLinker) require table entries. Full design → [wowok-guard](../wowok-guard/SKILL.md). |
134
- | `gen_passport` | MAX 20 Guards/call (AND-ed — all must pass). Omit `info` to auto-fetch submissions from Guards. Passport frozen after creation (immutable credential). Usage → [wowok-guard](../wowok-guard/SKILL.md). |
135
- | `order` | Builder-owned: agents can operate but **cannot withdraw** — only builder receives funds. `order.progress` with Guard requires Passport (mandatory, not bypassable). Arbitration via `order.arb_confirm`/`arb_objection` (not via `arbitration` directly). `arb_claim_compensation` once-only, from Service's compensation fund. Full flow → [wowok-order](../wowok-order/SKILL.md). |
136
- | `payment` | `type_parameter` required (e.g., `"0x2::wow::WOW"`). Irreversible — no refund mechanism. |
137
- | `personal` | **Permanently public** — no private field exists. Warn users before writing sensitive data. |
138
- | `demand` | Guard-gated: `guards` filter which presenters can submit solutions. Separate from Service. |
139
- | `treasury` | Guardable deposits (`external_deposit_guard`) and withdrawals (`external_withdraw_guard`). Each entry creates a Payment record in history table for auditability. |
140
- | `repository` | Composite key: `name + entity` (address or number). Guardable writes validate both writer eligibility and data content. |
141
- | `reward` | `guard_add` AmountType: `Fixed` (equal) or `GuardU64Identifier` (dynamic from submission). `guard_expiration_time` freezes the Guard list; `null` to remove. |
142
- | `allocation` | Auto-executes on Progress advancement; modes evaluated in order (Amount → Rate → Surplus), first-Guard-wins per mode. |
143
- | `contact` | Bridge between Service (`um` field) and Messenger: holds `ims[]` (messenger addresses). |
144
- | `permission` | Indices 0–65535 (0–999 reserved for protocol; custom ≥1000). SDK rejects custom below 1000. Reuse across objects. |
145
-
146
- ### WIP Hash Dispute-Prevention Mechanism
147
-
148
- When a customer browses products, the AI agent MUST capture the `wip_hash` from the Service query result (the `sale.wip_hash` field for each product). When creating an order, pass the captured hash in `buy.items[].wip_hash`.
149
-
150
- This is a two-layer protection:
151
- 1. **Off-chain** (SDK `verify_wip`): downloads the WIP file and verifies its hash matches the captured hash — detects WIP file tampering.
152
- 2. **On-chain** (Move contract `assert!(sale.wip_hash == i.wip_hash)`): confirms the Service's sale hasn't been updated between browse and purchase time.
153
-
154
- If the merchant swaps the WIP file or changes `sale.wip_hash` after the customer browses, the order will fail the customer is protected from bait-and-switch.
153
+ | `service` | `machine` must be **published**. Allocators: array order = priority (first-Guard-wins). Publish locks `machine`/`order_allocators`; `sales`/`discount`/`description` stay mutable. |
154
+ | `machine` | Nodes immutable after publish. Forward needs ≥1 of `namedOperator`/`permissionIndex` (both empty = SDK error). `""` = entry node. → [wowok-machine](../wowok-machine/SKILL.md) |
155
+ | `progress` | Two-phase: `hold:true` (lock) → `hold:false` (submit). `adminUnhold:true` force-releases. SDK auto-fetches Machine when resolving `object_address`. |
156
+ | `arbitration` | MAX 20 propositions, 520 voters. Verdict (2→3) **irreversible** — only customer can `order.arb_objection`. Non-Finished withdrawal = 30-day wait. → [wowok-arbitrator](../wowok-arbitrator/SKILL.md) |
157
+ | `guard` | `root.type:"node"` (inline) or `"file"` (JSON/MD). MAX 4 `rely`. `rep:false` Guards excluded from others' `rely`. System addresses `0xaab`/`0xaaa` need table entries. → [wowok-guard](../wowok-guard/SKILL.md) |
158
+ | `gen_passport` | MAX 20 Guards/call (AND-ed). Omit `info` to auto-fetch. Passport = frozen immutable credential. |
159
+ | `order` | Agents can operate but **cannot withdraw** — only builder. `order.progress`+Guard requires Passport. Arb via `order.arb_confirm`/`arb_objection` (not `arbitration` directly). `arb_claim_compensation` once-only. → [wowok-order](../wowok-order/SKILL.md) |
160
+ | `payment` | `type_parameter` required. **Irreversible** — no refund. |
161
+ | `personal` | **Permanently public** — warn users before writing sensitive data. |
162
+ | `demand` | Guard-gated: `guards` filter presenters. Separate from Service. |
163
+ | `treasury` | Guardable deposits/withdrawals. Each entry creates Payment record for audit. |
164
+ | `repository` | Composite key: `name + entity`. Guard validates writer + content. |
165
+ | `reward` | `guard_add`: `Fixed` (equal) or `GuardU64Identifier` (dynamic). `guard_expiration_time` freezes Guard list; `null` removes. |
166
+ | `allocation` | Auto-executes on Progress advance. Order: Amount → Rate → Surplus, first-Guard-wins per mode. |
167
+ | `contact` | Bridge: Service `um` Messenger `ims[]`. IM mutations need permission index 453; no events (poll `ims[]`). |
168
+ | `permission` | 0–999 reserved; custom ≥1000. SDK rejects <1000. Reusable across objects. |
169
+ | `proof` | Immutable (freeze_object). `proof_type=1` reserved for WTS; >100 for custom. Large data → Repository + `about_address`, not inline. |
170
+ | `gen_proof` | Convenience wrapper: creates Proof without `namedNew`. Same immutability rules. Use `proof` with `namedNew` when naming is needed. |
171
+
172
+ **WIP hash anti-bait**: Capture `sale.wip_hash` when browsing; pass in `buy.items[].wip_hash`. Two-layer: SDK verifies file hash off-chain, Move asserts on-chain. Merchant swap = order fails.
173
+
174
+ ### Other Tools (compact)
175
+
176
+ | Tool | Key Constraints |
177
+ |------|----------------|
178
+ | `query_toolkit` | `token_list` cached (first query populates). `account_balance`: `balance=true` for totals, `coin={cursor,limit}` for paginated. `onchain_objects` batches 50/req. `local_names` resolves accounts + marks. |
179
+ | `onchain_table_data` | 12 types. Global (no `parent`): `entity_registrar`, `entity_linker`. `onchain_table_item_generic` = universal fallback. |
180
+ | `account_operation` | `faucet` testnet/localnet only. Mainnet funding: `transfer` from existing account (1 WOW = 10^9 base units). `gen` with `m` enables Messenger. Private keys never leave device. |
181
+ | `local_mark_operation` | Max 50 tags/entry (64 chars). `replaceExistName:true` steals names — prefer `_v1`/`_v2`. |
182
+ | `local_info_operation` | Max 50 contents/entry, 300 chars each. |
183
+ | `messenger_operation` | Stranger: 1 msg before reply (~480 chars). Guard block → rejection includes guard list; sender needs Passport. WTS: `generate` needs continuous sequences. → [wowok-messenger](../wowok-messenger/SKILL.md) |
184
+ | `wip_file` | `verify`: hash → signatures stepwise. `wip2html`: single file or directory. |
185
+ | `guard2file` | Read-only export to JSON/Markdown. |
186
+ | `machineNode2file` | Read-only; exports complete topology. |
187
+ | `onchain_events` | 6 event types; cursor `{eventSeq, txDigest}`. |
188
+ | `wowok_buildin_info` | 5 info types. Guard instructions filter by `name`/`return_type`/`param_count`. **Never use Value type 19**. |
189
+ | `schema_query` | `list` returns empty if schemas not generated → `npm run generate:schemas`. |
155
190
 
156
191
  ---
157
192
 
158
- ### 2. `query_toolkit`Read (Local + On-Chain)
193
+ ## Supporting ObjectsWhen to Use
159
194
 
160
- 9 query types. Schema-inexpressible: `token_list` is **cached** (populated on first query). `account_balance` dual-mode: `balance=true` for totals, `coin={cursor,limit}` for paginated coin objects. `onchain_objects` batches 50/request internally. `local_names` resolves to account names AND local marks simultaneously.
195
+ > MCP handles risk assessment + confirmation rules automatically. This section covers business decisions NOT in schemas WHEN and WHY to choose each object type.
161
196
 
162
- ### 3. `onchain_table_data` — Dynamic Table Queries
197
+ ### Proof vs WIP
163
198
 
164
- 12 query types. **Global** (no `parent`): `entity_registrar`, `entity_linker`. All others require `parent`. `onchain_table_item_generic` accepts arbitrary key types — universal fallback for custom objects.
199
+ | Aspect | Proof (on-chain) | WIP (off-chain file) |
200
+ |--------|-----------------|---------------------|
201
+ | Purpose | Cryptographic attestation (merkle root, server signature, timestamp) | Product description + images for arbitration evidence |
202
+ | Immutability | `freeze_object` — permanent on-chain record | File hash anchored on-chain; file stored off-chain |
203
+ | Size | `MAX_PROOF_SIZE` (compact digests only) | Unlimited (file-based) |
204
+ | Use when | Need on-chain timestamp + signature verification | Need product evidence for order disputes |
165
205
 
166
- ### 4. `account_operation` Wallet (ALL LOCAL)
206
+ `gen_proof` = convenience (no `namedNew` wrapper). `proof` with `namedNew` = named object for reuse by reference. For large data, store in Repository and set `about_address` to the Repository ID.
167
207
 
168
- `faucet` only testnet/localnet. `gen` with `m` enables Messenger. `signData` supports UTF-8/base64/hex. `get` with `balance_required` splits existing coins (no minting). Private keys never leave the device.
208
+ ### Treasury vs Allocation
169
209
 
170
- **Mainnet operations**: `faucet` is unavailable on mainnet. To fund new accounts, use `transfer` from an existing account with sufficient balance:
171
- ```
172
- {"transfer": {"amount": 1000000000, "name_or_address_from": "", "name_or_address_to": "new_account", "network": "mainnet"}}
173
- ```
174
- - 1 WOW (10^9 base units) per account is sufficient for dozens of transactions
175
- - `name_or_address_from: ""` uses the default account
210
+ | Aspect | Treasury | Allocation |
211
+ |--------|----------|------------|
212
+ | Purpose | Team fund management (deposit/withdraw with audit trail) | Order fund distribution (auto-trigger on Progress advance) |
213
+ | Trigger | Manual deposit/withdraw (Guard-gated) | Automatic when Progress reaches configured node |
214
+ | Guard | External guard on withdrawals | Allocation guard on distribution rules |
215
+ | Use when | Holding pooled funds, compensation funds, team wallets | Splitting order payments among recipients |
176
216
 
177
- ### 5. `local_mark_operation` Address Book (ALL LOCAL)
217
+ Compensation fund = Treasury bound to Service. Each Treasury entry creates a Payment record for audit. Withdrawal requires Guard verification.
178
218
 
179
- Max 50 tags/entry (64 chars each). `replaceExistName:true` steals existing names — prefer versioned names (`_v1`, `_v2`).
219
+ ### Reward (Incentive Pools)
180
220
 
181
- ### 6. `local_info_operation` Private Data (ALL LOCAL)
221
+ Guard-gated claim pools: `claim_guard` verifies eligibility before payout. `guard_add` modes: `Fixed` (equal split among claimants) or `GuardU64Identifier` (dynamic amount from Guard table index). `guard_expiration_time` freezes the Guard list (set `null` to remove freeze). Use cases: customer loyalty rewards, referral bonuses, airdrop campaigns, attendance rewards. Query claim history via `query_toolkit` → `onchain_table_item_reward_record`.
182
222
 
183
- Max 50 contents/entry, 300 chars each.
223
+ ### Demand (Customer-Posted Requests)
184
224
 
185
- ---
225
+ Demand is the **inverse** of Service: customer posts a request + optional reward pool, providers submit offers. Guard-gated: `guards` filter which providers can present. `recommend_guard` filters presenter submissions. Separate `operation_type: "demand"` — NOT `service`. Use when: customer needs competitive bids (custom work, bulk procurement, reverse-auction marketplace). Pair with Reward to incentivize providers.
186
226
 
187
- ### 7. `messenger_operation` — Encrypted Messaging
227
+ ### Repository (On-Chain Database)
188
228
 
189
- **Stranger rules** (not in schema): 1 message before reply required (max ~480 chars); reply auto-adds stranger to friends; cool-down window after rejection.
229
+ Composite key: `name + entity`. Guard validates writer identity + content integrity. `id_from_submission` (must be Address) and `data_from_submission` (must match Repository's `value_type`) extract structured data from Guard submissions. Use cases: supply-chain tracking, multi-party attestation, dynamic pricing data, KYC registries. MAX 50 policies per Repository, 100 IDs per operation. Guard design: see [wowok-guard](../wowok-guard/SKILL.md) §"Where Guards Attach".
190
230
 
191
- **Guard flow** (not in schema): When guard blocks a stranger message, rejection reply includes guard list — sender must obtain valid Passport to resend.
231
+ ### Contact (Service.um Bridge)
192
232
 
193
- **WTS** (not in schema): `generate` requires continuous sequences (gaps break chain). `verify` `sign` `wts2html` pipeline. `proof_message` anchors to blockchain. Full design [wowok-messenger](../wowok-messenger/SKILL.md).
194
-
195
- ---
196
-
197
- | # | Tool | Schema-Inexpressible |
198
- |---|------|---------------------|
199
- | 8 | `wip_file` | `verify` checks hash → signatures stepwise. `wip2html` accepts single file or directory. |
200
- | 9 | `guard2file` | Read-only export to JSON/Markdown. |
201
- | 10 | `machineNode2file` | Read-only; exports complete topology. |
202
- | 11 | `onchain_events` | 6 event types; paginated via cursor `{eventSeq, txDigest}`. |
203
- | 12 | `wowok_buildin_info` | 5 info types. Guard instructions filter by `name`/`return_type`/`param_count`. **Never use Value type 19** (internal, SDK rejects). |
204
- | 13 | `schema_query` | `list` returns empty if schemas not generated → run `npm run generate:schemas`. |
233
+ Contact is the on-chain bridge: `Service.um` `Contact` `ims[]` (Messenger endpoints). Create BEFORE Service publish when `customer_required` is set. Contact can also bind to `Permission.um` (bidirectional dependency — clear `Permission.um` via `permission_um_set(null)` before deleting Contact). IM list mutations (`im_add`/`im_remove`) require permission index 453; no events emitted (poll `ims[]` field). Full Messenger integration: see [wowok-messenger](../wowok-messenger/SKILL.md).
205
234
 
206
235
  ---
207
236
 
208
237
  ## Decision Tree
209
238
 
210
239
  ```
211
- Write state? onchain_operations (choose operation_type)
240
+ All calls via: wowok({ tool: "<sub-tool>", data: {<params>} })
241
+
242
+ Write state? → tool: "onchain_operations" (choose operation_type in data)
212
243
  ├── No data wrapper? → only gen_passport
213
244
  ├── No submission? → only payment, personal
214
245
  └── String (MODIFY) vs Object (CREATE)? → safety §1.1
215
246
 
216
- Read state? → query_toolkit / onchain_table_data
217
- Communicate? → messenger_operation (encrypted)
218
- Local only? → account_operation / local_mark_operation / local_info_operation
219
- Export? → guard2file / machineNode2file
220
- Discover? → schema_query / wowok_buildin_info / onchain_events
247
+ Read state? → tool: "query_toolkit" / "onchain_table_data"
248
+ Communicate? → tool: "messenger_operation" (encrypted)
249
+ Local only? → tool: "account_operation" / "local_mark_operation" / "local_info_operation"
250
+ Export? → tool: "guard2file" / "machineNode2file"
251
+ Discover? → tool: "schema_query" / "wowok_buildin_info" / "onchain_events"
221
252
  ```
222
253
 
223
254
  ---
224
255
 
225
256
  ## Examples Reference
226
257
 
227
- The deployment package includes 5 complete examples in the `examples/` directory. These serve as reference implementations to help explain concepts and demonstrate patterns to users.
228
-
229
- ### Matching User Intent to Examples
230
-
231
- When a user describes their needs, reference the appropriate example to illustrate the approach:
232
-
233
- | User Intent | Example | Complexity | Key Techniques Demonstrated |
234
- |-------------|---------|------------|----------------------------|
235
- | Simple service with time-lock | Insurance | ⭐ Low | Two-node workflow, convert_witness, time-lock Guard |
236
- | E-commerce store setup | MyShop | ⭐⭐ Medium | Four-node workflow, Permission indexes, Messenger integration, discounts |
237
- | Complex multi-path order flow | MyShop_Advanced | ⭐⭐⭐ High | 11+ nodes, dual-signature (threshold=2), Merkle Root verification, Reward pool |
238
- | Weather/data validation service | Travel | ⭐⭐⭐ High | Repository queries, convert_number_address, supply chain sub-orders |
239
- | Signature/authorization service | ThreeBody_Signature | ⭐ Low | Buy Guard for access control, Machine-Service binding |
240
-
241
- ### Finding Examples by Technique
242
-
243
- When explaining a specific technique to users, reference where it appears:
244
-
245
- | Technique | Example | Location |
246
- |-----------|---------|----------|
247
- | convert_witness: 100 (Order to Progress) | Insurance, Travel | Insurance Step 2 |
248
- | Repository data query Guard | Travel | Step 3.1 |
249
- | Dual-signature (threshold=2) | MyShop_Advanced | Lost/Return nodes |
250
- | Reward pool with Guard verification | MyShop_Advanced | reward_wonderful_v2 Guards |
251
- | Buy Guard (restricting purchasers) | ThreeBody_Signature | Step 2 |
252
- | Discount coupons | MyShop | Step 8 |
253
- | Arbitration with voting_guard | MyShop_Advanced | Step 9 |
254
- | Time-lock Guard | Insurance, Travel | Step 2 / Step 3.2 |
255
-
256
- ### How to Use Examples with Users
257
-
258
- 1. **Assess complexity** — Match user requirements to the appropriate complexity level
259
- 2. **Reference the example** — Show users the relevant example path and explain which techniques it demonstrates
260
- 3. **Extract patterns** — Use JSON snippets from examples as templates to help users understand the structure
261
- 4. **Reference test results** — Each example includes `*_TestResults.md` with real testnet execution results for troubleshooting
258
+ 5 examples in `examples/` directory: **Insurance** (⭐ time-lock Guard), **MyShop** (⭐⭐ e-commerce, Messenger, discounts), **MyShop_Advanced** (⭐⭐⭐ 11+ nodes, dual-sig, Merkle Root, Reward), **Travel** (⭐⭐⭐ Repository Guard, supply chain), **ThreeBody_Signature** (⭐ Buy Guard). Each includes `*_TestResults.md` with real testnet data. Match user intent example complexity → extract JSON patterns.
262
259
 
263
260
  ---
264
261
 
@@ -266,9 +263,11 @@ When explaining a specific technique to users, reference where it appears:
266
263
 
267
264
  | Trap | Fix |
268
265
  |------|-----|
266
+ | **Calling sub-tool name directly** | MCP only exposes `wowok`. Use `wowok({ tool: "onchain_operations", data: {...} })`, not `onchain_operations({...})` |
267
+ | **Schema validation error** | The response includes `schema.input` — read it, fix params, retry. Cache the schema for future calls to the same sub-tool. |
269
268
  | **Transaction fails, gas error** | → [Pre-Flight: Gas & Faucet](#pre-flight-gas--faucet). AI should auto-check balance + faucet. |
270
269
  | **Don't know how to build a service** | → [Examples Reference](#examples-reference). Match user intent → example, extract JSON templates. |
271
- | `gen_passport` called as standalone tool | It's not — use `onchain_operations` with `operation_type: "gen_passport"` |
270
+ | `gen_passport` called as standalone tool | It's not — use `wowok({ tool: "onchain_operations", data: { operation_type: "gen_passport", ... } })` |
272
271
  | Missing `data` wrapper | Only `gen_passport` omits it; `payment`/`personal` omit `submission` |
273
272
  | String `object` passed expecting CREATE | String = existing (MODIFY), Object = new (CREATE) → [safety §1.1](../wowok-safety/SKILL.md) |
274
273
  | Missing `submission` on Guard call | See [Submission Loop](#submission-loop-two-phase) — two-phase pattern: call without `submission` first, collect data, re-call with it |
@@ -277,13 +276,3 @@ When explaining a specific technique to users, reference where it appears:
277
276
  | Arbitration called directly | Customer path: `order.arb_confirm` / `order.arb_objection`. Order is the interface |
278
277
 
279
278
  ---
280
-
281
- ## Appendices (Progressive Disclosure)
282
-
283
- > The following sections have been extracted to [APPENDIX.md](./APPENDIX.md) for on-demand loading:
284
- > - Dialogue Scripts (R1-R10) — guided conversation scripts
285
- > - Decision Trees — branching logic reference
286
- > - Failure Playbooks — recovery scenarios
287
- > - Tier Layering — expertise-tier based guidance
288
- >
289
- > Load APPENDIX.md when the user needs guided dialogue, recovery help, or tier-specific guidance.
@@ -1,297 +0,0 @@
1
- // Copyright (c) Wowok.
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- // Phase 2 L3' Knowledge Layer — Concept Glossary (Topic 6)
5
- // Single source of truth for authoritative terms. Schema fields and Skills must
6
- // align with this table; aliases are deprecated and detected by validateText().
7
-
8
- import { USER_DEFINED_PERM_INDEX_START } from "./onchain-constants.js";
9
-
10
- export type GlossaryCategory =
11
- | "role"
12
- | "object"
13
- | "operation"
14
- | "acceptance"
15
- | "permission"
16
- | "fund";
17
-
18
- export interface GlossaryEntry {
19
- /** Authoritative term (canonical, used in schema & docs). */
20
- term: string;
21
- /** Short definition. */
22
- definition: string;
23
- /** Deprecated aliases that should resolve to `term`. */
24
- aliases: string[];
25
- category: GlossaryCategory;
26
- }
27
-
28
- /**
29
- * Canonical glossary. Order is stable for deterministic scans.
30
- * When adding entries, keep `aliases` lowercase to match validateText().
31
- */
32
- export const CONCEPT_GLOSSARY: GlossaryEntry[] = [
33
- // ── Permission triple (the three core permission definitions) ───────────
34
- {
35
- term: "Permission",
36
- definition:
37
- `Organization-wide permission object. indices 0-${USER_DEFINED_PERM_INDEX_START - 1} builtin, ` +
38
- `${USER_DEFINED_PERM_INDEX_START}-65535 custom. ` +
39
- "Shared across all Progress instances of a Service. Use for internal staff roles.",
40
- aliases: ["permission object"],
41
- category: "permission",
42
- },
43
- {
44
- term: "NamedOperator",
45
- definition:
46
- "Per-order role assignment inside a Progress. Each Progress node can map a role " +
47
- "string to an address. Use for external collaborators whose identity varies per order.",
48
- aliases: ["named operator", "namedoperator"],
49
- category: "permission",
50
- },
51
- {
52
- term: "OrderHolder",
53
- definition:
54
- "The order holder and their agents. Represented by namedOperator=\"\" (empty string) " +
55
- "on a Forward. Lets the customer operate their own order.",
56
- aliases: ["order owner", "orderholder", "order holder"],
57
- category: "permission",
58
- },
59
- // ── Process definition ───────────────────────────────────────────────────
60
- {
61
- term: "Forward",
62
- definition:
63
- "A state-transition edge in a Machine. Carries weight, a permission " +
64
- "(Permission index / NamedOperator / OrderHolder), and an optional Guard. " +
65
- "Every Forward MUST define at least one permission.",
66
- aliases: ["transition"],
67
- category: "operation",
68
- },
69
- {
70
- term: "Pair",
71
- definition:
72
- "A prev_node → next_node transition group in a Machine with a threshold. " +
73
- "When the cumulative weight of executed Forwards meets the threshold, the Pair fires.",
74
- aliases: ["transition pair"],
75
- category: "operation",
76
- },
77
- {
78
- term: "Machine",
79
- definition:
80
- "Workflow blueprint (directed graph). Becomes immutable after publish. " +
81
- "A Progress instance is created per order from the Machine.",
82
- aliases: ["machine template"],
83
- category: "object",
84
- },
85
- {
86
- term: "Progress",
87
- definition:
88
- "A workflow instance bound to one order. Advances via Forwards; " +
89
- "carries retained_submission values for Guard verification.",
90
- aliases: ["progress instance"],
91
- category: "object",
92
- },
93
- // ── Acceptance ────────────────────────────────────────────────────────────
94
- {
95
- term: "Guard",
96
- definition:
97
- "Immutable static validation rule. Verifies submissions and on-chain object data. " +
98
- "Returns boolean. Cannot be mutated after creation.",
99
- aliases: ["guard object"],
100
- category: "acceptance",
101
- },
102
- {
103
- term: "Repository",
104
- definition:
105
- "Mutable dynamic acceptance store. Keyed by (name, entity). " +
106
- "Used for data that can change over time (e.g. SLA config, review records).",
107
- aliases: ["repository object"],
108
- category: "acceptance",
109
- },
110
- {
111
- term: "Acceptance",
112
- definition:
113
- "The verification standard for a process step. Composed of static Guard + " +
114
- "dynamic Repository. Drives whether a Forward can execute.",
115
- aliases: ["acceptance standard"],
116
- category: "acceptance",
117
- },
118
- // ─── Objects ──────────────────────────────────────────────────────────────
119
- {
120
- term: "Service",
121
- definition:
122
- "A merchant's service listing. References Machine, order_allocators, arbitrations, " +
123
- "compensation_fund, rewards, buy_guard. machine & order_allocators lock after publish.",
124
- aliases: ["service object"],
125
- category: "object",
126
- },
127
- {
128
- term: "Order",
129
- definition:
130
- "An order against a Service. Funds are escrowed; released via Progress + Allocation. " +
131
- "Arb cases attach to orders for dispute resolution.",
132
- aliases: ["order instance"],
133
- category: "object",
134
- },
135
- {
136
- term: "Allocator",
137
- definition:
138
- "Fund distribution rules. Priority: Amount → Rate → Surplus. first-Guard-wins. " +
139
- "Locked on Service publish (order_allocators).",
140
- aliases: ["allocation"],
141
- category: "fund",
142
- },
143
- {
144
- term: "Allocation",
145
- definition:
146
- "The act of distributing escrowed funds to recipients per an Allocator. " +
147
- "Executed by the order holder or Permission holder.",
148
- aliases: ["allocation act"],
149
- category: "fund",
150
- },
151
- {
152
- term: "Arbitration",
153
- definition:
154
- "Independent arbitration service object. Configured with voting_guard, usage_guard, " +
155
- "fee. Generates Arb cases per dispute. Third-party preferred over self-built.",
156
- aliases: ["arb service"],
157
- category: "object",
158
- },
159
- {
160
- term: "Arb",
161
- definition:
162
- "A single dispute case instance of an Arbitration. Has a state machine " +
163
- "(dispute → confirm → vote → verdict → settle).",
164
- aliases: ["arb case"],
165
- category: "object",
166
- },
167
- {
168
- term: "compensation_fund",
169
- definition:
170
- "A fund attached to a Service. Arbitration indemnity is drawn from it. " +
171
- "Adequacy is a key trust signal for customers.",
172
- aliases: ["compensation fund"],
173
- category: "fund",
174
- },
175
- {
176
- term: "buy_guard",
177
- definition:
178
- "A Guard attached to a Service that gates purchasing. Validates customer eligibility.",
179
- aliases: ["buy guard"],
180
- category: "acceptance",
181
- },
182
- {
183
- term: "Sub-Order",
184
- definition:
185
- "A child order in a cross-Machine supply chain. Introduced at a node with transparent " +
186
- "suppliers; verified by Guard to originate from one of the declared suppliers.",
187
- aliases: ["suborder", "sub order"],
188
- category: "object",
189
- },
190
- {
191
- term: "Reward",
192
- definition:
193
- "Incentive pool. claim is Guard-gated. guard_add supports Fixed or GuardU64Identifier " +
194
- "(dynamic). Used for marketing (first-order, cumulative, referral).",
195
- aliases: ["reward pool"],
196
- category: "fund",
197
- },
198
- {
199
- term: "Demand",
200
- definition:
201
- "A user's posted service request with optional reward. presenters submit proposals; " +
202
- "Guard filters them. Matches Services for personalized acquisition.",
203
- aliases: ["demand request"],
204
- category: "object",
205
- },
206
- {
207
- term: "Personal",
208
- definition:
209
- "Permanently public on-chain identity profile. Social links, reputation (likes/dislikes), " +
210
- "personal info records. CRITICAL: everything here is PUBLIC forever.",
211
- aliases: ["personal profile"],
212
- category: "object",
213
- },
214
- {
215
- term: "Contact",
216
- definition:
217
- "Bridges a Service's um (contact) and the Messenger ims (messaging). Enables " +
218
- "off-chain encrypted communication for pre-order negotiation & evidence.",
219
- aliases: ["contact bridge"],
220
- category: "object",
221
- },
222
- ];
223
-
224
- /** Lowercased alias → canonical term index. */
225
- const ALIAS_INDEX: Map<string, string> = (() => {
226
- const m = new Map<string, string>();
227
- for (const e of CONCEPT_GLOSSARY) {
228
- m.set(e.term.toLowerCase(), e.term);
229
- for (const a of e.aliases) m.set(a.toLowerCase(), e.term);
230
- }
231
- return m;
232
- })();
233
-
234
- /** Resolve a (possibly deprecated) alias to the canonical term. Returns the input unchanged if unknown. */
235
- export function resolveTerm(alias: string): string {
236
- if (!alias) return alias;
237
- return ALIAS_INDEX.get(alias.toLowerCase()) ?? alias;
238
- }
239
-
240
- /** Look up a glossary entry by canonical term (case-insensitive). */
241
- export function lookupEntry(term: string): GlossaryEntry | undefined {
242
- const t = term.toLowerCase();
243
- return CONCEPT_GLOSSARY.find(
244
- (e) => e.term.toLowerCase() === t || e.aliases.some((a) => a.toLowerCase() === t),
245
- );
246
- }
247
-
248
- export interface GlossaryDrift {
249
- /** The deprecated alias found. */
250
- alias: string;
251
- /** Canonical term to use instead. */
252
- canonical: string;
253
- /** 1-based line number where the alias appeared (when scanning a file). */
254
- line?: number;
255
- }
256
-
257
- /**
258
- * Scan free text for deprecated aliases.
259
- * Returns a list of drift findings. Empty = clean.
260
- *
261
- * Note: this is a simple substring/word scan. For schema-field alignment use
262
- * `auditSchemaFields` which checks object key names directly.
263
- */
264
- export function validateText(text: string): GlossaryDrift[] {
265
- const findings: GlossaryDrift[] = [];
266
- if (!text) return findings;
267
- const lower = text.toLowerCase();
268
- for (const entry of CONCEPT_GLOSSARY) {
269
- for (const alias of entry.aliases) {
270
- const a = alias.toLowerCase();
271
- // Avoid matching the canonical term inside its own definition
272
- if (entry.term.toLowerCase() === a) continue;
273
- if (lower.includes(a)) {
274
- findings.push({ alias, canonical: entry.term });
275
- }
276
- }
277
- }
278
- return findings;
279
- }
280
-
281
- /**
282
- * Audit an object's keys against the glossary. Returns aliases found among the
283
- * top-level keys. Used to keep schema field names canonical.
284
- */
285
- export function auditSchemaFields(obj: Record<string, unknown>): GlossaryDrift[] {
286
- const findings: GlossaryDrift[] = [];
287
- for (const key of Object.keys(obj)) {
288
- const canonical = ALIAS_INDEX.get(key.toLowerCase());
289
- if (canonical && canonical !== key) {
290
- findings.push({ alias: key, canonical });
291
- }
292
- }
293
- return findings;
294
- }
295
-
296
- /** Stable version of the glossary for offline-flywheel audits & rollback. */
297
- export const CONCEPT_GLOSSARY_VERSION = 1;