@wowok/agent-mcp 3.0.2 → 3.0.4

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 (322) hide show
  1. package/LICENSE +0 -3
  2. package/dist/harness/recover.js +1 -1
  3. package/dist/index.d.ts +2 -2
  4. package/dist/index.js +1 -1
  5. package/dist/knowledge/account-marks.js +1 -1
  6. package/dist/knowledge/arbitration-risk.js +1 -1
  7. package/dist/knowledge/event-semantics.js +1 -1
  8. package/dist/knowledge/flywheel-loop.d.ts +4 -52
  9. package/dist/knowledge/flywheel-loop.js +1 -1
  10. package/dist/knowledge/guard-lint.js +1 -1
  11. package/dist/knowledge/guard-puzzle.js +1 -1
  12. package/dist/knowledge/index.d.ts +2 -225
  13. package/dist/knowledge/index.js +1 -1
  14. package/dist/knowledge/industry-registry.js +1 -1
  15. package/dist/knowledge/machine-risk.js +1 -1
  16. package/dist/knowledge/machine-translation.js +1 -1
  17. package/dist/knowledge/onchain-constants.js +1 -1
  18. package/dist/knowledge/order-ledger.d.ts +2 -2
  19. package/dist/knowledge/order-ledger.js +1 -1
  20. package/dist/knowledge/order-puzzle.d.ts +4 -4
  21. package/dist/knowledge/order-puzzle.js +1 -1
  22. package/dist/knowledge/order-risk.d.ts +1 -0
  23. package/dist/knowledge/order-risk.js +1 -1
  24. package/dist/knowledge/order-templates.d.ts +1 -1
  25. package/dist/knowledge/order-templates.js +1 -1
  26. package/dist/knowledge/safety-rules.js +1 -1
  27. package/dist/knowledge/service-ledger.js +1 -1
  28. package/dist/knowledge/service-risk.js +1 -1
  29. package/dist/knowledge/template-registry.js +1 -1
  30. package/dist/knowledge/tools-reference.js +1 -1
  31. package/dist/knowledge/workspace-lists.js +1 -1
  32. package/dist/monitor/MonitorLoop.js +1 -1
  33. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  34. package/dist/playbooks/service-build/context-assembly.d.ts +3 -1
  35. package/dist/playbooks/service-build/context-assembly.js +1 -1
  36. package/dist/playbooks/service-build/machine-nodes.d.ts +2 -0
  37. package/dist/playbooks/service-build/machine-nodes.js +1 -1
  38. package/dist/playbooks/service-build/machine-panorama.d.ts +7 -0
  39. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  40. package/dist/review/machine.js +1 -1
  41. package/dist/safety/confirm-gate.js +1 -1
  42. package/dist/schema/call/allocation.d.ts +5 -0
  43. package/dist/schema/call/arbitration.d.ts +5 -0
  44. package/dist/schema/call/base.d.ts +17 -3
  45. package/dist/schema/call/base.js +1 -1
  46. package/dist/schema/call/bridge.d.ts +29 -0
  47. package/dist/schema/call/bridge.js +1 -1
  48. package/dist/schema/call/contact.d.ts +5 -0
  49. package/dist/schema/call/demand.d.ts +5 -0
  50. package/dist/schema/call/error-codes.d.ts +2 -0
  51. package/dist/schema/call/error-codes.js +1 -0
  52. package/dist/schema/call/guard.d.ts +19 -4
  53. package/dist/schema/call/machine.d.ts +10 -0
  54. package/dist/schema/call/order.d.ts +5 -0
  55. package/dist/schema/call/payment.d.ts +5 -0
  56. package/dist/schema/call/permission.d.ts +5 -0
  57. package/dist/schema/call/personal.d.ts +5 -0
  58. package/dist/schema/call/progress.d.ts +5 -0
  59. package/dist/schema/call/proof.d.ts +10 -0
  60. package/dist/schema/call/repository.d.ts +5 -0
  61. package/dist/schema/call/reward.d.ts +5 -0
  62. package/dist/schema/call/semantic.d.ts +9 -1
  63. package/dist/schema/call/semantic.js +1 -1
  64. package/dist/schema/call/service.d.ts +5 -0
  65. package/dist/schema/call/treasury.d.ts +5 -0
  66. package/dist/schema/common/index.js +1 -1
  67. package/dist/schema/goal/index.d.ts +3 -3
  68. package/dist/schema/goal/planning.d.ts +2 -2
  69. package/dist/schema/index.d.ts +1 -0
  70. package/dist/schema/index.js +1 -1
  71. package/dist/schema/industry-pack/index.d.ts +4 -4
  72. package/dist/schema/industry-pack/modes.d.ts +4 -4
  73. package/dist/schema/interaction/index.d.ts +34 -0
  74. package/dist/schema/interaction/index.js +1 -0
  75. package/dist/schema/local/index.d.ts +558 -0
  76. package/dist/schema/local/index.js +1 -1
  77. package/dist/schema/messenger/index.d.ts +31 -25
  78. package/dist/schema/messenger/index.js +1 -1
  79. package/dist/schema/operations.d.ts +91 -1
  80. package/dist/schema/operations.js +1 -1
  81. package/dist/schema/persona/index.d.ts +2 -2
  82. package/dist/schema/query/bi.d.ts +0 -4
  83. package/dist/schema/query/bi.js +1 -1
  84. package/dist/schema/query/index.js +1 -1
  85. package/dist/schema/schema-query/index.d.ts +1 -1
  86. package/dist/schema/schema-version.js +1 -1
  87. package/dist/schema/trust/index.d.ts +3 -3
  88. package/dist/schema/workspace/index.d.ts +1 -1
  89. package/dist/schema-query-impl/index.js +1 -1
  90. package/dist/schemas/account_operation.output.json +4 -0
  91. package/dist/schemas/ask_user.output.json +54 -0
  92. package/dist/schemas/ask_user.schema.json +78 -0
  93. package/dist/schemas/bridge_operation.output.json +4 -0
  94. package/dist/schemas/bridge_operation.schema.json +50 -5
  95. package/dist/schemas/guard2file.schema.json +10 -1
  96. package/dist/schemas/index.json +13 -1
  97. package/dist/schemas/local_history_operation.output.json +1458 -0
  98. package/dist/schemas/local_history_operation.schema.json +105 -0
  99. package/dist/schemas/local_info_operation.output.json +4 -0
  100. package/dist/schemas/local_mark_operation.output.json +4 -0
  101. package/dist/schemas/machineNode2file.schema.json +10 -1
  102. package/dist/schemas/messenger_operation.output.json +8 -0
  103. package/dist/schemas/messenger_operation.schema.json +8 -0
  104. package/dist/schemas/onchain_events.output.json +2 -2
  105. package/dist/schemas/onchain_operations.output.json +4 -1
  106. package/dist/schemas/onchain_operations.schema.json +210 -28
  107. package/dist/schemas/onchain_operations_allocation.schema.json +10 -1
  108. package/dist/schemas/onchain_operations_arbitration.schema.json +10 -1
  109. package/dist/schemas/onchain_operations_contact.schema.json +10 -1
  110. package/dist/schemas/onchain_operations_demand.schema.json +10 -1
  111. package/dist/schemas/onchain_operations_gen_passport.schema.json +10 -1
  112. package/dist/schemas/onchain_operations_gen_proof.schema.json +10 -1
  113. package/dist/schemas/onchain_operations_guard.schema.json +40 -11
  114. package/dist/schemas/onchain_operations_machine.schema.json +10 -1
  115. package/dist/schemas/onchain_operations_order.schema.json +10 -1
  116. package/dist/schemas/onchain_operations_payment.schema.json +10 -1
  117. package/dist/schemas/onchain_operations_permission.schema.json +10 -1
  118. package/dist/schemas/onchain_operations_personal.schema.json +10 -1
  119. package/dist/schemas/onchain_operations_progress.schema.json +10 -1
  120. package/dist/schemas/onchain_operations_proof.schema.json +10 -1
  121. package/dist/schemas/onchain_operations_repository.schema.json +10 -1
  122. package/dist/schemas/onchain_operations_reward.schema.json +10 -1
  123. package/dist/schemas/onchain_operations_service.schema.json +10 -1
  124. package/dist/schemas/onchain_operations_treasury.schema.json +10 -1
  125. package/dist/schemas/query_toolkit.output.json +17 -16
  126. package/dist/schemas/query_toolkit.schema.json +1 -1
  127. package/dist/tools/handlers/ask-user.d.ts +3 -0
  128. package/dist/tools/handlers/ask-user.js +1 -0
  129. package/dist/tools/handlers/config.js +1 -1
  130. package/dist/tools/handlers/local.d.ts +1 -0
  131. package/dist/tools/handlers/local.js +1 -1
  132. package/dist/tools/handlers/messenger.js +1 -1
  133. package/dist/tools/handlers/onchain.js +1 -1
  134. package/dist/tools/index.d.ts +2 -2
  135. package/dist/tools/index.js +1 -1
  136. package/dist/tools/registry/bridge.js +1 -1
  137. package/dist/tools/registry/business.js +1 -1
  138. package/dist/tools/registry/interaction.d.ts +2 -0
  139. package/dist/tools/registry/interaction.js +1 -0
  140. package/dist/tools/registry/local.js +1 -1
  141. package/dist/tools/registry/monitor.js +1 -1
  142. package/dist/tools/registry/onchain.js +1 -1
  143. package/dist/tools/registry/query.js +1 -1
  144. package/dist/tools/shared.js +1 -1
  145. package/dist/tools/types.d.ts +7 -1
  146. package/dist/tools/wrap.d.ts +3 -3
  147. package/dist/tools/wrap.js +1 -1
  148. package/package.json +2 -2
  149. package/dist/knowledge/allocation-confirm.d.ts +0 -115
  150. package/dist/knowledge/allocation-confirm.js +0 -1
  151. package/dist/knowledge/allocation-context.d.ts +0 -58
  152. package/dist/knowledge/allocation-context.js +0 -1
  153. package/dist/knowledge/allocation-translation.d.ts +0 -72
  154. package/dist/knowledge/allocation-translation.js +0 -1
  155. package/dist/knowledge/arb-confirm.d.ts +0 -28
  156. package/dist/knowledge/arb-confirm.js +0 -1
  157. package/dist/knowledge/arb-translation.d.ts +0 -48
  158. package/dist/knowledge/arb-translation.js +0 -1
  159. package/dist/knowledge/arbitration-confirm.d.ts +0 -135
  160. package/dist/knowledge/arbitration-confirm.js +0 -1
  161. package/dist/knowledge/arbitration-context.d.ts +0 -81
  162. package/dist/knowledge/arbitration-context.js +0 -1
  163. package/dist/knowledge/arbitration-translation.d.ts +0 -91
  164. package/dist/knowledge/arbitration-translation.js +0 -1
  165. package/dist/knowledge/bridge-confirm.d.ts +0 -26
  166. package/dist/knowledge/bridge-confirm.js +0 -1
  167. package/dist/knowledge/bridge-translation.d.ts +0 -37
  168. package/dist/knowledge/bridge-translation.js +0 -1
  169. package/dist/knowledge/contact-confirm.d.ts +0 -27
  170. package/dist/knowledge/contact-confirm.js +0 -1
  171. package/dist/knowledge/contact-translation.d.ts +0 -39
  172. package/dist/knowledge/contact-translation.js +0 -1
  173. package/dist/knowledge/demand-confirm.d.ts +0 -32
  174. package/dist/knowledge/demand-confirm.js +0 -1
  175. package/dist/knowledge/demand-context.d.ts +0 -17
  176. package/dist/knowledge/demand-context.js +0 -1
  177. package/dist/knowledge/demand-ledger.d.ts +0 -26
  178. package/dist/knowledge/demand-ledger.js +0 -1
  179. package/dist/knowledge/demand-puzzle.d.ts +0 -29
  180. package/dist/knowledge/demand-puzzle.js +0 -1
  181. package/dist/knowledge/demand-templates.d.ts +0 -12
  182. package/dist/knowledge/demand-templates.js +0 -1
  183. package/dist/knowledge/demand-translation.d.ts +0 -55
  184. package/dist/knowledge/demand-translation.js +0 -1
  185. package/dist/knowledge/examples-scanner-cli.d.ts +0 -1
  186. package/dist/knowledge/examples-scanner-cli.js +0 -1
  187. package/dist/knowledge/examples-scanner.d.ts +0 -121
  188. package/dist/knowledge/examples-scanner.js +0 -1
  189. package/dist/knowledge/glossary.d.ts +0 -18
  190. package/dist/knowledge/glossary.js +0 -1
  191. package/dist/knowledge/guard-bytecode-spec.d.ts +0 -82
  192. package/dist/knowledge/guard-bytecode-spec.js +0 -1
  193. package/dist/knowledge/guard-confirm.d.ts +0 -86
  194. package/dist/knowledge/guard-confirm.js +0 -1
  195. package/dist/knowledge/immutability.d.ts +0 -11
  196. package/dist/knowledge/immutability.js +0 -1
  197. package/dist/knowledge/machine-confirm.d.ts +0 -102
  198. package/dist/knowledge/machine-confirm.js +0 -1
  199. package/dist/knowledge/machine-context.d.ts +0 -160
  200. package/dist/knowledge/machine-context.js +0 -1
  201. package/dist/knowledge/machine-render.d.ts +0 -41
  202. package/dist/knowledge/machine-render.js +0 -1
  203. package/dist/knowledge/mcp-schema-audit-cli.d.ts +0 -1
  204. package/dist/knowledge/mcp-schema-audit-cli.js +0 -1
  205. package/dist/knowledge/mcp-schema-audit.d.ts +0 -91
  206. package/dist/knowledge/mcp-schema-audit.js +0 -1
  207. package/dist/knowledge/messenger-guard-guidance.d.ts +0 -17
  208. package/dist/knowledge/messenger-guard-guidance.js +0 -1
  209. package/dist/knowledge/order-confirm.d.ts +0 -115
  210. package/dist/knowledge/order-confirm.js +0 -1
  211. package/dist/knowledge/order-context.d.ts +0 -66
  212. package/dist/knowledge/order-context.js +0 -1
  213. package/dist/knowledge/order-translation.d.ts +0 -78
  214. package/dist/knowledge/order-translation.js +0 -1
  215. package/dist/knowledge/overrides-loader.d.ts +0 -13
  216. package/dist/knowledge/overrides-loader.js +0 -1
  217. package/dist/knowledge/passport-confirm.d.ts +0 -130
  218. package/dist/knowledge/passport-confirm.js +0 -1
  219. package/dist/knowledge/passport-context.d.ts +0 -59
  220. package/dist/knowledge/passport-context.js +0 -1
  221. package/dist/knowledge/passport-puzzle.d.ts +0 -108
  222. package/dist/knowledge/passport-puzzle.js +0 -1
  223. package/dist/knowledge/passport-risk.d.ts +0 -70
  224. package/dist/knowledge/passport-risk.js +0 -1
  225. package/dist/knowledge/passport-translation.d.ts +0 -68
  226. package/dist/knowledge/passport-translation.js +0 -1
  227. package/dist/knowledge/payment-confirm.d.ts +0 -26
  228. package/dist/knowledge/payment-confirm.js +0 -1
  229. package/dist/knowledge/payment-translation.d.ts +0 -37
  230. package/dist/knowledge/payment-translation.js +0 -1
  231. package/dist/knowledge/permission-confirm.d.ts +0 -110
  232. package/dist/knowledge/permission-confirm.js +0 -1
  233. package/dist/knowledge/permission-context.d.ts +0 -69
  234. package/dist/knowledge/permission-context.js +0 -1
  235. package/dist/knowledge/permission-translation.d.ts +0 -57
  236. package/dist/knowledge/permission-translation.js +0 -1
  237. package/dist/knowledge/personal-confirm.d.ts +0 -29
  238. package/dist/knowledge/personal-confirm.js +0 -1
  239. package/dist/knowledge/personal-translation.d.ts +0 -37
  240. package/dist/knowledge/personal-translation.js +0 -1
  241. package/dist/knowledge/process-model.d.ts +0 -14
  242. package/dist/knowledge/process-model.js +0 -1
  243. package/dist/knowledge/progress-confirm.d.ts +0 -108
  244. package/dist/knowledge/progress-confirm.js +0 -1
  245. package/dist/knowledge/progress-context.d.ts +0 -123
  246. package/dist/knowledge/progress-context.js +0 -1
  247. package/dist/knowledge/progress-translation.d.ts +0 -52
  248. package/dist/knowledge/progress-translation.js +0 -1
  249. package/dist/knowledge/proof-confirm.d.ts +0 -31
  250. package/dist/knowledge/proof-confirm.js +0 -1
  251. package/dist/knowledge/proof-context.d.ts +0 -17
  252. package/dist/knowledge/proof-context.js +0 -1
  253. package/dist/knowledge/proof-ledger.d.ts +0 -34
  254. package/dist/knowledge/proof-ledger.js +0 -1
  255. package/dist/knowledge/proof-puzzle.d.ts +0 -35
  256. package/dist/knowledge/proof-puzzle.js +0 -1
  257. package/dist/knowledge/proof-templates.d.ts +0 -22
  258. package/dist/knowledge/proof-templates.js +0 -1
  259. package/dist/knowledge/proof-translation.d.ts +0 -52
  260. package/dist/knowledge/proof-translation.js +0 -1
  261. package/dist/knowledge/registrar-confirm.d.ts +0 -26
  262. package/dist/knowledge/registrar-confirm.js +0 -1
  263. package/dist/knowledge/registrar-translation.d.ts +0 -37
  264. package/dist/knowledge/registrar-translation.js +0 -1
  265. package/dist/knowledge/repository-confirm.d.ts +0 -40
  266. package/dist/knowledge/repository-confirm.js +0 -1
  267. package/dist/knowledge/repository-context.d.ts +0 -12
  268. package/dist/knowledge/repository-context.js +0 -1
  269. package/dist/knowledge/repository-ledger.d.ts +0 -25
  270. package/dist/knowledge/repository-ledger.js +0 -1
  271. package/dist/knowledge/repository-puzzle.d.ts +0 -30
  272. package/dist/knowledge/repository-puzzle.js +0 -1
  273. package/dist/knowledge/repository-templates.d.ts +0 -14
  274. package/dist/knowledge/repository-templates.js +0 -1
  275. package/dist/knowledge/repository-translation.d.ts +0 -58
  276. package/dist/knowledge/repository-translation.js +0 -1
  277. package/dist/knowledge/resource-confirm.d.ts +0 -25
  278. package/dist/knowledge/resource-confirm.js +0 -1
  279. package/dist/knowledge/resource-translation.d.ts +0 -37
  280. package/dist/knowledge/resource-translation.js +0 -1
  281. package/dist/knowledge/reward-confirm.d.ts +0 -116
  282. package/dist/knowledge/reward-confirm.js +0 -1
  283. package/dist/knowledge/reward-context.d.ts +0 -127
  284. package/dist/knowledge/reward-context.js +0 -1
  285. package/dist/knowledge/reward-translation.d.ts +0 -58
  286. package/dist/knowledge/reward-translation.js +0 -1
  287. package/dist/knowledge/service-confirm.d.ts +0 -161
  288. package/dist/knowledge/service-confirm.js +0 -1
  289. package/dist/knowledge/service-context.d.ts +0 -66
  290. package/dist/knowledge/service-context.js +0 -1
  291. package/dist/knowledge/service-translation.d.ts +0 -103
  292. package/dist/knowledge/service-translation.js +0 -1
  293. package/dist/knowledge/treasury-confirm.d.ts +0 -133
  294. package/dist/knowledge/treasury-confirm.js +0 -1
  295. package/dist/knowledge/treasury-context.d.ts +0 -64
  296. package/dist/knowledge/treasury-context.js +0 -1
  297. package/dist/knowledge/treasury-translation.d.ts +0 -78
  298. package/dist/knowledge/treasury-translation.js +0 -1
  299. package/dist/knowledge/util-confirm.d.ts +0 -24
  300. package/dist/knowledge/util-confirm.js +0 -1
  301. package/dist/knowledge/util-translation.d.ts +0 -39
  302. package/dist/knowledge/util-translation.js +0 -1
  303. package/dist/loop-engineering/aggregate.d.ts +0 -50
  304. package/dist/loop-engineering/aggregate.js +0 -1
  305. package/dist/loop-engineering/context-collect.d.ts +0 -7
  306. package/dist/loop-engineering/context-collect.js +0 -1
  307. package/dist/loop-engineering/diagnose.d.ts +0 -22
  308. package/dist/loop-engineering/diagnose.js +0 -1
  309. package/dist/loop-engineering/improve.d.ts +0 -55
  310. package/dist/loop-engineering/improve.js +0 -1
  311. package/dist/loop-engineering/index.d.ts +0 -4
  312. package/dist/loop-engineering/index.js +0 -1
  313. package/dist/loop-engineering/pipeline.d.ts +0 -17
  314. package/dist/loop-engineering/pipeline.js +0 -1
  315. package/dist/schema/utils/object-type-utils.d.ts +0 -12
  316. package/dist/schema/utils/object-type-utils.js +0 -1
  317. package/dist/telemetry/index.d.ts +0 -19
  318. package/dist/telemetry/index.js +0 -1
  319. package/dist/telemetry/redact.d.ts +0 -2
  320. package/dist/telemetry/redact.js +0 -1
  321. package/dist/telemetry/storage.d.ts +0 -8
  322. package/dist/telemetry/storage.js +0 -1
