@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,434 +1 @@
|
|
|
1
|
-
import { strictParse, WatchQueryOperationsSchema, OnchainTableDataSchema, OnchainEventsInputSchema, ProtocolInfoQuerySchema, } from "../../schema/index.js";
|
|
2
|
-
import { query_local_mark_list, query_account_list, query_local_info_list, query_local_token_list, query_account, GetLocalNamesByAddresses, query_personal, query_objects, query_table, query_tableItem, queryTableItem_RepositoryData, queryTableItem_PermissionPerm, queryTableItem_RewardRecord, queryTableItem_DemandPresenter, queryTableItem_TreasuryHistory, queryTableItem_MachineNode, queryTableItem_ProgressHistory, queryTableItem_AddressMark, queryTableItem_EntityRegistrar, queryTableItem_EntityLinker, query_received, queryProtocolInfo, query_events, query_transaction, query_object_history, query_address_activity, generateNodeComments, } from "@wowok/wowok";
|
|
3
|
-
import { buildDataSemantic, } from "../../schema/call/semantic.js";
|
|
4
|
-
import { formatChainValue, annotateObjectMonetaryFields, annotateTableItemMonetaryFields, annotateEventsMonetaryFields, annotateBalanceChanges, resolveParentObjectTokenType, convertTokenValue, } from "../../knowledge/fund-layer.js";
|
|
5
|
-
import { normalizeAccountOrMark } from "./messenger.js";
|
|
6
|
-
async function annotateAccountBalance(result, network) {
|
|
7
|
-
if (!result || typeof result !== "object")
|
|
8
|
-
return;
|
|
9
|
-
const displays = {};
|
|
10
|
-
const convert = (raw, coinType) => {
|
|
11
|
-
if (raw === null || raw === undefined)
|
|
12
|
-
return undefined;
|
|
13
|
-
if (typeof raw !== "string" && typeof raw !== "number" && typeof raw !== "bigint")
|
|
14
|
-
return undefined;
|
|
15
|
-
if (typeof coinType !== "string" || !coinType)
|
|
16
|
-
return undefined;
|
|
17
|
-
return formatChainValue(raw, coinType, network);
|
|
18
|
-
};
|
|
19
|
-
const balance = result.balance;
|
|
20
|
-
if (balance && typeof balance === "object") {
|
|
21
|
-
const coinType = balance.coinType;
|
|
22
|
-
const total = await convert(balance.totalBalance, coinType);
|
|
23
|
-
if (total)
|
|
24
|
-
displays["balance.totalBalance"] = total;
|
|
25
|
-
if (balance.lockedBalance !== undefined) {
|
|
26
|
-
const locked = await convert(balance.lockedBalance, coinType);
|
|
27
|
-
if (locked)
|
|
28
|
-
displays["balance.lockedBalance"] = locked;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
const coinData = result.coin?.data;
|
|
32
|
-
if (Array.isArray(coinData)) {
|
|
33
|
-
for (let i = 0; i < coinData.length; i++) {
|
|
34
|
-
const c = coinData[i];
|
|
35
|
-
const d = await convert(c?.balance, c?.coinType);
|
|
36
|
-
if (d)
|
|
37
|
-
displays[`coin.data[${i}].balance`] = d;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
if (Object.keys(displays).length > 0) {
|
|
41
|
-
result._money_display = displays;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
export async function handleWatchQueryOperations(args) {
|
|
45
|
-
const validated = strictParse(WatchQueryOperationsSchema, args, "watch_and_query input");
|
|
46
|
-
let result;
|
|
47
|
-
switch (validated.query_type) {
|
|
48
|
-
case "local_mark_list": {
|
|
49
|
-
const queryResult = await query_local_mark_list(validated.filter || {});
|
|
50
|
-
result = { query_type: "local_mark_list", result: queryResult };
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
case "account_list": {
|
|
54
|
-
const queryResult = await query_account_list(validated.filter);
|
|
55
|
-
result = { query_type: "account_list", result: queryResult };
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
case "local_info_list": {
|
|
59
|
-
const queryResult = await query_local_info_list(validated.filter);
|
|
60
|
-
result = { query_type: "local_info_list", result: queryResult };
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
case "token_list": {
|
|
64
|
-
const queryResult = await query_local_token_list(validated.filter || {});
|
|
65
|
-
result = { query_type: "token_list", result: queryResult };
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
case "account_balance": {
|
|
69
|
-
const queryResult = await query_account({
|
|
70
|
-
name_or_address: validated.name_or_address,
|
|
71
|
-
token_type: validated.token_type,
|
|
72
|
-
balance: validated.balance,
|
|
73
|
-
coin: validated.coin,
|
|
74
|
-
network: validated.network,
|
|
75
|
-
});
|
|
76
|
-
await annotateAccountBalance(queryResult, validated.network);
|
|
77
|
-
result = { query_type: "account_balance", result: queryResult };
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
case "local_names": {
|
|
81
|
-
const queryResult = await GetLocalNamesByAddresses(validated.addresses);
|
|
82
|
-
result = { query_type: "local_names", result: queryResult };
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
case "onchain_personal_profile": {
|
|
86
|
-
const queryResult = await query_personal({
|
|
87
|
-
account: validated.account,
|
|
88
|
-
no_cache: validated.no_cache,
|
|
89
|
-
network: validated.network,
|
|
90
|
-
});
|
|
91
|
-
result = { query_type: "onchain_personal_profile", result: queryResult };
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
case "onchain_objects": {
|
|
95
|
-
const queryResult = await query_objects({
|
|
96
|
-
objects: validated.objects,
|
|
97
|
-
no_cache: validated.no_cache,
|
|
98
|
-
network: validated.network,
|
|
99
|
-
});
|
|
100
|
-
if (queryResult && queryResult.objects && Array.isArray(queryResult.objects)) {
|
|
101
|
-
queryResult.objects = queryResult.objects.map((obj) => {
|
|
102
|
-
if (obj && obj.data && obj.data.type === "Guard" && obj.data.root) {
|
|
103
|
-
try {
|
|
104
|
-
const nodeComments = generateNodeComments(obj.data.root);
|
|
105
|
-
return {
|
|
106
|
-
...obj,
|
|
107
|
-
_guard_node_comments: nodeComments,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
catch (e) {
|
|
111
|
-
return obj;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return obj;
|
|
115
|
-
});
|
|
116
|
-
queryResult.objects = queryResult.objects.map((obj) => {
|
|
117
|
-
if (obj && obj.data && obj.data.type === "Progress" && obj.data.current === "") {
|
|
118
|
-
const machineId = obj.data.machine;
|
|
119
|
-
const taskId = obj.data.task;
|
|
120
|
-
return {
|
|
121
|
-
...obj,
|
|
122
|
-
_diagnostic: {
|
|
123
|
-
issue: "Progress.current is empty — order workflow is stuck at the initial state",
|
|
124
|
-
cause: "The Machine's entry node (prev_node='') likely has no forwards defined. " +
|
|
125
|
-
"When Progress starts, it looks up the entry node's forwards to determine " +
|
|
126
|
-
"the next node. Without forwards, Progress cannot advance and the order " +
|
|
127
|
-
"is permanently stuck.",
|
|
128
|
-
machine_object_id: machineId ?? null,
|
|
129
|
-
bound_order_id: taskId ?? null,
|
|
130
|
-
fix: [
|
|
131
|
-
"1. Query the Machine object (use query_toolkit with query_type='onchain_objects' and objects=[" + JSON.stringify(machineId) + "]).",
|
|
132
|
-
"2. Inspect node.pairs for the entry node (prev_node='').",
|
|
133
|
-
"3. If forwards is empty: this is the root cause. The Machine must be republished with at least one forward on the entry node.",
|
|
134
|
-
"4. To republish: clone the Machine nodes, add a forward to the entry node's pairs, then create a new Machine (Machine nodes are immutable after publish — see P0-2 schema validation that now blocks this).",
|
|
135
|
-
"5. Rebind the new Machine to the Service (service.machine field) and create a new Order to test.",
|
|
136
|
-
],
|
|
137
|
-
reference: "P0-2 schema refinement in MachineNodePairSchema ensures new Machines cannot be published with empty entry-node forwards. This diagnostic catches legacy Machines that predate the fix.",
|
|
138
|
-
},
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
return obj;
|
|
142
|
-
});
|
|
143
|
-
for (const obj of queryResult.objects) {
|
|
144
|
-
try {
|
|
145
|
-
await annotateObjectMonetaryFields(obj, validated.network);
|
|
146
|
-
}
|
|
147
|
-
catch {
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
result = { query_type: "onchain_objects", result: queryResult };
|
|
152
|
-
break;
|
|
153
|
-
}
|
|
154
|
-
case "onchain_received": {
|
|
155
|
-
const queryResult = await query_received({
|
|
156
|
-
name_or_address: normalizeAccountOrMark(validated.name_or_address),
|
|
157
|
-
type: validated.type,
|
|
158
|
-
cursor: validated.cursor,
|
|
159
|
-
limit: validated.limit,
|
|
160
|
-
no_cache: validated.no_cache,
|
|
161
|
-
network: validated.network,
|
|
162
|
-
});
|
|
163
|
-
const qr = queryResult;
|
|
164
|
-
if (qr && typeof qr === "object" && typeof qr.balance === "bigint") {
|
|
165
|
-
const tokenType = qr.token_type;
|
|
166
|
-
qr.balance = qr.balance.toString();
|
|
167
|
-
if (Array.isArray(qr.received)) {
|
|
168
|
-
for (const item of qr.received) {
|
|
169
|
-
if (item && typeof item.balance === "bigint") {
|
|
170
|
-
item.balance = item.balance.toString();
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
if (tokenType) {
|
|
175
|
-
try {
|
|
176
|
-
const displays = {
|
|
177
|
-
balance: await formatChainValue(qr.balance, tokenType, validated.network),
|
|
178
|
-
};
|
|
179
|
-
if (Array.isArray(qr.received)) {
|
|
180
|
-
for (let i = 0; i < qr.received.length; i++) {
|
|
181
|
-
const b = qr.received[i]?.balance;
|
|
182
|
-
if (b !== undefined && b !== null) {
|
|
183
|
-
displays[`received[${i}].balance`] = await formatChainValue(b, tokenType, validated.network);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
qr._money_display = displays;
|
|
188
|
-
}
|
|
189
|
-
catch {
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
result = { query_type: "onchain_received", result: qr };
|
|
194
|
-
break;
|
|
195
|
-
}
|
|
196
|
-
case "onchain_transaction": {
|
|
197
|
-
const queryResult = await query_transaction({
|
|
198
|
-
digest: validated.digest,
|
|
199
|
-
no_cache: validated.no_cache,
|
|
200
|
-
network: validated.network,
|
|
201
|
-
});
|
|
202
|
-
try {
|
|
203
|
-
await annotateBalanceChanges(queryResult?.balance_changes, validated.network);
|
|
204
|
-
}
|
|
205
|
-
catch {
|
|
206
|
-
}
|
|
207
|
-
result = { query_type: "onchain_transaction", result: queryResult };
|
|
208
|
-
break;
|
|
209
|
-
}
|
|
210
|
-
case "onchain_object_history": {
|
|
211
|
-
const queryResult = await query_object_history({
|
|
212
|
-
object: validated.object,
|
|
213
|
-
cursor: validated.cursor,
|
|
214
|
-
limit: validated.limit,
|
|
215
|
-
order: validated.order,
|
|
216
|
-
no_cache: validated.no_cache,
|
|
217
|
-
network: validated.network,
|
|
218
|
-
});
|
|
219
|
-
result = { query_type: "onchain_object_history", result: queryResult };
|
|
220
|
-
break;
|
|
221
|
-
}
|
|
222
|
-
case "onchain_address_activity": {
|
|
223
|
-
const addrInput = typeof validated.name_or_address === 'string'
|
|
224
|
-
? validated.name_or_address
|
|
225
|
-
: validated.name_or_address.name_or_address;
|
|
226
|
-
const queryResult = await query_address_activity({
|
|
227
|
-
name_or_address: addrInput,
|
|
228
|
-
cursor: validated.cursor,
|
|
229
|
-
limit: validated.limit,
|
|
230
|
-
order: validated.order,
|
|
231
|
-
no_cache: validated.no_cache,
|
|
232
|
-
network: validated.network,
|
|
233
|
-
});
|
|
234
|
-
result = { query_type: "onchain_address_activity", result: queryResult };
|
|
235
|
-
break;
|
|
236
|
-
}
|
|
237
|
-
case "token_value_convert": {
|
|
238
|
-
const hasRaw = validated.raw !== undefined;
|
|
239
|
-
const hasUnit = validated.unit !== undefined;
|
|
240
|
-
if (hasRaw === hasUnit) {
|
|
241
|
-
throw new Error(`token_value_convert: provide EXACTLY ONE of 'raw' (u64 smallest units → unit value) ` +
|
|
242
|
-
`or 'unit' (unit value → u64 raw). Received raw=${JSON.stringify(validated.raw)}, ` +
|
|
243
|
-
`unit=${JSON.stringify(validated.unit)}.`);
|
|
244
|
-
}
|
|
245
|
-
const conversion = await convertTokenValue(validated.token_type, hasRaw ? { raw: validated.raw } : { unit: validated.unit }, validated.network);
|
|
246
|
-
result = { query_type: "token_value_convert", result: conversion };
|
|
247
|
-
break;
|
|
248
|
-
}
|
|
249
|
-
default:
|
|
250
|
-
throw new Error(`Unknown query type. Valid query_types are: "local_mark_list", "account_list", "local_info_list", "token_list", "account_balance", "local_names", "onchain_personal_profile", "onchain_objects", "onchain_received", "onchain_transaction", "onchain_object_history", "onchain_address_activity", "token_value_convert". For table queries, use the "onchain_table_data" tool.`);
|
|
251
|
-
}
|
|
252
|
-
return {
|
|
253
|
-
content: [{ type: "text", text: JSON.stringify({ result }) }],
|
|
254
|
-
structuredContent: {
|
|
255
|
-
result,
|
|
256
|
-
semantic: buildDataSemantic(result, {
|
|
257
|
-
operation_type: "query_toolkit",
|
|
258
|
-
data: validated,
|
|
259
|
-
}),
|
|
260
|
-
},
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
export async function handleOnchainTableData(args) {
|
|
264
|
-
const validated = strictParse(OnchainTableDataSchema, args, "onchain_table_data input");
|
|
265
|
-
let result;
|
|
266
|
-
switch (validated.query_type) {
|
|
267
|
-
case "onchain_table": {
|
|
268
|
-
const queryResult = await query_table({
|
|
269
|
-
parent: validated.parent,
|
|
270
|
-
cursor: validated.cursor,
|
|
271
|
-
limit: validated.limit,
|
|
272
|
-
no_cache: validated.no_cache,
|
|
273
|
-
network: validated.network,
|
|
274
|
-
});
|
|
275
|
-
result = { query_type: "onchain_table", result: queryResult };
|
|
276
|
-
break;
|
|
277
|
-
}
|
|
278
|
-
case "onchain_table_item_repository_data": {
|
|
279
|
-
const queryResult = await queryTableItem_RepositoryData({
|
|
280
|
-
parent: validated.parent, name: validated.name, entity: validated.entity,
|
|
281
|
-
no_cache: validated.no_cache, network: validated.network,
|
|
282
|
-
});
|
|
283
|
-
result = { query_type: "onchain_table_item_repository_data", result: queryResult };
|
|
284
|
-
break;
|
|
285
|
-
}
|
|
286
|
-
case "onchain_table_item_permission_perm": {
|
|
287
|
-
const queryResult = await queryTableItem_PermissionPerm({
|
|
288
|
-
parent: validated.parent, address: validated.address,
|
|
289
|
-
no_cache: validated.no_cache, network: validated.network,
|
|
290
|
-
});
|
|
291
|
-
result = { query_type: "onchain_table_item_permission_perm", result: queryResult };
|
|
292
|
-
break;
|
|
293
|
-
}
|
|
294
|
-
case "onchain_table_item_reward_record": {
|
|
295
|
-
const queryResult = await queryTableItem_RewardRecord({
|
|
296
|
-
parent: validated.parent, address: validated.address,
|
|
297
|
-
no_cache: validated.no_cache, network: validated.network,
|
|
298
|
-
});
|
|
299
|
-
if (queryResult) {
|
|
300
|
-
try {
|
|
301
|
-
const parentToken = await resolveParentObjectTokenType(validated.parent, validated.network);
|
|
302
|
-
await annotateTableItemMonetaryFields(queryResult, parentToken, validated.network);
|
|
303
|
-
}
|
|
304
|
-
catch {
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
result = { query_type: "onchain_table_item_reward_record", result: queryResult };
|
|
308
|
-
break;
|
|
309
|
-
}
|
|
310
|
-
case "onchain_table_item_demand_presenter": {
|
|
311
|
-
const queryResult = await queryTableItem_DemandPresenter({
|
|
312
|
-
parent: validated.parent, address: validated.address,
|
|
313
|
-
no_cache: validated.no_cache, network: validated.network,
|
|
314
|
-
});
|
|
315
|
-
result = { query_type: "onchain_table_item_demand_presenter", result: queryResult };
|
|
316
|
-
break;
|
|
317
|
-
}
|
|
318
|
-
case "onchain_table_item_treasury_history": {
|
|
319
|
-
const queryResult = await queryTableItem_TreasuryHistory({
|
|
320
|
-
parent: validated.parent, address: validated.address,
|
|
321
|
-
no_cache: validated.no_cache, network: validated.network,
|
|
322
|
-
});
|
|
323
|
-
if (queryResult) {
|
|
324
|
-
try {
|
|
325
|
-
const parentToken = await resolveParentObjectTokenType(validated.parent, validated.network);
|
|
326
|
-
await annotateTableItemMonetaryFields(queryResult, parentToken, validated.network);
|
|
327
|
-
}
|
|
328
|
-
catch {
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
result = { query_type: "onchain_table_item_treasury_history", result: queryResult };
|
|
332
|
-
break;
|
|
333
|
-
}
|
|
334
|
-
case "onchain_table_item_machine_node": {
|
|
335
|
-
const queryResult = await queryTableItem_MachineNode({
|
|
336
|
-
parent: validated.parent, key: validated.key,
|
|
337
|
-
no_cache: validated.no_cache, network: validated.network,
|
|
338
|
-
});
|
|
339
|
-
result = { query_type: "onchain_table_item_machine_node", result: queryResult };
|
|
340
|
-
break;
|
|
341
|
-
}
|
|
342
|
-
case "onchain_table_item_progress_history": {
|
|
343
|
-
const queryResult = await queryTableItem_ProgressHistory({
|
|
344
|
-
parent: validated.parent, u64: validated.u64,
|
|
345
|
-
no_cache: validated.no_cache, network: validated.network,
|
|
346
|
-
});
|
|
347
|
-
result = { query_type: "onchain_table_item_progress_history", result: queryResult };
|
|
348
|
-
break;
|
|
349
|
-
}
|
|
350
|
-
case "onchain_table_item_address_mark": {
|
|
351
|
-
const queryResult = await queryTableItem_AddressMark({
|
|
352
|
-
parent: validated.parent, address: validated.address,
|
|
353
|
-
no_cache: validated.no_cache, network: validated.network,
|
|
354
|
-
});
|
|
355
|
-
result = { query_type: "onchain_table_item_address_mark", result: queryResult };
|
|
356
|
-
break;
|
|
357
|
-
}
|
|
358
|
-
case "onchain_table_item_entity_registrar": {
|
|
359
|
-
const queryResult = await queryTableItem_EntityRegistrar({
|
|
360
|
-
address: validated.address,
|
|
361
|
-
no_cache: validated.no_cache, network: validated.network,
|
|
362
|
-
});
|
|
363
|
-
result = { query_type: "onchain_table_item_entity_registrar", result: queryResult };
|
|
364
|
-
break;
|
|
365
|
-
}
|
|
366
|
-
case "onchain_table_item_entity_linker": {
|
|
367
|
-
const queryResult = await queryTableItem_EntityLinker({
|
|
368
|
-
address: validated.address,
|
|
369
|
-
no_cache: validated.no_cache, network: validated.network,
|
|
370
|
-
});
|
|
371
|
-
result = { query_type: "onchain_table_item_entity_linker", result: queryResult };
|
|
372
|
-
break;
|
|
373
|
-
}
|
|
374
|
-
case "onchain_table_item_generic": {
|
|
375
|
-
const queryResult = await query_tableItem({
|
|
376
|
-
parent: validated.parent,
|
|
377
|
-
key: { type: validated.key_type, value: validated.key_value },
|
|
378
|
-
no_cache: validated.no_cache,
|
|
379
|
-
network: validated.network,
|
|
380
|
-
});
|
|
381
|
-
result = { query_type: "onchain_table_item_generic", result: queryResult };
|
|
382
|
-
break;
|
|
383
|
-
}
|
|
384
|
-
default:
|
|
385
|
-
throw new Error(`Unknown table query type. Valid query_types are: "onchain_table", "onchain_table_item_repository_data", "onchain_table_item_permission_perm", "onchain_table_item_reward_record", "onchain_table_item_demand_presenter", "onchain_table_item_treasury_history", "onchain_table_item_machine_node", "onchain_table_item_progress_history", "onchain_table_item_address_mark", "onchain_table_item_entity_registrar", "onchain_table_item_entity_linker", "onchain_table_item_generic"`);
|
|
386
|
-
}
|
|
387
|
-
return {
|
|
388
|
-
content: [{ type: "text", text: JSON.stringify({ result }) }],
|
|
389
|
-
structuredContent: {
|
|
390
|
-
result,
|
|
391
|
-
semantic: buildDataSemantic(result, {
|
|
392
|
-
operation_type: "onchain_table_data",
|
|
393
|
-
data: validated,
|
|
394
|
-
}),
|
|
395
|
-
},
|
|
396
|
-
};
|
|
397
|
-
}
|
|
398
|
-
export async function handleOnchainEvents(args) {
|
|
399
|
-
const validated = strictParse(OnchainEventsInputSchema, args, "onchain_events input");
|
|
400
|
-
const queryResult = await query_events({
|
|
401
|
-
type: validated.type,
|
|
402
|
-
cursor: validated.cursor ? {
|
|
403
|
-
eventSeq: String(validated.cursor.eventSeq),
|
|
404
|
-
txDigest: validated.cursor.txDigest,
|
|
405
|
-
} : null,
|
|
406
|
-
limit: validated.limit ?? null,
|
|
407
|
-
order: validated.order ?? null,
|
|
408
|
-
no_cache: validated.no_cache,
|
|
409
|
-
network: validated.network,
|
|
410
|
-
});
|
|
411
|
-
try {
|
|
412
|
-
await annotateEventsMonetaryFields(queryResult?.data, validated.network);
|
|
413
|
-
}
|
|
414
|
-
catch {
|
|
415
|
-
}
|
|
416
|
-
return {
|
|
417
|
-
content: [{ type: "text", text: JSON.stringify({ result: queryResult }) }],
|
|
418
|
-
structuredContent: {
|
|
419
|
-
result: queryResult,
|
|
420
|
-
semantic: buildDataSemantic(queryResult, {
|
|
421
|
-
operation_type: "onchain_events",
|
|
422
|
-
data: validated,
|
|
423
|
-
}),
|
|
424
|
-
},
|
|
425
|
-
};
|
|
426
|
-
}
|
|
427
|
-
export async function handleWowokInfo(args) {
|
|
428
|
-
const validated = strictParse(ProtocolInfoQuerySchema, args, "wowok_buildin_info input");
|
|
429
|
-
const queryResult = await queryProtocolInfo(validated);
|
|
430
|
-
return {
|
|
431
|
-
content: [{ type: "text", text: JSON.stringify({ result: queryResult }) }],
|
|
432
|
-
structuredContent: { result: queryResult },
|
|
433
|
-
};
|
|
434
|
-
}
|
|
1
|
+
import{strictParse,WatchQueryOperationsSchema,OnchainTableDataSchema,OnchainEventsInputSchema,ProtocolInfoQuerySchema}from'../../schema/index.js';import{checkUpgrade}from'../upgrade-check.js';import{query_local_mark_list,query_account_list,query_local_info_list,query_local_token_list,query_account,GetLocalNamesByAddresses,query_personal,query_objects,query_table,query_tableItem,queryTableItem_RepositoryData,queryTableItem_PermissionPerm,queryTableItem_RewardRecord,queryTableItem_DemandPresenter,queryTableItem_TreasuryHistory,queryTableItem_MachineNode,queryTableItem_ProgressHistory,queryTableItem_AddressMark,queryTableItem_EntityRegistrar,queryTableItem_EntityLinker,query_received,queryProtocolInfo,query_events,query_transaction,query_object_history,query_address_activity,generateNodeComments}from'@wowok/wowok';import{buildDataSemantic}from'../../schema/call/semantic.js';import{formatChainValue,annotateObjectMonetaryFields,annotateTableItemMonetaryFields,annotateEventsMonetaryFields,annotateBalanceChanges,resolveParentObjectTokenType,convertTokenValue}from'../../knowledge/fund-layer.js';import{normalizeAccountOrMark}from'./messenger.js';async function annotateAccountBalance(a,b){if(!a||typeof a!=='object')return;const e={},f=(j,k)=>{if(j===null||j===undefined)return undefined;if(typeof j!=='string'&&typeof j!=='number'&&typeof j!=='bigint')return undefined;if(typeof k!=='string'||!k)return undefined;return formatChainValue(j,k,b);},g=a['balance'];if(g&&typeof g==='object'){const j=g['coinType'],k=await f(g['totalBalance'],j);if(k)e['balance.totalBalance']=k;if(g['lockedBalance']!==undefined){const l=await f(g['lockedBalance'],j);if(l)e['balance.lockedBalance']=l;}}const h=a['coin']?.['data'];if(Array['isArray'](h))for(let m=0x0;m<h['length'];m++){const n=h[m],o=await f(n?.['balance'],n?.['coinType']);if(o)e['coin.data['+m+'].balance']=o;}Object['keys'](e)['length']>0x0&&(a['_money_display']=e);}export async function handleWatchQueryOperations(a){const c=strictParse(WatchQueryOperationsSchema,a,'watch_and_query\x20input');let d;switch(c['query_type']){case'local_mark_list':{const e=await query_local_mark_list(c['filter']||{});d={'query_type':'local_mark_list','result':e};break;}case'account_list':{const f=await query_account_list(c['filter']);d={'query_type':'account_list','result':f};break;}case'local_info_list':{const g=await query_local_info_list(c['filter']);d={'query_type':'local_info_list','result':g};break;}case'token_list':{const h=await query_local_token_list(c['filter']||{});d={'query_type':'token_list','result':h};break;}case'account_balance':{const j=await query_account({'name_or_address':c['name_or_address'],'token_type':c['token_type'],'balance':c['balance'],'coin':c['coin'],'network':c['network']});await annotateAccountBalance(j,c['network']),d={'query_type':'account_balance','result':j};break;}case'local_names':{const k=await GetLocalNamesByAddresses(c['addresses']);d={'query_type':'local_names','result':k};break;}case'onchain_personal_profile':{const l=await query_personal({'account':c['account'],'no_cache':c['no_cache'],'network':c['network']});d={'query_type':'onchain_personal_profile','result':l};break;}case'onchain_objects':{const m=await query_objects({'objects':c['objects'],'no_cache':c['no_cache'],'network':c['network']});if(m&&m['objects']&&Array['isArray'](m['objects'])){m['objects']=m['objects']['map'](n=>{if(n&&n['data']&&n['data']['type']==='Guard'&&n['data']['root'])try{const o=generateNodeComments(n['data']['root']);return{...n,'_guard_node_comments':o};}catch(p){return n;}return n;}),m['objects']=m['objects']['map'](n=>{if(n&&n['data']&&n['data']['type']==='Progress'&&n['data']['current']===''){const o=n['data']['machine'],p=n['data']['task'];return{...n,'_diagnostic':{'issue':'Progress.current\x20is\x20empty\x20—\x20order\x20workflow\x20is\x20stuck\x20at\x20the\x20initial\x20state','cause':'The\x20Machine\x27s\x20entry\x20node\x20(prev_node=\x27\x27)\x20likely\x20has\x20no\x20forwards\x20defined.\x20'+'When\x20Progress\x20starts,\x20it\x20looks\x20up\x20the\x20entry\x20node\x27s\x20forwards\x20to\x20determine\x20'+'the\x20next\x20node.\x20Without\x20forwards,\x20Progress\x20cannot\x20advance\x20and\x20the\x20order\x20'+'is\x20permanently\x20stuck.','machine_object_id':o??null,'bound_order_id':p??null,'fix':['1.\x20Query\x20the\x20Machine\x20object\x20(use\x20query_toolkit\x20with\x20query_type=\x27onchain_objects\x27\x20and\x20objects=['+JSON['stringify'](o)+']).','2.\x20Inspect\x20node.pairs\x20for\x20the\x20entry\x20node\x20(prev_node=\x27\x27).','3.\x20If\x20forwards\x20is\x20empty:\x20this\x20is\x20the\x20root\x20cause.\x20The\x20Machine\x20must\x20be\x20republished\x20with\x20at\x20least\x20one\x20forward\x20on\x20the\x20entry\x20node.','4.\x20To\x20republish:\x20clone\x20the\x20Machine\x20nodes,\x20add\x20a\x20forward\x20to\x20the\x20entry\x20node\x27s\x20pairs,\x20then\x20create\x20a\x20new\x20Machine\x20(Machine\x20nodes\x20are\x20immutable\x20after\x20publish\x20—\x20see\x20P0-2\x20schema\x20validation\x20that\x20now\x20blocks\x20this).','5.\x20Rebind\x20the\x20new\x20Machine\x20to\x20the\x20Service\x20(service.machine\x20field)\x20and\x20create\x20a\x20new\x20Order\x20to\x20test.'],'reference':'P0-2\x20schema\x20refinement\x20in\x20MachineNodePairSchema\x20ensures\x20new\x20Machines\x20cannot\x20be\x20published\x20with\x20empty\x20entry-node\x20forwards.\x20This\x20diagnostic\x20catches\x20legacy\x20Machines\x20that\x20predate\x20the\x20fix.'}};}return n;});for(const n of m['objects']){try{await annotateObjectMonetaryFields(n,c['network']);}catch{}}}d={'query_type':'onchain_objects','result':m};break;}case'onchain_received':{const o=await query_received({'name_or_address':normalizeAccountOrMark(c['name_or_address']),'type':c['type'],'cursor':c['cursor'],'limit':c['limit'],'no_cache':c['no_cache'],'network':c['network']}),p=o;if(p&&typeof p==='object'&&typeof p['balance']==='bigint'){const q=p['token_type'];p['balance']=p['balance']['toString']();if(Array['isArray'](p['received']))for(const r of p['received']){r&&typeof r['balance']==='bigint'&&(r['balance']=r['balance']['toString']());}if(q)try{const s={'balance':await formatChainValue(p['balance'],q,c['network'])};if(Array['isArray'](p['received']))for(let t=0x0;t<p['received']['length'];t++){const u=p['received'][t]?.['balance'];u!==undefined&&u!==null&&(s['received['+t+'].balance']=await formatChainValue(u,q,c['network']));}p['_money_display']=s;}catch{}}d={'query_type':'onchain_received','result':p};break;}case'onchain_transaction':{const v=await query_transaction({'digest':c['digest'],'no_cache':c['no_cache'],'network':c['network']});try{await annotateBalanceChanges(v?.['balance_changes'],c['network']);}catch{}d={'query_type':'onchain_transaction','result':v};break;}case'onchain_object_history':{const w=await query_object_history({'object':c['object'],'cursor':c['cursor'],'limit':c['limit'],'order':c['order'],'no_cache':c['no_cache'],'network':c['network']});d={'query_type':'onchain_object_history','result':w};break;}case'onchain_address_activity':{const x=typeof c['name_or_address']==='string'?c['name_or_address']:c['name_or_address']['name_or_address'],y=await query_address_activity({'name_or_address':x,'cursor':c['cursor'],'limit':c['limit'],'order':c['order'],'no_cache':c['no_cache'],'network':c['network']});d={'query_type':'onchain_address_activity','result':y};break;}case'token_value_convert':{const z=c['raw']!==undefined,A=c['unit']!==undefined;if(z===A)throw new Error('token_value_convert:\x20provide\x20EXACTLY\x20ONE\x20of\x20\x27raw\x27\x20(u64\x20smallest\x20units\x20→\x20unit\x20value)\x20'+('or\x20\x27unit\x27\x20(unit\x20value\x20→\x20u64\x20raw).\x20Received\x20raw='+JSON['stringify'](c['raw'])+',\x20')+('unit='+JSON['stringify'](c['unit'])+'.'));const B=await convertTokenValue(c['token_type'],z?{'raw':c['raw']}:{'unit':c['unit']},c['network']);d={'query_type':'token_value_convert','result':B};break;}default:throw new Error('Unknown\x20query\x20type.\x20Valid\x20query_types\x20are:\x20\x22local_mark_list\x22,\x20\x22account_list\x22,\x20\x22local_info_list\x22,\x20\x22token_list\x22,\x20\x22account_balance\x22,\x20\x22local_names\x22,\x20\x22onchain_personal_profile\x22,\x20\x22onchain_objects\x22,\x20\x22onchain_received\x22,\x20\x22onchain_transaction\x22,\x20\x22onchain_object_history\x22,\x20\x22onchain_address_activity\x22,\x20\x22token_value_convert\x22.\x20For\x20table\x20queries,\x20use\x20the\x20\x22onchain_table_data\x22\x20tool.');}return{'content':[{'type':'text','text':JSON['stringify']({'result':d})}],'structuredContent':{'result':d,'semantic':buildDataSemantic(d,{'operation_type':'query_toolkit','data':c})}};}export async function handleOnchainTableData(a){const b=strictParse(OnchainTableDataSchema,a,'onchain_table_data\x20input');let c;switch(b['query_type']){case'onchain_table':{const d=await query_table({'parent':b['parent'],'cursor':b['cursor'],'limit':b['limit'],'no_cache':b['no_cache'],'network':b['network']});c={'query_type':'onchain_table','result':d};break;}case'onchain_table_item_repository_data':{const e=await queryTableItem_RepositoryData({'parent':b['parent'],'name':b['name'],'entity':b['entity'],'no_cache':b['no_cache'],'network':b['network']});c={'query_type':'onchain_table_item_repository_data','result':e};break;}case'onchain_table_item_permission_perm':{const f=await queryTableItem_PermissionPerm({'parent':b['parent'],'address':b['address'],'no_cache':b['no_cache'],'network':b['network']});c={'query_type':'onchain_table_item_permission_perm','result':f};break;}case'onchain_table_item_reward_record':{const g=await queryTableItem_RewardRecord({'parent':b['parent'],'address':b['address'],'no_cache':b['no_cache'],'network':b['network']});if(g)try{const h=await resolveParentObjectTokenType(b['parent'],b['network']);await annotateTableItemMonetaryFields(g,h,b['network']);}catch{}c={'query_type':'onchain_table_item_reward_record','result':g};break;}case'onchain_table_item_demand_presenter':{const i=await queryTableItem_DemandPresenter({'parent':b['parent'],'address':b['address'],'no_cache':b['no_cache'],'network':b['network']});c={'query_type':'onchain_table_item_demand_presenter','result':i};break;}case'onchain_table_item_treasury_history':{const j=await queryTableItem_TreasuryHistory({'parent':b['parent'],'address':b['address'],'no_cache':b['no_cache'],'network':b['network']});if(j)try{const k=await resolveParentObjectTokenType(b['parent'],b['network']);await annotateTableItemMonetaryFields(j,k,b['network']);}catch{}c={'query_type':'onchain_table_item_treasury_history','result':j};break;}case'onchain_table_item_machine_node':{const l=await queryTableItem_MachineNode({'parent':b['parent'],'key':b['key'],'no_cache':b['no_cache'],'network':b['network']});c={'query_type':'onchain_table_item_machine_node','result':l};break;}case'onchain_table_item_progress_history':{const m=await queryTableItem_ProgressHistory({'parent':b['parent'],'u64':b['u64'],'no_cache':b['no_cache'],'network':b['network']});c={'query_type':'onchain_table_item_progress_history','result':m};break;}case'onchain_table_item_address_mark':{const n=await queryTableItem_AddressMark({'parent':b['parent'],'address':b['address'],'no_cache':b['no_cache'],'network':b['network']});c={'query_type':'onchain_table_item_address_mark','result':n};break;}case'onchain_table_item_entity_registrar':{const o=await queryTableItem_EntityRegistrar({'address':b['address'],'no_cache':b['no_cache'],'network':b['network']});c={'query_type':'onchain_table_item_entity_registrar','result':o};break;}case'onchain_table_item_entity_linker':{const p=await queryTableItem_EntityLinker({'address':b['address'],'no_cache':b['no_cache'],'network':b['network']});c={'query_type':'onchain_table_item_entity_linker','result':p};break;}case'onchain_table_item_generic':{const q=await query_tableItem({'parent':b['parent'],'key':{'type':b['key_type'],'value':b['key_value']},'no_cache':b['no_cache'],'network':b['network']});c={'query_type':'onchain_table_item_generic','result':q};break;}default:throw new Error('Unknown\x20table\x20query\x20type.\x20Valid\x20query_types\x20are:\x20\x22onchain_table\x22,\x20\x22onchain_table_item_repository_data\x22,\x20\x22onchain_table_item_permission_perm\x22,\x20\x22onchain_table_item_reward_record\x22,\x20\x22onchain_table_item_demand_presenter\x22,\x20\x22onchain_table_item_treasury_history\x22,\x20\x22onchain_table_item_machine_node\x22,\x20\x22onchain_table_item_progress_history\x22,\x20\x22onchain_table_item_address_mark\x22,\x20\x22onchain_table_item_entity_registrar\x22,\x20\x22onchain_table_item_entity_linker\x22,\x20\x22onchain_table_item_generic\x22');}return{'content':[{'type':'text','text':JSON['stringify']({'result':c})}],'structuredContent':{'result':c,'semantic':buildDataSemantic(c,{'operation_type':'onchain_table_data','data':b})}};}export async function handleOnchainEvents(a){const b=strictParse(OnchainEventsInputSchema,a,'onchain_events\x20input'),c=await query_events({'type':b['type'],'cursor':b['cursor']?{'eventSeq':String(b['cursor']['eventSeq']),'txDigest':b['cursor']['txDigest']}:null,'limit':b['limit']??null,'order':b['order']??null,'no_cache':b['no_cache'],'network':b['network']});try{await annotateEventsMonetaryFields(c?.['data'],b['network']);}catch{}return{'content':[{'type':'text','text':JSON['stringify']({'result':c})}],'structuredContent':{'result':c,'semantic':buildDataSemantic(c,{'operation_type':'onchain_events','data':b})}};}export async function handleWowokInfo(a){const b=strictParse(ProtocolInfoQuerySchema,a,'wowok_buildin_info\x20input');if(b['info']==='upgrade_check'){const d=await checkUpgrade(),e={'info':'upgrade_check','result':d};return{'content':[{'type':'text','text':JSON['stringify']({'result':e})}],'structuredContent':{'result':e}};}const c=await queryProtocolInfo(b);return{'content':[{'type':'text','text':JSON['stringify']({'result':c})}],'structuredContent':{'result':c}};}
|
|
@@ -1,176 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { strictParse } from "../../schema/index.js";
|
|
3
|
-
import { SchemaQueryInputSchema } from "../../schema/schema-query/index.js";
|
|
4
|
-
export async function handleSchemaQuery(args) {
|
|
5
|
-
const validated = strictParse(SchemaQueryInputSchema, args, "schema_query input");
|
|
6
|
-
const request = {
|
|
7
|
-
action: validated.action,
|
|
8
|
-
name: validated.name,
|
|
9
|
-
query: validated.query,
|
|
10
|
-
field_path: validated.field_path,
|
|
11
|
-
template: validated.template,
|
|
12
|
-
object_type: validated.object_type,
|
|
13
|
-
params: validated.params,
|
|
14
|
-
output_file: validated.output_file,
|
|
15
|
-
};
|
|
16
|
-
const response = processSchemaQuery(request);
|
|
17
|
-
let textContent = response.message;
|
|
18
|
-
if (response.output_file_path) {
|
|
19
|
-
textContent += `\n\n📄 Full data written to: ${response.output_file_path}`;
|
|
20
|
-
textContent += `\n Use the Read tool to access the file content.`;
|
|
21
|
-
}
|
|
22
|
-
const data = response.data;
|
|
23
|
-
if (response.success && data) {
|
|
24
|
-
switch (request.action) {
|
|
25
|
-
case "list":
|
|
26
|
-
if (Array.isArray(data) && data.length > 0) {
|
|
27
|
-
textContent += "\n\nAll available schemas:\n";
|
|
28
|
-
for (const item of data) {
|
|
29
|
-
textContent += `\n • ${item.name ?? ""}`;
|
|
30
|
-
if (item.title) {
|
|
31
|
-
textContent += ` - ${item.title}`;
|
|
32
|
-
}
|
|
33
|
-
if (item.description) {
|
|
34
|
-
textContent += `\n ${item.description.slice(0, 100)}...`;
|
|
35
|
-
}
|
|
36
|
-
textContent += "\n";
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
break;
|
|
40
|
-
case "list_operations":
|
|
41
|
-
if (Array.isArray(data) && data.length > 0) {
|
|
42
|
-
textContent += "\n\nOn-chain operation schemas:\n";
|
|
43
|
-
for (const item of data) {
|
|
44
|
-
textContent += `\n • ${item.name ?? ""}`;
|
|
45
|
-
if (item.title) {
|
|
46
|
-
textContent += ` - ${item.title}`;
|
|
47
|
-
}
|
|
48
|
-
if (item.description) {
|
|
49
|
-
textContent += `\n ${item.description.slice(0, 100)}...`;
|
|
50
|
-
}
|
|
51
|
-
textContent += "\n";
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
break;
|
|
55
|
-
case "get":
|
|
56
|
-
textContent += "\n\n## JSON Schema\n\n";
|
|
57
|
-
textContent += "```json\n";
|
|
58
|
-
textContent += JSON.stringify(data, null, 2);
|
|
59
|
-
textContent += "\n```\n";
|
|
60
|
-
break;
|
|
61
|
-
case "get_output":
|
|
62
|
-
textContent += "\n\n## Output JSON Schema\n\n";
|
|
63
|
-
textContent += "```json\n";
|
|
64
|
-
textContent += JSON.stringify(data, null, 2);
|
|
65
|
-
textContent += "\n```\n";
|
|
66
|
-
break;
|
|
67
|
-
case "get_guard_templates":
|
|
68
|
-
textContent += "\n\n## Guard Templates\n\n";
|
|
69
|
-
textContent += "```json\n";
|
|
70
|
-
textContent += JSON.stringify(data, null, 2);
|
|
71
|
-
textContent += "\n```\n";
|
|
72
|
-
break;
|
|
73
|
-
case "get_field":
|
|
74
|
-
textContent += "\n\n## Field Schema\n\n";
|
|
75
|
-
textContent += "```json\n";
|
|
76
|
-
textContent += JSON.stringify(data, null, 2);
|
|
77
|
-
textContent += "\n```\n";
|
|
78
|
-
break;
|
|
79
|
-
case "search":
|
|
80
|
-
if (Array.isArray(data) && data.length > 0) {
|
|
81
|
-
textContent += `\n\nFound ${data.length} schemas matching '${request.query ?? ""}':\n`;
|
|
82
|
-
for (const item of data) {
|
|
83
|
-
textContent += `\n • ${item.name ?? ""}`;
|
|
84
|
-
if (item.title) {
|
|
85
|
-
textContent += ` - ${item.title}`;
|
|
86
|
-
}
|
|
87
|
-
if (item.description) {
|
|
88
|
-
textContent += `\n ${item.description.slice(0, 100)}...`;
|
|
89
|
-
}
|
|
90
|
-
textContent += "\n";
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
textContent += "\n\nNo schemas found. Try 'list' to browse all available schemas, or use a broader search term.";
|
|
95
|
-
}
|
|
96
|
-
break;
|
|
97
|
-
case "search_examples": {
|
|
98
|
-
const items = (Array.isArray(data) ? data : []);
|
|
99
|
-
if (items.length > 0) {
|
|
100
|
-
textContent += `\n\nFound ${items.length} example(s) matching '${request.query ?? ""}':\n`;
|
|
101
|
-
for (const item of items) {
|
|
102
|
-
textContent += `\n • [score: ${item.score}] ${item.file}`;
|
|
103
|
-
textContent += `\n Title: ${item.title}`;
|
|
104
|
-
textContent += `\n Industry: ${item.industry} | Operation: ${item.operation_type} | Verified: ${item.verified ? "yes" : "no"}`;
|
|
105
|
-
textContent += `\n Tags: ${item.tags.join(", ")}`;
|
|
106
|
-
textContent += `\n Matched fields: ${item.matched_fields.join(", ")}`;
|
|
107
|
-
const descPreview = item.description.length > 120
|
|
108
|
-
? `${item.description.slice(0, 120)}...`
|
|
109
|
-
: item.description;
|
|
110
|
-
textContent += `\n Description: ${descPreview}`;
|
|
111
|
-
textContent += "\n";
|
|
112
|
-
}
|
|
113
|
-
textContent += `\n To view the full example JSON, read files from: ${EXAMPLES_DIR}`;
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
textContent += "\n\nNo examples found. Try broader terms like 'service', 'machine', 'guard', 'permission', or an industry name like 'rental' or 'retail'.";
|
|
117
|
-
}
|
|
118
|
-
break;
|
|
119
|
-
}
|
|
120
|
-
case "get_tool_reference": {
|
|
121
|
-
textContent += "\n\n## MCP Tool Reference\n\n";
|
|
122
|
-
textContent += "```json\n";
|
|
123
|
-
textContent += JSON.stringify(data, null, 2);
|
|
124
|
-
textContent += "\n```\n";
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
case "get_guard_design_patterns": {
|
|
128
|
-
textContent += "\n\n## Guard Design Patterns\n\n";
|
|
129
|
-
textContent += "```json\n";
|
|
130
|
-
textContent += JSON.stringify(data, null, 2);
|
|
131
|
-
textContent += "\n```\n";
|
|
132
|
-
break;
|
|
133
|
-
}
|
|
134
|
-
case "get_safety_rules": {
|
|
135
|
-
textContent += "\n\n## Safety Rules (sunk from wowok-safety skill)\n\n";
|
|
136
|
-
textContent += "```json\n";
|
|
137
|
-
textContent += JSON.stringify(data, null, 2);
|
|
138
|
-
textContent += "\n```\n";
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
|
-
case "get_templates": {
|
|
142
|
-
textContent += "\n\n## Unified Template Registry (92-review D.2)\n\n";
|
|
143
|
-
const listData = data;
|
|
144
|
-
if (Array.isArray(listData.templates) && !request.template) {
|
|
145
|
-
textContent += `\n${listData.total ?? listData.templates.length} template(s). `;
|
|
146
|
-
textContent += "Call with 'template'=<id> for detail; add 'params' (JSON string) to instantiate.\n";
|
|
147
|
-
for (const t of listData.templates) {
|
|
148
|
-
textContent += `\n • ${t.id} [${t.object_type}${t.instantiable ? "" : ", guidance-only"}] — ${t.name} (${t.parameters?.length ?? 0} params)`;
|
|
149
|
-
}
|
|
150
|
-
textContent += "\n";
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
textContent += "```json\n";
|
|
154
|
-
textContent += JSON.stringify(data, null, 2);
|
|
155
|
-
textContent += "\n```\n";
|
|
156
|
-
}
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
default:
|
|
160
|
-
throw new Error(`Unknown schema_query action: ${String(request.action)}`);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
if (response.suggestions && response.suggestions.length > 0) {
|
|
164
|
-
textContent += "\n\n💡 Suggestions:\n";
|
|
165
|
-
for (const suggestion of response.suggestions) {
|
|
166
|
-
textContent += ` • ${suggestion}\n`;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
return {
|
|
170
|
-
content: [{
|
|
171
|
-
type: "text",
|
|
172
|
-
text: textContent,
|
|
173
|
-
}],
|
|
174
|
-
structuredContent: response,
|
|
175
|
-
};
|
|
176
|
-
}
|
|
1
|
+
import{processSchemaQuery,EXAMPLES_DIR}from'../../schema-query/index.js';import{strictParse}from'../../schema/index.js';import{SchemaQueryInputSchema}from'../../schema/schema-query/index.js';export async function handleSchemaQuery(a){const b=strictParse(SchemaQueryInputSchema,a,'schema_query\x20input'),c={'action':b['action'],'name':b['name'],'query':b['query'],'field_path':b['field_path'],'template':b['template'],'object_type':b['object_type'],'params':b['params'],'output_file':b['output_file']},d=processSchemaQuery(c);let e=d['message'];d['output_file_path']&&(e+='\x0a\x0a📄\x20Full\x20data\x20written\x20to:\x20'+d['output_file_path'],e+='\x0a\x20\x20\x20Use\x20the\x20Read\x20tool\x20to\x20access\x20the\x20file\x20content.');const f=d['data'];if(d['success']&&f)switch(c['action']){case'list':if(Array['isArray'](f)&&f['length']>0x0){e+='\x0a\x0aAll\x20available\x20schemas:\x0a';for(const g of f){e+='\x0a\x20\x20•\x20'+(g['name']??''),g['title']&&(e+='\x20-\x20'+g['title']),g['description']&&(e+='\x0a\x20\x20\x20\x20'+g['description']['slice'](0x0,0x64)+'...'),e+='\x0a';}}break;case'list_operations':if(Array['isArray'](f)&&f['length']>0x0){e+='\x0a\x0aOn-chain\x20operation\x20schemas:\x0a';for(const h of f){e+='\x0a\x20\x20•\x20'+(h['name']??''),h['title']&&(e+='\x20-\x20'+h['title']),h['description']&&(e+='\x0a\x20\x20\x20\x20'+h['description']['slice'](0x0,0x64)+'...'),e+='\x0a';}}break;case'get':e+='\x0a\x0a##\x20JSON\x20Schema\x0a\x0a',e+='```json\x0a',e+=JSON['stringify'](f,null,0x2),e+='\x0a```\x0a';break;case'get_output':e+='\x0a\x0a##\x20Output\x20JSON\x20Schema\x0a\x0a',e+='```json\x0a',e+=JSON['stringify'](f,null,0x2),e+='\x0a```\x0a';break;case'get_guard_templates':e+='\x0a\x0a##\x20Guard\x20Templates\x0a\x0a',e+='```json\x0a',e+=JSON['stringify'](f,null,0x2),e+='\x0a```\x0a';break;case'get_field':e+='\x0a\x0a##\x20Field\x20Schema\x0a\x0a',e+='```json\x0a',e+=JSON['stringify'](f,null,0x2),e+='\x0a```\x0a';break;case'search':if(Array['isArray'](f)&&f['length']>0x0){e+='\x0a\x0aFound\x20'+f['length']+'\x20schemas\x20matching\x20\x27'+(c['query']??'')+'\x27:\x0a';for(const i of f){e+='\x0a\x20\x20•\x20'+(i['name']??''),i['title']&&(e+='\x20-\x20'+i['title']),i['description']&&(e+='\x0a\x20\x20\x20\x20'+i['description']['slice'](0x0,0x64)+'...'),e+='\x0a';}}else e+='\x0a\x0aNo\x20schemas\x20found.\x20Try\x20\x27list\x27\x20to\x20browse\x20all\x20available\x20schemas,\x20or\x20use\x20a\x20broader\x20search\x20term.';break;case'search_examples':{const j=Array['isArray'](f)?f:[];if(j['length']>0x0){e+='\x0a\x0aFound\x20'+j['length']+'\x20example(s)\x20matching\x20\x27'+(c['query']??'')+'\x27:\x0a';for(const k of j){e+='\x0a\x20\x20•\x20[score:\x20'+k['score']+']\x20'+k['file'],e+='\x0a\x20\x20\x20\x20Title:\x20'+k['title'],e+='\x0a\x20\x20\x20\x20Industry:\x20'+k['industry']+'\x20|\x20Operation:\x20'+k['operation_type']+'\x20|\x20Verified:\x20'+(k['verified']?'yes':'no'),e+='\x0a\x20\x20\x20\x20Tags:\x20'+k['tags']['join'](',\x20'),e+='\x0a\x20\x20\x20\x20Matched\x20fields:\x20'+k['matched_fields']['join'](',\x20');const l=k['description']['length']>0x78?k['description']['slice'](0x0,0x78)+'...':k['description'];e+='\x0a\x20\x20\x20\x20Description:\x20'+l,e+='\x0a';}e+='\x0a\x20\x20To\x20view\x20the\x20full\x20example\x20JSON,\x20read\x20files\x20from:\x20'+EXAMPLES_DIR;}else e+='\x0a\x0aNo\x20examples\x20found.\x20Try\x20broader\x20terms\x20like\x20\x27service\x27,\x20\x27machine\x27,\x20\x27guard\x27,\x20\x27permission\x27,\x20or\x20an\x20industry\x20name\x20like\x20\x27rental\x27\x20or\x20\x27retail\x27.';break;}case'get_tool_reference':{e+='\x0a\x0a##\x20MCP\x20Tool\x20Reference\x0a\x0a',e+='```json\x0a',e+=JSON['stringify'](f,null,0x2),e+='\x0a```\x0a';break;}case'get_guard_design_patterns':{e+='\x0a\x0a##\x20Guard\x20Design\x20Patterns\x0a\x0a',e+='```json\x0a',e+=JSON['stringify'](f,null,0x2),e+='\x0a```\x0a';break;}case'get_safety_rules':{e+='\x0a\x0a##\x20Safety\x20Rules\x20(sunk\x20from\x20wowok-safety\x20skill)\x0a\x0a',e+='```json\x0a',e+=JSON['stringify'](f,null,0x2),e+='\x0a```\x0a';break;}case'get_templates':{e+='\x0a\x0a##\x20Unified\x20Template\x20Registry\x20(92-review\x20D.2)\x0a\x0a';const m=f;if(Array['isArray'](m['templates'])&&!c['template']){e+='\x0a'+(m['total']??m['templates']['length'])+'\x20template(s).\x20',e+='Call\x20with\x20\x27template\x27=<id>\x20for\x20detail;\x20add\x20\x27params\x27\x20(JSON\x20string)\x20to\x20instantiate.\x0a';for(const n of m['templates']){e+='\x0a\x20\x20•\x20'+n['id']+'\x20['+n['object_type']+(n['instantiable']?'':',\x20guidance-only')+']\x20—\x20'+n['name']+'\x20('+(n['parameters']?.['length']??0x0)+'\x20params)';}e+='\x0a';}else e+='```json\x0a',e+=JSON['stringify'](f,null,0x2),e+='\x0a```\x0a';break;}default:throw new Error('Unknown\x20schema_query\x20action:\x20'+String(c['action']));}if(d['suggestions']&&d['suggestions']['length']>0x0){e+='\x0a\x0a💡\x20Suggestions:\x0a';for(const o of d['suggestions']){e+='\x20\x20•\x20'+o+'\x0a';}}return{'content':[{'type':'text','text':e}],'structuredContent':d};}
|