@wowok/skills 1.0.6

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 (70) hide show
  1. package/README.md +156 -0
  2. package/dist/cli.d.ts +3 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +177 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/index.d.ts +3 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +19 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/skills.d.ts +5 -0
  11. package/dist/skills.d.ts.map +1 -0
  12. package/dist/skills.js +46 -0
  13. package/dist/skills.js.map +1 -0
  14. package/dist/types.d.ts +9 -0
  15. package/dist/types.d.ts.map +1 -0
  16. package/dist/types.js +3 -0
  17. package/dist/types.js.map +1 -0
  18. package/examples/Insurance/Insurance.md +594 -0
  19. package/examples/Insurance/Insurance_TestResults.md +481 -0
  20. package/examples/Insurance/insurance_complete_guard_v1.json +50 -0
  21. package/examples/MyShop/MyShop.md +1353 -0
  22. package/examples/MyShop/MyShop_TestResults.md +1003 -0
  23. package/examples/MyShop_Advanced/MyShop_Advanced.md +1898 -0
  24. package/examples/MyShop_Advanced/MyShop_Advanced_MerchantSystem_TestResults.md +1297 -0
  25. package/examples/MyShop_Advanced/MyShop_Advanced_OrderFlow_TestResults.md +743 -0
  26. package/examples/MyShop_Advanced/machine_nodes.json +222 -0
  27. package/examples/ThreeBody_Signature/ThreeBody_Signature.md +776 -0
  28. package/examples/ThreeBody_Signature/ThreeBody_Signature_TestResults.md +599 -0
  29. package/examples/Travel/Travel.md +1157 -0
  30. package/examples/Travel/Travel_TestResults.md +743 -0
  31. package/examples/Travel/calc-weather-timestamps.js +8 -0
  32. package/examples/Travel/travel_machine_v2_export.json +104 -0
  33. package/examples/Travel/weather_check_guard_v1.json +51 -0
  34. package/package.json +56 -0
  35. package/schemas/onchain_operations/_common.md +236 -0
  36. package/schemas/onchain_operations/_index.md +22 -0
  37. package/schemas/onchain_operations/allocation.md +50 -0
  38. package/schemas/onchain_operations/arbitration.md +95 -0
  39. package/schemas/onchain_operations/contact.md +36 -0
  40. package/schemas/onchain_operations/demand.md +52 -0
  41. package/schemas/onchain_operations/gen_passport.md +43 -0
  42. package/schemas/onchain_operations/guard.md +136 -0
  43. package/schemas/onchain_operations/machine.md +70 -0
  44. package/schemas/onchain_operations/order.md +57 -0
  45. package/schemas/onchain_operations/payment.md +32 -0
  46. package/schemas/onchain_operations/permission.md +57 -0
  47. package/schemas/onchain_operations/personal.md +59 -0
  48. package/schemas/onchain_operations/progress.md +35 -0
  49. package/schemas/onchain_operations/repository.md +81 -0
  50. package/schemas/onchain_operations/reward.md +40 -0
  51. package/schemas/onchain_operations/service.md +104 -0
  52. package/schemas/onchain_operations/treasury.md +74 -0
  53. package/schemas/schema-account_operation.md +402 -0
  54. package/schemas/schema-guard2file.md +153 -0
  55. package/schemas/schema-local_info_operation.md +160 -0
  56. package/schemas/schema-local_mark_operation.md +148 -0
  57. package/schemas/schema-machineNode2file.md +155 -0
  58. package/schemas/schema-messenger_operation.md +547 -0
  59. package/schemas/schema-onchain_events.md +201 -0
  60. package/schemas/schema-onchain_table_data.md +334 -0
  61. package/schemas/schema-query_toolkit.md +375 -0
  62. package/schemas/schema-wip_file.md +240 -0
  63. package/schemas/schema-wowok_buildin_info.md +296 -0
  64. package/scripts/install.js +113 -0
  65. package/wowok-build/SKILL.md +606 -0
  66. package/wowok-guard/SKILL.md +374 -0
  67. package/wowok-machine/SKILL.md +512 -0
  68. package/wowok-order/SKILL.md +499 -0
  69. package/wowok-safety/SKILL.md +381 -0
  70. package/wowok-tools/SKILL.md +635 -0