@@ -1,161 +0,0 @@
1
- import { type ServiceRiskAssessment } from "./service-risk.js";
2
- export type ServiceConfirmGateStatus = "approved" | "blocked_checklist" | "blocked_risk" | "blocked_user" | "blocked_environment";
3
- export interface ServiceConfirmGateResult {
4
- status: ServiceConfirmGateStatus;
5
- checklist_result: ServiceChecklistResult;
6
- risk_result?: ServiceRiskAssessment;
7
- user_confirmation?: ServiceUserConfirmation;
8
- environment_result?: ServiceEnvironmentResult;
9
- confirmation_text?: string;
10
- block_reason?: string;
11
- decision_record: ServiceDecisionRecord;
12
- }
13
- export interface ServiceChecklistResult {
14
- all_passed: boolean;
15
- items: ServiceChecklistItem[];
16
- }
17
- export interface ServiceChecklistItem {
18
- id: string;
19
- description: string;
20
- passed: boolean;
21
- message: string;
22
- }
23
- export interface ServiceUserConfirmation {
24
- questions_asked: ServiceConfirmationQuestion[];
25
- responses: ServiceConfirmationResponse[];
26
- all_confirmed: boolean;
27
- }
28
- export interface ServiceConfirmationQuestion {
29
- id: string;
30
- question: string;
31
- requires_explicit_yes: boolean;
32
- related_risk_ids?: string[];
33
- }
34
- export interface ServiceConfirmationResponse {
35
- question_id: string;
36
- response: "yes" | "no" | "skip";
37
- }
38
- export type ServiceEnvironmentCheckLevel = "block" | "warning" | "info";
39
- export interface ServiceEnvironmentCheck {
40
- name: string;
41
- passed: boolean;
42
- message: string;
43
- level?: ServiceEnvironmentCheckLevel;
44
- }
45
- export interface ServiceEnvironmentResult {
46
- passed: boolean;
47
- checks: ServiceEnvironmentCheck[];
48
- warnings_count: number;
49
- infos_count: number;
50
- }
51
- export interface ServiceDecisionRecord {
52
- timestamp: string;
53
- gate_version: string;
54
- final_status: ServiceConfirmGateStatus;
55
- layers_passed: string[];
56
- layers_failed: string[];
57
- }
58
- export interface ServiceJsonForConfirm {
59
- object?: string | null;
60
- description?: string;
61
- location?: string;
62
- customer_required?: string[];
63
- sales?: {
64
- op: "add" | "set";
65
- sales: Array<{
66
- name: string;
67
- price?: string;
68
- stock?: number;
69
- wip?: string;
70
- wip_hash?: string;
71
- }>;
72
- } | {
73
- op: "remove";
74
- sales_name: string[];
75
- } | {
76
- op: "clear";
77
- };
78
- machine?: string | null;
79
- buy_guard?: string | null;
80
- arbitrations?: {
81
- op: "add" | "set" | "remove";
82
- objects: string[];
83
- } | {
84
- op: "clear";
85
- };
86
- repositories?: {
87
- op: "add" | "set" | "remove";
88
- objects: string[];
89
- } | {
90
- op: "clear";
91
- };
92
- rewards?: {
93
- op: "add" | "set" | "remove";
94
- objects: string[];
95
- } | {
96
- op: "clear";
97
- };
98
- order_allocators?: unknown;
99
- discount?: {
100
- name: string;
101
- discount_type: number;
102
- data: number;
103
- count: number;
104
- receivers?: string[];
105
- expire_at?: number;
106
- };
107
- pause?: boolean;
108
- publish?: boolean;
109
- compensation_fund_add?: {
110
- balance: string | number;
111
- };
112
- compensation_fund_withdraw?: unknown;
113
- compensation_fund_receive?: unknown;
114
- setting_lock_duration_add?: number;
115
- order_new?: {
116
- buy: {
117
- items: Array<{
118
- name: string;
119
- wip_hash: string;
120
- count: number;
121
- }>;
122
- discount?: string;
123
- total_pay: string;
124
- };
125
- };
126
- builder?: string;
127
- um?: string | null;
128
- owner_receive?: unknown;
129
- }
130
- export interface ServiceConfirmGateInput {
131
- service_json: ServiceJsonForConfirm;
132
- intent?: string;
133
- target_objects_types?: string[];
134
- current_bPublished?: boolean;
135
- current_bPaused?: boolean;
136
- current_compensation_fund_balance?: string;
137
- current_setting_lock_duration?: string;
138
- current_arbitrations_count?: number;
139
- current_rewards_count?: number;
140
- current_repositories_count?: number;
141
- current_sales_count?: number;
142
- current_machine_bound?: boolean;
143
- current_order_allocators_set?: boolean;
144
- skip_user_confirmation?: boolean;
145
- skip_environment_check?: boolean;
146
- current_machine_node_count?: number;
147
- current_machine_initial_forward_ok?: boolean;
148
- current_machine_bPublished?: boolean;
149
- current_arbitrators_authorized?: boolean;
150
- }
151
- export declare const SERVICE_PUBLISH_CHECKLIST: ServiceChecklistItem[];
152
- export declare const SERVICE_CONFIRMATION_QUESTIONS: ServiceConfirmationQuestion[];
153
- export declare const SERVICE_CONFIRM_VERSION = "1.0.0";
154
- export declare function runServiceConfirmGate(input: ServiceConfirmGateInput): ServiceConfirmGateResult;
155
- export interface ServiceProgressiveCheckResult {
156
- stage: "checklist" | "risk" | "confirmation" | "environment" | "complete";
157
- status: "pass" | "fail" | "pending";
158
- message: string;
159
- next_action?: string;
160
- }
161
- export declare function progressiveServiceCheck(input: ServiceConfirmGateInput): ServiceProgressiveCheckResult;
@@ -1 +0,0 @@
1
- import{MAX_SALE_COUNT,MAX_REPOSITORY_COUNT,MAX_ARBITRATION_COUNT,MAX_DISCOUNT_COUNT_ONCE,MAX_DISCOUNT_TOTAL_COUNT,MAX_WIP_LENGTH,MAX_WIP_HASH_LENGTH}from'@wowok/wowok';import{assessServiceRisks}from'./service-risk.js';export const SERVICE_PUBLISH_CHECKLIST=[{'id':'C-S-01','description':'Sales\x20count\x20<=\x20MAX_SALE_COUNT\x20(50)','passed':![],'message':''},{'id':'C-S-02','description':'Repositories\x20count\x20<=\x20MAX_REPOSITORY_COUNT\x20(100)','passed':![],'message':''},{'id':'C-S-03','description':'Arbitrations\x20count\x20<=\x20MAX_ARBITRATION_COUNT\x20(20)','passed':![],'message':''},{'id':'C-S-04','description':'Rewards\x20count\x20<=\x20MAX_REWARD_COUNT\x20(20)','passed':![],'message':''},{'id':'C-S-05','description':'WIP\x20URL\x20length\x20<=\x20MAX_WIP_LENGTH\x20(1024)\x20for\x20each\x20sale','passed':![],'message':''},{'id':'C-S-06','description':'WIP\x20hash\x20length\x20<=\x20MAX_WIP_HASH_LENGTH\x20(64)\x20—\x20sha256\x20hex','passed':![],'message':''},{'id':'C-S-07','description':'WIP\x20hash\x20NOT\x20empty\x20when\x20wip\x20URL\x20is\x20set\x20(tamper\x20protection)','passed':![],'message':''},{'id':'C-S-08','description':'Discount\x20count\x20<=\x20MAX_DISCOUNT_TOTAL_COUNT\x20(20000)','passed':![],'message':''},{'id':'C-S-09','description':'Discount\x20per-call\x20<=\x20MAX_DISCOUNT_COUNT_ONCE\x20(1000)','passed':![],'message':''},{'id':'C-S-10','description':'Publish:\x20order_allocators\x20MUST\x20be\x20set\x20(F-S-18,\x20E_NO_ALLOCATOR)','passed':![],'message':''},{'id':'C-S-11','description':'Publish:\x20if\x20compensation_fund\x20>\x200,\x20arbitrations\x20non-empty\x20(F-S-19)','passed':![],'message':''},{'id':'C-S-12','description':'Post-publish:\x20machine\x20modification\x20BLOCKED\x20(F-S-20)','passed':![],'message':''},{'id':'C-S-13','description':'Post-publish:\x20arbitrations\x20modification\x20BLOCKED\x20(F-S-21)','passed':![],'message':''},{'id':'C-S-14','description':'Post-publish:\x20order_allocators\x20modification\x20BLOCKED\x20(F-S-22)','passed':![],'message':''},{'id':'C-S-15','description':'compensation_fund_withdraw\x20requires\x20bPaused=true\x20+\x20lock_duration\x20expired\x20(F-S-25,\x20F-S-26)','passed':![],'message':''},{'id':'C-S-16','description':'Address\x20fields\x20valid\x20(0x\x20prefix,\x20length\x20>=\x2040)','passed':![],'message':''},{'id':'C-S-17','description':'Publish\x20operation\x20double-confirmed\x20(bPublished\x20irreversible)','passed':![],'message':''},{'id':'C-S-18','description':'Ownership\x20transfer\x20double-confirmed\x20(IRREVERSIBLE)','passed':![],'message':''},{'id':'C-S-19','description':'Publish:\x20arbitrations\x20strongly\x20recommended\x20(cannot\x20add\x20post-publish,\x20F-S-21)','passed':![],'message':''}];function runStaticChecklist(a){const b=SERVICE_PUBLISH_CHECKLIST['map'](h=>({...h})),c=a['service_json'],d=a['current_bPublished']??![];if(c['sales']&&(c['sales']['op']==='add'||c['sales']['op']==='set')){const h=a['current_sales_count']??0x0,i=c['sales']['op']==='set'?c['sales']['sales']['length']:h+c['sales']['sales']['length'],j=b['find'](k=>k['id']==='C-S-01');j['passed']=i<=MAX_SALE_COUNT,j['message']=j['passed']?'':'sales\x20count\x20'+i+'\x20>\x20'+MAX_SALE_COUNT;}else b['find'](k=>k['id']==='C-S-01')['passed']=!![];if(c['repositories']&&(c['repositories']['op']==='add'||c['repositories']['op']==='set')){const k=a['current_repositories_count']??0x0,l=c['repositories']['op']==='set'?c['repositories']['objects']['length']:k+c['repositories']['objects']['length'],m=b['find'](n=>n['id']==='C-S-02');m['passed']=l<=MAX_REPOSITORY_COUNT,m['message']=m['passed']?'':'repositories\x20count\x20'+l+'\x20>\x20'+MAX_REPOSITORY_COUNT;}else b['find'](n=>n['id']==='C-S-02')['passed']=!![];if(c['arbitrations']&&(c['arbitrations']['op']==='add'||c['arbitrations']['op']==='set')){const n=a['current_arbitrations_count']??0x0,o=c['arbitrations']['op']==='set'?c['arbitrations']['objects']['length']:n+c['arbitrations']['objects']['length'],p=b['find'](q=>q['id']==='C-S-03');p['passed']=o<=MAX_ARBITRATION_COUNT,p['message']=p['passed']?'':'arbitrations\x20count\x20'+o+'\x20>\x20'+MAX_ARBITRATION_COUNT;}else b['find'](q=>q['id']==='C-S-03')['passed']=!![];if(c['rewards']&&(c['rewards']['op']==='add'||c['rewards']['op']==='set')){const q=a['current_rewards_count']??0x0,r=c['rewards']['op']==='set'?c['rewards']['objects']['length']:q+c['rewards']['objects']['length'],t=b['find'](u=>u['id']==='C-S-04');t['passed']=r<=0x14,t['message']=t['passed']?'':'rewards\x20count\x20'+r+'\x20>\x2020';}else b['find'](u=>u['id']==='C-S-04')['passed']=!![];if(c['sales']&&(c['sales']['op']==='add'||c['sales']['op']==='set')){let u=!![],v=!![],w=!![],x='',y='',z='';for(const D of c['sales']['sales']){if(D['wip']&&D['wip']['length']>MAX_WIP_LENGTH){u=![],x='sale\x20\x22'+D['name']+'\x22\x20wip\x20URL\x20length\x20'+D['wip']['length']+'\x20>\x20'+MAX_WIP_LENGTH;break;}if(D['wip_hash']&&D['wip_hash']['length']>MAX_WIP_HASH_LENGTH){v=![],y='sale\x20\x22'+D['name']+'\x22\x20wip_hash\x20length\x20'+D['wip_hash']['length']+'\x20>\x20'+MAX_WIP_HASH_LENGTH;break;}if(D['wip']&&!D['wip_hash']){w=![],z='sale\x20\x22'+D['name']+'\x22\x20has\x20wip\x20URL\x20but\x20no\x20wip_hash\x20(tamper\x20risk)';break;}}const A=b['find'](E=>E['id']==='C-S-05');A['passed']=u,A['message']=x;const B=b['find'](E=>E['id']==='C-S-06');B['passed']=v,B['message']=y;const C=b['find'](E=>E['id']==='C-S-07');C['passed']=w,C['message']=z;}else b['find'](E=>E['id']==='C-S-05')['passed']=!![],b['find'](E=>E['id']==='C-S-06')['passed']=!![],b['find'](E=>E['id']==='C-S-07')['passed']=!![];if(c['discount']){const E=c['discount']['count'],F=b['find'](H=>H['id']==='C-S-08');F['passed']=E<=MAX_DISCOUNT_TOTAL_COUNT,F['message']=F['passed']?'':'discount\x20total\x20count\x20'+E+'\x20>\x20'+MAX_DISCOUNT_TOTAL_COUNT;const G=b['find'](H=>H['id']==='C-S-09');G['passed']=E<=MAX_DISCOUNT_COUNT_ONCE,G['message']=G['passed']?'':'discount\x20per-call\x20count\x20'+E+'\x20>\x20'+MAX_DISCOUNT_COUNT_ONCE;}else b['find'](H=>H['id']==='C-S-08')['passed']=!![],b['find'](H=>H['id']==='C-S-09')['passed']=!![];if(c['publish']){const H=a['current_order_allocators_set']===!![]||c['order_allocators']!==undefined,I=b['find'](J=>J['id']==='C-S-10');I['passed']=H,I['message']=H?'':'publish\x20requires\x20order_allocators\x20(F-S-18,\x20E_NO_ALLOCATOR)';}else b['find'](J=>J['id']==='C-S-10')['passed']=!![];if(c['publish']){const J=a['current_compensation_fund_balance']??'0',K=a['current_arbitrations_count']??0x0,L=c['arbitrations']&&'objects'in c['arbitrations']?c['arbitrations']['objects']['length']:0x0,M=K+L,N=b['find'](O=>O['id']==='C-S-11');BigInt(J)>0x0n&&M===0x0?(N['passed']=![],N['message']='compensation_fund\x20'+J+'\x20>\x200\x20but\x20no\x20arbitrations\x20(F-S-19)'):N['passed']=!![];}else b['find'](O=>O['id']==='C-S-11')['passed']=!![];if(d&&c['machine']!==undefined){const O=b['find'](P=>P['id']==='C-S-12');O['passed']=![],O['message']='machine\x20is\x20IMMUTABLE\x20post-publish\x20(F-S-20)';}else b['find'](P=>P['id']==='C-S-12')['passed']=!![];if(d&&c['arbitrations']!==undefined){const P=b['find'](Q=>Q['id']==='C-S-13');P['passed']=![],P['message']='arbitrations\x20is\x20IMMUTABLE\x20post-publish\x20(F-S-21)';}else b['find'](Q=>Q['id']==='C-S-13')['passed']=!![];if(d&&c['order_allocators']!==undefined){const Q=b['find'](R=>R['id']==='C-S-14');Q['passed']=![],Q['message']='order_allocators\x20is\x20IMMUTABLE\x20post-publish\x20(F-S-22)';}else b['find'](R=>R['id']==='C-S-14')['passed']=!![];if(c['compensation_fund_withdraw']){const R=a['current_bPaused']??![],S=b['find'](T=>T['id']==='C-S-15');!R?(S['passed']=![],S['message']='compensation_fund_withdraw\x20requires\x20bPaused=true\x20(F-S-26)'):(S['passed']=!![],S['message']='Paused\x20OK\x20—\x20verify\x20lock_duration\x20expired\x20on-chain');}else b['find'](T=>T['id']==='C-S-15')['passed']=!![];const e=[];if(c['object'])e['push'](c['object']);if(c['machine'])e['push'](c['machine']);if(c['buy_guard'])e['push'](c['buy_guard']);if(c['arbitrations']&&'objects'in c['arbitrations'])e['push'](...c['arbitrations']['objects']);if(c['repositories']&&'objects'in c['repositories'])e['push'](...c['repositories']['objects']);if(c['rewards']&&'objects'in c['rewards'])e['push'](...c['rewards']['objects']);if(c['builder'])e['push'](c['builder']);if(c['um'])e['push'](c['um']);const f=b['find'](T=>T['id']==='C-S-16');if(e['length']===0x0)f['passed']=!![];else{const T=e['filter'](U=>!U['startsWith']('0x')||U['length']<0x28);f['passed']=T['length']===0x0,f['message']=T['length']===0x0?'':'Invalid\x20addresses:\x20'+T['slice'](0x0,0x3)['join'](',\x20')+(T['length']>0x3?'...':'');}if(c['publish']){const U=b['find'](V=>V['id']==='C-S-17');U['passed']=![],U['message']='Pending\x20user\x20confirmation\x20in\x20Layer\x203\x20(QS1)';}else b['find'](V=>V['id']==='C-S-17')['passed']=!![];if(c['builder']){const V=b['find'](W=>W['id']==='C-S-18');V['passed']=![],V['message']='Pending\x20user\x20confirmation\x20in\x20Layer\x203\x20(QS2)';}else b['find'](W=>W['id']==='C-S-18')['passed']=!![];if(c['publish']){const W=a['current_arbitrations_count']??0x0,X=c['arbitrations']&&'objects'in c['arbitrations']?c['arbitrations']['objects']['length']:0x0,Y=c['arbitrations']&&c['arbitrations']['op']==='clear',Z=Y?0x0:W+X,a0=b['find'](a1=>a1['id']==='C-S-19');Z===0x0?(a0['passed']=![],a0['message']='Pending\x20user\x20confirmation\x20in\x20Layer\x203\x20(QS11)\x20—\x20arbitrations\x20cannot\x20be\x20added\x20post-publish'):a0['passed']=!![];}else b['find'](a1=>a1['id']==='C-S-19')['passed']=!![];const g=b['filter'](a1=>a1['id']!=='C-S-17'&&a1['id']!=='C-S-18'&&a1['id']!=='C-S-19')['every'](a1=>a1['passed']);return{'all_passed':g,'items':b};}function adaptRiskAssessment(a){const b={'object':a['service_json']['object'],'description':a['service_json']['description'],'location':a['service_json']['location'],'sales':a['service_json']['sales'],'repositories':a['service_json']['repositories'],'rewards':a['service_json']['rewards'],'arbitrations':a['service_json']['arbitrations'],'machine':a['service_json']['machine'],'discount':a['service_json']['discount'],'customer_required':a['service_json']['customer_required'],'order_allocators':a['service_json']['order_allocators'],'buy_guard':a['service_json']['buy_guard'],'compensation_fund_add':a['service_json']['compensation_fund_add'],'setting_lock_duration_add':a['service_json']['setting_lock_duration_add'],'compensation_fund_receive':a['service_json']['compensation_fund_receive'],'owner_receive':a['service_json']['owner_receive'],'pause':a['service_json']['pause'],'publish':a['service_json']['publish'],'um':a['service_json']['um'],'order_new':a['service_json']['order_new'],'current_bPublished':a['current_bPublished'],'current_bPaused':a['current_bPaused'],'current_compensation_fund_balance':a['current_compensation_fund_balance'],'current_setting_lock_duration':a['current_setting_lock_duration'],'current_arbitrations_count':a['current_arbitrations_count'],'current_rewards_count':a['current_rewards_count'],'current_repositories_count':a['current_repositories_count'],'current_sales_count':a['current_sales_count'],'current_machine_bound':a['current_machine_bound'],'current_order_allocators_set':a['current_order_allocators_set'],'builder':a['service_json']['builder'],'target_objects_types':a['target_objects_types']};return assessServiceRisks(b);}export const SERVICE_CONFIRMATION_QUESTIONS=[{'id':'QS1','question':'⚠️\x20PUBLISH\x20is\x20IRREVERSIBLE\x20—\x20once\x20published,\x20machine/arbitrations/order_allocators\x20become\x20permanently\x20immutable.\x20Do\x20you\x20confirm\x20all\x20configurations\x20are\x20correct\x20and\x20you\x27re\x20ready\x20to\x20publish?','requires_explicit_yes':!![],'related_risk_ids':['R-S-3-01','R-S-4-01']},{'id':'QS2','question':'⚠️\x20Ownership\x20transfer\x20is\x20IRREVERSIBLE\x20—\x20original\x20owner\x20will\x20lose\x20ALL\x20control\x20over\x20the\x20Service,\x20including\x20compensation_fund\x20and\x20all\x20bindings.\x20Do\x20you\x20confirm\x20the\x20new\x20owner\x20address\x20is\x20correct?','requires_explicit_yes':!![],'related_risk_ids':['R-S-3-04']},{'id':'QS3','question':'Are\x20all\x20sales\x20items\x20configured\x20with\x20valid\x20wip_hash\x20(sha256\x20of\x20the\x20WIP\x20file\x20content)?\x20Missing\x20or\x20incorrect\x20hashes\x20create\x20tampering\x20risks.','requires_explicit_yes':!![],'related_risk_ids':['R-S-2-01']},{'id':'QS4','question':'If\x20publishing\x20with\x20compensation_fund\x20>\x200,\x20are\x20Arbitration\x20objects\x20configured\x20and\x20their\x20reputations\x20verified?\x20Owners\x20cannot\x20add\x20new\x20Arbitration\x20objects\x20post-publish.','requires_explicit_yes':!![],'related_risk_ids':['R-S-5-02']},{'id':'QS5','question':'Is\x20the\x20order_allocators\x20configuration\x20final?\x20It\x20becomes\x20PERMANENTLY\x20immutable\x20after\x20publish\x20—\x20fee\x20splits\x20cannot\x20be\x20adjusted\x20without\x20creating\x20a\x20new\x20Service.','requires_explicit_yes':!![],'related_risk_ids':['R-S-5-03','R-S-4-03']},{'id':'QS6','question':'If\x20binding\x20a\x20Machine,\x20is\x20it\x20published\x20and\x20verified?\x20Machine\x20binding\x20is\x20permanent\x20post-publish\x20—\x20Progress\x20objects\x20will\x20inherit\x20this\x20Machine\x20forever.','requires_explicit_yes':!![],'related_risk_ids':['R-S-5-01']},{'id':'QS7','question':'If\x20using\x20buy_guard,\x20is\x20the\x20Guard\x20configuration\x20appropriate\x20for\x20your\x20sale\x20phase\x20(whitelist\x20for\x20pre-sale,\x20null\x20for\x20public\x20sale)?\x20buy_guard\x20remains\x20mutable\x20post-publish.','requires_explicit_yes':![],'related_risk_ids':['R-S-3-03']},{'id':'QS8','question':'For\x20discount\x20operations:\x20are\x20discount\x20counts\x20within\x20limits\x20(<=1000\x20per\x20call,\x20<=20000\x20total)?\x20Expired\x20or\x20exhausted\x20discounts\x20cannot\x20be\x20re-issued.','requires_explicit_yes':![],'related_risk_ids':['R-S-2-04']},{'id':'QS9','question':'For\x20order\x20placement:\x20are\x20you\x20aware\x20that\x20stock\x20is\x20deducted\x20at\x20the\x20quote\x20stage\x20and\x20NOT\x20rolled\x20back\x20if\x20later\x20stages\x20fail?\x20Monitor\x20failed\x20transactions\x20and\x20re-add\x20stock\x20manually\x20if\x20needed.','requires_explicit_yes':!![],'related_risk_ids':['R-S-2-03']},{'id':'QS10','question':'Have\x20you\x20exported\x20the\x20current\x20Service\x20JSON\x20as\x20a\x20backup\x20before\x20this\x20operation?','requires_explicit_yes':![]},{'id':'QS11','question':'⚠️\x20Service\x20is\x20about\x20to\x20be\x20published\x20WITHOUT\x20arbitrations.\x0a\x0a'+'After\x20publishing,\x20arbitrations\x20CANNOT\x20be\x20added\x20(contract\x20restriction,\x20F-S-21).\x0a'+'Dispute\x20resolution\x20will\x20NOT\x20be\x20available\x20for\x20this\x20service.\x0a\x0a'+'Recommended:\x20Set\x20arbitrations\x20BEFORE\x20publishing:\x0a'+'\x20\x20\x22arbitrations\x22:\x20{\x22op\x22:\x20\x22add\x22,\x20\x22objects\x22:\x20[\x22your_arbitration_object\x22]}\x0a\x0a'+'Continue\x20with\x20publish\x20anyway?','requires_explicit_yes':!![]}];function processUserConfirmation(a,b){const c=[...SERVICE_CONFIRMATION_QUESTIONS],d=a['service_json'],e=[];if(!d['publish'])e['push']('QS1');if(!d['builder'])e['push']('QS2');if(!d['sales']||d['sales']['op']==='clear'||d['sales']['op']==='remove')e['push']('QS3');if(!d['publish']&&!(d['compensation_fund_add']&&BigInt(String(d['compensation_fund_add']['balance']))>0x0n))e['push']('QS4');if(!d['publish']&&!d['order_allocators'])e['push']('QS5');if(!d['machine'])e['push']('QS6');if(d['buy_guard']===undefined)e['push']('QS7');if(!d['discount'])e['push']('QS8');if(!d['order_new'])e['push']('QS9');if(!d['publish'])e['push']('QS11');else{const g=a['current_arbitrations_count']??0x0,h=d['arbitrations']&&'objects'in d['arbitrations']?d['arbitrations']['objects']['length']:0x0,i=d['arbitrations']&&d['arbitrations']['op']==='clear',j=i?0x0:g+h;j>0x0&&e['push']('QS11');}const f=c['filter'](k=>!e['includes'](k['id']));if(a['skip_user_confirmation'])return{'questions_asked':f,'responses':f['map'](k=>({'question_id':k['id'],'response':'yes'})),'all_confirmed':!![]};return{'questions_asked':f,'responses':[],'all_confirmed':![]};}function verifyEnvironment(a){const b=[],c=a['service_json'];c['object']&&b['push']({'name':'object_exists','passed':!![],'message':'Service\x20object\x20'+c['object']+'\x20assumed\x20to\x20exist'});c['publish']&&b['push']({'name':'signer_has_publish_permission','passed':!![],'message':'Signer\x20must\x20hold\x20SERVICE_PUBLISH\x20(311)\x20permission'});c['builder']&&b['push']({'name':'signer_is_owner','passed':!![],'message':'Signer\x20must\x20be\x20Service\x20owner\x20for\x20transfer\x20(builder)'});c['pause']!==undefined&&b['push']({'name':'signer_has_pause_permission','passed':!![],'message':'Signer\x20must\x20hold\x20SERVICE_PAUSE\x20(310)\x20permission'});if(c['publish']){!a['current_order_allocators_set']&&c['order_allocators']===undefined&&b['push']({'name':'order_allocators_set','passed':![],'message':'Publish\x20blocked:\x20order_allocators\x20not\x20set\x20(E_NO_ALLOCATOR)'});const g=a['current_compensation_fund_balance']??'0',h=a['current_arbitrations_count']??0x0,i=c['arbitrations']&&'objects'in c['arbitrations']?c['arbitrations']['objects']['length']:0x0;BigInt(g)>0x0n&&h+i===0x0&&b['push']({'name':'arbitrations_for_compensation_fund','passed':![],'message':'Publish\x20blocked:\x20compensation_fund\x20>\x200\x20but\x20no\x20arbitrations\x20(E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND)'});c['machine']&&(a['current_machine_node_count']!==undefined&&a['current_machine_node_count']===0x0&&b['push']({'name':'machine_has_nodes','passed':![],'message':'Publish\x20blocked:\x20bound\x20Machine\x20has\x200\x20nodes\x20—\x20Progress\x20will\x20be\x20permanently\x20stuck'}),a['current_machine_initial_forward_ok']===![]&&b['push']({'name':'machine_initial_forward','passed':![],'message':'Publish\x20blocked:\x20bound\x20Machine\x27s\x20initial\x20node\x20(prev_node=\x27\x27)\x20has\x20no\x20forward\x20—\x20Progress\x20cannot\x20advance\x20from\x20\x27\x27\x20(FIX-002\x20violated)'}),a['current_machine_bPublished']===![]&&b['push']({'name':'machine_not_published','passed':!![],'level':'warning','message':'Warning:\x20bound\x20Machine\x20is\x20not\x20yet\x20published.\x20Orders\x20cannot\x20advance\x20until\x20the\x20Machine\x20is\x20published.\x20Publish\x20the\x20Machine\x20after\x20this\x20Service\x20to\x20enable\x20order\x20workflow.'}));const j=a['current_arbitrations_count']??0x0,k=c['arbitrations']&&'objects'in c['arbitrations']?c['arbitrations']['objects']['length']:0x0;j+k>0x0&&a['current_arbitrators_authorized']===![]&&b['push']({'name':'arbitrators_permission_authorized','passed':!![],'level':'info','message':'Info:\x20ensure\x20arbitrators\x20have\x20been\x20granted\x20the\x20required\x20permission\x20index\x20in\x20the\x20Permission\x20object.\x20Without\x20authorization,\x20dispute\x20resolution\x20Guards\x20will\x20reject\x20arbitrator\x20signatures\x20(Permission\x20denied).'});}a['current_bPublished']&&(c['machine']!==undefined&&b['push']({'name':'machine_immutable_post_publish','passed':![],'message':'machine\x20cannot\x20be\x20modified\x20post-publish\x20(F-S-20)'}),c['arbitrations']!==undefined&&b['push']({'name':'arbitrations_immutable_post_publish','passed':![],'message':'arbitrations\x20cannot\x20be\x20modified\x20post-publish\x20(F-S-21)'}),c['order_allocators']!==undefined&&b['push']({'name':'order_allocators_immutable_post_publish','passed':![],'message':'order_allocators\x20cannot\x20be\x20modified\x20post-publish\x20(F-S-22)'}));c['compensation_fund_withdraw']&&!a['current_bPaused']&&b['push']({'name':'compensation_fund_withdraw_requires_paused','passed':![],'message':'compensation_fund_withdraw\x20requires\x20bPaused=true\x20(F-S-26)'});const d=b['every'](l=>l['passed']),e=b['filter'](l=>l['level']==='warning')['length'],f=b['filter'](l=>l['level']==='info')['length'];return{'passed':d,'checks':b,'warnings_count':e,'infos_count':f};}export const SERVICE_CONFIRM_VERSION='1.0.0';export function runServiceConfirmGate(a){const b=[],c=[],d=runStaticChecklist(a);if(!d['all_passed'])return c['push']('L1_checklist'),{'status':'blocked_checklist','checklist_result':d,'confirmation_text':generateConfirmationText(a,d),'block_reason':'Checklist\x20failed:\x20'+d['items']['filter'](j=>!j['passed']&&j['id']!=='C-S-17'&&j['id']!=='C-S-18'&&j['id']!=='C-S-19')['map'](j=>j['id'])['join'](',\x20'),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':SERVICE_CONFIRM_VERSION,'final_status':'blocked_checklist','layers_passed':b,'layers_failed':c}};b['push']('L1_checklist');const e=adaptRiskAssessment(a),f=e['risks']['some'](i=>i['level']==='CRITICAL');if(f)return c['push']('L2_risk'),{'status':'blocked_risk','checklist_result':d,'risk_result':e,'confirmation_text':generateConfirmationText(a,d,e),'block_reason':'CRITICAL\x20risks:\x20'+e['risks']['filter'](i=>i['level']==='CRITICAL')['map'](i=>i['id'])['join'](',\x20'),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':SERVICE_CONFIRM_VERSION,'final_status':'blocked_risk','layers_passed':b,'layers_failed':c}};b['push']('L2_risk');const g=processUserConfirmation(a,e);if(!g['all_confirmed']){if(a['service_json']['publish']){const j=d['items']['find'](k=>k['id']==='C-S-17');if(j){const k=g['responses']['find'](l=>l['question_id']==='QS1');j['passed']=k?.['response']==='yes',j['message']=j['passed']?'':'Publish\x20not\x20confirmed\x20by\x20user\x20(QS1)';}}if(a['service_json']['builder']){const l=d['items']['find'](m=>m['id']==='C-S-18');if(l){const m=g['responses']['find'](n=>n['question_id']==='QS2');l['passed']=m?.['response']==='yes',l['message']=l['passed']?'':'Transfer\x20not\x20confirmed\x20by\x20user\x20(QS2)';}}const i=d['items']['find'](n=>n['id']==='C-S-19');if(i&&!i['passed']){const n=g['questions_asked']['some'](o=>o['id']==='QS11');if(n){const o=g['responses']['find'](p=>p['question_id']==='QS11');i['passed']=o?.['response']==='yes',i['message']=i['passed']?'':'User\x20declined\x20publish\x20without\x20arbitrations\x20(QS11)';}}if(a['service_json']['publish']){const p=d['items']['find'](q=>q['id']==='C-S-17');if(p&&!p['passed'])return c['push']('L3_user'),{'status':'blocked_user','checklist_result':d,'risk_result':e,'user_confirmation':g,'confirmation_text':generateConfirmationText(a,d,e),'block_reason':'User\x20did\x20not\x20confirm\x20publish\x20(QS1)','decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':SERVICE_CONFIRM_VERSION,'final_status':'blocked_user','layers_passed':b,'layers_failed':c}};}if(a['service_json']['builder']){const q=d['items']['find'](r=>r['id']==='C-S-18');if(q&&!q['passed'])return c['push']('L3_user'),{'status':'blocked_user','checklist_result':d,'risk_result':e,'user_confirmation':g,'confirmation_text':generateConfirmationText(a,d,e),'block_reason':'User\x20did\x20not\x20confirm\x20ownership\x20transfer\x20(QS2)','decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':SERVICE_CONFIRM_VERSION,'final_status':'blocked_user','layers_passed':b,'layers_failed':c}};}if(i&&!i['passed']){const r=g['questions_asked']['some'](s=>s['id']==='QS11');if(r)return c['push']('L3_user'),{'status':'blocked_user','checklist_result':d,'risk_result':e,'user_confirmation':g,'confirmation_text':generateConfirmationText(a,d,e),'block_reason':'User\x20did\x20not\x20confirm\x20publish\x20without\x20arbitrations\x20(QS11)\x20—\x20set\x20arbitrations\x20or\x20explicitly\x20confirm','decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':SERVICE_CONFIRM_VERSION,'final_status':'blocked_user','layers_passed':b,'layers_failed':c}};}}b['push']('L3_user');let h;if(a['skip_environment_check'])b['push']('L4_environment');else{h=verifyEnvironment(a);if(!h['passed'])return c['push']('L4_environment'),{'status':'blocked_environment','checklist_result':d,'risk_result':e,'user_confirmation':g,'environment_result':h,'confirmation_text':generateConfirmationText(a,d,e),'block_reason':'Environment\x20check\x20failed:\x20'+h['checks']['filter'](s=>!s['passed'])['map'](s=>s['name'])['join'](',\x20'),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':SERVICE_CONFIRM_VERSION,'final_status':'blocked_environment','layers_passed':b,'layers_failed':c}};b['push']('L4_environment');}return{'status':'approved','checklist_result':d,'risk_result':e,'user_confirmation':g,'environment_result':h,'confirmation_text':generateConfirmationText(a,d,e),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':SERVICE_CONFIRM_VERSION,'final_status':'approved','layers_passed':b,'layers_failed':c}};}function generateConfirmationText(a,b,c){const d=[],e=a['service_json'];d['push']('═══\x20Service\x20Confirmation\x20═══'),d['push']('');e['object']?d['push']('Service:\x20'+e['object']):d['push']('Service:\x20NEW\x20(to\x20be\x20created)');if(e['description'])d['push']('Description:\x20'+e['description']);if(a['current_bPublished']!==undefined)d['push']('Currently\x20published:\x20'+a['current_bPublished']);if(a['current_bPaused']!==undefined)d['push']('Currently\x20paused:\x20'+a['current_bPaused']);d['push'](''),d['push']('─\x20Checklist\x20──────────────────');for(const f of b['items']){const g=f['passed']?'✓':'✗';d['push']('\x20\x20'+g+'\x20'+f['id']+':\x20'+f['description']+(f['message']?'\x20—\x20'+f['message']:''));}d['push']('');if(c){d['push']('─\x20Risk\x20Assessment\x20──────────────────'),d['push']('Overall:\x20'+c['overall_risk']),d['push']('Detected:\x20'+c['risks']['length']+'\x20risk(s)');for(const h of c['risks']['slice'](0x0,0xa)){d['push']('\x20\x20['+h['level']+']\x20'+h['id']+':\x20'+h['title']);}c['risks']['length']>0xa&&d['push']('\x20\x20...\x20and\x20'+(c['risks']['length']-0xa)+'\x20more'),d['push']('');}d['push']('─\x20Operations\x20──────────────────');if(e['sales'])d['push']('-\x20Sales\x20'+e['sales']['op']);if(e['machine']!==undefined)d['push']('-\x20Machine:\x20'+(e['machine']??'(unbind)')+'\x20'+(a['current_bPublished']?'[BLOCKED\x20post-publish]':''));if(e['buy_guard']!==undefined)d['push']('-\x20Buy\x20Guard:\x20'+(e['buy_guard']??'(clear)'));if(e['arbitrations'])d['push']('-\x20Arbitrations\x20'+e['arbitrations']['op']);if(e['repositories'])d['push']('-\x20Repositories\x20'+e['repositories']['op']);if(e['rewards'])d['push']('-\x20Rewards\x20'+e['rewards']['op']);if(e['order_allocators']!==undefined)d['push']('-\x20Order\x20Allocators:\x20'+(e['order_allocators']?'(set)':'(clear)'));if(e['discount'])d['push']('-\x20Discount:\x20'+e['discount']['name']+'\x20('+e['discount']['count']+'\x20coupons)');if(e['pause']!==undefined)d['push']('-\x20Pause:\x20'+e['pause']);if(e['publish'])d['push']('-\x20⚠️\x20PUBLISH\x20(IRREVERSIBLE)');if(e['compensation_fund_add'])d['push']('-\x20Compensation\x20fund\x20deposit:\x20'+e['compensation_fund_add']['balance']);if(e['compensation_fund_withdraw'])d['push']('-\x20⚠️\x20Compensation\x20fund\x20withdraw\x20(requires\x20paused\x20+\x20lock\x20expired)');if(e['setting_lock_duration_add']!==undefined)d['push']('-\x20Setting\x20lock\x20+'+e['setting_lock_duration_add']+'ms');if(e['order_new'])d['push']('-\x20⚠️\x20ORDER\x20NEW\x20(8-stage\x20flow,\x20stock\x20deducted\x20at\x20quote)');if(e['builder'])d['push']('-\x20⚠️\x20TRANSFER\x20to:\x20'+e['builder']+'\x20(IRREVERSIBLE)');if(e['um']!==undefined)d['push']('-\x20UM:\x20'+(e['um']??'(revoke)'));return d['push'](''),d['join']('\x0a');}export function progressiveServiceCheck(a){const b=runStaticChecklist(a);if(!b['all_passed'])return{'stage':'checklist','status':'fail','message':'Checklist\x20failed:\x20'+b['items']['filter'](d=>!d['passed']&&d['id']!=='C-S-17'&&d['id']!=='C-S-18'&&d['id']!=='C-S-19')['map'](d=>d['id'])['join'](',\x20'),'next_action':'Fix\x20failing\x20checklist\x20items'};const c=adaptRiskAssessment(a);if(c['risks']['some'](d=>d['level']==='CRITICAL'))return{'stage':'risk','status':'fail','message':'CRITICAL\x20risks:\x20'+c['risks']['filter'](d=>d['level']==='CRITICAL')['map'](d=>d['id'])['join'](',\x20'),'next_action':'Resolve\x20CRITICAL\x20risks\x20before\x20proceeding'};if(c['needs_human_review'])return{'stage':'confirmation','status':'pending','message':'Human\x20review\x20required\x20for\x20HIGH\x20risks','next_action':'Confirm\x20risk\x20acceptance\x20via\x20user\x20questions'};return{'stage':'complete','status':'pass','message':'All\x20checks\x20passed'};}
@@ -1,66 +0,0 @@
1
- import { type ServiceScene, type ServicePermissionEntry, type ServiceCrossObjectBinding, type ServiceOrderFlowStage } from "./service-ledger.js";
2
- import { type ServiceTemplate } from "./service-templates.js";
3
- import { type SemanticToSchemaRule } from "./service-translation.js";
4
- import { type ServiceRiskRule, type ServiceRiskAssessment, type ServiceStakeholder } from "./service-risk.js";
5
- import { type ServicePuzzle, type ServicePuzzleCompleteness } from "./service-puzzle.js";
6
- import { type ServiceChecklistItem, type ServiceJsonForConfirm, type ServiceConfirmationQuestion } from "./service-confirm.js";
7
- export declare const SERVICE_CONTEXT_VERSION = "1.0.0";
8
- export type ServiceInjectionMode = "initial_design" | "mid_design_review" | "pre_publish" | "post_publish_modify" | "stakeholder_review" | "order_flow_check";
9
- export type ServiceStakeholderPerspective = ServiceStakeholder | "system";
10
- export interface ServiceContextBundle {
11
- version: string;
12
- mode: ServiceInjectionMode;
13
- stakeholder_perspective?: ServiceStakeholderPerspective;
14
- matched_scene?: ServiceScene;
15
- matched_template?: ServiceTemplate;
16
- matched_pattern?: SemanticToSchemaRule;
17
- puzzle_state?: ServicePuzzle;
18
- puzzle_completeness?: ServicePuzzleCompleteness;
19
- relevant_risks: ServiceRiskRule[];
20
- risk_assessment?: ServiceRiskAssessment;
21
- relevant_checklist: ServiceChecklistItem[];
22
- relevant_questions: ServiceConfirmationQuestion[];
23
- relevant_builtin_permissions: ServicePermissionEntry[];
24
- relevant_order_flow_stages: ServiceOrderFlowStage[];
25
- cross_object_bindings: ServiceCrossObjectBinding[];
26
- cross_object_refs: ServiceCrossObjectRef[];
27
- onchain_constraints: ServiceOnchainConstraint[];
28
- rendering_hints: ServiceRenderingHints;
29
- }
30
- export interface ServiceCrossObjectRef {
31
- object: "Machine" | "Allocation" | "Arbitration" | "Repository" | "Reward" | "Treasury" | "Progress" | "Guard" | "Contact" | "Permission";
32
- field: string;
33
- scene_id: string;
34
- description: string;
35
- locked_after_publish: boolean;
36
- }
37
- export interface ServiceOnchainConstraint {
38
- name: string;
39
- value: string | number;
40
- description: string;
41
- }
42
- export interface ServiceRenderingHints {
43
- include_puzzle_template: boolean;
44
- include_risk_details: boolean;
45
- include_questions: boolean;
46
- include_publish_warning: boolean;
47
- include_transfer_warning: boolean;
48
- include_order_flow_warning: boolean;
49
- include_immutability_matrix: boolean;
50
- max_length: number;
51
- }
52
- export interface BuildServiceContextInput {
53
- mode: ServiceInjectionMode;
54
- intent?: string;
55
- service_json?: ServiceJsonForConfirm;
56
- stakeholder?: ServiceStakeholderPerspective;
57
- target_scene_id?: string;
58
- target_permission_index?: number;
59
- target_category?: ServiceScene["category"];
60
- current_bPublished?: boolean;
61
- current_bPaused?: boolean;
62
- max_length?: number;
63
- }
64
- export declare function buildServiceContext(input: BuildServiceContextInput): ServiceContextBundle;
65
- export declare function buildPromptFromServiceContext(bundle: ServiceContextBundle): string;
66
- export declare function getServiceContextSummary(bundle: ServiceContextBundle): string;
@@ -1 +0,0 @@
1
- import{MAX_SALE_COUNT,MAX_REPOSITORY_COUNT,MAX_ARBITRATION_COUNT,MAX_DISCOUNT_COUNT_ONCE,MAX_DISCOUNT_TOTAL_COUNT,MAX_WIP_LENGTH,MAX_WIP_HASH_LENGTH,DEFAULT_LOCK_DURATION}from'@wowok/wowok';import{findSceneById,inferSceneFromIntent,getScenesByCategory,isServicePermission,SERVICE_PERMISSIONS,SERVICE_ORDER_FLOW_STAGES,SERVICE_CROSS_OBJECT_BINDINGS}from'./service-ledger.js';import{getServiceTemplatesByScene}from'./service-templates.js';import{matchSemanticPattern}from'./service-translation.js';import{getAllServiceRiskRules,assessServiceRisks}from'./service-risk.js';import{initPuzzleFromIntent,checkPuzzleCompleteness}from'./service-puzzle.js';import{SERVICE_PUBLISH_CHECKLIST,SERVICE_CONFIRMATION_QUESTIONS}from'./service-confirm.js';export const SERVICE_CONTEXT_VERSION='1.0.0';export function buildServiceContext(a){const b=a['max_length']??0x1770;let c;a['intent']&&(c=inferSceneFromIntent(a['intent']));!c&&a['target_scene_id']&&(c=findSceneById(a['target_scene_id']));if(!c&&a['target_category']){const r=getScenesByCategory(a['target_category']);if(r['length']>0x0)c=r[0x0];}!c&&a['target_permission_index']!==undefined&&isServicePermission(a['target_permission_index'])&&(c=findSceneById('service_retail'));let d;if(c){const s=getServiceTemplatesByScene(c['id']);if(s['length']>0x0)d=s[0x0];}let e;if(a['intent']){const t=matchSemanticPattern(a['intent']);if(t['length']>0x0)e=t[0x0];}let f,g;a['mode']==='initial_design'&&a['intent']&&(f=initPuzzleFromIntent({'primary_goal':a['intent']}),g=checkPuzzleCompleteness(f));const h=filterRiskRules(a['mode'],a['stakeholder'],c);let i;if((a['mode']==='pre_publish'||a['mode']==='post_publish_modify'||a['mode']==='order_flow_check')&&a['service_json']){const u={'object':a['service_json']['object'],'description':a['service_json']['description'],'location':a['service_json']['location'],'sales':a['service_json']['sales'],'repositories':a['service_json']['repositories'],'rewards':a['service_json']['rewards'],'arbitrations':a['service_json']['arbitrations'],'machine':a['service_json']['machine'],'discount':a['service_json']['discount'],'customer_required':a['service_json']['customer_required'],'order_allocators':a['service_json']['order_allocators'],'buy_guard':a['service_json']['buy_guard'],'compensation_fund_add':a['service_json']['compensation_fund_add'],'setting_lock_duration_add':a['service_json']['setting_lock_duration_add'],'compensation_fund_receive':a['service_json']['compensation_fund_receive'],'owner_receive':a['service_json']['owner_receive'],'pause':a['service_json']['pause'],'publish':a['service_json']['publish'],'um':a['service_json']['um'],'order_new':a['service_json']['order_new'],'current_bPublished':a['current_bPublished'],'current_bPaused':a['current_bPaused'],'current_machine_bound':a['current_bPublished']};i=assessServiceRisks(u);}const j=filterChecklist(a['mode']),k=filterQuestions(a['mode']),l=c?c['builtin_indexes']:[...SERVICE_PERMISSIONS],m=a['mode']==='order_flow_check'?[...SERVICE_ORDER_FLOW_STAGES]:[],n=[...SERVICE_CROSS_OBJECT_BINDINGS],o=buildCrossObjectRefs(c),p=buildOnchainConstraints(),q=buildRenderingHints(a['mode'],b,!!a['service_json']?.['publish'],!!a['service_json']?.['builder'],!!a['service_json']?.['order_new'],a['current_bPublished']??![]);return{'version':SERVICE_CONTEXT_VERSION,'mode':a['mode'],'stakeholder_perspective':a['stakeholder'],'matched_scene':c,'matched_template':d,'matched_pattern':e,'puzzle_state':f,'puzzle_completeness':g,'relevant_risks':h,'risk_assessment':i,'relevant_checklist':j,'relevant_questions':k,'relevant_builtin_permissions':l,'relevant_order_flow_stages':m,'cross_object_bindings':n,'cross_object_refs':o,'onchain_constraints':p,'rendering_hints':q};}function filterRiskRules(a,b,c){let d=getAllServiceRiskRules();if(a==='initial_design')return d['filter'](e=>e['category']==='structural'||e['category']==='authority');if(a==='pre_publish')return d;if(a==='post_publish_modify')return d['filter'](e=>e['category']==='lifecycle'||e['category']==='cross_object');if(a==='order_flow_check')return d['filter'](e=>e['category']==='semantic'||e['id']['startsWith']('R-S-2'));if(a==='stakeholder_review'&&b){if(b==='owner')return d['filter'](e=>e['category']==='authority'||e['category']==='lifecycle');if(b==='customer')return d['filter'](e=>e['category']==='semantic'||e['id']['startsWith']('R-S-2'));if(b==='provider')return d['filter'](e=>e['category']==='cross_object'||e['id']['startsWith']('R-S-5-01'));if(b==='arbitrator')return d['filter'](e=>e['id']['startsWith']('R-S-5-02')||e['id']['startsWith']('R-S-2-02'));if(b==='system')return d['filter'](e=>e['category']==='lifecycle');}return d;}function filterChecklist(a){if(a==='initial_design')return SERVICE_PUBLISH_CHECKLIST['filter'](b=>['C-S-01','C-S-02','C-S-03','C-S-04','C-S-05','C-S-06','C-S-07']['includes'](b['id']));if(a==='pre_publish')return SERVICE_PUBLISH_CHECKLIST;if(a==='post_publish_modify')return SERVICE_PUBLISH_CHECKLIST['filter'](b=>['C-S-12','C-S-13','C-S-14','C-S-15','C-S-16']['includes'](b['id']));if(a==='order_flow_check')return SERVICE_PUBLISH_CHECKLIST['filter'](b=>['C-S-07']['includes'](b['id']));return SERVICE_PUBLISH_CHECKLIST;}function filterQuestions(a){if(a==='pre_publish')return SERVICE_CONFIRMATION_QUESTIONS;if(a==='post_publish_modify')return SERVICE_CONFIRMATION_QUESTIONS['filter'](b=>!['QS1','QS2','QS5']['includes'](b['id']));if(a==='order_flow_check')return SERVICE_CONFIRMATION_QUESTIONS['filter'](b=>b['id']==='QS9');return[];}function buildCrossObjectRefs(a){return[{'object':'Machine','field':'machine','scene_id':'service_workflow','description':'Machine\x20workflow\x20template\x20—\x20post-publish\x20immutable.\x20Progress\x20inherits\x20this\x20binding.','locked_after_publish':!![]},{'object':'Allocation','field':'order_allocators','scene_id':'service_order_allocator','description':'Fund\x20distribution\x20strategy\x20—\x20publish\x20prerequisite,\x20post-publish\x20immutable.','locked_after_publish':!![]},{'object':'Arbitration','field':'arbitrations','scene_id':'service_arbitration','description':'Dispute\x20handlers\x20—\x20required\x20when\x20compensation_fund\x20>\x200,\x20post-publish\x20immutable.','locked_after_publish':!![]},{'object':'Repository','field':'repositories','scene_id':'service_retail','description':'Shared\x20data\x20stores\x20—\x20mutable\x20post-publish.','locked_after_publish':![]},{'object':'Reward','field':'rewards','scene_id':'service_reward','description':'Marketing\x20incentives\x20—\x20mutable\x20but\x20locked\x20by\x20setting_lock_duration.','locked_after_publish':![]},{'object':'Guard','field':'buy_guard','scene_id':'service_buy_guard','description':'Buyer\x20eligibility\x20Guard\x20—\x20UNUSUAL:\x20still\x20mutable\x20post-publish.','locked_after_publish':![]},{'object':'Contact','field':'um','scene_id':'service_retail','description':'User\x20Manager\x20(Contact\x20object)\x20—\x20mutable\x20post-publish.','locked_after_publish':![]},{'object':'Treasury','field':'(indirect\x20via\x20order_allocators.sharing.who=Entity)','scene_id':'service_multi_allocator','description':'Treasury\x20referenced\x20by\x20Allocation.sharing.who=Entity\x20(Treasury\x20address).\x20Not\x20directly\x20bound\x20to\x20Service.','locked_after_publish':![]},{'object':'Progress','field':'(created\x20at\x20order\x20time)','scene_id':'service_workflow','description':'Progress\x20object\x20created\x20per\x20order\x20(Stage\x206\x20of\x20buy\x20flow).\x20Inherits\x20Machine\x20from\x20Service.','locked_after_publish':![]},{'object':'Permission','field':'permission','scene_id':'service_retail','description':'Permission\x20object\x20governing\x2021\x20SERVICE_*\x20indexes\x20(300-320).\x20Bound\x20at\x20Service\x20creation,\x20immutable.','locked_after_publish':!![]}];}function buildOnchainConstraints(){return[{'name':'MAX_SALE_COUNT','value':MAX_SALE_COUNT,'description':'Maximum\x20sales\x20items\x20per\x20Service'},{'name':'MAX_REPOSITORY_COUNT','value':MAX_REPOSITORY_COUNT,'description':'Maximum\x20repositories\x20per\x20Service'},{'name':'MAX_ARBITRATION_COUNT','value':MAX_ARBITRATION_COUNT,'description':'Maximum\x20arbitrations\x20per\x20Service'},{'name':'MAX_REWARD_COUNT','value':0x14,'description':'Maximum\x20rewards\x20per\x20Service'},{'name':'MAX_DISCOUNT_COUNT_ONCE','value':MAX_DISCOUNT_COUNT_ONCE,'description':'Maximum\x20discount\x20coupons\x20per\x20issue\x20call'},{'name':'MAX_DISCOUNT_TOTAL_COUNT','value':MAX_DISCOUNT_TOTAL_COUNT,'description':'Maximum\x20total\x20discount\x20coupons\x20per\x20Service'},{'name':'MAX_WIP_LENGTH','value':MAX_WIP_LENGTH,'description':'Maximum\x20WIP\x20URL\x20length'},{'name':'MAX_WIP_HASH_LENGTH','value':MAX_WIP_HASH_LENGTH,'description':'Maximum\x20WIP\x20hash\x20length\x20(sha256\x20hex)'},{'name':'DEFAULT_LOCK_DURATION','value':DEFAULT_LOCK_DURATION,'description':'Default\x20setting_lock_duration\x20(30\x20days\x20in\x20ms)'}];}function buildRenderingHints(a,b,c,d,e,f){return{'include_puzzle_template':a==='initial_design','include_risk_details':a==='pre_publish'||a==='stakeholder_review'||a==='order_flow_check','include_questions':a==='pre_publish'||a==='order_flow_check','include_publish_warning':c,'include_transfer_warning':d,'include_order_flow_warning':e,'include_immutability_matrix':a==='post_publish_modify'||a==='pre_publish'||f,'max_length':b};}export function buildPromptFromServiceContext(a){const d=[],e=a['rendering_hints'];d['push']('═══\x20Service\x20Context\x20(mode:\x20'+a['mode']+')\x20═══'),d['push']('');a['matched_scene']&&(d['push']('Scene:\x20'+a['matched_scene']['name']),d['push']('Category:\x20'+a['matched_scene']['category']),d['push']('Permission\x20range:\x20'+a['matched_scene']['permission_index_range']),d['push'](''));if(a['matched_template']){d['push']('Suggested\x20template:\x20'+a['matched_template']['id']+'\x20—\x20'+a['matched_template']['name']);if(a['matched_template']['notes']&&a['matched_template']['notes']['length']>0x0){d['push']('Notes:');for(const f of a['matched_template']['notes']['slice'](0x0,0x3)){d['push']('\x20\x20-\x20'+f);}}d['push']('');}if(e['include_puzzle_template']&&a['puzzle_completeness']){const g=a['puzzle_completeness'];d['push']('─\x20Puzzle\x20Completeness\x20──────────────'),d['push']('Complete:\x20'+(g['complete']?'YES':'NO'));if(g['missing']['length']>0x0){d['push']('Missing\x20dimensions:\x20'+g['missing']['join'](',\x20'));for(const i of g['missing_details']['slice'](0x0,0x3)){d['push']('\x20\x20-\x20'+i['dimension']+':\x20'+i['reason']);}}d['push']('Next:\x20'+g['next_step']),d['push']('');}if(e['include_risk_details']&&a['relevant_risks']['length']>0x0){d['push']('─\x20Relevant\x20Risk\x20Rules\x20('+a['relevant_risks']['length']+')\x20──────────────');for(const j of a['relevant_risks']['slice'](0x0,0x8)){d['push']('\x20\x20'+j['id']+'\x20['+j['category']+']\x20—\x20'+j['trigger']);}a['relevant_risks']['length']>0x8&&d['push']('\x20\x20...\x20and\x20'+(a['relevant_risks']['length']-0x8)+'\x20more'),d['push']('');}if(a['risk_assessment']){d['push']('─\x20Risk\x20Assessment\x20──────────────'),d['push']('Overall:\x20'+a['risk_assessment']['overall_risk']),d['push']('Detected:\x20'+a['risk_assessment']['risks']['length']+'\x20risk(s)');if(a['risk_assessment']['risks']['length']>0x0)for(const k of a['risk_assessment']['risks']['slice'](0x0,0x5)){d['push']('\x20\x20['+k['level']+']\x20'+k['id']+':\x20'+k['title']);}d['push']('');}if(a['relevant_builtin_permissions']['length']>0x0){d['push']('─\x20Builtin\x20Permissions\x20('+a['relevant_builtin_permissions']['length']+')\x20──────────────');for(const l of a['relevant_builtin_permissions']['slice'](0x0,0xa)){const m=l['post_publish_mutability']==='immutable'?'\x20[IMMUTABLE]':l['post_publish_mutability']==='one_shot'?'\x20[ONE-SHOT]':l['post_publish_mutability']==='locked_by_duration'?'\x20[LOCKED]':'';d['push']('\x20\x20['+l['index']+']\x20'+l['name']+':\x20'+l['description']+m);}a['relevant_builtin_permissions']['length']>0xa&&d['push']('\x20\x20...\x20and\x20'+(a['relevant_builtin_permissions']['length']-0xa)+'\x20more'),d['push']('');}if(a['relevant_order_flow_stages']['length']>0x0){d['push']('─\x208-Stage\x20Order\x20Flow\x20──────────────');for(const n of a['relevant_order_flow_stages']){d['push']('\x20\x20Stage\x20'+n['stage']+':\x20'+n['name']+'\x20'+(n['always_executed']?'(always)':'(conditional)')),n['side_effects']['length']>0x0&&d['push']('\x20\x20\x20\x20Side\x20effects:\x20'+n['side_effects'][0x0]);}d['push']('');}e['include_publish_warning']&&(d['push']('⚠️\x20PUBLISH\x20OPERATION\x20DETECTED\x20—\x20IRREVERSIBLE'),d['push']('\x20\x20Once\x20published:\x20machine/arbitrations/order_allocators\x20become\x20PERMANENTLY\x20immutable'),d['push']('\x20\x20bPublished\x20cannot\x20be\x20reset\x20to\x20false\x20—\x20clone\x20Service\x20to\x20\x27reset\x27'),d['push'](''));e['include_transfer_warning']&&(d['push']('⚠️\x20TRANSFER\x20OPERATION\x20DETECTED\x20—\x20IRREVERSIBLE'),d['push']('\x20\x20Original\x20owner\x20loses\x20ALL\x20control.\x20New\x20owner\x20inherits\x20everything.'),d['push'](''));e['include_order_flow_warning']&&(d['push']('⚠️\x20ORDER\x20FLOW\x20—\x208\x20STAGES,\x20stock\x20deducted\x20at\x20quote\x20(Stage\x203)'),d['push']('\x20\x20If\x20Stages\x204-7\x20fail,\x20stock\x20remains\x20deducted\x20(not\x20rolled\x20back)'),d['push'](''));if(e['include_immutability_matrix']&&a['cross_object_bindings']['length']>0x0){d['push']('─\x20Post-publish\x20Immutability\x20Matrix\x20──────────────');for(const o of a['cross_object_bindings']){const q=o['locked_after_publish']?'🔒\x20IMMUTABLE':'🔓\x20mutable';d['push']('\x20\x20'+o['object']+'\x20('+o['field']+'):\x20'+q);}d['push']('');}if(a['onchain_constraints']['length']>0x0){d['push']('─\x20On-chain\x20Constraints\x20──────────────');for(const s of a['onchain_constraints']){d['push']('\x20\x20'+s['name']+'\x20=\x20'+s['value']+'\x20—\x20'+s['description']);}d['push']('');}if(a['cross_object_refs']['length']>0x0){d['push']('─\x20Cross-object\x20References\x20('+a['cross_object_refs']['length']+')\x20──────────────');for(const t of a['cross_object_refs']['slice'](0x0,0x6)){const u=t['locked_after_publish']?'\x20[locked]':'';d['push']('\x20\x20'+t['object']+'\x20('+t['field']+')'+u+':\x20'+t['description']);}a['cross_object_refs']['length']>0x6&&d['push']('\x20\x20...\x20and\x20'+(a['cross_object_refs']['length']-0x6)+'\x20more'),d['push']('');}return d['join']('\x0a');}export function getServiceContextSummary(a){const b=['mode='+a['mode'],'scene='+(a['matched_scene']?.['id']??'none'),'risks='+a['relevant_risks']['length'],'permissions='+a['relevant_builtin_permissions']['length']];if(a['risk_assessment'])b['push']('overall_risk='+a['risk_assessment']['overall_risk']);if(a['matched_template'])b['push']('template='+a['matched_template']['id']);if(a['relevant_order_flow_stages']['length']>0x0)b['push']('order_flow=8-stages');return b['join'](',\x20');}
@@ -1,103 +0,0 @@
1
- export interface SemanticToSchemaRule {
2
- id: string;
3
- pattern_name: string;
4
- semantic_intent: string;
5
- match_keywords: string[];
6
- schema_fields: string[];
7
- example_json: object;
8
- reverse_explanation: string;
9
- }
10
- export interface SchemaToSemanticRule {
11
- element_type: "field" | "op" | "index";
12
- type_name: string;
13
- semantic_explanation: string;
14
- constraints?: string[];
15
- }
16
- export interface ServiceConstraintRule {
17
- id: string;
18
- category: "structural" | "semantic" | "authority" | "lifecycle" | "cross_object";
19
- rule: string;
20
- applies_to: string[];
21
- }
22
- export declare const SEMANTIC_TO_SCHEMA_RULES: SemanticToSchemaRule[];
23
- export declare const SCHEMA_TO_SEMANTIC_RULES: SchemaToSemanticRule[];
24
- export declare const SERVICE_CONSTRAINT_RULES: ServiceConstraintRule[];
25
- export declare const SERVICE_TRANSLATION_VERSION = "1.0.0";
26
- export declare function matchSemanticPattern(userIntent: string): SemanticToSchemaRule[];
27
- export interface ServiceCallDataForExplain {
28
- object?: string | null;
29
- description?: string;
30
- location?: string;
31
- customer_required?: string[];
32
- sales?: {
33
- op: "add" | "set";
34
- sales: Array<{
35
- name: string;
36
- price?: string;
37
- stock?: number;
38
- wip?: string;
39
- wip_hash?: string;
40
- }>;
41
- } | {
42
- op: "remove";
43
- sales_name: string[];
44
- } | {
45
- op: "clear";
46
- };
47
- machine?: string | null;
48
- buy_guard?: string | null;
49
- arbitrations?: {
50
- op: "add" | "set" | "remove";
51
- objects: string[];
52
- } | {
53
- op: "clear";
54
- };
55
- repositories?: {
56
- op: "add" | "set" | "remove";
57
- objects: string[];
58
- } | {
59
- op: "clear";
60
- };
61
- rewards?: {
62
- op: "add" | "set" | "remove";
63
- objects: string[];
64
- } | {
65
- op: "clear";
66
- };
67
- order_allocators?: unknown;
68
- discount?: {
69
- name: string;
70
- discount_type: number;
71
- data: number;
72
- count: number;
73
- receivers?: string[];
74
- expire_at?: number;
75
- };
76
- pause?: boolean;
77
- publish?: boolean;
78
- compensation_fund_add?: {
79
- balance: string | number;
80
- };
81
- compensation_fund_withdraw?: unknown;
82
- compensation_fund_receive?: unknown;
83
- setting_lock_duration_add?: number;
84
- order_new?: {
85
- buy: {
86
- items: Array<{
87
- name: string;
88
- wip_hash: string;
89
- count: number;
90
- }>;
91
- discount?: string;
92
- total_pay: string;
93
- };
94
- };
95
- builder?: string;
96
- um?: string | null;
97
- owner_receive?: unknown;
98
- }
99
- export declare function explainServiceCallData(data: ServiceCallDataForExplain): string;
100
- export declare function explainField(fieldName: string): SchemaToSemanticRule | undefined;
101
- export declare function explainOp(opName: string): SchemaToSemanticRule | undefined;
102
- export declare function getConstraintsByCategory(category: ServiceConstraintRule["category"]): ServiceConstraintRule[];
103
- export declare function explainServicePermissionIndex(index: number): string;
@@ -1 +0,0 @@
1
- import{MAX_SALE_COUNT,MAX_REPOSITORY_COUNT,MAX_ARBITRATION_COUNT,MAX_DISCOUNT_COUNT_ONCE,MAX_DISCOUNT_TOTAL_COUNT,MAX_WIP_LENGTH,MAX_WIP_HASH_LENGTH}from'@wowok/wowok';import{isServicePermission,getServicePermissionByIndex}from'./service-ledger.js';export const SEMANTIC_TO_SCHEMA_RULES=[{'id':'P-S-01','pattern_name':'Create\x20new\x20Service','semantic_intent':'Create\x20a\x20new\x20Service<T>\x20with\x20owner,\x20permission,\x20description,\x20coin\x20type','match_keywords':['create','new','open'],'schema_fields':['object(null)','description','permission','owner','coin_type'],'example_json':{'object':null,'description':'My\x20retail\x20shop','permission':'0xPERMISSION_ADDRESS'},'reverse_explanation':'object=null\x20indicates\x20creation;\x20permission\x20must\x20be\x20a\x20valid\x20Permission\x20object\x20owned\x20by\x20signer'},{'id':'P-S-02','pattern_name':'Modify\x20description\x20/\x20location\x20/\x20customer_required','semantic_intent':'Update\x20Service\x20metadata\x20fields\x20(mutable\x20pre\x20and\x20post\x20publish)','match_keywords':['describe','locate','customer_required','update','modify'],'schema_fields':['object','description','location','customer_required'],'example_json':{'object':'0xSERVICE_ADDRESS','description':'Updated\x20description','location':'Shanghai','customer_required':['name','phone']},'reverse_explanation':'These\x20fields\x20are\x20always\x20mutable.\x20customer_required\x20is\x20a\x20string[]\x20of\x20field\x20names\x20buyers\x20must\x20provide\x20at\x20order\x20time.'},{'id':'P-S-03','pattern_name':'Manage\x20sales\x20items\x20(add/set/remove/clear)','semantic_intent':'Add\x20product\x20SKUs,\x20update\x20prices/stock,\x20remove\x20deprecated\x20items,\x20or\x20clear\x20all','match_keywords':['sales','product','sku','inventory','price'],'schema_fields':['object','sales'],'example_json':{'object':'0xSERVICE_ADDRESS','sales':{'op':'add','sales':[{'name':'standard','price':'1000000000','stock':0x64,'wip':'https://ipfs/wip','wip_hash':'abcd...64'}]}},'reverse_explanation':'sales.op=add\x20appends;\x20set\x20replaces\x20matching\x20name;\x20remove\x20deletes\x20by\x20name;\x20clear\x20empties\x20all.\x20wip_hash\x20is\x20REQUIRED\x20for\x20tamper\x20protection.'},{'id':'P-S-04','pattern_name':'Bind/unbind\x20Machine\x20workflow','semantic_intent':'Bind\x20a\x20Machine\x20workflow\x20template\x20to\x20Service\x20(post-publish\x20immutable)','match_keywords':['machine','workflow','bind\x20machine'],'schema_fields':['object','machine'],'example_json':{'object':'0xSERVICE_ADDRESS','machine':'0xMACHINE_ADDRESS'},'reverse_explanation':'machine=<address>\x20binds;\x20machine=null\x20unbinds\x20(pre-publish\x20only).\x20Once\x20published,\x20machine\x20is\x20immutable\x20(F-S-20).\x20Progress\x20inherits\x20this\x20binding.'},{'id':'P-S-05','pattern_name':'Set/clear\x20buy\x20Guard','semantic_intent':'Set\x20buyer\x20eligibility\x20Guard\x20(KYC/whitelist)\x20or\x20clear\x20it','match_keywords':['buy_guard','kyc','whitelist'],'schema_fields':['object','buy_guard'],'example_json':{'object':'0xSERVICE_ADDRESS','buy_guard':'0xGUARD_ADDRESS'},'reverse_explanation':'buy_guard\x20is\x20the\x20ONLY\x20field\x20still\x20mutable\x20post-publish\x20(F-S-26\x20exception).\x20Pre-sale:\x20set\x20to\x20whitelist;\x20public\x20sale:\x20set\x20to\x20null.'},{'id':'P-S-06','pattern_name':'Manage\x20arbitrations\x20(add/remove/clear)','semantic_intent':'Bind\x20Arbitration\x20objects\x20for\x20dispute\x20handling\x20(post-publish\x20immutable)','match_keywords':['arbitration','arbitrator','dispute'],'schema_fields':['object','arbitrations'],'example_json':{'object':'0xSERVICE_ADDRESS','arbitrations':{'op':'add','objects':['0xARB_ADDRESS']}},'reverse_explanation':'Required\x20when\x20compensation_fund\x20>\x200\x20(F-S-19).\x20Post-publish\x20immutable\x20(F-S-21).\x20Use\x201-3\x20Arbitration\x20objects\x20covering\x20different\x20scopes.'},{'id':'P-S-07','pattern_name':'Manage\x20repositories\x20(add/remove/clear)','semantic_intent':'Bind\x20Repository\x20objects\x20(data\x20stores)\x20—\x20mutable\x20post-publish','match_keywords':['repository','data\x20store','storage','data\x20source'],'schema_fields':['object','repositories'],'example_json':{'object':'0xSERVICE_ADDRESS','repositories':{'op':'add','objects':['0xREPO_ADDRESS']}},'reverse_explanation':'Mutable\x20post-publish.\x20SDK\x20validates\x20ObjectType.Repository\x20via\x20queryObjectsWithType.\x20Max\x20100\x20(MAX_REPOSITORY_COUNT).'},{'id':'P-S-08','pattern_name':'Manage\x20rewards\x20(add\x20/\x20remove\x20/\x20clear)','semantic_intent':'Bind\x20or\x20unbind\x20Reward\x20objects\x20for\x20marketing\x20incentives','match_keywords':['reward','incentive','marketing'],'schema_fields':['object','rewards'],'example_json':{'object':'0xSERVICE_ADDRESS','rewards':{'op':'add','objects':['0xREWARD_ADDRESS']}},'reverse_explanation':'add\x20is\x20always\x20allowed\x20(max\x2020,\x20MAX_REWARD_COUNT).\x20remove/clear\x20are\x20time-locked\x20after\x20publish:\x20require\x20Service\x20paused\x20AND\x20paused_time\x20+\x20setting_lock_duration\x20<=\x20clock\x20(service.move\x20assert_not_published).'},{'id':'P-S-09','pattern_name':'Set\x20order_allocators','semantic_intent':'Configure\x20fund\x20distribution\x20strategy\x20(publish\x20prerequisite,\x20post-publish\x20immutable)','match_keywords':['allocator','order_allocators'],'schema_fields':['object','order_allocators'],'example_json':{'object':'0xSERVICE_ADDRESS','order_allocators':[{'threshold':'0','sharing':[{'who':{'Object':'0xOWNER'},'weight':0x50},{'who':{'Object':'0xPLATFORM'},'weight':0x14}]}]},'reverse_explanation':'MANDATORY\x20before\x20publish\x20(F-S-18,\x20E_NO_ALLOCATOR).\x20First-match-wins:\x20first\x20allocator\x20whose\x20threshold\x20<=\x20order\x20value\x20handles\x20distribution.\x20Post-publish\x20immutable\x20(F-S-22).'},{'id':'P-S-10','pattern_name':'Pause/resume\x20Service','semantic_intent':'Block\x20new\x20orders\x20(pause)\x20or\x20resume\x20accepting\x20orders','match_keywords':['pause','resume'],'schema_fields':['object','pause'],'example_json':{'object':'0xSERVICE_ADDRESS','pause':!![]},'reverse_explanation':'pause=true\x20blocks\x20new\x20orders\x20(E_SERVICE_PAUSED);\x20pause=false\x20resumes.\x20Existing\x20Progress\x20continues\x20normally.\x20compensation_fund_withdraw\x20requires\x20paused=true.'},{'id':'P-S-11','pattern_name':'Publish\x20Service\x20(IRREVERSIBLE)','semantic_intent':'Publish\x20Service\x20—\x20makes\x20it\x20buyable.\x20One-shot,\x20cannot\x20revert.','match_keywords':['publish','go\x20live','release'],'schema_fields':['object','publish'],'example_json':{'object':'0xSERVICE_ADDRESS','publish':!![]},'reverse_explanation':'⚠️\x20IRREVERSIBLE.\x20Requires\x20SERVICE_PUBLISH\x20(311)\x20permission.\x20Prerequisites:\x20order_allocators\x20set;\x20if\x20compensation_fund\x20>\x200,\x20arbitrations\x20non-empty.\x20Locks\x20machine/arbitrations/order_allocators\x20forever.'},{'id':'P-S-12','pattern_name':'Issue/destroy\x20discount\x20coupons','semantic_intent':'Issue\x20promotional\x20discount\x20coupons\x20or\x20destroy\x20(redeem)\x20them','match_keywords':['discount','coupon'],'schema_fields':['object','discount'],'example_json':{'object':'0xSERVICE_ADDRESS','discount':{'name':'SUMMER10','discount_type':0x0,'data':0x3e8,'count':0x64,'receivers':['0xUSER1','0xUSER2'],'expire_at':0x1941f297c00}},'reverse_explanation':'discount_type=0\x20rates\x20(basis\x20points,\x20per\x2010000),\x201=minus\x20(direct\x20deduction).\x20Max\x201000\x20per\x20call\x20(MAX_DISCOUNT_COUNT_ONCE),\x2020000\x20total\x20(MAX_DISCOUNT_TOTAL_COUNT).\x20discount_destroy\x20is\x20holder-only.'},{'id':'P-S-13','pattern_name':'Compensation\x20fund\x20operations\x20(add\x20/\x20withdraw\x20/\x20receive)','semantic_intent':'Deposit\x20to\x20compensation_fund,\x20withdraw\x20(time-locked),\x20or\x20receive\x20arbitration\x20payouts','match_keywords':['compensation_fund','compensation','deposit','withdraw'],'schema_fields':['object','compensation_fund_add','compensation_fund_withdraw','compensation_fund_receive'],'example_json':{'object':'0xSERVICE_ADDRESS','compensation_fund_add':{'balance':'1000000000'}},'reverse_explanation':'add\x20and\x20receive\x20are\x20always\x20mutable\x20(permission\x20315/316).\x20withdraw\x20is\x20time-locked\x20after\x20publish:\x20requires\x20Service\x20paused\x20AND\x20paused_time\x20+\x20setting_lock_duration\x20<=\x20clock\x20(service.move\x20compensation_fund_withdraw_imp).\x20Internal\x20Balance<T>,\x20distinct\x20from\x20Treasury.'},{'id':'P-S-14','pattern_name':'Extend\x20setting_lock_duration','semantic_intent':'Add\x20milliseconds\x20to\x20setting_lock_duration\x20(only-increase\x20mechanism)','match_keywords':['setting_lock_duration','lock_duration','lock\x20period','extend\x20lock'],'schema_fields':['object','setting_lock_duration_add'],'example_json':{'object':'0xSERVICE_ADDRESS','setting_lock_duration_add':0x9a7ec800},'reverse_explanation':'Only-increase\x20(safe_add).\x20Default\x202592000000ms\x20(30\x20days).\x20Affects\x20rewards/compensation_fund_withdraw/compensation_fund_receive\x20mutability\x20windows.'},{'id':'P-S-15','pattern_name':'Buy\x20(8-stage\x20composite\x20order\x20flow)','semantic_intent':'Customer\x20places\x20order\x20—\x20atomic\x20creation\x20of\x20Order\x20+\x20Allocation\x20+\x20Progress','match_keywords':['buy','order','purchase'],'schema_fields':['object','order_new'],'example_json':{'object':'0xSERVICE_ADDRESS','order_new':{'buy':{'items':[{'name':'standard','wip_hash':'abcd...64','count':0x1}],'discount':'0xDISCOUNT_ADDRESS','total_pay':'1000000000','passport':null},'order_required_info':{'name':'Alice','phone':'+86...'},'agents':['0xAGENT1'],'transfer':null}},'reverse_explanation':'8\x20stages:\x20pre_check\x20→\x20wip_verify\x20→\x20quote\x20(deducts\x20stock!)\x20→\x20create_order\x20→\x20create_allocation\x20→\x20create_progress\x20→\x20post_actions\x20→\x20return_result.\x20Stock\x20deduction\x20is\x20NOT\x20rolled\x20back\x20on\x20later\x20failure.'},{'id':'P-S-16','pattern_name':'Transfer\x20ownership\x20(IRREVERSIBLE)','semantic_intent':'Transfer\x20Service\x20ownership\x20to\x20a\x20new\x20address','match_keywords':['transfer','handover'],'schema_fields':['object','builder'],'example_json':{'object':'0xSERVICE_ADDRESS','builder':'0xNEW_OWNER'},'reverse_explanation':'⚠️\x20IRREVERSIBLE.\x20Original\x20owner\x20loses\x20ALL\x20control.\x20New\x20owner\x20inherits\x20permission,\x20compensation_fund,\x20all\x20bindings.\x20Export\x20JSON\x20before\x20transfer.'}];export const SCHEMA_TO_SEMANTIC_RULES=[{'element_type':'field','type_name':'object','semantic_explanation':'Service\x20object\x20address.\x20STRING=operate\x20existing;\x20null/omitted=create\x20new'},{'element_type':'field','type_name':'description','semantic_explanation':'Human-readable\x20Service\x20description.\x20Mutable\x20pre/post\x20publish.\x20Max\x204000\x20chars.'},{'element_type':'field','type_name':'location','semantic_explanation':'The\x20service\x20area\x20and\x20scope\x20as\x20stated\x20by\x20the\x20merchant.\x20Mutable.\x20Index\x20303\x20(SERVICE_LOCATION).'},{'element_type':'field','type_name':'customer_required','semantic_explanation':'String[]\x20of\x20field\x20names\x20buyers\x20must\x20provide\x20at\x20order\x20time\x20(e.g.\x20[\x27name\x27,\x27phone\x27]).\x20Mutable.\x20Index\x20309.'},{'element_type':'field','type_name':'sales','semantic_explanation':'Product\x20SKU\x20list.\x20op=add/set/remove/clear.\x20Each\x20sale\x20has\x20name/price/stock/wip/wip_hash.\x20Index\x20305\x20(SERVICE_SALES).'},{'element_type':'field','type_name':'machine','semantic_explanation':'Machine\x20workflow\x20template\x20binding.\x20⚠️\x20IMMUTABLE\x20post-publish\x20(F-S-20).\x20Index\x20306\x20(SERVICE_MACHINE).'},{'element_type':'field','type_name':'buy_guard','semantic_explanation':'Buyer\x20eligibility\x20Guard.\x20⚠️\x20UNUSUAL:\x20still\x20mutable\x20post-publish\x20(F-S-26\x20exception).\x20Index\x20307\x20(SERVICE_BUY_GUARD).'},{'element_type':'field','type_name':'arbitrations','semantic_explanation':'Arbitration\x20object\x20list.\x20Required\x20if\x20compensation_fund\x20>\x200.\x20⚠️\x20IMMUTABLE\x20post-publish\x20(F-S-21).\x20Index\x20308.'},{'element_type':'field','type_name':'repositories','semantic_explanation':'Repository\x20object\x20list.\x20Mutable.\x20Max\x20100\x20(MAX_REPOSITORY_COUNT).\x20Index\x20304\x20(SERVICE_REPOSITORY).'},{'element_type':'field','type_name':'rewards','semantic_explanation':'Reward\x20object\x20list.\x20Mutable\x20but\x20locked\x20by\x20setting_lock_duration\x20(F-S-24).\x20Max\x2020\x20(MAX_REWARD_COUNT).\x20Index\x20318.'},{'element_type':'field','type_name':'order_allocators','semantic_explanation':'Fund\x20distribution\x20strategy.\x20⚠️\x20MANDATORY\x20for\x20publish\x20(F-S-18).\x20IMMUTABLE\x20post-publish\x20(F-S-22).\x20Index\x20313.'},{'element_type':'field','type_name':'discount','semantic_explanation':'Discount\x20coupon\x20issuance.\x20discount_type=0\x20rates,\x201=minus.\x20Index\x20312\x20(SERVICE_DISCOUNT).'},{'element_type':'field','type_name':'pause','semantic_explanation':'true=pause\x20(block\x20new\x20orders);\x20false=resume.\x20Existing\x20Progress\x20unaffected.\x20Index\x20310\x20(SERVICE_PAUSE).'},{'element_type':'field','type_name':'publish','semantic_explanation':'⚠️\x20IRREVERSIBLE\x20one-shot.\x20Requires\x20prerequisites.\x20Locks\x203\x20fields\x20forever.\x20Index\x20311\x20(SERVICE_PUBLISH).'},{'element_type':'field','type_name':'compensation_fund_add','semantic_explanation':'Deposit\x20to\x20internal\x20Balance<T>.\x20Always\x20mutable.\x20Index\x20315.\x20Distinct\x20from\x20Treasury.'},{'element_type':'field','type_name':'compensation_fund_withdraw','semantic_explanation':'Withdraw\x20from\x20internal\x20Balance<T>.\x20Requires\x20bPaused=true\x20+\x20lock_duration\x20expired.\x20Index\x20314.\x20Locked\x20by\x20duration\x20(F-S-25).'},{'element_type':'field','type_name':'compensation_fund_receive','semantic_explanation':'Receive\x20compensation_fund\x20(for\x20arbitration\x20payouts).\x20Locked\x20by\x20setting_lock_duration.\x20Index\x20316.'},{'element_type':'field','type_name':'setting_lock_duration_add','semantic_explanation':'Extend\x20setting_lock_duration\x20(only-increase,\x20safe_add).\x20Index\x20317\x20(SERVICE_COMPENSATION_LOCK_DURATION_ADD).'},{'element_type':'field','type_name':'order_new','semantic_explanation':'Composite\x20buy\x20operation.\x20Triggers\x208-stage\x20flow:\x20pre_check\x20→\x20wip_verify\x20→\x20quote\x20→\x20create_order/allocation/progress\x20→\x20post_actions\x20→\x20return_result.'},{'element_type':'field','type_name':'builder','semantic_explanation':'Transfer\x20ownership.\x20⚠️\x20IRREVERSIBLE.\x20Original\x20owner\x20loses\x20ALL\x20control.'},{'element_type':'field','type_name':'um','semantic_explanation':'User\x20Manager\x20(Contact\x20object).\x20Mutable.\x20Index\x20320\x20(SERVICE_UM).'},{'element_type':'field','type_name':'owner_receive','semantic_explanation':'Receive\x20Payment/objects\x20to\x20owner.\x20Index\x20319\x20(SERVICE_OWNER_RECEIVE).'},{'element_type':'op','type_name':'add','semantic_explanation':'Append\x20new\x20items\x20(sales/arbitrations/repositories/rewards).\x20Additive,\x20does\x20not\x20replace.'},{'element_type':'op','type_name':'set','semantic_explanation':'Replace\x20existing\x20item\x20by\x20name\x20(sales)\x20or\x20replace\x20entire\x20list\x20(repositories/rewards/arbitrations).'},{'element_type':'op','type_name':'remove','semantic_explanation':'Remove\x20specific\x20items\x20by\x20name\x20(sales)\x20or\x20address\x20(repositories/rewards/arbitrations).'},{'element_type':'op','type_name':'clear','semantic_explanation':'Remove\x20all\x20items\x20from\x20the\x20list.'}];export const SERVICE_CONSTRAINT_RULES=[{'id':'MC-S-01','category':'structural','rule':'Service\x20builtin\x20permission\x20indexes\x20must\x20be\x20in\x20range\x20300-320\x20(302\x20reserved/commented)','applies_to':['permission\x20table.index\x20(when\x20applied\x20to\x20Service)']},{'id':'MC-S-02','category':'structural','rule':'sales\x20count\x20<=\x20MAX_SALE_COUNT\x20('+MAX_SALE_COUNT+')','applies_to':['sales.sales']},{'id':'MC-S-03','category':'structural','rule':'repositories\x20count\x20<=\x20MAX_REPOSITORY_COUNT\x20('+MAX_REPOSITORY_COUNT+')','applies_to':['repositories.objects']},{'id':'MC-S-04','category':'structural','rule':'arbitrations\x20count\x20<=\x20MAX_ARBITRATION_COUNT\x20('+MAX_ARBITRATION_COUNT+')','applies_to':['arbitrations.objects']},{'id':'MC-S-05','category':'structural','rule':'rewards\x20count\x20<=\x20MAX_REWARD_COUNT\x20(20)','applies_to':['rewards.objects']},{'id':'MC-S-06','category':'structural','rule':'customer_required\x20count\x20<=\x2010,\x20each\x20item\x20length\x20<=\x2020','applies_to':['customer_required']},{'id':'MC-S-07','category':'structural','rule':'wip\x20URL\x20length\x20<=\x20MAX_WIP_LENGTH\x20('+MAX_WIP_LENGTH+')','applies_to':['sales.sales[].wip']},{'id':'MC-S-08','category':'structural','rule':'wip_hash\x20length\x20<=\x20MAX_WIP_HASH_LENGTH\x20('+MAX_WIP_HASH_LENGTH+')\x20—\x20sha256\x20hex\x20(64\x20chars,\x20no\x20prefix)','applies_to':['sales.sales[].wip_hash','order_new.buy.items[].wip_hash']},{'id':'MC-S-09','category':'semantic','rule':'wip_hash\x20must\x20NOT\x20be\x20empty\x20when\x20wip\x20URL\x20is\x20set\x20(tamper\x20protection)','applies_to':['sales.sales[]']},{'id':'MC-S-10','category':'authority','rule':'publish\x20requires\x20order_allocators\x20set\x20(F-S-18,\x20E_NO_ALLOCATOR)','applies_to':['publish','order_allocators']},{'id':'MC-S-11','category':'authority','rule':'publish\x20with\x20compensation_fund\x20>\x200\x20requires\x20arbitrations\x20non-empty\x20(F-S-19,\x20E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND)','applies_to':['publish','arbitrations','compensation_fund_add']},{'id':'MC-S-12','category':'lifecycle','rule':'machine\x20IMMUTABLE\x20post-publish\x20(F-S-20)\x20—\x20SDK\x20checkNotPublished()\x20blocks','applies_to':['machine']},{'id':'MC-S-13','category':'lifecycle','rule':'arbitrations\x20IMMUTABLE\x20post-publish\x20(F-S-21)\x20—\x20SDK\x20checkNotPublished()\x20blocks','applies_to':['arbitrations']},{'id':'MC-S-14','category':'lifecycle','rule':'order_allocators\x20IMMUTABLE\x20post-publish\x20(F-S-22)\x20—\x20SDK\x20checkNotPublished()\x20blocks','applies_to':['order_allocators']},{'id':'MC-S-15','category':'lifecycle','rule':'bPublished\x20is\x20IRREVERSIBLE\x20(one-shot,\x20cannot\x20revert\x20to\x20false)\x20—\x20to\x20\x27reset\x27,\x20create\x20new\x20Service','applies_to':['publish']},{'id':'MC-S-16','category':'lifecycle','rule':'setting_lock_duration\x20only-increase\x20(safe_add)\x20—\x20cannot\x20be\x20decreased;\x20protects\x20customers','applies_to':['setting_lock_duration_add']},{'id':'MC-S-17','category':'lifecycle','rule':'compensation_fund_withdraw\x20requires\x20bPaused=true\x20AND\x20setting_lock_duration\x20expired\x20(F-S-25,\x20F-S-26)','applies_to':['compensation_fund_withdraw','pause']},{'id':'MC-S-18','category':'semantic','rule':'discount\x20count\x20<=\x20MAX_DISCOUNT_TOTAL_COUNT\x20('+MAX_DISCOUNT_TOTAL_COUNT+');\x20per-call\x20<=\x20MAX_DISCOUNT_COUNT_ONCE\x20('+MAX_DISCOUNT_COUNT_ONCE+')','applies_to':['discount.count']},{'id':'MC-S-19','category':'semantic','rule':'buy_guard\x20is\x20the\x20ONLY\x20field\x20still\x20mutable\x20post-publish\x20(F-S-26\x20exception)\x20—\x20all\x20other\x20guarded\x20fields\x20are\x20immutable','applies_to':['buy_guard']},{'id':'MC-S-20','category':'authority','rule':'Ownership\x20transfer\x20(builder)\x20is\x20IRREVERSIBLE\x20—\x20new\x20owner\x20inherits\x20permission\x20+\x20compensation_fund\x20+\x20all\x20bindings','applies_to':['builder']}];export const SERVICE_TRANSLATION_VERSION='1.0.0';export function matchSemanticPattern(a){const b=a['toLowerCase']();return SEMANTIC_TO_SCHEMA_RULES['filter'](c=>c['match_keywords']['some'](d=>b['includes'](d['toLowerCase']())));}export function explainServiceCallData(b){const c=[];b['object']===null||b['object']===undefined?c['push']('Operation:\x20CREATE\x20new\x20Service'):c['push']('Operation:\x20MODIFY\x20existing\x20Service\x20at\x20'+b['object']);if(b['description'])c['push']('-\x20Set\x20description:\x20\x22'+b['description']+'\x22');if(b['location'])c['push']('-\x20Set\x20location:\x20'+b['location']);if(b['customer_required'])c['push']('-\x20Customer\x20required\x20fields:\x20['+b['customer_required']['join'](',\x20')+']');if(b['sales']){const e=b['sales'];if(e['op']==='clear')c['push']('-\x20Sales:\x20CLEAR\x20all\x20items');else{if(e['op']==='remove')c['push']('-\x20Sales\x20REMOVE:\x20['+e['sales_name']['join'](',\x20')+']');else{c['push']('-\x20Sales\x20'+e['op']['toUpperCase']()+':\x20'+e['sales']['length']+'\x20item(s)');for(const f of e['sales']){const g=f['wip_hash']?'\x20hash='+f['wip_hash']['slice'](0x0,0x8)+'...':'\x20⚠️NO_HASH';c['push']('\x20\x20\x20\x20•\x20'+f['name']+'\x20price='+(f['price']??'?')+'\x20stock='+(f['stock']??'?')+g);}}}}b['machine']!==undefined&&c['push'](b['machine']===null?'-\x20Machine:\x20unbind\x20(pre-publish\x20only)':'-\x20Machine:\x20bind\x20'+b['machine']);b['buy_guard']!==undefined&&c['push'](b['buy_guard']===null?'-\x20Buy\x20Guard:\x20clear':'-\x20Buy\x20Guard:\x20set\x20'+b['buy_guard']+'\x20[mutable\x20post-publish]');if(b['arbitrations']){const h=b['arbitrations'];h['op']==='clear'?c['push']('-\x20Arbitrations:\x20CLEAR\x20(pre-publish\x20only)'):c['push']('-\x20Arbitrations\x20'+h['op']['toUpperCase']()+':\x20'+h['objects']['length']+'\x20object(s)');}if(b['repositories']){const i=b['repositories'];i['op']==='clear'?c['push']('-\x20Repositories:\x20CLEAR'):c['push']('-\x20Repositories\x20'+i['op']['toUpperCase']()+':\x20'+i['objects']['length']+'\x20object(s)');}if(b['rewards']){const j=b['rewards'];j['op']==='clear'?c['push']('-\x20Rewards:\x20CLEAR\x20(locked\x20by\x20duration)'):c['push']('-\x20Rewards\x20'+j['op']['toUpperCase']()+':\x20'+j['objects']['length']+'\x20object(s)\x20[locked\x20by\x20duration]');}b['order_allocators']!==undefined&&c['push']('-\x20Order\x20Allocators:\x20'+(b['order_allocators']?'configured':'(clear)')+'\x20[immutable\x20post-publish]');if(b['discount']){const k=b['discount'],l=k['discount_type']===0x0?'rates\x20(basis\x20points,\x20per\x2010000)':'minus\x20(direct\x20deduction)';c['push']('-\x20Discount:\x20'+k['name']+'\x20type='+l+'\x20data='+k['data']+'\x20count='+k['count']);}b['pause']!==undefined&&c['push']('-\x20Pause:\x20'+(b['pause']?'PAUSE\x20(block\x20new\x20orders)':'RESUME'));b['publish']&&c['push']('-\x20⚠️\x20PUBLISH\x20(IRREVERSIBLE\x20—\x20locks\x20machine/arbitrations/order_allocators\x20forever)');b['compensation_fund_add']&&c['push']('-\x20Compensation\x20fund\x20deposit:\x20'+b['compensation_fund_add']['balance']+'\x20(internal\x20Balance<T>)');b['compensation_fund_withdraw']&&c['push']('-\x20⚠️\x20Compensation\x20fund\x20withdraw\x20(requires\x20bPaused=true\x20+\x20lock_duration\x20expired)');b['compensation_fund_receive']&&c['push']('-\x20Compensation\x20fund\x20receive\x20(locked\x20by\x20duration)');b['setting_lock_duration_add']!==undefined&&c['push']('-\x20Setting\x20lock\x20duration\x20+'+b['setting_lock_duration_add']+'ms\x20(only-increase)');if(b['order_new']){const m=b['order_new'];c['push']('-\x20⚠️\x20ORDER\x20NEW\x20(8-stage\x20composite\x20flow):'),c['push']('\x20\x20\x20\x20Items:\x20'+m['buy']['items']['length']),c['push']('\x20\x20\x20\x20Total\x20pay:\x20'+m['buy']['total_pay']);if(m['buy']['discount'])c['push']('\x20\x20\x20\x20Discount:\x20'+m['buy']['discount']);c['push']('\x20\x20\x20\x20Stages:\x20pre_check\x20→\x20wip_verify\x20→\x20quote\x20(deducts\x20stock!)\x20→\x20create_order/allocation/progress\x20→\x20return');}return b['builder']&&c['push']('-\x20⚠️\x20TRANSFER\x20ownership\x20to\x20'+b['builder']+'\x20(IRREVERSIBLE)'),b['um']!==undefined&&c['push'](b['um']===null?'-\x20UM:\x20revoke':'-\x20UM:\x20set\x20to\x20'+b['um']),b['owner_receive']&&c['push']('-\x20Owner\x20receive:\x20receive\x20Payment/objects\x20to\x20owner'),c['join']('\x0a');}export function explainField(a){return SCHEMA_TO_SEMANTIC_RULES['find'](b=>b['element_type']==='field'&&b['type_name']===a);}export function explainOp(a){return SCHEMA_TO_SEMANTIC_RULES['find'](b=>b['element_type']==='op'&&b['type_name']===a);}export function getConstraintsByCategory(a){return SERVICE_CONSTRAINT_RULES['filter'](b=>b['category']===a);}export function explainServicePermissionIndex(a){if(isServicePermission(a)){const b=getServicePermissionByIndex(a);if(!b)return'Unknown\x20Service\x20permission\x20('+a+')';const c=b['post_publish_mutability']==='immutable'?'\x20[IMMUTABLE\x20post-publish]':b['post_publish_mutability']==='one_shot'?'\x20[ONE-SHOT,\x20irreversible]':b['post_publish_mutability']==='locked_by_duration'?'\x20[locked\x20by\x20setting_lock_duration]':'';return b['name']+'\x20('+a+')\x20—\x20'+b['description']+c;}return'Non-Service\x20permission\x20('+a+')\x20—\x20verify\x20against\x20host\x20object\x27s\x20index\x20range';}