@wowok/agent-mcp 3.4.1 → 3.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/chain-semantics/composition-truth.js +1 -1
  2. package/dist/extensions/capability.js +1 -1
  3. package/dist/extensions/industry-pack.js +1 -1
  4. package/dist/extensions/modes.js +1 -1
  5. package/dist/harness/recover.js +1 -1
  6. package/dist/knowledge/arbitration-templates.js +1 -1
  7. package/dist/knowledge/audit-rules.d.ts +2 -1
  8. package/dist/knowledge/audit-rules.js +1 -1
  9. package/dist/knowledge/builtin-templates.d.ts +17 -1
  10. package/dist/knowledge/builtin-templates.js +1 -1
  11. package/dist/knowledge/fee-param-bindings.js +1 -1
  12. package/dist/knowledge/guard-bindings.js +1 -1
  13. package/dist/knowledge/guard-field-cognition.js +1 -1
  14. package/dist/knowledge/guard-templates.js +1 -1
  15. package/dist/knowledge/param-schema.js +1 -1
  16. package/dist/knowledge/pattern-resolutions.js +1 -1
  17. package/dist/knowledge/scenario-modes.js +1 -1
  18. package/dist/knowledge/template-scanner.js +1 -1
  19. package/dist/knowledge/template-test-profiles.js +1 -1
  20. package/dist/participation/customer-interest.d.ts +4 -0
  21. package/dist/participation/customer-interest.js +1 -1
  22. package/dist/participation/node-action-advisor.d.ts +4 -0
  23. package/dist/participation/node-action-advisor.js +1 -1
  24. package/dist/participation/time-window.d.ts +11 -0
  25. package/dist/participation/time-window.js +1 -1
  26. package/dist/playbooks/service-build/participation-radar.js +1 -1
  27. package/dist/schema/benchmark-migration/index.js +1 -1
  28. package/dist/schema/call/allocation.js +1 -1
  29. package/dist/schema/call/proof.js +1 -1
  30. package/dist/schema/call/service.d.ts +15 -5
  31. package/dist/schema/call/service.js +1 -1
  32. package/dist/schema/operations.d.ts +3 -1
  33. package/dist/schema/query/index.js +1 -1
  34. package/dist/schemas/benchmark_migration_operation.schema.json +1 -1
  35. package/dist/schemas/index.json +1 -1
  36. package/dist/schemas/onchain_operations.schema.json +16 -6
  37. package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
  38. package/dist/schemas/onchain_operations_guard.schema.json +2 -2
  39. package/dist/schemas/onchain_operations_proof.schema.json +1 -1
  40. package/dist/schemas/onchain_operations_service.schema.json +12 -2
  41. package/dist/schemas/query_toolkit.output.json +1 -1
  42. package/dist/tools/handlers/benchmark-migration.d.ts +9 -0
  43. package/dist/tools/handlers/benchmark-migration.js +1 -1
  44. package/dist/tools/handlers/onchain.d.ts +10 -0
  45. package/dist/tools/handlers/onchain.js +1 -1
  46. package/dist/tools/wrap.js +1 -1
  47. package/package.json +1 -1
@@ -515,7 +515,7 @@
515
515
  ]
516
516
  },
517
517
  "plan": {
518
- "description": "The creation plan to execute (required for plan_execute): pass the object returned under 'plan' by template_generate VERBATIM — mutating steps by hand is what the 32-manual-write era did. Executing requires verdict.buildable=true; a blocked plan is refused at the freeze gate.",
518
+ "description": "The creation plan to execute (required for plan_execute): pass the object returned under 'plan' by template_generate VERBATIM — mutating steps by hand is what the 32-manual-write era did. Alternatively pass {root:'file', path:'<plan.json>'} to read the plan from disk (HAR-P1-14: avoids echoing a 38-40-step plan through the tool-call arguments; the file must contain the plan envelope or the bare plan as JSON). Executing requires verdict.buildable=true; a blocked plan is refused at the freeze gate.",
519
519
  "type": "object",
520
520
  "propertyNames": {
521
521
  "type": "string"
@@ -2,7 +2,7 @@
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
3
  "title": "WoWok MCP Schema Index",
4
4
  "description": "Index of all available JSON schemas for WoWok MCP tools",
5
- "generatedAt": "2026-11-02T06:06:26.283Z",
5
+ "generatedAt": "2026-11-02T11:36:08.960Z",
6
6
  "tools": [
7
7
  {
8
8
  "name": "onchain_operations",
@@ -109,8 +109,19 @@
109
109
  "type": "object",
110
110
  "properties": {
111
111
  "name": {
112
+ "description": "Name of the product or service to purchase. Must match a listed sale name EXACTLY (the buy path resolves each item by exact name match) and MUST be ≤ 64 bytes (UTF-8): the on-chain buy path caps buyer-sent item names at 64 bytes even though the merchant side lists names up to 256 bytes — a longer name aborts E_NAME_LENGTH_EXCEEDED (abort 1) before anything else runs (F-RQ-01). When the exact name is impractical (long/CJK names that risk transport corruption), OMIT it and use sale_id or sale_name instead — the handler resolves the reference against the Service's LIVE sales list and fills this name for you (CHAN-P1-16).",
113
+ "type": "string"
114
+ },
115
+ "sale_id": {
116
+ "description": "CHAN-P1-16: buy by the SKU's 0-based INDEX in the Service's live sales list (the order the service_quote / query lists them). The handler resolves the index to the live sale (name + price), rewrites item.name on your behalf, and echoes `sale_index + sale_name + price` in the response — the exact name never crosses the wire. Out-of-range index → refused with the full live index table (index + name + price) so one retry lands. Consumed by the MCP gate, never reaches the chain.",
117
+ "type": "integer",
118
+ "minimum": 0,
119
+ "maximum": 9007199254740991
120
+ },
121
+ "sale_name": {
122
+ "description": "CHAN-P1-16: buy by SKU NAME matched against the Service's LIVE sales list (exact match first; whitespace/case-tolerant, then containment when the name was corrupted in transport). Exactly one live match → the handler fills item.name and echoes `sale_index + sale_name + price`; several candidates → refused with every candidate's index; none → refused with the full live index table. Consumed by the MCP gate, never reaches the chain.",
112
123
  "type": "string",
113
- "description": "Name of the product or service to purchase. Must match a listed sale name EXACTLY (the buy path resolves each item by exact name match) and MUST be ≤ 64 bytes (UTF-8): the on-chain buy path caps buyer-sent item names at 64 bytes even though the merchant side lists names up to 256 bytes — a longer name aborts E_NAME_LENGTH_EXCEEDED (abort 1) before anything else runs (F-RQ-01)."
124
+ "minLength": 1
114
125
  },
115
126
  "quantity": {
116
127
  "anyOf": [
@@ -130,7 +141,6 @@
130
141
  }
131
142
  },
132
143
  "required": [
133
- "name",
134
144
  "quantity",
135
145
  "wip_hash"
136
146
  ],
@@ -12908,7 +12918,7 @@
12908
12918
  "items": {
12909
12919
  "type": "string"
12910
12920
  },
12911
- "description": "EXPLICIT candidate object IDs (vector<address>) to scan. Duplicates are deduped; max 100 candidates; an EMPTY list matches no records (scalar 0) — there is no 'all objects' wildcard. S12-③ witness boundary (v139): the 100-cap applies to THIS guard-table vector; the guard's inline WITNESS is separately capped at 4096 BCS bytes total (passport MAX_SUBMISSION_SIZE — a 100-address roster fits), so keep roster-style attestation here in the vector and reserve the witness for per-call attestation."
12921
+ "description": "EXPLICIT candidate object IDs (vector<address>) to scan. Duplicates are deduped; max 100 candidates; an EMPTY list matches no records (scalar 0) — there is no 'all objects' wildcard. S12-③ witness boundary (v140): the 100-cap applies to THIS guard-table vector; the guard's inline WITNESS is separately capped at 4096 BCS bytes total (passport MAX_SUBMISSION_SIZE — a 100-address roster fits), so keep roster-style attestation here in the vector and reserve the witness for per-call attestation."
12912
12922
  }
12913
12923
  },
12914
12924
  "required": [
@@ -17956,7 +17966,7 @@
17956
17966
  "where"
17957
17967
  ],
17958
17968
  "additionalProperties": false,
17959
- "description": "Returns U256. ESCROW-BOUND sum (query 1179, live cap v139): per-row min(row_value, order.amount, LIVE allocation.balance of the Order the row id names) — only funds still in escrow right now count, so a refunded or already-disbursed order contributes 0 naturally; a row whose Order has no allocation link also contributes 0, while an unreadable allocation object aborts the query (corruption is never a silent 0). A row keyed by anything that is not an Order contributes 0 (fail-closed). Unlike query_repository_data_sum_where (self-reported row values), a record cannot claim more than the escrow actually bound to it — the forgery-proof aggregate for threshold gates and Formula pricing. Use logic_as_u256_* to compare the sum."
17969
+ "description": "Returns U256. ESCROW-BOUND sum (query 1179, live cap v140): per-row min(row_value, order.amount, LIVE allocation.balance of the Order the row id names) — only funds still in escrow right now count, so a refunded or already-disbursed order contributes 0 naturally; a row whose Order has no allocation link also contributes 0, while an unreadable allocation object aborts the query (corruption is never a silent 0). A row keyed by anything that is not an Order contributes 0 (fail-closed). Unlike query_repository_data_sum_where (self-reported row values), a record cannot claim more than the escrow actually bound to it — the forgery-proof aggregate for threshold gates and Formula pricing. Use logic_as_u256_* to compare the sum."
17960
17970
  },
17961
17971
  {
17962
17972
  "type": "object",
@@ -23141,7 +23151,7 @@
23141
23151
  ]
23142
23152
  },
23143
23153
  "about_address": {
23144
- "description": "About binding (K3 contract): ONLY the counterparty ACCOUNT address (address first byte = account type) or a Proof object address (first byte = Proof type) — a messenger contact record. NEVER a business object (Progress/Order/Arb) and never a guard decision condition. Accepts null/undefined (→ Move Option::none). When provided, must be a raw 0x-prefixed address (NOT a name). e.g. the peer account being proved with.",
23154
+ "description": "About binding (K3 contract): ONLY the counterparty ACCOUNT address (address first byte = account type) or a Proof object address (first byte = Proof type) — a messenger contact record. NEVER a business object (Progress/Arb) and never a guard decision condition. ONE EXCEPTION (F-27, Move truth — the order's required_info_bind entry): a Proof intended for order.required_info_bind MUST carry about = the ORDER's own address, with the Proof creator = the order owner (E_REQUIRED_INFO_PROOF_NOT_BOUND, abort 11 — the messenger-contact restriction does not apply to that flow). Accepts null/undefined (→ Move Option::none). When provided, must be a raw 0x-prefixed address (NOT a name). e.g. the peer account being proved with.",
23145
23155
  "anyOf": [
23146
23156
  {
23147
23157
  "type": "string",
@@ -27297,7 +27307,7 @@
27297
27307
  "where"
27298
27308
  ],
27299
27309
  "additionalProperties": false,
27300
- "description": "Returns U256. ESCROW-BOUND sum (query 1179, live cap v139): per-row min(row_value, order.amount, LIVE allocation.balance of the Order the row id names) — only funds still in escrow right now count, so a refunded or already-disbursed order contributes 0 naturally; a row whose Order has no allocation link also contributes 0, while an unreadable allocation object aborts the query (corruption is never a silent 0). A row keyed by anything that is not an Order contributes 0 (fail-closed). Unlike query_repository_data_sum_where (self-reported row values), a record cannot claim more than the escrow actually bound to it — the forgery-proof aggregate for threshold gates and Formula pricing. Use logic_as_u256_* to compare the sum."
27310
+ "description": "Returns U256. ESCROW-BOUND sum (query 1179, live cap v140): per-row min(row_value, order.amount, LIVE allocation.balance of the Order the row id names) — only funds still in escrow right now count, so a refunded or already-disbursed order contributes 0 naturally; a row whose Order has no allocation link also contributes 0, while an unreadable allocation object aborts the query (corruption is never a silent 0). A row keyed by anything that is not an Order contributes 0 (fail-closed). Unlike query_repository_data_sum_where (self-reported row values), a record cannot claim more than the escrow actually bound to it — the forgery-proof aggregate for threshold gates and Formula pricing. Use logic_as_u256_* to compare the sum."
27301
27311
  },
27302
27312
  {
27303
27313
  "type": "object",
@@ -706,7 +706,7 @@
706
706
  "items": {
707
707
  "type": "string"
708
708
  },
709
- "description": "EXPLICIT candidate object IDs (vector<address>) to scan. Duplicates are deduped; max 100 candidates; an EMPTY list matches no records (scalar 0) — there is no 'all objects' wildcard. S12-③ witness boundary (v139): the 100-cap applies to THIS guard-table vector; the guard's inline WITNESS is separately capped at 4096 BCS bytes total (passport MAX_SUBMISSION_SIZE — a 100-address roster fits), so keep roster-style attestation here in the vector and reserve the witness for per-call attestation."
709
+ "description": "EXPLICIT candidate object IDs (vector<address>) to scan. Duplicates are deduped; max 100 candidates; an EMPTY list matches no records (scalar 0) — there is no 'all objects' wildcard. S12-③ witness boundary (v140): the 100-cap applies to THIS guard-table vector; the guard's inline WITNESS is separately capped at 4096 BCS bytes total (passport MAX_SUBMISSION_SIZE — a 100-address roster fits), so keep roster-style attestation here in the vector and reserve the witness for per-call attestation."
710
710
  }
711
711
  },
712
712
  "required": [
@@ -3363,7 +3363,7 @@
3363
3363
  "where"
3364
3364
  ],
3365
3365
  "additionalProperties": false,
3366
- "description": "Returns U256. ESCROW-BOUND sum (query 1179, live cap v139): per-row min(row_value, order.amount, LIVE allocation.balance of the Order the row id names) — only funds still in escrow right now count, so a refunded or already-disbursed order contributes 0 naturally; a row whose Order has no allocation link also contributes 0, while an unreadable allocation object aborts the query (corruption is never a silent 0). A row keyed by anything that is not an Order contributes 0 (fail-closed). Unlike query_repository_data_sum_where (self-reported row values), a record cannot claim more than the escrow actually bound to it — the forgery-proof aggregate for threshold gates and Formula pricing. Use logic_as_u256_* to compare the sum."
3366
+ "description": "Returns U256. ESCROW-BOUND sum (query 1179, live cap v140): per-row min(row_value, order.amount, LIVE allocation.balance of the Order the row id names) — only funds still in escrow right now count, so a refunded or already-disbursed order contributes 0 naturally; a row whose Order has no allocation link also contributes 0, while an unreadable allocation object aborts the query (corruption is never a silent 0). A row keyed by anything that is not an Order contributes 0 (fail-closed). Unlike query_repository_data_sum_where (self-reported row values), a record cannot claim more than the escrow actually bound to it — the forgery-proof aggregate for threshold gates and Formula pricing. Use logic_as_u256_* to compare the sum."
3367
3367
  },
3368
3368
  {
3369
3369
  "type": "object",
@@ -7231,7 +7231,7 @@
7231
7231
  "where"
7232
7232
  ],
7233
7233
  "additionalProperties": false,
7234
- "description": "Returns U256. ESCROW-BOUND sum (query 1179, live cap v139): per-row min(row_value, order.amount, LIVE allocation.balance of the Order the row id names) — only funds still in escrow right now count, so a refunded or already-disbursed order contributes 0 naturally; a row whose Order has no allocation link also contributes 0, while an unreadable allocation object aborts the query (corruption is never a silent 0). A row keyed by anything that is not an Order contributes 0 (fail-closed). Unlike query_repository_data_sum_where (self-reported row values), a record cannot claim more than the escrow actually bound to it — the forgery-proof aggregate for threshold gates and Formula pricing. Use logic_as_u256_* to compare the sum."
7234
+ "description": "Returns U256. ESCROW-BOUND sum (query 1179, live cap v140): per-row min(row_value, order.amount, LIVE allocation.balance of the Order the row id names) — only funds still in escrow right now count, so a refunded or already-disbursed order contributes 0 naturally; a row whose Order has no allocation link also contributes 0, while an unreadable allocation object aborts the query (corruption is never a silent 0). A row keyed by anything that is not an Order contributes 0 (fail-closed). Unlike query_repository_data_sum_where (self-reported row values), a record cannot claim more than the escrow actually bound to it — the forgery-proof aggregate for threshold gates and Formula pricing. Use logic_as_u256_* to compare the sum."
7235
7235
  },
7236
7236
  {
7237
7237
  "type": "object",
@@ -88,7 +88,7 @@
88
88
  ]
89
89
  },
