@wowok/skills 1.1.9 → 1.1.11

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 (40) hide show
  1. package/LICENSE +36 -0
  2. package/README.md +1 -8
  3. package/dist/cli.js +4 -0
  4. package/dist/cli.js.map +1 -1
  5. package/dist/skills.d.ts.map +1 -1
  6. package/dist/skills.js +33 -0
  7. package/dist/skills.js.map +1 -1
  8. package/examples/Insurance/Insurance.md +218 -90
  9. package/examples/MyShop/MyShop.md +513 -245
  10. package/examples/MyShop/myshop_machine_nodes.json +87 -0
  11. package/examples/MyShop_Advanced/MyShop_Advanced.md +633 -228
  12. package/examples/ThreeBody_Signature/ThreeBody_Signature.md +195 -202
  13. package/examples/Travel/Travel.md +775 -487
  14. package/examples/Travel/calc-weather-timestamps.js +9 -5
  15. package/package.json +8 -3
  16. package/scripts/install.js +4 -0
  17. package/wowok-arbitrator/SKILL.md +542 -1
  18. package/wowok-auditor/SKILL.md +581 -0
  19. package/wowok-guard/SKILL.md +425 -1
  20. package/wowok-machine/SKILL.md +404 -1
  21. package/wowok-messenger/SKILL.md +551 -1
  22. package/wowok-onboard/SKILL.md +520 -0
  23. package/wowok-order/SKILL.md +528 -1
  24. package/wowok-output/SKILL.md +571 -0
  25. package/wowok-planner/SKILL.md +757 -0
  26. package/wowok-provider/SKILL.md +455 -1
  27. package/wowok-safety/SKILL.md +557 -0
  28. package/wowok-scenario/SKILL.md +585 -0
  29. package/wowok-tools/SKILL.md +423 -1
  30. package/examples/Insurance/Insurance_TestResults.md +0 -481
  31. package/examples/Insurance/insurance_complete_guard_v1.json +0 -50
  32. package/examples/MyShop/MyShop_TestResults.md +0 -1003
  33. package/examples/MyShop_Advanced/MyShop_Advanced_MerchantSystem_TestResults.md +0 -1297
  34. package/examples/MyShop_Advanced/MyShop_Advanced_OrderFlow_TestResults.md +0 -743
  35. package/examples/MyShop_Advanced/machine_nodes.json +0 -222
  36. package/examples/MyShop_Advanced/three_body_signature.wip +0 -30
  37. package/examples/ThreeBody_Signature/ThreeBody_Signature_TestResults.md +0 -599
  38. package/examples/Travel/Travel_TestResults.md +0 -743
  39. package/examples/Travel/travel_machine_v2_export.json +0 -104
  40. package/examples/Travel/weather_check_guard_v1.json +0 -51
@@ -2,8 +2,6 @@
2
2
 
3
3
  A complete example demonstrating how to create an outdoor accident insurance service using WoWok protocol. This insurance service is designed to be purchased by travel service providers as part of a travel package (supply chain sub-order).
4
4
 
5
- > **View Actual Execution Results**: See [Insurance_TestResults.md](Insurance_TestResults.md) for real testnet execution results with actual object addresses and transaction outputs.
6
-
7
5
  ---
8
6
 
9
7
  ## Core Requirements & Features
@@ -20,7 +18,7 @@ A complete example demonstrating how to create an outdoor accident insurance ser
20
18
  1. **Time-Lock via Witness Conversion**: The Complete node Guard uses `convert_witness: 100` (TypeOrderProgress) to convert the submitted Order ID into its associated Progress object, then queries `progress.current_time` to verify the time-lock condition.
21
19
  2. **Simple Two-Node Workflow**: Insurance claims follow a straightforward Start -> Complete path, keeping the workflow simple and predictable.
22
20
  3. **Order ID as Submission**: The Order ID is submitted at runtime (`b_submission: true`) and used for witness conversion.
23
- 4. **Machine Creation Pattern**: Machine must be created first, then nodes added separately, then published. Creating machine with nodes and publish in one transaction does not work correctly.
21
+ 4. **Machine Creation Pattern**: Machine can be created with nodes and published in a single transaction (as shown in this example).
24
22
 
