@wowok/agent-mcp 3.3.1 → 3.3.3

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 (277) 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 +5 -3
  11. package/dist/composition/compile.js +1 -1
  12. package/dist/composition/inflight.d.ts +32 -4
  13. package/dist/composition/inflight.js +1 -1
  14. package/dist/config/judgment.d.ts +111 -1
  15. package/dist/config/judgment.js +1 -1
  16. package/dist/customer/industry-risks.js +1 -1
  17. package/dist/customer/user-preferences.js +1 -1
  18. package/dist/evaluation/arbitration-game.d.ts +4 -0
  19. package/dist/evaluation/arbitration-game.js +1 -1
  20. package/dist/evaluation/builtins/graph-service.js +1 -1
  21. package/dist/evaluation/builtins/graph-service.spec.js +1 -1
  22. package/dist/evaluation/game-strategy.d.ts +6 -0
  23. package/dist/evaluation/game-strategy.js +1 -1
  24. package/dist/evaluation/node-game.d.ts +4 -0
  25. package/dist/evaluation/node-game.js +1 -1
  26. package/dist/evaluation/value-risk.d.ts +8 -0
  27. package/dist/evaluation/value-risk.js +1 -0
  28. package/dist/experience/realtime-feedback.js +1 -1
  29. package/dist/extensions/business-modules.d.ts +7 -2
  30. package/dist/extensions/business-modules.js +1 -1
  31. package/dist/extensions/industry-audit.spec.js +1 -1
  32. package/dist/extensions/industry-pack.d.ts +3 -2
  33. package/dist/extensions/industry-pack.js +1 -1
  34. package/dist/extensions/modes.js +1 -1
  35. package/dist/graph/onchain/analyze.js +1 -1
  36. package/dist/graph/onchain/analyze.spec.js +1 -1
  37. package/dist/graph/onchain/expand.js +1 -1
  38. package/dist/graph/onchain/exposure.js +1 -1
  39. package/dist/graph/onchain/facet-projection.js +1 -1
  40. package/dist/graph/onchain/facet-projection.spec.js +1 -1
  41. package/dist/graph/onchain/facts.d.ts +20 -0
  42. package/dist/graph/onchain/facts.js +1 -1
  43. package/dist/graph/onchain/facts.spec.js +1 -1
  44. package/dist/graph/onchain/object-held-receipts.d.ts +20 -0
  45. package/dist/graph/onchain/object-held-receipts.js +1 -0
  46. package/dist/graph/onchain/object-held-receipts.spec.d.ts +1 -0
  47. package/dist/graph/onchain/object-held-receipts.spec.js +1 -0
  48. package/dist/graph/onchain/project-relationship.js +1 -1
  49. package/dist/graph/onchain/sdk-batch.d.ts +1 -0
  50. package/dist/graph/onchain/sdk-batch.js +1 -1
  51. package/dist/harness/index.d.ts +1 -0
  52. package/dist/harness/recover.d.ts +2 -1
  53. package/dist/harness/recover.js +1 -1
  54. package/dist/knowledge/acquisition-flywheel.js +1 -1
  55. package/dist/knowledge/allocation-ledger.d.ts +3 -1
  56. package/dist/knowledge/allocation-ledger.js +1 -1
  57. package/dist/knowledge/allocation-puzzle.d.ts +1 -0
  58. package/dist/knowledge/allocation-puzzle.js +1 -1
  59. package/dist/knowledge/allocation-risk.d.ts +1 -1
  60. package/dist/knowledge/allocation-risk.js +1 -1
  61. package/dist/knowledge/arb-fund-facts.d.ts +12 -0
  62. package/dist/knowledge/arb-fund-facts.js +1 -1
  63. package/dist/knowledge/audit-rules.d.ts +4 -3
  64. package/dist/knowledge/audit-rules.js +1 -1
  65. package/dist/knowledge/baselines/judgment-baselines.json +502 -81
  66. package/dist/knowledge/baselines/rules/allocation.json +0 -14
  67. package/dist/knowledge/baselines/rules/graph.json +4 -4
  68. package/dist/knowledge/baselines/rules/plan.json +81 -5
  69. package/dist/knowledge/baselines/rules/reward.json +1 -1
  70. package/dist/knowledge/builtin-templates.d.ts +9 -1
  71. package/dist/knowledge/builtin-templates.js +1 -1
  72. package/dist/knowledge/discount-threshold.js +1 -1
  73. package/dist/knowledge/event-semantics.js +1 -1
  74. package/dist/knowledge/game-scenarios.d.ts +21 -0
  75. package/dist/knowledge/game-scenarios.js +1 -0
  76. package/dist/knowledge/getting-started.js +1 -1
  77. package/dist/knowledge/guard-bindings.js +1 -1
  78. package/dist/knowledge/guard-design-patterns.d.ts +1 -1
  79. package/dist/knowledge/guard-design-patterns.js +1 -1
  80. package/dist/knowledge/guard-field-cognition.js +1 -1
  81. package/dist/knowledge/guard-leg-map.d.ts +5 -0
  82. package/dist/knowledge/guard-leg-map.js +1 -0
  83. package/dist/knowledge/guard-lint.js +1 -1
  84. package/dist/knowledge/guard-puzzle.js +1 -1
  85. package/dist/knowledge/guard-render.js +1 -1
  86. package/dist/knowledge/guard-risk.js +1 -1
  87. package/dist/knowledge/guard-submission-brief.d.ts +5 -0
  88. package/dist/knowledge/guard-submission-brief.js +1 -1
  89. package/dist/knowledge/guard-submission-prompt.d.ts +2 -1
  90. package/dist/knowledge/guard-submission-prompt.js +1 -1
  91. package/dist/knowledge/guard-templates.d.ts +1 -1
  92. package/dist/knowledge/guard-templates.js +1 -1
  93. package/dist/knowledge/guard-translation.js +1 -1
  94. package/dist/knowledge/index.js +1 -1
  95. package/dist/knowledge/industry-generalizer.js +1 -1
  96. package/dist/knowledge/industry-registry.js +1 -1
  97. package/dist/knowledge/industry-strategy.js +1 -1
  98. package/dist/knowledge/jsonrpc-enum.js +1 -1
  99. package/dist/knowledge/onchain-constants.d.ts +4 -2
  100. package/dist/knowledge/onchain-constants.js +1 -1
  101. package/dist/knowledge/order-ledger.d.ts +1 -1
  102. package/dist/knowledge/order-ledger.js +1 -1
  103. package/dist/knowledge/order-puzzle.d.ts +3 -0
  104. package/dist/knowledge/order-risk.d.ts +1 -1
  105. package/dist/knowledge/passport-ledger.d.ts +12 -0
  106. package/dist/knowledge/passport-ledger.js +1 -1
  107. package/dist/knowledge/payment-tracker.js +1 -1
  108. package/dist/knowledge/protocol-facts.d.ts +1 -0
  109. package/dist/knowledge/protocol-facts.js +1 -1
  110. package/dist/knowledge/repository-write-semantics.d.ts +1 -1
  111. package/dist/knowledge/repository-write-semantics.js +1 -1
  112. package/dist/knowledge/reward-ledger.js +1 -1
  113. package/dist/knowledge/reward-puzzle.d.ts +1 -1
  114. package/dist/knowledge/reward-risk.d.ts +1 -1
  115. package/dist/knowledge/scenario-modes.d.ts +2 -2
  116. package/dist/knowledge/scenario-modes.js +1 -1
  117. package/dist/knowledge/scenario-topology.js +1 -1
  118. package/dist/knowledge/service-ledger.d.ts +14 -0
  119. package/dist/knowledge/service-ledger.js +1 -1
  120. package/dist/knowledge/strategy-manuals.js +1 -1
  121. package/dist/knowledge/template-index.d.ts +19 -0
  122. package/dist/knowledge/template-index.js +1 -0
  123. package/dist/knowledge/template-loader.d.ts +36 -0
  124. package/dist/knowledge/template-loader.js +1 -1
  125. package/dist/knowledge/template-registry.js +1 -1
  126. package/dist/knowledge/template-scanner.d.ts +11 -0
  127. package/dist/knowledge/template-scanner.js +1 -1
  128. package/dist/knowledge/tool-constraints.js +1 -1
  129. package/dist/knowledge/workflow-guidance.d.ts +2 -0
  130. package/dist/knowledge/workflow-guidance.js +1 -1
  131. package/dist/monitor/MonitorLoop.js +1 -1
  132. package/dist/participation/allocation-advice.d.ts +8 -1
  133. package/dist/participation/allocation-advice.js +1 -1
  134. package/dist/participation/game-context.d.ts +25 -0
  135. package/dist/participation/game-context.js +1 -0
  136. package/dist/participation/node-action-advisor.d.ts +64 -0
  137. package/dist/participation/node-action-advisor.js +1 -0
  138. package/dist/participation/radar-core.d.ts +1 -0
  139. package/dist/participation/radar-core.js +1 -1
  140. package/dist/persona/defaults.js +1 -1
  141. package/dist/persona/topology-focus.js +1 -1
  142. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  143. package/dist/playbooks/service-build/game-theory.d.ts +4 -1
  144. package/dist/playbooks/service-build/game-theory.js +1 -1
  145. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  146. package/dist/playbooks/service-build/merchant-guide.d.ts +26 -1
  147. package/dist/playbooks/service-build/merchant-guide.js +1 -1
  148. package/dist/playbooks/service-build/migration-planner.d.ts +2 -2
  149. package/dist/playbooks/service-build/migration-planner.js +1 -1
  150. package/dist/playbooks/service-build/object-panorama.d.ts +13 -1
  151. package/dist/playbooks/service-build/object-panorama.js +1 -1
  152. package/dist/playbooks/service-build/participation-radar.js +1 -1
  153. package/dist/playbooks/service-build/pipeline-actions.d.ts +4 -1
  154. package/dist/playbooks/service-build/pipeline-actions.js +1 -1
  155. package/dist/playbooks/service-build/relationship-profile.js +1 -1
  156. package/dist/playbooks/service-build/service-panorama.d.ts +12 -0
  157. package/dist/playbooks/service-build/service-panorama.js +1 -1
  158. package/dist/playbooks/service-build/service-quote.js +1 -1
  159. package/dist/playbooks/service-build/service-quote.spec.js +1 -1
  160. package/dist/relationship/derivation.d.ts +1 -1
  161. package/dist/review/index.js +1 -1
  162. package/dist/review/repository.js +1 -1
  163. package/dist/role/intent.d.ts +23 -0
  164. package/dist/role/intent.js +1 -0
  165. package/dist/safety/confirm-gate.js +1 -1
  166. package/dist/schema/benchmark-migration/index.d.ts +39 -0
  167. package/dist/schema/benchmark-migration/index.js +1 -1
  168. package/dist/schema/call/allocation.d.ts +49 -3
  169. package/dist/schema/call/allocation.js +1 -1
  170. package/dist/schema/call/arbitration.js +1 -1
  171. package/dist/schema/call/base.d.ts +52 -0
  172. package/dist/schema/call/base.js +1 -1
  173. package/dist/schema/call/bridge.d.ts +3 -0
  174. package/dist/schema/call/contact.js +1 -1
  175. package/dist/schema/call/error-codes.d.ts +1 -1
  176. package/dist/schema/call/error-codes.js +1 -1
  177. package/dist/schema/call/guard.js +1 -1
  178. package/dist/schema/call/handler.js +1 -1
  179. package/dist/schema/call/machine.d.ts +10 -0
  180. package/dist/schema/call/machine.js +1 -1
  181. package/dist/schema/call/order.d.ts +2 -0
  182. package/dist/schema/call/order.js +1 -1
  183. package/dist/schema/call/progress.d.ts +6 -3
  184. package/dist/schema/call/progress.js +1 -1
  185. package/dist/schema/call/repository.d.ts +4 -0
  186. package/dist/schema/call/repository.js +1 -1
  187. package/dist/schema/call/reward.d.ts +2 -2
  188. package/dist/schema/call/reward.js +1 -1
  189. package/dist/schema/call/semantic.d.ts +6 -0
  190. package/dist/schema/call/semantic.js +1 -1
  191. package/dist/schema/call/service.d.ts +42 -4
  192. package/dist/schema/call/service.js +1 -1
  193. package/dist/schema/common/index.js +1 -1
  194. package/dist/schema/goal/index.d.ts +54 -0
  195. package/dist/schema/goal/planning.d.ts +86 -0
  196. package/dist/schema/goal/planning.js +1 -1
  197. package/dist/schema/keeper/index.d.ts +2 -0
  198. package/dist/schema/local/index.d.ts +72 -0
  199. package/dist/schema/local/index.js +1 -1
  200. package/dist/schema/messenger/index.d.ts +2 -0
  201. package/dist/schema/operations.d.ts +46 -5
  202. package/dist/schema/operations.js +1 -1
  203. package/dist/schema/persona/index.d.ts +484 -0
  204. package/dist/schema/query/bi.d.ts +4 -0
  205. package/dist/schema/query/bi.js +1 -1
  206. package/dist/schema/query/index.d.ts +84 -60
  207. package/dist/schema/query/index.js +1 -1
  208. package/dist/schema/schema-version.d.ts +1 -1
  209. package/dist/schema/schema-version.js +1 -1
  210. package/dist/schema-query-impl/index.js +1 -1
  211. package/dist/schemas/account_operation.output.json +41 -10
  212. package/dist/schemas/account_operation.schema.json +1 -1
  213. package/dist/schemas/benchmark_migration_operation.output.json +8 -5
  214. package/dist/schemas/benchmark_migration_operation.schema.json +91 -3
  215. package/dist/schemas/bridge_operation.output.json +13 -7
  216. package/dist/schemas/goal_operation.schema.json +94 -0
  217. package/dist/schemas/index.json +1 -1
  218. package/dist/schemas/keeper_operation.output.json +12 -7
  219. package/dist/schemas/local_cache_operation.output.json +34 -7
  220. package/dist/schemas/local_cache_operation.schema.json +16 -1
  221. package/dist/schemas/local_history_operation.output.json +13 -7
  222. package/dist/schemas/local_info_operation.output.json +13 -7
  223. package/dist/schemas/local_info_operation.schema.json +5 -1
  224. package/dist/schemas/local_mark_operation.output.json +13 -7
  225. package/dist/schemas/messenger_operation.output.json +12 -7
  226. package/dist/schemas/monitor_events.output.json +12 -7
  227. package/dist/schemas/monitor_subscription.output.json +12 -7
  228. package/dist/schemas/onchain_events.output.json +67 -18
  229. package/dist/schemas/onchain_events.schema.json +4 -0
  230. package/dist/schemas/onchain_operations.output.json +81 -24
  231. package/dist/schemas/onchain_operations.schema.json +531 -126
  232. package/dist/schemas/onchain_operations_allocation.schema.json +294 -6
  233. package/dist/schemas/onchain_operations_arbitration.schema.json +3 -3
  234. package/dist/schemas/onchain_operations_contact.schema.json +2 -2
  235. package/dist/schemas/onchain_operations_demand.schema.json +3 -3
  236. package/dist/schemas/onchain_operations_gen_passport.schema.json +1 -1
  237. package/dist/schemas/onchain_operations_guard.schema.json +99 -63
  238. package/dist/schemas/onchain_operations_machine.schema.json +10 -1
  239. package/dist/schemas/onchain_operations_order.schema.json +8 -4
  240. package/dist/schemas/onchain_operations_progress.schema.json +8 -4
  241. package/dist/schemas/onchain_operations_proof.schema.json +1 -1
  242. package/dist/schemas/onchain_operations_repository.schema.json +6 -2
  243. package/dist/schemas/onchain_operations_reward.schema.json +8 -8
  244. package/dist/schemas/onchain_operations_service.schema.json +81 -21
  245. package/dist/schemas/onchain_operations_treasury.schema.json +7 -7
  246. package/dist/schemas/onchain_table_data.output.json +16 -7
  247. package/dist/schemas/persona_operation.output.json +1387 -0
  248. package/dist/schemas/persona_operation.schema.json +219 -0
  249. package/dist/schemas/query_toolkit.output.json +115 -64
  250. package/dist/schemas/query_toolkit.schema.json +8 -0
  251. package/dist/schemas/workflow_operation.schema.json +1 -1
  252. package/dist/tools/handlers/benchmark-migration.js +1 -1
  253. package/dist/tools/handlers/bridge.js +1 -1
  254. package/dist/tools/handlers/config.js +1 -1
  255. package/dist/tools/handlers/dispatch-expectations.js +1 -1
  256. package/dist/tools/handlers/file-export.js +1 -1
  257. package/dist/tools/handlers/industry-pack.d.ts +1 -0
  258. package/dist/tools/handlers/industry-pack.js +1 -1
  259. package/dist/tools/handlers/local.js +1 -1
  260. package/dist/tools/handlers/messenger.js +1 -1
  261. package/dist/tools/handlers/onchain-name-registration.d.ts +11 -0
  262. package/dist/tools/handlers/onchain-name-registration.js +1 -1
  263. package/dist/tools/handlers/onchain.d.ts +28 -0
  264. package/dist/tools/handlers/onchain.js +1 -1
  265. package/dist/tools/handlers/query.js +1 -1
  266. package/dist/tools/handlers/review-chain.d.ts +1 -1
  267. package/dist/tools/handlers/review-chain.js +1 -1
  268. package/dist/tools/handlers/schema-query.js +1 -1
  269. package/dist/tools/handlers/workflow.js +1 -1
  270. package/dist/tools/move-fn-index.gen.js +1 -1
  271. package/dist/tools/registry/agent.js +1 -1
  272. package/dist/tools/registry/local.js +1 -1
  273. package/dist/tools/registry/onchain.js +1 -1
  274. package/dist/tools/registry/query.js +1 -1
  275. package/dist/tools/wip-deploy-assist.js +1 -1
  276. package/dist/tools/wrap.js +1 -1
  277. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- export declare const MCP_SCHEMA_VERSION = "1.1.0";
