@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
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
export declare const CURRENT_SCHEMA_VERSION = "1.0.0";
|
|
2
|
-
export declare function projectsRootDir(): string;
|
|
3
|
-
export declare function projectDir(prefix: string, version: string): string;
|
|
4
|
-
export declare function deploymentDir(prefix: string, version: string): string;
|
|
5
|
-
export interface ProjectManifest {
|
|
6
|
-
schema_version: string;
|
|
7
|
-
mcp_version: string;
|
|
8
|
-
prefix: string;
|
|
9
|
-
version: string;
|
|
10
|
-
created_at: string;
|
|
11
|
-
updated_at: string;
|
|
12
|
-
forked_from?: string;
|
|
13
|
-
needs_recalibration?: boolean;
|
|
14
|
-
}
|
|
15
|
-
export type ProjectStage = 1 | 2 | 3 | 4 | 5;
|
|
16
|
-
export interface StageState {
|
|
17
|
-
stage: ProjectStage;
|
|
18
|
-
updated_at: number;
|
|
19
|
-
stage_meta: Record<ProjectStage, {
|
|
20
|
-
committed: boolean;
|
|
21
|
-
committed_at?: number;
|
|
22
|
-
gate_passed: boolean;
|
|
23
|
-
blocking_issues: string[];
|
|
24
|
-
completion: number;
|
|
25
|
-
}>;
|
|
26
|
-
has_published_object: boolean;
|
|
27
|
-
archived: boolean;
|
|
28
|
-
}
|
|
29
|
-
export type AuditEventType = "stage_commit" | "stage_rollback" | "risk_acknowledged" | "fork_created" | "migration_applied" | "gate_validation" | "object_published";
|
|
30
|
-
export interface AuditRecord {
|
|
31
|
-
timestamp: string;
|
|
32
|
-
event: AuditEventType;
|
|
33
|
-
stage?: ProjectStage;
|
|
34
|
-
reason: string;
|
|
35
|
-
affected_files: string[];
|
|
36
|
-
user_confirmed?: boolean;
|
|
37
|
-
}
|
|
38
|
-
export declare function ensureProjectDir(prefix: string, version: string): string;
|
|
39
|
-
export declare function initProject(prefix: string, version: string, options?: {
|
|
40
|
-
mcpVersion?: string;
|
|
41
|
-
forkedFrom?: string;
|
|
42
|
-
}): ProjectManifest;
|
|
43
|
-
export declare function loadManifest(prefix: string, version: string): ProjectManifest;
|
|
44
|
-
export declare function saveManifest(prefix: string, version: string, manifest: ProjectManifest): void;
|
|
45
|
-
export declare function loadStageState(prefix: string, version: string): StageState | undefined;
|
|
46
|
-
export declare function saveStageState(prefix: string, version: string, state: StageState): void;
|
|
47
|
-
export declare function saveProjectFile(prefix: string, version: string, relPath: string, data: unknown): string;
|
|
48
|
-
export declare function loadProjectFile<T = unknown>(prefix: string, version: string, relPath: string): T | undefined;
|
|
49
|
-
export declare function saveProjectMarkdown(prefix: string, version: string, relPath: string, markdown: string): string;
|
|
50
|
-
export declare function appendJsonl(prefix: string, version: string, relPath: string, record: unknown): string;
|
|
51
|
-
export declare function appendAudit(prefix: string, version: string, record: AuditRecord): void;
|
|
52
|
-
export declare function readAuditLog(prefix: string, version: string): AuditRecord[];
|
|
53
|
-
export interface LocalProjectEntry {
|
|
54
|
-
dir_name: string;
|
|
55
|
-
prefix: string;
|
|
56
|
-
version: string;
|
|
57
|
-
path: string;
|
|
58
|
-
initialized: boolean;
|
|
59
|
-
archived: boolean;
|
|
60
|
-
needs_migration: boolean;
|
|
61
|
-
forked_from?: string;
|
|
62
|
-
mtime: number;
|
|
63
|
-
}
|
|
64
|
-
export declare function parseProjectDirName(dirName: string): {
|
|
65
|
-
prefix: string;
|
|
66
|
-
version: string;
|
|
67
|
-
} | undefined;
|
|
68
|
-
export declare function listLocalProjects(): LocalProjectEntry[];
|
|
69
|
-
export declare function projectExists(prefix: string, version: string): boolean;
|
|
70
|
-
export interface ForkOptions {
|
|
71
|
-
newVersion: string;
|
|
72
|
-
newPrefix?: string;
|
|
73
|
-
mcpVersion?: string;
|
|
74
|
-
}
|
|
75
|
-
export interface ForkResult {
|
|
76
|
-
new_prefix: string;
|
|
77
|
-
new_version: string;
|
|
78
|
-
new_path: string;
|
|
79
|
-
forked_from: string;
|
|
80
|
-
copied_files: string[];
|
|
81
|
-
}
|
|
82
|
-
export declare function forkProject(srcPrefix: string, srcVersion: string, opts: ForkOptions): ForkResult;
|
|
83
|
-
export interface ProjectFileEntry {
|
|
84
|
-
path: string;
|
|
85
|
-
abs_path: string;
|
|
86
|
-
size: number;
|
|
87
|
-
mtime: number;
|
|
88
|
-
kind: "json" | "markdown" | "jsonl" | "other";
|
|
89
|
-
}
|
|
90
|
-
export declare function listProjectFiles(prefix: string, version: string): ProjectFileEntry[];
|
|
91
|
-
export declare function readProjectFile(prefix: string, version: string, relPath: string): string | undefined;
|
|
92
|
-
export declare function commitStage(prefix: string, version: string, stage: ProjectStage, options?: {
|
|
93
|
-
gatePassed?: boolean;
|
|
94
|
-
blockingIssues?: string[];
|
|
95
|
-
completion?: number;
|
|
96
|
-
reason?: string;
|
|
97
|
-
userConfirmed?: boolean;
|
|
98
|
-
}): StageState;
|
|
99
|
-
export declare function rollbackStage(prefix: string, version: string, toStage: ProjectStage, options?: {
|
|
100
|
-
reason?: string;
|
|
101
|
-
affectedFiles?: string[];
|
|
102
|
-
}): StageState;
|
|
103
|
-
export declare function markObjectPublished(prefix: string, version: string, objectName: string): void;
|
|
104
|
-
export interface ProjectSyncStatus {
|
|
105
|
-
local_exists: boolean;
|
|
106
|
-
initialized: boolean;
|
|
107
|
-
needs_migration: boolean;
|
|
108
|
-
archived: boolean;
|
|
109
|
-
}
|
|
110
|
-
export declare function getLocalSyncStatus(prefix: string, version: string): ProjectSyncStatus;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{existsSync,mkdirSync,readFileSync,writeFileSync,readdirSync,copyFileSync,statSync,appendFileSync}from'fs';import{dirname,join}from'path';import{getWowMcpDir}from'@wowok/wowok';export const CURRENT_SCHEMA_VERSION='1.0.0';export function projectsRootDir(){return join(getWowMcpDir(),'projects');}export function projectDir(a,b){return join(projectsRootDir(),a+'_'+b);}export function deploymentDir(a,b){return join(projectDir(a,b),'deployment');}function manifestPath(a,b){return join(projectDir(a,b),'manifest.json');}function stageStatePath(a,b){return join(projectDir(a,b),'stage.json');}function auditLogPath(a,b){return join(projectDir(a,b),'audit.jsonl');}export function ensureProjectDir(a,b){const c=projectDir(a,b);return!existsSync(c)&&mkdirSync(c,{'recursive':!![]}),c;}export function initProject(a,b,c={}){ensureProjectDir(a,b);const d=new Date()['toISOString'](),e={'schema_version':CURRENT_SCHEMA_VERSION,'mcp_version':c['mcpVersion']??'unknown','prefix':a,'version':b,'created_at':d,'updated_at':d,'forked_from':c['forkedFrom']};writeFileSync(manifestPath(a,b),JSON['stringify'](e,null,0x2),'utf-8');const f={'stage':0x1,'updated_at':Date['now'](),'stage_meta':{0x1:{'committed':![],'gate_passed':![],'blocking_issues':[],'completion':0x0},0x2:{'committed':![],'gate_passed':![],'blocking_issues':[],'completion':0x0},0x3:{'committed':![],'gate_passed':![],'blocking_issues':[],'completion':0x0},0x4:{'committed':![],'gate_passed':![],'blocking_issues':[],'completion':0x0},0x5:{'committed':![],'gate_passed':![],'blocking_issues':[],'completion':0x0}},'has_published_object':![],'archived':![]};return saveStageState(a,b,f),appendAudit(a,b,{'timestamp':d,'event':'stage_commit','stage':0x1,'reason':'project\x20initialized'+(c['forkedFrom']?'\x20(forked\x20from\x20'+c['forkedFrom']+')':''),'affected_files':['manifest.json','stage.json']}),e;}export function loadManifest(a,b){const c=manifestPath(a,b);if(!existsSync(c))throw new Error('project\x20not\x20initialized:\x20'+a+'_'+b+'\x20(missing\x20manifest.json)');const d=readFileSync(c,'utf-8');return JSON['parse'](d);}export function saveManifest(a,b,c){c['updated_at']=new Date()['toISOString'](),writeFileSync(manifestPath(a,b),JSON['stringify'](c,null,0x2),'utf-8');}export function loadStageState(a,b){const c=stageStatePath(a,b);if(!existsSync(c))return undefined;const d=readFileSync(c,'utf-8');return JSON['parse'](d);}export function saveStageState(a,b,c){c['updated_at']=Date['now'](),ensureProjectDir(a,b),writeFileSync(stageStatePath(a,b),JSON['stringify'](c,null,0x2),'utf-8');}export function saveProjectFile(a,b,c,d){const e=join(projectDir(a,b),c);return mkdirSync(dirname(e),{'recursive':!![]}),writeFileSync(e,JSON['stringify'](d,null,0x2),'utf-8'),e;}export function loadProjectFile(a,b,c){const d=join(projectDir(a,b),c);if(!existsSync(d))return undefined;const e=readFileSync(d,'utf-8');return JSON['parse'](e);}export function saveProjectMarkdown(a,b,c,d){const e=join(projectDir(a,b),c);return mkdirSync(dirname(e),{'recursive':!![]}),writeFileSync(e,d,'utf-8'),e;}export function appendJsonl(a,b,c,d){const e=join(projectDir(a,b),c);return ensureProjectDir(a,b),mkdirSync(dirname(e),{'recursive':!![]}),appendFileSync(e,JSON['stringify'](d)+'\x0a','utf-8'),e;}export function appendAudit(a,b,c){appendJsonl(a,b,'audit.jsonl',c);}export function readAuditLog(a,b){const c=auditLogPath(a,b);if(!existsSync(c))return[];const d=readFileSync(c,'utf-8');return d['split']('\x0a')['filter'](e=>e['trim']()['length']>0x0)['map'](e=>JSON['parse'](e));}export function parseProjectDirName(a){const b=a['match'](/^(.+)_v(\d+)$/);if(!b)return undefined;return{'prefix':b[0x1],'version':'v'+b[0x2]};}export function listLocalProjects(){const a=projectsRootDir();if(!existsSync(a))return[];const b=readdirSync(a,{'withFileTypes':!![]}),c=[];for(const d of b){if(!d['isDirectory']())continue;const f=parseProjectDirName(d['name']);if(!f)continue;const g=join(a,d['name']),h=join(g,'manifest.json'),i=join(g,'stage.json');let j=![],k=![],l=![],n;if(existsSync(h)){j=!![];try{const p=JSON['parse'](readFileSync(h,'utf-8'));l=p['schema_version']!==CURRENT_SCHEMA_VERSION,n=p['forked_from'];}catch{}}if(existsSync(i))try{const q=JSON['parse'](readFileSync(i,'utf-8'));k=q['archived'];}catch{}let o=0x0;try{o=statSync(g)['mtimeMs'];}catch{}c['push']({'dir_name':d['name'],'prefix':f['prefix'],'version':f['version'],'path':g,'initialized':j,'archived':k,'needs_migration':l,'forked_from':n,'mtime':o});}return c['sort']((r,t)=>t['mtime']-r['mtime']);}export function projectExists(a,b){return existsSync(manifestPath(a,b));}export function forkProject(a,b,c){if(!projectExists(a,b))throw new Error('source\x20project\x20not\x20found:\x20'+a+'_'+b);const d=c['newPrefix']??a;if(c['newVersion']===b&&d===a)throw new Error('fork\x20target\x20must\x20differ\x20from\x20source\x20(set\x20newVersion\x20or\x20newPrefix)');ensureProjectDir(d,c['newVersion']);const e=projectDir(a,b),f=projectDir(d,c['newVersion']),g=[];function h(m){const n=join(e,m);if(!existsSync(n))return;const o=readdirSync(n,{'withFileTypes':!![]});for(const p of o){const q=m?join(m,p['name']):p['name'],r=join(e,q),s=join(f,q);if(p['isDirectory']())mkdirSync(s,{'recursive':!![]}),h(q);else{if(p['isFile']()){if(q==='stage.json'||q==='audit.jsonl')continue;mkdirSync(dirname(s),{'recursive':!![]}),copyFileSync(r,s),g['push'](q);}}}}h('');const i=new Date()['toISOString'](),j={'schema_version':CURRENT_SCHEMA_VERSION,'mcp_version':c['mcpVersion']??'unknown','prefix':d,'version':c['newVersion'],'created_at':i,'updated_at':i,'forked_from':e};writeFileSync(manifestPath(d,c['newVersion']),JSON['stringify'](j,null,0x2),'utf-8');const k={'stage':0x1,'updated_at':Date['now'](),'stage_meta':{0x1:{'committed':![],'gate_passed':![],'blocking_issues':[],'completion':0x0},0x2:{'committed':![],'gate_passed':![],'blocking_issues':[],'completion':0x0},0x3:{'committed':![],'gate_passed':![],'blocking_issues':[],'completion':0x0},0x4:{'committed':![],'gate_passed':![],'blocking_issues':[],'completion':0x0},0x5:{'committed':![],'gate_passed':![],'blocking_issues':[],'completion':0x0}},'has_published_object':![],'archived':![]};saveStageState(d,c['newVersion'],k),appendAudit(d,c['newVersion'],{'timestamp':i,'event':'fork_created','reason':'forked\x20from\x20'+a+'_'+b+';\x20objects\x20must\x20be\x20re-created\x20(project\x20isolation\x20§3.0)','affected_files':['manifest.json','stage.json']});const l=loadStageState(a,b);return l&&(l['archived']=!![],saveStageState(a,b,l),appendAudit(a,b,{'timestamp':i,'event':'stage_commit','reason':'archived\x20after\x20fork\x20to\x20'+d+'_'+c['newVersion'],'affected_files':['stage.json']})),{'new_prefix':d,'new_version':c['newVersion'],'new_path':f,'forked_from':e,'copied_files':g};}export function listProjectFiles(a,b){const c=projectDir(a,b);if(!existsSync(c))return[];const d=[];function e(f){const g=join(c,f),h=readdirSync(g,{'withFileTypes':!![]});for(const i of h){const j=f?join(f,i['name']):i['name'],k=join(c,j);if(i['isDirectory']())e(j);else{if(i['isFile']()){let l;try{l=statSync(k);}catch{continue;}let m='other';if(k['endsWith']('.json'))m='json';else{if(k['endsWith']('.md'))m='markdown';else{if(k['endsWith']('.jsonl'))m='jsonl';}}d['push']({'path':j,'abs_path':k,'size':l['size'],'mtime':l['mtimeMs'],'kind':m});}}}}return e(''),d['sort']((f,g)=>f['path']['localeCompare'](g['path']));}export function readProjectFile(a,b,c){const d=join(projectDir(a,b),c);if(!existsSync(d))return undefined;return readFileSync(d,'utf-8');}export function commitStage(a,b,c,d={}){const e=loadStageState(a,b);if(!e)throw new Error('project\x20not\x20initialized:\x20'+a+'_'+b);const f=d['gatePassed']??![];return e['stage_meta'][c]={'committed':!![],'committed_at':Date['now'](),'gate_passed':f,'blocking_issues':d['blockingIssues']??[],'completion':d['completion']??(f?0x64:0x0)},c<0x5&&f&&(e['stage']=c+0x1),saveStageState(a,b,e),appendAudit(a,b,{'timestamp':new Date()['toISOString'](),'event':'stage_commit','stage':c,'reason':d['reason']??'stage\x20'+c+'\x20committed','affected_files':['stage.json'],'user_confirmed':d['userConfirmed']}),e;}export function rollbackStage(a,b,c,d={}){const e=loadStageState(a,b);if(!e)throw new Error('project\x20not\x20initialized:\x20'+a+'_'+b);if(e['has_published_object'])throw new Error('cannot\x20rollback:\x20project\x20has\x20published\x20objects\x20—\x20must\x20fork\x20new\x20version\x20(§3.3)');const f=e['stage'];for(let g=c+0x1;g<=0x5;g++){e['stage_meta'][g]={'committed':![],'gate_passed':![],'blocking_issues':[],'completion':0x0};}return e['stage']=c,saveStageState(a,b,e),appendAudit(a,b,{'timestamp':new Date()['toISOString'](),'event':'stage_rollback','stage':c,'reason':d['reason']??'rollback\x20from\x20stage\x20'+f+'\x20to\x20'+c,'affected_files':d['affectedFiles']??['stage.json']}),e;}export function markObjectPublished(a,b,c){const d=loadStageState(a,b);if(!d)return;if(d['has_published_object'])return;d['has_published_object']=!![],saveStageState(a,b,d),appendAudit(a,b,{'timestamp':new Date()['toISOString'](),'event':'object_published','stage':0x5,'reason':'object\x20published:\x20'+c+'\x20—\x20rollback\x20now\x20requires\x20fork\x20(§3.3)','affected_files':['stage.json']});}export function getLocalSyncStatus(a,b){const c=projectExists(a,b);if(!c)return{'local_exists':![],'initialized':![],'needs_migration':![],'archived':![]};let d=!![],e=![],f=![];try{const g=loadManifest(a,b);e=g['schema_version']!==CURRENT_SCHEMA_VERSION;}catch{d=![];}try{const h=loadStageState(a,b);if(h)f=h['archived'];}catch{}return{'local_exists':!![],'initialized':d,'needs_migration':e,'archived':f};}
|
package/dist/project/query.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { ProjectGraph, GraphEdge } from "./graph.js";
|
|
2
|
-
export interface ProjectInfo {
|
|
3
|
-
prefix: string;
|
|
4
|
-
objectCount: number;
|
|
5
|
-
types: string[];
|
|
6
|
-
versions?: string[];
|
|
7
|
-
objects: Array<{
|
|
8
|
-
name?: string;
|
|
9
|
-
address?: string;
|
|
10
|
-
type?: string;
|
|
11
|
-
version?: string;
|
|
12
|
-
tags?: string[];
|
|
13
|
-
}>;
|
|
14
|
-
}
|
|
15
|
-
export interface DependencyTrace {
|
|
16
|
-
object: string;
|
|
17
|
-
directDependencies: GraphEdge[];
|
|
18
|
-
transitive: Array<{
|
|
19
|
-
object: string;
|
|
20
|
-
via: string[];
|
|
21
|
-
}>;
|
|
22
|
-
dangling: string[];
|
|
23
|
-
}
|
|
24
|
-
export interface ReverseTrace {
|
|
25
|
-
object: string;
|
|
26
|
-
referencedBy: GraphEdge[];
|
|
27
|
-
}
|
|
28
|
-
export declare function listProjects(): Promise<ProjectInfo[]>;
|
|
29
|
-
export declare function listProjectObjects(prefix: string): Promise<ProjectInfo["objects"]>;
|
|
30
|
-
export declare function listShareableObjects(): Promise<Array<{
|
|
31
|
-
name?: string;
|
|
32
|
-
address?: string;
|
|
33
|
-
type?: string;
|
|
34
|
-
project?: string;
|
|
35
|
-
}>>;
|
|
36
|
-
export declare function traceDependencies(graph: ProjectGraph, objectId: string): DependencyTrace;
|
|
37
|
-
export declare function traceReferencedBy(graph: ProjectGraph, objectId: string): ReverseTrace;
|
|
38
|
-
export declare function prePublishCheck(graph: ProjectGraph, serviceId: string): string[];
|
|
39
|
-
export declare function findCrossProjectReferences(graph: ProjectGraph): Array<{
|
|
40
|
-
edge: GraphEdge;
|
|
41
|
-
fromProject?: string;
|
|
42
|
-
toProject?: string;
|
|
43
|
-
}>;
|
package/dist/project/query.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{LocalMark}from'@wowok/wowok';import{extractAllProjectVersions,TAG_PREFIX}from'./namespace.js';export async function listProjects(){const a=await LocalMark['Instance']()['list'](undefined),b=new Map();for(const c of a){const d=extractAllProjectVersions(c['tags']);if(d['length']===0x0)continue;const e=new Map();for(const h of d){if(!e['has'](h['prefix']))e['set'](h['prefix'],[]);e['get'](h['prefix'])['push'](h['version']);}const f=c['tags']?.['find'](i=>i['startsWith'](TAG_PREFIX['type'])),g=f?.['slice'](TAG_PREFIX['type']['length']);for(const [i,j]of e){const k=j['some'](o=>o!==undefined),l=k?j['filter'](o=>o!==undefined):j;!b['has'](i)&&b['set'](i,{'prefix':i,'objectCount':0x0,'types':[],'versions':[],'objects':[]});const n=b['get'](i);if(g&&!n['types']['includes'](g))n['types']['push'](g);for(const o of l){n['objectCount']++,o&&!n['versions']['includes'](o)&&n['versions']['push'](o),n['objects']['push']({'name':c['name'],'address':c['address'],'type':g,'version':o,'tags':c['tags']});}}}return Array['from'](b['values']())['sort']((p,q)=>q['objectCount']-p['objectCount']);}export async function listProjectObjects(a){const b=await LocalMark['Instance']()['list'](undefined),c=[],d=a['includes']('_v');for(const e of b){const f=extractAllProjectVersions(e['tags']),g=f['find'](i=>{if(d)return i['version']?i['prefix']+'_'+i['version']===a:![];return i['prefix']===a;});if(!g)continue;const h=e['tags']?.['find'](i=>i['startsWith'](TAG_PREFIX['type']));c['push']({'name':e['name'],'address':e['address'],'type':h?.['slice'](TAG_PREFIX['type']['length']),'version':g['version'],'tags':e['tags']});}return c;}export async function listShareableObjects(){const a=await LocalMark['Instance']()['list']({'tags':[TAG_PREFIX['shareable']+'true']});return a['map'](b=>{const c=b['tags']?.['find'](e=>e['startsWith'](TAG_PREFIX['type'])),d=b['tags']?.['find'](e=>e['startsWith'](TAG_PREFIX['project']));return{'name':b['name'],'address':b['address'],'type':c?.['slice'](TAG_PREFIX['type']['length']),'project':d?.['slice'](TAG_PREFIX['project']['length'])};});}export function traceDependencies(a,b){const c=a['getDependencies'](b),d=new Set([b]),f=[],g=c['map'](i=>({'id':i['to'],'via':[i['from'],i['to']]})),h=new Set();while(g['length']>0x0){const {id:i,via:j}=g['shift']();if(d['has'](i))continue;d['add'](i);const k=a['getNode'](i);(!k||!k['address']&&!k['project'])&&h['add'](i);f['push']({'object':i,'via':j});const l=a['getDependencies'](i);for(const m of l){!d['has'](m['to'])&&g['push']({'id':m['to'],'via':[...j,m['to']]});}}return{'object':b,'directDependencies':c,'transitive':f,'dangling':Array['from'](h)};}export function traceReferencedBy(a,b){return{'object':b,'referencedBy':a['getReferencedBy'](b)};}export function prePublishCheck(a,b){const c=[],d=traceDependencies(a,b);d['dangling']['length']>0x0&&c['push']('Service\x20\x27'+b+'\x27\x20references\x20objects\x20not\x20yet\x20created:\x20'+d['dangling']['join'](',\x20')+'.\x20'+'Publishing\x20will\x20lock\x20\x27machine\x27\x20and\x20\x27order_allocators\x27\x20—\x20ensure\x20these\x20are\x20finalized\x20first.');const e=a['detectCycles']();return e['length']>0x0&&c['push']('Dependency\x20graph\x20contains\x20'+e['length']+'\x20cycle(s):\x20'+e['map'](f=>f['join']('\x20→\x20'))['join'](';\x20')+'.\x20Cycles\x20may\x20indicate\x20a\x20design\x20issue.'),c;}export function findCrossProjectReferences(a){const b=[];for(const c of a['getEdges']()){const d=a['getNode'](c['from']),e=a['getNode'](c['to']),f=d?.['project'],g=e?.['project'];f&&g&&f!==g&&b['push']({'edge':c,'fromProject':f,'toProject':g});}return b;}
|
|
@@ -1 +0,0 @@
|
|
|
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,93 +0,0 @@
|
|
|
1
|
-
import { type Project, type ProjectObject, type GraphEdge } from "@wowok/wowok";
|
|
2
|
-
import type { ReputationData } from "./graph-builder.js";
|
|
3
|
-
export interface SemanticObjectContext {
|
|
4
|
-
address: string;
|
|
5
|
-
name: string | null;
|
|
6
|
-
objectType: string | null;
|
|
7
|
-
role: string | null;
|
|
8
|
-
description: string;
|
|
9
|
-
keyFields: Record<string, unknown>;
|
|
10
|
-
cacheFreshness: "fresh" | "stale" | "unknown";
|
|
11
|
-
}
|
|
12
|
-
export interface SemanticGraphContext {
|
|
13
|
-
nodeCount: number;
|
|
14
|
-
edgeCount: number;
|
|
15
|
-
edgesByType: Record<string, number>;
|
|
16
|
-
edgesBySource: Record<string, number>;
|
|
17
|
-
directDependencies: Array<{
|
|
18
|
-
target: string;
|
|
19
|
-
targetType: string | null;
|
|
20
|
-
fieldName: string | null;
|
|
21
|
-
relationshipType: string;
|
|
22
|
-
}>;
|
|
23
|
-
potentialGaps: Array<{
|
|
24
|
-
target: string;
|
|
25
|
-
targetType: string | null;
|
|
26
|
-
fieldName: string;
|
|
27
|
-
reason: string;
|
|
28
|
-
}>;
|
|
29
|
-
}
|
|
30
|
-
export interface SemanticReputationContext {
|
|
31
|
-
address: string;
|
|
32
|
-
likes: number;
|
|
33
|
-
dislikes: number;
|
|
34
|
-
favorites: number;
|
|
35
|
-
sentimentScore: number;
|
|
36
|
-
notableVoters: Array<{
|
|
37
|
-
who: string;
|
|
38
|
-
like: boolean;
|
|
39
|
-
dislike: boolean;
|
|
40
|
-
favor: boolean;
|
|
41
|
-
}>;
|
|
42
|
-
}
|
|
43
|
-
export interface SemanticProjectContext {
|
|
44
|
-
project: {
|
|
45
|
-
prefix: string;
|
|
46
|
-
name: string;
|
|
47
|
-
description: string | null;
|
|
48
|
-
industry: string | null;
|
|
49
|
-
perspective: string;
|
|
50
|
-
status: string;
|
|
51
|
-
network: string;
|
|
52
|
-
serviceAddress: string | null;
|
|
53
|
-
currentVersion: string | null;
|
|
54
|
-
};
|
|
55
|
-
objects: SemanticObjectContext[];
|
|
56
|
-
graph: SemanticGraphContext;
|
|
57
|
-
reputation: SemanticReputationContext[];
|
|
58
|
-
freshnessSummary: {
|
|
59
|
-
freshCount: number;
|
|
60
|
-
staleCount: number;
|
|
61
|
-
unknownCount: number;
|
|
62
|
-
oldestFetch: number | null;
|
|
63
|
-
newestFetch: number | null;
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
export interface EvaluationPrompt {
|
|
67
|
-
evaluationType: "risk" | "trust" | "worth_buying" | "completeness" | "value";
|
|
68
|
-
context: SemanticProjectContext;
|
|
69
|
-
prompt: string;
|
|
70
|
-
scoringCriteria: ScoringCriterion[];
|
|
71
|
-
}
|
|
72
|
-
export interface ScoringCriterion {
|
|
73
|
-
name: string;
|
|
74
|
-
description: string;
|
|
75
|
-
weight: number;
|
|
76
|
-
minScore: number;
|
|
77
|
-
maxScore: number;
|
|
78
|
-
}
|
|
79
|
-
export declare class SemanticAssembler {
|
|
80
|
-
private localProject;
|
|
81
|
-
constructor();
|
|
82
|
-
assemble(project: Project, objects: ProjectObject[], edges: GraphEdge[], reputation?: Map<string, ReputationData>): Promise<SemanticProjectContext>;
|
|
83
|
-
private assembleObjects;
|
|
84
|
-
private describeObject;
|
|
85
|
-
private extractKeyFields;
|
|
86
|
-
private assembleGraph;
|
|
87
|
-
private assembleReputation;
|
|
88
|
-
private classifyFreshness;
|
|
89
|
-
private computeFreshnessSummary;
|
|
90
|
-
buildEvaluationPrompt(evaluationType: EvaluationPrompt["evaluationType"], context: SemanticProjectContext): EvaluationPrompt;
|
|
91
|
-
private getScoringCriteria;
|
|
92
|
-
private formatPrompt;
|
|
93
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{LocalProject}from'@wowok/wowok';import{normalizeObjectType}from'./object-type.js';const FRESH_THRESHOLD_MS=0x1*0x3c*0x3c*0x3e8,STALE_THRESHOLD_MS=0x18*0x3c*0x3c*0x3e8;export class SemanticAssembler{['localProject'];constructor(){this['localProject']=LocalProject['Instance']();}async['assemble'](a,b,c,d){const e=await this['assembleObjects'](b),f=this['assembleGraph'](c),g=this['assembleReputation'](b,d),h=this['computeFreshnessSummary'](e);return{'project':{'prefix':a['prefix'],'name':a['name'],'description':a['description'],'industry':a['industry'],'perspective':a['perspective'],'status':a['status'],'network':a['network'],'serviceAddress':a['serviceAddress'],'currentVersion':a['currentVersion']},'objects':e,'graph':f,'reputation':g,'freshnessSummary':h};}async['assembleObjects'](a){const b=[];for(const c of a){const d=await this['localProject']['getCachedObject'](c['objectAddress']),e=d?this['describeObject'](c,d):'Object\x20'+c['objectAddress']+'\x20(no\x20cached\x20on-chain\x20data)',f=d?this['extractKeyFields'](c['objectType'],d):{},g=d?this['classifyFreshness'](d['fetchedAt']):'unknown';b['push']({'address':c['objectAddress'],'name':c['objectName'],'objectType':c['objectType'],'role':c['role'],'description':e,'keyFields':f,'cacheFreshness':g});}return b;}['describeObject'](a,b){const c=normalizeObjectType(a['objectType']),d=a['objectName']??abbreviateAddress(a['objectAddress']);let e=c+'\x20\x22'+d+'\x22\x20at\x20'+abbreviateAddress(a['objectAddress']);try{const f=JSON['parse'](b['data']);switch(c){case'Service':{const g=f['bPublished'],h=f['bPaused'],i=f['sales'];e+=g?h?'\x20(published\x20but\x20PAUSED)':'\x20(published,\x20active)':'\x20(not\x20yet\x20published)';i&&Array['isArray'](i)&&i['length']>0x0&&(e+='\x20with\x20'+i['length']+'\x20sale\x20option(s)');break;}case'Machine':{const j=f['node_count']??f['nodeCount'],k=f['bPublished'];e+=k?'\x20(published,\x20'+j+'\x20nodes)':'\x20(draft,\x20'+j+'\x20nodes)';break;}case'Treasury':{e+='\x20(compensation\x20fund)';break;}case'Guard':{e+='\x20(validation\x20rules)';break;}default:break;}}catch{}return e;}['extractKeyFields'](a,b){const c={};try{const d=JSON['parse'](b['data']);switch(normalizeObjectType(a)){case'Service':c['bPublished']=d['bPublished'],c['bPaused']=d['bPaused'],c['sales']=d['sales'],c['machine']=d['machine'],c['buy_guard']=d['buy_guard'],c['permission']=d['permission'],c['compensation_fund']=d['compensation_fund'],c['order_allocators']=d['order_allocators'],c['arbitrations']=d['arbitrations'],c['rewards']=d['rewards'],c['repositories']=d['repositories'];break;case'Machine':c['bPublished']=d['bPublished'],c['bPaused']=d['bPaused'],c['node_count']=d['node_count']??d['nodeCount'],c['permission']=d['permission'];break;case'Treasury':c['permission']=d['permission'],c['guard']=d['guard'];break;case'Allocation':case'Arbitration':case'Reward':case'Repository':case'Demand':c['permission']=d['permission'],c['guard']=d['guard'];break;default:break;}}catch{}return c;}['assembleGraph'](a){const b={},c={},d=[],e=[];for(const f of a){b[f['relationshipType']]=(b[f['relationshipType']]??0x0)+0x1,c[f['edgeSource']]=(c[f['edgeSource']]??0x0)+0x1;f['edgeSource']==='internal'&&f['depth']===0x0&&d['push']({'target':f['targetObject'],'targetType':null,'fieldName':f['fieldName'],'relationshipType':f['relationshipType']});if(f['edgeSource']==='potential'){const g=f['metadata']?.['reason'];e['push']({'target':f['targetObject'],'targetType':f['metadata']?.['expected_target_type'],'fieldName':f['fieldName']??'unknown','reason':typeof g==='string'?g:'expected_relationship_missing'});}}return{'nodeCount':new Set([...a['map'](h=>h['sourceObject']),...a['map'](h=>h['targetObject'])])['size'],'edgeCount':a['length'],'edgesByType':b,'edgesBySource':c,'directDependencies':d,'potentialGaps':e};}['assembleReputation'](a,b){if(!b||b['size']===0x0)return[];const c=[];for(const d of a){const e=b['get'](d['objectAddress']);if(!e)continue;const f=e['likes']+e['dislikes'],g=f>0x0?e['likes']/f:0.5;c['push']({'address':d['objectAddress'],'likes':e['likes'],'dislikes':e['dislikes'],'favorites':e['favorites'],'sentimentScore':g,'notableVoters':e['voters']['slice'](0x0,0x5)['map'](h=>({'who':abbreviateAddress(h['who']),'like':h['like'],'dislike':h['dislike'],'favor':h['favor']}))});}return c;}['classifyFreshness'](a){const b=Date['now']()-a;if(b<FRESH_THRESHOLD_MS)return'fresh';if(b<STALE_THRESHOLD_MS)return'stale';return'stale';}['computeFreshnessSummary'](a){let b=0x0,c=0x0,d=0x0,e=null,f=null;for(const g of a){switch(g['cacheFreshness']){case'fresh':b++;break;case'stale':c++;break;case'unknown':d++;break;}}return{'freshCount':b,'staleCount':c,'unknownCount':d,'oldestFetch':e,'newestFetch':f};}['buildEvaluationPrompt'](a,b){const c=this['getScoringCriteria'](a),d=this['formatPrompt'](a,b,c);return{'evaluationType':a,'context':b,'prompt':d,'scoringCriteria':c};}['getScoringCriteria'](a){switch(a){case'risk':return[{'name':'structural_risk','description':'Risk\x20from\x20missing\x20bindings,\x20broken\x20workflows,\x20incomplete\x20setup','weight':0.3,'minScore':0x0,'maxScore':0x64},{'name':'fund_safety','description':'Risk\x20from\x20Treasury/Allocation\x20misconfiguration,\x20missing\x20compensation\x20fund','weight':0.25,'minScore':0x0,'maxScore':0x64},{'name':'operational_risk','description':'Risk\x20from\x20Machine/Guard\x20complexity,\x20pause\x20state,\x20missing\x20arbitration','weight':0.25,'minScore':0x0,'maxScore':0x64},{'name':'governance_risk','description':'Risk\x20from\x20Permission\x20setup,\x20missing\x20UM,\x20overly\x20permissive\x20rules','weight':0.2,'minScore':0x0,'maxScore':0x64}];case'trust':return[{'name':'reputation','description':'Registrar\x20like/dislike\x20ratio\x20and\x20favor\x20count','weight':0.3,'minScore':0x0,'maxScore':0x64},{'name':'arbitration_coverage','description':'Presence\x20and\x20quality\x20of\x20arbitration\x20arrangements','weight':0.25,'minScore':0x0,'maxScore':0x64},{'name':'guard_quality','description':'Guard\x20rule\x20complexity\x20and\x20coverage\x20of\x20business\x20scenarios','weight':0.25,'minScore':0x0,'maxScore':0x64},{'name':'transparency','description':'Object\x20descriptions,\x20repository\x20data,\x20contact\x20information\x20availability','weight':0.2,'minScore':0x0,'maxScore':0x64}];case'worth_buying':return[{'name':'price_reasonableness','description':'Service\x20pricing\x20vs.\x20comparable\x20services\x20and\x20market\x20norms','weight':0.3,'minScore':0x0,'maxScore':0x64},{'name':'refund_protection','description':'Compensation\x20fund\x20balance,\x20lock\x20duration,\x20refund\x20workflow\x20availability','weight':0.25,'minScore':0x0,'maxScore':0x64},{'name':'risk_adjusted_value','description':'Value\x20proposition\x20adjusted\x20for\x20project\x20risk\x20score','weight':0.25,'minScore':0x0,'maxScore':0x64},{'name':'trust_adjusted_value','description':'Value\x20proposition\x20adjusted\x20for\x20merchant\x20trust\x20score','weight':0.2,'minScore':0x0,'maxScore':0x64}];case'completeness':return[{'name':'object_coverage','description':'Expected\x20objects\x20present\x20vs.\x20missing\x20(based\x20on\x20EXPECTED_RELATIONSHIPS)','weight':0.3,'minScore':0x0,'maxScore':0x64},{'name':'binding_completeness','description':'Required\x20bindings\x20established\x20(Service→Machine,\x20Guard,\x20Permission,\x20etc.)','weight':0.3,'minScore':0x0,'maxScore':0x64},{'name':'workflow_rationality','description':'Machine\x20node\x20topology\x20is\x20sound,\x20no\x20dangling\x20nodes\x20or\x20cycles','weight':0.2,'minScore':0x0,'maxScore':0x64},{'name':'deployment_readiness','description':'Service\x20publishable,\x20all\x20prerequisites\x20met','weight':0.2,'minScore':0x0,'maxScore':0x64}];case'value':return[{'name':'market_positioning','description':'Service\x20differentiation\x20and\x20competitive\x20positioning','weight':0.3,'minScore':0x0,'maxScore':0x64},{'name':'revenue_potential','description':'Pricing\x20strategy\x20and\x20revenue\x20model\x20viability','weight':0.3,'minScore':0x0,'maxScore':0x64},{'name':'scalability','description':'Ability\x20to\x20handle\x20growth\x20(Machine\x20capacity,\x20Allocation\x20flexibility)','weight':0.2,'minScore':0x0,'maxScore':0x64},{'name':'ecosystem_fit','description':'Integration\x20with\x20WoWok\x20ecosystem\x20(rewards,\x20demands,\x20repositories)','weight':0.2,'minScore':0x0,'maxScore':0x64}];}}['formatPrompt'](a,b,d){const e=[];e['push']('#\x20Project\x20Evaluation:\x20'+a['toUpperCase']()),e['push'](''),e['push']('##\x20Project:\x20'+b['project']['name']+'\x20('+b['project']['prefix']+')'),e['push']('-\x20Perspective:\x20'+b['project']['perspective']),e['push']('-\x20Status:\x20'+b['project']['status']),e['push']('-\x20Network:\x20'+b['project']['network']),e['push']('-\x20Industry:\x20'+(b['project']['industry']??'unspecified')),e['push']('-\x20Service:\x20'+(b['project']['serviceAddress']??'not\x20set')),e['push'](''),e['push']('##\x20Objects');for(const f of b['objects']){e['push']('-\x20'+f['description']);}e['push'](''),e['push']('##\x20Relationship\x20Graph'),e['push']('-\x20Total\x20nodes:\x20'+b['graph']['nodeCount']),e['push']('-\x20Total\x20edges:\x20'+b['graph']['edgeCount']),e['push']('-\x20Edge\x20sources:\x20'+JSON['stringify'](b['graph']['edgesBySource'])),e['push']('-\x20Edge\x20types:\x20'+JSON['stringify'](b['graph']['edgesByType'])),e['push']('-\x20Direct\x20dependencies:\x20'+b['graph']['directDependencies']['length']);if(b['graph']['potentialGaps']['length']>0x0){e['push']('-\x20**Missing\x20relationships\x20(potential\x20gaps):\x20'+b['graph']['potentialGaps']['length']+'**');for(const g of b['graph']['potentialGaps']['slice'](0x0,0xa)){e['push']('\x20\x20-\x20'+g['fieldName']+'\x20→\x20'+(g['targetType']??'unknown')+'\x20('+g['reason']+')');}}e['push']('');if(b['reputation']['length']>0x0){e['push']('##\x20Reputation\x20Data\x20(from\x20Registrar)');for(const h of b['reputation']){e['push']('-\x20'+abbreviateAddress(h['address'])+':\x20'+h['likes']+'\x20likes,\x20'+h['dislikes']+'\x20dislikes,\x20'+h['favorites']+'\x20favorites\x20(sentiment:\x20'+(h['sentimentScore']*0x64)['toFixed'](0x0)+'%)');}e['push']('');}e['push']('##\x20Cache\x20Freshness'),e['push']('-\x20Fresh:\x20'+b['freshnessSummary']['freshCount']),e['push']('-\x20Stale:\x20'+b['freshnessSummary']['staleCount']),e['push']('-\x20Unknown:\x20'+b['freshnessSummary']['unknownCount']),e['push'](''),e['push']('##\x20Scoring\x20Criteria'),e['push']('Please\x20score\x20each\x20criterion\x20(0-100,\x20higher\x20=\x20better)\x20and\x20provide\x20a\x20brief\x20justification:');for(const i of d){e['push']('-\x20**'+i['name']+'**\x20(weight:\x20'+i['weight']+'):\x20'+i['description']);}return e['push'](''),e['push']('##\x20Instructions'),e['push']('1.\x20Analyze\x20the\x20project\x20from\x20the\x20\x22'+a+'\x22\x20perspective.'),e['push']('2.\x20Score\x20each\x20criterion\x20above\x20(0-100).'),e['push']('3.\x20Compute\x20a\x20weighted\x20overall\x20score.'),e['push']('4.\x20Provide\x20a\x201-2\x20sentence\x20summary\x20of\x20your\x20assessment.'),e['push']('5.\x20Return\x20the\x20result\x20as\x20JSON:\x20{\x20score:\x20number,\x20summary:\x20string,\x20details:\x20{\x20criterion_scores:\x20{...},\x20justification:\x20string\x20}\x20}'),e['join']('\x0a');}}function abbreviateAddress(a){if(!a||a['length']<0xc)return a;return a['slice'](0x0,0x6)+'...'+a['slice'](-0x4);}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function buildSemanticGraph(a,b){const c=[],d=[],e=[];c['push']({'id':'main_permission','type':'permission','purpose':'Role-based\x20access\x20control\x20for\x20merchant,\x20customer,\x20and\x20optional\x20arbitrator','derivedFrom':{'intentField':'roles','rationale':'All\x20WOW\x20services\x20require\x20a\x20Permission\x20object\x20for\x20role\x20management'},'config':{'name':{'type':'string','value':a['description']['slice'](0x0,0x14)+'_permission','mapsTo':'object.name'}},'expectedState':{'published':!![],'paused':![]}});(a['intent']['startsWith']('sell_')||a['intent']==='rent_asset')&&(c['push']({'id':'main_service','type':'service','purpose':'Main\x20service\x20offering:\x20'+a['description'],'derivedFrom':{'intentField':'description','rationale':'Service\x20is\x20the\x20primary\x20object\x20representing\x20the\x20merchant\x20offering'},'config':{'name':{'type':'string','value':a['description']['slice'](0x0,0x14)+'_service','mapsTo':'object.name'},'type_parameter':{'type':'string','value':a['payment']['currency'],'mapsTo':'object.type_parameter'},'permission':{'type':'address_ref','targetId':'main_permission','mapsTo':'object.permission'}},'expectedState':{'published':!![],'paused':![]}}),d['push']({'from':'main_service','to':'main_permission','relation':'has_permission','required':!![],'derivedFrom':{'intentField':'roles','rationale':'Service\x20must\x20reference\x20its\x20Permission\x20object'}}));(a['payment']['model']==='milestone'||a['deliverables']['length']>0x1)&&(c['push']({'id':'main_machine','type':'machine','purpose':'Workflow\x20controlling\x20deliverable\x20milestones\x20and\x20acceptance','derivedFrom':{'intentField':'deliverables','rationale':'Multiple\x20deliverables\x20or\x20milestone\x20payment\x20requires\x20Machine\x20workflow'},'config':{'name':{'type':'string','value':a['description']['slice'](0x0,0x14)+'_machine','mapsTo':'object.name'},'permission':{'type':'address_ref','targetId':'main_permission','mapsTo':'object.permission'}},'expectedState':{'published':!![],'paused':![]}}),c['find'](l=>l['id']==='main_service')&&d['push']({'from':'main_service','to':'main_machine','relation':'uses_machine','required':!![],'derivedFrom':{'intentField':'deliverables','rationale':'Service\x20binds\x20to\x20Machine\x20for\x20workflow\x20execution'}}));(a['payment']['model']==='milestone'||a['payment']['model']==='escrow'||a['trust']['escrow'])&&(c['push']({'id':'main_allocation','type':'allocation','purpose':'Fund\x20distribution\x20among\x20merchant\x20and\x20optional\x20suppliers','derivedFrom':{'intentField':'payment.allocation','rationale':'Escrow/milestone\x20requires\x20Allocation\x20for\x20fund\x20routing'},'config':{'name':{'type':'string','value':a['description']['slice'](0x0,0x14)+'_allocation','mapsTo':'object.name'},'type_parameter':{'type':'string','value':a['payment']['currency'],'mapsTo':'object.type_parameter'},'permission':{'type':'address_ref','targetId':'main_permission','mapsTo':'object.permission'}},'expectedState':{'published':!![],'paused':![]}}),c['find'](l=>l['id']==='main_service')&&d['push']({'from':'main_service','to':'main_allocation','relation':'has_order_allocators','required':!![],'derivedFrom':{'intentField':'payment','rationale':'Service\x20must\x20bind\x20Allocation\x20for\x20order\x20fund\x20routing'}}));a['trust']['arbitration']!=='none'&&(c['push']({'id':'main_arbitration','type':'arb','purpose':'Independent\x20dispute\x20resolution','derivedFrom':{'intentField':'trust.arbitration','rationale':'Arbitration\x20object\x20provides\x20binding\x20dispute\x20resolution'},'config':{'name':{'type':'string','value':a['description']['slice'](0x0,0x14)+'_arbitration','mapsTo':'object.name'},'type_parameter':{'type':'string','value':a['payment']['currency'],'mapsTo':'object.type_parameter'}},'expectedState':{'published':!![],'paused':![]}}),c['push']({'id':'arb_permission','type':'permission','purpose':'Independent\x20permission\x20for\x20arbitration\x20(MUST\x20differ\x20from\x20Service.permission)','derivedFrom':{'intentField':'trust.arbitration','rationale':'Contract-enforced:\x20arbitration.permission\x20!=\x20service.permission\x20(E_ARBITRATION_PERMISSION_CONFLICT=33)'},'config':{'name':{'type':'string','value':a['description']['slice'](0x0,0x14)+'_arb_permission','mapsTo':'object.name'}},'expectedState':{'published':!![],'paused':![]}}),d['push']({'from':'main_arbitration','to':'arb_permission','relation':'has_permission','required':!![],'derivedFrom':{'intentField':'trust.arbitration','rationale':'Arbitration\x20requires\x20its\x20own\x20Permission'}}),c['find'](l=>l['id']==='main_service')&&d['push']({'from':'main_service','to':'main_arbitration','relation':'has_arbitration','required':![],'derivedFrom':{'intentField':'trust.arbitration','rationale':'Service\x20references\x20Arbitration\x20in\x20arbitrations\x20list'}}));const f=b['some'](l=>l['id']==='wip_provenance'||l['id']==='subscription_with_proof'||l['id']==='damage_attestation');f&&c['push']({'id':'main_repository','type':'repository','purpose':'Store\x20WIP\x20hashes\x20and\x20delivery\x20evidence','derivedFrom':{'intentField':'deliverables','rationale':'WIP\x20provenance\x20requires\x20Repository\x20for\x20hash\x20commitments'},'config':{'name':{'type':'string','value':a['description']['slice'](0x0,0x14)+'_repository','mapsTo':'object.name'},'permission':{'type':'address_ref','targetId':'main_permission','mapsTo':'object.permission'}},'expectedState':{'published':!![],'paused':![]}});for(const l of b){for(const m of l['templateRefs']){if(m['object_type']==='guard')c['push']({'id':'guard_'+l['id'],'type':'guard','purpose':m['purpose'],'derivedFrom':{'intentField':'trust','rationale':'Guard\x20for\x20'+l['name']+'\x20module'},'config':{'name':{'type':'string','value':a['description']['slice'](0x0,0x14)+'_'+l['id']+'_guard','mapsTo':'object.name'}},'expectedState':{'published':!![],'paused':![]}});else{if(m['template_id']['startsWith']('supplier-')){const n='supplier_'+l['id']+'_'+m['object_type'];if(c['some'](p=>p['id']===n))continue;c['push']({'id':n,'type':m['object_type'],'purpose':m['purpose'],'derivedFrom':{'intentField':'roles.suppliers','rationale':'Supplier\x20'+m['object_type']+'\x20for\x20'+l['name']+'\x20(B-6\x20two-hop\x20waterfall)'},'config':{'name':{'type':'string','value':a['description']['slice'](0x0,0x14)+'_'+l['id']+'_'+m['object_type'],'mapsTo':'object.name'}},'expectedState':{'published':!![],'paused':![]}});const o=c['find'](p=>p['id']==='main_service');o&&d['push']({'from':'main_service','to':n,'relation':'sub_order','required':![],'derivedFrom':{'intentField':'payment.allocation','rationale':'Two-hop\x20waterfall:\x20main\x20order\x20→\x20tier-1\x20allocation\x20→\x20supplier\x20sub-order\x20→\x20tier-2\x20allocation\x20('+l['name']+')'}});}}}}if(a['intent']['startsWith']('sell_')||a['intent']==='rent_asset'){c['push']({'id':'main_contact','type':'contact','purpose':'Public\x20contact/IM\x20channel\x20so\x20customers\x20can\x20reach\x20the\x20merchant\x20before\x20ordering','derivedFrom':{'intentField':'description','rationale':'A\x20discoverable\x20contact\x20object\x20improves\x20customer\x20trust\x20and\x20order\x20conversion'},'config':{'name':{'type':'string','value':a['description']['slice'](0x0,0x14)+'_contact','mapsTo':'object.name'},'description':{'type':'string','value':a['description'],'mapsTo':'object.description'}},'expectedState':{'published':!![],'paused':![]}});const p=c['find'](q=>q['id']==='main_service');p&&(p['config']['um']={'type':'address_ref','targetId':'main_contact','mapsTo':'object.um'},d['push']({'from':'main_service','to':'main_contact','relation':'has_contact','required':![],'derivedFrom':{'intentField':'description','rationale':'Service\x20binds\x20Contact\x20via\x20um\x20so\x20customers\x20can\x20reach\x20the\x20merchant'}}));}(a['intent']['startsWith']('sell_')||a['intent']==='rent_asset')&&(c['push']({'id':'main_reward','type':'reward','purpose':'Optional\x20incentive\x20pool\x20(discount/referral)\x20to\x20attract\x20and\x20retain\x20customers','derivedFrom':{'intentField':'payment','rationale':'Rewards\x20lower\x20acquisition\x20cost\x20and\x20boost\x20conversion'},'config':{'name':{'type':'string','value':a['description']['slice'](0x0,0x14)+'_reward','mapsTo':'object.name'},'type_parameter':{'type':'string','value':a['payment']['currency'],'mapsTo':'object.type_parameter'},'permission':{'type':'address_ref','targetId':'main_permission','mapsTo':'object.permission'}},'expectedState':{'published':!![],'paused':![]}}),c['find'](q=>q['id']==='main_service')&&d['push']({'from':'main_service','to':'main_reward','relation':'has_rewards','required':![],'derivedFrom':{'intentField':'payment','rationale':'Service\x20can\x20reference\x20Reward\x20in\x20its\x20rewards\x20list'}}));e['push']({'id':'service_permission_bound','level':'hard','description':'Service\x20must\x20be\x20bound\x20to\x20a\x20Permission\x20object','source':{'layer':'contract','reference':'service.move:\x20permission\x20field\x20is\x20required'},'fixSuggestion':'Create\x20Permission\x20object\x20first,\x20then\x20reference\x20it\x20in\x20Service.object.permission'});a['trust']['arbitration']!=='none'&&e['push']({'id':'arbitration_permission_independent','level':'hard','description':'Arbitration.permission\x20MUST\x20be\x20different\x20from\x20Service.permission','source':{'layer':'contract','reference':'service.move:433-436\x20E_ARBITRATION_PERMISSION_CONFLICT=33'},'fixSuggestion':'Create\x20a\x20dedicated\x20Permission\x20object\x20for\x20Arbitration,\x20do\x20NOT\x20reuse\x20Service.permission'});a['payment']['model']==='milestone'&&e['push']({'id':'machine_bound_before_publish','level':'hard','description':'Machine\x20must\x20be\x20published\x20and\x20bound\x20to\x20Service\x20before\x20Service.publish','source':{'layer':'contract','reference':'service.move:\x20machine\x20is\x20IMMUTABLE\x20after\x20publish'},'fixSuggestion':'Create\x20and\x20publish\x20Machine\x20before\x20calling\x20Service.publish.\x20Machine\x20cannot\x20be\x20changed\x20after\x20Service\x20is\x20published.'});const g=calculateModuleScoreBoost(b),h=Math['min'](0x64,0x28+Object['values'](g)['reduce']((q,r)=>q+r,0x0)/0x2),i=Math['min'](0x64,0x32+(g['trust']??0x0)+(g['fund_safety']??0x0)),j=Math['min'](0x64,0x1e+b['length']*0x8),k={'estimatedRiskScore':h,'estimatedTrustScore':i,'estimatedCompletenessScore':j,'keyRisks':[...a['trust']['arbitration']==='none'?['No\x20arbitration\x20configured\x20—\x20disputes\x20have\x20no\x20resolution\x20path']:[],...a['payment']['model']==='upfront'&&a['trust']['refundPolicy']==='no_refund'?['Full\x20upfront\x20+\x20no\x20refund\x20=\x20high\x20user\x20risk']:[]],'strengths':b['map'](q=>q['name']+':\x20'+q['description']['slice'](0x0,0x3c)+'...'),'moduleBoosts':g};return{'nodes':c,'edges':d,'constraints':e,'evaluationPreview':k,'adoptedModules':b['map'](q=>q['id']),'businessIntent':a};}function calculateModuleScoreBoost(a){const b={};for(const c of a){for(const d of c['evaluationImpact']){const e=d['effect']==='required'?0xf:d['effect']==='boost'?0x8:0x3;b[d['dimension']]=(b[d['dimension']]??0x0)+e;}}return b;}export function validateGraph(a){const b=[],c=[],d=[];for(const e of a['constraints']){if(e['id']==='service_permission_bound'){const f=a['nodes']['some'](h=>h['type']==='service'),g=a['edges']['some'](h=>h['relation']==='has_permission'&&h['from']['startsWith']('main_service'));f&&!g&&b['push'](e);}if(e['id']==='arbitration_permission_independent'){const h=a['nodes']['find'](j=>j['id']==='main_service'),i=a['nodes']['find'](j=>j['id']==='main_arbitration');if(h&&i){const j=a['edges']['find'](l=>l['from']==='main_service'&&l['relation']==='has_permission')?.['to'],k=a['edges']['find'](l=>l['from']==='main_arbitration'&&l['relation']==='has_permission')?.['to'];j&&k&&j===k&&b['push'](e);}}if(e['level']==='soft')c['push'](e);else e['level']==='info'&&d['push'](e);}return{'valid':b['length']===0x0,'hardViolations':b,'softViolations':c,'infoNotes':d};}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Config,LocalMark,LocalProject,query_serviceContext,query_object_last_updated,queryTableItem_ServiceOrders,query_affiliations,query_objects,objectTypeFromAddress,ObjectType}from'@wowok/wowok';import{generateBusinessReport}from'./reverse-mapping.js';import{resolveSupplyChainGraph}from'../knowledge/supply-chain.js';import{formatChainValue}from'../knowledge/fund-layer.js';import{buildMachineGraph}from'./machine-nodes.js';import{computeServiceTrustSummary}from'../tools/handlers/trust.js';function balanceStr(a){if(a===null||a===undefined)return null;if(typeof a==='bigint')return a['toString']();return String(a);}function 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'];}return null;}function requireField(a,b){if(a===undefined||a===null)throw new Error('\x27'+b+'\x27\x20is\x20required\x20for\x20this\x20action');return a;}function summarizeGuard(a){if(!a)return null;const b=a,c=Array['isArray'](b['table'])?b['table']:[],d=c['filter'](e=>e?.['b_submission']===!![])['length'];return{'address':b['object']??'','description':b['description']??null,'rep':typeof b['rep']==='boolean'?b['rep']:null,'table_entry_count':c['length'],'submission_slot_count':d,'relies':Array['isArray'](b['relies'])?b['relies']['filter'](e=>typeof e==='string'):[],'relies_logic_and':typeof b['relies_logic_and']==='boolean'?b['relies_logic_and']:null};}function summarizePermission(a,b){if(!a)return null;const c=a,d=Array['isArray'](c['admin'])?c['admin']:[],e=d[0x0],f=typeof e==='string'?e:typeof e?.['account']==='string'?e['account']:c['builder']??null;return{'address':c['object']??'','description':c['description']??null,'builder':c['builder']??null,'owner':f,'owner_name':b?.['name']??null,'admin_count':d['length'],'entity_count':typeof c['entity_count']==='number'?c['entity_count']:null,'perm_remark':Array['isArray'](c['perm_remark'])?c['perm_remark']['map'](g=>({'index':String(g?.['index']??''),'remark':typeof g?.['remark']==='string'?g['remark']:''})):[],'um':c['um']??null,'tags':b?.['tags']??[],'updated_timestamp_ms':b?.['updated_at_ms']!=null?String(b['updated_at_ms']):null};}async function markOf(a){if(!a)return{'name':null,'tags':[],'updated_at_ms':null};try{const b=await LocalMark['Instance']()['get'](a);if(b)return{'name':b['name']??null,'tags':Array['isArray'](b['tags'])?b['tags']:[],'updated_at_ms':typeof b['updatedAt']==='number'?b['updatedAt']:null};}catch{}try{const c=await LocalMark['Instance']()['list']({'address':a}),d=c?.[0x0];if(d)return{'name':d['name']??null,'tags':Array['isArray'](d['tags'])?d['tags']:[],'updated_at_ms':typeof d['updatedAt']==='number'?d['updatedAt']:null};}catch{}return{'name':null,'tags':[],'updated_at_ms':null};}async function markOfMany(a){const b=[...new Set(a['filter'](e=>!!e))],c=await Promise['all'](b['map'](e=>markOf(e))),d=new Map();for(let e=0x0;e<b['length'];e++)d['set'](b[e],c[e]);return d;}export async function handleServicePanorama(b){const c=requireField(b['service_address'],'service_address'),d=b['context_network']??b['project_network']??undefined;let f=d??await Config['Instance']()['network_get']();const h=[];let j=c;if(!/^0x[0-9a-fA-F]{32,64}$/['test'](c)){const S=await LocalMark['Instance']()['get_address'](c);if(!S)throw new Error('Cannot\x20resolve\x20service\x20\x27'+c+'\x27\x20—\x20not\x20a\x20valid\x20address\x20and\x20no\x20LocalMark\x20entry\x20found.\x20'+'Pass\x20the\x200x\x20Service\x20object\x20address\x20directly\x20or\x20register\x20the\x20name\x20via\x20local_mark_operation.');j=S;}let k=await query_serviceContext({'service':j,'include_machine_nodes':!![],'network':f});if(!k?.['service']&&d){const T=await Config['Instance']()['network_get']();T&&T!==f&&(f=T,k=await query_serviceContext({'service':j,'include_machine_nodes':!![],'network':f}));}const l=k['service'];j=l['object']??j;const m=new Set(),n=U=>{if(U)m['add'](U);};n(j),n(l['machine']),n(l['permission']),n(l['um']);for(const U of l['arbitrations']??[])n(U);for(const V of l['rewards']??[])n(V);for(const W of l['repositories']??[])n(W);const p=k['permission'];if(p){const X=Array['isArray'](p['admin'])?p['admin']:[];X[0x0]&&n(typeof X[0x0]==='string'?X[0x0]:X[0x0]?.['account']);if(p['builder'])n(p['builder']);}const q=await markOfMany([...m]),u=q['get'](j)??{'name':null,'tags':[],'updated_at_ms':null},w=u['name'],x=Y=>Y?q['get'](Y)??{'name':null,'tags':[],'updated_at_ms':null}:{'name':null,'tags':[],'updated_at_ms':null};let y=null;const z=k['machine'],A=k['machine_nodes']??[];if(z||A['length']>0x0){const {nodes:Y,edges:Z}=buildMachineGraph(A);y={'address':z?.['object']??l['machine']??'','name':x(z?.['object']??l['machine'])['name'],'description':z?.['description']??null,'published':typeof z?.['bPublished']==='boolean'?z['bPublished']:null,'paused':typeof z?.['bPaused']==='boolean'?z['bPaused']:null,'node_count':typeof z?.['node_count']==='number'?z['node_count']:null,'consensus_repositories':Array['isArray'](z?.['consensus_repositories'])?z['consensus_repositories']:[],'nodes':Y,'edges':Z};}let B=null;try{const a0=await query_object_last_updated({'object':j,'network':f});a0?.['timestamp_ms']&&(B={'timestamp_ms':a0['timestamp_ms'],'digest':a0['digest']??null,'sender':a0['sender']??null});}catch{h['push']('onchain_last_updated:\x20query\x20failed\x20(non-blocking)');}let C=null;try{C=await computeServiceTrustSummary({'service':j,'depth':'evaluate','network':f});}catch{h['push']('trust:\x20evaluation\x20failed\x20(non-blocking)');}let D=null;try{D=await resolveSupplyChainGraph(j,f);}catch{h['push']('supply_chain:\x20resolution\x20failed\x20(non-blocking)');}let E=null;try{const a1=[l];for(const a2 of Object['values'](k['referenced']??{})){if(a2&&a2['object']!==j)a1['push'](a2);}E=generateBusinessReport({'objects':a1,'machine_nodes':A['map'](a3=>({'name':a3['name']}))});}catch{h['push']('business_report:\x20generation\x20failed\x20(non-blocking)');}const F=l?.['type_raw']??l?.['type']??'',G=F['match'](/<(.+)>$/),H=G?G[0x1]:null,I=async a3=>{if(a3===null||a3===undefined||a3==='')return{'display':'','tip':''};if(!H)return{'display':a3,'tip':''};try{const a4=await formatChainValue(a3,H,f);if(a4['precision_known'])return{'display':a4['symbol']?a4['display']+'\x20'+a4['symbol']:a4['display'],'tip':a4['text']};return{'display':a3,'tip':''};}catch{return{'display':a3,'tip':''};}};let J=null;try{const a3=await queryTableItem_ServiceOrders({'address':j,'no_cache':!![],'network':f}),a4=Array['isArray'](a3?.['items'])?a3['items']:[],a5=a4['map'](ac=>typeof ac?.['who']==='string'?ac['who']:'')['filter'](ac=>ac!==''),a6=new Map();try{if(a5['length']>0x0){const ac=await query_objects({'objects':a5,'network':f});for(const ad of ac?.['objects']??[]){ad&&ad['type']===ObjectType['Order']&&a6['set'](ad['object'],ad);}}}catch{h['push']('recent_orders:\x20order\x20details\x20unavailable\x20(non-blocking)');}const a7=new Map(),a8=new Map(),a9=new Map();try{const ae=new Set();for(const af of a6['values']()){if(af?.['progress'])ae['add'](af['progress']);if(af?.['allocation'])ae['add'](af['allocation']);}if(ae['size']>0x0){const ag=await query_objects({'objects':Array['from'](ae),'network':f});for(const ah of ag?.['objects']??[]){if(!ah?.['object'])continue;if(ah['type']===ObjectType['Progress']){const ai=ah?.['current'];a7['set'](ah['object'],typeof ai==='string'&&ai!==''?ai:null),a8['set'](ah['object'],Number(ah?.['current_time'])||null);}else{if(ah['type']===ObjectType['Allocation']){const aj=Number(ah?.['balance']??0x0);a9['set'](ah['object'],Number['isFinite'](aj)&&aj===0x0?'allocated':'pending');}}}}}catch{h['push']('recent_orders:\x20progress/allocation\x20details\x20unavailable\x20(non-blocking)');}const aa=new Map();try{const ak=Array['from'](new Set(a4['map'](am=>typeof am?.['who']==='string'?am['who']:'')['filter'](Boolean))),al=await Promise['allSettled'](ak['map'](am=>query_object_last_updated({'object':am,'network':f})));for(let am=0x0;am<ak['length'];am++){const an=al[am];aa['set'](ak[am],an['status']==='fulfilled'&&an['value']?.['timestamp_ms']?Number(an['value']['timestamp_ms'])||null:null);}}catch{h['push']('recent_orders:\x20order\x20updated\x20times\x20unavailable\x20(non-blocking)');}const ab=await Promise['all'](a4['map'](async ao=>{const ap=typeof ao?.['who']==='string'?ao['who']:'',aq=a6['get'](ap),ar=aq?.['amount']!==null&&aq?.['amount']!==undefined?String(aq['amount']):'',as=await I(ar);return{'order':ap,'time':typeof ao?.['time']==='number'?ao['time']:0x0,'updated_ms':aa['get'](ap)??null,'amount':ar,'amount_display':as['display'],'amount_tip':as['tip'],'progress':aq?.['progress']??null,'allocation':aq?.['allocation']??null,'disputes':Array['isArray'](aq?.['dispute'])?aq['dispute']:[],'agent':Array['isArray'](aq?.['agent'])?aq['agent']:[],'owner':ownerAddr(aq?.['builder']??aq?.['owner']),'claimed_by':aq?.['claimed_by']??null,'required_info':aq?.['required_info']??null,'progress_next':aq?.['progress']?a7['get'](aq['progress'])??null:null,'progress_since':aq?.['progress']?a8['get'](aq['progress'])??null:null,'allocation_state':aq?.['allocation']?a9['get'](aq['allocation'])??'pending':'none','bought':await Promise['all']((Array['isArray'](aq?.['items'])?aq['items']:[])['map'](async at=>({'name':String(at?.['name']??''),'price_display':(await I(at?.['price']!==null&&at?.['price']!==undefined?String(at['price']):'0'))['display'],'quantity':String(at?.['quantity']??'0'),'wip_hash':String(at?.['wip_hash']??'')})))};}));J={'count':a4['length'],'items':ab['filter'](ao=>ao['order']!=='')['slice'](-0x14)['reverse']()};}catch{h['push']('recent_orders:\x20reverse-index\x20query\x20failed\x20(non-blocking)');}const K=[];try{const ao=await query_affiliations({'address':j,'no_cache':!![],'network':f}),ap=new Set(),aq=new Map();for(const as of ao?.['entries']??[]){const at=typeof as?.['who']==='string'?as['who']:'';if(!at||ap['has'](at))continue;ap['add'](at);if(objectTypeFromAddress(at)===ObjectType['Order'])continue;const au=objectTypeFromAddress(at),av=au?String(au):'Unknown';let aw=aq['get'](av);!aw&&(aw=[],aq['set'](av,aw)),aw['push']({'address':at,'type_label':av,'name':x(at)['name'],'time':typeof as?.['time']==='number'?as['time']:null});}const ar=['Progress','Allocation','Payment','Guard'];for(const ax of ar){const ay=aq['get'](ax);ay&&ay['length']>0x0&&(K['push']({'type_label':ax,'items':ay}),aq['delete'](ax));}for(const [az,aA]of aq){if(aA['length']>0x0)K['push']({'type_label':az,'items':aA});}}catch{h['push']('related:\x20global-table\x20lookup\x20failed\x20(non-blocking)');}const L=[];for(const aB of k['allocator_guards']??[]){const aC=summarizeGuard(aB);if(aC)L['push'](aC);}let M=null;try{const aD=j['toLowerCase'](),aE=await LocalProject['Instance']()['listProjects'](),aF=aE['filter'](aH=>(aH['serviceAddress']??'')['toLowerCase']()===aD),aG=aF['find'](aH=>aH['network']===f)??aF[0x0]??null;if(aG){const [aH,aI,aJ]=await Promise['all']([LocalProject['Instance']()['listObjects'](aG['id']),LocalProject['Instance']()['listEvaluations'](aG['id']),LocalProject['Instance']()['listVersions'](aG['id'])]);M={'id':aG['id'],'prefix':aG['prefix'],'name':aG['name'],'status':aG['status'],'perspective':aG['perspective'],'network':aG['network'],'currentVersion':aG['currentVersion']??null,'objectCount':aH['length'],'versionCount':aJ['length'],'evaluationCount':aI['length'],'evaluations':aI};}}catch{h['push']('linked_project:\x20local\x20lookup\x20failed\x20(non-blocking)');}const N=[];for(const aK of Array['isArray'](l['sales'])?l['sales']:[]){const aL=balanceStr(aK?.['price']),aM=await I(aL);N['push']({'name':typeof aK?.['name']==='string'?aK['name']:'','price':aL,'price_display':aM['display'],'price_tip':aM['tip'],'stock':balanceStr(aK?.['stock']),'suspension':aK?.['suspension']===!![],'wip':typeof aK?.['wip']==='string'?aK['wip']:'','wip_hash':typeof aK?.['wip_hash']==='string'?aK['wip_hash']:''});}const O=l['order_allocators']?{'description':l['order_allocators']['description']??'','threshold':balanceStr(l['order_allocators']['threshold']),'allocators':(l['order_allocators']['allocators']??[])['map'](aN=>({'guard':aN['guard'],'sharing_count':Array['isArray'](aN['sharing'])?aN['sharing']['length']:0x0,'max':balanceStr(aN['max']??null)}))}:null,P=summarizePermission(k['permission'],x(l['permission'])),Q=P?.['owner']??B?.['sender']??null,R=Q?await markOf(Q):null;return{'action':'service_panorama','network':f,'service':{'address':j,'name':w,'description':l['description']??'','location':l['location']??'','published':l['bPublished']===!![],'paused':l['bPaused']===!![],'paused_time':typeof l['paused_time']==='number'?l['paused_time']:null,'setting_lock_duration':balanceStr(l['setting_lock_duration']),'customer_required':Array['isArray'](l['customer_required'])?l['customer_required']:[],'compensation_fund':balanceStr(l['compensation_fund']),'sales':N,'machine':l['machine']??null,'buy_guard':l['buy_guard']??null,'permission':l['permission']??'','um':l['um']??null,'arbitrations':Array['isArray'](l['arbitrations'])?l['arbitrations']:[],'rewards':Array['isArray'](l['rewards'])?l['rewards']:[],'repositories':Array['isArray'](l['repositories'])?l['repositories']:[],'order_allocators':O,'onchain_last_updated':B,'tags':u['tags']??[],'owner':Q,'owner_name':R?.['name']??null},'machine_graph':y,'buy_guard':summarizeGuard(k['buy_guard']),'permission':P,'allocator_guards':L,'related':{'groups':K},'supply_chain':D,'trust':C,'business_report':E,'recent_orders':J,'linked_project':M,'data_gaps':h};}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { ProjectStage } from "./project-store.js";
|
|
2
|
-
export type GateDimension = "semantic" | "tools" | "reversibility" | "risk" | "isolation" | "gas_budget";
|
|
3
|
-
export interface GasBudgetCheck {
|
|
4
|
-
network: "testnet" | "mainnet";
|
|
5
|
-
already_spent_gas: number;
|
|
6
|
-
estimated_rerun_gas: number;
|
|
7
|
-
warning?: string;
|
|
8
|
-
}
|
|
9
|
-
export interface StageGateCheck {
|
|
10
|
-
dimension: GateDimension;
|
|
11
|
-
status: "PASS" | "FAIL" | "WARN";
|
|
12
|
-
message: string;
|
|
13
|
-
}
|
|
14
|
-
export interface StageGateInput {
|
|
15
|
-
stage: ProjectStage;
|
|
16
|
-
prefix: string;
|
|
17
|
-
version: string;
|
|
18
|
-
naming?: {
|
|
19
|
-
prefix_valid: boolean;
|
|
20
|
-
version_valid: boolean;
|
|
21
|
-
};
|
|
22
|
-
puzzles?: Record<string, unknown>;
|
|
23
|
-
puzzles_completeness?: "complete" | "partial" | "empty";
|
|
24
|
-
risk_status?: string;
|
|
25
|
-
risk_can_proceed?: boolean;
|
|
26
|
-
doc_error_count?: number;
|
|
27
|
-
objects?: Array<{
|
|
28
|
-
entry_id: string;
|
|
29
|
-
object_type?: string;
|
|
30
|
-
reused_from?: string;
|
|
31
|
-
}>;
|
|
32
|
-
edges?: Array<{
|
|
33
|
-
from: string;
|
|
34
|
-
to: string;
|
|
35
|
-
}>;
|
|
36
|
-
trace_coherent?: boolean;
|
|
37
|
-
has_published_object?: boolean;
|
|
38
|
-
evaluation_score?: number;
|
|
39
|
-
deployment_doc_generated?: boolean;
|
|
40
|
-
gas_budget?: GasBudgetCheck;
|
|
41
|
-
}
|
|
42
|
-
export interface StageGateResult {
|
|
43
|
-
stage: ProjectStage;
|
|
44
|
-
passed: boolean;
|
|
45
|
-
checks: StageGateCheck[];
|
|
46
|
-
blocking_issues: string[];
|
|
47
|
-
warnings: string[];
|
|
48
|
-
can_proceed: boolean;
|
|
49
|
-
}
|
|
50
|
-
export declare const STAGE5_RISK_SCORE_BLOCK = 50;
|
|
51
|
-
export declare const STAGE5_RISK_SCORE_WARN = 80;
|
|
52
|
-
export declare function validateStageGate(input: StageGateInput): StageGateResult;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const STAGE5_RISK_SCORE_BLOCK=0x32;export const STAGE5_RISK_SCORE_WARN=0x50;function buildStage5ScoreCheck(a){if(a['evaluation_score']!==undefined&&a['evaluation_score']!==null){const c=a['evaluation_score'];if(c<STAGE5_RISK_SCORE_BLOCK)return{'dimension':'risk','status':'FAIL','message':'Stage\x203\x20evaluation\x20score\x20'+c+'\x20<\x20'+STAGE5_RISK_SCORE_BLOCK+'\x20(block\x20threshold).\x20'+'GLM6\x20handoff\x20validation:\x20deployment\x20blocked\x20—\x20too\x20many\x20CRITICAL\x20risks\x20unresolved.\x20'+'Fix\x20risks\x20in\x20Stage\x203\x20(aggregate_risks)\x20before\x20deploying.'};if(c<STAGE5_RISK_SCORE_WARN)return{'dimension':'risk','status':'WARN','message':'Stage\x203\x20evaluation\x20score\x20'+c+'\x20<\x20'+STAGE5_RISK_SCORE_WARN+'\x20(warn\x20threshold).\x20'+'GLM6\x20handoff\x20validation:\x20non-blocking\x20—\x20proceed\x20at\x20your\x20own\x20risk.\x20'+'Recommend\x20improving\x20risk\x20posture\x20before\x20deploying\x20to\x20mainnet.'};return{'dimension':'risk','status':'PASS','message':'Stage\x203\x20evaluation\x20score\x20'+c+'\x20>=\x20'+STAGE5_RISK_SCORE_WARN+'\x20—\x20safe\x20to\x20deploy'};}const b=a['risk_status']==='RISK_PASSED';return{'dimension':'risk','status':b?'PASS':'WARN','message':b?'Risk\x20status\x20is\x20RISK_PASSED':'Risk\x20status\x20is\x20'+(a['risk_status']??'unknown')+'\x20—\x20recommend\x20resolving\x20before\x20deployment'};}function buildStage5DocCheck(a){if(a['deployment_doc_generated']!==!![])return{'dimension':'semantic','status':'FAIL','message':'GLM6\x20handoff\x20validation:\x20Stage\x204\x20deployment\x20doc\x20not\x20generated.\x20'+'Call\x20generate_deployment_doc\x20(Stage\x204)\x20before\x20executing\x20deployment\x20(Stage\x205).'};const b=a['doc_error_count']??0x0;if(b>0x0)return{'dimension':'semantic','status':'FAIL','message':'GLM6\x20handoff\x20validation:\x20Stage\x204\x20deployment\x20doc\x20has\x20'+b+'\x20D-error(s).\x20'+'Fix\x20all\x20D-errors\x20before\x20executing\x20deployment.'};return{'dimension':'semantic','status':'PASS','message':'Stage\x204\x20deployment\x20doc\x20generated\x20with\x200\x20D-errors'};}function buildGasBudgetCheck(a){const b=a['gas_budget'];if(!b)return{'dimension':'gas_budget','status':'PASS','message':'Gas\x20budget\x20not\x20provided\x20(N/A\x20for\x20this\x20stage\x20or\x20caller\x20omitted)'};if(b['network']==='testnet')return{'dimension':'gas_budget','status':'PASS','message':'testnet:\x20no\x20gas\x20limit\x20(faucet\x20is\x20free);\x20rollback\x20is\x20costless'};const c=b['already_spent_gas']+b['estimated_rerun_gas'],d=b['warning']??'mainnet:\x20estimated\x20total\x20gas\x20'+c+'\x20MIST\x20(already_spent='+b['already_spent_gas']+'\x20+\x20rerun='+b['estimated_rerun_gas']+').\x20Rollback\x20will\x20incur\x20real\x20cost.';return{'dimension':'gas_budget','status':'WARN','message':d};}function validateStage1Gate(a){const b=[],c=a['naming']?.['prefix_valid']&&a['naming']?.['version_valid'];return b['push']({'dimension':'semantic','status':c?'PASS':'FAIL','message':c?'Project\x20namespace\x20is\x20valid\x20(prefix\x20+\x20version)':'Project\x20naming\x20is\x20invalid\x20—\x20prefix\x20must\x20match\x20^[a-z][a-z0-9_]{2,63}$\x20and\x20version\x20must\x20match\x20^v\x5cd+$'}),b['push']({'dimension':'tools','status':'PASS','message':'Stage\x201\x20requires\x20no\x20on-chain\x20tools\x20(namespace\x20is\x20local-only)'}),b['push']({'dimension':'reversibility','status':'PASS','message':'Stage\x201\x20is\x20fully\x20reversible\x20(no\x20on-chain\x20state\x20changes)'}),b['push']({'dimension':'risk','status':'PASS','message':'No\x20risks\x20at\x20namespace\x20stage'}),b['push']({'dimension':'isolation','status':'PASS','message':'Stage\x201\x20has\x20no\x20objects\x20(isolation\x20N/A)'}),b['push'](buildGasBudgetCheck(a)),b;}function validateStage2Gate(a){const b=[],c=a['puzzles']&&Object['keys'](a['puzzles'])['length']>0x0,d=a['puzzles_completeness']??'empty';b['push']({'dimension':'semantic','status':c?d==='complete'?'PASS':d==='partial'?'WARN':'FAIL':'FAIL','message':c?'Puzzles\x20present\x20with\x20completeness:\x20'+d:'No\x20puzzles\x20found\x20—\x20call\x20analyze_intent\x20first'});if(c){const e=Object['keys'](a['puzzles']);b['push']({'dimension':'tools','status':'PASS','message':e['length']+'\x20object\x20type(s)\x20defined:\x20'+e['join'](',\x20')});}else b['push']({'dimension':'tools','status':'FAIL','message':'Cannot\x20verify\x20tools\x20—\x20no\x20puzzles\x20available'});b['push']({'dimension':'reversibility','status':'PASS','message':'Stage\x202\x20is\x20in-memory\x20only\x20(no\x20on-chain\x20state\x20changes)'}),b['push']({'dimension':'risk','status':'PASS','message':'Risk\x20assessment\x20happens\x20in\x20stage\x203\x20(aggregate_risks)'});if(a['objects']&&a['objects']['length']>0x0){const f=a['objects']['filter'](g=>g['reused_from']&&g['reused_from']['includes'](':')&&!g['reused_from']['startsWith']('0x'));b['push']({'dimension':'isolation','status':f['length']===0x0?'PASS':'FAIL','message':f['length']===0x0?'No\x20cross-project\x20object\x20references\x20detected':f['length']+'\x20object(s)\x20reference\x20external\x20projects\x20(§3.0\x20violation):\x20'+f['map'](g=>g['entry_id'])['join'](',\x20')});}else b['push']({'dimension':'isolation','status':'PASS','message':'No\x20objects\x20to\x20check\x20for\x20isolation\x20(stage\x202)'});return b['push'](buildGasBudgetCheck(a)),b;}function validateStage3Gate(a){const b=[],c=a['risk_status']!==undefined&&a['risk_status']!=='';b['push']({'dimension':'semantic','status':c?'PASS':'FAIL','message':c?'Risk\x20status:\x20'+a['risk_status']:'No\x20risk\x20assessment\x20found\x20—\x20call\x20aggregate_risks\x20first'}),b['push']({'dimension':'tools','status':'PASS','message':'Risk\x20assessment\x20uses\x20puzzles\x20from\x20stage\x202\x20(no\x20additional\x20tools)'}),b['push']({'dimension':'reversibility','status':'PASS','message':'Stage\x203\x20is\x20reversible\x20(re-run\x20aggregate_risks\x20to\x20update)'});const d=a['risk_can_proceed']===!![];return b['push']({'dimension':'risk','status':d?'PASS':'FAIL','message':d?'All\x20CRITICAL\x20risks\x20resolved\x20—\x20may\x20proceed':'CRITICAL\x20risks\x20remain\x20—\x20fix\x20before\x20proceeding\x20(non-blocking\x20principle:\x20only\x20CRITICAL\x20blocks)'}),b['push']({'dimension':'isolation','status':'PASS','message':'Isolation\x20verified\x20in\x20stage\x202'}),b['push'](buildGasBudgetCheck(a)),b;}function validateStage4Gate(a){const b=[],c=a['doc_error_count']??-0x1;b['push']({'dimension':'semantic','status':c===0x0?'PASS':c>0x0?'FAIL':'WARN','message':c===0x0?'Deployment\x20doc\x20generated\x20with\x200\x20D-errors':c>0x0?c+'\x20D-error(s)\x20remain\x20—\x20fix\x20before\x20proceeding':'Doc\x20error\x20count\x20unknown\x20—\x20call\x20generate_deployment_doc\x20first'});if(a['objects']&&a['edges']){const e=new Set(a['objects']['map'](g=>g['entry_id'])),f=a['edges']['filter'](g=>!e['has'](g['from'])||!e['has'](g['to']));b['push']({'dimension':'tools','status':f['length']===0x0?'PASS':'FAIL','message':f['length']===0x0?'All\x20'+a['edges']['length']+'\x20edge(s)\x20reference\x20defined\x20objects':f['length']+'\x20edge(s)\x20reference\x20undefined\x20objects'});}else b['push']({'dimension':'tools','status':'WARN','message':'Objects/edges\x20not\x20provided\x20—\x20cannot\x20verify\x20tool\x20availability'});b['push']({'dimension':'reversibility','status':'PASS','message':'Stage\x204\x20is\x20reversible\x20(regenerate\x20deployment\x20doc)'});const d=a['risk_status']==='RISK_PASSED';b['push']({'dimension':'risk','status':d?'PASS':'WARN','message':d?'Risk\x20status\x20is\x20RISK_PASSED':'Risk\x20status\x20is\x20'+(a['risk_status']??'unknown')+'\x20—\x20recommend\x20resolving\x20before\x20deployment'});if(a['objects']&&a['objects']['length']>0x0){const g=a['objects']['filter'](h=>h['reused_from']&&!h['reused_from']['startsWith']('0x')&&h['reused_from']['includes'](':'));b['push']({'dimension':'isolation','status':g['length']===0x0?'PASS':'FAIL','message':g['length']===0x0?'No\x20cross-project\x20references\x20in\x20deployment\x20objects':g['length']+'\x20object(s)\x20have\x20cross-project\x20reused_from\x20(§3.0\x20violation)'});}else b['push']({'dimension':'isolation','status':'PASS','message':'No\x20objects\x20to\x20check\x20for\x20isolation\x20(stage\x204)'});return b['push'](buildGasBudgetCheck(a)),b;}function validateStage5Gate(a){const b=[];b['push'](buildStage5DocCheck(a));const c=a['trace_coherent']===!![];b['push']({'dimension':'semantic','status':c?'PASS':'FAIL','message':c?'Substeps\x20are\x20coherent\x20(no\x20dangling/circular/missing)':'Substeps\x20are\x20not\x20coherent\x20—\x20call\x20trace_substeps\x20and\x20fix\x20issues'}),b['push']({'dimension':'tools','status':c?'PASS':'FAIL','message':c?'All\x20substep\x20dependencies\x20resolve':'Substep\x20dependencies\x20have\x20issues\x20(see\x20trace_substeps\x20output)'});const d=a['has_published_object']===!![];return b['push']({'dimension':'reversibility','status':d?'WARN':'PASS','message':d?'Objects\x20have\x20been\x20published\x20on-chain\x20—\x20rollback\x20requires\x20fork\x20(§3.3).\x20'+'Ensure\x20all\x20substeps\x20are\x20correct\x20before\x20executing\x20on\x20mainnet.':'No\x20objects\x20published\x20yet\x20—\x20stage\x205\x20is\x20still\x20reversible'}),b['push'](buildStage5ScoreCheck(a)),b['push']({'dimension':'isolation','status':'PASS','message':'Isolation\x20verified\x20in\x20stages\x202\x20and\x204'}),b['push'](buildGasBudgetCheck(a)),b;}const STAGE_VALIDATORS={0x1:validateStage1Gate,0x2:validateStage2Gate,0x3:validateStage3Gate,0x4:validateStage4Gate,0x5:validateStage5Gate};export function validateStageGate(a){const b=STAGE_VALIDATORS[a['stage']],c=b(a),d=c['filter'](f=>f['status']==='FAIL')['map'](f=>'['+f['dimension']+']\x20'+f['message']),e=c['filter'](f=>f['status']==='WARN')['map'](f=>'['+f['dimension']+']\x20'+f['message']);return{'stage':a['stage'],'passed':d['length']===0x0,'checks':c,'blocking_issues':d,'warnings':e,'can_proceed':d['length']===0x0};}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export type TaskStatus = "pending" | "running" | "completed" | "failed" | "cancelled";
|
|
2
|
-
export interface TaskState {
|
|
3
|
-
task_id: string;
|
|
4
|
-
operation: string;
|
|
5
|
-
status: TaskStatus;
|
|
6
|
-
progress: number;
|
|
7
|
-
message: string;
|
|
8
|
-
result: unknown;
|
|
9
|
-
error: string | null;
|
|
10
|
-
started_at: number;
|
|
11
|
-
completed_at: number | null;
|
|
12
|
-
project_id: string | null;
|
|
13
|
-
}
|
|
14
|
-
declare class TaskTrackerImpl {
|
|
15
|
-
private tasks;
|
|
16
|
-
private counter;
|
|
17
|
-
create(operation: string, projectId?: string): string;
|
|
18
|
-
update(task_id: string, progress: number, message?: string): void;
|
|
19
|
-
complete(task_id: string, result: unknown): void;
|
|
20
|
-
fail(task_id: string, error: string): void;
|
|
21
|
-
get(task_id: string): TaskState | undefined;
|
|
22
|
-
list(projectId?: string): TaskState[];
|
|
23
|
-
private persist;
|
|
24
|
-
private loadFromDisk;
|
|
25
|
-
private listFromDisk;
|
|
26
|
-
private evictExpired;
|
|
27
|
-
private deleteFromDisk;
|
|
28
|
-
}
|
|
29
|
-
export declare const TaskTracker: TaskTrackerImpl;
|
|
30
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{existsSync,mkdirSync,readFileSync,writeFileSync,readdirSync,unlinkSync}from'fs';import{join}from'path';import{getWowMcpDir}from'@wowok/wowok';const RETENTION_MS=0x5*0x3c*0x3e8,MAX_TASKS=0xc8,TASKS_ROOT=join(getWowMcpDir(),'tasks');function taskPath(a){return join(TASKS_ROOT,a+'.json');}function safeStringify(a){try{return JSON['stringify'](a);}catch{return JSON['stringify']({'__unserializable':!![]});}}class TaskTrackerImpl{['tasks']=new Map();['counter']=0x0;['create'](a,b){this['evictExpired'](),this['counter']++;const c='task_'+Date['now']()+'_'+this['counter'],d={'task_id':c,'operation':a,'status':'pending','progress':0x0,'message':'Task\x20created','result':null,'error':null,'started_at':Date['now'](),'completed_at':null,'project_id':b??null};return this['tasks']['set'](c,d),this['persist'](d),c;}['update'](a,b,c){const d=this['tasks']['get'](a);if(!d)return;d['progress']=Math['max'](0x0,Math['min'](0x64,b));if(c)d['message']=c;if(d['status']==='pending')d['status']='running';this['persist'](d);}['complete'](a,b){const c=this['tasks']['get'](a);if(!c)return;c['status']='completed',c['progress']=0x64,c['result']=b,c['completed_at']=Date['now'](),this['persist'](c);}['fail'](a,b){const c=this['tasks']['get'](a);if(!c)return;c['status']='failed',c['error']=b,c['completed_at']=Date['now'](),this['persist'](c);}['get'](a){const b=this['tasks']['get'](a);if(b)return b;return this['loadFromDisk'](a);}['list'](a){const b=new Map();for(const e of this['listFromDisk']())b['set'](e['task_id'],e);for(const f of this['tasks']['values']())b['set'](f['task_id'],f);const c=Array['from'](b['values']());if(a)return c['filter'](g=>g['project_id']===a);return c;}['persist'](a){try{if(!existsSync(TASKS_ROOT))mkdirSync(TASKS_ROOT,{'recursive':!![]});writeFileSync(taskPath(a['task_id']),safeStringify(a),'utf8');}catch{}}['loadFromDisk'](a){try{const b=taskPath(a);if(!existsSync(b))return undefined;return JSON['parse'](readFileSync(b,'utf8'));}catch{return undefined;}}['listFromDisk'](){try{if(!existsSync(TASKS_ROOT))return[];const a=[];for(const b of readdirSync(TASKS_ROOT)){if(!b['endsWith']('.json'))continue;try{const c=JSON['parse'](readFileSync(join(TASKS_ROOT,b),'utf8'));if(c?.['task_id'])a['push'](c);}catch{}}return a;}catch{return[];}}['evictExpired'](){const a=Date['now']();for(const [b,c]of this['tasks']){c['completed_at']&&a-c['completed_at']>RETENTION_MS&&(this['tasks']['delete'](b),this['deleteFromDisk'](b));}if(this['tasks']['size']>MAX_TASKS){const e=Array['from'](this['tasks']['values']())['filter'](g=>g['status']==='completed'||g['status']==='failed')['sort']((g,h)=>(g['completed_at']??0x0)-(h['completed_at']??0x0)),f=e['slice'](0x0,this['tasks']['size']-MAX_TASKS);for(const g of f){this['tasks']['delete'](g['task_id']),this['deleteFromDisk'](g['task_id']);}}for(const h of this['listFromDisk']()){h['completed_at']&&a-h['completed_at']>RETENTION_MS&&!this['tasks']['has'](h['task_id'])&&this['deleteFromDisk'](h['task_id']);}}['deleteFromDisk'](a){try{const b=taskPath(a);if(existsSync(b))unlinkSync(b);}catch{}}}export const TaskTracker=new TaskTrackerImpl();
|