@wowok/agent-mcp 2.6.9 → 2.7.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 (139) hide show
  1. package/README.md +0 -2
  2. package/dist/customer/risk-assessment.d.ts +5 -1
  3. package/dist/customer/risk-assessment.js +4 -4
  4. package/dist/evaluation/arbitration-game.d.ts +16 -0
  5. package/dist/evaluation/arbitration-game.js +48 -0
  6. package/dist/evaluation/builtins/demand-match.d.ts +15 -0
  7. package/dist/evaluation/builtins/demand-match.js +153 -0
  8. package/dist/evaluation/builtins/index.d.ts +3 -0
  9. package/dist/evaluation/builtins/index.js +10 -0
  10. package/dist/evaluation/builtins/service-risk.d.ts +6 -0
  11. package/dist/evaluation/builtins/service-risk.js +55 -0
  12. package/dist/evaluation/capability.d.ts +50 -0
  13. package/dist/evaluation/capability.js +13 -0
  14. package/dist/evaluation/composer.d.ts +13 -0
  15. package/dist/evaluation/composer.js +40 -0
  16. package/dist/evaluation/engine.d.ts +18 -0
  17. package/dist/evaluation/engine.js +175 -0
  18. package/dist/evaluation/extract.d.ts +30 -0
  19. package/dist/evaluation/extract.js +115 -0
  20. package/dist/evaluation/gap.d.ts +2 -0
  21. package/dist/evaluation/gap.js +100 -0
  22. package/dist/evaluation/index.d.ts +11 -0
  23. package/dist/evaluation/index.js +11 -0
  24. package/dist/evaluation/node-game.d.ts +34 -0
  25. package/dist/evaluation/node-game.js +57 -0
  26. package/dist/evaluation/region.d.ts +10 -0
  27. package/dist/evaluation/region.js +36 -0
  28. package/dist/evaluation/types.d.ts +76 -0
  29. package/dist/evaluation/types.js +1 -0
  30. package/dist/evaluation/user-injection.d.ts +6 -0
  31. package/dist/evaluation/user-injection.js +27 -0
  32. package/dist/examples/education-contact-create.json +40 -0
  33. package/dist/examples/freelance-contact-create.json +40 -0
  34. package/dist/examples/insurance-machine-create.json +1 -1
  35. package/dist/examples/insurance-service-allocators.json +1 -1
  36. package/dist/examples/machine-publish.json +1 -1
  37. package/dist/examples/rental-ziroom-service-create.json +1 -1
  38. package/dist/examples/retail-adv-guard-messenger-proof-create.json +1 -1
  39. package/dist/examples/retail-myshop-service-create.json +1 -1
  40. package/dist/examples/retail-myshop-service-customer-required.json +1 -1
  41. package/dist/examples/subscription-contact-create.json +40 -0
  42. package/dist/examples/threebody-machine-create.json +1 -1
  43. package/dist/examples/travel-machine-create.json +1 -1
  44. package/dist/examples/travel-service-create.json +1 -1
  45. package/dist/harness/plan.js +42 -3
  46. package/dist/intent/enrich.d.ts +1 -0
  47. package/dist/intent/enrich.js +67 -0
  48. package/dist/intent/index.d.ts +23 -0
  49. package/dist/intent/index.js +60 -0
  50. package/dist/intent/matcher.d.ts +2 -0
  51. package/dist/intent/matcher.js +81 -0
  52. package/dist/intent/store.d.ts +19 -0
  53. package/dist/intent/store.js +55 -0
  54. package/dist/intent/types.d.ts +33 -0
  55. package/dist/intent/types.js +10 -0
  56. package/dist/knowledge/arbitration-risk.js +1 -11
  57. package/dist/knowledge/contact-templates.d.ts +27 -0
  58. package/dist/knowledge/contact-templates.js +60 -0
  59. package/dist/knowledge/examples-scanner.js +21 -3
  60. package/dist/knowledge/fund-layer.js +8 -4
  61. package/dist/knowledge/industry-generalizer.js +21 -21
  62. package/dist/knowledge/machine-risk.js +0 -1
  63. package/dist/knowledge/mcp-schema-audit.d.ts +1 -1
  64. package/dist/knowledge/mcp-schema-audit.js +8 -4
  65. package/dist/knowledge/service-risk.js +38 -2
  66. package/dist/knowledge/service-templates.js +1 -1
  67. package/dist/knowledge/service-translation.js +2 -2
  68. package/dist/knowledge/template-registry.d.ts +1 -1
  69. package/dist/knowledge/template-registry.js +13 -1
  70. package/dist/knowledge/tools-reference.js +23 -0
  71. package/dist/persona/analyzer.d.ts +16 -0
  72. package/dist/persona/analyzer.js +66 -0
  73. package/dist/persona/bridge.d.ts +5 -0
  74. package/dist/persona/bridge.js +86 -0
  75. package/dist/persona/defaults.d.ts +4 -0
  76. package/dist/persona/defaults.js +195 -0
  77. package/dist/persona/experience-bridge.d.ts +3 -0
  78. package/dist/persona/experience-bridge.js +23 -0
  79. package/dist/persona/index.d.ts +18 -0
  80. package/dist/persona/index.js +71 -0
  81. package/dist/persona/model.d.ts +7 -0
  82. package/dist/persona/model.js +111 -0
  83. package/dist/persona/store.d.ts +19 -0
  84. package/dist/persona/store.js +62 -0
  85. package/dist/persona/types.d.ts +43 -0
  86. package/dist/persona/types.js +5 -0
  87. package/dist/project/handlers.d.ts +5 -0
  88. package/dist/project/handlers.js +23 -1
  89. package/dist/project/semantic-graph.js +47 -0
  90. package/dist/rules.d.ts +2 -0
  91. package/dist/rules.js +43 -0
  92. package/dist/schema/call/semantic.js +23 -1
  93. package/dist/schema/call/service.js +7 -1
  94. package/dist/schema/evaluation/index.d.ts +4239 -0
  95. package/dist/schema/evaluation/index.js +356 -0
  96. package/dist/schema/index.d.ts +4 -0
  97. package/dist/schema/index.js +4 -0
  98. package/dist/schema/intent-radar/index.d.ts +284 -0
  99. package/dist/schema/intent-radar/index.js +89 -0
  100. package/dist/schema/messenger/index.d.ts +171 -0
  101. package/dist/schema/messenger/index.js +5 -0
  102. package/dist/schema/operations.js +1 -1
  103. package/dist/schema/persona/index.d.ts +1985 -0
  104. package/dist/schema/persona/index.js +148 -0
  105. package/dist/schema/project/index.d.ts +2 -2
  106. package/dist/schema/query/index.js +6 -0
  107. package/dist/schema/sync-layer4.d.ts +1 -1
  108. package/dist/schema/sync-layer4.js +9 -5
  109. package/dist/schema/task-status.d.ts +168 -0
  110. package/dist/schema/task-status.js +36 -0
  111. package/dist/schema/trust/index.js +1 -1
  112. package/dist/schemas/evaluation_operation.output.json +677 -0
  113. package/dist/schemas/evaluation_operation.schema.json +903 -0
  114. package/dist/schemas/index.json +25 -1
  115. package/dist/schemas/intent_radar.output.json +229 -0
  116. package/dist/schemas/intent_radar.schema.json +135 -0
  117. package/dist/schemas/messenger_operation.output.json +14 -0
  118. package/dist/schemas/messenger_operation.schema.json +18 -0
  119. package/dist/schemas/onchain_operations.schema.json +2 -2
  120. package/dist/schemas/onchain_operations_service.schema.json +2 -2
  121. package/dist/schemas/persona_operation.output.json +389 -0
  122. package/dist/schemas/persona_operation.schema.json +247 -0
  123. package/dist/schemas/query_task_status.output.json +115 -0
  124. package/dist/schemas/query_task_status.schema.json +24 -0
  125. package/dist/schemas/query_toolkit.output.json +1 -1
  126. package/dist/schemas/trust_score.schema.json +1 -1
  127. package/dist/tools/handlers/evaluation.d.ts +2 -0
  128. package/dist/tools/handlers/evaluation.js +123 -0
  129. package/dist/tools/handlers/intent-radar.d.ts +2 -0
  130. package/dist/tools/handlers/intent-radar.js +76 -0
  131. package/dist/tools/handlers/onchain.js +98 -0
  132. package/dist/tools/handlers/persona.d.ts +4 -0
  133. package/dist/tools/handlers/persona.js +89 -0
  134. package/dist/tools/handlers/task-status.d.ts +0 -168
  135. package/dist/tools/handlers/task-status.js +0 -29
  136. package/dist/tools/index.js +83 -7
  137. package/dist/tools/wip-deploy-assist.d.ts +1 -1
  138. package/dist/tools/wip-deploy-assist.js +33 -5
  139. package/package.json +2 -2