25
23
  ---
26
24
 
@@ -111,11 +109,13 @@ Before running this example, ensure you have:
111
109
  }
112
110
  ```
113
111
 
112
+ > **Best Practice — `no_cache: true`**: When building multiple interdependent objects in one session, set `"no_cache": true` in the `env` object of every on-chain operation to ensure fresh chain state. The examples below omit it for brevity.
113
+
114
114
  ---
115
115
 
116
116
  ## Step 1: Create Permission Object
117
117
 
118
- Create a Permission object to manage access control for the insurance service.
118
+ Create a Permission object to manage access control for the insurance service. The Permission must include all permission indexes that will be used in the Machine workflow.
119
119
 
120
120
  **Prompt**: Create a Permission object named "insurance_permission" for the insurance service.
121
121
 
@@ -141,6 +141,13 @@ Create a Permission object to manage access control for the insurance service.
141
141
  }
142
142
  ```
143
143
 
144
+ > **Important**: The `index` array must include all permission indexes used in Machine forwards:
145
+ > - `1000`: for `start_claim` forward (Start node)
146
+ > - `1001`: for `complete_claim` forward (Complete node)
147
+ > - Additional indexes for future operations
148
+ >
149
+ > Without these permissions, advancing Progress will fail with `MoveAbort code: 7`.
150
+
144
151
  ---
145
152
 
146
153
  ## Step 2: Create Time-Lock Complete Guard
@@ -163,51 +170,48 @@ clock > progress.current_time + 1000
163
170
  "tags": ["insurance", "time-lock", "complete"],
164
171
  "replaceExistName": true
165
172
  },
166
- "description": "Time-lock guard for insurance claim completion. Requires current clock > progress.current_time + 1000ms (1 second for TESTING; in production set to reasonable duration like 8 hours). Progress is accessed via Order with convert_witness=TypeOrderProgress(100).",
173
+ "description": "Time-lock guard for insurance claim completion. Requires current clock > progress.current_time + 10000ms (10 seconds for TESTING; in production set to reasonable duration like 8 hours). Progress is accessed via Order with convert_witness=TypeOrderProgress(100).",
174
+
167
175
  "table": [
168
176
  {
169
177
  "identifier": 0,
170
178
  "b_submission": true,
171
179
  "value_type": "Address",
172
- "value": "0x0000000000000000000000000000000000000000000000000000000000000000",
173
180
  "name": "Order ID (submitted at runtime)"
174
181
  },
175
182
  {
176
183
  "identifier": 1,
177
184
  "b_submission": false,
178
185
  "value_type": "U64",
179
- "value": 1000
186
+ "value": 10000
180
187
  }
181
188
  ],
182
189
  "root": {
183
- "type": "node",
184
- "node": {
185
- "type": "logic_as_u256_greater",
186
- "nodes": [
187
- {
188
- "type": "context",
189
- "context": "Clock"
190
- },
191
- {
192
- "type": "calc_number_add",
193
- "nodes": [
194
- {
195
- "type": "query",
196
- "query": "progress.current_time",
197
- "object": {
198
- "identifier": 0,
199
- "convert_witness": 100
200
- },
201
- "parameters": []
190
+ "type": "logic_as_u256_greater",
191
+ "nodes": [
192
+ {
193
+ "type": "context",
194
+ "context": "Clock"
195
+ },
196
+ {
197
+ "type": "calc_number_add",
198
+ "nodes": [
199
+ {
200
+ "type": "query",
201
+ "query": 1272,
202
+ "object": {
203
+ "identifier": 0,
204
+ "convert_witness": 100
202
205
  },
203
- {
204
- "type": "identifier",
205
- "identifier": 1
206
- }
207
- ]
208
- }
209
- ]
210
- }
206
+ "parameters": []
207
+ },
208
+ {
209
+ "type": "identifier",
210
+ "identifier": 1
211
+ }
212
+ ]
213
+ }
214
+ ]
211
215
  }
212
216
  },
