Sign In

@sleep2agi/agent-network

Package Overview
Dependencies
Maintainers
1
Versions
309
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sleep2agi/agent-network - npm Package Compare versions

Comparing version
2.3.0-preview.35
to
2.3.0-preview.36
+339
dist/src/copresence-identity.d.ts
export interface SessionInfo {
tmux: string;
pid: number;
pgid: number;
starttime_jiffies: number;
}
export interface CopresenceMarker {
marker: string;
boot_id: string;
started_at_epoch_ms: number;
owner_uid: number;
sessions: {
appsrv?: SessionInfo;
bridge?: SessionInfo;
tui?: SessionInfo;
};
}
export type RefuseCause = "MISSING" | "SYMLINK" | "NOT_REGULAR" | "WRONG_MODE" | "OWNER_MISMATCH" | "PARSE_ERROR" | "SCHEMA_INVALID" | "STALE_BOOT_ID" | "PLATFORM_UNSUPPORTED";
export type ReadMarkerResult = {
kind: "ok";
marker: CopresenceMarker;
} | {
kind: "refuse";
cause: RefuseCause;
detail: string;
};
export interface ProcStat {
pgid: number;
starttime_jiffies: number;
ppid: number;
}
/**
* Injectable primitive for /proc access. Real impl reads the filesystem;
* unit tests inject a mock so /proc-based logic is deterministically testable.
*
* Contract:
* - listAllPids: read /proc directory and return numeric-name entries.
* Throws on unrecoverable errors (permission denied on /proc itself).
* - readEnviron: read /proc/<pid>/environ as a raw string. Returns null
* if the pid has vanished (ENOENT) — that's a normal race, not a failure.
* Throws for permission errors etc.
* - readStat: read /proc/<pid>/stat and extract (pgid, starttime, ppid).
* Returns null on ENOENT (pid gone). Throws on other errors.
*/
export interface ProcessEnumerator {
listAllPids(): number[];
readEnviron(pid: number): string | null;
readStat(pid: number): ProcStat | null;
/**
* REAL uid of the process itself (`Uid:` line of /proc/<pid>/status,
* field 0). Used by the environ-EACCES discriminator to tell
* "other-user process (expected EACCES)" from "our own process we could
* not inspect (must be accounted for)".
*
* MUST NOT be implemented as `statSync('/proc/<pid>/environ').uid`.
* A process that called prctl(PR_SET_DUMPABLE, 0) keeps its real uid but
* its /proc/<pid>/{environ,mem,...} nodes flip to root:root 0400 (see
* proc(5) / kernel `task_dump_owner`). Deriving ownership from the
* environ inode therefore reports uid 0 for our OWN non-dumpable
* children, which made them invisible to the scan: not in `hits`, not in
* the unreadable list, so teardown reported success and deleted the
* marker while the orphan lived on (Defect A).
*
* Returns null if the pid is gone (ENOENT) or if even /proc/<pid>/status
* is blocked (hidepid / LSM) — in that case the process cannot be ours
* to reason about and is skipped.
*/
readOwnerUid(pid: number): number | null;
/**
* Single-character process state from /proc/<pid>/status (R/S/D/Z/T/...).
* `Z` means zombie — mm freed, environ returns EACCES even to owner, but
* the pid is going away shortly. Skip zombies during environ scan.
* Returns null if the pid is gone (ENOENT).
*/
readState(pid: number): string | null;
}
/**
* Injectable primitive for sending signals. Real impl uses process.kill;
* tests inject a mock.
*/
export interface KillPrimitive {
killPgroup(pgid: number, signal: "TERM" | "KILL"): void;
/** Returns true if ANY process in the pgroup is still alive. */
pgroupAlive(pgid: number): boolean;
}
export declare function markerFilePath(nodesDir: string, nodeId: string): string;
export declare function readBootId(): string;
/**
* Write the marker file atomically.
*
* IMPORTANT (Blocker 1 fix): the uuid parameter is the SINGLE SOURCE OF
* TRUTH. Caller is expected to inject this same uuid into every tmux
* session's ANET_NODE_MARKER env var. writeMarker does NOT generate its
* own uuid — that was the exact bug in 9f2ec282.
*/
export declare function writeMarker(nodesDir: string, nodeId: string, uuid: string, sessions: CopresenceMarker["sessions"]): CopresenceMarker;
/**
* Read the marker file with structured fail-closed refuses.
*
* Never throws for expected refuse causes. Only throws if the OS itself
* is broken (e.g. EIO). Malformed JSON, wrong types, null bodies etc.
* all return { kind: "refuse", cause, detail }.
*/
export declare function readMarker(nodesDir: string, nodeId: string): ReadMarkerResult;
export declare function removeMarker(nodesDir: string, nodeId: string): void;
export declare function realEnumerator(): ProcessEnumerator;
export declare function realKiller(): KillPrimitive;
/**
* Scan /proc for all pids whose environ contains ANET_NODE_MARKER=<uuid>.
* This is the authoritative identity source — NOT the marker file's stored
* pids, which may be stale (main died, workers survived under new pgids).
*
* Bytes format of /proc/PID/environ: NUL-separated key=value pairs.
*
* Blocker 1 fix (independent audit 92d53c8f, 2026-07-29): /proc/<pid>/environ
* is 0400 owner-only. Blindly reading it will hit EACCES on every other-user
* process (pid 1 is systemd/root → guaranteed EACCES). The naive fix — wrap
* in try/catch and continue — would silently miss marker-carrying processes
* whose environ we can't read for some other reason, recreating Defect A
* ("nothing killed but report success"). Right fix:
*
* 1. Try readEnviron.
* 2. On EACCES, discriminate via readOwnerUid + readState:
* - Owner uid != ours → EXPECTED skip (can't be one of our procs).
* - Own uid, state = Z → EXPECTED skip (zombie, mm freed).
* - Own uid, not zombie → FAIL-CLOSED (unexplained EACCES on our own
* live process is a real problem, must throw).
*/
export interface ScanResult {
/** Pids whose environ we successfully read and matched the marker uuid. */
hits: number[];
/**
* Own-uid, live, environ-unreadable pids that are PLAUSIBLY PART OF THE
* COPRESENCE TREE (invariant 11 scope test). These might be marker-
* carrying without us being able to prove it, so the reap flow REFUSES
* marker removal while this list is non-empty — defense against Defect A
* (silently missing a marker-carrying process, then deleting the marker
* as if teardown had succeeded).
*/
unreadableOwnUid: number[];
/**
* Own-uid, live, environ-unreadable pids that failed the scope test:
* their pgid belongs to no marker-carrying group and their ppid chain
* reaches no marker carrier / validated marker-file session pid.
*
* INFORMATIONAL ONLY — never fail-closed. A machine routinely has such
* processes (a same-uid process whose primary GID differs from ours fails
* the kernel's __ptrace_may_access gid check and EACCESes on environ even
* though its real uid matches). v2 lumped these into unreadableOwnUid,
* which made reapMarkerGroups structurally unable to return success on
* any such host.
*
* KNOWN RESIDUAL GAP (stated rather than papered over): a marker-carrying
* process that is BOTH non-dumpable (environ unreadable) AND fully
* detached (setsid'd into its own pgroup with ppid=1, no live recorded
* session pid above it) lands here and is therefore not reaped and does
* not block marker removal. Nothing in /proc exposes the environment of a
* non-dumpable task to a non-root reader, so no scope widening can
* recover it — only running teardown as root could. Widening scope to
* "every same-uid unreadable process" is NOT an acceptable trade: that is
* exactly the v2 behaviour that made teardown never succeed. The
* realistic copresence shape (child of a recorded pane pid, or sharing a
* marker carrier's pgroup) IS covered — see the real-/proc test.
*/
unreadableOutOfScope: number[];
}
/**
* Marker-file session records used to anchor the invariant-11 scope test.
* Each entry must be re-validated (pid alive AND same starttime) before it
* is trusted — see validateAnchors.
*/
export interface ScanAnchors {
sessions?: Array<{
pid: number;
starttime_jiffies: number;
}>;
}
export declare function anchorsFromMarker(marker: CopresenceMarker): ScanAnchors;
/**
* Invariant 11 scope test: is `pid` plausibly part of the copresence tree?
*
* True when the pid IS an anchor, when its pgid belongs to a marker-carrying
* group (or a validated anchor's group), or when walking its ppid chain
* reaches an anchor / marker carrier / a pid inside a relevant pgroup.
*
* Everything else is out of scope and must not participate in a fail-closed
* decision, no matter how unreadable it is.
*/
export declare function isInCopresenceScope(enumer: ProcessEnumerator, pid: number, relevantPids: Set<number>, relevantPgids: Set<number>): boolean;
export declare function scanEnvironForMarker(enumer: ProcessEnumerator, markerUuid: string): number[];
export declare function scanEnvironForMarkerFull(enumer: ProcessEnumerator, markerUuid: string, anchors?: ScanAnchors): ScanResult;
export declare function groupPidsByPgid(enumer: ProcessEnumerator, pids: number[]): Map<number, number[]>;
export type HomogeneityResult = {
ok: true;
members: number[];
} | {
ok: false;
cause: "FOREIGN_MEMBER" | "ENUM_ERROR" | "EMPTY_GROUP";
foreignPids: number[];
unreadablePids: number[];
detail: string;
};
/**
* Verify that EVERY live member of `pgid` carries the marker.
*
* Blocker 2 fix: enumeration errors surface as ENUM_ERROR (fail-closed),
* never as an empty-list judged "safe". Any unreadable member also
* fails-closed. Empty group (no live members at all) also refuses — killing
* an empty pgroup can't be right and empty-list judged "ok" recreates the
* exact defect shape (independent audit 92d53c8f finding #6).
*
* Blocker 2 second half (zombie): a zombie same-uid process's environ
* returns EACCES even to owner (mm freed), but stat still exists with
* original pgid. Without discrimination, the zombie would be treated as
* "unreadable member" → ENUM_ERROR → entire group SKIPPED. Since re-verify
* happens post-SIGTERM (when zombies are most numerous), teardown would
* never escalate. Fix: apply the same owner-uid + state=Z discriminator as
* scanEnvironForMarker.
*
* Algorithm:
* 1. Enumerate all pids on the system.
* 2. Filter to pids whose /proc/PID/stat pgid == target pgid.
* 3. For each such pid, check its environ with EACCES discrimination:
* - Other-user EACCES → skip (can't be ours anyway).
* - Own-uid zombie → skip (expected, dying).
* - Own-uid live EACCES → truly unreadable → fail-closed.
* - Missing marker → foreign member → fail-closed.
*/
export declare function verifyGroupHomogeneity(enumer: ProcessEnumerator, pgid: number, markerUuid: string): HomogeneityResult;
/**
* Walk the caller's ancestry (self → PPID → grandparent → ...) and check
* whether any ancestor carries the target marker. If yes → caller is
* running inside the copresence tree we're about to kill, and would take
* itself down.
*/
export declare function callerCarriesMarker(enumer: ProcessEnumerator, markerUuid: string): {
self: boolean;
ancestorPid?: number;
};
export type ReapResult = {
kind: "success";
killedPgids: number[];
residualPids: number[];
unreadableOwnUid?: number[];
} | {
kind: "failed";
killedPgids: number[];
residualPids: number[];
skippedGroups: Array<{
pgid: number;
reason: string;
}>;
detail: string;
unreadableOwnUid?: number[];
};
export interface ReapOptions {
graceMs: number;
logger: (msg: string) => void;
/**
* Sleep primitive (grace period). Real code uses setTimeout; tests inject
* a fast/deterministic sleep so grace paths are actually covered. Prior
* impl was a busy-wait `while (Date.now() < end) {}` — audit 92d53c8f
* finding #3 flagged that as pinning one CPU core for graceMs and blocking
* the event loop; test coverage missed it because tests passed graceMs=0.
*/
sleep?: (ms: number) => Promise<void>;
/**
* Invariant-11 scope anchors, normally `anchorsFromMarker(marker)`.
*
* Without them the only anchors are the marker carriers the scan itself
* found, so a marker-carrying process we cannot READ (non-dumpable) but
* whose parent IS a recorded session pid would be judged out of scope and
* silently dropped. Passing the marker's recorded session pids closes that
* hole; each one is re-validated (alive + same starttime) before it can
* widen scope, so a stale/recycled pid cannot.
*/
anchors?: ScanAnchors;
}
/**
* Full reap flow with TOCTOU re-verification.
*
* Sequence:
* 1. Environ scan for marker → get all live pids carrying it.
* 2. Group by current PGID.
* 3. For each group: verify homogeneity. Skip on foreign/unreadable.
* 4. For each verified group: send SIGTERM to pgroup.
* 5. Wait grace.
* 6. Re-verify each group (marker still there, no new foreign) before SIGKILL.
* 7. Send SIGKILL to any group still alive.
* 8. Post-rescan: if any marker-carrying pid alive → preserve marker.
*/
export declare function reapMarkerGroups(enumer: ProcessEnumerator, killer: KillPrimitive, markerUuid: string, opts: ReapOptions): Promise<ReapResult>;
export interface PrepareStartDeps {
/** Usually () => readMarker(nodesDir, nodeId). */
readMarker(): ReadMarkerResult;
/** Usually (uuid, anchors) => reapMarkerGroups(realEnumerator(), realKiller(), uuid, {...anchors}). */
reap(uuid: string, anchors: ScanAnchors): Promise<ReapResult>;
/** Usually () => removeMarker(nodesDir, nodeId). */
removeMarker(): void;
/** Usually (uuid, sessions) => writeMarker(nodesDir, nodeId, uuid, sessions). */
writeMarker(uuid: string, sessions: CopresenceMarker["sessions"]): void;
logger(msg: string): void;
}
export type PrepareStartResult = {
kind: "ok";
reclaimedUuid?: string;
} | {
kind: "blocked";
cause: "STALE_TREE_ALIVE" | "UNUSABLE_MARKER";
detail: string;
remedy: string;
};
/**
* Everything that must happen BEFORE the first `tmux new-session` of a
* copresence start. Extracted out of cli.ts so both blockers below are
* actually reachable by tests — the audit's point that the two fatal
* defects of the previous rounds both lived in an untested cli.ts seam.
*
* Blocker 5 — marker-before-tmux ordering.
* v2 wrote the marker only after the app-server had bound its port, i.e.
* after a 25s wait and after several `process.exit(1)` paths. A start that
* died in that window left a live, marker-carrying tmux session behind
* with NO marker file on disk: the exact unreclaimable-ghost this feature
* exists to prevent. The marker is now written here, before any session is
* created, with an empty `sessions` object — reap identity has always been
* the environ uuid, never the recorded pids, so an empty sessions object
* loses nothing but observability hints (which the start path fills in
* later, best-effort).
*
* Blocker 6 — never overwrite a preserved marker.
* A failed stop deliberately PRESERVES the marker so the next stop can
* retry idempotently. v2's start then overwrote it with a fresh uuid while
* only killing tmux sessions BY NAME, so the still-running subprocesses of
* the previous instance became permanently unreclaimable: their uuid was
* gone from disk forever. Now the old identity is reaped FIRST; if that
* reap does not fully succeed we refuse to start rather than destroy the
* only handle on those processes.
*/
export declare function prepareIdentityForStart(newUuid: string, deps: PrepareStartDeps): Promise<PrepareStartResult>;
/** Lowest tmux version whose `new-session` understands `-e KEY=VALUE`. */
export declare const MIN_TMUX_MAJOR = 3;
export declare const MIN_TMUX_MINOR = 2;
export interface TmuxVersion {
major: number;
minor: number;
/** Trailing letter suffix, e.g. the "a" of "3.0a". Not used for ordering. */
suffix: string;
raw: string;
}
/**
* Parse the output of `tmux -V`, e.g.:
* "tmux 3.2a" → { major: 3, minor: 2, suffix: "a" }
* "tmux 3.0a" → { major: 3, minor: 0, suffix: "a" }
* "tmux 3.4" → { major: 3, minor: 4, suffix: "" }
* "tmux next-3.4" → { major: 3, minor: 4, suffix: "" }
* "tmux 2.9" → { major: 2, minor: 9, suffix: "" }
*
* Returns null when no version can be extracted (unknown build, empty
* output, `tmux master` with no numbers). Callers must treat null as
* "unknown" and NOT as "too old" — refusing to start on an unparseable
* version string would break hosts whose tmux is perfectly capable.
*/
export declare function parseTmuxVersion(raw: string): TmuxVersion | null;
/**
* True when this version's `new-session` supports `-e KEY=VALUE` (>= 3.2).
* Note 3.0a / 3.1c sort BELOW 3.2 — the letter suffix is a patch marker,
* never a minor bump, so it must not participate in the comparison.
*/
export declare function tmuxSupportsSessionEnv(v: TmuxVersion): boolean;
export type TmuxCapabilityVerdict = {
kind: "ok";
version: TmuxVersion;
} | {
kind: "unknown";
detail: string;
} | {
kind: "too_old";
version: TmuxVersion;
detail: string;
remedy: string[];
} | {
kind: "missing";
detail: string;
remedy: string[];
};
/**
* Pure decision function — `runVersionCmd` returns `tmux -V` output, or
* throws if tmux is absent/unrunnable. Split from the printing/exiting
* wrapper so tests drive every branch without a tmux binary.
*/
export declare function checkTmuxCapability(runVersionCmd: () => string): TmuxCapabilityVerdict;
/**
* cli.ts wrapper: run the check, print an actionable message, and exit
* non-zero when tmux cannot carry the marker. `unknown` is deliberately
* permissive — we log and continue.
*/
export declare function assertTmuxSupportsSessionEnv(runVersionCmd: () => string, log: (msg: string) => void, fail: (msg: string) => never): void;
+1
-1

