@wowok/agent-mcp 2.7.10 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extensions/capability-manifest.d.ts +1 -82
- package/dist/extensions/capability-manifest.js +1 -1
- package/dist/extensions/constraint-registry.d.ts +6 -4
- package/dist/extensions/constraint-registry.js +1 -1
- package/dist/extensions/index.d.ts +4 -5
- package/dist/extensions/index.js +1 -1
- package/dist/extensions/industry-pack.js +1 -1
- package/dist/extensions/metric-registry.d.ts +6 -4
- package/dist/extensions/metric-registry.js +1 -1
- package/dist/extensions/mode-evaluator.d.ts +2 -3
- package/dist/extensions/mode-evaluator.js +1 -1
- package/dist/extensions/registry.d.ts +3 -25
- package/dist/extensions/registry.js +1 -1
- package/dist/extensions/types.d.ts +0 -68
- package/dist/goal/GoalEngine.d.ts +36 -1
- package/dist/goal/GoalEngine.js +1 -1
- package/dist/goal/types.d.ts +4 -0
- package/dist/knowledge/account-marks.d.ts +1 -0
- package/dist/knowledge/account-marks.js +1 -1
- package/dist/knowledge/fund-layer.d.ts +13 -9
- package/dist/knowledge/fund-layer.js +1 -1
- package/dist/knowledge/goal-completion.js +1 -1
- package/dist/knowledge/guard-bindings.d.ts +21 -0
- package/dist/knowledge/guard-bindings.js +1 -0
- package/dist/knowledge/index.d.ts +5 -3
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/mcp-schema-audit-cli.js +1 -1
- package/dist/knowledge/mcp-schema-audit.js +1 -1
- package/dist/knowledge/reward-risk.d.ts +1 -1
- package/dist/knowledge/reward-risk.js +1 -1
- package/dist/knowledge/safety-rules.d.ts +2 -1
- package/dist/knowledge/safety-rules.js +1 -1
- package/dist/knowledge/scenario-topology.d.ts +43 -0
- package/dist/knowledge/scenario-topology.js +1 -0
- package/dist/knowledge/supply-chain.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/workflow-guidance.d.ts +35 -0
- package/dist/knowledge/workflow-guidance.js +1 -1
- package/dist/knowledge/workspace-lists.d.ts +1 -0
- package/dist/knowledge/workspace-lists.js +1 -1
- package/dist/monitor/MonitorLoop.d.ts +2 -0
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/monitor/ScopeResolver.js +1 -1
- package/dist/monitor/SuggestionBridge.d.ts +38 -0
- package/dist/monitor/SuggestionBridge.js +1 -0
- package/dist/participation/arbitrator-interest.d.ts +20 -0
- package/dist/participation/arbitrator-interest.js +1 -0
- package/dist/participation/demander-interest.d.ts +23 -0
- package/dist/participation/demander-interest.js +1 -0
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/context-assembly.js +1 -1
- package/dist/playbooks/service-build/machine-nodes.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/merchant-guide.d.ts +20 -0
- package/dist/playbooks/service-build/merchant-guide.js +1 -1
- package/dist/playbooks/service-build/mode-actions.d.ts +30 -6
- package/dist/playbooks/service-build/mode-actions.js +1 -1
- package/dist/playbooks/service-build/object-panorama.js +1 -1
- package/dist/playbooks/service-build/participation-radar.js +1 -1
- package/dist/playbooks/service-build/relationship-profile.d.ts +2 -0
- package/dist/playbooks/service-build/relationship-profile.js +1 -0
- package/dist/playbooks/service-build/semantic-graph.d.ts +5 -1
- package/dist/playbooks/service-build/semantic-graph.js +1 -1
- package/dist/playbooks/service-build/service-panorama.js +1 -1
- package/dist/relationship/derivation.d.ts +88 -0
- package/dist/relationship/derivation.js +1 -0
- package/dist/relationship/incentive.d.ts +38 -0
- package/dist/relationship/incentive.js +1 -0
- package/dist/relationship/index.d.ts +4 -0
- package/dist/relationship/index.js +1 -0
- package/dist/relationship/registry.d.ts +13 -0
- package/dist/relationship/registry.js +1 -0
- package/dist/relationship/types.d.ts +45 -0
- package/dist/relationship/types.js +1 -0
- package/dist/review/progress.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/safety/preview.js +1 -1
- package/dist/schema/call/bridge.d.ts +25 -3
- package/dist/schema/call/bridge.js +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/goal/index.d.ts +40 -14
- package/dist/schema/goal/index.js +1 -1
- package/dist/schema/goal/planning.d.ts +6 -6
- package/dist/schema/industry-pack/index.d.ts +58 -0
- package/dist/schema/industry-pack/index.js +1 -1
- package/dist/schema/industry-pack/modes.d.ts +59 -1
- package/dist/schema/industry-pack/modes.js +1 -1
- package/dist/schema/intent-radar/index.d.ts +19 -19
- package/dist/schema/local/index.d.ts +11 -0
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/operations.d.ts +58 -16
- package/dist/schema/persona/index.d.ts +1 -1
- package/dist/schema/query/bi.d.ts +145 -16
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.d.ts +2 -2
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +29 -0
- package/dist/schemas/account_operation.schema.json +6 -2
- package/dist/schemas/bridge_operation.output.json +24 -1
- package/dist/schemas/bridge_operation.schema.json +73 -1
- package/dist/schemas/goal_operation.schema.json +76 -0
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/industry_pack_operation.output.json +176 -1
- package/dist/schemas/industry_pack_operation.schema.json +19 -0
- package/dist/schemas/onchain_events.output.json +1 -1
- package/dist/schemas/onchain_operations.schema.json +41 -41
- package/dist/schemas/onchain_operations_allocation.schema.json +4 -4
- package/dist/schemas/onchain_operations_arbitration.schema.json +3 -3
- package/dist/schemas/onchain_operations_contact.schema.json +2 -2
- package/dist/schemas/onchain_operations_demand.schema.json +2 -2
- package/dist/schemas/onchain_operations_machine.schema.json +2 -2
- package/dist/schemas/onchain_operations_order.schema.json +2 -2
- package/dist/schemas/onchain_operations_payment.schema.json +1 -1
- package/dist/schemas/onchain_operations_permission.schema.json +2 -2
- package/dist/schemas/onchain_operations_progress.schema.json +2 -2
- package/dist/schemas/onchain_operations_repository.schema.json +2 -2
- package/dist/schemas/onchain_operations_reward.schema.json +6 -6
- package/dist/schemas/onchain_operations_service.schema.json +7 -7
- package/dist/schemas/onchain_operations_treasury.schema.json +6 -6
- package/dist/schemas/onchain_table_data.output.json +53 -0
- package/dist/schemas/query_toolkit.output.json +240 -7
- package/dist/schemas/query_toolkit.schema.json +53 -0
- package/dist/task/ProcessStore.d.ts +18 -1
- package/dist/task/ProcessStore.js +1 -1
- package/dist/task/types.d.ts +24 -0
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/evaluation.js +1 -1
- package/dist/tools/handlers/goal.js +1 -1
- package/dist/tools/handlers/industry-pack.js +1 -1
- package/dist/tools/handlers/local.d.ts +4 -3
- package/dist/tools/handlers/local.js +1 -1
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/permission.js +1 -1
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/workflow.js +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/rules-hook.d.ts +1 -0
- package/dist/tools/rules-hook.js +1 -1
- package/dist/tools/shared.js +1 -1
- package/package.json +2 -2
- package/dist/mode-market/index.d.ts +0 -3
- package/dist/mode-market/index.js +0 -1
- package/dist/mode-market/registry.d.ts +0 -53
- package/dist/mode-market/registry.js +0 -1
- package/dist/mode-market/review.d.ts +0 -27
- package/dist/mode-market/review.js +0 -1
- package/dist/mode-market/submission.d.ts +0 -25
- package/dist/mode-market/submission.js +0 -1
|
@@ -18,9 +18,6 @@ export interface CapabilityBenefitProfile {
|
|
|
18
18
|
export interface CapabilityConstraints {
|
|
19
19
|
must_pair_with?: string[];
|
|
20
20
|
conflicts_with?: string[];
|
|
21
|
-
max_single_transaction?: number;
|
|
22
|
-
requires_evidence?: boolean;
|
|
23
|
-
other_constraints?: string[];
|
|
24
21
|
}
|
|
25
22
|
export interface CapabilityCard {
|
|
26
23
|
capability_id: string;
|
|
@@ -30,96 +27,18 @@ export interface CapabilityCard {
|
|
|
30
27
|
module: CapabilityModule;
|
|
31
28
|
category: CapabilityCategory;
|
|
32
29
|
industry_agnostic: IndustryAgnostic;
|
|
33
|
-
config_template: Record<string, unknown>;
|
|
34
|
-
industry_overrides?: Record<string, Record<string, unknown>>;
|
|
35
|
-
observed_in_industries: Record<string, number>;
|
|
36
|
-
success_count: number;
|
|
37
|
-
failure_count: number;
|
|
38
|
-
known_failure_modes: string[];
|
|
39
|
-
depends_on_capabilities?: string[];
|
|
40
|
-
referenced_by_skills?: string[];
|
|
41
30
|
risk_profile?: CapabilityRiskProfile;
|
|
42
31
|
benefit_profile?: CapabilityBenefitProfile;
|
|
43
32
|
constraints?: CapabilityConstraints;
|
|
44
|
-
version: string;
|
|
45
|
-
superseded_by?: string;
|
|
46
|
-
}
|
|
47
|
-
export interface CapabilityGraphEdge {
|
|
48
|
-
from: string;
|
|
49
|
-
to: string;
|
|
50
|
-
edge_kind: "requires" | "optional" | "conflicts";
|
|
51
|
-
phase: "create" | "publish" | "runtime";
|
|
52
|
-
description?: string;
|
|
53
|
-
}
|
|
54
|
-
export interface CapabilityGraph {
|
|
55
|
-
nodes: Map<string, CapabilityCard>;
|
|
56
|
-
edges: CapabilityGraphEdge[];
|
|
57
|
-
}
|
|
58
|
-
export interface MigrationEvaluation {
|
|
59
|
-
feasibility_score: number;
|
|
60
|
-
covered_capabilities: string[];
|
|
61
|
-
missing_capabilities: string[];
|
|
62
|
-
conflicting_capabilities: Array<{
|
|
63
|
-
capability_id: string;
|
|
64
|
-
source_config: unknown;
|
|
65
|
-
target_config: unknown;
|
|
66
|
-
diff_summary: string;
|
|
67
|
-
}>;
|
|
68
|
-
recommendations: string[];
|
|
69
|
-
}
|
|
70
|
-
export interface CoverageReport {
|
|
71
|
-
industry: string;
|
|
72
|
-
declared_count: number;
|
|
73
|
-
expected_count: number;
|
|
74
|
-
coverage_percentage: number;
|
|
75
|
-
missing_capabilities: string[];
|
|
76
|
-
}
|
|
77
|
-
export interface ExperienceUpdate {
|
|
78
|
-
capability_id: string;
|
|
79
|
-
update_type: "config_template" | "industry_overrides" | "known_failure_modes" | "new_card";
|
|
80
|
-
payload: unknown;
|
|
81
|
-
source: string;
|
|
82
|
-
}
|
|
83
|
-
export interface VerificationReport {
|
|
84
|
-
project_id: string;
|
|
85
|
-
industry: string;
|
|
86
|
-
result: "success" | "failure" | "partial";
|
|
87
|
-
capabilities_used: string[];
|
|
88
|
-
failure_reasons?: string[];
|
|
89
33
|
}
|
|
90
34
|
export declare class CapabilityRegistry {
|
|
91
35
|
private static instance;
|
|
92
36
|
private cards;
|
|
93
|
-
private edges;
|
|
94
|
-
private initialized;
|
|
95
37
|
static Instance(): CapabilityRegistry;
|
|
96
38
|
private constructor();
|
|
97
39
|
registerCard(card: CapabilityCard): boolean;
|
|
98
40
|
getCard(capabilityId: string): CapabilityCard | undefined;
|
|
99
|
-
listCards(filter?: {
|
|
100
|
-
objectType?: ProjectObjectType;
|
|
101
|
-
module?: CapabilityModule;
|
|
102
|
-
industryAgnostic?: IndustryAgnostic;
|
|
103
|
-
industry?: string;
|
|
104
|
-
}): CapabilityCard[];
|
|
105
|
-
registerEdge(edge: CapabilityGraphEdge): void;
|
|
106
|
-
getGraph(): CapabilityGraph;
|
|
107
|
-
getDependencies(capabilityId: string): CapabilityCard[];
|
|
108
|
-
getDependents(capabilityId: string): CapabilityCard[];
|
|
109
|
-
getCapabilitiesByIndustry(industry: string): CapabilityCard[];
|
|
110
|
-
getCapabilitiesByObject(objectType: ProjectObjectType): CapabilityCard[];
|
|
111
|
-
evaluateMigration(source: string, target: string): MigrationEvaluation;
|
|
112
|
-
findPurityViolations(): CapabilityCard[];
|
|
113
|
-
recordUsage(capabilityId: string, industry: string): void;
|
|
114
|
-
recordSuccess(capabilityId: string): void;
|
|
115
|
-
recordFailure(capabilityId: string, reason: string): void;
|
|
116
|
-
recordVerificationReport(report: VerificationReport): void;
|
|
117
|
-
getCapabilitiesForExtension(capabilitiesUsed: string[]): CapabilityCard[];
|
|
118
|
-
evaluateExtensionCoverage(industry: string, capabilitiesUsed: string[]): CoverageReport;
|
|
119
41
|
private registerBuiltins;
|
|
120
|
-
private registerBuiltinEdges;
|
|
121
|
-
private computeConfigDiff;
|
|
122
42
|
}
|
|
123
43
|
export declare function getCapabilityRegistry(): CapabilityRegistry;
|
|
124
|
-
export declare const CAPABILITY_MANIFEST_VERSION =
|
|
125
|
-
export declare function recordCapabilitiesUsed(industry: string, capabilitiesUsed: string[]): void;
|
|
44
|
+
export declare const CAPABILITY_MANIFEST_VERSION = 2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export class CapabilityRegistry{static ['instance'];['cards']=new Map();['edges']=[];['initialized']=![];static['Instance'](){return!CapabilityRegistry['instance']&&(CapabilityRegistry['instance']=new CapabilityRegistry()),CapabilityRegistry['instance'];}constructor(){this['registerBuiltins'](),this['registerBuiltinEdges'](),this['initialized']=!![];}['registerCard'](a){if(!a['capability_id']||!a['object_type']||!a['module'])return![];return this['cards']['set'](a['capability_id'],a),!![];}['getCard'](a){return this['cards']['get'](a);}['listCards'](a){let b=Array['from'](this['cards']['values']());if(!a)return b;if(a['objectType'])b=b['filter'](d=>d['object_type']===a['objectType']);if(a['module'])b=b['filter'](d=>d['module']===a['module']);if(a['industryAgnostic'])b=b['filter'](d=>d['industry_agnostic']===a['industryAgnostic']);if(a['industry'])b=b['filter'](d=>d['observed_in_industries'][a['industry']]!==undefined||d['industry_overrides']?.[a['industry']]!==undefined);return b;}['registerEdge'](a){this['edges']['push'](a);}['getGraph'](){return{'nodes':new Map(this['cards']),'edges':[...this['edges']]};}['getDependencies'](a){const b=new Set(),c=[],d=e=>{if(b['has'](e))return;b['add'](e);for(const f of this['edges']){if(f['from']===e&&f['edge_kind']==='requires'){const g=this['cards']['get'](f['to']);g&&!b['has'](g['capability_id'])&&(c['push'](g),d(f['to']));}}};return d(a),c;}['getDependents'](a){const b=[];for(const c of this['edges']){if(c['to']===a&&c['edge_kind']==='requires'){const d=this['cards']['get'](c['from']);if(d)b['push'](d);}}return b;}['getCapabilitiesByIndustry'](a){return this['listCards']({'industry':a});}['getCapabilitiesByObject'](a){return this['listCards']({'objectType':a});}['evaluateMigration'](a,b){const c=this['getCapabilitiesByIndustry'](a),d=this['getCapabilitiesByIndustry'](b),e=new Set(c['map'](l=>l['capability_id'])),f=new Set(d['map'](l=>l['capability_id'])),g=[],h=[],i=[];for(const l of e){if(f['has'](l)){g['push'](l);const m=c['find'](p=>p['capability_id']===l),n=d['find'](p=>p['capability_id']===l),o=this['computeConfigDiff'](m['industry_overrides']?.[a]??m['config_template'],n['industry_overrides']?.[b]??n['config_template']);o['diff_ratio']>0.5&&i['push']({'capability_id':l,'source_config':m['industry_overrides']?.[a]??m['config_template'],'target_config':n['industry_overrides']?.[b]??n['config_template'],'diff_summary':o['summary']});}}for(const p of f){if(!e['has'](p))h['push'](p);}const j=g['length']===0x0&&h['length']===0x0?0x0:Math['round']((g['length']-i['length'])/(g['length']+h['length'])*0x64),k=[];h['length']>0x0&&k['push']('Missing\x20'+h['length']+'\x20capabilities,\x20need\x20to\x20add:\x20'+h['slice'](0x0,0x5)['join'](',\x20')+(h['length']>0x5?'...':''));i['length']>0x0&&k['push']('Detected\x20'+i['length']+'\x20capabilities\x20with\x20large\x20parameter\x20differences,\x20need\x20to\x20rewrite\x20configuration');if(j>=0x50)k['push']('Migration\x20feasibility\x20is\x20high,\x20most\x20capabilities\x20can\x20be\x20reused\x20directly');else j>=0x32?k['push']('Migration\x20feasibility\x20is\x20medium,\x20need\x20to\x20supplement\x20or\x20rewrite\x20some\x20capabilities'):k['push']('Migration\x20feasibility\x20is\x20low,\x20recommend\x20regenerating\x20the\x20plan\x20based\x20on\x20the\x20target\x20industry\x20template');return{'feasibility_score':j,'covered_capabilities':g,'missing_capabilities':h,'conflicting_capabilities':i,'recommendations':k};}['findPurityViolations'](){return Array['from'](this['cards']['values']())['filter'](a=>{if(a['industry_agnostic']!=='high')return![];const b=a['industry_overrides']?Object['keys'](a['industry_overrides'])['length']:0x0;return b>=0x3;});}['recordUsage'](a,b){const c=this['cards']['get'](a);if(!c)return;!c['observed_in_industries'][b]&&(c['observed_in_industries'][b]=0x0),c['observed_in_industries'][b]++;}['recordSuccess'](a){const b=this['cards']['get'](a);if(b)b['success_count']++;}['recordFailure'](a,b){const c=this['cards']['get'](a);if(!c)return;c['failure_count']++,b&&!c['known_failure_modes']['includes'](b)&&c['known_failure_modes']['push'](b);}['recordVerificationReport'](a){for(const b of a['capabilities_used']){this['recordUsage'](b,a['industry']);if(a['result']==='success')this['recordSuccess'](b);else{if(a['result']==='failure'){const c=a['failure_reasons']?.[0x0]??'unknown\x20failure';this['recordFailure'](b,c);}}}}['getCapabilitiesForExtension'](a){return a['map'](b=>this['cards']['get'](b))['filter'](b=>b!==undefined);}['evaluateExtensionCoverage'](a,b){const c=b['length'],d=this['getCapabilitiesByIndustry'](a),e=d['length']||c,f=d['filter'](h=>!b['includes'](h['capability_id']))['map'](h=>h['capability_id']),g=e===0x0?0x64:Math['round'](c/e*0x64);return{'industry':a,'declared_count':c,'expected_count':e,'coverage_percentage':Math['min'](g,0x64),'missing_capabilities':f};}['registerBuiltins'](){this['registerCard']({'capability_id':'permission.index_create','display_name':'Permission\x20Index\x20Create','description':'Create\x20role\x20permission\x20index,\x20supports\x20multi-role\x20permission\x20assignment\x20such\x20as\x20merchant/customer/arbiter','object_type':'permission','module':'handler','category':'trust','industry_agnostic':'high','config_template':{'permission_indexes':[{'name':'merchant','description':'Service\x20owner'},{'name':'customer','description':'Service\x20buyer'}]},'industry_overrides':{'education':{'permission_indexes':[{'name':'teacher','description':'Course\x20provider'},{'name':'student','description':'Course\x20consumer'},{'name':'parent','description':'Guardian\x20(minor)'}]},'travel':{'permission_indexes':[{'name':'guide','description':'Tour\x20guide'},{'name':'tourist','description':'Tour\x20participant'}]}},'observed_in_industries':{},'success_count':0x0,'failure_count':0x0,'known_failure_modes':[],'depends_on_capabilities':[],'version':'v1','risk_profile':{'funds_risk':'low','trust_risk':'low','delivery_risk':'low','compliance_risk':'low','known_risks':['Index\x20proliferation\x20without\x20naming\x20convention\x20makes\x20permission\x20audits\x20harder']},'benefit_profile':{'automation_level':'medium','trust_boost':'high','efficiency_gain':'medium','benefits':['Role-based\x20governance\x20foundation\x20for\x20all\x20other\x20objects']}}),this['registerCard']({'capability_id':'permission.role_assign','display_name':'Permission\x20Role\x20Assign','description':'Assign\x20role\x20permission\x20index\x20to\x20objects\x20(Machine/Service/Allocation)','object_type':'permission','module':'handler','category':'trust','industry_agnostic':'high','config_template':{'target_object':'<obj>','role':'<role_name>'},'observed_in_industries':{},'success_count':0x0,'failure_count':0x0,'known_failure_modes':[],'depends_on_capabilities':['permission.index_create'],'version':'v1','risk_profile':{'funds_risk':'low','trust_risk':'medium','delivery_risk':'low','compliance_risk':'low','known_risks':['Mis-assigned\x20role\x20grants\x20unintended\x20operational\x20authority']},'benefit_profile':{'automation_level':'high','trust_boost':'high','efficiency_gain':'medium','benefits':['Binds\x20governance\x20roles\x20to\x20concrete\x20objects']}}),this['registerCard']({'capability_id':'guard.validate_buy','display_name':'Guard\x20Validate\x20Buy','description':'Order\x20validation:\x20check\x20buyer\x20eligibility,\x20order\x20parameters,\x20inventory\x20and\x20other\x20conditions','object_type':'guard','module':'handler','category':'validation','industry_agnostic':'medium','config_template':{'host':'service','templates':[]},'industry_overrides':{'retail':{'templates':['tpl_check_inventory','tpl_check_buyer_address']},'freelance':{'templates':['tpl_check_buyer_budget','tpl_check_freelancer_available']},'rental':{'templates':['tpl_check_deposit','tpl_check_item_available']}},'observed_in_industries':{},'success_count':0x0,'failure_count':0x0,'known_failure_modes':[],'depends_on_capabilities':['permission.index_create'],'version':'v1','risk_profile':{'funds_risk':'low','trust_risk':'medium','delivery_risk':'medium','compliance_risk':'low','known_risks':['Over-strict\x20buy\x20validation\x20blocks\x20legitimate\x20orders;\x20over-loose\x20validation\x20admits\x20fraud']},'benefit_profile':{'automation_level':'high','trust_boost':'high','efficiency_gain':'high','benefits':['Automated\x20purchase\x20gating\x20without\x20manual\x20review']}}),this['registerCard']({'capability_id':'guard.validate_wip_hash','display_name':'Guard\x20Validate\x20WIP\x20Hash','description':'Validate\x20WIP\x20(Work-In-Progress)\x20hash,\x20used\x20for\x20milestone\x20validation\x20of\x20digital\x20deliverables','object_type':'guard','module':'handler','category':'evidence','industry_agnostic':'low','config_template':{'host':'machine','templates':['tpl_validate_wip_hash']},'industry_overrides':{'freelance':{'templates':['tpl_validate_wip_hash','tpl_validate_deliverable_format']}},'observed_in_industries':{},'success_count':0x0,'failure_count':0x0,'known_failure_modes':['milestone\x20mode\x20requires\x20WIP\x20hash\x20evidence\x20—\x20without\x20WIP,\x20allocation\x20cannot\x20advance'],'depends_on_capabilities':['guard.validate_buy'],'version':'v1','risk_profile':{'funds_risk':'low','trust_risk':'medium','delivery_risk':'high','compliance_risk':'low','known_risks':['Wrong\x20hash\x20algorithm\x20or\x20field\x20mapping\x20stalls\x20milestone\x20release']},'benefit_profile':{'automation_level':'high','trust_boost':'medium','efficiency_gain':'medium','benefits':['Tamper-proof\x20delivery\x20evidence\x20for\x20digital\x20deliverables']}}),this['registerCard']({'capability_id':'machine.node_topology','display_name':'Machine\x20Node\x20Topology','description':'Workflow\x20node\x20topology:\x20define\x20the\x20state\x20machine\x20from\x20order\x20creation\x20to\x20completion','object_type':'machine','module':'templates','category':'workflow','industry_agnostic':'low','config_template':{'nodes':[{'name':'paid','role':'Entry:\x20order\x20created\x20and\x20paid'},{'name':'delivering','role':'Service\x20delivery\x20in\x20progress'},{'name':'delivered','role':'Deliverable\x20available\x20for\x20review'},{'name':'completed','role':'Service\x20completed,\x20funds\x20released'},{'name':'cancelled','role':'Pre-delivery\x20cancellation\x20—\x20triggers\x20refund\x20Allocator'}]},'industry_overrides':{'retail':{'nodes':[{'name':'paid','role':'Order\x20paid'},{'name':'shipped','role':'Goods\x20shipped'},{'name':'delivered','role':'Goods\x20delivered'},{'name':'confirmed','role':'Buyer\x20confirms\x20receipt'},{'name':'completed','role':'Funds\x20released'},{'name':'returned','role':'Buyer\x20ships\x20goods\x20back\x20—\x20triggers\x20refund\x20Allocator\x20(R-M1-11)'},{'name':'cancelled','role':'Pre-ship\x20cancellation'}]},'freelance':{'nodes':[{'name':'paid','role':'Order\x20paid\x20(escrow)'},{'name':'in_progress','role':'Freelancer\x20working'},{'name':'submitted','role':'Work\x20submitted\x20for\x20review'},{'name':'accepted','role':'Buyer\x20accepts\x20deliverable'},{'name':'completed','role':'Funds\x20released'},{'name':'revision','role':'Revision\x20requested'},{'name':'cancelled','role':'Pre-start\x20cancellation\x20—\x20triggers\x20refund\x20Allocator\x20(R-M1-11)'}]}},'observed_in_industries':{},'success_count':0x0,'failure_count':0x0,'known_failure_modes':[],'depends_on_capabilities':['permission.index_create'],'version':'v1','risk_profile':{'funds_risk':'low','trust_risk':'medium','delivery_risk':'high','compliance_risk':'low','known_risks':['Dead-end\x20nodes\x20or\x20missing\x20refund\x20paths\x20trap\x20order\x20funds']},'benefit_profile':{'automation_level':'medium','trust_boost':'medium','efficiency_gain':'high','benefits':['Declarative\x20workflow\x20from\x20order\x20creation\x20to\x20completion']}}),this['registerCard']({'capability_id':'treasury.owner_receive','display_name':'Treasury\x20Owner\x20Receive','description':'Fund\x20escrow:\x20supports\x20owner_receive\x20mode,\x20funds\x20go\x20directly\x20into\x20the\x20object\x20owner\x20wallet','object_type':'treasury','module':'handler','category':'fund_flow','industry_agnostic':'high','config_template':{'owner_receive':!![]},'observed_in_industries':{},'success_count':0x0,'failure_count':0x0,'known_failure_modes':[],'depends_on_capabilities':[],'version':'v1','risk_profile':{'funds_risk':'high','trust_risk':'medium','delivery_risk':'low','compliance_risk':'low','known_risks':['Direct\x20fund\x20custody\x20—\x20misconfigured\x20owner\x20diverts\x20all\x20proceeds']},'benefit_profile':{'automation_level':'high','trust_boost':'medium','efficiency_gain':'medium','benefits':['Automated\x20escrow\x20and\x20owner\x20settlement']}}),this['registerCard']({'capability_id':'allocation.distribute','display_name':'Multi-tier\x20Allocation\x20Distribution','description':'Multi-tier\x20allocation:\x20supports\x20distributing\x20funds\x20to\x20multiple\x20recipients\x20by\x20ratio\x20/\x20by\x20order\x20/\x20by\x20condition','object_type':'allocation','module':'handler','category':'fund_flow','industry_agnostic':'medium','config_template':{'strategy':{'recipient':'entity','count':0x1,'mode':'surplus','description':'Default:\x20all\x20to\x20service\x20owner'}},'industry_overrides':{'retail':{'strategy':{'recipient':'entity','count':0x2,'mode':'rate','description':'Platform\x2010%\x20+\x20Merchant\x2090%'}},'freelance':{'strategy':{'recipient':'entity','count':0x2,'mode':'milestone','description':'50%\x20upfront\x20+\x2050%\x20on\x20delivery'}},'travel':{'strategy':{'recipient':'entity','count':0x3,'mode':'rate','description':'Guide\x2060%\x20+\x20Platform\x2030%\x20+\x20Insurance\x2010%'}}},'observed_in_industries':{},'success_count':0x0,'failure_count':0x0,'known_failure_modes':['milestone\x20mode\x20requires\x20WIP\x20hash\x20evidence\x20—\x20without\x20WIP,\x20allocation\x20cannot\x20advance'],'depends_on_capabilities':['treasury.owner_receive','guard.validate_buy'],'version':'v1','risk_profile':{'funds_risk':'high','trust_risk':'low','delivery_risk':'medium','compliance_risk':'low','known_risks':['Wrong\x20split\x20ratios\x20or\x20recipient\x20addresses\x20misdirect\x20settlement\x20funds']},'benefit_profile':{'automation_level':'high','trust_boost':'medium','efficiency_gain':'high','benefits':['Multi-recipient\x20settlement\x20without\x20manual\x20transfers']}}),this['registerCard']({'capability_id':'allocation.distribute_milestone','display_name':'Milestone-based\x20Allocation','description':'Milestone\x20allocation:\x20release\x20funds\x20by\x20delivery\x20milestones,\x20each\x20milestone\x20requires\x20WIP\x20hash\x20validation','object_type':'allocation','module':'handler','category':'fund_flow','industry_agnostic':'low','config_template':{'strategy':{'recipient':'entity','count':0x2,'mode':'milestone','description':'Milestone-based\x20release'}},'industry_overrides':{'freelance':{'strategy':{'recipient':'entity','count':0x2,'mode':'milestone','description':'50%\x20upfront\x20+\x2050%\x20on\x20delivery'}},'education':{'strategy':{'recipient':'entity','count':0x2,'mode':'milestone','description':'Per\x20session\x20release'}}},'observed_in_industries':{},'success_count':0x0,'failure_count':0x0,'known_failure_modes':[],'depends_on_capabilities':['allocation.distribute','guard.validate_wip_hash'],'version':'v1','risk_profile':{'funds_risk':'high','trust_risk':'medium','delivery_risk':'medium','compliance_risk':'low','known_risks':['Stuck\x20milestone\x20gates\x20lock\x20buyer\x20funds\x20until\x20evidence\x20is\x20supplied']},'benefit_profile':{'automation_level':'medium','trust_boost':'high','efficiency_gain':'medium','benefits':['Evidence-gated\x20release\x20protects\x20both\x20buyer\x20and\x20provider']}}),this['registerCard']({'capability_id':'service.publish','display_name':'Service\x20Publish','description':'Publish\x20Service\x20object\x20on-chain,\x20bind\x20Machine/Guard/Permission/Allocation\x20and\x20other\x20dependencies','object_type':'service','module':'handler','category':'lifecycle','industry_agnostic':'high','config_template':{'machine':'<machine_name>','buy_guard':'<guard_name>','permission':'<permission_name>','order_allocators':['<allocation_name>'],'compensation_fund_balance':0x0,'compensation_fund_add_hint':'Post-publish:\x20call\x20service.compensation_fund_add\x20with\x20Coin<T>.\x20Recommend\x203-10×\x20max\x20single-order\x20amount\x20(industry-specific:\x20subscription\x203×,\x20retail\x205×,\x20rental\x2010×).'},'observed_in_industries':{},'success_count':0x0,'failure_count':0x0,'known_failure_modes':[],'depends_on_capabilities':['machine.node_topology','guard.validate_buy','permission.index_create','allocation.distribute','treasury.owner_receive'],'version':'v1','risk_profile':{'funds_risk':'medium','trust_risk':'medium','delivery_risk':'medium','compliance_risk':'medium','known_risks':['Publish\x20freezes\x20machine\x20binding\x20and\x20order_allocators\x20permanently\x20(E_ALREADY_PUBLISHED)']},'benefit_profile':{'automation_level':'medium','trust_boost':'medium','efficiency_gain':'medium','benefits':['On-chain\x20discoverability\x20and\x20order\x20intake']}}),this['registerCard']({'capability_id':'progress.advance','display_name':'Progress\x20Advance','description':'Order\x20fulfillment\x20progress\x20advance:\x20advance\x20to\x20next\x20state\x20based\x20on\x20Machine\x20node\x20topology','object_type':'progress','module':'handler','category':'workflow','industry_agnostic':'medium','config_template':{'parent':'<machine_name>'},'observed_in_industries':{},'success_count':0x0,'failure_count':0x0,'known_failure_modes':[],'depends_on_capabilities':['machine.node_topology'],'version':'v1','risk_profile':{'funds_risk':'medium','trust_risk':'low','delivery_risk':'high','compliance_risk':'low','known_risks':['Forward\x20without\x20authorized\x20executor\x20permanently\x20stalls\x20the\x20order']},'benefit_profile':{'automation_level':'high','trust_boost':'medium','efficiency_gain':'high','benefits':['Deterministic\x20order\x20state\x20progression']}}),this['registerCard']({'capability_id':'arb.vote_weighted','display_name':'Arbitration\x20Vote\x20Weighted','description':'guard-based\x20weighted\x20voting\x20arbitration:\x20vote\x20by\x20Guard\x20weight\x20to\x20determine\x20arbitration\x20result','object_type':'arb','module':'handler','category':'trust','industry_agnostic':'medium','config_template':{'guard':'<guard_name>','voting_rule':'guard_weighted'},'observed_in_industries':{},'success_count':0x0,'failure_count':0x0,'known_failure_modes':[],'depends_on_capabilities':['guard.validate_buy'],'version':'v1','risk_profile':{'funds_risk':'low','trust_risk':'high','delivery_risk':'medium','compliance_risk':'medium','known_risks':['Shared\x20permission\x20with\x20Service\x20destroys\x20dispute\x20independence\x20(E_ARBITRATION_PERMISSION_CONFLICT)']},'benefit_profile':{'automation_level':'medium','trust_boost':'high','efficiency_gain':'low','benefits':['Neutral\x20third-party\x20dispute\x20resolution']}}),this['registerCard']({'capability_id':'reward.claim_guard','display_name':'Reward\x20Claim\x20Guard','description':'Reward\x20claim:\x20release\x20reward\x20after\x20validating\x20claim\x20conditions\x20(such\x20as\x20positive\x20review,\x20repurchase)\x20via\x20Guard','object_type':'reward','module':'handler','category':'fund_flow','industry_agnostic':'medium','config_template':{'claim_guard':'<guard_name>','max_guard_count':0x1},'observed_in_industries':{},'success_count':0x0,'failure_count':0x0,'known_failure_modes':[],'depends_on_capabilities':['guard.validate_buy'],'version':'v1','risk_profile':{'funds_risk':'medium','trust_risk':'low','delivery_risk':'low','compliance_risk':'low','known_risks':['Loose\x20claim\x20conditions\x20drain\x20the\x20reward\x20pool']},'benefit_profile':{'automation_level':'high','trust_boost':'medium','efficiency_gain':'medium','benefits':['Incentivizes\x20reviews\x20and\x20repurchase']}}),this['registerCard']({'capability_id':'contact.im_create','display_name':'Contact\x20IM\x20Create','description':'Create\x20IM\x20contact\x20object:\x20buyer\x20and\x20seller\x20communicate\x20via\x20Messenger','object_type':'contact','module':'handler','category':'communication','industry_agnostic':'high','config_template':{},'observed_in_industries':{},'success_count':0x0,'failure_count':0x0,'known_failure_modes':[],'depends_on_capabilities':[],'version':'v1','risk_profile':{'funds_risk':'low','trust_risk':'low','delivery_risk':'low','compliance_risk':'low','known_risks':['Unattended\x20IM\x20channel\x20degrades\x20dispute\x20response\x20time']},'benefit_profile':{'automation_level':'medium','trust_boost':'medium','efficiency_gain':'medium','benefits':['Direct\x20buyer-seller\x20encrypted\x20communication']}}),this['registerCard']({'capability_id':'demand.matching','display_name':'Demand\x20Matching','description':'Demand\x20matching:\x20match\x20corresponding\x20Service\x20based\x20on\x20user\x20demand','object_type':'demand','module':'handler','category':'query','industry_agnostic':'high','config_template':{},'observed_in_industries':{},'success_count':0x0,'failure_count':0x0,'known_failure_modes':[],'depends_on_capabilities':['service.publish'],'version':'v1','risk_profile':{'funds_risk':'low','trust_risk':'low','delivery_risk':'low','compliance_risk':'low','known_risks':['Poor\x20matching\x20signals\x20bury\x20quality\x20services']},'benefit_profile':{'automation_level':'medium','trust_boost':'low','efficiency_gain':'medium','benefits':['Demand-side\x20discovery\x20channel']}}),this['registerCard']({'capability_id':'repository.write_validate','display_name':'Repository\x20Write\x20Validate','description':'Knowledge\x20base\x20write\x20validation:\x20validate\x20write\x20permissions\x20and\x20data\x20format\x20via\x20Guard','object_type':'repository','module':'handler','category':'validation','industry_agnostic':'high','config_template':{},'observed_in_industries':{},'success_count':0x0,'failure_count':0x0,'known_failure_modes':[],'depends_on_capabilities':['guard.validate_buy'],'version':'v1','risk_profile':{'funds_risk':'low','trust_risk':'medium','delivery_risk':'low','compliance_risk':'medium','known_risks':['Unvalidated\x20writes\x20pollute\x20the\x20knowledge\x20base\x20with\x20unverifiable\x20claims']},'benefit_profile':{'automation_level':'medium','trust_boost':'high','efficiency_gain':'medium','benefits':['Guard-gated\x20attestation\x20for\x20off-chain\x20data']}}),this['registerCard']({'capability_id':'proof.evidence_anchor','display_name':'Proof\x20Evidence\x20Anchor','description':'Evidence\x20on-chain:\x20anchor\x20delivery\x20evidence\x20(hash)\x20to\x20on-chain\x20Progress\x20node','object_type':'proof','module':'handler','category':'evidence','industry_agnostic':'medium','config_template':{},'observed_in_industries':{},'success_count':0x0,'failure_count':0x0,'known_failure_modes':[],'depends_on_capabilities':['progress.advance'],'version':'v1','risk_profile':{'funds_risk':'low','trust_risk':'medium','delivery_risk':'low','compliance_risk':'low','known_risks':['Anchored\x20evidence\x20is\x20immutable\x20—\x20wrong\x20hash\x20cannot\x20be\x20corrected']},'benefit_profile':{'automation_level':'high','trust_boost':'high','efficiency_gain':'medium','benefits':['Immutable\x20WTS\x20evidence\x20for\x20Messenger\x20confirmations']}}),this['registerCard']({'capability_id':'personal.profile_manage','display_name':'Personal\x20Profile\x20Manage','description':'Personal\x20profile\x20management:\x20user\x20identity/preference/history\x20management','object_type':'personal','module':'handler','category':'data_model','industry_agnostic':'high','config_template':{},'observed_in_industries':{},'success_count':0x0,'failure_count':0x0,'known_failure_modes':[],'depends_on_capabilities':[],'version':'v1','risk_profile':{'funds_risk':'low','trust_risk':'low','delivery_risk':'low','compliance_risk':'medium','known_risks':['Profile\x20data\x20may\x20fall\x20under\x20privacy\x20regulation\x20(PII)']},'benefit_profile':{'automation_level':'medium','trust_boost':'low','efficiency_gain':'low','benefits':['Portable\x20user\x20identity\x20across\x20services']}}),this['registerCard']({'capability_id':'payment.settle','display_name':'Payment\x20Settle','description':'Payment\x20settlement:\x20complete\x20fund\x20settlement\x20in\x20collaboration\x20with\x20Allocation','object_type':'payment','module':'handler','category':'fund_flow','industry_agnostic':'high','config_template':{},'observed_in_industries':{},'success_count':0x0,'failure_count':0x0,'known_failure_modes':[],'depends_on_capabilities':['allocation.distribute','treasury.owner_receive'],'version':'v1','risk_profile':{'funds_risk':'high','trust_risk':'low','delivery_risk':'low','compliance_risk':'medium','known_risks':['Settlement\x20errors\x20are\x20irreversible\x20once\x20funds\x20transfer']},'benefit_profile':{'automation_level':'high','trust_boost':'low','efficiency_gain':'high','benefits':['Atomic\x20settlement\x20in\x20collaboration\x20with\x20Allocation']}}),this['registerCard']({'capability_id':'guard.validate_withdraw','display_name':'Guard\x20Validate\x20Withdraw','description':'Withdrawal\x20validation:\x20gate\x20fund\x20release\x20from\x20Allocation\x20escrow\x20on\x20delivery\x20confirmation','object_type':'guard','module':'handler','category':'validation','industry_agnostic':'medium','config_template':{'host':'service','templates':['tpl_withdraw_on_completed']},'industry_overrides':{'retail_d2c':{'templates':['tpl_withdraw_on_completed']}},'observed_in_industries':{},'success_count':0x0,'failure_count':0x0,'known_failure_modes':['Withdraw\x20gate\x20on\x20wrong\x20node\x20lets\x20merchant\x20pull\x20funds\x20before\x20delivery'],'depends_on_capabilities':['allocation.distribute'],'version':'v1','risk_profile':{'funds_risk':'high','trust_risk':'medium','delivery_risk':'medium','compliance_risk':'low','known_risks':['Mis-gated\x20withdrawal\x20releases\x20escrowed\x20funds\x20prematurely']},'benefit_profile':{'automation_level':'high','trust_boost':'high','efficiency_gain':'high','benefits':['Contract-enforced\x20delivery\x20gate\x20replaces\x20platform\x20custody']}}),this['registerCard']({'capability_id':'guard.validate_refund','display_name':'Guard\x20Validate\x20Refund','description':'Refund\x20validation:\x20gate\x20buyer\x20refund\x20on\x20cancellation\x20or\x20return\x20conditions','object_type':'guard','module':'handler','category':'validation','industry_agnostic':'medium','config_template':{'host':'service','templates':['tpl_refund_on_cancelled']},'industry_overrides':{'retail_d2c':{'templates':['tpl_refund_on_cancelled']}},'observed_in_industries':{},'success_count':0x0,'failure_count':0x0,'known_failure_modes':['Missing\x20refund\x20path\x20on\x20pre-delivery\x20cancellation\x20traps\x20buyer\x20funds'],'depends_on_capabilities':['guard.validate_buy'],'version':'v1','risk_profile':{'funds_risk':'medium','trust_risk':'medium','delivery_risk':'medium','compliance_risk':'low','known_risks':['Over-broad\x20refund\x20conditions\x20enable\x20buyer\x20abuse']},'benefit_profile':{'automation_level':'high','trust_boost':'high','efficiency_gain':'high','benefits':['Trustless\x20buyer\x20refund\x20without\x20merchant\x20approval']}});}['registerBuiltinEdges'](){const a=['machine.node_topology','guard.validate_buy','permission.index_create','allocation.distribute','treasury.owner_receive'];for(const b of a){this['registerEdge']({'from':'service.publish','to':b,'edge_kind':'requires','phase':'publish','description':'Service\x20publish\x20requires\x20this\x20capability'});}this['registerEdge']({'from':'service.publish','to':'arb.vote_weighted','edge_kind':'optional','phase':'publish','description':'Optional:\x20arbitration\x20for\x20dispute\x20resolution'}),this['registerEdge']({'from':'service.publish','to':'reward.claim_guard','edge_kind':'optional','phase':'publish','description':'Optional:\x20reward\x20for\x20positive\x20behavior'}),this['registerEdge']({'from':'service.publish','to':'contact.im_create','edge_kind':'optional','phase':'publish','description':'Optional:\x20IM\x20contact\x20between\x20buyer\x20and\x20seller'}),this['registerEdge']({'from':'permission.role_assign','to':'permission.index_create','edge_kind':'requires','phase':'create','description':'Role\x20assignment\x20requires\x20permission\x20index'}),this['registerEdge']({'from':'machine.node_topology','to':'permission.index_create','edge_kind':'requires','phase':'create','description':'Machine\x20requires\x20permission\x20for\x20role-based\x20node\x20access'}),this['registerEdge']({'from':'allocation.distribute','to':'treasury.owner_receive','edge_kind':'requires','phase':'runtime','description':'Allocation\x20distributes\x20via\x20treasury'}),this['registerEdge']({'from':'allocation.distribute','to':'guard.validate_buy','edge_kind':'requires','phase':'runtime','description':'Allocation\x20requires\x20guard\x20validation'}),this['registerEdge']({'from':'allocation.distribute_milestone','to':'allocation.distribute','edge_kind':'requires','phase':'create','description':'Milestone\x20allocation\x20extends\x20base\x20allocation'}),this['registerEdge']({'from':'allocation.distribute_milestone','to':'guard.validate_wip_hash','edge_kind':'requires','phase':'runtime','description':'Milestone\x20allocation\x20requires\x20WIP\x20hash\x20validation'}),this['registerEdge']({'from':'progress.advance','to':'machine.node_topology','edge_kind':'requires','phase':'runtime','description':'Progress\x20advances\x20based\x20on\x20machine\x20topology'}),this['registerEdge']({'from':'arb.vote_weighted','to':'guard.validate_buy','edge_kind':'requires','phase':'runtime','description':'Arbitration\x20voting\x20requires\x20guard\x20for\x20weight\x20validation'}),this['registerEdge']({'from':'reward.claim_guard','to':'guard.validate_buy','edge_kind':'requires','phase':'runtime','description':'Reward\x20claim\x20requires\x20guard\x20validation'}),this['registerEdge']({'from':'proof.evidence_anchor','to':'progress.advance','edge_kind':'requires','phase':'runtime','description':'Proof\x20anchors\x20to\x20progress\x20node'}),this['registerEdge']({'from':'payment.settle','to':'allocation.distribute','edge_kind':'requires','phase':'runtime','description':'Payment\x20settles\x20via\x20allocation'}),this['registerEdge']({'from':'demand.matching','to':'service.publish','edge_kind':'requires','phase':'runtime','description':'Demand\x20matching\x20requires\x20published\x20services'}),this['registerEdge']({'from':'repository.write_validate','to':'guard.validate_buy','edge_kind':'requires','phase':'runtime','description':'Repository\x20write\x20requires\x20guard\x20validation'});}['computeConfigDiff'](a,b){if(typeof a!=='object'||typeof b!=='object'||a===null||b===null)return a===b?{'diff_ratio':0x0,'summary':'identical'}:{'diff_ratio':0x1,'summary':'type\x20mismatch'};const c=a,d=b,e=new Set(Object['keys'](c)),f=new Set(Object['keys'](d)),g=new Set([...e,...f]);if(g['size']===0x0)return{'diff_ratio':0x0,'summary':'empty\x20configs'};let h=0x0;const i=[];for(const m of g){const n=c[m],o=d[m];JSON['stringify'](n)!==JSON['stringify'](o)&&(h++,i['push'](m));}const j=h/g['size'],l=h+'/'+g['size']+'\x20fields\x20differ:\x20'+i['slice'](0x0,0x3)['join'](',\x20')+(i['length']>0x3?'...':'');return{'diff_ratio':j,'summary':l};}}export function getCapabilityRegistry(){return CapabilityRegistry['Instance']();}export const CAPABILITY_MANIFEST_VERSION=0x1;export function recordCapabilitiesUsed(a,b){const c=CapabilityRegistry['Instance']();for(const d of b){c['recordUsage'](d,a);}}
|
|
1
|
+
export class CapabilityRegistry{static ['instance'];['cards']=new Map();static['Instance'](){return!CapabilityRegistry['instance']&&(CapabilityRegistry['instance']=new CapabilityRegistry()),CapabilityRegistry['instance'];}constructor(){this['registerBuiltins']();}['registerCard'](a){if(!a['capability_id']||!a['object_type']||!a['module'])return![];return this['cards']['set'](a['capability_id'],a),!![];}['getCard'](a){return this['cards']['get'](a);}['registerBuiltins'](){this['registerCard']({'capability_id':'permission.index_create','display_name':'Permission\x20Index\x20Create','description':'Create\x20role\x20permission\x20index,\x20supports\x20multi-role\x20permission\x20assignment\x20such\x20as\x20merchant/customer/arbiter','object_type':'permission','module':'handler','category':'trust','industry_agnostic':'high','risk_profile':{'funds_risk':'low','trust_risk':'low','delivery_risk':'low','compliance_risk':'low','known_risks':['Index\x20proliferation\x20without\x20naming\x20convention\x20makes\x20permission\x20audits\x20harder']},'benefit_profile':{'automation_level':'medium','trust_boost':'high','efficiency_gain':'medium','benefits':['Role-based\x20governance\x20foundation\x20for\x20all\x20other\x20objects']}}),this['registerCard']({'capability_id':'permission.role_assign','display_name':'Permission\x20Role\x20Assign','description':'Assign\x20role\x20permission\x20index\x20to\x20objects\x20(Machine/Service/Allocation)','object_type':'permission','module':'handler','category':'trust','industry_agnostic':'high','risk_profile':{'funds_risk':'low','trust_risk':'medium','delivery_risk':'low','compliance_risk':'low','known_risks':['Mis-assigned\x20role\x20grants\x20unintended\x20operational\x20authority']},'benefit_profile':{'automation_level':'high','trust_boost':'high','efficiency_gain':'medium','benefits':['Binds\x20governance\x20roles\x20to\x20concrete\x20objects']}}),this['registerCard']({'capability_id':'guard.validate_buy','display_name':'Guard\x20Validate\x20Buy','description':'Order\x20validation:\x20check\x20buyer\x20eligibility,\x20order\x20parameters,\x20inventory\x20and\x20other\x20conditions','object_type':'guard','module':'handler','category':'validation','industry_agnostic':'medium','risk_profile':{'funds_risk':'low','trust_risk':'medium','delivery_risk':'medium','compliance_risk':'low','known_risks':['Over-strict\x20buy\x20validation\x20blocks\x20legitimate\x20orders;\x20over-loose\x20validation\x20admits\x20fraud']},'benefit_profile':{'automation_level':'high','trust_boost':'high','efficiency_gain':'high','benefits':['Automated\x20purchase\x20gating\x20without\x20manual\x20review']}}),this['registerCard']({'capability_id':'guard.validate_wip_hash','display_name':'Guard\x20Validate\x20WIP\x20Hash','description':'Validate\x20WIP\x20(Work-In-Progress)\x20hash,\x20used\x20for\x20milestone\x20validation\x20of\x20digital\x20deliverables','object_type':'guard','module':'handler','category':'evidence','industry_agnostic':'low','risk_profile':{'funds_risk':'low','trust_risk':'medium','delivery_risk':'high','compliance_risk':'low','known_risks':['Wrong\x20hash\x20algorithm\x20or\x20field\x20mapping\x20stalls\x20milestone\x20release']},'benefit_profile':{'automation_level':'high','trust_boost':'medium','efficiency_gain':'medium','benefits':['Tamper-proof\x20delivery\x20evidence\x20for\x20digital\x20deliverables']}}),this['registerCard']({'capability_id':'machine.node_topology','display_name':'Machine\x20Node\x20Topology','description':'Workflow\x20node\x20topology:\x20define\x20the\x20state\x20machine\x20from\x20order\x20creation\x20to\x20completion','object_type':'machine','module':'templates','category':'workflow','industry_agnostic':'low','risk_profile':{'funds_risk':'low','trust_risk':'medium','delivery_risk':'high','compliance_risk':'low','known_risks':['Dead-end\x20nodes\x20or\x20missing\x20refund\x20paths\x20trap\x20order\x20funds']},'benefit_profile':{'automation_level':'medium','trust_boost':'medium','efficiency_gain':'high','benefits':['Declarative\x20workflow\x20from\x20order\x20creation\x20to\x20completion']}}),this['registerCard']({'capability_id':'treasury.owner_receive','display_name':'Treasury\x20Owner\x20Receive','description':'Fund\x20escrow:\x20supports\x20owner_receive\x20mode,\x20funds\x20go\x20directly\x20into\x20the\x20object\x20owner\x20wallet','object_type':'treasury','module':'handler','category':'fund_flow','industry_agnostic':'high','risk_profile':{'funds_risk':'high','trust_risk':'medium','delivery_risk':'low','compliance_risk':'low','known_risks':['Direct\x20fund\x20custody\x20—\x20misconfigured\x20owner\x20diverts\x20all\x20proceeds']},'benefit_profile':{'automation_level':'high','trust_boost':'medium','efficiency_gain':'medium','benefits':['Automated\x20escrow\x20and\x20owner\x20settlement']}}),this['registerCard']({'capability_id':'allocation.distribute','display_name':'Multi-tier\x20Allocation\x20Distribution','description':'Multi-tier\x20allocation:\x20supports\x20distributing\x20funds\x20to\x20multiple\x20recipients\x20by\x20ratio\x20/\x20by\x20order\x20/\x20by\x20condition','object_type':'allocation','module':'handler','category':'fund_flow','industry_agnostic':'medium','risk_profile':{'funds_risk':'high','trust_risk':'low','delivery_risk':'medium','compliance_risk':'low','known_risks':['Wrong\x20split\x20ratios\x20or\x20recipient\x20addresses\x20misdirect\x20settlement\x20funds']},'benefit_profile':{'automation_level':'high','trust_boost':'medium','efficiency_gain':'high','benefits':['Multi-recipient\x20settlement\x20without\x20manual\x20transfers']}}),this['registerCard']({'capability_id':'allocation.distribute_milestone','display_name':'Milestone-based\x20Allocation','description':'Milestone\x20allocation:\x20release\x20funds\x20by\x20delivery\x20milestones,\x20each\x20milestone\x20requires\x20WIP\x20hash\x20validation','object_type':'allocation','module':'handler','category':'fund_flow','industry_agnostic':'low','risk_profile':{'funds_risk':'high','trust_risk':'medium','delivery_risk':'medium','compliance_risk':'low','known_risks':['Stuck\x20milestone\x20gates\x20lock\x20buyer\x20funds\x20until\x20evidence\x20is\x20supplied']},'benefit_profile':{'automation_level':'medium','trust_boost':'high','efficiency_gain':'medium','benefits':['Evidence-gated\x20release\x20protects\x20both\x20buyer\x20and\x20provider']}}),this['registerCard']({'capability_id':'service.publish','display_name':'Service\x20Publish','description':'Publish\x20Service\x20object\x20on-chain,\x20bind\x20Machine/Guard/Permission/Allocation\x20and\x20other\x20dependencies','object_type':'service','module':'handler','category':'lifecycle','industry_agnostic':'high','risk_profile':{'funds_risk':'medium','trust_risk':'medium','delivery_risk':'medium','compliance_risk':'medium','known_risks':['Publish\x20freezes\x20machine\x20binding\x20and\x20order_allocators\x20permanently\x20(E_ALREADY_PUBLISHED)']},'benefit_profile':{'automation_level':'medium','trust_boost':'medium','efficiency_gain':'medium','benefits':['On-chain\x20discoverability\x20and\x20order\x20intake']}}),this['registerCard']({'capability_id':'progress.advance','display_name':'Progress\x20Advance','description':'Order\x20fulfillment\x20progress\x20advance:\x20advance\x20to\x20next\x20state\x20based\x20on\x20Machine\x20node\x20topology','object_type':'progress','module':'handler','category':'workflow','industry_agnostic':'medium','risk_profile':{'funds_risk':'medium','trust_risk':'low','delivery_risk':'high','compliance_risk':'low','known_risks':['Forward\x20without\x20authorized\x20executor\x20permanently\x20stalls\x20the\x20order']},'benefit_profile':{'automation_level':'high','trust_boost':'medium','efficiency_gain':'high','benefits':['Deterministic\x20order\x20state\x20progression']}}),this['registerCard']({'capability_id':'arb.vote_weighted','display_name':'Arbitration\x20Vote\x20Weighted','description':'guard-based\x20weighted\x20voting\x20arbitration:\x20vote\x20by\x20Guard\x20weight\x20to\x20determine\x20arbitration\x20result','object_type':'arb','module':'handler','category':'trust','industry_agnostic':'medium','risk_profile':{'funds_risk':'low','trust_risk':'high','delivery_risk':'medium','compliance_risk':'medium','known_risks':['Shared\x20permission\x20with\x20Service\x20destroys\x20dispute\x20independence\x20(E_ARBITRATION_PERMISSION_CONFLICT)']},'benefit_profile':{'automation_level':'medium','trust_boost':'high','efficiency_gain':'low','benefits':['Neutral\x20third-party\x20dispute\x20resolution']}}),this['registerCard']({'capability_id':'reward.claim_guard','display_name':'Reward\x20Claim\x20Guard','description':'Reward\x20claim:\x20release\x20reward\x20after\x20validating\x20claim\x20conditions\x20(such\x20as\x20positive\x20review,\x20repurchase)\x20via\x20Guard','object_type':'reward','module':'handler','category':'fund_flow','industry_agnostic':'medium','risk_profile':{'funds_risk':'medium','trust_risk':'low','delivery_risk':'low','compliance_risk':'low','known_risks':['Loose\x20claim\x20conditions\x20drain\x20the\x20reward\x20pool']},'benefit_profile':{'automation_level':'high','trust_boost':'medium','efficiency_gain':'medium','benefits':['Incentivizes\x20reviews\x20and\x20repurchase']}}),this['registerCard']({'capability_id':'contact.im_create','display_name':'Contact\x20IM\x20Create','description':'Create\x20IM\x20contact\x20object:\x20buyer\x20and\x20seller\x20communicate\x20via\x20Messenger','object_type':'contact','module':'handler','category':'communication','industry_agnostic':'high','risk_profile':{'funds_risk':'low','trust_risk':'low','delivery_risk':'low','compliance_risk':'low','known_risks':['Unattended\x20IM\x20channel\x20degrades\x20dispute\x20response\x20time']},'benefit_profile':{'automation_level':'medium','trust_boost':'medium','efficiency_gain':'medium','benefits':['Direct\x20buyer-seller\x20encrypted\x20communication']}}),this['registerCard']({'capability_id':'demand.matching','display_name':'Demand\x20Matching','description':'Demand\x20matching:\x20match\x20corresponding\x20Service\x20based\x20on\x20user\x20demand','object_type':'demand','module':'handler','category':'query','industry_agnostic':'high','risk_profile':{'funds_risk':'low','trust_risk':'low','delivery_risk':'low','compliance_risk':'low','known_risks':['Poor\x20matching\x20signals\x20bury\x20quality\x20services']},'benefit_profile':{'automation_level':'medium','trust_boost':'low','efficiency_gain':'medium','benefits':['Demand-side\x20discovery\x20channel']}}),this['registerCard']({'capability_id':'repository.write_validate','display_name':'Repository\x20Write\x20Validate','description':'Knowledge\x20base\x20write\x20validation:\x20validate\x20write\x20permissions\x20and\x20data\x20format\x20via\x20Guard','object_type':'repository','module':'handler','category':'validation','industry_agnostic':'high','risk_profile':{'funds_risk':'low','trust_risk':'medium','delivery_risk':'low','compliance_risk':'medium','known_risks':['Unvalidated\x20writes\x20pollute\x20the\x20knowledge\x20base\x20with\x20unverifiable\x20claims']},'benefit_profile':{'automation_level':'medium','trust_boost':'high','efficiency_gain':'medium','benefits':['Guard-gated\x20attestation\x20for\x20off-chain\x20data']}}),this['registerCard']({'capability_id':'proof.evidence_anchor','display_name':'Proof\x20Evidence\x20Anchor','description':'Evidence\x20on-chain:\x20anchor\x20delivery\x20evidence\x20(hash)\x20to\x20on-chain\x20Progress\x20node','object_type':'proof','module':'handler','category':'evidence','industry_agnostic':'medium','risk_profile':{'funds_risk':'low','trust_risk':'medium','delivery_risk':'low','compliance_risk':'low','known_risks':['Anchored\x20evidence\x20is\x20immutable\x20—\x20wrong\x20hash\x20cannot\x20be\x20corrected']},'benefit_profile':{'automation_level':'high','trust_boost':'high','efficiency_gain':'medium','benefits':['Immutable\x20WTS\x20evidence\x20for\x20Messenger\x20confirmations']}}),this['registerCard']({'capability_id':'personal.profile_manage','display_name':'Personal\x20Profile\x20Manage','description':'Personal\x20profile\x20management:\x20user\x20identity/preference/history\x20management','object_type':'personal','module':'handler','category':'data_model','industry_agnostic':'high','risk_profile':{'funds_risk':'low','trust_risk':'low','delivery_risk':'low','compliance_risk':'medium','known_risks':['Profile\x20data\x20may\x20fall\x20under\x20privacy\x20regulation\x20(PII)']},'benefit_profile':{'automation_level':'medium','trust_boost':'low','efficiency_gain':'low','benefits':['Portable\x20user\x20identity\x20across\x20services']}}),this['registerCard']({'capability_id':'payment.settle','display_name':'Payment\x20Settle','description':'Payment\x20settlement:\x20complete\x20fund\x20settlement\x20in\x20collaboration\x20with\x20Allocation','object_type':'payment','module':'handler','category':'fund_flow','industry_agnostic':'high','risk_profile':{'funds_risk':'high','trust_risk':'low','delivery_risk':'low','compliance_risk':'medium','known_risks':['Settlement\x20errors\x20are\x20irreversible\x20once\x20funds\x20transfer']},'benefit_profile':{'automation_level':'high','trust_boost':'low','efficiency_gain':'high','benefits':['Atomic\x20settlement\x20in\x20collaboration\x20with\x20Allocation']}}),this['registerCard']({'capability_id':'guard.validate_withdraw','display_name':'Guard\x20Validate\x20Withdraw','description':'Withdrawal\x20validation:\x20gate\x20fund\x20release\x20from\x20Allocation\x20escrow\x20on\x20delivery\x20confirmation','object_type':'guard','module':'handler','category':'validation','industry_agnostic':'medium','risk_profile':{'funds_risk':'high','trust_risk':'medium','delivery_risk':'medium','compliance_risk':'low','known_risks':['Mis-gated\x20withdrawal\x20releases\x20escrowed\x20funds\x20prematurely']},'benefit_profile':{'automation_level':'high','trust_boost':'high','efficiency_gain':'high','benefits':['Contract-enforced\x20delivery\x20gate\x20replaces\x20platform\x20custody']}}),this['registerCard']({'capability_id':'guard.validate_refund','display_name':'Guard\x20Validate\x20Refund','description':'Refund\x20validation:\x20gate\x20buyer\x20refund\x20on\x20cancellation\x20or\x20return\x20conditions','object_type':'guard','module':'handler','category':'validation','industry_agnostic':'medium','risk_profile':{'funds_risk':'medium','trust_risk':'medium','delivery_risk':'medium','compliance_risk':'low','known_risks':['Over-broad\x20refund\x20conditions\x20enable\x20buyer\x20abuse']},'benefit_profile':{'automation_level':'high','trust_boost':'high','efficiency_gain':'high','benefits':['Trustless\x20buyer\x20refund\x20without\x20merchant\x20approval']}});}}export function getCapabilityRegistry(){return CapabilityRegistry['Instance']();}export const CAPABILITY_MANIFEST_VERSION=0x2;
|
|
@@ -3,18 +3,20 @@ import type { CapabilityRegistry } from "./capability-manifest.js";
|
|
|
3
3
|
export declare class ConstraintRegistry {
|
|
4
4
|
private static instance;
|
|
5
5
|
private constraints;
|
|
6
|
-
private
|
|
6
|
+
private persistence;
|
|
7
|
+
private customConstraintsLoaded;
|
|
7
8
|
static Instance(): ConstraintRegistry;
|
|
8
9
|
private constructor();
|
|
10
|
+
ensureLoaded(): Promise<void>;
|
|
9
11
|
registerConstraint(constraint: ModeConstraint): boolean;
|
|
10
|
-
registerCustomConstraint(constraint_id: string, display_name: string, description: string, rule: ConstraintRule, owner: string, severity?: ConstraintSeverity, on_violation?: ConstraintViolationAction): boolean
|
|
12
|
+
registerCustomConstraint(constraint_id: string, display_name: string, description: string, rule: ConstraintRule, owner: string, severity?: ConstraintSeverity, on_violation?: ConstraintViolationAction): Promise<boolean>;
|
|
11
13
|
getConstraint(constraint_id: string): ModeConstraint | undefined;
|
|
12
14
|
listConstraints(filter?: {
|
|
13
15
|
scope?: "builtin" | "custom";
|
|
14
16
|
owner?: string;
|
|
15
17
|
severity?: ConstraintSeverity;
|
|
16
|
-
}): ModeConstraint[]
|
|
17
|
-
unregisterConstraint(constraint_id: string, owner: string): boolean
|
|
18
|
+
}): Promise<ModeConstraint[]>;
|
|
19
|
+
unregisterConstraint(constraint_id: string, owner: string): Promise<boolean>;
|
|
18
20
|
checkConstraints(mode: IndustryMode, _capabilityRegistry: CapabilityRegistry, extraConstraints?: ModeConstraint[]): ConstraintViolation[];
|
|
19
21
|
private checkConstraint;
|
|
20
22
|
private getNumericField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const BUILTIN_CONSTRAINTS=[{'constraint_id':'require_arbitration','display_name':'Require\x20Arbitration','description':'Mode\x20must\x20include\x20arbitration\x20capability\x20(arb.*)\x20for\x20dispute\x20resolution','rule':{'type':'capability_required','capability_id':'arb.vote_weighted'},'severity':'hard','on_violation':'block','scope':'builtin'},{'constraint_id':'require_compensation_fund','display_name':'Require\x20Compensation\x20Fund','description':'Mode\x20must\x20include\x20fund\x20escrow\x20capability\x20(treasury.*)\x20for\x20compensation\x20fund','rule':{'type':'capability_required','capability_id':'treasury.owner_receive'},'severity':'hard','on_violation':'block','scope':'builtin'},{'constraint_id':'require_wip_evidence','display_name':'Require\x20WIP\x20Evidence','description':'Mode\x20must\x20include\x20WIP\x20evidence\x20capability\x20(guard.validate_wip_hash)\x20for\x20digital\x20delivery\x20validation','rule':{'type':'capability_required','capability_id':'guard.validate_wip_hash'},'severity':'soft','on_violation':'warn','scope':'builtin'},{'constraint_id':'max_single_transaction_limit','display_name':'Single\x20Transaction\x20Limit','description':'Single\x20transaction\x20amount\x20must\x20not\x20exceed\x2010000\x20WOW\x20(default\x20value,\x20can\x20be\x20overridden\x20by\x20mode)','rule':{'type':'numeric_limit','field':'max_single_transaction','max':0x2710},'severity':'soft','on_violation':'warn','scope':'builtin'}];export class ConstraintRegistry{static ['instance'];['constraints']=new Map();['
|
|
1
|
+
import{OwnedRecordStorage}from'@wowok/wowok';const BUILTIN_CONSTRAINTS=[{'constraint_id':'require_arbitration','display_name':'Require\x20Arbitration','description':'Mode\x20must\x20include\x20arbitration\x20capability\x20(arb.*)\x20for\x20dispute\x20resolution','rule':{'type':'capability_required','capability_id':'arb.vote_weighted'},'severity':'hard','on_violation':'block','scope':'builtin'},{'constraint_id':'require_compensation_fund','display_name':'Require\x20Compensation\x20Fund','description':'Mode\x20must\x20include\x20fund\x20escrow\x20capability\x20(treasury.*)\x20for\x20compensation\x20fund','rule':{'type':'capability_required','capability_id':'treasury.owner_receive'},'severity':'hard','on_violation':'block','scope':'builtin'},{'constraint_id':'require_wip_evidence','display_name':'Require\x20WIP\x20Evidence','description':'Mode\x20must\x20include\x20WIP\x20evidence\x20capability\x20(guard.validate_wip_hash)\x20for\x20digital\x20delivery\x20validation','rule':{'type':'capability_required','capability_id':'guard.validate_wip_hash'},'severity':'soft','on_violation':'warn','scope':'builtin'},{'constraint_id':'max_single_transaction_limit','display_name':'Single\x20Transaction\x20Limit','description':'Single\x20transaction\x20amount\x20must\x20not\x20exceed\x2010000\x20WOW\x20(default\x20value,\x20can\x20be\x20overridden\x20by\x20mode)','rule':{'type':'numeric_limit','field':'max_single_transaction','max':0x2710},'severity':'soft','on_violation':'warn','scope':'builtin'}];export class ConstraintRegistry{static ['instance'];['constraints']=new Map();['persistence']=new OwnedRecordStorage('custom_constraints');['customConstraintsLoaded']=![];static['Instance'](){return!ConstraintRegistry['instance']&&(ConstraintRegistry['instance']=new ConstraintRegistry()),ConstraintRegistry['instance'];}constructor(){this['registerBuiltinConstraints']();}async['ensureLoaded'](){if(this['customConstraintsLoaded'])return;this['customConstraintsLoaded']=!![];try{const a=await this['persistence']['list']();for(const b of a){try{const c=JSON['parse'](b['data']);c?.['constraint_id']&&c['scope']==='custom'&&this['constraints']['set'](c['constraint_id'],c);}catch{console['warn']('[ConstraintRegistry]\x20Skipping\x20corrupt\x20custom_constraints\x20row\x20\x27'+b['owner']+':'+b['name']+'\x27.');}}}catch(d){console['warn']('[ConstraintRegistry]\x20Failed\x20to\x20load\x20persisted\x20custom\x20constraints:',d['message']);}}['registerConstraint'](a){if(!a['constraint_id']||!a['rule'])return![];if(this['constraints']['has'](a['constraint_id']))return![];return this['constraints']['set'](a['constraint_id'],a),!![];}async['registerCustomConstraint'](a,b,c,d,e,f='soft',g='warn'){await this['ensureLoaded']();const h={'constraint_id':a,'display_name':b,'description':c,'rule':d,'severity':f,'on_violation':g,'scope':'custom','owner':e},i=this['registerConstraint'](h);if(i)try{await this['persistence']['save'](e,a,JSON['stringify'](h));}catch(j){console['warn']('[ConstraintRegistry]\x20Failed\x20to\x20persist\x20custom\x20constraint\x20\x27'+a+'\x27:',j['message']);}return i;}['getConstraint'](a){return this['constraints']['get'](a);}async['listConstraints'](a){await this['ensureLoaded']();let b=Array['from'](this['constraints']['values']());if(!a)return b;if(a['scope'])b=b['filter'](d=>d['scope']===a['scope']);if(a['owner'])b=b['filter'](d=>d['owner']===a['owner']);if(a['severity'])b=b['filter'](d=>d['severity']===a['severity']);return b;}async['unregisterConstraint'](a,b){await this['ensureLoaded']();const c=this['constraints']['get'](a);if(!c||c['scope']!=='custom'||c['owner']!==b)return![];const d=this['constraints']['delete'](a);if(d)try{await this['persistence']['delete'](b,a);}catch(e){console['warn']('[ConstraintRegistry]\x20Failed\x20to\x20delete\x20persisted\x20custom\x20constraint\x20\x27'+a+'\x27:',e['message']);}return d;}['checkConstraints'](a,b,d){const e=new Set(a['disabled_builtin_constraints']??[]),f=[...this['constraints']['values']()]['filter'](h=>!(h['scope']==='builtin'&&e['has'](h['constraint_id'])));if(d)for(const h of d){!f['some'](i=>i['constraint_id']===h['constraint_id'])&&f['push'](h);}const g=[];for(const i of f){const j=this['checkConstraint'](a,i);j&&g['push'](j);}return g;}['checkConstraint'](a,b){const c=b['rule'];switch(c['type']){case'capability_required':{if(!a['capabilities_used']['includes'](c['capability_id']))return{'constraint_id':b['constraint_id'],'display_name':b['display_name'],'violation':'Missing\x20required\x20capability:\x20'+c['capability_id'],'severity':b['severity'],'action':b['on_violation'],'recommendation':'Add\x20\x22'+c['capability_id']+'\x22\x20to\x20capabilities_used'};return null;}case'capability_forbidden':{if(a['capabilities_used']['includes'](c['capability_id']))return{'constraint_id':b['constraint_id'],'display_name':b['display_name'],'violation':'Contains\x20forbidden\x20capability:\x20'+c['capability_id'],'severity':b['severity'],'action':b['on_violation'],'recommendation':'Remove\x20\x22'+c['capability_id']+'\x22\x20from\x20capabilities_used'};return null;}case'numeric_limit':{const d=this['getNumericField'](a,c['field']);if(d===undefined)return null;if(c['max']!==undefined&&d>c['max'])return{'constraint_id':b['constraint_id'],'display_name':b['display_name'],'violation':c['field']+'='+d+'\x20exceeds\x20upper\x20limit\x20'+c['max'],'severity':b['severity'],'action':b['on_violation'],'recommendation':'Reduce\x20'+c['field']+'\x20below\x20'+c['max']};if(c['min']!==undefined&&d<c['min'])return{'constraint_id':b['constraint_id'],'display_name':b['display_name'],'violation':c['field']+'='+d+'\x20below\x20lower\x20limit\x20'+c['min'],'severity':b['severity'],'action':b['on_violation'],'recommendation':'Increase\x20'+c['field']+'\x20above\x20'+c['min']};return null;}case'condition_required':{return{'constraint_id':b['constraint_id'],'display_name':b['display_name'],'violation':'Natural\x20language\x20condition\x20pending\x20AI\x20evaluation:\x20\x22'+c['condition']+'\x22','severity':b['severity'],'action':b['on_violation'],'recommendation':'Please\x20have\x20AI\x20evaluate\x20whether\x20this\x20condition\x20is\x20satisfied,\x20and\x20update\x20the\x20mode\x20configuration'};}default:return null;}}['getNumericField'](a,b){if(b==='max_single_transaction')return a['risk_constraints']['max_single_transaction'];return undefined;}['registerBuiltinConstraints'](){for(const a of BUILTIN_CONSTRAINTS){this['registerConstraint'](a);}}}export function getConstraintRegistry(){return ConstraintRegistry['Instance']();}export const BUILTIN_CONSTRAINTS_COUNT=BUILTIN_CONSTRAINTS['length'];
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
export type {
|
|
3
|
-
export type { ExpectedBenefit, RiskAppetite, ModeRiskConstraints, ModeApplicableConditions, ConfigOverrideRule, ModeEvaluation, ModeMigrationEvaluation, } from "./types.js";
|
|
1
|
+
export type { IndustryMode, IndustryModeRegistration, UserDefinedMode, } from "./types.js";
|
|
2
|
+
export type { ExpectedBenefit, RiskAppetite, ModeRiskConstraints, ModeApplicableConditions, ConfigOverrideRule, ModeEvaluation, } from "./types.js";
|
|
4
3
|
export type { BaseMetric, MetricType, MetricScale, MetricValue, CapabilityMetricValue, MetricEvaluation, } from "./types.js";
|
|
5
4
|
export type { ModeConstraint, ConstraintRule, ConstraintSeverity, ConstraintViolationAction, ConstraintViolation, } from "./types.js";
|
|
6
|
-
export { CapabilityRegistry, getCapabilityRegistry,
|
|
7
|
-
export type { CapabilityCard,
|
|
5
|
+
export { CapabilityRegistry, getCapabilityRegistry, CAPABILITY_MANIFEST_VERSION, } from "./capability-manifest.js";
|
|
6
|
+
export type { CapabilityCard, CapabilityModule, CapabilityCategory, IndustryAgnostic, CapabilityRiskProfile, CapabilityBenefitProfile, CapabilityConstraints, } from "./capability-manifest.js";
|
|
8
7
|
export { IndustryModeRegistry, getIndustryModeRegistry, INDUSTRY_MODE_REGISTRY_VERSION, } from "./registry.js";
|
|
9
8
|
export { MetricRegistry, getMetricRegistry, BUILTIN_METRICS_COUNT, } from "./metric-registry.js";
|
|
10
9
|
export { ConstraintRegistry, getConstraintRegistry, BUILTIN_CONSTRAINTS_COUNT, } from "./constraint-registry.js";
|
package/dist/extensions/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{CapabilityRegistry,getCapabilityRegistry,
|
|
1
|
+
export{CapabilityRegistry,getCapabilityRegistry,CAPABILITY_MANIFEST_VERSION}from'./capability-manifest.js';export{IndustryModeRegistry,getIndustryModeRegistry,INDUSTRY_MODE_REGISTRY_VERSION}from'./registry.js';export{MetricRegistry,getMetricRegistry,BUILTIN_METRICS_COUNT}from'./metric-registry.js';export{ConstraintRegistry,getConstraintRegistry,BUILTIN_CONSTRAINTS_COUNT}from'./constraint-registry.js';export{ModeEvaluator}from'./mode-evaluator.js';export{BUILTIN_MODES}from'./modes.js';export{registerIndustryPack,validatePackManifest,listRegisteredPacks,unregisterIndustryPack,scanPacks,rescanPack,resolveIndustryPackDir,scanDefaultIndustryPacks,scaffoldIndustryPack,seedBuiltinIndustryTemplates,diffIndustryPack,resetIndustryPath,readMergedPackIfPresent,buildPristineMergedPack,locatePackAndRemainder,ensureIndustryReadme,industryReadmeContent}from'./industry-pack.js';export{registerDisputeRules,registerComplianceRules,registerSupplyRules,registerIndustryRules,registerIndustryPlaybook,resolveDisputeRules,resolveComplianceRules,resolveSupplyRules,resolveIndustryRules,resolveIndustryPlaybook,listRegisteredDisputeCategories,listRegisteredComplianceCategories,listRegisteredSupplyCategories,listRegisteredIndustryRuleCategories,listRegisteredPlaybookCategories,compileIndustryRule,compileIndustryRules,registerIndustryRulesToEngine,unregisterIndustryRulesFromEngine}from'./industry-layers.js';export{registerIndustryPersonae,getIndustryPersona,listPersonaeIndustries,unregisterIndustryPersonae}from'../persona/pack-personae.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readdirSync,readFileSync,existsSync,mkdirSync,writeFileSync}from'node:fs';import{join}from'node:path';import{getWowokIndustryDir}from'@wowok/wowok';import{getIndustryModeRegistry}from'./registry.js';import{BUILTIN_MODES}from'./modes.js';import{registerCategoryMatchRules}from'../evaluation/category-match-rules.js';import{registerIndustryPersonae,unregisterIndustryPersonae}from'../persona/pack-personae.js';import{PERSONA_ROLES,SUPPORTED_INDUSTRIES}from'../persona/types.js';import{UNIVERSAL_TEMPLATE}from'../knowledge/universal-template.js';import{registerDisputeRules,registerComplianceRules,registerSupplyRules,registerIndustryRules,registerIndustryPlaybook,registerIndustryRulesToEngine}from'./industry-layers.js';const FORBIDDEN_PRICING_MODES=new Set(UNIVERSAL_TEMPLATE['pricing_redlines']),packRegistry=new Map();export function validatePackManifest(a){const b=[];return(!a||a['pack']!=='industry-pack')&&b['push']('manifest.pack\x20must\x20be\x20\x27industry-pack\x27'),(!a['name']||typeof a['name']!=='string')&&b['push']('manifest.name\x20is\x20required'),(!a['version']||typeof a['version']!=='string')&&b['push']('manifest.version\x20is\x20required'),(!Array['isArray'](a['layers'])||a['layers']['length']===0x0)&&b['push']('manifest.layers\x20must\x20be\x20a\x20non-empty\x20array'),{'valid':b['length']===0x0,'errors':b};}function isMeaningfulMatch(a){if(!a)return![];return(a['hard_constraints']?.['length']??0x0)>0x0||Object['keys'](a['soft_weights']??{})['length']>0x0||(a['pricing_rules']?.['length']??0x0)>0x0||(a['highlight_fields']?.['length']??0x0)>0x0;}function isMeaningfulPersona(a){const b=a['long_term']??{},c=a['current']??{};return(c['strategy']?.['length']??0x0)>0x0||(c['requirements']?.['length']??0x0)>0x0||(c['rules']?.['length']??0x0)>0x0||(c['spec']?.['length']??0x0)>0x0||Object['keys'](c['preferences']??{})['length']>0x0||Object['keys'](b['preferences']??{})['length']>0x0||(b['identity']?.['region']?.['length']??0x0)>0x0||(b['identity']?.['languages']?.['length']??0x0)>0x0;}function isMeaningfulDispute(a){return(a?.['sla_tiers']?.['length']??0x0)>0x0||(a?.['fault_rules']?.['length']??0x0)>0x0;}function isMeaningfulCompliance(a){return!!a?.['prepay_mode']||(a?.['qualification']?.['length']??0x0)>0x0||(a?.['disclosure']?.['length']??0x0)>0x0||a?.['refund_window']?.['days']!==undefined&&!a?.['refund_window']?.['not_applicable'];}function isMeaningfulSupply(a){return(a?.['supplier_qualification']?.['length']??0x0)>0x0||!!a?.['first_order_policy']||a?.['redundancy_required']===!![];}function isMeaningfulRules(a){return(a?.['rules']?.['length']??0x0)>0x0;}function isMeaningfulPlaybook(a){if(!a)return![];const b=a['content']??'',c=b['replace'](/# .*Industry Playbook/g,'')['replace'](/> .*/g,'')['replace'](/## (Experience|Strategy|Personalization)/g,'')['replace'](/- \(Add .*\)/g,'')['trim']();return c['length']>0x0;}export function registerIndustryPack(a,b=![]){const c=[],d=[],e=a['manifest'],f=validatePackManifest(e);c['push'](...f['errors']);if(!f['valid'])return{'ok':![],'errors':c,'registered':d};const g=packRegistry['get'](e['name']),h=g!==undefined&&g['version']!==e['version'],i=h||b;if(e['layers']['includes']('mode')){if(!a['mode'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27mode\x27\x20but\x20mode.json\x20is\x20missing');else{const j=getIndustryModeRegistry();i&&j['hasMode'](a['mode']['name'])&&j['unregisterMode'](a['mode']['name']),!j['registerMode'](a['mode'])?c['push']('mode\x20\x27'+a['mode']['name']+'\x27\x20failed\x20to\x20register\x20(already\x20registered?).\x20'+'Unregister\x20first\x20or\x20upgrade\x20with\x20a\x20different\x20version.'):d['push']('mode');}}if(e['layers']['includes']('match')){if(!a['match'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27match\x27\x20but\x20match.json\x20is\x20missing');else{if(!isMeaningfulMatch(a['match'])){}else{const k=a['match']['pricing_rules']['filter'](l=>FORBIDDEN_PRICING_MODES['has'](l));if(k['length']>0x0)c['push']('match.pricing_rules\x20contains\x20forbidden\x20modes:\x20'+k['join'](',\x20')+'\x20'+'(violates\x20upper-layer\x20pricing\x20red\x20lines,\x20K3\x2015\x20§4.2)');else!registerCategoryMatchRules(a['match'],i)?c['push']('match\x20rules\x20for\x20\x27'+a['match']['category']+'\x27\x20already\x20registered'):d['push']('match');}}}if(e['layers']['includes']('personae')){if(!a['personae']||a['personae']['length']===0x0)c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27personae\x27\x20but\x20personae\x20are\x20missing');else{const l=a['personae']['filter'](isMeaningfulPersona);if(l['length']===0x0){}else registerIndustryPersonae(e['name'],l),d['push']('personae');}}if(e['layers']['includes']('dispute')){if(!a['dispute'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27dispute\x27\x20but\x20dispute.json\x20is\x20missing');else{if(!isMeaningfulDispute(a['dispute'])){}else!registerDisputeRules(a['dispute'],i)?c['push']('dispute\x20rules\x20for\x20\x27'+a['dispute']['category']+'\x27\x20already\x20registered'):d['push']('dispute');}}if(e['layers']['includes']('compliance')){if(!a['compliance'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27compliance\x27\x20but\x20compliance.json\x20is\x20missing');else{if(!isMeaningfulCompliance(a['compliance'])){}else!registerComplianceRules(a['compliance'],i)?c['push']('compliance\x20rules\x20for\x20\x27'+a['compliance']['category']+'\x27\x20already\x20registered'):d['push']('compliance');}}if(e['layers']['includes']('supply')){if(!a['supply'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27supply\x27\x20but\x20supply.json\x20is\x20missing');else{if(!isMeaningfulSupply(a['supply'])){}else!registerSupplyRules(a['supply'],i)?c['push']('supply\x20rules\x20for\x20\x27'+a['supply']['category']+'\x27\x20already\x20registered'):d['push']('supply');}}if(e['layers']['includes']('rules')){if(!a['rules'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27rules\x27\x20but\x20rules.json\x20is\x20missing');else{if(!isMeaningfulRules(a['rules'])){}else!registerIndustryRules(a['rules'],i)?c['push']('industry\x20rules\x20for\x20\x27'+a['rules']['category']+'\x27\x20already\x20registered'):(d['push']('rules'),registerIndustryRulesToEngine(a['rules']));}}if(e['layers']['includes']('playbook')){if(!a['playbook'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27playbook\x27\x20but\x20playbook.md\x20is\x20missing');else{if(!isMeaningfulPlaybook(a['playbook'])){}else!registerIndustryPlaybook(a['playbook'],i)?c['push']('playbook\x20for\x20\x27'+a['playbook']['category']+'\x27\x20already\x20registered'):d['push']('playbook');}}return c['length']===0x0&&packRegistry['set'](e['name'],{'version':e['version'],'layers':[...e['layers']],'registered_at':Date['now']()}),{'ok':c['length']===0x0,'errors':c,'registered':d};}let builtinModesAsPacksRegistered=![];function ensureBuiltinModesAsPacks(){if(builtinModesAsPacksRegistered)return;builtinModesAsPacksRegistered=!![];for(const a of BUILTIN_MODES){if(packRegistry['has'](a['name']))continue;packRegistry['set'](a['name'],{'version':a['version'],'layers':['mode','match'],'registered_at':Date['now']()});}}export function listRegisteredPacks(){return ensureBuiltinModesAsPacks(),Array['from'](packRegistry['entries']())['map'](([a,b])=>({'name':a,...b}));}export function unregisterIndustryPack(a){const b=new Set(BUILTIN_MODES['map'](c=>c['name']));if(b['has'](a))return![];if(!packRegistry['has'](a))return![];return packRegistry['delete'](a),unregisterIndustryPersonae(a),!![];}export function diffIndustryPack(a){const b=packRegistry['get'](a)??null,c=resolveIndustryPackDir(),d=join(c,a),e=readMergedPackIfPresent(d);let f=null;try{if(e&&e['manifest'])f={'version':e['manifest']['version'],'layers':e['manifest']['layers']??[]};else{const l=join(d,'manifest.json');if(existsSync(l)){const m=JSON['parse'](readFileSync(l,'utf-8'));f={'version':m['version'],'layers':m['layers']??[]};}}}catch{f=null;}const g=b?.['layers']??[],h=f?.['layers']??[],i=h['filter'](n=>!g['includes'](n)),j=g['filter'](n=>!h['includes'](n)),k=!!b&&!!f&&(b['version']!==f['version']||i['length']>0x0||j['length']>0x0);return{'name':a,'registered':b?{...b,'layers':[...b['layers']]}:null,'disk':f,'upgradable':k,'layer_diff':{'added':i,'removed':j}};}export function scanPacks(a){const b=[];if(!existsSync(a))return b;for(const c of readdirSync(a,{'withFileTypes':!![]})){if(!c['isDirectory']())continue;const d=join(a,c['name']);try{const e=loadPackFromDir(d);if(!e)continue;b['push'](registerIndustryPack(e));}catch(f){b['push']({'ok':![],'errors':['failed\x20to\x20load\x20pack\x20\x27'+c['name']+'\x27:\x20'+f['message']],'registered':[]});}}return b;}function loadPackFromDir(a){const b=readMergedPackIfPresent(a),c=join(a,'manifest.json'),d=existsSync(c);if(!b&&!d)return null;if(b){const p=b['manifest'],q={'layout':'merged','manifest':p};if(b['mode'])q['mode']=b['mode'];if(b['match'])q['match']=b['match'];b['personae']&&Array['isArray'](b['personae'])&&(q['personae']=b['personae']);if(b['dispute'])q['dispute']=b['dispute'];if(b['compliance'])q['compliance']=b['compliance'];if(b['supply'])q['supply']=b['supply'];if(b['rules'])q['rules']=b['rules'];const r=join(a,'playbook.md');return existsSync(r)&&(q['playbook']={'category':p['name'],'content':readFileSync(r,'utf-8')}),q;}const e=JSON['parse'](readFileSync(c,'utf-8')),g={'layout':'legacy','manifest':e},h=join(a,'mode.json'),i=join(a,'match.json');existsSync(h)&&(g['mode']=JSON['parse'](readFileSync(h,'utf-8')));existsSync(i)&&(g['match']=JSON['parse'](readFileSync(i,'utf-8')));const j=join(a,'personae');if(existsSync(j)){const s=[];for(const t of readdirSync(j)){if(!t['endsWith']('.json'))continue;s['push'](JSON['parse'](readFileSync(join(j,t),'utf-8')));}if(s['length']>0x0)g['personae']=s;}const k=join(a,'dispute.json');existsSync(k)&&(g['dispute']=JSON['parse'](readFileSync(k,'utf-8')));const l=join(a,'compliance.json');existsSync(l)&&(g['compliance']=JSON['parse'](readFileSync(l,'utf-8')));const m=join(a,'supply.json');existsSync(m)&&(g['supply']=JSON['parse'](readFileSync(m,'utf-8')));const n=join(a,'rules.json');existsSync(n)&&(g['rules']=JSON['parse'](readFileSync(n,'utf-8')));const o=join(a,'playbook.md');return existsSync(o)&&(g['playbook']={'category':e['name'],'content':readFileSync(o,'utf-8')}),g;}export function rescanPack(a){const b=join(resolveIndustryPackDir(),a);try{const c=loadPackFromDir(b);if(!c)return{'ok':![],'errors':['no\x20pack\x20found\x20for\x20\x27'+a+'\x27'],'registered':[]};return registerIndustryPack(c,!![]);}catch(d){return{'ok':![],'errors':['failed\x20to\x20rescan\x20pack\x20\x27'+a+'\x27:\x20'+d['message']],'registered':[]};}}export function resolveIndustryPackDir(){return process['env']['WOWOK_INDUSTRY_DIR']||getWowokIndustryDir();}export function scanDefaultIndustryPacks(){return seedBuiltinIndustryTemplates(),ensureIndustryReadme(),ensureBuiltinModesAsPacks(),scanPacks(resolveIndustryPackDir());}export function seedBuiltinIndustryTemplates(a=SUPPORTED_INDUSTRIES){const b=[],c=resolveIndustryPackDir();mkdirSync(c,{'recursive':!![]}),ensureIndustryReadme();for(const d of a){const e=join(c,d);if(existsSync(join(e,'manifest.json'))||existsSync(join(e,'pack.json')))continue;const f=scaffoldIndustryPack(d,c);if(f['ok'])b['push'](d);}return b;}export const LAYER_FILE_SECTION={'match.json':'match','dispute.json':'dispute','compliance.json':'compliance','supply.json':'supply','rules.json':'rules','mode.json':'mode'};export const PERSONAE_DIR='personae';function manifestSection(a){return{'pack':'industry-pack','name':a,'display_name':a,'version':'0.1.0','layers':['match','personae','dispute','compliance','supply','rules','playbook']};}function matchSection(a){return{'category':a,'hard_constraints':[],'soft_weights':{},'highlight_fields':[],'calendar_mode':'none','geo_mode':'strict','pricing_rules':[]};}function personaPerRole(a,b){return{'role':a,'industry':b,'long_term':{'identity':{'self_description':b+'\x20'+a},'preferences':{}},'current':{'strategy':[],'requirements':[],'rules':[],'spec':'','preferences':{}}};}function disputeSection(a){return{'category':a,'sla_tiers':[],'fault_rules':[]};}function complianceSection(a){return{'category':a,'prepay_mode':'','qualification':[],'disclosure':[],'refund_window':{'days':0x7,'not_applicable':![]}};}function supplySection(a){return{'category':a,'supplier_qualification':[],'first_order_policy':'','redundancy_required':![]};}function rulesSection(a){return{'category':a,'rules':[]};}export function buildPristineMergedPack(a){const b=PERSONA_ROLES['map'](c=>personaPerRole(c,a));return{'manifest':manifestSection(a),'match':matchSection(a),'personae':b,'dispute':disputeSection(a),'compliance':complianceSection(a),'supply':supplySection(a),'rules':rulesSection(a),'mode':null};}export function industryReadmeContent(){return['#\x20WoWok\x20Industry\x20Packs','','>\x20This\x20folder\x20is\x20the\x20WoWok\x20industry\x20knowledge\x20root.\x20Each\x20sub-folder\x20is\x20one','>\x20industry\x20pack.\x20The\x20AI\x20reads\x20pack\x20data\x20as\x20context\x20on\x20every\x20chat\x20turn.','','##\x20Pack\x20structure\x20(unified\x20layout)','','Every\x20pack\x20is\x20exactly\x20two\x20files:','','-\x20**`<pack>/pack.json`**\x20—\x20machine-checkable\x20**settings\x20only**.\x20No\x20comments,','\x20\x20no\x20documentation.\x20One\x20section\x20per\x20layer\x20(see\x20below).','-\x20**`<pack>/playbook.md`**\x20—\x20human\x20strategy,\x20tone\x20and\x20field-tested\x20experience.','\x20\x20The\x20AI\x20reads\x20it\x20as\x20context\x20and\x20it\x20OVERRIDES\x20built-in\x20industry\x20data\x20for','\x20\x20this\x20account.','','All\x20field\x20explanations\x20live\x20in\x20THIS\x20file,\x20so\x20pack.json\x20stays\x20small\x20and\x20you','can\x20focus\x20on\x20configuration.\x20The\x20editor\x20also\x20validates\x20JSON\x20on\x20save\x20—\x20a\x20file','that\x20fails\x20to\x20parse\x20(or\x20a\x20pack.json\x20missing\x20its\x20manifest)\x20is\x20blocked.','','##\x20How\x20changes\x20take\x20effect','','1.\x20**Save**\x20in\x20the\x20Editor\x20writes\x20bytes\x20to\x20disk.','2.\x20**Scan**\x20(Industry\x20drawer)\x20re-registers\x20each\x20pack\x20into\x20the\x20runtime\x20AI','\x20\x20\x20registry\x20(and\x20SQLite\x20cache).\x20A\x20save\x20of\x20an\x20industry\x20file\x20already\x20runs','\x20\x20\x20Scan\x20automatically.','3.\x20**Next\x20AI\x20chat\x20turn**\x20the\x20L1\x20prompt\x20builder\x20reads\x20the\x20registered\x20layers,','\x20\x20\x20so\x20the\x20AI\x20reasons\x20against\x20your\x20edited\x20rules\x20from\x20that\x20point\x20onward.','','##\x20manifest\x20—\x20pack\x20metadata\x20+\x20layer\x20ENABLE\x20flags','','-\x20`name`:\x20snake_case\x20identifier,\x20must\x20match\x20the\x20folder\x20name.','-\x20`version`:\x20bump\x20after\x20editing\x20content\x20so\x20the\x20registry\x20treats\x20it\x20as\x20an\x20upgrade.','-\x20`display_name`:\x20user-visible\x20label.','-\x20`layers`:\x20which\x20sections\x20are\x20validated\x20and\x20registered\x20on\x20scan.\x20Remove\x20a','\x20\x20layer\x20name\x20to\x20DISABLE\x20it\x20(the\x20section\x20stays\x20in\x20pack.json\x20but\x20is\x20ignored).','','##\x20match\x20—\x20category-match\x20rules','','Decides\x20whether\x20an\x20order/service/account\x20belongs\x20to\x20this\x20industry\x20pack:','-\x20`hard_constraints`:\x20array\x20of\x20REQUIRED\x20predicates;\x20ALL\x20must\x20match\x20before\x20the','\x20\x20pack\x20is\x20considered.\x20Example:','\x20\x20`[{\x20key:\x20\x27order.metadata.service_kind\x27,\x20equals:\x20\x27food_onsite\x27\x20}]`','-\x20`soft_weights`:\x20dict\x20`<heuristic_key:\x20number\x200..1>`;\x20higher\x20=\x20stronger\x20signal.','-\x20`pricing_rules`:\x20pricing\x20modes\x20this\x20industry\x20requires.','-\x20`highlight_fields`:\x20dot-paths\x20surfaced\x20in\x20the\x20UI\x20as\x20important\x20info.','-\x20`geo_mode`:\x20`\x27strict\x27`\x20(region\x20must\x20match)\x20|\x20`\x27none\x27`\x20(ignore\x20region).','-\x20`calendar_mode`:\x20`\x27seasonal\x27`\x20|\x20`\x27weekday\x27`\x20|\x20`\x27none\x27`.','','##\x20personae\x20—\x20per-role\x20AI\x20personas','','One\x20persona\x20per\x20role\x20(`merchant`,\x20`customer`,\x20`supplier`,\x20`collaborator`,','`arbitrator`,\x20`prospect`).\x20The\x20AI\x20uses\x20them\x20to\x20role-play\x20negotiation\x20posture:','-\x20`long_term`:\x20stable\x20properties\x20—\x20`identity.self_description`\x20(free-text\x20bio),','\x20\x20`identity.region/languages`,\x20`preferences`\x20(`<key:\x20string[]>`).','-\x20`current`:\x20per-negotiation\x20posture\x20—\x20`strategy`\x20(moves\x20to\x20make),','\x20\x20`requirements`\x20(non-negotiable\x20demands),\x20`rules`\x20(constraints/axioms),','\x20\x20`spec`\x20(free-form\x20text),\x20`preferences`\x20(per-turn\x20overrides).','','##\x20dispute\x20—\x20SLA\x20tiers\x20+\x20fault\x20assignment','','-\x20`sla_tiers[]`:\x20response/remedy\x20windows\x20per\x20severity\x20level.','\x20\x20Example:\x20`{\x20level:\x20\x27L1\x27,\x20response_hours:\x2024,\x20remedy:\x20\x27reply\x27\x20}`','-\x20`fault_rules[]`:\x20automatic\x20fault\x20attribution\x20—\x20a\x20condition\x20plus\x20the\x20side','\x20\x20that\x20bears\x20fault\x20(`merchant`/`customer`/`supplier`/`operator`/`shared`).','\x20\x20Example:\x20`{\x20when:\x20{\x20evidence_has:\x20[\x27late\x20delivery\x20photo\x27]\x20},\x20assign_to:\x20\x27merchant\x27,\x20weight:\x201.0\x20}`','','##\x20compliance\x20—\x20hard\x20requirements\x20before\x20checkout','','-\x20`prepay_mode`:\x20`\x27\x27`\x20|\x20`\x27full\x27`\x20|\x20`\x27partial\x27`\x20|\x20`\x27deposit\x27`.','-\x20`qualification[]`:\x20licenses/certifications\x20a\x20merchant\x20must\x20hold.','\x20\x20Example:\x20`{\x20label:\x20\x27Food\x20Service\x20License\x27,\x20required:\x20true,\x20region:\x20\x27CN\x27\x20}`','-\x20`disclosure[]`:\x20text\x20the\x20merchant\x20MUST\x20show\x20buyers\x20up-front.','-\x20`refund_window`:\x20`{\x20days:\x20number,\x20not_applicable:\x20boolean,\x20exceptions:\x20[...]\x20}`','','##\x20supply\x20—\x20supply-chain\x20/\x20supplier\x20qualification','','-\x20`supplier_qualification[]`:\x20same\x20shape\x20as\x20compliance\x20qualifications,\x20but','\x20\x20evaluated\x20on\x20the\x20SUPPLIER\x20side\x20(multi-party\x20orders).','-\x20`first_order_policy`:\x20policy\x20string\x20on\x20the\x20first\x20order\x20from\x20a\x20new\x20supplier','\x20\x20(e.g.\x20`\x27sample-only\x27`,\x20`\x27reduced-quantity\x27`).','-\x20`redundancy_required`:\x20true\x20=\x20require\x20≥2\x20eligible\x20suppliers\x20before\x20accepting','\x20\x20an\x20order\x20(mitigates\x20single-sourcing).','','##\x20rules\x20—\x20declarative\x20machine-checked\x20rules','','Each\x20rule\x20is\x20an\x20AST\x20node\x20compiled\x20into\x20the\x20evaluation\x20engine:','`{\x20id:\x20\x27rule_...\x27,\x20when:\x20<bool-condition>,\x20then:\x20\x27reject\x27\x20|\x20\x27warn\x27\x20|\x20\x27flag\x27,\x20message:\x20\x27Text\x27\x20}`','Use\x20`rules`\x20for\x20rules\x20that\x20must\x20be\x20machine-checked;\x20put\x20human\x20strategy\x20in','`playbook.md`.','','##\x20mode\x20—\x20IndustryMode\x20(deep\x20shape)','','Not\x20scaffolded\x20by\x20default.\x20Add\x20it\x20when\x20you\x20need\x20a\x20full\x20driving\x20mode\x20for\x20the','industry,\x20or\x20ask\x20the\x20AI:\x20\x22help\x20me\x20fill\x20mode\x20for\x20<industry>\x22.','','##\x20Reset','','Right-click\x20any\x20file/pack\x20folder\x20in\x20the\x20Industry\x20drawer\x20and\x20choose\x20*Reset*','to\x20restore\x20the\x20pristine\x20template\x20at\x20any\x20time.','']['join']('\x0a');}export function ensureIndustryReadme(){const a=resolveIndustryPackDir();mkdirSync(a,{'recursive':!![]});const b=join(a,'README.md');return writeFileSync(b,industryReadmeContent(),'utf-8'),b;}export function scaffoldIndustryPack(a,b){const c=join(b??resolveIndustryPackDir(),a),d=[],e=[];if(!/^[a-z][a-z0-9_]*$/['test'](a))return{'ok':![],'dir':c,'files':d,'errors':['industry\x20name\x20\x27'+a+'\x27\x20must\x20be\x20lowercase\x20snake_case\x20(a-z,\x200-9,\x20_)']};try{mkdirSync(c,{'recursive':!![]}),ensureIndustryReadme();const f=buildPristineMergedPack(a);return writeFileSync(join(c,'pack.json'),JSON['stringify'](f,null,0x2)+'\x0a'),d['push']('pack.json'),writeFileSync(join(c,'playbook.md'),playbookTemplate(a)),d['push']('playbook.md'),{'ok':!![],'dir':c,'files':d,'errors':e};}catch(g){return{'ok':![],'dir':c,'files':d,'errors':['scaffold\x20failed:\x20'+g['message']]};}}export function readMergedPackIfPresent(a){const b=join(a,'pack.json');if(!existsSync(b))return null;try{const c=readFileSync(b,'utf-8');return JSON['parse'](c);}catch{return null;}}function playbookTemplate(a){return['#\x20'+a+'\x20—\x20Industry\x20Playbook','','>\x20📘\x20This\x20file\x20captures\x20human\x20business\x20intelligence\x20for\x20the\x20`'+a+'`','>\x20industry.\x20Content\x20here\x20is\x20READ\x20BY\x20THE\x20AI\x20AS\x20CONTEXT\x20on\x20every\x20turn,','>\x20and\x20OVERRIDES\x20WoWok\x27s\x20generic\x20built-in\x20industry\x20data/rules\x20for\x20this','>\x20account.\x20The\x20companion\x20`pack.json`\x20file\x20stores\x20machine-checkable','>\x20rules;\x20THIS\x20file\x20stores\x20human\x20strategy,\x20tone,\x20experience,\x20and\x20ethics.','','>\x20💡\x20Hint\x20for\x20the\x20AI:\x20when\x20the\x20user\x20asks\x20a\x20question\x20about\x20\x22how\x20to','>\x20handle\x20'+a+'\x22\x20or\x20\x22what\x20should\x20I\x20do?\x22,\x20check\x20this\x20file\x20first\x20for\x20the','>\x20merchant/customer\x20voice,\x20then\x20fall\x20back\x20to\x20your\x20built-in\x20data.\x20Cite','>\x20section\x20titles\x20in\x20your\x20reply\x20so\x20the\x20user\x20knows\x20where\x20advice\x20comes\x20from.','','##\x20Experience\x20(Field-Tested\x20Rules\x20of\x20Thumb)','','>\x20Write\x20what\x20actually\x20works\x20in\x20this\x20industry\x20—\x20not\x20what\x20textbooks\x20say.','>\x20Short\x20bullet\x20points\x20preferred;\x20the\x20AI\x20reads\x20them\x20as\x20axioms.\x20Include','>\x20specific\x20numbers\x20when\x20you\x20have\x20them.','','-\x20(Example)\x20\x22Catering:\x20if\x20the\x20event\x20starts\x20before\x2010:00,\x20always\x20assume','\x20\x20the\x20customer\x20wants\x20breakfast\x20service\x20too\x20—\x20upsell\x20it\x20proactively.\x22','-\x20(Example)\x20\x22Common\x20pitfall:\x20last-minute\x20menu\x20swaps\x20on\x20Fridays\x20—\x20require','\x20\x20a\x20written\x20change\x20request\x2048\x20h\x20before\x20the\x20event\x20or\x20charge\x20a\x2015%\x20fee.\x22','-\x20(Add\x20more\x20below\x20—\x20delete\x20the\x20examples\x20above\x20when\x20you\x20have\x20real\x20ones.)','','##\x20Strategy\x20(Competitive\x20/\x20Game-Theory)','','>\x20How\x20should\x20each\x20role\x20act\x20in\x20a\x20negotiation\x20/\x20dispute\x20/\x20supplier','>\x20relationship?\x20Think\x20in\x20\x22always\x20/\x20never\x20/\x20depends-on-X\x22\x20rules,\x20and\x20call','>\x20out\x20the\x20trade-offs.','','-\x20Merchant\x20strategy:\x20(Add\x20how\x20a\x20merchant\x20in\x20this\x20industry\x20should\x20act\x20—','\x20\x20price\x20anchoring,\x20which\x20concessions\x20to\x20give\x20early\x20vs\x20late,\x20what\x20to','\x20\x20never\x20concede\x20on,\x20etc.)','-\x20Customer\x20strategy:\x20(Add\x20what\x20a\x20smart\x20customer\x20should\x20push\x20for.)','-\x20Dispute\x20strategy:\x20(When\x20to\x20settle\x20fast\x20vs\x20when\x20to\x20fight\x20for\x20full','\x20\x20evidence\x20+\x20arbitration.\x20Call\x20out\x20the\x20escalation\x20thresholds.)','','##\x20Personalization\x20(Tone,\x20Brand,\x20Ethics,\x20Red\x20Lines)','','-\x20Tone\x20/\x20voice:\x20(Write\x20one\x20sentence\x20describing\x20the\x20exact\x20conversational','\x20\x20voice\x20this\x20account\x20should\x20use\x20—\x20casual,\x20formal,\x20technical,\x20etc.)','-\x20Brand\x20rules:\x20(Logo,\x20link-out\x20style,\x20forbidden\x20terminology,','\x20\x20always-include\x20phrases,\x20etc.)','-\x20Red\x20lines:\x20(Non-negotiable.\x20Example:\x20\x22Never\x20make\x20a\x20refund\x20promise','\x20\x20larger\x20than\x2030%\x20without\x20arbitration\x20evidence.\x22)','-\x20Ethics:\x20(Example:\x20\x22If\x20customer\x20appears\x20intoxicated,\x20refuse\x20service','\x20\x20and\x20refer\x20to\x20supervisor;\x20never\x20take\x20the\x20order\x20for\x20profit.\x22)','','##\x20Playbook\x20Maintenance','','>\x20You\x20don\x27t\x20need\x20to\x20be\x20perfect\x20on\x20day\x20one.\x20After\x20every\x20real\x20deal,\x20add\x20a','>\x20bullet\x20to\x20the\x20above\x20sections\x20with\x20what\x20worked\x20/\x20what\x20failed.\x20Every','>\x20entry\x20improves\x20the\x20AI\x27s\x20future\x20decisions.','','>\x20Right-click\x20the\x20file\x20or\x20this\x20pack\x20folder\x20in\x20the\x20Industry\x20drawer\x20at','>\x20any\x20time\x20and\x20choose\x20\x22Reset\x22\x20to\x20restore\x20this\x20annotated\x20template.','']['join']('\x0a');}export function locatePackAndRemainder(a){const b=a['replace'](/^[\\/]+/,'')['replace'](/[\\/]+$/,'');if(!b)return null;const [c,...d]=b['split'](/[\\/]+/);if(!c)return null;return{'packName':c,'remainder':d['join']('/')};}export function resetIndustryPath(a,b){const c=[],d=[],f=b??resolveIndustryPackDir(),g=locatePackAndRemainder(a),h=a;if(!g)return{'ok':![],'layout':'merged','target':h,'restored_files':[],'errors':['invalid\x20reset\x20path\x20\x27'+a+'\x27']};const {packName:i,remainder:j}=g,k=join(f,i);if(!existsSync(k))return{'ok':![],'layout':'merged','target':h,'restored_files':[],'errors':['pack\x20directory\x20\x27'+i+'\x27\x20does\x20not\x20exist']};if(!/^[a-z][a-z0-9_]*$/['test'](i))return{'ok':![],'layout':'merged','target':h,'restored_files':[],'errors':['pack\x20name\x20\x27'+i+'\x27\x20is\x20not\x20a\x20valid\x20snake_case\x20identifier']};const l=readMergedPackIfPresent(k),n=l?'merged':'legacy';if(j==='')try{mkdirSync(k,{'recursive':!![]});const s=buildPristineMergedPack(i);return writeFileSync(join(k,'pack.json'),JSON['stringify'](s,null,0x2)+'\x0a'),d['push']('pack.json'),writeFileSync(join(k,'playbook.md'),playbookTemplate(i)),d['push']('playbook.md'),{'ok':!![],'layout':'merged','target':h,'restored_files':d,'errors':c};}catch(t){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['pack\x20reset\x20failed:\x20'+t['message']]};}const o=j['split']('/')['slice'](-0x1)[0x0],p=j==='playbook.md',q=j['startsWith'](PERSONAE_DIR+'/')&&o['endsWith']('.json');if(n==='merged'){if(p)try{return writeFileSync(join(k,'playbook.md'),playbookTemplate(i)),d['push']('playbook.md'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(v){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['playbook\x20reset\x20failed:\x20'+v['message']]};}const u=LAYER_FILE_SECTION[j];if(u)try{const w=readMergedPackIfPresent(k)??buildPristineMergedPack(i);switch(u){case'match':w['match']=matchSection(i);break;case'dispute':w['dispute']=disputeSection(i);break;case'compliance':w['compliance']=complianceSection(i);break;case'supply':w['supply']=supplySection(i);break;case'rules':w['rules']=rulesSection(i);break;case'mode':w['mode']=null;break;}return writeFileSync(join(k,'pack.json'),JSON['stringify'](w,null,0x2)+'\x0a'),d['push']('pack.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(x){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['section\x20reset\x20failed:\x20'+x['message']]};}if(q){const y=o['replace'](/\.json$/,'');if(!PERSONA_ROLES['includes'](y))return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['unknown\x20persona\x20role\x20\x27'+y+'\x27']};try{const z=readMergedPackIfPresent(k)??buildPristineMergedPack(i),A=z['personae']&&Array['isArray'](z['personae'])?[...z['personae']]:[],B=A['findIndex'](D=>D['role']===y),C=personaPerRole(y,i);if(B>=0x0)A[B]=C;else A['push'](C);return z['personae']=A,writeFileSync(join(k,'pack.json'),JSON['stringify'](z,null,0x2)+'\x0a'),d['push']('pack.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(D){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['persona\x20reset\x20failed:\x20'+D['message']]};}}if(j==='manifest.json'||j==='manifest')try{const E=readMergedPackIfPresent(k)??buildPristineMergedPack(i);return E['manifest']=manifestSection(i),writeFileSync(join(k,'pack.json'),JSON['stringify'](E,null,0x2)+'\x0a'),d['push']('pack.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(F){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['manifest\x20reset\x20failed:\x20'+F['message']]};}return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['path\x20\x27'+j+'\x27\x20is\x20not\x20a\x20standard\x20section\x20file\x20of\x20pack\x20\x27'+i+'\x27.\x20Reset\x20is\x20only\x20provided\x20for\x20pack.json\x20standard\x20sections\x20and\x20playbook.md.']};}if(p)try{return writeFileSync(join(k,'playbook.md'),playbookTemplate(i)),d['push']('playbook.md'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(G){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20playbook\x20reset\x20failed:\x20'+G['message']]};}if(j==='manifest.json')try{const H=manifestSection(i);return writeFileSync(join(k,'manifest.json'),JSON['stringify'](H,null,0x2)+'\x0a'),d['push']('manifest.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(I){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20manifest\x20reset\x20failed:\x20'+I['message']]};}const r=LAYER_FILE_SECTION[j];if(r)try{let J='';switch(r){case'match':J=JSON['stringify'](matchSection(i),null,0x2)+'\x0a';break;case'dispute':J=JSON['stringify'](disputeSection(i),null,0x2)+'\x0a';break;case'compliance':J=JSON['stringify'](complianceSection(i),null,0x2)+'\x0a';break;case'supply':J=JSON['stringify'](supplySection(i),null,0x2)+'\x0a';break;case'rules':J=JSON['stringify'](rulesSection(i),null,0x2)+'\x0a';break;case'mode':J=JSON['stringify']({},null,0x2)+'\x0a';break;}return writeFileSync(join(k,j),J),d['push'](j),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(K){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20section\x20reset\x20failed:\x20'+K['message']]};}if(q){const L=o['replace'](/\.json$/,'');if(!PERSONA_ROLES['includes'](L))return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['unknown\x20persona\x20\x27'+L+'\x27']};try{return writeFileSync(join(k,j),JSON['stringify'](personaPerRole(L,i),null,0x2)+'\x0a'),d['push'](j),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(M){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20persona\x20reset\x20failed:\x20'+M['message']]};}}return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['cannot\x20reset\x20non-standard\x20file\x20\x27'+j+'\x27\x20in\x20legacy\x20layout.\x20Only\x20standard\x20layer\x20files,\x20personae/*.json,\x20manifest.json,\x20and\x20playbook.md\x20can\x20be\x20reset.']};}
|
|
1
|
+
import{readdirSync,readFileSync,existsSync,mkdirSync,writeFileSync}from'node:fs';import{join}from'node:path';import{getWowokIndustryDir}from'@wowok/wowok';import{getIndustryModeRegistry}from'./registry.js';import{BUILTIN_MODES}from'./modes.js';import{registerCategoryMatchRules}from'../evaluation/category-match-rules.js';import{registerIndustryPersonae,unregisterIndustryPersonae}from'../persona/pack-personae.js';import{PERSONA_ROLES,SUPPORTED_INDUSTRIES}from'../persona/types.js';import{UNIVERSAL_TEMPLATE}from'../knowledge/universal-template.js';import{registerDisputeRules,registerComplianceRules,registerSupplyRules,registerIndustryRules,registerIndustryPlaybook,registerIndustryRulesToEngine}from'./industry-layers.js';const FORBIDDEN_PRICING_MODES=new Set(UNIVERSAL_TEMPLATE['pricing_redlines']),packRegistry=new Map();export function validatePackManifest(a){const b=[];return(!a||a['pack']!=='industry-pack')&&b['push']('manifest.pack\x20must\x20be\x20\x27industry-pack\x27'),(!a['name']||typeof a['name']!=='string')&&b['push']('manifest.name\x20is\x20required'),(!a['version']||typeof a['version']!=='string')&&b['push']('manifest.version\x20is\x20required'),(!Array['isArray'](a['layers'])||a['layers']['length']===0x0)&&b['push']('manifest.layers\x20must\x20be\x20a\x20non-empty\x20array'),{'valid':b['length']===0x0,'errors':b};}function isMeaningfulMatch(a){if(!a)return![];return(a['hard_constraints']?.['length']??0x0)>0x0||Object['keys'](a['soft_weights']??{})['length']>0x0||(a['pricing_rules']?.['length']??0x0)>0x0||(a['highlight_fields']?.['length']??0x0)>0x0;}function isMeaningfulPersona(a){const b=a['long_term']??{},c=a['current']??{};return(c['strategy']?.['length']??0x0)>0x0||(c['requirements']?.['length']??0x0)>0x0||(c['rules']?.['length']??0x0)>0x0||(c['spec']?.['length']??0x0)>0x0||Object['keys'](c['preferences']??{})['length']>0x0||Object['keys'](b['preferences']??{})['length']>0x0||(b['identity']?.['region']?.['length']??0x0)>0x0||(b['identity']?.['languages']?.['length']??0x0)>0x0;}function isMeaningfulDispute(a){return(a?.['sla_tiers']?.['length']??0x0)>0x0||(a?.['fault_rules']?.['length']??0x0)>0x0;}function isMeaningfulCompliance(a){return!!a?.['prepay_mode']||(a?.['qualification']?.['length']??0x0)>0x0||(a?.['disclosure']?.['length']??0x0)>0x0||a?.['refund_window']?.['days']!==undefined&&!a?.['refund_window']?.['not_applicable'];}function isMeaningfulSupply(a){return(a?.['supplier_qualification']?.['length']??0x0)>0x0||!!a?.['first_order_policy']||a?.['redundancy_required']===!![];}function isMeaningfulRules(a){return(a?.['rules']?.['length']??0x0)>0x0;}function isMeaningfulPlaybook(a){if(!a)return![];const b=a['content']??'',c=b['replace'](/# .*Industry Playbook/g,'')['replace'](/> .*/g,'')['replace'](/## (Experience|Strategy|Personalization)/g,'')['replace'](/- \(Add .*\)/g,'')['trim']();return c['length']>0x0;}export function registerIndustryPack(a,b=![]){const c=[],d=[],e=a['manifest'],f=validatePackManifest(e);c['push'](...f['errors']);if(!f['valid'])return{'ok':![],'errors':c,'registered':d};const g=packRegistry['get'](e['name']),h=g!==undefined&&g['version']!==e['version'],i=h||b;if(e['layers']['includes']('mode')){if(!a['mode'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27mode\x27\x20but\x20mode.json\x20is\x20missing');else{const j=getIndustryModeRegistry();i&&j['hasMode'](a['mode']['name'])&&j['unregisterMode'](a['mode']['name']),!j['registerMode'](a['mode'])?c['push']('mode\x20\x27'+a['mode']['name']+'\x27\x20failed\x20to\x20register\x20(already\x20registered?).\x20'+'Unregister\x20first\x20or\x20upgrade\x20with\x20a\x20different\x20version.'):d['push']('mode');}}if(e['layers']['includes']('match')){if(!a['match'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27match\x27\x20but\x20match.json\x20is\x20missing');else{if(!isMeaningfulMatch(a['match'])){}else{const k=a['match']['pricing_rules']['filter'](l=>FORBIDDEN_PRICING_MODES['has'](l));if(k['length']>0x0)c['push']('match.pricing_rules\x20contains\x20forbidden\x20modes:\x20'+k['join'](',\x20')+'\x20'+'(violates\x20upper-layer\x20pricing\x20red\x20lines,\x20K3\x2015\x20§4.2)');else!registerCategoryMatchRules(a['match'],i)?c['push']('match\x20rules\x20for\x20\x27'+a['match']['category']+'\x27\x20already\x20registered'):d['push']('match');}}}if(e['layers']['includes']('personae')){if(!a['personae']||a['personae']['length']===0x0)c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27personae\x27\x20but\x20personae\x20are\x20missing');else{const l=a['personae']['filter'](isMeaningfulPersona);if(l['length']===0x0){}else registerIndustryPersonae(e['name'],l),d['push']('personae');}}if(e['layers']['includes']('dispute')){if(!a['dispute'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27dispute\x27\x20but\x20dispute.json\x20is\x20missing');else{if(!isMeaningfulDispute(a['dispute'])){}else!registerDisputeRules(a['dispute'],i)?c['push']('dispute\x20rules\x20for\x20\x27'+a['dispute']['category']+'\x27\x20already\x20registered'):d['push']('dispute');}}if(e['layers']['includes']('compliance')){if(!a['compliance'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27compliance\x27\x20but\x20compliance.json\x20is\x20missing');else{if(!isMeaningfulCompliance(a['compliance'])){}else!registerComplianceRules(a['compliance'],i)?c['push']('compliance\x20rules\x20for\x20\x27'+a['compliance']['category']+'\x27\x20already\x20registered'):d['push']('compliance');}}if(e['layers']['includes']('supply')){if(!a['supply'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27supply\x27\x20but\x20supply.json\x20is\x20missing');else{if(!isMeaningfulSupply(a['supply'])){}else!registerSupplyRules(a['supply'],i)?c['push']('supply\x20rules\x20for\x20\x27'+a['supply']['category']+'\x27\x20already\x20registered'):d['push']('supply');}}if(e['layers']['includes']('rules')){if(!a['rules'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27rules\x27\x20but\x20rules.json\x20is\x20missing');else{if(!isMeaningfulRules(a['rules'])){}else!registerIndustryRules(a['rules'],i)?c['push']('industry\x20rules\x20for\x20\x27'+a['rules']['category']+'\x27\x20already\x20registered'):(d['push']('rules'),registerIndustryRulesToEngine(a['rules']));}}if(e['layers']['includes']('playbook')){if(!a['playbook'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27playbook\x27\x20but\x20playbook.md\x20is\x20missing');else{if(!isMeaningfulPlaybook(a['playbook'])){}else!registerIndustryPlaybook(a['playbook'],i)?c['push']('playbook\x20for\x20\x27'+a['playbook']['category']+'\x27\x20already\x20registered'):d['push']('playbook');}}return c['length']===0x0&&packRegistry['set'](e['name'],{'version':e['version'],'layers':[...e['layers']],'registered_at':Date['now']()}),{'ok':c['length']===0x0,'errors':c,'registered':d};}let builtinModesAsPacksRegistered=![];function ensureBuiltinModesAsPacks(){if(builtinModesAsPacksRegistered)return;builtinModesAsPacksRegistered=!![];for(const a of BUILTIN_MODES){if(packRegistry['has'](a['name']))continue;packRegistry['set'](a['name'],{'version':a['version'],'layers':['mode','match'],'registered_at':Date['now']()});}}export function listRegisteredPacks(){return ensureBuiltinModesAsPacks(),Array['from'](packRegistry['entries']())['map'](([a,b])=>({'name':a,...b}));}export function unregisterIndustryPack(a){const b=new Set(BUILTIN_MODES['map'](c=>c['name']));if(b['has'](a))return![];if(!packRegistry['has'](a))return![];return packRegistry['delete'](a),unregisterIndustryPersonae(a),!![];}export function diffIndustryPack(a){const b=packRegistry['get'](a)??null,c=resolveIndustryPackDir(),d=join(c,a),e=readMergedPackIfPresent(d);let f=null;try{if(e&&e['manifest'])f={'version':e['manifest']['version'],'layers':e['manifest']['layers']??[]};else{const l=join(d,'manifest.json');if(existsSync(l)){const m=JSON['parse'](readFileSync(l,'utf-8'));f={'version':m['version'],'layers':m['layers']??[]};}}}catch{f=null;}const g=b?.['layers']??[],h=f?.['layers']??[],i=h['filter'](n=>!g['includes'](n)),j=g['filter'](n=>!h['includes'](n)),k=!!b&&!!f&&(b['version']!==f['version']||i['length']>0x0||j['length']>0x0);return{'name':a,'registered':b?{...b,'layers':[...b['layers']]}:null,'disk':f,'upgradable':k,'layer_diff':{'added':i,'removed':j}};}export function scanPacks(a){const b=[];if(!existsSync(a))return b;for(const c of readdirSync(a,{'withFileTypes':!![]})){if(!c['isDirectory']())continue;const d=join(a,c['name']);try{const e=loadPackFromDir(d);if(!e)continue;b['push'](registerIndustryPack(e));}catch(f){b['push']({'ok':![],'errors':['failed\x20to\x20load\x20pack\x20\x27'+c['name']+'\x27:\x20'+f['message']],'registered':[]});}}return b;}function loadPackFromDir(a){const b=readMergedPackIfPresent(a),c=join(a,'manifest.json'),d=existsSync(c);if(!b&&!d)return null;if(b){const p=b['manifest'],q={'layout':'merged','manifest':p};if(b['mode'])q['mode']=b['mode'];if(b['match'])q['match']=b['match'];b['personae']&&Array['isArray'](b['personae'])&&(q['personae']=b['personae']);if(b['dispute'])q['dispute']=b['dispute'];if(b['compliance'])q['compliance']=b['compliance'];if(b['supply'])q['supply']=b['supply'];if(b['rules'])q['rules']=b['rules'];const r=join(a,'playbook.md');return existsSync(r)&&(q['playbook']={'category':p['name'],'content':readFileSync(r,'utf-8')}),q;}const e=JSON['parse'](readFileSync(c,'utf-8')),g={'layout':'legacy','manifest':e},h=join(a,'mode.json'),i=join(a,'match.json');existsSync(h)&&(g['mode']=JSON['parse'](readFileSync(h,'utf-8')));existsSync(i)&&(g['match']=JSON['parse'](readFileSync(i,'utf-8')));const j=join(a,'personae');if(existsSync(j)){const s=[];for(const t of readdirSync(j)){if(!t['endsWith']('.json'))continue;s['push'](JSON['parse'](readFileSync(join(j,t),'utf-8')));}if(s['length']>0x0)g['personae']=s;}const k=join(a,'dispute.json');existsSync(k)&&(g['dispute']=JSON['parse'](readFileSync(k,'utf-8')));const l=join(a,'compliance.json');existsSync(l)&&(g['compliance']=JSON['parse'](readFileSync(l,'utf-8')));const m=join(a,'supply.json');existsSync(m)&&(g['supply']=JSON['parse'](readFileSync(m,'utf-8')));const n=join(a,'rules.json');existsSync(n)&&(g['rules']=JSON['parse'](readFileSync(n,'utf-8')));const o=join(a,'playbook.md');return existsSync(o)&&(g['playbook']={'category':e['name'],'content':readFileSync(o,'utf-8')}),g;}export function rescanPack(a){const b=join(resolveIndustryPackDir(),a);try{const c=loadPackFromDir(b);if(!c)return{'ok':![],'errors':['no\x20pack\x20found\x20for\x20\x27'+a+'\x27'],'registered':[]};return registerIndustryPack(c,!![]);}catch(d){return{'ok':![],'errors':['failed\x20to\x20rescan\x20pack\x20\x27'+a+'\x27:\x20'+d['message']],'registered':[]};}}export function resolveIndustryPackDir(){return process['env']['WOWOK_INDUSTRY_DIR']||getWowokIndustryDir();}export function scanDefaultIndustryPacks(){return seedBuiltinIndustryTemplates(),ensureIndustryReadme(),ensureBuiltinModesAsPacks(),scanPacks(resolveIndustryPackDir());}export function seedBuiltinIndustryTemplates(a=SUPPORTED_INDUSTRIES){const b=[],c=resolveIndustryPackDir();mkdirSync(c,{'recursive':!![]}),ensureIndustryReadme();for(const d of a){const e=join(c,d);if(existsSync(join(e,'manifest.json'))||existsSync(join(e,'pack.json')))continue;const f=scaffoldIndustryPack(d,c);if(f['ok'])b['push'](d);}return b;}export const LAYER_FILE_SECTION={'match.json':'match','dispute.json':'dispute','compliance.json':'compliance','supply.json':'supply','rules.json':'rules','mode.json':'mode'};export const PERSONAE_DIR='personae';function manifestSection(a){return{'pack':'industry-pack','name':a,'display_name':a,'version':'0.1.0','layers':['match','personae','dispute','compliance','supply','rules','playbook']};}function matchSection(a){return{'category':a,'hard_constraints':[],'soft_weights':{},'highlight_fields':[],'calendar_mode':'none','geo_mode':'strict','pricing_rules':[]};}function personaPerRole(a,b){return{'role':a,'industry':b,'long_term':{'identity':{'self_description':b+'\x20'+a},'preferences':{}},'current':{'strategy':[],'requirements':[],'rules':[],'spec':'','preferences':{}}};}function disputeSection(a){return{'category':a,'sla_tiers':[],'fault_rules':[]};}function complianceSection(a){return{'category':a,'prepay_mode':'','qualification':[],'disclosure':[],'refund_window':{'days':0x7,'not_applicable':![]}};}function supplySection(a){return{'category':a,'supplier_qualification':[],'first_order_policy':'','redundancy_required':![]};}function rulesSection(a){return{'category':a,'rules':[]};}export function buildPristineMergedPack(a){const b=PERSONA_ROLES['map'](c=>personaPerRole(c,a));return{'manifest':manifestSection(a),'match':matchSection(a),'personae':b,'dispute':disputeSection(a),'compliance':complianceSection(a),'supply':supplySection(a),'rules':rulesSection(a),'mode':null};}export function industryReadmeContent(){return['#\x20WoWok\x20Industry\x20Packs','','>\x20This\x20folder\x20is\x20the\x20WoWok\x20industry\x20knowledge\x20root.\x20Each\x20sub-folder\x20is\x20one','>\x20industry\x20pack.\x20The\x20AI\x20reads\x20pack\x20data\x20as\x20context\x20on\x20every\x20chat\x20turn.','','##\x20Pack\x20structure\x20(unified\x20layout)','','Every\x20pack\x20is\x20exactly\x20two\x20files:','','-\x20**`<pack>/pack.json`**\x20—\x20machine-checkable\x20**settings\x20only**.\x20No\x20comments,','\x20\x20no\x20documentation.\x20One\x20section\x20per\x20layer\x20(see\x20below).','-\x20**`<pack>/playbook.md`**\x20—\x20human\x20strategy,\x20tone\x20and\x20field-tested\x20experience.','\x20\x20The\x20AI\x20reads\x20it\x20as\x20context\x20and\x20it\x20OVERRIDES\x20built-in\x20industry\x20data\x20for','\x20\x20this\x20account.','','All\x20field\x20explanations\x20live\x20in\x20THIS\x20file,\x20so\x20pack.json\x20stays\x20small\x20and\x20you','can\x20focus\x20on\x20configuration.\x20The\x20editor\x20also\x20validates\x20JSON\x20on\x20save\x20—\x20a\x20file','that\x20fails\x20to\x20parse\x20(or\x20a\x20pack.json\x20missing\x20its\x20manifest)\x20is\x20blocked.','','##\x20How\x20changes\x20take\x20effect','','1.\x20**Save**\x20in\x20the\x20Editor\x20writes\x20bytes\x20to\x20disk.','2.\x20**Scan**\x20(Industry\x20drawer)\x20re-registers\x20each\x20pack\x20into\x20the\x20runtime\x20AI','\x20\x20\x20registry\x20(and\x20SQLite\x20cache).\x20A\x20save\x20of\x20an\x20industry\x20file\x20already\x20runs','\x20\x20\x20Scan\x20automatically.','3.\x20**Next\x20AI\x20chat\x20turn**\x20the\x20L1\x20prompt\x20builder\x20reads\x20the\x20registered\x20layers,','\x20\x20\x20so\x20the\x20AI\x20reasons\x20against\x20your\x20edited\x20rules\x20from\x20that\x20point\x20onward.','','##\x20manifest\x20—\x20pack\x20metadata\x20+\x20layer\x20ENABLE\x20flags','','-\x20`name`:\x20snake_case\x20identifier,\x20must\x20match\x20the\x20folder\x20name.','-\x20`version`:\x20bump\x20after\x20editing\x20content\x20so\x20the\x20registry\x20treats\x20it\x20as\x20an\x20upgrade.','-\x20`display_name`:\x20user-visible\x20label.','-\x20`layers`:\x20which\x20sections\x20are\x20validated\x20and\x20registered\x20on\x20scan.\x20Remove\x20a','\x20\x20layer\x20name\x20to\x20DISABLE\x20it\x20(the\x20section\x20stays\x20in\x20pack.json\x20but\x20is\x20ignored).','','##\x20match\x20—\x20category-match\x20rules','','Decides\x20whether\x20an\x20order/service/account\x20belongs\x20to\x20this\x20industry\x20pack:','-\x20`hard_constraints`:\x20array\x20of\x20REQUIRED\x20predicates;\x20ALL\x20must\x20match\x20before\x20the','\x20\x20pack\x20is\x20considered.\x20Example:','\x20\x20`[{\x20key:\x20\x27order.metadata.service_kind\x27,\x20equals:\x20\x27food_onsite\x27\x20}]`','-\x20`soft_weights`:\x20dict\x20`<heuristic_key:\x20number\x200..1>`;\x20higher\x20=\x20stronger\x20signal.','-\x20`pricing_rules`:\x20pricing\x20modes\x20this\x20industry\x20requires.','-\x20`highlight_fields`:\x20dot-paths\x20surfaced\x20in\x20the\x20UI\x20as\x20important\x20info.','-\x20`geo_mode`:\x20`\x27strict\x27`\x20(region\x20must\x20match)\x20|\x20`\x27none\x27`\x20(ignore\x20region).','-\x20`calendar_mode`:\x20`\x27seasonal\x27`\x20|\x20`\x27weekday\x27`\x20|\x20`\x27none\x27`.','','##\x20personae\x20—\x20per-role\x20AI\x20personas','','One\x20persona\x20per\x20role\x20(`merchant`,\x20`customer`,\x20`supplier`,\x20`collaborator`,','`arbitrator`,\x20`prospect`).\x20The\x20AI\x20uses\x20them\x20to\x20role-play\x20negotiation\x20posture:','-\x20`long_term`:\x20stable\x20properties\x20—\x20`identity.self_description`\x20(free-text\x20bio),','\x20\x20`identity.region/languages`,\x20`preferences`\x20(`<key:\x20string[]>`).','-\x20`current`:\x20per-negotiation\x20posture\x20—\x20`strategy`\x20(moves\x20to\x20make),','\x20\x20`requirements`\x20(non-negotiable\x20demands),\x20`rules`\x20(constraints/axioms),','\x20\x20`spec`\x20(free-form\x20text),\x20`preferences`\x20(per-turn\x20overrides).','','##\x20dispute\x20—\x20SLA\x20tiers\x20+\x20fault\x20assignment','','-\x20`sla_tiers[]`:\x20response/remedy\x20windows\x20per\x20severity\x20level.','\x20\x20Example:\x20`{\x20level:\x20\x27L1\x27,\x20response_hours:\x2024,\x20remedy:\x20\x27reply\x27\x20}`','-\x20`fault_rules[]`:\x20automatic\x20fault\x20attribution\x20—\x20a\x20condition\x20plus\x20the\x20side','\x20\x20that\x20bears\x20fault\x20(`merchant`/`customer`/`supplier`/`operator`/`shared`).','\x20\x20Example:\x20`{\x20when:\x20{\x20evidence_has:\x20[\x27late\x20delivery\x20photo\x27]\x20},\x20assign_to:\x20\x27merchant\x27,\x20weight:\x201.0\x20}`','','##\x20compliance\x20—\x20hard\x20requirements\x20before\x20checkout','','-\x20`prepay_mode`:\x20`\x27\x27`\x20|\x20`\x27full\x27`\x20|\x20`\x27partial\x27`\x20|\x20`\x27deposit\x27`.','-\x20`qualification[]`:\x20licenses/certifications\x20a\x20merchant\x20must\x20hold.','\x20\x20Example:\x20`{\x20label:\x20\x27Food\x20Service\x20License\x27,\x20required:\x20true,\x20region:\x20\x27CN\x27\x20}`','-\x20`disclosure[]`:\x20text\x20the\x20merchant\x20MUST\x20show\x20buyers\x20up-front.','-\x20`refund_window`:\x20`{\x20days:\x20number,\x20not_applicable:\x20boolean,\x20exceptions:\x20[...]\x20}`','','##\x20supply\x20—\x20supply-chain\x20/\x20supplier\x20qualification','','-\x20`supplier_qualification[]`:\x20same\x20shape\x20as\x20compliance\x20qualifications,\x20but','\x20\x20evaluated\x20on\x20the\x20SUPPLIER\x20side\x20(multi-party\x20orders).','-\x20`first_order_policy`:\x20policy\x20string\x20on\x20the\x20first\x20order\x20from\x20a\x20new\x20supplier','\x20\x20(e.g.\x20`\x27sample-only\x27`,\x20`\x27reduced-quantity\x27`).','-\x20`redundancy_required`:\x20true\x20=\x20require\x20≥2\x20eligible\x20suppliers\x20before\x20accepting','\x20\x20an\x20order\x20(mitigates\x20single-sourcing).','','##\x20rules\x20—\x20declarative\x20machine-checked\x20rules','','Each\x20rule\x20is\x20an\x20AST\x20node\x20compiled\x20into\x20the\x20evaluation\x20engine:','`{\x20id:\x20\x27rule_...\x27,\x20when:\x20<bool-condition>,\x20then:\x20\x27reject\x27\x20|\x20\x27warn\x27\x20|\x20\x27flag\x27,\x20message:\x20\x27Text\x27\x20}`','Use\x20`rules`\x20for\x20rules\x20that\x20must\x20be\x20machine-checked;\x20put\x20human\x20strategy\x20in','`playbook.md`.','','##\x20mode\x20—\x20IndustryMode\x20(deep\x20shape)','','Not\x20scaffolded\x20by\x20default.\x20Add\x20it\x20when\x20you\x20need\x20a\x20full\x20driving\x20mode\x20for\x20the','industry,\x20or\x20ask\x20the\x20AI:\x20\x22help\x20me\x20fill\x20mode\x20for\x20<industry>\x22.','','Registered\x20into\x20`IndustryModeRegistry`\x20on\x20scan\x20(manifest\x20must\x20list\x20the','`mode`\x20layer).\x20A\x20pack\x20mode\x20with\x20the\x20same\x20name\x20as\x20a\x20builtin\x20replaces\x20it\x20when','the\x20pack\x20version\x20changes\x20or\x20on\x20a\x20forced\x20rescan.','','###\x20How\x20the\x20mode\x20is\x20consumed','','-\x20**Service\x20build\x20(priors)**:\x20`merchant_guide`\x20resolves\x20the\x20confirmed','\x20\x20industry\x20to\x20a\x20mode\x20(user\x20mode\x20first,\x20then\x20pack\x20mode,\x20then\x20builtin)\x20and','\x20\x20feeds\x20`machine_shape`\x20/\x20`guards`\x20/\x20`allocator`\x20/\x20`key_risk`\x20into\x20the','\x20\x20SemanticObjectGraph\x20build.','-\x20**Evaluation**:\x20the\x20metric\x20+\x20constraint\x20registries\x20score\x20the\x20mode','\x20\x20(risk/benefit\x200-100,\x20hard\x20violations\x20block\x20adoption).\x20Custom\x20metrics\x20and','\x20\x20constraints\x20registered\x20via\x20`industry_pack_operation`\x20participate\x20too.','-\x20**Recommendation**:\x20`recommend_industry`\x20matches\x20trait\x20similarity\x20and,','\x20\x20when\x20a\x20merchant\x20strategy\x20is\x20given,\x20re-ranks\x20by\x20lever\x20alignment\x20(70%','\x20\x20similarity\x20+\x2030%\x20alignment).','','###\x20Field\x20reference','','-\x20**Identity**:\x20`name`\x20(snake_case),\x20`display_name`,\x20`version`\x20(e.g.\x20`v1`),','\x20\x20`source`\x20(`builtin`\x20|\x20`custom`).','-\x20`traits`:\x2010-dimension\x20industry\x20trait\x20vector\x20(logistics,\x20cycle,\x20deposit,','\x20\x20regulatory\x20intensity,\x20...).\x20Drives\x20`recommend_industry`\x20similarity.','-\x20`machine_shape`:\x20Machine\x20node\x20topology\x20—\x20`[{\x20name,\x20role\x20}]`.\x20Node\x20names\x20are','\x20\x20business\x20states.\x20R-M1-11:\x20NEVER\x20model\x20refund/dispute\x20terminals','\x20\x20(`refunded`,\x20`disputed`,\x20`arb_*`)\x20as\x20nodes\x20—\x20disputes\x20flow\x20through','\x20\x20Service.arbitrations\x20independently;\x20route\x20refunds\x20via\x20the\x20Allocator','\x20\x20triggered\x20by\x20business\x20states\x20(`cancelled`,\x20`returned`).','-\x20`guards`:\x20`[{\x20template_id,\x20host,\x20purpose\x20}]`\x20—\x20guard\x20templates\x20to\x20attach.','\x20\x20`host`\x20is\x20one\x20of\x20`service`\x20|\x20`machine`\x20|\x20`reward`\x20|\x20`repository`\x20|','\x20\x20`arbitration`.','-\x20`allocator`:\x20`{\x20recipient,\x20count,\x20mode,\x20description\x20}`\x20—\x20fund\x20split.','\x20\x20`recipient`:\x20`signer`\x20|\x20`entity`;\x20`count`\x20>\x201\x20switches\x20to\x20multi-party','\x20\x20distribution;\x20`mode`:\x20`surplus`\x20|\x20`rate`\x20|\x20`milestone`.','-\x20`risk_checks`\x20/\x20`needs`:\x20buyer-side\x20due-diligence\x20entries\x20surfaced\x20in','\x20\x20prospect\x20evaluation.','-\x20`flywheel`:\x20acquisition\x20flywheel\x20—\x20`rewardStrategy`\x20/\x20`discountStrategy`','\x20\x20/\x20`trustSellingPoints`.\x20A\x20concrete\x20(non-`User-defined`)\x20strategy\x20turns','\x20\x20the\x20`reward`/`discount`\x20levers\x20on\x20for\x20strategy\x20alignment.','-\x20`key_risk`\x20(string)\x20/\x20`build_notes`\x20(string[]):\x20the\x20headline\x20risk\x20and','\x20\x20actionable\x20build\x20guidance\x20shown\x20to\x20the\x20merchant.','-\x20`capabilities_used`:\x20CapabilityCard\x20IDs\x20(e.g.\x20`guard.validate_buy`,','\x20\x20`machine.node_topology`,\x20`allocation.distribute_milestone`).\x20Powers\x20the','\x20\x20`buy_guard`\x20/\x20`machine_design`\x20levers\x20and\x20constraint\x20checks.','-\x20`config_overrides`:\x20per-object\x20field\x20defaults,\x20e.g.','\x20\x20`{\x20service:\x20{\x20engagement_type:\x20\x27milestone\x27\x20},\x20machine:\x20{\x20wip_required:\x20true\x20}\x20}`.','-\x20`config_override_rules`:\x20conditional\x20overrides\x20—','\x20\x20`{\x20object_type,\x20field_path,\x20value\x20|\x20{\x20intent_contains,\x20then_value,\x20else_value\x20}\x20}`.','-\x20`expected_benefits`:\x20`[{\x20metric,\x20expected_value,\x20evidence\x20}]`\x20—\x20what\x20the','\x20\x20mode\x20is\x20supposed\x20to\x20buy\x20you.','-\x20`risk_appetite`:\x20`conservative`\x20|\x20`balanced`\x20|\x20`aggressive`\x20(thresholds','\x20\x20for\x20the\x20risk/benefit\x20verdict).','-\x20`risk_constraints`:\x20`{\x20require_arbitration,\x20require_compensation_fund,','\x20\x20require_wip_evidence,\x20max_single_transaction?,','\x20\x20compensation_fund_coverage_ratio?,\x20other_constraints?\x20}`.\x20Coverage\x20ratio','\x20\x20multiplies\x20max\x20single\x20order\x20to\x20size\x20the\x20compensation\x20fund\x20(retail\x205,','\x20\x20rental\x2010,\x20subscription\x203;\x20default\x205).','-\x20`applicable_conditions`:\x20`{\x20business_scale,\x20min_daily_orders?,','\x20\x20other_conditions?\x20}`\x20—\x20when\x20the\x20mode\x20fits.','-\x20`similar_industries`\x20/\x20`novel_capabilities`:\x20migration\x20hints.','-\x20`disabled_builtin_constraints`:\x20builtin\x20constraint\x20IDs\x20this\x20mode','\x20\x20deliberately\x20opts\x20out\x20of\x20(e.g.\x20retail_d2c\x20skips\x20`require_arbitration`).','\x20\x20Custom\x20constraints\x20are\x20never\x20skipped.','','###\x20Persona\x20integration\x20(strategy\x20→\x20levers)','','The\x20personae\x20section\x27s\x20`current.strategy`\x20statements\x20are\x20bridged\x20into\x20mode','ranking\x20(value\x20intent\x20↔\x20game\x20path\x20unification).\x20Deterministic\x20mapping\x20—','\x22enumerable\x20→\x20MCP,\x20not\x20prompt\x22:','','-\x20`sales_priority`\x20(volume\x20first)\x20→\x20levers\x20`discount`\x20+\x20`reward`','-\x20`profit_priority`\x20(margin\x20first)\x20→\x20levers\x20`discount`\x20+\x20`machine_design`','-\x20`buyer_screening`\x20(qualify\x20buyers)\x20→\x20lever\x20`buy_guard`','-\x20`gross_margin_control`\x20(margin\x20band)\x20→\x20levers\x20`discount`\x20+\x20`machine_design`','','A\x20mode\x20supports\x20a\x20lever\x20when\x20its\x20data\x20says\x20so:\x20`guard.validate_buy`','capability\x20or\x20a\x20buy-guard\x20template\x20enables\x20`buy_guard`;\x20a\x20concrete','flywheel\x20reward/discount\x20strategy\x20enables\x20`reward`/`discount`;\x20a','non-empty\x20`machine_shape`\x20with\x20`machine.node_topology`\x20enables','`machine_design`.\x20Pass\x20strategy\x20text\x20to\x20`recommend_industry`\x20and\x20each','recommendation\x20reports\x20`strategy_alignment`\x20(matched/missing\x20levers).','','##\x20Reset','','Right-click\x20any\x20file/pack\x20folder\x20in\x20the\x20Industry\x20drawer\x20and\x20choose\x20*Reset*','to\x20restore\x20the\x20pristine\x20template\x20at\x20any\x20time.','']['join']('\x0a');}export function ensureIndustryReadme(){const a=resolveIndustryPackDir();mkdirSync(a,{'recursive':!![]});const b=join(a,'README.md');return writeFileSync(b,industryReadmeContent(),'utf-8'),b;}export function scaffoldIndustryPack(a,b){const c=join(b??resolveIndustryPackDir(),a),d=[],e=[];if(!/^[a-z][a-z0-9_]*$/['test'](a))return{'ok':![],'dir':c,'files':d,'errors':['industry\x20name\x20\x27'+a+'\x27\x20must\x20be\x20lowercase\x20snake_case\x20(a-z,\x200-9,\x20_)']};try{mkdirSync(c,{'recursive':!![]}),ensureIndustryReadme();const f=buildPristineMergedPack(a);return writeFileSync(join(c,'pack.json'),JSON['stringify'](f,null,0x2)+'\x0a'),d['push']('pack.json'),writeFileSync(join(c,'playbook.md'),playbookTemplate(a)),d['push']('playbook.md'),{'ok':!![],'dir':c,'files':d,'errors':e};}catch(g){return{'ok':![],'dir':c,'files':d,'errors':['scaffold\x20failed:\x20'+g['message']]};}}export function readMergedPackIfPresent(a){const b=join(a,'pack.json');if(!existsSync(b))return null;try{const c=readFileSync(b,'utf-8');return JSON['parse'](c);}catch{return null;}}function playbookTemplate(a){return['#\x20'+a+'\x20—\x20Industry\x20Playbook','','>\x20📘\x20This\x20file\x20captures\x20human\x20business\x20intelligence\x20for\x20the\x20`'+a+'`','>\x20industry.\x20Content\x20here\x20is\x20READ\x20BY\x20THE\x20AI\x20AS\x20CONTEXT\x20on\x20every\x20turn,','>\x20and\x20OVERRIDES\x20WoWok\x27s\x20generic\x20built-in\x20industry\x20data/rules\x20for\x20this','>\x20account.\x20The\x20companion\x20`pack.json`\x20file\x20stores\x20machine-checkable','>\x20rules;\x20THIS\x20file\x20stores\x20human\x20strategy,\x20tone,\x20experience,\x20and\x20ethics.','','>\x20💡\x20Hint\x20for\x20the\x20AI:\x20when\x20the\x20user\x20asks\x20a\x20question\x20about\x20\x22how\x20to','>\x20handle\x20'+a+'\x22\x20or\x20\x22what\x20should\x20I\x20do?\x22,\x20check\x20this\x20file\x20first\x20for\x20the','>\x20merchant/customer\x20voice,\x20then\x20fall\x20back\x20to\x20your\x20built-in\x20data.\x20Cite','>\x20section\x20titles\x20in\x20your\x20reply\x20so\x20the\x20user\x20knows\x20where\x20advice\x20comes\x20from.','','##\x20Experience\x20(Field-Tested\x20Rules\x20of\x20Thumb)','','>\x20Write\x20what\x20actually\x20works\x20in\x20this\x20industry\x20—\x20not\x20what\x20textbooks\x20say.','>\x20Short\x20bullet\x20points\x20preferred;\x20the\x20AI\x20reads\x20them\x20as\x20axioms.\x20Include','>\x20specific\x20numbers\x20when\x20you\x20have\x20them.','','-\x20(Example)\x20\x22Catering:\x20if\x20the\x20event\x20starts\x20before\x2010:00,\x20always\x20assume','\x20\x20the\x20customer\x20wants\x20breakfast\x20service\x20too\x20—\x20upsell\x20it\x20proactively.\x22','-\x20(Example)\x20\x22Common\x20pitfall:\x20last-minute\x20menu\x20swaps\x20on\x20Fridays\x20—\x20require','\x20\x20a\x20written\x20change\x20request\x2048\x20h\x20before\x20the\x20event\x20or\x20charge\x20a\x2015%\x20fee.\x22','-\x20(Add\x20more\x20below\x20—\x20delete\x20the\x20examples\x20above\x20when\x20you\x20have\x20real\x20ones.)','','##\x20Strategy\x20(Competitive\x20/\x20Game-Theory)','','>\x20How\x20should\x20each\x20role\x20act\x20in\x20a\x20negotiation\x20/\x20dispute\x20/\x20supplier','>\x20relationship?\x20Think\x20in\x20\x22always\x20/\x20never\x20/\x20depends-on-X\x22\x20rules,\x20and\x20call','>\x20out\x20the\x20trade-offs.','','-\x20Merchant\x20strategy:\x20(Add\x20how\x20a\x20merchant\x20in\x20this\x20industry\x20should\x20act\x20—','\x20\x20price\x20anchoring,\x20which\x20concessions\x20to\x20give\x20early\x20vs\x20late,\x20what\x20to','\x20\x20never\x20concede\x20on,\x20etc.)','-\x20Customer\x20strategy:\x20(Add\x20what\x20a\x20smart\x20customer\x20should\x20push\x20for.)','-\x20Dispute\x20strategy:\x20(When\x20to\x20settle\x20fast\x20vs\x20when\x20to\x20fight\x20for\x20full','\x20\x20evidence\x20+\x20arbitration.\x20Call\x20out\x20the\x20escalation\x20thresholds.)','','##\x20Personalization\x20(Tone,\x20Brand,\x20Ethics,\x20Red\x20Lines)','','-\x20Tone\x20/\x20voice:\x20(Write\x20one\x20sentence\x20describing\x20the\x20exact\x20conversational','\x20\x20voice\x20this\x20account\x20should\x20use\x20—\x20casual,\x20formal,\x20technical,\x20etc.)','-\x20Brand\x20rules:\x20(Logo,\x20link-out\x20style,\x20forbidden\x20terminology,','\x20\x20always-include\x20phrases,\x20etc.)','-\x20Red\x20lines:\x20(Non-negotiable.\x20Example:\x20\x22Never\x20make\x20a\x20refund\x20promise','\x20\x20larger\x20than\x2030%\x20without\x20arbitration\x20evidence.\x22)','-\x20Ethics:\x20(Example:\x20\x22If\x20customer\x20appears\x20intoxicated,\x20refuse\x20service','\x20\x20and\x20refer\x20to\x20supervisor;\x20never\x20take\x20the\x20order\x20for\x20profit.\x22)','','##\x20Playbook\x20Maintenance','','>\x20You\x20don\x27t\x20need\x20to\x20be\x20perfect\x20on\x20day\x20one.\x20After\x20every\x20real\x20deal,\x20add\x20a','>\x20bullet\x20to\x20the\x20above\x20sections\x20with\x20what\x20worked\x20/\x20what\x20failed.\x20Every','>\x20entry\x20improves\x20the\x20AI\x27s\x20future\x20decisions.','','>\x20Right-click\x20the\x20file\x20or\x20this\x20pack\x20folder\x20in\x20the\x20Industry\x20drawer\x20at','>\x20any\x20time\x20and\x20choose\x20\x22Reset\x22\x20to\x20restore\x20this\x20annotated\x20template.','']['join']('\x0a');}export function locatePackAndRemainder(a){const b=a['replace'](/^[\\/]+/,'')['replace'](/[\\/]+$/,'');if(!b)return null;const [c,...d]=b['split'](/[\\/]+/);if(!c)return null;return{'packName':c,'remainder':d['join']('/')};}export function resetIndustryPath(a,b){const c=[],d=[],f=b??resolveIndustryPackDir(),g=locatePackAndRemainder(a),h=a;if(!g)return{'ok':![],'layout':'merged','target':h,'restored_files':[],'errors':['invalid\x20reset\x20path\x20\x27'+a+'\x27']};const {packName:i,remainder:j}=g,k=join(f,i);if(!existsSync(k))return{'ok':![],'layout':'merged','target':h,'restored_files':[],'errors':['pack\x20directory\x20\x27'+i+'\x27\x20does\x20not\x20exist']};if(!/^[a-z][a-z0-9_]*$/['test'](i))return{'ok':![],'layout':'merged','target':h,'restored_files':[],'errors':['pack\x20name\x20\x27'+i+'\x27\x20is\x20not\x20a\x20valid\x20snake_case\x20identifier']};const l=readMergedPackIfPresent(k),n=l?'merged':'legacy';if(j==='')try{mkdirSync(k,{'recursive':!![]});const s=buildPristineMergedPack(i);return writeFileSync(join(k,'pack.json'),JSON['stringify'](s,null,0x2)+'\x0a'),d['push']('pack.json'),writeFileSync(join(k,'playbook.md'),playbookTemplate(i)),d['push']('playbook.md'),{'ok':!![],'layout':'merged','target':h,'restored_files':d,'errors':c};}catch(t){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['pack\x20reset\x20failed:\x20'+t['message']]};}const o=j['split']('/')['slice'](-0x1)[0x0],p=j==='playbook.md',q=j['startsWith'](PERSONAE_DIR+'/')&&o['endsWith']('.json');if(n==='merged'){if(p)try{return writeFileSync(join(k,'playbook.md'),playbookTemplate(i)),d['push']('playbook.md'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(v){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['playbook\x20reset\x20failed:\x20'+v['message']]};}const u=LAYER_FILE_SECTION[j];if(u)try{const w=readMergedPackIfPresent(k)??buildPristineMergedPack(i);switch(u){case'match':w['match']=matchSection(i);break;case'dispute':w['dispute']=disputeSection(i);break;case'compliance':w['compliance']=complianceSection(i);break;case'supply':w['supply']=supplySection(i);break;case'rules':w['rules']=rulesSection(i);break;case'mode':w['mode']=null;break;}return writeFileSync(join(k,'pack.json'),JSON['stringify'](w,null,0x2)+'\x0a'),d['push']('pack.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(x){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['section\x20reset\x20failed:\x20'+x['message']]};}if(q){const y=o['replace'](/\.json$/,'');if(!PERSONA_ROLES['includes'](y))return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['unknown\x20persona\x20role\x20\x27'+y+'\x27']};try{const z=readMergedPackIfPresent(k)??buildPristineMergedPack(i),A=z['personae']&&Array['isArray'](z['personae'])?[...z['personae']]:[],B=A['findIndex'](D=>D['role']===y),C=personaPerRole(y,i);if(B>=0x0)A[B]=C;else A['push'](C);return z['personae']=A,writeFileSync(join(k,'pack.json'),JSON['stringify'](z,null,0x2)+'\x0a'),d['push']('pack.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(D){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['persona\x20reset\x20failed:\x20'+D['message']]};}}if(j==='manifest.json'||j==='manifest')try{const E=readMergedPackIfPresent(k)??buildPristineMergedPack(i);return E['manifest']=manifestSection(i),writeFileSync(join(k,'pack.json'),JSON['stringify'](E,null,0x2)+'\x0a'),d['push']('pack.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(F){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['manifest\x20reset\x20failed:\x20'+F['message']]};}return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['path\x20\x27'+j+'\x27\x20is\x20not\x20a\x20standard\x20section\x20file\x20of\x20pack\x20\x27'+i+'\x27.\x20Reset\x20is\x20only\x20provided\x20for\x20pack.json\x20standard\x20sections\x20and\x20playbook.md.']};}if(p)try{return writeFileSync(join(k,'playbook.md'),playbookTemplate(i)),d['push']('playbook.md'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(G){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20playbook\x20reset\x20failed:\x20'+G['message']]};}if(j==='manifest.json')try{const H=manifestSection(i);return writeFileSync(join(k,'manifest.json'),JSON['stringify'](H,null,0x2)+'\x0a'),d['push']('manifest.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(I){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20manifest\x20reset\x20failed:\x20'+I['message']]};}const r=LAYER_FILE_SECTION[j];if(r)try{let J='';switch(r){case'match':J=JSON['stringify'](matchSection(i),null,0x2)+'\x0a';break;case'dispute':J=JSON['stringify'](disputeSection(i),null,0x2)+'\x0a';break;case'compliance':J=JSON['stringify'](complianceSection(i),null,0x2)+'\x0a';break;case'supply':J=JSON['stringify'](supplySection(i),null,0x2)+'\x0a';break;case'rules':J=JSON['stringify'](rulesSection(i),null,0x2)+'\x0a';break;case'mode':J=JSON['stringify']({},null,0x2)+'\x0a';break;}return writeFileSync(join(k,j),J),d['push'](j),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(K){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20section\x20reset\x20failed:\x20'+K['message']]};}if(q){const L=o['replace'](/\.json$/,'');if(!PERSONA_ROLES['includes'](L))return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['unknown\x20persona\x20\x27'+L+'\x27']};try{return writeFileSync(join(k,j),JSON['stringify'](personaPerRole(L,i),null,0x2)+'\x0a'),d['push'](j),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(M){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20persona\x20reset\x20failed:\x20'+M['message']]};}}return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['cannot\x20reset\x20non-standard\x20file\x20\x27'+j+'\x27\x20in\x20legacy\x20layout.\x20Only\x20standard\x20layer\x20files,\x20personae/*.json,\x20manifest.json,\x20and\x20playbook.md\x20can\x20be\x20reset.']};}
|
|
@@ -3,18 +3,20 @@ import type { CapabilityRegistry } from "./capability-manifest.js";
|
|
|
3
3
|
export declare class MetricRegistry {
|
|
4
4
|
private static instance;
|
|
5
5
|
private metrics;
|
|
6
|
-
private
|
|
6
|
+
private persistence;
|
|
7
|
+
private customMetricsLoaded;
|
|
7
8
|
static Instance(): MetricRegistry;
|
|
8
9
|
private constructor();
|
|
10
|
+
ensureLoaded(): Promise<void>;
|
|
9
11
|
registerMetric(metric: BaseMetric): boolean;
|
|
10
|
-
registerCustomMetric(metric_id: string, display_name: string, description: string, type: MetricType, scale: MetricScale, owner: string, weight?: number): boolean
|
|
12
|
+
registerCustomMetric(metric_id: string, display_name: string, description: string, type: MetricType, scale: MetricScale, owner: string, weight?: number): Promise<boolean>;
|
|
11
13
|
getMetric(metric_id: string): BaseMetric | undefined;
|
|
12
14
|
listMetrics(filter?: {
|
|
13
15
|
type?: MetricType;
|
|
14
16
|
scope?: "builtin" | "custom";
|
|
15
17
|
owner?: string;
|
|
16
|
-
}): BaseMetric[]
|
|
17
|
-
unregisterMetric(metric_id: string, owner: string): boolean
|
|
18
|
+
}): Promise<BaseMetric[]>;
|
|
19
|
+
unregisterMetric(metric_id: string, owner: string): Promise<boolean>;
|
|
18
20
|
evaluateMode(mode: IndustryMode, capabilityRegistry: CapabilityRegistry, extraMetrics?: BaseMetric[]): MetricEvaluation;
|
|
19
21
|
private evaluateMetricGroup;
|
|
20
22
|
private computeAverageScore;
|