1
+ export declare const MCP_SCHEMA_VERSION = "1.2.0";
2
2
  export interface SchemaVersions {
3
3
  sdk: string;
4
4
  mcp: string;
@@ -1 +1 @@
1
- import*as a423a from'@wowok/wowok';const SDK_SCHEMA_VERSION=a423a['SCHEMA_VERSION']??'1.0.0',checkSchemaCompatibility=a423a['checkSchemaCompatibility']??((a,b)=>({'compatible':!![]}));export const MCP_SCHEMA_VERSION='1.1.0';export function getSchemaVersions(){return{'sdk':SDK_SCHEMA_VERSION,'mcp':MCP_SCHEMA_VERSION};}export function checkClientSchemaCompatibility(a,b={}){const c=getSchemaVersions(),d={'compatible':!![],'warnings':[],'errors':[],'versions':c,'client_version':a};if(!a)return d;const e=checkSchemaCompatibility(a,c['sdk']);if(!e['compatible']){d['compatible']=![];const g='SDK\x20schema\x20incompatibility:\x20'+e['reason'];b['mode']==='strict'?d['errors']['push'](g):d['warnings']['push'](g);}const f=checkSchemaCompatibility(a,c['mcp']);if(!f['compatible']){d['compatible']=![];const h='MCP\x20schema\x20incompatibility:\x20'+f['reason'];b['mode']==='strict'?d['errors']['push'](h):d['warnings']['push'](h);}return d;}export function attachSchemaWarning(a,b){if(b['warnings']['length']===0x0&&b['errors']['length']===0x0)return a;const c=[];b['warnings']['length']>0x0&&c['push'](...b['warnings']);b['errors']['length']>0x0&&c['push'](...b['errors']);const d=a['semantic']?{...a['semantic'],'warnings':[...a['semantic']['warnings']||[],...c]}:undefined;return{...a,'semantic':d,'schema_warning':{'compatible':b['compatible'],'warnings':c,'client_version':b['client_version'],'server_versions':b['versions']}};}
1
+ import*as a432a from'@wowok/wowok';const SDK_SCHEMA_VERSION=a432a['SCHEMA_VERSION']??'1.0.0',checkSchemaCompatibility=a432a['checkSchemaCompatibility']??((a,b)=>({'compatible':!![]}));export const MCP_SCHEMA_VERSION='1.2.0';export function getSchemaVersions(){return{'sdk':SDK_SCHEMA_VERSION,'mcp':MCP_SCHEMA_VERSION};}export function checkClientSchemaCompatibility(a,b={}){const c=getSchemaVersions(),d={'compatible':!![],'warnings':[],'errors':[],'versions':c,'client_version':a};if(!a)return d;const e=checkSchemaCompatibility(a,c['sdk']);if(!e['compatible']){d['compatible']=![];const g='SDK\x20schema\x20incompatibility:\x20'+e['reason'];b['mode']==='strict'?d['errors']['push'](g):d['warnings']['push'](g);}const f=checkSchemaCompatibility(a,c['mcp']);if(!f['compatible']){d['compatible']=![];const h='MCP\x20schema\x20incompatibility:\x20'+f['reason'];b['mode']==='strict'?d['errors']['push'](h):d['warnings']['push'](h);}return d;}export function attachSchemaWarning(a,b){if(b['warnings']['length']===0x0&&b['errors']['length']===0x0)return a;const c=[];b['warnings']['length']>0x0&&c['push'](...b['warnings']);b['errors']['length']>0x0&&c['push'](...b['errors']);const d=a['semantic']?{...a['semantic'],'warnings':[...a['semantic']['warnings']||[],...c]}:undefined;return{...a,'semantic':d,'schema_warning':{'compatible':b['compatible'],'warnings':c,'client_version':b['client_version'],'server_versions':b['versions']}};}
@@ -1 +1 @@
1
- import{readFileSync,existsSync,writeFileSync,mkdirSync}from'fs';import{resolve,join,dirname}from'path';import{fileURLToPath}from'url';import{GUARDQUERY,ObjectType,ValueType}from'@wowok/wowok';import{TOOLS_REFERENCE,getToolReference,searchToolReference,getToolSequence}from'../knowledge/tools-reference.js';import{GUARD_DESIGN_PATTERNS,getGuardDesignPattern,GUARD_DESIGN_PATTERNS_VERSION,GUARD_SCHEMA_NOTES}from'../knowledge/guard-design-patterns.js';import{OBJECT_REUSE_RULES,CREATE_VS_MODIFY_PATTERN,IMMUTABILITY_RULES,PROTOCOL_SLOT_RULES,OPERATION_TYPE_CLASSIFICATION,OPERATION_CLASS_META,NAMING_CONVENTIONS,SAFETY_RULES_VERSION}from'../knowledge/safety-rules.js';import{listTemplates as a435a,getTemplateDetail,instantiateTemplate,getTemplateCounts,TEMPLATE_OBJECT_TYPES}from'../knowledge/template-registry.js';import{lintGuard,formatLintResult}from'../knowledge/guard-lint.js';import{renderGuardTreeIndented,renderGuardMermaid,walkGuardTree}from'../knowledge/guard-render.js';import{getGuardQueryByIdOrName}from'../schema/utils/guard-query-utils.js';const __filename=fileURLToPath(import.meta.url),__dirname=fileURLToPath(new URL('.',import.meta.url)),SCHEMAS_DIR=resolve(__dirname,'../../dist/schemas'),GUARD_TEMPLATES_PATH_SCRIPTS=resolve(__dirname,'../../scripts/guard-templates.json'),GUARD_TEMPLATES_PATH_DIST=resolve(__dirname,'../../dist/schemas/guard-templates.json'),GUARD_TEMPLATES_PATH=existsSync(GUARD_TEMPLATES_PATH_SCRIPTS)?GUARD_TEMPLATES_PATH_SCRIPTS:GUARD_TEMPLATES_PATH_DIST,WORKSPACE_TMP_DIR=resolve(process['cwd'](),'.trae','tmp');export function areSchemasAvailable(){return existsSync(SCHEMAS_DIR)&&existsSync(join(SCHEMAS_DIR,'index.json'));}export function getSchemaIndex(){try{const a=join(SCHEMAS_DIR,'index.json');if(!existsSync(a))return null;const b=readFileSync(a,'utf-8');return JSON['parse'](b);}catch{return null;}}export function listSchemas(){const a=getSchemaIndex();if(!a)return[];return[...a['tools']||[],...a['operations']||[]];}export function getSchema(a){try{let b=join(SCHEMAS_DIR,a+'.schema.json');!existsSync(b)&&(b=join(SCHEMAS_DIR,a+'.json'));if(!existsSync(b))return null;const c=readFileSync(b,'utf-8'),d=JSON['parse'](c);return resolveSchemaRefs(d);}catch{return null;}}export function getOutputSchema(a){try{const b=join(SCHEMAS_DIR,a+'.output.json');if(!existsSync(b))return null;const c=readFileSync(b,'utf-8'),d=JSON['parse'](c);return resolveSchemaRefs(d);}catch{return null;}}export function getGuardTemplates(a){try{if(!existsSync(GUARD_TEMPLATES_PATH))return null;const b=readFileSync(GUARD_TEMPLATES_PATH,'utf-8'),c=JSON['parse'](b);if(!a)return{'version':c['version'],'description':c['description'],'templates':(c['templates']||[])['map'](e=>({'name':e['name'],'title':e['title'],'description':e['description'],'use_case':e['use_case']})),'query_reference':c['query_reference'],'node_return_types':c['node_return_types']};const d=(c['templates']||[])['find'](e=>e['name']===a);if(!d)return null;return d;}catch{return null;}}export function getSchemaField(a,b){const c=getSchema(a);if(!c)return null;const d=b['split']('.')['filter'](Boolean);let e=c;for(const f of d){if(!e||typeof e!=='object')return null;if(e['properties']&&f in e['properties']){e=e['properties'][f];continue;}if(e['items']&&typeof e['items']==='object'){if(/^\d+$/['test'](f)){e=e['items'];continue;}if(e['items']['properties']&&f in e['items']['properties']){e=e['items']['properties'][f];continue;}}if(Array['isArray'](e['oneOf'])||Array['isArray'](e['anyOf'])){const g=e['oneOf']??e['anyOf'];for(const h of g){if(h&&typeof h==='object'&&h['properties']&&f in h['properties']){e=h['properties'][f];break;}}continue;}if(f in e){e=e[f];continue;}return null;}return e;}function resolveSchemaRefs(a,b=new Set()){if(!a||typeof a!=='object')return a;if(Array['isArray'](a))return a['map'](d=>resolveSchemaRefs(d,b));const c={};for(const [d,e]of Object['entries'](a)){if(d==='$ref'&&typeof e==='string'){if(e['startsWith']('#'))c[d]=e;else{const f=loadRefSchema(e,b);f&&Object['assign'](c,resolveSchemaRefs(f,b));}}else typeof e==='object'?c[d]=resolveSchemaRefs(e,b):c[d]=e;}return c;}function loadRefSchema(a,b){if(a['startsWith']('#'))return null;if(b['has'](a))return{'description':'Circular\x20reference\x20to\x20'+a};b['add'](a);try{const c=join(SCHEMAS_DIR,a);if(!existsSync(c))return null;const d=readFileSync(c,'utf-8');return JSON['parse'](d);}catch{return null;}}export function searchSchemas(a){const b=listSchemas(),c=a['toLowerCase']();return b['filter'](d=>{const e=d['name']['toLowerCase']()['includes'](c),f=d['title']?.['toLowerCase']()['includes'](c),g=d['description']?.['toLowerCase']()['includes'](c);return e||f||g;});}export function listOperations(){const a=getSchemaIndex();if(!a)return[];return(a['operations']||[])['filter'](b=>b['name']['startsWith']('onchain_operations_'));}function writeResponseToFile(a,b){try{let c;if(b)c=resolve(process['cwd'](),b);else{!existsSync(WORKSPACE_TMP_DIR)&&mkdirSync(WORKSPACE_TMP_DIR,{'recursive':!![]});const g=Date['now']();c=join(WORKSPACE_TMP_DIR,'schema-'+g+'.json');}const d=dirname(c);!existsSync(d)&&mkdirSync(d,{'recursive':!![]});const f=typeof a==='string'?a:JSON['stringify'](a,null,0x2);return writeFileSync(c,f,'utf-8'),c;}catch(h){return null;}}const INLINE_CHAR_LIMIT=0x20*0x400,AUTO_OVERFLOW_DIR='.wowok/tmp';function unionVariantLabel(a){if(!a||typeof a!=='object')return'variant';const b=a['properties']&&typeof a['properties']==='object'?a['properties']:undefined;if(b)for(const [c,d]of Object['entries'](b)){if(d&&typeof d==='object'&&d['const']!==undefined)return c+'='+String(d['const']);}return typeof a['title']==='string'?a['title']:'variant';}export function buildSchemaSummary(a){const b=[];a&&typeof a['title']==='string'&&b['push']('Title:\x20'+a['title']);const c=a&&typeof a==='object'?a['properties']:undefined;if(c&&typeof c==='object'&&!Array['isArray'](c)){const d=Array['isArray'](a['required'])?a['required']:[],e=Object['keys'](c);b['push']('Top-level\x20fields\x20('+e['length']+',\x20*\x20=\x20required):');for(const f of e['slice'](0x0,0x28)){const g=c[f]??{},h=Array['isArray'](g['type'])?g['type']['join']('|'):g['type']??(g['$ref']?'ref':g['anyOf']||g['oneOf']?'union':'any'),i=d['includes'](f)?'*':'',j=typeof g['description']==='string'&&g['description']['length']>0x0?'\x20—\x20'+g['description']['split']('\x0a')[0x0]['slice'](0x0,0x50):'';b['push']('\x20\x20-\x20'+f+i+':\x20'+h+j);}e['length']>0x28&&b['push']('\x20\x20-\x20...and\x20'+(e['length']-0x28)+'\x20more\x20—\x20use\x20action=\x27get_field\x27\x20with\x20field_path\x20to\x20inspect');}else{if(a&&(Array['isArray'](a['oneOf'])||Array['isArray'](a['anyOf']))){const k=a['oneOf']??a['anyOf'];b['push']('Union\x20of\x20'+k['length']+'\x20variants:');for(const m of k['slice'](0x0,0x28)){const o=m&&typeof m['description']==='string'&&m['description']['length']>0x0?'\x20—\x20'+m['description']['split']('\x0a')[0x0]['slice'](0x0,0x50):'';b['push']('\x20\x20-\x20'+unionVariantLabel(m)+o);}k['length']>0x28&&b['push']('\x20\x20-\x20...and\x20'+(k['length']-0x28)+'\x20more');const l=k['filter'](q=>q&&typeof q==='object'&&q['properties']&&typeof q['properties']==='object');if(l['length']===k['length']&&l['length']>0x0){const q=Object['keys'](l[0x0]['properties'])['filter'](r=>l['every'](s=>Object['prototype']['hasOwnProperty']['call'](s['properties'],r)));b['push'](q['length']>0x0?'Common\x20fields\x20(declared\x20by\x20ALL\x20'+l['length']+'\x20variants):\x20'+q['join'](',\x20')+'.':'No\x20field\x20is\x20declared\x20by\x20all\x20'+l['length']+'\x20variants\x20—\x20each\x20variant\x20takes\x20its\x20own\x20parameters.');}else b['push']('Field\x20names\x20differ\x20per\x20variant\x20—\x20read\x20the\x20variant\x27s\x20own\x20list\x20above.\x20'+'The\x20discriminator\x20(\x22operation\x22\x20and\x20friends)\x20is\x20the\x20only\x20shared\x20key.');for(const r of k['slice'](0x0,0x28)){const s=r&&typeof r==='object'&&r['properties']&&typeof r['properties']==='object'?Object['keys'](r['properties']):[];if(s['length']===0x0)continue;b['push']('\x20\x20\x20\x20'+unionVariantLabel(r)+'\x20fields:\x20'+s['join'](',\x20'));}b['push']('Drill\x20into\x20the\x20variant\x20you\x20need\x20with\x20action=\x27get_field\x27\x20(name\x20+\x20field_path)\x20—\x20the\x20lists\x20above\x20are\x20a\x20summary,\x20not\x20the\x20schema.');}else b['push']('No\x20top-level\x20properties\x20map\x20—\x20use\x20action=\x27get_field\x27\x20with\x20a\x20field_path\x20to\x20inspect\x20this\x20schema.');}return b['join']('\x0a');}export function autoOverflowToFile(a,b){try{const c=JSON['stringify'](a)['length'];if(c<=INLINE_CHAR_LIMIT)return null;const d=process['env']['WOWOK_SCHEMA_TMP_DIR'],e=d?resolve(d):resolve(process['cwd'](),AUTO_OVERFLOW_DIR);!existsSync(e)&&mkdirSync(e,{'recursive':!![]});const f=b['replace'](/[^a-zA-Z0-9_-]/g,'_'),g=f+'.schema.json',h=join(e,g);return writeFileSync(h,JSON['stringify'](a,null,0x2),'utf-8'),{'absolute_path':h,'relative_path':d?h:join(AUTO_OVERFLOW_DIR,g),'bytes':c,'summary':buildSchemaSummary(a)};}catch{return null;}}export function processSchemaQuery(a){const {action:b,name:c,query:d,field_path:f,template:g,output_file:h,object_type:i,params:j}=a;if(b==='get_guard_templates'){const k=getGuardTemplates(g);if(!k)return{'success':![],'action':b,'data':null,'message':g?'Guard\x20template\x20\x27'+g+'\x27\x20not\x20found.\x20Omit\x20\x27template\x27\x20to\x20list\x20all\x20available\x20templates.':'Guard\x20templates\x20file\x20not\x20found.\x20Ensure\x20scripts/guard-templates.json\x20exists.','suggestions':['Omit\x20\x27template\x27\x20to\x20list\x20all\x20available\x20templates.','Available\x20template\x20names:\x20signer_verification,\x20progress_node_check,\x20order_owner_verification,\x20service_belonging_check,\x20reward_not_claimed,\x20combined_reward_guard']};if(h){const l=writeResponseToFile(k,h);if(l)return{'success':!![],'action':b,'data':null,'message':'Guard\x20template'+(g?'\x20\x27'+g+'\x27':'s')+'\x20written\x20to\x20file:\x20'+l,'output_file_path':l,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+l]};}return{'success':!![],'action':b,'data':k,'message':g?'Retrieved\x20Guard\x20template:\x20'+g:'Retrieved\x20'+(Array['isArray'](k['templates'])?k['templates']['length']:0x0)+'\x20Guard\x20templates'};}if(b==='get_templates'){if(!g){const p=a435a(i),q=getTemplateCounts(),r={'total':p['length'],'filter':i??null,'counts_by_object_type':q,'templates':p};if(h){const s=writeResponseToFile(r,h);if(s)return{'success':!![],'action':b,'data':null,'message':p['length']+'\x20templates\x20written\x20to\x20file:\x20'+s,'output_file_path':s,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+s]};}return{'success':!![],'action':b,'data':r,'message':p['length']+'\x20template(s)'+(i?'\x20for\x20object_type=\x27'+i+'\x27':'')+'\x20'+('(total\x20registry:\x20'+Object['values'](q)['reduce']((t,u)=>t+u,0x0)+'\x20across\x20'+TEMPLATE_OBJECT_TYPES['length']+'\x20object\x20types).\x20')+'Provide\x20\x27template\x27\x20(id)\x20for\x20full\x20detail;\x20add\x20\x27params\x27\x20(JSON\x20string)\x20to\x20instantiate.'};}if(!j){const t=getTemplateDetail(g);if(!t)return{'success':![],'action':b,'data':null,'message':'Template\x20\x27'+g+'\x27\x20not\x20found\x20in\x20the\x20unified\x20registry.','suggestions':['Omit\x20\x27template\x27\x20to\x20list\x20all\x20template\x20metadata\x20(id\x20+\x20object_type\x20+\x20parameters).','Filter\x20by\x20object_type:\x20'+TEMPLATE_OBJECT_TYPES['join'](',\x20')]};if(h){const u=writeResponseToFile(t,h);if(u)return{'success':!![],'action':b,'data':null,'message':'Template\x20\x27'+g+'\x27\x20detail\x20written\x20to\x20file:\x20'+u,'output_file_path':u,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+u]};}return{'success':!![],'action':b,'data':t,'message':'Template\x20\x27'+g+'\x27\x20('+t['object_type']+',\x20'+(t['instantiable']?'instantiable':'guidance-only')+').\x20'+'To\x20instantiate,\x20call\x20again\x20with\x20\x27params\x27\x20=\x20JSON\x20object\x20of\x20the\x20declared\x20parameters.'};}let m;try{const v=JSON['parse'](j);if(!v||typeof v!=='object'||Array['isArray'](v))return{'success':![],'action':b,'data':null,'message':'\x27params\x27\x20must\x20be\x20a\x20JSON\x20object\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27),\x20got\x20'+(Array['isArray'](v)?'array':typeof v)+'.'};m=v;}catch(w){return{'success':![],'action':b,'data':null,'message':'Failed\x20to\x20parse\x20\x27params\x27\x20as\x20JSON:\x20'+(w instanceof Error?w['message']:String(w)),'suggestions':['Example:\x20params=\x27{\x22whitelist\x22:[\x220xabc...\x22]}\x27']};}const n=instantiateTemplate(g,m);if(!n['ok'])return{'success':![],'action':b,'data':n['guidance']!==undefined?{'guidance':n['guidance']}:null,'message':'Instantiation\x20failed\x20for\x20\x27'+g+'\x27:\x20'+n['error'],'suggestions':n['missing_params']?['Missing\x20required\x20params:\x20'+n['missing_params']['join'](',\x20'),'Call\x20with\x20\x27template\x27\x20only\x20(no\x20\x27params\x27)\x20to\x20see\x20full\x20parameter\x20declarations.']:['Call\x20with\x20\x27template\x27\x20only\x20(no\x20\x27params\x27)\x20to\x20see\x20full\x20parameter\x20declarations.']};const o={'object_type':n['object_type'],'template_id':n['template_id'],'body':n['body'],...n['notes']?{'notes':n['notes']}:{}};if(h){const x=writeResponseToFile(o,h);if(x)return{'success':!![],'action':b,'data':null,'message':'Instantiated\x20template\x20\x27'+g+'\x27\x20written\x20to\x20file:\x20'+x,'output_file_path':x,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+x]};}return{'success':!![],'action':b,'data':o,'message':'Instantiated\x20\x27'+g+'\x27\x20('+n['object_type']+').\x20'+'Review\x20the\x20body\x20against\x20the\x20onchain_operations\x20schema\x20before\x20submitting.'};}if(b==='get_tool_reference'){if(c){const z=getToolReference(c);if(!z)return{'success':![],'action':b,'data':null,'message':'Tool\x20\x27'+c+'\x27\x20not\x20found\x20in\x20the\x20tool\x20reference.','suggestions':['Omit\x20\x27name\x27\x20to\x20list\x20all\x20tools.','Available\x20tools:\x20'+TOOLS_REFERENCE['map'](B=>B['name'])['join'](',\x20')]};const A=getToolSequence(c);return{'success':!![],'action':b,'data':{'tool':z,'call_sequence':A??null},'message':'Retrieved\x20tool\x20reference:\x20'+c};}if(d){const B=searchToolReference(d);return{'success':!![],'action':b,'data':{'tools':B,'count':B['length']},'message':'Found\x20'+B['length']+'\x20tool(s)\x20matching\x20\x27'+d+'\x27','suggestions':B['length']===0x0?['Try\x20a\x20broader\x20keyword\x20(e.g.\x20\x27onchain\x27,\x20\x27guard\x27,\x20\x27schema\x27),\x20or\x20omit\x20\x27query\x27\x20to\x20list\x20all\x20tools.']:undefined};}const y=TOOLS_REFERENCE['map'](C=>({'name':C['name'],'summary':C['summary'],'actions':C['actions']??[],'notes':C['notes']??[]}));return{'success':!![],'action':b,'data':{'tools':y,'count':y['length']},'message':'Retrieved\x20reference\x20for\x20'+y['length']+'\x20MCP\x20tools.\x20Pass\x20name=\x27<tool>\x27\x20for\x20full\x20detail\x20(params,\x20prerequisites,\x20follow-ups).'};}if(b==='get_guard_design_patterns'){if(c){const D=getGuardDesignPattern(c);if(!D)return{'success':![],'action':b,'data':null,'message':'Guard\x20design\x20pattern\x20\x27'+c+'\x27\x20not\x20found.','suggestions':['Omit\x20\x27name\x27\x20to\x20list\x20the\x20full\x20catalog.','Available\x20pattern\x20ids:\x20'+GUARD_DESIGN_PATTERNS['map'](E=>E['id'])['join'](',\x20')]};return{'success':!![],'action':b,'data':{'pattern':D},'message':'Retrieved\x20Guard\x20design\x20pattern:\x20'+c};}if(d){const E=GUARD_DESIGN_PATTERNS['filter'](G=>G['host']===d),F=E['length']>0x0?E:GUARD_DESIGN_PATTERNS['filter'](G=>G['business_requirement']['toLowerCase']()['includes'](d['toLowerCase']())||G['logic_summary']['toLowerCase']()['includes'](d['toLowerCase']()));return{'success':!![],'action':b,'data':{'patterns':F,'count':F['length'],'filtered_by':E['length']>0x0?'host':'keyword','schema_notes':GUARD_SCHEMA_NOTES},'message':'Found\x20'+F['length']+'\x20Guard\x20design\x20pattern(s)\x20matching\x20\x27'+d+'\x27','suggestions':F['length']===0x0?['Filter\x20by\x20host:\x20service_buy_guard,\x20service_allocator_guard,\x20machine_forward,\x20progress_submission,\x20reward_claim,\x20repository_write,\x20arbitration_usage,\x20arbitration_voting,\x20gen_passport']:undefined};}const C=GUARD_DESIGN_PATTERNS['map'](G=>({'id':G['id'],'business_requirement':G['business_requirement'],'host':G['host'],'data_source':G['data_source'],'verifier_level':G['verifier_level'],'logic_summary':G['logic_summary'],'key_queries':G['key_queries'],'notes':G['notes']??[]}));return{'success':!![],'action':b,'data':{'patterns':C,'count':C['length'],'version':GUARD_DESIGN_PATTERNS_VERSION,'schema_notes':GUARD_SCHEMA_NOTES},'message':'Retrieved\x20'+C['length']+'\x20Guard\x20design\x20patterns.\x20Pass\x20name=\x27<pattern_id>\x27\x20for\x20full\x20detail\x20(witness\x20types,\x20mitigated\x20risks,\x20industries).'};}if(b==='get_safety_rules')return{'success':!![],'action':b,'data':{'version':SAFETY_RULES_VERSION,'object_reuse_rules':OBJECT_REUSE_RULES,'create_vs_modify_pattern':CREATE_VS_MODIFY_PATTERN,'immutability_rules':IMMUTABILITY_RULES,'protocol_slot_rules':PROTOCOL_SLOT_RULES,'operation_type_classification':OPERATION_TYPE_CLASSIFICATION,'operation_class_meta':OPERATION_CLASS_META,'naming_conventions':NAMING_CONVENTIONS},'message':'Retrieved\x20safety\x20rule\x20tables\x20(reuse\x20/\x20immutability\x20/\x20protocol\x20slots\x20/\x20operation\x20classification\x20/\x20naming).\x20'+'Key\x20points:\x20prefer\x20REUSING\x20existing\x20objects\x20(string\x20reference\x20=\x20reuse,\x20object\x20shape\x20=\x20create);\x20'+'Machine\x20publish\x20locks\x20nodes/pairs/forwards,\x20Service\x20publish\x20locks\x20machine/order_allocators/arbitrations\x20(sales\x20stays\x20mutable);\x20'+'Guard\x20is\x20CREATE-only\x20immutable;\x20on-chain\x20writes\x20require\x20explicit\x20user\x20confirmation;\x20'+'Guards\x20bound\x20on\x20machine\x20forwards\x20MUST\x20declare\x20protocol\x20slot\x20254\x20(task\x20binding),\x20and\x20every\x20allocator\x20{GuardIdentifier:N}\x20leg\x20MUST\x20name\x20a\x20declared\x20b_submission\x20Address\x20slot.'};if(!areSchemasAvailable())return{'success':![],'action':b,'data':null,'message':'Schema\x20files\x20are\x20not\x20available.\x20Please\x20run\x20\x27npm\x20run\x20generate:schemas\x27\x20first.','suggestions':['Run\x20\x27npm\x20run\x20generate:schemas\x27\x20to\x20generate\x20schema\x20files','Ensure\x20the\x20dist/schemas\x20directory\x20exists']};switch(b){case'list':{const G=listSchemas();return{'success':!![],'action':b,'data':G,'message':'Found\x20'+G['length']+'\x20available\x20schemas'};}case'get':{if(!c)return{'success':![],'action':b,'data':null,'message':'Schema\x20name\x20is\x20required\x20for\x20\x27get\x27\x20action','suggestions':['Provide\x20a\x20schema\x20name','Use\x20\x27list\x27\x20action\x20to\x20see\x20available\x20schemas']};const H=getSchema(c);if(!H){const J=searchSchemas(c)['slice'](0x0,0x5);return{'success':![],'action':b,'data':null,'message':'Schema\x20\x27'+c+'\x27\x20not\x20found','suggestions':J['length']>0x0?J['map'](K=>'Did\x20you\x20mean:\x20'+K['name']+'?'):['Use\x20\x27list\x27\x20action\x20to\x20see\x20available\x20schemas']};}if(h){const K=writeResponseToFile(H,h);if(K)return{'success':!![],'action':b,'data':null,'message':'Schema\x20\x27'+c+'\x27\x20written\x20to\x20file:\x20'+K,'output_file_path':K,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+K]};}const I=autoOverflowToFile(H,c);if(I)return{'success':!![],'action':b,'data':null,'message':'Schema\x20\x27'+c+'\x27\x20is\x20large\x20('+Math['round'](I['bytes']/0x400)+'\x20KB)\x20—\x20'+'written\x20to\x20file\x20instead\x20of\x20inlining\x20to\x20protect\x20your\x20context.','output_file_path':I['absolute_path'],'inline_summary':I['summary'],'suggestions':['Read\x20the\x20full\x20file\x20with\x20the\x20Read\x20tool:\x20'+I['absolute_path'],'If\x20the\x20sandbox\x20blocks\x20that\x20path,\x20resolve\x20the\x20relative\x20path\x20\x27'+I['relative_path']+'\x27\x20against\x20the\x20workspace\x20root\x20and\x20read\x20that.','Without\x20file\x20access,\x20query\x20specific\x20fields\x20via\x20action=\x27get_field\x27\x20with\x20name=\x27'+c+'\x27\x20and\x20a\x20field_path\x20from\x20the\x20summary\x20below.']};return{'success':!![],'action':b,'data':H,'message':'Retrieved\x20schema:\x20'+c};}case'get_field':{if(!c||!f)return{'success':![],'action':b,'data':null,'message':'Both\x20\x27name\x27\x20and\x20\x27field_path\x27\x20are\x20required\x20for\x20\x27get_field\x27\x20action','suggestions':['Example:\x20{action:\x20\x27get_field\x27,\x20name:\x20\x27onchain_operations_machine\x27,\x20field_path:\x20\x27data.node\x27}','Use\x20\x27get\x27\x20action\x20to\x20retrieve\x20the\x20full\x20schema']};const L=getSchemaField(c,f);if(!L)return{'success':![],'action':b,'data':null,'message':'Field\x20path\x20\x27'+f+'\x27\x20not\x20found\x20in\x20schema\x20\x27'+c+'\x27','suggestions':['Check\x20the\x20field\x20path\x20(dot-separated,\x20e.g.\x20\x27data.node\x27)','Use\x20\x27get\x27\x20action\x20to\x20see\x20the\x20full\x20schema\x20structure']};return{'success':!![],'action':b,'data':L,'message':'Retrieved\x20field\x20\x27'+f+'\x27\x20from\x20schema\x20\x27'+c+'\x27'};}case'search':{if(!d)return{'success':![],'action':b,'data':null,'message':'Search\x20query\x20is\x20required\x20for\x20\x27search\x27\x20action'};const M=searchSchemas(d);return{'success':!![],'action':b,'data':M,'message':'Found\x20'+M['length']+'\x20schemas\x20matching\x20\x27'+d+'\x27'};}case'list_operations':{const N=listOperations();return{'success':!![],'action':b,'data':N,'message':'Found\x20'+N['length']+'\x20on-chain\x20operations'};}case'get_guard_queries':{const O=d?.['trim']()['toLowerCase'](),P=R=>({'id':R['id'],'name':R['name'],'objectType':ObjectType[R['objectType']]??String(R['objectType']),'returnType':ValueType[R['return']]??String(R['return'])});if(O){const R=GUARDQUERY['filter'](S=>S['name']['toLowerCase']()['includes'](O)||S['description']?.['toLowerCase']()['includes'](O)||String(S['id'])===O)['map'](S=>({...P(S),'description':S['description']}));return{'success':!![],'action':b,'data':R,'message':'Found\x20'+R['length']+'\x20GUARDQUERY\x20entries\x20matching\x20\x27'+d+'\x27\x20'+('(of\x20'+GUARDQUERY['length']+'\x20total).\x20Use\x20names,\x20not\x20numeric\x20ids,\x20in\x20Guard\x20trees\x20—\x20')+'names\x20fail\x20loudly\x20at\x20validation\x20when\x20wrong;\x20a\x20wrong-but-existing\x20id\x20silently\x20checks\x20a\x20different\x20field.'};}if(h){const S=GUARDQUERY['map'](U=>({...P(U),'description':U['description']})),T=writeResponseToFile(S,h);if(T)return{'success':!![],'action':b,'data':null,'message':'Full\x20GUARDQUERY\x20catalog\x20('+S['length']+'\x20entries)\x20written\x20to\x20file:\x20'+T,'output_file_path':T,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+T]};}const Q=GUARDQUERY['map'](P);return{'success':!![],'action':b,'data':Q,'message':'GUARDQUERY\x20catalog:\x20'+Q['length']+'\x20entries\x20(compact\x20form\x20—\x20id,\x20name,\x20objectType,\x20returnType).\x20'+'Add\x20query=\x27<keyword>\x27\x20for\x20full\x20entries\x20with\x20descriptions,\x20or\x20output_file\x20to\x20dump\x20all\x20details\x20to\x20a\x20file.\x20'+'Prefer\x20NAME\x20references\x20in\x20Guard\x20trees;\x20a\x20numeric\x20id\x20is\x20resolved\x20verbatim\x20and\x20a\x20wrong-but-existing\x20id\x20'+'silently\x20checks\x20a\x20different\x20field.'};}case'get_output':{if(!c)return{'success':![],'action':b,'data':null,'message':'Tool\x20name\x20is\x20required\x20for\x20\x27get_output\x27\x20action','suggestions':['Provide\x20a\x20tool\x20name','Use\x20\x27list\x27\x20action\x20to\x20see\x20available\x20tools\x20and\x20their\x20outputPath']};const U=getOutputSchema(c);if(!U){const W=listSchemas(),X=W['find'](Z=>Z['name']===c);if(X)return{'success':![],'action':b,'data':null,'message':'Tool\x20\x27'+c+'\x27\x20exists\x20but\x20has\x20no\x20output\x20schema\x20file.\x20The\x20tool\x20may\x20not\x20declare\x20an\x20outputSchema,\x20or\x20the\x20schema\x20file\x20was\x20not\x20generated.','suggestions':['Use\x20\x27get\x27\x20action\x20with\x20name=\x27'+c+'\x27\x20to\x20retrieve\x20its\x20input\x20schema']};const Y=searchSchemas(c)['slice'](0x0,0x5);return{'success':![],'action':b,'data':null,'message':'Tool\x20\x27'+c+'\x27\x20not\x20found','suggestions':Y['length']>0x0?Y['map'](Z=>'Did\x20you\x20mean:\x20'+Z['name']+'?'):['Use\x20\x27list\x27\x20action\x20to\x20see\x20available\x20tools']};}if(h){const Z=writeResponseToFile(U,h);if(Z)return{'success':!![],'action':b,'data':null,'message':'Output\x20schema\x20\x27'+c+'\x27\x20written\x20to\x20file:\x20'+Z,'output_file_path':Z,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+Z]};}const V=autoOverflowToFile(U,c);if(V)return{'success':!![],'action':b,'data':null,'message':'Output\x20schema\x20\x27'+c+'\x27\x20is\x20large\x20('+Math['round'](V['bytes']/0x400)+'\x20KB)\x20—\x20'+'written\x20to\x20file\x20instead\x20of\x20inlining\x20to\x20protect\x20your\x20context.','output_file_path':V['absolute_path'],'inline_summary':V['summary'],'suggestions':['Read\x20the\x20full\x20file\x20with\x20the\x20Read\x20tool:\x20'+V['absolute_path'],'If\x20the\x20sandbox\x20blocks\x20that\x20path,\x20resolve\x20the\x20relative\x20path\x20\x27'+V['relative_path']+'\x27\x20against\x20the\x20workspace\x20root\x20and\x20read\x20that.','Without\x20file\x20access,\x20query\x20specific\x20fields\x20via\x20action=\x27get_field\x27\x20with\x20name=\x27'+c+'\x27\x20and\x20a\x20field_path\x20from\x20the\x20summary\x20below.']};return{'success':!![],'action':b,'data':U,'message':'Retrieved\x20output\x20schema:\x20'+c};}default:return{'success':![],'action':b,'data':null,'message':'Unknown\x20action:\x20'+b,'suggestions':['Use\x20\x27list\x27,\x20\x27get\x27,\x20\x27get_field\x27,\x20\x27get_output\x27,\x20\x27search\x27,\x20\x27list_operations\x27,\x20\x27get_guard_templates\x27,\x20\x27get_tool_reference\x27,\x20\x27get_guard_design_patterns\x27,\x20\x27get_safety_rules\x27,\x20\x27get_templates\x27,\x20or\x20\x27analyze_guard_semantics\x27']};}}const GUARD_SEMANTICS_READING_CHECKLIST=['WHO\x20can\x20satisfy\x20this\x20Guard\x20(identity:\x20Signer\x20bindings,\x20Entity\x20membership,\x20allowlists)?','WHEN\x20can\x20it\x20be\x20satisfied\x20(time:\x20Clock\x20comparisons,\x20deadlines,\x20windows)?','WHAT\x20evidence\x20must\x20the\x20caller\x20submit\x20(b_submission\x20table\x20entries\x20—\x20Payment/Order/Proof\x20objects)?','WHICH\x20on-chain\x20data\x20does\x20it\x20read,\x20and\x20can\x20that\x20data\x20change\x20(Repository\x20entries\x20are\x20MUTABLE\x20—\x20who\x20controls\x20the\x20writes)?','WHAT\x20does\x20the\x20counterparty\x20gain/lose\x20in\x20each\x20branch\x20of\x20the\x20logic\x20tree?','ARE\x20there\x20error-level\x20diagnostics\x20or\x20critical\x20risks\x20(they\x20block\x20or\x20endanger\x20execution)?'];export async function analyzeGuardSemantics(a){const b=await lintGuard(a,{'auto_fix':![]}),c={'root':a['root'],'table':(a['table']??[])['map'](k=>({'identifier':k['identifier'],'name':k['name'],'value_type':k['value_type']??'Address','b_submission':k['b_submission']??![],'value':k['value']})),'guardName':a['description']??null,'rely':a['rely']??null},d=renderGuardTreeIndented(c),e=renderGuardMermaid(a['root']),f=new Set(),g=[];let h=![],i=![];walkGuardTree(a['root'],k=>{if(k['type']==='context'){if(k['context']==='Clock')h=!![];if(k['context']==='Signer')i=!![];}if(k['type']==='query'&&k['query']!==undefined&&k['query']!==null){if(typeof k['query']==='number'){const l=getGuardQueryByIdOrName(k['query']);if(l)f['add'](l['id']);else g['push'](k['query']);}else{const m=getGuardQueryByIdOrName(k['query']);if(m)f['add'](m['id']);else g['push'](k['query']);}}});const j={'submission_requirements':(a['table']??[])['filter'](k=>k['b_submission']===!![])['map'](k=>({'identifier':k['identifier'],'value_type':k['value_type'],'object_type':k['object_type'],'name':k['name']})),'data_sources':(a['table']??[])['filter'](k=>k['b_submission']!==!![])['map'](k=>({'identifier':k['identifier'],'kind':k['is_system_address']?'system_address':k['object_type']?'object':'fixed_value','value_type':k['value_type'],'object_type':k['object_type'],'name':k['name'],'is_mutable_onchain':k['object_type']==='Repository'})),'query_dependencies':[...f]['sort']((k,l)=>k-l),'unresolved_queries':g,'has_time_conditions':h,'has_signer_constraints':i,'has_rely_composition':Array['isArray'](a['rely']?.['guards'])&&a['rely']['guards']['length']>0x0,'reading_checklist':GUARD_SEMANTICS_READING_CHECKLIST};return{'render':{'tree_indented':d,'mermaid':e},'lint':b,'party_evaluation':j};}export{formatLintResult};
1
+ import{readFileSync,existsSync,writeFileSync,mkdirSync}from'fs';import{resolve,join,dirname}from'path';import{fileURLToPath}from'url';import{GUARDQUERY,ObjectType,ValueType}from'@wowok/wowok';import{TOOLS_REFERENCE,getToolReference,searchToolReference,getToolSequence}from'../knowledge/tools-reference.js';import{GUARD_DESIGN_PATTERNS,getGuardDesignPattern,GUARD_DESIGN_PATTERNS_VERSION,GUARD_SCHEMA_NOTES}from'../knowledge/guard-design-patterns.js';import{OBJECT_REUSE_RULES,CREATE_VS_MODIFY_PATTERN,IMMUTABILITY_RULES,PROTOCOL_SLOT_RULES,OPERATION_TYPE_CLASSIFICATION,OPERATION_CLASS_META,NAMING_CONVENTIONS,SAFETY_RULES_VERSION}from'../knowledge/safety-rules.js';import{listTemplates as a444a,getTemplateDetail,instantiateTemplate,getTemplateCounts,TEMPLATE_OBJECT_TYPES}from'../knowledge/template-registry.js';import{lintGuard,formatLintResult}from'../knowledge/guard-lint.js';import{renderGuardTreeIndented,renderGuardMermaid,walkGuardTree}from'../knowledge/guard-render.js';import{getGuardQueryByIdOrName}from'../schema/utils/guard-query-utils.js';const __filename=fileURLToPath(import.meta.url),__dirname=fileURLToPath(new URL('.',import.meta.url)),SCHEMAS_DIR=resolve(__dirname,'../../dist/schemas'),GUARD_TEMPLATES_PATH_SCRIPTS=resolve(__dirname,'../../scripts/guard-templates.json'),GUARD_TEMPLATES_PATH_DIST=resolve(__dirname,'../../dist/schemas/guard-templates.json'),GUARD_TEMPLATES_PATH=existsSync(GUARD_TEMPLATES_PATH_SCRIPTS)?GUARD_TEMPLATES_PATH_SCRIPTS:GUARD_TEMPLATES_PATH_DIST,WORKSPACE_TMP_DIR=resolve(process['cwd'](),'.trae','tmp');export function areSchemasAvailable(){return existsSync(SCHEMAS_DIR)&&existsSync(join(SCHEMAS_DIR,'index.json'));}export function getSchemaIndex(){try{const a=join(SCHEMAS_DIR,'index.json');if(!existsSync(a))return null;const b=readFileSync(a,'utf-8');return JSON['parse'](b);}catch{return null;}}export function listSchemas(){const a=getSchemaIndex();if(!a)return[];return[...a['tools']||[],...a['operations']||[]];}export function getSchema(a){try{let b=join(SCHEMAS_DIR,a+'.schema.json');!existsSync(b)&&(b=join(SCHEMAS_DIR,a+'.json'));if(!existsSync(b))return null;const c=readFileSync(b,'utf-8'),d=JSON['parse'](c);return resolveSchemaRefs(d);}catch{return null;}}export function getOutputSchema(a){try{const b=join(SCHEMAS_DIR,a+'.output.json');if(!existsSync(b))return null;const c=readFileSync(b,'utf-8'),d=JSON['parse'](c);return resolveSchemaRefs(d);}catch{return null;}}export function getGuardTemplates(a){try{if(!existsSync(GUARD_TEMPLATES_PATH))return null;const b=readFileSync(GUARD_TEMPLATES_PATH,'utf-8'),c=JSON['parse'](b);if(!a)return{'version':c['version'],'description':c['description'],'templates':(c['templates']||[])['map'](e=>({'name':e['name'],'title':e['title'],'description':e['description'],'use_case':e['use_case']})),'query_reference':c['query_reference'],'node_return_types':c['node_return_types']};const d=(c['templates']||[])['find'](e=>e['name']===a);if(!d)return null;return d;}catch{return null;}}export function getSchemaField(a,b){const c=getSchema(a);if(!c)return null;const d=b['split']('.')['filter'](Boolean);let e=c;for(const f of d){if(!e||typeof e!=='object')return null;if(e['properties']&&f in e['properties']){e=e['properties'][f];continue;}if(e['items']&&typeof e['items']==='object'){if(/^\d+$/['test'](f)){e=e['items'];continue;}if(e['items']['properties']&&f in e['items']['properties']){e=e['items']['properties'][f];continue;}}if(Array['isArray'](e['oneOf'])||Array['isArray'](e['anyOf'])){const g=e['oneOf']??e['anyOf'];for(const h of g){if(h&&typeof h==='object'&&h['properties']&&f in h['properties']){e=h['properties'][f];break;}}continue;}if(f in e){e=e[f];continue;}return null;}return e;}function resolveSchemaRefs(a,b=new Set()){if(!a||typeof a!=='object')return a;if(Array['isArray'](a))return a['map'](d=>resolveSchemaRefs(d,b));const c={};for(const [d,e]of Object['entries'](a)){if(d==='$ref'&&typeof e==='string'){if(e['startsWith']('#'))c[d]=e;else{const f=loadRefSchema(e,b);f&&Object['assign'](c,resolveSchemaRefs(f,b));}}else typeof e==='object'?c[d]=resolveSchemaRefs(e,b):c[d]=e;}return c;}function loadRefSchema(a,b){if(a['startsWith']('#'))return null;if(b['has'](a))return{'description':'Circular\x20reference\x20to\x20'+a};b['add'](a);try{const c=join(SCHEMAS_DIR,a);if(!existsSync(c))return null;const d=readFileSync(c,'utf-8');return JSON['parse'](d);}catch{return null;}}export function searchSchemas(a){const b=listSchemas(),c=a['toLowerCase']();return b['filter'](d=>{const e=d['name']['toLowerCase']()['includes'](c),f=d['title']?.['toLowerCase']()['includes'](c),g=d['description']?.['toLowerCase']()['includes'](c);return e||f||g;});}export function listOperations(){const a=getSchemaIndex();if(!a)return[];return(a['operations']||[])['filter'](b=>b['name']['startsWith']('onchain_operations_'));}function writeResponseToFile(a,b){try{let c;if(b)c=resolve(process['cwd'](),b);else{!existsSync(WORKSPACE_TMP_DIR)&&mkdirSync(WORKSPACE_TMP_DIR,{'recursive':!![]});const g=Date['now']();c=join(WORKSPACE_TMP_DIR,'schema-'+g+'.json');}const d=dirname(c);!existsSync(d)&&mkdirSync(d,{'recursive':!![]});const f=typeof a==='string'?a:JSON['stringify'](a,null,0x2);return writeFileSync(c,f,'utf-8'),c;}catch(h){return null;}}const INLINE_CHAR_LIMIT=0x20*0x400,AUTO_OVERFLOW_DIR='.wowok/tmp';function unionVariantLabel(a){if(!a||typeof a!=='object')return'variant';const b=a['properties']&&typeof a['properties']==='object'?a['properties']:undefined;if(b)for(const [c,d]of Object['entries'](b)){if(d&&typeof d==='object'&&d['const']!==undefined)return c+'='+String(d['const']);}return typeof a['title']==='string'?a['title']:'variant';}export function buildSchemaSummary(a){const b=[];a&&typeof a['title']==='string'&&b['push']('Title:\x20'+a['title']);const c=a&&typeof a==='object'?a['properties']:undefined;if(c&&typeof c==='object'&&!Array['isArray'](c)){const d=Array['isArray'](a['required'])?a['required']:[],e=Object['keys'](c);b['push']('Top-level\x20fields\x20('+e['length']+',\x20*\x20=\x20required):');for(const f of e['slice'](0x0,0x28)){const g=c[f]??{},h=Array['isArray'](g['type'])?g['type']['join']('|'):g['type']??(g['$ref']?'ref':g['anyOf']||g['oneOf']?'union':'any'),i=d['includes'](f)?'*':'',j=typeof g['description']==='string'&&g['description']['length']>0x0?'\x20—\x20'+g['description']['split']('\x0a')[0x0]['slice'](0x0,0x50):'';b['push']('\x20\x20-\x20'+f+i+':\x20'+h+j);}e['length']>0x28&&b['push']('\x20\x20-\x20...and\x20'+(e['length']-0x28)+'\x20more\x20—\x20use\x20action=\x27get_field\x27\x20with\x20field_path\x20to\x20inspect');}else{if(a&&(Array['isArray'](a['oneOf'])||Array['isArray'](a['anyOf']))){const k=a['oneOf']??a['anyOf'];b['push']('Union\x20of\x20'+k['length']+'\x20variants:');for(const m of k['slice'](0x0,0x28)){const o=m&&typeof m['description']==='string'&&m['description']['length']>0x0?'\x20—\x20'+m['description']['split']('\x0a')[0x0]['slice'](0x0,0x50):'';b['push']('\x20\x20-\x20'+unionVariantLabel(m)+o);}k['length']>0x28&&b['push']('\x20\x20-\x20...and\x20'+(k['length']-0x28)+'\x20more');const l=k['filter'](q=>q&&typeof q==='object'&&q['properties']&&typeof q['properties']==='object');if(l['length']===k['length']&&l['length']>0x0){const q=Object['keys'](l[0x0]['properties'])['filter'](r=>l['every'](s=>Object['prototype']['hasOwnProperty']['call'](s['properties'],r)));b['push'](q['length']>0x0?'Common\x20fields\x20(declared\x20by\x20ALL\x20'+l['length']+'\x20variants):\x20'+q['join'](',\x20')+'.':'No\x20field\x20is\x20declared\x20by\x20all\x20'+l['length']+'\x20variants\x20—\x20each\x20variant\x20takes\x20its\x20own\x20parameters.');}else b['push']('Field\x20names\x20differ\x20per\x20variant\x20—\x20read\x20the\x20variant\x27s\x20own\x20list\x20above.\x20'+'The\x20discriminator\x20(\x22operation\x22\x20and\x20friends)\x20is\x20the\x20only\x20shared\x20key.');for(const r of k['slice'](0x0,0x28)){const s=r&&typeof r==='object'&&r['properties']&&typeof r['properties']==='object'?Object['keys'](r['properties']):[];if(s['length']===0x0)continue;b['push']('\x20\x20\x20\x20'+unionVariantLabel(r)+'\x20fields:\x20'+s['join'](',\x20'));}b['push']('Drill\x20into\x20the\x20variant\x20you\x20need\x20with\x20action=\x27get_field\x27\x20(name\x20+\x20field_path)\x20—\x20the\x20lists\x20above\x20are\x20a\x20summary,\x20not\x20the\x20schema.');}else b['push']('No\x20top-level\x20properties\x20map\x20—\x20use\x20action=\x27get_field\x27\x20with\x20a\x20field_path\x20to\x20inspect\x20this\x20schema.');}return b['join']('\x0a');}export function autoOverflowToFile(a,b){try{const c=JSON['stringify'](a)['length'];if(c<=INLINE_CHAR_LIMIT)return null;const d=process['env']['WOWOK_SCHEMA_TMP_DIR'],e=d?resolve(d):resolve(process['cwd'](),AUTO_OVERFLOW_DIR);!existsSync(e)&&mkdirSync(e,{'recursive':!![]});const f=b['replace'](/[^a-zA-Z0-9_-]/g,'_'),g=f+'.schema.json',h=join(e,g);return writeFileSync(h,JSON['stringify'](a,null,0x2),'utf-8'),{'absolute_path':h,'relative_path':d?h:join(AUTO_OVERFLOW_DIR,g),'bytes':c,'summary':buildSchemaSummary(a)};}catch{return null;}}export function processSchemaQuery(a){const {action:b,name:c,query:d,field_path:f,template:g,output_file:h,object_type:i,params:j}=a;if(b==='get_guard_templates'){const k=getGuardTemplates(g);if(!k)return{'success':![],'action':b,'data':null,'message':g?'Guard\x20template\x20\x27'+g+'\x27\x20not\x20found.\x20Omit\x20\x27template\x27\x20to\x20list\x20all\x20available\x20templates.':'Guard\x20templates\x20file\x20not\x20found.\x20Ensure\x20scripts/guard-templates.json\x20exists.','suggestions':['Omit\x20\x27template\x27\x20to\x20list\x20all\x20available\x20templates.','Available\x20template\x20names:\x20signer_verification,\x20progress_node_check,\x20order_owner_verification,\x20service_belonging_check,\x20reward_not_claimed,\x20combined_reward_guard']};if(h){const l=writeResponseToFile(k,h);if(l)return{'success':!![],'action':b,'data':null,'message':'Guard\x20template'+(g?'\x20\x27'+g+'\x27':'s')+'\x20written\x20to\x20file:\x20'+l,'output_file_path':l,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+l]};}return{'success':!![],'action':b,'data':k,'message':g?'Retrieved\x20Guard\x20template:\x20'+g:'Retrieved\x20'+(Array['isArray'](k['templates'])?k['templates']['length']:0x0)+'\x20Guard\x20templates'};}if(b==='get_templates'){if(!g){const p=a444a(i),q=getTemplateCounts(),r={'total':p['length'],'filter':i??null,'counts_by_object_type':q,'templates':p};if(h){const s=writeResponseToFile(r,h);if(s)return{'success':!![],'action':b,'data':null,'message':p['length']+'\x20templates\x20written\x20to\x20file:\x20'+s,'output_file_path':s,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+s]};}return{'success':!![],'action':b,'data':r,'message':p['length']+'\x20template(s)'+(i?'\x20for\x20object_type=\x27'+i+'\x27':'')+'\x20'+('(total\x20registry:\x20'+Object['values'](q)['reduce']((t,u)=>t+u,0x0)+'\x20across\x20'+TEMPLATE_OBJECT_TYPES['length']+'\x20object\x20types).\x20')+'Provide\x20\x27template\x27\x20(id)\x20for\x20full\x20detail;\x20add\x20\x27params\x27\x20(JSON\x20string)\x20to\x20instantiate.'};}if(!j){const t=getTemplateDetail(g);if(!t)return{'success':![],'action':b,'data':null,'message':'Template\x20\x27'+g+'\x27\x20not\x20found\x20in\x20the\x20unified\x20registry.','suggestions':['Omit\x20\x27template\x27\x20to\x20list\x20all\x20template\x20metadata\x20(id\x20+\x20object_type\x20+\x20parameters).','Filter\x20by\x20object_type:\x20'+TEMPLATE_OBJECT_TYPES['join'](',\x20')]};if(h){const u=writeResponseToFile(t,h);if(u)return{'success':!![],'action':b,'data':null,'message':'Template\x20\x27'+g+'\x27\x20detail\x20written\x20to\x20file:\x20'+u,'output_file_path':u,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+u]};}return{'success':!![],'action':b,'data':t,'message':'Template\x20\x27'+g+'\x27\x20('+t['object_type']+',\x20'+(t['instantiable']?'instantiable':'guidance-only')+').\x20'+'To\x20instantiate,\x20call\x20again\x20with\x20\x27params\x27\x20=\x20JSON\x20object\x20of\x20the\x20declared\x20parameters.'};}let m;try{const v=JSON['parse'](j);if(!v||typeof v!=='object'||Array['isArray'](v))return{'success':![],'action':b,'data':null,'message':'\x27params\x27\x20must\x20be\x20a\x20JSON\x20object\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27),\x20got\x20'+(Array['isArray'](v)?'array':typeof v)+'.'};m=v;}catch(w){return{'success':![],'action':b,'data':null,'message':'Failed\x20to\x20parse\x20\x27params\x27\x20as\x20JSON:\x20'+(w instanceof Error?w['message']:String(w)),'suggestions':['Example:\x20params=\x27{\x22whitelist\x22:[\x220xabc...\x22]}\x27']};}const n=instantiateTemplate(g,m);if(!n['ok'])return{'success':![],'action':b,'data':n['guidance']!==undefined?{'guidance':n['guidance']}:null,'message':'Instantiation\x20failed\x20for\x20\x27'+g+'\x27:\x20'+n['error'],'suggestions':n['missing_params']?['Missing\x20required\x20params:\x20'+n['missing_params']['join'](',\x20'),'Call\x20with\x20\x27template\x27\x20only\x20(no\x20\x27params\x27)\x20to\x20see\x20full\x20parameter\x20declarations.']:['Call\x20with\x20\x27template\x27\x20only\x20(no\x20\x27params\x27)\x20to\x20see\x20full\x20parameter\x20declarations.']};const o={'object_type':n['object_type'],'template_id':n['template_id'],'body':n['body'],...n['notes']?{'notes':n['notes']}:{}};if(h){const x=writeResponseToFile(o,h);if(x)return{'success':!![],'action':b,'data':null,'message':'Instantiated\x20template\x20\x27'+g+'\x27\x20written\x20to\x20file:\x20'+x,'output_file_path':x,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+x]};}return{'success':!![],'action':b,'data':o,'message':'Instantiated\x20\x27'+g+'\x27\x20('+n['object_type']+').\x20'+'Review\x20the\x20body\x20against\x20the\x20onchain_operations\x20schema\x20before\x20submitting.'};}if(b==='get_tool_reference'){if(c){const z=getToolReference(c);if(!z)return{'success':![],'action':b,'data':null,'message':'Tool\x20\x27'+c+'\x27\x20not\x20found\x20in\x20the\x20tool\x20reference.','suggestions':['Omit\x20\x27name\x27\x20to\x20list\x20all\x20tools.','Available\x20tools:\x20'+TOOLS_REFERENCE['map'](B=>B['name'])['join'](',\x20')]};const A=getToolSequence(c);return{'success':!![],'action':b,'data':{'tool':z,'call_sequence':A??null},'message':'Retrieved\x20tool\x20reference:\x20'+c};}if(d){const B=searchToolReference(d);return{'success':!![],'action':b,'data':{'tools':B,'count':B['length']},'message':'Found\x20'+B['length']+'\x20tool(s)\x20matching\x20\x27'+d+'\x27','suggestions':B['length']===0x0?['Try\x20a\x20broader\x20keyword\x20(e.g.\x20\x27onchain\x27,\x20\x27guard\x27,\x20\x27schema\x27),\x20or\x20omit\x20\x27query\x27\x20to\x20list\x20all\x20tools.']:undefined};}const y=TOOLS_REFERENCE['map'](C=>({'name':C['name'],'summary':C['summary'],'actions':C['actions']??[],'notes':C['notes']??[]}));return{'success':!![],'action':b,'data':{'tools':y,'count':y['length']},'message':'Retrieved\x20reference\x20for\x20'+y['length']+'\x20MCP\x20tools.\x20Pass\x20name=\x27<tool>\x27\x20for\x20full\x20detail\x20(params,\x20prerequisites,\x20follow-ups).'};}if(b==='get_guard_design_patterns'){if(c){const D=getGuardDesignPattern(c);if(!D)return{'success':![],'action':b,'data':null,'message':'Guard\x20design\x20pattern\x20\x27'+c+'\x27\x20not\x20found.','suggestions':['Omit\x20\x27name\x27\x20to\x20list\x20the\x20full\x20catalog.','Available\x20pattern\x20ids:\x20'+GUARD_DESIGN_PATTERNS['map'](E=>E['id'])['join'](',\x20')]};return{'success':!![],'action':b,'data':{'pattern':D},'message':'Retrieved\x20Guard\x20design\x20pattern:\x20'+c};}if(d){const E=GUARD_DESIGN_PATTERNS['filter'](G=>G['host']===d),F=E['length']>0x0?E:GUARD_DESIGN_PATTERNS['filter'](G=>G['business_requirement']['toLowerCase']()['includes'](d['toLowerCase']())||G['logic_summary']['toLowerCase']()['includes'](d['toLowerCase']()));return{'success':!![],'action':b,'data':{'patterns':F,'count':F['length'],'filtered_by':E['length']>0x0?'host':'keyword','schema_notes':GUARD_SCHEMA_NOTES},'message':'Found\x20'+F['length']+'\x20Guard\x20design\x20pattern(s)\x20matching\x20\x27'+d+'\x27','suggestions':F['length']===0x0?['Filter\x20by\x20host:\x20service_buy_guard,\x20service_allocator_guard,\x20machine_forward,\x20progress_submission,\x20reward_claim,\x20repository_write,\x20arbitration_usage,\x20arbitration_voting,\x20gen_passport']:undefined};}const C=GUARD_DESIGN_PATTERNS['map'](G=>({'id':G['id'],'business_requirement':G['business_requirement'],'host':G['host'],'data_source':G['data_source'],'verifier_level':G['verifier_level'],'logic_summary':G['logic_summary'],'key_queries':G['key_queries'],'notes':G['notes']??[]}));return{'success':!![],'action':b,'data':{'patterns':C,'count':C['length'],'version':GUARD_DESIGN_PATTERNS_VERSION,'schema_notes':GUARD_SCHEMA_NOTES},'message':'Retrieved\x20'+C['length']+'\x20Guard\x20design\x20patterns.\x20Pass\x20name=\x27<pattern_id>\x27\x20for\x20full\x20detail\x20(witness\x20types,\x20mitigated\x20risks,\x20industries).'};}if(b==='get_safety_rules')return{'success':!![],'action':b,'data':{'version':SAFETY_RULES_VERSION,'object_reuse_rules':OBJECT_REUSE_RULES,'create_vs_modify_pattern':CREATE_VS_MODIFY_PATTERN,'immutability_rules':IMMUTABILITY_RULES,'protocol_slot_rules':PROTOCOL_SLOT_RULES,'operation_type_classification':OPERATION_TYPE_CLASSIFICATION,'operation_class_meta':OPERATION_CLASS_META,'naming_conventions':NAMING_CONVENTIONS},'message':'Retrieved\x20safety\x20rule\x20tables\x20(reuse\x20/\x20immutability\x20/\x20protocol\x20slots\x20/\x20operation\x20classification\x20/\x20naming).\x20'+'Key\x20points:\x20prefer\x20REUSING\x20existing\x20objects\x20(string\x20reference\x20=\x20reuse,\x20object\x20shape\x20=\x20create);\x20'+'Machine\x20publish\x20locks\x20nodes/pairs/forwards,\x20Service\x20publish\x20locks\x20machine/order_allocators/arbitrations\x20(sales\x20stays\x20mutable);\x20'+'Guard\x20is\x20CREATE-only\x20immutable;\x20on-chain\x20writes\x20require\x20explicit\x20user\x20confirmation;\x20'+'Guards\x20bound\x20on\x20machine\x20forwards\x20MUST\x20declare\x20protocol\x20slot\x20254\x20(task\x20binding),\x20and\x20every\x20allocator\x20{GuardIdentifier:N}\x20leg\x20MUST\x20name\x20a\x20declared\x20b_submission\x20Address\x20slot.'};if(!areSchemasAvailable())return{'success':![],'action':b,'data':null,'message':'Schema\x20files\x20are\x20not\x20available.\x20Please\x20run\x20\x27npm\x20run\x20generate:schemas\x27\x20first.','suggestions':['Run\x20\x27npm\x20run\x20generate:schemas\x27\x20to\x20generate\x20schema\x20files','Ensure\x20the\x20dist/schemas\x20directory\x20exists']};switch(b){case'list':{const G=listSchemas();return{'success':!![],'action':b,'data':G,'message':'Found\x20'+G['length']+'\x20available\x20schemas'};}case'get':{if(!c)return{'success':![],'action':b,'data':null,'message':'Schema\x20name\x20is\x20required\x20for\x20\x27get\x27\x20action','suggestions':['Provide\x20a\x20schema\x20name','Use\x20\x27list\x27\x20action\x20to\x20see\x20available\x20schemas']};const H=getSchema(c);if(!H){const J=searchSchemas(c)['slice'](0x0,0x5);return{'success':![],'action':b,'data':null,'message':'Schema\x20\x27'+c+'\x27\x20not\x20found','suggestions':J['length']>0x0?J['map'](K=>'Did\x20you\x20mean:\x20'+K['name']+'?'):['Use\x20\x27list\x27\x20action\x20to\x20see\x20available\x20schemas']};}if(h){const K=writeResponseToFile(H,h);if(K)return{'success':!![],'action':b,'data':null,'message':'Schema\x20\x27'+c+'\x27\x20written\x20to\x20file:\x20'+K,'output_file_path':K,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+K]};}const I=autoOverflowToFile(H,c);if(I)return{'success':!![],'action':b,'data':null,'message':'Schema\x20\x27'+c+'\x27\x20is\x20large\x20('+Math['round'](I['bytes']/0x400)+'\x20KB)\x20—\x20'+'written\x20to\x20file\x20instead\x20of\x20inlining\x20to\x20protect\x20your\x20context.','output_file_path':I['absolute_path'],'inline_summary':I['summary'],'suggestions':['Read\x20the\x20full\x20file\x20with\x20the\x20Read\x20tool:\x20'+I['absolute_path'],'If\x20the\x20sandbox\x20blocks\x20that\x20path,\x20resolve\x20the\x20relative\x20path\x20\x27'+I['relative_path']+'\x27\x20against\x20the\x20workspace\x20root\x20and\x20read\x20that.','Without\x20file\x20access,\x20query\x20specific\x20fields\x20via\x20action=\x27get_field\x27\x20with\x20name=\x27'+c+'\x27\x20and\x20a\x20field_path\x20from\x20the\x20summary\x20below.']};return{'success':!![],'action':b,'data':H,'message':'Retrieved\x20schema:\x20'+c};}case'get_field':{if(!c||!f)return{'success':![],'action':b,'data':null,'message':'Both\x20\x27name\x27\x20and\x20\x27field_path\x27\x20are\x20required\x20for\x20\x27get_field\x27\x20action','suggestions':['Example:\x20{action:\x20\x27get_field\x27,\x20name:\x20\x27onchain_operations_machine\x27,\x20field_path:\x20\x27data.node\x27}','Use\x20\x27get\x27\x20action\x20to\x20retrieve\x20the\x20full\x20schema']};const L=getSchemaField(c,f);if(!L)return{'success':![],'action':b,'data':null,'message':'Field\x20path\x20\x27'+f+'\x27\x20not\x20found\x20in\x20schema\x20\x27'+c+'\x27','suggestions':['Check\x20the\x20field\x20path\x20(dot-separated,\x20e.g.\x20\x27data.node\x27)','Use\x20\x27get\x27\x20action\x20to\x20see\x20the\x20full\x20schema\x20structure']};return{'success':!![],'action':b,'data':L,'message':'Retrieved\x20field\x20\x27'+f+'\x27\x20from\x20schema\x20\x27'+c+'\x27'};}case'search':{if(!d)return{'success':![],'action':b,'data':null,'message':'Search\x20query\x20is\x20required\x20for\x20\x27search\x27\x20action'};const M=searchSchemas(d);return{'success':!![],'action':b,'data':M,'message':'Found\x20'+M['length']+'\x20schemas\x20matching\x20\x27'+d+'\x27'};}case'list_operations':{const N=listOperations();return{'success':!![],'action':b,'data':N,'message':'Found\x20'+N['length']+'\x20on-chain\x20operations'};}case'get_guard_queries':{const O=d?.['trim']()['toLowerCase'](),P=R=>({'id':R['id'],'name':R['name'],'objectType':ObjectType[R['objectType']]??String(R['objectType']),'returnType':ValueType[R['return']]??String(R['return'])});if(O){const R=GUARDQUERY['filter'](S=>S['name']['toLowerCase']()['includes'](O)||S['description']?.['toLowerCase']()['includes'](O)||String(S['id'])===O)['map'](S=>({...P(S),'description':S['description']}));return{'success':!![],'action':b,'data':R,'message':'Found\x20'+R['length']+'\x20GUARDQUERY\x20entries\x20matching\x20\x27'+d+'\x27\x20'+('(of\x20'+GUARDQUERY['length']+'\x20total).\x20Use\x20names,\x20not\x20numeric\x20ids,\x20in\x20Guard\x20trees\x20—\x20')+'names\x20fail\x20loudly\x20at\x20validation\x20when\x20wrong;\x20a\x20wrong-but-existing\x20id\x20silently\x20checks\x20a\x20different\x20field.'};}if(h){const S=GUARDQUERY['map'](U=>({...P(U),'description':U['description']})),T=writeResponseToFile(S,h);if(T)return{'success':!![],'action':b,'data':null,'message':'Full\x20GUARDQUERY\x20catalog\x20('+S['length']+'\x20entries)\x20written\x20to\x20file:\x20'+T,'output_file_path':T,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+T]};}const Q=GUARDQUERY['map'](P);return{'success':!![],'action':b,'data':Q,'message':'GUARDQUERY\x20catalog:\x20'+Q['length']+'\x20entries\x20(compact\x20form\x20—\x20id,\x20name,\x20objectType,\x20returnType).\x20'+'Add\x20query=\x27<keyword>\x27\x20for\x20full\x20entries\x20with\x20descriptions,\x20or\x20output_file\x20to\x20dump\x20all\x20details\x20to\x20a\x20file.\x20'+'Prefer\x20NAME\x20references\x20in\x20Guard\x20trees;\x20a\x20numeric\x20id\x20is\x20resolved\x20verbatim\x20and\x20a\x20wrong-but-existing\x20id\x20'+'silently\x20checks\x20a\x20different\x20field.'};}case'get_output':{if(!c)return{'success':![],'action':b,'data':null,'message':'Tool\x20name\x20is\x20required\x20for\x20\x27get_output\x27\x20action','suggestions':['Provide\x20a\x20tool\x20name','Use\x20\x27list\x27\x20action\x20to\x20see\x20available\x20tools\x20and\x20their\x20outputPath']};const U=getOutputSchema(c);if(!U){const W=listSchemas(),X=W['find'](Z=>Z['name']===c);if(X)return{'success':![],'action':b,'data':null,'message':'Tool\x20\x27'+c+'\x27\x20exists\x20but\x20has\x20no\x20output\x20schema\x20file.\x20The\x20tool\x20may\x20not\x20declare\x20an\x20outputSchema,\x20or\x20the\x20schema\x20file\x20was\x20not\x20generated.','suggestions':['Use\x20\x27get\x27\x20action\x20with\x20name=\x27'+c+'\x27\x20to\x20retrieve\x20its\x20input\x20schema']};const Y=searchSchemas(c)['slice'](0x0,0x5);return{'success':![],'action':b,'data':null,'message':'Tool\x20\x27'+c+'\x27\x20not\x20found','suggestions':Y['length']>0x0?Y['map'](Z=>'Did\x20you\x20mean:\x20'+Z['name']+'?'):['Use\x20\x27list\x27\x20action\x20to\x20see\x20available\x20tools']};}if(h){const Z=writeResponseToFile(U,h);if(Z)return{'success':!![],'action':b,'data':null,'message':'Output\x20schema\x20\x27'+c+'\x27\x20written\x20to\x20file:\x20'+Z,'output_file_path':Z,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+Z]};}const V=autoOverflowToFile(U,c);if(V)return{'success':!![],'action':b,'data':null,'message':'Output\x20schema\x20\x27'+c+'\x27\x20is\x20large\x20('+Math['round'](V['bytes']/0x400)+'\x20KB)\x20—\x20'+'written\x20to\x20file\x20instead\x20of\x20inlining\x20to\x20protect\x20your\x20context.','output_file_path':V['absolute_path'],'inline_summary':V['summary'],'suggestions':['Read\x20the\x20full\x20file\x20with\x20the\x20Read\x20tool:\x20'+V['absolute_path'],'If\x20the\x20sandbox\x20blocks\x20that\x20path,\x20resolve\x20the\x20relative\x20path\x20\x27'+V['relative_path']+'\x27\x20against\x20the\x20workspace\x20root\x20and\x20read\x20that.','Without\x20file\x20access,\x20query\x20specific\x20fields\x20via\x20action=\x27get_field\x27\x20with\x20name=\x27'+c+'\x27\x20and\x20a\x20field_path\x20from\x20the\x20summary\x20below.']};return{'success':!![],'action':b,'data':U,'message':'Retrieved\x20output\x20schema:\x20'+c};}default:return{'success':![],'action':b,'data':null,'message':'Unknown\x20action:\x20'+b,'suggestions':['Use\x20\x27list\x27,\x20\x27get\x27,\x20\x27get_field\x27,\x20\x27get_output\x27,\x20\x27search\x27,\x20\x27list_operations\x27,\x20\x27get_guard_templates\x27,\x20\x27get_tool_reference\x27,\x20\x27get_guard_design_patterns\x27,\x20\x27get_safety_rules\x27,\x20\x27get_templates\x27,\x20or\x20\x27analyze_guard_semantics\x27']};}}const GUARD_SEMANTICS_READING_CHECKLIST=['WHO\x20can\x20satisfy\x20this\x20Guard\x20(identity:\x20Signer\x20bindings,\x20Entity\x20membership,\x20allowlists)?','WHEN\x20can\x20it\x20be\x20satisfied\x20(time:\x20Clock\x20comparisons,\x20deadlines,\x20windows)?','WHAT\x20evidence\x20must\x20the\x20caller\x20submit\x20(b_submission\x20table\x20entries\x20—\x20Payment/Order/Proof\x20objects)?','WHICH\x20on-chain\x20data\x20does\x20it\x20read,\x20and\x20can\x20that\x20data\x20change\x20(Repository\x20entries\x20are\x20MUTABLE\x20—\x20who\x20controls\x20the\x20writes)?','WHAT\x20does\x20the\x20counterparty\x20gain/lose\x20in\x20each\x20branch\x20of\x20the\x20logic\x20tree?','ARE\x20there\x20error-level\x20diagnostics\x20or\x20critical\x20risks\x20(they\x20block\x20or\x20endanger\x20execution)?'];export async function analyzeGuardSemantics(a){const b=await lintGuard(a,{'auto_fix':![]}),c={'root':a['root'],'table':(a['table']??[])['map'](k=>({'identifier':k['identifier'],'name':k['name'],'value_type':k['value_type']??'Address','b_submission':k['b_submission']??![],'value':k['value']})),'guardName':a['description']??null,'rely':a['rely']??null},d=renderGuardTreeIndented(c),e=renderGuardMermaid(a['root']),f=new Set(),g=[];let h=![],i=![];walkGuardTree(a['root'],k=>{if(k['type']==='context'){if(k['context']==='Clock')h=!![];if(k['context']==='Signer')i=!![];}if(k['type']==='query'&&k['query']!==undefined&&k['query']!==null){if(typeof k['query']==='number'){const l=getGuardQueryByIdOrName(k['query']);if(l)f['add'](l['id']);else g['push'](k['query']);}else{const m=getGuardQueryByIdOrName(k['query']);if(m)f['add'](m['id']);else g['push'](k['query']);}}});const j={'submission_requirements':(a['table']??[])['filter'](k=>k['b_submission']===!![])['map'](k=>({'identifier':k['identifier'],'value_type':k['value_type'],'object_type':k['object_type'],'name':k['name']})),'data_sources':(a['table']??[])['filter'](k=>k['b_submission']!==!![])['map'](k=>({'identifier':k['identifier'],'kind':k['is_system_address']?'system_address':k['object_type']?'object':'fixed_value','value_type':k['value_type'],'object_type':k['object_type'],'name':k['name'],'is_mutable_onchain':k['object_type']==='Repository'})),'query_dependencies':[...f]['sort']((k,l)=>k-l),'unresolved_queries':g,'has_time_conditions':h,'has_signer_constraints':i,'has_rely_composition':Array['isArray'](a['rely']?.['guards'])&&a['rely']['guards']['length']>0x0,'reading_checklist':GUARD_SEMANTICS_READING_CHECKLIST};return{'render':{'tree_indented':d,'mermaid':e},'lint':b,'party_evaluation':j};}export{formatLintResult};
@@ -177,7 +177,7 @@
177
177
  "additionalProperties": false
