@wowok/agent-mcp 3.3.3 → 3.3.6
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/chain-semantics/eval-order.d.ts +17 -0
- package/dist/chain-semantics/eval-order.js +1 -0
- package/dist/chain-semantics/freeze-map.js +1 -1
- package/dist/chain-semantics/fund-flow.js +1 -1
- package/dist/chain-semantics/index.d.ts +1 -0
- package/dist/chain-semantics/index.js +1 -1
- package/dist/chain-semantics/object-graph.js +1 -1
- package/dist/composition/audit.js +1 -1
- package/dist/composition/compile.d.ts +4 -1
- package/dist/composition/compile.js +1 -1
- package/dist/data/api/api.spec.d.ts +1 -0
- package/dist/data/api/api.spec.js +1 -0
- package/dist/data/api/cli.d.ts +1 -0
- package/dist/data/api/cli.js +1 -0
- package/dist/data/api/head.d.ts +16 -0
- package/dist/data/api/head.js +1 -0
- package/dist/data/api/head.spec.d.ts +1 -0
- package/dist/data/api/head.spec.js +1 -0
- package/dist/data/api/index.d.ts +2 -0
- package/dist/data/api/index.js +1 -0
- package/dist/data/api/match.d.ts +69 -0
- package/dist/data/api/match.js +1 -0
- package/dist/data/api/match.spec.d.ts +1 -0
- package/dist/data/api/match.spec.js +1 -0
- package/dist/data/api/server.d.ts +12 -0
- package/dist/data/api/server.js +1 -0
- package/dist/data/projection/cli.d.ts +1 -0
- package/dist/data/projection/cli.js +1 -0
- package/dist/data/projection/edges.d.ts +8 -0
- package/dist/data/projection/edges.js +1 -0
- package/dist/data/projection/edges.spec.d.ts +1 -0
- package/dist/data/projection/edges.spec.js +1 -0
- package/dist/data/projection/facets.d.ts +18 -0
- package/dist/data/projection/facets.js +1 -0
- package/dist/data/projection/facets.spec.d.ts +1 -0
- package/dist/data/projection/facets.spec.js +1 -0
- package/dist/data/projection/facts.d.ts +40 -0
- package/dist/data/projection/facts.js +1 -0
- package/dist/data/projection/index.d.ts +6 -0
- package/dist/data/projection/index.js +1 -0
- package/dist/data/projection/project.d.ts +10 -0
- package/dist/data/projection/project.js +1 -0
- package/dist/data/projection/projection.spec.d.ts +1 -0
- package/dist/data/projection/projection.spec.js +1 -0
- package/dist/data/projection/schema.d.ts +1 -0
- package/dist/data/projection/schema.js +1 -0
- package/dist/data/projection/store.d.ts +49 -0
- package/dist/data/projection/store.js +1 -0
- package/dist/data/projection/types.d.ts +137 -0
- package/dist/data/projection/types.js +1 -0
- package/dist/data/sync/cdc.d.ts +34 -0
- package/dist/data/sync/cdc.js +1 -0
- package/dist/data/sync/cdc.spec.d.ts +1 -0
- package/dist/data/sync/cdc.spec.js +1 -0
- package/dist/data/sync/graphql-source.d.ts +16 -0
- package/dist/data/sync/graphql-source.js +1 -0
- package/dist/data/sync/index.d.ts +5 -0
- package/dist/data/sync/index.js +1 -0
- package/dist/data/sync/reconciler.d.ts +14 -0
- package/dist/data/sync/reconciler.js +1 -0
- package/dist/data/sync/reconciler.spec.d.ts +1 -0
- package/dist/data/sync/reconciler.spec.js +1 -0
- package/dist/data/sync/schema.d.ts +1 -0
- package/dist/data/sync/schema.js +1 -0
- package/dist/data/sync/store.d.ts +19 -0
- package/dist/data/sync/store.js +1 -0
- package/dist/data/sync/sync.spec.d.ts +1 -0
- package/dist/data/sync/sync.spec.js +1 -0
- package/dist/data/sync/synchronizer.d.ts +10 -0
- package/dist/data/sync/synchronizer.js +1 -0
- package/dist/data/sync/types.d.ts +162 -0
- package/dist/data/sync/types.js +1 -0
- package/dist/evaluation/builtins/demand-match.js +1 -1
- package/dist/evaluation/builtins/graph-service.spec.js +1 -1
- package/dist/evaluation/capability.d.ts +1 -0
- package/dist/evaluation/engine.js +1 -1
- package/dist/evaluation/extract.d.ts +7 -1
- package/dist/evaluation/extract.js +1 -1
- package/dist/evaluation/match-policy.d.ts +118 -0
- package/dist/evaluation/match-policy.js +1 -0
- package/dist/evaluation/match-policy.spec.d.ts +1 -0
- package/dist/evaluation/match-policy.spec.js +1 -0
- package/dist/evaluation/node-game.d.ts +3 -0
- package/dist/evaluation/node-game.js +1 -1
- package/dist/experience/realtime-feedback.js +1 -1
- package/dist/graph/onchain/expand.js +1 -1
- package/dist/graph/onchain/exposure.js +1 -1
- package/dist/harness/recover.js +1 -1
- package/dist/knowledge/arbitration-ledger.js +1 -1
- package/dist/knowledge/baselines/rules/plan.json +16 -1
- package/dist/knowledge/builtin-templates.d.ts +1 -1
- package/dist/knowledge/builtin-templates.js +1 -1
- package/dist/knowledge/getting-started.js +1 -1
- package/dist/knowledge/guard-design-patterns.d.ts +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-ledger.js +1 -1
- package/dist/knowledge/guard-puzzle.js +1 -1
- package/dist/knowledge/guard-render.js +1 -1
- package/dist/knowledge/guard-risk.js +1 -1
- package/dist/knowledge/guard-templates.d.ts +1 -1
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/guard-translation.js +1 -1
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/jsonrpc-enum.d.ts +26 -10
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/projection.d.ts +54 -0
- package/dist/knowledge/projection.js +1 -0
- package/dist/knowledge/projection.spec.d.ts +1 -0
- package/dist/knowledge/projection.spec.js +1 -0
- package/dist/knowledge/recipient-constraint.d.ts +9 -0
- package/dist/knowledge/recipient-constraint.js +1 -1
- package/dist/knowledge/scenario-modes.d.ts +1 -0
- package/dist/knowledge/service-ledger.d.ts +1 -1
- package/dist/knowledge/service-ledger.js +1 -1
- package/dist/knowledge/template-loader.d.ts +1 -0
- package/dist/knowledge/template-loader.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/template-scanner.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/participation/node-action-advisor.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/object-panorama.js +1 -1
- package/dist/playbooks/service-build/participation-radar.js +1 -1
- package/dist/playbooks/service-build/relationship-profile.js +1 -1
- package/dist/playbooks/service-build/service-panorama.js +1 -1
- package/dist/playbooks/service-build/service-quote.js +1 -1
- package/dist/playbooks/service-build/service-quote.spec.js +1 -1
- package/dist/review/index.js +1 -1
- package/dist/role/profiles.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/call/allocation.js +1 -1
- package/dist/schema/call/base.d.ts +25 -0
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +1 -0
- package/dist/schema/call/error-codes.d.ts +1 -1
- package/dist/schema/call/error-codes.js +1 -1
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/order.d.ts +12 -0
- package/dist/schema/call/order.js +1 -1
- package/dist/schema/call/progress.js +1 -1
- package/dist/schema/call/proof.js +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.js +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/evaluation/index.d.ts +189 -0
- package/dist/schema/evaluation/index.js +1 -1
- package/dist/schema/local/index.d.ts +10 -0
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/operations.d.ts +4 -0
- package/dist/schema/query/bi.d.ts +8 -0
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.d.ts +147 -0
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +2 -1
- package/dist/schemas/bridge_operation.output.json +2 -1
- package/dist/schemas/evaluation_operation.output.json +384 -2
- package/dist/schemas/evaluation_operation.schema.json +202 -4
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/keeper_operation.output.json +1 -1
- package/dist/schemas/local_cache_operation.output.json +2 -1
- package/dist/schemas/local_history_operation.output.json +2 -1
- package/dist/schemas/local_info_operation.output.json +2 -1
- package/dist/schemas/local_mark_operation.output.json +2 -1
- package/dist/schemas/messenger_operation.output.json +1 -1
- package/dist/schemas/monitor_events.output.json +1 -1
- package/dist/schemas/monitor_subscription.output.json +1 -1
- package/dist/schemas/onchain_events.output.json +1 -1
- package/dist/schemas/onchain_operations.output.json +35 -4
- package/dist/schemas/onchain_operations.schema.json +687 -103
- package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
- package/dist/schemas/onchain_operations_gen_proof.schema.json +1 -1
- package/dist/schemas/onchain_operations_guard.schema.json +660 -94
- package/dist/schemas/onchain_operations_order.schema.json +19 -1
- package/dist/schemas/onchain_operations_progress.schema.json +2 -2
- package/dist/schemas/onchain_operations_service.schema.json +4 -4
- package/dist/schemas/onchain_table_data.output.json +2 -2
- package/dist/schemas/query_toolkit.output.json +316 -1
- package/dist/schemas/query_toolkit.schema.json +1 -1
- package/dist/schemas/wowok_buildin_info.output.json +259 -0
- package/dist/schemas/wowok_buildin_info.schema.json +121 -0
- package/dist/tools/build-fingerprint.d.ts +28 -0
- package/dist/tools/build-fingerprint.js +1 -0
- package/dist/tools/handlers/benchmark-migration.d.ts +4 -2
- package/dist/tools/handlers/benchmark-migration.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/evaluation.js +1 -1
- package/dist/tools/handlers/evaluation.spec.js +1 -1
- package/dist/tools/handlers/onchain.d.ts +7 -0
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/review-chain.d.ts +9 -13
- package/dist/tools/handlers/review-chain.js +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/registry/business.js +1 -1
- package/dist/tools/upgrade-check.d.ts +1 -0
- package/dist/tools/upgrade-check.js +1 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +7 -2
|
@@ -2206,6 +2206,265 @@
|
|
|
2206
2206
|
"result"
|
|
2207
2207
|
],
|
|
2208
2208
|
"additionalProperties": false
|
|
2209
|
+
},
|
|
2210
|
+
{
|
|
2211
|
+
"type": "object",
|
|
2212
|
+
"properties": {
|
|
2213
|
+
"info": {
|
|
2214
|
+
"type": "string",
|
|
2215
|
+
"const": "build_fingerprint"
|
|
2216
|
+
},
|
|
2217
|
+
"result": {
|
|
2218
|
+
"anyOf": [
|
|
2219
|
+
{
|
|
2220
|
+
"type": "object",
|
|
2221
|
+
"properties": {
|
|
2222
|
+
"fingerprint": {
|
|
2223
|
+
"type": "object",
|
|
2224
|
+
"properties": {
|
|
2225
|
+
"builtin_templates_version": {
|
|
2226
|
+
"type": "number",
|
|
2227
|
+
"description": "Builtin industry template catalog version compiled into this build — the primary identity key"
|
|
2228
|
+
},
|
|
2229
|
+
"git": {
|
|
2230
|
+
"type": "object",
|
|
2231
|
+
"properties": {
|
|
2232
|
+
"describe": {
|
|
2233
|
+
"anyOf": [
|
|
2234
|
+
{
|
|
2235
|
+
"type": "string"
|
|
2236
|
+
},
|
|
2237
|
+
{
|
|
2238
|
+
"type": "null"
|
|
2239
|
+
}
|
|
2240
|
+
],
|
|
2241
|
+
"description": "git describe --tags --always --dirty of the workspace the build was produced from (null outside a repo / no git)"
|
|
2242
|
+
},
|
|
2243
|
+
"branch": {
|
|
2244
|
+
"anyOf": [
|
|
2245
|
+
{
|
|
2246
|
+
"type": "string"
|
|
2247
|
+
},
|
|
2248
|
+
{
|
|
2249
|
+
"type": "null"
|
|
2250
|
+
}
|
|
2251
|
+
],
|
|
2252
|
+
"description": "Short branch name (null when detached/absent)"
|
|
2253
|
+
},
|
|
2254
|
+
"dirty": {
|
|
2255
|
+
"anyOf": [
|
|
2256
|
+
{
|
|
2257
|
+
"type": "boolean"
|
|
2258
|
+
},
|
|
2259
|
+
{
|
|
2260
|
+
"type": "null"
|
|
2261
|
+
}
|
|
2262
|
+
],
|
|
2263
|
+
"description": "Uncommitted changes present (null = undeterminable)"
|
|
2264
|
+
}
|
|
2265
|
+
},
|
|
2266
|
+
"required": [
|
|
2267
|
+
"describe",
|
|
2268
|
+
"branch",
|
|
2269
|
+
"dirty"
|
|
2270
|
+
],
|
|
2271
|
+
"additionalProperties": false,
|
|
2272
|
+
"description": "Git identity of the build workspace (best-effort, never throws)"
|
|
2273
|
+
},
|
|
2274
|
+
"mcp_dist_stale": {
|
|
2275
|
+
"anyOf": [
|
|
2276
|
+
{
|
|
2277
|
+
"type": "object",
|
|
2278
|
+
"properties": {
|
|
2279
|
+
"stale": {
|
|
2280
|
+
"type": "boolean"
|
|
2281
|
+
},
|
|
2282
|
+
"lag_minutes": {
|
|
2283
|
+
"type": "number"
|
|
2284
|
+
}
|
|
2285
|
+
},
|
|
2286
|
+
"required": [
|
|
2287
|
+
"stale",
|
|
2288
|
+
"lag_minutes"
|
|
2289
|
+
],
|
|
2290
|
+
"additionalProperties": false
|
|
2291
|
+
},
|
|
2292
|
+
{
|
|
2293
|
+
"type": "null"
|
|
2294
|
+
}
|
|
2295
|
+
],
|
|
2296
|
+
"description": "MCP workspace src newer than its dist (null = installed build, no src tree); runtime STATE, not identity — a rebuild between capture and compare is expected and never a skew"
|
|
2297
|
+
},
|
|
2298
|
+
"sdk_dist_stale": {
|
|
2299
|
+
"anyOf": [
|
|
2300
|
+
{
|
|
2301
|
+
"type": "object",
|
|
2302
|
+
"properties": {
|
|
2303
|
+
"stale": {
|
|
2304
|
+
"type": "boolean"
|
|
2305
|
+
},
|
|
2306
|
+
"lag_minutes": {
|
|
2307
|
+
"type": "number"
|
|
2308
|
+
}
|
|
2309
|
+
},
|
|
2310
|
+
"required": [
|
|
2311
|
+
"stale",
|
|
2312
|
+
"lag_minutes"
|
|
2313
|
+
],
|
|
2314
|
+
"additionalProperties": false
|
|
2315
|
+
},
|
|
2316
|
+
{
|
|
2317
|
+
"type": "null"
|
|
2318
|
+
}
|
|
2319
|
+
],
|
|
2320
|
+
"description": "SDK workspace src newer than its dist, same semantics (null = installed build)"
|
|
2321
|
+
},
|
|
2322
|
+
"captured_at": {
|
|
2323
|
+
"type": "string",
|
|
2324
|
+
"description": "ISO timestamp of the capture"
|
|
2325
|
+
}
|
|
2326
|
+
},
|
|
2327
|
+
"required": [
|
|
2328
|
+
"builtin_templates_version",
|
|
2329
|
+
"git",
|
|
2330
|
+
"mcp_dist_stale",
|
|
2331
|
+
"sdk_dist_stale",
|
|
2332
|
+
"captured_at"
|
|
2333
|
+
],
|
|
2334
|
+
"additionalProperties": false,
|
|
2335
|
+
"description": "Current build identity — record verbatim in the test-report header"
|
|
2336
|
+
},
|
|
2337
|
+
"chain_stamp": {
|
|
2338
|
+
"type": "object",
|
|
2339
|
+
"properties": {
|
|
2340
|
+
"network": {
|
|
2341
|
+
"anyOf": [
|
|
2342
|
+
{
|
|
2343
|
+
"type": "string"
|
|
2344
|
+
},
|
|
2345
|
+
{
|
|
2346
|
+
"type": "null"
|
|
2347
|
+
}
|
|
2348
|
+
]
|
|
2349
|
+
},
|
|
2350
|
+
"protocol_version": {
|
|
2351
|
+
"anyOf": [
|
|
2352
|
+
{
|
|
2353
|
+
"type": "string"
|
|
2354
|
+
},
|
|
2355
|
+
{
|
|
2356
|
+
"type": "null"
|
|
2357
|
+
}
|
|
2358
|
+
],
|
|
2359
|
+
"description": "Chain protocol version observed on the current network (null when the chain was unreachable)"
|
|
2360
|
+
},
|
|
2361
|
+
"system_state_version": {
|
|
2362
|
+
"anyOf": [
|
|
2363
|
+
{
|
|
2364
|
+
"type": "string"
|
|
2365
|
+
},
|
|
2366
|
+
{
|
|
2367
|
+
"type": "null"
|
|
2368
|
+
}
|
|
2369
|
+
],
|
|
2370
|
+
"description": "System state data-structure version observed (null when unreachable)"
|
|
2371
|
+
},
|
|
2372
|
+
"epoch": {
|
|
2373
|
+
"anyOf": [
|
|
2374
|
+
{
|
|
2375
|
+
"type": "string"
|
|
2376
|
+
},
|
|
2377
|
+
{
|
|
2378
|
+
"type": "null"
|
|
2379
|
+
}
|
|
2380
|
+
],
|
|
2381
|
+
"description": "Current epoch observed (null when unreachable)"
|
|
2382
|
+
},
|
|
2383
|
+
"fetched": {
|
|
2384
|
+
"type": "boolean",
|
|
2385
|
+
"description": "false when the chain was unreachable — the null fields then carry no meaning and must not be quoted"
|
|
2386
|
+
},
|
|
2387
|
+
"fetched_at": {
|
|
2388
|
+
"anyOf": [
|
|
2389
|
+
{
|
|
2390
|
+
"type": "string"
|
|
2391
|
+
},
|
|
2392
|
+
{
|
|
2393
|
+
"type": "null"
|
|
2394
|
+
}
|
|
2395
|
+
]
|
|
2396
|
+
}
|
|
2397
|
+
},
|
|
2398
|
+
"required": [
|
|
2399
|
+
"network",
|
|
2400
|
+
"protocol_version",
|
|
2401
|
+
"system_state_version",
|
|
2402
|
+
"epoch",
|
|
2403
|
+
"fetched",
|
|
2404
|
+
"fetched_at"
|
|
2405
|
+
],
|
|
2406
|
+
"additionalProperties": false,
|
|
2407
|
+
"description": "Chain attribution observed during capture (fetched:false when unreachable) — record alongside the fingerprint"
|
|
2408
|
+
}
|
|
2409
|
+
},
|
|
2410
|
+
"required": [
|
|
2411
|
+
"fingerprint",
|
|
2412
|
+
"chain_stamp"
|
|
2413
|
+
],
|
|
2414
|
+
"additionalProperties": false,
|
|
2415
|
+
"description": "CAPTURE result"
|
|
2416
|
+
},
|
|
2417
|
+
{
|
|
2418
|
+
"type": "object",
|
|
2419
|
+
"properties": {
|
|
2420
|
+
"comparison": {
|
|
2421
|
+
"type": "object",
|
|
2422
|
+
"properties": {
|
|
2423
|
+
"verdict": {
|
|
2424
|
+
"type": "string",
|
|
2425
|
+
"enum": [
|
|
2426
|
+
"current",
|
|
2427
|
+
"stale",
|
|
2428
|
+
"incomparable"
|
|
2429
|
+
],
|
|
2430
|
+
"description": "current: every comparable identity key matches; stale: at least one identity key differs from the current build; incomparable: the report recorded no fingerprint at all"
|
|
2431
|
+
},
|
|
2432
|
+
"downgrades_findings": {
|
|
2433
|
+
"type": "boolean",
|
|
2434
|
+
"description": "true when verdict is stale or incomparable — the report's findings must be marked \"pending retest\" instead of triaged against current code"
|
|
2435
|
+
},
|
|
2436
|
+
"skews": {
|
|
2437
|
+
"type": "array",
|
|
2438
|
+
"items": {
|
|
2439
|
+
"type": "string"
|
|
2440
|
+
},
|
|
2441
|
+
"description": "Human-readable diffs per mismatched identity key (empty when current)"
|
|
2442
|
+
}
|
|
2443
|
+
},
|
|
2444
|
+
"required": [
|
|
2445
|
+
"verdict",
|
|
2446
|
+
"downgrades_findings",
|
|
2447
|
+
"skews"
|
|
2448
|
+
],
|
|
2449
|
+
"additionalProperties": false,
|
|
2450
|
+
"description": "Report-vs-current verdict; downgrades_findings=true marks the report's findings \"pending retest\""
|
|
2451
|
+
}
|
|
2452
|
+
},
|
|
2453
|
+
"required": [
|
|
2454
|
+
"comparison"
|
|
2455
|
+
],
|
|
2456
|
+
"additionalProperties": false,
|
|
2457
|
+
"description": "COMPARE result"
|
|
2458
|
+
}
|
|
2459
|
+
],
|
|
2460
|
+
"description": "Build fingerprint result — capture (fingerprint + chain stamp) or compare (verdict)"
|
|
2461
|
+
}
|
|
2462
|
+
},
|
|
2463
|
+
"required": [
|
|
2464
|
+
"info",
|
|
2465
|
+
"result"
|
|
2466
|
+
],
|
|
2467
|
+
"additionalProperties": false
|
|
2209
2468
|
}
|
|
2210
2469
|
],
|
|
2211
2470
|
"description": "Protocol info result"
|
|
@@ -632,6 +632,127 @@
|
|
|
632
632
|
],
|
|
633
633
|
"additionalProperties": false,
|
|
634
634
|
"description": "Getting-started orientation for a freshly connected agent - what the companion WoWok Skills are, install/doctor/repair commands, best-effort local detection of installed skills, the ~20s cold-start window, and which sub-tools matter for common goals. Call this at conversation start when no skill guidance is loaded."
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
"type": "object",
|
|
638
|
+
"properties": {
|
|
639
|
+
"info": {
|
|
640
|
+
"type": "string",
|
|
641
|
+
"const": "build_fingerprint"
|
|
642
|
+
},
|
|
643
|
+
"compare": {
|
|
644
|
+
"type": "object",
|
|
645
|
+
"properties": {
|
|
646
|
+
"builtin_templates_version": {
|
|
647
|
+
"description": "Templates version the report recorded (from its capture)",
|
|
648
|
+
"type": "number"
|
|
649
|
+
},
|
|
650
|
+
"git": {
|
|
651
|
+
"description": "Git state the report recorded",
|
|
652
|
+
"anyOf": [
|
|
653
|
+
{
|
|
654
|
+
"type": "object",
|
|
655
|
+
"properties": {
|
|
656
|
+
"describe": {
|
|
657
|
+
"description": "git describe the report recorded",
|
|
658
|
+
"anyOf": [
|
|
659
|
+
{
|
|
660
|
+
"type": "string"
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
"type": "null"
|
|
664
|
+
}
|
|
665
|
+
]
|
|
666
|
+
}
|
|
667
|
+
},
|
|
668
|
+
"additionalProperties": false
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
"type": "null"
|
|
672
|
+
}
|
|
673
|
+
]
|
|
674
|
+
},
|
|
675
|
+
"chain_stamp": {
|
|
676
|
+
"description": "Chain stamp the report quoted (from upgrade_check)",
|
|
677
|
+
"anyOf": [
|
|
678
|
+
{
|
|
679
|
+
"type": "object",
|
|
680
|
+
"properties": {
|
|
681
|
+
"network": {
|
|
682
|
+
"anyOf": [
|
|
683
|
+
{
|
|
684
|
+
"type": "string"
|
|
685
|
+
},
|
|
686
|
+
{
|
|
687
|
+
"type": "null"
|
|
688
|
+
}
|
|
689
|
+
]
|
|
690
|
+
},
|
|
691
|
+
"protocol_version": {
|
|
692
|
+
"anyOf": [
|
|
693
|
+
{
|
|
694
|
+
"type": "string"
|
|
695
|
+
},
|
|
696
|
+
{
|
|
697
|
+
"type": "null"
|
|
698
|
+
}
|
|
699
|
+
],
|
|
700
|
+
"description": "Chain protocol version observed on the current network (null when the chain was unreachable)"
|
|
701
|
+
},
|
|
702
|
+
"system_state_version": {
|
|
703
|
+
"anyOf": [
|
|
704
|
+
{
|
|
705
|
+
"type": "string"
|
|
706
|
+
},
|
|
707
|
+
{
|
|
708
|
+
"type": "null"
|
|
709
|
+
}
|
|
710
|
+
],
|
|
711
|
+
"description": "System state data-structure version observed (null when unreachable)"
|
|
712
|
+
},
|
|
713
|
+
"epoch": {
|
|
714
|
+
"anyOf": [
|
|
715
|
+
{
|
|
716
|
+
"type": "string"
|
|
717
|
+
},
|
|
718
|
+
{
|
|
719
|
+
"type": "null"
|
|
720
|
+
}
|
|
721
|
+
],
|
|
722
|
+
"description": "Current epoch observed (null when unreachable)"
|
|
723
|
+
},
|
|
724
|
+
"fetched": {
|
|
725
|
+
"type": "boolean",
|
|
726
|
+
"description": "false when the chain was unreachable — the null fields then carry no meaning and must not be quoted"
|
|
727
|
+
},
|
|
728
|
+
"fetched_at": {
|
|
729
|
+
"anyOf": [
|
|
730
|
+
{
|
|
731
|
+
"type": "string"
|
|
732
|
+
},
|
|
733
|
+
{
|
|
734
|
+
"type": "null"
|
|
735
|
+
}
|
|
736
|
+
]
|
|
737
|
+
}
|
|
738
|
+
},
|
|
739
|
+
"additionalProperties": false
|
|
740
|
+
},
|
|
741
|
+
{
|
|
742
|
+
"type": "null"
|
|
743
|
+
}
|
|
744
|
+
]
|
|
745
|
+
}
|
|
746
|
+
},
|
|
747
|
+
"additionalProperties": false,
|
|
748
|
+
"description": "The fingerprint a test report recorded — supply it to COMPARE that report against the current build"
|
|
749
|
+
}
|
|
750
|
+
},
|
|
751
|
+
"required": [
|
|
752
|
+
"info"
|
|
753
|
+
],
|
|
754
|
+
"additionalProperties": false,
|
|
755
|
+
"description": "Build fingerprint - CAPTURE (no compare): returns the current build identity (templates version + git state + src/dist staleness + chain stamp) to record verbatim in a test-report header, one call, no LLM. COMPARE (with compare): diffs a report's recorded fingerprint against the current build - verdict stale or incomparable sets downgrades_findings=true, meaning the report's findings must be marked \"pending retest\" instead of triaged against current code (deployment-skew gate, yfd ruling 2026-10-24). Call CAPTURE at the start of a test round and COMPARE before triaging an AI test report."
|
|
635
756
|
}
|
|
636
757
|
]
|
|
637
758
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type WorkspaceStaleness, type ChainStamp } from "./upgrade-check.js";
|
|
2
|
+
export interface GitState {
|
|
3
|
+
describe: string | null;
|
|
4
|
+
branch: string | null;
|
|
5
|
+
dirty: boolean | null;
|
|
6
|
+
}
|
|
7
|
+
export interface BuildFingerprint {
|
|
8
|
+
builtin_templates_version: number;
|
|
9
|
+
git: GitState;
|
|
10
|
+
mcp_dist_stale: WorkspaceStaleness | null;
|
|
11
|
+
sdk_dist_stale: WorkspaceStaleness | null;
|
|
12
|
+
captured_at: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function captureGitState(): GitState;
|
|
15
|
+
export declare function currentBuildFingerprint(): BuildFingerprint;
|
|
16
|
+
export interface FingerprintComparison {
|
|
17
|
+
verdict: "current" | "stale" | "incomparable";
|
|
18
|
+
downgrades_findings: boolean;
|
|
19
|
+
skews: string[];
|
|
20
|
+
}
|
|
21
|
+
export type ReportedFingerprint = {
|
|
22
|
+
builtin_templates_version?: number;
|
|
23
|
+
git?: Partial<GitState> | null;
|
|
24
|
+
chain_stamp?: Pick<ChainStamp, "epoch" | "protocol_version" | "network"> | null;
|
|
25
|
+
};
|
|
26
|
+
export declare function compareReportFingerprint(report: ReportedFingerprint): FingerprintComparison;
|
|
27
|
+
export declare let currentChainEpoch: string | null;
|
|
28
|
+
export declare function setComparisonChainEpoch(epoch: string | null): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{execSync}from'child_process';import{join}from'path';import{fileURLToPath}from'url';import{dirname}from'path';import{BUILTIN_TEMPLATES_VERSION}from'../knowledge/builtin-templates.js';import{computeSrcDistStaleness,findSdkPackageDir}from'./upgrade-check.js';const __dirname=dirname(fileURLToPath(import.meta.url)),GIT_TIMEOUT_MS=0xbb8;function git(a){try{const b=execSync('git\x20'+a,{'timeout':GIT_TIMEOUT_MS,'stdio':['ignore','pipe','ignore']}),c=String(b)['trim']();return c['length']>0x0?c:null;}catch{return null;}}export function captureGitState(){const a=git('describe\x20--tags\x20--always\x20--dirty');if(a==null)return{'describe':null,'branch':null,'dirty':null};const b=a['endsWith']('-dirty')?!![]:git('status\x20--porcelain')!=null?![]:null;return{'describe':a,'branch':git('rev-parse\x20--abbrev-ref\x20HEAD'),'dirty':b};}export function currentBuildFingerprint(){return{'builtin_templates_version':BUILTIN_TEMPLATES_VERSION,'git':captureGitState(),'mcp_dist_stale':computeSrcDistStaleness(join(__dirname,'..','..','src'),join(__dirname,'..','..','dist'),{'srcExt':'.ts','distExt':'.js'}),'sdk_dist_stale':((()=>{const a=findSdkPackageDir();return a?computeSrcDistStaleness(join(a,'src'),join(a,'dist')):null;})()),'captured_at':new Date()['toISOString']()};}export function compareReportFingerprint(a){const b=[],c=currentBuildFingerprint();a['builtin_templates_version']!=null&&a['builtin_templates_version']!==BUILTIN_TEMPLATES_VERSION&&b['push']('templates\x20version:\x20report\x20'+a['builtin_templates_version']+'\x20vs\x20current\x20'+BUILTIN_TEMPLATES_VERSION+(a['builtin_templates_version']<BUILTIN_TEMPLATES_VERSION?'\x20(report\x20ran\x20on\x20an\x20older\x20template\x20set\x20—\x20fixed\x20defects\x20may\x20be\x20re-reported)':'\x20(current\x20code\x20is\x20BEHIND\x20the\x20report\x20—\x20checkout/rebuild\x20drift)'));const d=a['git']?.['describe']??null;d!=null&&d!==c['git']['describe']&&b['push']('git\x20state:\x20report\x20\x27'+d+'\x27\x20vs\x20current\x20\x27'+(c['git']['describe']??'(not\x20a\x20repo)')+'\x27');const e=a['chain_stamp']?.['epoch']??null;if(e!=null&¤tChainEpoch==null){}e!=null&¤tChainEpoch!=null&&e!==currentChainEpoch&&b['push']('chain\x20epoch:\x20report\x20'+e+'\x20vs\x20current\x20'+currentChainEpoch+'\x20(rolling\x20update\x20/\x20re-genesis\x20between\x20capture\x20and\x20review)');const f=a['builtin_templates_version']!=null||d!=null||e!=null;if(!f)return{'verdict':'incomparable','downgrades_findings':!![],'skews':['the\x20report\x20recorded\x20no\x20build\x20fingerprint\x20—\x20per\x20the\x20build_stamp\x20rule\x20it\x20cannot\x20claim\x20to\x20describe\x20the\x20current\x20code']};return{'verdict':b['length']>0x0?'stale':'current','downgrades_findings':b['length']>0x0,'skews':b};}export let currentChainEpoch=null;export function setComparisonChainEpoch(a){currentChainEpoch=a;}
|
|
@@ -26,8 +26,9 @@ declare function driftFace(templateId: string): {
|
|
|
26
26
|
detail: string;
|
|
27
27
|
};
|
|
28
28
|
declare function scanSummary(scan: TemplateScanResult, drift?: ReturnType<typeof driftFace>): {
|
|
29
|
+
template_id: string;
|
|
29
30
|
risk_level: import("../../knowledge/template-scanner.js").TemplateRiskLevel;
|
|
30
|
-
|
|
31
|
+
preflight_scan_passed: boolean;
|
|
31
32
|
finding_count: number;
|
|
32
33
|
findings_by_severity: Record<string, number>;
|
|
33
34
|
red_flags: string[];
|
|
@@ -55,9 +56,10 @@ declare function scanSummary(scan: TemplateScanResult, drift?: ReturnType<typeof
|
|
|
55
56
|
detail: string;
|
|
56
57
|
} | undefined;
|
|
57
58
|
};
|
|
58
|
-
export declare function buildVerdict(summary: ReturnType<typeof scanSummary>, plan: Record<string, unknown
|
|
59
|
+
export declare function buildVerdict(summary: ReturnType<typeof scanSummary>, plan: Record<string, unknown>, mirrorGenerateHighGate?: boolean): {
|
|
59
60
|
buildable: boolean;
|
|
60
61
|
blockers: string[];
|
|
62
|
+
status: "READY" | "BLOCKED";
|
|
61
63
|
};
|
|
62
64
|
export declare function planNextAction(plan: Record<string, unknown>, retryAction: string, verdict?: {
|
|
63
65
|
buildable: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{strictParse}from'../../schema/index.js';import{BenchmarkMigrationSchema}from'../../schema/benchmark-migration/index.js';import{getTemplate,listTemplates,validateAllocatorRows,platformShareBps,builtinTemplateDrift}from'../../knowledge/template-loader.js';import{BUILTIN_TEMPLATES,BUILTIN_TEMPLATES_VERSION}from'../../knowledge/builtin-templates.js';import{scanTemplate,buildFeeParamLandingTable}from'../../knowledge/template-scanner.js';import{planMigration}from'../../playbooks/service-build/migration-planner.js';import{handleMerchantGuide}from'../../playbooks/service-build/merchant-guide.js';import{inferArbitration}from'../../playbooks/service-build/intent-analyzer.js';import{getIndustryModeRegistry}from'../../extensions/index.js';import{resolveIndustryName}from'../../knowledge/industry-registry.js';function templateSummary(a){return{'id':a['id'],'industry':a['industry'],'variant':a['variant'],'product_ref':a['product_ref'],'archetype':a['archetype'],'key_risk':a['key_risk'],'node_count':a['machine_shape']['length'],'guard_count':a['guards']['length'],'recommended_role':a['recommended_role']};}function templateGetAids(a){const b=a['machine_shape']['some'](c=>c['name']==='reviewed');return{'claim_anchor':b?'review_node+final':'final_only','claim_anchor_note':b?'machine_shape\x20mounts\x20a\x20\x27reviewed\x27\x20node\x20—\x20the\x20buyer\x27s\x20structured\x20review\x20rides\x20that\x20node\x20alongside\x20the\x20final\x20settlement.':'no\x20\x27reviewed\x27\x20node\x20—\x20sanctioned\x20variant:\x20the\x20buyer\x27s\x20voice\x20rides\x20the\x20claim/arbitration\x20rail\x20only\x20(no\x20separate\x20review\x20stop).','allocator_count_note':'allocator.count\x20=\x20'+a['allocator']['count']+'\x20counts\x20SETTLEMENT-track\x20legs\x20only;\x20refund-track\x20legs\x20(rows[]\x20with\x20track:\x22refund\x22)\x20are\x20additional\x20and\x20NOT\x20included\x20in\x20this\x20count.\x20rows[]\x20carries\x20the\x20complete\x20executable\x20split\x20plan.','onchain_field_notes':['passport.impack\x20—\x20the\x20on-chain\x20field\x20is\x20spelled\x20`impack`\x20(passport.move,\x20packed\x20business\x20objects\x20in\x20the\x20passport\x20verification\x20context).\x20It\x20is\x20the\x20contract\x27s\x20own\x20field\x20name,\x20not\x20a\x20typo;\x20echo\x20it\x20verbatim.']};}function requireTemplate(a,b){if(!a)throw new Error('\x27template_id\x27\x20is\x20required\x20for\x20action=\x27'+b+'\x27');const c=getTemplate(a);if(!c)throw new Error('Unknown\x20template\x20id:\x20'+a+'\x20(use\x20action=\x27template_list\x27\x20to\x20see\x20valid\x20ids)');return c;}function driftFace(a){const b=builtinTemplateDrift()['find'](c=>c['template']===a);if(!b){const c=BUILTIN_TEMPLATES['some'](d=>d['id']===a);return c?{'template':a,'state':'current','catalog_version':BUILTIN_TEMPLATES_VERSION,'blocked':![],'repairable':![],'detail':'disk\x20body\x20matches\x20the\x20shipped\x20catalog\x20(hash-verified\x20sentinel)'}:{'template':a,'state':'untracked','catalog_version':undefined,'blocked':![],'repairable':![],'detail':'user-authored\x20template\x20—\x20no\x20builtin\x20catalog\x20binding\x20to\x20compare\x20against'};}return{'template':b['template'],'state':b['state'],'catalog_version':BUILTIN_TEMPLATES_VERSION,'blocked':!![],'repairable':b['repairable'],'detail':b['detail']};}function scanSummary(a,b){const c={};for(const d of a['findings'])c[d['severity']]=(c[d['severity']]??0x0)+0x1;return{'risk_level':a['risk_level'],'passed':a['red_flags']['length']===0x0,'finding_count':a['findings']['length'],'findings_by_severity':c,'red_flags':a['red_flags'],'findings':a['findings'],'drift':b};}function assertScanPassed(a,b){const c=a['red_flags'];if(a['passed']||c['length']===0x0)return;throw new Error('action=\x27'+b+'\x27\x20blocked:\x20pre-deploy\x20scan\x20of\x20template\x20\x27'+a['template_id']+'\x27\x20found\x20CRITICAL\x20risk\x20—\x20'+c['join'](';\x20')+'.\x20Fix\x20the\x20template\x20(frontmatter\x20or\x20body)\x20and\x20re-run\x20action=\x27template_scan\x27.');}const GENERATE_HIGH_TOLERATED=new Set([]);function assertGenerateScanPassed(a,b){assertScanPassed(a,b);if(b!=='template_generate')return;const c=a['findings']['filter'](d=>d['severity']==='high'&&!(d['rule_id']&&GENERATE_HIGH_TOLERATED['has'](a['template_id']+'/'+d['rule_id'])));if(c['length']===0x0)return;throw new Error('action=\x27'+b+'\x27\x20blocked:\x20pre-deploy\x20scan\x20of\x20template\x20\x27'+a['template_id']+'\x27\x20found\x20'+c['length']+'\x20HIGH\x20finding(s)\x20—\x20'+c['map'](d=>(d['rule_id']??'HIGH')+':\x20'+d['title'])['join'](';\x20')+'.\x20Fix\x20the\x20template\x20(frontmatter\x20or\x20body)\x20and\x20re-run\x20action=\x27template_scan\x27.');}export function buildVerdict(a,b){const c=[];!a['passed']&&c['push']('scan:\x20'+(a['findings_by_severity']['critical']??0x0)+'\x20CRITICAL\x20finding(s)\x20(scan.passed=false)');const d=b['graph_validation'];if(d&&d['valid']===![]){const f=Array['isArray'](d['hard_violations'])?d['hard_violations']['length']:0x0,g=Array['isArray'](d['hard_violations'])?d['hard_violations']['map'](h=>h['id'])['join'](',\x20'):'';c['push']('graph_validation:\x20'+f+'\x20hard\x20violation(s)'+(g?'\x20('+g+')':''));}const e=b['audit'];return e&&e['blocking']===!![]&&c['push']('audit:\x20guide\x20audit\x20flagged\x20blocking\x20issue(s)\x20(plan.audit)'),{'buildable':c['length']===0x0,'blockers':c};}export function planNextAction(a,b,c){const d=a['next_action'];if(typeof d==='string'&&d['startsWith']('Plan\x20ready.'))return d;if(c?.['buildable']){const f=Array['isArray'](a['pending_guard_designs'])?a['pending_guard_designs']['length']:0x0;return'Plan\x20is\x20buildable\x20(verdict.buildable=true).\x20Materialize\x20the\x20objects\x20in\x20plan.steps\x20order'+(f>0x0?',\x20resolving\x20the\x20'+f+'\x20pending\x20guard\x20design(s)\x20in\x20plan.pending_guard_designs\x20via\x20guard_resolutions\x20before\x20the\x20Machine\x20publish':'')+'.';}const e=Array['isArray'](a['pending_guard_designs'])?a['pending_guard_designs']['length']:0x0;return'Plan\x20BLOCKED\x20by\x20the\x20guide\x20audit\x20(see\x20plan.audit\x20/\x20plan.next_action).\x20Do\x20NOT\x20materialize,\x20'+'and\x20do\x20NOT\x20hand-build\x20the\x20objects\x20instead:\x20this\x20plan\x20is\x20the\x20wiring\x20authority\x20(Arbitration\x20+\x20'+'compensation-fund,\x20Contact/um,\x20allocator\x20rows)\x20and\x20hand-built\x20replicas\x20silently\x20drop\x20those\x20wirings.\x20'+(e>0x0?'Resolve\x20the\x20'+e+'\x20pending\x20guard\x20design(s)\x20in\x20plan.pending_guard_designs\x20via\x20guard_resolutions\x20(kind\x20\x27inline\x27\x20with\x20the\x20Guard\x20table+root,\x20kind\x20\x27template\x27\x20with\x20a\x20tpl_*\x20id,\x20or\x20{kind:\x27omit\x27}\x20for\x20advisory\x20designs\x20that\x20do\x20not\x20apply\x20to\x20this\x20shop),\x20':'Adjust\x20fee_overrides,\x20pick\x20another\x20template\x20variant,\x20or\x20fix\x20the\x20template,\x20')+('then\x20re-run\x20action=\x27'+b+'\x27.');}function templateIntent(a,b){if(b&&b['trim']())return b['trim']();return'Adopt\x20the\x20'+a['id']+'\x20industry\x20archetype\x20template\x20('+a['archetype']+')\x20for\x20the\x20'+a['industry']+'\x20industry.\x20'+('Primary\x20risk\x20to\x20mitigate:\x20'+a['key_risk']+'.');}function effectiveFeeParams(a,b){return{...a['fee_params'],...b??{}};}const REWARD_POOL_PATTERNS=[/(?:reward|review|bonus|tip|prize)[\s-]*pools?\s*(?:of|is|at|:|=)?\s*([0-9][0-9_,]*(?:\.[0-9]+)?)/i,/([0-9][0-9_,]*(?:\.[0-9]+)?)\s*(?:reward|review|bonus|tip|prize)[\s-]*pools?\b/i,/(?:奖(?:金|励)?池|打赏池|好评(?:奖励)?池)\s*(?:为|是|:|:|=)?\s*([0-9][0-9_,]*(?:\.[0-9]+)?)/,/([0-9][0-9_,]*(?:\.[0-9]+)?)\s*的?\s*(?:奖(?:金|励)?池|打赏池|好评(?:奖励)?池)/];export function extractRewardPoolCandidate(a){if(!a)return undefined;for(const b of REWARD_POOL_PATTERNS){const c=b['exec'](a);if(!c)continue;const d=Number(c[0x1]['replaceAll'](/[,_]/g,''));if(Number['isFinite'](d)&&d>=0x0)return d;}return undefined;}function rewardPoolPrefill(a,b,c){if(a['fee_params']['review_reward_pool']===undefined)return undefined;if(c?.['review_reward_pool']!==undefined)return undefined;const d=extractRewardPoolCandidate(b);return d===undefined?undefined:{'fee_key':'review_reward_pool','value':d};}function validateFeeParams(a,b){const c=[];let d=0x0;for(const [e,f]of Object['entries'](a)){if(typeof f!=='number'||!Number['isFinite'](f))continue;if(e['endsWith']('_bps')){(!Number['isInteger'](f)||f<0x0||f>0x2710)&&c['push'](e+'='+f+'\x20is\x20not\x20an\x20integer\x20rate\x20in\x20[0,\x2010000]\x20bps');if(e['endsWith']('_share_bps'))d+=Math['max'](0x0,f);}else{if(e['endsWith']('_days')){if(f<=0x0||f>0xe42)c['push'](e+'='+f+'\x20is\x20outside\x20the\x20sane\x20window\x20range\x20(0,\x203650]\x20days');}else{if(e['endsWith']('_hours')){if(f<=0x0||f>0x2238)c['push'](e+'='+f+'\x20is\x20outside\x20the\x20sane\x20window\x20range\x20(0,\x208760]\x20hours');}}}}if(d>0x2710)c['push']('*_share_bps\x20sum\x20'+d+'\x20exceeds\x2010000\x20(a\x20pool\x20splits\x20into\x20at\x20most\x20100%)');if(c['length']>0x0)throw new Error('invalid\x20fee\x20parameters\x20for\x20template\x20\x27'+b+'\x27:\x20'+c['join'](';\x20')+'.\x20'+'Correct\x20the\x20template\x27s\x20fee_params\x20or\x20pass\x20valid\x20\x27fee_overrides\x27.');}export{validateAllocatorRows};export function variantPaymentModel(a){if(a['payment_model'])return a['payment_model'];const b=a['allocator']['rows']??[];if(b['some'](d=>d['track']==='refund'))return'escrow';const c=a['machine_shape']['map'](d=>d['name'])['join']('\x20')['toLowerCase']();if(/\b(milestone|revision|revis|draft|deliverable)\b/['test'](c))return'milestone';if(/\b(charge|renew|subscription|cycle|billing|monthly)\b/['test'](c))return'subscription';return'escrow';}function variantRefundPolicy(a){const b=a['allocator']['description']['toLowerCase']();if(/full[ -]?refund|100% refund|refund .*100/['test'](b))return'full';if(/pro-?rata|prorated/['test'](b))return'milestone_prorated';if(/partial/['test'](b))return'partial';return undefined;}export function variantDeliverables(a,b){const c=a['machine_shape']['filter'](g=>g['semantic_role']==='final'),d=c[c['length']-0x1]??[...a['machine_shape']]['reverse']()['find'](g=>!/refund|cancel|dispute|terminat/i['test'](g['name']+'\x20'+g['role']))??a['machine_shape'][a['machine_shape']['length']-0x1],e=b?.['has_logistics']?'physical':b?.['pure_digital']?'digital':'service_session',f=(a['guards']??[])['filter'](h=>/repository_data_check|required_info_evidence_gate|allocator_order_anchor/['test'](h['template_id']));return[{'name':a['variant']+'\x20fulfillment','type':e,'acceptanceCriteria':'Order\x20reaches\x20the\x20terminal\x20workflow\x20node\x20\x27'+d['name']+'\x27\x20('+d['role']+')','proofOfDelivery':f['length']>0x0?'wip_hash':'manual_confirm'}];}function validateConditionalParams(a,b){for(const d of a['conditional_guards']??[]){const e=b[d['param']];if(e===undefined)continue;if(typeof e!=='string'||!d['values']['includes'](e))throw new Error('invalid\x20\x27'+d['param']+'='+String(e)+'\x27\x20for\x20template\x20\x27'+a['id']+'\x27:\x20must\x20be\x20one\x20of\x20'+d['values']['map'](f=>'\x27'+f+'\x27')['join']('\x20|\x20')+('\x20(the\x20guard\x20variant\x20mounts\x20at\x20\x27'+d['emit_value']+'\x27)'));}}async function runGuide(a,b,c,d,e,f){const g=effectiveFeeParams(a,c),h=rewardPoolPrefill(a,b,c);if(h)g[h['fee_key']]=h['value'];validateFeeParams(g,a['id']),validateConditionalParams(a,g);const i=getIndustryModeRegistry()['getMode'](a['industry']),j=platformShareBps(g),k={'model':variantPaymentModel(a)},l=[],m=(a['allocator']['rows']?.['length']??0x0)>0x0;if(j!==undefined&&j>0x0&&!m&&a['allocator']['mode']==='rate'){const q=Math['round'](j)/0x64;l['push']({'recipient':'merchant','percentage':Math['round']((0x64-q)*0x64)/0x64}),l['push']({'recipient':'platform','percentage':q}),k['allocation']=l;}const n=variantRefundPolicy(a),o={'escrow':!![]};if(n)o['refundPolicy']=n;o['arbitration']=a['arbitration_mode']??o['arbitration']??inferArbitration(templateIntent(a,b));const p=await handleMerchantGuide({'intent':templateIntent(a,b),'guide_confirm':{'industry':a['industry'],'payment':k,'trust':o,'deliverables':variantDeliverables(a,i?.['traits']),...d&&Object['keys'](d)['length']>0x0?{'guard_resolutions':d}:{},...e?.['review_mode']?{'review_mode':e['review_mode']}:{},...e?.['reward_funding']!==undefined?{'reward_funding':e['reward_funding']}:{},...e?.['after_sales_mode']?{'after_sales_mode':e['after_sales_mode']}:{},...e?.['acceptance_mode']?{'acceptance_mode':e['acceptance_mode']}:{},...e?.['installment_mode']?{'installment_mode':e['installment_mode']}:{},...e?.['affiliate_mode']?{'affiliate_mode':e['affiliate_mode']}:{},...e?.['crowdfunding_mode']?{'crowdfunding_mode':e['crowdfunding_mode']}:{},...f?.['length']?{'sales':f}:{}},'template_override':{...a,'fee_params':g},'name_base':a['id']});if(a['allocator']['rows']?.['length'])p['template_allocator_rows']=a['allocator']['rows']['map'](s=>({...s}));p['template']={'id':a['id'],'archetype':a['archetype'],'recommended_role':a['recommended_role'],'fee_params':g},p['template_fee_param_landings']=buildFeeParamLandingTable(a,g);if(c&&Object['keys'](c)['length']>0x0)p['template_fee_overrides']=c;return h&&(p['fee_overrides_prefill']=h,p['next_action']=p['next_action']+'\x20Reward\x20pool\x20prefilled\x20from\x20your\x20request:\x20'+h['value']+'\x20—\x20adjust\x20via\x20fee_overrides.'),p;}export async function handleBenchmarkMigrationOperation(a){const b=strictParse(BenchmarkMigrationSchema,a,'benchmark_migration_operation\x20input'),c=b['industry']?resolveIndustryName(b['industry'])??b['industry']['toLowerCase']():undefined;let d;switch(b['action']){case'template_list':{const {templates:e,errors:f}=listTemplates(),g=c?e['filter'](i=>i['industry']===c):e,h=new Map(builtinTemplateDrift()['map'](i=>[i['template'],i['state']]));d={'action':'template_list','count':g['length'],'templates':g['map'](i=>({...templateSummary(i),'disk_state':h['get'](i['id'])??(BUILTIN_TEMPLATES['some'](j=>j['id']===i['id'])?'current':'untracked')})),'load_errors':f};break;}case'template_get':{const i=requireTemplate(b['template_id'],'template_get');d={'action':'template_get','template':{...i,...templateGetAids(i)}};break;}case'template_generate':{const j=requireTemplate(b['template_id'],'template_generate'),k=b['review_mode']??j['review_mode']??'none';if(k==='review_reward'&&!b['reward_funding'])return{'content':[{'type':'text','text':'template_generate\x20refused\x20—\x20no\x20plan\x20was\x20built.\x20Template\x20\x27'+j['id']+'\x27\x20resolves\x20to\x20review_mode\x20\x27review_reward\x27\x20(input'+(b['review_mode']?'':'\x20via\x20template\x20declaration')+'),\x20which\x20promises\x20buyers\x20a\x20claimable\x20review\x20bounty\x20—\x20an\x20unfunded\x20pool\x20must\x20not\x20ship.\x20Pass\x20reward_funding\x20(smallest-unit\x20string),\x20or\x20drop\x20the\x20mode\x20explicitly\x20(review_mode\x20\x27review\x27\x20keeps\x20the\x20review\x20rail\x20without\x20the\x20bounty;\x20\x27none\x27\x20removes\x20the\x20rail).'}],'structuredContent':{'result':{'type':'error','error':'review_mode\x20\x27'+k+'\x27\x20without\x20reward_funding\x20(INV-4)\x20on\x20template\x20\x27'+j['id']+'\x27.','error_code':'reward_funding_required','retryable':!![],'recovery_hint':'Pass\x20reward_funding\x20=\x20expected\x20orders\x20x\x20per-order\x20reward\x20(fee_param\x20review_reward_pool\x20is\x20the\x20planning\x20benchmark),\x20or\x20re-send\x20with\x20review_mode:\x27review\x27\x20(rail\x20only)\x20/\x20\x27none\x27\x20(no\x20rail).'},'message':'Refused:\x20a\x20review_reward\x20build\x20requires\x20a\x20funded\x20reward\x20pool.\x20See\x20recovery_hint.'}};if(!Array['isArray'](b['sales'])||b['sales']['length']===0x0)return{'content':[{'type':'text','text':'template_generate\x20refused\x20—\x20no\x20plan\x20was\x20built.\x20The\x20sellable\x20catalog\x20(sales)\x20is\x20required:\x20a\x20plan\x20without\x20one\x20publishes\x20a\x20Service\x20frozen\x20with\x20sales:\x20[]\x20and\x20every\x20order_new\x20aborts\x20(PLAN-SALES-01).\x20List\x20at\x20least\x20one\x20SKU:\x20{\x20name,\x20price,\x20quantity?,\x20wip_hash?\x20}\x20—\x20price\x20in\x20smallest\x20units.'}],'structuredContent':{'result':{'type':'error','error':'template_generate\x20without\x20a\x20non-empty\x20sales\x20catalog\x20(PLAN-SALES-01\x20upgraded\x20to\x20an\x20input\x20requirement,\x20amz9\x20A-2).','error_code':'sales_required','retryable':!![],'recovery_hint':'Pass\x20sales:\x20[{\x20name,\x20price,\x20quantity?,\x20wip_hash?\x20}]\x20—\x20one\x20entry\x20per\x20sellable\x20SKU\x20(wip_hash\x20from\x20the\x20wip_file\x20tool\x20upload).\x20migration_apply\x20is\x20unaffected:\x20it\x20confirms\x20an\x20already-reviewed\x20import.'},'message':'Refused:\x20template_generate\x20requires\x20a\x20sellable\x20catalog.\x20See\x20recovery_hint.'}};const l=scanTemplate(j);assertGenerateScanPassed(l,'template_generate');const m=await runGuide(j,b['description'],b['fee_overrides'],b['guard_resolutions'],{'review_mode':b['review_mode'],'reward_funding':b['reward_funding'],'after_sales_mode':b['after_sales_mode'],'acceptance_mode':b['acceptance_mode'],'installment_mode':b['installment_mode'],'affiliate_mode':b['affiliate_mode'],'crowdfunding_mode':b['crowdfunding_mode']},b['sales']);d=((()=>{const n=scanSummary(l,driftFace(j['id'])),o=buildVerdict(n,m);return{'action':'template_generate','template_id':j['id'],'scan':n,'plan':m,'verdict':o,'next_action':planNextAction(m,'template_generate',o)};})());break;}case'template_scan':{const n=requireTemplate(b['template_id'],'template_scan');d={'action':'template_scan','scan':{...scanTemplate(n),'drift':driftFace(n['id'])}};break;}case'migration_import':{if(!b['description']||!b['description']['trim']())throw new Error('\x27description\x27\x20is\x20required\x20for\x20action=\x27migration_import\x27');const o=planMigration({'url':b['url'],'description':b['description'],'industry':c,'network':b['network']});if(!o)throw new Error('No\x20industry\x20template\x20matched\x20the\x20description.\x20Refine\x20the\x20description\x20or\x20pass\x20an\x20explicit\x20\x27industry\x27\x20hint.');d={'action':'migration_import','log':o,'next_action':'MigrationLog\x20ready.\x20Next:\x20call\x20action=\x27migration_review\x27\x20with\x20this\x20log\x20to\x20surface\x20the\x20mapped/unmapped/manual_review\x20items\x20for\x20user\x20confirmation.'};break;}case'migration_review':{if(!b['log'])throw new Error('\x27log\x27\x20is\x20required\x20for\x20action=\x27migration_review\x27');const p=b['log'],q=Array['isArray'](p['mapped'])?p['mapped']:[],r=Array['isArray'](p['unmapped'])?p['unmapped']:[],s=Array['isArray'](p['manual_review'])?p['manual_review']:[],t=p['risk_check']??{},u=p['source']?.['matched_template']??'',v=r['length']===0x0&&s['length']===0x0&&t['passed']===!![];d={'action':'migration_review','log':p,'review_summary':{'mapped_count':q['length'],'unmapped_count':r['length'],'manual_review_count':s['length'],'risk_passed':t['passed']===!![]},'next_action':v?'Review\x20clean.\x20Proceed:\x20call\x20action=\x27migration_apply\x27\x20with\x20template_id=\x27'+u+'\x27\x20to\x20produce\x20the\x20creation\x20plan\x20(network\x20defaults\x20to\x20testnet;\x20mainnet\x20requires\x20explicit\x20user\x20confirmation).':'Surface\x20the\x20'+r['length']+'\x20unmapped\x20and\x20'+s['length']+'\x20manual_review\x20items'+(t['passed']===!![]?'':'\x20plus\x20the\x20risk_check\x20findings')+'\x20to\x20the\x20user\x20for\x20a\x20decision\x20before\x20action=\x27migration_apply\x27\x20(template_id=\x27'+u+'\x27).'};break;}case'migration_apply':{const w=requireTemplate(b['template_id'],'migration_apply'),x=scanTemplate(w);assertScanPassed(x,'migration_apply');const y=b['network']??'testnet',z=await runGuide(w,b['description'],b['fee_overrides'],b['guard_resolutions'],{'review_mode':b['review_mode'],'reward_funding':b['reward_funding'],'after_sales_mode':b['after_sales_mode'],'acceptance_mode':b['acceptance_mode'],'installment_mode':b['installment_mode'],'affiliate_mode':b['affiliate_mode'],'crowdfunding_mode':b['crowdfunding_mode']},b['sales']);d=((()=>{const A=scanSummary(x,driftFace(w['id'])),B=buildVerdict(A,z);return{'action':'migration_apply','template_id':w['id'],'network':y,'scan':A,'plan':z,'verdict':B,'next_action':planNextAction(z,'migration_apply',B)};})());break;}default:throw new Error('Unknown\x20benchmark_migration_operation\x20action:\x20'+String(b['action']));}return{'content':[{'type':'text','text':JSON['stringify']({'result':d})}],'structuredContent':{'result':d}};}
|
|
1
|
+
import{strictParse}from'../../schema/index.js';import{BenchmarkMigrationSchema}from'../../schema/benchmark-migration/index.js';import{getTemplate,listTemplates,validateAllocatorRows,platformShareBps,builtinTemplateDrift}from'../../knowledge/template-loader.js';import{BUILTIN_TEMPLATES,BUILTIN_TEMPLATES_VERSION}from'../../knowledge/builtin-templates.js';import{scanTemplate,buildFeeParamLandingTable}from'../../knowledge/template-scanner.js';import{planMigration}from'../../playbooks/service-build/migration-planner.js';import{handleMerchantGuide}from'../../playbooks/service-build/merchant-guide.js';import{inferArbitration}from'../../playbooks/service-build/intent-analyzer.js';import{getIndustryModeRegistry}from'../../extensions/index.js';import{resolveIndustryName}from'../../knowledge/industry-registry.js';function templateSummary(a){return{'id':a['id'],'industry':a['industry'],'variant':a['variant'],'product_ref':a['product_ref'],'archetype':a['archetype'],'key_risk':a['key_risk'],'node_count':a['machine_shape']['length'],'guard_count':a['guards']['length'],'recommended_role':a['recommended_role']};}function templateGetAids(a){const b=a['machine_shape']['some'](c=>c['name']==='reviewed');return{'claim_anchor':b?'review_node+final':'final_only','claim_anchor_note':b?'machine_shape\x20mounts\x20a\x20\x27reviewed\x27\x20node\x20—\x20the\x20buyer\x27s\x20structured\x20review\x20rides\x20that\x20node\x20alongside\x20the\x20final\x20settlement.':'no\x20\x27reviewed\x27\x20node\x20—\x20sanctioned\x20variant:\x20the\x20buyer\x27s\x20voice\x20rides\x20the\x20claim/arbitration\x20rail\x20only\x20(no\x20separate\x20review\x20stop).','allocator_count_note':'allocator.count\x20=\x20'+a['allocator']['count']+'\x20counts\x20SETTLEMENT-track\x20legs\x20only;\x20refund-track\x20legs\x20(rows[]\x20with\x20track:\x22refund\x22)\x20are\x20additional\x20and\x20NOT\x20included\x20in\x20this\x20count.\x20rows[]\x20carries\x20the\x20complete\x20executable\x20split\x20plan.','onchain_field_notes':['passport.impack\x20—\x20the\x20on-chain\x20field\x20is\x20spelled\x20`impack`\x20(passport.move,\x20packed\x20business\x20objects\x20in\x20the\x20passport\x20verification\x20context).\x20It\x20is\x20the\x20contract\x27s\x20own\x20field\x20name,\x20not\x20a\x20typo;\x20echo\x20it\x20verbatim.']};}function requireTemplate(a,b){if(!a)throw new Error('\x27template_id\x27\x20is\x20required\x20for\x20action=\x27'+b+'\x27');const c=getTemplate(a);if(!c)throw new Error('Unknown\x20template\x20id:\x20'+a+'\x20(use\x20action=\x27template_list\x27\x20to\x20see\x20valid\x20ids)');return c;}function driftFace(a){const b=builtinTemplateDrift()['find'](c=>c['template']===a);if(!b){const c=BUILTIN_TEMPLATES['some'](d=>d['id']===a);return c?{'template':a,'state':'current','catalog_version':BUILTIN_TEMPLATES_VERSION,'blocked':![],'repairable':![],'detail':'disk\x20body\x20matches\x20the\x20shipped\x20catalog\x20(hash-verified\x20sentinel)'}:{'template':a,'state':'untracked','catalog_version':undefined,'blocked':![],'repairable':![],'detail':'user-authored\x20template\x20—\x20no\x20builtin\x20catalog\x20binding\x20to\x20compare\x20against'};}return{'template':b['template'],'state':b['state'],'catalog_version':BUILTIN_TEMPLATES_VERSION,'blocked':!![],'repairable':b['repairable'],'detail':b['detail']};}function scanSummary(a,b){const c={};for(const d of a['findings'])c[d['severity']]=(c[d['severity']]??0x0)+0x1;return{'template_id':a['template_id'],'risk_level':a['risk_level'],'preflight_scan_passed':a['red_flags']['length']===0x0,'finding_count':a['findings']['length'],'findings_by_severity':c,'red_flags':a['red_flags'],'findings':a['findings'],'drift':b};}function assertScanPassed(a,b){const c=a['red_flags'];if(a['passed']||c['length']===0x0)return;throw new Error('action=\x27'+b+'\x27\x20blocked:\x20pre-deploy\x20scan\x20of\x20template\x20\x27'+a['template_id']+'\x27\x20found\x20CRITICAL\x20risk\x20—\x20'+c['join'](';\x20')+'.\x20Fix\x20the\x20template\x20(frontmatter\x20or\x20body)\x20and\x20re-run\x20action=\x27template_scan\x27.');}const GENERATE_HIGH_TOLERATED=new Set([]);function assertGenerateScanPassed(a,b){assertScanPassed(a,b);if(b!=='template_generate')return;const c=generateHighBlockers(a['template_id'],a['findings']);if(c['length']===0x0)return;throw new Error('action=\x27'+b+'\x27\x20blocked:\x20pre-deploy\x20scan\x20of\x20template\x20\x27'+a['template_id']+'\x27\x20found\x20'+c['length']+'\x20HIGH\x20finding(s)\x20—\x20'+c['map'](d=>(d['rule_id']??'HIGH')+':\x20'+d['title'])['join'](';\x20')+'.\x20Fix\x20the\x20template\x20(frontmatter\x20or\x20body)\x20and\x20re-run\x20action=\x27template_scan\x27.');}function generateHighBlockers(a,b){return b['filter'](c=>c['severity']==='high'&&!(c['rule_id']&&GENERATE_HIGH_TOLERATED['has'](a+'/'+c['rule_id'])));}export function buildVerdict(a,b,c){const d=[];!a['preflight_scan_passed']&&d['push']('scan:\x20'+(a['findings_by_severity']['critical']??0x0)+'\x20CRITICAL\x20finding(s)\x20(preflight\x20scan\x20failed)');if(c){const h=generateHighBlockers(a['template_id'],a['findings']??[]);h['length']>0x0&&d['push']('scan:\x20'+h['length']+'\x20HIGH\x20finding(s)\x20—\x20template_generate\x20would\x20refuse\x20(N-21):\x20'+h['map'](i=>((i['rule_id']??'HIGH')+':\x20'+(i['title']??''))['trim']())['join'](';\x20'));}const e=b['graph_validation'];if(e&&e['valid']===![]){const i=Array['isArray'](e['hard_violations'])?e['hard_violations']['length']:0x0,j=Array['isArray'](e['hard_violations'])?e['hard_violations']['map'](k=>k['id'])['join'](',\x20'):'';d['push']('graph_validation:\x20'+i+'\x20hard\x20violation(s)'+(j?'\x20('+j+')':''));}const f=b['audit'];if(f&&f['blocking']===!![]){const k=(f['findings']??[])['filter'](l=>l['level']==='critical'||l['level']==='high');d['push'](k['length']===0x0?'audit:\x20guide\x20audit\x20flagged\x20blocking\x20issue(s)\x20(plan.audit)':'audit:\x20'+k['length']+'\x20blocking\x20finding(s)\x20—\x20'+k['slice'](0x0,0x5)['map'](l=>((l['rule_id']??'?')+':\x20'+(l['title']??''))['trim']())['join'](';\x20')+(k['length']>0x5?'\x20(+'+(k['length']-0x5)+'\x20more\x20in\x20plan.audit.findings)':''));}const g=d['length']===0x0;return{'buildable':g,'blockers':d,'status':g?'READY':'BLOCKED'};}async function templateScanDryRun(a){const b=[{'name':'scan-probe','price':'1000000000','quantity':0x1}],c=a['review_mode']==='review_reward'?{'review_mode':'review_reward','reward_funding':'20000000'}:undefined;try{const d=await runGuide(a,undefined,undefined,undefined,c,b),f=buildVerdict(scanSummary(scanTemplate(a)),d,!![]);return{'status':f['buildable']?'ready':'blocked','buildable':f['buildable'],'blockers':f['blockers'],'note':'Compile\x20dry-run\x20on\x20synthetic\x20probe\x20inputs\x20(single\x20probe\x20SKU,\x20benchmark\x20reward\x20funding),\x20mirrored\x20to\x20the\x20template_generate\x20gate\x20(CRITICAL\x20+\x20N-21\x20HIGH\x20+\x20graph\x20+\x20audit).\x20Structural\x20blockers\x20are\x20REAL\x20—\x20the\x20generate\x20face\x20refuses\x20for\x20the\x20same\x20reason.\x20Blockers\x20naming\x20caller\x20inputs\x20(fee_overrides\x20/\x20guard_resolutions\x20/\x20catalog)\x20may\x20clear\x20with\x20real\x20values.'};}catch(g){return{'status':'unavailable','note':'Compile\x20dry-run\x20could\x20not\x20run\x20on\x20synthetic\x20probe\x20inputs\x20('+(g instanceof Error?g['message']:String(g))+').\x20This\x20is\x20a\x20probe\x20limitation,\x20NOT\x20a\x20template\x20verdict\x20—\x20run\x20template_generate\x20for\x20the\x20authoritative\x20buildability.'};}}export function planNextAction(a,b,c){const d=a['next_action'];if(typeof d==='string'&&d['startsWith']('Plan\x20ready.'))return d;if(c?.['buildable']){const f=Array['isArray'](a['pending_guard_designs'])?a['pending_guard_designs']['length']:0x0;return'Plan\x20is\x20buildable\x20(verdict.buildable=true).\x20Materialize\x20the\x20objects\x20in\x20plan.steps\x20order'+(f>0x0?',\x20resolving\x20the\x20'+f+'\x20pending\x20guard\x20design(s)\x20in\x20plan.pending_guard_designs\x20via\x20guard_resolutions\x20before\x20the\x20Machine\x20publish':'')+'.';}const e=Array['isArray'](a['pending_guard_designs'])?a['pending_guard_designs']['length']:0x0;return'Plan\x20BLOCKED\x20by\x20the\x20guide\x20audit\x20(see\x20plan.audit\x20/\x20plan.next_action).\x20Do\x20NOT\x20materialize,\x20'+'and\x20do\x20NOT\x20hand-build\x20the\x20objects\x20instead:\x20this\x20plan\x20is\x20the\x20wiring\x20authority\x20(Arbitration\x20+\x20'+'compensation-fund,\x20Contact/um,\x20allocator\x20rows)\x20and\x20hand-built\x20replicas\x20silently\x20drop\x20those\x20wirings.\x20'+(e>0x0?'Resolve\x20the\x20'+e+'\x20pending\x20guard\x20design(s)\x20in\x20plan.pending_guard_designs\x20via\x20guard_resolutions\x20(kind\x20\x27inline\x27\x20with\x20the\x20Guard\x20table+root,\x20kind\x20\x27template\x27\x20with\x20a\x20tpl_*\x20id,\x20or\x20{kind:\x27omit\x27}\x20for\x20advisory\x20designs\x20that\x20do\x20not\x20apply\x20to\x20this\x20shop),\x20':'Adjust\x20fee_overrides,\x20pick\x20another\x20template\x20variant,\x20or\x20fix\x20the\x20template,\x20')+('then\x20re-run\x20action=\x27'+b+'\x27.');}function templateIntent(a,b){if(b&&b['trim']())return b['trim']();return'Adopt\x20the\x20'+a['id']+'\x20industry\x20archetype\x20template\x20('+a['archetype']+')\x20for\x20the\x20'+a['industry']+'\x20industry.\x20'+('Primary\x20risk\x20to\x20mitigate:\x20'+a['key_risk']+'.');}function effectiveFeeParams(a,b){return{...a['fee_params'],...b??{}};}const REWARD_POOL_PATTERNS=[/(?:reward|review|bonus|tip|prize)[\s-]*pools?\s*(?:of|is|at|:|=)?\s*([0-9][0-9_,]*(?:\.[0-9]+)?)/i,/([0-9][0-9_,]*(?:\.[0-9]+)?)\s*(?:reward|review|bonus|tip|prize)[\s-]*pools?\b/i,/(?:奖(?:金|励)?池|打赏池|好评(?:奖励)?池)\s*(?:为|是|:|:|=)?\s*([0-9][0-9_,]*(?:\.[0-9]+)?)/,/([0-9][0-9_,]*(?:\.[0-9]+)?)\s*的?\s*(?:奖(?:金|励)?池|打赏池|好评(?:奖励)?池)/];export function extractRewardPoolCandidate(a){if(!a)return undefined;for(const b of REWARD_POOL_PATTERNS){const c=b['exec'](a);if(!c)continue;const d=Number(c[0x1]['replaceAll'](/[,_]/g,''));if(Number['isFinite'](d)&&d>=0x0)return d;}return undefined;}function rewardPoolPrefill(a,b,c){if(a['fee_params']['review_reward_pool']===undefined)return undefined;if(c?.['review_reward_pool']!==undefined)return undefined;const d=extractRewardPoolCandidate(b);return d===undefined?undefined:{'fee_key':'review_reward_pool','value':d};}function validateFeeParams(a,b){const c=[];let d=0x0;for(const [e,f]of Object['entries'](a)){if(typeof f!=='number'||!Number['isFinite'](f))continue;if(e['endsWith']('_bps')){(!Number['isInteger'](f)||f<0x0||f>0x2710)&&c['push'](e+'='+f+'\x20is\x20not\x20an\x20integer\x20rate\x20in\x20[0,\x2010000]\x20bps');if(e['endsWith']('_share_bps'))d+=Math['max'](0x0,f);}else{if(e['endsWith']('_days')){if(f<=0x0||f>0xe42)c['push'](e+'='+f+'\x20is\x20outside\x20the\x20sane\x20window\x20range\x20(0,\x203650]\x20days');}else{if(e['endsWith']('_hours')){if(f<=0x0||f>0x2238)c['push'](e+'='+f+'\x20is\x20outside\x20the\x20sane\x20window\x20range\x20(0,\x208760]\x20hours');}}}}if(d>0x2710)c['push']('*_share_bps\x20sum\x20'+d+'\x20exceeds\x2010000\x20(a\x20pool\x20splits\x20into\x20at\x20most\x20100%)');if(c['length']>0x0)throw new Error('invalid\x20fee\x20parameters\x20for\x20template\x20\x27'+b+'\x27:\x20'+c['join'](';\x20')+'.\x20'+'Correct\x20the\x20template\x27s\x20fee_params\x20or\x20pass\x20valid\x20\x27fee_overrides\x27.');}export{validateAllocatorRows};export function variantPaymentModel(a){if(a['payment_model'])return a['payment_model'];const b=a['allocator']['rows']??[];if(b['some'](d=>d['track']==='refund'))return'escrow';const c=a['machine_shape']['map'](d=>d['name'])['join']('\x20')['toLowerCase']();if(/\b(milestone|revision|revis|draft|deliverable)\b/['test'](c))return'milestone';if(/\b(charge|renew|subscription|cycle|billing|monthly)\b/['test'](c))return'subscription';return'escrow';}function variantRefundPolicy(a){const b=a['allocator']['description']['toLowerCase']();if(/full[ -]?refund|100% refund|refund .*100/['test'](b))return'full';if(/pro-?rata|prorated/['test'](b))return'milestone_prorated';if(/partial/['test'](b))return'partial';return undefined;}export function variantDeliverables(a,b){const c=a['machine_shape']['filter'](g=>g['semantic_role']==='final'),d=c[c['length']-0x1]??[...a['machine_shape']]['reverse']()['find'](g=>!/refund|cancel|dispute|terminat/i['test'](g['name']+'\x20'+g['role']))??a['machine_shape'][a['machine_shape']['length']-0x1],e=b?.['has_logistics']?'physical':b?.['pure_digital']?'digital':'service_session',f=(a['guards']??[])['filter'](h=>/repository_data_check|required_info_evidence_gate|allocator_order_anchor/['test'](h['template_id']));return[{'name':a['variant']+'\x20fulfillment','type':e,'acceptanceCriteria':'Order\x20reaches\x20the\x20terminal\x20workflow\x20node\x20\x27'+d['name']+'\x27\x20('+d['role']+')','proofOfDelivery':f['length']>0x0?'wip_hash':'manual_confirm'}];}function validateConditionalParams(a,b){for(const d of a['conditional_guards']??[]){const e=b[d['param']];if(e===undefined)continue;if(typeof e!=='string'||!d['values']['includes'](e))throw new Error('invalid\x20\x27'+d['param']+'='+String(e)+'\x27\x20for\x20template\x20\x27'+a['id']+'\x27:\x20must\x20be\x20one\x20of\x20'+d['values']['map'](f=>'\x27'+f+'\x27')['join']('\x20|\x20')+('\x20(the\x20guard\x20variant\x20mounts\x20at\x20\x27'+d['emit_value']+'\x27)'));}}async function runGuide(a,b,c,d,e,f){const g=effectiveFeeParams(a,c),h=rewardPoolPrefill(a,b,c);if(h)g[h['fee_key']]=h['value'];validateFeeParams(g,a['id']),validateConditionalParams(a,g);const i=getIndustryModeRegistry()['getMode'](a['industry']),j=platformShareBps(g),k={'model':variantPaymentModel(a)},l=[],m=(a['allocator']['rows']?.['length']??0x0)>0x0;if(j!==undefined&&j>0x0&&!m&&a['allocator']['mode']==='rate'){const q=Math['round'](j)/0x64;l['push']({'recipient':'merchant','percentage':Math['round']((0x64-q)*0x64)/0x64}),l['push']({'recipient':'platform','percentage':q}),k['allocation']=l;}const n=variantRefundPolicy(a),o={'escrow':!![]};if(n)o['refundPolicy']=n;o['arbitration']=a['arbitration_mode']??o['arbitration']??inferArbitration(templateIntent(a,b));const p=await handleMerchantGuide({'intent':templateIntent(a,b),'guide_confirm':{'industry':a['industry'],'payment':k,'trust':o,'deliverables':variantDeliverables(a,i?.['traits']),...d&&Object['keys'](d)['length']>0x0?{'guard_resolutions':d}:{},...e?.['review_mode']?{'review_mode':e['review_mode']}:{},...e?.['reward_funding']!==undefined?{'reward_funding':e['reward_funding']}:{},...e?.['after_sales_mode']?{'after_sales_mode':e['after_sales_mode']}:{},...e?.['acceptance_mode']?{'acceptance_mode':e['acceptance_mode']}:{},...e?.['installment_mode']?{'installment_mode':e['installment_mode']}:{},...e?.['affiliate_mode']?{'affiliate_mode':e['affiliate_mode']}:{},...e?.['crowdfunding_mode']?{'crowdfunding_mode':e['crowdfunding_mode']}:{},...f?.['length']?{'sales':f}:{}},'template_override':{...a,'fee_params':g},'name_base':a['id']});if(a['allocator']['rows']?.['length'])p['template_allocator_rows']=a['allocator']['rows']['map'](s=>({...s}));p['template']={'id':a['id'],'archetype':a['archetype'],'recommended_role':a['recommended_role'],'fee_params':g},p['template_fee_param_landings']=buildFeeParamLandingTable(a,g);if(c&&Object['keys'](c)['length']>0x0)p['template_fee_overrides']=c;return h&&(p['fee_overrides_prefill']=h,p['next_action']=p['next_action']+'\x20Reward\x20pool\x20prefilled\x20from\x20your\x20request:\x20'+h['value']+'\x20—\x20adjust\x20via\x20fee_overrides.'),p;}export async function handleBenchmarkMigrationOperation(a){const b=strictParse(BenchmarkMigrationSchema,a,'benchmark_migration_operation\x20input'),c=b['industry']?resolveIndustryName(b['industry'])??b['industry']['toLowerCase']():undefined;let d;switch(b['action']){case'template_list':{const {templates:e,errors:f}=listTemplates(),g=c?e['filter'](i=>i['industry']===c):e,h=new Map(builtinTemplateDrift()['map'](i=>[i['template'],i['state']]));d={'action':'template_list','count':g['length'],'templates':g['map'](i=>({...templateSummary(i),'disk_state':h['get'](i['id'])??(BUILTIN_TEMPLATES['some'](j=>j['id']===i['id'])?'current':'untracked')})),'load_errors':f};break;}case'template_get':{const i=requireTemplate(b['template_id'],'template_get');d={'action':'template_get','template':{...i,...templateGetAids(i)}};break;}case'template_generate':{const j=requireTemplate(b['template_id'],'template_generate'),k=b['review_mode']??j['review_mode']??'none';if(k==='review_reward'&&!b['reward_funding'])return{'content':[{'type':'text','text':'template_generate\x20refused\x20—\x20no\x20plan\x20was\x20built.\x20Template\x20\x27'+j['id']+'\x27\x20resolves\x20to\x20review_mode\x20\x27review_reward\x27\x20(input'+(b['review_mode']?'':'\x20via\x20template\x20declaration')+'),\x20which\x20promises\x20buyers\x20a\x20claimable\x20review\x20bounty\x20—\x20an\x20unfunded\x20pool\x20must\x20not\x20ship.\x20Pass\x20reward_funding\x20(smallest-unit\x20string),\x20or\x20drop\x20the\x20mode\x20explicitly\x20(review_mode\x20\x27review\x27\x20keeps\x20the\x20review\x20rail\x20without\x20the\x20bounty;\x20\x27none\x27\x20removes\x20the\x20rail).'}],'structuredContent':{'result':{'type':'error','error':'review_mode\x20\x27'+k+'\x27\x20without\x20reward_funding\x20(INV-4)\x20on\x20template\x20\x27'+j['id']+'\x27.','error_code':'reward_funding_required','retryable':!![],'recovery_hint':'Pass\x20reward_funding\x20=\x20expected\x20orders\x20x\x20per-order\x20reward\x20(fee_param\x20review_reward_pool\x20is\x20the\x20planning\x20benchmark),\x20or\x20re-send\x20with\x20review_mode:\x27review\x27\x20(rail\x20only)\x20/\x20\x27none\x27\x20(no\x20rail).'},'message':'Refused:\x20a\x20review_reward\x20build\x20requires\x20a\x20funded\x20reward\x20pool.\x20See\x20recovery_hint.'}};if(!Array['isArray'](b['sales'])||b['sales']['length']===0x0)return{'content':[{'type':'text','text':'template_generate\x20refused\x20—\x20no\x20plan\x20was\x20built.\x20The\x20sellable\x20catalog\x20(sales)\x20is\x20required:\x20a\x20plan\x20without\x20one\x20publishes\x20a\x20Service\x20frozen\x20with\x20sales:\x20[]\x20and\x20every\x20order_new\x20aborts\x20(PLAN-SALES-01).\x20List\x20at\x20least\x20one\x20SKU:\x20{\x20name,\x20price,\x20quantity?,\x20wip_hash?\x20}\x20—\x20price\x20in\x20smallest\x20units.'}],'structuredContent':{'result':{'type':'error','error':'template_generate\x20without\x20a\x20non-empty\x20sales\x20catalog\x20(PLAN-SALES-01\x20upgraded\x20to\x20an\x20input\x20requirement,\x20amz9\x20A-2).','error_code':'sales_required','retryable':!![],'recovery_hint':'Pass\x20sales:\x20[{\x20name,\x20price,\x20quantity?,\x20wip_hash?\x20}]\x20—\x20one\x20entry\x20per\x20sellable\x20SKU\x20(wip_hash\x20from\x20the\x20wip_file\x20tool\x20upload).\x20migration_apply\x20is\x20unaffected:\x20it\x20confirms\x20an\x20already-reviewed\x20import.'},'message':'Refused:\x20template_generate\x20requires\x20a\x20sellable\x20catalog.\x20See\x20recovery_hint.'}};const l=scanTemplate(j);assertGenerateScanPassed(l,'template_generate');const m=await runGuide(j,b['description'],b['fee_overrides'],b['guard_resolutions'],{'review_mode':b['review_mode'],'reward_funding':b['reward_funding'],'after_sales_mode':b['after_sales_mode'],'acceptance_mode':b['acceptance_mode'],'installment_mode':b['installment_mode'],'affiliate_mode':b['affiliate_mode'],'crowdfunding_mode':b['crowdfunding_mode']},b['sales']);d=((()=>{const n=scanSummary(l,driftFace(j['id'])),o=buildVerdict(n,m);return{'action':'template_generate','template_id':j['id'],'scan':n,'plan':m,'verdict':o,'next_action':planNextAction(m,'template_generate',o)};})());break;}case'template_scan':{const n=requireTemplate(b['template_id'],'template_scan'),o=await templateScanDryRun(n);d={'action':'template_scan','scan':{...scanTemplate(n),'drift':driftFace(n['id']),'compile_dry_run':o}};break;}case'migration_import':{if(!b['description']||!b['description']['trim']())throw new Error('\x27description\x27\x20is\x20required\x20for\x20action=\x27migration_import\x27');const p=planMigration({'url':b['url'],'description':b['description'],'industry':c,'network':b['network']});if(!p)throw new Error('No\x20industry\x20template\x20matched\x20the\x20description.\x20Refine\x20the\x20description\x20or\x20pass\x20an\x20explicit\x20\x27industry\x27\x20hint.');d={'action':'migration_import','log':p,'next_action':'MigrationLog\x20ready.\x20Next:\x20call\x20action=\x27migration_review\x27\x20with\x20this\x20log\x20to\x20surface\x20the\x20mapped/unmapped/manual_review\x20items\x20for\x20user\x20confirmation.'};break;}case'migration_review':{if(!b['log'])throw new Error('\x27log\x27\x20is\x20required\x20for\x20action=\x27migration_review\x27');const q=b['log'],r=Array['isArray'](q['mapped'])?q['mapped']:[],s=Array['isArray'](q['unmapped'])?q['unmapped']:[],t=Array['isArray'](q['manual_review'])?q['manual_review']:[],u=q['risk_check']??{},v=q['source']?.['matched_template']??'',w=s['length']===0x0&&t['length']===0x0&&u['passed']===!![];d={'action':'migration_review','log':q,'review_summary':{'mapped_count':r['length'],'unmapped_count':s['length'],'manual_review_count':t['length'],'risk_passed':u['passed']===!![]},'next_action':w?'Review\x20clean.\x20Proceed:\x20call\x20action=\x27migration_apply\x27\x20with\x20template_id=\x27'+v+'\x27\x20to\x20produce\x20the\x20creation\x20plan\x20(network\x20defaults\x20to\x20testnet;\x20mainnet\x20requires\x20explicit\x20user\x20confirmation).':'Surface\x20the\x20'+s['length']+'\x20unmapped\x20and\x20'+t['length']+'\x20manual_review\x20items'+(u['passed']===!![]?'':'\x20plus\x20the\x20risk_check\x20findings')+'\x20to\x20the\x20user\x20for\x20a\x20decision\x20before\x20action=\x27migration_apply\x27\x20(template_id=\x27'+v+'\x27).'};break;}case'migration_apply':{const x=requireTemplate(b['template_id'],'migration_apply'),y=scanTemplate(x);assertScanPassed(y,'migration_apply');const z=b['network']??'testnet',A=await runGuide(x,b['description'],b['fee_overrides'],b['guard_resolutions'],{'review_mode':b['review_mode'],'reward_funding':b['reward_funding'],'after_sales_mode':b['after_sales_mode'],'acceptance_mode':b['acceptance_mode'],'installment_mode':b['installment_mode'],'affiliate_mode':b['affiliate_mode'],'crowdfunding_mode':b['crowdfunding_mode']},b['sales']);d=((()=>{const B=scanSummary(y,driftFace(x['id'])),C=buildVerdict(B,A);return{'action':'migration_apply','template_id':x['id'],'network':z,'scan':B,'plan':A,'verdict':C,'next_action':planNextAction(A,'migration_apply',C)};})());break;}default:throw new Error('Unknown\x20benchmark_migration_operation\x20action:\x20'+String(b['action']));}return{'content':[{'type':'text','text':JSON['stringify']({'result':d})}],'structuredContent':{'result':d}};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{listServices,getServiceInfo,toggle as
|
|
1
|
+
import{listServices,getServiceInfo,toggle as a496a,setEnabled as a496b,reset as a496c}from'../../config/index.js';import{judgmentStatus,setJudgmentOverride,clearJudgmentOverride,clearJudgmentOverrides,patchUserJudgmentDoc,readUserJudgmentDocView}from'../../config/judgment.js';import{strictParse}from'../../schema/index.js';import{ConfigOperationInputSchema}from'../../schema/config/index.js';export async function handleConfigOperation(a){const b=strictParse(ConfigOperationInputSchema,a,'config_operation\x20input'),{action:c,service:d,path:e,value:f}=b;let g;switch(c){case'list':g={'action':'list','services':listServices()};break;case'toggle':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20toggle');const h=d,i=getServiceInfo(h);if(!i)throw new Error('Unknown\x20service:\x20'+h+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');if(h==='confirm_gate'&&i['enabled'])throw new Error('confirm_gate\x20cannot\x20be\x20disabled\x20at\x20runtime.\x20'+'Set\x20WOWOK_CONFIRM_GATE=0\x20in\x20the\x20server\x20environment\x20and\x20restart\x20if\x20you\x20really\x20want\x20it\x20off.');const j=a496a(h);g={'action':'toggle','service':h,'enabled':j,'reminder':i['reminder']};break;}case'disable':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20disable');const k=d,l=getServiceInfo(k);if(!l)throw new Error('Unknown\x20service:\x20'+k+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');if(k==='confirm_gate')throw new Error('confirm_gate\x20cannot\x20be\x20disabled\x20at\x20runtime.\x20'+'Set\x20WOWOK_CONFIRM_GATE=0\x20in\x20the\x20server\x20environment\x20and\x20restart\x20if\x20you\x20really\x20want\x20it\x20off.');a496b(k,![]),g={'action':'disable','service':k,'enabled':![],'reminder':l['reminder']};break;}case'enable':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20enable');const m=d,n=getServiceInfo(m);if(!n)throw new Error('Unknown\x20service:\x20'+m+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');a496b(m,!![]),g={'action':'enable','service':m,'enabled':!![],'reminder':n['reminder']};break;}case'reset':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20reset');const o=d,p=getServiceInfo(o);if(!p)throw new Error('Unknown\x20service:\x20'+o+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');a496c(o),g={'action':'reset','service':o,'enabled':getServiceInfo(o)?.['enabled'],'reminder':p['reminder'],'reset':!![]};break;}case'info':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20info');const q=d,r=getServiceInfo(q);if(!r)throw new Error('Unknown\x20service:\x20'+q+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');g={'action':'info',...r};break;}case'judgment_list':g={'action':'judgment_list',...judgmentStatus()};break;case'judgment_set':{if(!e)throw new Error('\x27path\x27\x20param\x20is\x20required\x20for\x20judgment_set\x20(dotted,\x20e.g.\x20\x27evaluation.weights.trust_reviews\x27)');if(!('value'in b))throw new Error('\x27value\x27\x20param\x20is\x20required\x20for\x20judgment_set');const s=setJudgmentOverride(e,f);if(!s['ok'])throw new Error(s['error']);g={'action':'judgment_set','path':e,'value':f,'applied':!![]};break;}case'judgment_reset':{const t=e?clearJudgmentOverride(e)?0x1:0x0:clearJudgmentOverrides();g={'action':'judgment_reset',...e?{'path':e}:{},'cleared':t};break;}case'judgment_doc_read':{g={'action':'judgment_doc_read',...readUserJudgmentDocView()};break;}case'judgment_doc_patch':{if(!b['patch']||typeof b['patch']!=='object'||Array['isArray'](b['patch']))throw new Error('\x27patch\x27\x20param\x20is\x20required\x20for\x20judgment_doc_patch\x20(a\x20partial\x20judgment\x20document\x20object,\x20e.g.\x20{\x22evaluation\x22:\x20{\x22weights\x22:\x20{…}}})');g={'action':'judgment_doc_patch',...patchUserJudgmentDoc(b['patch'])};break;}default:throw new Error('Unknown\x20config_operation\x20action:\x20'+String(c));}return{'content':[{'type':'text','text':JSON['stringify']({'result':g})}],'structuredContent':{'result':g}};}
|