@wowok/agent-mcp 2.4.1 → 2.5.0
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.
- package/dist/config/runtime.d.ts +4 -0
- package/dist/config/runtime.js +29 -5
- package/dist/harness/auto-escalation.d.ts +27 -0
- package/dist/harness/auto-escalation.js +68 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +29 -1621
- package/dist/knowledge/allocation-confirm.d.ts +115 -0
- package/dist/knowledge/allocation-confirm.js +534 -0
- package/dist/knowledge/allocation-context.d.ts +58 -0
- package/dist/knowledge/allocation-context.js +249 -0
- package/dist/knowledge/allocation-ledger.d.ts +67 -0
- package/dist/knowledge/allocation-ledger.js +463 -0
- package/dist/knowledge/allocation-puzzle.d.ts +135 -0
- package/dist/knowledge/allocation-puzzle.js +298 -0
- package/dist/knowledge/allocation-risk.d.ts +78 -0
- package/dist/knowledge/allocation-risk.js +568 -0
- package/dist/knowledge/allocation-templates.d.ts +38 -0
- package/dist/knowledge/allocation-templates.js +970 -0
- package/dist/knowledge/allocation-translation.d.ts +72 -0
- package/dist/knowledge/allocation-translation.js +585 -0
- package/dist/knowledge/arb-risk.d.ts +37 -0
- package/dist/knowledge/arb-risk.js +210 -0
- package/dist/knowledge/arbitration-confirm.d.ts +135 -0
- package/dist/knowledge/arbitration-confirm.js +559 -0
- package/dist/knowledge/arbitration-context.d.ts +81 -0
- package/dist/knowledge/arbitration-context.js +505 -0
- package/dist/knowledge/arbitration-ledger.d.ts +62 -0
- package/dist/knowledge/arbitration-ledger.js +521 -0
- package/dist/knowledge/arbitration-puzzle.d.ts +84 -0
- package/dist/knowledge/arbitration-puzzle.js +304 -0
- package/dist/knowledge/arbitration-risk.d.ts +112 -0
- package/dist/knowledge/arbitration-risk.js +433 -0
- package/dist/knowledge/arbitration-templates.d.ts +38 -0
- package/dist/knowledge/arbitration-templates.js +276 -0
- package/dist/knowledge/arbitration-translation.d.ts +91 -0
- package/dist/knowledge/arbitration-translation.js +487 -0
- package/dist/knowledge/bridge-risk.d.ts +36 -0
- package/dist/knowledge/bridge-risk.js +263 -0
- package/dist/knowledge/contact-risk.d.ts +32 -0
- package/dist/knowledge/contact-risk.js +200 -0
- package/dist/knowledge/demand-confirm.d.ts +32 -0
- package/dist/knowledge/demand-confirm.js +206 -0
- package/dist/knowledge/demand-risk.d.ts +30 -0
- package/dist/knowledge/demand-risk.js +240 -0
- package/dist/knowledge/demand-translation.d.ts +55 -0
- package/dist/knowledge/demand-translation.js +354 -0
- package/dist/knowledge/deployment-scanner.d.ts +63 -0
- package/dist/knowledge/deployment-scanner.js +762 -0
- package/dist/knowledge/examples-scanner-cli.d.ts +1 -0
- package/dist/knowledge/examples-scanner-cli.js +26 -0
- package/dist/knowledge/examples-scanner.d.ts +121 -0
- package/dist/knowledge/examples-scanner.js +825 -0
- package/dist/knowledge/flywheel-loop.d.ts +3 -0
- package/dist/knowledge/flywheel-loop.js +32 -3
- package/dist/knowledge/glossary.js +3 -1
- package/dist/knowledge/guard-confirm.d.ts +86 -0
- package/dist/knowledge/guard-confirm.js +406 -0
- package/dist/knowledge/guard-context.d.ts +56 -0
- package/dist/knowledge/guard-context.js +287 -0
- package/dist/knowledge/guard-design-patterns.d.ts +37 -0
- package/dist/knowledge/guard-design-patterns.js +257 -0
- package/dist/knowledge/guard-ledger.js +14 -0
- package/dist/knowledge/guard-lint.d.ts +1 -0
- package/dist/knowledge/guard-lint.js +83 -3
- package/dist/knowledge/guard-migration.d.ts +48 -0
- package/dist/knowledge/guard-migration.js +228 -0
- package/dist/knowledge/guard-puzzle.js +3 -2
- package/dist/knowledge/guard-risk.d.ts +3 -1
- package/dist/knowledge/guard-risk.js +832 -64
- package/dist/knowledge/guard-templates.d.ts +1 -0
- package/dist/knowledge/guard-templates.js +278 -2
- package/dist/knowledge/guard-translation.js +6 -5
- package/dist/knowledge/index.d.ts +342 -0
- package/dist/knowledge/index.js +344 -0
- package/dist/knowledge/machine-confirm.d.ts +102 -0
- package/dist/knowledge/machine-confirm.js +559 -0
- package/dist/knowledge/machine-context.d.ts +160 -0
- package/dist/knowledge/machine-context.js +812 -0
- package/dist/knowledge/machine-ledger.d.ts +41 -0
- package/dist/knowledge/machine-ledger.js +315 -0
- package/dist/knowledge/machine-puzzle.d.ts +206 -0
- package/dist/knowledge/machine-puzzle.js +494 -0
- package/dist/knowledge/machine-risk.d.ts +75 -0
- package/dist/knowledge/machine-risk.js +644 -0
- package/dist/knowledge/machine-templates.d.ts +92 -0
- package/dist/knowledge/machine-templates.js +1592 -0
- package/dist/knowledge/machine-topology.d.ts +57 -0
- package/dist/knowledge/machine-topology.js +234 -0
- package/dist/knowledge/machine-translation.d.ts +96 -0
- package/dist/knowledge/machine-translation.js +513 -0
- package/dist/knowledge/mcp-schema-audit-cli.d.ts +1 -0
- package/dist/knowledge/mcp-schema-audit-cli.js +45 -0
- package/dist/knowledge/mcp-schema-audit.d.ts +90 -0
- package/dist/knowledge/mcp-schema-audit.js +772 -0
- package/dist/knowledge/onchain-constants.d.ts +4 -0
- package/dist/knowledge/onchain-constants.js +35 -0
- package/dist/knowledge/order-confirm.d.ts +115 -0
- package/dist/knowledge/order-confirm.js +573 -0
- package/dist/knowledge/order-context.d.ts +66 -0
- package/dist/knowledge/order-context.js +390 -0
- package/dist/knowledge/order-ledger.d.ts +69 -0
- package/dist/knowledge/order-ledger.js +341 -0
- package/dist/knowledge/order-puzzle.d.ts +159 -0
- package/dist/knowledge/order-puzzle.js +255 -0
- package/dist/knowledge/order-risk.d.ts +66 -0
- package/dist/knowledge/order-risk.js +653 -0
- package/dist/knowledge/order-templates.d.ts +50 -0
- package/dist/knowledge/order-templates.js +368 -0
- package/dist/knowledge/order-translation.d.ts +78 -0
- package/dist/knowledge/order-translation.js +550 -0
- package/dist/knowledge/passport-confirm.d.ts +130 -0
- package/dist/knowledge/passport-confirm.js +531 -0
- package/dist/knowledge/passport-context.d.ts +59 -0
- package/dist/knowledge/passport-context.js +306 -0
- package/dist/knowledge/passport-ledger.d.ts +48 -0
- package/dist/knowledge/passport-ledger.js +282 -0
- package/dist/knowledge/passport-puzzle.d.ts +108 -0
- package/dist/knowledge/passport-puzzle.js +333 -0
- package/dist/knowledge/passport-risk.d.ts +70 -0
- package/dist/knowledge/passport-risk.js +450 -0
- package/dist/knowledge/passport-templates.d.ts +40 -0
- package/dist/knowledge/passport-templates.js +568 -0
- package/dist/knowledge/passport-translation.d.ts +68 -0
- package/dist/knowledge/passport-translation.js +516 -0
- package/dist/knowledge/payment-risk.d.ts +33 -0
- package/dist/knowledge/payment-risk.js +182 -0
- package/dist/knowledge/permission-confirm.d.ts +110 -0
- package/dist/knowledge/permission-confirm.js +426 -0
- package/dist/knowledge/permission-context.d.ts +58 -0
- package/dist/knowledge/permission-context.js +224 -0
- package/dist/knowledge/permission-ledger.d.ts +38 -0
- package/dist/knowledge/permission-ledger.js +403 -0
- package/dist/knowledge/permission-puzzle.d.ts +122 -0
- package/dist/knowledge/permission-puzzle.js +173 -0
- package/dist/knowledge/permission-risk.d.ts +76 -0
- package/dist/knowledge/permission-risk.js +411 -0
- package/dist/knowledge/permission-templates.d.ts +38 -0
- package/dist/knowledge/permission-templates.js +234 -0
- package/dist/knowledge/permission-translation.d.ts +57 -0
- package/dist/knowledge/permission-translation.js +350 -0
- package/dist/knowledge/personal-risk.d.ts +36 -0
- package/dist/knowledge/personal-risk.js +212 -0
- package/dist/knowledge/progress-confirm.d.ts +108 -0
- package/dist/knowledge/progress-confirm.js +456 -0
- package/dist/knowledge/progress-context.d.ts +123 -0
- package/dist/knowledge/progress-context.js +452 -0
- package/dist/knowledge/progress-ledger.d.ts +63 -0
- package/dist/knowledge/progress-ledger.js +327 -0
- package/dist/knowledge/progress-puzzle.d.ts +82 -0
- package/dist/knowledge/progress-puzzle.js +219 -0
- package/dist/knowledge/progress-risk.d.ts +74 -0
- package/dist/knowledge/progress-risk.js +461 -0
- package/dist/knowledge/progress-templates.d.ts +38 -0
- package/dist/knowledge/progress-templates.js +228 -0
- package/dist/knowledge/progress-translation.d.ts +52 -0
- package/dist/knowledge/progress-translation.js +401 -0
- package/dist/knowledge/proof-confirm.d.ts +31 -0
- package/dist/knowledge/proof-confirm.js +187 -0
- package/dist/knowledge/proof-risk.d.ts +33 -0
- package/dist/knowledge/proof-risk.js +207 -0
- package/dist/knowledge/proof-translation.d.ts +52 -0
- package/dist/knowledge/proof-translation.js +283 -0
- package/dist/knowledge/registrar-risk.d.ts +34 -0
- package/dist/knowledge/registrar-risk.js +217 -0
- package/dist/knowledge/repository-confirm.d.ts +36 -0
- package/dist/knowledge/repository-confirm.js +242 -0
- package/dist/knowledge/repository-risk.d.ts +40 -0
- package/dist/knowledge/repository-risk.js +312 -0
- package/dist/knowledge/repository-translation.d.ts +58 -0
- package/dist/knowledge/repository-translation.js +422 -0
- package/dist/knowledge/resource-risk.d.ts +32 -0
- package/dist/knowledge/resource-risk.js +157 -0
- package/dist/knowledge/reward-confirm.d.ts +113 -0
- package/dist/knowledge/reward-confirm.js +496 -0
- package/dist/knowledge/reward-context.d.ts +127 -0
- package/dist/knowledge/reward-context.js +504 -0
- package/dist/knowledge/reward-ledger.d.ts +96 -0
- package/dist/knowledge/reward-ledger.js +502 -0
- package/dist/knowledge/reward-puzzle.d.ts +97 -0
- package/dist/knowledge/reward-puzzle.js +288 -0
- package/dist/knowledge/reward-risk.d.ts +84 -0
- package/dist/knowledge/reward-risk.js +545 -0
- package/dist/knowledge/reward-translation.d.ts +58 -0
- package/dist/knowledge/reward-translation.js +501 -0
- package/dist/knowledge/safety-rules.js +11 -3
- package/dist/knowledge/scenario-modes.d.ts +53 -0
- package/dist/knowledge/scenario-modes.js +302 -0
- package/dist/knowledge/service-confirm.d.ts +152 -0
- package/dist/knowledge/service-confirm.js +699 -0
- package/dist/knowledge/service-context.d.ts +66 -0
- package/dist/knowledge/service-context.js +403 -0
- package/dist/knowledge/service-ledger.d.ts +71 -0
- package/dist/knowledge/service-ledger.js +609 -0
- package/dist/knowledge/service-puzzle.d.ts +158 -0
- package/dist/knowledge/service-puzzle.js +236 -0
- package/dist/knowledge/service-risk.d.ts +108 -0
- package/dist/knowledge/service-risk.js +615 -0
- package/dist/knowledge/service-templates.d.ts +39 -0
- package/dist/knowledge/service-templates.js +418 -0
- package/dist/knowledge/service-translation.d.ts +103 -0
- package/dist/knowledge/service-translation.js +622 -0
- package/dist/knowledge/tools-reference.d.ts +17 -0
- package/dist/knowledge/tools-reference.js +151 -0
- package/dist/knowledge/treasury-confirm.d.ts +133 -0
- package/dist/knowledge/treasury-confirm.js +512 -0
- package/dist/knowledge/treasury-context.d.ts +64 -0
- package/dist/knowledge/treasury-context.js +363 -0
- package/dist/knowledge/treasury-ledger.d.ts +42 -0
- package/dist/knowledge/treasury-ledger.js +300 -0
- package/dist/knowledge/treasury-puzzle.d.ts +163 -0
- package/dist/knowledge/treasury-puzzle.js +216 -0
- package/dist/knowledge/treasury-risk.d.ts +86 -0
- package/dist/knowledge/treasury-risk.js +440 -0
- package/dist/knowledge/treasury-templates.d.ts +38 -0
- package/dist/knowledge/treasury-templates.js +316 -0
- package/dist/knowledge/treasury-translation.d.ts +78 -0
- package/dist/knowledge/treasury-translation.js +498 -0
- package/dist/knowledge/util-risk.d.ts +30 -0
- package/dist/knowledge/util-risk.js +135 -0
- package/dist/project/business-puzzle.d.ts +47 -0
- package/dist/project/business-puzzle.js +372 -0
- package/dist/project/deployment-doc.d.ts +61 -0
- package/dist/project/deployment-doc.js +432 -0
- package/dist/project/graph.d.ts +1 -0
- package/dist/project/graph.js +27 -1
- package/dist/project/index.d.ts +1 -0
- package/dist/project/index.js +39 -2
- package/dist/project/namespace.d.ts +11 -1
- package/dist/project/namespace.js +27 -2
- package/dist/project/query.d.ts +2 -0
- package/dist/project/query.js +56 -15
- package/dist/project/risk-aggregator.d.ts +50 -0
- package/dist/project/risk-aggregator.js +280 -0
- package/dist/project/substep-trace.d.ts +130 -0
- package/dist/project/substep-trace.js +332 -0
- package/dist/rules.d.ts +12 -0
- package/dist/rules.js +9 -0
- package/dist/schema/call/allocation.d.ts +44 -44
- package/dist/schema/call/arbitration.d.ts +141 -141
- package/dist/schema/call/base.d.ts +386 -386
- package/dist/schema/call/base.js +6 -6
- package/dist/schema/call/bridge-handler.d.ts +5 -2
- package/dist/schema/call/bridge.d.ts +159 -159
- package/dist/schema/call/contact.d.ts +110 -110
- package/dist/schema/call/demand.d.ts +76 -76
- package/dist/schema/call/handler.d.ts +2 -3
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/machine.d.ts +96 -96
- package/dist/schema/call/order.d.ts +98 -110
- package/dist/schema/call/permission-handler.d.ts +5 -0
- package/dist/schema/call/permission-handler.js +54 -0
- package/dist/schema/call/permission.d.ts +108 -108
- package/dist/schema/call/personal.d.ts +14 -14
- package/dist/schema/call/progress.d.ts +57 -72
- package/dist/schema/call/progress.js +7 -4
- package/dist/schema/call/proof.d.ts +18 -18
- package/dist/schema/call/proof.js +12 -7
- package/dist/schema/call/repository.d.ts +154 -154
- package/dist/schema/call/reward.d.ts +55 -55
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +238 -238
- package/dist/schema/call/treasury.d.ts +93 -93
- package/dist/schema/config/index.d.ts +178 -5
- package/dist/schema/config/index.js +52 -1
- package/dist/schema/local/index.d.ts +3554 -836
- package/dist/schema/local/index.js +2 -1
- package/dist/schema/messenger/index.d.ts +162 -162
- package/dist/schema/operations.d.ts +1102 -1118
- package/dist/schema/operations.js +7 -1
- package/dist/schema/project/index.d.ts +1392 -6
- package/dist/schema/project/index.js +426 -2
- package/dist/schema/query/index.d.ts +818 -818
- package/dist/schema/query/index.js +15 -9
- package/dist/schema/schema-query/index.d.ts +23 -3
- package/dist/schema/schema-query/index.js +13 -2
- package/dist/schema/sync-layer4.d.ts +21 -0
- package/dist/schema/sync-layer4.js +261 -0
- package/dist/schema/trust/index.d.ts +26 -26
- package/dist/schema/utils/guard-query-utils.d.ts +7 -0
- package/dist/schema/utils/guard-query-utils.js +14 -1
- package/dist/schemas/account_operation.output.json +718 -0
- package/dist/schemas/bridge_operation.output.json +1 -1
- package/dist/schemas/config_operation.output.json +173 -0
- package/dist/schemas/index.json +9 -1
- package/dist/schemas/local_info_operation.output.json +718 -0
- package/dist/schemas/local_mark_operation.output.json +718 -0
- package/dist/schemas/messenger_operation.output.json +1 -1
- package/dist/schemas/onchain_events.output.json +1 -1
- package/dist/schemas/onchain_operations.output.json +5 -4
- package/dist/schemas/onchain_operations.schema.json +1813 -333
- package/dist/schemas/onchain_operations_allocation.schema.json +9 -11
- package/dist/schemas/onchain_operations_arbitration.schema.json +2 -1
- package/dist/schemas/onchain_operations_contact.schema.json +2 -1
- package/dist/schemas/onchain_operations_demand.schema.json +2 -1
- package/dist/schemas/onchain_operations_gen_passport.schema.json +878 -872
- package/dist/schemas/onchain_operations_gen_proof.schema.json +273 -0
- package/dist/schemas/onchain_operations_guard.schema.json +584 -70
- package/dist/schemas/onchain_operations_machine.schema.json +4 -6
- package/dist/schemas/onchain_operations_order.schema.json +13 -9
- package/dist/schemas/onchain_operations_payment.schema.json +2 -1
- package/dist/schemas/onchain_operations_permission.schema.json +2 -1
- package/dist/schemas/onchain_operations_personal.schema.json +2 -1
- package/dist/schemas/onchain_operations_progress.schema.json +14 -10
- package/dist/schemas/onchain_operations_proof.schema.json +699 -0
- package/dist/schemas/onchain_operations_repository.schema.json +2 -1
- package/dist/schemas/onchain_operations_reward.schema.json +2 -1
- package/dist/schemas/onchain_operations_service.schema.json +4 -6
- package/dist/schemas/onchain_operations_treasury.schema.json +2 -1
- package/dist/schemas/onchain_table_data.output.json +6 -12
- package/dist/schemas/onchain_table_data.schema.json +32 -1
- package/dist/schemas/project_operation.output.json +879 -0
- package/dist/schemas/project_operation.schema.json +473 -2
- package/dist/schemas/query_toolkit.output.json +14906 -6
- package/dist/schemas/schema_query.output.json +38 -1
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/tools/handlers/bridge.d.ts +1 -0
- package/dist/tools/handlers/bridge.js +1 -0
- package/dist/tools/handlers/config.d.ts +2 -0
- package/dist/tools/handlers/config.js +74 -0
- package/dist/tools/handlers/file-export.d.ts +3 -0
- package/dist/tools/handlers/file-export.js +90 -0
- package/dist/tools/handlers/local.d.ts +3 -0
- package/dist/tools/handlers/local.js +38 -0
- package/dist/tools/handlers/messenger.d.ts +16 -0
- package/dist/tools/handlers/messenger.js +188 -0
- package/dist/tools/handlers/onchain.d.ts +2 -0
- package/dist/tools/handlers/onchain.js +248 -0
- package/dist/tools/handlers/project.d.ts +2 -0
- package/dist/tools/handlers/project.js +293 -0
- package/dist/tools/handlers/query.d.ts +5 -0
- package/dist/tools/handlers/query.js +256 -0
- package/dist/tools/handlers/schema-query.d.ts +2 -0
- package/dist/tools/handlers/schema-query.js +93 -0
- package/dist/tools/handlers/trust.d.ts +2 -0
- package/dist/tools/handlers/trust.js +194 -0
- package/dist/tools/handlers/wip.d.ts +2 -0
- package/dist/tools/handlers/wip.js +44 -0
- package/dist/tools/index.d.ts +13 -0
- package/dist/tools/index.js +526 -0
- package/dist/tools/rules-hook.d.ts +2 -0
- package/dist/tools/rules-hook.js +23 -0
- package/dist/tools/shared.d.ts +20 -0
- package/dist/tools/shared.js +130 -0
- package/dist/tools/types.d.ts +35 -0
- package/dist/tools/types.js +1 -0
- package/dist/tools/wrap.d.ts +14 -0
- package/dist/tools/wrap.js +267 -0
- package/package.json +20 -6
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { MAX_AGENT_COUNT, } from "@wowok/wowok";
|
|
2
|
+
import { ORDER_SCENES, findSceneById, inferSceneFromIntent, } from "./order-ledger.js";
|
|
3
|
+
export function initPuzzleFromIntent(intent) {
|
|
4
|
+
const puzzle = {};
|
|
5
|
+
if (intent.action || intent.rule_sentence) {
|
|
6
|
+
puzzle.intent = {
|
|
7
|
+
action: intent.action ?? "buy",
|
|
8
|
+
lifecycle_phase: intent.lifecycle_phase ?? "P-O-01_Created",
|
|
9
|
+
rule_sentence: intent.rule_sentence ?? "",
|
|
10
|
+
failure_conditions: intent.failure_conditions ?? [],
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
puzzle.constraints = {
|
|
14
|
+
F_O_01_no_permission_uses_owner_agent: true,
|
|
15
|
+
F_O_02_machine_is_snapshot: true,
|
|
16
|
+
F_O_03_compound_creation_via_service_buy: true,
|
|
17
|
+
F_O_04_progress_binding_freezes_owner_agent: true,
|
|
18
|
+
F_O_05_claimed_by_irreversible_blocks_dispute: true,
|
|
19
|
+
F_O_06_only_new_order_event_emitted: true,
|
|
20
|
+
F_O_07_dispute_max_10: true,
|
|
21
|
+
F_O_08_agent_max_10_actual_11: true,
|
|
22
|
+
F_O_09_no_store_cannot_be_nested: true,
|
|
23
|
+
F_O_10_sdk_builder_equals_move_owner: true,
|
|
24
|
+
F_O_11_receive_blocks_during_delivering: true,
|
|
25
|
+
F_O_12_agent_cannot_receive: true,
|
|
26
|
+
F_O_13_e_progress_not_specified_dual_semantics: true,
|
|
27
|
+
F_O_14_buy_is_atomic: true,
|
|
28
|
+
F_O_15_package_only_callbacks: true,
|
|
29
|
+
F_O_16_order_allocation_1_to_1: true,
|
|
30
|
+
F_O_17_order_progress_1_to_1: true,
|
|
31
|
+
F_O_18_wip_hash_no_empty_string: true,
|
|
32
|
+
F_O_19_saleitem_item_to_purchaseditem_name: true,
|
|
33
|
+
F_O_20_time_auto_set: true,
|
|
34
|
+
F_O_21_new_order_event_fields: true,
|
|
35
|
+
F_O_22_required_info_contact_or_wts: true,
|
|
36
|
+
F_O_23_transfer_to_irreversible: true,
|
|
37
|
+
F_O_24_sdk_no_client_side_count_check: true,
|
|
38
|
+
F_O_25_service_decoupled_after_publish: true,
|
|
39
|
+
};
|
|
40
|
+
return puzzle;
|
|
41
|
+
}
|
|
42
|
+
export function checkPuzzleCompleteness(puzzle) {
|
|
43
|
+
const missing = [];
|
|
44
|
+
const missing_details = [];
|
|
45
|
+
if (!puzzle.intent) {
|
|
46
|
+
missing.push("A");
|
|
47
|
+
missing_details.push({ dimension: "A", reason: "Intent not specified (action + rule_sentence)" });
|
|
48
|
+
}
|
|
49
|
+
else if (!puzzle.intent.rule_sentence) {
|
|
50
|
+
missing.push("A");
|
|
51
|
+
missing_details.push({ dimension: "A", reason: "rule_sentence is empty" });
|
|
52
|
+
}
|
|
53
|
+
if (!puzzle.binding) {
|
|
54
|
+
if (puzzle.intent?.action === "buy") {
|
|
55
|
+
missing.push("B");
|
|
56
|
+
missing_details.push({ dimension: "B", reason: "Binding not specified (service + items + owner)" });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else if (puzzle.intent?.action === "buy" && !puzzle.binding.service) {
|
|
60
|
+
missing.push("B");
|
|
61
|
+
missing_details.push({ dimension: "B", reason: "service address missing" });
|
|
62
|
+
}
|
|
63
|
+
if (!puzzle.data_source && puzzle.intent?.action === "buy") {
|
|
64
|
+
missing.push("C");
|
|
65
|
+
missing_details.push({ dimension: "C", reason: "Data source not specified (where fields come from)" });
|
|
66
|
+
}
|
|
67
|
+
if (!puzzle.operations) {
|
|
68
|
+
if (puzzle.intent && puzzle.intent.action !== "buy") {
|
|
69
|
+
missing.push("D");
|
|
70
|
+
missing_details.push({ dimension: "D", reason: "Operations not enumerated" });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (!puzzle.logic) {
|
|
74
|
+
missing.push("E");
|
|
75
|
+
missing_details.push({ dimension: "E", reason: "Logic flow not defined (state transitions + mutex)" });
|
|
76
|
+
}
|
|
77
|
+
if (!puzzle.constraints) {
|
|
78
|
+
missing.push("F");
|
|
79
|
+
missing_details.push({ dimension: "F", reason: "Constraints not checked" });
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
dimensions: ["A", "B", "C", "D", "E", "F"],
|
|
83
|
+
missing,
|
|
84
|
+
missing_details,
|
|
85
|
+
complete: missing.length === 0,
|
|
86
|
+
next_step: missing.length === 0
|
|
87
|
+
? "Puzzle complete — ready for confirmation text generation"
|
|
88
|
+
: `Next: complete dimension ${missing[0]} — ${missing_details[0].reason}`,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export function validateConstraints(puzzle) {
|
|
92
|
+
const violations = [];
|
|
93
|
+
if (puzzle.binding) {
|
|
94
|
+
const b = puzzle.binding;
|
|
95
|
+
if (b.agents.length > MAX_AGENT_COUNT) {
|
|
96
|
+
violations.push({
|
|
97
|
+
constraint_id: "F-O-08",
|
|
98
|
+
severity: "HIGH",
|
|
99
|
+
message: `Agent count ${b.agents.length} exceeds MAX_AGENT_COUNT ${MAX_AGENT_COUNT} (⚠️ Move actually allows 11 due to <= bug)`,
|
|
100
|
+
current_value: b.agents.length,
|
|
101
|
+
limit: MAX_AGENT_COUNT,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
for (const item of b.items) {
|
|
105
|
+
if (!item.wip_hash || item.wip_hash === "") {
|
|
106
|
+
violations.push({
|
|
107
|
+
constraint_id: "F-O-18",
|
|
108
|
+
severity: "HIGH",
|
|
109
|
+
message: `Item "${item.name}" has empty wip_hash (Move rejects empty string)`,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (puzzle.operations) {
|
|
115
|
+
for (const op of puzzle.operations.operations) {
|
|
116
|
+
if (op.type === "agent_set" && puzzle.binding?.progress) {
|
|
117
|
+
violations.push({
|
|
118
|
+
constraint_id: "F-O-04",
|
|
119
|
+
severity: "HIGH",
|
|
120
|
+
message: "Cannot set agent: Progress already bound (aborts E_PROGRESS_NOT_SPECIFIED — note dual semantics)",
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
if (op.type === "transfer_to") {
|
|
124
|
+
violations.push({
|
|
125
|
+
constraint_id: "F-O-23",
|
|
126
|
+
severity: "CRITICAL",
|
|
127
|
+
message: `transfer_to is IRREVERSIBLE — new owner ${op.new_owner} will take over ALL permissions`,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
if (op.type === "agent_set" && op.agents.length > MAX_AGENT_COUNT) {
|
|
131
|
+
violations.push({
|
|
132
|
+
constraint_id: "F-O-08",
|
|
133
|
+
severity: "HIGH",
|
|
134
|
+
message: `agent_set with ${op.agents.length} agents exceeds MAX_AGENT_COUNT ${MAX_AGENT_COUNT}`,
|
|
135
|
+
current_value: op.agents.length,
|
|
136
|
+
limit: MAX_AGENT_COUNT,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return violations;
|
|
142
|
+
}
|
|
143
|
+
export function generateConfirmationText(puzzle) {
|
|
144
|
+
const lines = [];
|
|
145
|
+
lines.push("═══ Order Confirmation ═══");
|
|
146
|
+
lines.push("");
|
|
147
|
+
if (puzzle.intent) {
|
|
148
|
+
lines.push(`Action: ${puzzle.intent.action}`);
|
|
149
|
+
lines.push(`Lifecycle phase: ${puzzle.intent.lifecycle_phase}`);
|
|
150
|
+
lines.push(`Intent: ${puzzle.intent.rule_sentence}`);
|
|
151
|
+
if (puzzle.intent.failure_conditions.length > 0) {
|
|
152
|
+
lines.push("Failure conditions:");
|
|
153
|
+
for (const fc of puzzle.intent.failure_conditions)
|
|
154
|
+
lines.push(` - ${fc}`);
|
|
155
|
+
}
|
|
156
|
+
lines.push("");
|
|
157
|
+
}
|
|
158
|
+
if (puzzle.binding) {
|
|
159
|
+
const b = puzzle.binding;
|
|
160
|
+
lines.push("─ Binding (Service snapshot) ──────────────");
|
|
161
|
+
lines.push(`Service: ${b.service}`);
|
|
162
|
+
lines.push(`Machine snapshot: ${b.machine_snapshot ?? "(none — no workflow)"}`);
|
|
163
|
+
lines.push(`Discount: ${b.discount ?? "(none)"}`);
|
|
164
|
+
lines.push(`Items: ${b.items.length}`);
|
|
165
|
+
for (const i of b.items) {
|
|
166
|
+
lines.push(` - ${i.name} x${i.quantity} @ ${i.price} (wip: ${i.wip_hash.slice(0, 10)}...)`);
|
|
167
|
+
}
|
|
168
|
+
lines.push(`Amount: ${b.amount} MIST`);
|
|
169
|
+
lines.push(`Owner (Move) / Builder (SDK): ${b.owner}`);
|
|
170
|
+
lines.push(`Agents: ${b.agents.length > 0 ? b.agents.join(", ") : "(none)"}`);
|
|
171
|
+
lines.push(`Progress: ${b.progress ?? "(not bound)"}`);
|
|
172
|
+
lines.push(`Allocation: ${b.allocation ?? "(not bound)"}`);
|
|
173
|
+
lines.push("");
|
|
174
|
+
}
|
|
175
|
+
if (puzzle.data_source) {
|
|
176
|
+
lines.push("─ Data Source ──────────────");
|
|
177
|
+
const d = puzzle.data_source;
|
|
178
|
+
lines.push(`Service: ${d.service_source}`);
|
|
179
|
+
lines.push(`Machine: ${d.machine_source}`);
|
|
180
|
+
lines.push(`Amount: ${d.amount_source}`);
|
|
181
|
+
lines.push(`Owner: ${d.owner_source}`);
|
|
182
|
+
if (d.progress_source !== "none")
|
|
183
|
+
lines.push(`Progress: ${d.progress_source}`);
|
|
184
|
+
if (d.allocation_source !== "none")
|
|
185
|
+
lines.push(`Allocation: ${d.allocation_source}`);
|
|
186
|
+
lines.push("");
|
|
187
|
+
}
|
|
188
|
+
if (puzzle.operations && puzzle.operations.operations.length > 0) {
|
|
189
|
+
lines.push("─ Operations ──────────────");
|
|
190
|
+
for (const op of puzzle.operations.operations)
|
|
191
|
+
lines.push(` - ${JSON.stringify(op)}`);
|
|
192
|
+
lines.push("");
|
|
193
|
+
}
|
|
194
|
+
if (puzzle.logic) {
|
|
195
|
+
lines.push("─ Logic ──────────────");
|
|
196
|
+
lines.push(`State transitions: ${puzzle.logic.state_transitions.length}`);
|
|
197
|
+
lines.push(`Field mutex rules: ${puzzle.logic.field_mutex.length}`);
|
|
198
|
+
lines.push(`Cross-object flows: ${puzzle.logic.cross_object_flows.length}`);
|
|
199
|
+
lines.push("");
|
|
200
|
+
}
|
|
201
|
+
const violations = validateConstraints(puzzle);
|
|
202
|
+
if (violations.length > 0) {
|
|
203
|
+
lines.push("─ Constraint Violations ──────────────");
|
|
204
|
+
for (const v of violations)
|
|
205
|
+
lines.push(` [${v.severity}] ${v.constraint_id}: ${v.message}`);
|
|
206
|
+
lines.push("");
|
|
207
|
+
}
|
|
208
|
+
return lines.join("\n");
|
|
209
|
+
}
|
|
210
|
+
export function verifySnapshotMechanism(puzzle) {
|
|
211
|
+
if (!puzzle.binding) {
|
|
212
|
+
return { snapshot_understood: false, message: "Binding not specified — cannot verify snapshot" };
|
|
213
|
+
}
|
|
214
|
+
if (puzzle.binding.machine_snapshot && !puzzle.data_source) {
|
|
215
|
+
return {
|
|
216
|
+
snapshot_understood: false,
|
|
217
|
+
message: "machine_snapshot set but data_source missing — cannot confirm snapshot semantics",
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
if (puzzle.binding.machine_snapshot && puzzle.data_source?.machine_source !== "service_machine_snapshot") {
|
|
221
|
+
return {
|
|
222
|
+
snapshot_understood: false,
|
|
223
|
+
message: `machine_source is ${puzzle.data_source?.machine_source}, expected "service_machine_snapshot"`,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
snapshot_understood: true,
|
|
228
|
+
message: "Snapshot mechanism correctly captured: machine is copied from service.machine at buy time",
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
export function inferLifecyclePhase(order) {
|
|
232
|
+
if (order.claimed_by)
|
|
233
|
+
return "P-O-04_Claimed";
|
|
234
|
+
if (order.progress) {
|
|
235
|
+
if (order.progress_at_terminal)
|
|
236
|
+
return "P-O-05_Completed";
|
|
237
|
+
if (order.progress_at_cancel)
|
|
238
|
+
return "P-O-06_Cancelled";
|
|
239
|
+
return "P-O-02_Progressing";
|
|
240
|
+
}
|
|
241
|
+
if (order.dispute && order.dispute.length > 0)
|
|
242
|
+
return "P-O-03_Disputed";
|
|
243
|
+
return "P-O-01_Created";
|
|
244
|
+
}
|
|
245
|
+
export function matchSceneFromPuzzle(puzzle) {
|
|
246
|
+
if (!puzzle.intent)
|
|
247
|
+
return undefined;
|
|
248
|
+
return inferSceneFromIntent(puzzle.intent.rule_sentence) ?? inferSceneFromIntent(puzzle.intent.action);
|
|
249
|
+
}
|
|
250
|
+
export function listAllScenes() {
|
|
251
|
+
return ORDER_SCENES;
|
|
252
|
+
}
|
|
253
|
+
export function lookupScene(id) {
|
|
254
|
+
return findSceneById(id);
|
|
255
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type OrderScene, type OrderPermissionLayer } from "./order-ledger.js";
|
|
2
|
+
export type OrderRiskLevel = "CRITICAL" | "HIGH" | "MEDIUM" | "LOW";
|
|
3
|
+
export type OrderRiskCategory = "structural" | "semantic" | "authority" | "lifecycle" | "cross_object";
|
|
4
|
+
export interface OrderRisk {
|
|
5
|
+
id: string;
|
|
6
|
+
level: OrderRiskLevel;
|
|
7
|
+
category: OrderRiskCategory;
|
|
8
|
+
title: string;
|
|
9
|
+
description: string;
|
|
10
|
+
affected_stakeholders: OrderStakeholder[];
|
|
11
|
+
scenario: string;
|
|
12
|
+
mitigation: string;
|
|
13
|
+
evidence?: string;
|
|
14
|
+
}
|
|
15
|
+
export type OrderStakeholder = "owner" | "agent" | "arbitrator" | "service_provider" | "system";
|
|
16
|
+
export interface OrderRiskRule {
|
|
17
|
+
id: string;
|
|
18
|
+
category: OrderRiskCategory;
|
|
19
|
+
trigger: string;
|
|
20
|
+
check: (ctx: OrderRiskCheckContext) => OrderRisk | null;
|
|
21
|
+
}
|
|
22
|
+
export interface OrderRiskCheckContext {
|
|
23
|
+
object?: string;
|
|
24
|
+
is_buy_operation?: boolean;
|
|
25
|
+
agent_set?: {
|
|
26
|
+
agents: string[];
|
|
27
|
+
};
|
|
28
|
+
current_dispute_count?: number;
|
|
29
|
+
claimed_by_set?: boolean;
|
|
30
|
+
progress_bound?: boolean;
|
|
31
|
+
operation?: "agent_set" | "required_info_update" | "progress_advance" | "arb_confirm" | "arb_objection" | "arb_claim_compensation" | "receive" | "transfer_to" | "service_buy";
|
|
32
|
+
items?: {
|
|
33
|
+
name: string;
|
|
34
|
+
price: string;
|
|
35
|
+
quantity: string;
|
|
36
|
+
wip_hash: string;
|
|
37
|
+
}[];
|
|
38
|
+
service_published?: boolean;
|
|
39
|
+
service_paused?: boolean;
|
|
40
|
+
current_service_machine?: string;
|
|
41
|
+
order_machine_snapshot?: string;
|
|
42
|
+
progress_at_terminal?: boolean;
|
|
43
|
+
transfer_to_new_owner?: string;
|
|
44
|
+
caller_is_owner?: boolean;
|
|
45
|
+
caller_is_agent?: boolean;
|
|
46
|
+
}
|
|
47
|
+
export declare const ORDER_RISK_VERSION = "1.0.0";
|
|
48
|
+
export declare function getAllOrderRiskRules(): OrderRiskRule[];
|
|
49
|
+
export declare function getOrderRiskRulesCount(): number;
|
|
50
|
+
export declare function getOrderRiskRulesByCategory(category: OrderRiskCategory): OrderRiskRule[];
|
|
51
|
+
export declare function getOrderRiskRuleById(id: string): OrderRiskRule | undefined;
|
|
52
|
+
export interface OrderRiskAssessment {
|
|
53
|
+
summary: string;
|
|
54
|
+
scene?: OrderScene;
|
|
55
|
+
risks: OrderRisk[];
|
|
56
|
+
overall_risk: OrderRiskLevel;
|
|
57
|
+
risks_by_category: Partial<Record<OrderRiskCategory, number>>;
|
|
58
|
+
stakeholder_advice: Partial<Record<OrderStakeholder, string[]>>;
|
|
59
|
+
needs_human_review: boolean;
|
|
60
|
+
}
|
|
61
|
+
export declare function assessOrderRisks(ctx: OrderRiskCheckContext): OrderRiskAssessment;
|
|
62
|
+
export declare function checkPermissionLayer(operation: string, caller_is_owner: boolean, caller_is_agent: boolean): {
|
|
63
|
+
allowed: boolean;
|
|
64
|
+
layer: OrderPermissionLayer;
|
|
65
|
+
reason?: string;
|
|
66
|
+
};
|