178
178
  },
179
179
  "transfer": {
180
- "description": "Result of token transfer transaction",
180
+ "description": "Result of token transfer transaction, annotated with the network it executed on and where that network came from",
181
181
  "type": "object",
182
182
  "properties": {
183
183
  "balanceChanges": {
@@ -2206,6 +2206,23 @@
2206
2206
  "type": "null"
2207
2207
  }
2208
2208
  ]
2209
+ },
2210
+ "network": {
2211
+ "description": "Chain the transfer transaction executed on, echoed back by the MCP layer so a same-session caller can detect a silently wrong chain (the session default network can change between calls).",
2212
+ "type": "string",
2213
+ "enum": [
2214
+ "localnet",
2215
+ "testnet",
2216
+ "mainnet"
2217
+ ]
2218
+ },
2219
+ "network_source": {
2220
+ "description": "Where the echoed network came from: 'request' = the call's explicit transfer.network input; 'session_default' = the SDK session default was used (no transfer.network in the request).",
2221
+ "type": "string",
2222
+ "enum": [
2223
+ "request",
2224
+ "session_default"
2225
+ ]
2209
2226
  }
2210
2227
  },
2211
2228
  "required": [
@@ -2249,13 +2266,21 @@
2249
2266
  "type": "string"
2250
2267
  },
