@sleep2agi/agent-network 2.3.0-preview.9 → 2.3.0-preview.90

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.
Files changed (113) hide show
  1. package/README.md +35 -324
  2. package/dist/bin/anet.cjs +101 -0
  3. package/dist/bin/cli.d.ts +1 -0
  4. package/dist/bin/cli.js +20 -1
  5. package/dist/bin/goal-wake-log-render.d.ts +31 -0
  6. package/dist/src/active-network-task.d.ts +28 -0
  7. package/dist/src/batch-workdir.d.ts +9 -0
  8. package/dist/src/bootstrap-password-db.d.ts +13 -0
  9. package/dist/src/channel-attachments.d.ts +29 -0
  10. package/dist/src/channel-meta.d.ts +10 -0
  11. package/dist/src/channel-task-trace.d.ts +14 -0
  12. package/dist/src/claude-vendor-env.d.ts +28 -0
  13. package/dist/src/cli-args.d.ts +8 -0
  14. package/dist/src/cli-version-display.d.ts +16 -0
  15. package/dist/src/client-task-trace.d.ts +9 -0
  16. package/dist/src/client.js +1 -1
  17. package/dist/src/codex-copresence-preflight.d.ts +65 -0
  18. package/dist/src/codex-copresence-profile.d.ts +125 -0
  19. package/dist/src/codex-copresence-recovery.d.ts +43 -0
  20. package/dist/src/codex-copresence-thread.d.ts +13 -0
  21. package/dist/src/codex-lifecycle-account.d.ts +104 -0
  22. package/dist/src/codex-lifecycle-canary.d.ts +20 -0
  23. package/dist/src/codex-lifecycle-facts.d.ts +53 -0
  24. package/dist/src/codex-lifecycle-fork.d.ts +53 -0
  25. package/dist/src/codex-lifecycle-preflight.d.ts +77 -0
  26. package/dist/src/codex-lifecycle-receipt.d.ts +44 -0
  27. package/dist/src/codex-lifecycle-restart.d.ts +86 -0
  28. package/dist/src/codex-model-default.d.ts +6 -0
  29. package/dist/src/codex-tui-client-health.d.ts +17 -0
  30. package/dist/src/commhub-response.d.ts +1 -0
  31. package/dist/src/controlled-upload.d.ts +83 -0
  32. package/dist/src/copresence-deps.d.ts +22 -0
  33. package/dist/src/copresence-identity.d.ts +339 -0
  34. package/dist/src/copresence-startup-diagnosis.d.ts +17 -0
  35. package/dist/src/daemon-capability-display.d.ts +110 -0
  36. package/dist/src/daemon-capability-display.js +21 -0
  37. package/dist/src/daemon-runtime-path-preflight.d.ts +22 -0
  38. package/dist/src/daemon-runtime-staleness.d.ts +13 -0
  39. package/dist/src/dashboard-managed-process.d.ts +35 -0
  40. package/dist/src/display-width.d.ts +27 -0
  41. package/dist/src/doctor-node-count.d.ts +28 -0
  42. package/dist/src/environ-alias.d.ts +14 -0
  43. package/dist/src/grok-attach-client.d.ts +129 -0
  44. package/dist/src/grok-build-drift.d.ts +15 -0
  45. package/dist/src/grok-copresence-disclosure.d.ts +11 -0
  46. package/dist/src/grok-copresence-orchestration.d.ts +75 -0
  47. package/dist/src/grok-copresence-profile.d.ts +65 -0
  48. package/dist/src/host-telemetry.d.ts +14 -0
  49. package/dist/src/hub-time-display.d.ts +20 -0
  50. package/dist/src/hub-version-skew.d.ts +19 -0
  51. package/dist/src/im/correlation-store.d.ts +34 -0
  52. package/dist/src/im/feishu/adapter.d.ts +80 -0
  53. package/dist/src/im/feishu/bridge.d.ts +85 -14
  54. package/dist/src/im/feishu/config.d.ts +31 -0
  55. package/dist/src/im/feishu/hub-upload.d.ts +88 -0
  56. package/dist/src/im/feishu/outbound-marker.d.ts +24 -19
  57. package/dist/src/im/feishu/outbound-paths.d.ts +50 -0
  58. package/dist/src/im/feishu/outbound-route.d.ts +62 -0
  59. package/dist/src/im/feishu/worker-lifecycle.d.ts +13 -0
  60. package/dist/src/im/feishu/worker.js +187 -144
  61. package/dist/src/im/types.d.ts +38 -1
  62. package/dist/src/local-process-state.d.ts +12 -0
  63. package/dist/src/locale-diagnostic.d.ts +12 -0
  64. package/dist/src/ls-columns.d.ts +15 -0
  65. package/dist/src/mock-llm.d.ts +12 -0
  66. package/dist/src/node-activity-log.d.ts +4 -0
  67. package/dist/src/node-not-found.d.ts +1 -0
  68. package/dist/src/node-running-guard.d.ts +9 -0
  69. package/dist/src/node-server-payload.d.ts +66 -0
  70. package/dist/src/node-server.js +7 -1
  71. package/dist/src/normalize-runtime.d.ts +29 -2
  72. package/dist/src/offline-age.d.ts +29 -0
  73. package/dist/src/one-line-cell.d.ts +20 -0
  74. package/dist/src/opencode-agent-node-pair.d.ts +25 -0
  75. package/dist/src/opencode-auth-login.d.ts +43 -0
  76. package/dist/src/opencode-launch-env.d.ts +13 -0
  77. package/dist/src/opencode-owner-mode.d.ts +6 -0
  78. package/dist/src/opencode-package-binary.d.ts +26 -0
  79. package/dist/src/opencode-pin.d.ts +44 -0
  80. package/dist/src/opencode-preset.d.ts +73 -0
  81. package/dist/src/opencode-runtime-binding.d.ts +30 -0
  82. package/dist/src/opencode-safe-root.d.ts +36 -0
  83. package/dist/src/opencode-smoke-env.d.ts +1 -0
  84. package/dist/src/outbound-attachments.d.ts +57 -0
  85. package/dist/src/outbound-tool-names.d.ts +1 -0
  86. package/dist/src/owned-roots.d.ts +58 -0
  87. package/dist/src/owner-env-file.d.ts +2 -0
  88. package/dist/src/package-mode-preflight.d.ts +41 -0
  89. package/dist/src/posix-codex-copresence.d.ts +8 -0
  90. package/dist/src/posix-modes.d.ts +36 -0
  91. package/dist/src/primary-network.d.ts +23 -0
  92. package/dist/src/private-state.d.ts +10 -0
  93. package/dist/src/process-telemetry.d.ts +12 -0
  94. package/dist/src/profile-serialize.d.ts +1 -0
  95. package/dist/src/project-key.d.ts +1 -0
  96. package/dist/src/reply-originator.d.ts +20 -0
  97. package/dist/src/resume-runtime-infer.d.ts +18 -0
  98. package/dist/src/secret-shell-guidance.d.ts +3 -0
  99. package/dist/src/session-status-class.d.ts +48 -0
  100. package/dist/src/sibling-agent-node.d.ts +23 -0
  101. package/dist/src/stale-socket.d.ts +118 -0
  102. package/dist/src/subcommand-redirect.d.ts +26 -0
  103. package/dist/src/task-trace.d.ts +33 -0
  104. package/dist/src/tmux-attach.d.ts +8 -0
  105. package/dist/src/tmux-capability.d.ts +58 -0
  106. package/dist/src/tmux-exact-target.d.ts +34 -0
  107. package/dist/src/tmux-pane-prompt.d.ts +22 -0
  108. package/dist/src/token-cli.d.ts +13 -0
  109. package/dist/src/tool-allowlist.d.ts +28 -0
  110. package/dist/src/unsafe-package-path-reason.d.ts +17 -0
  111. package/dist/src/win-launcher.d.ts +20 -0
  112. package/dist/src/windows-codex-copresence.d.ts +60 -0
  113. package/package.json +10 -5
