@wowok/agent-mcp 2.4.3 → 2.5.0

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 (317) hide show
  1. package/dist/config/runtime.d.ts +4 -0
  2. package/dist/config/runtime.js +29 -5
  3. package/dist/harness/auto-escalation.d.ts +27 -0
  4. package/dist/harness/auto-escalation.js +68 -0
  5. package/dist/index.js +21 -0
  6. package/dist/knowledge/allocation-confirm.d.ts +115 -0
  7. package/dist/knowledge/allocation-confirm.js +534 -0
  8. package/dist/knowledge/allocation-context.d.ts +58 -0
  9. package/dist/knowledge/allocation-context.js +249 -0
  10. package/dist/knowledge/allocation-ledger.d.ts +67 -0
  11. package/dist/knowledge/allocation-ledger.js +463 -0
  12. package/dist/knowledge/allocation-puzzle.d.ts +135 -0
  13. package/dist/knowledge/allocation-puzzle.js +298 -0
  14. package/dist/knowledge/allocation-risk.d.ts +78 -0
  15. package/dist/knowledge/allocation-risk.js +568 -0
  16. package/dist/knowledge/allocation-templates.d.ts +38 -0
  17. package/dist/knowledge/allocation-templates.js +970 -0
  18. package/dist/knowledge/allocation-translation.d.ts +72 -0
  19. package/dist/knowledge/allocation-translation.js +585 -0
  20. package/dist/knowledge/arb-risk.d.ts +37 -0
  21. package/dist/knowledge/arb-risk.js +210 -0
  22. package/dist/knowledge/arbitration-confirm.d.ts +135 -0
  23. package/dist/knowledge/arbitration-confirm.js +559 -0
  24. package/dist/knowledge/arbitration-context.d.ts +81 -0
  25. package/dist/knowledge/arbitration-context.js +505 -0
  26. package/dist/knowledge/arbitration-ledger.d.ts +62 -0
  27. package/dist/knowledge/arbitration-ledger.js +521 -0
  28. package/dist/knowledge/arbitration-puzzle.d.ts +84 -0
  29. package/dist/knowledge/arbitration-puzzle.js +304 -0
  30. package/dist/knowledge/arbitration-risk.d.ts +112 -0
  31. package/dist/knowledge/arbitration-risk.js +433 -0
  32. package/dist/knowledge/arbitration-templates.d.ts +38 -0
  33. package/dist/knowledge/arbitration-templates.js +276 -0
  34. package/dist/knowledge/arbitration-translation.d.ts +91 -0
  35. package/dist/knowledge/arbitration-translation.js +487 -0
  36. package/dist/knowledge/bridge-risk.d.ts +36 -0
  37. package/dist/knowledge/bridge-risk.js +263 -0
  38. package/dist/knowledge/contact-risk.d.ts +32 -0
  39. package/dist/knowledge/contact-risk.js +200 -0
  40. package/dist/knowledge/demand-confirm.d.ts +32 -0
  41. package/dist/knowledge/demand-confirm.js +206 -0
  42. package/dist/knowledge/demand-risk.d.ts +30 -0
  43. package/dist/knowledge/demand-risk.js +240 -0
  44. package/dist/knowledge/demand-translation.d.ts +55 -0
  45. package/dist/knowledge/demand-translation.js +354 -0
  46. package/dist/knowledge/deployment-scanner.d.ts +63 -0
  47. package/dist/knowledge/deployment-scanner.js +762 -0
  48. package/dist/knowledge/examples-scanner-cli.d.ts +1 -0
  49. package/dist/knowledge/examples-scanner-cli.js +26 -0
  50. package/dist/knowledge/examples-scanner.d.ts +121 -0
  51. package/dist/knowledge/examples-scanner.js +825 -0
  52. package/dist/knowledge/flywheel-loop.d.ts +3 -0
  53. package/dist/knowledge/flywheel-loop.js +32 -3
  54. package/dist/knowledge/glossary.js +3 -1
  55. package/dist/knowledge/guard-confirm.d.ts +86 -0
  56. package/dist/knowledge/guard-confirm.js +406 -0
  57. package/dist/knowledge/guard-context.d.ts +56 -0
  58. package/dist/knowledge/guard-context.js +287 -0
  59. package/dist/knowledge/guard-design-patterns.d.ts +37 -0
  60. package/dist/knowledge/guard-design-patterns.js +257 -0
  61. package/dist/knowledge/guard-puzzle.js +3 -2
  62. package/dist/knowledge/guard-risk.d.ts +1 -1
  63. package/dist/knowledge/guard-risk.js +12 -14
  64. package/dist/knowledge/guard-templates.js +1 -1
  65. package/dist/knowledge/guard-translation.js +6 -5
  66. package/dist/knowledge/index.d.ts +342 -0
  67. package/dist/knowledge/index.js +344 -0
  68. package/dist/knowledge/machine-confirm.d.ts +102 -0
  69. package/dist/knowledge/machine-confirm.js +559 -0
  70. package/dist/knowledge/machine-context.d.ts +160 -0
  71. package/dist/knowledge/machine-context.js +812 -0
  72. package/dist/knowledge/machine-ledger.d.ts +41 -0
  73. package/dist/knowledge/machine-ledger.js +315 -0
  74. package/dist/knowledge/machine-puzzle.d.ts +206 -0
  75. package/dist/knowledge/machine-puzzle.js +494 -0
  76. package/dist/knowledge/machine-risk.d.ts +75 -0
  77. package/dist/knowledge/machine-risk.js +644 -0
  78. package/dist/knowledge/machine-templates.d.ts +92 -0
  79. package/dist/knowledge/machine-templates.js +1592 -0
  80. package/dist/knowledge/machine-topology.d.ts +57 -0
  81. package/dist/knowledge/machine-topology.js +234 -0
  82. package/dist/knowledge/machine-translation.d.ts +96 -0
  83. package/dist/knowledge/machine-translation.js +513 -0
  84. package/dist/knowledge/mcp-schema-audit-cli.d.ts +1 -0
  85. package/dist/knowledge/mcp-schema-audit-cli.js +45 -0
  86. package/dist/knowledge/mcp-schema-audit.d.ts +90 -0
  87. package/dist/knowledge/mcp-schema-audit.js +772 -0
  88. package/dist/knowledge/onchain-constants.d.ts +4 -0
  89. package/dist/knowledge/onchain-constants.js +35 -0
  90. package/dist/knowledge/order-confirm.d.ts +115 -0
  91. package/dist/knowledge/order-confirm.js +573 -0
  92. package/dist/knowledge/order-context.d.ts +66 -0
  93. package/dist/knowledge/order-context.js +390 -0
  94. package/dist/knowledge/order-ledger.d.ts +69 -0
  95. package/dist/knowledge/order-ledger.js +341 -0
  96. package/dist/knowledge/order-puzzle.d.ts +159 -0
  97. package/dist/knowledge/order-puzzle.js +255 -0
  98. package/dist/knowledge/order-risk.d.ts +66 -0
  99. package/dist/knowledge/order-risk.js +653 -0
  100. package/dist/knowledge/order-templates.d.ts +50 -0
  101. package/dist/knowledge/order-templates.js +368 -0
  102. package/dist/knowledge/order-translation.d.ts +78 -0
  103. package/dist/knowledge/order-translation.js +550 -0
  104. package/dist/knowledge/passport-confirm.d.ts +130 -0
  105. package/dist/knowledge/passport-confirm.js +531 -0
  106. package/dist/knowledge/passport-context.d.ts +59 -0
  107. package/dist/knowledge/passport-context.js +306 -0
  108. package/dist/knowledge/passport-ledger.d.ts +48 -0
  109. package/dist/knowledge/passport-ledger.js +282 -0
  110. package/dist/knowledge/passport-puzzle.d.ts +108 -0
  111. package/dist/knowledge/passport-puzzle.js +333 -0
  112. package/dist/knowledge/passport-risk.d.ts +70 -0
  113. package/dist/knowledge/passport-risk.js +450 -0
  114. package/dist/knowledge/passport-templates.d.ts +40 -0
  115. package/dist/knowledge/passport-templates.js +568 -0
  116. package/dist/knowledge/passport-translation.d.ts +68 -0
  117. package/dist/knowledge/passport-translation.js +516 -0
  118. package/dist/knowledge/payment-risk.d.ts +33 -0
  119. package/dist/knowledge/payment-risk.js +182 -0
  120. package/dist/knowledge/permission-confirm.d.ts +110 -0
  121. package/dist/knowledge/permission-confirm.js +426 -0
  122. package/dist/knowledge/permission-context.d.ts +58 -0
  123. package/dist/knowledge/permission-context.js +224 -0
  124. package/dist/knowledge/permission-ledger.d.ts +38 -0
  125. package/dist/knowledge/permission-ledger.js +403 -0
  126. package/dist/knowledge/permission-puzzle.d.ts +122 -0
  127. package/dist/knowledge/permission-puzzle.js +173 -0
  128. package/dist/knowledge/permission-risk.d.ts +76 -0
  129. package/dist/knowledge/permission-risk.js +411 -0
  130. package/dist/knowledge/permission-templates.d.ts +38 -0
  131. package/dist/knowledge/permission-templates.js +234 -0
  132. package/dist/knowledge/permission-translation.d.ts +57 -0
  133. package/dist/knowledge/permission-translation.js +350 -0
  134. package/dist/knowledge/personal-risk.d.ts +36 -0
  135. package/dist/knowledge/personal-risk.js +212 -0
  136. package/dist/knowledge/progress-confirm.d.ts +108 -0
  137. package/dist/knowledge/progress-confirm.js +456 -0
  138. package/dist/knowledge/progress-context.d.ts +123 -0
  139. package/dist/knowledge/progress-context.js +452 -0
  140. package/dist/knowledge/progress-ledger.d.ts +63 -0
  141. package/dist/knowledge/progress-ledger.js +327 -0
  142. package/dist/knowledge/progress-puzzle.d.ts +82 -0
  143. package/dist/knowledge/progress-puzzle.js +219 -0
  144. package/dist/knowledge/progress-risk.d.ts +74 -0
  145. package/dist/knowledge/progress-risk.js +461 -0
  146. package/dist/knowledge/progress-templates.d.ts +38 -0
  147. package/dist/knowledge/progress-templates.js +228 -0
  148. package/dist/knowledge/progress-translation.d.ts +52 -0
  149. package/dist/knowledge/progress-translation.js +401 -0
  150. package/dist/knowledge/proof-confirm.d.ts +31 -0
  151. package/dist/knowledge/proof-confirm.js +187 -0
  152. package/dist/knowledge/proof-risk.d.ts +33 -0
  153. package/dist/knowledge/proof-risk.js +207 -0
  154. package/dist/knowledge/proof-translation.d.ts +52 -0
  155. package/dist/knowledge/proof-translation.js +283 -0
  156. package/dist/knowledge/registrar-risk.d.ts +34 -0
  157. package/dist/knowledge/registrar-risk.js +217 -0
  158. package/dist/knowledge/repository-confirm.d.ts +36 -0
  159. package/dist/knowledge/repository-confirm.js +242 -0
  160. package/dist/knowledge/repository-risk.d.ts +40 -0
  161. package/dist/knowledge/repository-risk.js +312 -0
  162. package/dist/knowledge/repository-translation.d.ts +58 -0
  163. package/dist/knowledge/repository-translation.js +422 -0
  164. package/dist/knowledge/resource-risk.d.ts +32 -0
  165. package/dist/knowledge/resource-risk.js +157 -0
  166. package/dist/knowledge/reward-confirm.d.ts +113 -0
  167. package/dist/knowledge/reward-confirm.js +496 -0
  168. package/dist/knowledge/reward-context.d.ts +127 -0
  169. package/dist/knowledge/reward-context.js +504 -0
  170. package/dist/knowledge/reward-ledger.d.ts +96 -0
  171. package/dist/knowledge/reward-ledger.js +502 -0
  172. package/dist/knowledge/reward-puzzle.d.ts +97 -0
  173. package/dist/knowledge/reward-puzzle.js +288 -0
  174. package/dist/knowledge/reward-risk.d.ts +84 -0
  175. package/dist/knowledge/reward-risk.js +545 -0
  176. package/dist/knowledge/reward-translation.d.ts +58 -0
  177. package/dist/knowledge/reward-translation.js +501 -0
  178. package/dist/knowledge/safety-rules.js +11 -3
  179. package/dist/knowledge/scenario-modes.d.ts +53 -0
  180. package/dist/knowledge/scenario-modes.js +302 -0
  181. package/dist/knowledge/service-confirm.d.ts +152 -0
  182. package/dist/knowledge/service-confirm.js +699 -0
  183. package/dist/knowledge/service-context.d.ts +66 -0
  184. package/dist/knowledge/service-context.js +403 -0
  185. package/dist/knowledge/service-ledger.d.ts +71 -0
  186. package/dist/knowledge/service-ledger.js +609 -0
  187. package/dist/knowledge/service-puzzle.d.ts +158 -0
  188. package/dist/knowledge/service-puzzle.js +236 -0
  189. package/dist/knowledge/service-risk.d.ts +108 -0
  190. package/dist/knowledge/service-risk.js +615 -0
  191. package/dist/knowledge/service-templates.d.ts +39 -0
  192. package/dist/knowledge/service-templates.js +418 -0
  193. package/dist/knowledge/service-translation.d.ts +103 -0
  194. package/dist/knowledge/service-translation.js +622 -0
  195. package/dist/knowledge/tools-reference.d.ts +17 -0
  196. package/dist/knowledge/tools-reference.js +151 -0
  197. package/dist/knowledge/treasury-confirm.d.ts +133 -0
  198. package/dist/knowledge/treasury-confirm.js +512 -0
  199. package/dist/knowledge/treasury-context.d.ts +64 -0
  200. package/dist/knowledge/treasury-context.js +363 -0
  201. package/dist/knowledge/treasury-ledger.d.ts +42 -0
  202. package/dist/knowledge/treasury-ledger.js +300 -0
  203. package/dist/knowledge/treasury-puzzle.d.ts +163 -0
  204. package/dist/knowledge/treasury-puzzle.js +216 -0
  205. package/dist/knowledge/treasury-risk.d.ts +86 -0
  206. package/dist/knowledge/treasury-risk.js +440 -0
  207. package/dist/knowledge/treasury-templates.d.ts +38 -0
  208. package/dist/knowledge/treasury-templates.js +316 -0
  209. package/dist/knowledge/treasury-translation.d.ts +78 -0
  210. package/dist/knowledge/treasury-translation.js +498 -0
  211. package/dist/knowledge/util-risk.d.ts +30 -0
  212. package/dist/knowledge/util-risk.js +135 -0
  213. package/dist/project/business-puzzle.d.ts +47 -0
  214. package/dist/project/business-puzzle.js +372 -0
  215. package/dist/project/deployment-doc.d.ts +61 -0
  216. package/dist/project/deployment-doc.js +432 -0
  217. package/dist/project/risk-aggregator.d.ts +50 -0
  218. package/dist/project/risk-aggregator.js +280 -0
  219. package/dist/project/substep-trace.d.ts +130 -0
  220. package/dist/project/substep-trace.js +332 -0
  221. package/dist/schema/call/allocation.d.ts +34 -34
  222. package/dist/schema/call/arbitration.d.ts +141 -141
  223. package/dist/schema/call/base.d.ts +386 -386
  224. package/dist/schema/call/base.js +3 -3
  225. package/dist/schema/call/bridge-handler.d.ts +5 -2
  226. package/dist/schema/call/bridge.d.ts +159 -159
  227. package/dist/schema/call/contact.d.ts +110 -110
  228. package/dist/schema/call/demand.d.ts +76 -76
  229. package/dist/schema/call/handler.d.ts +2 -3
  230. package/dist/schema/call/handler.js +1 -1
  231. package/dist/schema/call/machine.d.ts +58 -58
  232. package/dist/schema/call/order.d.ts +98 -110
  233. package/dist/schema/call/permission-handler.d.ts +5 -0
  234. package/dist/schema/call/permission-handler.js +54 -0
  235. package/dist/schema/call/permission.d.ts +108 -108
  236. package/dist/schema/call/personal.d.ts +14 -14
  237. package/dist/schema/call/progress.d.ts +57 -72
  238. package/dist/schema/call/progress.js +7 -4
  239. package/dist/schema/call/proof.d.ts +18 -18
  240. package/dist/schema/call/proof.js +12 -7
  241. package/dist/schema/call/repository.d.ts +154 -154
  242. package/dist/schema/call/reward.d.ts +55 -55
  243. package/dist/schema/call/service.d.ts +231 -231
  244. package/dist/schema/call/treasury.d.ts +93 -93
  245. package/dist/schema/config/index.d.ts +178 -5
  246. package/dist/schema/config/index.js +52 -1
  247. package/dist/schema/local/index.d.ts +3554 -836
  248. package/dist/schema/local/index.js +2 -1
  249. package/dist/schema/messenger/index.d.ts +162 -162
  250. package/dist/schema/operations.d.ts +1058 -1074
  251. package/dist/schema/operations.js +7 -1
  252. package/dist/schema/project/index.d.ts +1392 -6
  253. package/dist/schema/project/index.js +426 -2
  254. package/dist/schema/query/index.d.ts +672 -672
  255. package/dist/schema/schema-query/index.d.ts +23 -3
  256. package/dist/schema/schema-query/index.js +13 -2
  257. package/dist/schema/sync-layer4.d.ts +21 -0
  258. package/dist/schema/sync-layer4.js +261 -0
  259. package/dist/schema/trust/index.d.ts +26 -26
  260. package/dist/schemas/account_operation.output.json +718 -0
  261. package/dist/schemas/config_operation.output.json +173 -0
  262. package/dist/schemas/index.json +9 -1
  263. package/dist/schemas/local_info_operation.output.json +718 -0
  264. package/dist/schemas/local_mark_operation.output.json +718 -0
  265. package/dist/schemas/onchain_operations.output.json +3 -2
  266. package/dist/schemas/onchain_operations.schema.json +1802 -313
  267. package/dist/schemas/onchain_operations_allocation.schema.json +2 -1
  268. package/dist/schemas/onchain_operations_arbitration.schema.json +2 -1
  269. package/dist/schemas/onchain_operations_contact.schema.json +2 -1
  270. package/dist/schemas/onchain_operations_demand.schema.json +2 -1
  271. package/dist/schemas/onchain_operations_gen_passport.schema.json +878 -872
  272. package/dist/schemas/onchain_operations_gen_proof.schema.json +273 -0
  273. package/dist/schemas/onchain_operations_guard.schema.json +584 -70
  274. package/dist/schemas/onchain_operations_machine.schema.json +2 -1
  275. package/dist/schemas/onchain_operations_order.schema.json +13 -9
  276. package/dist/schemas/onchain_operations_payment.schema.json +2 -1
  277. package/dist/schemas/onchain_operations_permission.schema.json +2 -1
  278. package/dist/schemas/onchain_operations_personal.schema.json +2 -1
  279. package/dist/schemas/onchain_operations_progress.schema.json +14 -10
  280. package/dist/schemas/onchain_operations_proof.schema.json +699 -0
  281. package/dist/schemas/onchain_operations_repository.schema.json +2 -1
  282. package/dist/schemas/onchain_operations_reward.schema.json +2 -1
  283. package/dist/schemas/onchain_operations_service.schema.json +2 -1
  284. package/dist/schemas/onchain_operations_treasury.schema.json +2 -1
  285. package/dist/schemas/onchain_table_data.schema.json +32 -1
  286. package/dist/schemas/project_operation.output.json +879 -0
  287. package/dist/schemas/project_operation.schema.json +473 -2
  288. package/dist/schemas/query_toolkit.output.json +14906 -6
  289. package/dist/schemas/schema_query.output.json +38 -1
  290. package/dist/telemetry/index.d.ts +1 -1
  291. package/dist/tools/handlers/config.d.ts +1 -1
  292. package/dist/tools/handlers/config.js +21 -18
  293. package/dist/tools/handlers/file-export.d.ts +2 -2
  294. package/dist/tools/handlers/local.d.ts +3 -30
  295. package/dist/tools/handlers/local.js +14 -3
  296. package/dist/tools/handlers/messenger.d.ts +1 -1
  297. package/dist/tools/handlers/messenger.js +2 -1
  298. package/dist/tools/handlers/onchain.d.ts +1 -1
  299. package/dist/tools/handlers/onchain.js +24 -22
  300. package/dist/tools/handlers/project.d.ts +1 -1
  301. package/dist/tools/handlers/project.js +258 -18
  302. package/dist/tools/handlers/query.d.ts +4 -4
  303. package/dist/tools/handlers/schema-query.d.ts +1 -1
  304. package/dist/tools/handlers/schema-query.js +21 -20
  305. package/dist/tools/handlers/trust.d.ts +1 -1
  306. package/dist/tools/handlers/trust.js +2 -2
  307. package/dist/tools/handlers/wip.d.ts +1 -1
  308. package/dist/tools/handlers/wip.js +1 -1
  309. package/dist/tools/index.d.ts +1 -1
  310. package/dist/tools/index.js +55 -8
  311. package/dist/tools/rules-hook.d.ts +1 -1
  312. package/dist/tools/rules-hook.js +3 -2
  313. package/dist/tools/shared.d.ts +13 -22
  314. package/dist/tools/types.d.ts +5 -5
  315. package/dist/tools/wrap.d.ts +10 -2
  316. package/dist/tools/wrap.js +212 -0
  317. package/package.json +3 -3