2251
2268
  "network": {
2269
+ "description": "Chain the coin-production transaction executed on, annotated by the MCP layer with the RESOLVED network so a same-session caller can detect a silently wrong chain (the SDK alone echoes only the raw input, which is undefined when omitted).",
2252
2270
  "type": "string",
2253
2271
  "enum": [
2254
2272
  "localnet",
2255
2273
  "testnet",
2256
2274
  "mainnet"
2257
- ],
2258
- "description": "Network entrypoint: Specifies which network the operation occurs on. FIX-010 cross-network note: LocalMark names are scoped per network (testnet marks are invisible on mainnet and vice versa). When migrating from testnet to mainnet, recreate all objects on mainnet and re-register LocalMark names with the SAME names to keep name-based references working across networks. Recreate all objects on the target network via onchain_operations with env.network=target_network, then re-register the LocalMark names."
2275
+ ]
2276
+ },
2277
+ "network_source": {
2278
+ "description": "Where the echoed network came from: 'request' = the call's explicit get.network input; 'session_default' = the SDK session default was used (no get.network in the request).",
2279
+ "type": "string",
2280
+ "enum": [
2281
+ "request",
2282
+ "session_default"
2283
+ ]
2259
2284
  }
2260
2285
  },
2261
2286
  "required": [
@@ -2339,6 +2364,7 @@
2339
2364
  "guard_rejected",
2340
2365
  "state_conflict",
2341
2366
  "insufficient_balance",
2367
+ "pool_shortage",
2342
2368
  "transaction_expired",
2343
2369
  "stock_exhausted",
2344
2370
  "sale_suspended",
@@ -3093,7 +3119,7 @@
3093
3119
  }
