@wowok/agent-mcp 2.7.2 → 2.7.3
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/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-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-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.js +1 -1
- package/dist/knowledge/payment-confirm.d.ts +26 -0
- package/dist/knowledge/payment-confirm.js +1 -0
- package/dist/knowledge/payment-translation.d.ts +37 -0
- package/dist/knowledge/payment-translation.js +1 -0
- 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-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/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-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/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/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-translation.d.ts +38 -0
- package/dist/knowledge/util-translation.js +1 -0
- package/dist/knowledge/workflow-guidance.d.ts +116 -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.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-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 +3 -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 +2969 -26518
- package/dist/schema/operations.js +1 -1
- 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 +12042 -75678
- 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/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 +29 -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 +6018 -2433
- package/dist/schemas/onchain_table_data.schema.json +544 -430
- 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/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/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/workspace.d.ts +2 -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,116 @@
|
|
|
1
|
+
export interface ParsedForward {
|
|
2
|
+
name: string;
|
|
3
|
+
weight: number;
|
|
4
|
+
namedOperator?: string | null;
|
|
5
|
+
permissionIndex?: number | null;
|
|
6
|
+
guard?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ParsedPair {
|
|
9
|
+
prev_node: string;
|
|
10
|
+
threshold: number;
|
|
11
|
+
forwards: ParsedForward[];
|
|
12
|
+
}
|
|
13
|
+
export interface ParsedMachineNode {
|
|
14
|
+
name: string;
|
|
15
|
+
pairs: ParsedPair[];
|
|
16
|
+
}
|
|
17
|
+
export type NameResolver = (addr: string | undefined | null) => string | undefined;
|
|
18
|
+
export declare function resolvePermissionRole(index: number | undefined | null, permissionDescription?: string): string;
|
|
19
|
+
export declare function fetchMachineNodes(machine: string, network?: string, noCache?: boolean): Promise<ParsedMachineNode[]>;
|
|
20
|
+
export interface GuidanceInput {
|
|
21
|
+
current: string;
|
|
22
|
+
nodes: ParsedMachineNode[];
|
|
23
|
+
caller?: string;
|
|
24
|
+
orderHolderAddresses?: string[];
|
|
25
|
+
permissionDescription?: string;
|
|
26
|
+
nameResolver?: NameResolver;
|
|
27
|
+
}
|
|
28
|
+
export interface OperatorInfo {
|
|
29
|
+
kind: "order_holder" | "permission_index" | "named_operator";
|
|
30
|
+
permission_index?: number;
|
|
31
|
+
role_name?: string;
|
|
32
|
+
account_name?: string;
|
|
33
|
+
named_operator?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface OptionInfo {
|
|
36
|
+
next_node: string;
|
|
37
|
+
forward: string;
|
|
38
|
+
weight: number;
|
|
39
|
+
operator: OperatorInfo;
|
|
40
|
+
guard?: string;
|
|
41
|
+
business_meaning: string;
|
|
42
|
+
gains: string[];
|
|
43
|
+
risks: string[];
|
|
44
|
+
consistency: number;
|
|
45
|
+
recommended: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface GuidanceResult {
|
|
48
|
+
current_node: string;
|
|
49
|
+
caller?: string;
|
|
50
|
+
options: OptionInfo[];
|
|
51
|
+
recommendation?: {
|
|
52
|
+
best?: string;
|
|
53
|
+
rationale?: string;
|
|
54
|
+
caveat?: string;
|
|
55
|
+
};
|
|
56
|
+
note?: string;
|
|
57
|
+
}
|
|
58
|
+
export declare function buildWorkflowGuidance(input: GuidanceInput): GuidanceResult;
|
|
59
|
+
export interface ReceiptInput extends GuidanceInput {
|
|
60
|
+
callerName: string;
|
|
61
|
+
forward: string;
|
|
62
|
+
targetNode: string;
|
|
63
|
+
op?: string;
|
|
64
|
+
session?: Array<{
|
|
65
|
+
next_node?: string;
|
|
66
|
+
forwards?: Array<{
|
|
67
|
+
forward?: string;
|
|
68
|
+
accomplished?: boolean;
|
|
69
|
+
}>;
|
|
70
|
+
weights?: number;
|
|
71
|
+
threshold?: number;
|
|
72
|
+
}>;
|
|
73
|
+
}
|
|
74
|
+
export interface WaitingInfo {
|
|
75
|
+
forward: string;
|
|
76
|
+
operator: OperatorInfo;
|
|
77
|
+
}
|
|
78
|
+
export interface ReceiptResult {
|
|
79
|
+
account: string;
|
|
80
|
+
action: string;
|
|
81
|
+
forward: string;
|
|
82
|
+
target_node: string;
|
|
83
|
+
op?: string;
|
|
84
|
+
migrated: boolean;
|
|
85
|
+
current_node: string;
|
|
86
|
+
threshold?: number;
|
|
87
|
+
accumulated_weight?: number;
|
|
88
|
+
remaining?: number;
|
|
89
|
+
waiting_on?: WaitingInfo[];
|
|
90
|
+
next_guidance?: GuidanceResult;
|
|
91
|
+
note?: string;
|
|
92
|
+
}
|
|
93
|
+
export declare function buildWorkflowReceipt(input: ReceiptInput): ReceiptResult;
|
|
94
|
+
export declare function renderGuidanceText(g: GuidanceResult): string;
|
|
95
|
+
export declare function renderReceiptText(r: ReceiptResult): string;
|
|
96
|
+
export interface EnrichOptions {
|
|
97
|
+
progressRef: string;
|
|
98
|
+
network?: string;
|
|
99
|
+
accountName?: string;
|
|
100
|
+
operate?: {
|
|
101
|
+
forward?: string;
|
|
102
|
+
next_node_name?: string;
|
|
103
|
+
op?: string;
|
|
104
|
+
};
|
|
105
|
+
noCache?: boolean;
|
|
106
|
+
}
|
|
107
|
+
export interface EnrichResult {
|
|
108
|
+
guidance?: GuidanceResult;
|
|
109
|
+
receipt?: ReceiptResult;
|
|
110
|
+
text?: string;
|
|
111
|
+
}
|
|
112
|
+
export declare function enrichWorkflowGuidance(opts: EnrichOptions): Promise<EnrichResult | undefined>;
|
|
113
|
+
export declare function mergeGuidanceIntoOutput<T extends {
|
|
114
|
+
content: any[];
|
|
115
|
+
structuredContent: any;
|
|
116
|
+
}>(output: T, enrichment: EnrichResult | undefined): T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{query_objects,query_table,LocalMark,GetLocalNamesByAddresses}from'@wowok/wowok';import{REPOSITORY_PERMISSIONS,REWARD_PERMISSIONS,MACHINE_PERMISSIONS,PROGRESS_PERMISSIONS,TREASURY_PERMISSIONS,SERVICE_PERMISSIONS,ARBITRATION_PERMISSIONS,DEMAND_PERMISSIONS,CONTACT_PERMISSIONS}from'./permission-ledger.js';const BUILTIN_PERMISSION_MAP=new Map();for(const entry of[...REPOSITORY_PERMISSIONS,...REWARD_PERMISSIONS,...MACHINE_PERMISSIONS,...PROGRESS_PERMISSIONS,...TREASURY_PERMISSIONS,...SERVICE_PERMISSIONS,...ARBITRATION_PERMISSIONS,...DEMAND_PERMISSIONS,...CONTACT_PERMISSIONS]){BUILTIN_PERMISSION_MAP['set'](entry['index'],entry['name']);}export function resolvePermissionRole(a,b){if(a===undefined||a===null)return'unknown\x20role';if(b){const d=/([A-Za-z][A-Za-z0-9_]*)\s*=\s*(\d+)/g;let e;while((e=d['exec'](b))!==null){if(Number(e[0x2])===a)return e[0x1]+'\x20(permission\x20'+a+')';}}const c=BUILTIN_PERMISSION_MAP['get'](a);if(c)return c+'\x20(permission\x20'+a+')';return'permission\x20'+a;}export async function fetchMachineNodes(a,b,c){const d=await query_objects({'objects':[a],'no_cache':c,'network':b}),e=d?.['objects']?.[0x0],f=e?.['object']??(typeof a==='string'&&a['startsWith']('0x')?a:undefined);if(!f)return[];const g=await query_table({'parent':f,'no_cache':c,'network':b}),h=(g?.['items']??[])['map'](j=>j?.['object'])['filter'](j=>typeof j==='string');if(h['length']===0x0)return[];const i=await query_objects({'objects':h,'no_cache':c,'network':b});return(i?.['objects']??[])['filter'](j=>j?.['type']==='TableItem_MachineNode')['map'](j=>{const k=j?.['data']??j,l=typeof k?.['name']==='string'?k['name']:'',m=Array['isArray'](k?.['value'])?k['value']:Array['isArray'](k?.['pairs'])?k['pairs']:[];if(!l)return null;return{'name':l,'pairs':m['map'](n=>({'prev_node':String(n?.['prev_node']??''),'threshold':Number(n?.['threshold']??0x0),'forwards':Array['isArray'](n?.['forwards'])?n['forwards']['map'](q=>{const r=typeof q?.['guard']==='object'&&q?.['guard']!==null?q['guard']['guard']??undefined:typeof q?.['guard']==='string'?q['guard']:undefined;return{'name':String(q?.['name']??''),'weight':Number(q?.['weight']??0x0),'namedOperator':q?.['namedOperator']!==undefined&&q?.['namedOperator']!==null?String(q['namedOperator']):undefined,'permissionIndex':q?.['permissionIndex']!==undefined&&q?.['permissionIndex']!==null?Number(q['permissionIndex']):undefined,'guard':r};}):[]}))};})['filter'](j=>j!==null);}const COMPLETE_RE=/(^|_)(completed?|done|finished|received|delivered|accepted|confirmed|finalized|success|approved)(_|$)/i,REFUND_RE=/(^|_)(cancel(led)?|refund(ed)?|return(ed|_approved)?)(_|$)/i,EXCEPTION_RE=/(^|_)(interrupt(ed)?|exception|dispute(d)?|fail(ed)?|abort(ed)?|reject(ed)?)(_|$)/i;function classifyNode(a){if(COMPLETE_RE['test'](a))return'complete';if(REFUND_RE['test'](a))return'refund';if(EXCEPTION_RE['test'](a))return'exception';return'advance';}function businessMeaning(a,b){switch(b){case'complete':return'Service/deliverable\x20accepted\x20at\x20\x22'+a+'\x22\x20—\x20triggers\x20settlement\x20allocation\x20(funds\x20released\x20to\x20the\x20provider)';case'refund':return'Order\x20cancelled/returned\x20at\x20\x22'+a+'\x22\x20—\x20triggers\x20refund\x20allocation\x20(funds\x20back\x20to\x20the\x20customer)';case'exception':return'Exception\x20path\x20at\x20\x22'+a+'\x22\x20—\x20typically\x20routes\x20to\x20arbitration\x20or\x20partial-refund\x20handling';default:return'Progress\x20to\x20\x22'+a+'\x22';}}function shortAddr(a){if(!a)return undefined;if(a['length']>0xe)return a['slice'](0x0,0x8)+'...'+a['slice'](-0x4);return a;}function callerIsOrderHolder(a,b){if(!a||!b?.['length'])return![];const d=a['toLowerCase']();return b['some'](e=>e?.['toLowerCase']()===d);}function resolveOperator(a,b,c,d){if(a['namedOperator']===''){const e=b?.[0x0];return{'kind':'order_holder','role_name':'order\x20holder\x20(customer)','account_name':d?d(e):shortAddr(e)};}if(typeof a['namedOperator']==='string'&&a['namedOperator']['length']>0x0)return{'kind':'named_operator','named_operator':a['namedOperator'],'role_name':'named\x20operator\x20\x22'+a['namedOperator']+'\x22'};if(a['permissionIndex']!==undefined&&a['permissionIndex']!==null)return{'kind':'permission_index','permission_index':a['permissionIndex'],'role_name':resolvePermissionRole(a['permissionIndex'],c)};return{'kind':'order_holder','role_name':'unknown\x20operator'};}function gainsRisksFor(a,b,c){if(!c)return{'gains':[],'risks':[]};if(b)switch(a){case'complete':return{'gains':['Flow\x20advances','Settlement\x20triggered\x20(funds\x20released)'],'risks':['Funds\x20released\x20to\x20provider','Refund\x20leverage\x20lost\x20—\x20confirm\x20only\x20if\x20service\x20verified']};case'refund':return{'gains':['Funds\x20returned\x20to\x20you'],'risks':['If\x20service\x20was\x20already\x20rendered,\x20cancellation\x20may\x20be\x20disputed']};case'exception':return{'gains':['Avoids\x20stalemate'],'risks':['May\x20trigger\x20arbitration\x20/\x20reputation\x20impact']};default:return{'gains':['Flow\x20advances'],'risks':[]};}switch(a){case'complete':return{'gains':['Settlement\x20triggered\x20—\x20funds\x20released\x20to\x20provider'],'risks':[]};case'refund':return{'gains':['Clean\x20closure'],'risks':['Lost\x20revenue\x20for\x20this\x20order']};case'exception':return{'gains':['Avoids\x20stalemate'],'risks':['May\x20trigger\x20arbitration\x20/\x20compensation\x20fund']};default:return{'gains':['Flow\x20advances'],'risks':[]};}}function consistencyFor(a,b,c,d,e){let f;if(!e)f=a==='exception'?0x2d:0x32;else b?f=a==='refund'?0x46:a==='complete'?0x37:a==='exception'?0x23:0x32:f=a==='complete'?0x4b:a==='refund'?0x1e:a==='exception'?0x23:0x32;if(e&&c)f+=0x14;if(d)f-=0xa;return Math['max'](0x0,Math['min'](0x64,f));}export function buildWorkflowGuidance(a){const b=[];for(const i of a['nodes']){for(const j of i['pairs']){if(j['prev_node']!==a['current'])continue;for(const k of j['forwards']){if(!k['name'])continue;const l=resolveOperator(k,a['orderHolderAddresses'],a['permissionDescription'],a['nameResolver']),m=callerIsOrderHolder(a['caller'],a['orderHolderAddresses']);let n=![];if(l['kind']==='order_holder'&&a['caller']){const u=a['caller']['toLowerCase']();n=!!a['orderHolderAddresses']?.['some'](v=>v?.['toLowerCase']()===u)||u===(l['account_name']??'')['toLowerCase']();}else{if(l['kind']==='named_operator')n=!![];else l['kind']==='permission_index'&&(n=!![]);}const p=classifyNode(i['name']),q=!!a['caller'],{gains:r,risks:s}=gainsRisksFor(p,m,q),t=consistencyFor(p,m,n,!!k['guard'],q);b['push']({'next_node':i['name'],'forward':k['name'],'weight':k['weight'],'operator':l,'guard':k['guard'],'business_meaning':businessMeaning(i['name'],p),'gains':r,'risks':s,'consistency':t,'recommended':![]});}}}if(b['length']===0x0)return{'current_node':a['current'],'caller':a['caller'],'options':[],'note':'Node\x20\x22'+a['current']+'\x22\x20has\x20no\x20outgoing\x20forwards\x20—\x20it\x20is\x20a\x20terminal\x20node\x20(or\x20the\x20workflow\x20is\x20stuck).\x20No\x20further\x20progress\x20operation\x20is\x20available\x20here.'};b['sort']((v,w)=>w['consistency']-v['consistency']);const c=b[0x0];b[0x0]={...c,'recommended':!![]};const d=[];for(const v of b){v!==c&&v['consistency']>0x0&&v['forward']!==c['forward']&&d['push']('Choosing\x20\x22'+v['forward']+'\x20→\x20'+v['next_node']+'\x22\x20forfeits\x20the\x20faster/more\x20aligned\x20path\x20\x22'+c['forward']+'\x20→\x20'+c['next_node']+'\x22');}const e=[],g=b['filter'](w=>w['operator']['kind']==='order_holder'&&w['forward']!==c['forward']&&c['forward']!==w['forward']),h=b['filter'](w=>w['operator']['account_name']&&w['operator']['account_name']!==a['caller']);return h['length']>0x0&&!b['some'](w=>w['recommended']&&w['operator']['account_name']===a['caller'])&&e['push']('The\x20recommended\x20action\x20is\x20executed\x20by\x20another\x20account\x20('+h[0x0]['operator']['account_name']+');\x20switch\x20the\x20signing\x20account\x20(env.account)\x20before\x20operating.'),{'current_node':a['current'],'caller':a['caller'],'options':b,'recommendation':{'best':c['forward']+'\x20→\x20'+c['next_node'],'rationale':'Highest\x20consistency\x20('+c['consistency']+'/100)\x20with\x20the\x20caller\x27s\x20interests.\x20Gains:\x20'+(c['gains']['join'](';\x20')||'none')+'.\x20Risks:\x20'+(c['risks']['join'](';\x20')||'none')+'.\x20Operator:\x20'+(c['operator']['role_name']??c['operator']['kind'])+(c['operator']['account_name']?'\x20('+c['operator']['account_name']+')':'')+'.'+(c['guard']?'\x20Guard\x20to\x20satisfy:\x20'+c['guard']+'.':''),'caveat':d['length']?d['join']('.\x20'):undefined},'note':e['length']?e['join']('\x20'):undefined};}export function buildWorkflowReceipt(a){const b=a['current']===a['targetNode'],c={'account':a['callerName'],'action':a['callerName']+'\x20executed\x20'+a['forward']+'\x20(→\x20'+a['targetNode']+')','forward':a['forward'],'target_node':a['targetNode'],'op':a['op'],'migrated':b,'current_node':a['current']};if(!b){const e=a['nodes']['filter'](j=>j['name']===a['targetNode'])['flatMap'](j=>j['pairs'])['find'](j=>j['prev_node']===a['current']),g=a['session']?.['slice'](-0x1)[0x0],h=g?.['threshold']??e?.['threshold']??0x0,i=g?.['weights']??0x0;if(h>0x0){c['threshold']=h,c['accumulated_weight']=i,c['remaining']=Math['max'](0x0,h-i);const j=new Set((g?.['forwards']??[])['filter'](l=>l?.['accomplished']!==![])['map'](l=>l?.['forward'])['filter'](l=>!!l)),k=[];for(const l of e?.['forwards']??[]){if(!l['name']||j['has'](l['name']))continue;k['push']({'forward':l['name'],'operator':resolveOperator(l,a['orderHolderAddresses'],a['permissionDescription'],a['nameResolver'])});}if(k['length'])c['waiting_on']=k;c['note']='Node\x20did\x20not\x20migrate:\x20threshold\x20'+h+',\x20accumulated\x20weight\x20'+i+',\x20remaining\x20'+Math['max'](0x0,h-i)+'.\x20'+(k['length']?'Waiting\x20for:\x20'+k['map'](m=>m['forward']+'\x20('+(m['operator']['role_name']??m['operator']['kind'])+')')['join'](';\x20'):'All\x20forwards\x20on\x20this\x20pair\x20are\x20accomplished\x20—\x20the\x20node\x20should\x20migrate\x20on\x20the\x20next\x20operation.');}else c['note']='Node\x20did\x20not\x20migrate\x20(threshold\x200)\x20—\x20no\x20further\x20weight\x20cooperation\x20required;\x20verify\x20the\x20operation\x20outcome.';}const d=buildWorkflowGuidance({'current':a['current'],'nodes':a['nodes'],'caller':a['caller'],'orderHolderAddresses':a['orderHolderAddresses'],'permissionDescription':a['permissionDescription'],'nameResolver':a['nameResolver']});if(d['options']['length']>0x0)c['next_guidance']=d;return c;}function operatorText(a){const b=[a['role_name']??a['kind']];if(a['account_name'])b['push'](a['account_name']);return b['join']('\x20/\x20');}export function renderGuidanceText(a){const b=['[WORKFLOW\x20GUIDANCE]\x20current\x20node:\x20\x22'+a['current_node']+'\x22'+(a['caller']?'\x20(caller:\x20'+a['caller']+')':'')];if(a['options']['length']===0x0)return b['push']('\x20\x20•\x20'+(a['note']??'No\x20reachable\x20next\x20nodes.')),b['join']('\x0a');for(const c of a['options']){const d=['\x22'+c['forward']+'\x22\x20→\x20\x22'+c['next_node']+'\x22','operator:\x20'+operatorText(c['operator']),'weight:\x20'+c['weight'],'consistency:\x20'+c['consistency']+'/100'+(c['recommended']?'\x20[RECOMMENDED]':'')];if(c['guard'])d['push']('guard:\x20'+c['guard']);d['push']('meaning:\x20'+c['business_meaning']);if(c['gains']['length'])d['push']('gains:\x20'+c['gains']['join'](';\x20'));if(c['risks']['length'])d['push']('risks:\x20'+c['risks']['join'](';\x20'));b['push']('\x20\x20•\x20'+d['join']('\x20|\x20'));}if(a['recommendation']?.['best']){b['push']('\x20\x20RECOMMENDED:\x20'+a['recommendation']['best']+'.\x20'+(a['recommendation']['rationale']??''));if(a['recommendation']['caveat'])b['push']('\x20\x20CAVEAT\x20(opportunity\x20cost):\x20'+a['recommendation']['caveat']);}if(a['note'])b['push']('\x20\x20NOTE:\x20'+a['note']);return b['push']('\x20\x20(AI\x20recommendation\x20only\x20—\x20the\x20account\x20decides;\x20switch\x20env.account\x20if\x20another\x20operator\x20must\x20act.)'),b['join']('\x0a');}export function renderReceiptText(a){const b=['[WORKFLOW\x20RECEIPT]\x20'+a['action']];b['push']('\x20\x20•\x20node\x20migrated:\x20'+(a['migrated']?'yes\x20→\x20current:\x20\x22'+a['current_node']+'\x22':'no\x20→\x20current:\x20\x22'+a['current_node']+'\x22'));if(!a['migrated']){a['threshold']!==undefined&&a['threshold']>0x0&&(b['push']('\x20\x20•\x20threshold:\x20'+a['threshold']+'\x20|\x20accumulated\x20weight:\x20'+(a['accumulated_weight']??0x0)+'\x20|\x20remaining:\x20'+(a['remaining']??0x0)),a['waiting_on']?.['length']&&b['push']('\x20\x20•\x20waiting\x20on:\x20'+a['waiting_on']['map'](c=>'\x22'+c['forward']+'\x22\x20('+operatorText(c['operator'])+')')['join'](';\x20')));if(a['note'])b['push']('\x20\x20•\x20note:\x20'+a['note']);}return a['next_guidance']&&a['next_guidance']['options']['length']>0x0&&b['push'](renderGuidanceText(a['next_guidance'])),b['join']('\x0a');}async function makeNameResolver(a){const b=[...new Set(a['filter'](d=>!!d))],c=new Map();if(b['length'])try{const d=await GetLocalNamesByAddresses(b);for(const e of d){const f=e?.['account']??e?.['local_mark'];if(f)c['set'](e['address']['toLowerCase'](),f);}}catch{}return g=>{if(!g)return undefined;const h=c['get'](g['toLowerCase']());return h??shortAddr(g);};}export async function enrichWorkflowGuidance(a){try{let b;if(a['progressRef']['startsWith']('0x'))b=a['progressRef'];else b=await LocalMark['Instance']()['get_address'](a['progressRef'])??undefined;if(!b)return undefined;const c=await query_objects({'objects':[b],'no_cache':a['noCache'],'network':a['network']}),d=c?.['objects']?.[0x0],e=d?.['data']??d;if((d?.['type']??e?.['type'])!=='Progress')return undefined;const f=e['current']??'',g=e['machine'],h=Array['isArray'](e['session'])?e['session']:[],i=(Array['isArray'](e['namedOperator'])?e['namedOperator']['find'](q=>q?.['name']==='')?.['operators']:undefined)??[];if(!g)return undefined;const j=await fetchMachineNodes(g,a['network'],a['noCache']);let k;try{const q=await query_objects({'objects':[g],'no_cache':a['noCache'],'network':a['network']}),r=q?.['objects']?.[0x0],s=r?.['data']??r,t=s?.['permission'];if(t){const u=await query_objects({'objects':[t],'no_cache':a['noCache'],'network':a['network']}),v=u?.['objects']?.[0x0];k=(v?.['data']??v)?.['description']??undefined;}}catch{}const l=await makeNameResolver([a['accountName'],...i]),m={'current':f,'nodes':j,'caller':a['accountName'],'orderHolderAddresses':i,'permissionDescription':k,'nameResolver':l},n=buildWorkflowGuidance(m);let o;a['operate']?.['forward']&&a['operate']?.['next_node_name']&&(o=buildWorkflowReceipt({...m,'callerName':a['accountName']??b,'forward':a['operate']['forward'],'targetNode':a['operate']['next_node_name'],'op':a['operate']['op'],'session':h}));const p=[o?renderReceiptText(o):undefined,n['options']['length']?renderGuidanceText(n):undefined]['filter'](w=>!!w)['join']('\x0a\x0a');return{'guidance':n,'receipt':o,'text':p};}catch{return undefined;}}export function mergeGuidanceIntoOutput(a,b){if(!b)return a;try{const c=a?.['structuredContent'];if(c&&typeof c==='object'){const d=c['semantic'];if(d&&typeof d==='object'){if(b['guidance'])d['workflow_guidance']=b['guidance'];if(b['receipt'])d['workflow_receipt']=b['receipt'];}}b['text']&&Array['isArray'](a?.['content'])&&a['content'][0x0]?.['text']!==undefined&&(a['content'][0x0]['text']=b['text']+'\x0a\x0a'+a['content'][0x0]['text']);}catch{}return a;}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type EmployeeDepartment = "customer_service" | "logistics" | "finance" | "operations";
|
|
2
|
+
export type EmployeeLiability = "merchant_bears" | "self_bears" | "hybrid";
|
|
3
|
+
export interface EmployeeProfile {
|
|
4
|
+
department: EmployeeDepartment;
|
|
5
|
+
liability: EmployeeLiability;
|
|
6
|
+
response_time_budget_ms?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface ReactionKpi {
|
|
9
|
+
node: string;
|
|
10
|
+
reaction_ms: number;
|
|
11
|
+
within_budget: boolean;
|
|
12
|
+
status: "pass" | "warn" | "fail";
|
|
13
|
+
}
|
|
14
|
+
export interface LiabilityResolution {
|
|
15
|
+
bears: "merchant" | "employee";
|
|
16
|
+
must_compensate_before_resume: boolean;
|
|
17
|
+
note: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function assessReactionKpi(node: string, assigned_at: number, advanced_at: number | undefined, budget_ms?: number): ReactionKpi;
|
|
20
|
+
export declare function resolveLiability(liability: EmployeeLiability, loss_amount: number, hybrid_threshold?: number): LiabilityResolution;
|
|
21
|
+
export interface EmployeeProfileValidation {
|
|
22
|
+
valid: boolean;
|
|
23
|
+
issues: string[];
|
|
24
|
+
}
|
|
25
|
+
export declare function validateEmployeeProfile(profile: EmployeeProfile): EmployeeProfileValidation;
|
|
@@ -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.';}
|