@@ -1,1 +0,1 @@

const a0_0x4813e6=a0_0x55db;(function(_0x11f243,_0x2ad3fb){const _0x1b0148=a0_0x55db,_0x149257=_0x11f243();while(!![]){try{const _0x2c092c=-parseInt(_0x1b0148(0x1a8))/0x1+-parseInt(_0x1b0148(0x198))/0x2*(-parseInt(_0x1b0148(0x1b5))/0x3)+-parseInt(_0x1b0148(0x185))/0x4*(-parseInt(_0x1b0148(0x1bb))/0x5)+parseInt(_0x1b0148(0x18e))/0x6*(-parseInt(_0x1b0148(0x166))/0x7)+-parseInt(_0x1b0148(0x197))/0x8*(-parseInt(_0x1b0148(0x172))/0x9)+parseInt(_0x1b0148(0x180))/0xa+parseInt(_0x1b0148(0x1b4))/0xb*(-parseInt(_0x1b0148(0x1a6))/0xc);if(_0x2c092c===_0x2ad3fb)break;else _0x149257['push'](_0x149257['shift']());}catch(_0x1328a1){_0x149257['push'](_0x149257['shift']());}}}(a0_0x38dc,0xb4e79));import{EventEmitter as a0_0x50f097}from'events';function a0_0x55db(_0x5ce4ad,_0x527a66){_0x5ce4ad=_0x5ce4ad-0x166;const _0x38dcef=a0_0x38dc();let _0x55db6c=_0x38dcef[_0x5ce4ad];return _0x55db6c;}import{hostname as a0_0x42e141}from'os';class T extends a0_0x50f097{[a0_0x4813e6(0x1ac)];[a0_0x4813e6(0x199)];[a0_0x4813e6(0x1aa)];[a0_0x4813e6(0x168)];[a0_0x4813e6(0x16f)];[a0_0x4813e6(0x179)];[a0_0x4813e6(0x1a1)];[a0_0x4813e6(0x16e)];[a0_0x4813e6(0x1b9)];[a0_0x4813e6(0x196)]=!0x1;constructor(_0x3dd536){const _0x593924=a0_0x4813e6;super();if(this[_0x593924(0x1ac)]=_0x3dd536[_0x593924(0x1ac)][_0x593924(0x186)](/\/$/,''),this[_0x593924(0x199)]=_0x3dd536[_0x593924(0x199)],this[_0x593924(0x1aa)]=_0x3dd536[_0x593924(0x1aa)],this[_0x593924(0x168)]=_0x3dd536[_0x593924(0x168)]||_0x593924(0x16a),this['resumeId']=_0x593924(0x16b)+_0x3dd536[_0x593924(0x199)]+'-'+Date[_0x593924(0x18a)]()['toString'](0x24),this[_0x593924(0x179)]=_0x3dd536['heartbeatInterval']??0x2bf20,this[_0x593924(0x1a1)]=_0x3dd536['reconnectDelay']??0xbb8,_0x3dd536[_0x593924(0x1bd)]!==!0x1)this[_0x593924(0x1be)]();}[a0_0x4813e6(0x19e)](_0x5bd9c3){const _0x16cb50=a0_0x4813e6;console[_0x16cb50(0x19e)]('['+new Date()[_0x16cb50(0x1a7)]()[_0x16cb50(0x171)](0x0,0x8)+_0x16cb50(0x17c)+this[_0x16cb50(0x199)]+']\x20'+_0x5bd9c3);}async[a0_0x4813e6(0x18b)](_0x344c4a,_0x139960){const _0x300917=a0_0x4813e6;let _0x22a8b9={'Content-Type':_0x300917(0x17a),'Accept':_0x300917(0x175)};if(this['token'])_0x22a8b9[_0x300917(0x1a5)]='Bearer\x20'+this[_0x300917(0x1aa)];let _0x269648=await(await fetch(this[_0x300917(0x1ac)]+'/mcp',{'method':_0x300917(0x19b),'headers':_0x22a8b9,'body':JSON['stringify']({'jsonrpc':_0x300917(0x195),'id':Date[_0x300917(0x18a)](),'method':_0x300917(0x1ba),'params':{'name':_0x344c4a,'arguments':_0x139960}})}))[_0x300917(0x1a0)](),_0x51ac78=_0x269648['match'](/data: (.+)/),_0x4e8d70=_0x51ac78?JSON[_0x300917(0x16c)](_0x51ac78[0x1]):JSON[_0x300917(0x16c)](_0x269648),_0x32c39f=_0x4e8d70?.[_0x300917(0x183)]?.[_0x300917(0x1b7)]?.[0x0]?.['text'];return _0x32c39f?JSON[_0x300917(0x16c)](_0x32c39f):_0x4e8d70;}async[a0_0x4813e6(0x1be)](){const _0x107f4e=a0_0x4813e6;if(this[_0x107f4e(0x196)])return;this[_0x107f4e(0x196)]=!0x0,await this[_0x107f4e(0x17d)](_0x107f4e(0x193)),this['log'](_0x107f4e(0x19d)),this[_0x107f4e(0x16e)]=setInterval(()=>{const _0x9dd776=_0x107f4e;this[_0x9dd776(0x17d)]('idle')[_0x9dd776(0x1ae)](_0x33ff0d=>this[_0x9dd776(0x19e)](_0x9dd776(0x19a)+_0x33ff0d['message']));},this[_0x107f4e(0x179)]),this['connectSSE']();}async[a0_0x4813e6(0x1af)](){const _0x2ba720=a0_0x4813e6;if(this['running']=!0x1,this[_0x2ba720(0x1b9)]?.[_0x2ba720(0x17f)](),this[_0x2ba720(0x16e)])clearInterval(this[_0x2ba720(0x16e)]);await this[_0x2ba720(0x17d)](_0x2ba720(0x174))[_0x2ba720(0x1ae)](()=>{}),this['log'](_0x2ba720(0x1ab));}async[a0_0x4813e6(0x181)](_0x4512e0,_0x3eeabb,_0x59cc4e=a0_0x4813e6(0x167)){const _0x3139c2=a0_0x4813e6;return this[_0x3139c2(0x18b)](_0x3139c2(0x1b1),{'alias':_0x4512e0,'task':_0x3eeabb,'priority':_0x59cc4e,'from_session':this[_0x3139c2(0x199)]});}async[a0_0x4813e6(0x1b0)](_0x5bbb29,_0x3c9638){const _0x2ae2c9=a0_0x4813e6;return this[_0x2ae2c9(0x18b)]('send_message',{'alias':_0x5bbb29,'message':_0x3c9638,'from_session':this['alias']});}async[a0_0x4813e6(0x177)](_0x1ad994,_0x1c68e2,_0x254e6e=a0_0x4813e6(0x188)){const _0xef0205=a0_0x4813e6;return this[_0xef0205(0x18b)]('send_reply',{'in_reply_to':_0x1ad994,'text':_0x1c68e2,'status':_0x254e6e});}async[a0_0x4813e6(0x17d)](_0x362cb6,_0x58be86){const _0x271517=a0_0x4813e6;return this[_0x271517(0x18b)](_0x271517(0x1bc),{'resume_id':this[_0x271517(0x16f)],'alias':this[_0x271517(0x199)],'status':_0x362cb6,'server':a0_0x42e141(),'hostname':a0_0x42e141(),'agent':this[_0x271517(0x168)],'project_dir':process[_0x271517(0x176)](),..._0x58be86});}async['getAllStatus'](){return this['call']('get_all_status',{});}async['broadcast'](_0x24e194,_0x10d463){const _0x55c825=a0_0x4813e6;return this[_0x55c825(0x18b)](_0x55c825(0x187),{'message':_0x24e194,'filter_server':_0x10d463?.[_0x55c825(0x1b2)],'filter_status':_0x10d463?.['status']});}async[a0_0x4813e6(0x1a2)](){const _0x339a47=a0_0x4813e6;let _0x426cc3=encodeURIComponent(this['alias']),_0x191432=this[_0x339a47(0x1ac)]+_0x339a47(0x18c)+_0x426cc3,_0x4142e6=this[_0x339a47(0x1a1)];while(this[_0x339a47(0x196)]){try{this[_0x339a47(0x1b9)]=new AbortController();let _0x28e6f8={'Accept':_0x339a47(0x1b3)};if(this[_0x339a47(0x1aa)])_0x28e6f8[_0x339a47(0x1a5)]=_0x339a47(0x173)+this['token'];let _0x191d7f=await fetch(_0x191432,{'headers':_0x28e6f8,'signal':this[_0x339a47(0x1b9)][_0x339a47(0x169)]});if(!_0x191d7f['ok']||!_0x191d7f[_0x339a47(0x18d)]){this[_0x339a47(0x19e)](_0x339a47(0x192)+_0x191d7f[_0x339a47(0x17d)]),await this[_0x339a47(0x190)](_0x4142e6),_0x4142e6=Math[_0x339a47(0x184)](_0x4142e6*1.5,0xea60);continue;}_0x4142e6=this[_0x339a47(0x1a1)];let _0x2326ee=_0x191d7f[_0x339a47(0x18d)]['getReader'](),_0x3706ab=new TextDecoder(),_0xbf2c31='';while(this[_0x339a47(0x196)]){let {done:_0x21b668,value:_0xabe6bb}=await _0x2326ee[_0x339a47(0x16d)]();if(_0x21b668)break;_0xbf2c31+=_0x3706ab[_0x339a47(0x191)](_0xabe6bb,{'stream':!0x0});let _0x3bd60f=_0xbf2c31[_0x339a47(0x17e)]('\x0a');_0xbf2c31=_0x3bd60f[_0x339a47(0x178)]()||'';for(let _0x75ebc7 of _0x3bd60f){if(!_0x75ebc7[_0x339a47(0x182)](_0x339a47(0x18f)))continue;try{let _0x55fbd6=JSON[_0x339a47(0x16c)](_0x75ebc7[_0x339a47(0x171)](0x6));if(_0x55fbd6[_0x339a47(0x1b6)]===_0x339a47(0x17b)){this[_0x339a47(0x19e)](_0x339a47(0x194)),this[_0x339a47(0x1a9)](_0x339a47(0x17b));continue;}if(_0x55fbd6[_0x339a47(0x1b6)]===_0x339a47(0x19c)||_0x55fbd6[_0x339a47(0x1b6)]===_0x339a47(0x1b8)||_0x55fbd6[_0x339a47(0x1b6)]===_0x339a47(0x187))await this['processInbox']();}catch{}}}}catch(_0x111afa){if(_0x111afa[_0x339a47(0x19f)]===_0x339a47(0x1a4))break;this[_0x339a47(0x1a9)]('error',_0x111afa),this['log']('SSE\x20error:\x20'+_0x111afa[_0x339a47(0x1b0)]);}if(this['running'])this[_0x339a47(0x1a9)](_0x339a47(0x1ab)),this[_0x339a47(0x19e)]('SSE\x20reconnecting\x20in\x20'+_0x4142e6/0x3e8+_0x339a47(0x1ad)),await this[_0x339a47(0x190)](_0x4142e6),_0x4142e6=Math[_0x339a47(0x184)](_0x4142e6*1.5,0xea60);}}async['processInbox'](){const _0x477445=a0_0x4813e6;try{let _0x51a4a6=(await this[_0x477445(0x18b)]('get_inbox',{'alias':this[_0x477445(0x199)],'limit':0xa}))?.['messages']||[];for(let _0x2edada of _0x51a4a6)await this[_0x477445(0x18b)](_0x477445(0x170),{'alias':this['alias'],'message_id':_0x2edada['id']}),this['log']('←\x20'+_0x2edada[_0x477445(0x1a3)]+':\x20'+_0x2edada['content'][_0x477445(0x171)](0x0,0x3c)),this[_0x477445(0x1a9)]('task',_0x2edada),this[_0x477445(0x1a9)](_0x477445(0x1b0),_0x2edada);}catch(_0x3058eb){this['log'](_0x477445(0x189)+_0x3058eb[_0x477445(0x1b0)]);}}[a0_0x4813e6(0x190)](_0x495293){return new Promise(_0x3eb579=>setTimeout(_0x3eb579,_0x495293));}}var $=T;export{$ as default,T as CommHub};function a0_0x38dc(){const _0xac7f80=['113572CPYRxj','replace','broadcast','completed','inbox\x20error:\x20','now','call','/events/','body','252DMEZxA','data:\x20','sleep','decode','SSE\x20failed:\x20','idle','SSE\x20connected','2.0','running','464dQkQIJ','2ohjRwe','alias','heartbeat\x20failed:\x20','POST','new_task','registered','log','name','text','reconnectDelay','connectSSE','from_session','AbortError','Authorization','1752kxYMdU','toTimeString','94409zzGhAi','emit','token','disconnected','url','s...','catch','disconnect','message','send_task','server','text/event-stream','125411hvfIEJ','4239231SvWDsO','type','content','new_message','sseAbort','tools/call','55qUCFYS','report_status','autoConnect','connect','158683LarlfJ','normal','agent','signal','sdk','sdk-','parse','read','heartbeatTimer','resumeId','ack_inbox','slice','195795gJUKpE','Bearer\x20','offline','application/json,\x20text/event-stream','cwd','reply','pop','heartbeatInterval','application/json','connected',']\x20[commhub:','status','split','abort','4648480qtZBQV','send','startsWith','result','min'];a0_0x38dc=function(){return _0xac7f80;};return a0_0x38dc();}
function a0_0x855f(_0x39248a,_0x4f8b92){_0x39248a=_0x39248a-0x17e;const _0x1fdedc=a0_0x1fde();let _0x855f3a=_0x1fdedc[_0x39248a];return _0x855f3a;}const a0_0x4d231b=a0_0x855f;function a0_0x1fde(){const _0x6156d4=['1284230tDpjGQ','send','4054gZjmun','new_message','token','12sHOfGT','replace','application/json,\x20text/event-stream','name','content','510fdmlNL','completed','signal','startsWith','send_task','sdk-','url','decode','connected','alias','cwd','idle','SSE\x20failed:\x20','SSE\x20error:\x20','reconnectDelay','tools/call','report_status','203291GZjLqV','1420065tZtERR','body','POST','s...','292812gmjImy','sseAbort','emit','connect',']\x20[commhub:','Bearer\x20','180AKOQIx','Authorization','parse','normal','error','327072wpmrft','reply','sleep','status','text','toString','text/event-stream','heartbeatTimer','min','ack_inbox','/events/','387qyGICo','autoConnect','log','message','read','send_message','disconnect','pop','broadcast','agent','catch','abort','running','18GuMYSJ','type','connectSSE','getReader','data:\x20','server','get_inbox','registered','offline','slice','new_task','455xtKROn','call','disconnected','heartbeatInterval','split','messages','sdk','task','match','resumeId','processInbox','1860873HDbrtt','/mcp'];a0_0x1fde=function(){return _0x6156d4;};return a0_0x1fde();}(function(_0x69f157,_0x34d6a8){const _0x16a939=a0_0x855f,_0x43f872=_0x69f157();while(!![]){try{const _0x163c93=parseInt(_0x16a939(0x18e))/0x1*(parseInt(_0x16a939(0x1b5))/0x2)+parseInt(_0x16a939(0x1cf))/0x3+parseInt(_0x16a939(0x1b8))/0x4*(parseInt(_0x16a939(0x1b3))/0x5)+-parseInt(_0x16a939(0x19b))/0x6*(parseInt(_0x16a939(0x1b1))/0x7)+parseInt(_0x16a939(0x183))/0x8*(-parseInt(_0x16a939(0x17e))/0x9)+parseInt(_0x16a939(0x1bd))/0xa*(parseInt(_0x16a939(0x1ce))/0xb)+-parseInt(_0x16a939(0x1d3))/0xc*(parseInt(_0x16a939(0x1a6))/0xd);if(_0x163c93===_0x34d6a8)break;else _0x43f872['push'](_0x43f872['shift']());}catch(_0xff4c24){_0x43f872['push'](_0x43f872['shift']());}}}(a0_0x1fde,0x7a789));import{EventEmitter as a0_0x124210}from'events';import{hostname as a0_0x4fa072}from'os';class T extends a0_0x124210{[a0_0x4d231b(0x1c3)];[a0_0x4d231b(0x1c6)];[a0_0x4d231b(0x1b7)];[a0_0x4d231b(0x197)];[a0_0x4d231b(0x1af)];[a0_0x4d231b(0x1a9)];[a0_0x4d231b(0x1cb)];[a0_0x4d231b(0x18a)];[a0_0x4d231b(0x1d4)];[a0_0x4d231b(0x19a)]=!0x1;constructor(_0x378de7){const _0x3e0180=a0_0x4d231b;super();if(this[_0x3e0180(0x1c3)]=_0x378de7[_0x3e0180(0x1c3)][_0x3e0180(0x1b9)](/\/$/,''),this[_0x3e0180(0x1c6)]=_0x378de7[_0x3e0180(0x1c6)],this[_0x3e0180(0x1b7)]=_0x378de7[_0x3e0180(0x1b7)],this['agent']=_0x378de7[_0x3e0180(0x197)]||_0x3e0180(0x1ac),this[_0x3e0180(0x1af)]=_0x3e0180(0x1c2)+_0x378de7[_0x3e0180(0x1c6)]+'-'+Date['now']()[_0x3e0180(0x188)](0x24),this[_0x3e0180(0x1a9)]=_0x378de7[_0x3e0180(0x1a9)]??0x2bf20,this[_0x3e0180(0x1cb)]=_0x378de7['reconnectDelay']??0xbb8,_0x378de7[_0x3e0180(0x18f)]!==!0x1)this[_0x3e0180(0x1d6)]();}[a0_0x4d231b(0x190)](_0x1bcd5e){const _0x1c84f5=a0_0x4d231b;console['log']('['+new Date()['toTimeString']()[_0x1c84f5(0x1a4)](0x0,0x8)+_0x1c84f5(0x1d7)+this['alias']+']\x20'+_0x1bcd5e);}async['call'](_0x2c471f,_0x1d8c39){const _0x3f9e56=a0_0x4d231b;let _0x11ef76={'Content-Type':'application/json','Accept':_0x3f9e56(0x1ba)};if(this['token'])_0x11ef76[_0x3f9e56(0x17f)]=_0x3f9e56(0x1d8)+this[_0x3f9e56(0x1b7)];let _0x32392e=await(await fetch(this[_0x3f9e56(0x1c3)]+_0x3f9e56(0x1b2),{'method':_0x3f9e56(0x1d1),'headers':_0x11ef76,'body':JSON['stringify']({'jsonrpc':'2.0','id':Date['now'](),'method':_0x3f9e56(0x1cc),'params':{'name':_0x2c471f,'arguments':_0x1d8c39}})}))['text'](),_0x4a9b2d=_0x32392e[_0x3f9e56(0x1ae)](/data: (.+)/),_0x29381a=_0x4a9b2d?JSON['parse'](_0x4a9b2d[0x1]):JSON[_0x3f9e56(0x180)](_0x32392e),_0x40fe30=_0x29381a?.['result']?.['content']?.[0x0]?.[_0x3f9e56(0x187)];return _0x40fe30?JSON[_0x3f9e56(0x180)](_0x40fe30):_0x29381a;}async[a0_0x4d231b(0x1d6)](){const _0x490e88=a0_0x4d231b;if(this[_0x490e88(0x19a)])return;this[_0x490e88(0x19a)]=!0x0,await this[_0x490e88(0x186)](_0x490e88(0x1c8)),this[_0x490e88(0x190)](_0x490e88(0x1a2)),this['heartbeatTimer']=setInterval(()=>{const _0x323a3d=_0x490e88;this[_0x323a3d(0x186)](_0x323a3d(0x1c8))[_0x323a3d(0x198)](_0x2688bf=>this['log']('heartbeat\x20failed:\x20'+_0x2688bf[_0x323a3d(0x191)]));},this[_0x490e88(0x1a9)]),this[_0x490e88(0x19d)]();}async[a0_0x4d231b(0x194)](){const _0x48dfe2=a0_0x4d231b;if(this[_0x48dfe2(0x19a)]=!0x1,this['sseAbort']?.[_0x48dfe2(0x199)](),this['heartbeatTimer'])clearInterval(this[_0x48dfe2(0x18a)]);await this['status'](_0x48dfe2(0x1a3))['catch'](()=>{}),this[_0x48dfe2(0x190)](_0x48dfe2(0x1a8));}async[a0_0x4d231b(0x1b4)](_0x3e0fac,_0x58ed5e,_0x2a11e7=a0_0x4d231b(0x181)){const _0x32dbcc=a0_0x4d231b;return this[_0x32dbcc(0x1a7)](_0x32dbcc(0x1c1),{'alias':_0x3e0fac,'task':_0x58ed5e,'priority':_0x2a11e7,'from_session':this['alias']});}async[a0_0x4d231b(0x191)](_0x78ee4d,_0x4cd5f2){const _0x42f76f=a0_0x4d231b;return this[_0x42f76f(0x1a7)](_0x42f76f(0x193),{'alias':_0x78ee4d,'message':_0x4cd5f2,'from_session':this[_0x42f76f(0x1c6)]});}async[a0_0x4d231b(0x184)](_0x4ac7fd,_0x4eaf65,_0x4d2158=a0_0x4d231b(0x1be)){const _0x9807bc=a0_0x4d231b;return this[_0x9807bc(0x1a7)]('send_reply',{'in_reply_to':_0x4ac7fd,'text':_0x4eaf65,'status':_0x4d2158});}async[a0_0x4d231b(0x186)](_0x2a2d4a,_0x33278e){const _0x9d60a7=a0_0x4d231b;return this[_0x9d60a7(0x1a7)](_0x9d60a7(0x1cd),{'resume_id':this[_0x9d60a7(0x1af)],'alias':this[_0x9d60a7(0x1c6)],'status':_0x2a2d4a,'server':a0_0x4fa072(),'hostname':a0_0x4fa072(),'agent':this[_0x9d60a7(0x197)],'project_dir':process[_0x9d60a7(0x1c7)](),..._0x33278e});}async['getAllStatus'](){const _0x4a2eae=a0_0x4d231b;return this[_0x4a2eae(0x1a7)]('get_all_status',{});}async[a0_0x4d231b(0x196)](_0x2c4132,_0x1b73f1){const _0x1d63a4=a0_0x4d231b;return this['call'](_0x1d63a4(0x196),{'message':_0x2c4132,'filter_server':_0x1b73f1?.[_0x1d63a4(0x1a0)],'filter_status':_0x1b73f1?.[_0x1d63a4(0x186)]});}async['connectSSE'](){const _0x1cc7a5=a0_0x4d231b;let _0x4667ef=encodeURIComponent(this[_0x1cc7a5(0x1c6)]),_0x493abb=this['url']+_0x1cc7a5(0x18d)+_0x4667ef,_0xcdf218=this[_0x1cc7a5(0x1cb)];while(this[_0x1cc7a5(0x19a)]){try{this[_0x1cc7a5(0x1d4)]=new AbortController();let _0x11a55a={'Accept':_0x1cc7a5(0x189)};if(this[_0x1cc7a5(0x1b7)])_0x11a55a['Authorization']=_0x1cc7a5(0x1d8)+this['token'];let _0x21e48a=await fetch(_0x493abb,{'headers':_0x11a55a,'signal':this['sseAbort'][_0x1cc7a5(0x1bf)]});if(!_0x21e48a['ok']||!_0x21e48a['body']){this[_0x1cc7a5(0x190)](_0x1cc7a5(0x1c9)+_0x21e48a['status']),await this[_0x1cc7a5(0x185)](_0xcdf218),_0xcdf218=Math[_0x1cc7a5(0x18b)](_0xcdf218*1.5,0xea60);continue;}_0xcdf218=this['reconnectDelay'];let _0x1aa8d2=_0x21e48a[_0x1cc7a5(0x1d0)][_0x1cc7a5(0x19e)](),_0x5c90d3=new TextDecoder(),_0x3ad1a8='';while(this[_0x1cc7a5(0x19a)]){let {done:_0x21a8a7,value:_0x2f9942}=await _0x1aa8d2[_0x1cc7a5(0x192)]();if(_0x21a8a7)break;_0x3ad1a8+=_0x5c90d3[_0x1cc7a5(0x1c4)](_0x2f9942,{'stream':!0x0});let _0x564e1a=_0x3ad1a8[_0x1cc7a5(0x1aa)]('\x0a');_0x3ad1a8=_0x564e1a[_0x1cc7a5(0x195)]()||'';for(let _0x527343 of _0x564e1a){if(!_0x527343[_0x1cc7a5(0x1c0)](_0x1cc7a5(0x19f)))continue;try{let _0x15a837=JSON['parse'](_0x527343[_0x1cc7a5(0x1a4)](0x6));if(_0x15a837['type']===_0x1cc7a5(0x1c5)){this['log']('SSE\x20connected'),this[_0x1cc7a5(0x1d5)]('connected');continue;}if(_0x15a837[_0x1cc7a5(0x19c)]===_0x1cc7a5(0x1a5)||_0x15a837[_0x1cc7a5(0x19c)]===_0x1cc7a5(0x1b6)||_0x15a837[_0x1cc7a5(0x19c)]===_0x1cc7a5(0x196))await this['processInbox']();}catch{}}}}catch(_0x511634){if(_0x511634[_0x1cc7a5(0x1bb)]==='AbortError')break;this[_0x1cc7a5(0x1d5)](_0x1cc7a5(0x182),_0x511634),this['log'](_0x1cc7a5(0x1ca)+_0x511634['message']);}if(this[_0x1cc7a5(0x19a)])this[_0x1cc7a5(0x1d5)]('disconnected'),this['log']('SSE\x20reconnecting\x20in\x20'+_0xcdf218/0x3e8+_0x1cc7a5(0x1d2)),await this[_0x1cc7a5(0x185)](_0xcdf218),_0xcdf218=Math[_0x1cc7a5(0x18b)](_0xcdf218*1.5,0xea60);}}async[a0_0x4d231b(0x1b0)](){const _0x3f29f2=a0_0x4d231b;try{let _0x203ada=(await this[_0x3f29f2(0x1a7)](_0x3f29f2(0x1a1),{'alias':this[_0x3f29f2(0x1c6)],'limit':0xa}))?.[_0x3f29f2(0x1ab)]||[];for(let _0x12737f of _0x203ada)await this['call'](_0x3f29f2(0x18c),{'alias':this[_0x3f29f2(0x1c6)],'message_id':_0x12737f['id']}),this['log']('←\x20'+_0x12737f['from_session']+':\x20'+_0x12737f[_0x3f29f2(0x1bc)]['slice'](0x0,0x3c)),this['emit'](_0x3f29f2(0x1ad),_0x12737f),this[_0x3f29f2(0x1d5)](_0x3f29f2(0x191),_0x12737f);}catch(_0x2e2065){this[_0x3f29f2(0x190)]('inbox\x20error:\x20'+_0x2e2065['message']);}}[a0_0x4d231b(0x185)](_0x1b81ae){return new Promise(_0x12eb0d=>setTimeout(_0x12eb0d,_0x1b81ae));}}var $=T;export{$ as default,T as CommHub};
#!/usr/bin/env bun
const a0_0x59a7e7=a0_0x3ac4;function a0_0x3ac4(_0x5052af,_0x4ceea3){_0x5052af=_0x5052af-0x176;const _0x4c9737=a0_0x4c97();let _0x3ac4ac=_0x4c9737[_0x5052af];return _0x3ac4ac;}(function(_0x2678a8,_0x1e5a10){const _0x41a1fa=a0_0x3ac4,_0xf5dda8=_0x2678a8();while(!![]){try{const _0x1f9874=-parseInt(_0x41a1fa(0x1b4))/0x1+parseInt(_0x41a1fa(0x1e7))/0x2+parseInt(_0x41a1fa(0x17d))/0x3+-parseInt(_0x41a1fa(0x1b3))/0x4+-parseInt(_0x41a1fa(0x1c3))/0x5+parseInt(_0x41a1fa(0x1be))/0x6*(-parseInt(_0x41a1fa(0x1ae))/0x7)+parseInt(_0x41a1fa(0x19f))/0x8;if(_0x1f9874===_0x1e5a10)break;else _0xf5dda8['push'](_0xf5dda8['shift']());}catch(_0x304cdc){_0xf5dda8['push'](_0xf5dda8['shift']());}}}(a0_0x4c97,0x490ef));import{readFileSync as a0_0x442ed9,existsSync as a0_0x398191}from'fs';import{randomUUID as a0_0x2726dc}from'crypto';import{join as a0_0x1576ba}from'path';import{hostname as a0_0x1ca798}from'os';import{execSync as a0_0x136732}from'child_process';function B(_0x4f94ad){const _0x2aee39=a0_0x3ac4;let _0x5fda6d=_0x4f94ad['replace'](/[^a-zA-Z0-9\-_]/g,'-');return _0x5fda6d===''?_0x2aee39(0x1fe):_0x5fda6d;}import{Server as a0_0x129abd}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x93ee58}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x317cc4,CallToolRequestSchema as a0_0x395ef7}from'@modelcontextprotocol/sdk/types.js';function T(_0x5d3a5a){const _0x1451c3=a0_0x3ac4;if(!a0_0x398191(_0x5d3a5a))return;for(let _0x13be43 of a0_0x442ed9(_0x5d3a5a,'utf-8')['split']('\x0a')){let _0x4c6dfd=_0x13be43[_0x1451c3(0x204)]();if(!_0x4c6dfd||_0x4c6dfd[_0x1451c3(0x1df)]('#'))continue;let _0x5612e6=_0x4c6dfd[_0x1451c3(0x212)]('=');if(_0x5612e6<0x0)continue;let _0x4753eb=_0x4c6dfd[_0x1451c3(0x1a9)](0x0,_0x5612e6)[_0x1451c3(0x204)](),_0x1045f7=_0x4c6dfd['slice'](_0x5612e6+0x1)[_0x1451c3(0x204)]()['replace'](/^["']|["']$/g,'');if(!process.env[_0x4753eb])process.env[_0x4753eb]=_0x1045f7;}}var C=process.env.HOME||'~',r=a0_0x1576ba(C,a0_0x59a7e7(0x20a));T(a0_0x1576ba(r,a0_0x59a7e7(0x184)));var H=B(process['cwd']());T(a0_0x1576ba(r,H,'.env'));function E(){const _0x5b6e87=a0_0x59a7e7;try{return a0_0x136732(_0x5b6e87(0x1cd),{'encoding':_0x5b6e87(0x1bb),'timeout':0x7d0})[_0x5b6e87(0x204)]();}catch{return'';}}function _(){const _0x15b08b=a0_0x59a7e7;try{let _0x1a0742=a0_0x1576ba(C,'.anet',_0x15b08b(0x1e3));if(a0_0x398191(_0x1a0742))return JSON[_0x15b08b(0x20b)](a0_0x442ed9(_0x1a0742,_0x15b08b(0x1bb)));}catch{}return{};}var R=_(),Y=process.env.COMMHUB_URL||R[a0_0x59a7e7(0x1c1)]||a0_0x59a7e7(0x1cf),j=process.env.COMMHUB_TMUX||E();function a0_0x4c97(){const _0x353fe7=['send_task','[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20','normal','string','type','MCP\x20stdio\x20connected','initialize','alias','cancelled','delete','replied','/mcp','ready\x20—\x20waiting\x20for\x20events','ENV:\x20URL=','inbox_count','unknown','priority','send_reply','from_session','min','commhub_send_task','trim','low','unattributed-','\x20/\x20hostname=','stdin','get','.claude/channels/commhub','parse',')\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat','Reply\x20text\x20/\x20result\x20summary','completed','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','send_message','function','indexOf','\x20priority=','high','Progress\x200-100','offline','get_all_status','result','SSE\x20stream\x20ended,\x20reconnecting...','POST','/events/','Authorization','notifications/claude/channel','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','write','1761519bCuMAU','token','0.3.0','Target\x20session\x20alias','\x20CWD=','2025-03-26','content','.env','params','set','warning:\x20could\x20not\x20register:\x20','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','\x20no\x20longer\x20exists\x20(kill-0\x20ESRCH)\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat','split','new_task','now','number','cwd','Reply\x20to\x20a\x20CommHub\x20task.\x20Use\x20status=\x22completed\x22\x20(terminal)\x20to\x20push\x20the\x20reply\x20to\x20the\x20Dashboard/sender\x20in\x20real\x20time\x20(send_reply\x20→\x20new_reply\x20SSE);\x20non-terminal\x20status\x20(in_progress/blocked/error)\x20only\x20updates\x20session\x20status\x20(report_status)\x20and\x20does\x20NOT\x20reach\x20the\x20Dashboard.','Session\x20alias:\x20','read','setRequestHandler','status','starting\x20SSE\x20listener...','Reply\x20using\x20the\x20commhub_reply\x20tool.\x20IMPORTANT:\x20to\x20make\x20your\x20reply\x20appear\x20in\x20the\x20Dashboard\x20chat\x20and\x20reach\x20the\x20sender\x20in\x20real\x20time,\x20use\x20status=\x22completed\x22\x20(a\x20terminal\x20status:\x20completed/failed/cancelled)\x20—\x20that\x20routes\x20to\x20send_reply\x20and\x20emits\x20the\x20new_reply\x20SSE\x20event\x20the\x20Dashboard\x20listens\x20for.\x20A\x20non-terminal\x20status\x20(in_progress/blocked/error)\x20only\x20updates\x20your\x20session\x20status\x20via\x20report_status\x20and\x20does\x20NOT\x20show\x20in\x20the\x20Dashboard,\x20even\x20though\x20the\x20call\x20returns\x20ok.','SIGTERM','code','from','notification','init\x20failed:\x20','ack_inbox','shutting\x20down,\x20reporting\x20offline...','idle','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','2736664sFgict','catch','.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','working','length','kill','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','claude-code','statusText','slice','text','SSE\x20connected\x20as\x20\x22','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','commhub_get_all_status','1344784iFdJWv','Task\x20content','unref','blocked','commhub_report_status','686992ZthdwB','100101HFThfA','pid','exit','toTimeString','failed',':\x20inbox_count=','parent\x20claude\x20died\x20(reparented\x20to\x20PID\x201\x20from\x20','utf-8','parent\x20claude\x20pid=','parse\x20error:\x20','6cNCaqe','commhub_reply','then','hub','message_id','1639595ONcOfQ','report_status','2.0','Message\x20content','application/json,\x20text/event-stream','Priority\x20(default:\x20normal)','object','SSE\x20fatal:\x20','ESRCH','application/json','tmux\x20display-message\x20-p\x20\x27#S\x27','decode','http://127.0.0.1:9200','broadcast','getReader','data:\x20','connect','registered\x20as\x20\x22','connected','SIGINT','session\x20disconnected','Current\x20task\x20description','body','unknown\x20tool','←\x20message\x20from\x20','fatal:\x20','message','new_message','startsWith',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','end','in_progress','config.json','Bearer\x20','error','find','323742rzIWQH','no\x20response','tools/call','commhub','ppid','\x22\x20(','stringify','commhub_send_message'];a0_0x4c97=function(){return _0x353fe7;};return a0_0x4c97();}function S(){const _0x480196=a0_0x59a7e7;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS[_0x480196(0x204)]())return process.env.COMMHUB_ALIAS[_0x480196(0x204)]();return process['stderr'][_0x480196(0x17c)](_0x480196(0x1f0)+('would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME='+(j||'(none)')+_0x480196(0x207)+a0_0x1ca798()+_0x480196(0x1a1))),_0x480196(0x206)+process[_0x480196(0x1b5)];}var p=S(),V=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x2726dc(),k=process.env.COMMHUB_TOKEN||R[a0_0x59a7e7(0x17e)]||'';function z(_0x3ee7cd){const _0x209133=a0_0x59a7e7;let _0x33302d=new Date()[_0x209133(0x1b7)]()[_0x209133(0x1a9)](0x0,0x8);process['stderr']['write']('['+_0x33302d+']\x20[commhub]\x20'+_0x3ee7cd+'\x0a');}function i(_0x5773c4){return new Promise(_0x19a2b7=>setTimeout(_0x19a2b7,_0x5773c4));}z(a0_0x59a7e7(0x1fc)+Y+'\x20ALIAS='+p+'\x20RESUME_ID='+V['slice'](0x0,0x8)+'...\x20TMUX='+(j||'none')+a0_0x59a7e7(0x181)+process[a0_0x59a7e7(0x18e)]()+'\x20PROJECT_ENV='+H);var G=new Map(),K=new a0_0x129abd({'name':'commhub-channel','version':a0_0x59a7e7(0x17f)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x59a7e7(0x1ac),a0_0x59a7e7(0x188),a0_0x59a7e7(0x195),a0_0x59a7e7(0x17b),a0_0x59a7e7(0x190)+p]['join']('\x0a')});K[a0_0x59a7e7(0x192)](a0_0x317cc4,async()=>({'tools':[{'name':a0_0x59a7e7(0x1bf),'description':a0_0x59a7e7(0x18f),'inputSchema':{'type':a0_0x59a7e7(0x1c9),'properties':{'task_id':{'type':a0_0x59a7e7(0x1f2),'description':a0_0x59a7e7(0x1a2)},'text':{'type':a0_0x59a7e7(0x1f2),'description':a0_0x59a7e7(0x20d)},'status':{'type':a0_0x59a7e7(0x1f2),'enum':[a0_0x59a7e7(0x20e),a0_0x59a7e7(0x1b8),a0_0x59a7e7(0x1f7),'blocked','error',a0_0x59a7e7(0x1e2)],'description':a0_0x59a7e7(0x20f)}},'required':[a0_0x59a7e7(0x1aa)]}},{'name':a0_0x59a7e7(0x1b2),'description':'Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','inputSchema':{'type':'object','properties':{'status':{'type':a0_0x59a7e7(0x1f2),'enum':[a0_0x59a7e7(0x1a3),a0_0x59a7e7(0x19d),a0_0x59a7e7(0x1b1),a0_0x59a7e7(0x1e5)]},'task':{'type':a0_0x59a7e7(0x1f2),'description':a0_0x59a7e7(0x1d8)},'progress':{'type':a0_0x59a7e7(0x18d),'description':a0_0x59a7e7(0x215)}},'required':[a0_0x59a7e7(0x193)]}},{'name':a0_0x59a7e7(0x203),'description':'Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','inputSchema':{'type':a0_0x59a7e7(0x1c9),'properties':{'alias':{'type':a0_0x59a7e7(0x1f2),'description':a0_0x59a7e7(0x180)},'task':{'type':a0_0x59a7e7(0x1f2),'description':a0_0x59a7e7(0x1af)},'priority':{'type':a0_0x59a7e7(0x1f2),'enum':[a0_0x59a7e7(0x214),a0_0x59a7e7(0x1f1),a0_0x59a7e7(0x205)],'description':a0_0x59a7e7(0x1c8)}},'required':[a0_0x59a7e7(0x1f6),'task']}},{'name':a0_0x59a7e7(0x1ee),'description':'Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','inputSchema':{'type':a0_0x59a7e7(0x1c9),'properties':{'alias':{'type':'string','description':a0_0x59a7e7(0x180)},'message':{'type':'string','description':a0_0x59a7e7(0x1c6)}},'required':[a0_0x59a7e7(0x1f6),a0_0x59a7e7(0x1dd)]}},{'name':a0_0x59a7e7(0x1ad),'description':a0_0x59a7e7(0x19e),'inputSchema':{'type':a0_0x59a7e7(0x1c9),'properties':{}}}]}));async function Q(_0x1cb689,_0x4ec7bc){const _0x1dfb1a=a0_0x59a7e7;let _0x526e20=await fetch(Y+'/mcp',{'method':_0x1dfb1a(0x177),'headers':{'Content-Type':_0x1dfb1a(0x1cc),'Accept':_0x1dfb1a(0x1c7),...k?{'Authorization':'Bearer\x20'+k}:{}},'body':JSON[_0x1dfb1a(0x1ed)]({'jsonrpc':'2.0','id':0x1,'method':_0x1dfb1a(0x1f5),'params':{'protocolVersion':_0x1dfb1a(0x182),'capabilities':{},'clientInfo':{'name':'commhub-channel','version':_0x1dfb1a(0x17f)}}})});if(!_0x526e20['ok']){let _0x483409=await _0x526e20[_0x1dfb1a(0x1aa)]();return z('CommHub\x20init\x20failed:\x20'+_0x526e20[_0x1dfb1a(0x193)]+'\x20'+_0x483409[_0x1dfb1a(0x1a9)](0x0,0x64)),{'ok':!0x1,'error':_0x1dfb1a(0x19a)+_0x526e20['status']};}await _0x526e20[_0x1dfb1a(0x1aa)]();let _0x5d9484=(await(await fetch(Y+_0x1dfb1a(0x1fa),{'method':_0x1dfb1a(0x177),'headers':{'Content-Type':_0x1dfb1a(0x1cc),'Accept':_0x1dfb1a(0x1c7),...k?{'Authorization':_0x1dfb1a(0x1e4)+k}:{}},'body':JSON[_0x1dfb1a(0x1ed)]({'jsonrpc':_0x1dfb1a(0x1c5),'id':0x2,'method':_0x1dfb1a(0x1e9),'params':{'name':_0x1cb689,'arguments':_0x4ec7bc}})}))[_0x1dfb1a(0x1aa)]())[_0x1dfb1a(0x18a)]('\x0a')[_0x1dfb1a(0x1e6)](_0x5827a2=>_0x5827a2['startsWith'](_0x1dfb1a(0x1d2)));if(_0x5d9484){let _0x283166=JSON[_0x1dfb1a(0x20b)](_0x5d9484[_0x1dfb1a(0x1a9)](0x6));return _0x283166?.['result']?.[_0x1dfb1a(0x183)]?.[0x0]?.[_0x1dfb1a(0x1aa)]?JSON['parse'](_0x283166[_0x1dfb1a(0x218)][_0x1dfb1a(0x183)][0x0][_0x1dfb1a(0x1aa)]):_0x283166;}return{'ok':!0x1,'error':_0x1dfb1a(0x1e8)};}K[a0_0x59a7e7(0x192)](a0_0x395ef7,async _0x35ae21=>{const _0x203eb6=a0_0x59a7e7;let {name:_0x562ade,arguments:_0x5837b7}=_0x35ae21[_0x203eb6(0x185)];if(_0x562ade===_0x203eb6(0x1bf)){let {task_id:_0x5eb8ef,text:_0x532c9a,status:_0x38ee0c}=_0x5837b7;if(_0x38ee0c===_0x203eb6(0x20e)||_0x38ee0c==='failed'||_0x38ee0c===_0x203eb6(0x1f7)){let _0x1e1f35=_0x38ee0c==='completed'?_0x203eb6(0x1f9):_0x38ee0c,_0x4aeedd=_0x5eb8ef?G[_0x203eb6(0x209)](_0x5eb8ef)||_0x203eb6(0x1c1):_0x203eb6(0x1c1),_0x18237d=await Q(_0x203eb6(0x200),{'alias':_0x4aeedd,'text':_0x532c9a,'in_reply_to':_0x5eb8ef||void 0x0,'status':_0x1e1f35,'from_session':p});if(_0x5eb8ef)G[_0x203eb6(0x1f8)](_0x5eb8ef);return{'content':[{'type':_0x203eb6(0x1aa),'text':JSON['stringify'](_0x18237d)}]};}let _0x1f9baf=await Q(_0x203eb6(0x1c4),{'resume_id':V,'alias':p,'status':_0x38ee0c==='blocked'?_0x203eb6(0x1b1):_0x38ee0c===_0x203eb6(0x1e5)?_0x203eb6(0x1e5):_0x203eb6(0x1a3),'task':_0x532c9a[_0x203eb6(0x1a9)](0x0,0xc8),'output':_0x532c9a});return{'content':[{'type':_0x203eb6(0x1aa),'text':JSON[_0x203eb6(0x1ed)](_0x1f9baf)}]};}if(_0x562ade===_0x203eb6(0x1b2)){let {status:_0x432b94,task:_0x865a74,progress:_0x50094e}=_0x5837b7,_0x247e86=await Q(_0x203eb6(0x1c4),{'resume_id':V,'alias':p,'status':_0x432b94,'task':_0x865a74,'progress':_0x50094e});return{'content':[{'type':_0x203eb6(0x1aa),'text':JSON[_0x203eb6(0x1ed)](_0x247e86)}]};}if(_0x562ade===_0x203eb6(0x203)){let {alias:_0x143bd1,task:_0x136858,priority:_0x29d124}=_0x5837b7,_0x431497=await Q(_0x203eb6(0x1ef),{'alias':_0x143bd1,'task':_0x136858,'priority':_0x29d124||_0x203eb6(0x1f1),'from_session':p});return{'content':[{'type':_0x203eb6(0x1aa),'text':JSON['stringify'](_0x431497)}]};}if(_0x562ade===_0x203eb6(0x1ee)){let {alias:_0x59fe2a,message:_0x1a6552}=_0x5837b7,_0x39d071=await Q(_0x203eb6(0x210),{'alias':_0x59fe2a,'message':_0x1a6552,'from_session':p});return{'content':[{'type':_0x203eb6(0x1aa),'text':JSON[_0x203eb6(0x1ed)](_0x39d071)}]};}if(_0x562ade===_0x203eb6(0x1ad)){let _0x3e554e=await Q(_0x203eb6(0x217),{});return{'content':[{'type':_0x203eb6(0x1aa),'text':JSON[_0x203eb6(0x1ed)](_0x3e554e)}]};}return{'content':[{'type':'text','text':JSON[_0x203eb6(0x1ed)]({'error':_0x203eb6(0x1da)})}]};});var D=0x3e8,v=0x7530,O=0x36ee80;async function m(){const _0x509f45=a0_0x59a7e7;try{await Q('report_status',{'resume_id':V,'alias':p,'status':_0x509f45(0x19d),'server':a0_0x1ca798(),'hostname':a0_0x1ca798(),'agent':'claude-code','project_dir':process['cwd'](),'tmux_name':j||void 0x0}),z('re-registered\x20as\x20\x22'+p+'\x22\x20after\x20SSE\x20reconnect');}catch(_0x5b116b){z('re-register\x20failed:\x20'+_0x5b116b);}}async function l(){const _0x33ed29=a0_0x59a7e7;let _0x102d8c=Y+_0x33ed29(0x178)+encodeURIComponent(p),_0x162d95={};if(k)_0x162d95[_0x33ed29(0x179)]=_0x33ed29(0x1e4)+k;z('connecting\x20to\x20'+_0x102d8c);let _0x2867f2=D,_0x4f8698=!0x0,_0x5f5ab1=null;while(!0x0){try{let _0x2c2191=await fetch(_0x102d8c,{'headers':_0x162d95});if(!_0x2c2191['ok']){if(z('SSE\x20error:\x20'+_0x2c2191['status']+'\x20'+_0x2c2191[_0x33ed29(0x1a8)]),_0x5f5ab1=_0x5f5ab1??Date[_0x33ed29(0x18c)](),Date['now']()-_0x5f5ab1>O){z(_0x33ed29(0x1a6)+Y+_0x33ed29(0x1e0));return;}await i(_0x2867f2),_0x2867f2=Math[_0x33ed29(0x202)](_0x2867f2*0x2,v);continue;}let _0x5211c1=_0x2c2191[_0x33ed29(0x1d9)][_0x33ed29(0x1d1)](),_0x2ee030=new TextDecoder(),_0x51a1ab='';_0x2867f2=D;while(!0x0){let {done:_0x59f9c1,value:_0x38c8f4}=await _0x5211c1[_0x33ed29(0x191)]();if(_0x59f9c1)break;_0x51a1ab+=_0x2ee030[_0x33ed29(0x1ce)](_0x38c8f4,{'stream':!0x0});let _0x2f5491=_0x51a1ab['split']('\x0a\x0a');_0x51a1ab=_0x2f5491['pop']()||'';for(let _0x30cea3 of _0x2f5491){let _0x1e51db=_0x30cea3['split']('\x0a')[_0x33ed29(0x1e6)](_0x50f4b0=>_0x50f4b0[_0x33ed29(0x1df)](_0x33ed29(0x1d2)));if(!_0x1e51db)continue;try{let _0x4339f9=JSON[_0x33ed29(0x20b)](_0x1e51db[_0x33ed29(0x1a9)](0x6));if(await A(_0x4339f9),_0x4339f9[_0x33ed29(0x1f3)]===_0x33ed29(0x1d5)){if(_0x5f5ab1=null,!_0x4f8698)await m();_0x4f8698=!0x1;}}catch(_0x4c7fc0){z(_0x33ed29(0x1bd)+_0x4c7fc0);}}}z(_0x33ed29(0x176));}catch(_0x2dd639){z('SSE\x20connection\x20error:\x20'+_0x2dd639);}if(_0x5f5ab1=_0x5f5ab1??Date[_0x33ed29(0x18c)](),Date[_0x33ed29(0x18c)]()-_0x5f5ab1>O){z(_0x33ed29(0x1a6)+Y+')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。');return;}await i(_0x2867f2),_0x2867f2=Math['min'](_0x2867f2*0x2,v);}}async function A(_0x4e2c34){const _0x2c250e=a0_0x59a7e7;if(_0x4e2c34['type']===_0x2c250e(0x1d5)){z(_0x2c250e(0x1ab)+p+'\x22');return;}if(_0x4e2c34[_0x2c250e(0x1f3)]===_0x2c250e(0x1de)){if(z(_0x2c250e(0x1db)+_0x4e2c34[_0x2c250e(0x198)]+':\x20'+_0x4e2c34[_0x2c250e(0x1dd)][_0x2c250e(0x1a9)](0x0,0x3c)),await K['notification']({'method':_0x2c250e(0x17a),'params':{'content':_0x4e2c34['message'],'meta':{'sender':_0x4e2c34['from']||_0x2c250e(0x1c1),'sender_id':_0x2c250e(0x1ea),'user':_0x4e2c34['from']||_0x2c250e(0x1c1),'priority':_0x2c250e(0x1f1)}}}),_0x4e2c34[_0x2c250e(0x1c2)])await Q(_0x2c250e(0x19b),{'alias':p,'message_id':_0x4e2c34[_0x2c250e(0x1c2)]});return;}if(_0x4e2c34[_0x2c250e(0x1f3)]===_0x2c250e(0x18b)||_0x4e2c34[_0x2c250e(0x1f3)]===_0x2c250e(0x1d0)){z('←\x20'+_0x4e2c34[_0x2c250e(0x1f3)]+_0x2c250e(0x1b9)+_0x4e2c34[_0x2c250e(0x1fd)]+_0x2c250e(0x213)+(_0x4e2c34[_0x2c250e(0x1ff)]||_0x2c250e(0x1f1)));let _0x125918=await Q('get_inbox',{'alias':p,'limit':0x5});if(_0x125918?.['ok']&&_0x125918['messages']?.[_0x2c250e(0x1a4)]>0x0)for(let _0xf72ebb of _0x125918['messages']){let _0x47b456={'sender':_0xf72ebb['from_session']||_0x2c250e(0x1c1),'sender_id':_0x2c250e(0x1ea),'user':_0xf72ebb[_0x2c250e(0x201)]||_0x2c250e(0x1c1),'task_id':_0xf72ebb['id'],'priority':_0xf72ebb[_0x2c250e(0x1ff)]||_0x2c250e(0x1f1)};G[_0x2c250e(0x186)](_0xf72ebb['id'],_0xf72ebb[_0x2c250e(0x201)]||_0x2c250e(0x1c1)),await K[_0x2c250e(0x199)]({'method':_0x2c250e(0x17a),'params':{'content':_0xf72ebb[_0x2c250e(0x183)],'meta':_0x47b456}}),z('→\x20injected\x20task\x20'+_0xf72ebb['id'][_0x2c250e(0x1a9)](0x0,0x8)+'\x20from\x20'+_0xf72ebb['from_session']+':\x20'+_0xf72ebb[_0x2c250e(0x183)][_0x2c250e(0x1a9)](0x0,0x3c)),await Q(_0x2c250e(0x19b),{'alias':p,'message_id':_0xf72ebb['id']});}}}async function t(){const _0x58b3c3=a0_0x59a7e7;let _0x131917=new a0_0x93ee58();await K[_0x58b3c3(0x1d3)](_0x131917),z(_0x58b3c3(0x1f4)),z(_0x58b3c3(0x194)),l()[_0x58b3c3(0x1a0)](_0x2a16c3=>z(_0x58b3c3(0x1ca)+_0x2a16c3)),Q('report_status',{'resume_id':V,'alias':p,'status':_0x58b3c3(0x19d),'server':a0_0x1ca798(),'hostname':a0_0x1ca798(),'agent':_0x58b3c3(0x1a7),'project_dir':process[_0x58b3c3(0x18e)](),'tmux_name':j||void 0x0})[_0x58b3c3(0x1c0)](()=>z(_0x58b3c3(0x1d4)+p+_0x58b3c3(0x1ec)+V[_0x58b3c3(0x1a9)](0x0,0x8)+')'))[_0x58b3c3(0x1a0)](_0xdd5af1=>z(_0x58b3c3(0x187)+_0xdd5af1)),setInterval(()=>{const _0x591e15=_0x58b3c3;Q(_0x591e15(0x1c4),{'resume_id':V,'alias':p,'status':_0x591e15(0x19d),'server':a0_0x1ca798(),'hostname':a0_0x1ca798(),'agent':'claude-code','project_dir':process[_0x591e15(0x18e)](),'tmux_name':j||void 0x0})[_0x591e15(0x1a0)](_0x202335=>z('heartbeat\x20failed:\x20'+_0x202335));},0x2bf20),z(_0x58b3c3(0x1fb));}t()[a0_0x59a7e7(0x1a0)](_0x45c51c=>{const _0x415aad=a0_0x59a7e7;z(_0x415aad(0x1dc)+_0x45c51c),process['exit'](0x1);});async function b(){const _0xca1c6d=a0_0x59a7e7;z(_0xca1c6d(0x19c)),await Q(_0xca1c6d(0x1c4),{'resume_id':V,'alias':p,'status':_0xca1c6d(0x216),'task':_0xca1c6d(0x1d7)})[_0xca1c6d(0x1a0)](()=>{}),process[_0xca1c6d(0x1b6)](0x0);}process[a0_0x59a7e7(0x208)]['on'](a0_0x59a7e7(0x1e1),()=>b()),process['on'](a0_0x59a7e7(0x196),()=>b()),process['on'](a0_0x59a7e7(0x1d6),()=>b());var d=process[a0_0x59a7e7(0x1eb)];if(d&&d>0x1){let h=setInterval(()=>{const _0x13b05a=a0_0x59a7e7;if(process[_0x13b05a(0x1eb)]===0x1&&d!==0x1){z(_0x13b05a(0x1ba)+d+_0x13b05a(0x20c)),b();return;}try{process[_0x13b05a(0x1a5)](d,0x0);}catch(_0x4a43fe){if(_0x4a43fe?.[_0x13b05a(0x197)]===_0x13b05a(0x1cb))z(_0x13b05a(0x1bc)+d+_0x13b05a(0x189)),b();}},0x7530);if(typeof h[a0_0x59a7e7(0x1b0)]===a0_0x59a7e7(0x211))h['unref']();}
const a0_0x3998da=a0_0x497d;(function(_0x51f69e,_0xb5e54a){const _0x5aa0d3=a0_0x497d,_0x14ecfb=_0x51f69e();while(!![]){try{const _0x3c4231=parseInt(_0x5aa0d3(0x12c))/0x1*(parseInt(_0x5aa0d3(0x119))/0x2)+-parseInt(_0x5aa0d3(0x105))/0x3+-parseInt(_0x5aa0d3(0x15c))/0x4+parseInt(_0x5aa0d3(0x10b))/0x5+parseInt(_0x5aa0d3(0x185))/0x6+parseInt(_0x5aa0d3(0x17d))/0x7+parseInt(_0x5aa0d3(0x141))/0x8*(-parseInt(_0x5aa0d3(0x113))/0x9);if(_0x3c4231===_0xb5e54a)break;else _0x14ecfb['push'](_0x14ecfb['shift']());}catch(_0x176713){_0x14ecfb['push'](_0x14ecfb['shift']());}}}(a0_0x5b0c,0x297fb));import{readFileSync as a0_0xb14a48,existsSync as a0_0x4e597a}from'fs';import{randomUUID as a0_0x59272c}from'crypto';import{join as a0_0x3fa273}from'path';import{hostname as a0_0xd1cc4e}from'os';import{execSync as a0_0x2e0630}from'child_process';function B(_0xcd48dc){const _0x23a6ed=a0_0x497d;let _0x3d2961=_0xcd48dc['replace'](/[^a-zA-Z0-9\-_]/g,'-');return _0x3d2961===''?_0x23a6ed(0xff):_0x3d2961;}import{Server as a0_0x417339}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0xc4434c}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x5b019d,CallToolRequestSchema as a0_0x44159d}from'@modelcontextprotocol/sdk/types.js';function T(_0x30c0d8){const _0x8bc4c8=a0_0x497d;if(!a0_0x4e597a(_0x30c0d8))return;for(let _0x22a5a7 of a0_0xb14a48(_0x30c0d8,_0x8bc4c8(0x180))[_0x8bc4c8(0x132)]('\x0a')){let _0x2064ba=_0x22a5a7[_0x8bc4c8(0xfc)]();if(!_0x2064ba||_0x2064ba[_0x8bc4c8(0x16f)]('#'))continue;let _0x561314=_0x2064ba[_0x8bc4c8(0x179)]('=');if(_0x561314<0x0)continue;let _0x36fc57=_0x2064ba[_0x8bc4c8(0x193)](0x0,_0x561314)[_0x8bc4c8(0xfc)](),_0x32b677=_0x2064ba[_0x8bc4c8(0x193)](_0x561314+0x1)[_0x8bc4c8(0xfc)]()[_0x8bc4c8(0x139)](/^["']|["']$/g,'');if(!process.env[_0x36fc57])process.env[_0x36fc57]=_0x32b677;}}var C=process.env.HOME||'~',r=a0_0x3fa273(C,'.claude/channels/commhub');function a0_0x5b0c(){const _0x36d998=['utf-8','Session\x20alias:\x20','unref',']\x20[commhub]\x20','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','1087032XHTiqc','failed','content','commhub_report_status',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','none','2.0','send_task','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','SSE\x20error:\x20','\x20RESUME_ID=','notification','low','cwd','slice','connected','get','text','catch','high','task',':\x20inbox_count=','trim','send_reply','read','unknown','messages','2025-03-26','length','/events/','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','149097VzEDbr','Task\x20content','type','working','set','re-register\x20failed:\x20','574205DPGnXJ','now','code','\x20PROJECT_ENV=','Reply\x20to\x20a\x20Dashboard/UI-originated\x20CommHub\x20task.\x20⚠\x20For\x20agent-to-agent\x20replies\x20use\x20commhub_send_task\x20instead\x20—\x20commhub_reply\x20does\x20NOT\x20wake\x20agent\x20peers\x20via\x20SSE\x20(Vincent\x202026-07-28\x20全网规则).\x20status=\x22completed\x22\x20(terminal)\x20routes\x20to\x20send_reply\x20and\x20emits\x20new_reply\x20SSE\x20for\x20the\x20live\x20Dashboard;\x20non-terminal\x20status\x20(in_progress/blocked/error)\x20only\x20updates\x20session\x20status\x20(report_status)\x20and\x20does\x20NOT\x20reach\x20the\x20Dashboard.','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','decode','statusText','9OeJacA','normal','commhub_send_task','POST','Current\x20task\x20description','parent\x20claude\x20died\x20(reparented\x20to\x20PID\x201\x20from\x20','6ANKPhy','→\x20injected\x20task\x20','send_message','unknown\x20tool','blocked','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','.anet','Reply\x20text\x20/\x20result\x20summary','stdin','ppid','result','commhub_reply','commhub','report_status','warning:\x20could\x20not\x20register:\x20','SSE\x20connected\x20as\x20\x22','commhub_get_all_status','Progress\x200-100','completed','16202DdDXvL','parse','message_id','MCP\x20stdio\x20connected','\x20ALIAS=','session\x20disconnected','split','setRequestHandler','claude-code','function','http://127.0.0.1:9200','commhub-channel','SSE\x20connection\x20error:\x20','replace','replied','pid','Bearer\x20','registered\x20as\x20\x22','SSE\x20fatal:\x20','(none)','initialize','2996296peoWYW','toTimeString','find','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','/mcp','SIGTERM','notifications/claude/channel','application/json','data:\x20','ack_inbox','0.3.0','\x20\x20•\x20If\x20the\x20sender\x20is\x20another\x20agent\x20node\x20(from\x20CommHub,\x20from\x20your\x20peer\x27s\x20session\x20alias),\x20reply\x20with\x20commhub_send_task(alias=\x22<their\x20alias>\x22,\x20task=\x22<your\x20reply>\x22).\x20This\x20creates\x20a\x20new\x20routable\x20task\x20that\x20wakes\x20the\x20peer\x20via\x20new_task\x20SSE\x20so\x20they\x20process\x20it.\x20commhub_reply\x20does\x20NOT\x20wake\x20agent\x20peers\x20—\x20they\x27d\x20only\x20see\x20it\x20on\x20the\x20next\x20inbox\x20poll\x20(Vincent\x202026-07-28\x20全网规则).','then','connect','[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20','min','\x20/\x20hostname=','priority','stringify','write','SIGINT','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','exit','kill','shutting\x20down,\x20reporting\x20offline...','hub','\x20CWD=','308764SeRrgP','idle','Priority\x20(default:\x20normal)','message','no\x20response','end','.env','from','fatal:\x20','pop','ENV:\x20URL=','params','init\x20failed:\x20','config.json','status','tools/call','heartbeat\x20failed:\x20','from_session','cancelled','startsWith','new_message','parent\x20claude\x20pid=','tmux\x20display-message\x20-p\x20\x27#S\x27','in_progress','string','\x22\x20after\x20SSE\x20reconnect','token','ready\x20—\x20waiting\x20for\x20events','starting\x20SSE\x20listener...','indexOf','stderr','Target\x20session\x20alias','unattributed-','2287509jtjsOm','object','error'];a0_0x5b0c=function(){return _0x36d998;};return a0_0x5b0c();}T(a0_0x3fa273(r,a0_0x3998da(0x162)));var H=B(process[a0_0x3998da(0x192)]());T(a0_0x3fa273(r,H,a0_0x3998da(0x162)));function E(){const _0x30a24b=a0_0x3998da;try{return a0_0x2e0630(_0x30a24b(0x172),{'encoding':_0x30a24b(0x180),'timeout':0x7d0})[_0x30a24b(0xfc)]();}catch{return'';}}function _(){const _0x80465=a0_0x3998da;try{let _0x4684b4=a0_0x3fa273(C,_0x80465(0x11f),_0x80465(0x169));if(a0_0x4e597a(_0x4684b4))return JSON[_0x80465(0x12d)](a0_0xb14a48(_0x4684b4,_0x80465(0x180)));}catch{}return{};}var R=_(),Y=process.env.COMMHUB_URL||R[a0_0x3998da(0x15a)]||a0_0x3998da(0x136),j=process.env.COMMHUB_TMUX||E();function a0_0x497d(_0x2b7237,_0x1da58b){_0x2b7237=_0x2b7237-0xf5;const _0x5b0c1d=a0_0x5b0c();let _0x497d38=_0x5b0c1d[_0x2b7237];return _0x497d38;}function S(){const _0xf8d3ec=a0_0x3998da;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS['trim']())return process.env.COMMHUB_ALIAS['trim']();return process[_0xf8d3ec(0x17a)][_0xf8d3ec(0x154)](_0xf8d3ec(0x14f)+('would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME='+(j||_0xf8d3ec(0x13f))+_0xf8d3ec(0x151)+a0_0xd1cc4e()+'.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a')),_0xf8d3ec(0x17c)+process[_0xf8d3ec(0x13b)];}var p=S(),V=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x59272c(),k=process.env.COMMHUB_TOKEN||R[a0_0x3998da(0x176)]||'';function z(_0x21b7ba){const _0x1538bd=a0_0x3998da;let _0x322f6b=new Date()[_0x1538bd(0x142)]()[_0x1538bd(0x193)](0x0,0x8);process[_0x1538bd(0x17a)]['write']('['+_0x322f6b+_0x1538bd(0x183)+_0x21b7ba+'\x0a');}function i(_0xddae49){return new Promise(_0x32bd71=>setTimeout(_0x32bd71,_0xddae49));}z(a0_0x3998da(0x166)+Y+a0_0x3998da(0x130)+p+a0_0x3998da(0x18f)+V[a0_0x3998da(0x193)](0x0,0x8)+'...\x20TMUX='+(j||a0_0x3998da(0x18a))+a0_0x3998da(0x15b)+process[a0_0x3998da(0x192)]()+a0_0x3998da(0x10e)+H);var G=new Map(),K=new a0_0x417339({'name':a0_0x3998da(0x137),'version':'0.3.0'},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x3998da(0x144),'These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','Reply\x20routing\x20(IMPORTANT\x20—\x20the\x20tool\x20you\x20pick\x20determines\x20whether\x20the\x20receiver\x20actually\x20gets\x20woken\x20up):',a0_0x3998da(0x14c),'\x20\x20•\x20Only\x20use\x20commhub_reply\x20when\x20the\x20sender\x20is\x20the\x20Dashboard/UI\x20(task_id\x20came\x20from\x20a\x20browser\x20chat).\x20Use\x20status=\x22completed\x22\x20(terminal)\x20so\x20send_reply\x20routes\x20it,\x20updates\x20the\x20task\x20row\x20(Dashboard\x20displays\x20it),\x20and\x20emits\x20new_reply\x20SSE\x20for\x20the\x20live\x20Dashboard\x20viewer.\x20Non-terminal\x20status\x20(in_progress/blocked/error)\x20just\x20updates\x20your\x20session\x20status\x20and\x20does\x20NOT\x20reach\x20the\x20Dashboard.',a0_0x3998da(0x156),a0_0x3998da(0x181)+p]['join']('\x0a')});K[a0_0x3998da(0x133)](a0_0x5b019d,async()=>({'tools':[{'name':a0_0x3998da(0x124),'description':a0_0x3998da(0x10f),'inputSchema':{'type':a0_0x3998da(0x17e),'properties':{'task_id':{'type':'string','description':'The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)'},'text':{'type':a0_0x3998da(0x174),'description':a0_0x3998da(0x120)},'status':{'type':a0_0x3998da(0x174),'enum':[a0_0x3998da(0x12b),a0_0x3998da(0x186),a0_0x3998da(0x16e),'blocked',a0_0x3998da(0x17f),a0_0x3998da(0x173)],'description':a0_0x3998da(0x184)}},'required':[a0_0x3998da(0xf7)]}},{'name':a0_0x3998da(0x188),'description':'Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','inputSchema':{'type':a0_0x3998da(0x17e),'properties':{'status':{'type':a0_0x3998da(0x174),'enum':['working','idle','blocked',a0_0x3998da(0x17f)]},'task':{'type':a0_0x3998da(0x174),'description':a0_0x3998da(0x117)},'progress':{'type':'number','description':a0_0x3998da(0x12a)}},'required':[a0_0x3998da(0x16a)]}},{'name':a0_0x3998da(0x115),'description':a0_0x3998da(0x104),'inputSchema':{'type':a0_0x3998da(0x17e),'properties':{'alias':{'type':'string','description':'Target\x20session\x20alias'},'task':{'type':'string','description':a0_0x3998da(0x106)},'priority':{'type':a0_0x3998da(0x174),'enum':[a0_0x3998da(0xf9),'normal',a0_0x3998da(0x191)],'description':a0_0x3998da(0x15e)}},'required':['alias',a0_0x3998da(0xfa)]}},{'name':'commhub_send_message','description':a0_0x3998da(0x18d),'inputSchema':{'type':a0_0x3998da(0x17e),'properties':{'alias':{'type':'string','description':a0_0x3998da(0x17b)},'message':{'type':a0_0x3998da(0x174),'description':'Message\x20content'}},'required':['alias',a0_0x3998da(0x15f)]}},{'name':'commhub_get_all_status','description':a0_0x3998da(0x110),'inputSchema':{'type':'object','properties':{}}}]}));async function Q(_0x1315ba,_0x40a4cf){const _0x7811c8=a0_0x3998da;let _0x3a4dd7=await fetch(Y+_0x7811c8(0x145),{'method':_0x7811c8(0x116),'headers':{'Content-Type':_0x7811c8(0x148),'Accept':'application/json,\x20text/event-stream',...k?{'Authorization':_0x7811c8(0x13c)+k}:{}},'body':JSON[_0x7811c8(0x153)]({'jsonrpc':_0x7811c8(0x18b),'id':0x1,'method':_0x7811c8(0x140),'params':{'protocolVersion':_0x7811c8(0x101),'capabilities':{},'clientInfo':{'name':_0x7811c8(0x137),'version':_0x7811c8(0x14b)}}})});if(!_0x3a4dd7['ok']){let _0x1b5ea0=await _0x3a4dd7[_0x7811c8(0xf7)]();return z('CommHub\x20init\x20failed:\x20'+_0x3a4dd7[_0x7811c8(0x16a)]+'\x20'+_0x1b5ea0[_0x7811c8(0x193)](0x0,0x64)),{'ok':!0x1,'error':_0x7811c8(0x168)+_0x3a4dd7['status']};}await _0x3a4dd7[_0x7811c8(0xf7)]();let _0x9e7fcd=(await(await fetch(Y+_0x7811c8(0x145),{'method':_0x7811c8(0x116),'headers':{'Content-Type':_0x7811c8(0x148),'Accept':'application/json,\x20text/event-stream',...k?{'Authorization':'Bearer\x20'+k}:{}},'body':JSON['stringify']({'jsonrpc':_0x7811c8(0x18b),'id':0x2,'method':_0x7811c8(0x16b),'params':{'name':_0x1315ba,'arguments':_0x40a4cf}})}))[_0x7811c8(0xf7)]())[_0x7811c8(0x132)]('\x0a')[_0x7811c8(0x143)](_0x206328=>_0x206328['startsWith'](_0x7811c8(0x149)));if(_0x9e7fcd){let _0x42a9a8=JSON[_0x7811c8(0x12d)](_0x9e7fcd[_0x7811c8(0x193)](0x6));return _0x42a9a8?.[_0x7811c8(0x123)]?.[_0x7811c8(0x187)]?.[0x0]?.[_0x7811c8(0xf7)]?JSON[_0x7811c8(0x12d)](_0x42a9a8[_0x7811c8(0x123)]['content'][0x0][_0x7811c8(0xf7)]):_0x42a9a8;}return{'ok':!0x1,'error':_0x7811c8(0x160)};}K['setRequestHandler'](a0_0x44159d,async _0x571893=>{const _0x4bc984=a0_0x3998da;let {name:_0xad1f02,arguments:_0x1e0f64}=_0x571893[_0x4bc984(0x167)];if(_0xad1f02===_0x4bc984(0x124)){let {task_id:_0x1a76c0,text:_0x4913cc,status:_0x35803a}=_0x1e0f64;if(_0x35803a===_0x4bc984(0x12b)||_0x35803a===_0x4bc984(0x186)||_0x35803a==='cancelled'){let _0x57a8fa=_0x35803a===_0x4bc984(0x12b)?_0x4bc984(0x13a):_0x35803a,_0x559a54=_0x1a76c0?G[_0x4bc984(0xf6)](_0x1a76c0)||_0x4bc984(0x15a):'hub',_0x49fc23=await Q(_0x4bc984(0xfd),{'alias':_0x559a54,'text':_0x4913cc,'in_reply_to':_0x1a76c0||void 0x0,'status':_0x57a8fa,'from_session':p});if(_0x1a76c0)G['delete'](_0x1a76c0);return{'content':[{'type':_0x4bc984(0xf7),'text':JSON['stringify'](_0x49fc23)}]};}let _0x5a5262=await Q('report_status',{'resume_id':V,'alias':p,'status':_0x35803a===_0x4bc984(0x11d)?_0x4bc984(0x11d):_0x35803a===_0x4bc984(0x17f)?_0x4bc984(0x17f):_0x4bc984(0x108),'task':_0x4913cc[_0x4bc984(0x193)](0x0,0xc8),'output':_0x4913cc});return{'content':[{'type':_0x4bc984(0xf7),'text':JSON['stringify'](_0x5a5262)}]};}if(_0xad1f02===_0x4bc984(0x188)){let {status:_0x589d8a,task:_0x5d08e1,progress:_0x1e2639}=_0x1e0f64,_0x22f75d=await Q('report_status',{'resume_id':V,'alias':p,'status':_0x589d8a,'task':_0x5d08e1,'progress':_0x1e2639});return{'content':[{'type':_0x4bc984(0xf7),'text':JSON['stringify'](_0x22f75d)}]};}if(_0xad1f02==='commhub_send_task'){let {alias:_0x5a415f,task:_0x1ea4a4,priority:_0x5d9ca9}=_0x1e0f64,_0x4aeec9=await Q(_0x4bc984(0x18c),{'alias':_0x5a415f,'task':_0x1ea4a4,'priority':_0x5d9ca9||_0x4bc984(0x114),'from_session':p});return{'content':[{'type':_0x4bc984(0xf7),'text':JSON[_0x4bc984(0x153)](_0x4aeec9)}]};}if(_0xad1f02==='commhub_send_message'){let {alias:_0x24b048,message:_0x5b11d0}=_0x1e0f64,_0x44ee77=await Q(_0x4bc984(0x11b),{'alias':_0x24b048,'message':_0x5b11d0,'from_session':p});return{'content':[{'type':_0x4bc984(0xf7),'text':JSON[_0x4bc984(0x153)](_0x44ee77)}]};}if(_0xad1f02===_0x4bc984(0x129)){let _0x21e99d=await Q('get_all_status',{});return{'content':[{'type':_0x4bc984(0xf7),'text':JSON['stringify'](_0x21e99d)}]};}return{'content':[{'type':_0x4bc984(0xf7),'text':JSON['stringify']({'error':_0x4bc984(0x11c)})}]};});var D=0x3e8,v=0x7530,O=0x36ee80;async function m(){const _0x1d9abe=a0_0x3998da;try{await Q(_0x1d9abe(0x126),{'resume_id':V,'alias':p,'status':_0x1d9abe(0x15d),'server':a0_0xd1cc4e(),'hostname':a0_0xd1cc4e(),'agent':_0x1d9abe(0x134),'project_dir':process[_0x1d9abe(0x192)](),'tmux_name':j||void 0x0}),z('re-registered\x20as\x20\x22'+p+_0x1d9abe(0x175));}catch(_0x439e42){z(_0x1d9abe(0x10a)+_0x439e42);}}async function l(){const _0x3cc62f=a0_0x3998da;let _0xea8e30=Y+_0x3cc62f(0x103)+encodeURIComponent(p),_0x53aa0f={};if(k)_0x53aa0f['Authorization']=_0x3cc62f(0x13c)+k;z('connecting\x20to\x20'+_0xea8e30);let _0x4c6ff5=D,_0x5ebb04=!0x0,_0x3c462b=null;while(!0x0){try{let _0xbf13d4=await fetch(_0xea8e30,{'headers':_0x53aa0f});if(!_0xbf13d4['ok']){if(z(_0x3cc62f(0x18e)+_0xbf13d4[_0x3cc62f(0x16a)]+'\x20'+_0xbf13d4[_0x3cc62f(0x112)]),_0x3c462b=_0x3c462b??Date[_0x3cc62f(0x10c)](),Date['now']()-_0x3c462b>O){z('SSE\x20连续\x20>1h\x20连不上\x20hub\x20('+Y+')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。');return;}await i(_0x4c6ff5),_0x4c6ff5=Math['min'](_0x4c6ff5*0x2,v);continue;}let _0x4c11da=_0xbf13d4['body']['getReader'](),_0x5b6ff4=new TextDecoder(),_0x366469='';_0x4c6ff5=D;while(!0x0){let {done:_0x2f6554,value:_0x575fe2}=await _0x4c11da[_0x3cc62f(0xfe)]();if(_0x2f6554)break;_0x366469+=_0x5b6ff4[_0x3cc62f(0x111)](_0x575fe2,{'stream':!0x0});let _0x5b76a2=_0x366469[_0x3cc62f(0x132)]('\x0a\x0a');_0x366469=_0x5b76a2[_0x3cc62f(0x165)]()||'';for(let _0x26f2f6 of _0x5b76a2){let _0x2a5cbf=_0x26f2f6[_0x3cc62f(0x132)]('\x0a')[_0x3cc62f(0x143)](_0x3f56d7=>_0x3f56d7[_0x3cc62f(0x16f)]('data:\x20'));if(!_0x2a5cbf)continue;try{let _0x33d77b=JSON['parse'](_0x2a5cbf[_0x3cc62f(0x193)](0x6));if(await A(_0x33d77b),_0x33d77b[_0x3cc62f(0x107)]===_0x3cc62f(0xf5)){if(_0x3c462b=null,!_0x5ebb04)await m();_0x5ebb04=!0x1;}}catch(_0x308181){z('parse\x20error:\x20'+_0x308181);}}}z('SSE\x20stream\x20ended,\x20reconnecting...');}catch(_0x5f3642){z(_0x3cc62f(0x138)+_0x5f3642);}if(_0x3c462b=_0x3c462b??Date[_0x3cc62f(0x10c)](),Date[_0x3cc62f(0x10c)]()-_0x3c462b>O){z(_0x3cc62f(0x11e)+Y+_0x3cc62f(0x189));return;}await i(_0x4c6ff5),_0x4c6ff5=Math[_0x3cc62f(0x150)](_0x4c6ff5*0x2,v);}}async function A(_0x26c82c){const _0x4fc10b=a0_0x3998da;if(_0x26c82c[_0x4fc10b(0x107)]===_0x4fc10b(0xf5)){z(_0x4fc10b(0x128)+p+'\x22');return;}if(_0x26c82c[_0x4fc10b(0x107)]===_0x4fc10b(0x170)){if(z('←\x20message\x20from\x20'+_0x26c82c[_0x4fc10b(0x163)]+':\x20'+_0x26c82c['message']['slice'](0x0,0x3c)),await K[_0x4fc10b(0x190)]({'method':'notifications/claude/channel','params':{'content':_0x26c82c[_0x4fc10b(0x15f)],'meta':{'sender':_0x26c82c[_0x4fc10b(0x163)]||'hub','sender_id':_0x4fc10b(0x125),'user':_0x26c82c[_0x4fc10b(0x163)]||_0x4fc10b(0x15a),'priority':_0x4fc10b(0x114)}}}),_0x26c82c[_0x4fc10b(0x12e)])await Q(_0x4fc10b(0x14a),{'alias':p,'message_id':_0x26c82c[_0x4fc10b(0x12e)]});return;}if(_0x26c82c[_0x4fc10b(0x107)]==='new_task'||_0x26c82c[_0x4fc10b(0x107)]==='broadcast'){z('←\x20'+_0x26c82c[_0x4fc10b(0x107)]+_0x4fc10b(0xfb)+_0x26c82c['inbox_count']+'\x20priority='+(_0x26c82c[_0x4fc10b(0x152)]||_0x4fc10b(0x114)));let _0x10054b=await Q('get_inbox',{'alias':p,'limit':0x5});if(_0x10054b?.['ok']&&_0x10054b[_0x4fc10b(0x100)]?.[_0x4fc10b(0x102)]>0x0)for(let _0x3c4839 of _0x10054b[_0x4fc10b(0x100)]){let _0x553fd1={'sender':_0x3c4839['from_session']||_0x4fc10b(0x15a),'sender_id':'commhub','user':_0x3c4839[_0x4fc10b(0x16d)]||_0x4fc10b(0x15a),'task_id':_0x3c4839['id'],'priority':_0x3c4839[_0x4fc10b(0x152)]||_0x4fc10b(0x114)};G[_0x4fc10b(0x109)](_0x3c4839['id'],_0x3c4839['from_session']||'hub'),await K[_0x4fc10b(0x190)]({'method':_0x4fc10b(0x147),'params':{'content':_0x3c4839[_0x4fc10b(0x187)],'meta':_0x553fd1}}),z(_0x4fc10b(0x11a)+_0x3c4839['id'][_0x4fc10b(0x193)](0x0,0x8)+'\x20from\x20'+_0x3c4839[_0x4fc10b(0x16d)]+':\x20'+_0x3c4839[_0x4fc10b(0x187)][_0x4fc10b(0x193)](0x0,0x3c)),await Q(_0x4fc10b(0x14a),{'alias':p,'message_id':_0x3c4839['id']});}}}async function t(){const _0x2ef511=a0_0x3998da;let _0x32af90=new a0_0xc4434c();await K[_0x2ef511(0x14e)](_0x32af90),z(_0x2ef511(0x12f)),z(_0x2ef511(0x178)),l()[_0x2ef511(0xf8)](_0x78b2f0=>z(_0x2ef511(0x13e)+_0x78b2f0)),Q(_0x2ef511(0x126),{'resume_id':V,'alias':p,'status':_0x2ef511(0x15d),'server':a0_0xd1cc4e(),'hostname':a0_0xd1cc4e(),'agent':_0x2ef511(0x134),'project_dir':process[_0x2ef511(0x192)](),'tmux_name':j||void 0x0})[_0x2ef511(0x14d)](()=>z(_0x2ef511(0x13d)+p+'\x22\x20('+V['slice'](0x0,0x8)+')'))[_0x2ef511(0xf8)](_0x2948cd=>z(_0x2ef511(0x127)+_0x2948cd)),setInterval(()=>{const _0x52493b=_0x2ef511;Q(_0x52493b(0x126),{'resume_id':V,'alias':p,'status':_0x52493b(0x15d),'server':a0_0xd1cc4e(),'hostname':a0_0xd1cc4e(),'agent':'claude-code','project_dir':process[_0x52493b(0x192)](),'tmux_name':j||void 0x0})[_0x52493b(0xf8)](_0x5311a8=>z(_0x52493b(0x16c)+_0x5311a8));},0x2bf20),z(_0x2ef511(0x177));}t()[a0_0x3998da(0xf8)](_0x219017=>{const _0x3c6010=a0_0x3998da;z(_0x3c6010(0x164)+_0x219017),process[_0x3c6010(0x157)](0x1);});async function b(){const _0x174360=a0_0x3998da;z(_0x174360(0x159)),await Q('report_status',{'resume_id':V,'alias':p,'status':'offline','task':_0x174360(0x131)})[_0x174360(0xf8)](()=>{}),process['exit'](0x0);}process[a0_0x3998da(0x121)]['on'](a0_0x3998da(0x161),()=>b()),process['on'](a0_0x3998da(0x146),()=>b()),process['on'](a0_0x3998da(0x155),()=>b());var d=process['ppid'];if(d&&d>0x1){let h=setInterval(()=>{const _0x1554d0=a0_0x3998da;if(process[_0x1554d0(0x122)]===0x1&&d!==0x1){z(_0x1554d0(0x118)+d+')\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat'),b();return;}try{process[_0x1554d0(0x158)](d,0x0);}catch(_0x325ac9){if(_0x325ac9?.[_0x1554d0(0x10d)]==='ESRCH')z(_0x1554d0(0x171)+d+'\x20no\x20longer\x20exists\x20(kill-0\x20ESRCH)\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat'),b();}},0x7530);if(typeof h[a0_0x3998da(0x182)]===a0_0x3998da(0x135))h[a0_0x3998da(0x182)]();}

@@ -1,2 +0,2 @@

export declare const OPENCODE_AGENT_NETWORK_VERSION = "2.3.0-preview.34";
export declare const OPENCODE_AGENT_NETWORK_VERSION = "2.3.0-preview.36";
export declare const OPENCODE_AGENT_NODE_VERSION = "2.5.0-preview.26";

@@ -3,0 +3,0 @@ export declare const OPENCODE_AGENT_NODE_SPEC = "@sleep2agi/agent-node@2.5.0-preview.26";

{
"name": "@sleep2agi/agent-network",
"version": "2.3.0-preview.35",
"version": "2.3.0-preview.36",
"description": "AI Agent Network CLI — Local-first multi-agent orchestration across 6 runtimes (Claude Code CLI / Claude Agent SDK / Codex SDK / Codex app-server / Grok Build ACP / OpenCode CLI) and 8+ LLM providers. Apache 2.0.",

@@ -5,0 +5,0 @@ "type": "module",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display