3094
3120
  },
3095
3121
  "available_queries": {
3096
- "description": "Available query instructions for the current context (subset of 375 GUARDQUERY entries)",
3122
+ "description": "Available query instructions for the current context (subset of the GUARDQUERY catalog)",
3097
3123
  "type": "array",
3098
3124
  "items": {
3099
3125
  "type": "object",
@@ -3128,7 +3154,7 @@
3128
3154
  "returnType"
3129
3155
  ],
3130
3156
  "additionalProperties": false,
3131
- "description": "A Guard query instruction available for the current context (subset of GUARDQUERY 375 entries)."
3157
+ "description": "A Guard query instruction available for the current context (subset of the GUARDQUERY catalog)."
3132
3158
  }
3133
3159
  },
3134
3160
  "risk_warnings": {
@@ -3690,20 +3716,25 @@
3690
3716
  "type": "string",
3691
3717
  "enum": [
3692
3718
  "success",
3693
- "failed"
3719
+ "failed",
3720
+ "unknown"
3694
3721
  ],
3695
- "description": "Step outcome. Steps are fail-isolated: a failed step never affects the forward or the other step (on-chain has no rollback)."
3722
+ "description": "Step outcome. Steps are fail-isolated: a failed step never affects the forward or the other step (on-chain has no rollback). 'unknown' (esln-261023 E-6) = the submission outcome could NOT be observed (transport drop after submit) — the step MAY have landed; this is NOT a confirmed failure. Follow next_action (probe) before any retry; a blind retry double-writes."
3696
3723
  },
