@wowok/agent-mcp 2.6.0 → 2.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/README.md +5 -3
  2. package/dist/customer/info-puzzle.d.ts +1 -1
  3. package/dist/customer/info-puzzle.js +4 -2
  4. package/dist/customer/risk-assessment.js +26 -4
  5. package/dist/customer/types.d.ts +2 -0
  6. package/dist/examples/guard-template-balance-check.json +38 -0
  7. package/dist/examples/guard-template-time-lock.json +39 -0
  8. package/dist/examples/machine-template-7node-rental.json +114 -0
  9. package/dist/examples/rental-ziroom-machine-create.json +137 -0
  10. package/dist/examples/rental-ziroom-permission-create.json +35 -0
  11. package/dist/examples/rental-ziroom-service-create.json +80 -0
  12. package/dist/examples/retail-myshop-service-create.json +88 -0
  13. package/dist/extensions/capability-manifest.d.ts +125 -0
  14. package/dist/extensions/capability-manifest.js +594 -0
  15. package/dist/extensions/constraint-registry.d.ts +24 -0
  16. package/dist/extensions/constraint-registry.js +196 -0
  17. package/dist/extensions/index.d.ts +12 -0
  18. package/dist/extensions/index.js +6 -0
  19. package/dist/extensions/metric-registry.d.ts +26 -0
  20. package/dist/extensions/metric-registry.js +257 -0
  21. package/dist/extensions/mode-evaluator.d.ts +15 -0
  22. package/dist/extensions/mode-evaluator.js +170 -0
  23. package/dist/extensions/modes.d.ts +2 -0
  24. package/dist/extensions/modes.js +493 -0
  25. package/dist/extensions/registry.d.ts +50 -0
  26. package/dist/extensions/registry.js +662 -0
  27. package/dist/extensions/types.d.ts +219 -0
  28. package/dist/extensions/types.js +1 -0
  29. package/dist/index.js +50 -0
  30. package/dist/knowledge/deployment-scanner.d.ts +3 -0
  31. package/dist/knowledge/deployment-scanner.js +64 -3
  32. package/dist/knowledge/fund-layer.d.ts +72 -0
  33. package/dist/knowledge/fund-layer.js +420 -0
  34. package/dist/knowledge/guard-render.d.ts +57 -0
  35. package/dist/knowledge/guard-render.js +700 -0
  36. package/dist/knowledge/guard-risk.d.ts +13 -0
  37. package/dist/knowledge/guard-risk.js +57 -0
  38. package/dist/knowledge/guard-submission-prompt.d.ts +31 -0
  39. package/dist/knowledge/guard-submission-prompt.js +171 -0
  40. package/dist/knowledge/guard-templates.js +278 -0
  41. package/dist/knowledge/machine-ledger.js +1 -1
  42. package/dist/knowledge/machine-render.d.ts +41 -0
  43. package/dist/knowledge/machine-render.js +565 -0
  44. package/dist/knowledge/machine-templates.js +24 -5
  45. package/dist/knowledge/reward-confirm.js +2 -2
  46. package/dist/knowledge/reward-puzzle.js +1 -1
  47. package/dist/knowledge/reward-risk.js +9 -9
  48. package/dist/knowledge/reward-templates.js +2 -2
  49. package/dist/knowledge/service-confirm.d.ts +15 -6
  50. package/dist/knowledge/service-confirm.js +119 -11
  51. package/dist/knowledge/service-context.js +1 -1
  52. package/dist/knowledge/service-ledger.js +1 -1
  53. package/dist/knowledge/service-risk.d.ts +1 -1
  54. package/dist/knowledge/service-risk.js +3 -3
  55. package/dist/knowledge/service-templates.js +2 -2
  56. package/dist/knowledge/service-translation.d.ts +1 -1
  57. package/dist/knowledge/service-translation.js +7 -7
  58. package/dist/knowledge/tool-constraints.js +6 -2
  59. package/dist/project/deployment-bridge.d.ts +1 -1
  60. package/dist/project/deployment-bridge.js +31 -7
  61. package/dist/project/deployment-doc.d.ts +3 -0
  62. package/dist/project/deployment-doc.js +76 -14
  63. package/dist/project/edit-planner.d.ts +123 -0
  64. package/dist/project/edit-planner.js +1371 -0
  65. package/dist/project/evaluation.d.ts +2 -0
  66. package/dist/project/evaluation.js +873 -88
  67. package/dist/project/graph-builder.d.ts +4 -1
  68. package/dist/project/graph-builder.js +132 -62
  69. package/dist/project/graph.d.ts +1 -0
  70. package/dist/project/handlers.d.ts +317 -6
  71. package/dist/project/handlers.js +1171 -19
  72. package/dist/project/stage-gate.d.ts +4 -0
  73. package/dist/project/stage-gate.js +64 -5
  74. package/dist/project/task-tracker.d.ts +26 -0
  75. package/dist/project/task-tracker.js +78 -0
  76. package/dist/safety/preview.js +16 -0
  77. package/dist/schema/call/allocation.d.ts +16 -16
  78. package/dist/schema/call/allocation.js +2 -2
  79. package/dist/schema/call/arbitration.js +19 -6
  80. package/dist/schema/call/base.d.ts +21 -13
  81. package/dist/schema/call/base.js +27 -6
  82. package/dist/schema/call/bridge.d.ts +5 -5
  83. package/dist/schema/call/bridge.js +3 -1
  84. package/dist/schema/call/contact.js +2 -2
  85. package/dist/schema/call/demand.d.ts +23 -31
  86. package/dist/schema/call/demand.js +2 -2
  87. package/dist/schema/call/guard.js +2 -2
  88. package/dist/schema/call/machine.d.ts +1976 -752
  89. package/dist/schema/call/machine.js +50 -4
  90. package/dist/schema/call/order.d.ts +149 -228
  91. package/dist/schema/call/order.js +4 -3
  92. package/dist/schema/call/payment.d.ts +183 -3
  93. package/dist/schema/call/payment.js +21 -3
  94. package/dist/schema/call/permission.js +2 -2
  95. package/dist/schema/call/personal.d.ts +241 -52
  96. package/dist/schema/call/progress.d.ts +53 -61
  97. package/dist/schema/call/progress.js +18 -4
  98. package/dist/schema/call/repository.d.ts +23 -31
  99. package/dist/schema/call/repository.js +2 -2
  100. package/dist/schema/call/reward.js +3 -3
  101. package/dist/schema/call/semantic.d.ts +1 -1
  102. package/dist/schema/call/semantic.js +37 -2
  103. package/dist/schema/call/service.d.ts +275 -127
  104. package/dist/schema/call/service.js +89 -13
  105. package/dist/schema/call/treasury.js +3 -3
  106. package/dist/schema/common/index.d.ts +13 -2
  107. package/dist/schema/common/index.js +80 -15
  108. package/dist/schema/local/index.d.ts +32 -35
  109. package/dist/schema/local/index.js +28 -6
  110. package/dist/schema/messenger/index.d.ts +274 -46
  111. package/dist/schema/operations.d.ts +1264 -544
  112. package/dist/schema/operations.js +65 -7
  113. package/dist/schema/project/index.d.ts +2846 -167
  114. package/dist/schema/project/index.js +570 -16
  115. package/dist/schema/query/index.d.ts +922 -349
  116. package/dist/schema/query/index.js +205 -42
  117. package/dist/schema/schema-query/index.d.ts +65 -3
  118. package/dist/schema/schema-query/index.js +38 -5
  119. package/dist/schema/utils/node-parser.js +20 -4
  120. package/dist/schema/utils/object-type-utils.d.ts +12 -0
  121. package/dist/schema/utils/object-type-utils.js +35 -0
  122. package/dist/schema/utils/permission-machine-check.d.ts +49 -0
  123. package/dist/schema/utils/permission-machine-check.js +121 -0
  124. package/dist/schema/utils/skills-recommendation.d.ts +2 -0
  125. package/dist/schema/utils/skills-recommendation.js +76 -0
  126. package/dist/schema-query/index.d.ts +20 -1
  127. package/dist/schema-query/index.js +306 -4
  128. package/dist/schemas/account_operation.output.json +7 -1
  129. package/dist/schemas/account_operation.schema.json +3 -3
  130. package/dist/schemas/bridge_operation.output.json +6 -0
  131. package/dist/schemas/bridge_operation.schema.json +1 -1
  132. package/dist/schemas/guard-templates.json +379 -0
  133. package/dist/schemas/guard2file.schema.json +1 -1
  134. package/dist/schemas/index.json +1 -1
  135. package/dist/schemas/local_info_operation.output.json +6 -0
  136. package/dist/schemas/local_mark_operation.output.json +7 -1
  137. package/dist/schemas/local_mark_operation.schema.json +1 -1
  138. package/dist/schemas/machineNode2file.schema.json +1 -1
  139. package/dist/schemas/messenger_operation.schema.json +4 -4
  140. package/dist/schemas/onchain_events.output.json +1 -1
  141. package/dist/schemas/onchain_operations.output.json +2820 -0
  142. package/dist/schemas/onchain_operations.schema.json +444 -330
  143. package/dist/schemas/onchain_operations_allocation.schema.json +37 -28
  144. package/dist/schemas/onchain_operations_arbitration.schema.json +16 -14
  145. package/dist/schemas/onchain_operations_contact.schema.json +10 -10
  146. package/dist/schemas/onchain_operations_demand.schema.json +10 -10
  147. package/dist/schemas/onchain_operations_gen_passport.schema.json +16 -16
  148. package/dist/schemas/onchain_operations_gen_proof.schema.json +2 -2
  149. package/dist/schemas/onchain_operations_guard.schema.json +2 -2
  150. package/dist/schemas/onchain_operations_machine.schema.json +43 -35
  151. package/dist/schemas/onchain_operations_order.schema.json +72 -78
  152. package/dist/schemas/onchain_operations_payment.schema.json +141 -111
  153. package/dist/schemas/onchain_operations_permission.schema.json +3 -3
  154. package/dist/schemas/onchain_operations_personal.schema.json +7 -7
  155. package/dist/schemas/onchain_operations_progress.schema.json +9 -9
  156. package/dist/schemas/onchain_operations_proof.schema.json +8 -8
  157. package/dist/schemas/onchain_operations_repository.schema.json +10 -10
  158. package/dist/schemas/onchain_operations_reward.schema.json +14 -14
  159. package/dist/schemas/onchain_operations_service.schema.json +119 -48
  160. package/dist/schemas/onchain_operations_treasury.schema.json +11 -11
  161. package/dist/schemas/onchain_table_data.output.json +33 -25
  162. package/dist/schemas/onchain_table_data.schema.json +22 -21
  163. package/dist/schemas/project_operation.output.json +2194 -23
  164. package/dist/schemas/project_operation.schema.json +84 -6
  165. package/dist/schemas/query_toolkit.output.json +108 -80
  166. package/dist/schemas/query_toolkit.schema.json +12 -12
  167. package/dist/schemas/schema_query.output.json +70 -3
  168. package/dist/schemas/schema_query.schema.json +18 -3
  169. package/dist/schemas/wowok_buildin_info.output.json +81 -8
  170. package/dist/schemas/wowok_buildin_info.schema.json +46 -2
  171. package/dist/tools/handlers/local.js +20 -5
  172. package/dist/tools/handlers/onchain.js +594 -6
  173. package/dist/tools/handlers/project.js +76 -4
  174. package/dist/tools/handlers/query.js +27 -0
  175. package/dist/tools/handlers/schema-query.js +43 -1
  176. package/dist/tools/handlers/task-status.d.ts +170 -0
  177. package/dist/tools/handlers/task-status.js +55 -0
  178. package/dist/tools/handlers/wip.js +47 -1
  179. package/dist/tools/index.d.ts +8 -0
  180. package/dist/tools/index.js +387 -12
  181. package/dist/tools/retry.d.ts +8 -0
  182. package/dist/tools/retry.js +85 -0
  183. package/dist/tools/wip-deploy-assist.d.ts +28 -0
  184. package/dist/tools/wip-deploy-assist.js +278 -0
  185. package/package.json +2 -2
  186. package/dist/schemas/guard-node-examples.md +0 -199
