@wowok/agent-mcp 2.7.2 → 2.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/runtime.js +1 -1
- package/dist/customer/account-events.d.ts +32 -0
- package/dist/customer/account-events.js +1 -0
- package/dist/customer/customer-advice.d.ts +1 -0
- package/dist/customer/customer-advice.js +1 -1
- package/dist/customer/info-puzzle.js +1 -1
- package/dist/customer/order-strategy.d.ts +1 -1
- package/dist/customer/reminder-system.d.ts +2 -0
- package/dist/customer/reminder-system.js +1 -1
- package/dist/customer/risk-assessment.d.ts +1 -0
- package/dist/customer/risk-assessment.js +1 -1
- package/dist/customer/types.d.ts +2 -0
- package/dist/evaluation/builtins/arbitration-score.d.ts +41 -0
- package/dist/evaluation/builtins/arbitration-score.js +1 -0
- package/dist/evaluation/builtins/index.d.ts +1 -0
- package/dist/evaluation/builtins/index.js +1 -1
- package/dist/evaluation/category-match-rules.d.ts +30 -0
- package/dist/evaluation/category-match-rules.js +1 -0
- package/dist/evaluation/engine.js +1 -1
- package/dist/evaluation/extract.js +1 -1
- package/dist/evaluation/index.d.ts +1 -0
- package/dist/evaluation/index.js +1 -1
- package/dist/evaluation/location-match.d.ts +42 -0
- package/dist/evaluation/location-match.js +1 -0
- package/dist/evaluation/path-reasoning.d.ts +35 -0
- package/dist/evaluation/path-reasoning.js +1 -0
- package/dist/evaluation/region.d.ts +6 -0
- package/dist/evaluation/region.js +1 -1
- package/dist/evaluation/types.d.ts +17 -0
- package/dist/experience/realtime-feedback.js +1 -1
- package/dist/experience/user-profile.d.ts +1 -1
- package/dist/extensions/index.d.ts +6 -0
- package/dist/extensions/index.js +1 -1
- package/dist/extensions/industry-layers.d.ts +75 -0
- package/dist/extensions/industry-layers.js +1 -0
- package/dist/extensions/industry-pack.d.ts +105 -0
- package/dist/extensions/industry-pack.js +1 -0
- package/dist/extensions/metric-registry.js +1 -1
- package/dist/extensions/mode-evaluator.d.ts +1 -1
- package/dist/extensions/registry.d.ts +1 -0
- package/dist/extensions/registry.js +1 -1
- package/dist/graph/base.d.ts +8 -0
- package/dist/graph/base.js +1 -0
- package/dist/harness/index.d.ts +1 -0
- package/dist/harness/index.js +1 -1
- package/dist/harness/plan.d.ts +2 -0
- package/dist/harness/plan.js +1 -1
- package/dist/harness/recover.d.ts +1 -1
- package/dist/harness/types.d.ts +2 -3
- package/dist/index.js +1 -1
- package/dist/knowledge/allocation-confirm.js +1 -1
- package/dist/knowledge/anti-cheat.d.ts +37 -0
- package/dist/knowledge/anti-cheat.js +1 -0
- package/dist/knowledge/arb-confirm.d.ts +28 -0
- package/dist/knowledge/arb-confirm.js +1 -0
- package/dist/knowledge/arb-translation.d.ts +48 -0
- package/dist/knowledge/arb-translation.js +1 -0
- package/dist/knowledge/arbitration-context.js +1 -1
- package/dist/knowledge/arbitration-ledger.js +1 -1
- package/dist/knowledge/bridge-confirm.d.ts +26 -0
- package/dist/knowledge/bridge-confirm.js +1 -0
- package/dist/knowledge/bridge-translation.d.ts +37 -0
- package/dist/knowledge/bridge-translation.js +1 -0
- package/dist/knowledge/contact-confirm.d.ts +27 -0
- package/dist/knowledge/contact-confirm.js +1 -0
- package/dist/knowledge/contact-translation.d.ts +39 -0
- package/dist/knowledge/contact-translation.js +1 -0
- package/dist/knowledge/demand-confirm.js +1 -1
- package/dist/knowledge/demand-context.d.ts +17 -0
- package/dist/knowledge/demand-context.js +1 -0
- package/dist/knowledge/demand-ledger.d.ts +26 -0
- package/dist/knowledge/demand-ledger.js +1 -0
- package/dist/knowledge/demand-puzzle.d.ts +29 -0
- package/dist/knowledge/demand-puzzle.js +1 -0
- package/dist/knowledge/demand-risk.js +1 -1
- package/dist/knowledge/demand-templates.d.ts +12 -0
- package/dist/knowledge/demand-templates.js +1 -0
- package/dist/knowledge/demand-translation.js +1 -1
- package/dist/knowledge/deployment-scanner.js +1 -1
- package/dist/knowledge/evidence-review.d.ts +12 -0
- package/dist/knowledge/evidence-review.js +1 -0
- package/dist/knowledge/examples-scanner-cli.js +1 -1
- package/dist/knowledge/examples-scanner.js +1 -1
- package/dist/knowledge/flywheel-loop.d.ts +0 -1
- package/dist/knowledge/flywheel-loop.js +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-migration.d.ts +1 -1
- package/dist/knowledge/index.d.ts +71 -3
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/machine-render.js +1 -1
- package/dist/knowledge/market-metrics.d.ts +12 -0
- package/dist/knowledge/market-metrics.js +1 -0
- package/dist/knowledge/market-operations.d.ts +46 -0
- package/dist/knowledge/market-operations.js +1 -0
- package/dist/knowledge/mcp-schema-audit-cli.js +1 -1
- package/dist/knowledge/mcp-schema-audit.d.ts +22 -22
- package/dist/knowledge/mcp-schema-audit.js +1 -1
- package/dist/knowledge/onchain-constants.d.ts +2 -2
- package/dist/knowledge/onchain-constants.js +1 -1
- package/dist/knowledge/payment-confirm.d.ts +26 -0
- package/dist/knowledge/payment-confirm.js +1 -0
- package/dist/knowledge/payment-risk.js +1 -1
- package/dist/knowledge/payment-translation.d.ts +37 -0
- package/dist/knowledge/payment-translation.js +1 -0
- package/dist/knowledge/permission-context.d.ts +11 -0
- package/dist/knowledge/permission-context.js +1 -1
- package/dist/knowledge/permission-ledger.d.ts +11 -0
- package/dist/knowledge/permission-ledger.js +1 -1
- package/dist/knowledge/personal-confirm.d.ts +29 -0
- package/dist/knowledge/personal-confirm.js +1 -0
- package/dist/knowledge/personal-risk.js +1 -1
- package/dist/knowledge/personal-translation.d.ts +37 -0
- package/dist/knowledge/personal-translation.js +1 -0
- package/dist/knowledge/process-model.d.ts +1 -11
- package/dist/knowledge/process-model.js +1 -1
- package/dist/knowledge/progress-ledger.js +1 -1
- package/dist/knowledge/progress-risk.js +1 -1
- package/dist/knowledge/progress-templates.js +1 -1
- package/dist/knowledge/progress-translation.js +1 -1
- package/dist/knowledge/proof-context.d.ts +17 -0
- package/dist/knowledge/proof-context.js +1 -0
- package/dist/knowledge/proof-ledger.d.ts +34 -0
- package/dist/knowledge/proof-ledger.js +1 -0
- package/dist/knowledge/proof-puzzle.d.ts +35 -0
- package/dist/knowledge/proof-puzzle.js +1 -0
- package/dist/knowledge/proof-templates.d.ts +22 -0
- package/dist/knowledge/proof-templates.js +1 -0
- package/dist/knowledge/registrar-confirm.d.ts +26 -0
- package/dist/knowledge/registrar-confirm.js +1 -0
- package/dist/knowledge/registrar-risk.js +1 -1
- package/dist/knowledge/registrar-translation.d.ts +37 -0
- package/dist/knowledge/registrar-translation.js +1 -0
- package/dist/knowledge/repository-context.d.ts +12 -0
- package/dist/knowledge/repository-context.js +1 -0
- package/dist/knowledge/repository-ledger.d.ts +25 -0
- package/dist/knowledge/repository-ledger.js +1 -0
- package/dist/knowledge/repository-puzzle.d.ts +30 -0
- package/dist/knowledge/repository-puzzle.js +1 -0
- package/dist/knowledge/repository-templates.d.ts +14 -0
- package/dist/knowledge/repository-templates.js +1 -0
- package/dist/knowledge/resource-confirm.d.ts +25 -0
- package/dist/knowledge/resource-confirm.js +1 -0
- package/dist/knowledge/resource-translation.d.ts +37 -0
- package/dist/knowledge/resource-translation.js +1 -0
- package/dist/knowledge/reward-context.d.ts +2 -2
- package/dist/knowledge/reward-ledger.js +1 -1
- package/dist/knowledge/reward-translation.js +1 -1
- package/dist/knowledge/safety-rules.d.ts +1 -0
- package/dist/knowledge/safety-rules.js +1 -1
- package/dist/knowledge/service-risk.d.ts +1 -1
- package/dist/knowledge/service-risk.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/knowledge/treasury-context.d.ts +1 -1
- package/dist/knowledge/treasury-context.js +1 -1
- package/dist/knowledge/treasury-ledger.js +1 -1
- package/dist/knowledge/treasury-risk.js +1 -1
- package/dist/knowledge/universal-template.d.ts +22 -0
- package/dist/knowledge/universal-template.js +1 -0
- package/dist/knowledge/util-confirm.d.ts +24 -0
- package/dist/knowledge/util-confirm.js +1 -0
- package/dist/knowledge/util-risk.js +1 -1
- package/dist/knowledge/util-translation.d.ts +39 -0
- package/dist/knowledge/util-translation.js +1 -0
- package/dist/knowledge/workflow-guidance.d.ts +180 -0
- package/dist/knowledge/workflow-guidance.js +1 -0
- package/dist/participation/employee-kpi.d.ts +25 -0
- package/dist/participation/employee-kpi.js +1 -0
- package/dist/participation/employee-store.d.ts +16 -0
- package/dist/participation/employee-store.js +1 -0
- package/dist/participation/index.d.ts +2 -0
- package/dist/participation/index.js +1 -0
- package/dist/persona/defaults.js +1 -1
- package/dist/persona/index.d.ts +9 -2
- package/dist/persona/index.js +1 -1
- package/dist/persona/local-region.d.ts +20 -0
- package/dist/persona/local-region.js +1 -0
- package/dist/persona/model.js +1 -1
- package/dist/persona/overrides.d.ts +10 -0
- package/dist/persona/overrides.js +1 -0
- package/dist/persona/pack-personae.d.ts +11 -0
- package/dist/persona/pack-personae.js +1 -0
- package/dist/persona/strategy-intent.d.ts +20 -0
- package/dist/persona/strategy-intent.js +1 -0
- package/dist/persona/types.d.ts +3 -1
- package/dist/project/business-puzzle.d.ts +1 -1
- package/dist/project/business-puzzle.js +1 -1
- package/dist/project/deployment-doc.js +1 -1
- package/dist/project/edit-planner.js +1 -1
- package/dist/project/evaluation.d.ts +37 -1
- package/dist/project/evaluation.js +1 -1
- package/dist/project/graph-builder.d.ts +2 -2
- package/dist/project/graph-builder.js +1 -1
- package/dist/project/graph.d.ts +3 -6
- package/dist/project/handlers.d.ts +33 -2
- package/dist/project/handlers.js +1 -1
- package/dist/project/index.d.ts +1 -0
- package/dist/project/index.js +1 -1
- package/dist/project/merchant-guide.d.ts +19 -0
- package/dist/project/merchant-guide.js +1 -1
- package/dist/project/mode-actions.js +1 -1
- package/dist/project/rollback-policy.js +1 -1
- package/dist/project/semantic-assembler.d.ts +2 -2
- package/dist/project/semantic-assembler.js +1 -1
- package/dist/project/semantic-graph.d.ts +3 -5
- package/dist/project/workflow-design-assessment.d.ts +24 -0
- package/dist/project/workflow-design-assessment.js +1 -0
- package/dist/safety/confirm-gate.d.ts +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/call/allocation.d.ts +186 -1385
- package/dist/schema/call/arbitration.d.ts +272 -1871
- package/dist/schema/call/base.d.ts +1831 -9076
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +911 -3171
- package/dist/schema/call/contact.d.ts +135 -931
- package/dist/schema/call/demand.d.ts +164 -1194
- package/dist/schema/call/guard.d.ts +298 -1140
- package/dist/schema/call/guard.js +1 -1
- package/dist/schema/call/machine.d.ts +459 -5403
- package/dist/schema/call/machine.js +1 -1
- package/dist/schema/call/order.d.ts +137 -844
- package/dist/schema/call/payment.d.ts +74 -561
- package/dist/schema/call/permission.d.ts +335 -2791
- package/dist/schema/call/personal.d.ts +227 -1814
- package/dist/schema/call/progress.d.ts +140 -843
- package/dist/schema/call/proof.d.ts +42 -258
- package/dist/schema/call/repository.d.ts +324 -2222
- package/dist/schema/call/reward.d.ts +153 -1183
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +376 -3431
- package/dist/schema/call/treasury.d.ts +252 -2158
- package/dist/schema/common/index.d.ts +222 -697
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/config/index.d.ts +18 -161
- package/dist/schema/employee/index.d.ts +99 -0
- package/dist/schema/employee/index.js +1 -0
- package/dist/schema/evaluation/index.d.ts +1035 -3918
- package/dist/schema/evaluation/index.js +1 -1
- package/dist/schema/index.d.ts +5 -0
- package/dist/schema/index.js +1 -1
- package/dist/schema/industry-pack/index.d.ts +132 -0
- package/dist/schema/industry-pack/index.js +1 -0
- package/dist/schema/intent-radar/index.d.ts +92 -245
- package/dist/schema/intent-radar/index.js +1 -1
- package/dist/schema/local/index.d.ts +2045 -18080
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/local/wip.d.ts +61 -651
- package/dist/schema/local/wip.js +1 -1
- package/dist/schema/messenger/index.d.ts +949 -5557
- package/dist/schema/messenger/index.js +1 -1
- package/dist/schema/operations.d.ts +3168 -26468
- package/dist/schema/operations.js +1 -1
- package/dist/schema/permission/index.d.ts +121 -0
- package/dist/schema/permission/index.js +1 -0
- package/dist/schema/persona/index.d.ts +469 -1820
- package/dist/schema/persona/index.js +1 -1
- package/dist/schema/project/index.d.ts +1023 -8450
- package/dist/schema/project/index.js +1 -1
- package/dist/schema/query/index.d.ts +12121 -75556
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-query/index.d.ts +35 -98
- package/dist/schema/schema-query/index.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/task-status.d.ts +26 -132
- package/dist/schema/trust/index.d.ts +194 -1290
- package/dist/schema/utils/guard-parser.js +1 -1
- package/dist/schema/utils/node-parser.js +1 -1
- package/dist/schema/utils/skills-recommendation.d.ts +1 -0
- package/dist/schema/utils/skills-recommendation.js +1 -1
- package/dist/schema/workflow/index.d.ts +161 -0
- package/dist/schema/workflow/index.js +1 -0
- package/dist/schema/workspace/index.d.ts +69 -0
- package/dist/schema/workspace/index.js +1 -0
- package/dist/{schema-query → schema-query-impl}/index.js +1 -1
- package/dist/schemas/account_operation.output.json +3147 -1655
- package/dist/schemas/account_operation.schema.json +225 -218
- package/dist/schemas/bridge_operation.output.json +1168 -653
- package/dist/schemas/bridge_operation.schema.json +736 -504
- package/dist/schemas/config_operation.output.json +185 -179
- package/dist/schemas/config_operation.schema.json +21 -26
- package/dist/schemas/employee_operation.output.json +207 -0
- package/dist/schemas/employee_operation.schema.json +176 -0
- package/dist/schemas/evaluation_operation.output.json +2268 -601
- package/dist/schemas/evaluation_operation.schema.json +2919 -787
- package/dist/schemas/guard2file.output.json +58 -64
- package/dist/schemas/guard2file.schema.json +79 -81
- package/dist/schemas/index.json +41 -11
- package/dist/schemas/industry_pack_operation.output.json +594 -0
- package/dist/schemas/industry_pack_operation.schema.json +55 -0
- package/dist/schemas/intent_radar.output.json +275 -203
- package/dist/schemas/intent_radar.schema.json +124 -126
- package/dist/schemas/local_info_operation.output.json +1174 -660
- package/dist/schemas/local_info_operation.schema.json +119 -125
- package/dist/schemas/local_mark_operation.output.json +1239 -692
- package/dist/schemas/local_mark_operation.schema.json +91 -96
- package/dist/schemas/machineNode2file.output.json +63 -69
- package/dist/schemas/machineNode2file.schema.json +79 -81
- package/dist/schemas/messenger_operation.output.json +2722 -1531
- package/dist/schemas/messenger_operation.schema.json +1482 -1264
- package/dist/schemas/onchain_events.output.json +2590 -978
- package/dist/schemas/onchain_events.schema.json +117 -99
- package/dist/schemas/onchain_operations.output.json +3957 -2312
- package/dist/schemas/onchain_operations.schema.json +20799 -9285
- package/dist/schemas/onchain_operations_allocation.schema.json +171 -107
- package/dist/schemas/onchain_operations_arbitration.schema.json +233 -146
- package/dist/schemas/onchain_operations_contact.schema.json +129 -90
- package/dist/schemas/onchain_operations_demand.schema.json +170 -112
- package/dist/schemas/onchain_operations_gen_passport.schema.json +61 -646
- package/dist/schemas/onchain_operations_gen_proof.schema.json +40 -172
- package/dist/schemas/onchain_operations_guard.schema.json +3765 -294
- package/dist/schemas/onchain_operations_machine.schema.json +536 -163
- package/dist/schemas/onchain_operations_order.schema.json +126 -96
- package/dist/schemas/onchain_operations_payment.schema.json +82 -67
- package/dist/schemas/onchain_operations_permission.schema.json +331 -93
- package/dist/schemas/onchain_operations_personal.schema.json +636 -96
- package/dist/schemas/onchain_operations_progress.schema.json +125 -92
- package/dist/schemas/onchain_operations_proof.schema.json +76 -69
- package/dist/schemas/onchain_operations_repository.schema.json +636 -249
- package/dist/schemas/onchain_operations_reward.schema.json +218 -108
- package/dist/schemas/onchain_operations_service.schema.json +678 -220
- package/dist/schemas/onchain_operations_treasury.schema.json +401 -135
- package/dist/schemas/onchain_table_data.output.json +6833 -2432
- package/dist/schemas/onchain_table_data.schema.json +684 -417
- package/dist/schemas/permission_operation.output.json +173 -0
- package/dist/schemas/permission_operation.schema.json +39 -0
- package/dist/schemas/persona_operation.output.json +1568 -268
- package/dist/schemas/persona_operation.schema.json +346 -205
- package/dist/schemas/project_operation.output.json +6922 -5132
- package/dist/schemas/project_operation.schema.json +1050 -1020
- package/dist/schemas/query_task_status.output.json +195 -99
- package/dist/schemas/query_task_status.schema.json +12 -18
- package/dist/schemas/query_toolkit.output.json +18862 -14561
- package/dist/schemas/query_toolkit.schema.json +614 -522
- package/dist/schemas/schema_query.output.json +127 -129
- package/dist/schemas/schema_query.schema.json +64 -69
- package/dist/schemas/trust_score.output.json +678 -587
- package/dist/schemas/trust_score.schema.json +289 -277
- package/dist/schemas/wip_file.output.json +116 -124
- package/dist/schemas/wip_file.schema.json +142 -143
- package/dist/schemas/workflow_operation.output.json +164 -0
- package/dist/schemas/workflow_operation.schema.json +116 -0
- package/dist/schemas/workspace_operation.output.json +277 -0
- package/dist/schemas/workspace_operation.schema.json +45 -0
- package/dist/schemas/wowok_buildin_info.output.json +1682 -844
- package/dist/schemas/wowok_buildin_info.schema.json +576 -526
- package/dist/tools/handlers/bridge.d.ts +8 -1
- package/dist/tools/handlers/bridge.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/employee.d.ts +2 -0
- package/dist/tools/handlers/employee.js +1 -0
- package/dist/tools/handlers/evaluation.js +1 -1
- package/dist/tools/handlers/file-export.js +1 -1
- package/dist/tools/handlers/industry-pack.d.ts +2 -0
- package/dist/tools/handlers/industry-pack.js +1 -0
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/permission.d.ts +2 -0
- package/dist/tools/handlers/permission.js +1 -0
- package/dist/tools/handlers/persona.js +1 -1
- package/dist/tools/handlers/project.js +1 -1
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/schema-query.js +1 -1
- package/dist/tools/handlers/trust.js +1 -1
- package/dist/tools/handlers/wip.js +1 -1
- package/dist/tools/handlers/workflow.d.ts +2 -0
- package/dist/tools/handlers/workflow.js +1 -0
- package/dist/tools/handlers/workspace.d.ts +4 -0
- package/dist/tools/handlers/workspace.js +1 -0
- package/dist/tools/index.d.ts +2 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/rules-hook.d.ts +1 -1
- package/dist/tools/rules-hook.js +1 -1
- package/dist/tools/shared.d.ts +1 -1
- package/dist/tools/shared.js +1 -1
- package/dist/tools/types.d.ts +2 -1
- package/package.json +4 -5
- package/dist/knowledge/arbitration-trust.d.ts +0 -24
- package/dist/knowledge/arbitration-trust.js +0 -1
- package/dist/schema/call/bridge-handler.d.ts +0 -8
- package/dist/schema/call/bridge-handler.js +0 -1
- package/dist/schema/sync-layer4.d.ts +0 -21
- package/dist/schema/sync-layer4.js +0 -1
- /package/dist/{schema-query → schema-query-impl}/index.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const DEFAULT_RESPONSE_BUDGET_MS=0x30*0x3c*0x3c*0x3e8;export function assessReactionKpi(a,b,c,d=DEFAULT_RESPONSE_BUDGET_MS){if(c===undefined)return{'node':a,'reaction_ms':-0x1,'within_budget':![],'status':'warn'};const e=c-b,f=e<=d;return{'node':a,'reaction_ms':e,'within_budget':f,'status':f?'pass':'fail'};}export function resolveLiability(a,b,c=0x0){let d;switch(a){case'merchant_bears':d='merchant';break;case'self_bears':d='employee';break;case'hybrid':default:d=b>c?'employee':'merchant';break;}return{'bears':d,'must_compensate_before_resume':b>0x0,'note':d==='merchant'?'Merchant\x20bears\x20the\x20'+b+'\x20loss;\x20employee\x20error\x20is\x20attributed\x20to\x20the\x20merchant\x27s\x20problem\x20list\x20in\x20arbitration.':'Employee\x20bears\x20the\x20'+b+'\x20loss\x20(serious\x20negligence);\x20the\x20order\x20user\x20is\x20compensated\x20first,\x20then\x20the\x20workflow\x20resumes.'};}export function validateEmployeeProfile(a){const b=[];if(!a['department'])b['push']('department\x20is\x20required');if(!a['liability'])b['push']('liability\x20is\x20required');return a['response_time_budget_ms']!==undefined&&a['response_time_budget_ms']<=0x0&&b['push']('response_time_budget_ms\x20must\x20be\x20a\x20positive\x20number'),{'valid':b['length']===0x0,'issues':b};}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SQLiteStorage } from "@wowok/wowok";
|
|
2
|
+
import { type EmployeeProfile } from "./employee-kpi.js";
|
|
3
|
+
export interface EmployeeStore {
|
|
4
|
+
save(account: string, profile: EmployeeProfile): Promise<void>;
|
|
5
|
+
get(account: string): Promise<EmployeeProfile | null>;
|
|
6
|
+
remove(account: string): Promise<boolean>;
|
|
7
|
+
}
|
|
8
|
+
export declare class SqliteEmployeeStore implements EmployeeStore {
|
|
9
|
+
private readonly kv;
|
|
10
|
+
constructor(kv?: SQLiteStorage);
|
|
11
|
+
save(account: string, profile: EmployeeProfile): Promise<void>;
|
|
12
|
+
get(account: string): Promise<EmployeeProfile | null>;
|
|
13
|
+
remove(account: string): Promise<boolean>;
|
|
14
|
+
}
|
|
15
|
+
export declare function getEmployeeStore(): EmployeeStore;
|
|
16
|
+
export declare function setEmployeeStore(store: EmployeeStore): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{SQLiteStorage}from'@wowok/wowok';import{validateEmployeeProfile}from'./employee-kpi.js';const KEY_PREFIX='employee_profile:';function parse(a){try{const b=JSON['parse'](a);return validateEmployeeProfile(b)['valid']?b:null;}catch{return null;}}export class SqliteEmployeeStore{['kv'];constructor(a){this['kv']=a??new SQLiteStorage();}async['save'](a,b){const c=validateEmployeeProfile(b);if(!c['valid'])throw new Error('invalid\x20employee\x20profile:\x20'+c['issues']['join'](';\x20'));await this['kv']['put'](''+KEY_PREFIX+a,JSON['stringify'](b));}async['get'](a){const b=await this['kv']['get'](''+KEY_PREFIX+a);return b?parse(b):null;}async['remove'](a){const b=''+KEY_PREFIX+a,c=await this['kv']['get'](b)!==undefined;if(c)await this['kv']['del'](b);return c;}}let _store=null;export function getEmployeeStore(){if(!_store)_store=new SqliteEmployeeStore();return _store;}export function setEmployeeStore(a){_store=a;}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from'./employee-kpi.js';export*from'./employee-store.js';
|
package/dist/persona/defaults.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getDefaultPreferences}from'../customer/user-preferences.js';import{PERSONA_VERSION}from'./types.js';function safePrefs(a){const {budget_range:b,...c}=a;return c;}function industryPrefs(a){return safePrefs(getDefaultPreferences(a));}const SPECS=[{'role':'merchant','industry':'freelance','strategy':['Deliver\x20in\x20milestones\x20and\x20release\x20per\x20milestone\x20(avoid\x20all-or-nothing\x20non-acceptance).','Record\x20WIP\x20hash\x20at\x20each\x20key\x20node\x20as\x20evidence.','Use\x20an\x20accept_guard\x20time\x20gate\x20so\x20non-accepting\x20clients\x20auto-release\x20after\x20the\x20deadline.'],'requirements':['must\x20have\x20arbitration','must\x20have\x20a\x20compensation\x20fund','forbid\x20full\x20upfront\x20payment\x20before\x20any\x20delivery']},{'role':'customer','industry':'freelance','strategy':['Pay\x20per\x20milestone,\x20verify\x20each\x20before\x20releasing\x20the\x20next.','Verify\x20WIP\x20hash\x20before\x20accepting\x20a\x20delivery.','Open\x20arbitration\x20if\x20the\x20provider\x20is\x20unresponsive.'],'requirements':['must\x20have\x20arbitration','must\x20have\x20a\x20compensation\x20fund','forbid\x20direct\x20payment\x20without\x20escrow']},{'role':'merchant','industry':'rental','strategy':['Record\x20pre/post\x20rental\x20WIP\x20hashes\x20as\x20the\x20damage-claim\x20baseline.','Hold\x20the\x20deposit\x20in\x20a\x20graded\x20allocator\x20(normal\x20return\x20auto-releases).','Keep\x20an\x20evidence\x20chain\x20for\x20any\x20damage\x20claim.'],'requirements':['must\x20have\x20arbitration','damage\x20claims\x20require\x20pre-rental\x20baseline\x20evidence']},{'role':'customer','industry':'rental','strategy':['Record\x20condition\x20evidence\x20(WIP\x20hash)\x20before\x20renting.','Confirm\x20the\x20return\x20only\x20after\x20verifying\x20no\x20damage.','Open\x20arbitration\x20against\x20unfair\x20damage\x20claims.'],'requirements':['must\x20have\x20arbitration','deposit\x20must\x20be\x20refundable\x20(a\x20return\x20path\x20must\x20exist)']},{'role':'merchant','industry':'education','strategy':['Release\x20tuition\x20per\x20lesson\x20(1/N)\x20to\x20structurally\x20prevent\x20run-away\x20disputes.','Keep\x20attendance/completion\x20evidence.','Declare\x20the\x20refund\x20policy\x20up\x20front.'],'requirements':['must\x20have\x20arbitration','tuition\x20must\x20be\x20escrowed\x20(not\x20directly\x20received)']},{'role':'customer','industry':'education','strategy':['Pay\x20per\x20lesson,\x20never\x20full\x20upfront.','Confirm\x20completed\x20lessons\x20before\x20paying.','Request\x20proportional\x20refund\x20if\x20the\x20course\x20is\x20cancelled.'],'requirements':['must\x20have\x20arbitration','forbid\x20one-time\x20full\x20upfront\x20payment']},{'role':'merchant','industry':'travel','strategy':['Model\x20multi-leg\x20trips\x20as\x20a\x20multi-leg\x20machine\x20with\x20a\x20transparent\x20fund\x20waterfall.','Declare\x20the\x20cancellation\x20policy\x20up\x20front.','Separate\x20refundable\x20vs\x20non-refundable\x20legs.'],'requirements':['must\x20have\x20arbitration','funds\x20must\x20be\x20escrowed\x20(conditionally\x20released)']},{'role':'customer','industry':'travel','strategy':['Confirm\x20the\x20cancellation/refund\x20policy\x20before\x20booking.','Watch\x20cross-leg\x20responsibility\x20in\x20multi-leg\x20trips.','Pursue\x20the\x20non-refundable\x20downstream\x20on\x20flight\x20cancellation.'],'requirements':['must\x20have\x20arbitration','cancellation\x20must\x20be\x20refundable\x20(a\x20refund\x20path\x20must\x20exist)']},{'role':'merchant','industry':'subscription','strategy':['Charge\x20each\x20period\x20via\x20charge_guard_signer\x20(explicit\x20user\x20signature).','Keep\x20100%\x20of\x20revenue\x20(no\x20platform\x20cut).','Declare\x20pauses/cancellation\x20explicitly.'],'requirements':['forbid\x20auto-renewal\x20traps\x20(every\x20period\x20must\x20be\x20explicitly\x20signed)']},{'role':'customer','industry':'subscription','strategy':['Confirm\x20authorization\x20before\x20each\x20charge.','Cancel\x20anytime\x20without\x20friction.','Stop\x20charging\x20when\x20the\x20creator\x20pauses.'],'requirements':['forbid\x20auto-renewal\x20(every\x20period\x20must\x20be\x20explicitly\x20signed)','cancellation\x20must\x20be\x20frictionless']},{'role':'merchant','industry':'retail','strategy':['Release\x20funds\x20on\x20confirmed\x20receipt\x20(escrow).','Keep\x20an\x20evidence\x20chain\x20for\x20authenticity\x20disputes.','Declare\x20the\x20return\x20policy\x20up\x20front.'],'requirements':['must\x20have\x20arbitration','funds\x20must\x20be\x20escrowed\x20(released\x20on\x20confirmed\x20receipt)']},{'role':'customer','industry':'retail','strategy':['Verify\x20authenticity\x20before\x20confirming\x20receipt.','Never\x20confirm\x20receipt\x20before\x20the\x20goods\x20arrive.','Open\x20arbitration\x20for\x20counterfeit\x20/\x20not-received.'],'requirements':['must\x20have\x20arbitration','not-received\x20must\x20be\x20refundable']}];function buildDefault(a){const b=a['industry']?[a['industry']]:[],c={'identity':{'self_description':a['role']+'\x20in\x20'+(a['industry']??'any')+'\x20industry'},'preferences':a['industry']?industryPrefs(a['industry']):{}},d={'strategy':a['strategy'],'requirements':a['requirements']};return{'version':PERSONA_VERSION,'scope':'system','role':a['role'],'industries':b,'long_term':c,'current':d,'updated_at':0x0};}const GENERIC_ROLE_SPECS=[{'role':'arbitrator','strategy':['Confirm\x20cases\x20promptly\x20to\x20keep\x20the\x20dispute\x20pipeline\x20moving\x20(efficiency\x20+\x20fee\x20throughput).','Verify\x20all\x20evidence\x20(WTS)\x20before\x20ruling\x20—\x20unverified\x20evidence\x20is\x20not\x20evidence.','Write\x20reasoned,\x20professional\x20feedback\x20—\x20it\x20is\x20permanently\x20public\x20on-chain\x20(reputation).','Reset\x20unclear\x20cases\x20back\x20with\x20clear\x20feedback\x20rather\x20than\x20guessing.'],'requirements':['must\x20verify\x20evidence\x20(WTS)\x20before\x20ruling','forbid\x20ruling\x20without\x20verified\x20evidence']},{'role':'supplier','strategy':['Deliver\x20the\x20sub-order\x20and\x20retain\x20per-tier\x20sub-delivery\x20proof.','Settle\x20independently\x20per\x20verified\x20tier\x20(not\x20bundled\x20with\x20the\x20main\x20order).','Keep\x20an\x20evidence\x20chain\x20for\x20any\x20sub-delivery\x20dispute.'],'requirements':['sub-delivery\x20must\x20be\x20provable\x20(per-tier\x20release\x20guard)','must\x20have\x20independent\x20allocation\x20for\x20sub-order\x20settlement']},{'role':'collaborator','strategy':['Advance\x20only\x20the\x20forwards\x20within\x20your\x20permission\x20scope.','Advance\x20promptly\x20to\x20keep\x20the\x20workflow\x20moving\x20(avoid\x20stall\x20penalties).','Avoid\x20interfering\x20outside\x20your\x20permission\x20scope\x20(creates\x20responsibility\x20without\x20authority).'],'requirements':['only\x20operate\x20authorized\x20forwards\x20(permission\x20index\x20/\x20named\x20operator)','forbid\x20operating\x20outside\x20your\x20permission\x20scope']},{'role':'prospect','strategy':['Verify\x20fund\x20safety\x20(escrow\x20+\x20refund\x20path)\x20before\x20ordering.','Verify\x20delivery\x20trust\x20(WIP\x20hash,\x20machine\x20workflow)\x20before\x20ordering.','Check\x20arbitration\x20availability\x20for\x20recourse\x20before\x20committing.'],'requirements':['must\x20have\x20arbitration','must\x20have\x20a\x20refund\x20path']}],DEFAULTS=[...SPECS,...GENERIC_ROLE_SPECS]['map'](buildDefault);export const GENERIC_PERSONA={'version':PERSONA_VERSION,'scope':'system','role':'customer','industries':[],'long_term':{'identity':{'self_description':'generic\x20WoWok\x20user'}},'current':{},'updated_at':0x0};
|
|
1
|
+
import{getDefaultPreferences}from'../customer/user-preferences.js';import{getIndustryPersona,registerIndustryPersonae}from'./pack-personae.js';import{PERSONA_VERSION}from'./types.js';function safePrefs(a){const {budget_range:b,...c}=a;return c;}function industryPrefs(a){return safePrefs(getDefaultPreferences(a));}const SPECS=[{'role':'merchant','industry':'freelance','strategy':['Deliver\x20in\x20milestones\x20and\x20release\x20per\x20milestone\x20(avoid\x20all-or-nothing\x20non-acceptance).','Record\x20WIP\x20hash\x20at\x20each\x20key\x20node\x20as\x20evidence.','Use\x20an\x20accept_guard\x20time\x20gate\x20so\x20non-accepting\x20clients\x20auto-release\x20after\x20the\x20deadline.'],'requirements':['must\x20have\x20arbitration','must\x20have\x20a\x20compensation\x20fund','forbid\x20full\x20upfront\x20payment\x20before\x20any\x20delivery']},{'role':'customer','industry':'freelance','strategy':['Pay\x20per\x20milestone,\x20verify\x20each\x20before\x20releasing\x20the\x20next.','Verify\x20WIP\x20hash\x20before\x20accepting\x20a\x20delivery.','Open\x20arbitration\x20if\x20the\x20provider\x20is\x20unresponsive.'],'requirements':['must\x20have\x20arbitration','must\x20have\x20a\x20compensation\x20fund','forbid\x20direct\x20payment\x20without\x20escrow']},{'role':'merchant','industry':'rental','strategy':['Record\x20pre/post\x20rental\x20WIP\x20hashes\x20as\x20the\x20damage-claim\x20baseline.','Hold\x20the\x20deposit\x20in\x20a\x20graded\x20allocator\x20(normal\x20return\x20auto-releases).','Keep\x20an\x20evidence\x20chain\x20for\x20any\x20damage\x20claim.'],'requirements':['must\x20have\x20arbitration','damage\x20claims\x20require\x20pre-rental\x20baseline\x20evidence']},{'role':'customer','industry':'rental','strategy':['Record\x20condition\x20evidence\x20(WIP\x20hash)\x20before\x20renting.','Confirm\x20the\x20return\x20only\x20after\x20verifying\x20no\x20damage.','Open\x20arbitration\x20against\x20unfair\x20damage\x20claims.'],'requirements':['must\x20have\x20arbitration','deposit\x20must\x20be\x20refundable\x20(a\x20return\x20path\x20must\x20exist)']},{'role':'merchant','industry':'education','strategy':['Release\x20tuition\x20per\x20lesson\x20(1/N)\x20to\x20structurally\x20prevent\x20run-away\x20disputes.','Keep\x20attendance/completion\x20evidence.','Declare\x20the\x20refund\x20policy\x20up\x20front.'],'requirements':['must\x20have\x20arbitration','tuition\x20must\x20be\x20escrowed\x20(not\x20directly\x20received)']},{'role':'customer','industry':'education','strategy':['Pay\x20per\x20lesson,\x20never\x20full\x20upfront.','Confirm\x20completed\x20lessons\x20before\x20paying.','Request\x20proportional\x20refund\x20if\x20the\x20course\x20is\x20cancelled.'],'requirements':['must\x20have\x20arbitration','forbid\x20one-time\x20full\x20upfront\x20payment']},{'role':'merchant','industry':'travel','strategy':['Model\x20multi-leg\x20trips\x20as\x20a\x20multi-leg\x20machine\x20with\x20a\x20transparent\x20fund\x20waterfall.','Declare\x20the\x20cancellation\x20policy\x20up\x20front.','Separate\x20refundable\x20vs\x20non-refundable\x20legs.'],'requirements':['must\x20have\x20arbitration','funds\x20must\x20be\x20escrowed\x20(conditionally\x20released)']},{'role':'customer','industry':'travel','strategy':['Confirm\x20the\x20cancellation/refund\x20policy\x20before\x20booking.','Watch\x20cross-leg\x20responsibility\x20in\x20multi-leg\x20trips.','Pursue\x20the\x20non-refundable\x20downstream\x20on\x20flight\x20cancellation.'],'requirements':['must\x20have\x20arbitration','cancellation\x20must\x20be\x20refundable\x20(a\x20refund\x20path\x20must\x20exist)']},{'role':'merchant','industry':'subscription','strategy':['Charge\x20each\x20period\x20via\x20charge_guard_signer\x20(explicit\x20user\x20signature).','Keep\x20100%\x20of\x20revenue\x20(no\x20platform\x20cut).','Declare\x20pauses/cancellation\x20explicitly.'],'requirements':['forbid\x20auto-renewal\x20traps\x20(every\x20period\x20must\x20be\x20explicitly\x20signed)']},{'role':'customer','industry':'subscription','strategy':['Confirm\x20authorization\x20before\x20each\x20charge.','Cancel\x20anytime\x20without\x20friction.','Stop\x20charging\x20when\x20the\x20creator\x20pauses.'],'requirements':['forbid\x20auto-renewal\x20(every\x20period\x20must\x20be\x20explicitly\x20signed)','cancellation\x20must\x20be\x20frictionless']},{'role':'merchant','industry':'retail','strategy':['Release\x20funds\x20on\x20confirmed\x20receipt\x20(escrow).','Keep\x20an\x20evidence\x20chain\x20for\x20authenticity\x20disputes.','Declare\x20the\x20return\x20policy\x20up\x20front.'],'requirements':['must\x20have\x20arbitration','funds\x20must\x20be\x20escrowed\x20(released\x20on\x20confirmed\x20receipt)']},{'role':'customer','industry':'retail','strategy':['Verify\x20authenticity\x20before\x20confirming\x20receipt.','Never\x20confirm\x20receipt\x20before\x20the\x20goods\x20arrive.','Open\x20arbitration\x20for\x20counterfeit\x20/\x20not-received.'],'requirements':['must\x20have\x20arbitration','not-received\x20must\x20be\x20refundable']}];function buildDefault(a){const b=a['industry']?[a['industry']]:[],c={'identity':{'self_description':a['role']+'\x20in\x20'+(a['industry']??'any')+'\x20industry'},'preferences':a['industry']?industryPrefs(a['industry']):{}},d={'strategy':a['strategy'],'requirements':a['requirements']};return{'version':PERSONA_VERSION,'scope':'system','role':a['role'],'industries':b,'long_term':c,'current':d,'updated_at':0x0};}const GENERIC_ROLE_SPECS=[{'role':'arbitrator','strategy':['Confirm\x20cases\x20promptly\x20to\x20keep\x20the\x20dispute\x20pipeline\x20moving\x20(efficiency\x20+\x20fee\x20throughput).','Verify\x20all\x20evidence\x20(WTS)\x20before\x20ruling\x20—\x20unverified\x20evidence\x20is\x20not\x20evidence.','Write\x20reasoned,\x20professional\x20feedback\x20—\x20it\x20is\x20permanently\x20public\x20on-chain\x20(reputation).','Reset\x20unclear\x20cases\x20back\x20with\x20clear\x20feedback\x20rather\x20than\x20guessing.'],'requirements':['must\x20verify\x20evidence\x20(WTS)\x20before\x20ruling','forbid\x20ruling\x20without\x20verified\x20evidence']},{'role':'supplier','strategy':['Deliver\x20the\x20sub-order\x20and\x20retain\x20per-tier\x20sub-delivery\x20proof.','Settle\x20independently\x20per\x20verified\x20tier\x20(not\x20bundled\x20with\x20the\x20main\x20order).','Keep\x20an\x20evidence\x20chain\x20for\x20any\x20sub-delivery\x20dispute.'],'requirements':['sub-delivery\x20must\x20be\x20provable\x20(per-tier\x20release\x20guard)','must\x20have\x20independent\x20allocation\x20for\x20sub-order\x20settlement']},{'role':'collaborator','strategy':['Advance\x20only\x20the\x20forwards\x20within\x20your\x20permission\x20scope.','Advance\x20promptly\x20to\x20keep\x20the\x20workflow\x20moving\x20(avoid\x20stall\x20penalties).','Avoid\x20interfering\x20outside\x20your\x20permission\x20scope\x20(creates\x20responsibility\x20without\x20authority).'],'requirements':['only\x20operate\x20authorized\x20forwards\x20(permission\x20index\x20/\x20named\x20operator)','forbid\x20operating\x20outside\x20your\x20permission\x20scope']},{'role':'prospect','strategy':['Verify\x20fund\x20safety\x20(escrow\x20+\x20refund\x20path)\x20before\x20ordering.','Verify\x20delivery\x20trust\x20(WIP\x20hash,\x20machine\x20workflow)\x20before\x20ordering.','Check\x20arbitration\x20availability\x20for\x20recourse\x20before\x20committing.'],'requirements':['must\x20have\x20arbitration','must\x20have\x20a\x20refund\x20path']}],DEFAULTS=[...SPECS,...GENERIC_ROLE_SPECS]['map'](buildDefault);export const GENERIC_PERSONA={'version':PERSONA_VERSION,'scope':'system','role':'customer','industries':[],'long_term':{'identity':{'self_description':'generic\x20WoWok\x20user'}},'current':{},'updated_at':0x0};function personaToIndustryPersona(a){if(a['industries']['length']===0x0)return null;return{'role':a['role'],'industry':a['industries'][0x0],'long_term':a['long_term'],'current':a['current']};}function industryPersonaToPersona(a){return{'version':PERSONA_VERSION,'scope':'system','role':a['role'],'industries':[a['industry']],'long_term':a['long_term'],'current':a['current'],'updated_at':0x0};}const builtinPersonaeByIndustry=new Map();for(const p of DEFAULTS){const ip=personaToIndustryPersona(p);if(!ip)continue;const list=builtinPersonaeByIndustry['get'](ip['industry'])??[];list['push'](ip),builtinPersonaeByIndustry['set'](ip['industry'],list);}for(const [industry,personae]of builtinPersonaeByIndustry){registerIndustryPersonae(industry,personae);}export function getIndustryDefault(a,b){const c=getIndustryPersona(b,a);if(c)return industryPersonaToPersona(c);const d=DEFAULTS['find'](e=>e['role']===a&&e['industries']['length']===0x0);if(d)return{...d};return{...GENERIC_PERSONA,'role':a};}export function listIndustryDefaults(){return DEFAULTS['map'](a=>({...a}));}
|
package/dist/persona/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type PersonaAnalysis } from "./analyzer.js";
|
|
2
|
-
import type { EffectivePersona, Industry, Persona, PersonaLayer, PersonaRole, PersonaScope } from "./types.js";
|
|
2
|
+
import type { EffectivePersona, Industry, Persona, PersonaLayer, PersonaRole, PersonaScope, SystemOverrideValue } from "./types.js";
|
|
3
3
|
import type { UserProfile } from "../experience/types.js";
|
|
4
4
|
export { GENERIC_PERSONA, getIndustryDefault, listIndustryDefaults } from "./defaults.js";
|
|
5
5
|
export { SqlitePersonaStore, getPersonaStore, setPersonaStore } from "./store.js";
|
|
@@ -7,8 +7,15 @@ export { countPersonaLines, emptyPersona, mergeLayers, mutateLayer, resolveEffec
|
|
|
7
7
|
export { personaToContextText, personaToInjection, mergeInjections } from "./bridge.js";
|
|
8
8
|
export { analyzePersonaContext } from "./analyzer.js";
|
|
9
9
|
export { profileToCurrentLayer } from "./experience-bridge.js";
|
|
10
|
-
export
|
|
10
|
+
export { registerIndustryPersonae, getIndustryPersona, listPersonaeIndustries, unregisterIndustryPersonae } from "./pack-personae.js";
|
|
11
|
+
export type { IndustryPersona } from "./pack-personae.js";
|
|
12
|
+
export { resolveOverrides, validateLayerOverrides, getOverrideDefault, SYSTEM_OVERRIDE_SETTINGS, } from "./overrides.js";
|
|
13
|
+
export type { SystemOverrideSetting } from "./overrides.js";
|
|
14
|
+
export * from "./strategy-intent.js";
|
|
15
|
+
export * from "./local-region.js";
|
|
16
|
+
export type { EffectivePersona, Industry, Persona, PersonaIdentity, PersonaLayer, PersonaMutationMode, PersonaRole, PersonaScope, SystemOverrideValue, } from "./types.js";
|
|
11
17
|
export declare function getEffectivePersona(account?: string, industry?: Industry, role?: PersonaRole): Promise<EffectivePersona>;
|
|
18
|
+
export declare function resolveEffectiveOverrides(account?: string): Promise<Record<string, SystemOverrideValue>>;
|
|
12
19
|
export declare function analysisToLayerDelta(analysis: PersonaAnalysis): PersonaLayer;
|
|
13
20
|
export declare function applyAnalysisToCurrent(scope: PersonaScope, account: string | undefined, analysis: PersonaAnalysis, mode?: "merge" | "replace", role?: PersonaRole, industries?: Industry[]): Promise<Persona>;
|
|
14
21
|
export declare function syncExperienceToCurrent(account?: string, profile?: UserProfile): Promise<{
|
package/dist/persona/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{GENERIC_PERSONA,getIndustryDefault}from'./defaults.js';import{getPersonaStore}from'./store.js';import{emptyPersona,mutateLayer,resolveEffective,validatePersona}from'./model.js';import{profileToCurrentLayer}from'./experience-bridge.js';import{getProfile}from'../experience/index.js';export{GENERIC_PERSONA,getIndustryDefault,listIndustryDefaults}from'./defaults.js';export{SqlitePersonaStore,getPersonaStore,setPersonaStore}from'./store.js';export{countPersonaLines,emptyPersona,mergeLayers,mutateLayer,resolveEffective,validatePersona}from'./model.js';export{personaToContextText,personaToInjection,mergeInjections}from'./bridge.js';export{analyzePersonaContext}from'./analyzer.js';export{profileToCurrentLayer}from'./experience-bridge.js';export async function getEffectivePersona(a,b,c){const d=getPersonaStore(),e=await d['get']('system'),f=a?await d['get']('account',a):null,g=b?
|
|
1
|
+
import{GENERIC_PERSONA,getIndustryDefault}from'./defaults.js';import{getPersonaStore}from'./store.js';import{emptyPersona,mergeLayers,mutateLayer,resolveEffective,validatePersona}from'./model.js';import{getIndustryPersona}from'./pack-personae.js';import{resolveOverrides}from'./overrides.js';import{profileToCurrentLayer}from'./experience-bridge.js';import{getProfile}from'../experience/index.js';export{GENERIC_PERSONA,getIndustryDefault,listIndustryDefaults}from'./defaults.js';export{SqlitePersonaStore,getPersonaStore,setPersonaStore}from'./store.js';export{countPersonaLines,emptyPersona,mergeLayers,mutateLayer,resolveEffective,validatePersona}from'./model.js';export{personaToContextText,personaToInjection,mergeInjections}from'./bridge.js';export{analyzePersonaContext}from'./analyzer.js';export{profileToCurrentLayer}from'./experience-bridge.js';export{registerIndustryPersonae,getIndustryPersona,listPersonaeIndustries,unregisterIndustryPersonae}from'./pack-personae.js';export{resolveOverrides,validateLayerOverrides,getOverrideDefault,SYSTEM_OVERRIDE_SETTINGS}from'./overrides.js';export*from'./strategy-intent.js';export*from'./local-region.js';export async function getEffectivePersona(a,b,c){const d=getPersonaStore(),e=await d['get']('system'),f=a?await d['get']('account',a):null,g=b?mergeIndustryExternal(c??'customer',b):{...GENERIC_PERSONA,'role':c??'customer'};return resolveEffective(e,f,g);}function mergeIndustryExternal(a,b){const c=getIndustryDefault(a,b),d=getIndustryPersona(b,a);if(!d)return c;return{...c,'long_term':mergeLayers([c['long_term'],d['long_term']]),'current':mergeLayers([c['current'],d['current']])};}export async function resolveEffectiveOverrides(a){const b=getPersonaStore(),c=await b['get']('system'),d=a?await b['get']('account',a):null,e=[];if(c)e['push'](c['long_term'],c['current']);if(d)e['push'](d['long_term'],d['current']);return resolveOverrides(e);}export function analysisToLayerDelta(a){const b={};a['preferences']&&Object['keys'](a['preferences'])['length']&&(b['preferences']=a['preferences']);if(a['requirements']['length'])b['requirements']=a['requirements'];if(a['rules']['length'])b['rules']=a['rules'];return b;}export async function applyAnalysisToCurrent(a,b,c,d='merge',e,f){const g=getPersonaStore(),h=a==='account'&&b?await g['get']('account',b):await g['get']('system'),i=e??c['role']??h?.['role']??'customer',j=f??c['industries'],k=h??emptyPersona(a,b,i,j),l=Array['from'](new Set([...k['industries'],...j??[]])),m=analysisToLayerDelta(c),n=mutateLayer(k['current'],m,d),o={...k,'role':i,'industries':l,'current':n,'updated_at':Date['now']()},p=validatePersona(o);if(p['length']>0x0)throw new Error('persona\x20invalid\x20after\x20apply:\x20'+p['join'](';\x20'));return await g['put'](o),o;}export async function syncExperienceToCurrent(a,b){const c=getPersonaStore(),d=a?'account':'system',e=a?await c['get']('account',a):await c['get']('system'),f=e??emptyPersona(d,a,'customer',[]),g=profileToCurrentLayer(b??getProfile()),h=mutateLayer(f['current'],g,'merge'),i={...f,'current':h,'updated_at':Date['now']()},j=validatePersona(i);if(j['length']>0x0)throw new Error('persona\x20invalid\x20after\x20sync:\x20'+j['join'](';\x20'));return await c['put'](i),{'persona':i,'applied':g,'effective':await getEffectivePersona(a)};}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Region } from "../evaluation/region.js";
|
|
2
|
+
export declare const LOCAL_INFO_ADDRESS_NAME = "Address of delivery";
|
|
3
|
+
export interface LocalRegionHint {
|
|
4
|
+
region: Region;
|
|
5
|
+
source: "local_info";
|
|
6
|
+
raw: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function resolveLocalRegion(): Promise<LocalRegionHint | undefined>;
|
|
9
|
+
export interface LocalRegionSaveProposal {
|
|
10
|
+
requires_user_consent: true;
|
|
11
|
+
raw: string;
|
|
12
|
+
region: Region;
|
|
13
|
+
review: string;
|
|
14
|
+
store_via: "local_info_operation";
|
|
15
|
+
info: {
|
|
16
|
+
name: string;
|
|
17
|
+
default: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export declare function proposeLocalRegionSave(raw: string): LocalRegionSaveProposal;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{query_local_info_list}from'@wowok/wowok';import{parseRegion}from'../evaluation/region.js';export const LOCAL_INFO_ADDRESS_NAME='Address\x20of\x20delivery';export async function resolveLocalRegion(){const a=await query_local_info_list({'name':LOCAL_INFO_ADDRESS_NAME}),b=a?.[0x0],c=b?.['default'];if(!c)return undefined;return{'region':parseRegion(c),'source':'local_info','raw':c};}export function proposeLocalRegionSave(a){const b=a?.['trim']()??'';return{'requires_user_consent':!![],'raw':b,'region':parseRegion(b),'review':'User\x20must\x20confirm\x20this\x20address\x20is\x20correct\x20before\x20it\x20is\x20stored\x20locally.','store_via':'local_info_operation','info':{'name':LOCAL_INFO_ADDRESS_NAME,'default':b}};}
|
package/dist/persona/model.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PERSONA_MAX_LINES,PERSONA_ROLES,PERSONA_VERSION}from'./types.js';function dedupe(a){return Array['from'](new Set(a['filter'](b=>typeof b==='string'&&b['length']>0x0)));}export function mergeLayers(a){const b={};for(const c of a){if(!c)continue;c['identity']&&(b['identity']={...b['identity'],...c['identity']},c['identity']['languages']&&(b['identity']['languages']=dedupe([...b['identity']['languages']??[],...c['identity']['languages']]))),c['preferences']&&(b['preferences']={...b['preferences'],...c['preferences']}),c['strategy']&&(b['strategy']=dedupe([...b['strategy']??[],...c['strategy']])),c['rules']&&(b['rules']=dedupe([...b['rules']??[],...c['rules']])),c['requirements']&&(b['requirements']=dedupe([...b['requirements']??[],...c['requirements']])),c['spec']&&(b['spec']=[b['spec'],c['spec']]['filter'](Boolean)['join']('\x0a\x0a'));}return b;}export function mutateLayer(a,b,c){if(c==='replace')return{...b};return mergeLayers([a,b]);}export function resolveEffective(a,b,c){const d=[],e=[];
|
|
1
|
+
import{PERSONA_MAX_LINES,PERSONA_ROLES,PERSONA_VERSION}from'./types.js';import{validateLayerOverrides}from'./overrides.js';function dedupe(a){return Array['from'](new Set(a['filter'](b=>typeof b==='string'&&b['length']>0x0)));}export function mergeLayers(a){const b={};for(const c of a){if(!c)continue;c['identity']&&(b['identity']={...b['identity'],...c['identity']},c['identity']['languages']&&(b['identity']['languages']=dedupe([...b['identity']['languages']??[],...c['identity']['languages']]))),c['preferences']&&(b['preferences']={...b['preferences'],...c['preferences']}),c['overrides']&&(b['overrides']={...b['overrides'],...c['overrides']}),c['strategy']&&(b['strategy']=dedupe([...b['strategy']??[],...c['strategy']])),c['rules']&&(b['rules']=dedupe([...b['rules']??[],...c['rules']])),c['requirements']&&(b['requirements']=dedupe([...b['requirements']??[],...c['requirements']])),c['spec']&&(b['spec']=[b['spec'],c['spec']]['filter'](Boolean)['join']('\x0a\x0a'));}return b;}export function mutateLayer(a,b,c){if(c==='replace')return{...b};return mergeLayers([a,b]);}export function resolveEffective(a,b,c){const d=[],e=[];a&&(d['push'](a['long_term']),e['push']({'scope':'system','part':'long_term'}),d['push'](a['current']),e['push']({'scope':'system','part':'current'}));c&&(d['push'](c['long_term']),e['push']({'scope':c['scope'],'part':'long_term'}),d['push'](c['current']),e['push']({'scope':c['scope'],'part':'current'}));b&&(d['push'](b['long_term']),e['push']({'scope':'account','account':b['account'],'part':'long_term'}),d['push'](b['current']),e['push']({'scope':'account','account':b['account'],'part':'current'}));const f=b??c??a;return{'scope':b?'account':'system','account':b?.['account']??a?.['account'],'role':f?.['role']??'customer','industries':f?.['industries']??[],'layer':mergeLayers(d),'sources':e};}export function countPersonaLines(a){return JSON['stringify'](a,null,0x2)['split']('\x0a')['length'];}export function validatePersona(a){const b=[];a['version']!==PERSONA_VERSION&&b['push']('version\x20must\x20be\x20'+PERSONA_VERSION);a['scope']==='account'&&!a['account']&&b['push']('account\x20is\x20required\x20when\x20scope=account');a['scope']!=='account'&&a['account']&&b['push']('account\x20should\x20only\x20be\x20set\x20when\x20scope=account');(!a['role']||!PERSONA_ROLES['includes'](a['role']))&&b['push']('role\x20must\x20be\x20a\x20persona\x20role\x20(merchant|customer|prospect|supplier|collaborator|arbitrator)');!Array['isArray'](a['industries'])&&b['push']('industries\x20must\x20be\x20an\x20array');b['push'](...validateLayerOverrides(a['long_term'])),b['push'](...validateLayerOverrides(a['current']));const c=countPersonaLines(a);return c>PERSONA_MAX_LINES&&b['push']('persona\x20is\x20'+c+'\x20lines\x20(max\x20'+PERSONA_MAX_LINES+')'),b;}export function emptyPersona(a,b,c,d){return{'version':PERSONA_VERSION,'scope':a,'account':b,'role':c,'industries':d,'long_term':{},'current':{},'updated_at':Date['now']()};}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PersonaLayer, SystemOverrideValue } from "./types.js";
|
|
2
|
+
export interface SystemOverrideSetting {
|
|
3
|
+
id: string;
|
|
4
|
+
default: SystemOverrideValue;
|
|
5
|
+
allowed: readonly SystemOverrideValue[];
|
|
6
|
+
}
|
|
7
|
+
export declare const SYSTEM_OVERRIDE_SETTINGS: readonly SystemOverrideSetting[];
|
|
8
|
+
export declare function validateLayerOverrides(layer: PersonaLayer): string[];
|
|
9
|
+
export declare function resolveOverrides(layers: PersonaLayer[]): Record<string, SystemOverrideValue>;
|
|
10
|
+
export declare function getOverrideDefault(id: string): SystemOverrideValue | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const SYSTEM_OVERRIDE_SETTINGS=[{'id':'service.publish','default':'prompt','allowed':['auto','prompt','block']},{'id':'machine.publish','default':'prompt','allowed':['auto','prompt','block']},{'id':'node.advance','default':'prompt','allowed':['auto','prompt']},{'id':'risk.missing_arbitration','default':'warn','allowed':['block','warn']}];const byId=new Map(SYSTEM_OVERRIDE_SETTINGS['map'](a=>[a['id'],a]));export function validateLayerOverrides(a){const b=[];if(!a['overrides'])return b;for(const [c,d]of Object['entries'](a['overrides'])){const e=byId['get'](c);if(!e){b['push']('override\x20\x27'+c+'\x27\x20is\x20not\x20an\x20overridable\x20system\x20setting');continue;}!e['allowed']['includes'](d)&&b['push']('override\x20\x27'+c+'\x27\x20value\x20\x27'+d+'\x27\x20not\x20allowed\x20(allowed:\x20'+e['allowed']['join']('|')+')');}return b;}export function resolveOverrides(a){const b={};for(const c of a){if(!c['overrides'])continue;for(const [d,e]of Object['entries'](c['overrides'])){if(!byId['has'](d))continue;b[d]=e;}}return b;}export function getOverrideDefault(a){return byId['get'](a)?.['default'];}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PersonaRole, PersonaLayer } from "./types.js";
|
|
2
|
+
export interface IndustryPersona {
|
|
3
|
+
role: PersonaRole;
|
|
4
|
+
industry: string;
|
|
5
|
+
long_term: PersonaLayer;
|
|
6
|
+
current: PersonaLayer;
|
|
7
|
+
}
|
|
8
|
+
export declare function registerIndustryPersonae(industry: string, personae: IndustryPersona[]): void;
|
|
9
|
+
export declare function getIndustryPersona(industry: string, role: PersonaRole): IndustryPersona | undefined;
|
|
10
|
+
export declare function listPersonaeIndustries(): string[];
|
|
11
|
+
export declare function unregisterIndustryPersonae(industry: string): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const personaRegistry=new Map();export function registerIndustryPersonae(a,b){const c=personaRegistry['get'](a)??new Map();for(const d of b){c['set'](d['role'],d);}personaRegistry['set'](a,c);}export function getIndustryPersona(a,b){return personaRegistry['get'](a)?.['get'](b);}export function listPersonaeIndustries(){return Array['from'](personaRegistry['keys']());}export function unregisterIndustryPersonae(a){return personaRegistry['delete'](a);}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CommercialRole } from "../role/types.js";
|
|
2
|
+
export type StrategyObjective = "sales_priority" | "profit_priority" | "buyer_screening" | "gross_margin_control";
|
|
3
|
+
export type InfrastructureLever = "discount" | "reward" | "buy_guard" | "machine_design";
|
|
4
|
+
export interface StrategyIntent {
|
|
5
|
+
objective: StrategyObjective;
|
|
6
|
+
metrics: string[];
|
|
7
|
+
levers: InfrastructureLever[];
|
|
8
|
+
target: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const STRATEGY_LEVER_MAP: Record<StrategyObjective, InfrastructureLever[]>;
|
|
11
|
+
export declare function resolveObjective(text?: string): StrategyObjective | null;
|
|
12
|
+
export declare function buildStrategyIntent(objective: StrategyObjective, target?: string, metrics?: string[]): StrategyIntent;
|
|
13
|
+
export interface LeverSuggestion {
|
|
14
|
+
lever: InfrastructureLever;
|
|
15
|
+
objective: StrategyObjective;
|
|
16
|
+
action: string;
|
|
17
|
+
target: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function suggestLevers(intent: StrategyIntent): LeverSuggestion[];
|
|
20
|
+
export declare function resolveStrategyIntents(role: CommercialRole, strategy?: string[]): StrategyIntent[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const STRATEGY_LEVER_MAP={'sales_priority':['discount','reward'],'profit_priority':['discount','machine_design'],'buyer_screening':['buy_guard'],'gross_margin_control':['discount','machine_design']};const LEVER_ACTION={'discount':'issue/limit\x20Service.discount\x20coupons\x20(DISCOUNT_TYPE_RATES/MINUS)\x20to\x20steer\x20SKU\x20volume\x20vs\x20margin','reward':'bind\x20a\x20Reward\x20to\x20Service.rewards\x20and\x20gate\x20it\x20by\x20a\x20Guard\x20to\x20incentivize\x20the\x20target\x20segment','buy_guard':'set\x20Service.buy_guard\x20(post-publish\x20mutable)\x20to\x20qualify/restrict\x20eligible\x20buyers','machine_design':'adjust\x20Machine\x20topology/guards\x20(design-time)\x20to\x20enforce\x20the\x20target\x20acceptance\x20flow'};export function resolveObjective(a){if(!a)return null;const b=a['toLowerCase']();if(/(margin|profit|毛利率|利润)/['test'](b))return'gross_margin_control';if(/(volume|sales|销量|sell more|销量优先)/['test'](b))return'sales_priority';if(/(screen|qualify|filter|筛选|筛选购买人|eligible buyer)/['test'](b))return'buyer_screening';if(/(profit first|利润优先|margin first)/['test'](b))return'profit_priority';return null;}export function buildStrategyIntent(a,b,c){return{'objective':a,'metrics':c??[],'levers':STRATEGY_LEVER_MAP[a]??[],'target':b??''};}export function suggestLevers(a){return a['levers']['map'](b=>({'lever':b,'objective':a['objective'],'action':LEVER_ACTION[b],'target':a['target']}));}export function resolveStrategyIntents(a,b){if(a!=='merchant')return[];const c=[];for(const d of b??[]){const e=resolveObjective(d);if(e)c['push'](buildStrategyIntent(e,d));}return c;}
|
package/dist/persona/types.d.ts
CHANGED
|
@@ -2,13 +2,14 @@ import { type CommercialRole } from "../role/types.js";
|
|
|
2
2
|
export type PersonaScope = "system" | "account";
|
|
3
3
|
export type PersonaRole = Exclude<CommercialRole, "system">;
|
|
4
4
|
export declare const PERSONA_ROLES: readonly PersonaRole[];
|
|
5
|
-
export type Industry =
|
|
5
|
+
export type Industry = string;
|
|
6
6
|
export declare const SUPPORTED_INDUSTRIES: Industry[];
|
|
7
7
|
export interface PersonaIdentity {
|
|
8
8
|
region?: string;
|
|
9
9
|
languages?: string[];
|
|
10
10
|
self_description?: string;
|
|
11
11
|
}
|
|
12
|
+
export type SystemOverrideValue = "auto" | "prompt" | "block" | "warn";
|
|
12
13
|
export interface PersonaLayer {
|
|
13
14
|
identity?: PersonaIdentity;
|
|
14
15
|
preferences?: Record<string, unknown>;
|
|
@@ -16,6 +17,7 @@ export interface PersonaLayer {
|
|
|
16
17
|
rules?: string[];
|
|
17
18
|
requirements?: string[];
|
|
18
19
|
spec?: string;
|
|
20
|
+
overrides?: Record<string, SystemOverrideValue>;
|
|
19
21
|
}
|
|
20
22
|
export type PersonaMutationMode = "merge" | "replace";
|
|
21
23
|
export interface Persona {
|
|
@@ -38,7 +38,7 @@ export interface KeywordMatch {
|
|
|
38
38
|
}
|
|
39
39
|
export declare function extractKeywords(business_intent: string): KeywordMatch[];
|
|
40
40
|
export declare function resolveIndustry(intent: string, hint?: string): IndustryMode;
|
|
41
|
-
export declare function identifyObjects(
|
|
41
|
+
export declare function identifyObjects(_intent: string, matches: KeywordMatch[]): {
|
|
42
42
|
primary: ProjectObjectType;
|
|
43
43
|
secondary: ProjectObjectType[];
|
|
44
44
|
scenes: DetectedScene[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{initServicePuzzleFromIntent,initMachinePuzzleFromIntent,initAllocationPuzzleFromIntent,initTreasuryPuzzleFromIntent,initArbitrationPuzzleFromIntent,initRewardPuzzleFromIntent,initProgressPuzzleFromIntent,initOrderPuzzleFromIntent,initPuzzleFromIntent as
|
|
1
|
+
import{initServicePuzzleFromIntent,initMachinePuzzleFromIntent,initAllocationPuzzleFromIntent,initTreasuryPuzzleFromIntent,initArbitrationPuzzleFromIntent,initRewardPuzzleFromIntent,initProgressPuzzleFromIntent,initOrderPuzzleFromIntent,initPuzzleFromIntent as a258a,checkServicePuzzleCompleteness,checkMachinePuzzleCompleteness,checkAllocationPuzzleCompleteness,checkTreasuryPuzzleCompleteness,checkArbitrationPuzzleCompleteness,checkRewardPuzzleCompleteness,checkProgressPuzzleCompleteness,checkOrderPuzzleCompleteness,checkPuzzleCompleteness as a258b}from'../knowledge/index.js';import{initPuzzleFromIntent as a258c,checkPuzzleCompleteness as a258d}from'../knowledge/permission-puzzle.js';const KEYWORD_TABLE=[{'category':'Product/Service','keywords_zh':['product','selling','sell','sales','store','open\x20shop'],'keywords_en':['sell','product','sale','shop','store'],'objects':['service','order','progress'],'required_level':'R','scene_id':'retail'},{'category':'Subscription','keywords_zh':['subscription','cycle','renewal'],'keywords_en':['subscribe','recurring','subscription'],'objects':['service','machine','reward'],'required_level':'C','scene_id':'subscription'},{'category':'Rental','keywords_zh':['rent','lease','return'],'keywords_en':['rent','lease','return'],'objects':['service','machine','arb'],'required_level':'C','scene_id':'rental_return'},{'category':'Trust','keywords_zh':['deposit','pledge','verify','trust'],'keywords_en':['deposit','trust','verify'],'objects':['guard','permission','treasury'],'required_level':'R','scene_id':'trust_deposit'},{'category':'Funds','keywords_zh':['split','collect','share\x20profit','income','incentive'],'keywords_en':['split','revenue','reward'],'objects':['allocation','treasury','reward'],'required_level':'R','scene_id':'revenue_split'},{'category':'Workflow','keywords_zh':['node','stage','process','workflow'],'keywords_en':['workflow','stage','node'],'objects':['machine','progress'],'required_level':'R','scene_id':'workflow'},{'category':'Dispute','keywords_zh':['arbitration','refund','conflict','rights\x20protection'],'keywords_en':['arbitration','refund','dispute'],'objects':['arb','proof'],'required_level':'C','scene_id':'arbitration_dispute'},{'category':'Contact','keywords_zh':['customer\x20service','contact','communication'],'keywords_en':['contact','support','im'],'objects':['contact'],'required_level':'C','scene_id':'contact_im'},{'category':'Data','keywords_zh':['evidence','record','data'],'keywords_en':['evidence','record','data'],'objects':['repository','proof'],'required_level':'C','scene_id':'evidence_record'},{'category':'User\x20Profile','keywords_zh':['personal\x20info','preference','privacy'],'keywords_en':['personal','profile','privacy'],'objects':['personal','contact'],'required_level':'OPTIONAL','scene_id':'user_profile'},{'category':'Demand\x20Submission','keywords_zh':['demand','publish','inquiry'],'keywords_en':['demand','request','inquiry'],'objects':['demand'],'required_level':'OPTIONAL','scene_id':'demand_inquiry'}],INDUSTRY_KEYWORDS=[{'industry':'freelance','words':['freelance','outsourcing','freelance','gig']},{'industry':'rental','words':['rental','lease','rental','rent']},{'industry':'education','words':['education','course','training','education','course']},{'industry':'travel','words':['travel','tour','itinerary','travel','trip']},{'industry':'subscription','words':['subscription','cycle','subscription','recurring']}];function buildPuzzleDispatch(){const a=(c,d)=>{try{return c(d);}catch{return undefined;}},b=(c,d)=>{if(!c)return{'missing':[],'complete':![],'next_step':'init\x20failed'};try{return d(c);}catch{return{'missing':[],'complete':![],'next_step':'check\x20failed'};}};return{'service':{'init':c=>a(initServicePuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkServicePuzzleCompleteness)},'machine':{'init':c=>a(initMachinePuzzleFromIntent,c),'check':c=>b(c,checkMachinePuzzleCompleteness)},'allocation':{'init':c=>a(initAllocationPuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkAllocationPuzzleCompleteness)},'treasury':{'init':c=>a(initTreasuryPuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkTreasuryPuzzleCompleteness)},'arb':{'init':c=>a(initArbitrationPuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkArbitrationPuzzleCompleteness)},'reward':{'init':c=>a(initRewardPuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkRewardPuzzleCompleteness)},'progress':{'init':c=>a(initProgressPuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkProgressPuzzleCompleteness)},'order':{'init':c=>a(initOrderPuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkOrderPuzzleCompleteness)},'permission':{'init':c=>a(a258c,{'primary_goal':c}),'check':c=>b(c,a258d)},'guard':{'init':c=>a(a258a,{'primary_goal':c}),'check':c=>b(c,a258b)}};}export function extractKeywords(a){if(!a||typeof a!=='string')return[];const b=[];for(const c of KEYWORD_TABLE){const d=[...c['keywords_zh'],...c['keywords_en']];for(const e of d){try{const f=new RegExp(escapeRegex(e),'gi'),g=(a['match'](f)||[])['length'];g>0x0&&b['push']({'keyword':e,'category':c['category'],'matched_objects':[...c['objects']],'required_level':c['required_level'],'match_count':g});}catch{}}}return b['sort']((h,i)=>i['match_count']-h['match_count']),b;}function escapeRegex(a){return a['replace'](/[.*+?^${}()|[\]\\]/g,'\x5c$&');}export function resolveIndustry(a,b){const c=((a??'')+'\x20'+(b??''))['toLowerCase']();for(const d of INDUSTRY_KEYWORDS){for(const e of d['words']){if(c['includes'](e['toLowerCase']()))return d['industry'];}}return'general';}export function identifyObjects(a,b){if(b['length']===0x0)return{'primary':'service','secondary':['permission','machine','progress'],'scenes':[{'object':'service','scene_id':'general'}]};const c=b['find'](i=>i['required_level']==='R'),d=(c??b[0x0])['matched_objects'][0x0],e=new Set([d]),f=[];for(const i of b){for(const j of i['matched_objects']){!e['has'](j)&&(e['add'](j),f['push'](j));}}const g=[],h=new Set();for(const k of KEYWORD_TABLE){const l=b['find'](n=>n['category']===k['category']);if(!l)continue;if(h['has'](k['scene_id']))continue;h['add'](k['scene_id']),g['push']({'object':k['objects'][0x0],'scene_id':k['scene_id']});}return{'primary':d,'secondary':f,'scenes':g};}export function analyzeBusinessIntent(a){const b=[];if(!a||!a['user_intent']||typeof a['user_intent']!=='string')return{'intent_parsed':{'primary_object':'service','secondary_objects':[],'detected_scenes':[],'industry':'general','keyword_matches':[]},'puzzles':{},'overall_completeness':'empty','next_step':'Please\x20provide\x20a\x20non-empty\x20business\x20intent.','recommended_creation_order':[],'warnings':['input.user_intent\x20is\x20empty']};const c=a['user_intent'],e=extractKeywords(c),f=resolveIndustry(c,a['industry']),{primary:g,secondary:h,scenes:i}=identifyObjects(c,e);let j=[g,...h];if(a['target_objects']&&a['target_objects']['length']>0x0){const p=a['target_objects']['filter'](q=>['service','machine','guard','permission','reward','arb','progress','treasury','demand','repository','contact','order','allocation','personal','payment','proof']['includes'](q));if(p['length']>0x0)j=p;}const k=buildPuzzleDispatch(),l={};for(const q of j){const r=k[q];if(!r){b['push']('No\x20puzzle\x20module\x20for\x20\x27'+q+'\x27\x20—\x20skipped\x20(L3\x20object)');continue;}const s=r['init'](c),t=s?r['check'](s):undefined,u=extractMissingDimensions(t);l[q]={'puzzle':s,'completeness':t,'missing_dimensions':u},!s&&b['push']('Puzzle\x20init\x20failed\x20for\x20\x27'+q+'\x27');}const m=aggregatePuzzleCompleteness(l),n=suggestNextPuzzleStep({'intent_parsed':{'primary_object':g,'secondary_objects':h,'detected_scenes':i,'industry':f,'keyword_matches':e},'puzzles':l,'overall_completeness':m,'next_step':'','recommended_creation_order':[],'warnings':b}),o=['permission','progress','guard','allocation','machine','service'];return{'intent_parsed':{'primary_object':g,'secondary_objects':h,'detected_scenes':i,'industry':f,'keyword_matches':e},'puzzles':l,'overall_completeness':m,'next_step':n,'recommended_creation_order':o,'warnings':b};}function extractMissingDimensions(a){if(!a||typeof a!=='object')return[];const b=a,d=b['missing'];if(Array['isArray'](d))return d['map'](f=>String(f));const e=b['missing_details'];if(Array['isArray'](e))return e['map'](f=>String(f?.['dimension']??f));return[];}export function aggregatePuzzleCompleteness(a){const b=Object['values'](a??{});if(b['length']===0x0)return'empty';const c=b['filter'](f=>!f['puzzle'])['length'];if(c===b['length'])return'empty';const d=b['reduce']((f,g)=>f+(g['missing_dimensions']?.['length']??0x0),0x0);if(d===0x0)return'complete';return'partial';}export function suggestNextPuzzleStep(a){if(!a)return'No\x20result\x20to\x20suggest\x20from.';if(a['overall_completeness']==='complete')return'All\x20puzzle\x20dimensions\x20are\x20complete\x20—\x20ready\x20for\x20risk\x20calibration\x20(stage\x203).';if(a['overall_completeness']==='empty')return'No\x20puzzle\x20has\x20been\x20initialized.\x20Provide\x20more\x20concrete\x20business\x20intent\x20so\x20the\x20primary\x20object\x20can\x20be\x20identified.';const b=['permission','treasury','allocation','guard','machine','service','order','progress','arb','reward','proof','repository','demand','contact','personal','payment'],d=a['puzzles']??{},e=b['filter'](f=>d[f]);for(const f of e){const g=d[f];if(!g)continue;const h=g['missing_dimensions']??[];if(h['length']===0x0)continue;const i=g['completeness'],j=i&&typeof i==='object'?i['next_step']:undefined;if(typeof j==='string'&&j['trim']())return'['+f+']\x20'+j;return'['+f+']\x20Complete\x20dimension'+(h['length']>0x1?'s':'')+'\x20'+h['join'](',\x20')+'\x20to\x20advance\x20the\x20puzzle.';}return'Continue\x20dialog\x20to\x20fill\x20remaining\x20pending\x20fields.';}
|