3697
3724
  "detail": {
3698
3725
  "type": "string",
3699
- "description": "On success: what was written/claimed (payload summary). On failure: what the step attempted."
3726
+ "description": "On success: what was written/claimed (payload summary). On failure or unknown: what the step attempted."
3700
3727
  },
3701
3728
  "digest": {
3702
- "description": "Transaction digest when the step succeeded.",
3729
+ "description": "Transaction digest: on success the landing digest; on an unknown outcome the transport-reported pre-submit digest — verify it via onchain_transaction (executed → landed, adopt; failure → final; unresolvable → nothing landed).",
3703
3730
  "type": "string"
3704
3731
  },
3705
3732
  "error": {
3706
- "description": "Error message when the step failed. Retry via the dedicated repository/reward tools with the same submission values.",
3733
+ "description": "Error message when the step failed or stayed unknown. Retry via the dedicated repository/reward tools with the same submission values — only after a probe confirms nothing landed.",
3734
+ "type": "string"
3735
+ },
3736
+ "next_action": {
3737
+ "description": "Present on failed/unknown steps: the concrete recovery move (the probe to run, the safe-retry condition, or the two-phase split).",
3707
3738
  "type": "string"
3708
3739
  }
3709
3740
  },
@@ -109,7 +109,7 @@
109
109
  "additionalProperties": false
