@wowok/agent-mcp 2.7.1 → 2.7.2
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/index.js +1 -1
- package/dist/config/runtime.js +1 -238
- package/dist/customer/customer-advice.js +1 -130
- package/dist/customer/index.js +1 -11
- package/dist/customer/industry-risks.js +1 -438
- package/dist/customer/info-puzzle.js +1 -681
- package/dist/customer/order-monitor.js +1 -328
- package/dist/customer/order-strategy.js +1 -373
- package/dist/customer/post-purchase.js +1 -351
- package/dist/customer/preorder-compare.js +1 -34
- package/dist/customer/reminder-system.js +1 -316
- package/dist/customer/risk-assessment.js +1 -397
- package/dist/customer/types.js +1 -13
- package/dist/customer/user-preferences.js +1 -460
- package/dist/evaluation/arbitration-game.d.ts +9 -2
- package/dist/evaluation/arbitration-game.js +1 -48
- package/dist/evaluation/builtins/demand-match.js +1 -153
- package/dist/evaluation/builtins/index.js +1 -10
- package/dist/evaluation/builtins/service-risk.js +1 -55
- package/dist/evaluation/capability.js +1 -13
- package/dist/evaluation/composer.js +1 -40
- package/dist/evaluation/engine.js +1 -175
- package/dist/evaluation/extract.js +1 -115
- package/dist/evaluation/game-strategy.d.ts +27 -0
- package/dist/evaluation/game-strategy.js +1 -0
- package/dist/evaluation/gap.js +1 -100
- package/dist/evaluation/index.d.ts +1 -0
- package/dist/evaluation/index.js +1 -11
- package/dist/evaluation/node-game.d.ts +31 -3
- package/dist/evaluation/node-game.js +1 -57
- package/dist/evaluation/region.js +1 -36
- package/dist/evaluation/types.d.ts +1 -0
- package/dist/evaluation/types.js +1 -1
- package/dist/evaluation/user-injection.js +1 -27
- package/dist/experience/experience-reuse.js +1 -103
- package/dist/experience/index.js +1 -5
- package/dist/experience/intent-distill.js +1 -83
- package/dist/experience/realtime-feedback.js +1 -94
- package/dist/experience/types.js +1 -1
- package/dist/experience/user-profile.js +1 -171
- package/dist/extensions/business-modules.js +1 -287
- package/dist/extensions/capability-manifest.js +1 -781
- package/dist/extensions/constraint-registry.js +1 -198
- package/dist/extensions/index.js +1 -6
- package/dist/extensions/metric-registry.js +1 -257
- package/dist/extensions/mode-evaluator.js +1 -170
- package/dist/extensions/modes.js +1 -499
- package/dist/extensions/registry.js +1 -717
- package/dist/extensions/types.js +1 -1
- package/dist/harness/auto-escalation.js +1 -68
- package/dist/harness/checkpoint.js +1 -129
- package/dist/harness/index.js +1 -78
- package/dist/harness/plan.js +1 -315
- package/dist/harness/recover.js +1 -139
- package/dist/harness/types.js +1 -1
- package/dist/harness/verify.js +1 -237
- package/dist/index.js +1 -273
- package/dist/intent/enrich.js +1 -67
- package/dist/intent/index.js +1 -60
- package/dist/intent/matcher.js +1 -81
- package/dist/intent/store.js +1 -55
- package/dist/intent/types.js +1 -10
- package/dist/knowledge/acquisition-flywheel.js +1 -192
- package/dist/knowledge/allocation-confirm.js +1 -534
- package/dist/knowledge/allocation-context.js +1 -249
- package/dist/knowledge/allocation-ledger.js +1 -463
- package/dist/knowledge/allocation-puzzle.js +1 -298
- package/dist/knowledge/allocation-risk.js +1 -568
- package/dist/knowledge/allocation-templates.js +1 -970
- package/dist/knowledge/allocation-translation.js +1 -585
- package/dist/knowledge/arb-risk.js +1 -210
- package/dist/knowledge/arbitration-confirm.js +1 -559
- package/dist/knowledge/arbitration-context.js +1 -505
- package/dist/knowledge/arbitration-ledger.js +1 -521
- package/dist/knowledge/arbitration-puzzle.js +1 -304
- package/dist/knowledge/arbitration-risk.js +1 -423
- package/dist/knowledge/arbitration-templates.js +1 -276
- package/dist/knowledge/arbitration-translation.js +1 -487
- package/dist/knowledge/arbitration-trust.js +1 -117
- package/dist/knowledge/audit-rules.js +1 -141
- package/dist/knowledge/bridge-risk.js +1 -263
- package/dist/knowledge/contact-risk.js +1 -200
- package/dist/knowledge/contact-templates.js +1 -60
- package/dist/knowledge/demand-confirm.js +1 -206
- package/dist/knowledge/demand-matching.js +1 -132
- package/dist/knowledge/demand-risk.js +1 -240
- package/dist/knowledge/demand-translation.js +1 -354
- package/dist/knowledge/deployment-scanner.js +1 -823
- package/dist/knowledge/dynamic-pricing.js +1 -87
- package/dist/knowledge/examples-scanner-cli.js +1 -26
- package/dist/knowledge/examples-scanner.js +1 -843
- package/dist/knowledge/flywheel-loop.js +1 -404
- package/dist/knowledge/fund-layer.js +1 -973
- package/dist/knowledge/glossary.js +1 -211
- package/dist/knowledge/guard-confirm.js +1 -406
- package/dist/knowledge/guard-context.js +1 -287
- package/dist/knowledge/guard-design-patterns.js +1 -360
- package/dist/knowledge/guard-ledger.js +1 -260
- package/dist/knowledge/guard-lint.js +1 -670
- package/dist/knowledge/guard-migration.js +1 -228
- package/dist/knowledge/guard-puzzle.js +1 -805
- package/dist/knowledge/guard-render.js +1 -700
- package/dist/knowledge/guard-risk.js +1 -1879
- package/dist/knowledge/guard-submission-prompt.js +1 -171
- package/dist/knowledge/guard-templates.js +1 -1105
- package/dist/knowledge/guard-translation.js +1 -1119
- package/dist/knowledge/index.js +1 -436
- package/dist/knowledge/industry-evolution.js +1 -323
- package/dist/knowledge/industry-generalizer.js +1 -381
- package/dist/knowledge/industry-registry.js +1 -174
- package/dist/knowledge/intent-metrics.d.ts +4 -3
- package/dist/knowledge/intent-metrics.js +1 -566
- package/dist/knowledge/machine-confirm.js +1 -559
- package/dist/knowledge/machine-context.js +1 -833
- package/dist/knowledge/machine-ledger.js +1 -338
- package/dist/knowledge/machine-puzzle.js +1 -494
- package/dist/knowledge/machine-render.js +1 -565
- package/dist/knowledge/machine-risk.js +1 -669
- package/dist/knowledge/machine-templates.js +1 -1597
- package/dist/knowledge/machine-topology.js +1 -234
- package/dist/knowledge/machine-translation.js +1 -513
- package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
- package/dist/knowledge/mcp-schema-audit.js +1 -777
- package/dist/knowledge/onchain-constants.js +1 -35
- package/dist/knowledge/order-confirm.js +1 -573
- package/dist/knowledge/order-context.js +1 -390
- package/dist/knowledge/order-ledger.js +1 -341
- package/dist/knowledge/order-puzzle.js +1 -255
- package/dist/knowledge/order-risk.js +1 -653
- package/dist/knowledge/order-templates.js +1 -368
- package/dist/knowledge/order-translation.js +1 -550
- package/dist/knowledge/overrides-loader.js +1 -65
- package/dist/knowledge/passport-confirm.js +1 -531
- package/dist/knowledge/passport-context.js +1 -306
- package/dist/knowledge/passport-ledger.js +1 -282
- package/dist/knowledge/passport-puzzle.js +1 -333
- package/dist/knowledge/passport-risk.js +1 -450
- package/dist/knowledge/passport-templates.js +1 -568
- package/dist/knowledge/passport-translation.js +1 -516
- package/dist/knowledge/payment-risk.js +1 -249
- package/dist/knowledge/permission-confirm.js +1 -426
- package/dist/knowledge/permission-context.js +1 -224
- package/dist/knowledge/permission-ledger.js +1 -403
- package/dist/knowledge/permission-puzzle.js +1 -173
- package/dist/knowledge/permission-risk.js +1 -411
- package/dist/knowledge/permission-templates.js +1 -234
- package/dist/knowledge/permission-translation.js +1 -350
- package/dist/knowledge/personal-risk.js +1 -212
- package/dist/knowledge/process-model.js +1 -160
- package/dist/knowledge/progress-confirm.js +1 -456
- package/dist/knowledge/progress-context.js +1 -452
- package/dist/knowledge/progress-ledger.js +1 -330
- package/dist/knowledge/progress-puzzle.js +1 -219
- package/dist/knowledge/progress-risk.js +1 -461
- package/dist/knowledge/progress-templates.js +1 -228
- package/dist/knowledge/progress-translation.js +1 -405
- package/dist/knowledge/proof-confirm.js +1 -187
- package/dist/knowledge/proof-risk.js +1 -207
- package/dist/knowledge/proof-translation.js +1 -283
- package/dist/knowledge/registrar-risk.js +1 -217
- package/dist/knowledge/repository-confirm.js +1 -286
- package/dist/knowledge/repository-risk.js +1 -373
- package/dist/knowledge/repository-translation.js +1 -445
- package/dist/knowledge/reputation-rules.js +1 -99
- package/dist/knowledge/resource-risk.js +1 -157
- package/dist/knowledge/reward-confirm.js +1 -526
- package/dist/knowledge/reward-context.js +1 -504
- package/dist/knowledge/reward-ledger.js +1 -502
- package/dist/knowledge/reward-puzzle.js +1 -300
- package/dist/knowledge/reward-risk.js +1 -627
- package/dist/knowledge/reward-templates.js +1 -197
- package/dist/knowledge/reward-translation.js +1 -501
- package/dist/knowledge/safety-rules.js +1 -404
- package/dist/knowledge/scenario-modes.js +1 -321
- package/dist/knowledge/service-confirm.js +1 -807
- package/dist/knowledge/service-context.js +1 -403
- package/dist/knowledge/service-ledger.js +1 -609
- package/dist/knowledge/service-puzzle.js +1 -236
- package/dist/knowledge/service-risk.js +1 -651
- package/dist/knowledge/service-templates.js +1 -456
- package/dist/knowledge/service-translation.js +1 -622
- package/dist/knowledge/template-registry.js +1 -353
- package/dist/knowledge/tool-constraints.js +1 -195
- package/dist/knowledge/tools-reference.js +1 -178
- package/dist/knowledge/treasury-confirm.js +1 -512
- package/dist/knowledge/treasury-context.js +1 -363
- package/dist/knowledge/treasury-ledger.js +1 -300
- package/dist/knowledge/treasury-puzzle.js +1 -216
- package/dist/knowledge/treasury-risk.js +1 -440
- package/dist/knowledge/treasury-templates.js +1 -358
- package/dist/knowledge/treasury-translation.js +1 -498
- package/dist/knowledge/trust-metrics.js +1 -198
- package/dist/knowledge/util-risk.js +1 -135
- package/dist/loop-engineering/aggregate.js +1 -132
- package/dist/loop-engineering/context-collect.js +1 -83
- package/dist/loop-engineering/diagnose.js +1 -273
- package/dist/loop-engineering/improve.js +1 -405
- package/dist/loop-engineering/index.js +1 -4
- package/dist/loop-engineering/pipeline.js +1 -56
- package/dist/mode-market/index.js +1 -3
- package/dist/mode-market/registry.js +1 -124
- package/dist/mode-market/review.js +1 -214
- package/dist/mode-market/submission.js +1 -85
- package/dist/participation/collaborator-interest.d.ts +23 -0
- package/dist/participation/collaborator-interest.js +1 -0
- package/dist/participation/customer-interest.d.ts +25 -0
- package/dist/participation/customer-interest.js +1 -0
- package/dist/participation/merchant-interest.js +1 -100
- package/dist/participation/radar-core.d.ts +13 -3
- package/dist/participation/radar-core.js +1 -269
- package/dist/participation/supplier-interest.d.ts +25 -0
- package/dist/participation/supplier-interest.js +1 -0
- package/dist/persona/analyzer.js +1 -66
- package/dist/persona/bridge.js +1 -86
- package/dist/persona/defaults.js +1 -195
- package/dist/persona/experience-bridge.js +1 -23
- package/dist/persona/index.js +1 -71
- package/dist/persona/model.js +1 -111
- package/dist/persona/store.js +1 -62
- package/dist/persona/types.d.ts +3 -1
- package/dist/persona/types.js +1 -5
- package/dist/project/business-puzzle.js +1 -383
- package/dist/project/context-assembly.js +1 -254
- package/dist/project/deployment-bridge.js +1 -120
- package/dist/project/deployment-doc.js +1 -1126
- package/dist/project/edit-planner.js +1 -1342
- package/dist/project/evaluation.js +1 -2011
- package/dist/project/game-theory.js +1 -177
- package/dist/project/graph-builder.js +1 -656
- package/dist/project/graph.js +1 -340
- package/dist/project/handlers.js +1 -1784
- package/dist/project/index.d.ts +1 -0
- package/dist/project/index.js +1 -301
- package/dist/project/intent-analyzer.js +1 -149
- package/dist/project/machine-nodes.js +1 -36
- package/dist/project/merchant-guide.js +1 -264
- package/dist/project/migration.js +1 -125
- package/dist/project/mode-actions.js +1 -309
- package/dist/project/namespace.js +1 -206
- package/dist/project/participation-radar.js +1 -428
- package/dist/project/pipeline-actions.js +1 -109
- package/dist/project/project-store.js +1 -422
- package/dist/project/query.js +1 -153
- package/dist/project/reverse-mapping.d.ts +34 -0
- package/dist/project/reverse-mapping.js +1 -0
- package/dist/project/risk-aggregator.js +1 -295
- package/dist/project/rollback-policy.js +1 -290
- package/dist/project/semantic-assembler.js +1 -345
- package/dist/project/semantic-graph.js +1 -292
- package/dist/project/stage-gate.js +1 -369
- package/dist/project/substep-trace.js +1 -332
- package/dist/project/task-tracker.js +1 -78
- package/dist/role/derivation.d.ts +18 -0
- package/dist/role/derivation.js +1 -0
- package/dist/role/index.d.ts +5 -0
- package/dist/role/index.js +1 -0
- package/dist/role/model.d.ts +8 -0
- package/dist/role/model.js +1 -0
- package/dist/role/resolution.d.ts +11 -0
- package/dist/role/resolution.js +1 -0
- package/dist/role/types.d.ts +11 -0
- package/dist/role/types.js +1 -0
- package/dist/rules.js +1 -52
- package/dist/safety/confirm-gate.js +1 -88
- package/dist/safety/index.js +1 -3
- package/dist/safety/preview.js +1 -52
- package/dist/schema/call/allocation.js +1 -34
- package/dist/schema/call/arbitration.js +1 -113
- package/dist/schema/call/base.d.ts +15 -15
- package/dist/schema/call/base.js +1 -370
- package/dist/schema/call/bridge-handler.js +1 -265
- package/dist/schema/call/bridge.d.ts +7 -7
- package/dist/schema/call/bridge.js +1 -458
- package/dist/schema/call/contact.js +1 -37
- package/dist/schema/call/demand.js +1 -47
- package/dist/schema/call/guard.js +1 -161
- package/dist/schema/call/handler.js +1 -322
- package/dist/schema/call/index.js +1 -20
- package/dist/schema/call/machine.js +1 -193
- package/dist/schema/call/order.js +1 -35
- package/dist/schema/call/payment.js +1 -37
- package/dist/schema/call/permission-handler.js +1 -54
- package/dist/schema/call/permission.js +1 -105
- package/dist/schema/call/personal.js +1 -78
- package/dist/schema/call/progress.js +1 -47
- package/dist/schema/call/proof.js +1 -33
- package/dist/schema/call/repository.js +1 -77
- package/dist/schema/call/reward.js +1 -30
- package/dist/schema/call/semantic.js +1 -1679
- package/dist/schema/call/service.js +1 -184
- package/dist/schema/call/treasury.js +1 -71
- package/dist/schema/common/index.js +1 -407
- package/dist/schema/config/index.js +1 -68
- package/dist/schema/evaluation/index.d.ts +213 -16
- package/dist/schema/evaluation/index.js +1 -356
- package/dist/schema/index.js +1 -17
- package/dist/schema/intent-radar/index.d.ts +13 -13
- package/dist/schema/intent-radar/index.js +1 -89
- package/dist/schema/local/index.d.ts +21 -21
- package/dist/schema/local/index.js +1 -927
- package/dist/schema/local/wip.js +1 -187
- package/dist/schema/messenger/index.d.ts +7 -7
- package/dist/schema/messenger/index.js +1 -475
- package/dist/schema/operations.d.ts +7 -7
- package/dist/schema/operations.js +1 -520
- package/dist/schema/persona/index.d.ts +54 -54
- package/dist/schema/persona/index.js +1 -148
- package/dist/schema/project/index.d.ts +94 -48
- package/dist/schema/project/index.js +1 -2057
- package/dist/schema/query/index.d.ts +423 -7
- package/dist/schema/query/index.js +1 -1646
- package/dist/schema/schema-query/index.js +1 -104
- package/dist/schema/schema-version.js +1 -76
- package/dist/schema/sync-layer4.js +1 -286
- package/dist/schema/task-status.js +1 -36
- package/dist/schema/trust/index.js +1 -314
- package/dist/schema/utils/guard-parser.js +1 -419
- package/dist/schema/utils/guard-query-utils.js +1 -46
- package/dist/schema/utils/node-parser.js +1 -369
- package/dist/schema/utils/object-type-utils.js +1 -35
- package/dist/schema/utils/permission-index-utils.js +1 -7
- package/dist/schema/utils/permission-machine-check.js +1 -121
- package/dist/schema/utils/skills-recommendation.js +1 -77
- package/dist/schema-query/index.js +1 -810
- package/dist/schemas/account_operation.output.json +5 -2
- package/dist/schemas/bridge_operation.output.json +5 -2
- package/dist/schemas/evaluation_operation.output.json +112 -7
- package/dist/schemas/evaluation_operation.schema.json +93 -6
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/intent_radar.output.json +4 -1
- package/dist/schemas/intent_radar.schema.json +4 -1
- package/dist/schemas/local_info_operation.output.json +5 -2
- package/dist/schemas/local_mark_operation.output.json +5 -2
- package/dist/schemas/messenger_operation.output.json +5 -2
- package/dist/schemas/onchain_events.output.json +5 -2
- package/dist/schemas/onchain_operations.output.json +5 -2
- package/dist/schemas/onchain_operations.schema.json +4 -4
- package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
- package/dist/schemas/onchain_operations_machine.schema.json +2 -2
- package/dist/schemas/onchain_operations_service.schema.json +1 -1
- package/dist/schemas/onchain_table_data.output.json +6 -3
- package/dist/schemas/persona_operation.output.json +4 -1
- package/dist/schemas/persona_operation.schema.json +4 -1
- package/dist/schemas/project_operation.output.json +28 -8
- package/dist/schemas/query_toolkit.output.json +8 -5
- package/dist/schemas/wowok_buildin_info.output.json +132 -0
- package/dist/schemas/wowok_buildin_info.schema.json +14 -0
- package/dist/telemetry/index.js +1 -112
- package/dist/telemetry/redact.js +1 -23
- package/dist/telemetry/storage.js +1 -80
- package/dist/tools/handlers/bridge.js +1 -1
- package/dist/tools/handlers/config.js +1 -74
- package/dist/tools/handlers/evaluation.js +1 -123
- package/dist/tools/handlers/file-export.js +1 -90
- package/dist/tools/handlers/intent-radar.js +1 -76
- package/dist/tools/handlers/local.js +1 -53
- package/dist/tools/handlers/messenger.js +1 -188
- package/dist/tools/handlers/onchain.js +1 -1180
- package/dist/tools/handlers/persona.js +1 -89
- package/dist/tools/handlers/project.js +1 -211
- package/dist/tools/handlers/query.js +1 -434
- package/dist/tools/handlers/schema-query.js +1 -176
- package/dist/tools/handlers/task-status.js +1 -26
- package/dist/tools/handlers/trust.js +1 -380
- package/dist/tools/handlers/wip.js +1 -90
- package/dist/tools/index.js +1 -1382
- package/dist/tools/retry.js +1 -85
- package/dist/tools/rules-hook.js +1 -23
- package/dist/tools/shared.js +1 -130
- package/dist/tools/types.js +1 -1
- package/dist/tools/upgrade-check.d.ts +19 -0
- package/dist/tools/upgrade-check.js +1 -0
- package/dist/tools/wip-deploy-assist.js +1 -306
- package/dist/tools/wrap.js +1 -500
- package/package.json +4 -2
|
@@ -1,123 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { EvaluationOperationInputSchema } from "../../schema/evaluation/index.js";
|
|
3
|
-
import { evaluateArbGame } from "../../evaluation/arbitration-game.js";
|
|
4
|
-
import { evaluateNodeGame } from "../../evaluation/node-game.js";
|
|
5
|
-
import { summarizeCapabilityGaps } from "../../evaluation/gap.js";
|
|
6
|
-
import { composeServicesForDemand } from "../../evaluation/composer.js";
|
|
7
|
-
import { matchDemandToServices, matchServiceToDemands } from "../../evaluation/builtins/demand-match.js";
|
|
8
|
-
import { assessServiceRisk } from "../../evaluation/builtins/service-risk.js";
|
|
9
|
-
import { registerBuiltinEvaluations } from "../../evaluation/builtins/index.js";
|
|
10
|
-
import { getEffectivePersona, mergeInjections, personaToInjection } from "../../persona/index.js";
|
|
11
|
-
registerBuiltinEvaluations();
|
|
12
|
-
function capabilityFromInput(input) {
|
|
13
|
-
return {
|
|
14
|
-
id: input.id,
|
|
15
|
-
kind: input.kind,
|
|
16
|
-
owner: input.owner ?? "",
|
|
17
|
-
industry: input.industry,
|
|
18
|
-
industry_confidence: input.industry_confidence ?? 0,
|
|
19
|
-
region: input.region,
|
|
20
|
-
price_min: input.price_min !== undefined ? BigInt(input.price_min) : undefined,
|
|
21
|
-
price_max: input.price_max !== undefined ? BigInt(input.price_max) : undefined,
|
|
22
|
-
token_type: input.token_type ?? "",
|
|
23
|
-
ticket_size: input.ticket_size ?? "medium",
|
|
24
|
-
trust_score: input.trust_score ?? 50,
|
|
25
|
-
reputation_like_ratio: input.reputation_like_ratio ?? 1,
|
|
26
|
-
arbitration_independent: input.arbitration_independent ?? false,
|
|
27
|
-
merchant_history_count: input.merchant_history_count ?? 0,
|
|
28
|
-
capabilities: input.capabilities,
|
|
29
|
-
tags: input.tags ?? [],
|
|
30
|
-
keywords: input.keywords ?? [],
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
function puzzleRawFromInput(input) {
|
|
34
|
-
return {
|
|
35
|
-
service: {
|
|
36
|
-
...input.service,
|
|
37
|
-
priceRaw: input.service.priceRaw !== undefined ? BigInt(input.service.priceRaw) : undefined,
|
|
38
|
-
compensation_fund: input.service.compensation_fund
|
|
39
|
-
? { balance: input.service.compensation_fund.balance !== undefined ? BigInt(input.service.compensation_fund.balance) : undefined }
|
|
40
|
-
: undefined,
|
|
41
|
-
},
|
|
42
|
-
machine_nodes: input.machine_nodes,
|
|
43
|
-
machine_published: input.machine_published,
|
|
44
|
-
machine_paused: input.machine_paused,
|
|
45
|
-
reviews: input.reviews,
|
|
46
|
-
events: input.events,
|
|
47
|
-
similar_services: input.similar_services?.map((s) => ({ price: BigInt(s.price) })),
|
|
48
|
-
order_amount: input.order_amount !== undefined ? BigInt(input.order_amount) : undefined,
|
|
49
|
-
trust_score: input.trust_score,
|
|
50
|
-
arbitration_owner: input.arbitration_owner,
|
|
51
|
-
service_owner: input.service_owner,
|
|
52
|
-
wip_verified: input.wip_verified,
|
|
53
|
-
order_history: input.order_history,
|
|
54
|
-
merchant_reputation: input.merchant_reputation,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
async function resolveInjection(account, explicit) {
|
|
58
|
-
const base = account ? personaToInjection(await getEffectivePersona(account)) : undefined;
|
|
59
|
-
return mergeInjections(base, explicit);
|
|
60
|
-
}
|
|
61
|
-
export async function handleEvaluationOperation(args) {
|
|
62
|
-
const validated = strictParse(EvaluationOperationInputSchema, args, "evaluation_operation input");
|
|
63
|
-
let result;
|
|
64
|
-
switch (validated.action) {
|
|
65
|
-
case "arb_game": {
|
|
66
|
-
result = { action: "arb_game", ...evaluateArbGame(validated.status, validated.perspective) };
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
case "node_game": {
|
|
70
|
-
result = {
|
|
71
|
-
action: "node_game",
|
|
72
|
-
...evaluateNodeGame({
|
|
73
|
-
current_node: validated.current_node,
|
|
74
|
-
perspective: validated.perspective,
|
|
75
|
-
operable: validated.operable,
|
|
76
|
-
waiting_on: validated.waiting_on ?? [],
|
|
77
|
-
}),
|
|
78
|
-
};
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
case "capability_gap": {
|
|
82
|
-
result = {
|
|
83
|
-
action: "capability_gap",
|
|
84
|
-
report: summarizeCapabilityGaps(capabilityFromInput(validated.demand), capabilityFromInput(validated.service)),
|
|
85
|
-
};
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
case "compose_service": {
|
|
89
|
-
result = {
|
|
90
|
-
action: "compose_service",
|
|
91
|
-
plan: composeServicesForDemand(capabilityFromInput(validated.demand), validated.services.map(capabilityFromInput)),
|
|
92
|
-
};
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
case "demand_match": {
|
|
96
|
-
result = {
|
|
97
|
-
action: "demand_match",
|
|
98
|
-
matches: await matchDemandToServices(capabilityFromInput(validated.demand_cap), validated.services, await resolveInjection(validated.account, validated.injection)),
|
|
99
|
-
};
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
case "service_match": {
|
|
103
|
-
result = {
|
|
104
|
-
action: "service_match",
|
|
105
|
-
matches: await matchServiceToDemands(capabilityFromInput(validated.service_cap), validated.demands, await resolveInjection(validated.account, validated.injection)),
|
|
106
|
-
};
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
case "service_risk": {
|
|
110
|
-
result = {
|
|
111
|
-
action: "service_risk",
|
|
112
|
-
result: await assessServiceRisk(validated.service_id, puzzleRawFromInput(validated.puzzle_raw), await resolveInjection(validated.account, validated.injection), validated.depth ?? "preorder"),
|
|
113
|
-
};
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
default:
|
|
117
|
-
throw new Error("Unknown evaluation_operation action");
|
|
118
|
-
}
|
|
119
|
-
return {
|
|
120
|
-
content: [{ type: "text", text: JSON.stringify({ result }) }],
|
|
121
|
-
structuredContent: { result },
|
|
122
|
-
};
|
|
123
|
-
}
|
|
1
|
+
import{strictParse}from'../../schema/index.js';import{EvaluationOperationInputSchema}from'../../schema/evaluation/index.js';import{evaluateArbGame}from'../../evaluation/arbitration-game.js';import{evaluateNodeGame}from'../../evaluation/node-game.js';import{summarizeCapabilityGaps}from'../../evaluation/gap.js';import{composeServicesForDemand}from'../../evaluation/composer.js';import{matchDemandToServices,matchServiceToDemands}from'../../evaluation/builtins/demand-match.js';import{assessServiceRisk}from'../../evaluation/builtins/service-risk.js';import{registerBuiltinEvaluations}from'../../evaluation/builtins/index.js';import{getEffectivePersona,mergeInjections,personaToInjection}from'../../persona/index.js';registerBuiltinEvaluations();function capabilityFromInput(a){return{'id':a['id'],'kind':a['kind'],'owner':a['owner']??'','industry':a['industry'],'industry_confidence':a['industry_confidence']??0x0,'region':a['region'],'price_min':a['price_min']!==undefined?BigInt(a['price_min']):undefined,'price_max':a['price_max']!==undefined?BigInt(a['price_max']):undefined,'token_type':a['token_type']??'','ticket_size':a['ticket_size']??'medium','trust_score':a['trust_score']??0x32,'reputation_like_ratio':a['reputation_like_ratio']??0x1,'arbitration_independent':a['arbitration_independent']??![],'merchant_history_count':a['merchant_history_count']??0x0,'capabilities':a['capabilities'],'tags':a['tags']??[],'keywords':a['keywords']??[]};}function puzzleRawFromInput(a){return{'service':{...a['service'],'priceRaw':a['service']['priceRaw']!==undefined?BigInt(a['service']['priceRaw']):undefined,'compensation_fund':a['service']['compensation_fund']?{'balance':a['service']['compensation_fund']['balance']!==undefined?BigInt(a['service']['compensation_fund']['balance']):undefined}:undefined},'machine_nodes':a['machine_nodes'],'machine_published':a['machine_published'],'machine_paused':a['machine_paused'],'reviews':a['reviews'],'events':a['events'],'similar_services':a['similar_services']?.['map'](b=>({'price':BigInt(b['price'])})),'order_amount':a['order_amount']!==undefined?BigInt(a['order_amount']):undefined,'trust_score':a['trust_score'],'arbitration_owner':a['arbitration_owner'],'service_owner':a['service_owner'],'wip_verified':a['wip_verified'],'order_history':a['order_history'],'merchant_reputation':a['merchant_reputation']};}async function resolveInjection(a,b){const c=a?personaToInjection(await getEffectivePersona(a)):undefined;return mergeInjections(c,b);}export async function handleEvaluationOperation(a){const b=strictParse(EvaluationOperationInputSchema,a,'evaluation_operation\x20input');let c;switch(b['action']){case'arb_game':{const d=b['account']?await getEffectivePersona(b['account']):null,e=b['appetite']??d?.['layer']['preferences']?.['risk_appetite'],f=b['requirements']??d?.['layer']['requirements'];c={'action':'arb_game',...evaluateArbGame(b['status'],b['perspective'],{'risk_appetite':e,'requirements':f})};break;}case'node_game':{const g=b['account']?await getEffectivePersona(b['account']):null,h=b['appetite']??g?.['layer']['preferences']?.['risk_appetite'],i=b['requirements']??g?.['layer']['requirements'];c={'action':'node_game',...evaluateNodeGame({'current_node':b['current_node'],'perspective':b['perspective'],'appetite':h,'requirements':i,'threshold':b['threshold'],'allocation':b['allocation'],'order_amount':b['order_amount'],'compensation_fund':b['compensation_fund'],'operable':b['operable'],'waiting_on':b['waiting_on']??[]})};break;}case'capability_gap':{c={'action':'capability_gap','report':summarizeCapabilityGaps(capabilityFromInput(b['demand']),capabilityFromInput(b['service']))};break;}case'compose_service':{c={'action':'compose_service','plan':composeServicesForDemand(capabilityFromInput(b['demand']),b['services']['map'](capabilityFromInput))};break;}case'demand_match':{c={'action':'demand_match','matches':await matchDemandToServices(capabilityFromInput(b['demand_cap']),b['services'],await resolveInjection(b['account'],b['injection']))};break;}case'service_match':{c={'action':'service_match','matches':await matchServiceToDemands(capabilityFromInput(b['service_cap']),b['demands'],await resolveInjection(b['account'],b['injection']))};break;}case'service_risk':{c={'action':'service_risk','result':await assessServiceRisk(b['service_id'],puzzleRawFromInput(b['puzzle_raw']),await resolveInjection(b['account'],b['injection']),b['depth']??'preorder')};break;}default:throw new Error('Unknown\x20evaluation_operation\x20action');}return{'content':[{'type':'text','text':JSON['stringify']({'result':c})}],'structuredContent':{'result':c}};}
|
|
@@ -1,90 +1 @@
|
|
|
1
|
-
import { resolve }
|
|
2
|
-
import { strictParse, getEnvConfig, Guard2File_InputSchema, MachineNode2File_InputSchema, } from "../../schema/index.js";
|
|
3
|
-
import { guard2file, machineNode2file, } from "@wowok/wowok";
|
|
4
|
-
export async function handleGuard2File(args) {
|
|
5
|
-
const validated = strictParse(Guard2File_InputSchema, args, "guard2file input");
|
|
6
|
-
const env = getEnvConfig(validated.env);
|
|
7
|
-
try {
|
|
8
|
-
await guard2file(validated.guard, validated.file_path, validated.format || "json", env.network);
|
|
9
|
-
const result = {
|
|
10
|
-
result: {
|
|
11
|
-
status: "success",
|
|
12
|
-
data: {
|
|
13
|
-
file_path: resolve(validated.file_path),
|
|
14
|
-
format: validated.format || "json",
|
|
15
|
-
guard_object: validated.guard,
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
return {
|
|
20
|
-
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
21
|
-
structuredContent: result,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
catch (error) {
|
|
25
|
-
const result = {
|
|
26
|
-
result: {
|
|
27
|
-
status: "error",
|
|
28
|
-
error: error.message,
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
return {
|
|
32
|
-
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
33
|
-
structuredContent: result,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
export async function handleMachineNode2File(args) {
|
|
38
|
-
const validated = strictParse(MachineNode2File_InputSchema, args, "machineNode2file input");
|
|
39
|
-
const env = getEnvConfig(validated.env);
|
|
40
|
-
try {
|
|
41
|
-
await machineNode2file(validated.machine, validated.file_path, validated.format || "json", env.network);
|
|
42
|
-
let node_count = undefined;
|
|
43
|
-
try {
|
|
44
|
-
const filePath = resolve(validated.file_path);
|
|
45
|
-
const fileContent = await import('fs/promises').then(fs => fs.readFile(filePath, 'utf-8'));
|
|
46
|
-
if ((validated.format || "json") === "json") {
|
|
47
|
-
const parsed = JSON.parse(fileContent);
|
|
48
|
-
if (Array.isArray(parsed)) {
|
|
49
|
-
node_count = parsed.length;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
const nodeMatches = fileContent.match(/^##\s+Node:/gm);
|
|
54
|
-
node_count = nodeMatches ? nodeMatches.length : 0;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
catch {
|
|
58
|
-
node_count = undefined;
|
|
59
|
-
}
|
|
60
|
-
const result = {
|
|
61
|
-
result: {
|
|
62
|
-
status: "success",
|
|
63
|
-
data: {
|
|
64
|
-
file_path: resolve(validated.file_path),
|
|
65
|
-
format: validated.format || "json",
|
|
66
|
-
machine_object: validated.machine,
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
|
-
if (node_count !== undefined) {
|
|
71
|
-
result.result.data.node_count = node_count;
|
|
72
|
-
}
|
|
73
|
-
return {
|
|
74
|
-
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
75
|
-
structuredContent: result,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
const result = {
|
|
80
|
-
result: {
|
|
81
|
-
status: "error",
|
|
82
|
-
error: error.message,
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
return {
|
|
86
|
-
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
87
|
-
structuredContent: result,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
}
|
|
1
|
+
import{resolve}from'path';import{strictParse,getEnvConfig,Guard2File_InputSchema,MachineNode2File_InputSchema}from'../../schema/index.js';import{guard2file,machineNode2file}from'@wowok/wowok';export async function handleGuard2File(a){const b=strictParse(Guard2File_InputSchema,a,'guard2file\x20input'),c=getEnvConfig(b['env']);try{await guard2file(b['guard'],b['file_path'],b['format']||'json',c['network']);const d={'result':{'status':'success','data':{'file_path':resolve(b['file_path']),'format':b['format']||'json','guard_object':b['guard']}}};return{'content':[{'type':'text','text':JSON['stringify'](d)}],'structuredContent':d};}catch(e){const f={'result':{'status':'error','error':e['message']}};return{'content':[{'type':'text','text':JSON['stringify'](f)}],'structuredContent':f};}}export async function handleMachineNode2File(a){const b=strictParse(MachineNode2File_InputSchema,a,'machineNode2file\x20input'),c=getEnvConfig(b['env']);try{await machineNode2file(b['machine'],b['file_path'],b['format']||'json',c['network']);let d=undefined;try{const f=resolve(b['file_path']),g=await import('fs/promises')['then'](h=>h['readFile'](f,'utf-8'));if((b['format']||'json')==='json'){const h=JSON['parse'](g);Array['isArray'](h)&&(d=h['length']);}else{const i=g['match'](/^##\s+Node:/gm);d=i?i['length']:0x0;}}catch{d=undefined;}const e={'result':{'status':'success','data':{'file_path':resolve(b['file_path']),'format':b['format']||'json','machine_object':b['machine']}}};return d!==undefined&&(e['result']['data']['node_count']=d),{'content':[{'type':'text','text':JSON['stringify'](e)}],'structuredContent':e};}catch(j){const k={'result':{'status':'error','error':j['message']}};return{'content':[{'type':'text','text':JSON['stringify'](k)}],'structuredContent':k};}}
|
|
@@ -1,76 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { IntentRadarInputSchema } from "../../schema/intent-radar/index.js";
|
|
3
|
-
import { createIntent, listIntents, matchAllIntents, matchIntent, removeIntent, } from "../../intent/index.js";
|
|
4
|
-
import { enrichEventsWithObjectText } from "../../intent/enrich.js";
|
|
5
|
-
import { query_events } from "@wowok/wowok";
|
|
6
|
-
const AUTO_PULL_TYPES = [
|
|
7
|
-
"NewOrderEvent",
|
|
8
|
-
"DemandPresentEvent",
|
|
9
|
-
"DemandFeedbackEvent",
|
|
10
|
-
"ProgressEvent",
|
|
11
|
-
"NewEntityEvent",
|
|
12
|
-
"ArbEvent",
|
|
13
|
-
];
|
|
14
|
-
async function pullRecentEvents(network, limit) {
|
|
15
|
-
const all = [];
|
|
16
|
-
for (const type of AUTO_PULL_TYPES) {
|
|
17
|
-
try {
|
|
18
|
-
const res = await query_events({
|
|
19
|
-
type,
|
|
20
|
-
cursor: null,
|
|
21
|
-
limit,
|
|
22
|
-
order: "descending",
|
|
23
|
-
no_cache: false,
|
|
24
|
-
network: network,
|
|
25
|
-
});
|
|
26
|
-
const data = res?.data;
|
|
27
|
-
if (Array.isArray(data))
|
|
28
|
-
all.push(...data);
|
|
29
|
-
}
|
|
30
|
-
catch {
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return all;
|
|
34
|
-
}
|
|
35
|
-
export async function handleIntentRadar(args) {
|
|
36
|
-
const validated = strictParse(IntentRadarInputSchema, args, "intent_radar input");
|
|
37
|
-
let result;
|
|
38
|
-
switch (validated.action) {
|
|
39
|
-
case "save": {
|
|
40
|
-
const intent = await createIntent({
|
|
41
|
-
intent: validated.intent,
|
|
42
|
-
account: validated.account,
|
|
43
|
-
role: validated.role,
|
|
44
|
-
target_types: validated.target_types,
|
|
45
|
-
});
|
|
46
|
-
result = { action: "save", intent };
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
case "list": {
|
|
50
|
-
result = { action: "list", intents: await listIntents(validated.account) };
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
case "remove": {
|
|
54
|
-
result = { action: "remove", removed: await removeIntent(validated.id) };
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
case "match": {
|
|
58
|
-
let events = validated.events ?? [];
|
|
59
|
-
if (events.length === 0) {
|
|
60
|
-
events = await pullRecentEvents(validated.network, validated.limit ?? 5);
|
|
61
|
-
}
|
|
62
|
-
events = await enrichEventsWithObjectText(events, validated.network);
|
|
63
|
-
const results = validated.intent_id
|
|
64
|
-
? [await matchIntent(validated.intent_id, events)].filter((r) => r !== null)
|
|
65
|
-
: await matchAllIntents(events, validated.account);
|
|
66
|
-
result = { action: "match", results };
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
default:
|
|
70
|
-
throw new Error("Unknown intent_radar action");
|
|
71
|
-
}
|
|
72
|
-
return {
|
|
73
|
-
content: [{ type: "text", text: JSON.stringify({ result }) }],
|
|
74
|
-
structuredContent: { result },
|
|
75
|
-
};
|
|
76
|
-
}
|
|
1
|
+
import{strictParse}from'../../schema/index.js';import{IntentRadarInputSchema}from'../../schema/intent-radar/index.js';import{createIntent,listIntents,matchAllIntents,matchIntent,removeIntent}from'../../intent/index.js';import{enrichEventsWithObjectText}from'../../intent/enrich.js';import{query_events}from'@wowok/wowok';const AUTO_PULL_TYPES=['NewOrderEvent','DemandPresentEvent','DemandFeedbackEvent','ProgressEvent','NewEntityEvent','ArbEvent'];async function pullRecentEvents(a,b){const c=[];for(const d of AUTO_PULL_TYPES){try{const e=await query_events({'type':d,'cursor':null,'limit':b,'order':'descending','no_cache':![],'network':a}),f=e?.['data'];if(Array['isArray'](f))c['push'](...f);}catch{}}return c;}export async function handleIntentRadar(a){const b=strictParse(IntentRadarInputSchema,a,'intent_radar\x20input');let c;switch(b['action']){case'save':{const d=await createIntent({'intent':b['intent'],'account':b['account'],'role':b['role'],'target_types':b['target_types']});c={'action':'save','intent':d};break;}case'list':{c={'action':'list','intents':await listIntents(b['account'])};break;}case'remove':{c={'action':'remove','removed':await removeIntent(b['id'])};break;}case'match':{let e=b['events']??[];e['length']===0x0&&(e=await pullRecentEvents(b['network'],b['limit']??0x5));e=await enrichEventsWithObjectText(e,b['network']);const f=b['intent_id']?[await matchIntent(b['intent_id'],e)]['filter'](g=>g!==null):await matchAllIntents(e,b['account']);c={'action':'match','results':f};break;}default:throw new Error('Unknown\x20intent_radar\x20action');}return{'content':[{'type':'text','text':JSON['stringify']({'result':c})}],'structuredContent':{'result':c}};}
|
|
@@ -1,53 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { withFaucetRetry } from "../retry.js";
|
|
3
|
-
import { AccountOperationSchema, LocalMarkOperationSchema, LocalInfoOperationSchema, } from "../../schema/index.js";
|
|
4
|
-
import { account_operation, local_mark_operation, local_info_operation, } from "@wowok/wowok";
|
|
5
|
-
function deriveOpType(prefix, validated) {
|
|
6
|
-
for (const key of Object.keys(validated)) {
|
|
7
|
-
if (validated[key] !== undefined) {
|
|
8
|
-
return `${prefix}_${String(key)}`;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
return `${prefix}_unknown`;
|
|
12
|
-
}
|
|
13
|
-
export const handleAccountOperation = wrapLocalHandler({
|
|
14
|
-
schema: AccountOperationSchema,
|
|
15
|
-
operationFn: withFaucetRetry(account_operation),
|
|
16
|
-
parseLabel: "account_operation input",
|
|
17
|
-
buildContext: (validated) => ({
|
|
18
|
-
operation_type: deriveOpType("account", validated),
|
|
19
|
-
data: validated,
|
|
20
|
-
}),
|
|
21
|
-
});
|
|
22
|
-
export const handleMarkOperation = wrapLocalHandler({
|
|
23
|
-
schema: LocalMarkOperationSchema,
|
|
24
|
-
operationFn: local_mark_operation,
|
|
25
|
-
parseLabel: "local_mark_operation input",
|
|
26
|
-
buildContext: (validated) => {
|
|
27
|
-
const ctx = {
|
|
28
|
-
operation_type: deriveOpType("mark", validated),
|
|
29
|
-
data: validated,
|
|
30
|
-
};
|
|
31
|
-
const v = validated;
|
|
32
|
-
if (v.add && Array.isArray(v.add.data) && v.add.data.length > 0) {
|
|
33
|
-
ctx.pre_warnings = [
|
|
34
|
-
"Cross-network consistency (FIX-011): LocalMark names are scoped per network. " +
|
|
35
|
-
"When creating marks for the same logical object on different networks " +
|
|
36
|
-
"(e.g. testnet and mainnet), use the SAME name value to keep name-based " +
|
|
37
|
-
"references portable. Before creating a mark on mainnet, consider querying " +
|
|
38
|
-
"testnet via query_local with network='testnet' to check for an existing " +
|
|
39
|
-
"same-named mark and replicate it.",
|
|
40
|
-
];
|
|
41
|
-
}
|
|
42
|
-
return ctx;
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
export const handleInfoOperation = wrapLocalHandler({
|
|
46
|
-
schema: LocalInfoOperationSchema,
|
|
47
|
-
operationFn: local_info_operation,
|
|
48
|
-
parseLabel: "local_info_operation input",
|
|
49
|
-
buildContext: (validated) => ({
|
|
50
|
-
operation_type: deriveOpType("local_info", validated),
|
|
51
|
-
data: validated,
|
|
52
|
-
}),
|
|
53
|
-
});
|
|
1
|
+
import{wrapLocalHandler}from'../shared.js';import{withFaucetRetry}from'../retry.js';import{AccountOperationSchema,LocalMarkOperationSchema,LocalInfoOperationSchema}from'../../schema/index.js';import{account_operation,local_mark_operation,local_info_operation}from'@wowok/wowok';function deriveOpType(a,b){for(const c of Object['keys'](b)){if(b[c]!==undefined)return a+'_'+String(c);}return a+'_unknown';}export const handleAccountOperation=wrapLocalHandler({'schema':AccountOperationSchema,'operationFn':withFaucetRetry(account_operation),'parseLabel':'account_operation\x20input','buildContext':a=>({'operation_type':deriveOpType('account',a),'data':a})});export const handleMarkOperation=wrapLocalHandler({'schema':LocalMarkOperationSchema,'operationFn':local_mark_operation,'parseLabel':'local_mark_operation\x20input','buildContext':a=>{const b={'operation_type':deriveOpType('mark',a),'data':a},c=a;return c['add']&&Array['isArray'](c['add']['data'])&&c['add']['data']['length']>0x0&&(b['pre_warnings']=['Cross-network\x20consistency\x20(FIX-011):\x20LocalMark\x20names\x20are\x20scoped\x20per\x20network.\x20'+'When\x20creating\x20marks\x20for\x20the\x20same\x20logical\x20object\x20on\x20different\x20networks\x20'+'(e.g.\x20testnet\x20and\x20mainnet),\x20use\x20the\x20SAME\x20name\x20value\x20to\x20keep\x20name-based\x20'+'references\x20portable.\x20Before\x20creating\x20a\x20mark\x20on\x20mainnet,\x20consider\x20querying\x20'+'testnet\x20via\x20query_local\x20with\x20network=\x27testnet\x27\x20to\x20check\x20for\x20an\x20existing\x20'+'same-named\x20mark\x20and\x20replicate\x20it.']),b;}});export const handleInfoOperation=wrapLocalHandler({'schema':LocalInfoOperationSchema,'operationFn':local_info_operation,'parseLabel':'local_info_operation\x20input','buildContext':a=>({'operation_type':deriveOpType('local_info',a),'data':a})});
|
|
@@ -1,188 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { watch_conversations, send_message, send_file, watch_messages, extract_zip_messages, pull_messages, generate_wts, verify_wts, sign_wts, wts2html, proof_message, mark_messages_as_viewed, mark_conversation_as_viewed, blacklist, friendslist, guardlist, settings, } from "@wowok/wowok";
|
|
3
|
-
import { classifyError, buildDataSemantic, } from "../../schema/call/semantic.js";
|
|
4
|
-
export function normalizeAccountOrMark(input) {
|
|
5
|
-
if (typeof input === 'string') {
|
|
6
|
-
return { name_or_address: input, local_mark_first: true };
|
|
7
|
-
}
|
|
8
|
-
return input;
|
|
9
|
-
}
|
|
10
|
-
export function normalizeManyAccountOrMark(input) {
|
|
11
|
-
if (Array.isArray(input)) {
|
|
12
|
-
return {
|
|
13
|
-
entities: input.map(item => typeof item === 'string' ? { name_or_address: item, local_mark_first: true } : item),
|
|
14
|
-
check_all_founded: true,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
return input;
|
|
18
|
-
}
|
|
19
|
-
export async function handleMessengerOperation(args) {
|
|
20
|
-
let validated;
|
|
21
|
-
try {
|
|
22
|
-
validated = strictParse(MessengerOperationInputSchema, args, "messenger_operation input");
|
|
23
|
-
const opLiteral = validated.operation;
|
|
24
|
-
let result;
|
|
25
|
-
switch (validated.operation) {
|
|
26
|
-
case "watch_conversations": {
|
|
27
|
-
const conversations = await watch_conversations(validated.filter);
|
|
28
|
-
result = { operation: "watch_conversations", result: conversations };
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
case "send_message": {
|
|
32
|
-
const sendResult = await send_message(validated.from, normalizeAccountOrMark(validated.to), validated.content, validated.options);
|
|
33
|
-
const filteredResult = {
|
|
34
|
-
...sendResult,
|
|
35
|
-
merkleData: sendResult.merkleData ? {
|
|
36
|
-
leafIndex: sendResult.merkleData.leafIndex,
|
|
37
|
-
prevRoot: sendResult.merkleData.prevRoot,
|
|
38
|
-
newRoot: sendResult.merkleData.newRoot,
|
|
39
|
-
serverSignature: sendResult.merkleData.serverSignature,
|
|
40
|
-
serverTimestamp: sendResult.merkleData.serverTimestamp,
|
|
41
|
-
serverPublicKey: sendResult.merkleData.serverPublicKey,
|
|
42
|
-
} : undefined,
|
|
43
|
-
};
|
|
44
|
-
result = { operation: "send_message", result: filteredResult };
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
case "send_file": {
|
|
48
|
-
const sendResult = await send_file(validated.from, normalizeAccountOrMark(validated.to), validated.filePath, validated.options);
|
|
49
|
-
const filteredResult = {
|
|
50
|
-
...sendResult,
|
|
51
|
-
merkleData: sendResult.merkleData ? {
|
|
52
|
-
leafIndex: sendResult.merkleData.leafIndex,
|
|
53
|
-
prevRoot: sendResult.merkleData.prevRoot,
|
|
54
|
-
newRoot: sendResult.merkleData.newRoot,
|
|
55
|
-
serverSignature: sendResult.merkleData.serverSignature,
|
|
56
|
-
serverTimestamp: sendResult.merkleData.serverTimestamp,
|
|
57
|
-
serverPublicKey: sendResult.merkleData.serverPublicKey,
|
|
58
|
-
} : undefined,
|
|
59
|
-
};
|
|
60
|
-
result = { operation: "send_file", result: filteredResult };
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
case "watch_messages": {
|
|
64
|
-
const filter = validated.filter ? {
|
|
65
|
-
...validated.filter,
|
|
66
|
-
peerAddress: validated.filter.peerAddress ? normalizeAccountOrMark(validated.filter.peerAddress) : undefined,
|
|
67
|
-
} : undefined;
|
|
68
|
-
const messages = await watch_messages(filter);
|
|
69
|
-
result = { operation: "watch_messages", result: messages };
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
case "extract_zip_messages": {
|
|
73
|
-
const extractedPaths = await extract_zip_messages(validated.account, validated.messages, validated.outputDir);
|
|
74
|
-
result = { operation: "extract_zip_messages", result: extractedPaths };
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
case "generate_wts": {
|
|
78
|
-
const params = validated.params ? {
|
|
79
|
-
...validated.params,
|
|
80
|
-
peerAccount: normalizeAccountOrMark(validated.params.peerAccount),
|
|
81
|
-
} : undefined;
|
|
82
|
-
const wtsResult = await generate_wts(params);
|
|
83
|
-
result = { operation: "generate_wts", result: wtsResult };
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
case "verify_wts": {
|
|
87
|
-
const verifyResult = await verify_wts(validated.wtsFilePath);
|
|
88
|
-
result = { operation: "verify_wts", result: verifyResult };
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
case "sign_wts": {
|
|
92
|
-
const signedPath = await sign_wts(validated.wtsFilePath, validated.account, validated.outputPath);
|
|
93
|
-
result = { operation: "sign_wts", result: signedPath };
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
case "wts2html": {
|
|
97
|
-
const htmlResult = await wts2html(validated.wtsPath, validated.options);
|
|
98
|
-
result = { operation: "wts2html", result: htmlResult };
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
case "proof_message": {
|
|
102
|
-
const proofResult = await proof_message(validated.account, validated.messageId, validated.network);
|
|
103
|
-
result = { operation: "proof_message", result: proofResult };
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
case "blacklist": {
|
|
107
|
-
const blacklistParams = {
|
|
108
|
-
account: validated.account,
|
|
109
|
-
op: validated.blacklist.op,
|
|
110
|
-
};
|
|
111
|
-
if ('users' in validated.blacklist) {
|
|
112
|
-
blacklistParams.users = normalizeManyAccountOrMark(validated.blacklist.users);
|
|
113
|
-
}
|
|
114
|
-
const blacklistResult = await blacklist(blacklistParams);
|
|
115
|
-
result = { operation: "blacklist", op: validated.blacklist.op, result: blacklistResult.result };
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
case "friendslist": {
|
|
119
|
-
const friendslistParams = {
|
|
120
|
-
account: validated.account,
|
|
121
|
-
op: validated.friendslist.op,
|
|
122
|
-
};
|
|
123
|
-
if ('users' in validated.friendslist) {
|
|
124
|
-
friendslistParams.users = normalizeManyAccountOrMark(validated.friendslist.users);
|
|
125
|
-
}
|
|
126
|
-
const friendslistResult = await friendslist(friendslistParams);
|
|
127
|
-
result = { operation: "friendslist", op: validated.friendslist.op, result: friendslistResult.result };
|
|
128
|
-
break;
|
|
129
|
-
}
|
|
130
|
-
case "guardlist": {
|
|
131
|
-
const guardlistResult = await guardlist({
|
|
132
|
-
account: validated.account,
|
|
133
|
-
...validated.guardlist,
|
|
134
|
-
});
|
|
135
|
-
result = { operation: "guardlist", op: validated.guardlist.op, result: guardlistResult.result };
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
case "settings": {
|
|
139
|
-
const settingsResult = await settings({
|
|
140
|
-
account: validated.account,
|
|
141
|
-
...validated.settings,
|
|
142
|
-
});
|
|
143
|
-
result = { operation: "settings", op: validated.settings.op, result: settingsResult.result };
|
|
144
|
-
break;
|
|
145
|
-
}
|
|
146
|
-
case "mark_messages_as_viewed": {
|
|
147
|
-
const markedCount = await mark_messages_as_viewed(validated.messageIds, validated.account);
|
|
148
|
-
result = { operation: "mark_messages_as_viewed", result: markedCount };
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
case "mark_conversation_as_viewed": {
|
|
152
|
-
const markedCount = await mark_conversation_as_viewed(normalizeAccountOrMark(validated.peerAddress), validated.account);
|
|
153
|
-
result = { operation: "mark_conversation_as_viewed", result: markedCount };
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
case "pull_messages": {
|
|
157
|
-
const messages = await pull_messages(validated.account, validated.limit);
|
|
158
|
-
result = { operation: "pull_messages", result: messages };
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
default:
|
|
162
|
-
throw new Error(`Unknown messenger operation: ${opLiteral}`);
|
|
163
|
-
}
|
|
164
|
-
return {
|
|
165
|
-
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
166
|
-
structuredContent: { result },
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
catch (error) {
|
|
170
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
171
|
-
const ctx = validated ? { operation_type: "messenger_" + validated.operation, data: validated } : undefined;
|
|
172
|
-
const classified = classifyError(errorMessage);
|
|
173
|
-
const errorResult = { operation: "error", error: errorMessage };
|
|
174
|
-
if (classified.error_code !== undefined)
|
|
175
|
-
errorResult.error_code = classified.error_code;
|
|
176
|
-
if (classified.retryable !== undefined)
|
|
177
|
-
errorResult.retryable = classified.retryable;
|
|
178
|
-
if (classified.recovery_hint !== undefined)
|
|
179
|
-
errorResult.recovery_hint = classified.recovery_hint;
|
|
180
|
-
return {
|
|
181
|
-
content: [{ type: "text", text: `Error: ${errorMessage}` }],
|
|
182
|
-
structuredContent: {
|
|
183
|
-
result: errorResult,
|
|
184
|
-
semantic: buildDataSemantic(undefined, ctx, true, errorMessage),
|
|
185
|
-
},
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
}
|
|
1
|
+
import{strictParse,MessengerOperationInputSchema}from'../../schema/index.js';import{watch_conversations,send_message,send_file,watch_messages,extract_zip_messages,pull_messages,generate_wts,verify_wts,sign_wts,wts2html,proof_message,mark_messages_as_viewed,mark_conversation_as_viewed,blacklist,friendslist,guardlist,settings}from'@wowok/wowok';import{classifyError,buildDataSemantic}from'../../schema/call/semantic.js';export function normalizeAccountOrMark(a){if(typeof a==='string')return{'name_or_address':a,'local_mark_first':!![]};return a;}export function normalizeManyAccountOrMark(a){if(Array['isArray'](a))return{'entities':a['map'](b=>typeof b==='string'?{'name_or_address':b,'local_mark_first':!![]}:b),'check_all_founded':!![]};return a;}export async function handleMessengerOperation(a){let b;try{b=strictParse(MessengerOperationInputSchema,a,'messenger_operation\x20input');const c=b['operation'];let d;switch(b['operation']){case'watch_conversations':{const e=await watch_conversations(b['filter']);d={'operation':'watch_conversations','result':e};break;}case'send_message':{const f=await send_message(b['from'],normalizeAccountOrMark(b['to']),b['content'],b['options']),g={...f,'merkleData':f['merkleData']?{'leafIndex':f['merkleData']['leafIndex'],'prevRoot':f['merkleData']['prevRoot'],'newRoot':f['merkleData']['newRoot'],'serverSignature':f['merkleData']['serverSignature'],'serverTimestamp':f['merkleData']['serverTimestamp'],'serverPublicKey':f['merkleData']['serverPublicKey']}:undefined};d={'operation':'send_message','result':g};break;}case'send_file':{const h=await send_file(b['from'],normalizeAccountOrMark(b['to']),b['filePath'],b['options']),i={...h,'merkleData':h['merkleData']?{'leafIndex':h['merkleData']['leafIndex'],'prevRoot':h['merkleData']['prevRoot'],'newRoot':h['merkleData']['newRoot'],'serverSignature':h['merkleData']['serverSignature'],'serverTimestamp':h['merkleData']['serverTimestamp'],'serverPublicKey':h['merkleData']['serverPublicKey']}:undefined};d={'operation':'send_file','result':i};break;}case'watch_messages':{const j=b['filter']?{...b['filter'],'peerAddress':b['filter']['peerAddress']?normalizeAccountOrMark(b['filter']['peerAddress']):undefined}:undefined,k=await watch_messages(j);d={'operation':'watch_messages','result':k};break;}case'extract_zip_messages':{const l=await extract_zip_messages(b['account'],b['messages'],b['outputDir']);d={'operation':'extract_zip_messages','result':l};break;}case'generate_wts':{const m=b['params']?{...b['params'],'peerAccount':normalizeAccountOrMark(b['params']['peerAccount'])}:undefined,n=await generate_wts(m);d={'operation':'generate_wts','result':n};break;}case'verify_wts':{const o=await verify_wts(b['wtsFilePath']);d={'operation':'verify_wts','result':o};break;}case'sign_wts':{const p=await sign_wts(b['wtsFilePath'],b['account'],b['outputPath']);d={'operation':'sign_wts','result':p};break;}case'wts2html':{const q=await wts2html(b['wtsPath'],b['options']);d={'operation':'wts2html','result':q};break;}case'proof_message':{const r=await proof_message(b['account'],b['messageId'],b['network']);d={'operation':'proof_message','result':r};break;}case'blacklist':{const s={'account':b['account'],'op':b['blacklist']['op']};'users'in b['blacklist']&&(s['users']=normalizeManyAccountOrMark(b['blacklist']['users']));const t=await blacklist(s);d={'operation':'blacklist','op':b['blacklist']['op'],'result':t['result']};break;}case'friendslist':{const u={'account':b['account'],'op':b['friendslist']['op']};'users'in b['friendslist']&&(u['users']=normalizeManyAccountOrMark(b['friendslist']['users']));const v=await friendslist(u);d={'operation':'friendslist','op':b['friendslist']['op'],'result':v['result']};break;}case'guardlist':{const w=await guardlist({'account':b['account'],...b['guardlist']});d={'operation':'guardlist','op':b['guardlist']['op'],'result':w['result']};break;}case'settings':{const x=await settings({'account':b['account'],...b['settings']});d={'operation':'settings','op':b['settings']['op'],'result':x['result']};break;}case'mark_messages_as_viewed':{const y=await mark_messages_as_viewed(b['messageIds'],b['account']);d={'operation':'mark_messages_as_viewed','result':y};break;}case'mark_conversation_as_viewed':{const z=await mark_conversation_as_viewed(normalizeAccountOrMark(b['peerAddress']),b['account']);d={'operation':'mark_conversation_as_viewed','result':z};break;}case'pull_messages':{const A=await pull_messages(b['account'],b['limit']);d={'operation':'pull_messages','result':A};break;}default:throw new Error('Unknown\x20messenger\x20operation:\x20'+c);}return{'content':[{'type':'text','text':JSON['stringify'](d)}],'structuredContent':{'result':d}};}catch(B){const C=B instanceof Error?B['message']:String(B),D=b?{'operation_type':'messenger_'+b['operation'],'data':b}:undefined,E=classifyError(C),F={'operation':'error','error':C};if(E['error_code']!==undefined)F['error_code']=E['error_code'];if(E['retryable']!==undefined)F['retryable']=E['retryable'];if(E['recovery_hint']!==undefined)F['recovery_hint']=E['recovery_hint'];return{'content':[{'type':'text','text':'Error:\x20'+C}],'structuredContent':{'result':F,'semantic':buildDataSemantic(undefined,D,!![],C)}};}}
|