@wowok/agent-mcp 2.4.3 → 2.5.0
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/config/runtime.d.ts +4 -0
- package/dist/config/runtime.js +29 -5
- package/dist/harness/auto-escalation.d.ts +27 -0
- package/dist/harness/auto-escalation.js +68 -0
- package/dist/index.js +21 -0
- package/dist/knowledge/allocation-confirm.d.ts +115 -0
- package/dist/knowledge/allocation-confirm.js +534 -0
- package/dist/knowledge/allocation-context.d.ts +58 -0
- package/dist/knowledge/allocation-context.js +249 -0
- package/dist/knowledge/allocation-ledger.d.ts +67 -0
- package/dist/knowledge/allocation-ledger.js +463 -0
- package/dist/knowledge/allocation-puzzle.d.ts +135 -0
- package/dist/knowledge/allocation-puzzle.js +298 -0
- package/dist/knowledge/allocation-risk.d.ts +78 -0
- package/dist/knowledge/allocation-risk.js +568 -0
- package/dist/knowledge/allocation-templates.d.ts +38 -0
- package/dist/knowledge/allocation-templates.js +970 -0
- package/dist/knowledge/allocation-translation.d.ts +72 -0
- package/dist/knowledge/allocation-translation.js +585 -0
- package/dist/knowledge/arb-risk.d.ts +37 -0
- package/dist/knowledge/arb-risk.js +210 -0
- package/dist/knowledge/arbitration-confirm.d.ts +135 -0
- package/dist/knowledge/arbitration-confirm.js +559 -0
- package/dist/knowledge/arbitration-context.d.ts +81 -0
- package/dist/knowledge/arbitration-context.js +505 -0
- package/dist/knowledge/arbitration-ledger.d.ts +62 -0
- package/dist/knowledge/arbitration-ledger.js +521 -0
- package/dist/knowledge/arbitration-puzzle.d.ts +84 -0
- package/dist/knowledge/arbitration-puzzle.js +304 -0
- package/dist/knowledge/arbitration-risk.d.ts +112 -0
- package/dist/knowledge/arbitration-risk.js +433 -0
- package/dist/knowledge/arbitration-templates.d.ts +38 -0
- package/dist/knowledge/arbitration-templates.js +276 -0
- package/dist/knowledge/arbitration-translation.d.ts +91 -0
- package/dist/knowledge/arbitration-translation.js +487 -0
- package/dist/knowledge/bridge-risk.d.ts +36 -0
- package/dist/knowledge/bridge-risk.js +263 -0
- package/dist/knowledge/contact-risk.d.ts +32 -0
- package/dist/knowledge/contact-risk.js +200 -0
- package/dist/knowledge/demand-confirm.d.ts +32 -0
- package/dist/knowledge/demand-confirm.js +206 -0
- package/dist/knowledge/demand-risk.d.ts +30 -0
- package/dist/knowledge/demand-risk.js +240 -0
- package/dist/knowledge/demand-translation.d.ts +55 -0
- package/dist/knowledge/demand-translation.js +354 -0
- package/dist/knowledge/deployment-scanner.d.ts +63 -0
- package/dist/knowledge/deployment-scanner.js +762 -0
- package/dist/knowledge/examples-scanner-cli.d.ts +1 -0
- package/dist/knowledge/examples-scanner-cli.js +26 -0
- package/dist/knowledge/examples-scanner.d.ts +121 -0
- package/dist/knowledge/examples-scanner.js +825 -0
- package/dist/knowledge/flywheel-loop.d.ts +3 -0
- package/dist/knowledge/flywheel-loop.js +32 -3
- package/dist/knowledge/glossary.js +3 -1
- package/dist/knowledge/guard-confirm.d.ts +86 -0
- package/dist/knowledge/guard-confirm.js +406 -0
- package/dist/knowledge/guard-context.d.ts +56 -0
- package/dist/knowledge/guard-context.js +287 -0
- package/dist/knowledge/guard-design-patterns.d.ts +37 -0
- package/dist/knowledge/guard-design-patterns.js +257 -0
- package/dist/knowledge/guard-puzzle.js +3 -2
- package/dist/knowledge/guard-risk.d.ts +1 -1
- package/dist/knowledge/guard-risk.js +12 -14
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/guard-translation.js +6 -5
- package/dist/knowledge/index.d.ts +342 -0
- package/dist/knowledge/index.js +344 -0
- package/dist/knowledge/machine-confirm.d.ts +102 -0
- package/dist/knowledge/machine-confirm.js +559 -0
- package/dist/knowledge/machine-context.d.ts +160 -0
- package/dist/knowledge/machine-context.js +812 -0
- package/dist/knowledge/machine-ledger.d.ts +41 -0
- package/dist/knowledge/machine-ledger.js +315 -0
- package/dist/knowledge/machine-puzzle.d.ts +206 -0
- package/dist/knowledge/machine-puzzle.js +494 -0
- package/dist/knowledge/machine-risk.d.ts +75 -0
- package/dist/knowledge/machine-risk.js +644 -0
- package/dist/knowledge/machine-templates.d.ts +92 -0
- package/dist/knowledge/machine-templates.js +1592 -0
- package/dist/knowledge/machine-topology.d.ts +57 -0
- package/dist/knowledge/machine-topology.js +234 -0
- package/dist/knowledge/machine-translation.d.ts +96 -0
- package/dist/knowledge/machine-translation.js +513 -0
- package/dist/knowledge/mcp-schema-audit-cli.d.ts +1 -0
- package/dist/knowledge/mcp-schema-audit-cli.js +45 -0
- package/dist/knowledge/mcp-schema-audit.d.ts +90 -0
- package/dist/knowledge/mcp-schema-audit.js +772 -0
- package/dist/knowledge/onchain-constants.d.ts +4 -0
- package/dist/knowledge/onchain-constants.js +35 -0
- package/dist/knowledge/order-confirm.d.ts +115 -0
- package/dist/knowledge/order-confirm.js +573 -0
- package/dist/knowledge/order-context.d.ts +66 -0
- package/dist/knowledge/order-context.js +390 -0
- package/dist/knowledge/order-ledger.d.ts +69 -0
- package/dist/knowledge/order-ledger.js +341 -0
- package/dist/knowledge/order-puzzle.d.ts +159 -0
- package/dist/knowledge/order-puzzle.js +255 -0
- package/dist/knowledge/order-risk.d.ts +66 -0
- package/dist/knowledge/order-risk.js +653 -0
- package/dist/knowledge/order-templates.d.ts +50 -0
- package/dist/knowledge/order-templates.js +368 -0
- package/dist/knowledge/order-translation.d.ts +78 -0
- package/dist/knowledge/order-translation.js +550 -0
- package/dist/knowledge/passport-confirm.d.ts +130 -0
- package/dist/knowledge/passport-confirm.js +531 -0
- package/dist/knowledge/passport-context.d.ts +59 -0
- package/dist/knowledge/passport-context.js +306 -0
- package/dist/knowledge/passport-ledger.d.ts +48 -0
- package/dist/knowledge/passport-ledger.js +282 -0
- package/dist/knowledge/passport-puzzle.d.ts +108 -0
- package/dist/knowledge/passport-puzzle.js +333 -0
- package/dist/knowledge/passport-risk.d.ts +70 -0
- package/dist/knowledge/passport-risk.js +450 -0
- package/dist/knowledge/passport-templates.d.ts +40 -0
- package/dist/knowledge/passport-templates.js +568 -0
- package/dist/knowledge/passport-translation.d.ts +68 -0
- package/dist/knowledge/passport-translation.js +516 -0
- package/dist/knowledge/payment-risk.d.ts +33 -0
- package/dist/knowledge/payment-risk.js +182 -0
- package/dist/knowledge/permission-confirm.d.ts +110 -0
- package/dist/knowledge/permission-confirm.js +426 -0
- package/dist/knowledge/permission-context.d.ts +58 -0
- package/dist/knowledge/permission-context.js +224 -0
- package/dist/knowledge/permission-ledger.d.ts +38 -0
- package/dist/knowledge/permission-ledger.js +403 -0
- package/dist/knowledge/permission-puzzle.d.ts +122 -0
- package/dist/knowledge/permission-puzzle.js +173 -0
- package/dist/knowledge/permission-risk.d.ts +76 -0
- package/dist/knowledge/permission-risk.js +411 -0
- package/dist/knowledge/permission-templates.d.ts +38 -0
- package/dist/knowledge/permission-templates.js +234 -0
- package/dist/knowledge/permission-translation.d.ts +57 -0
- package/dist/knowledge/permission-translation.js +350 -0
- package/dist/knowledge/personal-risk.d.ts +36 -0
- package/dist/knowledge/personal-risk.js +212 -0
- package/dist/knowledge/progress-confirm.d.ts +108 -0
- package/dist/knowledge/progress-confirm.js +456 -0
- package/dist/knowledge/progress-context.d.ts +123 -0
- package/dist/knowledge/progress-context.js +452 -0
- package/dist/knowledge/progress-ledger.d.ts +63 -0
- package/dist/knowledge/progress-ledger.js +327 -0
- package/dist/knowledge/progress-puzzle.d.ts +82 -0
- package/dist/knowledge/progress-puzzle.js +219 -0
- package/dist/knowledge/progress-risk.d.ts +74 -0
- package/dist/knowledge/progress-risk.js +461 -0
- package/dist/knowledge/progress-templates.d.ts +38 -0
- package/dist/knowledge/progress-templates.js +228 -0
- package/dist/knowledge/progress-translation.d.ts +52 -0
- package/dist/knowledge/progress-translation.js +401 -0
- package/dist/knowledge/proof-confirm.d.ts +31 -0
- package/dist/knowledge/proof-confirm.js +187 -0
- package/dist/knowledge/proof-risk.d.ts +33 -0
- package/dist/knowledge/proof-risk.js +207 -0
- package/dist/knowledge/proof-translation.d.ts +52 -0
- package/dist/knowledge/proof-translation.js +283 -0
- package/dist/knowledge/registrar-risk.d.ts +34 -0
- package/dist/knowledge/registrar-risk.js +217 -0
- package/dist/knowledge/repository-confirm.d.ts +36 -0
- package/dist/knowledge/repository-confirm.js +242 -0
- package/dist/knowledge/repository-risk.d.ts +40 -0
- package/dist/knowledge/repository-risk.js +312 -0
- package/dist/knowledge/repository-translation.d.ts +58 -0
- package/dist/knowledge/repository-translation.js +422 -0
- package/dist/knowledge/resource-risk.d.ts +32 -0
- package/dist/knowledge/resource-risk.js +157 -0
- package/dist/knowledge/reward-confirm.d.ts +113 -0
- package/dist/knowledge/reward-confirm.js +496 -0
- package/dist/knowledge/reward-context.d.ts +127 -0
- package/dist/knowledge/reward-context.js +504 -0
- package/dist/knowledge/reward-ledger.d.ts +96 -0
- package/dist/knowledge/reward-ledger.js +502 -0
- package/dist/knowledge/reward-puzzle.d.ts +97 -0
- package/dist/knowledge/reward-puzzle.js +288 -0
- package/dist/knowledge/reward-risk.d.ts +84 -0
- package/dist/knowledge/reward-risk.js +545 -0
- package/dist/knowledge/reward-translation.d.ts +58 -0
- package/dist/knowledge/reward-translation.js +501 -0
- package/dist/knowledge/safety-rules.js +11 -3
- package/dist/knowledge/scenario-modes.d.ts +53 -0
- package/dist/knowledge/scenario-modes.js +302 -0
- package/dist/knowledge/service-confirm.d.ts +152 -0
- package/dist/knowledge/service-confirm.js +699 -0
- package/dist/knowledge/service-context.d.ts +66 -0
- package/dist/knowledge/service-context.js +403 -0
- package/dist/knowledge/service-ledger.d.ts +71 -0
- package/dist/knowledge/service-ledger.js +609 -0
- package/dist/knowledge/service-puzzle.d.ts +158 -0
- package/dist/knowledge/service-puzzle.js +236 -0
- package/dist/knowledge/service-risk.d.ts +108 -0
- package/dist/knowledge/service-risk.js +615 -0
- package/dist/knowledge/service-templates.d.ts +39 -0
- package/dist/knowledge/service-templates.js +418 -0
- package/dist/knowledge/service-translation.d.ts +103 -0
- package/dist/knowledge/service-translation.js +622 -0
- package/dist/knowledge/tools-reference.d.ts +17 -0
- package/dist/knowledge/tools-reference.js +151 -0
- package/dist/knowledge/treasury-confirm.d.ts +133 -0
- package/dist/knowledge/treasury-confirm.js +512 -0
- package/dist/knowledge/treasury-context.d.ts +64 -0
- package/dist/knowledge/treasury-context.js +363 -0
- package/dist/knowledge/treasury-ledger.d.ts +42 -0
- package/dist/knowledge/treasury-ledger.js +300 -0
- package/dist/knowledge/treasury-puzzle.d.ts +163 -0
- package/dist/knowledge/treasury-puzzle.js +216 -0
- package/dist/knowledge/treasury-risk.d.ts +86 -0
- package/dist/knowledge/treasury-risk.js +440 -0
- package/dist/knowledge/treasury-templates.d.ts +38 -0
- package/dist/knowledge/treasury-templates.js +316 -0
- package/dist/knowledge/treasury-translation.d.ts +78 -0
- package/dist/knowledge/treasury-translation.js +498 -0
- package/dist/knowledge/util-risk.d.ts +30 -0
- package/dist/knowledge/util-risk.js +135 -0
- package/dist/project/business-puzzle.d.ts +47 -0
- package/dist/project/business-puzzle.js +372 -0
- package/dist/project/deployment-doc.d.ts +61 -0
- package/dist/project/deployment-doc.js +432 -0
- package/dist/project/risk-aggregator.d.ts +50 -0
- package/dist/project/risk-aggregator.js +280 -0
- package/dist/project/substep-trace.d.ts +130 -0
- package/dist/project/substep-trace.js +332 -0
- package/dist/schema/call/allocation.d.ts +34 -34
- package/dist/schema/call/arbitration.d.ts +141 -141
- package/dist/schema/call/base.d.ts +386 -386
- package/dist/schema/call/base.js +3 -3
- package/dist/schema/call/bridge-handler.d.ts +5 -2
- package/dist/schema/call/bridge.d.ts +159 -159
- package/dist/schema/call/contact.d.ts +110 -110
- package/dist/schema/call/demand.d.ts +76 -76
- package/dist/schema/call/handler.d.ts +2 -3
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/machine.d.ts +58 -58
- package/dist/schema/call/order.d.ts +98 -110
- package/dist/schema/call/permission-handler.d.ts +5 -0
- package/dist/schema/call/permission-handler.js +54 -0
- package/dist/schema/call/permission.d.ts +108 -108
- package/dist/schema/call/personal.d.ts +14 -14
- package/dist/schema/call/progress.d.ts +57 -72
- package/dist/schema/call/progress.js +7 -4
- package/dist/schema/call/proof.d.ts +18 -18
- package/dist/schema/call/proof.js +12 -7
- package/dist/schema/call/repository.d.ts +154 -154
- package/dist/schema/call/reward.d.ts +55 -55
- package/dist/schema/call/service.d.ts +231 -231
- package/dist/schema/call/treasury.d.ts +93 -93
- package/dist/schema/config/index.d.ts +178 -5
- package/dist/schema/config/index.js +52 -1
- package/dist/schema/local/index.d.ts +3554 -836
- package/dist/schema/local/index.js +2 -1
- package/dist/schema/messenger/index.d.ts +162 -162
- package/dist/schema/operations.d.ts +1058 -1074
- package/dist/schema/operations.js +7 -1
- package/dist/schema/project/index.d.ts +1392 -6
- package/dist/schema/project/index.js +426 -2
- package/dist/schema/query/index.d.ts +672 -672
- package/dist/schema/schema-query/index.d.ts +23 -3
- package/dist/schema/schema-query/index.js +13 -2
- package/dist/schema/sync-layer4.d.ts +21 -0
- package/dist/schema/sync-layer4.js +261 -0
- package/dist/schema/trust/index.d.ts +26 -26
- package/dist/schemas/account_operation.output.json +718 -0
- package/dist/schemas/config_operation.output.json +173 -0
- package/dist/schemas/index.json +9 -1
- package/dist/schemas/local_info_operation.output.json +718 -0
- package/dist/schemas/local_mark_operation.output.json +718 -0
- package/dist/schemas/onchain_operations.output.json +3 -2
- package/dist/schemas/onchain_operations.schema.json +1802 -313
- package/dist/schemas/onchain_operations_allocation.schema.json +2 -1
- package/dist/schemas/onchain_operations_arbitration.schema.json +2 -1
- package/dist/schemas/onchain_operations_contact.schema.json +2 -1
- package/dist/schemas/onchain_operations_demand.schema.json +2 -1
- package/dist/schemas/onchain_operations_gen_passport.schema.json +878 -872
- package/dist/schemas/onchain_operations_gen_proof.schema.json +273 -0
- package/dist/schemas/onchain_operations_guard.schema.json +584 -70
- package/dist/schemas/onchain_operations_machine.schema.json +2 -1
- package/dist/schemas/onchain_operations_order.schema.json +13 -9
- package/dist/schemas/onchain_operations_payment.schema.json +2 -1
- package/dist/schemas/onchain_operations_permission.schema.json +2 -1
- package/dist/schemas/onchain_operations_personal.schema.json +2 -1
- package/dist/schemas/onchain_operations_progress.schema.json +14 -10
- package/dist/schemas/onchain_operations_proof.schema.json +699 -0
- package/dist/schemas/onchain_operations_repository.schema.json +2 -1
- package/dist/schemas/onchain_operations_reward.schema.json +2 -1
- package/dist/schemas/onchain_operations_service.schema.json +2 -1
- package/dist/schemas/onchain_operations_treasury.schema.json +2 -1
- package/dist/schemas/onchain_table_data.schema.json +32 -1
- package/dist/schemas/project_operation.output.json +879 -0
- package/dist/schemas/project_operation.schema.json +473 -2
- package/dist/schemas/query_toolkit.output.json +14906 -6
- package/dist/schemas/schema_query.output.json +38 -1
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/tools/handlers/config.d.ts +1 -1
- package/dist/tools/handlers/config.js +21 -18
- package/dist/tools/handlers/file-export.d.ts +2 -2
- package/dist/tools/handlers/local.d.ts +3 -30
- package/dist/tools/handlers/local.js +14 -3
- package/dist/tools/handlers/messenger.d.ts +1 -1
- package/dist/tools/handlers/messenger.js +2 -1
- package/dist/tools/handlers/onchain.d.ts +1 -1
- package/dist/tools/handlers/onchain.js +24 -22
- package/dist/tools/handlers/project.d.ts +1 -1
- package/dist/tools/handlers/project.js +258 -18
- package/dist/tools/handlers/query.d.ts +4 -4
- package/dist/tools/handlers/schema-query.d.ts +1 -1
- package/dist/tools/handlers/schema-query.js +21 -20
- package/dist/tools/handlers/trust.d.ts +1 -1
- package/dist/tools/handlers/trust.js +2 -2
- package/dist/tools/handlers/wip.d.ts +1 -1
- package/dist/tools/handlers/wip.js +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +55 -8
- package/dist/tools/rules-hook.d.ts +1 -1
- package/dist/tools/rules-hook.js +3 -2
- package/dist/tools/shared.d.ts +13 -22
- package/dist/tools/types.d.ts +5 -5
- package/dist/tools/wrap.d.ts +10 -2
- package/dist/tools/wrap.js +212 -0
- package/package.json +3 -3
package/dist/tools/types.d.ts
CHANGED
|
@@ -12,23 +12,23 @@ export interface ToolConfig {
|
|
|
12
12
|
idempotentHint?: boolean;
|
|
13
13
|
openWorldHint?: boolean;
|
|
14
14
|
};
|
|
15
|
-
_meta?:
|
|
15
|
+
_meta?: Record<string, unknown>;
|
|
16
16
|
}
|
|
17
|
-
export type ErrorShapeBuilder = (error: string, classified: ReturnType<typeof classifyError>, ctx: SemanticContext) => Record<string,
|
|
17
|
+
export type ErrorShapeBuilder = (error: string, classified: ReturnType<typeof classifyError>, ctx: SemanticContext) => Record<string, unknown>;
|
|
18
18
|
export interface ToolDispatchResult {
|
|
19
19
|
content: {
|
|
20
20
|
type: "text";
|
|
21
21
|
text: string;
|
|
22
22
|
}[];
|
|
23
|
-
structuredContent:
|
|
23
|
+
structuredContent: Record<string, unknown> | undefined;
|
|
24
24
|
}
|
|
25
25
|
export interface ToolEntry {
|
|
26
26
|
name: string;
|
|
27
|
-
handler: (args:
|
|
27
|
+
handler: (args: unknown) => Promise<ToolDispatchResult>;
|
|
28
28
|
config: ToolConfig;
|
|
29
29
|
errorShapeBuilder?: ErrorShapeBuilder;
|
|
30
30
|
timeoutMs?: number;
|
|
31
|
-
applyRules?: (args:
|
|
31
|
+
applyRules?: (args: unknown) => ToolDispatchResult | null;
|
|
32
32
|
}
|
|
33
33
|
export interface DispatchOptions {
|
|
34
34
|
skipRules?: boolean;
|
package/dist/tools/wrap.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import type { ErrorShapeBuilder } from "./types.js";
|
|
1
|
+
import type { ErrorShapeBuilder, ToolDispatchResult } from "./types.js";
|
|
2
2
|
export declare function withTimeout<T>(promise: Promise<T>, timeoutMs?: number, operationName?: string): Promise<T>;
|
|
3
|
-
export declare function wrapHandlerWithErrorShape(handler: (args:
|
|
3
|
+
export declare function wrapHandlerWithErrorShape(handler: (args: unknown) => Promise<ToolDispatchResult>, timeoutMs: number, toolName: string, errorShapeBuilder?: ErrorShapeBuilder): (args: unknown) => Promise<ToolDispatchResult>;
|
|
4
4
|
export declare const statusErrorShape: ErrorShapeBuilder;
|
|
5
5
|
export declare const operationErrorShape: ErrorShapeBuilder;
|
|
6
6
|
export declare const strictStatusErrorShape: ErrorShapeBuilder;
|
|
7
|
+
export type HarnessHookPhase = "pre_call" | "post_call" | "pre_publish" | "pre_sign";
|
|
8
|
+
export interface HarnessHookContext {
|
|
9
|
+
toolName: string;
|
|
10
|
+
args: unknown;
|
|
11
|
+
result?: ToolDispatchResult;
|
|
12
|
+
error?: unknown;
|
|
13
|
+
}
|
|
14
|
+
export declare function dispatchWithHarness(handler: (args: unknown) => Promise<ToolDispatchResult>, toolName: string): (args: unknown) => Promise<ToolDispatchResult>;
|
package/dist/tools/wrap.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { classifyError, buildDataSemantic, } from "../schema/call/semantic.js";
|
|
2
2
|
import { buildClassifiedErrorResult } from "./shared.js";
|
|
3
|
+
import { shouldRunLightHooks, shouldRunHeavyHooks, recordOperationFailure, } from "../harness/auto-escalation.js";
|
|
4
|
+
import { getHarness } from "../harness/index.js";
|
|
5
|
+
import { recordOperationOutcome } from "../experience/index.js";
|
|
6
|
+
import { recordIndustrySignal } from "../knowledge/flywheel-loop.js";
|
|
3
7
|
export function withTimeout(promise, timeoutMs = 30000, operationName = "operation") {
|
|
4
8
|
let timer;
|
|
5
9
|
return Promise.race([
|
|
@@ -53,3 +57,211 @@ export const operationErrorShape = (error, classified, ctx) => ({
|
|
|
53
57
|
export const strictStatusErrorShape = (error, _classified, _ctx) => ({
|
|
54
58
|
result: { status: "error", error },
|
|
55
59
|
});
|
|
60
|
+
export function dispatchWithHarness(handler, toolName) {
|
|
61
|
+
return async (args) => {
|
|
62
|
+
const harnessWarnings = [];
|
|
63
|
+
const harness = getHarness();
|
|
64
|
+
const runLight = shouldRunLightHooks();
|
|
65
|
+
const runHeavy = shouldRunHeavyHooks();
|
|
66
|
+
const isPublishOp = runHeavy && isPublishOperation(toolName, args);
|
|
67
|
+
const isSignOp = runHeavy && isSignOperation(toolName, args);
|
|
68
|
+
let expectedResult;
|
|
69
|
+
if (runLight) {
|
|
70
|
+
try {
|
|
71
|
+
const operationType = extractOperationType(toolName, args);
|
|
72
|
+
const intent = extractIntent(toolName, args);
|
|
73
|
+
if (operationType && intent) {
|
|
74
|
+
expectedResult = harness.expect(toolName, intent, operationType, extractData(args));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
harnessWarnings.push(`pre_call hook failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (isPublishOp) {
|
|
82
|
+
try {
|
|
83
|
+
harnessWarnings.push("pre_publish: full-tier check engaged");
|
|
84
|
+
}
|
|
85
|
+
catch (e) {
|
|
86
|
+
harnessWarnings.push(`pre_publish hook failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (isSignOp) {
|
|
90
|
+
try {
|
|
91
|
+
harnessWarnings.push("pre_sign: full-tier check engaged");
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
harnessWarnings.push(`pre_sign hook failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
let result;
|
|
98
|
+
try {
|
|
99
|
+
result = await handler(args);
|
|
100
|
+
}
|
|
101
|
+
catch (e) {
|
|
102
|
+
const errorCode = e instanceof Error ? e.message : String(e);
|
|
103
|
+
const escalation = recordOperationFailure(toolName, errorCode);
|
|
104
|
+
if (escalation) {
|
|
105
|
+
harnessWarnings.push(`Harness escalated to full tier: ${escalation.reason}`);
|
|
106
|
+
}
|
|
107
|
+
throw e;
|
|
108
|
+
}
|
|
109
|
+
if (runLight && expectedResult) {
|
|
110
|
+
try {
|
|
111
|
+
if (result?.structuredContent) {
|
|
112
|
+
const verifyInput = buildVerifyInput(expectedResult, result);
|
|
113
|
+
const report = harness.verify(verifyInput);
|
|
114
|
+
if (report.status === "fail") {
|
|
115
|
+
harnessWarnings.push(`Harness verify FAIL: ${report.summary}`);
|
|
116
|
+
}
|
|
117
|
+
else if (report.status === "warn") {
|
|
118
|
+
harnessWarnings.push(`Harness verify WARN: ${report.summary}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch (e) {
|
|
123
|
+
harnessWarnings.push(`post_call hook failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (isWriteClassTool(toolName)) {
|
|
127
|
+
try {
|
|
128
|
+
const operationType = extractOperationType(toolName, args) ?? toolName;
|
|
129
|
+
const intent = extractIntent(toolName, args) ?? toolName;
|
|
130
|
+
const data = extractData(args) ?? args;
|
|
131
|
+
const outcome = classifyOutcome(result);
|
|
132
|
+
const errorCode = extractErrorCode(result);
|
|
133
|
+
const industry = extractIndustry(args) ?? "general";
|
|
134
|
+
recordOperationOutcome(operationType, data, intent, outcome, errorCode);
|
|
135
|
+
recordIndustrySignal(industry, { type: operationType }, {
|
|
136
|
+
success: outcome === "success",
|
|
137
|
+
error_code: errorCode,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
catch (e) {
|
|
141
|
+
harnessWarnings.push(`signal collection failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (harnessWarnings.length > 0 && result?.structuredContent) {
|
|
145
|
+
const sc = result.structuredContent;
|
|
146
|
+
const semantic = sc.semantic;
|
|
147
|
+
if (semantic) {
|
|
148
|
+
const existing = Array.isArray(semantic.harness_warnings) ? semantic.harness_warnings : [];
|
|
149
|
+
semantic.harness_warnings = [...existing, ...harnessWarnings];
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
sc.harness_warnings = harnessWarnings;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return result;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function isPublishOperation(toolName, args) {
|
|
159
|
+
if (toolName !== "onchain_operations")
|
|
160
|
+
return false;
|
|
161
|
+
const opType = extractOperationType(toolName, args);
|
|
162
|
+
return opType === "service" || opType === "machine";
|
|
163
|
+
}
|
|
164
|
+
function isSignOperation(toolName, args) {
|
|
165
|
+
if (toolName === "wip_file") {
|
|
166
|
+
const data = args?.operation_type;
|
|
167
|
+
return data === "sign";
|
|
168
|
+
}
|
|
169
|
+
return toolName === "onchain_operations";
|
|
170
|
+
}
|
|
171
|
+
function extractOperationType(toolName, args) {
|
|
172
|
+
if (!args || typeof args !== "object")
|
|
173
|
+
return undefined;
|
|
174
|
+
const obj = args;
|
|
175
|
+
if (toolName === "onchain_operations") {
|
|
176
|
+
return typeof obj.operation_type === "string" ? obj.operation_type : undefined;
|
|
177
|
+
}
|
|
178
|
+
if (toolName === "project_operation") {
|
|
179
|
+
return typeof obj.action === "string" ? obj.action : undefined;
|
|
180
|
+
}
|
|
181
|
+
return typeof obj.operation_type === "string" ? obj.operation_type : undefined;
|
|
182
|
+
}
|
|
183
|
+
function extractIntent(toolName, args) {
|
|
184
|
+
if (!args || typeof args !== "object")
|
|
185
|
+
return undefined;
|
|
186
|
+
const obj = args;
|
|
187
|
+
if (toolName === "project_operation" && typeof obj.action === "string") {
|
|
188
|
+
return `project:${obj.action}`;
|
|
189
|
+
}
|
|
190
|
+
const opType = obj.operation_type;
|
|
191
|
+
if (typeof opType === "string")
|
|
192
|
+
return `${toolName}:${opType}`;
|
|
193
|
+
return toolName;
|
|
194
|
+
}
|
|
195
|
+
function extractData(args) {
|
|
196
|
+
if (!args || typeof args !== "object")
|
|
197
|
+
return undefined;
|
|
198
|
+
const obj = args;
|
|
199
|
+
const data = obj.data;
|
|
200
|
+
return data && typeof data === "object" ? data : undefined;
|
|
201
|
+
}
|
|
202
|
+
function buildVerifyInput(expected, result) {
|
|
203
|
+
const sc = (result.structuredContent ?? {});
|
|
204
|
+
const semantic = sc.semantic;
|
|
205
|
+
return {
|
|
206
|
+
expected,
|
|
207
|
+
actual: {
|
|
208
|
+
result_type: typeof sc.result_type === "string" ? sc.result_type : undefined,
|
|
209
|
+
semantic,
|
|
210
|
+
error_code: typeof sc.error_code === "string" ? sc.error_code : undefined,
|
|
211
|
+
error: typeof sc.error === "string" ? sc.error : undefined,
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
const WRITE_CLASS_TOOLS = new Set([
|
|
216
|
+
"onchain_operations",
|
|
217
|
+
"project_operation",
|
|
218
|
+
"wip_file",
|
|
219
|
+
"messenger_operation",
|
|
220
|
+
"bridge_operation",
|
|
221
|
+
]);
|
|
222
|
+
function isWriteClassTool(toolName) {
|
|
223
|
+
return WRITE_CLASS_TOOLS.has(toolName);
|
|
224
|
+
}
|
|
225
|
+
function classifyOutcome(result) {
|
|
226
|
+
if (!result?.structuredContent)
|
|
227
|
+
return "failed";
|
|
228
|
+
const sc = result.structuredContent;
|
|
229
|
+
const status = typeof sc.status === "string" ? sc.status
|
|
230
|
+
: typeof sc.result_type === "string" ? sc.result_type
|
|
231
|
+
: "";
|
|
232
|
+
if (status === "error" || status === "failed")
|
|
233
|
+
return "failed";
|
|
234
|
+
if (status === "partial")
|
|
235
|
+
return "partial";
|
|
236
|
+
return "success";
|
|
237
|
+
}
|
|
238
|
+
function extractErrorCode(result) {
|
|
239
|
+
if (!result?.structuredContent)
|
|
240
|
+
return undefined;
|
|
241
|
+
const sc = result.structuredContent;
|
|
242
|
+
if (typeof sc.error_code === "string")
|
|
243
|
+
return sc.error_code;
|
|
244
|
+
const err = sc.error;
|
|
245
|
+
if (typeof err === "string")
|
|
246
|
+
return err;
|
|
247
|
+
if (err && typeof err === "object") {
|
|
248
|
+
const code = err.code;
|
|
249
|
+
if (typeof code === "string")
|
|
250
|
+
return code;
|
|
251
|
+
}
|
|
252
|
+
return undefined;
|
|
253
|
+
}
|
|
254
|
+
function extractIndustry(args) {
|
|
255
|
+
if (!args || typeof args !== "object")
|
|
256
|
+
return undefined;
|
|
257
|
+
const obj = args;
|
|
258
|
+
if (typeof obj.industry === "string")
|
|
259
|
+
return obj.industry;
|
|
260
|
+
const data = obj.data;
|
|
261
|
+
if (data && typeof data === "object") {
|
|
262
|
+
const d = data;
|
|
263
|
+
if (typeof d.industry === "string")
|
|
264
|
+
return d.industry;
|
|
265
|
+
}
|
|
266
|
+
return undefined;
|
|
267
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wowok/agent-mcp",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
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.
|
|
53
|
+
"@wowok/wowok": "2.5.0",
|
|
54
54
|
"lodash": "^4.18.1",
|
|
55
55
|
"zod": "^3.25.76",
|
|
56
56
|
"zod-to-json-schema": "^3.25.2"
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"build": "tsc && pnpm generate:schemas",
|
|
67
67
|
"watch": "tsc --watch",
|
|
68
68
|
"start": "tsx src/index.ts",
|
|
69
|
-
"generate:schemas": "tsx scripts/generate-json-schemas.ts",
|
|
69
|
+
"generate:schemas": "node --max-old-space-size=4096 --import tsx/esm scripts/generate-json-schemas.ts",
|
|
70
70
|
"test": "vitest run",
|
|
71
71
|
"test:watch": "vitest"
|
|
72
72
|
}
|