110
110
  },
111
111
  "transfer": {
112
- "description": "💰 FUND MOVEMENT (on-chain, irreversible): transfer tokens from one account to another. Amount parsing: display strings like \"2.5WOW\" are converted to raw smallest units with the token's decimals; bare decimal numbers are rejected. Use the EMPTY STRING '' in name_or_address_from/to for the default account — the literal 'DEFAULT' is rejected. Requires confirmation — first call previews, re-call with confirmed=true.",
112
+ "description": "💰 FUND MOVEMENT (on-chain, irreversible): transfer tokens from one account to another. Amount parsing: display strings like \"2.5WOW\" are converted to raw smallest units with the token's decimals; bare decimal numbers are rejected. ⚠️ The numeric part of a suffixed string counts WHOLE tokens, never raw units: \"320000000WOW\" = 320 million WOW (raw 320000000000000000 at decimals 9) — to send 0.32 WOW write \"0.32WOW\"; to pass raw smallest units use the bare integer string \"320000000\" (no symbol). Use the EMPTY STRING '' in name_or_address_from/to for the default account — the literal 'DEFAULT' is rejected. Requires confirmation — first call previews, re-call with confirmed=true.",
113
113
  "type": "object",
114
114
  "properties": {
115
115
  "name_or_address_from": {
@@ -535,9 +535,10 @@
535
535
  "type": "string",
536
536
  "enum": [
537
537
  "testnet",
538
- "mainnet"
538
+ "mainnet",
539
+ "localnet"
539
540
  ],
540
- "description": "Target network (default testnet)."
541
+ "description": "Target network (default testnet). 'localnet' labels plans validated against a local net — the migration pipeline is network-agnostic, this is provenance metadata, not an execution target."
541
542
  }
542
543
  },
543
544
  "required": [
@@ -756,9 +757,10 @@
756
757
  "type": "string",
757
758
  "enum": [
758
759
  "testnet",
759
- "mainnet"
760
+ "mainnet",
761
+ "localnet"
760
762
  ],
761
- "description": "Target network (default testnet)."
763
+ "description": "Target network (default testnet). 'localnet' labels plans validated against a local net — the migration pipeline is network-agnostic, this is provenance metadata, not an execution target."
762
764
  }
763
765
  },