@@ -0,0 +1,219 @@
1
+ import type { ProjectObjectType } from "../project/namespace.js";
2
+ import type { IndustryTraits, IndustrySource } from "../knowledge/industry-registry.js";
3
+ import type { AcquisitionFlywheel } from "../knowledge/acquisition-flywheel.js";
4
+ import type { IndustryRiskCheck, IndustryNeed } from "../customer/industry-risks.js";
5
+ import type { ModeMachineNode, ModeGuardRef, ModeAllocatorStrategy } from "../knowledge/scenario-modes.js";
6
+ export type { ProjectObjectType, IndustryTraits, IndustrySource, AcquisitionFlywheel, IndustryRiskCheck, IndustryNeed, ModeMachineNode, ModeGuardRef, ModeAllocatorStrategy, };
7
+ export interface ProjectContext {
8
+ project_id?: string;
9
+ prefix: string;
10
+ network: "testnet" | "mainnet" | "both";
11
+ business_intent?: string;
12
+ version?: string;
13
+ testnet_test_passed?: boolean;
14
+ industry?: string;
15
+ }
16
+ export interface Blueprint {
17
+ context: ProjectContext;
18
+ objects: BlueprintObject[];
19
+ edges: BlueprintEdge[];
20
+ steps: BlueprintStep[];
21
+ scenarios?: BlueprintScenario[];
22
+ industry_source: string;
23
+ applied_template: string;
24
+ validation?: {
25
+ errors: string[];
26
+ warnings: string[];
27
+ };
28
+ }
29
+ export interface BlueprintObject {
30
+ entry_id: string;
31
+ object_type: ProjectObjectType;
32
+ name: string;
33
+ config: Record<string, unknown>;
34
+ publish_required: boolean;
35
+ status: "draft" | "deployed";
36
+ description?: string;
37
+ }
38
+ export interface BlueprintEdge {
39
+ from: string;
40
+ to: string;
41
+ edge_kind: string;
42
+ field_path: string;
43
+ required_at_publish: boolean;
44
+ }
45
+ export interface BlueprintStep {
46
+ step: number;
47
+ object_type: ProjectObjectType;
48
+ operation: "create" | "publish";
49
+ substep_count: number;
50
+ depends_on: number[];
51
+ entry_id: string;
52
+ network_phase: "testnet" | "mainnet" | "both";
53
+ }
54
+ export interface BlueprintScenario {
55
+ scenario_id: string;
56
+ description: string;
57
+ primary_object: string;
58
+ supporting_objects: string[];
59
+ }
60
+ export type RiskAppetite = "conservative" | "balanced" | "aggressive";
61
+ export interface ExpectedBenefit {
62
+ metric: string;
63
+ expected_value: string;
64
+ evidence: string;
65
+ }
66
+ export interface ModeRiskConstraints {
67
+ require_arbitration: boolean;
68
+ require_compensation_fund: boolean;
69
+ require_wip_evidence: boolean;
70
+ max_single_transaction?: number;
71
+ compensation_fund_coverage_ratio?: number;
72
+ other_constraints?: string[];
73
+ }
74
+ export interface ModeApplicableConditions {
75
+ business_scale: "small" | "medium" | "large";
76
+ min_daily_orders?: number;
77
+ other_conditions?: string[];
78
+ }
79
+ export interface ConfigOverrideRule {
80
+ object_type: string;
81
+ field_path: string;
82
+ value?: unknown;
83
+ condition?: {
84
+ intent_contains?: string;
85
+ context_field?: string;
86
+ matches?: unknown;
87
+ then_value: unknown;
88
+ else_value?: unknown;
89
+ };
90
+ }
91
+ export interface IndustryMode {
92
+ name: string;
93
+ display_name: string;
94
+ version: string;
95
+ source: IndustrySource;
96
+ traits: IndustryTraits;
97
+ machine_shape: ModeMachineNode[];
98
+ guards: ModeGuardRef[];
99
+ allocator: ModeAllocatorStrategy;
100
+ risk_checks: IndustryRiskCheck[];
101
+ needs: IndustryNeed[];
102
+ flywheel: AcquisitionFlywheel;
103
+ key_risk: string;
104
+ build_notes?: string[];
105
+ capabilities_used: string[];
106
+ config_overrides?: Record<string, Record<string, unknown>>;
107
+ config_override_rules?: ConfigOverrideRule[];
108
+ expected_benefits: ExpectedBenefit[];
109
+ risk_appetite: RiskAppetite;
110
+ risk_constraints: ModeRiskConstraints;
111
+ applicable_conditions: ModeApplicableConditions;
112
+ similar_industries?: string[];
113
+ novel_capabilities?: string[];
114
+ }
115
+ export interface UserDefinedMode extends IndustryMode {
116
+ owner: string;
117
+ source: IndustrySource;
118
+ derived_from?: string;
119
+ custom_metrics?: BaseMetric[];
120
+ custom_constraints?: ModeConstraint[];
121
+ evolution_history?: Array<{
122
+ version: string;
123
+ changed_at: number;
124
+ changes: string[];
125
+ }>;
126
+ }
127
+ export interface IndustryModeRegistration {
128
+ mode: IndustryMode;
129
+ aliases?: string[];
130
+ enabled: boolean;
131
+ registered_at: number;
132
+ }
133
+ export type DeriveModeOptions = Partial<UserDefinedMode>;
134
+ export type EvolveModeOptions = Partial<UserDefinedMode>;
135
+ export type MetricType = "risk" | "benefit";
136
+ export type MetricScale = "level" | "numeric" | "percentage";
137
+ export type MetricValue = string | number;
138
+ export type CapabilityMetricValue = Record<string, Record<string, MetricValue>>;
139
+ export interface BaseMetric {
140
+ metric_id: string;
141
+ display_name: string;
142
+ description: string;
143
+ type: MetricType;
144
+ scale: MetricScale;
145
+ weight?: number;
146
+ scope: "builtin" | "custom";
147
+ owner?: string;
148
+ }
149
+ export interface MetricEvaluationDetail {
150
+ metric_id: string;
151
+ display_name: string;
152
+ value: MetricValue;
153
+ normalized_score: number;
154
+ weight: number;
155
+ }
156
+ export interface MetricEvaluation {
157
+ risk_score: number;
158
+ benefit_score: number;
159
+ metric_details: MetricEvaluationDetail[];
160
+ }
161
+ export type ConstraintSeverity = "hard" | "soft";
162
+ export type ConstraintViolationAction = "block" | "warn" | "log";
163
+ export type ConstraintRule = {
164
+ type: "capability_required";
165
+ capability_id: string;
166
+ } | {
167
+ type: "capability_forbidden";
168
+ capability_id: string;
169
+ } | {
170
+ type: "numeric_limit";
171
+ field: string;
172
+ max?: number;
173
+ min?: number;
174
+ } | {
175
+ type: "condition_required";
176
+ condition: string;
177
+ ai_evaluated: true;
178
+ };
179
+ export interface ModeConstraint {
180
+ constraint_id: string;
181
+ display_name: string;
182
+ description: string;
183
+ rule: ConstraintRule;
184
+ severity: ConstraintSeverity;
185
+ on_violation: ConstraintViolationAction;
186
+ scope: "builtin" | "custom";
187
+ owner?: string;
188
+ }
189
+ export interface ConstraintViolation {
190
+ constraint_id: string;
191
+ display_name: string;
192
+ violation: string;
193
+ severity: ConstraintSeverity;
194
+ action: ConstraintViolationAction;
195
+ recommendation: string;
196
+ }
197
+ export interface ModeEvaluation {
198
+ applicable: boolean;
199
+ risk_score: number;
200
+ benefit_score: number;
201
+ risk_benefit_ratio: number;
202
+ capability_conflicts: string[];
203
+ violated_constraints: string[];
204
+ unmet_conditions: string[];
205
+ recommendations: string[];
206
+ }
207
+ export interface ModeMigrationEvaluation {
208
+ feasibility_score: number;
209
+ source_risk_score: number;
210
+ target_risk_score: number;
211
+ source_benefit_score: number;
212
+ target_benefit_score: number;
213
+ risk_delta: number;
214
+ benefit_delta: number;
215
+ added_capabilities: string[];
216
+ removed_capabilities: string[];
217
+ conflicting_capabilities: string[];
218
+ recommendations: string[];
219
+ }
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.js CHANGED
@@ -14,6 +14,47 @@ import { registerAllTools } from "./tools/index.js";
14
14
  if (process.env.WOWOK_TELEMETRY === "false" || process.env.WOWOK_TELEMETRY === "0") {
15
15
  setTelemetryEnabled(false);
16
16
  }
