@wowok/agent-mcp 3.2.0 → 3.2.2
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/communication/wts-attestation.d.ts +34 -0
- package/dist/communication/wts-attestation.js +1 -0
- package/dist/config/exposure.d.ts +8 -8
- package/dist/config/judgment.d.ts +45 -20
- package/dist/config/rule-engine.d.ts +30 -20
- package/dist/config/rule-engine.js +1 -1
- package/dist/evaluation/builtins/graph-service.spec.js +1 -1
- package/dist/evaluation/engine.js +1 -1
- package/dist/experience/realtime-feedback.js +1 -1
- package/dist/extensions/industry-pack.js +1 -1
- package/dist/graph/onchain/expand.js +1 -1
- package/dist/graph/onchain/exposure.js +1 -1
- package/dist/graph/onchain/facts.js +1 -1
- package/dist/graph/onchain/sdk-batch.d.ts +1 -0
- package/dist/graph/onchain/sdk-batch.js +1 -1
- package/dist/graph/onchain/sdk-dataplane.d.ts +1 -0
- package/dist/graph/onchain/sdk-dataplane.js +1 -1
- package/dist/knowledge/allocation-risk.d.ts +2 -1
- package/dist/knowledge/allocation-risk.js +1 -1
- package/dist/knowledge/allocation-templates.d.ts +1 -1
- package/dist/knowledge/allocation-templates.js +1 -1
- package/dist/knowledge/arbitration-ledger.js +1 -1
- package/dist/knowledge/audit-rules.d.ts +1 -1
- package/dist/knowledge/audit-rules.js +1 -1
- package/dist/knowledge/baselines/rules/allocation.json +31 -1
- package/dist/knowledge/builtin-templates.d.ts +3 -1
- package/dist/knowledge/builtin-templates.js +1 -1
- package/dist/knowledge/discount-threshold.d.ts +15 -0
- package/dist/knowledge/discount-threshold.js +1 -0
- package/dist/knowledge/entity-recipient-guard.d.ts +21 -0
- package/dist/knowledge/entity-recipient-guard.js +1 -0
- package/dist/knowledge/getting-started.js +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-lint.js +1 -1
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/guard-translation.js +1 -1
- package/dist/knowledge/index.d.ts +2 -2
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-generalizer.d.ts +38 -1
- package/dist/knowledge/industry-generalizer.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/industry-strategy.js +1 -1
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/machine-topology.d.ts +34 -0
- package/dist/knowledge/machine-topology.js +1 -1
- package/dist/knowledge/onchain-constants.d.ts +2 -2
- package/dist/knowledge/onchain-constants.js +1 -1
- package/dist/knowledge/scenario-modes.d.ts +11 -0
- package/dist/knowledge/scenario-modes.js +1 -1
- package/dist/knowledge/strategy-manuals.d.ts +1 -1
- package/dist/knowledge/strategy-manuals.js +1 -1
- package/dist/knowledge/template-loader.d.ts +41 -0
- package/dist/knowledge/template-loader.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/template-scanner.js +1 -1
- package/dist/knowledge/tool-constraints.js +1 -1
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/knowledge/workflow-guidance.d.ts +4 -0
- package/dist/knowledge/workflow-guidance.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/participation/arbitrator-interest.js +1 -1
- package/dist/participation/customer-interest.js +1 -1
- package/dist/participation/merchant-interest.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/index.d.ts +1 -0
- package/dist/playbooks/service-build/intent-analyzer.d.ts +1 -0
- package/dist/playbooks/service-build/intent-analyzer.js +1 -1
- package/dist/playbooks/service-build/machine-nodes.d.ts +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.js +1 -1
- package/dist/playbooks/service-build/mode-actions.d.ts +12 -1
- package/dist/playbooks/service-build/mode-actions.js +1 -1
- package/dist/playbooks/service-build/object-panorama.d.ts +27 -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/pipeline-actions.d.ts +4 -0
- package/dist/playbooks/service-build/pipeline-actions.js +1 -1
- package/dist/playbooks/service-build/relationship-profile.js +1 -1
- package/dist/playbooks/service-build/reverse-mapping-refund-p0-5.spec.d.ts +1 -0
- package/dist/playbooks/service-build/reverse-mapping-refund-p0-5.spec.js +1 -0
- package/dist/playbooks/service-build/reverse-mapping.js +1 -1
- package/dist/playbooks/service-build/semantic-graph.d.ts +1 -0
- package/dist/playbooks/service-build/semantic-graph.js +1 -1
- package/dist/playbooks/service-build/service-panorama.js +1 -1
- package/dist/playbooks/service-build/service-quote.js +1 -1
- package/dist/review/index.js +1 -1
- package/dist/role/profiles.js +1 -1
- package/dist/role/types.d.ts +2 -0
- package/dist/role/types.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/call/allocation.d.ts +7 -7
- package/dist/schema/call/arbitration.d.ts +1 -1
- package/dist/schema/call/arbitration.js +1 -1
- package/dist/schema/call/base.d.ts +5 -5
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +5 -9
- package/dist/schema/call/bridge.js +1 -1
- package/dist/schema/call/contact.d.ts +1 -1
- package/dist/schema/call/demand.d.ts +1 -1
- package/dist/schema/call/guard.d.ts +11 -11
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/machine.d.ts +3 -2
- package/dist/schema/call/machine.js +1 -1
- package/dist/schema/call/order.d.ts +1 -1
- package/dist/schema/call/payment.d.ts +1 -1
- package/dist/schema/call/permission.d.ts +1 -1
- package/dist/schema/call/personal.d.ts +1 -1
- package/dist/schema/call/progress.d.ts +1 -1
- package/dist/schema/call/proof.d.ts +2 -2
- package/dist/schema/call/repository.d.ts +1 -1
- package/dist/schema/call/reward.d.ts +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +5 -5
- package/dist/schema/call/service.js +1 -1
- package/dist/schema/call/treasury.d.ts +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/evaluation/index.d.ts +6 -2
- package/dist/schema/evaluation/index.js +1 -1
- package/dist/schema/goal/index.d.ts +8 -8
- package/dist/schema/goal/planning.d.ts +22 -15
- package/dist/schema/goal/planning.js +1 -1
- package/dist/schema/industry-pack/index.d.ts +39 -0
- package/dist/schema/industry-pack/index.js +1 -1
- package/dist/schema/industry-pack/modes.d.ts +15 -0
- package/dist/schema/industry-pack/modes.js +1 -1
- package/dist/schema/intent-radar/index.d.ts +3 -0
- package/dist/schema/intent-radar/index.js +1 -1
- package/dist/schema/local/index.d.ts +577 -18
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/messenger/index.d.ts +160 -20
- package/dist/schema/messenger/index.js +1 -1
- package/dist/schema/operations.d.ts +32 -28
- package/dist/schema/operations.js +1 -1
- package/dist/schema/persona/index.d.ts +818 -708
- package/dist/schema/persona/index.js +1 -1
- package/dist/schema/query/bi.d.ts +22 -6
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.d.ts +32 -32
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-query/index.d.ts +3 -3
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/utils/node-parser.js +1 -1
- package/dist/schema/watch/index.d.ts +2 -2
- package/dist/schema/workflow/index.d.ts +2 -2
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +6 -2
- package/dist/schemas/account_operation.schema.json +1 -1
- package/dist/schemas/bridge_operation.schema.json +2 -10
- package/dist/schemas/evaluation_operation.output.json +2 -0
- package/dist/schemas/evaluation_operation.schema.json +2 -0
- package/dist/schemas/index.json +7 -1
- package/dist/schemas/industry_pack_operation.output.json +196 -4
- package/dist/schemas/industry_pack_operation.schema.json +3 -1
- package/dist/schemas/intent_radar.output.json +2 -0
- package/dist/schemas/intent_radar.schema.json +1 -0
- package/dist/schemas/local_cache_operation.output.json +1536 -0
- package/dist/schemas/local_cache_operation.schema.json +101 -0
- package/dist/schemas/local_mark_operation.output.json +51 -36
- package/dist/schemas/local_mark_operation.schema.json +1 -0
- package/dist/schemas/messenger_operation.output.json +42 -4
- package/dist/schemas/messenger_operation.schema.json +358 -35
- package/dist/schemas/onchain_operations.schema.json +14 -14
- package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
- package/dist/schemas/onchain_operations_arbitration.schema.json +3 -3
- package/dist/schemas/onchain_operations_machine.schema.json +2 -2
- package/dist/schemas/onchain_operations_payment.schema.json +1 -1
- package/dist/schemas/onchain_operations_reward.schema.json +1 -1
- package/dist/schemas/onchain_operations_service.schema.json +5 -5
- package/dist/schemas/onchain_operations_treasury.schema.json +1 -1
- package/dist/schemas/onchain_table_data.output.json +16 -1
- package/dist/schemas/persona_operation.output.json +266 -0
- package/dist/schemas/persona_operation.schema.json +42 -0
- package/dist/schemas/query_toolkit.output.json +12 -5
- package/dist/schemas/query_toolkit.schema.json +18 -3
- package/dist/tools/handlers/benchmark-migration.d.ts +17 -0
- package/dist/tools/handlers/benchmark-migration.js +1 -1
- package/dist/tools/handlers/bridge.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/industry-pack.js +1 -1
- package/dist/tools/handlers/local.d.ts +1 -0
- package/dist/tools/handlers/local.js +1 -1
- package/dist/tools/handlers/messenger.d.ts +9 -2
- package/dist/tools/handlers/messenger.js +1 -1
- package/dist/tools/handlers/name-resolution.d.ts +4 -0
- package/dist/tools/handlers/name-resolution.js +1 -0
- package/dist/tools/handlers/name-resolution.spec.d.ts +1 -0
- package/dist/tools/handlers/name-resolution.spec.js +1 -0
- package/dist/tools/handlers/onchain-name-registration.d.ts +37 -0
- package/dist/tools/handlers/onchain-name-registration.js +1 -0
- package/dist/tools/handlers/onchain-name-registration.spec.d.ts +1 -0
- package/dist/tools/handlers/onchain-name-registration.spec.js +1 -0
- package/dist/tools/handlers/onchain.d.ts +1 -0
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/query.d.ts +1 -0
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/registry/business.js +1 -1
- package/dist/tools/registry/local.js +1 -1
- package/dist/tools/sanitize-description-roundtrip.spec.d.ts +1 -0
- package/dist/tools/sanitize-description-roundtrip.spec.js +1 -0
- package/dist/tools/sanitize-output.d.ts +1 -0
- package/dist/tools/sanitize-output.js +1 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type AttestStatus = "verified" | "invalid_signature" | "unsigned" | "no_public_key";
|
|
2
|
+
export interface MessageAttestation {
|
|
3
|
+
leaf_index?: number;
|
|
4
|
+
status: AttestStatus;
|
|
5
|
+
server_public_key?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface WtsAttestation {
|
|
8
|
+
total_messages: number;
|
|
9
|
+
attested_count: number;
|
|
10
|
+
unattested_count: number;
|
|
11
|
+
fully_attested: boolean;
|
|
12
|
+
messages: MessageAttestation[];
|
|
13
|
+
server_public_keys: string[];
|
|
14
|
+
packet_signed: boolean;
|
|
15
|
+
verdict: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function attestWtsDocument(doc: unknown): WtsAttestation | undefined;
|
|
18
|
+
export declare function attestWtsFile(wtsFilePath: string): Promise<WtsAttestation | undefined>;
|
|
19
|
+
export interface ProofAnchor {
|
|
20
|
+
proof?: string | null;
|
|
21
|
+
server_pubkey?: string | null;
|
|
22
|
+
time?: number | string | null;
|
|
23
|
+
signer?: string | null;
|
|
24
|
+
address?: string | null;
|
|
25
|
+
}
|
|
26
|
+
export interface AnchorCrossCheck {
|
|
27
|
+
root_matched: boolean;
|
|
28
|
+
matched_leaf_indices: number[];
|
|
29
|
+
key_matched: boolean;
|
|
30
|
+
anchored_before_packet: boolean | null;
|
|
31
|
+
verdict: string;
|
|
32
|
+
}
|
|
33
|
+
export declare function checkWtsProofAnchor(doc: unknown, anchor: ProofAnchor): AnchorCrossCheck;
|
|
34
|
+
export declare function readWtsDocument(wtsFilePath: string): Promise<unknown | undefined>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readFile}from'node:fs/promises';import{verifyFalcon512Signature}from'@wowok/wowok/w/messenger/crypto.js';function resolveServerPublicKey(a,b){const c=Array['isArray'](b?.['serverPublicKeys'])?b['serverPublicKeys']:undefined,d=a?.['serverPublicKeyIndex'];if(c&&typeof d==='number'&&d>=0x0&&d<c['length']){const f=c[d],g=typeof f==='string'?f:f?.['publicKey'];if(typeof g==='string'&&g)return g;}const e=a?.['serverPublicKey'];return typeof e==='string'&&e?e:null;}export function attestWtsDocument(a){const b=a,c=b?.['meta'],d=Array['isArray'](b?.['payload']?.['messages'])?b['payload']['messages']:undefined;if(!c||!d)return undefined;const e=[];let f=0x0;for(const m of d){const n=m??{},o=typeof n['leafIndex']==='number'?n['leafIndex']:undefined,p=resolveServerPublicKey(n,c),q=n['serverSignature'];let r;if(typeof q!=='string'||!q)r='unsigned';else{if(!p)r='no_public_key';else{const s=n['prevRoot']+':'+n['merkleRoot']+':'+n['timestamp']+':'+p;r=verifyFalcon512Signature(p,s,q)?'verified':'invalid_signature';}}if(r==='verified')f++;e['push']({'leaf_index':o,'status':r,'server_public_key':p??undefined});}const g=(Array['isArray'](c['serverPublicKeys'])?c['serverPublicKeys']:[])['map'](t=>typeof t==='string'?t:t?.['publicKey'])['filter'](t=>typeof t==='string'&&!!t),h=f===d['length']&&d['length']>0x0,i=e['filter'](t=>t['status']==='invalid_signature')['length'],j=d['length']-f,k=e['filter'](t=>t['status']==='no_public_key')['length'];let l;if(d['length']===0x0)l='WTS\x20packet\x20contains\x20no\x20messages\x20—\x20nothing\x20to\x20attest.';else{if(i>0x0)l='ATTENTION:\x20'+i+'\x20of\x20'+d['length']+'\x20message(s)\x20carry\x20a\x20server\x20signature\x20that\x20does\x20NOT\x20verify\x20—\x20this\x20packet\x20has\x20been\x20altered\x20or\x20signed\x20by\x20a\x20key\x20that\x20is\x20not\x20the\x20messenger\x20server\x27s.\x20Do\x20NOT\x20present\x20it\x20as\x20evidence.';else h?l='Server-attested:\x20all\x20'+d['length']+'\x20message(s)\x20carry\x20a\x20Falcon512\x20signature\x20that\x20verifies\x20against\x20the\x20packet\x27s\x20own\x20server\x20public\x20key.\x20'+'CAVEAT:\x20that\x20key\x20is\x20declared\x20inside\x20this\x20packet\x20(meta.serverPublicKeys)\x20—\x20the\x20signatures\x20prove\x20the\x20packet\x20is\x20SELF-CONSISTENT\x20under\x20a\x20key\x20its\x20'+'author\x20chose,\x20not\x20that\x20this\x20is\x20the\x20messenger\x20service\x27s\x20key.\x20verify_wts\x20closes\x20this\x20gap\x20by\x20cross-checking\x20every\x20key\x20against\x20the\x20server\x27s\x20OFFICIAL\x20'+'key\x20history\x20(rotation-aware:\x20any\x20historical\x20official\x20key\x20whose\x20window\x20covers\x20the\x20message\x27s\x20server\x20timestamp\x20verifies);\x20serverKeysOfficial:true\x20'+'in\x20its\x20result\x20is\x20what\x20makes\x20the\x20packet\x20evidence-grade.\x20This\x20MCP\x20recount\x20is\x20file-only\x20and\x20stays\x20independent\x20of\x20that\x20check.\x20Anchor\x20it\x20(an\x20on-chain\x20'+'Proof\x20of\x20the\x20last\x20Merkle\x20root)\x20before\x20treating\x20it\x20as\x20third-party-proof\x20evidence.':l='NOT\x20server-attested:\x20'+j+'\x20of\x20'+d['length']+'\x20message(s)\x20carry\x20no\x20verifying\x20server\x20signature'+(k>0x0?'\x20('+k+'\x20of\x20them\x20reference\x20a\x20server\x20key\x20the\x20packet\x20never\x20supplies,\x20so\x20their\x20signature\x20cannot\x20be\x20checked\x20at\x20all)':'')+'.\x20'+'verify_wts\x20REJECTS\x20such\x20packets\x20(valid:false)\x20—\x20its\x20digest\x20covers\x20the\x20payload\x20with\x20no\x20key,\x20so\x20anyone\x20who\x20edits\x20the\x20content\x20can\x20recompute\x20it,\x20'+'and\x20nothing\x20in\x20the\x20packet\x20can\x20substitute\x20for\x20the\x20server\x27s\x20own\x20signature.\x20Treat\x20these\x20messages\x20as\x20the\x20file\x20author\x27s\x20ASSERTION,\x20not\x20as\x20evidence\x20issued\x20by\x20the\x20'+'messenger\x20server,\x20and\x20do\x20not\x20present\x20them\x20as\x20proof\x20to\x20a\x20counterparty\x20or\x20an\x20arbitrator.';}return{'total_messages':d['length'],'attested_count':f,'unattested_count':d['length']-f,'fully_attested':h,'messages':e,'server_public_keys':g,'packet_signed':!!c['signature'],'verdict':l};}export async function attestWtsFile(a){if(typeof a!=='string'||!a)return undefined;try{if(/^https?:\/\//i['test'](a))return undefined;const b=await readFile(a,'utf8');return attestWtsDocument(JSON['parse'](b));}catch{return undefined;}}export function checkWtsProofAnchor(a,b){const c=a,d=Array['isArray'](c?.['payload']?.['messages'])?c['payload']['messages']:[],e=(b['proof']??'')['toLowerCase'](),f=d['filter'](o=>typeof o?.['merkleRoot']==='string'&&o['merkleRoot']['toLowerCase']()===e&&e!=='')['map'](o=>typeof o['leafIndex']==='number'?o['leafIndex']:-0x1),g=[...(Array['isArray'](c?.['meta']?.['serverPublicKeys'])?c['meta']['serverPublicKeys']:[])['map'](o=>typeof o==='string'?o:o?.['publicKey']),...d['map'](o=>o?.['serverPublicKey'])]['filter'](o=>typeof o==='string'&&!!o)['map'](o=>o['toLowerCase']()),h=(b['server_pubkey']??'')['toLowerCase'](),i=!!h&&g['includes'](h),j=typeof b['time']==='string'?Number(b['time']):b['time'],k=c?.['meta']?.['created'],l=typeof k==='number'?k:Date['parse'](String(k??'')),m=Number['isFinite'](j)&&Number['isFinite'](l)?j<=l:null;let n;if(!e)n='Proof\x20carries\x20no\x20root\x20—\x20nothing\x20to\x20anchor.';else f['length']===0x0?n='Proof\x20root\x20'+e['slice'](0x0,0x12)+'…\x20does\x20NOT\x20appear\x20among\x20this\x20packet\x27s\x20'+d['length']+'\x20message\x20root(s)\x20—\x20the\x20packet\x20does\x20not\x20contain\x20what\x20this\x20Proof\x20froze.':n='ANCHORED:\x20the\x20packet\x27s\x20leaf/leaves\x20['+f['join'](',\x20')+']\x20match\x20the\x20root\x20frozen\x20on\x20chain\x20by\x20Proof\x20'+(b['address']??'?')+'\x20(signer\x20'+(b['signer']??'?')+',\x20'+(m===null?'time\x20not\x20comparable':m?'before\x20the\x20packet\x20was\x20written':'AFTER\x20the\x20packet\x27s\x20own\x20creation\x20stamp\x20—\x20the\x20anchor\x20postdates\x20the\x20content\x20it\x20attests')+').\x20'+(i?'The\x20Proof\x27s\x20server\x20key\x20is\x20the\x20same\x20key\x20the\x20packet\x20attests\x20under,\x20so\x20this\x20segment\x20cannot\x20have\x20been\x20re-fabricated\x20after\x20anchoring.':'WARNING:\x20the\x20Proof\x27s\x20server\x20key\x20differs\x20from\x20the\x20key(s)\x20the\x20packet\x20declares\x20—\x20the\x20anchor\x20and\x20the\x20packet\x20do\x20not\x20share\x20an\x20issuer.');return{'root_matched':f['length']>0x0,'matched_leaf_indices':f,'key_matched':i,'anchored_before_packet':m,'verdict':n};}export async function readWtsDocument(a){if(typeof a!=='string'||!a)return undefined;if(/^https?:\/\//i['test'](a))return undefined;try{return JSON['parse'](await readFile(a,'utf8'));}catch{return undefined;}}
|
|
@@ -13,9 +13,9 @@ export declare const ExposurePartyDataSchema: z.ZodObject<{
|
|
|
13
13
|
supplier: "supplier";
|
|
14
14
|
collaborator: "collaborator";
|
|
15
15
|
arbitrator: "arbitrator";
|
|
16
|
-
buyer: "buyer";
|
|
17
|
-
system: "system";
|
|
18
16
|
neutral: "neutral";
|
|
17
|
+
system: "system";
|
|
18
|
+
buyer: "buyer";
|
|
19
19
|
}>;
|
|
20
20
|
basis: z.ZodString;
|
|
21
21
|
}, z.core.$strict>;
|
|
@@ -25,9 +25,9 @@ export declare const GainPathDataSchema: z.ZodObject<{
|
|
|
25
25
|
supplier: "supplier";
|
|
26
26
|
collaborator: "collaborator";
|
|
27
27
|
arbitrator: "arbitrator";
|
|
28
|
-
buyer: "buyer";
|
|
29
|
-
system: "system";
|
|
30
28
|
neutral: "neutral";
|
|
29
|
+
system: "system";
|
|
30
|
+
buyer: "buyer";
|
|
31
31
|
}>;
|
|
32
32
|
path: z.ZodString;
|
|
33
33
|
viability: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -45,9 +45,9 @@ export declare const ExposureFragmentSchema: z.ZodObject<{
|
|
|
45
45
|
supplier: "supplier";
|
|
46
46
|
collaborator: "collaborator";
|
|
47
47
|
arbitrator: "arbitrator";
|
|
48
|
-
buyer: "buyer";
|
|
49
|
-
system: "system";
|
|
50
48
|
neutral: "neutral";
|
|
49
|
+
system: "system";
|
|
50
|
+
buyer: "buyer";
|
|
51
51
|
}>;
|
|
52
52
|
basis: z.ZodString;
|
|
53
53
|
}, z.core.$strict>>;
|
|
@@ -57,9 +57,9 @@ export declare const ExposureFragmentSchema: z.ZodObject<{
|
|
|
57
57
|
supplier: "supplier";
|
|
58
58
|
collaborator: "collaborator";
|
|
59
59
|
arbitrator: "arbitrator";
|
|
60
|
-
buyer: "buyer";
|
|
61
|
-
system: "system";
|
|
62
60
|
neutral: "neutral";
|
|
61
|
+
system: "system";
|
|
62
|
+
buyer: "buyer";
|
|
63
63
|
}>;
|
|
64
64
|
path: z.ZodString;
|
|
65
65
|
viability: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -394,9 +394,9 @@ export declare const RulesSectionSchema: z.ZodObject<{
|
|
|
394
394
|
supplier: "supplier";
|
|
395
395
|
collaborator: "collaborator";
|
|
396
396
|
arbitrator: "arbitrator";
|
|
397
|
-
buyer: "buyer";
|
|
398
|
-
system: "system";
|
|
399
397
|
neutral: "neutral";
|
|
398
|
+
system: "system";
|
|
399
|
+
buyer: "buyer";
|
|
400
400
|
}>;
|
|
401
401
|
basis: z.ZodString;
|
|
402
402
|
}, z.core.$strict>>;
|
|
@@ -406,9 +406,9 @@ export declare const RulesSectionSchema: z.ZodObject<{
|
|
|
406
406
|
supplier: "supplier";
|
|
407
407
|
collaborator: "collaborator";
|
|
408
408
|
arbitrator: "arbitrator";
|
|
409
|
-
buyer: "buyer";
|
|
410
|
-
system: "system";
|
|
411
409
|
neutral: "neutral";
|
|
410
|
+
system: "system";
|
|
411
|
+
buyer: "buyer";
|
|
412
412
|
}>;
|
|
413
413
|
path: z.ZodString;
|
|
414
414
|
viability: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -424,6 +424,11 @@ export declare const RulesSectionSchema: z.ZodObject<{
|
|
|
424
424
|
}, z.core.$strict>>;
|
|
425
425
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
426
426
|
}, z.core.$strict>>;
|
|
427
|
+
severity_overrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
428
|
+
error: "error";
|
|
429
|
+
info: "info";
|
|
430
|
+
warning: "warning";
|
|
431
|
+
}>>>;
|
|
427
432
|
}, z.core.$strict>>;
|
|
428
433
|
}, z.core.$strict>;
|
|
429
434
|
export declare const RulesSectionInputSchema: z.ZodObject<{
|
|
@@ -451,9 +456,9 @@ export declare const RulesSectionInputSchema: z.ZodObject<{
|
|
|
451
456
|
supplier: "supplier";
|
|
452
457
|
collaborator: "collaborator";
|
|
453
458
|
arbitrator: "arbitrator";
|
|
454
|
-
buyer: "buyer";
|
|
455
|
-
system: "system";
|
|
456
459
|
neutral: "neutral";
|
|
460
|
+
system: "system";
|
|
461
|
+
buyer: "buyer";
|
|
457
462
|
}>;
|
|
458
463
|
basis: z.ZodString;
|
|
459
464
|
}, z.core.$strict>>;
|
|
@@ -463,9 +468,9 @@ export declare const RulesSectionInputSchema: z.ZodObject<{
|
|
|
463
468
|
supplier: "supplier";
|
|
464
469
|
collaborator: "collaborator";
|
|
465
470
|
arbitrator: "arbitrator";
|
|
466
|
-
buyer: "buyer";
|
|
467
|
-
system: "system";
|
|
468
471
|
neutral: "neutral";
|
|
472
|
+
system: "system";
|
|
473
|
+
buyer: "buyer";
|
|
469
474
|
}>;
|
|
470
475
|
path: z.ZodString;
|
|
471
476
|
viability: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -481,6 +486,11 @@ export declare const RulesSectionInputSchema: z.ZodObject<{
|
|
|
481
486
|
}, z.core.$strict>>>;
|
|
482
487
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
483
488
|
}, z.core.$strict>>>;
|
|
489
|
+
severity_overrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
490
|
+
error: "error";
|
|
491
|
+
info: "info";
|
|
492
|
+
warning: "warning";
|
|
493
|
+
}>>>;
|
|
484
494
|
}, z.core.$strict>>>;
|
|
485
495
|
}, z.core.$strict>;
|
|
486
496
|
export declare const JudgmentDocSchema: z.ZodObject<{
|
|
@@ -670,9 +680,9 @@ export declare const JudgmentDocSchema: z.ZodObject<{
|
|
|
670
680
|
supplier: "supplier";
|
|
671
681
|
collaborator: "collaborator";
|
|
672
682
|
arbitrator: "arbitrator";
|
|
673
|
-
buyer: "buyer";
|
|
674
|
-
system: "system";
|
|
675
683
|
neutral: "neutral";
|
|
684
|
+
system: "system";
|
|
685
|
+
buyer: "buyer";
|
|
676
686
|
}>;
|
|
677
687
|
basis: z.ZodString;
|
|
678
688
|
}, z.core.$strict>>;
|
|
@@ -682,9 +692,9 @@ export declare const JudgmentDocSchema: z.ZodObject<{
|
|
|
682
692
|
supplier: "supplier";
|
|
683
693
|
collaborator: "collaborator";
|
|
684
694
|
arbitrator: "arbitrator";
|
|
685
|
-
buyer: "buyer";
|
|
686
|
-
system: "system";
|
|
687
695
|
neutral: "neutral";
|
|
696
|
+
system: "system";
|
|
697
|
+
buyer: "buyer";
|
|
688
698
|
}>;
|
|
689
699
|
path: z.ZodString;
|
|
690
700
|
viability: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -700,6 +710,11 @@ export declare const JudgmentDocSchema: z.ZodObject<{
|
|
|
700
710
|
}, z.core.$strict>>;
|
|
701
711
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
702
712
|
}, z.core.$strict>>;
|
|
713
|
+
severity_overrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
714
|
+
error: "error";
|
|
715
|
+
info: "info";
|
|
716
|
+
warning: "warning";
|
|
717
|
+
}>>>;
|
|
703
718
|
}, z.core.$strict>>;
|
|
704
719
|
}, z.core.$strict>;
|
|
705
720
|
}, z.core.$strict>;
|
|
@@ -884,9 +899,9 @@ export declare const JudgmentDocInputSchema: z.ZodObject<{
|
|
|
884
899
|
supplier: "supplier";
|
|
885
900
|
collaborator: "collaborator";
|
|
886
901
|
arbitrator: "arbitrator";
|
|
887
|
-
buyer: "buyer";
|
|
888
|
-
system: "system";
|
|
889
902
|
neutral: "neutral";
|
|
903
|
+
system: "system";
|
|
904
|
+
buyer: "buyer";
|
|
890
905
|
}>;
|
|
891
906
|
basis: z.ZodString;
|
|
892
907
|
}, z.core.$strict>>;
|
|
@@ -896,9 +911,9 @@ export declare const JudgmentDocInputSchema: z.ZodObject<{
|
|
|
896
911
|
supplier: "supplier";
|
|
897
912
|
collaborator: "collaborator";
|
|
898
913
|
arbitrator: "arbitrator";
|
|
899
|
-
buyer: "buyer";
|
|
900
|
-
system: "system";
|
|
901
914
|
neutral: "neutral";
|
|
915
|
+
system: "system";
|
|
916
|
+
buyer: "buyer";
|
|
902
917
|
}>;
|
|
903
918
|
path: z.ZodString;
|
|
904
919
|
viability: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -914,6 +929,11 @@ export declare const JudgmentDocInputSchema: z.ZodObject<{
|
|
|
914
929
|
}, z.core.$strict>>>;
|
|
915
930
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
916
931
|
}, z.core.$strict>>>;
|
|
932
|
+
severity_overrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
933
|
+
error: "error";
|
|
934
|
+
info: "info";
|
|
935
|
+
warning: "warning";
|
|
936
|
+
}>>>;
|
|
917
937
|
}, z.core.$strict>>>;
|
|
918
938
|
}, z.core.$strict>>;
|
|
919
939
|
}, z.core.$strict>;
|
|
@@ -980,9 +1000,9 @@ export declare const JudgmentFragmentSchema: z.ZodObject<{
|
|
|
980
1000
|
supplier: "supplier";
|
|
981
1001
|
collaborator: "collaborator";
|
|
982
1002
|
arbitrator: "arbitrator";
|
|
983
|
-
buyer: "buyer";
|
|
984
|
-
system: "system";
|
|
985
1003
|
neutral: "neutral";
|
|
1004
|
+
system: "system";
|
|
1005
|
+
buyer: "buyer";
|
|
986
1006
|
}>;
|
|
987
1007
|
basis: z.ZodString;
|
|
988
1008
|
}, z.core.$strict>>;
|
|
@@ -992,9 +1012,9 @@ export declare const JudgmentFragmentSchema: z.ZodObject<{
|
|
|
992
1012
|
supplier: "supplier";
|
|
993
1013
|
collaborator: "collaborator";
|
|
994
1014
|
arbitrator: "arbitrator";
|
|
995
|
-
buyer: "buyer";
|
|
996
|
-
system: "system";
|
|
997
1015
|
neutral: "neutral";
|
|
1016
|
+
system: "system";
|
|
1017
|
+
buyer: "buyer";
|
|
998
1018
|
}>;
|
|
999
1019
|
path: z.ZodString;
|
|
1000
1020
|
viability: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -1010,6 +1030,11 @@ export declare const JudgmentFragmentSchema: z.ZodObject<{
|
|
|
1010
1030
|
}, z.core.$strict>>>;
|
|
1011
1031
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
1012
1032
|
}, z.core.$strict>>>;
|
|
1033
|
+
severity_overrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
1034
|
+
error: "error";
|
|
1035
|
+
info: "info";
|
|
1036
|
+
warning: "warning";
|
|
1037
|
+
}>>>;
|
|
1013
1038
|
}, z.core.$strict>>>;
|
|
1014
1039
|
}, z.core.$strict>>;
|
|
1015
1040
|
evaluation: z.ZodOptional<z.ZodObject<{
|
|
@@ -36,9 +36,9 @@ export declare const RuleCaseSchema: z.ZodObject<{
|
|
|
36
36
|
supplier: "supplier";
|
|
37
37
|
collaborator: "collaborator";
|
|
38
38
|
arbitrator: "arbitrator";
|
|
39
|
-
buyer: "buyer";
|
|
40
|
-
system: "system";
|
|
41
39
|
neutral: "neutral";
|
|
40
|
+
system: "system";
|
|
41
|
+
buyer: "buyer";
|
|
42
42
|
}>;
|
|
43
43
|
basis: z.ZodString;
|
|
44
44
|
}, z.core.$strict>>;
|
|
@@ -48,9 +48,9 @@ export declare const RuleCaseSchema: z.ZodObject<{
|
|
|
48
48
|
supplier: "supplier";
|
|
49
49
|
collaborator: "collaborator";
|
|
50
50
|
arbitrator: "arbitrator";
|
|
51
|
-
buyer: "buyer";
|
|
52
|
-
system: "system";
|
|
53
51
|
neutral: "neutral";
|
|
52
|
+
system: "system";
|
|
53
|
+
buyer: "buyer";
|
|
54
54
|
}>;
|
|
55
55
|
path: z.ZodString;
|
|
56
56
|
viability: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -84,9 +84,9 @@ export declare const RuleEntrySchema: z.ZodObject<{
|
|
|
84
84
|
supplier: "supplier";
|
|
85
85
|
collaborator: "collaborator";
|
|
86
86
|
arbitrator: "arbitrator";
|
|
87
|
-
buyer: "buyer";
|
|
88
|
-
system: "system";
|
|
89
87
|
neutral: "neutral";
|
|
88
|
+
system: "system";
|
|
89
|
+
buyer: "buyer";
|
|
90
90
|
}>;
|
|
91
91
|
basis: z.ZodString;
|
|
92
92
|
}, z.core.$strict>>;
|
|
@@ -96,9 +96,9 @@ export declare const RuleEntrySchema: z.ZodObject<{
|
|
|
96
96
|
supplier: "supplier";
|
|
97
97
|
collaborator: "collaborator";
|
|
98
98
|
arbitrator: "arbitrator";
|
|
99
|
-
buyer: "buyer";
|
|
100
|
-
system: "system";
|
|
101
99
|
neutral: "neutral";
|
|
100
|
+
system: "system";
|
|
101
|
+
buyer: "buyer";
|
|
102
102
|
}>;
|
|
103
103
|
path: z.ZodString;
|
|
104
104
|
viability: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -137,9 +137,9 @@ export declare const RuleDomainPackSchema: z.ZodObject<{
|
|
|
137
137
|
supplier: "supplier";
|
|
138
138
|
collaborator: "collaborator";
|
|
139
139
|
arbitrator: "arbitrator";
|
|
140
|
-
buyer: "buyer";
|
|
141
|
-
system: "system";
|
|
142
140
|
neutral: "neutral";
|
|
141
|
+
system: "system";
|
|
142
|
+
buyer: "buyer";
|
|
143
143
|
}>;
|
|
144
144
|
basis: z.ZodString;
|
|
145
145
|
}, z.core.$strict>>;
|
|
@@ -149,9 +149,9 @@ export declare const RuleDomainPackSchema: z.ZodObject<{
|
|
|
149
149
|
supplier: "supplier";
|
|
150
150
|
collaborator: "collaborator";
|
|
151
151
|
arbitrator: "arbitrator";
|
|
152
|
-
buyer: "buyer";
|
|
153
|
-
system: "system";
|
|
154
152
|
neutral: "neutral";
|
|
153
|
+
system: "system";
|
|
154
|
+
buyer: "buyer";
|
|
155
155
|
}>;
|
|
156
156
|
path: z.ZodString;
|
|
157
157
|
viability: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -167,6 +167,11 @@ export declare const RuleDomainPackSchema: z.ZodObject<{
|
|
|
167
167
|
}, z.core.$strict>>;
|
|
168
168
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
169
169
|
}, z.core.$strict>>;
|
|
170
|
+
severity_overrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
171
|
+
error: "error";
|
|
172
|
+
info: "info";
|
|
173
|
+
warning: "warning";
|
|
174
|
+
}>>>;
|
|
170
175
|
}, z.core.$strict>;
|
|
171
176
|
export type RuleCase = z.infer<typeof RuleCaseSchema>;
|
|
172
177
|
export type RuleEntry = z.infer<typeof RuleEntrySchema>;
|
|
@@ -191,9 +196,9 @@ export declare const RuleEntryInputSchema: z.ZodObject<{
|
|
|
191
196
|
supplier: "supplier";
|
|
192
197
|
collaborator: "collaborator";
|
|
193
198
|
arbitrator: "arbitrator";
|
|
194
|
-
buyer: "buyer";
|
|
195
|
-
system: "system";
|
|
196
199
|
neutral: "neutral";
|
|
200
|
+
system: "system";
|
|
201
|
+
buyer: "buyer";
|
|
197
202
|
}>;
|
|
198
203
|
basis: z.ZodString;
|
|
199
204
|
}, z.core.$strict>>;
|
|
@@ -203,9 +208,9 @@ export declare const RuleEntryInputSchema: z.ZodObject<{
|
|
|
203
208
|
supplier: "supplier";
|
|
204
209
|
collaborator: "collaborator";
|
|
205
210
|
arbitrator: "arbitrator";
|
|
206
|
-
buyer: "buyer";
|
|
207
|
-
system: "system";
|
|
208
211
|
neutral: "neutral";
|
|
212
|
+
system: "system";
|
|
213
|
+
buyer: "buyer";
|
|
209
214
|
}>;
|
|
210
215
|
path: z.ZodString;
|
|
211
216
|
viability: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -244,9 +249,9 @@ export declare const RuleDomainPackInputSchema: z.ZodObject<{
|
|
|
244
249
|
supplier: "supplier";
|
|
245
250
|
collaborator: "collaborator";
|
|
246
251
|
arbitrator: "arbitrator";
|
|
247
|
-
buyer: "buyer";
|
|
248
|
-
system: "system";
|
|
249
252
|
neutral: "neutral";
|
|
253
|
+
system: "system";
|
|
254
|
+
buyer: "buyer";
|
|
250
255
|
}>;
|
|
251
256
|
basis: z.ZodString;
|
|
252
257
|
}, z.core.$strict>>;
|
|
@@ -256,9 +261,9 @@ export declare const RuleDomainPackInputSchema: z.ZodObject<{
|
|
|
256
261
|
supplier: "supplier";
|
|
257
262
|
collaborator: "collaborator";
|
|
258
263
|
arbitrator: "arbitrator";
|
|
259
|
-
buyer: "buyer";
|
|
260
|
-
system: "system";
|
|
261
264
|
neutral: "neutral";
|
|
265
|
+
system: "system";
|
|
266
|
+
buyer: "buyer";
|
|
262
267
|
}>;
|
|
263
268
|
path: z.ZodString;
|
|
264
269
|
viability: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -274,6 +279,11 @@ export declare const RuleDomainPackInputSchema: z.ZodObject<{
|
|
|
274
279
|
}, z.core.$strict>>>;
|
|
275
280
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
276
281
|
}, z.core.$strict>>>;
|
|
282
|
+
severity_overrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
283
|
+
error: "error";
|
|
284
|
+
info: "info";
|
|
285
|
+
warning: "warning";
|
|
286
|
+
}>>>;
|
|
277
287
|
}, z.core.$strict>;
|
|
278
288
|
export type RuleDomainPackInput = z.infer<typeof RuleDomainPackInputSchema>;
|
|
279
289
|
export type { FindingExposure, GainPath, ExposureParty, ExposureVerdict, GainPathViability, } from "./exposure.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z}from'zod';import{SEVERITY_ORDER}from'./severity.js';import{ExposureFragmentSchema,FactRefSchema,applyExposureGate,parseFactRef,resolveExposureFragment}from'./exposure.js';const LEAF_OPS=['present','missing','truthy','falsy','eq','neq','gt','gte','lt','lte','in','nin','contains','matches','size'];export const RuleConditionSchema=z['lazy'](()=>z['union']([z['object']({'all':z['array'](RuleConditionSchema)})['strict'](),z['object']({'any':z['array'](RuleConditionSchema)})['strict'](),z['object']({'not':RuleConditionSchema})['strict'](),z['object']({'field':z['string'](),'op':z['enum'](LEAF_OPS),'value':z['unknown']()['optional'](),'flags':z['string']()['optional']()})['strict']()]));const CaseLevelSchema=z['union']([z['enum'](SEVERITY_ORDER),FactRefSchema]);export const RuleCaseSchema=z['object']({'when':RuleConditionSchema,'level':CaseLevelSchema,'title':z['string'](),'description':z['string'](),'scenario':z['string']()['optional'](),'mitigation':z['string']()['optional'](),'evidence':z['string']()['optional'](),'stakeholders':z['array'](z['string']())['optional'](),'exposure':ExposureFragmentSchema['optional']()})['strict']();export const RuleEntrySchema=z['object']({'rule_id':z['string'](),'dimension':z['string']()['optional'](),'trigger':z['string']()['optional'](),'cases':z['array'](RuleCaseSchema)['min'](0x1),'enabled':z['boolean']()['optional']()})['strict']();export const RuleDomainPackSchema=z['object']({'comment':z['string']()['optional'](),'facts':z['record'](z['string'](),z['string']())['optional'](),'rules':z['array'](RuleEntrySchema)})['strict']();export const RuleEntryInputSchema=z['object']({'rule_id':z['string'](),'dimension':z['string']()['optional'](),'trigger':z['string']()['optional'](),'cases':z['array'](RuleCaseSchema)['optional'](),'enabled':z['boolean']()['optional']()})['strict']();export const RuleDomainPackInputSchema=z['object']({'comment':z['string']()['optional'](),'facts':z['record'](z['string'](),z['string']())['optional'](),'rules':z['array'](RuleEntryInputSchema)['optional']()})['strict']();function lookup(a,b){let c=a;for(const d of b['split']('.')){if(c===null||typeof c!=='object')return undefined;c=c[d];if(c===undefined)return undefined;}return c;}function isPlainObject(a){return typeof a==='object'&&a!==null&&!Array['isArray'](a);}function toNumber(a){if(typeof a==='number'&&Number['isFinite'](a))return a;if(typeof a==='string'&&a['trim']()!==''&&Number['isFinite'](Number(a)))return Number(a);return null;}function matchesOp(c,d){const e=lookup(d,c['field']);switch(c['op']){case'present':return e!==undefined;case'missing':return e===undefined;case'truthy':return Array['isArray'](e)?e['length']>0x0:Boolean(e);case'falsy':return Array['isArray'](e)?e['length']===0x0:!e;case'eq':return e===c['value'];case'neq':return e!==c['value'];case'gt':case'gte':case'lt':case'lte':{const f=toNumber(e),g=toNumber(c['value']);if(f===null||g===null)return![];if(c['op']==='gt')return f>g;if(c['op']==='gte')return f>=g;if(c['op']==='lt')return f<g;return f<=g;}case'in':case'nin':{const h=Array['isArray'](c['value'])?c['value']:[],i=h['some'](j=>j===e);return c['op']==='in'?i:!i;}case'contains':if(Array['isArray'](e))return e['some'](j=>j===c['value']);if(typeof e==='string'&&typeof c['value']==='string')return e['includes'](c['value']);return![];case'matches':{if(typeof e!=='string'||typeof c['value']!=='string')return![];return new RegExp(c['value'],c['flags']??'i')['test'](e);}case'size':if(Array['isArray'](e))return e['length']===c['value'];if(typeof e==='string')return e['length']===c['value'];return![];}}export function evaluateCondition(a,b){if('all'in a)return a['all']['every'](d=>evaluateCondition(d,b));if('any'in a)return a['any']['some'](d=>evaluateCondition(d,b));if('not'in a)return!evaluateCondition(a['not'],b);return matchesOp(a,b);}export function interpolate(a,b){return a['replace'](/\$\{([^}]+)\}/g,(c,d)=>{const e=lookup(b,d['trim']());if(e===undefined)return c;if(typeof e==='object')return JSON['stringify'](e);return String(e);});}function resolveLevel(a,b){const c=parseFactRef(a);if(c===null)return a;const d=b[c];return SEVERITY_ORDER['includes'](String(d))?String(d):'info';}export function evaluateRuleBook(a,b){const d=[],e=[];for(const f of a){if(f['enabled']===![]){e['push'](f['rule_id']);continue;}for(const g of f['cases']){if(!evaluateCondition(g['when'],b))continue;const h=resolveLevel(g['level'],b),i=g['exposure']?resolveExposureFragment(g['exposure'],b,k=>interpolate(k,b)):undefined,j=i?applyExposureGate(h,i,{'downgradeExempt':i['downgradeExempt']}):undefined;d['push']({'rule_id':f['rule_id'],'dimension':f['dimension'],'level':j?j['severity']:h,'title':interpolate(g['title'],b),'description':interpolate(g['description'],b),'scenario':g['scenario']===undefined?undefined:interpolate(g['scenario'],b),'mitigation':g['mitigation']===undefined?undefined:interpolate(g['mitigation'],b),'evidence':g['evidence']===undefined?undefined:interpolate(g['evidence'],b),'stakeholders':g['stakeholders'],...j?{'exposure':j['exposure']}:{}});break;}}return{'findings':d,'disabled_traces':e};}
|
|
1
|
+
import{z}from'zod';import{SEVERITY_ORDER}from'./severity.js';import{ExposureFragmentSchema,FactRefSchema,applyExposureGate,parseFactRef,resolveExposureFragment}from'./exposure.js';const LEAF_OPS=['present','missing','truthy','falsy','eq','neq','gt','gte','lt','lte','in','nin','contains','matches','size'];export const RuleConditionSchema=z['lazy'](()=>z['union']([z['object']({'all':z['array'](RuleConditionSchema)})['strict'](),z['object']({'any':z['array'](RuleConditionSchema)})['strict'](),z['object']({'not':RuleConditionSchema})['strict'](),z['object']({'field':z['string'](),'op':z['enum'](LEAF_OPS),'value':z['unknown']()['optional'](),'flags':z['string']()['optional']()})['strict']()]));const CaseLevelSchema=z['union']([z['enum'](SEVERITY_ORDER),FactRefSchema]);export const RuleCaseSchema=z['object']({'when':RuleConditionSchema,'level':CaseLevelSchema,'title':z['string'](),'description':z['string'](),'scenario':z['string']()['optional'](),'mitigation':z['string']()['optional'](),'evidence':z['string']()['optional'](),'stakeholders':z['array'](z['string']())['optional'](),'exposure':ExposureFragmentSchema['optional']()})['strict']();export const RuleEntrySchema=z['object']({'rule_id':z['string'](),'dimension':z['string']()['optional'](),'trigger':z['string']()['optional'](),'cases':z['array'](RuleCaseSchema)['min'](0x1),'enabled':z['boolean']()['optional']()})['strict']();export const RuleDomainPackSchema=z['object']({'comment':z['string']()['optional'](),'facts':z['record'](z['string'](),z['string']())['optional'](),'rules':z['array'](RuleEntrySchema),'severity_overrides':z['record'](z['string'](),z['enum'](['error','warning','info']))['optional']()})['strict']();export const RuleEntryInputSchema=z['object']({'rule_id':z['string'](),'dimension':z['string']()['optional'](),'trigger':z['string']()['optional'](),'cases':z['array'](RuleCaseSchema)['optional'](),'enabled':z['boolean']()['optional']()})['strict']();export const RuleDomainPackInputSchema=z['object']({'comment':z['string']()['optional'](),'facts':z['record'](z['string'](),z['string']())['optional'](),'rules':z['array'](RuleEntryInputSchema)['optional'](),'severity_overrides':z['record'](z['string'](),z['enum'](['error','warning','info']))['optional']()})['strict']();function lookup(a,b){let c=a;for(const d of b['split']('.')){if(c===null||typeof c!=='object')return undefined;c=c[d];if(c===undefined)return undefined;}return c;}function isPlainObject(a){return typeof a==='object'&&a!==null&&!Array['isArray'](a);}function toNumber(a){if(typeof a==='number'&&Number['isFinite'](a))return a;if(typeof a==='string'&&a['trim']()!==''&&Number['isFinite'](Number(a)))return Number(a);return null;}function matchesOp(c,d){const e=lookup(d,c['field']);switch(c['op']){case'present':return e!==undefined;case'missing':return e===undefined;case'truthy':return Array['isArray'](e)?e['length']>0x0:Boolean(e);case'falsy':return Array['isArray'](e)?e['length']===0x0:!e;case'eq':return e===c['value'];case'neq':return e!==c['value'];case'gt':case'gte':case'lt':case'lte':{const f=toNumber(e),g=toNumber(c['value']);if(f===null||g===null)return![];if(c['op']==='gt')return f>g;if(c['op']==='gte')return f>=g;if(c['op']==='lt')return f<g;return f<=g;}case'in':case'nin':{const h=Array['isArray'](c['value'])?c['value']:[],i=h['some'](j=>j===e);return c['op']==='in'?i:!i;}case'contains':if(Array['isArray'](e))return e['some'](j=>j===c['value']);if(typeof e==='string'&&typeof c['value']==='string')return e['includes'](c['value']);return![];case'matches':{if(typeof e!=='string'||typeof c['value']!=='string')return![];return new RegExp(c['value'],c['flags']??'i')['test'](e);}case'size':if(Array['isArray'](e))return e['length']===c['value'];if(typeof e==='string')return e['length']===c['value'];return![];}}export function evaluateCondition(a,b){if('all'in a)return a['all']['every'](d=>evaluateCondition(d,b));if('any'in a)return a['any']['some'](d=>evaluateCondition(d,b));if('not'in a)return!evaluateCondition(a['not'],b);return matchesOp(a,b);}export function interpolate(a,b){return a['replace'](/\$\{([^}]+)\}/g,(c,d)=>{const e=lookup(b,d['trim']());if(e===undefined)return c;if(typeof e==='object')return JSON['stringify'](e);return String(e);});}function resolveLevel(a,b){const c=parseFactRef(a);if(c===null)return a;const d=b[c];return SEVERITY_ORDER['includes'](String(d))?String(d):'info';}export function evaluateRuleBook(a,b){const d=[],e=[];for(const f of a){if(f['enabled']===![]){e['push'](f['rule_id']);continue;}for(const g of f['cases']){if(!evaluateCondition(g['when'],b))continue;const h=resolveLevel(g['level'],b),i=g['exposure']?resolveExposureFragment(g['exposure'],b,k=>interpolate(k,b)):undefined,j=i?applyExposureGate(h,i,{'downgradeExempt':i['downgradeExempt']}):undefined;d['push']({'rule_id':f['rule_id'],'dimension':f['dimension'],'level':j?j['severity']:h,'title':interpolate(g['title'],b),'description':interpolate(g['description'],b),'scenario':g['scenario']===undefined?undefined:interpolate(g['scenario'],b),'mitigation':g['mitigation']===undefined?undefined:interpolate(g['mitigation'],b),'evidence':g['evidence']===undefined?undefined:interpolate(g['evidence'],b),'stakeholders':g['stakeholders'],...j?{'exposure':j['exposure']}:{}});break;}}return{'findings':d,'disabled_traces':e};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{describe,expect,it}from'vitest';import{ENTRYPOINT}from'@wowok/wowok';import{FakeDataPlane}from'../../graph/onchain/dataplane.js';import{expandTopology}from'../../graph/onchain/expand.js';import{FULL,GAP,fullServiceState,gapServiceState,truncatedServiceState}from'../../graph/onchain/fixtures.js';import{buildViewport}from'../../graph/onchain/viewport.js';import{runAnalyzers}from'../../graph/onchain/analyze.js';import{EVALUATION_SERVICE_INTENTS,resolveExpansionStrategy,withEvaluationBundle}from'../../graph/onchain/strategy.js';import{projectEvaluationFacts as
|
|
1
|
+
import{describe,expect,it}from'vitest';import{ENTRYPOINT}from'@wowok/wowok';import{FakeDataPlane}from'../../graph/onchain/dataplane.js';import{expandTopology}from'../../graph/onchain/expand.js';import{FULL,GAP,fullServiceState,gapServiceState,truncatedServiceState}from'../../graph/onchain/fixtures.js';import{buildViewport}from'../../graph/onchain/viewport.js';import{runAnalyzers}from'../../graph/onchain/analyze.js';import{EVALUATION_SERVICE_INTENTS,resolveExpansionStrategy,withEvaluationBundle}from'../../graph/onchain/strategy.js';import{projectEvaluationFacts as a23a}from'../../graph/onchain/facts.js';import{evaluateGraphServiceFacts,GRAPH_RULE_INPUT_FACTS,registerGraphServiceEvaluations}from'./graph-service.js';async function evalState(a,b){registerGraphServiceEvaluations();const c=withEvaluationBundle(resolveExpansionStrategy({'intents':[...EVALUATION_SERVICE_INTENTS]})),d=await expandTopology(new FakeDataPlane(a),{'network':ENTRYPOINT['Mainnet'],'seed':b,'edges':c['edges'],'budget':c['budget']}),e=buildViewport(d,b,'neutral'),f=a23a(e,b,runAnalyzers(e));return{'projected':f,'r':await evaluateGraphServiceFacts(f)};}const scoreOf=(a,b,c)=>a[b]['breakdown']['find'](d=>d['rule_id']===c);describe('graph\x20service\x20evaluation\x20—\x20fully\x20hooked\x20shop\x20(TR-14.1)',()=>{it('scores\x20all\x20nine\x20dimensions\x20from\x20material\x20facts\x20with\x20no\x20default-low\x20deductions',async()=>{const {r:a}=await evalState(fullServiceState(),FULL['svc']);expect(a['unverified'])['toEqual']([]),expect(a['completeness'])['toBe'](0x64);const c=scoreOf(a,'trust','trust_arbitration');expect(c['score'])['toBe'](0x64),expect(c['matched'])['toEqual'](expect['arrayContaining'](['arbitrator\x20roster\x20configured','arbitration\x20fee\x20funded','arbitration\x20active'])),expect(c['reason'])['toContain']('Arbitration\x2020/20'),expect(scoreOf(a,'trust','trust_reviews')['score'])['toBe'](0x28),expect(scoreOf(a,'trust','trust_fulfillment')['score'])['toBe'](0x19);const d=scoreOf(a,'trust','trust_fund_safety');expect(d['score'])['toBe'](0x0),expect(d['mismatched'])['toContain']('compensation\x20fund\x20below\x20the\x20statutory\x203x\x20exposure\x20ceiling'),expect(scoreOf(a,'trust','trust_transparency')['score'])['toBe'](0x64),expect(a['trust']['total'])['toBe'](0x31);const e=scoreOf(a,'risk','risk_fund');expect(e['score'])['toBeLessThan'](0x64),expect(e['mismatched'])['toContain']('Payout\x20exposure:\x20compensation\x20fund\x20is\x20below\x20the\x203x\x20ceiling\x20of\x20windowed\x20order\x20amounts'),expect(e['mismatched']?.['some'](h=>h['startsWith']('R2:')))['toBe'](![]),expect(e['finding_refs']?.['map'](h=>h['id']))['toContain']('R2:'+FULL['svc']['toLowerCase']());const f=scoreOf(a,'risk','risk_trust');expect(f['score'])['toBeLessThan'](0x64),expect(f['mismatched']?.['some'](h=>h['startsWith']('R1:')))['toBe'](![]),expect(f['mismatched']?.['length'])['toBeGreaterThan'](0x0),expect(f['finding_refs']?.['some'](h=>h['id']['startsWith']('R1:')))['toBe'](!![]);for(const h of[...a['trust']['breakdown'],...a['risk']['breakdown']]){for(const i of h['mismatched']??[])expect(i)['not']['toContain']('::node::');}expect(scoreOf(a,'risk','risk_workflow')['score'])['toBe'](0x64),expect(scoreOf(a,'risk','risk_behavior')['score'])['toBe'](0x64);for(const j of[...a['trust']['breakdown'],...a['risk']['breakdown']]){const k=(j['reason']??'')['toLowerCase']();expect(k)['not']['toContain']('no\x20data'),expect(k)['not']['toContain']('default\x20low');}const g=a['trust']['trace']['filter'](l=>l['kind']==='rule'&&l['detail']['startsWith']('score='));expect(g['map'](l=>l['id']))['toEqual'](expect['arrayContaining'](Object['keys'](GRAPH_RULE_INPUT_FACTS)['filter'](l=>l['startsWith']('trust_'))));}),it('keeps\x20the\x20injection\x20+\x20requirement\x20mechanisms\x20working',async()=>{const {projected:a}=await evalState(fullServiceState(),FULL['svc']),b=await evaluateGraphServiceFacts(a,{'overrides':{'rules':{'trust_arbitration':{'weight':0x28}}}});expect(b['trust']['total'])['toBe'](0x3a);const c=await evaluateGraphServiceFacts(a,{'requirements':[{'rule_id':'trust_fund_safety','condition':'require'}]});expect(c['trust']['blocked'])['toBe'](!![]),expect(c['trust']['red_flags']['length'])['toBeGreaterThan'](0x0);});}),describe('graph\x20service\x20evaluation\x20—\x20configured-empty\x20shell\x20(TR-14.1)',()=>{it('scores\x20verified\x20absence\x20as\x20a\x20configured\x20fact\x20and\x20excludes\x20only\x20the\x20gap\x20dimension',async()=>{const {r:a}=await evalState(gapServiceState(),GAP['svc']),b=scoreOf(a,'trust','trust_arbitration');expect(b['score'])['toBe'](0x0),expect(b['reason'])['toContain']('verified\x20absence'),expect(scoreOf(a,'trust','trust_reviews')['score'])['toBe'](0x32),expect(a['unverified'])['toEqual'](['risk_workflow']),expect(scoreOf(a,'risk','risk_workflow'))['toBeUndefined'](),expect(a['risk']['unverified'])['toEqual'](['risk_workflow']),expect(a['trust']['unverified'])['toEqual'](['risk_workflow']);const c=a['risk']['trace']['find'](d=>d['kind']==='rule'&&d['id']==='risk_workflow');expect(c?.['detail'])['toContain']('not\x20applicable'),expect(scoreOf(a,'trust','trust_transparency')['score'])['toBe'](0x28),expect(scoreOf(a,'trust','trust_fund_safety')['score'])['toBe'](0x0);});}),describe('graph\x20service\x20evaluation\x20—\x20truncated\x20order\x20window\x20(TR-14.1)',()=>{it('excludes\x20the\x20unverifiable\x20dimensions\x20and\x20renormalizes\x20the\x20weighted\x20total',async()=>{const {r:a}=await evalState(truncatedServiceState(),FULL['svc']);expect(a['unverified'])['toEqual'](expect['arrayContaining'](['trust_fulfillment','trust_fund_safety','risk_fund','risk_behavior'])),expect(scoreOf(a,'trust','trust_fulfillment'))['toBeUndefined'](),expect(scoreOf(a,'trust','trust_fund_safety'))['toBeUndefined'](),expect(scoreOf(a,'risk','risk_fund'))['toBeUndefined'](),expect(scoreOf(a,'risk','risk_behavior'))['toBeUndefined'](),expect(a['trust']['total'])['toBe'](0x44);for(const b of['trust_fulfillment','trust_fund_safety']){expect(a['trust']['trace']['find'](c=>c['kind']==='rule'&&c['id']===b)?.['detail'])['toContain']('not\x20applicable');}for(const c of['risk_fund','risk_behavior']){expect(a['risk']['trace']['find'](d=>d['kind']==='rule'&&d['id']===c)?.['detail'])['toContain']('not\x20applicable');}});}),describe('graph\x20service\x20evaluation\x20—\x20scoring\x20report\x20(TR-14.2)',()=>{it('renders\x20a\x20per-dimension\x20report\x20with\x20score,\x20weight,\x20state,\x20confidence\x20and\x20evidence',async()=>{const {projected:a,r:c}=await evalState(fullServiceState(),FULL['svc']),d=new Map(a['facts']['map'](g=>[g['key'],g])),e=[];for(const g of['trust','risk']){const h=c[g];e['push'](g['toUpperCase']()+'\x20'+h['total']+'/100\x20('+h['level']+')\x20—\x20'+h['summary']);for(const i of h['breakdown']){const j=GRAPH_RULE_INPUT_FACTS[i['rule_id']]??[],k=j['map'](o=>o+':state='+(d['get'](o)?.['state']??'missing')),l=j['map'](o=>d['get'](o)?.['provenance']['confidence']??'missing'),n=j['map'](o=>d['get'](o)?.['evidence']??'missing')['join']('\x20');e['push'](i['rule_id']+':\x20score='+i['score']+'\x20weight='+i['weight']+'\x20'+k['join'](',')+'\x20confidence='+[...new Set(l)]['join']('+')+'\x20evidence=\x22'+n+'\x22');}}expect(e)['toHaveLength'](0xb);const f=e['filter'](o=>o['includes']('score='));expect(f)['toHaveLength'](0x9);for(const o of f){expect(o)['toMatch'](/weight=\d+/),expect(o)['toContain']('state=present'),expect(o)['toMatch'](/confidence=(exact|bounded|windowed|derived)/);const p=o['match'](/evidence="(.*)"/);expect(p,o)['not']['toBeNull'](),expect(p[0x1]['length'],o)['toBeGreaterThan'](0x0);}expect(c['trust']['summary'])['toContain']('weakest\x20Fund\x20safety'),expect(c['trust']['summary'])['not']['toContain']('trust_fund_safety'),expect(c['trust']['summary'])['toMatch'](/grade: (strong|fair|weak)/),expect(c['trust']['summary'])['toContain']('Compensation\x20fund');});});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{REQUIREMENT_PASS_THRESHOLD,effectiveWeight,isDataSourceEnabled,isRuleEnabled,normalizeInjection}from'./user-injection.js';import{levelFromScore as
|
|
1
|
+
import{REQUIREMENT_PASS_THRESHOLD,effectiveWeight,isDataSourceEnabled,isRuleEnabled,normalizeInjection}from'./user-injection.js';import{levelFromScore as a29a}from'./standards.js';export function levelFromScore(a){return a29a(a);}function appliesTo(a,b){if(!a||a['length']===0x0)return!![];return a['includes'](b);}export class EvaluationEngine{static ['instance']=null;['dataSources']=new Map();['rules']=new Map();static['Instance'](){return!EvaluationEngine['instance']&&(EvaluationEngine['instance']=new EvaluationEngine()),EvaluationEngine['instance'];}['registerDataSource'](a){if(!a['id']||this['dataSources']['has'](a['id']))return![];return this['dataSources']['set'](a['id'],a),!![];}['unregisterDataSource'](a){return this['dataSources']['delete'](a);}['registerRule'](a){if(!a['id']||this['rules']['has'](a['id']))return![];return this['rules']['set'](a['id'],a),!![];}['unregisterRule'](a){return this['rules']['delete'](a);}['getRule'](a){return this['rules']['get'](a);}['listRules'](){return Array['from'](this['rules']['values']());}['getDataSource'](a){return this['dataSources']['get'](a);}['listDataSources'](){return Array['from'](this['dataSources']['values']());}async['evaluate'](a,b,c){const d=normalizeInjection(c),e={'evaluation_id':a,'entities':b,'facts':{},'injection':d,'now':Date['now']()},f=[],g=Array['from'](this['dataSources']['values']())['filter'](m=>appliesTo(m['evaluation_ids'],a))['sort']((m,n)=>(m['priority']??0x0)-(n['priority']??0x0));for(const m of g){if(!isDataSourceEnabled(m['id'],d)){f['push']({'kind':'override','id':m['id'],'detail':'data\x20source\x20disabled\x20by\x20user\x20override'});continue;}if(m['isEnabled']&&!m['isEnabled'](e))continue;const n=await m['extract'](e);Object['assign'](e['facts'],n),f['push']({'kind':'data_source','id':m['id'],'detail':'extracted\x20'+Object['keys'](n)['length']+'\x20fact(s)'});}const h=[],i=[];for(const o of this['rules']['values']()){if(!appliesTo(o['evaluation_ids'],a))continue;if(!isRuleEnabled(o['id'],d)){f['push']({'kind':'override','id':o['id'],'detail':'rule\x20disabled\x20by\x20user\x20override'});continue;}if(o['isEnabled']&&!o['isEnabled'](e))continue;const p=o['evaluate'](e);if(!p){f['push']({'kind':'rule','id':o['id'],'detail':'not\x20applicable\x20—\x20excluded\x20from\x20weighted\x20aggregation'});continue;}const q=effectiveWeight(o,d);h['push']({'rule_id':o['id'],'dimension':o['dimension'],'score':p['score'],'weight':q,'weight_source':q!==o['weight']?'override':'default','reason':p['reason'],'matched':p['matched'],'mismatched':p['mismatched'],'finding_refs':p['finding_refs'],'red_flag':p['red_flag']}),p['red_flag']&&i['push'](p['reason']??o['id']+'\x20triggered\x20a\x20hard\x20block'),f['push']({'kind':'rule','id':o['id'],'detail':'score='+p['score']+'\x20weight='+q});}const j=aggregateScore(h);let k=i['length']>0x0;for(const r of d['requirements']??[]){const s=h['find'](t=>t['rule_id']===r['rule_id']);if(r['condition']==='require')(!s||s['score']<REQUIREMENT_PASS_THRESHOLD||s['red_flag'])&&(k=!![],i['push'](r['note']??'Requirement\x20requires\x20rule\x20\x27'+r['rule_id']+'\x27\x20to\x20pass'));else r['condition']==='forbid'&&(s&&s['red_flag']&&(k=!![],i['push'](r['note']??'Requirement\x20forbids\x20rule\x20\x27'+r['rule_id']+'\x27\x20from\x20triggering')));}const l=e['facts']['summary']??buildSummary(a,j,h,i,k);return{'evaluation_id':a,'total':j,'level':levelFromScore(j),'breakdown':h,'red_flags':i,'blocked':k,'trace':f,'summary':l,'criterionScores':e['facts']['criterionScores'],'findings':e['facts']['findings'],'strengths':e['facts']['strengths'],'needsLlm':e['facts']['needsLlm'],'llmPrompt':e['facts']['llmPrompt']};}}function aggregateScore(a){if(a['length']===0x0)return 0x0;let c=0x0,d=0x0;for(const e of a){c+=e['score']*e['weight'],d+=e['weight'];}if(d<=0x0)return 0x0;return clamp(Math['round'](c/d),0x0,0x64);}function clamp(a,b,c){return Math['max'](b,Math['min'](c,a));}function buildSummary(a,b,c,d,e){const f=['Evaluation\x20\x27'+a+'\x27:\x20score\x20'+b+'/100'];return e?f['push']('BLOCKED\x20('+d['length']+'\x20red\x20flag(s))'):f['push'](c['length']+'\x20rule(s)\x20evaluated'),f['join']('\x20—\x20');}export function getEvaluationEngine(){return EvaluationEngine['Instance']();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{distillIntent,extractSignals}from'./intent-distill.js';import{getProfile,updateFromOperation}from'./user-profile.js';import{findMatches,recordSignature}from'./experience-reuse.js';import{EXPERIENCE_LAYER_VERSION}from'./types.js';import{isEnabled as
|
|
1
|
+
import{distillIntent,extractSignals}from'./intent-distill.js';import{getProfile,updateFromOperation}from'./user-profile.js';import{findMatches,recordSignature}from'./experience-reuse.js';import{EXPERIENCE_LAYER_VERSION}from'./types.js';import{isEnabled as a51a}from'../config/index.js';import{recordIndustrySignal}from'../knowledge/flywheel-loop.js';export{EXPERIENCE_LAYER_VERSION};export function getExperienceFeedback(a,b,c){try{const d=distillIntent(a,b,c),e=findMatches(d['primary_intent'],a,b,0x3);if(e['length']===0x0)return undefined;const f=e[0x0],g=getProfile();return formatFeedback(f,e,d['scenario'],g);}catch{return undefined;}}export function recordOperationOutcome(a,b,c,d,e,f=[]){try{const g=distillIntent(a,b,c),h=extractSignals(a,b);recordSignature({'intent':g['primary_intent'],'scenario':g['scenario'],'signals':h,'timestamp':Date['now'](),'outcome':d,'error_code':e}),updateFromOperation(g['primary_intent'],g['scenario'],d,e,f);try{if(a51a('industry_evolution')){const i=typeof b?.['industry']==='string'&&b['industry']['trim']()?b['industry']['trim']():undefined;if(i){const j=d==='success'?{'success':!![]}:{'success':![],'error_code':e};recordIndustrySignal(i,{'type':a,'data':b},j);}}}catch{}}catch{}}function formatFeedback(a,b,c,d){const e=buildAdviceText(a,b,d),f=collectAvoidList(b,d),g=a['relevance'],h=c??a['signature']['scenario'],i={};if(e)i['advice']=e;if(f['length']>0x0)i['avoid']=f;if(g>0x0)i['relevance']=Math['round'](g*0x64)/0x64;if(h)i['matched_scenario']=h;return i;}function buildAdviceText(a,b,c){const d=[];if(a['signature']['outcome']==='success')d['push']('Historically,\x20'+a['signature']['intent']+'\x20operation\x20succeeded');else a['signature']['outcome']==='failed'&&d['push']('Historically,\x20'+a['signature']['intent']+'\x20operation\x20failed\x20('+(a['signature']['error_code']??'unknown\x20error')+'),\x20pay\x20special\x20attention\x20to\x20parameters');return c['expertise_tier']==='novice'&&b['length']>0x0&&d['push']('It\x20is\x20recommended\x20to\x20carefully\x20check\x20parameters\x20before\x20executing'),d['join'](';\x20')||a['advice'];}function collectAvoidList(b,c){const d=new Set();for(const e of b){for(const f of e['avoid']){d['add'](f);}}for(const g of c['frequent_pitfalls']){d['add']('You\x20often\x20make\x20mistakes\x20at\x20the\x20'+g+'\x20step,\x20please\x20be\x20especially\x20careful');}return Array['from'](d)['slice'](0x0,0x5);}
|