90
90
  "about_address": {
91
- "description": "About binding (K3 contract): ONLY the counterparty ACCOUNT address (address first byte = account type) or a Proof object address (first byte = Proof type) — a messenger contact record. NEVER a business object (Progress/Order/Arb) and never a guard decision condition. Accepts null/undefined (→ Move Option::none). When provided, must be a raw 0x-prefixed address (NOT a name). e.g. the peer account being proved with.",
91
+ "description": "About binding (K3 contract): ONLY the counterparty ACCOUNT address (address first byte = account type) or a Proof object address (first byte = Proof type) — a messenger contact record. NEVER a business object (Progress/Arb) and never a guard decision condition. ONE EXCEPTION (F-27, Move truth — the order's required_info_bind entry): a Proof intended for order.required_info_bind MUST carry about = the ORDER's own address, with the Proof creator = the order owner (E_REQUIRED_INFO_PROOF_NOT_BOUND, abort 11 — the messenger-contact restriction does not apply to that flow). Accepts null/undefined (→ Move Option::none). When provided, must be a raw 0x-prefixed address (NOT a name). e.g. the peer account being proved with.",
92
92
  "anyOf": [
93
93
  {
94
94
  "type": "string",
@@ -107,8 +107,19 @@
107
107
  "type": "object",
108
108
  "properties": {
109
109
  "name": {
110
+ "description": "Name of the product or service to purchase. Must match a listed sale name EXACTLY (the buy path resolves each item by exact name match) and MUST be ≤ 64 bytes (UTF-8): the on-chain buy path caps buyer-sent item names at 64 bytes even though the merchant side lists names up to 256 bytes — a longer name aborts E_NAME_LENGTH_EXCEEDED (abort 1) before anything else runs (F-RQ-01). When the exact name is impractical (long/CJK names that risk transport corruption), OMIT it and use sale_id or sale_name instead — the handler resolves the reference against the Service's LIVE sales list and fills this name for you (CHAN-P1-16).",
111
+ "type": "string"
112
+ },
113
+ "sale_id": {
114
+ "description": "CHAN-P1-16: buy by the SKU's 0-based INDEX in the Service's live sales list (the order the service_quote / query lists them). The handler resolves the index to the live sale (name + price), rewrites item.name on your behalf, and echoes `sale_index + sale_name + price` in the response — the exact name never crosses the wire. Out-of-range index → refused with the full live index table (index + name + price) so one retry lands. Consumed by the MCP gate, never reaches the chain.",
115
+ "type": "integer",
116
+ "minimum": 0,
117
+ "maximum": 9007199254740991
118
+ },
119
+ "sale_name": {
120
+ "description": "CHAN-P1-16: buy by SKU NAME matched against the Service's LIVE sales list (exact match first; whitespace/case-tolerant, then containment when the name was corrupted in transport). Exactly one live match → the handler fills item.name and echoes `sale_index + sale_name + price`; several candidates → refused with every candidate's index; none → refused with the full live index table. Consumed by the MCP gate, never reaches the chain.",
110
121
  "type": "string",
111
- "description": "Name of the product or service to purchase. Must match a listed sale name EXACTLY (the buy path resolves each item by exact name match) and MUST be ≤ 64 bytes (UTF-8): the on-chain buy path caps buyer-sent item names at 64 bytes even though the merchant side lists names up to 256 bytes — a longer name aborts E_NAME_LENGTH_EXCEEDED (abort 1) before anything else runs (F-RQ-01)."
122
+ "minLength": 1
112
123
  },
113
124
  "quantity": {
114
125
  "anyOf": [
@@ -128,7 +139,6 @@
128
139
  }
129
140
  },
130
141
  "required": [
131
- "name",
132
142
  "quantity",
133
143
  "wip_hash"
134
144
  ],
@@ -27252,7 +27252,7 @@
27252
27252
  "where"
27253
27253
  ],
27254
27254
  "additionalProperties": false,
27255
- "description": "Returns U256. ESCROW-BOUND sum (query 1179, live cap v139): per-row min(row_value, order.amount, LIVE allocation.balance of the Order the row id names) — only funds still in escrow right now count, so a refunded or already-disbursed order contributes 0 naturally; a row whose Order has no allocation link also contributes 0, while an unreadable allocation object aborts the query (corruption is never a silent 0). A row keyed by anything that is not an Order contributes 0 (fail-closed). Unlike query_repository_data_sum_where (self-reported row values), a record cannot claim more than the escrow actually bound to it — the forgery-proof aggregate for threshold gates and Formula pricing. Use logic_as_u256_* to compare the sum."
27255
+ "description": "Returns U256. ESCROW-BOUND sum (query 1179, live cap v140): per-row min(row_value, order.amount, LIVE allocation.balance of the Order the row id names) — only funds still in escrow right now count, so a refunded or already-disbursed order contributes 0 naturally; a row whose Order has no allocation link also contributes 0, while an unreadable allocation object aborts the query (corruption is never a silent 0). A row keyed by anything that is not an Order contributes 0 (fail-closed). Unlike query_repository_data_sum_where (self-reported row values), a record cannot claim more than the escrow actually bound to it — the forgery-proof aggregate for threshold gates and Formula pricing. Use logic_as_u256_* to compare the sum."
27256
27256
  },
27257
27257
  {
27258
27258
  "type": "object",
@@ -19,6 +19,13 @@ export declare function wipAnchorFace(sales: unknown): {
19
19
  unpinned_skus: string[];
20
20
  remediation: string;
21
21
  } | undefined;
22
+ export declare function returnNoExitFace(templateId: string): {
23
+ status: string;
24
+ rule_id: string;
25
+ severity: string;
26
+ stranded_nodes: string[];
27
+ remediation: string;
28
+ } | undefined;
22
29
  declare function driftFace(templateId: string): {
23
30
  template: string;
24
31
  state: "current";
@@ -41,6 +48,8 @@ declare function driftFace(templateId: string): {
41
48
  repairable: boolean;
42
49
  detail: string;
43
50
  };
51
+ export declare function planEnvelopeFromInput(planInput: unknown): Record<string, unknown>;
52
+ export declare function templateAdvisoryFaces(templateId: string | undefined): Record<string, unknown>;
44
53
  declare function scanSummary(scan: TemplateScanResult, drift?: ReturnType<typeof driftFace>): {
45
54
  template_id: string;
46
55
  risk_level: import("../../knowledge/template-scanner.js").TemplateRiskLevel;
@@ -1 +1 @@
1
- import{strictParse}from'../../schema/index.js';import{BenchmarkMigrationSchema}from'../../schema/benchmark-migration/index.js';import{getTemplate,getTemplateLoadError,listTemplates,validateAllocatorRows,platformShareBps,builtinTemplateDrift,templateCatalogDigest}from'../../knowledge/template-loader.js';import{BUILTIN_TEMPLATES,auditTemplateOnceSlotArms,auditTemplateNodeOperatorOverwrite,BUILTIN_TEMPLATES_VERSION,DISCOVERY_PRODUCT_REFS,DISCOVERY_TAG_VOCABULARY,discoveryTagsForTemplate}from'../../knowledge/builtin-templates.js';import{landPlatformCommission}from'../../knowledge/commission-landing.js';import{getTemplateParamFileLayer,templateParamsFilePath}from'../../config/template-params.js';import{scanTemplate,buildFeeParamLandingTable}from'../../knowledge/template-scanner.js';import{planMigration}from'../../playbooks/service-build/migration-planner.js';import{handleMerchantGuide}from'../../playbooks/service-build/merchant-guide.js';import{inferArbitration}from'../../playbooks/service-build/intent-analyzer.js';import{getIndustryModeRegistry}from'../../extensions/index.js';import{listIndustries,resolveIndustryName}from'../../knowledge/industry-registry.js';import{claimNumber,discoverySignal,normalizeSemanticIR}from'../../knowledge/semantic-ir.js';import{handleRecommendIndustry}from'../../playbooks/service-build/mode-actions.js';import{bindAuditPlan,bindAuditReport,bindRecoveryList,handlerExecutor,materializePlan}from'../../composition/materialize.js';import{clearPlanStep,lockedFreshStep,planLedgerKey,recordPlanRound,repeatedPlanFailures}from'../../composition/plan-retry-ledger.js';import{collectLateMarks,collectAddressSlotBareNames,validatePlan}from'../../composition/plan.js';import{LocalMark}from'@wowok/wowok';import{join,dirname}from'node:path';import{fileURLToPath}from'node:url';import{computeSrcDistStaleness}from'../upgrade-check.js';const __dirname=dirname(fileURLToPath(import.meta.url));export function platformMarkRefusal(a,b){const c=a['toLowerCase']()['replace'](/^0x/,'');if(/^0x[0-9a-fA-F]{1,64}$/['test'](a)&&!/^0+$/['test'](c))return undefined;return'action=\x27plan_execute\x27:\x20the\x20LocalMark\x20\x27platform\x27\x20resolves\x20to\x20\x27'+a+'\x27\x20on\x20'+b+'\x20network\x20—\x20not\x20a\x20usable\x20account\x20address.\x20'+'This\x20plan\x20names\x20\x27platform\x27\x20as\x20a\x20settlement\x20recipient\x20and\x20order_allocators\x20freezes\x20at\x20Service\x20publish,\x20so\x20a\x20wrong\x20payee\x20can\x20only\x20be\x20fixed\x20by\x20re-publishing\x20the\x20Service.\x20'+'An\x20empty\x20name\x20makes\x20the\x20SDK\x20substitute\x20the\x20deploying\x20account\x20(the\x20share\x20lands\x20in\x20whoever\x20runs\x20the\x20deploy);\x20an\x20object-id\x20/\x20zero-address\x20recipient\x20is\x20transferred\x20and\x20cannot\x20be\x20retrieved.\x20'+'Re-point\x20the\x20mark\x20at\x20a\x20real\x20account\x20address\x20—\x20local_mark_operation\x20{add:{op:\x22add\x22,data:[{name:\x22platform\x22,address:\x220x...\x22}]}}\x20—\x20then\x20re-run.\x20Nothing\x20was\x20executed.';}export function staleBuildFace(a=join(__dirname,'..','..','..','src'),b=join(__dirname,'..','..','..','dist')){let c=null;try{c=computeSrcDistStaleness(a,b,{'srcExt':'.ts','distExt':'.js'});}catch{c=null;}if(!c)return{'stale':![],'known':![],'actionable':![],'lag_minutes':null,'detail':'Stale-build\x20state\x20UNKNOWN\x20—\x20the\x20source\x20and\x20build-output\x20trees\x20were\x20not\x20both\x20resolvable\x20(installed\x20dist-only\x20'+'package\x20or\x20a\x20build\x20in\x20progress),\x20so\x20template\x20freshness\x20could\x20not\x20be\x20verified.\x20NOT\x20actionable:\x20treat\x20the\x20'+'scan/plan\x20verdicts\x20as\x20unconfirmed\x20—\x20do\x20not\x20act\x20on\x20them\x20until\x20a\x20rebuild\x20resolves\x20freshness.'};if(!c['stale'])return{'stale':![],'known':!![],'actionable':!![],'lag_minutes':c['lag_minutes'],'detail':'dist\x20is\x20current\x20with\x20src\x20(newest\x20compiled\x20.js\x20vs\x20newest\x20source\x20.ts\x20mtime\x20lag\x20'+c['lag_minutes']+'\x20'+'minute(s))\x20—\x20the\x20scan/plan\x20verdicts\x20reflect\x20this\x20workspace\x20checkout.'};return{'stale':!![],'known':!![],'actionable':![],'lag_minutes':c['lag_minutes'],'detail':'NOT\x20ACTIONABLE\x20—\x20do\x20not\x20act\x20on\x20the\x20verdicts\x20in\x20this\x20response.\x20dist\x20is\x20'+c['lag_minutes']+'\x20minute(s)\x20OLDER\x20'+'than\x20src\x20(newest\x20compiled\x20.js\x20vs\x20newest\x20source\x20.ts\x20mtime),\x20so\x20every\x20scan/plan\x20conclusion\x20above\x20may\x20'+'describe\x20superseded\x20template\x20knowledge\x20(live\x20rq-tn-261030-8693be:\x20a\x20508-minute-stale\x20dist\x20produced\x20two\x20'+'false\x20defect\x20reports,\x20F-RQ-09/14).\x20Rebuild\x20(pnpm\x20build),\x20restart\x20the\x20MCP\x20process,\x20and\x20re-run\x20before\x20'+'acting\x20on\x20ANY\x20conclusion\x20here.'};}function templateSummary(a){return{'id':a['id'],'industry':a['industry'],'variant':a['variant'],'product_ref':a['product_ref'],'archetype':a['archetype'],'key_risk':a['key_risk'],'node_count':a['machine_shape']['length'],'guard_count':a['guards']['length'],'recommended_role':a['recommended_role'],'tags':discoveryTagsForTemplate(a['id'])};}function templateGetAids(a){const b=a['machine_shape']['find'](g=>g['name']==='reviewed'),c=b!==undefined&&a['review_mode']!=='none'&&b['operator']!=='merchant',d=a['allocator']['rows']??[],e=[...new Set(d['map'](g=>g['guard_key'])['filter'](g=>typeof g==='string'&&g!==''))],f=d['length']>0x0?'\x20On-chain\x20this\x20materialises\x20as\x20~'+e['length']+'\x20Allocator\x20OBJECT(S)\x20(one\x20per\x20distinct\x20guard_key:\x20'+e['join'](',\x20')+')\x20across\x20'+d['length']+'\x20row(s)\x20—\x20model\x20capacity/monitoring\x20on\x20the\x20object\x20count,\x20never\x20on\x20allocator.count.':'\x20rows[]\x20is\x20empty\x20—\x20no\x20allocator\x20legs\x20are\x20declared.';return{'claim_anchor':c?'review_node+final':b!==undefined?'no_buyer_review_rail':'final_only','claim_anchor_note':c?'machine_shape\x20mounts\x20a\x20\x27reviewed\x27\x20node\x20—\x20the\x20buyer\x27s\x20structured\x20review\x20rides\x20that\x20node\x20alongside\x20the\x20final\x20settlement.':b!==undefined?'a\x20\x27reviewed\x27\x20node\x20exists\x20but\x20is\x20NOT\x20a\x20buyer\x20review\x20rail\x20(review_mode\x20\x27none\x27,\x20or\x20the\x20marker\x20is\x20merchant/triager-operated)\x20—\x20no\x20buyer-structured\x20review\x20is\x20mounted;\x20the\x20buyer\x27s\x20voice\x20rides\x20the\x20claim/arbitration\x20rail\x20only.':'no\x20\x27reviewed\x27\x20node\x20—\x20sanctioned\x20variant:\x20the\x20buyer\x27s\x20voice\x20rides\x20the\x20claim/arbitration\x20rail\x20only\x20(no\x20separate\x20review\x20stop).','allocator_count_note':'allocator.count\x20=\x20'+a['allocator']['count']+'\x20counts\x20SETTLEMENT-track\x20legs\x20only;\x20refund-track\x20legs\x20(rows[]\x20with\x20track:\x22refund\x22)\x20are\x20additional\x20and\x20NOT\x20included\x20in\x20this\x20count.\x20rows[]\x20carries\x20the\x20complete\x20executable\x20split\x20plan.'+f,'onchain_field_notes':['passport.impack\x20—\x20the\x20on-chain\x20field\x20is\x20spelled\x20`impack`\x20(the\x20on-chain\x20passport\x20contract\x27s\x20own\x20field\x20name,\x20packed\x20business\x20objects\x20in\x20the\x20passport\x20verification\x20context).\x20It\x20is\x20the\x20contract\x27s\x20own\x20field\x20name,\x20not\x20a\x20typo;\x20echo\x20it\x20verbatim.']};}function requireTemplate(a,b){if(!a)throw new Error('\x27template_id\x27\x20is\x20required\x20for\x20action=\x27'+b+'\x27');const c=getTemplate(a);if(!c){const d=getTemplateLoadError(a);if(d)throw new Error('Template\x20\x27'+a+'\x27\x20is\x20BLOCKED\x20for\x20action=\x27'+b+'\x27:\x20its\x20machine\x20file\x20failed\x20to\x20load/validate\x20and\x20is\x20invisible\x20to\x20every\x20action\x20until\x20fixed\x20(T-18\x20—\x20see\x20action=\x27template_list\x27\x20load_errors).\x20Loader:\x20'+d);throw new Error('Unknown\x20template\x20id:\x20'+a+'\x20(use\x20action=\x27template_list\x27\x20to\x20see\x20valid\x20ids)');}return c;}export function wipAnchorFace(a){if(!Array['isArray'](a)||a['length']===0x0)return undefined;const b=a['filter'](c=>c&&typeof c==='object'&&typeof c['name']==='string'&&String(c['wip_hash']??'')==='')['map'](c=>c['name']);if(b['length']===0x0)return undefined;return{'status':'unpinned','rule_id':'R-WIP-UNPINNED','severity':'high','unpinned_skus':b,'remediation':'These\x20SKU(s)\x20publish\x20with\x20NO\x20wip\x20pin\x20—\x20buyers\x20get\x20no\x20delivery-integrity\x20guarantee\x20(the\x20merchant\x20can\x20swap\x20the\x20.wip\x20file\x20later\x20undetected).\x20'+'After\x20publish,\x20rebind\x20via\x20the\x20per-item\x20sales\x20op\x20wip_set\x20(MCP\x20composite:\x20touches\x20only\x20wip/wip_hash)\x20or\x20a\x20full\x20op:set\x20rewrite\x20—\x20live-tested\x200.00272\x20gas.\x20'+'Prefer\x20passing\x20wip_hash\x20from\x20the\x20wip_file\x20tool\x20upload\x20at\x20build\x20time\x20instead.'};}function driftFace(a){const b=builtinTemplateDrift()['find'](c=>c['template']===a);if(!b){const c=BUILTIN_TEMPLATES['some'](d=>d['id']===a);return c?{'template':a,'state':'current','catalog_version':BUILTIN_TEMPLATES_VERSION,'blocked':![],'repairable':![],'detail':'disk\x20body\x20matches\x20the\x20shipped\x20catalog\x20(hash-verified\x20sentinel)'}:{'template':a,'state':'untracked','catalog_version':undefined,'blocked':![],'repairable':![],'detail':'user-authored\x20template\x20—\x20no\x20builtin\x20catalog\x20binding\x20to\x20compare\x20against'};}return{'template':b['template'],'state':b['state'],'catalog_version':BUILTIN_TEMPLATES_VERSION,'blocked':!![],'repairable':b['repairable'],'detail':b['detail']};}function withOnceSlotAdvisories(a){try{const b=auditTemplateOnceSlotArms()['find'](e=>e['template_id']===a['template_id']),c=auditTemplateNodeOperatorOverwrite()['filter'](e=>e['template_id']===a['template_id']);if(!b&&c['length']===0x0)return a;const d=c['map'](e=>({'rule_id':'NODE_OPERATOR_OVERWRITTEN','severity':'medium','title':'Edge\x20operator\x20inherited\x20past\x20an\x20explicit\x20source-node\x20operator','detail':e['message'],'suggestion':'Declare\x20edge.operator\x20explicitly\x20on\x20this\x20forward\x20(or\x20add\x20a\x20buyer-favour\x20timeout\x20exit\x20from\x20the\x20request\x20node).\x20The\x20kernel\x20inheritance\x20chain\x20(edge\x20??\x20dest-node\x20??\x20default)\x20never\x20consults\x20the\x20SOURCE\x20node,\x20so\x20an\x20un-annotated\x20edge\x20out\x20of\x20an\x20order_payer\x20request\x20node\x20silently\x20ships\x20as\x20a\x20merchant\x20permission\x20rail\x20(F-40/F-42:\x20the\x20buyer\x20parked\x20on\x20the\x20request\x20node\x20has\x20zero\x20executable\x20forwards\x20and\x20the\x20merchant\x20rewrite\x20ships\x20unguarded).\x20Re-run\x20action=\x27template_scan\x27\x20after\x20the\x20fix.'}));return{...a,'findings':[...a['findings'],...b?[{'rule_id':'R-ONCE-SLOT-ARM-254','severity':'medium','title':'Once-slot\x20arming\x20on\x20a\x20periodic\x20rail\x20('+b['kind']+')','detail':b['message'],'suggestion':'Arm\x20the\x20re-enterable\x20settlement/renewal\x20guard\x20with\x20identifier\x20255\x20plus\x20a\x20per-period\x20key\x20(period-<N>\x20from\x20chain\x20state,\x20e.g.\x20progress\x20history\x20count)\x20and\x20have\x20the\x20trigger\x20Passport\x20submit\x20the\x20same\x20value;\x20keep\x20254\x20for\x20one-shot-per-order\x20rails\x20only.\x20Re-run\x20action=\x27template_scan\x27\x20after\x20the\x20fix.'}]:[],...d]};}catch{return a;}}function scanSummary(a,b){a=withOnceSlotAdvisories(a);const c={};for(const d of a['findings'])c[d['severity']]=(c[d['severity']]??0x0)+0x1;return{'template_id':a['template_id'],'risk_level':a['risk_level'],'preflight_scan_passed':a['red_flags']['length']===0x0,'finding_count':a['findings']['length'],'findings_by_severity':c,'red_flags':a['red_flags'],'findings':a['findings'],'drift':b};}function assertScanPassed(a,b){const c=a['red_flags'];if(a['passed']||c['length']===0x0)return;throw new Error('action=\x27'+b+'\x27\x20blocked:\x20pre-deploy\x20scan\x20of\x20template\x20\x27'+a['template_id']+'\x27\x20found\x20CRITICAL\x20risk\x20—\x20'+c['join'](';\x20')+'.\x20Fix\x20the\x20template\x20(frontmatter\x20or\x20body)\x20and\x20re-run\x20action=\x27template_scan\x27.');}const GENERATE_HIGH_TOLERATED=new Set([]);function assertGenerateScanPassed(a,b){assertScanPassed(a,b);if(b!=='template_generate')return;const c=generateHighBlockers(a['template_id'],a['findings']);if(c['length']===0x0)return;throw new Error('action=\x27'+b+'\x27\x20blocked:\x20pre-deploy\x20scan\x20of\x20template\x20\x27'+a['template_id']+'\x27\x20found\x20'+c['length']+'\x20HIGH\x20finding(s)\x20—\x20'+c['map'](d=>(d['rule_id']??'HIGH')+':\x20'+d['title'])['join'](';\x20')+'.\x20Fix\x20the\x20template\x20(frontmatter\x20or\x20body)\x20and\x20re-run\x20action=\x27template_scan\x27.');}function generateHighBlockers(a,b){return b['filter'](c=>c['severity']==='high'&&!(c['rule_id']&&GENERATE_HIGH_TOLERATED['has'](a+'/'+c['rule_id'])));}export function buildVerdict(a,b,c,d){const e=[];!a['preflight_scan_passed']&&e['push']('scan:\x20'+(a['findings_by_severity']['critical']??0x0)+'\x20CRITICAL\x20finding(s)\x20(preflight\x20scan\x20failed)');if(c){const m=generateHighBlockers(a['template_id'],a['findings']??[]);m['length']>0x0&&e['push']('scan:\x20'+m['length']+'\x20HIGH\x20finding(s)\x20—\x20template_generate\x20would\x20refuse\x20(N-21):\x20'+m['map'](n=>((n['rule_id']??'HIGH')+':\x20'+(n['title']??''))['trim']())['join'](';\x20'));}const f=b['graph_validation'];if(f&&f['valid']===![]){const n=Array['isArray'](f['hard_violations'])?f['hard_violations']['length']:0x0,o=Array['isArray'](f['hard_violations'])?f['hard_violations']['map'](p=>p['id'])['join'](',\x20'):'';e['push']('graph_validation:\x20'+n+'\x20hard\x20violation(s)'+(o?'\x20('+o+')':''));}const g=b['audit'];if(g&&g['blocking']===!![]){const p=(g['findings']??[])['filter'](q=>q['level']==='critical'||q['level']==='high');e['push'](p['length']===0x0?'audit:\x20guide\x20audit\x20flagged\x20blocking\x20issue(s)\x20(plan.audit)':'audit:\x20'+p['length']+'\x20blocking\x20finding(s)\x20—\x20'+p['slice'](0x0,0x5)['map'](q=>((q['rule_id']??'?')+':\x20'+(q['title']??''))['trim']())['join'](';\x20')+(p['length']>0x5?'\x20(+'+(p['length']-0x5)+'\x20more\x20in\x20plan.audit.findings)':''));}const h=b['harness_check'],i=[...new Set((h?.['blocking_issues']??[])['filter'](q=>q['module']==='template')['flatMap'](q=>q['missing_constraints']??[]))];i['length']>0x0&&e['push']('compile:\x20'+i['length']+'\x20blocker(s)\x20—\x20merchant_guide\x20refuses\x20to\x20materialize\x20this\x20plan:\x20'+i['join'](',\x20'));const j=(Array['isArray'](b['pending_guard_designs'])?b['pending_guard_designs']:[])['filter'](q=>q!=null&&q['bound']===!![])['length'];j>0x0&&e['push']('pending_guard_designs:\x20'+j+'\x20unresolved\x20BOUND\x20guard\x20design(s)\x20—\x20the\x20guard\x20surface\x20is\x20not\x20final.\x20'+'Resolve\x20each\x20via\x20guard_resolutions\x20(kind\x20\x27inline\x27\x20with\x20the\x20Guard\x20table+root,\x20kind\x20\x27template\x27\x20with\x20a\x20tpl_*\x20id,\x20or\x20{kind:\x27omit\x27}\x20for\x20advisory\x20designs\x20that\x20do\x20not\x20apply\x20to\x20this\x20shop),\x20then\x20re-run.');const k=b['steps'];if(Array['isArray'](k)&&k['length']>0x0){const q=validatePlan(b);q['length']>0x0&&e['push']('executability:\x20'+q['length']+'\x20structural\x20issue(s)\x20—\x20the\x20plan\x20would\x20abort\x20mid-flight:\x20'+q['slice'](0x0,0x5)['map'](r=>''+r['code']+(r['step']?'@'+r['step']:''))['join'](',\x20')+(q['length']>0x5?'\x20(+'+(q['length']-0x5)+'\x20more)':''));}if(d&&!d['actionable'])return{'buildable':![],'blockers':['UNVERIFIED\x20(stale_build):\x20'+(d['stale']?'the\x20running\x20dist\x20lags\x20the\x20workspace\x20src\x20by\x20'+(d['lag_minutes']??'?')+'\x20minute(s)':'template\x20freshness\x20could\x20NOT\x20be\x20resolved\x20(dist-only\x20install\x20or\x20a\x20build\x20in\x20progress)')+'\x20—\x20every\x20conclusion\x20in\x20this\x20response\x20may\x20describe\x20superseded\x20template\x20knowledge.\x20'+'This\x20is\x20a\x20VERIFICATION\x20failure,\x20NOT\x20a\x20plan\x20defect;\x20the\x20plan\x27s\x20own\x20signal\x20faces\x20below\x20are\x20listed\x20unverified.\x20'+'Rebuild\x20the\x20MCP\x20dist\x20(pnpm\x20build\x20in\x20the\x20mcp\x20workspace),\x20restart\x20the\x20process,\x20and\x20re-run\x20for\x20a\x20verified\x20verdict.',...e],'status':'UNVERIFIED'};const l=e['length']===0x0;return{'buildable':l,'blockers':e,'status':l?'READY':'BLOCKED'};}async function templateScanDryRun(a,b){const c=[{'name':'scan-probe','price':'1000000000','quantity':0x1}],d=a['review_mode']==='review_reward'?{'review_mode':'review_reward','reward_funding':'20000000','reward_claim_amount':'1000000'}:undefined;try{const f=await runGuide(a,undefined,undefined,undefined,d,c),g=buildVerdict(scanSummary(scanTemplate(a)),f,!![],b);return{'status':g['status']==='UNVERIFIED'?'unverified':g['buildable']?'ready':'blocked','buildable':g['buildable'],'blockers':g['blockers'],'note':'Compile\x20dry-run\x20on\x20synthetic\x20probe\x20inputs\x20(single\x20probe\x20SKU,\x20benchmark\x20reward\x20funding),\x20mirrored\x20to\x20the\x20template_generate\x20gate\x20(CRITICAL\x20+\x20N-21\x20HIGH\x20+\x20graph\x20+\x20audit).\x20Structural\x20blockers\x20are\x20REAL\x20—\x20the\x20generate\x20face\x20refuses\x20for\x20the\x20same\x20reason.\x20Blockers\x20naming\x20caller\x20inputs\x20(fee_overrides\x20/\x20guard_resolutions\x20/\x20catalog)\x20may\x20clear\x20with\x20real\x20values.'};}catch(h){return{'status':'unavailable','note':'Compile\x20dry-run\x20could\x20not\x20run\x20on\x20synthetic\x20probe\x20inputs\x20('+(h instanceof Error?h['message']:String(h))+').\x20This\x20is\x20a\x20probe\x20limitation,\x20NOT\x20a\x20template\x20verdict\x20—\x20run\x20template_generate\x20for\x20the\x20authoritative\x20buildability.'};}}export function planNextAction(a,b,c,d){if(d&&!d['actionable'])return'DO\x20NOT\x20execute\x20this\x20plan\x20yet\x20—\x20'+(d['stale']?'the\x20running\x20dist\x20lags\x20the\x20workspace\x20src\x20by\x20'+(d['lag_minutes']??'?')+'\x20min':'template\x20freshness\x20could\x20NOT\x20be\x20verified')+'\x20(stale_build\x20above;\x20verdicts\x20unconfirmed).\x20Rebuild\x20the\x20MCP\x20dist\x20first\x20(pnpm\x20build\x20in\x20the\x20mcp\x20workspace),\x20restart\x20the\x20server,\x20then\x20re-run\x20'+b+'\x20—\x20the\x20plan\x20just\x20returned\x20was\x20compiled\x20from\x20code\x20that\x20may\x20not\x20be\x20what\x20is\x20running.';const e=a['next_action'],f=(Array['isArray'](a['pending_guard_designs'])?a['pending_guard_designs']:[])['filter'](g=>g!=null&&g['bound']===!![])['length'];if(c&&!c['buildable'])return(f>0x0?'Plan\x20BLOCKED\x20—\x20'+f+'\x20unresolved\x20guard\x20design(s)\x20in\x20plan.pending_guard_designs\x20(verdict).\x20Do\x20NOT\x20materialize,\x20':'Plan\x20BLOCKED\x20by\x20the\x20guide\x20audit\x20(see\x20plan.audit\x20/\x20plan.next_action).\x20Do\x20NOT\x20materialize,\x20')+'and\x20do\x20NOT\x20hand-build\x20the\x20objects\x20instead:\x20this\x20plan\x20is\x20the\x20wiring\x20authority\x20(Arbitration\x20+\x20'+'compensation-fund,\x20Contact/um,\x20allocator\x20rows)\x20and\x20hand-built\x20replicas\x20silently\x20drop\x20those\x20wirings.\x20'+(f>0x0?'Resolve\x20the\x20'+f+'\x20pending\x20guard\x20design(s)\x20in\x20plan.pending_guard_designs\x20via\x20guard_resolutions\x20(kind\x20\x27inline\x27\x20with\x20the\x20Guard\x20table+root,\x20kind\x20\x27template\x27\x20with\x20a\x20tpl_*\x20id,\x20or\x20{kind:\x27omit\x27}\x20for\x20advisory\x20designs\x20that\x20do\x20not\x20apply\x20to\x20this\x20shop),\x20':'Adjust\x20fee_overrides,\x20pick\x20another\x20template\x20variant,\x20or\x20fix\x20the\x20template,\x20')+('then\x20re-run\x20action=\x27'+b+'\x27.');if(typeof e==='string'&&e['startsWith']('Plan\x20ready.'))return e;if(c?.['buildable'])return'Plan\x20is\x20buildable\x20(verdict.buildable=true).\x20Materialize\x20the\x20objects\x20in\x20plan.steps\x20order'+(f>0x0?',\x20resolving\x20the\x20'+f+'\x20pending\x20guard\x20design(s)\x20in\x20plan.pending_guard_designs\x20via\x20guard_resolutions\x20before\x20the\x20Machine\x20publish':'')+'.';return'Plan\x20BLOCKED\x20by\x20the\x20guide\x20audit\x20(see\x20plan.audit\x20/\x20plan.next_action).\x20Do\x20NOT\x20materialize,\x20'+'and\x20do\x20NOT\x20hand-build\x20the\x20objects\x20instead:\x20this\x20plan\x20is\x20the\x20wiring\x20authority\x20(Arbitration\x20+\x20'+'compensation-fund,\x20Contact/um,\x20allocator\x20rows)\x20and\x20hand-built\x20replicas\x20silently\x20drop\x20those\x20wirings.\x20'+(f>0x0?'Resolve\x20the\x20'+f+'\x20pending\x20guard\x20design(s)\x20in\x20plan.pending_guard_designs\x20via\x20guard_resolutions\x20(kind\x20\x27inline\x27\x20with\x20the\x20Guard\x20table+root,\x20kind\x20\x27template\x27\x20with\x20a\x20tpl_*\x20id,\x20or\x20{kind:\x27omit\x27}\x20for\x20advisory\x20designs\x20that\x20do\x20not\x20apply\x20to\x20this\x20shop),\x20':'Adjust\x20fee_overrides,\x20pick\x20another\x20template\x20variant,\x20or\x20fix\x20the\x20template,\x20')+('then\x20re-run\x20action=\x27'+b+'\x27.');}function templateIntent(a,b){if(b&&b['trim']())return b['trim']();return'Adopt\x20the\x20'+a['id']+'\x20industry\x20archetype\x20template\x20('+a['archetype']+')\x20for\x20the\x20'+a['industry']+'\x20industry.\x20'+('Primary\x20risk\x20to\x20mitigate:\x20'+a['key_risk']+'.');}function effectiveFeeParams(a,b){return{...a['fee_params'],...b??{}};}const REWARD_POOL_PATTERNS=[/(?:reward|review|bonus|tip|prize)[\s-]*pools?\s*(?:of|is|at|:|=)?\s*([0-9][0-9_,]*(?:\.[0-9]+)?)/i,/([0-9][0-9_,]*(?:\.[0-9]+)?)\s*(?:reward|review|bonus|tip|prize)[\s-]*pools?\b/i];export function extractRewardPoolCandidate(a){if(!a)return undefined;for(const b of REWARD_POOL_PATTERNS){const c=b['exec'](a);if(!c)continue;const d=Number(c[0x1]['replaceAll'](/[,_]/g,''));if(Number['isFinite'](d)&&d>=0x0)return d;}return undefined;}function rewardPoolPrefill(a,b,c,d){if(a['fee_params']['review_reward_pool']===undefined)return undefined;if(c?.['review_reward_pool']!==undefined)return undefined;const e=d?claimNumber(d,'reward_pool_amount'):undefined;if(e!==undefined)return{'fee_key':'review_reward_pool','value':e,'claim_source':'semantic_ir'};const f=extractRewardPoolCandidate(b);return f===undefined?undefined:{'fee_key':'review_reward_pool','value':f};}const FUNDING_THRESHOLD_PATTERNS=[/(?:funding|campaign|round)[\s-]*(?:threshold|goal)s?\s*(?:of|is|at|:|=)?\s*([0-9][0-9_,]*(?:\.[0-9]+)?)/i,/([0-9][0-9_,]*(?:\.[0-9]+)?)\s*(?:funding|campaign|round)[\s-]*(?:threshold|goal)\b/i],MIN_ORDER_PATTERNS=[/(?:min(?:imum)?)\s+order(?:\s+(?:price|value|amount))?\s*(?:of|is|at|:|=)?\s*([0-9][0-9_,]*(?:\.[0-9]+)?)/i,/([0-9][0-9_,]*(?:\.[0-9]+)?)\s*(?:min(?:imum)?)\s+order\b/i];export function extractFundingThresholdCandidate(a){if(!a)return undefined;for(const b of FUNDING_THRESHOLD_PATTERNS){const c=b['exec'](a);if(!c)continue;const d=Number(c[0x1]['replaceAll'](/[,_]/g,''));if(Number['isFinite'](d)&&d>=0x0)return d;}return undefined;}export function extractMinOrderCandidate(a){if(!a)return undefined;for(const b of MIN_ORDER_PATTERNS){const c=b['exec'](a);if(!c)continue;const d=Number(c[0x1]['replaceAll'](/[,_]/g,''));if(Number['isFinite'](d)&&d>=0x0)return d;}return undefined;}function numericFeePrefill(a,b,c,d,e,f,g){if(a['fee_params'][b]===undefined)return undefined;if(f?.[b]!==undefined)return undefined;const h=g?claimNumber(g,c):undefined;if(h!==undefined)return{'fee_key':b,'value':h,'claim_source':'semantic_ir'};const i=d(e);return i===undefined?undefined:{'fee_key':b,'value':i};}function validateFeeParams(a,b){const c=[];let d=0x0;for(const [e,f]of Object['entries'](a)){if(typeof f!=='number'||!Number['isFinite'](f))continue;if(e['endsWith']('_bps')){(!Number['isInteger'](f)||f<0x0||f>0x2710)&&c['push'](e+'='+f+'\x20is\x20not\x20an\x20integer\x20rate\x20in\x20[0,\x2010000]\x20bps');if(e['endsWith']('_share_bps'))d+=Math['max'](0x0,f);}else{if(e['endsWith']('_days')){if(f<=0x0||f>0xe42)c['push'](e+'='+f+'\x20is\x20outside\x20the\x20sane\x20window\x20range\x20(0,\x203650]\x20days');}else{if(e['endsWith']('_hours')){if(f<=0x0||f>0x2238)c['push'](e+'='+f+'\x20is\x20outside\x20the\x20sane\x20window\x20range\x20(0,\x208760]\x20hours');}}}}if(d>0x2710)c['push']('*_share_bps\x20sum\x20'+d+'\x20exceeds\x2010000\x20(a\x20pool\x20splits\x20into\x20at\x20most\x20100%)');if(c['length']>0x0)throw new Error('invalid\x20fee\x20parameters\x20for\x20template\x20\x27'+b+'\x27:\x20'+c['join'](';\x20')+'.\x20'+'Correct\x20the\x20template\x27s\x20fee_params\x20or\x20pass\x20valid\x20\x27fee_overrides\x27.');}export{validateAllocatorRows};export function variantPaymentModel(a){if(a['payment_model'])return a['payment_model'];const b=a['allocator']['rows']??[];if(b['some'](d=>d['track']==='refund'))return'escrow';const c=a['machine_shape']['map'](d=>d['name'])['join']('\x20')['toLowerCase']();if(/\b(milestone|revision|revis|draft|deliverable)\b/['test'](c))return'milestone';if(/\b(charge|renew|subscription|cycle|billing|monthly)\b/['test'](c))return'subscription';return'escrow';}function variantRefundPolicy(a){const b=a['allocator']['description']['toLowerCase']();if(/full[ -]?refund|100% refund|refund .*100/['test'](b))return'full';if(/pro-?rata|prorated/['test'](b))return'milestone_prorated';if(/partial/['test'](b))return'partial';return undefined;}export function variantDeliverables(a,b){const c=a['machine_shape']['filter'](g=>g['semantic_role']==='final'),d=c[c['length']-0x1]??[...a['machine_shape']]['reverse']()['find'](g=>!/refund|cancel|dispute|terminat/i['test'](g['name']+'\x20'+g['role']))??a['machine_shape'][a['machine_shape']['length']-0x1],e=b?.['has_logistics']?'physical':b?.['pure_digital']?'digital':'service_session',f=(a['guards']??[])['filter'](h=>/repository_data_check|required_info_evidence_gate|allocator_order_anchor/['test'](h['template_id']));return[{'name':a['variant']+'\x20fulfillment','type':e,'acceptanceCriteria':'Order\x20reaches\x20the\x20terminal\x20workflow\x20node\x20\x27'+d['name']+'\x27\x20('+d['role']+')','proofOfDelivery':f['length']>0x0?'wip_hash':'manual_confirm'}];}function validateConditionalParams(a,b){for(const d of a['conditional_guards']??[]){const e=b[d['param']];if(e===undefined)continue;if(typeof e!=='string'||!d['values']['includes'](e))throw new Error('invalid\x20\x27'+d['param']+'='+String(e)+'\x27\x20for\x20template\x20\x27'+a['id']+'\x27:\x20must\x20be\x20one\x20of\x20'+d['values']['map'](f=>'\x27'+f+'\x27')['join']('\x20|\x20')+('\x20(the\x20guard\x20variant\x20mounts\x20at\x20\x27'+d['emit_value']+'\x27)'));}}async function runGuide(a,b,c,d,e,f,g){const h=effectiveFeeParams(a,c),i=rewardPoolPrefill(a,b,c,g);if(i)h[i['fee_key']]=i['value'];const j=numericFeePrefill(a,'funding_threshold','funding_threshold_amount',extractFundingThresholdCandidate,b,c,g);if(j)h[j['fee_key']]=j['value'];const k=numericFeePrefill(a,'min_order_price','min_order_price_amount',extractMinOrderCandidate,b,c,g);if(k)h[k['fee_key']]=k['value'];validateFeeParams(h,a['id']),validateConditionalParams(a,h);const l=landPlatformCommission(a,h);if(l['error']!==undefined)throw new Error(l['error']);const m=l['rows']?{...a,'allocator':{...a['allocator'],'rows':l['rows'],'count':l['rows']['filter'](z=>z['track']==='settlement')['length']}}:a,n=getIndustryModeRegistry()['getMode'](a['industry']),o=platformShareBps(h),q={'model':variantPaymentModel(a)},r=[],s=(m['allocator']['rows']?.['length']??0x0)>0x0;if(o!==undefined&&o>0x0&&!s&&a['allocator']['mode']==='rate'){const z=Math['round'](o)/0x64;r['push']({'recipient':'merchant','percentage':Math['round']((0x64-z)*0x64)/0x64}),r['push']({'recipient':'platform','percentage':z}),q['allocation']=r;}const u=variantRefundPolicy(a),v={'escrow':!![]};if(u)v['refundPolicy']=u;v['arbitration']=a['arbitration_mode']??v['arbitration']??inferArbitration(templateIntent(a,b));const w=await handleMerchantGuide({'intent':templateIntent(a,b),'guide_confirm':{'industry':a['industry'],'payment':q,'trust':v,'deliverables':variantDeliverables(a,n?.['traits']),...d&&Object['keys'](d)['length']>0x0?{'guard_resolutions':d}:{},...e?.['review_mode']?{'review_mode':e['review_mode']}:{},...e?.['reward_funding']!==undefined?{'reward_funding':e['reward_funding']}:{},...e?.['reward_claim_amount']!==undefined?{'reward_claim_amount':e['reward_claim_amount']}:{},...e?.['after_sales_mode']?{'after_sales_mode':e['after_sales_mode']}:{},...e?.['acceptance_mode']?{'acceptance_mode':e['acceptance_mode']}:{},...e?.['installment_mode']?{'installment_mode':e['installment_mode']}:{},...e?.['affiliate_mode']?{'affiliate_mode':e['affiliate_mode']}:{},...e?.['crowdfunding_mode']?{'crowdfunding_mode':e['crowdfunding_mode']}:{},...e?.['logistics_mode']?{'logistics_mode':e['logistics_mode']}:{},...f?.['length']?{'sales':f}:{}},'template_override':{...m,'fee_params':h},'name_base':a['id']});m['allocator']['rows']?.['length']&&(w['template_allocator_rows']=m['allocator']['rows']['map'](A=>({...A})));if(l['landing']!==undefined)w['commission_landing']=l['landing'];w['template']={'id':a['id'],'archetype':a['archetype'],'recommended_role':a['recommended_role'],'fee_params':h},w['catalog_version']=BUILTIN_TEMPLATES_VERSION;const x=templateCatalogDigest(a['id']);if(x!==undefined)w['template_digest']=x;if(w['plan']&&typeof w['plan']==='object'&&!Array['isArray'](w['plan'])){w['plan']['catalog_version']=BUILTIN_TEMPLATES_VERSION;if(x!==undefined)w['plan']['template_digest']=x;}{const A=[...collectLateMarks(w['plan']??{})]['sort']();A['length']>0x0&&(w['required_local_marks']=A,w['required_local_marks_note']='plan_execute\x20resolves\x20each\x20of\x20these\x20local\x20names\x20against\x20the\x20LocalMark\x20store\x20of\x20the\x20target\x20network\x20and\x20refuses\x20to\x20execute\x20while\x20any\x20is\x20unregistered.\x20'+'Register\x20them\x20BEFORE\x20executing\x20(local_mark_operation\x20add).\x20A\x20name\x20that\x20matches\x20an\x20object\x20this\x20plan\x20itself\x20creates\x20is\x20bound\x20to\x20that\x20object\x20automatically.\x20'+'A\x20recipient\x20mark\x20must\x20point\x20at\x20a\x20real\x20account\x20address:\x20an\x20empty\x20name\x20makes\x20the\x20SDK\x20substitute\x20the\x20deploying\x20account\x20(the\x20share\x20lands\x20in\x20whoever\x20runs\x20the\x20deploy),\x20and\x20an\x20object-id\x20/\x20zero-address\x20recipient\x20is\x20transferred\x20and\x20cannot\x20be\x20retrieved.\x20'+'A\x20Rate-0\x20Entity\x20leg\x20still\x20listed\x20in\x20template_allocator_rows\x20is\x20dropped\x20at\x20compile\x20time\x20and\x20needs\x20no\x20mark\x20(the\x20direct-sales\x20default\x20pays\x20nobody).');}w['template_fee_param_landings']=buildFeeParamLandingTable(m,h);if(c&&Object['keys'](c)['length']>0x0)w['template_fee_overrides']=c;const y=[];if(i)y['push'](i);if(j)y['push'](j);if(k)y['push'](k);if(y['length']>0x0){w['fee_overrides_prefills']=y;for(const B of y){const C=B['fee_key']==='review_reward_pool'?'Reward\x20pool':B['fee_key']==='funding_threshold'?'Funding\x20threshold':'Minimum\x20order',D=B['claim_source']==='semantic_ir'?'\x20(from\x20the\x20semantic\x20IR\x20claim)':'';w['next_action']=w['next_action']+'\x20'+C+'\x20prefilled\x20from\x20your\x20request:\x20'+B['value']+D+'\x20—\x20adjust\x20via\x20fee_overrides.';}}return w;}export async function handleBenchmarkMigrationOperation(a){const b=strictParse(BenchmarkMigrationSchema,a,'benchmark_migration_operation\x20input'),c=b['industry']?resolveIndustryName(b['industry'])??b['industry']['toLowerCase']():undefined,d=b['semantic_ir']?normalizeSemanticIR(b['semantic_ir'],{'source_text':b['description']}):undefined,e=d?{'semantic_ir_digest':d['digest'],...d['issues']['length']>0x0?{'semantic_ir_issues':d['issues']}:{}}:undefined;let f;switch(b['action']){case'template_list':{const {templates:g,errors:h}=listTemplates(),i=c?g['filter'](k=>k['industry']===c):g,j=new Map(builtinTemplateDrift()['map'](k=>[k['template'],k['state']]));f={'action':'template_list','count':i['length'],'templates':i['map'](k=>({...templateSummary(k),'disk_state':j['get'](k['id'])??(BUILTIN_TEMPLATES['some'](l=>l['id']===k['id'])?'current':'untracked')})),'discovery_vocabulary':{'industries':listIndustries()['map'](k=>k['name'])['sort'](),'tags':[...DISCOVERY_TAG_VOCABULARY],'product_refs':[...DISCOVERY_PRODUCT_REFS]},'load_errors':h};break;}case'template_get':{const k=requireTemplate(b['template_id'],'template_get');f={'action':'template_get','template':{...k,...templateGetAids(k)}};break;}case'template_generate':{const l=requireTemplate(b['template_id'],'template_generate'),m=b['review_mode']??l['review_mode']??'none',n=[];m==='review_reward'&&!b['reward_funding']&&n['push']('reward_funding\x20is\x20required:\x20template\x20\x27'+l['id']+'\x27\x20resolves\x20to\x20review_mode\x20\x27review_reward\x27\x20(input'+(b['review_mode']?'':'\x20via\x20template\x20declaration')+'),\x20which\x20promises\x20buyers\x20a\x20claimable\x20review\x20bounty\x20—\x20an\x20unfunded\x20pool\x20must\x20not\x20ship\x20(INV-4).\x20Pass\x20reward_funding\x20(smallest-unit\x20string;\x20expected\x20orders\x20x\x20per-order\x20reward\x20—\x20fee_param\x20review_reward_pool\x20is\x20the\x20planning\x20benchmark),\x20or\x20drop\x20the\x20mode\x20explicitly\x20(review_mode\x20\x27review\x27\x20keeps\x20the\x20review\x20rail\x20without\x20the\x20bounty;\x20\x27none\x27\x20removes\x20the\x20rail).');(!Array['isArray'](b['sales'])||b['sales']['length']===0x0)&&n['push']('sales\x20is\x20required:\x20a\x20plan\x20without\x20a\x20sellable\x20catalog\x20publishes\x20a\x20Service\x20frozen\x20with\x20sales:\x20[]\x20and\x20every\x20order_new\x20aborts\x20(PLAN-SALES-01,\x20upgraded\x20to\x20an\x20input\x20requirement,\x20amz9\x20A-2).\x20Pass\x20sales:\x20[{\x20name,\x20price,\x20quantity?,\x20wip_hash?\x20}]\x20—\x20one\x20entry\x20per\x20sellable\x20SKU,\x20price\x20in\x20smallest\x20units\x20(wip_hash\x20from\x20the\x20wip_file\x20tool\x20upload).');if(n['length']>0x0)return{'content':[{'type':'text','text':'template_generate\x20refused\x20—\x20no\x20plan\x20was\x20built.\x20'+n['length']+'\x20input\x20gap(s),\x20ALL\x20listed\x20at\x20once\x20(AR-4\x20T-05):\x20'+n['map']((t,u)=>'('+(u+0x1)+')\x20'+t)['join']('\x20')}],'structuredContent':{'result':{'type':'error','error':'template_generate\x20input\x20preflight\x20failed\x20with\x20'+n['length']+'\x20gap(s)\x20on\x20template\x20\x27'+l['id']+'\x27\x20—\x20all\x20gaps\x20reported\x20in\x20this\x20single\x20response\x20(do\x20not\x20fix\x20one\x20and\x20rediscover\x20the\x20next).','error_code':'input_preflight_failed','retryable':!![],'recovery_hint':n['join']('\x20|\x20'),'gaps':n},'message':'Refused:\x20input\x20preflight\x20failed.\x20Fix\x20ALL\x20listed\x20gaps,\x20then\x20re-send\x20ONCE.\x20See\x20recovery_hint.'}};const o=scanTemplate(l);assertGenerateScanPassed(o,'template_generate');const p=getTemplateParamFileLayer(l['id']),q=Object['keys'](p)['length']>0x0,r=q?{...p,...b['fee_overrides']??{}}:b['fee_overrides'],s=await runGuide(l,b['description'],r,b['guard_resolutions'],{'review_mode':b['review_mode'],'reward_funding':b['reward_funding'],'reward_claim_amount':b['reward_claim_amount'],'after_sales_mode':b['after_sales_mode'],'acceptance_mode':b['acceptance_mode'],'installment_mode':b['installment_mode'],'affiliate_mode':b['affiliate_mode'],'crowdfunding_mode':b['crowdfunding_mode']},b['sales'],d?.['ir']);f=((()=>{const t=scanSummary(o,driftFace(l['id'])),u=staleBuildFace(),v=buildVerdict(t,s,undefined,u),w=wipAnchorFace(b['sales']),x=planNextAction(s,'template_generate',v,u);return{'action':'template_generate','template_id':l['id'],...e,'stale_build':u,'scan':t,'plan':s,'verdict':v,...q?{'template_params_file':{'path':templateParamsFilePath(),'applied':p}}:{},...w?{'wip_anchor':w}:{},'next_action':x};})());break;}case'template_scan':{const t=requireTemplate(b['template_id'],'template_scan'),u=staleBuildFace(),v=await templateScanDryRun(t,u);f={'action':'template_scan','stale_build':u,'scan':{...withOnceSlotAdvisories(scanTemplate(t)),'drift':driftFace(t['id']),'compile_dry_run':v},...v['status']==='unavailable'?{}:{'buildable':v['buildable']===!![],'build_blockers':v['blockers']??[]},'next_action':v['status']==='blocked'?'compile_dry_run\x20BLOCKED\x20—\x20the\x20static\x20rule\x20scan\x20passed,\x20but\x20the\x20compile\x20kernel\x20refuses\x20this\x20template\x20(see\x20build_blockers;\x20the\x20same\x20verdict\x20template_generate\x20enforces).\x20Do\x20NOT\x20publish\x20from\x20this\x20scan:\x20run\x20template_generate\x20for\x20the\x20full\x20verdict,\x20or\x20fix\x20the\x20template\x20and\x20re-scan.':v['status']==='unverified'?'compile_dry_run\x20UNVERIFIED\x20—\x20the\x20running\x20dist\x20is\x20stale\x20against\x20the\x20workspace\x20src\x20(stale_build\x20above):\x20the\x20findings\x20and\x20verdict\x20may\x20describe\x20superseded\x20template\x20knowledge.\x20Do\x20NOT\x20act\x20on\x20ANY\x20conclusion\x20here.\x20Rebuild\x20the\x20MCP\x20dist\x20(pnpm\x20build\x20in\x20the\x20mcp\x20workspace),\x20restart\x20the\x20process,\x20and\x20re-scan.':v['status']==='ready'?'compile_dry_run\x20READY\x20on\x20probe\x20inputs\x20—\x20proceed\x20with\x20template_generate.':'compile_dry_run\x20unavailable\x20on\x20probe\x20inputs\x20—\x20run\x20template_generate\x20for\x20the\x20authoritative\x20buildability.'};break;}case'migration_import':{if(!b['description']||!b['description']['trim']())throw new Error('\x27description\x27\x20is\x20required\x20for\x20action=\x27migration_import\x27');const w=d?handleRecommendIndustry({'intent':b['description'],'semantic_ir':b['semantic_ir']}):undefined,x=planMigration({'url':b['url'],'description':b['description'],'industry':c,'ir_industry':c?undefined:w?.['recommendations'][0x0]?.['industry'],'ir_discovery':d?discoverySignal(d['ir']):undefined,'network':b['network']});if(!x)throw new Error('No\x20industry\x20template\x20matched\x20the\x20description.\x20Refine\x20the\x20description\x20or\x20pass\x20an\x20explicit\x20\x27industry\x27\x20hint'+(d?',\x20or\x20add\x20discovery\x20tags\x20/\x20a\x20product_ref\x20to\x20semantic_ir\x20(tags\x20vocabulary:\x20template_list.discovery_vocabulary).':'\x20(or\x20provide\x20semantic_ir\x20with\x20discovery\x20tags\x20/\x20traits\x20for\x20a\x20non-English\x20description).'));const y=getTemplate(x['source']['matched_template']),z=y?await templateScanDryRun(y,staleBuildFace()):undefined;f={'action':'migration_import','log':x,...z&&z['buildable']!==undefined?{'buildable':z['buildable']===!![],'build_blockers':z['blockers']??[],'compile_dry_run':{'status':z['status'],'note':z['note']}}:{},...w?{'inference_source':w['inference_source']}:{},...e,'next_action':'MigrationLog\x20ready.\x20Next:\x20call\x20action=\x27migration_review\x27\x20with\x20this\x20log\x20to\x20surface\x20the\x20mapped/unmapped/manual_review\x20items\x20for\x20user\x20confirmation.'+(z?.['status']==='unverified'?'\x20NOTE:\x20the\x20compile\x20dry-run\x20verdict\x20is\x20UNVERIFIED\x20—\x20the\x20running\x20dist\x20is\x20stale\x20against\x20the\x20workspace\x20src\x20(see\x20build_blockers):\x20do\x20NOT\x20act\x20on\x20buildability\x20until\x20rebuilt\x20(pnpm\x20build\x20in\x20the\x20mcp\x20workspace)\x20and\x20re-run.':z?.['status']==='blocked'?'\x20NOTE:\x20compile\x20dry-run\x20BLOCKED\x20on\x20probe\x20inputs\x20(see\x20build_blockers)\x20—\x20surface\x20the\x20blockers\x20at\x20review\x20BEFORE\x20migration_apply;\x20input-naming\x20blockers\x20may\x20clear\x20with\x20real\x20values.':'')};break;}case'plan_execute':{if(!b['plan']||typeof b['plan']!=='object'||Array['isArray'](b['plan']))throw new Error('\x27plan\x27\x20is\x20required\x20for\x20action=\x27plan_execute\x27\x20—\x20pass\x20the\x20object\x20returned\x20under\x20\x27plan\x27\x20by\x20template_generate\x20verbatim');const A=b['plan'],B=A['plan']!==undefined&&typeof A['plan']==='object'&&!Array['isArray'](A['plan'])&&Array['isArray'](A['plan']['steps'])?A['plan']:A;if(!Array['isArray'](B['steps']))throw new Error('action=\x27plan_execute\x27:\x20the\x20passed\x20plan\x20carries\x20no\x20steps[]\x20—\x20pass\x20the\x20template_generate\x20\x27plan\x27\x20object\x20verbatim');const C=typeof B['catalog_version']==='number'?B['catalog_version']:undefined,D=typeof B['templateId']==='string'?B['templateId']:undefined,E=typeof B['template_digest']==='string'?B['template_digest']:undefined,F=C===BUILTIN_TEMPLATES_VERSION,G=!F&&D!==undefined&&E!==undefined&&templateCatalogDigest(D)===E;if(C!==undefined&&!F&&!G)throw new Error('action=\x27plan_execute\x27:\x20STALE\x20PLAN\x20—\x20the\x20plan\x20was\x20generated\x20against\x20catalog\x20v'+C+',\x20'+('but\x20this\x20server\x20runs\x20catalog\x20v'+BUILTIN_TEMPLATES_VERSION+(G?'':'\x20and\x20its\x20template\x20content\x20does\x20not\x20match\x20this\x20catalog\x27s\x20template')+';\x20shapes,\x20guards\x20and\x20emissions\x20may\x20have\x20')+'changed\x20since.\x20Re-run\x20template_generate\x20(or\x20migration_apply)\x20to\x20regenerate\x20the\x20plan\x20against\x20the\x20'+'current\x20catalog,\x20then\x20execute\x20THAT\x20verbatim.\x20Nothing\x20was\x20executed.');const H=(B['steps']??[])['filter'](a8=>a8!==null&&typeof a8==='object'),I=H['map'](a8=>String(a8['id'])),J=new Set(H['filter'](a8=>a8['op']==='create')['map'](a8=>String(a8['id'])));let K=[...b['completed_steps']??[]];const L=b['resume_from_step'];if(L!==undefined){const a8=I['indexOf'](L);if(a8<0x0)throw new Error('action=\x27plan_execute\x27:\x20resume_from_step\x20\x27'+L+'\x27\x20is\x20not\x20a\x20step\x20of\x20THIS\x20plan\x20(steps:\x20'+I['join'](',\x20')+').\x20'+'Step\x20ids\x20are\x20plan-local:\x20resume\x20against\x20the\x20plan\x20returned\x20by\x20the\x20ORIGINAL\x20template_generate\x20(a\x20regenerated\x20plan\x20mints\x20new\x20ids).\x20Nothing\x20was\x20executed.');K=[...new Set([...K,...I['slice'](0x0,a8)])];}const M=K['filter'](a9=>!I['includes'](a9));if(M['length']>0x0)throw new Error('action=\x27plan_execute\x27:\x20completed_steps\x20name(s)\x20['+M['join'](',\x20')+']\x20are\x20not\x20steps\x20of\x20THIS\x20plan\x20—\x20the\x20resume\x20channel\x20'+'adopts\x20ONLY\x20steps\x20of\x20the\x20SAME\x20plan,\x20and\x20a\x20silently-ignored\x20unknown\x20id\x20would\x20re-execute\x20the\x20real\x20step\x20(ghost\x20duplicates).\x20'+'This\x20usually\x20means\x20the\x20plan\x20was\x20REGENERATED\x20(ids\x20changed):\x20pass\x20the\x20original\x20plan\x20with\x20ITS\x20resume\x20payload,\x20or\x20this\x20response\x27s\x20`resume`\x20object\x20verbatim.\x20Nothing\x20was\x20executed.');const N=b['previous_outputs']??{},O=K['filter'](a9=>J['has'](a9)&&N[a9]===undefined);if(O['length']>0x0)throw new Error('action=\x27plan_execute\x27:\x20adopted\x20create\x20step(s)\x20['+O['join'](',\x20')+']\x20have\x20NO\x20previous_outputs\x20entry\x20—\x20an\x20adopted\x20create\x20'+'without\x20its\x20created\x20address\x20cannot\x20resolve\x20$ref\x20bindings.\x20Pass\x20the\x20addresses\x20from\x20the\x20prior\x20run\x27s\x20outputs\x20field\x20(or\x20its\x20`resume`\x20payload).\x20Nothing\x20was\x20executed.');const P=K['length']>0x0||Object['keys'](N)['length']>0x0||L!==undefined?{'completedSteps':K,'outputs':N}:undefined,Q=((()=>{const a9=new Map();for(const ab of B['steps']??[]){const ac=ab['params'];ab['op']==='create'&&typeof ac?.['name']==='string'&&a9['set'](ac['name'],String(ab['id']));}const aa=ad=>{if(Array['isArray'](ad))return ad['map'](aa);if(ad&&typeof ad==='object'){const ae=ad,af=ae['$late'],ag=Object['keys'](ae);if(af?.['by']==='local_name'&&typeof af['mark']==='string'&&ag['length']===0x1&&a9['has'](af['mark']))return{'$ref':a9['get'](af['mark'])};return Object['fromEntries'](Object['entries'](ae)['map'](([ah,ai])=>[ah,aa(ai)]));}return ad;};return aa(B);})()),R=bindAuditPlan(Q);if(R['length']>0x0){const a9=bindRecoveryList(Q,b['previous_outputs']);throw new Error('action=\x27plan_execute\x27:\x20PLAN_BIND_AUDIT_FAILED\x20—\x20the\x20plan\x20binds\x20plan-created\x20objects\x20by\x20'+'global-namespace\x20NAME\x20instead\x20of\x20{\x22$ref\x22:\x20stepId}\x20(or\x20carries\x20an\x20undeclared\x20external\x20local_name).\x20'+'Executing\x20would\x20wire\x20THIS\x20store\x20to\x20ANOTHER\x20run\x27s\x20objects\x20—\x20Guards\x20are\x20create-frozen\x20and\x20Machines\x20'+'cannot\x20republish,\x20so\x20the\x20mis-binding\x20is\x20unrecoverable\x20after\x20the\x20fact\x20(ddmc4\x20B-13,\x20pdd\x20F-08).\x20'+'Nothing\x20was\x20executed.\x0a'+bindAuditReport(R,a9)+'\x0aRe-run\x20template_generate\x20against\x20the\x20current\x20catalog\x20(its\x20compile\x20emits\x20{\x22$ref\x22:\x20stepId}\x20for\x20'+'every\x20plan-internal\x20object),\x20then\x20execute\x20THAT\x20plan.');}const S=planLedgerKey(Q);let T;const U=lockedFreshStep(S,I,new Set(K));if(U!==undefined){const aa=b['retry_override'];if(aa!==undefined&&aa['step_id']===U['stepId']&&aa['note']['trim']()['length']>0x0)clearPlanStep(S,U['stepId']),T={'step_id':U['stepId'],'note':aa['note']};else throw new Error('action=\x27plan_execute\x27:\x20RETRY_LOCKED\x20—\x20step\x20\x27'+U['stepId']+'\x27\x20failed\x20with\x20the\x20IDENTICAL\x20error\x20in\x20'+U['count']+'\x20consecutive\x20'+('rounds\x20(\x22'+U['lastError']+'\x22).\x20A\x20further\x20unchanged\x20re-run\x20fails\x20identically\x20and\x20burns\x20gas,\x20so\x20this\x20server\x20refuses\x20it\x20(nothing\x20was\x20executed).\x20')+'Fix\x20the\x20cause\x20first\x20—\x20usual\x20roots:\x20a\x20template/input\x20defect\x20(re-run\x20template_generate\x20for\x20a\x20FRESH\x20plan:\x20new\x20ids,\x20new\x20ledger),\x20a\x20missing\x20registration\x20(do\x20it,\x20then\x20resume),\x20'+'or\x20verify\x20the\x20single\x20step\x20manually\x20via\x20onchain_operations\x20to\x20confirm\x20the\x20fix.\x20'+('If\x20one\x20more\x20round\x20IS\x20justified,\x20pass\x20retry_override\x20{step_id:\x20\x22'+U['stepId']+'\x22,\x20note:\x20\x22<why>\x22}.'));}const V=[...new Set([...collectLateMarks(Q),...collectAddressSlotBareNames(Q)])],W=b['env']?.['network'],X=new Map(),Y=[];for(const ab of V){const ac=await LocalMark['Instance']()['get_address'](ab,W)['catch'](()=>undefined);if(typeof ac==='string'&&ac['length']>0x0)X['set'](ab,ac);else Y['push'](ab);}if(Y['length']>0x0)throw new Error('action=\x27plan_execute\x27:\x20unresolved\x20LocalMark(s)\x20['+Y['join'](',\x20')+']\x20on\x20'+(W??'default')+'\x20network.\x20'+'This\x20plan\x20binds\x20an\x20object\x20by\x20local\x20name\x20(a\x20funding\x20recipient\x20slot,\x20an\x20external\x20object\x20reference,\x20or\x20an\x20Address-typed\x20guard\x20table\x20value).\x20Register\x20the\x20mark\x20first\x20—\x20'+('local_mark_operation\x20{add:{op:\x22add\x22,data:[{name:\x22'+Y[0x0]+'\x22,address:\x22<your\x20entity\x20address>\x22}]}}\x20—\x20then\x20re-run.\x20')+'Nothing\x20was\x20executed.');const Z=X['get']('platform');if(Z!==undefined){const ad=platformMarkRefusal(Z,W??'default');if(ad!==undefined)throw new Error(ad);}const a0=await materializePlan(Q,{'execute':handlerExecutor(b['env']),'envByAccount':b['accounts'],'timeoutMs':b['timeout_ms'],'resolveLate':ae=>{if(ae['by']==='address')return ae['address'];const af=X['get'](ae['mark']);if(af===undefined)throw new Error('unresolved\x20late\x20binding:\x20local_name\x20\x27'+ae['mark']+'\x27');return af;}},P),a1=a0['steps']['filter'](ae=>ae['status']==='blocked')['length'],a2=a0['steps']['find'](ae=>ae['status']==='failed'),a3=a0['steps']['some'](ae=>ae['status']==='blocked'&&typeof ae['error']==='string'&&ae['error']['startsWith']('preflight\x20failed:')),a4=a0['steps']['find'](ae=>ae['status']==='failed'&&typeof ae['digest']==='string'&&ae['digest']['length']>0x0),a5=a0['steps']['find'](ae=>ae['status']==='blocked'&&typeof ae['error']==='string'&&ae['error']['startsWith']('time\x20budget'));recordPlanRound(S,a0['steps']);const a6=repeatedPlanFailures(S);let a7=a0['completed']?'Deployed.\x20Verify\x20the\x20store\x20(query_toolkit:\x20service\x20/\x20machine\x20/\x20orders),\x20then\x20discharge\x20any\x20post-deploy\x20module\x20obligations\x20the\x20guide\x20listed\x20under\x20harness_check.module_gaps.':a3?'A\x20publish\x20step\x20was\x20BLOCKED\x20by\x20the\x20freeze\x20gate\x20—\x20the\x20store\x20is\x20NOT\x20live.\x20Fix\x20the\x20listed\x20preflight\x20checks\x20at\x20the\x20SOURCE\x20(re-run\x20template_generate);\x20never\x20patch\x20plan\x20steps\x20by\x20hand.':a4!==undefined?'Step\x20\x27'+a4['stepId']+'\x27\x20FAILED\x20with\x20digest\x20'+a4['digest']+'\x20—\x20the\x20transaction\x20MAY\x20have\x20committed\x20(transport\x20face).\x20VERIFY\x20FIRST:\x20onchain_transaction\x20with\x20that\x20digest.\x20If\x20committed:\x20ADOPT\x20it\x20—\x20add\x20\x27'+a4['stepId']+'\x27\x20to\x20completed_steps\x20(and\x20its\x20created\x20object\x20address\x20to\x20previous_outputs)\x20in\x20the\x20resume\x20call.\x20If\x20confirmed\x20absent:\x20re-send\x20with\x20this\x20response\x27s\x20resume\x20payload\x20(or\x20completed_steps/previous_outputs\x20from\x20it).\x20Never\x20blind-resume\x20a\x20digest-bearing\x20failure\x20(ghost\x20duplicates).':a0['budgetExhausted']?'Time\x20budget\x20('+String(b['timeout_ms'])+'ms)\x20reached\x20before\x20step\x20\x27'+(a5?.['stepId']??'?')+'\x27\x20—\x20the\x20run\x20stopped\x20cleanly\x20mid-plan\x20with\x20NO\x20unknown-state\x20step.\x20RESUME\x20(W5-08):\x20send\x20plan_execute\x20again\x20with\x20the\x20SAME\x20plan\x20and\x20this\x20response\x27s\x20resume\x20payload\x20VERBATIM\x20(completed_steps\x20+\x20previous_outputs),\x20or\x20resume_from_step\x20=\x20\x27'+(a5?.['stepId']??'<first\x20non-executed\x20stepId>')+'\x27\x20+\x20previous_outputs\x20('+a1+'\x20step(s)\x20remain;\x20raise\x20or\x20omit\x20timeout_ms\x20to\x20take\x20fewer\x20slices).':'Step\x20\x27'+(a2?.['stepId']??'?')+'\x27\x20FAILED:\x20'+(a2?.['error']??'unknown')+'.\x20RESUME\x20—\x20do\x20NOT\x20re-run\x20from\x20scratch\x20(duplicate\x20objects):\x20send\x20plan_execute\x20again\x20with\x20this\x20response\x27s\x20resume\x20payload\x20(completed_steps\x20+\x20previous_outputs),\x20or\x20resume_from_step\x20=\x20\x27'+(a2?.['stepId']??'?')+'\x27\x20+\x20previous_outputs.';if(a6['length']>0x0&&!a0['completed']){const ae='STOP\x20—\x20do\x20NOT\x20re-run\x20unchanged:\x20step\x20\x27'+a6[0x0]['step_id']+'\x27\x20failed\x20with\x20the\x20IDENTICAL\x20error\x20for\x20'+a6[0x0]['consecutive_rounds']+'\x20consecutive\x20round(s);\x20a\x20further\x20unchanged\x20re-run\x20is\x20REFUSED\x20pre-execution.\x20';a7=a4!==undefined||a3?a7+'\x20'+ae+'After\x20resolving\x20the\x20state\x20question\x20above,\x20fix\x20the\x20ROOT\x20CAUSE\x20before\x20resuming\x20(retry_override\x20{step_id,\x20note}\x20is\x20the\x20audited\x20exception).':ae+'The\x20generic\x20RESUME\x20recipe\x20is\x20withheld\x20on\x20purpose.\x20Fix\x20the\x20root\x20cause\x20first\x20—\x20re-run\x20template_generate\x20for\x20a\x20fresh\x20plan\x20(new\x20ids\x20bypass\x20the\x20lock),\x20complete\x20a\x20missing\x20registration,\x20or\x20verify\x20the\x20single\x20failing\x20step\x20via\x20onchain_operations\x20—\x20THEN\x20resume\x20with\x20the\x20resume\x20payload.\x20retry_override\x20{step_id,\x20note}\x20authorizes\x20one\x20audited\x20exception.';}f={'action':'plan_execute','completed':a0['completed'],'steps':a0['steps'],'outputs':a0['outputs'],'preflight':{'issues':a0['preflight']['issues'],'findings':a0['preflight']['findings']},'readback':a0['readback'],...X['size']>0x0?{'late_mark_bindings':Object['fromEntries'](X),'late_mark_note':'PAYEE\x20VERIFICATION\x20(last\x20repairable\x20moment):\x20each\x20entry\x20is\x20the\x20address\x20a\x20local-name\x20funding\x20recipient\x20resolved\x20to.\x20'+'Verify\x20every\x20address\x20belongs\x20to\x20THIS\x20store\x27s\x20owner/operator\x20accounts\x20(accounts\x20you\x20control)\x20before\x20any\x20service_publish\x20step\x20runs.\x20'+'A\x20wrong\x20address\x20here\x20becomes\x20an\x20UNFIXABLE\x20on-chain\x20allocator\x20after\x20publish\x20—\x20correct\x20the\x20local\x20mark\x20(local_mark_operation\x20add)\x20and\x20re-run\x20if\x20anything\x20is\x20off.'}:{},...a0['completed']?{}:{'resume':{'completed_steps':a0['steps']['filter'](af=>af['status']==='executed')['map'](af=>af['stepId']),'previous_outputs':a0['outputs']}},...a6['length']>0x0?{'repeated_failures':a6,'retry_prohibited':!![]}:{},...T!==undefined?{'retry_override_applied':T}:{},'next_action':a7};break;}case'migration_review':{if(!b['log'])throw new Error('\x27log\x27\x20is\x20required\x20for\x20action=\x27migration_review\x27');const af=b['log'],ag=Array['isArray'](af['mapped'])?af['mapped']:[],ah=Array['isArray'](af['unmapped'])?af['unmapped']:[],ai=Array['isArray'](af['manual_review'])?af['manual_review']:[],aj=af['risk_check']??{},ak=af['source']?.['matched_template']??'',al=af['template_match']??{},am=typeof al['source']==='string'?al['source']:'unknown',an=typeof al['confidence']==='number'?al['confidence']:0x0,ao=am==='unknown'||am==='industry_leader'||am==='ir_industry_fallback'||an<0.5,ap=ak?getTemplate(ak):undefined,aq=ap?await templateScanDryRun(ap,staleBuildFace()):undefined,ar=aq?.['buildable']===undefined?undefined:aq['buildable']===!![],as=aq?.['blockers']??[],at=aq?.['status']==='unverified'?'\x20NOTE:\x20the\x20compile\x20dry-run\x20verdict\x20is\x20UNVERIFIED\x20—\x20the\x20running\x20dist\x20is\x20stale\x20against\x20the\x20workspace\x20src\x20(see\x20review_summary.build_blockers):\x20rebuild\x20(pnpm\x20build\x20in\x20the\x20mcp\x20workspace),\x20restart,\x20and\x20re-run\x20before\x20acting.':ar===![]?'\x20NOTE:\x20compile\x20dry-run\x20ALSO\x20blocks\x20this\x20template\x20on\x20probe\x20inputs\x20(review_summary.build_blockers)\x20—\x20input-naming\x20blockers\x20may\x20clear\x20with\x20real\x20values.':'',au=ah['length']===0x0&&ai['length']===0x0&&aj['passed']===!![]&&!ao&&ar!==![];f={'action':'migration_review','log':af,'review_summary':{'mapped_count':ag['length'],'unmapped_count':ah['length'],'manual_review_count':ai['length'],'risk_passed':aj['passed']===!![],...aq?{...ar!==undefined?{'buildable':ar}:{},'build_blockers':as,'compile_dry_run':{'status':aq['status'],'note':aq['note']}}:{},'template_match':{'template_id':ak,'source':am,'confidence':an,'weak_match':ao}},'next_action':au?'Review\x20clean.\x20Proceed:\x20call\x20action=\x27migration_apply\x27\x20with\x20template_id=\x27'+ak+'\x27\x20to\x20produce\x20the\x20creation\x20plan\x20(network\x20defaults\x20to\x20testnet;\x20mainnet\x20requires\x20explicit\x20user\x20confirmation).'+(aq?.['status']==='unavailable'?'\x20Note:\x20the\x20compile\x20dry-run\x20could\x20not\x20run\x20on\x20probe\x20inputs\x20—\x20template_generate\x20remains\x20the\x20authoritative\x20buildability\x20check.':''):aq?.['status']==='unverified'&&!ao?'compile\x20dry-run\x20verdict\x20UNVERIFIED\x20—\x20the\x20running\x20dist\x20is\x20stale\x20against\x20the\x20workspace\x20src\x20(see\x20review_summary.build_blockers).\x20Do\x20NOT\x20act\x20on\x20buildability:\x20rebuild\x20(pnpm\x20build\x20in\x20the\x20mcp\x20workspace),\x20restart\x20the\x20process,\x20and\x20re-run\x20migration_plan\x20for\x20a\x20verified\x20verdict.':ar===![]&&!ao?'compile_dry_run\x20BLOCKED\x20on\x20probe\x20inputs\x20—\x20the\x20static\x20risk\x20check\x20passed,\x20but\x20the\x20compile\x20kernel\x20refuses\x20\x27'+ak+'\x27\x20(see\x20review_summary.build_blockers;\x20the\x20same\x20verdict\x20template_generate\x20enforces).\x20Surface\x20the\x20blockers\x20to\x20the\x20user\x20BEFORE\x20action=\x27migration_apply\x27\x20—\x20blockers\x20naming\x20caller\x20inputs\x20(sales\x20/\x20fee_overrides\x20/\x20guard_resolutions)\x20may\x20clear\x20with\x20real\x20values.':ao?'WEAK\x20TEMPLATE\x20MATCH:\x20\x27'+ak+'\x27\x20was\x20chosen\x20by\x20\x27'+am+'\x27\x20at\x20confidence\x20'+an+'\x20—\x20a\x20fallback,\x20not\x20evidence\x20(ssng\x20A-1:\x20a\x20Chinese\x20one-liner\x20silently\x20built\x20the\x20wrong\x20store\x20this\x20way).\x20Play\x20the\x20match\x20back\x20to\x20the\x20user\x20and\x20confirm\x20the\x20business\x20model.\x20To\x20get\x20an\x20EVIDENCE-based\x20match,\x20translate\x20through\x20the\x20caller\x20mechanism\x20(any\x20locale\x20works;\x20translation\x20happens\x20in\x20the\x20caller,\x20never\x20in\x20keyword\x20tables):\x20produce\x20a\x20semantic_ir\x20carrying\x20discovery.english_summary\x20(an\x20English\x20restatement\x20of\x20the\x20intent),\x20discovery.tags\x20(each\x20from\x20template_list.discovery_vocabulary)\x20and\x20discovery.product_ref\x20(a\x20benchmark-product\x20slug),\x20with\x20every\x20evidence\x20quote\x20verbatim\x20in\x20the\x20description\x20—\x20then\x20re-run\x20migration_plan.\x20Only\x20call\x20action=\x27migration_apply\x27\x20with\x20template_id=\x27'+ak+'\x27\x20after\x20the\x20user\x20approves\x20THAT\x20template.'+at:'Surface\x20the\x20'+ah['length']+'\x20unmapped\x20and\x20'+ai['length']+'\x20manual_review\x20items'+(aj['passed']===!![]?'':'\x20plus\x20the\x20risk_check\x20findings')+'\x20to\x20the\x20user\x20for\x20a\x20decision\x20before\x20action=\x27migration_apply\x27\x20(template_id=\x27'+ak+'\x27).'+at};break;}case'migration_apply':{const av=requireTemplate(b['template_id'],'migration_apply'),aw=scanTemplate(av);assertScanPassed(aw,'migration_apply');const ax=b['network']??'testnet',ay=await runGuide(av,b['description'],b['fee_overrides'],b['guard_resolutions'],{'review_mode':b['review_mode'],'reward_funding':b['reward_funding'],'reward_claim_amount':b['reward_claim_amount'],'after_sales_mode':b['after_sales_mode'],'acceptance_mode':b['acceptance_mode'],'installment_mode':b['installment_mode'],'affiliate_mode':b['affiliate_mode'],'crowdfunding_mode':b['crowdfunding_mode']},b['sales'],d?.['ir']);f=((()=>{const az=scanSummary(aw,driftFace(av['id'])),aA=staleBuildFace(),aB=buildVerdict(az,ay,undefined,aA),aC=wipAnchorFace(b['sales']);return{'action':'migration_apply','template_id':av['id'],'network':ax,...e,'scan':az,'plan':ay,'verdict':aB,...aC?{'wip_anchor':aC}:{},'next_action':planNextAction(ay,'migration_apply',aB,aA)};})());break;}default:throw new Error('Unknown\x20benchmark_migration_operation\x20action:\x20'+String(b['action']));}return{'content':[{'type':'text','text':JSON['stringify']({'result':f})}],'structuredContent':{'result':f}};}
1
+ import{strictParse}from'../../schema/index.js';import{BenchmarkMigrationSchema}from'../../schema/benchmark-migration/index.js';import{getTemplate,getTemplateLoadError,listTemplates,validateAllocatorRows,platformShareBps,builtinTemplateDrift,templateCatalogDigest}from'../../knowledge/template-loader.js';import{BUILTIN_TEMPLATES,auditTemplateOnceSlotArms,auditTemplateNodeOperatorOverwrite,auditTemplateReturnNoExit,BUILTIN_TEMPLATES_VERSION,DISCOVERY_PRODUCT_REFS,DISCOVERY_TAG_VOCABULARY,discoveryTagsForTemplate}from'../../knowledge/builtin-templates.js';import{landPlatformCommission}from'../../knowledge/commission-landing.js';import{getTemplateParamFileLayer,templateParamsFilePath}from'../../config/template-params.js';import{scanTemplate,buildFeeParamLandingTable}from'../../knowledge/template-scanner.js';import{planMigration}from'../../playbooks/service-build/migration-planner.js';import{handleMerchantGuide}from'../../playbooks/service-build/merchant-guide.js';import{inferArbitration}from'../../playbooks/service-build/intent-analyzer.js';import{getIndustryModeRegistry}from'../../extensions/index.js';import{listIndustries,resolveIndustryName}from'../../knowledge/industry-registry.js';import{claimNumber,discoverySignal,normalizeSemanticIR}from'../../knowledge/semantic-ir.js';import{handleRecommendIndustry}from'../../playbooks/service-build/mode-actions.js';import{bindAuditPlan,bindAuditReport,bindRecoveryList,handlerExecutor,materializePlan}from'../../composition/materialize.js';import{clearPlanStep,lockedFreshStep,planLedgerKey,recordPlanRound,repeatedPlanFailures}from'../../composition/plan-retry-ledger.js';import{collectLateMarks,collectAddressSlotBareNames,validatePlan}from'../../composition/plan.js';import{LocalMark}from'@wowok/wowok';import{join,dirname,resolve}from'node:path';import{readFileSync}from'node:fs';import{fileURLToPath}from'node:url';import{computeSrcDistStaleness}from'../upgrade-check.js';const __dirname=dirname(fileURLToPath(import.meta.url));export function platformMarkRefusal(a,b){const c=a['toLowerCase']()['replace'](/^0x/,'');if(/^0x[0-9a-fA-F]{1,64}$/['test'](a)&&!/^0+$/['test'](c))return undefined;return'action=\x27plan_execute\x27:\x20the\x20LocalMark\x20\x27platform\x27\x20resolves\x20to\x20\x27'+a+'\x27\x20on\x20'+b+'\x20network\x20—\x20not\x20a\x20usable\x20account\x20address.\x20'+'This\x20plan\x20names\x20\x27platform\x27\x20as\x20a\x20settlement\x20recipient\x20and\x20order_allocators\x20freezes\x20at\x20Service\x20publish,\x20so\x20a\x20wrong\x20payee\x20can\x20only\x20be\x20fixed\x20by\x20re-publishing\x20the\x20Service.\x20'+'An\x20empty\x20name\x20makes\x20the\x20SDK\x20substitute\x20the\x20deploying\x20account\x20(the\x20share\x20lands\x20in\x20whoever\x20runs\x20the\x20deploy);\x20an\x20object-id\x20/\x20zero-address\x20recipient\x20is\x20transferred\x20and\x20cannot\x20be\x20retrieved.\x20'+'Re-point\x20the\x20mark\x20at\x20a\x20real\x20account\x20address\x20—\x20local_mark_operation\x20{add:{op:\x22add\x22,data:[{name:\x22platform\x22,address:\x220x...\x22}]}}\x20—\x20then\x20re-run.\x20Nothing\x20was\x20executed.';}export function staleBuildFace(a=join(__dirname,'..','..','..','src'),b=join(__dirname,'..','..','..','dist')){let c=null;try{c=computeSrcDistStaleness(a,b,{'srcExt':'.ts','distExt':'.js'});}catch{c=null;}if(!c)return{'stale':![],'known':![],'actionable':![],'lag_minutes':null,'detail':'Stale-build\x20state\x20UNKNOWN\x20—\x20the\x20source\x20and\x20build-output\x20trees\x20were\x20not\x20both\x20resolvable\x20(installed\x20dist-only\x20'+'package\x20or\x20a\x20build\x20in\x20progress),\x20so\x20template\x20freshness\x20could\x20not\x20be\x20verified.\x20NOT\x20actionable:\x20treat\x20the\x20'+'scan/plan\x20verdicts\x20as\x20unconfirmed\x20—\x20do\x20not\x20act\x20on\x20them\x20until\x20a\x20rebuild\x20resolves\x20freshness.'};if(!c['stale'])return{'stale':![],'known':!![],'actionable':!![],'lag_minutes':c['lag_minutes'],'detail':'dist\x20is\x20current\x20with\x20src\x20(newest\x20compiled\x20.js\x20vs\x20newest\x20source\x20.ts\x20mtime\x20lag\x20'+c['lag_minutes']+'\x20'+'minute(s))\x20—\x20the\x20scan/plan\x20verdicts\x20reflect\x20this\x20workspace\x20checkout.'};return{'stale':!![],'known':!![],'actionable':![],'lag_minutes':c['lag_minutes'],'detail':'NOT\x20ACTIONABLE\x20—\x20do\x20not\x20act\x20on\x20the\x20verdicts\x20in\x20this\x20response.\x20dist\x20is\x20'+c['lag_minutes']+'\x20minute(s)\x20OLDER\x20'+'than\x20src\x20(newest\x20compiled\x20.js\x20vs\x20newest\x20source\x20.ts\x20mtime),\x20so\x20every\x20scan/plan\x20conclusion\x20above\x20may\x20'+'describe\x20superseded\x20template\x20knowledge\x20(live\x20rq-tn-261030-8693be:\x20a\x20508-minute-stale\x20dist\x20produced\x20two\x20'+'false\x20defect\x20reports,\x20F-RQ-09/14).\x20Rebuild\x20(pnpm\x20build),\x20restart\x20the\x20MCP\x20process,\x20and\x20re-run\x20before\x20'+'acting\x20on\x20ANY\x20conclusion\x20here.'};}function templateSummary(a){return{'id':a['id'],'industry':a['industry'],'variant':a['variant'],'product_ref':a['product_ref'],'archetype':a['archetype'],'key_risk':a['key_risk'],'node_count':a['machine_shape']['length'],'guard_count':a['guards']['length'],'recommended_role':a['recommended_role'],'tags':discoveryTagsForTemplate(a['id'])};}function templateGetAids(a){const b=a['machine_shape']['find'](g=>g['name']==='reviewed'),c=b!==undefined&&a['review_mode']!=='none'&&b['operator']!=='merchant',d=a['allocator']['rows']??[],e=[...new Set(d['map'](g=>g['guard_key'])['filter'](g=>typeof g==='string'&&g!==''))],f=d['length']>0x0?'\x20On-chain\x20this\x20materialises\x20as\x20~'+e['length']+'\x20Allocator\x20OBJECT(S)\x20(one\x20per\x20distinct\x20guard_key:\x20'+e['join'](',\x20')+')\x20across\x20'+d['length']+'\x20row(s)\x20—\x20model\x20capacity/monitoring\x20on\x20the\x20object\x20count,\x20never\x20on\x20allocator.count.':'\x20rows[]\x20is\x20empty\x20—\x20no\x20allocator\x20legs\x20are\x20declared.';return{'claim_anchor':c?'review_node+final':b!==undefined?'no_buyer_review_rail':'final_only','claim_anchor_note':c?'machine_shape\x20mounts\x20a\x20\x27reviewed\x27\x20node\x20—\x20the\x20buyer\x27s\x20structured\x20review\x20rides\x20that\x20node\x20alongside\x20the\x20final\x20settlement.':b!==undefined?'a\x20\x27reviewed\x27\x20node\x20exists\x20but\x20is\x20NOT\x20a\x20buyer\x20review\x20rail\x20(review_mode\x20\x27none\x27,\x20or\x20the\x20marker\x20is\x20merchant/triager-operated)\x20—\x20no\x20buyer-structured\x20review\x20is\x20mounted;\x20the\x20buyer\x27s\x20voice\x20rides\x20the\x20claim/arbitration\x20rail\x20only.':'no\x20\x27reviewed\x27\x20node\x20—\x20sanctioned\x20variant:\x20the\x20buyer\x27s\x20voice\x20rides\x20the\x20claim/arbitration\x20rail\x20only\x20(no\x20separate\x20review\x20stop).','allocator_count_note':'allocator.count\x20=\x20'+a['allocator']['count']+'\x20counts\x20SETTLEMENT-track\x20legs\x20only;\x20refund-track\x20legs\x20(rows[]\x20with\x20track:\x22refund\x22)\x20are\x20additional\x20and\x20NOT\x20included\x20in\x20this\x20count.\x20rows[]\x20carries\x20the\x20complete\x20executable\x20split\x20plan.'+f,'onchain_field_notes':['passport.impack\x20—\x20the\x20on-chain\x20field\x20is\x20spelled\x20`impack`\x20(the\x20on-chain\x20passport\x20contract\x27s\x20own\x20field\x20name,\x20packed\x20business\x20objects\x20in\x20the\x20passport\x20verification\x20context).\x20It\x20is\x20the\x20contract\x27s\x20own\x20field\x20name,\x20not\x20a\x20typo;\x20echo\x20it\x20verbatim.']};}function requireTemplate(a,b){if(!a)throw new Error('\x27template_id\x27\x20is\x20required\x20for\x20action=\x27'+b+'\x27');const c=getTemplate(a);if(!c){const d=getTemplateLoadError(a);if(d)throw new Error('Template\x20\x27'+a+'\x27\x20is\x20BLOCKED\x20for\x20action=\x27'+b+'\x27:\x20its\x20machine\x20file\x20failed\x20to\x20load/validate\x20and\x20is\x20invisible\x20to\x20every\x20action\x20until\x20fixed\x20(T-18\x20—\x20see\x20action=\x27template_list\x27\x20load_errors).\x20Loader:\x20'+d);throw new Error('Unknown\x20template\x20id:\x20'+a+'\x20(use\x20action=\x27template_list\x27\x20to\x20see\x20valid\x20ids)');}return c;}export function wipAnchorFace(a){if(!Array['isArray'](a)||a['length']===0x0)return undefined;const b=a['filter'](c=>c&&typeof c==='object'&&typeof c['name']==='string'&&String(c['wip_hash']??'')==='')['map'](c=>c['name']);if(b['length']===0x0)return undefined;return{'status':'unpinned','rule_id':'R-WIP-UNPINNED','severity':'high','unpinned_skus':b,'remediation':'These\x20SKU(s)\x20publish\x20with\x20NO\x20wip\x20pin\x20—\x20buyers\x20get\x20no\x20delivery-integrity\x20guarantee\x20(the\x20merchant\x20can\x20swap\x20the\x20.wip\x20file\x20later\x20undetected).\x20'+'After\x20publish,\x20rebind\x20via\x20the\x20per-item\x20sales\x20op\x20wip_set\x20(MCP\x20composite:\x20touches\x20only\x20wip/wip_hash)\x20or\x20a\x20full\x20op:set\x20rewrite\x20—\x20live-tested\x200.00272\x20gas.\x20'+'Prefer\x20passing\x20wip_hash\x20from\x20the\x20wip_file\x20tool\x20upload\x20at\x20build\x20time\x20instead.'};}export function returnNoExitFace(a){try{const b=BUILTIN_TEMPLATES['find'](d=>d['id']===a);if(!b)return undefined;const c=auditTemplateReturnNoExit([b])[0x0];return c?{'status':'return_no_exit','rule_id':c['rule_id'],'severity':c['severity'],'stranded_nodes':c['stranded_nodes'],'remediation':c['remediation']}:undefined;}catch{return undefined;}}function driftFace(a){const b=builtinTemplateDrift()['find'](c=>c['template']===a);if(!b){const c=BUILTIN_TEMPLATES['some'](d=>d['id']===a);return c?{'template':a,'state':'current','catalog_version':BUILTIN_TEMPLATES_VERSION,'blocked':![],'repairable':![],'detail':'disk\x20body\x20matches\x20the\x20shipped\x20catalog\x20(hash-verified\x20sentinel)'}:{'template':a,'state':'untracked','catalog_version':undefined,'blocked':![],'repairable':![],'detail':'user-authored\x20template\x20—\x20no\x20builtin\x20catalog\x20binding\x20to\x20compare\x20against'};}return{'template':b['template'],'state':b['state'],'catalog_version':BUILTIN_TEMPLATES_VERSION,'blocked':!![],'repairable':b['repairable'],'detail':b['detail']};}function withOnceSlotAdvisories(a){try{const b=auditTemplateOnceSlotArms()['find'](e=>e['template_id']===a['template_id']),c=auditTemplateNodeOperatorOverwrite()['filter'](e=>e['template_id']===a['template_id']);if(!b&&c['length']===0x0)return a;const d=c['map'](e=>({'rule_id':'NODE_OPERATOR_OVERWRITTEN','severity':'medium','title':'Edge\x20operator\x20inherited\x20past\x20an\x20explicit\x20source-node\x20operator','detail':e['message'],'suggestion':'Declare\x20edge.operator\x20explicitly\x20on\x20this\x20forward\x20(or\x20add\x20a\x20buyer-favour\x20timeout\x20exit\x20from\x20the\x20request\x20node).\x20The\x20kernel\x20inheritance\x20chain\x20(edge\x20??\x20dest-node\x20??\x20default)\x20never\x20consults\x20the\x20SOURCE\x20node,\x20so\x20an\x20un-annotated\x20edge\x20out\x20of\x20an\x20order_payer\x20request\x20node\x20silently\x20ships\x20as\x20a\x20merchant\x20permission\x20rail\x20(F-40/F-42:\x20the\x20buyer\x20parked\x20on\x20the\x20request\x20node\x20has\x20zero\x20executable\x20forwards\x20and\x20the\x20merchant\x20rewrite\x20ships\x20unguarded).\x20Re-run\x20action=\x27template_scan\x27\x20after\x20the\x20fix.'}));return{...a,'findings':[...a['findings'],...b?[{'rule_id':'R-ONCE-SLOT-ARM-254','severity':'medium','title':'Once-slot\x20arming\x20on\x20a\x20periodic\x20rail\x20('+b['kind']+')','detail':b['message'],'suggestion':'Arm\x20the\x20re-enterable\x20settlement/renewal\x20guard\x20with\x20identifier\x20255\x20plus\x20a\x20per-period\x20key\x20(period-<N>\x20from\x20chain\x20state,\x20e.g.\x20progress\x20history\x20count)\x20and\x20have\x20the\x20trigger\x20Passport\x20submit\x20the\x20same\x20value;\x20keep\x20254\x20for\x20one-shot-per-order\x20rails\x20only.\x20Re-run\x20action=\x27template_scan\x27\x20after\x20the\x20fix.'}]:[],...d]};}catch{return a;}}export function planEnvelopeFromInput(a){if(!a||typeof a!=='object'||Array['isArray'](a))throw new Error('\x27plan\x27\x20is\x20required\x20for\x20action=\x27plan_execute\x27\x20—\x20pass\x20the\x20object\x20returned\x20under\x20\x27plan\x27\x20by\x20template_generate\x20verbatim,\x20or\x20{root:\x27file\x27,\x20path}\x20to\x20read\x20it\x20from\x20disk');let b=a;if(b['root']==='file'){const c=typeof b['path']==='string'?b['path']:'';if(!c)throw new Error('action=\x27plan_execute\x27:\x20plan\x20{root:\x27file\x27}\x20requires\x20a\x20\x27path\x27\x20field\x20pointing\x20at\x20the\x20saved\x20plan\x20JSON');let d;try{d=readFileSync(resolve(c),'utf-8');}catch(g){throw new Error('action=\x27plan_execute\x27:\x20failed\x20to\x20read\x20plan\x20file\x20\x27'+c+'\x27:\x20'+g['message']);}let f;try{f=JSON['parse'](d);}catch(h){throw new Error('action=\x27plan_execute\x27:\x20plan\x20file\x20\x27'+c+'\x27\x20is\x20not\x20valid\x20JSON:\x20'+h['message']);}if(!f||typeof f!=='object'||Array['isArray'](f))throw new Error('action=\x27plan_execute\x27:\x20plan\x20file\x20\x27'+c+'\x27\x20must\x20contain\x20a\x20JSON\x20object\x20—\x20the\x20template_generate\x20plan\x20envelope\x20({plan:{steps,...}})\x20or\x20the\x20bare\x20plan\x20({steps,...})');b=f;}return b;}export function templateAdvisoryFaces(a){try{if(!a)return{};const b=getTemplate(a);if(!b)return{};const c=scanSummary(withOnceSlotAdvisories(scanTemplate(b)),driftFace(a)),d=returnNoExitFace(a);return d?{'scan':c,'return_no_exit':d}:{'scan':c};}catch{return{};}}function scanSummary(a,b){a=withOnceSlotAdvisories(a);const c={};for(const d of a['findings'])c[d['severity']]=(c[d['severity']]??0x0)+0x1;return{'template_id':a['template_id'],'risk_level':a['risk_level'],'preflight_scan_passed':a['red_flags']['length']===0x0,'finding_count':a['findings']['length'],'findings_by_severity':c,'red_flags':a['red_flags'],'findings':a['findings'],'drift':b};}function assertScanPassed(a,b){const c=a['red_flags'];if(a['passed']||c['length']===0x0)return;throw new Error('action=\x27'+b+'\x27\x20blocked:\x20pre-deploy\x20scan\x20of\x20template\x20\x27'+a['template_id']+'\x27\x20found\x20CRITICAL\x20risk\x20—\x20'+c['join'](';\x20')+'.\x20Fix\x20the\x20template\x20(frontmatter\x20or\x20body)\x20and\x20re-run\x20action=\x27template_scan\x27.');}const GENERATE_HIGH_TOLERATED=new Set([]);function assertGenerateScanPassed(a,b){assertScanPassed(a,b);if(b!=='template_generate')return;const c=generateHighBlockers(a['template_id'],a['findings']);if(c['length']===0x0)return;throw new Error('action=\x27'+b+'\x27\x20blocked:\x20pre-deploy\x20scan\x20of\x20template\x20\x27'+a['template_id']+'\x27\x20found\x20'+c['length']+'\x20HIGH\x20finding(s)\x20—\x20'+c['map'](d=>(d['rule_id']??'HIGH')+':\x20'+d['title'])['join'](';\x20')+'.\x20Fix\x20the\x20template\x20(frontmatter\x20or\x20body)\x20and\x20re-run\x20action=\x27template_scan\x27.');}function generateHighBlockers(a,b){return b['filter'](c=>c['severity']==='high'&&!(c['rule_id']&&GENERATE_HIGH_TOLERATED['has'](a+'/'+c['rule_id'])));}export function buildVerdict(a,b,c,d){const e=[];!a['preflight_scan_passed']&&e['push']('scan:\x20'+(a['findings_by_severity']['critical']??0x0)+'\x20CRITICAL\x20finding(s)\x20(preflight\x20scan\x20failed)');if(c){const m=generateHighBlockers(a['template_id'],a['findings']??[]);m['length']>0x0&&e['push']('scan:\x20'+m['length']+'\x20HIGH\x20finding(s)\x20—\x20template_generate\x20would\x20refuse\x20(N-21):\x20'+m['map'](n=>((n['rule_id']??'HIGH')+':\x20'+(n['title']??''))['trim']())['join'](';\x20'));}const f=b['graph_validation'];if(f&&f['valid']===![]){const n=Array['isArray'](f['hard_violations'])?f['hard_violations']['length']:0x0,o=Array['isArray'](f['hard_violations'])?f['hard_violations']['map'](p=>p['id'])['join'](',\x20'):'';e['push']('graph_validation:\x20'+n+'\x20hard\x20violation(s)'+(o?'\x20('+o+')':''));}const g=b['audit'];if(g&&g['blocking']===!![]){const p=(g['findings']??[])['filter'](q=>q['level']==='critical'||q['level']==='high');e['push'](p['length']===0x0?'audit:\x20guide\x20audit\x20flagged\x20blocking\x20issue(s)\x20(plan.audit)':'audit:\x20'+p['length']+'\x20blocking\x20finding(s)\x20—\x20'+p['slice'](0x0,0x5)['map'](q=>((q['rule_id']??'?')+':\x20'+(q['title']??''))['trim']())['join'](';\x20')+(p['length']>0x5?'\x20(+'+(p['length']-0x5)+'\x20more\x20in\x20plan.audit.findings)':''));}const h=b['harness_check'],i=[...new Set((h?.['blocking_issues']??[])['filter'](q=>q['module']==='template')['flatMap'](q=>q['missing_constraints']??[]))];i['length']>0x0&&e['push']('compile:\x20'+i['length']+'\x20blocker(s)\x20—\x20merchant_guide\x20refuses\x20to\x20materialize\x20this\x20plan:\x20'+i['join'](',\x20'));const j=(Array['isArray'](b['pending_guard_designs'])?b['pending_guard_designs']:[])['filter'](q=>q!=null&&q['bound']===!![])['length'];j>0x0&&e['push']('pending_guard_designs:\x20'+j+'\x20unresolved\x20BOUND\x20guard\x20design(s)\x20—\x20the\x20guard\x20surface\x20is\x20not\x20final.\x20'+'Resolve\x20each\x20via\x20guard_resolutions\x20(kind\x20\x27inline\x27\x20with\x20the\x20Guard\x20table+root,\x20kind\x20\x27template\x27\x20with\x20a\x20tpl_*\x20id,\x20or\x20{kind:\x27omit\x27}\x20for\x20advisory\x20designs\x20that\x20do\x20not\x20apply\x20to\x20this\x20shop),\x20then\x20re-run.');const k=b['steps'];if(Array['isArray'](k)&&k['length']>0x0){const q=validatePlan(b);q['length']>0x0&&e['push']('executability:\x20'+q['length']+'\x20structural\x20issue(s)\x20—\x20the\x20plan\x20would\x20abort\x20mid-flight:\x20'+q['slice'](0x0,0x5)['map'](r=>''+r['code']+(r['step']?'@'+r['step']:''))['join'](',\x20')+(q['length']>0x5?'\x20(+'+(q['length']-0x5)+'\x20more)':''));}if(d&&!d['actionable'])return{'buildable':![],'blockers':['UNVERIFIED\x20(stale_build):\x20'+(d['stale']?'the\x20running\x20dist\x20lags\x20the\x20workspace\x20src\x20by\x20'+(d['lag_minutes']??'?')+'\x20minute(s)':'template\x20freshness\x20could\x20NOT\x20be\x20resolved\x20(dist-only\x20install\x20or\x20a\x20build\x20in\x20progress)')+'\x20—\x20every\x20conclusion\x20in\x20this\x20response\x20may\x20describe\x20superseded\x20template\x20knowledge.\x20'+'This\x20is\x20a\x20VERIFICATION\x20failure,\x20NOT\x20a\x20plan\x20defect;\x20the\x20plan\x27s\x20own\x20signal\x20faces\x20below\x20are\x20listed\x20unverified.\x20'+'Rebuild\x20the\x20MCP\x20dist\x20(pnpm\x20build\x20in\x20the\x20mcp\x20workspace),\x20restart\x20the\x20process,\x20and\x20re-run\x20for\x20a\x20verified\x20verdict.',...e],'status':'UNVERIFIED'};const l=e['length']===0x0;return{'buildable':l,'blockers':e,'status':l?'READY':'BLOCKED'};}async function templateScanDryRun(a,b){const c=[{'name':'scan-probe','price':'1000000000','quantity':0x1}],d=a['review_mode']==='review_reward'?{'review_mode':'review_reward','reward_funding':'20000000','reward_claim_amount':'1000000'}:undefined;try{const f=await runGuide(a,undefined,undefined,undefined,d,c),g=buildVerdict(scanSummary(scanTemplate(a)),f,!![],b);return{'status':g['status']==='UNVERIFIED'?'unverified':g['buildable']?'ready':'blocked','buildable':g['buildable'],'blockers':g['blockers'],'note':'Compile\x20dry-run\x20on\x20synthetic\x20probe\x20inputs\x20(single\x20probe\x20SKU,\x20benchmark\x20reward\x20funding),\x20mirrored\x20to\x20the\x20template_generate\x20gate\x20(CRITICAL\x20+\x20N-21\x20HIGH\x20+\x20graph\x20+\x20audit).\x20Structural\x20blockers\x20are\x20REAL\x20—\x20the\x20generate\x20face\x20refuses\x20for\x20the\x20same\x20reason.\x20Blockers\x20naming\x20caller\x20inputs\x20(fee_overrides\x20/\x20guard_resolutions\x20/\x20catalog)\x20may\x20clear\x20with\x20real\x20values.'};}catch(h){return{'status':'unavailable','note':'Compile\x20dry-run\x20could\x20not\x20run\x20on\x20synthetic\x20probe\x20inputs\x20('+(h instanceof Error?h['message']:String(h))+').\x20This\x20is\x20a\x20probe\x20limitation,\x20NOT\x20a\x20template\x20verdict\x20—\x20run\x20template_generate\x20for\x20the\x20authoritative\x20buildability.'};}}export function planNextAction(a,b,c,d){if(d&&!d['actionable'])return'DO\x20NOT\x20execute\x20this\x20plan\x20yet\x20—\x20'+(d['stale']?'the\x20running\x20dist\x20lags\x20the\x20workspace\x20src\x20by\x20'+(d['lag_minutes']??'?')+'\x20min':'template\x20freshness\x20could\x20NOT\x20be\x20verified')+'\x20(stale_build\x20above;\x20verdicts\x20unconfirmed).\x20Rebuild\x20the\x20MCP\x20dist\x20first\x20(pnpm\x20build\x20in\x20the\x20mcp\x20workspace),\x20restart\x20the\x20server,\x20then\x20re-run\x20'+b+'\x20—\x20the\x20plan\x20just\x20returned\x20was\x20compiled\x20from\x20code\x20that\x20may\x20not\x20be\x20what\x20is\x20running.';const e=a['next_action'],f=(Array['isArray'](a['pending_guard_designs'])?a['pending_guard_designs']:[])['filter'](g=>g!=null&&g['bound']===!![])['length'];if(c&&!c['buildable'])return(f>0x0?'Plan\x20BLOCKED\x20—\x20'+f+'\x20unresolved\x20guard\x20design(s)\x20in\x20plan.pending_guard_designs\x20(verdict).\x20Do\x20NOT\x20materialize,\x20':'Plan\x20BLOCKED\x20by\x20the\x20guide\x20audit\x20(see\x20plan.audit\x20/\x20plan.next_action).\x20Do\x20NOT\x20materialize,\x20')+'and\x20do\x20NOT\x20hand-build\x20the\x20objects\x20instead:\x20this\x20plan\x20is\x20the\x20wiring\x20authority\x20(Arbitration\x20+\x20'+'compensation-fund,\x20Contact/um,\x20allocator\x20rows)\x20and\x20hand-built\x20replicas\x20silently\x20drop\x20those\x20wirings.\x20'+(f>0x0?'Resolve\x20the\x20'+f+'\x20pending\x20guard\x20design(s)\x20in\x20plan.pending_guard_designs\x20via\x20guard_resolutions\x20(kind\x20\x27inline\x27\x20with\x20the\x20Guard\x20table+root,\x20kind\x20\x27template\x27\x20with\x20a\x20tpl_*\x20id,\x20or\x20{kind:\x27omit\x27}\x20for\x20advisory\x20designs\x20that\x20do\x20not\x20apply\x20to\x20this\x20shop),\x20':'Adjust\x20fee_overrides,\x20pick\x20another\x20template\x20variant,\x20or\x20fix\x20the\x20template,\x20')+('then\x20re-run\x20action=\x27'+b+'\x27.');if(typeof e==='string'&&e['startsWith']('Plan\x20ready.'))return e;if(c?.['buildable'])return'Plan\x20is\x20buildable\x20(verdict.buildable=true).\x20Materialize\x20the\x20objects\x20in\x20plan.steps\x20order'+(f>0x0?',\x20resolving\x20the\x20'+f+'\x20pending\x20guard\x20design(s)\x20in\x20plan.pending_guard_designs\x20via\x20guard_resolutions\x20before\x20the\x20Machine\x20publish':'')+'.';return'Plan\x20BLOCKED\x20by\x20the\x20guide\x20audit\x20(see\x20plan.audit\x20/\x20plan.next_action).\x20Do\x20NOT\x20materialize,\x20'+'and\x20do\x20NOT\x20hand-build\x20the\x20objects\x20instead:\x20this\x20plan\x20is\x20the\x20wiring\x20authority\x20(Arbitration\x20+\x20'+'compensation-fund,\x20Contact/um,\x20allocator\x20rows)\x20and\x20hand-built\x20replicas\x20silently\x20drop\x20those\x20wirings.\x20'+(f>0x0?'Resolve\x20the\x20'+f+'\x20pending\x20guard\x20design(s)\x20in\x20plan.pending_guard_designs\x20via\x20guard_resolutions\x20(kind\x20\x27inline\x27\x20with\x20the\x20Guard\x20table+root,\x20kind\x20\x27template\x27\x20with\x20a\x20tpl_*\x20id,\x20or\x20{kind:\x27omit\x27}\x20for\x20advisory\x20designs\x20that\x20do\x20not\x20apply\x20to\x20this\x20shop),\x20':'Adjust\x20fee_overrides,\x20pick\x20another\x20template\x20variant,\x20or\x20fix\x20the\x20template,\x20')+('then\x20re-run\x20action=\x27'+b+'\x27.');}function templateIntent(a,b){if(b&&b['trim']())return b['trim']();return'Adopt\x20the\x20'+a['id']+'\x20industry\x20archetype\x20template\x20('+a['archetype']+')\x20for\x20the\x20'+a['industry']+'\x20industry.\x20'+('Primary\x20risk\x20to\x20mitigate:\x20'+a['key_risk']+'.');}function effectiveFeeParams(a,b){return{...a['fee_params'],...b??{}};}const REWARD_POOL_PATTERNS=[/(?:reward|review|bonus|tip|prize)[\s-]*pools?\s*(?:of|is|at|:|=)?\s*([0-9][0-9_,]*(?:\.[0-9]+)?)/i,/([0-9][0-9_,]*(?:\.[0-9]+)?)\s*(?:reward|review|bonus|tip|prize)[\s-]*pools?\b/i];export function extractRewardPoolCandidate(a){if(!a)return undefined;for(const b of REWARD_POOL_PATTERNS){const c=b['exec'](a);if(!c)continue;const d=Number(c[0x1]['replaceAll'](/[,_]/g,''));if(Number['isFinite'](d)&&d>=0x0)return d;}return undefined;}function rewardPoolPrefill(a,b,c,d){if(a['fee_params']['review_reward_pool']===undefined)return undefined;if(c?.['review_reward_pool']!==undefined)return undefined;const e=d?claimNumber(d,'reward_pool_amount'):undefined;if(e!==undefined)return{'fee_key':'review_reward_pool','value':e,'claim_source':'semantic_ir'};const f=extractRewardPoolCandidate(b);return f===undefined?undefined:{'fee_key':'review_reward_pool','value':f};}const FUNDING_THRESHOLD_PATTERNS=[/(?:funding|campaign|round)[\s-]*(?:threshold|goal)s?\s*(?:of|is|at|:|=)?\s*([0-9][0-9_,]*(?:\.[0-9]+)?)/i,/([0-9][0-9_,]*(?:\.[0-9]+)?)\s*(?:funding|campaign|round)[\s-]*(?:threshold|goal)\b/i],MIN_ORDER_PATTERNS=[/(?:min(?:imum)?)\s+order(?:\s+(?:price|value|amount))?\s*(?:of|is|at|:|=)?\s*([0-9][0-9_,]*(?:\.[0-9]+)?)/i,/([0-9][0-9_,]*(?:\.[0-9]+)?)\s*(?:min(?:imum)?)\s+order\b/i];export function extractFundingThresholdCandidate(a){if(!a)return undefined;for(const b of FUNDING_THRESHOLD_PATTERNS){const c=b['exec'](a);if(!c)continue;const d=Number(c[0x1]['replaceAll'](/[,_]/g,''));if(Number['isFinite'](d)&&d>=0x0)return d;}return undefined;}export function extractMinOrderCandidate(a){if(!a)return undefined;for(const b of MIN_ORDER_PATTERNS){const c=b['exec'](a);if(!c)continue;const d=Number(c[0x1]['replaceAll'](/[,_]/g,''));if(Number['isFinite'](d)&&d>=0x0)return d;}return undefined;}function numericFeePrefill(a,b,c,d,e,f,g){if(a['fee_params'][b]===undefined)return undefined;if(f?.[b]!==undefined)return undefined;const h=g?claimNumber(g,c):undefined;if(h!==undefined)return{'fee_key':b,'value':h,'claim_source':'semantic_ir'};const i=d(e);return i===undefined?undefined:{'fee_key':b,'value':i};}function validateFeeParams(a,b){const c=[];let d=0x0;for(const [e,f]of Object['entries'](a)){if(typeof f!=='number'||!Number['isFinite'](f))continue;if(e['endsWith']('_bps')){(!Number['isInteger'](f)||f<0x0||f>0x2710)&&c['push'](e+'='+f+'\x20is\x20not\x20an\x20integer\x20rate\x20in\x20[0,\x2010000]\x20bps');if(e['endsWith']('_share_bps'))d+=Math['max'](0x0,f);}else{if(e['endsWith']('_days')){if(f<=0x0||f>0xe42)c['push'](e+'='+f+'\x20is\x20outside\x20the\x20sane\x20window\x20range\x20(0,\x203650]\x20days');}else{if(e['endsWith']('_hours')){if(f<=0x0||f>0x2238)c['push'](e+'='+f+'\x20is\x20outside\x20the\x20sane\x20window\x20range\x20(0,\x208760]\x20hours');}}}}if(d>0x2710)c['push']('*_share_bps\x20sum\x20'+d+'\x20exceeds\x2010000\x20(a\x20pool\x20splits\x20into\x20at\x20most\x20100%)');if(c['length']>0x0)throw new Error('invalid\x20fee\x20parameters\x20for\x20template\x20\x27'+b+'\x27:\x20'+c['join'](';\x20')+'.\x20'+'Correct\x20the\x20template\x27s\x20fee_params\x20or\x20pass\x20valid\x20\x27fee_overrides\x27.');}export{validateAllocatorRows};export function variantPaymentModel(a){if(a['payment_model'])return a['payment_model'];const b=a['allocator']['rows']??[];if(b['some'](d=>d['track']==='refund'))return'escrow';const c=a['machine_shape']['map'](d=>d['name'])['join']('\x20')['toLowerCase']();if(/\b(milestone|revision|revis|draft|deliverable)\b/['test'](c))return'milestone';if(/\b(charge|renew|subscription|cycle|billing|monthly)\b/['test'](c))return'subscription';return'escrow';}function variantRefundPolicy(a){const b=a['allocator']['description']['toLowerCase']();if(/full[ -]?refund|100% refund|refund .*100/['test'](b))return'full';if(/pro-?rata|prorated/['test'](b))return'milestone_prorated';if(/partial/['test'](b))return'partial';return undefined;}export function variantDeliverables(a,b){const c=a['machine_shape']['filter'](g=>g['semantic_role']==='final'),d=c[c['length']-0x1]??[...a['machine_shape']]['reverse']()['find'](g=>!/refund|cancel|dispute|terminat/i['test'](g['name']+'\x20'+g['role']))??a['machine_shape'][a['machine_shape']['length']-0x1],e=b?.['has_logistics']?'physical':b?.['pure_digital']?'digital':'service_session',f=(a['guards']??[])['filter'](h=>/repository_data_check|required_info_evidence_gate|allocator_order_anchor/['test'](h['template_id']));return[{'name':a['variant']+'\x20fulfillment','type':e,'acceptanceCriteria':'Order\x20reaches\x20the\x20terminal\x20workflow\x20node\x20\x27'+d['name']+'\x27\x20('+d['role']+')','proofOfDelivery':f['length']>0x0?'wip_hash':'manual_confirm'}];}function validateConditionalParams(a,b){for(const d of a['conditional_guards']??[]){const e=b[d['param']];if(e===undefined)continue;if(typeof e!=='string'||!d['values']['includes'](e))throw new Error('invalid\x20\x27'+d['param']+'='+String(e)+'\x27\x20for\x20template\x20\x27'+a['id']+'\x27:\x20must\x20be\x20one\x20of\x20'+d['values']['map'](f=>'\x27'+f+'\x27')['join']('\x20|\x20')+('\x20(the\x20guard\x20variant\x20mounts\x20at\x20\x27'+d['emit_value']+'\x27)'));}}async function runGuide(a,b,c,d,e,f,g){const h=effectiveFeeParams(a,c),i=rewardPoolPrefill(a,b,c,g);if(i)h[i['fee_key']]=i['value'];const j=numericFeePrefill(a,'funding_threshold','funding_threshold_amount',extractFundingThresholdCandidate,b,c,g);if(j)h[j['fee_key']]=j['value'];const k=numericFeePrefill(a,'min_order_price','min_order_price_amount',extractMinOrderCandidate,b,c,g);if(k)h[k['fee_key']]=k['value'];validateFeeParams(h,a['id']),validateConditionalParams(a,h);const l=landPlatformCommission(a,h);if(l['error']!==undefined)throw new Error(l['error']);const m=l['rows']?{...a,'allocator':{...a['allocator'],'rows':l['rows'],'count':l['rows']['filter'](z=>z['track']==='settlement')['length']}}:a,n=getIndustryModeRegistry()['getMode'](a['industry']),o=platformShareBps(h),q={'model':variantPaymentModel(a)},r=[],s=(m['allocator']['rows']?.['length']??0x0)>0x0;if(o!==undefined&&o>0x0&&!s&&a['allocator']['mode']==='rate'){const z=Math['round'](o)/0x64;r['push']({'recipient':'merchant','percentage':Math['round']((0x64-z)*0x64)/0x64}),r['push']({'recipient':'platform','percentage':z}),q['allocation']=r;}const u=variantRefundPolicy(a),v={'escrow':!![]};if(u)v['refundPolicy']=u;v['arbitration']=a['arbitration_mode']??v['arbitration']??inferArbitration(templateIntent(a,b));const w=await handleMerchantGuide({'intent':templateIntent(a,b),'guide_confirm':{'industry':a['industry'],'payment':q,'trust':v,'deliverables':variantDeliverables(a,n?.['traits']),...d&&Object['keys'](d)['length']>0x0?{'guard_resolutions':d}:{},...e?.['review_mode']?{'review_mode':e['review_mode']}:{},...e?.['reward_funding']!==undefined?{'reward_funding':e['reward_funding']}:{},...e?.['reward_claim_amount']!==undefined?{'reward_claim_amount':e['reward_claim_amount']}:{},...e?.['after_sales_mode']?{'after_sales_mode':e['after_sales_mode']}:{},...e?.['acceptance_mode']?{'acceptance_mode':e['acceptance_mode']}:{},...e?.['installment_mode']?{'installment_mode':e['installment_mode']}:{},...e?.['affiliate_mode']?{'affiliate_mode':e['affiliate_mode']}:{},...e?.['crowdfunding_mode']?{'crowdfunding_mode':e['crowdfunding_mode']}:{},...e?.['logistics_mode']?{'logistics_mode':e['logistics_mode']}:{},...f?.['length']?{'sales':f}:{}},'template_override':{...m,'fee_params':h},'name_base':a['id']});m['allocator']['rows']?.['length']&&(w['template_allocator_rows']=m['allocator']['rows']['map'](A=>({...A})));if(l['landing']!==undefined)w['commission_landing']=l['landing'];w['template']={'id':a['id'],'archetype':a['archetype'],'recommended_role':a['recommended_role'],'fee_params':h},w['catalog_version']=BUILTIN_TEMPLATES_VERSION;const x=templateCatalogDigest(a['id']);if(x!==undefined)w['template_digest']=x;if(w['plan']&&typeof w['plan']==='object'&&!Array['isArray'](w['plan'])){w['plan']['catalog_version']=BUILTIN_TEMPLATES_VERSION;if(x!==undefined)w['plan']['template_digest']=x;}{const A=[...collectLateMarks(w['plan']??{})]['sort']();A['length']>0x0&&(w['required_local_marks']=A,w['required_local_marks_note']='plan_execute\x20resolves\x20each\x20of\x20these\x20local\x20names\x20against\x20the\x20LocalMark\x20store\x20of\x20the\x20target\x20network\x20and\x20refuses\x20to\x20execute\x20while\x20any\x20is\x20unregistered.\x20'+'Register\x20them\x20BEFORE\x20executing\x20(local_mark_operation\x20add).\x20A\x20name\x20that\x20matches\x20an\x20object\x20this\x20plan\x20itself\x20creates\x20is\x20bound\x20to\x20that\x20object\x20automatically.\x20'+'A\x20recipient\x20mark\x20must\x20point\x20at\x20a\x20real\x20account\x20address:\x20an\x20empty\x20name\x20makes\x20the\x20SDK\x20substitute\x20the\x20deploying\x20account\x20(the\x20share\x20lands\x20in\x20whoever\x20runs\x20the\x20deploy),\x20and\x20an\x20object-id\x20/\x20zero-address\x20recipient\x20is\x20transferred\x20and\x20cannot\x20be\x20retrieved.\x20'+'A\x20Rate-0\x20Entity\x20leg\x20still\x20listed\x20in\x20template_allocator_rows\x20is\x20dropped\x20at\x20compile\x20time\x20and\x20needs\x20no\x20mark\x20(the\x20direct-sales\x20default\x20pays\x20nobody).');}w['template_fee_param_landings']=buildFeeParamLandingTable(m,h);if(c&&Object['keys'](c)['length']>0x0)w['template_fee_overrides']=c;const y=[];if(i)y['push'](i);if(j)y['push'](j);if(k)y['push'](k);if(y['length']>0x0){w['fee_overrides_prefills']=y;for(const B of y){const C=B['fee_key']==='review_reward_pool'?'Reward\x20pool':B['fee_key']==='funding_threshold'?'Funding\x20threshold':'Minimum\x20order',D=B['claim_source']==='semantic_ir'?'\x20(from\x20the\x20semantic\x20IR\x20claim)':'';w['next_action']=w['next_action']+'\x20'+C+'\x20prefilled\x20from\x20your\x20request:\x20'+B['value']+D+'\x20—\x20adjust\x20via\x20fee_overrides.';}}return w;}export async function handleBenchmarkMigrationOperation(a){const b=strictParse(BenchmarkMigrationSchema,a,'benchmark_migration_operation\x20input'),c=b['industry']?resolveIndustryName(b['industry'])??b['industry']['toLowerCase']():undefined,d=b['semantic_ir']?normalizeSemanticIR(b['semantic_ir'],{'source_text':b['description']}):undefined,e=d?{'semantic_ir_digest':d['digest'],...d['issues']['length']>0x0?{'semantic_ir_issues':d['issues']}:{}}:undefined;let f;switch(b['action']){case'template_list':{const {templates:g,errors:h}=listTemplates(),i=c?g['filter'](k=>k['industry']===c):g,j=new Map(builtinTemplateDrift()['map'](k=>[k['template'],k['state']]));f={'action':'template_list','count':i['length'],'templates':i['map'](k=>({...templateSummary(k),'disk_state':j['get'](k['id'])??(BUILTIN_TEMPLATES['some'](l=>l['id']===k['id'])?'current':'untracked')})),'discovery_vocabulary':{'industries':listIndustries()['map'](k=>k['name'])['sort'](),'tags':[...DISCOVERY_TAG_VOCABULARY],'product_refs':[...DISCOVERY_PRODUCT_REFS]},'load_errors':h};break;}case'template_get':{const k=requireTemplate(b['template_id'],'template_get');f={'action':'template_get','template':{...k,...templateGetAids(k)}};break;}case'template_generate':{const l=requireTemplate(b['template_id'],'template_generate'),m=b['review_mode']??l['review_mode']??'none',n=[];m==='review_reward'&&!b['reward_funding']&&n['push']('reward_funding\x20is\x20required:\x20template\x20\x27'+l['id']+'\x27\x20resolves\x20to\x20review_mode\x20\x27review_reward\x27\x20(input'+(b['review_mode']?'':'\x20via\x20template\x20declaration')+'),\x20which\x20promises\x20buyers\x20a\x20claimable\x20review\x20bounty\x20—\x20an\x20unfunded\x20pool\x20must\x20not\x20ship\x20(INV-4).\x20Pass\x20reward_funding\x20(smallest-unit\x20string;\x20expected\x20orders\x20x\x20per-order\x20reward\x20—\x20fee_param\x20review_reward_pool\x20is\x20the\x20planning\x20benchmark),\x20or\x20drop\x20the\x20mode\x20explicitly\x20(review_mode\x20\x27review\x27\x20keeps\x20the\x20review\x20rail\x20without\x20the\x20bounty;\x20\x27none\x27\x20removes\x20the\x20rail).');(!Array['isArray'](b['sales'])||b['sales']['length']===0x0)&&n['push']('sales\x20is\x20required:\x20a\x20plan\x20without\x20a\x20sellable\x20catalog\x20publishes\x20a\x20Service\x20frozen\x20with\x20sales:\x20[]\x20and\x20every\x20order_new\x20aborts\x20(PLAN-SALES-01,\x20upgraded\x20to\x20an\x20input\x20requirement,\x20amz9\x20A-2).\x20Pass\x20sales:\x20[{\x20name,\x20price,\x20quantity?,\x20wip_hash?\x20}]\x20—\x20one\x20entry\x20per\x20sellable\x20SKU,\x20price\x20in\x20smallest\x20units\x20(wip_hash\x20from\x20the\x20wip_file\x20tool\x20upload).');if(n['length']>0x0)return{'content':[{'type':'text','text':'template_generate\x20refused\x20—\x20no\x20plan\x20was\x20built.\x20'+n['length']+'\x20input\x20gap(s),\x20ALL\x20listed\x20at\x20once\x20(AR-4\x20T-05):\x20'+n['map']((t,u)=>'('+(u+0x1)+')\x20'+t)['join']('\x20')}],'structuredContent':{'result':{'type':'error','error':'template_generate\x20input\x20preflight\x20failed\x20with\x20'+n['length']+'\x20gap(s)\x20on\x20template\x20\x27'+l['id']+'\x27\x20—\x20all\x20gaps\x20reported\x20in\x20this\x20single\x20response\x20(do\x20not\x20fix\x20one\x20and\x20rediscover\x20the\x20next).','error_code':'input_preflight_failed','retryable':!![],'recovery_hint':n['join']('\x20|\x20'),'gaps':n},'message':'Refused:\x20input\x20preflight\x20failed.\x20Fix\x20ALL\x20listed\x20gaps,\x20then\x20re-send\x20ONCE.\x20See\x20recovery_hint.'}};const o=scanTemplate(l);assertGenerateScanPassed(o,'template_generate');const p=getTemplateParamFileLayer(l['id']),q=Object['keys'](p)['length']>0x0,r=q?{...p,...b['fee_overrides']??{}}:b['fee_overrides'],s=await runGuide(l,b['description'],r,b['guard_resolutions'],{'review_mode':b['review_mode'],'reward_funding':b['reward_funding'],'reward_claim_amount':b['reward_claim_amount'],'after_sales_mode':b['after_sales_mode'],'acceptance_mode':b['acceptance_mode'],'installment_mode':b['installment_mode'],'affiliate_mode':b['affiliate_mode'],'crowdfunding_mode':b['crowdfunding_mode']},b['sales'],d?.['ir']);f=((()=>{const t=scanSummary(o,driftFace(l['id'])),u=staleBuildFace(),v=buildVerdict(t,s,undefined,u),w=wipAnchorFace(b['sales']),x=returnNoExitFace(l['id']),y=planNextAction(s,'template_generate',v,u);return{'action':'template_generate','template_id':l['id'],...e,'stale_build':u,'scan':t,'plan':s,'verdict':v,...q?{'template_params_file':{'path':templateParamsFilePath(),'applied':p}}:{},...w?{'wip_anchor':w}:{},...x?{'return_no_exit':x}:{},'next_action':y};})());break;}case'template_scan':{const t=requireTemplate(b['template_id'],'template_scan'),u=staleBuildFace(),v=await templateScanDryRun(t,u),w=returnNoExitFace(t['id']);f={'action':'template_scan','stale_build':u,'scan':{...withOnceSlotAdvisories(scanTemplate(t)),'drift':driftFace(t['id']),'compile_dry_run':v},...v['status']==='unavailable'?{}:{'buildable':v['buildable']===!![],'build_blockers':v['blockers']??[]},...w?{'return_no_exit':w}:{},'next_action':v['status']==='blocked'?'compile_dry_run\x20BLOCKED\x20—\x20the\x20static\x20rule\x20scan\x20passed,\x20but\x20the\x20compile\x20kernel\x20refuses\x20this\x20template\x20(see\x20build_blockers;\x20the\x20same\x20verdict\x20template_generate\x20enforces).\x20Do\x20NOT\x20publish\x20from\x20this\x20scan:\x20run\x20template_generate\x20for\x20the\x20full\x20verdict,\x20or\x20fix\x20the\x20template\x20and\x20re-scan.':v['status']==='unverified'?'compile_dry_run\x20UNVERIFIED\x20—\x20the\x20running\x20dist\x20is\x20stale\x20against\x20the\x20workspace\x20src\x20(stale_build\x20above):\x20the\x20findings\x20and\x20verdict\x20may\x20describe\x20superseded\x20template\x20knowledge.\x20Do\x20NOT\x20act\x20on\x20ANY\x20conclusion\x20here.\x20Rebuild\x20the\x20MCP\x20dist\x20(pnpm\x20build\x20in\x20the\x20mcp\x20workspace),\x20restart\x20the\x20process,\x20and\x20re-scan.':v['status']==='ready'?'compile_dry_run\x20READY\x20on\x20probe\x20inputs\x20—\x20proceed\x20with\x20template_generate.':'compile_dry_run\x20unavailable\x20on\x20probe\x20inputs\x20—\x20run\x20template_generate\x20for\x20the\x20authoritative\x20buildability.'};break;}case'migration_import':{if(!b['description']||!b['description']['trim']())throw new Error('\x27description\x27\x20is\x20required\x20for\x20action=\x27migration_import\x27');const x=d?handleRecommendIndustry({'intent':b['description'],'semantic_ir':b['semantic_ir']}):undefined,y=planMigration({'url':b['url'],'description':b['description'],'industry':c,'ir_industry':c?undefined:x?.['recommendations'][0x0]?.['industry'],'ir_discovery':d?discoverySignal(d['ir']):undefined,'network':b['network']});if(!y)throw new Error('No\x20industry\x20template\x20matched\x20the\x20description.\x20Refine\x20the\x20description\x20or\x20pass\x20an\x20explicit\x20\x27industry\x27\x20hint'+(d?',\x20or\x20add\x20discovery\x20tags\x20/\x20a\x20product_ref\x20to\x20semantic_ir\x20(tags\x20vocabulary:\x20template_list.discovery_vocabulary).':'\x20(or\x20provide\x20semantic_ir\x20with\x20discovery\x20tags\x20/\x20traits\x20for\x20a\x20non-English\x20description).'));const z=getTemplate(y['source']['matched_template']),A=z?await templateScanDryRun(z,staleBuildFace()):undefined;f={'action':'migration_import','log':y,...A&&A['buildable']!==undefined?{'buildable':A['buildable']===!![],'build_blockers':A['blockers']??[],'compile_dry_run':{'status':A['status'],'note':A['note']}}:{},...x?{'inference_source':x['inference_source']}:{},...e,'next_action':'MigrationLog\x20ready.\x20Next:\x20call\x20action=\x27migration_review\x27\x20with\x20this\x20log\x20to\x20surface\x20the\x20mapped/unmapped/manual_review\x20items\x20for\x20user\x20confirmation.'+(A?.['status']==='unverified'?'\x20NOTE:\x20the\x20compile\x20dry-run\x20verdict\x20is\x20UNVERIFIED\x20—\x20the\x20running\x20dist\x20is\x20stale\x20against\x20the\x20workspace\x20src\x20(see\x20build_blockers):\x20do\x20NOT\x20act\x20on\x20buildability\x20until\x20rebuilt\x20(pnpm\x20build\x20in\x20the\x20mcp\x20workspace)\x20and\x20re-run.':A?.['status']==='blocked'?'\x20NOTE:\x20compile\x20dry-run\x20BLOCKED\x20on\x20probe\x20inputs\x20(see\x20build_blockers)\x20—\x20surface\x20the\x20blockers\x20at\x20review\x20BEFORE\x20migration_apply;\x20input-naming\x20blockers\x20may\x20clear\x20with\x20real\x20values.':'')};break;}case'plan_execute':{const B=planEnvelopeFromInput(b['plan']),C=B['plan']!==undefined&&typeof B['plan']==='object'&&!Array['isArray'](B['plan'])&&Array['isArray'](B['plan']['steps'])?B['plan']:B;if(!Array['isArray'](C['steps']))throw new Error('action=\x27plan_execute\x27:\x20the\x20passed\x20plan\x20carries\x20no\x20steps[]\x20—\x20pass\x20the\x20template_generate\x20\x27plan\x27\x20object\x20verbatim');const D=typeof C['catalog_version']==='number'?C['catalog_version']:undefined,E=typeof C['templateId']==='string'?C['templateId']:undefined,F=typeof C['template_digest']==='string'?C['template_digest']:undefined,G=D===BUILTIN_TEMPLATES_VERSION,H=!G&&E!==undefined&&F!==undefined&&templateCatalogDigest(E)===F;if(D!==undefined&&!G&&!H)throw new Error('action=\x27plan_execute\x27:\x20STALE\x20PLAN\x20—\x20the\x20plan\x20was\x20generated\x20against\x20catalog\x20v'+D+',\x20'+('but\x20this\x20server\x20runs\x20catalog\x20v'+BUILTIN_TEMPLATES_VERSION+(H?'':'\x20and\x20its\x20template\x20content\x20does\x20not\x20match\x20this\x20catalog\x27s\x20template')+';\x20shapes,\x20guards\x20and\x20emissions\x20may\x20have\x20')+'changed\x20since.\x20Re-run\x20template_generate\x20(or\x20migration_apply)\x20to\x20regenerate\x20the\x20plan\x20against\x20the\x20'+'current\x20catalog,\x20then\x20execute\x20THAT\x20verbatim.\x20Nothing\x20was\x20executed.');const I=templateAdvisoryFaces(E),J=(C['steps']??[])['filter'](aa=>aa!==null&&typeof aa==='object'),K=J['map'](aa=>String(aa['id'])),L=new Set(J['filter'](aa=>aa['op']==='create')['map'](aa=>String(aa['id'])));let M=[...b['completed_steps']??[]];const N=b['resume_from_step'];if(N!==undefined){const aa=K['indexOf'](N);if(aa<0x0)throw new Error('action=\x27plan_execute\x27:\x20resume_from_step\x20\x27'+N+'\x27\x20is\x20not\x20a\x20step\x20of\x20THIS\x20plan\x20(steps:\x20'+K['join'](',\x20')+').\x20'+'Step\x20ids\x20are\x20plan-local:\x20resume\x20against\x20the\x20plan\x20returned\x20by\x20the\x20ORIGINAL\x20template_generate\x20(a\x20regenerated\x20plan\x20mints\x20new\x20ids).\x20Nothing\x20was\x20executed.');M=[...new Set([...M,...K['slice'](0x0,aa)])];}const O=M['filter'](ab=>!K['includes'](ab));if(O['length']>0x0)throw new Error('action=\x27plan_execute\x27:\x20completed_steps\x20name(s)\x20['+O['join'](',\x20')+']\x20are\x20not\x20steps\x20of\x20THIS\x20plan\x20—\x20the\x20resume\x20channel\x20'+'adopts\x20ONLY\x20steps\x20of\x20the\x20SAME\x20plan,\x20and\x20a\x20silently-ignored\x20unknown\x20id\x20would\x20re-execute\x20the\x20real\x20step\x20(ghost\x20duplicates).\x20'+'This\x20usually\x20means\x20the\x20plan\x20was\x20REGENERATED\x20(ids\x20changed):\x20pass\x20the\x20original\x20plan\x20with\x20ITS\x20resume\x20payload,\x20or\x20this\x20response\x27s\x20`resume`\x20object\x20verbatim.\x20Nothing\x20was\x20executed.');const P=b['previous_outputs']??{},Q=M['filter'](ab=>L['has'](ab)&&P[ab]===undefined);if(Q['length']>0x0)throw new Error('action=\x27plan_execute\x27:\x20adopted\x20create\x20step(s)\x20['+Q['join'](',\x20')+']\x20have\x20NO\x20previous_outputs\x20entry\x20—\x20an\x20adopted\x20create\x20'+'without\x20its\x20created\x20address\x20cannot\x20resolve\x20$ref\x20bindings.\x20Pass\x20the\x20addresses\x20from\x20the\x20prior\x20run\x27s\x20outputs\x20field\x20(or\x20its\x20`resume`\x20payload).\x20Nothing\x20was\x20executed.');const R=M['length']>0x0||Object['keys'](P)['length']>0x0||N!==undefined?{'completedSteps':M,'outputs':P}:undefined,S=((()=>{const ab=new Map();for(const ad of C['steps']??[]){const ae=ad['params'];ad['op']==='create'&&typeof ae?.['name']==='string'&&ab['set'](ae['name'],String(ad['id']));}const ac=af=>{if(Array['isArray'](af))return af['map'](ac);if(af&&typeof af==='object'){const ag=af,ah=ag['$late'],ai=Object['keys'](ag);if(ah?.['by']==='local_name'&&typeof ah['mark']==='string'&&ai['length']===0x1&&ab['has'](ah['mark']))return{'$ref':ab['get'](ah['mark'])};return Object['fromEntries'](Object['entries'](ag)['map'](([aj,ak])=>[aj,ac(ak)]));}return af;};return ac(C);})()),T=bindAuditPlan(S);if(T['length']>0x0){const ab=bindRecoveryList(S,b['previous_outputs']);throw new Error('action=\x27plan_execute\x27:\x20PLAN_BIND_AUDIT_FAILED\x20—\x20the\x20plan\x20binds\x20plan-created\x20objects\x20by\x20'+'global-namespace\x20NAME\x20instead\x20of\x20{\x22$ref\x22:\x20stepId}\x20(or\x20carries\x20an\x20undeclared\x20external\x20local_name).\x20'+'Executing\x20would\x20wire\x20THIS\x20store\x20to\x20ANOTHER\x20run\x27s\x20objects\x20—\x20Guards\x20are\x20create-frozen\x20and\x20Machines\x20'+'cannot\x20republish,\x20so\x20the\x20mis-binding\x20is\x20unrecoverable\x20after\x20the\x20fact\x20(ddmc4\x20B-13,\x20pdd\x20F-08).\x20'+'Nothing\x20was\x20executed.\x0a'+bindAuditReport(T,ab)+'\x0aRe-run\x20template_generate\x20against\x20the\x20current\x20catalog\x20(its\x20compile\x20emits\x20{\x22$ref\x22:\x20stepId}\x20for\x20'+'every\x20plan-internal\x20object),\x20then\x20execute\x20THAT\x20plan.');}const U=planLedgerKey(S);let V;const W=lockedFreshStep(U,K,new Set(M));if(W!==undefined){const ac=b['retry_override'];if(ac!==undefined&&ac['step_id']===W['stepId']&&ac['note']['trim']()['length']>0x0)clearPlanStep(U,W['stepId']),V={'step_id':W['stepId'],'note':ac['note']};else throw new Error('action=\x27plan_execute\x27:\x20RETRY_LOCKED\x20—\x20step\x20\x27'+W['stepId']+'\x27\x20failed\x20with\x20the\x20IDENTICAL\x20error\x20in\x20'+W['count']+'\x20consecutive\x20'+('rounds\x20(\x22'+W['lastError']+'\x22).\x20A\x20further\x20unchanged\x20re-run\x20fails\x20identically\x20and\x20burns\x20gas,\x20so\x20this\x20server\x20refuses\x20it\x20(nothing\x20was\x20executed).\x20')+'Fix\x20the\x20cause\x20first\x20—\x20usual\x20roots:\x20a\x20template/input\x20defect\x20(re-run\x20template_generate\x20for\x20a\x20FRESH\x20plan:\x20new\x20ids,\x20new\x20ledger),\x20a\x20missing\x20registration\x20(do\x20it,\x20then\x20resume),\x20'+'or\x20verify\x20the\x20single\x20step\x20manually\x20via\x20onchain_operations\x20to\x20confirm\x20the\x20fix.\x20'+('If\x20one\x20more\x20round\x20IS\x20justified,\x20pass\x20retry_override\x20{step_id:\x20\x22'+W['stepId']+'\x22,\x20note:\x20\x22<why>\x22}.'));}const X=[...new Set([...collectLateMarks(S),...collectAddressSlotBareNames(S)])],Y=b['env']?.['network'],Z=new Map(),a0=[];for(const ad of X){const ae=await LocalMark['Instance']()['get_address'](ad,Y)['catch'](()=>undefined);if(typeof ae==='string'&&ae['length']>0x0)Z['set'](ad,ae);else a0['push'](ad);}if(a0['length']>0x0)throw new Error('action=\x27plan_execute\x27:\x20unresolved\x20LocalMark(s)\x20['+a0['join'](',\x20')+']\x20on\x20'+(Y??'default')+'\x20network.\x20'+'This\x20plan\x20binds\x20an\x20object\x20by\x20local\x20name\x20(a\x20funding\x20recipient\x20slot,\x20an\x20external\x20object\x20reference,\x20or\x20an\x20Address-typed\x20guard\x20table\x20value).\x20Register\x20the\x20mark\x20first\x20—\x20'+('local_mark_operation\x20{add:{op:\x22add\x22,data:[{name:\x22'+a0[0x0]+'\x22,address:\x22<your\x20entity\x20address>\x22}]}}\x20—\x20then\x20re-run.\x20')+'Nothing\x20was\x20executed.');const a1=Z['get']('platform');if(a1!==undefined){const af=platformMarkRefusal(a1,Y??'default');if(af!==undefined)throw new Error(af);}const a2=await materializePlan(S,{'execute':handlerExecutor(b['env']),'envByAccount':b['accounts'],'timeoutMs':b['timeout_ms'],'resolveLate':ag=>{if(ag['by']==='address')return ag['address'];const ah=Z['get'](ag['mark']);if(ah===undefined)throw new Error('unresolved\x20late\x20binding:\x20local_name\x20\x27'+ag['mark']+'\x27');return ah;}},R),a3=a2['steps']['filter'](ag=>ag['status']==='blocked')['length'],a4=a2['steps']['find'](ag=>ag['status']==='failed'),a5=a2['steps']['some'](ag=>ag['status']==='blocked'&&typeof ag['error']==='string'&&ag['error']['startsWith']('preflight\x20failed:')),a6=a2['steps']['find'](ag=>ag['status']==='failed'&&typeof ag['digest']==='string'&&ag['digest']['length']>0x0),a7=a2['steps']['find'](ag=>ag['status']==='blocked'&&typeof ag['error']==='string'&&ag['error']['startsWith']('time\x20budget'));recordPlanRound(U,a2['steps']);const a8=repeatedPlanFailures(U);let a9=a2['completed']?'Deployed.\x20Verify\x20the\x20store\x20(query_toolkit:\x20service\x20/\x20machine\x20/\x20orders),\x20then\x20discharge\x20any\x20post-deploy\x20module\x20obligations\x20the\x20guide\x20listed\x20under\x20harness_check.module_gaps.':a5?'A\x20publish\x20step\x20was\x20BLOCKED\x20by\x20the\x20freeze\x20gate\x20—\x20the\x20store\x20is\x20NOT\x20live.\x20Fix\x20the\x20listed\x20preflight\x20checks\x20at\x20the\x20SOURCE\x20(re-run\x20template_generate);\x20never\x20patch\x20plan\x20steps\x20by\x20hand.':a6!==undefined?'Step\x20\x27'+a6['stepId']+'\x27\x20FAILED\x20with\x20digest\x20'+a6['digest']+'\x20—\x20the\x20transaction\x20MAY\x20have\x20committed\x20(transport\x20face).\x20VERIFY\x20FIRST:\x20onchain_transaction\x20with\x20that\x20digest.\x20If\x20committed:\x20ADOPT\x20it\x20—\x20add\x20\x27'+a6['stepId']+'\x27\x20to\x20completed_steps\x20(and\x20its\x20created\x20object\x20address\x20to\x20previous_outputs)\x20in\x20the\x20resume\x20call.\x20If\x20confirmed\x20absent:\x20re-send\x20with\x20this\x20response\x27s\x20resume\x20payload\x20(or\x20completed_steps/previous_outputs\x20from\x20it).\x20Never\x20blind-resume\x20a\x20digest-bearing\x20failure\x20(ghost\x20duplicates).':a2['budgetExhausted']?'Time\x20budget\x20('+String(b['timeout_ms'])+'ms)\x20reached\x20before\x20step\x20\x27'+(a7?.['stepId']??'?')+'\x27\x20—\x20the\x20run\x20stopped\x20cleanly\x20mid-plan\x20with\x20NO\x20unknown-state\x20step.\x20RESUME\x20(W5-08):\x20send\x20plan_execute\x20again\x20with\x20the\x20SAME\x20plan\x20and\x20this\x20response\x27s\x20resume\x20payload\x20VERBATIM\x20(completed_steps\x20+\x20previous_outputs),\x20or\x20resume_from_step\x20=\x20\x27'+(a7?.['stepId']??'<first\x20non-executed\x20stepId>')+'\x27\x20+\x20previous_outputs\x20('+a3+'\x20step(s)\x20remain;\x20raise\x20or\x20omit\x20timeout_ms\x20to\x20take\x20fewer\x20slices).':'Step\x20\x27'+(a4?.['stepId']??'?')+'\x27\x20FAILED:\x20'+(a4?.['error']??'unknown')+'.\x20RESUME\x20—\x20do\x20NOT\x20re-run\x20from\x20scratch\x20(duplicate\x20objects):\x20send\x20plan_execute\x20again\x20with\x20this\x20response\x27s\x20resume\x20payload\x20(completed_steps\x20+\x20previous_outputs),\x20or\x20resume_from_step\x20=\x20\x27'+(a4?.['stepId']??'?')+'\x27\x20+\x20previous_outputs.';if(a8['length']>0x0&&!a2['completed']){const ag='STOP\x20—\x20do\x20NOT\x20re-run\x20unchanged:\x20step\x20\x27'+a8[0x0]['step_id']+'\x27\x20failed\x20with\x20the\x20IDENTICAL\x20error\x20for\x20'+a8[0x0]['consecutive_rounds']+'\x20consecutive\x20round(s);\x20a\x20further\x20unchanged\x20re-run\x20is\x20REFUSED\x20pre-execution.\x20';a9=a6!==undefined||a5?a9+'\x20'+ag+'After\x20resolving\x20the\x20state\x20question\x20above,\x20fix\x20the\x20ROOT\x20CAUSE\x20before\x20resuming\x20(retry_override\x20{step_id,\x20note}\x20is\x20the\x20audited\x20exception).':ag+'The\x20generic\x20RESUME\x20recipe\x20is\x20withheld\x20on\x20purpose.\x20Fix\x20the\x20root\x20cause\x20first\x20—\x20re-run\x20template_generate\x20for\x20a\x20fresh\x20plan\x20(new\x20ids\x20bypass\x20the\x20lock),\x20complete\x20a\x20missing\x20registration,\x20or\x20verify\x20the\x20single\x20failing\x20step\x20via\x20onchain_operations\x20—\x20THEN\x20resume\x20with\x20the\x20resume\x20payload.\x20retry_override\x20{step_id,\x20note}\x20authorizes\x20one\x20audited\x20exception.';}f={'action':'plan_execute','completed':a2['completed'],'steps':a2['steps'],'outputs':a2['outputs'],'preflight':{'issues':a2['preflight']['issues'],'findings':a2['preflight']['findings'],...Object['keys'](I)['length']>0x0?{'template_advisories':I}:{}},'readback':a2['readback'],...Z['size']>0x0?{'late_mark_bindings':Object['fromEntries'](Z),'late_mark_note':'PAYEE\x20VERIFICATION\x20(last\x20repairable\x20moment):\x20each\x20entry\x20is\x20the\x20address\x20a\x20local-name\x20funding\x20recipient\x20resolved\x20to.\x20'+'Verify\x20every\x20address\x20belongs\x20to\x20THIS\x20store\x27s\x20owner/operator\x20accounts\x20(accounts\x20you\x20control)\x20before\x20any\x20service_publish\x20step\x20runs.\x20'+'A\x20wrong\x20address\x20here\x20becomes\x20an\x20UNFIXABLE\x20on-chain\x20allocator\x20after\x20publish\x20—\x20correct\x20the\x20local\x20mark\x20(local_mark_operation\x20add)\x20and\x20re-run\x20if\x20anything\x20is\x20off.'}:{},...a2['completed']?{}:{'resume':{'completed_steps':a2['steps']['filter'](ah=>ah['status']==='executed')['map'](ah=>ah['stepId']),'previous_outputs':a2['outputs']}},...a8['length']>0x0?{'repeated_failures':a8,'retry_prohibited':!![]}:{},...V!==undefined?{'retry_override_applied':V}:{},'next_action':a9};break;}case'migration_review':{if(!b['log'])throw new Error('\x27log\x27\x20is\x20required\x20for\x20action=\x27migration_review\x27');const ah=b['log'],ai=Array['isArray'](ah['mapped'])?ah['mapped']:[],aj=Array['isArray'](ah['unmapped'])?ah['unmapped']:[],ak=Array['isArray'](ah['manual_review'])?ah['manual_review']:[],al=ah['risk_check']??{},am=ah['source']?.['matched_template']??'',an=ah['template_match']??{},ao=typeof an['source']==='string'?an['source']:'unknown',ap=typeof an['confidence']==='number'?an['confidence']:0x0,aq=ao==='unknown'||ao==='industry_leader'||ao==='ir_industry_fallback'||ap<0.5,ar=am?getTemplate(am):undefined,as=ar?await templateScanDryRun(ar,staleBuildFace()):undefined,at=as?.['buildable']===undefined?undefined:as['buildable']===!![],au=as?.['blockers']??[],av=as?.['status']==='unverified'?'\x20NOTE:\x20the\x20compile\x20dry-run\x20verdict\x20is\x20UNVERIFIED\x20—\x20the\x20running\x20dist\x20is\x20stale\x20against\x20the\x20workspace\x20src\x20(see\x20review_summary.build_blockers):\x20rebuild\x20(pnpm\x20build\x20in\x20the\x20mcp\x20workspace),\x20restart,\x20and\x20re-run\x20before\x20acting.':at===![]?'\x20NOTE:\x20compile\x20dry-run\x20ALSO\x20blocks\x20this\x20template\x20on\x20probe\x20inputs\x20(review_summary.build_blockers)\x20—\x20input-naming\x20blockers\x20may\x20clear\x20with\x20real\x20values.':'',aw=aj['length']===0x0&&ak['length']===0x0&&al['passed']===!![]&&!aq&&at!==![];f={'action':'migration_review','log':ah,'review_summary':{'mapped_count':ai['length'],'unmapped_count':aj['length'],'manual_review_count':ak['length'],'risk_passed':al['passed']===!![],...as?{...at!==undefined?{'buildable':at}:{},'build_blockers':au,'compile_dry_run':{'status':as['status'],'note':as['note']}}:{},'template_match':{'template_id':am,'source':ao,'confidence':ap,'weak_match':aq}},'next_action':aw?'Review\x20clean.\x20Proceed:\x20call\x20action=\x27migration_apply\x27\x20with\x20template_id=\x27'+am+'\x27\x20to\x20produce\x20the\x20creation\x20plan\x20(network\x20defaults\x20to\x20testnet;\x20mainnet\x20requires\x20explicit\x20user\x20confirmation).'+(as?.['status']==='unavailable'?'\x20Note:\x20the\x20compile\x20dry-run\x20could\x20not\x20run\x20on\x20probe\x20inputs\x20—\x20template_generate\x20remains\x20the\x20authoritative\x20buildability\x20check.':''):as?.['status']==='unverified'&&!aq?'compile\x20dry-run\x20verdict\x20UNVERIFIED\x20—\x20the\x20running\x20dist\x20is\x20stale\x20against\x20the\x20workspace\x20src\x20(see\x20review_summary.build_blockers).\x20Do\x20NOT\x20act\x20on\x20buildability:\x20rebuild\x20(pnpm\x20build\x20in\x20the\x20mcp\x20workspace),\x20restart\x20the\x20process,\x20and\x20re-run\x20migration_plan\x20for\x20a\x20verified\x20verdict.':at===![]&&!aq?'compile_dry_run\x20BLOCKED\x20on\x20probe\x20inputs\x20—\x20the\x20static\x20risk\x20check\x20passed,\x20but\x20the\x20compile\x20kernel\x20refuses\x20\x27'+am+'\x27\x20(see\x20review_summary.build_blockers;\x20the\x20same\x20verdict\x20template_generate\x20enforces).\x20Surface\x20the\x20blockers\x20to\x20the\x20user\x20BEFORE\x20action=\x27migration_apply\x27\x20—\x20blockers\x20naming\x20caller\x20inputs\x20(sales\x20/\x20fee_overrides\x20/\x20guard_resolutions)\x20may\x20clear\x20with\x20real\x20values.':aq?'WEAK\x20TEMPLATE\x20MATCH:\x20\x27'+am+'\x27\x20was\x20chosen\x20by\x20\x27'+ao+'\x27\x20at\x20confidence\x20'+ap+'\x20—\x20a\x20fallback,\x20not\x20evidence\x20(ssng\x20A-1:\x20a\x20Chinese\x20one-liner\x20silently\x20built\x20the\x20wrong\x20store\x20this\x20way).\x20Play\x20the\x20match\x20back\x20to\x20the\x20user\x20and\x20confirm\x20the\x20business\x20model.\x20To\x20get\x20an\x20EVIDENCE-based\x20match,\x20translate\x20through\x20the\x20caller\x20mechanism\x20(any\x20locale\x20works;\x20translation\x20happens\x20in\x20the\x20caller,\x20never\x20in\x20keyword\x20tables):\x20produce\x20a\x20semantic_ir\x20carrying\x20discovery.english_summary\x20(an\x20English\x20restatement\x20of\x20the\x20intent),\x20discovery.tags\x20(each\x20from\x20template_list.discovery_vocabulary)\x20and\x20discovery.product_ref\x20(a\x20benchmark-product\x20slug),\x20with\x20every\x20evidence\x20quote\x20verbatim\x20in\x20the\x20description\x20—\x20then\x20re-run\x20migration_plan.\x20Only\x20call\x20action=\x27migration_apply\x27\x20with\x20template_id=\x27'+am+'\x27\x20after\x20the\x20user\x20approves\x20THAT\x20template.'+av:'Surface\x20the\x20'+aj['length']+'\x20unmapped\x20and\x20'+ak['length']+'\x20manual_review\x20items'+(al['passed']===!![]?'':'\x20plus\x20the\x20risk_check\x20findings')+'\x20to\x20the\x20user\x20for\x20a\x20decision\x20before\x20action=\x27migration_apply\x27\x20(template_id=\x27'+am+'\x27).'+av};break;}case'migration_apply':{const ax=requireTemplate(b['template_id'],'migration_apply'),ay=scanTemplate(ax);assertScanPassed(ay,'migration_apply');const az=b['network']??'testnet',aA=await runGuide(ax,b['description'],b['fee_overrides'],b['guard_resolutions'],{'review_mode':b['review_mode'],'reward_funding':b['reward_funding'],'reward_claim_amount':b['reward_claim_amount'],'after_sales_mode':b['after_sales_mode'],'acceptance_mode':b['acceptance_mode'],'installment_mode':b['installment_mode'],'affiliate_mode':b['affiliate_mode'],'crowdfunding_mode':b['crowdfunding_mode']},b['sales'],d?.['ir']);f=((()=>{const aB=scanSummary(ay,driftFace(ax['id'])),aC=staleBuildFace(),aD=buildVerdict(aB,aA,undefined,aC),aE=wipAnchorFace(b['sales']);return{'action':'migration_apply','template_id':ax['id'],'network':az,...e,'scan':aB,'plan':aA,'verdict':aD,...aE?{'wip_anchor':aE}:{},'next_action':planNextAction(aA,'migration_apply',aD,aC)};})());break;}default:throw new Error('Unknown\x20benchmark_migration_operation\x20action:\x20'+String(b['action']));}return{'content':[{'type':'text','text':JSON['stringify']({'result':f})}],'structuredContent':{'result':f}};}
@@ -12,9 +12,14 @@ export declare function warnMerchantCompensationFundLow(data: any, network: stri
12
12
  }>;
13
13
  structuredContent: Record<string, unknown>;
14
14
  } | undefined>;
15
+ export declare function checkUmContactHasIm(umRef: string, network: string | undefined): Promise<ToolDispatchResult | undefined>;
15
16
  export declare function deriveTotalPayIfOmitted(data: any, network: unknown): Promise<string | undefined>;
16
17
  export declare function warnOrderNewFundCoverage(data: any, network: unknown): Promise<string | null>;
17
18
  export declare function warnBuyCustomerRequiredSelfAttested(data: any, network: unknown): Promise<string | null>;
19
+ export declare function resolveOrderNewSaleRefs(data: any, network: unknown): Promise<{
20
+ note?: string;
21
+ block?: ToolDispatchResult;
22
+ } | undefined>;
18
23
  export declare function warnBuyGuardTimeCutoff(data: any, network: unknown): Promise<string | null>;
19
24
  export declare function gateServiceBuyGuardMount(data: any, network: unknown): Promise<ToolDispatchResult | null>;
20
25
  export declare function parseTotalPayRaw(buy: any): bigint | undefined;
@@ -37,6 +42,11 @@ export declare function arbClaimEscrowEmptyDualPayout(inputs: {
37
42
  poolValue?: number;
38
43
  acknowledged: boolean;
39
44
  }): "refuse" | "acknowledged" | null;
45
+ export declare function dualPayoutReleaseGuidance(inputs: {
46
+ allocAddr?: string;
47
+ indemnityRaw?: number;
48
+ network?: string;
49
+ }): Promise<string>;
40
50
  export declare function awardPoolCapacityPosture(inputs: {
41
51
  indemnity: number;
42
52
  pool?: number;