@wowok/agent-mcp 3.0.2 → 3.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) 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/flywheel-loop.d.ts +4 -52
  8. package/dist/knowledge/flywheel-loop.js +1 -1
  9. package/dist/knowledge/guard-lint.js +1 -1
  10. package/dist/knowledge/index.d.ts +2 -225
  11. package/dist/knowledge/index.js +1 -1
  12. package/dist/knowledge/industry-registry.js +1 -1
  13. package/dist/knowledge/machine-risk.js +1 -1
  14. package/dist/knowledge/machine-translation.js +1 -1
  15. package/dist/knowledge/onchain-constants.js +1 -1
  16. package/dist/knowledge/order-ledger.d.ts +2 -2
  17. package/dist/knowledge/order-ledger.js +1 -1
  18. package/dist/knowledge/order-puzzle.d.ts +4 -4
  19. package/dist/knowledge/order-puzzle.js +1 -1
  20. package/dist/knowledge/order-risk.d.ts +1 -0
  21. package/dist/knowledge/order-risk.js +1 -1
  22. package/dist/knowledge/order-templates.d.ts +1 -1
  23. package/dist/knowledge/order-templates.js +1 -1
  24. package/dist/knowledge/safety-rules.js +1 -1
  25. package/dist/knowledge/service-ledger.js +1 -1
  26. package/dist/knowledge/service-risk.js +1 -1
  27. package/dist/knowledge/template-registry.js +1 -1
  28. package/dist/knowledge/tools-reference.js +1 -1
  29. package/dist/knowledge/workspace-lists.js +1 -1
  30. package/dist/monitor/MonitorLoop.js +1 -1
  31. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  32. package/dist/playbooks/service-build/context-assembly.d.ts +3 -1
  33. package/dist/playbooks/service-build/context-assembly.js +1 -1
  34. package/dist/playbooks/service-build/machine-nodes.d.ts +2 -0
  35. package/dist/playbooks/service-build/machine-nodes.js +1 -1
  36. package/dist/playbooks/service-build/machine-panorama.d.ts +7 -0
  37. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  38. package/dist/review/machine.js +1 -1
  39. package/dist/safety/confirm-gate.js +1 -1
  40. package/dist/schema/call/base.d.ts +12 -3
  41. package/dist/schema/call/base.js +1 -1
  42. package/dist/schema/call/bridge.d.ts +4 -0
  43. package/dist/schema/call/bridge.js +1 -1
  44. package/dist/schema/call/error-codes.d.ts +2 -0
  45. package/dist/schema/call/error-codes.js +1 -0
  46. package/dist/schema/call/guard.d.ts +4 -4
  47. package/dist/schema/call/semantic.d.ts +9 -1
  48. package/dist/schema/call/semantic.js +1 -1
  49. package/dist/schema/common/index.js +1 -1
  50. package/dist/schema/goal/index.d.ts +3 -3
  51. package/dist/schema/goal/planning.d.ts +2 -2
  52. package/dist/schema/industry-pack/index.d.ts +4 -4
  53. package/dist/schema/industry-pack/modes.d.ts +4 -4
  54. package/dist/schema/local/index.d.ts +558 -0
  55. package/dist/schema/local/index.js +1 -1
  56. package/dist/schema/messenger/index.d.ts +25 -25
  57. package/dist/schema/operations.d.ts +1 -1
  58. package/dist/schema/persona/index.d.ts +2 -2
  59. package/dist/schema/query/bi.d.ts +0 -4
  60. package/dist/schema/query/bi.js +1 -1
  61. package/dist/schema/query/index.js +1 -1
  62. package/dist/schema/schema-query/index.d.ts +1 -1
  63. package/dist/schema/schema-version.js +1 -1
  64. package/dist/schema/trust/index.d.ts +3 -3
  65. package/dist/schema/workspace/index.d.ts +1 -1
  66. package/dist/schema-query-impl/index.js +1 -1
  67. package/dist/schemas/account_operation.output.json +4 -0
  68. package/dist/schemas/bridge_operation.output.json +4 -0
  69. package/dist/schemas/index.json +7 -1
  70. package/dist/schemas/local_history_operation.output.json +1458 -0
  71. package/dist/schemas/local_history_operation.schema.json +105 -0
  72. package/dist/schemas/local_info_operation.output.json +4 -0
  73. package/dist/schemas/local_mark_operation.output.json +4 -0
  74. package/dist/schemas/onchain_operations.output.json +4 -1
  75. package/dist/schemas/onchain_operations.schema.json +30 -10
  76. package/dist/schemas/onchain_operations_guard.schema.json +30 -10
  77. package/dist/schemas/query_toolkit.output.json +17 -16
  78. package/dist/tools/handlers/config.js +1 -1
  79. package/dist/tools/handlers/local.d.ts +1 -0
  80. package/dist/tools/handlers/local.js +1 -1
  81. package/dist/tools/handlers/onchain.js +1 -1
  82. package/dist/tools/index.js +1 -1
  83. package/dist/tools/registry/local.js +1 -1
  84. package/dist/tools/shared.js +1 -1
  85. package/dist/tools/wrap.js +1 -1
  86. package/package.json +2 -2
  87. package/dist/knowledge/allocation-confirm.d.ts +0 -115
  88. package/dist/knowledge/allocation-confirm.js +0 -1
  89. package/dist/knowledge/allocation-context.d.ts +0 -58
  90. package/dist/knowledge/allocation-context.js +0 -1
  91. package/dist/knowledge/allocation-translation.d.ts +0 -72
  92. package/dist/knowledge/allocation-translation.js +0 -1
  93. package/dist/knowledge/arb-confirm.d.ts +0 -28
  94. package/dist/knowledge/arb-confirm.js +0 -1
  95. package/dist/knowledge/arb-translation.d.ts +0 -48
  96. package/dist/knowledge/arb-translation.js +0 -1
  97. package/dist/knowledge/arbitration-confirm.d.ts +0 -135
  98. package/dist/knowledge/arbitration-confirm.js +0 -1
  99. package/dist/knowledge/arbitration-context.d.ts +0 -81
  100. package/dist/knowledge/arbitration-context.js +0 -1
  101. package/dist/knowledge/arbitration-translation.d.ts +0 -91
  102. package/dist/knowledge/arbitration-translation.js +0 -1
  103. package/dist/knowledge/bridge-confirm.d.ts +0 -26
  104. package/dist/knowledge/bridge-confirm.js +0 -1
  105. package/dist/knowledge/bridge-translation.d.ts +0 -37
  106. package/dist/knowledge/bridge-translation.js +0 -1
  107. package/dist/knowledge/contact-confirm.d.ts +0 -27
  108. package/dist/knowledge/contact-confirm.js +0 -1
  109. package/dist/knowledge/contact-translation.d.ts +0 -39
  110. package/dist/knowledge/contact-translation.js +0 -1
  111. package/dist/knowledge/demand-confirm.d.ts +0 -32
  112. package/dist/knowledge/demand-confirm.js +0 -1
  113. package/dist/knowledge/demand-context.d.ts +0 -17
  114. package/dist/knowledge/demand-context.js +0 -1
  115. package/dist/knowledge/demand-ledger.d.ts +0 -26
  116. package/dist/knowledge/demand-ledger.js +0 -1
  117. package/dist/knowledge/demand-puzzle.d.ts +0 -29
  118. package/dist/knowledge/demand-puzzle.js +0 -1
  119. package/dist/knowledge/demand-templates.d.ts +0 -12
  120. package/dist/knowledge/demand-templates.js +0 -1
  121. package/dist/knowledge/demand-translation.d.ts +0 -55
  122. package/dist/knowledge/demand-translation.js +0 -1
  123. package/dist/knowledge/examples-scanner-cli.d.ts +0 -1
  124. package/dist/knowledge/examples-scanner-cli.js +0 -1
  125. package/dist/knowledge/examples-scanner.d.ts +0 -121
  126. package/dist/knowledge/examples-scanner.js +0 -1
  127. package/dist/knowledge/glossary.d.ts +0 -18
  128. package/dist/knowledge/glossary.js +0 -1
  129. package/dist/knowledge/guard-bytecode-spec.d.ts +0 -82
  130. package/dist/knowledge/guard-bytecode-spec.js +0 -1
  131. package/dist/knowledge/guard-confirm.d.ts +0 -86
  132. package/dist/knowledge/guard-confirm.js +0 -1
  133. package/dist/knowledge/immutability.d.ts +0 -11
  134. package/dist/knowledge/immutability.js +0 -1
  135. package/dist/knowledge/machine-confirm.d.ts +0 -102
  136. package/dist/knowledge/machine-confirm.js +0 -1
  137. package/dist/knowledge/machine-context.d.ts +0 -160
  138. package/dist/knowledge/machine-context.js +0 -1
  139. package/dist/knowledge/machine-render.d.ts +0 -41
  140. package/dist/knowledge/machine-render.js +0 -1
  141. package/dist/knowledge/mcp-schema-audit-cli.d.ts +0 -1
  142. package/dist/knowledge/mcp-schema-audit-cli.js +0 -1
  143. package/dist/knowledge/mcp-schema-audit.d.ts +0 -91
  144. package/dist/knowledge/mcp-schema-audit.js +0 -1
  145. package/dist/knowledge/messenger-guard-guidance.d.ts +0 -17
  146. package/dist/knowledge/messenger-guard-guidance.js +0 -1
  147. package/dist/knowledge/order-confirm.d.ts +0 -115
  148. package/dist/knowledge/order-confirm.js +0 -1
  149. package/dist/knowledge/order-context.d.ts +0 -66
  150. package/dist/knowledge/order-context.js +0 -1
  151. package/dist/knowledge/order-translation.d.ts +0 -78
  152. package/dist/knowledge/order-translation.js +0 -1
  153. package/dist/knowledge/overrides-loader.d.ts +0 -13
  154. package/dist/knowledge/overrides-loader.js +0 -1
  155. package/dist/knowledge/passport-confirm.d.ts +0 -130
  156. package/dist/knowledge/passport-confirm.js +0 -1
  157. package/dist/knowledge/passport-context.d.ts +0 -59
  158. package/dist/knowledge/passport-context.js +0 -1
  159. package/dist/knowledge/passport-puzzle.d.ts +0 -108
  160. package/dist/knowledge/passport-puzzle.js +0 -1
  161. package/dist/knowledge/passport-risk.d.ts +0 -70
  162. package/dist/knowledge/passport-risk.js +0 -1
  163. package/dist/knowledge/passport-translation.d.ts +0 -68
  164. package/dist/knowledge/passport-translation.js +0 -1
  165. package/dist/knowledge/payment-confirm.d.ts +0 -26
  166. package/dist/knowledge/payment-confirm.js +0 -1
  167. package/dist/knowledge/payment-translation.d.ts +0 -37
  168. package/dist/knowledge/payment-translation.js +0 -1
  169. package/dist/knowledge/permission-confirm.d.ts +0 -110
  170. package/dist/knowledge/permission-confirm.js +0 -1
  171. package/dist/knowledge/permission-context.d.ts +0 -69
  172. package/dist/knowledge/permission-context.js +0 -1
  173. package/dist/knowledge/permission-translation.d.ts +0 -57
  174. package/dist/knowledge/permission-translation.js +0 -1
  175. package/dist/knowledge/personal-confirm.d.ts +0 -29
  176. package/dist/knowledge/personal-confirm.js +0 -1
  177. package/dist/knowledge/personal-translation.d.ts +0 -37
  178. package/dist/knowledge/personal-translation.js +0 -1
  179. package/dist/knowledge/process-model.d.ts +0 -14
  180. package/dist/knowledge/process-model.js +0 -1
  181. package/dist/knowledge/progress-confirm.d.ts +0 -108
  182. package/dist/knowledge/progress-confirm.js +0 -1
  183. package/dist/knowledge/progress-context.d.ts +0 -123
  184. package/dist/knowledge/progress-context.js +0 -1
  185. package/dist/knowledge/progress-translation.d.ts +0 -52
  186. package/dist/knowledge/progress-translation.js +0 -1
  187. package/dist/knowledge/proof-confirm.d.ts +0 -31
  188. package/dist/knowledge/proof-confirm.js +0 -1
  189. package/dist/knowledge/proof-context.d.ts +0 -17
  190. package/dist/knowledge/proof-context.js +0 -1
  191. package/dist/knowledge/proof-ledger.d.ts +0 -34
  192. package/dist/knowledge/proof-ledger.js +0 -1
  193. package/dist/knowledge/proof-puzzle.d.ts +0 -35
  194. package/dist/knowledge/proof-puzzle.js +0 -1
  195. package/dist/knowledge/proof-templates.d.ts +0 -22
  196. package/dist/knowledge/proof-templates.js +0 -1
  197. package/dist/knowledge/proof-translation.d.ts +0 -52
  198. package/dist/knowledge/proof-translation.js +0 -1
  199. package/dist/knowledge/registrar-confirm.d.ts +0 -26
  200. package/dist/knowledge/registrar-confirm.js +0 -1
  201. package/dist/knowledge/registrar-translation.d.ts +0 -37
  202. package/dist/knowledge/registrar-translation.js +0 -1
  203. package/dist/knowledge/repository-confirm.d.ts +0 -40
  204. package/dist/knowledge/repository-confirm.js +0 -1
  205. package/dist/knowledge/repository-context.d.ts +0 -12
  206. package/dist/knowledge/repository-context.js +0 -1
  207. package/dist/knowledge/repository-ledger.d.ts +0 -25
  208. package/dist/knowledge/repository-ledger.js +0 -1
  209. package/dist/knowledge/repository-puzzle.d.ts +0 -30
  210. package/dist/knowledge/repository-puzzle.js +0 -1
  211. package/dist/knowledge/repository-templates.d.ts +0 -14
  212. package/dist/knowledge/repository-templates.js +0 -1
  213. package/dist/knowledge/repository-translation.d.ts +0 -58
  214. package/dist/knowledge/repository-translation.js +0 -1
  215. package/dist/knowledge/resource-confirm.d.ts +0 -25
  216. package/dist/knowledge/resource-confirm.js +0 -1
  217. package/dist/knowledge/resource-translation.d.ts +0 -37
  218. package/dist/knowledge/resource-translation.js +0 -1
  219. package/dist/knowledge/reward-confirm.d.ts +0 -116
  220. package/dist/knowledge/reward-confirm.js +0 -1
  221. package/dist/knowledge/reward-context.d.ts +0 -127
  222. package/dist/knowledge/reward-context.js +0 -1
  223. package/dist/knowledge/reward-translation.d.ts +0 -58
  224. package/dist/knowledge/reward-translation.js +0 -1
  225. package/dist/knowledge/service-confirm.d.ts +0 -161
  226. package/dist/knowledge/service-confirm.js +0 -1
  227. package/dist/knowledge/service-context.d.ts +0 -66
  228. package/dist/knowledge/service-context.js +0 -1
  229. package/dist/knowledge/service-translation.d.ts +0 -103
  230. package/dist/knowledge/service-translation.js +0 -1
  231. package/dist/knowledge/treasury-confirm.d.ts +0 -133
  232. package/dist/knowledge/treasury-confirm.js +0 -1
  233. package/dist/knowledge/treasury-context.d.ts +0 -64
  234. package/dist/knowledge/treasury-context.js +0 -1
  235. package/dist/knowledge/treasury-translation.d.ts +0 -78
  236. package/dist/knowledge/treasury-translation.js +0 -1
  237. package/dist/knowledge/util-confirm.d.ts +0 -24
  238. package/dist/knowledge/util-confirm.js +0 -1
  239. package/dist/knowledge/util-translation.d.ts +0 -39
  240. package/dist/knowledge/util-translation.js +0 -1
  241. package/dist/loop-engineering/aggregate.d.ts +0 -50
  242. package/dist/loop-engineering/aggregate.js +0 -1
  243. package/dist/loop-engineering/context-collect.d.ts +0 -7
  244. package/dist/loop-engineering/context-collect.js +0 -1
  245. package/dist/loop-engineering/diagnose.d.ts +0 -22
  246. package/dist/loop-engineering/diagnose.js +0 -1
  247. package/dist/loop-engineering/improve.d.ts +0 -55
  248. package/dist/loop-engineering/improve.js +0 -1
  249. package/dist/loop-engineering/index.d.ts +0 -4
  250. package/dist/loop-engineering/index.js +0 -1
  251. package/dist/loop-engineering/pipeline.d.ts +0 -17
  252. package/dist/loop-engineering/pipeline.js +0 -1
  253. package/dist/schema/utils/object-type-utils.d.ts +0 -12
  254. package/dist/schema/utils/object-type-utils.js +0 -1
  255. package/dist/telemetry/index.d.ts +0 -19
  256. package/dist/telemetry/index.js +0 -1
  257. package/dist/telemetry/redact.d.ts +0 -2
  258. package/dist/telemetry/redact.js +0 -1
  259. package/dist/telemetry/storage.d.ts +0 -8
  260. package/dist/telemetry/storage.js +0 -1
