@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,1180 +1 @@
|
|
|
1
|
-
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
|
|
2
|
-
import { resolve, dirname, join } from "path";
|
|
3
|
-
import { getWowMcpDir } from "@wowok/wowok";
|
|
4
|
-
import { CallService, CallMachine, CallProgress, CallGuard, CallArbitration, CallRepository, CallContact, CallTreasury, CallReward, CallAllocation, CallPersonal, CallPayment, CallDemand, CallOrder, gen_passport, CallProof, gen_proof, ResponseData, LocalProject, LocalMark, query_objects, parseGuardFile, formatGuardParseErrors, transformRewardInput, transformPersonalInput, } from "@wowok/wowok";
|
|
5
|
-
import { OnchainOperationsSchema, strictParse, getEnvConfig, handleCallResult, checkClientSchemaCompatibility, parseMachineNodesFromText, formatNodeErrors as formatMachineNodeErrors, transformSubmission, } from "../../schema/index.js";
|
|
6
|
-
import { handlePermissionOperations } from "../../schema/call/permission-handler.js";
|
|
7
|
-
import { collectPermissionIndexes, checkPermissionAuthorization, formatPermissionWarning, } from "../../schema/utils/permission-machine-check.js";
|
|
8
|
-
import { isProjectServiceEnabled, normalize as projectNormalize, } from "../../project/index.js";
|
|
9
|
-
import { getSkillsHintForOnchain } from "../../schema/utils/skills-recommendation.js";
|
|
10
|
-
import { prepareFundOperation, generateSkillsHint as generateFundSkillsHint } from "../../knowledge/fund-layer.js";
|
|
11
|
-
import { generateGuardSubmissionPrompt, formatSubmissionPrompt } from "../../knowledge/guard-submission-prompt.js";
|
|
12
|
-
import { classifyWipPath } from "../wip-deploy-assist.js";
|
|
13
|
-
import { withHarness } from "../shared.js";
|
|
14
|
-
const REFERRER_FILE = join(getWowMcpDir(), "referrer");
|
|
15
|
-
function readStoredReferrer() {
|
|
16
|
-
try {
|
|
17
|
-
if (!existsSync(REFERRER_FILE))
|
|
18
|
-
return null;
|
|
19
|
-
const v = readFileSync(REFERRER_FILE, "utf8").trim();
|
|
20
|
-
return v || null;
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
const PROJECT_SKILL_DIRS = [
|
|
27
|
-
".claude/skills",
|
|
28
|
-
".agents/skills",
|
|
29
|
-
".cursor/rules",
|
|
30
|
-
".github/prompts",
|
|
31
|
-
".windsurf/skills",
|
|
32
|
-
".codex/skills",
|
|
33
|
-
".qoder/skills",
|
|
34
|
-
".roo/skills",
|
|
35
|
-
".codebuddy/skills",
|
|
36
|
-
];
|
|
37
|
-
const PROJECT_SKILL_MARKERS = [
|
|
38
|
-
"wowok-provider",
|
|
39
|
-
"wowok-arbitrator",
|
|
40
|
-
"wowok-order",
|
|
41
|
-
"wowok-messenger",
|
|
42
|
-
"wowok-machine",
|
|
43
|
-
"wowok-output",
|
|
44
|
-
"wowok-onboard",
|
|
45
|
-
"wowok-planner",
|
|
46
|
-
"wowok-auditor",
|
|
47
|
-
];
|
|
48
|
-
const SKILLS_HINT_FILE = join(getWowMcpDir(), "skills-hint-asked.json");
|
|
49
|
-
function projectHasSkills(cwd) {
|
|
50
|
-
for (const dir of PROJECT_SKILL_DIRS) {
|
|
51
|
-
for (const marker of PROJECT_SKILL_MARKERS) {
|
|
52
|
-
if (existsSync(join(cwd, dir, marker)))
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
function loadSkillsAsked() {
|
|
59
|
-
try {
|
|
60
|
-
if (!existsSync(SKILLS_HINT_FILE))
|
|
61
|
-
return {};
|
|
62
|
-
return JSON.parse(readFileSync(SKILLS_HINT_FILE, "utf8")) ?? {};
|
|
63
|
-
}
|
|
64
|
-
catch {
|
|
65
|
-
return {};
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function persistSkillsAsked(cwd) {
|
|
69
|
-
try {
|
|
70
|
-
const map = loadSkillsAsked();
|
|
71
|
-
map[cwd] = true;
|
|
72
|
-
mkdirSync(dirname(SKILLS_HINT_FILE), { recursive: true });
|
|
73
|
-
writeFileSync(SKILLS_HINT_FILE, JSON.stringify(map, null, 2), "utf8");
|
|
74
|
-
}
|
|
75
|
-
catch {
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
function getProjectSkillsHint() {
|
|
79
|
-
try {
|
|
80
|
-
const cwd = process.cwd();
|
|
81
|
-
if (!cwd || projectHasSkills(cwd))
|
|
82
|
-
return null;
|
|
83
|
-
const asked = loadSkillsAsked();
|
|
84
|
-
if (asked[cwd])
|
|
85
|
-
return null;
|
|
86
|
-
persistSkillsAsked(cwd);
|
|
87
|
-
return ("WoWok skills are not installed in this project. Run `wowok-skills init` " +
|
|
88
|
-
"here to install them (the MCP works regardless; skills improve AI orchestration).");
|
|
89
|
-
}
|
|
90
|
-
catch {
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
function formatRecipientLabel(recipient) {
|
|
95
|
-
if (!recipient)
|
|
96
|
-
return "unknown";
|
|
97
|
-
if (typeof recipient === "string")
|
|
98
|
-
return recipient;
|
|
99
|
-
if ("GuardIdentifier" in recipient) {
|
|
100
|
-
return `GuardIdentifier(${recipient.GuardIdentifier})`;
|
|
101
|
-
}
|
|
102
|
-
if ("Entity" in recipient) {
|
|
103
|
-
const addr = recipient.Entity;
|
|
104
|
-
if (typeof addr === "string" && addr.length > 16) {
|
|
105
|
-
return `Entity(${addr.slice(0, 8)}...${addr.slice(-4)})`;
|
|
106
|
-
}
|
|
107
|
-
return `Entity(${addr})`;
|
|
108
|
-
}
|
|
109
|
-
if ("Signer" in recipient) {
|
|
110
|
-
return "Signer (transaction signer)";
|
|
111
|
-
}
|
|
112
|
-
return JSON.stringify(recipient);
|
|
113
|
-
}
|
|
114
|
-
function formatMistAmount(amount) {
|
|
115
|
-
const wowEquivalent = Number(amount) / 1_000_000_000;
|
|
116
|
-
if (wowEquivalent === 0)
|
|
117
|
-
return "0 WOW";
|
|
118
|
-
const wowStr = wowEquivalent.toFixed(9).replace(/\.?0+$/, "");
|
|
119
|
-
return `${wowStr} WOW (${amount.toString()} MIST)`;
|
|
120
|
-
}
|
|
121
|
-
function extractNodesForCheck(data) {
|
|
122
|
-
if (!data?.node)
|
|
123
|
-
return [];
|
|
124
|
-
if (data.node.nodes && Array.isArray(data.node.nodes)) {
|
|
125
|
-
return data.node.nodes;
|
|
126
|
-
}
|
|
127
|
-
return [];
|
|
128
|
-
}
|
|
129
|
-
function resolvePermissionRef(data) {
|
|
130
|
-
if (!data?.object)
|
|
131
|
-
return null;
|
|
132
|
-
if (typeof data.object === "string")
|
|
133
|
-
return null;
|
|
134
|
-
const obj = data.object;
|
|
135
|
-
if (obj.permission) {
|
|
136
|
-
if (typeof obj.permission === "string")
|
|
137
|
-
return obj.permission;
|
|
138
|
-
return null;
|
|
139
|
-
}
|
|
140
|
-
return null;
|
|
141
|
-
}
|
|
142
|
-
async function checkMachinePermissionBeforePublish(data, env) {
|
|
143
|
-
if (data?.publish !== true)
|
|
144
|
-
return "";
|
|
145
|
-
const nodes = extractNodesForCheck(data);
|
|
146
|
-
if (nodes.length === 0)
|
|
147
|
-
return "";
|
|
148
|
-
const collection = collectPermissionIndexes(nodes);
|
|
149
|
-
if (collection.requiredIndexes.length === 0) {
|
|
150
|
-
return "";
|
|
151
|
-
}
|
|
152
|
-
let warning = "";
|
|
153
|
-
if (collection.missingRefs.length > 0) {
|
|
154
|
-
warning += "WARNING: Some forwards have NEITHER permissionIndex nor namedOperator. " +
|
|
155
|
-
"These forwards cannot be executed. Add one or the other:\n";
|
|
156
|
-
for (const ref of collection.missingRefs) {
|
|
157
|
-
warning += ` - Node "${ref.nodeName}", pair prev_node="${ref.prevNode}", forward "${ref.forwardName}"\n`;
|
|
158
|
-
}
|
|
159
|
-
warning += "\n";
|
|
160
|
-
}
|
|
161
|
-
const permRef = resolvePermissionRef(data);
|
|
162
|
-
if (!permRef) {
|
|
163
|
-
if (collection.requiredIndexes.length > 0) {
|
|
164
|
-
warning += "PRE-PUBLISH REMINDER: This Machine uses " + collection.requiredIndexes.length +
|
|
165
|
-
" custom permission index(es): [" + collection.requiredIndexes.join(", ") + "]. " +
|
|
166
|
-
"After creating the Permission object, grant entities for each index via " +
|
|
167
|
-
'permission.op="add perm by index" BEFORE publishing the Machine. ' +
|
|
168
|
-
"Otherwise, forwards using these indexes will be un-executable.\n";
|
|
169
|
-
}
|
|
170
|
-
return warning;
|
|
171
|
-
}
|
|
172
|
-
let permAddress = permRef;
|
|
173
|
-
if (!permRef.startsWith("0x")) {
|
|
174
|
-
try {
|
|
175
|
-
const mark = await LocalMark.Instance().get(permRef);
|
|
176
|
-
if (mark?.address) {
|
|
177
|
-
permAddress = mark.address;
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
return warning + "PRE-PUBLISH: Could not resolve Permission name '" + permRef +
|
|
181
|
-
"' to an address. Ensure the Permission object exists and is marked. " +
|
|
182
|
-
"Required indexes: [" + collection.requiredIndexes.join(", ") + "]\n";
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
catch {
|
|
186
|
-
return warning + "PRE-PUBLISH: Failed to lookup Permission name '" + permRef +
|
|
187
|
-
"'. Required indexes: [" + collection.requiredIndexes.join(", ") + "]\n";
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
const network = env?.network ?? "testnet";
|
|
191
|
-
let permData = null;
|
|
192
|
-
try {
|
|
193
|
-
const queryResult = await query_objects({
|
|
194
|
-
objects: [permAddress],
|
|
195
|
-
network: network,
|
|
196
|
-
});
|
|
197
|
-
const permObj = queryResult?.objects?.[0];
|
|
198
|
-
if (permObj) {
|
|
199
|
-
permData = {
|
|
200
|
-
address: permAddress,
|
|
201
|
-
entity_count: permObj.entity_count,
|
|
202
|
-
perm_remark: permObj.perm_remark,
|
|
203
|
-
owner: permObj.owner ?? permObj.builder,
|
|
204
|
-
admin: permObj.admin,
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
catch {
|
|
209
|
-
return warning + "PRE-PUBLISH: Failed to query Permission object " + permAddress +
|
|
210
|
-
". Required indexes: [" + collection.requiredIndexes.join(", ") + "]\n";
|
|
211
|
-
}
|
|
212
|
-
if (!permData) {
|
|
213
|
-
return warning + "PRE-PUBLISH: Permission object " + permAddress +
|
|
214
|
-
" not found on-chain. Required indexes: [" + collection.requiredIndexes.join(", ") + "]\n";
|
|
215
|
-
}
|
|
216
|
-
const report = checkPermissionAuthorization(collection.requiredIndexes, permData);
|
|
217
|
-
if (!report.allAuthorized) {
|
|
218
|
-
warning += formatPermissionWarning(report) + "\n";
|
|
219
|
-
}
|
|
220
|
-
return warning;
|
|
221
|
-
}
|
|
222
|
-
async function detectServiceGuardCircularDependency(data) {
|
|
223
|
-
if (!data || typeof data.object !== "object" || data.object === null)
|
|
224
|
-
return null;
|
|
225
|
-
const orderAllocators = data.order_allocators;
|
|
226
|
-
if (!orderAllocators || typeof orderAllocators !== "object")
|
|
227
|
-
return null;
|
|
228
|
-
const allocators = Array.isArray(orderAllocators.allocators)
|
|
229
|
-
? orderAllocators.allocators
|
|
230
|
-
: [];
|
|
231
|
-
if (allocators.length === 0)
|
|
232
|
-
return null;
|
|
233
|
-
const unresolvedGuards = [];
|
|
234
|
-
const seen = new Set();
|
|
235
|
-
for (const alloc of allocators) {
|
|
236
|
-
const guardRef = alloc?.guard;
|
|
237
|
-
if (typeof guardRef === "string" && !guardRef.startsWith("0x")) {
|
|
238
|
-
if (seen.has(guardRef))
|
|
239
|
-
continue;
|
|
240
|
-
seen.add(guardRef);
|
|
241
|
-
try {
|
|
242
|
-
const addr = await LocalMark.Instance().get_address(guardRef);
|
|
243
|
-
if (!addr) {
|
|
244
|
-
unresolvedGuards.push(guardRef);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
catch {
|
|
248
|
-
unresolvedGuards.push(guardRef);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
if (unresolvedGuards.length === 0)
|
|
253
|
-
return null;
|
|
254
|
-
const guardList = unresolvedGuards.map(g => `'${g}'`).join(", ");
|
|
255
|
-
const serviceObj = data.object;
|
|
256
|
-
const serviceName = serviceObj.name ?? "<service_name>";
|
|
257
|
-
const recommended_steps = [
|
|
258
|
-
{
|
|
259
|
-
step: 1,
|
|
260
|
-
action: "onchain_operations",
|
|
261
|
-
operation_type: "service",
|
|
262
|
-
params: {
|
|
263
|
-
...data,
|
|
264
|
-
order_allocators: null,
|
|
265
|
-
publish: false,
|
|
266
|
-
},
|
|
267
|
-
purpose: `Create Service '${serviceName}' WITHOUT order_allocators to establish ` +
|
|
268
|
-
`its LocalMark entry. After this step, the name '${serviceName}' resolves ` +
|
|
269
|
-
`to an on-chain address.`,
|
|
270
|
-
},
|
|
271
|
-
{
|
|
272
|
-
step: 2,
|
|
273
|
-
action: "onchain_operations",
|
|
274
|
-
operation_type: "guard",
|
|
275
|
-
params: unresolvedGuards.map(name => ({
|
|
276
|
-
object: { name, type: "Guard" },
|
|
277
|
-
_hint: `Table items may reference Service '${serviceName}' by name`,
|
|
278
|
-
})),
|
|
279
|
-
purpose: `Create Guard(s) ${guardList}. Their table items can now resolve ` +
|
|
280
|
-
`Service '${serviceName}' by name (LocalMark entry from step 1).`,
|
|
281
|
-
},
|
|
282
|
-
{
|
|
283
|
-
step: 3,
|
|
284
|
-
action: "onchain_operations",
|
|
285
|
-
operation_type: "service",
|
|
286
|
-
params: {
|
|
287
|
-
object: serviceName,
|
|
288
|
-
order_allocators: orderAllocators,
|
|
289
|
-
publish: data.publish ?? true,
|
|
290
|
-
},
|
|
291
|
-
purpose: "Update Service with order_allocators (referencing Guards created in " +
|
|
292
|
-
"step 2) and publish. After publish, order_allocators becomes SDK-LOCKED.",
|
|
293
|
-
},
|
|
294
|
-
];
|
|
295
|
-
const guideText = `⚠️ Circular dependency detected: Service ↔ Guard\n\n` +
|
|
296
|
-
`Cannot create Service with order_allocators referencing non-existent Guard(s): ${guardList}.\n\n` +
|
|
297
|
-
`Explanation: Guard table items may reference the Service by name, creating a circular ` +
|
|
298
|
-
`dependency: the Service must exist as a LocalMark before the Guard can resolve it, ` +
|
|
299
|
-
`but the Guard must exist before the Service can reference it in order_allocators. ` +
|
|
300
|
-
`The SDK would fail with a BCS serialization error: "Expected valid Address for ` +
|
|
301
|
-
`ValueType.Address, but failed to resolve string: <name>".\n\n` +
|
|
302
|
-
`Recommended steps:\n` +
|
|
303
|
-
recommended_steps
|
|
304
|
-
.map(s => ` Step ${s.step} (${s.operation_type}): ${s.purpose}`)
|
|
305
|
-
.join("\n") +
|
|
306
|
-
`\n\nHint: This is the canonical Service↔Guard circular dependency. The 3-step ` +
|
|
307
|
-
`pattern above is the documented solution (see SCHEMA-03 / P0-01 fix in ` +
|
|
308
|
-
`schema/call/service.ts publish field description).`;
|
|
309
|
-
return {
|
|
310
|
-
content: [{
|
|
311
|
-
type: "text",
|
|
312
|
-
text: guideText,
|
|
313
|
-
}],
|
|
314
|
-
structuredContent: {
|
|
315
|
-
result: {
|
|
316
|
-
type: "error",
|
|
317
|
-
error: `Cannot create Service with order_allocators referencing non-existent Guard(s): ${guardList}. Circular dependency: Service↔Guard.`,
|
|
318
|
-
error_code: "circular_dependency_detected",
|
|
319
|
-
retryable: true,
|
|
320
|
-
recovery_hint: JSON.stringify(recommended_steps),
|
|
321
|
-
related_object: serviceName,
|
|
322
|
-
},
|
|
323
|
-
message: "Circular dependency detected: Service ↔ Guard. See recovery_hint for the 3-step creation pattern.",
|
|
324
|
-
},
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
function buildFundBlockResult(fund, operationType) {
|
|
328
|
-
const hasMismatch = fund.matchErrors.length > 0;
|
|
329
|
-
const hasInputErrors = fund.errors.length > 0;
|
|
330
|
-
const title = hasMismatch && hasInputErrors
|
|
331
|
-
? "FUND OPERATION BLOCKED"
|
|
332
|
-
: hasMismatch
|
|
333
|
-
? "TOKEN TYPE MISMATCH — operation blocked"
|
|
334
|
-
: "FUND INPUT BLOCKED — operation blocked";
|
|
335
|
-
const errorCode = hasMismatch && hasInputErrors
|
|
336
|
-
? "fund_blocked"
|
|
337
|
-
: hasMismatch
|
|
338
|
-
? "token_type_mismatch"
|
|
339
|
-
: "fund_input_error";
|
|
340
|
-
const errorText = `⛔ ${title}\n\n` +
|
|
341
|
-
fund.blockingErrors.map(e => ` • ${e}`).join("\n") +
|
|
342
|
-
`\n\nThe token type of a generic on-chain object (e.g. Treasury<T>, Service<T>) is ` +
|
|
343
|
-
`determined at creation and can NEVER be changed, and monetary input is never ` +
|
|
344
|
-
`processed with unknown token precision. This ${operationType} operation was ` +
|
|
345
|
-
`NOT executed. Fix the errors above and re-issue the operation` +
|
|
346
|
-
(fund.objectTokenType ? ` (object token type: ${fund.objectTokenType})` : "") + ".";
|
|
347
|
-
return {
|
|
348
|
-
content: [{ type: "text", text: errorText }],
|
|
349
|
-
structuredContent: {
|
|
350
|
-
result: {
|
|
351
|
-
type: "error",
|
|
352
|
-
error: fund.blockingErrors.join(" | "),
|
|
353
|
-
error_code: errorCode,
|
|
354
|
-
retryable: true,
|
|
355
|
-
recovery_hint: `Use token type ${fund.objectTokenType ?? "<the object's generic token type>"} for all ` +
|
|
356
|
-
`amounts, coins, and receive records in this ${operationType} operation. ` +
|
|
357
|
-
`Query the object via query_toolkit onchain_objects to confirm its generic ` +
|
|
358
|
-
`token type (type_raw, e.g. "0x2::treasury::Treasury<0x2::wow::WOW>"). ` +
|
|
359
|
-
`For precision-unavailable tokens, retry the operation — the on-chain ` +
|
|
360
|
-
`metadata lookup may have been transient.`,
|
|
361
|
-
},
|
|
362
|
-
message: "Fund operation blocked before execution.",
|
|
363
|
-
},
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
function checkSalesWipNetworkDeployment(data, env, warnings) {
|
|
367
|
-
const sales = data?.sales;
|
|
368
|
-
if (!sales || typeof sales !== "object")
|
|
369
|
-
return null;
|
|
370
|
-
if (sales.op !== "add" && sales.op !== "set")
|
|
371
|
-
return null;
|
|
372
|
-
const items = Array.isArray(sales.sales) ? sales.sales : [];
|
|
373
|
-
if (items.length === 0)
|
|
374
|
-
return null;
|
|
375
|
-
const isLocalnet = env?.network === "localnet";
|
|
376
|
-
for (const sale of items) {
|
|
377
|
-
const wip = sale?.wip;
|
|
378
|
-
if (typeof wip !== "string" || wip === "")
|
|
379
|
-
continue;
|
|
380
|
-
const classification = classifyWipPath(wip);
|
|
381
|
-
if (!classification.is_local)
|
|
382
|
-
continue;
|
|
383
|
-
if (classification.type === "local_http") {
|
|
384
|
-
if (isLocalnet) {
|
|
385
|
-
warnings.push(`WIP INTERNAL-TEST-ONLY REMINDER (sale "${sale.name}"): wip = "${wip}" is a ` +
|
|
386
|
-
`local-network URL (${classification.description}). It is reachable ONLY on the ` +
|
|
387
|
-
`local machine / LAN where a local WIP server runs. This is acceptable for LOCALNET ` +
|
|
388
|
-
`internal testing, but customers and on-chain verifiers on OTHER machines CANNOT ` +
|
|
389
|
-
`reach it — on testnet/mainnet, every customer order_new would fail 100% because the ` +
|
|
390
|
-
`WIP file cannot be verified. For any non-localnet deployment, replace this URL with ` +
|
|
391
|
-
`a public endpoint (GitHub Pages / IPFS / your own website) or leave sale.wip empty.`);
|
|
392
|
-
continue;
|
|
393
|
-
}
|
|
394
|
-
const typeLabel = `a local-network URL (${classification.description})`;
|
|
395
|
-
const errorText = `⛔ WIP IS NOT NETWORK-DEPLOYABLE — sales NOT submitted\n\n` +
|
|
396
|
-
`Sale "${sale.name}" has wip = "${wip}", which is ${typeLabel}.\n\n` +
|
|
397
|
-
`INTERNAL TEST USE ONLY: this URL is reachable only from the merchant's own machine/LAN. ` +
|
|
398
|
-
`Customers on other machines cannot reach it, so verifying the WIP file at order time ` +
|
|
399
|
-
`fails and order_new aborts 100%. Local-network WIP URLs are allowed ONLY for ` +
|
|
400
|
-
`localnet internal testing (env.network = "localnet"); on ${env?.network ?? "this network"} ` +
|
|
401
|
-
`they must never be stored on-chain.\n\n` +
|
|
402
|
-
`Fix: deploy the .wip file to a publicly reachable endpoint, then re-run with ` +
|
|
403
|
-
`sale.wip = "<public URL>" (e.g. GitHub Pages, IPFS gateway, or your own website).\n` +
|
|
404
|
-
` • GitHub Pages: https://<user>.github.io/<repo>/<file>.wip\n` +
|
|
405
|
-
` • IPFS: https://ipfs.io/ipfs/<CID> (or ipfs://<CID>)\n` +
|
|
406
|
-
` • Your site: https://<your-domain>/<path>/<file>.wip\n` +
|
|
407
|
-
`Alternatively, set sale.wip = "" (empty) to SKIP WIP verification — ` +
|
|
408
|
-
`TESTING ONLY, not recommended for production.`;
|
|
409
|
-
return {
|
|
410
|
-
content: [{ type: "text", text: errorText }],
|
|
411
|
-
structuredContent: {
|
|
412
|
-
result: {
|
|
413
|
-
type: "error",
|
|
414
|
-
error: `Sale "${sale.name}" wip is ${typeLabel}: ${wip}. Local-network URLs are INTERNAL TEST USE ONLY — customers cannot verify them, aborting order_new 100%.`,
|
|
415
|
-
error_code: "wip_not_network_deployed",
|
|
416
|
-
retryable: true,
|
|
417
|
-
recovery_hint: "Deploy the .wip file to a public endpoint (GitHub Pages / IPFS / your own website) " +
|
|
418
|
-
"and set sale.wip to the public URL; or set sale.wip = \"\" (empty) to skip WIP " +
|
|
419
|
-
"verification (TESTING ONLY).",
|
|
420
|
-
related_object: sale.name,
|
|
421
|
-
},
|
|
422
|
-
message: "WIP is a local-network URL (INTERNAL TEST USE ONLY) — sales not submitted. See recovery_hint.",
|
|
423
|
-
},
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
|
-
const typeLabel = `a LOCAL ${classification.type} path`;
|
|
427
|
-
const errorText = `⛔ WIP IS NOT NETWORK-DEPLOYABLE — sales NOT submitted\n\n` +
|
|
428
|
-
`Sale "${sale.name}" has wip = "${wip}", which is ${typeLabel}.\n\n` +
|
|
429
|
-
`Why this is fatal: the WIP path is stored ON-CHAIN and every customer ` +
|
|
430
|
-
`(on a different machine) fetches it when placing an order. A local path / ` +
|
|
431
|
-
`localhost / LAN URL is reachable only from YOUR machine — it passes the ` +
|
|
432
|
-
`merchant-side set-time verification but makes order_new abort 100% for customers.\n\n` +
|
|
433
|
-
`Fix: deploy the .wip file to a publicly reachable endpoint, then re-run with ` +
|
|
434
|
-
`sale.wip = "<public URL>" (e.g. GitHub Pages, IPFS gateway, or your own website).\n` +
|
|
435
|
-
` • GitHub Pages: https://<user>.github.io/<repo>/<file>.wip\n` +
|
|
436
|
-
` • IPFS: https://ipfs.io/ipfs/<CID> (or ipfs://<CID>)\n` +
|
|
437
|
-
` • Your site: https://<your-domain>/<path>/<file>.wip\n` +
|
|
438
|
-
`Alternatively, set sale.wip = "" (empty) to SKIP WIP verification — ` +
|
|
439
|
-
`TESTING ONLY, not recommended for production.`;
|
|
440
|
-
return {
|
|
441
|
-
content: [{ type: "text", text: errorText }],
|
|
442
|
-
structuredContent: {
|
|
443
|
-
result: {
|
|
444
|
-
type: "error",
|
|
445
|
-
error: `Sale "${sale.name}" wip is ${typeLabel}: ${wip}. Local WIP paths are unreachable by customers and abort order_new 100%.`,
|
|
446
|
-
error_code: "wip_not_network_deployed",
|
|
447
|
-
retryable: true,
|
|
448
|
-
recovery_hint: "Deploy the .wip file to a public endpoint (GitHub Pages / IPFS / your own website) " +
|
|
449
|
-
"and set sale.wip to the public URL; or set sale.wip = \"\" (empty) to skip WIP " +
|
|
450
|
-
"verification (TESTING ONLY).",
|
|
451
|
-
related_object: sale.name,
|
|
452
|
-
},
|
|
453
|
-
message: "WIP is not network-deployable — sales not submitted. See recovery_hint.",
|
|
454
|
-
},
|
|
455
|
-
};
|
|
456
|
-
}
|
|
457
|
-
return null;
|
|
458
|
-
}
|
|
459
|
-
export async function handleOnchainOperations(args) {
|
|
460
|
-
let validated;
|
|
461
|
-
let constraintWarnings = [];
|
|
462
|
-
let projectWarnings = [];
|
|
463
|
-
async function autoAddToProject(projectPrefix, operationType, result) {
|
|
464
|
-
if (!projectPrefix)
|
|
465
|
-
return;
|
|
466
|
-
const creationOps = new Set([
|
|
467
|
-
"service", "machine", "progress", "repository",
|
|
468
|
-
"arbitration", "contact", "treasury", "reward",
|
|
469
|
-
"allocation", "permission", "guard", "personal",
|
|
470
|
-
"demand", "order", "proof",
|
|
471
|
-
]);
|
|
472
|
-
if (!creationOps.has(operationType))
|
|
473
|
-
return;
|
|
474
|
-
if (!result || typeof result !== 'object' || 'error' in result)
|
|
475
|
-
return;
|
|
476
|
-
if (!result.digest)
|
|
477
|
-
return;
|
|
478
|
-
try {
|
|
479
|
-
const lp = LocalProject.Instance();
|
|
480
|
-
const project = await lp.getProjectByPrefix(projectPrefix);
|
|
481
|
-
if (!project) {
|
|
482
|
-
console.warn(`[autoAddToProject] Project with prefix '${projectPrefix}' not found — object not auto-associated. Create the project first via project_operation action='create_project'.`);
|
|
483
|
-
return;
|
|
484
|
-
}
|
|
485
|
-
const rData = ResponseData(result);
|
|
486
|
-
const created = rData.filter((r) => r.change === "created" && r.object);
|
|
487
|
-
for (const obj of created) {
|
|
488
|
-
const isService = !!(obj.type_raw && obj.type_raw.includes("service::Service"));
|
|
489
|
-
await lp.addObject(project.id, {
|
|
490
|
-
objectAddress: obj.object,
|
|
491
|
-
objectType: obj.type_raw,
|
|
492
|
-
role: isService ? "core" : "reference",
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
if (operationType === "service") {
|
|
496
|
-
const svc = created.find((o) => o.type_raw && o.type_raw.includes("service::Service"));
|
|
497
|
-
if (svc && svc.object) {
|
|
498
|
-
await lp.updateProject(project.id, { serviceAddress: svc.object }).catch(() => { });
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
catch {
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
try {
|
|
506
|
-
if (typeof args === 'object' && args !== null
|
|
507
|
-
&& 'description' in args && !('operation_type' in args)) {
|
|
508
|
-
const desc = args.description;
|
|
509
|
-
const hasWrappedParams = typeof desc === 'string' &&
|
|
510
|
-
(desc.includes('operation_type') || desc.includes('data'));
|
|
511
|
-
if (hasWrappedParams) {
|
|
512
|
-
throw new Error("Invalid parameter structure. Parameters should NOT be wrapped in 'description' field.\n" +
|
|
513
|
-
"Correct format: { operation_type: '...', data: {...} }\n" +
|
|
514
|
-
"Incorrect format: { description: '{ operation_type: ... }' }");
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
validated = strictParse(OnchainOperationsSchema, args, "onchain_operations input");
|
|
518
|
-
const env = getEnvConfig(validated.env);
|
|
519
|
-
if (!env.referrer) {
|
|
520
|
-
const storedReferrer = readStoredReferrer();
|
|
521
|
-
if (storedReferrer)
|
|
522
|
-
env.referrer = storedReferrer;
|
|
523
|
-
}
|
|
524
|
-
const clientSchemaVersion = env.client_schema_version;
|
|
525
|
-
const schemaStrictMode = env.schema_strict_mode;
|
|
526
|
-
const schemaCheck = clientSchemaVersion
|
|
527
|
-
? checkClientSchemaCompatibility(clientSchemaVersion, { mode: schemaStrictMode ? "strict" : "warn" })
|
|
528
|
-
: undefined;
|
|
529
|
-
const buildCtx = (data) => ({
|
|
530
|
-
operation_type: validated.operation_type,
|
|
531
|
-
data,
|
|
532
|
-
pre_warnings: [...constraintWarnings, ...projectWarnings].length
|
|
533
|
-
? [...constraintWarnings, ...projectWarnings]
|
|
534
|
-
: undefined,
|
|
535
|
-
schema_check: schemaCheck,
|
|
536
|
-
});
|
|
537
|
-
const projectEnvPrefix = env.project;
|
|
538
|
-
if (isProjectServiceEnabled() && 'data' in validated && validated.data) {
|
|
539
|
-
const pn = projectNormalize({
|
|
540
|
-
operation_type: validated.operation_type,
|
|
541
|
-
data: validated.data,
|
|
542
|
-
projectPrefix: projectEnvPrefix,
|
|
543
|
-
});
|
|
544
|
-
validated.data = pn.data;
|
|
545
|
-
projectWarnings = pn.warnings ?? [];
|
|
546
|
-
}
|
|
547
|
-
if (!env.account && projectEnvPrefix) {
|
|
548
|
-
try {
|
|
549
|
-
const project = await LocalProject.Instance().getProjectByPrefix(projectEnvPrefix);
|
|
550
|
-
if (project?.defaultAccount) {
|
|
551
|
-
env.account = project.defaultAccount;
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
catch { }
|
|
555
|
-
}
|
|
556
|
-
delete env.confirmed;
|
|
557
|
-
delete env.user_intent_phrases;
|
|
558
|
-
delete env.project;
|
|
559
|
-
delete env.client_schema_version;
|
|
560
|
-
delete env.schema_strict_mode;
|
|
561
|
-
const skillsHint = getSkillsHintForOnchain(validated.operation_type, validated.data);
|
|
562
|
-
if (skillsHint) {
|
|
563
|
-
constraintWarnings.push(skillsHint);
|
|
564
|
-
}
|
|
565
|
-
const projectSkillsHint = getProjectSkillsHint();
|
|
566
|
-
if (projectSkillsHint) {
|
|
567
|
-
constraintWarnings.push(projectSkillsHint);
|
|
568
|
-
}
|
|
569
|
-
switch (validated.operation_type) {
|
|
570
|
-
case "service": {
|
|
571
|
-
const data = validated.data;
|
|
572
|
-
const circularDepGuide = await detectServiceGuardCircularDependency(data);
|
|
573
|
-
if (circularDepGuide) {
|
|
574
|
-
return circularDepGuide;
|
|
575
|
-
}
|
|
576
|
-
const wipDeployBlock = checkSalesWipNetworkDeployment(data, env, constraintWarnings);
|
|
577
|
-
if (wipDeployBlock) {
|
|
578
|
-
return wipDeployBlock;
|
|
579
|
-
}
|
|
580
|
-
const fundResult = await prepareFundOperation(data, "service", env?.network);
|
|
581
|
-
if (fundResult.blockingErrors.length > 0) {
|
|
582
|
-
return buildFundBlockResult(fundResult, "service");
|
|
583
|
-
}
|
|
584
|
-
constraintWarnings.push(...fundResult.warnings);
|
|
585
|
-
if (fundResult.confirmation) {
|
|
586
|
-
constraintWarnings.push(fundResult.confirmation.message);
|
|
587
|
-
const fundHint = generateFundSkillsHint(fundResult.confirmation);
|
|
588
|
-
if (fundHint)
|
|
589
|
-
constraintWarnings.push(fundHint);
|
|
590
|
-
}
|
|
591
|
-
const orderAllocators = data?.order_allocators;
|
|
592
|
-
if (orderAllocators && typeof orderAllocators === "object") {
|
|
593
|
-
const allocators = Array.isArray(orderAllocators.allocators)
|
|
594
|
-
? orderAllocators.allocators : [];
|
|
595
|
-
for (let i = 0; i < allocators.length; i++) {
|
|
596
|
-
const alloc = allocators[i];
|
|
597
|
-
const sharing = Array.isArray(alloc?.sharing) ? alloc.sharing : [];
|
|
598
|
-
if (sharing.length <= 1)
|
|
599
|
-
continue;
|
|
600
|
-
const seen = new Map();
|
|
601
|
-
for (let j = 0; j < sharing.length; j++) {
|
|
602
|
-
const who = sharing[j]?.who;
|
|
603
|
-
let key = "";
|
|
604
|
-
if (typeof who === "string") {
|
|
605
|
-
key = who;
|
|
606
|
-
}
|
|
607
|
-
else if (who && typeof who === "object") {
|
|
608
|
-
if (who.Entity && typeof who.Entity === "object") {
|
|
609
|
-
key = "Entity:" + (who.Entity.name_or_address ?? "");
|
|
610
|
-
}
|
|
611
|
-
else if (who.Signer) {
|
|
612
|
-
key = "Signer";
|
|
613
|
-
}
|
|
614
|
-
else if (who.GuardIdentifier !== undefined) {
|
|
615
|
-
key = "Guard:" + who.GuardIdentifier;
|
|
616
|
-
}
|
|
617
|
-
else {
|
|
618
|
-
key = JSON.stringify(who);
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
if (!key)
|
|
622
|
-
continue;
|
|
623
|
-
const count = seen.get(key) ?? 0;
|
|
624
|
-
seen.set(key, count + 1);
|
|
625
|
-
}
|
|
626
|
-
for (const [key, count] of seen) {
|
|
627
|
-
if (count > 1) {
|
|
628
|
-
constraintWarnings.push(`DUPLICATE SHARING ENTITY: Allocator[${i}] has entity "${key}" appearing ${count} times ` +
|
|
629
|
-
`in the sharing array. This is likely a configuration error — each entity should appear ` +
|
|
630
|
-
`at most once per allocator. Total sharing: ${count * 100}% to the same entity. ` +
|
|
631
|
-
`If intentional, ignore this warning.`);
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
const callService = new CallService(validated.data);
|
|
637
|
-
let result;
|
|
638
|
-
try {
|
|
639
|
-
result = validated.submission
|
|
640
|
-
? await callService.call_with_submission(env, await transformSubmission(validated.submission))
|
|
641
|
-
: await callService.call(env);
|
|
642
|
-
}
|
|
643
|
-
catch (e) {
|
|
644
|
-
const errMsg = e.message ?? String(e);
|
|
645
|
-
if (/not found|GetObjectExisted|resolve|LocalMark|failed to resolve/i.test(errMsg)) {
|
|
646
|
-
const permRef = (typeof data?.object === 'object' && data?.object !== null)
|
|
647
|
-
? data.object.permission
|
|
648
|
-
: undefined;
|
|
649
|
-
throw new Error(`DEPENDENCY RESOLUTION FAILED: One or more referenced objects could not be resolved.\n` +
|
|
650
|
-
`Original error: ${errMsg}\n` +
|
|
651
|
-
`Common causes:\n` +
|
|
652
|
-
` 1. Object name typo — check spelling in LocalMark\n` +
|
|
653
|
-
` 2. Object not yet created — create dependencies first\n` +
|
|
654
|
-
` 3. Object on different network — check env.network\n` +
|
|
655
|
-
`Referenced objects in this call: machine=${data?.machine ?? "<none>"}, ` +
|
|
656
|
-
`buy_guard=${data?.buy_guard ?? "<none>"}, ` +
|
|
657
|
-
`permission=${permRef ?? "<inline/new>"}, ` +
|
|
658
|
-
`arbitrations=${Array.isArray(data?.arbitrations) ? data.arbitrations.length + " item(s)" : "<none>"}`);
|
|
659
|
-
}
|
|
660
|
-
throw e;
|
|
661
|
-
}
|
|
662
|
-
const intent = data?.publish ? "publish service" : data?.bPublished !== undefined ? "modify service" : "create service";
|
|
663
|
-
const isCreatingService = data?.object != null && typeof data.object === "object";
|
|
664
|
-
const hasCompensationFundAdd = data?.compensation_fund_add != null;
|
|
665
|
-
if (isCreatingService && !hasCompensationFundAdd) {
|
|
666
|
-
constraintWarnings.push("Service.compensation_fund balance is 0 — no refund protection for buyers. " +
|
|
667
|
-
"If buyers need refund protection, call service.compensation_fund_add with a Coin<T> " +
|
|
668
|
-
"to deposit. Without deposit, arbitration rulings cannot withdraw compensation " +
|
|
669
|
-
"from this Service. (Note: some industries like freelance do not require this; " +
|
|
670
|
-
"the evaluation engine will check industry-specific requirements.)");
|
|
671
|
-
}
|
|
672
|
-
const isPublishing = data?.publish === true;
|
|
673
|
-
const hasArbitrations = Array.isArray(data?.arbitrations) && data.arbitrations.length > 0;
|
|
674
|
-
if (isPublishing && !hasArbitrations && hasCompensationFundAdd) {
|
|
675
|
-
throw new Error("HARD PRE-CHECK FAILED: Cannot publish Service with compensation_fund > 0 but no Arbitration bound.\n" +
|
|
676
|
-
"Contract (service.move:494): assert!(arbitration_count > 0, E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND).\n" +
|
|
677
|
-
"The transaction WILL ABORT on-chain if you proceed.\n" +
|
|
678
|
-
"Fix: (1) Create an Arbitration object first (onchain_operations with operation_type='arbitration').\n" +
|
|
679
|
-
" (2) Set data.arbitrations=[<arbitration_name_or_id>] in this same call.\n" +
|
|
680
|
-
" (3) Then call publish=true.\n" +
|
|
681
|
-
"Note: After publish, arbitrations can still be ADDED (but not removed without pause+lock).");
|
|
682
|
-
}
|
|
683
|
-
if (isPublishing && !hasArbitrations && !hasCompensationFundAdd) {
|
|
684
|
-
constraintWarnings.push("WARNING: Publishing Service without arbitrations. If compensation_fund was " +
|
|
685
|
-
"deposited in a prior call, the contract (service.move:494) WILL ABORT with " +
|
|
686
|
-
"E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND. If compensation_fund is 0, " +
|
|
687
|
-
"publish will succeed but buyers have no dispute resolution path. " +
|
|
688
|
-
"Recommended: bind arbitrations before publish.");
|
|
689
|
-
}
|
|
690
|
-
if (!isPublishing && hasCompensationFundAdd && !hasArbitrations) {
|
|
691
|
-
constraintWarnings.push("WARNING: Depositing compensation_fund on a Service without arbitrations bound. " +
|
|
692
|
-
"If this Service is already published, arbitration rulings will not be able to " +
|
|
693
|
-
"withdraw compensation from this Service. Recommended: bind arbitrations first, " +
|
|
694
|
-
"then deposit compensation_fund.");
|
|
695
|
-
}
|
|
696
|
-
const output = handleCallResult(result, withHarness(buildCtx(data), "service", intent));
|
|
697
|
-
autoAddToProject(projectEnvPrefix, validated.operation_type, result).catch(() => { });
|
|
698
|
-
return output;
|
|
699
|
-
}
|
|
700
|
-
case "machine": {
|
|
701
|
-
if (validated.data.node && typeof validated.data.node === 'object' && 'json_or_markdown_file' in validated.data.node) {
|
|
702
|
-
const filePathStr = validated.data.node.json_or_markdown_file;
|
|
703
|
-
let fileContent;
|
|
704
|
-
try {
|
|
705
|
-
const filePath = resolve(filePathStr);
|
|
706
|
-
fileContent = readFileSync(filePath, 'utf-8');
|
|
707
|
-
}
|
|
708
|
-
catch (e) {
|
|
709
|
-
throw new Error(`Failed to read file '${filePathStr}': ${e.message}`);
|
|
710
|
-
}
|
|
711
|
-
const parseResult = parseMachineNodesFromText(fileContent);
|
|
712
|
-
if (!parseResult.success) {
|
|
713
|
-
const errorMessages = formatMachineNodeErrors(parseResult.errors);
|
|
714
|
-
throw new Error(`Machine node validation failed for file '${filePathStr}':\n\n${errorMessages}`);
|
|
715
|
-
}
|
|
716
|
-
if (!parseResult.data) {
|
|
717
|
-
throw new Error(`No nodes found in file '${filePathStr}'`);
|
|
718
|
-
}
|
|
719
|
-
validated.data.node = {
|
|
720
|
-
op: "set",
|
|
721
|
-
nodes: parseResult.data,
|
|
722
|
-
bReplace: true
|
|
723
|
-
};
|
|
724
|
-
}
|
|
725
|
-
const machineData = validated.data;
|
|
726
|
-
const permWarning = await checkMachinePermissionBeforePublish(machineData, env);
|
|
727
|
-
if (permWarning) {
|
|
728
|
-
constraintWarnings.push(permWarning);
|
|
729
|
-
}
|
|
730
|
-
const machineNodes = machineData?.node?.nodes ?? machineData?.node;
|
|
731
|
-
if (Array.isArray(machineNodes)) {
|
|
732
|
-
const arbPatterns = /^(dispute|disputed|arbitration|arb_|arb\.|resolve_dispute|start_arbitration|open_dispute)/i;
|
|
733
|
-
for (const node of machineNodes) {
|
|
734
|
-
const nodeName = typeof node === 'object' ? node?.name : '';
|
|
735
|
-
if (typeof nodeName === 'string' && arbPatterns.test(nodeName)) {
|
|
736
|
-
constraintWarnings.push(`ARBITRATION SEPARATION WARNING: Machine node "${nodeName}" appears to be an arbitration-related node.\n` +
|
|
737
|
-
`CORE PRINCIPLE: A merchant cannot handle disputes fairly — they would be 'both player and referee'.\n` +
|
|
738
|
-
`The WoWok smart contract design makes Arbitration a completely separate object:\n` +
|
|
739
|
-
` - Arbitration has its own Permission, voting_guard, usage_guard, and balance\n` +
|
|
740
|
-
` - Arb instances have a 7-state lifecycle managed by Arbitration, not by Machine\n` +
|
|
741
|
-
` - The Order object is the bridge: it has 'progress' (Machine) and 'dispute' (Arb list) fields\n` +
|
|
742
|
-
` - When Arb rules, it calls order::compensate() — the ONLY connection to the business flow\n\n` +
|
|
743
|
-
`CORRECT PATTERN:\n` +
|
|
744
|
-
` - Machine: business states only (ordered -> shipped -> delivered -> completed)\n` +
|
|
745
|
-
` - Arbitration: separate object with its own Permission (NOT shared with Service)\n` +
|
|
746
|
-
` - Arb: 7-state lifecycle (Principal_confirming -> Arbitrator_confirming -> Voting -> Arbitrated -> Objectionable -> Finished -> Withdrawn)\n` +
|
|
747
|
-
` - R-M1-11: NEVER name nodes 'refunded'/'disputed'/'arb'/'refund' — use business states ('cancelled'/'returned') for dispute OUTCOMES; refunds route via Allocator triggered by those states, disputes via the separate Arbitration object\n\n` +
|
|
748
|
-
`If this node name is a legitimate business state (not arbitration), ignore this warning.`);
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
const callMachine = new CallMachine(validated.data);
|
|
753
|
-
const result = validated.submission
|
|
754
|
-
? await callMachine.call_with_submission(env, await transformSubmission(validated.submission))
|
|
755
|
-
: await callMachine.call(env);
|
|
756
|
-
const output = handleCallResult(result, buildCtx(validated.data));
|
|
757
|
-
autoAddToProject(projectEnvPrefix, validated.operation_type, result).catch(() => { });
|
|
758
|
-
return output;
|
|
759
|
-
}
|
|
760
|
-
case "progress": {
|
|
761
|
-
if (validated.data?.operate) {
|
|
762
|
-
constraintWarnings.push("Progress routing hint: if this Progress is bound to an Order and the target " +
|
|
763
|
-
"Forward uses namedOperator=\"\" (empty string = OrderHolder), use " +
|
|
764
|
-
"order.progress (NOT progress.operate). Direct progress::next fails with " +
|
|
765
|
-
"Permission denied for OrderHolder forwards. Use progress.operate only for " +
|
|
766
|
-
"non-empty namedOperator or permissionIndex-only forwards.");
|
|
767
|
-
}
|
|
768
|
-
const callProgress = new CallProgress(validated.data);
|
|
769
|
-
const result = validated.submission
|
|
770
|
-
? await callProgress.call_with_submission(env, await transformSubmission(validated.submission))
|
|
771
|
-
: await callProgress.call(env);
|
|
772
|
-
if (!validated.submission && result && typeof result === 'object' && 'submission' in result) {
|
|
773
|
-
const submissionData = result.submission;
|
|
774
|
-
if (Array.isArray(submissionData) && submissionData.length > 0) {
|
|
775
|
-
const guardRef = submissionData[0]?.guard;
|
|
776
|
-
if (guardRef) {
|
|
777
|
-
const submissionCtx = {
|
|
778
|
-
operation: "progress_next",
|
|
779
|
-
network: env?.network,
|
|
780
|
-
signer: env?.account,
|
|
781
|
-
progress_address: validated.data?.object,
|
|
782
|
-
order_address: validated.data?.task,
|
|
783
|
-
};
|
|
784
|
-
const prompt = await generateGuardSubmissionPrompt(guardRef, submissionCtx);
|
|
785
|
-
if (prompt) {
|
|
786
|
-
constraintWarnings.push(formatSubmissionPrompt(prompt));
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
if (result && typeof result === 'object' && 'digest' in result
|
|
792
|
-
&& result?.effects?.status?.status === 'success') {
|
|
793
|
-
try {
|
|
794
|
-
const progressRef = validated.data?.object;
|
|
795
|
-
let progressAddr;
|
|
796
|
-
if (typeof progressRef === 'string') {
|
|
797
|
-
if (progressRef.startsWith('0x')) {
|
|
798
|
-
progressAddr = progressRef;
|
|
799
|
-
}
|
|
800
|
-
else {
|
|
801
|
-
progressAddr = await LocalMark.Instance().get_address(progressRef) ?? undefined;
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
if (progressAddr) {
|
|
805
|
-
const progressQuery = await query_objects({
|
|
806
|
-
objects: [progressAddr],
|
|
807
|
-
no_cache: true,
|
|
808
|
-
network: env?.network,
|
|
809
|
-
});
|
|
810
|
-
const progressObj = progressQuery?.objects?.[0];
|
|
811
|
-
if (progressObj?.type === "Progress") {
|
|
812
|
-
const currentNode = progressObj.current ?? "<unknown>";
|
|
813
|
-
const historyCount = Array.isArray(progressObj.session)
|
|
814
|
-
? progressObj.session.length : 0;
|
|
815
|
-
const machineAddr = progressObj.machine;
|
|
816
|
-
const previewLines = [
|
|
817
|
-
`PROGRESS PREVIEW:`,
|
|
818
|
-
` • current node: "${currentNode}"`,
|
|
819
|
-
` • history count: ${historyCount} session(s)`,
|
|
820
|
-
];
|
|
821
|
-
if (machineAddr) {
|
|
822
|
-
previewLines.push(` • machine: ${machineAddr}`);
|
|
823
|
-
}
|
|
824
|
-
constraintWarnings.push(previewLines.join("\n"));
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
catch {
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
const output = handleCallResult(result, buildCtx(validated.data));
|
|
832
|
-
autoAddToProject(projectEnvPrefix, validated.operation_type, result).catch(() => { });
|
|
833
|
-
return output;
|
|
834
|
-
}
|
|
835
|
-
case "repository": {
|
|
836
|
-
const callRepository = new CallRepository(validated.data);
|
|
837
|
-
const result = validated.submission
|
|
838
|
-
? await callRepository.call_with_submission(env, await transformSubmission(validated.submission))
|
|
839
|
-
: await callRepository.call(env);
|
|
840
|
-
const output = handleCallResult(result, buildCtx(validated.data));
|
|
841
|
-
autoAddToProject(projectEnvPrefix, validated.operation_type, result).catch(() => { });
|
|
842
|
-
return output;
|
|
843
|
-
}
|
|
844
|
-
case "arbitration": {
|
|
845
|
-
const arbFundResult = await prepareFundOperation(validated.data, "arbitration", env?.network);
|
|
846
|
-
if (arbFundResult.blockingErrors.length > 0) {
|
|
847
|
-
return buildFundBlockResult(arbFundResult, "arbitration");
|
|
848
|
-
}
|
|
849
|
-
constraintWarnings.push(...arbFundResult.warnings);
|
|
850
|
-
if (arbFundResult.confirmation) {
|
|
851
|
-
constraintWarnings.push(arbFundResult.confirmation.message);
|
|
852
|
-
const fundHint = generateFundSkillsHint(arbFundResult.confirmation);
|
|
853
|
-
if (fundHint)
|
|
854
|
-
constraintWarnings.push(fundHint);
|
|
855
|
-
}
|
|
856
|
-
const callArbitration = new CallArbitration(validated.data);
|
|
857
|
-
const result = validated.submission
|
|
858
|
-
? await callArbitration.call_with_submission(env, await transformSubmission(validated.submission))
|
|
859
|
-
: await callArbitration.call(env);
|
|
860
|
-
const output = handleCallResult(result, buildCtx(validated.data));
|
|
861
|
-
autoAddToProject(projectEnvPrefix, validated.operation_type, result).catch(() => { });
|
|
862
|
-
return output;
|
|
863
|
-
}
|
|
864
|
-
case "contact": {
|
|
865
|
-
const callContact = new CallContact(validated.data);
|
|
866
|
-
const result = validated.submission
|
|
867
|
-
? await callContact.call_with_submission(env, await transformSubmission(validated.submission))
|
|
868
|
-
: await callContact.call(env);
|
|
869
|
-
const output = handleCallResult(result, buildCtx(validated.data));
|
|
870
|
-
autoAddToProject(projectEnvPrefix, validated.operation_type, result).catch(() => { });
|
|
871
|
-
return output;
|
|
872
|
-
}
|
|
873
|
-
case "treasury": {
|
|
874
|
-
const trFundResult = await prepareFundOperation(validated.data, "treasury", env?.network);
|
|
875
|
-
if (trFundResult.blockingErrors.length > 0) {
|
|
876
|
-
return buildFundBlockResult(trFundResult, "treasury");
|
|
877
|
-
}
|
|
878
|
-
constraintWarnings.push(...trFundResult.warnings);
|
|
879
|
-
if (trFundResult.confirmation) {
|
|
880
|
-
constraintWarnings.push(trFundResult.confirmation.message);
|
|
881
|
-
const fundHint = generateFundSkillsHint(trFundResult.confirmation);
|
|
882
|
-
if (fundHint)
|
|
883
|
-
constraintWarnings.push(fundHint);
|
|
884
|
-
}
|
|
885
|
-
const callTreasury = new CallTreasury(validated.data);
|
|
886
|
-
const result = validated.submission
|
|
887
|
-
? await callTreasury.call_with_submission(env, await transformSubmission(validated.submission))
|
|
888
|
-
: await callTreasury.call(env);
|
|
889
|
-
const output = handleCallResult(result, buildCtx(validated.data));
|
|
890
|
-
autoAddToProject(projectEnvPrefix, validated.operation_type, result).catch(() => { });
|
|
891
|
-
return output;
|
|
892
|
-
}
|
|
893
|
-
case "reward": {
|
|
894
|
-
const rwFundResult = await prepareFundOperation(validated.data, "reward", env?.network);
|
|
895
|
-
if (rwFundResult.blockingErrors.length > 0) {
|
|
896
|
-
return buildFundBlockResult(rwFundResult, "reward");
|
|
897
|
-
}
|
|
898
|
-
constraintWarnings.push(...rwFundResult.warnings);
|
|
899
|
-
if (rwFundResult.confirmation) {
|
|
900
|
-
constraintWarnings.push(rwFundResult.confirmation.message);
|
|
901
|
-
const fundHint = generateFundSkillsHint(rwFundResult.confirmation);
|
|
902
|
-
if (fundHint)
|
|
903
|
-
constraintWarnings.push(fundHint);
|
|
904
|
-
}
|
|
905
|
-
const transformedData = transformRewardInput(validated.data);
|
|
906
|
-
const callReward = new CallReward(transformedData);
|
|
907
|
-
const result = validated.submission
|
|
908
|
-
? await callReward.call_with_submission(env, await transformSubmission(validated.submission))
|
|
909
|
-
: await callReward.call(env);
|
|
910
|
-
const output = handleCallResult(result, buildCtx(validated.data));
|
|
911
|
-
autoAddToProject(projectEnvPrefix, validated.operation_type, result).catch(() => { });
|
|
912
|
-
return output;
|
|
913
|
-
}
|
|
914
|
-
case "allocation": {
|
|
915
|
-
const alFundResult = await prepareFundOperation(validated.data, "allocation", env?.network);
|
|
916
|
-
if (alFundResult.blockingErrors.length > 0) {
|
|
917
|
-
return buildFundBlockResult(alFundResult, "allocation");
|
|
918
|
-
}
|
|
919
|
-
constraintWarnings.push(...alFundResult.warnings);
|
|
920
|
-
if (alFundResult.confirmation) {
|
|
921
|
-
constraintWarnings.push(alFundResult.confirmation.message);
|
|
922
|
-
const fundHint = generateFundSkillsHint(alFundResult.confirmation);
|
|
923
|
-
if (fundHint)
|
|
924
|
-
constraintWarnings.push(fundHint);
|
|
925
|
-
}
|
|
926
|
-
const callAllocation = new CallAllocation(validated.data);
|
|
927
|
-
const result = validated.submission
|
|
928
|
-
? await callAllocation.call_with_submission(env, await transformSubmission(validated.submission))
|
|
929
|
-
: await callAllocation.call(env);
|
|
930
|
-
const allocData = validated.data;
|
|
931
|
-
if (allocData?.alloc_by_guard) {
|
|
932
|
-
const createdPayments = ResponseData(result).filter((e) => e?.type === "Payment" && e?.change === "created");
|
|
933
|
-
if (createdPayments.length > 0) {
|
|
934
|
-
const paymentAddrs = createdPayments.map((p) => p.object).join(", ");
|
|
935
|
-
try {
|
|
936
|
-
const paymentResult = await query_objects({
|
|
937
|
-
objects: createdPayments.map((p) => p.object),
|
|
938
|
-
no_cache: true,
|
|
939
|
-
network: env?.network,
|
|
940
|
-
});
|
|
941
|
-
const distributionLines = [];
|
|
942
|
-
let totalDistributed = BigInt(0);
|
|
943
|
-
for (const obj of paymentResult?.objects || []) {
|
|
944
|
-
if (obj?.type === "Payment" && obj?.record) {
|
|
945
|
-
for (const entry of obj.record) {
|
|
946
|
-
const recipientLabel = formatRecipientLabel(entry.recipient);
|
|
947
|
-
const amountStr = typeof entry.amount === 'string' ? entry.amount : String(entry.amount);
|
|
948
|
-
const amountBig = BigInt(amountStr);
|
|
949
|
-
totalDistributed += amountBig;
|
|
950
|
-
distributionLines.push(` • ${recipientLabel}: ${formatMistAmount(amountBig)}`);
|
|
951
|
-
}
|
|
952
|
-
if (obj.object) {
|
|
953
|
-
distributionLines.push(` • Payment object: ${obj.object}`);
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
if (distributionLines.length > 0) {
|
|
958
|
-
distributionLines.unshift(`DISTRIBUTION DETAILS (alloc_by_guard):`);
|
|
959
|
-
distributionLines.push(` ─────────────────`, ` • Total distributed: ${formatMistAmount(totalDistributed)}`);
|
|
960
|
-
const isEscrow = paymentResult?.objects?.some((obj) => obj?.type === "Payment" && obj?.info?.for_object);
|
|
961
|
-
if (isEscrow) {
|
|
962
|
-
distributionLines.push(``, `ESCROW MODE: Funds are held in escrow (Payment.for_object points to an Order). ` +
|
|
963
|
-
`The Order owner must call order_claim (or service_order_claim) to actually receive the funds. ` +
|
|
964
|
-
`This happens when the Guard's sharing config uses { GuardIdentifier: 0 }.`);
|
|
965
|
-
}
|
|
966
|
-
constraintWarnings.push(distributionLines.join("\n"));
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
catch {
|
|
970
|
-
constraintWarnings.push(`alloc_by_guard created Payment object(s) [${paymentAddrs}]. ` +
|
|
971
|
-
`Query these Payment objects to see the distribution details and check for_object for escrow mode.`);
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
const output = handleCallResult(result, buildCtx(validated.data));
|
|
976
|
-
autoAddToProject(projectEnvPrefix, validated.operation_type, result).catch(() => { });
|
|
977
|
-
return output;
|
|
978
|
-
}
|
|
979
|
-
case "permission": {
|
|
980
|
-
const opType = validated.operation_type;
|
|
981
|
-
const output = handlePermissionOperations(validated.data, env, buildCtx);
|
|
982
|
-
if (output && typeof output === 'object' && 'then' in output) {
|
|
983
|
-
output.then((resolved) => {
|
|
984
|
-
if (resolved?.structuredContent?.result) {
|
|
985
|
-
autoAddToProject(projectEnvPrefix, opType, resolved.structuredContent.result).catch(() => { });
|
|
986
|
-
}
|
|
987
|
-
}).catch(() => { });
|
|
988
|
-
}
|
|
989
|
-
return output;
|
|
990
|
-
}
|
|
991
|
-
case "guard": {
|
|
992
|
-
const validatedData = validated.data;
|
|
993
|
-
if (validatedData.root?.type === "file") {
|
|
994
|
-
const filePath = resolve(validatedData.root.file_path);
|
|
995
|
-
let fileContent;
|
|
996
|
-
try {
|
|
997
|
-
fileContent = readFileSync(filePath, 'utf-8');
|
|
998
|
-
}
|
|
999
|
-
catch (e) {
|
|
1000
|
-
throw new Error(`Failed to read Guard definition file '${validatedData.root.file_path}': ${e.message}`);
|
|
1001
|
-
}
|
|
1002
|
-
const parseResult = parseGuardFile(fileContent, validatedData.root.format);
|
|
1003
|
-
if (!parseResult.success) {
|
|
1004
|
-
const errorMessages = formatGuardParseErrors(parseResult.errors);
|
|
1005
|
-
throw new Error(`Guard validation failed for file '${validatedData.root.file_path}':\n\n${errorMessages}`);
|
|
1006
|
-
}
|
|
1007
|
-
const fileData = parseResult.data;
|
|
1008
|
-
validatedData.root = { type: "node", node: fileData.root };
|
|
1009
|
-
if (fileData.table !== undefined && validatedData.table === undefined) {
|
|
1010
|
-
validatedData.table = fileData.table;
|
|
1011
|
-
}
|
|
1012
|
-
if (fileData.description !== undefined && validatedData.description === undefined) {
|
|
1013
|
-
validatedData.description = fileData.description;
|
|
1014
|
-
}
|
|
1015
|
-
if (fileData.rely !== undefined && validatedData.rely === undefined) {
|
|
1016
|
-
validatedData.rely = fileData.rely;
|
|
1017
|
-
}
|
|
1018
|
-
if (fileData.namedNew !== undefined && validatedData.namedNew === undefined) {
|
|
1019
|
-
validatedData.namedNew = fileData.namedNew;
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
if (validatedData.root && typeof validatedData.root === 'object') {
|
|
1023
|
-
const rootObj = validatedData.root;
|
|
1024
|
-
if (rootObj.type === 'node' && rootObj.node) {
|
|
1025
|
-
validatedData.root = rootObj.node;
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
if (!validatedData.table || validatedData.table.length === 0) {
|
|
1029
|
-
throw new Error("Guard 'table' field is required and cannot be empty");
|
|
1030
|
-
}
|
|
1031
|
-
if (!validatedData.root) {
|
|
1032
|
-
throw new Error("Guard 'root' field is required");
|
|
1033
|
-
}
|
|
1034
|
-
const callGuard = new CallGuard(validatedData);
|
|
1035
|
-
const result = await callGuard.call(env);
|
|
1036
|
-
if (result && typeof result === 'object' && 'digest' in result
|
|
1037
|
-
&& result?.effects?.status?.status === 'success') {
|
|
1038
|
-
try {
|
|
1039
|
-
const rootType = validatedData.root?.type ?? "<unknown>";
|
|
1040
|
-
const tableArr = Array.isArray(validatedData.table) ? validatedData.table : [];
|
|
1041
|
-
const tableEntries = tableArr.length;
|
|
1042
|
-
const submissionEntries = tableArr.filter((t) => t?.b_submission === true).length;
|
|
1043
|
-
const relyGuards = validatedData.rely?.guards;
|
|
1044
|
-
const relyCount = Array.isArray(relyGuards) ? relyGuards.length : 0;
|
|
1045
|
-
const relyMode = validatedData.rely?.logic_or === true
|
|
1046
|
-
? "OR" : validatedData.rely?.logic_or === false ? "AND" : "none";
|
|
1047
|
-
const summaryLines = [
|
|
1048
|
-
`GUARD LOGIC SUMMARY:`,
|
|
1049
|
-
` • root type: ${rootType}`,
|
|
1050
|
-
` • table entries: ${tableEntries} (${submissionEntries} require runtime submission)`,
|
|
1051
|
-
];
|
|
1052
|
-
if (relyCount > 0) {
|
|
1053
|
-
summaryLines.push(` • relies on: ${relyCount} guard(s) (mode: ${relyMode})`);
|
|
1054
|
-
}
|
|
1055
|
-
if (validatedData.description) {
|
|
1056
|
-
const desc = String(validatedData.description).slice(0, 80);
|
|
1057
|
-
summaryLines.push(` • description: "${desc}"`);
|
|
1058
|
-
}
|
|
1059
|
-
constraintWarnings.push(summaryLines.join("\n"));
|
|
1060
|
-
}
|
|
1061
|
-
catch {
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
const output = handleCallResult(result, buildCtx(validated.data));
|
|
1065
|
-
autoAddToProject(projectEnvPrefix, validated.operation_type, result).catch(() => { });
|
|
1066
|
-
return output;
|
|
1067
|
-
}
|
|
1068
|
-
case "personal": {
|
|
1069
|
-
const transformedData = transformPersonalInput(validated.data);
|
|
1070
|
-
const callPersonal = new CallPersonal(transformedData);
|
|
1071
|
-
const result = await callPersonal.call(env);
|
|
1072
|
-
const output = handleCallResult(result, buildCtx(validated.data));
|
|
1073
|
-
autoAddToProject(projectEnvPrefix, validated.operation_type, result).catch(() => { });
|
|
1074
|
-
return output;
|
|
1075
|
-
}
|
|
1076
|
-
case "payment": {
|
|
1077
|
-
const payFundResult = await prepareFundOperation(validated.data, "payment", env?.network);
|
|
1078
|
-
if (payFundResult.blockingErrors.length > 0) {
|
|
1079
|
-
return buildFundBlockResult(payFundResult, "payment");
|
|
1080
|
-
}
|
|
1081
|
-
constraintWarnings.push(...payFundResult.warnings);
|
|
1082
|
-
if (payFundResult.confirmation) {
|
|
1083
|
-
constraintWarnings.push(payFundResult.confirmation.message);
|
|
1084
|
-
const fundHint = generateFundSkillsHint(payFundResult.confirmation);
|
|
1085
|
-
if (fundHint)
|
|
1086
|
-
constraintWarnings.push(fundHint);
|
|
1087
|
-
}
|
|
1088
|
-
const paymentData = validated.data;
|
|
1089
|
-
if (paymentData?.receive === true) {
|
|
1090
|
-
constraintWarnings.push("RECEIVE MODE (order_claim): You are unwrapping a CoinWrapper to your wallet. " +
|
|
1091
|
-
"This is the final step of the escrow flow:\n" +
|
|
1092
|
-
" 1. Allocation's alloc_by_guard created a Payment object with your address as a recipient\n" +
|
|
1093
|
-
" 2. The Payment's revenue split transferred a CoinWrapper to your wallet (owned but not spendable)\n" +
|
|
1094
|
-
" 3. THIS operation unwraps the CoinWrapper via payment::unwrap_to_myself, deleting the " +
|
|
1095
|
-
"CoinWrapper and transferring the underlying coin to tx_context::sender\n" +
|
|
1096
|
-
"Requirements:\n" +
|
|
1097
|
-
" - You MUST be the CoinWrapper's owner (the recipient specified in the Allocation)\n" +
|
|
1098
|
-
" - type_parameter is OPTIONAL: when omitted it is auto-derived from the CoinWrapper's " +
|
|
1099
|
-
"own on-chain type (the inner T of CoinWrapper<T>)\n" +
|
|
1100
|
-
" - object can be a CoinWrapper ID (0x...) or a local mark name\n" +
|
|
1101
|
-
"To find received CoinWrappers: call query_toolkit with query_type='onchain_received' " +
|
|
1102
|
-
"and type='CoinWrapper' for your account.\n" +
|
|
1103
|
-
"After success: verify your balance increased via account_balance query.");
|
|
1104
|
-
}
|
|
1105
|
-
else if (paymentData?.revenue) {
|
|
1106
|
-
constraintWarnings.push("CREATE MODE: Creating a new Payment object. Payments are IMMUTABLE after creation — " +
|
|
1107
|
-
"they cannot be modified. The 'revenue' array defines the recipients and amounts; " +
|
|
1108
|
-
"ensure correctness before submitting. The 'info.for_guard' field (if set) binds this " +
|
|
1109
|
-
"Payment to a Guard for conditional release (common in escrow workflows).");
|
|
1110
|
-
}
|
|
1111
|
-
const callPayment = new CallPayment(validated.data);
|
|
1112
|
-
const result = await callPayment.call(env);
|
|
1113
|
-
const output = handleCallResult(result, buildCtx(validated.data));
|
|
1114
|
-
autoAddToProject(projectEnvPrefix, validated.operation_type, result).catch(() => { });
|
|
1115
|
-
return output;
|
|
1116
|
-
}
|
|
1117
|
-
case "demand": {
|
|
1118
|
-
const callDemand = new CallDemand(validated.data);
|
|
1119
|
-
const result = validated.submission
|
|
1120
|
-
? await callDemand.call_with_submission(env, await transformSubmission(validated.submission))
|
|
1121
|
-
: await callDemand.call(env);
|
|
1122
|
-
const output = handleCallResult(result, buildCtx(validated.data));
|
|
1123
|
-
autoAddToProject(projectEnvPrefix, validated.operation_type, result).catch(() => { });
|
|
1124
|
-
return output;
|
|
1125
|
-
}
|
|
1126
|
-
case "order": {
|
|
1127
|
-
if (validated.data?.progress) {
|
|
1128
|
-
constraintWarnings.push("Order routing hint: order.progress works only for Forwards with " +
|
|
1129
|
-
"namedOperator=\"\" (OrderHolder). If the target Forward uses a " +
|
|
1130
|
-
"non-empty namedOperator or permissionIndex-only, use progress.operate " +
|
|
1131
|
-
"on the Progress object directly instead.");
|
|
1132
|
-
constraintWarnings.push("Allocation hint: if this operation advances the order to a terminal " +
|
|
1133
|
-
"state (e.g. Completed/Cancelled/Refunded), funds remain in the " +
|
|
1134
|
-
"Allocation object and are NOT auto-distributed. To release funds, " +
|
|
1135
|
-
"trigger the corresponding Guard verification via allocation operation " +
|
|
1136
|
-
"(the Guard bound to the matching Allocator will verify and distribute).");
|
|
1137
|
-
}
|
|
1138
|
-
const callOrder = new CallOrder(validated.data);
|
|
1139
|
-
const result = validated.submission
|
|
1140
|
-
? await callOrder.call_with_submission(env, await transformSubmission(validated.submission))
|
|
1141
|
-
: await callOrder.call(env);
|
|
1142
|
-
const output = handleCallResult(result, buildCtx(validated.data));
|
|
1143
|
-
autoAddToProject(projectEnvPrefix, validated.operation_type, result).catch(() => { });
|
|
1144
|
-
return output;
|
|
1145
|
-
}
|
|
1146
|
-
case "gen_passport": {
|
|
1147
|
-
const result = await gen_passport(env, validated.guard, validated.info);
|
|
1148
|
-
const output = handleCallResult(result, buildCtx(validated.data));
|
|
1149
|
-
autoAddToProject(projectEnvPrefix, validated.operation_type, result).catch(() => { });
|
|
1150
|
-
return output;
|
|
1151
|
-
}
|
|
1152
|
-
case "proof": {
|
|
1153
|
-
const callProof = new CallProof(validated.data);
|
|
1154
|
-
const result = validated.submission
|
|
1155
|
-
? await callProof.call_with_submission(env, await transformSubmission(validated.submission))
|
|
1156
|
-
: await callProof.call(env);
|
|
1157
|
-
const output = handleCallResult(result, buildCtx(validated.data));
|
|
1158
|
-
autoAddToProject(projectEnvPrefix, validated.operation_type, result).catch(() => { });
|
|
1159
|
-
return output;
|
|
1160
|
-
}
|
|
1161
|
-
case "gen_proof": {
|
|
1162
|
-
const result = await gen_proof(env, validated.proof, validated.server_pubkey, validated.server_signature, validated.proof_type, validated.description, validated.item_count, validated.about_address);
|
|
1163
|
-
const output = handleCallResult(result, buildCtx(validated.data));
|
|
1164
|
-
autoAddToProject(projectEnvPrefix, validated.operation_type, result).catch(() => { });
|
|
1165
|
-
return output;
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
const exhaustiveOp = validated;
|
|
1169
|
-
throw new Error(`Unknown on-chain operation type: ${String(exhaustiveOp.operation_type)}`);
|
|
1170
|
-
}
|
|
1171
|
-
catch (error) {
|
|
1172
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1173
|
-
const opType = validated?.operation_type;
|
|
1174
|
-
const ctxData = validated && 'data' in validated ? validated.data : undefined;
|
|
1175
|
-
return handleCallResult({ error: errorMessage }, opType ? {
|
|
1176
|
-
operation_type: opType,
|
|
1177
|
-
data: ctxData,
|
|
1178
|
-
} : undefined);
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1
|
+
import{readFileSync,writeFileSync,existsSync,mkdirSync}from'fs';import{resolve,dirname,join}from'path';import{getWowMcpDir}from'@wowok/wowok';import{CallService,CallMachine,CallProgress,CallGuard,CallArbitration,CallRepository,CallContact,CallTreasury,CallReward,CallAllocation,CallPersonal,CallPayment,CallDemand,CallOrder,gen_passport,CallProof,gen_proof,ResponseData,LocalProject,LocalMark,query_objects,parseGuardFile,formatGuardParseErrors,transformRewardInput,transformPersonalInput}from'@wowok/wowok';import{OnchainOperationsSchema,strictParse,getEnvConfig,handleCallResult,checkClientSchemaCompatibility,parseMachineNodesFromText,formatNodeErrors as a306a,transformSubmission}from'../../schema/index.js';import{handlePermissionOperations}from'../../schema/call/permission-handler.js';import{collectPermissionIndexes,checkPermissionAuthorization,formatPermissionWarning}from'../../schema/utils/permission-machine-check.js';import{isProjectServiceEnabled,normalize as a306b}from'../../project/index.js';import{getSkillsHintForOnchain}from'../../schema/utils/skills-recommendation.js';import{prepareFundOperation,generateSkillsHint as a306c}from'../../knowledge/fund-layer.js';import{generateGuardSubmissionPrompt,formatSubmissionPrompt}from'../../knowledge/guard-submission-prompt.js';import{classifyWipPath}from'../wip-deploy-assist.js';import{withHarness}from'../shared.js';const REFERRER_FILE=join(getWowMcpDir(),'referrer');function readStoredReferrer(){try{if(!existsSync(REFERRER_FILE))return null;const a=readFileSync(REFERRER_FILE,'utf8')['trim']();return a||null;}catch{return null;}}const PROJECT_SKILL_DIRS=['.claude/skills','.agents/skills','.cursor/rules','.github/prompts','.windsurf/skills','.codex/skills','.qoder/skills','.roo/skills','.codebuddy/skills'],PROJECT_SKILL_MARKERS=['wowok-provider','wowok-supplier','wowok-collaborator','wowok-arbitrator','wowok-order','wowok-messenger','wowok-machine','wowok-output','wowok-onboard','wowok-planner','wowok-auditor'],SKILLS_HINT_FILE=join(getWowMcpDir(),'skills-hint-asked.json');function projectHasSkills(a){for(const b of PROJECT_SKILL_DIRS){for(const c of PROJECT_SKILL_MARKERS){if(existsSync(join(a,b,c)))return!![];}}return![];}function loadSkillsAsked(){try{if(!existsSync(SKILLS_HINT_FILE))return{};return JSON['parse'](readFileSync(SKILLS_HINT_FILE,'utf8'))??{};}catch{return{};}}function persistSkillsAsked(a){try{const b=loadSkillsAsked();b[a]=!![],mkdirSync(dirname(SKILLS_HINT_FILE),{'recursive':!![]}),writeFileSync(SKILLS_HINT_FILE,JSON['stringify'](b,null,0x2),'utf8');}catch{}}function getProjectSkillsHint(){try{const a=process['cwd']();if(!a||projectHasSkills(a))return null;const b=loadSkillsAsked();if(b[a])return null;return persistSkillsAsked(a),'WoWok\x20skills\x20are\x20not\x20installed\x20in\x20this\x20project.\x20Run\x20`wowok-skills\x20init`\x20'+'here\x20to\x20install\x20them\x20(the\x20MCP\x20works\x20regardless;\x20skills\x20improve\x20AI\x20orchestration).';}catch{return null;}}function formatRecipientLabel(a){if(!a)return'unknown';if(typeof a==='string')return a;if('GuardIdentifier'in a)return'GuardIdentifier('+a['GuardIdentifier']+')';if('Entity'in a){const b=a['Entity'];if(typeof b==='string'&&b['length']>0x10)return'Entity('+b['slice'](0x0,0x8)+'...'+b['slice'](-0x4)+')';return'Entity('+b+')';}if('Signer'in a)return'Signer\x20(transaction\x20signer)';return JSON['stringify'](a);}function formatMistAmount(a){const b=Number(a)/0x3b9aca00;if(b===0x0)return'0\x20WOW';const c=b['toFixed'](0x9)['replace'](/\.?0+$/,'');return c+'\x20WOW\x20('+a['toString']()+'\x20MIST)';}function extractNodesForCheck(a){if(!a?.['node'])return[];if(a['node']['nodes']&&Array['isArray'](a['node']['nodes']))return a['node']['nodes'];return[];}function resolvePermissionRef(a){if(!a?.['object'])return null;if(typeof a['object']==='string')return null;const b=a['object'];if(b['permission']){if(typeof b['permission']==='string')return b['permission'];return null;}return null;}async function checkMachinePermissionBeforePublish(a,b){if(a?.['publish']!==!![])return'';const c=extractNodesForCheck(a);if(c['length']===0x0)return'';const d=collectPermissionIndexes(c);if(d['requiredIndexes']['length']===0x0)return'';let e='';if(d['missingRefs']['length']>0x0){e+='WARNING:\x20Some\x20forwards\x20have\x20NEITHER\x20permissionIndex\x20nor\x20namedOperator.\x20'+'These\x20forwards\x20cannot\x20be\x20executed.\x20Add\x20one\x20or\x20the\x20other:\x0a';for(const k of d['missingRefs']){e+='\x20\x20-\x20Node\x20\x22'+k['nodeName']+'\x22,\x20pair\x20prev_node=\x22'+k['prevNode']+'\x22,\x20forward\x20\x22'+k['forwardName']+'\x22\x0a';}e+='\x0a';}const f=resolvePermissionRef(a);if(!f)return d['requiredIndexes']['length']>0x0&&(e+='PRE-PUBLISH\x20REMINDER:\x20This\x20Machine\x20uses\x20'+d['requiredIndexes']['length']+'\x20custom\x20permission\x20index(es):\x20['+d['requiredIndexes']['join'](',\x20')+'].\x20'+'After\x20creating\x20the\x20Permission\x20object,\x20grant\x20entities\x20for\x20each\x20index\x20via\x20'+'permission.op=\x22add\x20perm\x20by\x20index\x22\x20BEFORE\x20publishing\x20the\x20Machine.\x20'+'Otherwise,\x20forwards\x20using\x20these\x20indexes\x20will\x20be\x20un-executable.\x0a'),e;let g=f;if(!f['startsWith']('0x'))try{const l=await LocalMark['Instance']()['get'](f);if(l?.['address'])g=l['address'];else return e+'PRE-PUBLISH:\x20Could\x20not\x20resolve\x20Permission\x20name\x20\x27'+f+'\x27\x20to\x20an\x20address.\x20Ensure\x20the\x20Permission\x20object\x20exists\x20and\x20is\x20marked.\x20'+'Required\x20indexes:\x20['+d['requiredIndexes']['join'](',\x20')+']\x0a';}catch{return e+'PRE-PUBLISH:\x20Failed\x20to\x20lookup\x20Permission\x20name\x20\x27'+f+'\x27.\x20Required\x20indexes:\x20['+d['requiredIndexes']['join'](',\x20')+']\x0a';}const h=b?.['network']??'testnet';let i=null;try{const m=await query_objects({'objects':[g],'network':h}),n=m?.['objects']?.[0x0];n&&(i={'address':g,'entity_count':n['entity_count'],'perm_remark':n['perm_remark'],'owner':n['owner']??n['builder'],'admin':n['admin']});}catch{return e+'PRE-PUBLISH:\x20Failed\x20to\x20query\x20Permission\x20object\x20'+g+'.\x20Required\x20indexes:\x20['+d['requiredIndexes']['join'](',\x20')+']\x0a';}if(!i)return e+'PRE-PUBLISH:\x20Permission\x20object\x20'+g+'\x20not\x20found\x20on-chain.\x20Required\x20indexes:\x20['+d['requiredIndexes']['join'](',\x20')+']\x0a';const j=checkPermissionAuthorization(d['requiredIndexes'],i);return!j['allAuthorized']&&(e+=formatPermissionWarning(j)+'\x0a'),e;}async function detectServiceGuardCircularDependency(a){if(!a||typeof a['object']!=='object'||a['object']===null)return null;const b=a['order_allocators'];if(!b||typeof b!=='object')return null;const c=Array['isArray'](b['allocators'])?b['allocators']:[];if(c['length']===0x0)return null;const d=[],e=new Set();for(const k of c){const l=k?.['guard'];if(typeof l==='string'&&!l['startsWith']('0x')){if(e['has'](l))continue;e['add'](l);try{const m=await LocalMark['Instance']()['get_address'](l);!m&&d['push'](l);}catch{d['push'](l);}}}if(d['length']===0x0)return null;const f=d['map'](n=>'\x27'+n+'\x27')['join'](',\x20'),g=a['object'],h=g['name']??'<service_name>',i=[{'step':0x1,'action':'onchain_operations','operation_type':'service','params':{...a,'order_allocators':null,'publish':![]},'purpose':'Create\x20Service\x20\x27'+h+'\x27\x20WITHOUT\x20order_allocators\x20to\x20establish\x20'+('its\x20LocalMark\x20entry.\x20After\x20this\x20step,\x20the\x20name\x20\x27'+h+'\x27\x20resolves\x20')+'to\x20an\x20on-chain\x20address.'},{'step':0x2,'action':'onchain_operations','operation_type':'guard','params':d['map'](n=>({'object':{'name':n,'type':'Guard'},'_hint':'Table\x20items\x20may\x20reference\x20Service\x20\x27'+h+'\x27\x20by\x20name'})),'purpose':'Create\x20Guard(s)\x20'+f+'.\x20Their\x20table\x20items\x20can\x20now\x20resolve\x20'+('Service\x20\x27'+h+'\x27\x20by\x20name\x20(LocalMark\x20entry\x20from\x20step\x201).')},{'step':0x3,'action':'onchain_operations','operation_type':'service','params':{'object':h,'order_allocators':b,'publish':a['publish']??!![]},'purpose':'Update\x20Service\x20with\x20order_allocators\x20(referencing\x20Guards\x20created\x20in\x20'+'step\x202)\x20and\x20publish.\x20After\x20publish,\x20order_allocators\x20becomes\x20SDK-LOCKED.'}],j='⚠️\x20Circular\x20dependency\x20detected:\x20Service\x20↔\x20Guard\x0a\x0a'+('Cannot\x20create\x20Service\x20with\x20order_allocators\x20referencing\x20non-existent\x20Guard(s):\x20'+f+'.\x0a\x0a')+'Explanation:\x20Guard\x20table\x20items\x20may\x20reference\x20the\x20Service\x20by\x20name,\x20creating\x20a\x20circular\x20'+'dependency:\x20the\x20Service\x20must\x20exist\x20as\x20a\x20LocalMark\x20before\x20the\x20Guard\x20can\x20resolve\x20it,\x20'+'but\x20the\x20Guard\x20must\x20exist\x20before\x20the\x20Service\x20can\x20reference\x20it\x20in\x20order_allocators.\x20'+'The\x20SDK\x20would\x20fail\x20with\x20a\x20BCS\x20serialization\x20error:\x20\x22Expected\x20valid\x20Address\x20for\x20'+'ValueType.Address,\x20but\x20failed\x20to\x20resolve\x20string:\x20<name>\x22.\x0a\x0a'+'Recommended\x20steps:\x0a'+i['map'](n=>'\x20\x20Step\x20'+n['step']+'\x20('+n['operation_type']+'):\x20'+n['purpose'])['join']('\x0a')+'\x0a\x0aHint:\x20This\x20is\x20the\x20canonical\x20Service↔Guard\x20circular\x20dependency.\x20The\x203-step\x20'+'pattern\x20above\x20is\x20the\x20documented\x20solution\x20(see\x20SCHEMA-03\x20/\x20P0-01\x20fix\x20in\x20'+'schema/call/service.ts\x20publish\x20field\x20description).';return{'content':[{'type':'text','text':j}],'structuredContent':{'result':{'type':'error','error':'Cannot\x20create\x20Service\x20with\x20order_allocators\x20referencing\x20non-existent\x20Guard(s):\x20'+f+'.\x20Circular\x20dependency:\x20Service↔Guard.','error_code':'circular_dependency_detected','retryable':!![],'recovery_hint':JSON['stringify'](i),'related_object':h},'message':'Circular\x20dependency\x20detected:\x20Service\x20↔\x20Guard.\x20See\x20recovery_hint\x20for\x20the\x203-step\x20creation\x20pattern.'}};}function buildFundBlockResult(a,b){const c=a['matchErrors']['length']>0x0,d=a['errors']['length']>0x0,e=c&&d?'FUND\x20OPERATION\x20BLOCKED':c?'TOKEN\x20TYPE\x20MISMATCH\x20—\x20operation\x20blocked':'FUND\x20INPUT\x20BLOCKED\x20—\x20operation\x20blocked',f=c&&d?'fund_blocked':c?'token_type_mismatch':'fund_input_error',g='⛔\x20'+e+'\x0a\x0a'+a['blockingErrors']['map'](h=>'\x20\x20•\x20'+h)['join']('\x0a')+'\x0a\x0aThe\x20token\x20type\x20of\x20a\x20generic\x20on-chain\x20object\x20(e.g.\x20Treasury<T>,\x20Service<T>)\x20is\x20'+'determined\x20at\x20creation\x20and\x20can\x20NEVER\x20be\x20changed,\x20and\x20monetary\x20input\x20is\x20never\x20'+('processed\x20with\x20unknown\x20token\x20precision.\x20This\x20'+b+'\x20operation\x20was\x20')+'NOT\x20executed.\x20Fix\x20the\x20errors\x20above\x20and\x20re-issue\x20the\x20operation'+(a['objectTokenType']?'\x20(object\x20token\x20type:\x20'+a['objectTokenType']+')':'')+'.';return{'content':[{'type':'text','text':g}],'structuredContent':{'result':{'type':'error','error':a['blockingErrors']['join']('\x20|\x20'),'error_code':f,'retryable':!![],'recovery_hint':'Use\x20token\x20type\x20'+(a['objectTokenType']??'<the\x20object\x27s\x20generic\x20token\x20type>')+'\x20for\x20all\x20'+('amounts,\x20coins,\x20and\x20receive\x20records\x20in\x20this\x20'+b+'\x20operation.\x20')+'Query\x20the\x20object\x20via\x20query_toolkit\x20onchain_objects\x20to\x20confirm\x20its\x20generic\x20'+'token\x20type\x20(type_raw,\x20e.g.\x20\x220x2::treasury::Treasury<0x2::wow::WOW>\x22).\x20'+'For\x20precision-unavailable\x20tokens,\x20retry\x20the\x20operation\x20—\x20the\x20on-chain\x20'+'metadata\x20lookup\x20may\x20have\x20been\x20transient.'},'message':'Fund\x20operation\x20blocked\x20before\x20execution.'}};}function checkSalesWipNetworkDeployment(a,b,c){const d=a?.['sales'];if(!d||typeof d!=='object')return null;if(d['op']!=='add'&&d['op']!=='set')return null;const e=Array['isArray'](d['sales'])?d['sales']:[];if(e['length']===0x0)return null;const f=b?.['network']==='localnet';for(const g of e){const h=g?.['wip'];if(typeof h!=='string'||h==='')continue;const i=classifyWipPath(h);if(!i['is_local'])continue;if(i['type']==='local_http'){if(f){c['push']('WIP\x20INTERNAL-TEST-ONLY\x20REMINDER\x20(sale\x20\x22'+g['name']+'\x22):\x20wip\x20=\x20\x22'+h+'\x22\x20is\x20a\x20'+('local-network\x20URL\x20('+i['description']+').\x20It\x20is\x20reachable\x20ONLY\x20on\x20the\x20')+'local\x20machine\x20/\x20LAN\x20where\x20a\x20local\x20WIP\x20server\x20runs.\x20This\x20is\x20acceptable\x20for\x20LOCALNET\x20'+'internal\x20testing,\x20but\x20customers\x20and\x20on-chain\x20verifiers\x20on\x20OTHER\x20machines\x20CANNOT\x20'+'reach\x20it\x20—\x20on\x20testnet/mainnet,\x20every\x20customer\x20order_new\x20would\x20fail\x20100%\x20because\x20the\x20'+'WIP\x20file\x20cannot\x20be\x20verified.\x20For\x20any\x20non-localnet\x20deployment,\x20replace\x20this\x20URL\x20with\x20'+'a\x20public\x20endpoint\x20(GitHub\x20Pages\x20/\x20IPFS\x20/\x20your\x20own\x20website)\x20or\x20leave\x20sale.wip\x20empty.');continue;}const l='a\x20local-network\x20URL\x20('+i['description']+')',m='⛔\x20WIP\x20IS\x20NOT\x20NETWORK-DEPLOYABLE\x20—\x20sales\x20NOT\x20submitted\x0a\x0a'+('Sale\x20\x22'+g['name']+'\x22\x20has\x20wip\x20=\x20\x22'+h+'\x22,\x20which\x20is\x20'+l+'.\x0a\x0a')+'INTERNAL\x20TEST\x20USE\x20ONLY:\x20this\x20URL\x20is\x20reachable\x20only\x20from\x20the\x20merchant\x27s\x20own\x20machine/LAN.\x20'+'Customers\x20on\x20other\x20machines\x20cannot\x20reach\x20it,\x20so\x20verifying\x20the\x20WIP\x20file\x20at\x20order\x20time\x20'+'fails\x20and\x20order_new\x20aborts\x20100%.\x20Local-network\x20WIP\x20URLs\x20are\x20allowed\x20ONLY\x20for\x20'+('localnet\x20internal\x20testing\x20(env.network\x20=\x20\x22localnet\x22);\x20on\x20'+(b?.['network']??'this\x20network')+'\x20')+'they\x20must\x20never\x20be\x20stored\x20on-chain.\x0a\x0a'+'Fix:\x20deploy\x20the\x20.wip\x20file\x20to\x20a\x20publicly\x20reachable\x20endpoint,\x20then\x20re-run\x20with\x20'+'sale.wip\x20=\x20\x22<public\x20URL>\x22\x20(e.g.\x20GitHub\x20Pages,\x20IPFS\x20gateway,\x20or\x20your\x20own\x20website).\x0a'+'\x20\x20•\x20GitHub\x20Pages:\x20https://<user>.github.io/<repo>/<file>.wip\x0a'+'\x20\x20•\x20IPFS:\x20\x20\x20\x20\x20\x20\x20\x20https://ipfs.io/ipfs/<CID>\x20\x20(or\x20ipfs://<CID>)\x0a'+'\x20\x20•\x20Your\x20site:\x20\x20\x20https://<your-domain>/<path>/<file>.wip\x0a'+'Alternatively,\x20set\x20sale.wip\x20=\x20\x22\x22\x20(empty)\x20to\x20SKIP\x20WIP\x20verification\x20—\x20'+'TESTING\x20ONLY,\x20not\x20recommended\x20for\x20production.';return{'content':[{'type':'text','text':m}],'structuredContent':{'result':{'type':'error','error':'Sale\x20\x22'+g['name']+'\x22\x20wip\x20is\x20'+l+':\x20'+h+'.\x20Local-network\x20URLs\x20are\x20INTERNAL\x20TEST\x20USE\x20ONLY\x20—\x20customers\x20cannot\x20verify\x20them,\x20aborting\x20order_new\x20100%.','error_code':'wip_not_network_deployed','retryable':!![],'recovery_hint':'Deploy\x20the\x20.wip\x20file\x20to\x20a\x20public\x20endpoint\x20(GitHub\x20Pages\x20/\x20IPFS\x20/\x20your\x20own\x20website)\x20'+'and\x20set\x20sale.wip\x20to\x20the\x20public\x20URL;\x20or\x20set\x20sale.wip\x20=\x20\x22\x22\x20(empty)\x20to\x20skip\x20WIP\x20'+'verification\x20(TESTING\x20ONLY).','related_object':g['name']},'message':'WIP\x20is\x20a\x20local-network\x20URL\x20(INTERNAL\x20TEST\x20USE\x20ONLY)\x20—\x20sales\x20not\x20submitted.\x20See\x20recovery_hint.'}};}const j='a\x20LOCAL\x20'+i['type']+'\x20path',k='⛔\x20WIP\x20IS\x20NOT\x20NETWORK-DEPLOYABLE\x20—\x20sales\x20NOT\x20submitted\x0a\x0a'+('Sale\x20\x22'+g['name']+'\x22\x20has\x20wip\x20=\x20\x22'+h+'\x22,\x20which\x20is\x20'+j+'.\x0a\x0a')+'Why\x20this\x20is\x20fatal:\x20the\x20WIP\x20path\x20is\x20stored\x20ON-CHAIN\x20and\x20every\x20customer\x20'+'(on\x20a\x20different\x20machine)\x20fetches\x20it\x20when\x20placing\x20an\x20order.\x20A\x20local\x20path\x20/\x20'+'localhost\x20/\x20LAN\x20URL\x20is\x20reachable\x20only\x20from\x20YOUR\x20machine\x20—\x20it\x20passes\x20the\x20'+'merchant-side\x20set-time\x20verification\x20but\x20makes\x20order_new\x20abort\x20100%\x20for\x20customers.\x0a\x0a'+'Fix:\x20deploy\x20the\x20.wip\x20file\x20to\x20a\x20publicly\x20reachable\x20endpoint,\x20then\x20re-run\x20with\x20'+'sale.wip\x20=\x20\x22<public\x20URL>\x22\x20(e.g.\x20GitHub\x20Pages,\x20IPFS\x20gateway,\x20or\x20your\x20own\x20website).\x0a'+'\x20\x20•\x20GitHub\x20Pages:\x20https://<user>.github.io/<repo>/<file>.wip\x0a'+'\x20\x20•\x20IPFS:\x20\x20\x20\x20\x20\x20\x20\x20https://ipfs.io/ipfs/<CID>\x20\x20(or\x20ipfs://<CID>)\x0a'+'\x20\x20•\x20Your\x20site:\x20\x20\x20https://<your-domain>/<path>/<file>.wip\x0a'+'Alternatively,\x20set\x20sale.wip\x20=\x20\x22\x22\x20(empty)\x20to\x20SKIP\x20WIP\x20verification\x20—\x20'+'TESTING\x20ONLY,\x20not\x20recommended\x20for\x20production.';return{'content':[{'type':'text','text':k}],'structuredContent':{'result':{'type':'error','error':'Sale\x20\x22'+g['name']+'\x22\x20wip\x20is\x20'+j+':\x20'+h+'.\x20Local\x20WIP\x20paths\x20are\x20unreachable\x20by\x20customers\x20and\x20abort\x20order_new\x20100%.','error_code':'wip_not_network_deployed','retryable':!![],'recovery_hint':'Deploy\x20the\x20.wip\x20file\x20to\x20a\x20public\x20endpoint\x20(GitHub\x20Pages\x20/\x20IPFS\x20/\x20your\x20own\x20website)\x20'+'and\x20set\x20sale.wip\x20to\x20the\x20public\x20URL;\x20or\x20set\x20sale.wip\x20=\x20\x22\x22\x20(empty)\x20to\x20skip\x20WIP\x20'+'verification\x20(TESTING\x20ONLY).','related_object':g['name']},'message':'WIP\x20is\x20not\x20network-deployable\x20—\x20sales\x20not\x20submitted.\x20See\x20recovery_hint.'}};}return null;}export async function handleOnchainOperations(a){let b,c=[],d=[];async function f(g,h,k){if(!g)return;const l=new Set(['service','machine','progress','repository','arbitration','contact','treasury','reward','allocation','permission','guard','personal','demand','order','proof']);if(!l['has'](h))return;if(!k||typeof k!=='object'||'error'in k)return;if(!k['digest'])return;try{const m=LocalProject['Instance'](),n=await m['getProjectByPrefix'](g);if(!n){console['warn']('[autoAddToProject]\x20Project\x20with\x20prefix\x20\x27'+g+'\x27\x20not\x20found\x20—\x20object\x20not\x20auto-associated.\x20Create\x20the\x20project\x20first\x20via\x20project_operation\x20action=\x27create_project\x27.');return;}const o=ResponseData(k),p=o['filter'](q=>q['change']==='created'&&q['object']);for(const q of p){const r=!!(q['type_raw']&&q['type_raw']['includes']('service::Service'));await m['addObject'](n['id'],{'objectAddress':q['object'],'objectType':q['type_raw'],'role':r?'core':'reference'});}if(h==='service'){const s=p['find'](t=>t['type_raw']&&t['type_raw']['includes']('service::Service'));s&&s['object']&&await m['updateProject'](n['id'],{'serviceAddress':s['object']})['catch'](()=>{});}}catch{}}try{if(typeof a==='object'&&a!==null&&'description'in a&&!('operation_type'in a)){const r=a['description'],s=typeof r==='string'&&(r['includes']('operation_type')||r['includes']('data'));if(s)throw new Error('Invalid\x20parameter\x20structure.\x20Parameters\x20should\x20NOT\x20be\x20wrapped\x20in\x20\x27description\x27\x20field.\x0a'+'Correct\x20format:\x20{\x20operation_type:\x20\x27...\x27,\x20data:\x20{...}\x20}\x0a'+'Incorrect\x20format:\x20{\x20description:\x20\x27{\x20operation_type:\x20...\x20}\x27\x20}');}b=strictParse(OnchainOperationsSchema,a,'onchain_operations\x20input');const g=getEnvConfig(b['env']);if(!g['referrer']){const t=readStoredReferrer();if(t)g['referrer']=t;}const h=g['client_schema_version'],k=g['schema_strict_mode'],l=h?checkClientSchemaCompatibility(h,{'mode':k?'strict':'warn'}):undefined,m=u=>({'operation_type':b['operation_type'],'data':u,'pre_warnings':[...c,...d]['length']?[...c,...d]:undefined,'schema_check':l}),n=g['project'];if(isProjectServiceEnabled()&&'data'in b&&b['data']){const u=a306b({'operation_type':b['operation_type'],'data':b['data'],'projectPrefix':n});b['data']=u['data'],d=u['warnings']??[];}if(!g['account']&&n)try{const v=await LocalProject['Instance']()['getProjectByPrefix'](n);v?.['defaultAccount']&&(g['account']=v['defaultAccount']);}catch{}delete g['confirmed'],delete g['user_intent_phrases'],delete g['project'],delete g['client_schema_version'],delete g['schema_strict_mode'];const o=getSkillsHintForOnchain(b['operation_type'],b['data']);o&&c['push'](o);const p=getProjectSkillsHint();p&&c['push'](p);switch(b['operation_type']){case'service':{const w=b['data'],x=await detectServiceGuardCircularDependency(w);if(x)return x;const y=checkSalesWipNetworkDeployment(w,g,c);if(y)return y;const z=await prepareFundOperation(w,'service',g?.['network']);if(z['blockingErrors']['length']>0x0)return buildFundBlockResult(z,'service');c['push'](...z['warnings']);if(z['confirmation']){c['push'](z['confirmation']['message']);const J=a306c(z['confirmation']);if(J)c['push'](J);}const A=w?.['order_allocators'];if(A&&typeof A==='object'){const K=Array['isArray'](A['allocators'])?A['allocators']:[];for(let L=0x0;L<K['length'];L++){const M=K[L],N=Array['isArray'](M?.['sharing'])?M['sharing']:[];if(N['length']<=0x1)continue;const O=new Map();for(let P=0x0;P<N['length'];P++){const Q=N[P]?.['who'];let R='';if(typeof Q==='string')R=Q;else{if(Q&&typeof Q==='object'){if(Q['Entity']&&typeof Q['Entity']==='object')R='Entity:'+(Q['Entity']['name_or_address']??'');else{if(Q['Signer'])R='Signer';else Q['GuardIdentifier']!==undefined?R='Guard:'+Q['GuardIdentifier']:R=JSON['stringify'](Q);}}}if(!R)continue;const S=O['get'](R)??0x0;O['set'](R,S+0x1);}for(const [T,U]of O){U>0x1&&c['push']('DUPLICATE\x20SHARING\x20ENTITY:\x20Allocator['+L+']\x20has\x20entity\x20\x22'+T+'\x22\x20appearing\x20'+U+'\x20times\x20'+'in\x20the\x20sharing\x20array.\x20This\x20is\x20likely\x20a\x20configuration\x20error\x20—\x20each\x20entity\x20should\x20appear\x20'+('at\x20most\x20once\x20per\x20allocator.\x20Total\x20sharing:\x20'+U*0x64+'%\x20to\x20the\x20same\x20entity.\x20')+'If\x20intentional,\x20ignore\x20this\x20warning.');}}}const B=new CallService(b['data']);let C;try{C=b['submission']?await B['call_with_submission'](g,await transformSubmission(b['submission'])):await B['call'](g);}catch(V){const W=V['message']??String(V);if(/not found|GetObjectExisted|resolve|LocalMark|failed to resolve/i['test'](W)){const X=typeof w?.['object']==='object'&&w?.['object']!==null?w['object']['permission']:undefined;throw new Error('DEPENDENCY\x20RESOLUTION\x20FAILED:\x20One\x20or\x20more\x20referenced\x20objects\x20could\x20not\x20be\x20resolved.\x0a'+('Original\x20error:\x20'+W+'\x0a')+'Common\x20causes:\x0a'+'\x20\x201.\x20Object\x20name\x20typo\x20—\x20check\x20spelling\x20in\x20LocalMark\x0a'+'\x20\x202.\x20Object\x20not\x20yet\x20created\x20—\x20create\x20dependencies\x20first\x0a'+'\x20\x203.\x20Object\x20on\x20different\x20network\x20—\x20check\x20env.network\x0a'+('Referenced\x20objects\x20in\x20this\x20call:\x20machine='+(w?.['machine']??'<none>')+',\x20')+('buy_guard='+(w?.['buy_guard']??'<none>')+',\x20')+('permission='+(X??'<inline/new>')+',\x20')+('arbitrations='+(Array['isArray'](w?.['arbitrations'])?w['arbitrations']['length']+'\x20item(s)':'<none>')));}throw V;}const D=w?.['publish']?'publish\x20service':w?.['bPublished']!==undefined?'modify\x20service':'create\x20service',E=w?.['object']!=null&&typeof w['object']==='object',F=w?.['compensation_fund_add']!=null;E&&!F&&c['push']('Service.compensation_fund\x20balance\x20is\x200\x20—\x20no\x20refund\x20protection\x20for\x20buyers.\x20'+'If\x20buyers\x20need\x20refund\x20protection,\x20call\x20service.compensation_fund_add\x20with\x20a\x20Coin<T>\x20'+'to\x20deposit.\x20Without\x20deposit,\x20arbitration\x20rulings\x20cannot\x20withdraw\x20compensation\x20'+'from\x20this\x20Service.\x20(Note:\x20some\x20industries\x20like\x20freelance\x20do\x20not\x20require\x20this;\x20'+'the\x20evaluation\x20engine\x20will\x20check\x20industry-specific\x20requirements.)');const G=w?.['publish']===!![],H=Array['isArray'](w?.['arbitrations'])&&w['arbitrations']['length']>0x0;if(G&&!H&&F)throw new Error('HARD\x20PRE-CHECK\x20FAILED:\x20Cannot\x20publish\x20Service\x20with\x20compensation_fund\x20>\x200\x20but\x20no\x20Arbitration\x20bound.\x0a'+'Contract\x20(service.move:494):\x20assert!(arbitration_count\x20>\x200,\x20E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND).\x0a'+'The\x20transaction\x20WILL\x20ABORT\x20on-chain\x20if\x20you\x20proceed.\x0a'+'Fix:\x20(1)\x20Create\x20an\x20Arbitration\x20object\x20first\x20(onchain_operations\x20with\x20operation_type=\x27arbitration\x27).\x0a'+'\x20\x20\x20\x20\x20(2)\x20Set\x20data.arbitrations=[<arbitration_name_or_id>]\x20in\x20this\x20same\x20call.\x0a'+'\x20\x20\x20\x20\x20(3)\x20Then\x20call\x20publish=true.\x0a'+'Note:\x20After\x20publish,\x20arbitrations\x20can\x20still\x20be\x20ADDED\x20(but\x20not\x20removed\x20without\x20pause+lock).');G&&!H&&!F&&c['push']('WARNING:\x20Publishing\x20Service\x20without\x20arbitrations.\x20If\x20compensation_fund\x20was\x20'+'deposited\x20in\x20a\x20prior\x20call,\x20the\x20contract\x20(service.move:494)\x20WILL\x20ABORT\x20with\x20'+'E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND.\x20If\x20compensation_fund\x20is\x200,\x20'+'publish\x20will\x20succeed\x20but\x20buyers\x20have\x20no\x20dispute\x20resolution\x20path.\x20'+'Recommended:\x20bind\x20arbitrations\x20before\x20publish.');!G&&F&&!H&&c['push']('WARNING:\x20Depositing\x20compensation_fund\x20on\x20a\x20Service\x20without\x20arbitrations\x20bound.\x20'+'If\x20this\x20Service\x20is\x20already\x20published,\x20arbitration\x20rulings\x20will\x20not\x20be\x20able\x20to\x20'+'withdraw\x20compensation\x20from\x20this\x20Service.\x20Recommended:\x20bind\x20arbitrations\x20first,\x20'+'then\x20deposit\x20compensation_fund.');const I=handleCallResult(C,withHarness(m(w),'service',D));return f(n,b['operation_type'],C)['catch'](()=>{}),I;}case'machine':{if(b['data']['node']&&typeof b['data']['node']==='object'&&'json_or_markdown_file'in b['data']['node']){const a4=b['data']['node']['json_or_markdown_file'];let a5;try{const a7=resolve(a4);a5=readFileSync(a7,'utf-8');}catch(a8){throw new Error('Failed\x20to\x20read\x20file\x20\x27'+a4+'\x27:\x20'+a8['message']);}const a6=parseMachineNodesFromText(a5);if(!a6['success']){const a9=a306a(a6['errors']);throw new Error('Machine\x20node\x20validation\x20failed\x20for\x20file\x20\x27'+a4+'\x27:\x0a\x0a'+a9);}if(!a6['data'])throw new Error('No\x20nodes\x20found\x20in\x20file\x20\x27'+a4+'\x27');b['data']['node']={'op':'set','nodes':a6['data'],'bReplace':!![]};}const Y=b['data'],Z=await checkMachinePermissionBeforePublish(Y,g);Z&&c['push'](Z);const a0=Y?.['node']?.['nodes']??Y?.['node'];if(Array['isArray'](a0)){const aa=/^(dispute|disputed|arbitration|arb_|arb\.|resolve_dispute|start_arbitration|open_dispute)/i;for(const ab of a0){const ac=typeof ab==='object'?ab?.['name']:'';typeof ac==='string'&&aa['test'](ac)&&c['push']('ARBITRATION\x20SEPARATION\x20WARNING:\x20Machine\x20node\x20\x22'+ac+'\x22\x20appears\x20to\x20be\x20an\x20arbitration-related\x20node.\x0a'+'CORE\x20PRINCIPLE:\x20A\x20merchant\x20cannot\x20handle\x20disputes\x20fairly\x20—\x20they\x20would\x20be\x20\x27both\x20player\x20and\x20referee\x27.\x0a'+'The\x20WoWok\x20smart\x20contract\x20design\x20makes\x20Arbitration\x20a\x20completely\x20separate\x20object:\x0a'+'\x20\x20-\x20Arbitration\x20has\x20its\x20own\x20Permission,\x20voting_guard,\x20usage_guard,\x20and\x20balance\x0a'+'\x20\x20-\x20Arb\x20instances\x20have\x20a\x207-state\x20lifecycle\x20managed\x20by\x20Arbitration,\x20not\x20by\x20Machine\x0a'+'\x20\x20-\x20The\x20Order\x20object\x20is\x20the\x20bridge:\x20it\x20has\x20\x27progress\x27\x20(Machine)\x20and\x20\x27dispute\x27\x20(Arb\x20list)\x20fields\x0a'+'\x20\x20-\x20When\x20Arb\x20rules,\x20it\x20calls\x20order::compensate()\x20—\x20the\x20ONLY\x20connection\x20to\x20the\x20business\x20flow\x0a\x0a'+'CORRECT\x20PATTERN:\x0a'+'\x20\x20-\x20Machine:\x20business\x20states\x20only\x20(ordered\x20->\x20shipped\x20->\x20delivered\x20->\x20completed)\x0a'+'\x20\x20-\x20Arbitration:\x20separate\x20object\x20with\x20its\x20own\x20Permission\x20(NOT\x20shared\x20with\x20Service)\x0a'+'\x20\x20-\x20Arb:\x207-state\x20lifecycle\x20(Principal_confirming\x20->\x20Arbitrator_confirming\x20->\x20Voting\x20->\x20Arbitrated\x20->\x20Objectionable\x20->\x20Finished\x20->\x20Withdrawn)\x0a'+'\x20\x20-\x20R-M1-11:\x20NEVER\x20name\x20nodes\x20\x27refunded\x27/\x27disputed\x27/\x27arb\x27/\x27refund\x27\x20—\x20use\x20business\x20states\x20(\x27cancelled\x27/\x27returned\x27)\x20for\x20dispute\x20OUTCOMES;\x20refunds\x20route\x20via\x20Allocator\x20triggered\x20by\x20those\x20states,\x20disputes\x20via\x20the\x20separate\x20Arbitration\x20object\x0a\x0a'+'If\x20this\x20node\x20name\x20is\x20a\x20legitimate\x20business\x20state\x20(not\x20arbitration),\x20ignore\x20this\x20warning.');}}const a1=new CallMachine(b['data']),a2=b['submission']?await a1['call_with_submission'](g,await transformSubmission(b['submission'])):await a1['call'](g),a3=handleCallResult(a2,m(b['data']));return f(n,b['operation_type'],a2)['catch'](()=>{}),a3;}case'progress':{b['data']?.['operate']&&c['push']('Progress\x20routing\x20hint:\x20if\x20this\x20Progress\x20is\x20bound\x20to\x20an\x20Order\x20and\x20the\x20target\x20'+'Forward\x20uses\x20namedOperator=\x22\x22\x20(empty\x20string\x20=\x20OrderHolder),\x20use\x20'+'order.progress\x20(NOT\x20progress.operate).\x20Direct\x20progress::next\x20fails\x20with\x20'+'Permission\x20denied\x20for\x20OrderHolder\x20forwards.\x20Use\x20progress.operate\x20only\x20for\x20'+'non-empty\x20namedOperator\x20or\x20permissionIndex-only\x20forwards.');const ad=new CallProgress(b['data']),ae=b['submission']?await ad['call_with_submission'](g,await transformSubmission(b['submission'])):await ad['call'](g);if(!b['submission']&&ae&&typeof ae==='object'&&'submission'in ae){const ag=ae['submission'];if(Array['isArray'](ag)&&ag['length']>0x0){const ah=ag[0x0]?.['guard'];if(ah){const ai={'operation':'progress_next','network':g?.['network'],'signer':g?.['account'],'progress_address':b['data']?.['object'],'order_address':b['data']?.['task']},aj=await generateGuardSubmissionPrompt(ah,ai);aj&&c['push'](formatSubmissionPrompt(aj));}}}if(ae&&typeof ae==='object'&&'digest'in ae&&ae?.['effects']?.['status']?.['status']==='success')try{const ak=b['data']?.['object'];let al;typeof ak==='string'&&(ak['startsWith']('0x')?al=ak:al=await LocalMark['Instance']()['get_address'](ak)??undefined);if(al){const am=await query_objects({'objects':[al],'no_cache':!![],'network':g?.['network']}),an=am?.['objects']?.[0x0];if(an?.['type']==='Progress'){const ao=an['current']??'<unknown>',ap=Array['isArray'](an['session'])?an['session']['length']:0x0,aq=an['machine'],ar=['PROGRESS\x20PREVIEW:','\x20\x20•\x20current\x20node:\x20\x22'+ao+'\x22','\x20\x20•\x20history\x20count:\x20'+ap+'\x20session(s)'];aq&&ar['push']('\x20\x20•\x20machine:\x20'+aq),c['push'](ar['join']('\x0a'));}}}catch{}const af=handleCallResult(ae,m(b['data']));return f(n,b['operation_type'],ae)['catch'](()=>{}),af;}case'repository':{const as=new CallRepository(b['data']),at=b['submission']?await as['call_with_submission'](g,await transformSubmission(b['submission'])):await as['call'](g),au=handleCallResult(at,m(b['data']));return f(n,b['operation_type'],at)['catch'](()=>{}),au;}case'arbitration':{const av=await prepareFundOperation(b['data'],'arbitration',g?.['network']);if(av['blockingErrors']['length']>0x0)return buildFundBlockResult(av,'arbitration');c['push'](...av['warnings']);if(av['confirmation']){c['push'](av['confirmation']['message']);const az=a306c(av['confirmation']);if(az)c['push'](az);}const aw=new CallArbitration(b['data']),ax=b['submission']?await aw['call_with_submission'](g,await transformSubmission(b['submission'])):await aw['call'](g),ay=handleCallResult(ax,m(b['data']));return f(n,b['operation_type'],ax)['catch'](()=>{}),ay;}case'contact':{const aA=new CallContact(b['data']),aB=b['submission']?await aA['call_with_submission'](g,await transformSubmission(b['submission'])):await aA['call'](g),aC=handleCallResult(aB,m(b['data']));return f(n,b['operation_type'],aB)['catch'](()=>{}),aC;}case'treasury':{const aD=await prepareFundOperation(b['data'],'treasury',g?.['network']);if(aD['blockingErrors']['length']>0x0)return buildFundBlockResult(aD,'treasury');c['push'](...aD['warnings']);if(aD['confirmation']){c['push'](aD['confirmation']['message']);const aH=a306c(aD['confirmation']);if(aH)c['push'](aH);}const aE=new CallTreasury(b['data']),aF=b['submission']?await aE['call_with_submission'](g,await transformSubmission(b['submission'])):await aE['call'](g),aG=handleCallResult(aF,m(b['data']));return f(n,b['operation_type'],aF)['catch'](()=>{}),aG;}case'reward':{const aI=await prepareFundOperation(b['data'],'reward',g?.['network']);if(aI['blockingErrors']['length']>0x0)return buildFundBlockResult(aI,'reward');c['push'](...aI['warnings']);if(aI['confirmation']){c['push'](aI['confirmation']['message']);const aN=a306c(aI['confirmation']);if(aN)c['push'](aN);}const aJ=transformRewardInput(b['data']),aK=new CallReward(aJ),aL=b['submission']?await aK['call_with_submission'](g,await transformSubmission(b['submission'])):await aK['call'](g),aM=handleCallResult(aL,m(b['data']));return f(n,b['operation_type'],aL)['catch'](()=>{}),aM;}case'allocation':{const aO=await prepareFundOperation(b['data'],'allocation',g?.['network']);if(aO['blockingErrors']['length']>0x0)return buildFundBlockResult(aO,'allocation');c['push'](...aO['warnings']);if(aO['confirmation']){c['push'](aO['confirmation']['message']);const aT=a306c(aO['confirmation']);if(aT)c['push'](aT);}const aP=new CallAllocation(b['data']),aQ=b['submission']?await aP['call_with_submission'](g,await transformSubmission(b['submission'])):await aP['call'](g),aR=b['data'];if(aR?.['alloc_by_guard']){const aU=ResponseData(aQ)['filter'](aV=>aV?.['type']==='Payment'&&aV?.['change']==='created');if(aU['length']>0x0){const aV=aU['map'](aW=>aW['object'])['join'](',\x20');try{const aW=await query_objects({'objects':aU['map'](aZ=>aZ['object']),'no_cache':!![],'network':g?.['network']}),aX=[];let aY=BigInt(0x0);for(const aZ of aW?.['objects']||[]){if(aZ?.['type']==='Payment'&&aZ?.['record']){for(const b0 of aZ['record']){const b1=formatRecipientLabel(b0['recipient']),b2=typeof b0['amount']==='string'?b0['amount']:String(b0['amount']),b3=BigInt(b2);aY+=b3,aX['push']('\x20\x20•\x20'+b1+':\x20'+formatMistAmount(b3));}aZ['object']&&aX['push']('\x20\x20•\x20Payment\x20object:\x20'+aZ['object']);}}if(aX['length']>0x0){aX['unshift']('DISTRIBUTION\x20DETAILS\x20(alloc_by_guard):'),aX['push']('\x20\x20─────────────────','\x20\x20•\x20Total\x20distributed:\x20'+formatMistAmount(aY));const b4=aW?.['objects']?.['some'](b5=>b5?.['type']==='Payment'&&b5?.['info']?.['for_object']);b4&&aX['push']('','ESCROW\x20MODE:\x20Funds\x20are\x20held\x20in\x20escrow\x20(Payment.for_object\x20points\x20to\x20an\x20Order).\x20'+'The\x20Order\x20owner\x20must\x20call\x20order_claim\x20(or\x20service_order_claim)\x20to\x20actually\x20receive\x20the\x20funds.\x20'+'This\x20happens\x20when\x20the\x20Guard\x27s\x20sharing\x20config\x20uses\x20{\x20GuardIdentifier:\x200\x20}.'),c['push'](aX['join']('\x0a'));}}catch{c['push']('alloc_by_guard\x20created\x20Payment\x20object(s)\x20['+aV+'].\x20'+'Query\x20these\x20Payment\x20objects\x20to\x20see\x20the\x20distribution\x20details\x20and\x20check\x20for_object\x20for\x20escrow\x20mode.');}}}const aS=handleCallResult(aQ,m(b['data']));return f(n,b['operation_type'],aQ)['catch'](()=>{}),aS;}case'permission':{const b5=b['operation_type'],b6=handlePermissionOperations(b['data'],g,m);return b6&&typeof b6==='object'&&'then'in b6&&b6['then'](b7=>{b7?.['structuredContent']?.['result']&&f(n,b5,b7['structuredContent']['result'])['catch'](()=>{});})['catch'](()=>{}),b6;}case'guard':{const b7=b['data'];if(b7['root']?.['type']==='file'){const bb=resolve(b7['root']['file_path']);let bc;try{bc=readFileSync(bb,'utf-8');}catch(bf){throw new Error('Failed\x20to\x20read\x20Guard\x20definition\x20file\x20\x27'+b7['root']['file_path']+'\x27:\x20'+bf['message']);}const bd=parseGuardFile(bc,b7['root']['format']);if(!bd['success']){const bg=formatGuardParseErrors(bd['errors']);throw new Error('Guard\x20validation\x20failed\x20for\x20file\x20\x27'+b7['root']['file_path']+'\x27:\x0a\x0a'+bg);}const be=bd['data'];b7['root']={'type':'node','node':be['root']},be['table']!==undefined&&b7['table']===undefined&&(b7['table']=be['table']),be['description']!==undefined&&b7['description']===undefined&&(b7['description']=be['description']),be['rely']!==undefined&&b7['rely']===undefined&&(b7['rely']=be['rely']),be['namedNew']!==undefined&&b7['namedNew']===undefined&&(b7['namedNew']=be['namedNew']);}if(b7['root']&&typeof b7['root']==='object'){const bh=b7['root'];bh['type']==='node'&&bh['node']&&(b7['root']=bh['node']);}if(!b7['table']||b7['table']['length']===0x0)throw new Error('Guard\x20\x27table\x27\x20field\x20is\x20required\x20and\x20cannot\x20be\x20empty');if(!b7['root'])throw new Error('Guard\x20\x27root\x27\x20field\x20is\x20required');const b8=new CallGuard(b7),b9=await b8['call'](g);if(b9&&typeof b9==='object'&&'digest'in b9&&b9?.['effects']?.['status']?.['status']==='success')try{const bi=b7['root']?.['type']??'<unknown>',bj=Array['isArray'](b7['table'])?b7['table']:[],bk=bj['length'],bl=bj['filter'](bq=>bq?.['b_submission']===!![])['length'],bm=b7['rely']?.['guards'],bn=Array['isArray'](bm)?bm['length']:0x0,bo=b7['rely']?.['logic_or']===!![]?'OR':b7['rely']?.['logic_or']===![]?'AND':'none',bp=['GUARD\x20LOGIC\x20SUMMARY:','\x20\x20•\x20root\x20type:\x20'+bi,'\x20\x20•\x20table\x20entries:\x20'+bk+'\x20('+bl+'\x20require\x20runtime\x20submission)'];bn>0x0&&bp['push']('\x20\x20•\x20relies\x20on:\x20'+bn+'\x20guard(s)\x20(mode:\x20'+bo+')');if(b7['description']){const bq=String(b7['description'])['slice'](0x0,0x50);bp['push']('\x20\x20•\x20description:\x20\x22'+bq+'\x22');}c['push'](bp['join']('\x0a'));}catch{}const ba=handleCallResult(b9,m(b['data']));return f(n,b['operation_type'],b9)['catch'](()=>{}),ba;}case'personal':{const br=transformPersonalInput(b['data']),bs=new CallPersonal(br),bt=await bs['call'](g),bu=handleCallResult(bt,m(b['data']));return f(n,b['operation_type'],bt)['catch'](()=>{}),bu;}case'payment':{const bv=await prepareFundOperation(b['data'],'payment',g?.['network']);if(bv['blockingErrors']['length']>0x0)return buildFundBlockResult(bv,'payment');c['push'](...bv['warnings']);if(bv['confirmation']){c['push'](bv['confirmation']['message']);const bA=a306c(bv['confirmation']);if(bA)c['push'](bA);}const bw=b['data'];if(bw?.['receive']===!![])c['push']('RECEIVE\x20MODE\x20(order_claim):\x20You\x20are\x20unwrapping\x20a\x20CoinWrapper\x20to\x20your\x20wallet.\x20'+'This\x20is\x20the\x20final\x20step\x20of\x20the\x20escrow\x20flow:\x0a'+'\x20\x201.\x20Allocation\x27s\x20alloc_by_guard\x20created\x20a\x20Payment\x20object\x20with\x20your\x20address\x20as\x20a\x20recipient\x0a'+'\x20\x202.\x20The\x20Payment\x27s\x20revenue\x20split\x20transferred\x20a\x20CoinWrapper\x20to\x20your\x20wallet\x20(owned\x20but\x20not\x20spendable)\x0a'+'\x20\x203.\x20THIS\x20operation\x20unwraps\x20the\x20CoinWrapper\x20via\x20payment::unwrap_to_myself,\x20deleting\x20the\x20'+'CoinWrapper\x20and\x20transferring\x20the\x20underlying\x20coin\x20to\x20tx_context::sender\x0a'+'Requirements:\x0a'+'\x20\x20-\x20You\x20MUST\x20be\x20the\x20CoinWrapper\x27s\x20owner\x20(the\x20recipient\x20specified\x20in\x20the\x20Allocation)\x0a'+'\x20\x20-\x20type_parameter\x20is\x20OPTIONAL:\x20when\x20omitted\x20it\x20is\x20auto-derived\x20from\x20the\x20CoinWrapper\x27s\x20'+'own\x20on-chain\x20type\x20(the\x20inner\x20T\x20of\x20CoinWrapper<T>)\x0a'+'\x20\x20-\x20object\x20can\x20be\x20a\x20CoinWrapper\x20ID\x20(0x...)\x20or\x20a\x20local\x20mark\x20name\x0a'+'To\x20find\x20received\x20CoinWrappers:\x20call\x20query_toolkit\x20with\x20query_type=\x27onchain_received\x27\x20'+'and\x20type=\x27CoinWrapper\x27\x20for\x20your\x20account.\x0a'+'After\x20success:\x20verify\x20your\x20balance\x20increased\x20via\x20account_balance\x20query.');else bw?.['revenue']&&c['push']('CREATE\x20MODE:\x20Creating\x20a\x20new\x20Payment\x20object.\x20Payments\x20are\x20IMMUTABLE\x20after\x20creation\x20—\x20'+'they\x20cannot\x20be\x20modified.\x20The\x20\x27revenue\x27\x20array\x20defines\x20the\x20recipients\x20and\x20amounts;\x20'+'ensure\x20correctness\x20before\x20submitting.\x20The\x20\x27info.for_guard\x27\x20field\x20(if\x20set)\x20binds\x20this\x20'+'Payment\x20to\x20a\x20Guard\x20for\x20conditional\x20release\x20(common\x20in\x20escrow\x20workflows).');const bx=new CallPayment(b['data']),by=await bx['call'](g),bz=handleCallResult(by,m(b['data']));return f(n,b['operation_type'],by)['catch'](()=>{}),bz;}case'demand':{const bB=new CallDemand(b['data']),bC=b['submission']?await bB['call_with_submission'](g,await transformSubmission(b['submission'])):await bB['call'](g),bD=handleCallResult(bC,m(b['data']));return f(n,b['operation_type'],bC)['catch'](()=>{}),bD;}case'order':{b['data']?.['progress']&&(c['push']('Order\x20routing\x20hint:\x20order.progress\x20works\x20only\x20for\x20Forwards\x20with\x20'+'namedOperator=\x22\x22\x20(OrderHolder).\x20If\x20the\x20target\x20Forward\x20uses\x20a\x20'+'non-empty\x20namedOperator\x20or\x20permissionIndex-only,\x20use\x20progress.operate\x20'+'on\x20the\x20Progress\x20object\x20directly\x20instead.'),c['push']('Allocation\x20hint:\x20if\x20this\x20operation\x20advances\x20the\x20order\x20to\x20a\x20terminal\x20'+'state\x20(e.g.\x20Completed/Cancelled/Refunded),\x20funds\x20remain\x20in\x20the\x20'+'Allocation\x20object\x20and\x20are\x20NOT\x20auto-distributed.\x20To\x20release\x20funds,\x20'+'trigger\x20the\x20corresponding\x20Guard\x20verification\x20via\x20allocation\x20operation\x20'+'(the\x20Guard\x20bound\x20to\x20the\x20matching\x20Allocator\x20will\x20verify\x20and\x20distribute).'));const bE=new CallOrder(b['data']),bF=b['submission']?await bE['call_with_submission'](g,await transformSubmission(b['submission'])):await bE['call'](g),bG=handleCallResult(bF,m(b['data']));return f(n,b['operation_type'],bF)['catch'](()=>{}),bG;}case'gen_passport':{const bH=await gen_passport(g,b['guard'],b['info']),bI=handleCallResult(bH,m(b['data']));return f(n,b['operation_type'],bH)['catch'](()=>{}),bI;}case'proof':{const bJ=new CallProof(b['data']),bK=b['submission']?await bJ['call_with_submission'](g,await transformSubmission(b['submission'])):await bJ['call'](g),bL=handleCallResult(bK,m(b['data']));return f(n,b['operation_type'],bK)['catch'](()=>{}),bL;}case'gen_proof':{const bM=await gen_proof(g,b['proof'],b['server_pubkey'],b['server_signature'],b['proof_type'],b['description'],b['item_count'],b['about_address']),bN=handleCallResult(bM,m(b['data']));return f(n,b['operation_type'],bM)['catch'](()=>{}),bN;}}const q=b;throw new Error('Unknown\x20on-chain\x20operation\x20type:\x20'+String(q['operation_type']));}catch(bO){const bP=bO instanceof Error?bO['message']:String(bO),bQ=b?.['operation_type'],bR=b&&'data'in b?b['data']:undefined;return handleCallResult({'error':bP},bQ?{'operation_type':bQ,'data':bR}:undefined);}}
|