@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
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export interface MachineNode {
|
|
2
|
+
name: string;
|
|
3
|
+
description?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface MachineForward {
|
|
6
|
+
name: string;
|
|
7
|
+
weight: number;
|
|
8
|
+
named_operator?: string;
|
|
9
|
+
permission_index?: number;
|
|
10
|
+
guard?: string;
|
|
11
|
+
retained_submission?: string | string[] | number[];
|
|
12
|
+
}
|
|
13
|
+
export interface MachinePair {
|
|
14
|
+
prev_node: string;
|
|
15
|
+
next_node: string;
|
|
16
|
+
threshold: number;
|
|
17
|
+
forwards: MachineForward[];
|
|
18
|
+
}
|
|
19
|
+
export interface MachineTopology {
|
|
20
|
+
entry_nodes: string[];
|
|
21
|
+
terminal_nodes: string[];
|
|
22
|
+
orphaned_nodes: string[];
|
|
23
|
+
dead_end_nodes: string[];
|
|
24
|
+
dead_branches: DeadBranch[];
|
|
25
|
+
has_cycles: boolean;
|
|
26
|
+
cycle_nodes: string[][];
|
|
27
|
+
reachability: Map<string, Set<string>>;
|
|
28
|
+
node_count: number;
|
|
29
|
+
pair_count: number;
|
|
30
|
+
forward_count: number;
|
|
31
|
+
within_limits: {
|
|
32
|
+
max_node_count: boolean;
|
|
33
|
+
max_node_pair_count: boolean;
|
|
34
|
+
max_forward_count: boolean;
|
|
35
|
+
max_forward_order_count: boolean;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export interface DeadBranch {
|
|
39
|
+
pair: {
|
|
40
|
+
prev_node: string;
|
|
41
|
+
next_node: string;
|
|
42
|
+
};
|
|
43
|
+
reason: string;
|
|
44
|
+
competing_with: string[];
|
|
45
|
+
}
|
|
46
|
+
import { MAX_NODE_COUNT, MAX_NODE_PAIR_COUNT, MAX_FORWARD_COUNT, MAX_FORWARD_ORDER_COUNT } from "./onchain-constants.js";
|
|
47
|
+
export { MAX_NODE_COUNT, MAX_NODE_PAIR_COUNT, MAX_FORWARD_COUNT, MAX_FORWARD_ORDER_COUNT, };
|
|
48
|
+
export declare function analyzeTopology(nodes: MachineNode[], pairs: MachinePair[]): MachineTopology;
|
|
49
|
+
export declare function detectCycle(nodes: MachineNode[], pairs: MachinePair[]): {
|
|
50
|
+
has_cycles: boolean;
|
|
51
|
+
cycle_nodes: string[][];
|
|
52
|
+
};
|
|
53
|
+
export declare function isReachableFromEntry(node: string, topology: MachineTopology): boolean;
|
|
54
|
+
export declare function getNodesReachingTerminals(topology: MachineTopology): Set<string>;
|
|
55
|
+
export declare function formatTopologySummary(topology: MachineTopology): string;
|
|
56
|
+
export declare function identifyTopologyPattern(pairs: MachinePair[]): string;
|
|
57
|
+
export declare const MACHINE_TOPOLOGY_VERSION = "1.0.0";
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { MAX_NODE_COUNT, MAX_NODE_PAIR_COUNT, MAX_FORWARD_COUNT, MAX_FORWARD_ORDER_COUNT, } from "./onchain-constants.js";
|
|
2
|
+
export { MAX_NODE_COUNT, MAX_NODE_PAIR_COUNT, MAX_FORWARD_COUNT, MAX_FORWARD_ORDER_COUNT, };
|
|
3
|
+
export function analyzeTopology(nodes, pairs) {
|
|
4
|
+
const nodeNames = nodes.map((n) => n.name);
|
|
5
|
+
const nodeSet = new Set(nodeNames);
|
|
6
|
+
const outgoing = new Map();
|
|
7
|
+
const incoming = new Map();
|
|
8
|
+
for (const name of nodeNames) {
|
|
9
|
+
outgoing.set(name, []);
|
|
10
|
+
incoming.set(name, []);
|
|
11
|
+
}
|
|
12
|
+
for (const pair of pairs) {
|
|
13
|
+
if (!outgoing.has(pair.prev_node) && pair.prev_node !== "") {
|
|
14
|
+
outgoing.set(pair.prev_node, []);
|
|
15
|
+
}
|
|
16
|
+
if (!incoming.has(pair.next_node)) {
|
|
17
|
+
incoming.set(pair.next_node, []);
|
|
18
|
+
}
|
|
19
|
+
if (pair.prev_node !== "") {
|
|
20
|
+
outgoing.get(pair.prev_node).push(pair.next_node);
|
|
21
|
+
}
|
|
22
|
+
incoming.get(pair.next_node).push(pair.prev_node);
|
|
23
|
+
}
|
|
24
|
+
const entry_nodes = pairs
|
|
25
|
+
.filter((p) => p.prev_node === "")
|
|
26
|
+
.map((p) => p.next_node)
|
|
27
|
+
.filter((n) => nodeSet.has(n));
|
|
28
|
+
const terminal_nodes = nodeNames.filter((n) => (outgoing.get(n) || []).length === 0);
|
|
29
|
+
const orphaned_nodes = nodeNames.filter((n) => !entry_nodes.includes(n) && (incoming.get(n) || []).length === 0);
|
|
30
|
+
const dead_end_nodes = nodeNames.filter((n) => (outgoing.get(n) || []).length === 0 && !terminal_nodes.includes(n));
|
|
31
|
+
const { has_cycles, cycle_nodes } = detectCycles(nodeNames, pairs);
|
|
32
|
+
const dead_branches = analyzeDeadBranches(pairs);
|
|
33
|
+
const reachability = computeReachability(nodeNames, pairs);
|
|
34
|
+
const totalForwards = pairs.reduce((sum, p) => sum + p.forwards.length, 0);
|
|
35
|
+
const maxForwardsInPair = Math.max(0, ...pairs.map((p) => p.forwards.length));
|
|
36
|
+
const maxRetainedSubmissionsPerForward = Math.max(0, ...pairs.flatMap((p) => p.forwards.map((f) => countRetainedSubmissions(f.retained_submission))));
|
|
37
|
+
const within_limits = {
|
|
38
|
+
max_node_count: nodes.length <= MAX_NODE_COUNT,
|
|
39
|
+
max_node_pair_count: pairs.length <= MAX_NODE_PAIR_COUNT,
|
|
40
|
+
max_forward_count: maxForwardsInPair <= MAX_FORWARD_COUNT,
|
|
41
|
+
max_forward_order_count: maxRetainedSubmissionsPerForward <= MAX_FORWARD_ORDER_COUNT,
|
|
42
|
+
};
|
|
43
|
+
return {
|
|
44
|
+
entry_nodes,
|
|
45
|
+
terminal_nodes,
|
|
46
|
+
orphaned_nodes,
|
|
47
|
+
dead_end_nodes,
|
|
48
|
+
dead_branches,
|
|
49
|
+
has_cycles,
|
|
50
|
+
cycle_nodes,
|
|
51
|
+
reachability,
|
|
52
|
+
node_count: nodes.length,
|
|
53
|
+
pair_count: pairs.length,
|
|
54
|
+
forward_count: totalForwards,
|
|
55
|
+
within_limits,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function countRetainedSubmissions(retained_submission) {
|
|
59
|
+
if (retained_submission === undefined || retained_submission === null)
|
|
60
|
+
return 0;
|
|
61
|
+
if (Array.isArray(retained_submission))
|
|
62
|
+
return retained_submission.length;
|
|
63
|
+
if (typeof retained_submission === 'string') {
|
|
64
|
+
return retained_submission.length > 0 ? 1 : 0;
|
|
65
|
+
}
|
|
66
|
+
return 0;
|
|
67
|
+
}
|
|
68
|
+
export function detectCycle(nodes, pairs) {
|
|
69
|
+
const nodeNames = nodes.map((n) => n.name);
|
|
70
|
+
return detectCycles(nodeNames, pairs);
|
|
71
|
+
}
|
|
72
|
+
function detectCycles(nodeNames, pairs) {
|
|
73
|
+
const adj = new Map();
|
|
74
|
+
for (const name of nodeNames)
|
|
75
|
+
adj.set(name, []);
|
|
76
|
+
for (const pair of pairs) {
|
|
77
|
+
if (pair.prev_node !== "" && adj.has(pair.prev_node)) {
|
|
78
|
+
adj.get(pair.prev_node).push(pair.next_node);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const WHITE = 0, GRAY = 1, BLACK = 2;
|
|
82
|
+
const color = new Map();
|
|
83
|
+
for (const name of nodeNames)
|
|
84
|
+
color.set(name, WHITE);
|
|
85
|
+
const cycles = [];
|
|
86
|
+
const path = [];
|
|
87
|
+
function dfs(u) {
|
|
88
|
+
color.set(u, GRAY);
|
|
89
|
+
path.push(u);
|
|
90
|
+
for (const v of adj.get(u) || []) {
|
|
91
|
+
if (color.get(v) === GRAY) {
|
|
92
|
+
const cycleStart = path.indexOf(v);
|
|
93
|
+
cycles.push(path.slice(cycleStart));
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
if (color.get(v) === WHITE) {
|
|
97
|
+
if (dfs(v))
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
path.pop();
|
|
102
|
+
color.set(u, BLACK);
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
for (const name of nodeNames) {
|
|
106
|
+
if (color.get(name) === WHITE) {
|
|
107
|
+
dfs(name);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
has_cycles: cycles.length > 0,
|
|
112
|
+
cycle_nodes: cycles,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function analyzeDeadBranches(pairs) {
|
|
116
|
+
const dead = [];
|
|
117
|
+
const byPrevNode = new Map();
|
|
118
|
+
for (const pair of pairs) {
|
|
119
|
+
if (!byPrevNode.has(pair.prev_node))
|
|
120
|
+
byPrevNode.set(pair.prev_node, []);
|
|
121
|
+
byPrevNode.get(pair.prev_node).push(pair);
|
|
122
|
+
}
|
|
123
|
+
for (const [prev, groupPairs] of byPrevNode) {
|
|
124
|
+
if (groupPairs.length <= 1)
|
|
125
|
+
continue;
|
|
126
|
+
const minThreshold = Math.min(...groupPairs.map((p) => p.threshold));
|
|
127
|
+
for (const pair of groupPairs) {
|
|
128
|
+
if (pair.threshold > minThreshold * 2) {
|
|
129
|
+
dead.push({
|
|
130
|
+
pair: { prev_node: pair.prev_node, next_node: pair.next_node },
|
|
131
|
+
reason: `Threshold ${pair.threshold} is much higher than competing minimum ${minThreshold}. Likely always loses.`,
|
|
132
|
+
competing_with: groupPairs
|
|
133
|
+
.filter((p) => p !== pair)
|
|
134
|
+
.map((p) => p.next_node),
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return dead;
|
|
140
|
+
}
|
|
141
|
+
function computeReachability(nodeNames, pairs) {
|
|
142
|
+
const adj = new Map();
|
|
143
|
+
for (const name of nodeNames)
|
|
144
|
+
adj.set(name, []);
|
|
145
|
+
for (const pair of pairs) {
|
|
146
|
+
if (pair.prev_node !== "") {
|
|
147
|
+
if (!adj.has(pair.prev_node))
|
|
148
|
+
adj.set(pair.prev_node, []);
|
|
149
|
+
adj.get(pair.prev_node).push(pair.next_node);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
const reachability = new Map();
|
|
153
|
+
for (const start of nodeNames) {
|
|
154
|
+
const visited = new Set();
|
|
155
|
+
const queue = [start];
|
|
156
|
+
while (queue.length > 0) {
|
|
157
|
+
const u = queue.shift();
|
|
158
|
+
for (const v of adj.get(u) || []) {
|
|
159
|
+
if (!visited.has(v)) {
|
|
160
|
+
visited.add(v);
|
|
161
|
+
queue.push(v);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
reachability.set(start, visited);
|
|
166
|
+
}
|
|
167
|
+
return reachability;
|
|
168
|
+
}
|
|
169
|
+
export function isReachableFromEntry(node, topology) {
|
|
170
|
+
for (const entry of topology.entry_nodes) {
|
|
171
|
+
if (entry === node)
|
|
172
|
+
return true;
|
|
173
|
+
if (topology.reachability.get(entry)?.has(node))
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
export function getNodesReachingTerminals(topology) {
|
|
179
|
+
const result = new Set();
|
|
180
|
+
for (const [node, reachable] of topology.reachability) {
|
|
181
|
+
for (const terminal of topology.terminal_nodes) {
|
|
182
|
+
if (reachable.has(terminal)) {
|
|
183
|
+
result.add(node);
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return result;
|
|
189
|
+
}
|
|
190
|
+
export function formatTopologySummary(topology) {
|
|
191
|
+
const lines = [
|
|
192
|
+
`Nodes: ${topology.node_count} (max 100)`,
|
|
193
|
+
`Pairs: ${topology.pair_count} (max 40)`,
|
|
194
|
+
`Forwards: ${topology.forward_count} (max 20 per Pair)`,
|
|
195
|
+
"",
|
|
196
|
+
`Entry nodes: ${topology.entry_nodes.join(", ") || "(none)"}`,
|
|
197
|
+
`Terminal nodes: ${topology.terminal_nodes.join(", ") || "(none)"}`,
|
|
198
|
+
`Orphaned nodes: ${topology.orphaned_nodes.join(", ") || "(none)"}`,
|
|
199
|
+
`Dead branches: ${topology.dead_branches.length}`,
|
|
200
|
+
`Cycles: ${topology.has_cycles ? "YES (❌ invalid DAG)" : "NO (✓ valid DAG)"}`,
|
|
201
|
+
"",
|
|
202
|
+
`Within on-chain limits: ${topology.within_limits.max_node_count &&
|
|
203
|
+
topology.within_limits.max_node_pair_count &&
|
|
204
|
+
topology.within_limits.max_forward_count &&
|
|
205
|
+
topology.within_limits.max_forward_order_count
|
|
206
|
+
? "YES ✓"
|
|
207
|
+
: "NO ❌"}`,
|
|
208
|
+
];
|
|
209
|
+
return lines.join("\n");
|
|
210
|
+
}
|
|
211
|
+
export function identifyTopologyPattern(pairs) {
|
|
212
|
+
const fromNode = new Map();
|
|
213
|
+
const toNode = new Map();
|
|
214
|
+
for (const p of pairs) {
|
|
215
|
+
if (!fromNode.has(p.prev_node))
|
|
216
|
+
fromNode.set(p.prev_node, []);
|
|
217
|
+
fromNode.get(p.prev_node).push(p.next_node);
|
|
218
|
+
if (!toNode.has(p.next_node))
|
|
219
|
+
toNode.set(p.next_node, []);
|
|
220
|
+
toNode.get(p.next_node).push(p.prev_node);
|
|
221
|
+
}
|
|
222
|
+
for (const [prev, nexts] of fromNode) {
|
|
223
|
+
if (nexts.length > 1 && prev !== "") {
|
|
224
|
+
return "P-M-COMPETING";
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
for (const [next, prevs] of toNode) {
|
|
228
|
+
if (prevs.length > 1) {
|
|
229
|
+
return "P-M-FORKMERGE";
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return "P-M-LINEAR";
|
|
233
|
+
}
|
|
234
|
+
export const MACHINE_TOPOLOGY_VERSION = "1.0.0";
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export interface SemanticToMachineRule {
|
|
2
|
+
id: string;
|
|
3
|
+
pattern_name: string;
|
|
4
|
+
category: "execution" | "topology" | "permission" | "integration";
|
|
5
|
+
semantic_intent: string;
|
|
6
|
+
match_keywords: string[];
|
|
7
|
+
schema_elements: {
|
|
8
|
+
threshold: number | "dynamic";
|
|
9
|
+
forward_count: number | "dynamic";
|
|
10
|
+
permission_model: "single" | "mixed";
|
|
11
|
+
pair_count: number | "dynamic";
|
|
12
|
+
structure: string;
|
|
13
|
+
};
|
|
14
|
+
constraints: string[];
|
|
15
|
+
example: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
export declare const SEMANTIC_TO_MACHINE_RULES: SemanticToMachineRule[];
|
|
18
|
+
export interface NodeFieldExplanation {
|
|
19
|
+
field: string;
|
|
20
|
+
type: string;
|
|
21
|
+
required: boolean;
|
|
22
|
+
semantic: string;
|
|
23
|
+
constraint: string;
|
|
24
|
+
}
|
|
25
|
+
export declare const NODE_FIELD_EXPLANATIONS: NodeFieldExplanation[];
|
|
26
|
+
export declare const PAIR_FIELD_EXPLANATIONS: NodeFieldExplanation[];
|
|
27
|
+
export declare const FORWARD_FIELD_EXPLANATIONS: NodeFieldExplanation[];
|
|
28
|
+
export declare function identifyExecutionMode(pair: {
|
|
29
|
+
threshold: number;
|
|
30
|
+
forwards: Array<{
|
|
31
|
+
weight: number;
|
|
32
|
+
named_operator?: string;
|
|
33
|
+
permission_index?: number;
|
|
34
|
+
}>;
|
|
35
|
+
}): string;
|
|
36
|
+
export declare function identifyTopology(pairs: Array<{
|
|
37
|
+
prev_node: string;
|
|
38
|
+
next_node: string;
|
|
39
|
+
}>): string;
|
|
40
|
+
export declare function matchSemanticPattern(intent: string): SemanticToMachineRule | undefined;
|
|
41
|
+
export declare function explainForwardPermission(forward: {
|
|
42
|
+
named_operator?: string;
|
|
43
|
+
permission_index?: number;
|
|
44
|
+
}): string;
|
|
45
|
+
export interface MachineConstraintRule {
|
|
46
|
+
id: string;
|
|
47
|
+
name: string;
|
|
48
|
+
description: string;
|
|
49
|
+
category: "creation" | "structure" | "publish" | "runtime" | "node_operation";
|
|
50
|
+
verification_location: string;
|
|
51
|
+
on_chain_enforced: boolean;
|
|
52
|
+
}
|
|
53
|
+
export declare const MACHINE_CONSTRAINT_RULES: MachineConstraintRule[];
|
|
54
|
+
export declare function getConstraintsByCategory(category: MachineConstraintRule["category"]): MachineConstraintRule[];
|
|
55
|
+
export declare function getConstraintById(id: string): MachineConstraintRule | undefined;
|
|
56
|
+
export declare function getOnChainConstraints(): MachineConstraintRule[];
|
|
57
|
+
export declare function getOffChainConstraints(): MachineConstraintRule[];
|
|
58
|
+
export declare const MACHINE_TRANSLATION_VERSION = "1.0.0";
|
|
59
|
+
export declare const MACHINE_PATTERNS_COUNT: number;
|
|
60
|
+
export declare const MACHINE_CONSTRAINTS_COUNT: number;
|
|
61
|
+
import type { MachineForward, MachinePair } from "./machine-topology.js";
|
|
62
|
+
export interface MachineNodeForExplanation {
|
|
63
|
+
name: string;
|
|
64
|
+
description?: string;
|
|
65
|
+
pairs?: MachinePair[];
|
|
66
|
+
all_pairs?: MachinePair[];
|
|
67
|
+
}
|
|
68
|
+
export interface NodeSemantic {
|
|
69
|
+
name: string;
|
|
70
|
+
role: "entry" | "normal" | "terminal" | "branch" | "merge";
|
|
71
|
+
pairs: PairSemantic[];
|
|
72
|
+
description?: string;
|
|
73
|
+
}
|
|
74
|
+
export interface PairSemantic {
|
|
75
|
+
prev_node: string;
|
|
76
|
+
next_node: string;
|
|
77
|
+
threshold: number;
|
|
78
|
+
execution_pattern: string;
|
|
79
|
+
forwards: ForwardSemantic[];
|
|
80
|
+
}
|
|
81
|
+
export interface ForwardSemantic {
|
|
82
|
+
name: string;
|
|
83
|
+
permission: string;
|
|
84
|
+
weight: number;
|
|
85
|
+
guard: GuardBindingSemantic | null;
|
|
86
|
+
retained_submission: string | string[] | number[] | null;
|
|
87
|
+
}
|
|
88
|
+
export interface GuardBindingSemantic {
|
|
89
|
+
address: string;
|
|
90
|
+
immutable_required: true;
|
|
91
|
+
note: string;
|
|
92
|
+
}
|
|
93
|
+
export declare function identifyNodeRole(node: MachineNodeForExplanation): NodeSemantic["role"];
|
|
94
|
+
export declare function explainNode(node: MachineNodeForExplanation): NodeSemantic;
|
|
95
|
+
export declare function explainPair(pair: MachinePair): PairSemantic;
|
|
96
|
+
export declare function explainForward(forward: MachineForward): ForwardSemantic;
|