@sleep2agi/agent-network 2.3.0-preview.3 → 2.3.0-preview.31
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/README.md +1 -1
- package/dist/bin/cli.d.ts +1 -0
- 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/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 +1 -1
- 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 +7 -4
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_0x15f4d9=a0_0x2ade;(function(_0x292073,_0x1ea9c2){const _0x2aad4f=a0_0x2ade,_0x2e6e37=_0x292073();while(!![]){try{const _0x1cb1a2=parseInt(_0x2aad4f(0x18d))/0x1+parseInt(_0x2aad4f(0x147))/0x2*(parseInt(_0x2aad4f(0x107))/0x3)+-parseInt(_0x2aad4f(0x115))/0x4+-parseInt(_0x2aad4f(0x119))/0x5+-parseInt(_0x2aad4f(0x19b))/0x6*(parseInt(_0x2aad4f(0x11f))/0x7)+-parseInt(_0x2aad4f(0xfe))/0x8*(-parseInt(_0x2aad4f(0x17e))/0x9)+parseInt(_0x2aad4f(0x16f))/0xa;if(_0x1cb1a2===_0x1ea9c2)break;else _0x2e6e37['push'](_0x2e6e37['shift']());}catch(_0x715d2f){_0x2e6e37['push'](_0x2e6e37['shift']());}}}(a0_0x4501,0xe74f4));import{readFileSync as a0_0x37dd53,existsSync as a0_0x42c8d7}from'fs';import{randomUUID as a0_0x11eb1d}from'crypto';import{join as a0_0x434ea2}from'path';import{hostname as a0_0x237be6}from'os';import{execSync as a0_0x5c9412}from'child_process';import{Server as a0_0x23ed3b}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x246d70}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x1cc1ee,CallToolRequestSchema as a0_0x14e8b6}from'@modelcontextprotocol/sdk/types.js';function I(_0xf1e101){const _0x40e9a1=a0_0x2ade;if(!a0_0x42c8d7(_0xf1e101))return;for(let _0x5d428f of a0_0x37dd53(_0xf1e101,_0x40e9a1(0x192))[_0x40e9a1(0x113)]('\x0a')){let _0x54ed27=_0x5d428f[_0x40e9a1(0x175)]();if(!_0x54ed27||_0x54ed27['startsWith']('#'))continue;let _0x594886=_0x54ed27[_0x40e9a1(0x18e)]('=');if(_0x594886<0x0)continue;let _0x3b7c0b=_0x54ed27[_0x40e9a1(0x16c)](0x0,_0x594886)['trim'](),_0x1b5861=_0x54ed27[_0x40e9a1(0x16c)](_0x594886+0x1)['trim']()[_0x40e9a1(0x14e)](/^["']|["']$/g,'');if(!process.env[_0x3b7c0b])process.env[_0x3b7c0b]=_0x1b5861;}}var L=process.env.HOME||'~',U=a0_0x434ea2(L,a0_0x15f4d9(0x17f));I(a0_0x434ea2(U,a0_0x15f4d9(0x170)));var v=process[a0_0x15f4d9(0x18f)]()[a0_0x15f4d9(0x14e)](/\//g,'-');I(a0_0x434ea2(U,v,'.env'));function d(){const _0x33b9e2=a0_0x15f4d9;try{return a0_0x5c9412('tmux\x20display-message\x20-p\x20\x27#S\x27',{'encoding':_0x33b9e2(0x192),'timeout':0x7d0})[_0x33b9e2(0x175)]();}catch{return'';}}function m(){const _0x4c3005=a0_0x15f4d9;try{let _0x20b3d9=a0_0x434ea2(L,_0x4c3005(0x11c),'config.json');if(a0_0x42c8d7(_0x20b3d9))return JSON[_0x4c3005(0x178)](a0_0x37dd53(_0x20b3d9,_0x4c3005(0x192)));}catch{}return{};}var u=m(),j=process.env.COMMHUB_URL||u[a0_0x15f4d9(0x137)]||a0_0x15f4d9(0x138),f=process.env.COMMHUB_TMUX||d();function r(){const _0x95f1d7=a0_0x15f4d9;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS['trim']())return process.env.COMMHUB_ALIAS[_0x95f1d7(0x175)]();return process['stderr'][_0x95f1d7(0x112)](_0x95f1d7(0x10c)+(_0x95f1d7(0x177)+(f||_0x95f1d7(0x116))+_0x95f1d7(0x162)+a0_0x237be6()+_0x95f1d7(0x128))),'unattributed-'+process[_0x95f1d7(0x197)];}var G=r(),K=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x11eb1d(),F=process.env.COMMHUB_TOKEN||u[a0_0x15f4d9(0x12f)]||'';function W(_0x3484a7){const _0x1b9689=a0_0x15f4d9;let _0x1f39ba=new Date()['toTimeString']()['slice'](0x0,0x8);process[_0x1b9689(0x15c)][_0x1b9689(0x112)]('['+_0x1f39ba+_0x1b9689(0x14d)+_0x3484a7+'\x0a');}function N(_0x1ea835){return new Promise(_0x1db6a8=>setTimeout(_0x1db6a8,_0x1ea835));}function a0_0x2ade(_0x5bec9b,_0x4765fc){_0x5bec9b=_0x5bec9b-0xfd;const _0x4501be=a0_0x4501();let _0x2aded2=_0x4501be[_0x5bec9b];return _0x2aded2;}W(a0_0x15f4d9(0x10e)+j+a0_0x15f4d9(0x198)+G+a0_0x15f4d9(0x19d)+K[a0_0x15f4d9(0x16c)](0x0,0x8)+a0_0x15f4d9(0x12b)+(f||a0_0x15f4d9(0x185))+a0_0x15f4d9(0x121)+process[a0_0x15f4d9(0x18f)]()+'\x20PROJECT_ENV='+v);var D=new Map(),x=new a0_0x23ed3b({'name':a0_0x15f4d9(0x13c),'version':a0_0x15f4d9(0x163)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x15f4d9(0x11d),a0_0x15f4d9(0x12e),'Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.',a0_0x15f4d9(0x144),a0_0x15f4d9(0x18c)+G][a0_0x15f4d9(0x11b)]('\x0a')});x[a0_0x15f4d9(0x19a)](a0_0x1cc1ee,async()=>({'tools':[{'name':a0_0x15f4d9(0x176),'description':'Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','inputSchema':{'type':a0_0x15f4d9(0x131),'properties':{'task_id':{'type':a0_0x15f4d9(0x159),'description':a0_0x15f4d9(0x10b)},'text':{'type':'string','description':a0_0x15f4d9(0x140)},'status':{'type':'string','enum':['completed',a0_0x15f4d9(0x199),a0_0x15f4d9(0x130),a0_0x15f4d9(0x134),a0_0x15f4d9(0x125),a0_0x15f4d9(0x154)],'description':a0_0x15f4d9(0x174)}},'required':[a0_0x15f4d9(0x12c)]}},{'name':a0_0x15f4d9(0x102),'description':'Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','inputSchema':{'type':a0_0x15f4d9(0x131),'properties':{'status':{'type':a0_0x15f4d9(0x159),'enum':[a0_0x15f4d9(0x15e),a0_0x15f4d9(0x16a),a0_0x15f4d9(0x134),a0_0x15f4d9(0x125)]},'task':{'type':a0_0x15f4d9(0x159),'description':a0_0x15f4d9(0x148)},'progress':{'type':'number','description':a0_0x15f4d9(0x167)}},'required':[a0_0x15f4d9(0x15f)]}},{'name':'commhub_send_task','description':a0_0x15f4d9(0x16e),'inputSchema':{'type':'object','properties':{'alias':{'type':a0_0x15f4d9(0x159),'description':a0_0x15f4d9(0x103)},'task':{'type':'string','description':a0_0x15f4d9(0x171)},'priority':{'type':a0_0x15f4d9(0x159),'enum':[a0_0x15f4d9(0x179),a0_0x15f4d9(0x111),a0_0x15f4d9(0x166)],'description':a0_0x15f4d9(0x13e)}},'required':['alias',a0_0x15f4d9(0x146)]}},{'name':a0_0x15f4d9(0x183),'description':a0_0x15f4d9(0x150),'inputSchema':{'type':a0_0x15f4d9(0x131),'properties':{'alias':{'type':a0_0x15f4d9(0x159),'description':a0_0x15f4d9(0x103)},'message':{'type':a0_0x15f4d9(0x159),'description':a0_0x15f4d9(0x182)}},'required':[a0_0x15f4d9(0x118),'message']}},{'name':a0_0x15f4d9(0x139),'description':a0_0x15f4d9(0x189),'inputSchema':{'type':'object','properties':{}}}]}));async function Y(_0x23f82d,_0x2f25fa){const _0x41b335=a0_0x15f4d9;let _0x120e4d=await fetch(j+_0x41b335(0x10f),{'method':_0x41b335(0x100),'headers':{'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream',...F?{'Authorization':_0x41b335(0x15b)+F}:{}},'body':JSON[_0x41b335(0x12a)]({'jsonrpc':_0x41b335(0x126),'id':0x1,'method':_0x41b335(0xff),'params':{'protocolVersion':'2025-03-26','capabilities':{},'clientInfo':{'name':_0x41b335(0x13c),'version':_0x41b335(0x163)}}})});if(!_0x120e4d['ok']){let _0x34c0cc=await _0x120e4d[_0x41b335(0x12c)]();return W(_0x41b335(0x191)+_0x120e4d[_0x41b335(0x15f)]+'\x20'+_0x34c0cc[_0x41b335(0x16c)](0x0,0x64)),{'ok':!0x1,'error':'init\x20failed:\x20'+_0x120e4d[_0x41b335(0x15f)]};}await _0x120e4d[_0x41b335(0x12c)]();let _0x531abb=(await(await fetch(j+_0x41b335(0x10f),{'method':_0x41b335(0x100),'headers':{'Content-Type':_0x41b335(0x133),'Accept':_0x41b335(0x143),...F?{'Authorization':_0x41b335(0x15b)+F}:{}},'body':JSON[_0x41b335(0x12a)]({'jsonrpc':_0x41b335(0x126),'id':0x2,'method':'tools/call','params':{'name':_0x23f82d,'arguments':_0x2f25fa}})}))[_0x41b335(0x12c)]())[_0x41b335(0x113)]('\x0a')[_0x41b335(0x114)](_0x3b2957=>_0x3b2957['startsWith'](_0x41b335(0x122)));if(_0x531abb){let _0x3b1479=JSON[_0x41b335(0x178)](_0x531abb['slice'](0x6));return _0x3b1479?.[_0x41b335(0x173)]?.[_0x41b335(0x18b)]?.[0x0]?.[_0x41b335(0x12c)]?JSON[_0x41b335(0x178)](_0x3b1479[_0x41b335(0x173)]['content'][0x0][_0x41b335(0x12c)]):_0x3b1479;}return{'ok':!0x1,'error':_0x41b335(0x181)};}x['setRequestHandler'](a0_0x14e8b6,async _0x5f5af3=>{const _0x544e9b=a0_0x15f4d9;let {name:_0x2b0297,arguments:_0x3b41dc}=_0x5f5af3[_0x544e9b(0x104)];if(_0x2b0297===_0x544e9b(0x176)){let {task_id:_0x3c469d,text:_0x3c71b9,status:_0x3b796c}=_0x3b41dc;if(_0x3b796c===_0x544e9b(0x101)||_0x3b796c===_0x544e9b(0x199)||_0x3b796c===_0x544e9b(0x130)){let _0x202d26=_0x3b796c===_0x544e9b(0x101)?_0x544e9b(0x145):_0x3b796c,_0x3fb581=_0x3c469d?D[_0x544e9b(0x13f)](_0x3c469d)||_0x544e9b(0x137):_0x544e9b(0x137),_0x2ab1cc=await Y('send_reply',{'alias':_0x3fb581,'text':_0x3c71b9,'in_reply_to':_0x3c469d||void 0x0,'status':_0x202d26,'from_session':G});if(_0x3c469d)D[_0x544e9b(0xfd)](_0x3c469d);return{'content':[{'type':'text','text':JSON['stringify'](_0x2ab1cc)}]};}let _0x1af9d3=await Y(_0x544e9b(0x11e),{'resume_id':K,'alias':G,'status':_0x3b796c===_0x544e9b(0x134)?_0x544e9b(0x134):_0x3b796c===_0x544e9b(0x125)?_0x544e9b(0x125):_0x544e9b(0x15e),'task':_0x3c71b9[_0x544e9b(0x16c)](0x0,0xc8),'output':_0x3c71b9});return{'content':[{'type':_0x544e9b(0x12c),'text':JSON[_0x544e9b(0x12a)](_0x1af9d3)}]};}if(_0x2b0297===_0x544e9b(0x102)){let {status:_0x1ec5c4,task:_0x474b26,progress:_0x5265fb}=_0x3b41dc,_0xe719c5=await Y(_0x544e9b(0x11e),{'resume_id':K,'alias':G,'status':_0x1ec5c4,'task':_0x474b26,'progress':_0x5265fb});return{'content':[{'type':_0x544e9b(0x12c),'text':JSON[_0x544e9b(0x12a)](_0xe719c5)}]};}if(_0x2b0297==='commhub_send_task'){let {alias:_0x1a2027,task:_0x33358b,priority:_0x3d67bf}=_0x3b41dc,_0xab37b7=await Y(_0x544e9b(0x15a),{'alias':_0x1a2027,'task':_0x33358b,'priority':_0x3d67bf||_0x544e9b(0x111),'from_session':G});return{'content':[{'type':_0x544e9b(0x12c),'text':JSON[_0x544e9b(0x12a)](_0xab37b7)}]};}if(_0x2b0297===_0x544e9b(0x183)){let {alias:_0x32e534,message:_0x28bde7}=_0x3b41dc,_0x1bb4f1=await Y('send_message',{'alias':_0x32e534,'message':_0x28bde7,'from_session':G});return{'content':[{'type':'text','text':JSON[_0x544e9b(0x12a)](_0x1bb4f1)}]};}if(_0x2b0297==='commhub_get_all_status'){let _0x56ebb6=await Y(_0x544e9b(0x129),{});return{'content':[{'type':'text','text':JSON[_0x544e9b(0x12a)](_0x56ebb6)}]};}return{'content':[{'type':_0x544e9b(0x12c),'text':JSON['stringify']({'error':_0x544e9b(0x13a)})}]};});var O=0x3e8,R=0x7530,T=0x36ee80;async function l(){const _0x2695a0=a0_0x15f4d9;try{await Y(_0x2695a0(0x11e),{'resume_id':K,'alias':G,'status':_0x2695a0(0x16a),'server':a0_0x237be6(),'hostname':a0_0x237be6(),'agent':_0x2695a0(0x161),'project_dir':process['cwd'](),'tmux_name':f||void 0x0}),W(_0x2695a0(0x155)+G+_0x2695a0(0x136));}catch(_0x2a073f){W('re-register\x20failed:\x20'+_0x2a073f);}}async function o(){const _0x1bdfe1=a0_0x15f4d9;let _0x33cfc7=j+_0x1bdfe1(0x152)+encodeURIComponent(G),_0x4f9aed={};if(F)_0x4f9aed[_0x1bdfe1(0x18a)]='Bearer\x20'+F;W(_0x1bdfe1(0x180)+_0x33cfc7);let _0xbf5fa6=O,_0x36bd05=!0x0,_0x4a8f52=null;while(!0x0){try{let _0x305ba5=await fetch(_0x33cfc7,{'headers':_0x4f9aed});if(!_0x305ba5['ok']){if(W('SSE\x20error:\x20'+_0x305ba5[_0x1bdfe1(0x15f)]+'\x20'+_0x305ba5[_0x1bdfe1(0x153)]),_0x4a8f52=_0x4a8f52??Date[_0x1bdfe1(0x186)](),Date['now']()-_0x4a8f52>T){W(_0x1bdfe1(0x184)+j+_0x1bdfe1(0x13b));return;}await N(_0xbf5fa6),_0xbf5fa6=Math[_0x1bdfe1(0x19c)](_0xbf5fa6*0x2,R);continue;}let _0x533cb3=_0x305ba5[_0x1bdfe1(0x14f)][_0x1bdfe1(0x17b)](),_0x20e01c=new TextDecoder(),_0x2a85d5='';_0xbf5fa6=O;while(!0x0){let {done:_0x37d50e,value:_0x48b716}=await _0x533cb3[_0x1bdfe1(0x10d)]();if(_0x37d50e)break;_0x2a85d5+=_0x20e01c[_0x1bdfe1(0x160)](_0x48b716,{'stream':!0x0});let _0x1df06d=_0x2a85d5[_0x1bdfe1(0x113)]('\x0a\x0a');_0x2a85d5=_0x1df06d[_0x1bdfe1(0x10a)]()||'';for(let _0x4b5117 of _0x1df06d){let _0x1750a0=_0x4b5117[_0x1bdfe1(0x113)]('\x0a')[_0x1bdfe1(0x114)](_0x20c240=>_0x20c240[_0x1bdfe1(0x195)](_0x1bdfe1(0x122)));if(!_0x1750a0)continue;try{let _0x54b141=JSON['parse'](_0x1750a0[_0x1bdfe1(0x16c)](0x6));if(await a(_0x54b141),_0x54b141[_0x1bdfe1(0x193)]==='connected'){if(_0x4a8f52=null,!_0x36bd05)await l();_0x36bd05=!0x1;}}catch(_0x4ef405){W(_0x1bdfe1(0x14c)+_0x4ef405);}}}W(_0x1bdfe1(0x110));}catch(_0x2cc933){W(_0x1bdfe1(0x135)+_0x2cc933);}if(_0x4a8f52=_0x4a8f52??Date[_0x1bdfe1(0x186)](),Date[_0x1bdfe1(0x186)]()-_0x4a8f52>T){W(_0x1bdfe1(0x184)+j+_0x1bdfe1(0x13b));return;}await N(_0xbf5fa6),_0xbf5fa6=Math[_0x1bdfe1(0x19c)](_0xbf5fa6*0x2,R);}}async function a(_0x598cc1){const _0x53b639=a0_0x15f4d9;if(_0x598cc1[_0x53b639(0x193)]===_0x53b639(0x123)){W(_0x53b639(0x196)+G+'\x22');return;}if(_0x598cc1['type']===_0x53b639(0x142)){if(W(_0x53b639(0x156)+_0x598cc1[_0x53b639(0x151)]+':\x20'+_0x598cc1['message'][_0x53b639(0x16c)](0x0,0x3c)),await x[_0x53b639(0x157)]({'method':'notifications/claude/channel','params':{'content':_0x598cc1[_0x53b639(0x158)],'meta':{'sender':_0x598cc1[_0x53b639(0x151)]||_0x53b639(0x137),'sender_id':'commhub','user':_0x598cc1[_0x53b639(0x151)]||_0x53b639(0x137),'priority':'normal'}}}),_0x598cc1[_0x53b639(0x141)])await Y(_0x53b639(0x105),{'alias':G,'message_id':_0x598cc1[_0x53b639(0x141)]});return;}if(_0x598cc1[_0x53b639(0x193)]===_0x53b639(0x172)||_0x598cc1[_0x53b639(0x193)]==='broadcast'){W('←\x20'+_0x598cc1[_0x53b639(0x193)]+':\x20inbox_count='+_0x598cc1[_0x53b639(0x165)]+_0x53b639(0x13d)+(_0x598cc1[_0x53b639(0x149)]||_0x53b639(0x111)));let _0x56e576=await Y('get_inbox',{'alias':G,'limit':0x5});if(_0x56e576?.['ok']&&_0x56e576[_0x53b639(0x11a)]?.[_0x53b639(0x108)]>0x0)for(let _0x23d285 of _0x56e576['messages']){let _0x107147={'sender':_0x23d285[_0x53b639(0x124)]||_0x53b639(0x137),'sender_id':_0x53b639(0x109),'user':_0x23d285['from_session']||'hub','task_id':_0x23d285['id'],'priority':_0x23d285['priority']||_0x53b639(0x111)};D[_0x53b639(0x127)](_0x23d285['id'],_0x23d285[_0x53b639(0x124)]||_0x53b639(0x137)),await x[_0x53b639(0x157)]({'method':_0x53b639(0x190),'params':{'content':_0x23d285[_0x53b639(0x18b)],'meta':_0x107147}}),W(_0x53b639(0x188)+_0x23d285['id'][_0x53b639(0x16c)](0x0,0x8)+'\x20from\x20'+_0x23d285['from_session']+':\x20'+_0x23d285['content'][_0x53b639(0x16c)](0x0,0x3c)),await Y('ack_inbox',{'alias':G,'message_id':_0x23d285['id']});}}}function a0_0x4501(){const _0x6cac2d=['delete','50808MTtBtu','initialize','POST','completed','commhub_report_status','Target\x20session\x20alias','params','ack_inbox','offline','6kuKwgv','length','commhub','pop','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20','read','ENV:\x20URL=','/mcp','SSE\x20stream\x20ended,\x20reconnecting...','normal','write','split','find','6360224cceeZl','(none)','stdin','alias','8666325DAPEBr','messages','join','.anet','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','report_status','952469PecTou','SIGINT','\x20CWD=','data:\x20','connected','from_session','error','2.0','set','.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a','get_all_status','stringify','...\x20TMUX=','text','fatal:\x20','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','token','cancelled','object','SIGTERM','application/json','blocked','SSE\x20connection\x20error:\x20','\x22\x20after\x20SSE\x20reconnect','hub','http://127.0.0.1:9200','commhub_get_all_status','unknown\x20tool',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','commhub-channel','\x20priority=','Priority\x20(default:\x20normal)','get','Reply\x20text\x20/\x20result\x20summary','message_id','new_message','application/json,\x20text/event-stream','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','replied','task','906156sglHKg','Current\x20task\x20description','priority','heartbeat\x20failed:\x20','then','parse\x20error:\x20',']\x20[commhub]\x20','replace','body','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','from','/events/','statusText','in_progress','re-registered\x20as\x20\x22','←\x20message\x20from\x20','notification','message','string','send_task','Bearer\x20','stderr','warning:\x20could\x20not\x20register:\x20','working','status','decode','claude-code','\x20/\x20hostname=','0.3.0','session\x20disconnected','inbox_count','low','Progress\x200-100','MCP\x20stdio\x20connected','exit','idle','shutting\x20down,\x20reporting\x20offline...','slice','ready\x20—\x20waiting\x20for\x20events','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','29466220DuRAdr','.env','Task\x20content','new_task','result','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','trim','commhub_reply','would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME=','parse','high','catch','getReader','\x22\x20(','connect','495ZWUGjY','.claude/channels/commhub','connecting\x20to\x20','no\x20response','Message\x20content','commhub_send_message','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','none','now','starting\x20SSE\x20listener...','→\x20injected\x20task\x20','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','Authorization','content','Session\x20alias:\x20','1565419vuDdEz','indexOf','cwd','notifications/claude/channel','CommHub\x20init\x20failed:\x20','utf-8','type','end','startsWith','SSE\x20connected\x20as\x20\x22','pid','\x20ALIAS=','failed','setRequestHandler','66RrCwQc','min','\x20RESUME_ID='];a0_0x4501=function(){return _0x6cac2d;};return a0_0x4501();}async function n(){const _0x2c16fb=a0_0x15f4d9;let _0x59ee4f=new a0_0x246d70();await x[_0x2c16fb(0x17d)](_0x59ee4f),W(_0x2c16fb(0x168)),W(_0x2c16fb(0x187)),o()['catch'](_0x59681d=>W('SSE\x20fatal:\x20'+_0x59681d)),Y(_0x2c16fb(0x11e),{'resume_id':K,'alias':G,'status':_0x2c16fb(0x16a),'server':a0_0x237be6(),'hostname':a0_0x237be6(),'agent':_0x2c16fb(0x161),'project_dir':process[_0x2c16fb(0x18f)](),'tmux_name':f||void 0x0})[_0x2c16fb(0x14b)](()=>W('registered\x20as\x20\x22'+G+_0x2c16fb(0x17c)+K[_0x2c16fb(0x16c)](0x0,0x8)+')'))[_0x2c16fb(0x17a)](_0x253dbc=>W(_0x2c16fb(0x15d)+_0x253dbc)),setInterval(()=>{const _0x535dd4=_0x2c16fb;Y(_0x535dd4(0x11e),{'resume_id':K,'alias':G,'status':'idle','server':a0_0x237be6(),'hostname':a0_0x237be6(),'agent':'claude-code','project_dir':process[_0x535dd4(0x18f)](),'tmux_name':f||void 0x0})[_0x535dd4(0x17a)](_0x31b110=>W(_0x535dd4(0x14a)+_0x31b110));},0x2bf20),W(_0x2c16fb(0x16d));}n()['catch'](_0x1b8f2d=>{const _0x50c31e=a0_0x15f4d9;W(_0x50c31e(0x12d)+_0x1b8f2d),process[_0x50c31e(0x169)](0x1);});async function b(){const _0x549aac=a0_0x15f4d9;W(_0x549aac(0x16b)),await Y(_0x549aac(0x11e),{'resume_id':K,'alias':G,'status':_0x549aac(0x106),'task':_0x549aac(0x164)})[_0x549aac(0x17a)](()=>{}),process[_0x549aac(0x169)](0x0);}process[a0_0x15f4d9(0x117)]['on'](a0_0x15f4d9(0x194),()=>b()),process['on'](a0_0x15f4d9(0x132),()=>b()),process['on'](a0_0x15f4d9(0x120),()=>b());
|
|
2
|
+
const a0_0x1685ca=a0_0xca9b;(function(_0x89f77d,_0x5b9570){const _0x23df84=a0_0xca9b,_0x1c8406=_0x89f77d();while(!![]){try{const _0x4287b8=parseInt(_0x23df84(0x1ac))/0x1*(-parseInt(_0x23df84(0x1b4))/0x2)+-parseInt(_0x23df84(0x211))/0x3*(-parseInt(_0x23df84(0x1ca))/0x4)+parseInt(_0x23df84(0x21b))/0x5*(-parseInt(_0x23df84(0x1f5))/0x6)+-parseInt(_0x23df84(0x209))/0x7+-parseInt(_0x23df84(0x19e))/0x8+parseInt(_0x23df84(0x1f2))/0x9*(-parseInt(_0x23df84(0x1de))/0xa)+-parseInt(_0x23df84(0x214))/0xb*(-parseInt(_0x23df84(0x1dd))/0xc);if(_0x4287b8===_0x5b9570)break;else _0x1c8406['push'](_0x1c8406['shift']());}catch(_0x4116e7){_0x1c8406['push'](_0x1c8406['shift']());}}}(a0_0x4193,0x41114));import{readFileSync as a0_0x57c093,existsSync as a0_0x1e91dc}from'fs';import{randomUUID as a0_0x33e0c7}from'crypto';import{join as a0_0x241df4}from'path';import{hostname as a0_0x1921c6}from'os';import{execSync as a0_0x1c144c}from'child_process';function B(_0x522291){const _0x24e42a=a0_0xca9b;let _0x3c42bb=_0x522291['replace'](/[^a-zA-Z0-9\-_]/g,'-');return _0x3c42bb===''?_0x24e42a(0x1a2):_0x3c42bb;}import{Server as a0_0x4867bc}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x127f45}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x1d2525,CallToolRequestSchema as a0_0x21c857}from'@modelcontextprotocol/sdk/types.js';function T(_0x24a81e){const _0x1e1a16=a0_0xca9b;if(!a0_0x1e91dc(_0x24a81e))return;for(let _0x29f1ae of a0_0x57c093(_0x24a81e,_0x1e1a16(0x207))['split']('\x0a')){let _0x191cc8=_0x29f1ae[_0x1e1a16(0x1ea)]();if(!_0x191cc8||_0x191cc8[_0x1e1a16(0x181)]('#'))continue;let _0x3b0bb7=_0x191cc8[_0x1e1a16(0x1b7)]('=');if(_0x3b0bb7<0x0)continue;let _0x3b435b=_0x191cc8['slice'](0x0,_0x3b0bb7)['trim'](),_0x1f3b00=_0x191cc8[_0x1e1a16(0x191)](_0x3b0bb7+0x1)['trim']()[_0x1e1a16(0x205)](/^["']|["']$/g,'');if(!process.env[_0x3b435b])process.env[_0x3b435b]=_0x1f3b00;}}var C=process.env.HOME||'~',r=a0_0x241df4(C,a0_0x1685ca(0x1d9));T(a0_0x241df4(r,a0_0x1685ca(0x206)));var H=B(process[a0_0x1685ca(0x1c5)]());T(a0_0x241df4(r,H,a0_0x1685ca(0x206)));function E(){const _0x143212=a0_0x1685ca;try{return a0_0x1c144c(_0x143212(0x1be),{'encoding':_0x143212(0x207),'timeout':0x7d0})['trim']();}catch{return'';}}function _(){const _0x1f0dee=a0_0x1685ca;try{let _0x106bed=a0_0x241df4(C,'.anet',_0x1f0dee(0x1e4));if(a0_0x1e91dc(_0x106bed))return JSON[_0x1f0dee(0x1c3)](a0_0x57c093(_0x106bed,'utf-8'));}catch{}return{};}var R=_(),Y=process.env.COMMHUB_URL||R['hub']||a0_0x1685ca(0x215),j=process.env.COMMHUB_TMUX||E();function S(){const _0x74c2ce=a0_0x1685ca;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS[_0x74c2ce(0x1ea)]())return process.env.COMMHUB_ALIAS[_0x74c2ce(0x1ea)]();return process['stderr'][_0x74c2ce(0x1f8)](_0x74c2ce(0x1a7)+(_0x74c2ce(0x1ee)+(j||_0x74c2ce(0x201))+'\x20/\x20hostname='+a0_0x1921c6()+_0x74c2ce(0x1fe))),_0x74c2ce(0x1b3)+process[_0x74c2ce(0x1f0)];}var p=S(),V=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x33e0c7(),k=process.env.COMMHUB_TOKEN||R[a0_0x1685ca(0x1c1)]||'';function z(_0xf31291){const _0x5a97bd=a0_0x1685ca;let _0x45dd47=new Date()['toTimeString']()[_0x5a97bd(0x191)](0x0,0x8);process[_0x5a97bd(0x200)][_0x5a97bd(0x1f8)]('['+_0x45dd47+_0x5a97bd(0x21e)+_0xf31291+'\x0a');}function i(_0x1d6e84){return new Promise(_0x1b9a47=>setTimeout(_0x1b9a47,_0x1d6e84));}z(a0_0x1685ca(0x182)+Y+'\x20ALIAS='+p+'\x20RESUME_ID='+V[a0_0x1685ca(0x191)](0x0,0x8)+a0_0x1685ca(0x1b8)+(j||a0_0x1685ca(0x1ab))+a0_0x1685ca(0x208)+process['cwd']()+'\x20PROJECT_ENV='+H);var G=new Map(),K=new a0_0x4867bc({'name':a0_0x1685ca(0x1a0),'version':a0_0x1685ca(0x1d8)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x1685ca(0x18f),a0_0x1685ca(0x1cb),a0_0x1685ca(0x188),'You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.',a0_0x1685ca(0x1fb)+p][a0_0x1685ca(0x196)]('\x0a')});K[a0_0x1685ca(0x1d3)](a0_0x1d2525,async()=>({'tools':[{'name':a0_0x1685ca(0x1d1),'description':a0_0x1685ca(0x1db),'inputSchema':{'type':a0_0x1685ca(0x1bc),'properties':{'task_id':{'type':a0_0x1685ca(0x1af),'description':a0_0x1685ca(0x1aa)},'text':{'type':a0_0x1685ca(0x1af),'description':'Reply\x20text\x20/\x20result\x20summary'},'status':{'type':a0_0x1685ca(0x1af),'enum':['completed',a0_0x1685ca(0x203),'cancelled',a0_0x1685ca(0x1b1),'error','in_progress'],'description':a0_0x1685ca(0x1e5)}},'required':['text']}},{'name':a0_0x1685ca(0x1f9),'description':'Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','inputSchema':{'type':'object','properties':{'status':{'type':a0_0x1685ca(0x1af),'enum':[a0_0x1685ca(0x1a4),a0_0x1685ca(0x1b9),'blocked',a0_0x1685ca(0x19b)]},'task':{'type':a0_0x1685ca(0x1af),'description':a0_0x1685ca(0x1a3)},'progress':{'type':a0_0x1685ca(0x212),'description':a0_0x1685ca(0x1a9)}},'required':[a0_0x1685ca(0x1ad)]}},{'name':a0_0x1685ca(0x1f1),'description':a0_0x1685ca(0x1b2),'inputSchema':{'type':a0_0x1685ca(0x1bc),'properties':{'alias':{'type':a0_0x1685ca(0x1af),'description':a0_0x1685ca(0x1e9)},'task':{'type':a0_0x1685ca(0x1af),'description':'Task\x20content'},'priority':{'type':a0_0x1685ca(0x1af),'enum':[a0_0x1685ca(0x19c),'normal',a0_0x1685ca(0x204)],'description':a0_0x1685ca(0x17f)}},'required':[a0_0x1685ca(0x202),'task']}},{'name':'commhub_send_message','description':a0_0x1685ca(0x1a1),'inputSchema':{'type':a0_0x1685ca(0x1bc),'properties':{'alias':{'type':a0_0x1685ca(0x1af),'description':a0_0x1685ca(0x1e9)},'message':{'type':a0_0x1685ca(0x1af),'description':a0_0x1685ca(0x1c2)}},'required':[a0_0x1685ca(0x202),a0_0x1685ca(0x1cd)]}},{'name':'commhub_get_all_status','description':'Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','inputSchema':{'type':'object','properties':{}}}]}));async function Q(_0x3a0ee4,_0x30eb38){const _0x27ac39=a0_0x1685ca;let _0x51aa1e=await fetch(Y+'/mcp',{'method':_0x27ac39(0x1e6),'headers':{'Content-Type':_0x27ac39(0x19f),'Accept':_0x27ac39(0x1bd),...k?{'Authorization':_0x27ac39(0x18a)+k}:{}},'body':JSON[_0x27ac39(0x197)]({'jsonrpc':_0x27ac39(0x210),'id':0x1,'method':_0x27ac39(0x183),'params':{'protocolVersion':_0x27ac39(0x1e0),'capabilities':{},'clientInfo':{'name':_0x27ac39(0x1a0),'version':_0x27ac39(0x1d8)}}})});if(!_0x51aa1e['ok']){let _0x268299=await _0x51aa1e['text']();return z(_0x27ac39(0x1fc)+_0x51aa1e[_0x27ac39(0x1ad)]+'\x20'+_0x268299[_0x27ac39(0x191)](0x0,0x64)),{'ok':!0x1,'error':_0x27ac39(0x1ba)+_0x51aa1e[_0x27ac39(0x1ad)]};}await _0x51aa1e[_0x27ac39(0x1bf)]();let _0x15cacd=(await(await fetch(Y+'/mcp',{'method':_0x27ac39(0x1e6),'headers':{'Content-Type':'application/json','Accept':_0x27ac39(0x1bd),...k?{'Authorization':_0x27ac39(0x18a)+k}:{}},'body':JSON[_0x27ac39(0x197)]({'jsonrpc':_0x27ac39(0x210),'id':0x2,'method':_0x27ac39(0x1da),'params':{'name':_0x3a0ee4,'arguments':_0x30eb38}})}))[_0x27ac39(0x1bf)]())[_0x27ac39(0x1e3)]('\x0a')[_0x27ac39(0x1d7)](_0x1925a5=>_0x1925a5[_0x27ac39(0x181)]('data:\x20'));if(_0x15cacd){let _0x454bcc=JSON[_0x27ac39(0x1c3)](_0x15cacd[_0x27ac39(0x191)](0x6));return _0x454bcc?.['result']?.[_0x27ac39(0x218)]?.[0x0]?.['text']?JSON[_0x27ac39(0x1c3)](_0x454bcc[_0x27ac39(0x1d4)][_0x27ac39(0x218)][0x0][_0x27ac39(0x1bf)]):_0x454bcc;}return{'ok':!0x1,'error':_0x27ac39(0x17e)};}K[a0_0x1685ca(0x1d3)](a0_0x21c857,async _0x505d74=>{const _0x2300f4=a0_0x1685ca;let {name:_0x21506d,arguments:_0x4e6a64}=_0x505d74[_0x2300f4(0x189)];if(_0x21506d===_0x2300f4(0x1d1)){let {task_id:_0x5228d8,text:_0x3ca950,status:_0x541a03}=_0x4e6a64;if(_0x541a03==='completed'||_0x541a03==='failed'||_0x541a03===_0x2300f4(0x20e)){let _0x54083c=_0x541a03===_0x2300f4(0x199)?_0x2300f4(0x1d2):_0x541a03,_0x5b4871=_0x5228d8?G[_0x2300f4(0x20b)](_0x5228d8)||_0x2300f4(0x1e2):'hub',_0x12b457=await Q('send_reply',{'alias':_0x5b4871,'text':_0x3ca950,'in_reply_to':_0x5228d8||void 0x0,'status':_0x54083c,'from_session':p});if(_0x5228d8)G['delete'](_0x5228d8);return{'content':[{'type':_0x2300f4(0x1bf),'text':JSON[_0x2300f4(0x197)](_0x12b457)}]};}let _0x9cf757=await Q('report_status',{'resume_id':V,'alias':p,'status':_0x541a03===_0x2300f4(0x1b1)?_0x2300f4(0x1b1):_0x541a03==='error'?'error':_0x2300f4(0x1a4),'task':_0x3ca950[_0x2300f4(0x191)](0x0,0xc8),'output':_0x3ca950});return{'content':[{'type':'text','text':JSON[_0x2300f4(0x197)](_0x9cf757)}]};}if(_0x21506d===_0x2300f4(0x1f9)){let {status:_0x895261,task:_0x2bd113,progress:_0x355de9}=_0x4e6a64,_0x358739=await Q('report_status',{'resume_id':V,'alias':p,'status':_0x895261,'task':_0x2bd113,'progress':_0x355de9});return{'content':[{'type':'text','text':JSON[_0x2300f4(0x197)](_0x358739)}]};}if(_0x21506d===_0x2300f4(0x1f1)){let {alias:_0x1207d6,task:_0x34ba32,priority:_0x5b9ff4}=_0x4e6a64,_0xac31f3=await Q('send_task',{'alias':_0x1207d6,'task':_0x34ba32,'priority':_0x5b9ff4||'normal','from_session':p});return{'content':[{'type':_0x2300f4(0x1bf),'text':JSON[_0x2300f4(0x197)](_0xac31f3)}]};}if(_0x21506d===_0x2300f4(0x185)){let {alias:_0x5368cd,message:_0xe84129}=_0x4e6a64,_0x453c5c=await Q('send_message',{'alias':_0x5368cd,'message':_0xe84129,'from_session':p});return{'content':[{'type':_0x2300f4(0x1bf),'text':JSON[_0x2300f4(0x197)](_0x453c5c)}]};}if(_0x21506d===_0x2300f4(0x1a5)){let _0x44f1f8=await Q('get_all_status',{});return{'content':[{'type':_0x2300f4(0x1bf),'text':JSON[_0x2300f4(0x197)](_0x44f1f8)}]};}return{'content':[{'type':_0x2300f4(0x1bf),'text':JSON[_0x2300f4(0x197)]({'error':_0x2300f4(0x1d0)})}]};});var D=0x3e8,v=0x7530,O=0x36ee80;async function m(){const _0x4ddb02=a0_0x1685ca;try{await Q(_0x4ddb02(0x1e8),{'resume_id':V,'alias':p,'status':'idle','server':a0_0x1921c6(),'hostname':a0_0x1921c6(),'agent':'claude-code','project_dir':process[_0x4ddb02(0x1c5)](),'tmux_name':j||void 0x0}),z(_0x4ddb02(0x17d)+p+'\x22\x20after\x20SSE\x20reconnect');}catch(_0x28319a){z(_0x4ddb02(0x1e7)+_0x28319a);}}async function l(){const _0x199d24=a0_0x1685ca;let _0x5ade71=Y+_0x199d24(0x187)+encodeURIComponent(p),_0x53b22e={};if(k)_0x53b22e['Authorization']=_0x199d24(0x18a)+k;z(_0x199d24(0x198)+_0x5ade71);let _0x218153=D,_0x38ce93=!0x0,_0x260189=null;while(!0x0){try{let _0x23e632=await fetch(_0x5ade71,{'headers':_0x53b22e});if(!_0x23e632['ok']){if(z(_0x199d24(0x180)+_0x23e632[_0x199d24(0x1ad)]+'\x20'+_0x23e632[_0x199d24(0x213)]),_0x260189=_0x260189??Date['now'](),Date[_0x199d24(0x1d5)]()-_0x260189>O){z('SSE\x20连续\x20>1h\x20连不上\x20hub\x20('+Y+_0x199d24(0x1c7));return;}await i(_0x218153),_0x218153=Math[_0x199d24(0x1b5)](_0x218153*0x2,v);continue;}let _0x1736ff=_0x23e632[_0x199d24(0x192)][_0x199d24(0x1e1)](),_0x314a86=new TextDecoder(),_0x4612ee='';_0x218153=D;while(!0x0){let {done:_0x3258e5,value:_0x2461ee}=await _0x1736ff['read']();if(_0x3258e5)break;_0x4612ee+=_0x314a86['decode'](_0x2461ee,{'stream':!0x0});let _0x547248=_0x4612ee[_0x199d24(0x1e3)]('\x0a\x0a');_0x4612ee=_0x547248[_0x199d24(0x1ce)]()||'';for(let _0x4c77cc of _0x547248){let _0x58b37e=_0x4c77cc[_0x199d24(0x1e3)]('\x0a')[_0x199d24(0x1d7)](_0x37652a=>_0x37652a['startsWith'](_0x199d24(0x20a)));if(!_0x58b37e)continue;try{let _0x354a83=JSON[_0x199d24(0x1c3)](_0x58b37e['slice'](0x6));if(await A(_0x354a83),_0x354a83[_0x199d24(0x1cc)]===_0x199d24(0x1c6)){if(_0x260189=null,!_0x38ce93)await m();_0x38ce93=!0x1;}}catch(_0x434e60){z(_0x199d24(0x1dc)+_0x434e60);}}}z('SSE\x20stream\x20ended,\x20reconnecting...');}catch(_0x4d64e5){z('SSE\x20connection\x20error:\x20'+_0x4d64e5);}if(_0x260189=_0x260189??Date[_0x199d24(0x1d5)](),Date[_0x199d24(0x1d5)]()-_0x260189>O){z(_0x199d24(0x216)+Y+_0x199d24(0x1c7));return;}await i(_0x218153),_0x218153=Math['min'](_0x218153*0x2,v);}}async function A(_0x4d6dee){const _0x2e6293=a0_0x1685ca;if(_0x4d6dee[_0x2e6293(0x1cc)]===_0x2e6293(0x1c6)){z(_0x2e6293(0x1c9)+p+'\x22');return;}if(_0x4d6dee[_0x2e6293(0x1cc)]===_0x2e6293(0x20c)){if(z(_0x2e6293(0x1b6)+_0x4d6dee[_0x2e6293(0x18b)]+':\x20'+_0x4d6dee[_0x2e6293(0x1cd)][_0x2e6293(0x191)](0x0,0x3c)),await K[_0x2e6293(0x21a)]({'method':_0x2e6293(0x1a6),'params':{'content':_0x4d6dee[_0x2e6293(0x1cd)],'meta':{'sender':_0x4d6dee['from']||_0x2e6293(0x1e2),'sender_id':_0x2e6293(0x18c),'user':_0x4d6dee['from']||'hub','priority':'normal'}}}),_0x4d6dee[_0x2e6293(0x1f6)])await Q(_0x2e6293(0x1eb),{'alias':p,'message_id':_0x4d6dee['message_id']});return;}if(_0x4d6dee[_0x2e6293(0x1cc)]===_0x2e6293(0x1f3)||_0x4d6dee[_0x2e6293(0x1cc)]==='broadcast'){z('←\x20'+_0x4d6dee[_0x2e6293(0x1cc)]+_0x2e6293(0x193)+_0x4d6dee[_0x2e6293(0x1a8)]+'\x20priority='+(_0x4d6dee[_0x2e6293(0x1ae)]||_0x2e6293(0x1f4)));let _0xae3168=await Q(_0x2e6293(0x1ef),{'alias':p,'limit':0x5});if(_0xae3168?.['ok']&&_0xae3168[_0x2e6293(0x18e)]?.[_0x2e6293(0x21c)]>0x0)for(let _0x1d5a9d of _0xae3168[_0x2e6293(0x18e)]){let _0x1fe558={'sender':_0x1d5a9d[_0x2e6293(0x20d)]||_0x2e6293(0x1e2),'sender_id':'commhub','user':_0x1d5a9d[_0x2e6293(0x20d)]||_0x2e6293(0x1e2),'task_id':_0x1d5a9d['id'],'priority':_0x1d5a9d['priority']||_0x2e6293(0x1f4)};G[_0x2e6293(0x1fd)](_0x1d5a9d['id'],_0x1d5a9d['from_session']||_0x2e6293(0x1e2)),await K[_0x2e6293(0x21a)]({'method':_0x2e6293(0x1a6),'params':{'content':_0x1d5a9d['content'],'meta':_0x1fe558}}),z(_0x2e6293(0x217)+_0x1d5a9d['id'][_0x2e6293(0x191)](0x0,0x8)+'\x20from\x20'+_0x1d5a9d[_0x2e6293(0x20d)]+':\x20'+_0x1d5a9d['content']['slice'](0x0,0x3c)),await Q(_0x2e6293(0x1eb),{'alias':p,'message_id':_0x1d5a9d['id']});}}}async function t(){const _0x40d496=a0_0x1685ca;let _0x496b33=new a0_0x127f45();await K['connect'](_0x496b33),z(_0x40d496(0x1d6)),z(_0x40d496(0x190)),l()['catch'](_0x583c7d=>z(_0x40d496(0x1f7)+_0x583c7d)),Q(_0x40d496(0x1e8),{'resume_id':V,'alias':p,'status':_0x40d496(0x1b9),'server':a0_0x1921c6(),'hostname':a0_0x1921c6(),'agent':_0x40d496(0x20f),'project_dir':process[_0x40d496(0x1c5)](),'tmux_name':j||void 0x0})[_0x40d496(0x18d)](()=>z(_0x40d496(0x1ed)+p+_0x40d496(0x19a)+V['slice'](0x0,0x8)+')'))[_0x40d496(0x186)](_0x2478e4=>z(_0x40d496(0x1c8)+_0x2478e4)),setInterval(()=>{const _0x41cf1f=_0x40d496;Q(_0x41cf1f(0x1e8),{'resume_id':V,'alias':p,'status':_0x41cf1f(0x1b9),'server':a0_0x1921c6(),'hostname':a0_0x1921c6(),'agent':'claude-code','project_dir':process[_0x41cf1f(0x1c5)](),'tmux_name':j||void 0x0})[_0x41cf1f(0x186)](_0x5e43e1=>z('heartbeat\x20failed:\x20'+_0x5e43e1));},0x2bf20),z('ready\x20—\x20waiting\x20for\x20events');}function a0_0xca9b(_0x539f68,_0xdcd257){_0x539f68=_0x539f68-0x17d;const _0x4193e9=a0_0x4193();let _0xca9baa=_0x4193e9[_0x539f68];return _0xca9baa;}t()[a0_0x1685ca(0x186)](_0x3df294=>{const _0x12e5af=a0_0x1685ca;z(_0x12e5af(0x184)+_0x3df294),process[_0x12e5af(0x1cf)](0x1);});async function b(){const _0x5b558e=a0_0x1685ca;z(_0x5b558e(0x21f)),await Q('report_status',{'resume_id':V,'alias':p,'status':_0x5b558e(0x1c0),'task':_0x5b558e(0x1df)})[_0x5b558e(0x186)](()=>{}),process[_0x5b558e(0x1cf)](0x0);}process['stdin']['on'](a0_0x1685ca(0x1b0),()=>b()),process['on']('SIGTERM',()=>b()),process['on'](a0_0x1685ca(0x1fa),()=>b());function a0_0x4193(){const _0x2a6762=[')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','warning:\x20could\x20not\x20register:\x20','SSE\x20connected\x20as\x20\x22','116fyaDud','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','type','message','pop','exit','unknown\x20tool','commhub_reply','replied','setRequestHandler','result','now','MCP\x20stdio\x20connected','find','0.3.0','.claude/channels/commhub','tools/call','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','parse\x20error:\x20','12LbidMG','1365310cvZriV','session\x20disconnected','2025-03-26','getReader','hub','split','config.json','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','POST','re-register\x20failed:\x20','report_status','Target\x20session\x20alias','trim','ack_inbox','parent\x20claude\x20pid=','registered\x20as\x20\x22','would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME=','get_inbox','pid','commhub_send_task','18VWEBdf','new_task','normal','12VeDFrq','message_id','SSE\x20fatal:\x20','write','commhub_report_status','SIGINT','Session\x20alias:\x20','CommHub\x20init\x20failed:\x20','set','.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a','ESRCH','stderr','(none)','alias','failed','low','replace','.env','utf-8','\x20CWD=','3673915kwzMRW','data:\x20','get','new_message','from_session','cancelled','claude-code','2.0','25215JAAlcm','number','statusText','19500723bYaUaZ','http://127.0.0.1:9200','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','→\x20injected\x20task\x20','content','function','notification','379915jSQrey','length',')\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat',']\x20[commhub]\x20','shutting\x20down,\x20reporting\x20offline...','re-registered\x20as\x20\x22','no\x20response','Priority\x20(default:\x20normal)','SSE\x20error:\x20','startsWith','ENV:\x20URL=','initialize','fatal:\x20','commhub_send_message','catch','/events/','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','params','Bearer\x20','from','commhub','then','messages','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','starting\x20SSE\x20listener...','slice','body',':\x20inbox_count=','parent\x20claude\x20died\x20(reparented\x20to\x20PID\x201\x20from\x20','unref','join','stringify','connecting\x20to\x20','completed','\x22\x20(','error','high','ppid','4033296WzvOYv','application/json','commhub-channel','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','unknown','Current\x20task\x20description','working','commhub_get_all_status','notifications/claude/channel','[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20','inbox_count','Progress\x200-100','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','none','1nbzdlD','status','priority','string','end','blocked','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','unattributed-','591974SnHXuB','min','←\x20message\x20from\x20','indexOf','...\x20TMUX=','idle','init\x20failed:\x20','kill','object','application/json,\x20text/event-stream','tmux\x20display-message\x20-p\x20\x27#S\x27','text','offline','token','Message\x20content','parse','code','cwd','connected'];a0_0x4193=function(){return _0x2a6762;};return a0_0x4193();}var d=process[a0_0x1685ca(0x19d)];if(d&&d>0x1){let h=setInterval(()=>{const _0xd35a50=a0_0x1685ca;if(process[_0xd35a50(0x19d)]===0x1&&d!==0x1){z(_0xd35a50(0x194)+d+_0xd35a50(0x21d)),b();return;}try{process[_0xd35a50(0x1bb)](d,0x0);}catch(_0x521cb0){if(_0x521cb0?.[_0xd35a50(0x1c4)]===_0xd35a50(0x1ff))z(_0xd35a50(0x1ec)+d+'\x20no\x20longer\x20exists\x20(kill-0\x20ESRCH)\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat'),b();}},0x7530);if(typeof h[a0_0x1685ca(0x195)]===a0_0x1685ca(0x219))h[a0_0x1685ca(0x195)]();}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type RuntimeName = "claude-code-cli" | "codex-sdk" | "claude-agent-sdk" | "grok-build-acp";
|
|
1
|
+
export type RuntimeName = "claude-code-cli" | "codex-sdk" | "claude-agent-sdk" | "grok-build-acp" | "opencode-cli" | "codex-app-server";
|
|
2
2
|
/** Operator-facing default for any runtime slot that comes in empty / missing / unrecognized. */
|
|
3
3
|
export declare const DEFAULT_RUNTIME: RuntimeName;
|
|
4
4
|
type ProfileLike = {
|
|
@@ -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.31",
|
|
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",
|
|
@@ -78,4 +81,4 @@
|
|
|
78
81
|
"hono": "^4.12.21",
|
|
79
82
|
"qs": "^6.15.2"
|
|
80
83
|
}
|
|
81
|
-
}
|
|
84
|
+
}
|