@wowok/agent-mcp 3.0.4 → 3.0.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/README.md +25 -20
- package/dist/customer/account-events.js +1 -1
- package/dist/evaluation/path-reasoning.d.ts +4 -2
- package/dist/evaluation/path-reasoning.js +1 -1
- package/dist/extensions/constraint-registry.d.ts +2 -2
- package/dist/extensions/constraint-registry.js +1 -1
- package/dist/extensions/custom-registry-file.d.ts +22 -0
- package/dist/extensions/custom-registry-file.js +1 -0
- package/dist/extensions/index.d.ts +2 -1
- package/dist/extensions/index.js +1 -1
- package/dist/extensions/industry-pack.d.ts +7 -0
- package/dist/extensions/industry-pack.js +1 -1
- package/dist/extensions/metric-registry.d.ts +2 -2
- package/dist/extensions/metric-registry.js +1 -1
- package/dist/extensions/modes.js +1 -1
- package/dist/extensions/registry.d.ts +2 -2
- package/dist/extensions/registry.js +1 -1
- package/dist/extensions/types.d.ts +4 -0
- package/dist/goal/GoalEngine.d.ts +13 -1
- package/dist/goal/GoalEngine.js +1 -1
- package/dist/goal/next-steps.d.ts +12 -0
- package/dist/goal/next-steps.js +1 -0
- package/dist/goal/pursue.d.ts +18 -0
- package/dist/goal/pursue.js +1 -0
- package/dist/goal/types.d.ts +72 -0
- package/dist/goal/types.js +1 -1
- package/dist/graph/onchain/analyze.d.ts +44 -0
- package/dist/graph/onchain/analyze.js +1 -0
- package/dist/graph/onchain/analyze.spec.d.ts +1 -0
- package/dist/graph/onchain/analyze.spec.js +1 -0
- package/dist/graph/onchain/anti-cheat.d.ts +39 -0
- package/dist/graph/onchain/anti-cheat.js +1 -0
- package/dist/graph/onchain/anti-cheat.spec.d.ts +1 -0
- package/dist/graph/onchain/anti-cheat.spec.js +1 -0
- package/dist/graph/onchain/dataplane.d.ts +44 -0
- package/dist/graph/onchain/dataplane.js +1 -0
- package/dist/graph/onchain/edge-schema.d.ts +60 -0
- package/dist/graph/onchain/edge-schema.js +1 -0
- package/dist/graph/onchain/expand.d.ts +4 -0
- package/dist/graph/onchain/expand.js +1 -0
- package/dist/graph/onchain/extract.d.ts +21 -0
- package/dist/graph/onchain/extract.js +1 -0
- package/dist/graph/onchain/index.d.ts +17 -0
- package/dist/graph/onchain/index.js +1 -0
- package/dist/graph/onchain/interest.d.ts +10 -0
- package/dist/graph/onchain/interest.js +1 -0
- package/dist/graph/onchain/interest.spec.d.ts +1 -0
- package/dist/graph/onchain/interest.spec.js +1 -0
- package/dist/graph/onchain/onchain.spec.d.ts +1 -0
- package/dist/graph/onchain/onchain.spec.js +1 -0
- package/dist/graph/onchain/order-status.d.ts +53 -0
- package/dist/graph/onchain/order-status.js +1 -0
- package/dist/graph/onchain/project-relationship.d.ts +3 -0
- package/dist/graph/onchain/project-relationship.js +1 -0
- package/dist/graph/onchain/sdk-batch.d.ts +123 -0
- package/dist/graph/onchain/sdk-batch.js +1 -0
- package/dist/graph/onchain/sdk-dataplane.d.ts +43 -0
- package/dist/graph/onchain/sdk-dataplane.js +1 -0
- package/dist/graph/onchain/strategy.d.ts +54 -0
- package/dist/graph/onchain/strategy.js +1 -0
- package/dist/graph/onchain/strategy.spec.d.ts +1 -0
- package/dist/graph/onchain/strategy.spec.js +1 -0
- package/dist/graph/onchain/types.d.ts +238 -0
- package/dist/graph/onchain/types.js +1 -0
- package/dist/graph/onchain/viewport.d.ts +5 -0
- package/dist/graph/onchain/viewport.js +1 -0
- package/dist/harness/recover.js +1 -1
- package/dist/index.js +1 -1
- package/dist/intent/enrich.js +1 -1
- package/dist/keeper/detectors.d.ts +1 -1
- package/dist/keeper/detectors.js +1 -1
- package/dist/knowledge/account-marks.js +1 -1
- package/dist/knowledge/allocation-risk.js +1 -1
- package/dist/knowledge/allocation-templates.js +1 -1
- package/dist/knowledge/anti-cheat.d.ts +2 -37
- package/dist/knowledge/anti-cheat.js +1 -1
- package/dist/knowledge/contract-invariants.js +1 -1
- package/dist/knowledge/getting-started.d.ts +37 -0
- package/dist/knowledge/getting-started.js +1 -0
- package/dist/knowledge/goal-completion.d.ts +12 -0
- package/dist/knowledge/goal-completion.js +1 -1
- package/dist/knowledge/guard-render.d.ts +1 -0
- package/dist/knowledge/guard-render.js +1 -1
- package/dist/knowledge/guard-risk.js +1 -1
- package/dist/knowledge/guard-submission-brief.d.ts +83 -0
- package/dist/knowledge/guard-submission-brief.js +1 -0
- package/dist/knowledge/guard-submission-prompt.d.ts +13 -0
- package/dist/knowledge/guard-submission-prompt.js +1 -1
- package/dist/knowledge/index.d.ts +10 -4
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/industry-strategy.d.ts +91 -0
- package/dist/knowledge/industry-strategy.js +1 -0
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/market-metrics.d.ts +14 -3
- package/dist/knowledge/market-metrics.js +1 -1
- package/dist/knowledge/migration-preflight.js +1 -1
- package/dist/knowledge/operation-dictionary.d.ts +1 -1
- package/dist/knowledge/payment-tracker.d.ts +63 -0
- package/dist/knowledge/payment-tracker.js +1 -0
- package/dist/knowledge/recipient-constraint.d.ts +160 -0
- package/dist/knowledge/recipient-constraint.js +1 -0
- package/dist/knowledge/safety-rules.d.ts +1 -1
- package/dist/knowledge/safety-rules.js +1 -1
- package/dist/knowledge/scenario-topology.d.ts +6 -1
- package/dist/knowledge/scenario-topology.js +1 -1
- package/dist/knowledge/service-risk-node.d.ts +3 -0
- package/dist/knowledge/service-risk-node.js +1 -0
- package/dist/knowledge/service-risk.d.ts +2 -0
- package/dist/knowledge/service-risk.js +1 -1
- package/dist/knowledge/service-templates.d.ts +2 -0
- package/dist/knowledge/service-templates.js +1 -1
- package/dist/knowledge/strategy-manuals.d.ts +17 -0
- package/dist/knowledge/strategy-manuals.js +1 -0
- package/dist/knowledge/supply-chain.d.ts +3 -1
- package/dist/knowledge/supply-chain.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/knowledge/workflow-guidance.d.ts +3 -118
- package/dist/knowledge/workflow-guidance.js +1 -1
- package/dist/knowledge/workspace-lists.d.ts +4 -0
- package/dist/knowledge/workspace-lists.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/monitor/ScopeResolver.js +1 -1
- package/dist/participation/arbitrator-interest.d.ts +2 -0
- package/dist/participation/arbitrator-interest.js +1 -1
- package/dist/participation/collaborator-interest.d.ts +2 -0
- package/dist/participation/collaborator-interest.js +1 -1
- package/dist/participation/customer-interest.d.ts +2 -0
- package/dist/participation/customer-interest.js +1 -1
- package/dist/participation/merchant-interest.d.ts +2 -0
- package/dist/participation/merchant-interest.js +1 -1
- package/dist/participation/radar-core.d.ts +15 -15
- package/dist/participation/radar-core.js +1 -1
- package/dist/participation/supplier-interest.d.ts +2 -0
- package/dist/participation/supplier-interest.js +1 -1
- package/dist/persona/analyzer.d.ts +2 -1
- package/dist/persona/bridge.d.ts +5 -1
- package/dist/persona/bridge.js +1 -1
- package/dist/persona/defaults.js +1 -1
- package/dist/persona/distill-goal.d.ts +7 -1
- package/dist/persona/distill-goal.js +1 -1
- package/dist/persona/index.d.ts +13 -3
- package/dist/persona/index.js +1 -1
- package/dist/persona/model.d.ts +12 -2
- package/dist/persona/model.js +1 -1
- package/dist/persona/overrides.d.ts +1 -0
- package/dist/persona/overrides.js +1 -1
- package/dist/persona/topology-focus.d.ts +29 -0
- package/dist/persona/topology-focus.js +1 -0
- package/dist/persona/types.d.ts +81 -0
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/context-assembly.js +1 -1
- package/dist/playbooks/service-build/machine-nodes.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/merchant-guide.d.ts +7 -0
- package/dist/playbooks/service-build/merchant-guide.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/pipeline-actions.d.ts +2 -2
- package/dist/playbooks/service-build/pipeline-actions.js +1 -1
- package/dist/playbooks/service-build/relationship-profile.d.ts +1 -0
- package/dist/playbooks/service-build/relationship-profile.js +1 -1
- package/dist/playbooks/service-build/risk-aggregator.js +1 -1
- package/dist/playbooks/service-build/service-panorama.d.ts +4 -0
- package/dist/playbooks/service-build/service-panorama.js +1 -1
- package/dist/playbooks/service-build/topology-query.d.ts +14 -0
- package/dist/playbooks/service-build/topology-query.js +1 -0
- package/dist/relationship/derivation.js +1 -1
- package/dist/role/index.d.ts +1 -0
- package/dist/role/index.js +1 -1
- package/dist/role/profiles.d.ts +26 -0
- package/dist/role/profiles.js +1 -0
- package/dist/safety/confirm-gate.d.ts +4 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/call/allocation.d.ts +6 -6
- package/dist/schema/call/allocation.js +1 -1
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +1 -1
- package/dist/schema/call/guard.d.ts +20 -20
- package/dist/schema/call/repository.js +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +4 -4
- package/dist/schema/call/service.js +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/employee/index.d.ts +7 -7
- package/dist/schema/evaluation/index.d.ts +26 -13
- package/dist/schema/evaluation/index.js +1 -1
- package/dist/schema/goal/index.d.ts +53 -17
- package/dist/schema/goal/index.js +1 -1
- package/dist/schema/goal/planning.d.ts +7 -7
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/index.js +1 -1
- package/dist/schema/industry-pack/index.d.ts +13 -6
- package/dist/schema/industry-pack/index.js +1 -1
- package/dist/schema/industry-pack/modes.d.ts +6 -6
- package/dist/schema/intent-radar/index.d.ts +16 -16
- package/dist/schema/local/index.d.ts +8 -4
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/messenger/index.d.ts +428 -72
- package/dist/schema/messenger/index.js +1 -1
- package/dist/schema/operations.d.ts +177 -34
- package/dist/schema/operations.js +1 -1
- package/dist/schema/persona/index.d.ts +15744 -1
- package/dist/schema/persona/index.js +1 -1
- package/dist/schema/query/bi.d.ts +891 -24
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.d.ts +168 -43
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-query/index.d.ts +16 -0
- package/dist/schema/schema-query/index.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/strategy-review/index.d.ts +137 -0
- package/dist/schema/strategy-review/index.js +1 -0
- package/dist/schema/trust/index.d.ts +6 -6
- package/dist/schema/workflow/index.d.ts +2 -2
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +8 -4
- package/dist/schemas/account_operation.schema.json +6 -2
- package/dist/schemas/bridge_operation.schema.json +10 -10
- package/dist/schemas/evaluation_operation.output.json +24 -0
- package/dist/schemas/evaluation_operation.schema.json +7 -7
- package/dist/schemas/goal_operation.schema.json +124 -0
- package/dist/schemas/guard2file.schema.json +2 -2
- package/dist/schemas/index.json +7 -1
- package/dist/schemas/industry_pack_operation.output.json +39 -0
- package/dist/schemas/local_mark_operation.schema.json +2 -2
- package/dist/schemas/machineNode2file.schema.json +2 -2
- package/dist/schemas/messenger_operation.output.json +934 -236
- package/dist/schemas/messenger_operation.schema.json +93 -242
- package/dist/schemas/onchain_events.schema.json +1 -1
- package/dist/schemas/onchain_operations.schema.json +54 -54
- package/dist/schemas/onchain_operations_allocation.schema.json +5 -5
- package/dist/schemas/onchain_operations_arbitration.schema.json +2 -2
- package/dist/schemas/onchain_operations_contact.schema.json +2 -2
- package/dist/schemas/onchain_operations_demand.schema.json +2 -2
- package/dist/schemas/onchain_operations_gen_passport.schema.json +2 -2
- package/dist/schemas/onchain_operations_gen_proof.schema.json +2 -2
- package/dist/schemas/onchain_operations_guard.schema.json +2 -2
- package/dist/schemas/onchain_operations_machine.schema.json +8 -8
- package/dist/schemas/onchain_operations_order.schema.json +2 -2
- package/dist/schemas/onchain_operations_payment.schema.json +3 -3
- package/dist/schemas/onchain_operations_permission.schema.json +2 -2
- package/dist/schemas/onchain_operations_personal.schema.json +2 -2
- package/dist/schemas/onchain_operations_progress.schema.json +2 -2
- package/dist/schemas/onchain_operations_proof.schema.json +2 -2
- package/dist/schemas/onchain_operations_repository.schema.json +5 -5
- package/dist/schemas/onchain_operations_reward.schema.json +2 -2
- package/dist/schemas/onchain_operations_service.schema.json +5 -5
- package/dist/schemas/onchain_operations_treasury.schema.json +4 -4
- package/dist/schemas/onchain_table_data.output.json +197 -13
- package/dist/schemas/onchain_table_data.schema.json +43 -43
- package/dist/schemas/persona_operation.output.json +37778 -262
- package/dist/schemas/persona_operation.schema.json +5960 -1
- package/dist/schemas/query_toolkit.output.json +1615 -10
- package/dist/schemas/query_toolkit.schema.json +232 -42
- package/dist/schemas/schema_query.schema.json +25 -1
- package/dist/schemas/strategy_review_operation.output.json +532 -0
- package/dist/schemas/strategy_review_operation.schema.json +66 -0
- package/dist/schemas/wowok_buildin_info.output.json +188 -6
- package/dist/schemas/wowok_buildin_info.schema.json +14 -0
- package/dist/strategy/collectors.d.ts +66 -0
- package/dist/strategy/collectors.js +1 -0
- package/dist/strategy/collectors.spec.d.ts +1 -0
- package/dist/strategy/collectors.spec.js +1 -0
- package/dist/strategy/index.d.ts +5 -0
- package/dist/strategy/index.js +1 -0
- package/dist/strategy/metrics.d.ts +20 -0
- package/dist/strategy/metrics.js +1 -0
- package/dist/strategy/review.d.ts +48 -0
- package/dist/strategy/review.js +1 -0
- package/dist/strategy/scorecard.d.ts +32 -0
- package/dist/strategy/scorecard.js +1 -0
- package/dist/strategy/store.d.ts +26 -0
- package/dist/strategy/store.js +1 -0
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/evaluation.js +1 -1
- package/dist/tools/handlers/goal.js +1 -1
- package/dist/tools/handlers/industry-pack.js +1 -1
- package/dist/tools/handlers/local.js +1 -1
- package/dist/tools/handlers/messenger.js +1 -1
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/permission.js +1 -1
- package/dist/tools/handlers/persona.js +1 -1
- package/dist/tools/handlers/query.d.ts +6 -0
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/schema-query.js +1 -1
- package/dist/tools/handlers/strategy-review.d.ts +2 -0
- package/dist/tools/handlers/strategy-review.js +1 -0
- package/dist/tools/handlers/watch.js +1 -1
- package/dist/tools/handlers/workflow.js +1 -1
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.js +1 -1
- package/dist/tools/registry/agent.js +1 -1
- package/dist/tools/registry/business.js +1 -1
- package/dist/tools/registry/local.js +1 -1
- package/dist/tools/registry/messenger.js +1 -1
- package/dist/tools/registry/onchain.js +1 -1
- package/dist/tools/registry/query.js +1 -1
- package/dist/tools/rules-hook.d.ts +2 -0
- package/dist/tools/rules-hook.js +1 -1
- package/dist/tools/shared.d.ts +2 -1
- package/dist/tools/shared.js +1 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +2 -2
|
@@ -206,12 +206,24 @@
|
|
|
206
206
|
"description": "Query ID"
|
|
207
207
|
}
|
|
208
208
|
],
|
|
209
|
-
"description": "ID of the guard instruction or query"
|
|
209
|
+
"description": "ID of the guard instruction (node opcode) or object query selector (1000-2255 U16, used only inside a query node)"
|
|
210
210
|
},
|
|
211
211
|
"description": {
|
|
212
212
|
"type": "string",
|
|
213
213
|
"description": "Description"
|
|
214
214
|
},
|
|
215
|
+
"kind": {
|
|
216
|
+
"description": "\"node\" = builds a Guard root node; \"query\" = query-id usable only inside a {\"type\":\"query\"} node",
|
|
217
|
+
"type": "string",
|
|
218
|
+
"enum": [
|
|
219
|
+
"node",
|
|
220
|
+
"query"
|
|
221
|
+
]
|
|
222
|
+
},
|
|
223
|
+
"node": {
|
|
224
|
+
"description": "Exact root-node JSON for special entries (identifier / query_wowok_object / context_*) whose catalog name is not itself a root node type",
|
|
225
|
+
"type": "string"
|
|
226
|
+
},
|
|
215
227
|
"returnType": {
|
|
216
228
|
"description": "Return type for guard instruction",
|
|
217
229
|
"anyOf": [
|
|
@@ -1195,7 +1207,7 @@
|
|
|
1195
1207
|
"description"
|
|
1196
1208
|
],
|
|
1197
1209
|
"additionalProperties": false,
|
|
1198
|
-
"description": "Guard item - either a guard instruction or a guard query"
|
|
1210
|
+
"description": "Guard item - either a guard instruction (kind=\"node\": build a root node) or a guard query (kind=\"query\": use its id inside a query node)"
|
|
1199
1211
|
},
|
|
1200
1212
|
"description": "Guard instructions result"
|
|
1201
1213
|
}
|
|
@@ -1424,16 +1436,21 @@
|
|
|
1424
1436
|
"properties": {
|
|
1425
1437
|
"url": {
|
|
1426
1438
|
"type": "string",
|
|
1427
|
-
"description": "WOW
|
|
1439
|
+
"description": "WOW airdrop page — single source of truth for the CURRENT round (status, pool, dates, eligibility). Fetch/open it for live details; do not rely on embedded constants because the facts change between rounds."
|
|
1428
1440
|
},
|
|
1429
|
-
"
|
|
1441
|
+
"refer_url": {
|
|
1430
1442
|
"type": "string",
|
|
1431
|
-
"description": "
|
|
1443
|
+
"description": "WOW airdrop referral-program page"
|
|
1444
|
+
},
|
|
1445
|
+
"note": {
|
|
1446
|
+
"type": "string",
|
|
1447
|
+
"description": "Instruction: live round details are published only on the airdrop page and intentionally not hardcoded; if the user needs detail beyond the link, fetch the page and summarize it."
|
|
1432
1448
|
}
|
|
1433
1449
|
},
|
|
1434
1450
|
"required": [
|
|
1435
1451
|
"url",
|
|
1436
|
-
"
|
|
1452
|
+
"refer_url",
|
|
1453
|
+
"note"
|
|
1437
1454
|
],
|
|
1438
1455
|
"additionalProperties": false
|
|
1439
1456
|
},
|
|
@@ -1808,6 +1825,171 @@
|
|
|
1808
1825
|
"result"
|
|
1809
1826
|
],
|
|
1810
1827
|
"additionalProperties": false
|
|
1828
|
+
},
|
|
1829
|
+
{
|
|
1830
|
+
"type": "object",
|
|
1831
|
+
"properties": {
|
|
1832
|
+
"info": {
|
|
1833
|
+
"type": "string",
|
|
1834
|
+
"const": "getting started"
|
|
1835
|
+
},
|
|
1836
|
+
"result": {
|
|
1837
|
+
"type": "object",
|
|
1838
|
+
"properties": {
|
|
1839
|
+
"skills": {
|
|
1840
|
+
"type": "object",
|
|
1841
|
+
"properties": {
|
|
1842
|
+
"what": {
|
|
1843
|
+
"type": "string",
|
|
1844
|
+
"description": "What the WoWok Skills are and how they relate to this MCP server"
|
|
1845
|
+
},
|
|
1846
|
+
"package": {
|
|
1847
|
+
"type": "string",
|
|
1848
|
+
"description": "npm package name of the companion skills"
|
|
1849
|
+
},
|
|
1850
|
+
"recommended": {
|
|
1851
|
+
"type": "boolean",
|
|
1852
|
+
"description": "Whether installing the skills is recommended by the project"
|
|
1853
|
+
},
|
|
1854
|
+
"install_command": {
|
|
1855
|
+
"type": "string",
|
|
1856
|
+
"description": "Command that installs skills into every detected AI client AND registers this MCP server (postinstall is idempotent)"
|
|
1857
|
+
},
|
|
1858
|
+
"doctor_command": {
|
|
1859
|
+
"type": "string",
|
|
1860
|
+
"description": "Authoritative per-client install + MCP registration check"
|
|
1861
|
+
},
|
|
1862
|
+
"repair_command": {
|
|
1863
|
+
"type": "string",
|
|
1864
|
+
"description": "Command that rewrites every install target (use after old/broken installs)"
|
|
1865
|
+
},
|
|
1866
|
+
"detection": {
|
|
1867
|
+
"type": "object",
|
|
1868
|
+
"properties": {
|
|
1869
|
+
"status": {
|
|
1870
|
+
"type": "string",
|
|
1871
|
+
"enum": [
|
|
1872
|
+
"detected",
|
|
1873
|
+
"not_detected"
|
|
1874
|
+
],
|
|
1875
|
+
"description": "Best-effort scan of standard client skill roots on THIS machine"
|
|
1876
|
+
},
|
|
1877
|
+
"detected_roots": {
|
|
1878
|
+
"type": "array",
|
|
1879
|
+
"items": {
|
|
1880
|
+
"type": "string"
|
|
1881
|
+
},
|
|
1882
|
+
"description": "Skill roots that contained a wowok-* skill directory or the .wowok-skills.json manifest"
|
|
1883
|
+
}
|
|
1884
|
+
},
|
|
1885
|
+
"required": [
|
|
1886
|
+
"status",
|
|
1887
|
+
"detected_roots"
|
|
1888
|
+
],
|
|
1889
|
+
"additionalProperties": false,
|
|
1890
|
+
"description": "Best-effort local skills detection"
|
|
1891
|
+
},
|
|
1892
|
+
"detection_note": {
|
|
1893
|
+
"type": "string",
|
|
1894
|
+
"description": "Why detection is best-effort and when to trust doctor instead"
|
|
1895
|
+
},
|
|
1896
|
+
"roles": {
|
|
1897
|
+
"type": "array",
|
|
1898
|
+
"items": {
|
|
1899
|
+
"type": "string"
|
|
1900
|
+
},
|
|
1901
|
+
"description": "Role-based skill names the package installs"
|
|
1902
|
+
}
|
|
1903
|
+
},
|
|
1904
|
+
"required": [
|
|
1905
|
+
"what",
|
|
1906
|
+
"package",
|
|
1907
|
+
"recommended",
|
|
1908
|
+
"install_command",
|
|
1909
|
+
"doctor_command",
|
|
1910
|
+
"repair_command",
|
|
1911
|
+
"detection",
|
|
1912
|
+
"detection_note",
|
|
1913
|
+
"roles"
|
|
1914
|
+
],
|
|
1915
|
+
"additionalProperties": false,
|
|
1916
|
+
"description": "Companion Skills layer orientation"
|
|
1917
|
+
},
|
|
1918
|
+
"cold_start": {
|
|
1919
|
+
"type": "object",
|
|
1920
|
+
"properties": {
|
|
1921
|
+
"ready_seconds": {
|
|
1922
|
+
"type": "number",
|
|
1923
|
+
"description": "Approximate upper bound of first-call startup latency"
|
|
1924
|
+
},
|
|
1925
|
+
"note": {
|
|
1926
|
+
"type": "string",
|
|
1927
|
+
"description": "Why the first call after boot is slow and why it is not a failure"
|
|
1928
|
+
}
|
|
1929
|
+
},
|
|
1930
|
+
"required": [
|
|
1931
|
+
"ready_seconds",
|
|
1932
|
+
"note"
|
|
1933
|
+
],
|
|
1934
|
+
"additionalProperties": false,
|
|
1935
|
+
"description": "Cold-start readiness window"
|
|
1936
|
+
},
|
|
1937
|
+
"common_goals": {
|
|
1938
|
+
"type": "array",
|
|
1939
|
+
"items": {
|
|
1940
|
+
"type": "object",
|
|
1941
|
+
"properties": {
|
|
1942
|
+
"goal": {
|
|
1943
|
+
"type": "string",
|
|
1944
|
+
"description": "A common user goal"
|
|
1945
|
+
},
|
|
1946
|
+
"skills": {
|
|
1947
|
+
"type": "array",
|
|
1948
|
+
"items": {
|
|
1949
|
+
"type": "string"
|
|
1950
|
+
},
|
|
1951
|
+
"description": "Role skills carrying the playbook for this goal"
|
|
1952
|
+
},
|
|
1953
|
+
"tools": {
|
|
1954
|
+
"type": "array",
|
|
1955
|
+
"items": {
|
|
1956
|
+
"type": "string"
|
|
1957
|
+
},
|
|
1958
|
+
"description": "MCP sub-tools most often used for this goal"
|
|
1959
|
+
}
|
|
1960
|
+
},
|
|
1961
|
+
"required": [
|
|
1962
|
+
"goal",
|
|
1963
|
+
"skills",
|
|
1964
|
+
"tools"
|
|
1965
|
+
],
|
|
1966
|
+
"additionalProperties": false
|
|
1967
|
+
},
|
|
1968
|
+
"description": "Which sub-tools and skills matter for common goals"
|
|
1969
|
+
},
|
|
1970
|
+
"first_calls": {
|
|
1971
|
+
"type": "array",
|
|
1972
|
+
"items": {
|
|
1973
|
+
"type": "string"
|
|
1974
|
+
},
|
|
1975
|
+
"description": "Suggested orientation calls for a freshly connected agent"
|
|
1976
|
+
}
|
|
1977
|
+
},
|
|
1978
|
+
"required": [
|
|
1979
|
+
"skills",
|
|
1980
|
+
"cold_start",
|
|
1981
|
+
"common_goals",
|
|
1982
|
+
"first_calls"
|
|
1983
|
+
],
|
|
1984
|
+
"additionalProperties": false,
|
|
1985
|
+
"description": "Getting-started orientation (companion Skills, install/doctor commands, local detection, cold-start window, common-goal tool map)"
|
|
1986
|
+
}
|
|
1987
|
+
},
|
|
1988
|
+
"required": [
|
|
1989
|
+
"info",
|
|
1990
|
+
"result"
|
|
1991
|
+
],
|
|
1992
|
+
"additionalProperties": false
|
|
1811
1993
|
}
|
|
1812
1994
|
],
|
|
1813
1995
|
"description": "Protocol info result"
|
|
@@ -618,6 +618,20 @@
|
|
|
618
618
|
],
|
|
619
619
|
"additionalProperties": false,
|
|
620
620
|
"description": "Universal Template query - returns cross-industry baselines and red lines (anti-cheat baseline, pricing/governance red lines, quality signals, consumer journey, north-star metric) that hold across ALL industries (K3 17 §2)."
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
"type": "object",
|
|
624
|
+
"properties": {
|
|
625
|
+
"info": {
|
|
626
|
+
"type": "string",
|
|
627
|
+
"const": "getting started"
|
|
628
|
+
}
|
|
629
|
+
},
|
|
630
|
+
"required": [
|
|
631
|
+
"info"
|
|
632
|
+
],
|
|
633
|
+
"additionalProperties": false,
|
|
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."
|
|
621
635
|
}
|
|
622
636
|
]
|
|
623
637
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { ENTRYPOINT } from "@wowok/wowok";
|
|
2
|
+
import type { Industry } from "../persona/types.js";
|
|
3
|
+
import { type MetricSourceId, type StrategyMetricId } from "./metrics.js";
|
|
4
|
+
export interface ScorecardOrderEvidence {
|
|
5
|
+
id: string;
|
|
6
|
+
customer: string;
|
|
7
|
+
time: number;
|
|
8
|
+
disputed?: boolean;
|
|
9
|
+
status?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface CollectContext {
|
|
12
|
+
account: string;
|
|
13
|
+
industry: Industry;
|
|
14
|
+
network?: ENTRYPOINT;
|
|
15
|
+
limit?: number;
|
|
16
|
+
no_cache?: boolean;
|
|
17
|
+
orders?: ScorecardOrderEvidence[];
|
|
18
|
+
due_diligence?: number;
|
|
19
|
+
reviews_count?: number;
|
|
20
|
+
arbitration_object?: string;
|
|
21
|
+
discovery_terms?: string[];
|
|
22
|
+
}
|
|
23
|
+
export type MetricValueEntry = number | {
|
|
24
|
+
value?: number;
|
|
25
|
+
note?: string;
|
|
26
|
+
};
|
|
27
|
+
export type MetricValueMap = Record<string, MetricValueEntry>;
|
|
28
|
+
export interface MetricFetcher {
|
|
29
|
+
id: MetricSourceId;
|
|
30
|
+
fetch(ctx: CollectContext): Promise<MetricValueMap>;
|
|
31
|
+
}
|
|
32
|
+
export type CollectedMetricStatus = "ok" | "unavailable" | "error";
|
|
33
|
+
export interface CollectedMetric {
|
|
34
|
+
id: StrategyMetricId;
|
|
35
|
+
source: MetricSourceId;
|
|
36
|
+
status: CollectedMetricStatus;
|
|
37
|
+
value?: number;
|
|
38
|
+
note?: string;
|
|
39
|
+
collected_at: number;
|
|
40
|
+
}
|
|
41
|
+
export interface ScorecardCollection {
|
|
42
|
+
account: string;
|
|
43
|
+
industry: string;
|
|
44
|
+
network: ENTRYPOINT;
|
|
45
|
+
collected_at: number;
|
|
46
|
+
metrics: CollectedMetric[];
|
|
47
|
+
unavailable: StrategyMetricId[];
|
|
48
|
+
errors: Array<{
|
|
49
|
+
id: StrategyMetricId;
|
|
50
|
+
error: string;
|
|
51
|
+
}>;
|
|
52
|
+
}
|
|
53
|
+
export interface ShopOrderResolution {
|
|
54
|
+
orders: ScorecardOrderEvidence[];
|
|
55
|
+
service_count: number;
|
|
56
|
+
observed_total: number;
|
|
57
|
+
truncated: boolean;
|
|
58
|
+
unknown_workflow: number;
|
|
59
|
+
}
|
|
60
|
+
export declare function resolveShopOrderEvidence(ctx: CollectContext): Promise<ShopOrderResolution>;
|
|
61
|
+
export declare const DEFAULT_METRIC_FETCHERS: MetricFetcher[];
|
|
62
|
+
export declare function collectScorecard(ctx: CollectContext, opts?: {
|
|
63
|
+
fetchers?: MetricFetcher[];
|
|
64
|
+
metricIds?: StrategyMetricId[];
|
|
65
|
+
resolveOrders?: (ctx: CollectContext) => Promise<ScorecardOrderEvidence[]>;
|
|
66
|
+
}): Promise<ScorecardCollection>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Config}from'@wowok/wowok/w/local';import{SdkDataPlane,expandTopology,orderCompletionInGraph}from'../graph/onchain/index.js';import{computeOrderFlow,computeMarketMetrics}from'../knowledge/market-metrics.js';import{computeJourneyFunnel,buildCustomerRelationships}from'../knowledge/market-operations.js';import{enumerateServices}from'../knowledge/jsonrpc-enum.js';import{assessArbitration}from'../evaluation/builtins/arbitration-score.js';import{runAccountEventWatchers}from'../customer/account-events.js';import{STRATEGY_METRIC_CATALOG}from'./metrics.js';const COMPLETED_RE=/completed|closed|finished|done/i;function toCustomerOrders(a){return a['map'](b=>({'id':b['id'],'customer':b['customer'],'time':b['time'],'disputed':b['disputed']??![]}));}const INDUSTRY_DISCOVERY_TERMS={'education':['education','tutor','course','class','learning','培训','课'],'rental':['rental','rent','lease','租'],'freelance':['freelance','agency','studio','consulting','design'],'subscription':['subscription','membership','member','订阅'],'travel':['travel','tour','trip','游'],'retail':['shop','store','retail','boutique','商城','店']};function discoveryTermsFor(a){const b=a['discovery_terms']??INDUSTRY_DISCOVERY_TERMS[a['industry']]??[a['industry']];return b['length']?b:[a['industry']];}const SHOP_ORDER_WINDOW_DEFAULT=0x64,MAX_PERMISSIONS_RESOLVED=0xa,MAX_SERVICES_RESOLVED=0x14,MAX_MACHINE_NODES=0xc8;export async function resolveShopOrderEvidence(a){const b=a['network']??await Config['Instance']()['network_get'](),c=Math['max'](0x1,a['limit']??SHOP_ORDER_WINDOW_DEFAULT),d=new SdkDataPlane(b,{'noCache':a['no_cache']}),f=await expandTopology(d,{'network':b,'seed':a['account'],'budget':{'maxDepth':0x4,'maxNodes':0x4b0,'maxFanoutPerNode':c,'maxRpcs':0x64,'perKindCaps':{'eoa.permission':MAX_PERMISSIONS_RESOLVED,'permission.core_binding':MAX_SERVICES_RESOLVED,'service.order':c,'machine.node':MAX_MACHINE_NODES}},'edges':{'schemas':['eoa.permission','permission.core_binding','service.order','order.machine','order.progress'],'tableEdges':['machine.node']}}),g=new Set();for(const i of f['edges']){if(i['schema']!=='permission.core_binding')continue;if(f['nodes']['get'](i['to']['toLowerCase']())?.['objectType']==='Service')g['add'](i['to']['toLowerCase']());}if(g['size']===0x0&&f['gaps']['length']>0x0)throw new Error('shop\x20topology\x20unreadable\x20for\x20'+a['account']+':\x20'+f['gaps']['slice'](0x0,0x3)['join'](';\x20'));const h=[];for(const j of f['edges']){if(j['schema']!=='service.order'||!g['has'](j['from']['toLowerCase']()))continue;const k=f['nodes']['get'](j['to']['toLowerCase']());if(k?.['objectType']!=='Order'||!k['raw'])continue;const l=k['raw']['data']??k['raw'];h['push']({'id':j['to'],'customer':String(l['builder']??''),'time':Number(BigInt(l['time']??0x0)),'disputed':Array['isArray'](l['dispute'])&&l['dispute']['length']>0x0,'status':orderCompletionInGraph(f,j['to'])['status']});}return h['sort']((m,n)=>n['time']-m['time']),{'orders':h['slice'](0x0,c),'service_count':g['size'],'observed_total':h['length'],'truncated':h['length']>c,'unknown_workflow':h['filter'](m=>m['status']==='unknown')['length']};}const marketOperationsFetcher={'id':'market_operations',async 'fetch'(a){const b={},c=a['orders']??[];if(c['length']===0x0)return b;const d=c['filter'](i=>i['status']?COMPLETED_RE['test'](i['status']):![])['length'],e=computeJourneyFunnel({'due_diligence':a['due_diligence']??0x0,'orders':c['length'],'completed':d,'reviews':a['reviews_count']??0x0});b['order_count']=e['orders'],b['completed_count']=e['completed'],b['completion_rate']=e['order_completion_rate'];if(e['due_diligence']>0x0)b['dd_to_order_rate']=e['dd_to_order_rate'];const f=buildCustomerRelationships(toCustomerOrders(c)),g=f['filter'](i=>i['order_count']>=0x2)['length'];b['repeat_customer_rate']=f['length']>0x0?g/f['length']:0x0;const h=c['filter'](i=>i['disputed'])['length'];return b['dispute_rate']=h/c['length'],b;}},orderFlowFetcher={'id':'order_flow',async 'fetch'(a){const b=a['network']??await Config['Instance']()['network_get'](),c=await computeOrderFlow(b,{'noCache':a['no_cache'],'maxPages':Math['max'](0x1,Math['ceil']((a['limit']??0x64)/0x32))}),d=c['gmv_by_coin']['filter'](f=>f['coin']!=='unknown');let e;if(d['length']===0x1&&c['unclassified_orders']===0x0){const f=BigInt(d[0x0]['amount']);e=f<=BigInt(Number['MAX_SAFE_INTEGER'])?Number(f):{'note':'exact\x20'+d[0x0]['coin']+'\x20GMV\x20'+d[0x0]['amount']+'\x20base\x20units\x20exceeds\x202^53'};}else{const g=c['gmv_by_coin']['map'](h=>h['coin']+'='+h['amount']+'\x20('+h['orders']+'\x20orders)')['join'](';\x20');e={'note':'order\x20volume\x20spans\x20multiple/unresolved\x20coin\x20types\x20and\x20cannot\x20be\x20summed\x20into\x20one\x20GMV\x20'+('('+c['window']+');\x20per-coin\x20base-unit\x20volume:\x20'+(g||'none'))};}return{'market_recent_orders':c['order_count'],'market_recent_gmv':e};}},marketMetricsFetcher={'id':'market_metrics',async 'fetch'(a){const b=a['network']??await Config['Instance']()['network_get'](),c=await computeMarketMetrics(b,a['no_cache']),d={'market_active_services':c['active_services']};if(c['supply_demand_ratio']!==null)d['supply_demand_ratio']=c['supply_demand_ratio'];return d;}},discoverServicesFetcher={'id':'discover_services',async 'fetch'(a){const b=discoveryTermsFor(a)['map'](g=>g['toLowerCase']()),c=a['network']??await Config['Instance']()['network_get'](),d=await enumerateServices(c,{'max_objects':a['limit']??0xc8,'no_cache':a['no_cache']}),e=d['services']['filter'](g=>{const h=((g['name']??'')+'\x20'+(g['json']?.['description']??'')+'\x20'+(g['json']?.['category']??''))['toLowerCase']();return b['some'](i=>h['includes'](i));}),f={'category_enumerated_count':d['total_enumerated']};return f['competitor_count']=e['length']>0x0?e['length']:{'note':'no\x20enumerated\x20service\x20matched\x20the\x20discovery\x20terms;\x20category\x20density\x20reported\x20as\x20category_enumerated_count'},f;}},arbitrationScoreFetcher={'id':'arbitration_score',async 'fetch'(a){const b={};if(!a['arbitration_object'])return b;const c=await assessArbitration({'arbitration':{'object':a['arbitration_object']}});return b['arbitration_trust_score']=c['combined'],b;}},accountEventsFetcher={'id':'account_events',async 'fetch'(a){const b=await runAccountEventWatchers({'account':a['account'],'network':a['network']??await Config['Instance']()['network_get'](),'order_history':(a['orders']??[])['map'](c=>({'id':c['id'],'status':c['status']??''}))});return{'open_attention_count':b['length']};}};export const DEFAULT_METRIC_FETCHERS=[marketOperationsFetcher,orderFlowFetcher,marketMetricsFetcher,discoverServicesFetcher,arbitrationScoreFetcher,accountEventsFetcher];export async function collectScorecard(a,b={}){const c=b['fetchers']??DEFAULT_METRIC_FETCHERS,d=new Set(b['metricIds']??STRATEGY_METRIC_CATALOG['map'](n=>n['id'])),e=Date['now'](),f=[],g=[],h=[],i=new Map();for(const m of STRATEGY_METRIC_CATALOG){if(!d['has'](m['id']))continue;const n=i['get'](m['source'])??[];n['push']({'id':m['id']}),i['set'](m['source'],n);}let j=a;const k=['market_operations','account_events'];if(!a['orders']&&k['some'](o=>i['has'](o)))try{const o=b['resolveOrders']??(q=>resolveShopOrderEvidence(q)['then'](s=>s['orders'])),p=await o(a);p['length']>0x0&&(j={...a,'orders':p});}catch{}await Promise['all']([...i['entries']()]['map'](async([q,r])=>{const s=c['find'](v=>v['id']===q);let t={},u=null;if(!s)u='no\x20fetcher\x20registered\x20for\x20source\x20\x27'+q+'\x27';else try{t=await s['fetch'](j);}catch(v){u=v['message'];}for(const w of r){const x=t[w['id']],y=typeof x==='number'?x:x?.['value'],z=typeof x==='number'?undefined:x?.['note'];if(u)f['push']({'id':w['id'],'source':q,'status':'error','note':u,'collected_at':e}),h['push']({'id':w['id'],'error':u});else typeof y==='number'&&Number['isFinite'](y)?f['push']({'id':w['id'],'source':q,'status':'ok','value':y,'note':z,'collected_at':e}):(f['push']({'id':w['id'],'source':q,'status':'unavailable','note':z,'collected_at':e}),g['push'](w['id']));}}));const l=new Map(STRATEGY_METRIC_CATALOG['map']((q,r)=>[q['id'],r]));return f['sort']((q,r)=>(l['get'](q['id'])??0x0)-(l['get'](r['id'])??0x0)),{'account':a['account'],'industry':a['industry'],'network':a['network']??await Config['Instance']()['network_get'](),'collected_at':e,'metrics':f,'unavailable':g,'errors':h};}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{describe,it,expect}from'vitest';import{collectScorecard}from'./collectors.js';describe('collectScorecard\x20—\x20shop\x20operations\x20metrics',()=>{const a={'account':'0xshop1','industry':'retail'},b=['order_count','completed_count','completion_rate','repeat_customer_rate','dispute_rate','dd_to_order_rate'],c=[{'id':'o1','customer':'A','time':0x3e8,'status':'completed'},{'id':'o2','customer':'A','time':0x7d0,'status':'completed'},{'id':'o3','customer':'B','time':0xbb8,'status':'completed'},{'id':'o4','customer':'C','time':0xfa0,'status':'in_progress','disputed':!![]},{'id':'o5','customer':'D','time':0x1388,'status':'unknown'}];it('computes\x20the\x20six\x20shop\x20metrics\x20from\x20resolved\x20chain\x20evidence',async()=>{const d=await collectScorecard(a,{'metricIds':b,'resolveOrders':async()=>c}),e=new Map(d['metrics']['map'](f=>[f['id'],f]));expect(e['get']('order_count')['value'])['toBe'](0x5),expect(e['get']('completed_count')['value'])['toBe'](0x3),expect(e['get']('completion_rate')['value'])['toBeCloseTo'](0.6,0x5),expect(e['get']('repeat_customer_rate')['value'])['toBeCloseTo'](0.25,0x5),expect(e['get']('dispute_rate')['value'])['toBeCloseTo'](0.2,0x5),expect(e['get']('dd_to_order_rate')['status'])['toBe']('unavailable');}),it('does\x20not\x20invoke\x20the\x20resolver\x20when\x20explicit\x20evidence\x20is\x20supplied',async()=>{let d=![];await collectScorecard({...a,'orders':c['slice'](0x0,0x1)},{'metricIds':['order_count'],'resolveOrders':async()=>{return d=!![],[];}}),expect(d)['toBe'](![]);}),it('degrades\x20shop\x20metrics\x20to\x20unavailable\x20when\x20the\x20resolver\x20fails',async()=>{const d=await collectScorecard(a,{'metricIds':['order_count'],'resolveOrders':async()=>{throw new Error('rpc\x20down');}}),e=d['metrics']['find'](f=>f['id']==='order_count');expect(e['status'])['toBe']('unavailable'),expect(d['unavailable'])['toContain']('order_count');});}),describe('collectScorecard\x20—\x20fetcher\x20envelopes',()=>{const a={'account':'0xshop2','industry':'retail','orders':[{'id':'o1','customer':'A','time':0x1,'status':'completed'}]};it('accepts\x20value\x20envelopes\x20with\x20notes\x20and\x20treats\x20note-only\x20envelopes\x20as\x20unavailable',async()=>{const b={'id':'market_operations',async 'fetch'(){return{'order_count':{'value':0x7,'note':'capped\x20recent\x20window'},'completed_count':{'note':'workflow\x20unverifiable'}};}},c=await collectScorecard(a,{'metricIds':['order_count','completed_count'],'fetchers':[b]}),d=new Map(c['metrics']['map'](e=>[e['id'],e]));expect(d['get']('order_count')['status'])['toBe']('ok'),expect(d['get']('order_count')['value'])['toBe'](0x7),expect(d['get']('order_count')['note'])['toContain']('capped'),expect(d['get']('completed_count')['status'])['toBe']('unavailable'),expect(d['get']('completed_count')['note'])['toContain']('unverifiable');});});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { STRATEGY_METRIC_CATALOG, getMetricDef, metricsBySource, listMetricSources, type MetricDef, type MetricSourceId, type MetricUnit, type MetricDirection, type StrategyMetricId, } from "./metrics.js";
|
|
2
|
+
export { DEFAULT_METRIC_FETCHERS, collectScorecard, type CollectContext, type ScorecardOrderEvidence, type MetricFetcher, type MetricValueMap, type CollectedMetric, type CollectedMetricStatus, type ScorecardCollection, } from "./collectors.js";
|
|
3
|
+
export { getScorecardStore, setScorecardStore, SqliteScorecardStore, type SnapshotStore, type ScorecardSnapshot, } from "./store.js";
|
|
4
|
+
export { scoreScorecard, scoreMetricValue, computeMetricDeltas, describeDelta, type ScorecardScore, type MetricScore, type MetricDelta, type DeltaDirection, } from "./scorecard.js";
|
|
5
|
+
export { buildReview, reviewCadenceDays, isReviewDue, reviewNudgeLine, type StrategyReview, type StrategyProposal, type ReviewCadence, type BuildReviewOptions, } from "./review.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{STRATEGY_METRIC_CATALOG,getMetricDef,metricsBySource,listMetricSources}from'./metrics.js';export{DEFAULT_METRIC_FETCHERS,collectScorecard}from'./collectors.js';export{getScorecardStore,setScorecardStore,SqliteScorecardStore}from'./store.js';export{scoreScorecard,scoreMetricValue,computeMetricDeltas,describeDelta}from'./scorecard.js';export{buildReview,reviewCadenceDays,isReviewDue,reviewNudgeLine}from'./review.js';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { StrategicPosture } from "../persona/types.js";
|
|
2
|
+
export type MetricSourceId = "market_operations" | "order_flow" | "market_metrics" | "discover_services" | "arbitration_score" | "account_events";
|
|
3
|
+
export type MetricUnit = "count" | "rate" | "ratio" | "score" | "token_units";
|
|
4
|
+
export type MetricDirection = "higher_better" | "lower_better";
|
|
5
|
+
export type StrategyMetricId = "order_count" | "completed_count" | "completion_rate" | "repeat_customer_rate" | "dispute_rate" | "dd_to_order_rate" | "market_recent_orders" | "market_recent_gmv" | "supply_demand_ratio" | "market_active_services" | "competitor_count" | "category_enumerated_count" | "arbitration_trust_score" | "open_attention_count";
|
|
6
|
+
export interface MetricDef {
|
|
7
|
+
id: StrategyMetricId;
|
|
8
|
+
label: string;
|
|
9
|
+
source: MetricSourceId;
|
|
10
|
+
unit: MetricUnit;
|
|
11
|
+
direction: MetricDirection;
|
|
12
|
+
weight: Record<StrategicPosture, number>;
|
|
13
|
+
good_threshold?: number;
|
|
14
|
+
bad_threshold?: number;
|
|
15
|
+
description: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const STRATEGY_METRIC_CATALOG: MetricDef[];
|
|
18
|
+
export declare function getMetricDef(id: StrategyMetricId): MetricDef | undefined;
|
|
19
|
+
export declare function metricsBySource(source: MetricSourceId): MetricDef[];
|
|
20
|
+
export declare function listMetricSources(): MetricSourceId[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const w=(a,b,c)=>({'volume':a,'balanced':b,'margin':c});export const STRATEGY_METRIC_CATALOG=[{'id':'order_count','label':'Order\x20count\x20(evidence\x20window)','source':'market_operations','unit':'count','direction':'higher_better','weight':w(0.2,0.15,0.05),'good_threshold':0x14,'bad_threshold':0x5,'description':'Shop\x20orders\x20in\x20the\x20evidence\x20window:\x20resolved\x20from\x20chain\x20topology\x20(account\x20→\x20EntityPermission\x20→\x20Service\x20→\x20ObjectLinkerTx\x20orders,\x20recent\x20capped;\x20per-service\x20FIFO\x20≤5200),\x20or\x20from\x20explicitly\x20supplied\x20evidence.'},{'id':'completed_count','label':'Completed\x20orders','source':'market_operations','unit':'count','direction':'higher_better','weight':w(0.1,0.1,0.1),'description':'Orders\x20that\x20reached\x20the\x20finished/completed\x20progress\x20state.'},{'id':'completion_rate','label':'Order\x20completion\x20rate','source':'market_operations','unit':'rate','direction':'higher_better','weight':w(0.15,0.2,0.15),'good_threshold':0.9,'bad_threshold':0.6,'description':'completed\x20/\x20orders\x20—\x20workflow\x20reliability;\x20K1\x2090-day\x20gate\x20expects\x20100%\x20on-chain\x20dispute\x20closure.'},{'id':'repeat_customer_rate','label':'Repeat\x20customer\x20rate','source':'market_operations','unit':'rate','direction':'higher_better','weight':w(0.2,0.25,0.2),'good_threshold':0.25,'bad_threshold':0.1,'description':'Share\x20of\x20customers\x20with\x20≥2\x20orders;\x20K1\x20quality\x20gate:\x20>25%.'},{'id':'dispute_rate','label':'Dispute\x20rate','source':'market_operations','unit':'rate','direction':'lower_better','weight':w(0.1,0.15,0.2),'good_threshold':0.02,'bad_threshold':0.05,'description':'Orders\x20with\x20a\x20dispute\x20case;\x20>5%\x20triggers\x20a\x20guard-tightening\x20recommendation.'},{'id':'dd_to_order_rate','label':'Due-diligence\x20→\x20order\x20conversion','source':'market_operations','unit':'rate','direction':'higher_better','weight':w(0.15,0.1,0.05),'good_threshold':0.2,'bad_threshold':0.05,'description':'Funnel\x20conversion\x20from\x20trust_score\x20preorder\x20calls\x20to\x20created\x20orders.'},{'id':'market_recent_orders','label':'Market\x20recent\x20orders\x20(finite\x20window)','source':'order_flow','unit':'count','direction':'higher_better','weight':w(0.05,0.02,0.02),'description':'Network-wide\x20recent\x20NewOrderEvent\x20count\x20—\x20market\x20temperature,\x20not\x20shop\x20performance.'},{'id':'market_recent_gmv','label':'Market\x20recent\x20order-volume\x20sum\x20(mixed\x20coin\x20base\x20units,\x20finite\x20window)','source':'order_flow','unit':'token_units','direction':'higher_better','weight':w(0.02,0.02,0.02),'description':'Network-wide\x20recent\x20NewOrderEvent\x20amount\x20sum.\x20NOT\x20a\x20comparable\x20GMV:\x20each\x20service\x20mints\x20orders\x20in\x20its\x20own\x20coin\x20type\x20T\x20(u64\x20base\x20units),\x20so\x20the\x20event\x20window\x20mixes\x20BTC/ETH/USDT/USDC/WOW\x20denominations;\x20use\x20only\x20as\x20coarse\x20market-temperature.\x20Unavailable\x20when\x20the\x20exact\x20bigint\x20sum\x20exceeds\x20the\x20safe\x20JS\x20integer\x20range.\x20True\x20per-coin\x20GMV\x20comes\x20from\x20the\x20topology\x20fund-flow\x20layer\x20(service\x20coin\x20type\x20→\x20Payment/Allocation\x20records).'},{'id':'supply_demand_ratio','label':'Supply\x20/\x20open-demand\x20ratio','source':'market_metrics','unit':'ratio','direction':'lower_better','weight':w(0.02,0.03,0.05),'good_threshold':0x1,'bad_threshold':0x4,'description':'Active\x20services\x20per\x20open\x20demand;\x20lower\x20=\x20less\x20supply\x20glut\x20for\x20the\x20shop\x27s\x20category.'},{'id':'market_active_services','label':'Market\x20active\x20services','source':'market_metrics','unit':'count','direction':'lower_better','weight':w(0.01,0.01,0.01),'description':'Published,\x20non-paused\x20network\x20supply\x20count\x20—\x20density\x20context.'},{'id':'competitor_count','label':'Competitor\x20services\x20matching\x20category','source':'discover_services','unit':'count','direction':'lower_better','weight':w(0.02,0.05,0.1),'good_threshold':0x5,'bad_threshold':0x1e,'description':'Services\x20in\x20the\x20event-enumeration\x20window\x20whose\x20name/description/category\x20actually\x20matches\x20the\x20industry\x20discovery\x20terms\x20(exact\x20semantic\x20match).\x20When\x20NOTHING\x20matches,\x20this\x20metric\x20is\x20unavailable\x20(an\x20uninformative\x20term\x20miss\x20is\x20not\x20evidence\x20of\x20zero\x20competition);\x20category_enumerated_count\x20carries\x20the\x20scan\x20density.'},{'id':'category_enumerated_count','label':'Services\x20enumerated\x20in\x20the\x20discovery\x20window','source':'discover_services','unit':'count','direction':'lower_better','weight':w(0.02,0.05,0.1),'description':'Total\x20distinct\x20services\x20the\x20event-driven\x20enumeration\x20could\x20scan\x20(event-window\x20bound,\x20has_more\x20honest).\x20The\x20density/coverage\x20denominator\x20behind\x20competitor_count;\x20contextual\x20only\x20—\x20it\x20counts\x20every\x20category,\x20not\x20just\x20matches.'},{'id':'arbitration_trust_score','label':'Bound\x20arbitration\x20trust\x20score','source':'arbitration_score','unit':'score','direction':'higher_better','weight':w(0.05,0.1,0.15),'good_threshold':0x50,'bad_threshold':0x32,'description':'0–100\x20combined\x20trust+fairness\x20assessment\x20of\x20the\x20shop\x27s\x20bound\x20Arbitration\x20object.'},{'id':'open_attention_count','label':'Open\x20attention\x20items','source':'account_events','unit':'count','direction':'lower_better','weight':w(0.03,0.03,0.05),'good_threshold':0x0,'bad_threshold':0x5,'description':'Account\x20events\x20currently\x20demanding\x20attention\x20(disputes/messages/tasks);\x20process\x20friction.'}];const METRIC_BY_ID=new Map(STRATEGY_METRIC_CATALOG['map'](a=>[a['id'],a]));export function getMetricDef(a){return METRIC_BY_ID['get'](a);}export function metricsBySource(a){return STRATEGY_METRIC_CATALOG['filter'](b=>b['source']===a);}export function listMetricSources(){return[...new Set(STRATEGY_METRIC_CATALOG['map'](a=>a['source']))];}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { PersonaLayer, StrategicPosture } from "../persona/types.js";
|
|
2
|
+
import type { ScorecardCollection } from "./collectors.js";
|
|
3
|
+
import { type ScorecardScore } from "./scorecard.js";
|
|
4
|
+
import type { ScorecardSnapshot } from "./store.js";
|
|
5
|
+
import type { StrategyMetricId } from "./metrics.js";
|
|
6
|
+
export interface StrategyProposal {
|
|
7
|
+
id: string;
|
|
8
|
+
rationale: string;
|
|
9
|
+
target_layer: "current";
|
|
10
|
+
delta: Partial<PersonaLayer>;
|
|
11
|
+
apply_via: {
|
|
12
|
+
tool: "persona_operation";
|
|
13
|
+
action: "apply_delta";
|
|
14
|
+
note: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface ReviewCadence {
|
|
18
|
+
cadence_days: number;
|
|
19
|
+
days_since_last: number | null;
|
|
20
|
+
due: boolean;
|
|
21
|
+
next_review_after: number | null;
|
|
22
|
+
}
|
|
23
|
+
export interface StrategyReview {
|
|
24
|
+
account: string;
|
|
25
|
+
industry: string;
|
|
26
|
+
posture: StrategicPosture;
|
|
27
|
+
generated_at: number;
|
|
28
|
+
scorecard: ScorecardScore;
|
|
29
|
+
cadence: ReviewCadence;
|
|
30
|
+
summary: string;
|
|
31
|
+
findings: string[];
|
|
32
|
+
recommendations: string[];
|
|
33
|
+
proposals: StrategyProposal[];
|
|
34
|
+
unavailable: StrategyMetricId[];
|
|
35
|
+
}
|
|
36
|
+
export interface BuildReviewOptions {
|
|
37
|
+
account: string;
|
|
38
|
+
industry: string;
|
|
39
|
+
posture?: StrategicPosture;
|
|
40
|
+
collection: ScorecardCollection;
|
|
41
|
+
previous?: ScorecardSnapshot | null;
|
|
42
|
+
current_merchant_posture?: StrategicPosture;
|
|
43
|
+
now?: number;
|
|
44
|
+
}
|
|
45
|
+
export declare function reviewCadenceDays(industry: string): number;
|
|
46
|
+
export declare function isReviewDue(industry: string, lastCollectedAt: number | null | undefined, now?: number): boolean;
|
|
47
|
+
export declare function reviewNudgeLine(industry: string, lastCollectedAt: number | null | undefined, now?: number): string | null;
|
|
48
|
+
export declare function buildReview(opts: BuildReviewOptions): StrategyReview;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{assertAiCurrentDelta}from'../persona/model.js';import{getIndustryStrategy,recommendStrategy}from'../knowledge/industry-strategy.js';import{scoreScorecard,describeDelta}from'./scorecard.js';const DAY_MS=0x18*0x3c*0x3c*0x3e8;function metricValue(a,b){const c=a['metrics']['find'](d=>d['id']===b);return c?.['status']==='ok'&&typeof c['value']==='number'?c['value']:undefined;}export function reviewCadenceDays(a){return getIndustryStrategy(a)?.['competitor_watch']['cadence_days']??0x7;}export function isReviewDue(a,b,c=Date['now']()){if(b===null||b===undefined)return!![];return c-b>=reviewCadenceDays(a)*DAY_MS;}export function reviewNudgeLine(a,b,c=Date['now']()){if(!isReviewDue(a,b,c))return null;const d=reviewCadenceDays(a),e=b===null||b===undefined?'no\x20recorded\x20review\x20yet':'last\x20review\x20'+Math['max'](0x0,Math['floor']((c-b)/DAY_MS))+'d\x20ago';return'strategy\x20review\x20due\x20('+e+';\x20cadence\x20every\x20'+d+'d)\x20—\x20suggest\x20strategy_review_operation\x20action=\x27review\x27\x20(suggestion\x20only;\x20do\x20NOT\x20call\x20it\x20without\x20the\x20user\x27s\x20go-ahead)';}function toAdvisorMetrics(a){return{'order_count':metricValue(a,'order_count'),'repeat_customer_rate':metricValue(a,'repeat_customer_rate'),'dispute_rate':metricValue(a,'dispute_rate'),'trust_score':metricValue(a,'arbitration_trust_score')};}export function buildReview(a){const b=a['now']??Date['now'](),c=a['posture']??a['current_merchant_posture']??'balanced',d=getIndustryStrategy(a['industry']),e=reviewCadenceDays(a['industry']),g=a['previous']?.['collection']??null,h=scoreScorecard(a['collection'],c,g),i=a['previous']?.['collected_at']??null,j=i===null?null:Math['max'](0x0,Math['floor']((b-i)/DAY_MS)),k=isReviewDue(a['industry'],i,b),l={'cadence_days':e,'days_since_last':j,'due':k,'next_review_after':k?null:i+e*DAY_MS},m=[];for(const y of h['metric_scores']){if(y['value']===null)continue;const z=y['delta']?';\x20'+describeDelta(y['delta']):'',A=y['score']===null?'':'\x20[score\x20'+y['score']+'/100]';m['push'](y['label']+':\x20'+y['value']+z+A);}for(const B of a['collection']['unavailable']){m['push'](B+':\x20unavailable\x20(no\x20evidence\x20this\x20cycle\x20—\x20degraded,\x20not\x20zero)');}const n=[],o=recommendStrategy(a['industry'],c,undefined,toAdvisorMetrics(a['collection']));o&&(n['push']('pricing\x20model:\x20'+o['pricing_model_name']+'\x20(stage:\x20'+o['stage']+')'),n['push'](...o['actions']));if(d){const C=d['postures'][c];n['push'](d['competitor_watch']['cadence']+'\x20competitor\x20watch:\x20'+d['competitor_watch']['dimensions']['slice'](0x0,0x3)['join'](',\x20')),n['push']('posture\x20guardrail:\x20'+C['guardrails'][0x0]);}const q=[],t=metricValue(a['collection'],'dispute_rate'),u=metricValue(a['collection'],'repeat_customer_rate'),v=metricValue(a['collection'],'order_count');if(t!==undefined&&t>0.05)q['push']({'id':'tighten_evidence_guards','rationale':'Dispute\x20rate\x20'+(t*0x64)['toFixed'](0x1)+'%\x20exceeds\x20the\x205%\x20guardrail;\x20the\x20'+a['industry']+'\x20playbook\x20says\x20tighten\x20pre-delivery\x20evidence\x20guards\x20before\x20spending\x20on\x20promotion.','target_layer':'current','delta':{'strategy':['Tighten\x20pre-delivery/pre-handover\x20evidence\x20guards\x20and\x20hold\x20promotions\x20until\x20dispute\x20rate\x20returns\x20under\x205%\x20(strategy\x20review\x20'+new Date(b)['toISOString']()['slice'](0x0,0xa)+').']},'apply_via':{'tool':'persona_operation','action':'apply_delta','note':'Server-side\x20merge\x20into\x20the\x20CURRENT\x20layer\x20after\x20explicit\x20user\x20confirmation;\x20never\x20writes\x20long_term.'}});else u!==undefined&&u<0.25&&(v??0x0)>=0x5&&q['push']({'id':'repeat_reward_focus','rationale':'Repeat\x20rate\x20'+(u*0x64)['toFixed'](0x0)+'%\x20is\x20below\x20the\x2025%\x20K1\x20quality\x20gate\x20with\x20'+v+'\x20observed\x20orders;\x20address\x20retention\x20with\x20rewards\x20rather\x20than\x20blanket\x20price\x20cuts.','target_layer':'current','delta':{'strategy':['Run\x20a\x20repeat/referral\x20reward\x20and\x20review\x20post-delivery\x20follow-up;\x20do\x20not\x20cut\x20headline\x20price\x20(strategy\x20review\x20'+new Date(b)['toISOString']()['slice'](0x0,0xa)+').']},'apply_via':{'tool':'persona_operation','action':'apply_delta','note':'Server-side\x20merge\x20into\x20the\x20CURRENT\x20layer\x20after\x20explicit\x20user\x20confirmation;\x20never\x20writes\x20long_term.'}});a['current_merchant_posture']===undefined&&q['push']({'id':'adopt_posture','rationale':'No\x20strategic\x20posture\x20is\x20recorded\x20in\x20the\x20persona\x20yet;\x20this\x20review\x20was\x20run\x20under\x20the\x20default\x20\x22'+c+'\x22\x20posture.\x20Recording\x20it\x20makes\x20pricing/posture\x20advice\x20stable\x20across\x20sessions.','target_layer':'current','delta':{'profiles':{'merchant':{'merchant':{'posture':c}}}},'apply_via':{'tool':'persona_operation','action':'apply_delta','note':'Server-side\x20merge\x20into\x20the\x20CURRENT\x20layer\x20after\x20explicit\x20user\x20confirmation;\x20never\x20writes\x20long_term.'}});const w=[];w['push']('#\x20Strategy\x20review\x20—\x20'+a['industry']+'\x20('+c+')'),w['push'](''),w['push']('-\x20overall\x20score:\x20'+(h['overall']===null?'n/a\x20(insufficient\x20anchored\x20evidence)':h['overall']+'/100')+'\x20('+h['scored_metric_count']+'\x20scored\x20metrics)'),w['push']('-\x20review\x20cadence:\x20every\x20'+e+'d;\x20'+(j===null?'no\x20previous\x20snapshot':j+'d\x20since\x20last\x20review')+';\x20'+(k?'review\x20due\x20now':'not\x20yet\x20due'));if(o)w['push']('-\x20pricing\x20model:\x20'+o['pricing_model_name']);w['push']('','##\x20Findings');for(const D of m)w['push']('-\x20'+D);w['push']('','##\x20Recommendations');for(const E of n)w['push']('-\x20'+E);if(q['length']){w['push']('','##\x20Proposals\x20(apply\x20only\x20on\x20your\x20confirmation)');for(const F of q)w['push']('-\x20**'+F['id']+'**:\x20'+F['rationale']);}const x=w['join']('\x0a');return{'account':a['account'],'industry':a['industry'],'posture':c,'generated_at':b,'scorecard':h,'cadence':l,'summary':x,'findings':m,'recommendations':n,'proposals':q['slice'](0x0,0x2)['map'](G=>{return assertAiCurrentDelta(G['delta']),G;}),'unavailable':a['collection']['unavailable']};}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { StrategicPosture } from "../persona/types.js";
|
|
2
|
+
import { type StrategyMetricId } from "./metrics.js";
|
|
3
|
+
import type { ScorecardCollection, CollectedMetric } from "./collectors.js";
|
|
4
|
+
export type DeltaDirection = "up" | "down" | "flat";
|
|
5
|
+
export interface MetricDelta {
|
|
6
|
+
id: StrategyMetricId;
|
|
7
|
+
from: number;
|
|
8
|
+
to: number;
|
|
9
|
+
change: number;
|
|
10
|
+
direction: DeltaDirection;
|
|
11
|
+
improved: boolean | null;
|
|
12
|
+
}
|
|
13
|
+
export interface MetricScore {
|
|
14
|
+
id: StrategyMetricId;
|
|
15
|
+
label: string;
|
|
16
|
+
status: CollectedMetric["status"];
|
|
17
|
+
value: number | null;
|
|
18
|
+
weight: number;
|
|
19
|
+
score: number | null;
|
|
20
|
+
delta: MetricDelta | null;
|
|
21
|
+
}
|
|
22
|
+
export interface ScorecardScore {
|
|
23
|
+
posture: StrategicPosture;
|
|
24
|
+
overall: number | null;
|
|
25
|
+
scored_metric_count: number;
|
|
26
|
+
metric_scores: MetricScore[];
|
|
27
|
+
unavailable: StrategyMetricId[];
|
|
28
|
+
}
|
|
29
|
+
export declare function scoreMetricValue(id: StrategyMetricId, value: number): number | null;
|
|
30
|
+
export declare function computeMetricDeltas(current: ScorecardCollection, previous?: ScorecardCollection | null): Map<StrategyMetricId, MetricDelta>;
|
|
31
|
+
export declare function scoreScorecard(collection: ScorecardCollection, posture: StrategicPosture, previous?: ScorecardCollection | null): ScorecardScore;
|
|
32
|
+
export declare function describeDelta(delta: MetricDelta): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getMetricDef}from'./metrics.js';const SHOP_EVIDENCE_METRIC_IDS=new Set(['order_count','completion_rate','repeat_customer_rate','dispute_rate','dd_to_order_rate','arbitration_trust_score']);function clamp01(a){return Math['max'](0x0,Math['min'](0x1,a));}export function scoreMetricValue(a,b){const c=getMetricDef(a);if(!c||c['good_threshold']===undefined||c['bad_threshold']===undefined)return null;const {good_threshold:d,bad_threshold:e}=c;if(d===e)return b>=d?0x64:0x0;const f=clamp01((b-e)/(d-e));return Math['round'](f*0x64);}function valueMap(a){return new Map(a['metrics']['map'](b=>[b['id'],b]));}export function computeMetricDeltas(a,b){const c=new Map();if(!b)return c;const d=valueMap(b);for(const e of a['metrics']){const f=d['get'](e['id']);if(e['status']!=='ok'||typeof e['value']!=='number'||!f||f['status']!=='ok'||typeof f['value']!=='number')continue;const g=e['value']-f['value'],h=g>0x0?'up':g<0x0?'down':'flat',i=getMetricDef(e['id']),j=i&&h!=='flat'?i['direction']==='higher_better'&&g>0x0||i['direction']==='lower_better'&&g<0x0:null;c['set'](e['id'],{'id':e['id'],'from':f['value'],'to':e['value'],'change':g,'direction':h,'improved':j});}return c;}export function scoreScorecard(a,b,c){const d=computeMetricDeltas(a,c),e=a['metrics']['map'](j=>{const k=getMetricDef(j['id']),l=j['status']==='ok'&&typeof j['value']==='number'?j['value']:null,n=l===null?null:scoreMetricValue(j['id'],l);return{'id':j['id'],'label':k?.['label']??j['id'],'status':j['status'],'value':l,'weight':k?.['weight'][b]??0x0,'score':n,'delta':d['get'](j['id'])??null};}),f=e['filter'](j=>j['score']!==null&&j['weight']>0x0),g=f['reduce']((j,k)=>j+k['weight'],0x0),h=f['some'](j=>SHOP_EVIDENCE_METRIC_IDS['has'](j['id'])),i=g>0x0&&h?Math['round'](f['reduce']((j,k)=>j+k['score']*k['weight'],0x0)/g):null;return{'posture':b,'overall':i,'scored_metric_count':f['length'],'metric_scores':e,'unavailable':a['unavailable']};}export function describeDelta(a){const b=a['from']!==0x0?'\x20('+(a['change']>0x0?'+':'')+Math['round'](a['change']/Math['abs'](a['from'])*0x64)+'%)':'',c=a['change']>0x0?'+':'',d=a['improved']===null?'':a['improved']?'\x20✓\x20improving':'\x20⚠\x20worsening';return''+c+roundMetric(a['change'])+b+d;}function roundMetric(a){return Math['abs'](a)>=0x64?Math['round'](a):Math['round'](a*0x64)/0x64;}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SQLiteStorage } from "@wowok/wowok";
|
|
2
|
+
import type { ScorecardCollection } from "./collectors.js";
|
|
3
|
+
import type { StrategicPosture } from "../persona/types.js";
|
|
4
|
+
export interface ScorecardSnapshot {
|
|
5
|
+
id: string;
|
|
6
|
+
account: string;
|
|
7
|
+
industry: string;
|
|
8
|
+
posture?: StrategicPosture;
|
|
9
|
+
collected_at: number;
|
|
10
|
+
created_at: number;
|
|
11
|
+
collection: ScorecardCollection;
|
|
12
|
+
}
|
|
13
|
+
export interface SnapshotStore {
|
|
14
|
+
append(snapshot: ScorecardSnapshot): Promise<void>;
|
|
15
|
+
list(account: string, industry: string): Promise<ScorecardSnapshot[]>;
|
|
16
|
+
latest(account: string, industry: string): Promise<ScorecardSnapshot | null>;
|
|
17
|
+
}
|
|
18
|
+
export declare class SqliteScorecardStore implements SnapshotStore {
|
|
19
|
+
private readonly kv;
|
|
20
|
+
constructor(kv?: SQLiteStorage);
|
|
21
|
+
append(snapshot: ScorecardSnapshot): Promise<void>;
|
|
22
|
+
list(account: string, industry: string): Promise<ScorecardSnapshot[]>;
|
|
23
|
+
latest(account: string, industry: string): Promise<ScorecardSnapshot | null>;
|
|
24
|
+
}
|
|
25
|
+
export declare function getScorecardStore(): SnapshotStore;
|
|
26
|
+
export declare function setScorecardStore(store: SnapshotStore | null): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{randomUUID}from'node:crypto';import{SQLiteStorage}from'@wowok/wowok';function safeParse(a){try{return JSON['parse'](a);}catch{return null;}}const KEY_PREFIX='strategy:snapshot:';function keyFor(a,b){return''+KEY_PREFIX+a['account']+':'+a['industry']+':'+a['collected_at']+':'+b;}export class SqliteScorecardStore{['kv'];constructor(a=new SQLiteStorage()){this['kv']=a;}async['append'](a){const b=randomUUID()['slice'](0x0,0x8);await this['kv']['put'](keyFor(a,b),JSON['stringify'](a));}async['list'](a,b){const c=await this['kv']['list'](KEY_PREFIX),d=[];for(const {value:e}of c){const f=safeParse(e);f&&f['account']===a&&f['industry']===b&&d['push'](f);}return d['sort']((g,h)=>g['collected_at']-h['collected_at']),d;}async['latest'](a,b){const c=await this['list'](a,b);return c['length']?c[c['length']-0x1]:null;}}let _store=null;export function getScorecardStore(){if(!_store)_store=new SqliteScorecardStore();return _store;}export function setScorecardStore(a){_store=a;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{listServices,getServiceInfo,toggle as
|
|
1
|
+
import{listServices,getServiceInfo,toggle as a358a,setEnabled as a358b,reset as a358c}from'../../config/index.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}=b;let e;switch(c){case'list':e={'action':'list','services':listServices()};break;case'toggle':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20toggle');const f=d,g=getServiceInfo(f);if(!g)throw new Error('Unknown\x20service:\x20'+f+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');if(f==='confirm_gate'&&g['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 h=a358a(f);e={'action':'toggle','service':f,'enabled':h,'reminder':g['reminder']};break;}case'disable':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20disable');const i=d,j=getServiceInfo(i);if(!j)throw new Error('Unknown\x20service:\x20'+i+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');if(i==='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.');a358b(i,![]),e={'action':'disable','service':i,'enabled':![],'reminder':j['reminder']};break;}case'enable':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20enable');const k=d,l=getServiceInfo(k);if(!l)throw new Error('Unknown\x20service:\x20'+k+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');a358b(k,!![]),e={'action':'enable','service':k,'enabled':!![],'reminder':l['reminder']};break;}case'reset':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20reset');const m=d,n=getServiceInfo(m);if(!n)throw new Error('Unknown\x20service:\x20'+m+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');a358c(m),e={'action':'reset','service':m,'enabled':getServiceInfo(m)?.['enabled'],'reminder':n['reminder'],'reset':!![]};break;}case'info':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20info');const o=d,p=getServiceInfo(o);if(!p)throw new Error('Unknown\x20service:\x20'+o+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');e={'action':'info',...p};break;}default:throw new Error('Unknown\x20config_operation\x20action:\x20'+String(c));}return{'content':[{'type':'text','text':JSON['stringify']({'result':e})}],'structuredContent':{'result':e}};}
|