@sleep2agi/agent-network 2.3.0-preview.2 → 2.3.0-preview.21
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/bin/cli.d.ts +3 -1
- package/dist/bin/cli.js +1 -1
- package/dist/bin/goal-wake-log-render.d.ts +31 -0
- package/dist/src/client.js +1 -1
- package/dist/src/environ-alias.d.ts +14 -0
- package/dist/src/im/access-resolve.d.ts +103 -0
- package/dist/src/im/feishu/adapter.d.ts +106 -1
- package/dist/src/im/feishu/bridge.d.ts +7 -0
- package/dist/src/im/feishu/config.d.ts +31 -0
- package/dist/src/im/feishu/hub-upload.d.ts +88 -0
- package/dist/src/im/feishu/markdown-image-renderer.d.ts +61 -0
- package/dist/src/im/feishu/outbound-marker.d.ts +140 -0
- package/dist/src/im/feishu/outbound-paths.d.ts +50 -0
- package/dist/src/im/feishu/outbound-route.d.ts +62 -0
- package/dist/src/im/feishu/worker.js +390 -16
- package/dist/src/im/types.d.ts +38 -1
- package/dist/src/node-server.js +1 -1
- package/dist/src/normalize-runtime.d.ts +9 -0
- package/dist/src/opencode-pin.d.ts +41 -0
- package/dist/src/opencode-preset.d.ts +43 -0
- package/dist/src/project-key.d.ts +1 -0
- package/package.json +6 -3
package/dist/src/im/types.d.ts
CHANGED
|
@@ -72,13 +72,42 @@ export interface NormalizedIMEvent {
|
|
|
72
72
|
mentioned: boolean;
|
|
73
73
|
content: {
|
|
74
74
|
text?: string;
|
|
75
|
-
/** Local filesystem paths to already-downloaded images.
|
|
75
|
+
/** Local filesystem paths to already-downloaded images.
|
|
76
|
+
*
|
|
77
|
+
* RFC-020 §17 backward-compat shim: the new richer
|
|
78
|
+
* `attachments[]` field below is the canonical source going
|
|
79
|
+
* forward. `images` stays a `string[]` of paths so an older
|
|
80
|
+
* agent-node worker reading this envelope across a rolling
|
|
81
|
+
* upgrade doesn't crash. New workers prefer `attachments`,
|
|
82
|
+
* old workers ignore it and keep using `images`. */
|
|
76
83
|
images?: string[];
|
|
77
84
|
files?: {
|
|
78
85
|
name: string;
|
|
79
86
|
path?: string;
|
|
80
87
|
url?: string;
|
|
81
88
|
}[];
|
|
89
|
+
/** RFC-020 §17 cross-machine attachment descriptors.
|
|
90
|
+
*
|
|
91
|
+
* Each entry mirrors `meta.attachments[]` on commhub tasks
|
|
92
|
+
* (`{ type, file_id?, path?, mime?, name?, size? }`). The
|
|
93
|
+
* feishu bridge populates `file_id` by uploading inbound
|
|
94
|
+
* files to `/api/upload` so cross-host agents delegated via
|
|
95
|
+
* `commhub_send_task(meta.attachments=...)` can fetch via
|
|
96
|
+
* `/api/files/<id>`. When upload fails, `file_id` is absent
|
|
97
|
+
* and the descriptor degrades to path-only (single-host
|
|
98
|
+
* still works via local Read; no regression vs pre-fix
|
|
99
|
+
* baseline).
|
|
100
|
+
*
|
|
101
|
+
* Always populated alongside `images` for the same files —
|
|
102
|
+
* duplication is intentional for rolling-upgrade safety. */
|
|
103
|
+
attachments?: Array<{
|
|
104
|
+
type: "image" | "file";
|
|
105
|
+
path?: string;
|
|
106
|
+
file_id?: string;
|
|
107
|
+
mime?: string;
|
|
108
|
+
name?: string;
|
|
109
|
+
size?: number;
|
|
110
|
+
}>;
|
|
82
111
|
};
|
|
83
112
|
/**
|
|
84
113
|
* Original platform payload. Default: held in memory only and dropped after
|
|
@@ -115,6 +144,14 @@ export interface NormalizedIMMessage {
|
|
|
115
144
|
replyToMessageId?: string;
|
|
116
145
|
/** Ephemeral / visible-to-sender-only. Slack only; others ignore. */
|
|
117
146
|
ephemeral?: boolean;
|
|
147
|
+
/** Caption-mode hint (RFC-020 §15.2): bypass markdown-card / markdown→PNG
|
|
148
|
+
* rendering and send as plain text. Set by the bridge when the same
|
|
149
|
+
* dispatch loop is also sending one or more attachment files — the text
|
|
150
|
+
* is a caption ("here's the report"), not the deliverable. Without this
|
|
151
|
+
* hint, Vincent's "make me a PDF" UAT had the bot's accompanying
|
|
152
|
+
* description heading + bullet list rendered to PNG via #329, which
|
|
153
|
+
* read as "you sent another image" instead of "you sent my file". */
|
|
154
|
+
forceTextOnly?: boolean;
|
|
118
155
|
/** Tie back to the commhub task that produced this message. */
|
|
119
156
|
correlation: {
|
|
120
157
|
taskId: string;
|
package/dist/src/node-server.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
const a0_0x193669=a0_0x2430;(function(_0x593117,_0xa976d7){const _0x7bd123=a0_0x2430,_0x5da658=_0x593117();while(!![]){try{const _0x84ab2e=parseInt(_0x7bd123(0x1f3))/0x1*(parseInt(_0x7bd123(0x1c0))/0x2)+-parseInt(_0x7bd123(0x190))/0x3+-parseInt(_0x7bd123(0x1ea))/0x4+parseInt(_0x7bd123(0x19f))/0x5+-parseInt(_0x7bd123(0x1c7))/0x6*(-parseInt(_0x7bd123(0x20c))/0x7)+parseInt(_0x7bd123(0x1d3))/0x8*(parseInt(_0x7bd123(0x1be))/0x9)+-parseInt(_0x7bd123(0x1dc))/0xa;if(_0x84ab2e===_0xa976d7)break;else _0x5da658['push'](_0x5da658['shift']());}catch(_0x493ec9){_0x5da658['push'](_0x5da658['shift']());}}}(a0_0x2a6f,0x4f63c));import{readFileSync as a0_0x44c519,existsSync as a0_0x19da89}from'fs';import{randomUUID as a0_0x4968da}from'crypto';import{join as a0_0x1843f3}from'path';import{hostname as a0_0x4ad13a}from'os';import{execSync as a0_0x4a5f1d}from'child_process';import{Server as a0_0x2a8829}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x58076e}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x449c53,CallToolRequestSchema as a0_0x1520fd}from'@modelcontextprotocol/sdk/types.js';function I(_0x2ca5de){const _0x2e5a27=a0_0x2430;if(!a0_0x19da89(_0x2ca5de))return;for(let _0x908165 of a0_0x44c519(_0x2ca5de,'utf-8')[_0x2e5a27(0x1e6)]('\x0a')){let _0x3448a=_0x908165[_0x2e5a27(0x211)]();if(!_0x3448a||_0x3448a['startsWith']('#'))continue;let _0x5df3da=_0x3448a[_0x2e5a27(0x20e)]('=');if(_0x5df3da<0x0)continue;let _0x31dc80=_0x3448a[_0x2e5a27(0x1ab)](0x0,_0x5df3da)[_0x2e5a27(0x211)](),_0x35d471=_0x3448a[_0x2e5a27(0x1ab)](_0x5df3da+0x1)[_0x2e5a27(0x211)]()['replace'](/^["']|["']$/g,'');if(!process.env[_0x31dc80])process.env[_0x31dc80]=_0x35d471;}}var L=process.env.HOME||'~',U=a0_0x1843f3(L,a0_0x193669(0x1f0));I(a0_0x1843f3(U,a0_0x193669(0x1c1)));var v=process[a0_0x193669(0x19a)]()[a0_0x193669(0x1c3)](/\//g,'-');I(a0_0x1843f3(U,v,a0_0x193669(0x1c1)));function d(){const _0x3d9960=a0_0x193669;try{return a0_0x4a5f1d('tmux\x20display-message\x20-p\x20\x27#S\x27',{'encoding':_0x3d9960(0x19c),'timeout':0x7d0})['trim']();}catch{return'';}}function m(){const _0xb86702=a0_0x193669;try{let _0x2c700e=a0_0x1843f3(L,'.anet',_0xb86702(0x19b));if(a0_0x19da89(_0x2c700e))return JSON[_0xb86702(0x21e)](a0_0x44c519(_0x2c700e,_0xb86702(0x19c)));}catch{}return{};}var u=m(),j=process.env.COMMHUB_URL||u[a0_0x193669(0x217)]||a0_0x193669(0x1f2),f=process.env.COMMHUB_TMUX||d();function r(){const _0x146d32=a0_0x193669;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS[_0x146d32(0x211)]())return process.env.COMMHUB_ALIAS[_0x146d32(0x211)]();return process[_0x146d32(0x215)][_0x146d32(0x1fb)]('[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20'+('would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME='+(f||_0x146d32(0x1f5))+_0x146d32(0x1ac)+a0_0x4ad13a()+'.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a')),'unattributed-'+process['pid'];}var G=r(),K=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x4968da(),F=process.env.COMMHUB_TOKEN||u[a0_0x193669(0x1b9)]||'';function W(_0x59cf3d){const _0x300654=a0_0x193669;let _0x4f98e1=new Date()[_0x300654(0x1bc)]()[_0x300654(0x1ab)](0x0,0x8);process[_0x300654(0x215)][_0x300654(0x1fb)]('['+_0x4f98e1+_0x300654(0x1fd)+_0x59cf3d+'\x0a');}function a0_0x2430(_0x4b1b7f,_0x26d08c){_0x4b1b7f=_0x4b1b7f-0x18e;const _0x2a6fa3=a0_0x2a6f();let _0x2430c0=_0x2a6fa3[_0x4b1b7f];return _0x2430c0;}function N(_0x550ac0){return new Promise(_0x47cd66=>setTimeout(_0x47cd66,_0x550ac0));}W(a0_0x193669(0x1a7)+j+'\x20ALIAS='+G+'\x20RESUME_ID='+K[a0_0x193669(0x1ab)](0x0,0x8)+'...\x20TMUX='+(f||a0_0x193669(0x1ee))+a0_0x193669(0x1cc)+process[a0_0x193669(0x19a)]()+a0_0x193669(0x218)+v);var D=new Map(),x=new a0_0x2a8829({'name':'commhub-channel','version':a0_0x193669(0x210)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x193669(0x196),a0_0x193669(0x1bd),a0_0x193669(0x1c4),'You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.',a0_0x193669(0x1e5)+G][a0_0x193669(0x208)]('\x0a')});function a0_0x2a6f(){const _0x156167=['stringify','new_message','2553060GLQrgK','Target\x20session\x20alias','commhub_get_all_status','SSE\x20stream\x20ended,\x20reconnecting...','shutting\x20down,\x20reporting\x20offline...','replied','message','registered\x20as\x20\x22','ENV:\x20URL=','setRequestHandler','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','connecting\x20to\x20','slice','\x20/\x20hostname=','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','completed','SSE\x20error:\x20','low','no\x20response','alias','blocked','data:\x20','text','fatal:\x20','params','commhub_report_status','token','object','priority','toTimeString','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','117Zqnabv','warning:\x20could\x20not\x20register:\x20','68754wDoSya','.env','Message\x20content','replace','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','find','content','1211172CAhCtd','parse\x20error:\x20','startsWith','catch','commhub_send_message','\x20CWD=','offline','SSE\x20connected\x20as\x20\x22','stdin','inbox_count','unknown\x20tool','Current\x20task\x20description','299400qMUItP','from_session','commhub_send_task','decode','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','commhub','min','Bearer\x20','idle','4293020lxYKSl','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','commhub_reply','notification','commhub-channel','error','length','2.0','type','Session\x20alias:\x20','split','CommHub\x20init\x20failed:\x20','Reply\x20text\x20/\x20result\x20summary','cancelled','1828884FATaHN','MCP\x20stdio\x20connected','session\x20disconnected','exit','none','string','.claude/channels/commhub','statusText','http://127.0.0.1:9200','1CTmwyE','claude-code','(none)','in_progress','from','body','ack_inbox','task','write','SIGTERM',']\x20[commhub]\x20','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','new_task','status','ready\x20—\x20waiting\x20for\x20events','message_id',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','end','get_all_status','\x20from\x20',':\x20inbox_count=','join','tools/call','result','getReader','7HrRCHO','Task\x20content','indexOf','/mcp','0.3.0','trim','report_status','now','notifications/claude/channel','stderr','re-registered\x20as\x20\x22','hub','\x20PROJECT_ENV=','pop','connected','\x22\x20after\x20SSE\x20reconnect','set','broadcast','parse','delete','working','re-register\x20failed:\x20','application/json,\x20text/event-stream','connect','65019dTPoOM','normal','get_inbox','failed','Priority\x20(default:\x20normal)','starting\x20SSE\x20listener...','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','Progress\x200-100','initialize','POST','cwd','config.json','utf-8'];a0_0x2a6f=function(){return _0x156167;};return a0_0x2a6f();}x[a0_0x193669(0x1a8)](a0_0x449c53,async()=>({'tools':[{'name':a0_0x193669(0x1de),'description':a0_0x193669(0x1dd),'inputSchema':{'type':a0_0x193669(0x1ba),'properties':{'task_id':{'type':a0_0x193669(0x1ef),'description':a0_0x193669(0x1fe)},'text':{'type':a0_0x193669(0x1ef),'description':a0_0x193669(0x1e8)},'status':{'type':a0_0x193669(0x1ef),'enum':[a0_0x193669(0x1ae),a0_0x193669(0x193),a0_0x193669(0x1e9),'blocked',a0_0x193669(0x1e1),a0_0x193669(0x1f6)],'description':a0_0x193669(0x1a9)}},'required':['text']}},{'name':a0_0x193669(0x1b8),'description':'Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','inputSchema':{'type':a0_0x193669(0x1ba),'properties':{'status':{'type':a0_0x193669(0x1ef),'enum':['working','idle',a0_0x193669(0x1b3),a0_0x193669(0x1e1)]},'task':{'type':a0_0x193669(0x1ef),'description':a0_0x193669(0x1d2)},'progress':{'type':'number','description':a0_0x193669(0x197)}},'required':[a0_0x193669(0x200)]}},{'name':a0_0x193669(0x1d5),'description':a0_0x193669(0x1ad),'inputSchema':{'type':a0_0x193669(0x1ba),'properties':{'alias':{'type':'string','description':a0_0x193669(0x1a0)},'task':{'type':'string','description':a0_0x193669(0x20d)},'priority':{'type':a0_0x193669(0x1ef),'enum':['high','normal',a0_0x193669(0x1b0)],'description':a0_0x193669(0x194)}},'required':[a0_0x193669(0x1b2),a0_0x193669(0x1fa)]}},{'name':'commhub_send_message','description':'Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','inputSchema':{'type':'object','properties':{'alias':{'type':a0_0x193669(0x1ef),'description':a0_0x193669(0x1a0)},'message':{'type':a0_0x193669(0x1ef),'description':a0_0x193669(0x1c2)}},'required':[a0_0x193669(0x1b2),a0_0x193669(0x1a5)]}},{'name':a0_0x193669(0x1a1),'description':'Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','inputSchema':{'type':a0_0x193669(0x1ba),'properties':{}}}]}));async function Y(_0x168976,_0x124495){const _0x5b522e=a0_0x193669;let _0x2470ce=await fetch(j+_0x5b522e(0x20f),{'method':_0x5b522e(0x199),'headers':{'Content-Type':'application/json','Accept':_0x5b522e(0x18e),...F?{'Authorization':_0x5b522e(0x1da)+F}:{}},'body':JSON['stringify']({'jsonrpc':'2.0','id':0x1,'method':_0x5b522e(0x198),'params':{'protocolVersion':'2025-03-26','capabilities':{},'clientInfo':{'name':_0x5b522e(0x1e0),'version':_0x5b522e(0x210)}}})});if(!_0x2470ce['ok']){let _0x43c200=await _0x2470ce[_0x5b522e(0x1b5)]();return W(_0x5b522e(0x1e7)+_0x2470ce[_0x5b522e(0x200)]+'\x20'+_0x43c200['slice'](0x0,0x64)),{'ok':!0x1,'error':'init\x20failed:\x20'+_0x2470ce[_0x5b522e(0x200)]};}await _0x2470ce[_0x5b522e(0x1b5)]();let _0x5af720=(await(await fetch(j+_0x5b522e(0x20f),{'method':_0x5b522e(0x199),'headers':{'Content-Type':'application/json','Accept':_0x5b522e(0x18e),...F?{'Authorization':_0x5b522e(0x1da)+F}:{}},'body':JSON[_0x5b522e(0x19d)]({'jsonrpc':_0x5b522e(0x1e3),'id':0x2,'method':_0x5b522e(0x209),'params':{'name':_0x168976,'arguments':_0x124495}})}))[_0x5b522e(0x1b5)]())[_0x5b522e(0x1e6)]('\x0a')[_0x5b522e(0x1c5)](_0x4f6d24=>_0x4f6d24[_0x5b522e(0x1c9)](_0x5b522e(0x1b4)));if(_0x5af720){let _0x4d72bd=JSON[_0x5b522e(0x21e)](_0x5af720[_0x5b522e(0x1ab)](0x6));return _0x4d72bd?.['result']?.['content']?.[0x0]?.['text']?JSON[_0x5b522e(0x21e)](_0x4d72bd[_0x5b522e(0x20a)][_0x5b522e(0x1c6)][0x0][_0x5b522e(0x1b5)]):_0x4d72bd;}return{'ok':!0x1,'error':_0x5b522e(0x1b1)};}x[a0_0x193669(0x1a8)](a0_0x1520fd,async _0x244963=>{const _0x778788=a0_0x193669;let {name:_0x48f7e9,arguments:_0x1639fe}=_0x244963[_0x778788(0x1b7)];if(_0x48f7e9===_0x778788(0x1de)){let {task_id:_0x187c97,text:_0x6adb20,status:_0x59f23f}=_0x1639fe;if(_0x59f23f===_0x778788(0x1ae)||_0x59f23f===_0x778788(0x193)||_0x59f23f==='cancelled'){let _0x31028a=_0x59f23f===_0x778788(0x1ae)?_0x778788(0x1a4):_0x59f23f,_0x37db71=_0x187c97?D['get'](_0x187c97)||_0x778788(0x217):_0x778788(0x217),_0x520dd7=await Y('send_reply',{'alias':_0x37db71,'text':_0x6adb20,'in_reply_to':_0x187c97||void 0x0,'status':_0x31028a,'from_session':G});if(_0x187c97)D[_0x778788(0x21f)](_0x187c97);return{'content':[{'type':_0x778788(0x1b5),'text':JSON['stringify'](_0x520dd7)}]};}let _0x163b96=await Y(_0x778788(0x212),{'resume_id':K,'alias':G,'status':_0x59f23f===_0x778788(0x1b3)?_0x778788(0x1b3):_0x59f23f===_0x778788(0x1e1)?'error':_0x778788(0x220),'task':_0x6adb20[_0x778788(0x1ab)](0x0,0xc8),'output':_0x6adb20});return{'content':[{'type':_0x778788(0x1b5),'text':JSON['stringify'](_0x163b96)}]};}if(_0x48f7e9==='commhub_report_status'){let {status:_0x5dac0d,task:_0x3236a8,progress:_0xc33f86}=_0x1639fe,_0x218117=await Y(_0x778788(0x212),{'resume_id':K,'alias':G,'status':_0x5dac0d,'task':_0x3236a8,'progress':_0xc33f86});return{'content':[{'type':_0x778788(0x1b5),'text':JSON[_0x778788(0x19d)](_0x218117)}]};}if(_0x48f7e9===_0x778788(0x1d5)){let {alias:_0x6cb6b8,task:_0x176a6a,priority:_0x305b0e}=_0x1639fe,_0x3cac46=await Y('send_task',{'alias':_0x6cb6b8,'task':_0x176a6a,'priority':_0x305b0e||_0x778788(0x191),'from_session':G});return{'content':[{'type':_0x778788(0x1b5),'text':JSON[_0x778788(0x19d)](_0x3cac46)}]};}if(_0x48f7e9===_0x778788(0x1cb)){let {alias:_0x1c102f,message:_0xed3ef7}=_0x1639fe,_0x59f59e=await Y('send_message',{'alias':_0x1c102f,'message':_0xed3ef7,'from_session':G});return{'content':[{'type':_0x778788(0x1b5),'text':JSON[_0x778788(0x19d)](_0x59f59e)}]};}if(_0x48f7e9===_0x778788(0x1a1)){let _0x4e0c26=await Y(_0x778788(0x205),{});return{'content':[{'type':_0x778788(0x1b5),'text':JSON[_0x778788(0x19d)](_0x4e0c26)}]};}return{'content':[{'type':_0x778788(0x1b5),'text':JSON['stringify']({'error':_0x778788(0x1d1)})}]};});var O=0x3e8,R=0x7530,T=0x36ee80;async function l(){const _0x33edc8=a0_0x193669;try{await Y(_0x33edc8(0x212),{'resume_id':K,'alias':G,'status':'idle','server':a0_0x4ad13a(),'hostname':a0_0x4ad13a(),'agent':_0x33edc8(0x1f4),'project_dir':process[_0x33edc8(0x19a)](),'tmux_name':f||void 0x0}),W(_0x33edc8(0x216)+G+_0x33edc8(0x21b));}catch(_0x597ba7){W(_0x33edc8(0x221)+_0x597ba7);}}async function o(){const _0x1b9c74=a0_0x193669;let _0x54d47c=j+'/events/'+encodeURIComponent(G),_0x472a59={};if(F)_0x472a59['Authorization']=_0x1b9c74(0x1da)+F;W(_0x1b9c74(0x1aa)+_0x54d47c);let _0x2730b0=O,_0x3c5e4b=!0x0,_0x788c4e=null;while(!0x0){try{let _0x4e6f39=await fetch(_0x54d47c,{'headers':_0x472a59});if(!_0x4e6f39['ok']){if(W(_0x1b9c74(0x1af)+_0x4e6f39[_0x1b9c74(0x200)]+'\x20'+_0x4e6f39[_0x1b9c74(0x1f1)]),_0x788c4e=_0x788c4e??Date['now'](),Date[_0x1b9c74(0x213)]()-_0x788c4e>T){W(_0x1b9c74(0x1d7)+j+_0x1b9c74(0x203));return;}await N(_0x2730b0),_0x2730b0=Math[_0x1b9c74(0x1d9)](_0x2730b0*0x2,R);continue;}let _0x1958c6=_0x4e6f39[_0x1b9c74(0x1f8)][_0x1b9c74(0x20b)](),_0x50f421=new TextDecoder(),_0x54c148='';_0x2730b0=O;while(!0x0){let {done:_0x27b274,value:_0xd8f27f}=await _0x1958c6['read']();if(_0x27b274)break;_0x54c148+=_0x50f421[_0x1b9c74(0x1d6)](_0xd8f27f,{'stream':!0x0});let _0xbd4b97=_0x54c148[_0x1b9c74(0x1e6)]('\x0a\x0a');_0x54c148=_0xbd4b97[_0x1b9c74(0x219)]()||'';for(let _0x31f2d2 of _0xbd4b97){let _0x47f9eb=_0x31f2d2[_0x1b9c74(0x1e6)]('\x0a')['find'](_0x22f8ca=>_0x22f8ca['startsWith'](_0x1b9c74(0x1b4)));if(!_0x47f9eb)continue;try{let _0x4752d0=JSON['parse'](_0x47f9eb[_0x1b9c74(0x1ab)](0x6));if(await a(_0x4752d0),_0x4752d0[_0x1b9c74(0x1e4)]===_0x1b9c74(0x21a)){if(_0x788c4e=null,!_0x3c5e4b)await l();_0x3c5e4b=!0x1;}}catch(_0x437e2e){W(_0x1b9c74(0x1c8)+_0x437e2e);}}}W(_0x1b9c74(0x1a2));}catch(_0x35991c){W('SSE\x20connection\x20error:\x20'+_0x35991c);}if(_0x788c4e=_0x788c4e??Date[_0x1b9c74(0x213)](),Date['now']()-_0x788c4e>T){W(_0x1b9c74(0x1d7)+j+')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。');return;}await N(_0x2730b0),_0x2730b0=Math[_0x1b9c74(0x1d9)](_0x2730b0*0x2,R);}}async function a(_0x32771b){const _0x5978c7=a0_0x193669;if(_0x32771b['type']==='connected'){W(_0x5978c7(0x1ce)+G+'\x22');return;}if(_0x32771b[_0x5978c7(0x1e4)]===_0x5978c7(0x19e)){if(W('←\x20message\x20from\x20'+_0x32771b[_0x5978c7(0x1f7)]+':\x20'+_0x32771b[_0x5978c7(0x1a5)][_0x5978c7(0x1ab)](0x0,0x3c)),await x[_0x5978c7(0x1df)]({'method':_0x5978c7(0x214),'params':{'content':_0x32771b['message'],'meta':{'sender':_0x32771b[_0x5978c7(0x1f7)]||_0x5978c7(0x217),'sender_id':_0x5978c7(0x1d8),'user':_0x32771b[_0x5978c7(0x1f7)]||_0x5978c7(0x217),'priority':_0x5978c7(0x191)}}}),_0x32771b[_0x5978c7(0x202)])await Y(_0x5978c7(0x1f9),{'alias':G,'message_id':_0x32771b[_0x5978c7(0x202)]});return;}if(_0x32771b[_0x5978c7(0x1e4)]===_0x5978c7(0x1ff)||_0x32771b[_0x5978c7(0x1e4)]===_0x5978c7(0x21d)){W('←\x20'+_0x32771b['type']+_0x5978c7(0x207)+_0x32771b[_0x5978c7(0x1d0)]+'\x20priority='+(_0x32771b[_0x5978c7(0x1bb)]||_0x5978c7(0x191)));let _0x15e15b=await Y(_0x5978c7(0x192),{'alias':G,'limit':0x5});if(_0x15e15b?.['ok']&&_0x15e15b['messages']?.[_0x5978c7(0x1e2)]>0x0)for(let _0x1be1f6 of _0x15e15b['messages']){let _0x528625={'sender':_0x1be1f6['from_session']||'hub','sender_id':_0x5978c7(0x1d8),'user':_0x1be1f6[_0x5978c7(0x1d4)]||_0x5978c7(0x217),'task_id':_0x1be1f6['id'],'priority':_0x1be1f6['priority']||_0x5978c7(0x191)};D[_0x5978c7(0x21c)](_0x1be1f6['id'],_0x1be1f6['from_session']||_0x5978c7(0x217)),await x[_0x5978c7(0x1df)]({'method':_0x5978c7(0x214),'params':{'content':_0x1be1f6[_0x5978c7(0x1c6)],'meta':_0x528625}}),W('→\x20injected\x20task\x20'+_0x1be1f6['id'][_0x5978c7(0x1ab)](0x0,0x8)+_0x5978c7(0x206)+_0x1be1f6[_0x5978c7(0x1d4)]+':\x20'+_0x1be1f6[_0x5978c7(0x1c6)][_0x5978c7(0x1ab)](0x0,0x3c)),await Y(_0x5978c7(0x1f9),{'alias':G,'message_id':_0x1be1f6['id']});}}}async function n(){const _0x602df3=a0_0x193669;let _0x3540b6=new a0_0x58076e();await x[_0x602df3(0x18f)](_0x3540b6),W(_0x602df3(0x1eb)),W(_0x602df3(0x195)),o()['catch'](_0x45a77a=>W('SSE\x20fatal:\x20'+_0x45a77a)),Y(_0x602df3(0x212),{'resume_id':K,'alias':G,'status':_0x602df3(0x1db),'server':a0_0x4ad13a(),'hostname':a0_0x4ad13a(),'agent':_0x602df3(0x1f4),'project_dir':process[_0x602df3(0x19a)](),'tmux_name':f||void 0x0})['then'](()=>W(_0x602df3(0x1a6)+G+'\x22\x20('+K['slice'](0x0,0x8)+')'))[_0x602df3(0x1ca)](_0x6addf4=>W(_0x602df3(0x1bf)+_0x6addf4)),setInterval(()=>{const _0x2fab15=_0x602df3;Y(_0x2fab15(0x212),{'resume_id':K,'alias':G,'status':_0x2fab15(0x1db),'server':a0_0x4ad13a(),'hostname':a0_0x4ad13a(),'agent':'claude-code','project_dir':process['cwd'](),'tmux_name':f||void 0x0})[_0x2fab15(0x1ca)](_0x27cc4b=>W('heartbeat\x20failed:\x20'+_0x27cc4b));},0x2bf20),W(_0x602df3(0x201));}n()[a0_0x193669(0x1ca)](_0x583d21=>{const _0x1833cf=a0_0x193669;W(_0x1833cf(0x1b6)+_0x583d21),process[_0x1833cf(0x1ed)](0x1);});async function b(){const _0x25c833=a0_0x193669;W(_0x25c833(0x1a3)),await Y(_0x25c833(0x212),{'resume_id':K,'alias':G,'status':_0x25c833(0x1cd),'task':_0x25c833(0x1ec)})[_0x25c833(0x1ca)](()=>{}),process[_0x25c833(0x1ed)](0x0);}process[a0_0x193669(0x1cf)]['on'](a0_0x193669(0x204),()=>b()),process['on'](a0_0x193669(0x1fc),()=>b()),process['on']('SIGINT',()=>b());
|
|
2
|
+
const a0_0x433c2f=a0_0xb524;(function(_0xb2c8bd,_0x1229e0){const _0x359232=a0_0xb524,_0x32eac3=_0xb2c8bd();while(!![]){try{const _0x459b1f=parseInt(_0x359232(0x247))/0x1*(-parseInt(_0x359232(0x1b7))/0x2)+-parseInt(_0x359232(0x200))/0x3*(parseInt(_0x359232(0x1cc))/0x4)+-parseInt(_0x359232(0x201))/0x5*(parseInt(_0x359232(0x245))/0x6)+parseInt(_0x359232(0x205))/0x7*(parseInt(_0x359232(0x21c))/0x8)+parseInt(_0x359232(0x1cd))/0x9+parseInt(_0x359232(0x1e8))/0xa+parseInt(_0x359232(0x1f0))/0xb;if(_0x459b1f===_0x1229e0)break;else _0x32eac3['push'](_0x32eac3['shift']());}catch(_0x50c184){_0x32eac3['push'](_0x32eac3['shift']());}}}(a0_0xc9d3,0x9eda2));import{readFileSync as a0_0x21b53a,existsSync as a0_0x348584}from'fs';import{randomUUID as a0_0x3148f3}from'crypto';import{join as a0_0x41ccce}from'path';import{hostname as a0_0x5c6388}from'os';import{execSync as a0_0x370c54}from'child_process';function B(_0x4e7c98){const _0x564960=a0_0xb524;let _0x2b2732=_0x4e7c98[_0x564960(0x1c0)](/[^a-zA-Z0-9\-_]/g,'-');return _0x2b2732===''?_0x564960(0x204):_0x2b2732;}import{Server as a0_0x1e14c1}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x4af890}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x2595ff,CallToolRequestSchema as a0_0x120387}from'@modelcontextprotocol/sdk/types.js';function T(_0x1a3d17){const _0x250b01=a0_0xb524;if(!a0_0x348584(_0x1a3d17))return;for(let _0x1244e4 of a0_0x21b53a(_0x1a3d17,_0x250b01(0x23d))[_0x250b01(0x207)]('\x0a')){let _0x1291f4=_0x1244e4[_0x250b01(0x20c)]();if(!_0x1291f4||_0x1291f4[_0x250b01(0x21a)]('#'))continue;let _0x1ee40a=_0x1291f4[_0x250b01(0x21d)]('=');if(_0x1ee40a<0x0)continue;let _0x3a8581=_0x1291f4[_0x250b01(0x203)](0x0,_0x1ee40a)[_0x250b01(0x20c)](),_0x173986=_0x1291f4[_0x250b01(0x203)](_0x1ee40a+0x1)[_0x250b01(0x20c)]()['replace'](/^["']|["']$/g,'');if(!process.env[_0x3a8581])process.env[_0x3a8581]=_0x173986;}}var C=process.env.HOME||'~',r=a0_0x41ccce(C,a0_0x433c2f(0x1ff));T(a0_0x41ccce(r,a0_0x433c2f(0x211)));var H=B(process[a0_0x433c2f(0x21e)]());T(a0_0x41ccce(r,H,a0_0x433c2f(0x211)));function E(){const _0xd52e86=a0_0x433c2f;try{return a0_0x370c54(_0xd52e86(0x239),{'encoding':_0xd52e86(0x23d),'timeout':0x7d0})[_0xd52e86(0x20c)]();}catch{return'';}}function _(){const _0x12eb45=a0_0x433c2f;try{let _0x2a39cb=a0_0x41ccce(C,_0x12eb45(0x1e0),_0x12eb45(0x1b4));if(a0_0x348584(_0x2a39cb))return JSON[_0x12eb45(0x241)](a0_0x21b53a(_0x2a39cb,_0x12eb45(0x23d)));}catch{}return{};}var R=_(),Y=process.env.COMMHUB_URL||R[a0_0x433c2f(0x1fe)]||a0_0x433c2f(0x1b2),j=process.env.COMMHUB_TMUX||E();function S(){const _0x10dad6=a0_0x433c2f;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS[_0x10dad6(0x20c)]())return process.env.COMMHUB_ALIAS[_0x10dad6(0x20c)]();return process[_0x10dad6(0x20b)][_0x10dad6(0x1ac)]('[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20'+('would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME='+(j||'(none)')+_0x10dad6(0x1ba)+a0_0x5c6388()+_0x10dad6(0x24c))),_0x10dad6(0x235)+process[_0x10dad6(0x1c2)];}var p=S(),V=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x3148f3(),k=process.env.COMMHUB_TOKEN||R[a0_0x433c2f(0x1c5)]||'';function a0_0xc9d3(){const _0x525fe2=['task','\x20no\x20longer\x20exists\x20(kill-0\x20ESRCH)\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat','SSE\x20stream\x20ended,\x20reconnecting...','POST','\x20PROJECT_ENV=','working','Task\x20content','message_id','notification','.anet','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','cancelled','registered\x20as\x20\x22','exit','SSE\x20connection\x20error:\x20','messages','commhub_send_message','3067850VIJsat','priority','Authorization','min','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','send_message','session\x20disconnected','commhub_get_all_status','3074511CowflG','delete','commhub-channel','notifications/claude/channel',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','join','connected','\x22\x20after\x20SSE\x20reconnect','stringify','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','commhub_reply',':\x20inbox_count=','/mcp','new_task','hub','.claude/channels/commhub','1824mZhkSN','5dpCAtn','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','slice','unknown','14hsPUSu','text','split','Reply\x20text\x20/\x20result\x20summary','fatal:\x20','stdin','stderr','trim','ESRCH','body','alias','re-registered\x20as\x20\x22','.env','starting\x20SSE\x20listener...','application/json,\x20text/event-stream','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','from_session','shutting\x20down,\x20reporting\x20offline...','SSE\x20fatal:\x20','←\x20message\x20from\x20','error','startsWith','data:\x20','2032432WzkKbO','indexOf','cwd','none','find','\x20RESUME_ID=','ppid','in_progress','ready\x20—\x20waiting\x20for\x20events','broadcast','SIGINT','MCP\x20stdio\x20connected','Progress\x200-100','get_inbox','end','message','read','code','failed','function','params','Session\x20alias:\x20','offline','commhub_send_task','inbox_count','unattributed-','type','idle','parse\x20error:\x20','tmux\x20display-message\x20-p\x20\x27#S\x27','getReader','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','normal','utf-8','string','parent\x20claude\x20died\x20(reparented\x20to\x20PID\x201\x20from\x20','unknown\x20tool','parse','0.3.0','2.0','pop','1495170iyTcCH','init\x20failed:\x20','164062gmvStB','length','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','unref','send_task','.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a',')\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat','blocked','from','Priority\x20(default:\x20normal)','object','catch','toTimeString','connect','write','report_status','kill','...\x20TMUX=','Bearer\x20','content','http://127.0.0.1:9200','\x22\x20(','config.json','result','SSE\x20error:\x20','4UUZCQr','get_all_status','number','\x20/\x20hostname=','→\x20injected\x20task\x20','CommHub\x20init\x20failed:\x20','completed','now','Current\x20task\x20description','replace','commhub_report_status','pid','status','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','token','decode','set','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','parent\x20claude\x20pid=','get','7656ixrpLQ','11675655CZaGsy','ack_inbox','low','claude-code','SIGTERM','high','setRequestHandler','application/json','Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','Target\x20session\x20alias'];a0_0xc9d3=function(){return _0x525fe2;};return a0_0xc9d3();}function z(_0x20af38){const _0x3bd7f=a0_0x433c2f;let _0x4111d5=new Date()[_0x3bd7f(0x253)]()[_0x3bd7f(0x203)](0x0,0x8);process['stderr'][_0x3bd7f(0x1ac)]('['+_0x4111d5+']\x20[commhub]\x20'+_0x20af38+'\x0a');}function i(_0x4a3456){return new Promise(_0xa5f08f=>setTimeout(_0xa5f08f,_0x4a3456));}z('ENV:\x20URL='+Y+'\x20ALIAS='+p+a0_0x433c2f(0x221)+V[a0_0x433c2f(0x203)](0x0,0x8)+a0_0x433c2f(0x1af)+(j||a0_0x433c2f(0x21f))+'\x20CWD='+process[a0_0x433c2f(0x21e)]()+a0_0x433c2f(0x1db)+H);var G=new Map(),K=new a0_0x1e14c1({'name':'commhub-channel','version':a0_0x433c2f(0x242)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x433c2f(0x202),a0_0x433c2f(0x1c8),a0_0x433c2f(0x1ec),a0_0x433c2f(0x1c9),a0_0x433c2f(0x231)+p][a0_0x433c2f(0x1f5)]('\x0a')});K[a0_0x433c2f(0x1d3)](a0_0x2595ff,async()=>({'tools':[{'name':a0_0x433c2f(0x1fa),'description':a0_0x433c2f(0x1e1),'inputSchema':{'type':a0_0x433c2f(0x251),'properties':{'task_id':{'type':a0_0x433c2f(0x23e),'description':a0_0x433c2f(0x23b)},'text':{'type':'string','description':a0_0x433c2f(0x208)},'status':{'type':a0_0x433c2f(0x23e),'enum':[a0_0x433c2f(0x1bd),a0_0x433c2f(0x22e),a0_0x433c2f(0x1e2),a0_0x433c2f(0x24e),'error',a0_0x433c2f(0x223)],'description':a0_0x433c2f(0x249)}},'required':[a0_0x433c2f(0x206)]}},{'name':'commhub_report_status','description':a0_0x433c2f(0x1d5),'inputSchema':{'type':a0_0x433c2f(0x251),'properties':{'status':{'type':a0_0x433c2f(0x23e),'enum':[a0_0x433c2f(0x1dc),a0_0x433c2f(0x237),a0_0x433c2f(0x24e),a0_0x433c2f(0x219)]},'task':{'type':'string','description':a0_0x433c2f(0x1bf)},'progress':{'type':a0_0x433c2f(0x1b9),'description':a0_0x433c2f(0x228)}},'required':[a0_0x433c2f(0x1c3)]}},{'name':a0_0x433c2f(0x233),'description':a0_0x433c2f(0x1c4),'inputSchema':{'type':a0_0x433c2f(0x251),'properties':{'alias':{'type':a0_0x433c2f(0x23e),'description':a0_0x433c2f(0x1d6)},'task':{'type':a0_0x433c2f(0x23e),'description':a0_0x433c2f(0x1dd)},'priority':{'type':a0_0x433c2f(0x23e),'enum':[a0_0x433c2f(0x1d2),a0_0x433c2f(0x23c),a0_0x433c2f(0x1cf)],'description':a0_0x433c2f(0x250)}},'required':[a0_0x433c2f(0x20f),a0_0x433c2f(0x1d7)]}},{'name':a0_0x433c2f(0x1e7),'description':'Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','inputSchema':{'type':'object','properties':{'alias':{'type':a0_0x433c2f(0x23e),'description':a0_0x433c2f(0x1d6)},'message':{'type':'string','description':'Message\x20content'}},'required':[a0_0x433c2f(0x20f),'message']}},{'name':'commhub_get_all_status','description':a0_0x433c2f(0x214),'inputSchema':{'type':a0_0x433c2f(0x251),'properties':{}}}]}));async function Q(_0x15d7de,_0x5d902d){const _0x3e1b3f=a0_0x433c2f;let _0x1f5756=await fetch(Y+_0x3e1b3f(0x1fc),{'method':_0x3e1b3f(0x1da),'headers':{'Content-Type':_0x3e1b3f(0x1d4),'Accept':_0x3e1b3f(0x213),...k?{'Authorization':_0x3e1b3f(0x1b0)+k}:{}},'body':JSON['stringify']({'jsonrpc':_0x3e1b3f(0x243),'id':0x1,'method':'initialize','params':{'protocolVersion':'2025-03-26','capabilities':{},'clientInfo':{'name':_0x3e1b3f(0x1f2),'version':'0.3.0'}}})});if(!_0x1f5756['ok']){let _0x17acb9=await _0x1f5756[_0x3e1b3f(0x206)]();return z(_0x3e1b3f(0x1bc)+_0x1f5756[_0x3e1b3f(0x1c3)]+'\x20'+_0x17acb9['slice'](0x0,0x64)),{'ok':!0x1,'error':_0x3e1b3f(0x246)+_0x1f5756[_0x3e1b3f(0x1c3)]};}await _0x1f5756[_0x3e1b3f(0x206)]();let _0x29c761=(await(await fetch(Y+_0x3e1b3f(0x1fc),{'method':_0x3e1b3f(0x1da),'headers':{'Content-Type':_0x3e1b3f(0x1d4),'Accept':_0x3e1b3f(0x213),...k?{'Authorization':_0x3e1b3f(0x1b0)+k}:{}},'body':JSON[_0x3e1b3f(0x1f8)]({'jsonrpc':_0x3e1b3f(0x243),'id':0x2,'method':'tools/call','params':{'name':_0x15d7de,'arguments':_0x5d902d}})}))[_0x3e1b3f(0x206)]())[_0x3e1b3f(0x207)]('\x0a')[_0x3e1b3f(0x220)](_0x38bd99=>_0x38bd99[_0x3e1b3f(0x21a)](_0x3e1b3f(0x21b)));if(_0x29c761){let _0x191075=JSON[_0x3e1b3f(0x241)](_0x29c761[_0x3e1b3f(0x203)](0x6));return _0x191075?.[_0x3e1b3f(0x1b5)]?.[_0x3e1b3f(0x1b1)]?.[0x0]?.['text']?JSON[_0x3e1b3f(0x241)](_0x191075[_0x3e1b3f(0x1b5)][_0x3e1b3f(0x1b1)][0x0][_0x3e1b3f(0x206)]):_0x191075;}return{'ok':!0x1,'error':'no\x20response'};}K[a0_0x433c2f(0x1d3)](a0_0x120387,async _0x2cdfbb=>{const _0x34ea9c=a0_0x433c2f;let {name:_0x1fe37a,arguments:_0x3725d9}=_0x2cdfbb[_0x34ea9c(0x230)];if(_0x1fe37a===_0x34ea9c(0x1fa)){let {task_id:_0x2f0318,text:_0xb17867,status:_0x49daea}=_0x3725d9;if(_0x49daea===_0x34ea9c(0x1bd)||_0x49daea===_0x34ea9c(0x22e)||_0x49daea===_0x34ea9c(0x1e2)){let _0x1e432a=_0x49daea===_0x34ea9c(0x1bd)?'replied':_0x49daea,_0x47a1fb=_0x2f0318?G[_0x34ea9c(0x1cb)](_0x2f0318)||_0x34ea9c(0x1fe):_0x34ea9c(0x1fe),_0x13ee40=await Q('send_reply',{'alias':_0x47a1fb,'text':_0xb17867,'in_reply_to':_0x2f0318||void 0x0,'status':_0x1e432a,'from_session':p});if(_0x2f0318)G[_0x34ea9c(0x1f1)](_0x2f0318);return{'content':[{'type':'text','text':JSON['stringify'](_0x13ee40)}]};}let _0x314438=await Q(_0x34ea9c(0x1ad),{'resume_id':V,'alias':p,'status':_0x49daea===_0x34ea9c(0x24e)?_0x34ea9c(0x24e):_0x49daea===_0x34ea9c(0x219)?_0x34ea9c(0x219):_0x34ea9c(0x1dc),'task':_0xb17867[_0x34ea9c(0x203)](0x0,0xc8),'output':_0xb17867});return{'content':[{'type':_0x34ea9c(0x206),'text':JSON['stringify'](_0x314438)}]};}if(_0x1fe37a===_0x34ea9c(0x1c1)){let {status:_0xa997c2,task:_0x3b245d,progress:_0x2c7570}=_0x3725d9,_0x58dfa5=await Q('report_status',{'resume_id':V,'alias':p,'status':_0xa997c2,'task':_0x3b245d,'progress':_0x2c7570});return{'content':[{'type':_0x34ea9c(0x206),'text':JSON[_0x34ea9c(0x1f8)](_0x58dfa5)}]};}if(_0x1fe37a==='commhub_send_task'){let {alias:_0x4051fb,task:_0x28a03e,priority:_0x40f81b}=_0x3725d9,_0x257fe6=await Q(_0x34ea9c(0x24b),{'alias':_0x4051fb,'task':_0x28a03e,'priority':_0x40f81b||_0x34ea9c(0x23c),'from_session':p});return{'content':[{'type':_0x34ea9c(0x206),'text':JSON[_0x34ea9c(0x1f8)](_0x257fe6)}]};}if(_0x1fe37a===_0x34ea9c(0x1e7)){let {alias:_0x149ef6,message:_0x13bf87}=_0x3725d9,_0x2e03fb=await Q(_0x34ea9c(0x1ed),{'alias':_0x149ef6,'message':_0x13bf87,'from_session':p});return{'content':[{'type':_0x34ea9c(0x206),'text':JSON[_0x34ea9c(0x1f8)](_0x2e03fb)}]};}if(_0x1fe37a===_0x34ea9c(0x1ef)){let _0xd58fd9=await Q(_0x34ea9c(0x1b8),{});return{'content':[{'type':'text','text':JSON[_0x34ea9c(0x1f8)](_0xd58fd9)}]};}return{'content':[{'type':_0x34ea9c(0x206),'text':JSON['stringify']({'error':_0x34ea9c(0x240)})}]};});var D=0x3e8,v=0x7530,O=0x36ee80;async function m(){const _0x467ece=a0_0x433c2f;try{await Q('report_status',{'resume_id':V,'alias':p,'status':_0x467ece(0x237),'server':a0_0x5c6388(),'hostname':a0_0x5c6388(),'agent':'claude-code','project_dir':process[_0x467ece(0x21e)](),'tmux_name':j||void 0x0}),z(_0x467ece(0x210)+p+_0x467ece(0x1f7));}catch(_0x2c2e67){z('re-register\x20failed:\x20'+_0x2c2e67);}}async function l(){const _0x47d9a6=a0_0x433c2f;let _0x188125=Y+'/events/'+encodeURIComponent(p),_0x442e3a={};if(k)_0x442e3a[_0x47d9a6(0x1ea)]=_0x47d9a6(0x1b0)+k;z('connecting\x20to\x20'+_0x188125);let _0x4cce36=D,_0x11854d=!0x0,_0x1803b3=null;while(!0x0){try{let _0x6f7b6f=await fetch(_0x188125,{'headers':_0x442e3a});if(!_0x6f7b6f['ok']){if(z(_0x47d9a6(0x1b6)+_0x6f7b6f[_0x47d9a6(0x1c3)]+'\x20'+_0x6f7b6f['statusText']),_0x1803b3=_0x1803b3??Date[_0x47d9a6(0x1be)](),Date[_0x47d9a6(0x1be)]()-_0x1803b3>O){z('SSE\x20连续\x20>1h\x20连不上\x20hub\x20('+Y+_0x47d9a6(0x1f4));return;}await i(_0x4cce36),_0x4cce36=Math[_0x47d9a6(0x1eb)](_0x4cce36*0x2,v);continue;}let _0x314665=_0x6f7b6f[_0x47d9a6(0x20e)][_0x47d9a6(0x23a)](),_0x2b7c50=new TextDecoder(),_0x936229='';_0x4cce36=D;while(!0x0){let {done:_0xdd4069,value:_0x4def78}=await _0x314665[_0x47d9a6(0x22c)]();if(_0xdd4069)break;_0x936229+=_0x2b7c50[_0x47d9a6(0x1c6)](_0x4def78,{'stream':!0x0});let _0x4f8164=_0x936229[_0x47d9a6(0x207)]('\x0a\x0a');_0x936229=_0x4f8164[_0x47d9a6(0x244)]()||'';for(let _0x4f8506 of _0x4f8164){let _0x31fff8=_0x4f8506['split']('\x0a')[_0x47d9a6(0x220)](_0x554604=>_0x554604['startsWith']('data:\x20'));if(!_0x31fff8)continue;try{let _0x3d3528=JSON[_0x47d9a6(0x241)](_0x31fff8[_0x47d9a6(0x203)](0x6));if(await A(_0x3d3528),_0x3d3528[_0x47d9a6(0x236)]===_0x47d9a6(0x1f6)){if(_0x1803b3=null,!_0x11854d)await m();_0x11854d=!0x1;}}catch(_0x52745b){z(_0x47d9a6(0x238)+_0x52745b);}}}z(_0x47d9a6(0x1d9));}catch(_0x4e958b){z(_0x47d9a6(0x1e5)+_0x4e958b);}if(_0x1803b3=_0x1803b3??Date['now'](),Date[_0x47d9a6(0x1be)]()-_0x1803b3>O){z(_0x47d9a6(0x1f9)+Y+_0x47d9a6(0x1f4));return;}await i(_0x4cce36),_0x4cce36=Math['min'](_0x4cce36*0x2,v);}}async function A(_0x339286){const _0x17e996=a0_0x433c2f;if(_0x339286[_0x17e996(0x236)]===_0x17e996(0x1f6)){z('SSE\x20connected\x20as\x20\x22'+p+'\x22');return;}if(_0x339286[_0x17e996(0x236)]==='new_message'){if(z(_0x17e996(0x218)+_0x339286['from']+':\x20'+_0x339286[_0x17e996(0x22b)][_0x17e996(0x203)](0x0,0x3c)),await K['notification']({'method':_0x17e996(0x1f3),'params':{'content':_0x339286[_0x17e996(0x22b)],'meta':{'sender':_0x339286['from']||'hub','sender_id':'commhub','user':_0x339286[_0x17e996(0x24f)]||_0x17e996(0x1fe),'priority':'normal'}}}),_0x339286[_0x17e996(0x1de)])await Q(_0x17e996(0x1ce),{'alias':p,'message_id':_0x339286[_0x17e996(0x1de)]});return;}if(_0x339286[_0x17e996(0x236)]===_0x17e996(0x1fd)||_0x339286[_0x17e996(0x236)]===_0x17e996(0x225)){z('←\x20'+_0x339286['type']+_0x17e996(0x1fb)+_0x339286[_0x17e996(0x234)]+'\x20priority='+(_0x339286[_0x17e996(0x1e9)]||'normal'));let _0x124433=await Q(_0x17e996(0x229),{'alias':p,'limit':0x5});if(_0x124433?.['ok']&&_0x124433[_0x17e996(0x1e6)]?.[_0x17e996(0x248)]>0x0)for(let _0x5e7e8c of _0x124433[_0x17e996(0x1e6)]){let _0x4b3781={'sender':_0x5e7e8c[_0x17e996(0x215)]||_0x17e996(0x1fe),'sender_id':'commhub','user':_0x5e7e8c[_0x17e996(0x215)]||_0x17e996(0x1fe),'task_id':_0x5e7e8c['id'],'priority':_0x5e7e8c[_0x17e996(0x1e9)]||_0x17e996(0x23c)};G[_0x17e996(0x1c7)](_0x5e7e8c['id'],_0x5e7e8c['from_session']||_0x17e996(0x1fe)),await K[_0x17e996(0x1df)]({'method':_0x17e996(0x1f3),'params':{'content':_0x5e7e8c[_0x17e996(0x1b1)],'meta':_0x4b3781}}),z(_0x17e996(0x1bb)+_0x5e7e8c['id'][_0x17e996(0x203)](0x0,0x8)+'\x20from\x20'+_0x5e7e8c[_0x17e996(0x215)]+':\x20'+_0x5e7e8c[_0x17e996(0x1b1)][_0x17e996(0x203)](0x0,0x3c)),await Q(_0x17e996(0x1ce),{'alias':p,'message_id':_0x5e7e8c['id']});}}}async function t(){const _0x15faa8=a0_0x433c2f;let _0x159ca1=new a0_0x4af890();await K[_0x15faa8(0x1ab)](_0x159ca1),z(_0x15faa8(0x227)),z(_0x15faa8(0x212)),l()[_0x15faa8(0x252)](_0x3ede06=>z(_0x15faa8(0x217)+_0x3ede06)),Q(_0x15faa8(0x1ad),{'resume_id':V,'alias':p,'status':_0x15faa8(0x237),'server':a0_0x5c6388(),'hostname':a0_0x5c6388(),'agent':_0x15faa8(0x1d0),'project_dir':process[_0x15faa8(0x21e)](),'tmux_name':j||void 0x0})['then'](()=>z(_0x15faa8(0x1e3)+p+_0x15faa8(0x1b3)+V['slice'](0x0,0x8)+')'))[_0x15faa8(0x252)](_0x2d31b8=>z('warning:\x20could\x20not\x20register:\x20'+_0x2d31b8)),setInterval(()=>{const _0x3c0b03=_0x15faa8;Q(_0x3c0b03(0x1ad),{'resume_id':V,'alias':p,'status':_0x3c0b03(0x237),'server':a0_0x5c6388(),'hostname':a0_0x5c6388(),'agent':_0x3c0b03(0x1d0),'project_dir':process['cwd'](),'tmux_name':j||void 0x0})[_0x3c0b03(0x252)](_0x58d4b8=>z('heartbeat\x20failed:\x20'+_0x58d4b8));},0x2bf20),z(_0x15faa8(0x224));}t()[a0_0x433c2f(0x252)](_0x4b25ac=>{const _0x38e8c7=a0_0x433c2f;z(_0x38e8c7(0x209)+_0x4b25ac),process['exit'](0x1);});async function b(){const _0x22a093=a0_0x433c2f;z(_0x22a093(0x216)),await Q(_0x22a093(0x1ad),{'resume_id':V,'alias':p,'status':_0x22a093(0x232),'task':_0x22a093(0x1ee)})['catch'](()=>{}),process[_0x22a093(0x1e4)](0x0);}process[a0_0x433c2f(0x20a)]['on'](a0_0x433c2f(0x22a),()=>b()),process['on'](a0_0x433c2f(0x1d1),()=>b()),process['on'](a0_0x433c2f(0x226),()=>b());var d=process['ppid'];function a0_0xb524(_0x7154d2,_0x154c93){_0x7154d2=_0x7154d2-0x1ab;const _0xc9d3f9=a0_0xc9d3();let _0xb52475=_0xc9d3f9[_0x7154d2];return _0xb52475;}if(d&&d>0x1){let h=setInterval(()=>{const _0xd1d9ec=a0_0x433c2f;if(process[_0xd1d9ec(0x222)]===0x1&&d!==0x1){z(_0xd1d9ec(0x23f)+d+_0xd1d9ec(0x24d)),b();return;}try{process[_0xd1d9ec(0x1ae)](d,0x0);}catch(_0x11fa9f){if(_0x11fa9f?.[_0xd1d9ec(0x22d)]===_0xd1d9ec(0x20d))z(_0xd1d9ec(0x1ca)+d+_0xd1d9ec(0x1d8)),b();}},0x7530);if(typeof h[a0_0x433c2f(0x24a)]===a0_0x433c2f(0x22f))h[a0_0x433c2f(0x24a)]();}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type RuntimeName = "claude-code-cli" | "codex-sdk" | "claude-agent-sdk" | "grok-build-acp" | "opencode-cli";
|
|
2
|
+
/** Operator-facing default for any runtime slot that comes in empty / missing / unrecognized. */
|
|
3
|
+
export declare const DEFAULT_RUNTIME: RuntimeName;
|
|
4
|
+
type ProfileLike = {
|
|
5
|
+
runtime?: string;
|
|
6
|
+
codexRuntime?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function normalizeRuntime(profileOrRuntime?: ProfileLike | string): RuntimeName;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Version this branch was validated against by the maintainers.
|
|
3
|
+
* Bumped when a new opencode-ai release passes the manual smoke +
|
|
4
|
+
* PR② e2e in a fresh checkout. `readEffectivePin()` still returns
|
|
5
|
+
* this when no override file exists.
|
|
6
|
+
*/
|
|
7
|
+
export declare const OPENCODE_BUILTIN_PIN = "1.17.13";
|
|
8
|
+
/** Where the per-machine override lives. Kept under `~/.anet/` so
|
|
9
|
+
* it sits next to the other anet-local state. */
|
|
10
|
+
export declare function opencodePinFilePath(homeDirOverride?: string): string;
|
|
11
|
+
/** Shape of the override file written by `upgrade-pin`. */
|
|
12
|
+
export interface OpencodePinOverride {
|
|
13
|
+
version: string;
|
|
14
|
+
/** ISO timestamp when the smoke test passed. Presence of this
|
|
15
|
+
* field is REQUIRED for `readEffectivePin()` to trust the file —
|
|
16
|
+
* a hand-edited version without a smoke marker is refused. */
|
|
17
|
+
smokePassedAt: string;
|
|
18
|
+
/** Free-form note about what the smoke checked (initialize +
|
|
19
|
+
* session/new by default). Kept so a future review can tell what
|
|
20
|
+
* bar the pin actually cleared. */
|
|
21
|
+
smokeNote?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface EffectivePin {
|
|
24
|
+
version: string;
|
|
25
|
+
source: "override-file" | "builtin";
|
|
26
|
+
smokePassedAt?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Prefer a validated override file when present; otherwise fall
|
|
30
|
+
* back to the built-in constant. A malformed override file is
|
|
31
|
+
* ignored (built-in wins) — we don't want a partially-written
|
|
32
|
+
* override to wedge every start.
|
|
33
|
+
*/
|
|
34
|
+
export declare function readEffectivePin(homeDirOverride?: string): EffectivePin;
|
|
35
|
+
/**
|
|
36
|
+
* Write the override — SHOULD ONLY be called after the smoke test
|
|
37
|
+
* has actually passed. The command layer in `bin/cli.ts` is
|
|
38
|
+
* responsible for gating this; this function does no
|
|
39
|
+
* verification of its own beyond shape.
|
|
40
|
+
*/
|
|
41
|
+
export declare function writePinOverride(version: string, smokePassedAt: string, smokeNote?: string, homeDirOverride?: string): void;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export type OpencodePresetId = "anthropic" | "openai";
|
|
2
|
+
export interface OpencodePreset {
|
|
3
|
+
id: OpencodePresetId;
|
|
4
|
+
displayName: string;
|
|
5
|
+
envKey: string;
|
|
6
|
+
signupUrl: string;
|
|
7
|
+
/** How opencode's provider config identifies this vendor in the
|
|
8
|
+
* `provider.<id>.options.baseUrl` config. Left null when we don't
|
|
9
|
+
* need to override the built-in default. */
|
|
10
|
+
configProviderId: "anthropic" | "openai";
|
|
11
|
+
}
|
|
12
|
+
export declare const OPENCODE_PRESETS: OpencodePreset[];
|
|
13
|
+
export declare function findOpencodePreset(id: string): OpencodePreset | null;
|
|
14
|
+
/**
|
|
15
|
+
* Look up the API key for a preset from the current process env.
|
|
16
|
+
* Callers MUST handle the `null` case (per RFC v0.3 D3 + 通信龙 PR③
|
|
17
|
+
* flag: "从 env 读, 别 prompt"). Returns null so the wizard can
|
|
18
|
+
* emit a clear message telling the operator to export the env var
|
|
19
|
+
* and re-run — rather than silently continuing without a key.
|
|
20
|
+
*/
|
|
21
|
+
export declare function readPresetKeyFromEnv(preset: OpencodePreset, env?: NodeJS.ProcessEnv): string | null;
|
|
22
|
+
/**
|
|
23
|
+
* opencode.ai's auth.json shape:
|
|
24
|
+
* { "<providerId>": { "type": "api", "key": "..." } }
|
|
25
|
+
* Same shape Phase 0b probes verified against opencode-ai@1.17.13.
|
|
26
|
+
*/
|
|
27
|
+
export declare function buildAuthJsonBody(preset: OpencodePreset, apiKey: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Write auth.json into the opencode config root that lives under
|
|
30
|
+
* `nodeWorkDir` (which becomes the child's HOME per PR② §8 D5).
|
|
31
|
+
* mode 0o600 keeps it operator-only. Directory is created if
|
|
32
|
+
* missing.
|
|
33
|
+
*
|
|
34
|
+
* Returns the absolute path we wrote for logging.
|
|
35
|
+
*/
|
|
36
|
+
export declare function writeOpencodeAuthJson(nodeWorkDir: string, preset: OpencodePreset, apiKey: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Companion opencode.json: pins the vendor's baseUrl (defaults for
|
|
39
|
+
* Anthropic / OpenAI are fine, so this is minimal for now). A
|
|
40
|
+
* placeholder so later PRs can push per-node overrides without
|
|
41
|
+
* needing to invent the file.
|
|
42
|
+
*/
|
|
43
|
+
export declare function writeOpencodeConfigJson(nodeWorkDir: string, preset: OpencodePreset): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function encodeCwd(cwd: string): string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sleep2agi/agent-network",
|
|
3
|
-
"version": "2.3.0-preview.
|
|
4
|
-
"description": "AI Agent Network CLI
|
|
3
|
+
"version": "2.3.0-preview.21",
|
|
4
|
+
"description": "AI Agent Network CLI — Local-first multi-agent orchestration across 4 runtimes (Claude Code CLI / Claude Agent SDK / Codex SDK / Grok Build ACP) and 8+ LLM providers (Anthropic / OpenAI / xAI Grok / MiniMax / DeepSeek / GLM / Kimi / InternLM / Xiaomi MiMo / OpenRouter). Apache 2.0.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/client.js",
|
|
7
7
|
"types": "dist/client.d.ts",
|
|
@@ -65,10 +65,13 @@
|
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@inquirer/prompts": "^8.4.3",
|
|
68
|
-
"@larksuiteoapi/node-sdk": "^1.42.0"
|
|
68
|
+
"@larksuiteoapi/node-sdk": "^1.42.0",
|
|
69
|
+
"markdown-it": "^14.1.0",
|
|
70
|
+
"puppeteer-core": "^24.10.2"
|
|
69
71
|
},
|
|
70
72
|
"devDependencies": {
|
|
71
73
|
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
74
|
+
"@types/markdown-it": "^14.1.2",
|
|
72
75
|
"@types/node": "^25.0.0",
|
|
73
76
|
"javascript-obfuscator": "^5.4.1",
|
|
74
77
|
"node-pty": "^1.1.0",
|