@wowok/agent-mcp 2.6.9 → 2.7.1
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/README.md +0 -2
- package/dist/customer/risk-assessment.d.ts +5 -1
- package/dist/customer/risk-assessment.js +4 -4
- package/dist/evaluation/arbitration-game.d.ts +16 -0
- package/dist/evaluation/arbitration-game.js +48 -0
- package/dist/evaluation/builtins/demand-match.d.ts +15 -0
- package/dist/evaluation/builtins/demand-match.js +153 -0
- package/dist/evaluation/builtins/index.d.ts +3 -0
- package/dist/evaluation/builtins/index.js +10 -0
- package/dist/evaluation/builtins/service-risk.d.ts +6 -0
- package/dist/evaluation/builtins/service-risk.js +55 -0
- package/dist/evaluation/capability.d.ts +50 -0
- package/dist/evaluation/capability.js +13 -0
- package/dist/evaluation/composer.d.ts +13 -0
- package/dist/evaluation/composer.js +40 -0
- package/dist/evaluation/engine.d.ts +18 -0
- package/dist/evaluation/engine.js +175 -0
- package/dist/evaluation/extract.d.ts +30 -0
- package/dist/evaluation/extract.js +115 -0
- package/dist/evaluation/gap.d.ts +2 -0
- package/dist/evaluation/gap.js +100 -0
- package/dist/evaluation/index.d.ts +11 -0
- package/dist/evaluation/index.js +11 -0
- package/dist/evaluation/node-game.d.ts +34 -0
- package/dist/evaluation/node-game.js +57 -0
- package/dist/evaluation/region.d.ts +10 -0
- package/dist/evaluation/region.js +36 -0
- package/dist/evaluation/types.d.ts +76 -0
- package/dist/evaluation/types.js +1 -0
- package/dist/evaluation/user-injection.d.ts +6 -0
- package/dist/evaluation/user-injection.js +27 -0
- package/dist/examples/education-contact-create.json +40 -0
- package/dist/examples/freelance-contact-create.json +40 -0
- package/dist/examples/insurance-machine-create.json +1 -1
- package/dist/examples/insurance-service-allocators.json +1 -1
- package/dist/examples/machine-publish.json +1 -1
- package/dist/examples/rental-ziroom-service-create.json +1 -1
- package/dist/examples/retail-adv-guard-messenger-proof-create.json +1 -1
- package/dist/examples/retail-myshop-service-create.json +1 -1
- package/dist/examples/retail-myshop-service-customer-required.json +1 -1
- package/dist/examples/subscription-contact-create.json +40 -0
- package/dist/examples/threebody-machine-create.json +1 -1
- package/dist/examples/travel-machine-create.json +1 -1
- package/dist/examples/travel-service-create.json +1 -1
- package/dist/harness/plan.js +42 -3
- package/dist/intent/enrich.d.ts +1 -0
- package/dist/intent/enrich.js +67 -0
- package/dist/intent/index.d.ts +23 -0
- package/dist/intent/index.js +60 -0
- package/dist/intent/matcher.d.ts +2 -0
- package/dist/intent/matcher.js +81 -0
- package/dist/intent/store.d.ts +19 -0
- package/dist/intent/store.js +55 -0
- package/dist/intent/types.d.ts +33 -0
- package/dist/intent/types.js +10 -0
- package/dist/knowledge/arbitration-risk.js +1 -11
- package/dist/knowledge/contact-templates.d.ts +27 -0
- package/dist/knowledge/contact-templates.js +60 -0
- package/dist/knowledge/examples-scanner.js +21 -3
- package/dist/knowledge/fund-layer.js +8 -4
- package/dist/knowledge/industry-generalizer.js +21 -21
- package/dist/knowledge/machine-risk.js +0 -1
- package/dist/knowledge/mcp-schema-audit.d.ts +1 -1
- package/dist/knowledge/mcp-schema-audit.js +8 -4
- package/dist/knowledge/service-risk.js +38 -2
- package/dist/knowledge/service-templates.js +1 -1
- package/dist/knowledge/service-translation.js +2 -2
- package/dist/knowledge/template-registry.d.ts +1 -1
- package/dist/knowledge/template-registry.js +13 -1
- package/dist/knowledge/tools-reference.js +23 -0
- package/dist/persona/analyzer.d.ts +16 -0
- package/dist/persona/analyzer.js +66 -0
- package/dist/persona/bridge.d.ts +5 -0
- package/dist/persona/bridge.js +86 -0
- package/dist/persona/defaults.d.ts +4 -0
- package/dist/persona/defaults.js +195 -0
- package/dist/persona/experience-bridge.d.ts +3 -0
- package/dist/persona/experience-bridge.js +23 -0
- package/dist/persona/index.d.ts +18 -0
- package/dist/persona/index.js +71 -0
- package/dist/persona/model.d.ts +7 -0
- package/dist/persona/model.js +111 -0
- package/dist/persona/store.d.ts +19 -0
- package/dist/persona/store.js +62 -0
- package/dist/persona/types.d.ts +43 -0
- package/dist/persona/types.js +5 -0
- package/dist/project/handlers.d.ts +5 -0
- package/dist/project/handlers.js +23 -1
- package/dist/project/semantic-graph.js +47 -0
- package/dist/rules.d.ts +2 -0
- package/dist/rules.js +43 -0
- package/dist/schema/call/semantic.js +23 -1
- package/dist/schema/call/service.js +7 -1
- package/dist/schema/evaluation/index.d.ts +4239 -0
- package/dist/schema/evaluation/index.js +356 -0
- package/dist/schema/index.d.ts +4 -0
- package/dist/schema/index.js +4 -0
- package/dist/schema/intent-radar/index.d.ts +284 -0
- package/dist/schema/intent-radar/index.js +89 -0
- package/dist/schema/messenger/index.d.ts +171 -0
- package/dist/schema/messenger/index.js +5 -0
- package/dist/schema/operations.js +1 -1
- package/dist/schema/persona/index.d.ts +1985 -0
- package/dist/schema/persona/index.js +148 -0
- package/dist/schema/project/index.d.ts +2 -2
- package/dist/schema/query/index.js +6 -0
- package/dist/schema/sync-layer4.d.ts +1 -1
- package/dist/schema/sync-layer4.js +9 -5
- package/dist/schema/task-status.d.ts +168 -0
- package/dist/schema/task-status.js +36 -0
- package/dist/schema/trust/index.js +1 -1
- package/dist/schemas/evaluation_operation.output.json +677 -0
- package/dist/schemas/evaluation_operation.schema.json +903 -0
- package/dist/schemas/index.json +25 -1
- package/dist/schemas/intent_radar.output.json +229 -0
- package/dist/schemas/intent_radar.schema.json +135 -0
- package/dist/schemas/messenger_operation.output.json +14 -0
- package/dist/schemas/messenger_operation.schema.json +18 -0
- package/dist/schemas/onchain_operations.schema.json +2 -2
- package/dist/schemas/onchain_operations_service.schema.json +2 -2
- package/dist/schemas/persona_operation.output.json +389 -0
- package/dist/schemas/persona_operation.schema.json +247 -0
- package/dist/schemas/query_task_status.output.json +115 -0
- package/dist/schemas/query_task_status.schema.json +24 -0
- package/dist/schemas/query_toolkit.output.json +1 -1
- package/dist/schemas/trust_score.schema.json +1 -1
- package/dist/tools/handlers/evaluation.d.ts +2 -0
- package/dist/tools/handlers/evaluation.js +123 -0
- package/dist/tools/handlers/intent-radar.d.ts +2 -0
- package/dist/tools/handlers/intent-radar.js +76 -0
- package/dist/tools/handlers/onchain.js +98 -0
- package/dist/tools/handlers/persona.d.ts +4 -0
- package/dist/tools/handlers/persona.js +89 -0
- package/dist/tools/handlers/task-status.d.ts +0 -168
- package/dist/tools/handlers/task-status.js +0 -29
- package/dist/tools/index.js +83 -7
- package/dist/tools/wip-deploy-assist.d.ts +1 -1
- package/dist/tools/wip-deploy-assist.js +33 -5
- package/package.json +2 -2
package/dist/project/handlers.js
CHANGED
|
@@ -888,10 +888,32 @@ export async function handleGetGraph(v) {
|
|
|
888
888
|
}
|
|
889
889
|
export async function handleEvaluateProject(v) {
|
|
890
890
|
const projectId = await resolveProjectId(v);
|
|
891
|
-
const evalType = requireField(v.evaluation_type, "evaluation_type");
|
|
892
891
|
const project = await localProject.getProject(projectId);
|
|
893
892
|
if (!project)
|
|
894
893
|
throw new Error(`Project not found: ${projectId}`);
|
|
894
|
+
if (v.async_mode === true) {
|
|
895
|
+
const taskId = TaskTracker.create("evaluate_project", projectId);
|
|
896
|
+
(async () => {
|
|
897
|
+
try {
|
|
898
|
+
TaskTracker.update(taskId, 10, "Refreshing objects and gathering inputs");
|
|
899
|
+
const result = await evaluateProjectSync(projectId, project, v);
|
|
900
|
+
TaskTracker.complete(taskId, result);
|
|
901
|
+
}
|
|
902
|
+
catch (err) {
|
|
903
|
+
TaskTracker.fail(taskId, err.message ?? String(err));
|
|
904
|
+
}
|
|
905
|
+
})();
|
|
906
|
+
return {
|
|
907
|
+
action: "evaluate_project",
|
|
908
|
+
async_mode: true,
|
|
909
|
+
task_id: taskId,
|
|
910
|
+
hint: "Evaluation is running in the background. Call query_task_status with task_id to check progress and retrieve the result.",
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
return evaluateProjectSync(projectId, project, v);
|
|
914
|
+
}
|
|
915
|
+
async function evaluateProjectSync(projectId, project, v) {
|
|
916
|
+
const evalType = requireField(v.evaluation_type, "evaluation_type");
|
|
895
917
|
let refreshWarning;
|
|
896
918
|
if (v.refresh_before_eval !== false) {
|
|
897
919
|
const refreshResult = await refreshProjectObjects(projectId, project.network);
|
|
@@ -147,6 +147,53 @@ export function buildSemanticGraph(intent, adoptedModules) {
|
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
+
if (intent.intent.startsWith("sell_") || intent.intent === "rent_asset") {
|
|
151
|
+
nodes.push({
|
|
152
|
+
id: "main_contact",
|
|
153
|
+
type: "contact",
|
|
154
|
+
purpose: "Public contact/IM channel so customers can reach the merchant before ordering",
|
|
155
|
+
derivedFrom: { intentField: "description", rationale: "A discoverable contact object improves customer trust and order conversion" },
|
|
156
|
+
config: {
|
|
157
|
+
name: { type: "string", value: `${intent.description.slice(0, 20)}_contact`, mapsTo: "object.name" },
|
|
158
|
+
description: { type: "string", value: intent.description, mapsTo: "object.description" },
|
|
159
|
+
},
|
|
160
|
+
expectedState: { published: true, paused: false },
|
|
161
|
+
});
|
|
162
|
+
const svc = nodes.find((n) => n.id === "main_service");
|
|
163
|
+
if (svc) {
|
|
164
|
+
svc.config["um"] = { type: "address_ref", targetId: "main_contact", mapsTo: "object.um" };
|
|
165
|
+
edges.push({
|
|
166
|
+
from: "main_service",
|
|
167
|
+
to: "main_contact",
|
|
168
|
+
relation: "has_contact",
|
|
169
|
+
required: false,
|
|
170
|
+
derivedFrom: { intentField: "description", rationale: "Service binds Contact via um so customers can reach the merchant" },
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (intent.intent.startsWith("sell_") || intent.intent === "rent_asset") {
|
|
175
|
+
nodes.push({
|
|
176
|
+
id: "main_reward",
|
|
177
|
+
type: "reward",
|
|
178
|
+
purpose: "Optional incentive pool (discount/referral) to attract and retain customers",
|
|
179
|
+
derivedFrom: { intentField: "payment", rationale: "Rewards lower acquisition cost and boost conversion" },
|
|
180
|
+
config: {
|
|
181
|
+
name: { type: "string", value: `${intent.description.slice(0, 20)}_reward`, mapsTo: "object.name" },
|
|
182
|
+
type_parameter: { type: "string", value: intent.payment.currency, mapsTo: "object.type_parameter" },
|
|
183
|
+
permission: { type: "address_ref", targetId: "main_permission", mapsTo: "object.permission" },
|
|
184
|
+
},
|
|
185
|
+
expectedState: { published: true, paused: false },
|
|
186
|
+
});
|
|
187
|
+
if (nodes.find((n) => n.id === "main_service")) {
|
|
188
|
+
edges.push({
|
|
189
|
+
from: "main_service",
|
|
190
|
+
to: "main_reward",
|
|
191
|
+
relation: "has_rewards",
|
|
192
|
+
required: false,
|
|
193
|
+
derivedFrom: { intentField: "payment", rationale: "Service can reference Reward in its rewards list" },
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
150
197
|
constraints.push({
|
|
151
198
|
id: "service_permission_bound",
|
|
152
199
|
level: "hard",
|
package/dist/rules.d.ts
CHANGED
|
@@ -10,3 +10,5 @@ export { Harness, getHarness, setHarness } from "./harness/index.js";
|
|
|
10
10
|
export type { ODG, ExpectedResult, VerifyReport, RecoveryAction, Checkpoint, } from "./harness/types.js";
|
|
11
11
|
export { getDefaultPreferences, inferPreferences, matchServiceToPreferences, mergePreferences, validatePreferences, SUPPORTED_INDUSTRIES, type IndustryTemplate, type Industry, type PreferenceInference, type ServiceForMatching, type PreferenceMatchResult, } from "./customer/user-preferences.js";
|
|
12
12
|
export type { UserPreferences } from "./customer/types.js";
|
|
13
|
+
export declare function buildSoftRulesPrompt(): string;
|
|
14
|
+
export { OBJECT_REUSE_RULES, CREATE_VS_MODIFY_PATTERN, IMMUTABILITY_RULES, OPERATION_TYPE_CLASSIFICATION, OPERATION_CLASS_META, NAMING_CONVENTIONS, classifyTool, checkObjectReuseRules, checkImmutabilityRules, type ObjectReuseRule, type ImmutabilityRule, type OperationClass, type OperationClassMeta, type ReuseRecommendation, type SafetyRiskItem, } from "./knowledge/safety-rules.js";
|
package/dist/rules.js
CHANGED
|
@@ -7,3 +7,46 @@ export { CONFIRMATION_RULES, SAFETY_RULES_VERSION, DEFAULT_AMOUNT_THRESHOLD, get
|
|
|
7
7
|
export { distillIntent, extractSignals } from "./experience/intent-distill.js";
|
|
8
8
|
export { Harness, getHarness, setHarness } from "./harness/index.js";
|
|
9
9
|
export { getDefaultPreferences, inferPreferences, matchServiceToPreferences, mergePreferences, validatePreferences, SUPPORTED_INDUSTRIES, } from "./customer/user-preferences.js";
|
|
10
|
+
import { CONFIRMATION_RULES, DEFAULT_AMOUNT_THRESHOLD, formatAmount, OBJECT_REUSE_RULES, CREATE_VS_MODIFY_PATTERN, IMMUTABILITY_RULES, OPERATION_CLASS_META, NAMING_CONVENTIONS, } from "./knowledge/safety-rules.js";
|
|
11
|
+
const PERMISSION_INDEX_RANGE = "1000-65535 (0-999 reserved)";
|
|
12
|
+
export function buildSoftRulesPrompt() {
|
|
13
|
+
const lines = [];
|
|
14
|
+
lines.push("## Token amounts");
|
|
15
|
+
lines.push("- Token amounts are U64 integers in the smallest unit. 1 WOW = 1_000_000_000 (9 decimals).");
|
|
16
|
+
lines.push("- Amount input accepts '2WOW' / '10.5WOW' (auto-converted) or a raw integer '2000000000'.");
|
|
17
|
+
lines.push("- Always query token precision via query_toolkit before using a non-WOW token.");
|
|
18
|
+
lines.push("");
|
|
19
|
+
lines.push("## Operation classes");
|
|
20
|
+
for (const [cls, meta] of Object.entries(OPERATION_CLASS_META)) {
|
|
21
|
+
lines.push(`- ${cls}: ${meta.note}`);
|
|
22
|
+
}
|
|
23
|
+
lines.push("");
|
|
24
|
+
lines.push("## Object reuse vs create");
|
|
25
|
+
lines.push(`- ${CREATE_VS_MODIFY_PATTERN.note}`);
|
|
26
|
+
for (const r of OBJECT_REUSE_RULES) {
|
|
27
|
+
lines.push(` - ${r.object_type}: ${r.recommendation.replace(/_/g, " ")} — ${r.reason}`);
|
|
28
|
+
}
|
|
29
|
+
lines.push("");
|
|
30
|
+
lines.push("## Immutability");
|
|
31
|
+
for (const r of IMMUTABILITY_RULES) {
|
|
32
|
+
const mutable = r.mutable_after?.length
|
|
33
|
+
? ` (still mutable: ${r.mutable_after.join(", ")})`
|
|
34
|
+
: "";
|
|
35
|
+
lines.push(`- ${r.object_type} ${r.trigger}: ${r.message}${mutable}`);
|
|
36
|
+
}
|
|
37
|
+
lines.push("");
|
|
38
|
+
lines.push("## Confirmation levels");
|
|
39
|
+
const levels = [...new Set(CONFIRMATION_RULES.map((r) => r.level))];
|
|
40
|
+
lines.push(`- Amount threshold for extra scrutiny: ${formatAmount(DEFAULT_AMOUNT_THRESHOLD)} WOW.`);
|
|
41
|
+
lines.push(`- Confirm-gate levels: ${levels.join(", ")}.`);
|
|
42
|
+
lines.push("");
|
|
43
|
+
lines.push("## Naming conventions");
|
|
44
|
+
lines.push(`- Scheme: ${NAMING_CONVENTIONS.scheme}`);
|
|
45
|
+
for (const rec of NAMING_CONVENTIONS.recommendations) {
|
|
46
|
+
lines.push(`- ${rec}`);
|
|
47
|
+
}
|
|
48
|
+
lines.push(`- Custom permission indices: ${PERMISSION_INDEX_RANGE}.`);
|
|
49
|
+
lines.push("");
|
|
50
|
+
return lines.join("\n");
|
|
51
|
+
}
|
|
52
|
+
export { OBJECT_REUSE_RULES, CREATE_VS_MODIFY_PATTERN, IMMUTABILITY_RULES, OPERATION_TYPE_CLASSIFICATION, OPERATION_CLASS_META, NAMING_CONVENTIONS, classifyTool, checkObjectReuseRules, checkImmutabilityRules, } from "./knowledge/safety-rules.js";
|
|
@@ -893,6 +893,18 @@ const EVENT_SEMANTIC_RULES = [
|
|
|
893
893
|
business_meaning: "Order progress was updated",
|
|
894
894
|
category: "state_change",
|
|
895
895
|
},
|
|
896
|
+
{
|
|
897
|
+
pattern: /::demand::DemandFeedbackEvent|::demand::FeedbackEvent/i,
|
|
898
|
+
business_meaning: "A demand owner gave feedback (acceptance score) on a presented service",
|
|
899
|
+
category: "state_change",
|
|
900
|
+
side_effect: "High acceptance score signals a strong service↔demand fit; low score signals a mismatch",
|
|
901
|
+
},
|
|
902
|
+
{
|
|
903
|
+
pattern: /::entity::NewEntityEvent|::entity::EntityRegisteredEvent|::registrar::NewEntityEvent/i,
|
|
904
|
+
business_meaning: "A new on-chain entity (user/merchant) was registered",
|
|
905
|
+
category: "lifecycle",
|
|
906
|
+
side_effect: "A new potential counterparty entered the ecosystem",
|
|
907
|
+
},
|
|
896
908
|
];
|
|
897
909
|
function extractRelatedObject(event) {
|
|
898
910
|
if (!event || typeof event !== "object")
|
|
@@ -907,9 +919,19 @@ function extractRelatedObject(event) {
|
|
|
907
919
|
}
|
|
908
920
|
return undefined;
|
|
909
921
|
}
|
|
922
|
+
const BUILTIN_EVENT_TYPE_MAP = {
|
|
923
|
+
NewOrderEvent: "::order::OrderCreatedEvent",
|
|
924
|
+
ArbEvent: "::arbitration::ArbitrationRequestedEvent",
|
|
925
|
+
ProgressEvent: "::progress::ProgressUpdatedEvent",
|
|
926
|
+
DemandPresentEvent: "::demand::PresenterSubmittedEvent",
|
|
927
|
+
DemandFeedbackEvent: "::demand::DemandFeedbackEvent",
|
|
928
|
+
NewEntityEvent: "::entity::NewEntityEvent",
|
|
929
|
+
};
|
|
910
930
|
export function eventToSemantic(event) {
|
|
911
931
|
const eventType = String(event?.type ?? event?.event_type ?? "");
|
|
912
|
-
const
|
|
932
|
+
const typeRaw = String(event?.type_raw ?? "");
|
|
933
|
+
const candidates = [typeRaw, eventType, BUILTIN_EVENT_TYPE_MAP[eventType] ?? ""].filter(Boolean);
|
|
934
|
+
const rule = EVENT_SEMANTIC_RULES.find((r) => candidates.some((c) => r.pattern.test(c)));
|
|
913
935
|
if (!rule) {
|
|
914
936
|
return {
|
|
915
937
|
event_type: eventType,
|
|
@@ -69,7 +69,13 @@ export const CallService_DataSchema = z.object({
|
|
|
69
69
|
order_new: OrderNewSchema.optional().describe("Create new order."),
|
|
70
70
|
description: DescriptionSchema.optional(),
|
|
71
71
|
location: LongNameSchema.optional().describe("Location of the Service"),
|
|
72
|
-
sales: SalesSchema.optional().describe("Service sales products or services list."
|
|
72
|
+
sales: SalesSchema.optional().describe("Service sales products or services list. " +
|
|
73
|
+
"⚠️ WIP NETWORK-DEPLOYMENT RULE: a non-empty sale.wip MUST be a publicly reachable URL " +
|
|
74
|
+
"(GitHub Pages / IPFS / your own website). The URL is stored ON-CHAIN and every customer " +
|
|
75
|
+
"fetches it at order time — a local file path, localhost/loopback URL, or LAN private-IP URL " +
|
|
76
|
+
"is unreachable by customers on other machines and aborts order_new 100%. Local-network URLs " +
|
|
77
|
+
"are INTERNAL TEST USE ONLY (env.network = localnet). Leave sale.wip empty (\"\") to skip " +
|
|
78
|
+
"WIP verification (TESTING ONLY)."),
|
|
73
79
|
repositories: ObjectsSchema.optional().describe("Service Repository object list."),
|
|
74
80
|
rewards: ObjectsSchema.optional().describe("Service Reward object list. " +
|
|
75
81
|
"May share the Service's Permission (no conflict check — intentional: rewards are the provider's own " +
|