@wowok/agent-mcp 2.7.7 → 2.7.10
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/customer/index.d.ts +3 -4
- package/dist/customer/index.js +1 -1
- package/dist/customer/info-puzzle.js +1 -1
- package/dist/customer/order-monitor.d.ts +0 -9
- package/dist/customer/order-monitor.js +1 -1
- package/dist/customer/order-strategy.d.ts +0 -19
- package/dist/customer/order-strategy.js +1 -1
- package/dist/customer/reminder-system.d.ts +0 -5
- package/dist/customer/reminder-system.js +1 -1
- package/dist/evaluation/game-strategy.js +1 -1
- package/dist/evaluation/injection.d.ts +6 -0
- package/dist/evaluation/injection.js +1 -0
- package/dist/evaluation/node-game.js +1 -1
- package/dist/examples/machine-multisig-threshold.json +1 -0
- 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 +1 -1
- package/dist/extensions/types.d.ts +1 -1
- package/dist/goal/GoalClassifier.d.ts +17 -0
- package/dist/goal/GoalClassifier.js +1 -0
- package/dist/goal/GoalEngine.d.ts +120 -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 +76 -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/recover.js +1 -1
- package/dist/harness/types.d.ts +1 -36
- package/dist/harness/verify.js +1 -1
- package/dist/index.js +1 -1
- package/dist/intent/enrich.js +1 -1
- package/dist/intent/matcher.js +1 -1
- package/dist/intent/types.d.ts +1 -1
- package/dist/intent/types.js +1 -1
- package/dist/knowledge/account-marks.d.ts +35 -0
- package/dist/knowledge/account-marks.js +1 -0
- package/dist/knowledge/arbitration-ledger.js +1 -1
- package/dist/knowledge/audit-rules.d.ts +3 -1
- package/dist/knowledge/audit-rules.js +1 -1
- package/dist/knowledge/contract-invariants.d.ts +53 -0
- package/dist/knowledge/contract-invariants.js +1 -0
- package/dist/knowledge/dynamic-pricing.d.ts +0 -2
- package/dist/knowledge/dynamic-pricing.js +1 -1
- package/dist/knowledge/event-semantics.d.ts +20 -0
- package/dist/knowledge/event-semantics.js +1 -0
- package/dist/knowledge/examples-scanner-cli.js +1 -1
- package/dist/knowledge/examples-scanner.js +1 -1
- package/dist/knowledge/glossary.js +1 -1
- package/dist/knowledge/goal-completion.d.ts +19 -0
- package/dist/knowledge/goal-completion.js +1 -0
- package/dist/knowledge/guard-submission-prompt.js +1 -1
- package/dist/knowledge/guard-translation.js +1 -1
- package/dist/knowledge/immutability.d.ts +11 -0
- package/dist/knowledge/immutability.js +1 -0
- package/dist/knowledge/index.d.ts +13 -6
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/intent-metrics.d.ts +1 -1
- package/dist/knowledge/jsonrpc-enum.d.ts +37 -0
- package/dist/knowledge/jsonrpc-enum.js +1 -0
- package/dist/knowledge/machine-confirm.js +1 -1
- package/dist/knowledge/machine-risk.js +1 -1
- package/dist/knowledge/machine-topology.d.ts +11 -0
- package/dist/knowledge/machine-topology.js +1 -1
- package/dist/knowledge/machine-translation.js +1 -1
- package/dist/knowledge/market-metrics.d.ts +11 -0
- package/dist/knowledge/market-metrics.js +1 -1
- package/dist/knowledge/mcp-schema-audit-cli.js +1 -1
- package/dist/knowledge/mcp-schema-audit.d.ts +1 -0
- package/dist/knowledge/mcp-schema-audit.js +1 -1
- package/dist/knowledge/messenger-guard-guidance.d.ts +17 -0
- package/dist/knowledge/messenger-guard-guidance.js +1 -0
- package/dist/knowledge/operation-dictionary.d.ts +18 -0
- package/dist/knowledge/operation-dictionary.js +1 -0
- 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/safety-rules.js +1 -1
- package/dist/knowledge/service-ledger.js +1 -1
- package/dist/knowledge/service-risk.js +1 -1
- package/dist/knowledge/service-translation.js +1 -1
- package/dist/knowledge/supply-chain.d.ts +24 -0
- package/dist/knowledge/supply-chain.js +1 -0
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/knowledge/trust-metrics.d.ts +27 -2
- package/dist/knowledge/trust-metrics.js +1 -1
- package/dist/knowledge/workflow-guidance.d.ts +22 -0
- package/dist/knowledge/workflow-guidance.js +1 -1
- package/dist/knowledge/workspace-lists.d.ts +56 -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 +98 -0
- package/dist/monitor/EventStore.js +1 -0
- package/dist/monitor/MonitorLoop.d.ts +79 -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/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/radar-core.d.ts +0 -1
- package/dist/participation/radar-core.js +1 -1
- package/dist/persona/address-format.d.ts +6 -0
- package/dist/persona/address-format.js +1 -0
- package/dist/persona/analyzer.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 +5 -0
- package/dist/persona/index.js +1 -1
- package/dist/persona/model.js +1 -1
- package/dist/persona/types.d.ts +1 -1
- package/dist/persona/types.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.d.ts +25 -0
- package/dist/playbooks/service-build/machine-nodes.js +1 -0
- package/dist/playbooks/service-build/machine-panorama.d.ts +43 -0
- package/dist/playbooks/service-build/machine-panorama.js +1 -0
- package/dist/{project → playbooks/service-build}/merchant-guide.d.ts +1 -1
- package/dist/playbooks/service-build/merchant-guide.js +1 -0
- package/dist/{project → playbooks/service-build}/mode-actions.d.ts +2 -2
- 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/playbooks/service-build/object-panorama.d.ts +178 -0
- package/dist/playbooks/service-build/object-panorama.js +1 -0
- package/dist/playbooks/service-build/object-type.d.ts +1 -0
- package/dist/playbooks/service-build/object-type.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/risk-aggregator.js +1 -0
- package/dist/{project → playbooks/service-build}/semantic-graph.d.ts +2 -2
- package/dist/playbooks/service-build/service-panorama.d.ts +164 -0
- package/dist/playbooks/service-build/service-panorama.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/role/derivation.d.ts +19 -2
- package/dist/role/derivation.js +1 -1
- package/dist/role/index.d.ts +2 -2
- package/dist/role/index.js +1 -1
- package/dist/role/model.js +1 -1
- package/dist/role/resolution.d.ts +16 -0
- package/dist/role/resolution.js +1 -1
- package/dist/role/types.d.ts +1 -1
- package/dist/role/types.js +1 -1
- 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 +2 -1
- package/dist/schema/call/arbitration.d.ts +5 -4
- package/dist/schema/call/arbitration.js +1 -1
- package/dist/schema/call/base.d.ts +17 -1
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +11 -4
- package/dist/schema/call/contact.d.ts +2 -1
- package/dist/schema/call/contact.js +1 -1
- package/dist/schema/call/demand.d.ts +2 -1
- package/dist/schema/call/demand.js +1 -1
- package/dist/schema/call/guard.d.ts +6 -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 +4 -2
- package/dist/schema/call/machine.js +1 -1
- package/dist/schema/call/order.d.ts +2 -1
- package/dist/schema/call/payment.d.ts +2 -1
- package/dist/schema/call/permission.d.ts +2 -1
- package/dist/schema/call/personal.d.ts +39 -1
- package/dist/schema/call/personal.js +1 -1
- package/dist/schema/call/progress.d.ts +2 -1
- package/dist/schema/call/proof.d.ts +4 -2
- package/dist/schema/call/repository.d.ts +6 -5
- package/dist/schema/call/repository.js +1 -1
- package/dist/schema/call/reward.d.ts +2 -13
- package/dist/schema/call/reward.js +1 -1
- package/dist/schema/call/semantic.d.ts +3 -2
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +2 -1
- package/dist/schema/call/service.js +1 -1
- package/dist/schema/call/treasury.d.ts +2 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/evaluation/index.d.ts +146 -0
- package/dist/schema/evaluation/index.js +1 -1
- package/dist/schema/goal/index.d.ts +317 -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 +2 -2
- package/dist/schema/index.js +1 -1
- package/dist/schema/industry-pack/index.d.ts +265 -1
- package/dist/schema/industry-pack/index.js +1 -1
- package/dist/schema/industry-pack/modes.d.ts +268 -0
- package/dist/schema/industry-pack/modes.js +1 -0
- package/dist/schema/intent-radar/index.d.ts +30 -3
- package/dist/schema/intent-radar/index.js +1 -1
- package/dist/schema/local/index.d.ts +9 -0
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/messenger/index.d.ts +54 -0
- package/dist/schema/messenger/index.js +1 -1
- package/dist/schema/operations.d.ts +1147 -94
- package/dist/schema/operations.js +1 -1
- package/dist/schema/permission/index.d.ts +18 -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 +783 -0
- package/dist/schema/query/bi.js +1 -0
- package/dist/schema/query/index.d.ts +1471 -208
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/trust/index.d.ts +17 -0
- package/dist/schema/trust/index.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/watch/index.d.ts +204 -0
- package/dist/schema/watch/index.js +1 -0
- package/dist/schema/workflow/index.d.ts +301 -0
- package/dist/schema/workflow/index.js +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +8 -5
- package/dist/schemas/account_operation.schema.json +2 -2
- package/dist/schemas/bridge_operation.output.json +7 -4
- package/dist/schemas/bridge_operation.schema.json +37 -21
- package/dist/schemas/config_operation.output.json +1 -1
- package/dist/schemas/config_operation.schema.json +1 -1
- package/dist/schemas/evaluation_operation.output.json +276 -1
- package/dist/schemas/evaluation_operation.schema.json +307 -0
- package/dist/schemas/goal_operation.schema.json +1016 -0
- package/dist/schemas/guard2file.schema.json +9 -5
- package/dist/schemas/index.json +22 -11
- package/dist/schemas/industry_pack_operation.output.json +898 -0
- package/dist/schemas/industry_pack_operation.schema.json +217 -2
- package/dist/schemas/intent_radar.output.json +20 -2
- package/dist/schemas/intent_radar.schema.json +10 -1
- package/dist/schemas/local_info_operation.output.json +7 -4
- package/dist/schemas/local_mark_operation.output.json +7 -4
- package/dist/schemas/machineNode2file.schema.json +9 -5
- package/dist/schemas/messenger_operation.output.json +107 -4
- package/dist/schemas/messenger_operation.schema.json +98 -0
- package/dist/schemas/monitor_events.output.json +1435 -0
- package/dist/schemas/monitor_events.schema.json +85 -0
- 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 +241 -18
- package/dist/schemas/onchain_events.schema.json +20 -0
- package/dist/schemas/onchain_operations.output.json +12 -7
- package/dist/schemas/onchain_operations.schema.json +570 -478
- package/dist/schemas/onchain_operations_allocation.schema.json +14 -10
- package/dist/schemas/onchain_operations_arbitration.schema.json +17 -12
- package/dist/schemas/onchain_operations_contact.schema.json +13 -9
- package/dist/schemas/onchain_operations_demand.schema.json +13 -9
- package/dist/schemas/onchain_operations_gen_passport.schema.json +9 -5
- package/dist/schemas/onchain_operations_gen_proof.schema.json +9 -5
- package/dist/schemas/onchain_operations_guard.schema.json +9 -5
- package/dist/schemas/onchain_operations_machine.schema.json +17 -13
- package/dist/schemas/onchain_operations_order.schema.json +12 -8
- package/dist/schemas/onchain_operations_payment.schema.json +10 -6
- package/dist/schemas/onchain_operations_permission.schema.json +12 -8
- package/dist/schemas/onchain_operations_personal.schema.json +47 -5
- package/dist/schemas/onchain_operations_progress.schema.json +12 -8
- package/dist/schemas/onchain_operations_proof.schema.json +9 -5
- package/dist/schemas/onchain_operations_repository.schema.json +295 -310
- package/dist/schemas/onchain_operations_reward.schema.json +17 -13
- package/dist/schemas/onchain_operations_service.schema.json +21 -17
- package/dist/schemas/onchain_operations_treasury.schema.json +17 -13
- package/dist/schemas/onchain_table_data.output.json +4125 -239
- package/dist/schemas/onchain_table_data.schema.json +326 -15
- package/dist/schemas/permission_operation.output.json +32 -0
- 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 +3384 -2040
- package/dist/schemas/query_toolkit.schema.json +548 -9
- package/dist/schemas/trust_score.output.json +38 -0
- package/dist/schemas/trust_score.schema.json +32 -0
- package/dist/schemas/watch_operation.output.json +827 -0
- package/dist/schemas/watch_operation.schema.json +145 -0
- package/dist/schemas/workflow_operation.output.json +263 -5
- package/dist/schemas/workflow_operation.schema.json +599 -4
- package/dist/task/ProcessStore.d.ts +81 -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 +120 -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/intent-radar.js +1 -1
- package/dist/tools/handlers/messenger.js +1 -1
- package/dist/tools/handlers/monitor.d.ts +26 -0
- package/dist/tools/handlers/monitor.js +1 -0
- 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/trust.d.ts +14 -0
- package/dist/tools/handlers/trust.js +1 -1
- package/dist/tools/handlers/watch.d.ts +2 -0
- package/dist/tools/handlers/watch.js +1 -0
- package/dist/tools/handlers/workflow.js +1 -1
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/index.js +1 -1
- package/dist/tools/shared.js +1 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +5 -4
- package/dist/customer/post-purchase.d.ts +0 -44
- package/dist/customer/post-purchase.js +0 -1
- 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/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 -540
- 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.d.ts +0 -2
- package/dist/project/machine-nodes.js +0 -1
- package/dist/project/merchant-guide.js +0 -1
- package/dist/project/migration.d.ts +0 -22
- package/dist/project/migration.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/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/rollback-policy.d.ts +0 -45
- package/dist/project/rollback-policy.js +0 -1
- package/dist/project/semantic-assembler.d.ts +0 -93
- package/dist/project/semantic-assembler.js +0 -1
- package/dist/project/stage-gate.d.ts +0 -53
- package/dist/project/stage-gate.js +0 -1
- package/dist/project/task-tracker.d.ts +0 -26
- package/dist/project/task-tracker.js +0 -1
- package/dist/schema/project/index.d.ts +0 -2015
- 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 -1133
- 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}/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}/semantic-graph.js +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 +1 @@
|
|
|
1
|
-
import{extractSignals}from'./intent-distill.js';const MAX_HISTORY=0xc8,history=[];export function recordSignature(a){try{history['push'](a),history['length']>MAX_HISTORY
|
|
1
|
+
import{extractSignals}from'./intent-distill.js';import{appendSignature,clearSignatures,loadSignatures,rewriteSignatures}from'./persistence.js';const MAX_HISTORY=0xc8,history=[];let hydrated=![];function ensureHydrated(){if(hydrated)return;hydrated=!![];try{for(const a of loadSignatures(MAX_HISTORY)){if(a&&typeof a['intent']==='string')history['push'](a);}}catch{}}export function recordSignature(a){try{ensureHydrated(),history['push'](a),history['length']>MAX_HISTORY?(history['shift'](),rewriteSignatures(history)):appendSignature(a);}catch{}}export function findMatches(a,b,c,d=0x3){try{ensureHydrated();const e=extractSignals(b,c),f=Date['now'](),g=history['map'](h=>{const i=computeRelevance(h,a,e,f);return{'signature':h,'relevance':i};})['filter'](h=>h['relevance']>0.3)['sort']((h,i)=>i['relevance']-h['relevance'])['slice'](0x0,d);return g['map'](h=>formatMatch(h['signature'],h['relevance']));}catch{return[];}}function computeRelevance(a,b,c,d){let e=0x0;if(a['intent']===b)e+=0.5;else a['intent']['startsWith'](b['split']('_')[0x0])&&(e+=0.2);const f=Object['keys'](a['signals']);if(f['length']>0x0){const i=f['filter'](j=>{const l=JSON['stringify'](a['signals'][j]),m=JSON['stringify'](c[j]);return l===m;})['length'];e+=i/f['length']*0.3;}const g=(d-a['timestamp'])/(0x3e8*0x3c*0x3c*0x18),h=Math['exp'](-g/0x1e);return e*=h,Math['min'](0x1,e);}function formatMatch(a,b){const c=buildAdvice(a),d=buildAvoid(a);return{'signature':a,'relevance':b,'advice':c,'avoid':d};}function buildAdvice(a){if(a['outcome']==='success'){if(a['recovery_path']&&a['recovery_path']['length']>0x0)return'Last\x20'+a['intent']+'\x20succeeded\x20(after\x20'+a['recovery_path']['length']+'\x20recovery\x20steps),\x20you\x20can\x20follow\x20the\x20same\x20path.';return'Last\x20'+a['intent']+'\x20succeeded,\x20parameter\x20configuration\x20is\x20valid.';}if(a['outcome']==='failed'&&a['error_code'])return'Last\x20'+a['intent']+'\x20failed\x20('+a['error_code']+'),\x20please\x20check\x20the\x20relevant\x20parameters.';return'Last\x20'+a['intent']+'\x20partially\x20succeeded,\x20check\x20result\x20completeness.';}function buildAvoid(a){const b=[];return a['outcome']!=='success'&&a['error_code']&&b['push']('Avoid\x20triggering\x20'+a['error_code']+'\x20error'),a['recovery_path']&&a['recovery_path']['length']>0x0&&b['push']('Note:\x20last\x20time\x20required\x20'+a['recovery_path']['length']+'\x20recovery\x20steps\x20to\x20succeed'),b;}export function getHistory(a){ensureHydrated();if(a)return history['filter'](b=>b['intent']===a);return[...history];}export function clearHistory(){ensureHydrated(),history['length']=0x0,clearSignatures();}export function getHistoryStats(){ensureHydrated();const a={},b={};for(const c of history){a[c['outcome']]=(a[c['outcome']]??0x0)+0x1,b[c['intent']]=(b[c['intent']]??0x0)+0x1;}return{'total':history['length'],'by_outcome':a,'by_intent':b};}
|
|
@@ -2,5 +2,6 @@ import { distillIntent, extractSignals } from "./intent-distill.js";
|
|
|
2
2
|
import { getProfile, updateFromOperation, resetProfile, getProfileStats } from "./user-profile.js";
|
|
3
3
|
import { findMatches, recordSignature, getHistory, clearHistory, getHistoryStats } from "./experience-reuse.js";
|
|
4
4
|
import { getExperienceFeedback, recordOperationOutcome, EXPERIENCE_LAYER_VERSION } from "./realtime-feedback.js";
|
|
5
|
+
import { configureExperiencePersistence } from "./persistence.js";
|
|
5
6
|
import type { DistilledIntent, ExperienceMatch, ExperienceFeedback, UserProfile, UserIntentSignature } from "./types.js";
|
|
6
|
-
export { distillIntent, extractSignals, getProfile, updateFromOperation, resetProfile, getProfileStats, findMatches, recordSignature, getHistory, clearHistory, getHistoryStats, getExperienceFeedback, recordOperationOutcome, EXPERIENCE_LAYER_VERSION, type DistilledIntent, type ExperienceMatch, type ExperienceFeedback, type UserProfile, type UserIntentSignature, };
|
|
7
|
+
export { distillIntent, extractSignals, getProfile, updateFromOperation, resetProfile, getProfileStats, findMatches, recordSignature, getHistory, clearHistory, getHistoryStats, getExperienceFeedback, recordOperationOutcome, configureExperiencePersistence, EXPERIENCE_LAYER_VERSION, type DistilledIntent, type ExperienceMatch, type ExperienceFeedback, type UserProfile, type UserIntentSignature, };
|
package/dist/experience/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{distillIntent,extractSignals}from'./intent-distill.js';import{getProfile,updateFromOperation,resetProfile,getProfileStats}from'./user-profile.js';import{findMatches,recordSignature,getHistory,clearHistory,getHistoryStats}from'./experience-reuse.js';import{getExperienceFeedback,recordOperationOutcome,EXPERIENCE_LAYER_VERSION}from'./realtime-feedback.js';export{distillIntent,extractSignals,getProfile,updateFromOperation,resetProfile,getProfileStats,findMatches,recordSignature,getHistory,clearHistory,getHistoryStats,getExperienceFeedback,recordOperationOutcome,EXPERIENCE_LAYER_VERSION};
|
|
1
|
+
import{distillIntent,extractSignals}from'./intent-distill.js';import{getProfile,updateFromOperation,resetProfile,getProfileStats}from'./user-profile.js';import{findMatches,recordSignature,getHistory,clearHistory,getHistoryStats}from'./experience-reuse.js';import{getExperienceFeedback,recordOperationOutcome,EXPERIENCE_LAYER_VERSION}from'./realtime-feedback.js';import{configureExperiencePersistence}from'./persistence.js';export{distillIntent,extractSignals,getProfile,updateFromOperation,resetProfile,getProfileStats,findMatches,recordSignature,getHistory,clearHistory,getHistoryStats,getExperienceFeedback,recordOperationOutcome,configureExperiencePersistence,EXPERIENCE_LAYER_VERSION};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let overrideDir,enabled=!![];export function configureExperiencePersistence(a={}){if(a['dir']!==undefined)overrideDir=a['dir'];if(a['enabled']!==undefined)enabled=a['enabled'];}export function persistenceOverrideDir(){return overrideDir;}export function persistenceEnabled(){return enabled;}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { BuyerSignals, UserIntentSignature, UserProfile } from "./types.js";
|
|
2
|
+
import { configureExperiencePersistence } from "./persistence-config.js";
|
|
3
|
+
export { configureExperiencePersistence };
|
|
4
|
+
export interface ProfileSnapshot {
|
|
5
|
+
profile: UserProfile;
|
|
6
|
+
buyer_signals: BuyerSignals;
|
|
7
|
+
counters: {
|
|
8
|
+
scenario_counts: [string, number][];
|
|
9
|
+
pitfall_counts: [string, number][];
|
|
10
|
+
object_refs: [string, number][];
|
|
11
|
+
success_count: number;
|
|
12
|
+
total_count: number;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export declare function experienceDir(): string;
|
|
16
|
+
export declare function loadSignatures(limit: number): UserIntentSignature[];
|
|
17
|
+
export declare function appendSignature(sig: UserIntentSignature): void;
|
|
18
|
+
export declare function clearSignatures(): void;
|
|
19
|
+
export declare function rewriteSignatures(sigs: UserIntentSignature[]): void;
|
|
20
|
+
export declare function loadProfileSnapshot(): ProfileSnapshot | undefined;
|
|
21
|
+
export declare function saveProfileSnapshot(snapshot: ProfileSnapshot): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{appendFileSync,existsSync,mkdirSync,readFileSync,renameSync,unlinkSync,writeFileSync}from'fs';import{join}from'path';import{getWowMcpDir}from'@wowok/wowok';import{configureExperiencePersistence,persistenceEnabled,persistenceOverrideDir}from'./persistence-config.js';export{configureExperiencePersistence};export function experienceDir(){return persistenceOverrideDir()??join(getWowMcpDir(),'experience');}function signaturesFile(){return join(experienceDir(),'signatures.jsonl');}function profileFile(){return join(experienceDir(),'profile.json');}function ensureDir(){mkdirSync(experienceDir(),{'recursive':!![]});}export function loadSignatures(a){if(!persistenceEnabled())return[];try{const b=signaturesFile();if(!existsSync(b))return[];const c=[];for(const d of readFileSync(b,'utf8')['split']('\x0a')){const e=d['trim']();if(!e)continue;try{c['push'](JSON['parse'](e));}catch{}}return c['slice'](-a);}catch{return[];}}export function appendSignature(a){if(!persistenceEnabled())return;try{ensureDir(),appendFileSync(signaturesFile(),JSON['stringify'](a)+'\x0a','utf8');}catch{}}export function clearSignatures(){if(!persistenceEnabled())return;try{const a=signaturesFile();if(existsSync(a))unlinkSync(a);}catch{}}export function rewriteSignatures(a){if(!persistenceEnabled())return;try{ensureDir();const b=signaturesFile(),c=b+'.tmp';writeFileSync(c,a['map'](d=>JSON['stringify'](d))['join']('\x0a')+(a['length']?'\x0a':''),'utf8'),renameSync(c,b);}catch{}}export function loadProfileSnapshot(){if(!persistenceEnabled())return undefined;try{const a=profileFile();if(!existsSync(a))return undefined;const b=JSON['parse'](readFileSync(a,'utf8'));if(!b||typeof b!=='object'||!b['profile']||!b['counters'])return undefined;return b;}catch{return undefined;}}export function saveProfileSnapshot(a){if(!persistenceEnabled())return;try{ensureDir();const b=profileFile(),c=b+'.tmp';writeFileSync(c,JSON['stringify'](a),'utf8'),renameSync(c,b);}catch{}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{distillIntent,extractSignals}from'./intent-distill.js';import{getProfile,updateFromOperation}from'./user-profile.js';import{findMatches,recordSignature}from'./experience-reuse.js';import{EXPERIENCE_LAYER_VERSION}from'./types.js';import{isEnabled as
|
|
1
|
+
import{distillIntent,extractSignals}from'./intent-distill.js';import{getProfile,updateFromOperation}from'./user-profile.js';import{findMatches,recordSignature}from'./experience-reuse.js';import{EXPERIENCE_LAYER_VERSION}from'./types.js';import{isEnabled as a39a}from'../config/index.js';import{recordIndustrySignal}from'../knowledge/flywheel-loop.js';export{EXPERIENCE_LAYER_VERSION};export function getExperienceFeedback(a,b,c){try{const d=distillIntent(a,b,c),e=findMatches(d['primary_intent'],a,b,0x3);if(e['length']===0x0)return undefined;const f=e[0x0],g=getProfile();return formatFeedback(f,e,d['scenario'],g);}catch{return undefined;}}export function recordOperationOutcome(a,b,c,d,e,f=[]){try{const g=distillIntent(a,b,c),h=extractSignals(a,b);recordSignature({'intent':g['primary_intent'],'scenario':g['scenario'],'signals':h,'timestamp':Date['now'](),'outcome':d,'error_code':e}),updateFromOperation(g['primary_intent'],g['scenario'],d,e,f);try{if(a39a('industry_evolution')){const i=typeof b?.['industry']==='string'&&b['industry']['trim']()?b['industry']['trim']():undefined;if(i){const j=d==='success'?{'success':!![]}:{'success':![],'error_code':e};recordIndustrySignal(i,{'type':a,'data':b},j);}}}catch{}}catch{}}function formatFeedback(a,b,c,d){const e=buildAdviceText(a,b,d),f=collectAvoidList(b,d),g=a['relevance'],h=c??a['signature']['scenario'],i={};if(e)i['advice']=e;if(f['length']>0x0)i['avoid']=f;if(g>0x0)i['relevance']=Math['round'](g*0x64)/0x64;if(h)i['matched_scenario']=h;return i;}function buildAdviceText(a,b,c){const d=[];if(a['signature']['outcome']==='success')d['push']('Historically,\x20'+a['signature']['intent']+'\x20operation\x20succeeded');else a['signature']['outcome']==='failed'&&d['push']('Historically,\x20'+a['signature']['intent']+'\x20operation\x20failed\x20('+(a['signature']['error_code']??'unknown\x20error')+'),\x20pay\x20special\x20attention\x20to\x20parameters');return c['expertise_tier']==='novice'&&b['length']>0x0&&d['push']('It\x20is\x20recommended\x20to\x20carefully\x20check\x20parameters\x20before\x20executing'),d['join'](';\x20')||a['advice'];}function collectAvoidList(b,c){const d=new Set();for(const e of b){for(const f of e['avoid']){d['add'](f);}}for(const g of c['frequent_pitfalls']){d['add']('You\x20often\x20make\x20mistakes\x20at\x20the\x20'+g+'\x20step,\x20please\x20be\x20especially\x20careful');}return Array['from'](d)['slice'](0x0,0x5);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
let currentProfile={'expertise_tier':'novice','preferred_industries':[],'risk_appetite':'balanced','frequent_pitfalls':[],'reused_objects':[],'preferred_confirmation':'standard','total_operations':0x0,'success_rate':0x1,'last_updated':0x0},buyerSignals={'purchase_count':0x0,'avg_purchase_price_ratio':0x1,'discount_usage_count':0x0,'referral_usage_count':0x0,'dispute_count':0x0},scenarioCounts=new Map(),pitfallCounts=new Map(),objectRefs=new Map(),successCount=0x0,totalCount=0x0;export function getProfile(){return{...currentProfile,'buyer_signals':{...buyerSignals}};}export function recordPurchaseOutcome(a){try{buyerSignals['purchase_count']++;if(a['used_discount'])buyerSignals['discount_usage_count']++;if(a['used_referral'])buyerSignals['referral_usage_count']++;if(a['has_dispute'])buyerSignals['dispute_count']++;if(a['avg_market_price']&&a['avg_market_price']>0x0n){const b=Number(a['price']*0x64n/a['avg_market_price'])/0x64,c=buyerSignals['avg_purchase_price_ratio'],d=buyerSignals['purchase_count'];buyerSignals['avg_purchase_price_ratio']=(c*(d-0x1)+b)/d;}recomputeBuyerInferences();}catch{}}function recomputeBuyerInferences(){const a=buyerSignals['purchase_count'];if(a>=0x3){const b=buyerSignals['avg_purchase_price_ratio'];if(b<0.9)buyerSignals['inferred_price_sensitivity']='high';else b>1.1?buyerSignals['inferred_price_sensitivity']='low':buyerSignals['inferred_price_sensitivity']='medium';}if(a>=0x2){const c=buyerSignals['discount_usage_count']+buyerSignals['referral_usage_count'],d=c/a;buyerSignals['inferred_bargain_hunting']=Math['min'](0x1,d);}}export function getBuyerSignals(){return{...buyerSignals};}export function updateFromOperation(a,b,c,d,e){try{totalCount++;if(c==='success')successCount++;b&&scenarioCounts['set'](b,(scenarioCounts['get'](b)??0x0)+0x1);c!=='success'&&d&&pitfallCounts['set'](d,(pitfallCounts['get'](d)??0x0)+0x1);for(const f of e){objectRefs['set'](f,(objectRefs['get'](f)??0x0)+0x1);}currentProfile=recomputeProfile();}catch{}}function recomputeProfile(){const a=totalCount,b=a>0x0?successCount/a:0x1;let c='novice';if(a>=0x32&&b>=0.9)c='expert';else{if(a>=0xa&&b>=0.7)c='advanced';}const d=Array['from'](scenarioCounts['entries']())['sort']((i,j)=>j[0x1]-i[0x1])['slice'](0x0,0x3)['map'](([i])=>i);let e='balanced';if(a>0x14&&b<0.6)e='aggressive';else{if(a>0x14&&b>0.95)e='conservative';}const f=Array['from'](pitfallCounts['entries']())['filter'](([,i])=>i>=0x2)['sort']((i,j)=>j[0x1]-i[0x1])['slice'](0x0,0x3)['map'](([i])=>i),g=Array['from'](objectRefs['entries']())['filter'](([,i])=>i>=0x2)['sort']((i,j)=>j[0x1]-i[0x1])['slice'](0x0,0x5)['map'](([i])=>i);let h='standard';if(c==='expert')h='minimal';else{if(c==='novice')h='verbose';}return{'expertise_tier':c,'preferred_industries':d,'risk_appetite':e,'frequent_pitfalls':f,'reused_objects':g,'preferred_confirmation':h,'total_operations':a,'success_rate':b,'last_updated':Date['now']()};}export function resetProfile(){currentProfile={'expertise_tier':'novice','preferred_industries':[],'risk_appetite':'balanced','frequent_pitfalls':[],'reused_objects':[],'preferred_confirmation':'verbose','total_operations':0x0,'success_rate':0x1,'last_updated':0x0},scenarioCounts=new Map(),pitfallCounts=new Map(),objectRefs=new Map(),successCount=0x0,totalCount=0x0,buyerSignals={'purchase_count':0x0,'avg_purchase_price_ratio':0x1,'discount_usage_count':0x0,'referral_usage_count':0x0,'dispute_count':0x0};}export function getProfileStats(){return{'total_operations':totalCount,'success_rate':totalCount>0x0?successCount/totalCount:0x1,'top_scenarios':Array['from'](scenarioCounts['entries']())['sort']((c,d)=>d[0x1]-c[0x1])['slice'](0x0,0x5)['map'](([a,b])=>({'scenario':a,'count':b})),'top_pitfalls':Array['from'](pitfallCounts['entries']())['sort']((c,d)=>d[0x1]-c[0x1])['slice'](0x0,0x5)['map'](([a,b])=>({'error_code':a,'count':b}))};}
|
|
1
|
+
import{loadProfileSnapshot,saveProfileSnapshot}from'./persistence.js';let currentProfile={'expertise_tier':'novice','preferred_industries':[],'risk_appetite':'balanced','frequent_pitfalls':[],'reused_objects':[],'preferred_confirmation':'standard','total_operations':0x0,'success_rate':0x1,'last_updated':0x0},buyerSignals={'purchase_count':0x0,'avg_purchase_price_ratio':0x1,'discount_usage_count':0x0,'referral_usage_count':0x0,'dispute_count':0x0},scenarioCounts=new Map(),pitfallCounts=new Map(),objectRefs=new Map(),successCount=0x0,totalCount=0x0,hydrated=![];function ensureHydrated(){if(hydrated)return;hydrated=!![];try{const a=loadProfileSnapshot();if(!a)return;currentProfile=a['profile'],buyerSignals=a['buyer_signals'],scenarioCounts=new Map(a['counters']['scenario_counts']),pitfallCounts=new Map(a['counters']['pitfall_counts']),objectRefs=new Map(a['counters']['object_refs']),successCount=a['counters']['success_count'],totalCount=a['counters']['total_count'];}catch{}}function persist(){try{const a={'profile':currentProfile,'buyer_signals':buyerSignals,'counters':{'scenario_counts':[...scenarioCounts['entries']()],'pitfall_counts':[...pitfallCounts['entries']()],'object_refs':[...objectRefs['entries']()],'success_count':successCount,'total_count':totalCount}};saveProfileSnapshot(a);}catch{}}export function getProfile(){return ensureHydrated(),{...currentProfile,'buyer_signals':{...buyerSignals}};}export function recordPurchaseOutcome(a){try{ensureHydrated(),buyerSignals['purchase_count']++;if(a['used_discount'])buyerSignals['discount_usage_count']++;if(a['used_referral'])buyerSignals['referral_usage_count']++;if(a['has_dispute'])buyerSignals['dispute_count']++;if(a['avg_market_price']&&a['avg_market_price']>0x0n){const b=Number(a['price']*0x64n/a['avg_market_price'])/0x64,c=buyerSignals['avg_purchase_price_ratio'],d=buyerSignals['purchase_count'];buyerSignals['avg_purchase_price_ratio']=(c*(d-0x1)+b)/d;}recomputeBuyerInferences(),persist();}catch{}}function recomputeBuyerInferences(){const a=buyerSignals['purchase_count'];if(a>=0x3){const b=buyerSignals['avg_purchase_price_ratio'];if(b<0.9)buyerSignals['inferred_price_sensitivity']='high';else b>1.1?buyerSignals['inferred_price_sensitivity']='low':buyerSignals['inferred_price_sensitivity']='medium';}if(a>=0x2){const c=buyerSignals['discount_usage_count']+buyerSignals['referral_usage_count'],d=c/a;buyerSignals['inferred_bargain_hunting']=Math['min'](0x1,d);}}export function getBuyerSignals(){return ensureHydrated(),{...buyerSignals};}export function updateFromOperation(a,b,c,d,e){try{ensureHydrated(),totalCount++;if(c==='success')successCount++;b&&scenarioCounts['set'](b,(scenarioCounts['get'](b)??0x0)+0x1);c!=='success'&&d&&pitfallCounts['set'](d,(pitfallCounts['get'](d)??0x0)+0x1);for(const f of e){objectRefs['set'](f,(objectRefs['get'](f)??0x0)+0x1);}currentProfile=recomputeProfile(),persist();}catch{}}function recomputeProfile(){const a=totalCount,b=a>0x0?successCount/a:0x1;let c='novice';if(a>=0x32&&b>=0.9)c='expert';else{if(a>=0xa&&b>=0.7)c='advanced';}const d=Array['from'](scenarioCounts['entries']())['sort']((i,j)=>j[0x1]-i[0x1])['slice'](0x0,0x3)['map'](([i])=>i);let e='balanced';if(a>0x14&&b<0.6)e='aggressive';else{if(a>0x14&&b>0.95)e='conservative';}const f=Array['from'](pitfallCounts['entries']())['filter'](([,i])=>i>=0x2)['sort']((i,j)=>j[0x1]-i[0x1])['slice'](0x0,0x3)['map'](([i])=>i),g=Array['from'](objectRefs['entries']())['filter'](([,i])=>i>=0x2)['sort']((i,j)=>j[0x1]-i[0x1])['slice'](0x0,0x5)['map'](([i])=>i);let h='standard';if(c==='expert')h='minimal';else{if(c==='novice')h='verbose';}return{'expertise_tier':c,'preferred_industries':d,'risk_appetite':e,'frequent_pitfalls':f,'reused_objects':g,'preferred_confirmation':h,'total_operations':a,'success_rate':b,'last_updated':Date['now']()};}export function resetProfile(){ensureHydrated(),currentProfile={'expertise_tier':'novice','preferred_industries':[],'risk_appetite':'balanced','frequent_pitfalls':[],'reused_objects':[],'preferred_confirmation':'verbose','total_operations':0x0,'success_rate':0x1,'last_updated':0x0},scenarioCounts=new Map(),pitfallCounts=new Map(),objectRefs=new Map(),successCount=0x0,totalCount=0x0,buyerSignals={'purchase_count':0x0,'avg_purchase_price_ratio':0x1,'discount_usage_count':0x0,'referral_usage_count':0x0,'dispute_count':0x0},persist();}export function getProfileStats(){return ensureHydrated(),{'total_operations':totalCount,'success_rate':totalCount>0x0?successCount/totalCount:0x1,'top_scenarios':Array['from'](scenarioCounts['entries']())['sort']((c,d)=>d[0x1]-c[0x1])['slice'](0x0,0x5)['map'](([a,b])=>({'scenario':a,'count':b})),'top_pitfalls':Array['from'](pitfallCounts['entries']())['sort']((c,d)=>d[0x1]-c[0x1])['slice'](0x0,0x5)['map'](([a,b])=>({'error_code':a,'count':b}))};}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ProjectObjectType } from "../
|
|
1
|
+
import type { ProjectObjectType } from "../playbooks/service-build/namespace.js";
|
|
2
2
|
export type BusinessModuleId = "milestone_escrow" | "independent_arbitration" | "wip_provenance" | "multi_tier_allocation" | "subscription_with_proof" | "accept_timeout_protection" | "refund_guarantee" | "reputation_on_chain" | "supplier_collaboration" | "damage_attestation";
|
|
3
3
|
export interface ModuleEvaluationImpact {
|
|
4
4
|
dimension: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ProjectObjectType } from "../
|
|
1
|
+
import type { ProjectObjectType } from "../playbooks/service-build/namespace.js";
|
|
2
2
|
export type CapabilityModule = "puzzle" | "risk" | "translation" | "templates" | "confirm" | "context" | "ledger" | "schema" | "handler";
|
|
3
3
|
export type CapabilityCategory = "data_model" | "validation" | "lifecycle" | "fund_flow" | "trust" | "workflow" | "communication" | "evidence" | "query";
|
|
4
4
|
export type IndustryAgnostic = "high" | "medium" | "low";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ProjectObjectType } from "../
|
|
1
|
+
import type { ProjectObjectType } from "../playbooks/service-build/namespace.js";
|
|
2
2
|
import type { IndustryTraits, IndustrySource } from "../knowledge/industry-registry.js";
|
|
3
3
|
import type { AcquisitionFlywheel } from "../knowledge/acquisition-flywheel.js";
|
|
4
4
|
import type { IndustryRiskCheck, IndustryNeed } from "../customer/industry-risks.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { GOAL_TYPES, type GoalType } from "./types.js";
|
|
2
|
+
export interface GoalClassification {
|
|
3
|
+
goal_type: GoalType | null;
|
|
4
|
+
confidence: number;
|
|
5
|
+
matched: string[];
|
|
6
|
+
alternatives: {
|
|
7
|
+
goal_type: GoalType;
|
|
8
|
+
score: number;
|
|
9
|
+
}[];
|
|
10
|
+
}
|
|
11
|
+
interface GoalKeywordRule {
|
|
12
|
+
goal_type: GoalType;
|
|
13
|
+
keywords: string[];
|
|
14
|
+
}
|
|
15
|
+
export declare const GOAL_KEYWORD_RULES: readonly GoalKeywordRule[];
|
|
16
|
+
export declare function classifyGoal(intentText: string): GoalClassification;
|
|
17
|
+
export { GOAL_TYPES };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{GOAL_TYPES}from'./types.js';export const GOAL_KEYWORD_RULES=[{'goal_type':'publish_service','keywords':['发布服务','开店','上线服务','开个店','开个点','出售服务','上架','publish\x20service','launch\x20service','open\x20store','open\x20a\x20store','open\x20shop','sell\x20service']},{'goal_type':'fulfill_order','keywords':['履约','交付订单','新订单','推进订单','处理订单','订单交付','fulfill','fulfil','deliver\x20order','new\x20order','process\x20order']},{'goal_type':'capture_demand','keywords':['需求机会','接单','有什么需求','找需求','需求匹配','capture\x20demand','opportunities','opportunity','demands\x20available','what\x20demands']},{'goal_type':'purchase_service','keywords':['购买服务','帮我买','帮我找','定制','下单','买个','buy','purchase','order\x20a\x20service','customize','custom-made']},{'goal_type':'collaborate_flow','keywords':['待办','我的节点','协作','员工','工作任务','my\x20tasks','pending\x20nodes','collaborate','my\x20node','todo']},{'goal_type':'supply_suborder','keywords':['子订单','应征','供应商','供货','sub-order','suborder','supplier','present']},{'goal_type':'publish_demand','keywords':['发布需求','找人做','悬赏','求人','publish\x20demand','post\x20demand','bounty','looking\x20for\x20someone']},{'goal_type':'run_arbitration','keywords':['仲裁业务','仲裁服务','经营仲裁','仲裁经营','arbitration\x20business','arbitrator','arbitration\x20service']},{'goal_type':'dispute_resolution','keywords':['争议','纠纷','投诉','申诉','维权','dispute','complaint','appeal']},{'goal_type':'manage_assets','keywords':['资产','资金','数据管理','盘点','权限盘点','treasury','assets','manage\x20funds','asset','inventory']}];const ASCII_RE=/^[\x20-\x7e]+$/;function keywordWeight(a){return a['length']>=0x4?0x2:0x1;}function escapeRe(a){return a['replace'](/[.*+?^${}()|[\]\\]/g,'\x5c$&');}const boundaryCache=new Map();function keywordMatches(a,b){if(ASCII_RE['test'](a)){let c=boundaryCache['get'](a);return!c&&(c=new RegExp('\x5cb'+escapeRe(a)+'\x5cb','i'),boundaryCache['set'](a,c)),c['test'](b);}return b['includes'](a);}export function classifyGoal(a){const b=(a??'')['trim']()['toLowerCase'](),c={'goal_type':null,'confidence':0x0,'matched':[],'alternatives':[]};if(!b)return c;const d=[];for(const k of GOAL_KEYWORD_RULES){const l=[];let m=0x0;for(const n of k['keywords']){keywordMatches(n,b)&&(l['push'](n),m+=keywordWeight(n));}if(m>0x0)d['push']({'goal_type':k['goal_type'],'score':m,'matched':l});}if(d['length']===0x0)return c;let e=d[0x0];for(const o of d){if(o['score']>e['score'])e=o;}const f=d['reduce']((p,q)=>p+q['score'],0x0),g=e['score']/f,h=Math['min'](0x1,e['score']/0x3),i=Math['round'](g*h*0x3e8)/0x3e8,j=d['filter'](p=>p['goal_type']!==e['goal_type'])['sort']((p,q)=>q['score']-p['score'])['map'](({goal_type:p,score:q})=>({'goal_type':p,'score':q}));return{'goal_type':e['goal_type'],'confidence':i,'matched':e['matched'],'alternatives':j};}export{GOAL_TYPES};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { type GoalClassification } from "./GoalClassifier.js";
|
|
2
|
+
import { GoalStore } from "./GoalStore.js";
|
|
3
|
+
import { type GoalProcessSummary, type GoalRecord, type GoalStage, type GoalType, type ObjectRef } from "./types.js";
|
|
4
|
+
import { type FeedbackRecord, type ProblemRecord, type ProcessEvent, type ProcessManifest, type ProcessStageState } from "../task/types.js";
|
|
5
|
+
import type { UserIntentSignature } from "../experience/types.js";
|
|
6
|
+
import { type SubscriptionStore } from "../monitor/SubscriptionStore.js";
|
|
7
|
+
import type { CreateIntentInput } from "../intent/index.js";
|
|
8
|
+
import type { IntentRecord } from "../intent/types.js";
|
|
9
|
+
import { type LocalAccountInfo } from "../knowledge/workflow-guidance.js";
|
|
10
|
+
import { type GoalCompletionVerdict } from "../knowledge/goal-completion.js";
|
|
11
|
+
export declare const GOAL_PLAYBOOKS: Record<GoalType, string | undefined>;
|
|
12
|
+
export declare const PLAN_APPROVAL_COVERS_LEVELS: readonly ["standard", "none"];
|
|
13
|
+
export interface GoalProcessDeps {
|
|
14
|
+
rootDir(): string;
|
|
15
|
+
initProcess(dir: string, manifest: ProcessManifest, stages: string[]): ProcessManifest;
|
|
16
|
+
loadManifest(dir: string): ProcessManifest;
|
|
17
|
+
saveManifest(dir: string, manifest: ProcessManifest): void;
|
|
18
|
+
loadStageState(dir: string): ProcessStageState | undefined;
|
|
19
|
+
appendEvent(dir: string, event: ProcessEvent): void;
|
|
20
|
+
addFeedback(dir: string, input: {
|
|
21
|
+
source: FeedbackRecord["source"];
|
|
22
|
+
sentiment: FeedbackRecord["sentiment"];
|
|
23
|
+
comment: string;
|
|
24
|
+
refs?: FeedbackRecord["refs"];
|
|
25
|
+
}): FeedbackRecord;
|
|
26
|
+
listProblems(dir: string, filter?: {
|
|
27
|
+
status?: ProblemRecord["status"];
|
|
28
|
+
}): ProblemRecord[];
|
|
29
|
+
listFeedback(dir: string): FeedbackRecord[];
|
|
30
|
+
readEvents(dir: string): ProcessEvent[];
|
|
31
|
+
removeDir(dir: string): void;
|
|
32
|
+
}
|
|
33
|
+
export interface GoalEngineDeps {
|
|
34
|
+
store: Pick<GoalStore, "create" | "get" | "save" | "list" | "counts" | "remove">;
|
|
35
|
+
subscriptionStore: Pick<SubscriptionStore, "getConfig" | "saveConfig">;
|
|
36
|
+
createIntent(input: CreateIntentInput): Promise<IntentRecord>;
|
|
37
|
+
removeIntent(id: string): Promise<boolean>;
|
|
38
|
+
listLocalAccounts(): Promise<LocalAccountInfo[]>;
|
|
39
|
+
evaluateCompletion(goal: GoalRecord, network?: string): Promise<GoalCompletionVerdict>;
|
|
40
|
+
processes: GoalProcessDeps;
|
|
41
|
+
recordSignature(sig: UserIntentSignature): void;
|
|
42
|
+
}
|
|
43
|
+
export interface CreateOrAdoptInput {
|
|
44
|
+
intent_text: string;
|
|
45
|
+
goal_type?: GoalType;
|
|
46
|
+
account?: string;
|
|
47
|
+
persona?: string;
|
|
48
|
+
title?: string;
|
|
49
|
+
network?: string;
|
|
50
|
+
conversation_id?: string;
|
|
51
|
+
create_process?: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface CreateOrAdoptResult {
|
|
54
|
+
goal?: GoalRecord;
|
|
55
|
+
adopted: boolean;
|
|
56
|
+
classification?: GoalClassification;
|
|
57
|
+
needs_type?: boolean;
|
|
58
|
+
warnings?: string[];
|
|
59
|
+
}
|
|
60
|
+
export interface AdvanceInput {
|
|
61
|
+
stage?: GoalStage;
|
|
62
|
+
objects?: ObjectRef[];
|
|
63
|
+
}
|
|
64
|
+
export interface CompleteResult {
|
|
65
|
+
goal: GoalRecord;
|
|
66
|
+
completed: boolean;
|
|
67
|
+
verify_report: GoalCompletionVerdict;
|
|
68
|
+
teardown_notes?: string[];
|
|
69
|
+
}
|
|
70
|
+
export declare const ADOPT_JACCARD_THRESHOLD = 0.6;
|
|
71
|
+
export declare function tokenizeIntent(text: string): Set<string>;
|
|
72
|
+
export declare function jaccard(a: Set<string>, b: Set<string>): number;
|
|
73
|
+
export declare class GoalEngine {
|
|
74
|
+
private readonly deps;
|
|
75
|
+
constructor(deps: GoalEngineDeps);
|
|
76
|
+
createOrAdopt(input: CreateOrAdoptInput): Promise<CreateOrAdoptResult>;
|
|
77
|
+
private preflightAccount;
|
|
78
|
+
approve(network: string, id: string, note?: string): Promise<GoalRecord>;
|
|
79
|
+
bind(network: string, id: string, account: string, persona?: string): Promise<GoalRecord>;
|
|
80
|
+
advance(network: string, id: string, input?: AdvanceInput): Promise<GoalRecord>;
|
|
81
|
+
registerActObjects(goalId: string, objects: ObjectRef[], network?: string): Promise<number>;
|
|
82
|
+
private registerProcessObjects;
|
|
83
|
+
private emitProcessEvent;
|
|
84
|
+
private distillOutcome;
|
|
85
|
+
private assertTransition;
|
|
86
|
+
pause(network: string, id: string): Promise<GoalRecord>;
|
|
87
|
+
private autoBindMonitor;
|
|
88
|
+
complete(network: string, id: string, opts?: {
|
|
89
|
+
force?: boolean;
|
|
90
|
+
feedback?: {
|
|
91
|
+
sentiment: "positive" | "negative" | "neutral";
|
|
92
|
+
comment: string;
|
|
93
|
+
};
|
|
94
|
+
}): Promise<CompleteResult>;
|
|
95
|
+
abandon(network: string, id: string, reason?: string): Promise<{
|
|
96
|
+
goal: GoalRecord;
|
|
97
|
+
teardown_notes?: string[];
|
|
98
|
+
}>;
|
|
99
|
+
remove(network: string, id: string, opts?: {
|
|
100
|
+
force?: boolean;
|
|
101
|
+
}): Promise<{
|
|
102
|
+
deleted: boolean;
|
|
103
|
+
tore_down_active?: boolean;
|
|
104
|
+
process_removed?: boolean;
|
|
105
|
+
}>;
|
|
106
|
+
private teardown;
|
|
107
|
+
get(network: string, id: string): Promise<GoalRecord & {
|
|
108
|
+
process_summary?: GoalProcessSummary;
|
|
109
|
+
}>;
|
|
110
|
+
private summarizeProcess;
|
|
111
|
+
list(network: string, filter?: {
|
|
112
|
+
stage?: GoalStage;
|
|
113
|
+
account?: string;
|
|
114
|
+
}): Promise<{
|
|
115
|
+
goals: GoalRecord[];
|
|
116
|
+
counts: Record<string, number>;
|
|
117
|
+
}>;
|
|
118
|
+
private mustGet;
|
|
119
|
+
}
|
|
120
|
+
export declare const goalEngine: GoalEngine;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{classifyGoal}from'./GoalClassifier.js';import{goalStore}from'./GoalStore.js';import{isTerminalStage,newGoalId,stageIndex}from'./types.js';import{GENERIC_PLAYBOOK,playbookForGoalType}from'../task/playbook.js';import{PROCESS_SCHEMA_VERSION,newProcessId}from'../task/types.js';import{addFeedback,appendEvent,deleteProcessDir,initProcess,listFeedback,listProblems,loadManifest,loadStageState,processesRootDir,readEvents,saveManifest}from'../task/ProcessStore.js';import{recordSignature}from'../experience/index.js';import{join}from'path';import{registerPlanApproval,revokePlanApproval}from'./plan-approval.js';import{subscriptionStore}from'../monitor/SubscriptionStore.js';import{createIntent,removeIntent}from'../intent/index.js';import{listLocalAccounts}from'../knowledge/workflow-guidance.js';import{evaluateGoalCompletion}from'../knowledge/goal-completion.js';export const GOAL_PLAYBOOKS={'publish_service':'wowok-provider','fulfill_order':'wowok-provider','capture_demand':'wowok-market','purchase_service':'wowok-order','collaborate_flow':'wowok-collaborator','supply_suborder':'wowok-supplier','publish_demand':'wowok-order','run_arbitration':'wowok-arbitrator','dispute_resolution':'wowok-order','manage_assets':undefined};export const PLAN_APPROVAL_COVERS_LEVELS=['standard','none'];export const ADOPT_JACCARD_THRESHOLD=0.6;export function tokenizeIntent(a){const b=new Set(),c=(a??'')['toLowerCase']();for(const d of c['matchAll'](/[a-z0-9]+/g))b['add'](d[0x0]);for(const e of c['matchAll'](/[\u3400-\u9fff\uf900-\ufaff]/g))b['add'](e[0x0]);return b;}export function jaccard(c,d){if(c['size']===0x0||d['size']===0x0)return 0x0;let e=0x0;for(const f of c)if(d['has'](f))e++;return e/(c['size']+d['size']-e);}function deriveTitle(a){const b=(intent_text_first_line(a)||'Untitled\x20goal')['trim']();return b['length']>0x3c?b['slice'](0x0,0x39)+'…':b;}function intent_text_first_line(a){return(a??'')['split'](/\r?\n/,0x1)[0x0]??'';}function newApprovalId(){return'appr_'+Date['now']()['toString'](0x24)+Math['random']()['toString'](0x24)['slice'](0x2,0x8);}export class GoalEngine{['deps'];constructor(a){this['deps']=a;}async['createOrAdopt'](a){const b=a['network']??'default',c=(a['intent_text']??'')['trim']();if(!c)throw new Error('create_or_adopt\x20requires\x20non-empty\x20intent_text');let d=a['goal_type'],f;if(!d){f=classifyGoal(c),d=f['goal_type']??undefined;if(!d)return{'adopted':![],'classification':f,'needs_type':!![]};}const h=await this['deps']['store']['list'](b),i=a['account']??'',j=tokenizeIntent(c);let k;for(const r of h){if(isTerminalStage(r['stage']))continue;if(r['goal_type']!==d)continue;if((r['binding']?.['account']??'')!==i)continue;const s=jaccard(j,tokenizeIntent(r['intent_text']));s>=ADOPT_JACCARD_THRESHOLD&&(!k||s>k['sim'])&&(k={'goal':r,'sim':s});}if(k)return{'goal':k['goal'],'adopted':!![],'classification':f};const l=Date['now']();let m,n='recognized';if(a['account']){const t=await this['preflightAccount'](a['account']);m={'account':a['account'],'persona':a['persona'],'preflight':t},n='bound';}const o={'id':newGoalId(),'goal_type':d,'title':a['title']?.['trim']()||deriveTitle(c),'intent_text':c,...a['conversation_id']?{'conversation_id':a['conversation_id']}:{},'binding':m,'objects':[],'monitor':{'focus_ids':[],'intent_ids':[]},'stage':n,'playbook':GOAL_PLAYBOOKS[d],'approvals':[],'created_at':l,'updated_at':l};await this['deps']['store']['create'](b,o);const p=[],q=playbookForGoalType(d);if(q['name']!==GENERIC_PLAYBOOK||a['create_process']===!![])try{const u=newProcessId(),v=join(this['deps']['processes']['rootDir'](),u),w=new Date(l)['toISOString']();this['deps']['processes']['initProcess'](v,{'schema_version':PROCESS_SCHEMA_VERSION,'mcp_version':'unknown','process_id':u,'playbook':q['name'],'goal_id':o['id'],'title':o['title'],'network':b,'objects':[],'created_at':w,'updated_at':w,'archived':![]},q['stages']),o['process']={'id':u,'playbook':q['name'],'dir':v},o['plan_ref']=u,await this['deps']['store']['save'](b,o);}catch(x){p['push']('process\x20creation\x20failed\x20(goal\x20kept\x20without\x20process):\x20'+(x instanceof Error?x['message']:String(x)));}return{'goal':o,'adopted':![],'classification':f,...p['length']?{'warnings':p}:{}};}async['preflightAccount'](a){const b=[];let c;try{const d=await this['deps']['listLocalAccounts']();c=d['find'](f=>f['address']===a||f['name']===a);}catch(f){b['push']('local\x20account\x20lookup\x20failed:\x20'+(f instanceof Error?f['message']:String(f)));}if(c){if(c['address']!==a)b['push']('resolved\x20\x27'+a+'\x27\x20to\x20'+c['address']);}else b['push']('account\x20\x27'+a+'\x27\x20not\x20found\x20among\x20local\x20accounts');return{'account_found':Boolean(c),'notes':b};}async['approve'](a,b,c){const d=await this['mustGet'](a,b);if(isTerminalStage(d['stage']))throw new Error('goal\x20'+b+'\x20is\x20terminal\x20('+d['stage']+')');const e={'id':newApprovalId(),'approved_at':Date['now'](),'scope':'plan','covers_levels':[...PLAN_APPROVAL_COVERS_LEVELS],...c?{'note':c}:{}};d['approvals']['push'](e),registerPlanApproval(d['id']);const f=stageIndex(d['stage']);if(f>=0x0&&f<stageIndex('approved'))d['stage']='approved';return d['updated_at']=Date['now'](),this['deps']['store']['save'](a,d);}async['bind'](a,b,c,d){const e=await this['mustGet'](a,b);if(isTerminalStage(e['stage']))throw new Error('goal\x20'+b+'\x20is\x20terminal\x20('+e['stage']+')');if(!c?.['trim']())throw new Error('bind\x20requires\x20a\x20non-empty\x20account');const f=await this['preflightAccount'](c['trim']());e['binding']={'account':c['trim'](),...d?.['trim']()?{'persona':d['trim']()}:{},'preflight':f};const g=stageIndex(e['stage']);if(g>=0x0&&g<stageIndex('bound'))e['stage']='bound';return e['updated_at']=Date['now'](),this['deps']['store']['save'](a,e);}async['advance'](a,b,c={}){const d=await this['mustGet'](a,b);if(isTerminalStage(d['stage']))throw new Error('goal\x20'+b+'\x20is\x20terminal\x20('+d['stage']+')');const e=[];for(const g of c['objects']??[]){const h=d['objects']['some'](i=>i['type']===g['type']&&i['object']['toLowerCase']()===g['object']['toLowerCase']());!h&&(d['objects']['push']({'type':g['type'],'object':g['object']}),e['push']({'type':g['type'],'object':g['object']}));}const f=c['stage'];if(f){this['assertTransition'](d['stage'],f);const i=f==='monitoring'&&d['stage']!=='monitoring';d['stage']=f,d['updated_at']=Date['now']();if(i)await this['autoBindMonitor'](a,d);if(i)this['emitProcessEvent'](d,'goal_monitoring','goal\x20entered\x20monitoring');}else{if((c['objects']??[])['length']===0x0)throw new Error('advance\x20requires\x20a\x20target\x20stage\x20and/or\x20objects');}return e['length']>0x0&&d['process']&&this['registerProcessObjects'](d,e),d['updated_at']=Date['now'](),this['deps']['store']['save'](a,d);}async['registerActObjects'](a,b,c='default'){if(b['length']===0x0)return 0x0;try{let d=c,e=await this['deps']['store']['get'](d,a);if(!e&&d!=='default'){e=await this['deps']['store']['get']('default',a);if(e)d='default';}if(!e||isTerminalStage(e['stage']))return 0x0;const f=e['objects']['length'],g=await this['advance'](d,a,{'objects':b});return g['objects']['length']-f;}catch{return 0x0;}}['registerProcessObjects'](a,b){try{const c=a['process']['dir'],d=this['deps']['processes']['loadManifest'](c);for(const e of b){const f=d['objects']['some'](g=>g['type']===e['type']&&g['object']['toLowerCase']()===e['object']['toLowerCase']());if(!f)d['objects']['push']({'type':e['type'],'object':e['object']});}this['deps']['processes']['saveManifest'](c,d),this['deps']['processes']['appendEvent'](c,{'timestamp':new Date()['toISOString'](),'event':'objects_registered','reason':b['length']+'\x20object(s)\x20registered\x20by\x20goal\x20'+a['id'],'data':{'added':b['map'](g=>g['type']+':'+g['object'])}});}catch{}}['emitProcessEvent'](a,b,c){if(!a['process'])return;try{this['deps']['processes']['appendEvent'](a['process']['dir'],{'timestamp':new Date()['toISOString'](),'event':b,'reason':c});}catch{}}['distillOutcome'](a,b){try{const c={'playbook':a['process']?.['playbook'],'objects_count':a['objects']['length']};if(a['process']){const d=this['deps']['processes']['loadStageState'](a['process']['dir']),e=d?.['stages']['filter'](h=>d['stage_meta'][h]?.['committed'])['length'];if(e!==undefined)c['stages_completed']=e;const f=this['deps']['processes']['listProblems'](a['process']['dir']),g=this['deps']['processes']['listFeedback'](a['process']['dir']);c['problems_open']=f['filter'](h=>h['status']==='open')['length'],c['problems_resolved']=f['filter'](h=>h['status']==='resolved')['length'],c['feedback_positive']=g['filter'](h=>h['sentiment']==='positive')['length'],c['feedback_negative']=g['filter'](h=>h['sentiment']==='negative')['length'];}this['deps']['recordSignature']({'intent':a['goal_type'],'signals':c,'timestamp':Date['now'](),'outcome':b});}catch{}}['assertTransition'](a,b){if(isTerminalStage(a))throw new Error('goal\x20is\x20terminal\x20('+a+')');if(b==='abandoned')throw new Error('use\x20the\x20abandon\x20action\x20to\x20abandon\x20a\x20goal');if(b==='paused')return;if(a==='paused')return;if(b===a)return;const c=stageIndex(a),d=stageIndex(b);if(d<0x0||c<0x0||d<c)throw new Error('invalid\x20stage\x20transition:\x20'+a+'\x20→\x20'+b+'\x20(forward-only\x20along\x20'+'recognized→confirmed→bound→planned→approved→acting→monitoring→completed'+')');}async['pause'](a,b){return this['advance'](a,b,{'stage':'paused'});}async['autoBindMonitor'](a,b){const c=await this['deps']['subscriptionStore']['getConfig'](a),d=c['scope']['focus_objects']['map'](g=>({...g})),e=Date['now']();for(const f of b['objects']){const g=d['some'](h=>h['object']===f['object']&&h['goal_id']===b['id']);if(g)continue;d['push']({'object':f['object'],'added_at':e,'reason':'goal','closure':!![],'goal_id':b['id'],'note':b['title']});if(!b['monitor']['focus_ids']['includes'](f['object']))b['monitor']['focus_ids']['push'](f['object']);}await this['deps']['subscriptionStore']['saveConfig'](a,{'scope':{...c['scope'],'focus_objects':d}});if((b['goal_type']==='capture_demand'||b['goal_type']==='publish_demand')&&b['monitor']['intent_ids']['length']===0x0){const h=await this['deps']['createIntent']({'intent':b['intent_text'],'account':b['binding']?.['account']});b['monitor']['intent_ids']['push'](h['id']);}}async['complete'](a,b,c={}){const d=await this['mustGet'](a,b);if(isTerminalStage(d['stage']))throw new Error('goal\x20'+b+'\x20is\x20terminal\x20('+d['stage']+')');const e=await this['deps']['evaluateCompletion'](d,a),f=c['force']===!![];if(!e['complete']&&!f)return{'goal':d,'completed':![],'verify_report':e};const g=await this['teardown'](a,d);d['stage']='completed',d['outcome']={'success':e['complete']||f,'completed_at':Date['now'](),'verify_report':e,...!e['complete']&&f?{'forced':!![]}:{}},d['updated_at']=Date['now']();if(d['process']){if(c['feedback'])try{this['deps']['processes']['addFeedback'](d['process']['dir'],{'source':'user','sentiment':c['feedback']['sentiment'],'comment':c['feedback']['comment']});}catch{g['push']('feedback\x20recording\x20failed');}this['emitProcessEvent'](d,'goal_completed','goal\x20completed\x20('+d['title']+')');}this['distillOutcome'](d,'success');const h=await this['deps']['store']['save'](a,d);return{'goal':h,'completed':!![],'verify_report':e,'teardown_notes':g['length']?g:undefined};}async['abandon'](a,b,c){const d=await this['mustGet'](a,b);if(isTerminalStage(d['stage']))throw new Error('goal\x20'+b+'\x20is\x20already\x20terminal\x20('+d['stage']+')');const e=await this['teardown'](a,d);d['stage']='abandoned',d['outcome']={'success':![],'completed_at':Date['now'](),...c?{'verify_report':{'reason':c}}:{}},d['updated_at']=Date['now'](),this['emitProcessEvent'](d,'goal_abandoned',c??'goal\x20abandoned'),this['distillOutcome'](d,'failed');const f=await this['deps']['store']['save'](a,d);return{'goal':f,'teardown_notes':e['length']?e:undefined};}async['remove'](a,b,c={}){const d=await this['mustGet'](a,b);let e;if(!isTerminalStage(d['stage'])){if(c['force']!==!![])throw new Error('goal\x20'+b+'\x20is\x20not\x20terminal\x20('+d['stage']+')\x20—\x20complete/abandon\x20it\x20first,\x20or\x20pass\x20force=true');await this['teardown'](a,d),e=!![];}let f;if(d['process'])try{this['deps']['processes']['removeDir'](d['process']['dir']),f=!![];}catch{f=![];}const g=await this['deps']['store']['remove'](a,b);return{'deleted':g,...e!==undefined?{'tore_down_active':e}:{},...f!==undefined?{'process_removed':f}:{}};}async['teardown'](a,b){const c=[];try{const d=await this['deps']['subscriptionStore']['getConfig'](a),f=d['scope']['focus_objects']['filter'](g=>g['goal_id']!==b['id']);f['length']!==d['scope']['focus_objects']['length']&&await this['deps']['subscriptionStore']['saveConfig'](a,{'scope':{...d['scope'],'focus_objects':f}});}catch(g){c['push']('focus\x20teardown\x20failed:\x20'+(g instanceof Error?g['message']:String(g)));}revokePlanApproval(b['id']);for(const h of b['monitor']['intent_ids']){try{await this['deps']['removeIntent'](h);}catch(i){c['push']('intent\x20teardown\x20failed\x20('+h+'):\x20'+(i instanceof Error?i['message']:String(i)));}}return c;}async['get'](a,b){const c=await this['mustGet'](a,b);if(!c['process'])return c;try{return{...c,'process_summary':this['summarizeProcess'](c['process']['dir'],c['process']['id'],c['process']['playbook'])};}catch{return c;}}['summarizeProcess'](a,b,c){const d=this['deps']['processes']['loadStageState'](a),e=this['deps']['processes']['listProblems'](a,{'status':'open'}),f={'critical':0x0,'high':0x1,'medium':0x2,'low':0x3},g=[...e]['sort']((h,i)=>f[h['severity']]-f[i['severity']])['slice'](0x0,0x3)['map'](h=>h['title']);return{'id':b,'playbook':c,'current_stage':d?.['current_stage']??'unknown','stages':(d?.['stages']??[])['map'](h=>({'name':h,'committed':d?.['stage_meta'][h]?.['committed']??![],'completion':d?.['stage_meta'][h]?.['completion']??0x0})),'open_problems':{'count':e['length'],'top':g},'last_events':this['deps']['processes']['readEvents'](a)['slice'](-0x5),'feedback_count':this['deps']['processes']['listFeedback'](a)['length']};}async['list'](a,b={}){const [c,d]=await Promise['all']([this['deps']['store']['list'](a,b),this['deps']['store']['counts'](a)]);return{'goals':c,'counts':d};}async['mustGet'](a,b){const c=await this['deps']['store']['get'](a,b);if(!c)throw new Error('goal\x20not\x20found:\x20'+b);return c;}}export const goalEngine=new GoalEngine({'store':goalStore,'subscriptionStore':subscriptionStore,'createIntent':createIntent,'removeIntent':removeIntent,'listLocalAccounts':listLocalAccounts,'evaluateCompletion':(a,b)=>evaluateGoalCompletion(a,b),'processes':{'rootDir':processesRootDir,'initProcess':initProcess,'loadManifest':loadManifest,'saveManifest':saveManifest,'loadStageState':loadStageState,'appendEvent':appendEvent,'addFeedback':addFeedback,'listProblems':listProblems,'listFeedback':listFeedback,'readEvents':readEvents,'removeDir':deleteProcessDir},'recordSignature':recordSignature});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SQLiteStorage } from "@wowok/wowok/w/local";
|
|
2
|
+
import { TERMINAL_STAGES, type GoalRecord, type GoalStage } from "./types.js";
|
|
3
|
+
export interface GoalListFilter {
|
|
4
|
+
stage?: GoalStage;
|
|
5
|
+
account?: string;
|
|
6
|
+
conversation_id?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class GoalStore {
|
|
9
|
+
private storage;
|
|
10
|
+
private locks;
|
|
11
|
+
constructor(storage?: SQLiteStorage);
|
|
12
|
+
private withLock;
|
|
13
|
+
private goalKey;
|
|
14
|
+
private idxKey;
|
|
15
|
+
private getJson;
|
|
16
|
+
private putJson;
|
|
17
|
+
create(network: string, goal: GoalRecord): Promise<GoalRecord>;
|
|
18
|
+
get(network: string, id: string): Promise<GoalRecord | undefined>;
|
|
19
|
+
save(network: string, goal: GoalRecord): Promise<GoalRecord>;
|
|
20
|
+
list(network: string, filter?: GoalListFilter): Promise<GoalRecord[]>;
|
|
21
|
+
remove(network: string, id: string): Promise<boolean>;
|
|
22
|
+
counts(network: string): Promise<Record<string, number>>;
|
|
23
|
+
private indexAdd;
|
|
24
|
+
}
|
|
25
|
+
export declare const GOAL_INDEX_STAGES: readonly GoalStage[];
|
|
26
|
+
export { TERMINAL_STAGES };
|
|
27
|
+
export declare const goalStore: GoalStore;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{SQLiteStorage}from'@wowok/wowok/w/local';import{TERMINAL_STAGES}from'./types.js';const KEY_PREFIX='goal:v1:',IDX_PREFIX='goal_idx:v1:',INDEX_STAGES=['recognized','confirmed','bound','planned','approved','acting','monitoring','paused','completed','abandoned'];function netKey(a){return(a||'default')['replace'](/[^a-zA-Z0-9_-]/g,'_');}function parseRecord(a){try{const b=JSON['parse'](a);return b&&typeof b['id']==='string'?b:undefined;}catch{return undefined;}}export class GoalStore{['storage'];['locks']=new Map();constructor(a){this['storage']=a??new SQLiteStorage();}['withLock'](a,b){const c=netKey(a),d=this['locks']['get'](c)??Promise['resolve'](),e=d['then'](b,b);return this['locks']['set'](c,e['catch'](()=>undefined)),e;}['goalKey'](a,b){return''+KEY_PREFIX+netKey(a)+':'+b;}['idxKey'](a){return''+IDX_PREFIX+netKey(a);}async['getJson'](a){const b=await this['storage']['get'](a);if(!b)return undefined;try{return JSON['parse'](b);}catch{return undefined;}}async['putJson'](a,b){await this['storage']['put'](a,JSON['stringify'](b));}async['create'](a,b){return this['withLock'](a,async()=>{const c=await this['storage']['get'](this['goalKey'](a,b['id']));if(c)throw new Error('goal\x20already\x20exists:\x20'+b['id']);return await this['putJson'](this['goalKey'](a,b['id']),b),await this['indexAdd'](a,b['id'],b['stage']),b;});}async['get'](a,b){const c=await this['storage']['get'](this['goalKey'](a,b));return c?parseRecord(c):undefined;}async['save'](a,b){return this['withLock'](a,async()=>{const c=await this['storage']['get'](this['goalKey'](a,b['id']));if(!c)throw new Error('goal\x20not\x20found:\x20'+b['id']);return await this['putJson'](this['goalKey'](a,b['id']),b),await this['indexAdd'](a,b['id'],b['stage']),b;});}async['list'](a,b={}){let c;if(b['stage']){const f=await this['getJson'](this['idxKey'](a))??{'by_stage':{}};c=[...f['by_stage'][b['stage']]??[]];}else{const g=await this['storage']['list'](''+KEY_PREFIX+netKey(a)+':');c=g['map'](({value:h})=>parseRecord(h)?.['id'])['filter'](h=>typeof h==='string');}if(c['length']===0x0)return[];const d=await this['storage']['getMany'](c['map'](h=>this['goalKey'](a,h))),e=[];for(const h of d){const i=h?parseRecord(h):undefined;if(!i)continue;if(b['stage']&&i['stage']!==b['stage'])continue;if(b['account']!==undefined&&i['binding']?.['account']!==b['account'])continue;if(b['conversation_id']!==undefined&&i['conversation_id']!==b['conversation_id'])continue;e['push'](i);}return e['sort']((j,k)=>k['updated_at']-j['updated_at']);}async['remove'](a,b){return this['withLock'](a,async()=>{const c=this['goalKey'](a,b),d=await this['storage']['get'](c);if(!d)return![];await this['storage']['del'](c);const e=await this['getJson'](this['idxKey'](a))??{'by_stage':{}},f={...e['by_stage']};let g=![];for(const h of INDEX_STAGES){const i=f[h]??[];i['includes'](b)&&(f[h]=i['filter'](j=>j!==b),g=!![]);}if(g)await this['putJson'](this['idxKey'](a),{'by_stage':f});return!![];});}async['counts'](a){const b=await this['getJson'](this['idxKey'](a))??{'by_stage':{}},c={};for(const d of INDEX_STAGES)c[d]=b['by_stage'][d]?.['length']??0x0;return c;}async['indexAdd'](a,b,c){const d=await this['getJson'](this['idxKey'](a))??{'by_stage':{}},e={...d['by_stage']};for(const f of INDEX_STAGES){const g=(e[f]??[])['filter'](h=>h!==b);if(f===c)g['push'](b);e[f]=g;}await this['putJson'](this['idxKey'](a),{'by_stage':e});}}export const GOAL_INDEX_STAGES=INDEX_STAGES;export{TERMINAL_STAGES};export const goalStore=new GoalStore();
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function registerPlanApproval(goalId: string): void;
|
|
2
|
+
export declare function revokePlanApproval(goalId: string): void;
|
|
3
|
+
export declare function isPlanPreapproved(env: unknown): boolean;
|
|
4
|
+
export declare function clearPlanApprovals(): void;
|
|
5
|
+
export declare function listPlanApprovals(): string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const preapprovedGoals=new Map();export function registerPlanApproval(a){if(!a)return;preapprovedGoals['set'](a,Date['now']());}export function revokePlanApproval(a){preapprovedGoals['delete'](a);}export function isPlanPreapproved(a){const b=a?.['plan_approval'];return typeof b==='string'&&b['length']>0x0&&preapprovedGoals['has'](b);}export function clearPlanApprovals(){preapprovedGoals['clear']();}export function listPlanApprovals(){return[...preapprovedGoals['keys']()];}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { ProcessEvent } from "../task/types.js";
|
|
2
|
+
export type GoalType = "publish_service" | "fulfill_order" | "capture_demand" | "purchase_service" | "collaborate_flow" | "supply_suborder" | "publish_demand" | "run_arbitration" | "dispute_resolution" | "manage_assets";
|
|
3
|
+
export declare const GOAL_TYPES: readonly GoalType[];
|
|
4
|
+
export declare const GOAL_TYPE_LABELS: Record<GoalType, string>;
|
|
5
|
+
export type GoalStage = "recognized" | "confirmed" | "bound" | "planned" | "approved" | "acting" | "monitoring" | "paused" | "completed" | "abandoned";
|
|
6
|
+
export declare const STAGE_ORDER: readonly GoalStage[];
|
|
7
|
+
export declare const TERMINAL_STAGES: readonly GoalStage[];
|
|
8
|
+
export interface ObjectRef {
|
|
9
|
+
type: string;
|
|
10
|
+
object: string;
|
|
11
|
+
}
|
|
12
|
+
export interface PreflightResult {
|
|
13
|
+
account_found: boolean;
|
|
14
|
+
notes: string[];
|
|
15
|
+
}
|
|
16
|
+
export interface BindingRecord {
|
|
17
|
+
account: string;
|
|
18
|
+
persona?: string;
|
|
19
|
+
preflight: PreflightResult;
|
|
20
|
+
}
|
|
21
|
+
export interface ApprovalRecord {
|
|
22
|
+
id: string;
|
|
23
|
+
approved_at: number;
|
|
24
|
+
scope: "plan";
|
|
25
|
+
covers_levels: string[];
|
|
26
|
+
note?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface GoalRecord {
|
|
29
|
+
id: string;
|
|
30
|
+
goal_type: GoalType;
|
|
31
|
+
title: string;
|
|
32
|
+
intent_text: string;
|
|
33
|
+
conversation_id?: string;
|
|
34
|
+
binding?: BindingRecord;
|
|
35
|
+
plan_ref?: string;
|
|
36
|
+
process?: {
|
|
37
|
+
id: string;
|
|
38
|
+
playbook: string;
|
|
39
|
+
dir: string;
|
|
40
|
+
};
|
|
41
|
+
objects: ObjectRef[];
|
|
42
|
+
monitor: {
|
|
43
|
+
focus_ids: string[];
|
|
44
|
+
intent_ids: string[];
|
|
45
|
+
};
|
|
46
|
+
stage: GoalStage;
|
|
47
|
+
playbook?: string;
|
|
48
|
+
approvals: ApprovalRecord[];
|
|
49
|
+
outcome?: {
|
|
50
|
+
success: boolean;
|
|
51
|
+
completed_at: number;
|
|
52
|
+
verify_report?: unknown;
|
|
53
|
+
forced?: boolean;
|
|
54
|
+
};
|
|
55
|
+
created_at: number;
|
|
56
|
+
updated_at: number;
|
|
57
|
+
}
|
|
58
|
+
export declare function isTerminalStage(stage: GoalStage): boolean;
|
|
59
|
+
export declare function stageIndex(stage: GoalStage): number;
|
|
60
|
+
export interface GoalProcessSummary {
|
|
61
|
+
id: string;
|
|
62
|
+
playbook: string;
|
|
63
|
+
current_stage: string;
|
|
64
|
+
stages: {
|
|
65
|
+
name: string;
|
|
66
|
+
committed: boolean;
|
|
67
|
+
completion: number;
|
|
68
|
+
}[];
|
|
69
|
+
open_problems: {
|
|
70
|
+
count: number;
|
|
71
|
+
top: string[];
|
|
72
|
+
};
|
|
73
|
+
last_events: ProcessEvent[];
|
|
74
|
+
feedback_count: number;
|
|
75
|
+
}
|
|
76
|
+
export declare function newGoalId(): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const GOAL_TYPES=['publish_service','fulfill_order','capture_demand','purchase_service','collaborate_flow','supply_suborder','publish_demand','run_arbitration','dispute_resolution','manage_assets'];export const GOAL_TYPE_LABELS={'publish_service':'Publish\x20&\x20operate\x20a\x20service','fulfill_order':'Fulfill\x20an\x20order\x20(merchant\x20side)','capture_demand':'Capture\x20demand\x20opportunities','purchase_service':'Purchase\x20a\x20service\x20&\x20see\x20it\x20delivered','collaborate_flow':'Collaborate\x20in\x20a\x20workflow\x20(my\x20pending\x20nodes)','supply_suborder':'Supply\x20a\x20sub-order\x20to\x20a\x20demand','publish_demand':'Publish\x20a\x20demand','run_arbitration':'Run\x20an\x20arbitration\x20business','dispute_resolution':'Resolve\x20a\x20dispute\x20(as\x20a\x20party)','manage_assets':'Manage\x20assets\x20&\x20data'};export const STAGE_ORDER=['recognized','confirmed','bound','planned','approved','acting','monitoring','completed'];export const TERMINAL_STAGES=['completed','abandoned'];export function isTerminalStage(a){return TERMINAL_STAGES['includes'](a);}export function stageIndex(a){return STAGE_ORDER['indexOf'](a);}export function newGoalId(){return'goal_'+Date['now']()['toString'](0x24)+Math['random']()['toString'](0x24)['slice'](0x2,0x8);}
|
package/dist/harness/index.d.ts
CHANGED
|
@@ -2,14 +2,13 @@ export * from "./types.js";
|
|
|
2
2
|
export * from "./plan.js";
|
|
3
3
|
export * from "./verify.js";
|
|
4
4
|
export * from "./recover.js";
|
|
5
|
-
export * from "./checkpoint.js";
|
|
6
5
|
import type { DecisionPoint, MigrationDecision } from "./plan.js";
|
|
7
6
|
import type { VerifyInput } from "./verify.js";
|
|
8
|
-
import type { ODG, ExpectedResult, VerifyReport, RecoveryAction
|
|
7
|
+
import type { ODG, ExpectedResult, VerifyReport, RecoveryAction } from "./types.js";
|
|
9
8
|
export declare class Harness {
|
|
10
9
|
private context;
|
|
11
10
|
plan(userInput: string, taskId?: string): ODG;
|
|
12
|
-
planFromSemanticGraph(graph: import("../
|
|
11
|
+
planFromSemanticGraph(graph: import("../playbooks/service-build/semantic-graph.js").SemanticObjectGraph, taskId?: string): ODG;
|
|
13
12
|
classifyIntent(userInput: string): import("./plan.js").IntentClassification;
|
|
14
13
|
getDecisions(odg: ODG): DecisionPoint[];
|
|
15
14
|
getMigrationDecisions(options?: {
|
|
@@ -28,10 +27,6 @@ export declare class Harness {
|
|
|
28
27
|
resetRecovery(operationId: string): void;
|
|
29
28
|
getBackoffDelay(attempt: number): number;
|
|
30
29
|
getRecoveryRules(): Record<string, import("./recover.js").RecoveryRule>;
|
|
31
|
-
checkpoint(taskId: string, phase: string, phaseStatus: Checkpoint["phase_status"], odgSnapshot: Checkpoint["odg_snapshot"], userDecisions: Record<string, unknown>, operationLog: Checkpoint["operation_log"], nextPhase: string, semanticSummary: Checkpoint["semantic_summary"]): Checkpoint;
|
|
32
|
-
loadCheckpoint(taskId: string): Checkpoint | null;
|
|
33
|
-
listCheckpoints(taskId: string): Checkpoint[];
|
|
34
|
-
listTasks(): string[];
|
|
35
30
|
setContext(key: string, value: unknown): void;
|
|
36
31
|
getContext<T>(key: string): T | undefined;
|
|
37
32
|
}
|
package/dist/harness/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from'./types.js';export*from'./plan.js';export*from'./verify.js';export*from'./recover.js';
|
|
1
|
+
export*from'./types.js';export*from'./plan.js';export*from'./verify.js';export*from'./recover.js';import{classifyIntent,generateODG,generateODGFromSemanticGraph,identifyDecisionPoints,detectCycles,SCENARIO_REGISTRY,identifyMigrationDecisions}from'./plan.js';import{verify,generateExpected}from'./verify.js';import{recover,resetAttempts,getBackoffDelay,RECOVERY_RULES}from'./recover.js';export class Harness{['context']=new Map();['plan'](a,b){return generateODG(a,b);}['planFromSemanticGraph'](a,b){return generateODGFromSemanticGraph(a,b);}['classifyIntent'](a){return classifyIntent(a);}['getDecisions'](a){return identifyDecisionPoints(a);}['getMigrationDecisions'](a){return identifyMigrationDecisions(a);}['detectCycles'](a){return detectCycles(a);}['getScenarioRegistry'](){return SCENARIO_REGISTRY;}['expect'](a,b,c,d){return generateExpected(a,b,c,d);}['verify'](a){return verify(a);}['recover'](a,b,c){return recover(a,b,c);}['resetRecovery'](a){resetAttempts(a);}['getBackoffDelay'](a){return getBackoffDelay(a);}['getRecoveryRules'](){return RECOVERY_RULES;}['setContext'](a,b){this['context']['set'](a,b);}['getContext'](a){return this['context']['get'](a);}}let singleton=null;export function getHarness(){return!singleton&&(singleton=new Harness()),singleton;}export function setHarness(a){singleton=a;}
|
package/dist/harness/plan.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ODG, ScenarioTemplate } from "./types.js";
|
|
2
|
-
import type { SemanticObjectGraph } from "../
|
|
2
|
+
import type { SemanticObjectGraph } from "../playbooks/service-build/semantic-graph.js";
|
|
3
3
|
export declare const SCENARIO_REGISTRY: ScenarioTemplate[];
|
|
4
4
|
export interface IntentClassification {
|
|
5
5
|
scenario: string;
|
package/dist/harness/recover.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const RECOVERY_RULES={'insufficient_balance':{'error_code':'insufficient_balance','strategy':'claim_faucet','max_attempts':0x3,'automation':'semi','detail':'1.\x20Testnet:\x20claim\x20WOW\x20from\x20the\x20faucet\x202.\x20Mainnet:\x20transfer\x20ETH/USDT/USDC/WBTC\x20via\x20the\x20ETH\x20mainnet\x20cross-chain\x20bridge\x20(query\x20active\x20EVM\x20account\x20→\x20top\x20up\x20from\x20external\x20wallet\x20→\x20confirm\x20→\x20cross-chain)\x203.\x20Mention\x20the\x20WOW\x20airdrop\x20(under\x20construction)\x204.\x20Retry\x20original\x20operation','user_prompt':'Insufficient\x20balance\x20for\x20gas\x20or\x20operation.\x20How\x20to\x20obtain\x20WOW\x20tokens:\x20(1)\x20Testnet\x20—\x20claim\x20WOW\x20from\x20the\x20faucet\x20(https://faucet.testnet.wowok.net);\x20all\x20merchant\x20and\x20order\x20testing\x20can\x20use\x20WOW\x20as\x20the\x20payment\x20token.\x20(2)\x20Mainnet\x20—\x20transfer\x20ETH\x20/\x20USDT\x20/\x20USDC\x20/\x20WBTC\x20via\x20the\x20ETH\x20mainnet\x20cross-chain\x20bridge:\x20first\x20query\x20the\x20active\x20EVM\x20account\x20(bridge_operation\x20query_active_evm_account,\x20auto-generated\x20on\x20first\x20use),\x20then\x20transfer\x20from\x20an\x20external\x20wallet\x20(e.g.\x20MetaMask)\x20to\x20that\x20address,\x20confirm\x20the\x20balance\x20arrived,\x20and\x20cross-chain\x20to\x20WOW\x20mainnet\x20(bridge_operation\x20cross_chain_evm_to_wow).\x20(3)\x20WOW\x20mainnet\x20airdrop:\x20https://airdrop.wowok.net\x20(under\x20construction).'},'network_error':{'error_code':'network_error','strategy':'retry','max_attempts':0x5,'automation':'full','detail':'Exponential\x20backoff\x20retry:\x201s\x20/\x202s\x20/\x204s\x20/\x208s\x20/\x2016s.\x20Switch\x20RPC\x20node\x20if\x20available.'},'guard_rejected':{'error_code':'guard_rejected','strategy':'fill_submission','max_attempts':0x2,'automation':'semi','detail':'1.\x20Parse\x20Guard\x20table\x20structure\x202.\x20Prompt\x20user\x20to\x20fill\x20submission\x20fields\x203.\x20Resubmit\x20with\x20call_with_submission','user_prompt':'Guard\x20verification\x20rejected.\x20Please\x20fill\x20in\x20the\x20required\x20submission\x20data\x20and\x20resubmit.'},'immutable_violation':{'error_code':'immutable_violation','strategy':'recreate','max_attempts':0x1,'automation':'semi','detail':'1.\x20Stop\x20modification\x20attempt\x202.\x20Evaluate\x20creating\x20a\x20new\x20object\x20as\x20replacement\x203.\x20Re-plan\x20affected\x20phases','user_prompt':'Cannot\x20modify\x20an\x20immutable\x20object.\x20A\x20new\x20object\x20must\x20be\x20created\x20as\x20a\x20replacement.\x20Confirm\x20to\x20proceed\x20with\x20recreation.'},'permission_denied':{'error_code':'permission_denied','strategy':'switch_account','max_attempts':0x2,'automation':'semi','detail':'1.\x20Query\x20object\x27s\x20permission_guard\x202.\x20List\x20accounts\x20with\x20permission\x203.\x20Switch\x20account\x20or\x20prompt\x20user\x20to\x20add\x20permission','user_prompt':'Current\x20account\x20lacks\x20permission\x20for\x20this\x20operation.\x20Switch\x20to\x20an\x20authorized\x20account\x20or\x20update\x20the\x20Permission\x20object.'},'object_not_found':{'error_code':'object_not_found','strategy':'query_and_retry','max_attempts':0x3,'automation':'semi','detail':'1.\x20Re-query\x20the\x20object\x20(may\x20be\x20sync\x20delay)\x202.\x20If\x20truly\x20absent,\x20search\x20for\x20similar\x20objects\x203.\x20Prompt\x20user\x20to\x20reselect','user_prompt':'Referenced\x20object\x20not\x20found.\x20It\x20may\x20be\x20a\x20synchronization\x20delay.\x20Retrying...\x20If\x20the\x20issue\x20persists,\x20please\x20select\x20a\x20valid\x20object.'},'state_conflict':{'error_code':'state_conflict','strategy':'adjust_params','max_attempts':0x2,'automation':'full','detail':'1.\x20Query\x20object\x27s\x20current\x20true\x20state\x202.\x20Update\x20ODG\x20status\x20annotations\x203.\x20Adjust\x20subsequent\x20operations\x20(e.g.,\x20skip\x20completed\x20steps)'},'invalid_parameter':{'error_code':'invalid_parameter','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'1.\x20Query\x20the\x20relevant\x20schema\x202.\x20Auto-fix\x20obvious\x20errors\x20(e.g.,\x20BigInt\x20vs\x20string)\x203.\x20If\x20unfixable,\x20prompt\x20user','user_prompt':'Parameter\x20validation\x20failed.\x20Please\x20check\x20the\x20parameter\x20types\x20and\x20values\x20against\x20the\x20schema\x20and\x20retry.'},'unknown':{'error_code':'unknown','strategy':'escalate_human','max_attempts':0x1,'automation':'manual','detail':'1.\x20Report\x20full\x20error\x20context\x20to\x20telemetry\x202.\x20Escalate\x20to\x20human\x20intervention\x203.\x20Flag\x20for\x20Loop\x20Engineering\x20rule\x20addition','user_prompt':'An\x20unclassified\x20error\x20occurred.\x20Please\x20review\x20the\x20error\x20details\x20and\x20contact\x20support\x20if\x20needed.\x20This\x20error\x20has\x20been\x20logged\x20for\x20tool\x20improvement.'}};const operationAttempts=new Map();function getAttemptCount(a,b){const c=operationAttempts['get'](a);if(!c)return 0x0;return c['get'](b)??0x0;}function incrementAttempt(a,b){!operationAttempts['has'](a)&&operationAttempts['set'](a,new Map());const c=operationAttempts['get'](a),d=(c['get'](b)??0x0)+0x1;return c['set'](b,d),d;}function getTotalAttempts(a){const b=operationAttempts['get'](a);if(!b)return 0x0;let c=0x0;for(const d of b['values']())c+=d;return c;}export function resetAttempts(a){operationAttempts['delete'](a);}export function recover(a,b,c){const d=RECOVERY_RULES[a]??RECOVERY_RULES['unknown'],e=0x5,f=getTotalAttempts(b),g=getAttemptCount(b,a);if(f>=e)return{'strategy':'stop','should_retry':![],'max_attempts':e,'current_attempt':f,'detail':'Total\x20retry\x20limit\x20('+e+')\x20reached\x20for\x20operation\x20'+b+'.\x20Escalating\x20to\x20human\x20intervention.','user_prompt':'Maximum\x20retry\x20attempts\x20reached.\x20Manual\x20intervention\x20required.'};if(g>=d['max_attempts'])return{'strategy':'escalate_human','should_retry':![],'max_attempts':d['max_attempts'],'current_attempt':g,'detail':'Per-error-code\x20retry\x20limit\x20('+d['max_attempts']+')\x20reached\x20for\x20'+a+'.\x20Escalating\x20to\x20human.','user_prompt':'Recovery\x20attempts\x20for\x20'+a+'\x20exhausted.\x20Manual\x20intervention\x20required.'};const h=incrementAttempt(b,a);return{'strategy':d['strategy'],'should_retry':d['automation']==='full'||h<d['max_attempts'],'max_attempts':d['max_attempts'],'current_attempt':h,'adjusted_params':d['adjusted_params'],'user_prompt':d['user_prompt'],'detail':d['detail']};}export function getBackoffDelay(a){return Math['pow'](0x2,a-0x1)*0x3e8;}
|
|
1
|
+
export const RECOVERY_RULES={'insufficient_balance':{'error_code':'insufficient_balance','strategy':'claim_faucet','max_attempts':0x3,'automation':'semi','detail':'1.\x20Testnet:\x20claim\x20WOW\x20from\x20the\x20faucet\x202.\x20Mainnet:\x20transfer\x20ETH/USDT/USDC/WBTC\x20via\x20the\x20ETH\x20mainnet\x20cross-chain\x20bridge\x20(query\x20active\x20EVM\x20account\x20→\x20top\x20up\x20from\x20external\x20wallet\x20→\x20confirm\x20→\x20cross-chain)\x203.\x20Mention\x20the\x20WOW\x20airdrop\x20(under\x20construction)\x204.\x20Retry\x20original\x20operation','user_prompt':'Insufficient\x20balance\x20for\x20gas\x20or\x20operation.\x20How\x20to\x20obtain\x20WOW\x20tokens:\x20(1)\x20Testnet\x20—\x20claim\x20WOW\x20from\x20the\x20faucet\x20(https://faucet.testnet.wowok.net);\x20all\x20merchant\x20and\x20order\x20testing\x20can\x20use\x20WOW\x20as\x20the\x20payment\x20token.\x20(2)\x20Mainnet\x20—\x20transfer\x20ETH\x20/\x20USDT\x20/\x20USDC\x20/\x20WBTC\x20via\x20the\x20ETH\x20mainnet\x20cross-chain\x20bridge:\x20first\x20query\x20the\x20active\x20EVM\x20account\x20(bridge_operation\x20query_active_evm_account,\x20auto-generated\x20on\x20first\x20use),\x20then\x20transfer\x20from\x20an\x20external\x20wallet\x20(e.g.\x20MetaMask)\x20to\x20that\x20address,\x20confirm\x20the\x20balance\x20arrived,\x20and\x20cross-chain\x20to\x20WOW\x20mainnet\x20(bridge_operation\x20cross_chain_evm_to_wow).\x20(3)\x20WOW\x20mainnet\x20airdrop:\x20https://airdrop.wowok.net\x20(under\x20construction).'},'network_error':{'error_code':'network_error','strategy':'retry','max_attempts':0x5,'automation':'full','detail':'Exponential\x20backoff\x20retry:\x201s\x20/\x202s\x20/\x204s\x20/\x208s\x20/\x2016s.\x20Switch\x20RPC\x20node\x20if\x20available.'},'guard_rejected':{'error_code':'guard_rejected','strategy':'fill_submission','max_attempts':0x2,'automation':'semi','detail':'1.\x20Parse\x20Guard\x20table\x20structure\x202.\x20Prompt\x20user\x20to\x20fill\x20submission\x20fields\x203.\x20Resubmit\x20with\x20call_with_submission','user_prompt':'Guard\x20verification\x20rejected.\x20Please\x20fill\x20in\x20the\x20required\x20submission\x20data\x20and\x20resubmit.'},'time_lock_not_elapsed':{'error_code':'time_lock_not_elapsed','strategy':'wait_and_retry','max_attempts':0x1,'automation':'semi','detail':'1.\x20Verify\x20Service\x20is\x20paused\x20(bPaused=true).\x20If\x20not,\x20submit\x20pause=true\x20first.\x202.\x20Wait\x20until\x20paused_time\x20+\x20setting_lock_duration\x20<=\x20current\x20clock.\x203.\x20Retry\x20the\x20original\x20operation.\x20Do\x20NOT\x20recreate\x20the\x20object.','user_prompt':'Service\x20setting_lock_duration\x20has\x20not\x20elapsed\x20since\x20the\x20Service\x20was\x20paused.\x20Please\x20pause\x20the\x20Service\x20if\x20it\x20is\x20not\x20already\x20paused,\x20wait\x20for\x20the\x20lock\x20duration\x20to\x20elapse,\x20then\x20retry.'},'immutable_violation':{'error_code':'immutable_violation','strategy':'recreate','max_attempts':0x1,'automation':'semi','detail':'1.\x20Stop\x20modification\x20attempt\x202.\x20Evaluate\x20creating\x20a\x20new\x20object\x20as\x20replacement\x203.\x20Re-plan\x20affected\x20phases','user_prompt':'Cannot\x20modify\x20an\x20immutable\x20object.\x20A\x20new\x20object\x20must\x20be\x20created\x20as\x20a\x20replacement.\x20Confirm\x20to\x20proceed\x20with\x20recreation.'},'permission_denied':{'error_code':'permission_denied','strategy':'switch_account','max_attempts':0x2,'automation':'semi','detail':'1.\x20Query\x20object\x27s\x20permission_guard\x202.\x20List\x20accounts\x20with\x20permission\x203.\x20Switch\x20account\x20or\x20prompt\x20user\x20to\x20add\x20permission','user_prompt':'Current\x20account\x20lacks\x20permission\x20for\x20this\x20operation.\x20Switch\x20to\x20an\x20authorized\x20account\x20or\x20update\x20the\x20Permission\x20object.'},'object_not_found':{'error_code':'object_not_found','strategy':'query_and_retry','max_attempts':0x3,'automation':'semi','detail':'1.\x20Re-query\x20the\x20object\x20(may\x20be\x20sync\x20delay)\x202.\x20If\x20truly\x20absent,\x20search\x20for\x20similar\x20objects\x203.\x20Prompt\x20user\x20to\x20reselect','user_prompt':'Referenced\x20object\x20not\x20found.\x20It\x20may\x20be\x20a\x20synchronization\x20delay.\x20Retrying...\x20If\x20the\x20issue\x20persists,\x20please\x20select\x20a\x20valid\x20object.'},'state_conflict':{'error_code':'state_conflict','strategy':'adjust_params','max_attempts':0x2,'automation':'full','detail':'1.\x20Query\x20object\x27s\x20current\x20true\x20state\x202.\x20Update\x20ODG\x20status\x20annotations\x203.\x20Adjust\x20subsequent\x20operations\x20(e.g.,\x20skip\x20completed\x20steps)'},'invalid_parameter':{'error_code':'invalid_parameter','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'1.\x20Query\x20the\x20relevant\x20schema\x202.\x20Auto-fix\x20obvious\x20errors\x20(e.g.,\x20BigInt\x20vs\x20string)\x203.\x20If\x20unfixable,\x20prompt\x20user','user_prompt':'Parameter\x20validation\x20failed.\x20Please\x20check\x20the\x20parameter\x20types\x20and\x20values\x20against\x20the\x20schema\x20and\x20retry.'},'unknown':{'error_code':'unknown','strategy':'escalate_human','max_attempts':0x1,'automation':'manual','detail':'1.\x20Report\x20full\x20error\x20context\x20to\x20telemetry\x202.\x20Escalate\x20to\x20human\x20intervention\x203.\x20Flag\x20for\x20Loop\x20Engineering\x20rule\x20addition','user_prompt':'An\x20unclassified\x20error\x20occurred.\x20Please\x20review\x20the\x20error\x20details\x20and\x20contact\x20support\x20if\x20needed.\x20This\x20error\x20has\x20been\x20logged\x20for\x20tool\x20improvement.'}};const operationAttempts=new Map();function getAttemptCount(a,b){const c=operationAttempts['get'](a);if(!c)return 0x0;return c['get'](b)??0x0;}function incrementAttempt(a,b){!operationAttempts['has'](a)&&operationAttempts['set'](a,new Map());const c=operationAttempts['get'](a),d=(c['get'](b)??0x0)+0x1;return c['set'](b,d),d;}function getTotalAttempts(a){const b=operationAttempts['get'](a);if(!b)return 0x0;let c=0x0;for(const d of b['values']())c+=d;return c;}export function resetAttempts(a){operationAttempts['delete'](a);}export function recover(a,b,c){const d=RECOVERY_RULES[a]??RECOVERY_RULES['unknown'],e=0x5,f=getTotalAttempts(b),g=getAttemptCount(b,a);if(f>=e)return{'strategy':'stop','should_retry':![],'max_attempts':e,'current_attempt':f,'detail':'Total\x20retry\x20limit\x20('+e+')\x20reached\x20for\x20operation\x20'+b+'.\x20Escalating\x20to\x20human\x20intervention.','user_prompt':'Maximum\x20retry\x20attempts\x20reached.\x20Manual\x20intervention\x20required.'};if(g>=d['max_attempts'])return{'strategy':'escalate_human','should_retry':![],'max_attempts':d['max_attempts'],'current_attempt':g,'detail':'Per-error-code\x20retry\x20limit\x20('+d['max_attempts']+')\x20reached\x20for\x20'+a+'.\x20Escalating\x20to\x20human.','user_prompt':'Recovery\x20attempts\x20for\x20'+a+'\x20exhausted.\x20Manual\x20intervention\x20required.'};const h=incrementAttempt(b,a);return{'strategy':d['strategy'],'should_retry':d['automation']==='full'||h<d['max_attempts'],'max_attempts':d['max_attempts'],'current_attempt':h,'adjusted_params':d['adjusted_params'],'user_prompt':d['user_prompt'],'detail':d['detail']};}export function getBackoffDelay(a){return Math['pow'](0x2,a-0x1)*0x3e8;}
|