@wowok/agent-mcp 2.6.1 → 2.6.4
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.
- package/dist/customer/customer-advice.d.ts +31 -0
- package/dist/customer/customer-advice.js +129 -0
- package/dist/customer/index.d.ts +2 -0
- package/dist/customer/index.js +2 -0
- package/dist/customer/info-puzzle.d.ts +9 -2
- package/dist/customer/info-puzzle.js +34 -7
- package/dist/customer/order-monitor.d.ts +2 -0
- package/dist/customer/order-monitor.js +3 -2
- package/dist/customer/post-purchase.d.ts +2 -0
- package/dist/customer/post-purchase.js +6 -5
- package/dist/customer/preorder-compare.d.ts +24 -0
- package/dist/customer/preorder-compare.js +34 -0
- package/dist/customer/reminder-system.d.ts +2 -0
- package/dist/customer/reminder-system.js +2 -1
- package/dist/customer/risk-assessment.js +30 -7
- package/dist/customer/types.d.ts +7 -0
- package/dist/examples/arbitration-dispute-create.json +41 -0
- package/dist/examples/arbitration-vote-weighted.json +35 -0
- package/dist/examples/arbitration-voting-guard-add.json +38 -0
- package/dist/examples/demand-present-service.json +33 -0
- package/dist/examples/gen-passport-verify-guard.json +48 -0
- package/dist/examples/guard-template-balance-check.json +59 -0
- package/dist/examples/guard-template-time-lock.json +60 -0
- package/dist/examples/insurance-guard-claim-timelock.json +75 -0
- package/dist/examples/insurance-guard-withdraw-allocation.json +96 -0
- package/dist/examples/insurance-machine-create-publish.json +75 -0
- package/dist/examples/insurance-service-allocators-publish.json +56 -0
- package/dist/examples/machine-multisig-threshold.json +86 -0
- package/dist/examples/machine-template-7node-rental.json +119 -0
- package/dist/examples/payment-scenario-bound.json +45 -0
- package/dist/examples/rental-ziroom-machine-create.json +149 -0
- package/dist/examples/rental-ziroom-permission-create.json +42 -0
- package/dist/examples/rental-ziroom-service-create.json +89 -0
- package/dist/examples/retail-adv-guard-customer-win-create.json +80 -0
- package/dist/examples/retail-adv-guard-messenger-proof-create.json +65 -0
- package/dist/examples/retail-adv-guard-reward-timeout-create.json +92 -0
- package/dist/examples/retail-adv-reward-guard-add.json +51 -0
- package/dist/examples/retail-myshop-allocation-activate.json +55 -0
- package/dist/examples/retail-myshop-arbitration-create.json +40 -0
- package/dist/examples/retail-myshop-contact-create.json +43 -0
- package/dist/examples/retail-myshop-order-create.json +56 -0
- package/dist/examples/retail-myshop-progress-operate.json +38 -0
- package/dist/examples/retail-myshop-reward-create.json +35 -0
- package/dist/examples/retail-myshop-service-create.json +88 -0
- package/dist/examples/service-discount-issue.json +46 -0
- package/dist/examples/threebody-guard-create.json +56 -0
- package/dist/examples/threebody-machine-create.json +72 -0
- package/dist/examples/threebody-permission-create.json +38 -0
- package/dist/examples/threebody-service-allocators.json +49 -0
- package/dist/examples/travel-guard-time-lock.json +69 -0
- package/dist/examples/travel-guard-weather-oracle.json +70 -0
- package/dist/examples/travel-machine-create.json +136 -0
- package/dist/examples/travel-repository-create.json +47 -0
- package/dist/examples/travel-service-create.json +102 -0
- package/dist/examples/travel-treasury-create.json +34 -0
- package/dist/examples/treasury-deposit.json +37 -0
- package/dist/examples/treasury-withdraw.json +38 -0
- package/dist/extensions/business-modules.d.ts +49 -0
- package/dist/extensions/business-modules.js +287 -0
- package/dist/extensions/capability-manifest.js +216 -29
- package/dist/extensions/constraint-registry.js +21 -19
- package/dist/extensions/metric-registry.js +14 -14
- package/dist/extensions/mode-evaluator.js +16 -16
- package/dist/extensions/modes.js +141 -49
- package/dist/extensions/registry.d.ts +16 -9
- package/dist/extensions/registry.js +132 -44
- package/dist/extensions/types.d.ts +2 -0
- package/dist/index.js +50 -0
- package/dist/knowledge/deployment-scanner.js +1 -1
- package/dist/knowledge/fund-layer.d.ts +138 -0
- package/dist/knowledge/fund-layer.js +969 -0
- package/dist/knowledge/guard-render.d.ts +57 -0
- package/dist/knowledge/guard-render.js +700 -0
- package/dist/knowledge/guard-submission-prompt.d.ts +31 -0
- package/dist/knowledge/guard-submission-prompt.js +171 -0
- package/dist/knowledge/guard-templates.d.ts +10 -0
- package/dist/knowledge/guard-templates.js +50 -0
- package/dist/knowledge/index.d.ts +2 -2
- package/dist/knowledge/index.js +2 -2
- package/dist/knowledge/machine-ledger.js +1 -1
- package/dist/knowledge/machine-render.d.ts +41 -0
- package/dist/knowledge/machine-render.js +565 -0
- package/dist/knowledge/machine-risk.js +4 -1
- package/dist/knowledge/machine-templates.js +4 -4
- package/dist/knowledge/progress-context.js +1 -1
- package/dist/knowledge/progress-ledger.js +3 -3
- package/dist/knowledge/progress-templates.js +1 -1
- package/dist/knowledge/progress-translation.js +1 -1
- package/dist/knowledge/reward-confirm.js +2 -2
- package/dist/knowledge/reward-puzzle.js +1 -1
- package/dist/knowledge/reward-risk.js +9 -9
- package/dist/knowledge/reward-templates.js +2 -2
- package/dist/knowledge/safety-rules.d.ts +83 -1
- package/dist/knowledge/safety-rules.js +166 -2
- package/dist/knowledge/scenario-modes.d.ts +1 -1
- package/dist/knowledge/scenario-modes.js +13 -11
- package/dist/knowledge/service-confirm.d.ts +1 -1
- package/dist/knowledge/service-confirm.js +3 -3
- package/dist/knowledge/service-context.js +1 -1
- package/dist/knowledge/service-ledger.js +1 -1
- package/dist/knowledge/service-risk.d.ts +1 -1
- package/dist/knowledge/service-risk.js +3 -3
- package/dist/knowledge/service-templates.js +2 -2
- package/dist/knowledge/service-translation.d.ts +1 -1
- package/dist/knowledge/service-translation.js +7 -7
- package/dist/knowledge/template-registry.d.ts +48 -0
- package/dist/knowledge/template-registry.js +341 -0
- package/dist/knowledge/tool-constraints.js +6 -6
- package/dist/knowledge/tools-reference.js +11 -8
- package/dist/participation/merchant-interest.d.ts +32 -0
- package/dist/participation/merchant-interest.js +100 -0
- package/dist/participation/radar-core.d.ts +104 -0
- package/dist/participation/radar-core.js +269 -0
- package/dist/project/context-assembly.js +8 -0
- package/dist/project/deployment-bridge.js +6 -5
- package/dist/project/deployment-doc.js +5 -5
- package/dist/project/edit-planner.d.ts +123 -0
- package/dist/project/edit-planner.js +1342 -0
- package/dist/project/evaluation.d.ts +36 -0
- package/dist/project/evaluation.js +734 -68
- package/dist/project/game-theory.d.ts +43 -0
- package/dist/project/game-theory.js +177 -0
- package/dist/project/graph-builder.js +7 -1
- package/dist/project/handlers.d.ts +137 -2
- package/dist/project/handlers.js +423 -51
- package/dist/project/intent-analyzer.d.ts +71 -0
- package/dist/project/intent-analyzer.js +149 -0
- package/dist/project/machine-nodes.d.ts +2 -0
- package/dist/project/machine-nodes.js +36 -0
- package/dist/project/merchant-guide.d.ts +165 -0
- package/dist/project/merchant-guide.js +264 -0
- package/dist/project/mode-actions.d.ts +199 -0
- package/dist/project/mode-actions.js +309 -0
- package/dist/project/participation-radar.d.ts +18 -0
- package/dist/project/participation-radar.js +428 -0
- package/dist/project/pipeline-actions.d.ts +101 -0
- package/dist/project/pipeline-actions.js +109 -0
- package/dist/project/semantic-graph.d.ts +95 -0
- package/dist/project/semantic-graph.js +245 -0
- package/dist/project/stage-gate.js +4 -4
- package/dist/schema/call/allocation.d.ts +11 -11
- package/dist/schema/call/allocation.js +13 -3
- package/dist/schema/call/arbitration.d.ts +21 -21
- package/dist/schema/call/arbitration.js +30 -9
- package/dist/schema/call/base.d.ts +2 -2
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +127 -127
- package/dist/schema/call/bridge.js +12 -12
- package/dist/schema/call/contact.d.ts +3 -3
- package/dist/schema/call/contact.js +2 -2
- package/dist/schema/call/demand.d.ts +3 -3
- package/dist/schema/call/demand.js +2 -2
- package/dist/schema/call/guard.d.ts +11 -11
- package/dist/schema/call/guard.js +2 -2
- package/dist/schema/call/machine.d.ts +2072 -679
- package/dist/schema/call/machine.js +51 -5
- package/dist/schema/call/order.d.ts +7 -7
- package/dist/schema/call/order.js +3 -6
- package/dist/schema/call/payment.d.ts +3 -3
- package/dist/schema/call/permission.d.ts +3 -3
- package/dist/schema/call/permission.js +2 -2
- package/dist/schema/call/personal.d.ts +337 -3
- package/dist/schema/call/personal.js +10 -0
- package/dist/schema/call/progress.d.ts +177 -9
- package/dist/schema/call/progress.js +7 -3
- package/dist/schema/call/proof.d.ts +6 -6
- package/dist/schema/call/repository.d.ts +3 -3
- package/dist/schema/call/repository.js +2 -2
- package/dist/schema/call/reward.d.ts +57 -57
- package/dist/schema/call/reward.js +3 -3
- package/dist/schema/call/semantic.js +48 -2
- package/dist/schema/call/service.d.ts +285 -113
- package/dist/schema/call/service.js +92 -28
- package/dist/schema/call/treasury.d.ts +57 -57
- package/dist/schema/call/treasury.js +3 -3
- package/dist/schema/common/index.d.ts +2 -0
- package/dist/schema/common/index.js +46 -10
- package/dist/schema/local/index.js +5 -1
- package/dist/schema/messenger/index.js +4 -1
- package/dist/schema/operations.d.ts +1318 -317
- package/dist/schema/operations.js +76 -7
- package/dist/schema/project/index.d.ts +5662 -164
- package/dist/schema/project/index.js +1136 -5
- package/dist/schema/query/index.d.ts +580 -19
- package/dist/schema/query/index.js +88 -36
- package/dist/schema/schema-query/index.d.ts +59 -3
- package/dist/schema/schema-query/index.js +45 -6
- package/dist/schema/trust/index.d.ts +1012 -6
- package/dist/schema/trust/index.js +212 -11
- package/dist/schema/utils/node-parser.js +13 -0
- package/dist/schema/utils/object-type-utils.d.ts +12 -0
- package/dist/schema/utils/object-type-utils.js +35 -0
- package/dist/schema/utils/permission-machine-check.d.ts +49 -0
- package/dist/schema/utils/permission-machine-check.js +121 -0
- package/dist/schema/utils/skills-recommendation.d.ts +2 -0
- package/dist/schema/utils/skills-recommendation.js +77 -0
- package/dist/schema-query/index.d.ts +17 -1
- package/dist/schema-query/index.js +359 -3
- package/dist/schemas/account_operation.schema.json +1 -1
- package/dist/schemas/bridge_operation.schema.json +14 -7
- package/dist/schemas/guard2file.schema.json +2 -0
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/machineNode2file.schema.json +2 -0
- package/dist/schemas/messenger_operation.schema.json +1 -1
- package/dist/schemas/onchain_events.output.json +1 -1
- package/dist/schemas/onchain_operations.output.json +2820 -0
- package/dist/schemas/onchain_operations.schema.json +255 -65
- package/dist/schemas/onchain_operations_allocation.schema.json +7 -6
- package/dist/schemas/onchain_operations_arbitration.schema.json +14 -10
- package/dist/schemas/onchain_operations_contact.schema.json +4 -3
- package/dist/schemas/onchain_operations_demand.schema.json +4 -3
- package/dist/schemas/onchain_operations_gen_passport.schema.json +4 -2
- package/dist/schemas/onchain_operations_gen_proof.schema.json +2 -0
- package/dist/schemas/onchain_operations_guard.schema.json +579 -1
- package/dist/schemas/onchain_operations_machine.schema.json +5 -4
- package/dist/schemas/onchain_operations_order.schema.json +7 -6
- package/dist/schemas/onchain_operations_payment.schema.json +2 -1
- package/dist/schemas/onchain_operations_permission.schema.json +3 -2
- package/dist/schemas/onchain_operations_personal.schema.json +37 -0
- package/dist/schemas/onchain_operations_progress.schema.json +91 -4
- package/dist/schemas/onchain_operations_proof.schema.json +2 -1
- package/dist/schemas/onchain_operations_repository.schema.json +4 -3
- package/dist/schemas/onchain_operations_reward.schema.json +7 -6
- package/dist/schemas/onchain_operations_service.schema.json +80 -19
- package/dist/schemas/onchain_operations_treasury.schema.json +5 -4
- package/dist/schemas/onchain_table_data.output.json +1 -1
- package/dist/schemas/onchain_table_data.schema.json +10 -9
- package/dist/schemas/project_operation.output.json +3318 -57
- package/dist/schemas/project_operation.schema.json +728 -4
- package/dist/schemas/query_toolkit.output.json +16 -16
- package/dist/schemas/query_toolkit.schema.json +40 -3
- package/dist/schemas/schema_query.output.json +65 -2
- package/dist/schemas/schema_query.schema.json +31 -5
- package/dist/schemas/trust_score.output.json +392 -1
- package/dist/schemas/trust_score.schema.json +275 -1
- package/dist/schemas/wowok_buildin_info.output.json +81 -8
- package/dist/schemas/wowok_buildin_info.schema.json +46 -2
- package/dist/tools/handlers/onchain.js +636 -6
- package/dist/tools/handlers/project.js +71 -2
- package/dist/tools/handlers/query.js +117 -2
- package/dist/tools/handlers/schema-query.js +65 -1
- package/dist/tools/handlers/trust.js +192 -6
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.js +229 -15
- package/dist/tools/wrap.js +194 -15
- package/package.json +2 -2
package/dist/tools/wrap.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
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";
|
|
3
|
+
import { shouldRunLightHooks, shouldRunHeavyHooks, recordOperationFailure, recordCriticalRisk, recordCriticalOperation, recordSubstepFailure, } from "../harness/auto-escalation.js";
|
|
4
|
+
import { getHarnessTier, setHarnessTier } from "../config/runtime.js";
|
|
4
5
|
import { getHarness } from "../harness/index.js";
|
|
5
6
|
import { recordOperationOutcome } from "../experience/index.js";
|
|
6
7
|
import { recordIndustrySignal } from "../knowledge/flywheel-loop.js";
|
|
7
8
|
import { getStageCache } from "../project/index.js";
|
|
9
|
+
import { extractAmount, getAmountThreshold, formatAmount } from "../knowledge/safety-rules.js";
|
|
8
10
|
export function withTimeout(promise, timeoutMs = 30000, operationName = "operation") {
|
|
9
11
|
let timer;
|
|
10
12
|
return Promise.race([
|
|
@@ -59,13 +61,6 @@ export const strictStatusErrorShape = (error, _classified, _ctx) => ({
|
|
|
59
61
|
result: { status: "error", error },
|
|
60
62
|
});
|
|
61
63
|
function checkProjectStage(action, project, version) {
|
|
62
|
-
const entry = getStageCache(project, version);
|
|
63
|
-
if (!entry) {
|
|
64
|
-
if (action === "analyze_intent" || action === "get_project_status") {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
return `project_stage: calling '${action}' before 'analyze_intent' — recommend calling analyze_intent first for project '${project}:${version}'`;
|
|
68
|
-
}
|
|
69
64
|
const stageOrder = {
|
|
70
65
|
analyze_intent: 2,
|
|
71
66
|
aggregate_risks: 3,
|
|
@@ -75,6 +70,13 @@ function checkProjectStage(action, project, version) {
|
|
|
75
70
|
const requiredStage = stageOrder[action];
|
|
76
71
|
if (!requiredStage)
|
|
77
72
|
return null;
|
|
73
|
+
const entry = getStageCache(project, version);
|
|
74
|
+
if (!entry) {
|
|
75
|
+
if (action === "analyze_intent") {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
return `project_stage: calling '${action}' before 'analyze_intent' — recommend calling analyze_intent first for project '${project}:${version}'`;
|
|
79
|
+
}
|
|
78
80
|
if (entry.stage < requiredStage - 1) {
|
|
79
81
|
return `project_stage: calling '${action}' (stage ${requiredStage}) but project is at stage ${entry.stage} — recommend completing prior stages first for '${project}:${version}'`;
|
|
80
82
|
}
|
|
@@ -92,8 +94,9 @@ export function dispatchWithHarness(handler, toolName) {
|
|
|
92
94
|
const harness = getHarness();
|
|
93
95
|
const runLight = shouldRunLightHooks();
|
|
94
96
|
const runHeavy = shouldRunHeavyHooks();
|
|
95
|
-
const
|
|
96
|
-
const
|
|
97
|
+
const publishIntent = isPublishOperation(toolName, args);
|
|
98
|
+
const signIntent = isSignOperation(toolName, args);
|
|
99
|
+
const tierNow = getHarnessTier();
|
|
97
100
|
let expectedResult;
|
|
98
101
|
if (runLight) {
|
|
99
102
|
try {
|
|
@@ -123,17 +126,45 @@ export function dispatchWithHarness(handler, toolName) {
|
|
|
123
126
|
catch {
|
|
124
127
|
}
|
|
125
128
|
}
|
|
126
|
-
if (
|
|
129
|
+
if (publishIntent && tierNow === "lightweight") {
|
|
130
|
+
setHarnessTier("full");
|
|
131
|
+
harnessWarnings.push("pre_publish: tier forced to full for publish-class operation (GLM5-21 §3.3)");
|
|
132
|
+
}
|
|
133
|
+
if (publishIntent && tierNow !== "off") {
|
|
127
134
|
try {
|
|
128
|
-
|
|
135
|
+
const check = runPrePublishChecks(toolName, args);
|
|
136
|
+
harnessWarnings.push(...check.warnings);
|
|
137
|
+
if (check.critical.length > 0) {
|
|
138
|
+
for (const c of check.critical) {
|
|
139
|
+
const esc = recordCriticalRisk(c);
|
|
140
|
+
if (esc)
|
|
141
|
+
harnessWarnings.push(`Harness escalated to full tier: ${esc.reason}`);
|
|
142
|
+
}
|
|
143
|
+
return buildHarnessBlockResult("pre_publish", `Publish BLOCKED by Harness pre-publish gate (GLM5-21 V6): ` +
|
|
144
|
+
`${check.critical.length} CRITICAL risk(s) must be resolved before publish.`, check.critical, check.warnings, "immutable_violation", "Fix the CRITICAL risks listed in the message (e.g. rename dispute/refund nodes per R-M1-11, add the entry pair prev_node=\"\"), then retry publish. Nodes/pairs/forwards are immutable after publish — verify via machineNode2file first.");
|
|
145
|
+
}
|
|
129
146
|
}
|
|
130
147
|
catch (e) {
|
|
131
148
|
harnessWarnings.push(`pre_publish hook failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
132
149
|
}
|
|
133
150
|
}
|
|
134
|
-
if (
|
|
151
|
+
if (signIntent && runHeavy) {
|
|
135
152
|
try {
|
|
136
|
-
|
|
153
|
+
const data = extractData(args);
|
|
154
|
+
const amt = data ? extractAmount(data) : null;
|
|
155
|
+
if (amt !== null) {
|
|
156
|
+
const threshold = getAmountThreshold();
|
|
157
|
+
let value = null;
|
|
158
|
+
try {
|
|
159
|
+
value = BigInt(amt);
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
value = null;
|
|
163
|
+
}
|
|
164
|
+
if (value !== null && value > threshold) {
|
|
165
|
+
return buildHarnessBlockResult("pre_sign", `Sign BLOCKED by Harness pre-sign gate (GLM5-21 V7): amount ${formatAmount(value)} WOW exceeds the full-tier threshold ${formatAmount(threshold)} WOW.`, [`amount ${amt} (smallest unit) > threshold ${threshold.toString()} (smallest unit)`], [], "invalid_parameter", "Raise WOWOK_AMOUNT_THRESHOLD to match the intended amount, split the transaction, or reset the harness tier to lightweight (config_operation) after explicit user confirmation.");
|
|
166
|
+
}
|
|
167
|
+
}
|
|
137
168
|
}
|
|
138
169
|
catch (e) {
|
|
139
170
|
harnessWarnings.push(`pre_sign hook failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
@@ -149,6 +180,17 @@ export function dispatchWithHarness(handler, toolName) {
|
|
|
149
180
|
if (escalation) {
|
|
150
181
|
harnessWarnings.push(`Harness escalated to full tier: ${escalation.reason}`);
|
|
151
182
|
}
|
|
183
|
+
if (toolName === "onchain_operations") {
|
|
184
|
+
try {
|
|
185
|
+
const classified = classifyError(errorCode, e);
|
|
186
|
+
if (!classified.retryable && classified.error_code !== "unknown") {
|
|
187
|
+
const esc2 = recordCriticalOperation(toolName, classified.error_code);
|
|
188
|
+
if (esc2)
|
|
189
|
+
harnessWarnings.push(`Harness escalated to full tier: ${esc2.reason}`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
catch { }
|
|
193
|
+
}
|
|
152
194
|
throw e;
|
|
153
195
|
}
|
|
154
196
|
if (runLight && expectedResult) {
|
|
@@ -168,6 +210,34 @@ export function dispatchWithHarness(handler, toolName) {
|
|
|
168
210
|
harnessWarnings.push(`post_call hook failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
169
211
|
}
|
|
170
212
|
}
|
|
213
|
+
if (toolName === "onchain_operations") {
|
|
214
|
+
try {
|
|
215
|
+
if (classifyOutcome(result) === "failed") {
|
|
216
|
+
const errText = extractErrorCode(result) ?? "";
|
|
217
|
+
const classified = classifyError(errText);
|
|
218
|
+
if (!classified.retryable && classified.error_code !== "unknown") {
|
|
219
|
+
const esc = recordCriticalOperation(toolName, classified.error_code);
|
|
220
|
+
if (esc)
|
|
221
|
+
harnessWarnings.push(`Harness escalated to full tier: ${esc.reason}`);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
catch { }
|
|
226
|
+
}
|
|
227
|
+
if (toolName === "project_operation") {
|
|
228
|
+
try {
|
|
229
|
+
const action = args?.action;
|
|
230
|
+
if (action === "generate_deployment_doc" || action === "trace_substeps") {
|
|
231
|
+
const crit = extractCriticalFindingCount(result);
|
|
232
|
+
if (crit > 0) {
|
|
233
|
+
const esc = recordSubstepFailure(`${String(action)}: ${crit} critical finding(s)`);
|
|
234
|
+
if (esc)
|
|
235
|
+
harnessWarnings.push(`Harness escalated to full tier: ${esc.reason}`);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
catch { }
|
|
240
|
+
}
|
|
171
241
|
if (isWriteClassTool(toolName)) {
|
|
172
242
|
try {
|
|
173
243
|
const operationType = extractOperationType(toolName, args) ?? toolName;
|
|
@@ -213,7 +283,10 @@ function isPublishOperation(toolName, args) {
|
|
|
213
283
|
if (toolName !== "onchain_operations")
|
|
214
284
|
return false;
|
|
215
285
|
const opType = extractOperationType(toolName, args);
|
|
216
|
-
|
|
286
|
+
if (opType !== "service" && opType !== "machine")
|
|
287
|
+
return false;
|
|
288
|
+
const data = extractData(args);
|
|
289
|
+
return data?.publish === true || data?.bPublished === true;
|
|
217
290
|
}
|
|
218
291
|
function isSignOperation(toolName, args) {
|
|
219
292
|
if (toolName === "wip_file") {
|
|
@@ -319,3 +392,109 @@ function extractIndustry(args) {
|
|
|
319
392
|
}
|
|
320
393
|
return undefined;
|
|
321
394
|
}
|
|
395
|
+
const ANTI_PATTERN_NODE_REGEX = /(^|_)(disputed?|refund(?:ed)?|arbitration|arb)(_|$)/i;
|
|
396
|
+
function runPrePublishChecks(toolName, args) {
|
|
397
|
+
const critical = [];
|
|
398
|
+
const warnings = [];
|
|
399
|
+
const opType = extractOperationType(toolName, args);
|
|
400
|
+
const data = extractData(args) ?? {};
|
|
401
|
+
if (opType === "machine") {
|
|
402
|
+
const nodeOp = data.node;
|
|
403
|
+
const nodes = Array.isArray(nodeOp)
|
|
404
|
+
? nodeOp
|
|
405
|
+
: Array.isArray(nodeOp?.nodes)
|
|
406
|
+
? nodeOp.nodes
|
|
407
|
+
: [];
|
|
408
|
+
if (nodes.length > 0) {
|
|
409
|
+
for (const n of nodes) {
|
|
410
|
+
const name = typeof n?.name === "string" ? n.name : "";
|
|
411
|
+
if (name && ANTI_PATTERN_NODE_REGEX.test(name)) {
|
|
412
|
+
critical.push(`R-M1-11: machine node "${name}" models dispute/refund flow — ` +
|
|
413
|
+
`refunds must route via an Allocator triggered by business states, ` +
|
|
414
|
+
`disputes via the separate Arbitration object (off-Machine)`);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
const seen = new Set();
|
|
418
|
+
for (const n of nodes) {
|
|
419
|
+
const name = typeof n?.name === "string" ? n.name : "";
|
|
420
|
+
if (!name)
|
|
421
|
+
continue;
|
|
422
|
+
if (seen.has(name)) {
|
|
423
|
+
critical.push(`MC-C-04: duplicate machine node name "${name}" — on-chain will reject the publish transaction`);
|
|
424
|
+
}
|
|
425
|
+
seen.add(name);
|
|
426
|
+
}
|
|
427
|
+
const hasEntry = nodes.some((n) => Array.isArray(n?.pairs) && n.pairs.some((p) => p?.prev_node === ""));
|
|
428
|
+
if (!hasEntry) {
|
|
429
|
+
critical.push(`Machine has no entry pair (prev_node="") — Progress can never advance ` +
|
|
430
|
+
`from the initial state; orders are permanently stuck`);
|
|
431
|
+
}
|
|
432
|
+
for (const n of nodes) {
|
|
433
|
+
const nodeName = typeof n?.name === "string" ? n.name : "?";
|
|
434
|
+
for (const p of n?.pairs ?? []) {
|
|
435
|
+
for (const f of (p?.forwards ?? [])) {
|
|
436
|
+
const hasOp = f?.namedOperator !== undefined && f?.namedOperator !== null;
|
|
437
|
+
const hasIdx = f?.permissionIndex !== undefined && f?.permissionIndex !== null;
|
|
438
|
+
if (!hasOp && !hasIdx) {
|
|
439
|
+
warnings.push(`pre_publish: node "${nodeName}" forward "${String(f?.name ?? "?")}" has neither namedOperator nor permissionIndex — no one can advance it`);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
else {
|
|
446
|
+
warnings.push("pre_publish: publishing machine without inline node data — topology not verifiable in this call; " +
|
|
447
|
+
"verify nodes/pairs/forwards via machineNode2file BEFORE publish (immutable after publish, IMMUT-001)");
|
|
448
|
+
}
|
|
449
|
+
warnings.push("pre_publish: machine nodes/pairs/forwards become immutable after publish (IMMUT-001)");
|
|
450
|
+
}
|
|
451
|
+
if (opType === "service") {
|
|
452
|
+
warnings.push("pre_publish: service machine/order_allocators/arbitrations become immutable after publish (IMMUT-002); sales remains modifiable");
|
|
453
|
+
if (data.machine === undefined) {
|
|
454
|
+
warnings.push("pre_publish: 'machine' not set in this call — if the service was never bound to a published machine, " +
|
|
455
|
+
"it cannot process orders and CANNOT be fixed after publish");
|
|
456
|
+
}
|
|
457
|
+
if (data.order_allocators === undefined) {
|
|
458
|
+
warnings.push("pre_publish: 'order_allocators' not set in this call — immutable after publish; " +
|
|
459
|
+
"orders will have no fund distribution if never configured");
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
return { critical, warnings };
|
|
463
|
+
}
|
|
464
|
+
function buildHarnessBlockResult(gate, reason, critical, warnings, errorCode, recoveryHint) {
|
|
465
|
+
const detail = [
|
|
466
|
+
...critical.map((c) => `CRITICAL: ${c}`),
|
|
467
|
+
...warnings.map((w) => `WARN: ${w}`),
|
|
468
|
+
].join("\n");
|
|
469
|
+
const text = `Error: ${reason}${detail ? `\n${detail}` : ""}\nRecovery: ${recoveryHint}`;
|
|
470
|
+
return {
|
|
471
|
+
content: [{ type: "text", text }],
|
|
472
|
+
structuredContent: {
|
|
473
|
+
result: {
|
|
474
|
+
type: "error",
|
|
475
|
+
error: `${reason} [gate=${gate}]`,
|
|
476
|
+
error_code: errorCode,
|
|
477
|
+
retryable: false,
|
|
478
|
+
recovery_hint: recoveryHint,
|
|
479
|
+
},
|
|
480
|
+
message: text,
|
|
481
|
+
},
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
function extractCriticalFindingCount(result) {
|
|
485
|
+
const sc = result?.structuredContent;
|
|
486
|
+
if (!sc)
|
|
487
|
+
return 0;
|
|
488
|
+
const semantic = sc.semantic;
|
|
489
|
+
const summary = semantic?.summary;
|
|
490
|
+
if (typeof summary?.critical_count === "number" && summary.critical_count > 0) {
|
|
491
|
+
return summary.critical_count;
|
|
492
|
+
}
|
|
493
|
+
const findings = (sc.findings ?? semantic?.findings);
|
|
494
|
+
if (Array.isArray(findings)) {
|
|
495
|
+
return findings.filter((f) => f?.severity === "error").length;
|
|
496
|
+
}
|
|
497
|
+
const text = result?.content?.map((c) => ("text" in c ? c.text : "")).join("\n") ?? "";
|
|
498
|
+
const matches = text.match(/\[AUDIT ERROR\]/g);
|
|
499
|
+
return matches ? matches.length : 0;
|
|
500
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wowok/agent-mcp",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.4",
|
|
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.6.
|
|
53
|
+
"@wowok/wowok": "2.6.4",
|
|
54
54
|
"lodash": "^4.18.1",
|
|
55
55
|
"zod": "^3.25.76",
|
|
56
56
|
"zod-to-json-schema": "^3.25.2"
|