@@ -0,0 +1,456 @@
1
+ import { MAX_NAMED_OPERATOR_COUNT, MAX_NAMED_OPERATOR_ADDRESS_COUNT, MAX_CONTEXT_REPOSITORY_COUNT, } from "@wowok/wowok";
2
+ import { assessProgressRisks, } from "./progress-risk.js";
3
+ export const PROGRESS_OPERATION_CHECKLIST = [
4
+ { id: "C-PR-01", description: "Machine is published (machine::on_progress_new asserts published)", passed: false, message: "" },
5
+ { id: "C-PR-02", description: "progress.machine matches the bound Machine (E_MACHINE_NOT_MATCH)", passed: false, message: "" },
6
+ { id: "C-PR-03", description: "named_operator count < MAX_NAMED_OPERATOR_COUNT (60)", passed: false, message: "" },
7
+ { id: "C-PR-04", description: "named_operator addresses ≤ MAX_NAMED_OPERATOR_ADDRESS_COUNT (80)", passed: false, message: "" },
8
+ { id: "C-PR-05", description: "context_repository count ≤ MAX_CONTEXT_REPOSITORY_COUNT (30)", passed: false, message: "" },
9
+ { id: "C-PR-06", description: "task_set is one-time (E_TASK_ALREADY_SET if already bound)", passed: false, message: "" },
10
+ { id: "C-PR-07", description: "operate.op is one of: next | hold | unhold | adminUnhold", passed: false, message: "" },
11
+ { id: "C-PR-08", description: "operate.message ≤ MAX_LONG_NAME_LENGTH (1024 chars)", passed: false, message: "" },
12
+ { id: "C-PR-09", description: "Forward exists in Machine (current → next_node_name, forward)", passed: false, message: "" },
13
+ { id: "C-PR-10", description: "adminUnhold (224 permission) double-confirmed by user", passed: false, message: "" },
14
+ ];
15
+ function runStaticChecklist(input) {
16
+ const items = PROGRESS_OPERATION_CHECKLIST.map(c => ({ ...c }));
17
+ const data = input.progress_json;
18
+ const cp01 = items.find(i => i.id === "C-PR-01");
19
+ if (input.machine_published === false) {
20
+ cp01.passed = false;
21
+ cp01.message = `Machine ${input.current_machine ?? "(unknown)"} not published`;
22
+ }
23
+ else {
24
+ cp01.passed = true;
25
+ }
26
+ const cp02 = items.find(i => i.id === "C-PR-02");
27
+ cp02.passed = !!input.current_machine || !!data.object;
28
+ cp02.message = cp02.passed ? "" : "No machine bound";
29
+ const cp03 = items.find(i => i.id === "C-PR-03");
30
+ const currentOps = input.current_named_operator_count ?? 0;
31
+ const isAddingNewName = data.progress_namedOperator?.op === "add" || data.progress_namedOperator?.op === "set";
32
+ if (isAddingNewName && currentOps >= MAX_NAMED_OPERATOR_COUNT) {
33
+ cp03.passed = false;
34
+ cp03.message = `named_operator count ${currentOps} ≥ MAX_NAMED_OPERATOR_COUNT ${MAX_NAMED_OPERATOR_COUNT}`;
35
+ }
36
+ else {
37
+ cp03.passed = true;
38
+ }
39
+ const cp04 = items.find(i => i.id === "C-PR-04");
40
+ if (data.progress_namedOperator) {
41
+ const count = data.progress_namedOperator.operators.length;
42
+ cp04.passed = count <= MAX_NAMED_OPERATOR_ADDRESS_COUNT;
43
+ cp04.message = cp04.passed ? "" : `${count} > ${MAX_NAMED_OPERATOR_ADDRESS_COUNT}`;
44
+ }
45
+ else {
46
+ cp04.passed = true;
47
+ }
48
+ const cp05 = items.find(i => i.id === "C-PR-05");
49
+ if (data.repository && (data.repository.op === "add" || data.repository.op === "set")) {
50
+ const current = input.current_context_repository_count ?? 0;
51
+ const addCount = data.repository.op === "set" ? data.repository.objects.length : data.repository.objects.length;
52
+ const newCount = data.repository.op === "set" ? addCount : current + addCount;
53
+ cp05.passed = newCount <= MAX_CONTEXT_REPOSITORY_COUNT;
54
+ cp05.message = cp05.passed ? "" : `${newCount} > ${MAX_CONTEXT_REPOSITORY_COUNT}`;
55
+ }
56
+ else {
57
+ cp05.passed = true;
58
+ }
59
+ const cp06 = items.find(i => i.id === "C-PR-06");
60
+ if (data.task && input.current_task) {
61
+ cp06.passed = false;
62
+ cp06.message = `task already set to ${input.current_task} — E_TASK_ALREADY_SET will abort`;
63
+ }
64
+ else {
65
+ cp06.passed = true;
66
+ }
67
+ const cp07 = items.find(i => i.id === "C-PR-07");
68
+ const validOps = ["next", "hold", "unhold", "adminUnhold"];
69
+ if (data.operate && data.operate.op && !validOps.includes(data.operate.op)) {
70
+ cp07.passed = false;
71
+ cp07.message = `operate.op must be one of: ${validOps.join(", ")}`;
72
+ }
73
+ else {
74
+ cp07.passed = true;
75
+ }
76
+ const cp08 = items.find(i => i.id === "C-PR-08");
77
+ if (data.operate?.message) {
78
+ const len = data.operate.message.length;
79
+ cp08.passed = len <= 1024;
80
+ cp08.message = cp08.passed ? "" : `message length ${len} > 1024`;
81
+ }
82
+ else {
83
+ cp08.passed = true;
84
+ }
85
+ const cp09 = items.find(i => i.id === "C-PR-09");
86
+ if (data.operate) {
87
+ cp09.passed = true;
88
+ cp09.message = "Forward existence verified in L4 (queryTableItem_MachineNode)";
89
+ }
90
+ else {
91
+ cp09.passed = true;
92
+ }
93
+ const cp10 = items.find(i => i.id === "C-PR-10");
94
+ if (data.operate?.op === "adminUnhold") {
95
+ cp10.passed = false;
96
+ cp10.message = "Pending user confirmation in L3 (QPR3)";
97
+ }
98
+ else {
99
+ cp10.passed = true;
100
+ }
101
+ return {
102
+ all_passed: items.filter(i => i.id !== "C-PR-10").every(i => i.passed),
103
+ items,
104
+ };
105
+ }
106
+ function adaptRiskAssessment(input) {
107
+ const ctx = {
108
+ object: input.progress_json.object,
109
+ task: input.progress_json.task,
110
+ repository: input.progress_json.repository,
111
+ progress_namedOperator: input.progress_json.progress_namedOperator,
112
+ operate: input.progress_json.operate,
113
+ current_machine: input.current_machine,
114
+ machine_published: input.machine_published,
115
+ current_task: input.current_task,
116
+ current_named_operator_count: input.current_named_operator_count,
117
+ current_context_repository_count: input.current_context_repository_count,
118
+ current_node: input.current_node,
119
+ forward_already_accomplished: input.forward_already_accomplished,
120
+ holder_address: input.holder_address,
121
+ signer: input.signer,
122
+ forward_named_operator: input.forward_named_operator,
123
+ forward_permission_index: input.forward_permission_index,
124
+ forward_has_guard: input.forward_has_guard,
125
+ target_objects_types: input.target_objects_types,
126
+ };
127
+ return assessProgressRisks(ctx);
128
+ }
129
+ export const PROGRESS_CONFIRMATION_QUESTIONS = [
130
+ {
131
+ id: "QPR1",
132
+ question: "Is the target Progress object address correct, and is it bound to the intended Machine?",
133
+ requires_explicit_yes: true,
134
+ },
135
+ {
136
+ id: "QPR2",
137
+ question: "For task_set: do you acknowledge that task is ONE-TIME and immutable (E_TASK_ALREADY_SET blocks any re-assignment)?",
138
+ requires_explicit_yes: true,
139
+ related_risk_ids: ["R-PR-2-01"],
140
+ },
141
+ {
142
+ id: "QPR3",
143
+ question: "⚠️ For adminUnhold: do you confirm force-releasing the held forward via 224 permission? This bypasses the holder check.",
144
+ requires_explicit_yes: true,
145
+ related_risk_ids: ["R-PR-3-01"],
146
+ },
147
+ {
148
+ id: "QPR4",
149
+ question: "For named_operator changes: are all addresses verified as the intended role holders (not expired/compromised)?",
150
+ requires_explicit_yes: true,
151
+ related_risk_ids: ["R-PR-3-02"],
152
+ },
153
+ {
154
+ id: "QPR5",
155
+ question: "For Forward advance (next/hold): does the Forward exist in the Machine, and is the caller authorized (named_operator match OR order.has_op_permission)?",
156
+ requires_explicit_yes: true,
157
+ related_risk_ids: ["R-PR-3-03", "R-PR-4-03"],
158
+ },
159
+ {
160
+ id: "QPR6",
161
+ question: "For context_repository binding: have you verified the Repository addresses still exist and are owned by trusted parties?",
162
+ requires_explicit_yes: false,
163
+ related_risk_ids: ["R-PR-5-02"],
164
+ },
165
+ ];
166
+ function processUserConfirmation(input, assessment) {
167
+ const questions = [...PROGRESS_CONFIRMATION_QUESTIONS];
168
+ const data = input.progress_json;
169
+ const filtered = [];
170
+ for (const q of questions) {
171
+ if (q.id === "QPR2" && !data.task)
172
+ continue;
173
+ if (q.id === "QPR3" && data.operate?.op !== "adminUnhold")
174
+ continue;
175
+ if (q.id === "QPR4" && !data.progress_namedOperator)
176
+ continue;
177
+ if (q.id === "QPR5" && !data.operate)
178
+ continue;
179
+ if (q.id === "QPR6" && !data.repository)
180
+ continue;
181
+ filtered.push(q);
182
+ }
183
+ if (input.skip_user_confirmation) {
184
+ return {
185
+ questions_asked: filtered,
186
+ responses: filtered.map(q => ({ question_id: q.id, response: "yes" })),
187
+ all_confirmed: true,
188
+ };
189
+ }
190
+ return {
191
+ questions_asked: filtered,
192
+ responses: [],
193
+ all_confirmed: false,
194
+ };
195
+ }
196
+ function verifyEnvironment(input) {
197
+ const checks = [];
198
+ if (input.progress_json.object) {
199
+ checks.push({
200
+ name: "progress_exists",
201
+ passed: true,
202
+ message: `Progress ${input.progress_json.object} assumed to exist`,
203
+ });
204
+ }
205
+ if (input.current_machine) {
206
+ checks.push({
207
+ name: "machine_published_and_bound",
208
+ passed: input.machine_published !== false,
209
+ message: input.machine_published === false
210
+ ? `Machine ${input.current_machine} NOT published`
211
+ : `Machine ${input.current_machine} published and bound`,
212
+ });
213
+ }
214
+ if (input.progress_json.operate) {
215
+ checks.push({
216
+ name: "forward_exists_in_machine",
217
+ passed: true,
218
+ message: `Forward "${input.progress_json.operate.operation.forward}" from "${input.current_node ?? "(unknown)"}" → "${input.progress_json.operate.operation.next_node_name}" — verify via queryTableItem_MachineNode`,
219
+ });
220
+ }
221
+ if (input.progress_json.operate && input.signer) {
222
+ const isOrderHolder = input.forward_named_operator === "";
223
+ const isNamedOperatorMatch = !!input.forward_named_operator && input.forward_named_operator !== "";
224
+ checks.push({
225
+ name: "signer_authorized_for_forward",
226
+ passed: true,
227
+ message: isOrderHolder
228
+ ? `OrderHolder namespace — signer must be order.owner/agent (use order_next/order_hold)`
229
+ : isNamedOperatorMatch
230
+ ? `namedOperator="${input.forward_named_operator}" — signer must be in operator list`
231
+ : `Forward.permissionIndex=${input.forward_permission_index ?? "None"} — signer must have this index`,
232
+ });
233
+ }
234
+ if (input.progress_json.operate &&
235
+ input.progress_json.operate.op === "unhold" &&
236
+ input.holder_address) {
237
+ const isHolder = input.signer === input.holder_address;
238
+ checks.push({
239
+ name: "unhold_by_holder",
240
+ passed: isHolder,
241
+ message: isHolder
242
+ ? "Signer is the holder — unhold allowed"
243
+ : `Signer ${input.signer} ≠ holder ${input.holder_address} — E_NOT_THE_HOLDER will abort (use adminUnhold for force release)`,
244
+ });
245
+ }
246
+ const allPassed = checks.every(c => c.passed);
247
+ return { passed: allPassed, checks };
248
+ }
249
+ export const PROGRESS_CONFIRM_VERSION = "1.0.0";
250
+ export function runProgressConfirmGate(input) {
251
+ const layersPassed = [];
252
+ const layersFailed = [];
253
+ const checklist = runStaticChecklist(input);
254
+ if (!checklist.all_passed) {
255
+ layersFailed.push("L1_checklist");
256
+ return {
257
+ status: "blocked_checklist",
258
+ checklist_result: checklist,
259
+ confirmation_text: generateConfirmationText(input, checklist),
260
+ block_reason: `Checklist failed: ${checklist.items.filter(i => !i.passed).map(i => i.id).join(", ")}`,
261
+ decision_record: {
262
+ timestamp: new Date().toISOString(),
263
+ gate_version: PROGRESS_CONFIRM_VERSION,
264
+ final_status: "blocked_checklist",
265
+ layers_passed: layersPassed,
266
+ layers_failed: layersFailed,
267
+ },
268
+ };
269
+ }
270
+ layersPassed.push("L1_checklist");
271
+ const assessment = adaptRiskAssessment(input);
272
+ const hasCritical = assessment.risks.some(r => r.level === "CRITICAL");
273
+ if (hasCritical) {
274
+ layersFailed.push("L2_risk");
275
+ return {
276
+ status: "blocked_risk",
277
+ checklist_result: checklist,
278
+ risk_result: assessment,
279
+ confirmation_text: generateConfirmationText(input, checklist, assessment),
280
+ block_reason: `CRITICAL risks: ${assessment.risks.filter(r => r.level === "CRITICAL").map(r => r.id).join(", ")}`,
281
+ decision_record: {
282
+ timestamp: new Date().toISOString(),
283
+ gate_version: PROGRESS_CONFIRM_VERSION,
284
+ final_status: "blocked_risk",
285
+ layers_passed: layersPassed,
286
+ layers_failed: layersFailed,
287
+ },
288
+ };
289
+ }
290
+ layersPassed.push("L2_risk");
291
+ const userConf = processUserConfirmation(input, assessment);
292
+ if (!userConf.all_confirmed) {
293
+ if (input.progress_json.operate?.op === "adminUnhold") {
294
+ const cp10 = checklist.items.find(i => i.id === "C-PR-10");
295
+ if (cp10) {
296
+ const qpr3 = userConf.responses.find(r => r.question_id === "QPR3");
297
+ cp10.passed = qpr3?.response === "yes";
298
+ cp10.message = cp10.passed ? "" : "adminUnhold not confirmed by user (QPR3)";
299
+ }
300
+ }
301
+ if (input.progress_json.operate?.op === "adminUnhold") {
302
+ const cp10 = checklist.items.find(i => i.id === "C-PR-10");
303
+ if (cp10 && !cp10.passed) {
304
+ layersFailed.push("L3_user");
305
+ return {
306
+ status: "blocked_user",
307
+ checklist_result: checklist,
308
+ risk_result: assessment,
309
+ user_confirmation: userConf,
310
+ confirmation_text: generateConfirmationText(input, checklist, assessment),
311
+ block_reason: "User did not confirm adminUnhold (QPR3)",
312
+ decision_record: {
313
+ timestamp: new Date().toISOString(),
314
+ gate_version: PROGRESS_CONFIRM_VERSION,
315
+ final_status: "blocked_user",
316
+ layers_passed: layersPassed,
317
+ layers_failed: layersFailed,
318
+ },
319
+ };
320
+ }
321
+ }
322
+ }
323
+ layersPassed.push("L3_user");
324
+ if (input.skip_environment_check) {
325
+ layersPassed.push("L4_environment");
326
+ }
327
+ else {
328
+ const env = verifyEnvironment(input);
329
+ if (!env.passed) {
330
+ layersFailed.push("L4_environment");
331
+ return {
332
+ status: "blocked_environment",
333
+ checklist_result: checklist,
334
+ risk_result: assessment,
335
+ user_confirmation: userConf,
336
+ environment_result: env,
337
+ confirmation_text: generateConfirmationText(input, checklist, assessment),
338
+ block_reason: `Environment check failed: ${env.checks.filter(c => !c.passed).map(c => c.name).join(", ")}`,
339
+ decision_record: {
340
+ timestamp: new Date().toISOString(),
341
+ gate_version: PROGRESS_CONFIRM_VERSION,
342
+ final_status: "blocked_environment",
343
+ layers_passed: layersPassed,
344
+ layers_failed: layersFailed,
345
+ },
346
+ };
347
+ }
348
+ layersPassed.push("L4_environment");
349
+ }
350
+ return {
351
+ status: "approved",
352
+ checklist_result: checklist,
353
+ risk_result: assessment,
354
+ user_confirmation: userConf,
355
+ confirmation_text: generateConfirmationText(input, checklist, assessment),
356
+ decision_record: {
357
+ timestamp: new Date().toISOString(),
358
+ gate_version: PROGRESS_CONFIRM_VERSION,
359
+ final_status: "approved",
360
+ layers_passed: layersPassed,
361
+ layers_failed: layersFailed,
362
+ },
363
+ };
364
+ }
365
+ function generateConfirmationText(input, checklist, assessment) {
366
+ const lines = [];
367
+ const data = input.progress_json;
368
+ lines.push("═══ Progress Operation Confirmation ═══");
369
+ lines.push("");
370
+ if (data.object) {
371
+ lines.push(`Progress: ${data.object}`);
372
+ }
373
+ else {
374
+ lines.push("Progress: NEW (indirect via service::buy)");
375
+ }
376
+ if (input.current_machine) {
377
+ lines.push(`Bound Machine: ${input.current_machine} (published: ${input.machine_published !== false ? "YES" : "NO"})`);
378
+ }
379
+ if (input.current_node) {
380
+ lines.push(`Current node: ${input.current_node}`);
381
+ }
382
+ lines.push("");
383
+ lines.push("─ Checklist ──────────────────");
384
+ for (const item of checklist.items) {
385
+ const mark = item.passed ? "✓" : "✗";
386
+ lines.push(` ${mark} ${item.id}: ${item.description}${item.message ? " — " + item.message : ""}`);
387
+ }
388
+ lines.push("");
389
+ if (assessment) {
390
+ lines.push("─ Risk Assessment ──────────────────");
391
+ lines.push(`Overall: ${assessment.overall_risk}`);
392
+ lines.push(`Detected: ${assessment.risks.length} risk(s)`);
393
+ for (const r of assessment.risks) {
394
+ lines.push(` [${r.level}] ${r.id}: ${r.title}`);
395
+ }
396
+ lines.push("");
397
+ }
398
+ lines.push("─ Operations ──────────────────");
399
+ if (data.task)
400
+ lines.push(`- ⚠️ task_set: ${data.task} (one-time, immutable)`);
401
+ if (data.repository)
402
+ lines.push(`- Repository ${data.repository.op}: ${data.repository.objects?.length ?? 0} object(s)`);
403
+ if (data.progress_namedOperator) {
404
+ const n = data.progress_namedOperator;
405
+ lines.push(`- namedOperator ${n.op} "${n.name}": ${n.operators.length} address(es)`);
406
+ }
407
+ if (data.operate) {
408
+ const o = data.operate;
409
+ lines.push(`- Operation: ${o.operation.forward} → ${o.operation.next_node_name}`);
410
+ if (o.op)
411
+ lines.push(` op=${o.op}`);
412
+ if (o.op === "hold")
413
+ lines.push(` ⚠️ hold (lock forward)`);
414
+ if (o.op === "adminUnhold")
415
+ lines.push(` ⚠️ adminUnhold (force release via 224)`);
416
+ if (o.op === "unhold")
417
+ lines.push(` ℹ️ unhold (self-release)`);
418
+ if (o.message)
419
+ lines.push(` Message: "${o.message}"`);
420
+ }
421
+ lines.push("");
422
+ return lines.join("\n");
423
+ }
424
+ export function progressiveProgressCheck(input) {
425
+ const checklist = runStaticChecklist(input);
426
+ if (!checklist.all_passed) {
427
+ return {
428
+ stage: "checklist",
429
+ status: "fail",
430
+ message: `Checklist failed: ${checklist.items.filter(i => !i.passed).map(i => i.id).join(", ")}`,
431
+ next_action: "Fix failing checklist items",
432
+ };
433
+ }
434
+ const assessment = adaptRiskAssessment(input);
435
+ if (assessment.risks.some(r => r.level === "CRITICAL")) {
436
+ return {
437
+ stage: "risk",
438
+ status: "fail",
439
+ message: `CRITICAL risks: ${assessment.risks.filter(r => r.level === "CRITICAL").map(r => r.id).join(", ")}`,
440
+ next_action: "Resolve CRITICAL risks before proceeding",
441
+ };
442
+ }
443
+ if (assessment.needs_human_review) {
444
+ return {
445
+ stage: "confirmation",
446
+ status: "pending",
447
+ message: "Human review required for HIGH risks",
448
+ next_action: "Confirm risk acceptance",
449
+ };
450
+ }
451
+ return {
452
+ stage: "complete",
453
+ status: "pass",
454
+ message: "All checks passed",
455
+ };
456
+ }
@@ -0,0 +1,123 @@
1
+ import { type ProgressScene, type ProgressBuiltinPermissionEntry, type ProgressPhase } from "./progress-ledger.js";
2
+ import { type ProgressPuzzle, type ProgressPuzzleCompleteness } from "./progress-puzzle.js";
3
+ import { type ProgressRiskAssessment, type ProgressRiskRule, type ProgressStakeholder } from "./progress-risk.js";
4
+ import { type ProgressSemanticToSchemaRule } from "./progress-translation.js";
5
+ import { type ProgressTemplate } from "./progress-templates.js";
6
+ import { PROGRESS_OPERATION_CHECKLIST, PROGRESS_CONFIRMATION_QUESTIONS, type ProgressJsonForConfirm } from "./progress-confirm.js";
7
+ export declare const PROGRESS_CONTEXT_VERSION = "1.0.0";
8
+ export type ProgressInjectionMode = "initial_design" | "mid_progress_review" | "pre_advance" | "post_task_binding" | "stakeholder_review" | "apply_check";
9
+ export type ProgressStakeholderPerspective = ProgressStakeholder | "system";
10
+ export interface ProgressContextBundle {
11
+ version: string;
12
+ mode: ProgressInjectionMode;
13
+ stakeholder_perspective?: ProgressStakeholderPerspective;
14
+ matched_scene?: ProgressScene;
15
+ matched_template?: ProgressTemplate;
16
+ matched_pattern?: ProgressSemanticToSchemaRule;
17
+ puzzle_state?: ProgressPuzzle;
18
+ puzzle_completeness?: ProgressPuzzleCompleteness;
19
+ relevant_risks: ProgressRiskRule[];
20
+ risk_assessment?: ProgressRiskAssessment;
21
+ relevant_checklist: typeof PROGRESS_OPERATION_CHECKLIST;
22
+ relevant_questions: typeof PROGRESS_CONFIRMATION_QUESTIONS;
23
+ relevant_builtin_permissions: ProgressBuiltinPermissionEntry[];
24
+ cross_object_refs: ProgressCrossObjectRef[];
25
+ onchain_constraints: ProgressOnchainConstraint[];
26
+ rendering_hints: ProgressRenderingHints;
27
+ }
28
+ export interface ProgressCrossObjectRef {
29
+ object: "Machine" | "Order" | "Repository" | "Permission" | "Service" | "Passport" | "Payment" | "Allocation";
30
+ phase: ProgressPhase | "universal";
31
+ relationship: string;
32
+ description: string;
33
+ }
34
+ export interface ProgressOnchainConstraint {
35
+ name: string;
36
+ value: string | number;
37
+ description: string;
38
+ error_code?: string;
39
+ }
40
+ export interface ProgressRenderingHints {
41
+ include_puzzle_template: boolean;
42
+ include_risk_details: boolean;
43
+ include_questions: boolean;
44
+ include_immutability_warning: boolean;
45
+ include_admin_unhold_warning: boolean;
46
+ include_cross_object_refs: boolean;
47
+ include_terminal_node_note: boolean;
48
+ max_length: number;
49
+ }
50
+ export interface BuildProgressContextInput {
51
+ mode: ProgressInjectionMode;
52
+ intent?: string;
53
+ progress_json?: ProgressJsonForConfirm;
54
+ stakeholder?: ProgressStakeholderPerspective;
55
+ target_phase?: ProgressPhase;
56
+ target_industry?: string;
57
+ max_length?: number;
58
+ current_machine?: string;
59
+ machine_published?: boolean;
60
+ current_task?: string | null;
61
+ current_named_operator_count?: number;
62
+ current_context_repository_count?: number;
63
+ current_node?: string;
64
+ forward_already_accomplished?: boolean;
65
+ holder_address?: string | null;
66
+ signer?: string;
67
+ forward_named_operator?: string;
68
+ forward_permission_index?: number | null;
69
+ forward_has_guard?: boolean;
70
+ target_objects_types?: string[];
71
+ }
72
+ export declare function buildProgressContext(input: BuildProgressContextInput): ProgressContextBundle;
73
+ export declare function buildPromptFromProgressContext(bundle: ProgressContextBundle): string;
74
+ export declare function getProgressContextSummary(bundle: ProgressContextBundle): string;
75
+ export declare function buildStakeholderContext(stakeholder: ProgressStakeholderPerspective, intent?: string, progress_json?: ProgressJsonForConfirm): ProgressContextBundle;
76
+ export declare function quickValidateProgressJson(progress_json: ProgressJsonForConfirm, current_state?: {
77
+ machine_published?: boolean;
78
+ current_task?: string | null;
79
+ current_named_operator_count?: number;
80
+ current_context_repository_count?: number;
81
+ }): {
82
+ ok: boolean;
83
+ violations: string[];
84
+ };
85
+ export declare function getProgressKnowledgeSnapshot(): {
86
+ version: {
87
+ ledger: string;
88
+ puzzle: string;
89
+ risk: string;
90
+ translation: string;
91
+ templates: string;
92
+ confirm: string;
93
+ context: string;
94
+ };
95
+ scenes_count: number;
96
+ builtin_permissions_count: number;
97
+ builtin_permissions: {
98
+ index: 220 | 221 | 222 | 223 | 224 | 225;
99
+ name: string;
100
+ sdk_exposed: boolean;
101
+ }[];
102
+ templates_count: number;
103
+ templates: {
104
+ id: string;
105
+ name: string;
106
+ description: string;
107
+ scenes: string[];
108
+ }[];
109
+ semantic_patterns_count: number;
110
+ schema_rules_count: number;
111
+ constraint_rules_count: number;
112
+ risk_rules_count: number;
113
+ checklist_count: number;
114
+ confirmation_questions_count: number;
115
+ cross_object_refs_count: number;
116
+ onchain_limits: {
117
+ max_named_operator_count: 60;
118
+ max_named_operator_address_count: 80;
119
+ max_context_repository_count: 30;
120
+ };
121
+ injection_modes: ProgressInjectionMode[];
122
+ stakeholders: ProgressStakeholderPerspective[];
123
+ };