@wowok/agent-mcp 2.7.8 → 3.0.0
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 +2 -2
- package/dist/config/runtime.d.ts +1 -1
- package/dist/config/runtime.js +1 -1
- package/dist/examples/rental-ziroom-machine-create.json +1 -2
- package/dist/examples/rental-ziroom-permission-create.json +1 -2
- package/dist/examples/rental-ziroom-service-create.json +1 -2
- package/dist/experience/experience-reuse.js +1 -1
- package/dist/experience/index.d.ts +2 -1
- package/dist/experience/index.js +1 -1
- package/dist/experience/persistence-config.d.ts +6 -0
- package/dist/experience/persistence-config.js +1 -0
- package/dist/experience/persistence.d.ts +21 -0
- package/dist/experience/persistence.js +1 -0
- package/dist/experience/realtime-feedback.js +1 -1
- package/dist/experience/user-profile.js +1 -1
- package/dist/extensions/business-modules.d.ts +1 -1
- package/dist/extensions/capability-manifest.d.ts +2 -83
- package/dist/extensions/capability-manifest.js +1 -1
- package/dist/extensions/constraint-registry.d.ts +6 -4
- package/dist/extensions/constraint-registry.js +1 -1
- package/dist/extensions/index.d.ts +4 -5
- package/dist/extensions/index.js +1 -1
- package/dist/extensions/industry-pack.js +1 -1
- package/dist/extensions/metric-registry.d.ts +6 -4
- package/dist/extensions/metric-registry.js +1 -1
- package/dist/extensions/mode-evaluator.d.ts +2 -3
- package/dist/extensions/mode-evaluator.js +1 -1
- package/dist/extensions/registry.d.ts +3 -25
- package/dist/extensions/registry.js +1 -1
- package/dist/extensions/types.d.ts +1 -69
- package/dist/goal/GoalClassifier.d.ts +17 -0
- package/dist/goal/GoalClassifier.js +1 -0
- package/dist/goal/GoalEngine.d.ts +155 -0
- package/dist/goal/GoalEngine.js +1 -0
- package/dist/goal/GoalStore.d.ts +27 -0
- package/dist/goal/GoalStore.js +1 -0
- package/dist/goal/plan-approval.d.ts +5 -0
- package/dist/goal/plan-approval.js +1 -0
- package/dist/goal/types.d.ts +80 -0
- package/dist/goal/types.js +1 -0
- package/dist/harness/index.d.ts +2 -7
- package/dist/harness/index.js +1 -1
- package/dist/harness/plan.d.ts +1 -1
- package/dist/harness/types.d.ts +0 -35
- package/dist/index.js +1 -1
- package/dist/knowledge/account-marks.d.ts +36 -0
- package/dist/knowledge/account-marks.js +1 -0
- package/dist/knowledge/audit-rules.d.ts +3 -1
- package/dist/knowledge/audit-rules.js +1 -1
- package/dist/knowledge/examples-scanner-cli.js +1 -1
- package/dist/knowledge/examples-scanner.js +1 -1
- package/dist/knowledge/fund-layer.d.ts +13 -9
- package/dist/knowledge/fund-layer.js +1 -1
- package/dist/knowledge/goal-completion.d.ts +19 -0
- package/dist/knowledge/goal-completion.js +1 -0
- package/dist/knowledge/guard-bindings.d.ts +21 -0
- package/dist/knowledge/guard-bindings.js +1 -0
- package/dist/knowledge/guard-translation.js +1 -1
- package/dist/knowledge/index.d.ts +6 -3
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/mcp-schema-audit-cli.js +1 -1
- package/dist/knowledge/mcp-schema-audit.js +1 -1
- package/dist/knowledge/operation-dictionary.js +1 -1
- package/dist/knowledge/passport-confirm.js +1 -1
- package/dist/knowledge/passport-puzzle.js +1 -1
- package/dist/knowledge/passport-translation.js +1 -1
- package/dist/knowledge/proof-risk.js +1 -1
- package/dist/knowledge/reward-risk.d.ts +1 -1
- package/dist/knowledge/reward-risk.js +1 -1
- package/dist/knowledge/safety-rules.d.ts +2 -1
- package/dist/knowledge/safety-rules.js +1 -1
- package/dist/knowledge/scenario-topology.d.ts +43 -0
- package/dist/knowledge/scenario-topology.js +1 -0
- package/dist/knowledge/service-translation.js +1 -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 +36 -0
- package/dist/knowledge/workflow-guidance.js +1 -1
- package/dist/knowledge/workspace-lists.d.ts +57 -0
- package/dist/knowledge/workspace-lists.js +1 -0
- package/dist/loop-engineering/context-collect.d.ts +1 -1
- package/dist/monitor/EventRouter.d.ts +10 -0
- package/dist/monitor/EventRouter.js +1 -0
- package/dist/monitor/EventStore.d.ts +32 -12
- package/dist/monitor/EventStore.js +1 -1
- package/dist/monitor/MonitorLoop.d.ts +81 -0
- package/dist/monitor/MonitorLoop.js +1 -0
- package/dist/monitor/ProblemBridge.d.ts +32 -0
- package/dist/monitor/ProblemBridge.js +1 -0
- package/dist/monitor/ScopeResolver.d.ts +59 -0
- package/dist/monitor/ScopeResolver.js +1 -0
- package/dist/monitor/SubscriptionStore.d.ts +13 -0
- package/dist/monitor/SubscriptionStore.js +1 -0
- package/dist/monitor/SuggestionBridge.d.ts +38 -0
- package/dist/monitor/SuggestionBridge.js +1 -0
- package/dist/monitor/normalize.d.ts +8 -0
- package/dist/monitor/normalize.js +1 -0
- package/dist/monitor/types.d.ts +89 -0
- package/dist/monitor/types.js +1 -0
- package/dist/participation/arbitrator-interest.d.ts +20 -0
- package/dist/participation/arbitrator-interest.js +1 -0
- package/dist/participation/demander-interest.d.ts +23 -0
- package/dist/participation/demander-interest.js +1 -0
- package/dist/persona/address-format.d.ts +1 -1
- package/dist/persona/address-format.js +1 -1
- package/dist/persona/distill-goal.d.ts +20 -0
- package/dist/persona/distill-goal.js +1 -0
- package/dist/persona/index.d.ts +2 -0
- package/dist/persona/index.js +1 -1
- package/dist/persona/model.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -0
- package/dist/{project → playbooks/service-build}/context-assembly.d.ts +9 -4
- package/dist/playbooks/service-build/context-assembly.js +1 -0
- package/dist/{project → playbooks/service-build}/game-theory.d.ts +1 -1
- package/dist/playbooks/service-build/index.d.ts +14 -0
- package/dist/playbooks/service-build/index.js +1 -0
- package/dist/{project → playbooks/service-build}/intent-analyzer.d.ts +1 -1
- package/dist/playbooks/service-build/intent-analyzer.js +1 -0
- package/dist/playbooks/service-build/machine-nodes.js +1 -0
- package/dist/{project → playbooks/service-build}/machine-panorama.d.ts +5 -3
- package/dist/playbooks/service-build/machine-panorama.js +1 -0
- package/dist/{project → playbooks/service-build}/merchant-guide.d.ts +21 -1
- package/dist/playbooks/service-build/merchant-guide.js +1 -0
- package/dist/{project → playbooks/service-build}/mode-actions.d.ts +32 -8
- package/dist/playbooks/service-build/mode-actions.js +1 -0
- package/dist/playbooks/service-build/namespace.d.ts +2 -0
- package/dist/playbooks/service-build/namespace.js +1 -0
- package/dist/{project → playbooks/service-build}/object-panorama.d.ts +2 -3
- package/dist/playbooks/service-build/object-panorama.js +1 -0
- package/dist/{project → playbooks/service-build}/participation-radar.d.ts +4 -5
- package/dist/playbooks/service-build/participation-radar.js +1 -0
- package/dist/{project → playbooks/service-build}/pipeline-actions.d.ts +9 -9
- package/dist/playbooks/service-build/pipeline-actions.js +1 -0
- package/dist/playbooks/service-build/process.d.ts +6 -0
- package/dist/playbooks/service-build/process.js +1 -0
- package/dist/playbooks/service-build/relationship-profile.d.ts +2 -0
- package/dist/playbooks/service-build/relationship-profile.js +1 -0
- package/dist/playbooks/service-build/risk-aggregator.js +1 -0
- package/dist/{project → playbooks/service-build}/semantic-graph.d.ts +7 -3
- package/dist/playbooks/service-build/semantic-graph.js +1 -0
- package/dist/{project → playbooks/service-build}/service-panorama.d.ts +3 -19
- package/dist/playbooks/service-build/service-panorama.js +1 -0
- package/dist/relationship/derivation.d.ts +88 -0
- package/dist/relationship/derivation.js +1 -0
- package/dist/relationship/incentive.d.ts +38 -0
- package/dist/relationship/incentive.js +1 -0
- package/dist/relationship/index.d.ts +4 -0
- package/dist/relationship/index.js +1 -0
- package/dist/relationship/registry.d.ts +13 -0
- package/dist/relationship/registry.js +1 -0
- package/dist/relationship/types.d.ts +45 -0
- package/dist/relationship/types.js +1 -0
- package/dist/review/arb.d.ts +6 -0
- package/dist/review/arb.js +1 -0
- package/dist/review/demand.d.ts +3 -0
- package/dist/review/demand.js +1 -0
- package/dist/review/index.d.ts +3 -0
- package/dist/review/index.js +1 -0
- package/dist/review/machine.d.ts +3 -0
- package/dist/review/machine.js +1 -0
- package/dist/review/order.d.ts +9 -0
- package/dist/review/order.js +1 -0
- package/dist/review/progress.d.ts +3 -0
- package/dist/review/progress.js +1 -0
- package/dist/review/repository.d.ts +3 -0
- package/dist/review/repository.js +1 -0
- package/dist/review/service.d.ts +5 -0
- package/dist/review/service.js +1 -0
- package/dist/review/types.d.ts +156 -0
- package/dist/review/types.js +1 -0
- package/dist/rules.d.ts +2 -2
- package/dist/rules.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/safety/index.d.ts +1 -1
- package/dist/safety/index.js +1 -1
- package/dist/safety/preview.d.ts +1 -0
- package/dist/safety/preview.js +1 -1
- package/dist/schema/call/allocation.d.ts +1 -1
- package/dist/schema/call/arbitration.d.ts +1 -1
- package/dist/schema/call/base.d.ts +1 -1
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +29 -7
- package/dist/schema/call/bridge.js +1 -1
- package/dist/schema/call/contact.d.ts +1 -1
- package/dist/schema/call/contact.js +1 -1
- package/dist/schema/call/demand.d.ts +1 -1
- package/dist/schema/call/demand.js +1 -1
- package/dist/schema/call/guard.d.ts +3 -3
- package/dist/schema/call/handler.d.ts +0 -3
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/machine.d.ts +2 -2
- package/dist/schema/call/order.d.ts +1 -1
- package/dist/schema/call/payment.d.ts +1 -1
- package/dist/schema/call/permission.d.ts +1 -1
- package/dist/schema/call/personal.d.ts +1 -1
- package/dist/schema/call/progress.d.ts +1 -1
- package/dist/schema/call/proof.d.ts +2 -2
- package/dist/schema/call/repository.d.ts +1 -1
- package/dist/schema/call/repository.js +1 -1
- package/dist/schema/call/reward.d.ts +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +1 -1
- package/dist/schema/call/service.js +1 -1
- package/dist/schema/call/treasury.d.ts +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/goal/index.d.ts +343 -0
- package/dist/schema/goal/index.js +1 -0
- package/dist/schema/goal/planning.d.ts +465 -0
- package/dist/schema/goal/planning.js +1 -0
- package/dist/schema/index.d.ts +1 -2
- package/dist/schema/index.js +1 -1
- package/dist/schema/industry-pack/index.d.ts +323 -1
- package/dist/schema/industry-pack/index.js +1 -1
- package/dist/schema/industry-pack/modes.d.ts +326 -0
- package/dist/schema/industry-pack/modes.js +1 -0
- package/dist/schema/intent-radar/index.d.ts +19 -19
- package/dist/schema/local/index.d.ts +11 -0
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/operations.d.ts +258 -19
- package/dist/schema/operations.js +1 -1
- package/dist/schema/permission/index.d.ts +1 -0
- package/dist/schema/permission/index.js +1 -1
- package/dist/schema/persona/index.d.ts +40 -0
- package/dist/schema/persona/index.js +1 -1
- package/dist/schema/query/bi.d.ts +912 -0
- package/dist/schema/query/bi.js +1 -0
- package/dist/schema/query/index.d.ts +663 -2
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/utils/skills-recommendation.d.ts +0 -1
- package/dist/schema/utils/skills-recommendation.js +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +32 -3
- package/dist/schemas/account_operation.schema.json +8 -4
- package/dist/schemas/bridge_operation.output.json +26 -3
- package/dist/schemas/bridge_operation.schema.json +85 -13
- package/dist/schemas/config_operation.output.json +1 -1
- package/dist/schemas/config_operation.schema.json +1 -1
- package/dist/schemas/goal_operation.schema.json +1092 -0
- package/dist/schemas/guard2file.schema.json +3 -3
- package/dist/schemas/index.json +12 -13
- package/dist/schemas/industry_pack_operation.output.json +1073 -0
- package/dist/schemas/industry_pack_operation.schema.json +236 -2
- package/dist/schemas/local_info_operation.output.json +2 -2
- package/dist/schemas/local_mark_operation.output.json +2 -2
- package/dist/schemas/machineNode2file.schema.json +3 -3
- package/dist/schemas/messenger_operation.output.json +2 -2
- package/dist/schemas/monitor_events.output.json +78 -3
- package/dist/schemas/monitor_events.schema.json +24 -1
- package/dist/schemas/monitor_subscription.output.json +1462 -0
- package/dist/schemas/monitor_subscription.schema.json +327 -0
- package/dist/schemas/onchain_events.output.json +5 -5
- package/dist/schemas/onchain_operations.output.json +2 -2
- package/dist/schemas/onchain_operations.schema.json +100 -100
- package/dist/schemas/onchain_operations_allocation.schema.json +7 -7
- package/dist/schemas/onchain_operations_arbitration.schema.json +6 -6
- package/dist/schemas/onchain_operations_contact.schema.json +6 -6
- package/dist/schemas/onchain_operations_demand.schema.json +6 -6
- package/dist/schemas/onchain_operations_gen_passport.schema.json +3 -3
- package/dist/schemas/onchain_operations_gen_proof.schema.json +3 -3
- package/dist/schemas/onchain_operations_guard.schema.json +3 -3
- package/dist/schemas/onchain_operations_machine.schema.json +5 -5
- package/dist/schemas/onchain_operations_order.schema.json +5 -5
- package/dist/schemas/onchain_operations_payment.schema.json +4 -4
- package/dist/schemas/onchain_operations_permission.schema.json +5 -5
- package/dist/schemas/onchain_operations_personal.schema.json +3 -3
- package/dist/schemas/onchain_operations_progress.schema.json +5 -5
- package/dist/schemas/onchain_operations_proof.schema.json +3 -3
- package/dist/schemas/onchain_operations_repository.schema.json +7 -7
- package/dist/schemas/onchain_operations_reward.schema.json +9 -9
- package/dist/schemas/onchain_operations_service.schema.json +11 -11
- package/dist/schemas/onchain_operations_treasury.schema.json +9 -9
- package/dist/schemas/onchain_table_data.output.json +399 -2
- package/dist/schemas/onchain_table_data.schema.json +22 -22
- package/dist/schemas/permission_operation.schema.json +6 -2
- package/dist/schemas/persona_operation.output.json +145 -0
- package/dist/schemas/persona_operation.schema.json +28 -2
- package/dist/schemas/query_toolkit.output.json +1514 -22
- package/dist/schemas/query_toolkit.schema.json +465 -11
- package/dist/schemas/workflow_operation.schema.json +4 -4
- package/dist/task/ProcessStore.d.ts +98 -0
- package/dist/task/ProcessStore.js +1 -0
- package/dist/task/playbook.d.ts +11 -0
- package/dist/task/playbook.js +1 -0
- package/dist/task/stage-gate.d.ts +22 -0
- package/dist/task/stage-gate.js +1 -0
- package/dist/{project → task}/substep-trace.d.ts +6 -45
- package/dist/task/types.d.ts +144 -0
- package/dist/task/types.js +1 -0
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/evaluation.js +1 -1
- package/dist/tools/handlers/goal.d.ts +4 -0
- package/dist/tools/handlers/goal.js +1 -0
- package/dist/tools/handlers/industry-pack.js +1 -1
- package/dist/tools/handlers/local.d.ts +4 -3
- package/dist/tools/handlers/local.js +1 -1
- package/dist/tools/handlers/monitor.d.ts +24 -0
- package/dist/tools/handlers/monitor.js +1 -1
- package/dist/tools/handlers/network.d.ts +1 -0
- package/dist/tools/handlers/network.js +1 -0
- 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.js +1 -1
- package/dist/tools/handlers/watch.js +1 -1
- package/dist/tools/handlers/workflow.js +1 -1
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.js +1 -1
- package/dist/tools/rules-hook.d.ts +1 -0
- package/dist/tools/rules-hook.js +1 -1
- package/dist/tools/shared.js +1 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +5 -4
- package/dist/harness/checkpoint.d.ts +0 -8
- package/dist/harness/checkpoint.js +0 -1
- package/dist/knowledge/deployment-scanner.d.ts +0 -66
- package/dist/knowledge/deployment-scanner.js +0 -1
- package/dist/mode-market/index.d.ts +0 -3
- package/dist/mode-market/index.js +0 -1
- package/dist/mode-market/registry.d.ts +0 -53
- package/dist/mode-market/registry.js +0 -1
- package/dist/mode-market/review.d.ts +0 -27
- package/dist/mode-market/review.js +0 -1
- package/dist/mode-market/submission.d.ts +0 -25
- package/dist/mode-market/submission.js +0 -1
- package/dist/project/business-puzzle.js +0 -1
- package/dist/project/context-assembly.js +0 -1
- package/dist/project/deployment-bridge.d.ts +0 -5
- package/dist/project/deployment-bridge.js +0 -1
- package/dist/project/deployment-doc.d.ts +0 -190
- package/dist/project/deployment-doc.js +0 -1
- package/dist/project/edit-planner.d.ts +0 -123
- package/dist/project/edit-planner.js +0 -1
- package/dist/project/evaluation-fix.spec.d.ts +0 -1
- package/dist/project/evaluation-fix.spec.js +0 -1
- package/dist/project/evaluation.d.ts +0 -127
- package/dist/project/evaluation.js +0 -1
- package/dist/project/graph-builder.d.ts +0 -51
- package/dist/project/graph-builder.js +0 -1
- package/dist/project/graph.d.ts +0 -70
- package/dist/project/graph.js +0 -1
- package/dist/project/handlers.d.ts +0 -524
- package/dist/project/handlers.js +0 -1
- package/dist/project/index.d.ts +0 -91
- package/dist/project/index.js +0 -1
- package/dist/project/intent-analyzer.js +0 -1
- package/dist/project/machine-nodes.js +0 -1
- package/dist/project/machine-panorama.js +0 -1
- package/dist/project/merchant-guide.js +0 -1
- package/dist/project/mode-actions.js +0 -1
- package/dist/project/namespace.d.ts +0 -72
- package/dist/project/namespace.js +0 -1
- package/dist/project/object-panorama.js +0 -1
- package/dist/project/participation-radar.js +0 -1
- package/dist/project/pipeline-actions.js +0 -1
- package/dist/project/project-store.d.ts +0 -110
- package/dist/project/project-store.js +0 -1
- package/dist/project/query.d.ts +0 -43
- package/dist/project/query.js +0 -1
- package/dist/project/risk-aggregator.js +0 -1
- package/dist/project/semantic-assembler.d.ts +0 -93
- package/dist/project/semantic-assembler.js +0 -1
- package/dist/project/semantic-graph.js +0 -1
- package/dist/project/service-panorama.js +0 -1
- package/dist/project/stage-gate.d.ts +0 -52
- package/dist/project/stage-gate.js +0 -1
- package/dist/project/task-tracker.d.ts +0 -30
- package/dist/project/task-tracker.js +0 -1
- package/dist/schema/project/index.d.ts +0 -2021
- package/dist/schema/project/index.js +0 -1
- package/dist/schema/task-status.d.ts +0 -62
- package/dist/schema/task-status.js +0 -1
- package/dist/schemas/project_operation.output.json +0 -7877
- package/dist/schemas/project_operation.schema.json +0 -1139
- package/dist/schemas/query_task_status.output.json +0 -211
- package/dist/schemas/query_task_status.schema.json +0 -18
- package/dist/tools/handlers/project.d.ts +0 -2
- package/dist/tools/handlers/project.js +0 -1
- package/dist/tools/handlers/task-status.d.ts +0 -2
- package/dist/tools/handlers/task-status.js +0 -1
- /package/dist/{project → playbooks/service-build}/business-puzzle.d.ts +0 -0
- /package/dist/{project → playbooks/service-build}/game-theory.js +0 -0
- /package/dist/{project → playbooks/service-build}/machine-nodes.d.ts +0 -0
- /package/dist/{project → playbooks/service-build}/object-type.d.ts +0 -0
- /package/dist/{project → playbooks/service-build}/object-type.js +0 -0
- /package/dist/{project → playbooks/service-build}/reverse-mapping.d.ts +0 -0
- /package/dist/{project → playbooks/service-build}/reverse-mapping.js +0 -0
- /package/dist/{project → playbooks/service-build}/risk-aggregator.d.ts +0 -0
- /package/dist/{project → playbooks/service-build}/workflow-design-assessment.d.ts +0 -0
- /package/dist/{project → playbooks/service-build}/workflow-design-assessment.js +0 -0
- /package/dist/{project → task}/substep-trace.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{findSimilarIndustries,inferTraitsFromDescription}from'../../knowledge/industry-generalizer.js';const INTENT_KEYWORDS={'sell_service':['design','develop','consult','freelance','service','build','create','write','translate'],'sell_product':['sell','product','item','goods','merchandise','store','shop'],'sell_subscription':['subscribe','subscription','membership','monthly','recurring','creator','patron'],'rent_asset':['rent','rental','lease','borrow','car','house','apartment','equipment'],'crowdfund':['crowdfund','fund','raise','campaign','donation','backer'],'escrow':['escrow','hold','mediate','intermediary','safe','secure\x20transaction']};function classifyIntentType(a){const b=a['toLowerCase']();let c='sell_service',d=0x0;for(const [e,f]of Object['entries'](INTENT_KEYWORDS)){const g=f['filter'](h=>b['includes'](h))['length'];g>d&&(d=g,c=e);}return c;}function inferPaymentModel(a){const b=a['toLowerCase']();if(b['includes']('milestone')||b['includes']('phase')||b['includes']('stage'))return'milestone';if(b['includes']('subscription')||b['includes']('monthly')||b['includes']('recurring'))return'subscription';if(b['includes']('per\x20use')||b['includes']('hourly')||b['includes']('per\x20session'))return'per_use';if(b['includes']('escrow')||b['includes']('hold'))return'escrow';return'upfront';}function inferRefundPolicy(a){const b=a['toLowerCase']();if(b['includes']('no\x20refund')||b['includes']('non-refundable'))return'no_refund';if(b['includes']('milestone')&&b['includes']('refund'))return'milestone_prorated';if(b['includes']('full\x20refund'))return'full';return'partial';}function inferArbitration(a){const b=a['toLowerCase']();if(b['includes']('no\x20arbitration')||b['includes']('no\x20dispute'))return'none';if(b['includes']('third\x20party')||b['includes']('independent'))return'third_party';if(b['includes']('mutual'))return'mutual_pick';return'merchant_pick';}export async function analyzeIntent(a,b){const c=[],d=classifyIntentType(a),e=inferTraitsFromDescription(a),f=findSimilarIndustries(e['traits'],0x3),g=f['map'](n=>n['industry']),h=b?.['preferredIndustry']??g[0x0]??'general',i=g['includes'](h)?0.85:0.5,j=e['traits'],k={'intent':d,'industry':h,'description':a,'roles':{'merchant':{'name':'merchant','description':'Service\x20provider\x20or\x20seller','obligations':['Deliver\x20as\x20described','Maintain\x20compensation_fund\x20if\x20required','Accept\x20arbitration\x20verdicts'],'rights':['Receive\x20payment\x20upon\x20verified\x20delivery','Set\x20service\x20terms\x20before\x20publish']},'customer':{'name':'customer','description':'Buyer\x20or\x20service\x20recipient','obligations':['Pay\x20according\x20to\x20agreed\x20schedule','Provide\x20acceptance/rejection\x20within\x20timeout'],'rights':['Receive\x20deliverables\x20as\x20described','Request\x20refund\x20if\x20delivery\x20fails','Initiate\x20arbitration\x20for\x20disputes']}},'deliverables':[{'name':'main_deliverable','type':inferDeliverableType(a),'acceptanceCriteria':'To\x20be\x20defined\x20by\x20merchant\x20during\x20configuration','proofOfDelivery':'wip_hash'}],'payment':{'model':inferPaymentModel(a),'currency':b?.['currency']??'WOW','triggers':[{'event':inferPaymentModel(a)==='milestone'?'milestone\x20completion':'service\x20confirmation','guardDescription':'Guard\x20verifies\x20deliverable\x20meets\x20acceptance\x20criteria'}],'allocation':[{'recipient':'merchant','percentage':0x5a},{'recipient':'platform','percentage':0x0},{'recipient':'arbitration_reserve','percentage':0xa}]},'trust':{'refundPolicy':inferRefundPolicy(a),'arbitration':inferArbitration(a),'escrow':!![],'transparency':'full'}};k['payment']['model']==='milestone'&&!a['toLowerCase']()['includes']('milestone')&&c['push']('Payment\x20model\x20inferred\x20as\x20\x27milestone\x27\x20but\x20not\x20explicitly\x20mentioned.\x20Please\x20verify.');k['trust']['arbitration']==='none'&&c['push']('No\x20arbitration\x20configured.\x20This\x20increases\x20risk\x20for\x20both\x20parties.\x20Consider\x20adding\x20independent_arbitration\x20module.');k['payment']['allocation']&&k['payment']['allocation']['some'](n=>n['recipient']==='platform'&&n['percentage']>0x0)&&c['push']('Platform\x20fee\x20>\x200\x20detected.\x20WOW\x20philosophy\x20recommends\x200%\x20platform\x20fee\x20for\x20peer-to-peer\x20transactions.');const l=a['toLowerCase']();/(refund|cancel|dispute)/['test'](l)&&k['payment']['model']==='milestone'&&c['push']('T1\x20B-1:\x20\x27refund/dispute\x27\x20must\x20be\x20modeled\x20via\x20the\x20Allocation\x20waterfall\x20(order_allocators)\x20+\x20'+'the\x20bound\x20Arbitration\x20—\x20NOT\x20a\x20Machine\x20\x27refunded\x27/\x27disputed\x27\x20node\x20(R-M1-11).');/(按(实际|定损|损失|评估)[^。]{0,8}(金额|赔付|赔偿)|variable amount|dynamic amount|actual loss|assessed loss)/['test'](l)&&c['push']('T1\x20B-2:\x20a\x20variable/conditional\x20payout\x20amount\x20cannot\x20be\x20expressed\x20in\x20Allocation\x20—\x20amounts\x20are\x20'+'pre-configured.\x20Use\x20fixed\x20tiers\x20guarded\x20by\x20distinct\x20Guards,\x20or\x20an\x20Amount\x20with\x20a\x20max\x20cap.');/(auto|automatic|automatically|after \d+ (day|hour|week)|within \d+ (day|hour|week)|自动|到期后)/['test'](l)&&c['push']('T1\x20B-3:\x20\x27auto\x20/\x20after\x20N\x20days\x27\x20has\x20no\x20on-chain\x20cron\x20—\x20it\x20requires\x20a\x20time_guard\x20PLUS\x20an\x20off-chain\x20'+'keeper\x20to\x20submit.\x20Configuring\x20a\x20time_guard\x20without\x20a\x20keeper\x20means\x20nothing\x20ever\x20fires.');let m=[];try{const {recommendModules:n}=await import('../../extensions/business-modules.js'),o=n(h,a,{'maxModules':0x5});m=o['map'](p=>p['id']);}catch{m=['milestone_escrow','independent_arbitration','wip_provenance'];}return{'intent':k,'inferredIndustry':h,'industryConfidence':i,'similarIndustries':g,'inferredTraits':j,'recommendedModules':m,'warnings':c};}function inferDeliverableType(a){const b=a['toLowerCase']();if(b['includes']('design')||b['includes']('code')||b['includes']('write')||b['includes']('digital'))return'digital';if(b['includes']('class')||b['includes']('lesson')||b['includes']('session'))return'service_session';if(b['includes']('rent')||b['includes']('access'))return'access_right';return'physical';}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{batchQueryTableItems}from'../../knowledge/workflow-guidance.js';export async function fetchMachineNodes(a,b){const {items:c}=await batchQueryTableItems(a,{'network':b}),d=[];for(const e of c){e['object']?.['type']==='TableItem_MachineNode'&&d['push'](e['object']);}return d;}export function normalizeForwards(a){if(!Array['isArray'](a))return[];return a['map'](b=>{const c=b?.['guard'],d=c&&typeof c==='object'&&typeof c['guard']==='string';return{'name':typeof b?.['name']==='string'?b['name']:'','weight':typeof b?.['weight']==='number'?b['weight']:0x0,'guard':d?c['guard']:typeof c==='string'?c:null,'retained_submission':d&&Array['isArray'](c['retained_submission'])?c['retained_submission']:null,'named_operator':typeof b?.['namedOperator']==='string'?b['namedOperator']:null,'permission_index':typeof b?.['permissionIndex']==='number'?b['permissionIndex']:null};});}export function buildMachineGraph(a){const b=new Map(),c=[];for(const d of a){const e=d['name'];if(!e)continue;!b['has'](e)&&b['set'](e,{'name':e,'description':null});const f=Array['isArray'](d['value'])?d['value']:[];for(const g of f){if(!g||typeof g!=='object')continue;const h=typeof g['prev_node']==='string'?g['prev_node']:'';if(!h)continue;c['push']({'from':h,'to':e,'threshold':typeof g['threshold']==='number'?g['threshold']:0x1,'forwards':normalizeForwards(g['forwards'])});}}for(const i of c){!b['has'](i['from'])&&b['set'](i['from'],{'name':i['from'],'description':null}),!b['has'](i['to'])&&b['set'](i['to'],{'name':i['to'],'description':null});}return{'nodes':Array['from'](b['values']()),'edges':c};}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ProjectOperationInputSchema } from "../schema/project/index.js";
|
|
1
|
+
import type { MachinePanoramaInput } from "../../schema/query/bi.js";
|
|
3
2
|
import { type MachineGraphNode, type MachineGraphEdge } from "./machine-nodes.js";
|
|
4
|
-
type ProjectInput =
|
|
3
|
+
type ProjectInput = MachinePanoramaInput;
|
|
5
4
|
export interface MachinePanoramaResult {
|
|
6
5
|
action: "machine_panorama";
|
|
7
6
|
machineAddress: string;
|
|
@@ -35,6 +34,9 @@ export interface MachinePanoramaResult {
|
|
|
35
34
|
created_at: number | null;
|
|
36
35
|
}[];
|
|
37
36
|
};
|
|
37
|
+
related: {
|
|
38
|
+
count: number;
|
|
39
|
+
};
|
|
38
40
|
data_gaps: string[];
|
|
39
41
|
}
|
|
40
42
|
export declare function handleMachinePanorama(v: ProjectInput): Promise<MachinePanoramaResult>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Config,LocalMark,query_objects,objectTypeFromAddress,ObjectType}from'@wowok/wowok';import{fetchMachineNodes,buildMachineGraph}from'./machine-nodes.js';import{batchQueryObjectsByIds,fetchObjectLinkerTx}from'../../knowledge/workflow-guidance.js';export async function handleMachinePanorama(a){const b=a['object_address'];if(!b)throw new Error('\x27object_address\x27\x20is\x20required\x20for\x20machine_panorama');let c=a['context_network']??undefined;const d=[];let f=b;if(!/^0x[0-9a-fA-F]{32,64}$/['test'](b)){const p=await LocalMark['Instance']()['get_address'](b);if(!p)throw new Error('Cannot\x20resolve\x20machine\x20\x27'+b+'\x27\x20—\x20not\x20a\x20valid\x20address\x20and\x20no\x20LocalMark\x20entry\x20found.\x20'+'Pass\x20the\x200x\x20Machine\x20object\x20address\x20directly\x20or\x20register\x20the\x20name\x20via\x20local_mark_operation.');f=p;}let g=null;try{if(!c)c=await Config['Instance']()['network_get']();const q=await query_objects({'objects':[f],'network':c});g=q?.['objects']?.[0x0]??null;if(!g&&a['context_network']){const s=await Config['Instance']()['network_get']();if(s&&s!==c){const t=await query_objects({'objects':[f],'network':s,'no_cache':!![]}),u=t?.['objects']?.[0x0]??null;u&&(g=u,c=s);}}}catch(w){throw new Error('Failed\x20to\x20query\x20Machine\x20'+f+'\x20on\x20'+c+':\x20'+(''+(w instanceof Error?w['message']:String(w))));}if(!g)throw new Error('Machine\x20'+f+'\x20not\x20found\x20on\x20'+c+'.\x20It\x20may\x20not\x20exist\x20on\x20this\x20network.');f=g['object']??f;let h=null,j=[];try{const x=await LocalMark['Instance']()['list']({'address':f});x['length']>0x0&&(h=x[0x0]['name']??null,j=(x[0x0]['tags']??[])['map'](y=>String(y)));}catch{d['push']('head:\x20LocalMark\x20lookup\x20failed');}let k={'nodes':[],'edges':[]};try{const y=await fetchMachineNodes(f,c);k=buildMachineGraph(y);}catch{d['push']('graph:\x20node\x20fetch\x20failed\x20(non-blocking)');}const l=[];let m=0x0,n=0x0;try{const z=await fetchObjectLinkerTx(f,c,!![]),A=z?.['items']??[],B=new Set();for(const G of A){const H=typeof G?.['who']==='string'?G['who']['toLowerCase']():'';if(!H||H==='0x0')continue;if(!objectTypeFromAddress(H))continue;B['add'](H);}n=B['size'];const C=A['filter'](I=>objectTypeFromAddress(I['who'])===ObjectType['Progress']);m=C['length'];const D=C['slice'](-0x32)['reverse'](),E=D['map'](I=>I['who']),F=new Map();if(E['length']>0x0)try{const I=await batchQueryObjectsByIds(E,c,!![]);for(const J of I){if(J?.['object'])F['set'](J['object'],J);}}catch{d['push']('progresses:\x20detail\x20fetch\x20failed');}for(const K of D){const L=typeof K?.['who']==='string'?K['who']:'';if(!L)continue;const M=F['get'](L);l['push']({'progress':L,'name':null,'current':M?.['current']??null,'task':M?.['task']??null,'history_count':typeof M?.['history_count']==='number'?M['history_count']:null,'current_time':typeof M?.['current_time']==='number'?M['current_time']:null,'created_at':typeof K?.['time']==='number'?K['time']:null});}}catch{d['push']('progresses:\x20global-table\x20lookup\x20failed\x20(non-blocking)');}return{'action':'machine_panorama','machineAddress':f,'network':String(c),'head':{'name':h,'tags':j,'description':typeof g['description']==='string'?g['description']:null,'published':typeof g['bPublished']==='boolean'?g['bPublished']:null,'paused':typeof g['bPaused']==='boolean'?g['bPaused']:null},'fields':{'permission':g['permission']??null,'um':g['um']??null,'node_count':typeof g['node_count']==='number'?g['node_count']:null,'consensus_repositories':Array['isArray'](g['consensus_repositories'])?g['consensus_repositories']:[]},'graph':k,'progresses':{'count':m,'items':l},'related':{'count':n},'data_gaps':d};}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type BusinessIntent, type DeliverableDefinition, type PaymentIntent, type TrustIntent } from "./intent-analyzer.js";
|
|
2
|
-
import { type BusinessModuleId } from "
|
|
2
|
+
import { type BusinessModuleId } from "../../extensions/business-modules.js";
|
|
3
3
|
export interface GuideState {
|
|
4
4
|
intent_text: string;
|
|
5
5
|
confirmed_industry?: string;
|
|
@@ -52,6 +52,7 @@ export declare function handleMerchantGuide(v: MerchantGuideInput): Promise<{
|
|
|
52
52
|
next_action: string;
|
|
53
53
|
intent?: undefined;
|
|
54
54
|
adopted_modules?: undefined;
|
|
55
|
+
mode_prior?: undefined;
|
|
55
56
|
blueprint?: undefined;
|
|
56
57
|
evaluation_preview?: undefined;
|
|
57
58
|
graph_validation?: undefined;
|
|
@@ -94,6 +95,25 @@ export declare function handleMerchantGuide(v: MerchantGuideInput): Promise<{
|
|
|
94
95
|
user_protections: string[];
|
|
95
96
|
merchant_obligations: string[];
|
|
96
97
|
}[];
|
|
98
|
+
mode_prior: {
|
|
99
|
+
name: string;
|
|
100
|
+
display_name: string;
|
|
101
|
+
source: import("../../knowledge/industry-registry.js").IndustrySource;
|
|
102
|
+
risk_appetite: import("../../extensions/types.js").RiskAppetite;
|
|
103
|
+
key_risk: string;
|
|
104
|
+
machine_shape: {
|
|
105
|
+
name: string;
|
|
106
|
+
role: string;
|
|
107
|
+
}[];
|
|
108
|
+
guards: {
|
|
109
|
+
template_id: string;
|
|
110
|
+
host: "reward" | "service" | "machine" | "arbitration" | "repository";
|
|
111
|
+
purpose: string;
|
|
112
|
+
}[];
|
|
113
|
+
allocator: import("../../knowledge/scenario-modes.js").ModeAllocatorStrategy;
|
|
114
|
+
risk_constraints: import("../../extensions/types.js").ModeRiskConstraints;
|
|
115
|
+
build_notes: string[];
|
|
116
|
+
} | undefined;
|
|
97
117
|
blueprint: {
|
|
98
118
|
nodes: {
|
|
99
119
|
id: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{analyzeIntent}from'./intent-analyzer.js';import{buildSemanticGraph,validateGraph}from'./semantic-graph.js';import{checkGameTheoryConstraints}from'./game-theory.js';import{assessWorkflowDesign}from'./workflow-design-assessment.js';import{CORE_BUSINESS_MODULES,getBusinessModule,recommendModules,checkModuleConstraints}from'../../extensions/business-modules.js';import{getIndustryModeRegistry}from'../../extensions/index.js';import{LOCAL_MODE_OWNER}from'./mode-actions.js';function derivePlanSatisfiedConstraints(a,b){const c=new Set(),d=h=>a['edges']['some'](i=>i['relation']===h),e=h=>a['nodes']['some'](i=>i['id']===h),f=h=>a['nodes']['some'](i=>i['type']===h),g=h=>a['adoptedModules']['includes'](h);if(d('has_order_allocators'))c['add']('order_allocators_bound');if(d('uses_machine'))c['add']('machine_bound_before_publish');if(d('has_arbitration'))c['add']('arbitration_bound_to_service');if(e('main_machine'))c['add']('machine_published');if(e('main_repository'))c['add']('repository_published');if(e('main_service'))c['add']('service_published');e('arb_permission')&&e('main_permission')&&c['add']('arbitration_permission_independent');g('independent_arbitration')&&e('guard_independent_arbitration')&&c['add']('voting_guard_configured');g('accept_timeout_protection')&&(c['add']('time_guard_configured'),c['add']('adminUnhold_permission'));g('milestone_escrow')&&f('guard')&&c['add']('milestone_forward_guarded');if(e('main_allocation')&&b['payment']['allocation']&&b['payment']['allocation']['length']>0x0){c['add']('allocators_configured');const h=b['payment']['allocation']['reduce']((j,k)=>j+k['percentage'],0x0);if(Math['abs'](h-0x64)<0.001)c['add']('sharing_sum_100');const i=b['payment']['allocation']['find'](j=>j['recipient']==='platform');if(i&&i['percentage']===0x0)c['add']('platform_fee_zero');g('supplier_collaboration')&&(c['add']('allocation_sharing_configured'),c['add']('demand_configured'));}return g('wip_provenance')&&e('main_repository')&&c['add']('wip_hash_before_delivery'),g('subscription_with_proof')&&e('main_repository')&&(c['add']('delivery_guard_per_cycle'),c['add']('repository_updated')),g('damage_attestation')&&(c['add']('pre_rental_hash'),c['add']('post_rental_hash')),g('refund_guarantee')&&(c['add']('compensation_fund_positive'),c['add']('refund_guard_configured')),c;}function deriveDeployTimeChecks(a){const b=[];return a['nodes']['some'](c=>c['id']==='main_machine')&&b['push']('Machine\x20published\x20AND\x20bound\x20to\x20Service\x20BEFORE\x20Service.publish\x20(machine\x20is\x20immutable\x20after\x20publish)'),a['edges']['some'](c=>c['relation']==='has_order_allocators')&&b['push']('Service.order_allocators\x20bound\x20(verify\x20via\x20query_objects\x20after\x20publish\x20—\x20order_allocators\x20is\x20FROZEN\x20at\x20publish)'),a['nodes']['some'](c=>c['id']==='main_arbitration')&&b['push']('Arbitration.permission\x20!=\x20Service.permission\x20on-chain\x20(E_ARBITRATION_PERMISSION_CONFLICT=33)'),a['nodes']['some'](c=>c['id']==='main_repository')&&b['push']('Repository\x20published\x20and\x20Guard\x20write\x20validation\x20configured'),b['push']('After\x20materialization,\x20confirm\x20the\x20on-chain\x20state\x20matches\x20this\x20plan\x20(query_toolkit\x20query_type=\x27service_panorama\x27)'),b;}function buildCreationPlan(a){const b=[],c=new Map(a['nodes']['map'](i=>[i['id'],i])),f=new Map();for(const i of a['nodes'])f['set'](i['id'],new Set());for(const j of a['edges']){j['required']&&f['has'](j['from'])&&c['has'](j['to'])&&f['get'](j['from'])['add'](j['to']);}const g=[],h=new Map(f);while(h['size']>0x0){const k=[...h['entries']()]['filter'](([,l])=>l['size']===0x0)['map'](([l])=>l);if(k['length']===0x0){g['push'](...h['keys']());break;}k['sort']();for(const l of k){g['push'](l),h['delete'](l);for(const m of h['values']())m['delete'](l);}}return g['forEach']((o,p)=>{const q=c['get'](o),r=q['config']['name'];b['push']({'order':p+0x1,'node_id':o,'object_type':q['type'],'suggested_name':r?.['type']==='string'?r['value']:o,'depends_on':[...f['get'](o)??[]],'operation_hint':'Create\x20'+q['type']+'\x20via\x20onchain_operations,\x20then\x20configure.\x20Purpose:\x20'+q['purpose']});}),b;}async function resolveModePrior(a){if(!a)return undefined;const b=getIndustryModeRegistry(),c=await b['getUserMode'](a,LOCAL_MODE_OWNER);return c??b['getMode'](a);}export async function handleMerchantGuide(a){const b=a['guide_state']??{'intent_text':''},c=a['guide_confirm']??{},d={'intent_text':(a['intent']??b['intent_text']??'')['trim'](),'confirmed_industry':c['industry']??b['confirmed_industry'],'currency':c['currency']??b['currency'],'deliverables':c['deliverables']??b['deliverables'],'payment_override':c['payment']??b['payment_override'],'trust_override':c['trust']??b['trust_override'],'adopted_module_ids':c['adopted_module_ids']??b['adopted_module_ids']};for(const s of Object['keys'](d)){if(d[s]===undefined)delete d[s];}if(!d['intent_text'])throw new Error('merchant_guide\x20requires\x20\x27intent\x27\x20(business\x20description)\x20for\x20Step\x201.\x20'+'Example:\x20intent=\x27I\x20want\x20to\x20offer\x20online\x20design\x20service\x20with\x20milestone\x20payments\x27.\x20'+'Pass\x20the\x20returned\x20guide_state\x20back\x20UNCHANGED\x20on\x20subsequent\x20calls,\x20plus\x20guide_confirm\x20for\x20merchant\x20decisions.');const e=await analyzeIntent(d['intent_text'],{'preferredIndustry':d['confirmed_industry'],'currency':d['currency']});if(!d['confirmed_industry'])return{'action':'merchant_guide','current_step':0x2,'step_name':'Industry\x20Matching','guide_state':d,'intent_draft':e['intent'],'industry_options':{'inferred':e['inferredIndustry'],'confidence':e['industryConfidence'],'similar':e['similarIndustries']},'warnings':e['warnings'],'next_action':'Confirm\x20the\x20industry\x20by\x20calling\x20merchant_guide\x20again\x20with\x20guide_state\x20(UNCHANGED)\x20'+('plus\x20guide_confirm={\x20industry:\x20\x27<one\x20of:\x20'+e['similarIndustries']['join'](',\x20')+'\x20—\x20or\x20any\x20other\x20industry\x20id>\x27\x20}')};const f={...e['intent'],'industry':d['confirmed_industry'],'deliverables':d['deliverables']??e['intent']['deliverables'],'payment':{...e['intent']['payment'],...d['payment_override']??{}},'trust':{...e['intent']['trust'],...d['trust_override']??{}}},g=d['adopted_module_ids']?d['adopted_module_ids']['map'](t=>getBusinessModule(t))['filter'](t=>!!t):recommendModules(d['confirmed_industry'],d['intent_text'],{'maxModules':0x5}),h=await resolveModePrior(d['confirmed_industry']),i=buildSemanticGraph(f,g,h,{'paymentExplicit':!!(d['payment_override']||d['trust_override'])}),j=validateGraph(i),l=derivePlanSatisfiedConstraints(i,f),m=g['map'](t=>checkModuleConstraints(t,l)),n=deriveDeployTimeChecks(i),o=m['filter'](t=>!t['adopted']),p=checkGameTheoryConstraints(i,f),q=assessWorkflowDesign(i),r=buildCreationPlan(i);return{'action':'merchant_guide','current_step':o['length']>0x0?0x9:0xa,'step_name':o['length']>0x0?'Harness\x20Check\x20(issues\x20found)':'Submission\x20Plan\x20Ready','guide_state':{...d,'adopted_module_ids':g['map'](t=>t['id'])},'intent':{'intent_type':f['intent'],'industry':f['industry'],'roles':f['roles'],'deliverables':f['deliverables'],'payment':f['payment'],'trust':f['trust']},'adopted_modules':g['map'](t=>({'id':t['id'],'name':t['name'],'description':t['description'],'requires_keeper':t['requiresKeeper'],'keeper_hint':t['keeperHint'],'user_protections':t['userProtections'],'merchant_obligations':t['merchantObligations']})),'mode_prior':h?{'name':h['name'],'display_name':h['display_name'],'source':h['source'],'risk_appetite':h['risk_appetite'],'key_risk':h['key_risk'],'machine_shape':h['machine_shape']['map'](t=>({'name':t['name'],'role':t['role']})),'guards':h['guards']['map'](t=>({'template_id':t['template_id'],'host':t['host'],'purpose':t['purpose']})),'allocator':h['allocator'],'risk_constraints':h['risk_constraints'],'build_notes':h['build_notes']??[]}:undefined,'blueprint':{'nodes':i['nodes']['map'](t=>({'id':t['id'],'type':t['type'],'purpose':t['purpose']})),'edges':i['edges']['map'](t=>({'from':t['from'],'to':t['to'],'relation':t['relation'],'required':t['required']}))},'evaluation_preview':i['evaluationPreview'],'graph_validation':{'valid':j['valid'],'hard_violations':j['hardViolations']['map'](t=>({'id':t['id'],'description':t['description'],'fix':t['fixSuggestion']})),'soft_notes':j['softViolations']['map'](t=>({'id':t['id'],'description':t['description']}))},'harness_check':{'module_constraints':m['map'](t=>({'module':t['module'],'plan_satisfied':t['adopted'],'missing':t['missingConstraints'],'reason':t['reason'],'estimated_score_boost':t['estimatedScoreBoost']})),'blocking_issues':o['map'](t=>({'module':t['module'],'missing_constraints':t['missingConstraints'],'fix':t['reason']})),'deploy_time_checks':n},'game_theory':{'summary':p['summary'],'coverage':p['coveredCount']+'/'+p['totalCount'],'exposed_scenarios':p['exposedScenarios'],'wow_alignments':p['wowAlignments'],'scenarios':p['results']['map'](t=>({'scenario':t['scenario'],'covered':t['covered'],'conflict':t['conflict'],'user_protection':t['userProtection'],'evaluation_metric':t['evaluationMetric'],'recommendation':t['recommendation']}))},'workflow_design_assessment':{'score':q['score'],'summary':q['summary'],'findings':q['findings']['map'](t=>({'kind':t['kind'],'severity':t['severity'],'message':t['message'],'fix':t['fix']})),'checks':q['checks']['map'](t=>({'id':t['id'],'dimension':t['dimension'],'passed':t['passed'],'severity':t['severity'],'message':t['message'],'fix':t['fix']}))},'creation_plan':r,'warnings':e['warnings'],'next_action':o['length']>0x0?'Resolve\x20the\x20blocking_issues\x20above\x20(adjust\x20guide_confirm\x20payment/trust/modules,\x20or\x20accept\x20and\x20drop\x20the\x20affected\x20module\x20via\x20guide_confirm.adopted_module_ids),\x20then\x20call\x20merchant_guide\x20again.':'Plan\x20ready.\x20Materialize:\x20create\x20the\x20objects\x20in\x20creation_plan\x20order\x20via\x20onchain_operations,\x20then\x20publish\x20the\x20Service\x20(machine\x20binding\x20is\x20immutable\x20after\x20publish).'};}export function listBusinessModules(){return CORE_BUSINESS_MODULES['map'](a=>({'id':a['id'],'name':a['name'],'description':a['description'],'industry_fit':a['industryFit'],'addresses_pain_points':a['addressesPainPoints'],'requires_keeper':a['requiresKeeper']}));}
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import { type MetricType, type MetricScale, type ConstraintRule, type ConstraintSeverity, type ConstraintViolationAction } from "
|
|
1
|
+
import { type MetricType, type MetricScale, type ConstraintRule, type ConstraintSeverity, type ConstraintViolationAction } from "../../extensions/index.js";
|
|
2
|
+
import { type InfrastructureLever } from "../../persona/strategy-intent.js";
|
|
3
|
+
export declare const LOCAL_MODE_OWNER = "local";
|
|
2
4
|
export interface RecommendIndustryInput {
|
|
3
5
|
intent?: string;
|
|
4
6
|
project_description?: string;
|
|
5
7
|
project_name?: string;
|
|
8
|
+
strategy?: string | string[];
|
|
6
9
|
}
|
|
7
10
|
export declare function handleRecommendIndustry(v: RecommendIndustryInput): {
|
|
8
11
|
action: "recommend_industry";
|
|
9
12
|
intent: string;
|
|
10
|
-
inferred_traits: import("
|
|
13
|
+
inferred_traits: import("../../knowledge/industry-registry.js").IndustryTraits;
|
|
11
14
|
inference_confidence: number;
|
|
12
15
|
matched_keywords: string[];
|
|
16
|
+
strategy_intents: import("../../persona/strategy-intent.js").StrategyIntent[];
|
|
17
|
+
lever_suggestions: import("../../persona/strategy-intent.js").LeverSuggestion[];
|
|
13
18
|
recommendations: {
|
|
14
19
|
industry: string;
|
|
15
20
|
similarity: number;
|
|
@@ -20,6 +25,11 @@ export declare function handleRecommendIndustry(v: RecommendIndustryInput): {
|
|
|
20
25
|
operation_type: string;
|
|
21
26
|
verified: boolean;
|
|
22
27
|
}[];
|
|
28
|
+
strategy_alignment: {
|
|
29
|
+
score: number;
|
|
30
|
+
matched_levers: InfrastructureLever[];
|
|
31
|
+
missing_levers: InfrastructureLever[];
|
|
32
|
+
} | undefined;
|
|
23
33
|
}[];
|
|
24
34
|
hint: string;
|
|
25
35
|
};
|
|
@@ -135,7 +145,7 @@ export interface RegisterCustomMetricInput {
|
|
|
135
145
|
metric_scale?: MetricScale;
|
|
136
146
|
metric_weight?: number;
|
|
137
147
|
}
|
|
138
|
-
export declare function handleRegisterCustomMetric(v: RegisterCustomMetricInput): {
|
|
148
|
+
export declare function handleRegisterCustomMetric(v: RegisterCustomMetricInput): Promise<{
|
|
139
149
|
action: "register_custom_metric";
|
|
140
150
|
metric: {
|
|
141
151
|
metric_id: string;
|
|
@@ -148,7 +158,14 @@ export declare function handleRegisterCustomMetric(v: RegisterCustomMetricInput)
|
|
|
148
158
|
owner: string;
|
|
149
159
|
};
|
|
150
160
|
hint: string;
|
|
151
|
-
}
|
|
161
|
+
}>;
|
|
162
|
+
export declare function handleUnregisterCustomMetric(v: {
|
|
163
|
+
metric_id?: string;
|
|
164
|
+
}): Promise<{
|
|
165
|
+
action: "unregister_custom_metric";
|
|
166
|
+
removed: true;
|
|
167
|
+
metric_id: string;
|
|
168
|
+
}>;
|
|
152
169
|
export interface RegisterCustomConstraintInput {
|
|
153
170
|
constraint_id?: string;
|
|
154
171
|
constraint_display_name?: string;
|
|
@@ -157,7 +174,7 @@ export interface RegisterCustomConstraintInput {
|
|
|
157
174
|
constraint_severity?: ConstraintSeverity;
|
|
158
175
|
constraint_on_violation?: ConstraintViolationAction;
|
|
159
176
|
}
|
|
160
|
-
export declare function handleRegisterCustomConstraint(v: RegisterCustomConstraintInput): {
|
|
177
|
+
export declare function handleRegisterCustomConstraint(v: RegisterCustomConstraintInput): Promise<{
|
|
161
178
|
action: "register_custom_constraint";
|
|
162
179
|
constraint: {
|
|
163
180
|
constraint_id: string;
|
|
@@ -170,12 +187,19 @@ export declare function handleRegisterCustomConstraint(v: RegisterCustomConstrai
|
|
|
170
187
|
owner: string;
|
|
171
188
|
};
|
|
172
189
|
hint: string;
|
|
173
|
-
}
|
|
190
|
+
}>;
|
|
191
|
+
export declare function handleUnregisterCustomConstraint(v: {
|
|
192
|
+
constraint_id?: string;
|
|
193
|
+
}): Promise<{
|
|
194
|
+
action: "unregister_custom_constraint";
|
|
195
|
+
removed: true;
|
|
196
|
+
constraint_id: string;
|
|
197
|
+
}>;
|
|
174
198
|
export interface ListMetricsConstraintsInput {
|
|
175
199
|
metric_type_filter?: MetricType;
|
|
176
200
|
scope_filter?: "builtin" | "custom";
|
|
177
201
|
}
|
|
178
|
-
export declare function handleListMetricsConstraints(v: ListMetricsConstraintsInput): {
|
|
202
|
+
export declare function handleListMetricsConstraints(v: ListMetricsConstraintsInput): Promise<{
|
|
179
203
|
action: "list_metrics_constraints";
|
|
180
204
|
metrics: {
|
|
181
205
|
metric_id: string;
|
|
@@ -196,4 +220,4 @@ export declare function handleListMetricsConstraints(v: ListMetricsConstraintsIn
|
|
|
196
220
|
scope: "custom" | "builtin";
|
|
197
221
|
}[];
|
|
198
222
|
hint: string;
|
|
199
|
-
}
|
|
223
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getIndustryModeRegistry,getMetricRegistry,getConstraintRegistry}from'../../extensions/index.js';import{inferTraitsFromDescription,findSimilarIndustries}from'../../knowledge/industry-generalizer.js';import{searchExamples}from'../../schema-query-impl/index.js';import{resolveObjective,buildStrategyIntent,suggestLevers}from'../../persona/strategy-intent.js';export const LOCAL_MODE_OWNER='local';const RM1_11_NODE_REGEX=/(^|_)(disputed?|refund(?:ed)?|arbitration|arb)(_|$)/i;function validateMachineShape(a,b){const c=[];if(!Array['isArray'](a))return c;const d=new Set();for(const e of a){const f=e?.['name'];if(typeof f!=='string'||!f){c['push'](b+':\x20every\x20node\x20must\x20have\x20a\x20non-empty\x20string\x20\x27name\x27');continue;}d['has'](f)&&c['push'](b+':\x20duplicate\x20node\x20name\x20\x27'+f+'\x27\x20(R-M1-10)'),d['add'](f),RM1_11_NODE_REGEX['test'](f)&&c['push'](b+':\x20node\x20\x27'+f+'\x27\x20violates\x20R-M1-11\x20—\x20dispute/refund\x20flows\x20must\x20NOT\x20be\x20'+'modeled\x20as\x20Machine\x20nodes.\x20Disputes\x20flow\x20through\x20Service.arbitrations\x20→\x20Arbitration.dispute()\x20'+'independently\x20of\x20the\x20Machine.\x20Use\x20business-state\x20nodes\x20(e.g.\x20\x27cancelled\x27,\x20\x27return_approved\x27)\x20'+'and\x20route\x20fund\x20refunds\x20via\x20Allocator\x20triggered\x20by\x20those\x20states.');}return c;}function modeLevers(a){const b=[];return(a['capabilities_used']['some'](d=>d['startsWith']('reward.'))||a['flywheel']?.['rewardStrategy']&&a['flywheel']['rewardStrategy']!=='User-defined')&&b['push']('reward'),(a['flywheel']?.['discountStrategy']&&a['flywheel']['discountStrategy']!=='User-defined'||a['config_overrides']?.['service']?.['first_order_discount']===!![])&&b['push']('discount'),(a['capabilities_used']['includes']('guard.validate_buy')||a['guards']['some'](c=>c['template_id']['includes']('buy')))&&b['push']('buy_guard'),a['capabilities_used']['includes']('machine.node_topology')&&a['machine_shape']['length']>0x0&&b['push']('machine_design'),b;}function resolveStrategyObjectives(a){const b=typeof a==='string'?[a]:a??[],c=new Set();for(const d of b){const e=resolveObjective(d);if(e)c['add'](e);}return[...c];}export function handleRecommendIndustry(a){const b=(a['intent']??a['project_description']??a['project_name']??'')['trim']();if(!b)throw new Error('recommend_industry\x20requires\x20\x27intent\x27\x20(business\x20description\x20text).\x20'+'Example:\x20intent=\x27I\x20rent\x20cameras\x20to\x20photographers\x20with\x20deposit\x20and\x20damage\x20inspection\x27.');const c=inferTraitsFromDescription(b),d=findSimilarIndustries(c['traits'],0x3),e=resolveStrategyObjectives(a['strategy']),f=e['map'](k=>buildStrategyIntent(k)),g=[...new Set(f['flatMap'](k=>k['levers']))],h=getIndustryModeRegistry(),i=d['map'](k=>{const l=searchExamples(k['industry'])['slice'](0x0,0x3)['map'](r=>({'file':r['file'],'title':r['title'],'operation_type':r['operation_type'],'verified':r['verified']})),n=h['getMode'](k['industry']),o=n?modeLevers(n):[],p=g['filter'](r=>o['includes'](r)),q=g['length']>0x0?{'score':p['length']/g['length'],'matched_levers':p,'missing_levers':g['filter'](r=>!o['includes'](r))}:undefined;return{'industry':k['industry'],'similarity':k['similarity'],'matched_traits':k['matched_traits'],'reference_examples':l,'strategy_alignment':q};});g['length']>0x0&&i['sort']((k,l)=>{const m=k['similarity']*0.7+(k['strategy_alignment']?.['score']??0x0)*0.3,n=l['similarity']*0.7+(l['strategy_alignment']?.['score']??0x0)*0.3;return n-m;});const j=i[0x0];return{'action':'recommend_industry','intent':b,'inferred_traits':c['traits'],'inference_confidence':c['confidence'],'matched_keywords':c['matched_keywords'],'strategy_intents':f,'lever_suggestions':f['flatMap'](k=>suggestLevers(k)),'recommendations':i,'hint':j?'Top\x20match:\x20\x27'+j['industry']+'\x27\x20(similarity\x20'+(j['similarity']*0x64)['toFixed'](0x0)+'%'+(g['length']>0x0?',\x20strategy\x20alignment\x20'+((j['strategy_alignment']?.['score']??0x0)*0x64)['toFixed'](0x0)+'%':'')+').\x20Use\x20it\x20to\x20shape\x20the\x20build\x20—\x20run\x20goal_operation\x20action=\x27merchant_guide\x27\x20(or\x20\x27analyze_intent\x27)\x20with\x20this\x20industry\x20context,\x20'+'or\x20choose\x20another\x20industry\x20from\x20\x27recommendations\x27.\x20'+'Review\x20reference\x20examples\x20via\x20schema_query\x20action=\x27search_examples\x27\x20query=\x27<industry>\x27.':'No\x20similar\x20industry\x20found.\x20Shape\x20the\x20build\x20from\x20scratch\x20via\x20goal_operation\x20action=\x27merchant_guide\x27.'};}export async function handleListModes(){const a=getIndustryModeRegistry(),b=a['listModes']()['filter'](d=>d['source']==='builtin')['map'](d=>({'name':d['name'],'display_name':d['display_name'],'version':d['version'],'key_risk':d['key_risk'],'machine_nodes':d['machine_shape']['map'](e=>e['name']),'similar_industries':d['similar_industries']??[]})),c=(await a['listUserModes'](LOCAL_MODE_OWNER))['map'](d=>({'name':d['name'],'display_name':d['display_name'],'version':d['version'],'derived_from':d['derived_from']??null,'key_risk':d['key_risk'],'machine_nodes':d['machine_shape']['map'](e=>e['name']),'evolution_history':(d['evolution_history']??[])['map'](e=>({'version':e['version'],'changed_at':e['changed_at'],'changes':e['changes']}))}));return{'action':'list_modes','builtin_modes':b,'user_modes':c,'owner':LOCAL_MODE_OWNER,'hint':'Use\x20a\x20builtin\x20mode\x20name\x20as\x20the\x20industry/mode\x20context\x20for\x20your\x20build\x20(see\x20recommend_industry\x20/\x20merchant_guide).\x20'+'Use\x20derive_user_mode\x20to\x20customize\x20a\x20builtin\x20mode,\x20or\x20register_user_mode\x20for\x20a\x20fully\x20custom\x20mode.\x20'+'User\x20modes\x20are\x20referenced\x20as\x20\x27<name>\x27\x20in\x20derive/evolve/unregister\x20actions.'};}export async function handleDeriveUserMode(a){const b=requireField(a['mode_source'],'mode_source'),c=requireField(a['mode_name'],'mode_name'),d=a['mode_changes']??{},e=validateMachineShape(d['machine_shape'],'mode_changes.machine_shape');if(e['length']>0x0)throw new Error('derive_user_mode\x20blocked:\x0a'+e['join']('\x0a'));const f=getIndustryModeRegistry(),g=await f['deriveMode'](b,d,LOCAL_MODE_OWNER,c,a['mode_display_name']);if(!g)throw new Error('derive_user_mode\x20failed:\x20source\x20mode\x20\x27'+b+'\x27\x20not\x20found,\x20or\x20name\x20\x27'+c+'\x27\x20conflicts\x20'+'with\x20a\x20builtin/existing\x20user\x20mode.\x20Call\x20list_modes\x20to\x20see\x20available\x20names.');return{'action':'derive_user_mode','mode':summarizeUserMode(g),'hint':'Mode\x20\x27'+c+'\x27\x20derived\x20from\x20\x27'+b+'\x27.\x20Use\x20it\x20as\x20the\x20industry/mode\x20context\x20for\x20your\x20build.\x20'+'Iterate\x20with\x20evolve_user_mode.'};}export async function handleEvolveUserMode(a){const b=requireField(a['mode_name'],'mode_name'),c=requireField(a['mode_change_description'],'mode_change_description'),d=a['mode_changes']??{},e=validateMachineShape(d['machine_shape'],'mode_changes.machine_shape');if(e['length']>0x0)throw new Error('evolve_user_mode\x20blocked:\x0a'+e['join']('\x0a'));const f=getIndustryModeRegistry(),g=await f['evolveMode'](b,d,LOCAL_MODE_OWNER,c,a['mode_bump_version']??!![]);if(!g)throw new Error('evolve_user_mode\x20failed:\x20user\x20mode\x20\x27'+b+'\x27\x20not\x20found\x20for\x20owner\x20\x27'+LOCAL_MODE_OWNER+'\x27.\x20'+'Call\x20list_modes\x20to\x20see\x20your\x20modes.');return{'action':'evolve_user_mode','mode':summarizeUserMode(g),'hint':'Mode\x20\x27'+b+'\x27\x20evolved\x20to\x20'+g['version']+'.\x20Evolution\x20history\x20recorded.'};}export async function handleRegisterUserMode(a){const b=requireField(a['mode_name'],'mode_name'),c=a['mode_changes']??{},d=[];(!Array['isArray'](c['machine_shape'])||c['machine_shape']['length']===0x0)&&d['push']('machine_shape\x20(non-empty\x20array\x20of\x20{name,\x20role})');(typeof c['key_risk']!=='string'||!c['key_risk'])&&d['push']('key_risk\x20(string\x20describing\x20the\x20industry\x27s\x20key\x20risk)');if(d['length']>0x0)throw new Error('register_user_mode\x20requires\x20these\x20fields\x20in\x20mode_changes:\x20'+d['join'](',\x20')+'.\x20'+'Tip:\x20derive_user_mode\x20from\x20a\x20builtin\x20mode\x20is\x20usually\x20easier\x20than\x20registering\x20from\x20scratch.');const e=validateMachineShape(c['machine_shape'],'mode_changes.machine_shape');if(e['length']>0x0)throw new Error('register_user_mode\x20blocked:\x0a'+e['join']('\x0a'));const f=getIndustryModeRegistry(),g=f['getMode']('general');if(!g)throw new Error('Builtin\x20mode\x20\x27general\x27\x20not\x20registered\x20—\x20cannot\x20build\x20custom\x20mode\x20defaults');const h={...g,...c,'name':b,'display_name':a['mode_display_name']??b,'version':'v1','source':'custom','owner':LOCAL_MODE_OWNER,'derived_from':undefined,'evolution_history':[]},i=await f['registerUserMode'](h,LOCAL_MODE_OWNER);if(!i)throw new Error('register_user_mode\x20failed:\x20name\x20\x27'+b+'\x27\x20conflicts\x20with\x20a\x20builtin/existing\x20user\x20mode,\x20'+'or\x20payload\x20is\x20invalid.\x20Call\x20list_modes\x20to\x20see\x20available\x20names.');return{'action':'register_user_mode','mode':summarizeUserMode(h),'hint':'Custom\x20mode\x20\x27'+b+'\x27\x20registered.\x20Use\x20it\x20as\x20the\x20industry/mode\x20context\x20for\x20your\x20build.'};}export async function handleUnregisterUserMode(a){const b=requireField(a['mode_name'],'mode_name'),c=getIndustryModeRegistry(),d=await c['unregisterUserMode'](b,LOCAL_MODE_OWNER);if(!d)throw new Error('unregister_user_mode\x20failed:\x20user\x20mode\x20\x27'+b+'\x27\x20not\x20found\x20for\x20owner\x20\x27'+LOCAL_MODE_OWNER+'\x27.');return{'action':'unregister_user_mode','removed':!![],'mode_name':b};}export async function handleRegisterCustomMetric(a){const b=requireField(a['metric_id'],'metric_id'),c=requireField(a['metric_display_name'],'metric_display_name'),d=requireField(a['metric_description'],'metric_description'),e=requireField(a['metric_type'],'metric_type'),f=requireField(a['metric_scale'],'metric_scale'),g=await getMetricRegistry()['registerCustomMetric'](b,c,d,e,f,LOCAL_MODE_OWNER,a['metric_weight']);if(!g)throw new Error('register_custom_metric\x20failed:\x20metric_id\x20\x27'+b+'\x27\x20already\x20exists\x20or\x20fields\x20are\x20invalid.');return{'action':'register_custom_metric','metric':{'metric_id':b,'display_name':c,'description':d,'type':e,'scale':f,'weight':a['metric_weight']??0x1,'scope':'custom','owner':LOCAL_MODE_OWNER},'hint':'Custom\x20metric\x20\x27'+b+'\x27\x20registered\x20globally\x20and\x20persisted\x20(survives\x20restart)\x20—\x20all\x20modes\x20reference\x20it\x20in\x20evaluation.'};}export async function handleUnregisterCustomMetric(a){const b=requireField(a['metric_id'],'metric_id'),c=await getMetricRegistry()['unregisterMetric'](b,LOCAL_MODE_OWNER);if(!c)throw new Error('unregister_custom_metric\x20failed:\x20custom\x20metric\x20\x27'+b+'\x27\x20not\x20found\x20(builtin\x20metrics\x20cannot\x20be\x20deleted).\x20'+'Call\x20list_metrics_constraints\x20with\x20scope_filter=\x27custom\x27\x20to\x20see\x20deletable\x20metrics.');return{'action':'unregister_custom_metric','removed':!![],'metric_id':b};}export async function handleRegisterCustomConstraint(a){const b=requireField(a['constraint_id'],'constraint_id'),c=requireField(a['constraint_display_name'],'constraint_display_name'),d=requireField(a['constraint_description'],'constraint_description'),e=a['constraint_rule'];if(!e||typeof e!=='object'||!('type'in e))throw new Error('constraint_rule\x20is\x20required\x20and\x20must\x20be\x20one\x20of:\x20'+'{type:\x27capability_required\x27,\x20capability_id}\x20|\x20{type:\x27capability_forbidden\x27,\x20capability_id}\x20|\x20'+'{type:\x27numeric_limit\x27,\x20field,\x20max?,\x20min?}\x20|\x20{type:\x27condition_required\x27,\x20condition,\x20ai_evaluated:true}');const f=await getConstraintRegistry()['registerCustomConstraint'](b,c,d,e,LOCAL_MODE_OWNER,a['constraint_severity']??'soft',a['constraint_on_violation']??'warn');if(!f)throw new Error('register_custom_constraint\x20failed:\x20constraint_id\x20\x27'+b+'\x27\x20already\x20exists\x20or\x20rule\x20is\x20invalid.');return{'action':'register_custom_constraint','constraint':{'constraint_id':b,'display_name':c,'description':d,'rule':e,'severity':a['constraint_severity']??'soft','on_violation':a['constraint_on_violation']??'warn','scope':'custom','owner':LOCAL_MODE_OWNER},'hint':'Custom\x20constraint\x20\x27'+b+'\x27\x20registered\x20and\x20persisted\x20(survives\x20restart).\x20\x27hard\x27\x20constraints\x20mark\x20a\x20mode\x20not\x20applicable\x20on\x20violation;\x20\x27soft\x27\x20only\x20warn.'};}export async function handleUnregisterCustomConstraint(a){const b=requireField(a['constraint_id'],'constraint_id'),c=await getConstraintRegistry()['unregisterConstraint'](b,LOCAL_MODE_OWNER);if(!c)throw new Error('unregister_custom_constraint\x20failed:\x20custom\x20constraint\x20\x27'+b+'\x27\x20not\x20found\x20(builtin\x20constraints\x20cannot\x20be\x20deleted).\x20'+'Call\x20list_metrics_constraints\x20with\x20scope_filter=\x27custom\x27\x20to\x20see\x20deletable\x20constraints.');return{'action':'unregister_custom_constraint','removed':!![],'constraint_id':b};}export async function handleListMetricsConstraints(a){const b=(await getMetricRegistry()['listMetrics']({'type':a['metric_type_filter'],'scope':a['scope_filter']}))['map'](d=>({'metric_id':d['metric_id'],'display_name':d['display_name'],'description':d['description'],'type':d['type'],'scale':d['scale'],'weight':d['weight'],'scope':d['scope']})),c=(await getConstraintRegistry()['listConstraints']({'scope':a['scope_filter']}))['map'](d=>({'constraint_id':d['constraint_id'],'display_name':d['display_name'],'description':d['description'],'rule':d['rule'],'severity':d['severity'],'on_violation':d['on_violation'],'scope':d['scope']}));return{'action':'list_metrics_constraints','metrics':b,'constraints':c,'hint':'Register\x20custom\x20entries\x20via\x20register_custom_metric\x20/\x20register_custom_constraint;\x20'+'delete\x20via\x20unregister_custom_metric\x20/\x20unregister_custom_constraint\x20(custom\x20only).\x20'+'Custom\x20entries\x20are\x20persisted\x20and\x20survive\x20restart.\x20'+'Filter\x20with\x20metric_type_filter\x20(\x27risk\x27|\x27benefit\x27)\x20or\x20scope_filter\x20(\x27builtin\x27|\x27custom\x27).'};}function requireField(a,b){if(a===undefined||a===null||typeof a==='string'&&!a['trim']())throw new Error('\x27'+b+'\x27\x20is\x20required\x20for\x20this\x20action');return a;}function summarizeUserMode(a){return{'name':a['name'],'display_name':a['display_name'],'version':a['version'],'derived_from':a['derived_from']??null,'owner':a['owner'],'key_risk':a['key_risk'],'machine_nodes':a['machine_shape']['map'](b=>b['name']),'evolution_history':(a['evolution_history']??[])['map'](b=>({'version':b['version'],'changed_at':b['changed_at'],'changes':b['changes']}))};}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export type ProjectObjectType = "service" | "machine" | "guard" | "permission" | "reward" | "arb" | "progress" | "treasury" | "demand" | "repository" | "contact" | "order" | "allocation" | "personal" | "payment" | "proof";
|
|
2
|
+
export type IndustryMode = "freelance" | "rental" | "education" | "travel" | "subscription" | "general";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
type ProjectInput = z.infer<typeof ProjectOperationInputSchema>;
|
|
1
|
+
import type { ObjectPanoramaInput } from "../../schema/query/bi.js";
|
|
2
|
+
type ProjectInput = ObjectPanoramaInput;
|
|
4
3
|
interface PanoBase {
|
|
5
4
|
action: "object_panorama";
|
|
6
5
|
object: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Config,LocalMark,query_objects,query_object_last_updated,objectTypeFromAddress,ObjectType}from'@wowok/wowok';import{batchReadAddressKeyedFields,fetchObjectLinkerTx}from'../../knowledge/workflow-guidance.js';const js=a=>{if(typeof a==='bigint')return a['toString']();if(a&&typeof a==='object'&&!Array['isArray'](a)){const b={};for(const [c,d]of Object['entries'](a)){b[c]=js(d);}return b;}if(Array['isArray'](a))return a['map'](js);return a;},str=a=>a===null||a===undefined?null:String(a),ownerAddr=a=>{if(typeof a==='string')return a;const b=a;if(b&&typeof b==='object'){if(typeof b['AddressOwner']==='string')return b['AddressOwner'];if(typeof b['ObjectOwner']==='string')return b['ObjectOwner'];const c=Object['values'](b)['find'](d=>typeof d==='string'&&d['length']>0x14);if(typeof c==='string')return c;}return null;},num=a=>{if(typeof a==='bigint')return Number(a);if(typeof a==='number')return Number['isFinite'](a)?a:null;if(typeof a==='string'&&a['trim']()!==''){const b=Number(a);return Number['isFinite'](b)?b:null;}return null;},arr=a=>Array['isArray'](a)?a:[],ARB_STATUS_NAMES={0x0:'Principal_confirming',0x1:'Arbitrator_confirming',0x2:'Voting',0x3:'Arbitrated',0x4:'Objectionable',0x5:'Finished',0x6:'Withdrawn'};async function resolveObject(a,b){let c=a;if(!/^0x[0-9a-fA-F]{32,64}$/['test'](c)){const g=await LocalMark['Instance']()['get_address'](c);if(!g)throw new Error('Cannot\x20resolve\x20\x27'+c+'\x27\x20—\x20not\x20a\x20valid\x20address\x20and\x20no\x20LocalMark\x20entry\x20found.');c=g;}let d=b??undefined,f=null;if(!d)d=await Config['Instance']()['network_get']();try{const h=await query_objects({'objects':[c],'network':d});f=h?.['objects']?.[0x0]??null;if(!f&&b){const i=await Config['Instance']()['network_get']();if(i&&i!==d){const j=await query_objects({'objects':[c],'network':i,'no_cache':!![]}),k=j?.['objects']?.[0x0]??null;k&&(f=k,d=i);}}}catch(l){throw new Error('Failed\x20to\x20query\x20'+c+'\x20on\x20'+d+':\x20'+(l instanceof Error?l['message']:String(l)));}if(!f)throw new Error(c+'\x20not\x20found\x20on\x20'+d+'.\x20It\x20may\x20not\x20exist\x20on\x20this\x20network.');return f['object']=f['object']??c,{'network':String(d),'obj':f};}async function resolveHead(a,b,c){let d=null,e=[];try{const f=await LocalMark['Instance']()['list']({'address':a});f['length']>0x0&&(d=f[0x0]['name']??null,e=(f[0x0]['tags']??[])['map'](g=>String(g)));}catch{c['push']('head:\x20LocalMark\x20lookup\x20failed');}return{'name':d,'tags':e,'description':str(b['description'])};}async function buildPresenters(a,b,c){const d=[];let e=0x0;try{const f=await fetchObjectLinkerTx(a,b,!![]),g=(f?.['items']??[])['map'](j=>({'service':String(j?.['who']??''),'time':typeof j?.['time']==='number'?j['time']:null}))['filter'](j=>objectTypeFromAddress(j['service'])===ObjectType['Service']);e=g['length'];const h=g['slice'](-0x32)['reverse'](),i=await batchReadAddressKeyedFields(a,h['map'](j=>j['service']),b,!![]);for(const j of h){const k=i['get'](j['service']['toLowerCase']());d['push']({'service':j['service'],'recommend':str(k?.['recommend']),'acceptance_score':num(k?.['acceptance_score']),'feedback':str(k?.['feedback']),'feedback_time':num(k?.['feedback_time']),'update_time':num(k?.['update_time'])??j['time']});}}catch{c['push']('presenters:\x20global-table\x20lookup\x20failed\x20(non-blocking)');}return{'count':e,'items':d};}async function buildRepositoryData(a,b,c){return void a,void b,c['push']('data:\x20per-key\x20enumeration\x20requires\x20the\x20{entity,name}\x20pair\x20—\x20showing\x20count\x20only'),{'count':null,'items':[]};}export async function handleObjectPanorama(b){const c=b['object_address'];if(!c)throw new Error('\x27object_address\x27\x20is\x20required\x20for\x20object_panorama');const {network:d,obj:e}=await resolveObject(c,b['context_network']),f=String(e['object']),g=[],h=await resolveHead(f,e,g),j=String(e['type']??'');if(j==='Progress'){const k=arr(e['session'])[0x0],l=k?{'next_node':str(k['next_node']),'weights':num(k['weights']),'threshold':num(k['threshold']),'forwards':arr(k['forwards'])['map'](n=>{const o=n;return{'forward':str(o['forward'])??'','who':str(o['who']),'accomplished':o['accomplished']===!![],'msg':str(o['msg']),'time':num(o['time'])};})}:null,m={'key':typeof e['machine']==='string'?e['machine']:null,'items':[],'count':0x0};if(m['key'])try{const n=await fetchObjectLinkerTx(m['key'],d,!![]),o=n?.['items']??[];for(const q of o['slice'](-0x32)['reverse']()){const r=typeof q?.['who']==='string'?q['who']:'';if(!r||r['toLowerCase']()===f['toLowerCase']())continue;let s;try{s=objectTypeFromAddress(r);}catch{}if(!s)continue;m['items']['push']({'address':r,'object_type':s,'time':typeof q?.['time']==='number'?q['time']:null});}m['count']=m['items']['length'];}catch{g['push']('related:\x20ObjectLinkerTx(machine)\x20lookup\x20failed');}return{'action':'object_panorama','object':f,'object_type':'Progress','network':d,'head':h,'fields':{'machine':str(e['machine']),'current':str(e['current']),'task':str(e['task']),'history_count':num(e['history_count']),'current_time':num(e['current_time'])},'context_repositories':arr(e['context_repositories'])['map'](t=>String(t)),'operators':arr(e['namedOperator'])['map'](t=>{const u=t;return{'name':str(u['name'])??'','operators':arr(u['operators'])['map'](w=>String(w))};}),'session':l,'related':m,'data_gaps':g};}if(j==='Demand')return{'action':'object_panorama','object':f,'object_type':'Demand','network':d,'head':h,'fields':{'location':str(e['location']),'um':str(e['um']),'permission':str(e['permission']),'presenters_count':num(e['presenters_count'])},'rewards':arr(e['rewards'])['map'](t=>String(t)),'guards':arr(e['guards'])['map'](t=>({'guard':str(t['guard'])??''})),'presenters':await buildPresenters(f,d,g),'data_gaps':g};if(j==='Order'){let t=null;try{const C=await query_object_last_updated({'object':f,'network':d,'previous_transaction':str(e['previousTransaction'])});t=C?.['timestamp_ms']?Number(C['timestamp_ms'])||null:null;}catch{}let u='none',w=null,x=null;const y=str(e['allocation']),z=str(e['progress']),A=[y,z]['filter'](D=>!!D);if(A['length']>0x0)try{const D=await query_objects({'objects':A,'network':d}),E=D?.['objects']??[];if(y){u='pending';const F=E['find'](H=>H?.['object']===y),G=Number(F?.['balance']??NaN);if(Number['isFinite'](G)&&G===0x0)u='allocated';}if(z){const H=E['find'](I=>I?.['object']===z);w=str(H?.['current']),x=num(H?.['current_time']);}}catch{}const B={'key':f,'items':[],'count':0x0};try{const I=await fetchObjectLinkerTx(f,d,!![]),J=I?.['items']??[];for(const K of J['slice'](-0x32)['reverse']()){const L=typeof K?.['who']==='string'?K['who']:'';if(!L||L['toLowerCase']()===f['toLowerCase']())continue;let M;try{M=objectTypeFromAddress(L);}catch{}if(!M)continue;B['items']['push']({'address':L,'object_type':M,'time':typeof K?.['time']==='number'?K['time']:null});}B['count']=B['items']['length'];}catch{g['push']('related:\x20ObjectLinkerTx(order)\x20lookup\x20failed');}return{'action':'object_panorama','object':f,'object_type':'Order','network':d,'head':h,'fields':{'service':str(e['service']),'machine':str(e['machine']),'progress':z,'allocation':y,'discount':str(e['discount']),'amount':str(e['amount']),'owner':ownerAddr(e['builder']??e['owner']),'claimed_by':str(e['claimed_by']),'required_info':str(e['required_info']),'time':num(e['time'])},'updated_ms':t,'related':B,'allocation_state':u,'progress_next':w,'progress_since':x,'items':arr(e['items'])['map'](N=>{const O=N;return{'name':str(O['name']),'price':str(O['price']),'quantity':str(O['quantity']),'wip_hash':str(O['wip_hash'])};}),'disputes':arr(e['dispute'])['map'](N=>String(N)),'agents':arr(e['agent'])['map'](N=>String(N)),'data_gaps':g};}if(j==='Arb'){const N=e['indemnity'];let O=null;try{const S=await query_object_last_updated({'object':f,'network':d,'previous_transaction':str(e['previousTransaction'])});O=S?.['timestamp_ms']?Number(S['timestamp_ms'])||null:null;}catch{}const P=str(e['order']);let Q=null;if(P)try{const T=await query_objects({'objects':[P],'network':d}),U=T?.['objects']?.[0x0];Q=str(U?.['service']);}catch{}const R={'key':f,'items':[],'count':0x0};try{const V=await fetchObjectLinkerTx(f,d,!![]),W=V?.['items']??[];for(const X of W['slice'](-0x32)['reverse']()){const Y=typeof X?.['who']==='string'?X['who']:'';if(!Y||Y['toLowerCase']()===f['toLowerCase']())continue;let Z;try{Z=objectTypeFromAddress(Y);}catch{}if(!Z)continue;R['items']['push']({'address':Y,'object_type':Z,'time':typeof X?.['time']==='number'?X['time']:null});}R['count']=R['items']['length'];}catch{g['push']('related:\x20ObjectLinkerTx(arb)\x20lookup\x20failed');}return{'action':'object_panorama','object':f,'object_type':'Arb','network':d,'head':h,'fields':{'arbitration':str(e['arbitration']),'order':str(e['order']),'service':Q,'fee':str(e['fee']),'feedback':str(e['feedback']),'indemnity':N?{'amount':str(N['amount']),'time':num(N['time'])}:null,'voting_deadline':num(e['voting_deadline']),'objection':str(e['objection']),'status':ARB_STATUS_NAMES[num(e['status'])??-0x1]??str(e['status']),'compensation_time':num(e['compensation_time']),'time':num(e['time']),'type_raw':str(e['type_raw'])},'voted':arr(e['voted'])['map'](a0=>{const a1=a0;return{'voter':str(a1['voter'])??'','agrees':arr(a1['agrees'])['map'](a2=>Number(a2)),'weight':num(a1['weight'])??0x0,'time':num(a1['time'])??0x0};}),'proposition':arr(e['proposition'])['map'](a0=>{const a1=a0;return{'name':str(a1['name'])??'','votes':num(a1['votes'])??0x0};}),'related':R,'updated_ms':O,'data_gaps':g};}if(j==='Repository')return{'action':'object_panorama','object':f,'object_type':'Repository','network':d,'head':h,'fields':{'um':str(e['um']),'permission':str(e['permission']),'data_count':num(e['data_count'])},'policies':arr(e['policies'])['map'](a0=>{const a1=a0;return{'name':str(a1['name'])??'','description':str(a1['description']),'id_from':str(a1['id_from']),'value_type':str(a1['value_type']),'write_guards':arr(a1['write_guard'])['length'],'quote_guard':str(a1['quote_guard'])};}),'rewards':arr(e['rewards'])['map'](a0=>String(a0)),'data_entries':await buildRepositoryData(f,d,g),'data_gaps':g};throw new Error('object_panorama:\x20unsupported\x20object\x20type\x20\x27'+(j||'unknown')+'\x27\x20for\x20'+f+'.\x20'+'Supported:\x20Progress\x20/\x20Demand\x20/\x20Order\x20/\x20Arb\x20/\x20Repository.');}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
type ProjectInput = z.infer<typeof ProjectOperationInputSchema>;
|
|
1
|
+
import { type OrderRadarResult } from "../../participation/radar-core.js";
|
|
2
|
+
import type { ParticipationRadarInput } from "../../schema/query/bi.js";
|
|
3
|
+
type ProjectInput = ParticipationRadarInput;
|
|
5
4
|
export declare function handleParticipationRadar(v: ProjectInput): Promise<{
|
|
6
5
|
action: "participation_radar";
|
|
7
6
|
account: string;
|
|
8
7
|
orders_analyzed: number;
|
|
9
8
|
actionable: OrderRadarResult[];
|
|
10
9
|
waiting: OrderRadarResult[];
|
|
11
|
-
all_pending_claims: (import("
|
|
10
|
+
all_pending_claims: (import("../../participation/radar-core.js").PendingClaim & {
|
|
12
11
|
progress: string;
|
|
13
12
|
})[];
|
|
14
13
|
unread_messages_total: number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LocalMark,watch_conversations}from'@wowok/wowok';import{analyzeOrderParticipation,aggregateRadar,isConsequenceNode}from'../../participation/radar-core.js';import{monitorOrder}from'../../customer/order-monitor.js';import{analyzeMerchantInterest}from'../../participation/merchant-interest.js';import{analyzeCustomerInterest}from'../../participation/customer-interest.js';import{analyzeSupplierInterest}from'../../participation/supplier-interest.js';import{analyzeCollaboratorInterest}from'../../participation/collaborator-interest.js';import{fetchMachineNodes}from'./machine-nodes.js';import{extractGenericTokenType,registryDisplayHint}from'../../knowledge/fund-layer.js';import{batchQueryObjectsByIds,batchQueryTableItems}from'../../knowledge/workflow-guidance.js';function fld(a,b){return a?.[b]??a?.['data']?.[b];}async function resolveAddress(a,b){const c=await LocalMark['Instance']()['get_address'](a);if(!c)throw new Error('Cannot\x20resolve\x20'+b+'\x20\x27'+a+'\x27\x20—\x20not\x20a\x20valid\x20address\x20and\x20no\x20LocalMark\x20entry\x20found.\x20'+'Register\x20it\x20via\x20local_mark_operation\x20or\x20pass\x20the\x200x\x20address\x20directly.');return c;}function balanceStr(a){if(a==null)return undefined;if(typeof a==='object'&&'balance'in a)return String(a['balance']);return String(a);}function balanceToken(a){if(a!=null&&typeof a==='object'&&typeof a['token_type']==='string')return a['token_type'];return undefined;}function summarizeAllocation(a,b){const c=Array['isArray'](a)?a:Array['isArray'](a?.['allocators'])?a['allocators']:[];if(c['length']===0x0)return undefined;let d=0x0,e=0x0,f=0x0,g=0x0;const h=b['toLowerCase']();for(const i of c){for(const j of i?.['sharing']??[]){d++;const k=j?.['who'];if(k==null)continue;if(typeof k==='object'&&'GuardIdentifier'in k)e++;else{if(typeof k==='object'&&'Signer'in k)g++;else{if(typeof k==='object'&&'Entity'in k){const l=k['Entity'],m=typeof l==='string'?l:l?.['name_or_address'];if(typeof m==='string'&&m['toLowerCase']()===h)f++;}else typeof k==='string'&&k['toLowerCase']()===h&&f++;}}}}return{'recipient_slots':d,'guard_gated_slots':e,'direct_to_me_slots':f,'to_payer_slots':g};}async function fetchEntityPermissions(a,b){const c=new Map(),{items:d}=await batchQueryTableItems(a,{'network':b});for(const e of d){const f=e['object'];if(f?.['type']!=='TableItem_PermissionPerm')continue;const g=fld(f,'address'),h=fld(f,'perm')??[],i=h['map'](j=>typeof j==='number'?j:typeof j?.['index']==='number'?j['index']:null)['filter'](j=>j!==null);if(g)c['set'](g,i);}return c;}function toRadarMachineNodes(a){return a['map'](b=>({'name':b['name'],'pairs':(Array['isArray'](b['value'])?b['value']:[])['map'](c=>({'prev_node':c['prev_node'],'threshold':c['threshold']??undefined,'forwards':(c['forwards']??[])['map'](d=>({'name':d['name'],'permissionIndex':d['permissionIndex']??null,'namedOperator':d['namedOperator']??null,'guard':d['guard']?.['guard']??(typeof d['guard']==='string'?d['guard']:null),'weight':d['weight']??null}))}))}));}export async function handleParticipationRadar(a){if(!a['radar_account'])throw new Error('\x27radar_account\x27\x20is\x20required\x20for\x20participation_radar');if(!a['radar_targets']||a['radar_targets']['length']===0x0)throw new Error('\x27radar_targets\x27\x20(1-20\x20in-flight\x20orders)\x20is\x20required\x20for\x20participation_radar');const b=a['context_network']??'testnet',d=a['radar_include_alerts']??!![],f=[],g=await resolveAddress(a['radar_account'],'radar_account'),h=await Promise['all'](a['radar_targets']['map'](async I=>({'progress':await resolveAddress(I['progress'],'progress'),'order':I['order']?await resolveAddress(I['order'],'order'):undefined}))),i=h['flatMap'](I=>I['order']?[I['progress'],I['order']]:[I['progress']]),j=await batchQueryObjectsByIds(i,b),k=new Map();for(const I of j){const J=fld(I,'object');if(J)k['set'](J,I);}const l=new Map(),m=new Map();for(const K of h){const L=k['get'](K['progress']);if(!L){f['push']('Progress\x20'+K['progress']+'\x20not\x20found\x20on\x20'+b+'\x20—\x20target\x20skipped.');continue;}l['set'](K['progress'],L);if(K['order']){const M=k['get'](K['order']);if(M)m['set'](K['order'],M);else f['push']('Order\x20'+K['order']+'\x20not\x20found\x20on\x20'+b+'\x20—\x20order-holder\x20detection\x20disabled\x20for\x20'+K['progress']+'.');}}h['length']>0x0&&l['size']===0x0&&f['push']('NETWORK\x20MISMATCH\x20SUSPECTED:\x200/'+h['length']+'\x20radar\x20targets\x20exist\x20on\x20network=\x27'+b+'\x27.\x20'+'These\x20objects\x20most\x20likely\x20live\x20on\x20a\x20different\x20network\x20—\x20re-run\x20with\x20the\x20matching\x20\x27network\x27\x20parameter.');const q=[...new Set([...l['values']()]['map'](N=>fld(N,'machine'))['filter'](N=>!!N))],s=[...new Set([...m['values']()]['map'](N=>fld(N,'service'))['filter'](N=>!!N))],u=[...new Set([...m['values']()]['flatMap'](N=>{const O=fld(N,'dispute');return Array['isArray'](O)?O:[];}))],w=new Map(),x=new Map(),y=new Map(),z=new Map();await Promise['all']([...q['map'](async N=>{try{const [O,P]=await Promise['all']([batchQueryObjectsByIds([N],b),fetchMachineNodes(N,b)]);if(O[0x0])w['set'](N,O[0x0]);x['set'](N,toRadarMachineNodes(P));}catch(Q){f['push']('Machine\x20'+N+'\x20fetch\x20failed:\x20'+Q['message']+'\x20—\x20workflow\x20unknown\x20for\x20its\x20orders.');}}),((async()=>{if(s['length']===0x0)return;try{const N=await batchQueryObjectsByIds(s,b);for(const O of N){const P=fld(O,'object');if(P)y['set'](P,O);}}catch(Q){f['push']('Service\x20query\x20failed:\x20'+Q['message']+'\x20—\x20compensation/reward\x20context\x20degraded.');}})()),((async()=>{if(u['length']===0x0)return;try{const N=await batchQueryObjectsByIds(u,b);for(const O of N){const P=fld(O,'object');if(P)z['set'](P,O);}}catch(Q){f['push']('Arb\x20query\x20failed:\x20'+Q['message']+'\x20—\x20compensation\x20claim\x20detection\x20disabled.');}})())]);const A=new Map(),B=[...new Set(q['map'](N=>fld(w['get'](N),'permission'))['filter'](N=>!!N))],C=new Map();await Promise['all'](B['map'](async N=>{try{const [O,P]=await Promise['all']([batchQueryObjectsByIds([N],b),fetchEntityPermissions(N,b)]),Q=O[0x0];C['set'](N,{'address':N,'entity_count':fld(Q,'entity_count'),'perm_remark':fld(Q,'perm_remark'),'entityPermissions':P,'owner':fld(Q,'builder')});}catch(R){f['push']('Permission\x20'+N+'\x20fetch\x20failed:\x20'+R['message']+'\x20—\x20operator\x20permission\x20matching\x20degraded.');}}));for(const N of q){const O=fld(w['get'](N),'permission');if(O&&C['has'](O))A['set'](N,C['get'](O));}let D=0x0;const E=new Map();try{const P=await watch_conversations({'account':g,'unreadOnly':!![],'previewMessageCount':0x0,'skipAutoMarkViewed':!![]}),Q=Array['isArray'](P)?P:P?.['conversations']??[];for(const R of Q){const S=R?.['peerAddress'],T=typeof R?.['unreadCount']==='number'?R['unreadCount']:0x0;typeof S==='string'&&T>0x0&&(E['set'](S['toLowerCase'](),T),D+=T);}}catch{f['push']('Messenger\x20unread\x20unavailable\x20(radar\x20account\x20is\x20not\x20a\x20local\x20messenger\x20account,\x20or\x20messenger\x20storage\x20offline)\x20'+'—\x20unread_messages_total\x20reported\x20as\x200.');}const F=[],G=Date['now']();for(const U of h){const V=l['get'](U['progress']);if(!V)continue;const W=U['order']?m['get'](U['order']):undefined,X=fld(V,'machine'),Y=fld(V,'current')??'',Z=fld(V,'namedOperator')??[],a0={};for(const ae of Z){if(ae?.['name'])a0[ae['name']]=Array['isArray'](ae['operators'])?ae['operators']:[];}const a1=W?fld(W,'service'):undefined,a2=a1?y['get'](a1):undefined;let a3;const a4=W?fld(W,'builder'):undefined;if(W&&a4===g){const af=fld(W,'dispute')??[];for(const ag of af){const ah=z['get'](ag);if(!ah)continue;const ai=fld(ah,'indemnity');if(ai){a3={'arbitration':fld(ah,'arbitration')??ag,'note':'Arbitration\x20verdict\x20recorded\x20an\x20indemnity\x20(Arb\x20'+ag+').\x20'+'Claim\x20via\x20service\x20op=\x27compensation_claim\x27\x20—\x20paid\x20directly\x20from\x20the\x20Service\x20compensation_fund.\x20'+'(Claimed-status\x20is\x20not\x20readable\x20from\x20the\x20Arb\x20object;\x20the\x20contract\x20rejects\x20double-claims.)'};break;}}}const a5=[];if(a2&&a4===g){const aj=fld(a2,'rewards')??[];for(const ak of aj){a5['push']({'address':ak,'description':'Service\x20reward\x20'+ak+'\x20(guard-gated\x20—\x20eligibility\x20verified\x20at\x20claim\x20time)'});}}const a6=isConsequenceNode(Y,'completed'),a7=isConsequenceNode(Y,'refunded');let a8=0x0;if(E['size']>0x0){const al=new Set();if(a4)al['add'](a4['toLowerCase']());for(const am of Object['values'](a0)){for(const an of am)al['add'](an['toLowerCase']());}al['delete'](g['toLowerCase']());for(const ao of al){a8+=E['get'](ao)??0x0;}}const a9={'account':g,'progress_address':U['progress'],'order_address':U['order'],'current_node':Y,'order_holder':a4,'machine_nodes':X?x['get'](X):undefined,'permission':X?A['get'](X)??null:null,'named_accounts':a0,'claimable_rewards':a5['length']>0x0?a5:undefined,'pending_compensation':a3,'rating_pending':a6&&a4===g,'unread_messages':a8>0x0?a8:undefined,'last_progress_at':fld(V,'current_time')??undefined,'now':G},aa=analyzeOrderParticipation(a9),ab=(fld(a2,'arbitrations')??[])['length']>0x0,ac=a6?'completed':a7?'refunded':null,ad=a9['last_progress_at']!=null?(G-a9['last_progress_at'])/0x36ee80:undefined;if(aa['perspective']==='merchant')aa['interest_analysis']=analyzeMerchantInterest({'account':g,'current_node':Y,'operable':aa['operable'],'waiting_on':aa['waiting_on'],'order_amount':balanceStr(fld(W,'amount')),'token_type':balanceToken(fld(W,'amount')),'allocation':summarizeAllocation(fld(a2,'order_allocators'),g),'compensation_fund':balanceStr(fld(a2,'compensation_fund')),'arbitration_bound':ab,'rewards_count':(fld(a2,'rewards')??[])['length'],'stalled_hours':ad,'terminal':ac,'unread_messages':a8>0x0?a8:undefined});else{if(aa['perspective']==='supplier')aa['interest_analysis']=analyzeSupplierInterest({'account':g,'current_node':Y,'operable':aa['operable'],'waiting_on':aa['waiting_on'],'order_amount':balanceStr(fld(W,'amount')),'token_type':balanceToken(fld(W,'amount')),'arbitration_bound':ab,'compensation_fund':balanceStr(fld(a2,'compensation_fund')),'terminal':ac,'stalled_hours':ad,'unread_messages':a8>0x0?a8:undefined});else{if(aa['perspective']==='collaborator')aa['interest_analysis']=analyzeCollaboratorInterest({'account':g,'current_node':Y,'operable':aa['operable'],'waiting_on':aa['waiting_on'],'collaborator_kind':aa['collaborator_kind'],'arbitration_bound':ab,'terminal':ac,'stalled_hours':ad,'unread_messages':a8>0x0?a8:undefined});else aa['perspective']==='customer'&&(aa['interest_analysis']=analyzeCustomerInterest({'account':g,'current_node':Y,'operable':aa['operable'],'waiting_on':aa['waiting_on'],'order_amount':balanceStr(fld(W,'amount')),'token_type':balanceToken(fld(W,'amount')),'compensation_fund':balanceStr(fld(a2,'compensation_fund')),'arbitration_bound':ab,'terminal':ac,'stalled_hours':ad,'unread_messages':a8>0x0?a8:undefined}));}}if(d&&W){const ap={'order_id':U['order'],'service_id':a1??'','current_node':Y||undefined,'created_at':Number(fld(W,'time')??G)||G,'last_progress_at':fld(V,'current_time')??undefined,'now':G,'order_amount':((()=>{try{return BigInt(fld(W,'amount')??0x0);}catch{return undefined;}})()),'compensation_balance':((()=>{try{const aq=fld(a2,'compensation_fund');return aq!=null?BigInt(aq):undefined;}catch{return undefined;}})()),'token':registryDisplayHint(extractGenericTokenType(fld(a2,'type_raw'))),'has_arbitration':(fld(a2,'arbitrations')??[])['length']>0x0,'pending_user_action':aa['operable']['some'](aq=>aq['execution_path']==='order_holder'),'completed':a6,'refunded':a7};try{const aq=monitorOrder({'current':ap,'thresholds':a['radar_monitor_thresholds']});aq['length']>0x0&&(aa['attached_alerts']=aq);}catch(ar){f['push']('Order\x20monitor\x20failed\x20for\x20'+U['order']+':\x20'+ar['message']+'.');}}F['push'](aa);}const H=aggregateRadar(F,D);return{'action':'participation_radar','account':g,'orders_analyzed':H['orders_analyzed'],'actionable':H['actionable'],'waiting':H['waiting'],'all_pending_claims':H['all_pending_claims'],'unread_messages_total':H['unread_messages_total'],'data_gaps':f,'summary':H['summary']};}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ObjectPuzzleEntry } from "./business-puzzle.js";
|
|
2
|
-
import type { SubstepRecord, SubstepEdge } from "
|
|
2
|
+
import type { SubstepRecord, SubstepEdge } from "../../task/types.js";
|
|
3
3
|
export interface AnalyzeIntentInput {
|
|
4
4
|
intent?: string;
|
|
5
5
|
project_description?: string;
|
|
@@ -49,7 +49,7 @@ export declare function handleAggregateRisks(v: AggregateRisksInput): {
|
|
|
49
49
|
industry: string;
|
|
50
50
|
overall_completeness: "complete" | "partial" | "empty";
|
|
51
51
|
} | undefined;
|
|
52
|
-
safety_findings?: import("
|
|
52
|
+
safety_findings?: import("../../knowledge/safety-rules.js").SafetyRiskItem[] | undefined;
|
|
53
53
|
namespace: {
|
|
54
54
|
prefix: string;
|
|
55
55
|
version: string;
|
|
@@ -88,14 +88,14 @@ export declare function handleTraceSubsteps(v: TraceSubstepsInput): {
|
|
|
88
88
|
prefix: string;
|
|
89
89
|
version: string;
|
|
90
90
|
};
|
|
91
|
-
network:
|
|
91
|
+
network: string;
|
|
92
92
|
coherent: boolean;
|
|
93
|
-
dangling_inputs: import("
|
|
94
|
-
circular_refs: import("
|
|
95
|
-
missing_outputs: import("
|
|
96
|
-
cross_step_breaks: import("
|
|
97
|
-
step_details: import("
|
|
93
|
+
dangling_inputs: import("../../task/substep-trace.js").DanglingInput[];
|
|
94
|
+
circular_refs: import("../../task/substep-trace.js").CircularRef[];
|
|
95
|
+
missing_outputs: import("../../task/substep-trace.js").MissingOutput[];
|
|
96
|
+
cross_step_breaks: import("../../task/substep-trace.js").CrossStepBreak[];
|
|
97
|
+
step_details: import("../../task/substep-trace.js").StepTraceDetail[];
|
|
98
98
|
topological_order: string[];
|
|
99
|
-
d10_check: import("
|
|
99
|
+
d10_check: import("../../task/substep-trace.js").D10CheckResult;
|
|
100
100
|
action: "trace_substeps";
|
|
101
101
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{analyzeBusinessIntent}from'./business-puzzle.js';import{aggregateProjectRisks}from'./risk-aggregator.js';import{traceSubsteps}from'../../task/substep-trace.js';import{updateStageCache}from'./index.js';import{checkObjectReuseRules,checkImmutabilityRules}from'../../knowledge/safety-rules.js';export function handleAnalyzeIntent(a){const b=(a['intent']??a['project_description']??a['project_name']??'')['trim']();if(!b)throw new Error('analyze_intent\x20requires\x20\x27intent\x27\x20(business\x20description\x20text).\x20'+'Example:\x20intent=\x27I\x20want\x20to\x20open\x20an\x20online\x20toy\x20store\x20with\x20escrow\x20and\x20dispute\x20resolution\x27.');const c=analyzeBusinessIntent({'user_intent':b,'project_name':a['project_name'],'target_objects':a['target_objects'],'industry':a['project_industry']}),d=(a['project']??'')['trim']();return d&&updateStageCache(d,(a['version']??'v1')['trim'](),{'stage':'puzzle','puzzles':c['puzzles'],'business_intent':b,'industry':c['intent_parsed']['industry']}),{'action':'analyze_intent',...c};}export function handleAggregateRisks(a){const b=(a['project']??'')['trim']();if(!b)throw new Error('aggregate_risks\x20requires\x20\x27project\x27\x20(project\x20prefix,\x20e.g.\x20\x27myshop\x27).\x20'+'Use\x20one\x20stable\x20prefix\x20per\x20build\x20so\x20findings\x20map\x20to\x20the\x20service-build\x20stage\x20cache\x20namespace.');const c=(a['version']??'v1')['trim']();let d,e;if(a['puzzles'])d=Object['fromEntries'](Object['entries'](a['puzzles'])['map'](([h,i])=>[h,{'puzzle':i['puzzle'],'completeness':i['completeness'],'missing_dimensions':i['missing_dimensions']}]));else{const h=(a['intent']??a['project_description']??a['project_name']??'')['trim']();if(!h)throw new Error('aggregate_risks\x20requires\x20\x27puzzles\x27\x20(from\x20a\x20prior\x20analyze_intent\x20result)\x20'+'OR\x20\x27intent\x27\x20(business\x20description\x20—\x20analyze_intent\x20runs\x20automatically\x20first).');const i=analyzeBusinessIntent({'user_intent':h,'project_name':a['project_name'],'industry':a['project_industry']});d=i['puzzles'],e={'primary_object':i['intent_parsed']['primary_object'],'industry':i['intent_parsed']['industry'],'overall_completeness':i['overall_completeness']};}const f=aggregateProjectRisks({'project_prefix':b,'version':c,'industry':a['project_industry'],'puzzles':d,'severity_threshold':a['severity_threshold'],'user_confirmed_high_risks':a['user_confirmed_high_risks']}),g=[...a['planned_objects']?checkObjectReuseRules(a['planned_objects']):[],...a['planned_operations']?checkImmutabilityRules(a['planned_operations']):[]];return updateStageCache(b,c,{'stage':'risk','risk_status':f['status'],'risk_can_proceed':f['status']==='RISK_PASSED'}),{'action':'aggregate_risks',...f,...g['length']>0x0?{'safety_findings':g}:{},...e?{'intent_echo':e}:{}};}export function handleTraceSubsteps(a){const b=(a['project']??'')['trim']();if(!b)throw new Error('trace_substeps\x20requires\x20\x27project\x27\x20(project\x20prefix,\x20e.g.\x20\x27myshop\x27).');if(!a['substeps']||a['substeps']['length']===0x0)throw new Error('trace_substeps\x20requires\x20\x27substeps\x27\x20(non-empty\x20array\x20of\x20substep\x20execution\x20records,\x20'+'63-spec\x20§2.1).\x20Construct\x20them\x20from\x20your\x20deployment\x20execution\x20trace:\x20each\x20onchain_operations\x20'+'call\x20=\x20one\x20substep\x20with\x20step_id\x20\x27T<step>.<substep>\x27,\x20input_refs\x20pointing\x20at\x20upstream\x20substeps.');const c=traceSubsteps({'project_prefix':b,'version':(a['version']??'v1')['trim'](),'network':a['network']??'testnet','substeps':a['substeps'],'edges':a['substep_edges']});return updateStageCache(b,(a['version']??'v1')['trim'](),{'stage':'substeps','trace_coherent':c['coherent'],'trace_can_proceed':c['coherent']}),{'action':'trace_substeps',...c};}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const SERVICE_BUILD_STAGES: string[];
|
|
2
|
+
export declare function serviceBuildRootDir(): string;
|
|
3
|
+
export declare function serviceBuildDir(prefix: string, version: string): string;
|
|
4
|
+
export declare function openServiceBuildProcessDir(prefix: string, version: string): string;
|
|
5
|
+
export declare function ensureServiceBuildProcess(prefix: string, version: string, mcpVersion: string): string;
|
|
6
|
+
export declare function openServiceBuildProcessDirById(processId: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync}from'fs';import{join}from'path';import{getWowMcpDir}from'@wowok/wowok';import{getPlaybook}from'../../task/playbook.js';import{PROCESS_SCHEMA_VERSION}from'../../task/types.js';import{initProcess}from'../../task/ProcessStore.js';export const SERVICE_BUILD_STAGES=getPlaybook('service-build')?.['stages']??['puzzle','risk','substeps'];export function serviceBuildRootDir(){return join(getWowMcpDir(),'projects');}export function serviceBuildDir(a,b){return join(serviceBuildRootDir(),a+'_'+b);}export function openServiceBuildProcessDir(a,b){return serviceBuildDir(a,b);}export function ensureServiceBuildProcess(a,b,c){const d=openServiceBuildProcessDir(a,b);if(!existsSync(join(d,'manifest.json'))){const e=new Date()['toISOString']();initProcess(d,{'schema_version':PROCESS_SCHEMA_VERSION,'mcp_version':c,'process_id':a+'_'+b,'playbook':'service-build','title':a,'objects':[],'created_at':e,'updated_at':e,'archived':![]},SERVICE_BUILD_STAGES);}return d;}export function openServiceBuildProcessDirById(a){return join(serviceBuildRootDir(),a);}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LocalMark,objectTypeFromAddress,queryOrdersByUser}from'@wowok/wowok';import{batchQueryObjectsByIds,batchQueryTableItems,fetchEntityPermission,fetchObjectLinkerCore,fetchObjectLinkerTx,fetchServiceOrders}from'../../knowledge/workflow-guidance.js';import{deriveRelationshipProfile}from'../../relationship/index.js';import{GUARD_BINDING_REGISTRY,OWNER_RECEIVE_COGNITION}from'../../knowledge/guard-bindings.js';import{detectBridgesForObjects,summarizeBridge}from'../../knowledge/scenario-topology.js';import{fetchMachineNodes}from'./machine-nodes.js';const MAX_MANAGED_PER_PERMISSION=0x3c,MAX_ORDERS=0x28,MAX_DEMANDS=0x14,MAX_ALLOCATIONS=0x28;function fld(a,b){return a?.[b]??a?.['data']?.[b];}async function resolveAddress(a,b){if(/^0x[0-9a-fA-F]{4,}$/i['test'](a))return a;const c=await LocalMark['Instance']()['get_address'](a);if(!c)throw new Error('Cannot\x20resolve\x20'+b+'\x20\x27'+a+'\x27\x20—\x20not\x20a\x20valid\x20address\x20and\x20no\x20LocalMark\x20entry\x20found.\x20'+'Pass\x20the\x200x\x20address\x20directly\x20or\x20register\x20it\x20via\x20local_mark_operation.');return c;}async function safe(a,b,c){try{return await b();}catch(d){return c['push'](a+':\x20'+d['message']),undefined;}}export async function handleRelationshipProfile(b){if(!b['radar_account'])throw new Error('\x27radar_account\x27\x20is\x20required\x20for\x20relationship_profile');const e=b['context_network']??'testnet',f=[],g=await resolveAddress(b['radar_account'],'radar_account'),h=await safe('entity_permission\x20'+g,()=>fetchEntityPermission(g,e),f),i=[...new Set((h?.['items']??[])['map'](S=>typeof S?.['permission']==='string'?S['permission']:undefined)['filter'](S=>!!S))]['slice'](0x0,0x19),j=[],k=new Map();if(i['length']>0x0){const S=await safe('permissions\x20query',()=>batchQueryObjectsByIds(i,e),f)??[];for(const T of S){const U=fld(T,'object');if(!U)continue;j['push']({'address':U,'owner':fld(T,'owner')??'','admins':(fld(T,'admin')??[])['filter'](V=>typeof V==='string'),'entities':[]});}await Promise['all'](i['map'](async V=>{const W=await safe('permission\x20table\x20'+V,()=>batchQueryTableItems(V,{'network':e}),f);if(!W)return;const X=j['find'](Y=>Y['address']['toLowerCase']()===V['toLowerCase']());if(!X)return;for(const Y of W['items']){const Z=Y['object'];if(Z?.['type']&&!String(Z['type'])['includes']('PermissionPerm'))continue;const a0=fld(Z,'address');if(!a0)continue;const a1=fld(Z,'perm')??[],a2=a1['map'](a3=>typeof a3==='number'?a3:typeof a3?.['index']==='number'?a3['index']:null)['filter'](a3=>a3!==null);X['entities']['push']({'address':a0,'perm_indices':a2});}}));for(const V of i){const [W,X]=await Promise['all']([safe('object_linker_core\x20'+V,()=>fetchObjectLinkerCore(V,e),f),safe('object_linker_tx\x20'+V,()=>fetchObjectLinkerTx(V,e),f)]),Y=[...(W?.['items']??[])['map'](Z=>Z?.['who']),...(X?.['items']??[])['map'](Z=>Z?.['who'])]['filter'](Z=>typeof Z==='string'&&!!Z);for(const Z of Y['slice'](0x0,MAX_MANAGED_PER_PERMISSION)){if(!k['has'](Z['toLowerCase']())){const a0=objectTypeFromAddress(Z);if(a0)k['set'](Z['toLowerCase'](),a0);}}}}const l=a1=>[...k['entries']()]['filter'](([a2,a3])=>a3===a1)['map'](([a2])=>a2),m=l('service'),n=l('demand')['slice'](0x0,MAX_DEMANDS),q=l('contact'),u=l('arbitration'),w=new Map(),x=await safe('orders\x20by\x20user\x20'+g,()=>queryOrdersByUser({'address':g,'network':e}),f);for(const a1 of x??[]){const a2=a1?.['order']?.['object'];typeof a2==='string'&&a2&&w['set'](a2['toLowerCase'](),'buyer');}for(const a3 of m){const a4=await safe('service\x20orders\x20'+a3,()=>fetchServiceOrders(a3,e),f);for(const a5 of a4?.['items']??[]){typeof a5?.['who']==='string'&&a5['who']&&w['set'](a5['who']['toLowerCase'](),'merchant');}}const y=[...w['keys']()]['slice'](0x0,MAX_ORDERS),z=[],A={};if(y['length']>0x0){const a6=await safe('orders\x20query',()=>batchQueryObjectsByIds(y,e),f)??[],a7=new Set();for(const ab of a6){const ac=fld(ab,'object');if(!ac)continue;z['push']({'address':ac,'owner':fld(ab,'owner')??'','agents':(fld(ab,'agent')??[])['filter'](ae=>typeof ae==='string'),'service':fld(ab,'service')??'','amount':fld(ab,'amount')??undefined,'allocation':fld(ab,'allocation')??undefined,'dispute_arbitrations':(fld(ab,'dispute')??[])['filter'](ae=>typeof ae==='string'),'claimed_by':fld(ab,'claimed_by')??null});const ad=fld(ab,'service');if(ad)a7['add'](ad);}const a8=await safe('order\x20services\x20query',()=>batchQueryObjectsByIds([...a7],e),f)??[],a9=new Map();for(const ae of a8){const af=fld(ae,'object'),ag=fld(ae,'permission');if(af&&ag)a9['set'](af['toLowerCase'](),ag);}const aa=[...new Set([...a9['values']()])];if(aa['length']>0x0){const ah=await safe('service\x20permissions\x20query',()=>batchQueryObjectsByIds(aa,e),f)??[],ai=new Map();for(const aj of ah){const ak=fld(aj,'object'),al=fld(aj,'owner');if(ak&&al)ai['set'](ak['toLowerCase'](),al);}for(const [am,an]of a9){const ao=ai['get'](an['toLowerCase']());if(ao)A[am]=ao;}}}const B=[];for(const ap of n){const aq=await safe('demand\x20'+ap,()=>batchQueryObjectsByIds([ap],e),f)??[],ar=aq[0x0],as=fld(ar,'permission');let at='';if(as){const aw=await safe('demand\x20permission\x20'+as,()=>batchQueryObjectsByIds([as],e),f)??[];at=fld(aw[0x0],'owner')??'';}const au=[],av=await safe('demand\x20presenters\x20'+ap,()=>batchQueryTableItems(ap,{'network':e}),f);if(av)for(const ax of av['items']){const ay=ax['object'];if(!ay?.['type']||!String(ay['type'])['includes']('Present'))continue;const az=fld(ay,'address')??ax['objectId'],aA=fld(ay,'value')??ay;au['push']({'address':typeof az==='string'?az:ax['objectId'],'service':typeof aA?.['service']==='string'?aA['service']:undefined,'acceptance_score':typeof aA?.['acceptance_score']==='number'?aA['acceptance_score']:undefined});}B['push']({'address':ap,'owner':at,'presenters':au});}const C=[],D=[...new Set(z['map'](aB=>aB['allocation'])['filter'](aB=>!!aB))]['slice'](0x0,MAX_ALLOCATIONS);if(D['length']>0x0){const aB=await safe('allocations\x20query',()=>batchQueryObjectsByIds(D,e),f)??[];for(const aC of aB){const aD=fld(aC,'object');if(!aD)continue;const aE=fld(aC,'allocators')??aC,aF=Array['isArray'](aE)?aE:Array['isArray'](aE?.['allocators'])?aE['allocators']:[],aG=aF['flatMap'](aH=>(aH?.['sharing']??[])['map'](aI=>({'who':aI?.['who']??aI,'mode':aI?.['mode']===0x1||aI?.['mode']==='Rate'?'Rate':aI?.['mode']===0x2||aI?.['mode']==='Surplus'?'Surplus':'Amount','sharing':aI?.['sharing']!=null?String(aI['sharing']):undefined,'guard':typeof aH?.['guard']==='string'?aH['guard']:undefined})));C['push']({'address':aD,'owner':fld(aC,'owner')??'','sharing':aG});}}const E=[];if(q['length']>0x0){const aH=await safe('contacts\x20query',()=>batchQueryObjectsByIds(q['slice'](0x0,0x14),e),f)??[];for(const aI of aH){const aJ=fld(aI,'object');if(!aJ)continue;const aK=fld(aI,'permission');let aL='';if(aK){const aN=await safe('contact\x20permission\x20'+aK,()=>batchQueryObjectsByIds([aK],e),f)??[];aL=fld(aN[0x0],'owner')??'';}const aM=(fld(aI,'ims')??[])['map'](aO=>typeof aO==='string'?aO:aO?.['at'])['filter'](aO=>typeof aO==='string');E['push']({'address':aJ,'ims':aM,'owner':aL});}}const F=[],G=l('machine')['slice'](0x0,0xa);for(const aO of G){const [aP,aQ]=await Promise['all']([safe('machine\x20'+aO,()=>batchQueryObjectsByIds([aO],e),f),safe('machine\x20nodes\x20'+aO,()=>fetchMachineNodes(aO,e),f)]),aR=aP?.[0x0]?fld(aP[0x0],'permission'):undefined,aS=(aQ??[])['flatMap'](aT=>(Array['isArray'](aT['value'])?aT['value']:[])['flatMap'](aU=>(aU['forwards']??[])['map'](aV=>({'node':aU['prev_node']??aT['name'],'next_node':aT['name'],'forward_name':aV['name'],'named_operator':aV['namedOperator']??null,'permission_index':aV['permissionIndex']??null,'guard':typeof aV['guard']==='string'?aV['guard']:aV['guard']?.['guard']??null}))));F['push']({'address':aO,'permission_address':aR,'forwards':aS});}const H=[],I=new Set(u);for(const aT of z){for(const aU of aT['dispute_arbitrations']??[])I['add'](aU);}if(I['size']>0x0){const aV=await safe('arbitrations\x20query',()=>batchQueryObjectsByIds([...I]['slice'](0x0,0xf),e),f)??[];for(const aW of aV){const aX=fld(aW,'object');if(!aX)continue;H['push']({'address':aX,'voters':[],'bound_services':[]});}H['length']>0x0&&f['push']('Arbitration\x20voting-guard\x20member\x20resolution\x20is\x20not\x20implemented\x20yet\x20—\x20arbitration_delegation\x20edges\x20list\x20the\x20arbitration\x20bindings\x20without\x20individual\x20voters.');}const J={'anchor':g,'permissions':j,'machines':F,'orders':z,'demands':B,'allocations':C,'contacts':E,'arbitrations':H,'service_owners':A},K=deriveRelationshipProfile(J),L=new Set();if(C['length']>0x0)L['add']('Allocation');if(B['length']>0x0)L['add']('Demand');if(F['some'](aY=>(aY['forwards']??[])['some'](aZ=>aZ['guard'])))L['add']('MachineForward');if(H['length']>0x0)L['add']('Arbitration');for(const aY of L){const aZ=GUARD_BINDING_REGISTRY['filter'](b1=>b1['object']===aY);if(aZ['length']===0x0)continue;const b0=aZ['map'](b1=>{const b2=b1['preset_kind']==='amount'&&b1['object']==='Allocation'?'\x20(Rate\x20is\x20basis\x20points;\x20rates\x20must\x20complete\x2010000\x20unless\x20a\x20Surplus\x20entry\x20exists)':'';return''+b1['slot']+b2+'\x20['+b1['preset_kind']+']\x20—\x20creator:\x20'+b1['creator']['split']('\x20—\x20')[0x0]['split']('.\x20')[0x0]+';\x20user:\x20'+b1['user'];})['join']('\x20|\x20');K['notes']['push']('Guard-preset\x20deep\x20context\x20on\x20the\x20'+aY+'(s)\x20in\x20this\x20topology:\x20'+b0+'.');}C['length']>0x0&&K['notes']['push']('Cognition\x20fixed:\x20'+OWNER_RECEIVE_COGNITION);const M=['Permission'];if(z['length']>0x0)M['push']('Order');if(F['length']>0x0)M['push']('Machine','Progress');if(C['length']>0x0)M['push']('Allocation','Payment');if(B['length']>0x0)M['push']('Demand');if(H['length']>0x0)M['push']('Arbitration','Arb');if(E['length']>0x0)M['push']('Contact');if(Object['keys'](A)['length']>0x0)M['push']('Service','Guard');const N=detectBridgesForObjects(M);if(N['length']>0x0){const b1=N['slice'](0x0,0x8)['map'](b2=>summarizeBridge(b2))['join']('\x0a-\x20');K['notes']['push']('Scenario\x20topology\x20('+N['length']+'\x20bridge(s)\x20implied\x20by\x20the\x20touched\x20objects\x20—\x20capability\x20comes\x20from\x20the\x20\x22\x20+\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x22integration,\x20not\x20from\x20any\x20single\x20object):\x0a-\x20'+b1);}const O=b['relation_kinds']?new Set(b['relation_kinds']):undefined,P=O?K['edges']['filter'](b2=>O['has'](b2['kind'])):K['edges'],Q=P['reduce']((b2,b3)=>{return b2[b3['kind']]=(b2[b3['kind']]??0x0)+0x1,b2;},{});let R=g+'\x20holds\x20'+P['length']+'\x20relationship\x20edge(s)\x20across\x20'+Object['keys'](K['by_counterparty'])['length']+'\x20counterparty(ies)'+(Object['keys'](Q)['length']>0x0?':\x20'+Object['entries'](Q)['map'](([b2,b3])=>b2+'×'+b3)['join'](',\x20')+'.':'.');return P['length']===0x0&&f['length']>0x0&&(R+='\x20No\x20edges\x20derived\x20—\x20check\x20data_gaps\x20(the\x20account\x20may\x20have\x20no\x20on-chain\x20power\x20carriers\x20on\x20this\x20network).'),{'action':'relationship_profile','account':g,'edges':P,'by_counterparty':K['by_counterparty'],'notes':K['notes'],'data_gaps':f,'summary':R};}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{assessServiceRisks,assessMachineRisks,assessAllocationRisks,assessTreasuryRisks,assessArbitrationRisks,assessRewardRisks,assessProgressRisks,assessOrderRisks,assessGuardRisks,checkContactRisks,checkResourceRisks,checkPaymentRisks,checkArbRisks,checkPersonalRisks,checkUtilRisks,checkRegistrarRisks,checkBridgeRisks,checkProofRisks,checkRepositoryRisks,checkDemandRisks}from'../../knowledge/index.js';import{assessPermissionRisks}from'../../knowledge/permission-risk.js';const SEVERITY_ORDER={'CRITICAL':0x0,'HIGH':0x1,'MEDIUM':0x2,'LOW':0x3,'INFO':0x4},ALL_SEVERITIES=['CRITICAL','HIGH','MEDIUM','LOW','INFO'];function normalizeSeverity(a){if(typeof a!=='string')return'INFO';const b=a['toUpperCase']();return ALL_SEVERITIES['includes'](b)?b:'INFO';}function extractRiskId(a,b){if(!a||typeof a!=='object')return b;return String(a['id']??a['risk_rule_id']??a['rule_id']??b);}function extractRiskMessage(a){if(!a||typeof a!=='object')return'(no\x20message)';return String(a['title']??a['message']??a['description']??a['trigger']??'(no\x20message)');}function extractFixSuggestion(a){if(!a||typeof a!=='object')return'';return String(a['mitigation']??a['fix_suggestion']??a['suggestion']??'');}function toAggregatedRisk(a,b,c){return{'risk_rule_id':extractRiskId(a,'R-'+b['toUpperCase']()+'-?'),'object_type':b,'entry_id':c,'severity':normalizeSeverity(a?.['level']??a?.['severity']),'message':extractRiskMessage(a),'fix_suggestion':extractFixSuggestion(a),'details':a?.['evidence']?{'field_path':String(a['evidence'])}:undefined};}function isL1L2Object(a){return['service','machine','allocation','treasury','arb','reward','progress','order','permission','guard']['includes'](a);}function buildL1L2Dispatch(){const a=(b,c)=>{try{const d=b??{},e=c(d);if(Array['isArray'](e))return e;if(e&&typeof e==='object'){const f=e['risks'];if(Array['isArray'](f))return f;}return[];}catch{return[];}};return{'service':{'assess':b=>a(b,assessServiceRisks)},'machine':{'assess':b=>a(b,c=>assessMachineRisks(c,{}))},'allocation':{'assess':b=>a(b,assessAllocationRisks)},'treasury':{'assess':b=>a(b,assessTreasuryRisks)},'arb':{'assess':b=>a(b,assessArbitrationRisks)},'reward':{'assess':b=>a(b,c=>assessRewardRisks(c))},'progress':{'assess':b=>a(b,c=>assessProgressRisks(c))},'order':{'assess':b=>a(b,assessOrderRisks)},'permission':{'assess':b=>a(b,assessPermissionRisks)},'guard':{'assess':b=>{try{const c=assessGuardRisks({'table':[],'root':undefined});if(Array['isArray'](c))return c;if(c&&typeof c==='object'){const d=c['risks'];if(Array['isArray'](d))return d;}return[];}catch{return[];}}}};}function buildL3Dispatch(){const a=(b,c)=>{try{const d=b??{},e=c(d);if(Array['isArray'](e))return e;return[];}catch{return[];}};return{'contact':{'check':b=>a(b,checkContactRisks)},'resource':{'check':b=>a(b,checkResourceRisks)},'payment':{'check':b=>a(b,checkPaymentRisks)},'arb':{'check':b=>a(b,checkArbRisks)},'personal':{'check':b=>a(b,checkPersonalRisks)},'util':{'check':b=>a(b,checkUtilRisks)},'registrar':{'check':b=>a(b,checkRegistrarRisks)},'bridge':{'check':b=>a(b,checkBridgeRisks)},'proof':{'check':b=>a(b,checkProofRisks)},'repository':{'check':b=>a(b,checkRepositoryRisks)},'demand':{'check':b=>a(b,checkDemandRisks)}};}export function aggregateProjectRisks(a){const b=[];(!a||!a['project_prefix'])&&b['push']('input.project_prefix\x20is\x20empty');const c=a?.['puzzles']??{},e=[],f=buildL1L2Dispatch(),g=buildL3Dispatch();for(const [m,n]of Object['entries'](c)){const o=m,p=(a['project_prefix']??'project')+'_'+o,q=n?.['puzzle'];if(isL1L2Object(o)){const s=f[o];if(!s){b['push']('No\x20L1/L2\x20risk\x20dispatcher\x20for\x20\x27'+o+'\x27');continue;}const t=s['assess'](q);for(const u of t){e['push'](toAggregatedRisk(u,o,p));}}else{const v=g[o];if(!v){b['push']('No\x20L3\x20risk\x20dispatcher\x20for\x20\x27'+o+'\x27');continue;}const w=v['check'](q);for(const x of w){e['push'](toAggregatedRisk(x,o,p));}}}sortFindings(e);const h=countBySeverity(e),i=a['severity_threshold']??'HIGH',j=determineStatus(h,i,a['user_confirmed_high_risks']??[],e);let k;j==='RISK_PENDING_CONFIRM'&&(k=e['filter'](y=>y['severity']==='HIGH')['filter'](y=>!(a['user_confirmed_high_risks']??[])['includes'](y['risk_rule_id']))['map'](y=>({'risk_rule_id':y['risk_rule_id'],'description':y['message'],'fix_suggestion':y['fix_suggestion'],'object_type':y['object_type'],'entry_id':y['entry_id']})));const l={};for(const y of e){const z=y['object_type'];!l[z]&&(l[z]=[]),l[z]['push']({'risk_rule_id':y['risk_rule_id'],'severity':y['severity'],'message':y['message'],'fix_suggestion':y['fix_suggestion'],'entry_id':y['entry_id']});}return{'namespace':{'prefix':a['project_prefix']??'','version':a['version']??'','industry':a['industry']??'general'},'findings':e,'severity_summary':h,'status':j,'pending_confirmations':k,'calibrated_at':Date['now'](),'fix_suggestions_grouped':l,'warnings':b};}export function sortFindings(a){return a['sort']((c,d)=>{const e=SEVERITY_ORDER[c['severity']]-SEVERITY_ORDER[d['severity']];if(e!==0x0)return e;if(c['object_type']!==d['object_type'])return c['object_type']['localeCompare'](d['object_type']);return c['risk_rule_id']['localeCompare'](d['risk_rule_id']);});}export function countBySeverity(a){const b={'CRITICAL':0x0,'HIGH':0x0,'MEDIUM':0x0,'LOW':0x0,'INFO':0x0};for(const c of a){b[c['severity']]++;}return b;}export function determineStatus(a,b,c,d){if(a['CRITICAL']>0x0)return'RISK_BLOCKED';const e=SEVERITY_ORDER[b];if(a['HIGH']>0x0&&e<=SEVERITY_ORDER['HIGH']){const f=d['filter'](g=>g['severity']==='HIGH'&&!c['includes'](g['risk_rule_id']));if(f['length']>0x0)return'RISK_PENDING_CONFIRM';}if(a['MEDIUM']>0x0&&e<=SEVERITY_ORDER['MEDIUM'])return'RISK_BLOCKED';if(a['LOW']>0x0&&e<=SEVERITY_ORDER['LOW'])return'RISK_BLOCKED';return'RISK_PASSED';}export function getCriticalRisks(a){if(!a?.['findings'])return[];return a['findings']['filter'](b=>b['severity']==='CRITICAL');}export function summarizeRiskReport(a){if(!a)return'(no\x20result)';const b=[];b['push']('#\x20Risk\x20Aggregation\x20Report'),b['push'](''),b['push']('-\x20Project:\x20'+a['namespace']['prefix']+'_'+a['namespace']['version']),b['push']('-\x20Status:\x20'+a['status']),b['push']('-\x20Calibrated\x20at:\x20'+new Date(a['calibrated_at'])['toISOString']()),b['push'](''),b['push']('##\x20Severity\x20Summary'),b['push'](''),b['push']('|\x20Severity\x20|\x20Count\x20|'),b['push']('|----------|-------|');for(const c of ALL_SEVERITIES){b['push']('|\x20'+c+'\x20|\x20'+(a['severity_summary'][c]??0x0)+'\x20|');}b['push']('');if(a['findings']['length']===0x0)return b['push']('No\x20risks\x20found.'),b['join']('\x0a');b['push']('##\x20Findings\x20(sorted\x20by\x20severity)'),b['push']('');for(const d of a['findings']){b['push']('-\x20**['+d['severity']+']\x20'+d['risk_rule_id']+'**\x20('+d['object_type']+'\x20/\x20'+d['entry_id']+')'),b['push']('\x20\x20-\x20'+d['message']),d['fix_suggestion']&&b['push']('\x20\x20-\x20Fix:\x20'+d['fix_suggestion']);}if(a['warnings']['length']>0x0){b['push'](''),b['push']('##\x20Warnings');for(const e of a['warnings'])b['push']('-\x20'+e);}return b['join']('\x0a');}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { ProjectObjectType } from "./namespace.js";
|
|
2
2
|
import type { BusinessIntent } from "./intent-analyzer.js";
|
|
3
|
-
import type { BusinessModule, BusinessModuleId } from "
|
|
4
|
-
import type { GraphEdgeBase, GraphNodeBase } from "
|
|
3
|
+
import type { BusinessModule, BusinessModuleId } from "../../extensions/business-modules.js";
|
|
4
|
+
import type { GraphEdgeBase, GraphNodeBase } from "../../graph/base.js";
|
|
5
|
+
import type { IndustryMode } from "../../extensions/types.js";
|
|
5
6
|
export type ConfigValueType = "string" | "number" | "boolean" | "address_ref" | "guard_logic" | "enum";
|
|
6
7
|
export interface ConfigValueBase {
|
|
7
8
|
type: ConfigValueType;
|
|
@@ -89,5 +90,8 @@ export interface GraphValidationResult {
|
|
|
89
90
|
softViolations: SemanticConstraint[];
|
|
90
91
|
infoNotes: SemanticConstraint[];
|
|
91
92
|
}
|
|
92
|
-
export
|
|
93
|
+
export interface ModePriorOptions {
|
|
94
|
+
paymentExplicit?: boolean;
|
|
95
|
+
}
|
|
96
|
+
export declare function buildSemanticGraph(intent: BusinessIntent, adoptedModules: BusinessModule[], mode?: IndustryMode, options?: ModePriorOptions): SemanticObjectGraph;
|
|
93
97
|
export declare function validateGraph(graph: SemanticObjectGraph): GraphValidationResult;
|