@@ -0,0 +1,31 @@
1
+ export interface WakeLogEntryShape {
2
+ ts?: string;
3
+ status?: string;
4
+ summary?: string;
5
+ task_id?: string;
6
+ }
7
+ export interface WakeLogGoalShape {
8
+ goal_id: string;
9
+ progress_log?: WakeLogEntryShape[];
10
+ }
11
+ export interface WakeLogRenderOpts {
12
+ /** Trim to the last N entries. undefined = all. */
13
+ tail?: number;
14
+ }
15
+ /**
16
+ * Format progress_log as a JSON object suitable for `--json` output.
17
+ * Pure. Never reads/writes filesystem. Legacy goals without
18
+ * progress_log render as empty array (not error).
19
+ */
20
+ export declare function renderWakeLogJson(goal: WakeLogGoalShape, opts?: WakeLogRenderOpts): {
21
+ goal_id: string;
22
+ total: number;
23
+ returned: number;
24
+ entries: WakeLogEntryShape[];
25
+ };
26
+ /**
27
+ * Format progress_log as a table for human console output.
28
+ * Column layout mirrors printGoalShow so the two commands read
29
+ * consistently. Empty log renders a single "(none)" line, not an error.
30
+ */
31
+ export declare function renderWakeLogText(goal: WakeLogGoalShape, opts?: WakeLogRenderOpts): string;
@@ -0,0 +1,28 @@
1
+ export interface ActiveNetworkTask {
2
+ taskId: string;
3
+ from: string;
4
+ startedAt: number;
5
+ }
6
+ /** 运行时崩溃没来得及删标记时的兜底:超过这个年龄的标记当不存在。 */
7
+ export declare const ACTIVE_NETWORK_TASK_MAX_AGE_MS: number;
8
+ export declare function parseActiveNetworkTask(raw: string | null | undefined, now: number, maxAgeMs?: number): ActiveNetworkTask | null;
9
+ export type OutboundTool = "commhub_send_task" | "commhub_send_message";
10
+ export type OutboundRewrite = {
11
+ kind: "pass";
12
+ } | {
13
+ kind: "progress_of_active_task";
14
+ taskId: string;
15
+ from: string;
16
+ text: string;
17
+ };
18
+ /**
19
+ * 只在「目标 alias 恰好是当前网络任务的发起方」时改写;发给别人的照常放行——
20
+ * 模型替任务派活给第三方是合法的协作,不能一刀切。
21
+ */
22
+ export declare function decideOutboundRewrite(tool: OutboundTool, args: {
23
+ alias?: unknown;
24
+ task?: unknown;
25
+ message?: unknown;
26
+ } | null | undefined, active: ActiveNetworkTask | null): OutboundRewrite;
27
+ /** outbound-only 模式下模型不能自选 high(#1770 第三条):降为 normal,其余原样。 */
28
+ export declare function clampOutboundPriority(priority: unknown, outboundOnly: boolean): "high" | "normal" | "low" | undefined;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Resolve one batch workdir before any mkdir/chdir loop starts.
3
+ *
4
+ * Node does not expand shell tildes. Leaving `~/team` relative means every
5
+ * iteration can resolve it from the previous node's cwd and create paths such
6
+ * as `/work/~/team/~/team`. Only the current user's `~` form is supported;
7
+ * `~other` is rejected instead of being written as a literal directory.
8
+ */
9
+ export declare function normalizeBatchWorkdir(input: string, cwd?: string, home?: string): string;
@@ -0,0 +1,13 @@
1
+ export interface BootstrapPasswordUpdateInvocation {
2
+ argv: string[];
3
+ env: NodeJS.ProcessEnv;
4
+ script: string;
5
+ }
6
+ /**
7
+ * Resolve the database selected for the local Hub into an explicit absolute
8
+ * path before launching the bootstrap helper. The helper must never infer a
9
+ * database from its own HOME/cwd: those can differ from the parent process.
10
+ */
11
+ export declare function resolveBootstrapDatabasePath(env: NodeJS.ProcessEnv, home: string, cwd: string): string;
12
+ export declare const BOOTSTRAP_PASSWORD_UPDATE_SCRIPT: string;
13
+ export declare function buildBootstrapPasswordUpdateInvocation(userId: string, dbPath: string, baseEnv?: NodeJS.ProcessEnv): BootstrapPasswordUpdateInvocation;
@@ -0,0 +1,29 @@
1
+ interface AttachmentDescriptor {
2
+ type?: unknown;
3
+ file_id?: unknown;
4
+ path?: unknown;
5
+ mime?: unknown;
6
+ name?: unknown;
7
+ size?: unknown;
8
+ }
9
+ export interface ChannelAttachmentDeps {
10
+ hubUrl: string;
11
+ authToken: string;
12
+ cacheDir: string;
13
+ fetch?: typeof fetch;
14
+ maxBytes?: number;
15
+ }
16
+ export interface ChannelAttachmentResult {
17
+ paths: string[];
18
+ failures: Array<{
19
+ fileId: string;
20
+ code: string;
21
+ message: string;
22
+ }>;
23
+ }
24
+ export declare function readableAttachmentsFromInbox(message: any): AttachmentDescriptor[];
25
+ export declare function channelAttachmentCacheDir(home: string, alias: string): string;
26
+ export declare function downloadChannelAttachments(message: any, deps: ChannelAttachmentDeps): Promise<ChannelAttachmentResult>;
27
+ export declare const downloadChannelImageAttachments: typeof downloadChannelAttachments;
28
+ export declare function appendChannelAttachmentPaths(content: string, paths: readonly string[]): string;
29
+ export {};
@@ -0,0 +1,10 @@
1
+ /** One inbound inbox row → the meta Claude Code renders as `<channel …>` attrs.
2
+ *
3
+ * Pure so the attribute set is assertable; it used to be inline in the SSE
4
+ * handler, where nothing could see it. */
5
+ export declare function inboundChannelMeta(msg: {
6
+ id: string;
7
+ from_session?: string | null;
8
+ priority?: string | null;
9
+ created_at?: string | null;
10
+ }): Record<string, string>;
@@ -0,0 +1,14 @@
1
+ export declare function sendChannelTaskWithTrace(input: {
2
+ alias: string;
3
+ task: string;
4
+ priority?: string;
5
+ fromAlias: string;
6
+ networkId?: string | null;
7
+ /** Structured task metadata forwarded verbatim, e.g. { attachments: [...] }.
8
+ * Omitted from the outbound body when absent, so a call without it is
9
+ * unchanged. */
10
+ meta?: Record<string, unknown>;
11
+ }, deps: {
12
+ send: (args: Record<string, unknown>) => Promise<any>;
13
+ log: (line: string) => void;
14
+ }): Promise<any>;
@@ -0,0 +1,28 @@
1
+ export declare const CLAUDE_VENDOR_ENV_KEYS: readonly ["ANTHROPIC_BASE_URL", "ANTHROPIC_AUTH_TOKEN", "ANTHROPIC_API_KEY"];
2
+ export type PlainSecretEnvRewrite = {
3
+ key: string;
4
+ refName: string;
5
+ value: string;
6
+ };
7
+ /**
8
+ * Plan the values that the node-create writer will move into its line-oriented
9
+ * `.env` file. This is deliberately side-effect free: callers can run it as a
10
+ * preflight before creating a node directory, changing process.env, or writing
11
+ * config.json. Keeping the line-break rejection here makes it cover every
12
+ * caller of the dotenv writer, including the no-name interactive wizard.
13
+ */
14
+ export declare function planPlainSecretEnvRewrites(input: {
15
+ env: unknown;
16
+ nodeId: string;
17
+ }): PlainSecretEnvRewrite[];
18
+ /**
19
+ * Persist the exact Anthropic-compatible vendor environment used by an
20
+ * explicit claude-agent-sdk create. Explicit --env values retain precedence;
21
+ * ambient shell values only fill missing known keys. Other environment values
22
+ * are intentionally ignored so node create never snapshots the whole shell.
23
+ */
24
+ export declare function collectClaudeVendorEnvForCreate(input: {
25
+ runtime: string;
26
+ explicitEnv: readonly string[];
27
+ shellEnv: Readonly<Record<string, string | undefined>>;
28
+ }): string[];
@@ -0,0 +1,8 @@
1
+ export type ParsedCliOptions = {
2
+ [key: string]: string | string[];
3
+ _channels: string[];
4
+ _envs: string[];
5
+ };
6
+ export declare const BOOLEAN_FLAGS: Set<string>;
7
+ export declare function parseCliOptions(argv: string[]): ParsedCliOptions;
8
+ export declare function positionalArgs(argv: string[]): string[];
@@ -0,0 +1,16 @@
1
+ /**
2
+ * #1645 —— `anet doctor` 原先对三个 runtime CLI **只检查「在不在」**:
3
+ *
4
+ * try { execSync("codex --version", …); check("Codex CLI", true); } catch { … }
5
+ *
6
+ * 于是一个**装着、但太旧**的 CLI 会拿到一个 ✅。实测过一次:`codex-cli 0.149.1`
7
+ * 解不动上游 models 响应(`unknown variant \`max\``,它只认到 `xhigh`),
8
+ * rmcp worker 致命退出,用户看到的是 300s 超时 —— 而 doctor 说一切正常。
9
+ *
10
+ * 🔴 **这里只把版本摆出来,不做最低版本判定。**
11
+ * 「多少版本才够」由上游返回什么决定,不是我们能钉死的常量;猜一个下限,
12
+ * 会在别人升级 CLI、上游又改动之后变成误报。而一个会误报的检查,
13
+ * 第一周就会被人关掉。摆出实际版本,让读的人自己对得上号,是这一格
14
+ * 现在能诚实做到的全部。
15
+ */
16
+ export declare function formatCliVersion(raw: unknown): string;
@@ -0,0 +1,9 @@
1
+ export declare function sendClientTaskWithTrace(input: {
2
+ alias: string;
3
+ fromAlias: string;
4
+ parentTaskId?: string | null;
5
+ networkId?: string | null;
6
+ }, dependencies: {
7
+ send: () => Promise<any>;
8
+ log: (line: string) => void;
9
+ }): Promise<any>;
@@ -1 +1 @@
1
- const a0_0x5920d3=a0_0x16ff;(function(_0x2ba291,_0x1e2095){const _0x4ffd6f=a0_0x16ff,_0x24cf74=_0x2ba291();while(!![]){try{const _0x494620=parseInt(_0x4ffd6f(0x210))/0x1*(parseInt(_0x4ffd6f(0x206))/0x2)+-parseInt(_0x4ffd6f(0x22d))/0x3+parseInt(_0x4ffd6f(0x1e6))/0x4*(-parseInt(_0x4ffd6f(0x21e))/0x5)+parseInt(_0x4ffd6f(0x220))/0x6*(parseInt(_0x4ffd6f(0x22c))/0x7)+-parseInt(_0x4ffd6f(0x215))/0x8*(-parseInt(_0x4ffd6f(0x1d8))/0x9)+-parseInt(_0x4ffd6f(0x20f))/0xa*(-parseInt(_0x4ffd6f(0x20b))/0xb)+-parseInt(_0x4ffd6f(0x20e))/0xc;if(_0x494620===_0x1e2095)break;else _0x24cf74['push'](_0x24cf74['shift']());}catch(_0x1fb59b){_0x24cf74['push'](_0x24cf74['shift']());}}}(a0_0x1d84,0x5cc6a));function a0_0x16ff(_0x2bd2c0,_0x1bf401){_0x2bd2c0=_0x2bd2c0-0x1d8;const _0x1d84fe=a0_0x1d84();let _0x16ff51=_0x1d84fe[_0x2bd2c0];return _0x16ff51;}import{EventEmitter as a0_0x302ef1}from'events';function a0_0x1d84(){const _0x4a5a59=['application/json,\x20text/event-stream','alias','705krKHwc','get_all_status','351228KPOtwm','s...','match','token','broadcast','url','call','SSE\x20reconnecting\x20in\x20','POST','tools/call','text/event-stream','signal','28SICtSD','140412SGeGSj','disconnected','send_task','connected','read','531JsuzXG','disconnect','toTimeString','heartbeatInterval','report_status','inbox\x20error:\x20','data:\x20','/mcp','stringify','slice','sdk','processInbox','now','normal','10936cbUyUZ','offline','min','getReader','cwd','parse','catch','Bearer\x20','registered','message','SSE\x20error:\x20','status','toString','resumeId','content','connect','new_task','from_session','log','new_message','send_reply','getAllStatus','messages','AbortError','autoConnect','sseAbort','connectSSE','text','sleep','type','startsWith','/events/','8anUVCl','emit','agent','completed','send_message','11YGRDNc','Authorization','reconnectDelay','8968332JGzJBc','4836790IREQic','184529cLDiAv','split','heartbeatTimer','name','send','14064aPspDd','body','running','2.0','idle','decode','sdk-'];a0_0x1d84=function(){return _0x4a5a59;};return a0_0x1d84();}import{hostname as a0_0x2755ad}from'os';class T extends a0_0x302ef1{['url'];[a0_0x5920d3(0x21d)];['token'];[a0_0x5920d3(0x208)];[a0_0x5920d3(0x1f3)];['heartbeatInterval'];[a0_0x5920d3(0x20d)];[a0_0x5920d3(0x212)];[a0_0x5920d3(0x1ff)];['running']=!0x1;constructor(_0x5f2f64){const _0x12a96f=a0_0x5920d3;super();if(this[_0x12a96f(0x225)]=_0x5f2f64[_0x12a96f(0x225)]['replace'](/\/$/,''),this[_0x12a96f(0x21d)]=_0x5f2f64[_0x12a96f(0x21d)],this[_0x12a96f(0x223)]=_0x5f2f64[_0x12a96f(0x223)],this[_0x12a96f(0x208)]=_0x5f2f64['agent']||_0x12a96f(0x1e2),this[_0x12a96f(0x1f3)]=_0x12a96f(0x21b)+_0x5f2f64[_0x12a96f(0x21d)]+'-'+Date[_0x12a96f(0x1e4)]()[_0x12a96f(0x1f2)](0x24),this[_0x12a96f(0x1db)]=_0x5f2f64['heartbeatInterval']??0x2bf20,this[_0x12a96f(0x20d)]=_0x5f2f64[_0x12a96f(0x20d)]??0xbb8,_0x5f2f64[_0x12a96f(0x1fe)]!==!0x1)this['connect']();}[a0_0x5920d3(0x1f8)](_0x1c820b){const _0x51a463=a0_0x5920d3;console[_0x51a463(0x1f8)]('['+new Date()[_0x51a463(0x1da)]()[_0x51a463(0x1e1)](0x0,0x8)+']\x20[commhub:'+this['alias']+']\x20'+_0x1c820b);}async[a0_0x5920d3(0x226)](_0x510e92,_0x16eb96){const _0xde81c6=a0_0x5920d3;let _0x29b431={'Content-Type':'application/json','Accept':_0xde81c6(0x21c)};if(this[_0xde81c6(0x223)])_0x29b431[_0xde81c6(0x20c)]=_0xde81c6(0x1ed)+this[_0xde81c6(0x223)];let _0x362ba8=await(await fetch(this[_0xde81c6(0x225)]+_0xde81c6(0x1df),{'method':_0xde81c6(0x228),'headers':_0x29b431,'body':JSON[_0xde81c6(0x1e0)]({'jsonrpc':_0xde81c6(0x218),'id':Date[_0xde81c6(0x1e4)](),'method':_0xde81c6(0x229),'params':{'name':_0x510e92,'arguments':_0x16eb96}})}))[_0xde81c6(0x201)](),_0x2e5516=_0x362ba8[_0xde81c6(0x222)](/data: (.+)/),_0x3d67c1=_0x2e5516?JSON[_0xde81c6(0x1eb)](_0x2e5516[0x1]):JSON['parse'](_0x362ba8),_0x2607c=_0x3d67c1?.['result']?.[_0xde81c6(0x1f4)]?.[0x0]?.[_0xde81c6(0x201)];return _0x2607c?JSON[_0xde81c6(0x1eb)](_0x2607c):_0x3d67c1;}async[a0_0x5920d3(0x1f5)](){const _0x3747bf=a0_0x5920d3;if(this[_0x3747bf(0x217)])return;this[_0x3747bf(0x217)]=!0x0,await this['status'](_0x3747bf(0x219)),this[_0x3747bf(0x1f8)](_0x3747bf(0x1ee)),this['heartbeatTimer']=setInterval(()=>{const _0xd4119b=_0x3747bf;this[_0xd4119b(0x1f1)](_0xd4119b(0x219))[_0xd4119b(0x1ec)](_0x19410a=>this[_0xd4119b(0x1f8)]('heartbeat\x20failed:\x20'+_0x19410a[_0xd4119b(0x1ef)]));},this[_0x3747bf(0x1db)]),this['connectSSE']();}async[a0_0x5920d3(0x1d9)](){const _0x3b0abc=a0_0x5920d3;if(this[_0x3b0abc(0x217)]=!0x1,this[_0x3b0abc(0x1ff)]?.['abort'](),this[_0x3b0abc(0x212)])clearInterval(this[_0x3b0abc(0x212)]);await this[_0x3b0abc(0x1f1)](_0x3b0abc(0x1e7))[_0x3b0abc(0x1ec)](()=>{}),this[_0x3b0abc(0x1f8)](_0x3b0abc(0x22e));}async[a0_0x5920d3(0x214)](_0x172e8d,_0x4ee915,_0x520465=a0_0x5920d3(0x1e5)){const _0x496136=a0_0x5920d3;return this[_0x496136(0x226)](_0x496136(0x22f),{'alias':_0x172e8d,'task':_0x4ee915,'priority':_0x520465,'from_session':this[_0x496136(0x21d)]});}async[a0_0x5920d3(0x1ef)](_0x5dd07a,_0x1d1ce3){const _0x5f1bab=a0_0x5920d3;return this[_0x5f1bab(0x226)](_0x5f1bab(0x20a),{'alias':_0x5dd07a,'message':_0x1d1ce3,'from_session':this['alias']});}async['reply'](_0x12a01c,_0x87fda4,_0x466014=a0_0x5920d3(0x209)){const _0x2d5f9a=a0_0x5920d3;return this[_0x2d5f9a(0x226)](_0x2d5f9a(0x1fa),{'in_reply_to':_0x12a01c,'text':_0x87fda4,'status':_0x466014});}async[a0_0x5920d3(0x1f1)](_0x26fef4,_0xd4c06c){const _0x120180=a0_0x5920d3;return this[_0x120180(0x226)](_0x120180(0x1dc),{'resume_id':this[_0x120180(0x1f3)],'alias':this[_0x120180(0x21d)],'status':_0x26fef4,'server':a0_0x2755ad(),'hostname':a0_0x2755ad(),'agent':this[_0x120180(0x208)],'project_dir':process[_0x120180(0x1ea)](),..._0xd4c06c});}async[a0_0x5920d3(0x1fb)](){const _0x1d9c4e=a0_0x5920d3;return this[_0x1d9c4e(0x226)](_0x1d9c4e(0x21f),{});}async[a0_0x5920d3(0x224)](_0x58200f,_0x22c77d){const _0x50a4ec=a0_0x5920d3;return this[_0x50a4ec(0x226)](_0x50a4ec(0x224),{'message':_0x58200f,'filter_server':_0x22c77d?.['server'],'filter_status':_0x22c77d?.[_0x50a4ec(0x1f1)]});}async[a0_0x5920d3(0x200)](){const _0x47cb57=a0_0x5920d3;let _0x560cc2=encodeURIComponent(this['alias']),_0x4841a1=this[_0x47cb57(0x225)]+_0x47cb57(0x205)+_0x560cc2,_0x12cd58=this[_0x47cb57(0x20d)];while(this[_0x47cb57(0x217)]){try{this[_0x47cb57(0x1ff)]=new AbortController();let _0x35d2c6={'Accept':_0x47cb57(0x22a)};if(this[_0x47cb57(0x223)])_0x35d2c6['Authorization']=_0x47cb57(0x1ed)+this[_0x47cb57(0x223)];let _0x34a2cc=await fetch(_0x4841a1,{'headers':_0x35d2c6,'signal':this[_0x47cb57(0x1ff)][_0x47cb57(0x22b)]});if(!_0x34a2cc['ok']||!_0x34a2cc[_0x47cb57(0x216)]){this['log']('SSE\x20failed:\x20'+_0x34a2cc['status']),await this[_0x47cb57(0x202)](_0x12cd58),_0x12cd58=Math['min'](_0x12cd58*1.5,0xea60);continue;}_0x12cd58=this[_0x47cb57(0x20d)];let _0x54d9bc=_0x34a2cc['body'][_0x47cb57(0x1e9)](),_0x44e986=new TextDecoder(),_0x214d83='';while(this[_0x47cb57(0x217)]){let {done:_0x3256bd,value:_0x33943a}=await _0x54d9bc[_0x47cb57(0x231)]();if(_0x3256bd)break;_0x214d83+=_0x44e986[_0x47cb57(0x21a)](_0x33943a,{'stream':!0x0});let _0x5eac3f=_0x214d83[_0x47cb57(0x211)]('\x0a');_0x214d83=_0x5eac3f['pop']()||'';for(let _0x1dc067 of _0x5eac3f){if(!_0x1dc067[_0x47cb57(0x204)](_0x47cb57(0x1de)))continue;try{let _0x8c8d76=JSON[_0x47cb57(0x1eb)](_0x1dc067[_0x47cb57(0x1e1)](0x6));if(_0x8c8d76[_0x47cb57(0x203)]==='connected'){this[_0x47cb57(0x1f8)]('SSE\x20connected'),this[_0x47cb57(0x207)](_0x47cb57(0x230));continue;}if(_0x8c8d76[_0x47cb57(0x203)]===_0x47cb57(0x1f6)||_0x8c8d76[_0x47cb57(0x203)]===_0x47cb57(0x1f9)||_0x8c8d76[_0x47cb57(0x203)]===_0x47cb57(0x224))await this[_0x47cb57(0x1e3)]();}catch{}}}}catch(_0x169a25){if(_0x169a25[_0x47cb57(0x213)]===_0x47cb57(0x1fd))break;this[_0x47cb57(0x207)]('error',_0x169a25),this[_0x47cb57(0x1f8)](_0x47cb57(0x1f0)+_0x169a25[_0x47cb57(0x1ef)]);}if(this[_0x47cb57(0x217)])this[_0x47cb57(0x207)](_0x47cb57(0x22e)),this[_0x47cb57(0x1f8)](_0x47cb57(0x227)+_0x12cd58/0x3e8+_0x47cb57(0x221)),await this['sleep'](_0x12cd58),_0x12cd58=Math[_0x47cb57(0x1e8)](_0x12cd58*1.5,0xea60);}}async['processInbox'](){const _0x60277b=a0_0x5920d3;try{let _0x30d1eb=(await this[_0x60277b(0x226)]('get_inbox',{'alias':this[_0x60277b(0x21d)],'limit':0xa}))?.[_0x60277b(0x1fc)]||[];for(let _0x8a5294 of _0x30d1eb)await this[_0x60277b(0x226)]('ack_inbox',{'alias':this[_0x60277b(0x21d)],'message_id':_0x8a5294['id']}),this[_0x60277b(0x1f8)]('←\x20'+_0x8a5294[_0x60277b(0x1f7)]+':\x20'+_0x8a5294[_0x60277b(0x1f4)][_0x60277b(0x1e1)](0x0,0x3c)),this[_0x60277b(0x207)]('task',_0x8a5294),this[_0x60277b(0x207)](_0x60277b(0x1ef),_0x8a5294);}catch(_0x1597fe){this[_0x60277b(0x1f8)](_0x60277b(0x1dd)+_0x1597fe['message']);}}[a0_0x5920d3(0x202)](_0x11d201){return new Promise(_0x3186f5=>setTimeout(_0x3186f5,_0x11d201));}}var $=T;export{$ as default,T as CommHub};
1
+ const a0_0x50df69=a0_0x6d08;(function(_0x31dedc,_0x58d114){const _0x29e3c0=a0_0x6d08,_0x16fb4f=_0x31dedc();while(!![]){try{const _0x1d2a7d=parseInt(_0x29e3c0(0x1c4))/0x1*(-parseInt(_0x29e3c0(0x1d0))/0x2)+-parseInt(_0x29e3c0(0x1d2))/0x3*(-parseInt(_0x29e3c0(0x1a8))/0x4)+parseInt(_0x29e3c0(0x1a0))/0x5+parseInt(_0x29e3c0(0x16b))/0x6+parseInt(_0x29e3c0(0x1c3))/0x7+-parseInt(_0x29e3c0(0x1b0))/0x8+-parseInt(_0x29e3c0(0x1ae))/0x9*(parseInt(_0x29e3c0(0x1da))/0xa);if(_0x1d2a7d===_0x58d114)break;else _0x16fb4f['push'](_0x16fb4f['shift']());}catch(_0x1b50af){_0x16fb4f['push'](_0x16fb4f['shift']());}}}(a0_0x5250,0x35a3c));function a0_0x6d08(_0x41486a,_0x42ad7c){_0x41486a=_0x41486a-0x15d;const _0x525039=a0_0x5250();let _0x6d08c9=_0x525039[_0x41486a];return _0x6d08c9;}import{EventEmitter as a0_0x522963}from'events';function a0_0x5250(){const _0x4159cb=['lifecycleTracking','token','\x20transport=','reply','cwd','<unknown>','1457034CqJdlj','getReader','POST','get_all_status','send_message','<pending>','pop','toAlias','Bearer\x20','messages','application/json','agent','error_message','sdk-','Authorization','sleep','/events/','mcp_http','send_reply','\x20duration_ms=','resumeId','\x20lifecycle=','match','\x20task_id=','parentTaskId','emit','heartbeatInterval','completed','duration_ms','SSE\x20failed:\x20','send','new_task','body','disconnected','message_id','heartbeat\x20failed:\x20','unknown\x20error','getAllStatus','application/json,\x20text/event-stream','connected','\x20from=','reconnectDelay','send_task','normal','s...','server','delivered','CommHub\x20response\x20omitted\x20task_id','message','stringify','error_code','[REDACTED]','parse','495785rseDXk','get_inbox','type','url','<missing>','disconnect','tools/call','sdk','5316VIntJT','task.send.failed','error','json',']\x20[commhub:','not_tracked','9tzykLE','SSE\x20connected','2293328JJAHwR','fromAlias','processInbox','SSE\x20reconnecting\x20in\x20','\x20to=','lifecycle_tracking','task.send.delivered','transport','\x20parent_task_id=','task_id','catch','failed','sseAbort','task.ack','min','content','call','alias','/mcp','1398845gJPrQQ','1sMyzmX','offline','startsWith','task.replied','data:\x20','parent_task_id','toTimeString','missing_task_id','heartbeatTimer','log','status','split','397778CRkVvl','now','957XDNPzz','slice','\x20error=','connect','autoConnect','send_rejected','idle','to_alias','2605190OHdgkD','replace','\x20network_id=','text','task','running','network_id','string','networkId','connectSSE','send_failed'];a0_0x5250=function(){return _0x4159cb;};return a0_0x5250();}import{hostname as a0_0x21b1e0}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x2ad2cb,_0x44ae8d)=>(_0x2ad2cb??_0x44ae8d)[a0_0x50df69(0x1db)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0xb6c746){const _0x73a7b=a0_0x50df69;return(_0xb6c746 instanceof Error?_0xb6c746[_0x73a7b(0x19b)]:String(_0xb6c746??_0x73a7b(0x18f)))[_0x73a7b(0x1db)](K,_0x73a7b(0x19e))[_0x73a7b(0x1db)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x73a7b(0x1d3)](0x0,0xf0);}function O(_0x491582,_0xbe8889=process.env.ANET_TASK_TRACE_FORMAT===a0_0x50df69(0x1ab)){const _0x5446ec=a0_0x50df69;if(_0xbe8889)return JSON['stringify'](_0x491582);let _0x483fea=L(_0x491582[_0x5446ec(0x1c9)],_0x5446ec(0x1a4)),_0x376ee3=L(_0x491582['task_id'],_0x5446ec(0x170)),_0x3ecec0=_0x491582[_0x5446ec(0x19d)]?_0x5446ec(0x1d4)+_0x491582[_0x5446ec(0x19d)]+':'+(_0x491582[_0x5446ec(0x177)]??''):'';return'[commhub:task]\x20'+_0x491582[_0x5446ec(0x1ce)]+_0x5446ec(0x193)+L(_0x491582['from_alias'],_0x5446ec(0x16a))+_0x5446ec(0x1b4)+L(_0x491582[_0x5446ec(0x1d9)],_0x5446ec(0x16a))+_0x5446ec(0x182)+_0x376ee3+_0x5446ec(0x1b8)+_0x483fea+_0x5446ec(0x1dc)+L(_0x491582[_0x5446ec(0x160)],_0x5446ec(0x16a))+_0x5446ec(0x167)+_0x491582['transport']+_0x5446ec(0x17e)+_0x491582[_0x5446ec(0x187)]+_0x5446ec(0x180)+_0x491582[_0x5446ec(0x1b5)]+_0x3ecec0;}function U(_0x1c9827){const _0x2694d2=a0_0x50df69;return{'event':{'sending':'task.send.start','delivered':_0x2694d2(0x1b6),'failed':_0x2694d2(0x1a9),'acked':_0x2694d2(0x1bd),'started':'task.started','replied':_0x2694d2(0x1c7),'expired':'task.expired'}[_0x1c9827[_0x2694d2(0x1ce)]],..._0x1c9827};}function j(_0x4a8db1){const _0x5199fa=a0_0x50df69;let _0x32a36e=_0x4a8db1?.[_0x5199fa(0x1b9)]||_0x4a8db1?.[_0x5199fa(0x18d)]||_0x4a8db1?.['id'];if(_0x32a36e)return String(_0x32a36e);let _0x16a0d1=_0x4a8db1?.[_0x5199fa(0x1bf)]?.[0x0]?.[_0x5199fa(0x15d)];if(typeof _0x16a0d1!==_0x5199fa(0x161))return null;try{let _0x522ec6=JSON[_0x5199fa(0x19f)](_0x16a0d1);return _0x522ec6?.[_0x5199fa(0x1b9)]||_0x522ec6?.[_0x5199fa(0x18d)]||_0x522ec6?.['id']||null;}catch{return null;}}async function X(_0x184542,_0x5a5a2d){const _0x208c13=a0_0x50df69;let _0x4d187a=_0x5a5a2d['now']??Date[_0x208c13(0x1d1)],_0x2df1b7=_0x4d187a(),_0x11e44f=(_0x40653f,_0x5d868a,_0x415f0b,_0x287a1c)=>{const _0x1f3b2a=_0x208c13;_0x5a5a2d[_0x1f3b2a(0x1cd)](O(U({'from_alias':_0x184542['fromAlias'],'to_alias':_0x184542[_0x1f3b2a(0x172)],'task_id':_0x5d868a,'parent_task_id':_0x184542[_0x1f3b2a(0x183)],'network_id':_0x184542['networkId'],'transport':_0x184542[_0x1f3b2a(0x1b7)],'status':_0x40653f,'duration_ms':_0x4d187a()-_0x2df1b7,'lifecycle_tracking':_0x184542[_0x1f3b2a(0x165)],..._0x415f0b!==void 0x0?{'error_code':_0x287a1c||_0x1f3b2a(0x164),'error_message':N(_0x415f0b)}:{}})));};_0x11e44f('sending',null);try{let _0x5b4f99=await _0x5a5a2d['send'](),_0x2e0ce8=j(_0x5b4f99);if(_0x2e0ce8)_0x11e44f(_0x208c13(0x199),_0x2e0ce8);else{if(_0x5b4f99?.['ok']===!0x1||_0x5b4f99?.[_0x208c13(0x1aa)])_0x11e44f('failed',_0x2e0ce8,_0x5b4f99?.[_0x208c13(0x1aa)]||'CommHub\x20rejected\x20task',_0x208c13(0x1d7));else _0x11e44f(_0x208c13(0x1bb),null,_0x208c13(0x19a),_0x208c13(0x1cb));}return _0x5b4f99;}catch(_0x43d20b){throw _0x11e44f(_0x208c13(0x1bb),null,_0x43d20b,_0x208c13(0x164)),_0x43d20b;}}async function Y(_0x37120d,_0x134c0c){const _0x1a2310=a0_0x50df69;return X({'fromAlias':_0x37120d[_0x1a2310(0x1b1)],'toAlias':_0x37120d[_0x1a2310(0x1c1)],'parentTaskId':_0x37120d[_0x1a2310(0x183)]||null,'networkId':_0x37120d[_0x1a2310(0x162)]||null,'transport':_0x1a2310(0x17c),'lifecycleTracking':_0x1a2310(0x1ad)},_0x134c0c);}class $ extends a0_0x522963{[a0_0x50df69(0x1a3)];['alias'];[a0_0x50df69(0x166)];[a0_0x50df69(0x176)];[a0_0x50df69(0x17f)];[a0_0x50df69(0x185)];[a0_0x50df69(0x194)];[a0_0x50df69(0x1cc)];[a0_0x50df69(0x1bc)];[a0_0x50df69(0x15f)]=!0x1;constructor(_0x1a8091){const _0x52b8ae=a0_0x50df69;super();if(this[_0x52b8ae(0x1a3)]=_0x1a8091[_0x52b8ae(0x1a3)][_0x52b8ae(0x1db)](/\/$/,''),this[_0x52b8ae(0x1c1)]=_0x1a8091[_0x52b8ae(0x1c1)],this[_0x52b8ae(0x166)]=_0x1a8091[_0x52b8ae(0x166)],this[_0x52b8ae(0x176)]=_0x1a8091['agent']||_0x52b8ae(0x1a7),this[_0x52b8ae(0x17f)]=_0x52b8ae(0x178)+_0x1a8091['alias']+'-'+Date['now']()['toString'](0x24),this[_0x52b8ae(0x185)]=_0x1a8091[_0x52b8ae(0x185)]??0x2bf20,this[_0x52b8ae(0x194)]=_0x1a8091[_0x52b8ae(0x194)]??0xbb8,_0x1a8091[_0x52b8ae(0x1d6)]!==!0x1)this[_0x52b8ae(0x1d5)]();}[a0_0x50df69(0x1cd)](_0x48a12b){const _0xc28632=a0_0x50df69;console[_0xc28632(0x1cd)]('['+new Date()[_0xc28632(0x1ca)]()[_0xc28632(0x1d3)](0x0,0x8)+_0xc28632(0x1ac)+this[_0xc28632(0x1c1)]+']\x20'+_0x48a12b);}async[a0_0x50df69(0x1c0)](_0x5e3876,_0x1bf066){const _0x16eec7=a0_0x50df69;let _0x4d30d6={'Content-Type':_0x16eec7(0x175),'Accept':_0x16eec7(0x191)};if(this['token'])_0x4d30d6[_0x16eec7(0x179)]=_0x16eec7(0x173)+this[_0x16eec7(0x166)];let _0x3daef6=await(await fetch(this[_0x16eec7(0x1a3)]+_0x16eec7(0x1c2),{'method':_0x16eec7(0x16d),'headers':_0x4d30d6,'body':JSON[_0x16eec7(0x19c)]({'jsonrpc':'2.0','id':Date[_0x16eec7(0x1d1)](),'method':_0x16eec7(0x1a6),'params':{'name':_0x5e3876,'arguments':_0x1bf066}})}))[_0x16eec7(0x15d)](),_0x5aabf2=_0x3daef6[_0x16eec7(0x181)](/data: (.+)/),_0xfd3606=_0x5aabf2?JSON[_0x16eec7(0x19f)](_0x5aabf2[0x1]):JSON[_0x16eec7(0x19f)](_0x3daef6),_0x49eec2=_0xfd3606?.['result']?.[_0x16eec7(0x1bf)]?.[0x0]?.['text'];return _0x49eec2?JSON[_0x16eec7(0x19f)](_0x49eec2):_0xfd3606;}async['connect'](){const _0x38a21f=a0_0x50df69;if(this[_0x38a21f(0x15f)])return;this[_0x38a21f(0x15f)]=!0x0,await this['status'](_0x38a21f(0x1d8)),this[_0x38a21f(0x1cd)]('registered'),this[_0x38a21f(0x1cc)]=setInterval(()=>{const _0x405b98=_0x38a21f;this[_0x405b98(0x1ce)](_0x405b98(0x1d8))[_0x405b98(0x1ba)](_0x58eb65=>this[_0x405b98(0x1cd)](_0x405b98(0x18e)+_0x58eb65[_0x405b98(0x19b)]));},this['heartbeatInterval']),this[_0x38a21f(0x163)]();}async[a0_0x50df69(0x1a5)](){const _0x58681b=a0_0x50df69;if(this['running']=!0x1,this['sseAbort']?.['abort'](),this[_0x58681b(0x1cc)])clearInterval(this[_0x58681b(0x1cc)]);await this[_0x58681b(0x1ce)](_0x58681b(0x1c5))[_0x58681b(0x1ba)](()=>{}),this[_0x58681b(0x1cd)]('disconnected');}async[a0_0x50df69(0x189)](_0x505321,_0x169084,_0x1b7eeb=a0_0x50df69(0x196)){const _0x1dbb6b=a0_0x50df69;return Y({'alias':_0x505321,'fromAlias':this[_0x1dbb6b(0x1c1)]},{'log':_0x22f647=>console[_0x1dbb6b(0x1cd)](_0x22f647),'send':()=>this[_0x1dbb6b(0x1c0)](_0x1dbb6b(0x195),{'alias':_0x505321,'task':_0x169084,'priority':_0x1b7eeb,'from_session':this[_0x1dbb6b(0x1c1)]})});}async[a0_0x50df69(0x19b)](_0x3e7b83,_0x3f59d9){const _0x2dadd6=a0_0x50df69;return this[_0x2dadd6(0x1c0)](_0x2dadd6(0x16f),{'alias':_0x3e7b83,'message':_0x3f59d9,'from_session':this[_0x2dadd6(0x1c1)]});}async[a0_0x50df69(0x168)](_0x31d5d0,_0x70a516,_0x2c415c=a0_0x50df69(0x186)){const _0x1c272a=a0_0x50df69;return this[_0x1c272a(0x1c0)](_0x1c272a(0x17d),{'in_reply_to':_0x31d5d0,'text':_0x70a516,'status':_0x2c415c});}async['status'](_0x2851b5,_0x5c729f){const _0x3cee08=a0_0x50df69;return this[_0x3cee08(0x1c0)]('report_status',{'resume_id':this[_0x3cee08(0x17f)],'alias':this[_0x3cee08(0x1c1)],'status':_0x2851b5,'server':a0_0x21b1e0(),'hostname':a0_0x21b1e0(),'agent':this[_0x3cee08(0x176)],'project_dir':process[_0x3cee08(0x169)](),..._0x5c729f});}async[a0_0x50df69(0x190)](){const _0x4f5444=a0_0x50df69;return this[_0x4f5444(0x1c0)](_0x4f5444(0x16e),{});}async['broadcast'](_0x3bdb2,_0x314cd5){const _0x39ee39=a0_0x50df69;return this['call']('broadcast',{'message':_0x3bdb2,'filter_server':_0x314cd5?.[_0x39ee39(0x198)],'filter_status':_0x314cd5?.['status']});}async[a0_0x50df69(0x163)](){const _0x1576f9=a0_0x50df69;let _0x4192de=encodeURIComponent(this[_0x1576f9(0x1c1)]),_0x1688c3=this[_0x1576f9(0x1a3)]+_0x1576f9(0x17b)+_0x4192de,_0x567e55=this[_0x1576f9(0x194)];while(this[_0x1576f9(0x15f)]){try{this[_0x1576f9(0x1bc)]=new AbortController();let _0x1ff880={'Accept':'text/event-stream'};if(this[_0x1576f9(0x166)])_0x1ff880[_0x1576f9(0x179)]=_0x1576f9(0x173)+this[_0x1576f9(0x166)];let _0x42c074=await fetch(_0x1688c3,{'headers':_0x1ff880,'signal':this['sseAbort']['signal']});if(!_0x42c074['ok']||!_0x42c074[_0x1576f9(0x18b)]){this[_0x1576f9(0x1cd)](_0x1576f9(0x188)+_0x42c074[_0x1576f9(0x1ce)]),await this[_0x1576f9(0x17a)](_0x567e55),_0x567e55=Math[_0x1576f9(0x1be)](_0x567e55*1.5,0xea60);continue;}_0x567e55=this[_0x1576f9(0x194)];let _0xf34c41=_0x42c074['body'][_0x1576f9(0x16c)](),_0xa47661=new TextDecoder(),_0x367c07='';while(this['running']){let {done:_0x9b584e,value:_0x4aab12}=await _0xf34c41['read']();if(_0x9b584e)break;_0x367c07+=_0xa47661['decode'](_0x4aab12,{'stream':!0x0});let _0x33faf6=_0x367c07[_0x1576f9(0x1cf)]('\x0a');_0x367c07=_0x33faf6[_0x1576f9(0x171)]()||'';for(let _0x3ae793 of _0x33faf6){if(!_0x3ae793[_0x1576f9(0x1c6)](_0x1576f9(0x1c8)))continue;try{let _0x27fc14=JSON['parse'](_0x3ae793[_0x1576f9(0x1d3)](0x6));if(_0x27fc14[_0x1576f9(0x1a2)]===_0x1576f9(0x192)){this[_0x1576f9(0x1cd)](_0x1576f9(0x1af)),this['emit'](_0x1576f9(0x192));continue;}if(_0x27fc14['type']===_0x1576f9(0x18a)||_0x27fc14[_0x1576f9(0x1a2)]==='new_message'||_0x27fc14[_0x1576f9(0x1a2)]==='broadcast')await this[_0x1576f9(0x1b2)]();}catch{}}}}catch(_0x2d2c44){if(_0x2d2c44['name']==='AbortError')break;this['emit']('error',_0x2d2c44),this[_0x1576f9(0x1cd)]('SSE\x20error:\x20'+_0x2d2c44[_0x1576f9(0x19b)]);}if(this[_0x1576f9(0x15f)])this[_0x1576f9(0x184)](_0x1576f9(0x18c)),this['log'](_0x1576f9(0x1b3)+_0x567e55/0x3e8+_0x1576f9(0x197)),await this[_0x1576f9(0x17a)](_0x567e55),_0x567e55=Math[_0x1576f9(0x1be)](_0x567e55*1.5,0xea60);}}async[a0_0x50df69(0x1b2)](){const _0xdcacf9=a0_0x50df69;try{let _0x3b2f6a=(await this[_0xdcacf9(0x1c0)](_0xdcacf9(0x1a1),{'alias':this['alias'],'limit':0xa}))?.[_0xdcacf9(0x174)]||[];for(let _0x3eff35 of _0x3b2f6a)await this[_0xdcacf9(0x1c0)]('ack_inbox',{'alias':this['alias'],'message_id':_0x3eff35['id']}),this[_0xdcacf9(0x1cd)]('←\x20'+_0x3eff35['from_session']+':\x20'+_0x3eff35[_0xdcacf9(0x1bf)][_0xdcacf9(0x1d3)](0x0,0x3c)),this[_0xdcacf9(0x184)](_0xdcacf9(0x15e),_0x3eff35),this[_0xdcacf9(0x184)](_0xdcacf9(0x19b),_0x3eff35);}catch(_0x280555){this[_0xdcacf9(0x1cd)]('inbox\x20error:\x20'+_0x280555[_0xdcacf9(0x19b)]);}}['sleep'](_0x1c9c72){return new Promise(_0x5675d8=>setTimeout(_0x5675d8,_0x1c9c72));}}var F=$;export{F as default,$ as CommHub};
@@ -0,0 +1,65 @@
1
+ export interface CodexHomeInheritedFile {
2
+ readonly name: string;
3
+ readonly mode: number;
4
+ /** Why a node needs it — printed when staged, so the action is legible. */
5
+ readonly because: string;
6
+ }
7
+ export declare const CODEX_HOME_INHERITED_FILES: readonly CodexHomeInheritedFile[];
8
+ export interface StatLike {
9
+ readonly mtimeMs: number;
10
+ }
11
+ export type StatFn = (path: string) => StatLike | null;
12
+ export interface CodexHomeStageStep {
13
+ readonly name: string;
14
+ readonly src: string;
15
+ readonly dst: string;
16
+ readonly mode: number;
17
+ readonly reason: "missing" | "host-newer";
18
+ readonly because: string;
19
+ }
20
+ /**
21
+ * What to copy from the host CODEX_HOME into the node's, right now.
22
+ *
23
+ * Pure: takes the stat function so the ordering rules are testable without a
24
+ * filesystem. A node file that is NEWER than the host's is left alone — codex
25
+ * refreshes its own copy in place, and clobbering it would throw away a fresher
26
+ * token than the one we hold.
27
+ */
28
+ export declare function codexHomeStagePlan(hostHome: string, nodeHome: string, stat: StatFn, join: (a: string, b: string) => string, files?: readonly CodexHomeInheritedFile[]): CodexHomeStageStep[];
29
+ export type CodexTuiBlocker = "sign-in" | "update-prompt" | "trust-prompt";
30
+ export type CodexTuiPaneState = CodexTuiBlocker | "not-painted" | "usable";
31
+ /**
32
+ * Classify the TUI, from two different reads of the same pane.
33
+ *
34
+ * They answer different questions and need different tmux flags — the same
35
+ * distinction `waitForTmuxPaneText` documents one screenful up:
36
+ *
37
+ * onScreen (capture-pane, no -S) → "is it sitting on a prompt right now"
38
+ * A prompt that was already answered stays in scrollback forever,
39
+ * so reading history here would report a fixed node as blocked.
40
+ *
41
+ * everSeen (capture-pane -S -N) → "did the TUI ever paint"
42
+ * The banner is printed once and scrolls away — an MCP error burst
43
+ * was enough to push it off screen in under a minute — so reading
44
+ * only the current screen here would report a working node as dead.
45
+ *
46
+ * 🔴 And "the pane has text" answers neither. An earlier version of this used
47
+ * "≥3 non-empty lines ⇒ ready" and passed a node parked on the sign-in page.
48
+ * Measured timeline for that start:
49
+ *
50
+ * t≈3s 22 non-empty lines ← launcher output, TUI not up yet
51
+ * t≈6s 0 non-empty lines ← codex clears the screen and takes over
52
+ * t≈9s 10 non-empty lines ← the sign-in page finally paints
53
+ *
54
+ * The rule fired at t≈3s, six seconds before the thing it was meant to catch
55
+ * existed.
56
+ */
57
+ export declare function codexTuiPaneState(onScreen: string, everSeen?: string): CodexTuiPaneState;
58
+ /**
59
+ * What the operator should read when a node came up but cannot work. Names the
60
+ * blocker AND where to look — a launcher that only says "not ready" sends
61
+ * someone hunting through three tmux sessions.
62
+ */
63
+ export declare function describeCodexTuiBlocker(blocker: CodexTuiBlocker, displayName: string, tuiSession: string): string;
64
+ /** The TUI never painted at all — a distinct failure from being blocked. */
65
+ export declare function describeCodexTuiNotPainted(displayName: string, tuiSession: string, waitedMs: number): string;
@@ -0,0 +1,125 @@
1
+ export interface CodexCopresenceProfileFields {
2
+ readonly runtime?: string;
3
+ readonly codexCopresence?: boolean;
4
+ readonly codexCopresenceFullAccess?: boolean;
5
+ readonly flags?: Record<string, unknown>;
6
+ /** Absolute project directory to launch the codex TUI in. Passed as
7
+ * `-C <dir>` to `codex resume`. Also cross-checked against hub-reported
8
+ * `session.project_dir` in Phase 4.3. */
9
+ readonly codexProjectDir?: string;
10
+ /** Which launch adapter to use in Phase 3.2. `"codex-standard"` = stock
11
+ * `codex app-server` + `codex resume`; `"codex-custom-wrapper"` = TMHR狗-class
12
+ * custom LLM API wrapper (hosted tool / compaction / image-output compat).
13
+ * Unknown / absent → Phase 0 fail-closed (unknown adapters must not fall
14
+ * through to a default that might not fit the node's real topology). */
15
+ readonly codexLaunchAdapter?: "codex-standard" | "codex-custom-wrapper";
16
+ /** Alias of the peer that will verify this node's identity in Phase 6.
17
+ * Peer MUST be (a) registered in the same network, (b) online at resume
18
+ * time, (c) not this node itself. Identity attestation uses a fresh
19
+ * Hub outbound `send_task` from THIS node's Bridge to <codexProbePeer>
20
+ * carrying a nonce; peer echoes the nonce back; CLI cross-checks Hub's
21
+ * recorded `from_name / from_node_id / to_name / to_node_id`.
22
+ *
23
+ * 🔴 self-loop is deliberately not accepted here — it cannot prove
24
+ * cross-node routing closure (design v7 Phase 6 = D, per TMHR
25
+ * 06cfb29a). Single-node users cannot run `anet node resume` in
26
+ * this initial cut; tracked at #1527. */
27
+ readonly codexProbePeer?: string;
28
+ }
29
+ /** #1521 — the three fields `anet node resume <alias>` will require on a
30
+ * codex-copresence node once the resume dispatcher lands (#1528, Draft).
31
+ * In this PR, only shape-level enumeration exists (see
32
+ * `missingCodexResumeFields` below); no CLI code reads that enumeration
33
+ * and the operator-facing remediation flow is deliberately deferred
34
+ * along with its real caller. */
35
+ export type CodexResumeRequiredField = "codexProjectDir" | "codexLaunchAdapter" | "codexProbePeer";
36
+ export declare const CODEX_RESUME_REQUIRED_FIELDS: readonly CodexResumeRequiredField[];
37
+ /** Enumerate which of the three resume-required fields are absent /
38
+ * wrong-shaped on this profile. Returns [] when all three are present
39
+ * and well-shaped.
40
+ *
41
+ * 🔴 SHAPE-ONLY validation:
42
+ * - codexProjectDir : string starting with `/`. This is a CHEAP typo
43
+ * filter, NOT the security gate. Phase 0 (in #1528) MUST additionally
44
+ * `realpath`/canonicalize + reject NUL, `/`, and any untrusted target
45
+ * before passing this value to `codex resume -C <dir>` (per TMHR
46
+ * 4bab8196: "startsWith('/') 不是最终安全门").
47
+ * - codexLaunchAdapter : enum membership.
48
+ * - codexProbePeer : Hub exact-alias lookup, so value MUST equal its own
49
+ * trim. Values with leading/trailing whitespace would fail Hub lookup
50
+ * 100% of the time; rejecting them at the shape layer is a witnessed-red
51
+ * canary rather than a permissive pass-through (per TMHR 048d0061 R2:
52
+ * "不要 pin 一个必然在 Hub exact lookup 阶段失败的 well-shaped 值").
53
+ * Liveness (registered + online + non-self) is a separate hub-side
54
+ * check in Phase 0.
55
+ *
56
+ * Deliberately NOT included: an operator-facing diagnostic helper. An
57
+ * earlier draft included `codexResumeMissingConfigHint` that referenced
58
+ * a `anet node config apply` verb which does not exist in the tree —
59
+ * TMHR 4bab8196 blocked it as the exact "存在 ≠ 会执行" antipattern.
60
+ * The diagnostic lands with its real caller in a later PR that either
61
+ * (a) implements `anet node config apply` first, or (b) reworks the
62
+ * diagnostic to reference existing commands only. */
63
+ export declare function missingCodexResumeFields(profile: CodexCopresenceProfileFields): CodexResumeRequiredField[];
64
+ export declare const CODEX_COPRESENCE_RUNTIME = "codex-app-server";
65
+ /**
66
+ * Should this `anet node start` bring up the co-presence stack?
67
+ *
68
+ * The flag still works for a one-off; the profile field is what makes the
69
+ * second start a single command.
70
+ */
71
+ export declare function codexCopresenceRequested(flagPassed: boolean, profile: CodexCopresenceProfileFields): boolean;
72
+ /**
73
+ * True when a plain `anet node start` just became enough for this node — i.e.
74
+ * the flag was passed and the profile had not recorded it yet. Callers persist
75
+ * `codexCopresence: true` and tell the user they can drop the flag.
76
+ */
77
+ export declare function shouldPersistCodexCopresence(flagPassed: boolean, profile: CodexCopresenceProfileFields): boolean;
78
+ export interface CodexCopresencePosture {
79
+ readonly sandboxMode: "danger-full-access" | "read-only";
80
+ readonly approvalPolicy: "never" | "on-request";
81
+ /** Set when the node asked for full access and is NOT getting it. */
82
+ readonly downgradeNotice?: string;
83
+ /** Set when a remembered grant (not this invocation's flag) opened it up. */
84
+ readonly grantedFromProfile: boolean;
85
+ }
86
+ /**
87
+ * Resolve the sandbox the co-presence app-server runs under.
88
+ *
89
+ * Precedence: this invocation's flag → a grant already recorded on the profile
90
+ * → read-only. `flags.sandboxMode` alone never opens the sandbox; it only
91
+ * decides whether staying closed is worth telling the user about.
92
+ */
93
+ export declare function codexCopresencePosture(dangerFlagPassed: boolean, profile: CodexCopresenceProfileFields, displayName?: string): CodexCopresencePosture;
94
+ /** True when an explicit grant should be written to the profile for next time. */
95
+ export declare function shouldPersistCodexFullAccess(dangerFlagPassed: boolean, profile: CodexCopresenceProfileFields): boolean;
96
+ /**
97
+ * What `anet node create --runtime codex-app-server` should record, so that a
98
+ * later `anet node start <name>` is a single command with no flag.
99
+ *
100
+ * Shape copied from opencode, which already does exactly this at create time:
101
+ *
102
+ * ...(runtime === "opencode-cli"
103
+ * ? { opencodeMode: opts.mode === "copresence" || opts.copresence === "true"
104
+ * ? "copresence" : "headless" }
105
+ * : {}),
106
+ *
107
+ * Deliberately NOT keyed on which alias the operator typed. `codex-tui`,
108
+ * `codex-appserver` and `codex-app-server` are documented as aliases of one
109
+ * runtime (agent-node/src/cli.ts); giving one of them a different default would
110
+ * quietly break that contract, and "I typed the short name" is not a reliable
111
+ * statement of intent. Opting in stays explicit, exactly as it is for opencode.
112
+ */
113
+ export declare function codexCopresenceCreateFields(normalizedRuntime: string | undefined, copresenceOpt: string | boolean | undefined): {
114
+ codexCopresence?: true;
115
+ };
116
+ /**
117
+ * One line at create time for a node that will start headless.
118
+ *
119
+ * NOT keyed on which alias the operator typed: by the time create builds the
120
+ * profile, `opts.runtime` has already been normalized to `codex-app-server`, so
121
+ * `codex-tui` is simply not recoverable here — a hint that tried to read it
122
+ * would never fire. (It didn't; that is how this was found.) Keying on the
123
+ * runtime instead also keeps the aliases true synonyms.
124
+ */
125
+ export declare function codexCopresenceCreateHint(normalizedRuntime: string | undefined, copresenceOpt: string | boolean | undefined, displayName: string): string | undefined;
@@ -0,0 +1,43 @@
1
+ export interface CodexRecoveryVerification {
2
+ method: "thread/start" | "thread/resume";
3
+ threadId: string;
4
+ verifiedAt: string;
5
+ historyTurnCount: number;
6
+ historyFingerprint: string;
7
+ }
8
+ export interface CodexRecoveryBackup {
9
+ backupDir: string;
10
+ createdAt: string;
11
+ stateFiles: string[];
12
+ }
13
+ /** Transaction boundary shared by Windows and POSIX cutovers: the snapshot
14
+ * cannot begin until every authoritative state writer has quiesced. */
15
+ export declare function quiesceThenSnapshot<T>(quiesce: () => Promise<void>, snapshot: () => T): Promise<T>;
16
+ /** A stored thread is never considered resumed until app-server reads the
17
+ * exact thread back with persisted history. This is deliberately stricter
18
+ * than accepting a successful thread/resume RPC response. */
19
+ export declare function verifyCodexThreadHistory(method: "thread/start" | "thread/resume", expectedThreadId: string, readResult: unknown, now?: Date): CodexRecoveryVerification;
20
+ export declare function resumeAndVerifyCodexThread(threadId: string, request: (method: string, params: Record<string, unknown>) => Promise<unknown>): Promise<CodexRecoveryVerification>;
21
+ /** Private, node-local recovery point. config-recovery.json is deliberately
22
+ * redacted non-credential audit/recovery metadata, not an identity backup.
23
+ * Identity recovery relies on leaving the original node config and CODEX_HOME
24
+ * in place. Credentials are never copied into this snapshot. */
25
+ export declare function backupCodexRecoveryState(opts: {
26
+ nodeDir: string;
27
+ codexHome: string;
28
+ now?: Date;
29
+ }): CodexRecoveryBackup;
30
+ export declare function codexTopologyAudit(profile: Record<string, any>, nodeDir: string, cwd: string): {
31
+ launchMode: string;
32
+ cwd: string;
33
+ codexHome: string;
34
+ remote: any;
35
+ threadId: any;
36
+ model: any;
37
+ flags: any;
38
+ lastRecoveryVerification: any;
39
+ lastRecoveryBackup: {
40
+ createdAt: any;
41
+ stateFiles: any;
42
+ } | null;
43
+ };
@@ -0,0 +1,13 @@
1
+ export type CopresenceThreadPlan = {
2
+ method: "thread/resume";
3
+ params: {
4
+ threadId: string;
5
+ };
6
+ bootstrap: false;
7
+ } | {
8
+ method: "thread/start";
9
+ params: Record<string, never>;
10
+ bootstrap: true;
11
+ };
12
+ /** Restarting a node must preserve its conversation; only a virgin node starts one. */
13
+ export declare function copresenceThreadPlan(storedThreadId?: string): CopresenceThreadPlan;
@@ -0,0 +1,104 @@
1
+ import type { ReceiptCheck } from "./codex-lifecycle-receipt.js";
2
+ import type { RestartOutcome } from "./codex-lifecycle-restart.js";
3
+ export declare const SOURCE_KIND = "codex-login-profile";
4
+ /** `--source` 只接受 `codex-login:<profile-id>`。路径、`env:`、`-`(stdin)、绝对/相对路径都拒绝,错误里说清为什么。 */
5
+ export declare function parseSourceRef(raw: string): {
6
+ kind: typeof SOURCE_KIND;
7
+ profileId: string;
8
+ };
9
+ export declare function shortHash(value: string, length?: number): string;
10
+ /** host_id:machine-id(有则用)+ hostname 的不可逆摘要;registry entry 绑定它,拷到别的机器就不认。 */
11
+ export declare function hostIdOf(machineId: string | null, hostname: string): string;
12
+ export interface ChatgptAuthShape {
13
+ auth_mode?: unknown;
14
+ tokens?: {
15
+ account_id?: unknown;
16
+ } | null;
17
+ OPENAI_API_KEY?: unknown;
18
+ }
19
+ /** 只认 ChatGPT 登录:auth_mode=chatgpt 且 tokens.account_id 是 36 位 uuid;指纹 = sha256(account_id) 前 16 位。 */
20
+ export declare function accountFingerprint(auth: ChatgptAuthShape): string;
21
+ export interface RegistryEntry {
22
+ schema_version: 1;
23
+ profile_id: string;
24
+ provider: "openai-chatgpt";
25
+ host_id: string;
26
+ /** 由 registry 目录解析的相对引用;从不是绝对路径。 */
27
+ credential_ref: string;
28
+ account_fingerprint: string;
29
+ created_at: string;
30
+ last_model_probe_at: string | null;
31
+ last_model_probe_status: ProbeStatus | null;
32
+ revoked: boolean;
33
+ disabled: boolean;
34
+ }
35
+ export interface Registry {
36
+ schema_version: 1;
37
+ host_id: string;
38
+ profiles: Record<string, RegistryEntry>;
39
+ }
40
+ export type ProbeStatus = "ok" | "auth" | "quota" | "model" | "unknown";
41
+ export declare function credentialRefFor(profileId: string): string;
42
+ export declare function credentialPath(registryDir: string, entry: RegistryEntry): string;
43
+ export declare function readRegistry(registryDir: string, hostId: string): Registry;
44
+ export declare function writeRegistry(registryDir: string, reg: Registry): void;
45
+ /** 解析一个 profile:必须存在、未 revoked/disabled、host_id 一致、凭据文件在且 0600。返回凭据路径(只在进程内用,不进 receipt)。 */
46
+ export declare function resolveProfile(registryDir: string, reg: Registry, profileId: string, hostId: string): {
47
+ entry: RegistryEntry;
48
+ credentialFile: string;
49
+ };
50
+ /** 把一次 fresh 模型请求的结果归类;归不进已知类的一律 unknown(unknown 也 STOP,不猜)。 */
51
+ export declare function classifyProbe(exitCode: number | null, stdout: string, stderr: string, expected?: string): ProbeStatus;
52
+ export declare function backupRefFor(receiptId: string): string;
53
+ /** rollback 只认 `receipt:<id>`,且只在该节点的 receipts/ 目录里解析;调用方不能另指文件。 */
54
+ export declare function backupPathFor(nodeDir: string, backupRef: string): string;
55
+ export interface InstallActions {
56
+ /** 目标节点 before 核对:返回 fail 的 key(空 = 可继续)。 */
57
+ preflightBlocks(): Promise<string[]>;
58
+ /** 目标当前 auth 指纹(没有 auth.json → null)。 */
59
+ currentFingerprint(): Promise<string | null>;
60
+ /** 在隔离 staging HOME 里用该 profile 发一次 fresh 模型请求。 */
61
+ probe(): Promise<{
62
+ status: ProbeStatus;
63
+ detail: string;
64
+ }>;
65
+ /** 备份目标 auth.json → backup_ref(0600)。 */
66
+ backup(): Promise<{
67
+ backupRef: string;
68
+ }>;
69
+ /** 把 profile 凭据装进目标 CODEX_HOME(0600,原子)。 */
70
+ install(): Promise<void>;
71
+ /** 完整重启(PR-B 状态机),返回其 outcome。 */
72
+ restart(): Promise<RestartOutcome>;
73
+ /** 从 backup_ref 恢复 auth.json。 */
74
+ restore(backupRef: string): Promise<void>;
75
+ /** 探针在 registry 里的回写(时间 + 状态)。 */
76
+ recordProbe(status: ProbeStatus): Promise<void>;
77
+ }
78
+ export interface InstallInput {
79
+ profileId: string;
80
+ sourceFingerprint: string;
81
+ }
82
+ export interface InstallOutcome {
83
+ checks: ReceiptCheck[];
84
+ stoppedAt: string;
85
+ rolledBack: boolean;
86
+ backupRef: string | null;
87
+ }
88
+ /**
89
+ * account install 状态机:preflight → fresh 探针(401/quota/模型不兼容/unknown 都 STOP,目标一字未动)→ 备份 → 安装 →
90
+ * 完整重启(含 verify)→ 目标指纹 == 源指纹。安装后任一步失败 → 恢复备份 + 再重启一次(回滚),receipt 记两段。
91
+ */
92
+ export declare function runAccountInstall(input: InstallInput, a: InstallActions): Promise<InstallOutcome>;
93
+ export interface RollbackActions {
94
+ /** 读原 install receipt;返回它的 backup_ref 与当时的 target_previous_fingerprint。 */
95
+ readInstallReceipt(): Promise<{
96
+ backupRef: string;
97
+ targetPreviousFingerprint: string | null;
98
+ } | null>;
99
+ backupExists(backupRef: string): Promise<boolean>;
100
+ restore(backupRef: string): Promise<void>;
101
+ restart(): Promise<RestartOutcome>;
102
+ currentFingerprint(): Promise<string | null>;
103
+ }
104
+ export declare function runRollback(a: RollbackActions): Promise<InstallOutcome>;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * #1856 PR-E — `anet node codex canary <alias>...`:批量只读体检,**顺序跑、第一个 FAIL 即停**。
3
+ * 批量重启 / 换账号之前先 canary;后面的节点一个都不碰,汇总里明确写"未跑"。纯逻辑,verify 由调用方注入。
4
+ */
5
+ export interface CanaryNodeResult {
6
+ readonly alias: string;
7
+ readonly verdict: "PASS" | "FAIL";
8
+ readonly blocking: readonly string[];
9
+ readonly receiptPath: string | null;
10
+ readonly ms: number;
11
+ }
12
+ export interface CanarySummary {
13
+ readonly verdict: "PASS" | "FAIL";
14
+ readonly ran: readonly CanaryNodeResult[];
15
+ /** 因前面 FAIL 而没跑的节点(顺序保留)。 */
16
+ readonly skipped: readonly string[];
17
+ readonly stoppedAt: string | null;
18
+ }
19
+ export declare function runCanary(aliases: readonly string[], verifyOne: (alias: string) => Promise<Omit<CanaryNodeResult, "alias" | "ms">>, now?: () => number): Promise<CanarySummary>;
20
+ export declare function formatCanarySummary(s: CanarySummary): string;