213
217
  "env": {
@@ -221,10 +225,10 @@ clock > progress.current_time + 1000
221
225
 
222
226
  | identifier | b_submission | value_type | value | Purpose |
223
227
  |------------|-------------|-----------|-------|---------|
224
- | 0 | **true** | Address | 0x0...0 (placeholder) | Order ID submitted at runtime, converted to Progress via convert_witness |
225
- | 1 | false | U64 | 1000 | Time-lock duration in ms (1 second for testing) |
228
+ | 0 | **true** | Address | (submitted at runtime) | Order ID submitted at runtime, converted to Progress via convert_witness |
229
+ | 1 | false | U64 | 10000 | Time-lock duration in ms (10 seconds for testing) |
226
230
 
227
- > **Important**: `1000` ms (1 second) is for testing only. In production, set to a reasonable duration (e.g., 8 hours = 28800000 ms).
231
+ > **Important**: `10000` ms (10 seconds) is for testing only. In production, set to a reasonable duration (e.g., 8 hours = 28800000 ms).
228
232
 
229
233
  ---
230
234
 
@@ -260,25 +264,22 @@ Create a Guard that allows the insurance provider to withdraw funds after the or
260
264
  }
261
265
  ],
262
266
  "root": {
263
- "type": "node",
264
- "node": {
265
- "type": "logic_equal",
266
- "nodes": [
267
- {
268
- "type": "query",
269
- "query": "progress.current",
270
- "object": {
271
- "identifier": 0,
272
- "convert_witness": 100
273
- },
274
- "parameters": []
267
+ "type": "logic_equal",
268
+ "nodes": [
269
+ {
270
+ "type": "query",
271
+ "query": 1253,
272
+ "object": {
273
+ "identifier": 0,
274
+ "convert_witness": 100
275
275
  },
276
- {
277
- "type": "identifier",
278
- "identifier": 1
279
- }
280
- ]
281
- }
276
+ "parameters": []
277
+ },
278
+ {
279
+ "type": "identifier",
280
+ "identifier": 1
281
+ }
282
+ ]
282
283
  }
283
284
  },
