@wowok/agent-mcp 3.3.0 → 3.3.2

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 (167) hide show
  1. package/dist/chain-semantics/field-capability.js +1 -1
  2. package/dist/chain-semantics/freeze-map.js +1 -1
  3. package/dist/chain-semantics/fund-flow.js +1 -1
  4. package/dist/chain-semantics/guard-verbs.js +1 -1
  5. package/dist/chain-semantics/object-graph.js +1 -1
  6. package/dist/composition/audit.d.ts +5 -0
  7. package/dist/composition/audit.js +1 -1
  8. package/dist/composition/blueprint-view.d.ts +0 -1
  9. package/dist/composition/blueprint-view.js +1 -1
  10. package/dist/composition/compile.d.ts +4 -2
  11. package/dist/composition/compile.js +1 -1
  12. package/dist/composition/inflight.d.ts +8 -4
  13. package/dist/composition/inflight.js +1 -1
  14. package/dist/customer/industry-risks.js +1 -1
  15. package/dist/customer/user-preferences.js +1 -1
  16. package/dist/extensions/business-modules.d.ts +7 -2
  17. package/dist/extensions/business-modules.js +1 -1
  18. package/dist/extensions/industry-audit.spec.js +1 -1
  19. package/dist/extensions/industry-pack.d.ts +3 -2
  20. package/dist/extensions/industry-pack.js +1 -1
  21. package/dist/extensions/modes.js +1 -1
  22. package/dist/graph/onchain/project-relationship.js +1 -1
  23. package/dist/knowledge/acquisition-flywheel.js +1 -1
  24. package/dist/knowledge/allocation-ledger.d.ts +4 -1
  25. package/dist/knowledge/allocation-ledger.js +1 -1
  26. package/dist/knowledge/allocation-puzzle.d.ts +1 -0
  27. package/dist/knowledge/allocation-puzzle.js +1 -1
  28. package/dist/knowledge/allocation-risk.d.ts +1 -1
  29. package/dist/knowledge/allocation-risk.js +1 -1
  30. package/dist/knowledge/arb-fund-facts.d.ts +5 -0
  31. package/dist/knowledge/arb-fund-facts.js +1 -1
  32. package/dist/knowledge/audit-rules.d.ts +4 -3
  33. package/dist/knowledge/audit-rules.js +1 -1
  34. package/dist/knowledge/baselines/rules/plan.json +48 -2
  35. package/dist/knowledge/baselines/rules/reward.json +1 -1
  36. package/dist/knowledge/builtin-templates.d.ts +9 -1
  37. package/dist/knowledge/builtin-templates.js +1 -1
  38. package/dist/knowledge/discount-threshold.js +1 -1
  39. package/dist/knowledge/guard-bindings.js +1 -1
  40. package/dist/knowledge/guard-design-patterns.js +1 -1
  41. package/dist/knowledge/guard-field-cognition.js +1 -1
  42. package/dist/knowledge/guard-lint.js +1 -1
  43. package/dist/knowledge/guard-submission-brief.d.ts +5 -0
  44. package/dist/knowledge/guard-submission-brief.js +1 -1
  45. package/dist/knowledge/guard-submission-prompt.d.ts +2 -1
  46. package/dist/knowledge/guard-submission-prompt.js +1 -1
  47. package/dist/knowledge/guard-templates.d.ts +1 -1
  48. package/dist/knowledge/guard-templates.js +1 -1
  49. package/dist/knowledge/industry-generalizer.js +1 -1
  50. package/dist/knowledge/industry-registry.js +1 -1
  51. package/dist/knowledge/industry-strategy.js +1 -1
  52. package/dist/knowledge/reward-ledger.js +1 -1
  53. package/dist/knowledge/reward-puzzle.d.ts +1 -1
  54. package/dist/knowledge/reward-risk.d.ts +1 -1
  55. package/dist/knowledge/scenario-modes.d.ts +2 -2
  56. package/dist/knowledge/scenario-modes.js +1 -1
  57. package/dist/knowledge/scenario-topology.js +1 -1
  58. package/dist/knowledge/strategy-manuals.js +1 -1
  59. package/dist/knowledge/template-index.d.ts +19 -0
  60. package/dist/knowledge/template-index.js +1 -0
  61. package/dist/knowledge/template-loader.d.ts +36 -0
  62. package/dist/knowledge/template-loader.js +1 -1
  63. package/dist/knowledge/template-registry.js +1 -1
  64. package/dist/knowledge/template-scanner.d.ts +7 -0
  65. package/dist/knowledge/template-scanner.js +1 -1
  66. package/dist/knowledge/tool-constraints.js +1 -1
  67. package/dist/knowledge/workflow-guidance.js +1 -1
  68. package/dist/monitor/MonitorLoop.js +1 -1
  69. package/dist/participation/radar-core.d.ts +1 -0
  70. package/dist/participation/radar-core.js +1 -1
  71. package/dist/persona/defaults.js +1 -1
  72. package/dist/persona/topology-focus.js +1 -1
  73. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  74. package/dist/playbooks/service-build/game-theory.d.ts +4 -1
  75. package/dist/playbooks/service-build/game-theory.js +1 -1
  76. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  77. package/dist/playbooks/service-build/merchant-guide.d.ts +25 -1
  78. package/dist/playbooks/service-build/merchant-guide.js +1 -1
  79. package/dist/playbooks/service-build/migration-planner.js +1 -1
  80. package/dist/playbooks/service-build/object-panorama.js +1 -1
  81. package/dist/playbooks/service-build/participation-radar.js +1 -1
  82. package/dist/playbooks/service-build/pipeline-actions.d.ts +4 -1
  83. package/dist/playbooks/service-build/pipeline-actions.js +1 -1
  84. package/dist/playbooks/service-build/relationship-profile.js +1 -1
  85. package/dist/playbooks/service-build/service-panorama.d.ts +4 -0
  86. package/dist/playbooks/service-build/service-panorama.js +1 -1
  87. package/dist/playbooks/service-build/service-quote.js +1 -1
  88. package/dist/relationship/derivation.d.ts +1 -1
  89. package/dist/review/index.js +1 -1
  90. package/dist/rules.js +1 -1
  91. package/dist/safety/confirm-gate.js +1 -1
  92. package/dist/schema/benchmark-migration/index.d.ts +35 -0
  93. package/dist/schema/benchmark-migration/index.js +1 -1
  94. package/dist/schema/call/allocation.d.ts +46 -3
  95. package/dist/schema/call/allocation.js +1 -1
  96. package/dist/schema/call/contact.js +1 -1
  97. package/dist/schema/call/guard.js +1 -1
  98. package/dist/schema/call/handler.js +1 -1
  99. package/dist/schema/call/order.js +1 -1
  100. package/dist/schema/call/progress.d.ts +6 -3
  101. package/dist/schema/call/progress.js +1 -1
  102. package/dist/schema/call/repository.js +1 -1
  103. package/dist/schema/call/reward.d.ts +2 -2
  104. package/dist/schema/call/reward.js +1 -1
  105. package/dist/schema/call/semantic.js +1 -1
  106. package/dist/schema/call/service.d.ts +8 -4
  107. package/dist/schema/call/service.js +1 -1
  108. package/dist/schema/common/index.js +1 -1
  109. package/dist/schema/goal/index.d.ts +54 -0
  110. package/dist/schema/goal/planning.d.ts +86 -0
  111. package/dist/schema/goal/planning.js +1 -1
  112. package/dist/schema/local/index.d.ts +39 -0
  113. package/dist/schema/local/index.js +1 -1
  114. package/dist/schema/operations.d.ts +20 -5
  115. package/dist/schema/operations.js +1 -1
  116. package/dist/schema/query/bi.d.ts +2 -0
  117. package/dist/schema/query/bi.js +1 -1
  118. package/dist/schema/query/index.d.ts +24 -12
  119. package/dist/schema/query/index.js +1 -1
  120. package/dist/schema/schema-version.d.ts +1 -1
  121. package/dist/schema/schema-version.js +1 -1
  122. package/dist/schema/workspace/index.d.ts +9 -0
  123. package/dist/schema/workspace/index.js +1 -1
  124. package/dist/schema-query-impl/index.js +1 -1
  125. package/dist/schemas/account_operation.output.json +28 -3
  126. package/dist/schemas/benchmark_migration_operation.schema.json +87 -0
  127. package/dist/schemas/goal_operation.schema.json +94 -0
  128. package/dist/schemas/index.json +1 -1
  129. package/dist/schemas/onchain_operations.output.json +1 -1
  130. package/dist/schemas/onchain_operations.schema.json +409 -119
  131. package/dist/schemas/onchain_operations_allocation.schema.json +290 -6
  132. package/dist/schemas/onchain_operations_arbitration.schema.json +2 -2
  133. package/dist/schemas/onchain_operations_contact.schema.json +2 -2
  134. package/dist/schemas/onchain_operations_demand.schema.json +3 -3
  135. package/dist/schemas/onchain_operations_gen_passport.schema.json +1 -1
  136. package/dist/schemas/onchain_operations_guard.schema.json +63 -63
  137. package/dist/schemas/onchain_operations_machine.schema.json +1 -1
  138. package/dist/schemas/onchain_operations_order.schema.json +2 -2
  139. package/dist/schemas/onchain_operations_progress.schema.json +7 -3
  140. package/dist/schemas/onchain_operations_proof.schema.json +1 -1
  141. package/dist/schemas/onchain_operations_repository.schema.json +2 -2
  142. package/dist/schemas/onchain_operations_reward.schema.json +8 -8
  143. package/dist/schemas/onchain_operations_service.schema.json +20 -18
  144. package/dist/schemas/onchain_operations_treasury.schema.json +7 -7
  145. package/dist/schemas/query_toolkit.output.json +67 -53
  146. package/dist/schemas/workflow_operation.schema.json +1 -1
  147. package/dist/schemas/workspace_operation.output.json +23 -3
  148. package/dist/schemas/workspace_operation.schema.json +3 -3
  149. package/dist/tools/handlers/benchmark-migration.js +1 -1
  150. package/dist/tools/handlers/config.js +1 -1
  151. package/dist/tools/handlers/file-export.js +1 -1
  152. package/dist/tools/handlers/industry-pack.d.ts +1 -0
  153. package/dist/tools/handlers/industry-pack.js +1 -1
  154. package/dist/tools/handlers/local.js +1 -1
  155. package/dist/tools/handlers/onchain.d.ts +24 -0
  156. package/dist/tools/handlers/onchain.js +1 -1
  157. package/dist/tools/handlers/query.js +1 -1
  158. package/dist/tools/handlers/review-chain.d.ts +1 -1
  159. package/dist/tools/handlers/review-chain.js +1 -1
  160. package/dist/tools/handlers/schema-query.js +1 -1
  161. package/dist/tools/handlers/workflow.js +1 -1
  162. package/dist/tools/handlers/workspace.js +1 -1
  163. package/dist/tools/registry/agent.js +1 -1
  164. package/dist/tools/registry/local.js +1 -1
  165. package/dist/tools/wip-deploy-assist.js +1 -1
  166. package/dist/tools/wrap.js +1 -1
  167. package/package.json +2 -2