@@ -0,0 +1,33 @@
1
+ import type { IndustryScenario } from "../evaluation/capability.js";
2
+ import type { PersonaRole } from "../persona/types.js";
3
+ export type IntentTargetType = "NewOrderEvent" | "ProgressEvent" | "DemandPresentEvent" | "DemandFeedbackEvent" | "NewEntityEvent" | "ArbEvent";
4
+ export interface IntentRecord {
5
+ id: string;
6
+ intent: string;
7
+ account?: string;
8
+ role?: PersonaRole;
9
+ industries: IndustryScenario[];
10
+ keywords: string[];
11
+ target_types: IntentTargetType[];
12
+ created_at: number;
13
+ updated_at: number;
14
+ }
15
+ export interface IntentEventHit {
16
+ event_type: string;
17
+ event_id: string;
18
+ related_objects: string[];
19
+ business_meaning: string;
20
+ score: number;
21
+ matched_industries: string[];
22
+ matched_keywords: string[];
23
+ event: Record<string, unknown>;
24
+ }
25
+ export interface IntentMatchResult {
26
+ intent_id: string;
27
+ intent: string;
28
+ hits: IntentEventHit[];
29
+ scanned: number;
30
+ }
31
+ export declare const INTENT_VERSION = 1;
32
+ export declare const INTENT_MAX_PER_SCOPE = 50;
33
+ export declare const ALL_INTENT_TARGET_TYPES: IntentTargetType[];
@@ -0,0 +1,10 @@
1
+ export const INTENT_VERSION = 1;
2
+ export const INTENT_MAX_PER_SCOPE = 50;
3
+ export const ALL_INTENT_TARGET_TYPES = [
4
+ "NewOrderEvent",
5
+ "ProgressEvent",
6
+ "DemandPresentEvent",
7
+ "DemandFeedbackEvent",
8
+ "NewEntityEvent",
9
+ "ArbEvent",
10
+ ];
@@ -138,16 +138,6 @@ const R_AB_2_01 = {
138
138
  return null;
139
139
  },