17
+ process.on("unhandledRejection", (reason, promise) => {
18
+ const reasonStr = reason instanceof Error
19
+ ? `${reason.name}: ${reason.message}\n${reason.stack ?? ""}`
20
+ : String(reason);
21
+ console.error(`[unhandledRejection] ${new Date().toISOString()}`);
22
+ console.error(` reason: ${reasonStr}`);
23
+ });
24
+ process.on("uncaughtException", (error) => {
25
+ console.error(`[uncaughtException] ${new Date().toISOString()}`);
26
+ console.error(` name: ${error.name}`);
27
+ console.error(` message: ${error.message}`);
28
+ console.error(` stack: ${error.stack ?? ""}`);
29
+ });
30
+ process.on("beforeExit", (code) => {
31
+ console.error(`[beforeExit] ${new Date().toISOString()} code=${code} — event loop empty, process would exit`);
32
+ console.error(` active handles: ${process._getActiveHandles?.()?.length ?? "?"}`);
33
+ console.error(` active requests: ${process._getActiveRequests?.()?.length ?? "?"}`);
34
+ });
35
+ process.on("exit", (code) => {
36
+ console.error(`[exit] ${new Date().toISOString()} code=${code} — process exiting`);
37
+ });
38
+ process.stdin.on("end", () => {
39
+ console.error(`[stdin end] ${new Date().toISOString()} — MCP client closed stdin`);
40
+ });
41
+ process.stdin.on("close", () => {
42
+ console.error(`[stdin close] ${new Date().toISOString()} — stdin stream closed`);
43
+ });
44
+ let keepaliveTimer = null;
45
+ function startKeepalive() {
46
+ if (keepaliveTimer)
47
+ return;
48
+ keepaliveTimer = setInterval(() => {
49
+ const mem = process.memoryUsage();
50
+ const heapUsedMB = Math.round(mem.heapUsed / 1024 / 1024);
51
+ const heapTotalMB = Math.round(mem.heapTotal / 1024 / 1024);
52
+ const rssMB = Math.round(mem.rss / 1024 / 1024);
53
+ const level = heapUsedMB > 1200 ? "WARNING" : heapUsedMB > 800 ? "INFO" : "DEBUG";
54
+ console.error(`[memory ${level}] heap=${heapUsedMB}MB/${heapTotalMB}MB rss=${rssMB}MB`);
55
+ }, 60_000);
56
+ }
57
+ startKeepalive();
17
58
  const SERVER_DESCRIPTION = `WoWok MCP Server - Making It Easy for AI Agents to Communicate, Collaborate, Trade, and Trust.
18
59
 
19
60
  ## CRITICAL: Unified Single-Tool Architecture
@@ -210,5 +251,14 @@ async function main() {
210
251
  await server.close();
211
252
  process.exit(0);
212
253
  });
254
+ process.on("SIGTERM", async () => {
255
+ console.error(`[SIGTERM] ${new Date().toISOString()} — graceful shutdown`);
256
+ try {
257
+ await server.close();
258
+ }
259
+ catch {
260
+ }
261
+ process.exit(0);
262
+ });
213
263
  }
214
264
  main().catch(console.error);
@@ -44,6 +44,8 @@ export interface DeploymentScanResult {
44
44
  D16_no_critical_risk: "pass" | "fail";
45
45
  D17_no_high_risk: "pass" | "fail";
46
46
  D18_completeness_checklist: "pass" | "fail";
47
+ D19_machine_entry_forward: "pass" | "fail";
48
+ D20_service_compensation_fund: "pass" | "fail";
47
49
  };
48
50
  scanned_at: number;
49
51
  scanner_version: string;
@@ -56,6 +58,7 @@ export declare function analyzePermissionIndexRange(input: DeploymentScanInput):
56
58
  export declare function analyzeScenarioCoverage(input: DeploymentScanInput): Finding[];
57
59
  export declare function analyzeVerificationChecklist(input: DeploymentScanInput): Finding[];
58
60
  export declare function analyzeDeployableReadiness(input: DeploymentScanInput): Finding[];
61
+ export declare function analyzeMachineAndServiceReadiness(input: DeploymentScanInput): Finding[];
59
62
  export declare function scanDeployment(input: DeploymentScanInput): DeploymentScanResult;
60
63
  export declare function isReady(scan: DeploymentScanResult): boolean;
61
64
  export declare function isBlocked(scan: DeploymentScanResult): boolean;
@@ -25,7 +25,7 @@ function fromDeploymentDocInput(input) {
25
25
  for (let i = 1; i <= 5; i++)
26
26
  mainnet_verification.set(`V-M-${String(i).padStart(2, "0")}`, false);
27
27
  const completeness_checklist = new Map();
28
- for (let i = 1; i <= 18; i++)
28
+ for (let i = 1; i <= 20; i++)
29
29
  completeness_checklist.set(`D-${String(i).padStart(2, "0")}`, false);
30
30
  return {
31
31
  project_name: input.project_prefix, version, namespace_tag,
@@ -529,7 +529,7 @@ export function analyzeScenarioCoverage(input) {
529
529
  }
530
530
  const TESTNET_VERIFICATION_ITEMS = ["V-T-01", "V-T-02", "V-T-03", "V-T-04", "V-T-05", "V-T-06", "V-T-07", "V-T-08", "V-T-09", "V-T-10", "V-T-11"];
531
531
  const MAINNET_VERIFICATION_ITEMS = ["V-M-01", "V-M-02", "V-M-03", "V-M-04", "V-M-05"];
532
- const COMPLETENESS_CHECK_IDS = Array.from({ length: 18 }, (_, i) => `D-${String(i + 1).padStart(2, "0")}`);
532
+ const COMPLETENESS_CHECK_IDS = Array.from({ length: 20 }, (_, i) => `D-${String(i + 1).padStart(2, "0")}`);
533
533
  export function analyzeVerificationChecklist(input) {
534
534
  const findings = [];
535
535
  try {
@@ -623,6 +623,64 @@ function resolveRiskResult(input) {
623
623
  }
624
624
  return undefined;
625
625
  }
626
+ function extractMachinePairs(block) {
627
+ const data = block.data;
628
+ if (!data)
629
+ return [];
630
+ const node = data.node;
631
+ if (!node || typeof node !== "object")
632
+ return [];
633
+ const nodes = node.nodes;
634
+ if (!Array.isArray(nodes))
635
+ return [];
636
+ return nodes.filter((n) => {
637
+ if (!n || typeof n !== "object")
638
+ return false;
639
+ const pairs = n.pairs;
640
+ return Array.isArray(pairs);
641
+ }).flatMap((n) => n.pairs ?? []);
642
+ }
643
+ export function analyzeMachineAndServiceReadiness(input) {
644
+ const findings = [];
645
+ try {
646
+ const doc = normalizeInput(input);
647
+ if (!doc)
648
+ return [];
649
+ const allBlocks = [...doc.testnet_blocks, ...doc.mainnet_blocks];
650
+ for (const block of allBlocks) {
651
+ if (block.operation_type !== "machine")
652
+ continue;
653
+ const pairs = extractMachinePairs(block);
654
+ if (pairs.length === 0)
655
+ continue;
656
+ const entryPairs = pairs.filter((p) => p.prev_node === "");
657
+ for (const pair of entryPairs) {
658
+ const forwardsLen = Array.isArray(pair.forwards) ? pair.forwards.length : 0;
659
+ if (forwardsLen === 0) {
660
+ add(findings, "D-19", "critical", `Machine in step ${block.step} (${block.env.network ?? "?"}) has an entry node (prev_node="") with no forwards. ` +
661
+ `Progress created from this Machine will be permanently stuck at current="" (P0-2 root cause).`, `${block.env.network ?? "?"} step ${block.step}`, `Add at least one forward to the entry node's pairs. Example: pairs: [{prev_node: "", forwards: [{next_node: "Ordered", ...}]}]`);
662
+ }
663
+ }
664
+ }
665
+ const serviceBlocks = allBlocks.filter((b) => b.operation_type === "service");
666
+ if (serviceBlocks.length > 0) {
667
+ const blocksWithFundAdd = serviceBlocks.filter((b) => {
668
+ const data = b.data;
669
+ return data?.compensation_fund_add != null;
670
+ });
671
+ if (blocksWithFundAdd.length === 0) {
672
+ add(findings, "D-20", "warning", `No Service block in the deployment doc includes a compensation_fund_add step. ` +
673
+ `Without deposit, arbitration rulings that award refunds to buyers cannot be paid out from the Service. ` +
674
+ `Industries like freelance may not require this (info), but rental/travel/education typically do.`, "§3.2 / §4.2 Service blocks", `Add a compensation_fund_add step for the Service (e.g., data.compensation_fund_add = {balance: <amount>}). ` +
675
+ `Recommended: 3-10× the max single-order amount, depending on industry (subscription: 3×, retail: 5×, rental: 10×). See P1-1 evaluation rule.`);
676
+ }
677
+ }
678
+ }
679
+ catch (err) {
680
+ add(findings, "D-19", "warning", `analyzeMachineAndServiceReadiness failed: ${err.message}`);
681
+ }
682
+ return findings;
683
+ }
626
684
  export function scanDeployment(input) {
627
685
  const allFindings = [
628
686
  ...analyzeObjectDependencyCompleteness(input),
@@ -633,6 +691,7 @@ export function scanDeployment(input) {
633
691
  ...analyzeScenarioCoverage(input),
634
692
  ...analyzeVerificationChecklist(input),
635
693
  ...analyzeDeployableReadiness(input),
694
+ ...analyzeMachineAndServiceReadiness(input),
636
695
  ];
637
696
  return {
638
697
  project_name: input.project_name,
@@ -666,6 +725,8 @@ function computeChecks(findings) {
666
725
  D16_no_critical_risk: has("D-16") ? "fail" : "pass",
667
726
  D17_no_high_risk: has("D-17") ? "fail" : "pass",
668
727
  D18_completeness_checklist: has("D-18") ? "fail" : "pass",
728
+ D19_machine_entry_forward: has("D-19") ? "fail" : "pass",
729
+ D20_service_compensation_fund: has("D-20") ? "fail" : "pass",
669
730
  };
670
731
  }
671
732
  function computeCoverage(input) {
@@ -726,7 +787,7 @@ export function summarizeScan(scan) {
726
787
  L.push(`| testnet steps | ${scan.coverage.testnet_steps} |`);
727
788
  L.push(`| mainnet steps | ${scan.coverage.mainnet_steps} |`);
728
789
  L.push(`| verification items | ${scan.coverage.verification_items} |`, "");
729
- L.push("## Checks (D-01 ~ D-18)", "", "| Check ID | Status |", "|----------|--------|");
790
+ L.push("## Checks (D-01 ~ D-20)", "", "| Check ID | Status |", "|----------|--------|");
730
791
  const entries = Object.entries(scan.checks);
731
792
  for (const [id, status] of entries)
732
793
  L.push(`| ${id} | ${status === "pass" ? "✅ pass" : "❌ fail"} |`);
@@ -0,0 +1,72 @@
1
+ import type { ENTRYPOINT } from "@wowok/wowok";
2
+ export interface OfficialTokenEntry {
3
+ type: string;
4
+ symbol: string;
5
+ decimals: number;
6
+ name: string;
7
+ description: string;
8
+ }
9
+ export type TokenNetwork = "gas" | "testnet" | "mainnet";
10
+ export declare const OFFICIAL_TOKEN_REGISTRY: Record<TokenNetwork, OfficialTokenEntry[]>;
11
+ export declare function getRegistryForNetwork(network?: string): OfficialTokenEntry[];
12
+ export type TokenSource = "registry" | "cache" | "onchain";
13
+ export interface TokenResolution {
14
+ type: string;
15
+ symbol: string;
16
+ decimals: number;
17
+ name: string;
18
+ source: TokenSource;
19
+ verified: boolean;
20
+ }
21
+ export declare function findInRegistryByType(tokenType: string, network?: string): OfficialTokenEntry | undefined;
22
+ export declare function findInRegistryBySymbol(symbol: string, network?: string): OfficialTokenEntry[];
23
+ export declare function resolveTokenByType(tokenType: string, network?: ENTRYPOINT): Promise<TokenResolution | undefined>;
24
+ export declare function resolveTokensBySymbol(symbol: string, network?: ENTRYPOINT, preferredType?: string): Promise<TokenResolution[]>;
25
+ export interface ParsedAmount {
26
+ smallestUnit: bigint;
27
+ displayAmount: string;
28
+ originalInput: string | number;
29
+ tokenType: string;
30
+ tokenSymbol: string;
31
+ decimals: number;
32
+ converted: boolean;
33
+ source: TokenSource;
34
+ verified: boolean;
35
+ }
36
+ export declare function isAmountWithSymbol(value: unknown): boolean;
37
+ export declare function parseAmount(amount: string | number, tokenType: string, network?: ENTRYPOINT): Promise<ParsedAmount>;
38
+ export declare function smallestToDisplay(value: bigint, decimals: number): string;
39
+ export interface FundFieldConfirmation {
40
+ path: string;
41
+ displayAmount: string;
42
+ tokenType: string;
43
+ tokenSymbol: string;
44
+ verified: boolean;
45
+ source: TokenSource;
46
+ converted: boolean;
47
+ context: string;
48
+ }
49
+ export interface TokenAmbiguity {
50
+ symbol: string;
51
+ candidates: {
52
+ type: string;
53
+ decimals: number;
54
+ source: TokenSource;
55
+ verified: boolean;
56
+ }[];
57
+ }
58
+ export interface FundConfirmationRequest {
59
+ requiresConfirmation: boolean;
60
+ reason: string;
61
+ fields: FundFieldConfirmation[];
62
+ ambiguities: TokenAmbiguity[];
63
+ message: string;
64
+ }
65
+ export declare function generateFundConfirmation(fields: FundFieldConfirmation[], ambiguities?: TokenAmbiguity[]): FundConfirmationRequest;
66
+ export interface FundProcessResult {
67
+ convertedData: any;
68
+ warnings: string[];
69
+ confirmation: FundConfirmationRequest | null;
70
+ }
71
+ export declare function processFundOperation(data: any, operationType: string, network?: ENTRYPOINT): Promise<FundProcessResult>;
72
+ export declare function generateSkillsHint(confirmation: FundConfirmationRequest | null): string | null;