@@ -1 +1 @@
1
- import{handleIntentRadar}from'../handlers/intent-radar.js';import{handleGoalOperation}from'../handlers/goal.js';import{handleEmployeeOperation}from'../handlers/employee.js';import{createToolMeta,IntentRadarInputSchema,IntentRadarOutputSchema,GoalOperationInputSchema,EmployeeOperationInputSchema,EmployeeOperationOutputSchema}from'../../schema/index.js';export const AGENT_TOOLS=[{'name':'intent_radar','handler':handleIntentRadar,'config':{'title':'📡\x20Intent\x20Radar\x20-\x20User\x20Intent\x20×\x20Chain\x20Event\x20Matching','summary':'Persist\x20user\x20intents\x20and\x20match\x20them\x20against\x20on-chain\x20events.','description':'Persist\x20the\x20user\x27s\x20standing\x20business\x20intents\x20and\x20match\x20them\x20against\x20on-chain\x20events/data.\x20'+'This\x20closes\x20the\x20loop:\x20user\x20records\x20an\x20intent\x20(e.g.\x20\x27find\x20subscription\x20services\x27),\x20'+'the\x20system\x20pulls\x20recent\x20chain\x20events\x20and\x20returns\x20ranked\x20hits.\x0a\x0a'+'Actions:\x0a'+'\x20\x20•\x20save\x20—\x20record\x20an\x20intent\x20(industry/keywords\x20resolved\x20once;\x20optionally\x20bound\x20to\x20an\x20account).\x0a'+'\x20\x20•\x20list\x20—\x20list\x20persisted\x20intents\x20(optionally\x20filtered\x20by\x20account).\x0a'+'\x20\x20•\x20remove\x20—\x20delete\x20an\x20intent.\x0a'+'\x20\x20•\x20match\x20—\x20score\x20events\x20against\x20intents\x20(pass\x20`events`\x20from\x20onchain_events,\x20or\x20auto-pull\x20recent\x20events).\x0a\x0a'+'Watchable\x20event\x20families\x20(target_types):\x20market\x20opportunity\x20(ServiceEvent,\x20DemandChangedEvent,\x20'+'DemandPresentEvent\x20—\x20the\x20supply/demand\x20discovery\x20signals),\x20order/workflow\x20(NewOrderEvent,\x20'+'ProgressEvent),\x20dispute\x20(ArbEvent,\x20VoteEvent,\x20FeedbackEvent),\x20reputation\x20(DemandFeedbackEvent,\x20'+'NewEntityEvent),\x20fund\x20flow\x20(AllocationEvent,\x20TreasuryEvent,\x20RewardClaimEvent,\x20RewardFundEvent,\x20'+'RewardWithdrawEvent,\x20NewPaymentEvent),\x20audit/watch\x20(PermissionChangedEvent,\x20'+'RepositoryDataOverwriteEvent).\x20Each\x20hit\x27s\x20business_meaning\x20comes\x20from\x20the\x20Event\x20Semantics\x20Registry.\x0a\x0a'+'Read-only\x20w.r.t.\x20chain\x20state\x20(reads\x20events\x20+\x20local\x20intent\x20store\x20only).\x0a\x0a'+'💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27intent_radar\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema.','inputSchema':IntentRadarInputSchema,'outputSchema':IntentRadarOutputSchema,'annotations':{'readOnlyHint':!![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':![]},'_meta':createToolMeta('intent',['intent','radar','match','event','watch','business','intelligence'])}},{'name':'goal_operation','handler':handleGoalOperation,'config':{'title':'🎯\x20Goal\x20-\x20Goal-Driven\x20Lifecycle\x20(GoalEngine)','summary':'Goal-driven\x20lifecycle:\x20create/list/get/approve/advance/pause/complete/abandon/delete\x20goals\x20+\x20event-bridged\x20advancement\x20suggestions\x20+\x20G5\x20boundaries/pursue/next-steps\x20(self-driving\x20within\x20user-granted\x20autonomy).','description':'GoalEngine\x20Agent\x20portal\x20(K3\x2024)\x20—\x20the\x20business-layer\x20storyline\x20ABOVE\x20projects/tasks:\x20'+'record\x20a\x20user\x20goal\x20once,\x20then\x20track\x20it\x20through\x20the\x20nine-station\x20lifecycle\x20'+'RECOGNIZE\x20→\x20CONFIRM\x20→\x20BIND\x20→\x20PLAN\x20→\x20APPROVE\x20→\x20ACT\x20→\x20MONITOR\x20→\x20COMPLETE\x20(→\x20REFLECT).\x20'+'Near-duplicate\x20create\x20calls\x20ADOPT\x20the\x20existing\x20active\x20goal\x20(same\x20type\x20+\x20account\x20+\x20similar\x20intent)\x20'+'instead\x20of\x20forking\x20a\x20second\x20storyline.\x0a\x0a'+'Actions:\x0a'+'\x20\x20•\x20create\x20—\x20record\x20a\x20goal\x20from\x20intent_text\x20(goal_type\x20auto-classified;\x20override\x20with\x20goal_type).\x20'+'Pass\x20account\x20to\x20BIND\x20immediately\x20(local-account\x20preflight;\x20goal\x20starts\x20at\x20\x27bound\x27).\x20'+'Goal\x20types\x20with\x20a\x20dedicated\x20playbook\x20(publish_service,\x20fulfill_order,\x20capture_demand,\x20publish_demand,\x20'+'purchase_service)\x20AUTOMATICALLY\x20attach\x20a\x20TaskProcess\x20(K3\x2024\x20§3.5):\x20the\x20long-task\x20carrier\x20with\x20a\x20named\x20'+'stage\x20sequence\x20+\x20events/problems/feedback/decisions\x20memory\x20streams;\x20create_process=true\x20forces\x20one\x20for\x20'+'the\x20other\x20(generic)\x20goal\x20types.\x0a'+'\x20\x20•\x20list\x20—\x20enumerate\x20goals\x20(stage/account\x20filters;\x20include_finished\x20for\x20completed/abandoned)\x20+\x20per-stage\x20counts.\x0a'+'\x20\x20•\x20get\x20—\x20one\x20goal\x27s\x20full\x20record\x20(stage,\x20objects,\x20monitor\x20bindings,\x20approvals,\x20outcome).\x20Goals\x20with\x20a\x20'+'TaskProcess\x20also\x20return\x20process_summary\x20(current\x20stage,\x20per-stage\x20progress,\x20open\x20problems,\x20pending\x20'+'suggestions,\x20last\x20events,\x20feedback\x20count)\x20—\x20the\x20interrupted-task\x20resume\x20surface:\x20read\x20it,\x20then\x20continue\x20'+'with\x20advance\x20(there\x20is\x20no\x20separate\x20resume\x20action).\x0a'+'\x20\x20•\x20approve\x20—\x20APPROVE\x20station:\x20records\x20a\x20plan\x20approval;\x20while\x20active,\x20fail-open\x20ConfirmGate\x20rules\x20'+'(standard/none\x20levels)\x20auto-pass\x20for\x20calls\x20carrying\x20env.plan_approval=<goal\x20id>,\x20and\x20successful\x20'+'creation\x20operations\x20carrying\x20that\x20stamp\x20auto-register\x20their\x20created\x20objects\x20into\x20the\x20goal\x20'+'(ACT\x20station\x20\x27execution\x20registers\x27).\x20'+'Fail-closed\x20levels\x20(irreversible/publish/amount)\x20ALWAYS\x20still\x20ask.\x0a'+'\x20\x20•\x20advance\x20—\x20forward\x20stage\x20move\x20(BIND/PLAN/ACT/MONITOR)\x20and/or\x20ACT\x20object\x20registration\x20'+'(objects:\x20[{type,\x20object}];\x20also\x20written\x20back\x20into\x20the\x20goal\x27s\x20TaskProcess\x20manifest).\x20'+'Entering\x20\x27monitoring\x27\x20auto-binds\x20monitor\x20focus\x20for\x20the\x20goal\x27s\x20objects\x20'+'(and\x20a\x20radar\x20intent\x20for\x20demand\x20goals),\x20so\x20progress\x20surfaces\x20in\x20the\x20monitor\x20todo\x20stream.\x0a'+'\x20\x20•\x20pause\x20—\x20off-axis\x20hold\x20from\x20any\x20non-terminal\x20stage;\x20resume\x20via\x20advance.\x0a'+'\x20\x20•\x20complete\x20—\x20COMPLETE\x20station:\x20verifies\x20the\x20goal-type\x20completion\x20conjunction\x20against\x20chain\x20state\x20'+'(e.g.\x20publish_service\x20needs\x20a\x20live\x20Service;\x20purchase_service\x20needs\x20a\x20completed\x20Order).\x20'+'force=true\x20skips\x20verification\x20(audited\x20as\x20outcome.forced).\x20Tears\x20down\x20the\x20goal\x27s\x20monitor\x20bindings.\x20'+'Pass\x20feedback\x20{sentiment,\x20comment}\x20to\x20record\x20user\x20feedback\x20on\x20the\x20process;\x20the\x20outcome\x20is\x20distilled\x20'+'into\x20the\x20experience\x20layer\x20(REFLECT).\x0a'+'\x20\x20•\x20abandon\x20—\x20terminal\x20give-up\x20(reason\x20required);\x20same\x20monitor\x20teardown,\x20outcome.success=false.\x0a'+'\x20\x20•\x20delete\x20—\x20housekeeping:\x20remove\x20a\x20TERMINAL\x20goal\x20record\x20entirely\x20(record\x20+\x20stage-index\x20entries\x20+\x20'+'TaskProcess\x20dir).\x20force=true\x20also\x20allows\x20non-terminal\x20goals\x20(monitor\x20teardown\x20runs\x20first).\x0a'+'\x20\x20•\x20suggestions\x20—\x20T5-C:\x20the\x20goal\x27s\x20PENDING\x20advancement\x20suggestions\x20(monitor-bridged\x20POSITIVE\x20events:\x20'+'first\x20order\x20received\x20→\x20enter\x20monitoring;\x20arbitration\x20finished\x20→\x20verify\x20completion;\x20service\x20live\x20→\x20'+'verify\x20completion)\x20joined\x20with\x20its\x20OPEN\x20problems\x20—\x20the\x20single\x20consumption\x20face\x20for\x20\x27what\x20wants\x20my\x20'+'decision\x20on\x20this\x20goal\x27.\x20include_resolved=true\x20also\x20returns\x20confirmed/dismissed\x20ones.\x0a'+'\x20\x20•\x20suggestion_resolve\x20—\x20one-shot\x20decision\x20on\x20one\x20suggestion:\x20confirm\x20(apply=true\x20runs\x20the\x20suggested\x20'+'move\x20through\x20the\x20NORMAL\x20engine\x20stations\x20—\x20advance/complete\x20with\x20chain\x20verification\x20still\x20gating;\x20'+'apply=false\x20just\x20acknowledges)\x20or\x20dismiss\x20(note\x20optional,\x20audited).\x20A\x20suggestion\x20NEVER\x20auto-applies;\x20'+'when\x20applying\x20fails\x20the\x20suggestion\x20stays\x20pending\x20and\x20apply_error\x20explains\x20why.\x0a'+'\x20\x20•\x20boundaries\x20—\x20G5\x20CONFIRM\x20station:\x20the\x20boundary\x20questions\x20to\x20ask\x20the\x20user\x20BEFORE\x20the\x20goal\x20pursues\x20'+'autonomously\x20(budget\x20/\x20deadline\x20/\x20acceptance\x20requirements\x20/\x20autonomy)\x20+\x20the\x20current\x20boundaries\x20and\x20'+'what\x20is\x20still\x20missing.\x0a'+'\x20\x20•\x20boundaries_set\x20—\x20G5\x20CONFIRM\x20station:\x20set/merge-patch\x20the\x20boundaries.\x20budget\x20=\x20total\x20spend\x20ceiling\x20'+'(smallest\x20unit,\x20decimal\x20string;\x20over-budget\x20candidates\x20are\x20rejected,\x20never\x20asked),\x20deadline\x20=\x20ms\x20epoch\x20'+'(past\x20it\x20everything\x20stalls),\x20requirements\x20=\x20hard\x20acceptance\x20red\x20lines\x20(commitment\x20moves\x20wait\x20for\x20'+'verification),\x20autonomy\x20=\x20confirm_all\x20|\x20execute_low_risk\x20|\x20execute_all\x20(irreversible/publish/amount\x20'+'operations\x20ALWAYS\x20ask\x20regardless).\x20Setting\x20any\x20field\x20marks\x20CONFIRM\x20done.\x0a'+'\x20\x20•\x20pursue\x20—\x20G5\x20self-driving\x20tick:\x20gathers\x20the\x20goal\x27s\x20pending\x20suggestions\x20+\x20the\x20engine\x20completion\x20'+'check\x20(monitoring\x20station),\x20runs\x20them\x20through\x20the\x20boundary\x20filter\x20and\x20the\x20autonomy\x20mapping,\x20then\x20'+'APPLIES\x20the\x20allowed\x20moves\x20through\x20the\x20normal\x20engine\x20stations\x20(execute)\x20or\x20surfaces\x20them\x20as\x20pending\x20'+'suggestions\x20(ask_user).\x20Boundary\x20violations\x20stall\x20and\x20are\x20reported.\x20A\x20paused\x20goal\x20does\x20not\x20pursue.\x20'+'Call\x20it\x20after\x20monitor\x20events\x20/\x20periodically\x20—\x20the\x20monitor\x20loop\x20bridges\x20events\x20into\x20suggestions\x20in\x20'+'the\x20background\x20either\x20way.\x0a'+'\x20\x20•\x20next_steps\x20—\x20G5\x20user-driven\x20follow-ups:\x20recommended\x20next\x20steps\x20for\x20this\x20goal\x20—\x20station\x20steps\x20'+'(confirm\x20boundaries,\x20bind,\x20resolve\x20pending\x20suggestions,\x20advance),\x20the\x20G2\x20role-interest\x20view\x20pointer\x20'+'(when\x20the\x20goal\x20has\x20objects\x20+\x20a\x20binding:\x20operable\x20forwards,\x20blocked\x20moves,\x20risks\x20via\x20topology_bi\x20'+'interest_role),\x20and\x20business-loop\x20follow-ups\x20(what\x20goals\x20naturally\x20follow\x20this\x20one).\x20Works\x20for\x20'+'completed\x20goals\x20too\x20(follow-ups\x20lead).\x0a'+'\x20\x20•\x20analyze_intent\x20(C1)\x20—\x20natural-language\x20business\x20intent\x20→\x20parsed\x20intent\x20(primary/secondary\x20objects,\x20'+'detected\x20scenes,\x20industry)\x20+\x20per-object\x20puzzle\x20snapshots\x20+\x20recommended\x20creation\x20order.\x0a'+'\x20\x20•\x20aggregate_risks\x20(C2)\x20—\x20puzzle\x20snapshots\x20→\x20cross-object\x20risk\x20calibration\x20(CRITICAL/HIGH/MEDIUM/LOW/INFO)\x20'+'with\x20blocking\x20status\x20(STATIC_ANALYZERS_CLEAN/RISK_BLOCKED/RISK_PENDING_CONFIRM).\x20Omit\x20\x27puzzles\x27\x20but\x20pass\x20\x27intent\x27\x20'+'to\x20run\x20C1→C2\x20in\x20one\x20call.\x0a'+'\x20\x20•\x20trace_substeps\x20(C3)\x20—\x20substep\x20execution\x20records\x20→\x20DAG\x20coherence\x20analysis\x20(dangling\x20inputs,\x20circular\x20'+'refs,\x20missing\x20outputs,\x20cross-step\x20breaks,\x20topological\x20order,\x20D-10\x20verdict).\x0a'+'\x20\x20•\x20merchant_guide\x20—\x2010-step\x20merchant\x20onboarding\x20wizard:\x20intent\x20→\x20industry\x20confirmation\x20→\x20module\x20adoption\x20→\x20'+'Blueprint\x20(L1\x20plan\x20projection)\x20→\x20evaluation\x20preview\x20→\x20harness\x20check\x20→\x20creation\x20plan.\x20Stateless\x20(pass\x20'+'guide_state/guide_confirm\x20to\x20advance);\x20NEVER\x20executes\x20on-chain\x20operations.\x0a\x0a'+'Local\x20goal\x20state\x20only;\x20the\x20only\x20chain\x20access\x20is\x20READ-ONLY\x20completion\x20verification\x20(complete\x20/\x20the\x20pursue\x20tick\x27s\x20completion\x20check).\x0a\x0a'+'💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27goal_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema.','inputSchema':GoalOperationInputSchema,'annotations':{'readOnlyHint':![],'destructiveHint':![],'idempotentHint':![],'openWorldHint':![]},'_meta':createToolMeta('goal',['goal','lifecycle','plan','approve','monitor','complete','abandon','objective'])}},{'name':'employee_operation','handler':handleEmployeeOperation,'config':{'title':'👥\x20Employee\x20-\x20Merchant\x20Staff\x20Profile','summary':'Merchant\x20employee\x20profile,\x20KPI\x20assessment,\x20liability\x20resolution.','description':'Read/write\x20a\x20merchant\x20employee\x27s\x20LOCAL\x20organizational\x20profile:\x20department\x20'+'(customer_service/logistics/finance/operations),\x20liability\x20(merchant_bears/self_bears/hybrid),\x20'+'and\x20response-time\x20budget.\x20LOCAL\x20ONLY\x20—\x20never\x20mutates\x20chain\x20state;\x20the\x20employee\x27s\x20on-chain\x20'+'authorization\x20lives\x20in\x20the\x20merchant\x27s\x20Permission\x20(namedOperator/entity).\x0a\x0a'+'Actions:\x0a'+'\x20\x20•\x20set\x20—\x20persist\x20an\x20employee\x20profile\x20(validated:\x20department+liability\x20required,\x20budget\x20must\x20be\x20positive).\x0a'+'\x20\x20•\x20get\x20—\x20read\x20an\x20employee\x20profile\x20(null\x20when\x20absent).\x0a'+'\x20\x20•\x20remove\x20—\x20delete\x20an\x20employee\x20profile.\x0a'+'\x20\x20•\x20assess_kpi\x20—\x20measure\x20an\x20employee\x27s\x20node\x20reaction\x20speed\x20(assigned_at\x20→\x20advanced_at\x20vs\x20budget:\x20pass/warn/fail).\x20Timestamps:\x20pass\x20them\x20explicitly,\x20OR\x20pass\x20`progress`\x20(progress\x20object\x20address)\x20to\x20auto-derive\x20them\x20from\x20monitored\x20ProgressEvents\x20—\x20explicit\x20values\x20override\x20derived\x20ones.\x20Budget\x20precedence:\x20explicit\x20budget_ms\x20>\x20stored\x20profile\x20>\x2048h\x20default.\x0a'+'\x20\x20•\x20resolve_liability\x20—\x20resolve\x20who\x20internally\x20bears\x20an\x20employee-error\x20loss\x20(merchant/employee,\x20hybrid\x20threshold\x20split)\x20and\x20whether\x20the\x20order\x20user\x20must\x20be\x20compensated\x20BEFORE\x20the\x20workflow\x20resumes.\x20Outward\x20liability\x20toward\x20the\x20customer\x20is\x20ALWAYS\x20the\x20merchant\x27s.\x0a'+'\x20\x20•\x20suggest_incentive\x20—\x20the\x20employment\x20relationship\x27s\x20action\x20layer:\x20node\x20KPIs\x20(from\x20assess_kpi)\x20+\x20WIP\x20acceptance\x20evidence\x20+\x20liability\x20resolution\x20→\x20a\x20Reward\x20suggestion\x20(reward_grant\x20/\x20compensation_offset\x20/\x20correction_notice\x20/\x20none)\x20with\x20rationale\x20and\x20execution\x20hints.\x20Suggestion\x20ONLY\x20—\x20never\x20auto-executes;\x20the\x20merchant\x20confirms\x20and\x20runs\x20the\x20on-chain\x20reward/payment\x20ops\x20separately.\x0a\x0a'+'💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27employee_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema.','inputSchema':EmployeeOperationInputSchema,'outputSchema':EmployeeOperationOutputSchema,'annotations':{'readOnlyHint':![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':![]},'_meta':createToolMeta('employee',['employee','staff','merchant','department','kpi','liability','local'])}}];
1
+ import{handleIntentRadar}from'../handlers/intent-radar.js';import{handleGoalOperation}from'../handlers/goal.js';import{handleEmployeeOperation}from'../handlers/employee.js';import{createToolMeta,IntentRadarInputSchema,IntentRadarOutputSchema,GoalOperationInputSchema,EmployeeOperationInputSchema,EmployeeOperationOutputSchema}from'../../schema/index.js';export const AGENT_TOOLS=[{'name':'intent_radar','handler':handleIntentRadar,'config':{'title':'📡\x20Intent\x20Radar\x20-\x20User\x20Intent\x20×\x20Chain\x20Event\x20Matching','summary':'Persist\x20user\x20intents\x20and\x20match\x20them\x20against\x20on-chain\x20events.','description':'Persist\x20the\x20user\x27s\x20standing\x20business\x20intents\x20and\x20match\x20them\x20against\x20on-chain\x20events/data.\x20'+'This\x20closes\x20the\x20loop:\x20user\x20records\x20an\x20intent\x20(e.g.\x20\x27find\x20subscription\x20services\x27),\x20'+'the\x20system\x20pulls\x20recent\x20chain\x20events\x20and\x20returns\x20ranked\x20hits.\x0a\x0a'+'Actions:\x0a'+'\x20\x20•\x20save\x20—\x20record\x20an\x20intent\x20(industry/keywords\x20resolved\x20once;\x20optionally\x20bound\x20to\x20an\x20account).\x0a'+'\x20\x20•\x20list\x20—\x20list\x20persisted\x20intents\x20(optionally\x20filtered\x20by\x20account).\x0a'+'\x20\x20•\x20remove\x20—\x20delete\x20an\x20intent.\x0a'+'\x20\x20•\x20match\x20—\x20score\x20events\x20against\x20intents\x20(pass\x20`events`\x20from\x20onchain_events,\x20or\x20auto-pull\x20recent\x20events).\x0a\x0a'+'Watchable\x20event\x20families\x20(target_types):\x20market\x20opportunity\x20(ServiceEvent,\x20DemandChangedEvent,\x20'+'DemandPresentEvent\x20—\x20the\x20supply/demand\x20discovery\x20signals),\x20order/workflow\x20(NewOrderEvent,\x20'+'ProgressEvent),\x20dispute\x20(ArbEvent,\x20VoteEvent,\x20FeedbackEvent),\x20reputation\x20(DemandFeedbackEvent,\x20'+'NewEntityEvent),\x20fund\x20flow\x20(AllocationEvent,\x20TreasuryEvent,\x20RewardClaimEvent,\x20RewardFundEvent,\x20'+'RewardWithdrawEvent,\x20NewPaymentEvent),\x20audit/watch\x20(PermissionChangedEvent,\x20'+'RepositoryDataOverwriteEvent).\x20Each\x20hit\x27s\x20business_meaning\x20comes\x20from\x20the\x20Event\x20Semantics\x20Registry.\x0a\x0a'+'Read-only\x20w.r.t.\x20chain\x20state\x20(reads\x20events\x20+\x20local\x20intent\x20store\x20only).\x0a\x0a'+'💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27intent_radar\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema.','inputSchema':IntentRadarInputSchema,'outputSchema':IntentRadarOutputSchema,'annotations':{'readOnlyHint':!![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':![]},'_meta':createToolMeta('intent',['intent','radar','match','event','watch','business','intelligence'])}},{'name':'goal_operation','handler':handleGoalOperation,'config':{'title':'🎯\x20Goal\x20-\x20Goal-Driven\x20Lifecycle\x20(GoalEngine)','summary':'Goal-driven\x20lifecycle:\x20create/list/get/approve/advance/pause/complete/abandon/delete\x20goals\x20+\x20event-bridged\x20advancement\x20suggestions\x20+\x20G5\x20boundaries/pursue/next-steps\x20(self-driving\x20within\x20user-granted\x20autonomy).','description':'GoalEngine\x20Agent\x20portal\x20(K3\x2024)\x20—\x20the\x20business-layer\x20storyline\x20ABOVE\x20projects/tasks:\x20'+'record\x20a\x20user\x20goal\x20once,\x20then\x20track\x20it\x20through\x20the\x20nine-station\x20lifecycle\x20'+'RECOGNIZE\x20→\x20CONFIRM\x20→\x20BIND\x20→\x20PLAN\x20→\x20APPROVE\x20→\x20ACT\x20→\x20MONITOR\x20→\x20COMPLETE\x20(→\x20REFLECT).\x20'+'Near-duplicate\x20create\x20calls\x20ADOPT\x20the\x20existing\x20active\x20goal\x20(same\x20type\x20+\x20account\x20+\x20similar\x20intent)\x20'+'instead\x20of\x20forking\x20a\x20second\x20storyline.\x0a\x0a'+'Actions:\x0a'+'\x20\x20•\x20create\x20—\x20record\x20a\x20goal\x20from\x20intent_text\x20(goal_type\x20auto-classified;\x20override\x20with\x20goal_type).\x20'+'Pass\x20account\x20to\x20BIND\x20immediately\x20(local-account\x20preflight;\x20goal\x20starts\x20at\x20\x27bound\x27).\x20'+'Goal\x20types\x20with\x20a\x20dedicated\x20playbook\x20(publish_service,\x20fulfill_order,\x20capture_demand,\x20publish_demand,\x20'+'purchase_service)\x20AUTOMATICALLY\x20attach\x20a\x20TaskProcess\x20(K3\x2024\x20§3.5):\x20the\x20long-task\x20carrier\x20with\x20a\x20named\x20'+'stage\x20sequence\x20+\x20events/problems/feedback/decisions\x20memory\x20streams;\x20create_process=true\x20forces\x20one\x20for\x20'+'the\x20other\x20(generic)\x20goal\x20types.\x0a'+'\x20\x20•\x20list\x20—\x20enumerate\x20goals\x20(stage/account\x20filters;\x20include_finished\x20for\x20completed/abandoned)\x20+\x20per-stage\x20counts.\x0a'+'\x20\x20•\x20get\x20—\x20one\x20goal\x27s\x20full\x20record\x20(stage,\x20objects,\x20monitor\x20bindings,\x20approvals,\x20outcome).\x20Goals\x20with\x20a\x20'+'TaskProcess\x20also\x20return\x20process_summary\x20(current\x20stage,\x20per-stage\x20progress,\x20open\x20problems,\x20pending\x20'+'suggestions,\x20last\x20events,\x20feedback\x20count)\x20—\x20the\x20interrupted-task\x20resume\x20surface:\x20read\x20it,\x20then\x20continue\x20'+'with\x20advance\x20(there\x20is\x20no\x20separate\x20resume\x20action).\x0a'+'\x20\x20•\x20approve\x20—\x20APPROVE\x20station:\x20records\x20a\x20plan\x20approval;\x20while\x20active,\x20fail-open\x20ConfirmGate\x20rules\x20'+'(standard/none\x20levels)\x20auto-pass\x20for\x20calls\x20carrying\x20env.plan_approval=<goal\x20id>,\x20and\x20successful\x20'+'creation\x20operations\x20carrying\x20that\x20stamp\x20auto-register\x20their\x20created\x20objects\x20into\x20the\x20goal\x20'+'(ACT\x20station\x20\x27execution\x20registers\x27).\x20'+'Fail-closed\x20levels\x20(irreversible/publish/amount)\x20ALWAYS\x20still\x20ask.\x0a'+'\x20\x20•\x20advance\x20—\x20forward\x20stage\x20move\x20(BIND/PLAN/ACT/MONITOR)\x20and/or\x20ACT\x20object\x20registration\x20'+'(objects:\x20[{type,\x20object}];\x20also\x20written\x20back\x20into\x20the\x20goal\x27s\x20TaskProcess\x20manifest).\x20'+'Entering\x20\x27monitoring\x27\x20auto-binds\x20monitor\x20focus\x20for\x20the\x20goal\x27s\x20objects\x20'+'(and\x20a\x20radar\x20intent\x20for\x20demand\x20goals),\x20so\x20progress\x20surfaces\x20in\x20the\x20monitor\x20todo\x20stream.\x0a'+'\x20\x20•\x20pause\x20—\x20off-axis\x20hold\x20from\x20any\x20non-terminal\x20stage;\x20resume\x20via\x20advance.\x0a'+'\x20\x20•\x20complete\x20—\x20COMPLETE\x20station:\x20verifies\x20the\x20goal-type\x20completion\x20conjunction\x20against\x20chain\x20state\x20'+'(e.g.\x20publish_service\x20needs\x20a\x20live\x20Service;\x20purchase_service\x20needs\x20a\x20completed\x20Order).\x20'+'force=true\x20skips\x20verification\x20(audited\x20as\x20outcome.forced).\x20Tears\x20down\x20the\x20goal\x27s\x20monitor\x20bindings.\x20'+'Pass\x20feedback\x20{sentiment,\x20comment}\x20to\x20record\x20user\x20feedback\x20on\x20the\x20process;\x20the\x20outcome\x20is\x20distilled\x20'+'into\x20the\x20experience\x20layer\x20(REFLECT).\x0a'+'\x20\x20•\x20abandon\x20—\x20terminal\x20give-up\x20(reason\x20required);\x20same\x20monitor\x20teardown,\x20outcome.success=false.\x0a'+'\x20\x20•\x20delete\x20—\x20housekeeping:\x20remove\x20a\x20TERMINAL\x20goal\x20record\x20entirely\x20(record\x20+\x20stage-index\x20entries\x20+\x20'+'TaskProcess\x20dir).\x20force=true\x20also\x20allows\x20non-terminal\x20goals\x20(monitor\x20teardown\x20runs\x20first).\x0a'+'\x20\x20•\x20suggestions\x20—\x20T5-C:\x20the\x20goal\x27s\x20PENDING\x20advancement\x20suggestions\x20(monitor-bridged\x20POSITIVE\x20events:\x20'+'first\x20order\x20received\x20→\x20enter\x20monitoring;\x20arbitration\x20finished\x20→\x20verify\x20completion;\x20service\x20live\x20→\x20'+'verify\x20completion)\x20joined\x20with\x20its\x20OPEN\x20problems\x20—\x20the\x20single\x20consumption\x20face\x20for\x20\x27what\x20wants\x20my\x20'+'decision\x20on\x20this\x20goal\x27.\x20include_resolved=true\x20also\x20returns\x20confirmed/dismissed\x20ones.\x0a'+'\x20\x20•\x20suggestion_resolve\x20—\x20one-shot\x20decision\x20on\x20one\x20suggestion:\x20confirm\x20(apply=true\x20runs\x20the\x20suggested\x20'+'move\x20through\x20the\x20NORMAL\x20engine\x20stations\x20—\x20advance/complete\x20with\x20chain\x20verification\x20still\x20gating;\x20'+'apply=false\x20just\x20acknowledges)\x20or\x20dismiss\x20(note\x20optional,\x20audited).\x20A\x20suggestion\x20NEVER\x20auto-applies;\x20'+'when\x20applying\x20fails\x20the\x20suggestion\x20stays\x20pending\x20and\x20apply_error\x20explains\x20why.\x0a'+'\x20\x20•\x20boundaries\x20—\x20G5\x20CONFIRM\x20station:\x20the\x20boundary\x20questions\x20to\x20ask\x20the\x20user\x20BEFORE\x20the\x20goal\x20pursues\x20'+'autonomously\x20(budget\x20/\x20deadline\x20/\x20acceptance\x20requirements\x20/\x20autonomy)\x20+\x20the\x20current\x20boundaries\x20and\x20'+'what\x20is\x20still\x20missing.\x0a'+'\x20\x20•\x20boundaries_set\x20—\x20G5\x20CONFIRM\x20station:\x20set/merge-patch\x20the\x20boundaries.\x20budget\x20=\x20total\x20spend\x20ceiling\x20'+'(smallest\x20unit,\x20decimal\x20string;\x20over-budget\x20candidates\x20are\x20rejected,\x20never\x20asked),\x20deadline\x20=\x20ms\x20epoch\x20'+'(past\x20it\x20everything\x20stalls),\x20requirements\x20=\x20hard\x20acceptance\x20red\x20lines\x20(commitment\x20moves\x20wait\x20for\x20'+'verification),\x20autonomy\x20=\x20confirm_all\x20|\x20execute_low_risk\x20|\x20execute_all\x20(irreversible/publish/amount\x20'+'operations\x20ALWAYS\x20ask\x20regardless).\x20Setting\x20any\x20field\x20marks\x20CONFIRM\x20done.\x0a'+'\x20\x20•\x20pursue\x20—\x20G5\x20self-driving\x20tick:\x20gathers\x20the\x20goal\x27s\x20pending\x20suggestions\x20+\x20the\x20engine\x20completion\x20'+'check\x20(monitoring\x20station),\x20runs\x20them\x20through\x20the\x20boundary\x20filter\x20and\x20the\x20autonomy\x20mapping,\x20then\x20'+'APPLIES\x20the\x20allowed\x20moves\x20through\x20the\x20normal\x20engine\x20stations\x20(execute)\x20or\x20surfaces\x20them\x20as\x20pending\x20'+'suggestions\x20(ask_user).\x20Boundary\x20violations\x20stall\x20and\x20are\x20reported.\x20A\x20paused\x20goal\x20does\x20not\x20pursue.\x20'+'Call\x20it\x20after\x20monitor\x20events\x20/\x20periodically\x20—\x20the\x20monitor\x20loop\x20bridges\x20events\x20into\x20suggestions\x20in\x20'+'the\x20background\x20either\x20way.\x0a'+'\x20\x20•\x20next_steps\x20—\x20G5\x20user-driven\x20follow-ups:\x20recommended\x20next\x20steps\x20for\x20this\x20goal\x20—\x20station\x20steps\x20'+'(confirm\x20boundaries,\x20bind,\x20resolve\x20pending\x20suggestions,\x20advance),\x20the\x20G2\x20role-interest\x20view\x20pointer\x20'+'(when\x20the\x20goal\x20has\x20objects\x20+\x20a\x20binding:\x20operable\x20forwards,\x20blocked\x20moves,\x20risks\x20via\x20topology_bi\x20'+'interest_role),\x20and\x20business-loop\x20follow-ups\x20(what\x20goals\x20naturally\x20follow\x20this\x20one).\x20Works\x20for\x20'+'completed\x20goals\x20too\x20(follow-ups\x20lead).\x0a'+'\x20\x20•\x20analyze_intent\x20(C1)\x20—\x20natural-language\x20business\x20intent\x20→\x20parsed\x20intent\x20(primary/secondary\x20objects,\x20'+'detected\x20scenes,\x20industry)\x20+\x20per-object\x20puzzle\x20snapshots\x20+\x20recommended\x20creation\x20order.\x0a'+'\x20\x20•\x20aggregate_risks\x20(C2)\x20—\x20puzzle\x20snapshots\x20→\x20cross-object\x20risk\x20calibration\x20(CRITICAL/HIGH/MEDIUM/LOW/INFO)\x20'+'with\x20blocking\x20status\x20(CLEAN_WITHIN_SCOPE/RISK_BLOCKED/RISK_PENDING_CONFIRM).\x20CLEAN_WITHIN_SCOPE\x20=\x20static\x20analyzers\x20found\x20'+'nothing\x20AND\x20zero\x20on-chain\x20objects\x20were\x20inspected\x20—\x20it\x20is\x20NOT\x20publish\x20clearance.\x20Omit\x20\x27puzzles\x27\x20but\x20pass\x20\x27intent\x27\x20'+'to\x20run\x20C1→C2\x20in\x20one\x20call.\x0a'+'\x20\x20•\x20trace_substeps\x20(C3)\x20—\x20substep\x20execution\x20records\x20→\x20DAG\x20coherence\x20analysis\x20(dangling\x20inputs,\x20circular\x20'+'refs,\x20missing\x20outputs,\x20cross-step\x20breaks,\x20topological\x20order,\x20D-10\x20verdict).\x0a'+'\x20\x20•\x20merchant_guide\x20—\x2010-step\x20merchant\x20onboarding\x20wizard:\x20intent\x20→\x20industry\x20confirmation\x20→\x20module\x20adoption\x20→\x20'+'Blueprint\x20(L1\x20plan\x20projection)\x20→\x20evaluation\x20preview\x20→\x20harness\x20check\x20→\x20creation\x20plan.\x20Stateless\x20(pass\x20'+'guide_state/guide_confirm\x20to\x20advance);\x20NEVER\x20executes\x20on-chain\x20operations.\x0a\x0a'+'Local\x20goal\x20state\x20only;\x20the\x20only\x20chain\x20access\x20is\x20READ-ONLY\x20completion\x20verification\x20(complete\x20/\x20the\x20pursue\x20tick\x27s\x20completion\x20check).\x0a\x0a'+'💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27goal_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema.','inputSchema':GoalOperationInputSchema,'annotations':{'readOnlyHint':![],'destructiveHint':![],'idempotentHint':![],'openWorldHint':![]},'_meta':createToolMeta('goal',['goal','lifecycle','plan','approve','monitor','complete','abandon','objective'])}},{'name':'employee_operation','handler':handleEmployeeOperation,'config':{'title':'👥\x20Employee\x20-\x20Merchant\x20Staff\x20Profile','summary':'Merchant\x20employee\x20profile,\x20KPI\x20assessment,\x20liability\x20resolution.','description':'Read/write\x20a\x20merchant\x20employee\x27s\x20LOCAL\x20organizational\x20profile:\x20department\x20'+'(customer_service/logistics/finance/operations),\x20liability\x20(merchant_bears/self_bears/hybrid),\x20'+'and\x20response-time\x20budget.\x20LOCAL\x20ONLY\x20—\x20never\x20mutates\x20chain\x20state;\x20the\x20employee\x27s\x20on-chain\x20'+'authorization\x20lives\x20in\x20the\x20merchant\x27s\x20Permission\x20(namedOperator/entity).\x0a\x0a'+'Actions:\x0a'+'\x20\x20•\x20set\x20—\x20persist\x20an\x20employee\x20profile\x20(validated:\x20department+liability\x20required,\x20budget\x20must\x20be\x20positive).\x0a'+'\x20\x20•\x20get\x20—\x20read\x20an\x20employee\x20profile\x20(null\x20when\x20absent).\x0a'+'\x20\x20•\x20remove\x20—\x20delete\x20an\x20employee\x20profile.\x0a'+'\x20\x20•\x20assess_kpi\x20—\x20measure\x20an\x20employee\x27s\x20node\x20reaction\x20speed\x20(assigned_at\x20→\x20advanced_at\x20vs\x20budget:\x20pass/warn/fail).\x20Timestamps:\x20pass\x20them\x20explicitly,\x20OR\x20pass\x20`progress`\x20(progress\x20object\x20address)\x20to\x20auto-derive\x20them\x20from\x20monitored\x20ProgressEvents\x20—\x20explicit\x20values\x20override\x20derived\x20ones.\x20Budget\x20precedence:\x20explicit\x20budget_ms\x20>\x20stored\x20profile\x20>\x2048h\x20default.\x0a'+'\x20\x20•\x20resolve_liability\x20—\x20resolve\x20who\x20internally\x20bears\x20an\x20employee-error\x20loss\x20(merchant/employee,\x20hybrid\x20threshold\x20split)\x20and\x20whether\x20the\x20order\x20user\x20must\x20be\x20compensated\x20BEFORE\x20the\x20workflow\x20resumes.\x20Outward\x20liability\x20toward\x20the\x20customer\x20is\x20ALWAYS\x20the\x20merchant\x27s.\x0a'+'\x20\x20•\x20suggest_incentive\x20—\x20the\x20employment\x20relationship\x27s\x20action\x20layer:\x20node\x20KPIs\x20(from\x20assess_kpi)\x20+\x20WIP\x20acceptance\x20evidence\x20+\x20liability\x20resolution\x20→\x20a\x20Reward\x20suggestion\x20(reward_grant\x20/\x20compensation_offset\x20/\x20correction_notice\x20/\x20none)\x20with\x20rationale\x20and\x20execution\x20hints.\x20Suggestion\x20ONLY\x20—\x20never\x20auto-executes;\x20the\x20merchant\x20confirms\x20and\x20runs\x20the\x20on-chain\x20reward/payment\x20ops\x20separately.\x0a\x0a'+'💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27employee_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema.','inputSchema':EmployeeOperationInputSchema,'outputSchema':EmployeeOperationOutputSchema,'annotations':{'readOnlyHint':![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':![]},'_meta':createToolMeta('employee',['employee','staff','merchant','department','kpi','liability','local'])}}];
@@ -1 +1 @@
1
- import{handleAccountOperation,handleMarkOperation,handleInfoOperation,handleHistoryOperation,handleCacheOperation}from'../handlers/local.js';import{statusErrorShape}from'../wrap.js';import{createToolMeta,AccountOperationSchema,LocalMarkOperationSchema,LocalInfoOperationSchema,LocalHistoryOperationSchema,LocalCacheOperationSchema,AccountOperationOutputWrappedSchema,LocalMarkOperationOutputWrappedSchema,LocalInfoOperationOutputWrappedSchema,LocalHistoryOperationOutputWrappedSchema,LocalCacheOperationOutputWrappedSchema}from'../../schema/index.js';export const LOCAL_TOOLS=[{'name':'account_operation','handler':handleAccountOperation,'config':{'title':'Account\x20-\x20Wallet\x20Management\x20&\x20On-Chain\x20Coin\x20Transactions','summary':'Wallet\x20management\x20(local)\x20+\x20token\x20transfer\x20and\x20coin-object\x20production\x20(on-chain,\x20confirmed).','description':'Manage\x20WoWok\x20accounts\x20locally:\x20generate,\x20suspend,\x20resume,\x20faucet-test,\x20sign\x20data,\x20etc.\x0a\x0a💰\x20ON-CHAIN\x20COIN\x20TRANSACTIONS\x20(IRREVERSIBLE,\x20confirmed):\x20`transfer`\x20moves\x20tokens\x20to\x20another\x20account\x20(fund\x20movement);\x20`get`\x20splits/merges\x20the\x20account\x27s\x20coins\x20to\x20produce\x20a\x20coin\x20object\x20carrying\x20at\x20least\x20the\x20required\x20balance\x20and\x20self-delivers\x20it\x20to\x20the\x20same\x20account\x20(fund\x20never\x20leaves\x20the\x20account\x20minus\x20gas,\x20but\x20a\x20real\x20transaction\x20IS\x20executed\x20and\x20SPENDS\x20GAS,\x20and\x20its\x20digest\x20is\x20returned).\x20Both\x20amounts\x20accept\x20display\x20format\x20with\x20symbol\x20(\x222.5WOW\x22)\x20—\x20converted\x20with\x20the\x20token\x27s\x20decimals\x20—\x20or\x20raw\x20smallest-unit\x20integers;\x20bare\x20decimals\x20are\x20rejected.\x20The\x20first\x20call\x20returns\x20a\x20pending_confirmation\x20preview\x20(amount,\x20token\x20full\x20type,\x20counterparty/account);\x20re-call\x20with\x20transfer.confirmed=true\x20or\x20get.confirmed=true\x20after\x20user\x20consent\x20to\x20execute.\x0a\x0a💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27account_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema\x20before\x20calling.','inputSchema':AccountOperationSchema,'outputSchema':AccountOperationOutputWrappedSchema,'annotations':{'readOnlyHint':![],'destructiveHint':!![],'idempotentHint':!![],'openWorldHint':![]},'_meta':createToolMeta('operation',['account','local','private','wallet','transfer','fund'])},'errorShapeBuilder':statusErrorShape,'timeoutMs':0x1d4c0},{'name':'local_mark_operation','handler':handleMarkOperation,'config':{'title':'🔒\x20LOCAL\x20ONLY:\x20LocalMark\x20-\x20Address\x20Book\x20Management','summary':'LOCAL\x20address\x20book\x20(name/tag\x20for\x20addresses\x20and\x20object\x20IDs).','description':'100%\x20LOCAL,\x20NEVER\x20ON-CHAIN\x20🔒\x20Manage\x20ID\x20names\x20and\x20tags\x20stored\x20ONLY\x20on\x20your\x20local\x20device\x20for\x20easy\x20identification\x20of\x20user\x20address\x20or\x20object\x20IDs\x20by\x20name.\x0a\x0a💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27local_mark_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema\x20before\x20calling.','inputSchema':LocalMarkOperationSchema,'outputSchema':LocalMarkOperationOutputWrappedSchema,'annotations':{'readOnlyHint':![],'destructiveHint':!![],'idempotentHint':!![],'openWorldHint':![]},'_meta':createToolMeta('operation',['mark','local','private','address-book','off-chain'])},'errorShapeBuilder':statusErrorShape},{'name':'local_info_operation','handler':handleInfoOperation,'config':{'title':'🔒\x20LOCAL\x20ONLY:\x20LocalInfo\x20-\x20Private\x20Data\x20Management','summary':'LOCAL\x20private\x20data\x20(delivery\x20addresses,\x20phone\x20numbers).','description':'100%\x20LOCAL,\x20NEVER\x20ON-CHAIN\x20🔒\x20Manage\x20sensitive\x20personal\x20information\x20stored\x20ONLY\x20on\x20your\x20device:\x20delivery\x20addresses,\x20phone\x20numbers,\x20contacts.\x0a\x0a💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27local_info_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema\x20before\x20calling.','inputSchema':LocalInfoOperationSchema,'outputSchema':LocalInfoOperationOutputWrappedSchema,'annotations':{'readOnlyHint':![],'destructiveHint':!![],'idempotentHint':!![],'openWorldHint':![]},'_meta':createToolMeta('operation',['info','local','private','data-management','off-chain'])},'errorShapeBuilder':statusErrorShape},{'name':'local_history_operation','handler':handleHistoryOperation,'config':{'title':'🕘\x20LOCAL\x20ONLY:\x20LocalHistory\x20-\x20Explorer\x20Visit\x20History','summary':'LOCAL\x20visit\x20history\x20of\x20Explorer\x20objects\x20(recently\x20viewed,\x20newest\x20first).','description':'100%\x20LOCAL,\x20NEVER\x20ON-CHAIN\x20🔒\x20Manage\x20the\x20Explorer\x20visit\x20history\x20stored\x20ONLY\x20on\x20your\x20device.\x20Each\x20entry\x20keeps\x20the\x20stable\x20object\x20key,\x20canonical\x200x\x20address,\x20object\x20type\x20tag\x20(detail\x20visits\x20only),\x20network\x20and\x20visit\x20timestamp\x20—\x20display\x20names\x20are\x20NEVER\x20stored\x20and\x20are\x20resolved\x20live\x20at\x20render\x20time.\x0a\x0aOmit\x20every\x20operation\x20field\x20to\x20LIST\x20history\x20(newest\x20first,\x20auto-pruned\x20to\x20the\x20last\x2030\x20recorded\x20days\x20/\x20300\x20entries).\x20Use\x20{add:{op:\x27add\x27,data:[...]}}\x20to\x20record\x20visits\x20(upsert\x20by\x20key),\x20{remove:{op:\x27remove\x27,keys:[...]}}\x20to\x20delete\x20entries,\x20or\x20{clear:{op:\x27clear\x27}}\x20to\x20erase\x20all\x20history.\x0a\x0a💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27local_history_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema\x20before\x20calling.','inputSchema':LocalHistoryOperationSchema,'outputSchema':LocalHistoryOperationOutputWrappedSchema,'annotations':{'readOnlyHint':![],'destructiveHint':!![],'idempotentHint':!![],'openWorldHint':![]},'_meta':createToolMeta('operation',['history','local','private','recent','off-chain'])},'errorShapeBuilder':statusErrorShape},{'name':'local_cache_operation','handler':handleCacheOperation,'config':{'title':'🧹\x20LOCAL\x20ONLY:\x20SDK\x20Read\x20Cache\x20-\x20Diagnose\x20&\x20Clear','summary':'LOCAL\x20SDK\x20read\x20cache:\x20report\x20diagnostics,\x20clear\x20a\x20prefix\x20or\x20everything,\x20re-detect\x20chain\x20identity\x20after\x20a\x20node\x20reset.','description':'100%\x20LOCAL,\x20NEVER\x20ON-CHAIN\x20🔒\x20Inspect\x20and\x20clear\x20this\x20device\x27s\x20WoWok\x20SDK\x20read\x20cache.\x20Does\x20NOT\x20touch\x20accounts,\x20marks,\x20info\x20or\x20history\x20(separate\x20stores,\x20separate\x20tools)\x20and\x20never\x20touches\x20the\x20blockchain.\x0a\x0a'+'WHEN\x20TO\x20USE:\x20after\x20the\x20chain\x20node\x20was\x20restarted\x20or\x20reset,\x20or\x20when\x20a\x20call\x20fails\x20with\x20\x27object\x200x…\x20version\x200x…\x20is\x20unavailable\x27.\x20The\x20SDK\x20namespaces\x20its\x20cache\x20by\x20CHAIN\x20IDENTITY\x20(the\x20genesis\x20checkpoint\x20digest\x20from\x20w_getChainIdentifier),\x20which\x20changes\x20exactly\x20when\x20the\x20chain\x20is\x20replaced\x20—\x20so\x20a\x20reset\x20normally\x20needs\x20no\x20action.\x20Use\x20{refresh_chain_scope:\x20{op:\x27refresh_chain_scope\x27}}\x20to\x20force\x20that\x20re-detection\x20when\x20the\x20node\x20was\x20unreachable\x20at\x20startup\x20(leaving\x20the\x20cache\x20unscoped),\x20{status:\x20{op:\x27status\x27}}\x20to\x20see\x20whether\x20a\x20chain\x20identity\x20is\x20active,\x20{clear_prefix:\x20{op:\x27clear_prefix\x27,\x20prefix:\x27objectv2\x27}}\x20to\x20drop\x20only\x20the\x20on-chain\x20object\x20cache,\x20or\x20{clear:\x20{op:\x27clear\x27}}\x20to\x20drop\x20everything.\x0a\x0a'+'READ-ONLY\x20SUB-OP:\x20`status`\x20changes\x20nothing.\x20The\x20others\x20discard\x20cached\x20reads\x20only\x20—\x20the\x20next\x20call\x20re-reads\x20from\x20the\x20node.\x0a\x0a'+'💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27local_cache_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema\x20before\x20calling.','inputSchema':LocalCacheOperationSchema,'outputSchema':LocalCacheOperationOutputWrappedSchema,'annotations':{'readOnlyHint':![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':![]},'_meta':createToolMeta('operation',['cache','local','private','diagnostics','off-chain','stale'])},'errorShapeBuilder':statusErrorShape}];
1
+ import{handleAccountOperation,handleMarkOperation,handleInfoOperation,handleHistoryOperation,handleCacheOperation}from'../handlers/local.js';import{statusErrorShape}from'../wrap.js';import{createToolMeta,AccountOperationSchema,LocalMarkOperationSchema,LocalInfoOperationSchema,LocalHistoryOperationSchema,LocalCacheOperationSchema,AccountOperationOutputWrappedSchema,LocalMarkOperationOutputWrappedSchema,LocalInfoOperationOutputWrappedSchema,LocalHistoryOperationOutputWrappedSchema,LocalCacheOperationOutputWrappedSchema}from'../../schema/index.js';export const LOCAL_TOOLS=[{'name':'account_operation','handler':handleAccountOperation,'config':{'title':'Account\x20-\x20Wallet\x20Management\x20&\x20On-Chain\x20Coin\x20Transactions','summary':'Wallet\x20management\x20(local):\x20gen/faucet/suspend/resume/sign\x20+\x20on-chain\x20token\x20transfer\x20and\x20coin\x20production.','description':'Manage\x20WoWok\x20accounts\x20locally:\x20generate,\x20suspend,\x20resume,\x20sign\x20data,\x20and\x20claim\x20test\x20coins\x20via\x20the\x20faucet.\x0a\x0a🚰\x20FAUCET\x20(test\x20coins):\x20{faucet:\x20{name_or_address:\x20\x22\x22,\x20network:\x20\x22testnet\x22}}\x20claims\x20test\x20coins\x20IN-APP\x20(\x27\x27\x20=\x20default\x20account;\x20network\x20accepts\x20testnet/localnet\x20only\x20—\x20mainnet\x20has\x20no\x20faucet).\x20Never\x20send\x20the\x20user\x20to\x20an\x20external\x20faucet\x20website.\x0a\x0a💰\x20ON-CHAIN\x20COIN\x20TRANSACTIONS\x20(IRREVERSIBLE,\x20confirmed):\x20`transfer`\x20moves\x20tokens\x20to\x20another\x20account\x20(fund\x20movement);\x20`get`\x20splits/merges\x20the\x20account\x27s\x20coins\x20to\x20produce\x20a\x20coin\x20object\x20carrying\x20at\x20least\x20the\x20required\x20balance\x20and\x20self-delivers\x20it\x20to\x20the\x20same\x20account\x20(fund\x20never\x20leaves\x20the\x20account\x20minus\x20gas,\x20but\x20a\x20real\x20transaction\x20IS\x20executed\x20and\x20SPENDS\x20GAS,\x20and\x20its\x20digest\x20is\x20returned).\x20Both\x20amounts\x20accept\x20display\x20format\x20with\x20symbol\x20(\x222.5WOW\x22)\x20—\x20converted\x20with\x20the\x20token\x27s\x20decimals\x20—\x20or\x20raw\x20smallest-unit\x20integers;\x20bare\x20decimals\x20are\x20rejected.\x20The\x20first\x20call\x20returns\x20a\x20pending_confirmation\x20preview\x20(amount,\x20token\x20full\x20type,\x20counterparty/account);\x20re-call\x20with\x20transfer.confirmed=true\x20or\x20get.confirmed=true\x20after\x20user\x20consent\x20to\x20execute.\x0a\x0a💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27account_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema\x20before\x20calling.','inputSchema':AccountOperationSchema,'outputSchema':AccountOperationOutputWrappedSchema,'annotations':{'readOnlyHint':![],'destructiveHint':!![],'idempotentHint':!![],'openWorldHint':![]},'_meta':createToolMeta('operation',['account','local','private','wallet','transfer','fund'])},'errorShapeBuilder':statusErrorShape,'timeoutMs':0x1d4c0},{'name':'local_mark_operation','handler':handleMarkOperation,'config':{'title':'🔒\x20LOCAL\x20ONLY:\x20LocalMark\x20-\x20Address\x20Book\x20Management','summary':'LOCAL\x20address\x20book\x20(name/tag\x20for\x20addresses\x20and\x20object\x20IDs).','description':'100%\x20LOCAL,\x20NEVER\x20ON-CHAIN\x20🔒\x20Manage\x20ID\x20names\x20and\x20tags\x20stored\x20ONLY\x20on\x20your\x20local\x20device\x20for\x20easy\x20identification\x20of\x20user\x20address\x20or\x20object\x20IDs\x20by\x20name.\x0a\x0a💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27local_mark_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema\x20before\x20calling.','inputSchema':LocalMarkOperationSchema,'outputSchema':LocalMarkOperationOutputWrappedSchema,'annotations':{'readOnlyHint':![],'destructiveHint':!![],'idempotentHint':!![],'openWorldHint':![]},'_meta':createToolMeta('operation',['mark','local','private','address-book','off-chain'])},'errorShapeBuilder':statusErrorShape},{'name':'local_info_operation','handler':handleInfoOperation,'config':{'title':'🔒\x20LOCAL\x20ONLY:\x20LocalInfo\x20-\x20Private\x20Data\x20Management','summary':'LOCAL\x20private\x20data\x20(delivery\x20addresses,\x20phone\x20numbers).','description':'100%\x20LOCAL,\x20NEVER\x20ON-CHAIN\x20🔒\x20Manage\x20sensitive\x20personal\x20information\x20stored\x20ONLY\x20on\x20your\x20device:\x20delivery\x20addresses,\x20phone\x20numbers,\x20contacts.\x0a\x0a💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27local_info_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema\x20before\x20calling.','inputSchema':LocalInfoOperationSchema,'outputSchema':LocalInfoOperationOutputWrappedSchema,'annotations':{'readOnlyHint':![],'destructiveHint':!![],'idempotentHint':!![],'openWorldHint':![]},'_meta':createToolMeta('operation',['info','local','private','data-management','off-chain'])},'errorShapeBuilder':statusErrorShape},{'name':'local_history_operation','handler':handleHistoryOperation,'config':{'title':'🕘\x20LOCAL\x20ONLY:\x20LocalHistory\x20-\x20Explorer\x20Visit\x20History','summary':'LOCAL\x20visit\x20history\x20of\x20Explorer\x20objects\x20(recently\x20viewed,\x20newest\x20first).','description':'100%\x20LOCAL,\x20NEVER\x20ON-CHAIN\x20🔒\x20Manage\x20the\x20Explorer\x20visit\x20history\x20stored\x20ONLY\x20on\x20your\x20device.\x20Each\x20entry\x20keeps\x20the\x20stable\x20object\x20key,\x20canonical\x200x\x20address,\x20object\x20type\x20tag\x20(detail\x20visits\x20only),\x20network\x20and\x20visit\x20timestamp\x20—\x20display\x20names\x20are\x20NEVER\x20stored\x20and\x20are\x20resolved\x20live\x20at\x20render\x20time.\x0a\x0aOmit\x20every\x20operation\x20field\x20to\x20LIST\x20history\x20(newest\x20first,\x20auto-pruned\x20to\x20the\x20last\x2030\x20recorded\x20days\x20/\x20300\x20entries).\x20Use\x20{add:{op:\x27add\x27,data:[...]}}\x20to\x20record\x20visits\x20(upsert\x20by\x20key),\x20{remove:{op:\x27remove\x27,keys:[...]}}\x20to\x20delete\x20entries,\x20or\x20{clear:{op:\x27clear\x27}}\x20to\x20erase\x20all\x20history.\x0a\x0a💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27local_history_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema\x20before\x20calling.','inputSchema':LocalHistoryOperationSchema,'outputSchema':LocalHistoryOperationOutputWrappedSchema,'annotations':{'readOnlyHint':![],'destructiveHint':!![],'idempotentHint':!![],'openWorldHint':![]},'_meta':createToolMeta('operation',['history','local','private','recent','off-chain'])},'errorShapeBuilder':statusErrorShape},{'name':'local_cache_operation','handler':handleCacheOperation,'config':{'title':'🧹\x20LOCAL\x20ONLY:\x20SDK\x20Read\x20Cache\x20-\x20Diagnose\x20&\x20Clear','summary':'LOCAL\x20SDK\x20read\x20cache:\x20report\x20diagnostics,\x20clear\x20a\x20prefix\x20or\x20everything,\x20re-detect\x20chain\x20identity\x20after\x20a\x20node\x20reset.','description':'100%\x20LOCAL,\x20NEVER\x20ON-CHAIN\x20🔒\x20Inspect\x20and\x20clear\x20this\x20device\x27s\x20WoWok\x20SDK\x20read\x20cache.\x20Does\x20NOT\x20touch\x20accounts,\x20marks,\x20info\x20or\x20history\x20(separate\x20stores,\x20separate\x20tools)\x20and\x20never\x20touches\x20the\x20blockchain.\x0a\x0a'+'WHEN\x20TO\x20USE:\x20after\x20the\x20chain\x20node\x20was\x20restarted\x20or\x20reset,\x20or\x20when\x20a\x20call\x20fails\x20with\x20\x27object\x200x…\x20version\x200x…\x20is\x20unavailable\x27.\x20The\x20SDK\x20namespaces\x20its\x20cache\x20by\x20CHAIN\x20IDENTITY\x20(the\x20genesis\x20checkpoint\x20digest\x20from\x20w_getChainIdentifier),\x20which\x20changes\x20exactly\x20when\x20the\x20chain\x20is\x20replaced\x20—\x20so\x20a\x20reset\x20normally\x20needs\x20no\x20action.\x20Use\x20{refresh_chain_scope:\x20{op:\x27refresh_chain_scope\x27}}\x20to\x20force\x20that\x20re-detection\x20when\x20the\x20node\x20was\x20unreachable\x20at\x20startup\x20(leaving\x20the\x20cache\x20unscoped),\x20{status:\x20{op:\x27status\x27}}\x20to\x20see\x20whether\x20a\x20chain\x20identity\x20is\x20active,\x20{clear_prefix:\x20{op:\x27clear_prefix\x27,\x20prefix:\x27objectv2\x27}}\x20to\x20drop\x20only\x20the\x20on-chain\x20object\x20cache,\x20or\x20{clear:\x20{op:\x27clear\x27}}\x20to\x20drop\x20everything.\x0a\x0a'+'READ-ONLY\x20SUB-OP:\x20`status`\x20changes\x20nothing.\x20The\x20others\x20discard\x20cached\x20reads\x20only\x20—\x20the\x20next\x20call\x20re-reads\x20from\x20the\x20node.\x0a\x0a'+'💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27local_cache_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema\x20before\x20calling.','inputSchema':LocalCacheOperationSchema,'outputSchema':LocalCacheOperationOutputWrappedSchema,'annotations':{'readOnlyHint':![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':![]},'_meta':createToolMeta('operation',['cache','local','private','diagnostics','off-chain','stale'])},'errorShapeBuilder':statusErrorShape}];
@@ -1 +1 @@
1
- export function classifyWipPath(a){if(!a||typeof a!=='string')return{'type':'unknown','is_local':![],'is_network':![],'description':'Empty\x20or\x20invalid\x20path'};if(a['startsWith']('data:'))return{'type':'data_url','is_local':![],'is_network':!![],'description':'Data\x20URL\x20—\x20embedded\x20content,\x20globally\x20reachable'};if(a['startsWith']('ipfs://'))return{'type':'ipfs','is_local':![],'is_network':!![],'description':'IPFS\x20URI\x20—\x20resolve\x20via\x20any\x20public\x20gateway'};const b=[/^https?:\/\/ipfs\.io\//i,/^https?:\/\/cloudflare-ipfs\.com\//i,/^https?:\/\/gateway\.pinata\.cloud\//i,/^https?:\/\/dweb\.link\//i,/^https?:\/\/[^/]*pinata\.cloud\//i];if(b['some'](d=>d['test'](a)))return{'type':'ipfs','is_local':![],'is_network':!![],'description':'IPFS\x20HTTP\x20gateway\x20URL\x20—\x20globally\x20reachable'};if(/^https?:\/\/(localhost|127\.0\.0\.1|\[::1\]|0\.0\.0\.0)([:/]|$)/i['test'](a))return{'type':'local_http','is_local':!![],'is_network':![],'description':'Local\x20HTTP\x20URL\x20(localhost/loopback)\x20—\x20reachable\x20only\x20on\x20this\x20machine,\x20NOT\x20by\x20customers'};const c=/^https?:\/\/(10\.\d{1,3}\.\d{1,3}\.\d{1,3}|172\.(1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}|192\.168\.\d{1,3}\.\d{1,3})([:/]|$)/i;if(c['test'](a))return{'type':'local_http','is_local':!![],'is_network':![],'description':'LAN\x20HTTP\x20URL\x20(private\x20IP)\x20—\x20reachable\x20only\x20on\x20the\x20local\x20network,\x20NOT\x20by\x20customers'};if(/^https?:\/\//i['test'](a))return{'type':'http_url','is_local':![],'is_network':!![],'description':'HTTP(S)\x20URL\x20—\x20globally\x20reachable\x20if\x20server\x20returns\x20200'};if(/^[A-Za-z]:[\\/]/['test'](a))return{'type':'local_windows','is_local':!![],'is_network':![],'description':'Windows\x20local\x20path\x20—\x20NOT\x20reachable\x20by\x20customers/AI'};if(a['startsWith']('/'))return{'type':'local_unix','is_local':!![],'is_network':![],'description':'Unix\x20local\x20path\x20—\x20NOT\x20reachable\x20by\x20customers/AI'};if(a['startsWith']('./')||a['startsWith']('../')||a==='.'||a==='..')return{'type':'local_relative','is_local':!![],'is_network':![],'description':'Relative\x20local\x20path\x20—\x20NOT\x20reachable\x20by\x20customers/AI'};if(!a['includes']('://')&&!a['startsWith']('data:'))return{'type':'local_relative','is_local':!![],'is_network':![],'description':'Local\x20file\x20path\x20(no\x20scheme)\x20—\x20NOT\x20reachable\x20by\x20customers/AI'};return{'type':'unknown','is_local':![],'is_network':![],'description':'Unrecognized\x20path\x20format'};}export async function probeWipReachability(a,b=0x1770){const c=new AbortController(),d=setTimeout(()=>c['abort'](),b);try{let f=await fetch(a,{'method':'HEAD','redirect':'follow','signal':c['signal']});if(f['status']===0x195||f['status']===0x1f5){f=await fetch(a,{'method':'GET','redirect':'follow','headers':{'Range':'bytes=0-0'},'signal':c['signal']});try{await f['arrayBuffer']();}catch{}}else try{f['body']?.['cancel']();}catch{}return{'ok':f['status']>=0xc8&&f['status']<0x190,'status':f['status']};}catch(g){const h=g?.['name']==='AbortError';return{'ok':![],'reason':h?'no\x20response\x20within\x20'+b+'ms\x20(host\x20down\x20or\x20unreachable)':String(g?.['message']??g)};}finally{clearTimeout(d);}}export function getDeployOptions(a){const b=a['replace'](/'/g,'\x27\x5c\x27\x27'),c=a['split'](/[\\/]/)['pop']()||'file.wip';return[{'name':'Wowok\x20WIP\x20storage\x20service\x20(Recommended)','description':'Upload\x20the\x20.wip\x20file\x20directly\x20from\x20the\x20MCP\x20with\x20wip_file\x20type=\x27upload\x27.\x20'+'Default\x20is\x20the\x20official\x20FREE\x20store\x20wip.store.wowok.net\x20(limited\x20to\x2010\x20files\x20per\x20account);\x20'+'with\x20storage=\x27custom\x27\x20any\x20self-hosted\x20or\x20third-party\x20wip\x20storage\x20service\x20works\x20(no\x20store\x20quota,\x20full\x20control).','difficulty':'easy','free':!![],'result_url_pattern':'https://wip.store.wowok.net/f/{hash}\x20\x20\x20(or\x20your\x20custom\x20service\x20base\x20URL\x20+\x20/f/{hash})','steps':['//\x201.\x20Generate\x20the\x20WIP\x20file:\x20wip_file\x20{\x20type:\x20\x27generate\x27,\x20options:\x20{\x20markdown_text:\x20\x27...\x27\x20}\x20}','//\x202.\x20Sign\x20it\x20with\x20your\x20account:\x20wip_file\x20{\x20type:\x20\x27sign\x27,\x20wipFilePath:\x20\x27<file>\x27,\x20account:\x20\x27<account>\x27\x20}','//\x203.\x20Upload\x20to\x20the\x20official\x20free\x20store:\x20wip_file\x20{\x20type:\x20\x27upload\x27,\x20wipFilePath:\x20\x27<file>\x27,\x20account:\x20\x27<account>\x27\x20}','//\x20\x20\x20\x20Or\x20use\x20your\x20own\x20/\x20a\x20third-party\x20service:\x20wip_file\x20{\x20type:\x20\x27upload\x27,\x20wipFilePath:\x20\x27<file>\x27,\x20storage:\x20\x27custom\x27,\x20customBaseUrl:\x20\x27https://your-wip-service.example.com\x27\x20}','//\x204.\x20Use\x20the\x20returned\x20URL\x20(base_url\x20+\x20/f/{hash})\x20as\x20the\x20Service\x27s\x20sale\x20wip:','//\x20\x20\x20\x20onchain_operations\x20{\x20operation_type:\x20\x27service\x27,\x20data:\x20{\x20object:\x20\x27<service-id>\x27,\x20sales:\x20{\x20op:\x20\x27set\x27,\x20sales:\x20[{\x20...,\x20wip:\x20\x27<public-url>\x27,\x20wip_hash:\x20\x27<hash>\x27\x20}]\x20}\x20}\x20}','//\x205.\x20Confirm\x20reachability:\x20wip_file\x20{\x20type:\x20\x27verify\x27,\x20wipFilePath:\x20\x27<public-url>\x27\x20}'],'notes':['Official\x20free\x20store\x20is\x20limited\x20to\x2010\x20files\x20per\x20account\x20—\x20free\x20up\x20space\x20with\x20wip_file\x20type=\x27storage_delete\x27\x20when\x20the\x20quota\x20is\x20hit.','Official\x20free\x20store\x20declaration:\x20files\x20are\x20retained\x20for\x206\x20months\x20(180\x20days);\x20free\x20best-effort\x20service\x20—\x20force\x20majeure\x20excepted;\x20expired\x20files\x20are\x20NEVER\x20deleted\x20automatically\x20(manual\x20admin\x20purge\x20only).\x20For\x20permanent\x20hosting\x20use\x20storage=\x27custom\x27.','The\x20public\x20WIP\x20URL\x20is\x20network-independent:\x20the\x20same\x20file\x20serves\x20buyers\x20on\x20both\x20testnet\x20and\x20mainnet.','Large\x20WIP\x20files\x20(multi-MB,\x20image-heavy)\x20are\x20network-sensitive:\x20compress\x20images\x20before\x20generate\x20and\x20retry\x20transient\x20upload\x20failures.']},{'name':'GitHub\x20Pages','description':'Upload\x20the\x20.wip\x20file\x20to\x20a\x20GitHub\x20repository\x20and\x20serve\x20it\x20via\x20GitHub\x20Pages.\x20'+'Free,\x20stable,\x20HTTPS-enabled,\x20no\x20expiration.','difficulty':'easy','free':!![],'result_url_pattern':'https://<your-username>.github.io/<repo>/<file>.wip','steps':['//\x201.\x20Create\x20a\x20new\x20GitHub\x20repository\x20(e.g.,\x20\x27wowok-wip\x27)\x20via\x20https://github.com/new','//\x202.\x20Make\x20it\x20PUBLIC\x20so\x20the\x20file\x20is\x20world-readable.','//\x203.\x20Copy\x20your\x20local\x20WIP\x20file\x20into\x20the\x20repo:','git\x20clone\x20https://github.com/<your-username>/wowok-wip.git','cp\x20\x27'+b+'\x27\x20wowok-wip/'+c,'cd\x20wowok-wip','git\x20add\x20'+c,'git\x20commit\x20-m\x20\x22Add\x20WIP\x20file\x22','git\x20push\x20origin\x20main','//\x204.\x20Enable\x20GitHub\x20Pages:\x20repo\x20→\x20Settings\x20→\x20Pages\x20→\x20Source\x20→\x20\x27main\x27\x20branch\x20→\x20/(root)\x20→\x20Save','//\x205.\x20Wait\x2030-60\x20seconds\x20for\x20deployment,\x20then\x20verify\x20the\x20URL\x20is\x20reachable:','curl\x20-I\x20https://<your-username>.github.io/wowok-wip/'+c,'//\x206.\x20Update\x20your\x20Service\x20on-chain\x20with\x20the\x20new\x20public\x20URL:','//\x20\x20\x20\x20Call\x20onchain_operations\x20{\x20operation_type:\x20\x27service\x27,\x20data:\x20{\x20object:\x20\x27<service-id>\x27,\x20sales:\x20{\x20op:\x20\x27set\x27,\x20sales:\x20[{\x20...,\x20wip:\x20\x27https://...\x27,\x20wip_hash:\x20\x27<hash>\x27\x20}]\x20}\x20}\x20}'],'notes':['If\x20the\x20repo\x20already\x20has\x20Pages\x20enabled\x20on\x20the\x20main\x20branch,\x20step\x204\x20can\x20be\x20skipped.','GitHub\x20Pages\x20serves\x20files\x20up\x20to\x2025\x20MB\x20—\x20well\x20above\x20typical\x20WIP\x20sizes\x20(<\x201\x20MB).','URL\x20is\x20case-sensitive;\x20ensure\x20the\x20filename\x20in\x20the\x20URL\x20matches\x20exactly.']},{'name':'IPFS\x20via\x20Pinata\x20(Free\x20gateway)','description':'Upload\x20the\x20.wip\x20file\x20to\x20IPFS\x20through\x20Pinata\x27s\x20free\x20gateway.\x20'+'Content-addressed\x20—\x20the\x20CID\x20hash\x20also\x20serves\x20as\x20an\x20integrity\x20check.','difficulty':'medium','free':!![],'result_url_pattern':'https://gateway.pinata.cloud/ipfs/<CID>\x20\x20(or\x20\x20https://ipfs.io/ipfs/<CID>)','steps':['//\x201.\x20Sign\x20up\x20for\x20a\x20free\x20Pinata\x20account\x20at\x20https://app.pinata.cloud/\x20(1\x20GB\x20free\x20storage).','//\x202.\x20Get\x20your\x20API\x20key\x20from\x20https://app.pinata.cloud/keys\x20(generate\x20a\x20new\x20key\x20with\x20\x27pinFileToIPFS\x27\x20scope).','//\x203.\x20Upload\x20your\x20local\x20WIP\x20file\x20via\x20curl:','curl\x20-X\x20POST\x20https://api.pinata.cloud/pinning/pinFileToIPFS\x20\x5c','\x20\x20-H\x20\x22Authorization:\x20Bearer\x20<YOUR_PINATA_API_KEY>\x22\x20\x5c','\x20\x20-F\x20\x22file=@\x27'+b+'\x27\x22','//\x204.\x20Pinata\x20returns\x20JSON\x20with\x20\x27IpfsHash\x27\x20(the\x20CID).\x20Extract\x20it:','//\x20\x20\x20\x20Example\x20response:\x20{\x20\x22IpfsHash\x22:\x20\x22QmXYZ...\x22,\x20\x22PinSize\x22:\x2012345,\x20\x22Timestamp\x22:\x20\x22...\x22\x20}','//\x205.\x20Verify\x20the\x20file\x20is\x20reachable\x20via\x20the\x20public\x20gateway:','curl\x20-I\x20https://gateway.pinata.cloud/ipfs/<CID>','//\x206.\x20(Optional)\x20Use\x20ipfs://<CID>\x20as\x20the\x20sale\x20wip\x20—\x20the\x20SDK\x20resolves\x20it.','//\x207.\x20Update\x20your\x20Service\x20on-chain\x20with\x20the\x20IPFS\x20URL\x20or\x20CID:','//\x20\x20\x20\x20Call\x20onchain_operations\x20{\x20operation_type:\x20\x27service\x27,\x20data:\x20{\x20object:\x20\x27<service-id>\x27,\x20sales:\x20{\x20op:\x20\x27set\x27,\x20sales:\x20[{\x20...,\x20wip:\x20\x27https://gateway.pinata.cloud/ipfs/<CID>\x27,\x20wip_hash:\x20\x27<hash>\x27\x20}]\x20}\x20}\x20}'],'notes':['Pinata\x20free\x20tier:\x201\x20GB\x20storage,\x20100\x20uploads/day\x20—\x20sufficient\x20for\x20WIP\x20files.','For\x20long-term\x20durability,\x20also\x20pin\x20via\x20another\x20gateway\x20(e.g.,\x20nft.storage).','IPFS\x20CIDs\x20are\x20content-addressed\x20—\x20if\x20the\x20file\x20changes,\x20the\x20CID\x20changes.\x20This\x20is\x20a\x20feature,\x20not\x20a\x20bug.']},{'name':'User\x27s\x20own\x20website\x20/\x20static\x20host','description':'If\x20you\x20already\x20operate\x20a\x20website\x20or\x20static\x20host\x20(e.g.,\x20nginx,\x20Vercel,\x20Netlify,\x20Cloudflare\x20Pages),\x20'+'upload\x20the\x20.wip\x20file\x20there\x20and\x20use\x20its\x20public\x20URL.','difficulty':'medium','free':!![],'result_url_pattern':'https://<your-domain>/<path>/<file>.wip','steps':['//\x201.\x20Copy\x20your\x20local\x20WIP\x20file\x20to\x20your\x20web\x20server\x27s\x20static\x20directory:','scp\x20\x27'+b+'\x27\x20user@your-server:/var/www/html/wowok/'+c,'//\x202.\x20Ensure\x20the\x20server\x20sets\x20Content-Type:\x20application/json\x20(or\x20application/octet-stream)\x20for\x20.wip\x20files.','//\x20\x20\x20\x20For\x20nginx,\x20add\x20to\x20your\x20server\x20block:','//\x20\x20\x20\x20\x20\x20\x20\x20location\x20~\x20\x5c.wip$\x20{\x20default_type\x20application/json;\x20}','//\x203.\x20Verify\x20the\x20file\x20is\x20reachable:','curl\x20-I\x20https://<your-domain>/wowok/'+c,'//\x204.\x20Update\x20your\x20Service\x20on-chain\x20with\x20the\x20new\x20public\x20URL:','//\x20\x20\x20\x20Call\x20onchain_operations\x20{\x20operation_type:\x20\x27service\x27,\x20data:\x20{\x20object:\x20\x27<service-id>\x27,\x20sales:\x20{\x20op:\x20\x27set\x27,\x20sales:\x20[{\x20...,\x20wip:\x20\x27https://<your-domain>/wowok/<file>.wip\x27,\x20wip_hash:\x20\x27<hash>\x27\x20}]\x20}\x20}\x20}'],'notes':['Make\x20sure\x20CORS\x20is\x20permissive\x20if\x20the\x20verifier\x20fetches\x20via\x20browser\x20(Access-Control-Allow-Origin:\x20*).','Ensure\x20HTTPS\x20is\x20enabled\x20—\x20most\x20verifiers\x20reject\x20plain\x20HTTP.']},{'name':'Data\x20URL\x20embedding\x20(small\x20files\x20only)','description':'Embed\x20the\x20entire\x20WIP\x20file\x20as\x20a\x20base64\x20data\x20URL\x20directly\x20in\x20the\x20sale\x27s\x20wip\x20field.\x20'+'No\x20external\x20hosting\x20required,\x20but\x20on-chain\x20storage\x20cost\x20grows\x20with\x20file\x20size.','difficulty':'easy','free':!![],'result_url_pattern':'data:application/json;base64,<base64-encoded-content>','steps':['//\x201.\x20Encode\x20your\x20local\x20WIP\x20file\x20as\x20a\x20base64\x20data\x20URL:','//\x20\x20\x20\x20On\x20Linux/macOS:','echo\x20\x22data:application/json;base64,$(base64\x20-w0\x20\x27'+b+'\x27)\x22','//\x20\x20\x20\x20On\x20Windows\x20(PowerShell):','$bytes\x20=\x20[System.IO.File]::ReadAllBytes(\x27'+a+'\x27);\x20$b64\x20=\x20[System.Convert]::ToBase64String($bytes);\x20Write-Output\x20\x22data:application/json;base64,$b64\x22','//\x202.\x20Use\x20the\x20resulting\x20data\x20URL\x20as\x20the\x20sale\x27s\x20wip\x20field\x20when\x20updating\x20the\x20Service.','//\x203.\x20Note:\x20data\x20URLs\x20are\x20NOT\x20recommended\x20for\x20files\x20>\x2050\x20KB\x20due\x20to\x20on-chain\x20storage\x20cost.'],'notes':['Only\x20suitable\x20for\x20very\x20small\x20WIP\x20files\x20(typically\x20<\x2010\x20KB).','Data\x20URLs\x20cannot\x20be\x20updated\x20without\x20an\x20on-chain\x20transaction\x20—\x20content\x20is\x20literally\x20embedded.','Prefer\x20GitHub\x20Pages\x20or\x20IPFS\x20for\x20files\x20>\x2010\x20KB.']}];}export function analyzeWipDeployment(a){const b=classifyWipPath(a),c=b['is_local'];let d,e=[];if(c)b['type']==='local_http'?d='The\x20WIP\x20URL\x20\x27'+a+'\x27\x20is\x20a\x20'+b['description']+'.\x20'+'It\x20is\x20reachable\x20only\x20from\x20the\x20merchant\x27s\x20own\x20machine/LAN\x20—\x20customers\x20and\x20'+'on-chain\x20verifiers\x20on\x20other\x20machines\x20CANNOT\x20fetch\x20it.\x20Storing\x20it\x20on-chain\x20'+'makes\x20every\x20customer\x20order\x20fail.\x20'+'Deploy\x20the\x20.wip\x20file\x20to\x20a\x20public\x20host\x20(GitHub\x20Pages,\x20IPFS,\x20or\x20your\x20own\x20website)\x20'+'and\x20update\x20the\x20Service\x27s\x20sale\x20wip\x20with\x20the\x20public\x20URL.':d='The\x20WIP\x20path\x20\x27'+a+'\x27\x20is\x20a\x20LOCAL\x20'+b['type']+'\x20path.\x20'+'Local\x20paths\x20stored\x20on-chain\x20are\x20unreachable\x20by\x20customers\x20and\x20verifiers.\x20'+'Deploy\x20the\x20.wip\x20file\x20to\x20a\x20public\x20host\x20(GitHub\x20Pages,\x20IPFS,\x20or\x20your\x20own\x20website)\x20'+'and\x20update\x20the\x20Service\x27s\x20sale\x20wip\x20with\x20the\x20public\x20URL.',e=getDeployOptions(a);else{if(b['type']==='http_url')d='The\x20WIP\x20path\x20is\x20an\x20HTTP(S)\x20URL\x20—\x20verify\x20the\x20server\x20returns\x20200.\x20'+'If\x20the\x20URL\x20returns\x20404/403,\x20the\x20file\x20may\x20have\x20been\x20moved\x20or\x20deleted.',e=[];else{if(b['type']==='ipfs')d='The\x20WIP\x20path\x20is\x20an\x20IPFS\x20URL\x20—\x20verify\x20the\x20gateway\x20is\x20responsive.\x20'+'If\x20the\x20CID\x20is\x20unreachable,\x20the\x20file\x20may\x20have\x20been\x20unpinned.',e=[];else b['type']==='data_url'?(d='The\x20WIP\x20path\x20is\x20a\x20data\x20URL\x20—\x20content\x20is\x20embedded,\x20no\x20deployment\x20needed.',e=[]):(d='Unrecognized\x20WIP\x20path\x20format:\x20\x27'+a+'\x27',e=[]);}}return{'path':a,'classification':b,'needs_deployment':c,'reason':d,'options':e,'remind_update_hash':c};}export function formatDeployHints(a){if(!a['needs_deployment']&&a['options']['length']===0x0)return'';const b=[];b['push']('===\x20WIP\x20Deployment\x20Assistance\x20==='),b['push'](''),b['push']('Path:\x20'+a['path']),b['push']('Type:\x20'+a['classification']['description']),b['push']('Reason:\x20'+a['reason']),b['push']('');if(a['options']['length']>0x0){b['push']('Recommended\x20deployment\x20options:'),b['push']('');for(const c of a['options']){b['push']('▶\x20'+c['name']+'\x20(difficulty:\x20'+c['difficulty']+',\x20free:\x20'+c['free']+')'),b['push']('\x20\x20'+c['description']),b['push']('\x20\x20Resulting\x20URL\x20pattern:\x20'+c['result_url_pattern']),b['push']('\x20\x20Steps:');for(const d of c['steps']){b['push']('\x20\x20\x20\x20'+d);}if(c['notes']&&c['notes']['length']>0x0){b['push']('\x20\x20Notes:');for(const e of c['notes']){b['push']('\x20\x20\x20\x20-\x20'+e);}}b['push']('');}}return a['remind_update_hash']&&(b['push']('⚠️\x20After\x20deploying,\x20compute\x20the\x20new\x20WIP\x20hash\x20and\x20update\x20the\x20Service:'),b['push']('\x20\x201.\x20Re-run\x20wip_file\x20{\x20type:\x20\x27verify\x27,\x20wipFilePath:\x20\x27<new-public-url>\x27\x20}\x20to\x20confirm\x20the\x20file\x20is\x20reachable.'),b['push']('\x20\x202.\x20Extract\x20the\x20meta.hash\x20from\x20the\x20WIP\x20file\x20(or\x20use\x20wip_file\x20{\x20type:\x20\x27verify\x27\x20}\x20result).'),b['push']('\x20\x203.\x20Update\x20the\x20Service\x20on-chain:\x20onchain_operations\x20{\x20operation_type:\x20\x27service\x27,\x20data:\x20{\x20object:\x20\x27<service-id>\x27,\x20sales:\x20{\x20op:\x20\x27set\x27,\x20sales:\x20[{\x20...,\x20wip:\x20\x27<new-public-url>\x27,\x20wip_hash:\x20\x27<hash>\x27\x20}]\x20}\x20}\x20}'),b['push']('')),b['push']('==============================='),b['join']('\x0a');}
1
+ export function classifyWipPath(a){if(!a||typeof a!=='string')return{'type':'unknown','is_local':![],'is_network':![],'description':'Empty\x20or\x20invalid\x20path'};if(a['startsWith']('data:'))return{'type':'data_url','is_local':![],'is_network':!![],'description':'Data\x20URL\x20—\x20embedded\x20content,\x20globally\x20reachable'};if(a['startsWith']('ipfs://'))return{'type':'ipfs','is_local':![],'is_network':!![],'description':'IPFS\x20URI\x20—\x20resolve\x20via\x20any\x20public\x20gateway'};const b=[/^https?:\/\/ipfs\.io\//i,/^https?:\/\/cloudflare-ipfs\.com\//i,/^https?:\/\/gateway\.pinata\.cloud\//i,/^https?:\/\/dweb\.link\//i,/^https?:\/\/[^/]*pinata\.cloud\//i];if(b['some'](d=>d['test'](a)))return{'type':'ipfs','is_local':![],'is_network':!![],'description':'IPFS\x20HTTP\x20gateway\x20URL\x20—\x20globally\x20reachable'};if(/^https?:\/\/(localhost|127\.0\.0\.1|\[::1\]|0\.0\.0\.0)([:/]|$)/i['test'](a))return{'type':'local_http','is_local':!![],'is_network':![],'description':'Local\x20HTTP\x20URL\x20(localhost/loopback)\x20—\x20reachable\x20only\x20on\x20this\x20machine,\x20NOT\x20by\x20customers'};const c=/^https?:\/\/(10\.\d{1,3}\.\d{1,3}\.\d{1,3}|172\.(1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}|192\.168\.\d{1,3}\.\d{1,3})([:/]|$)/i;if(c['test'](a))return{'type':'local_http','is_local':!![],'is_network':![],'description':'LAN\x20HTTP\x20URL\x20(private\x20IP)\x20—\x20reachable\x20only\x20on\x20the\x20local\x20network,\x20NOT\x20by\x20customers'};if(/^https?:\/\//i['test'](a))return{'type':'http_url','is_local':![],'is_network':!![],'description':'HTTP(S)\x20URL\x20—\x20globally\x20reachable\x20if\x20server\x20returns\x20200'};if(/^[A-Za-z]:[\\/]/['test'](a))return{'type':'local_windows','is_local':!![],'is_network':![],'description':'Windows\x20local\x20path\x20—\x20NOT\x20reachable\x20by\x20customers/AI'};if(a['startsWith']('/'))return{'type':'local_unix','is_local':!![],'is_network':![],'description':'Unix\x20local\x20path\x20—\x20NOT\x20reachable\x20by\x20customers/AI'};if(a['startsWith']('./')||a['startsWith']('../')||a==='.'||a==='..')return{'type':'local_relative','is_local':!![],'is_network':![],'description':'Relative\x20local\x20path\x20—\x20NOT\x20reachable\x20by\x20customers/AI'};if(!a['includes']('://')&&!a['startsWith']('data:'))return{'type':'local_relative','is_local':!![],'is_network':![],'description':'Local\x20file\x20path\x20(no\x20scheme)\x20—\x20NOT\x20reachable\x20by\x20customers/AI'};return{'type':'unknown','is_local':![],'is_network':![],'description':'Unrecognized\x20path\x20format'};}export async function probeWipReachability(a,b=0x3a98){const c=new AbortController(),d=setTimeout(()=>c['abort'](),b);try{let f=await fetch(a,{'method':'HEAD','redirect':'follow','signal':c['signal']});if(f['status']===0x195||f['status']===0x1f5){f=await fetch(a,{'method':'GET','redirect':'follow','headers':{'Range':'bytes=0-0'},'signal':c['signal']});try{await f['arrayBuffer']();}catch{}}else try{f['body']?.['cancel']();}catch{}return{'ok':f['status']>=0xc8&&f['status']<0x190,'status':f['status']};}catch(g){const h=g?.['name']==='AbortError';return{'ok':![],'reason':h?'no\x20response\x20within\x20'+b+'ms\x20(host\x20down,\x20unreachable,\x20or\x20very\x20slow\x20—\x20the\x20official\x20WIP\x20store\x27s\x20cold\x20TTFB\x20has\x20measured\x20over\x2020s)':String(g?.['message']??g)};}finally{clearTimeout(d);}}export function getDeployOptions(a){const b=a['replace'](/'/g,'\x27\x5c\x27\x27'),c=a['split'](/[\\/]/)['pop']()||'file.wip';return[{'name':'Wowok\x20WIP\x20storage\x20service\x20(Recommended)','description':'Upload\x20the\x20.wip\x20file\x20directly\x20from\x20the\x20MCP\x20with\x20wip_file\x20type=\x27upload\x27.\x20'+'Default\x20is\x20the\x20official\x20FREE\x20store\x20wip.store.wowok.net\x20(limited\x20to\x2010\x20files\x20per\x20account);\x20'+'with\x20storage=\x27custom\x27\x20any\x20self-hosted\x20or\x20third-party\x20wip\x20storage\x20service\x20works\x20(no\x20store\x20quota,\x20full\x20control).','difficulty':'easy','free':!![],'result_url_pattern':'https://wip.store.wowok.net/f/{hash}\x20\x20\x20(or\x20your\x20custom\x20service\x20base\x20URL\x20+\x20/f/{hash})','steps':['//\x201.\x20Generate\x20the\x20WIP\x20file:\x20wip_file\x20{\x20type:\x20\x27generate\x27,\x20options:\x20{\x20markdown_text:\x20\x27...\x27\x20}\x20}','//\x202.\x20Sign\x20it\x20with\x20your\x20account:\x20wip_file\x20{\x20type:\x20\x27sign\x27,\x20wipFilePath:\x20\x27<file>\x27,\x20account:\x20\x27<account>\x27\x20}','//\x203.\x20Upload\x20to\x20the\x20official\x20free\x20store:\x20wip_file\x20{\x20type:\x20\x27upload\x27,\x20wipFilePath:\x20\x27<file>\x27,\x20account:\x20\x27<account>\x27\x20}','//\x20\x20\x20\x20Or\x20use\x20your\x20own\x20/\x20a\x20third-party\x20service:\x20wip_file\x20{\x20type:\x20\x27upload\x27,\x20wipFilePath:\x20\x27<file>\x27,\x20storage:\x20\x27custom\x27,\x20customBaseUrl:\x20\x27https://your-wip-service.example.com\x27\x20}','//\x204.\x20Use\x20the\x20returned\x20URL\x20(base_url\x20+\x20/f/{hash})\x20as\x20the\x20Service\x27s\x20sale\x20wip:','//\x20\x20\x20\x20onchain_operations\x20{\x20operation_type:\x20\x27service\x27,\x20data:\x20{\x20object:\x20\x27<service-id>\x27,\x20sales:\x20{\x20op:\x20\x27set\x27,\x20sales:\x20[{\x20...,\x20wip:\x20\x27<public-url>\x27,\x20wip_hash:\x20\x27<hash>\x27\x20}]\x20}\x20}\x20}','//\x205.\x20Confirm\x20reachability:\x20wip_file\x20{\x20type:\x20\x27verify\x27,\x20wipFilePath:\x20\x27<public-url>\x27\x20}'],'notes':['Official\x20free\x20store\x20is\x20limited\x20to\x2010\x20files\x20per\x20account\x20—\x20free\x20up\x20space\x20with\x20wip_file\x20type=\x27storage_delete\x27\x20when\x20the\x20quota\x20is\x20hit.','Official\x20free\x20store\x20declaration:\x20files\x20are\x20retained\x20for\x206\x20months\x20(180\x20days);\x20free\x20best-effort\x20service\x20—\x20force\x20majeure\x20excepted;\x20expired\x20files\x20are\x20NEVER\x20deleted\x20automatically\x20(manual\x20admin\x20purge\x20only).\x20For\x20permanent\x20hosting\x20use\x20storage=\x27custom\x27.','The\x20public\x20WIP\x20URL\x20is\x20network-independent:\x20the\x20same\x20file\x20serves\x20buyers\x20on\x20both\x20testnet\x20and\x20mainnet.','Large\x20WIP\x20files\x20(multi-MB,\x20image-heavy)\x20are\x20network-sensitive:\x20compress\x20images\x20before\x20generate\x20and\x20retry\x20transient\x20upload\x20failures.']},{'name':'GitHub\x20Pages','description':'Upload\x20the\x20.wip\x20file\x20to\x20a\x20GitHub\x20repository\x20and\x20serve\x20it\x20via\x20GitHub\x20Pages.\x20'+'Free,\x20stable,\x20HTTPS-enabled,\x20no\x20expiration.','difficulty':'easy','free':!![],'result_url_pattern':'https://<your-username>.github.io/<repo>/<file>.wip','steps':['//\x201.\x20Create\x20a\x20new\x20GitHub\x20repository\x20(e.g.,\x20\x27wowok-wip\x27)\x20via\x20https://github.com/new','//\x202.\x20Make\x20it\x20PUBLIC\x20so\x20the\x20file\x20is\x20world-readable.','//\x203.\x20Copy\x20your\x20local\x20WIP\x20file\x20into\x20the\x20repo:','git\x20clone\x20https://github.com/<your-username>/wowok-wip.git','cp\x20\x27'+b+'\x27\x20wowok-wip/'+c,'cd\x20wowok-wip','git\x20add\x20'+c,'git\x20commit\x20-m\x20\x22Add\x20WIP\x20file\x22','git\x20push\x20origin\x20main','//\x204.\x20Enable\x20GitHub\x20Pages:\x20repo\x20→\x20Settings\x20→\x20Pages\x20→\x20Source\x20→\x20\x27main\x27\x20branch\x20→\x20/(root)\x20→\x20Save','//\x205.\x20Wait\x2030-60\x20seconds\x20for\x20deployment,\x20then\x20verify\x20the\x20URL\x20is\x20reachable:','curl\x20-I\x20https://<your-username>.github.io/wowok-wip/'+c,'//\x206.\x20Update\x20your\x20Service\x20on-chain\x20with\x20the\x20new\x20public\x20URL:','//\x20\x20\x20\x20Call\x20onchain_operations\x20{\x20operation_type:\x20\x27service\x27,\x20data:\x20{\x20object:\x20\x27<service-id>\x27,\x20sales:\x20{\x20op:\x20\x27set\x27,\x20sales:\x20[{\x20...,\x20wip:\x20\x27https://...\x27,\x20wip_hash:\x20\x27<hash>\x27\x20}]\x20}\x20}\x20}'],'notes':['If\x20the\x20repo\x20already\x20has\x20Pages\x20enabled\x20on\x20the\x20main\x20branch,\x20step\x204\x20can\x20be\x20skipped.','GitHub\x20Pages\x20serves\x20files\x20up\x20to\x2025\x20MB\x20—\x20well\x20above\x20typical\x20WIP\x20sizes\x20(<\x201\x20MB).','URL\x20is\x20case-sensitive;\x20ensure\x20the\x20filename\x20in\x20the\x20URL\x20matches\x20exactly.']},{'name':'IPFS\x20via\x20Pinata\x20(Free\x20gateway)','description':'Upload\x20the\x20.wip\x20file\x20to\x20IPFS\x20through\x20Pinata\x27s\x20free\x20gateway.\x20'+'Content-addressed\x20—\x20the\x20CID\x20hash\x20also\x20serves\x20as\x20an\x20integrity\x20check.','difficulty':'medium','free':!![],'result_url_pattern':'https://gateway.pinata.cloud/ipfs/<CID>\x20\x20(or\x20\x20https://ipfs.io/ipfs/<CID>)','steps':['//\x201.\x20Sign\x20up\x20for\x20a\x20free\x20Pinata\x20account\x20at\x20https://app.pinata.cloud/\x20(1\x20GB\x20free\x20storage).','//\x202.\x20Get\x20your\x20API\x20key\x20from\x20https://app.pinata.cloud/keys\x20(generate\x20a\x20new\x20key\x20with\x20\x27pinFileToIPFS\x27\x20scope).','//\x203.\x20Upload\x20your\x20local\x20WIP\x20file\x20via\x20curl:','curl\x20-X\x20POST\x20https://api.pinata.cloud/pinning/pinFileToIPFS\x20\x5c','\x20\x20-H\x20\x22Authorization:\x20Bearer\x20<YOUR_PINATA_API_KEY>\x22\x20\x5c','\x20\x20-F\x20\x22file=@\x27'+b+'\x27\x22','//\x204.\x20Pinata\x20returns\x20JSON\x20with\x20\x27IpfsHash\x27\x20(the\x20CID).\x20Extract\x20it:','//\x20\x20\x20\x20Example\x20response:\x20{\x20\x22IpfsHash\x22:\x20\x22QmXYZ...\x22,\x20\x22PinSize\x22:\x2012345,\x20\x22Timestamp\x22:\x20\x22...\x22\x20}','//\x205.\x20Verify\x20the\x20file\x20is\x20reachable\x20via\x20the\x20public\x20gateway:','curl\x20-I\x20https://gateway.pinata.cloud/ipfs/<CID>','//\x206.\x20(Optional)\x20Use\x20ipfs://<CID>\x20as\x20the\x20sale\x20wip\x20—\x20the\x20SDK\x20resolves\x20it.','//\x207.\x20Update\x20your\x20Service\x20on-chain\x20with\x20the\x20IPFS\x20URL\x20or\x20CID:','//\x20\x20\x20\x20Call\x20onchain_operations\x20{\x20operation_type:\x20\x27service\x27,\x20data:\x20{\x20object:\x20\x27<service-id>\x27,\x20sales:\x20{\x20op:\x20\x27set\x27,\x20sales:\x20[{\x20...,\x20wip:\x20\x27https://gateway.pinata.cloud/ipfs/<CID>\x27,\x20wip_hash:\x20\x27<hash>\x27\x20}]\x20}\x20}\x20}'],'notes':['Pinata\x20free\x20tier:\x201\x20GB\x20storage,\x20100\x20uploads/day\x20—\x20sufficient\x20for\x20WIP\x20files.','For\x20long-term\x20durability,\x20also\x20pin\x20via\x20another\x20gateway\x20(e.g.,\x20nft.storage).','IPFS\x20CIDs\x20are\x20content-addressed\x20—\x20if\x20the\x20file\x20changes,\x20the\x20CID\x20changes.\x20This\x20is\x20a\x20feature,\x20not\x20a\x20bug.']},{'name':'User\x27s\x20own\x20website\x20/\x20static\x20host','description':'If\x20you\x20already\x20operate\x20a\x20website\x20or\x20static\x20host\x20(e.g.,\x20nginx,\x20Vercel,\x20Netlify,\x20Cloudflare\x20Pages),\x20'+'upload\x20the\x20.wip\x20file\x20there\x20and\x20use\x20its\x20public\x20URL.','difficulty':'medium','free':!![],'result_url_pattern':'https://<your-domain>/<path>/<file>.wip','steps':['//\x201.\x20Copy\x20your\x20local\x20WIP\x20file\x20to\x20your\x20web\x20server\x27s\x20static\x20directory:','scp\x20\x27'+b+'\x27\x20user@your-server:/var/www/html/wowok/'+c,'//\x202.\x20Ensure\x20the\x20server\x20sets\x20Content-Type:\x20application/json\x20(or\x20application/octet-stream)\x20for\x20.wip\x20files.','//\x20\x20\x20\x20For\x20nginx,\x20add\x20to\x20your\x20server\x20block:','//\x20\x20\x20\x20\x20\x20\x20\x20location\x20~\x20\x5c.wip$\x20{\x20default_type\x20application/json;\x20}','//\x203.\x20Verify\x20the\x20file\x20is\x20reachable:','curl\x20-I\x20https://<your-domain>/wowok/'+c,'//\x204.\x20Update\x20your\x20Service\x20on-chain\x20with\x20the\x20new\x20public\x20URL:','//\x20\x20\x20\x20Call\x20onchain_operations\x20{\x20operation_type:\x20\x27service\x27,\x20data:\x20{\x20object:\x20\x27<service-id>\x27,\x20sales:\x20{\x20op:\x20\x27set\x27,\x20sales:\x20[{\x20...,\x20wip:\x20\x27https://<your-domain>/wowok/<file>.wip\x27,\x20wip_hash:\x20\x27<hash>\x27\x20}]\x20}\x20}\x20}'],'notes':['Make\x20sure\x20CORS\x20is\x20permissive\x20if\x20the\x20verifier\x20fetches\x20via\x20browser\x20(Access-Control-Allow-Origin:\x20*).','Ensure\x20HTTPS\x20is\x20enabled\x20—\x20most\x20verifiers\x20reject\x20plain\x20HTTP.']},{'name':'Data\x20URL\x20embedding\x20(small\x20files\x20only)','description':'Embed\x20the\x20entire\x20WIP\x20file\x20as\x20a\x20base64\x20data\x20URL\x20directly\x20in\x20the\x20sale\x27s\x20wip\x20field.\x20'+'No\x20external\x20hosting\x20required,\x20but\x20on-chain\x20storage\x20cost\x20grows\x20with\x20file\x20size.','difficulty':'easy','free':!![],'result_url_pattern':'data:application/json;base64,<base64-encoded-content>','steps':['//\x201.\x20Encode\x20your\x20local\x20WIP\x20file\x20as\x20a\x20base64\x20data\x20URL:','//\x20\x20\x20\x20On\x20Linux/macOS:','echo\x20\x22data:application/json;base64,$(base64\x20-w0\x20\x27'+b+'\x27)\x22','//\x20\x20\x20\x20On\x20Windows\x20(PowerShell):','$bytes\x20=\x20[System.IO.File]::ReadAllBytes(\x27'+a+'\x27);\x20$b64\x20=\x20[System.Convert]::ToBase64String($bytes);\x20Write-Output\x20\x22data:application/json;base64,$b64\x22','//\x202.\x20Use\x20the\x20resulting\x20data\x20URL\x20as\x20the\x20sale\x27s\x20wip\x20field\x20when\x20updating\x20the\x20Service.','//\x203.\x20Note:\x20data\x20URLs\x20are\x20NOT\x20recommended\x20for\x20files\x20>\x2050\x20KB\x20due\x20to\x20on-chain\x20storage\x20cost.'],'notes':['Only\x20suitable\x20for\x20very\x20small\x20WIP\x20files\x20(typically\x20<\x2010\x20KB).','Data\x20URLs\x20cannot\x20be\x20updated\x20without\x20an\x20on-chain\x20transaction\x20—\x20content\x20is\x20literally\x20embedded.','Prefer\x20GitHub\x20Pages\x20or\x20IPFS\x20for\x20files\x20>\x2010\x20KB.']}];}export function analyzeWipDeployment(a){const b=classifyWipPath(a),c=b['is_local'];let d,e=[];if(c)b['type']==='local_http'?d='The\x20WIP\x20URL\x20\x27'+a+'\x27\x20is\x20a\x20'+b['description']+'.\x20'+'It\x20is\x20reachable\x20only\x20from\x20the\x20merchant\x27s\x20own\x20machine/LAN\x20—\x20customers\x20and\x20'+'on-chain\x20verifiers\x20on\x20other\x20machines\x20CANNOT\x20fetch\x20it.\x20Storing\x20it\x20on-chain\x20'+'makes\x20every\x20customer\x20order\x20fail.\x20'+'Deploy\x20the\x20.wip\x20file\x20to\x20a\x20public\x20host\x20(GitHub\x20Pages,\x20IPFS,\x20or\x20your\x20own\x20website)\x20'+'and\x20update\x20the\x20Service\x27s\x20sale\x20wip\x20with\x20the\x20public\x20URL.':d='The\x20WIP\x20path\x20\x27'+a+'\x27\x20is\x20a\x20LOCAL\x20'+b['type']+'\x20path.\x20'+'Local\x20paths\x20stored\x20on-chain\x20are\x20unreachable\x20by\x20customers\x20and\x20verifiers.\x20'+'Deploy\x20the\x20.wip\x20file\x20to\x20a\x20public\x20host\x20(GitHub\x20Pages,\x20IPFS,\x20or\x20your\x20own\x20website)\x20'+'and\x20update\x20the\x20Service\x27s\x20sale\x20wip\x20with\x20the\x20public\x20URL.',e=getDeployOptions(a);else{if(b['type']==='http_url')d='The\x20WIP\x20path\x20is\x20an\x20HTTP(S)\x20URL\x20—\x20verify\x20the\x20server\x20returns\x20200.\x20'+'If\x20the\x20URL\x20returns\x20404/403,\x20the\x20file\x20may\x20have\x20been\x20moved\x20or\x20deleted.',e=[];else{if(b['type']==='ipfs')d='The\x20WIP\x20path\x20is\x20an\x20IPFS\x20URL\x20—\x20verify\x20the\x20gateway\x20is\x20responsive.\x20'+'If\x20the\x20CID\x20is\x20unreachable,\x20the\x20file\x20may\x20have\x20been\x20unpinned.',e=[];else b['type']==='data_url'?(d='The\x20WIP\x20path\x20is\x20a\x20data\x20URL\x20—\x20content\x20is\x20embedded,\x20no\x20deployment\x20needed.',e=[]):(d='Unrecognized\x20WIP\x20path\x20format:\x20\x27'+a+'\x27',e=[]);}}return{'path':a,'classification':b,'needs_deployment':c,'reason':d,'options':e,'remind_update_hash':c};}export function formatDeployHints(a){if(!a['needs_deployment']&&a['options']['length']===0x0)return'';const b=[];b['push']('===\x20WIP\x20Deployment\x20Assistance\x20==='),b['push'](''),b['push']('Path:\x20'+a['path']),b['push']('Type:\x20'+a['classification']['description']),b['push']('Reason:\x20'+a['reason']),b['push']('');if(a['options']['length']>0x0){b['push']('Recommended\x20deployment\x20options:'),b['push']('');for(const c of a['options']){b['push']('▶\x20'+c['name']+'\x20(difficulty:\x20'+c['difficulty']+',\x20free:\x20'+c['free']+')'),b['push']('\x20\x20'+c['description']),b['push']('\x20\x20Resulting\x20URL\x20pattern:\x20'+c['result_url_pattern']),b['push']('\x20\x20Steps:');for(const d of c['steps']){b['push']('\x20\x20\x20\x20'+d);}if(c['notes']&&c['notes']['length']>0x0){b['push']('\x20\x20Notes:');for(const e of c['notes']){b['push']('\x20\x20\x20\x20-\x20'+e);}}b['push']('');}}return a['remind_update_hash']&&(b['push']('⚠️\x20After\x20deploying,\x20compute\x20the\x20new\x20WIP\x20hash\x20and\x20update\x20the\x20Service:'),b['push']('\x20\x201.\x20Re-run\x20wip_file\x20{\x20type:\x20\x27verify\x27,\x20wipFilePath:\x20\x27<new-public-url>\x27\x20}\x20to\x20confirm\x20the\x20file\x20is\x20reachable.'),b['push']('\x20\x202.\x20Extract\x20the\x20meta.hash\x20from\x20the\x20WIP\x20file\x20(or\x20use\x20wip_file\x20{\x20type:\x20\x27verify\x27\x20}\x20result).'),b['push']('\x20\x203.\x20Update\x20the\x20Service\x20on-chain:\x20onchain_operations\x20{\x20operation_type:\x20\x27service\x27,\x20data:\x20{\x20object:\x20\x27<service-id>\x27,\x20sales:\x20{\x20op:\x20\x27set\x27,\x20sales:\x20[{\x20...,\x20wip:\x20\x27<new-public-url>\x27,\x20wip_hash:\x20\x27<hash>\x27\x20}]\x20}\x20}\x20}'),b['push']('')),b['push']('==============================='),b['join']('\x0a');}
@@ -1 +1 @@
1
- import{classifyError,buildDataSemantic}from'../schema/call/semantic.js';import{buildClassifiedErrorResult}from'./shared.js';import{shouldRunLightHooks,shouldRunHeavyHooks,recordOperationFailure,recordCriticalRisk,recordCriticalOperation,recordSubstepFailure}from'../harness/auto-escalation.js';import{getHarnessTier,setHarnessTier,isEnabled}from'../config/runtime.js';import{getHarness}from'../harness/index.js';import{recover}from'../harness/recover.js';import{stableOperationId}from'../harness/operation-id.js';import{recordOperationOutcome}from'../experience/index.js';import{recordIndustrySignal}from'../knowledge/flywheel-loop.js';import{getStageCache}from'../playbooks/service-build/index.js';import{SERVICE_BUILD_STAGES}from'../playbooks/service-build/process.js';import{extractAmount,getAmountThreshold,formatAmount}from'../knowledge/safety-rules.js';import{LocalMark,query_serviceContext}from'@wowok/wowok';import{arbitrationVotingLockDetail,auditMachineNodes,computeTerminalReachability,guardTimeProfileDetail,lintReviewLockedTerminals,rewardRefsOf,serviceRewardsUnfundedDetail}from'../knowledge/audit-rules.js';import{lintGuard}from'../knowledge/guard-lint.js';import{parseGuardNodeGates}from'../knowledge/guard-node-gates.js';import{batchQueryObjectsByIds,fetchMachineNodes}from'../graph/onchain/sdk-batch.js';function stageIndexOf(a){const b=SERVICE_BUILD_STAGES['indexOf'](a);return b>=0x0?b:0x0;}export function withTimeout(a,b=0x7530,c='operation'){let d;return Promise['race']([a['finally'](()=>{if(d)clearTimeout(d);}),new Promise((e,f)=>{d=setTimeout(()=>{let g='';if(c['includes']('messenger'))g='\x20This\x20is\x20a\x20messenger\x20network\x20operation.\x20Possible\x20causes:\x20'+'(1)\x20messenger\x20server\x20(https://messenger.wowok.net)\x20unreachable,\x20'+'(2)\x20no\x20messenger-enabled\x20account\x20configured\x20(use\x20account_operation\x20to\x20set\x20messenger\x20name),\x20'+'(3)\x20network\x20connectivity\x20issue.\x20'+'Ensure\x20you\x20have\x20a\x20messenger-enabled\x20account\x20and\x20the\x20server\x20is\x20reachable.';else(c['includes']('onchain')||c['includes']('account_operation')||c['includes']('bridge')||c['includes']('workflow')||c['includes']('keeper')||c['includes']('wowok'))&&(g='\x20This\x20tool\x20may\x20submit\x20an\x20ON-CHAIN\x20transaction.\x20The\x20transaction\x20was\x20NOT\x20cancelled\x20'+'by\x20this\x20timeout\x20—\x20it\x20may\x20already\x20be\x20submitted\x20and\x20still\x20finalize\x20on-chain.\x20'+'DO\x20NOT\x20blindly\x20retry\x20(risk\x20of\x20duplicate\x20operations).\x20First\x20verify:\x20'+'(1)\x20if\x20the\x20error\x20above\x20carries\x20a\x20tx\x20digest,\x20check\x20it\x20via\x20query_toolkit\x20'+'(query_type=\x27onchain_transaction\x27);\x20(2)\x20otherwise\x20verify\x20via\x20query_toolkit\x20'+'onchain_events\x20(or\x20the\x20account\x27s\x20recent\x20transactions).\x20Do\x20NOT\x20rely\x20on\x20an\x20'+'onchain_objects\x20read\x20alone:\x20it\x20may\x20serve\x20a\x20pre-transaction\x20cached\x20snapshot,\x20'+'so\x20an\x20unchanged\x20object\x20must\x20never\x20on\x20its\x20own\x20justify\x20a\x20retry.');f(new Error('Operation\x20\x27'+c+'\x27\x20timed\x20out\x20after\x20'+b+'ms.'+g));},b);})]);}export function wrapHandlerWithErrorShape(a,b,c,d){return async(e,f)=>{try{return await withTimeout(a(e,f),b,c);}catch(g){if(d){const h=g instanceof Error?g['message']:String(g),i=classifyError(h,g),j={'operation_type':c,'data':e},k=d(h,i,j);return{'content':[{'type':'text','text':'Error:\x20'+h}],'structuredContent':k};}throw g;}};}export const statusErrorShape=(a,b,c)=>({'result':buildClassifiedErrorResult({'status':'error'},a,b),'semantic':buildDataSemantic(undefined,c,!![],a)});export const operationErrorShape=(a,b,c)=>({'result':buildClassifiedErrorResult({'operation':'error'},a,b),'semantic':buildDataSemantic(undefined,c,!![],a)});export const strictStatusErrorShape=(a,b,c)=>({'result':{'status':'error','error':a}});function checkProjectStage(a,b,c){const d={'analyze_intent':'puzzle','aggregate_risks':'risk','trace_substeps':'substeps'},e=d[a];if(!e)return null;const f=getStageCache(b,c);if(!f){if(a==='analyze_intent')return null;return'project_stage:\x20calling\x20\x27'+a+'\x27\x20before\x20\x27analyze_intent\x27\x20—\x20recommend\x20calling\x20analyze_intent\x20first\x20for\x20project\x20\x27'+b+':'+c+'\x27';}if(stageIndexOf(f['stage'])<stageIndexOf(e)-0x1)return'project_stage:\x20calling\x20\x27'+a+'\x27\x20(stage\x20\x27'+e+'\x27)\x20but\x20project\x20is\x20at\x20stage\x20\x27'+f['stage']+'\x27\x20—\x20recommend\x20completing\x20prior\x20stages\x20first\x20for\x20\x27'+b+':'+c+'\x27';return null;}export function dispatchWithHarness(a,b){return async(d,f)=>{const g=[],h=getHarness(),i=shouldRunLightHooks(),j=shouldRunHeavyHooks(),k=isPublishOperation(b,d),l=isSignOperation(b,d),m=isBuyOperation(b,d),n=getHarnessTier();if(b==='goal_operation'&&i)try{const p=d,q=p?.['action'],r=p?.['project'],s=p?.['version'];if(q&&r&&s){const t=checkProjectStage(q,r,s);t&&g['push'](t);}}catch{}k&&n==='lightweight'&&(setHarnessTier('full'),g['push']('pre_publish:\x20tier\x20forced\x20to\x20full\x20for\x20publish-class\x20operation\x20(GLM5-21\x20§3.3)'));if(k&&n!=='off')try{const u=await runPrePublishChecks(b,d);g['push'](...u['warnings']);if(u['critical']['length']>0x0){for(const v of u['critical']){const x=recordCriticalRisk(v);if(x)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+x['reason']);}return buildHarnessBlockResult('pre_publish','Publish\x20BLOCKED\x20by\x20Harness\x20pre-publish\x20gate\x20(GLM5-21\x20V6):\x20'+(u['critical']['length']+'\x20CRITICAL\x20risk(s)\x20must\x20be\x20resolved\x20before\x20publish.'),u['critical'],u['warnings'],'immutable_violation','Fix\x20the\x20CRITICAL\x20risks\x20listed\x20in\x20the\x20message\x20(e.g.\x20rename\x20dispute\x20nodes\x20per\x20R-M1-11\x20—\x20disputes\x20live\x20off-Machine;\x20bare\x20fund-terminal\x20names\x20only\x20warn\x20but\x20must\x20carry\x20an\x20anchored\x20refund\x20rail),\x20add\x20the\x20entry\x20pair\x20prev_node=\x22\x22,\x20then\x20retry\x20publish.\x20Nodes/pairs/forwards\x20are\x20immutable\x20after\x20publish\x20—\x20verify\x20via\x20machineNode2file\x20first.');}}catch(y){g['push']('pre_publish\x20hook\x20failed:\x20'+(y instanceof Error?y['message']:String(y)));}if(l&&j)try{const z=extractData(d),A=z?extractAmount(z,{'excludeConfigAmounts':!![]}):null;if(A!==null){const B=getAmountThreshold();let C=null;try{C=BigInt(A);}catch{C=null;}if(C!==null&&C>B){const D=await skuMatchedOrderTotalExemption(z,d?.['env']?.['network']);if(D)g['push']('pre_sign:\x20order\x20total\x20'+A+'\x20exceeds\x20the\x20full-tier\x20threshold\x20'+B['toString']()+'\x20(smallest\x20unit)\x20—\x20'+'EXEMPTED\x20(M-K11-a):\x20exact\x20catalog\x20match\x20Σ\x20price×quantity\x20against\x20the\x20Service\x27s\x20published\x20sales'+(D['coinType']?',\x20payment\x20coin\x20'+D['coinType']:'')+'.');else return buildHarnessBlockResult('pre_sign','Sign\x20BLOCKED\x20by\x20Harness\x20pre-sign\x20gate\x20(GLM5-21\x20V7):\x20amount\x20'+formatAmount(C)+'\x20WOW\x20exceeds\x20the\x20full-tier\x20threshold\x20'+formatAmount(B)+'\x20WOW.',['amount\x20'+A+'\x20(smallest\x20unit)\x20>\x20threshold\x20'+B['toString']()+'\x20(smallest\x20unit)'],[],'invalid_parameter','Raise\x20WOWOK_AMOUNT_THRESHOLD\x20to\x20match\x20the\x20intended\x20amount,\x20split\x20the\x20transaction,\x20or\x20reset\x20the\x20harness\x20tier\x20to\x20lightweight\x20(config_operation)\x20after\x20explicit\x20user\x20confirmation.\x20'+'M-K11-a:\x20catalog-priced\x20order_new\x20buys\x20(total_pay\x20EXACTLY\x20equal\x20to\x20Σ\x20price×quantity\x20of\x20PUBLISHED\x20sales)\x20are\x20exempted\x20automatically\x20—\x20'+'if\x20this\x20IS\x20a\x20catalog-priced\x20buy,\x20verify\x20every\x20item\x20name/quantity\x20against\x20the\x20service\x27s\x20current\x20sales\x20and\x20retry.');}}}catch(E){g['push']('pre_sign\x20hook\x20failed:\x20'+(E instanceof Error?E['message']:String(E)));}if(m&&n!=='off')try{const F=await runPreBuyChecks(b,d);g['push'](...F['warnings']);if(F['critical']['length']>0x0){for(const G of F['critical']){const H=recordCriticalRisk(G);if(H)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+H['reason']);}return buildHarnessBlockResult('pre_buy','Purchase\x20BLOCKED\x20by\x20Harness\x20pre-buy\x20gate:\x20'+F['critical']['length']+'\x20CRITICAL\x20allocator\x20risk(s)\x20—\x20'+'paying\x20into\x20this\x20service\x20as\x20currently\x20configured\x20would\x20fail\x20on-chain\x20or\x20lock\x20funds\x20with\x20no\x20distribution\x20path.',F['critical'],F['warnings'],'state_conflict','Do\x20NOT\x20retry\x20this\x20purchase\x20against\x20the\x20current\x20service\x20state.\x20Read\x20the\x20service\x27s\x20effective\x20allocator\x20plan\x20'+'(query_toolkit\x20query_type=\x27service_panorama\x27,\x20field\x20order_allocators)\x20and\x20confirm\x20every\x20finding\x20above\x20is\x20resolved\x20'+'(merchant\x20fixes\x20the\x20plan\x20—\x20post-publish\x20append\x20is\x20allowed\x20—\x20or\x20the\x20guard\x20definitions\x20are\x20repaired).\x20'+'Only\x20retry\x20the\x20buy\x20after\x20the\x20on-chain\x20state\x20changes;\x20otherwise\x20choose\x20a\x20different\x20service.');}}catch(I){g['push']('pre_buy\x20hook\x20failed:\x20'+(I instanceof Error?I['message']:String(I)));}let o;try{o=await a(d,f);}catch(J){const K=J instanceof Error?J['message']:String(J),L=recordOperationFailure(b,K);L&&g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+L['reason']);if(b==='onchain_operations')try{const M=classifyError(K,J);if(!M['retryable']&&M['error_code']!=='unknown'){const N=recordCriticalOperation(b,M['error_code']);if(N)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+N['reason']);}}catch{}throw J;}if(b==='onchain_operations')try{if(classifyOutcome(o)==='failed'){const O=extractErrorCode(o)??'',P=classifyError(O);if(!P['retryable']&&P['error_code']!=='unknown'){const Q=recordCriticalOperation(b,P['error_code']);if(Q)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+Q['reason']);}}}catch{}if(i&&!isOutcomeDiscriminated(o)){const R=stableOperationId(extractIntent(b,d)??b,extractData(d));try{const S=classifyOutcome(o);if(S==='failed'){const T=extractErrorCode(o)??'',U=classifyError(T),V=h['recover'](U['error_code'],R,{'operation_type':b,'data':extractData(d)});g['push']('Harness\x20recover:\x20strategy='+V['strategy']+('\x20(attempt\x20'+V['current_attempt']+'/'+V['max_attempts']+')')+(V['should_retry']?'\x20—\x20retryable':'\x20—\x20do\x20NOT\x20retry\x20blindly')+(V['user_prompt']?'\x20—\x20'+V['user_prompt']:'\x20—\x20'+V['detail']));}else S==='success'&&h['resetRecovery'](R);}catch(W){g['push']('recover\x20hook\x20failed:\x20'+(W instanceof Error?W['message']:String(W)));}}if(b==='goal_operation')try{const X=d?.['action'];if(X==='trace_substeps'){const Y=extractCriticalFindingCount(o);if(Y>0x0){const Z=recordSubstepFailure(String(X)+':\x20'+Y+'\x20critical\x20finding(s)');if(Z)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+Z['reason']);}}}catch{}if(isWriteClassTool(b)&&!SEMANTIC_RECORDED_TOOLS['has'](b))try{const a0=extractOperationType(b,d)??b,a1=extractIntent(b,d)??b,a2=extractData(d)??d,a3=classifyOutcome(o),a4=extractErrorCode(o),a5=isEnabled('experience_layer');if(a5)recordOperationOutcome(a0,a2,a1,a3,a4);else{const a6=extractIndustry(d);a6&&isEnabled('industry_evolution')&&recordIndustrySignal(a6,{'type':a0},{'success':a3==='success','error_code':a4});}}catch(a7){g['push']('signal\x20collection\x20failed:\x20'+(a7 instanceof Error?a7['message']:String(a7)));}if(g['length']>0x0){if(o?.['structuredContent']){const a8=o['structuredContent'],a9=a8['semantic'];if(a9){const aa=Array['isArray'](a9['warnings'])?a9['warnings']:[];a9['warnings']=[...aa,...g];}else for(const ab of g){console['warn']('[harness]\x20'+ab);}}else for(const ac of g){console['warn']('[harness]\x20'+ac);}}return o;};}function isPublishOperation(a,b){if(a!=='onchain_operations')return![];const c=extractOperationType(a,b);if(c!=='service'&&c!=='machine')return![];const d=extractData(b);return d?.['publish']===!![]||d?.['bPublished']===!![];}function isSignOperation(a,b){if(a==='wip_file'){const c=b?.['operation_type'];return c==='sign';}return a==='onchain_operations';}function isBuyOperation(a,b){if(a!=='onchain_operations')return![];if(extractOperationType(a,b)!=='service')return![];const c=extractData(b);return c?.['buy']!=null&&typeof c['object']==='string'&&c['object']!=='';}function extractOperationType(a,b){if(!b||typeof b!=='object')return undefined;const c=b;if(a==='onchain_operations')return typeof c['operation_type']==='string'?c['operation_type']:undefined;if(a==='goal_operation'||a==='industry_pack_operation'||a==='strategy_review_operation')return typeof c['action']==='string'?c['action']:undefined;return typeof c['operation_type']==='string'?c['operation_type']:undefined;}function extractIntent(a,b){if(!b||typeof b!=='object')return undefined;const c=b;if((a==='goal_operation'||a==='industry_pack_operation'||a==='strategy_review_operation')&&typeof c['action']==='string')return a+':'+c['action'];const d=c['operation_type'];if(typeof d==='string')return a+':'+d;return a;}function extractData(a){if(!a||typeof a!=='object')return undefined;const b=a,c=b['data'];return c&&typeof c==='object'?c:undefined;}export async function skuMatchedOrderTotalExemption(a,b){try{if(!a)return undefined;const c=a['order_new']?.['buy'];if(!c||c['discount']!=null)return undefined;const d=c?.['total_pay']?.['balance']??c?.['total_pay'];if(d===null||d===undefined||typeof d==='object')return undefined;const e=Array['isArray'](c['items'])?c['items']:[];if(e['length']===0x0)return undefined;const f=a['object'];if(typeof f!=='string'||f['length']===0x0)return undefined;const g=f['startsWith']('0x')?f:await LocalMark['Instance']()['get_address'](f)??undefined;if(!g)return undefined;const h=await query_serviceContext({'service':g,'network':b}),i=h?.['service'];if(!i)return undefined;if(i['bPublished']!==!![])return undefined;const j=String(i?.['type_raw']??i?.['type']??'')['match'](/<(.+)>$/)?.[0x1],k=Array['isArray'](i['sales'])?i['sales']:[];let l=0x0n;for(const n of e){const o=k['find'](r=>r?.['name']===n?.['name']);if(!o||o?.['suspension']===!![])return undefined;const p=BigInt(String(o?.['price']?.['balance']??o?.['price']??'0')),q=BigInt(String(n?.['quantity']??'1'));if(q<=0x0n)return undefined;l+=p*q;}let m;try{m=BigInt(String(d));}catch{return undefined;}if(m!==l)return undefined;return{'coinType':j};}catch{return undefined;}}const WRITE_CLASS_TOOLS=new Set(['onchain_operations','goal_operation','industry_pack_operation','strategy_review_operation','wip_file','messenger_operation','bridge_operation']),SEMANTIC_RECORDED_TOOLS=new Set(['onchain_operations','bridge_operation']);function isWriteClassTool(a){return WRITE_CLASS_TOOLS['has'](a);}function classifyOutcome(a){if(!a?.['structuredContent'])return'failed';const b=a['structuredContent'];if(b['outcome']==='failed')return'failed';if(b['outcome']==='executed')return'success';if(b['outcome']==='pending_input')return'partial';const c=b['verdict'];if(c&&typeof c==='object'&&c['buildable']===![])return'failed';const d=typeof b['status']==='string'?b['status']:typeof b['result_type']==='string'?b['result_type']:b['result']&&typeof b['result']==='object'&&typeof b['result']['status']==='string'?b['result']['status']:'';if(d==='error'||d==='failed'||d==='schema_mismatch')return'failed';if(d==='partial')return'partial';return'success';}function isOutcomeDiscriminated(a){const b=a?.['structuredContent'];return!!b&&typeof b==='object'&&'outcome'in b;}function extractErrorCode(a){if(!a?.['structuredContent'])return undefined;const b=a['structuredContent'];if(typeof b['error_code']==='string')return b['error_code'];const c=b['error'];if(typeof c==='string')return c;if(c&&typeof c==='object'){const d=c['code'];if(typeof d==='string')return d;}return undefined;}function extractIndustry(a){if(!a||typeof a!=='object')return undefined;const b=a;if(typeof b['industry']==='string')return b['industry'];const c=b['data'];if(c&&typeof c==='object'){const e=c;if(typeof e['industry']==='string')return e['industry'];}return undefined;}function numericBalance(a){if(typeof a==='number'&&Number['isFinite'](a))return a;if(typeof a==='string'&&a['trim']()!==''&&Number['isFinite'](Number(a)))return Number(a);if(typeof a==='bigint')return Number(a);return undefined;}function collectAllocatorGuards(b){const c=new Map();for(const d of b){const e=d?.['allocators'];if(!Array['isArray'](e))continue;for(const f of e){const g=f?.['guard'];if(typeof g!=='string'||g['trim']()==='')continue;const h=g['toLowerCase']();let i=c['get'](h);!i&&(i={'ref':g,'recipients':new Set(),'slots':new Set()},c['set'](h,i));const j=f?.['sharing'];if(!Array['isArray'](j))continue;for(const k of j){const l=k?.['who'];if(!l||typeof l!=='object')continue;if('Signer'in l)i['recipients']['add']('Signer');else{if('Entity'in l)i['recipients']['add']('Entity');else{if('GuardIdentifier'in l){i['recipients']['add']('GuardIdentifier');const m=l['GuardIdentifier'],o=Number(m);if(Number['isFinite'](o))i['slots']['add'](o);}}}}}}return c;}async function lintAllocatorGuardSet(a,b,c,f){const h=[],i=[],j=collectAllocatorGuards(a);if(j['size']===0x0)return{'critical':h,'warnings':i};let l;try{l=await batchQueryObjectsByIds([...j['values']()]['map'](n=>n['ref']),b,!![]);}catch(n){return i['push'](c+':\x20allocator\x20guard\x20lint\x20skipped\x20—\x20could\x20not\x20query\x20guard\x20objects\x20'+('('+(n instanceof Error?n['message']:String(n))+');\x20')+(c==='pre_buy'?'the\x20guard\x20layer\x20of\x20this\x20service\x27s\x20allocator\x20plan\x20is\x20UNVERIFIED\x20—\x20verify\x20the\x20guards\x20yourself\x20before\x20trusting\x20this\x20buy':'run\x20guard\x20lint\x20manually\x20BEFORE\x20publish\x20(order_allocators\x20immutable\x20after\x20publish,\x20IMMUT-002)')),{'critical':h,'warnings':i};}const m=new Map();for(const o of l??[]){const p=o;if(p?.['type']!=='Guard')continue;for(const q of[p['query_name'],p['object']]){if(typeof q==='string'&&q!=='')m['set'](q['toLowerCase'](),p);}}for(const [r,s]of j){const t=m['get'](r);if(!t){const z=c+':\x20allocator\x20guard\x20\x22'+s['ref']+'\x22\x20not\x20found\x20on-chain\x20—\x20'+(f==='critical'?'the\x20pool\x20accepts\x20funds\x20but\x20no\x20distribution\x20run\x20can\x20ever\x20pass\x20a\x20missing\x20guard\x20(fund-lock\x20risk)':'lint\x20skipped\x20for\x20this\x20guard;\x20verify\x20the\x20guard\x20exists\x20and\x20is\x20final\x20BEFORE\x20publish\x20(order_allocators\x20immutable\x20after\x20publish,\x20IMMUT-002)');if(f==='critical')h['push'](z);else i['push'](z);continue;}const u=t['data']??t,v=Array['isArray'](u?.['table'])?u['table']:[],w=Array['isArray'](u?.['relies'])?u['relies']:[];for(const A of s['slots']){const B=v['find'](D=>Number(D?.['identifier'])===A),C=B!=null&&B['b_submission']===!![]&&String(B['value_type'])==='Address';!C&&h['push'](c+':\x20allocator\x20guard\x20\x22'+s['ref']+'\x22\x20pays\x20a\x20{GuardIdentifier:\x20'+A+'}\x20leg\x20but\x20its\x20table\x20has\x20'+(B==null?'NO\x20slot\x20'+A+'\x20row':'slot\x20'+A+'\x20as\x20a\x20STATIC\x20row\x20(b_submission:\x20'+(B['b_submission']===!![])+',\x20value_type:\x20'+String(B['value_type'])+')')+'\x20—\x20the\x20passport\x20only\x20emits\x20DECLARED\x20submission\x20slots\x20and\x20allocation\x20asserts\x20the\x20slot\x20equals\x20the\x20paying\x20'+'order,\x20so\x20this\x20rail\x20aborts\x20at\x20alloc\x20(code\x2015,\x20ERECIPIENT_NOT_FOR_OBJECT)\x20with\x20the\x20leg\x27s\x20funds\x20stranded.\x20'+'Anchor\x20the\x20leg\x20on\x20protocol\x20slot\x20254\x20(auto-written\x20with\x20the\x20paying\x20order\x20id\x20at\x20order\x20creation)\x20or\x20declare\x20'+('{identifier:\x20'+A+',\x20b_submission:\x20true,\x20value_type:\x20\x22Address\x22}\x20in\x20the\x20guard\x20table\x20BEFORE\x20publish'));}const x={'description':typeof u?.['description']==='string'?u['description']:undefined,'table':v['map'](D=>({'identifier':Number(D?.['identifier']??0x0),'b_submission':!!D?.['b_submission'],'value_type':D?.['value_type']!==undefined?String(D['value_type']):undefined,'value':D?.['value'],'name':D?.['name']!==undefined?String(D['name']):undefined,'object_type':D?.['object_type']!==undefined?String(D['object_type']):undefined})),'root':u?.['root'],'rely':w['length']>0x0?{'guards':w['map'](D=>String(D)),'logic_or':!u?.['relies_logic_and']}:undefined,'binding_hint':{'host_object':'Service','binding_field':'order_allocators','sharing_recipients':s['recipients']['size']>0x0?[...s['recipients']]:undefined}},y=guardTimeProfileDetail({'ref':s['ref'],'description':typeof u?.['description']==='string'?u['description']:undefined,'table':v,'root':u?.['root']});if(y){const D='pre_publish:\x20R-TIME-PROFILE\x20—\x20allocator\x20guard\x20\x22'+s['ref']+'\x22:\x20'+y['detail'];if(y['level']==='critical')h['push'](D);else i['push'](D);}try{const E=await lintGuard(x,{'auto_fix':![]});for(const F of E['diagnostics']){const G=c+':\x20allocator\x20guard\x20\x22'+s['ref']+'\x22\x20'+F['code']+'\x20('+F['source']+'):\x20'+F['message']+'\x20at\x20'+F['location']['path'];if(F['severity']==='error')h['push'](G);else{if(F['severity']==='warning')i['push'](G);}}}catch(H){i['push'](c+':\x20allocator\x20guard\x20\x22'+s['ref']+'\x22\x20lint\x20failed\x20'+('('+(H instanceof Error?H['message']:String(H))+')\x20—\x20non-blocking'));}}return{'critical':h,'warnings':i};}function collectForwardGuardRefs(a){const b=new Map();for(const c of a){const d=c,e=Array['isArray'](d?.['pairs'])?d['pairs']:Array['isArray'](d?.['value'])?d['value']:[];for(const h of e){const i=h,j=Array['isArray'](i?.['forwards'])?i['forwards']:[];for(const k of j){const l=k,m=l?.['guard'],n=typeof m==='string'&&m['trim']()!==''?m:m&&typeof m==='object'?m['guard']??m['$ref']:undefined;typeof n==='string'&&n['trim']()!==''&&b['set'](n['toLowerCase'](),n);}}}return b;}async function fetchForwardGuardIndex(a,b){const c=collectForwardGuardRefs(a),d=new Map();if(c['size']===0x0)return{'refs':c,'defs':d};try{const f=await batchQueryObjectsByIds([...c['values']()],b,!![]);for(const h of f??[]){const i=h;if(i?.['type']!=='Guard')continue;for(const j of[i['query_name'],i['object']]){if(typeof j==='string'&&j!=='')d['set'](j['toLowerCase'](),i);}}return{'refs':c,'defs':d};}catch(l){return{'refs':c,'defs':d,'error':l instanceof Error?l['message']:String(l)};}}function lintForwardGuardsTaskBinding(a){const b=[],c=[];if(a['refs']['size']===0x0)return{'critical':b,'warnings':c};if(a['error']!==undefined)return c['push']('pre_publish:\x20forward-guard\x20lints\x20(task-binding\x20+\x20review-lock)\x20skipped\x20—\x20could\x20not\x20query\x20guard\x20objects\x20'+('('+a['error']+');\x20verify\x20every\x20forward\x20guard\x20carries\x20the\x20protocol\x20slot\x20254\x20Address\x20submission\x20row\x20and\x20')+'that\x20no\x20settlement\x20rail\x20is\x20review-locked\x20BEFORE\x20publish\x20(immutable\x20after\x20publish,\x20IMMUT-001)'),{'critical':b,'warnings':c};for(const [d,e]of a['refs']){const f=a['defs']['get'](d);if(!f){c['push']('pre_publish:\x20forward-bound\x20guard\x20\x22'+e+'\x22\x20not\x20found\x20on-chain\x20—\x20task-binding\x20lint\x20skipped\x20for\x20it;\x20'+'ensure\x20it\x20exists\x20and\x20carries\x20the\x20protocol\x20slot\x20254\x20Address\x20submission\x20row\x20BEFORE\x20publish\x20'+'(immutable\x20after\x20publish,\x20IMMUT-001)');continue;}const g=f['data']??f,h=Array['isArray'](g?.['table'])?g['table']:[],i=h['some'](j=>Number(j?.['identifier'])===0xfe&&j?.['b_submission']===!![]&&String(j?.['value_type'])==='Address');!i&&b['push']('pre_publish:\x20forward-bound\x20guard\x20\x22'+e+'\x22\x20has\x20NO\x20protocol\x20slot\x20254\x20Address\x20submission\x20row\x20—\x20'+'the\x20passport\x20only\x20emits\x20DECLARED\x20slots,\x20so\x20once\x20a\x20Service\x20binds\x20this\x20Machine\x20EVERY\x20forward\x20this\x20'+'guard\x20gates\x20aborts\x20(code\x2011)\x20and\x20escrowed\x20funds\x20can\x20never\x20advance.\x20Machine\x20topology\x20is\x20immutable\x20'+'after\x20publish\x20(IMMUT-001):\x20add\x20{identifier:254,\x20b_submission:true,\x20value_type:\x22Address\x22}\x20to\x20the\x20'+'guard\x27s\x20table\x20(recreate\x20the\x20guard\x20unfrozen\x20if\x20it\x20is\x20frozen)\x20BEFORE\x20publishing\x20this\x20Machine');}return{'critical':b,'warnings':c};}function lintForwardReviewLocks(a,b){if(b['error']!==undefined||b['refs']['size']===0x0)return{'critical':[],'warnings':[]};const c=new Map();for(const [d,e]of b['defs']){const f=new Set();collectGuardNodeGates(e,f);if(f['size']>0x0)c['set'](d,[...f]);}return lintReviewLockedTerminals(a,c);}function lintForwardGuardsTimeProfile(a){const b=[],c=[];if(a['error']!==undefined||a['refs']['size']===0x0)return{'critical':b,'warnings':c};for(const [d,e]of a['refs']){const f=a['defs']['get'](d);if(!f)continue;const g=f['data']??f,h=guardTimeProfileDetail({'ref':e,'description':g?.['description'],'table':Array['isArray'](g?.['table'])?g['table']:undefined,'root':g?.['root']});if(h){const i='pre_publish:\x20R-TIME-PROFILE\x20—\x20forward-bound\x20guard\x20\x22'+e+'\x22:\x20'+h['detail'];if(h['level']==='critical')b['push'](i);else c['push'](i);}}return{'critical':b,'warnings':c};}async function lintAllocatorGuards(a,b){return lintAllocatorGuardSet([a['order_allocators'],a['order_allocators_append']],b,'pre_publish','warning');}async function lintServiceEscrowExitCoverage(b,c,d){const f=[],h=[];let i=[];try{i=await fetchMachineNodes(b,d,!![]);}catch(p){return f['push']('pre_publish:\x20escrow-exit\x20gate\x20could\x20not\x20fetch\x20machine\x20\x22'+b+'\x22\x20nodes\x20'+('('+(p instanceof Error?p['message']:String(p))+')\x20—\x20terminal\x20coverage\x20UNVERIFIABLE;\x20publish\x20blocked.\x20')+'Retry\x20when\x20the\x20network\x20is\x20reachable'),{'critical':f,'warnings':h};}if(i['length']===0x0)return h['push']('pre_publish:\x20escrow-exit\x20gate\x20skipped\x20—\x20machine\x20has\x20no\x20nodes\x20to\x20cover'),{'critical':f,'warnings':h};const j=computeTerminalReachability(i);if(j['terminals']['length']===0x0)return{'critical':f,'warnings':h};const k=new Map();let l=0x0;for(const q of c){if(!Array['isArray'](q))continue;for(const r of q){l++;const s=r?.['guard'];if(typeof s==='string'&&s['trim']()!=='')k['set'](s['toLowerCase'](),s);}}if(k['size']===0x0)return f['push']('pre_publish:\x20machine\x20terminal\x20node(s)\x20'+j['terminals']['map'](t=>'\x22'+t+'\x22')['join'](',\x20')+'\x20have\x20NO\x20allocator\x20rail\x20—\x20'+(l===0x0?'order_allocators\x20is\x20empty\x20in\x20this\x20call,\x20so\x20':'no\x20allocator\x20row\x20carries\x20a\x20guard\x20ref,\x20so\x20')+'an\x20order\x20stopping\x20at\x20any\x20terminal\x20strands\x20its\x20escrow\x20by\x20construction\x20(immutable\x20after\x20publish,\x20IMMUT-002).\x20'+'Every\x20terminal\x20needs\x20a\x20settlement/refund\x20allocator\x20whose\x20guard\x20gates\x20progress.current\x20==\x20<terminal>\x20'+'(canonical\x20designs:\x20tpl_allocator_node_gate_settle\x20/\x20tpl_allocator_node_gate_refund,\x20M-T12)'),{'critical':f,'warnings':h};let m;try{m=await batchQueryObjectsByIds([...k['values']()],d,!![]);}catch(t){return h['push']('pre_publish:\x20escrow-exit\x20coverage\x20UNVERIFIED\x20—\x20could\x20not\x20query\x20allocator\x20guards\x20'+('('+(t instanceof Error?t['message']:String(t))+');\x20run\x20guard\x20lint\x20manually\x20BEFORE\x20publish\x20')+'(terminal(s)\x20in\x20question:\x20'+j['terminals']['join'](',\x20')+')'),{'critical':f,'warnings':h};}const n=new Set();for(const u of m??[]){const v=u;if(v?.['type']!=='Guard')continue;collectGuardNodeGates(v,n);}const o=j['terminals']['filter'](w=>!n['has'](w));return o['length']>0x0&&f['push']('pre_publish:\x20terminal\x20node(s)\x20'+o['map'](w=>'\x22'+w+'\x22')['join'](',\x20')+'\x20have\x20NO\x20allocator\x20rail\x20—\x20'+'an\x20order\x20that\x20reaches\x20a\x20terminal\x20moves\x20no\x20money\x20by\x20itself,\x20so\x20its\x20escrow\x20strands\x20permanently\x20'+'(mainnet:\x200.299\x20stranded\x20at\x20an\x20un-railied\x20terminal;\x20ofshop:\x200.25\x20stranded\x20at\x20\x27expired\x27).\x20Every\x20terminal\x20'+'needs\x20a\x20settlement/refund\x20allocator\x20whose\x20guard\x20gates\x20progress.current\x20==\x20<terminal>\x20(canonical\x20designs:\x20'+'tpl_allocator_node_gate_settle\x20/\x20tpl_allocator_node_gate_refund,\x20M-T12).\x20If\x20the\x20pool\x20legitimately\x20drains\x20'+'at\x20an\x20earlier\x20node,\x20add\x20a\x20zero-value\x20anchor\x20row\x20on\x20the\x20terminal\x20rail\x20so\x20the\x20guard\x20resolves\x20without\x20paying'),{'critical':f,'warnings':h};}function collectGuardNodeGates(a,b){const c=a['data']??a;for(const d of parseGuardNodeGates(c?.['root'],c?.['table']))b['add'](d);}async function checkArbitrationNeutrality(b,c){const d=[],f=[],g=[],h=p=>{const q=typeof p==='string'?p:p?.['object']??p?.['name'];if(typeof q==='string'&&q!==''&&!g['includes'](q))g['push'](q);};for(const p of Array['isArray'](b['arbitrations'])?b['arbitrations']:[])h(p);let i=typeof b['permission']==='string'?b['permission']:undefined;const j=typeof b['object']==='string'?b['object']:undefined;if(j){let q;try{const r=await batchQueryObjectsByIds([j],c,!![]);q=(r??[])['find'](s=>s?.['type']==='Service');}catch(s){f['push']('pre_publish:\x20arbitration\x20neutrality\x20check\x20DEGRADED\x20—\x20could\x20not\x20query\x20service\x20\x22'+j+'\x22\x20'+('('+(s instanceof Error?s['message']:String(s))+').\x20Verify\x20manually\x20that\x20every\x20bound\x20arbitration\x27s\x20')+'Permission\x20owner/admin\x20set\x20is\x20DISJOINT\x20from\x20the\x20service\x27s\x20controller\x20keys\x20before\x20publishing');}if(q){const t=q['data']??q;if(!i&&typeof t['permission']==='string')i=t['permission'];for(const u of Array['isArray'](t['arbitrations'])?t['arbitrations']:[])h(u);}}if(g['length']===0x0)return{'critical':d,'warnings':f};if(!i)return f['push']('pre_publish:\x20arbitration\x20neutrality\x20check\x20DEGRADED\x20—\x20the\x20service\x20Permission\x20address\x20is\x20not\x20resolvable\x20'+'from\x20this\x20call\x20(no\x20payload\x20\x27permission\x27,\x20service\x20object\x20not\x20found).\x20The\x20bound\x20arbitrations\x27\x20controller\x20'+'keys\x20are\x20UNVERIFIED:\x20confirm\x20each\x20arbitration\x20Permission\x27s\x20owner/admin\x20set\x20is\x20disjoint\x20from\x20the\x20service\x27s\x20'+'controller\x20keys\x20(same-controller\x20arbitration\x20=\x20the\x20merchant\x20can\x20rule\x20their\x20own\x20disputes)'),{'critical':d,'warnings':f};let k;try{k=await batchQueryObjectsByIds([i,...g],c,!![]);}catch(v){return f['push']('pre_publish:\x20arbitration\x20neutrality\x20check\x20DEGRADED\x20—\x20object\x20query\x20failed\x20'+('('+(v instanceof Error?v['message']:String(v))+').\x20Verify\x20the\x20arbitration\x20Permissions\x27\x20owner/admin\x20sets\x20')+'are\x20disjoint\x20from\x20the\x20service\x27s\x20controller\x20keys\x20before\x20publishing'),{'critical':d,'warnings':f};}const l=w=>(k??[])['find'](x=>{const y=x;return typeof y?.['object']==='string'&&y['object']['toLowerCase']()===w['toLowerCase']()||typeof y?.['query_name']==='string'&&y['query_name']['toLowerCase']()===w['toLowerCase']();}),m=w=>{if(!w)return new Set();const x=w['data']??w,y=new Set();for(const z of[x['builder']])if(typeof z==='string'&&z)y['add'](z['toLowerCase']());for(const A of Array['isArray'](x['admin'])?x['admin']:[])if(typeof A==='string'&&A)y['add'](A['toLowerCase']());return y;},n=l(i),o=m(n);if(o['size']===0x0)return f['push']('pre_publish:\x20arbitration\x20neutrality\x20check\x20DEGRADED\x20—\x20service\x20Permission\x20\x22'+i+'\x22\x20not\x20found\x20or\x20'+'carries\x20no\x20builder/admin\x20list.\x20The\x20bound\x20arbitrations\x27\x20controller\x20keys\x20are\x20UNVERIFIED\x20—\x20confirm\x20disjointness\x20manually'),{'critical':d,'warnings':f};for(const w of g){const x=l(w);if(!x){f['push']('pre_publish:\x20arbitration\x20\x22'+w+'\x22\x20not\x20found\x20on-chain\x20(or\x20not\x20yet\x20indexed)\x20—\x20its\x20Permission\x20controller\x20'+'keys\x20are\x20UNVERIFIED.\x20Confirm\x20the\x20arbitration\x20Permission\x27s\x20builder/admin\x20set\x20is\x20disjoint\x20from\x20the\x20service\x27s\x20'+'controller\x20keys\x20(same-controller\x20arbitration\x20=\x20the\x20merchant\x20can\x20rule\x20their\x20own\x20disputes)');continue;}const y=x['data']??x,z=typeof y['permission']==='string'?y['permission']:undefined;if(!z){f['push']('pre_publish:\x20arbitration\x20\x22'+w+'\x22\x20exposes\x20no\x20permission\x20address\x20—\x20controller-key\x20disjointness\x20UNVERIFIED');continue;}if(z['toLowerCase']()===i['toLowerCase']()){d['push']('pre_publish:\x20R-ARB-SAME-CONTROLLER\x20—\x20arbitration\x20\x22'+w+'\x22\x20shares\x20the\x20service\x27s\x20Permission\x20object\x20'+('('+i+').\x20The\x20chain\x20aborts\x20this\x20binding\x20(E_ARBITRATION_PERMISSION_CONFLICT);\x20bind\x20an\x20')+'arbitration\x20with\x20its\x20own\x20independent\x20Permission');continue;}if(!l(z))try{const D=await batchQueryObjectsByIds([z],c,!![]);k=[...k??[],...D??[]];}catch(E){f['push']('pre_publish:\x20arbitration\x20\x22'+w+'\x22\x20Permission\x20\x22'+z+'\x22\x20could\x20not\x20be\x20queried\x20'+('('+(E instanceof Error?E['message']:String(E))+')\x20—\x20controller-key\x20disjointness\x20UNVERIFIED'));continue;}const A=m(l(z));if(A['size']===0x0){f['push']('pre_publish:\x20arbitration\x20\x22'+w+'\x22\x20Permission\x20\x22'+z+'\x22\x20not\x20found\x20or\x20carries\x20no\x20builder/admin\x20list\x20—\x20'+'controller-key\x20disjointness\x20UNVERIFIED');continue;}const B=[...o]['filter'](F=>A['has'](F));B['length']>0x0&&d['push']('pre_publish:\x20R-ARB-SAME-CONTROLLER\x20—\x20the\x20arbitration\x20\x22'+w+'\x22\x20is\x20NOT\x20controller-independent:\x20'+('EOA(s)\x20'+B['join'](',\x20')+'\x20appear\x20in\x20BOTH\x20the\x20service\x20Permission\x20('+i+')\x20and\x20the\x20')+('arbitration\x20Permission\x20('+z+')\x20builder/admin\x20sets.\x20Object\x20isolation\x20is\x20enforced\x20on-chain\x20')+'(different\x20Permission\x20objects),\x20but\x20controller\x20isolation\x20is\x20NOT:\x20a\x20shared\x20EOA\x20can\x20confirm,\x20vote\x20in,\x20'+'and\x20rule\x20the\x20service\x27s\x20disputes\x20—\x20arbitration\x20neutrality\x20collapses\x20(live\x20mainnet:\x20the\x20reused\x20arb\x27s\x20'+'Permission\x20builder\x20AND\x20sole\x20admin\x20was\x20the\x20merchant).\x20Bind\x20an\x20arbitration\x20whose\x20Permission\x20is\x20controlled\x20'+'by\x20physically\x20independent\x20keys');const C=arbitrationVotingLockDetail(y['voting_guard']);C!==null&&d['push']('pre_publish:\x20R-ARB-VOTE-LOCK\x20—\x20arbitration\x20\x22'+w+'\x22:\x20'+C);}return{'critical':d,'warnings':f};}async function runPreBuyChecks(a,b){const c=[],d=[],f=extractData(b)??{},g=b?.['env']?.['network'],h=f['object'];let i;try{i=await batchQueryObjectsByIds([h],g,!![]);}catch(m){return d['push']('pre_buy:\x20allocator\x20screening\x20DEGRADED\x20—\x20could\x20not\x20query\x20service\x20\x22'+h+'\x22\x20'+('('+(m instanceof Error?m['message']:String(m))+');\x20the\x20purchase\x20was\x20NOT\x20screened.\x20')+'Verify\x20the\x20service\x27s\x20order_allocators\x20yourself\x20(query_toolkit\x20query_type=\x27service_panorama\x27)\x20before\x20trusting\x20this\x20buy'),{'critical':c,'warnings':d};}const j=(i??[])['find'](n=>n?.['type']==='Service');if(!j)return d['push']('pre_buy:\x20allocator\x20screening\x20DEGRADED\x20—\x20service\x20\x22'+h+'\x22\x20not\x20found\x20on-chain\x20(or\x20not\x20yet\x20indexed);\x20'+'the\x20purchase\x20was\x20NOT\x20screened.\x20Verify\x20the\x20address/network\x20and\x20the\x20service\x27s\x20order_allocators\x20before\x20trusting\x20this\x20buy'),{'critical':c,'warnings':d};const k=j['data']??j;k['bPublished']!==!![]&&c['push']('pre_buy:\x20service\x20\x22'+h+'\x22\x20is\x20NOT\x20published\x20—\x20the\x20buy\x20aborts\x20on-chain\x20(E_NOT_PUBLISHED)');k['bPaused']===!![]&&c['push']('pre_buy:\x20service\x20\x22'+h+'\x22\x20is\x20paused\x20—\x20the\x20buy\x20aborts\x20on-chain\x20(E_PAUSED)');const l=k['order_allocators'];if(l==null)c['push']('pre_buy:\x20service\x20\x22'+h+'\x22\x20has\x20NO\x20order_allocators\x20—\x20the\x20payment\x20step\x20aborts\x20(no\x20distribution\x20plan).\x20'+'Funds\x20committed\x20to\x20this\x20service\x20would\x20have\x20NO\x20distribution\x20path\x20(the\x20fund-lock\x20incident\x20class).\x20'+'Do\x20not\x20buy\x20until\x20the\x20merchant\x20configures\x20an\x20allocator\x20plan');else{if(!Array['isArray'](l['allocators'])||l['allocators']['length']===0x0)c['push']('pre_buy:\x20service\x20\x22'+h+'\x22\x20order_allocators\x20is\x20EMPTY\x20—\x20the\x20payment\x20step\x20aborts\x20(EALLOCATORS_EMPTY).\x20'+'Do\x20not\x20buy\x20until\x20the\x20merchant\x20configures\x20at\x20least\x20one\x20allocator');else{const n=f['buy'],o=Array['isArray'](n?.['items'])?n['items']:[],p=Array['isArray'](k['sales'])?k['sales']:[];let q=0x0,r=o['length']>0x0;const s=[];for(const v of o){const w=v,x=numericBalance(w?.['quantity']),y=p['find'](A=>A?.['name']===w?.['name']),z=numericBalance(y?.['price']);if(x===undefined||z===undefined){r=![],s['push'](typeof w?.['name']==='string'?w['name']:JSON['stringify'](w?.['name']));continue;}q+=z*x;}const t=numericBalance(l['threshold']);if(!r)d['push']('pre_buy:\x20could\x20not\x20price\x20'+s['length']+'\x20cart\x20item(s)\x20['+s['join'](',\x20')+']\x20against\x20the\x20service\x27s\x20on-chain\x20sales\x20—\x20'+'allocator-threshold\x20coverage\x20UNVERIFIED\x20for\x20this\x20cart\x20(unknown\x20items\x20also\x20abort\x20the\x20quote\x20step).\x20'+'Confirm\x20every\x20item\x20name\x20matches\x20a\x20current\x20sale\x20entry');else t!==undefined&&t>q&&c['push']('pre_buy:\x20allocator\x20threshold\x20'+t+'\x20exceeds\x20this\x20cart\x27s\x20total\x20'+q+'\x20(Σ\x20price×quantity\x20over\x20the\x20on-chain\x20sales)\x20—\x20'+'the\x20payment\x20step\x20aborts\x20(EINSUFFICIENT_BALANCE):\x20pool\x20creation\x20requires\x20amount\x20>=\x20threshold.\x20'+'The\x20merchant\x20must\x20lower\x20the\x20threshold\x20(new\x20service\x20—\x20threshold\x20is\x20frozen\x20at\x20publish)\x20or\x20the\x20cart\x20must\x20grow');n?.['discount']!=null&&r&&t!==undefined&&t<=q&&d['push']('pre_buy:\x20a\x20discount\x20is\x20applied\x20—\x20the\x20discounted\x20total\x20may\x20fall\x20below\x20the\x20list\x20total\x20'+q+'\x20used\x20here;\x20'+('if\x20it\x20lands\x20under\x20the\x20allocator\x20threshold\x20'+t+',\x20the\x20payment\x20step\x20aborts\x20(EINSUFFICIENT_BALANCE)'));const u=await lintAllocatorGuardSet([l],g,'pre_buy','critical');c['push'](...u['critical']),d['push'](...u['warnings']);}}return{'critical':c,'warnings':d};}export async function runPrePublishChecks(a,b){const c=[],d=[],f=extractOperationType(a,b),g=extractData(b)??{},h=b?.['env']?.['network'];if(f==='machine'){const i=g['node'];let j=Array['isArray'](i)?i:Array['isArray'](i?.['nodes'])?i['nodes']:[];if(j['length']===0x0&&typeof g['object']==='string'){const l=g['object'];try{const m=await fetchMachineNodes(l,h,!![]);m['length']>0x0&&(j=m,d['push']('pre_publish:\x20machine\x20\x22'+l+'\x22\x20published\x20by\x20reference\x20—\x20audited\x20against\x20its\x20'+(m['length']+'\x20on-chain\x20node(s)\x20(effective-state\x20gate)')));}catch(n){c['push']('pre_publish:\x20could\x20not\x20fetch\x20on-chain\x20nodes\x20for\x20machine\x20\x22'+l+'\x22\x20'+('('+(n instanceof Error?n['message']:String(n))+')\x20—\x20topology\x20UNVERIFIABLE;\x20publish\x20blocked.\x20')+'Retry\x20when\x20the\x20network\x20is\x20reachable;\x20every\x20guarded\x20forward\x20must\x20carry\x20the\x20protocol\x20slot\x20254\x20'+'submission\x20row\x20and\x20topology\x20is\x20immutable\x20after\x20publish\x20(IMMUT-001)');}}if(j['length']>0x0){const o=auditMachineNodes(j);c['push'](...o['critical']),d['push'](...o['warnings']);const p=await fetchForwardGuardIndex(j,h),q=lintForwardGuardsTaskBinding(p);c['push'](...q['critical']),d['push'](...q['warnings']);const s=lintForwardReviewLocks(j,p);c['push'](...s['critical']),d['push'](...s['warnings']);const t=lintForwardGuardsTimeProfile(p);c['push'](...t['critical']),d['push'](...t['warnings']);}else typeof g['object']!=='string'&&d['push']('pre_publish:\x20publishing\x20machine\x20without\x20inline\x20node\x20data\x20—\x20topology\x20not\x20verifiable\x20in\x20this\x20call;\x20'+'verify\x20nodes/pairs/forwards\x20via\x20machineNode2file\x20BEFORE\x20publish\x20(immutable\x20after\x20publish,\x20IMMUT-001)');d['push']('pre_publish:\x20machine\x20nodes/pairs/forwards\x20become\x20immutable\x20after\x20publish\x20(IMMUT-001)');}if(f==='service'){d['push']('pre_publish:\x20service\x20machine/order_allocators/arbitrations\x20become\x20immutable\x20after\x20publish\x20(IMMUT-002);\x20sales\x20remains\x20modifiable');g['machine']===undefined&&d['push']('pre_publish:\x20\x27machine\x27\x20absent\x20from\x20THIS\x20call\x20(the\x20store\x20may\x20already\x20be\x20bound\x20—\x20verify\x20before\x20assuming\x20otherwise):\x20'+'query_toolkit\x20query_type=\x27service_panorama\x27\x20and\x20read\x20service.machine;\x20an\x20unset\x20machine\x20cannot\x20process\x20orders\x20and\x20CANNOT\x20be\x20fixed\x20after\x20publish\x20(IMMUT-002)');g['order_allocators']===undefined&&d['push']('pre_publish:\x20\x27order_allocators\x27\x20absent\x20from\x20THIS\x20call\x20(the\x20store\x20may\x20already\x20be\x20configured\x20—\x20verify\x20before\x20assuming\x20otherwise):\x20'+'query_toolkit\x20query_type=\x27service_panorama\x27\x20and\x20read\x20order_allocators;\x20immutable\x20after\x20publish,\x20so\x20orders\x20get\x20no\x20fund\x20distribution\x20if\x20never\x20configured\x20(IMMUT-002)');const u=g,v=numericBalance(u['compensation_fund_add']?.['balance']);if(v!==undefined&&v>0x0){const z=u['sales'],A=(Array['isArray'](z?.['sales'])?z['sales']:[])['map'](B=>numericBalance(B?.['price']?.['balance']))['filter'](B=>B!==undefined);if(A['length']>0x0){const B=A['reduce']((D,E)=>D+E,0x0),C=B*0x3;if(C>0x0){const D=v/C,E='fund='+v+',\x20highest-SKU\x20single\x20order=Σ(price×1)='+B+'\x20(quantity\x20set\x20at\x20buy\x20time),\x20'+('award\x20cap=3×order='+C+'\x20(MAX_INDEMNITY_MULTIPLE),\x20coverage='+D['toFixed'](0x2));D<0x1&&d['push']('pre_publish:\x20compensation-fund\x20coverage\x20below\x20the\x20award\x20ceiling\x20—\x20'+E+'\x20<\x201.\x20'+'Disclosure\x20only\x20(b6-11):\x20this\x20does\x20NOT\x20block\x20publish.\x20Per-order\x20coverage\x20is\x20enforced\x20at\x20'+'BUY\x20time\x20—\x20orders\x20are\x20rejected\x20while\x20the\x20fund\x20cannot\x20cover\x203x\x20that\x20order,\x20so\x20top\x20up\x20via\x20'+'compensation_fund_add\x20as\x20your\x20catalog\x27s\x20order\x20sizes\x20require\x20(no\x20cross-SKU\x20subsidy).\x20'+'Awards\x20beyond\x20the\x20fund\x20would\x20abort\x20the\x20buyer\x27s\x20payout\x20at\x20claim\x20time\x20(code\x2027).');}}else d['push']('pre_publish:\x20compensation_fund_add\x20present\x20but\x20\x27sales\x27\x20absent\x20from\x20THIS\x20call\x20(sales\x20may\x20already\x20be\x20configured\x20—\x20verify,\x20do\x20not\x20assume):\x20'+'the\x20fund\x20should\x20cover\x203×\x20each\x20order\x20you\x20want\x20to\x20sell\x20(MAX_INDEMNITY_MULTIPLE=3;\x20enforced\x20per-order\x20at\x20buy\x20time).\x20'+'query_toolkit\x20query_type=\x27service_panorama\x27\x20to\x20read\x20the\x20current\x20sales\x20prices,\x20then\x20re-check\x20coverage.');}const w=await lintAllocatorGuards(u,h);c['push'](...w['critical']),d['push'](...w['warnings']);if(u['order_allocators']!==undefined||u['order_allocators_append']!==undefined){const F=u['machine'];if(typeof F==='string'&&F['trim']()!==''){const G=await lintServiceEscrowExitCoverage(F,[u['order_allocators'],u['order_allocators_append']],h);c['push'](...G['critical']),d['push'](...G['warnings']);}else d['push']('pre_publish:\x20\x27machine\x27\x20absent\x20from\x20THIS\x20call\x20—\x20escrow-exit\x20terminal\x20coverage\x20not\x20auditable\x20here;\x20'+'if\x20the\x20machine\x20is\x20already\x20bound,\x20every\x20machine\x20terminal\x20needs\x20an\x20allocator\x20rail\x20(immutable\x20after\x20publish,\x20IMMUT-002)');}const x=await checkArbitrationNeutrality(u,h);c['push'](...x['critical']),d['push'](...x['warnings']);const y=new Set(rewardRefsOf(u)['map'](H=>H['toLowerCase']()));if(y['size']===0x0&&u['publish']===!![]&&typeof u['object']==='string')try{const H=await batchQueryObjectsByIds([u['object']],h,!![]),I=(H??[])[0x0],J=I?.['data']??I,K=Array['isArray'](J?.['rewards'])?J['rewards']:[];for(const L of K){if(typeof L==='string'&&L['trim']()!=='')y['add'](L['toLowerCase']());}}catch(M){d['push']('pre_publish:\x20reward-funding\x20gate\x20skipped\x20—\x20could\x20not\x20read\x20the\x20service\x27s\x20on-chain\x20rewards\x20'+('('+(M instanceof Error?M['message']:String(M))+');\x20verify\x20every\x20attached\x20Reward\x20pool\x20is\x20funded\x20')+'up\x20to\x20expected_orders\x20x\x20per-claim\x20amount\x20BEFORE\x20publish');}if(y['size']>0x0)try{const N=await batchQueryObjectsByIds([...y['values']()],h,!![]),O=new Map();for(const P of N??[]){const Q=P;if(Q?.['type']!=='Reward')continue;for(const R of[Q['query_name'],Q['object']]){if(typeof R==='string'&&R!=='')O['set'](R['toLowerCase'](),Q);}}for(const S of y){const T=O['get'](S);if(!T){d['push']('pre_publish:\x20attached\x20reward\x20\x22'+S+'\x22\x20not\x20found\x20on-chain\x20—\x20funding\x20check\x20skipped\x20for\x20it;\x20'+'an\x20unfunded\x20pool\x20publishes\x20silently\x20and\x20claims\x20abort\x20when\x20it\x20drains');continue;}const U=serviceRewardsUnfundedDetail(T);U&&c['push']('pre_publish:\x20OFN-C\x20reward-pool\x20funding\x20—\x20reward\x20\x22'+S+'\x22:\x20'+U);}}catch(V){d['push']('pre_publish:\x20reward-funding\x20gate\x20skipped\x20—\x20could\x20not\x20query\x20reward\x20objects\x20'+('('+(V instanceof Error?V['message']:String(V))+');\x20verify\x20every\x20attached\x20Reward\x20pool\x20is\x20funded\x20')+'up\x20to\x20expected_orders\x20x\x20per-claim\x20amount\x20BEFORE\x20publish');}}return{'critical':c,'warnings':d};}function buildHarnessBlockResult(a,b,c,d,e,f){const g=[...c['map'](i=>'CRITICAL:\x20'+i),...d['map'](i=>'WARN:\x20'+i)]['join']('\x0a'),h='Error:\x20'+b+(g?'\x0a'+g:'')+'\x0aRecovery:\x20'+f;return{'content':[{'type':'text','text':h}],'structuredContent':{'outcome':'failed','result':{'type':'error','error':b+'\x20[gate='+a+']','error_code':e,'retryable':![],'recovery_hint':f},'message':h,'recovery':recover(e,'harness:'+a)}};}function extractCriticalFindingCount(a){const b=a?.['structuredContent'];if(!b)return 0x0;const c=b['semantic'],d=c?.['summary'];if(typeof d?.['critical_count']==='number'&&d['critical_count']>0x0)return d['critical_count'];const e=b['findings']??c?.['findings'];if(Array['isArray'](e))return e['filter'](h=>h?.['severity']==='error')['length'];const f=a?.['content']?.['map'](h=>'text'in h?h['text']:'')['join']('\x0a')??'',g=f['match'](/\[AUDIT ERROR\]/g);return g?g['length']:0x0;}
1
+ import{classifyError,buildDataSemantic}from'../schema/call/semantic.js';import{buildClassifiedErrorResult}from'./shared.js';import{shouldRunLightHooks,shouldRunHeavyHooks,recordOperationFailure,recordCriticalRisk,recordCriticalOperation,recordSubstepFailure}from'../harness/auto-escalation.js';import{getHarnessTier,setHarnessTier,isEnabled}from'../config/runtime.js';import{getHarness}from'../harness/index.js';import{recover}from'../harness/recover.js';import{stableOperationId}from'../harness/operation-id.js';import{recordOperationOutcome}from'../experience/index.js';import{recordIndustrySignal}from'../knowledge/flywheel-loop.js';import{getStageCache}from'../playbooks/service-build/index.js';import{SERVICE_BUILD_STAGES}from'../playbooks/service-build/process.js';import{extractAmount,getAmountThreshold,formatAmount}from'../knowledge/safety-rules.js';import{LocalMark,query_serviceContext}from'@wowok/wowok';import{arbitrationVotingLockDetail,auditMachineNodes,computeTerminalReachability,guardTimeProfileDetail,lintReviewLockedTerminals,rewardRefsOf,serviceRewardsUnfundedDetail}from'../knowledge/audit-rules.js';import{lintGuard}from'../knowledge/guard-lint.js';import{parseGuardNodeGates}from'../knowledge/guard-node-gates.js';import{batchQueryObjectsByIds,fetchMachineNodes}from'../graph/onchain/sdk-batch.js';function stageIndexOf(a){const b=SERVICE_BUILD_STAGES['indexOf'](a);return b>=0x0?b:0x0;}export function withTimeout(a,b=0x7530,c='operation'){let d;return Promise['race']([a['finally'](()=>{if(d)clearTimeout(d);}),new Promise((e,f)=>{d=setTimeout(()=>{let g='';if(c['includes']('messenger'))g='\x20This\x20is\x20a\x20messenger\x20network\x20operation.\x20Possible\x20causes:\x20'+'(1)\x20messenger\x20server\x20(https://messenger.wowok.net)\x20unreachable,\x20'+'(2)\x20no\x20messenger-enabled\x20account\x20configured\x20(use\x20account_operation\x20to\x20set\x20messenger\x20name),\x20'+'(3)\x20network\x20connectivity\x20issue.\x20'+'Ensure\x20you\x20have\x20a\x20messenger-enabled\x20account\x20and\x20the\x20server\x20is\x20reachable.';else(c['includes']('onchain')||c['includes']('account_operation')||c['includes']('bridge')||c['includes']('workflow')||c['includes']('keeper')||c['includes']('wowok'))&&(g='\x20This\x20tool\x20may\x20submit\x20an\x20ON-CHAIN\x20transaction.\x20The\x20transaction\x20was\x20NOT\x20cancelled\x20'+'by\x20this\x20timeout\x20—\x20it\x20may\x20already\x20be\x20submitted\x20and\x20still\x20finalize\x20on-chain.\x20'+'DO\x20NOT\x20blindly\x20retry\x20(risk\x20of\x20duplicate\x20operations).\x20First\x20verify:\x20'+'(1)\x20if\x20the\x20error\x20above\x20carries\x20a\x20tx\x20digest,\x20check\x20it\x20via\x20query_toolkit\x20'+'(query_type=\x27onchain_transaction\x27);\x20(2)\x20otherwise\x20verify\x20via\x20query_toolkit\x20'+'onchain_events\x20(or\x20the\x20account\x27s\x20recent\x20transactions).\x20Do\x20NOT\x20rely\x20on\x20an\x20'+'onchain_objects\x20read\x20alone:\x20it\x20may\x20serve\x20a\x20pre-transaction\x20cached\x20snapshot,\x20'+'so\x20an\x20unchanged\x20object\x20must\x20never\x20on\x20its\x20own\x20justify\x20a\x20retry.');f(new Error('Operation\x20\x27'+c+'\x27\x20timed\x20out\x20after\x20'+b+'ms.'+g));},b);})]);}export function wrapHandlerWithErrorShape(a,b,c,d){return async(e,f)=>{try{return await withTimeout(a(e,f),b,c);}catch(g){if(d){const h=g instanceof Error?g['message']:String(g),i=classifyError(h,g),j={'operation_type':c,'data':e},k=d(h,i,j);return{'content':[{'type':'text','text':'Error:\x20'+h}],'structuredContent':k};}throw g;}};}export const statusErrorShape=(a,b,c)=>({'result':buildClassifiedErrorResult({'status':'error'},a,b),'semantic':buildDataSemantic(undefined,c,!![],a)});export const operationErrorShape=(a,b,c)=>({'result':buildClassifiedErrorResult({'operation':'error'},a,b),'semantic':buildDataSemantic(undefined,c,!![],a)});export const strictStatusErrorShape=(a,b,c)=>({'result':{'status':'error','error':a}});function checkProjectStage(a,b,c){const d={'analyze_intent':'puzzle','aggregate_risks':'risk','trace_substeps':'substeps'},e=d[a];if(!e)return null;const f=getStageCache(b,c);if(!f){if(a==='analyze_intent')return null;return'project_stage:\x20calling\x20\x27'+a+'\x27\x20before\x20\x27analyze_intent\x27\x20—\x20recommend\x20calling\x20analyze_intent\x20first\x20for\x20project\x20\x27'+b+':'+c+'\x27';}if(stageIndexOf(f['stage'])<stageIndexOf(e)-0x1)return'project_stage:\x20calling\x20\x27'+a+'\x27\x20(stage\x20\x27'+e+'\x27)\x20but\x20project\x20is\x20at\x20stage\x20\x27'+f['stage']+'\x27\x20—\x20recommend\x20completing\x20prior\x20stages\x20first\x20for\x20\x27'+b+':'+c+'\x27';return null;}export function dispatchWithHarness(a,b){return async(d,f)=>{const g=[],h=getHarness(),i=shouldRunLightHooks(),j=shouldRunHeavyHooks(),k=isPublishOperation(b,d),l=isSignOperation(b,d),m=isBuyOperation(b,d),n=getHarnessTier();if(b==='goal_operation'&&i)try{const p=d,q=p?.['action'],r=p?.['project'],s=p?.['version'];if(q&&r&&s){const t=checkProjectStage(q,r,s);t&&g['push'](t);}}catch{}k&&n==='lightweight'&&(setHarnessTier('full'),g['push']('pre_publish:\x20tier\x20forced\x20to\x20full\x20for\x20publish-class\x20operation\x20(GLM5-21\x20§3.3)'));if(k&&n!=='off')try{const u=await runPrePublishChecks(b,d);g['push'](...u['warnings']);if(u['critical']['length']>0x0){for(const v of u['critical']){const x=recordCriticalRisk(v);if(x)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+x['reason']);}return buildHarnessBlockResult('pre_publish','Publish\x20BLOCKED\x20by\x20Harness\x20pre-publish\x20gate\x20(GLM5-21\x20V6):\x20'+(u['critical']['length']+'\x20CRITICAL\x20risk(s)\x20must\x20be\x20resolved\x20before\x20publish.'),u['critical'],u['warnings'],'immutable_violation','Fix\x20the\x20CRITICAL\x20risks\x20listed\x20in\x20the\x20message\x20(e.g.\x20rename\x20dispute\x20nodes\x20per\x20R-M1-11\x20—\x20disputes\x20live\x20off-Machine;\x20bare\x20fund-terminal\x20names\x20only\x20warn\x20but\x20must\x20carry\x20an\x20anchored\x20refund\x20rail),\x20add\x20the\x20entry\x20pair\x20prev_node=\x22\x22,\x20then\x20retry\x20publish.\x20Nodes/pairs/forwards\x20are\x20immutable\x20after\x20publish\x20—\x20verify\x20via\x20machineNode2file\x20first.');}}catch(y){g['push']('pre_publish\x20hook\x20failed:\x20'+(y instanceof Error?y['message']:String(y)));}if(l&&j)try{const z=extractData(d),A=z?extractAmount(z,{'excludeConfigAmounts':!![]}):null;if(A!==null){const B=getAmountThreshold();let C=null;try{C=BigInt(A);}catch{C=null;}if(C!==null&&C>B){const D=await skuMatchedOrderTotalExemption(z,d?.['env']?.['network']);if(D)g['push']('pre_sign:\x20order\x20total\x20'+A+'\x20exceeds\x20the\x20full-tier\x20threshold\x20'+B['toString']()+'\x20(smallest\x20unit)\x20—\x20'+'EXEMPTED\x20(M-K11-a):\x20exact\x20catalog\x20match\x20Σ\x20price×quantity\x20against\x20the\x20Service\x27s\x20published\x20sales'+(D['coinType']?',\x20payment\x20coin\x20'+D['coinType']:'')+'.');else return buildHarnessBlockResult('pre_sign','Sign\x20BLOCKED\x20by\x20Harness\x20pre-sign\x20gate\x20(GLM5-21\x20V7):\x20amount\x20'+formatAmount(C)+'\x20WOW\x20exceeds\x20the\x20full-tier\x20threshold\x20'+formatAmount(B)+'\x20WOW.',['amount\x20'+A+'\x20(smallest\x20unit)\x20>\x20threshold\x20'+B['toString']()+'\x20(smallest\x20unit)'],[],'invalid_parameter','Raise\x20WOWOK_AMOUNT_THRESHOLD\x20to\x20match\x20the\x20intended\x20amount,\x20split\x20the\x20transaction,\x20or\x20reset\x20the\x20harness\x20tier\x20to\x20lightweight\x20(config_operation)\x20after\x20explicit\x20user\x20confirmation.\x20'+'M-K11-a:\x20catalog-priced\x20order_new\x20buys\x20(total_pay\x20EXACTLY\x20equal\x20to\x20Σ\x20price×quantity\x20of\x20PUBLISHED\x20sales)\x20are\x20exempted\x20automatically\x20—\x20'+'if\x20this\x20IS\x20a\x20catalog-priced\x20buy,\x20verify\x20every\x20item\x20name/quantity\x20against\x20the\x20service\x27s\x20current\x20sales\x20and\x20retry.');}}}catch(E){g['push']('pre_sign\x20hook\x20failed:\x20'+(E instanceof Error?E['message']:String(E)));}if(m&&n!=='off')try{const F=await runPreBuyChecks(b,d);g['push'](...F['warnings']);if(F['critical']['length']>0x0){for(const G of F['critical']){const H=recordCriticalRisk(G);if(H)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+H['reason']);}return buildHarnessBlockResult('pre_buy','Purchase\x20BLOCKED\x20by\x20Harness\x20pre-buy\x20gate:\x20'+F['critical']['length']+'\x20CRITICAL\x20allocator\x20risk(s)\x20—\x20'+'paying\x20into\x20this\x20service\x20as\x20currently\x20configured\x20would\x20fail\x20on-chain\x20or\x20lock\x20funds\x20with\x20no\x20distribution\x20path.',F['critical'],F['warnings'],'state_conflict','Do\x20NOT\x20retry\x20this\x20purchase\x20against\x20the\x20current\x20service\x20state.\x20Read\x20the\x20service\x27s\x20effective\x20allocator\x20plan\x20'+'(query_toolkit\x20query_type=\x27service_panorama\x27,\x20field\x20order_allocators)\x20and\x20confirm\x20every\x20finding\x20above\x20is\x20resolved\x20'+'(merchant\x20fixes\x20the\x20plan\x20—\x20post-publish\x20append\x20is\x20allowed\x20—\x20or\x20the\x20guard\x20definitions\x20are\x20repaired).\x20'+'Only\x20retry\x20the\x20buy\x20after\x20the\x20on-chain\x20state\x20changes;\x20otherwise\x20choose\x20a\x20different\x20service.');}}catch(I){g['push']('pre_buy\x20hook\x20failed:\x20'+(I instanceof Error?I['message']:String(I)));}let o;try{o=await a(d,f);}catch(J){const K=J instanceof Error?J['message']:String(J),L=recordOperationFailure(b,K);L&&g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+L['reason']);if(b==='onchain_operations')try{const M=classifyError(K,J);if(!M['retryable']&&M['error_code']!=='unknown'){const N=recordCriticalOperation(b,M['error_code']);if(N)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+N['reason']);}}catch{}throw J;}if(b==='onchain_operations')try{if(classifyOutcome(o)==='failed'){const O=extractErrorCode(o)??'',P=classifyError(O);if(!P['retryable']&&P['error_code']!=='unknown'){const Q=recordCriticalOperation(b,P['error_code']);if(Q)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+Q['reason']);}}}catch{}if(i&&!isOutcomeDiscriminated(o)){const R=stableOperationId(extractIntent(b,d)??b,extractData(d));try{const S=classifyOutcome(o);if(S==='failed'){const T=extractErrorCode(o)??'',U=classifyError(T),V=h['recover'](U['error_code'],R,{'operation_type':b,'data':extractData(d)});g['push']('Harness\x20recover:\x20strategy='+V['strategy']+('\x20(attempt\x20'+V['current_attempt']+'/'+V['max_attempts']+')')+(V['should_retry']?'\x20—\x20retryable':'\x20—\x20do\x20NOT\x20retry\x20blindly')+(V['user_prompt']?'\x20—\x20'+V['user_prompt']:'\x20—\x20'+V['detail']));}else S==='success'&&h['resetRecovery'](R);}catch(W){g['push']('recover\x20hook\x20failed:\x20'+(W instanceof Error?W['message']:String(W)));}}if(b==='goal_operation')try{const X=d?.['action'];if(X==='trace_substeps'){const Y=extractCriticalFindingCount(o);if(Y>0x0){const Z=recordSubstepFailure(String(X)+':\x20'+Y+'\x20critical\x20finding(s)');if(Z)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+Z['reason']);}}}catch{}if(isWriteClassTool(b)&&!SEMANTIC_RECORDED_TOOLS['has'](b))try{const a0=extractOperationType(b,d)??b,a1=extractIntent(b,d)??b,a2=extractData(d)??d,a3=classifyOutcome(o),a4=extractErrorCode(o),a5=isEnabled('experience_layer');if(a5)recordOperationOutcome(a0,a2,a1,a3,a4);else{const a6=extractIndustry(d);a6&&isEnabled('industry_evolution')&&recordIndustrySignal(a6,{'type':a0},{'success':a3==='success','error_code':a4});}}catch(a7){g['push']('signal\x20collection\x20failed:\x20'+(a7 instanceof Error?a7['message']:String(a7)));}if(g['length']>0x0){if(o?.['structuredContent']){const a8=o['structuredContent'],a9=a8['semantic'];if(a9){const aa=Array['isArray'](a9['warnings'])?a9['warnings']:[];a9['warnings']=[...aa,...g];}else for(const ab of g){console['warn']('[harness]\x20'+ab);}}else for(const ac of g){console['warn']('[harness]\x20'+ac);}}return o;};}function isPublishOperation(a,b){if(a!=='onchain_operations')return![];const c=extractOperationType(a,b);if(c!=='service'&&c!=='machine')return![];const d=extractData(b);return d?.['publish']===!![]||d?.['bPublished']===!![];}function isSignOperation(a,b){if(a==='wip_file'){const c=b?.['operation_type'];return c==='sign';}return a==='onchain_operations';}function isBuyOperation(a,b){if(a!=='onchain_operations')return![];if(extractOperationType(a,b)!=='service')return![];const c=extractData(b),d=c?.['order_new'],e=c?.['buy']!=null||d!=null&&typeof d==='object'&&d['buy']!=null;return e&&c!=null&&typeof c['object']==='string'&&c['object']!=='';}function extractOperationType(a,b){if(!b||typeof b!=='object')return undefined;const c=b;if(a==='onchain_operations')return typeof c['operation_type']==='string'?c['operation_type']:undefined;if(a==='goal_operation'||a==='industry_pack_operation'||a==='strategy_review_operation')return typeof c['action']==='string'?c['action']:undefined;return typeof c['operation_type']==='string'?c['operation_type']:undefined;}function extractIntent(a,b){if(!b||typeof b!=='object')return undefined;const c=b;if((a==='goal_operation'||a==='industry_pack_operation'||a==='strategy_review_operation')&&typeof c['action']==='string')return a+':'+c['action'];const d=c['operation_type'];if(typeof d==='string')return a+':'+d;return a;}function extractData(a){if(!a||typeof a!=='object')return undefined;const b=a,c=b['data'];return c&&typeof c==='object'?c:undefined;}export async function skuMatchedOrderTotalExemption(a,b){try{if(!a)return undefined;const c=a['order_new']?.['buy'];if(!c||c['discount']!=null)return undefined;const d=c?.['total_pay']?.['balance']??c?.['total_pay'];if(d===null||d===undefined||typeof d==='object')return undefined;const e=Array['isArray'](c['items'])?c['items']:[];if(e['length']===0x0)return undefined;const f=a['object'];if(typeof f!=='string'||f['length']===0x0)return undefined;const g=f['startsWith']('0x')?f:await LocalMark['Instance']()['get_address'](f)??undefined;if(!g)return undefined;const h=await query_serviceContext({'service':g,'network':b}),i=h?.['service'];if(!i)return undefined;if(i['bPublished']!==!![])return undefined;const j=String(i?.['type_raw']??i?.['type']??'')['match'](/<(.+)>$/)?.[0x1],k=Array['isArray'](i['sales'])?i['sales']:[];let l=0x0n;for(const n of e){const o=k['find'](r=>r?.['name']===n?.['name']);if(!o||o?.['suspension']===!![])return undefined;const p=BigInt(String(o?.['price']?.['balance']??o?.['price']??'0')),q=BigInt(String(n?.['quantity']??'1'));if(q<=0x0n)return undefined;l+=p*q;}let m;try{m=BigInt(String(d));}catch{return undefined;}if(m!==l)return undefined;return{'coinType':j};}catch{return undefined;}}const WRITE_CLASS_TOOLS=new Set(['onchain_operations','goal_operation','industry_pack_operation','strategy_review_operation','wip_file','messenger_operation','bridge_operation']),SEMANTIC_RECORDED_TOOLS=new Set(['onchain_operations','bridge_operation']);function isWriteClassTool(a){return WRITE_CLASS_TOOLS['has'](a);}function classifyOutcome(a){if(!a?.['structuredContent'])return'failed';const b=a['structuredContent'];if(b['outcome']==='failed')return'failed';if(b['outcome']==='executed')return'success';if(b['outcome']==='pending_input')return'partial';const c=b['verdict'];if(c&&typeof c==='object'&&c['buildable']===![])return'failed';const d=typeof b['status']==='string'?b['status']:typeof b['result_type']==='string'?b['result_type']:b['result']&&typeof b['result']==='object'&&typeof b['result']['status']==='string'?b['result']['status']:'';if(d==='error'||d==='failed'||d==='schema_mismatch')return'failed';if(d==='partial')return'partial';return'success';}function isOutcomeDiscriminated(a){const b=a?.['structuredContent'];return!!b&&typeof b==='object'&&'outcome'in b;}function extractErrorCode(a){if(!a?.['structuredContent'])return undefined;const b=a['structuredContent'];if(typeof b['error_code']==='string')return b['error_code'];const c=b['error'];if(typeof c==='string')return c;if(c&&typeof c==='object'){const d=c['code'];if(typeof d==='string')return d;}return undefined;}function extractIndustry(a){if(!a||typeof a!=='object')return undefined;const b=a;if(typeof b['industry']==='string')return b['industry'];const c=b['data'];if(c&&typeof c==='object'){const e=c;if(typeof e['industry']==='string')return e['industry'];}return undefined;}function numericBalance(a){if(typeof a==='number'&&Number['isFinite'](a))return a;if(typeof a==='string'&&a['trim']()!==''&&Number['isFinite'](Number(a)))return Number(a);if(typeof a==='bigint')return Number(a);return undefined;}function collectAllocatorGuards(b){const c=new Map();for(const d of b){const e=d?.['allocators'];if(!Array['isArray'](e))continue;for(const f of e){const g=f?.['guard'];if(typeof g!=='string'||g['trim']()==='')continue;const h=g['toLowerCase']();let i=c['get'](h);!i&&(i={'ref':g,'recipients':new Set(),'slots':new Set()},c['set'](h,i));const j=f?.['sharing'];if(!Array['isArray'](j))continue;for(const k of j){const l=k?.['who'];if(!l||typeof l!=='object')continue;if('Signer'in l)i['recipients']['add']('Signer');else{if('Entity'in l)i['recipients']['add']('Entity');else{if('GuardIdentifier'in l){i['recipients']['add']('GuardIdentifier');const m=l['GuardIdentifier'],o=Number(m);if(Number['isFinite'](o))i['slots']['add'](o);}}}}}}return c;}async function lintAllocatorGuardSet(a,b,c,f){const h=[],i=[],j=collectAllocatorGuards(a);if(j['size']===0x0)return{'critical':h,'warnings':i};let l;try{l=await batchQueryObjectsByIds([...j['values']()]['map'](n=>n['ref']),b,!![]);}catch(n){return i['push'](c+':\x20allocator\x20guard\x20lint\x20skipped\x20—\x20could\x20not\x20query\x20guard\x20objects\x20'+('('+(n instanceof Error?n['message']:String(n))+');\x20')+(c==='pre_buy'?'the\x20guard\x20layer\x20of\x20this\x20service\x27s\x20allocator\x20plan\x20is\x20UNVERIFIED\x20—\x20verify\x20the\x20guards\x20yourself\x20before\x20trusting\x20this\x20buy':'run\x20guard\x20lint\x20manually\x20BEFORE\x20publish\x20(order_allocators\x20immutable\x20after\x20publish,\x20IMMUT-002)')),{'critical':h,'warnings':i};}const m=new Map();for(const o of l??[]){const p=o;if(p?.['type']!=='Guard')continue;for(const q of[p['query_name'],p['object']]){if(typeof q==='string'&&q!=='')m['set'](q['toLowerCase'](),p);}}for(const [r,s]of j){const t=m['get'](r);if(!t){const z=c+':\x20allocator\x20guard\x20\x22'+s['ref']+'\x22\x20not\x20found\x20on-chain\x20—\x20'+(f==='critical'?'the\x20pool\x20accepts\x20funds\x20but\x20no\x20distribution\x20run\x20can\x20ever\x20pass\x20a\x20missing\x20guard\x20(fund-lock\x20risk)':'lint\x20skipped\x20for\x20this\x20guard;\x20verify\x20the\x20guard\x20exists\x20and\x20is\x20final\x20BEFORE\x20publish\x20(order_allocators\x20immutable\x20after\x20publish,\x20IMMUT-002)');if(f==='critical')h['push'](z);else i['push'](z);continue;}const u=t['data']??t,v=Array['isArray'](u?.['table'])?u['table']:[],w=Array['isArray'](u?.['relies'])?u['relies']:[];for(const A of s['slots']){const B=v['find'](D=>Number(D?.['identifier'])===A),C=B!=null&&B['b_submission']===!![]&&String(B['value_type'])==='Address';!C&&h['push'](c+':\x20allocator\x20guard\x20\x22'+s['ref']+'\x22\x20pays\x20a\x20{GuardIdentifier:\x20'+A+'}\x20leg\x20but\x20its\x20table\x20has\x20'+(B==null?'NO\x20slot\x20'+A+'\x20row':'slot\x20'+A+'\x20as\x20a\x20STATIC\x20row\x20(b_submission:\x20'+(B['b_submission']===!![])+',\x20value_type:\x20'+String(B['value_type'])+')')+'\x20—\x20the\x20passport\x20only\x20emits\x20DECLARED\x20submission\x20slots\x20and\x20allocation\x20asserts\x20the\x20slot\x20equals\x20the\x20paying\x20'+'order,\x20so\x20this\x20rail\x20aborts\x20at\x20alloc\x20(code\x2015,\x20ERECIPIENT_NOT_FOR_OBJECT)\x20with\x20the\x20leg\x27s\x20funds\x20stranded.\x20'+'Anchor\x20the\x20leg\x20on\x20protocol\x20slot\x20254\x20(auto-written\x20with\x20the\x20paying\x20order\x20id\x20at\x20order\x20creation)\x20or\x20declare\x20'+('{identifier:\x20'+A+',\x20b_submission:\x20true,\x20value_type:\x20\x22Address\x22}\x20in\x20the\x20guard\x20table\x20BEFORE\x20publish'));}const x={'description':typeof u?.['description']==='string'?u['description']:undefined,'table':v['map'](D=>({'identifier':Number(D?.['identifier']??0x0),'b_submission':!!D?.['b_submission'],'value_type':D?.['value_type']!==undefined?String(D['value_type']):undefined,'value':D?.['value'],'name':D?.['name']!==undefined?String(D['name']):undefined,'object_type':D?.['object_type']!==undefined?String(D['object_type']):undefined})),'root':u?.['root'],'rely':w['length']>0x0?{'guards':w['map'](D=>String(D)),'logic_or':!u?.['relies_logic_and']}:undefined,'binding_hint':{'host_object':'Service','binding_field':'order_allocators','sharing_recipients':s['recipients']['size']>0x0?[...s['recipients']]:undefined}},y=guardTimeProfileDetail({'ref':s['ref'],'description':typeof u?.['description']==='string'?u['description']:undefined,'table':v,'root':u?.['root']});if(y){const D='pre_publish:\x20R-TIME-PROFILE\x20—\x20allocator\x20guard\x20\x22'+s['ref']+'\x22:\x20'+y['detail'];if(y['level']==='critical')h['push'](D);else i['push'](D);}try{const E=await lintGuard(x,{'auto_fix':![]});for(const F of E['diagnostics']){const G=c+':\x20allocator\x20guard\x20\x22'+s['ref']+'\x22\x20'+F['code']+'\x20('+F['source']+'):\x20'+F['message']+'\x20at\x20'+F['location']['path'];if(F['severity']==='error')h['push'](G);else{if(F['severity']==='warning')i['push'](G);}}}catch(H){i['push'](c+':\x20allocator\x20guard\x20\x22'+s['ref']+'\x22\x20lint\x20failed\x20'+('('+(H instanceof Error?H['message']:String(H))+')\x20—\x20non-blocking'));}}return{'critical':h,'warnings':i};}function collectForwardGuardRefs(a){const b=new Map();for(const c of a){const d=c,e=Array['isArray'](d?.['pairs'])?d['pairs']:Array['isArray'](d?.['value'])?d['value']:[];for(const h of e){const i=h,j=Array['isArray'](i?.['forwards'])?i['forwards']:[];for(const k of j){const l=k,m=l?.['guard'],n=typeof m==='string'&&m['trim']()!==''?m:m&&typeof m==='object'?m['guard']??m['$ref']:undefined;typeof n==='string'&&n['trim']()!==''&&b['set'](n['toLowerCase'](),n);}}}return b;}async function fetchForwardGuardIndex(a,b){const c=collectForwardGuardRefs(a),d=new Map();if(c['size']===0x0)return{'refs':c,'defs':d};try{const f=await batchQueryObjectsByIds([...c['values']()],b,!![]);for(const h of f??[]){const i=h;if(i?.['type']!=='Guard')continue;for(const j of[i['query_name'],i['object']]){if(typeof j==='string'&&j!=='')d['set'](j['toLowerCase'](),i);}}return{'refs':c,'defs':d};}catch(l){return{'refs':c,'defs':d,'error':l instanceof Error?l['message']:String(l)};}}function lintForwardGuardsTaskBinding(a){const b=[],c=[];if(a['refs']['size']===0x0)return{'critical':b,'warnings':c};if(a['error']!==undefined)return c['push']('pre_publish:\x20forward-guard\x20lints\x20(task-binding\x20+\x20review-lock)\x20skipped\x20—\x20could\x20not\x20query\x20guard\x20objects\x20'+('('+a['error']+');\x20verify\x20every\x20forward\x20guard\x20carries\x20the\x20protocol\x20slot\x20254\x20Address\x20submission\x20row\x20and\x20')+'that\x20no\x20settlement\x20rail\x20is\x20review-locked\x20BEFORE\x20publish\x20(immutable\x20after\x20publish,\x20IMMUT-001)'),{'critical':b,'warnings':c};for(const [d,e]of a['refs']){const f=a['defs']['get'](d);if(!f){c['push']('pre_publish:\x20forward-bound\x20guard\x20\x22'+e+'\x22\x20not\x20found\x20on-chain\x20—\x20task-binding\x20lint\x20skipped\x20for\x20it;\x20'+'ensure\x20it\x20exists\x20and\x20carries\x20the\x20protocol\x20slot\x20254\x20Address\x20submission\x20row\x20BEFORE\x20publish\x20'+'(immutable\x20after\x20publish,\x20IMMUT-001)');continue;}const g=f['data']??f,h=Array['isArray'](g?.['table'])?g['table']:[],i=h['some'](j=>Number(j?.['identifier'])===0xfe&&j?.['b_submission']===!![]&&String(j?.['value_type'])==='Address');!i&&b['push']('pre_publish:\x20forward-bound\x20guard\x20\x22'+e+'\x22\x20has\x20NO\x20protocol\x20slot\x20254\x20Address\x20submission\x20row\x20—\x20'+'the\x20passport\x20only\x20emits\x20DECLARED\x20slots,\x20so\x20once\x20a\x20Service\x20binds\x20this\x20Machine\x20EVERY\x20forward\x20this\x20'+'guard\x20gates\x20aborts\x20(code\x2011)\x20and\x20escrowed\x20funds\x20can\x20never\x20advance.\x20Machine\x20topology\x20is\x20immutable\x20'+'after\x20publish\x20(IMMUT-001):\x20add\x20{identifier:254,\x20b_submission:true,\x20value_type:\x22Address\x22}\x20to\x20the\x20'+'guard\x27s\x20table\x20(recreate\x20the\x20guard\x20unfrozen\x20if\x20it\x20is\x20frozen)\x20BEFORE\x20publishing\x20this\x20Machine');}return{'critical':b,'warnings':c};}function lintForwardReviewLocks(a,b){if(b['error']!==undefined||b['refs']['size']===0x0)return{'critical':[],'warnings':[]};const c=new Map();for(const [d,e]of b['defs']){const f=new Set();collectGuardNodeGates(e,f);if(f['size']>0x0)c['set'](d,[...f]);}return lintReviewLockedTerminals(a,c);}function lintForwardGuardsTimeProfile(a){const b=[],c=[];if(a['error']!==undefined||a['refs']['size']===0x0)return{'critical':b,'warnings':c};for(const [d,e]of a['refs']){const f=a['defs']['get'](d);if(!f)continue;const g=f['data']??f,h=guardTimeProfileDetail({'ref':e,'description':g?.['description'],'table':Array['isArray'](g?.['table'])?g['table']:undefined,'root':g?.['root']});if(h){const i='pre_publish:\x20R-TIME-PROFILE\x20—\x20forward-bound\x20guard\x20\x22'+e+'\x22:\x20'+h['detail'];if(h['level']==='critical')b['push'](i);else c['push'](i);}}return{'critical':b,'warnings':c};}async function lintAllocatorGuards(a,b){return lintAllocatorGuardSet([a['order_allocators'],a['order_allocators_append']],b,'pre_publish','warning');}async function lintServiceEscrowExitCoverage(b,c,d){const f=[],h=[];let i=[];try{i=await fetchMachineNodes(b,d,!![]);}catch(p){return f['push']('pre_publish:\x20escrow-exit\x20gate\x20could\x20not\x20fetch\x20machine\x20\x22'+b+'\x22\x20nodes\x20'+('('+(p instanceof Error?p['message']:String(p))+')\x20—\x20terminal\x20coverage\x20UNVERIFIABLE;\x20publish\x20blocked.\x20')+'Retry\x20when\x20the\x20network\x20is\x20reachable'),{'critical':f,'warnings':h};}if(i['length']===0x0)return h['push']('pre_publish:\x20escrow-exit\x20gate\x20skipped\x20—\x20machine\x20has\x20no\x20nodes\x20to\x20cover'),{'critical':f,'warnings':h};const j=computeTerminalReachability(i);if(j['terminals']['length']===0x0)return{'critical':f,'warnings':h};const k=new Map();let l=0x0;for(const q of c){if(!Array['isArray'](q))continue;for(const r of q){l++;const s=r?.['guard'];if(typeof s==='string'&&s['trim']()!=='')k['set'](s['toLowerCase'](),s);}}if(k['size']===0x0)return f['push']('pre_publish:\x20machine\x20terminal\x20node(s)\x20'+j['terminals']['map'](t=>'\x22'+t+'\x22')['join'](',\x20')+'\x20have\x20NO\x20allocator\x20rail\x20—\x20'+(l===0x0?'order_allocators\x20is\x20empty\x20in\x20this\x20call,\x20so\x20':'no\x20allocator\x20row\x20carries\x20a\x20guard\x20ref,\x20so\x20')+'an\x20order\x20stopping\x20at\x20any\x20terminal\x20strands\x20its\x20escrow\x20by\x20construction\x20(immutable\x20after\x20publish,\x20IMMUT-002).\x20'+'Every\x20terminal\x20needs\x20a\x20settlement/refund\x20allocator\x20whose\x20guard\x20gates\x20progress.current\x20==\x20<terminal>\x20'+'(canonical\x20designs:\x20tpl_allocator_node_gate_settle\x20/\x20tpl_allocator_node_gate_refund,\x20M-T12)'),{'critical':f,'warnings':h};let m;try{m=await batchQueryObjectsByIds([...k['values']()],d,!![]);}catch(t){return h['push']('pre_publish:\x20escrow-exit\x20coverage\x20UNVERIFIED\x20—\x20could\x20not\x20query\x20allocator\x20guards\x20'+('('+(t instanceof Error?t['message']:String(t))+');\x20run\x20guard\x20lint\x20manually\x20BEFORE\x20publish\x20')+'(terminal(s)\x20in\x20question:\x20'+j['terminals']['join'](',\x20')+')'),{'critical':f,'warnings':h};}const n=new Set();for(const u of m??[]){const v=u;if(v?.['type']!=='Guard')continue;collectGuardNodeGates(v,n);}const o=j['terminals']['filter'](w=>!n['has'](w));return o['length']>0x0&&f['push']('pre_publish:\x20terminal\x20node(s)\x20'+o['map'](w=>'\x22'+w+'\x22')['join'](',\x20')+'\x20have\x20NO\x20allocator\x20rail\x20—\x20'+'an\x20order\x20that\x20reaches\x20a\x20terminal\x20moves\x20no\x20money\x20by\x20itself,\x20so\x20its\x20escrow\x20strands\x20permanently\x20'+'(mainnet:\x200.299\x20stranded\x20at\x20an\x20un-railied\x20terminal;\x20ofshop:\x200.25\x20stranded\x20at\x20\x27expired\x27).\x20Every\x20terminal\x20'+'needs\x20a\x20settlement/refund\x20allocator\x20whose\x20guard\x20gates\x20progress.current\x20==\x20<terminal>\x20(canonical\x20designs:\x20'+'tpl_allocator_node_gate_settle\x20/\x20tpl_allocator_node_gate_refund,\x20M-T12).\x20If\x20the\x20pool\x20legitimately\x20drains\x20'+'at\x20an\x20earlier\x20node,\x20add\x20a\x20zero-value\x20anchor\x20row\x20on\x20the\x20terminal\x20rail\x20so\x20the\x20guard\x20resolves\x20without\x20paying'),{'critical':f,'warnings':h};}function collectGuardNodeGates(a,b){const c=a['data']??a;for(const d of parseGuardNodeGates(c?.['root'],c?.['table']))b['add'](d);}async function checkArbitrationNeutrality(b,c){const d=[],f=[],g=[],h=p=>{const q=typeof p==='string'?p:p?.['object']??p?.['name'];if(typeof q==='string'&&q!==''&&!g['includes'](q))g['push'](q);};for(const p of Array['isArray'](b['arbitrations'])?b['arbitrations']:[])h(p);let i=typeof b['permission']==='string'?b['permission']:undefined;const j=typeof b['object']==='string'?b['object']:undefined;if(j){let q;try{const r=await batchQueryObjectsByIds([j],c,!![]);q=(r??[])['find'](s=>s?.['type']==='Service');}catch(s){f['push']('pre_publish:\x20arbitration\x20neutrality\x20check\x20DEGRADED\x20—\x20could\x20not\x20query\x20service\x20\x22'+j+'\x22\x20'+('('+(s instanceof Error?s['message']:String(s))+').\x20Verify\x20manually\x20that\x20every\x20bound\x20arbitration\x27s\x20')+'Permission\x20owner/admin\x20set\x20is\x20DISJOINT\x20from\x20the\x20service\x27s\x20controller\x20keys\x20before\x20publishing');}if(q){const t=q['data']??q;if(!i&&typeof t['permission']==='string')i=t['permission'];for(const u of Array['isArray'](t['arbitrations'])?t['arbitrations']:[])h(u);}}if(g['length']===0x0)return{'critical':d,'warnings':f};if(!i)return f['push']('pre_publish:\x20arbitration\x20neutrality\x20check\x20DEGRADED\x20—\x20the\x20service\x20Permission\x20address\x20is\x20not\x20resolvable\x20'+'from\x20this\x20call\x20(no\x20payload\x20\x27permission\x27,\x20service\x20object\x20not\x20found).\x20The\x20bound\x20arbitrations\x27\x20controller\x20'+'keys\x20are\x20UNVERIFIED:\x20confirm\x20each\x20arbitration\x20Permission\x27s\x20owner/admin\x20set\x20is\x20disjoint\x20from\x20the\x20service\x27s\x20'+'controller\x20keys\x20(same-controller\x20arbitration\x20=\x20the\x20merchant\x20can\x20rule\x20their\x20own\x20disputes)'),{'critical':d,'warnings':f};let k;try{k=await batchQueryObjectsByIds([i,...g],c,!![]);}catch(v){return f['push']('pre_publish:\x20arbitration\x20neutrality\x20check\x20DEGRADED\x20—\x20object\x20query\x20failed\x20'+('('+(v instanceof Error?v['message']:String(v))+').\x20Verify\x20the\x20arbitration\x20Permissions\x27\x20owner/admin\x20sets\x20')+'are\x20disjoint\x20from\x20the\x20service\x27s\x20controller\x20keys\x20before\x20publishing'),{'critical':d,'warnings':f};}const l=w=>(k??[])['find'](x=>{const y=x;return typeof y?.['object']==='string'&&y['object']['toLowerCase']()===w['toLowerCase']()||typeof y?.['query_name']==='string'&&y['query_name']['toLowerCase']()===w['toLowerCase']();}),m=w=>{if(!w)return new Set();const x=w['data']??w,y=new Set();for(const z of[x['builder']])if(typeof z==='string'&&z)y['add'](z['toLowerCase']());for(const A of Array['isArray'](x['admin'])?x['admin']:[])if(typeof A==='string'&&A)y['add'](A['toLowerCase']());return y;},n=l(i),o=m(n);if(o['size']===0x0)return f['push']('pre_publish:\x20arbitration\x20neutrality\x20check\x20DEGRADED\x20—\x20service\x20Permission\x20\x22'+i+'\x22\x20not\x20found\x20or\x20'+'carries\x20no\x20builder/admin\x20list.\x20The\x20bound\x20arbitrations\x27\x20controller\x20keys\x20are\x20UNVERIFIED\x20—\x20confirm\x20disjointness\x20manually'),{'critical':d,'warnings':f};for(const w of g){const x=l(w);if(!x){f['push']('pre_publish:\x20arbitration\x20\x22'+w+'\x22\x20not\x20found\x20on-chain\x20(or\x20not\x20yet\x20indexed)\x20—\x20its\x20Permission\x20controller\x20'+'keys\x20are\x20UNVERIFIED.\x20Confirm\x20the\x20arbitration\x20Permission\x27s\x20builder/admin\x20set\x20is\x20disjoint\x20from\x20the\x20service\x27s\x20'+'controller\x20keys\x20(same-controller\x20arbitration\x20=\x20the\x20merchant\x20can\x20rule\x20their\x20own\x20disputes)');continue;}const y=x['data']??x,z=typeof y['permission']==='string'?y['permission']:undefined;if(!z){f['push']('pre_publish:\x20arbitration\x20\x22'+w+'\x22\x20exposes\x20no\x20permission\x20address\x20—\x20controller-key\x20disjointness\x20UNVERIFIED');continue;}if(z['toLowerCase']()===i['toLowerCase']()){d['push']('pre_publish:\x20R-ARB-SAME-CONTROLLER\x20—\x20arbitration\x20\x22'+w+'\x22\x20shares\x20the\x20service\x27s\x20Permission\x20object\x20'+('('+i+').\x20The\x20chain\x20aborts\x20this\x20binding\x20(E_ARBITRATION_PERMISSION_CONFLICT);\x20bind\x20an\x20')+'arbitration\x20with\x20its\x20own\x20independent\x20Permission');continue;}if(!l(z))try{const D=await batchQueryObjectsByIds([z],c,!![]);k=[...k??[],...D??[]];}catch(E){f['push']('pre_publish:\x20arbitration\x20\x22'+w+'\x22\x20Permission\x20\x22'+z+'\x22\x20could\x20not\x20be\x20queried\x20'+('('+(E instanceof Error?E['message']:String(E))+')\x20—\x20controller-key\x20disjointness\x20UNVERIFIED'));continue;}const A=m(l(z));if(A['size']===0x0){f['push']('pre_publish:\x20arbitration\x20\x22'+w+'\x22\x20Permission\x20\x22'+z+'\x22\x20not\x20found\x20or\x20carries\x20no\x20builder/admin\x20list\x20—\x20'+'controller-key\x20disjointness\x20UNVERIFIED');continue;}const B=[...o]['filter'](F=>A['has'](F));B['length']>0x0&&d['push']('pre_publish:\x20R-ARB-SAME-CONTROLLER\x20—\x20the\x20arbitration\x20\x22'+w+'\x22\x20is\x20NOT\x20controller-independent:\x20'+('EOA(s)\x20'+B['join'](',\x20')+'\x20appear\x20in\x20BOTH\x20the\x20service\x20Permission\x20('+i+')\x20and\x20the\x20')+('arbitration\x20Permission\x20('+z+')\x20builder/admin\x20sets.\x20Object\x20isolation\x20is\x20enforced\x20on-chain\x20')+'(different\x20Permission\x20objects),\x20but\x20controller\x20isolation\x20is\x20NOT:\x20a\x20shared\x20EOA\x20can\x20confirm,\x20vote\x20in,\x20'+'and\x20rule\x20the\x20service\x27s\x20disputes\x20—\x20arbitration\x20neutrality\x20collapses\x20(live\x20mainnet:\x20the\x20reused\x20arb\x27s\x20'+'Permission\x20builder\x20AND\x20sole\x20admin\x20was\x20the\x20merchant).\x20Bind\x20an\x20arbitration\x20whose\x20Permission\x20is\x20controlled\x20'+'by\x20physically\x20independent\x20keys');const C=arbitrationVotingLockDetail(y['voting_guard']);C!==null&&d['push']('pre_publish:\x20R-ARB-VOTE-LOCK\x20—\x20arbitration\x20\x22'+w+'\x22:\x20'+C);}return{'critical':d,'warnings':f};}async function runPreBuyChecks(a,b){const c=[],d=[],f=extractData(b)??{},g=b?.['env']?.['network'],h=f['object'];let i;try{i=await batchQueryObjectsByIds([h],g,!![]);}catch(m){return d['push']('pre_buy:\x20allocator\x20screening\x20DEGRADED\x20—\x20could\x20not\x20query\x20service\x20\x22'+h+'\x22\x20'+('('+(m instanceof Error?m['message']:String(m))+');\x20the\x20purchase\x20was\x20NOT\x20screened.\x20')+'Verify\x20the\x20service\x27s\x20order_allocators\x20yourself\x20(query_toolkit\x20query_type=\x27service_panorama\x27)\x20before\x20trusting\x20this\x20buy'),{'critical':c,'warnings':d};}const j=(i??[])['find'](n=>n?.['type']==='Service');if(!j)return d['push']('pre_buy:\x20allocator\x20screening\x20DEGRADED\x20—\x20service\x20\x22'+h+'\x22\x20not\x20found\x20on-chain\x20(or\x20not\x20yet\x20indexed);\x20'+'the\x20purchase\x20was\x20NOT\x20screened.\x20Verify\x20the\x20address/network\x20and\x20the\x20service\x27s\x20order_allocators\x20before\x20trusting\x20this\x20buy'),{'critical':c,'warnings':d};const k=j['data']??j;k['bPublished']!==!![]&&c['push']('pre_buy:\x20service\x20\x22'+h+'\x22\x20is\x20NOT\x20published\x20—\x20the\x20buy\x20aborts\x20on-chain\x20(E_NOT_PUBLISHED)');k['bPaused']===!![]&&c['push']('pre_buy:\x20service\x20\x22'+h+'\x22\x20is\x20paused\x20—\x20the\x20buy\x20aborts\x20on-chain\x20(E_PAUSED)');const l=k['order_allocators'];if(l==null)c['push']('pre_buy:\x20service\x20\x22'+h+'\x22\x20has\x20NO\x20order_allocators\x20—\x20the\x20payment\x20step\x20aborts\x20(no\x20distribution\x20plan).\x20'+'Funds\x20committed\x20to\x20this\x20service\x20would\x20have\x20NO\x20distribution\x20path\x20(the\x20fund-lock\x20incident\x20class).\x20'+'Do\x20not\x20buy\x20until\x20the\x20merchant\x20configures\x20an\x20allocator\x20plan');else{if(!Array['isArray'](l['allocators'])||l['allocators']['length']===0x0)c['push']('pre_buy:\x20service\x20\x22'+h+'\x22\x20order_allocators\x20is\x20EMPTY\x20—\x20the\x20payment\x20step\x20aborts\x20(EALLOCATORS_EMPTY).\x20'+'Do\x20not\x20buy\x20until\x20the\x20merchant\x20configures\x20at\x20least\x20one\x20allocator');else{const n=f['buy'],o=Array['isArray'](n?.['items'])?n['items']:[],p=Array['isArray'](k['sales'])?k['sales']:[];let q=0x0,r=o['length']>0x0;const s=[];for(const v of o){const w=v,x=numericBalance(w?.['quantity']),y=p['find'](A=>A?.['name']===w?.['name']),z=numericBalance(y?.['price']);if(x===undefined||z===undefined){r=![],s['push'](typeof w?.['name']==='string'?w['name']:JSON['stringify'](w?.['name']));continue;}q+=z*x;}const t=numericBalance(l['threshold']);if(!r)d['push']('pre_buy:\x20could\x20not\x20price\x20'+s['length']+'\x20cart\x20item(s)\x20['+s['join'](',\x20')+']\x20against\x20the\x20service\x27s\x20on-chain\x20sales\x20—\x20'+'allocator-threshold\x20coverage\x20UNVERIFIED\x20for\x20this\x20cart\x20(unknown\x20items\x20also\x20abort\x20the\x20quote\x20step).\x20'+'Confirm\x20every\x20item\x20name\x20matches\x20a\x20current\x20sale\x20entry');else t!==undefined&&t>q&&c['push']('pre_buy:\x20allocator\x20threshold\x20'+t+'\x20exceeds\x20this\x20cart\x27s\x20total\x20'+q+'\x20(Σ\x20price×quantity\x20over\x20the\x20on-chain\x20sales)\x20—\x20'+'the\x20payment\x20step\x20aborts\x20(EINSUFFICIENT_BALANCE):\x20pool\x20creation\x20requires\x20amount\x20>=\x20threshold.\x20'+'The\x20merchant\x20must\x20lower\x20the\x20threshold\x20(new\x20service\x20—\x20threshold\x20is\x20frozen\x20at\x20publish)\x20or\x20the\x20cart\x20must\x20grow');n?.['discount']!=null&&r&&t!==undefined&&t<=q&&d['push']('pre_buy:\x20a\x20discount\x20is\x20applied\x20—\x20the\x20discounted\x20total\x20may\x20fall\x20below\x20the\x20list\x20total\x20'+q+'\x20used\x20here;\x20'+('if\x20it\x20lands\x20under\x20the\x20allocator\x20threshold\x20'+t+',\x20the\x20payment\x20step\x20aborts\x20(EINSUFFICIENT_BALANCE)'));const u=await lintAllocatorGuardSet([l],g,'pre_buy','critical');c['push'](...u['critical']),d['push'](...u['warnings']);}}return{'critical':c,'warnings':d};}export async function runPrePublishChecks(a,b){const c=[],d=[],f=extractOperationType(a,b),g=extractData(b)??{},h=b?.['env']?.['network'];if(f==='machine'){const i=g['node'];let j=Array['isArray'](i)?i:Array['isArray'](i?.['nodes'])?i['nodes']:[];if(j['length']===0x0&&typeof g['object']==='string'){const l=g['object'];try{const m=await fetchMachineNodes(l,h,!![]);m['length']>0x0&&(j=m,d['push']('pre_publish:\x20machine\x20\x22'+l+'\x22\x20published\x20by\x20reference\x20—\x20audited\x20against\x20its\x20'+(m['length']+'\x20on-chain\x20node(s)\x20(effective-state\x20gate)')));}catch(n){c['push']('pre_publish:\x20could\x20not\x20fetch\x20on-chain\x20nodes\x20for\x20machine\x20\x22'+l+'\x22\x20'+('('+(n instanceof Error?n['message']:String(n))+')\x20—\x20topology\x20UNVERIFIABLE;\x20publish\x20blocked.\x20')+'Retry\x20when\x20the\x20network\x20is\x20reachable;\x20every\x20guarded\x20forward\x20must\x20carry\x20the\x20protocol\x20slot\x20254\x20'+'submission\x20row\x20and\x20topology\x20is\x20immutable\x20after\x20publish\x20(IMMUT-001)');}}if(j['length']>0x0){const o=g['reentry_kind'],p=o==='none'||o==='review-loop'||o==='paid-cycle'?o:undefined;o!==undefined&&p===undefined&&d['push']('pre_publish:\x20ignored\x20invalid\x20reentry_kind\x20\x22'+String(o)+'\x22\x20—\x20'+'valid\x20values:\x20none\x20(default,\x20word-stem\x20classification)\x20/\x20review-loop\x20(same-order\x20no-charge\x20revisits)\x20/\x20paid-cycle\x20(per-revisit\x20fee,\x20fund\x20gate\x20required)');const q=auditMachineNodes(j,p);c['push'](...q['critical']),d['push'](...q['warnings']);const s=await fetchForwardGuardIndex(j,h),t=lintForwardGuardsTaskBinding(s);c['push'](...t['critical']),d['push'](...t['warnings']);const u=lintForwardReviewLocks(j,s);c['push'](...u['critical']),d['push'](...u['warnings']);const v=lintForwardGuardsTimeProfile(s);c['push'](...v['critical']),d['push'](...v['warnings']);}else typeof g['object']!=='string'&&d['push']('pre_publish:\x20publishing\x20machine\x20without\x20inline\x20node\x20data\x20—\x20topology\x20not\x20verifiable\x20in\x20this\x20call;\x20'+'verify\x20nodes/pairs/forwards\x20via\x20machineNode2file\x20BEFORE\x20publish\x20(immutable\x20after\x20publish,\x20IMMUT-001)');d['push']('pre_publish:\x20machine\x20nodes/pairs/forwards\x20become\x20immutable\x20after\x20publish\x20(IMMUT-001)');}if(f==='service'){d['push']('pre_publish:\x20service\x20machine/order_allocators/arbitrations\x20become\x20immutable\x20after\x20publish\x20(IMMUT-002);\x20sales\x20remains\x20modifiable');g['machine']===undefined&&d['push']('pre_publish:\x20\x27machine\x27\x20absent\x20from\x20THIS\x20call\x20(the\x20store\x20may\x20already\x20be\x20bound\x20—\x20verify\x20before\x20assuming\x20otherwise):\x20'+'query_toolkit\x20query_type=\x27service_panorama\x27\x20and\x20read\x20service.machine;\x20an\x20unset\x20machine\x20cannot\x20process\x20orders\x20and\x20CANNOT\x20be\x20fixed\x20after\x20publish\x20(IMMUT-002)');g['order_allocators']===undefined&&d['push']('pre_publish:\x20\x27order_allocators\x27\x20absent\x20from\x20THIS\x20call\x20(the\x20store\x20may\x20already\x20be\x20configured\x20—\x20verify\x20before\x20assuming\x20otherwise):\x20'+'query_toolkit\x20query_type=\x27service_panorama\x27\x20and\x20read\x20order_allocators;\x20immutable\x20after\x20publish,\x20so\x20orders\x20get\x20no\x20fund\x20distribution\x20if\x20never\x20configured\x20(IMMUT-002)');const w=g,x=numericBalance(w['compensation_fund_add']?.['balance']);if(x!==undefined&&x>0x0){const B=w['sales'],C=(Array['isArray'](B?.['sales'])?B['sales']:[])['map'](D=>numericBalance(D?.['price']?.['balance']))['filter'](D=>D!==undefined);if(C['length']>0x0){const D=C['reduce']((F,G)=>F+G,0x0),E=D*0x3;if(E>0x0){const F=x/E,G='fund='+x+',\x20highest-SKU\x20single\x20order=Σ(price×1)='+D+'\x20(quantity\x20set\x20at\x20buy\x20time),\x20'+('award\x20cap=3×order='+E+'\x20(MAX_INDEMNITY_MULTIPLE),\x20coverage='+F['toFixed'](0x2));F<0x1&&d['push']('pre_publish:\x20compensation-fund\x20coverage\x20below\x20the\x20award\x20ceiling\x20—\x20'+G+'\x20<\x201.\x20'+'Disclosure\x20only\x20(b6-11):\x20this\x20does\x20NOT\x20block\x20publish.\x20Per-order\x20coverage\x20is\x20enforced\x20at\x20'+'BUY\x20time\x20—\x20orders\x20are\x20rejected\x20while\x20the\x20fund\x20cannot\x20cover\x203x\x20that\x20order,\x20so\x20top\x20up\x20via\x20'+'compensation_fund_add\x20as\x20your\x20catalog\x27s\x20order\x20sizes\x20require\x20(no\x20cross-SKU\x20subsidy).\x20'+'Awards\x20beyond\x20the\x20fund\x20abort\x20the\x20claim\x20(code\x2027)\x20—\x20settlement\x20is\x20all-or-nothing,\x20nothing\x20partial\x20is\x20paid;\x20top\x20up\x20and\x20the\x20winner\x20retries.');}}else d['push']('pre_publish:\x20compensation_fund_add\x20present\x20but\x20\x27sales\x27\x20absent\x20from\x20THIS\x20call\x20(sales\x20may\x20already\x20be\x20configured\x20—\x20verify,\x20do\x20not\x20assume):\x20'+'the\x20fund\x20should\x20cover\x203×\x20each\x20order\x20you\x20want\x20to\x20sell\x20(MAX_INDEMNITY_MULTIPLE=3;\x20enforced\x20per-order\x20at\x20buy\x20time).\x20'+'query_toolkit\x20query_type=\x27service_panorama\x27\x20to\x20read\x20the\x20current\x20sales\x20prices,\x20then\x20re-check\x20coverage.');}const y=await lintAllocatorGuards(w,h);c['push'](...y['critical']),d['push'](...y['warnings']);if(w['order_allocators']!==undefined||w['order_allocators_append']!==undefined){const H=w['machine'];if(typeof H==='string'&&H['trim']()!==''){const I=await lintServiceEscrowExitCoverage(H,[w['order_allocators'],w['order_allocators_append']],h);c['push'](...I['critical']),d['push'](...I['warnings']);}else d['push']('pre_publish:\x20\x27machine\x27\x20absent\x20from\x20THIS\x20call\x20—\x20escrow-exit\x20terminal\x20coverage\x20not\x20auditable\x20here;\x20'+'if\x20the\x20machine\x20is\x20already\x20bound,\x20every\x20machine\x20terminal\x20needs\x20an\x20allocator\x20rail\x20(immutable\x20after\x20publish,\x20IMMUT-002)');}const z=await checkArbitrationNeutrality(w,h);c['push'](...z['critical']),d['push'](...z['warnings']);const A=new Set(rewardRefsOf(w)['map'](J=>J['toLowerCase']()));if(A['size']===0x0&&w['publish']===!![]&&typeof w['object']==='string')try{const J=await batchQueryObjectsByIds([w['object']],h,!![]),K=(J??[])[0x0],L=K?.['data']??K,M=Array['isArray'](L?.['rewards'])?L['rewards']:[];for(const N of M){if(typeof N==='string'&&N['trim']()!=='')A['add'](N['toLowerCase']());}}catch(O){d['push']('pre_publish:\x20reward-funding\x20gate\x20skipped\x20—\x20could\x20not\x20read\x20the\x20service\x27s\x20on-chain\x20rewards\x20'+('('+(O instanceof Error?O['message']:String(O))+');\x20verify\x20every\x20attached\x20Reward\x20pool\x20is\x20funded\x20')+'up\x20to\x20expected_orders\x20x\x20per-claim\x20amount\x20BEFORE\x20publish');}if(A['size']>0x0)try{const P=await batchQueryObjectsByIds([...A['values']()],h,!![]),Q=new Map();for(const R of P??[]){const S=R;if(S?.['type']!=='Reward')continue;for(const T of[S['query_name'],S['object']]){if(typeof T==='string'&&T!=='')Q['set'](T['toLowerCase'](),S);}}for(const U of A){const V=Q['get'](U);if(!V){d['push']('pre_publish:\x20attached\x20reward\x20\x22'+U+'\x22\x20not\x20found\x20on-chain\x20—\x20funding\x20check\x20skipped\x20for\x20it;\x20'+'an\x20unfunded\x20pool\x20publishes\x20silently\x20and\x20claims\x20abort\x20when\x20it\x20drains');continue;}const W=serviceRewardsUnfundedDetail(V);W&&c['push']('pre_publish:\x20OFN-C\x20reward-pool\x20funding\x20—\x20reward\x20\x22'+U+'\x22:\x20'+W);}}catch(X){d['push']('pre_publish:\x20reward-funding\x20gate\x20skipped\x20—\x20could\x20not\x20query\x20reward\x20objects\x20'+('('+(X instanceof Error?X['message']:String(X))+');\x20verify\x20every\x20attached\x20Reward\x20pool\x20is\x20funded\x20')+'up\x20to\x20expected_orders\x20x\x20per-claim\x20amount\x20BEFORE\x20publish');}}return{'critical':c,'warnings':d};}function buildHarnessBlockResult(a,b,c,d,e,f){const g=[...c['map'](i=>'CRITICAL:\x20'+i),...d['map'](i=>'WARN:\x20'+i)]['join']('\x0a'),h='Error:\x20'+b+(g?'\x0a'+g:'')+'\x0aRecovery:\x20'+f;return{'content':[{'type':'text','text':h}],'structuredContent':{'outcome':'failed','result':{'type':'error','error':b+'\x20[gate='+a+']','error_code':e,'retryable':![],'recovery_hint':f},'message':h,'recovery':recover(e,'harness:'+a)}};}function extractCriticalFindingCount(a){const b=a?.['structuredContent'];if(!b)return 0x0;const c=b['semantic'],d=c?.['summary'];if(typeof d?.['critical_count']==='number'&&d['critical_count']>0x0)return d['critical_count'];const e=b['findings']??c?.['findings'];if(Array['isArray'](e))return e['filter'](h=>h?.['severity']==='error')['length'];const f=a?.['content']?.['map'](h=>'text'in h?h['text']:'')['join']('\x0a')??'',g=f['match'](/\[AUDIT ERROR\]/g);return g?g['length']:0x0;}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wowok/agent-mcp",
3
- "version": "3.3.0",
3
+ "version": "3.3.2",
4
4
  "description": "Making It Easy for AI Agents to Communicate, Collaborate, Trade, and Trust.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -54,7 +54,7 @@
54
54
  "license": "Apache-2.0",
55
55
  "dependencies": {
56
56
  "@modelcontextprotocol/server": "^2.0.0",
57
- "@wowok/wowok": "3.3.1",
57
+ "@wowok/wowok": "3.3.3",
58
58
  "lodash": "^4.18.1",
59
59
  "zod": "^4.2.0"
60
60
  },