@@ -1,133 +0,0 @@
1
- import { type TreasuryRiskAssessment } from "./treasury-risk.js";
2
- export type TreasuryConfirmGateStatus = "approved" | "blocked_checklist" | "blocked_risk" | "blocked_user" | "blocked_environment";
3
- export interface TreasuryConfirmGateResult {
4
- status: TreasuryConfirmGateStatus;
5
- checklist_result: TreasuryChecklistResult;
6
- risk_result?: TreasuryRiskAssessment;
7
- user_confirmation?: TreasuryUserConfirmation;
8
- environment_result?: TreasuryEnvironmentResult;
9
- confirmation_text?: string;
10
- block_reason?: string;
11
- decision_record: TreasuryDecisionRecord;
12
- }
13
- export interface TreasuryChecklistResult {
14
- all_passed: boolean;
15
- items: TreasuryChecklistItem[];
16
- }
17
- export interface TreasuryChecklistItem {
18
- id: string;
19
- description: string;
20
- passed: boolean;
21
- message: string;
22
- }
23
- export interface TreasuryUserConfirmation {
24
- questions_asked: TreasuryConfirmationQuestion[];
25
- responses: TreasuryConfirmationResponse[];
26
- all_confirmed: boolean;
27
- }
28
- export interface TreasuryConfirmationQuestion {
29
- id: string;
30
- question: string;
31
- requires_explicit_yes: boolean;
32
- related_risk_ids?: string[];
33
- }
34
- export interface TreasuryConfirmationResponse {
35
- question_id: string;
36
- response: "yes" | "no" | "skip";
37
- }
38
- export interface TreasuryEnvironmentResult {
39
- passed: boolean;
40
- checks: {
41
- name: string;
42
- passed: boolean;
43
- message: string;
44
- }[];
45
- }
46
- export interface TreasuryDecisionRecord {
47
- timestamp: string;
48
- gate_version: string;
49
- final_status: TreasuryConfirmGateStatus;
50
- layers_passed: string[];
51
- layers_failed: string[];
52
- }
53
- export interface TreasuryJsonForConfirm {
54
- object?: string | object | null;
55
- description?: string;
56
- deposit?: {
57
- coin?: {
58
- balance?: string;
59
- coin_object?: string;
60
- };
61
- by_external_deposit_guard?: string;
62
- payment_info?: {
63
- remark?: string;
64
- index: number;
65
- };
66
- };
67
- withdraw?: {
68
- amount?: {
69
- fixed?: string;
70
- by_external_withdraw_guard?: string;
71
- };
72
- recipient?: string;
73
- payment_info?: {
74
- remark?: string;
75
- index: number;
76
- };
77
- };
78
- external_deposit_guard?: {
79
- op: "add" | "set";
80
- guards: {
81
- guard: string;
82
- identifier?: number | null;
83
- store_from_id?: number | null;
84
- }[];
85
- } | {
86
- op: "remove";
87
- guards: string[];
88
- } | {
89
- op: "clear";
90
- };
91
- external_withdraw_guard?: {
92
- op: "add" | "set";
93
- guards: {
94
- guard: string;
95
- identifier?: number | null;
96
- store_from_id?: number | null;
97
- }[];
98
- } | {
99
- op: "remove";
100
- guards: string[];
101
- } | {
102
- op: "clear";
103
- };
104
- receive?: string[] | "recently";
105
- owner_receive?: string[] | "recently";
106
- um?: string | null;
107
- }
108
- export interface TreasuryConfirmGateInput {
109
- treasury_json: TreasuryJsonForConfirm;
110
- intent?: string;
111
- type_parameter?: string;
112
- permission_address?: string;
113
- current_balance?: string;
114
- current_external_deposit_guard_count?: number;
115
- current_external_withdraw_guard_count?: number;
116
- shared_with_service?: boolean;
117
- shared_with_allocator?: boolean;
118
- shared_with_arbitration?: boolean;
119
- current_permission_indexes_granted?: number[];
120
- skip_user_confirmation?: boolean;
121
- skip_environment_check?: boolean;
122
- }
123
- export declare const TREASURY_PUBLISH_CHECKLIST: TreasuryChecklistItem[];
124
- export declare const TREASURY_CONFIRMATION_QUESTIONS: TreasuryConfirmationQuestion[];
125
- export declare const TREASURY_CONFIRM_VERSION = "1.0.0";
126
- export declare function runTreasuryConfirmGate(input: TreasuryConfirmGateInput): TreasuryConfirmGateResult;
127
- export interface ProgressiveTreasuryCheckResult {
128
- stage: "checklist" | "risk" | "confirmation" | "environment" | "complete";
129
- status: "pass" | "fail" | "pending";
130
- message: string;
131
- next_action?: string;
132
- }
133
- export declare function progressiveTreasuryCheck(input: TreasuryConfirmGateInput): ProgressiveTreasuryCheckResult;
@@ -1 +0,0 @@
1
- import{assessTreasuryRisks}from'./treasury-risk.js';import{MAX_EXTERNAL_DEPOSIT_GUARD_COUNT,MAX_EXTERNAL_WITHDRAW_GUARD_COUNT,MAX_DESCRIPTION_LENGTH}from'./treasury-puzzle.js';export const TREASURY_PUBLISH_CHECKLIST=[{'id':'C-T-01','description':'type_parameter\x20(Coin\x20type\x20T)\x20specified\x20and\x20valid','passed':![],'message':''},{'id':'C-T-02','description':'Permission\x20object\x20configured\x20(new\x20or\x20existing)','passed':![],'message':''},{'id':'C-T-03','description':'description\x20length\x20<=\x20MAX_DESCRIPTION_LENGTH\x20(4000)','passed':![],'message':''},{'id':'C-T-04','description':'external_withdraw_guard.identifier\x20provided\x20(u8,\x20required)','passed':![],'message':''},{'id':'C-T-05','description':'external_deposit_guard\x20count\x20<=\x20MAX_EXTERNAL_DEPOSIT_GUARD_COUNT\x20(100)','passed':![],'message':''},{'id':'C-T-06','description':'external_withdraw_guard\x20count\x20<=\x20MAX_EXTERNAL_WITHDRAW_GUARD_COUNT\x20(200)','passed':![],'message':''},{'id':'C-T-07','description':'withdraw\x20recipient\x20address\x20valid','passed':![],'message':''},{'id':'C-T-08','description':'UM\x20address\x20is\x20valid\x20Contact\x20object\x20reference\x20(or\x20null\x20for\x20revoke)','passed':![],'message':''},{'id':'C-T-09','description':'withdraw\x20(fixed)\x20/\x20external_withdraw\x20double-confirmed\x20by\x20user','passed':![],'message':''},{'id':'C-T-10','description':'Permission\x20indexes\x20align\x20with\x20Move\x20on-chain\x20(no\x20stale\x20259/260)','passed':![],'message':''}];function runStaticChecklist(a){const b=TREASURY_PUBLISH_CHECKLIST['map'](p=>({...p})),c=a['treasury_json'],d=b['find'](p=>p['id']==='C-T-01');if(typeof c['object']==='object'&&c['object']!==null){const p=c['object'],q=!!p['type_parameter']&&p['type_parameter']['length']>0x0;d['passed']=q,d['message']=q?'':'type_parameter\x20missing\x20in\x20object\x20(required\x20for\x20creation)';}else{if(a['type_parameter'])d['passed']=!![];else typeof c['object']==='string'?d['passed']=!![]:(d['passed']=![],d['message']='Cannot\x20determine\x20type_parameter');}const e=b['find'](r=>r['id']==='C-T-02');if(typeof c['object']==='object'&&c['object']!==null){const r=c['object'],s=!!r['permission'];e['passed']=s,e['message']=s?'':'permission\x20missing\x20in\x20object\x20(required\x20for\x20creation)';}else a['permission_address']?e['passed']=!![]:e['passed']=!![];const f=b['find'](t=>t['id']==='C-T-03');if(c['description']!==undefined){const t=c['description']['length']<=MAX_DESCRIPTION_LENGTH;f['passed']=t,f['message']=t?'':'Description\x20length\x20'+c['description']['length']+'\x20>\x20'+MAX_DESCRIPTION_LENGTH;}else f['passed']=!![];const g=b['find'](u=>u['id']==='C-T-04');if(c['external_withdraw_guard']&&(c['external_withdraw_guard']['op']==='add'||c['external_withdraw_guard']['op']==='set')){const u=c['external_withdraw_guard']['guards']['filter'](w=>w['identifier']===undefined||w['identifier']===null),v=u['length']===0x0;g['passed']=v,g['message']=v?'':u['length']+'\x20withdraw\x20guard(s)\x20missing\x20identifier\x20(u8\x20required)';}else g['passed']=!![];const h=b['find'](w=>w['id']==='C-T-05');if(c['external_deposit_guard']&&(c['external_deposit_guard']['op']==='add'||c['external_deposit_guard']['op']==='set')){const w=a['current_external_deposit_guard_count']??0x0,x=c['external_deposit_guard']['guards']['length'],y=(c['external_deposit_guard']['op']==='set'?x:w+x)<=MAX_EXTERNAL_DEPOSIT_GUARD_COUNT;h['passed']=y,h['message']=y?'':'deposit_guard\x20count\x20'+(c['external_deposit_guard']['op']==='set'?x:w+x)+'\x20>\x20'+MAX_EXTERNAL_DEPOSIT_GUARD_COUNT;}else h['passed']=!![];const i=b['find'](z=>z['id']==='C-T-06');if(c['external_withdraw_guard']&&(c['external_withdraw_guard']['op']==='add'||c['external_withdraw_guard']['op']==='set')){const z=a['current_external_withdraw_guard_count']??0x0,A=c['external_withdraw_guard']['guards']['length'],B=(c['external_withdraw_guard']['op']==='set'?A:z+A)<=MAX_EXTERNAL_WITHDRAW_GUARD_COUNT;i['passed']=B,i['message']=B?'':'withdraw_guard\x20count\x20'+(c['external_withdraw_guard']['op']==='set'?A:z+A)+'\x20>\x20'+MAX_EXTERNAL_WITHDRAW_GUARD_COUNT;}else i['passed']=!![];const j=b['find'](C=>C['id']==='C-T-07');if(c['withdraw']?.['recipient']){const C=c['withdraw']['recipient']['startsWith']('0x')&&c['withdraw']['recipient']['length']>=0x28;j['passed']=C,j['message']=C?'':'Recipient\x20'+c['withdraw']['recipient']+'\x20invalid';}else c['withdraw']?(j['passed']=![],j['message']='withdraw\x20specified\x20without\x20recipient'):j['passed']=!![];const k=b['find'](D=>D['id']==='C-T-08');if(c['um']!==undefined){const D=c['um']===null||typeof c['um']==='string'&&c['um']['startsWith']('0x')&&c['um']['length']>=0x28;k['passed']=D,k['message']=D?'':'UM\x20'+c['um']+'\x20invalid\x20(must\x20be\x20Contact\x20object\x20address\x20or\x20null)';}else k['passed']=!![];const l=b['find'](E=>E['id']==='C-T-09');c['withdraw']?(l['passed']=![],l['message']='Pending\x20user\x20confirmation\x20in\x20Layer\x203\x20(QT3/QT4)'):l['passed']=!![];const m=b['find'](E=>E['id']==='C-T-10'),n=(a['current_permission_indexes_granted']??[])['filter'](E=>E===0x103||E===0x104),o=n['length']===0x0;return m['passed']=o,m['message']=o?'':'Stale\x20indexes\x20259/260\x20detected:\x20'+n['join'](',')+'\x20(R-T-01\x20regression)',{'all_passed':b['filter'](E=>E['id']!=='C-T-09')['every'](E=>E['passed']),'items':b};}function adaptRiskAssessment(a){const b={'object':typeof a['treasury_json']['object']==='string'?a['treasury_json']['object']:null,'description':a['treasury_json']['description'],'deposit':a['treasury_json']['deposit']?{'coin_balance':a['treasury_json']['deposit']['coin']?.['balance'],'coin_object':a['treasury_json']['deposit']['coin']?.['coin_object'],'by_external_deposit_guard':a['treasury_json']['deposit']['by_external_deposit_guard']}:undefined,'withdraw':a['treasury_json']['withdraw']?{'amount_fixed':a['treasury_json']['withdraw']['amount']?.['fixed'],'amount_by_external_withdraw_guard':a['treasury_json']['withdraw']['amount']?.['by_external_withdraw_guard'],'recipient':a['treasury_json']['withdraw']['recipient']}:undefined,'external_deposit_guard':a['treasury_json']['external_deposit_guard'],'external_withdraw_guard':a['treasury_json']['external_withdraw_guard'],'owner_receive':a['treasury_json']['owner_receive'],'um':a['treasury_json']['um'],'permission_address':a['permission_address'],'type_parameter':a['type_parameter'],'current_balance':a['current_balance'],'current_external_deposit_guard_count':a['current_external_deposit_guard_count'],'current_external_withdraw_guard_count':a['current_external_withdraw_guard_count'],'shared_with_service':a['shared_with_service'],'shared_with_allocator':a['shared_with_allocator'],'shared_with_arbitration':a['shared_with_arbitration'],'current_permission_indexes_granted':a['current_permission_indexes_granted']};return assessTreasuryRisks(b);}export const TREASURY_CONFIRMATION_QUESTIONS=[{'id':'QT1','question':'Is\x20the\x20Coin\x20type\x20T\x20(type_parameter)\x20correct\x20and\x20matching\x20all\x20expected\x20deposit/withdraw\x20operations?','requires_explicit_yes':!![]},{'id':'QT2','question':'Is\x20the\x20associated\x20Permission\x20object\x20correctly\x20configured\x20with\x20intended\x20admin/entity/index\x20assignments?','requires_explicit_yes':!![]},{'id':'QT3','question':'⚠️\x20If\x20withdrawing\x20(fixed\x20amount):\x20do\x20you\x20confirm\x20the\x20recipient\x20address\x20and\x20amount\x20are\x20correct?\x20This\x20operation\x20is\x20IRREVERSIBLE.','requires_explicit_yes':!![],'related_risk_ids':['R-T-4-01']},{'id':'QT4','question':'⚠️\x20If\x20external_withdraw\x20via\x20Guard:\x20do\x20you\x20confirm\x20the\x20Guard\x20rules\x20match\x20business\x20intent\x20and\x20the\x20identifier\x20points\x20to\x20the\x20correct\x20amount\x20field?\x20IRREVERSIBLE.','requires_explicit_yes':!![],'related_risk_ids':['R-T-4-02']},{'id':'QT5','question':'If\x20configuring\x20external_deposit/withdraw_guard:\x20are\x20the\x20Guard\x20table\x20fields\x20correctly\x20typed\x20(number\x20for\x20identifier,\x20address-compatible\x20for\x20store_from_id)?','requires_explicit_yes':!![],'related_risk_ids':['R-T-1-04']},{'id':'QT6','question':'If\x20sharing\x20Permission\x20with\x20a\x20Service\x20or\x20referenced\x20by\x20Allocator/Arbitration:\x20have\x20you\x20verified\x20the\x20cross-object\x20consistency\x20(R-T-5-01\x20/\x20R-T-5-02)?','requires_explicit_yes':![]}];function processUserConfirmation(a,b){const c=[...TREASURY_CONFIRMATION_QUESTIONS];if(!a['treasury_json']['withdraw']?.['amount']?.['fixed']){const d=c['findIndex'](e=>e['id']==='QT3');if(d>=0x0)c['splice'](d,0x1);}if(!a['treasury_json']['withdraw']?.['amount']?.['by_external_withdraw_guard']){const e=c['findIndex'](f=>f['id']==='QT4');if(e>=0x0)c['splice'](e,0x1);}if(!a['treasury_json']['external_deposit_guard']&&!a['treasury_json']['external_withdraw_guard']){const f=c['findIndex'](g=>g['id']==='QT5');if(f>=0x0)c['splice'](f,0x1);}if(!a['shared_with_service']&&!a['shared_with_allocator']&&!a['shared_with_arbitration']){const g=c['findIndex'](h=>h['id']==='QT6');if(g>=0x0)c['splice'](g,0x1);}if(a['skip_user_confirmation'])return{'questions_asked':c,'responses':c['map'](h=>({'question_id':h['id'],'response':'yes'})),'all_confirmed':!![]};return{'questions_asked':c,'responses':[],'all_confirmed':![]};}function verifyEnvironment(a){const b=[];typeof a['treasury_json']['object']==='string'&&b['push']({'name':'treasury_object_exists','passed':!![],'message':'Treasury\x20object\x20'+a['treasury_json']['object']+'\x20assumed\x20to\x20exist'});(a['permission_address']||typeof a['treasury_json']['object']==='object')&&b['push']({'name':'permission_object_exists','passed':!![],'message':'Permission\x20object\x20exists\x20and\x20is\x20bound\x20to\x20Treasury'});const c=[];a['treasury_json']['deposit']&&!a['treasury_json']['deposit']['by_external_deposit_guard']&&c['push'](0xfc);if(a['treasury_json']['withdraw']?.['amount']?.['fixed'])c['push'](0xfe);if(a['treasury_json']['external_deposit_guard'])c['push'](0xff);if(a['treasury_json']['external_withdraw_guard'])c['push'](0x100);if(a['treasury_json']['owner_receive'])c['push'](0x101);if(a['treasury_json']['um']!==undefined)c['push'](0x102);if(a['treasury_json']['receive'])c['push'](0xfd);if(c['length']>0x0){const e=a['current_permission_indexes_granted']??[],f=c['filter'](g=>!e['includes'](g));b['push']({'name':'signer_has_required_permissions','passed':f['length']===0x0,'message':f['length']===0x0?'Signer\x20has\x20all\x20required\x20indexes:\x20'+c['join'](','):'Signer\x20missing\x20required\x20indexes:\x20'+f['join'](',')+'\x20(granted:\x20'+e['join'](',')+')'});}(a['treasury_json']['deposit']?.['by_external_deposit_guard']||a['treasury_json']['withdraw']?.['amount']?.['by_external_withdraw_guard'])&&b['push']({'name':'passport_provided_for_external_ops','passed':!![],'message':'External\x20operations\x20require\x20Passport\x20submission\x20(verified\x20at\x20SDK\x20call\x20time)'});if(a['treasury_json']['withdraw']?.['amount']?.['fixed']&&a['current_balance']){const g=BigInt(a['treasury_json']['withdraw']['amount']['fixed']),h=BigInt(a['current_balance']),i=g<=h;b['push']({'name':'balance_sufficient_for_withdraw','passed':i,'message':i?'Balance\x20'+a['current_balance']+'\x20>=\x20withdraw\x20'+a['treasury_json']['withdraw']['amount']['fixed']:'Balance\x20'+a['current_balance']+'\x20<\x20withdraw\x20'+a['treasury_json']['withdraw']['amount']['fixed']+'\x20(E_WITHDRAW_INSUFFICIENT_AMOUNT)'});}const d=b['every'](j=>j['passed']);return{'passed':d,'checks':b};}export const TREASURY_CONFIRM_VERSION='1.0.0';export function runTreasuryConfirmGate(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'](h=>!h['passed'])['map'](h=>h['id'])['join'](',\x20'),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':TREASURY_CONFIRM_VERSION,'final_status':'blocked_checklist','layers_passed':b,'layers_failed':c}};b['push']('L1_checklist');const e=adaptRiskAssessment(a),f=e['risks']['some'](h=>h['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'](h=>h['level']==='CRITICAL')['map'](h=>h['id'])['join'](',\x20'),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':TREASURY_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['treasury_json']['withdraw']){const h=d['items']['find'](j=>j['id']==='C-T-09');if(h){const i=g['responses']['find'](l=>l['question_id']==='QT3'),j=g['responses']['find'](l=>l['question_id']==='QT4'),k=[i,j]['filter'](l=>l!==undefined);k['length']>0x0&&(h['passed']=k['every'](l=>l?.['response']==='yes'),h['message']=h['passed']?'':'Withdraw\x20not\x20confirmed\x20by\x20user');}}if(a['treasury_json']['withdraw']){const l=d['items']['find'](m=>m['id']==='C-T-09');if(l&&!l['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\x20withdraw\x20operation','decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':TREASURY_CONFIRM_VERSION,'final_status':'blocked_user','layers_passed':b,'layers_failed':c}};}}b['push']('L3_user');if(a['skip_environment_check'])b['push']('L4_environment');else{const m=verifyEnvironment(a);if(!m['passed'])return c['push']('L4_environment'),{'status':'blocked_environment','checklist_result':d,'risk_result':e,'user_confirmation':g,'environment_result':m,'confirmation_text':generateConfirmationText(a,d,e),'block_reason':'Environment\x20check\x20failed:\x20'+m['checks']['filter'](n=>!n['passed'])['map'](n=>n['name'])['join'](',\x20'),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':TREASURY_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,'confirmation_text':generateConfirmationText(a,d,e),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':TREASURY_CONFIRM_VERSION,'final_status':'approved','layers_passed':b,'layers_failed':c}};}function generateConfirmationText(a,b,c){const d=[],e=a['treasury_json'];d['push']('═══\x20Treasury\x20Confirmation\x20═══'),d['push']('');if(typeof e['object']==='string')d['push']('Treasury:\x20'+e['object']);else{if(typeof e['object']==='object'&&e['object']!==null){const f=e['object'];d['push']('Treasury:\x20NEW\x20(name='+(f['name']??'?')+',\x20T='+(f['type_parameter']??'?')+')');}else d['push']('Treasury:\x20(invalid\x20object\x20field)');}if(e['description'])d['push']('Description:\x20'+e['description']);if(a['type_parameter'])d['push']('Type\x20parameter:\x20'+a['type_parameter']);d['push'](''),d['push']('─\x20Checklist\x20──────────────────');for(const g of b['items']){const h=g['passed']?'✓':'✗';d['push']('\x20\x20'+h+'\x20'+g['id']+':\x20'+g['description']+(g['message']?'\x20—\x20'+g['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 i of c['risks']){d['push']('\x20\x20['+i['level']+']\x20'+i['id']+':\x20'+i['title']);}d['push']('');}d['push']('─\x20Operations\x20──────────────────');e['deposit']&&(e['deposit']['by_external_deposit_guard']?d['push']('-\x20External\x20deposit\x20via\x20guard:\x20'+e['deposit']['by_external_deposit_guard']):d['push']('-\x20Internal\x20deposit\x20(Permission\x20252)'));if(e['withdraw']){if(e['withdraw']['amount']?.['fixed'])d['push']('-\x20⚠️\x20Internal\x20withdraw\x20(Permission\x20254):\x20'+e['withdraw']['amount']['fixed']+'\x20to\x20'+(e['withdraw']['recipient']??'?'));else e['withdraw']['amount']?.['by_external_withdraw_guard']&&d['push']('-\x20⚠️\x20External\x20withdraw\x20via\x20guard:\x20'+e['withdraw']['amount']['by_external_withdraw_guard']+'\x20to\x20'+(e['withdraw']['recipient']??'?'));}if(e['receive'])d['push']('-\x20Receive\x20CoinWrapper\x20(Permission\x20253)');if(e['owner_receive'])d['push']('-\x20owner_receive\x20forward\x20(Permission\x20257)');if(e['external_deposit_guard'])d['push']('-\x20Manage\x20external_deposit_guard\x20(Permission\x20255):\x20op='+e['external_deposit_guard']['op']);if(e['external_withdraw_guard'])d['push']('-\x20Manage\x20external_withdraw_guard\x20(Permission\x20256):\x20op='+e['external_withdraw_guard']['op']);if(e['um']!==undefined)d['push']('-\x20UM:\x20'+(e['um']??'(revoke)'));return d['push'](''),d['join']('\x0a');}export function progressiveTreasuryCheck(a){const b=runStaticChecklist(a);if(!b['all_passed'])return{'stage':'checklist','status':'fail','message':'Checklist\x20failed:\x20'+b['items']['filter'](d=>!d['passed'])['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\x20(especially\x20withdraw\x20irreversibility)'};if(c['needs_human_review'])return{'stage':'confirmation','status':'pending','message':'Human\x20review\x20required\x20for\x20HIGH\x20risks\x20(withdraw/external\x20operations)','next_action':'Confirm\x20risk\x20acceptance\x20via\x20QT1-QT6\x20questions'};return{'stage':'complete','status':'pass','message':'All\x20checks\x20passed'};}
@@ -1,64 +0,0 @@
1
- import { type TreasuryScene, type BuiltinTreasuryPermissionEntry } from "./treasury-ledger.js";
2
- import { type TreasuryTemplate } from "./treasury-templates.js";
3
- import { type SemanticToSchemaRule } from "./treasury-translation.js";
4
- import { type TreasuryRiskRule, type TreasuryRiskAssessment, type TreasuryStakeholder } from "./treasury-risk.js";
5
- import { type TreasuryPuzzle, type TreasuryPuzzleCompleteness } from "./treasury-puzzle.js";
6
- import { TREASURY_PUBLISH_CHECKLIST, TREASURY_CONFIRMATION_QUESTIONS, type TreasuryJsonForConfirm } from "./treasury-confirm.js";
7
- export declare const TREASURY_CONTEXT_VERSION = "1.0.0";
8
- export type TreasuryInjectionMode = "initial_design" | "mid_design_review" | "pre_publish" | "post_publish_modify" | "stakeholder_review" | "cross_object_check";
9
- export type TreasuryStakeholderPerspective = TreasuryStakeholder | "system";
10
- export interface TreasuryContextBundle {
11
- version: string;
12
- mode: TreasuryInjectionMode;
13
- stakeholder_perspective?: TreasuryStakeholderPerspective;
14
- matched_scene?: TreasuryScene;
15
- matched_template?: TreasuryTemplate;
16
- matched_pattern?: SemanticToSchemaRule;
17
- puzzle_state?: TreasuryPuzzle;
18
- puzzle_completeness?: TreasuryPuzzleCompleteness;
19
- relevant_risks: TreasuryRiskRule[];
20
- risk_assessment?: TreasuryRiskAssessment;
21
- relevant_checklist: typeof TREASURY_PUBLISH_CHECKLIST;
22
- relevant_questions: typeof TREASURY_CONFIRMATION_QUESTIONS;
23
- relevant_builtin_permissions: BuiltinTreasuryPermissionEntry[];
24
- reserved_builtin_permissions: BuiltinTreasuryPermissionEntry[];
25
- cross_object_refs: TreasuryCrossObjectRef[];
26
- onchain_constraints: TreasuryOnchainConstraint[];
27
- rendering_hints: TreasuryRenderingHints;
28
- }
29
- export interface TreasuryCrossObjectRef {
30
- object: "Permission" | "Guard" | "Passport" | "Payment" | "CoinWrapper" | "Contact" | "Allocator" | "Arbitration" | "Service" | "Registrar" | "Clock" | "ObjectLinkerCore";
31
- field: string;
32
- description: string;
33
- collaboration_type: "dependency" | "referenced_by" | "parallel_design";
34
- }
35
- export interface TreasuryOnchainConstraint {
36
- name: string;
37
- value: string | number;
38
- description: string;
39
- }
40
- export interface TreasuryRenderingHints {
41
- include_puzzle_template: boolean;
42
- include_risk_details: boolean;
43
- include_questions: boolean;
44
- include_irreversibility_warning: boolean;
45
- include_external_guard_warning: boolean;
46
- include_cross_object_warning: boolean;
47
- max_length: number;
48
- }
49
- export interface BuildTreasuryContextInput {
50
- mode: TreasuryInjectionMode;
51
- intent?: string;
52
- treasury_json?: TreasuryJsonForConfirm;
53
- stakeholder?: TreasuryStakeholderPerspective;
54
- target_permission_index?: number;
55
- type_parameter?: string;
56
- max_length?: number;
57
- shared_with_service?: boolean;
58
- shared_with_allocator?: boolean;
59
- shared_with_arbitration?: boolean;
60
- current_permission_indexes_granted?: number[];
61
- }
62
- export declare function buildTreasuryContext(input: BuildTreasuryContextInput): TreasuryContextBundle;
63
- export declare function buildPromptFromTreasuryContext(bundle: TreasuryContextBundle): string;
64
- export declare function getTreasuryContextSummary(bundle: TreasuryContextBundle): string;
@@ -1 +0,0 @@
1
- import{USER_DEFINED_PERM_INDEX_START,MAX_ADMIN_COUNT,MAX_PERM_FOR_ENTITY,MAX_ENTITY_COUNT}from'@wowok/wowok';import{findSceneById,findSceneByPermissionIndex,inferSceneFromIntent,getActiveBuiltinPermissions,getReservedBuiltinPermissions}from'./treasury-ledger.js';import{getTemplatesByScene}from'./treasury-templates.js';import{matchSemanticPattern}from'./treasury-translation.js';import{getAllTreasuryRiskRules,assessTreasuryRisks}from'./treasury-risk.js';import{initPuzzleFromIntent,checkPuzzleCompleteness,MAX_EXTERNAL_DEPOSIT_GUARD_COUNT,MAX_EXTERNAL_WITHDRAW_GUARD_COUNT,MAX_DESCRIPTION_LENGTH}from'./treasury-puzzle.js';import{TREASURY_PUBLISH_CHECKLIST,TREASURY_CONFIRMATION_QUESTIONS}from'./treasury-confirm.js';export const TREASURY_CONTEXT_VERSION='1.0.0';export function buildTreasuryContext(a){const b=a['max_length']??0xfa0;let c;if(a['intent'])c=inferSceneFromIntent(a['intent']);else a['target_permission_index']!==undefined&&(c=findSceneByPermissionIndex(a['target_permission_index']));!c&&a['intent']&&(c=findSceneById('treasury_fund_collection'));let d;if(c){const q=getTemplatesByScene(c['id']);if(q['length']>0x0)d=q[0x0];}let e;if(a['intent']){const r=matchSemanticPattern(a['intent']);if(r['length']>0x0)e=r[0x0];}let f,g;a['mode']==='initial_design'&&a['intent']&&(f=initPuzzleFromIntent({'rule_sentence':a['intent']}),g=checkPuzzleCompleteness(f));const h=filterRiskRules(a['mode'],a['stakeholder'],c);let i;if((a['mode']==='pre_publish'||a['mode']==='mid_design_review')&&a['treasury_json']){const s={'object':typeof a['treasury_json']['object']==='string'?a['treasury_json']['object']:null,'description':a['treasury_json']['description'],'deposit':a['treasury_json']['deposit']?{'coin_balance':a['treasury_json']['deposit']['coin']?.['balance'],'coin_object':a['treasury_json']['deposit']['coin']?.['coin_object'],'by_external_deposit_guard':a['treasury_json']['deposit']['by_external_deposit_guard']}:undefined,'withdraw':a['treasury_json']['withdraw']?{'amount_fixed':a['treasury_json']['withdraw']['amount']?.['fixed'],'amount_by_external_withdraw_guard':a['treasury_json']['withdraw']['amount']?.['by_external_withdraw_guard'],'recipient':a['treasury_json']['withdraw']['recipient']}:undefined,'external_deposit_guard':a['treasury_json']['external_deposit_guard'],'external_withdraw_guard':a['treasury_json']['external_withdraw_guard'],'owner_receive':a['treasury_json']['owner_receive'],'um':a['treasury_json']['um'],'type_parameter':a['type_parameter'],'shared_with_service':a['shared_with_service'],'shared_with_allocator':a['shared_with_allocator'],'shared_with_arbitration':a['shared_with_arbitration'],'current_permission_indexes_granted':a['current_permission_indexes_granted']};i=assessTreasuryRisks(s);}const j=filterChecklist(a['mode']),k=filterQuestions(a['mode']),l=c?c['builtin_indexes']['filter'](t=>t['active']):getActiveBuiltinPermissions(),m=getReservedBuiltinPermissions(),n=buildCrossObjectRefs(a['mode'],c),o=buildOnchainConstraints(),p=buildRenderingHints(a['mode'],b,!!a['treasury_json']?.['withdraw'],!!a['treasury_json']?.['external_deposit_guard']||!!a['treasury_json']?.['external_withdraw_guard'],!!a['shared_with_service']||!!a['shared_with_allocator']||!!a['shared_with_arbitration']);return{'version':TREASURY_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,'reserved_builtin_permissions':m,'cross_object_refs':n,'onchain_constraints':o,'rendering_hints':p};}function filterRiskRules(a,b,c){let d=getAllTreasuryRiskRules();if(a==='initial_design')return d['filter'](e=>e['category']==='structural'||e['category']==='authority');if(a==='pre_publish')return d;if(a==='stakeholder_review'&&b){if(b==='owner')return d['filter'](e=>e['category']==='authority'||e['category']==='lifecycle');if(b==='admin')return d['filter'](e=>e['category']==='structural'||e['category']==='semantic');if(b==='depositor')return d['filter'](e=>e['id']==='R-T-2-02'||e['id']==='R-T-2-03'||e['category']==='structural');if(b==='withdrawer')return d['filter'](e=>e['id']==='R-T-4-01'||e['id']==='R-T-4-02'||e['id']==='R-T-3-01');if(b==='external_operator')return d['filter'](e=>e['id']==='R-T-2-01'||e['id']==='R-T-2-03'||e['id']==='R-T-4-02');if(b==='system')return d['filter'](e=>e['category']==='cross_object'||e['id']==='R-T-0-01');}if(a==='cross_object_check')return d['filter'](e=>e['category']==='cross_object');return d;}function filterChecklist(a){if(a==='initial_design')return TREASURY_PUBLISH_CHECKLIST['filter'](b=>['C-T-01','C-T-02','C-T-03','C-T-10']['includes'](b['id']));return TREASURY_PUBLISH_CHECKLIST;}function filterQuestions(a){if(a==='pre_publish')return TREASURY_CONFIRMATION_QUESTIONS;if(a==='post_publish_modify')return TREASURY_CONFIRMATION_QUESTIONS['filter'](b=>b['id']!=='QT1');return[];}function buildCrossObjectRefs(a,b){const c=[];return c['push']({'object':'Permission','field':'permission','description':'All\x20Treasury\x20write\x20operations\x20(except\x20external_deposit/withdraw)\x20require\x20Permission\x20authorization\x20via\x20indexes\x20250-258','collaboration_type':'dependency'}),c['push']({'object':'ObjectLinkerCore','field':'object_linker','description':'Tracks\x20object-linker\x20core\x20bindings\x20between\x20Treasury,\x20Permission,\x20and\x20UM\x20(Contact)\x20objects','collaboration_type':'dependency'}),c['push']({'object':'Clock','field':'clock','description':'Provides\x20timestamp\x20for\x20Record\x20entries\x20in\x20history\x20ParentTable','collaboration_type':'dependency'}),(b?.['id']==='treasury_external_ops'||b?.['id']==='treasury_guard_protection'||a==='cross_object_check')&&(c['push']({'object':'Guard','field':'external_deposit_guard\x20/\x20external_withdraw_guard','description':'Guard\x20objects\x20referenced\x20by\x20external_*_guard\x20lists;\x20provide\x20programmable\x20access\x20rules\x20for\x20external\x20deposit/withdraw','collaboration_type':'dependency'}),c['push']({'object':'Passport','field':'passport','description':'Required\x20for\x20every\x20external_deposit\x20/\x20external_withdraw\x20call;\x20carries\x20submission\x20values\x20verified\x20by\x20Guard','collaboration_type':'dependency'})),c['push']({'object':'Allocator','field':'sharing.who=Entity','description':'Allocator\x20can\x20reference\x20Treasury\x20address\x20as\x20fund\x20split\x20target;\x20Treasury.receive\x20(253)\x20converts\x20CoinWrapper\x20to\x20balance','collaboration_type':'referenced_by'}),c['push']({'object':'Arbitration','field':'fees_transfer','description':'Arbitration.fees_transfer\x20sends\x20Payment\x20to\x20Treasury\x20address;\x20Treasury.receive\x20(253)\x20required\x20to\x20intake','collaboration_type':'referenced_by'}),c['push']({'object':'Service','field':'compensation_fund\x20(parallel\x20design)','description':'Service.compensation_fund\x20is\x20a\x20parallel\x20design\x20(NOT\x20a\x20Treasury\x20object);\x20both\x20are\x20Balance<T>\x20containers\x20but\x20implementation-independent','collaboration_type':'parallel_design'}),c['push']({'object':'Contact','field':'um','description':'Optional\x20UM\x20(User\x20Manager)\x20Contact\x20object;\x20manages\x20user-tier\x20information\x20via\x20object_linker::affiliation_core','collaboration_type':'dependency'}),c['push']({'object':'Payment','field':'history\x20ParentTable','description':'Every\x20deposit/withdraw/receive\x20creates\x20a\x20Payment\x20object;\x20Payment\x20address\x20is\x20the\x20key\x20in\x20history\x20ParentTable','collaboration_type':'dependency'}),c['push']({'object':'CoinWrapper','field':'receive','description':'CoinWrapper\x20is\x20the\x20received\x20form\x20of\x20coins;\x20Treasury.receive\x20(253)\x20unwraps\x20CoinWrapper\x20to\x20balance','collaboration_type':'dependency'}),c;}function buildOnchainConstraints(){return[{'name':'MAX_EXTERNAL_DEPOSIT_GUARD_COUNT','value':MAX_EXTERNAL_DEPOSIT_GUARD_COUNT,'description':'Maximum\x20external_deposit_guard\x20entries\x20(Treasury-specific,\x20not\x20yet\x20in\x20onchain-constants.ts)'},{'name':'MAX_EXTERNAL_WITHDRAW_GUARD_COUNT','value':MAX_EXTERNAL_WITHDRAW_GUARD_COUNT,'description':'Maximum\x20external_withdraw_guard\x20entries\x20(Treasury-specific,\x20not\x20yet\x20in\x20onchain-constants.ts)'},{'name':'MAX_DESCRIPTION_LENGTH','value':MAX_DESCRIPTION_LENGTH,'description':'Maximum\x20description\x20length\x20(shared\x20across\x20all\x20objects)'},{'name':'USER_DEFINED_PERM_INDEX_START','value':USER_DEFINED_PERM_INDEX_START,'description':'Custom\x20permission\x20indexes\x20must\x20be\x20>=\x20this\x20value'},{'name':'MAX_ENTITY_COUNT','value':MAX_ENTITY_COUNT,'description':'Maximum\x20entities\x20per\x20Permission\x20(shared)'},{'name':'MAX_PERM_FOR_ENTITY','value':MAX_PERM_FOR_ENTITY,'description':'Maximum\x20permission\x20indexes\x20per\x20entity\x20(shared)'},{'name':'MAX_ADMIN_COUNT','value':MAX_ADMIN_COUNT,'description':'Maximum\x20admins\x20per\x20Permission\x20(shared)'}];}function buildRenderingHints(a,b,c,d,e){return{'include_puzzle_template':a==='initial_design','include_risk_details':a==='pre_publish'||a==='stakeholder_review'||a==='mid_design_review','include_questions':a==='pre_publish','include_irreversibility_warning':c,'include_external_guard_warning':d,'include_cross_object_warning':e||a==='cross_object_check','max_length':b};}export function buildPromptFromTreasuryContext(a){const b=[],d=a['rendering_hints'];b['push']('═══\x20Treasury\x20Context\x20(mode:\x20'+a['mode']+')\x20═══'),b['push']('');a['stakeholder_perspective']&&(b['push']('Stakeholder\x20perspective:\x20'+a['stakeholder_perspective']),b['push'](''));a['matched_scene']&&(b['push']('Scene:\x20'+a['matched_scene']['name']),b['push']('Scene\x20ID:\x20'+a['matched_scene']['id']),b['push']('Permission\x20range:\x20'+a['matched_scene']['permission_index_range']),b['push'](''));a['matched_template']&&(b['push']('Suggested\x20template:\x20'+a['matched_template']['id']+'\x20—\x20'+a['matched_template']['name']),b['push'](''));if(d['include_puzzle_template']&&a['puzzle_completeness']){const e=a['puzzle_completeness'];b['push']('─\x20Puzzle\x20Completeness\x20──────────────'),b['push']('Complete:\x20'+(e['complete']?'YES':'NO')),e['missing']['length']>0x0&&b['push']('Missing:\x20'+e['missing']['join'](',\x20')),b['push']('Next:\x20'+e['next_step']),b['push']('');}if(d['include_risk_details']&&a['relevant_risks']['length']>0x0){b['push']('─\x20Relevant\x20Risk\x20Rules\x20('+a['relevant_risks']['length']+')\x20──────────────');for(const f of a['relevant_risks']['slice'](0x0,0x8)){b['push']('\x20\x20'+f['id']+'\x20—\x20'+f['trigger']);}a['relevant_risks']['length']>0x8&&b['push']('\x20\x20...\x20and\x20'+(a['relevant_risks']['length']-0x8)+'\x20more'),b['push']('');}if(a['risk_assessment']){b['push']('─\x20Risk\x20Assessment\x20──────────────'),b['push']('Overall:\x20'+a['risk_assessment']['overall_risk']),b['push']('Detected:\x20'+a['risk_assessment']['risks']['length']+'\x20risk(s)');for(const g of a['risk_assessment']['risks']['slice'](0x0,0x5)){b['push']('\x20\x20['+g['level']+']\x20'+g['id']+':\x20'+g['title']);}b['push']('');}if(a['relevant_builtin_permissions']['length']>0x0){b['push']('─\x20Builtin\x20Treasury\x20Permissions\x20(active:\x20'+a['relevant_builtin_permissions']['length']+')\x20──────────────');for(const i of a['relevant_builtin_permissions']){b['push']('\x20\x20['+i['index']+']\x20'+i['name']+':\x20'+i['description']);}b['push']('');}if(a['reserved_builtin_permissions']['length']>0x0){b['push']('─\x20Reserved\x20(no\x20Permission\x20index)\x20──────────────');for(const j of a['reserved_builtin_permissions']){b['push']('\x20\x20'+j['name']+':\x20'+j['description']);}b['push']('');}d['include_irreversibility_warning']&&(b['push']('⚠️\x20WITHDRAW\x20OPERATION\x20DETECTED\x20—\x20IRREVERSIBLE'),b['push']('\x20\x20-\x20withdraw\x20(fixed)\x20and\x20external_withdraw\x20cannot\x20be\x20undone'),b['push']('\x20\x20-\x20verify\x20recipient\x20address\x20twice'),b['push']('\x20\x20-\x20ensure\x20balance\x20sufficiency'),b['push'](''));d['include_external_guard_warning']&&(b['push']('⚠️\x20EXTERNAL\x20GUARD\x20MANAGEMENT\x20—\x20Verify\x20Guard\x20table\x20fields'),b['push']('\x20\x20-\x20identifier\x20must\x20be\x20number-type\x20(u8/u16/u32/u64/u128/u256)'),b['push']('\x20\x20-\x20store_from_id\x20must\x20be\x20address-compatible'),b['push']('\x20\x20-\x20external_withdraw_guard.identifier\x20is\x20REQUIRED\x20(u8,\x20not\x20Option)'),b['push']('\x20\x20-\x20external_deposit_guard.identifier\x20is\x20Option<u8>\x20(None\x20=\x20no\x20amount\x20limit)'),b['push'](''));d['include_cross_object_warning']&&(b['push']('⚠️\x20CROSS-OBJECT\x20COLLABORATION\x20—\x20Verify\x20consistency'),b['push']('\x20\x20-\x20If\x20shared\x20with\x20Service:\x20verify\x20Permission\x20indexes\x20250-258\x20(Treasury)\x20and\x20300-320\x20(Service)\x20align'),b['push']('\x20\x20-\x20If\x20referenced\x20by\x20Allocator/Arbitration:\x20TREASURY_RECEIVE\x20(253)\x20must\x20be\x20granted\x20for\x20CoinWrapper\x20intake'),b['push'](''));if(a['cross_object_refs']['length']>0x0){b['push']('─\x20Cross-Object\x20References\x20('+a['cross_object_refs']['length']+')\x20──────────────');for(const k of a['cross_object_refs']['slice'](0x0,0x6)){b['push']('\x20\x20['+k['collaboration_type']+']\x20'+k['object']+'.'+k['field']),b['push']('\x20\x20\x20\x20'+k['description']);}a['cross_object_refs']['length']>0x6&&b['push']('\x20\x20...\x20and\x20'+(a['cross_object_refs']['length']-0x6)+'\x20more'),b['push']('');}if(a['onchain_constraints']['length']>0x0){b['push']('─\x20On-chain\x20Constraints\x20──────────────');for(const l of a['onchain_constraints']){b['push']('\x20\x20'+l['name']+'\x20=\x20'+l['value']+'\x20—\x20'+l['description']);}b['push']('');}if(d['include_questions']&&a['relevant_questions']['length']>0x0){b['push']('─\x20Confirmation\x20Questions\x20──────────────');for(const m of a['relevant_questions']){const n=m['requires_explicit_yes']?'\x20⚠️':'';b['push']('\x20\x20'+m['id']+n+':\x20'+m['question']);}b['push']('');}return b['join']('\x0a');}export function getTreasuryContextSummary(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['stakeholder_perspective'])b['push']('stakeholder='+a['stakeholder_perspective']);if(a['risk_assessment'])b['push']('overall_risk='+a['risk_assessment']['overall_risk']);if(a['matched_template'])b['push']('template='+a['matched_template']['id']);return b['join'](',\x20');}
@@ -1,78 +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 TreasuryConstraintRule {
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 TREASURY_CONSTRAINT_RULES: TreasuryConstraintRule[];
25
- export declare const TREASURY_TRANSLATION_VERSION = "1.0.0";
26
- export declare function matchSemanticPattern(userIntent: string): SemanticToSchemaRule[];
27
- export interface TreasuryCallDataForExplanation {
28
- object?: string | object | null;
29
- description?: string;
30
- receive?: string[] | "recently" | object;
31
- deposit?: {
32
- coin?: {
33
- balance?: string;
34
- coin_object?: string;
35
- };
36
- by_external_deposit_guard?: string;
37
- payment_info?: {
38
- remark?: string;
39
- index: number;
40
- };
41
- };
42
- withdraw?: {
43
- amount?: {
44
- fixed?: string;
45
- by_external_withdraw_guard?: string;
46
- };
47
- recipient?: string;
48
- payment_info?: {
49
- remark?: string;
50
- index: number;
51
- };
52
- };
53
- external_deposit_guard?: {
54
- op: "add" | "set";
55
- guards: object[];
56
- } | {
57
- op: "remove";
58
- guards: string[];
59
- } | {
60
- op: "clear";
61
- };
62
- external_withdraw_guard?: {
63
- op: "add" | "set";
64
- guards: object[];
65
- } | {
66
- op: "remove";
67
- guards: string[];
68
- } | {
69
- op: "clear";
70
- };
71
- owner_receive?: string[] | "recently";
72
- um?: string | null;
73
- }
74
- export declare function explainTreasuryCallData(data: TreasuryCallDataForExplanation): string;
75
- export declare function explainField(fieldName: string): SchemaToSemanticRule | undefined;
76
- export declare function explainOp(opName: string): SchemaToSemanticRule | undefined;
77
- export declare function getConstraintsByCategory(category: TreasuryConstraintRule["category"]): TreasuryConstraintRule[];
78
- export declare function explainTreasuryPermissionIndex(index: number): string;
@@ -1 +0,0 @@
1
- import{isBuiltinTreasuryPermission,getBuiltinPermissionByIndex,findSceneByPermissionIndex}from'./treasury-ledger.js';export const SEMANTIC_TO_SCHEMA_RULES=[{'id':'T-T-01','pattern_name':'Create\x20new\x20Treasury','semantic_intent':'Create\x20a\x20new\x20Treasury\x20with\x20a\x20Coin\x20type\x20T\x20and\x20associated\x20Permission','match_keywords':['create','new'],'schema_fields':['object\x20(TypeNamedObjectWithPermission)','description'],'example_json':{'object':{'name':'myteam_treasury','type_parameter':'0x2::wow::WOW','permission':{'name':'myteam_treasury_permission','description':'Permission\x20for\x20myteam\x20treasury'}},'description':'Team\x20treasury\x20for\x20project\x20X\x20funding'},'reverse_explanation':'object\x20must\x20be\x20in\x20OBJECT\x20format\x20(not\x20STRING)\x20for\x20creation;\x20type_parameter\x20is\x20the\x20Coin\x20type\x20T;\x20permission\x20can\x20be\x20new\x20or\x20existing'},{'id':'T-T-02','pattern_name':'Internal\x20deposit\x20(Permission\x20path)','semantic_intent':'Deposit\x20funds\x20to\x20Treasury\x20via\x20Permission\x20authorization','match_keywords':['deposit'],'schema_fields':['object\x20(string)','deposit.coin','deposit.payment_info'],'example_json':{'object':'myteam_treasury','deposit':{'coin':{'balance':'1000000000'},'payment_info':{'remark':'Q3\x20budget\x20allocation','index':0x0}}},'reverse_explanation':'deposit.by_external_deposit_guard\x20omitted\x20→\x20Permission\x20path\x20(TREASURY_DEPOSIT=252);\x20coin\x20can\x20be\x20{balance}\x20or\x20{coin_object}'},{'id':'T-T-03','pattern_name':'Internal\x20withdraw\x20(Permission\x20path,\x20fixed\x20amount)','semantic_intent':'Withdraw\x20fixed\x20amount\x20from\x20Treasury\x20via\x20Permission\x20authorization','match_keywords':['withdraw'],'schema_fields':['object\x20(string)','withdraw.amount.fixed','withdraw.recipient','withdraw.payment_info'],'example_json':{'object':'myteam_treasury','withdraw':{'amount':{'fixed':'500000000'},'recipient':'0xRECIPIENT','payment_info':{'remark':'Vendor\x20payment','index':0x1}}},'reverse_explanation':'withdraw.amount.fixed\x20→\x20Permission\x20path\x20(TREASURY_WITHDRAW=254);\x20amount\x20is\x20fixed\x20u64;\x20irreversible'},{'id':'T-T-04','pattern_name':'External\x20deposit\x20(Guard\x20+\x20Passport\x20path)','semantic_intent':'External\x20user\x20deposits\x20via\x20preset\x20Guard\x20verification\x20(no\x20Permission\x20needed)','match_keywords':['external\x20deposit','guard\x20deposit'],'schema_fields':['object\x20(string)','deposit.coin','deposit.by_external_deposit_guard','deposit.payment_info','submission\x20(Passport)'],'example_json':{'object':'myteam_treasury','deposit':{'coin':{'balance':'200000000'},'by_external_deposit_guard':'deposit_guard_v1','payment_info':{'remark':'External\x20deposit\x20via\x20guard','index':0x2}}},'reverse_explanation':'deposit.by_external_deposit_guard\x20present\x20→\x20Guard\x20path\x20(NO\x20Permission\x20check);\x20Passport\x20required\x20via\x20submission\x20field;\x20amount\x20may\x20split\x20if\x20coin\x20>\x20guard-specified'},{'id':'T-T-05','pattern_name':'External\x20withdraw\x20(Guard\x20+\x20Passport\x20path,\x20amount\x20from\x20Guard)','semantic_intent':'External\x20user\x20withdraws\x20via\x20preset\x20Guard\x20verification;\x20amount\x20determined\x20by\x20Guard\x20table\x20identifier','match_keywords':['external\x20withdraw','guard\x20withdraw'],'schema_fields':['object\x20(string)','withdraw.amount.by_external_withdraw_guard','withdraw.recipient','withdraw.payment_info','submission\x20(Passport)'],'example_json':{'object':'myteam_treasury','withdraw':{'amount':{'by_external_withdraw_guard':'withdraw_guard_v1'},'recipient':'0xRECIPIENT','payment_info':{'remark':'External\x20withdraw\x20via\x20guard','index':0x3}}},'reverse_explanation':'withdraw.amount.by_external_withdraw_guard\x20→\x20Guard\x20path\x20(NO\x20Permission\x20check);\x20amount\x20comes\x20from\x20Guard\x20table\x20identifier\x20(u8,\x20required);\x20irreversible'},{'id':'T-T-06','pattern_name':'Manage\x20external\x20deposit/withdraw\x20Guard\x20(add/set/remove/clear)','semantic_intent':'Add,\x20set,\x20remove,\x20or\x20clear\x20external_deposit_guard\x20/\x20external_withdraw_guard\x20lists','match_keywords':['guard\x20add','guard\x20set','guard\x20remove','guard\x20clear'],'schema_fields':['object\x20(string)','external_deposit_guard\x20|\x20external_withdraw_guard'],'example_json':{'object':'myteam_treasury','external_deposit_guard':{'op':'add','guards':[{'guard':'deposit_guard_v1','identifier':0x2,'store_from_id':null}]}},'reverse_explanation':'op=\x27add\x27\x20(upsert)\x20/\x20\x27set\x27\x20(clear+add)\x20/\x20\x27remove\x27\x20(by\x20guard\x20address)\x20/\x20\x27clear\x27\x20(empty\x20list);\x20Permission\x20index\x20255\x20(deposit)\x20/\x20256\x20(withdraw)\x20required'},{'id':'T-T-07','pattern_name':'Receive\x20CoinWrapper\x20/\x20owner_receive\x20forward','semantic_intent':'Receive\x20CoinWrapper\x20into\x20balance,\x20or\x20forward\x20received\x20objects\x20to\x20Permission\x20owner','match_keywords':['receive','owner_receive','forward'],'schema_fields':['object\x20(string)','receive\x20|\x20owner_receive'],'example_json':{'object':'myteam_treasury','receive':'recently'},'reverse_explanation':'receive\x20→\x20TREASURY_RECEIVE=253,\x20converts\x20CoinWrapper\x20to\x20balance,\x20writes\x20Record;\x20owner_receive\x20→\x20TREASURY_OWNER_RECEIVE=257,\x20forwards\x20to\x20Permission.owner,\x20no\x20Record'},{'id':'T-T-08','pattern_name':'Set\x20UM\x20/\x20modify\x20description','semantic_intent':'Delegate\x20User\x20Manager\x20(Contact\x20object)\x20or\x20modify\x20Treasury\x20description','match_keywords':['um','um_set','um_none','description','delegate'],'schema_fields':['object\x20(string)','um\x20|\x20description'],'example_json':{'object':'myteam_treasury','um':'team_contact'},'reverse_explanation':'um=address\x20→\x20TREASURY_UM=258\x20(um_set);\x20um=null\x20→\x20TREASURY_UM=258\x20(um_none);\x20description=string\x20→\x20TREASURY_DESCRIPTION=251'}];export const SCHEMA_TO_SEMANTIC_RULES=[{'element_type':'field','type_name':'object','semantic_explanation':'Treasury\x20object\x20reference.\x20STRING=operate\x20existing;\x20OBJECT={name,\x20type_parameter,\x20permission}=create\x20new','constraints':['type_parameter\x20required\x20at\x20creation,\x20immutable\x20thereafter','permission\x20can\x20be\x20new\x20(TypeNamedObject)\x20or\x20existing\x20(string\x20address)']},{'element_type':'field','type_name':'description','semantic_explanation':'Human-readable\x20description\x20of\x20Treasury\x20purpose.\x20Max\x204000\x20chars\x20(MAX_DESCRIPTION_LENGTH).','constraints':['<=\x204000\x20chars','Modifiable\x20via\x20TREASURY_DESCRIPTION\x20(251)']},{'element_type':'field','type_name':'deposit','semantic_explanation':'Deposit\x20operation.\x20Two\x20access\x20paths:\x20(1)\x20Permission\x20path\x20(by_external_deposit_guard\x20omitted,\x20requires\x20TREASURY_DEPOSIT=252);\x20(2)\x20Guard\x20path\x20(by_external_deposit_guard\x20set,\x20requires\x20Passport,\x20no\x20Permission)'},{'element_type':'field','type_name':'deposit.coin','semantic_explanation':'Coin\x20to\x20deposit.\x20{balance:\x20string}\x20for\x20amount;\x20{coin_object:\x20string}\x20for\x20existing\x20Coin\x20object.\x20Type\x20T\x20must\x20match\x20Treasury\x27s\x20type_parameter.'},{'element_type':'field','type_name':'deposit.by_external_deposit_guard','semantic_explanation':'Guard\x20address\x20or\x20name\x20for\x20external\x20deposit\x20path.\x20Triggers\x20Guard\x20+\x20Passport\x20verification;\x20bypasses\x20Permission\x20check.','constraints':['Guard\x20must\x20be\x20in\x20external_deposit_guard\x20list\x20(else\x20E_EXTERNAL_DEPOSIT_GUARD_NOT_FOUND)','Passport\x20required']},{'element_type':'field','type_name':'withdraw','semantic_explanation':'Withdraw\x20operation.\x20Two\x20access\x20paths:\x20(1)\x20Permission\x20path\x20(amount.fixed,\x20requires\x20TREASURY_WITHDRAW=254);\x20(2)\x20Guard\x20path\x20(amount.by_external_withdraw_guard,\x20requires\x20Passport,\x20no\x20Permission)'},{'element_type':'field','type_name':'withdraw.amount.fixed','semantic_explanation':'Fixed\x20u64\x20withdraw\x20amount\x20(Permission\x20path).\x20Irreversible.\x20Recipient\x20specified\x20separately.','constraints':['Must\x20be\x20<=\x20balance\x20(else\x20E_WITHDRAW_INSUFFICIENT_AMOUNT)','u64\x20format']},{'element_type':'field','type_name':'withdraw.amount.by_external_withdraw_guard','semantic_explanation':'Guard\x20address/name\x20for\x20external\x20withdraw\x20path.\x20Amount\x20determined\x20by\x20Guard\x20table\x20identifier\x20(not\x20caller-specified).','constraints':['Guard\x20must\x20be\x20in\x20external_withdraw_guard\x20list','Passport\x20required','Amount\x20from\x20Guard\x20is\x20authoritative']},{'element_type':'field','type_name':'external_deposit_guard','semantic_explanation':'Manage\x20external_deposit_guard\x20list.\x20op:\x20add\x20(upsert)\x20/\x20set\x20(clear+add)\x20/\x20remove\x20(by\x20address)\x20/\x20clear\x20(empty).\x20Requires\x20TREASURY_EXTERNAL_DEPOSIT_GUARD=255.','constraints':['Max\x20100\x20guards\x20(MAX_EXTERNAL_DEPOSIT_GUARD_COUNT)','identifier\x20is\x20Option<u8>\x20(None\x20=\x20no\x20amount\x20limit)','store_from_id\x20is\x20Option<u8>']},{'element_type':'field','type_name':'external_withdraw_guard','semantic_explanation':'Manage\x20external_withdraw_guard\x20list.\x20op:\x20add/set/remove/clear.\x20Requires\x20TREASURY_EXTERNAL_WITHDRAW_GUARD=256.','constraints':['Max\x20200\x20guards\x20(MAX_EXTERNAL_WITHDRAW_GUARD_COUNT)','identifier\x20is\x20u8\x20(REQUIRED,\x20not\x20Option)','store_from_id\x20is\x20Option<u8>']},{'element_type':'field','type_name':'receive','semantic_explanation':'Receive\x20CoinWrapper\x20objects\x20into\x20balance.\x20Requires\x20TREASURY_RECEIVE=253.\x20Writes\x20Record(op=RECEIVE)\x20to\x20history.','constraints':['CoinWrapper\x20type\x20T\x20must\x20match\x20Treasury\x27s\x20T','\x27recently\x27\x20resolves\x20to\x20all\x20un-received\x20CoinWrapper']},{'element_type':'field','type_name':'owner_receive','semantic_explanation':'Unwrap\x20received\x20objects\x20(CoinWrapper\x20+\x20others)\x20and\x20forward\x20to\x20Permission.owner.\x20Requires\x20TREASURY_OWNER_RECEIVE=257.\x20Does\x20NOT\x20write\x20to\x20history.','constraints':['Irreversible\x20(funds\x20leave\x20Treasury)','Recipient\x20is\x20Permission.owner\x20(resolved\x20at\x20tx\x20time)']},{'element_type':'field','type_name':'um','semantic_explanation':'User\x20Manager\x20(Contact\x20object\x20address).\x20um=address\x20→\x20um_set;\x20um=null\x20→\x20um_none.\x20Requires\x20TREASURY_UM=258.','constraints':['Must\x20be\x20a\x20Contact\x20object\x20(not\x20user\x20wallet)','UM\x20≠\x20admin\x20(no\x20permission\x20management)']},{'element_type':'op','type_name':'add','semantic_explanation':'Upsert\x20semantics:\x20if\x20guard\x20exists,\x20update\x20identifier/store_from_id;\x20else\x20append\x20(after\x20count\x20check)'},{'element_type':'op','type_name':'set','semantic_explanation':'Replace\x20entire\x20list:\x20clear\x20first,\x20then\x20add.\x20Use\x20when\x20wholesale\x20replacement\x20is\x20intended.'},{'element_type':'op','type_name':'remove','semantic_explanation':'Remove\x20specific\x20guards\x20by\x20address.\x20Count\x20check\x20uses\x20MAX\x20as\x20upper\x20bound\x20(not\x20subtractive).'},{'element_type':'op','type_name':'clear','semantic_explanation':'Empty\x20the\x20entire\x20guard\x20list.\x20No\x20count\x20check\x20needed.'}];export const TREASURY_CONSTRAINT_RULES=[{'id':'MC-T-01','category':'structural','rule':'description\x20length\x20<=\x20MAX_DESCRIPTION_LENGTH\x20(4000)','applies_to':['description']},{'id':'MC-T-02','category':'structural','rule':'external_deposit_guard\x20count\x20<=\x20MAX_EXTERNAL_DEPOSIT_GUARD_COUNT\x20(100)','applies_to':['external_deposit_guard.guards']},{'id':'MC-T-03','category':'structural','rule':'external_withdraw_guard\x20count\x20<=\x20MAX_EXTERNAL_WITHDRAW_GUARD_COUNT\x20(200)','applies_to':['external_withdraw_guard.guards']},{'id':'MC-T-04','category':'structural','rule':'external_withdraw_guard.identifier\x20is\x20u8\x20(REQUIRED,\x20not\x20Option<u8>)','applies_to':['external_withdraw_guard.guards[].identifier']},{'id':'MC-T-05','category':'structural','rule':'external_deposit_guard.identifier\x20is\x20Option<u8>\x20(None\x20means\x20no\x20amount\x20limit)','applies_to':['external_deposit_guard.guards[].identifier']},{'id':'MC-T-06','category':'semantic','rule':'Coin\x20type\x20T\x20must\x20match\x20Treasury\x27s\x20type_parameter\x20for\x20all\x20deposit/withdraw/receive\x20operations','applies_to':['deposit.coin','withdraw.amount.fixed','receive']},{'id':'MC-T-07','category':'authority','rule':'deposit\x20via\x20Permission\x20path\x20requires\x20TREASURY_DEPOSIT\x20(252);\x20deposit\x20via\x20Guard\x20path\x20requires\x20no\x20Permission\x20(Guard+Passport\x20only)','applies_to':['deposit.by_external_deposit_guard']},{'id':'MC-T-08','category':'authority','rule':'withdraw.amount.fixed\x20requires\x20TREASURY_WITHDRAW\x20(254);\x20withdraw.amount.by_external_withdraw_guard\x20requires\x20no\x20Permission','applies_to':['withdraw.amount']},{'id':'MC-T-09','category':'authority','rule':'external_deposit_guard\x20management\x20requires\x20TREASURY_EXTERNAL_DEPOSIT_GUARD\x20(255);\x20external_withdraw_guard\x20management\x20requires\x20TREASURY_EXTERNAL_WITHDRAW_GUARD\x20(256)','applies_to':['external_deposit_guard','external_withdraw_guard']},{'id':'MC-T-10','category':'lifecycle','rule':'withdraw\x20(fixed)\x20and\x20external_withdraw\x20are\x20IRREVERSIBLE;\x20verify\x20recipient\x20and\x20amount\x20before\x20execution','applies_to':['withdraw.amount.fixed','withdraw.amount.by_external_withdraw_guard']},{'id':'MC-T-11','category':'lifecycle','rule':'owner_receive\x20forwards\x20assets\x20to\x20Permission.owner\x20and\x20does\x20NOT\x20write\x20to\x20history;\x20verify\x20owner\x20address\x20is\x20current','applies_to':['owner_receive']},{'id':'MC-T-12','category':'lifecycle','rule':'um_set\x20requires\x20Contact\x20object\x20address\x20(not\x20user\x20wallet);\x20um_set\x20vs\x20um_none\x20both\x20use\x20TREASURY_UM\x20(258)','applies_to':['um']},{'id':'MC-T-13','category':'cross_object','rule':'If\x20Treasury\x20is\x20referenced\x20by\x20Allocator/Arbitration,\x20TREASURY_RECEIVE\x20(253)\x20must\x20be\x20granted\x20to\x20a\x20trusted\x20operator\x20for\x20regular\x20intake','applies_to':['receive']},{'id':'MC-T-14','category':'semantic','rule':'external_deposit\x20may\x20split\x20coin\x20if\x20value\x20>\x20guard-specified\x20amount;\x20excess\x20refunded\x20to\x20sender','applies_to':['deposit.by_external_deposit_guard']},{'id':'MC-T-15','category':'semantic','rule':'inflow/outflow\x20are\x20monotonic\x20counters\x20(never\x20decrease);\x20used\x20for\x20audit\x20reconciliation:\x20theoretical\x20balance\x20=\x20inflow\x20-\x20outflow','applies_to':['(read-only\x20audit\x20fields)']}];export const TREASURY_TRANSLATION_VERSION='1.0.0';export function matchSemanticPattern(a){const b=a['toLowerCase'](),c=[];(b['includes']('create')||b['includes']('new'))&&c['push'](SEMANTIC_TO_SCHEMA_RULES[0x0]);b['includes']('deposit')&&(b['includes']('external')||b['includes']('guard')?c['push'](SEMANTIC_TO_SCHEMA_RULES[0x3]):c['push'](SEMANTIC_TO_SCHEMA_RULES[0x1]));b['includes']('withdraw')&&(b['includes']('external')||b['includes']('guard')?c['push'](SEMANTIC_TO_SCHEMA_RULES[0x4]):c['push'](SEMANTIC_TO_SCHEMA_RULES[0x2]));(b['includes']('guard\x20add')||b['includes']('guard\x20set')||b['includes']('guard\x20remove')||b['includes']('guard\x20clear'))&&c['push'](SEMANTIC_TO_SCHEMA_RULES[0x5]);(b['includes']('receive')||b['includes']('owner_receive')||b['includes']('forward'))&&c['push'](SEMANTIC_TO_SCHEMA_RULES[0x6]);(b['includes']('um')||b['includes']('delegate')||b['includes']('user\x20manager')||b['includes']('description'))&&c['push'](SEMANTIC_TO_SCHEMA_RULES[0x7]);if(c['length']===0x0)return[...SEMANTIC_TO_SCHEMA_RULES];return c;}export function explainTreasuryCallData(a){const b=[];if(a['object']===null||a['object']===undefined)b['push']('Operation:\x20INVALID\x20(object\x20field\x20required)');else{if(typeof a['object']==='string')b['push']('Operation:\x20OPERATE\x20existing\x20Treasury\x20at\x20'+a['object']);else{if(typeof a['object']==='object'){const c=a['object'];b['push']('Operation:\x20CREATE\x20new\x20Treasury');if(c['name'])b['push']('\x20\x20name:\x20'+c['name']);if(c['type_parameter'])b['push']('\x20\x20type_parameter\x20(T):\x20'+c['type_parameter']);c['permission']&&(typeof c['permission']==='string'?b['push']('\x20\x20permission:\x20existing\x20'+c['permission']):b['push']('\x20\x20permission:\x20new\x20(TypeNamedObject)'));}}}a['description']&&b['push']('-\x20Set\x20description:\x20\x22'+a['description']+'\x22');if(a['deposit']){const e=a['deposit'];if(e['by_external_deposit_guard']){b['push']('-\x20External\x20deposit\x20via\x20guard:\x20'+e['by_external_deposit_guard']);if(e['coin']?.['balance'])b['push']('\x20\x20coin\x20balance:\x20'+e['coin']['balance']+'\x20(may\x20split\x20if\x20>\x20guard\x20limit)');if(e['coin']?.['coin_object'])b['push']('\x20\x20coin\x20object:\x20'+e['coin']['coin_object']);b['push']('\x20\x20⚠️\x20No\x20Permission\x20check;\x20Passport\x20required');}else{b['push']('-\x20Internal\x20deposit\x20via\x20Permission\x20(TREASURY_DEPOSIT=252)');if(e['coin']?.['balance'])b['push']('\x20\x20coin\x20balance:\x20'+e['coin']['balance']);if(e['coin']?.['coin_object'])b['push']('\x20\x20coin\x20object:\x20'+e['coin']['coin_object']);}if(e['payment_info']?.['remark'])b['push']('\x20\x20payment\x20remark:\x20\x22'+e['payment_info']['remark']+'\x22');}if(a['withdraw']){const f=a['withdraw'];if(f['amount']?.['fixed'])b['push']('-\x20Internal\x20withdraw\x20via\x20Permission\x20(TREASURY_WITHDRAW=254)'),b['push']('\x20\x20amount:\x20'+f['amount']['fixed']+'\x20(fixed,\x20IRREVERSIBLE)');else f['amount']?.['by_external_withdraw_guard']&&(b['push']('-\x20External\x20withdraw\x20via\x20guard:\x20'+f['amount']['by_external_withdraw_guard']),b['push']('\x20\x20⚠️\x20Amount\x20determined\x20by\x20Guard\x20table\x20identifier\x20(not\x20caller-specified)'),b['push']('\x20\x20⚠️\x20IRREVERSIBLE;\x20No\x20Permission\x20check;\x20Passport\x20required'));if(f['recipient'])b['push']('\x20\x20recipient:\x20'+f['recipient']);if(f['payment_info']?.['remark'])b['push']('\x20\x20payment\x20remark:\x20\x22'+f['payment_info']['remark']+'\x22');}if(a['receive']){if(a['receive']==='recently')b['push']('-\x20Receive\x20all\x20recently-received\x20CoinWrapper\x20(TREASURY_RECEIVE=253)');else Array['isArray'](a['receive'])&&b['push']('-\x20Receive\x20'+a['receive']['length']+'\x20CoinWrapper\x20object(s)\x20(TREASURY_RECEIVE=253)');}if(a['external_deposit_guard']){const h=a['external_deposit_guard'];if(h['op']==='clear')b['push']('-\x20Clear\x20external_deposit_guard\x20list\x20(TREASURY_EXTERNAL_DEPOSIT_GUARD=255)');else{if(h['op']==='remove')b['push']('-\x20Remove\x20'+h['guards']['length']+'\x20guard(s)\x20from\x20external_deposit_guard\x20(Permission\x20255)');else{const i=h['guards']['length'];b['push']('-\x20'+(h['op']==='set'?'Set\x20(clear+add)':'Add\x20(upsert)')+'\x20'+i+'\x20external_deposit_guard(s)\x20(Permission\x20255)');}}}if(a['external_withdraw_guard']){const j=a['external_withdraw_guard'];if(j['op']==='clear')b['push']('-\x20Clear\x20external_withdraw_guard\x20list\x20(TREASURY_EXTERNAL_WITHDRAW_GUARD=256)');else{if(j['op']==='remove')b['push']('-\x20Remove\x20'+j['guards']['length']+'\x20guard(s)\x20from\x20external_withdraw_guard\x20(Permission\x20256)');else{const k=j['guards']['length'];b['push']('-\x20'+(j['op']==='set'?'Set\x20(clear+add)':'Add\x20(upsert)')+'\x20'+k+'\x20external_withdraw_guard(s)\x20(Permission\x20256)'),b['push']('\x20\x20⚠️\x20withdraw\x20guard\x20identifier\x20is\x20REQUIRED\x20(u8,\x20not\x20Option)');}}}if(a['owner_receive']){if(a['owner_receive']==='recently')b['push']('-\x20owner_receive:\x20forward\x20all\x20recently-received\x20objects\x20to\x20Permission.owner\x20(TREASURY_OWNER_RECEIVE=257)');else Array['isArray'](a['owner_receive'])&&b['push']('-\x20owner_receive:\x20forward\x20'+a['owner_receive']['length']+'\x20object(s)\x20to\x20Permission.owner\x20(Permission\x20257)');b['push']('\x20\x20⚠️\x20IRREVERSIBLE;\x20does\x20NOT\x20write\x20to\x20history');}return a['um']!==undefined&&(a['um']===null?b['push']('-\x20UM\x20revoke\x20(um_none,\x20TREASURY_UM=258)'):b['push']('-\x20UM\x20set\x20to\x20'+a['um']+'\x20(TREASURY_UM=258)')),b['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 TREASURY_CONSTRAINT_RULES['filter'](b=>b['category']===a);}export function explainTreasuryPermissionIndex(a){if(isBuiltinTreasuryPermission(a)){const b=getBuiltinPermissionByIndex(a),c=findSceneByPermissionIndex(a);return(b?.['name']??'Unknown')+'\x20('+a+')\x20—\x20'+(b?.['description']??'')+'\x20[scene:\x20'+(c?.['id']??'unknown')+']';}if(a===-0x1)return'Reserved\x20(no\x20Permission\x20index)\x20—\x20external\x20operations\x20use\x20Guard\x20+\x20Passport\x20instead';if(a>=0x3e8)return'Custom\x20permission\x20('+a+')\x20—\x20must\x20be\x20documented\x20via\x20Permission.remark;\x20not\x20used\x20by\x20Treasury\x20builtin\x20operations';if(a===0x103||a===0x104)return'STALE\x20index\x20'+a+'\x20—\x20was\x20pre-fix\x20SDK\x20value;\x20canonical\x20post-fix\x20indexes\x20are\x20255-258.\x20See\x20R-T-01.';return'Index\x20'+a+'\x20—\x20not\x20a\x20Treasury\x20builtin\x20permission\x20(range\x20250-258)';}
@@ -1,24 +0,0 @@
1
- export declare const UTIL_CONFIRM_VERSION = "1.0.0";
2
- export type ConfirmSeverity = "block" | "warn" | "info";
3
- export interface UtilConfirmItem {
4
- id: string;
5
- severity: ConfirmSeverity;
6
- title: string;
7
- description: string;
8
- passed: boolean;
9
- evidence?: string;
10
- fix_hint?: string;
11
- }
12
- export interface UtilCallCheckInput {
13
- uses_typo_function_name?: boolean;
14
- assumes_stable_address_bytes?: boolean;
15
- bcs_manually_synced?: boolean;
16
- }
17
- export declare function preCheckUtilCall(input: UtilCallCheckInput): UtilConfirmItem[];
18
- export declare function canProceedUtilCall(input: UtilCallCheckInput): {
19
- canProceed: boolean;
20
- blockers: UtilConfirmItem[];
21
- warnings: UtilConfirmItem[];
22
- info: UtilConfirmItem[];
23
- };
24
- export declare function formatUtilCallSummary(input: UtilCallCheckInput): string;
@@ -1 +0,0 @@
1
- export const UTIL_CONFIRM_VERSION='1.0.0';function checkTypo(a){const b=!!a['uses_typo_function_name'];return{'id':'C-UTIL-01','severity':b?'info':'info','title':'Typo\x27d\x20function\x20name\x20is\x20handled\x20(is_chiild_object_address_byte)','description':'util.move\x20defines\x20is_chiild_object_address_byte\x20with\x20a\x20\x27chiild\x27\x20typo;\x20it\x20cannot\x20be\x20renamed\x20post-publish.\x20The\x20SDK\x20should\x20expose\x20a\x20correct\x20alias.','passed':!![],'evidence':b?'uses_typo_function_name=true\x20(must\x20use\x20\x27chiild\x27)':'typo\x20handled\x20via\x20alias'};}function checkAddressBytes(a){const b=!!a['assumes_stable_address_bytes'];return{'id':'C-UTIL-02','severity':b?'warn':'info','title':'Address-byte\x20thresholds\x20are\x20hardcoded','description':'util.move\x20classifies\x20addresses\x20by\x20first\x20byte\x20(user\x200x00,\x20object\x200xf1\x20or\x200x10..0x24,\x20child\x20unified\x20with\x20object).\x20A\x20Wow\x20protocol\x20upgrade\x20could\x20invalidate\x20them.','passed':!b,'evidence':b?'assumes_stable_address_bytes=true':'upgrade\x20coupling\x20understood','fix_hint':'Track\x20Wow\x20address-layout\x20upgrades;\x20ship\x20util.move\x20+\x20SDK\x20in\x20lockstep.'};}function checkBcs(a){const b=a['bcs_manually_synced']===!![];return{'id':'C-UTIL-03','severity':b?'warn':'info','title':'SDK\x20BCS\x20structures\x20stay\x20in\x20sync\x20with\x20Move\x20structs','description':'util.ts\x20defines\x20BCS\x20query\x20structures\x20that\x20must\x20match\x20Move\x20layouts\x20byte-for-byte;\x20drift\x20breaks\x20queries\x20silently.','passed':!b,'evidence':b?'bcs_manually_synced=true\x20(drift\x20risk)':'BCS\x20sync\x20safe','fix_hint':'Generate\x20BCS\x20from\x20Move\x20via\x20codegen,\x20or\x20run\x20a\x20layout\x20sync\x20test.'};}export function preCheckUtilCall(a){return[checkTypo(a),checkAddressBytes(a),checkBcs(a)];}export function canProceedUtilCall(a){const b=preCheckUtilCall(a);return{'canProceed':b['every'](c=>c['severity']!=='block'||c['passed']),'blockers':b['filter'](c=>c['severity']==='block'&&!c['passed']),'warnings':b['filter'](c=>c['severity']==='warn'&&!c['passed']),'info':b['filter'](c=>c['severity']==='info')};}export function formatUtilCallSummary(a){const {canProceed:b,warnings:c}=canProceedUtilCall(a),d=[b?'✓\x20Util\x20call\x20pre-check\x20PASSED':'✗\x20Util\x20call\x20pre-check\x20FAILED',''];return c['length']>0x0&&(d['push']('WARNINGS:'),c['forEach'](e=>d['push']('\x20\x20['+e['id']+']\x20'+e['title']+'\x20—\x20'+(e['evidence']??'')))),d['join']('\x0a');}
@@ -1,39 +0,0 @@
1
- export declare const UTIL_TRANSLATION_VERSION = "1.0.0";
2
- export declare const UTIL_ADDRESS_BYTES: {
3
- readonly USER: 0;
4
- readonly OBJECT: 241;
5
- readonly TYPED_OBJECT_MIN: 16;
6
- readonly TYPED_OBJECT_MAX: 36;
7
- };
8
- export interface SemanticToUtilSchemaRule {
9
- id: string;
10
- pattern_name: string;
11
- semantic_intent: string;
12
- match_keywords: string[];
13
- example: Record<string, unknown>;
14
- }
15
- export declare const SEMANTIC_TO_UTIL_SCHEMA_RULES: SemanticToUtilSchemaRule[];
16
- export interface UtilFieldTranslation {
17
- field_name: string;
18
- value_type: string;
19
- semantic: string;
20
- format_example: string;
21
- validation_rules: string[];
22
- }
23
- export declare const UTIL_FIELD_TRANSLATIONS: UtilFieldTranslation[];
24
- export interface UtilConstraintRule {
25
- id: string;
26
- name: string;
27
- description: string;
28
- related_field: string;
29
- }
30
- export declare const UTIL_CONSTRAINT_RULES: UtilConstraintRule[];
31
- export interface UtilExplainInput {
32
- first_byte?: number;
33
- }
34
- export interface UtilExplanation {
35
- summary: string;
36
- classification: string;
37
- warnings: string[];
38
- }
39
- export declare function explainUtil(input: UtilExplainInput): UtilExplanation;
@@ -1 +0,0 @@
1
- export const UTIL_TRANSLATION_VERSION='1.0.0';export const UTIL_ADDRESS_BYTES={'USER':0x0,'OBJECT':0xf1,'TYPED_OBJECT_MIN':0x10,'TYPED_OBJECT_MAX':0x24};export const SEMANTIC_TO_UTIL_SCHEMA_RULES=[{'id':'P-UTIL-01','pattern_name':'Classify\x20address','semantic_intent':'Determine\x20whether\x20an\x20address\x20is\x20a\x20user,\x20object,\x20or\x20child-object.','match_keywords':['is\x20user\x20address','is\x20object\x20address','classify\x20address'],'example':{'addr':'0x...'}}];export const UTIL_FIELD_TRANSLATIONS=[{'field_name':'first_byte','value_type':'u8','semantic':'Address\x20classification\x20byte:\x20user\x200x00,\x20object\x200xf1\x20(regular/child)\x20or\x200x10..0x24\x20(typed\x20business).','format_example':'0xf1\x20(object)','validation_rules':['hardcoded\x20in\x20util.move']}];export const UTIL_CONSTRAINT_RULES=[{'id':'UTIL_C_01','name':'typo\x20function','description':'is_chiild_object_address_byte\x20has\x20a\x20\x27chiild\x27\x20typo;\x20cannot\x20rename\x20post-publish.','related_field':'first_byte'},{'id':'UTIL_C_02','name':'address-byte\x20stability','description':'byte\x20thresholds\x20are\x20hardcoded;\x20Wow\x20upgrade\x20could\x20invalidate\x20them.','related_field':'first_byte'},{'id':'UTIL_C_03','name':'BCS\x20sync','description':'SDK\x20BCS\x20structures\x20must\x20match\x20Move\x20layouts\x20byte-for-byte.','related_field':'first_byte'}];export function explainUtil(a){const b=[];let c='unknown';if(a['first_byte']!==undefined){if(a['first_byte']===UTIL_ADDRESS_BYTES['USER'])c='user\x20address';else{if(a['first_byte']===UTIL_ADDRESS_BYTES['OBJECT'])c='object\x20address\x20(regular/child)';else{if(a['first_byte']>=UTIL_ADDRESS_BYTES['TYPED_OBJECT_MIN']&&a['first_byte']<=UTIL_ADDRESS_BYTES['TYPED_OBJECT_MAX'])c='typed\x20business\x20object\x20address';else b['push']('first\x20byte\x200x'+a['first_byte']['toString'](0x10)+'\x20not\x20in\x20known\x20classification\x20range');}}}return{'summary':'Util\x20address\x20classification:\x20'+c+'.','classification':c,'warnings':b};}
@@ -1,50 +0,0 @@
1
- import type { TelemetryEvent } from "../telemetry/index.js";
2
- export interface ToolStats {
3
- tool_name: string;
4
- total_calls: number;
5
- success_count: number;
6
- failed_count: number;
7
- pending_input_count: number;
8
- success_rate: number;
9
- avg_duration_ms: number;
10
- p50_duration_ms: number;
11
- p95_duration_ms: number;
12
- semantic_hit_rate: number;
13
- error_distribution: Record<string, number>;
14
- top_error_messages: Array<{
15
- message: string;
16
- count: number;
17
- }>;
18
- }
19
- export interface OperationStats {
20
- operation_type: string;
21
- total_calls: number;
22
- success_rate: number;
23
- semantic_hit_rate: number;
24
- error_distribution: Record<string, number>;
25
- }
26
- export interface AggregatedStats {
27
- aggregation_date: string;
28
- total_events: number;
29
- date_range: {
30
- earliest: string;
31
- latest: string;
32
- };
33
- per_tool: ToolStats[];
34
- per_operation: OperationStats[];
35
- overall: {
36
- total_calls: number;
37
- success_count: number;
38
- failed_count: number;
39
- success_rate: number;
40
- semantic_hit_rate: number;
41
- unknown_error_count: number;
42
- unknown_error_rate: number;
43
- avg_duration_ms: number;
44
- };
45
- error_code_distribution: Record<string, number>;
46
- intent_distribution: Record<string, number>;
47
- }
48
- export declare function aggregateByTool(events: TelemetryEvent[]): ToolStats[];
49
- export declare function aggregateByOperation(events: TelemetryEvent[]): OperationStats[];
50
- export declare function aggregate(events: TelemetryEvent[]): AggregatedStats;
@@ -1 +0,0 @@
1
- function percentile(a,b){if(a['length']===0x0)return 0x0;const c=Math['ceil'](b/0x64*a['length'])-0x1;return a[Math['max'](0x0,c)];}function topMessages(a,b=0x5){const c=new Map();for(const d of a){if(!d)continue;c['set'](d,(c['get'](d)||0x0)+0x1);}return Array['from'](c['entries']())['map'](([e,f])=>({'message':e,'count':f}))['sort']((e,f)=>f['count']-e['count'])['slice'](0x0,b);}export function aggregateByTool(a){const b=new Map();for(const d of a){const f=d['tool_name']||'unknown';if(!b['has'](f))b['set'](f,[]);b['get'](f)['push'](d);}const c=[];for(const [g,h]of b){const i=h['length'],j=h['filter'](q=>q['status']==='success')['length'],k=h['filter'](q=>q['status']==='failed')['length'],l=h['filter'](q=>q['status']==='pending_input')['length'],m=h['filter'](q=>q['semantic_hit'])['length'],n=h['map'](q=>q['duration_ms'])['sort']((q,r)=>q-r),o={},p=[];for(const q of h){q['error_code']&&(o[q['error_code']]=(o[q['error_code']]||0x0)+0x1);if(q['error_message'])p['push'](q['error_message']);}c['push']({'tool_name':g,'total_calls':i,'success_count':j,'failed_count':k,'pending_input_count':l,'success_rate':i>0x0?j/ i:0x0,'avg_duration_ms':n['length']>0x0?n['reduce']((r,s)=>r+s,0x0)/n['length']:0x0,'p50_duration_ms':percentile(n,0x32),'p95_duration_ms':percentile(n,0x5f),'semantic_hit_rate':i>0x0?m/ i:0x0,'error_distribution':o,'top_error_messages':topMessages(p)});}return c['sort']((r,s)=>s['total_calls']-r['total_calls']);}export function aggregateByOperation(a){const b=new Map();for(const d of a){const f=d['operation_type']||'unknown';if(!b['has'](f))b['set'](f,[]);b['get'](f)['push'](d);}const c=[];for(const [g,h]of b){const i=h['length'],j=h['filter'](m=>m['status']==='success')['length'],k=h['filter'](m=>m['semantic_hit'])['length'],l={};for(const m of h){m['error_code']&&(l[m['error_code']]=(l[m['error_code']]||0x0)+0x1);}c['push']({'operation_type':g,'total_calls':i,'success_rate':i>0x0?j/ i:0x0,'semantic_hit_rate':i>0x0?k/ i:0x0,'error_distribution':l});}return c['sort']((n,o)=>o['total_calls']-n['total_calls']);}export function aggregate(a){const b=a['length'],c=a['filter'](k=>k['status']==='success')['length'],d=a['filter'](k=>k['semantic_hit'])['length'],f=a['filter'](k=>k['error_code']==='unknown')['length'],g=a['map'](k=>k['duration_ms']),h={},i={};for(const k of a){k['error_code']&&(h[k['error_code']]=(h[k['error_code']]||0x0)+0x1),k['intent']&&(i[k['intent']]=(i[k['intent']]||0x0)+0x1);}const j=a['map'](l=>l['timestamp'])['filter'](Boolean)['sort']();return{'aggregation_date':new Date()['toISOString'](),'total_events':b,'date_range':{'earliest':j[0x0]||'','latest':j[j['length']-0x1]||''},'per_tool':aggregateByTool(a),'per_operation':aggregateByOperation(a),'overall':{'total_calls':b,'success_count':c,'failed_count':a['filter'](l=>l['status']==='failed')['length'],'success_rate':b>0x0?c/b:0x0,'semantic_hit_rate':b>0x0?d/b:0x0,'unknown_error_count':f,'unknown_error_rate':b>0x0?f/b:0x0,'avg_duration_ms':g['length']>0x0?g['reduce']((l,m)=>l+m,0x0)/g['length']:0x0},'error_code_distribution':h,'intent_distribution':i};}
@@ -1,7 +0,0 @@
1
- import type { AssembleContextResult } from "../playbooks/service-build/context-assembly.js";
2
- export interface ContextCollectionResult {
3
- signature_recorded: boolean;
4
- proposal_created: boolean;
5
- proposal_id?: string;
6
- }
7
- export declare function collectContextExperience(result: AssembleContextResult, network: string): ContextCollectionResult;
@@ -1 +0,0 @@
1
- import{recordSignature}from'../experience/index.js';import{persistImprovementQueue}from'./improve.js';export function collectContextExperience(a,b){const c=extractObjectTypes(a['objects']),d=!!a['embedded_history'],e=!!a['events']&&a['events']['length']>0x0,f={'intent':'assemble_context','signals':{'object_types':c,'object_count':a['objects']['length'],'has_embedded_history':d,'has_events':e,'context_digest':a['context_digest'],'network':b},'timestamp':Date['now'](),'outcome':'success'};let g=![];try{recordSignature(f),g=!![];}catch{}let h;if(c['length']>=0x3){h={'proposal_id':'PROP-CTX-'+Date['now']()+'-'+Math['random']()['toString'](0x24)['slice'](0x2,0x6),'source_diagnosis_id':'CTX-'+a['context_digest'],'type':'description_rewrite','priority':'P3','automation':'semi','apply_mode':'config_override','override_category':'descriptions','title':'Enrich\x20assemble_context\x20for\x20'+c['join']('+')+'\x20patterns','description':'Assembled\x20context\x20with\x20'+c['length']+'\x20object\x20types\x20('+c['join'](',\x20')+').\x20'+'Consider\x20enriching\x20the\x20assemble_context\x20action\x20description\x20to\x20guide\x20AI\x20toward\x20'+('common\x20'+c['join']('+')+'\x20business\x20patterns.'),'target':'assemble_context','proposed_change':{'action':'enrich_description','object_types':c,'has_embedded_history':d,'has_events':e,'context_digest':a['context_digest']},'evidence':{'context_digest':a['context_digest'],'object_count':a['objects']['length'],'object_types':c,'network':b},'review_status':'pending','ab_test_recommended':![]};try{persistImprovementQueue([h]);}catch{}}return{'signature_recorded':g,'proposal_created':!!h,'proposal_id':h?.['proposal_id']};}function extractObjectTypes(a){const b=new Set();for(const c of a){const d=c?.['data']??c,e=d?.['type'];if(typeof e==='string'){const f=e['match'](/::(\w+)$/);f&&b['add'](f[0x1]);}}return Array['from'](b);}