@wowok/agent-mcp 3.4.4 → 3.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.build-stamp.json +3 -3
- package/dist/chain-semantics/composition-truth.js +1 -1
- package/dist/composition/audit.js +1 -1
- package/dist/composition/compile.js +1 -1
- package/dist/composition/emit-phases.js +1 -1
- package/dist/composition/guard-fill.js +1 -1
- package/dist/composition/input-normalize.js +1 -1
- package/dist/composition/materialize.js +1 -1
- package/dist/composition/mode-gates.js +1 -1
- package/dist/composition/param-disclosure.js +1 -1
- package/dist/composition/plan-run-store.js +1 -0
- package/dist/composition/reflux.js +1 -1
- package/dist/composition/role-bindings.js +1 -0
- package/dist/composition/shape-expand.js +1 -1
- package/dist/composition/supply-chain-emit.js +1 -1
- package/dist/config/judgment.d.ts +13 -25
- package/dist/config/judgment.js +1 -1
- package/dist/config/match-policy-file.js +1 -1
- package/dist/config/rule-engine.d.ts +4 -10
- package/dist/config/rule-engine.js +1 -1
- package/dist/config/template-params.js +1 -1
- package/dist/evaluation/engine.js +1 -1
- package/dist/experience/realtime-feedback.js +1 -1
- package/dist/extensions/capability.js +1 -1
- package/dist/graph/onchain/expand.js +1 -1
- package/dist/graph/onchain/exposure.js +1 -1
- package/dist/harness/forward-roster-preflight.js +1 -0
- package/dist/keeper/detectors.js +1 -1
- package/dist/knowledge/allocator-rail-verifier.js +1 -1
- package/dist/knowledge/arb-operation-face.js +1 -1
- package/dist/knowledge/arbitration-rail-verifier.js +1 -1
- package/dist/knowledge/audit-rules.d.ts +17 -1
- package/dist/knowledge/audit-rules.js +1 -1
- package/dist/knowledge/baselines/rules/alloc_audit.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/allocation.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/arb.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/arbitration.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/bridge.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/contact.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/demand.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/graph.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/guard.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/machine.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/oracle.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/order.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/payment.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/permission.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/personal.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/plan.json +153 -33
- package/dist/knowledge/baselines/rules/plan.json.good +153 -33
- package/dist/knowledge/baselines/rules/plan.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/progress.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/proof.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/registrar.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/repository.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/resource.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/reward.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/service.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/treasury.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/util.json.good.sha256 +1 -0
- package/dist/knowledge/builtin-templates.d.ts +1 -1
- package/dist/knowledge/builtin-templates.js +1 -1
- package/dist/knowledge/discount-threshold.js +1 -1
- package/dist/knowledge/fee-param-bindings.js +1 -1
- package/dist/knowledge/getting-started.js +1 -1
- package/dist/knowledge/guard-binding-table.js +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-templates.d.ts +3 -2
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/knob-docs.js +1 -1
- package/dist/knowledge/machine-topology.js +1 -1
- package/dist/knowledge/param-schema.js +1 -1
- package/dist/knowledge/param-tiers.js +1 -1
- package/dist/knowledge/path-oracle/products/alibaba-1688.js +1 -1
- package/dist/knowledge/path-oracle/products/amazon.js +1 -1
- package/dist/knowledge/path-oracle/products/booking-com.js +1 -1
- package/dist/knowledge/path-oracle/products/contra.js +1 -1
- package/dist/knowledge/path-oracle/products/costco.js +1 -1
- package/dist/knowledge/path-oracle/products/duoduo-maicai.js +1 -1
- package/dist/knowledge/path-oracle/products/etsy.js +1 -1
- package/dist/knowledge/path-oracle/products/gamefound.js +1 -1
- package/dist/knowledge/path-oracle/products/gofundme.js +1 -1
- package/dist/knowledge/path-oracle/products/klook.js +1 -1
- package/dist/knowledge/path-oracle/products/ninety-nine-designs.js +1 -1
- package/dist/knowledge/path-oracle/products/pinduoduo-kuaituantuan.js +1 -1
- package/dist/knowledge/path-oracle/products/shansong.js +1 -1
- package/dist/knowledge/path-oracle/products/taobao-presale.js +1 -1
- package/dist/knowledge/path-oracle/products/upwork-catalog.js +1 -1
- package/dist/knowledge/path-oracle/products/upwork.js +1 -1
- package/dist/knowledge/pattern-resolutions.js +1 -1
- package/dist/knowledge/protocol-facts.js +1 -1
- package/dist/knowledge/publish-gate.js +1 -1
- package/dist/knowledge/publish-surface-contract.js +1 -1
- package/dist/knowledge/template-loader.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/template-scanner.js +1 -1
- package/dist/knowledge/time-units.js +1 -0
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/knowledge/workflow-guidance.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/participation/radar-core.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/merchant-guide.js +1 -1
- package/dist/playbooks/service-build/migration-planner.js +1 -1
- package/dist/playbooks/service-build/object-panorama.js +1 -1
- package/dist/playbooks/service-build/participation-radar.js +1 -1
- package/dist/playbooks/service-build/relationship-profile.js +1 -1
- package/dist/playbooks/service-build/service-panorama.js +1 -1
- package/dist/playbooks/service-build/service-quote.js +1 -1
- package/dist/review/index.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/benchmark-migration/index.d.ts +110 -2
- package/dist/schema/benchmark-migration/index.js +1 -1
- package/dist/schema/boundary-coercion.js +1 -0
- package/dist/schema/call/arbitration.js +1 -1
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/machine.d.ts +56 -8
- package/dist/schema/call/order.d.ts +37 -10
- package/dist/schema/call/order.js +1 -1
- package/dist/schema/call/permission.d.ts +210 -30
- package/dist/schema/call/personal.d.ts +56 -8
- package/dist/schema/call/progress.d.ts +28 -4
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +84 -12
- package/dist/schema/common/index.d.ts +14 -2
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/evaluation/index.js +1 -1
- package/dist/schema/goal/index.d.ts +1 -1
- package/dist/schema/goal/planning.js +1 -1
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/messenger/index.d.ts +168 -24
- package/dist/schema/messenger/index.js +1 -1
- package/dist/schema/operations.d.ts +655 -22
- package/dist/schema/operations.js +1 -1
- package/dist/schema/persona/index.d.ts +22 -110
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/workflow/index.d.ts +4 -0
- package/dist/schema/workflow/index.js +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/benchmark_migration_operation.schema.json +1 -1
- package/dist/schemas/evaluation_operation.schema.json +1 -1
- package/dist/schemas/goal_operation.schema.json +1 -1
- package/dist/schemas/guard_rebind_replacement.schema.json +1 -0
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/messenger_operation.schema.json +1 -1
- package/dist/schemas/onchain_operations.schema.json +1 -1
- package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
- package/dist/schemas/onchain_operations_arbitration.schema.json +1 -1
- package/dist/schemas/onchain_operations_contact.schema.json +1 -1
- package/dist/schemas/onchain_operations_demand.schema.json +1 -1
- package/dist/schemas/onchain_operations_gen_passport.schema.json +1 -1
- package/dist/schemas/onchain_operations_machine.schema.json +1 -1
- package/dist/schemas/onchain_operations_order.schema.json +1 -1
- package/dist/schemas/onchain_operations_permission.schema.json +1 -1
- package/dist/schemas/onchain_operations_personal.schema.json +1 -1
- package/dist/schemas/onchain_operations_progress.schema.json +1 -1
- package/dist/schemas/onchain_operations_proof.schema.json +1 -1
- package/dist/schemas/onchain_operations_repository.schema.json +1 -1
- package/dist/schemas/onchain_operations_reward.schema.json +1 -1
- package/dist/schemas/onchain_operations_service.schema.json +1 -1
- package/dist/schemas/onchain_operations_treasury.schema.json +1 -1
- package/dist/schemas/persona_operation.schema.json +1 -1
- package/dist/schemas/time_convert.schema.json +1 -0
- package/dist/schemas/wip_file.schema.json +1 -1
- package/dist/schemas/workflow_operation.schema.json +1 -1
- package/dist/tools/handlers/benchmark-migration.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/fund-rail-recipe.js +1 -1
- package/dist/tools/handlers/guard-rebind-replacement.js +1 -0
- package/dist/tools/handlers/local.js +1 -1
- package/dist/tools/handlers/mark-namespace.js +1 -1
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/settle-sweep.js +1 -1
- package/dist/tools/handlers/time-convert.js +1 -0
- package/dist/tools/handlers/wip.js +1 -1
- package/dist/tools/handlers/workflow.js +1 -1
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.js +1 -1
- package/dist/tools/registry/business.js +1 -1
- package/dist/tools/registry/local.js +1 -1
- package/dist/tools/registry/onchain.js +1 -1
- package/dist/tools/wip-verify-ledger.js +1 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +6 -5
package/dist/tools/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z}from'zod';import{readFileSync}from'fs';import{fileURLToPath}from'url';import{dirname,join}from'path';import{fromJsonSchema}from'@modelcontextprotocol/server';import{registerOutputSchemaResolver}from'../schema-query-impl/index.js';const __filename=fileURLToPath(import.meta.url),__dirname=dirname(__filename),SCHEMA_DIR_CANDIDATES=[join(__dirname,'..','schemas'),join(__dirname,'..','..','dist','schemas')],preGeneratedSchemaCache=new Map();import{wrapHandlerWithErrorShape,dispatchWithHarness,withTimeout}from'./wrap.js';import{sanitizeToolDispatchResult}from'./sanitize-output.js';import{getStartupUpgradeNotice,upgradePolicyPath}from'./upgrade-check.js';import{classifyError,normalizeErrorMessage}from'../schema/call/semantic.js';import{arbNestingExamplesForSchemaErrors}from'../knowledge/arb-operation-face.js';import{catalogFieldsFor}from'./error-catalog.js';import{unknownOutcomeFields}from'./shared.js';import{findLatin1Mojibake,mojibakeBlockResult}from'./transport-integrity.js';import{ONCHAIN_TOOLS}from'./registry/onchain.js';import{LOCAL_TOOLS}from'./registry/local.js';import{FILE_TOOLS}from'./registry/files.js';import{MESSENGER_TOOLS}from'./registry/messenger.js';import{QUERY_TOOLS}from'./registry/query.js';import{BRIDGE_TOOLS}from'./registry/bridge.js';import{CONFIG_TOOLS}from'./registry/config.js';import{EVALUATION_TOOLS}from'./registry/evaluation.js';import{IDENTITY_TOOLS}from'./registry/identity.js';import{BUSINESS_TOOLS}from'./registry/business.js';import{AGENT_TOOLS}from'./registry/agent.js';import{MONITOR_TOOLS}from'./registry/monitor.js';import{INTERACTION_TOOLS}from'./registry/interaction.js';export{monitorEventStore,MonitorEventStore,monitorEventId}from'../monitor/EventStore.js';export{monitorLoop,MonitorLoop}from'../monitor/MonitorLoop.js';export{MONITOR_CAPTURE_TYPES}from'../monitor/normalize.js';export{NETWORK_FIELD_BY_QUERY}from'./handlers/query.js';export{resolveGateControls,resolveEffectiveOverrides}from'../persona/index.js';export{SYSTEM_OVERRIDE_SETTINGS}from'../persona/index.js';export const TOOL_REGISTRY=[...ONCHAIN_TOOLS,...LOCAL_TOOLS,...FILE_TOOLS['slice'](0x0,0x1),...MESSENGER_TOOLS,...FILE_TOOLS['slice'](0x1),...QUERY_TOOLS,...BRIDGE_TOOLS,...CONFIG_TOOLS,...EVALUATION_TOOLS,...IDENTITY_TOOLS,...BUSINESS_TOOLS,...AGENT_TOOLS,...MONITOR_TOOLS,...INTERACTION_TOOLS];export const TOOL_REGISTRY_MAP=new Map(TOOL_REGISTRY['map'](a=>[a['name'],a]));const derivedOutputSchemaCache=new Map();function deriveToolOutputSchema(a){const b=derivedOutputSchemaCache['get'](a);if(b)return b;const c=TOOL_REGISTRY_MAP['get'](a),d=c?.['config']['outputSchema'];if(!c||!d)return null;const e={'$schema':'http://json-schema.org/draft-07/schema#','$id':'https://wowok.net/schemas/'+a+'.output.json','title':c['config']['title'],'description':c['config']['description'],...zodToJsonSchemaSafe(d,a)};return derivedOutputSchemaCache['set'](a,e),e;}registerOutputSchemaResolver(deriveToolOutputSchema);export const SUB_TOOL_COUNT=TOOL_REGISTRY['length'];const SUB_TOOL_NAMES=TOOL_REGISTRY['map'](a=>a['name']),WowokToolRuntimeSchema=fromJsonSchema({'type':'object'}),WowokToolDisplaySchema=z['object']({'tool':z['enum'](SUB_TOOL_NAMES)['optional']()['describe']('The\x20sub-tool\x20to\x20execute.\x20Each\x20sub-tool\x20has\x20its\x20own\x20parameter\x20schema.'),'data':z['record'](z['string'](),z['unknown']())['optional']()['describe']('Sub-tool\x20specific\x20parameters.\x20If\x20validation\x20fails,\x20the\x20response\x20includes\x20the\x20correct\x20schema\x20for\x20this\x20sub-tool\x20—\x20read\x20it,\x20fix\x20your\x20params,\x20and\x20retry.'),'submission':z['record'](z['string'](),z['unknown']())['optional']()['describe']('Guard\x20submission\x20slots\x20(top-level\x20placement,\x20sibling\x20of\x20data/env).\x20Alternative:\x20place\x20inside\x20data.'),'env':z['record'](z['string'](),z['unknown']())['optional']()['describe']('Environment\x20(account/network/confirmed/...).\x20Top-level\x20placement\x20is\x20folded\x20into\x20data.env.'),'idempotency_key':z['string']()['max'](0x80)['optional']()['describe']('Caller-declared\x20idempotency\x20key\x20for\x20a\x20write\x20(1-128\x20chars,\x20on-chain\x20bound).\x20Top-level\x20placement\x20is\x20folded\x20into\x20data.idempotency_key.\x20Use\x20one\x20for\x20every\x20fund-moving\x20call\x20you\x20might\x20have\x20to\x20replay:\x20an\x20unknown-outcome\x20retry\x20under\x20the\x20SAME\x20key\x20is\x20HELD\x20by\x20the\x20dispatch\x20gate\x20until\x20the\x20outcome\x20is\x20verified,\x20which\x20is\x20what\x20makes\x20verify-before-retry\x20mechanical\x20instead\x20of\x20a\x20matter\x20of\x20discipline.'),'tool_name':z['enum'](SUB_TOOL_NAMES)['optional']()['describe']('DEPRECATED\x20alias\x20for\x20\x27tool\x27.\x20Use\x20\x27tool\x27\x20instead.'),'args':z['record'](z['string'](),z['unknown']())['optional']()['describe']('DEPRECATED\x20alias\x20for\x20\x27data\x27.\x20Use\x20\x27data\x27\x20instead.'),'name':z['enum'](SUB_TOOL_NAMES)['optional']()['describe']('DEPRECATED\x20alias\x20for\x20\x27tool\x27.\x20Use\x20\x27tool\x27\x20instead.'),'params':z['record'](z['string'](),z['unknown']())['optional']()['describe']('DEPRECATED\x20alias\x20for\x20\x27data\x27.\x20Use\x20\x27data\x27\x20instead.')})['describe']('WoWok\x20unified\x20tool\x20input.\x20Call\x20with\x20{\x20tool:\x20\x22<sub-tool>\x22,\x20data:\x20{<params>}\x20}.\x20'+'Aliases:\x20tool_name/name→tool,\x20args/params→data.'),SUB_TOOL_LIST=TOOL_REGISTRY['map'](a=>'\x20\x20'+a['name']+'\x20—\x20'+a['config']['summary'])['join']('\x0a'),SKILLS_MISMATCH_POINTER='Structured\x20role-based\x20guidance\x20(WHEN\x20and\x20in\x20what\x20ORDER\x20to\x20use\x20WoWok\x20sub-tools)\x20is\x20available\x20via\x20the\x20WoWok\x20Skills:\x20install\x20with\x20\x22npm\x20install\x20-g\x20@wowok'+'/skills\x22\x20(verify\x20with\x20\x22wowok-skills\x20doctor\x22),\x20or\x20fetch\x20orientation\x20now\x20via\x20wowok_buildin_info\x20info=\x22getting\x20started\x22.';function schemaMismatchHint(a){return'Fix\x20your\x20parameters\x20based\x20on\x20the\x20schema\x20below\x20and\x20retry.\x20CACHE\x20THIS\x20SCHEMA\x20for\x20future\x20'+a+'\x20calls\x20—\x20you\x20don\x27t\x20need\x20to\x20query\x20it\x20again.\x0a'+SKILLS_MISMATCH_POINTER;}const WOWOK_TOOL_DESCRIPTION=['WoWok\x20MCP\x20unified\x20interface.\x20Call\x20with\x20{\x20tool:\x20\x22<sub-tool>\x22,\x20data:\x20{<params>}\x20}.','','\x20\x20▶\x20START\x20HERE\x20—\x20WoWok\x20Skills\x20(recommended):','\x20\x20\x20\x20Role-based\x20playbooks\x20(onboarding,\x20building,\x20buying,\x20fulfillment,\x20arbitration,\x20governance)','\x20\x20\x20\x20sit\x20ON\x20TOP\x20of\x20this\x20MCP\x20and\x20materially\x20reduce\x20failed\x20calls\x20by\x20telling\x20you\x20WHEN\x20and\x20in\x20what','\x20\x20\x20\x20ORDER\x20to\x20use\x20the\x2030+\x20sub-tools\x20below.\x20One\x20command\x20installs\x20them\x20into\x20every\x20detected\x20AI','\x20\x20\x20\x20client\x20AND\x20registers\x20this\x20MCP\x20server\x20(idempotent\x20postinstall):','\x20\x20\x20\x20\x20\x20npm\x20install\x20-g\x20@wowok'+'/skills','\x20\x20\x20\x20Verify:\x20wowok-skills\x20doctor\x20\x20\x20Repair\x20an\x20old\x20install:\x20wowok-skills\x20init\x20--force','\x20\x20\x20\x20Machine-readable\x20orientation\x20+\x20best-effort\x20detection\x20of\x20whether\x20skills\x20are\x20installed\x20here:','\x20\x20\x20\x20\x20\x20wowok({\x20tool:\x20\x22wowok_buildin_info\x22,\x20data:\x20{\x20info:\x20\x22getting\x20started\x22\x20}\x20})','\x20\x20▶\x20COLD\x20START:\x20the\x20FIRST\x20call\x20after\x20server\x20boot\x20can\x20take\x20~20\x20seconds\x20(server\x20bootstraps\x20via\x20npx).','\x20\x20\x20\x20Wait\x20for\x20it\x20—\x20a\x20timed-out\x20first\x20response\x20is\x20startup\x20latency,\x20not\x20a\x20broken\x20server,\x20and\x20never\x20a','\x20\x20\x20\x20reason\x20to\x20retry\x20a\x20write\x20transaction.\x20Later\x20calls\x20are\x20fast.','','\x20\x20tool:\x20name\x20of\x20the\x20sub-tool\x20(string)','\x20\x20data:\x20sub-tool\x20parameters\x20(object)','','\x20\x20Aliases\x20accepted\x20(deprecated):\x20tool_name/name\x20for\x20tool,\x20args/params\x20for\x20data.','\x20\x20Inline\x20params\x20also\x20accepted:\x20{\x20tool:\x20\x22<sub-tool>\x22,\x20<param1>:\x20...,\x20<param2>:\x20...\x20}','\x20\x20⚠️\x20RESERVED\x20KEYS\x20cannot\x20be\x20passed\x20inline:\x20name\x20/\x20tool_name\x20/\x20args\x20/\x20params\x20are\x20the','\x20\x20deprecated\x20aliases\x20themselves\x20—\x20an\x20inline\x20\x27name\x27\x20is\x20consumed\x20as\x20the\x20tool\x20alias\x20and','\x20\x20never\x20reaches\x20the\x20sub-tool.\x20Pass\x20such\x20fields\x20inside\x20data\x20instead.','','\x20\x20EXAMPLE:\x20wowok({\x20tool:\x20\x22schema_query\x22,\x20data:\x20{\x20action:\x20\x22get\x22,\x20name:\x20\x22onchain_operations\x22\x20}\x20})','\x20\x20EXAMPLE:\x20wowok({\x20tool:\x20\x22wowok_buildin_info\x22,\x20data:\x20{\x20info:\x20\x22mainnet\x20bridge\x20tokens\x22\x20}\x20})','\x20\x20EXAMPLE\x20(inline\x20params):\x20wowok({\x20tool:\x20\x22query_toolkit\x22,\x20query_type:\x20\x22account_list\x22\x20})','','Available\x20sub-tools\x20('+SUB_TOOL_COUNT+'):',SUB_TOOL_LIST,'','SCHEMA-GATED\x20EXECUTION:','\x20\x20If\x20your\x20parameters\x20don\x27t\x20match\x20the\x20sub-tool\x27s\x20schema,\x20the\x20response\x20will\x20include:','\x20\x20\x20\x20result.status\x20=\x20\x22schema_mismatch\x22','\x20\x20\x20\x20result.errors\x20=\x20specific\x20validation\x20errors\x20(field\x20path\x20+\x20expected\x20type)','\x20\x20\x20\x20result.hint\x20=\x20instructions\x20to\x20fix\x20and\x20retry','\x20\x20\x20\x20schema.input\x20=\x20the\x20correct\x20JSON\x20schema\x20for\x20the\x20sub-tool','\x20\x20\x20\x20schema.tool\x20=\x20which\x20sub-tool\x20this\x20schema\x20belongs\x20to','\x20\x20Read\x20the\x20schema,\x20fix\x20your\x20params,\x20and\x20retry.\x20This\x20is\x20normal\x20—\x20no\x20need\x20to\x20call\x20schema_query\x20separately.','','SCHEMA\x20CACHING:','\x20\x20Each\x20sub-tool\x20has\x20a\x20DIFFERENT\x20schema.\x20When\x20you\x20receive\x20a\x20schema\x20in\x20a\x20mismatch\x20response:','\x20\x20\x20\x201.\x20Read\x20the\x20schema\x20carefully','\x20\x20\x20\x202.\x20Fix\x20your\x20parameters','\x20\x20\x20\x203.\x20Retry\x20the\x20call','\x20\x20\x20\x204.\x20CACHE\x20the\x20schema\x20in\x20your\x20context\x20for\x20future\x20calls\x20to\x20the\x20SAME\x20sub-tool','\x20\x20You\x20should\x20only\x20need\x20to\x20see\x20each\x20sub-tool\x27s\x20schema\x20once\x20per\x20conversation.','','ON-CHAIN\x20BUSINESS\x20INTELLIGENCE\x20(query_toolkit,\x20READ-ONLY\x20—\x20no\x20local\x20project\x20entity):','\x20\x20query_toolkit\x20query_type=\x27service_panorama\x27\x20→\x20ONE-CALL\x20full\x20Service\x20context\x20(workflow\x20graph,\x20guards,\x20supply\x20chain,\x20orders)','\x20\x20query_toolkit\x20query_type=\x27machine_panorama\x27\x20→\x20Machine\x20context\x20(head\x20+\x20fields\x20+\x20workflow\x20graph\x20+\x20Progress\x20list)','\x20\x20query_toolkit\x20query_type=\x27object_panorama\x27\x20→\x20detail\x20panorama\x20for\x20Progress/Demand/Order/Arb/Repository','\x20\x20query_toolkit\x20query_type=\x27review_pack\x27\x20→\x20typed\x20ReviewPack\x20for\x20the\x20client\x27s\x20generic\x20ReviewPackRenderer','\x20\x20query_toolkit\x20query_type=\x27assemble_context\x27\x20→\x20semantic\x20context\x20assembly\x20from\x20on-chain\x20objects','\x20\x20query_toolkit\x20query_type=\x27reverse_map\x27\x20→\x20deterministic\x20L4→L1\x20business\x20report\x20(merchant\x20profile\x20/\x20user\x20risk\x20/\x20game\x20theory)','\x20\x20query_toolkit\x20query_type=\x27participation_radar\x27\x20→\x20in-flight\x20order\x20participation\x20analysis\x20for\x20ONE\x20account','\x20\x20query_toolkit\x20query_type=\x27order_aggregate\x27\x20→\x20CROSS-ORDER\x20aggregate\x20(count\x20+\x20exact\x20amount\x20sums\x20per\x20service/machine/owner,\x20funding-target\x20checks\x20like\x20\x273\x20x\x206\x20>=\x2018\x27)','\x20\x20query_toolkit\x20query_type=\x27relationship_profile\x27\x20→\x20business\x20relationship\x20graph\x20for\x20ONE\x20account\x20(power/interest/value-flow\x20edges,\x20K3/19)','\x20\x20industry_pack_operation\x20action=\x27recommend_industry\x27/\x27list_modes\x27\x20→\x20industry\x20mode\x20registry\x20(GLM6/92\x20§E)','\x20\x20strategy_review_operation\x20action=\x27collect\x27/\x27review\x27/\x27list_snapshots\x27\x20→\x20posture-weighted\x20scorecard\x20+\x20periodic\x20review\x20(current-layer\x20proposals\x20only)','\x20\x20goal_operation\x20action=\x27merchant_guide\x27\x20→\x2010-step\x20merchant\x20onboarding\x20wizard\x20(never\x20executes\x20on-chain\x20ops)','\x20\x20benchmark_migration_operation\x20→\x20industry\x20archetype\x20templates\x20+\x20one-click\x20competitor\x20migration:','\x20\x20\x20\x20template_list\x20/\x20template_get\x20/\x20template_scan\x20(pre-deploy\x20risk\x20scan)\x20/\x20template_generate\x20(creation\x20plan)','\x20\x20\x20\x20migration_import\x20(store\x20URL/description\x20→\x20MigrationLog)\x20→\x20migration_review\x20(user\x20confirmation)\x20→\x20migration_apply\x20(scan-first\x20creation\x20plan;\x20testnet\x20default)','','═══════════════════════════════════════════════════════════════','BUILD/BUY\x20POLICY\x20(no\x20local\x20projects\x20—\x20chain\x20state\x20is\x20the\x20source\x20of\x20truth):','═══════════════════════════════════════════════════════════════','','CASE\x201\x20—\x20COMPLEX\x20REQUIREMENT\x20(user\x20wants\x20to\x20build/deploy\x20a\x20full\x20service):','\x20\x20→\x20Plan\x20with\x20goal_operation\x20action=\x27analyze_intent\x27\x20(C1:\x20intent\x20→\x20per-object\x20puzzle\x20snapshots\x20+\x20creation\x20order),','\x20\x20\x20\x20then\x20\x27aggregate_risks\x27\x20(C2:\x20cross-object\x20risk\x20calibration)\x20and\x20\x27trace_substeps\x27\x20(C3:\x20substep\x20DAG\x20coherence).','\x20\x20→\x20Alternatively\x20run\x20goal_operation\x20action=\x27merchant_guide\x27\x20for\x20a\x20guided\x2010-step\x20onboarding\x20plan.','\x20\x20→\x20If\x20the\x20user\x20wants\x20to\x20build\x20LIKE\x20an\x20industry\x20archetype\x20(\x27build\x20like\x20the\x20retail\x20leader\x20model\x27)\x20or','\x20\x20\x20\x20MIGRATE\x20an\x20existing\x20store\x20(hands\x20over\x20a\x20store\x20URL/description),\x20use\x20benchmark_migration_operation','\x20\x20\x20\x20(template_list\x20→\x20template_scan\x20→\x20template_generate,\x20or\x20migration_import\x20→\x20migration_review\x20→\x20migration_apply).','\x20\x20→\x20Create\x20objects\x20via\x20onchain_operations,\x20then\x20publish\x20the\x20Service.','','CASE\x202\x20—\x20SINGLE\x20OBJECT\x20CREATION\x20(user\x20wants\x20one\x20specific\x20object):','\x20\x20→\x20Create\x20directly\x20via\x20onchain_operations.\x20No\x20project\x20bookkeeping\x20needed.','','CASE\x203\x20—\x20CONSUMER\x20FLOW\x20(user\x20wants\x20to\x20buy/evaluate\x20a\x20service):','\x20\x20→\x20query_toolkit\x20query_type=\x27service_panorama\x27\x20or\x20\x27review_pack\x27\x20for\x20the\x20detail\x20page,','\x20\x20\x20\x20\x27reverse_map\x27\x20for\x20the\x20deterministic\x20buy\x20report\x20(add\x20Machine/Allocation\x20for\x20refund-path\x20detection),','\x20\x20\x20\x20then\x20onchain_operations\x20service_buy.','','CASE\x204\x20—\x20SIMPLE\x20QUERY\x20(user\x20wants\x20to\x20check\x20object\x20info,\x20balance,\x20etc.):','\x20\x20→\x20Proceed\x20directly\x20with\x20the\x20query.','═══════════════════════════════════════════════════════════════']['join']('\x0a');function joinIssuePath(a){return a['length']>0x0?a['map'](b=>typeof b==='number'?'['+b+']':String(b))['join']('.')['replace']('.[','['):'(root)';}function unionVariantErrors(a){const b=a,d=b['errors']??b['unionErrors']??b['issues'];if(!Array['isArray'](d))return[];const e=[];for(const f of d){if(!f)continue;if(Array['isArray'](f))f['every'](g=>!!g&&typeof g==='object'&&'code'in g)&&e['push']({'issues':f});else typeof f==='object'&&Array['isArray'](f['issues'])&&e['push']({'issues':f['issues']});}return e;}function variantScore(a){let b=0x0;for(const c of a['issues']){b+=0xa;const d=c;if(c['code']==='invalid_type')d['received']==='undefined'?b+=0x14:b-=0x5;else{if(c['code']==='unrecognized_keys'){const e=Array['isArray'](d['keys'])?d['keys']['length']:0x1;b+=0xf+e*0x5;}else{if(c['code']==='invalid_union'){const f=unionVariantErrors(c);if(f['length']>0x0)b+=Math['min'](...f['map'](variantScore));}}}}return b;}function variantSummary(a,b=0x3){const c=[];for(const e of a['issues']){const f=e;if(e['code']==='unrecognized_keys'){const g=Array['isArray'](f['keys'])?f['keys']['join'](',\x20'):'?';c['push']('unknown\x20field(s):\x20'+g);}else e['code']==='invalid_type'&&f['received']==='undefined'?c['push']('missing:\x20'+joinIssuePath([...e['path']])):c['push'](e['code']+'\x20at\x20'+joinIssuePath([...e['path']]));if(c['length']>=b)break;}const d=a['issues']['length']>b?'\x20(+'+(a['issues']['length']-b)+'\x20more)':'';return c['length']>0x0?c['join'](';\x20')+d:'shape\x20mismatch';}function resolveIssuePath(a,b){if(a['length']===0x0)return joinIssuePath(b);const c=b['length']>=a['length']&&a['every']((d,e)=>b[e]===d);return joinIssuePath(c?b:[...a,...b]);}function subToolRoutingHint(a,b){if(a!=='query_type')return'';const c=b['toLowerCase']();if(c['startsWith']('onchain_table'))return'\x20—\x20ROUTING:\x20table\x20/\x20table-item\x20queries\x20belong\x20to\x20the\x20SEPARATE\x20\x27onchain_table_data\x27\x20tool\x20—\x20call\x20onchain_table_data\x20with\x20this\x20query_type\x20(and\x20its\x20parent/address\x20params)\x20instead\x20of\x20query_toolkit';return'';}function matchedVariantLegalKeys(a){if(!a||typeof a!=='object')return[];const b=a['properties'];if(!b||typeof b!=='object'||Array['isArray'](b))return[];return Object['keys'](b)['sort']();}function absoluteIssuePath(a,b){const c=a['length']>0x0&&b['length']>=a['length']&&a['every']((d,e)=>b[e]===d);return c?b:[...a,...b];}function pushFlattened(a,b,c,d,e=[]){for(const f of a['issues']){if(f['code']==='invalid_union'){const g=f,h=[...f['path']],i=Array['isArray'](g['errors'])?g['errors']['length']:Array['isArray'](g['unionErrors'])?g['unionErrors']['length']:0x0,j=unionVariantErrors(f);if(j['length']===0x0){const o=resolveIssuePath(e,h),p=c!==undefined?extractValueAtPath(c,absoluteIssuePath(e,h)):undefined,q=p!==undefined;let r;if(i>0x0)r=(q?'value\x20does\x20not\x20match\x20any\x20of\x20the\x20union\x27s':'missing\x20required\x20union\x20field\x20—\x20no\x20value\x20provided;\x20union\x20accepts')+'\x20'+i+'\x20shape(s);\x20see\x20the\x20schema\x20preview\x20for\x20the\x20accepted\x20fields';else{if(q&&p&&typeof p==='object'&&!Array['isArray'](p)){const s=p,t=['operation_type','query_type','type','action','op']['find'](u=>typeof s[u]==='string');r=t?'discriminator\x20\x27'+t+'\x27=\x22'+String(s[t])+'\x22\x20does\x20not\x20match\x20any\x20variant;\x20check\x20the\x20\x22Valid\x20\x27'+t+'\x27\x20values\x22\x20line\x20in\x20the\x20schema\x20preview\x20below'+subToolRoutingHint(t,String(s[t])):'value\x20does\x20not\x20match\x20any\x20union\x20variant\x20(no\x20per-variant\x20details\x20available);\x20see\x20the\x20schema\x20preview';}else{if(q&&typeof p==='string'&&h['length']>0x0){const u=String(h[h['length']-0x1]);r='discriminator\x20\x27'+u+'\x27=\x22'+p+'\x22\x20does\x20not\x20match\x20any\x20variant;\x20check\x20the\x20\x22Valid\x20\x27'+u+'\x27\x20values\x22\x20line\x20in\x20the\x20schema\x20preview\x20below'+subToolRoutingHint(u,p);}else r='value\x20does\x20not\x20match\x20any\x20union\x20variant\x20(no\x20per-variant\x20details\x20available);\x20see\x20the\x20schema\x20preview';}}b['push']({'kind':'header','path':o,'code':'invalid_union','message':r});d&&(b[b['length']-0x1]={'kind':'header','path':o+'\x20['+d+']','code':'invalid_union','message':r});continue;}const k=j['map']((v,w)=>({'idx':w,'err':v,'score':variantScore(v)}))['sort']((v,w)=>v['score']-w['score']),l=k[0x0],m=k['slice'](0x1)['map'](v=>'variant\x20'+(v['idx']+0x1)+':\x20'+variantSummary(v['err']))['join']('\x20|\x20');b['push']({'kind':'header','path':resolveIssuePath(e,h),'code':'invalid_union','message':'no\x20union\x20variant\x20matched\x20('+j['length']+'\x20checked);\x20closest\x20=\x20variant\x20'+(l['idx']+0x1)+'\x20—\x20it\x20fails\x20on:\x20'+variantSummary(l['err'])+(m?'\x20—\x20others:\x20'+m:'')});const n=h['length']>0x0&&h['every']((v,w)=>e[w]===v)?h:[...e,...h];pushFlattened(l['err'],b,c,'variant\x20'+(l['idx']+0x1),n);}else b['push']({'kind':'issue','issue':f,'variantTag':d,'pathPrefix':e});}}function flattenZodIssues(a,b){const c=[];pushFlattened(a,c,b);const d=(f,g)=>{if(f['kind']!=='issue'||g['kind']!=='issue')return![];const h=absoluteIssuePath(f['pathPrefix']??[],f['issue']['path']),i=absoluteIssuePath(g['pathPrefix']??[],g['issue']['path']);return i['length']>h['length']&&h['every']((j,l)=>i[l]===j);},e=c['filter'](f=>{if(f['kind']!=='issue'||f['issue']['code']!=='unrecognized_keys')return!![];return!c['some'](g=>g!==f&&g['kind']==='issue'&&g['issue']['code']!=='unrecognized_keys'&&d(f,g));});return e;}const RECEIVED_VALUE_MAX=0x1f4;function truncateEcho(a){return a['length']>RECEIVED_VALUE_MAX?a['slice'](0x0,RECEIVED_VALUE_MAX)+'...(truncated,\x20'+(a['length']-RECEIVED_VALUE_MAX)+'\x20more\x20chars)':a;}function formatZodErrors(a,b){return flattenZodIssues(a,b)['map'](c=>{if(c['kind']==='header')return c['path']+'\x20['+c['code']+']:\x20'+c['message'];const d=c['issue'],e=resolveIssuePath(c['pathPrefix']??[],d['path']),f=d['code'],g=d['message'];let h='';const i=d;if(f==='invalid_type'){const l=i['expected'],m=i['received'];typeof l==='string'&&typeof m==='string'&&(h='\x20(expected:\x20'+l+';\x20received:\x20'+m+')');}else{if(f==='invalid_value'){const n=i['expected'];if(n!==undefined){const o=typeof n==='string'?n:JSON['stringify'](n);h='\x20(expected:\x20'+o['slice'](0x0,0x3c)+')';}}else{if(f==='too_big'||f==='too_small'){const p=i['maximum']??i['minimum'],q=i['origin'];p!==undefined&&q!==undefined&&(h='\x20('+q+':\x20'+p+')');}}}const j=extractValueAtPath(b,absoluteIssuePath(c['pathPrefix']??[],d['path']));if(j!==undefined){const r=typeof j==='string'?'\x22'+truncateEcho(j)+'\x22':typeof j==='object'?truncateEcho(JSON['stringify'](j)):String(j);!h['includes']('received:')&&(h+='\x20(received\x20value:\x20'+r+')');}const k=c['variantTag']?'\x20['+c['variantTag']+']':'';return''+e+k+'\x20['+f+']:\x20'+g+h;});}function generateSuggestion(a,b,c){const d=b;switch(a){case'invalid_type':{const e=d['expected'];if(e==='number'&&typeof c==='string')return'Convert\x20to\x20number:\x20'+Number(c);if(e==='string')return'Wrap\x20in\x20quotes\x20or\x20call\x20String(...)';if(e==='array')return'Wrap\x20in\x20array:\x20['+JSON['stringify'](c)+']';if(e==='object')return'Provide\x20an\x20object,\x20not\x20a\x20primitive';return'Convert\x20value\x20to\x20'+(e??'the\x20expected\x20type');}case'invalid_enum_value':{const f=d['options'],g=Array['isArray'](f)?f['map'](h=>JSON['stringify'](h))['join']('\x20|\x20'):String(f);return'Use\x20one\x20of:\x20'+g;}case'invalid_literal':{const h=d['expected'];return'Use\x20the\x20exact\x20value:\x20'+JSON['stringify'](h);}case'too_small':{const i=d['minimum'],j=d['type'];if(j==='array')return'Add\x20at\x20least\x20'+i+'\x20element(s)\x20to\x20the\x20array';if(j==='string')return'String\x20must\x20be\x20at\x20least\x20'+i+'\x20character(s)\x20long';if(j==='number')return'Use\x20a\x20value\x20>=\x20'+i;return'Value\x20must\x20be\x20>=\x20'+i;}case'too_big':{const k=d['maximum'],l=d['type'];if(l==='array')return'Reduce\x20array\x20to\x20at\x20most\x20'+k+'\x20element(s)';if(l==='string')return'Shorten\x20string\x20to\x20at\x20most\x20'+k+'\x20character(s)';if(l==='number')return'Use\x20a\x20value\x20<=\x20'+k;return'Value\x20must\x20be\x20<=\x20'+k;}case'unrecognized_keys':{const m=d['keys'];return'Remove\x20unknown\x20field(s):\x20'+(m??[])['join'](',\x20')+'.\x20Check\x20the\x20schema\x20for\x20valid\x20field\x20names.';}case'invalid_union':{return'Value\x20does\x20not\x20match\x20any\x20of\x20the\x20union\x20variants\x20—\x20see\x20the\x20\x22closest\x20variant\x22\x20line\x20above\x20for\x20the\x20concrete\x20field\x20error(s).';}case'invalid_string':{const n=d['validation'];if(n==='url')return'Provide\x20a\x20valid\x20URL\x20string';if(n==='email')return'Provide\x20a\x20valid\x20email\x20string';if(n==='uuid')return'Provide\x20a\x20valid\x20UUID\x20string';if(n==='regex')return'String\x20does\x20not\x20match\x20the\x20required\x20pattern';return'Provide\x20a\x20valid\x20string\x20matching\x20the\x20validation:\x20'+(n??'unknown');}case'invalid_date':{return'Provide\x20a\x20valid\x20Date\x20object\x20or\x20ISO\x20date\x20string';}case'not_finite':{return'Use\x20a\x20finite\x20number\x20(not\x20Infinity\x20or\x20NaN)';}case'invalid_arguments':{return'Arguments\x20do\x20not\x20match\x20the\x20expected\x20schema';}case'invalid_return_type':{return'Return\x20type\x20does\x20not\x20match\x20the\x20expected\x20schema';}case'custom':{return'Custom\x20validation\x20failed\x20—\x20see\x20the\x20field\x27s\x20description\x20in\x20the\x20schema';}default:{return'Fix\x20the\x20value\x20at\x20\x27'+b['path']['join']('.')+'\x27\x20based\x20on\x20the\x20schema';}}}function formatZodErrorsStructured(a,b){return flattenZodIssues(a,b)['flatMap'](c=>{if(c['kind']==='header'){const l=c['message']['match'](/closest = variant (\d+)/),m=c['message']['includes']('missing\x20required\x20union\x20field'),n=c['message']['includes']('does\x20not\x20match\x20any\x20variant'),o=l?'Fix\x20the\x20field\x20error(s)\x20listed\x20for\x20variant\x20'+l[0x1]+'\x20below.':m?'Provide\x20this\x20required\x20field\x20with\x20one\x20of\x20the\x20accepted\x20shapes,\x20and\x20check\x20field-name\x20spelling\x20against\x20the\x20schema\x20preview.':n?'No\x20union\x20variant\x20accepts\x20this\x20discriminator\x20—\x20pick\x20a\x20value\x20from\x20the\x20\x27Valid\x20...\x20values\x27\x20line\x20in\x20the\x20schema\x20preview\x20below.\x20If\x20the\x20value\x20belongs\x20to\x20a\x20sub-tool\x20(e.g.\x20onchain_table*\x20→\x20onchain_table_data),\x20resend\x20it\x20to\x20that\x20tool.':'No\x20union\x20variant\x20matched\x20—\x20check\x20the\x20schema\x20preview\x20below\x20for\x20the\x20accepted\x20shapes.';return[{'path':c['path'],'code':c['code'],'message':c['message'],'suggestion':o}];}const d=c['issue'],e=resolveIssuePath(c['pathPrefix']??[],d['path']),f=d['code'],g=c['variantTag']?d['message']+'\x20(closest\x20union\x20variant:\x20'+c['variantTag']+')':d['message'],h=d;let i;if(f==='invalid_type'){const p=h['expected'],q=h['received'];typeof p==='string'&&typeof q==='string'&&(i=p);}else{if(f==='invalid_value'){const r=h['expected'],s=h['options'];if(Array['isArray'](s))i=s['map'](t=>JSON['stringify'](t))['join']('\x20|\x20');else r!==undefined&&(i=typeof r==='string'?r:JSON['stringify'](r));}else{if(f==='too_big'||f==='too_small'){const t=h['maximum']??h['minimum'];t!==undefined&&(i=String(t));}}}const j=extractValueAtPath(b,absoluteIssuePath(c['pathPrefix']??[],d['path'])),k=generateSuggestion(f,d,j);return[{'path':e,'code':f,'message':g,'expected':i,'received_value':truncateReceivedValue(j),'suggestion':k}];});}function extractValueAtPath(a,b){if(a===undefined||a===null||b['length']===0x0)return undefined;let c=a;for(const d of b){if(c===undefined||c===null)return undefined;if(typeof d==='number'){if(!Array['isArray'](c))return undefined;c=c[d];}else{if(typeof c!=='object')return undefined;c=c[d];}}return c;}const RECEIVED_VALUE_MAX_CHARS=0xc8;function truncateReceivedValue(a){if(a===undefined)return undefined;if(typeof a==='string')return a['length']<=RECEIVED_VALUE_MAX_CHARS?a:a['slice'](0x0,RECEIVED_VALUE_MAX_CHARS)+'…(truncated,\x20'+a['length']+'\x20chars)';let b;try{b=JSON['stringify'](a)??String(a);}catch{b=String(a);}if(b['length']<=RECEIVED_VALUE_MAX_CHARS)return a;return b['slice'](0x0,RECEIVED_VALUE_MAX_CHARS)+'…(truncated,\x20'+b['length']+'\x20chars)';}const MAX_MISMATCH_ERRORS=0xa;function capMismatchErrors(a,b){if(a['length']>MAX_MISMATCH_ERRORS){const c=a['length']-MAX_MISMATCH_ERRORS;a['length']=MAX_MISMATCH_ERRORS,a['push']('…and\x20'+c+'\x20more\x20error(s)\x20truncated\x20(fix\x20the\x20listed\x20ones\x20first).');}if(b['length']>MAX_MISMATCH_ERRORS){const d=b['length']-MAX_MISMATCH_ERRORS;b['length']=MAX_MISMATCH_ERRORS,b['push']({'path':'(root)','code':'errors_truncated','message':d+'\x20additional\x20error(s)\x20truncated.','suggestion':'Fix\x20the\x20listed\x20errors\x20first\x20—\x20remaining\x20errors\x20frequently\x20disappear\x20once\x20the\x20first\x20ones\x20are\x20corrected.'});}}function zodTopLevelShape(a){let b=a;while(!![]){const e=b['_def'];if(!e)break;const f=e['typeName']==='ZodEffects'?e['schema']:e['out']??e['innerType'];if(!f||f===b)break;b=f;}const c=b['_def'],d=typeof c?.['shape']==='function'?c['shape']():c?.['shape'];return d&&typeof d==='object'?d:undefined;}function checkUnknownFields(a,b){const c=zodTopLevelShape(a);if(!c||typeof b!=='object'||b===null)return[];const d=Object['keys'](c),e=Object['keys'](b);return e['filter'](g=>!d['includes'](g));}function zodUnionAwareKeyCheck(a,b){let c=a;while(!![]){const g=c['_def'];if(!g)break;const h=g['typeName']==='ZodEffects'?g['schema']:g['out']??g['innerType'];if(!h||h===c)break;c=h;}const d=c['_def']?.['options']??[c];let e=![],f=![];for(const i of d){const j=zodTopLevelShape(i);if(!j)continue;if(b in j)e=!![];if('env'in j)f=!![];}return{'declared':e,'hasEnvSlot':f};}function zodBranchAwareDeclared(a,b,c){let d=a;while(!![]){const h=d['_def'];if(!h)break;const i=h['typeName']==='ZodEffects'?h['schema']:h['out']??h['innerType'];if(!i||i===d)break;d=i;}const e=d['_def'],f=e?.['options'];if(!f){const j=zodTopLevelShape(d);return j!==undefined&&b in j;}const g=e?.['discriminator'];if(typeof g==='string'&&c[g]!==undefined)for(const k of f){const l=zodTopLevelShape(k);if(!l)continue;const m=l[g]?.['_def']?.['value'];if(m===c[g])return b in l;}return f['some'](n=>{const p=zodTopLevelShape(n);return p!==undefined&&b in p;});}function extractRelevantSchema(a,b,c){if(b==='onchain_operations'&&typeof c==='object'&&c!==null){const d=c['operation_type'];if(typeof d==='string'){const e='onchain_operations_'+d,f=loadPreGeneratedSchema(e);if(f)return f;}}return a;}function isSchemaValidationError(a){return a['startsWith']('Unknown\x20')&&a['includes']('field')||a['includes']('expected')&&a['includes']('received')||a['includes']('Invalid\x20input')||a['includes']('Required')||a['includes']('validation\x20failed\x20with');}function variantConstValue(a,b){const c=a['properties'];if(!c||typeof c!=='object')return undefined;const d=c[b];if(!d)return undefined;if(typeof d['const']==='string')return d['const'];if(Array['isArray'](d['enum'])&&d['enum']['length']===0x1&&typeof d['enum'][0x0]==='string')return d['enum'][0x0];return undefined;}function pickUnionVariant(a,b){const c=['query_type','operation_type','type'],d=b&&typeof b==='object'&&!Array['isArray'](b)?Object['keys'](b):[],e=[...c,...d['filter'](f=>!c['includes'](f))];for(const f of e){const g=b?.[f];if(typeof g!=='string')continue;for(let h=0x0;h<a['length'];h++){const j=a[h];if(j&&typeof j==='object'&&variantConstValue(j,f)===g)return{'variant':j,'index':h,'discriminator':f,'matched':!![]};}}for(let k=0x0;k<a['length'];k++){const l=a[k];if(l&&typeof l==='object'){const m=l;if(m['properties']&&typeof m['properties']==='object')return{'variant':m,'index':k,'matched':![]};}}return{'index':-0x1,'matched':![]};}function unionDiscriminatorValues(a,b){const c=[];for(const d of a){if(d&&typeof d==='object'){const e=variantConstValue(d,b);if(e!==undefined&&!c['includes'](e))c['push'](e);}}return c;}function inferDiscriminatorKey(a){if(!Array['isArray'](a)||a['length']===0x0)return undefined;const b=a['filter'](d=>!!d&&typeof d==='object'&&!!d['properties']);if(b['length']!==a['length']||b['length']===0x0)return undefined;const c=b[0x0]['properties'];for(const d of Object['keys'](c)){let e=!![];for(const f of b){if(variantConstValue(f,d)===undefined){e=![];break;}}if(e)return d;}return undefined;}const NESTED_REQUIRED_MAX_LINES=0x10;function nestedRequiredLines(a,b,c){if(c>0x2)return[];const d=[],e=Array['isArray'](b['required'])?b['required']['filter'](g=>typeof g==='string'):[];e['length']>0x0&&d['push']('\x20\x20\x20\x20\x20\x20Required\x20within\x20'+a+':\x20'+e['join'](',\x20'));const f=b['properties'];if(!f||typeof f!=='object'||c>=0x2)return d;for(const [g,h]of Object['entries'](f)){if(d['length']>=NESTED_REQUIRED_MAX_LINES){d['push']('\x20\x20\x20\x20\x20\x20(more\x20nested\x20required\x20fields\x20under\x20'+a+'\x20—\x20see\x20structuredContent\x20for\x20the\x20full\x20schema)');break;}if(!h||typeof h!=='object')continue;const i=h;if(!i['properties']||typeof i['properties']!=='object')continue;d['push'](...nestedRequiredLines(a+'.'+g,i,c+0x1));}return d;}export function buildSchemaPreview(a,b,c){try{const d=['Schema\x20preview\x20for\x20'+b+':'];let e,g=[],h='',i,j=-0x1,k,l=![];if(a['properties']&&typeof a['properties']==='object')e=a['properties'],g=Array['isArray'](a['required'])?a['required']:[],h=typeof a['description']==='string'?a['description']:'';else{if(Array['isArray'](a['oneOf'])||Array['isArray'](a['anyOf'])){i=a['oneOf']??a['anyOf'];const p=pickUnionVariant(i,c);j=p['index'],k=p['discriminator'],l=p['matched'];p['variant']&&(e=p['variant']['properties'],g=Array['isArray'](p['variant']['required'])?p['variant']['required']:[],h=typeof p['variant']['description']==='string'?p['variant']['description']:'');if(!e)return d['push']('\x20\x20(discriminated\x20union\x20with\x20'+i['length']+'\x20variants\x20—\x20see\x20structuredContent\x20for\x20full\x20schema)'),d['join']('\x0a');}}h&&h['length']>0x0&&h['length']<0xc8&&d['push']('\x20\x20'+h);if(!e)return d['push']('\x20\x20(no\x20properties\x20available\x20—\x20see\x20structuredContent\x20for\x20full\x20schema)'),d['join']('\x0a');const m=new Set(g),n=g['length']>0x0?g['join'](',\x20'):'(none)',o=Object['keys'](e)['filter'](q=>!m['has'](q))['join'](',\x20');d['push']('Required:\x20'+n);o&&d['push']('Optional:\x20'+o);d['push']('Fields:');for(const [q,r]of Object['entries'](e)){if(r&&typeof r==='object'){const s=r,t=describeSchemaType(s),u=m['has'](q)?'required':'optional';let v=typeof s['description']==='string'?s['description']:'';if(v['length']>0x78)v=v['slice'](0x0,0x75)+'...';let w='';if(s['properties']&&typeof s['properties']==='object'){const y=Object['keys'](s['properties']);y['length']>0x0&&(w='\x20{\x20'+y['slice'](0x0,0x8)['join'](',\x20')+(y['length']>0x8?',\x20...':'')+'\x20}');}if(s['items']&&typeof s['items']==='object'){const A=s['items'],B=describeSchemaType(A);w='\x20(array\x20of\x20'+B+')';}Array['isArray'](s['enum'])&&(w='\x20(enum:\x20'+s['enum']['slice'](0x0,0x6)['map'](C=>JSON['stringify'](C))['join'](',\x20')+(s['enum']['length']>0x6?',\x20...':'')+')');d['push']('\x20\x20-\x20'+q+'\x20('+t+',\x20'+u+')'+w+(v?'\x20—\x20'+v:''));const x=nestedRequiredLines(q,s,0x0);d['push'](...x);}}if(i&&i['length']>0x0){d['push']('');if(l&&k){const C=c&&typeof c==='object'?c:{},D=String(C[k]);d['push']('Matched\x20variant:\x20'+k+'=\x22'+D+'\x22\x20(variant\x20'+(j+0x1)+'\x20of\x20'+i['length']+').');}else{d['push']('Discriminated\x20union\x20with\x20'+i['length']+'\x20variants;\x20showing\x20variant\x20'+(j+0x1)+'\x20(no\x20matching\x20discriminator\x20value\x20in\x20input).');const E=k??inferDiscriminatorKey(i)??(b==='query_toolkit'?'query_type':'operation_type'),F=unionDiscriminatorValues(i,E);F['length']>0x0&&d['push']('Valid\x20\x27'+E+'\x27\x20values:\x20'+F['join'](',\x20'));}}if(b==='onchain_operations'&&typeof c==='object'&&c!==null){const G=c['operation_type'];typeof G==='string'&&(d['push'](''),d['push']('operation_type-specific\x20schema:\x20onchain_operations_'+G),d['push']('(Use\x20schema_query\x20with\x20action=\x27get\x27\x20and\x20name=\x27onchain_operations_'+G+'\x27\x20for\x20the\x20full\x20sub-schema.)'));}return d['join']('\x0a');}catch{return'Schema\x20preview\x20for\x20'+b+':\x20(unable\x20to\x20build\x20preview\x20—\x20see\x20structuredContent\x20for\x20full\x20schema)';}}function compactMismatchSchemaInput(a,b){const c=Array['isArray'](a['oneOf'])?a['oneOf']:Array['isArray'](a['anyOf'])?a['anyOf']:undefined;if(!c)return a;const d=pickUnionVariant(c,b);if(!d['matched']||!d['variant'])return fallbackUnionSchema(a,c,b);const e=d['variant'],{oneOf:f,anyOf:g,...h}=a,i=h['properties']&&typeof h['properties']==='object'?h['properties']:{},j=e['properties']&&typeof e['properties']==='object'?e['properties']:{},k=Array['isArray'](h['required'])?h['required']:[],l=Array['isArray'](e['required'])?e['required']:[];return{...h,...e['type']!==undefined?{'type':e['type']}:{},...e['additionalProperties']!==undefined?{'additionalProperties':e['additionalProperties']}:{},...e['description']!==undefined?{'description':e['description']}:{},'properties':{...i,...j},'required':[...new Set([...k,...l])]};}function fallbackUnionSchema(a,b,c){const d=inferDiscriminatorKey(b);if(!d)return a;const e=unionDiscriminatorValues(b,d);if(e['length']===0x0)return a;const {oneOf:f,anyOf:g,...h}=a,i=h['properties']&&typeof h['properties']==='object'?h['properties']:{},j=Array['isArray'](h['required'])?h['required']:[],k=c&&typeof c==='object'&&!Array['isArray'](c)?Object['keys'](c):[];return{...h,'properties':{...i,[d]:{'type':'string','enum':e,'description':k['includes'](d)?'Unknown\x20\x22'+d+'\x22\x20value\x20—\x20must\x20be\x20one\x20of\x20the\x20listed\x20values.\x20Per-variant\x20parameters:\x20schema_query\x20(action=\x27get\x27)':'Missing\x20\x22'+d+'\x22\x20—\x20set\x20it\x20to\x20one\x20of\x20the\x20listed\x20values.\x20Per-variant\x20parameters:\x20schema_query\x20(action=\x27get\x27)'}},'required':j['includes'](d)?j:[...j,d]};}function describeSchemaType(a){if(typeof a['type']==='string')return a['type'];if(Array['isArray'](a['type']))return a['type']['join']('|');if(a['$ref'])return'$ref';if(Array['isArray'](a['oneOf']))return'oneOf';if(Array['isArray'](a['anyOf']))return'anyOf';if(Array['isArray'](a['allOf']))return'allOf';if(a['enum'])return'enum';if(a['const'])return'const('+JSON['stringify'](a['const'])+')';return'object';}const MISMATCH_SCHEMA_MAX_DEPTH=0x18;function capSchemaDepth(a,b){if(b>=MISMATCH_SCHEMA_MAX_DEPTH){if(Array['isArray'](a))return'(depth-capped\x20—\x20use\x20schema_query\x20action=\x27get\x27\x20for\x20the\x20full\x20sub-schema)';if(a!==null&&typeof a==='object')return{'type':'object','description':'(depth-capped\x20—\x20use\x20schema_query\x20action=\x27get\x27\x20for\x20the\x20full\x20sub-schema)'};return a;}if(Array['isArray'](a))return a['map'](c=>capSchemaDepth(c,b+0x1));if(a!==null&&typeof a==='object'){const c={};for(const [d,e]of Object['entries'](a)){c[d]=capSchemaDepth(e,b+0x1);}return c;}return a;}export async function dispatchToolCall(a,b,c,d){return sanitizeToolDispatchResult(await dispatchToolCallRaw(a,b,c,d));}async function dispatchToolCallRaw(a,b,c,d){{const i=findLatin1Mojibake(b);if(i)return mojibakeBlockResult(i['path'],i['sample']);}if(a==='wowok')return handleWowok(b,c,d);const e=TOOL_REGISTRY_MAP['get'](a);if(!e)throw new Error('Unknown\x20tool:\x20'+a+'.\x20Available:\x20'+TOOL_REGISTRY['map'](j=>j['name'])['join'](',\x20'));if(e['applyRules']&&!c?.['skipRules']){const j=await withTimeout(Promise['resolve'](e['applyRules'](b)),e['timeoutMs']??0xea60,a);if(j)return j;}const f=dispatchWithHarness(e['handler'],a),g=e['timeoutMs']??0xea60,h=wrapHandlerWithErrorShape(f,g,a,e['errorShapeBuilder'],e['onTimeoutVerify']);return h(b,d);}const TOOL_FIELD_ALIASES=['tool','tool_name','name'],DATA_FIELD_ALIASES=['data','args','params','parameters'],RESERVED_FIELD_NAMES=new Set([...TOOL_FIELD_ALIASES,...DATA_FIELD_ALIASES]);function normalizeInput(a){const b=[];if(!a||typeof a!=='object'||Array['isArray'](a))return{'tool':undefined,'data':{},'normalizationNotes':['input\x20is\x20not\x20an\x20object']};const c=a;let d;for(const f of TOOL_FIELD_ALIASES){if(typeof c[f]==='string'&&c[f]){d=c[f];f!=='tool'&&b['push']('normalized\x20\x27'+f+'\x27\x20→\x20\x27tool\x27');break;}}let e;for(const g of DATA_FIELD_ALIASES){const h=c[g];if(h!==undefined&&h!==null&&typeof h==='object'&&!Array['isArray'](h)){e=h;g!=='data'&&b['push']('normalized\x20\x27'+g+'\x27\x20→\x20\x27data\x27');break;}}if(!e){const i={};let j=![];for(const k of Object['keys'](c)){!RESERVED_FIELD_NAMES['has'](k)&&(i[k]=c[k],j=!![]);}j?(e=i,b['push']('extracted\x20inline\x20params\x20→\x20\x27data\x27\x20(no\x20data\x20wrapper\x20was\x20provided)')):e={};}return{'tool':d,'data':e,'normalizationNotes':b};}const QUERY_ACCOUNT_FIELD_ALIASES={'account_balance':{'canonical':'name_or_address','aliases':['account','address']},'onchain_personal_profile':{'canonical':'account','aliases':['name_or_address','address']},'address_profile':{'canonical':'address','aliases':['name_or_address','account']}};function normalizeQueryToolkitAliases(a,b){if(typeof a['query_type']!=='string')return;const c=QUERY_ACCOUNT_FIELD_ALIASES[a['query_type']];if(!c)return;if(a[c['canonical']]!==undefined)return;for(const d of c['aliases']){if(a[d]!==undefined){a[c['canonical']]=a[d],delete a[d],b['push']('query_toolkit\x20'+a['query_type']+':\x20normalized\x20\x27'+d+'\x27\x20→\x20\x27'+c['canonical']+'\x27');return;}}}const QUERY_NETWORK_CANONICAL={'testnet':'testnet','mainnet':'mainnet','localnet':'localnet'},QUERY_NETWORK_ACCEPTED=Object['keys'](QUERY_NETWORK_CANONICAL)['join'](',\x20'),QUERY_NETWORK_KEY_VARIANTS=['context_network','network','net','chain'];function queryNetworkCanonicalValue(a){return QUERY_NETWORK_CANONICAL[a['trim']()['toLowerCase']()['replace'](/[-_]/g,'')];}function queryNetworkKeyFor(a,b){if(typeof b!=='string'||b==='')return undefined;let c=a;while(!![]){const g=c['_def'];if(!g)break;const h=g['typeName']==='ZodEffects'?g['schema']:g['out']??g['innerType'];if(!h||h===c)break;c=h;}const d=c['_def']?.['options'];if(!Array['isArray'](d))return undefined;const e=[],f=i=>{for(const j of i){const k=j['_def']?.['options'];if(Array['isArray'](k)){f(k);continue;}e['push'](j);}};f(d);for(const i of e){const j=zodTopLevelShape(i);if(!j)continue;const k=j['query_type']?.['value'];if(k!==b)continue;if('context_network'in j)return'context_network';if('network'in j)return'network';return undefined;}return undefined;}function normalizeQueryNetworkSpellings(a,b,c){for(const e of QUERY_NETWORK_KEY_VARIANTS){const f=a[e];if(typeof f!=='string')continue;const g=queryNetworkCanonicalValue(f);g&&f!==g&&(a[e]=g,b['push']('query_toolkit:\x20normalized\x20'+e+'\x20\x27'+f+'\x27\x20→\x20\x27'+g+'\x27'));}const d=queryNetworkKeyFor(c,a['query_type']);if(d!==undefined)for(const h of QUERY_NETWORK_KEY_VARIANTS){if(h===d)continue;const i=a[h];if(typeof i!=='string'||i==='')continue;if(a[d]===undefined){a[d]=i;const j=d==='context_network'?'BI\x20family\x20key':'on-chain\x20query\x20family\x20key';b['push']('normalized\x20\x27'+h+'\x27\x20→\x20\x27'+d+'\x27\x20('+j+')');}else b['push']('ignored\x20redundant\x20\x27'+h+'\x27\x20—\x20\x27'+d+'\x27\x20already\x20set');delete a[h];}if(d!==undefined){const k=a[d];if(typeof k==='string'&&k!==''&&queryNetworkCanonicalValue(k)===undefined)return{'field':d,'message':'Unknown\x20network\x20\x27'+k+'\x27\x20for\x20\x27'+d+'\x27.\x20Accepted\x20values:\x20'+QUERY_NETWORK_ACCEPTED+'.\x20'+'An\x20unknown\x20network\x20is\x20rejected\x20here\x20instead\x20of\x20silently\x20querying\x20the\x20default\x20network\x20'+'(that\x20mismatch\x20reads\x20as\x20\x22no\x20data\x22\x20—\x20F-NND-07).'};}return undefined;}async function handleWowok(a,b,c){const {tool:d,data:g,normalizationNotes:h}=normalizeInput(a);let j;{const q=a&&typeof a==='object'&&!Array['isArray'](a)?a:undefined,r=g,s=typeof q?.['harness_override_note']==='string'?q['harness_override_note']:typeof r?.['harness_override_note']==='string'?r['harness_override_note']:undefined;if(typeof s==='string'&&s['trim']()){if(q&&q['harness_override_note']!==undefined)delete q['harness_override_note'];if(r&&r['harness_override_note']!==undefined)delete r['harness_override_note'];j=s['trim'](),h['push']('rescued\x20top-level\x20\x27harness_override_note\x27\x20(per-purchase\x20pre-buy\x20gate\x20appeal)\x20—\x20forwarded\x20to\x20the\x20handler');}}(d==='query_toolkit'||d==='onchain_table_data')&&normalizeQueryToolkitAliases(g,h);if(d==='query_toolkit'||d==='onchain_table_data'){const t=TOOL_REGISTRY_MAP['get'](d),u=t?normalizeQueryNetworkSpellings(g,h,t['config']['inputSchema']):undefined;if(u!==undefined)return{'content':[{'type':'text','text':'Schema\x20mismatch\x20for\x20'+d+'.\x201\x20error(s).\x20'+u['message']}],'structuredContent':{'result':{'status':'schema_mismatch','errors':[u['message']],'structured_errors':[{'path':u['field'],'code':'unrecognized_enum_value','message':u['message'],'suggestion':'Use\x20one\x20of:\x20'+QUERY_NETWORK_ACCEPTED+'\x20(spellings\x20like\x20\x27TestNet\x27/\x27test-net\x27\x20are\x20normalized\x20automatically).\x20Omit\x20the\x20key\x20to\x20use\x20the\x20current\x20default\x20network.'}],'hint':'Fix\x20the\x20network\x20value\x20and\x20retry.'},'schema':null}};}let l=![];{const w=a&&typeof a==='object'&&!Array['isArray'](a)?a:undefined,x=g;w?.['want_schema']===!![]&&(l=!![],delete w['want_schema']),x&&typeof x==='object'&&x['want_schema']===!![]&&(l=!![],delete x['want_schema']);}if(a&&typeof a==='object'&&!Array['isArray'](a)){const y=a;y['passport']!==undefined&&y['submission']===undefined&&(y['submission']=y['passport'],h['push']('accepted\x20top-level\x20\x27passport\x27\x20as\x20alias\x20for\x20\x27submission\x27'));if(y['submission']!==undefined){const A=g['submission'];if(A!==undefined)return{'content':[{'type':'text','text':'Schema\x20mismatch\x20for\x20'+d+'.\x201\x20error(s).\x20\x27submission\x27\x20was\x20provided\x20in\x20BOTH\x20the\x20top\x20level\x20and\x20inside\x20\x27data\x27\x20—\x20provide\x20it\x20in\x20only\x20ONE\x20place\x20(top\x20level\x20OR\x20data),\x20not\x20both.'}],'structuredContent':{'result':{'status':'schema_mismatch','errors':['\x27submission\x27\x20provided\x20twice:\x20top\x20level\x20AND\x20inside\x20data.\x20Provide\x20it\x20in\x20only\x20ONE\x20place.'],'structured_errors':[{'path':'submission','code':'duplicate_field','message':'\x27submission\x27\x20provided\x20both\x20at\x20the\x20top\x20level\x20and\x20inside\x20data.','suggestion':'Keep\x20the\x20submission\x20in\x20exactly\x20one\x20place:\x20either\x20wowok({tool,\x20data,\x20submission})\x20or\x20wowok({tool,\x20data:\x20{operation_type,\x20data:\x20{...},\x20env,\x20submission}}).'}],'hint':'Move\x20\x27submission\x27\x20to\x20a\x20single\x20location\x20and\x20retry.'},'schema':null}};g['submission']=y['submission'],h['push']('merged\x20top-level\x20\x27submission\x27\x20into\x20data');}}let m=![];{const B=a,C=B['data']!==undefined||B['args']!==undefined||B['params']!==undefined,D=B['env'],E=B['confirmed'];if(C&&(D!==undefined||E!==undefined)){const F=g,G=TOOL_REGISTRY['find'](I=>I['name']===d),H=G!==undefined?zodUnionAwareKeyCheck(G['config']['inputSchema'],'env')['hasEnvSlot']:!![];if(H){const I=F['env']!==undefined&&typeof F['env']==='object'&&!Array['isArray'](F['env'])?{...F['env']}:{},J=D!==undefined&&typeof D==='object'&&!Array['isArray'](D)?D:{},K={...J,...I};E!==undefined&&K['confirmed']===undefined&&(K['confirmed']=E),Object['keys'](K)['length']>0x0&&(F['env']=K,m=!![],h['push']('merged\x20top-level\x20env/confirmed\x20into\x20data.env\x20(env\x20belongs\x20INSIDE\x20data)'));}else{const L=D!==undefined&&typeof D==='object'&&!Array['isArray'](D)?D:{},M=[];for(const [N,O]of Object['entries'](L)){if(N==='confirmed')continue;if(F[N]!==undefined)continue;if(zodBranchAwareDeclared(G['config']['inputSchema'],N,F)){F[N]=O,M['push'](N);continue;}N==='network'&&F['context_network']===undefined&&zodBranchAwareDeclared(G['config']['inputSchema'],'context_network',F)&&(F['context_network']=O,M['push']('context_network'));}E!==undefined&&F['confirmed']===undefined&&zodBranchAwareDeclared(G['config']['inputSchema'],'confirmed',F)&&(F['confirmed']=E,M['push']('confirmed')),M['length']>0x0&&h['push']('top-level\x20env\x20skipped\x20(this\x20sub-tool\x20has\x20no\x20env\x20slot);\x20routed\x20'+M['join'](',\x20')+'\x20to\x20plain\x20data\x20fields\x20(F-22)');}}}if(a&&typeof a==='object'&&!Array['isArray'](a)){const P=a;if(P['idempotency_key']!==undefined){const Q=g;if(Q['idempotency_key']!==undefined&&Q['idempotency_key']!==P['idempotency_key'])return{'content':[{'type':'text','text':'Schema\x20mismatch\x20for\x20'+d+'.\x201\x20error(s).\x20\x27idempotency_key\x27\x20was\x20provided\x20in\x20BOTH\x20the\x20top\x20level\x20and\x20inside\x20\x27data\x27\x20with\x20different\x20values\x20—\x20provide\x20it\x20in\x20only\x20ONE\x20place.'}],'structuredContent':{'result':{'status':'schema_mismatch','errors':['\x27idempotency_key\x27\x20provided\x20twice\x20with\x20different\x20values:\x20top\x20level\x20AND\x20inside\x20data.'],'structured_errors':[{'path':'idempotency_key','code':'duplicate_field','message':'\x27idempotency_key\x27\x20is\x20set\x20both\x20at\x20the\x20top\x20level\x20and\x20inside\x20data,\x20to\x20different\x20values.','suggestion':'Keep\x20the\x20idempotency\x20key\x20in\x20exactly\x20one\x20place:\x20wowok({tool,\x20data,\x20idempotency_key})\x20or\x20wowok({tool,\x20data:\x20{…,\x20idempotency_key}}).'}],'hint':'Move\x20\x27idempotency_key\x27\x20to\x20a\x20single\x20location\x20and\x20retry.'},'schema':null}};Q['idempotency_key']=P['idempotency_key'],delete P['idempotency_key'],h['push']('merged\x20top-level\x20\x27idempotency_key\x27\x20into\x20data');}}if(!d){const R=a&&typeof a==='object'&&!Array['isArray'](a)?Object['keys'](a)['join'](',\x20')||'(none)':'(non-object\x20input:\x20'+typeof a+')',S=['Missing\x20\x27tool\x27\x20field.\x20Received\x20keys:\x20'+R,'Expected\x20one\x20of:\x20'+SUB_TOOL_NAMES['join'](',\x20')];return{'content':[{'type':'text','text':'Missing\x20\x27tool\x27\x20field.\x20Call\x20format:\x20wowok({\x20tool:\x20\x22<sub-tool>\x22,\x20data:\x20{<params>}\x20}).\x20Received\x20keys:\x20'+R+'.\x20Available\x20sub-tools:\x20'+SUB_TOOL_NAMES['join'](',\x20')}],'structuredContent':{'result':{'status':'schema_mismatch','errors':S,'hint':'Provide\x20\x27tool\x27\x20(one\x20of:\x20'+SUB_TOOL_NAMES['join'](',\x20')+')\x20and\x20\x27data\x27\x20(sub-tool\x20parameters).\x20Aliases\x20accepted:\x20tool_name/name→tool,\x20args/params→data.','received':truncateReceivedValue(a)},'schema':{'input':zodToJsonSchemaSafe(WowokToolDisplaySchema,'wowok'),'tool':'wowok'}}};}const n=TOOL_REGISTRY_MAP['get'](d);if(!n){const T=d['toLowerCase'](),U=T==='wowok',V=T['split']('_')['filter'](Boolean),W=U?[]:TOOL_REGISTRY['map'](Z=>Z['name'])['map'](Z=>{const a0=Z['toLowerCase']()['split']('_');let a1=0x0;if(a0[0x0]===V[0x0])a1+=0x2;a1+=a0['filter'](a2=>V['includes'](a2))['length'];if(a0['some'](a2=>a2['startsWith'](V[V['length']-0x1]??'')))a1+=0x1;return{'name':Z,'score':a1};})['filter'](Z=>Z['score']>0x0)['sort']((Z,a0)=>a0['score']-Z['score'])['slice'](0x0,0x5)['map'](Z=>Z['name']),X=U?'\x20NOTE:\x20\x27wowok\x27\x20is\x20the\x20DISPATCHER\x20tool\x20itself,\x20not\x20a\x20sub-tool.\x20Call\x20format:\x20wowok({\x20tool:\x20\x22<sub-tool-name>\x22,\x20data:\x20{<params>}\x20}).':'',Y=W['length']>0x0?'.\x20Did\x20you\x20mean:\x20'+W['join'](',\x20')+'?':'';return{'content':[{'type':'text','text':'Unknown\x20sub-tool:\x20\x27'+d+'\x27.\x20Available:\x20'+TOOL_REGISTRY['map'](Z=>Z['name'])['join'](',\x20')+X+Y}],'structuredContent':{'result':{'status':'error','errors':['Unknown\x20sub-tool:\x20'+d],'hint':'Available\x20sub-tools:\x20'+TOOL_REGISTRY['map'](Z=>Z['name'])['join'](',\x20')+X+Y,'suggestions':W},'schema':null}};}h['length']>0x0&&console['warn']('[wowok]\x20input\x20normalization\x20for\x20\x27'+d+'\x27:\x20'+h['join'](';\x20'));{const Z=g,a0=Z['env']&&typeof Z['env']==='object'&&!Array['isArray'](Z['env'])?Z['env']:undefined;if(a0?.['confirmed']!==undefined&&Z['confirmed']===undefined){const a1=zodUnionAwareKeyCheck(n['config']['inputSchema'],'confirmed');if(a1['declared']&&!a1['hasEnvSlot']){Z['confirmed']=a0['confirmed'],delete a0['confirmed'];if(Object['keys'](a0)['length']===0x0)delete Z['env'];h['push']('routed\x20rescued\x20top-level\x20confirmed\x20to\x20the\x20tool\x27s\x20own\x20confirmed\x20slot'),console['warn']('[wowok]\x20input\x20normalization\x20for\x20\x27'+d+'\x27:\x20confirmed\x20slot\x20re-routed\x20(F-10)');}}}const o=n['config']['inputSchema']['safeParse'](g),p=checkUnknownFields(n['config']['inputSchema'],g);if(!o['success']||p['length']>0x0){const a2=[];!o['success']&&a2['push'](...formatZodErrors(o['error'],g));p['length']>0x0&&a2['push']('Unknown\x20field(s):\x20'+p['join'](',\x20'));const a3=[];!o['success']&&a3['push'](...formatZodErrorsStructured(o['error'],g));if(p['length']>0x0)for(const ah of p){a3['push']({'path':ah,'code':'unrecognized_keys','message':'Unknown\x20field\x20\x27'+ah+'\x27\x20is\x20not\x20allowed','suggestion':'Remove\x20field\x20\x27'+ah+'\x27\x20or\x20check\x20the\x20schema\x20for\x20valid\x20field\x20names'});}if(m){const ai='A\x20top-level\x20env/confirmed\x20was\x20merged\x20into\x20data.env\x20automatically\x20(contra\x20F-01\x20rescue),\x20but\x20THIS\x20sub-tool\x20does\x20not\x20accept\x20env\x20in\x20data.\x20Operation\x20tools\x20(onchain_operations\x20etc.)\x20take\x20env\x20inside\x20data;\x20query\x20tools\x20take\x20plain\x20data\x20fields\x20(e.g.\x20network)\x20instead\x20—\x20drop\x20the\x20env\x20key\x20for\x20this\x20call.';a2['push'](ai),a3['push']({'path':'env','code':'unrecognized_keys','message':'env\x20rescued\x20from\x20the\x20top\x20level,\x20but\x20this\x20sub-tool\x27s\x20data\x20schema\x20has\x20no\x20env\x20slot','suggestion':ai});}const a4=g??undefined,a5=a4!==undefined&&typeof a4['operation_type']==='string'&&a4['data']===undefined,a6=a3['some'](aj=>String(aj['path'])==='data'&&aj['code']==='invalid_type'&&/received undefined/i['test'](aj['message']));let a7;if(a6&&a5)a7='SHAPE\x20FIX\x20(rndb58d8d\x2004-ROOTCAUSE-A\x20A1):\x20operation\x20parameters\x20must\x20be\x20nested\x20INSIDE\x20a\x20\x27data\x27\x20object.\x20'+'The\x20envelope\x20is\x20{\x20operation_type:\x20\x27...\x27,\x20data:\x20{\x20<the\x20operation\x27s\x20parameters>\x20},\x20env?:\x20{...},\x20submission?:\x20{...}\x20}\x20'+'—\x20your\x20call\x20put\x20the\x20parameters\x20at\x20the\x20SAME\x20level\x20as\x20operation_type\x20(or\x20omitted\x20them),\x20so\x20\x27data\x27\x20arrived\x20undefined.\x20'+'Resend\x20with\x20the\x20parameters\x20wrapped\x20in\x20data.\x20This\x20is\x20a\x20static\x20shape\x20error,\x20NOT\x20session\x20state\x20—\x20no\x20restart\x20is\x20needed\x20'+'(this\x20server\x20is\x20stateless).\x20Also\x20discard\x20any\x20schema\x20slice\x20you\x20cached\x20from\x20an\x20earlier\x20call\x20for\x20a\x20DIFFERENT\x20'+'operation_type\x20—\x20slices\x20are\x20union-variant\x20specific\x20and\x20reusing\x20one\x20across\x20variants\x20mangles\x20the\x20payload.',a2['push'](a7),a3['push']({'path':'data','code':'invalid_type','message':'parameters\x20must\x20be\x20nested\x20inside\x20data\x20(flat\x20envelope:\x20parameters\x20found\x20as\x20siblings\x20of\x20operation_type)','suggestion':a7});else a6&&(a7='DIAGNOSTIC:\x20\x27data\x27\x20arrived\x20at\x20validation\x20as\x20undefined.\x20Send\x20the\x20tool\x27s\x20parameters\x20inside\x20the\x20\x27data\x27\x20object\x20'+'(for\x20onchain_operations:\x20{\x20operation_type:\x20\x27...\x27,\x20data:\x20{\x20<parameters>\x20},\x20env?,\x20submission?\x20}).\x20If\x20you\x20are\x20CERTAIN\x20'+'your\x20client\x20transmitted\x20a\x20well-formed\x20payload,\x20inspect\x20what\x20the\x20wrapper\x20actually\x20sent\x20before\x20retrying\x20—\x20identical\x20'+'retries\x20cannot\x20recover\x20from\x20a\x20construction\x20error.\x20(C-11\x27s\x20old\x20\x27wrapper\x20state\x20corruption\x20/\x20restart\x20the\x20session\x27\x20'+'conclusion\x20was\x20retired\x20by\x20rndb58d8d\x2004-ROOTCAUSE-A:\x20a\x20stateless\x20server\x20cannot\x20diagnose\x20caller-side\x20runtime\x20state.)',a2['push'](a7),a3['push']({'path':'data','code':'invalid_type','message':'data\x20is\x20required\x20—\x20the\x20tool\x27s\x20parameters\x20belong\x20inside\x20the\x20data\x20object','suggestion':a7}));const a8=loadPreGeneratedSchema(d)??zodToJsonSchemaSafe(n['config']['inputSchema'],d),a9=extractRelevantSchema(a8,d,g),aa=capSchemaDepth(compactMismatchSchemaInput(a9,g),0x0),ab=matchedVariantLegalKeys(aa)['filter'](aj=>aj!=='env');if(ab['length']>0x0){const aj='Legal\x20keys\x20for\x20this\x20input:\x20'+ab['join'](',\x20')+'.';for(const ak of a3){ak['code']==='unrecognized_keys'&&!String(ak['suggestion'])['includes']('Legal\x20keys')&&(ak['suggestion']=ak['suggestion']+'\x20'+aj);}for(let al=0x0;al<a2['length'];al++){/^(Unknown field\(s\):|.*(Unrecognized key|unexpected key))/i['test'](a2[al])&&!a2[al]['includes']('Legal\x20keys')&&(a2[al]=a2[al]+'\x20'+aj);}}{const am=arbNestingExamplesForSchemaErrors(d,g,a3);am&&(a2['push'](am['line']),a3['push'](am['structured']));}capMismatchErrors(a2,a3);const ac=a3[0x0]?.['suggestion']?'\x20FIRST\x20ERROR\x20SUGGESTION:\x20'+a3[0x0]['suggestion']:'',ad=a2['slice'](0x0,0x5)['map']((an,ao)=>'\x20\x20'+(ao+0x1)+'.\x20'+an)['join']('\x0a'),ae=buildSchemaPreview(a9,d,g),af=l?'Full\x20JSON\x20Schema\x20is\x20in\x20the\x20structuredContent.schema.input\x20field\x20(cache\x20it\x20ONLY\x20for\x20future\x20'+d+'\x20calls\x20with\x20the\x20SAME\x20operation_type/variant\x20—\x20slices\x20are\x20branch-specific;\x20a\x20different\x20operation_type\x20needs\x20a\x20fresh\x20schema).':'Full\x20JSON\x20Schema\x20was\x20omitted\x20(compact\x20default):\x20re-send\x20with\x20want_schema:true\x20to\x20receive\x20it\x20in\x20structuredContent.schema.input,\x20or\x20use\x20schema_query\x20(action=\x27get\x27)\x20for\x20a\x20specific\x20sub-schema.',ag=['Schema\x20mismatch\x20for\x20'+d+'.\x20'+a2['length']+'\x20error(s).'+ac,ad,...a7?['','⚠\x20'+a7]:[],'',ae,'','Fix\x20the\x20parameters\x20based\x20on\x20the\x20errors\x20above\x20and\x20the\x20schema\x20summary,\x20then\x20retry.',af,'Structured\x20errors\x20with\x20fix\x20suggestions\x20are\x20in\x20structuredContent.result.structured_errors\x20(ARCH-02).',SKILLS_MISMATCH_POINTER]['filter'](Boolean)['join']('\x0a');return{'content':[{'type':'text','text':ag}],'structuredContent':{'result':{'status':'schema_mismatch','errors':a2,'structured_errors':a3,'hint':schemaMismatchHint(d)},...l?{'schema':{'input':aa,'tool':d}}:{'schema':null}}};}try{j!==undefined&&(g['harness_override_note']=j);const an=await dispatchToolCall(d,g,b,c);if(an['resultType']==='input_required')return an;const ao=an['structuredContent'],ap=ao?.['result'],aq=ap?.['status']==='error'||ap?.['status']==='schema_mismatch'||ap?.['operation']==='error'||ap?.['type']==='error';if(aq){const av={'status':'error','data':an['structuredContent'],'errors':[an['content'][0x0]?.['text']??'Sub-tool\x20returned\x20an\x20error']};if(typeof ap?.['error_code']==='string')av['error_code']=ap['error_code'];if(typeof ap?.['retryable']==='boolean')av['retryable']=ap['retryable'];if(typeof ap?.['recovery_hint']==='string')av['recovery_hint']=ap['recovery_hint'];if(ap?.['refused']===!![])av['refused']=!![];if(ap?.['tx_submitted']===![])av['tx_submitted']=![];return{'content':an['content'],'structuredContent':{'result':av,'schema':null}};}const ar=typeof ao?.['outcome']==='string'?ao['outcome']:undefined,as=ao?.['verdict'],at=as!==undefined&&typeof as==='object'&&as['buildable']===![],au=at?'error':ar===undefined||ar==='executed'?'success':ar==='failed'?'error':'pending';return{'content':an['content'],'structuredContent':{'result':{'status':au,...ar!==undefined?{'outcome':ar}:{},...at?{'errors':['Plan\x20audit\x20BLOCKED\x20(verdict.buildable=false)\x20—\x20see\x20data.verdict.blockers\x20and\x20data.next_action.\x20Do\x20NOT\x20materialize\x20this\x20plan.']}:{},'data':an['structuredContent']},'schema':null}};}catch(aw){const ax=normalizeErrorMessage(aw);if(isSchemaValidationError(ax)){const aD=loadPreGeneratedSchema(d)??zodToJsonSchemaSafe(n['config']['inputSchema'],d),aE=extractRelevantSchema(aD,d,g),aF=buildSchemaPreview(aE,d,g),aG=[{'path':'(runtime)','code':'schema_validation_error','message':ax,'suggestion':'Check\x20the\x20error\x20message\x20and\x20the\x20schema\x20below\x20for\x20the\x20correct\x20field\x20format'}],aH=['Schema\x20mismatch\x20for\x20'+d+':\x20'+ax,'',aF,'','Fix\x20the\x20parameters\x20and\x20retry.',l?'Full\x20JSON\x20Schema\x20is\x20in\x20structuredContent.schema.input.':'Full\x20JSON\x20Schema\x20was\x20omitted\x20(compact\x20default):\x20re-send\x20with\x20want_schema:true\x20to\x20receive\x20it\x20in\x20structuredContent.schema.input.','Structured\x20errors\x20with\x20fix\x20suggestions\x20are\x20in\x20structuredContent.result.structured_errors\x20(ARCH-02).',SKILLS_MISMATCH_POINTER]['join']('\x0a');return{'content':[{'type':'text','text':aH}],'structuredContent':{'result':{'status':'schema_mismatch','errors':[ax],'structured_errors':aG,'hint':schemaMismatchHint(d)},...l?{'schema':{'input':compactMismatchSchemaInput(aE,g),'tool':d}}:{'schema':null}}};}const ay=/Unexpected token.*?\((\d+):(\d+)\)/['exec'](ax)??(/^(Unexpected end of JSON input|JSON\.parse)/['test'](ax)?[ax,'','']:null);if(ay){const aI=ay[0x1]?Number(ay[0x1]):undefined,aJ=ay[0x2]?Number(ay[0x2]):undefined,aK=aI!==undefined?'\x20at\x20line\x20'+aI+',\x20column\x20'+aJ:'',aL=loadPreGeneratedSchema(d)??zodToJsonSchemaSafe(n['config']['inputSchema'],d),aM=extractRelevantSchema(aL,d,g),aN=[{'path':'(root)','code':'malformed_json','message':'A\x20JSON\x20string\x20in\x20the\x20arguments\x20could\x20not\x20be\x20parsed'+aK+':\x20'+ax+'.\x20'+'Any\x20argument\x20passed\x20as\x20a\x20STRING\x20must\x20itself\x20be\x20valid\x20JSON.','suggestion':'Send\x20objects/arrays\x20as\x20real\x20JSON\x20values,\x20not\x20as\x20stringified\x20JSON.\x20'+'If\x20a\x20string\x20field\x20is\x20genuinely\x20textual\x20(description,\x20message,\x20remark),\x20it\x20must\x20NOT\x20be\x20quoted-and-escaped\x20JSON.\x20'+'If\x20the\x20argument\x20shape\x20is\x20confirmed\x20valid,\x20the\x20payload\x20may\x20have\x20been\x20TRUNCATED\x20before\x20parsing\x20—\x20arguments\x20past\x20a\x20'+'transport\x20size\x20limit\x20fail\x20with\x20this\x20same\x20envelope;\x20shrink\x20the\x20payload\x20(fewer\x20or\x20smaller\x20items)\x20and\x20retry.'}];return{'content':[{'type':'text','text':['Malformed\x20JSON\x20in\x20the\x20arguments\x20to\x20'+d+aK+':\x20'+ax,'',buildSchemaPreview(aM,d,g),'','Fix\x20the\x20parameters\x20and\x20retry.',l?'Full\x20JSON\x20Schema\x20is\x20in\x20structuredContent.schema.input.':'Full\x20JSON\x20Schema\x20was\x20omitted\x20(compact\x20default):\x20re-send\x20with\x20want_schema:true\x20to\x20receive\x20it\x20in\x20structuredContent.schema.input.']['join']('\x0a')}],'structuredContent':{'result':{'status':'schema_mismatch','errors':[ax],'structured_errors':aN,'hint':schemaMismatchHint(d)},...l?{'schema':{'input':compactMismatchSchemaInput(aM,g),'tool':d}}:{'schema':null}}};}const az=classifyError(ax,aw),aA={'status':'error','errors':[ax]};if(az['error_code']!==undefined)aA['error_code']=az['error_code'];if(az['retryable']!==undefined)aA['retryable']=az['retryable'];if(az['recovery_hint']!==undefined)aA['recovery_hint']=az['recovery_hint'];const aB=g?.['env'],aC=g?.['idempotency_key'];return Object['assign'](aA,unknownOutcomeFields(az,aw,aB,typeof aC==='string'?aC:undefined)),Object['assign'](aA,catalogFieldsFor(az,ax)??{}),{'content':[{'type':'text','text':'Error:\x20'+ax}],'structuredContent':{'result':aA,'schema':null}};}}function zodToJsonSchemaSafe(a,b){try{const c=z['toJSONSchema'](a,{'unrepresentable':'any','target':'draft-07'});if(c&&typeof c==='object'&&!Array['isArray'](c)){const {$schema:d,...e}=c;return e;}return{'type':'object'};}catch{return{'type':'object','additionalProperties':!![]};}}function resolveSchemaRefs(a){const b=new Set(['definitions','$schema','$id']);function c(e){if(!e['startsWith']('#/'))return null;const f=e['slice'](0x2)['split']('/');let g=a;for(const h of f){if(g==null||typeof g!=='object')return null;g=g[h];}return g;}function d(e,f){if(!e||typeof e!=='object')return e;if(Array['isArray'](e))return e['map'](i=>d(i,f));const g=e;if(typeof g['$ref']==='string'){const i=g['$ref'];if(f['has'](i))return{'type':'object','additionalProperties':!![]};const j=c(i);if(j&&typeof j==='object'&&!Array['isArray'](j)){const l=new Set(f);l['add'](i);const m=d(j,l),n={};for(const [o,p]of Object['entries'](g)){if(o!=='$ref'&&!b['has'](o))n[o]=p;}return{...m,...n};}return{'type':'object','additionalProperties':!![]};}const h={};for(const [q,r]of Object['entries'](g)){if(b['has'](q))continue;h[q]=d(r,f);}return h;}return d(a,new Set());}function loadPreGeneratedSchema(a){const b=preGeneratedSchemaCache['get'](a);if(b)return b;for(const c of SCHEMA_DIR_CANDIDATES){try{const d=join(c,a+'.schema.json'),e=readFileSync(d,'utf-8'),f=JSON['parse'](e),g=resolveSchemaRefs(f);return preGeneratedSchemaCache['set'](a,g),g;}catch{}}return null;}export function listTools(){return[{'name':'wowok','title':'WoWok\x20MCP','description':WOWOK_TOOL_DESCRIPTION,'inputSchema':resolveSchemaRefs(zodToJsonSchemaSafe(WowokToolDisplaySchema,'wowok'))}];}let startupUpgradeNoticeAttached=![],startupNoticePromise=null,upgradeEnforcementDecided=![];function startupNotice(){return startupNoticePromise??=getStartupUpgradeNotice(),startupNoticePromise;}async function upgradeRequiredResult(){if(upgradeEnforcementDecided)return null;let a=null;try{a=await startupNotice();}catch{a=null;}if(!a)return null;upgradeEnforcementDecided=!![];if(!a['enforced'])return null;const b='WoWok\x20upgrade\x20REQUIRED\x20—\x20tool\x20calls\x20are\x20blocked\x20until\x20the\x20local\x20package\x20is\x20current.\x0a'+(a['message']+'\x0a')+('To\x20stay\x20on\x20the\x20current\x20version\x20anyway,\x20write\x20{\x22enforce\x22:\x20false}\x20to\x20'+upgradePolicyPath()+'\x20and\x20restart.');return{'content':[{'type':'text','text':b}],'structuredContent':{'result':{'status':'error','error_code':'UPGRADE_REQUIRED','retryable':![],'recovery_hint':b,'data':{'upgrade_notice':a}},'schema':null}};}async function attachStartupUpgradeNotice(a){if(startupUpgradeNoticeAttached)return a;try{const b=await startupNotice();if(!b)return a;startupUpgradeNoticeAttached=!![];if(b['enforced'])return a;const c={...a};return Array['isArray'](a['content'])&&(c['content']=[...a['content'],{'type':'text','text':'\x0a⚠\x20'+b['message']+'\x0a'+'Surface\x20this\x20upgrade\x20notice\x20to\x20the\x20user\x20once\x20in\x20this\x20conversation\x20(do\x20not\x20wait\x20for\x20them\x20to\x20ask).'}]),a['structuredContent']&&typeof a['structuredContent']==='object'&&(c['structuredContent']={...a['structuredContent'],'upgrade_notice':b}),c;}catch{return startupUpgradeNoticeAttached=!![],a;}}export const wowokErrorShape=(a,b,c,d)=>{const e={'status':'error','errors':[a]};if(b['error_code']!==undefined)e['error_code']=b['error_code'];if(b['retryable']!==undefined)e['retryable']=b['retryable'];if(b['recovery_hint']!==undefined)e['recovery_hint']=b['recovery_hint'];const f=normalizeInput(c['data'])['data']??{};return Object['assign'](e,unknownOutcomeFields(b,d,f['env'],typeof f['idempotency_key']==='string'?f['idempotency_key']:undefined)),Object['assign'](e,catalogFieldsFor(b,a)??{}),{'result':e,'schema':null};};export async function wowokTimeoutVerify(a){try{const b=normalizeInput(a),c=b['tool']?TOOL_REGISTRY_MAP['get'](b['tool']):undefined;if(!c?.['onTimeoutVerify'])return undefined;const d={...b['data']??{}},e=a&&typeof a==='object'&&!Array['isArray'](a)?a:{};for(const g of['env','submission','idempotency_key']){if(d[g]===undefined&&e[g]!==undefined)d[g]=e[g];}const f=await c['onTimeoutVerify'](d);if(!f)return undefined;return'SUB-TOOL\x20\x27'+c['name']+'\x27\x20VERIFY-FIRST\x20READBACK\x20(the\x20unified\x20wrapper\x20stopped\x20waiting;\x20the\x20transaction\x20was\x20NOT\x20cancelled):\x0a'+f;}catch{return undefined;}}export function registerAllTools(a){const b=0x2bf20,c=async(e,f)=>handleWowok(e,undefined,f),d=wrapHandlerWithErrorShape(c,b,'wowok',wowokErrorShape,wowokTimeoutVerify);a['registerTool']('wowok',{'title':'WoWok\x20MCP','description':WOWOK_TOOL_DESCRIPTION,'inputSchema':WowokToolRuntimeSchema,'annotations':{'readOnlyHint':![],'destructiveHint':!![],'idempotentHint':![],'openWorldHint':!![]}},async(e,f)=>{const g=await upgradeRequiredResult();if(g)return g;return attachStartupUpgradeNotice(sanitizeToolDispatchResult(await d(e,f?.['mcpReq']?.['inputResponses']?{'inputResponses':f['mcpReq']['inputResponses']}:undefined)));}),overrideToolsListHandler(a);}function overrideToolsListHandler(a){a['server']['setRequestHandler']('tools/list',()=>({'tools':[{'name':'wowok','title':'WoWok\x20MCP','description':WOWOK_TOOL_DESCRIPTION,'inputSchema':ensureObjectType(zodToJsonSchemaSafe(WowokToolDisplaySchema,'wowok')),'annotations':{'readOnlyHint':![],'destructiveHint':!![],'idempotentHint':![],'openWorldHint':!![]}}]}));}function ensureObjectType(a){if(a['type']==='object')return a;return{...a,'type':'object'};}
|
|
1
|
+
import{z}from'zod';import{readFileSync}from'fs';import{fileURLToPath}from'url';import{dirname,join}from'path';import{fromJsonSchema}from'@modelcontextprotocol/server';import{registerOutputSchemaResolver}from'../schema-query-impl/index.js';const __filename=fileURLToPath(import.meta.url),__dirname=dirname(__filename),SCHEMA_DIR_CANDIDATES=[join(__dirname,'..','schemas'),join(__dirname,'..','..','dist','schemas')],preGeneratedSchemaCache=new Map();import{wrapHandlerWithErrorShape,dispatchWithHarness,withTimeout}from'./wrap.js';import{sanitizeToolDispatchResult}from'./sanitize-output.js';import{getStartupUpgradeNotice,upgradePolicyPath}from'./upgrade-check.js';import{classifyError,normalizeErrorMessage}from'../schema/call/semantic.js';import{arbNestingExamplesForSchemaErrors}from'../knowledge/arb-operation-face.js';import{catalogFieldsFor}from'./error-catalog.js';import{unknownOutcomeFields}from'./shared.js';import{findLatin1Mojibake,mojibakeBlockResult}from'./transport-integrity.js';import{ONCHAIN_TOOLS}from'./registry/onchain.js';import{LOCAL_TOOLS}from'./registry/local.js';import{FILE_TOOLS}from'./registry/files.js';import{MESSENGER_TOOLS}from'./registry/messenger.js';import{QUERY_TOOLS}from'./registry/query.js';import{BRIDGE_TOOLS}from'./registry/bridge.js';import{CONFIG_TOOLS}from'./registry/config.js';import{EVALUATION_TOOLS}from'./registry/evaluation.js';import{IDENTITY_TOOLS}from'./registry/identity.js';import{BUSINESS_TOOLS}from'./registry/business.js';import{AGENT_TOOLS}from'./registry/agent.js';import{MONITOR_TOOLS}from'./registry/monitor.js';import{INTERACTION_TOOLS}from'./registry/interaction.js';export{monitorEventStore,MonitorEventStore,monitorEventId}from'../monitor/EventStore.js';export{monitorLoop,MonitorLoop}from'../monitor/MonitorLoop.js';export{MONITOR_CAPTURE_TYPES}from'../monitor/normalize.js';export{NETWORK_FIELD_BY_QUERY}from'./handlers/query.js';export{resolveGateControls,resolveEffectiveOverrides}from'../persona/index.js';export{SYSTEM_OVERRIDE_SETTINGS}from'../persona/index.js';export const TOOL_REGISTRY=[...ONCHAIN_TOOLS,...LOCAL_TOOLS,...FILE_TOOLS['slice'](0x0,0x1),...MESSENGER_TOOLS,...FILE_TOOLS['slice'](0x1),...QUERY_TOOLS,...BRIDGE_TOOLS,...CONFIG_TOOLS,...EVALUATION_TOOLS,...IDENTITY_TOOLS,...BUSINESS_TOOLS,...AGENT_TOOLS,...MONITOR_TOOLS,...INTERACTION_TOOLS];export const TOOL_REGISTRY_MAP=new Map(TOOL_REGISTRY['map'](a=>[a['name'],a]));const derivedOutputSchemaCache=new Map();function deriveToolOutputSchema(a){const b=derivedOutputSchemaCache['get'](a);if(b)return b;const c=TOOL_REGISTRY_MAP['get'](a),d=c?.['config']['outputSchema'];if(!c||!d)return null;const e={'$schema':'http://json-schema.org/draft-07/schema#','$id':'https://wowok.net/schemas/'+a+'.output.json','title':c['config']['title'],'description':c['config']['description'],...zodToJsonSchemaSafe(d,a)};return derivedOutputSchemaCache['set'](a,e),e;}registerOutputSchemaResolver(deriveToolOutputSchema);export const SUB_TOOL_COUNT=TOOL_REGISTRY['length'];const SUB_TOOL_NAMES=TOOL_REGISTRY['map'](a=>a['name']),WowokToolRuntimeSchema=fromJsonSchema({'type':'object'}),WowokToolDisplaySchema=z['object']({'tool':z['enum'](SUB_TOOL_NAMES)['optional']()['describe']('The\x20sub-tool\x20to\x20execute.\x20Each\x20sub-tool\x20has\x20its\x20own\x20parameter\x20schema.'),'data':z['record'](z['string'](),z['unknown']())['optional']()['describe']('Sub-tool\x20specific\x20parameters.\x20If\x20validation\x20fails,\x20the\x20response\x20includes\x20the\x20correct\x20schema\x20for\x20this\x20sub-tool\x20—\x20read\x20it,\x20fix\x20your\x20params,\x20and\x20retry.'),'submission':z['record'](z['string'](),z['unknown']())['optional']()['describe']('Guard\x20submission\x20slots\x20(top-level\x20placement,\x20sibling\x20of\x20data/env).\x20Alternative:\x20place\x20inside\x20data.'),'env':z['record'](z['string'](),z['unknown']())['optional']()['describe']('Environment\x20(account/network/confirmed/...).\x20Top-level\x20placement\x20is\x20folded\x20into\x20data.env.'),'idempotency_key':z['string']()['max'](0x80)['optional']()['describe']('Caller-declared\x20idempotency\x20key\x20for\x20a\x20write\x20(1-128\x20chars,\x20on-chain\x20bound).\x20Top-level\x20placement\x20is\x20folded\x20into\x20data.idempotency_key.\x20Use\x20one\x20for\x20every\x20fund-moving\x20call\x20you\x20might\x20have\x20to\x20replay:\x20an\x20unknown-outcome\x20retry\x20under\x20the\x20SAME\x20key\x20is\x20HELD\x20by\x20the\x20dispatch\x20gate\x20until\x20the\x20outcome\x20is\x20verified,\x20which\x20is\x20what\x20makes\x20verify-before-retry\x20mechanical\x20instead\x20of\x20a\x20matter\x20of\x20discipline.'),'tool_name':z['enum'](SUB_TOOL_NAMES)['optional']()['describe']('DEPRECATED\x20alias\x20for\x20\x27tool\x27.\x20Use\x20\x27tool\x27\x20instead.'),'args':z['record'](z['string'](),z['unknown']())['optional']()['describe']('DEPRECATED\x20alias\x20for\x20\x27data\x27.\x20Use\x20\x27data\x27\x20instead.'),'name':z['enum'](SUB_TOOL_NAMES)['optional']()['describe']('DEPRECATED\x20alias\x20for\x20\x27tool\x27.\x20Use\x20\x27tool\x27\x20instead.'),'params':z['record'](z['string'](),z['unknown']())['optional']()['describe']('DEPRECATED\x20alias\x20for\x20\x27data\x27.\x20Use\x20\x27data\x27\x20instead.')})['describe']('WoWok\x20unified\x20tool\x20input.\x20Call\x20with\x20{\x20tool:\x20\x22<sub-tool>\x22,\x20data:\x20{<params>}\x20}.\x20'+'Aliases:\x20tool_name/name→tool,\x20args/params→data.'),SUB_TOOL_LIST=TOOL_REGISTRY['map'](a=>'\x20\x20'+a['name']+'\x20—\x20'+a['config']['summary'])['join']('\x0a'),SKILLS_MISMATCH_POINTER='Structured\x20role-based\x20guidance\x20(WHEN\x20and\x20in\x20what\x20ORDER\x20to\x20use\x20WoWok\x20sub-tools)\x20is\x20available\x20via\x20the\x20WoWok\x20Skills:\x20install\x20with\x20\x22npm\x20install\x20-g\x20@wowok'+'/skills\x22\x20(verify\x20with\x20\x22wowok-skills\x20doctor\x22),\x20or\x20fetch\x20orientation\x20now\x20via\x20wowok_buildin_info\x20info=\x22getting\x20started\x22.';function schemaMismatchHint(a){return'Fix\x20your\x20parameters\x20based\x20on\x20the\x20schema\x20below\x20and\x20retry.\x20CACHE\x20THIS\x20SCHEMA\x20for\x20future\x20'+a+'\x20calls\x20—\x20you\x20don\x27t\x20need\x20to\x20query\x20it\x20again.\x0a'+SKILLS_MISMATCH_POINTER;}const WOWOK_TOOL_DESCRIPTION=['WoWok\x20MCP\x20unified\x20interface.\x20Call\x20with\x20{\x20tool:\x20\x22<sub-tool>\x22,\x20data:\x20{<params>}\x20}.','','\x20\x20▶\x20START\x20HERE\x20—\x20WoWok\x20Skills\x20(recommended):','\x20\x20\x20\x20Role-based\x20playbooks\x20(onboarding,\x20building,\x20buying,\x20fulfillment,\x20arbitration,\x20governance)','\x20\x20\x20\x20sit\x20ON\x20TOP\x20of\x20this\x20MCP\x20and\x20materially\x20reduce\x20failed\x20calls\x20by\x20telling\x20you\x20WHEN\x20and\x20in\x20what','\x20\x20\x20\x20ORDER\x20to\x20use\x20the\x2030+\x20sub-tools\x20below.\x20One\x20command\x20installs\x20them\x20into\x20every\x20detected\x20AI','\x20\x20\x20\x20client\x20AND\x20registers\x20this\x20MCP\x20server\x20(idempotent\x20postinstall):','\x20\x20\x20\x20\x20\x20npm\x20install\x20-g\x20@wowok'+'/skills','\x20\x20\x20\x20Verify:\x20wowok-skills\x20doctor\x20\x20\x20Repair\x20an\x20old\x20install:\x20wowok-skills\x20init\x20--force','\x20\x20\x20\x20Machine-readable\x20orientation\x20+\x20best-effort\x20detection\x20of\x20whether\x20skills\x20are\x20installed\x20here:','\x20\x20\x20\x20\x20\x20wowok({\x20tool:\x20\x22wowok_buildin_info\x22,\x20data:\x20{\x20info:\x20\x22getting\x20started\x22\x20}\x20})','\x20\x20▶\x20COLD\x20START:\x20the\x20FIRST\x20call\x20after\x20server\x20boot\x20can\x20take\x20~20\x20seconds\x20(server\x20bootstraps\x20via\x20npx).','\x20\x20\x20\x20Wait\x20for\x20it\x20—\x20a\x20timed-out\x20first\x20response\x20is\x20startup\x20latency,\x20not\x20a\x20broken\x20server,\x20and\x20never\x20a','\x20\x20\x20\x20reason\x20to\x20retry\x20a\x20write\x20transaction.\x20Later\x20calls\x20are\x20fast.','','\x20\x20tool:\x20name\x20of\x20the\x20sub-tool\x20(string)','\x20\x20data:\x20sub-tool\x20parameters\x20(object)','','\x20\x20Aliases\x20accepted\x20(deprecated):\x20tool_name/name\x20for\x20tool,\x20args/params\x20for\x20data.','\x20\x20Inline\x20params\x20also\x20accepted:\x20{\x20tool:\x20\x22<sub-tool>\x22,\x20<param1>:\x20...,\x20<param2>:\x20...\x20}','\x20\x20⚠️\x20RESERVED\x20KEYS\x20cannot\x20be\x20passed\x20inline:\x20name\x20/\x20tool_name\x20/\x20args\x20/\x20params\x20are\x20the','\x20\x20deprecated\x20aliases\x20themselves\x20—\x20an\x20inline\x20\x27name\x27\x20is\x20consumed\x20as\x20the\x20tool\x20alias\x20and','\x20\x20never\x20reaches\x20the\x20sub-tool.\x20Pass\x20such\x20fields\x20inside\x20data\x20instead.','','\x20\x20EXAMPLE:\x20wowok({\x20tool:\x20\x22schema_query\x22,\x20data:\x20{\x20action:\x20\x22get\x22,\x20name:\x20\x22onchain_operations\x22\x20}\x20})','\x20\x20EXAMPLE:\x20wowok({\x20tool:\x20\x22wowok_buildin_info\x22,\x20data:\x20{\x20info:\x20\x22mainnet\x20bridge\x20tokens\x22\x20}\x20})','\x20\x20EXAMPLE\x20(inline\x20params):\x20wowok({\x20tool:\x20\x22query_toolkit\x22,\x20query_type:\x20\x22account_list\x22\x20})','','Available\x20sub-tools\x20('+SUB_TOOL_COUNT+'):',SUB_TOOL_LIST,'','SCHEMA-GATED\x20EXECUTION:','\x20\x20If\x20your\x20parameters\x20don\x27t\x20match\x20the\x20sub-tool\x27s\x20schema,\x20the\x20response\x20will\x20include:','\x20\x20\x20\x20result.status\x20=\x20\x22schema_mismatch\x22','\x20\x20\x20\x20result.errors\x20=\x20specific\x20validation\x20errors\x20(field\x20path\x20+\x20expected\x20type)','\x20\x20\x20\x20result.hint\x20=\x20instructions\x20to\x20fix\x20and\x20retry','\x20\x20\x20\x20schema.input\x20=\x20the\x20correct\x20JSON\x20schema\x20for\x20the\x20sub-tool','\x20\x20\x20\x20schema.tool\x20=\x20which\x20sub-tool\x20this\x20schema\x20belongs\x20to','\x20\x20Read\x20the\x20schema,\x20fix\x20your\x20params,\x20and\x20retry.\x20This\x20is\x20normal\x20—\x20no\x20need\x20to\x20call\x20schema_query\x20separately.','','SCHEMA\x20CACHING:','\x20\x20Each\x20sub-tool\x20has\x20a\x20DIFFERENT\x20schema.\x20When\x20you\x20receive\x20a\x20schema\x20in\x20a\x20mismatch\x20response:','\x20\x20\x20\x201.\x20Read\x20the\x20schema\x20carefully','\x20\x20\x20\x202.\x20Fix\x20your\x20parameters','\x20\x20\x20\x203.\x20Retry\x20the\x20call','\x20\x20\x20\x204.\x20CACHE\x20the\x20schema\x20in\x20your\x20context\x20for\x20future\x20calls\x20to\x20the\x20SAME\x20sub-tool','\x20\x20You\x20should\x20only\x20need\x20to\x20see\x20each\x20sub-tool\x27s\x20schema\x20once\x20per\x20conversation.','','ON-CHAIN\x20BUSINESS\x20INTELLIGENCE\x20(query_toolkit,\x20READ-ONLY\x20—\x20no\x20local\x20project\x20entity):','\x20\x20query_toolkit\x20query_type=\x27service_panorama\x27\x20→\x20ONE-CALL\x20full\x20Service\x20context\x20(workflow\x20graph,\x20guards,\x20supply\x20chain,\x20orders)','\x20\x20query_toolkit\x20query_type=\x27machine_panorama\x27\x20→\x20Machine\x20context\x20(head\x20+\x20fields\x20+\x20workflow\x20graph\x20+\x20Progress\x20list)','\x20\x20query_toolkit\x20query_type=\x27object_panorama\x27\x20→\x20detail\x20panorama\x20for\x20Progress/Demand/Order/Arb/Repository','\x20\x20query_toolkit\x20query_type=\x27review_pack\x27\x20→\x20typed\x20ReviewPack\x20for\x20the\x20client\x27s\x20generic\x20ReviewPackRenderer','\x20\x20query_toolkit\x20query_type=\x27assemble_context\x27\x20→\x20semantic\x20context\x20assembly\x20from\x20on-chain\x20objects','\x20\x20query_toolkit\x20query_type=\x27reverse_map\x27\x20→\x20deterministic\x20L4→L1\x20business\x20report\x20(merchant\x20profile\x20/\x20user\x20risk\x20/\x20game\x20theory)','\x20\x20query_toolkit\x20query_type=\x27participation_radar\x27\x20→\x20in-flight\x20order\x20participation\x20analysis\x20for\x20ONE\x20account','\x20\x20query_toolkit\x20query_type=\x27order_aggregate\x27\x20→\x20CROSS-ORDER\x20aggregate\x20(count\x20+\x20exact\x20amount\x20sums\x20per\x20service/machine/owner,\x20funding-target\x20checks\x20like\x20\x273\x20x\x206\x20>=\x2018\x27)','\x20\x20query_toolkit\x20query_type=\x27relationship_profile\x27\x20→\x20business\x20relationship\x20graph\x20for\x20ONE\x20account\x20(power/interest/value-flow\x20edges,\x20K3/19)','\x20\x20industry_pack_operation\x20action=\x27recommend_industry\x27/\x27list_modes\x27\x20→\x20industry\x20mode\x20registry\x20(GLM6/92\x20§E)','\x20\x20strategy_review_operation\x20action=\x27collect\x27/\x27review\x27/\x27list_snapshots\x27\x20→\x20posture-weighted\x20scorecard\x20+\x20periodic\x20review\x20(current-layer\x20proposals\x20only)','\x20\x20goal_operation\x20action=\x27merchant_guide\x27\x20→\x2010-step\x20merchant\x20onboarding\x20wizard\x20(never\x20executes\x20on-chain\x20ops)','\x20\x20benchmark_migration_operation\x20→\x20industry\x20archetype\x20templates\x20+\x20one-click\x20competitor\x20migration:','\x20\x20\x20\x20template_list\x20/\x20template_get\x20/\x20template_scan\x20(pre-deploy\x20risk\x20scan)\x20/\x20template_generate\x20(creation\x20plan)','\x20\x20\x20\x20migration_import\x20(store\x20URL/description\x20→\x20MigrationLog)\x20→\x20migration_review\x20(user\x20confirmation)\x20→\x20migration_apply\x20(scan-first\x20creation\x20plan;\x20testnet\x20default)','','═══════════════════════════════════════════════════════════════','BUILD/BUY\x20POLICY\x20(no\x20local\x20projects\x20—\x20chain\x20state\x20is\x20the\x20source\x20of\x20truth):','═══════════════════════════════════════════════════════════════','','CASE\x201\x20—\x20COMPLEX\x20REQUIREMENT\x20(user\x20wants\x20to\x20build/deploy\x20a\x20full\x20service):','\x20\x20→\x20Plan\x20with\x20goal_operation\x20action=\x27analyze_intent\x27\x20(C1:\x20intent\x20→\x20per-object\x20puzzle\x20snapshots\x20+\x20creation\x20order),','\x20\x20\x20\x20then\x20\x27aggregate_risks\x27\x20(C2:\x20cross-object\x20risk\x20calibration)\x20and\x20\x27trace_substeps\x27\x20(C3:\x20substep\x20DAG\x20coherence).','\x20\x20→\x20Alternatively\x20run\x20goal_operation\x20action=\x27merchant_guide\x27\x20for\x20a\x20guided\x2010-step\x20onboarding\x20plan.','\x20\x20→\x20If\x20the\x20user\x20wants\x20to\x20build\x20LIKE\x20an\x20industry\x20archetype\x20(\x27build\x20like\x20the\x20retail\x20leader\x20model\x27)\x20or','\x20\x20\x20\x20MIGRATE\x20an\x20existing\x20store\x20(hands\x20over\x20a\x20store\x20URL/description),\x20use\x20benchmark_migration_operation','\x20\x20\x20\x20(template_list\x20→\x20template_scan\x20→\x20template_generate,\x20or\x20migration_import\x20→\x20migration_review\x20→\x20migration_apply).','\x20\x20→\x20Create\x20objects\x20via\x20onchain_operations,\x20then\x20publish\x20the\x20Service.','','CASE\x202\x20—\x20SINGLE\x20OBJECT\x20CREATION\x20(user\x20wants\x20one\x20specific\x20object):','\x20\x20→\x20Create\x20directly\x20via\x20onchain_operations.\x20No\x20project\x20bookkeeping\x20needed.','','CASE\x203\x20—\x20CONSUMER\x20FLOW\x20(user\x20wants\x20to\x20buy/evaluate\x20a\x20service):','\x20\x20→\x20query_toolkit\x20query_type=\x27service_panorama\x27\x20or\x20\x27review_pack\x27\x20for\x20the\x20detail\x20page,','\x20\x20\x20\x20\x27reverse_map\x27\x20for\x20the\x20deterministic\x20buy\x20report\x20(add\x20Machine/Allocation\x20for\x20refund-path\x20detection),','\x20\x20\x20\x20then\x20onchain_operations\x20service_buy.','','CASE\x204\x20—\x20SIMPLE\x20QUERY\x20(user\x20wants\x20to\x20check\x20object\x20info,\x20balance,\x20etc.):','\x20\x20→\x20Proceed\x20directly\x20with\x20the\x20query.','═══════════════════════════════════════════════════════════════']['join']('\x0a');function joinIssuePath(a){return a['length']>0x0?a['map'](b=>typeof b==='number'?'['+b+']':String(b))['join']('.')['replace']('.[','['):'(root)';}function unionVariantErrors(a){const b=a,d=b['errors']??b['unionErrors']??b['issues'];if(!Array['isArray'](d))return[];const e=[];for(const f of d){if(!f)continue;if(Array['isArray'](f))f['every'](g=>!!g&&typeof g==='object'&&'code'in g)&&e['push']({'issues':f});else typeof f==='object'&&Array['isArray'](f['issues'])&&e['push']({'issues':f['issues']});}return e;}function variantScore(a){let b=0x0;for(const c of a['issues']){b+=0xa;const d=c;if(c['code']==='invalid_type')d['received']==='undefined'?b+=0x14:b-=0x5;else{if(c['code']==='unrecognized_keys'){const e=Array['isArray'](d['keys'])?d['keys']['length']:0x1;b+=0xf+e*0x5;}else{if(c['code']==='invalid_union'){const f=unionVariantErrors(c);if(f['length']>0x0)b+=Math['min'](...f['map'](variantScore));}}}}return b;}function variantSummary(a,b=0x3){const c=[];for(const e of a['issues']){const f=e;if(e['code']==='unrecognized_keys'){const g=Array['isArray'](f['keys'])?f['keys']['join'](',\x20'):'?';c['push']('unknown\x20field(s):\x20'+g);}else e['code']==='invalid_type'&&f['received']==='undefined'?c['push']('missing:\x20'+joinIssuePath([...e['path']])):c['push'](e['code']+'\x20at\x20'+joinIssuePath([...e['path']]));if(c['length']>=b)break;}const d=a['issues']['length']>b?'\x20(+'+(a['issues']['length']-b)+'\x20more)':'';return c['length']>0x0?c['join'](';\x20')+d:'shape\x20mismatch';}function resolveIssuePath(a,b){if(a['length']===0x0)return joinIssuePath(b);const c=b['length']>=a['length']&&a['every']((d,e)=>b[e]===d);return joinIssuePath(c?b:[...a,...b]);}function subToolRoutingHint(a,b){if(a!=='query_type')return'';const c=b['toLowerCase']();if(c['startsWith']('onchain_table'))return'\x20—\x20ROUTING:\x20table\x20/\x20table-item\x20queries\x20belong\x20to\x20the\x20SEPARATE\x20\x27onchain_table_data\x27\x20tool\x20—\x20call\x20onchain_table_data\x20with\x20this\x20query_type\x20(and\x20its\x20parent/address\x20params)\x20instead\x20of\x20query_toolkit';return'';}function matchedVariantLegalKeys(a){if(!a||typeof a!=='object')return[];const b=a['properties'];if(!b||typeof b!=='object'||Array['isArray'](b))return[];return Object['keys'](b)['sort']();}function absoluteIssuePath(a,b){const c=a['length']>0x0&&b['length']>=a['length']&&a['every']((d,e)=>b[e]===d);return c?b:[...a,...b];}function pushFlattened(a,b,c,d,e=[]){for(const f of a['issues']){if(f['code']==='invalid_union'){const g=f,h=[...f['path']],i=Array['isArray'](g['errors'])?g['errors']['length']:Array['isArray'](g['unionErrors'])?g['unionErrors']['length']:0x0,j=unionVariantErrors(f);if(j['length']===0x0){const o=resolveIssuePath(e,h),p=c!==undefined?extractValueAtPath(c,absoluteIssuePath(e,h)):undefined,q=p!==undefined;let r;if(i>0x0)r=(q?'value\x20does\x20not\x20match\x20any\x20of\x20the\x20union\x27s':'missing\x20required\x20union\x20field\x20—\x20no\x20value\x20provided;\x20union\x20accepts')+'\x20'+i+'\x20shape(s);\x20see\x20the\x20schema\x20preview\x20for\x20the\x20accepted\x20fields';else{if(q&&p&&typeof p==='object'&&!Array['isArray'](p)){const s=p,t=['operation_type','query_type','type','action','op']['find'](u=>typeof s[u]==='string');r=t?'discriminator\x20\x27'+t+'\x27=\x22'+String(s[t])+'\x22\x20does\x20not\x20match\x20any\x20variant;\x20check\x20the\x20\x22Valid\x20\x27'+t+'\x27\x20values\x22\x20line\x20in\x20the\x20schema\x20preview\x20below'+subToolRoutingHint(t,String(s[t])):'value\x20does\x20not\x20match\x20any\x20union\x20variant\x20(no\x20per-variant\x20details\x20available);\x20see\x20the\x20schema\x20preview';}else{if(q&&typeof p==='string'&&h['length']>0x0){const u=String(h[h['length']-0x1]);r='discriminator\x20\x27'+u+'\x27=\x22'+p+'\x22\x20does\x20not\x20match\x20any\x20variant;\x20check\x20the\x20\x22Valid\x20\x27'+u+'\x27\x20values\x22\x20line\x20in\x20the\x20schema\x20preview\x20below'+subToolRoutingHint(u,p);}else r='value\x20does\x20not\x20match\x20any\x20union\x20variant\x20(no\x20per-variant\x20details\x20available);\x20see\x20the\x20schema\x20preview';}}b['push']({'kind':'header','path':o,'code':'invalid_union','message':r});d&&(b[b['length']-0x1]={'kind':'header','path':o+'\x20['+d+']','code':'invalid_union','message':r});continue;}const k=j['map']((v,w)=>({'idx':w,'err':v,'score':variantScore(v)}))['sort']((v,w)=>v['score']-w['score']),l=k[0x0],m=k['slice'](0x1)['map'](v=>'variant\x20'+(v['idx']+0x1)+':\x20'+variantSummary(v['err']))['join']('\x20|\x20');b['push']({'kind':'header','path':resolveIssuePath(e,h),'code':'invalid_union','message':'no\x20union\x20variant\x20matched\x20('+j['length']+'\x20checked);\x20closest\x20=\x20variant\x20'+(l['idx']+0x1)+'\x20—\x20it\x20fails\x20on:\x20'+variantSummary(l['err'])+(m?'\x20—\x20others:\x20'+m:'')});const n=h['length']>0x0&&h['every']((v,w)=>e[w]===v)?h:[...e,...h];pushFlattened(l['err'],b,c,'variant\x20'+(l['idx']+0x1),n);}else b['push']({'kind':'issue','issue':f,'variantTag':d,'pathPrefix':e});}}function flattenZodIssues(a,b){const c=[];pushFlattened(a,c,b);const d=(f,g)=>{if(f['kind']!=='issue'||g['kind']!=='issue')return![];const h=absoluteIssuePath(f['pathPrefix']??[],f['issue']['path']),i=absoluteIssuePath(g['pathPrefix']??[],g['issue']['path']);return i['length']>h['length']&&h['every']((j,l)=>i[l]===j);},e=c['filter'](f=>{if(f['kind']!=='issue'||f['issue']['code']!=='unrecognized_keys')return!![];return!c['some'](g=>g!==f&&g['kind']==='issue'&&g['issue']['code']!=='unrecognized_keys'&&d(f,g));});return e;}const RECEIVED_VALUE_MAX=0x1f4;function truncateEcho(a){return a['length']>RECEIVED_VALUE_MAX?a['slice'](0x0,RECEIVED_VALUE_MAX)+'...(truncated,\x20'+(a['length']-RECEIVED_VALUE_MAX)+'\x20more\x20chars)':a;}function formatZodErrors(a,b,c){return flattenZodIssues(a,b)['map'](d=>{if(d['kind']==='header')return d['path']+'\x20['+d['code']+']:\x20'+d['message'];const e=d['issue'],f=resolveIssuePath(d['pathPrefix']??[],e['path']),g=e['code'],h=e['message'];let i='';const j=e,k=absoluteIssuePath(d['pathPrefix']??[],e['path']),l=g==='unrecognized_keys'?k:k['slice'](0x0,-0x1),m=legalSiblingFields(c,b,l);m&&(i+='\x0a\x20\x20\x20\x20LEGAL\x20FIELDS\x20at\x20'+levelLabel(l)+':\x20'+m['join'](',\x20'));if(g==='invalid_type'){const p=j['expected'],q=j['received'];typeof p==='string'&&typeof q==='string'&&(i='\x20(expected:\x20'+p+';\x20received:\x20'+q+')');}else{if(g==='invalid_value'){const r=j['expected'];if(r!==undefined){const s=typeof r==='string'?r:JSON['stringify'](r);i='\x20(expected:\x20'+s['slice'](0x0,0x3c)+')';}}else{if(g==='too_big'||g==='too_small'){const t=j['maximum']??j['minimum'],u=j['origin'];t!==undefined&&u!==undefined&&(i='\x20('+u+':\x20'+t+')');}}}const n=extractValueAtPath(b,absoluteIssuePath(d['pathPrefix']??[],e['path']));if(n!==undefined){const v=typeof n==='string'?'\x22'+truncateEcho(n)+'\x22':typeof n==='object'?truncateEcho(JSON['stringify'](n)):String(n);!i['includes']('received:')&&(i+='\x20(received\x20value:\x20'+v+')');}const o=d['variantTag']?'\x20['+d['variantTag']+']':'';return''+f+o+'\x20['+g+']:\x20'+h+i;});}function generateSuggestion(a,b,c,d=[]){const e=b,f=d['map'](h=>String(h)),g=f['includes']('guard')&&(a==='invalid_type'||a==='too_big'||a==='too_small'||a==='invalid_union'||a==='invalid_literal');if(g){const h=typeof c==='string'&&c['length']>0x0?c:'0xGuardObjectAddress';return'submission.guard\x20entries\x20are\x20OBJECTS\x20—\x20not\x20bare\x20address\x20strings:\x20'+('guard:\x20[{\x20object:\x20\x22'+h+'\x22,\x20impack:\x20true\x20}]\x20')+'(object\x20=\x20Guard\x20name\x20or\x20on-chain\x20ID;\x20impack\x20=\x20whether\x20this\x20Guard\x27s\x20verdict\x20blocks\x20the\x20operation).\x20'+'One\x20entry\x20per\x20Guard\x20the\x20forward\x20must\x20pass;\x20an\x20empty\x20array\x20is\x20invalid\x20(MCP-1).';}switch(a){case'invalid_type':{const i=e['expected'];if(i==='number'&&typeof c==='string')return'Convert\x20to\x20number:\x20'+Number(c);if(i==='string')return'Wrap\x20in\x20quotes\x20or\x20call\x20String(...)';if(i==='array')return'Wrap\x20in\x20array:\x20['+JSON['stringify'](c)+']';if(i==='object')return'Provide\x20an\x20object,\x20not\x20a\x20primitive';return'Convert\x20value\x20to\x20'+(i??'the\x20expected\x20type');}case'invalid_enum_value':{const j=e['options'],k=Array['isArray'](j)?j['map'](l=>JSON['stringify'](l))['join']('\x20|\x20'):String(j);return'Use\x20one\x20of:\x20'+k;}case'invalid_literal':{const l=e['expected'];return'Use\x20the\x20exact\x20value:\x20'+JSON['stringify'](l);}case'too_small':{const m=e['minimum'],n=e['type'];if(n==='array')return'Add\x20at\x20least\x20'+m+'\x20element(s)\x20to\x20the\x20array';if(n==='string')return'String\x20must\x20be\x20at\x20least\x20'+m+'\x20character(s)\x20long';if(n==='number')return'Use\x20a\x20value\x20>=\x20'+m;return'Value\x20must\x20be\x20>=\x20'+m;}case'too_big':{const o=e['maximum'],p=e['type'];if(p==='array')return'Reduce\x20array\x20to\x20at\x20most\x20'+o+'\x20element(s)';if(p==='string')return'Shorten\x20string\x20to\x20at\x20most\x20'+o+'\x20character(s)';if(p==='number')return'Use\x20a\x20value\x20<=\x20'+o;return'Value\x20must\x20be\x20<=\x20'+o;}case'unrecognized_keys':{const q=e['keys'];return'Remove\x20unknown\x20field(s):\x20'+(q??[])['join'](',\x20')+'.\x20Check\x20the\x20schema\x20for\x20valid\x20field\x20names.';}case'invalid_union':{return'Value\x20does\x20not\x20match\x20any\x20of\x20the\x20union\x20variants\x20—\x20see\x20the\x20\x22closest\x20variant\x22\x20line\x20above\x20for\x20the\x20concrete\x20field\x20error(s).';}case'invalid_string':{const r=e['validation'];if(r==='url')return'Provide\x20a\x20valid\x20URL\x20string';if(r==='email')return'Provide\x20a\x20valid\x20email\x20string';if(r==='uuid')return'Provide\x20a\x20valid\x20UUID\x20string';if(r==='regex')return'String\x20does\x20not\x20match\x20the\x20required\x20pattern';return'Provide\x20a\x20valid\x20string\x20matching\x20the\x20validation:\x20'+(r??'unknown');}case'invalid_date':{return'Provide\x20a\x20valid\x20Date\x20object\x20or\x20ISO\x20date\x20string';}case'not_finite':{return'Use\x20a\x20finite\x20number\x20(not\x20Infinity\x20or\x20NaN)';}case'invalid_arguments':{return'Arguments\x20do\x20not\x20match\x20the\x20expected\x20schema';}case'invalid_return_type':{return'Return\x20type\x20does\x20not\x20match\x20the\x20expected\x20schema';}case'custom':{return'Custom\x20validation\x20failed\x20—\x20see\x20the\x20field\x27s\x20description\x20in\x20the\x20schema';}default:{return'Fix\x20the\x20value\x20at\x20\x27'+b['path']['join']('.')+'\x27\x20based\x20on\x20the\x20schema';}}}function formatZodErrorsStructured(a,b,c){return flattenZodIssues(a,b)['flatMap'](d=>{if(d['kind']==='header'){const q=d['message']['match'](/closest = variant (\d+)/),r=d['message']['includes']('missing\x20required\x20union\x20field'),s=d['message']['includes']('does\x20not\x20match\x20any\x20variant'),t=q?'Fix\x20the\x20field\x20error(s)\x20listed\x20for\x20variant\x20'+q[0x1]+'\x20below.':r?'Provide\x20this\x20required\x20field\x20with\x20one\x20of\x20the\x20accepted\x20shapes,\x20and\x20check\x20field-name\x20spelling\x20against\x20the\x20schema\x20preview.':s?'No\x20union\x20variant\x20accepts\x20this\x20discriminator\x20—\x20pick\x20a\x20value\x20from\x20the\x20\x27Valid\x20...\x20values\x27\x20line\x20in\x20the\x20schema\x20preview\x20below.\x20If\x20the\x20value\x20belongs\x20to\x20a\x20sub-tool\x20(e.g.\x20onchain_table*\x20→\x20onchain_table_data),\x20resend\x20it\x20to\x20that\x20tool.':'No\x20union\x20variant\x20matched\x20—\x20check\x20the\x20schema\x20preview\x20below\x20for\x20the\x20accepted\x20shapes.';return[{'path':d['path'],'code':d['code'],'message':d['message'],'suggestion':t}];}const e=d['issue'],f=resolveIssuePath(d['pathPrefix']??[],e['path']),g=e['code'],h=d['variantTag']?e['message']+'\x20(closest\x20union\x20variant:\x20'+d['variantTag']+')':e['message'],i=e;let j;if(g==='invalid_type'){const u=i['expected'],v=i['received'];typeof u==='string'&&typeof v==='string'&&(j=u);}else{if(g==='invalid_value'){const w=i['expected'],x=i['options'];if(Array['isArray'](x))j=x['map'](y=>JSON['stringify'](y))['join']('\x20|\x20');else w!==undefined&&(j=typeof w==='string'?w:JSON['stringify'](w));}else{if(g==='too_big'||g==='too_small'){const y=i['maximum']??i['minimum'];y!==undefined&&(j=String(y));}}}const k=extractValueAtPath(b,absoluteIssuePath(d['pathPrefix']??[],e['path'])),l=generateSuggestion(g,e,k,absoluteIssuePath(d['pathPrefix']??[],e['path'])),m=absoluteIssuePath(d['pathPrefix']??[],e['path']),n=g==='unrecognized_keys'?m:m['slice'](0x0,-0x1),o=legalSiblingFields(c,b,n),p=o?g==='unrecognized_keys'?l+'\x20Legal\x20fields\x20at\x20'+levelLabel(n)+':\x20'+o['join'](',\x20')+'.':l:l;return[{'path':f,'code':g,'message':h,'expected':j,'received_value':truncateReceivedValue(k),'suggestion':p,...o?{'legal_fields':o}:{}}];});}function extractValueAtPath(a,b){if(a===undefined||a===null||b['length']===0x0)return undefined;let c=a;for(const d of b){if(c===undefined||c===null)return undefined;if(typeof d==='number'){if(!Array['isArray'](c))return undefined;c=c[d];}else{if(typeof c!=='object')return undefined;c=c[d];}}return c;}function unwrapSchemaType(a){let b=a?.['_def']??a;for(let c=0x0;b&&c<0x8;c+=0x1){const d=b['type']??b['typeName'];if(d==='optional'||d==='nullable'||d==='default'||d==='readonly'||d==='ZodOptional'||d==='ZodNullable'||d==='ZodDefault'||d==='ZodReadonly'){b=b['innerType']?.['_def']??b['innerType'];continue;}return b;}return undefined;}function objectShapeKeys(a){const b=unwrapSchemaType(a);if(!b)return undefined;const c=b['type']??b['typeName'];if(c!=='object'&&c!=='ZodObject')return undefined;const d=typeof b['shape']==='function'?b['shape']():b['shape'];if(!d||typeof d!=='object')return undefined;const e=Object['keys'](d);return e['length']>0x0&&e['length']<=0x18?e:undefined;}function legalSiblingFields(a,b,c){if(!a)return undefined;let d=a,e=b;for(const f of c){const g=unwrapSchemaType(d);if(!g)return undefined;const h=g['type']??g['typeName'];if(h==='array'||h==='ZodArray'){const j=g['element']??g['elemType'];if(typeof f!=='number'||!Array['isArray'](e))return undefined;d=j,e=e[f];continue;}const i=typeof g['shape']==='function'?g['shape']():g['shape'];if(!i||typeof i!=='object'||typeof f!=='string')return undefined;d=i[f],e=e?.[f];}return objectShapeKeys(d);}function levelLabel(a){if(a['length']===0x0)return'(root)';return a['map'](b=>typeof b==='number'?'['+b+']':String(b))['join']('.')['replace']('.[','[');}const RECEIVED_VALUE_MAX_CHARS=0xc8;function truncateReceivedValue(a){if(a===undefined)return undefined;if(typeof a==='string')return a['length']<=RECEIVED_VALUE_MAX_CHARS?a:a['slice'](0x0,RECEIVED_VALUE_MAX_CHARS)+'…(truncated,\x20'+a['length']+'\x20chars)';let b;try{b=JSON['stringify'](a)??String(a);}catch{b=String(a);}if(b['length']<=RECEIVED_VALUE_MAX_CHARS)return a;return b['slice'](0x0,RECEIVED_VALUE_MAX_CHARS)+'…(truncated,\x20'+b['length']+'\x20chars)';}const MAX_MISMATCH_ERRORS=0xa;function capMismatchErrors(a,b){if(a['length']>MAX_MISMATCH_ERRORS){const c=a['length']-MAX_MISMATCH_ERRORS;a['length']=MAX_MISMATCH_ERRORS,a['push']('…and\x20'+c+'\x20more\x20error(s)\x20truncated\x20(fix\x20the\x20listed\x20ones\x20first).');}if(b['length']>MAX_MISMATCH_ERRORS){const d=b['length']-MAX_MISMATCH_ERRORS;b['length']=MAX_MISMATCH_ERRORS,b['push']({'path':'(root)','code':'errors_truncated','message':d+'\x20additional\x20error(s)\x20truncated.','suggestion':'Fix\x20the\x20listed\x20errors\x20first\x20—\x20remaining\x20errors\x20frequently\x20disappear\x20once\x20the\x20first\x20ones\x20are\x20corrected.'});}}function zodTopLevelShape(a){let b=a;while(!![]){const e=b['_def'];if(!e)break;const f=e['typeName']==='ZodEffects'?e['schema']:e['out']??e['innerType'];if(!f||f===b)break;b=f;}const c=b['_def'],d=typeof c?.['shape']==='function'?c['shape']():c?.['shape'];return d&&typeof d==='object'?d:undefined;}function checkUnknownFields(a,b){const c=zodTopLevelShape(a);if(!c||typeof b!=='object'||b===null)return[];const d=Object['keys'](c),e=Object['keys'](b);return e['filter'](g=>!d['includes'](g));}function zodUnionAwareKeyCheck(a,b){let c=a;while(!![]){const g=c['_def'];if(!g)break;const h=g['typeName']==='ZodEffects'?g['schema']:g['out']??g['innerType'];if(!h||h===c)break;c=h;}const d=c['_def']?.['options']??[c];let e=![],f=![];for(const i of d){const j=zodTopLevelShape(i);if(!j)continue;if(b in j)e=!![];if('env'in j)f=!![];}return{'declared':e,'hasEnvSlot':f};}function zodBranchAwareDeclared(a,b,c){let d=a;while(!![]){const h=d['_def'];if(!h)break;const i=h['typeName']==='ZodEffects'?h['schema']:h['out']??h['innerType'];if(!i||i===d)break;d=i;}const e=d['_def'],f=e?.['options'];if(!f){const j=zodTopLevelShape(d);return j!==undefined&&b in j;}const g=e?.['discriminator'];if(typeof g==='string'&&c[g]!==undefined)for(const k of f){const l=zodTopLevelShape(k);if(!l)continue;const m=l[g]?.['_def']?.['value'];if(m===c[g])return b in l;}return f['some'](n=>{const p=zodTopLevelShape(n);return p!==undefined&&b in p;});}function extractRelevantSchema(a,b,c){if(b==='onchain_operations'&&typeof c==='object'&&c!==null){const d=c['operation_type'];if(typeof d==='string'){const e='onchain_operations_'+d,f=loadPreGeneratedSchema(e);if(f)return f;}}return a;}function isSchemaValidationError(a){return a['startsWith']('Unknown\x20')&&a['includes']('field')||a['includes']('expected')&&a['includes']('received')||a['includes']('Invalid\x20input')||a['includes']('Required')||a['includes']('validation\x20failed\x20with');}function variantConstValue(a,b){const c=a['properties'];if(!c||typeof c!=='object')return undefined;const d=c[b];if(!d)return undefined;if(typeof d['const']==='string')return d['const'];if(Array['isArray'](d['enum'])&&d['enum']['length']===0x1&&typeof d['enum'][0x0]==='string')return d['enum'][0x0];return undefined;}function pickUnionVariant(a,b){const c=['query_type','operation_type','type'],d=b&&typeof b==='object'&&!Array['isArray'](b)?Object['keys'](b):[],e=[...c,...d['filter'](f=>!c['includes'](f))];for(const f of e){const g=b?.[f];if(typeof g!=='string')continue;for(let h=0x0;h<a['length'];h++){const j=a[h];if(j&&typeof j==='object'&&variantConstValue(j,f)===g)return{'variant':j,'index':h,'discriminator':f,'matched':!![]};}}for(let k=0x0;k<a['length'];k++){const l=a[k];if(l&&typeof l==='object'){const m=l;if(m['properties']&&typeof m['properties']==='object')return{'variant':m,'index':k,'matched':![]};}}return{'index':-0x1,'matched':![]};}function unionDiscriminatorValues(a,b){const c=[];for(const d of a){if(d&&typeof d==='object'){const e=variantConstValue(d,b);if(e!==undefined&&!c['includes'](e))c['push'](e);}}return c;}function inferDiscriminatorKey(a){if(!Array['isArray'](a)||a['length']===0x0)return undefined;const b=a['filter'](d=>!!d&&typeof d==='object'&&!!d['properties']);if(b['length']!==a['length']||b['length']===0x0)return undefined;const c=b[0x0]['properties'];for(const d of Object['keys'](c)){let e=!![];for(const f of b){if(variantConstValue(f,d)===undefined){e=![];break;}}if(e)return d;}return undefined;}const NESTED_REQUIRED_MAX_LINES=0x10;function nestedRequiredLines(a,b,c){if(c>0x2)return[];const d=[],e=Array['isArray'](b['required'])?b['required']['filter'](g=>typeof g==='string'):[];e['length']>0x0&&d['push']('\x20\x20\x20\x20\x20\x20Required\x20within\x20'+a+':\x20'+e['join'](',\x20'));const f=b['properties'];if(!f||typeof f!=='object'||c>=0x2)return d;for(const [g,h]of Object['entries'](f)){if(d['length']>=NESTED_REQUIRED_MAX_LINES){d['push']('\x20\x20\x20\x20\x20\x20(more\x20nested\x20required\x20fields\x20under\x20'+a+'\x20—\x20see\x20structuredContent\x20for\x20the\x20full\x20schema)');break;}if(!h||typeof h!=='object')continue;const i=h;if(!i['properties']||typeof i['properties']!=='object')continue;d['push'](...nestedRequiredLines(a+'.'+g,i,c+0x1));}return d;}export function buildSchemaPreview(a,b,c){try{const d=['Schema\x20preview\x20for\x20'+b+':'];let e,g=[],h='',i,j=-0x1,k,l=![];if(a['properties']&&typeof a['properties']==='object')e=a['properties'],g=Array['isArray'](a['required'])?a['required']:[],h=typeof a['description']==='string'?a['description']:'';else{if(Array['isArray'](a['oneOf'])||Array['isArray'](a['anyOf'])){i=a['oneOf']??a['anyOf'];const p=pickUnionVariant(i,c);j=p['index'],k=p['discriminator'],l=p['matched'];p['variant']&&(e=p['variant']['properties'],g=Array['isArray'](p['variant']['required'])?p['variant']['required']:[],h=typeof p['variant']['description']==='string'?p['variant']['description']:'');if(!e)return d['push']('\x20\x20(discriminated\x20union\x20with\x20'+i['length']+'\x20variants\x20—\x20see\x20structuredContent\x20for\x20full\x20schema)'),d['join']('\x0a');}}h&&h['length']>0x0&&h['length']<0xc8&&d['push']('\x20\x20'+h);if(!e)return d['push']('\x20\x20(no\x20properties\x20available\x20—\x20see\x20structuredContent\x20for\x20full\x20schema)'),d['join']('\x0a');const m=new Set(g),n=g['length']>0x0?g['join'](',\x20'):'(none)',o=Object['keys'](e)['filter'](q=>!m['has'](q))['join'](',\x20');d['push']('Required:\x20'+n);o&&d['push']('Optional:\x20'+o);d['push']('Fields:');for(const [q,r]of Object['entries'](e)){if(r&&typeof r==='object'){const s=r,t=describeSchemaType(s),u=m['has'](q)?'required':'optional';let v=typeof s['description']==='string'?s['description']:'';if(v['length']>0x78)v=v['slice'](0x0,0x75)+'...';let w='';if(s['properties']&&typeof s['properties']==='object'){const y=Object['keys'](s['properties']);y['length']>0x0&&(w='\x20{\x20'+y['slice'](0x0,0x8)['join'](',\x20')+(y['length']>0x8?',\x20...':'')+'\x20}');}if(s['items']&&typeof s['items']==='object'){const A=s['items'],B=describeSchemaType(A);w='\x20(array\x20of\x20'+B+')';}Array['isArray'](s['enum'])&&(w='\x20(enum:\x20'+s['enum']['slice'](0x0,0x6)['map'](C=>JSON['stringify'](C))['join'](',\x20')+(s['enum']['length']>0x6?',\x20...':'')+')');d['push']('\x20\x20-\x20'+q+'\x20('+t+',\x20'+u+')'+w+(v?'\x20—\x20'+v:''));const x=nestedRequiredLines(q,s,0x0);d['push'](...x);}}if(i&&i['length']>0x0){d['push']('');if(l&&k){const C=c&&typeof c==='object'?c:{},D=String(C[k]);d['push']('Matched\x20variant:\x20'+k+'=\x22'+D+'\x22\x20(variant\x20'+(j+0x1)+'\x20of\x20'+i['length']+').');}else{d['push']('Discriminated\x20union\x20with\x20'+i['length']+'\x20variants;\x20showing\x20variant\x20'+(j+0x1)+'\x20(no\x20matching\x20discriminator\x20value\x20in\x20input).');const E=k??inferDiscriminatorKey(i)??(b==='query_toolkit'?'query_type':'operation_type'),F=unionDiscriminatorValues(i,E);F['length']>0x0&&d['push']('Valid\x20\x27'+E+'\x27\x20values:\x20'+F['join'](',\x20'));}}if(b==='onchain_operations'&&typeof c==='object'&&c!==null){const G=c['operation_type'];typeof G==='string'&&(d['push'](''),d['push']('operation_type-specific\x20schema:\x20onchain_operations_'+G),d['push']('(Use\x20schema_query\x20with\x20action=\x27get\x27\x20and\x20name=\x27onchain_operations_'+G+'\x27\x20for\x20the\x20full\x20sub-schema.)'));}return d['join']('\x0a');}catch{return'Schema\x20preview\x20for\x20'+b+':\x20(unable\x20to\x20build\x20preview\x20—\x20see\x20structuredContent\x20for\x20full\x20schema)';}}function compactMismatchSchemaInput(a,b){const c=Array['isArray'](a['oneOf'])?a['oneOf']:Array['isArray'](a['anyOf'])?a['anyOf']:undefined;if(!c)return a;const d=pickUnionVariant(c,b);if(!d['matched']||!d['variant'])return fallbackUnionSchema(a,c,b);const e=d['variant'],{oneOf:f,anyOf:g,...h}=a,i=h['properties']&&typeof h['properties']==='object'?h['properties']:{},j=e['properties']&&typeof e['properties']==='object'?e['properties']:{},k=Array['isArray'](h['required'])?h['required']:[],l=Array['isArray'](e['required'])?e['required']:[];return{...h,...e['type']!==undefined?{'type':e['type']}:{},...e['additionalProperties']!==undefined?{'additionalProperties':e['additionalProperties']}:{},...e['description']!==undefined?{'description':e['description']}:{},'properties':{...i,...j},'required':[...new Set([...k,...l])]};}function fallbackUnionSchema(a,b,c){const d=inferDiscriminatorKey(b);if(!d)return a;const e=unionDiscriminatorValues(b,d);if(e['length']===0x0)return a;const {oneOf:f,anyOf:g,...h}=a,i=h['properties']&&typeof h['properties']==='object'?h['properties']:{},j=Array['isArray'](h['required'])?h['required']:[],k=c&&typeof c==='object'&&!Array['isArray'](c)?Object['keys'](c):[];return{...h,'properties':{...i,[d]:{'type':'string','enum':e,'description':k['includes'](d)?'Unknown\x20\x22'+d+'\x22\x20value\x20—\x20must\x20be\x20one\x20of\x20the\x20listed\x20values.\x20Per-variant\x20parameters:\x20schema_query\x20(action=\x27get\x27)':'Missing\x20\x22'+d+'\x22\x20—\x20set\x20it\x20to\x20one\x20of\x20the\x20listed\x20values.\x20Per-variant\x20parameters:\x20schema_query\x20(action=\x27get\x27)'}},'required':j['includes'](d)?j:[...j,d]};}function describeSchemaType(a){if(typeof a['type']==='string')return a['type'];if(Array['isArray'](a['type']))return a['type']['join']('|');if(a['$ref'])return'$ref';if(Array['isArray'](a['oneOf']))return'oneOf';if(Array['isArray'](a['anyOf']))return'anyOf';if(Array['isArray'](a['allOf']))return'allOf';if(a['enum'])return'enum';if(a['const'])return'const('+JSON['stringify'](a['const'])+')';return'object';}const MISMATCH_SCHEMA_MAX_DEPTH=0x18;function capSchemaDepth(a,b){if(b>=MISMATCH_SCHEMA_MAX_DEPTH){if(Array['isArray'](a))return'(depth-capped\x20—\x20use\x20schema_query\x20action=\x27get\x27\x20for\x20the\x20full\x20sub-schema)';if(a!==null&&typeof a==='object')return{'type':'object','description':'(depth-capped\x20—\x20use\x20schema_query\x20action=\x27get\x27\x20for\x20the\x20full\x20sub-schema)'};return a;}if(Array['isArray'](a))return a['map'](c=>capSchemaDepth(c,b+0x1));if(a!==null&&typeof a==='object'){const c={};for(const [d,e]of Object['entries'](a)){c[d]=capSchemaDepth(e,b+0x1);}return c;}return a;}export async function dispatchToolCall(a,b,c,d){return sanitizeToolDispatchResult(await dispatchToolCallRaw(a,b,c,d));}async function dispatchToolCallRaw(a,b,c,d){{const i=findLatin1Mojibake(b);if(i)return mojibakeBlockResult(i['path'],i['sample']);}if(a==='wowok')return handleWowok(b,c,d);const e=TOOL_REGISTRY_MAP['get'](a);if(!e)throw new Error('Unknown\x20tool:\x20'+a+'.\x20Available:\x20'+TOOL_REGISTRY['map'](j=>j['name'])['join'](',\x20'));if(e['applyRules']&&!c?.['skipRules']){const j=await withTimeout(Promise['resolve'](e['applyRules'](b)),e['timeoutMs']??0xea60,a);if(j)return j;}const f=dispatchWithHarness(e['handler'],a),g=e['timeoutMs']??0xea60,h=wrapHandlerWithErrorShape(f,g,a,e['errorShapeBuilder'],e['onTimeoutVerify']);return h(b,d);}const TOOL_FIELD_ALIASES=['tool','tool_name','name'],DATA_FIELD_ALIASES=['data','args','params','parameters'],RESERVED_FIELD_NAMES=new Set([...TOOL_FIELD_ALIASES,...DATA_FIELD_ALIASES]);function normalizeInput(a){const b=[];if(!a||typeof a!=='object'||Array['isArray'](a))return{'tool':undefined,'data':{},'normalizationNotes':['input\x20is\x20not\x20an\x20object']};const c=a;let d;for(const f of TOOL_FIELD_ALIASES){if(typeof c[f]==='string'&&c[f]){d=c[f];f!=='tool'&&b['push']('normalized\x20\x27'+f+'\x27\x20→\x20\x27tool\x27');break;}}let e;for(const g of DATA_FIELD_ALIASES){const h=c[g];if(h!==undefined&&h!==null&&typeof h==='object'&&!Array['isArray'](h)){e=h;g!=='data'&&b['push']('normalized\x20\x27'+g+'\x27\x20→\x20\x27data\x27');break;}}if(!e){const i={};let j=![];for(const k of Object['keys'](c)){!RESERVED_FIELD_NAMES['has'](k)&&(i[k]=c[k],j=!![]);}j?(e=i,b['push']('extracted\x20inline\x20params\x20→\x20\x27data\x27\x20(no\x20data\x20wrapper\x20was\x20provided)')):e={};}return{'tool':d,'data':e,'normalizationNotes':b};}const QUERY_ACCOUNT_FIELD_ALIASES={'account_balance':{'canonical':'name_or_address','aliases':['account','address']},'onchain_personal_profile':{'canonical':'account','aliases':['name_or_address','address']},'address_profile':{'canonical':'address','aliases':['name_or_address','account']}};function normalizeQueryToolkitAliases(a,b){if(typeof a['query_type']!=='string')return;const c=QUERY_ACCOUNT_FIELD_ALIASES[a['query_type']];if(!c)return;if(a[c['canonical']]!==undefined)return;for(const d of c['aliases']){if(a[d]!==undefined){a[c['canonical']]=a[d],delete a[d],b['push']('query_toolkit\x20'+a['query_type']+':\x20normalized\x20\x27'+d+'\x27\x20→\x20\x27'+c['canonical']+'\x27');return;}}}const QUERY_NETWORK_CANONICAL={'testnet':'testnet','mainnet':'mainnet','localnet':'localnet'},QUERY_NETWORK_ACCEPTED=Object['keys'](QUERY_NETWORK_CANONICAL)['join'](',\x20'),QUERY_NETWORK_KEY_VARIANTS=['context_network','network','net','chain'];function queryNetworkCanonicalValue(a){return QUERY_NETWORK_CANONICAL[a['trim']()['toLowerCase']()['replace'](/[-_]/g,'')];}function queryNetworkKeyFor(a,b){if(typeof b!=='string'||b==='')return undefined;let c=a;while(!![]){const g=c['_def'];if(!g)break;const h=g['typeName']==='ZodEffects'?g['schema']:g['out']??g['innerType'];if(!h||h===c)break;c=h;}const d=c['_def']?.['options'];if(!Array['isArray'](d))return undefined;const e=[],f=i=>{for(const j of i){const k=j['_def']?.['options'];if(Array['isArray'](k)){f(k);continue;}e['push'](j);}};f(d);for(const i of e){const j=zodTopLevelShape(i);if(!j)continue;const k=j['query_type']?.['value'];if(k!==b)continue;if('context_network'in j)return'context_network';if('network'in j)return'network';return undefined;}return undefined;}function normalizeQueryNetworkSpellings(a,b,c){for(const e of QUERY_NETWORK_KEY_VARIANTS){const f=a[e];if(typeof f!=='string')continue;const g=queryNetworkCanonicalValue(f);g&&f!==g&&(a[e]=g,b['push']('query_toolkit:\x20normalized\x20'+e+'\x20\x27'+f+'\x27\x20→\x20\x27'+g+'\x27'));}const d=queryNetworkKeyFor(c,a['query_type']);if(d!==undefined)for(const h of QUERY_NETWORK_KEY_VARIANTS){if(h===d)continue;const i=a[h];if(typeof i!=='string'||i==='')continue;if(a[d]===undefined){a[d]=i;const j=d==='context_network'?'BI\x20family\x20key':'on-chain\x20query\x20family\x20key';b['push']('normalized\x20\x27'+h+'\x27\x20→\x20\x27'+d+'\x27\x20('+j+')');}else b['push']('ignored\x20redundant\x20\x27'+h+'\x27\x20—\x20\x27'+d+'\x27\x20already\x20set');delete a[h];}if(d!==undefined){const k=a[d];if(typeof k==='string'&&k!==''&&queryNetworkCanonicalValue(k)===undefined)return{'field':d,'message':'Unknown\x20network\x20\x27'+k+'\x27\x20for\x20\x27'+d+'\x27.\x20Accepted\x20values:\x20'+QUERY_NETWORK_ACCEPTED+'.\x20'+'An\x20unknown\x20network\x20is\x20rejected\x20here\x20instead\x20of\x20silently\x20querying\x20the\x20default\x20network\x20'+'(that\x20mismatch\x20reads\x20as\x20\x22no\x20data\x22\x20—\x20F-NND-07).'};}return undefined;}async function handleWowok(a,b,c){const {tool:d,data:g,normalizationNotes:h}=normalizeInput(a);let j;{const q=a&&typeof a==='object'&&!Array['isArray'](a)?a:undefined,r=g,s=typeof q?.['harness_override_note']==='string'?q['harness_override_note']:typeof r?.['harness_override_note']==='string'?r['harness_override_note']:undefined;if(typeof s==='string'&&s['trim']()){if(q&&q['harness_override_note']!==undefined)delete q['harness_override_note'];if(r&&r['harness_override_note']!==undefined)delete r['harness_override_note'];j=s['trim'](),h['push']('rescued\x20top-level\x20\x27harness_override_note\x27\x20(per-purchase\x20pre-buy\x20gate\x20appeal)\x20—\x20forwarded\x20to\x20the\x20handler');}}(d==='query_toolkit'||d==='onchain_table_data')&&normalizeQueryToolkitAliases(g,h);if(d==='query_toolkit'||d==='onchain_table_data'){const t=TOOL_REGISTRY_MAP['get'](d),u=t?normalizeQueryNetworkSpellings(g,h,t['config']['inputSchema']):undefined;if(u!==undefined)return{'content':[{'type':'text','text':'Schema\x20mismatch\x20for\x20'+d+'.\x201\x20error(s).\x20'+u['message']}],'structuredContent':{'result':{'status':'schema_mismatch','errors':[u['message']],'structured_errors':[{'path':u['field'],'code':'unrecognized_enum_value','message':u['message'],'suggestion':'Use\x20one\x20of:\x20'+QUERY_NETWORK_ACCEPTED+'\x20(spellings\x20like\x20\x27TestNet\x27/\x27test-net\x27\x20are\x20normalized\x20automatically).\x20Omit\x20the\x20key\x20to\x20use\x20the\x20current\x20default\x20network.'}],'hint':'Fix\x20the\x20network\x20value\x20and\x20retry.'},'schema':null}};}let l=![];{const w=a&&typeof a==='object'&&!Array['isArray'](a)?a:undefined,x=g;w?.['want_schema']===!![]&&(l=!![],delete w['want_schema']),x&&typeof x==='object'&&x['want_schema']===!![]&&(l=!![],delete x['want_schema']);}if(a&&typeof a==='object'&&!Array['isArray'](a)){const y=a;y['passport']!==undefined&&y['submission']===undefined&&(y['submission']=y['passport'],h['push']('accepted\x20top-level\x20\x27passport\x27\x20as\x20alias\x20for\x20\x27submission\x27'));if(y['submission']!==undefined){const A=g['submission'];if(A!==undefined)return{'content':[{'type':'text','text':'Schema\x20mismatch\x20for\x20'+d+'.\x201\x20error(s).\x20\x27submission\x27\x20was\x20provided\x20in\x20BOTH\x20the\x20top\x20level\x20and\x20inside\x20\x27data\x27\x20—\x20provide\x20it\x20in\x20only\x20ONE\x20place\x20(top\x20level\x20OR\x20data),\x20not\x20both.'}],'structuredContent':{'result':{'status':'schema_mismatch','errors':['\x27submission\x27\x20provided\x20twice:\x20top\x20level\x20AND\x20inside\x20data.\x20Provide\x20it\x20in\x20only\x20ONE\x20place.'],'structured_errors':[{'path':'submission','code':'duplicate_field','message':'\x27submission\x27\x20provided\x20both\x20at\x20the\x20top\x20level\x20and\x20inside\x20data.','suggestion':'Keep\x20the\x20submission\x20in\x20exactly\x20one\x20place:\x20either\x20wowok({tool,\x20data,\x20submission})\x20or\x20wowok({tool,\x20data:\x20{operation_type,\x20data:\x20{...},\x20env,\x20submission}}).'}],'hint':'Move\x20\x27submission\x27\x20to\x20a\x20single\x20location\x20and\x20retry.'},'schema':null}};g['submission']=y['submission'],h['push']('merged\x20top-level\x20\x27submission\x27\x20into\x20data');}}let m=![];{const B=a,C=B['data']!==undefined||B['args']!==undefined||B['params']!==undefined,D=B['env'],E=B['confirmed'];if(C&&(D!==undefined||E!==undefined)){const F=g,G=TOOL_REGISTRY['find'](I=>I['name']===d),H=G!==undefined?zodUnionAwareKeyCheck(G['config']['inputSchema'],'env')['hasEnvSlot']:!![];if(H){const I=F['env']!==undefined&&typeof F['env']==='object'&&!Array['isArray'](F['env'])?{...F['env']}:{},J=D!==undefined&&typeof D==='object'&&!Array['isArray'](D)?D:{},K={...J,...I};E!==undefined&&K['confirmed']===undefined&&(K['confirmed']=E),Object['keys'](K)['length']>0x0&&(F['env']=K,m=!![],h['push']('merged\x20top-level\x20env/confirmed\x20into\x20data.env\x20(env\x20belongs\x20INSIDE\x20data)'));}else{const L=D!==undefined&&typeof D==='object'&&!Array['isArray'](D)?D:{},M=[];for(const [N,O]of Object['entries'](L)){if(N==='confirmed')continue;if(F[N]!==undefined)continue;if(zodBranchAwareDeclared(G['config']['inputSchema'],N,F)){F[N]=O,M['push'](N);continue;}N==='network'&&F['context_network']===undefined&&zodBranchAwareDeclared(G['config']['inputSchema'],'context_network',F)&&(F['context_network']=O,M['push']('context_network'));}E!==undefined&&F['confirmed']===undefined&&zodBranchAwareDeclared(G['config']['inputSchema'],'confirmed',F)&&(F['confirmed']=E,M['push']('confirmed')),M['length']>0x0&&h['push']('top-level\x20env\x20skipped\x20(this\x20sub-tool\x20has\x20no\x20env\x20slot);\x20routed\x20'+M['join'](',\x20')+'\x20to\x20plain\x20data\x20fields\x20(F-22)');}}}if(a&&typeof a==='object'&&!Array['isArray'](a)){const P=a;if(P['idempotency_key']!==undefined){const Q=g;if(Q['idempotency_key']!==undefined&&Q['idempotency_key']!==P['idempotency_key'])return{'content':[{'type':'text','text':'Schema\x20mismatch\x20for\x20'+d+'.\x201\x20error(s).\x20\x27idempotency_key\x27\x20was\x20provided\x20in\x20BOTH\x20the\x20top\x20level\x20and\x20inside\x20\x27data\x27\x20with\x20different\x20values\x20—\x20provide\x20it\x20in\x20only\x20ONE\x20place.'}],'structuredContent':{'result':{'status':'schema_mismatch','errors':['\x27idempotency_key\x27\x20provided\x20twice\x20with\x20different\x20values:\x20top\x20level\x20AND\x20inside\x20data.'],'structured_errors':[{'path':'idempotency_key','code':'duplicate_field','message':'\x27idempotency_key\x27\x20is\x20set\x20both\x20at\x20the\x20top\x20level\x20and\x20inside\x20data,\x20to\x20different\x20values.','suggestion':'Keep\x20the\x20idempotency\x20key\x20in\x20exactly\x20one\x20place:\x20wowok({tool,\x20data,\x20idempotency_key})\x20or\x20wowok({tool,\x20data:\x20{…,\x20idempotency_key}}).'}],'hint':'Move\x20\x27idempotency_key\x27\x20to\x20a\x20single\x20location\x20and\x20retry.'},'schema':null}};Q['idempotency_key']=P['idempotency_key'],delete P['idempotency_key'],h['push']('merged\x20top-level\x20\x27idempotency_key\x27\x20into\x20data');}}if(!d){const R=a&&typeof a==='object'&&!Array['isArray'](a)?Object['keys'](a)['join'](',\x20')||'(none)':'(non-object\x20input:\x20'+typeof a+')',S=['Missing\x20\x27tool\x27\x20field.\x20Received\x20keys:\x20'+R,'Expected\x20one\x20of:\x20'+SUB_TOOL_NAMES['join'](',\x20')];return{'content':[{'type':'text','text':'Missing\x20\x27tool\x27\x20field.\x20Call\x20format:\x20wowok({\x20tool:\x20\x22<sub-tool>\x22,\x20data:\x20{<params>}\x20}).\x20Received\x20keys:\x20'+R+'.\x20Available\x20sub-tools:\x20'+SUB_TOOL_NAMES['join'](',\x20')}],'structuredContent':{'result':{'status':'schema_mismatch','errors':S,'hint':'Provide\x20\x27tool\x27\x20(one\x20of:\x20'+SUB_TOOL_NAMES['join'](',\x20')+')\x20and\x20\x27data\x27\x20(sub-tool\x20parameters).\x20Aliases\x20accepted:\x20tool_name/name→tool,\x20args/params→data.','received':truncateReceivedValue(a)},'schema':{'input':zodToJsonSchemaSafe(WowokToolDisplaySchema,'wowok'),'tool':'wowok'}}};}const n=TOOL_REGISTRY_MAP['get'](d);if(!n){const T=d['toLowerCase'](),U=T==='wowok',V=T['split']('_')['filter'](Boolean),W=U?[]:TOOL_REGISTRY['map'](Z=>Z['name'])['map'](Z=>{const a0=Z['toLowerCase']()['split']('_');let a1=0x0;if(a0[0x0]===V[0x0])a1+=0x2;a1+=a0['filter'](a2=>V['includes'](a2))['length'];if(a0['some'](a2=>a2['startsWith'](V[V['length']-0x1]??'')))a1+=0x1;return{'name':Z,'score':a1};})['filter'](Z=>Z['score']>0x0)['sort']((Z,a0)=>a0['score']-Z['score'])['slice'](0x0,0x5)['map'](Z=>Z['name']),X=U?'\x20NOTE:\x20\x27wowok\x27\x20is\x20the\x20DISPATCHER\x20tool\x20itself,\x20not\x20a\x20sub-tool.\x20Call\x20format:\x20wowok({\x20tool:\x20\x22<sub-tool-name>\x22,\x20data:\x20{<params>}\x20}).':'',Y=W['length']>0x0?'.\x20Did\x20you\x20mean:\x20'+W['join'](',\x20')+'?':'';return{'content':[{'type':'text','text':'Unknown\x20sub-tool:\x20\x27'+d+'\x27.\x20Available:\x20'+TOOL_REGISTRY['map'](Z=>Z['name'])['join'](',\x20')+X+Y}],'structuredContent':{'result':{'status':'error','errors':['Unknown\x20sub-tool:\x20'+d],'hint':'Available\x20sub-tools:\x20'+TOOL_REGISTRY['map'](Z=>Z['name'])['join'](',\x20')+X+Y,'suggestions':W},'schema':null}};}h['length']>0x0&&console['warn']('[wowok]\x20input\x20normalization\x20for\x20\x27'+d+'\x27:\x20'+h['join'](';\x20'));{const Z=g,a0=Z['env']&&typeof Z['env']==='object'&&!Array['isArray'](Z['env'])?Z['env']:undefined;if(a0?.['confirmed']!==undefined&&Z['confirmed']===undefined){const a1=zodUnionAwareKeyCheck(n['config']['inputSchema'],'confirmed');if(a1['declared']&&!a1['hasEnvSlot']){Z['confirmed']=a0['confirmed'],delete a0['confirmed'];if(Object['keys'](a0)['length']===0x0)delete Z['env'];h['push']('routed\x20rescued\x20top-level\x20confirmed\x20to\x20the\x20tool\x27s\x20own\x20confirmed\x20slot'),console['warn']('[wowok]\x20input\x20normalization\x20for\x20\x27'+d+'\x27:\x20confirmed\x20slot\x20re-routed\x20(F-10)');}}}const o=n['config']['inputSchema']['safeParse'](g),p=checkUnknownFields(n['config']['inputSchema'],g);if(!o['success']||p['length']>0x0){const a2=[];!o['success']&&a2['push'](...formatZodErrors(o['error'],g,n['config']['inputSchema']));p['length']>0x0&&a2['push']('Unknown\x20field(s):\x20'+p['join'](',\x20'));const a3=[];!o['success']&&a3['push'](...formatZodErrorsStructured(o['error'],g,n['config']['inputSchema']));if(p['length']>0x0){const ah=legalSiblingFields(n['config']['inputSchema'],g,[]);for(const ai of p){a3['push']({'path':ai,'code':'unrecognized_keys','message':'Unknown\x20field\x20\x27'+ai+'\x27\x20is\x20not\x20allowed','suggestion':ah?'Remove\x20field\x20\x27'+ai+'\x27.\x20Legal\x20fields\x20at\x20(root):\x20'+ah['join'](',\x20')+'.':'Remove\x20field\x20\x27'+ai+'\x27\x20or\x20check\x20the\x20schema\x20for\x20valid\x20field\x20names',...ah?{'legal_fields':ah}:{}});}}if(m){const aj='A\x20top-level\x20env/confirmed\x20was\x20merged\x20into\x20data.env\x20automatically\x20(contra\x20F-01\x20rescue),\x20but\x20THIS\x20sub-tool\x20does\x20not\x20accept\x20env\x20in\x20data.\x20Operation\x20tools\x20(onchain_operations\x20etc.)\x20take\x20env\x20inside\x20data;\x20query\x20tools\x20take\x20plain\x20data\x20fields\x20(e.g.\x20network)\x20instead\x20—\x20drop\x20the\x20env\x20key\x20for\x20this\x20call.';a2['push'](aj),a3['push']({'path':'env','code':'unrecognized_keys','message':'env\x20rescued\x20from\x20the\x20top\x20level,\x20but\x20this\x20sub-tool\x27s\x20data\x20schema\x20has\x20no\x20env\x20slot','suggestion':aj});}const a4=g??undefined,a5=a4!==undefined&&typeof a4['operation_type']==='string'&&a4['data']===undefined,a6=a3['some'](ak=>String(ak['path'])==='data'&&ak['code']==='invalid_type'&&/received undefined/i['test'](ak['message']));let a7;if(a6&&a5)a7='SHAPE\x20FIX\x20(rndb58d8d\x2004-ROOTCAUSE-A\x20A1):\x20operation\x20parameters\x20must\x20be\x20nested\x20INSIDE\x20a\x20\x27data\x27\x20object.\x20'+'The\x20envelope\x20is\x20{\x20operation_type:\x20\x27...\x27,\x20data:\x20{\x20<the\x20operation\x27s\x20parameters>\x20},\x20env?:\x20{...},\x20submission?:\x20{...}\x20}\x20'+'—\x20your\x20call\x20put\x20the\x20parameters\x20at\x20the\x20SAME\x20level\x20as\x20operation_type\x20(or\x20omitted\x20them),\x20so\x20\x27data\x27\x20arrived\x20undefined.\x20'+'Resend\x20with\x20the\x20parameters\x20wrapped\x20in\x20data.\x20This\x20is\x20a\x20static\x20shape\x20error,\x20NOT\x20session\x20state\x20—\x20no\x20restart\x20is\x20needed\x20'+'(this\x20server\x20is\x20stateless).\x20Also\x20discard\x20any\x20schema\x20slice\x20you\x20cached\x20from\x20an\x20earlier\x20call\x20for\x20a\x20DIFFERENT\x20'+'operation_type\x20—\x20slices\x20are\x20union-variant\x20specific\x20and\x20reusing\x20one\x20across\x20variants\x20mangles\x20the\x20payload.',a2['push'](a7),a3['push']({'path':'data','code':'invalid_type','message':'parameters\x20must\x20be\x20nested\x20inside\x20data\x20(flat\x20envelope:\x20parameters\x20found\x20as\x20siblings\x20of\x20operation_type)','suggestion':a7});else a6&&(a7='DIAGNOSTIC:\x20\x27data\x27\x20arrived\x20at\x20validation\x20as\x20undefined.\x20Send\x20the\x20tool\x27s\x20parameters\x20inside\x20the\x20\x27data\x27\x20object\x20'+'(for\x20onchain_operations:\x20{\x20operation_type:\x20\x27...\x27,\x20data:\x20{\x20<parameters>\x20},\x20env?,\x20submission?\x20}).\x20If\x20you\x20are\x20CERTAIN\x20'+'your\x20client\x20transmitted\x20a\x20well-formed\x20payload,\x20inspect\x20what\x20the\x20wrapper\x20actually\x20sent\x20before\x20retrying\x20—\x20identical\x20'+'retries\x20cannot\x20recover\x20from\x20a\x20construction\x20error.\x20(C-11\x27s\x20old\x20\x27wrapper\x20state\x20corruption\x20/\x20restart\x20the\x20session\x27\x20'+'conclusion\x20was\x20retired\x20by\x20rndb58d8d\x2004-ROOTCAUSE-A:\x20a\x20stateless\x20server\x20cannot\x20diagnose\x20caller-side\x20runtime\x20state.)',a2['push'](a7),a3['push']({'path':'data','code':'invalid_type','message':'data\x20is\x20required\x20—\x20the\x20tool\x27s\x20parameters\x20belong\x20inside\x20the\x20data\x20object','suggestion':a7}));const a8=loadPreGeneratedSchema(d)??zodToJsonSchemaSafe(n['config']['inputSchema'],d),a9=extractRelevantSchema(a8,d,g),aa=capSchemaDepth(compactMismatchSchemaInput(a9,g),0x0),ab=matchedVariantLegalKeys(aa)['filter'](ak=>ak!=='env');if(ab['length']>0x0){const ak='Legal\x20keys\x20for\x20this\x20input:\x20'+ab['join'](',\x20')+'.';for(const al of a3){al['code']==='unrecognized_keys'&&!String(al['suggestion'])['includes']('Legal\x20keys')&&(al['suggestion']=al['suggestion']+'\x20'+ak);}for(let am=0x0;am<a2['length'];am++){/^(Unknown field\(s\):|.*(Unrecognized key|unexpected key))/i['test'](a2[am])&&!a2[am]['includes']('Legal\x20keys')&&(a2[am]=a2[am]+'\x20'+ak);}}{const an=arbNestingExamplesForSchemaErrors(d,g,a3);an&&(a2['push'](an['line']),a3['push'](an['structured']));}capMismatchErrors(a2,a3);const ac=a3[0x0]?.['suggestion']?'\x20FIRST\x20ERROR\x20SUGGESTION:\x20'+a3[0x0]['suggestion']:'',ad=a2['slice'](0x0,0x5)['map']((ao,ap)=>'\x20\x20'+(ap+0x1)+'.\x20'+ao)['join']('\x0a'),ae=buildSchemaPreview(a9,d,g),af=l?'Full\x20JSON\x20Schema\x20is\x20in\x20the\x20structuredContent.schema.input\x20field\x20(cache\x20it\x20ONLY\x20for\x20future\x20'+d+'\x20calls\x20with\x20the\x20SAME\x20operation_type/variant\x20—\x20slices\x20are\x20branch-specific;\x20a\x20different\x20operation_type\x20needs\x20a\x20fresh\x20schema).':'Full\x20JSON\x20Schema\x20was\x20omitted\x20(compact\x20default):\x20re-send\x20with\x20want_schema:true\x20to\x20receive\x20it\x20in\x20structuredContent.schema.input,\x20or\x20use\x20schema_query\x20(action=\x27get\x27)\x20for\x20a\x20specific\x20sub-schema.',ag=['Schema\x20mismatch\x20for\x20'+d+'.\x20'+a2['length']+'\x20error(s).'+ac,ad,...a7?['','⚠\x20'+a7]:[],'',ae,'','Fix\x20the\x20parameters\x20based\x20on\x20the\x20errors\x20above\x20and\x20the\x20schema\x20summary,\x20then\x20retry.',af,'Structured\x20errors\x20with\x20fix\x20suggestions\x20are\x20in\x20structuredContent.result.structured_errors\x20(ARCH-02).',SKILLS_MISMATCH_POINTER]['filter'](Boolean)['join']('\x0a');return{'content':[{'type':'text','text':ag}],'structuredContent':{'result':{'status':'schema_mismatch','errors':a2,'structured_errors':a3,'hint':schemaMismatchHint(d)},...l?{'schema':{'input':aa,'tool':d}}:{'schema':null}}};}try{j!==undefined&&(g['harness_override_note']=j);const ao=await dispatchToolCall(d,g,b,c);if(ao['resultType']==='input_required')return ao;const ap=ao['structuredContent'],aq=ap?.['result'],ar=aq?.['status']==='error'||aq?.['status']==='schema_mismatch'||aq?.['operation']==='error'||aq?.['type']==='error';if(ar){const aw={'status':'error','data':ao['structuredContent'],'errors':[ao['content'][0x0]?.['text']??'Sub-tool\x20returned\x20an\x20error']};if(typeof aq?.['error_code']==='string')aw['error_code']=aq['error_code'];if(typeof aq?.['retryable']==='boolean')aw['retryable']=aq['retryable'];if(typeof aq?.['recovery_hint']==='string')aw['recovery_hint']=aq['recovery_hint'];if(aq?.['refused']===!![])aw['refused']=!![];if(aq?.['tx_submitted']===![])aw['tx_submitted']=![];return{'content':ao['content'],'structuredContent':{'result':aw,'schema':null}};}const as=typeof ap?.['outcome']==='string'?ap['outcome']:undefined,at=ap?.['verdict'],au=at!==undefined&&typeof at==='object'&&at['buildable']===![],av=au?'error':as===undefined||as==='executed'?'success':as==='failed'?'error':'pending';return{'content':ao['content'],'structuredContent':{'result':{'status':av,...as!==undefined?{'outcome':as}:{},...au?{'errors':['Plan\x20audit\x20BLOCKED\x20(verdict.buildable=false)\x20—\x20see\x20data.verdict.blockers\x20and\x20data.next_action.\x20Do\x20NOT\x20materialize\x20this\x20plan.']}:{},'data':ao['structuredContent']},'schema':null}};}catch(ax){const ay=normalizeErrorMessage(ax);if(isSchemaValidationError(ay)){const aE=loadPreGeneratedSchema(d)??zodToJsonSchemaSafe(n['config']['inputSchema'],d),aF=extractRelevantSchema(aE,d,g),aG=buildSchemaPreview(aF,d,g),aH=[{'path':'(runtime)','code':'schema_validation_error','message':ay,'suggestion':'Check\x20the\x20error\x20message\x20and\x20the\x20schema\x20below\x20for\x20the\x20correct\x20field\x20format'}],aI=['Schema\x20mismatch\x20for\x20'+d+':\x20'+ay,'',aG,'','Fix\x20the\x20parameters\x20and\x20retry.',l?'Full\x20JSON\x20Schema\x20is\x20in\x20structuredContent.schema.input.':'Full\x20JSON\x20Schema\x20was\x20omitted\x20(compact\x20default):\x20re-send\x20with\x20want_schema:true\x20to\x20receive\x20it\x20in\x20structuredContent.schema.input.','Structured\x20errors\x20with\x20fix\x20suggestions\x20are\x20in\x20structuredContent.result.structured_errors\x20(ARCH-02).',SKILLS_MISMATCH_POINTER]['join']('\x0a');return{'content':[{'type':'text','text':aI}],'structuredContent':{'result':{'status':'schema_mismatch','errors':[ay],'structured_errors':aH,'hint':schemaMismatchHint(d)},...l?{'schema':{'input':compactMismatchSchemaInput(aF,g),'tool':d}}:{'schema':null}}};}const az=/Unexpected token.*?\((\d+):(\d+)\)/['exec'](ay)??(/^(Unexpected end of JSON input|JSON\.parse)/['test'](ay)?[ay,'','']:null);if(az){const aJ=az[0x1]?Number(az[0x1]):undefined,aK=az[0x2]?Number(az[0x2]):undefined,aL=aJ!==undefined?'\x20at\x20line\x20'+aJ+',\x20column\x20'+aK:'',aM=loadPreGeneratedSchema(d)??zodToJsonSchemaSafe(n['config']['inputSchema'],d),aN=extractRelevantSchema(aM,d,g),aO=[{'path':'(root)','code':'malformed_json','message':'A\x20JSON\x20string\x20in\x20the\x20arguments\x20could\x20not\x20be\x20parsed'+aL+':\x20'+ay+'.\x20'+'Any\x20argument\x20passed\x20as\x20a\x20STRING\x20must\x20itself\x20be\x20valid\x20JSON.','suggestion':'Send\x20objects/arrays\x20as\x20real\x20JSON\x20values,\x20not\x20as\x20stringified\x20JSON.\x20'+'If\x20a\x20string\x20field\x20is\x20genuinely\x20textual\x20(description,\x20message,\x20remark),\x20it\x20must\x20NOT\x20be\x20quoted-and-escaped\x20JSON.\x20'+'If\x20the\x20argument\x20shape\x20is\x20confirmed\x20valid,\x20the\x20payload\x20may\x20have\x20been\x20TRUNCATED\x20before\x20parsing\x20—\x20arguments\x20past\x20a\x20'+'transport\x20size\x20limit\x20fail\x20with\x20this\x20same\x20envelope;\x20shrink\x20the\x20payload\x20(fewer\x20or\x20smaller\x20items)\x20and\x20retry.'}];return{'content':[{'type':'text','text':['Malformed\x20JSON\x20in\x20the\x20arguments\x20to\x20'+d+aL+':\x20'+ay,'',buildSchemaPreview(aN,d,g),'','Fix\x20the\x20parameters\x20and\x20retry.',l?'Full\x20JSON\x20Schema\x20is\x20in\x20structuredContent.schema.input.':'Full\x20JSON\x20Schema\x20was\x20omitted\x20(compact\x20default):\x20re-send\x20with\x20want_schema:true\x20to\x20receive\x20it\x20in\x20structuredContent.schema.input.']['join']('\x0a')}],'structuredContent':{'result':{'status':'schema_mismatch','errors':[ay],'structured_errors':aO,'hint':schemaMismatchHint(d)},...l?{'schema':{'input':compactMismatchSchemaInput(aN,g),'tool':d}}:{'schema':null}}};}const aA=classifyError(ay,ax),aB={'status':'error','errors':[ay]};if(aA['error_code']!==undefined)aB['error_code']=aA['error_code'];if(aA['retryable']!==undefined)aB['retryable']=aA['retryable'];if(aA['recovery_hint']!==undefined)aB['recovery_hint']=aA['recovery_hint'];const aC=g?.['env'],aD=g?.['idempotency_key'];return Object['assign'](aB,unknownOutcomeFields(aA,ax,aC,typeof aD==='string'?aD:undefined)),Object['assign'](aB,catalogFieldsFor(aA,ay)??{}),{'content':[{'type':'text','text':'Error:\x20'+ay}],'structuredContent':{'result':aB,'schema':null}};}}function zodToJsonSchemaSafe(a,b){try{const c=z['toJSONSchema'](a,{'unrepresentable':'any','target':'draft-07'});if(c&&typeof c==='object'&&!Array['isArray'](c)){const {$schema:d,...e}=c;return e;}return{'type':'object'};}catch{return{'type':'object','additionalProperties':!![]};}}function resolveSchemaRefs(a){const b=new Set(['definitions','$schema','$id']);function c(e){if(!e['startsWith']('#/'))return null;const f=e['slice'](0x2)['split']('/');let g=a;for(const h of f){if(g==null||typeof g!=='object')return null;g=g[h];}return g;}function d(e,f){if(!e||typeof e!=='object')return e;if(Array['isArray'](e))return e['map'](i=>d(i,f));const g=e;if(typeof g['$ref']==='string'){const i=g['$ref'];if(f['has'](i))return{'type':'object','additionalProperties':!![]};const j=c(i);if(j&&typeof j==='object'&&!Array['isArray'](j)){const l=new Set(f);l['add'](i);const m=d(j,l),n={};for(const [o,p]of Object['entries'](g)){if(o!=='$ref'&&!b['has'](o))n[o]=p;}return{...m,...n};}return{'type':'object','additionalProperties':!![]};}const h={};for(const [q,r]of Object['entries'](g)){if(b['has'](q))continue;h[q]=d(r,f);}return h;}return d(a,new Set());}function loadPreGeneratedSchema(a){const b=preGeneratedSchemaCache['get'](a);if(b)return b;for(const c of SCHEMA_DIR_CANDIDATES){try{const d=join(c,a+'.schema.json'),e=readFileSync(d,'utf-8'),f=JSON['parse'](e),g=resolveSchemaRefs(f);return preGeneratedSchemaCache['set'](a,g),g;}catch{}}return null;}export function listTools(){return[{'name':'wowok','title':'WoWok\x20MCP','description':WOWOK_TOOL_DESCRIPTION,'inputSchema':resolveSchemaRefs(zodToJsonSchemaSafe(WowokToolDisplaySchema,'wowok'))}];}let startupUpgradeNoticeAttached=![],startupNoticePromise=null,upgradeEnforcementDecided=![];function startupNotice(){return startupNoticePromise??=getStartupUpgradeNotice(),startupNoticePromise;}async function upgradeRequiredResult(){if(upgradeEnforcementDecided)return null;let a=null;try{a=await startupNotice();}catch{a=null;}if(!a)return null;upgradeEnforcementDecided=!![];if(!a['enforced'])return null;const b='WoWok\x20upgrade\x20REQUIRED\x20—\x20tool\x20calls\x20are\x20blocked\x20until\x20the\x20local\x20package\x20is\x20current.\x0a'+(a['message']+'\x0a')+('To\x20stay\x20on\x20the\x20current\x20version\x20anyway,\x20write\x20{\x22enforce\x22:\x20false}\x20to\x20'+upgradePolicyPath()+'\x20and\x20restart.');return{'content':[{'type':'text','text':b}],'structuredContent':{'result':{'status':'error','error_code':'UPGRADE_REQUIRED','retryable':![],'recovery_hint':b,'data':{'upgrade_notice':a}},'schema':null}};}async function attachStartupUpgradeNotice(a){if(startupUpgradeNoticeAttached)return a;try{const b=await startupNotice();if(!b)return a;startupUpgradeNoticeAttached=!![];if(b['enforced'])return a;const c={...a};return Array['isArray'](a['content'])&&(c['content']=[...a['content'],{'type':'text','text':'\x0a⚠\x20'+b['message']+'\x0a'+'Surface\x20this\x20upgrade\x20notice\x20to\x20the\x20user\x20once\x20in\x20this\x20conversation\x20(do\x20not\x20wait\x20for\x20them\x20to\x20ask).'}]),a['structuredContent']&&typeof a['structuredContent']==='object'&&(c['structuredContent']={...a['structuredContent'],'upgrade_notice':b}),c;}catch{return startupUpgradeNoticeAttached=!![],a;}}export const wowokErrorShape=(a,b,c,d)=>{const e={'status':'error','errors':[a]};if(b['error_code']!==undefined)e['error_code']=b['error_code'];if(b['retryable']!==undefined)e['retryable']=b['retryable'];if(b['recovery_hint']!==undefined)e['recovery_hint']=b['recovery_hint'];const f=normalizeInput(c['data'])['data']??{};return Object['assign'](e,unknownOutcomeFields(b,d,f['env'],typeof f['idempotency_key']==='string'?f['idempotency_key']:undefined)),Object['assign'](e,catalogFieldsFor(b,a)??{}),{'result':e,'schema':null};};export async function wowokTimeoutVerify(a){try{const b=normalizeInput(a),c=b['tool']?TOOL_REGISTRY_MAP['get'](b['tool']):undefined;if(!c?.['onTimeoutVerify'])return undefined;const d={...b['data']??{}},e=a&&typeof a==='object'&&!Array['isArray'](a)?a:{};for(const g of['env','submission','idempotency_key']){if(d[g]===undefined&&e[g]!==undefined)d[g]=e[g];}const f=await c['onTimeoutVerify'](d);if(!f)return undefined;return'SUB-TOOL\x20\x27'+c['name']+'\x27\x20VERIFY-FIRST\x20READBACK\x20(the\x20unified\x20wrapper\x20stopped\x20waiting;\x20the\x20transaction\x20was\x20NOT\x20cancelled):\x0a'+f;}catch{return undefined;}}export function registerAllTools(a){const b=0x2bf20,c=async(e,f)=>handleWowok(e,undefined,f),d=wrapHandlerWithErrorShape(c,b,'wowok',wowokErrorShape,wowokTimeoutVerify);a['registerTool']('wowok',{'title':'WoWok\x20MCP','description':WOWOK_TOOL_DESCRIPTION,'inputSchema':WowokToolRuntimeSchema,'annotations':{'readOnlyHint':![],'destructiveHint':!![],'idempotentHint':![],'openWorldHint':!![]}},async(e,f)=>{const g=await upgradeRequiredResult();if(g)return g;return attachStartupUpgradeNotice(sanitizeToolDispatchResult(await d(e,f?.['mcpReq']?.['inputResponses']?{'inputResponses':f['mcpReq']['inputResponses']}:undefined)));}),overrideToolsListHandler(a);}function overrideToolsListHandler(a){a['server']['setRequestHandler']('tools/list',()=>({'tools':[{'name':'wowok','title':'WoWok\x20MCP','description':WOWOK_TOOL_DESCRIPTION,'inputSchema':ensureObjectType(zodToJsonSchemaSafe(WowokToolDisplaySchema,'wowok')),'annotations':{'readOnlyHint':![],'destructiveHint':!![],'idempotentHint':![],'openWorldHint':!![]}}]}));}function ensureObjectType(a){if(a['type']==='object')return a;return{...a,'type':'object'};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{handleIndustryPackOperation}from'../handlers/industry-pack.js';import{handleBenchmarkMigrationOperation}from'../handlers/benchmark-migration.js';import{handleStrategyReviewOperation}from'../handlers/strategy-review.js';import{handleWorkspaceOperation}from'../handlers/workspace.js';import{handleWorkflowOperation}from'../handlers/workflow.js';import{handlePermissionOperation}from'../handlers/permission.js';import{handleServiceCloneOperation}from'../handlers/service-clone.js';import{createToolMeta,IndustryPackOperationInputSchema,IndustryPackOperationOutputSchema,BenchmarkMigrationSchema,BenchmarkMigrationOutputSchema,StrategyReviewOperationInputSchema,StrategyReviewOperationOutputSchema,WorkspaceOperationInputSchema,WorkspaceOperationOutputSchema,WorkflowOperationInputSchema,WorkflowOperationOutputSchema,PermissionOperationInputSchema,PermissionOperationOutputSchema,ServiceCloneSchema,ServiceCloneOutputSchema}from'../../schema/index.js';import{CATALOG_INDUSTRY_COUNT as a578a,CATALOG_TEMPLATE_COUNT as a578b}from'../../knowledge/catalog-facts.js';export const BUSINESS_TOOLS=[{'name':'industry_pack_operation','handler':handleIndustryPackOperation,'config':{'title':'🧩\x20Industry\x20Pack\x20-\x20Knowledge\x20Template\x20Orchestration','summary':'Industry\x20knowledge\x20packs:\x20scaffold,\x20register,\x20list,\x20reset\x20templates.','description':'Manage\x20industry\x20knowledge\x20packs\x20(distributable,\x20registrable,\x20versionable\x20units\x20carrying\x20'+'one\x20industry\x27s\x20object-shape,\x20matching\x20rules,\x20and\x20role\x20personae).\x0a\x0a'+'Pack\x20layout\x20(merged\x20v2):\x20pack.json\x20(settings\x20only\x20—\x20manifest\x20+\x20match\x20+\x20personae\x20+\x20'+'dispute/compliance/supply/rules\x20sections;\x20field\x20explanations\x20live\x20in\x20the\x20industry-root\x20'+'README.md)\x20and\x20playbook.md\x20(chaptered\x20AI\x20prompt\x20guide).\x20Legacy\x20split-file\x20layouts\x20'+'(manifest.json/match.json/personae)\x20are\x20still\x20read\x20for\x20backward\x20compatibility.\x0a\x0a'+'Actions:\x0a'+'\x20\x20•\x20scaffold\x20—\x20generate\x20a\x20pack\x20template\x20skeleton\x20(pack.json\x20+\x20playbook.md,\x20settings\x20only)\x20'+'into\x20the\x20industry\x20directory;\x20the\x20user\x20fills\x20in\x20the\x20content.\x0a'+'\x20\x20•\x20list\x20—\x20list\x20currently\x20registered\x20packs.\x0a'+'\x20\x20•\x20scan\x20—\x20scan\x20+\x20register\x20every\x20pack\x20under\x20the\x20default\x20industry\x20directory.\x0a'+'\x20\x20?\x20template_drift\x20-\x20REPORT\x20builtin\x20template\x20files\x20whose\x20on-disk\x20body\x20differs\x20from\x20the\x20'+'in-code\x20catalog\x20(no_sentinel_legacy\x20/\x20stale_release\x20/\x20user_modified).\x20Run\x20this\x20FIRST\x20when\x20a\x20'+'template\x20change\x20appears\x20to\x20have\x20no\x20effect:\x20a\x20builtin\x20file\x20seeded\x20before\x20the\x20release\x20'+'sentinel\x20existed\x20carries\x20no\x20sentinel\x20and\x20is\x20never\x20upgraded\x20automatically.'+'\x20\x20?\x20repair_builtin_templates\x20-\x20RESEED\x20those\x20legacy\x20files\x20from\x20the\x20in-code\x20catalog.\x20'+'Identity-gated\x20on\x20a\x20known\x20builtin\x20id;\x20the\x20previous\x20body\x20is\x20kept\x20in\x20the\x20hidden\x20templates/.archive/\x20dir\x20and\x20a\x20'+'custom\x20(user)\x20template\x20is\x20never\x20touched.'+'\x20\x20•\x20resolve\x20—\x20return\x20the\x20industry\x20root\x20directory.\x0a'+'\x20\x20•\x20list_files\x20—\x20list\x20files\x20under\x20the\x20industry\x20directory.\x0a'+'\x20\x20•\x20read_file\x20—\x20read\x20a\x20file\x20under\x20the\x20industry\x20directory\x20(path\x20required).\x0a'+'\x20\x20•\x20write_file\x20—\x20write\x20content\x20to\x20a\x20file\x20under\x20the\x20industry\x20directory\x20(path\x20+\x20content\x20required).\x0a'+'\x20\x20•\x20get\x20—\x20return\x20registered\x20layer\x20data\x20for\x20an\x20industry\x20(name\x20required;\x20dispute/compliance/supply/rules/playbook).\x0a'+'\x20\x20\x20\x20layer=\x27template\x27\x20returns\x20one\x20builtin\x20template\x20(merge-safe\x20projection);\x20layer=\x27params\x27\x20is\x20the\x0a'+'\x20\x20\x20\x20merchant-facing\x20SETTINGS\x20surface:\x20with\x20template=\x27<id>\x27\x20every\x20declared\x20parameter\x20in\x20business\x20order\x0a'+'\x20\x20\x20\x20(tier,\x20tags,\x20kind/unit,\x20meaning,\x20default,\x20accepted\x20values,\x20PROVEN\x20live/inert\x20status,\x20landing,\x20editable);\x0a'+'\x20\x20\x20\x20with\x20\x27query\x27\x20instead\x20of\x20a\x20template\x20id\x20it\x20searches\x20the\x20catalog\x20for\x20a\x20business\x20facet\x20(\x27settlement\x20window\x27,\x0a'+'\x20\x20\x20\x20\x27take\x20rate\x27)\x20and\x20returns\x20ranked\x20hits\x20with\x20explainable\x20reasons\x20—\x20an\x20empty\x20list\x20means\x20no\x20such\x20setting.\x0a'+'\x20\x20\x20\x20layer=\x27components\x27\x20is\x20the\x20COMPONENT\x20surface\x20beside\x20it:\x20one\x20slot\x20per\x20Service/Sale\x20field,\x20allocator\x0a'+'\x20\x20\x20\x20row,\x20per-order\x20Allocation,\x20Machine,\x20Guard,\x20Repository\x20policy,\x20reward,\x20arbitration\x20binding,\x20permission\x0a'+'\x20\x20\x20\x20and\x20treasury\x20item\x20—\x20each\x20with\x20what\x20it\x20is,\x20how\x20it\x20is\x20configured\x20(lifecycle\x20surface\x20create/pre-publish/\x0a'+'\x20\x20\x20\x20append-only/post-publish/immutable\x20+\x20the\x20exact\x20field\x20path),\x20the\x20effect\x20once\x20it\x20applies,\x20and\x20what\x20it\x20is\x0a'+'\x20\x20\x20\x20bound\x20to;\x20a\x20non-configurable\x20slot\x20always\x20carries\x20why_not\x20(e.g.\x20a\x20split\x20hard-coded\x20in\x20the\x20template\x20body).\x0a'+'\x20\x20•\x20capability_list\x20—\x20list\x20the\x20Capability\x20Lattice\x20registry\x20(composable\x20business\x20units;\x20optional\x20group\x20filter).\x0a'+'\x20\x20•\x20capability_get\x20—\x20full\x20card\x20of\x20ONE\x20capability\x20(intent/binds/requires/excludes/risks/disclosures/cost/constraints).\x0a'+'\x20\x20•\x20compose_probe\x20—\x20probe\x20whether\x20a\x20capability\x20selection\x20can\x20coexist\x20in\x20one\x20build\x20(capabilities[]\x20required;\x20optional\x20template\x20as\x20base\x20build).\x0a'+'\x20\x20•\x20product_cards\x20—\x20FRONT-stage\x20ProductCard\x20summaries\x20for\x20the\x20catalog\x20or\x20one\x20industry\x20(optional\x20name\x20filter).\x0a'+'\x20\x20•\x20product_card\x20—\x20the\x20full\x20ProductCard\x20of\x20ONE\x20builtin\x20template\x20(template\x20id\x20required):\x20alignment/features/cost/params/risks,\x20every\x20assertion\x20projected\x20from\x20declared\x20data.\x0a'+'\x20\x20•\x20diff\x20—\x20compare\x20registered\x20vs\x20on-disk\x20manifest\x20version/layers\x20(name\x20required).\x0a'+'\x20\x20•\x20reset\x20—\x20restore\x20a\x20file\x20or\x20entire\x20pack\x20folder\x20to\x20its\x20pristine\x20annotated\x20template\x20(path\x20required).\x0a'+'\x20\x20•\x20delete_file\x20—\x20delete\x20a\x20file\x20or\x20directory\x20(path\x20required).\x0a'+'\x20\x20•\x20create_file\x20—\x20create\x20an\x20empty\x20file\x20(path\x20required;\x20content\x20optional).\x0a'+'\x20\x20•\x20create_dir\x20—\x20create\x20a\x20directory\x20recursively\x20(path\x20required).\x0a'+'\x20\x20•\x20copy\x20—\x20copy\x20a\x20file\x20or\x20directory\x20(from\x20+\x20to\x20required).\x0a'+'\x20\x20•\x20move\x20/\x20rename\x20—\x20move\x20or\x20rename\x20a\x20file\x20or\x20directory\x20(from\x20+\x20to\x20required).\x0a'+'\x20\x20•\x20recommend_industry\x20—\x20business\x20intent\x20text\x20→\x20top-3\x20similar\x20industry\x20modes\x20(trait\x20similarity;\x20optional\x20strategy\x20statements\x20re-rank\x20by\x20lever\x20alignment).\x0a'+'\x20\x20•\x20list_modes\x20—\x20list\x20builtin\x20+\x20caller\x27s\x20custom\x20industry\x20modes.\x0a'+'\x20\x20•\x20derive_user_mode\x20—\x20derive\x20(and\x20register)\x20a\x20custom\x20mode\x20from\x20a\x20builtin\x20mode.\x0a'+'\x20\x20•\x20evolve_user_mode\x20—\x20iterate\x20an\x20existing\x20custom\x20mode\x20(version-bumped\x20evolution\x20history).\x0a'+'\x20\x20•\x20register_user_mode\x20—\x20register\x20a\x20fully\x20custom\x20mode\x20(machine_shape\x20+\x20key_risk\x20required).\x0a'+'\x20\x20•\x20unregister_user_mode\x20—\x20delete\x20a\x20custom\x20mode\x20(owner\x20only).\x0a'+'\x20\x20•\x20register_custom_metric\x20—\x20register\x20a\x20global\x20custom\x20evaluation\x20metric\x20(risk/benefit;\x20persisted).\x0a'+'\x20\x20•\x20unregister_custom_metric\x20—\x20delete\x20a\x20custom\x20metric\x20(custom\x20only;\x20builtin\x20metrics\x20cannot\x20be\x20deleted).\x0a'+'\x20\x20•\x20register_custom_constraint\x20—\x20register\x20a\x20custom\x20mode\x20constraint\x20(4\x20rule\x20types;\x20hard/soft;\x20persisted).\x0a'+'\x20\x20•\x20unregister_custom_constraint\x20—\x20delete\x20a\x20custom\x20constraint\x20(custom\x20only;\x20builtin\x20constraints\x20cannot\x20be\x20deleted).\x0a'+'\x20\x20•\x20list_metrics_constraints\x20—\x20list\x20metrics\x20+\x20constraints\x20(filterable\x20by\x20type/scope).\x0a\x0a'+'Local\x20filesystem\x20+\x20in-memory\x20registry\x20only;\x20never\x20mutates\x20chain\x20state.\x0a\x0a'+'💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27industry_pack_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema.','inputSchema':IndustryPackOperationInputSchema,'outputSchema':IndustryPackOperationOutputSchema,'annotations':{'readOnlyHint':![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':![]},'_meta':createToolMeta('industry_pack',['industry','pack','mode','match','persona','scaffold','template'])}},{'name':'benchmark_migration_operation','handler':handleBenchmarkMigrationOperation,'config':{'title':'🏆\x20Template\x20Migration\x20-\x20Industry\x20Templates\x20&\x20Competitor\x20Migration','summary':'MD\x20industry-archetype\x20templates\x20(hot-loaded,\x20'+a578b+'\x20built-ins)\x20+\x20pre-deploy\x20risk\x20scan\x20+\x20one-click\x20competitor\x20migration.','description':'Industry-archetype\x20MD\x20templates\x20and\x20one-click\x20competitor\x20migration\x20(V2\x20MD-template\x20architecture).\x20'+'Templates\x20live\x20in\x20`.wowok/industry/<industry>/templates/<variant>.md`\x20(the\x20client\x27s\x20industry\x20drawer\x20tree\x20—\x20hot-loaded,\x20zod-validated\x20frontmatter;\x20'+(a578b+'\x20built-in\x20archetypes\x20across\x20'+a578a+'\x20industries\x20are\x20seeded\x20idempotently\x20and\x20never\x20')+'overwritten).\x20Each\x20template\x20is\x20a\x20ScenarioMode-compatible\x20build\x20shape\x20(machine_shape\x20/\x20guards\x20/\x20'+'allocator)\x20plus\x20fee\x20parameters\x20and\x20R1-R10\x20trust\x20mechanisms.\x0a\x0a'+'Product\x20tagging:\x20every\x20built-in\x20carries\x20a\x20`product_ref`\x20benchmark\x20slug\x20(e.g.\x20retail/scale-marketplace\x20→\x20'+'\x27amazon\x27,\x20travel/global-ota\x20→\x20\x27booking-com\x27).\x20This\x20is\x20the\x20ONLY\x20sanctioned\x20company\x20name\x20—\x20it\x20lets\x20a\x20user\x20'+'pick\x20a\x20template\x20by\x20naming\x20the\x20incumbent\x20product\x20they\x20want\x20to\x20migrate\x20from.\x20When\x20the\x20user\x20names\x20a\x20product,\x20'+'call\x20template_list\x20and\x20match\x20on\x20product_ref,\x20then\x20template_generate/migration_apply\x20with\x20that\x20template_id.\x0a\x0a'+'Three\x20build\x20modes\x20(choose\x20from\x20the\x20user\x27s\x20intent):\x0a'+'\x20\x20•\x20template-driven\x20—\x20pick\x20the\x20closest\x20product_ref/industry\x20template,\x20adopt\x20it\x20as-is\x20(template_generate).\x0a'+'\x20\x20•\x20template\x20+\x20partial\x20customization\x20—\x20start\x20from\x20a\x20template,\x20then\x20override\x20fee_params\x20(fee_overrides)\x20or\x20'+'edit\x20the\x20MD\x20file\x20via\x20industry_pack_operation\x20write_file\x20before\x20generating.\x0a'+'\x20\x20•\x20fully\x20custom\x20—\x20skip\x20templates;\x20drive\x20the\x20merchant-guide\x20pipeline\x20from\x20a\x20free-text\x20description.\x0a\x0a'+'Actions:\x0a'+'\x20\x20•\x20template_list\x20—\x20list\x20the\x20loaded\x20MD\x20templates\x20(optional\x20industry\x20filter;\x20rows\x20carry\x20product_ref);\x20load\x20errors\x20are\x20'+'reported,\x20never\x20silently\x20dropped.\x0a'+'\x20\x20•\x20template_get\x20—\x20fetch\x20one\x20template\x20by\x20template_id\x20(full\x20machine_shape/guards/allocator/'+'fee_params/trust_mechanisms/body).\x0a'+'\x20\x20•\x20template_generate\x20—\x20generate\x20a\x20creation\x20plan\x20from\x20a\x20template\x20via\x20the\x20merchant-guide\x20pipeline\x20'+'(template_id\x20required;\x20scan-first\x20—\x20CRITICAL\x20findings\x20block;\x20description\x20optional\x20as\x20the\x20intent\x20'+'text;\x20fee_overrides\x20optional;\x20never\x20executes\x20on-chain).\x0a'+'\x20\x20•\x20plan_execute\x20—\x20execute\x20the\x20plan\x20returned\x20by\x20template_generate\x20in\x20ONE\x20call\x20(plan\x20required):\x20'+'materializes\x20every\x20step\x20in\x20order\x20through\x20the\x20built-in\x20executor\x20(chain\x20writes).\x20On\x20a\x20mid-plan\x20'+'failure\x20the\x20response\x20carries\x20a\x20ready-to-pass\x20`resume`\x20payload\x20(completed_steps\x20+\x20previous_outputs)\x20—\x20'+'send\x20it\x20back\x20VERBATIM\x20with\x20the\x20SAME\x20plan\x20to\x20RESUME\x20where\x20it\x20halted\x20(never\x20re-run\x20from\x20scratch:\x20the\x20'+'already-created\x20objects\x20would\x20duplicate),\x20or\x20use\x20resume_from_step\x20(first\x20non-executed\x20step\x20id)\x20+\x20'+'previous_outputs.\x20A\x20step\x20failing\x20with\x20the\x20IDENTICAL\x20error\x20in\x202+\x20consecutive\x20rounds\x20withholds\x20the\x20'+'RESUME\x20recipe\x20(repeated_failures)\x20and\x20a\x20third\x20unchanged\x20re-run\x20is\x20REFUSED\x20(retry_override\x20{step_id,\x20'+'note}\x20is\x20the\x20audited\x20escape\x20hatch).\x0a'+'\x20\x20•\x20template_scan\x20—\x20pre-deploy\x20risk\x20scan\x20of\x20one\x20template\x20(template_id\x20required):\x20synthetic\x20draft\x20'+'topology\x20through\x20the\x20same\x20rule\x20surface\x20as\x20on-chain\x20analyze\x20+\x20static\x20R1-R10\x20checks;\x20returns\x20'+'risk_level/findings/red_flags\x20plus\x20a\x20drift\x20face\x20(disk-vs-catalog\x20provenance\x20of\x20the\x20scanned\x20'+'body\x20—\x20blocked=true\x20means\x20the\x20audited\x20body\x20is\x20not\x20the\x20shipped\x20catalog\x20body)\x20and\x20a\x20compile\x20'+'dry-run\x20verdict\x20(compile_dry_run.status\x20ready/blocked/unavailable\x20—\x20synthetic-probe\x20'+'buildability\x20through\x20the\x20same\x20pipeline\x20template_generate\x20uses,\x20mirrored\x20to\x20the\x20'+'generate\x20gate:\x20CRITICAL\x20+\x20N-21\x20HIGH\x20findings\x20+\x20graph\x20+\x20audit\x20blockers;\x20blocked\x20lists\x20'+'the\x20named\x20rules\x20the\x20generate\x20face\x20would\x20refuse\x20on);\x20CRITICAL\x20blocks\x20generation/apply.\x0a'+'\x20\x20•\x20migration_import\x20—\x20competitor\x20URL/description\x20→\x20structured\x20MigrationLog:\x20mapped\x20/\x20'+'unmapped\x20/\x20manual_review\x20entries,\x20WoWok\x20advantages,\x20customizable\x20modules,\x20role\x20assessment\x20'+'and\x20a\x20dry-run\x20risk\x20check\x20(description\x20required;\x20url\x20recorded\x20as\x20provenance\x20only;\x20default\x20'+'network\x20testnet).\x0a'+'\x20\x20•\x20migration_review\x20—\x20surface\x20a\x20prior\x20MigrationLog\x20with\x20counts\x20+\x20risk\x20status\x20for\x20user\x20'+'confirmation\x20(log\x20required).\x0a'+'\x20\x20•\x20migration_apply\x20—\x20run\x20the\x20approved\x20template\x20through\x20the\x20merchant-guide\x20pipeline\x20'+'(template_id\x20required;\x20scan-first\x20—\x20CRITICAL\x20findings\x20block;\x20creation\x20plan\x20only\x20—\x20never\x20executes\x20'+'on-chain;\x20default\x20network\x20testnet,\x20mainnet\x20requires\x20explicit\x20user\x20confirmation).\x0a\x0a'+'Deterministic\x20planning;\x20only\x20plan_execute\x20writes\x20chain\x20state\x20(its\x20plan\x27s\x20steps)\x20—\x20every\x20other\x20action\x20is\x20a\x20read/plan\x20emission.\x0a\x0a'+'💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27benchmark_migration_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema.','inputSchema':BenchmarkMigrationSchema,'outputSchema':BenchmarkMigrationOutputSchema,'annotations':{'readOnlyHint':![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':![]},'_meta':createToolMeta('benchmark_migration',['template','migration','competitor','industry','leader','challenger','scan','risk'])},'timeoutMs':0xdbba0},{'name':'service_clone_operation','handler':handleServiceCloneOperation,'config':{'title':'🧬\x20Service\x20Clone\x20-\x20Rebuild\x20On-chain\x20Services','summary':'Read\x20an\x20existing\x20Service\x27s\x20full\x20configuration\x20and\x20rebuild\x20it\x20as\x20a\x20new\x20object\x20with\x20optional\x20overrides\x20(token,\x20network,\x20fees).','description':'Clone\x20an\x20existing\x20on-chain\x20Service\x20into\x20a\x20new\x20object.\x20'+'Two\x20actions:\x0a'+'\x20\x20•\x20clone_plan\x20—\x20read\x20the\x20source\x20Service\x20(service\x20fields,\x20machine\x20graph,\x20guards,\x20permission,\x20'+'allocators)\x20and\x20emit\x20a\x20reconstruction\x20plan.\x20Optional\x20overrides:\x20token_type\x20(change\x20payment\x20'+'token),\x20network\x20(target\x20network),\x20description,\x20location,\x20sales,\x20compensation_fund,\x20'+'order_allocators.\x20Never\x20executes\x20on-chain.\x0a'+'\x20\x20•\x20clone_apply\x20—\x20take\x20a\x20prior\x20clone_plan\x20(possibly\x20user-edited),\x20apply\x20overrides,\x20run\x20the\x20'+'pre-publish\x20gate\x20(machine\x20topology,\x20allocator\x20guard\x20lint,\x20immutability\x20warnings),\x20and\x20emit\x20'+'the\x20exact\x20onchain_operations\x20payloads\x20in\x20execution\x20order.\x20Never\x20executes\x20on-chain.\x0a\x0a'+'Workflow:\x20clone_plan\x20→\x20review/edit\x20the\x20plan\x20→\x20clone_apply\x20→\x20review\x20gate\x20findings\x20→\x20execute\x20'+'the\x20operations\x20via\x20onchain_operations.\x0a\x0a'+'Deterministic\x20knowledge\x20lookups\x20+\x20planning;\x20never\x20mutates\x20chain\x20state.\x0a\x0a'+'💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27service_clone_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema.','inputSchema':ServiceCloneSchema,'outputSchema':ServiceCloneOutputSchema,'annotations':{'readOnlyHint':!![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':![]},'_meta':createToolMeta('service_clone',['clone','service','rebuild','token','network','migrate'])}},{'name':'strategy_review_operation','handler':handleStrategyReviewOperation,'config':{'title':'📈\x20Strategy\x20Review\x20-\x20Posture-Weighted\x20Scorecard\x20&\x20Periodic\x20Review','summary':'Collect\x20on-chain/derived\x20evidence\x20for\x20an\x20(account,\x20industry),\x20snapshot\x20it\x20locally,\x20and\x20assemble\x20posture-weighted\x20strategy\x20reviews\x20with\x20current-layer\x20persona\x20proposals.','description':'Evidence-driven\x20operating\x20review\x20for\x20one\x20merchant\x20account\x20in\x20one\x20industry,\x20built\x20on\x20the\x20six-industry\x20'+'strategy\x20catalog\x20(education/rental/freelance/subscription/travel/retail\x20+\x20pack-registered\x20ids).\x0a\x0a'+'Actions:\x0a'+'\x20\x20•\x20collect\x20—\x20gather\x20fresh\x20evidence\x20(journey\x20funnel,\x20order\x20flow,\x20market\x20metrics,\x20service\x20discovery\x20/\x20'+'competitor\x20count,\x20arbitration\x20trust,\x20account\x20attention),\x20persist\x20ONE\x20append-only\x20snapshot\x20in\x20local\x20'+'SQLite\x20KV,\x20and\x20return\x20the\x20raw\x20collection.\x20Failed\x20evidence\x20sources\x20degrade\x20single\x20metrics\x20to\x20'+'unavailable/error\x20—\x20never\x20zero-filled;\x20storage\x20failure\x20is\x20fail-soft\x20and\x20never\x20loses\x20the\x20collection.\x0a'+'\x20\x20•\x20review\x20—\x20gather\x20fresh\x20evidence\x20WITHOUT\x20persisting,\x20diff\x20against\x20the\x20latest\x20stored\x20snapshot,\x20'+'score\x200–100\x20under\x20the\x20persona\x27s\x20merchant\x20posture\x20(volume/balanced/margin,\x20renormalized\x20over\x20'+'available\x20anchored\x20metrics),\x20and\x20return\x20findings,\x20deterministic\x20pricing/posture\x20recommendations,\x20'+'cadence\x20status\x20and\x20at\x20most\x20two\x20persona\x20proposals.\x20Proposals\x20target\x20the\x20CURRENT\x20layer\x20ONLY\x20and\x20are\x20'+'applied\x20only\x20when\x20the\x20user\x20explicitly\x20calls\x20persona_operation\x20apply\x20—\x20this\x20tool\x20never\x20writes\x20the\x20'+'persona\x20and\x20never\x20mutates\x20chain\x20state.\x0a'+'\x20\x20•\x20list_snapshots\x20—\x20list\x20stored\x20snapshot\x20summaries\x20(oldest-first)\x20for\x20account+industry.\x0a\x0a'+'Posture\x20defaults:\x20explicit\x20`posture`\x20arg\x20→\x20merchant\x20posture\x20in\x20the\x20effective\x20persona\x20→\x20\x27balanced\x27.\x0a\x0a'+'💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27strategy_review_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema.','inputSchema':StrategyReviewOperationInputSchema,'outputSchema':StrategyReviewOperationOutputSchema,'annotations':{'readOnlyHint':![],'destructiveHint':![],'idempotentHint':![],'openWorldHint':!![]},'_meta':createToolMeta('strategy',['strategy','scorecard','review','posture','metrics','industry','competitor','retention','dispute'])},'timeoutMs':0x1d4c0},{'name':'workspace_operation','handler':handleWorkspaceOperation,'config':{'title':'📁\x20Workspace\x20-\x20File\x20Generation\x20&\x20User\x20Data','summary':'Local\x20workspace\x20files:\x20list,\x20read,\x20search,\x20glob,\x20edit,\x20write,\x20move,\x20copy,\x20delete.','description':'Manage\x20the\x20local\x20workspace\x20directory\x20(`.wowok/workspace`):\x20files\x20generated\x20for\x20review\x20'+'(machine/guard/wts/wip\x20JSON)\x20and\x20user-created\x20documents.\x0a\x0a'+'Actions:\x0a'+'\x20\x20•\x20resolve\x20—\x20return\x20the\x20workspace\x20root\x20directory.\x0a'+'\x20\x20•\x20list\x20—\x20list\x20files\x20under\x20the\x20workspace.\x0a'+'\x20\x20•\x20read\x20—\x20read\x20a\x20file\x27s\x20content\x20(use\x20as\x20AI\x20context);\x20optional\x20offset/limit\x20line\x20slicing\x20'+'(1-based\x20offset,\x20max\x202000\x20lines)\x20and\x20encoding=\x27base64\x27\x20for\x20raw\x20bytes\x20(≤10MB).\x0a'+'\x20\x20•\x20search\x20—\x20regex\x20content\x20search\x20across\x20workspace\x20files\x20(pattern\x20required;\x20optional\x20path\x20scope,\x20'+'glob\x20basename\x20filter,\x20ignore_case,\x20max_results\x20≤200,\x20context_lines\x20≤5).\x20Skips\x20binary/large\x20files.\x0a'+'\x20\x20•\x20glob\x20—\x20list\x20files\x20whose\x20workspace-relative\x20path\x20matches\x20a\x20wildcard\x20pattern\x20(\x27**\x27\x20spans\x20'+'directories,\x20\x27*\x27\x20stays\x20within\x20one\x20segment,\x20\x27?\x27\x20=\x20one\x20char,\x20\x27{a,b}\x27\x20alternation).\x0a'+'\x20\x20•\x20edit\x20—\x20exact\x20string\x20replacement\x20inside\x20a\x20file\x20(path\x20+\x20old_string\x20+\x20new_string\x20required;\x20'+'errors\x20when\x20old_string\x20is\x20not\x20unique\x20unless\x20replace_all=true;\x20files\x20≤2MB).\x0a'+'\x20\x20•\x20write\x20—\x20write/overwrite\x20a\x20file\x20(path\x20+\x20content).\x0a'+'\x20\x20•\x20delete\x20—\x20delete\x20a\x20file.\x0a'+'\x20\x20•\x20create_file\x20—\x20create\x20an\x20empty\x20file\x20(path\x20required;\x20content\x20optional).\x0a'+'\x20\x20•\x20create_dir\x20—\x20create\x20a\x20directory\x20recursively\x20(path\x20required).\x0a'+'\x20\x20•\x20copy\x20—\x20copy\x20a\x20file\x20or\x20directory\x20(from\x20+\x20to\x20required).\x0a'+'\x20\x20•\x20move\x20—\x20move\x20a\x20file\x20or\x20directory\x20(from\x20+\x20to\x20required).\x0a'+'\x20\x20•\x20rename\x20—\x20rename\x20a\x20file\x20or\x20directory\x20(from\x20+\x20to\x20required).\x0a\x0a'+'Local\x20filesystem\x20only;\x20never\x20mutates\x20chain\x20state.\x0a\x0a'+'💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27workspace_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema.','inputSchema':WorkspaceOperationInputSchema,'outputSchema':WorkspaceOperationOutputSchema,'annotations':{'readOnlyHint':![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':![]},'_meta':createToolMeta('workspace',['workspace','file','document','machine','guard','wts','wip','context'])}},{'name':'workflow_operation','handler':handleWorkflowOperation,'config':{'title':'🔀\x20Workflow\x20-\x20Local-Account\x20Progress\x20Tasks','summary':'List\x20local-account\x20progress\x20(actionable\x20+\x20related/history)\x20+\x20advance/hold/unhold\x20forwards\x20+\x20view\x20progress\x20history.','description':'Local-account\x20workflow\x20view\x20over\x20on-chain\x20Progress\x20objects.\x0a\x0a'+'Actions:\x0a'+'\x20\x20•\x20list\x20—\x20enumerate\x20progress\x20related\x20to\x20local\x20accounts:\x20actionable\x20first\x20(a\x20'+'local\x20account\x20can\x20advance\x20a\x20forward),\x20plus\x20related\x20/\x20completed\x20progress\x20(order\x20'+'holder,\x20named\x20operator,\x20or\x20session\x20operator\x20involvement)\x20so\x20the\x20user\x20always\x20'+'keeps\x20visibility\x20of\x20their\x20own\x20progress\x20history.\x20Each\x20task\x20carries\x20every\x20'+'reachable\x20next\x20node\x20+\x20forward,\x20the\x20local\x20accounts\x20that\x20can\x20execute\x20each\x20'+'forward\x20(order\x20holder\x20/\x20named\x20operator\x20/\x20permission\x20index,\x20including\x20admin),\x20'+'guard\x20reminders\x20(a\x20forward\x20with\x20a\x20guard\x20must\x20be\x20verified\x20via\x20passport),\x20and\x20'+'the\x20on-chain\x20history_count.\x0a'+'\x20\x20•\x20operate\x20—\x20advance\x20(\x27next\x27)\x20/\x20block\x20(\x27hold\x27)\x20/\x20release\x20(\x27unhold\x27)\x20/\x20force-release\x20'+'(\x27adminUnhold\x27)\x20a\x20forward\x20as\x20a\x20chosen\x20local\x20account\x20(env.account).\x20Delegates\x20to\x20the\x20'+'on-chain\x20progress\x20operation\x20(guard-aware).\x0a'+'\x20\x20•\x20history\x20—\x20incrementally\x20sync\x20a\x20progress\x27s\x20ON-CHAIN\x20history\x20(Progress.history\x20'+'append-only\x20u64\x20index)\x20into\x20the\x20local\x20SQLite\x20mirror\x20via\x20a\x20per-progress\x20cursor\x20'+'(only\x20NEW\x20records\x20are\x20pulled),\x20then\x20return\x20the\x20migration\x20timeline\x20(newest\x20first)\x20'+'with\x20each\x20migration\x27s\x20session\x20snapshot\x20(forwards\x20/\x20operator\x20address\x20/\x20weight\x20/\x20time).\x20'+'Also\x20runs\x20a\x2090-day\x20retention\x20cleanup\x20of\x20stale\x20progress\x20histories\x20by\x20default.\x0a\x0a'+'Permission\x20model\x20(chain-authoritative):\x20a\x20forward\x20is\x20executable\x20by\x20an\x20account\x20when\x20'+'(a)\x20namedOperator=\x22\x22\x20and\x20the\x20account\x20is\x20the\x20order\x20holder\x20(order\x20builder\x20or\x20agent),\x20'+'or\x20(b)\x20namedOperator=name\x20and\x20the\x20account\x20is\x20in\x20progress.namedOperator[name],\x20or\x20'+'(c)\x20permissionIndex\x20is\x20set\x20and\x20the\x20account\x20is\x20in\x20permission.admin\x20or\x20permission.table.\x0a\x0a'+'💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27workflow_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema.','inputSchema':WorkflowOperationInputSchema,'outputSchema':WorkflowOperationOutputSchema,'annotations':{'readOnlyHint':![],'destructiveHint':!![],'idempotentHint':![],'openWorldHint':!![]},'_meta':createToolMeta('workflow',['workflow','progress','forward','permission','named-operator','guard','advance','hold'])},'timeoutMs':0x1d4c0},{'name':'permission_operation','handler':handlePermissionOperation,'config':{'title':'🛡️\x20Permissions\x20-\x20Local-Account\x20Overview','summary':'List\x20Permissions\x20related\x20to\x20local\x20accounts\x20with\x20related\x20accounts/objects.','description':'Local-account\x20Permission\x20overview.\x0a\x0a'+'Actions:\x0a'+'\x20\x20•\x20list\x20—\x20enumerate\x20every\x20on-chain\x20Permission\x20object\x20related\x20to\x20at\x20least\x20one\x20LOCAL\x20'+'account\x20(reverse-looked-up\x20via\x20the\x20global\x20entity_permission\x20index\x20@0xaad),\x20deduplicated\x20'+'and\x20merged.\x20Each\x20row\x20includes\x20description,\x20owner,\x20latest\x20on-chain\x20update\x20time,\x20related\x20'+'accounts\x20(owner/admin/entity),\x20and\x20related\x20objects\x20(grouped\x20by\x20type\x20via\x20the\x20registrar\x20'+'linker).\x20Pass\x20`permission`\x20to\x20scope\x20the\x20listing\x20to\x20ONE\x20Permission\x20address\x20—\x20fast\x20path\x20'+'(metadata\x20+\x20local-account\x20roles\x20only;\x20skips\x20the\x20per-permission\x20linker/tx-time\x20fan-out)\x20'+'for\x20detail-page\x20Permission\x20rows.\x0a\x0a'+'Read-only\x20(no\x20on-chain\x20mutation).\x0a\x0a'+'💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27permission_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema.','inputSchema':PermissionOperationInputSchema,'outputSchema':PermissionOperationOutputSchema,'annotations':{'readOnlyHint':!![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':![]},'_meta':createToolMeta('query',['permission','account','role','owner','admin','entity','overview','registrar','reverse-index'])}}];
|
|
1
|
+
import{handleIndustryPackOperation}from'../handlers/industry-pack.js';import{handleBenchmarkMigrationOperation}from'../handlers/benchmark-migration.js';import{handleStrategyReviewOperation}from'../handlers/strategy-review.js';import{handleWorkspaceOperation}from'../handlers/workspace.js';import{handleWorkflowOperation}from'../handlers/workflow.js';import{handlePermissionOperation}from'../handlers/permission.js';import{handleServiceCloneOperation}from'../handlers/service-clone.js';import{createToolMeta,IndustryPackOperationInputSchema,IndustryPackOperationOutputSchema,BenchmarkMigrationSchema,BenchmarkMigrationOutputSchema,StrategyReviewOperationInputSchema,StrategyReviewOperationOutputSchema,WorkspaceOperationInputSchema,WorkspaceOperationOutputSchema,WorkflowOperationInputSchema,WorkflowOperationOutputSchema,PermissionOperationInputSchema,PermissionOperationOutputSchema,ServiceCloneSchema,ServiceCloneOutputSchema}from'../../schema/index.js';import{CATALOG_INDUSTRY_COUNT as a585a,CATALOG_TEMPLATE_COUNT as a585b}from'../../knowledge/catalog-facts.js';export const BUSINESS_TOOLS=[{'name':'industry_pack_operation','handler':handleIndustryPackOperation,'config':{'title':'🧩\x20Industry\x20Pack\x20-\x20Knowledge\x20Template\x20Orchestration','summary':'Industry\x20knowledge\x20packs:\x20scaffold,\x20register,\x20list,\x20reset\x20templates.','description':'Manage\x20industry\x20knowledge\x20packs\x20(distributable,\x20registrable,\x20versionable\x20units\x20carrying\x20'+'one\x20industry\x27s\x20object-shape,\x20matching\x20rules,\x20and\x20role\x20personae).\x0a\x0a'+'Pack\x20layout\x20(merged\x20v2):\x20pack.json\x20(settings\x20only\x20—\x20manifest\x20+\x20match\x20+\x20personae\x20+\x20'+'dispute/compliance/supply/rules\x20sections;\x20field\x20explanations\x20live\x20in\x20the\x20industry-root\x20'+'README.md)\x20and\x20playbook.md\x20(chaptered\x20AI\x20prompt\x20guide).\x20Legacy\x20split-file\x20layouts\x20'+'(manifest.json/match.json/personae)\x20are\x20still\x20read\x20for\x20backward\x20compatibility.\x0a\x0a'+'Actions:\x0a'+'\x20\x20•\x20scaffold\x20—\x20generate\x20a\x20pack\x20template\x20skeleton\x20(pack.json\x20+\x20playbook.md,\x20settings\x20only)\x20'+'into\x20the\x20industry\x20directory;\x20the\x20user\x20fills\x20in\x20the\x20content.\x0a'+'\x20\x20•\x20list\x20—\x20list\x20currently\x20registered\x20packs.\x0a'+'\x20\x20•\x20scan\x20—\x20scan\x20+\x20register\x20every\x20pack\x20under\x20the\x20default\x20industry\x20directory.\x0a'+'\x20\x20?\x20template_drift\x20-\x20REPORT\x20builtin\x20template\x20files\x20whose\x20on-disk\x20body\x20differs\x20from\x20the\x20'+'in-code\x20catalog\x20(no_sentinel_legacy\x20/\x20stale_release\x20/\x20user_modified).\x20Run\x20this\x20FIRST\x20when\x20a\x20'+'template\x20change\x20appears\x20to\x20have\x20no\x20effect:\x20a\x20builtin\x20file\x20seeded\x20before\x20the\x20release\x20'+'sentinel\x20existed\x20carries\x20no\x20sentinel\x20and\x20is\x20never\x20upgraded\x20automatically.'+'\x20\x20?\x20repair_builtin_templates\x20-\x20RESEED\x20those\x20legacy\x20files\x20from\x20the\x20in-code\x20catalog.\x20'+'Identity-gated\x20on\x20a\x20known\x20builtin\x20id;\x20the\x20previous\x20body\x20is\x20kept\x20in\x20the\x20hidden\x20templates/.archive/\x20dir\x20and\x20a\x20'+'custom\x20(user)\x20template\x20is\x20never\x20touched.'+'\x20\x20•\x20resolve\x20—\x20return\x20the\x20industry\x20root\x20directory.\x0a'+'\x20\x20•\x20list_files\x20—\x20list\x20files\x20under\x20the\x20industry\x20directory.\x0a'+'\x20\x20•\x20read_file\x20—\x20read\x20a\x20file\x20under\x20the\x20industry\x20directory\x20(path\x20required).\x0a'+'\x20\x20•\x20write_file\x20—\x20write\x20content\x20to\x20a\x20file\x20under\x20the\x20industry\x20directory\x20(path\x20+\x20content\x20required).\x0a'+'\x20\x20•\x20get\x20—\x20return\x20registered\x20layer\x20data\x20for\x20an\x20industry\x20(name\x20required;\x20dispute/compliance/supply/rules/playbook).\x0a'+'\x20\x20\x20\x20layer=\x27template\x27\x20returns\x20one\x20builtin\x20template\x20(merge-safe\x20projection);\x20layer=\x27params\x27\x20is\x20the\x0a'+'\x20\x20\x20\x20merchant-facing\x20SETTINGS\x20surface:\x20with\x20template=\x27<id>\x27\x20every\x20declared\x20parameter\x20in\x20business\x20order\x0a'+'\x20\x20\x20\x20(tier,\x20tags,\x20kind/unit,\x20meaning,\x20default,\x20accepted\x20values,\x20PROVEN\x20live/inert\x20status,\x20landing,\x20editable);\x0a'+'\x20\x20\x20\x20with\x20\x27query\x27\x20instead\x20of\x20a\x20template\x20id\x20it\x20searches\x20the\x20catalog\x20for\x20a\x20business\x20facet\x20(\x27settlement\x20window\x27,\x0a'+'\x20\x20\x20\x20\x27take\x20rate\x27)\x20and\x20returns\x20ranked\x20hits\x20with\x20explainable\x20reasons\x20—\x20an\x20empty\x20list\x20means\x20no\x20such\x20setting.\x0a'+'\x20\x20\x20\x20layer=\x27components\x27\x20is\x20the\x20COMPONENT\x20surface\x20beside\x20it:\x20one\x20slot\x20per\x20Service/Sale\x20field,\x20allocator\x0a'+'\x20\x20\x20\x20row,\x20per-order\x20Allocation,\x20Machine,\x20Guard,\x20Repository\x20policy,\x20reward,\x20arbitration\x20binding,\x20permission\x0a'+'\x20\x20\x20\x20and\x20treasury\x20item\x20—\x20each\x20with\x20what\x20it\x20is,\x20how\x20it\x20is\x20configured\x20(lifecycle\x20surface\x20create/pre-publish/\x0a'+'\x20\x20\x20\x20append-only/post-publish/immutable\x20+\x20the\x20exact\x20field\x20path),\x20the\x20effect\x20once\x20it\x20applies,\x20and\x20what\x20it\x20is\x0a'+'\x20\x20\x20\x20bound\x20to;\x20a\x20non-configurable\x20slot\x20always\x20carries\x20why_not\x20(e.g.\x20a\x20split\x20hard-coded\x20in\x20the\x20template\x20body).\x0a'+'\x20\x20•\x20capability_list\x20—\x20list\x20the\x20Capability\x20Lattice\x20registry\x20(composable\x20business\x20units;\x20optional\x20group\x20filter).\x0a'+'\x20\x20•\x20capability_get\x20—\x20full\x20card\x20of\x20ONE\x20capability\x20(intent/binds/requires/excludes/risks/disclosures/cost/constraints).\x0a'+'\x20\x20•\x20compose_probe\x20—\x20probe\x20whether\x20a\x20capability\x20selection\x20can\x20coexist\x20in\x20one\x20build\x20(capabilities[]\x20required;\x20optional\x20template\x20as\x20base\x20build).\x0a'+'\x20\x20•\x20product_cards\x20—\x20FRONT-stage\x20ProductCard\x20summaries\x20for\x20the\x20catalog\x20or\x20one\x20industry\x20(optional\x20name\x20filter).\x0a'+'\x20\x20•\x20product_card\x20—\x20the\x20full\x20ProductCard\x20of\x20ONE\x20builtin\x20template\x20(template\x20id\x20required):\x20alignment/features/cost/params/risks,\x20every\x20assertion\x20projected\x20from\x20declared\x20data.\x0a'+'\x20\x20•\x20diff\x20—\x20compare\x20registered\x20vs\x20on-disk\x20manifest\x20version/layers\x20(name\x20required).\x0a'+'\x20\x20•\x20reset\x20—\x20restore\x20a\x20file\x20or\x20entire\x20pack\x20folder\x20to\x20its\x20pristine\x20annotated\x20template\x20(path\x20required).\x0a'+'\x20\x20•\x20delete_file\x20—\x20delete\x20a\x20file\x20or\x20directory\x20(path\x20required).\x0a'+'\x20\x20•\x20create_file\x20—\x20create\x20an\x20empty\x20file\x20(path\x20required;\x20content\x20optional).\x0a'+'\x20\x20•\x20create_dir\x20—\x20create\x20a\x20directory\x20recursively\x20(path\x20required).\x0a'+'\x20\x20•\x20copy\x20—\x20copy\x20a\x20file\x20or\x20directory\x20(from\x20+\x20to\x20required).\x0a'+'\x20\x20•\x20move\x20/\x20rename\x20—\x20move\x20or\x20rename\x20a\x20file\x20or\x20directory\x20(from\x20+\x20to\x20required).\x0a'+'\x20\x20•\x20recommend_industry\x20—\x20business\x20intent\x20text\x20→\x20top-3\x20similar\x20industry\x20modes\x20(trait\x20similarity;\x20optional\x20strategy\x20statements\x20re-rank\x20by\x20lever\x20alignment).\x0a'+'\x20\x20•\x20list_modes\x20—\x20list\x20builtin\x20+\x20caller\x27s\x20custom\x20industry\x20modes.\x0a'+'\x20\x20•\x20derive_user_mode\x20—\x20derive\x20(and\x20register)\x20a\x20custom\x20mode\x20from\x20a\x20builtin\x20mode.\x0a'+'\x20\x20•\x20evolve_user_mode\x20—\x20iterate\x20an\x20existing\x20custom\x20mode\x20(version-bumped\x20evolution\x20history).\x0a'+'\x20\x20•\x20register_user_mode\x20—\x20register\x20a\x20fully\x20custom\x20mode\x20(machine_shape\x20+\x20key_risk\x20required).\x0a'+'\x20\x20•\x20unregister_user_mode\x20—\x20delete\x20a\x20custom\x20mode\x20(owner\x20only).\x0a'+'\x20\x20•\x20register_custom_metric\x20—\x20register\x20a\x20global\x20custom\x20evaluation\x20metric\x20(risk/benefit;\x20persisted).\x0a'+'\x20\x20•\x20unregister_custom_metric\x20—\x20delete\x20a\x20custom\x20metric\x20(custom\x20only;\x20builtin\x20metrics\x20cannot\x20be\x20deleted).\x0a'+'\x20\x20•\x20register_custom_constraint\x20—\x20register\x20a\x20custom\x20mode\x20constraint\x20(4\x20rule\x20types;\x20hard/soft;\x20persisted).\x0a'+'\x20\x20•\x20unregister_custom_constraint\x20—\x20delete\x20a\x20custom\x20constraint\x20(custom\x20only;\x20builtin\x20constraints\x20cannot\x20be\x20deleted).\x0a'+'\x20\x20•\x20list_metrics_constraints\x20—\x20list\x20metrics\x20+\x20constraints\x20(filterable\x20by\x20type/scope).\x0a\x0a'+'Local\x20filesystem\x20+\x20in-memory\x20registry\x20only;\x20never\x20mutates\x20chain\x20state.\x0a\x0a'+'💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27industry_pack_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema.','inputSchema':IndustryPackOperationInputSchema,'outputSchema':IndustryPackOperationOutputSchema,'annotations':{'readOnlyHint':![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':![]},'_meta':createToolMeta('industry_pack',['industry','pack','mode','match','persona','scaffold','template'])}},{'name':'benchmark_migration_operation','handler':handleBenchmarkMigrationOperation,'config':{'title':'🏆\x20Template\x20Migration\x20-\x20Industry\x20Templates\x20&\x20Competitor\x20Migration','summary':'MD\x20industry-archetype\x20templates\x20(hot-loaded,\x20'+a585b+'\x20built-ins)\x20+\x20pre-deploy\x20risk\x20scan\x20+\x20one-click\x20competitor\x20migration.','description':'Industry-archetype\x20MD\x20templates\x20and\x20one-click\x20competitor\x20migration\x20(V2\x20MD-template\x20architecture).\x20'+'Templates\x20live\x20in\x20`.wowok/industry/<industry>/templates/<variant>.md`\x20(the\x20client\x27s\x20industry\x20drawer\x20tree\x20—\x20hot-loaded,\x20zod-validated\x20frontmatter;\x20'+(a585b+'\x20built-in\x20archetypes\x20across\x20'+a585a+'\x20industries\x20are\x20seeded\x20idempotently\x20and\x20never\x20')+'overwritten).\x20Each\x20template\x20is\x20a\x20ScenarioMode-compatible\x20build\x20shape\x20(machine_shape\x20/\x20guards\x20/\x20'+'allocator)\x20plus\x20fee\x20parameters\x20and\x20R1-R10\x20trust\x20mechanisms.\x0a\x0a'+'Product\x20tagging:\x20every\x20built-in\x20carries\x20a\x20`product_ref`\x20benchmark\x20slug\x20(e.g.\x20retail/scale-marketplace\x20→\x20'+'\x27amazon\x27,\x20travel/global-ota\x20→\x20\x27booking-com\x27).\x20This\x20is\x20the\x20ONLY\x20sanctioned\x20company\x20name\x20—\x20it\x20lets\x20a\x20user\x20'+'pick\x20a\x20template\x20by\x20naming\x20the\x20incumbent\x20product\x20they\x20want\x20to\x20migrate\x20from.\x20When\x20the\x20user\x20names\x20a\x20product,\x20'+'call\x20template_list\x20and\x20match\x20on\x20product_ref,\x20then\x20template_generate/migration_apply\x20with\x20that\x20template_id.\x0a\x0a'+'Three\x20build\x20modes\x20(choose\x20from\x20the\x20user\x27s\x20intent):\x0a'+'\x20\x20•\x20template-driven\x20—\x20pick\x20the\x20closest\x20product_ref/industry\x20template,\x20adopt\x20it\x20as-is\x20(template_generate).\x0a'+'\x20\x20•\x20template\x20+\x20partial\x20customization\x20—\x20start\x20from\x20a\x20template,\x20then\x20override\x20fee_params\x20(fee_overrides)\x20or\x20'+'edit\x20the\x20MD\x20file\x20via\x20industry_pack_operation\x20write_file\x20before\x20generating.\x0a'+'\x20\x20•\x20fully\x20custom\x20—\x20skip\x20templates;\x20drive\x20the\x20merchant-guide\x20pipeline\x20from\x20a\x20free-text\x20description.\x0a\x0a'+'Actions:\x0a'+'\x20\x20•\x20template_list\x20—\x20list\x20the\x20loaded\x20MD\x20templates\x20(optional\x20industry\x20filter;\x20rows\x20carry\x20product_ref);\x20load\x20errors\x20are\x20'+'reported,\x20never\x20silently\x20dropped.\x0a'+'\x20\x20•\x20template_get\x20—\x20fetch\x20one\x20template\x20by\x20template_id\x20(full\x20machine_shape/guards/allocator/'+'fee_params/trust_mechanisms/body).\x0a'+'\x20\x20•\x20template_generate\x20—\x20generate\x20a\x20creation\x20plan\x20from\x20a\x20template\x20via\x20the\x20merchant-guide\x20pipeline\x20'+'(template_id\x20required;\x20scan-first\x20—\x20CRITICAL\x20findings\x20block;\x20description\x20optional\x20as\x20the\x20intent\x20'+'text;\x20fee_overrides\x20optional;\x20never\x20executes\x20on-chain).\x0a'+'\x20\x20•\x20plan_execute\x20—\x20execute\x20the\x20plan\x20returned\x20by\x20template_generate\x20in\x20ONE\x20call\x20(plan\x20required):\x20'+'materializes\x20every\x20step\x20in\x20order\x20through\x20the\x20built-in\x20executor\x20(chain\x20writes).\x20Every\x20step\x20is\x20'+'checkpointed\x20to\x20a\x20durable\x20run\x20store\x20(D-④):\x20a\x20re-issued\x20IDENTICAL\x20plan\x20AUTO-RESUMES\x20from\x20the\x20'+'checkpoint\x20(executed\x20steps\x20adopted,\x20never\x20re-executed\x20—\x20no\x20manual\x20payload\x20needed),\x20and\x20on\x20a\x20'+'mid-plan\x20failure\x20the\x20response\x20still\x20carries\x20a\x20ready-to-pass\x20`resume`\x20payload\x20(completed_steps\x20+\x20'+'previous_outputs)\x20—\x20send\x20it\x20back\x20VERBATIM\x20with\x20the\x20SAME\x20plan,\x20or\x20use\x20resume_from_step\x20(first\x20'+'non-executed\x20step\x20id)\x20+\x20previous_outputs.\x20A\x20step\x20failing\x20with\x20the\x20IDENTICAL\x20error\x20in\x202+\x20'+'consecutive\x20rounds\x20withholds\x20the\x20RESUME\x20recipe\x20(repeated_failures)\x20and\x20a\x20third\x20unchanged\x20re-run\x20'+'is\x20REFUSED\x20(retry_override\x20{step_id,\x20note}\x20is\x20the\x20audited\x20escape\x20hatch).\x0a'+'\x20\x20•\x20plan_status\x20—\x20query\x20a\x20durable\x20run\x20WITHOUT\x20re-running\x20(D-④):\x20run_id\x20(from\x20the\x20plan_execute\x20'+'response\x27s\x20durable_run.run_id),\x20or\x20plan\x20(finds\x20that\x20plan\x27s\x20latest\x20unfinished\x20run\x20by\x20digest),\x20or\x20'+'no\x20argument\x20(lists\x20the\x20most\x20recent\x20runs).\x20Read-only.\x0a'+'\x20\x20•\x20template_scan\x20—\x20pre-deploy\x20risk\x20scan\x20of\x20one\x20template\x20(template_id\x20required):\x20synthetic\x20draft\x20'+'topology\x20through\x20the\x20same\x20rule\x20surface\x20as\x20on-chain\x20analyze\x20+\x20static\x20R1-R10\x20checks;\x20returns\x20'+'risk_level/findings/red_flags\x20plus\x20a\x20drift\x20face\x20(disk-vs-catalog\x20provenance\x20of\x20the\x20scanned\x20'+'body\x20—\x20blocked=true\x20means\x20the\x20audited\x20body\x20is\x20not\x20the\x20shipped\x20catalog\x20body)\x20and\x20a\x20compile\x20'+'dry-run\x20verdict\x20(compile_dry_run.status\x20ready/blocked/unavailable\x20—\x20synthetic-probe\x20'+'buildability\x20through\x20the\x20same\x20pipeline\x20template_generate\x20uses,\x20mirrored\x20to\x20the\x20'+'generate\x20gate:\x20CRITICAL\x20+\x20N-21\x20HIGH\x20findings\x20+\x20graph\x20+\x20audit\x20blockers;\x20blocked\x20lists\x20'+'the\x20named\x20rules\x20the\x20generate\x20face\x20would\x20refuse\x20on);\x20CRITICAL\x20blocks\x20generation/apply.\x0a'+'\x20\x20•\x20migration_import\x20—\x20competitor\x20URL/description\x20→\x20structured\x20MigrationLog:\x20mapped\x20/\x20'+'unmapped\x20/\x20manual_review\x20entries,\x20WoWok\x20advantages,\x20customizable\x20modules,\x20role\x20assessment\x20'+'and\x20a\x20dry-run\x20risk\x20check\x20(description\x20required;\x20url\x20recorded\x20as\x20provenance\x20only;\x20default\x20'+'network\x20testnet).\x0a'+'\x20\x20•\x20migration_review\x20—\x20surface\x20a\x20prior\x20MigrationLog\x20with\x20counts\x20+\x20risk\x20status\x20for\x20user\x20'+'confirmation\x20(log\x20required).\x0a'+'\x20\x20•\x20migration_apply\x20—\x20run\x20the\x20approved\x20template\x20through\x20the\x20merchant-guide\x20pipeline\x20'+'(template_id\x20required;\x20scan-first\x20—\x20CRITICAL\x20findings\x20block;\x20creation\x20plan\x20only\x20—\x20never\x20executes\x20'+'on-chain;\x20default\x20network\x20testnet,\x20mainnet\x20requires\x20explicit\x20user\x20confirmation).\x0a\x0a'+'Deterministic\x20planning;\x20only\x20plan_execute\x20writes\x20chain\x20state\x20(its\x20plan\x27s\x20steps)\x20—\x20every\x20other\x20action\x20is\x20a\x20read/plan\x20emission.\x0a\x0a'+'💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27benchmark_migration_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema.','inputSchema':BenchmarkMigrationSchema,'outputSchema':BenchmarkMigrationOutputSchema,'annotations':{'readOnlyHint':![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':![]},'_meta':createToolMeta('benchmark_migration',['template','migration','competitor','industry','leader','challenger','scan','risk'])},'timeoutMs':0xdbba0},{'name':'service_clone_operation','handler':handleServiceCloneOperation,'config':{'title':'🧬\x20Service\x20Clone\x20-\x20Rebuild\x20On-chain\x20Services','summary':'Read\x20an\x20existing\x20Service\x27s\x20full\x20configuration\x20and\x20rebuild\x20it\x20as\x20a\x20new\x20object\x20with\x20optional\x20overrides\x20(token,\x20network,\x20fees).','description':'Clone\x20an\x20existing\x20on-chain\x20Service\x20into\x20a\x20new\x20object.\x20'+'Two\x20actions:\x0a'+'\x20\x20•\x20clone_plan\x20—\x20read\x20the\x20source\x20Service\x20(service\x20fields,\x20machine\x20graph,\x20guards,\x20permission,\x20'+'allocators)\x20and\x20emit\x20a\x20reconstruction\x20plan.\x20Optional\x20overrides:\x20token_type\x20(change\x20payment\x20'+'token),\x20network\x20(target\x20network),\x20description,\x20location,\x20sales,\x20compensation_fund,\x20'+'order_allocators.\x20Never\x20executes\x20on-chain.\x0a'+'\x20\x20•\x20clone_apply\x20—\x20take\x20a\x20prior\x20clone_plan\x20(possibly\x20user-edited),\x20apply\x20overrides,\x20run\x20the\x20'+'pre-publish\x20gate\x20(machine\x20topology,\x20allocator\x20guard\x20lint,\x20immutability\x20warnings),\x20and\x20emit\x20'+'the\x20exact\x20onchain_operations\x20payloads\x20in\x20execution\x20order.\x20Never\x20executes\x20on-chain.\x0a\x0a'+'Workflow:\x20clone_plan\x20→\x20review/edit\x20the\x20plan\x20→\x20clone_apply\x20→\x20review\x20gate\x20findings\x20→\x20execute\x20'+'the\x20operations\x20via\x20onchain_operations.\x0a\x0a'+'Deterministic\x20knowledge\x20lookups\x20+\x20planning;\x20never\x20mutates\x20chain\x20state.\x0a\x0a'+'💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27service_clone_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema.','inputSchema':ServiceCloneSchema,'outputSchema':ServiceCloneOutputSchema,'annotations':{'readOnlyHint':!![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':![]},'_meta':createToolMeta('service_clone',['clone','service','rebuild','token','network','migrate'])}},{'name':'strategy_review_operation','handler':handleStrategyReviewOperation,'config':{'title':'📈\x20Strategy\x20Review\x20-\x20Posture-Weighted\x20Scorecard\x20&\x20Periodic\x20Review','summary':'Collect\x20on-chain/derived\x20evidence\x20for\x20an\x20(account,\x20industry),\x20snapshot\x20it\x20locally,\x20and\x20assemble\x20posture-weighted\x20strategy\x20reviews\x20with\x20current-layer\x20persona\x20proposals.','description':'Evidence-driven\x20operating\x20review\x20for\x20one\x20merchant\x20account\x20in\x20one\x20industry,\x20built\x20on\x20the\x20six-industry\x20'+'strategy\x20catalog\x20(education/rental/freelance/subscription/travel/retail\x20+\x20pack-registered\x20ids).\x0a\x0a'+'Actions:\x0a'+'\x20\x20•\x20collect\x20—\x20gather\x20fresh\x20evidence\x20(journey\x20funnel,\x20order\x20flow,\x20market\x20metrics,\x20service\x20discovery\x20/\x20'+'competitor\x20count,\x20arbitration\x20trust,\x20account\x20attention),\x20persist\x20ONE\x20append-only\x20snapshot\x20in\x20local\x20'+'SQLite\x20KV,\x20and\x20return\x20the\x20raw\x20collection.\x20Failed\x20evidence\x20sources\x20degrade\x20single\x20metrics\x20to\x20'+'unavailable/error\x20—\x20never\x20zero-filled;\x20storage\x20failure\x20is\x20fail-soft\x20and\x20never\x20loses\x20the\x20collection.\x0a'+'\x20\x20•\x20review\x20—\x20gather\x20fresh\x20evidence\x20WITHOUT\x20persisting,\x20diff\x20against\x20the\x20latest\x20stored\x20snapshot,\x20'+'score\x200–100\x20under\x20the\x20persona\x27s\x20merchant\x20posture\x20(volume/balanced/margin,\x20renormalized\x20over\x20'+'available\x20anchored\x20metrics),\x20and\x20return\x20findings,\x20deterministic\x20pricing/posture\x20recommendations,\x20'+'cadence\x20status\x20and\x20at\x20most\x20two\x20persona\x20proposals.\x20Proposals\x20target\x20the\x20CURRENT\x20layer\x20ONLY\x20and\x20are\x20'+'applied\x20only\x20when\x20the\x20user\x20explicitly\x20calls\x20persona_operation\x20apply\x20—\x20this\x20tool\x20never\x20writes\x20the\x20'+'persona\x20and\x20never\x20mutates\x20chain\x20state.\x0a'+'\x20\x20•\x20list_snapshots\x20—\x20list\x20stored\x20snapshot\x20summaries\x20(oldest-first)\x20for\x20account+industry.\x0a\x0a'+'Posture\x20defaults:\x20explicit\x20`posture`\x20arg\x20→\x20merchant\x20posture\x20in\x20the\x20effective\x20persona\x20→\x20\x27balanced\x27.\x0a\x0a'+'💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27strategy_review_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema.','inputSchema':StrategyReviewOperationInputSchema,'outputSchema':StrategyReviewOperationOutputSchema,'annotations':{'readOnlyHint':![],'destructiveHint':![],'idempotentHint':![],'openWorldHint':!![]},'_meta':createToolMeta('strategy',['strategy','scorecard','review','posture','metrics','industry','competitor','retention','dispute'])},'timeoutMs':0x1d4c0},{'name':'workspace_operation','handler':handleWorkspaceOperation,'config':{'title':'📁\x20Workspace\x20-\x20File\x20Generation\x20&\x20User\x20Data','summary':'Local\x20workspace\x20files:\x20list,\x20read,\x20search,\x20glob,\x20edit,\x20write,\x20move,\x20copy,\x20delete.','description':'Manage\x20the\x20local\x20workspace\x20directory\x20(`.wowok/workspace`):\x20files\x20generated\x20for\x20review\x20'+'(machine/guard/wts/wip\x20JSON)\x20and\x20user-created\x20documents.\x0a\x0a'+'Actions:\x0a'+'\x20\x20•\x20resolve\x20—\x20return\x20the\x20workspace\x20root\x20directory.\x0a'+'\x20\x20•\x20list\x20—\x20list\x20files\x20under\x20the\x20workspace.\x0a'+'\x20\x20•\x20read\x20—\x20read\x20a\x20file\x27s\x20content\x20(use\x20as\x20AI\x20context);\x20optional\x20offset/limit\x20line\x20slicing\x20'+'(1-based\x20offset,\x20max\x202000\x20lines)\x20and\x20encoding=\x27base64\x27\x20for\x20raw\x20bytes\x20(≤10MB).\x0a'+'\x20\x20•\x20search\x20—\x20regex\x20content\x20search\x20across\x20workspace\x20files\x20(pattern\x20required;\x20optional\x20path\x20scope,\x20'+'glob\x20basename\x20filter,\x20ignore_case,\x20max_results\x20≤200,\x20context_lines\x20≤5).\x20Skips\x20binary/large\x20files.\x0a'+'\x20\x20•\x20glob\x20—\x20list\x20files\x20whose\x20workspace-relative\x20path\x20matches\x20a\x20wildcard\x20pattern\x20(\x27**\x27\x20spans\x20'+'directories,\x20\x27*\x27\x20stays\x20within\x20one\x20segment,\x20\x27?\x27\x20=\x20one\x20char,\x20\x27{a,b}\x27\x20alternation).\x0a'+'\x20\x20•\x20edit\x20—\x20exact\x20string\x20replacement\x20inside\x20a\x20file\x20(path\x20+\x20old_string\x20+\x20new_string\x20required;\x20'+'errors\x20when\x20old_string\x20is\x20not\x20unique\x20unless\x20replace_all=true;\x20files\x20≤2MB).\x0a'+'\x20\x20•\x20write\x20—\x20write/overwrite\x20a\x20file\x20(path\x20+\x20content).\x0a'+'\x20\x20•\x20delete\x20—\x20delete\x20a\x20file.\x0a'+'\x20\x20•\x20create_file\x20—\x20create\x20an\x20empty\x20file\x20(path\x20required;\x20content\x20optional).\x0a'+'\x20\x20•\x20create_dir\x20—\x20create\x20a\x20directory\x20recursively\x20(path\x20required).\x0a'+'\x20\x20•\x20copy\x20—\x20copy\x20a\x20file\x20or\x20directory\x20(from\x20+\x20to\x20required).\x0a'+'\x20\x20•\x20move\x20—\x20move\x20a\x20file\x20or\x20directory\x20(from\x20+\x20to\x20required).\x0a'+'\x20\x20•\x20rename\x20—\x20rename\x20a\x20file\x20or\x20directory\x20(from\x20+\x20to\x20required).\x0a\x0a'+'Local\x20filesystem\x20only;\x20never\x20mutates\x20chain\x20state.\x0a\x0a'+'💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27workspace_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema.','inputSchema':WorkspaceOperationInputSchema,'outputSchema':WorkspaceOperationOutputSchema,'annotations':{'readOnlyHint':![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':![]},'_meta':createToolMeta('workspace',['workspace','file','document','machine','guard','wts','wip','context'])}},{'name':'workflow_operation','handler':handleWorkflowOperation,'config':{'title':'🔀\x20Workflow\x20-\x20Local-Account\x20Progress\x20Tasks','summary':'List\x20local-account\x20progress\x20(actionable\x20+\x20related/history)\x20+\x20advance/hold/unhold\x20forwards\x20+\x20view\x20progress\x20history.','description':'Local-account\x20workflow\x20view\x20over\x20on-chain\x20Progress\x20objects.\x0a\x0a'+'Actions:\x0a'+'\x20\x20•\x20list\x20—\x20enumerate\x20progress\x20related\x20to\x20local\x20accounts:\x20actionable\x20first\x20(a\x20'+'local\x20account\x20can\x20advance\x20a\x20forward),\x20plus\x20related\x20/\x20completed\x20progress\x20(order\x20'+'holder,\x20named\x20operator,\x20or\x20session\x20operator\x20involvement)\x20so\x20the\x20user\x20always\x20'+'keeps\x20visibility\x20of\x20their\x20own\x20progress\x20history.\x20Each\x20task\x20carries\x20every\x20'+'reachable\x20next\x20node\x20+\x20forward,\x20the\x20local\x20accounts\x20that\x20can\x20execute\x20each\x20'+'forward\x20(order\x20holder\x20/\x20named\x20operator\x20/\x20permission\x20index,\x20including\x20admin),\x20'+'guard\x20reminders\x20(a\x20forward\x20with\x20a\x20guard\x20must\x20be\x20verified\x20via\x20passport),\x20and\x20'+'the\x20on-chain\x20history_count.\x0a'+'\x20\x20•\x20operate\x20—\x20advance\x20(\x27next\x27)\x20/\x20block\x20(\x27hold\x27)\x20/\x20release\x20(\x27unhold\x27)\x20/\x20force-release\x20'+'(\x27adminUnhold\x27)\x20a\x20forward\x20as\x20a\x20chosen\x20local\x20account\x20(env.account).\x20Delegates\x20to\x20the\x20'+'on-chain\x20progress\x20operation\x20(guard-aware).\x0a'+'\x20\x20•\x20history\x20—\x20incrementally\x20sync\x20a\x20progress\x27s\x20ON-CHAIN\x20history\x20(Progress.history\x20'+'append-only\x20u64\x20index)\x20into\x20the\x20local\x20SQLite\x20mirror\x20via\x20a\x20per-progress\x20cursor\x20'+'(only\x20NEW\x20records\x20are\x20pulled),\x20then\x20return\x20the\x20migration\x20timeline\x20(newest\x20first)\x20'+'with\x20each\x20migration\x27s\x20session\x20snapshot\x20(forwards\x20/\x20operator\x20address\x20/\x20weight\x20/\x20time).\x20'+'Also\x20runs\x20a\x2090-day\x20retention\x20cleanup\x20of\x20stale\x20progress\x20histories\x20by\x20default.\x0a\x0a'+'Permission\x20model\x20(chain-authoritative):\x20a\x20forward\x20is\x20executable\x20by\x20an\x20account\x20when\x20'+'(a)\x20namedOperator=\x22\x22\x20and\x20the\x20account\x20is\x20the\x20order\x20holder\x20(order\x20builder\x20or\x20agent),\x20'+'or\x20(b)\x20namedOperator=name\x20and\x20the\x20account\x20is\x20in\x20progress.namedOperator[name],\x20or\x20'+'(c)\x20permissionIndex\x20is\x20set\x20and\x20the\x20account\x20is\x20in\x20permission.admin\x20or\x20permission.table.\x0a\x0a'+'💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27workflow_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema.','inputSchema':WorkflowOperationInputSchema,'outputSchema':WorkflowOperationOutputSchema,'annotations':{'readOnlyHint':![],'destructiveHint':!![],'idempotentHint':![],'openWorldHint':!![]},'_meta':createToolMeta('workflow',['workflow','progress','forward','permission','named-operator','guard','advance','hold'])},'timeoutMs':0x1d4c0},{'name':'permission_operation','handler':handlePermissionOperation,'config':{'title':'🛡️\x20Permissions\x20-\x20Local-Account\x20Overview','summary':'List\x20Permissions\x20related\x20to\x20local\x20accounts\x20with\x20related\x20accounts/objects.','description':'Local-account\x20Permission\x20overview.\x0a\x0a'+'Actions:\x0a'+'\x20\x20•\x20list\x20—\x20enumerate\x20every\x20on-chain\x20Permission\x20object\x20related\x20to\x20at\x20least\x20one\x20LOCAL\x20'+'account\x20(reverse-looked-up\x20via\x20the\x20global\x20entity_permission\x20index\x20@0xaad),\x20deduplicated\x20'+'and\x20merged.\x20Each\x20row\x20includes\x20description,\x20owner,\x20latest\x20on-chain\x20update\x20time,\x20related\x20'+'accounts\x20(owner/admin/entity),\x20and\x20related\x20objects\x20(grouped\x20by\x20type\x20via\x20the\x20registrar\x20'+'linker).\x20Pass\x20`permission`\x20to\x20scope\x20the\x20listing\x20to\x20ONE\x20Permission\x20address\x20—\x20fast\x20path\x20'+'(metadata\x20+\x20local-account\x20roles\x20only;\x20skips\x20the\x20per-permission\x20linker/tx-time\x20fan-out)\x20'+'for\x20detail-page\x20Permission\x20rows.\x0a\x0a'+'Read-only\x20(no\x20on-chain\x20mutation).\x0a\x0a'+'💡\x20Schema\x20hint:\x20call\x20the\x20OTHER\x20tool\x20`schema_query`\x20with\x20action=\x27get\x27\x20and\x20name=\x27permission_operation\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema.','inputSchema':PermissionOperationInputSchema,'outputSchema':PermissionOperationOutputSchema,'annotations':{'readOnlyHint':!![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':![]},'_meta':createToolMeta('query',['permission','account','role','owner','admin','entity','overview','registrar','reverse-index'])}}];
|