@@ -0,0 +1,499 @@
1
+ ---
2
+ name: wowok-order
3
+ description: |
4
+ WoWok order lifecycle management — covers the complete order flow from
5
+ creation through payment, progress tracking, completion, and dispute
6
+ resolution. Includes order splitting (Allocation), incentive distribution
7
+ (Reward), and arbitration patterns.
8
+
9
+ Use this skill when managing orders, setting up payment flows, configuring
10
+ order splitting, or handling disputes.
11
+ when_to_use:
12
+ - User wants to create or manage orders
13
+ - User asks about order lifecycle, payment, or progress
14
+ - User needs to set up order splitting (allocation) or incentives (reward)
15
+ - User mentions "order", "payment", "allocation", "reward", "arbitration", "dispute"
16
+ - User wants to understand how money flows in WoWok
17
+ ---
18
+
19
+ # WoWok Order Lifecycle Management
20
+
21
+ ## Order Lifecycle Overview
22
+
23
+ ```
24
+ Demand → Order → Payment → Progress → Completion
25
+
26
+ Arbitration (disputes)
27
+ ```
28
+
29
+ ## Component Relationships
30
+
31
+ ```
32
+ Service (marketplace)
33
+ ├── Machine (workflow template)
34
+ ├── Allocation (order splitting rules)
35
+ ├── Reward (incentive pool)
36
+ └── Treasury (team fund)
37
+
38
+ Order (instance)
39
+ ├── references Service
40
+ ├── references Machine (for workflow)
41
+ ├── Payment (funds transfer)
42
+ └── Progress (workflow tracking)
43
+ ```
44
+
45
+ ## Order Creation
46
+
47
+ ```
48
+ onchain_operations({
49
+ operation_type: "order",
50
+ data: {
51
+ op: "create",
52
+ service: "<service_name_or_id>",
53
+ machine: "<machine_name_or_id>",
54
+ buyer: "<buyer_address>",
55
+ seller: "<seller_address>",
56
+ price: "<amount>",
57
+ token_type: "<token_type>",
58
+ ...
59
+ }
60
+ })
61
+ ```
62
+
63
+ ## Payment Flow
64
+
65
+ ### Direct Payment
66
+ ```
67
+ onchain_operations({
68
+ operation_type: "payment",
69
+ data: {
70
+ op: "send",
71
+ from: "<sender_account>",
72
+ to: "<recipient_address>",
73
+ amount: "<amount>",
74
+ token_type: "<token_type>"
75
+ }
76
+ })
77
+ ```
78
+
79
+ ### Payment via Order
80
+ Orders can hold funds in escrow. Payment is released when order progresses through the Machine workflow.
81
+
82
+ ## Order Splitting (Allocation)
83
+
84
+ Allocation defines how order payments are automatically split among multiple recipients.
85
+
86
+ ### Create Allocation
87
+ ```
88
+ onchain_operations({
89
+ operation_type: "allocation",
90
+ data: {
91
+ op: "create",
92
+ name: "<allocation_name>",
93
+ service: "<service_id>",
94
+ rules: [
95
+ {
96
+ recipient: "<address_or_guard>",
97
+ share: <percentage_or_fixed>,
98
+ discount_type: "RATES" // or "FIXED"
99
+ }
100
+ ]
101
+ }
102
+ })
103
+ ```
104
+
105
+ ### Discount Types
106
+ | Type | Description |
107
+ |------|-------------|
108
+ | `RATES` | Percentage-based split (e.g., 30% = 30/100) |
109
+ | `FIXED` | Fixed amount split |
110
+
111
+ ### Common Allocation Patterns
112
+
113
+ **Pattern 1: Platform Fee**
114
+ ```
115
+ rules: [
116
+ { recipient: "<platform_address>", share: 5, discount_type: "RATES" },
117
+ { recipient: "<seller_address>", share: 95, discount_type: "RATES" }
118
+ ]
119
+ ```
120
+
121
+ **Pattern 2: Multi-Party Split**
122
+ ```
123
+ rules: [
124
+ { recipient: "<platform>", share: 3, discount_type: "RATES" },
125
+ { recipient: "<seller>", share: 70, discount_type: "RATES" },
126
+ { recipient: "<affiliate>", share: 27, discount_type: "RATES" }
127
+ ]
128
+ ```
129
+
130
+ ## Incentive Distribution (Reward)
131
+
132
+ Reward defines incentive pools that distribute tokens based on Guard-validated conditions.
133
+
134
+ ### Create Reward
135
+ ```
136
+ onchain_operations({
137
+ operation_type: "reward",
138
+ data: {
139
+ op: "create",
140
+ name: "<reward_name>",
141
+ service: "<service_id>",
142
+ ...
143
+ }
144
+ })
145
+ ```
146
+
147
+ ### Reward Claim Flow
148
+ 1. User meets Reward conditions (validated by Guard)
149
+ 2. User claims reward → `onchain_table_data` query `onchain_table_item_reward_record`
150
+ 3. Tokens are distributed from the Reward pool
151
+
152
+ ## Treasury Management
153
+
154
+ Treasury is a team fund for a Service.
155
+
156
+ ### Deposit to Treasury
157
+ ```
158
+ onchain_operations({
159
+ operation_type: "treasury",
160
+ data: {
161
+ op: "deposit",
162
+ service: "<service_id>",
163
+ amount: "<amount>",
164
+ token_type: "<token_type>"
165
+ }
166
+ })
167
+ ```
168
+
169
+ ### Withdraw from Treasury
170
+ ```
171
+ onchain_operations({
172
+ operation_type: "treasury",
173
+ data: {
174
+ op: "withdraw",
175
+ service: "<service_id>",
176
+ amount: "<amount>",
177
+ token_type: "<token_type>",
178
+ recipient: "<address>"
179
+ }
180
+ })
181
+ ```
182
+
183
+ ### Query Treasury History
184
+ ```
185
+ onchain_table_data({
186
+ query_type: "onchain_table_item_treasury_history",
187
+ parent: "<treasury_id>",
188
+ address: "<payment_id>"
189
+ })
190
+ ```
191
+
192
+ ## Arbitration (Dispute Resolution)
193
+
194
+ When orders have disputes, Arbitration provides resolution.
195
+
196
+ ### Create Arbitration
197
+ ```
198
+ onchain_operations({
199
+ operation_type: "arbitration",
200
+ data: {
201
+ op: "create",
202
+ name: "<arbitration_name>",
203
+ ...
204
+ }
205
+ })
206
+ ```
207
+
208
+ ### Watch Arbitration Events
209
+ ```
210
+ onchain_events({
211
+ type: "arbitration",
212
+ cursor: null,
213
+ limit: 20
214
+ })
215
+ ```
216
+
217
+ ## Demand (Service Requests)
218
+
219
+ Demand allows users to request services.
220
+
221
+ ### Create Demand
222
+ ```
223
+ onchain_operations({
224
+ operation_type: "demand",
225
+ data: {
226
+ op: "create",
227
+ service: "<service_id>",
228
+ description: "<request_description>",
229
+ ...
230
+ }
231
+ })
232
+ ```
233
+
234
+ ### Query Demand Presenters
235
+ ```
236
+ onchain_table_data({
237
+ query_type: "onchain_table_item_demand_presenter",
238
+ parent: "<demand_id>",
239
+ address: "<presenter_address>"
240
+ })
241
+ ```
242
+
243
+ ## Complete Order Flow Example
244
+
245
+ ### 1. Service Setup (done once)
246
+ ```
247
+ Permission → Guard → Service → Machine → Allocation → Reward
248
+ ```
249
+
250
+ ### 2. Order Creation (per transaction)
251
+ ```
252
+ 1. Buyer creates Order referencing Service + Machine
253
+ 2. Buyer sends Payment to Order (escrow)
254
+ 3. Seller advances Progress through Machine nodes
255
+ 4. On completion, Allocation splits payment automatically
256
+ 5. Reward distributes incentives if conditions met
257
+ ```
258
+
259
+ ### 3. Dispute Resolution (if needed)
260
+ ```
261
+ 1. Either party initiates Arbitration
262
+ 2. Arbiter reviews evidence
263
+ 3. Arbiter resolves → funds released per resolution
264
+ ```
265
+
266
+ ## Querying Order State
267
+
268
+ ### Check Order Object
269
+ ```
270
+ query_toolkit({
271
+ query_type: "onchain_objects",
272
+ objects: ["<order_name_or_id>"]
273
+ })
274
+ ```
275
+
276
+ ### Check Order Progress
277
+ ```
278
+ onchain_table_data({
279
+ query_type: "onchain_table",
280
+ parent: "<progress_id>"
281
+ })
282
+ ```
283
+
284
+ ### Check Received Payments
285
+ ```
286
+ query_toolkit({
287
+ query_type: "onchain_received",
288
+ name_or_address: "<object_id>"
289
+ })
290
+ ```
291
+
292
+ ## Common Order Errors
293
+
294
+ | Error | Cause | Fix |
295
+ |-------|-------|-----|
296
+ | "service not found" | Service doesn't exist | Create Service first |
297
+ | "machine not found" | Machine doesn't exist | Create Machine first |
298
+ | "insufficient balance" | Not enough tokens | Check balance with account_balance |
299
+ | "allocation failed" | Invalid split rules | Check total shares = 100% |
300
+ | "progress blocked" | Guard condition not met | Check forward Guard logic |
301
+ | "arbitration not found" | No Arbiter configured | Create Arbitration object |
302
+
303
+ ## Real-World Order Flows (from tested examples)
304
+
305
+ ### Allocation Patterns
306
+
307
+ **From [Insurance](../examples/Insurance/Insurance.md) — Single-Recipient Allocation**
308
+
309
+ The Insurance service uses a single allocator with 100% going to the signer who completes the claim:
310
+
311
+ ```
312
+ order_allocators: {
313
+ description: "Insurance order revenue allocation",
314
+ threshold: 0,
315
+ allocators: [{
316
+ guard: "insurance_withdraw_guard_v1",
317
+ sharing: [{ who: { Signer: "signer" }, sharing: 10000, mode: "Rate" }]
318
+ }]
319
+ }
320
+ ```
321
+
322
+ `sharing: 10000` in `mode: "Rate"` = 100% (basis points: 10000 = 100%).
323
+
324
+ **From [MyShop Advanced](../examples/MyShop_Advanced/MyShop_Advanced.md) — Multi-Recipient Allocation**
325
+
326
+ Dual-allocation pattern: one allocator for merchant-winning scenarios, one for customer-winning scenarios:
327
+
328
+ ```
329
+ order_allocators: {
330
+ description: "Order fund allocation",
331
+ threshold: 0,
332
+ allocators: [
333
+ {
334
+ guard: "service_merchant_win_v2",
335
+ sharing: [{ who: { Signer: "signer" }, sharing: 10000, mode: "Rate" }]
336
+ },
337
+ {
338
+ guard: "service_customer_win_v2",
339
+ sharing: [{ who: { Signer: "signer" }, sharing: 10000, mode: "Rate" }]
340
+ }
341
+ ]
342
+ }
343
+ ```
344
+
345
+ Each allocator's Guard validates the order's current node — if the node is "Order Complete", "Wonderful", or "Return Fail", the merchant's allocator fires. If "Lost" or "Return Complete", the customer's allocator fires.
346
+
347
+ ### Order Creation Patterns
348
+
349
+ **From [Insurance](../examples/Insurance/Insurance.md) — Order via Service**
350
+
351
+ Orders can be created directly through the Service's `order_new` field:
352
+
353
+ ```
354
+ onchain_operations({
355
+ operation_type: "service",
356
+ data: {
357
+ object: "insurance_service_v1",
358
+ order_new: {
359
+ buy: {
360
+ items: [{ name: "Outdoor Accident Insurance", stock: 1, wip_hash: "" }],
361
+ total_pay: { balance: 100000000 }
362
+ },
363
+ namedNewOrder: { name: "test_insurance_order_v1", replaceExistName: true }
364
+ }
365
+ }
366
+ })
367
+ ```
368
+
369
+ **From [Travel](../examples/Travel/Travel.md) — Order via Service with Discount**
370
+
371
+ Orders can include discounts for time-limited promotions:
372
+
373
+ ```
374
+ order_new: {
375
+ buy: {
376
+ items: [{ name: "Iceland Adventure", stock: 1 }],
377
+ total_pay: { balance: 200000000 }
378
+ },
379
+ namedNewOrder: { name: "alice_travel_order_v1" }
380
+ }
381
+ ```
382
+
383
+ ### Reward Patterns
384
+
385
+ **From [MyShop Advanced](../examples/MyShop_Advanced/MyShop_Advanced.md) — Multi-Condition Rewards**
386
+
387
+ Rewards can be added AFTER Service publish. Each reward uses a Guard to verify claim conditions:
388
+
389
+ ```
390
+ onchain_operations({
391
+ operation_type: "reward",
392
+ data: {
393
+ object: { name: "myshop_reward_v2", permission: "myshop_permission_v2", replaceExistName: true },
394
+ description: "Reward pool for MyShop Advanced",
395
+ coin_add: { balance: 100000000 },
396
+ guard_add: [
397
+ {
398
+ guard: "reward_wonderful_v2",
399
+ recipient: { Signer: "signer" },
400
+ amount: { type: "Fixed", value: 10000 },
401
+ expiration_time: null
402
+ },
403
+ {
404
+ guard: "reward_lost_v2",
405
+ recipient: { Signer: "signer" },
406
+ amount: { type: "Fixed", value: 20000 },
407
+ expiration_time: null
408
+ },
409
+ {
410
+ guard: "reward_shipping_timeout_v2",
411
+ recipient: { Signer: "signer" },
412
+ amount: { type: "Fixed", value: 30000 },
413
+ expiration_time: null
414
+ }
415
+ ]
416
+ }
417
+ })
418
+ ```
419
+
420
+ Each guard checks the order's current node:
421
+ - `reward_wonderful_v2`: order at "Wonderful" node → 10000 reward
422
+ - `reward_lost_v2`: order at "Lost" node → 20000 compensation
423
+ - `reward_shipping_timeout_v2`: order at "Shipping" node > 2 days → 30000 compensation
424
+
425
+ ### Progress Advancement Patterns
426
+
427
+ **From [MyShop Advanced](../examples/MyShop_Advanced/MyShop_Advanced.md) — Progress with Submitted Data**
428
+
429
+ When advancing through a node that requires Guard validation with submitted data:
430
+
431
+ ```
432
+ onchain_operations({
433
+ operation_type: "progress",
434
+ data: {
435
+ object: "<progress_id>",
436
+ order: "<order_name>",
437
+ node: { name: "Shipping", forward: 0 },
438
+ pairs: [{ name: "prev_node", value: "Order Confirmed" }]
439
+ }
440
+ })
441
+ ```
442
+
443
+ For the Shipping node (which requires a Merkle root Guard), the Guard's `table` expects a submitted Merkle root string. The `pairs` field carries the runtime data the Guard validates.
444
+
445
+ ### Arbitration Patterns
446
+
447
+ **From [Travel](../examples/Travel/Travel.md) — Pre-Service Arbitration**
448
+
449
+ Arbitration can be created before the Service and bound during Service creation/update:
450
+
451
+ ```
452
+ // Create Arbitration independently:
453
+ onchain_operations({
454
+ operation_type: "arbitration",
455
+ data: {
456
+ object: { name: "travel_arbitration_v1", permission: "travel_permission_v1" },
457
+ description: "Arbitration for Iceland travel service disputes"
458
+ }
459
+ })
460
+
461
+ // Bind during Service update:
462
+ onchain_operations({
463
+ operation_type: "service",
464
+ data: {
465
+ object: "travel_service_v1",
466
+ arbitrations: { op: "add", objects: ["travel_arbitration_v1"] }
467
+ }
468
+ })
469
+ ```
470
+
471
+ ### Sub-Order (Supply Chain) Patterns
472
+
473
+ **From [Travel](../examples/Travel/Travel.md) — Insurance Sub-Order**
474
+
475
+ The Travel workflow creates a sub-order on the Insurance Service as part of its Machine progression. The "Buy Insurance" node's forward includes `forward_to_order_create` which automatically creates an order on the insurance service when the travel order reaches that node.
476
+
477
+ The Insurance Service must already be deployed and published before the Travel Service creates sub-orders on it. See [wowok-build](../wowok-build/SKILL.md) Pattern C: Repository-Linked for the build order.
478
+
479
+ ### Order Lifecycle Summary (from tested examples)
480
+
481
+ ```
482
+ 1. SERVICE SETUP (one-time)
483
+ Permission → Guard(s) → Machine → Service (with allocation) → Publish
484
+
485
+ 2. ORDER CREATION (per transaction)
486
+ onchain_operations(operation_type: "service", data: { object, order_new: { buy: { items, total_pay } } })
487
+
488
+ 3. PROGRESS ADVANCEMENT (multi-step)
489
+ onchain_operations(operation_type: "progress", data: { object, order, node: { name, forward } })
490
+
491
+ 4. FUND DISTRIBUTION (automatic on completion)
492
+ Allocation fires → Payment split per allocator Guards
493
+
494
+ 5. REWARD CLAIMS (on trigger nodes)
495
+ Reward Guard validates → tokens distributed to claimant
496
+
497
+ 6. DISPUTE RESOLUTION (if needed)
498
+ Arbitration → arb_confirm/arb_objection → resolution
499
+ ```