@wowok/skills 1.0.6 → 1.1.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 (52) hide show
  1. package/README.md +26 -30
  2. package/dist/cli.js +114 -19
  3. package/dist/cli.js.map +1 -1
  4. package/dist/index.d.ts +1 -1
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +11 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/skills.d.ts +46 -1
  9. package/dist/skills.d.ts.map +1 -1
  10. package/dist/skills.js +154 -16
  11. package/dist/skills.js.map +1 -1
  12. package/dist/types.d.ts +31 -0
  13. package/dist/types.d.ts.map +1 -1
  14. package/package.json +3 -4
  15. package/scripts/install.js +5 -3
  16. package/wowok-arbitrator/SKILL.md +279 -0
  17. package/wowok-guard/SKILL.md +166 -139
  18. package/wowok-machine/SKILL.md +215 -280
  19. package/wowok-order/SKILL.md +290 -404
  20. package/wowok-provider/SKILL.md +453 -0
  21. package/wowok-safety/SKILL.md +176 -279
  22. package/wowok-tools/SKILL.md +329 -344
  23. package/schemas/onchain_operations/_common.md +0 -236
  24. package/schemas/onchain_operations/_index.md +0 -22
  25. package/schemas/onchain_operations/allocation.md +0 -50
  26. package/schemas/onchain_operations/arbitration.md +0 -95
  27. package/schemas/onchain_operations/contact.md +0 -36
  28. package/schemas/onchain_operations/demand.md +0 -52
  29. package/schemas/onchain_operations/gen_passport.md +0 -43
  30. package/schemas/onchain_operations/guard.md +0 -136
  31. package/schemas/onchain_operations/machine.md +0 -70
  32. package/schemas/onchain_operations/order.md +0 -57
  33. package/schemas/onchain_operations/payment.md +0 -32
  34. package/schemas/onchain_operations/permission.md +0 -57
  35. package/schemas/onchain_operations/personal.md +0 -59
  36. package/schemas/onchain_operations/progress.md +0 -35
  37. package/schemas/onchain_operations/repository.md +0 -81
  38. package/schemas/onchain_operations/reward.md +0 -40
  39. package/schemas/onchain_operations/service.md +0 -104
  40. package/schemas/onchain_operations/treasury.md +0 -74
  41. package/schemas/schema-account_operation.md +0 -402
  42. package/schemas/schema-guard2file.md +0 -153
  43. package/schemas/schema-local_info_operation.md +0 -160
  44. package/schemas/schema-local_mark_operation.md +0 -148
  45. package/schemas/schema-machineNode2file.md +0 -155
  46. package/schemas/schema-messenger_operation.md +0 -547
  47. package/schemas/schema-onchain_events.md +0 -201
  48. package/schemas/schema-onchain_table_data.md +0 -334
  49. package/schemas/schema-query_toolkit.md +0 -375
  50. package/schemas/schema-wip_file.md +0 -240
  51. package/schemas/schema-wowok_buildin_info.md +0 -296
  52. package/wowok-build/SKILL.md +0 -606
