@sleep2agi/agent-network 2.3.0-preview.2 → 2.3.0-preview.20
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_0x772d6f=a0_0x35e7;(function(_0x540113,_0x2fd8e0){const _0x2f73a5=a0_0x35e7,_0x4ed00a=_0x540113();while(!![]){try{const _0x5a33b6=parseInt(_0x2f73a5(0x15b))/0x1+parseInt(_0x2f73a5(0x1db))/0x2+-parseInt(_0x2f73a5(0x175))/0x3+-parseInt(_0x2f73a5(0x145))/0x4+-parseInt(_0x2f73a5(0x179))/0x5*(parseInt(_0x2f73a5(0x170))/0x6)+-parseInt(_0x2f73a5(0x161))/0x7+parseInt(_0x2f73a5(0x1a9))/0x8;if(_0x5a33b6===_0x2fd8e0)break;else _0x4ed00a['push'](_0x4ed00a['shift']());}catch(_0x312478){_0x4ed00a['push'](_0x4ed00a['shift']());}}}(a0_0x202c,0xdae9e));function a0_0x202c(){const _0x44107c=['Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','session\x20disconnected','2795674oCmDAO','exit','\x20/\x20hostname=','error','write','idle','/events/','startsWith','3925220EuGAxv','inbox_count','init\x20failed:\x20','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','getReader','cancelled','messages','body','Message\x20content','SSE\x20error:\x20','delete','toTimeString','data:\x20','SIGINT','/mcp','result',']\x20[commhub]\x20','POST','send_message','\x20no\x20longer\x20exists\x20(kill-0\x20ESRCH)\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat','statusText','Bearer\x20','951173HKOTCX','new_message','from_session','broadcast','Reply\x20text\x20/\x20result\x20summary','stdin','1814848OfsuHj','\x20PROJECT_ENV=','send_reply','min','\x20from\x20','slice','.env','alias','low','ready\x20—\x20waiting\x20for\x20events','blocked','connected','get_inbox','would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME=','...\x20TMUX=','222942OZLKEE','.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a','read','warning:\x20could\x20not\x20register:\x20','params','722520RGpUYj','catch','then','decode','105VwFQlD','Authorization','priority','commhub_send_message','unattributed-','replied','number','message','commhub_get_all_status','pid','SSE\x20stream\x20ended,\x20reconnecting...','normal','Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','commhub','Progress\x200-100','text','type','set','failed','parse\x20error:\x20','re-registered\x20as\x20\x22','unref','ack_inbox','hub','notification',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','claude-code','SSE\x20connected\x20as\x20\x22','.claude/channels/commhub','status','object','get_all_status','stderr','replace','application/json','trim','2.0','ppid','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','split','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','indexOf','utf-8','shutting\x20down,\x20reporting\x20offline...','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','ESRCH','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','in_progress','6474928nYTiOT','join','string','re-register\x20failed:\x20','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','message_id','content','unknown','cwd','MCP\x20stdio\x20connected','tmux\x20display-message\x20-p\x20\x27#S\x27','notifications/claude/channel','high','(none)','Current\x20task\x20description','Target\x20session\x20alias','send_task','token',':\x20inbox_count=','parent\x20claude\x20pid=','0.3.0','parse','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','\x20CWD=','←\x20message\x20from\x20','SSE\x20fatal:\x20','from','working','\x22\x20(','none','fatal:\x20','setRequestHandler','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','completed','task','commhub_report_status','config.json','get','report_status','CommHub\x20init\x20failed:\x20','application/json,\x20text/event-stream','find','now','\x20RESUME_ID=','registered\x20as\x20\x22','stringify','commhub_reply','commhub_send_task'];a0_0x202c=function(){return _0x44107c;};return a0_0x202c();}import{readFileSync as a0_0x3ee350,existsSync as a0_0x3ae3e7}from'fs';import{randomUUID as a0_0x5e26b8}from'crypto';import{join as a0_0x51ed96}from'path';import{hostname as a0_0xb52976}from'os';import{execSync as a0_0x179602}from'child_process';function B(_0x5d1fda){const _0x1a0b46=a0_0x35e7;let _0x20e812=_0x5d1fda['replace'](/[^a-zA-Z0-9\-_]/g,'-');return _0x20e812===''?_0x1a0b46(0x1b0):_0x20e812;}import{Server as a0_0x913f64}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0xec1033}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x437a5f,CallToolRequestSchema as a0_0x3c7784}from'@modelcontextprotocol/sdk/types.js';function T(_0x288350){const _0x33472d=a0_0x35e7;if(!a0_0x3ae3e7(_0x288350))return;for(let _0x20d287 of a0_0x3ee350(_0x288350,_0x33472d(0x1a3))['split']('\x0a')){let _0x291ef5=_0x20d287[_0x33472d(0x19c)]();if(!_0x291ef5||_0x291ef5['startsWith']('#'))continue;let _0x56e5c2=_0x291ef5[_0x33472d(0x1a2)]('=');if(_0x56e5c2<0x0)continue;let _0x5190a1=_0x291ef5[_0x33472d(0x166)](0x0,_0x56e5c2)[_0x33472d(0x19c)](),_0x2a0dbf=_0x291ef5['slice'](_0x56e5c2+0x1)[_0x33472d(0x19c)]()[_0x33472d(0x19a)](/^["']|["']$/g,'');if(!process.env[_0x5190a1])process.env[_0x5190a1]=_0x2a0dbf;}}var C=process.env.HOME||'~',r=a0_0x51ed96(C,a0_0x772d6f(0x195));T(a0_0x51ed96(r,a0_0x772d6f(0x167)));var H=B(process[a0_0x772d6f(0x1b1)]());T(a0_0x51ed96(r,H,a0_0x772d6f(0x167)));function E(){const _0x53cabc=a0_0x772d6f;try{return a0_0x179602(_0x53cabc(0x1b3),{'encoding':'utf-8','timeout':0x7d0})[_0x53cabc(0x19c)]();}catch{return'';}}function _(){const _0x3f398f=a0_0x772d6f;try{let _0x46ec85=a0_0x51ed96(C,'.anet',_0x3f398f(0x1cd));if(a0_0x3ae3e7(_0x46ec85))return JSON[_0x3f398f(0x1be)](a0_0x3ee350(_0x46ec85,'utf-8'));}catch{}return{};}var R=_(),Y=process.env.COMMHUB_URL||R[a0_0x772d6f(0x190)]||'http://127.0.0.1:9200',j=process.env.COMMHUB_TMUX||E();function S(){const _0x363d11=a0_0x772d6f;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS[_0x363d11(0x19c)]())return process.env.COMMHUB_ALIAS['trim']();return process[_0x363d11(0x199)][_0x363d11(0x1df)]('[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20'+(_0x363d11(0x16e)+(j||_0x363d11(0x1b6))+_0x363d11(0x1dd)+a0_0xb52976()+_0x363d11(0x171))),_0x363d11(0x17d)+process[_0x363d11(0x182)];}var p=S(),V=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x5e26b8(),k=process.env.COMMHUB_TOKEN||R[a0_0x772d6f(0x1ba)]||'';function z(_0x54bd13){const _0x20883d=a0_0x772d6f;let _0x4fba2c=new Date()[_0x20883d(0x150)]()[_0x20883d(0x166)](0x0,0x8);process[_0x20883d(0x199)][_0x20883d(0x1df)]('['+_0x4fba2c+_0x20883d(0x155)+_0x54bd13+'\x0a');}function i(_0x150eaf){return new Promise(_0x2777ef=>setTimeout(_0x2777ef,_0x150eaf));}z('ENV:\x20URL='+Y+'\x20ALIAS='+p+a0_0x772d6f(0x1d4)+V[a0_0x772d6f(0x166)](0x0,0x8)+a0_0x772d6f(0x16f)+(j||a0_0x772d6f(0x1c6))+a0_0x772d6f(0x1c0)+process[a0_0x772d6f(0x1b1)]()+a0_0x772d6f(0x162)+H);var G=new Map(),K=new a0_0x913f64({'name':'commhub-channel','version':a0_0x772d6f(0x1bd)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x772d6f(0x1bf),a0_0x772d6f(0x148),'Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.',a0_0x772d6f(0x1a5),'Session\x20alias:\x20'+p][a0_0x772d6f(0x1aa)]('\x0a')});K[a0_0x772d6f(0x1c8)](a0_0x437a5f,async()=>({'tools':[{'name':a0_0x772d6f(0x1d7),'description':a0_0x772d6f(0x1a1),'inputSchema':{'type':a0_0x772d6f(0x197),'properties':{'task_id':{'type':a0_0x772d6f(0x1ab),'description':a0_0x772d6f(0x19f)},'text':{'type':a0_0x772d6f(0x1ab),'description':a0_0x772d6f(0x15f)},'status':{'type':'string','enum':[a0_0x772d6f(0x1ca),a0_0x772d6f(0x18b),a0_0x772d6f(0x14a),a0_0x772d6f(0x16b),a0_0x772d6f(0x1de),a0_0x772d6f(0x1a8)],'description':a0_0x772d6f(0x1c9)}},'required':[a0_0x772d6f(0x188)]}},{'name':a0_0x772d6f(0x1cc),'description':a0_0x772d6f(0x185),'inputSchema':{'type':a0_0x772d6f(0x197),'properties':{'status':{'type':a0_0x772d6f(0x1ab),'enum':['working',a0_0x772d6f(0x1e0),a0_0x772d6f(0x16b),a0_0x772d6f(0x1de)]},'task':{'type':a0_0x772d6f(0x1ab),'description':a0_0x772d6f(0x1b7)},'progress':{'type':a0_0x772d6f(0x17f),'description':a0_0x772d6f(0x187)}},'required':[a0_0x772d6f(0x196)]}},{'name':a0_0x772d6f(0x1d8),'description':'Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','inputSchema':{'type':a0_0x772d6f(0x197),'properties':{'alias':{'type':a0_0x772d6f(0x1ab),'description':a0_0x772d6f(0x1b8)},'task':{'type':a0_0x772d6f(0x1ab),'description':'Task\x20content'},'priority':{'type':a0_0x772d6f(0x1ab),'enum':[a0_0x772d6f(0x1b5),'normal',a0_0x772d6f(0x169)],'description':'Priority\x20(default:\x20normal)'}},'required':['alias',a0_0x772d6f(0x1cb)]}},{'name':a0_0x772d6f(0x17c),'description':a0_0x772d6f(0x1d9),'inputSchema':{'type':a0_0x772d6f(0x197),'properties':{'alias':{'type':a0_0x772d6f(0x1ab),'description':'Target\x20session\x20alias'},'message':{'type':a0_0x772d6f(0x1ab),'description':a0_0x772d6f(0x14d)}},'required':[a0_0x772d6f(0x168),a0_0x772d6f(0x180)]}},{'name':a0_0x772d6f(0x181),'description':a0_0x772d6f(0x1ad),'inputSchema':{'type':a0_0x772d6f(0x197),'properties':{}}}]}));async function Q(_0x40183b,_0x11cd73){const _0x38cbbd=a0_0x772d6f;let _0x336ea3=await fetch(Y+_0x38cbbd(0x153),{'method':_0x38cbbd(0x156),'headers':{'Content-Type':_0x38cbbd(0x19b),'Accept':_0x38cbbd(0x1d1),...k?{'Authorization':'Bearer\x20'+k}:{}},'body':JSON[_0x38cbbd(0x1d6)]({'jsonrpc':_0x38cbbd(0x19d),'id':0x1,'method':'initialize','params':{'protocolVersion':'2025-03-26','capabilities':{},'clientInfo':{'name':'commhub-channel','version':_0x38cbbd(0x1bd)}}})});if(!_0x336ea3['ok']){let _0x1a6479=await _0x336ea3[_0x38cbbd(0x188)]();return z(_0x38cbbd(0x1d0)+_0x336ea3[_0x38cbbd(0x196)]+'\x20'+_0x1a6479[_0x38cbbd(0x166)](0x0,0x64)),{'ok':!0x1,'error':_0x38cbbd(0x147)+_0x336ea3[_0x38cbbd(0x196)]};}await _0x336ea3[_0x38cbbd(0x188)]();let _0x429417=(await(await fetch(Y+'/mcp',{'method':'POST','headers':{'Content-Type':'application/json','Accept':_0x38cbbd(0x1d1),...k?{'Authorization':_0x38cbbd(0x15a)+k}:{}},'body':JSON[_0x38cbbd(0x1d6)]({'jsonrpc':_0x38cbbd(0x19d),'id':0x2,'method':'tools/call','params':{'name':_0x40183b,'arguments':_0x11cd73}})}))[_0x38cbbd(0x188)]())['split']('\x0a')[_0x38cbbd(0x1d2)](_0x542f32=>_0x542f32[_0x38cbbd(0x144)](_0x38cbbd(0x151)));if(_0x429417){let _0x25d7d7=JSON[_0x38cbbd(0x1be)](_0x429417['slice'](0x6));return _0x25d7d7?.[_0x38cbbd(0x154)]?.[_0x38cbbd(0x1af)]?.[0x0]?.['text']?JSON[_0x38cbbd(0x1be)](_0x25d7d7[_0x38cbbd(0x154)][_0x38cbbd(0x1af)][0x0][_0x38cbbd(0x188)]):_0x25d7d7;}return{'ok':!0x1,'error':'no\x20response'};}K[a0_0x772d6f(0x1c8)](a0_0x3c7784,async _0xc3d585=>{const _0x4346b6=a0_0x772d6f;let {name:_0x4b8e6b,arguments:_0x21db75}=_0xc3d585[_0x4346b6(0x174)];if(_0x4b8e6b===_0x4346b6(0x1d7)){let {task_id:_0x1ba934,text:_0x1a8d64,status:_0x5f0f28}=_0x21db75;if(_0x5f0f28===_0x4346b6(0x1ca)||_0x5f0f28==='failed'||_0x5f0f28===_0x4346b6(0x14a)){let _0x4769bb=_0x5f0f28===_0x4346b6(0x1ca)?_0x4346b6(0x17e):_0x5f0f28,_0x468bbe=_0x1ba934?G[_0x4346b6(0x1ce)](_0x1ba934)||_0x4346b6(0x190):_0x4346b6(0x190),_0x173f29=await Q(_0x4346b6(0x163),{'alias':_0x468bbe,'text':_0x1a8d64,'in_reply_to':_0x1ba934||void 0x0,'status':_0x4769bb,'from_session':p});if(_0x1ba934)G[_0x4346b6(0x14f)](_0x1ba934);return{'content':[{'type':'text','text':JSON[_0x4346b6(0x1d6)](_0x173f29)}]};}let _0x2331ca=await Q('report_status',{'resume_id':V,'alias':p,'status':_0x5f0f28==='blocked'?_0x4346b6(0x16b):_0x5f0f28==='error'?_0x4346b6(0x1de):_0x4346b6(0x1c4),'task':_0x1a8d64['slice'](0x0,0xc8),'output':_0x1a8d64});return{'content':[{'type':'text','text':JSON['stringify'](_0x2331ca)}]};}if(_0x4b8e6b==='commhub_report_status'){let {status:_0x3e4e62,task:_0x14cae3,progress:_0x4509b0}=_0x21db75,_0x40ec10=await Q('report_status',{'resume_id':V,'alias':p,'status':_0x3e4e62,'task':_0x14cae3,'progress':_0x4509b0});return{'content':[{'type':_0x4346b6(0x188),'text':JSON[_0x4346b6(0x1d6)](_0x40ec10)}]};}if(_0x4b8e6b===_0x4346b6(0x1d8)){let {alias:_0x3f8aeb,task:_0x32f37c,priority:_0x25f174}=_0x21db75,_0x482301=await Q(_0x4346b6(0x1b9),{'alias':_0x3f8aeb,'task':_0x32f37c,'priority':_0x25f174||_0x4346b6(0x184),'from_session':p});return{'content':[{'type':_0x4346b6(0x188),'text':JSON[_0x4346b6(0x1d6)](_0x482301)}]};}if(_0x4b8e6b===_0x4346b6(0x17c)){let {alias:_0x817112,message:_0x526fb1}=_0x21db75,_0x5ae21f=await Q(_0x4346b6(0x157),{'alias':_0x817112,'message':_0x526fb1,'from_session':p});return{'content':[{'type':_0x4346b6(0x188),'text':JSON['stringify'](_0x5ae21f)}]};}if(_0x4b8e6b===_0x4346b6(0x181)){let _0x30f390=await Q(_0x4346b6(0x198),{});return{'content':[{'type':_0x4346b6(0x188),'text':JSON[_0x4346b6(0x1d6)](_0x30f390)}]};}return{'content':[{'type':_0x4346b6(0x188),'text':JSON[_0x4346b6(0x1d6)]({'error':'unknown\x20tool'})}]};});var D=0x3e8,v=0x7530,O=0x36ee80;async function m(){const _0xab29c4=a0_0x772d6f;try{await Q(_0xab29c4(0x1cf),{'resume_id':V,'alias':p,'status':_0xab29c4(0x1e0),'server':a0_0xb52976(),'hostname':a0_0xb52976(),'agent':_0xab29c4(0x193),'project_dir':process['cwd'](),'tmux_name':j||void 0x0}),z(_0xab29c4(0x18d)+p+'\x22\x20after\x20SSE\x20reconnect');}catch(_0x11b146){z(_0xab29c4(0x1ac)+_0x11b146);}}async function l(){const _0x40650b=a0_0x772d6f;let _0x334782=Y+_0x40650b(0x143)+encodeURIComponent(p),_0x50f57f={};if(k)_0x50f57f[_0x40650b(0x17a)]=_0x40650b(0x15a)+k;z('connecting\x20to\x20'+_0x334782);let _0x740d7b=D,_0x1335b8=!0x0,_0x1c6163=null;while(!0x0){try{let _0x53930e=await fetch(_0x334782,{'headers':_0x50f57f});if(!_0x53930e['ok']){if(z(_0x40650b(0x14e)+_0x53930e['status']+'\x20'+_0x53930e[_0x40650b(0x159)]),_0x1c6163=_0x1c6163??Date[_0x40650b(0x1d3)](),Date[_0x40650b(0x1d3)]()-_0x1c6163>O){z(_0x40650b(0x1a7)+Y+_0x40650b(0x192));return;}await i(_0x740d7b),_0x740d7b=Math[_0x40650b(0x164)](_0x740d7b*0x2,v);continue;}let _0x5b64de=_0x53930e[_0x40650b(0x14c)][_0x40650b(0x149)](),_0x34583f=new TextDecoder(),_0x54357d='';_0x740d7b=D;while(!0x0){let {done:_0x20d872,value:_0x15de43}=await _0x5b64de[_0x40650b(0x172)]();if(_0x20d872)break;_0x54357d+=_0x34583f[_0x40650b(0x178)](_0x15de43,{'stream':!0x0});let _0x4689f1=_0x54357d[_0x40650b(0x1a0)]('\x0a\x0a');_0x54357d=_0x4689f1['pop']()||'';for(let _0x1e0b2b of _0x4689f1){let _0x17ddac=_0x1e0b2b['split']('\x0a')[_0x40650b(0x1d2)](_0x4016e8=>_0x4016e8['startsWith']('data:\x20'));if(!_0x17ddac)continue;try{let _0x345ce7=JSON[_0x40650b(0x1be)](_0x17ddac[_0x40650b(0x166)](0x6));if(await A(_0x345ce7),_0x345ce7[_0x40650b(0x189)]===_0x40650b(0x16c)){if(_0x1c6163=null,!_0x1335b8)await m();_0x1335b8=!0x1;}}catch(_0x1b1d5c){z(_0x40650b(0x18c)+_0x1b1d5c);}}}z(_0x40650b(0x183));}catch(_0x271e93){z('SSE\x20connection\x20error:\x20'+_0x271e93);}if(_0x1c6163=_0x1c6163??Date['now'](),Date[_0x40650b(0x1d3)]()-_0x1c6163>O){z(_0x40650b(0x1a7)+Y+')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。');return;}await i(_0x740d7b),_0x740d7b=Math['min'](_0x740d7b*0x2,v);}}async function A(_0x4e41fa){const _0x4460a7=a0_0x772d6f;if(_0x4e41fa['type']===_0x4460a7(0x16c)){z(_0x4460a7(0x194)+p+'\x22');return;}if(_0x4e41fa[_0x4460a7(0x189)]===_0x4460a7(0x15c)){if(z(_0x4460a7(0x1c1)+_0x4e41fa['from']+':\x20'+_0x4e41fa['message'][_0x4460a7(0x166)](0x0,0x3c)),await K[_0x4460a7(0x191)]({'method':_0x4460a7(0x1b4),'params':{'content':_0x4e41fa['message'],'meta':{'sender':_0x4e41fa[_0x4460a7(0x1c3)]||_0x4460a7(0x190),'sender_id':_0x4460a7(0x186),'user':_0x4e41fa[_0x4460a7(0x1c3)]||_0x4460a7(0x190),'priority':_0x4460a7(0x184)}}}),_0x4e41fa[_0x4460a7(0x1ae)])await Q(_0x4460a7(0x18f),{'alias':p,'message_id':_0x4e41fa[_0x4460a7(0x1ae)]});return;}if(_0x4e41fa[_0x4460a7(0x189)]==='new_task'||_0x4e41fa[_0x4460a7(0x189)]===_0x4460a7(0x15e)){z('←\x20'+_0x4e41fa[_0x4460a7(0x189)]+_0x4460a7(0x1bb)+_0x4e41fa[_0x4460a7(0x146)]+'\x20priority='+(_0x4e41fa[_0x4460a7(0x17b)]||_0x4460a7(0x184)));let _0xa51d8b=await Q(_0x4460a7(0x16d),{'alias':p,'limit':0x5});if(_0xa51d8b?.['ok']&&_0xa51d8b['messages']?.['length']>0x0)for(let _0x353734 of _0xa51d8b[_0x4460a7(0x14b)]){let _0x38e807={'sender':_0x353734[_0x4460a7(0x15d)]||'hub','sender_id':'commhub','user':_0x353734[_0x4460a7(0x15d)]||_0x4460a7(0x190),'task_id':_0x353734['id'],'priority':_0x353734[_0x4460a7(0x17b)]||_0x4460a7(0x184)};G[_0x4460a7(0x18a)](_0x353734['id'],_0x353734[_0x4460a7(0x15d)]||_0x4460a7(0x190)),await K[_0x4460a7(0x191)]({'method':_0x4460a7(0x1b4),'params':{'content':_0x353734['content'],'meta':_0x38e807}}),z('→\x20injected\x20task\x20'+_0x353734['id']['slice'](0x0,0x8)+_0x4460a7(0x165)+_0x353734[_0x4460a7(0x15d)]+':\x20'+_0x353734[_0x4460a7(0x1af)]['slice'](0x0,0x3c)),await Q('ack_inbox',{'alias':p,'message_id':_0x353734['id']});}}}async function t(){const _0x4adffe=a0_0x772d6f;let _0x4902c1=new a0_0xec1033();await K['connect'](_0x4902c1),z(_0x4adffe(0x1b2)),z('starting\x20SSE\x20listener...'),l()[_0x4adffe(0x176)](_0x55314c=>z(_0x4adffe(0x1c2)+_0x55314c)),Q(_0x4adffe(0x1cf),{'resume_id':V,'alias':p,'status':_0x4adffe(0x1e0),'server':a0_0xb52976(),'hostname':a0_0xb52976(),'agent':_0x4adffe(0x193),'project_dir':process[_0x4adffe(0x1b1)](),'tmux_name':j||void 0x0})[_0x4adffe(0x177)](()=>z(_0x4adffe(0x1d5)+p+_0x4adffe(0x1c5)+V[_0x4adffe(0x166)](0x0,0x8)+')'))['catch'](_0x3168f8=>z(_0x4adffe(0x173)+_0x3168f8)),setInterval(()=>{const _0x30570a=_0x4adffe;Q('report_status',{'resume_id':V,'alias':p,'status':_0x30570a(0x1e0),'server':a0_0xb52976(),'hostname':a0_0xb52976(),'agent':'claude-code','project_dir':process[_0x30570a(0x1b1)](),'tmux_name':j||void 0x0})[_0x30570a(0x176)](_0x3943fc=>z('heartbeat\x20failed:\x20'+_0x3943fc));},0x2bf20),z(_0x4adffe(0x16a));}t()[a0_0x772d6f(0x176)](_0x1b12d5=>{const _0x206804=a0_0x772d6f;z(_0x206804(0x1c7)+_0x1b12d5),process[_0x206804(0x1dc)](0x1);});async function b(){const _0x107f09=a0_0x772d6f;z(_0x107f09(0x1a4)),await Q(_0x107f09(0x1cf),{'resume_id':V,'alias':p,'status':'offline','task':_0x107f09(0x1da)})[_0x107f09(0x176)](()=>{}),process[_0x107f09(0x1dc)](0x0);}function a0_0x35e7(_0x48d436,_0x540117){_0x48d436=_0x48d436-0x143;const _0x202c61=a0_0x202c();let _0x202cca=_0x202c61[_0x48d436];return _0x202cca;}process[a0_0x772d6f(0x160)]['on']('end',()=>b()),process['on']('SIGTERM',()=>b()),process['on'](a0_0x772d6f(0x152),()=>b());var d=process[a0_0x772d6f(0x19e)];if(d&&d>0x1){let h=setInterval(()=>{const _0x2cec3c=a0_0x772d6f;if(process['ppid']===0x1&&d!==0x1){z('parent\x20claude\x20died\x20(reparented\x20to\x20PID\x201\x20from\x20'+d+')\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat'),b();return;}try{process['kill'](d,0x0);}catch(_0x2b5be9){if(_0x2b5be9?.['code']===_0x2cec3c(0x1a6))z(_0x2cec3c(0x1bc)+d+_0x2cec3c(0x158)),b();}},0x7530);if(typeof h['unref']==='function')h[a0_0x772d6f(0x18e)]();}
|
|
@@ -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.20",
|
|
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",
|