140
140
  };
141
- const R_AB_2_02 = {
142
- id: "R-AB-2-02",
143
- category: "semantic",
144
- trigger: "usage_guard set but dispute without passport — E_NEED_PASSPORT",
145
- check: (ctx) => {
146
- if (ctx.dispute && ctx.current_voting_guard_addresses !== undefined) {
147
- }
148
- return null;
149
- },
150
- };
151
141
  const R_AB_2_03 = {
152
142
  id: "R-AB-2-03",
153
143
  category: "semantic",
@@ -382,7 +372,7 @@ const R_AB_5_02 = {
382
372
  };
383
373
  const ALL_RULES = [
384
374
  R_AB_1_01, R_AB_1_02, R_AB_1_03, R_AB_1_04,
385
- R_AB_2_01, R_AB_2_02, R_AB_2_03,
375
+ R_AB_2_01, R_AB_2_03,
386
376
  R_AB_3_01, R_AB_3_02, R_AB_3_03,
387
377
  R_AB_4_01, R_AB_4_02, R_AB_4_03,
388
378
  R_AB_5_01, R_AB_5_02,
@@ -0,0 +1,27 @@
1
+ export type ContactTemplateParamType = "string";
2
+ export interface ContactTemplateParam {
3
+ name: string;
4
+ type: ContactTemplateParamType;
5
+ description: string;
6
+ required: boolean;
7
+ }
8
+ export interface ContactTemplate {
9
+ id: string;
10
+ name: string;
11
+ description: string;
12
+ applicable_scenes: string[];
13
+ industry_tags: string[];
14
+ params: ContactTemplateParam[];
15
+ body: (params: Record<string, string>) => object;
16
+ notes?: string[];
17
+ }
18
+ export declare const CONTACT_TEMPLATES: ContactTemplate[];
19
+ export declare const CONTACT_TEMPLATES_VERSION = "1.0.0";
20
+ export declare function getContactTemplateById(id: string): ContactTemplate | undefined;
21
+ export declare function fillTemplate(templateId: string, params: Record<string, string>): {
22
+ ok: true;
23
+ body: object;
24
+ } | {
25
+ ok: false;
26
+ error: string;
27
+ };
@@ -0,0 +1,60 @@
1
+ export const CONTACT_TEMPLATES = [
2
+ {
3
+ id: "T-C-01",
4
+ name: "Basic contact",
5
+ description: "Named contact with a permission reference and description. Bind to a Service via `um`.",
6
+ applicable_scenes: ["contact_basic"],
7
+ industry_tags: ["universal"],
8
+ params: [
9
+ { name: "name", type: "string", description: "Contact object name", required: true },
10
+ { name: "permission", type: "string", description: "Permission object name/address", required: true },
11
+ { name: "description", type: "string", description: "Contact description shown to customers", required: true },
12
+ ],
13
+ body: (p) => ({
14
+ object: { name: p.name, permission: p.permission, replaceExistName: true },
15
+ description: p.description,
16
+ }),
17
+ notes: ["Bind this contact to a Service via the service call's 'um' field"],
18
+ },
19
+ {
20
+ id: "T-C-02",
21
+ name: "Support contact with IM",
22
+ description: "Contact with an initial IM entry pointing at a support account (after-sales / pre-order).",
23
+ applicable_scenes: ["contact_support"],
24
+ industry_tags: ["retail", "rental", "education", "travel", "freelance", "subscription"],
25
+ params: [
26
+ { name: "name", type: "string", description: "Contact object name", required: true },
27
+ { name: "permission", type: "string", description: "Permission object name/address", required: true },
28
+ { name: "description", type: "string", description: "Contact description shown to customers", required: true },
29
+ { name: "support_account", type: "string", description: "Support account name or 0x address for IM", required: true },
30
+ { name: "im_description", type: "string", description: "IM entry description (e.g. 'Primary support representative')", required: true },
31
+ ],
32
+ body: (p) => ({
33
+ object: { name: p.name, permission: p.permission, replaceExistName: true },
34
+ description: p.description,
35
+ ims: {
36
+ op: "add",
37
+ im: [{ at: p.support_account, description: p.im_description }],
38
+ },
39
+ }),
40
+ notes: [
41
+ "ims.im[].at accepts an account name or a full 0x address",
42
+ "ims is an op discriminated union — {op:'add'|'set'|'remove'|'clear'}",
43
+ ],
44
+ },
45
+ ];
46
+ export const CONTACT_TEMPLATES_VERSION = "1.0.0";
47
+ export function getContactTemplateById(id) {
48
+ return CONTACT_TEMPLATES.find((t) => t.id === id);
49
+ }
50
+ export function fillTemplate(templateId, params) {
51
+ const tpl = getContactTemplateById(templateId);
52
+ if (!tpl)
53
+ return { ok: false, error: `Template ${templateId} not found` };
54
+ for (const p of tpl.params) {
55
+ if (p.required && !(p.name in params)) {
56
+ return { ok: false, error: `Missing required param: ${p.name}` };
57
+ }
58
+ }
59
+ return { ok: true, body: tpl.body(params) };
60
+ }
@@ -94,9 +94,27 @@ function extractJsonBlocks(mdPath) {
94
94
  }
95
95
  const raw = blockLines.join('\n');
96
96
  try {
97
- const json = JSON.parse(raw);
98
- if (json && typeof json === 'object' && 'operation_type' in json) {
99
- blocks.push({ lineStart: i + 1, raw, json: json });
97
+ const parsed = JSON.parse(raw);
98
+ let json = null;
99
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
100
+ const p = parsed;
101
+ if (p.tool === 'onchain_operations' && p.data && typeof p.data === 'object'
102
+ && !Array.isArray(p.data)) {
103
+ const inner = p.data;
104
+ if (typeof inner.operation_type === 'string') {
105
+ json = {
106
+ operation_type: inner.operation_type,
107
+ data: inner.data,
108
+ ...(inner.env !== undefined ? { env: inner.env } : {}),
109
+ };
110
+ }
111
+ }
112
+ else if (typeof p.operation_type === 'string') {
113
+ json = p;
114
+ }
115
+ }
116
+ if (json && typeof json.operation_type === 'string') {
117
+ blocks.push({ lineStart: i + 1, raw, json });
100
118
  }
101
119
  }
102
120
  catch {
@@ -897,17 +897,21 @@ export async function annotateTableItemMonetaryFields(item, parentTokenType, net
897
897
  export async function annotateEventMonetaryFields(event, network) {
898
898
  if (!event || typeof event !== "object")
899
899
  return;
900
- if (event.type !== "NewOrderEvent")
900
+ const isNewOrder = event.type === "NewOrderEvent" ||
901
+ (typeof event.type === "string" && event.type.includes("::order::NewOrderEvent"));
902
+ if (!isNewOrder)
901
903
  return;
902
- const raw = event.amount;
904
+ const pj = event.parsedJson_raw ?? {};
905
+ const raw = event.amount ?? pj.amount;
903
906
  if (raw === null || raw === undefined)
904
907
  return;
905
908
  if (typeof raw !== "string" && typeof raw !== "number" && typeof raw !== "bigint")
906
909
  return;
907
910
  let tokenType;
908
- if (typeof event.service === "string" && event.service) {
911
+ const service = event.service ?? pj.service;
912
+ if (typeof service === "string" && service) {
909
913
  try {
910
- tokenType = (await resolveObjectTokenType(event.service, network))?.tokenType;
914
+ tokenType = (await resolveObjectTokenType(service, network))?.tokenType;
911
915
  }
912
916
  catch {
913
917
  }
@@ -1,50 +1,50 @@
1
1
  import { getIndustryProfile, listIndustries, registerIndustry, } from "./industry-registry.js";
2
2
  const TRAIT_INFERENCE_RULES = [
3
- { keywords: ["logistics", "shipping", "delivery", "express", "shipment", "delivery", "shipping", "logistics", "ship"],
3
+ { keywords: ["logistics", "shipping", "delivery", "express", "shipment", "ship"],
4
4
  trait: "has_logistics", value: true, weight: 0.85 },
5
- { keywords: ["digital", "online", "cloud", "online", "digital", "online", "cloud"],
5
+ { keywords: ["digital", "online", "cloud", "virtual"],
6
6
  trait: "has_logistics", value: false, weight: 0.7 },
7
- { keywords: ["consulting", "communication", "requirement-confirmation", "revision-rounds", "consult", "communication", "negotiate"],
7
+ { keywords: ["consulting", "communication", "requirement-confirmation", "revision-rounds", "negotiate", "consult"],
8
8
  trait: "communication_heavy", value: true, weight: 0.8 },
9
9
  { keywords: ["standard-product", "in-stock", "one-click-order", "standard", "instant"],
10
10
  trait: "communication_heavy", value: false, weight: 0.7 },
11
- { keywords: ["digital", "file", "code", "design-draft", "electronic", "online", "digital", "file", "online"],
11
+ { keywords: ["digital", "file", "code", "design-draft", "electronic", "online", "software", "source"],
12
12
  trait: "pure_digital", value: true, weight: 0.8 },
13
- { keywords: ["physical", "hardware", "equipment", "physical", "hardware", "equipment"],
13
+ { keywords: ["physical", "hardware", "equipment"],
14
14
  trait: "pure_digital", value: false, weight: 0.75 },
15
- { keywords: ["course", "semester", "long-cycle", "long-term", "project-based", "course", "semester", "long-term", "project"],
15
+ { keywords: ["course", "semester", "long-cycle", "long-term", "project-based", "project"],
16
16
  trait: "long_cycle", value: true, weight: 0.75 },
17
- { keywords: ["instant", "in-stock", "same-day", "instant", "same-day", "immediate"],
17
+ { keywords: ["instant", "in-stock", "same-day", "immediate"],
18
18
  trait: "long_cycle", value: false, weight: 0.8 },
19
- { keywords: ["rental", "rent", "deposit", "rental", "rent", "deposit", "lease"],
19
+ { keywords: ["rental", "rent", "deposit", "lease"],
20
20
  trait: "deposit_required", value: true, weight: 0.9 },
21
- { keywords: ["purchase", "buyout", "purchase", "buy"],
21
+ { keywords: ["purchase", "buyout", "buy"],
22
22
  trait: "deposit_required", value: false, weight: 0.6 },
23
- { keywords: ["multi-party", "segmented", "multi-stage", "multi-vendor", "itinerary", "multi-party", "segment", "multi-vendor"],
23
+ { keywords: ["multi-party", "segmented", "multi-stage", "multi-vendor", "itinerary", "segment"],
24
24
  trait: "multi_tier_allocation", value: true, weight: 0.75 },
25
- { keywords: ["medical", "legal", "financial", "insurance", "pharmaceutical", "medical", "legal", "finance", "insurance", "pharma"],
25
+ { keywords: ["medical", "legal", "financial", "insurance", "pharmaceutical", "pharma"],
26
26
  trait: "regulatory_intensity", value: "high", weight: 0.9 },
27
- { keywords: ["education", "food", "construction", "education", "food", "construction"],
27
+ { keywords: ["education", "food", "construction"],
28
28
  trait: "regulatory_intensity", value: "medium", weight: 0.7 },
29
- { keywords: ["entertainment", "gaming", "digital", "entertainment", "game", "digital"],
29
+ { keywords: ["entertainment", "gaming", "digital", "game"],
30
30
  trait: "regulatory_intensity", value: "low", weight: 0.6 },
31
- { keywords: ["custom", "high-value", "customized", "custom", "high-value", "bespoke"],
31
+ { keywords: ["custom", "high-value", "customized", "bespoke"],
32
32
  trait: "trust_sensitivity", value: "high", weight: 0.8 },
33
33
  { keywords: ["standard-product", "small-ticket", "standard", "low-value"],
34
34
  trait: "trust_sensitivity", value: "low", weight: 0.7 },
35
- { keywords: ["subscription", "membership", "recurring", "subscription", "membership", "recurring"],
35
+ { keywords: ["subscription", "membership", "recurring"],
36
36
  trait: "consumption_frequency", value: "frequent", weight: 0.85 },
37
- { keywords: ["course", "semester", "education", "course", "education"],
37
+ { keywords: ["course", "semester", "education"],
38
38
  trait: "consumption_frequency", value: "one_time", weight: 0.75 },
39
- { keywords: ["daily", "frequent", "common", "daily", "frequent"],
39
+ { keywords: ["daily", "frequent", "common"],
40
40
  trait: "consumption_frequency", value: "frequent", weight: 0.75 },
41
- { keywords: ["small-ticket", "daily", "convenience-store", "micro", "small-ticket"],
41
+ { keywords: ["small-ticket", "daily", "convenience-store", "micro"],
42
42
  trait: "avg_ticket_size", value: "micro", weight: 0.7 },
43
- { keywords: ["retail", "commodity", "standard-product", "retail", "commodity"],
43
+ { keywords: ["retail", "commodity", "standard-product"],
44
44
  trait: "avg_ticket_size", value: "small", weight: 0.7 },
45
- { keywords: ["custom", "project", "outsourcing", "custom", "project"],
45
+ { keywords: ["custom", "project", "outsourcing"],
46
46
  trait: "avg_ticket_size", value: "medium", weight: 0.7 },
47
- { keywords: ["real-estate", "automobile", "high-value", "luxury", "realestate", "luxury", "car"],
47
+ { keywords: ["real-estate", "automobile", "high-value", "luxury", "realestate", "car"],
48
48
  trait: "avg_ticket_size", value: "large", weight: 0.85 },
49
49
  ];
50
50
  export const DEFAULT_TRAITS = {
@@ -133,7 +133,6 @@ export const MACHINE_RISK_RULES = [
133
133
  "to the Service. Disputes are then filed via arbitration::dispute(order, " +
134
134
  "arbitration) — completely independent of the machine workflow.",
135
135
  auto_fixable: false,
136
- related_constraint: "dispute_independence_principle",
137
136
  },
138
137
  {
139
138
  id: "R-M2-01",
@@ -10,7 +10,7 @@ export interface ToolDescriptor {
10
10
  input_schema_export: string;
11
11
  output_schema_export: string | null;
12
12
  }
13
- export declare const TOOLS_17: readonly ToolDescriptor[];
13
+ export declare const ALL_TOOLS: readonly ToolDescriptor[];
14
14
  export type FindingSeverity = 'critical' | 'high' | 'medium' | 'low' | 'info';
15
15
  export type FindingCategory = 'layer_census' | 'stub_inconsistency' | 'layer_parity' | 'any_unknown' | 'handler_types' | 'output_coverage' | 'generation_sync' | 'reflection';
16
16
  export interface Finding {
@@ -7,7 +7,7 @@ export const MCP_SRC_TOOLS_DIR = 'd:\\wowok\\agent\\mcp\\src\\tools';
7
7
  export const GENERATION_SCRIPT = 'd:\\wowok\\agent\\mcp\\scripts\\generate-json-schemas.ts';
8
8
  export const TOOLS_INDEX_FILE = 'd:\\wowok\\agent\\mcp\\src\\tools\\index.ts';
9
9
  export const MCP_SCHEMA_AUDIT_VERSION = '1.0.0';
10
- export const TOOLS_17 = [
10
+ export const ALL_TOOLS = [
11
11
  { name: 'onchain_operations', input_schema_export: 'OnchainOperationsSchema', output_schema_export: 'CallOutputSchema' },
12
12
  { name: 'account_operation', input_schema_export: 'AccountOperationSchema', output_schema_export: 'AccountOperationOutputWrappedSchema' },
13
13
  { name: 'local_mark_operation', input_schema_export: 'LocalMarkOperationSchema', output_schema_export: 'LocalMarkOperationOutputWrappedSchema' },
@@ -25,6 +25,10 @@ export const TOOLS_17 = [
25
25
  { name: 'project_operation', input_schema_export: 'ProjectOperationInputSchema', output_schema_export: 'ProjectOperationOutputSchema' },
26
26
  { name: 'config_operation', input_schema_export: 'ConfigOperationInputSchema', output_schema_export: 'ConfigOperationOutputSchema' },
27
27
  { name: 'trust_score', input_schema_export: 'TrustScoreInputSchema', output_schema_export: 'TrustScoreOutputSchema' },
28
+ { name: 'query_task_status', input_schema_export: 'QueryTaskStatusInputSchema', output_schema_export: 'QueryTaskStatusOutputSchema' },
29
+ { name: 'evaluation_operation', input_schema_export: 'EvaluationOperationInputSchema', output_schema_export: 'EvaluationOperationOutputSchema' },
30
+ { name: 'persona_operation', input_schema_export: 'PersonaOperationInputSchema', output_schema_export: 'PersonaOperationOutputSchema' },
31
+ { name: 'intent_radar', input_schema_export: 'IntentRadarInputSchema', output_schema_export: 'IntentRadarOutputSchema' },
28
32
  ];
29
33
  export function loadLayer4Deployed(toolName) {
30
34
  const filePath = path.join(DEPLOYED_TOOLS_DIR, `${toolName}.json`);
@@ -98,7 +102,7 @@ export function loadLayer3Generated(toolName) {
98
102
  }
99
103
  export function analyzeLayerCensus() {
100
104
  const census = [];
101
- for (const tool of TOOLS_17) {
105
+ for (const tool of ALL_TOOLS) {
102
106
  census.push({
103
107
  name: tool.name,
104
108
  layer2_zod: {
@@ -524,11 +528,11 @@ export function analyzeGenerationScriptSync() {
524
528
  const scriptNames = new Set();
525
529
  let m;
526
530
  while ((m = nameRegex.exec(src)) !== null) {
527
- if (TOOLS_17.some(t => t.name === m[1])) {
531
+ if (ALL_TOOLS.some(t => t.name === m[1])) {
528
532
  scriptNames.add(m[1]);
529
533
  }
530
534
  }
531
- for (const tool of TOOLS_17) {
535
+ for (const tool of ALL_TOOLS) {
532
536
  if (!scriptNames.has(tool.name)) {
533
537
  findings.push({
534
538
  rule_id: 'MCP-GENSYNC-002',
@@ -115,9 +115,45 @@ const R_S_1_04 = {
115
115
  const R_S_1_05 = {
116
116
  id: "R-S-1-05",
117
117
  category: "structural",
118
- trigger: "Permission index not in Service range (300-320) used on Service object",
118
+ trigger: "sale.wip is a local path / localhost / LAN URL (not network-deployable) — every customer order fails",
119
119
  check: (ctx) => {
120
- if (ctx.target_objects_types?.includes("Service")) {
120
+ if (ctx.sales && (ctx.sales.op === "add" || ctx.sales.op === "set")) {
121
+ for (const s of ctx.sales.sales) {
122
+ if (s.wip && s.wip !== "") {
123
+ let localType = null;
124
+ const w = s.wip;
125
+ if (/^[A-Za-z]:[\\/]/.test(w) || w.startsWith("/") || w.startsWith("./") || w.startsWith("../")) {
126
+ localType = "local filesystem path";
127
+ }
128
+ else if (/^https?:\/\/(localhost|127\.0\.0\.1|\[::1\]|0\.0\.0\.0)([:/]|$)/i.test(w)) {
129
+ localType = "localhost/loopback URL";
130
+ }
131
+ else if (/^https?:\/\/(10\.\d{1,3}\.\d{1,3}\.\d{1,3}|172\.(1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}|192\.168\.\d{1,3}\.\d{1,3})([:/]|$)/i.test(w)) {
132
+ localType = "LAN (private IP) URL";
133
+ }
134
+ else if (!/^https?:\/\//i.test(w) && !w.startsWith("ipfs://") && !w.startsWith("data:")) {
135
+ localType = "unrecognized format (not a network URL)";
136
+ }
137
+ if (localType) {
138
+ return {
139
+ id: "R-S-1-05",
140
+ level: "CRITICAL",
141
+ category: "structural",
142
+ title: "WIP is not network-deployed — every customer order will fail",
143
+ description: `Sale "${s.name}" wip "${s.wip}" is a ${localType}. It passes set-time verification ` +
144
+ `on the merchant's own machine but is unreachable by customers on other machines — ` +
145
+ `order_new aborts 100% when a customer tries to buy.`,
146
+ affected_stakeholders: ["owner", "customer"],
147
+ scenario: "Merchant sets wip to a local file path / localhost / LAN URL and publishes the Service; " +
148
+ "the on-chain wip points at the merchant's machine; customers cannot fetch it.",
149
+ mitigation: "Deploy the .wip file to a public host (GitHub Pages, IPFS, or your own website) and set " +
150
+ "sale.wip to the public URL. Or leave sale.wip empty (\"\") to skip WIP verification " +
151
+ "(TESTING ONLY — not recommended for production).",
152
+ evidence: `sale=${s.name}, wip=${s.wip}`,
153
+ };
154
+ }
155
+ }
156
+ }
121
157
  }
122
158
  return null;
123
159
  },
@@ -9,7 +9,7 @@ export const SERVICE_TEMPLATES = [
9
9
  { name: "owner_address", type: "address", description: "Service owner address (receives payments)", required: true },
10
10
  { name: "permission_address", type: "address", description: "Permission object address (must be owned by owner)", required: true },
11
11
  { name: "description", type: "string", description: "Shop description", required: true },
12
- { name: "location", type: "string", description: "Shop URL (HTTPS or IPFS)", required: false, default: "" },
12
+ { name: "location", type: "string", description: "Service geographic location (city/region)", required: false, default: "" },
13
13
  { name: "sales_items", type: "object", description: "Array of {name, price, stock, wip, wip_hash}", required: true },
14
14
  { name: "buy_guard_address", type: "address", description: "Buyer eligibility Guard (null for public sale)", required: false, default: "" },
15
15
  ],
@@ -23,7 +23,7 @@ export const SEMANTIC_TO_SCHEMA_RULES = [
23
23
  example_json: {
24
24
  object: "0xSERVICE_ADDRESS",
25
25
  description: "Updated description",
26
- location: "https://shop.example.com",
26
+ location: "Shanghai",
27
27
  customer_required: ["name", "phone"],
28
28
  },
29
29
  reverse_explanation: "These fields are always mutable. customer_required is a string[] of field names buyers must provide at order time.",
@@ -241,7 +241,7 @@ export const SCHEMA_TO_SEMANTIC_RULES = [
241
241
  {
242
242
  element_type: "field",
243
243
  type_name: "location",
244
- semantic_explanation: "Service URL/location (e.g. shop URL). Mutable. Index 303 (SERVICE_LOCATION).",
244
+ semantic_explanation: "Geographic location of the service (city/region). Mutable. Index 303 (SERVICE_LOCATION).",
245
245
  },
246
246
  {
247
247
  element_type: "field",
@@ -1,5 +1,5 @@
1
1
  export declare const TEMPLATE_REGISTRY_VERSION = 1;
2
- export type TemplateObjectType = "guard" | "machine" | "service" | "order" | "progress" | "arbitration" | "treasury" | "permission" | "passport" | "allocation" | "reward";
2
+ export type TemplateObjectType = "guard" | "machine" | "service" | "order" | "progress" | "arbitration" | "treasury" | "permission" | "passport" | "allocation" | "reward" | "contact";
3
3
  export declare const TEMPLATE_OBJECT_TYPES: readonly TemplateObjectType[];
4
4
  export type UnifiedTemplateParamDefault = string | number | boolean | object | string[];
5
5
  export interface UnifiedTemplateParam {
@@ -8,6 +8,7 @@ import { TREASURY_TEMPLATES, fillTemplate as fillTreasuryTemplate, } from "./tre
8
8
  import { PERMISSION_TEMPLATES, fillTemplate as fillPermissionTemplate, } from "./permission-templates.js";
9
9
  import { PASSPORT_TEMPLATES, fillTemplate as fillPassportTemplate, } from "./passport-templates.js";
10
10
  import { ALLOCATION_TEMPLATES, fillTemplate as fillAllocationTemplate, } from "./allocation-templates.js";
11
+ import { CONTACT_TEMPLATES, fillTemplate as fillContactTemplate, } from "./contact-templates.js";
11
12
  import { REWARD_TEMPLATES, } from "./reward-templates.js";
12
13
  export const TEMPLATE_REGISTRY_VERSION = 1;
13
14
  export const TEMPLATE_OBJECT_TYPES = [
@@ -22,6 +23,7 @@ export const TEMPLATE_OBJECT_TYPES = [
22
23
  "passport",
23
24
  "allocation",
24
25
  "reward",
26
+ "contact",
25
27
  ];
26
28
  function normalizeParam(p) {
27
29
  return {
@@ -168,6 +170,13 @@ function buildRegistry() {
168
170
  },
169
171
  });
170
172
  }
173
+ for (const t of CONTACT_TEMPLATES) {
174
+ add({
175
+ meta: bodyMeta(t, "contact", t.applicable_scenes, t.industry_tags),
176
+ raw: t,
177
+ notes: t.notes,
178
+ });
179
+ }
171
180
  ID_COLLISIONS = collisions;
172
181
  return map;
173
182
  }
@@ -292,7 +301,8 @@ export function instantiateTemplate(templateId, params) {
292
301
  case "permission":
293
302
  case "passport":
294
303
  case "allocation":
295
- case "progress": {
304
+ case "progress":
305
+ case "contact": {
296
306
  const r = fillBodyTemplate(objectType, templateId, params);
297
307
  if (!r.ok) {
298
308
  return {
@@ -335,6 +345,8 @@ function fillBodyTemplate(objectType, templateId, params) {
335
345
  return fillAllocationTemplate(templateId, params);
336
346
  case "progress":
337
347
  return fillProgressTemplate(templateId, params);
348
+ case "contact":
349
+ return fillContactTemplate(templateId, params);
338
350
  default:
339
351
  return { ok: false, error: `No body-template fill for '${objectType}'` };
340
352
  }
@@ -127,6 +127,29 @@ export const TOOLS_REFERENCE = [
127
127
  summary: "Service trust & risk assessment — 5 trust dimensions + 4 risk dimensions.",
128
128
  notes: ["Use when user asks 'is this service trustworthy?' or 'should I buy?'."],
129
129
  },
130
+ {
131
+ name: "query_task_status",
132
+ summary: "Query async task status (build_graph / evaluate_project with async_mode).",
133
+ notes: ["Read-only; tasks are ephemeral (retained 5 min after completion)."],
134
+ },
135
+ {
136
+ name: "evaluation_operation",
137
+ summary: "Pluggable business evaluations — risk / match / compose / game with user injection.",
138
+ actions: ["service_risk", "demand_match", "service_match", "capability_gap", "compose_service", "node_game", "arb_game"],
139
+ notes: ["Read-only; the role decides and acts via onchain_operations."],
140
+ },
141
+ {
142
+ name: "persona_operation",
143
+ summary: "User identity setting (persona) — preferences, strategy, rules, spec; long-term + current layers.",
144
+ actions: ["get", "list", "set", "analyze", "apply", "remove"],
145
+ notes: ["Read/write local state; account persona overrides system; current overrides long-term."],
146
+ },
147
+ {
148
+ name: "intent_radar",
149
+ summary: "User business intent × chain event matching — persist intents, score events against them.",
150
+ actions: ["save", "list", "remove", "match"],
151
+ notes: ["Read-only w.r.t. chain; industry/keywords resolved once at save; events supplied or auto-pulled."],
152
+ },
130
153
  ];
131
154
  export function getToolReference(name) {
132
155
  return TOOLS_REFERENCE.find((t) => t.name === name);
@@ -0,0 +1,16 @@
1
+ import type { Industry, PersonaRole } from "./types.js";
2
+ export interface PersonaAnalysisSuggestion {
3
+ field: string;
4
+ value: unknown;
5
+ reason: string;
6
+ }
7
+ export interface PersonaAnalysis {
8
+ role?: PersonaRole;
9
+ industries: Industry[];
10
+ preferences: Record<string, unknown>;
11
+ requirements: string[];
12
+ rules: string[];
13
+ suggestions: PersonaAnalysisSuggestion[];
14
+ confidence: number;
15
+ }
16
+ export declare function analyzePersonaContext(context: string): PersonaAnalysis;
@@ -0,0 +1,66 @@
1
+ const INDUSTRY_KEYWORDS = {
2
+ freelance: ["freelance", "upwork"],
3
+ rental: ["rental", "airbnb"],
4
+ education: ["education", "coursera"],
5
+ travel: ["travel", "booking"],
6
+ subscription: ["subscription", "patreon"],
7
+ retail: ["retail", "amazon"],
8
+ };
9
+ const ROLE_KEYWORDS = {
10
+ merchant: ["merchant", "seller", "provider"],
11
+ user: ["user", "buyer", "customer"],
12
+ arbitrator: ["arbitrator"],
13
+ };
14
+ const RISK_KEYWORDS = {
15
+ conservative: ["conservative"],
16
+ aggressive: ["aggressive"],
17
+ };
18
+ export function analyzePersonaContext(context) {
19
+ const lower = context.toLowerCase();
20
+ const analysis = {
21
+ industries: [],
22
+ preferences: {},
23
+ requirements: [],
24
+ rules: [],
25
+ suggestions: [],
26
+ confidence: 0,
27
+ };
28
+ for (const [role, kws] of Object.entries(ROLE_KEYWORDS)) {
29
+ if (kws.some((k) => lower.includes(k))) {
30
+ analysis.role = role;
31
+ analysis.suggestions.push({ field: "role", value: role, reason: "role keyword matched" });
32
+ break;
33
+ }
34
+ }
35
+ for (const [ind, kws] of Object.entries(INDUSTRY_KEYWORDS)) {
36
+ if (kws.some((k) => lower.includes(k))) {
37
+ analysis.industries.push(ind);
38
+ analysis.suggestions.push({ field: "industries", value: ind, reason: "industry keyword matched" });
39
+ }
40
+ }
41
+ if (RISK_KEYWORDS.conservative.some((k) => lower.includes(k))) {
42
+ analysis.preferences.risk_appetite = "conservative";
43
+ analysis.suggestions.push({ field: "preferences.risk_appetite", value: "conservative", reason: "conservative keyword" });
44
+ }
45
+ else if (RISK_KEYWORDS.aggressive.some((k) => lower.includes(k))) {
46
+ analysis.preferences.risk_appetite = "aggressive";
47
+ analysis.suggestions.push({ field: "preferences.risk_appetite", value: "aggressive", reason: "aggressive keyword" });
48
+ }
49
+ const reqKeywords = ["must", "forbid", "never", "require"];
50
+ const ruleKeywords = ["learned", "avoid"];
51
+ for (const raw of context.split(/[;.\n]/)) {
52
+ const s = raw.trim();
53
+ if (!s)
54
+ continue;
55
+ if (reqKeywords.some((k) => s.toLowerCase().includes(k.toLowerCase()))) {
56
+ analysis.requirements.push(s);
57
+ analysis.suggestions.push({ field: "requirements", value: s, reason: "red-line keyword" });
58
+ }
59
+ else if (ruleKeywords.some((k) => s.toLowerCase().includes(k.toLowerCase()))) {
60
+ analysis.rules.push(s);
61
+ analysis.suggestions.push({ field: "rules", value: s, reason: "experience keyword" });
62
+ }
63
+ }
64
+ analysis.confidence = Math.min(1, analysis.suggestions.length * 0.2);
65
+ return analysis;
66
+ }
@@ -0,0 +1,5 @@
1
+ import type { UserInjection } from "../evaluation/types.js";
2
+ import type { EffectivePersona } from "./types.js";
3
+ export declare function personaToInjection(effective: EffectivePersona): UserInjection;
4
+ export declare function personaToContextText(effective: EffectivePersona): string;
5
+ export declare function mergeInjections(base?: UserInjection | null, override?: UserInjection | null): UserInjection | undefined;