@@ -0,0 +1,453 @@
1
+ ---
2
+ name: wowok-provider
3
+ description: |
4
+ WoWok Service Provider — the canonical skill for service providers (merchants, sellers)
5
+ to build, operate, and manage commercial services on WoWok.
6
+
7
+ Covers service design (WIP products, Machine workflows, Allocator strategies),
8
+ trust mechanisms (compensation funds, arbitration), customer attraction
9
+ (discounts, rewards, supply chain promises), and order fulfillment.
10
+
11
+ For customers placing orders, see wowok-order. For arbitrators, see wowok-arbitrator.
12
+ when_to_use:
13
+ - User is a service provider/merchant/seller on WoWok
14
+ - User wants to create a commercial service/marketplace
15
+ - User wants to design workflow (Machine) for order processing
16
+ - User wants to set up fund distribution strategies (Allocators)
17
+ - User wants to configure trust mechanisms (compensation, arbitration)
18
+ - User wants to handle order fulfillment and customer service
19
+ - User mentions "create service", "merchant", "seller", "provider", "workflow design", "compensation", "arbitration"
20
+ ---
21
+
22
+ # WoWok Service Provider Guide
23
+
24
+ Build and operate commercial services on WoWok as a service provider.
25
+
26
+ > **Role**: Service Provider (Merchant/Seller)
27
+ > **Prerequisites**: Understand CREATE vs MODIFY pattern — use `schema_query({ action: "get", name: "onchain_operations" })`
28
+ > **Customer Perspective**: See [wowok-order](../wowok-order/SKILL.md)
29
+ > **Arbitration**: See [wowok-arbitrator](../wowok-arbitrator/SKILL.md)
30
+ > **Machine Design**: See [wowok-machine](../wowok-machine/SKILL.md) for workflow details
31
+ > **Messenger**: See [wowok-messenger](../wowok-messenger/SKILL.md) for customer communication
32
+ > **Tools**: See [wowok-tools](../wowok-tools/SKILL.md)
33
+
34
+ ---
35
+
36
+ ## Core Concepts
37
+
38
+ ### Dependency-First Construction
39
+
40
+ Commercial services MUST be built in strict dependency order. An object cannot reference another that does not yet exist.
41
+
42
+ **Build Sequence**:
43
+ ```
44
+ Permission → Service (unpublished) → Machine (Nodes but unpublished) → Guards → Allocators → Reward/Arbitration → Publish Machine → Bind to Service → Publish Service
45
+ ```
46
+
47
+ **Immutability Rules**:
48
+ | Object | When Immutable | Impact |
49
+ |--------|---------------|--------|
50
+ | **Guard** | After creation | CREATE-only, cannot modify |
51
+ | **Machine** | After `publish: true` | Nodes locked, workflow frozen |
52
+ | **Service** | After `publish: true` | `machine` and `order_allocators` locked |
53
+
54
+ ### CREATE vs MODIFY Pattern
55
+
56
+ The unified pattern across all operations:
57
+ - **Object shape** (`{ name?, ... }`) = **CREATE** new object
58
+ - **String value** (`"<name>"`) = **MODIFY** existing object
59
+
60
+ **Schema Reference**: `schema_query({ action: "get", name: "onchain_operations" })`
61
+
62
+ ### Key Object Relationships
63
+
64
+ ```
65
+ Service (merchant storefront)
66
+ ├── machine → Machine (workflow definition)
67
+ ├── order_allocators → Allocators (fund distribution rules)
68
+ ├── arbitrations → Arbitration[] (dispute resolution options)
69
+ ├── compensation_fund → Customer protection pool
70
+ ├── sales → SalesItem[] (products with WIP files)
71
+ ├── discount → Discount[] (coupons)
72
+ ├── rewards → Reward[] (order/user behavior incentives)
73
+ └── um → Contact (customer service)
74
+
75
+ Order (created per purchase)
76
+ ├── builder → Customer (order owner)
77
+ ├── progress → Progress (workflow state)
78
+ └── allocation → Allocation (fund distribution engine)
79
+ ```
80
+
81
+ ---
82
+
83
+ ## Phase 1: Service Design (Commercial Intent)
84
+
85
+ Design your service offering before building. This phase defines what customers see and how orders flow.
86
+
87
+ ### 1.1 Product Promise (WIP Files)
88
+
89
+ WIP (Witness Information Promise) files are **immutable product commitments** — your on-chain promise to customers.
90
+
91
+ **Creating WIP Files**:
92
+
93
+ **Tool**: `wip_file` with `type: "generate"` operation.
94
+
95
+ **Schema Reference**: `schema_query({ action: "get", name: "wip_file" })`
96
+
97
+ **Key Parameters**:
98
+ - `options.markdown_text`: Product description in markdown format
99
+ - `options.images`: Array of image sources for product visuals
100
+ - `outputPath`: Output file path for generated WIP file
101
+
102
+ **Attaching to Service**:
103
+
104
+ **Operation**: `onchain_operations` with `operation_type: "service"`.
105
+
106
+ **Key Fields**:
107
+ - `sales.op`: Operation type ("add", "set", "remove")
108
+ - `sales.sales`: Array of sales items, each with:
109
+ - `name`: Product name
110
+ - `price`: Price in token units
111
+ - `stock`: Available quantity
112
+ - `wip`: URL to WIP file (your official site, GitHub, etc.)
113
+ - `wip_hash`: SHA256 hash of WIP file for verification (default: `""`, uses hash embedded in WIP file unless explicitly set for verification)
114
+
115
+ **Why WIP Matters**:
116
+ - **Immutable commitment**: Hashed and signed on-chain
117
+ - **Arbitration evidence**: Disputes resolved against your WIP claims
118
+ - **Customer trust**: Transparent specifications reduce uncertainty
119
+ - **Legal protection**: Tamper-proof record of promises
120
+
121
+ ### 1.2 Service Workflow (Machine Design)
122
+
123
+ Machine defines your **service process** — from order creation to completion. Design from a **commercial intent** perspective, not technical implementation.
124
+
125
+ **Key Design Questions**:
126
+ 1. **Service stages**: What are the key milestones? (e.g., confirmed → processing → shipped → delivered)
127
+ 2. **Validation points**: Where do you need customer confirmation or external verification?
128
+ 3. **Branching paths**: What happens on success vs. failure? (e.g., on-time vs. late delivery)
129
+ 4. **Fund release triggers**: At which nodes and how to allocate order funds?
130
+
131
+ **Integration with Allocators**:
132
+ - Each terminal node should map to an allocator strategy
133
+ - Guards determine which allocator executes
134
+ - Design Machine and Allocators together for coherent fund flow
135
+
136
+ > **Implementation**: See [wowok-machine](../wowok-machine/SKILL.md) for node definition syntax, Guard conditions, and Forward configurations.
137
+
138
+ ### 1.3 Fund Distribution Strategy (Allocators)
139
+
140
+ Allocators define **who gets what** under different outcomes. Design these alongside your Machine workflow.
141
+
142
+ **Allocator + Machine Integration**:
143
+ ```
144
+ "delivered" → "order_complete" (threshold: 1)
145
+ └── Forward: "customer_signed" (weight: 1)
146
+ └── Allocator: "completed" → 95% merchant, 5% platform
147
+
148
+ "delivered" → "package_lost" (threshold: 2)
149
+ ├── Forward: "customer_reports_lost" (weight: 1)
150
+ ├── Forward: "merchant_confirms_lost" (weight: 1)
151
+ └── Allocator: "package_lost" → 100% to order (buyer can withdraw)
152
+
153
+ Note: Arbitration is an independent action that can be triggered at any time.
154
+ ```
155
+
156
+ **Allocation Modes** (3 types, executed in order):
157
+ 1. **Amount**: Fixed allocation amount (U64) for each recipient
158
+ 2. **Rate**: Percentage in basis points (10000 = 100%, 500 = 5%)
159
+ - If no Surplus defined, sum of all Rates must equal 10000 (100%)
160
+ 3. **Surplus**: Receives remaining funds (maximum one per allocator)
161
+
162
+ **How Allocation Executes**:
163
+ - When an allocator Guard returns `true`, funds are distributed immediately per that allocator's `sharing` rules. If multiple Guards may evaluate to `true`, query and compare their validation logic and `sharing` rules to determine the most favorable outcome for your interests.
164
+
165
+ **Query Guard Logic**: Use `query_toolkit` with `query_type: "onchain_objects"` to query Guard objects by ID or name. Retrieve detailed validation logic including required node conditions, evidence submissions, and permission checks.
166
+
167
+ **Schema Reference**: `schema_query({ action: "get", name: "onchain_operations_service" })` — look for `order_allocators` field
168
+
169
+ ---
170
+
171
+ ## Phase 2: Trust Mechanisms (Customer Confidence)
172
+
173
+ Configure mechanisms that assure customers they can trust your service.
174
+
175
+ ### 2.1 Compensation Fund (compensation_fund)
176
+
177
+ A **dedicated pool** that pays customers if arbitration rules in their favor. Demonstrates your commitment to fair resolution.
178
+
179
+ **Setting Up Compensation Fund**:
180
+
181
+ **Operation**: `onchain_operations` with `operation_type: "service"`.
182
+
183
+ **Key Fields**:
184
+ - `compensation_fund_add`: Add funds to compensation pool (BalanceType)
185
+ - `setting_locked_time_add`: Lock duration in milliseconds (minimum 30 days = 2592000000ms)
186
+
187
+ **Merchant Commitment (Constraint)**:
188
+ ```
189
+ Merchant withdrawal constraints from compensation_fund:
190
+ 1. Pause Service (stop accepting new orders)
191
+ 2. Wait compensation_lock_duration (≥30 days)
192
+ 3. Then can withdraw remaining funds via compensation_fund_receive
193
+
194
+ This commitment ensures existing orders can still claim compensation during the lock period.
195
+ ```
196
+
197
+ **Customer-Facing Benefits**:
198
+ - Display `compensation_fund` balance in service listing
199
+ - Higher balance + longer lock = more confidence for high-value orders
200
+ - Shows merchant has "skin in the game" for fair resolution
201
+ - Customers can claim compensation via arbitration — see [wowok-order](../wowok-order/SKILL.md) for customer arbitration process
202
+
203
+ ### 2.2 Arbitration Configuration
204
+
205
+ Configure which arbitration services can resolve disputes for your orders.
206
+
207
+ **Operation**: `onchain_operations` with `operation_type: "service"`.
208
+
209
+ **Key Fields**:
210
+ - `arbitrations.op`: Operation type ("add", "set", "remove")
211
+ - `arbitrations.list`: Array of Arbitration object IDs/names
212
+
213
+ **Why Multiple Arbitrations**:
214
+ - Customers evaluate on-chain data to choose the most trusted Arbitration from your approved list
215
+ - Different arbitrations may specialize (e.g., product quality vs. service delivery)
216
+
217
+ ---
218
+
219
+ ## Phase 3: Build & Publish
220
+
221
+ Execute the dependency-first build process.
222
+
223
+ ### 3.1 4-Phase Build Process
224
+
225
+ ```
226
+ PHASE 1 — Foundation
227
+ ├── 1. Permission (CREATE)
228
+ ├── 2. Service (CREATE, unpublished) — define basic info
229
+ └── 3. Machine (CREATE, unpublished) — define ALL nodes and transitions
230
+
231
+ PHASE 2 — Trust Layer
232
+ └── 4. Guards (CREATE) — schema_query({ action: "get", name: "onchain_operations_guard" }) — validate Reward claims, Allocator conditions, Machine node transitions, etc. Create all Guards needed for your workflow.
233
+
234
+ PHASE 3 — Business Logic
235
+ ├── 5. Machine Node Guards (MODIFY Machine) — bind Guards to Machine node forwards for workflow validation at each operation
236
+ ├── 6. Allocators (MODIFY Service) — fund distribution rules
237
+ ├── 7. Rewards (CREATE/MODIFY Service) — optional incentive pools
238
+ ├── 8. Arbitrations (MODIFY Service) — dispute resolution options
239
+ └── 9. Compensation Fund (MODIFY Service) — add funds
240
+
241
+ PHASE 4 — Publication
242
+ ├── 10. Publish Machine — nodes become IMMUTABLE
243
+ ├── 11. Bind Machine to Service — MODIFY Service.machine
244
+ └── 12. Publish Service — everything LOCKED
245
+ ```
246
+
247
+ ### 3.2 Pre-Build Discovery
248
+
249
+ Query existing resources to avoid collisions:
250
+
251
+ **Tools**:
252
+ - `query_toolkit` with `query_type: "account_list"` — list account objects
253
+ - `query_toolkit` with `query_type: "local_mark_list"` — list local marks
254
+ - `query_toolkit` with `query_type: "onchain_objects"` — query specific objects
255
+
256
+ ### 3.3 Reuse Existing Templates
257
+
258
+ Export from proven services instead of building from scratch:
259
+
260
+ **Tools**:
261
+ - `machineNode2file` — export Machine nodes to JSON file for editing
262
+ - `guard2file` — export Guard rules to JSON file for editing
263
+
264
+ **Schema References**:
265
+ - `schema_query({ action: "get", name: "machineNode2file" })`
266
+ - `schema_query({ action: "get", name: "guard2file" })`
267
+
268
+ ---
269
+
270
+ ## Phase 4: Customer Attraction & Incentives
271
+
272
+ Optional mechanisms to attract and retain customers.
273
+
274
+ ### 4.1 Discount Coupons
275
+
276
+ Issue promotional discounts to attract new customers or reward loyal ones (AI: query `schema_query` for `onchain_operations_service` to view `discount` field definitions).
277
+ **Operation**: `onchain_operations` with `operation_type: "service"`.
278
+
279
+ ### 4.2 Review & Reward Incentives
280
+
281
+ Encourage post-order feedback and engagement.
282
+
283
+ **Design Pattern — Review Incentive**:
284
+ ```
285
+ Machine Workflow:
286
+ "order_completed" → "like" (threshold: 1)
287
+ └── Forward: "positive_feedback" (weight: 1)
288
+
289
+ "order_completed" → "suggest" (threshold: 1)
290
+ └── Forward: "negative_feedback" (weight: 1)
291
+ ```
292
+
293
+ **Creating Reward Pool**:
294
+
295
+ **Operation**: `onchain_operations` with `operation_type: "reward"`.
296
+
297
+ **Example Configuration**:
298
+
299
+ Create 2 Guards that check if Progress reached "like" node, then bind to Reward with different amounts:
300
+
301
+ ```
302
+ Guard 1: "reward_like_200k"
303
+ └── Condition: progress.current_node == "like"
304
+
305
+ Guard 2: "reward_suggest_100k"
306
+ └── Condition: progress.current_node == "suggest"
307
+
308
+ Reward Configuration:
309
+ ├── Guard: "reward_like_200k"
310
+ │ └── Amount: 200000
311
+
312
+ └── Guard: "reward_suggest_100k"
313
+ └── Amount: 100000
314
+ ```
315
+
316
+ > **Note**: Reward is an optional advanced feature. See `schema_query({ action: "get", name: "onchain_operations_reward" })` for full configuration.
317
+
318
+ ### 4.3 Supply Chain Promises (Sub-Orders)
319
+
320
+ Demonstrate quality by committing to purchase from trusted suppliers.
321
+
322
+ **Use Case — Travel Service**:
323
+ ```
324
+ Travel Service promises:
325
+ "We only book 5-star hotels from trusted hotel groups"
326
+
327
+ Machine Implementation:
328
+ ├── "Book Hotel" Node
329
+ │ └── forward_to_order_create: {
330
+ │ service: "trusted-hotel-group-service",
331
+ │ // Creates sub-order on hotel service
332
+ │ }
333
+
334
+ └── Guard: "hotel_booking_confirmed"
335
+ └── Validates sub-order created and confirmed
336
+ ```
337
+
338
+ **Benefits**:
339
+ - **Transparency & Quality assurance**: Commits you to vetted suppliers
340
+ - **Trust building**: "We use X brand" becomes verifiable on-chain
341
+
342
+ **Prerequisites**:
343
+ - Supplier Service must be published first
344
+ - Your Machine references their Service ID
345
+
346
+ ---
347
+
348
+ ## Phase 5: Order Fulfillment
349
+
350
+ Handle active orders through workflow progression.
351
+
352
+ ### 5.1 Progress Operations
353
+
354
+ Advance orders through your Machine workflow via the Progress object.
355
+
356
+ **Key Principle**:
357
+ | Object | Purpose | Operation Target |
358
+ |--------|---------|------------------|
359
+ | **Order** | Fund escrow, ownership | Read-only for workflow |
360
+ | **Progress** | Workflow state, node execution | **Operate via this** |
361
+
362
+ **Two-Phase Operation** (recommended):
363
+
364
+ **Operation**: `onchain_operations` with `operation_type: "progress"`.
365
+
366
+ **Step 1: Lock permission** (Prevents race conditions):
367
+ - `object`: Progress object ID (from Order.progress)
368
+ - `operate.operation`: Target node operation (e.g., `{ Next: "shipped" }`)
369
+ - `operate.hold`: `true` to lock permission
370
+
371
+ **Step 2: Complete off-chain work, then submit**:
372
+ - Same operation with `hold: false` to release lock and submit
373
+
374
+ **Schema Reference**: `schema_query({ action: "get", name: "onchain_operations_progress" })`
375
+
376
+ ### 5.2 Voluntary Compensation
377
+
378
+ Proactively compensate for service failures to maintain relationships.
379
+
380
+ **Scenario — Late Delivery**:
381
+ ```
382
+ Machine Design:
383
+ ├── "Shipping" Node
384
+ │ ├── Forward: "On Time" (normal)
385
+ │ └── Forward: "Late" (penalty trigger)
386
+
387
+ └── Guard "late_penalty"
388
+ ├── IF delivery_time > promised + grace_period
389
+ ├── THEN require Payment from merchant to Order
390
+ └── Validate: Payment ≥ configured_penalty
391
+ ```
392
+
393
+ **Payment Flow**:
394
+ ```
395
+ Merchant or Participant Wallet
396
+ ├──→ Payment (penalty) ──→ Customer's Order
397
+ │ └──→ Customer extracts via receive()
398
+ └──→ Guard validates before workflow continues
399
+ ```
400
+
401
+ **Benefits**:
402
+ - Retains customers through proactive accountability
403
+ - Avoids escalation to arbitration
404
+ - Differentiates your service with guarantees
405
+
406
+ ### 5.3 Customer Service
407
+
408
+ Handle inquiries and issues via Messenger.
409
+
410
+ **Setup**:
411
+ ```
412
+ Service.um → Contact.object_id
413
+ Contact.ims[] → Your customer service addresses
414
+ ```
415
+
416
+ **Best Practices**:
417
+ - Respond promptly to build trust
418
+ - Document all agreements (generates WTS evidence)
419
+ - Confirm understanding explicitly (ARK signature required for evidence)
420
+ - Proactively communicate delays
421
+
422
+ > **Full Guide**: See [wowok-messenger](../wowok-messenger/SKILL.md) for messaging, WTS generation, and evidence management.
423
+
424
+ ---
425
+
426
+ ## Best Practices & Common Pitfalls
427
+
428
+ ### Design Principles
429
+
430
+ | Do | Don't |
431
+ |----|-------|
432
+ | Design Machine + Allocators together | Design workflow without considering fund flow |
433
+ | Provide generous compensation_fund | Skip compensation fund for high-value services |
434
+ | Use clear, verifiable Guard conditions | Create ambiguous validation logic |
435
+ | Test on testnet first, then mainnet | Publish to mainnet without testing |
436
+ | Document WIP thoroughly | Make vague product promises |
437
+
438
+ ---
439
+
440
+ ## Quick Reference
441
+
442
+ ### Essential Schemas
443
+
444
+ | Purpose | Schema Name |
445
+ |---------|-------------|
446
+ | Service operations | `onchain_operations_service` |
447
+ | Machine operations | `onchain_operations_machine` |
448
+ | Guard operations | `onchain_operations_guard` |
449
+ | WIP file generation | `wip_file` |
450
+ | Messenger operations | `messenger_operation` |
451
+ | Query toolkit | `query_toolkit` |
452
+
453
+ **Query Schema**: `schema_query({ action: "get", name: "<schema_name>" })`