764
766
  "required": [
@@ -827,7 +829,8 @@
827
829
  "type": "string",
828
830
  "enum": [
829
831
  "testnet",
830
- "mainnet"
832
+ "mainnet",
833
+ "localnet"
831
834
  ]
832
835
  },
833
836
  "scan": {
@@ -155,9 +155,96 @@
155
155
  ]
156
156
  },
157
157
  "reward_funding": {
158
- "description": "Review reward pool funding, smallest-unit string. Required by template_generate/migration_apply when the effective review mode is review_reward (INV-4: the incentive must be funded at build time).",
158
+ "description": "Review reward pool funding, smallest-unit string. HARD-REQUIRED when the effective review mode is review_reward (INV-4): template_generate refuses the build up-front with error_code 'reward_funding_required' rather than promising an unfunded incentive — pass this, or drop the mode explicitly (review_mode 'review' keeps the rail without the bounty; 'none' removes the rail). The compile kernel also blocks with REVIEW_REWARD_UNFUNDED — this input gate just fails before the pipeline runs.",
159
159
  "type": "string"
160
160
  },
161
+ "after_sales_mode": {
162
+ "description": "Per-build after-sales mode (D12 重构 4). Absent = the template's declared after_sales_mode applies. Declaring a mode with no backing rail in machine_shape is a compile blocker (AFTER_SALES_RAIL_MISSING).",
163
+ "type": "string",
164
+ "enum": [
165
+ "return",
166
+ "exchange",
167
+ "warranty",
168
+ "none"
169
+ ]
170
+ },
171
+ "acceptance_mode": {
172
+ "description": "Per-build acceptance/judging mode (D12 重构 2). Absent = the template's declared acceptance_mode applies. A judge-decided mode (contest/bounty/agent) without arbitration_mode 'third_party' is a compile blocker (ACCEPTANCE_JUDGE_NOT_INDEPENDENT); a finite revision_rounds_max with no counter Repository guard is a compile blocker (ACCEPTANCE_REVISION_UNBOUNDED).",
173
+ "type": "string",
174
+ "enum": [
175
+ "milestone",
176
+ "contest",
177
+ "bounty",
178
+ "agent",
179
+ "none"
180
+ ]
181
+ },
182
+ "installment_mode": {
183
+ "description": "Per-build installment/deposit mode (D12 重构 3). Absent = the template's declared installment_mode applies. A capture forward with no fund-gate Guard is a compile blocker (INSTALLMENT_FUNDING_UNGATED); a deposit-held state with no exit rail is a compile blocker (INSTALLMENT_DEPOSIT_STRANDED).",
184
+ "type": "string",
185
+ "enum": [
186
+ "deposit_balance",
187
+ "milestone_n",
188
+ "none"
189
+ ]
190
+ },
191
+ "affiliate_mode": {
192
+ "description": "Per-build affiliate commission overlay (D12 批 5). Absent = the template's declared affiliate_mode applies. A declared commission overlay with no commission rail is a compile blocker (AFFILIATE_RAIL_MISSING); a commission with no post-lock no-clawback disclosure build_note is a compile blocker (AFFILIATE_CLAWBACK_UNDISCLOSED).",
193
+ "type": "string",
194
+ "enum": [
195
+ "commission",
196
+ "none"
197
+ ]
198
+ },
199
+ "crowdfunding_mode": {
200
+ "description": "Per-build crowdfunding campaign overlay (D12 批 7). Absent = the template's declared crowdfunding_mode applies. A declared threshold/flexible overlay with no two-leg escrow-exit gate (release XOR refund, D-BUG-2) is a compile blocker (CROWDFUNDING_THRESHOLD_GATE_MISSING); a threshold gate whose aggregate is NOT a writer-bound sum-where (id_from signer) is a compile blocker (CROWDFUNDING_AGGREGATE_UNBOUND); a missing L-04/L-01/L-05 disclosure build_note is a compile blocker (CROWDFUNDING_DISCLOSURE_MISSING).",
201
+ "type": "string",
202
+ "enum": [
203
+ "threshold",
204
+ "flexible",
205
+ "none"
206
+ ]
207
+ },
208
+ "sales": {
209
+ "description": "The sellable SKU catalog (upwc-cat-261017 CAT-A1 / PLAN-SALES-01). REQUIRED for template_generate (A-2, amz9-ln-261023): an empty/absent catalog is refused up-front with error_code 'sales_required' — the published Service would freeze with sales: [] and every order_new aborts; PLAN-SALES-01 is now an INPUT error on this action, not a post-hoc audit finding. migration_apply keeps the audit-finding posture (it confirms an already-reviewed import). Item shape follows the chain's SaleItem: { name, price, quantity?, wip_hash? } with price in smallest units. OPTIONAL per item: a structured `incentive` object (G-07: { amount, conditions, basis, claim_window }, all strings) declaring the buyer-perceivable reward terms — carried verbatim into the compiled plan's service_sales step for quote-time disclosure; it is plan metadata only and never an on-chain SaleItem field.",
210
+ "type": "array",
211
+ "items": {
212
+ "type": "object",
213
+ "properties": {
214
+ "incentive": {
215
+ "type": "object",
216
+ "properties": {
217
+ "amount": {
218
+ "type": "string",
219
+ "description": "Incentive amount as a buyer-readable string (e.g. \"5 USDC\" or \"1000000000 WOW smallest units\"). Quote-time disclosure only — fund the actual rail separately (e.g. the template's review_reward_pool)."
220
+ },
221
+ "conditions": {
222
+ "type": "string",
223
+ "description": "What the buyer must do to earn it (e.g. \"leave a written + rated review of the delivered work\"). Must be perceptible BEFORE the order is placed."
224
+ },
225
+ "basis": {
226
+ "type": "string",
227
+ "description": "Accrual scope: \"per-order\" / \"once-per-buyer\" / \"once-per-buyer-per-order\". Matches the claim guard's replay semantics — a recipient-only gate is once-per-buyer-for-life, an order-scoped stamp is per-order (SV-2)."
228
+ },
229
+ "claim_window": {
230
+ "type": "string",
231
+ "description": "How long the buyer has to claim (e.g. \"14 days from the review\"). Mirror the reward claim guard's window fee_param so the quote never promises more than the rail pays."
232
+ }
233
+ },
234
+ "required": [
235
+ "amount",
236
+ "conditions",
237
+ "basis",
238
+ "claim_window"
239
+ ],
240
+ "additionalProperties": false,
241
+ "description": "Optional structured incentive for one sale item (G-07): buyer-perceivable reward terms carried to the compiled plan for quote-time disclosure. DECLARATION ONLY — the chain SaleItem has no such field; the actual payout rail is configured separately."
242
+ }
243
+ },
244
+ "additionalProperties": {},
245
+ "description": "One sellable SKU in the plan catalog: the chain SaleItem fields plus the optional structured `incentive` declaration (G-07). Unknown keys pass through so chain-side fields can evolve without schema changes."
246
+ }
247
+ },
161
248
  "log": {
162
249
  "description": "A prior MigrationLog (required for migration_review).",
163
250
  "type": "object",
@@ -167,11 +254,12 @@
167
254
  "additionalProperties": {}
168
255
  },
169
256
  "network": {
170
- "description": "Target network for migration_import / migration_apply (default testnet; mainnet requires explicit user confirmation).",
257
+ "description": "Target network for migration_import / migration_apply (default testnet; mainnet requires explicit user confirmation; 'localnet' is a provenance label for locally validated plans — the pipeline never executes on-chain).",
171
258
  "type": "string",
172
259
  "enum": [
173
260
  "testnet",
174
- "mainnet"
261
+ "mainnet",
262
+ "localnet"
175
263
  ]
176
264
  }
177
265
  },
@@ -48,6 +48,7 @@
48
48
  "guard_rejected",
49
49
  "state_conflict",
50
50
  "insufficient_balance",
51
+ "pool_shortage",
51
52
  "transaction_expired",
52
53
  "stock_exhausted",
53
54
  "sale_suspended",
@@ -797,7 +798,7 @@
797
798
  }
798
799
  },
799
800
  "available_queries": {
800
- "description": "Available query instructions for the current context (subset of 375 GUARDQUERY entries)",
801
+ "description": "Available query instructions for the current context (subset of the GUARDQUERY catalog)",
801
802
  "type": "array",
802
803
  "items": {
803
804
  "type": "object",
@@ -832,7 +833,7 @@
832
833
  "returnType"
833
834
  ],
834
835
  "additionalProperties": false,
835
- "description": "A Guard query instruction available for the current context (subset of GUARDQUERY 375 entries)."
836
+ "description": "A Guard query instruction available for the current context (subset of the GUARDQUERY catalog)."
836
837
  }
837
838
  },
838
839
  "risk_warnings": {
@@ -1394,20 +1395,25 @@
1394
1395
  "type": "string",
1395
1396
  "enum": [
1396
1397
  "success",
1397
- "failed"
1398
+ "failed",
1399
+ "unknown"
1398
1400
  ],
1399
- "description": "Step outcome. Steps are fail-isolated: a failed step never affects the forward or the other step (on-chain has no rollback)."
1401
+ "description": "Step outcome. Steps are fail-isolated: a failed step never affects the forward or the other step (on-chain has no rollback). 'unknown' (esln-261023 E-6) = the submission outcome could NOT be observed (transport drop after submit) — the step MAY have landed; this is NOT a confirmed failure. Follow next_action (probe) before any retry; a blind retry double-writes."
1400
1402
  },
1401
1403
  "detail": {
1402
1404
  "type": "string",
1403
- "description": "On success: what was written/claimed (payload summary). On failure: what the step attempted."
1405
+ "description": "On success: what was written/claimed (payload summary). On failure or unknown: what the step attempted."
1404
1406
  },
1405
1407
  "digest": {
1406
- "description": "Transaction digest when the step succeeded.",
1408
+ "description": "Transaction digest: on success the landing digest; on an unknown outcome the transport-reported pre-submit digest — verify it via onchain_transaction (executed → landed, adopt; failure → final; unresolvable → nothing landed).",
1407
1409
  "type": "string"
1408
1410
  },
1409
1411
  "error": {
1410
- "description": "Error message when the step failed. Retry via the dedicated repository/reward tools with the same submission values.",
1412
+ "description": "Error message when the step failed or stayed unknown. Retry via the dedicated repository/reward tools with the same submission values — only after a probe confirms nothing landed.",
1413
+ "type": "string"
1414
+ },
1415
+ "next_action": {
1416
+ "description": "Present on failed/unknown steps: the concrete recovery move (the probe to run, the safe-retry condition, or the two-phase split).",
1411
1417
  "type": "string"
1412
1418
  }
1413
1419
  },