@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
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface SubmissionFieldPrompt {
|
|
2
|
+
identifier: number;
|
|
3
|
+
name: string;
|
|
4
|
+
value_type: string;
|
|
5
|
+
required: boolean;
|
|
6
|
+
suggested_value?: string;
|
|
7
|
+
suggestion_reason?: string;
|
|
8
|
+
description: string;
|
|
9
|
+
}
|
|
10
|
+
export interface GuardSubmissionPrompt {
|
|
11
|
+
guard_address: string;
|
|
12
|
+
guard_name?: string;
|
|
13
|
+
operation: string;
|
|
14
|
+
required_fields: SubmissionFieldPrompt[];
|
|
15
|
+
context: string;
|
|
16
|
+
fill_example: string;
|
|
17
|
+
}
|
|
18
|
+
export interface SubmissionContext {
|
|
19
|
+
operation: string;
|
|
20
|
+
network?: string;
|
|
21
|
+
signer?: string;
|
|
22
|
+
progress_address?: string;
|
|
23
|
+
progress_current?: string;
|
|
24
|
+
order_address?: string;
|
|
25
|
+
service_address?: string;
|
|
26
|
+
machine_address?: string;
|
|
27
|
+
allocation_address?: string;
|
|
28
|
+
extra?: Record<string, string>;
|
|
29
|
+
}
|
|
30
|
+
export declare function generateGuardSubmissionPrompt(guardRef: string, ctx: SubmissionContext): Promise<GuardSubmissionPrompt | undefined>;
|
|
31
|
+
export declare function formatSubmissionPrompt(prompt: GuardSubmissionPrompt): string;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { query_objects, LocalMark } from "@wowok/wowok";
|
|
2
|
+
function inferValue(fieldName, valueType, ctx) {
|
|
3
|
+
const name = fieldName.toLowerCase();
|
|
4
|
+
if (name.includes("order") || name.includes("task")) {
|
|
5
|
+
if (ctx.order_address) {
|
|
6
|
+
return { value: ctx.order_address, reason: "Inferred from operation's order_address context" };
|
|
7
|
+
}
|
|
8
|
+
if (ctx.progress_address) {
|
|
9
|
+
return { value: ctx.progress_address, reason: "Progress.task is typically the order — query Progress to get the actual task address" };
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
if (name.includes("signer") || name.includes("sender") || name.includes("caller")) {
|
|
13
|
+
if (ctx.signer) {
|
|
14
|
+
return { value: ctx.signer, reason: "Inferred from env.account (the signing account)" };
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (name.includes("service")) {
|
|
18
|
+
if (ctx.service_address) {
|
|
19
|
+
return { value: ctx.service_address, reason: "Inferred from operation's service_address context" };
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (name.includes("machine")) {
|
|
23
|
+
if (ctx.machine_address) {
|
|
24
|
+
return { value: ctx.machine_address, reason: "Inferred from operation's machine_address context" };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (name.includes("progress") || name.includes("node") || name.includes("current")) {
|
|
28
|
+
if (ctx.progress_current) {
|
|
29
|
+
return { value: ctx.progress_current, reason: "Inferred from Progress.current node name" };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (name.includes("allocation") || name.includes("allocator")) {
|
|
33
|
+
if (ctx.allocation_address) {
|
|
34
|
+
return { value: ctx.allocation_address, reason: "Inferred from operation's allocation_address context" };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (ctx.extra) {
|
|
38
|
+
for (const [key, val] of Object.entries(ctx.extra)) {
|
|
39
|
+
if (name.includes(key.toLowerCase())) {
|
|
40
|
+
return { value: val, reason: `Inferred from extra context: ${key}` };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
function describeField(name, valueType) {
|
|
47
|
+
const n = name.toLowerCase();
|
|
48
|
+
if (n.includes("order"))
|
|
49
|
+
return `Order object address (type: ${valueType})`;
|
|
50
|
+
if (n.includes("signer") || n.includes("sender"))
|
|
51
|
+
return `Transaction signer address (type: ${valueType})`;
|
|
52
|
+
if (n.includes("service"))
|
|
53
|
+
return `Service object address (type: ${valueType})`;
|
|
54
|
+
if (n.includes("machine"))
|
|
55
|
+
return `Machine object address (type: ${valueType})`;
|
|
56
|
+
if (n.includes("progress"))
|
|
57
|
+
return `Progress object address (type: ${valueType})`;
|
|
58
|
+
if (n.includes("node") || n.includes("current"))
|
|
59
|
+
return `Current node name (type: ${valueType})`;
|
|
60
|
+
if (n.includes("amount") || n.includes("price") || n.includes("balance"))
|
|
61
|
+
return `Amount in smallest unit (type: ${valueType})`;
|
|
62
|
+
if (n.includes("allocation"))
|
|
63
|
+
return `Allocation object address (type: ${valueType})`;
|
|
64
|
+
return `Field "${name}" (type: ${valueType})`;
|
|
65
|
+
}
|
|
66
|
+
export async function generateGuardSubmissionPrompt(guardRef, ctx) {
|
|
67
|
+
let guardAddress = guardRef;
|
|
68
|
+
let guardName;
|
|
69
|
+
if (!guardRef.startsWith("0x")) {
|
|
70
|
+
try {
|
|
71
|
+
const mark = await LocalMark.Instance().get(guardRef);
|
|
72
|
+
if (mark?.address) {
|
|
73
|
+
guardAddress = mark.address;
|
|
74
|
+
guardName = guardRef;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
let guardObj;
|
|
85
|
+
try {
|
|
86
|
+
const result = await query_objects({
|
|
87
|
+
objects: [guardAddress],
|
|
88
|
+
network: ctx.network,
|
|
89
|
+
});
|
|
90
|
+
guardObj = result?.objects?.[0];
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
if (!guardObj)
|
|
96
|
+
return undefined;
|
|
97
|
+
const table = guardObj.table ?? guardObj.b_table ?? [];
|
|
98
|
+
if (!Array.isArray(table) || table.length === 0)
|
|
99
|
+
return undefined;
|
|
100
|
+
const submissionItems = table.filter((item) => item.b_submission === true);
|
|
101
|
+
if (submissionItems.length === 0)
|
|
102
|
+
return undefined;
|
|
103
|
+
const requiredFields = submissionItems.map((item) => {
|
|
104
|
+
const fieldName = item.name ?? `identifier_${item.identifier}`;
|
|
105
|
+
const valueType = typeof item.value_type === "number"
|
|
106
|
+
? ValueTypeNames[item.value_type] ?? String(item.value_type)
|
|
107
|
+
: String(item.value_type);
|
|
108
|
+
const inferred = inferValue(fieldName, valueType, ctx);
|
|
109
|
+
return {
|
|
110
|
+
identifier: item.identifier,
|
|
111
|
+
name: fieldName,
|
|
112
|
+
value_type: valueType,
|
|
113
|
+
required: true,
|
|
114
|
+
suggested_value: inferred?.value,
|
|
115
|
+
suggestion_reason: inferred?.reason,
|
|
116
|
+
description: describeField(fieldName, valueType),
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
const fillLines = requiredFields.map((f) => {
|
|
120
|
+
const val = f.suggested_value ?? `<${f.value_type}_value>`;
|
|
121
|
+
return ` { identifier: ${f.identifier}, name: "${f.name}", value_type: "${f.value_type}", value: ${val} }`;
|
|
122
|
+
});
|
|
123
|
+
const fillExample = `submission: {
|
|
124
|
+
guard: "${guardName ?? guardAddress}",
|
|
125
|
+
submission: [
|
|
126
|
+
${fillLines.join(",\n")}
|
|
127
|
+
]
|
|
128
|
+
}`;
|
|
129
|
+
return {
|
|
130
|
+
guard_address: guardAddress,
|
|
131
|
+
guard_name: guardName,
|
|
132
|
+
operation: ctx.operation,
|
|
133
|
+
required_fields: requiredFields,
|
|
134
|
+
context: `Operation "${ctx.operation}" requires Guard "${guardName ?? guardAddress}" verification. ` +
|
|
135
|
+
`The Guard has ${requiredFields.length} field(s) that need submission data (b_submission=true). ` +
|
|
136
|
+
`Fill the submission with the required values and retry the operation using call_with_submission. ` +
|
|
137
|
+
`Each field has an identifier (number), name, and expected value_type. ` +
|
|
138
|
+
`The suggested_value (if provided) is inferred from the operation context — verify before using.`,
|
|
139
|
+
fill_example: fillExample,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
export function formatSubmissionPrompt(prompt) {
|
|
143
|
+
const lines = [];
|
|
144
|
+
lines.push("GUARD SUBMISSION REQUIRED — operation cannot proceed without submission data.");
|
|
145
|
+
lines.push(`Guard: ${prompt.guard_name ?? prompt.guard_address} (${prompt.guard_address})`);
|
|
146
|
+
lines.push(`Operation: ${prompt.operation}`);
|
|
147
|
+
lines.push("");
|
|
148
|
+
lines.push("Required fields (fill these in the submission):");
|
|
149
|
+
for (const f of prompt.required_fields) {
|
|
150
|
+
lines.push(` [${f.identifier}] ${f.name} (${f.value_type}) — ${f.description}`);
|
|
151
|
+
if (f.suggested_value) {
|
|
152
|
+
lines.push(` Suggested: ${f.suggested_value} (${f.suggestion_reason})`);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
lines.push(` No suggestion — derive value from context or ask user.`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
lines.push("");
|
|
159
|
+
lines.push("Fill example (use in the next call with submission):");
|
|
160
|
+
lines.push(prompt.fill_example);
|
|
161
|
+
return lines.join("\n");
|
|
162
|
+
}
|
|
163
|
+
const ValueTypeNames = {
|
|
164
|
+
0: "Bool",
|
|
165
|
+
1: "Address",
|
|
166
|
+
2: "U64",
|
|
167
|
+
3: "String",
|
|
168
|
+
4: "Vec",
|
|
169
|
+
5: "U256",
|
|
170
|
+
6: "Object",
|
|
171
|
+
};
|
|
@@ -34,5 +34,15 @@ export declare function validateTemplateParams(templateId: string, params: Recor
|
|
|
34
34
|
valid: boolean;
|
|
35
35
|
missing: string[];
|
|
36
36
|
};
|
|
37
|
+
export type FillGuardTemplateResult = {
|
|
38
|
+
ok: true;
|
|
39
|
+
table: unknown;
|
|
40
|
+
root: unknown;
|
|
41
|
+
} | {
|
|
42
|
+
ok: false;
|
|
43
|
+
error: string;
|
|
44
|
+
missing?: string[];
|
|
45
|
+
};
|
|
46
|
+
export declare function fillGuardTemplate(templateId: string, params: Record<string, unknown>): FillGuardTemplateResult;
|
|
37
47
|
export declare const GUARD_TEMPLATES_VERSION = "1.0.0";
|
|
38
48
|
export declare const GUARD_TEMPLATES_COUNT: number;
|
|
@@ -1051,5 +1051,55 @@ export function validateTemplateParams(templateId, params) {
|
|
|
1051
1051
|
.map((p) => p.name);
|
|
1052
1052
|
return { valid: missing.length === 0, missing };
|
|
1053
1053
|
}
|
|
1054
|
+
function deepSubstitute(obj, params) {
|
|
1055
|
+
if (typeof obj === "string") {
|
|
1056
|
+
const full = obj.match(/^\$\{(\w+)\}$/);
|
|
1057
|
+
if (full && full[1] in params) {
|
|
1058
|
+
return params[full[1]];
|
|
1059
|
+
}
|
|
1060
|
+
return obj.replace(/\$\{(\w+)\}/g, (_, key) => key in params ? String(params[key]) : `\${${key}}`);
|
|
1061
|
+
}
|
|
1062
|
+
if (Array.isArray(obj)) {
|
|
1063
|
+
return obj.map((item) => deepSubstitute(item, params));
|
|
1064
|
+
}
|
|
1065
|
+
if (obj && typeof obj === "object") {
|
|
1066
|
+
const result = {};
|
|
1067
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
1068
|
+
result[k] = deepSubstitute(v, params);
|
|
1069
|
+
}
|
|
1070
|
+
return result;
|
|
1071
|
+
}
|
|
1072
|
+
return obj;
|
|
1073
|
+
}
|
|
1074
|
+
export function fillGuardTemplate(templateId, params) {
|
|
1075
|
+
const template = getTemplateById(templateId);
|
|
1076
|
+
if (!template) {
|
|
1077
|
+
return { ok: false, error: `Template not found: ${templateId}` };
|
|
1078
|
+
}
|
|
1079
|
+
const { valid, missing } = validateTemplateParams(templateId, params);
|
|
1080
|
+
if (!valid) {
|
|
1081
|
+
return {
|
|
1082
|
+
ok: false,
|
|
1083
|
+
error: `Missing required parameters: ${missing.join(", ")}`,
|
|
1084
|
+
missing,
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1087
|
+
const filled = { ...params };
|
|
1088
|
+
for (const p of template.parameters) {
|
|
1089
|
+
if (!(p.name in filled) && p.default !== undefined) {
|
|
1090
|
+
filled[p.name] = p.default;
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
const table = deepSubstitute(template.example_table, filled);
|
|
1094
|
+
const root = deepSubstitute(template.example_root, filled);
|
|
1095
|
+
const leftover = JSON.stringify({ table, root }).match(/\$\{(\w+)\}/);
|
|
1096
|
+
if (leftover) {
|
|
1097
|
+
return {
|
|
1098
|
+
ok: false,
|
|
1099
|
+
error: `Unresolved placeholder \${${leftover[1]}} — not declared in template parameters`,
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
1102
|
+
return { ok: true, table, root };
|
|
1103
|
+
}
|
|
1054
1104
|
export const GUARD_TEMPLATES_VERSION = "1.0.0";
|
|
1055
1105
|
export const GUARD_TEMPLATES_COUNT = GUARD_TEMPLATES.length;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CONCEPT_GLOSSARY, CONCEPT_GLOSSARY_VERSION, resolveTerm, lookupEntry, validateText, auditSchemaFields, type GlossaryEntry, type GlossaryCategory, type GlossaryDrift } from "./glossary.js";
|
|
2
|
-
import { CONFIRMATION_RULES, SAFETY_RULES_VERSION, type ConfirmationRule, type OperationPreview, type ConfirmLevel } from "./safety-rules.js";
|
|
2
|
+
import { CONFIRMATION_RULES, SAFETY_RULES_VERSION, OBJECT_REUSE_RULES, CREATE_VS_MODIFY_PATTERN, IMMUTABILITY_RULES, OPERATION_TYPE_CLASSIFICATION, OPERATION_CLASS_META, classifyTool, NAMING_CONVENTIONS, checkObjectReuseRules, checkImmutabilityRules, type ConfirmationRule, type OperationPreview, type ConfirmLevel, type ReuseRecommendation, type ObjectReuseRule, type ImmutabilityRule, type OperationClass, type OperationClassMeta, type SafetyRiskItem } from "./safety-rules.js";
|
|
3
3
|
import { TOOL_CONSTRAINTS, TOOL_CONSTRAINTS_VERSION, validateOperation, hasBlockingViolations, getWarningViolations, type ConstraintSeverity, type FieldConstraint, type OperationConstraint, type ConstraintViolation } from "./tool-constraints.js";
|
|
4
4
|
import { PERMISSION_TYPES, GAME_ELEMENTS, getPermissionType, getGameElement, getGameElementsByType, PROCESS_MODEL_VERSION, type PermissionScope, type PermissionTypeDef, type GameElementType, type GameElementDef } from "./process-model.js";
|
|
5
5
|
import { computeTrustScore, quickRiskAssessment, ARBITRATION_TRUST_VERSION, type ArbMetrics, type TrustScore, type TrustComponent } from "./arbitration-trust.js";
|
|
@@ -105,7 +105,7 @@ import { TOOLS_REFERENCE, getToolReference, searchToolReference, getToolSequence
|
|
|
105
105
|
import { SCENARIO_MODES, SCENARIO_MODES_VERSION, MODE_COMPOSITIONS, matchScenarioMode, inferScenarioTraits, getScenarioMode, listScenarioModes, getShippedModes, getModeCompositions, type IndustryModeName, type ScenarioTraits, type ModeAllocatorStrategy, type ModeGuardRef, type ModeMachineNode, type ScenarioMode, type ModeComposition } from "./scenario-modes.js";
|
|
106
106
|
import { GUARD_DESIGN_PATTERNS, GUARD_DESIGN_PATTERNS_VERSION, VERIFIER_LEVEL_GUIDANCE, getGuardDesignPattern, searchGuardDesignPatterns, getPatternsByHost, getPatternsByIndustry, getPatternsByDataSourceClass, getVerifierLevelGuidance, suggestPatternForRequirement, type GuardDataSourceClass, type VerifierConstraintLevel, type GuardHostObject, type GuardDesignPattern, type VerifierLevelGuidance } from "./guard-design-patterns.js";
|
|
107
107
|
export { CONCEPT_GLOSSARY, CONCEPT_GLOSSARY_VERSION, resolveTerm, lookupEntry, validateText, auditSchemaFields, type GlossaryEntry, type GlossaryCategory, type GlossaryDrift, };
|
|
108
|
-
export { CONFIRMATION_RULES, SAFETY_RULES_VERSION, type ConfirmationRule, type OperationPreview, type ConfirmLevel, };
|
|
108
|
+
export { CONFIRMATION_RULES, SAFETY_RULES_VERSION, OBJECT_REUSE_RULES, CREATE_VS_MODIFY_PATTERN, IMMUTABILITY_RULES, OPERATION_TYPE_CLASSIFICATION, OPERATION_CLASS_META, classifyTool, NAMING_CONVENTIONS, checkObjectReuseRules, checkImmutabilityRules, type ConfirmationRule, type OperationPreview, type ConfirmLevel, type ReuseRecommendation, type ObjectReuseRule, type ImmutabilityRule, type OperationClass, type OperationClassMeta, type SafetyRiskItem, };
|
|
109
109
|
export { TOOL_CONSTRAINTS, TOOL_CONSTRAINTS_VERSION, validateOperation, hasBlockingViolations, getWarningViolations, type ConstraintSeverity, type FieldConstraint, type OperationConstraint, type ConstraintViolation, };
|
|
110
110
|
export { PERMISSION_TYPES, GAME_ELEMENTS, getPermissionType, getGameElement, getGameElementsByType, PROCESS_MODEL_VERSION, type PermissionScope, type PermissionTypeDef, type GameElementType, type GameElementDef, };
|
|
111
111
|
export { computeTrustScore, quickRiskAssessment, ARBITRATION_TRUST_VERSION, type ArbMetrics, type TrustScore, type TrustComponent, };
|
package/dist/knowledge/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CONCEPT_GLOSSARY, CONCEPT_GLOSSARY_VERSION, resolveTerm, lookupEntry, validateText, auditSchemaFields } from "./glossary.js";
|
|
2
|
-
import { CONFIRMATION_RULES, SAFETY_RULES_VERSION } from "./safety-rules.js";
|
|
2
|
+
import { CONFIRMATION_RULES, SAFETY_RULES_VERSION, OBJECT_REUSE_RULES, CREATE_VS_MODIFY_PATTERN, IMMUTABILITY_RULES, OPERATION_TYPE_CLASSIFICATION, OPERATION_CLASS_META, classifyTool, NAMING_CONVENTIONS, checkObjectReuseRules, checkImmutabilityRules } from "./safety-rules.js";
|
|
3
3
|
import { TOOL_CONSTRAINTS, TOOL_CONSTRAINTS_VERSION, validateOperation, hasBlockingViolations, getWarningViolations, } from "./tool-constraints.js";
|
|
4
4
|
import { PERMISSION_TYPES, GAME_ELEMENTS, getPermissionType, getGameElement, getGameElementsByType, PROCESS_MODEL_VERSION, } from "./process-model.js";
|
|
5
5
|
import { computeTrustScore, quickRiskAssessment, ARBITRATION_TRUST_VERSION, } from "./arbitration-trust.js";
|
|
@@ -105,7 +105,7 @@ import { TOOLS_REFERENCE, getToolReference, searchToolReference, getToolSequence
|
|
|
105
105
|
import { SCENARIO_MODES, SCENARIO_MODES_VERSION, MODE_COMPOSITIONS, matchScenarioMode, inferScenarioTraits, getScenarioMode, listScenarioModes, getShippedModes, getModeCompositions, } from "./scenario-modes.js";
|
|
106
106
|
import { GUARD_DESIGN_PATTERNS, GUARD_DESIGN_PATTERNS_VERSION, VERIFIER_LEVEL_GUIDANCE, getGuardDesignPattern, searchGuardDesignPatterns, getPatternsByHost, getPatternsByIndustry, getPatternsByDataSourceClass, getVerifierLevelGuidance, suggestPatternForRequirement, } from "./guard-design-patterns.js";
|
|
107
107
|
export { CONCEPT_GLOSSARY, CONCEPT_GLOSSARY_VERSION, resolveTerm, lookupEntry, validateText, auditSchemaFields, };
|
|
108
|
-
export { CONFIRMATION_RULES, SAFETY_RULES_VERSION, };
|
|
108
|
+
export { CONFIRMATION_RULES, SAFETY_RULES_VERSION, OBJECT_REUSE_RULES, CREATE_VS_MODIFY_PATTERN, IMMUTABILITY_RULES, OPERATION_TYPE_CLASSIFICATION, OPERATION_CLASS_META, classifyTool, NAMING_CONVENTIONS, checkObjectReuseRules, checkImmutabilityRules, };
|
|
109
109
|
export { TOOL_CONSTRAINTS, TOOL_CONSTRAINTS_VERSION, validateOperation, hasBlockingViolations, getWarningViolations, };
|
|
110
110
|
export { PERMISSION_TYPES, GAME_ELEMENTS, getPermissionType, getGameElement, getGameElementsByType, PROCESS_MODEL_VERSION, };
|
|
111
111
|
export { computeTrustScore, quickRiskAssessment, ARBITRATION_TRUST_VERSION, };
|
|
@@ -284,7 +284,7 @@ export function inferSceneFromFlow(description) {
|
|
|
284
284
|
if (lower.includes("wonder") || lower.includes("praise") || lower.includes("complain")
|
|
285
285
|
|| lower.includes("thumbs_up") || lower.includes("thumbs_down")
|
|
286
286
|
|| lower.includes("rating") || lower.includes("feedback")
|
|
287
|
-
|| lower.includes("
|
|
287
|
+
|| lower.includes("praise") || lower.includes("complaint")) {
|
|
288
288
|
return findScene("wonder_feedback");
|
|
289
289
|
}
|
|
290
290
|
if (lower.includes("reward") || lower.includes("incentive")) {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface MachineNodeForRender {
|
|
2
|
+
name: string;
|
|
3
|
+
description?: string | null;
|
|
4
|
+
}
|
|
5
|
+
export interface MachineForwardForRender {
|
|
6
|
+
name: string;
|
|
7
|
+
weight: number;
|
|
8
|
+
named_operator?: string | null;
|
|
9
|
+
permission_index?: number | null;
|
|
10
|
+
guard?: string | null;
|
|
11
|
+
retained_submission?: number[] | string | null;
|
|
12
|
+
}
|
|
13
|
+
export interface MachineEdgeForRender {
|
|
14
|
+
from: string;
|
|
15
|
+
to: string;
|
|
16
|
+
threshold: number;
|
|
17
|
+
forwards: MachineForwardForRender[];
|
|
18
|
+
}
|
|
19
|
+
export interface MachineRenderInput {
|
|
20
|
+
nodes: MachineNodeForRender[];
|
|
21
|
+
edges: MachineEdgeForRender[];
|
|
22
|
+
machineName?: string | null;
|
|
23
|
+
machineAddress?: string | null;
|
|
24
|
+
published?: boolean | null;
|
|
25
|
+
paused?: boolean | null;
|
|
26
|
+
}
|
|
27
|
+
export declare function sanitizeMermaidNodeId(name: string): string;
|
|
28
|
+
export declare function renderMachineMermaid(nodes: MachineNodeForRender[], edges: MachineEdgeForRender[], options?: {
|
|
29
|
+
colored?: boolean;
|
|
30
|
+
}): string;
|
|
31
|
+
export declare function renderMachineTreeIndented(input: MachineRenderInput): string;
|
|
32
|
+
export declare function parseMachineTreeIndented(text: string): {
|
|
33
|
+
success: boolean;
|
|
34
|
+
data?: {
|
|
35
|
+
nodes: MachineNodeForRender[];
|
|
36
|
+
edges: MachineEdgeForRender[];
|
|
37
|
+
};
|
|
38
|
+
errors: string[];
|
|
39
|
+
};
|
|
40
|
+
export declare function renderMachineAscii(input: MachineRenderInput): string;
|
|
41
|
+
export declare function renderMachineMarkmap(input: MachineRenderInput): string;
|