@wowok/agent-mcp 3.2.4 → 3.2.7
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/chain-semantics/field-capability.js +1 -1
- package/dist/chain-semantics/freeze-map.js +1 -1
- package/dist/chain-semantics/object-graph.js +1 -1
- package/dist/communication/wts-attestation.js +1 -1
- package/dist/composition/audit.js +1 -1
- package/dist/composition/blueprint-view.d.ts +64 -0
- package/dist/composition/blueprint-view.js +1 -0
- package/dist/composition/compile.d.ts +3 -2
- package/dist/composition/compile.js +1 -1
- package/dist/composition/inflight.d.ts +17 -0
- package/dist/composition/inflight.js +1 -0
- package/dist/config/config-audit.spec.js +1 -1
- package/dist/customer/account-events.js +1 -1
- package/dist/customer/order-monitor.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/constraint-registry.d.ts +6 -1
- package/dist/extensions/constraint-registry.js +1 -1
- package/dist/extensions/index.d.ts +1 -1
- package/dist/extensions/index.js +1 -1
- package/dist/extensions/industry-pack.d.ts +6 -0
- package/dist/extensions/industry-pack.js +1 -1
- package/dist/extensions/mode-evaluator.d.ts +3 -2
- package/dist/extensions/mode-evaluator.js +1 -1
- package/dist/extensions/modes.js +1 -1
- package/dist/extensions/registry.d.ts +1 -2
- package/dist/extensions/registry.js +1 -1
- package/dist/graph/onchain/analyze.js +1 -1
- package/dist/graph/onchain/analyze.spec.js +1 -1
- package/dist/graph/onchain/anti-cheat.d.ts +32 -2
- package/dist/graph/onchain/anti-cheat.js +1 -1
- package/dist/graph/onchain/anti-cheat.spec.js +1 -1
- package/dist/graph/onchain/expand.js +1 -1
- package/dist/graph/onchain/exposure.js +1 -1
- package/dist/graph/onchain/extract.js +1 -1
- package/dist/graph/onchain/facts.js +1 -1
- package/dist/graph/onchain/graph-policy.spec.js +1 -1
- package/dist/graph/onchain/index.d.ts +2 -2
- package/dist/graph/onchain/index.js +1 -1
- package/dist/graph/onchain/project-relationship.js +1 -1
- package/dist/graph/onchain/table-ledger.spec.js +1 -1
- package/dist/graph/onchain/types.d.ts +3 -0
- package/dist/harness/recover.js +1 -1
- package/dist/index.js +1 -1
- package/dist/knowledge/arbitration-venue-order.d.ts +25 -0
- package/dist/knowledge/arbitration-venue-order.js +1 -0
- package/dist/knowledge/audit-rules.d.ts +12 -0
- package/dist/knowledge/audit-rules.js +1 -1
- package/dist/knowledge/baselines/risk-baselines.spec.js +1 -1
- package/dist/knowledge/baselines/rules/allocation.json +5 -5
- package/dist/knowledge/baselines/rules/arb.json +1 -1
- package/dist/knowledge/baselines/rules/graph.json +81 -0
- package/dist/knowledge/baselines/rules/guard.json +9 -9
- package/dist/knowledge/baselines/rules/machine.json +5 -5
- package/dist/knowledge/baselines/rules/order.json +1 -1
- package/dist/knowledge/baselines/rules/plan.json +80 -2
- package/dist/knowledge/builtin-templates.d.ts +18 -2
- package/dist/knowledge/builtin-templates.js +1 -1
- package/dist/knowledge/discount-threshold.js +1 -1
- package/dist/knowledge/entity-recipient-guard.js +1 -1
- package/dist/knowledge/event-semantics.js +1 -1
- package/dist/knowledge/getting-started.js +1 -1
- package/dist/knowledge/guard-bindings.js +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-field-cognition.js +1 -1
- package/dist/knowledge/guard-ledger.js +1 -1
- package/dist/knowledge/guard-lint.d.ts +1 -0
- package/dist/knowledge/guard-lint.js +1 -1
- package/dist/knowledge/guard-node-gates.d.ts +4 -0
- package/dist/knowledge/guard-node-gates.js +1 -0
- package/dist/knowledge/guard-puzzle.js +1 -1
- package/dist/knowledge/guard-risk.js +1 -1
- package/dist/knowledge/guard-submission-prompt.d.ts +1 -0
- package/dist/knowledge/guard-submission-prompt.js +1 -1
- package/dist/knowledge/guard-templates.d.ts +2 -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.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/machine-topology.d.ts +6 -0
- package/dist/knowledge/machine-topology.js +1 -1
- package/dist/knowledge/order-ledger.js +1 -1
- package/dist/knowledge/reputation-rules.d.ts +3 -9
- package/dist/knowledge/reputation-rules.js +1 -1
- package/dist/knowledge/safety-rules.d.ts +10 -1
- package/dist/knowledge/safety-rules.js +1 -1
- package/dist/knowledge/scenario-modes.d.ts +2 -4
- package/dist/knowledge/scenario-modes.js +1 -1
- package/dist/knowledge/service-ledger.js +1 -1
- package/dist/knowledge/service-templates.js +1 -1
- package/dist/knowledge/settlement-semantics.d.ts +1 -0
- package/dist/knowledge/settlement-semantics.js +1 -0
- package/dist/knowledge/template-loader.d.ts +29 -2
- package/dist/knowledge/template-loader.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/template-scanner.d.ts +14 -0
- package/dist/knowledge/template-scanner.js +1 -1
- package/dist/knowledge/template-validation.d.ts +2 -0
- package/dist/knowledge/template-validation.js +1 -0
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/knowledge/workflow-guidance.d.ts +1 -0
- package/dist/knowledge/workflow-guidance.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/participation/allocation-advice.js +1 -1
- package/dist/participation/customer-interest.js +1 -1
- package/dist/participation/radar-core.d.ts +6 -1
- package/dist/participation/radar-core.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/game-theory.d.ts +2 -2
- package/dist/playbooks/service-build/game-theory.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/merchant-guide.d.ts +79 -13
- package/dist/playbooks/service-build/merchant-guide.js +1 -1
- package/dist/playbooks/service-build/migration-planner.d.ts +7 -0
- package/dist/playbooks/service-build/migration-planner.js +1 -1
- package/dist/playbooks/service-build/mode-actions.js +1 -1
- package/dist/playbooks/service-build/object-panorama.js +1 -1
- package/dist/playbooks/service-build/participation-radar.js +1 -1
- package/dist/playbooks/service-build/pipeline-actions.d.ts +1 -1
- 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-nk4.spec.d.ts +1 -0
- package/dist/playbooks/service-build/reverse-mapping-nk4.spec.js +1 -0
- package/dist/playbooks/service-build/reverse-mapping.d.ts +24 -0
- package/dist/playbooks/service-build/reverse-mapping.js +1 -1
- package/dist/playbooks/service-build/risk-aggregator.d.ts +1 -1
- package/dist/playbooks/service-build/risk-aggregator.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/playbooks/service-build/service-quote.spec.js +1 -1
- package/dist/playbooks/service-build/workflow-design-assessment.d.ts +2 -2
- package/dist/playbooks/service-build/workflow-design-assessment.js +1 -1
- package/dist/relationship/derivation.d.ts +1 -0
- package/dist/review/index.js +1 -1
- package/dist/runtime/instance-registry.d.ts +8 -0
- package/dist/runtime/instance-registry.js +1 -0
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/benchmark-migration/index.d.ts +14 -0
- package/dist/schema/benchmark-migration/index.js +1 -1
- package/dist/schema/call/arbitration.js +1 -1
- package/dist/schema/call/base.d.ts +109 -0
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +14 -0
- package/dist/schema/call/contact.js +1 -1
- package/dist/schema/call/error-codes.d.ts +1 -1
- package/dist/schema/call/error-codes.js +1 -1
- package/dist/schema/call/guard.d.ts +7 -0
- package/dist/schema/call/guard.js +1 -1
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/machine.d.ts +7 -0
- package/dist/schema/call/machine.js +1 -1
- package/dist/schema/call/payment.js +1 -1
- package/dist/schema/call/permission-handler.js +1 -1
- package/dist/schema/call/progress.d.ts +46 -0
- package/dist/schema/call/progress.js +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +22 -8
- package/dist/schema/call/service.js +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/goal/index.d.ts +11 -0
- package/dist/schema/goal/planning.d.ts +32 -1
- package/dist/schema/goal/planning.js +1 -1
- package/dist/schema/industry-pack/index.d.ts +40 -0
- package/dist/schema/industry-pack/index.js +1 -1
- package/dist/schema/keeper/index.d.ts +13 -0
- package/dist/schema/local/index.d.ts +75 -0
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/messenger/index.d.ts +17 -0
- package/dist/schema/messenger/index.js +1 -1
- package/dist/schema/operations.d.ts +46 -2
- package/dist/schema/operations.js +1 -1
- package/dist/schema/query/bi.d.ts +64 -0
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.d.ts +94 -0
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-version.d.ts +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/utils/permission-machine-check.js +1 -1
- 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 +45 -0
- package/dist/schemas/benchmark_migration_operation.output.json +24 -4
- package/dist/schemas/benchmark_migration_operation.schema.json +70 -0
- package/dist/schemas/bridge_operation.output.json +45 -0
- package/dist/schemas/goal_operation.schema.json +79 -1
- package/dist/schemas/guard2file.output.json +6 -1
- package/dist/schemas/guard2file.schema.json +9 -0
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/industry_pack_operation.output.json +91 -0
- package/dist/schemas/industry_pack_operation.schema.json +19 -1
- package/dist/schemas/keeper_operation.output.json +44 -0
- package/dist/schemas/local_cache_operation.output.json +45 -0
- package/dist/schemas/local_history_operation.output.json +45 -0
- package/dist/schemas/local_info_operation.output.json +45 -0
- package/dist/schemas/local_mark_operation.output.json +45 -0
- package/dist/schemas/machineNode2file.output.json +6 -1
- package/dist/schemas/machineNode2file.schema.json +9 -0
- package/dist/schemas/messenger_operation.output.json +52 -0
- package/dist/schemas/monitor_events.output.json +44 -0
- package/dist/schemas/monitor_subscription.output.json +44 -0
- package/dist/schemas/onchain_events.output.json +44 -0
- package/dist/schemas/onchain_operations.output.json +133 -0
- package/dist/schemas/onchain_operations.schema.json +110 -18
- package/dist/schemas/onchain_operations_arbitration.schema.json +2 -1
- package/dist/schemas/onchain_operations_contact.schema.json +2 -2
- package/dist/schemas/onchain_operations_guard.schema.json +2 -2
- 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_progress.schema.json +57 -0
- package/dist/schemas/onchain_operations_service.schema.json +44 -10
- package/dist/schemas/onchain_table_data.output.json +81 -13
- package/dist/schemas/onchain_table_data.schema.json +21 -21
- package/dist/schemas/query_toolkit.output.json +218 -9
- package/dist/schemas/query_toolkit.schema.json +50 -26
- package/dist/schemas/wowok_buildin_info.output.json +80 -1
- package/dist/schemas/wowok_buildin_info.schema.json +1 -1
- package/dist/tools/handlers/benchmark-migration.d.ts +3 -13
- package/dist/tools/handlers/benchmark-migration.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/file-export.js +1 -1
- package/dist/tools/handlers/industry-pack.js +1 -1
- package/dist/tools/handlers/messenger.js +1 -1
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/review-chain.d.ts +22 -0
- package/dist/tools/handlers/review-chain.js +1 -0
- package/dist/tools/registry/agent.js +1 -1
- package/dist/tools/registry/business.js +1 -1
- package/dist/tools/registry/config.js +1 -1
- package/dist/tools/registry/evaluation.js +1 -1
- package/dist/tools/registry/files.js +1 -1
- package/dist/tools/registry/identity.js +1 -1
- package/dist/tools/registry/local.js +1 -1
- package/dist/tools/registry/messenger.js +1 -1
- package/dist/tools/registry/monitor.js +1 -1
- package/dist/tools/registry/onchain.js +1 -1
- package/dist/tools/registry/query.js +1 -1
- package/dist/tools/rules-hook.js +1 -1
- package/dist/tools/runtime-health.d.ts +10 -0
- package/dist/tools/runtime-health.js +1 -0
- package/dist/tools/upgrade-check.d.ts +10 -1
- package/dist/tools/upgrade-check.js +1 -1
- package/dist/tools/wip-deploy-assist.js +1 -1
- package/dist/tools/wrap.d.ts +3 -0
- package/dist/tools/wrap.js +1 -1
- package/package.json +2 -2
- package/dist/playbooks/service-build/semantic-graph.d.ts +0 -99
- package/dist/playbooks/service-build/semantic-graph.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readdirSync,readFileSync,writeFileSync,existsSync,mkdirSync,statSync,cpSync,renameSync,rmSync}from'node:fs';import{join,relative,resolve,sep,dirname,basename}from'node:path';import{strictParse}from'../../schema/index.js';import{IndustryPackOperationInputSchema}from'../../schema/industry-pack/index.js';import{validateJudgmentFragment}from'../../config/judgment.js';import{scaffoldIndustryPack,listRegisteredPacks,scanDefaultIndustryPacks,seedBuiltinIndustryTemplates,seedBuiltinStrategyManuals,ensureIndustryReadme,resolveIndustryPackDir,rescanPack,resolveDisputeRules,resolveComplianceRules,resolveSupplyRules,resolveIndustryRules,resolveIndustryPlaybook,diffIndustryPack,resetIndustryPath}from'../../extensions/index.js';import{getIndustryModeRegistry}from'../../extensions/registry.js';import{handleRecommendIndustry,handleListModes,handleDeriveUserMode,handleEvolveUserMode,handleRegisterUserMode,handleUnregisterUserMode,handleRegisterCustomMetric,handleUnregisterCustomMetric,handleRegisterCustomConstraint,handleUnregisterCustomConstraint,handleListMetricsConstraints}from'../../playbooks/service-build/mode-actions.js';import{repairBuiltinTemplates,builtinTemplateDrift,resolveTemplatesDir}from'../../knowledge/template-loader.js';const INDUSTRY_ROOT=resolveIndustryPackDir(),resolveTemplatesDirSafe=resolveTemplatesDir;function resolveIndustryPath(a){const b=resolve(INDUSTRY_ROOT,a);if(b!==INDUSTRY_ROOT&&!b['startsWith'](INDUSTRY_ROOT+sep))throw new Error('path\x20\x27'+a+'\x27\x20escapes\x20the\x20industry\x20root');return b;}function isTemplateTreePath(a){const b=a['split'](/[\\/]+/)['filter'](c=>c['length']>0x0);return b['length']>=0x2&&b[0x1]==='templates';}function assertTemplateWriteAuthorized(a,b,c){if(c===!![])return;const d=b['find'](e=>e!==undefined&&isTemplateTreePath(e));if(!d)return;throw new Error('action=\x27'+a+'\x27\x20modifies\x20the\x20user-editable\x20template\x20file\x20\x27'+d+'\x27.\x20'+'Present\x20the\x20intended\x20change\x20to\x20the\x20user\x20first;\x20after\x20the\x20user\x20explicitly\x20confirms,\x20'+'re-call\x20with\x20authorize=true\x20(C5).');}function rescanAffectedPack(a){const b=a['split'](/[\\/]+/)['find'](c=>c['length']>0x0);if(!b)return;rescanPack(b);}const BASELINES_FILENAME='baselines.json',PACK_FILENAME='pack.json';function assertBaselinesContentValid(a,b){const c=a['split'](/[\\/]+/)['pop']()??'';if(c!==BASELINES_FILENAME&&c!==PACK_FILENAME)return;let d;try{d=JSON['parse'](b);}catch{return;}if(!d||typeof d!=='object'||Array['isArray'](d))return;const e=d,f=c===BASELINES_FILENAME?d:e['baselines'];if(f===undefined||f===null)return;const g=validateJudgmentFragment(f,a+'\x20baselines');if(g)throw new Error('write\x20rejected\x20—\x20the\x20baselines\x20fragment\x20in\x20\x27'+a+'\x27\x20is\x20not\x20a\x20valid\x20judgment\x20fragment:\x20'+g);}function listRecursive(a,b,c,d=0x0){if(d>0x8)return;let f;try{f=readdirSync(a,{'withFileTypes':!![]});}catch{return;}for(const g of f){const h=join(a,g['name']),i=relative(b,h)['split'](sep)['join']('/');let j=0x0,k=0x0;try{const l=statSync(h);k=l['size'],j=l['mtimeMs'];}catch{}g['isDirectory']()?(c['push']({'path':i,'is_dir':!![],'size':0x0,'mtime':j}),listRecursive(h,b,c,d+0x1)):c['push']({'path':i,'is_dir':![],'size':k,'mtime':j});}}export async function handleIndustryPackOperation(a){const b=strictParse(IndustryPackOperationInputSchema,a,'industry_pack_operation\x20input');mkdirSync(INDUSTRY_ROOT,{'recursive':!![]}),seedBuiltinIndustryTemplates(),seedBuiltinStrategyManuals(),ensureIndustryReadme();let c;switch(b['action']){case'scaffold':{if(!b['name'])throw new Error('\x27name\x27\x20is\x20required\x20for\x20action=\x27scaffold\x27');const d=scaffoldIndustryPack(b['name']);c={'action':'scaffold','ok':d['ok'],'dir':d['dir'],'files':d['files'],'errors':d['errors']};if(d['ok'])rescanPack(b['name']);break;}case'list':{c={'action':'list','packs':listRegisteredPacks()};break;}case'scan':{c={'action':'scan','results':scanDefaultIndustryPacks()};break;}case'repair_builtin_templates':{if(b['authorize']!==!![]){const g=repairBuiltinTemplates({'backup':!![],'dryRun':!![]}),h=g['filter'](i=>i['status']==='would_update');c={'action':'repair_builtin_templates','dir':resolveTemplatesDirSafe(),'reseeded_count':0x0,'requires_authorization':!![],'results':g,'note':h['length']?'PLAN\x20ONLY\x20(no\x20writes)\x20—\x20'+h['length']+'\x20legacy\x20sentinel-less\x20builtin\x20file(s)\x20would\x20be\x20reseeded\x20from\x20the\x20in-code\x20catalog,\x20each\x20previous\x20body\x20preserved\x20as\x20<file>.bak.\x20Present\x20this\x20plan\x20to\x20the\x20user;\x20after\x20the\x20user\x20explicitly\x20confirms,\x20re-call\x20with\x20authorize=true\x20to\x20execute.':'No\x20legacy\x20sentinel-less\x20builtin\x20files\x20found\x20—\x20every\x20builtin\x20template\x20already\x20carries\x20a\x20release\x20sentinel.'};break;}const e=repairBuiltinTemplates({'backup':!![]}),f=e['filter'](i=>i['status']==='updated');c={'action':'repair_builtin_templates','dir':resolveTemplatesDirSafe(),'reseeded_count':f['length'],'results':e,'note':f['length']?'Legacy\x20sentinel-less\x20builtin\x20files\x20were\x20reseeded\x20from\x20the\x20in-code\x20catalog.\x20Each\x20previous\x20body\x20is\x20preserved\x20as\x20<file>.bak.':'No\x20legacy\x20sentinel-less\x20builtin\x20files\x20found\x20—\x20every\x20builtin\x20template\x20already\x20carries\x20a\x20release\x20sentinel.'};break;}case'template_drift':{const i=builtinTemplateDrift();c={'action':'template_drift','dir':resolveTemplatesDirSafe(),'drift_count':i['length'],'drift':i,'note':i['length']?'On-disk\x20builtin\x20templates\x20differ\x20from\x20the\x20in-code\x20catalog.\x20Run\x20action=\x27repair_builtin_templates\x27\x20to\x20reseed.':'Every\x20builtin\x20template\x20on\x20disk\x20matches\x20the\x20in-code\x20catalog.'};break;}case'resolve':{c={'action':'resolve','dir':INDUSTRY_ROOT};break;}case'list_files':{const j=[];listRecursive(INDUSTRY_ROOT,INDUSTRY_ROOT,j),c={'action':'list_files','dir':INDUSTRY_ROOT,'files':j};break;}case'read_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27read_file\x27');const k=resolveIndustryPath(b['path']);if(!existsSync(k))throw new Error('file\x20not\x20found:\x20'+b['path']);c={'action':'read_file','path':k,'content':readFileSync(k,'utf-8')};break;}case'write_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27write_file\x27');if(b['content']===undefined)throw new Error('\x27content\x27\x20is\x20required\x20for\x20action=\x27write_file\x27');assertTemplateWriteAuthorized('write_file',[b['path']],b['authorize']);const l=resolveIndustryPath(b['path']);assertBaselinesContentValid(b['path'],b['content']),mkdirSync(dirname(l),{'recursive':!![]}),writeFileSync(l,b['content'],'utf-8'),c={'action':'write_file','path':l,'ok':!![]},rescanAffectedPack(b['path']);break;}case'get':{if(!b['name'])throw new Error('\x27name\x27\x20is\x20required\x20for\x20action=\x27get\x27');const m=b['name'],n=getIndustryModeRegistry()['getMode'](m),o=n?{'name':n['name'],'display_name':n['display_name'],'key_risk':n['key_risk'],'needs':n['needs']['map'](p=>p['description']),...n['analyze']?.['key_questions']?.['length']?{'analyze_questions':n['analyze']['key_questions']['slice'](0x0,0x2)}:{}}:undefined;c={'action':'get','category':m,...o?{'mode':o}:{},...resolveDisputeRules(m)?{'dispute':resolveDisputeRules(m)}:{},...resolveComplianceRules(m)?{'compliance':resolveComplianceRules(m)}:{},...resolveSupplyRules(m)?{'supply':resolveSupplyRules(m)}:{},...resolveIndustryRules(m)?{'rules':resolveIndustryRules(m)}:{},...resolveIndustryPlaybook(m)?{'playbook':resolveIndustryPlaybook(m)}:{}};break;}case'diff':{if(!b['name'])throw new Error('\x27name\x27\x20is\x20required\x20for\x20action=\x27diff\x27');c={'action':'diff',...diffIndustryPack(b['name'])};break;}case'reset':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27reset\x27');assertTemplateWriteAuthorized('reset',[b['path']],b['authorize']);const p=resetIndustryPath(b['path']);c={'action':'reset','ok':p['ok'],'layout':p['layout'],'target':p['target'],'restored_files':p['restored_files'],'errors':p['errors']},rescanAffectedPack(b['path']);break;}case'delete_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27delete_file\x27');assertTemplateWriteAuthorized('delete_file',[b['path']],b['authorize']);const q=resolveIndustryPath(b['path']);if(!existsSync(q))throw new Error('file\x20not\x20found:\x20'+b['path']);rmSync(q,{'recursive':!![],'force':!![]}),c={'action':'delete_file','path':q,'ok':!![]},rescanAffectedPack(b['path']);break;}case'create_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27create_file\x27');const t=resolveIndustryPath(b['path']);if(existsSync(t))throw new Error('file\x20already\x20exists:\x20'+b['path']);if(b['content']!==undefined)assertBaselinesContentValid(b['path'],b['content']);mkdirSync(dirname(t),{'recursive':!![]}),writeFileSync(t,b['content']??'','utf-8'),c={'action':'create_file','path':t,'ok':!![]},rescanAffectedPack(b['path']);break;}case'create_dir':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27create_dir\x27');const u=resolveIndustryPath(b['path']);mkdirSync(u,{'recursive':!![]}),c={'action':'create_dir','path':u,'ok':!![]},rescanAffectedPack(b['path']);break;}case'copy':{if(!b['from'])throw new Error('\x27from\x27\x20is\x20required\x20for\x20action=\x27copy\x27');if(!b['to'])throw new Error('\x27to\x27\x20is\x20required\x20for\x20action=\x27copy\x27');const v=resolveIndustryPath(b['from']);let w=resolveIndustryPath(b['to']);if(!existsSync(v))throw new Error('source\x20not\x20found:\x20'+b['from']);try{existsSync(w)&&statSync(w)['isDirectory']()&&(w=join(w,basename(v)));}catch{}if(w===v)throw new Error('\x27copy\x27\x20cannot\x20copy\x20a\x20file\x20onto\x20itself');existsSync(w)&&isTemplateTreePath(b['to'])&&assertTemplateWriteAuthorized('copy',[b['to']],b['authorize']);mkdirSync(dirname(w),{'recursive':!![]}),cpSync(v,w,{'recursive':!![],'force':!![]}),c={'action':'copy','from':v,'to':w,'ok':!![]},rescanAffectedPack(b['to']);break;}case'move':case'rename':{if(!b['from'])throw new Error('\x27from\x27\x20is\x20required\x20for\x20action=\x27'+b['action']+'\x27');if(!b['to'])throw new Error('\x27to\x27\x20is\x20required\x20for\x20action=\x27'+b['action']+'\x27');assertTemplateWriteAuthorized(b['action'],[b['from'],b['to']],b['authorize']);const x=resolveIndustryPath(b['from']);let y=resolveIndustryPath(b['to']);if(!existsSync(x))throw new Error('source\x20not\x20found:\x20'+b['from']);try{existsSync(y)&&statSync(y)['isDirectory']()&&(y=join(y,basename(x)));}catch{}if(y===x)throw new Error('\x27'+b['action']+'\x27\x20cannot\x20move\x20onto\x20itself');mkdirSync(dirname(y),{'recursive':!![]}),renameSync(x,y),c={'action':b['action'],'from':x,'to':y,'ok':!![]},rescanAffectedPack(b['from']),rescanAffectedPack(b['to']);break;}case'recommend_industry':c=await handleRecommendIndustry(b);break;case'list_modes':c=await handleListModes();break;case'derive_user_mode':c=await handleDeriveUserMode(b);break;case'evolve_user_mode':c=await handleEvolveUserMode(b);break;case'register_user_mode':c=await handleRegisterUserMode(b);break;case'unregister_user_mode':c=await handleUnregisterUserMode(b);break;case'register_custom_metric':c=await handleRegisterCustomMetric(b);break;case'unregister_custom_metric':c=await handleUnregisterCustomMetric(b);break;case'register_custom_constraint':c=await handleRegisterCustomConstraint(b);break;case'unregister_custom_constraint':c=await handleUnregisterCustomConstraint(b);break;case'list_metrics_constraints':c=await handleListMetricsConstraints(b);break;default:throw new Error('Unknown\x20industry_pack_operation\x20action:\x20'+String(b['action']));}return{'content':[{'type':'text','text':JSON['stringify']({'result':c})}],'structuredContent':{'result':c}};}
|
|
1
|
+
import{readdirSync,readFileSync,writeFileSync,existsSync,mkdirSync,statSync,cpSync,renameSync,rmSync}from'node:fs';import{join,relative,resolve,sep,dirname,basename}from'node:path';import{strictParse}from'../../schema/index.js';import{IndustryPackOperationInputSchema}from'../../schema/industry-pack/index.js';import{validateJudgmentFragment}from'../../config/judgment.js';import{scaffoldIndustryPack,listRegisteredPacks,getRegisteredPack,packKind,scanDefaultIndustryPacks,seedBuiltinIndustryTemplates,seedBuiltinStrategyManuals,ensureIndustryReadme,resolveIndustryPackDir,rescanPack,resolveDisputeRules,resolveComplianceRules,resolveSupplyRules,resolveIndustryRules,resolveIndustryPlaybook,diffIndustryPack,resetIndustryPath}from'../../extensions/index.js';import{getIndustryModeRegistry}from'../../extensions/registry.js';import{getBuiltinTemplate,listBuiltinTemplates}from'../../knowledge/builtin-templates.js';import{handleRecommendIndustry,handleListModes,handleDeriveUserMode,handleEvolveUserMode,handleRegisterUserMode,handleUnregisterUserMode,handleRegisterCustomMetric,handleUnregisterCustomMetric,handleRegisterCustomConstraint,handleUnregisterCustomConstraint,handleListMetricsConstraints}from'../../playbooks/service-build/mode-actions.js';import{repairBuiltinTemplates,builtinTemplateDrift,resolveTemplatesDir,parseTemplateFile,TemplateFrontmatterSchema}from'../../knowledge/template-loader.js';const INDUSTRY_ROOT=resolveIndustryPackDir(),resolveTemplatesDirSafe=resolveTemplatesDir;function resolveIndustryPath(a){const b=resolve(INDUSTRY_ROOT,a);if(b!==INDUSTRY_ROOT&&!b['startsWith'](INDUSTRY_ROOT+sep))throw new Error('path\x20\x27'+a+'\x27\x20escapes\x20the\x20industry\x20root');return b;}function isTemplateTreePath(a){const b=a['split'](/[\\/]+/)['filter'](c=>c['length']>0x0);return b['length']>=0x2&&b[0x1]==='templates';}function assertTemplateWriteAuthorized(a,b,c){if(c===!![])return;const d=b['find'](e=>e!==undefined&&isTemplateTreePath(e));if(!d)return;throw new Error('action=\x27'+a+'\x27\x20modifies\x20the\x20user-editable\x20template\x20file\x20\x27'+d+'\x27.\x20'+'Present\x20the\x20intended\x20change\x20to\x20the\x20user\x20first;\x20after\x20the\x20user\x20explicitly\x20confirms,\x20'+'re-call\x20with\x20authorize=true\x20(C5).');}function rescanAffectedPack(a){const b=a['split'](/[\\/]+/)['find'](c=>c['length']>0x0);if(!b)return;rescanPack(b);}const BASELINES_FILENAME='baselines.json',PACK_FILENAME='pack.json';function assertBaselinesContentValid(a,b){const c=a['split'](/[\\/]+/)['pop']()??'';if(c!==BASELINES_FILENAME&&c!==PACK_FILENAME)return;let d;try{d=JSON['parse'](b);}catch{return;}if(!d||typeof d!=='object'||Array['isArray'](d))return;const e=d,f=c===BASELINES_FILENAME?d:e['baselines'];if(f===undefined||f===null)return;const g=validateJudgmentFragment(f,a+'\x20baselines');if(g)throw new Error('write\x20rejected\x20—\x20the\x20baselines\x20fragment\x20in\x20\x27'+a+'\x27\x20is\x20not\x20a\x20valid\x20judgment\x20fragment:\x20'+g);}function assertTemplateContentValid(a,b){if(!isTemplateTreePath(a)||!a['endsWith']('.md'))return;let c;try{({frontmatter:c}=parseTemplateFile(b));}catch(e){throw new Error('write\x20rejected\x20—\x20\x27'+a+'\x27\x20is\x20a\x20template\x20file\x20but\x20the\x20frontmatter\x20block\x20is\x20malformed:\x20'+e['message']);}const d=TemplateFrontmatterSchema['safeParse'](c);if(!d['success']){const f=d['error']['issues']['map'](g=>'\x20\x20'+g['path']['join']('.')+':\x20'+g['message'])['join']('\x0a');throw new Error('write\x20rejected\x20—\x20the\x20template\x20frontmatter\x20in\x20\x27'+a+'\x27\x20violates\x20the\x20schema\x20(the\x20editor\x20whitelist\x20IS\x20the\x20zod\x20schema):\x0a'+f);}}function listRecursive(a,b,c,d=0x0){if(d>0x8)return;let f;try{f=readdirSync(a,{'withFileTypes':!![]});}catch{return;}for(const g of f){const h=join(a,g['name']),i=relative(b,h)['split'](sep)['join']('/');let j=0x0,k=0x0;try{const l=statSync(h);k=l['size'],j=l['mtimeMs'];}catch{}g['isDirectory']()?(c['push']({'path':i,'is_dir':!![],'size':0x0,'mtime':j}),listRecursive(h,b,c,d+0x1)):c['push']({'path':i,'is_dir':![],'size':k,'mtime':j});}}export async function handleIndustryPackOperation(a){const b=strictParse(IndustryPackOperationInputSchema,a,'industry_pack_operation\x20input');mkdirSync(INDUSTRY_ROOT,{'recursive':!![]}),seedBuiltinIndustryTemplates(),seedBuiltinStrategyManuals(),ensureIndustryReadme();let c;switch(b['action']){case'scaffold':{if(!b['name'])throw new Error('\x27name\x27\x20is\x20required\x20for\x20action=\x27scaffold\x27');const d=scaffoldIndustryPack(b['name']);c={'action':'scaffold','ok':d['ok'],'dir':d['dir'],'files':d['files'],'errors':d['errors']};if(d['ok'])rescanPack(b['name']);break;}case'list':{c={'action':'list','packs':listRegisteredPacks()};break;}case'scan':{c={'action':'scan','results':scanDefaultIndustryPacks()};break;}case'repair_builtin_templates':{if(b['authorize']!==!![]){const g=repairBuiltinTemplates({'backup':!![],'dryRun':!![]}),h=g['filter'](i=>i['status']==='would_update');c={'action':'repair_builtin_templates','dir':resolveTemplatesDirSafe(),'reseeded_count':0x0,'requires_authorization':!![],'results':g,'note':h['length']?'PLAN\x20ONLY\x20(no\x20writes)\x20—\x20'+h['length']+'\x20builtin\x20file(s)\x20differ\x20from\x20the\x20in-code\x20catalog\x20and\x20would\x20be\x20reseeded\x20(each\x20result\x20carries\x20a\x20field-level\x20diff;\x20previous\x20bodies\x20preserved\x20as\x20<file>.bak).\x20Present\x20this\x20plan\x20to\x20the\x20user;\x20after\x20the\x20user\x20explicitly\x20confirms,\x20re-call\x20with\x20authorize=true\x20to\x20execute.':'Nothing\x20to\x20repair\x20—\x20every\x20on-disk\x20builtin\x20template\x20either\x20matches\x20the\x20in-code\x20catalog\x20or\x20carries\x20user\x20edits\x20(which\x20are\x20never\x20overwritten).'};break;}const e=repairBuiltinTemplates({'backup':!![]}),f=e['filter'](i=>i['status']==='updated');c={'action':'repair_builtin_templates','dir':resolveTemplatesDirSafe(),'reseeded_count':f['length'],'results':e,'note':f['length']?'Diverging\x20builtin\x20files\x20were\x20reseeded\x20from\x20the\x20in-code\x20catalog.\x20Each\x20previous\x20body\x20is\x20preserved\x20as\x20<file>.bak.':'Nothing\x20repaired\x20—\x20every\x20on-disk\x20builtin\x20template\x20either\x20matches\x20the\x20in-code\x20catalog\x20or\x20carries\x20user\x20edits\x20(which\x20are\x20never\x20overwritten).'};break;}case'template_drift':{const i=builtinTemplateDrift(),j=i['filter'](k=>k['repairable'])['length'];c={'action':'template_drift','dir':resolveTemplatesDirSafe(),'drift_count':i['length'],'repairable_count':j,'drift':i,'note':i['length']?j>0x0?j+'\x20of\x20'+i['length']+'\x20diverging\x20builtin\x20template(s)\x20can\x20be\x20reseeded\x20without\x20losing\x20user\x20work\x20—\x20run\x20action=\x27repair_builtin_templates\x27\x20(plan-only\x20preview\x20first,\x20then\x20authorize=true\x20after\x20the\x20user\x20confirms).\x20The\x20rest\x20carry\x20user\x20edits\x20and\x20are\x20never\x20overwritten.':'All\x20diverging\x20builtin\x20templates\x20carry\x20user\x20edits\x20—\x20never\x20overwritten\x20automatically;\x20resolve\x20by\x20hand\x20or\x20via\x20an\x20authorized\x20write.':'Every\x20builtin\x20template\x20on\x20disk\x20matches\x20the\x20in-code\x20catalog.'};break;}case'resolve':{c={'action':'resolve','dir':INDUSTRY_ROOT};break;}case'list_files':{const k=[];listRecursive(INDUSTRY_ROOT,INDUSTRY_ROOT,k),c={'action':'list_files','dir':INDUSTRY_ROOT,'files':k};break;}case'read_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27read_file\x27');const l=resolveIndustryPath(b['path']);if(!existsSync(l))throw new Error('file\x20not\x20found:\x20'+b['path']);c={'action':'read_file','path':l,'content':readFileSync(l,'utf-8')};break;}case'write_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27write_file\x27');if(b['content']===undefined)throw new Error('\x27content\x27\x20is\x20required\x20for\x20action=\x27write_file\x27');assertTemplateWriteAuthorized('write_file',[b['path']],b['authorize']);const m=resolveIndustryPath(b['path']);assertBaselinesContentValid(b['path'],b['content']),assertTemplateContentValid(b['path'],b['content']),mkdirSync(dirname(m),{'recursive':!![]}),writeFileSync(m,b['content'],'utf-8'),c={'action':'write_file','path':m,'ok':!![]},rescanAffectedPack(b['path']);break;}case'get':{if(!b['name'])throw new Error('\x27name\x27\x20is\x20required\x20for\x20action=\x27get\x27');const n=b['name'],o=getRegisteredPack(n),p=o?.['layers']??[],q=()=>o?{'kind':packKind(p),'layers':p}:{},u=()=>{const x=getIndustryModeRegistry()['getMode'](n);return x?{'name':x['name'],'display_name':x['display_name'],'key_risk':x['key_risk'],'needs':x['needs']['map'](y=>y['description']),...x['analyze']?.['key_questions']?.['length']?{'analyze_questions':x['analyze']['key_questions']['slice'](0x0,0x2)}:{}}:undefined;};if(b['layer']==='template'){if(b['template']){const x=getBuiltinTemplate(b['template']);if(!x)throw new Error('template\x20\x27'+b['template']+'\x27\x20is\x20not\x20in\x20the\x20builtin\x20catalog\x20'+('(available:\x20'+listBuiltinTemplates()['map'](y=>y['id'])['join'](',\x20')+')'));if(x['industry']!==n)throw new Error('template\x20\x27'+x['id']+'\x27\x20belongs\x20to\x20industry\x20\x27'+x['industry']+'\x27,\x20not\x20\x27'+n+'\x27\x20—\x20'+'set\x20\x27name\x27\x20to\x20the\x20template\x27s\x20industry');c={'action':'get','category':n,'layer':'template','template':JSON['parse'](JSON['stringify'](x))};}else{const y=listBuiltinTemplates()['filter'](z=>z['industry']===n)['map'](z=>({'id':z['id'],'variant':z['variant'],'product_ref':z['product_ref'],'key_risk':z['key_risk']}));if(!y['length'])throw new Error('industry\x20\x27'+n+'\x27\x20has\x20no\x20builtin\x20templates\x20(ids\x20use\x20\x27<industry>/<variant>\x27)');c={'action':'get','category':n,'layer':'template','templates':y,'note':'Re-call\x20with\x20layer=\x27template\x27\x20+\x20template=\x27<id>\x27\x20for\x20the\x20full\x20projection\x20'+'(machine_shape/guards/allocator\x20rows/fee_params/build_notes).'};}break;}if(b['layer']){const z=b['layer'];if(z==='match')throw new Error('layer\x20\x27match\x27\x20is\x20consumed\x20internally\x20by\x20the\x20recommend\x20matching\x20flow\x20—\x20not\x20exposed\x20via\x20get');if(!p['includes'](z))throw new Error('pack\x20\x27'+n+'\x27\x20does\x20not\x20register\x20layer\x20\x27'+z+'\x27'+(o?'\x20(kind='+packKind(p)+',\x20layers=['+p['join'](',\x20')+'])':'\x20(the\x20pack\x20is\x20not\x20registered)')+(z!=='mode'?';\x20layer=\x27template\x27\x20reads\x20the\x20builtin\x20catalog\x20instead\x20if\x20that\x20is\x20what\x20you\x20need':''));const A=z==='mode'?u():z==='dispute'?resolveDisputeRules(n):z==='compliance'?resolveComplianceRules(n):z==='supply'?resolveSupplyRules(n):z==='rules'?resolveIndustryRules(n):resolveIndustryPlaybook(n);if(A===undefined)throw new Error('layer\x20\x27'+z+'\x27\x20is\x20registered\x20for\x20pack\x20\x27'+n+'\x27\x20but\x20resolved\x20to\x20no\x20data');c={'action':'get','category':n,'layer':z,[z]:A,...q()};break;}const v=u(),w=['dispute','compliance','supply','rules','playbook']['filter'](B=>!p['includes'](B));c={'action':'get','category':n,...q(),...v?{'mode':v}:{},...resolveDisputeRules(n)?{'dispute':resolveDisputeRules(n)}:{},...resolveComplianceRules(n)?{'compliance':resolveComplianceRules(n)}:{},...resolveSupplyRules(n)?{'supply':resolveSupplyRules(n)}:{},...resolveIndustryRules(n)?{'rules':resolveIndustryRules(n)}:{},...resolveIndustryPlaybook(n)?{'playbook':resolveIndustryPlaybook(n)}:{},...w['length']?{'missing_layers':w,'note':'pack\x20\x27'+n+'\x27\x20('+(o?packKind(p):'unregistered')+')\x20does\x20not\x20register\x20'+('['+w['join'](',\x20')+']\x20—\x20stub\x20packs\x20(builtin-mode\x20aliases)\x20carry\x20only\x20mode/match\x20')+'data;\x20scaffold\x20a\x20pack\x20or\x20place\x20a\x20pack.json\x20to\x20add\x20business\x20layers.'}:{}};break;}case'diff':{if(!b['name'])throw new Error('\x27name\x27\x20is\x20required\x20for\x20action=\x27diff\x27');c={'action':'diff',...diffIndustryPack(b['name'])};break;}case'reset':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27reset\x27');assertTemplateWriteAuthorized('reset',[b['path']],b['authorize']);const B=resetIndustryPath(b['path']);c={'action':'reset','ok':B['ok'],'layout':B['layout'],'target':B['target'],'restored_files':B['restored_files'],'errors':B['errors']},rescanAffectedPack(b['path']);break;}case'delete_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27delete_file\x27');assertTemplateWriteAuthorized('delete_file',[b['path']],b['authorize']);const C=resolveIndustryPath(b['path']);if(!existsSync(C))throw new Error('file\x20not\x20found:\x20'+b['path']);rmSync(C,{'recursive':!![],'force':!![]}),c={'action':'delete_file','path':C,'ok':!![]},rescanAffectedPack(b['path']);break;}case'create_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27create_file\x27');const D=resolveIndustryPath(b['path']);if(existsSync(D))throw new Error('file\x20already\x20exists:\x20'+b['path']);if(b['content']!==undefined)assertBaselinesContentValid(b['path'],b['content']);mkdirSync(dirname(D),{'recursive':!![]}),writeFileSync(D,b['content']??'','utf-8'),c={'action':'create_file','path':D,'ok':!![]},rescanAffectedPack(b['path']);break;}case'create_dir':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27create_dir\x27');const E=resolveIndustryPath(b['path']);mkdirSync(E,{'recursive':!![]}),c={'action':'create_dir','path':E,'ok':!![]},rescanAffectedPack(b['path']);break;}case'copy':{if(!b['from'])throw new Error('\x27from\x27\x20is\x20required\x20for\x20action=\x27copy\x27');if(!b['to'])throw new Error('\x27to\x27\x20is\x20required\x20for\x20action=\x27copy\x27');const F=resolveIndustryPath(b['from']);let G=resolveIndustryPath(b['to']);if(!existsSync(F))throw new Error('source\x20not\x20found:\x20'+b['from']);try{existsSync(G)&&statSync(G)['isDirectory']()&&(G=join(G,basename(F)));}catch{}if(G===F)throw new Error('\x27copy\x27\x20cannot\x20copy\x20a\x20file\x20onto\x20itself');existsSync(G)&&isTemplateTreePath(b['to'])&&assertTemplateWriteAuthorized('copy',[b['to']],b['authorize']);mkdirSync(dirname(G),{'recursive':!![]}),cpSync(F,G,{'recursive':!![],'force':!![]}),c={'action':'copy','from':F,'to':G,'ok':!![]},rescanAffectedPack(b['to']);break;}case'move':case'rename':{if(!b['from'])throw new Error('\x27from\x27\x20is\x20required\x20for\x20action=\x27'+b['action']+'\x27');if(!b['to'])throw new Error('\x27to\x27\x20is\x20required\x20for\x20action=\x27'+b['action']+'\x27');assertTemplateWriteAuthorized(b['action'],[b['from'],b['to']],b['authorize']);const H=resolveIndustryPath(b['from']);let I=resolveIndustryPath(b['to']);if(!existsSync(H))throw new Error('source\x20not\x20found:\x20'+b['from']);try{existsSync(I)&&statSync(I)['isDirectory']()&&(I=join(I,basename(H)));}catch{}if(I===H)throw new Error('\x27'+b['action']+'\x27\x20cannot\x20move\x20onto\x20itself');mkdirSync(dirname(I),{'recursive':!![]}),renameSync(H,I),c={'action':b['action'],'from':H,'to':I,'ok':!![]},rescanAffectedPack(b['from']),rescanAffectedPack(b['to']);break;}case'recommend_industry':c=await handleRecommendIndustry(b);break;case'list_modes':c=await handleListModes();break;case'derive_user_mode':c=await handleDeriveUserMode(b);break;case'evolve_user_mode':c=await handleEvolveUserMode(b);break;case'register_user_mode':c=await handleRegisterUserMode(b);break;case'unregister_user_mode':c=await handleUnregisterUserMode(b);break;case'register_custom_metric':c=await handleRegisterCustomMetric(b);break;case'unregister_custom_metric':c=await handleUnregisterCustomMetric(b);break;case'register_custom_constraint':c=await handleRegisterCustomConstraint(b);break;case'unregister_custom_constraint':c=await handleUnregisterCustomConstraint(b);break;case'list_metrics_constraints':c=await handleListMetricsConstraints(b);break;default:throw new Error('Unknown\x20industry_pack_operation\x20action:\x20'+String(b['action']));}return{'content':[{'type':'text','text':JSON['stringify']({'result':c})}],'structuredContent':{'result':c}};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{strictParse,MessengerOperationInputSchema}from'../../schema/index.js';import{watch_conversations,send_message,send_file,watch_messages,export_attachment,pull_messages,generate_wts,verify_wts,sign_wts,wts2html,proof_message,mark_messages_as_viewed,mark_conversation_as_viewed,blacklist,friendslist,guardlist,settings,LocalInfo}from'@wowok/wowok';import{classifyError,buildDataSemantic}from'../../schema/call/semantic.js';import{classifyCommunicationEvidence}from'../../communication/evidence.js';import{noteProofIssued}from'../../communication/proof-reuse.js';import{attestWtsFile}from'../../communication/wts-attestation.js';import{goalEngine}from'../../goal/GoalEngine.js';export function normalizeAccountOrMark(a){if(typeof a==='string')return{'name_or_address':a,'local_mark_first':!![]};return a;}export function normalizeOptionalAccountOrMark(a){if(a===undefined||a===null)return undefined;return normalizeAccountOrMark(a);}export function normalizeManyAccountOrMark(a){if(a===undefined||a===null)return undefined;if(Array['isArray'](a))return{'entities':a['map'](b=>typeof b==='string'?{'name_or_address':b,'local_mark_first':!![]}:b),'check_all_founded':!![]};return a;}function communicationEvidencePayload(a,b){const c=b??{};switch(a){case'send_message':case'send_file':{const d=typeof c['messageId']==='string'?c['messageId']:undefined;return{'detail':d?'message\x20'+d:'message\x20sent','data':d?{'message_id':d}:{}};}case'send_required_info':{const e=typeof c['messageId']==='string'?c['messageId']:undefined,f=Array['isArray'](c['sent_fields'])?c['sent_fields']:undefined;return{'detail':'required-info\x20confirmation\x20sent','data':{...e?{'message_id':e}:{},...f?{'sent_fields':f}:{}}};}case'generate_wts':{const g=typeof c['totalMessageCount']==='number'?c['totalMessageCount']:undefined,h=Array['isArray'](c['files'])?c['files']:undefined,i=Array['isArray'](c['htmlFiles'])?c['htmlFiles']:undefined;return{'detail':'WTS\x20evidence\x20packet\x20generated','data':{...g!==undefined?{'message_count':g}:{},...h?{'files':h}:{},...i?{'html_reports':i}:{}}};}case'verify_wts':{const j=c['attestation'],k=typeof c['error']==='string'?c['error']:undefined;return{'detail':j?'WTS\x20verification\x20—\x20'+j['attested_count']+'/'+j['total_messages']+'\x20message(s)\x20server-attested':'WTS\x20verification\x20—\x20server\x20attestation\x20unavailable','data':{'valid':c['valid']===!![],'hash_valid':c['hashValid']===!![],'has_signature':c['hasSignature']===!![],...c['signatureValid']===undefined?{}:{'packet_signature_valid':c['signatureValid']===!![]},...k?{'error':k}:{},...j?{'attested_messages':j['attested_count'],'total_messages':j['total_messages'],'fully_attested':j['fully_attested'],'packet_signed':j['packet_signed'],'server_public_keys':j['server_public_keys'],'verdict':j['verdict']}:{'attestation':'unavailable\x20—\x20cross-check\x20the\x20seal\x20signer\x20and\x20server\x20keys\x20independently\x20before\x20treating\x20the\x20packet\x20as\x20third-party\x20evidence'}}};}case'sign_wts':{return{'detail':typeof b==='string'?b:'WTS\x20evidence\x20signed','data':{}};}case'proof_message':{const l=typeof c['proofAddress']==='string'?c['proofAddress']:undefined;return{'detail':l?'proof\x20'+l:'message\x20proofed\x20on-chain','data':l?{'proof_address':l}:{}};}default:return{'detail':a,'data':{}};}}export async function handleMessengerOperation(a){let b;try{b=strictParse(MessengerOperationInputSchema,a,'messenger_operation\x20input');const c=b['operation'];let d;switch(b['operation']){case'watch_conversations':{const g=await watch_conversations(b['filter']);d={'operation':'watch_conversations','result':g};break;}case'send_message':{const h=await send_message(normalizeOptionalAccountOrMark(b['from']),normalizeAccountOrMark(b['to']),b['content'],b['options']);if(h['authRequired']){d={'operation':'send_message','result':h};break;}const i=h,j={...i,'merkleData':i['merkleData']?{'leafIndex':i['merkleData']['leafIndex'],'prevRoot':i['merkleData']['prevRoot'],'newRoot':i['merkleData']['newRoot'],'serverSignature':i['merkleData']['serverSignature'],'serverTimestamp':i['merkleData']['serverTimestamp'],'serverPublicKey':i['merkleData']['serverPublicKey']}:undefined};d={'operation':'send_message','result':j};break;}case'send_file':{const k=await send_file(normalizeOptionalAccountOrMark(b['from']),normalizeAccountOrMark(b['to']),b['filePath'],b['options']),l=k,m={...l,'merkleData':l['merkleData']?{'leafIndex':l['merkleData']['leafIndex'],'prevRoot':l['merkleData']['prevRoot'],'newRoot':l['merkleData']['newRoot'],'serverSignature':l['merkleData']['serverSignature'],'serverTimestamp':l['merkleData']['serverTimestamp'],'serverPublicKey':l['merkleData']['serverPublicKey']}:undefined};d={'operation':'send_file','result':m};break;}case'send_required_info':{let n=b['content'];const o=[];if(!n){const s=await LocalInfo['Instance']()['list'](),t=b['fields'],u=t&&t['length']>0x0?s['filter'](v=>t['includes'](v['name'])):s;if(u['length']===0x0)throw new Error('No\x20LocalInfo\x20fields\x20available.\x20Add\x20private\x20info\x20first\x20via\x20local_info_operation.');n=u['map'](v=>v['name']+':\x20'+v['default'])['join']('\x0a'),o['push'](...u['map'](v=>v['name']));}const p=await send_message(normalizeOptionalAccountOrMark(b['from']),normalizeAccountOrMark(b['to']),n,b['options']),q=p,r={...q,'merkleData':q['merkleData']?{'leafIndex':q['merkleData']['leafIndex'],'prevRoot':q['merkleData']['prevRoot'],'newRoot':q['merkleData']['newRoot'],'serverSignature':q['merkleData']['serverSignature'],'serverTimestamp':q['merkleData']['serverTimestamp'],'serverPublicKey':q['merkleData']['serverPublicKey']}:undefined,'sent_fields':o};d={'operation':'send_required_info','result':r};break;}case'watch_messages':{const v=b['filter']?{...b['filter'],'peerAddress':b['filter']['peerAddress']?normalizeAccountOrMark(b['filter']['peerAddress']):undefined,'account':b['filter']['account']?normalizeOptionalAccountOrMark(b['filter']['account']):undefined}:undefined,w=await watch_messages(v);d={'operation':'watch_messages','result':w};break;}case'save_attachment':{const x=await export_attachment(normalizeOptionalAccountOrMark(b['account']),b['messageId'],{'outputDir':b['outputDir'],'saveAs':b['saveAs']});d={'operation':'save_attachment','result':x};break;}case'generate_wts':{const y=b['params']?{...b['params'],'peerAccount':normalizeAccountOrMark(b['params']['peerAccount']),'myAccount':normalizeOptionalAccountOrMark(b['params']['myAccount'])}:undefined,z=await generate_wts(y);d={'operation':'generate_wts','result':z};break;}case'verify_wts':{const A=await verify_wts(b['wtsFilePath']),B=await attestWtsFile(b['wtsFilePath']);d={'operation':'verify_wts','result':B?{...A,'attestation':B}:{...A,'attestation_unavailable':'Per-message\x20server\x20attestation\x20could\x20not\x20be\x20computed\x20(file\x20not\x20readable\x20locally\x20or\x20not\x20JSON).\x20The\x20guarded\x20verifier\x27s\x20valid\x20flag\x20already\x20required\x20server\x20attestation\x20+\x20seal;\x20cross-check\x20the\x20seal\x20signer\x20and\x20server\x20keys\x20yourself\x20before\x20treating\x20it\x20as\x20third-party\x20evidence.'}};break;}case'sign_wts':{const C=await sign_wts(b['wtsFilePath'],normalizeOptionalAccountOrMark(b['account']),b['outputPath']);d={'operation':'sign_wts','result':C};break;}case'wts2html':{const D=await wts2html(b['wtsPath'],b['options']);d={'operation':'wts2html','result':D};break;}case'proof_message':{const E=await proof_message(normalizeOptionalAccountOrMark(b['account']),b['messageId'],b['network']),F=E?.['proofAddress'];if(typeof F==='string')noteProofIssued(F);d={'operation':'proof_message','result':E};break;}case'blacklist':{const G={'account':normalizeOptionalAccountOrMark(b['account']),'op':b['blacklist']['op']};'users'in b['blacklist']&&(G['users']=normalizeManyAccountOrMark(b['blacklist']['users']));const H=await blacklist(G);d={'operation':'blacklist','op':b['blacklist']['op'],'result':H['result']};break;}case'friendslist':{const I={'account':normalizeOptionalAccountOrMark(b['account']),'op':b['friendslist']['op']};'users'in b['friendslist']&&(I['users']=normalizeManyAccountOrMark(b['friendslist']['users']));const J=await friendslist(I);d={'operation':'friendslist','op':b['friendslist']['op'],'result':J['result']};break;}case'guardlist':{const K=await guardlist({'account':normalizeOptionalAccountOrMark(b['account']),...b['guardlist']});d={'operation':'guardlist','op':b['guardlist']['op'],'result':K['result']};break;}case'settings':{const L=await settings({'account':normalizeOptionalAccountOrMark(b['account']),...b['settings']});d={'operation':'settings','op':b['settings']['op'],'result':L['result']};break;}case'mark_messages_as_viewed':{const M=await mark_messages_as_viewed(b['messageIds'],normalizeOptionalAccountOrMark(b['account']));d={'operation':'mark_messages_as_viewed','result':M};break;}case'mark_conversation_as_viewed':{const N=await mark_conversation_as_viewed(normalizeAccountOrMark(b['peerAddress']),normalizeOptionalAccountOrMark(b['account']));d={'operation':'mark_conversation_as_viewed','result':N};break;}case'pull_messages':{const O=await pull_messages(normalizeOptionalAccountOrMark(b['account']),b['limit'],{'allAccounts':b['allAccounts'],'accounts':b['accounts']?.['map'](P=>normalizeAccountOrMark(P)),'concurrency':b['concurrency']});d={'operation':'pull_messages','result':O};break;}default:throw new Error('Unknown\x20messenger\x20operation:\x20'+c);}const e=classifyCommunicationEvidence(c),f=b['goal_id'];if(e&&f){const P=d['result'],{detail:Q,data:R}=communicationEvidencePayload(c,P);await goalEngine['recordCommunicationEvidence'](f,{'operation':c,'kind':e['kind'],'title':e['title'],'detail':Q,'data':R},b['network']??'default');}return{'content':[{'type':'text','text':JSON['stringify'](d)}],'structuredContent':{'result':d}};}catch(S){const T=S instanceof Error?S['message']:String(S),U=b?{'operation_type':'messenger_'+b['operation'],'data':b}:undefined,V=classifyError(T),W={'operation':'error','error':T};if(V['error_code']!==undefined)W['error_code']=V['error_code'];if(V['retryable']!==undefined)W['retryable']=V['retryable'];if(V['recovery_hint']!==undefined)W['recovery_hint']=V['recovery_hint'];return{'content':[{'type':'text','text':'Error:\x20'+T}],'structuredContent':{'result':W,'semantic':buildDataSemantic(undefined,U,!![],T)}};}}
|
|
1
|
+
import{strictParse,MessengerOperationInputSchema}from'../../schema/index.js';import{watch_conversations,send_message,send_file,watch_messages,export_attachment,pull_messages,generate_wts,verify_wts,sign_wts,wts2html,proof_message,mark_messages_as_viewed,mark_conversation_as_viewed,blacklist,friendslist,guardlist,settings,LocalInfo,Config}from'@wowok/wowok';import{classifyError,buildDataSemantic}from'../../schema/call/semantic.js';import{classifyCommunicationEvidence}from'../../communication/evidence.js';import{noteProofIssued}from'../../communication/proof-reuse.js';import{isModuleLoadError,noteRuntimeModuleFault}from'../runtime-health.js';import{attestWtsFile}from'../../communication/wts-attestation.js';import{goalEngine}from'../../goal/GoalEngine.js';export function normalizeAccountOrMark(a){if(typeof a==='string')return{'name_or_address':a,'local_mark_first':!![]};return a;}export function normalizeOptionalAccountOrMark(a){if(a===undefined||a===null)return undefined;return normalizeAccountOrMark(a);}export function normalizeManyAccountOrMark(a){if(a===undefined||a===null)return undefined;if(Array['isArray'](a))return{'entities':a['map'](b=>typeof b==='string'?{'name_or_address':b,'local_mark_first':!![]}:b),'check_all_founded':!![]};return a;}function communicationEvidencePayload(a,b){const c=b??{};switch(a){case'send_message':case'send_file':{const d=typeof c['messageId']==='string'?c['messageId']:undefined;return{'detail':d?'message\x20'+d:'message\x20sent','data':d?{'message_id':d}:{}};}case'send_required_info':{const e=typeof c['messageId']==='string'?c['messageId']:undefined,f=Array['isArray'](c['sent_fields'])?c['sent_fields']:undefined;return{'detail':'required-info\x20confirmation\x20sent','data':{...e?{'message_id':e}:{},...f?{'sent_fields':f}:{}}};}case'generate_wts':{const g=typeof c['totalMessageCount']==='number'?c['totalMessageCount']:undefined,h=Array['isArray'](c['files'])?c['files']:undefined,i=Array['isArray'](c['htmlFiles'])?c['htmlFiles']:undefined;return{'detail':'WTS\x20evidence\x20packet\x20generated','data':{...g!==undefined?{'message_count':g}:{},...h?{'files':h}:{},...i?{'html_reports':i}:{}}};}case'verify_wts':{const j=c['attestation'],k=typeof c['error']==='string'?c['error']:undefined;return{'detail':j?'WTS\x20verification\x20—\x20'+j['attested_count']+'/'+j['total_messages']+'\x20message(s)\x20server-attested':'WTS\x20verification\x20—\x20server\x20attestation\x20unavailable','data':{'valid':c['valid']===!![],'hash_valid':c['hashValid']===!![],'has_signature':c['hasSignature']===!![],...c['signatureValid']===undefined?{}:{'packet_signature_valid':c['signatureValid']===!![]},...k?{'error':k}:{},...j?{'attested_messages':j['attested_count'],'total_messages':j['total_messages'],'fully_attested':j['fully_attested'],'packet_signed':j['packet_signed'],'server_public_keys':j['server_public_keys'],'verdict':j['verdict']}:{'attestation':'unavailable\x20—\x20cross-check\x20the\x20seal\x20signer\x20and\x20server\x20keys\x20independently\x20before\x20treating\x20the\x20packet\x20as\x20third-party\x20evidence'}}};}case'sign_wts':{return{'detail':typeof b==='string'?b:'WTS\x20evidence\x20signed','data':{}};}case'proof_message':{const l=typeof c['proofAddress']==='string'?c['proofAddress']:undefined;return{'detail':l?'proof\x20'+l:'message\x20proofed\x20on-chain','data':l?{'proof_address':l}:{}};}default:return{'detail':a,'data':{}};}}export async function handleMessengerOperation(a){let b;try{b=strictParse(MessengerOperationInputSchema,a,'messenger_operation\x20input');const c=b['operation'];let d;switch(b['operation']){case'watch_conversations':{const g=await watch_conversations(b['filter']);d={'operation':'watch_conversations','result':g};break;}case'send_message':{const h=await send_message(normalizeOptionalAccountOrMark(b['from']),normalizeAccountOrMark(b['to']),b['content'],b['options']);if(h['authRequired']){d={'operation':'send_message','result':h};break;}const i=h,j={...i,'merkleData':i['merkleData']?{'leafIndex':i['merkleData']['leafIndex'],'prevRoot':i['merkleData']['prevRoot'],'newRoot':i['merkleData']['newRoot'],'serverSignature':i['merkleData']['serverSignature'],'serverTimestamp':i['merkleData']['serverTimestamp'],'serverPublicKey':i['merkleData']['serverPublicKey']}:undefined};d={'operation':'send_message','result':j};break;}case'send_file':{const k=await send_file(normalizeOptionalAccountOrMark(b['from']),normalizeAccountOrMark(b['to']),b['filePath'],b['options']),l=k,m={...l,'merkleData':l['merkleData']?{'leafIndex':l['merkleData']['leafIndex'],'prevRoot':l['merkleData']['prevRoot'],'newRoot':l['merkleData']['newRoot'],'serverSignature':l['merkleData']['serverSignature'],'serverTimestamp':l['merkleData']['serverTimestamp'],'serverPublicKey':l['merkleData']['serverPublicKey']}:undefined};d={'operation':'send_file','result':m};break;}case'send_required_info':{let n=b['content'];const o=[];if(!n){const s=await LocalInfo['Instance']()['list'](),t=b['fields'],u=t&&t['length']>0x0?s['filter'](v=>t['includes'](v['name'])):s;if(u['length']===0x0)throw new Error('No\x20LocalInfo\x20fields\x20available.\x20Add\x20private\x20info\x20first\x20via\x20local_info_operation.');n=u['map'](v=>v['name']+':\x20'+v['default'])['join']('\x0a'),o['push'](...u['map'](v=>v['name']));}const p=await send_message(normalizeOptionalAccountOrMark(b['from']),normalizeAccountOrMark(b['to']),n,b['options']),q=p,r={...q,'merkleData':q['merkleData']?{'leafIndex':q['merkleData']['leafIndex'],'prevRoot':q['merkleData']['prevRoot'],'newRoot':q['merkleData']['newRoot'],'serverSignature':q['merkleData']['serverSignature'],'serverTimestamp':q['merkleData']['serverTimestamp'],'serverPublicKey':q['merkleData']['serverPublicKey']}:undefined,'sent_fields':o};d={'operation':'send_required_info','result':r};break;}case'watch_messages':{const v=b['filter']?{...b['filter'],'peerAddress':b['filter']['peerAddress']?normalizeAccountOrMark(b['filter']['peerAddress']):undefined,'account':b['filter']['account']?normalizeOptionalAccountOrMark(b['filter']['account']):undefined}:undefined,w=await watch_messages(v);d={'operation':'watch_messages','result':w};break;}case'save_attachment':{const x=await export_attachment(normalizeOptionalAccountOrMark(b['account']),b['messageId'],{'outputDir':b['outputDir'],'saveAs':b['saveAs']});d={'operation':'save_attachment','result':x};break;}case'generate_wts':{const y=b['params']?{...b['params'],'peerAccount':normalizeAccountOrMark(b['params']['peerAccount']),'myAccount':normalizeOptionalAccountOrMark(b['params']['myAccount'])}:undefined,z=await generate_wts(y);d={'operation':'generate_wts','result':z};break;}case'verify_wts':{const A=await verify_wts(b['wtsFilePath']),B=A?.['valid']===![]?'A\x20packet\x20generated\x20by\x20generate_wts\x20is\x20UNSEALED\x20(no\x20meta.signature)\x20and\x20always\x20fails\x20verification\x20—\x20run\x20sign_wts\x20on\x20this\x20file\x20first,\x20then\x20verify_wts\x20the\x20SIGNED\x20output.':undefined,C=await attestWtsFile(b['wtsFilePath']);let D;if(A?.['serverKeysOfficial']===!![]){const E=A?.['serverKeysOfficialNetwork'],F=A?.['serverKeyAnchor']?.['network'],G=[];if(E){let H;try{H=String(await Config['Instance']()['network_get']());}catch{}H&&H!==E&&G['push']('NETWORK\x20MISMATCH:\x20official-key\x20verification\x20scored\x20in\x20the\x20\x27'+E+'\x27\x20key\x20partition,\x20but\x20this\x20call\x20was\x20served\x20on\x20network\x20\x27'+H+'\x27.\x20'+('The\x20verdict\x20is\x20evidence\x20for\x20\x27'+E+'\x27\x20only\x20—\x20quote\x20this\x20transcript\x20with\x20its\x20partition\x20stated,\x20or\x20switch\x20env.network\x20to\x20\x27'+E+'\x27\x20and\x20re-verify.')),E!=='mainnet'&&G['push']('PARTITION\x20RULE:\x20this\x20official\x20verdict\x20is\x20bound\x20to\x20the\x20\x27'+E+'\x27\x20partition\x20(anchor\x20network:\x20'+(F??E)+').\x20'+'For\x20a\x20MAINNET\x20case\x20the\x20ONLY\x20network-level\x20truth\x20is\x20an\x20on-chain\x20Proof\x20anchor\x20—\x20a\x20proof_message\x20re-anchored\x20on\x20mainnet.\x20'+'A\x20file-level\x20official\x20verdict\x20from\x20a\x20non-mainnet\x20partition\x20is\x20rehearsal\x20evidence\x20and\x20can\x20never\x20ground\x20a\x20mainnet\x20ruling.');}if(G['length']>0x0)D=G['join']('\x20');}d={'operation':'verify_wts','result':C?{...A,...B?{'hint':B}:{},...D?{'network_caveat':D}:{},'attestation':C}:{...A,...B?{'hint':B}:{},...D?{'network_caveat':D}:{},'attestation_unavailable':'Per-message\x20server\x20attestation\x20could\x20not\x20be\x20computed\x20(file\x20not\x20readable\x20locally\x20or\x20not\x20JSON).\x20The\x20guarded\x20verifier\x27s\x20valid\x20flag\x20already\x20required\x20server\x20attestation\x20+\x20seal;\x20cross-check\x20the\x20seal\x20signer\x20and\x20server\x20keys\x20yourself\x20before\x20treating\x20it\x20as\x20third-party\x20evidence.'}};break;}case'sign_wts':{const I=await sign_wts(b['wtsFilePath'],normalizeOptionalAccountOrMark(b['account']),b['outputPath']);d={'operation':'sign_wts','result':I};break;}case'wts2html':{const J=await wts2html(b['wtsPath'],b['options']);d={'operation':'wts2html','result':J};break;}case'proof_message':{let K;try{K=await proof_message(normalizeOptionalAccountOrMark(b['account']),b['messageId'],b['network']);}catch(M){if(isModuleLoadError(M)){const N=noteRuntimeModuleFault('proof_message',M);throw new Error('SDK\x20runtime\x20is\x20stale\x20in\x20this\x20process:\x20the\x20loaded\x20module\x20graph\x20references\x20chunk\x20\x22'+N['module']+'\x22\x20'+'which\x20no\x20longer\x20exists\x20on\x20disk\x20(the\x20SDK\x20dist\x20was\x20rebuilt\x20after\x20this\x20MCP\x20process\x20started).\x20'+'Restart\x20the\x20MCP\x20server\x20to\x20reload\x20the\x20rebuilt\x20dist;\x20this\x20operation\x20cannot\x20succeed\x20until\x20then.');}throw M;}const L=K?.['proofAddress'];if(typeof L==='string')noteProofIssued(L);d={'operation':'proof_message','result':K};break;}case'blacklist':{const O={'account':normalizeOptionalAccountOrMark(b['account']),'op':b['blacklist']['op']};'users'in b['blacklist']&&(O['users']=normalizeManyAccountOrMark(b['blacklist']['users']));const P=await blacklist(O);d={'operation':'blacklist','op':b['blacklist']['op'],'result':P['result']};break;}case'friendslist':{const Q={'account':normalizeOptionalAccountOrMark(b['account']),'op':b['friendslist']['op']};'users'in b['friendslist']&&(Q['users']=normalizeManyAccountOrMark(b['friendslist']['users']));const R=await friendslist(Q);d={'operation':'friendslist','op':b['friendslist']['op'],'result':R['result']};break;}case'guardlist':{const S=await guardlist({'account':normalizeOptionalAccountOrMark(b['account']),...b['guardlist']});d={'operation':'guardlist','op':b['guardlist']['op'],'result':S['result']};break;}case'settings':{const T=await settings({'account':normalizeOptionalAccountOrMark(b['account']),...b['settings']});d={'operation':'settings','op':b['settings']['op'],'result':T['result']};break;}case'mark_messages_as_viewed':{const U=await mark_messages_as_viewed(b['messageIds'],normalizeOptionalAccountOrMark(b['account']));d={'operation':'mark_messages_as_viewed','result':U};break;}case'mark_conversation_as_viewed':{const V=await mark_conversation_as_viewed(normalizeAccountOrMark(b['peerAddress']),normalizeOptionalAccountOrMark(b['account']));d={'operation':'mark_conversation_as_viewed','result':V};break;}case'pull_messages':{const W=await pull_messages(normalizeOptionalAccountOrMark(b['account']),b['limit'],{'allAccounts':b['allAccounts'],'accounts':b['accounts']?.['map'](X=>normalizeAccountOrMark(X)),'concurrency':b['concurrency']});d={'operation':'pull_messages','result':W};break;}default:throw new Error('Unknown\x20messenger\x20operation:\x20'+c);}const e=classifyCommunicationEvidence(c),f=b['goal_id'];if(e&&f){const X=d['result'],{detail:Y,data:Z}=communicationEvidencePayload(c,X);await goalEngine['recordCommunicationEvidence'](f,{'operation':c,'kind':e['kind'],'title':e['title'],'detail':Y,'data':Z},b['network']??'default');}return{'content':[{'type':'text','text':JSON['stringify'](d)}],'structuredContent':{'result':d}};}catch(a0){const a1=a0 instanceof Error?a0['message']:String(a0),a2=b?{'operation_type':'messenger_'+b['operation'],'data':b}:undefined,a3=classifyError(a1),a4={'operation':'error','error':a1};if(a3['error_code']!==undefined)a4['error_code']=a3['error_code'];if(a3['retryable']!==undefined)a4['retryable']=a3['retryable'];if(a3['recovery_hint']!==undefined)a4['recovery_hint']=a3['recovery_hint'];return{'content':[{'type':'text','text':'Error:\x20'+a1}],'structuredContent':{'result':a4,'semantic':buildDataSemantic(undefined,a2,!![],a1)}};}}
|