@wowok/agent-mcp 2.4.3 → 2.5.1

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 +1412 -6
  253. package/dist/schema/project/index.js +441 -3
  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 +1809 -336
  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 +578 -579
  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 +0 -514
  277. package/dist/schemas/onchain_operations_permission.schema.json +0 -514
  278. package/dist/schemas/onchain_operations_personal.schema.json +0 -514
  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 +918 -0
  287. package/dist/schemas/project_operation.schema.json +474 -3
  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 +262 -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 +96 -25
  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
@@ -10,11 +10,12 @@ export function applyOnchainRules(args) {
10
10
  return null;
11
11
  }
12
12
  const env = getEnvConfig(validated.env);
13
- const gateResult = buildPendingConfirmation(validated.operation_type, validated.data, env);
13
+ const data = 'data' in validated ? validated.data : undefined;
14
+ const gateResult = buildPendingConfirmation(validated.operation_type, data, env);
14
15
  if (gateResult.structuredContent) {
15
16
  return gateResult;
16
17
  }
17
- const constraintViolations = validateOperation(validated.operation_type, validated.data);
18
+ const constraintViolations = validateOperation(validated.operation_type, data);
18
19
  if (hasBlockingViolations(constraintViolations)) {
19
20
  return buildConstraintError(validated.operation_type, constraintViolations);
20
21
  }
@@ -1,29 +1,20 @@
1
1
  import { validateOperation, hasBlockingViolations, getWarningViolations, type ConstraintViolation } from "../knowledge/index.js";
2
2
  import { classifyError, type SemanticContext } from "../schema/call/semantic.js";
3
+ import type { ToolDispatchResult } from "./types.js";
3
4
  export declare function withHarness(base: SemanticContext, operation: string, intent: string): SemanticContext;