284
285
  "env": {
@@ -292,7 +293,12 @@ Create a Guard that allows the insurance provider to withdraw funds after the or
292
293
 
293
294
  ## Step 4: Create, Configure and Publish Machine
294
295
 
295
- Create a Machine with workflow nodes and publish it in a single transaction. **IMPORTANT**: Machine nodes must be added during creation (in the same transaction) before publishing. Adding nodes after creation in separate transactions may not persist correctly.
296
+ Create a Machine with workflow nodes and publish it in a single transaction.
297
+
298
+ > **IMPORTANT**:
299
+ > - Machine nodes are added during creation in the same transaction
300
+ > - Once published, Machine nodes become immutable and cannot be modified
301
+ > - If you need to change nodes after publishing, you must create a new Machine
296
302
 
297
303
  **Prompt**: Create a Machine named "insurance_machine" with the claim processing workflow and publish it.
298
304
 
@@ -364,13 +370,16 @@ Create a Machine with workflow nodes and publish it in a single transaction. **I
364
370
 
365
371
  ---
366
372
 
367
- ## Step 7: Create and Publish Service
373
+ ## Step 5: Create and Publish Service
368
374
 
369
375
  Create the insurance service with machine, order_allocators, sales, and publish in a single transaction.
370
376
 
371
- > **Important**: Service must include `order_allocators` when publishing. After publishing, `machine`, `order_allocators`, and `arbitrations` become immutable.
377
+ > **Important**:
378
+ > - Service must include `order_allocators` when publishing
379
+ > - After publishing, `machine`, `order_allocators`, and `arbitrations` become immutable
380
+ > - Ensure the Machine is properly configured before creating the Service
372
381
 
373
- **Prompt**: Create and publish a Service named "insurance_service" with machine, order allocation, and insurance product.
382
+ **Prompt**: Create and publish a Service named "insurance_service_v1" with machine, order allocation, and insurance product.
374
383
 
375
384
  ```json
376
385
  {
@@ -422,19 +431,23 @@ Create the insurance service with machine, order_allocators, sales, and publish
422
431
  }
423
432
  ```
424
433
 
434
+ > **Important**:
435
+ > - `mode: "Rate"` represents Rate allocation mode (valid values: `"Amount"`, `"Rate"`, `"Surplus"`)
436
+ > - `who: {"Signer": "signer"}` represents the transaction signer
437
+
425
438
  ---
426
439
 
427
- ## Step 8: Unpause Service
440
+ ## Step 6: Unpause Service
428
441
 
429
442
  Unpause the service to allow order creation.
430
443
 
431
- **Prompt**: Unpause "insurance_service".
444
+ **Prompt**: Unpause "insurance_service_v1".
432
445
 
433
446
  ```json
434
447
  {
435
448
  "operation_type": "service",
436
449
  "data": {
437
- "object": "insurance_service",
450
+ "object": "insurance_service_v1",
438
451
  "pause": false
439
452
  },
440
453
  "env": {
@@ -446,34 +459,35 @@ Unpause the service to allow order creation.
446
459
 
447
460
  ---
448
461
 
449
- ## Step 9: Verify Service Configuration
462
+ ## Step 7: Verify Service Configuration
450
463
 
451
464
  Query the service to verify all configurations are correct.
452
465
 
453
- **Prompt**: Query "insurance_service" to verify configuration.
466
+ **Prompt**: Query "insurance_service_v1" to verify configuration.
454
467
 
455
468
  ```json
456
469
  {
457
470
  "query_type": "onchain_objects",
458
- "objects": ["insurance_service"]
471
+ "objects": ["insurance_service_v1"],
472
+ "network": "testnet"
459
473
  }
460
474
  ```
461
475
 
462
476
  ---
463
477
 
464
- ## Step 10: Test Order Creation and Progress
478
+ ## Step 8: Test Order Creation and Progress
465
479
 
466
- ### 10.1 Create Insurance Order
480
+ ### 8.1 Create Insurance Order
467
481
 
468
482
  Create an order on the insurance service using the `order_new` field of the `service` operation. In production, this would be done by the travel service provider as a supply chain sub-order.
469
483
 
470
- **Prompt**: Create an order on "insurance_service" using account "insurance_provider".
484
+ **Prompt**: Create an order on "insurance_service_v1" using account "insurance_provider_v1".
471
485
 
472
486
  ```json
473
487
  {
474
488
  "operation_type": "service",
475
489
  "data": {
476
- "object": "insurance_service",
490
+ "object": "insurance_service_v1",
477
491
  "order_new": {
478
492
  "buy": {
479
493
  "items": [
@@ -500,7 +514,18 @@ Create an order on the insurance service using the `order_new` field of the `ser
500
514
  }
501
515
  ```
502
516
 
503
- ### 10.2 Advance Progress: Initial -> Start
517
+ > **Get the Progress ID**: After creating the order, query it to obtain the Progress object ID needed for the next steps:
518
+ > ```json
519
+ > {
520
+ > "query_type": "onchain_objects",
521
+ > "objects": ["test_insurance_order_v1"],
522
+ > "network": "testnet",
523
+ > "no_cache": true
524
+ > }
525
+ > ```
526
+ > The response includes a `progress` field containing the Progress object ID, and an `allocation` field containing the Allocation object ID.
527
+
528
+ ### 8.2 Advance Progress: Initial -> Start
504
529
 
505
530
  First, advance the progress from initial state to Start node.
506
531
 
@@ -525,11 +550,22 @@ First, advance the progress from initial state to Start node.
525
550
  }
526
551
  ```
527
552
 
528
- ### 10.3 Advance Progress: Start -> Complete
553
+ > **Note**:
554
+ > - Both `next_node_name` and `forward` fields are required in the operation object
555
+ > - Use simple forward name (e.g., `"start_claim"`) without node prefix. The system automatically resolves the path from current node
556
+ > - The Progress object ID can be obtained by querying the Order object (it has a `progress` field) — see Step 8.1
557
+
558
+ ### 8.3 Advance Progress: Start -> Complete
559
+
560
+ Wait at least 10 seconds after entering Start node, then advance the progress to Complete with the Order ID as submission.
529
561
 
530
- Wait at least 1 second after entering Start node, then advance the progress to Complete with the Order ID as submission.
562
+ > **Two-Phase Submission Loop**: When a forward has a Guard that requires user submission (`b_submission: true`), the MCP server uses a two-phase approach:
563
+ >
564
+ > **Phase 1**: Call WITHOUT the `submission` field at root level. The server will return a `submission` prompt containing the Guard addresses and submission structure that needs to be filled.
565
+ >
566
+ > **Phase 2**: Call WITH the `submission` field at root level, populated with the `value` fields from the Phase 1 prompt. The prompt shows which `identifier` expects a value of which `value_type`.
531
567
 
532
- **Prompt**: Advance progress to Complete, submitting the Order ID. Wait 1 second before executing.
568
+ **Phase 1 Prompt**: Call progress operation WITHOUT `submission` field.
533
569
 
534
570
  ```json
535
571
  {
@@ -546,49 +582,141 @@ Wait at least 1 second after entering Start node, then advance the progress to C
546
582
  "env": {
547
583
  "account": "insurance_provider_v1",
548
584
  "network": "testnet"
585
+ }
586
+ }
587
+ ```
588
+
589
+ The server will return a `submission` prompt like:
590
+
591
+ ```json
592
+ {
593
+ "type": "submission",
594
+ "guard": [
595
+ { "object": "0x1508ded8...", "impack": true }
596
+ ],
597
+ "submission": [
598
+ {
599
+ "guard": "0x1508ded8...",
600
+ "submission": [
601
+ {
602
+ "identifier": 0,
603
+ "b_submission": true,
604
+ "value_type": "Address",
605
+ "name": "Order ID (submitted at runtime)",
606
+ "object_type": "Order"
607
+ }
608
+ ]
609
+ }
610
+ ]
611
+ }
612
+ ```
613
+
614
+ > **Note**: The Phase 1 response returns `value_type` as a numeric enum ID (e.g., `1` = Address). When filling in Phase 2, you can use either the numeric form (`1`) or the string name (`"Address"`) — both are accepted.
615
+
616
+ **Phase 2**: Fill in the `value` field with the Order ID and resubmit. The `submission` field must be placed at the **root level** of the request (sibling to `operation_type`, `data`, and `env`).
617
+
618
+ ```json
619
+ {
620
+ "operation_type": "progress",
621
+ "data": {
622
+ "object": "<insurance_progress_id>",
623
+ "operate": {
624
+ "operation": {
625
+ "next_node_name": "Complete",
626
+ "forward": "complete_claim"
627
+ }
628
+ }
549
629
  },
550
630
  "submission": {
551
631
  "type": "submission",
552
632
  "guard": [
553
633
  {
554
- "object": "insurance_complete_guard_v1",
634
+ "object": "0x1508ded8...",
555
635
  "impack": true
556
636
  }
557
637
  ],
558
638
  "submission": [
559
639
  {
560
- "guard": "insurance_complete_guard_v1",
640
+ "guard": "0x1508ded8...",
561
641
  "submission": [
562
642
  {
563
643
  "identifier": 0,
564
644
  "b_submission": true,
565
645
  "value_type": "Address",
646
+ "name": "Order ID (submitted at runtime)",
647
+ "object_type": "Order",
566
648
  "value": "<insurance_order_id>"
567
649
  }
568
650
  ]
569
651
  }
570
652
  ]
653
+ },
654
+ "env": {
655
+ "account": "insurance_provider_v1",
656
+ "network": "testnet"
657
+ }
658
+ }
659
+ ```
660
+
661
+ > **⚠️ Important**:
662
+ > - The `submission` field must be at the **root level** of the request (sibling to `operation_type`, `data`, and `env`), NOT nested inside `data` or `operate.operation`.
663
+ > - The `guard` objects in the submission use on-chain addresses (not names), as returned by the Phase 1 response.
664
+ > - Fill in the `value` field with the actual Order ID (or Order name). Keep the other fields (`identifier`, `value_type`, `name`, `object_type`) as returned by Phase 1.
665
+ > - Replace `<insurance_progress_id>` and `<insurance_order_id>` with actual values from step 8.1.
666
+ > - Both `next_node_name` and `forward` fields are required in the operation object.
667
+ > - Use simple forward name `"complete_claim"` without node prefix.
668
+
669
+ ---
670
+
671
+ ## Troubleshooting
672
+
673
+ ### MoveAbort code: 7 (Guard Verification Failed)
674
+
675
+ When advancing Progress, if you get `abort code: 7 (Verify failed)`, the Guard condition was not satisfied. For the time-lock Guard:
676
+ - Wait longer than the time-lock duration (10000ms = 10 seconds) before advancing to Complete
677
+ - Verify the submitted Order ID is correct and corresponds to the Progress being advanced
678
+
679
+ ### Forward validation failed
680
+
681
+ If you see `Connection from current node "" to target node "Complete" does not exist`, use simple forward names without node prefix:
682
+ - ✅ Correct: `"forward": "start_claim"`
683
+ - ❌ Incorrect: `"forward": "Start.start_claim"`
684
+
685
+ ### Missing required field 'next_node_name'
686
+
687
+ The progress operation requires both `next_node_name` and `forward` fields in the operation object:
688
+ ```json
689
+ {
690
+ "operation": {
691
+ "next_node_name": "Start",
692
+ "forward": "start_claim"
571
693
  }
572
694
  }
573
695
  ```
574
696
 
575
- > **Note**: Replace `<insurance_progress_id>` and `<insurance_order_id>` with actual values from step 10.1.
697
+ ### Data not found / stale data
698
+
699
+ If queries return old data after successful transactions:
700
+ - Use `no_cache: true` parameter for critical queries
701
+ - Wait for transaction confirmation before the next operation
702
+
703
+ ### Machine modification failed
704
+
705
+ Published Machine nodes are immutable (`MoveAbort code: 3`). Create a new Machine with the correct configuration if changes are needed.
576
706
 
577
707
  ---
578
708
 
579
709
  ## Execution Checklist
580
710
 
581
- - [ ] Create `insurance_provider` account
582
- - [ ] Get test tokens for `insurance_provider`
583
- - [ ] Step 1: Create `insurance_permission`
584
- - [ ] Step 2: Create `insurance_complete_guard`
585
- - [ ] Step 3: Create `insurance_withdraw_guard`
586
- - [ ] Step 4: Create `insurance_machine` (without nodes)
587
- - [ ] Step 5: Add nodes to Machine (Start, Complete)
588
- - [ ] Step 6: Publish Machine
589
- - [ ] Step 7: Create and publish `insurance_service` (with machine, order_allocators, sales)
590
- - [ ] Step 8: Unpause Service
591
- - [ ] Step 9: Verify Service configuration
592
- - [ ] Step 10.1: Create test insurance order
593
- - [ ] Step 10.2: Advance progress Initial -> Start
594
- - [ ] Step 10.3: Wait 1s, then advance progress Start -> Complete
711
+ - [ ] Create `insurance_provider_v1` account
712
+ - [ ] Get test tokens for `insurance_provider_v1`
713
+ - [ ] Step 1: Create `insurance_permission_v1` with all required indexes
714
+ - [ ] Step 2: Create `insurance_complete_guard_v1`
715
+ - [ ] Step 3: Create `insurance_withdraw_guard_v1`
716
+ - [ ] Step 4: Create `insurance_machine_v1` with nodes and publish
717
+ - [ ] Step 5: Create and publish `insurance_service_v1` (with machine, order_allocators, sales)
718
+ - [ ] Step 6: Unpause Service
719
+ - [ ] Step 7: Verify Service configuration
720
+ - [ ] Step 8.1: Create test insurance order
721
+ - [ ] Step 8.2: Advance progress Initial -> Start
722
+ - [ ] Step 8.3: Advance progress Start -> Complete with submission (wait 10s after Step 8.2)