@wowok/agent-mcp 2.7.10 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extensions/capability-manifest.d.ts +1 -82
- package/dist/extensions/capability-manifest.js +1 -1
- package/dist/extensions/constraint-registry.d.ts +6 -4
- package/dist/extensions/constraint-registry.js +1 -1
- package/dist/extensions/index.d.ts +4 -5
- package/dist/extensions/index.js +1 -1
- package/dist/extensions/industry-pack.js +1 -1
- package/dist/extensions/metric-registry.d.ts +6 -4
- package/dist/extensions/metric-registry.js +1 -1
- package/dist/extensions/mode-evaluator.d.ts +2 -3
- package/dist/extensions/mode-evaluator.js +1 -1
- package/dist/extensions/registry.d.ts +3 -25
- package/dist/extensions/registry.js +1 -1
- package/dist/extensions/types.d.ts +0 -68
- package/dist/goal/GoalEngine.d.ts +36 -1
- package/dist/goal/GoalEngine.js +1 -1
- package/dist/goal/types.d.ts +4 -0
- package/dist/knowledge/account-marks.d.ts +1 -0
- package/dist/knowledge/account-marks.js +1 -1
- package/dist/knowledge/fund-layer.d.ts +13 -9
- package/dist/knowledge/fund-layer.js +1 -1
- package/dist/knowledge/goal-completion.js +1 -1
- package/dist/knowledge/guard-bindings.d.ts +21 -0
- package/dist/knowledge/guard-bindings.js +1 -0
- package/dist/knowledge/index.d.ts +5 -3
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/mcp-schema-audit-cli.js +1 -1
- package/dist/knowledge/mcp-schema-audit.js +1 -1
- package/dist/knowledge/reward-risk.d.ts +1 -1
- package/dist/knowledge/reward-risk.js +1 -1
- package/dist/knowledge/safety-rules.d.ts +2 -1
- package/dist/knowledge/safety-rules.js +1 -1
- package/dist/knowledge/scenario-topology.d.ts +43 -0
- package/dist/knowledge/scenario-topology.js +1 -0
- package/dist/knowledge/supply-chain.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/workflow-guidance.d.ts +35 -0
- package/dist/knowledge/workflow-guidance.js +1 -1
- package/dist/knowledge/workspace-lists.d.ts +1 -0
- package/dist/knowledge/workspace-lists.js +1 -1
- package/dist/monitor/MonitorLoop.d.ts +2 -0
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/monitor/ScopeResolver.js +1 -1
- package/dist/monitor/SuggestionBridge.d.ts +38 -0
- package/dist/monitor/SuggestionBridge.js +1 -0
- package/dist/participation/arbitrator-interest.d.ts +20 -0
- package/dist/participation/arbitrator-interest.js +1 -0
- package/dist/participation/demander-interest.d.ts +23 -0
- package/dist/participation/demander-interest.js +1 -0
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/context-assembly.js +1 -1
- package/dist/playbooks/service-build/machine-nodes.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/merchant-guide.d.ts +20 -0
- package/dist/playbooks/service-build/merchant-guide.js +1 -1
- package/dist/playbooks/service-build/mode-actions.d.ts +30 -6
- package/dist/playbooks/service-build/mode-actions.js +1 -1
- package/dist/playbooks/service-build/object-panorama.js +1 -1
- package/dist/playbooks/service-build/participation-radar.js +1 -1
- package/dist/playbooks/service-build/relationship-profile.d.ts +2 -0
- package/dist/playbooks/service-build/relationship-profile.js +1 -0
- package/dist/playbooks/service-build/semantic-graph.d.ts +5 -1
- package/dist/playbooks/service-build/semantic-graph.js +1 -1
- package/dist/playbooks/service-build/service-panorama.js +1 -1
- package/dist/relationship/derivation.d.ts +88 -0
- package/dist/relationship/derivation.js +1 -0
- package/dist/relationship/incentive.d.ts +38 -0
- package/dist/relationship/incentive.js +1 -0
- package/dist/relationship/index.d.ts +4 -0
- package/dist/relationship/index.js +1 -0
- package/dist/relationship/registry.d.ts +13 -0
- package/dist/relationship/registry.js +1 -0
- package/dist/relationship/types.d.ts +45 -0
- package/dist/relationship/types.js +1 -0
- package/dist/review/progress.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/safety/preview.js +1 -1
- package/dist/schema/call/bridge.d.ts +25 -3
- package/dist/schema/call/bridge.js +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/goal/index.d.ts +40 -14
- package/dist/schema/goal/index.js +1 -1
- package/dist/schema/goal/planning.d.ts +6 -6
- package/dist/schema/industry-pack/index.d.ts +58 -0
- package/dist/schema/industry-pack/index.js +1 -1
- package/dist/schema/industry-pack/modes.d.ts +59 -1
- package/dist/schema/industry-pack/modes.js +1 -1
- package/dist/schema/intent-radar/index.d.ts +19 -19
- package/dist/schema/local/index.d.ts +11 -0
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/operations.d.ts +58 -16
- package/dist/schema/persona/index.d.ts +1 -1
- package/dist/schema/query/bi.d.ts +145 -16
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.d.ts +2 -2
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +29 -0
- package/dist/schemas/account_operation.schema.json +6 -2
- package/dist/schemas/bridge_operation.output.json +24 -1
- package/dist/schemas/bridge_operation.schema.json +73 -1
- package/dist/schemas/goal_operation.schema.json +76 -0
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/industry_pack_operation.output.json +176 -1
- package/dist/schemas/industry_pack_operation.schema.json +19 -0
- package/dist/schemas/onchain_events.output.json +1 -1
- package/dist/schemas/onchain_operations.schema.json +41 -41
- package/dist/schemas/onchain_operations_allocation.schema.json +4 -4
- package/dist/schemas/onchain_operations_arbitration.schema.json +3 -3
- package/dist/schemas/onchain_operations_contact.schema.json +2 -2
- package/dist/schemas/onchain_operations_demand.schema.json +2 -2
- package/dist/schemas/onchain_operations_machine.schema.json +2 -2
- package/dist/schemas/onchain_operations_order.schema.json +2 -2
- package/dist/schemas/onchain_operations_payment.schema.json +1 -1
- package/dist/schemas/onchain_operations_permission.schema.json +2 -2
- package/dist/schemas/onchain_operations_progress.schema.json +2 -2
- package/dist/schemas/onchain_operations_repository.schema.json +2 -2
- package/dist/schemas/onchain_operations_reward.schema.json +6 -6
- package/dist/schemas/onchain_operations_service.schema.json +7 -7
- package/dist/schemas/onchain_operations_treasury.schema.json +6 -6
- package/dist/schemas/onchain_table_data.output.json +53 -0
- package/dist/schemas/query_toolkit.output.json +240 -7
- package/dist/schemas/query_toolkit.schema.json +53 -0
- package/dist/task/ProcessStore.d.ts +18 -1
- package/dist/task/ProcessStore.js +1 -1
- package/dist/task/types.d.ts +24 -0
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/evaluation.js +1 -1
- package/dist/tools/handlers/goal.js +1 -1
- package/dist/tools/handlers/industry-pack.js +1 -1
- package/dist/tools/handlers/local.d.ts +4 -3
- package/dist/tools/handlers/local.js +1 -1
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/permission.js +1 -1
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/workflow.js +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/rules-hook.d.ts +1 -0
- package/dist/tools/rules-hook.js +1 -1
- package/dist/tools/shared.js +1 -1
- package/package.json +2 -2
- package/dist/mode-market/index.d.ts +0 -3
- package/dist/mode-market/index.js +0 -1
- package/dist/mode-market/registry.d.ts +0 -53
- package/dist/mode-market/registry.js +0 -1
- package/dist/mode-market/review.d.ts +0 -27
- package/dist/mode-market/review.js +0 -1
- package/dist/mode-market/submission.d.ts +0 -25
- package/dist/mode-market/submission.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SQLiteStorage}from'@wowok/wowok/w/local';import{query_objects,queryOrdersByUser,
|
|
1
|
+
import{SQLiteStorage}from'@wowok/wowok/w/local';import{query_objects,queryOrdersByUser,objectTypeFromAddress}from'@wowok/wowok';import{fetchEntityPermission,fetchObjectLinkerCore,fetchObjectLinkerTx,fetchServiceOrders,listLocalAccounts}from'../knowledge/workflow-guidance.js';import{monitorEventStore}from'./EventStore.js';import{LOOP_DEFAULTS,normalizeAddr,shortId}from'./types.js';const SCOPE_PREFIX='mon_scope:v4:',SCOPE_HIST_PREFIX='mon_scope_hist:v4:',SCOPE_HISTORY_KEEP=0x5,FAVOR_SCAN_MAX=0x1388;function netKey(a){return(a||'default')['replace'](/[^a-zA-Z0-9_-]/g,'_');}function realDeps(){return{'listLocalAccounts':()=>listLocalAccounts(),'fetchEntityPermission':(a,b)=>fetchEntityPermission(a,b),'fetchObjectLinkerCore':(a,b)=>fetchObjectLinkerCore(a,b),'fetchObjectLinkerTx':(a,b)=>fetchObjectLinkerTx(a,b),'queryServiceOrders':a=>fetchServiceOrders(a['address'],a['network']),'queryOrdersByUser':a=>queryOrdersByUser({'address':a['address'],'network':a['network']}),'queryObjects':a=>query_objects({'objects':a['objects'],'network':a['network']}),'objectTypeFromAddress':a=>objectTypeFromAddress(a),'store':monitorEventStore,'storage':new SQLiteStorage(),'now':()=>Date['now']()};}function canonicalize(a){if(Array['isArray'](a))return a['map'](canonicalize)['sort']((c,d)=>{const e=JSON['stringify'](c),f=JSON['stringify'](d);return e<f?-0x1:e>f?0x1:0x0;});if(a&&typeof a==='object'){const b={};for(const c of Object['keys'](a)['sort']()){b[c]=canonicalize(a[c]);}return b;}return a;}function semanticHashOf(a){return JSON['stringify'](canonicalize({'accounts':a['accounts'],'permissions':a['permissions'],'managed_objects':a['managed_objects'],'services':a['services'],'orders':a['orders'],'order_children':a['order_children'],'focus':a['focus']}));}function lowerTypeOf(a,b){try{return a['objectTypeFromAddress'](b)?.['toLowerCase']()??null;}catch{return null;}}function objectFields(a){return a?.['data']??a??{};}function childrenOfOrder(a){const b=[],c=Array['isArray'](a?.['dispute'])?a['dispute']:[];for(const e of c){if(typeof e==='string'&&e)b['push']({'type':'arb','object':e});}return typeof a?.['progress']==='string'&&a['progress']&&b['push']({'type':'progress','object':a['progress']}),typeof a?.['allocation']==='string'&&a['allocation']&&b['push']({'type':'allocation','object':a['allocation']}),b;}export async function loadScopeSnapshot(a,b){try{const c=await(b??new SQLiteStorage())['get'](''+SCOPE_PREFIX+netKey(a));if(!c)return undefined;const d=JSON['parse'](c);return d&&typeof d['version']==='number'?d:undefined;}catch{return undefined;}}export async function resolveScope(a,b,e){const g={...realDeps(),...e??{}},h=g['now'](),j=[],k=async(N,O)=>{try{return await O();}catch{return j['push'](N),undefined;}},l=''+SCOPE_PREFIX+netKey(a),n=''+SCOPE_HIST_PREFIX+netKey(a);let p;try{const N=await g['storage']['get'](l);p=N?JSON['parse'](N):undefined;}catch{p=undefined;}let q;if(b['scope']['accounts']==='local-all'){const O=await k('accounts',()=>g['listLocalAccounts']());q=(O??[])['map'](P=>P['address'])['filter'](P=>typeof P==='string'&&P);}else q=[...b['scope']['accounts']];q=[...new Set(q)];const s=b['scope']['rules'],t=[],u=[],w=new Map();if(s['managed_objects']||s['merchant_orders']){for(const R of q){const S=await k('entity_permission:'+shortId(R),()=>g['fetchEntityPermission'](R,a));for(const T of S?.['items']??[]){if(T?.['permission'])t['push'](T['permission']);}}const P=[...new Set(t)];t['length']=0x0,t['push'](...P);const Q=new Set();for(const U of P){const V=await k('object_linker_core:'+shortId(U),()=>g['fetchObjectLinkerCore'](U,a)),W=await k('object_linker_tx:'+shortId(U),()=>g['fetchObjectLinkerTx'](U,a)),X=[...(V?.['items']??[])['map'](Y=>Y?.['who']),...(W?.['items']??[])['map'](Y=>Y?.['who'])];for(const Y of X){if(typeof Y!=='string'||!Y)continue;const Z=lowerTypeOf(g,Y);if(!Z)continue;const a0=normalizeAddr(Y);if(Q['has'](a0))continue;Q['add'](a0),u['push']({'type':Z,'object':Y}),w['set'](a0,U);}}}const x=u['filter'](a1=>a1['type']==='service')['map'](a1=>a1['object']),y=new Map(),z=(a1,a2)=>{const a3=normalizeAddr(a1);if(!a3)return;const a4=y['get'](a3)??{'order':a1,'merchant':![],'buyer':![]};a4[a2]=!![],y['set'](a3,a4);};if(s['merchant_orders'])for(const a1 of x){const a2=await k('service_orders:'+shortId(a1),()=>g['queryServiceOrders']({'address':a1,'network':a}));for(const a3 of a2?.['items']??[]){if(typeof a3?.['who']==='string'&&a3['who'])z(a3['who'],'merchant');}}if(s['my_orders'])for(const a4 of q){const a5=await k('user_orders:'+shortId(a4),()=>g['queryOrdersByUser']({'address':a4,'network':a}));for(const a6 of a5??[]){if(!a6?.['is_owner']&&!a6?.['is_agent'])continue;const a7=a6?.['order']?.['object']??a6?.['order']?.['id'];if(typeof a7==='string'&&a7)z(a7,'buyer');}}const A=[...y['values']()]['map'](a8=>({'order':a8['order'],'role':a8['merchant']&&a8['buyer']?'both':a8['merchant']?'merchant':'buyer'})),B=[],C=new Map();if(s['order_children']&&y['size']>0x0){const a8=[...y['values']()]['map'](a9=>a9['order']);for(let a9=0x0;a9<a8['length'];a9+=0x32){const aa=a8['slice'](a9,a9+0x32),ab=await k('order_objects:'+shortId(aa[0x0]),()=>g['queryObjects']({'objects':aa,'network':a}));for(const ac of ab?.['objects']??[]){const ad=objectFields(ac),ae=ac?.['object']??ad?.['object']??ad?.['id'];if(typeof ae!=='string'||!ae)continue;for(const af of childrenOfOrder(ad)){const ag=normalizeAddr(af['object']);if(C['has'](ag))continue;C['set'](ag,ae),B['push'](af);}}}}const D=(b['scope']['focus_objects']??[])['map'](ah=>({...ah})),E=new Set(D['map'](ah=>normalizeAddr(ah['object']))),F=new Map();for(const ah of p?.['focus']??[]){if(ah?.['reason']==='favor'&&ah['object'])F['set'](normalizeAddr(ah['object']),ah['added_at']);}if(s['favor_objects']&&q['length']>0x0){const ai=Number(b['loop']?.['backfill_days']??LOOP_DEFAULTS['backfill_days']),aj=h-Math['max'](0x0,ai)*0x5265c00,ak=new Set(q['map'](al=>normalizeAddr(al)));try{let al=0x0;for(;;){const am=await g['store']['list'](a,{'module':'arb','eventType':'FeedbackEvent','since':aj,'offset':al,'limit':0xc8});if(am['events']['length']===0x0)break;for(const an of am['events']){const ao=an['event'],ap=normalizeAddr(ao?.['sender']);if(!ap||!ak['has'](ap))continue;const aq=ao?.['object'],ar=normalizeAddr(typeof aq==='string'?aq:'');if(!ar||E['has'](ar))continue;E['add'](ar),D['push']({'object':aq,'added_at':F['get'](ar)??h,'reason':'favor','closure':!![]});}al+=am['events']['length'];if(al>=am['total']||al>=FAVOR_SCAN_MAX)break;}}catch{j['push']('favor_scan');}}const G={},H=(as,at)=>{const au=normalizeAddr(as);if(!au)return;const av=G[au]??=[],aw=av['some'](ax=>ax['rule']===at['rule']&&normalizeAddr(ax['object'])===normalizeAddr(at['object']));if(!aw)av['push'](at);};if(s['managed_objects'])for(const as of u){const at=w['get'](normalizeAddr(as['object']));H(as['object'],{'rule':'managed_objects','object':as['object'],'detail':at?as['type']+'\x20'+shortId(as['object'])+'\x20of\x20permission\x20'+shortId(at):as['type']+'\x20'+shortId(as['object'])+'\x20(managed)'});}for(const au of A){(au['role']==='merchant'||au['role']==='both')&&H(au['order'],{'rule':'merchant_orders','object':au['order'],'detail':'order\x20'+shortId(au['order'])+'\x20(merchant)'}),(au['role']==='buyer'||au['role']==='both')&&H(au['order'],{'rule':'my_orders','object':au['order'],'detail':'order\x20'+shortId(au['order'])+'\x20(buyer)'});}if(s['order_children'])for(const av of B){const aw=C['get'](normalizeAddr(av['object']));H(av['object'],{'rule':'order_children','object':av['object'],'detail':aw?av['type']+'\x20'+shortId(av['object'])+'\x20of\x20order\x20'+shortId(aw):av['type']+'\x20'+shortId(av['object'])+'\x20(order\x20child)'});}for(const ax of D){const ay=lowerTypeOf(g,ax['object']);H(ax['object'],{'rule':'focus','object':ax['object'],'detail':'focused\x20'+(ay??'object')+'\x20'+shortId(ax['object'])});if(!ax['closure'])continue;if(ay==='service'){const az=await k('focus_service_orders:'+shortId(ax['object']),()=>g['queryServiceOrders']({'address':ax['object'],'network':a}));for(const aA of az?.['items']??[]){if(typeof aA?.['who']!=='string'||!aA['who'])continue;H(aA['who'],{'rule':'focus','object':aA['who'],'detail':'order\x20'+shortId(aA['who'])+'\x20of\x20focused\x20service\x20'+shortId(ax['object'])});}}else{if(ay==='order'){const aB=await k('focus_order:'+shortId(ax['object']),()=>g['queryObjects']({'objects':[ax['object']],'network':a})),aC=objectFields(aB?.['objects']?.[0x0]);for(const aD of childrenOfOrder(aC)){H(aD['object'],{'rule':'focus','object':aD['object'],'detail':aD['type']+'\x20'+shortId(aD['object'])+'\x20of\x20focused\x20order\x20'+shortId(ax['object'])});}}}}const I={'accounts':q,'permissions':t,'managed_objects':u,'services':x,'orders':A,'order_children':B,'focus':D},J=semanticHashOf(I),K=!p||semanticHashOf(p)!==J,L=p?K?p['version']+0x1:p['version']:0x1,M={'version':L,'resolved_at':h,...I,'index':G,...j['length']>0x0?{'data_gaps':j}:{}};try{await g['storage']['put'](l,JSON['stringify'](M));if(K){let aE=[];try{const aF=await g['storage']['get'](n),aG=aF?JSON['parse'](aF):undefined;aE=Array['isArray'](aG?.['snapshots'])?aG['snapshots']:[];}catch{aE=[];}aE['unshift'](M),await g['storage']['put'](n,JSON['stringify']({'snapshots':aE['slice'](0x0,SCOPE_HISTORY_KEEP)}));}}catch{j['push']('snapshot_persist');}return{'snapshot':M,'changed':K};}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { GoalRecord, GoalStage } from "../goal/types.js";
|
|
2
|
+
import type { SuggestionRecord } from "../task/types.js";
|
|
3
|
+
import type { RelevanceAnnotation, ScopeSnapshot } from "./types.js";
|
|
4
|
+
export interface ProgressionClassification {
|
|
5
|
+
kind: "advance_stage" | "complete_goal";
|
|
6
|
+
stage?: GoalStage;
|
|
7
|
+
goal_type?: string;
|
|
8
|
+
title: string;
|
|
9
|
+
detail: string;
|
|
10
|
+
object: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function classifyProgression(ev: any): ProgressionClassification | null;
|
|
13
|
+
export interface SuggestionBridgeDeps {
|
|
14
|
+
getGoal(network: string, id: string): Promise<GoalRecord | undefined>;
|
|
15
|
+
addSuggestion(dir: string, input: {
|
|
16
|
+
object?: string;
|
|
17
|
+
kind: SuggestionRecord["kind"];
|
|
18
|
+
stage?: string;
|
|
19
|
+
objects?: {
|
|
20
|
+
type: string;
|
|
21
|
+
object: string;
|
|
22
|
+
}[];
|
|
23
|
+
title: string;
|
|
24
|
+
detail?: string;
|
|
25
|
+
origin?: SuggestionRecord["origin"];
|
|
26
|
+
}): SuggestionRecord;
|
|
27
|
+
listSuggestions(dir: string, filter?: {
|
|
28
|
+
status?: SuggestionRecord["status"];
|
|
29
|
+
}): SuggestionRecord[];
|
|
30
|
+
logger(message: string): void;
|
|
31
|
+
}
|
|
32
|
+
export interface SuggestionBridgeInput {
|
|
33
|
+
network: string;
|
|
34
|
+
events: any[];
|
|
35
|
+
annotations: RelevanceAnnotation[];
|
|
36
|
+
scope: ScopeSnapshot;
|
|
37
|
+
}
|
|
38
|
+
export declare function bridgeMonitorSuggestions(input: SuggestionBridgeInput, deps: SuggestionBridgeDeps): Promise<number>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{monitorEventId}from'./EventStore.js';const ARB_STATUS_FINISHED=0x5,STAGE_GATE={'advance_stage':'acting','complete_goal':'monitoring'};export function classifyProgression(a){if(!a||typeof a!=='object')return null;if(a['type']==='NewOrderEvent'){const b=typeof a['order']==='string'?a['order']:null,c=typeof a['service']==='string'?a['service']:null,d=b??c;if(!d)return null;return{'kind':'advance_stage','stage':'monitoring','title':'First\x20order\x20received\x20—\x20enter\x20monitoring','detail':'NewOrderEvent\x20on\x20'+d+(c?'\x20for\x20service\x20'+c:'')+'.\x20The\x20goal\x27s\x20live\x20object\x20now\x20transacts\x20on\x20its\x20own;\x20confirm\x20to\x20enter\x20the\x20monitoring\x20station\x20(auto-binds\x20focus\x20for\x20the\x20order\x20lifecycle).','object':d};}if(a['type']==='ArbEvent'){const e=Number(a['status']);if(e!==ARB_STATUS_FINISHED)return null;const f=typeof a['order']==='string'?a['order']:null,g=typeof a['arb']==='string'?a['arb']:null,h=f??g;if(!h)return null;return{'kind':'complete_goal','title':'Arbitration\x20finished\x20—\x20verify\x20completion','detail':'The\x20dispute\x20covering\x20'+h+'\x20finished\x20(ArbEvent\x20Finished)'+(a['arbitration']?'\x20—\x20arbitration\x20'+a['arbitration']:'')+'.\x20Confirm\x20to\x20run\x20the\x20COMPLETE\x20station:\x20chain\x20conditions\x20are\x20re-verified\x20before\x20the\x20goal\x20closes.','object':h};}if(a['type']==='ServiceEvent'){const i=typeof a['object']==='string'?a['object']:null;if(!i)return null;return{'kind':'complete_goal','goal_type':'publish_service','title':'Service\x20live\x20—\x20verify\x20completion','detail':'ServiceEvent\x20on\x20'+i+(a['description']?'\x20('+a['description']+')':'')+'.\x20Confirm\x20to\x20run\x20the\x20COMPLETE\x20station:\x20the\x20service\x20conjunction\x20(healthy,\x20sales,\x20machine,\x20permission)\x20is\x20re-verified\x20on\x20chain.','object':i};}return null;}const EVENT_OBJECT_FIELDS=['order','service','arb','arbitration','object','progress'];export async function bridgeMonitorSuggestions(b,c){const {network:d,events:g,annotations:h,scope:i}=b;try{const j=new Set(h['map'](n=>n['event_id'])),k=new Map();for(const n of h){k['set'](n['event_id'],n['rules']['map'](o=>o['object']));}const l=new Map();for(const o of i['focus']??[]){if(o['goal_id']&&o['object'])l['set'](o['object'],o['goal_id']);}if(l['size']===0x0)return 0x0;const m=[];for(const p of g){const q=monitorEventId(p?.['id']);if(!q||!j['has'](q))continue;const r=classifyProgression(p);if(!r)continue;const s=[...k['get'](q)??[],...EVENT_OBJECT_FIELDS['map'](y=>p[y])['filter'](y=>typeof y==='string'&&y['length']>0x0)];let t;for(const y of s){const z=l['get'](y);if(z){t=z;break;}}if(!t)continue;const u=await c['getGoal'](d,t),v=u?.['process']?.['dir'];if(!u||!v)continue;const w=STAGE_GATE[r['kind']];if(w&&u['stage']!==w)continue;if(r['goal_type']&&u['goal_type']!==r['goal_type'])continue;const x=c['listSuggestions'](v)['some'](A=>A['origin']?.['source']==='monitor'&&A['origin']?.['event_id']===q);if(x)continue;c['addSuggestion'](v,{'object':r['object'],'kind':r['kind'],...r['stage']?{'stage':r['stage']}:{},'title':r['title'],'detail':r['detail'],'origin':{'source':'monitor','network':d,'event_id':q,'event_type':String(p['type']??'unknown')}}),m['push'](q);}return m['length']>0x0&&c['logger']('suggestion\x20bridge:\x20opened\x20'+m['length']+'\x20suggestion(s)\x20on\x20'+d+'\x20from\x20monitor\x20progressions'),m['length'];}catch(A){return c['logger']('suggestion\x20bridge:\x20skipped\x20('+String(A?.['message']??A)+')'),0x0;}}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface ArbitratorInterestInput {
|
|
2
|
+
account: string;
|
|
3
|
+
arbitration: string;
|
|
4
|
+
vote_weight?: number;
|
|
5
|
+
open_disputes: Array<{
|
|
6
|
+
arb: string;
|
|
7
|
+
order?: string;
|
|
8
|
+
voting_deadline?: number;
|
|
9
|
+
current_time?: number;
|
|
10
|
+
}>;
|
|
11
|
+
resolved_indemnities?: string[];
|
|
12
|
+
}
|
|
13
|
+
export interface ArbitratorInterestAnalysis {
|
|
14
|
+
fund_flow: string[];
|
|
15
|
+
responsibility: string[];
|
|
16
|
+
leverage: string[];
|
|
17
|
+
stakes: string[];
|
|
18
|
+
summary: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function analyzeArbitratorInterest(input: ArbitratorInterestInput): ArbitratorInterestAnalysis;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function analyzeArbitratorInterest(a){const b=[],c=[],e=[],f=[];b['push']('Arbitration\x20fee\x20is\x20escrowed\x20per\x20dispute\x20(arb.move)\x20—\x20collected\x20when\x20the\x20verdict\x20lands,\x20forfeited\x20if\x20you\x20never\x20vote.');a['vote_weight']!==undefined&&b['push']('Your\x20vote\x20carries\x20weight\x20'+a['vote_weight']+'\x20—\x20weighted\x20voting,\x20not\x20majority\x20count:\x20a\x20high-weight\x20vote\x20can\x20decide\x20a\x20case\x20alone.');if(a['open_disputes']['length']>0x0){c['push'](a['open_disputes']['length']+'\x20open\x20dispute(s)\x20await\x20your\x20proposition/vote\x20—\x20you\x20hold\x20arbitration\x20power\x20over\x20funds\x20that\x20are\x20already\x20escrowed.');for(const h of a['open_disputes']){if(h['voting_deadline']!==undefined&&h['current_time']!==undefined){const i=Math['round']((h['voting_deadline']-h['current_time'])/0x36ee80);c['push']('Arb\x20'+h['arb']+':\x20'+(i>=0x0?i+'h\x20left\x20to\x20the\x20voting\x20deadline':'voting\x20deadline\x20PASSED')+(h['order']?'\x20(order\x20'+h['order']+')':'')+'.');}}}c['push']('Verdicts\x20must\x20be\x20defensible\x20from\x20on-chain\x20evidence\x20(progress\x20records,\x20WIP\x20hashes,\x20Messenger\x20records)\x20—\x20every\x20Voted\x20entry\x20is\x20permanent\x20and\x20queryable.'),e['push']('Pull\x20the\x20order\x27s\x20full\x20record\x20before\x20voting:\x20Progress\x20holders\x20show\x20WHO\x20advanced\x20WHAT\x20and\x20WHEN\x20—\x20the\x20liability\x20question\x20usually\x20answers\x20itself\x20from\x20the\x20timestamps.');a['open_disputes']['length']>0x0&&e['push']('Request\x20missing\x20evidence\x20via\x20Messenger\x20—\x20the\x20conversation\x20record\x20becomes\x20part\x20of\x20the\x20dispute\x20record.');f['push']('Deadline\x20miss:\x20a\x20case\x20you\x20hold\x20weight\x20in\x20resolves\x20without\x20you\x20—\x20fee\x20forfeited\x20and\x20your\x20arbitration\x20reputation\x20degrades\x20(registrar\x20votes\x20are\x20queryable\x20by\x20future\x20disputants).');a['resolved_indemnities']?.['length']&&f['push']('You\x20resolved\x20'+a['resolved_indemnities']['length']+'\x20case(s)\x20recently\x20—\x20a\x20verdict\x20overturned\x20by\x20evidence\x20later\x20discovered\x20is\x20a\x20permanent\x20reputation\x20mark.');f['push']('Separation\x20of\x20powers:\x20you\x20must\x20NOT\x20hold\x20power\x20in\x20the\x20disputing\x20service\x27s\x20own\x20permission\x20(service.move\x20rejects\x20such\x20bindings)\x20—\x20avoid\x20any\x20position\x20that\x20re-creates\x20that\x20conflict.');const g='As\x20an\x20arbitrator\x20of\x20'+a['arbitration']+(a['vote_weight']!==undefined?'\x20(weight\x20'+a['vote_weight']+')':'')+(',\x20'+a['open_disputes']['length']+'\x20open\x20dispute(s)')+(a['open_disputes']['length']>0x0?'\x20await\x20your\x20vote':'\x20are\x20pending')+'.\x20Your\x20income\x20is\x20the\x20fee;\x20your\x20asset\x20is\x20a\x20defensible\x20verdict\x20record;\x20your\x20exposure\x20is\x20the\x20deadline.';return{'fund_flow':b,'responsibility':c,'leverage':e,'stakes':f,'summary':g};}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface DemanderInterestInput {
|
|
2
|
+
account: string;
|
|
3
|
+
demand: string;
|
|
4
|
+
presenters: Array<{
|
|
5
|
+
address: string;
|
|
6
|
+
service?: string;
|
|
7
|
+
acceptance_score?: number;
|
|
8
|
+
}>;
|
|
9
|
+
rewards: Array<{
|
|
10
|
+
address: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
}>;
|
|
13
|
+
guards: string[];
|
|
14
|
+
open: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface DemanderInterestAnalysis {
|
|
17
|
+
fund_flow: string[];
|
|
18
|
+
responsibility: string[];
|
|
19
|
+
leverage: string[];
|
|
20
|
+
stakes: string[];
|
|
21
|
+
summary: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function analyzeDemanderInterest(input: DemanderInterestInput): DemanderInterestAnalysis;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function analyzeDemanderInterest(a){const b=[],c=[],d=[],e=[];a['rewards']['length']>0x0?b['push'](a['rewards']['length']+'\x20reward\x20object(s)\x20escrowed\x20on\x20the\x20demand\x20—\x20claimable\x20ONLY\x20by\x20the\x20presenter\x20you\x20select\x20'+'(the\x20claim\x20guard\x20passes\x20for\x20the\x20winner\x27s\x20claim\x20alone).\x20Nothing\x20is\x20paid\x20for\x20presenting\x20itself.'):b['push']('No\x20reward\x20attached\x20—\x20presenters\x20see\x20a\x20non-paying\x20demand;\x20expect\x20fewer\x20or\x20weaker\x20presentations.');c['push']('Selection\x20is\x20yours\x20alone:\x20the\x20on-chain\x20feedback\x20you\x20write\x20(acceptance_score)\x20becomes\x20the\x20presenter\x27s\x20permanent,\x20queryable\x20reputation.');a['presenters']['length']>0x0&&c['push'](a['presenters']['length']+'\x20presenter(s)\x20are\x20waiting\x20on\x20your\x20selection\x20—\x20each\x20present\x20is\x20visible\x20with\x20its\x20service\x20and\x20history.');a['open']?(d['push']('Keep\x20the\x20demand\x20open\x20and\x20compare\x20presenters\x20via\x20their\x20services\x27\x20trust\x20data\x20(registrar\x20votes,\x20past\x20orders,\x20arbitration\x20bindings)\x20before\x20selecting.'),a['guards']['length']>0x0&&d['push']('Demand\x20guards\x20('+a['guards']['join'](',\x20')+')\x20filter\x20who\x20may\x20present\x20—\x20tighten\x20them\x20if\x20low-quality\x20presentations\x20arrive.')):d['push']('Demand\x20closed\x20—\x20leave\x20on-chain\x20feedback\x20(acceptance_score)\x20to\x20finish\x20the\x20evaluation\x20loop.');d['push']('Negotiate\x20pre-commitment\x20terms\x20via\x20Messenger:\x20the\x20conversation\x20record\x20is\x20evidence\x20if\x20a\x20dispute\x20later\x20arises.');a['presenters']['length']===0x0&&e['push']('No\x20presenters\x20yet\x20—\x20the\x20demand\x20may\x20be\x20over-narrow\x20or\x20under-rewarded;\x20consider\x20adjusting\x20the\x20reward\x20or\x20guards.');a['rewards']['length']>0x0&&a['presenters']['length']===0x0&&e['push']('Escrowed\x20reward\x20sits\x20idle\x20while\x20no\x20one\x20presents\x20—\x20value\x20overhang\x20with\x20no\x20delivery.');e['push']('Selecting\x20without\x20evidence\x20review:\x20acceptance_score\x20and\x20service\x20trust\x20data\x20are\x20your\x20only\x20pre-commitment\x20protection\x20—\x20there\x20is\x20NO\x20platform\x20intermediary\x20to\x20reverse\x20a\x20bad\x20selection.');const f='As\x20the\x20demander\x20of\x20'+a['demand']+',\x20'+(a['presenters']['length']>0x0?a['presenters']['length']+'\x20presenter(s)\x20compete\x20for\x20your\x20selection':'no\x20presenter\x20has\x20come\x20forward\x20yet')+(a['rewards']['length']>0x0?';\x20'+a['rewards']['length']+'\x20escrowed\x20reward(s)\x20back\x20the\x20selection.':';\x20no\x20reward\x20is\x20attached.')+'\x20Your\x20leverage\x20is\x20comparison\x20and\x20evidence;\x20your\x20exposure\x20is\x20selection\x20risk.';return{'fund_flow':b,'responsibility':c,'leverage':d,'stakes':e,'summary':f};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{initServicePuzzleFromIntent,initMachinePuzzleFromIntent,initAllocationPuzzleFromIntent,initTreasuryPuzzleFromIntent,initArbitrationPuzzleFromIntent,initRewardPuzzleFromIntent,initProgressPuzzleFromIntent,initOrderPuzzleFromIntent,initPuzzleFromIntent as
|
|
1
|
+
import{initServicePuzzleFromIntent,initMachinePuzzleFromIntent,initAllocationPuzzleFromIntent,initTreasuryPuzzleFromIntent,initArbitrationPuzzleFromIntent,initRewardPuzzleFromIntent,initProgressPuzzleFromIntent,initOrderPuzzleFromIntent,initPuzzleFromIntent as a284a,checkServicePuzzleCompleteness,checkMachinePuzzleCompleteness,checkAllocationPuzzleCompleteness,checkTreasuryPuzzleCompleteness,checkArbitrationPuzzleCompleteness,checkRewardPuzzleCompleteness,checkProgressPuzzleCompleteness,checkOrderPuzzleCompleteness,checkPuzzleCompleteness as a284b}from'../../knowledge/index.js';import{initPuzzleFromIntent as a284c,checkPuzzleCompleteness as a284d}from'../../knowledge/permission-puzzle.js';const KEYWORD_TABLE=[{'category':'Product/Service','keywords_zh':['product','selling','sell','sales','store','open\x20shop'],'keywords_en':['sell','product','sale','shop','store'],'objects':['service','order','progress'],'required_level':'R','scene_id':'retail'},{'category':'Subscription','keywords_zh':['subscription','cycle','renewal'],'keywords_en':['subscribe','recurring','subscription'],'objects':['service','machine','reward'],'required_level':'C','scene_id':'subscription'},{'category':'Rental','keywords_zh':['rent','lease','return'],'keywords_en':['rent','lease','return'],'objects':['service','machine','arb'],'required_level':'C','scene_id':'rental_return'},{'category':'Trust','keywords_zh':['deposit','pledge','verify','trust'],'keywords_en':['deposit','trust','verify'],'objects':['guard','permission','treasury'],'required_level':'R','scene_id':'trust_deposit'},{'category':'Funds','keywords_zh':['split','collect','share\x20profit','income','incentive'],'keywords_en':['split','revenue','reward'],'objects':['allocation','treasury','reward'],'required_level':'R','scene_id':'revenue_split'},{'category':'Workflow','keywords_zh':['node','stage','process','workflow'],'keywords_en':['workflow','stage','node'],'objects':['machine','progress'],'required_level':'R','scene_id':'workflow'},{'category':'Dispute','keywords_zh':['arbitration','refund','conflict','rights\x20protection'],'keywords_en':['arbitration','refund','dispute'],'objects':['arb','proof'],'required_level':'C','scene_id':'arbitration_dispute'},{'category':'Contact','keywords_zh':['customer\x20service','contact','communication'],'keywords_en':['contact','support','im'],'objects':['contact'],'required_level':'C','scene_id':'contact_im'},{'category':'Data','keywords_zh':['evidence','record','data'],'keywords_en':['evidence','record','data'],'objects':['repository','proof'],'required_level':'C','scene_id':'evidence_record'},{'category':'User\x20Profile','keywords_zh':['personal\x20info','preference','privacy'],'keywords_en':['personal','profile','privacy'],'objects':['personal','contact'],'required_level':'OPTIONAL','scene_id':'user_profile'},{'category':'Demand\x20Submission','keywords_zh':['demand','publish','inquiry'],'keywords_en':['demand','request','inquiry'],'objects':['demand'],'required_level':'OPTIONAL','scene_id':'demand_inquiry'}],INDUSTRY_KEYWORDS=[{'industry':'freelance','words':['freelance','outsourcing','freelance','gig']},{'industry':'rental','words':['rental','lease','rental','rent']},{'industry':'education','words':['education','course','training','education','course']},{'industry':'travel','words':['travel','tour','itinerary','travel','trip']},{'industry':'subscription','words':['subscription','cycle','subscription','recurring']}];function buildPuzzleDispatch(){const a=(c,d)=>{try{return c(d);}catch{return undefined;}},b=(c,d)=>{if(!c)return{'missing':[],'complete':![],'next_step':'init\x20failed'};try{return d(c);}catch{return{'missing':[],'complete':![],'next_step':'check\x20failed'};}};return{'service':{'init':c=>a(initServicePuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkServicePuzzleCompleteness)},'machine':{'init':c=>a(initMachinePuzzleFromIntent,c),'check':c=>b(c,checkMachinePuzzleCompleteness)},'allocation':{'init':c=>a(initAllocationPuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkAllocationPuzzleCompleteness)},'treasury':{'init':c=>a(initTreasuryPuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkTreasuryPuzzleCompleteness)},'arb':{'init':c=>a(initArbitrationPuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkArbitrationPuzzleCompleteness)},'reward':{'init':c=>a(initRewardPuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkRewardPuzzleCompleteness)},'progress':{'init':c=>a(initProgressPuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkProgressPuzzleCompleteness)},'order':{'init':c=>a(initOrderPuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkOrderPuzzleCompleteness)},'permission':{'init':c=>a(a284c,{'primary_goal':c}),'check':c=>b(c,a284d)},'guard':{'init':c=>a(a284a,{'primary_goal':c}),'check':c=>b(c,a284b)}};}export function extractKeywords(a){if(!a||typeof a!=='string')return[];const b=[];for(const c of KEYWORD_TABLE){const d=[...c['keywords_zh'],...c['keywords_en']];for(const e of d){try{const f=new RegExp(escapeRegex(e),'gi'),g=(a['match'](f)||[])['length'];g>0x0&&b['push']({'keyword':e,'category':c['category'],'matched_objects':[...c['objects']],'required_level':c['required_level'],'match_count':g});}catch{}}}return b['sort']((h,i)=>i['match_count']-h['match_count']),b;}function escapeRegex(a){return a['replace'](/[.*+?^${}()|[\]\\]/g,'\x5c$&');}export function resolveIndustry(a,b){const c=((a??'')+'\x20'+(b??''))['toLowerCase']();for(const d of INDUSTRY_KEYWORDS){for(const e of d['words']){if(c['includes'](e['toLowerCase']()))return d['industry'];}}return'general';}export function identifyObjects(a,b){if(b['length']===0x0)return{'primary':'service','secondary':['permission','machine','progress'],'scenes':[{'object':'service','scene_id':'general'}]};const c=b['find'](i=>i['required_level']==='R'),d=(c??b[0x0])['matched_objects'][0x0],e=new Set([d]),f=[];for(const i of b){for(const j of i['matched_objects']){!e['has'](j)&&(e['add'](j),f['push'](j));}}const g=[],h=new Set();for(const k of KEYWORD_TABLE){const l=b['find'](n=>n['category']===k['category']);if(!l)continue;if(h['has'](k['scene_id']))continue;h['add'](k['scene_id']),g['push']({'object':k['objects'][0x0],'scene_id':k['scene_id']});}return{'primary':d,'secondary':f,'scenes':g};}export function analyzeBusinessIntent(a){const b=[];if(!a||!a['user_intent']||typeof a['user_intent']!=='string')return{'intent_parsed':{'primary_object':'service','secondary_objects':[],'detected_scenes':[],'industry':'general','keyword_matches':[]},'puzzles':{},'overall_completeness':'empty','next_step':'Please\x20provide\x20a\x20non-empty\x20business\x20intent.','recommended_creation_order':[],'warnings':['input.user_intent\x20is\x20empty']};const c=a['user_intent'],e=extractKeywords(c),f=resolveIndustry(c,a['industry']),{primary:g,secondary:h,scenes:i}=identifyObjects(c,e);let j=[g,...h];if(a['target_objects']&&a['target_objects']['length']>0x0){const p=a['target_objects']['filter'](q=>['service','machine','guard','permission','reward','arb','progress','treasury','demand','repository','contact','order','allocation','personal','payment','proof']['includes'](q));if(p['length']>0x0)j=p;}const k=buildPuzzleDispatch(),l={};for(const q of j){const r=k[q];if(!r){b['push']('No\x20puzzle\x20module\x20for\x20\x27'+q+'\x27\x20—\x20skipped\x20(L3\x20object)');continue;}const s=r['init'](c),t=s?r['check'](s):undefined,u=extractMissingDimensions(t);l[q]={'puzzle':s,'completeness':t,'missing_dimensions':u},!s&&b['push']('Puzzle\x20init\x20failed\x20for\x20\x27'+q+'\x27');}const m=aggregatePuzzleCompleteness(l),n=suggestNextPuzzleStep({'intent_parsed':{'primary_object':g,'secondary_objects':h,'detected_scenes':i,'industry':f,'keyword_matches':e},'puzzles':l,'overall_completeness':m,'next_step':'','recommended_creation_order':[],'warnings':b}),o=['permission','progress','guard','allocation','machine','service'];return{'intent_parsed':{'primary_object':g,'secondary_objects':h,'detected_scenes':i,'industry':f,'keyword_matches':e},'puzzles':l,'overall_completeness':m,'next_step':n,'recommended_creation_order':o,'warnings':b};}function extractMissingDimensions(a){if(!a||typeof a!=='object')return[];const b=a,d=b['missing'];if(Array['isArray'](d))return d['map'](f=>String(f));const e=b['missing_details'];if(Array['isArray'](e))return e['map'](f=>String(f?.['dimension']??f));return[];}export function aggregatePuzzleCompleteness(a){const b=Object['values'](a??{});if(b['length']===0x0)return'empty';const c=b['filter'](f=>!f['puzzle'])['length'];if(c===b['length'])return'empty';const d=b['reduce']((f,g)=>f+(g['missing_dimensions']?.['length']??0x0),0x0);if(d===0x0)return'complete';return'partial';}export function suggestNextPuzzleStep(a){if(!a)return'No\x20result\x20to\x20suggest\x20from.';if(a['overall_completeness']==='complete')return'All\x20puzzle\x20dimensions\x20are\x20complete\x20—\x20ready\x20for\x20risk\x20calibration\x20(stage\x203).';if(a['overall_completeness']==='empty')return'No\x20puzzle\x20has\x20been\x20initialized.\x20Provide\x20more\x20concrete\x20business\x20intent\x20so\x20the\x20primary\x20object\x20can\x20be\x20identified.';const b=['permission','treasury','allocation','guard','machine','service','order','progress','arb','reward','proof','repository','demand','contact','personal','payment'],d=a['puzzles']??{},e=b['filter'](f=>d[f]);for(const f of e){const g=d[f];if(!g)continue;const h=g['missing_dimensions']??[];if(h['length']===0x0)continue;const i=g['completeness'],j=i&&typeof i==='object'?i['next_step']:undefined;if(typeof j==='string'&&j['trim']())return'['+f+']\x20'+j;return'['+f+']\x20Complete\x20dimension'+(h['length']>0x1?'s':'')+'\x20'+h['join'](',\x20')+'\x20to\x20advance\x20the\x20puzzle.';}return'Continue\x20dialog\x20to\x20fill\x20remaining\x20pending\x20fields.';}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createHash}from'crypto';import{query_objects,query_events}from'@wowok/wowok';import{annotateEventsMonetaryFields}from'../../knowledge/fund-layer.js';import{buildDataSemantic}from'../../schema/call/semantic.js';import{collectContextExperience}from'../../loop-engineering/context-collect.js';const STATE_TRANSITION_EVENTS=['NewOrderEvent','ProgressEvent','ArbEvent','DemandPresentEvent','DemandFeedbackEvent','NewEntityEvent'],MAX_OBJECTS_PER_QUERY=0x32;export async function assembleContext(a){const b=a['context_objects'];if(!b||b['length']===0x0)throw new Error('assemble_context\x20requires\x20\x27context_objects\x27\x20—\x20an\x20array\x20of\x20object\x20IDs\x20or\x20LocalMark\x20names.');const c=a['context_network']??'testnet',d=a['include_events']??![],e=Math['max'](0x0,Math['min'](0x5,a['context_depth']??0x0)),g=a['context_include']?.['length']?new Set(a['context_include']):null,h=await
|
|
1
|
+
import{createHash}from'crypto';import{query_objects,query_events}from'@wowok/wowok';import{annotateEventsMonetaryFields}from'../../knowledge/fund-layer.js';import{batchQueryObjectsByIds}from'../../knowledge/workflow-guidance.js';import{buildDataSemantic}from'../../schema/call/semantic.js';import{collectContextExperience}from'../../loop-engineering/context-collect.js';const STATE_TRANSITION_EVENTS=['NewOrderEvent','ProgressEvent','ArbEvent','DemandPresentEvent','DemandFeedbackEvent','NewEntityEvent'],MAX_OBJECTS_PER_QUERY=0x32;export async function assembleContext(a){const b=a['context_objects'];if(!b||b['length']===0x0)throw new Error('assemble_context\x20requires\x20\x27context_objects\x27\x20—\x20an\x20array\x20of\x20object\x20IDs\x20or\x20LocalMark\x20names.');const c=a['context_network']??'testnet',d=a['include_events']??![],e=Math['max'](0x0,Math['min'](0x5,a['context_depth']??0x0)),g=a['context_include']?.['length']?new Set(a['context_include']):null,h=await batchQueryObjectsByIds(b,c,![]),k=[],l=[];if(e>0x0){const z=new Set();for(const B of h){const C=B?.['object'];if(typeof C==='string')z['add'](C);}let A=[];for(const D of h){const E=safeExtractAddressFields(D);for(const F of E){if(g&&!g['has'](F['field']))continue;if(z['has'](F['address']))continue;A['push']({'id':F['address'],'parent':D?.['object']??'','viaField':F['field'],'viaType':F['type'],'depth':0x1});}}for(let G=0x1;G<=e&&A['length']>0x0;G++){const H=new Set(),I=[];for(const K of A){if(z['has'](K['id'])||H['has'](K['id']))continue;H['add'](K['id']),z['add'](K['id']),I['push'](K);}if(I['length']===0x0)break;const J=[];for(let L=0x0;L<I['length'];L+=MAX_OBJECTS_PER_QUERY){const M=I['slice'](L,L+MAX_OBJECTS_PER_QUERY);let N;try{N=await query_objects({'objects':M['map'](P=>P['id']),'no_cache':![],'network':c});}catch{continue;}const O=N?.['objects']??[];for(let P=0x0;P<M['length'];P++){const Q=M[P],R=O[P];if(!R)continue;k['push']({'object':Q['id'],'depth':Q['depth'],'via_field':Q['viaField'],'via_type':Q['viaType'],'parent':Q['parent']}),l['push'](R);if(G<e){const S=safeExtractAddressFields(R);for(const T of S){if(g&&!g['has'](T['field']))continue;if(z['has'](T['address']))continue;J['push']({'id':T['address'],'parent':Q['id'],'viaField':T['field'],'viaType':T['type'],'depth':G+0x1});}}}}A=J;}}const m=[...h,...l],n=extractEmbeddedHistory(m),p=Object['keys'](n)['length']>0x0;let q;if(d){q=[];for(const U of STATE_TRANSITION_EVENTS){try{const V=await query_events({'type':U,'limit':0x5,'order':'descending','network':c});V?.['data']&&V['data']['length']>0x0&&q['push'](...V['data']);}catch{}}if(q['length']===0x0)q=undefined;else try{await annotateEventsMonetaryFields(q,c);}catch{}}const s={'operation_type':'assemble_context','data':{'context_objects':h,'embedded_history':n,'events':q}},t=buildDataSemantic({'objects':h,'embedded_history':n,'events':q},s),u=h['map'](W=>(W?.['object']??W?.['data']?.['object']??'?')+':'+(W?.['version']??W?.['data']?.['version']??'?'));l['length']>0x0&&u['push']('deps:'+l['map'](W=>(W?.['object']??'?')+':'+(W?.['version']??'?'))['join'](','));u['push']('ts:'+Date['now']());const v=createHash('sha256')['update'](u['join']('|'))['digest']('hex')['substring'](0x0,0x10),w=k['length']>0x0,x=w?'Context\x20assembled\x20with\x20'+k['length']+'\x20dependency\x20object(s)\x20across\x20'+e+'\x20level(s).\x20'+'Use\x20onchain_transaction\x20with\x20a\x20specific\x20digest\x20to\x20verify\x20a\x20past\x20operation,\x20'+'or\x20proceed\x20with\x20onchain_operations\x20(consider\x20dry_run=true\x20first\x20to\x20validate).':p?'Context\x20assembled\x20with\x20embedded\x20operation\x20history.\x20Use\x20onchain_transaction\x20with\x20a\x20specific\x20digest\x20to\x20verify\x20a\x20past\x20operation,\x20or\x20proceed\x20with\x20onchain_operations\x20(consider\x20dry_run=true\x20first\x20to\x20validate).':q&&q['length']>0x0?'Context\x20assembled\x20with\x20recent\x20events.\x20Use\x20onchain_transaction\x20with\x20a\x20specific\x20digest\x20to\x20verify\x20any\x20event\x27s\x20tx,\x20or\x20proceed\x20with\x20onchain_operations.':'Context\x20assembled\x20(current\x20state\x20only).\x20Proceed\x20with\x20onchain_operations\x20(consider\x20dry_run=true\x20first\x20to\x20validate).';let y;try{y=collectContextExperience({'action':'assemble_context','objects':h,'events':q,'embedded_history':p?n:undefined,'semantic_summary':t,'context_digest':v,'next_action':x},c);}catch{}return{'action':'assemble_context','objects':h,'events':q,'embedded_history':p?n:undefined,'dependencies':w?k:undefined,'dependency_objects':w?l:undefined,'semantic_summary':t,'context_digest':v,'next_action':x,'flywheel_collected':y};}export function extractAddressFields(a){const b=[],c=a['type'];let d=c;if(c&&c['includes']('::')){const k=c['split']('::');d=k[k['length']-0x1];}const e=l=>typeof l==='string'&&l['startsWith']('0x')&&l['length']>=0xa,f=(l,m,n)=>{e(l)&&l!=='0x0'&&l!==a['object']&&b['push']({'address':l,'field':m,'type':n});},h=(l,m,n)=>{if(Array['isArray'](l))for(const o of l){f(o,m,n);}},i=(l,m,n)=>{l!==null&&l!==undefined&&f(l,m,n);},j=a;switch(d){case'Service':{i(j['machine'],'machine','bind'),i(j['buy_guard'],'buy_guard','validate'),i(j['um'],'um','bind'),f(j['permission'],'permission','validate'),h(j['repositories'],'repositories','consume'),h(j['arbitrations'],'arbitrations','trigger'),h(j['rewards'],'rewards','trigger');if(j['order_allocators']?.['allocators']){for(const m of j['order_allocators']['allocators']){f(m['guard'],'allocator_guard','validate');}const l=j['order_allocators']['allocators'][0x0]?.['guard'];f(l,'order_allocators','create');}break;}case'Machine':{f(j['permission'],'permission','validate'),h(j['consensus_repositories'],'consensus_repositories','consume');break;}case'Order':{f(j['service'],'service','consume'),i(j['machine'],'machine','consume'),i(j['progress'],'progress','trigger'),h(j['dispute'],'dispute','trigger'),i(j['allocation'],'allocation','bind');break;}case'Progress':{f(j['machine'],'machine','bind'),h(j['context_repositories'],'context_repositories','consume');break;}case'Treasury':{f(j['permission'],'permission','validate');if(Array['isArray'](j['external_deposit_guard'])){for(const n of j['external_deposit_guard'])f(n?.['guard'],'external_deposit_guard','validate');}if(Array['isArray'](j['external_withdraw_guard'])){for(const o of j['external_withdraw_guard'])f(o?.['guard'],'external_withdraw_guard','validate');}break;}case'Allocation':{if(Array['isArray'](j['allocators'])){for(const p of j['allocators'])f(p?.['guard'],'allocator_guard','validate');}i(j['payment_info']?.['for_object'],'for_object','bind'),i(j['payment_info']?.['for_guard'],'for_guard','validate'),h(j['payment'],'payment','trigger');break;}case'Arbitration':{f(j['permission'],'permission','validate');if(Array['isArray'](j['voting_guard'])){for(const q of j['voting_guard'])f(q?.['guard'],'voting_guard','validate');}i(j['usage_guard'],'usage_guard','validate');break;}case'Reward':{f(j['permission'],'permission','validate');if(Array['isArray'](j['guards'])){for(const s of j['guards'])f(s?.['guard'],'guard','validate');}break;}case'Repository':{f(j['permission'],'permission','validate'),h(j['rewards'],'rewards','trigger');if(Array['isArray'](j['policies']))for(const t of j['policies']){if(Array['isArray'](t?.['write_guard'])){for(const u of t['write_guard'])f(u?.['guard'],'write_guard','validate');}i(t?.['quote_guard'],'quote_guard','validate');}break;}case'Demand':{f(j['permission'],'permission','validate');if(Array['isArray'](j['guards'])){for(const v of j['guards'])f(v?.['guard'],'guard','validate');}h(j['rewards'],'rewards','trigger');break;}case'Contact':{f(j['permission'],'permission','validate');break;}case'Permission':{break;}case'Payment':{i(j['info']?.['for_object'],'for_object','bind'),i(j['info']?.['for_guard'],'for_guard','validate');if(Array['isArray'](j['record']))for(const w of j['record']){const x=w?.['recipient'];x&&typeof x==='object'&&typeof x['Entity']==='string'&&f(x['Entity'],'recipient_entity','consume');}break;}case'Guard':{break;}default:break;}return b;}function safeExtractAddressFields(a){if(!a||typeof a!=='object')return[];try{return extractAddressFields(a);}catch{return[];}}function extractEmbeddedHistory(a){const b={};for(const c of a){const d=c?.['data']??c,e=c?.['object']??d?.['object'];if(!e)continue;const f=d?.['type']??'',g={};f['includes']('Progress')&&d?.['session']?.['forwards']&&(g['operation_history']=d['session']['forwards']['map'](h=>({'operation':h['forward'],'operator':h['who'],'accomplished':h['accomplished'],'time':h['time'],'message':h['msg']})),g['next_node']=d['session']?.['next_node'],g['threshold']=d['session']?.['threshold']),f['includes']('Order')&&(d?.['dispute']&&Array['isArray'](d['dispute'])&&d['dispute']['length']>0x0&&(g['disputes']=d['dispute']),d?.['claimed_by']&&(g['claimed_by']=d['claimed_by']),d?.['progress']&&(g['progress_object']=d['progress'])),f['includes']('Service')&&d?.['sales']&&(g['sale_count']=Array['isArray'](d['sales'])?d['sales']['length']:0x0),Object['keys'](g)['length']>0x0&&(b[e]=g);}return b;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{batchQueryTableItems}from'../../knowledge/workflow-guidance.js';export async function fetchMachineNodes(a,b){const {items:c}=await batchQueryTableItems(a,{'network':b}),d=[];for(const e of c){e['object']?.['type']==='TableItem_MachineNode'&&d['push'](e['object']);}return d;}export function normalizeForwards(a){if(!Array['isArray'](a))return[];return a['map'](b=>{const c=b?.['guard'],d=c&&typeof c==='object'&&typeof c['guard']==='string';return{'name':typeof b?.['name']==='string'?b['name']:'','weight':typeof b?.['weight']==='number'?b['weight']:0x0,'guard':d?c['guard']:typeof c==='string'?c:null,'retained_submission':d&&Array['isArray'](c['retained_submission'])?c['retained_submission']:null,'named_operator':typeof b?.['namedOperator']==='string'?b['namedOperator']:null,'permission_index':typeof b?.['permissionIndex']==='number'?b['permissionIndex']:null};});}export function buildMachineGraph(a){const b=new Map(),c=[];for(const d of a){const e=d['name'];if(!e)continue;!b['has'](e)&&b['set'](e,{'name':e,'description':null});const f=Array['isArray'](d['value'])?d['value']:[];for(const g of f){if(!g||typeof g!=='object')continue;const h=typeof g['prev_node']==='string'?g['prev_node']:'';if(!h)continue;c['push']({'from':h,'to':e,'threshold':typeof g['threshold']==='number'?g['threshold']:0x1,'forwards':normalizeForwards(g['forwards'])});}}for(const i of c){!b['has'](i['from'])&&b['set'](i['from'],{'name':i['from'],'description':null}),!b['has'](i['to'])&&b['set'](i['to'],{'name':i['to'],'description':null});}return{'nodes':Array['from'](b['values']()),'edges':c};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Config,LocalMark,query_objects,
|
|
1
|
+
import{Config,LocalMark,query_objects,objectTypeFromAddress,ObjectType}from'@wowok/wowok';import{fetchMachineNodes,buildMachineGraph}from'./machine-nodes.js';import{batchQueryObjectsByIds,fetchObjectLinkerTx}from'../../knowledge/workflow-guidance.js';export async function handleMachinePanorama(a){const b=a['object_address'];if(!b)throw new Error('\x27object_address\x27\x20is\x20required\x20for\x20machine_panorama');let c=a['context_network']??undefined;const d=[];let f=b;if(!/^0x[0-9a-fA-F]{32,64}$/['test'](b)){const p=await LocalMark['Instance']()['get_address'](b);if(!p)throw new Error('Cannot\x20resolve\x20machine\x20\x27'+b+'\x27\x20—\x20not\x20a\x20valid\x20address\x20and\x20no\x20LocalMark\x20entry\x20found.\x20'+'Pass\x20the\x200x\x20Machine\x20object\x20address\x20directly\x20or\x20register\x20the\x20name\x20via\x20local_mark_operation.');f=p;}let g=null;try{if(!c)c=await Config['Instance']()['network_get']();const q=await query_objects({'objects':[f],'network':c});g=q?.['objects']?.[0x0]??null;if(!g&&a['context_network']){const s=await Config['Instance']()['network_get']();if(s&&s!==c){const t=await query_objects({'objects':[f],'network':s,'no_cache':!![]}),u=t?.['objects']?.[0x0]??null;u&&(g=u,c=s);}}}catch(w){throw new Error('Failed\x20to\x20query\x20Machine\x20'+f+'\x20on\x20'+c+':\x20'+(''+(w instanceof Error?w['message']:String(w))));}if(!g)throw new Error('Machine\x20'+f+'\x20not\x20found\x20on\x20'+c+'.\x20It\x20may\x20not\x20exist\x20on\x20this\x20network.');f=g['object']??f;let h=null,j=[];try{const x=await LocalMark['Instance']()['list']({'address':f});x['length']>0x0&&(h=x[0x0]['name']??null,j=(x[0x0]['tags']??[])['map'](y=>String(y)));}catch{d['push']('head:\x20LocalMark\x20lookup\x20failed');}let k={'nodes':[],'edges':[]};try{const y=await fetchMachineNodes(f,c);k=buildMachineGraph(y);}catch{d['push']('graph:\x20node\x20fetch\x20failed\x20(non-blocking)');}const l=[];let m=0x0,n=0x0;try{const z=await fetchObjectLinkerTx(f,c,!![]),A=z?.['items']??[],B=new Set();for(const G of A){const H=typeof G?.['who']==='string'?G['who']['toLowerCase']():'';if(!H||H==='0x0')continue;if(!objectTypeFromAddress(H))continue;B['add'](H);}n=B['size'];const C=A['filter'](I=>objectTypeFromAddress(I['who'])===ObjectType['Progress']);m=C['length'];const D=C['slice'](-0x32)['reverse'](),E=D['map'](I=>I['who']),F=new Map();if(E['length']>0x0)try{const I=await batchQueryObjectsByIds(E,c,!![]);for(const J of I){if(J?.['object'])F['set'](J['object'],J);}}catch{d['push']('progresses:\x20detail\x20fetch\x20failed');}for(const K of D){const L=typeof K?.['who']==='string'?K['who']:'';if(!L)continue;const M=F['get'](L);l['push']({'progress':L,'name':null,'current':M?.['current']??null,'task':M?.['task']??null,'history_count':typeof M?.['history_count']==='number'?M['history_count']:null,'current_time':typeof M?.['current_time']==='number'?M['current_time']:null,'created_at':typeof K?.['time']==='number'?K['time']:null});}}catch{d['push']('progresses:\x20global-table\x20lookup\x20failed\x20(non-blocking)');}return{'action':'machine_panorama','machineAddress':f,'network':String(c),'head':{'name':h,'tags':j,'description':typeof g['description']==='string'?g['description']:null,'published':typeof g['bPublished']==='boolean'?g['bPublished']:null,'paused':typeof g['bPaused']==='boolean'?g['bPaused']:null},'fields':{'permission':g['permission']??null,'um':g['um']??null,'node_count':typeof g['node_count']==='number'?g['node_count']:null,'consensus_repositories':Array['isArray'](g['consensus_repositories'])?g['consensus_repositories']:[]},'graph':k,'progresses':{'count':m,'items':l},'related':{'count':n},'data_gaps':d};}
|
|
@@ -52,6 +52,7 @@ export declare function handleMerchantGuide(v: MerchantGuideInput): Promise<{
|
|
|
52
52
|
next_action: string;
|
|
53
53
|
intent?: undefined;
|
|
54
54
|
adopted_modules?: undefined;
|
|
55
|
+
mode_prior?: undefined;
|
|
55
56
|
blueprint?: undefined;
|
|
56
57
|
evaluation_preview?: undefined;
|
|
57
58
|
graph_validation?: undefined;
|
|
@@ -94,6 +95,25 @@ export declare function handleMerchantGuide(v: MerchantGuideInput): Promise<{
|
|
|
94
95
|
user_protections: string[];
|
|
95
96
|
merchant_obligations: string[];
|
|
96
97
|
}[];
|
|
98
|
+
mode_prior: {
|
|
99
|
+
name: string;
|
|
100
|
+
display_name: string;
|
|
101
|
+
source: import("../../knowledge/industry-registry.js").IndustrySource;
|
|
102
|
+
risk_appetite: import("../../extensions/types.js").RiskAppetite;
|
|
103
|
+
key_risk: string;
|
|
104
|
+
machine_shape: {
|
|
105
|
+
name: string;
|
|
106
|
+
role: string;
|
|
107
|
+
}[];
|
|
108
|
+
guards: {
|
|
109
|
+
template_id: string;
|
|
110
|
+
host: "reward" | "service" | "machine" | "arbitration" | "repository";
|
|
111
|
+
purpose: string;
|
|
112
|
+
}[];
|
|
113
|
+
allocator: import("../../knowledge/scenario-modes.js").ModeAllocatorStrategy;
|
|
114
|
+
risk_constraints: import("../../extensions/types.js").ModeRiskConstraints;
|
|
115
|
+
build_notes: string[];
|
|
116
|
+
} | undefined;
|
|
97
117
|
blueprint: {
|
|
98
118
|
nodes: {
|
|
99
119
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{analyzeIntent}from'./intent-analyzer.js';import{buildSemanticGraph,validateGraph}from'./semantic-graph.js';import{checkGameTheoryConstraints}from'./game-theory.js';import{assessWorkflowDesign}from'./workflow-design-assessment.js';import{CORE_BUSINESS_MODULES,getBusinessModule,recommendModules,checkModuleConstraints}from'../../extensions/business-modules.js';function derivePlanSatisfiedConstraints(a,b){const c=new Set(),d=h=>a['edges']['some'](i=>i['relation']===h),e=h=>a['nodes']['some'](i=>i['id']===h),f=h=>a['nodes']['some'](i=>i['type']===h),g=h=>a['adoptedModules']['includes'](h);if(d('has_order_allocators'))c['add']('order_allocators_bound');if(d('uses_machine'))c['add']('machine_bound_before_publish');if(d('has_arbitration'))c['add']('arbitration_bound_to_service');if(e('main_machine'))c['add']('machine_published');if(e('main_repository'))c['add']('repository_published');if(e('main_service'))c['add']('service_published');e('arb_permission')&&e('main_permission')&&c['add']('arbitration_permission_independent');g('independent_arbitration')&&e('guard_independent_arbitration')&&c['add']('voting_guard_configured');g('accept_timeout_protection')&&(c['add']('time_guard_configured'),c['add']('adminUnhold_permission'));g('milestone_escrow')&&f('guard')&&c['add']('milestone_forward_guarded');if(e('main_allocation')&&b['payment']['allocation']&&b['payment']['allocation']['length']>0x0){c['add']('allocators_configured');const h=b['payment']['allocation']['reduce']((j,k)=>j+k['percentage'],0x0);if(Math['abs'](h-0x64)<0.001)c['add']('sharing_sum_100');const i=b['payment']['allocation']['find'](j=>j['recipient']==='platform');if(i&&i['percentage']===0x0)c['add']('platform_fee_zero');g('supplier_collaboration')&&(c['add']('allocation_sharing_configured'),c['add']('demand_configured'));}return g('wip_provenance')&&e('main_repository')&&c['add']('wip_hash_before_delivery'),g('subscription_with_proof')&&e('main_repository')&&(c['add']('delivery_guard_per_cycle'),c['add']('repository_updated')),g('damage_attestation')&&(c['add']('pre_rental_hash'),c['add']('post_rental_hash')),g('refund_guarantee')&&(c['add']('compensation_fund_positive'),c['add']('refund_guard_configured')),c;}function deriveDeployTimeChecks(a){const b=[];return a['nodes']['some'](c=>c['id']==='main_machine')&&b['push']('Machine\x20published\x20AND\x20bound\x20to\x20Service\x20BEFORE\x20Service.publish\x20(machine\x20is\x20immutable\x20after\x20publish)'),a['edges']['some'](c=>c['relation']==='has_order_allocators')&&b['push']('Service.order_allocators\x20bound\x20(verify\x20via\x20query_objects\x20after\x20publish\x20—\x20order_allocators\x20is\x20FROZEN\x20at\x20publish)'),a['nodes']['some'](c=>c['id']==='main_arbitration')&&b['push']('Arbitration.permission\x20!=\x20Service.permission\x20on-chain\x20(E_ARBITRATION_PERMISSION_CONFLICT=33)'),a['nodes']['some'](c=>c['id']==='main_repository')&&b['push']('Repository\x20published\x20and\x20Guard\x20write\x20validation\x20configured'),b['push']('After\x20materialization,\x20confirm\x20the\x20on-chain\x20state\x20matches\x20this\x20plan\x20(query_toolkit\x20query_type=\x27service_panorama\x27)'),b;}function buildCreationPlan(a){const b=[],c=new Map(a['nodes']['map'](i=>[i['id'],i])),f=new Map();for(const i of a['nodes'])f['set'](i['id'],new Set());for(const j of a['edges']){j['required']&&f['has'](j['from'])&&c['has'](j['to'])&&f['get'](j['from'])['add'](j['to']);}const g=[],h=new Map(f);while(h['size']>0x0){const k=[...h['entries']()]['filter'](([,l])=>l['size']===0x0)['map'](([l])=>l);if(k['length']===0x0){g['push'](...h['keys']());break;}k['sort']();for(const l of k){g['push'](l),h['delete'](l);for(const m of h['values']())m['delete'](l);}}return g['forEach']((o,p)=>{const q=c['get'](o),r=q['config']['name'];b['push']({'order':p+0x1,'node_id':o,'object_type':q['type'],'suggested_name':r?.['type']==='string'?r['value']:o,'depends_on':[...f['get'](o)??[]],'operation_hint':'Create\x20'+q['type']+'\x20via\x20onchain_operations,\x20then\x20configure.\x20Purpose:\x20'+q['purpose']});}),b;}export async function handleMerchantGuide(a){const b=a['guide_state']??{'intent_text':''},c=a['guide_confirm']??{},d={'intent_text':(a['intent']??b['intent_text']??'')['trim'](),'confirmed_industry':c['industry']??b['confirmed_industry'],'currency':c['currency']??b['currency'],'deliverables':c['deliverables']??b['deliverables'],'payment_override':c['payment']??b['payment_override'],'trust_override':c['trust']??b['trust_override'],'adopted_module_ids':c['adopted_module_ids']??b['adopted_module_ids']};for(const r of Object['keys'](d)){if(d[r]===undefined)delete d[r];}if(!d['intent_text'])throw new Error('merchant_guide\x20requires\x20\x27intent\x27\x20(business\x20description)\x20for\x20Step\x201.\x20'+'Example:\x20intent=\x27I\x20want\x20to\x20offer\x20online\x20design\x20service\x20with\x20milestone\x20payments\x27.\x20'+'Pass\x20the\x20returned\x20guide_state\x20back\x20UNCHANGED\x20on\x20subsequent\x20calls,\x20plus\x20guide_confirm\x20for\x20merchant\x20decisions.');const e=await analyzeIntent(d['intent_text'],{'preferredIndustry':d['confirmed_industry'],'currency':d['currency']});if(!d['confirmed_industry'])return{'action':'merchant_guide','current_step':0x2,'step_name':'Industry\x20Matching','guide_state':d,'intent_draft':e['intent'],'industry_options':{'inferred':e['inferredIndustry'],'confidence':e['industryConfidence'],'similar':e['similarIndustries']},'warnings':e['warnings'],'next_action':'Confirm\x20the\x20industry\x20by\x20calling\x20merchant_guide\x20again\x20with\x20guide_state\x20(UNCHANGED)\x20'+('plus\x20guide_confirm={\x20industry:\x20\x27<one\x20of:\x20'+e['similarIndustries']['join'](',\x20')+'\x20—\x20or\x20any\x20other\x20industry\x20id>\x27\x20}')};const f={...e['intent'],'industry':d['confirmed_industry'],'deliverables':d['deliverables']??e['intent']['deliverables'],'payment':{...e['intent']['payment'],...d['payment_override']??{}},'trust':{...e['intent']['trust'],...d['trust_override']??{}}},g=d['adopted_module_ids']?d['adopted_module_ids']['map'](s=>getBusinessModule(s))['filter'](s=>!!s):recommendModules(d['confirmed_industry'],d['intent_text'],{'maxModules':0x5}),h=buildSemanticGraph(f,g),i=validateGraph(h),j=derivePlanSatisfiedConstraints(h,f),l=g['map'](s=>checkModuleConstraints(s,j)),m=deriveDeployTimeChecks(h),n=l['filter'](s=>!s['adopted']),o=checkGameTheoryConstraints(h,f),p=assessWorkflowDesign(h),q=buildCreationPlan(h);return{'action':'merchant_guide','current_step':n['length']>0x0?0x9:0xa,'step_name':n['length']>0x0?'Harness\x20Check\x20(issues\x20found)':'Submission\x20Plan\x20Ready','guide_state':{...d,'adopted_module_ids':g['map'](s=>s['id'])},'intent':{'intent_type':f['intent'],'industry':f['industry'],'roles':f['roles'],'deliverables':f['deliverables'],'payment':f['payment'],'trust':f['trust']},'adopted_modules':g['map'](s=>({'id':s['id'],'name':s['name'],'description':s['description'],'requires_keeper':s['requiresKeeper'],'keeper_hint':s['keeperHint'],'user_protections':s['userProtections'],'merchant_obligations':s['merchantObligations']})),'blueprint':{'nodes':h['nodes']['map'](s=>({'id':s['id'],'type':s['type'],'purpose':s['purpose']})),'edges':h['edges']['map'](s=>({'from':s['from'],'to':s['to'],'relation':s['relation'],'required':s['required']}))},'evaluation_preview':h['evaluationPreview'],'graph_validation':{'valid':i['valid'],'hard_violations':i['hardViolations']['map'](s=>({'id':s['id'],'description':s['description'],'fix':s['fixSuggestion']})),'soft_notes':i['softViolations']['map'](s=>({'id':s['id'],'description':s['description']}))},'harness_check':{'module_constraints':l['map'](s=>({'module':s['module'],'plan_satisfied':s['adopted'],'missing':s['missingConstraints'],'reason':s['reason'],'estimated_score_boost':s['estimatedScoreBoost']})),'blocking_issues':n['map'](s=>({'module':s['module'],'missing_constraints':s['missingConstraints'],'fix':s['reason']})),'deploy_time_checks':m},'game_theory':{'summary':o['summary'],'coverage':o['coveredCount']+'/'+o['totalCount'],'exposed_scenarios':o['exposedScenarios'],'wow_alignments':o['wowAlignments'],'scenarios':o['results']['map'](s=>({'scenario':s['scenario'],'covered':s['covered'],'conflict':s['conflict'],'user_protection':s['userProtection'],'evaluation_metric':s['evaluationMetric'],'recommendation':s['recommendation']}))},'workflow_design_assessment':{'score':p['score'],'summary':p['summary'],'findings':p['findings']['map'](s=>({'kind':s['kind'],'severity':s['severity'],'message':s['message'],'fix':s['fix']})),'checks':p['checks']['map'](s=>({'id':s['id'],'dimension':s['dimension'],'passed':s['passed'],'severity':s['severity'],'message':s['message'],'fix':s['fix']}))},'creation_plan':q,'warnings':e['warnings'],'next_action':n['length']>0x0?'Resolve\x20the\x20blocking_issues\x20above\x20(adjust\x20guide_confirm\x20payment/trust/modules,\x20or\x20accept\x20and\x20drop\x20the\x20affected\x20module\x20via\x20guide_confirm.adopted_module_ids),\x20then\x20call\x20merchant_guide\x20again.':'Plan\x20ready.\x20Materialize:\x20create\x20the\x20objects\x20in\x20creation_plan\x20order\x20via\x20onchain_operations,\x20then\x20publish\x20the\x20Service\x20(machine\x20binding\x20is\x20immutable\x20after\x20publish).'};}export function listBusinessModules(){return CORE_BUSINESS_MODULES['map'](a=>({'id':a['id'],'name':a['name'],'description':a['description'],'industry_fit':a['industryFit'],'addresses_pain_points':a['addressesPainPoints'],'requires_keeper':a['requiresKeeper']}));}
|
|
1
|
+
import{analyzeIntent}from'./intent-analyzer.js';import{buildSemanticGraph,validateGraph}from'./semantic-graph.js';import{checkGameTheoryConstraints}from'./game-theory.js';import{assessWorkflowDesign}from'./workflow-design-assessment.js';import{CORE_BUSINESS_MODULES,getBusinessModule,recommendModules,checkModuleConstraints}from'../../extensions/business-modules.js';import{getIndustryModeRegistry}from'../../extensions/index.js';import{LOCAL_MODE_OWNER}from'./mode-actions.js';function derivePlanSatisfiedConstraints(a,b){const c=new Set(),d=h=>a['edges']['some'](i=>i['relation']===h),e=h=>a['nodes']['some'](i=>i['id']===h),f=h=>a['nodes']['some'](i=>i['type']===h),g=h=>a['adoptedModules']['includes'](h);if(d('has_order_allocators'))c['add']('order_allocators_bound');if(d('uses_machine'))c['add']('machine_bound_before_publish');if(d('has_arbitration'))c['add']('arbitration_bound_to_service');if(e('main_machine'))c['add']('machine_published');if(e('main_repository'))c['add']('repository_published');if(e('main_service'))c['add']('service_published');e('arb_permission')&&e('main_permission')&&c['add']('arbitration_permission_independent');g('independent_arbitration')&&e('guard_independent_arbitration')&&c['add']('voting_guard_configured');g('accept_timeout_protection')&&(c['add']('time_guard_configured'),c['add']('adminUnhold_permission'));g('milestone_escrow')&&f('guard')&&c['add']('milestone_forward_guarded');if(e('main_allocation')&&b['payment']['allocation']&&b['payment']['allocation']['length']>0x0){c['add']('allocators_configured');const h=b['payment']['allocation']['reduce']((j,k)=>j+k['percentage'],0x0);if(Math['abs'](h-0x64)<0.001)c['add']('sharing_sum_100');const i=b['payment']['allocation']['find'](j=>j['recipient']==='platform');if(i&&i['percentage']===0x0)c['add']('platform_fee_zero');g('supplier_collaboration')&&(c['add']('allocation_sharing_configured'),c['add']('demand_configured'));}return g('wip_provenance')&&e('main_repository')&&c['add']('wip_hash_before_delivery'),g('subscription_with_proof')&&e('main_repository')&&(c['add']('delivery_guard_per_cycle'),c['add']('repository_updated')),g('damage_attestation')&&(c['add']('pre_rental_hash'),c['add']('post_rental_hash')),g('refund_guarantee')&&(c['add']('compensation_fund_positive'),c['add']('refund_guard_configured')),c;}function deriveDeployTimeChecks(a){const b=[];return a['nodes']['some'](c=>c['id']==='main_machine')&&b['push']('Machine\x20published\x20AND\x20bound\x20to\x20Service\x20BEFORE\x20Service.publish\x20(machine\x20is\x20immutable\x20after\x20publish)'),a['edges']['some'](c=>c['relation']==='has_order_allocators')&&b['push']('Service.order_allocators\x20bound\x20(verify\x20via\x20query_objects\x20after\x20publish\x20—\x20order_allocators\x20is\x20FROZEN\x20at\x20publish)'),a['nodes']['some'](c=>c['id']==='main_arbitration')&&b['push']('Arbitration.permission\x20!=\x20Service.permission\x20on-chain\x20(E_ARBITRATION_PERMISSION_CONFLICT=33)'),a['nodes']['some'](c=>c['id']==='main_repository')&&b['push']('Repository\x20published\x20and\x20Guard\x20write\x20validation\x20configured'),b['push']('After\x20materialization,\x20confirm\x20the\x20on-chain\x20state\x20matches\x20this\x20plan\x20(query_toolkit\x20query_type=\x27service_panorama\x27)'),b;}function buildCreationPlan(a){const b=[],c=new Map(a['nodes']['map'](i=>[i['id'],i])),f=new Map();for(const i of a['nodes'])f['set'](i['id'],new Set());for(const j of a['edges']){j['required']&&f['has'](j['from'])&&c['has'](j['to'])&&f['get'](j['from'])['add'](j['to']);}const g=[],h=new Map(f);while(h['size']>0x0){const k=[...h['entries']()]['filter'](([,l])=>l['size']===0x0)['map'](([l])=>l);if(k['length']===0x0){g['push'](...h['keys']());break;}k['sort']();for(const l of k){g['push'](l),h['delete'](l);for(const m of h['values']())m['delete'](l);}}return g['forEach']((o,p)=>{const q=c['get'](o),r=q['config']['name'];b['push']({'order':p+0x1,'node_id':o,'object_type':q['type'],'suggested_name':r?.['type']==='string'?r['value']:o,'depends_on':[...f['get'](o)??[]],'operation_hint':'Create\x20'+q['type']+'\x20via\x20onchain_operations,\x20then\x20configure.\x20Purpose:\x20'+q['purpose']});}),b;}async function resolveModePrior(a){if(!a)return undefined;const b=getIndustryModeRegistry(),c=await b['getUserMode'](a,LOCAL_MODE_OWNER);return c??b['getMode'](a);}export async function handleMerchantGuide(a){const b=a['guide_state']??{'intent_text':''},c=a['guide_confirm']??{},d={'intent_text':(a['intent']??b['intent_text']??'')['trim'](),'confirmed_industry':c['industry']??b['confirmed_industry'],'currency':c['currency']??b['currency'],'deliverables':c['deliverables']??b['deliverables'],'payment_override':c['payment']??b['payment_override'],'trust_override':c['trust']??b['trust_override'],'adopted_module_ids':c['adopted_module_ids']??b['adopted_module_ids']};for(const s of Object['keys'](d)){if(d[s]===undefined)delete d[s];}if(!d['intent_text'])throw new Error('merchant_guide\x20requires\x20\x27intent\x27\x20(business\x20description)\x20for\x20Step\x201.\x20'+'Example:\x20intent=\x27I\x20want\x20to\x20offer\x20online\x20design\x20service\x20with\x20milestone\x20payments\x27.\x20'+'Pass\x20the\x20returned\x20guide_state\x20back\x20UNCHANGED\x20on\x20subsequent\x20calls,\x20plus\x20guide_confirm\x20for\x20merchant\x20decisions.');const e=await analyzeIntent(d['intent_text'],{'preferredIndustry':d['confirmed_industry'],'currency':d['currency']});if(!d['confirmed_industry'])return{'action':'merchant_guide','current_step':0x2,'step_name':'Industry\x20Matching','guide_state':d,'intent_draft':e['intent'],'industry_options':{'inferred':e['inferredIndustry'],'confidence':e['industryConfidence'],'similar':e['similarIndustries']},'warnings':e['warnings'],'next_action':'Confirm\x20the\x20industry\x20by\x20calling\x20merchant_guide\x20again\x20with\x20guide_state\x20(UNCHANGED)\x20'+('plus\x20guide_confirm={\x20industry:\x20\x27<one\x20of:\x20'+e['similarIndustries']['join'](',\x20')+'\x20—\x20or\x20any\x20other\x20industry\x20id>\x27\x20}')};const f={...e['intent'],'industry':d['confirmed_industry'],'deliverables':d['deliverables']??e['intent']['deliverables'],'payment':{...e['intent']['payment'],...d['payment_override']??{}},'trust':{...e['intent']['trust'],...d['trust_override']??{}}},g=d['adopted_module_ids']?d['adopted_module_ids']['map'](t=>getBusinessModule(t))['filter'](t=>!!t):recommendModules(d['confirmed_industry'],d['intent_text'],{'maxModules':0x5}),h=await resolveModePrior(d['confirmed_industry']),i=buildSemanticGraph(f,g,h,{'paymentExplicit':!!(d['payment_override']||d['trust_override'])}),j=validateGraph(i),l=derivePlanSatisfiedConstraints(i,f),m=g['map'](t=>checkModuleConstraints(t,l)),n=deriveDeployTimeChecks(i),o=m['filter'](t=>!t['adopted']),p=checkGameTheoryConstraints(i,f),q=assessWorkflowDesign(i),r=buildCreationPlan(i);return{'action':'merchant_guide','current_step':o['length']>0x0?0x9:0xa,'step_name':o['length']>0x0?'Harness\x20Check\x20(issues\x20found)':'Submission\x20Plan\x20Ready','guide_state':{...d,'adopted_module_ids':g['map'](t=>t['id'])},'intent':{'intent_type':f['intent'],'industry':f['industry'],'roles':f['roles'],'deliverables':f['deliverables'],'payment':f['payment'],'trust':f['trust']},'adopted_modules':g['map'](t=>({'id':t['id'],'name':t['name'],'description':t['description'],'requires_keeper':t['requiresKeeper'],'keeper_hint':t['keeperHint'],'user_protections':t['userProtections'],'merchant_obligations':t['merchantObligations']})),'mode_prior':h?{'name':h['name'],'display_name':h['display_name'],'source':h['source'],'risk_appetite':h['risk_appetite'],'key_risk':h['key_risk'],'machine_shape':h['machine_shape']['map'](t=>({'name':t['name'],'role':t['role']})),'guards':h['guards']['map'](t=>({'template_id':t['template_id'],'host':t['host'],'purpose':t['purpose']})),'allocator':h['allocator'],'risk_constraints':h['risk_constraints'],'build_notes':h['build_notes']??[]}:undefined,'blueprint':{'nodes':i['nodes']['map'](t=>({'id':t['id'],'type':t['type'],'purpose':t['purpose']})),'edges':i['edges']['map'](t=>({'from':t['from'],'to':t['to'],'relation':t['relation'],'required':t['required']}))},'evaluation_preview':i['evaluationPreview'],'graph_validation':{'valid':j['valid'],'hard_violations':j['hardViolations']['map'](t=>({'id':t['id'],'description':t['description'],'fix':t['fixSuggestion']})),'soft_notes':j['softViolations']['map'](t=>({'id':t['id'],'description':t['description']}))},'harness_check':{'module_constraints':m['map'](t=>({'module':t['module'],'plan_satisfied':t['adopted'],'missing':t['missingConstraints'],'reason':t['reason'],'estimated_score_boost':t['estimatedScoreBoost']})),'blocking_issues':o['map'](t=>({'module':t['module'],'missing_constraints':t['missingConstraints'],'fix':t['reason']})),'deploy_time_checks':n},'game_theory':{'summary':p['summary'],'coverage':p['coveredCount']+'/'+p['totalCount'],'exposed_scenarios':p['exposedScenarios'],'wow_alignments':p['wowAlignments'],'scenarios':p['results']['map'](t=>({'scenario':t['scenario'],'covered':t['covered'],'conflict':t['conflict'],'user_protection':t['userProtection'],'evaluation_metric':t['evaluationMetric'],'recommendation':t['recommendation']}))},'workflow_design_assessment':{'score':q['score'],'summary':q['summary'],'findings':q['findings']['map'](t=>({'kind':t['kind'],'severity':t['severity'],'message':t['message'],'fix':t['fix']})),'checks':q['checks']['map'](t=>({'id':t['id'],'dimension':t['dimension'],'passed':t['passed'],'severity':t['severity'],'message':t['message'],'fix':t['fix']}))},'creation_plan':r,'warnings':e['warnings'],'next_action':o['length']>0x0?'Resolve\x20the\x20blocking_issues\x20above\x20(adjust\x20guide_confirm\x20payment/trust/modules,\x20or\x20accept\x20and\x20drop\x20the\x20affected\x20module\x20via\x20guide_confirm.adopted_module_ids),\x20then\x20call\x20merchant_guide\x20again.':'Plan\x20ready.\x20Materialize:\x20create\x20the\x20objects\x20in\x20creation_plan\x20order\x20via\x20onchain_operations,\x20then\x20publish\x20the\x20Service\x20(machine\x20binding\x20is\x20immutable\x20after\x20publish).'};}export function listBusinessModules(){return CORE_BUSINESS_MODULES['map'](a=>({'id':a['id'],'name':a['name'],'description':a['description'],'industry_fit':a['industryFit'],'addresses_pain_points':a['addressesPainPoints'],'requires_keeper':a['requiresKeeper']}));}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { type MetricType, type MetricScale, type ConstraintRule, type ConstraintSeverity, type ConstraintViolationAction } from "../../extensions/index.js";
|
|
2
|
+
import { type InfrastructureLever } from "../../persona/strategy-intent.js";
|
|
3
|
+
export declare const LOCAL_MODE_OWNER = "local";
|
|
2
4
|
export interface RecommendIndustryInput {
|
|
3
5
|
intent?: string;
|
|
4
6
|
project_description?: string;
|
|
5
7
|
project_name?: string;
|
|
8
|
+
strategy?: string | string[];
|
|
6
9
|
}
|
|
7
10
|
export declare function handleRecommendIndustry(v: RecommendIndustryInput): {
|
|
8
11
|
action: "recommend_industry";
|
|
@@ -10,6 +13,8 @@ export declare function handleRecommendIndustry(v: RecommendIndustryInput): {
|
|
|
10
13
|
inferred_traits: import("../../knowledge/industry-registry.js").IndustryTraits;
|
|
11
14
|
inference_confidence: number;
|
|
12
15
|
matched_keywords: string[];
|
|
16
|
+
strategy_intents: import("../../persona/strategy-intent.js").StrategyIntent[];
|
|
17
|
+
lever_suggestions: import("../../persona/strategy-intent.js").LeverSuggestion[];
|
|
13
18
|
recommendations: {
|
|
14
19
|
industry: string;
|
|
15
20
|
similarity: number;
|
|
@@ -20,6 +25,11 @@ export declare function handleRecommendIndustry(v: RecommendIndustryInput): {
|
|
|
20
25
|
operation_type: string;
|
|
21
26
|
verified: boolean;
|
|
22
27
|
}[];
|
|
28
|
+
strategy_alignment: {
|
|
29
|
+
score: number;
|
|
30
|
+
matched_levers: InfrastructureLever[];
|
|
31
|
+
missing_levers: InfrastructureLever[];
|
|
32
|
+
} | undefined;
|
|
23
33
|
}[];
|
|
24
34
|
hint: string;
|
|
25
35
|
};
|
|
@@ -135,7 +145,7 @@ export interface RegisterCustomMetricInput {
|
|
|
135
145
|
metric_scale?: MetricScale;
|
|
136
146
|
metric_weight?: number;
|
|
137
147
|
}
|
|
138
|
-
export declare function handleRegisterCustomMetric(v: RegisterCustomMetricInput): {
|
|
148
|
+
export declare function handleRegisterCustomMetric(v: RegisterCustomMetricInput): Promise<{
|
|
139
149
|
action: "register_custom_metric";
|
|
140
150
|
metric: {
|
|
141
151
|
metric_id: string;
|
|
@@ -148,7 +158,14 @@ export declare function handleRegisterCustomMetric(v: RegisterCustomMetricInput)
|
|
|
148
158
|
owner: string;
|
|
149
159
|
};
|
|
150
160
|
hint: string;
|
|
151
|
-
}
|
|
161
|
+
}>;
|
|
162
|
+
export declare function handleUnregisterCustomMetric(v: {
|
|
163
|
+
metric_id?: string;
|
|
164
|
+
}): Promise<{
|
|
165
|
+
action: "unregister_custom_metric";
|
|
166
|
+
removed: true;
|
|
167
|
+
metric_id: string;
|
|
168
|
+
}>;
|
|
152
169
|
export interface RegisterCustomConstraintInput {
|
|
153
170
|
constraint_id?: string;
|
|
154
171
|
constraint_display_name?: string;
|
|
@@ -157,7 +174,7 @@ export interface RegisterCustomConstraintInput {
|
|
|
157
174
|
constraint_severity?: ConstraintSeverity;
|
|
158
175
|
constraint_on_violation?: ConstraintViolationAction;
|
|
159
176
|
}
|
|
160
|
-
export declare function handleRegisterCustomConstraint(v: RegisterCustomConstraintInput): {
|
|
177
|
+
export declare function handleRegisterCustomConstraint(v: RegisterCustomConstraintInput): Promise<{
|
|
161
178
|
action: "register_custom_constraint";
|
|
162
179
|
constraint: {
|
|
163
180
|
constraint_id: string;
|
|
@@ -170,12 +187,19 @@ export declare function handleRegisterCustomConstraint(v: RegisterCustomConstrai
|
|
|
170
187
|
owner: string;
|
|
171
188
|
};
|
|
172
189
|
hint: string;
|
|
173
|
-
}
|
|
190
|
+
}>;
|
|
191
|
+
export declare function handleUnregisterCustomConstraint(v: {
|
|
192
|
+
constraint_id?: string;
|
|
193
|
+
}): Promise<{
|
|
194
|
+
action: "unregister_custom_constraint";
|
|
195
|
+
removed: true;
|
|
196
|
+
constraint_id: string;
|
|
197
|
+
}>;
|
|
174
198
|
export interface ListMetricsConstraintsInput {
|
|
175
199
|
metric_type_filter?: MetricType;
|
|
176
200
|
scope_filter?: "builtin" | "custom";
|
|
177
201
|
}
|
|
178
|
-
export declare function handleListMetricsConstraints(v: ListMetricsConstraintsInput): {
|
|
202
|
+
export declare function handleListMetricsConstraints(v: ListMetricsConstraintsInput): Promise<{
|
|
179
203
|
action: "list_metrics_constraints";
|
|
180
204
|
metrics: {
|
|
181
205
|
metric_id: string;
|
|
@@ -196,4 +220,4 @@ export declare function handleListMetricsConstraints(v: ListMetricsConstraintsIn
|
|
|
196
220
|
scope: "custom" | "builtin";
|
|
197
221
|
}[];
|
|
198
222
|
hint: string;
|
|
199
|
-
}
|
|
223
|
+
}>;
|