@wowok/agent-mcp 3.0.2 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +0 -3
- package/dist/harness/recover.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/knowledge/account-marks.js +1 -1
- package/dist/knowledge/arbitration-risk.js +1 -1
- package/dist/knowledge/flywheel-loop.d.ts +4 -52
- package/dist/knowledge/flywheel-loop.js +1 -1
- package/dist/knowledge/guard-lint.js +1 -1
- package/dist/knowledge/index.d.ts +2 -225
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/machine-risk.js +1 -1
- package/dist/knowledge/machine-translation.js +1 -1
- package/dist/knowledge/onchain-constants.js +1 -1
- package/dist/knowledge/order-ledger.d.ts +2 -2
- package/dist/knowledge/order-ledger.js +1 -1
- package/dist/knowledge/order-puzzle.d.ts +4 -4
- package/dist/knowledge/order-puzzle.js +1 -1
- package/dist/knowledge/order-risk.d.ts +1 -0
- package/dist/knowledge/order-risk.js +1 -1
- package/dist/knowledge/order-templates.d.ts +1 -1
- package/dist/knowledge/order-templates.js +1 -1
- package/dist/knowledge/safety-rules.js +1 -1
- package/dist/knowledge/service-ledger.js +1 -1
- package/dist/knowledge/service-risk.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/knowledge/workspace-lists.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/context-assembly.d.ts +3 -1
- package/dist/playbooks/service-build/context-assembly.js +1 -1
- package/dist/playbooks/service-build/machine-nodes.d.ts +2 -0
- package/dist/playbooks/service-build/machine-nodes.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.d.ts +7 -0
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/review/machine.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/call/base.d.ts +12 -3
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +4 -0
- package/dist/schema/call/bridge.js +1 -1
- package/dist/schema/call/error-codes.d.ts +2 -0
- package/dist/schema/call/error-codes.js +1 -0
- package/dist/schema/call/guard.d.ts +4 -4
- package/dist/schema/call/semantic.d.ts +9 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/goal/index.d.ts +3 -3
- package/dist/schema/goal/planning.d.ts +2 -2
- package/dist/schema/industry-pack/index.d.ts +4 -4
- package/dist/schema/industry-pack/modes.d.ts +4 -4
- package/dist/schema/local/index.d.ts +558 -0
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/messenger/index.d.ts +25 -25
- package/dist/schema/operations.d.ts +1 -1
- package/dist/schema/persona/index.d.ts +2 -2
- package/dist/schema/query/bi.d.ts +0 -4
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-query/index.d.ts +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/trust/index.d.ts +3 -3
- package/dist/schema/workspace/index.d.ts +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +4 -0
- package/dist/schemas/bridge_operation.output.json +4 -0
- package/dist/schemas/index.json +7 -1
- package/dist/schemas/local_history_operation.output.json +1458 -0
- package/dist/schemas/local_history_operation.schema.json +105 -0
- package/dist/schemas/local_info_operation.output.json +4 -0
- package/dist/schemas/local_mark_operation.output.json +4 -0
- package/dist/schemas/onchain_operations.output.json +4 -1
- package/dist/schemas/onchain_operations.schema.json +30 -10
- package/dist/schemas/onchain_operations_guard.schema.json +30 -10
- package/dist/schemas/query_toolkit.output.json +17 -16
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/local.d.ts +1 -0
- package/dist/tools/handlers/local.js +1 -1
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/registry/local.js +1 -1
- package/dist/tools/shared.js +1 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +2 -2
- package/dist/knowledge/allocation-confirm.d.ts +0 -115
- package/dist/knowledge/allocation-confirm.js +0 -1
- package/dist/knowledge/allocation-context.d.ts +0 -58
- package/dist/knowledge/allocation-context.js +0 -1
- package/dist/knowledge/allocation-translation.d.ts +0 -72
- package/dist/knowledge/allocation-translation.js +0 -1
- package/dist/knowledge/arb-confirm.d.ts +0 -28
- package/dist/knowledge/arb-confirm.js +0 -1
- package/dist/knowledge/arb-translation.d.ts +0 -48
- package/dist/knowledge/arb-translation.js +0 -1
- package/dist/knowledge/arbitration-confirm.d.ts +0 -135
- package/dist/knowledge/arbitration-confirm.js +0 -1
- package/dist/knowledge/arbitration-context.d.ts +0 -81
- package/dist/knowledge/arbitration-context.js +0 -1
- package/dist/knowledge/arbitration-translation.d.ts +0 -91
- package/dist/knowledge/arbitration-translation.js +0 -1
- package/dist/knowledge/bridge-confirm.d.ts +0 -26
- package/dist/knowledge/bridge-confirm.js +0 -1
- package/dist/knowledge/bridge-translation.d.ts +0 -37
- package/dist/knowledge/bridge-translation.js +0 -1
- package/dist/knowledge/contact-confirm.d.ts +0 -27
- package/dist/knowledge/contact-confirm.js +0 -1
- package/dist/knowledge/contact-translation.d.ts +0 -39
- package/dist/knowledge/contact-translation.js +0 -1
- package/dist/knowledge/demand-confirm.d.ts +0 -32
- package/dist/knowledge/demand-confirm.js +0 -1
- package/dist/knowledge/demand-context.d.ts +0 -17
- package/dist/knowledge/demand-context.js +0 -1
- package/dist/knowledge/demand-ledger.d.ts +0 -26
- package/dist/knowledge/demand-ledger.js +0 -1
- package/dist/knowledge/demand-puzzle.d.ts +0 -29
- package/dist/knowledge/demand-puzzle.js +0 -1
- package/dist/knowledge/demand-templates.d.ts +0 -12
- package/dist/knowledge/demand-templates.js +0 -1
- package/dist/knowledge/demand-translation.d.ts +0 -55
- package/dist/knowledge/demand-translation.js +0 -1
- package/dist/knowledge/examples-scanner-cli.d.ts +0 -1
- package/dist/knowledge/examples-scanner-cli.js +0 -1
- package/dist/knowledge/examples-scanner.d.ts +0 -121
- package/dist/knowledge/examples-scanner.js +0 -1
- package/dist/knowledge/glossary.d.ts +0 -18
- package/dist/knowledge/glossary.js +0 -1
- package/dist/knowledge/guard-bytecode-spec.d.ts +0 -82
- package/dist/knowledge/guard-bytecode-spec.js +0 -1
- package/dist/knowledge/guard-confirm.d.ts +0 -86
- package/dist/knowledge/guard-confirm.js +0 -1
- package/dist/knowledge/immutability.d.ts +0 -11
- package/dist/knowledge/immutability.js +0 -1
- package/dist/knowledge/machine-confirm.d.ts +0 -102
- package/dist/knowledge/machine-confirm.js +0 -1
- package/dist/knowledge/machine-context.d.ts +0 -160
- package/dist/knowledge/machine-context.js +0 -1
- package/dist/knowledge/machine-render.d.ts +0 -41
- package/dist/knowledge/machine-render.js +0 -1
- package/dist/knowledge/mcp-schema-audit-cli.d.ts +0 -1
- package/dist/knowledge/mcp-schema-audit-cli.js +0 -1
- package/dist/knowledge/mcp-schema-audit.d.ts +0 -91
- package/dist/knowledge/mcp-schema-audit.js +0 -1
- package/dist/knowledge/messenger-guard-guidance.d.ts +0 -17
- package/dist/knowledge/messenger-guard-guidance.js +0 -1
- package/dist/knowledge/order-confirm.d.ts +0 -115
- package/dist/knowledge/order-confirm.js +0 -1
- package/dist/knowledge/order-context.d.ts +0 -66
- package/dist/knowledge/order-context.js +0 -1
- package/dist/knowledge/order-translation.d.ts +0 -78
- package/dist/knowledge/order-translation.js +0 -1
- package/dist/knowledge/overrides-loader.d.ts +0 -13
- package/dist/knowledge/overrides-loader.js +0 -1
- package/dist/knowledge/passport-confirm.d.ts +0 -130
- package/dist/knowledge/passport-confirm.js +0 -1
- package/dist/knowledge/passport-context.d.ts +0 -59
- package/dist/knowledge/passport-context.js +0 -1
- package/dist/knowledge/passport-puzzle.d.ts +0 -108
- package/dist/knowledge/passport-puzzle.js +0 -1
- package/dist/knowledge/passport-risk.d.ts +0 -70
- package/dist/knowledge/passport-risk.js +0 -1
- package/dist/knowledge/passport-translation.d.ts +0 -68
- package/dist/knowledge/passport-translation.js +0 -1
- package/dist/knowledge/payment-confirm.d.ts +0 -26
- package/dist/knowledge/payment-confirm.js +0 -1
- package/dist/knowledge/payment-translation.d.ts +0 -37
- package/dist/knowledge/payment-translation.js +0 -1
- package/dist/knowledge/permission-confirm.d.ts +0 -110
- package/dist/knowledge/permission-confirm.js +0 -1
- package/dist/knowledge/permission-context.d.ts +0 -69
- package/dist/knowledge/permission-context.js +0 -1
- package/dist/knowledge/permission-translation.d.ts +0 -57
- package/dist/knowledge/permission-translation.js +0 -1
- package/dist/knowledge/personal-confirm.d.ts +0 -29
- package/dist/knowledge/personal-confirm.js +0 -1
- package/dist/knowledge/personal-translation.d.ts +0 -37
- package/dist/knowledge/personal-translation.js +0 -1
- package/dist/knowledge/process-model.d.ts +0 -14
- package/dist/knowledge/process-model.js +0 -1
- package/dist/knowledge/progress-confirm.d.ts +0 -108
- package/dist/knowledge/progress-confirm.js +0 -1
- package/dist/knowledge/progress-context.d.ts +0 -123
- package/dist/knowledge/progress-context.js +0 -1
- package/dist/knowledge/progress-translation.d.ts +0 -52
- package/dist/knowledge/progress-translation.js +0 -1
- package/dist/knowledge/proof-confirm.d.ts +0 -31
- package/dist/knowledge/proof-confirm.js +0 -1
- package/dist/knowledge/proof-context.d.ts +0 -17
- package/dist/knowledge/proof-context.js +0 -1
- package/dist/knowledge/proof-ledger.d.ts +0 -34
- package/dist/knowledge/proof-ledger.js +0 -1
- package/dist/knowledge/proof-puzzle.d.ts +0 -35
- package/dist/knowledge/proof-puzzle.js +0 -1
- package/dist/knowledge/proof-templates.d.ts +0 -22
- package/dist/knowledge/proof-templates.js +0 -1
- package/dist/knowledge/proof-translation.d.ts +0 -52
- package/dist/knowledge/proof-translation.js +0 -1
- package/dist/knowledge/registrar-confirm.d.ts +0 -26
- package/dist/knowledge/registrar-confirm.js +0 -1
- package/dist/knowledge/registrar-translation.d.ts +0 -37
- package/dist/knowledge/registrar-translation.js +0 -1
- package/dist/knowledge/repository-confirm.d.ts +0 -40
- package/dist/knowledge/repository-confirm.js +0 -1
- package/dist/knowledge/repository-context.d.ts +0 -12
- package/dist/knowledge/repository-context.js +0 -1
- package/dist/knowledge/repository-ledger.d.ts +0 -25
- package/dist/knowledge/repository-ledger.js +0 -1
- package/dist/knowledge/repository-puzzle.d.ts +0 -30
- package/dist/knowledge/repository-puzzle.js +0 -1
- package/dist/knowledge/repository-templates.d.ts +0 -14
- package/dist/knowledge/repository-templates.js +0 -1
- package/dist/knowledge/repository-translation.d.ts +0 -58
- package/dist/knowledge/repository-translation.js +0 -1
- package/dist/knowledge/resource-confirm.d.ts +0 -25
- package/dist/knowledge/resource-confirm.js +0 -1
- package/dist/knowledge/resource-translation.d.ts +0 -37
- package/dist/knowledge/resource-translation.js +0 -1
- package/dist/knowledge/reward-confirm.d.ts +0 -116
- package/dist/knowledge/reward-confirm.js +0 -1
- package/dist/knowledge/reward-context.d.ts +0 -127
- package/dist/knowledge/reward-context.js +0 -1
- package/dist/knowledge/reward-translation.d.ts +0 -58
- package/dist/knowledge/reward-translation.js +0 -1
- package/dist/knowledge/service-confirm.d.ts +0 -161
- package/dist/knowledge/service-confirm.js +0 -1
- package/dist/knowledge/service-context.d.ts +0 -66
- package/dist/knowledge/service-context.js +0 -1
- package/dist/knowledge/service-translation.d.ts +0 -103
- package/dist/knowledge/service-translation.js +0 -1
- package/dist/knowledge/treasury-confirm.d.ts +0 -133
- package/dist/knowledge/treasury-confirm.js +0 -1
- package/dist/knowledge/treasury-context.d.ts +0 -64
- package/dist/knowledge/treasury-context.js +0 -1
- package/dist/knowledge/treasury-translation.d.ts +0 -78
- package/dist/knowledge/treasury-translation.js +0 -1
- package/dist/knowledge/util-confirm.d.ts +0 -24
- package/dist/knowledge/util-confirm.js +0 -1
- package/dist/knowledge/util-translation.d.ts +0 -39
- package/dist/knowledge/util-translation.js +0 -1
- package/dist/loop-engineering/aggregate.d.ts +0 -50
- package/dist/loop-engineering/aggregate.js +0 -1
- package/dist/loop-engineering/context-collect.d.ts +0 -7
- package/dist/loop-engineering/context-collect.js +0 -1
- package/dist/loop-engineering/diagnose.d.ts +0 -22
- package/dist/loop-engineering/diagnose.js +0 -1
- package/dist/loop-engineering/improve.d.ts +0 -55
- package/dist/loop-engineering/improve.js +0 -1
- package/dist/loop-engineering/index.d.ts +0 -4
- package/dist/loop-engineering/index.js +0 -1
- package/dist/loop-engineering/pipeline.d.ts +0 -17
- package/dist/loop-engineering/pipeline.js +0 -1
- package/dist/schema/utils/object-type-utils.d.ts +0 -12
- package/dist/schema/utils/object-type-utils.js +0 -1
- package/dist/telemetry/index.d.ts +0 -19
- package/dist/telemetry/index.js +0 -1
- package/dist/telemetry/redact.d.ts +0 -2
- package/dist/telemetry/redact.js +0 -1
- package/dist/telemetry/storage.d.ts +0 -8
- package/dist/telemetry/storage.js +0 -1
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { AggregatedStats } from "./aggregate.js";
|
|
2
|
-
export type DiagnosisType = "rule_gap" | "description_quality" | "skill_need" | "recovery_ineffectiveness" | "latency_anomaly" | "industry_health_anomaly";
|
|
3
|
-
export type DiagnosisSeverity = "P0" | "P1" | "P2" | "P3";
|
|
4
|
-
export interface Diagnosis {
|
|
5
|
-
diagnosis_id: string;
|
|
6
|
-
type: DiagnosisType;
|
|
7
|
-
severity: DiagnosisSeverity;
|
|
8
|
-
title: string;
|
|
9
|
-
description: string;
|
|
10
|
-
evidence: Record<string, unknown>;
|
|
11
|
-
target: string;
|
|
12
|
-
proposed_improvement_type: "rule_addition" | "description_rewrite" | "skill_creation" | "recovery_priority_adjustment" | "investigation" | "industry_update_application";
|
|
13
|
-
}
|
|
14
|
-
export interface DiagnosisReport {
|
|
15
|
-
report_id: string;
|
|
16
|
-
diagnosis_date: string;
|
|
17
|
-
total_diagnoses: number;
|
|
18
|
-
diagnoses: Diagnosis[];
|
|
19
|
-
summary: string;
|
|
20
|
-
}
|
|
21
|
-
export declare function diagnoseIndustryHealth(industries?: string[]): Diagnosis[];
|
|
22
|
-
export declare function diagnose(stats: AggregatedStats): DiagnosisReport;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{listIndustriesWithSignals,getIndustryEvolutionStatus,getPendingSuggestions,getIndustrySignalCount}from'../knowledge/flywheel-loop.js';const THRESHOLDS={'UNKNOWN_ERROR_RATE_P0':0.15,'UNKNOWN_ERROR_RATE_P1':0.08,'LOW_SEMANTIC_HIT_RATE':0.5,'LOW_SUCCESS_RATE':0.7,'HIGH_LATENCY_MS':0x1388,'MIN_SAMPLE_SIZE':0xa,'MIN_UNKNOWN_ERRORS_FOR_RULE':0x3};function diagnoseRuleGaps(a){const b=[];if(a['overall']['unknown_error_rate']>=THRESHOLDS['UNKNOWN_ERROR_RATE_P1']&&a['overall']['unknown_error_count']>=THRESHOLDS['MIN_UNKNOWN_ERRORS_FOR_RULE']){const c=a['overall']['unknown_error_rate']>=THRESHOLDS['UNKNOWN_ERROR_RATE_P0']?'P0':'P1',d=[];for(const e of a['per_tool']){for(const f of e['top_error_messages']){d['push'](f);}}b['push']({'diagnosis_id':'DIAG-RULE-'+Date['now']()+'-001','type':'rule_gap','severity':c,'title':'High\x20unknown\x20error\x20rate\x20('+(a['overall']['unknown_error_rate']*0x64)['toFixed'](0x1)+'%)','description':a['overall']['unknown_error_count']+'\x20errors\x20classified\x20as\x20\x27unknown\x27\x20out\x20of\x20'+a['overall']['total_calls']+'\x20total\x20calls.\x20The\x20ERROR_RULES\x20table\x20does\x20not\x20cover\x20these\x20error\x20patterns.','evidence':{'unknown_error_count':a['overall']['unknown_error_count'],'unknown_error_rate':a['overall']['unknown_error_rate'],'top_error_messages':d['slice'](0x0,0x5)},'target':'ERROR_RULES','proposed_improvement_type':'rule_addition'});}for(const g of a['per_tool']){const h=g['error_distribution']['unknown']||0x0;h>=THRESHOLDS['MIN_UNKNOWN_ERRORS_FOR_RULE']&&b['push']({'diagnosis_id':'DIAG-RULE-'+Date['now']()+'-'+g['tool_name'],'type':'rule_gap','severity':'P2','title':'Tool\x20\x27'+g['tool_name']+'\x27\x20has\x20'+h+'\x20unknown\x20errors','description':'Tool-specific\x20error\x20patterns\x20not\x20covered\x20by\x20ERROR_RULES.','evidence':{'tool_name':g['tool_name'],'unknown_error_count':h,'top_error_messages':g['top_error_messages']['slice'](0x0,0x3)},'target':'ERROR_RULES\x20(for\x20'+g['tool_name']+')','proposed_improvement_type':'rule_addition'});}return b;}function diagnoseDescriptionQuality(a){const b=[];for(const c of a['per_tool']){if(c['total_calls']<THRESHOLDS['MIN_SAMPLE_SIZE'])continue;if(c['semantic_hit_rate']<THRESHOLDS['LOW_SEMANTIC_HIT_RATE']){const d=c['semantic_hit_rate']<0.25?'P1':'P2';b['push']({'diagnosis_id':'DIAG-DESC-'+Date['now']()+'-'+c['tool_name'],'type':'description_quality','severity':d,'title':'Low\x20semantic\x20hit\x20rate\x20for\x20\x27'+c['tool_name']+'\x27\x20('+(c['semantic_hit_rate']*0x64)['toFixed'](0x1)+'%)','description':'The\x20semantic\x20layer\x20is\x20not\x20producing\x20summaries\x20for\x20most\x20calls\x20to\x20this\x20tool.\x20This\x20may\x20indicate\x20description\x20gaps\x20or\x20missing\x20INTENT_RULES\x20for\x20this\x20operation\x20type.','evidence':{'tool_name':c['tool_name'],'semantic_hit_rate':c['semantic_hit_rate'],'total_calls':c['total_calls']},'target':c['tool_name']+'\x20description\x20/\x20INTENT_RULES','proposed_improvement_type':'description_rewrite'});}}return b;}function diagnoseSkillNeeds(a){const b=[];for(const c of a['per_operation']){if(c['total_calls']<THRESHOLDS['MIN_SAMPLE_SIZE'])continue;c['success_rate']<THRESHOLDS['LOW_SUCCESS_RATE']&&c['success_rate']>0x0&&b['push']({'diagnosis_id':'DIAG-SKILL-'+Date['now']()+'-'+c['operation_type'],'type':'skill_need','severity':'P2','title':'Operation\x20\x27'+c['operation_type']+'\x27\x20has\x20low\x20success\x20rate\x20('+(c['success_rate']*0x64)['toFixed'](0x1)+'%)','description':'This\x20operation\x20type\x20has\x20a\x20high\x20failure\x20rate,\x20suggesting\x20users\x20may\x20lack\x20guidance.\x20A\x20Skill\x20with\x20step-by-step\x20dialogue\x20and\x20failure\x20playbooks\x20could\x20help.','evidence':{'operation_type':c['operation_type'],'success_rate':c['success_rate'],'total_calls':c['total_calls'],'error_distribution':c['error_distribution']},'target':'new\x20Skill\x20for\x20'+c['operation_type'],'proposed_improvement_type':'skill_creation'});}return b;}function diagnoseRecoveryIneffectiveness(a){const b=[],c=Object['entries'](a['error_code_distribution'])['filter'](([d])=>d!=='unknown')['sort']((d,e)=>e[0x1]-d[0x1]);for(const [d,e]of c){const f=a['overall']['total_calls'];f>0x0&&e/f>0.1&&e>=THRESHOLDS['MIN_SAMPLE_SIZE']&&b['push']({'diagnosis_id':'DIAG-RECOV-'+Date['now']()+'-'+d,'type':'recovery_ineffectiveness','severity':'P2','title':'Error\x20code\x20\x27'+d+'\x27\x20accounts\x20for\x20'+e+'\x20failures\x20('+(e/f*0x64)['toFixed'](0x1)+'%)','description':'This\x20error\x20code\x20is\x20frequent.\x20The\x20recovery\x20strategy\x20may\x20need\x20priority\x20adjustment\x20or\x20the\x20root\x20cause\x20should\x20be\x20addressed\x20at\x20the\x20source.','evidence':{'error_code':d,'count':e,'percentage':e/f},'target':'RECOVERY_RULES[\x27'+d+'\x27]','proposed_improvement_type':'recovery_priority_adjustment'});}return b;}function diagnoseLatencyAnomalies(a){const b=[];for(const c of a['per_tool']){if(c['total_calls']<THRESHOLDS['MIN_SAMPLE_SIZE'])continue;c['p95_duration_ms']>THRESHOLDS['HIGH_LATENCY_MS']&&b['push']({'diagnosis_id':'DIAG-LATENCY-'+Date['now']()+'-'+c['tool_name'],'type':'latency_anomaly','severity':'P3','title':'Tool\x20\x27'+c['tool_name']+'\x27\x20has\x20high\x20p95\x20latency\x20('+c['p95_duration_ms']+'ms)','description':'The\x2095th\x20percentile\x20latency\x20exceeds\x20the\x20threshold.\x20This\x20may\x20indicate\x20performance\x20issues\x20or\x20RPC\x20bottlenecks.','evidence':{'tool_name':c['tool_name'],'p95_duration_ms':c['p95_duration_ms'],'avg_duration_ms':c['avg_duration_ms']},'target':c['tool_name'],'proposed_improvement_type':'investigation'});}return b;}const INDUSTRY_HEALTH_THRESHOLDS={'CRITICAL_HEALTH_SCORE':0x2d,'STRESSED_HEALTH_SCORE':0x41,'HIGH_PENDING_SUGGESTIONS':0x3,'STALE_SIGNAL_THRESHOLD':0x14};export function diagnoseIndustryHealth(a){const b=a??listIndustriesWithSignals(),c=[];for(const d of b){const e=getIndustryEvolutionStatus(d),f=getPendingSuggestions(d),g=getIndustrySignalCount(d);if(e['health']){const h=e['health']['health_score'];if(h<INDUSTRY_HEALTH_THRESHOLDS['CRITICAL_HEALTH_SCORE'])c['push']({'diagnosis_id':'DIAG-IND-'+Date['now']()+'-'+d+'-critical','type':'industry_health_anomaly','severity':'P0','title':'Industry\x20\x27'+d+'\x27\x20health\x20critical\x20('+h+'/100,\x20'+e['health']['level']+')','description':'Industry\x20health\x20score\x20is\x20in\x20the\x20danger\x20zone.\x20Weaknesses:\x20'+(e['health']['weaknesses']['join'](';\x20')||'none')+'.\x20Recommendations:\x20'+(e['health']['recommendations']['join'](';\x20')||'none')+'.','evidence':{'industry':d,'health_score':h,'health_level':e['health']['level'],'weaknesses':e['health']['weaknesses'],'recommendations':e['health']['recommendations'],'signal_count':g},'target':'industry:'+d,'proposed_improvement_type':'industry_update_application'});else h<INDUSTRY_HEALTH_THRESHOLDS['STRESSED_HEALTH_SCORE']&&c['push']({'diagnosis_id':'DIAG-IND-'+Date['now']()+'-'+d+'-stressed','type':'industry_health_anomaly','severity':'P1','title':'Industry\x20\x27'+d+'\x27\x20health\x20stressed\x20('+h+'/100,\x20'+e['health']['level']+')','description':'Industry\x20health\x20score\x20is\x20under\x20pressure.\x20Weaknesses:\x20'+(e['health']['weaknesses']['join'](';\x20')||'none')+'.','evidence':{'industry':d,'health_score':h,'health_level':e['health']['level'],'weaknesses':e['health']['weaknesses'],'signal_count':g},'target':'industry:'+d,'proposed_improvement_type':'industry_update_application'});}if(f['length']>=INDUSTRY_HEALTH_THRESHOLDS['HIGH_PENDING_SUGGESTIONS']){const i=f['filter'](j=>j['priority']==='high');c['push']({'diagnosis_id':'DIAG-IND-'+Date['now']()+'-'+d+'-pending','type':'industry_health_anomaly','severity':i['length']>0x0?'P1':'P2','title':'Industry\x20\x27'+d+'\x27\x20has\x20'+f['length']+'\x20pending\x20suggestions\x20('+i['length']+'\x20high\x20priority)','description':'Industry\x20has\x20'+f['length']+'\x20pending\x20evolution\x20suggestions\x20unprocessed.\x20Review\x20and\x20apply\x20promptly\x20to\x20drive\x20industry\x20evolution.','evidence':{'industry':d,'pending_count':f['length'],'high_priority_count':i['length'],'suggestion_types':f['map'](j=>j['suggestion_type']),'suggestion_summaries':f['map'](j=>({'type':j['suggestion_type'],'field':j['field'],'priority':j['priority']}))},'target':'industry:'+d+':pending_suggestions','proposed_improvement_type':'industry_update_application'});}g>=INDUSTRY_HEALTH_THRESHOLDS['STALE_SIGNAL_THRESHOLD']&&!e['health']&&c['push']({'diagnosis_id':'DIAG-IND-'+Date['now']()+'-'+d+'-stale','type':'industry_health_anomaly','severity':'P2','title':'Industry\x20\x27'+d+'\x27\x20has\x20'+g+'\x20signals\x20but\x20no\x20health\x20report\x20(evolution\x20stale)','description':'Industry\x20has\x20accumulated\x20'+g+'\x20signals\x20but\x20health\x20score\x20has\x20not\x20been\x20recalculated.\x20May\x20need\x20to\x20manually\x20trigger\x20updateIndustryCognition\x20or\x20check\x20scheduling\x20configuration.','evidence':{'industry':d,'signal_count':g,'evolution_ready':e['evolution_ready'],'version':e['version']},'target':'industry:'+d+':cognition','proposed_improvement_type':'industry_update_application'});}return c;}export function diagnose(a){const b=[...diagnoseRuleGaps(a),...diagnoseDescriptionQuality(a),...diagnoseSkillNeeds(a),...diagnoseRecoveryIneffectiveness(a),...diagnoseLatencyAnomalies(a),...diagnoseIndustryHealth()],c={'P0':0x0,'P1':0x1,'P2':0x2,'P3':0x3};b['sort']((g,h)=>c[g['severity']]-c[h['severity']]);const d=b['filter'](g=>g['severity']==='P0')['length'],e=b['filter'](g=>g['severity']==='P1')['length'],f=b['length']+'\x20diagnoses:\x20'+d+'\x20P0,\x20'+e+'\x20P1,\x20'+(b['length']-d-e)+'\x20P2/P3.\x20'+('Overall\x20success\x20rate:\x20'+(a['overall']['success_rate']*0x64)['toFixed'](0x1)+'%.\x20')+('Unknown\x20error\x20rate:\x20'+(a['overall']['unknown_error_rate']*0x64)['toFixed'](0x1)+'%.');return{'report_id':'DIAG-REPORT-'+Date['now'](),'diagnosis_date':new Date()['toISOString'](),'total_diagnoses':b['length'],'diagnoses':b,'summary':f};}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { DiagnosisReport } from "./diagnose.js";
|
|
2
|
-
export type ProposalType = "error_rule_addition" | "intent_rule_addition" | "description_rewrite" | "skill_creation" | "recovery_priority_adjustment" | "investigation" | "industry_update_application";
|
|
3
|
-
export type AutomationLevel = "full" | "semi" | "manual";
|
|
4
|
-
export type ApplyMode = "config_override" | "source_patch";
|
|
5
|
-
export interface ImprovementProposal {
|
|
6
|
-
proposal_id: string;
|
|
7
|
-
source_diagnosis_id: string;
|
|
8
|
-
type: ProposalType;
|
|
9
|
-
priority: string;
|
|
10
|
-
automation: AutomationLevel;
|
|
11
|
-
apply_mode: ApplyMode;
|
|
12
|
-
override_category?: OverrideCategory;
|
|
13
|
-
title: string;
|
|
14
|
-
description: string;
|
|
15
|
-
target: string;
|
|
16
|
-
proposed_change: Record<string, unknown>;
|
|
17
|
-
evidence: Record<string, unknown>;
|
|
18
|
-
review_status: "pending" | "approved" | "rejected" | "applied";
|
|
19
|
-
ab_test_recommended: boolean;
|
|
20
|
-
persisted_at?: string;
|
|
21
|
-
reviewed_at?: string;
|
|
22
|
-
}
|
|
23
|
-
export type OverrideCategory = "risk-thresholds" | "descriptions" | "industry-profiles" | "scenario-defaults" | "recovery-priorities";
|
|
24
|
-
export interface ImprovementReport {
|
|
25
|
-
report_id: string;
|
|
26
|
-
generated_date: string;
|
|
27
|
-
source_diagnosis_report_id: string;
|
|
28
|
-
total_proposals: number;
|
|
29
|
-
proposals: ImprovementProposal[];
|
|
30
|
-
summary: string;
|
|
31
|
-
}
|
|
32
|
-
export declare function generateImprovements(report: DiagnosisReport): ImprovementReport;
|
|
33
|
-
export declare function persistImprovementQueue(proposals: ImprovementProposal[]): number;
|
|
34
|
-
export interface QueueFilter {
|
|
35
|
-
status?: "pending" | "approved" | "rejected" | "applied";
|
|
36
|
-
type?: string;
|
|
37
|
-
priority?: string;
|
|
38
|
-
}
|
|
39
|
-
export declare function loadImprovementQueue(filter?: QueueFilter): ImprovementProposal[];
|
|
40
|
-
export declare function updateProposalReviewStatus(proposalId: string, newStatus: "approved" | "rejected" | "applied"): ImprovementProposal | undefined;
|
|
41
|
-
export declare function applyConfigOverride(proposal: ImprovementProposal): string;
|
|
42
|
-
export declare function produceSourcePatch(proposal: ImprovementProposal): string;
|
|
43
|
-
export interface FlywheelConfigSummary {
|
|
44
|
-
queue_path: string;
|
|
45
|
-
overrides_dir: string;
|
|
46
|
-
patches_dir: string;
|
|
47
|
-
total_proposals: number;
|
|
48
|
-
pending_count: number;
|
|
49
|
-
approved_count: number;
|
|
50
|
-
applied_count: number;
|
|
51
|
-
rejected_count: number;
|
|
52
|
-
override_files: string[];
|
|
53
|
-
recent_proposals: ImprovementProposal[];
|
|
54
|
-
}
|
|
55
|
-
export declare function getFlywheelConfigSummary(): FlywheelConfigSummary;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{getPendingSuggestions}from'../knowledge/flywheel-loop.js';import{readFileSync,writeFileSync,existsSync,mkdirSync,appendFileSync,readdirSync}from'fs';import{join,dirname}from'path';import{getWowMcpDir}from'@wowok/wowok';function proposeErrorRuleAddition(a){const b=a['evidence'],c=b['top_error_messages']||[],d=c['slice'](0x0,0x3)['map'](e=>{const f=e['message']['toLowerCase']();let g=f['replace'](/0x[0-9a-f]+/gi,'0xADDR')['replace'](/\d+/g,'\x5cd+')['replace'](/[^\w\s\\]/g,'\x20')['replace'](/\s+/g,'\x20')['trim']();if(g['length']>0x3c)g=g['slice'](0x0,0x3c);return{'pattern':g,'sample_count':e['count']};});return{'proposal_id':'PROP-RULE-'+Date['now']()+'-'+Math['random']()['toString'](0x24)['slice'](0x2,0x6),'source_diagnosis_id':a['diagnosis_id'],'type':'error_rule_addition','priority':a['severity'],'automation':'semi','apply_mode':'source_patch','title':'Add\x20ERROR_RULES\x20entries\x20for\x20'+a['target'],'description':'Generate\x20new\x20error\x20classification\x20rules\x20to\x20cover\x20patterns\x20currently\x20falling\x20into\x20\x27unknown\x27.\x20AI\x20should\x20draft\x20regex\x20patterns;\x20human\x20reviewer\x20validates\x20accuracy\x20and\x20assigns\x20correct\x20error_code.','target':'ERROR_RULES','proposed_change':{'action':'append','rules':d['map'](e=>({'pattern':e['pattern'],'error_code':'unknown','retryable':![],'recovery_hint':'TODO:\x20assign\x20by\x20reviewer','sample_message':e['sample_count']})),'note':'error_code\x20must\x20be\x20assigned\x20by\x20human\x20reviewer\x20based\x20on\x20semantic\x20analysis'},'evidence':a['evidence'],'review_status':'pending','ab_test_recommended':!![]};}function proposeDescriptionRewrite(a){const b=a['evidence'];return{'proposal_id':'PROP-DESC-'+Date['now']()+'-'+Math['random']()['toString'](0x24)['slice'](0x2,0x6),'source_diagnosis_id':a['diagnosis_id'],'type':'description_rewrite','priority':a['severity'],'automation':'semi','apply_mode':'config_override','override_category':'descriptions','title':'Rewrite\x20description\x20for\x20'+(b['tool_name']||a['target']),'description':'The\x20semantic\x20layer\x20produces\x20no\x20summary\x20for\x20'+((0x1-(b['semantic_hit_rate']||0x0))*0x64)['toFixed'](0x1)+'%\x20of\x20calls\x20to\x20this\x20tool.\x20AI\x20should\x20rewrite\x20the\x20tool\x20description\x20and\x20INTENT_RULES\x20to\x20improve\x20coverage.\x20A/B\x20test\x20before\x20merging.','target':a['target'],'proposed_change':{'action':'rewrite','current_semantic_hit_rate':b['semantic_hit_rate'],'target_semantic_hit_rate':0.8,'rewrite_guidelines':['Follow\x204-part\x20format:\x20Meaning\x20+\x20Constraint\x20+\x20Relation\x20+\x20Example','Add\x20explicit\x20intent\x20signals\x20to\x20INTENT_RULES','Include\x20concrete\x20examples\x20for\x20common\x20operation\x20types']},'evidence':a['evidence'],'review_status':'pending','ab_test_recommended':!![]};}function proposeSkillCreation(a){const b=a['evidence'];return{'proposal_id':'PROP-SKILL-'+Date['now']()+'-'+Math['random']()['toString'](0x24)['slice'](0x2,0x6),'source_diagnosis_id':a['diagnosis_id'],'type':'skill_creation','priority':a['severity'],'automation':'semi','apply_mode':'source_patch','title':'Create\x20new\x20Skill\x20for\x20\x27'+b['operation_type']+'\x27\x20operations','description':'This\x20operation\x20type\x20has\x20a\x20'+(b['success_rate']?(0x1-b['success_rate'])*0x64:0x0)['toFixed'](0x1)+'%\x20failure\x20rate\x20across\x20'+b['total_calls']+'\x20calls.\x20A\x20Skill\x20with\x20R1-R10\x20dialogue\x20scripts,\x20decision\x20trees,\x20and\x20failure\x20playbooks\x20could\x20guide\x20users\x20to\x20success.','target':'wowok-'+b['operation_type']+'-guide','proposed_change':{'action':'create','skill_name':'wowok-'+b['operation_type']+'-guide','skill_structure':{'sections':['R1-R10\x20dialogues','Decision\x20trees','Failure\x20playbooks','Tier\x20layering'],'target_role':'provider','loading':'on-demand'},'top_errors':b['error_distribution']},'evidence':a['evidence'],'review_status':'pending','ab_test_recommended':![]};}function proposeRecoveryAdjustment(a){const b=a['evidence'];return{'proposal_id':'PROP-RECOV-'+Date['now']()+'-'+Math['random']()['toString'](0x24)['slice'](0x2,0x6),'source_diagnosis_id':a['diagnosis_id'],'type':'recovery_priority_adjustment','priority':a['severity'],'automation':'semi','apply_mode':'config_override','override_category':'recovery-priorities','title':'Review\x20recovery\x20strategy\x20for\x20\x27'+b['error_code']+'\x27\x20errors','description':'Error\x20code\x20\x27'+b['error_code']+'\x27\x20accounts\x20for\x20'+b['count']+'\x20failures\x20('+((b['percentage']||0x0)*0x64)['toFixed'](0x1)+'%).\x20The\x20current\x20recovery\x20strategy\x20may\x20need\x20tuning\x20—\x20consider\x20increasing\x20max_attempts,\x20adjusting\x20automation\x20level,\x20or\x20addressing\x20the\x20root\x20cause.','target':'RECOVERY_RULES[\x27'+b['error_code']+'\x27]','proposed_change':{'action':'review_and_adjust','current_strategy':'see\x20RECOVERY_RULES\x20table','suggestions':['Increase\x20max_attempts\x20if\x20failures\x20are\x20transient','Reduce\x20max_attempts\x20if\x20failures\x20are\x20persistent\x20(wastes\x20user\x20time)','Upgrade\x20automation\x20from\x20\x27semi\x27\x20to\x20\x27full\x27\x20if\x20recovery\x20is\x20deterministic','Consider\x20root-cause\x20fix\x20in\x20description/rules\x20to\x20prevent\x20the\x20error']},'evidence':a['evidence'],'review_status':'pending','ab_test_recommended':![]};}function proposeInvestigation(a){return{'proposal_id':'PROP-INV-'+Date['now']()+'-'+Math['random']()['toString'](0x24)['slice'](0x2,0x6),'source_diagnosis_id':a['diagnosis_id'],'type':'investigation','priority':a['severity'],'automation':'manual','apply_mode':'source_patch','title':a['title'],'description':'Manual\x20investigation\x20required.\x20'+a['description'],'target':a['target'],'proposed_change':{'action':'investigate','steps':['Collect\x20additional\x20telemetry\x20around\x20the\x20anomaly','Check\x20if\x20the\x20issue\x20is\x20reproducible','Determine\x20if\x20the\x20root\x20cause\x20is\x20in\x20the\x20SDK,\x20MCP\x20layer,\x20or\x20user\x20behavior']},'evidence':a['evidence'],'review_status':'pending','ab_test_recommended':![]};}function proposeIndustryUpdate(a){const b=a['evidence'],c=b['industry']??a['target']['split'](':')[0x1]??'unknown',d=c!=='unknown'?getPendingSuggestions(c):[],e=d['map'](h=>({'suggestion_type':h['suggestion_type'],'field':h['field'],'suggested_value':h['suggested_value'],'evidence':h['evidence'],'confidence':h['confidence'],'priority':h['priority']})),f=b['health_score']!==undefined&&b['health_score']<0x2d,g=(b['high_priority_count']??0x0)>0x0;return{'proposal_id':'PROP-IND-'+Date['now']()+'-'+Math['random']()['toString'](0x24)['slice'](0x2,0x6),'source_diagnosis_id':a['diagnosis_id'],'type':'industry_update_application','priority':a['severity'],'automation':f?'semi':'manual','apply_mode':'config_override','override_category':'industry-profiles','title':'Apply\x20'+d['length']+'\x20evolution\x20suggestions\x20for\x20industry\x20\x27'+c+'\x27','description':'Industry\x20\x27'+c+'\x27\x20has\x20health\x20anomaly\x20(health\x20score\x20'+(b['health_score']??'N/A')+',\x20level\x20'+(b['health_level']??'N/A')+').\x20'+('Has\x20'+d['length']+'\x20pending\x20evolution\x20suggestions\x20('+(b['high_priority_count']??0x0)+'\x20high\x20priority).\x20')+('Review\x20and\x20apply\x20to\x20drive\x20industry\x20cognition\x20evolution.\x20Weaknesses:\x20'+((b['weaknesses']??[])['join'](';\x20')||'none')+'.'),'target':'industry:'+c,'proposed_change':{'action':'apply_industry_updates','industry':c,'current_health_score':b['health_score'],'current_health_level':b['health_level'],'weaknesses':b['weaknesses']??[],'recommendations':b['recommendations']??[],'pending_suggestion_count':d['length'],'high_priority_count':b['high_priority_count']??0x0,'suggestions':e,'auto_applicable_suggestions':e['filter'](h=>h['confidence']>=0.85&&h['priority']==='high'),'apply_guidance':g?'Prioritize\x20reviewing\x20high-priority\x20suggestions;\x20high-confidence\x20(≥0.85)\x20suggestions\x20can\x20be\x20semi-automatically\x20applied':'No\x20high-priority\x20suggestions,\x20review\x20via\x20normal\x20process'},'evidence':a['evidence'],'review_status':'pending','ab_test_recommended':![]};}export function generateImprovements(a){const b=[];for(const g of a['diagnoses']){let h;switch(g['proposed_improvement_type']){case'rule_addition':h=proposeErrorRuleAddition(g);break;case'description_rewrite':h=proposeDescriptionRewrite(g);break;case'skill_creation':h=proposeSkillCreation(g);break;case'recovery_priority_adjustment':h=proposeRecoveryAdjustment(g);break;case'industry_update_application':h=proposeIndustryUpdate(g);break;default:h=proposeInvestigation(g);}b['push'](h);}const c=b['filter'](i=>i['priority']==='P0')['length'],d=b['filter'](i=>i['automation']==='semi')['length'],e=b['filter'](i=>i['ab_test_recommended'])['length'],f=b['length']+'\x20proposals\x20generated\x20from\x20'+a['total_diagnoses']+'\x20diagnoses.\x20'+(c+'\x20P0,\x20'+d+'\x20semi-automatic,\x20'+e+'\x20recommend\x20A/B\x20testing.\x20')+'All\x20proposals\x20require\x20human\x20review\x20before\x20application.';try{persistImprovementQueue(b);}catch{}return{'report_id':'IMPROVE-REPORT-'+Date['now'](),'generated_date':new Date()['toISOString'](),'source_diagnosis_report_id':a['report_id'],'total_proposals':b['length'],'proposals':b,'summary':f};}function wowokRootDir(){return getWowMcpDir();}function improvementQueuePath(){return join(wowokRootDir(),'improvement-queue.jsonl');}function overridesDir(){return join(wowokRootDir(),'overrides');}function patchesDir(){return join(wowokRootDir(),'patches');}export function persistImprovementQueue(a){if(a['length']===0x0)return 0x0;const b=improvementQueuePath();mkdirSync(dirname(b),{'recursive':!![]});const c=new Date()['toISOString'](),d=a['map'](e=>JSON['stringify']({...e,'persisted_at':c}));return appendFileSync(b,d['join']('\x0a')+'\x0a','utf-8'),a['length'];}export function loadImprovementQueue(a){const b=improvementQueuePath();if(!existsSync(b))return[];const c=readFileSync(b,'utf-8'),d=c['split']('\x0a')['filter'](f=>f['trim']()['length']>0x0),e=[];for(const f of d){try{const g=JSON['parse'](f);if(a?.['status']&&g['review_status']!==a['status'])continue;if(a?.['type']&&g['type']!==a['type'])continue;if(a?.['priority']&&g['priority']!==a['priority'])continue;e['push'](g);}catch{}}return e;}export function updateProposalReviewStatus(a,b){const c=loadImprovementQueue();let d;const e=new Date()['toISOString']();for(const g of c){g['proposal_id']===a&&(g['review_status']=b,g['reviewed_at']=e,d=g);}if(!d)return undefined;const f=improvementQueuePath();if(c['length']===0x0)writeFileSync(f,'','utf-8');else{const h=c['map'](i=>JSON['stringify'](i));writeFileSync(f,h['join']('\x0a')+'\x0a','utf-8');}return d;}export function applyConfigOverride(a){if(a['apply_mode']!=='config_override')throw new Error('Proposal\x20'+a['proposal_id']+'\x20has\x20apply_mode='+a['apply_mode']+',\x20not\x20config_override');if(!a['override_category'])throw new Error('Proposal\x20'+a['proposal_id']+'\x20has\x20no\x20override_category');const b=overridesDir();mkdirSync(b,{'recursive':!![]});const c=join(b,a['override_category']+'.json');let d={};if(existsSync(c))try{d=JSON['parse'](readFileSync(c,'utf-8'));}catch{d={};}const e={...d,...a['proposed_change'],'_last_applied_proposal':a['proposal_id'],'_last_applied_at':new Date()['toISOString']()};return writeFileSync(c,JSON['stringify'](e,null,0x2),'utf-8'),c;}export function produceSourcePatch(a){if(a['apply_mode']!=='source_patch')throw new Error('Proposal\x20'+a['proposal_id']+'\x20has\x20apply_mode='+a['apply_mode']+',\x20not\x20source_patch');const b=patchesDir();mkdirSync(b,{'recursive':!![]});const c=a['proposal_id']+'.md',d=join(b,c),e=['#\x20Source\x20Patch\x20Proposal:\x20'+a['title'],'','-\x20**Proposal\x20ID**:\x20'+a['proposal_id'],'-\x20**Type**:\x20'+a['type'],'-\x20**Priority**:\x20'+a['priority'],'-\x20**Target**:\x20'+a['target'],'-\x20**Generated**:\x20'+new Date()['toISOString'](),'','##\x20Description',a['description'],'','##\x20Proposed\x20Change','```json',JSON['stringify'](a['proposed_change'],null,0x2),'```','','##\x20Evidence','```json',JSON['stringify'](a['evidence'],null,0x2),'```','','##\x20Application','This\x20proposal\x20requires\x20manual\x20review\x20and\x20merge\x20into\x20the\x20MCP\x20source\x20code.','Do\x20NOT\x20auto-apply.\x20After\x20merging,\x20republish\x20the\x20MCP\x20server.','','##\x20Override\x20Whiteline\x20(§4.4)','This\x20proposal\x20type\x20is\x20NOT\x20in\x20the\x20config_override\x20whitelist\x20and\x20must\x20go','through\x20source\x20patch\x20(risk\x20rules,\x20skill\x20structure,\x20schema\x20fields).']['join']('\x0a');return writeFileSync(d,e,'utf-8'),d;}export function getFlywheelConfigSummary(){const a=loadImprovementQueue(),b=[],c=overridesDir();if(existsSync(c))try{for(const d of readdirSync(c)){if(d['endsWith']('.json'))b['push'](d);}}catch{}return{'queue_path':improvementQueuePath(),'overrides_dir':c,'patches_dir':patchesDir(),'total_proposals':a['length'],'pending_count':a['filter'](e=>e['review_status']==='pending')['length'],'approved_count':a['filter'](e=>e['review_status']==='approved')['length'],'applied_count':a['filter'](e=>e['review_status']==='applied')['length'],'rejected_count':a['filter'](e=>e['review_status']==='rejected')['length'],'override_files':b,'recent_proposals':a['slice'](-0x5)};}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export*from'./aggregate.js';export*from'./diagnose.js';export*from'./improve.js';export*from'./pipeline.js';
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { TelemetryEvent } from "../telemetry/index.js";
|
|
2
|
-
import { type AggregatedStats } from "./aggregate.js";
|
|
3
|
-
import { type DiagnosisReport } from "./diagnose.js";
|
|
4
|
-
import { type ImprovementReport } from "./improve.js";
|
|
5
|
-
export interface LoopEngineeringReport {
|
|
6
|
-
pipeline_run_id: string;
|
|
7
|
-
run_date: string;
|
|
8
|
-
stage: "aggregate" | "diagnose" | "improve" | "complete";
|
|
9
|
-
aggregated_stats: AggregatedStats | null;
|
|
10
|
-
diagnosis_report: DiagnosisReport | null;
|
|
11
|
-
improvement_report: ImprovementReport | null;
|
|
12
|
-
error?: string;
|
|
13
|
-
}
|
|
14
|
-
export declare function runLoopEngineeringPipeline(): Promise<LoopEngineeringReport>;
|
|
15
|
-
export declare function runDiagnoseFromStats(stats: AggregatedStats): DiagnosisReport;
|
|
16
|
-
export declare function runImproveFromDiagnoses(report: DiagnosisReport): ImprovementReport;
|
|
17
|
-
export declare function runAggregateFromEvents(events: TelemetryEvent[]): AggregatedStats;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{getStorage}from'../telemetry/storage.js';import{aggregate}from'./aggregate.js';import{diagnose}from'./diagnose.js';import{generateImprovements}from'./improve.js';async function loadTelemetryEvents(){const a=getStorage(),b=await a['query']({});return b;}async function runAggregateStage(){const a=await loadTelemetryEvents();return aggregate(a);}function runDiagnoseStage(a){return diagnose(a);}function runImproveStage(a){return generateImprovements(a);}export async function runLoopEngineeringPipeline(){const a='LE-'+Date['now']()+'-'+Math['random']()['toString'](0x24)['slice'](0x2,0x8),b=new Date()['toISOString']();try{const c=await runAggregateStage(),d=runDiagnoseStage(c),e=runImproveStage(d);return{'pipeline_run_id':a,'run_date':b,'stage':'complete','aggregated_stats':c,'diagnosis_report':d,'improvement_report':e};}catch(f){return{'pipeline_run_id':a,'run_date':b,'stage':'complete','aggregated_stats':null,'diagnosis_report':null,'improvement_report':null,'error':f instanceof Error?f['message']:String(f)};}}export function runDiagnoseFromStats(a){return runDiagnoseStage(a);}export function runImproveFromDiagnoses(a){return runImproveStage(a);}export function runAggregateFromEvents(a){return aggregate(a);}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare function shortTypeName(objectType: string | null | undefined): string;
|
|
2
|
-
export declare function normalizeObjectType(objectType: string | null | undefined): string;
|
|
3
|
-
export declare function isObjectOfType(objectType: string | null | undefined, expectedShortName: string): boolean;
|
|
4
|
-
export declare function groupObjectsByType<T extends {
|
|
5
|
-
objectType: string | null;
|
|
6
|
-
}>(objects: T[]): Map<string, T[]>;
|
|
7
|
-
export declare function findObjectByType<T extends {
|
|
8
|
-
objectType: string | null;
|
|
9
|
-
}>(objects: T[], expectedShortName: string): T | undefined;
|
|
10
|
-
export declare function countObjectsByType<T extends {
|
|
11
|
-
objectType: string | null;
|
|
12
|
-
}>(objects: T[], expectedShortName: string): number;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function shortTypeName(a){if(!a)return'unknown';const b=a['replace'](/<.*>/,'')['trim'](),c=b['split']('::'),d=c[c['length']-0x1]||'unknown';if(d['length']>0x0&&d===d['toLowerCase']())return d['charAt'](0x0)['toUpperCase']()+d['slice'](0x1);return d;}export function normalizeObjectType(a){return shortTypeName(a)['toLowerCase']();}export function isObjectOfType(a,b){const c=normalizeObjectType(a),d=b['toLowerCase']();return c===d;}export function groupObjectsByType(a){const b=new Map();for(const c of a){const d=shortTypeName(c['objectType']);if(!b['has'](d))b['set'](d,[]);b['get'](d)['push'](c);}return b;}export function findObjectByType(a,b){return a['find'](c=>isObjectOfType(c['objectType'],b));}export function countObjectsByType(a,b){return a['filter'](c=>isObjectOfType(c['objectType'],b))['length'];}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { CallOutput } from "../schema/call/base.js";
|
|
2
|
-
export interface TelemetryEvent {
|
|
3
|
-
timestamp: string;
|
|
4
|
-
tool_name: string;
|
|
5
|
-
operation_type: string;
|
|
6
|
-
intent?: string;
|
|
7
|
-
status?: "success" | "partial" | "failed" | "pending_input";
|
|
8
|
-
error_code?: string;
|
|
9
|
-
duration_ms: number;
|
|
10
|
-
semantic_hit: boolean;
|
|
11
|
-
error_message?: string;
|
|
12
|
-
}
|
|
13
|
-
export declare function setTelemetryEnabled(enabled: boolean): void;
|
|
14
|
-
export declare function isTelemetryEnabled(): boolean;
|
|
15
|
-
export declare function captureTelemetry(toolName: string, structuredContent: CallOutput | undefined, durationMs: number, operationTypeHint?: string): Promise<void>;
|
|
16
|
-
export declare function captureTelemetryError(toolName: string, error: any, durationMs: number, operationTypeHint?: string): Promise<void>;
|
|
17
|
-
export declare function withTelemetry<TArgs, TOutput extends {
|
|
18
|
-
structuredContent?: unknown;
|
|
19
|
-
}>(toolName: string, handler: (args: TArgs) => Promise<TOutput>): (args: TArgs) => Promise<TOutput>;
|
package/dist/telemetry/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{getStorage}from'./storage.js';import{redactObject}from'./redact.js';let _enabled=!![];export function setTelemetryEnabled(a){_enabled=a;}export function isTelemetryEnabled(){return _enabled;}function extractFromOutput(a,b,c){if(!a)return{'tool_name':b,'semantic_hit':![]};const d=a['semantic'],e=a['result'],f={'tool_name':b,'semantic_hit':!!d};d&&(f['intent']=d['intent'],f['status']=d['status']);if(e?.['type']==='error'){f['status']=f['status']||'failed',f['error_code']=e['error_code'];if(e['error']){const g=String(e['error'])['slice'](0x0,0x1f4);f['error_message']=redactObject(g);}}if(c)f['operation_type']=c;else d?.['intent']&&(f['operation_type']='unknown');return f;}export async function captureTelemetry(a,b,c,d){if(!_enabled)return;try{const e=extractFromOutput(b,a,d),f={'timestamp':new Date()['toISOString'](),'tool_name':e['tool_name']||a,'operation_type':e['operation_type']||'unknown','intent':e['intent'],'status':e['status'],'error_code':e['error_code'],'duration_ms':c,'semantic_hit':e['semantic_hit']??![],'error_message':e['error_message']};await getStorage()['append'](f);}catch{}}export async function captureTelemetryError(a,b,c,d){if(!_enabled)return;try{const e=String(b?.['message']??b)['slice'](0x0,0x1f4),f={'timestamp':new Date()['toISOString'](),'tool_name':a,'operation_type':d||'unknown','status':'failed','duration_ms':c,'semantic_hit':![],'error_message':redactObject(e)};await getStorage()['append'](f);}catch{}}export function withTelemetry(a,b){return async c=>{const d=Date['now']();let e;try{return e=await b(c),e;}catch(f){await captureTelemetryError(a,f,Date['now']()-d,extractOperationType(c));throw f;}finally{e&&await captureTelemetry(a,e?.['structuredContent'],Date['now']()-d,extractOperationType(c));}};}function extractOperationType(a){if(!a||typeof a!=='object')return undefined;if(typeof a['operation_type']==='string'){if(a['operation_type']['startsWith']('cross_chain')||a['operation_type']['startsWith']('claim')||a['operation_type']['startsWith']('withdraw')||a['operation_type']['startsWith']('query_'))return'bridge_'+a['operation_type'];return a['operation_type'];}if(a['data']?.['operation_type'])return a['data']['operation_type'];return undefined;}
|
package/dist/telemetry/redact.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createHash}from'crypto';const ADDRESS_PATTERN=/^0x[0-9a-fA-F]{40,}$/;export function redactAddress(a){if(typeof a!=='string')return a;if(!ADDRESS_PATTERN['test'](a))return a;const b=createHash('sha256')['update'](a['toLowerCase']())['digest']('hex');return'0x'+b['slice'](0x0,0x10);}export function redactObject(a){if(typeof a==='string')return redactAddress(a);if(Array['isArray'](a))return a['map'](redactObject);if(a&&typeof a==='object'&&a['constructor']===Object){const b={};for(const c of Object['keys'](a))b[c]=redactObject(a[c]);return b;}return a;}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export interface TelemetryStorage {
|
|
2
|
-
append(event: Record<string, unknown>): Promise<void>;
|
|
3
|
-
query(filter: Partial<Record<string, unknown>>): Promise<Record<string, unknown>[]>;
|
|
4
|
-
rotate(): Promise<void>;
|
|
5
|
-
}
|
|
6
|
-
export declare function getStorage(): TelemetryStorage;
|
|
7
|
-
export declare function setStorage(storage: TelemetryStorage): void;
|
|
8
|
-
export declare function getTelemetryFilePath(): string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{mkdir,appendFile,stat,rename}from'fs/promises';import{dirname,join}from'path';import{getWowMcpDir}from'@wowok/wowok';const MAX_SIZE_BYTES=0xa*0x400*0x400,DATA_DIR=join(getWowMcpDir(),'data'),TELEMETRY_FILE=join(DATA_DIR,'telemetry.jsonl'),ROTATED_FILE=join(DATA_DIR,'telemetry.jsonl.1');class JsonlStorage{['filePath'];['rotatedPath'];['writeQueue']=Promise['resolve']();constructor(a=TELEMETRY_FILE,b=ROTATED_FILE){this['filePath']=a,this['rotatedPath']=b;}async['append'](a){return this['writeQueue']=this['writeQueue']['then'](async()=>{try{await mkdir(dirname(this['filePath']),{'recursive':!![]});const b=JSON['stringify'](a)+'\x0a';await appendFile(this['filePath'],b,'utf8'),await this['maybeRotate']();}catch{}}),this['writeQueue'];}async['query'](a){try{const {readFile:b}=await import('fs/promises'),c=await b(this['filePath'],'utf8'),d=c['split']('\x0a')['filter'](f=>f['trim']()),e=d['map'](f=>{try{return JSON['parse'](f);}catch{return null;}})['filter'](f=>f!==null);return e['filter'](f=>{return Object['entries'](a)['every'](([g,h])=>f[g]===h);});}catch{return[];}}async['rotate'](){try{await rename(this['filePath'],this['rotatedPath'])['catch'](()=>{});}catch{}}async['maybeRotate'](){try{const a=await stat(this['filePath']);a['size']>=MAX_SIZE_BYTES&&await this['rotate']();}catch{}}}let _storage=null;export function getStorage(){return!_storage&&(_storage=new JsonlStorage()),_storage;}export function setStorage(a){_storage=a;}export function getTelemetryFilePath(){return TELEMETRY_FILE;}
|