4
- export interface LocalHandlerConfig {
5
- schema: import("zod").ZodTypeAny;
6
- operationFn: (input: any) => Promise<any>;
5
+ import type { z } from "zod";
6
+ import type { CallEnv } from "../schema/call/base.js";
7
+ export interface LocalHandlerConfig<S extends z.ZodTypeAny> {
8
+ schema: S;
9
+ operationFn: (input: z.infer<S>) => Promise<unknown>;
7
10
  parseLabel: string;
8
- buildContext: (validated: any) => SemanticContext;
11
+ buildContext: (validated: z.infer<S>) => SemanticContext;
9
12
  }
10
- export declare function wrapLocalHandler(config: LocalHandlerConfig): (args: any) => Promise<{
11
- content: {
12
- type: "text";
13
- text: string;
14
- }[];
15
- structuredContent: {
16
- result: any;
17
- semantic: any;
18
- };
19
- }>;
20
- export declare function buildPendingConfirmation(operation_type: string, data: any, env: any): {
21
- content: any[];
22
- structuredContent: any;
13
+ export declare function wrapLocalHandler<S extends z.ZodTypeAny>(config: LocalHandlerConfig<S>): (args: unknown) => Promise<ToolDispatchResult>;
14
+ export declare function buildPendingConfirmation(operation_type: string, data: unknown, env: CallEnv | undefined): ToolDispatchResult | {
15
+ content: never[];
16
+ structuredContent: null;
23
17
  };
24
- export declare function buildConstraintError(operation_type: string, violations: ConstraintViolation[]): {
25
- content: any[];
26
- structuredContent: any;
27
- };
28
- export declare function buildClassifiedErrorResult(base: Record<string, any>, error: string, classified: ReturnType<typeof classifyError>): Record<string, any>;
18
+ export declare function buildConstraintError(operation_type: string, violations: ConstraintViolation[]): ToolDispatchResult;
19
+ export declare function buildClassifiedErrorResult(base: Record<string, unknown>, error: string, classified: ReturnType<typeof classifyError>): Record<string, unknown>;
29
20
  export { validateOperation, hasBlockingViolations, getWarningViolations, type ConstraintViolation, };
@@ -12,23 +12,23 @@ export interface ToolConfig {
12
12
  idempotentHint?: boolean;
13
13
  openWorldHint?: boolean;
14
14
  };
15
- _meta?: any;
15
+ _meta?: Record<string, unknown>;
16
16
  }
17
- export type ErrorShapeBuilder = (error: string, classified: ReturnType<typeof classifyError>, ctx: SemanticContext) => Record<string, any>;
17
+ export type ErrorShapeBuilder = (error: string, classified: ReturnType<typeof classifyError>, ctx: SemanticContext) => Record<string, unknown>;
18
18
  export interface ToolDispatchResult {
19
19
  content: {
20
20
  type: "text";
21
21
  text: string;
22
22
  }[];
23
- structuredContent: any;
23
+ structuredContent: Record<string, unknown> | undefined;
24
24
  }
25
25
  export interface ToolEntry {
26
26
  name: string;
27
- handler: (args: any) => Promise<ToolDispatchResult>;
27
+ handler: (args: unknown) => Promise<ToolDispatchResult>;
28
28
  config: ToolConfig;
29
29
  errorShapeBuilder?: ErrorShapeBuilder;
30
30
  timeoutMs?: number;
31
- applyRules?: (args: any) => ToolDispatchResult | null;
31
+ applyRules?: (args: unknown) => ToolDispatchResult | null;
32
32
  }
33
33
  export interface DispatchOptions {
34
34
  skipRules?: boolean;
@@ -1,6 +1,14 @@
1
- import type { ErrorShapeBuilder } from "./types.js";
1
+ import type { ErrorShapeBuilder, ToolDispatchResult } from "./types.js";
2
2
  export declare function withTimeout<T>(promise: Promise<T>, timeoutMs?: number, operationName?: string): Promise<T>;
3
- export declare function wrapHandlerWithErrorShape(handler: (args: any) => Promise<any>, timeoutMs: number, toolName: string, errorShapeBuilder?: ErrorShapeBuilder): (args: any) => Promise<any>;
3
+ export declare function wrapHandlerWithErrorShape(handler: (args: unknown) => Promise<ToolDispatchResult>, timeoutMs: number, toolName: string, errorShapeBuilder?: ErrorShapeBuilder): (args: unknown) => Promise<ToolDispatchResult>;
4
4
  export declare const statusErrorShape: ErrorShapeBuilder;
5
5
  export declare const operationErrorShape: ErrorShapeBuilder;
6
6
  export declare const strictStatusErrorShape: ErrorShapeBuilder;
7
+ export type HarnessHookPhase = "pre_call" | "post_call" | "pre_publish" | "pre_sign";
8
+ export interface HarnessHookContext {
9
+ toolName: string;
10
+ args: unknown;
11
+ result?: ToolDispatchResult;
12
+ error?: unknown;
13
+ }
14
+ export declare function dispatchWithHarness(handler: (args: unknown) => Promise<ToolDispatchResult>, toolName: string): (args: unknown) => Promise<ToolDispatchResult>;
@@ -1,5 +1,9 @@
1
1
  import { classifyError, buildDataSemantic, } from "../schema/call/semantic.js";
2
2
  import { buildClassifiedErrorResult } from "./shared.js";
3
+ import { shouldRunLightHooks, shouldRunHeavyHooks, recordOperationFailure, } from "../harness/auto-escalation.js";
4
+ import { getHarness } from "../harness/index.js";
5
+ import { recordOperationOutcome } from "../experience/index.js";
6
+ import { recordIndustrySignal } from "../knowledge/flywheel-loop.js";
3
7
  export function withTimeout(promise, timeoutMs = 30000, operationName = "operation") {
4
8
  let timer;
5
9
  return Promise.race([
@@ -53,3 +57,211 @@ export const operationErrorShape = (error, classified, ctx) => ({
53
57
  export const strictStatusErrorShape = (error, _classified, _ctx) => ({
54
58
  result: { status: "error", error },
55
59
  });
60
+ export function dispatchWithHarness(handler, toolName) {
61
+ return async (args) => {
62
+ const harnessWarnings = [];
63
+ const harness = getHarness();
64
+ const runLight = shouldRunLightHooks();
65
+ const runHeavy = shouldRunHeavyHooks();
66
+ const isPublishOp = runHeavy && isPublishOperation(toolName, args);
67
+ const isSignOp = runHeavy && isSignOperation(toolName, args);
68
+ let expectedResult;
69
+ if (runLight) {
70
+ try {
71
+ const operationType = extractOperationType(toolName, args);
72
+ const intent = extractIntent(toolName, args);
73
+ if (operationType && intent) {
74
+ expectedResult = harness.expect(toolName, intent, operationType, extractData(args));
75
+ }
76
+ }
77
+ catch (e) {
78
+ harnessWarnings.push(`pre_call hook failed: ${e instanceof Error ? e.message : String(e)}`);
79
+ }
80
+ }
81
+ if (isPublishOp) {
82
+ try {
83
+ harnessWarnings.push("pre_publish: full-tier check engaged");
84
+ }
85
+ catch (e) {
86
+ harnessWarnings.push(`pre_publish hook failed: ${e instanceof Error ? e.message : String(e)}`);
87
+ }
88
+ }
89
+ if (isSignOp) {
90
+ try {
91
+ harnessWarnings.push("pre_sign: full-tier check engaged");
92
+ }
93
+ catch (e) {
94
+ harnessWarnings.push(`pre_sign hook failed: ${e instanceof Error ? e.message : String(e)}`);
95
+ }
96
+ }
97
+ let result;
98
+ try {
99
+ result = await handler(args);
100
+ }
101
+ catch (e) {
102
+ const errorCode = e instanceof Error ? e.message : String(e);
103
+ const escalation = recordOperationFailure(toolName, errorCode);
104
+ if (escalation) {
105
+ harnessWarnings.push(`Harness escalated to full tier: ${escalation.reason}`);
106
+ }
107
+ throw e;
108
+ }
109
+ if (runLight && expectedResult) {
110
+ try {
111
+ if (result?.structuredContent) {
112
+ const verifyInput = buildVerifyInput(expectedResult, result);
113
+ const report = harness.verify(verifyInput);
114
+ if (report.status === "fail") {
115
+ harnessWarnings.push(`Harness verify FAIL: ${report.summary}`);
116
+ }
117
+ else if (report.status === "warn") {
118
+ harnessWarnings.push(`Harness verify WARN: ${report.summary}`);
119
+ }
120
+ }
121
+ }
122
+ catch (e) {
123
+ harnessWarnings.push(`post_call hook failed: ${e instanceof Error ? e.message : String(e)}`);
124
+ }
125
+ }
126
+ if (isWriteClassTool(toolName)) {
127
+ try {
128
+ const operationType = extractOperationType(toolName, args) ?? toolName;
129
+ const intent = extractIntent(toolName, args) ?? toolName;
130
+ const data = extractData(args) ?? args;
131
+ const outcome = classifyOutcome(result);
132
+ const errorCode = extractErrorCode(result);
133
+ const industry = extractIndustry(args) ?? "general";
134
+ recordOperationOutcome(operationType, data, intent, outcome, errorCode);
135
+ recordIndustrySignal(industry, { type: operationType }, {
136
+ success: outcome === "success",
137
+ error_code: errorCode,
138
+ });
139
+ }
140
+ catch (e) {
141
+ harnessWarnings.push(`signal collection failed: ${e instanceof Error ? e.message : String(e)}`);
142
+ }
143
+ }
144
+ if (harnessWarnings.length > 0 && result?.structuredContent) {
145
+ const sc = result.structuredContent;
146
+ const semantic = sc.semantic;
147
+ if (semantic) {
148
+ const existing = Array.isArray(semantic.harness_warnings) ? semantic.harness_warnings : [];
149
+ semantic.harness_warnings = [...existing, ...harnessWarnings];
150
+ }
151
+ else {
152
+ sc.harness_warnings = harnessWarnings;
153
+ }
154
+ }
155
+ return result;
156
+ };
157
+ }
158
+ function isPublishOperation(toolName, args) {
159
+ if (toolName !== "onchain_operations")
160
+ return false;
161
+ const opType = extractOperationType(toolName, args);
162
+ return opType === "service" || opType === "machine";
163
+ }
164
+ function isSignOperation(toolName, args) {
165
+ if (toolName === "wip_file") {
166
+ const data = args?.operation_type;
167
+ return data === "sign";
168
+ }
169
+ return toolName === "onchain_operations";
170
+ }
171
+ function extractOperationType(toolName, args) {
172
+ if (!args || typeof args !== "object")
173
+ return undefined;
174
+ const obj = args;
175
+ if (toolName === "onchain_operations") {
176
+ return typeof obj.operation_type === "string" ? obj.operation_type : undefined;
177
+ }
178
+ if (toolName === "project_operation") {
179
+ return typeof obj.action === "string" ? obj.action : undefined;
180
+ }
181
+ return typeof obj.operation_type === "string" ? obj.operation_type : undefined;
182
+ }
183
+ function extractIntent(toolName, args) {
184
+ if (!args || typeof args !== "object")
185
+ return undefined;
186
+ const obj = args;
187
+ if (toolName === "project_operation" && typeof obj.action === "string") {
188
+ return `project:${obj.action}`;
189
+ }
190
+ const opType = obj.operation_type;
191
+ if (typeof opType === "string")
192
+ return `${toolName}:${opType}`;
193
+ return toolName;
194
+ }
195
+ function extractData(args) {
196
+ if (!args || typeof args !== "object")
197
+ return undefined;
198
+ const obj = args;
199
+ const data = obj.data;
200
+ return data && typeof data === "object" ? data : undefined;
201
+ }
202
+ function buildVerifyInput(expected, result) {
203
+ const sc = (result.structuredContent ?? {});
204
+ const semantic = sc.semantic;
205
+ return {
206
+ expected,
207
+ actual: {
208
+ result_type: typeof sc.result_type === "string" ? sc.result_type : undefined,
209
+ semantic,
210
+ error_code: typeof sc.error_code === "string" ? sc.error_code : undefined,
211
+ error: typeof sc.error === "string" ? sc.error : undefined,
212
+ },
213
+ };
214
+ }
215
+ const WRITE_CLASS_TOOLS = new Set([
216
+ "onchain_operations",
217
+ "project_operation",
218
+ "wip_file",
219
+ "messenger_operation",
220
+ "bridge_operation",
221
+ ]);
222
+ function isWriteClassTool(toolName) {
223
+ return WRITE_CLASS_TOOLS.has(toolName);
224
+ }
225
+ function classifyOutcome(result) {
226
+ if (!result?.structuredContent)
227
+ return "failed";
228
+ const sc = result.structuredContent;
229
+ const status = typeof sc.status === "string" ? sc.status
230
+ : typeof sc.result_type === "string" ? sc.result_type
231
+ : "";
232
+ if (status === "error" || status === "failed")
233
+ return "failed";
234
+ if (status === "partial")
235
+ return "partial";
236
+ return "success";
237
+ }
238
+ function extractErrorCode(result) {
239
+ if (!result?.structuredContent)
240
+ return undefined;
241
+ const sc = result.structuredContent;
242
+ if (typeof sc.error_code === "string")
243
+ return sc.error_code;
244
+ const err = sc.error;
245
+ if (typeof err === "string")
246
+ return err;
247
+ if (err && typeof err === "object") {
248
+ const code = err.code;
249
+ if (typeof code === "string")
250
+ return code;
251
+ }
252
+ return undefined;
253
+ }
254
+ function extractIndustry(args) {
255
+ if (!args || typeof args !== "object")
256
+ return undefined;
257
+ const obj = args;
258
+ if (typeof obj.industry === "string")
259
+ return obj.industry;
260
+ const data = obj.data;
261
+ if (data && typeof data === "object") {
262
+ const d = data;
263
+ if (typeof d.industry === "string")
264
+ return d.industry;
265
+ }
266
+ return undefined;
267
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wowok/agent-mcp",
3
- "version": "2.4.3",
3
+ "version": "2.5.1",
4
4
  "description": "Making It Easy for AI Agents to Communicate, Collaborate, Trade, and Trust.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -50,7 +50,7 @@
50
50
  "license": "Apache-2.0",
51
51
  "dependencies": {
52
52
  "@modelcontextprotocol/sdk": "^1.29.0",
53
- "@wowok/wowok": "2.4.3",
53
+ "@wowok/wowok": "2.5.0",
54
54
  "lodash": "^4.18.1",
55
55
  "zod": "^3.25.76",
56
56
  "zod-to-json-schema": "^3.25.2"
@@ -66,7 +66,7 @@
66
66
  "build": "tsc && pnpm generate:schemas",
67
67
  "watch": "tsc --watch",
68
68
  "start": "tsx src/index.ts",
69
- "generate:schemas": "tsx scripts/generate-json-schemas.ts",
69
+ "generate:schemas": "node --max-old-space-size=4096 --import tsx/esm scripts/generate-json-schemas.ts",
70
70
  "test": "vitest run",
71
71
  "test:watch": "vitest"
72
72
  }