@wowok/agent-mcp 2.5.0 → 2.5.2

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.
@@ -484,7 +484,7 @@ export function analyzeHandlerTypeSafety(instances) {
484
484
  export function analyzeOutputSchemaCoverage(census) {
485
485
  const findings = [];
486
486
  for (const c of census) {
487
- if (!c.layer3_generated.output_exists) {
487
+ if (!c.layer3_generated.output_exists && c.name !== "onchain_operations") {
488
488
  findings.push({
489
489
  rule_id: 'MCP-OUTPUT-001',
490
490
  severity: 'high',
@@ -559,7 +559,7 @@ export function analyzeSchemaQueryReflection(census) {
559
559
  fix: `Run pnpm generate:schemas.`,
560
560
  });
561
561
  }
562
- if (!c.layer3_generated.output_exists) {
562
+ if (!c.layer3_generated.output_exists && c.name !== "onchain_operations") {
563
563
  findings.push({
564
564
  rule_id: 'MCP-REFLECT-002',
565
565
  severity: 'medium',
@@ -574,6 +574,7 @@ export function analyzeSchemaQueryReflection(census) {
574
574
  'permission', 'service', 'machine', 'progress', 'guard',
575
575
  'arbitration', 'repository', 'contact', 'treasury', 'reward',
576
576
  'allocation', 'personal', 'payment', 'demand', 'order', 'gen_passport',
577
+ 'proof', 'gen_proof',
577
578
  ];
578
579
  for (const op of onchainOps) {
579
580
  const opFile = path.join(GENERATED_SCHEMAS_DIR, `onchain_operations_${op}.schema.json`);
@@ -26,6 +26,7 @@ export interface BusinessPuzzleResult {
26
26
  puzzles: Record<string, ObjectPuzzleEntry>;
27
27
  overall_completeness: "complete" | "partial" | "empty";
28
28
  next_step: string;
29
+ recommended_creation_order: string[];
29
30
  warnings: string[];
30
31
  }
31
32
  export interface KeywordMatch {
@@ -246,6 +246,7 @@ export function analyzeBusinessIntent(input) {
246
246
  puzzles: {},
247
247
  overall_completeness: "empty",
248
248
  next_step: "Please provide a non-empty business intent.",
249
+ recommended_creation_order: [],
249
250
  warnings: ["input.user_intent is empty"],
250
251
  };
251
252
  }
@@ -295,8 +296,17 @@ export function analyzeBusinessIntent(input) {
295
296
  puzzles,
296
297
  overall_completeness: overall,
297
298
  next_step: "",
299
+ recommended_creation_order: [],
298
300
  warnings,
299
301
  });
302
+ const creationOrder = [
303
+ "permission",
304
+ "progress",
305
+ "guard",
306
+ "allocation",
307
+ "machine",
308
+ "service",
309
+ ];
300
310
  return {
301
311
  intent_parsed: {
302
312
  primary_object: primary,
@@ -308,6 +318,7 @@ export function analyzeBusinessIntent(input) {
308
318
  puzzles,
309
319
  overall_completeness: overall,
310
320
  next_step: nextStep,
321
+ recommended_creation_order: creationOrder,
311
322
  warnings,
312
323
  };
313
324
  }
@@ -56,6 +56,17 @@ export interface DeploymentDocValidationResult {
56
56
  }>;
57
57
  errors: string[];
58
58
  }
59
+ export interface GasEstimate {
60
+ total_gas_mist: number;
61
+ per_object: Array<{
62
+ entry_id: string;
63
+ object_type: string;
64
+ create_gas_mist: number;
65
+ publish_gas_mist: number;
66
+ }>;
67
+ publish_gas_mist: number;
68
+ }
59
69
  export declare function generateDeploymentDoc(input: DeploymentDocInput): string;
70
+ export declare function estimateDeploymentGas(input: Pick<DeploymentDocInput, "objects">): GasEstimate;
60
71
  export declare function validateDeploymentDoc(input: DeploymentDocInput): DeploymentDocValidationResult;
61
72
  export declare function getStandardTopoOrder(): ProjectObjectType[];
@@ -300,6 +300,43 @@ export function generateDeploymentDoc(input) {
300
300
  ];
301
301
  return sections.filter((s) => s.length > 0).join("\n");
302
302
  }
303
+ export function estimateDeploymentGas(input) {
304
+ const GAS_RATES = {
305
+ permission: { create: 20_000_000, publish: 0 },
306
+ progress: { create: 40_000_000, publish: 0 },
307
+ guard: { create: 30_000_000, publish: 0 },
308
+ allocation: { create: 40_000_000, publish: 0 },
309
+ machine: { create: 50_000_000, publish: 200_000_000 },
310
+ service: { create: 50_000_000, publish: 100_000_000 },
311
+ arb: { create: 40_000_000, publish: 0 },
312
+ treasury: { create: 30_000_000, publish: 0 },
313
+ demand: { create: 40_000_000, publish: 0 },
314
+ repository: { create: 40_000_000, publish: 0 },
315
+ reward: { create: 30_000_000, publish: 0 },
316
+ };
317
+ const perObject = [];
318
+ let totalGas = 0;
319
+ let publishGas = 0;
320
+ for (const obj of input.objects) {
321
+ const rate = GAS_RATES[obj.object_type] ?? { create: 40_000_000, publish: 0 };
322
+ const createGas = obj.reused_from ? 0 : rate.create;
323
+ const pubGas = obj.publish_required ? rate.publish : 0;
324
+ const objTotal = createGas + pubGas;
325
+ perObject.push({
326
+ entry_id: obj.entry_id,
327
+ object_type: obj.object_type,
328
+ create_gas_mist: createGas,
329
+ publish_gas_mist: pubGas,
330
+ });
331
+ totalGas += objTotal;
332
+ publishGas += pubGas;
333
+ }
334
+ return {
335
+ total_gas_mist: totalGas,
336
+ per_object: perObject,
337
+ publish_gas_mist: publishGas,
338
+ };
339
+ }
303
340
  export function validateDeploymentDoc(input) {
304
341
  const errors = [];
305
342
  const checks = [];
@@ -7,6 +7,31 @@ export * from "./query.js";
7
7
  export declare function isProjectServiceEnabled(): boolean;
8
8
  export declare function getGraph(): ProjectGraph;
9
9
  export declare function setGraph(g: ProjectGraph): void;
10
+ export type ProjectStage = 1 | 2 | 3 | 4 | 5;
11
+ export interface StageCacheEntry {
12
+ stage: ProjectStage;
13
+ updated_at: number;
14
+ puzzles?: Record<string, unknown>;
15
+ risk_status?: string;
16
+ risk_can_proceed?: boolean;
17
+ doc_generated?: boolean;
18
+ doc_error_count?: number;
19
+ trace_coherent?: boolean;
20
+ trace_can_proceed?: boolean;
21
+ business_intent?: string;
22
+ industry?: string;
23
+ }
24
+ export declare function getStageCache(prefix: string, version: string): StageCacheEntry | undefined;
25
+ export declare function updateStageCache(prefix: string, version: string, update: Partial<StageCacheEntry>): StageCacheEntry;
26
+ export declare function getProjectStatus(prefix: string, version: string): {
27
+ stage: ProjectStage;
28
+ stage_name: string;
29
+ stage_description: string;
30
+ next_action: string;
31
+ can_proceed: boolean;
32
+ details: StageCacheEntry | undefined;
33
+ };
34
+ export declare function clearStageCache(prefix: string, version: string): void;
10
35
  export interface NormalizeCallInput {
11
36
  operation_type: string;
12
37
  data: any;
@@ -62,6 +62,48 @@ export function getGraph() {
62
62
  export function setGraph(g) {
63
63
  GRAPH_INSTANCE = g;
64
64
  }
65
+ const STAGE_CACHE = new Map();
66
+ function stageCacheKey(prefix, version) {
67
+ return `${prefix}:${version}`;
68
+ }
69
+ export function getStageCache(prefix, version) {
70
+ return STAGE_CACHE.get(stageCacheKey(prefix, version));
71
+ }
72
+ export function updateStageCache(prefix, version, update) {
73
+ const key = stageCacheKey(prefix, version);
74
+ const existing = STAGE_CACHE.get(key);
75
+ const entry = {
76
+ stage: update.stage ?? existing?.stage ?? 1,
77
+ updated_at: Date.now(),
78
+ ...existing,
79
+ ...update,
80
+ };
81
+ STAGE_CACHE.set(key, entry);
82
+ return entry;
83
+ }
84
+ export function getProjectStatus(prefix, version) {
85
+ const entry = getStageCache(prefix, version);
86
+ const stage = entry?.stage ?? 1;
87
+ const stageInfo = {
88
+ 1: { name: "Project Naming", description: "Project namespace established. Ready to analyze business intent.", next: "analyze_intent" },
89
+ 2: { name: "Business Puzzle", description: "Business intent analyzed. Puzzles may need completion before risk assessment.", next: entry?.puzzles ? "aggregate_risks" : "analyze_intent" },
90
+ 3: { name: "Risk Calibration", description: "Risks assessed. Fix CRITICAL risks before generating deployment doc.", next: entry?.risk_can_proceed ? "generate_deployment_doc" : "aggregate_risks" },
91
+ 4: { name: "Deployment Document", description: "Deployment doc generated. Fix D-errors before substep trace.", next: entry?.doc_error_count === 0 ? "trace_substeps" : "generate_deployment_doc" },
92
+ 5: { name: "Substep Trace", description: "Substeps traced. Ready for deployment execution.", next: entry?.trace_can_proceed ? "deploy" : "trace_substeps" },
93
+ };
94
+ const info = stageInfo[stage];
95
+ return {
96
+ stage,
97
+ stage_name: info.name,
98
+ stage_description: info.description,
99
+ next_action: info.next,
100
+ can_proceed: stage < 5,
101
+ details: entry,
102
+ };
103
+ }
104
+ export function clearStageCache(prefix, version) {
105
+ STAGE_CACHE.delete(stageCacheKey(prefix, version));
106
+ }
65
107
  export function normalize(input) {
66
108
  if (!isProjectServiceEnabled()) {
67
109
  return { data: input.data, warnings: [] };
@@ -40,6 +40,13 @@ export interface RiskAggregationResult {
40
40
  entry_id: string;
41
41
  }>;
42
42
  calibrated_at: number;
43
+ fix_suggestions_grouped?: Record<string, Array<{
44
+ risk_rule_id: string;
45
+ severity: RiskSeverity;
46
+ message: string;
47
+ fix_suggestion: string;
48
+ entry_id: string;
49
+ }>>;
43
50
  warnings: string[];
44
51
  }
45
52
  export declare function aggregateProjectRisks(input: RiskAggregationInput): RiskAggregationResult;
@@ -179,6 +179,20 @@ export function aggregateProjectRisks(input) {
179
179
  entry_id: f.entry_id,
180
180
  }));
181
181
  }
182
+ const fixSuggestionsGrouped = {};
183
+ for (const finding of findings) {
184
+ const key = finding.object_type;
185
+ if (!fixSuggestionsGrouped[key]) {
186
+ fixSuggestionsGrouped[key] = [];
187
+ }
188
+ fixSuggestionsGrouped[key].push({
189
+ risk_rule_id: finding.risk_rule_id,
190
+ severity: finding.severity,
191
+ message: finding.message,
192
+ fix_suggestion: finding.fix_suggestion,
193
+ entry_id: finding.entry_id,
194
+ });
195
+ }
182
196
  return {
183
197
  namespace: {
184
198
  prefix: input.project_prefix ?? "",
@@ -190,6 +204,7 @@ export function aggregateProjectRisks(input) {
190
204
  status,
191
205
  pending_confirmations,
192
206
  calibrated_at: Date.now(),
207
+ fix_suggestions_grouped: fixSuggestionsGrouped,
193
208
  warnings,
194
209
  };
195
210
  }
@@ -340,9 +340,9 @@ export const SchemaWarningSchema = z.object({
340
340
  }).describe("Server-side schema versions."),
341
341
  }).strict().describe("Schema compatibility warning attached to tool output when client_schema_version is provided and a mismatch is detected.");
342
342
  export const CallOutputSchema = z.object({
343
- result: CallResultSchema.describe("Discriminated result. Check result.type first: 'transaction'|'submission'|'error'|'data'|'null'. Each variant has different fields."),
343
+ result: CallResultSchema.describe("Discriminated result. Check result.type first: 'transaction'|'submission'|'error'|'data'|'null'|'pending_confirmation'. Each variant has different fields."),
344
344
  message: z.string().optional().describe("Human-readable summary or hint. Constraint: always present for error/transaction results; may be omitted for data/null. Example: 'Transaction completed successfully'"),
345
345
  semantic: SemanticSummarySchema.optional().describe("Business semantic summary. AI should read semantic first; fall back to parsing result only when semantic is absent. Relation: populated by MCP server from operation context; undefined when intent cannot be confidently inferred or for non-transaction tools. Example: {intent:'publish_service', status:'success', summary:'...'}"),
346
346
  harness_report: HarnessReportSchema.optional().describe("L4 Harness report (Verify + Recover). Present only when the Harness is injected and an Expected Result was declared for this operation. Relation: produced by handler.ts calling harness.verify() and harness.recover(). Example: {verify:{status:'fail', mismatches:[...]}, recovery:{strategy:'recreate'}}"),
347
347
  schema_warning: SchemaWarningSchema.optional().describe("Schema compatibility warning. Present only when client_schema_version is provided in env and a mismatch is detected."),
348
- }).strict().describe("Unified MCP tool output. result.type discriminates 5 outcomes: 'transaction' (raw Wow response), 'submission' (needs Guard data), 'error' (failed with error_code), 'data' (query result), 'null' (no-op). When semantic is present, prefer it over raw result parsing. When harness_report is present, check verify.status first and follow recovery.strategy if status is 'fail'.");
348
+ }).strict().describe("Unified MCP tool output. result.type discriminates 6 outcomes: 'transaction' (raw Wow response), 'submission' (needs Guard data), 'error' (failed with error_code), 'data' (query result), 'null' (no-op), 'pending_confirmation' (ConfirmGate blocked — re-call with env.confirmed=true). When semantic is present, prefer it over raw result parsing. When harness_report is present, check verify.status first and follow recovery.strategy if status is 'fail'.");