@sleep2agi/agent-network 2.3.0-preview.16 → 2.3.0-preview.160

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 (169) 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-inbox-wake.d.ts +21 -0
  11. package/dist/src/channel-meta.d.ts +10 -0
  12. package/dist/src/channel-peer-reply.d.ts +41 -0
  13. package/dist/src/channel-task-trace.d.ts +14 -0
  14. package/dist/src/claude-vendor-env.d.ts +28 -0
  15. package/dist/src/cli-args.d.ts +8 -0
  16. package/dist/src/cli-auth-session.d.ts +47 -0
  17. package/dist/src/cli-errors.d.ts +41 -0
  18. package/dist/src/cli-exit.d.ts +11 -0
  19. package/dist/src/cli-help.d.ts +10 -0
  20. package/dist/src/cli-version-display.d.ts +16 -0
  21. package/dist/src/client-task-trace.d.ts +9 -0
  22. package/dist/src/client.js +1 -1
  23. package/dist/src/codex-adopt.d.ts +46 -0
  24. package/dist/src/codex-auth-fingerprint.d.ts +211 -0
  25. package/dist/src/codex-bin-pin.d.ts +23 -0
  26. package/dist/src/codex-commhub-mcp.d.ts +22 -0
  27. package/dist/src/codex-copresence-bridge-log.d.ts +44 -0
  28. package/dist/src/codex-copresence-env.d.ts +5 -0
  29. package/dist/src/codex-copresence-login-gate.d.ts +16 -0
  30. package/dist/src/codex-copresence-model.d.ts +23 -0
  31. package/dist/src/codex-copresence-preflight.d.ts +78 -0
  32. package/dist/src/codex-copresence-profile.d.ts +125 -0
  33. package/dist/src/codex-copresence-recovery.d.ts +67 -0
  34. package/dist/src/codex-copresence-resume-timeout.d.ts +28 -0
  35. package/dist/src/codex-copresence-rollout-guard.d.ts +36 -0
  36. package/dist/src/codex-copresence-rpc.d.ts +15 -0
  37. package/dist/src/codex-copresence-thread.d.ts +13 -0
  38. package/dist/src/codex-external-appserver.d.ts +128 -0
  39. package/dist/src/codex-fork-recovery.d.ts +47 -0
  40. package/dist/src/codex-home-enforce.d.ts +88 -0
  41. package/dist/src/codex-lifecycle-account.d.ts +104 -0
  42. package/dist/src/codex-lifecycle-canary.d.ts +20 -0
  43. package/dist/src/codex-lifecycle-facts.d.ts +53 -0
  44. package/dist/src/codex-lifecycle-fork.d.ts +91 -0
  45. package/dist/src/codex-lifecycle-preflight.d.ts +77 -0
  46. package/dist/src/codex-lifecycle-receipt.d.ts +53 -0
  47. package/dist/src/codex-lifecycle-restart.d.ts +88 -0
  48. package/dist/src/codex-login-share-guard.d.ts +146 -0
  49. package/dist/src/codex-menu.d.ts +99 -0
  50. package/dist/src/codex-model-default.d.ts +6 -0
  51. package/dist/src/codex-node-login.d.ts +98 -0
  52. package/dist/src/codex-pending-thread-restart.d.ts +69 -0
  53. package/dist/src/codex-recovery-lease.d.ts +39 -0
  54. package/dist/src/codex-recovery-resource-gate.d.ts +15 -0
  55. package/dist/src/codex-resume.d.ts +89 -0
  56. package/dist/src/codex-rollout-history-guard.d.ts +84 -0
  57. package/dist/src/codex-tui-client-health.d.ts +30 -0
  58. package/dist/src/commhub-response.d.ts +1 -0
  59. package/dist/src/controlled-upload.d.ts +83 -0
  60. package/dist/src/copresence-deps.d.ts +22 -0
  61. package/dist/src/copresence-identity.d.ts +363 -0
  62. package/dist/src/copresence-startup-diagnosis.d.ts +17 -0
  63. package/dist/src/daemon-adopt.d.ts +14 -0
  64. package/dist/src/daemon-anet-bin.d.ts +32 -0
  65. package/dist/src/daemon-capability-display.d.ts +110 -0
  66. package/dist/src/daemon-capability-display.js +21 -0
  67. package/dist/src/daemon-inherited-env.d.ts +9 -0
  68. package/dist/src/daemon-runtime-path-preflight.d.ts +22 -0
  69. package/dist/src/daemon-runtime-staleness.d.ts +13 -0
  70. package/dist/src/dashboard-managed-process.d.ts +35 -0
  71. package/dist/src/display-width.d.ts +27 -0
  72. package/dist/src/doctor-node-count.d.ts +28 -0
  73. package/dist/src/environ-alias.d.ts +14 -0
  74. package/dist/src/grok-attach-client.d.ts +129 -0
  75. package/dist/src/grok-build-drift.d.ts +15 -0
  76. package/dist/src/grok-copresence-disclosure.d.ts +11 -0
  77. package/dist/src/grok-copresence-orchestration.d.ts +75 -0
  78. package/dist/src/grok-copresence-profile.d.ts +65 -0
  79. package/dist/src/grok-create-mode.d.ts +19 -0
  80. package/dist/src/host-telemetry.d.ts +14 -0
  81. package/dist/src/hub-health-timeout.d.ts +4 -0
  82. package/dist/src/hub-server-version.d.ts +64 -0
  83. package/dist/src/hub-stop.d.ts +74 -0
  84. package/dist/src/hub-time-display.d.ts +20 -0
  85. package/dist/src/hub-version-skew.d.ts +19 -0
  86. package/dist/src/im/correlation-store.d.ts +34 -0
  87. package/dist/src/im/feishu/adapter.d.ts +54 -0
  88. package/dist/src/im/feishu/bridge.d.ts +78 -14
  89. package/dist/src/im/feishu/hub-upload.d.ts +1 -1
  90. package/dist/src/im/feishu/outbound-route.d.ts +62 -0
  91. package/dist/src/im/feishu/worker-lifecycle.d.ts +13 -0
  92. package/dist/src/im/feishu/worker.js +180 -153
  93. package/dist/src/inbox-drain.d.ts +20 -0
  94. package/dist/src/local-process-state.d.ts +12 -0
  95. package/dist/src/locale-diagnostic.d.ts +12 -0
  96. package/dist/src/login-client-label.d.ts +6 -0
  97. package/dist/src/ls-columns.d.ts +15 -0
  98. package/dist/src/mock-llm.d.ts +12 -0
  99. package/dist/src/node-activity-log.d.ts +4 -0
  100. package/dist/src/node-clone.d.ts +134 -0
  101. package/dist/src/node-delete-hub.d.ts +42 -0
  102. package/dist/src/node-files.d.ts +62 -0
  103. package/dist/src/node-locate.d.ts +60 -0
  104. package/dist/src/node-ls-all.d.ts +80 -0
  105. package/dist/src/node-menu.d.ts +40 -0
  106. package/dist/src/node-not-found.d.ts +1 -0
  107. package/dist/src/node-remote.d.ts +180 -0
  108. package/dist/src/node-running-guard.d.ts +9 -0
  109. package/dist/src/node-server-identity.d.ts +35 -0
  110. package/dist/src/node-server-payload.d.ts +66 -0
  111. package/dist/src/node-server-rules-file.d.ts +14 -0
  112. package/dist/src/node-server-version.d.ts +39 -0
  113. package/dist/src/node-server.js +8 -1
  114. package/dist/src/node-skills.d.ts +57 -0
  115. package/dist/src/normalize-runtime.d.ts +29 -2
  116. package/dist/src/offline-age.d.ts +29 -0
  117. package/dist/src/one-line-cell.d.ts +20 -0
  118. package/dist/src/opencode-agent-node-pair.d.ts +28 -0
  119. package/dist/src/opencode-auth-login.d.ts +43 -0
  120. package/dist/src/opencode-free-tier.d.ts +27 -0
  121. package/dist/src/opencode-generation-create.d.ts +27 -0
  122. package/dist/src/opencode-generation-record.d.ts +24 -0
  123. package/dist/src/opencode-launch-env.d.ts +13 -0
  124. package/dist/src/opencode-owner-mode.d.ts +6 -0
  125. package/dist/src/opencode-package-binary.d.ts +44 -0
  126. package/dist/src/opencode-pin.d.ts +61 -0
  127. package/dist/src/opencode-preset.d.ts +73 -0
  128. package/dist/src/opencode-runtime-binding.d.ts +30 -0
  129. package/dist/src/opencode-safe-root.d.ts +36 -0
  130. package/dist/src/opencode-smoke-env.d.ts +1 -0
  131. package/dist/src/opencode-versions.d.ts +44 -0
  132. package/dist/src/outbound-attachments.d.ts +60 -0
  133. package/dist/src/outbound-tool-names.d.ts +1 -0
  134. package/dist/src/owned-roots.d.ts +58 -0
  135. package/dist/src/owner-env-file.d.ts +2 -0
  136. package/dist/src/package-mode-preflight.d.ts +41 -0
  137. package/dist/src/posix-codex-copresence.d.ts +33 -0
  138. package/dist/src/posix-modes.d.ts +36 -0
  139. package/dist/src/primary-network.d.ts +23 -0
  140. package/dist/src/private-state.d.ts +10 -0
  141. package/dist/src/process-telemetry.d.ts +12 -0
  142. package/dist/src/profile-serialize.d.ts +1 -0
  143. package/dist/src/project-key.d.ts +1 -0
  144. package/dist/src/reply-local-links.d.ts +47 -0
  145. package/dist/src/reply-originator.d.ts +20 -0
  146. package/dist/src/resume-runtime-infer.d.ts +18 -0
  147. package/dist/src/rules-file.d.ts +53 -0
  148. package/dist/src/secret-shell-guidance.d.ts +4 -0
  149. package/dist/src/session-status-class.d.ts +48 -0
  150. package/dist/src/shared/reserved-env.d.ts +3 -0
  151. package/dist/src/sibling-agent-node.d.ts +23 -0
  152. package/dist/src/stale-socket.d.ts +118 -0
  153. package/dist/src/start-resource-gate.d.ts +146 -0
  154. package/dist/src/stopped-receipt.d.ts +8 -0
  155. package/dist/src/subcommand-redirect.d.ts +26 -0
  156. package/dist/src/task-trace.d.ts +33 -0
  157. package/dist/src/tmux-attach.d.ts +11 -0
  158. package/dist/src/tmux-capability.d.ts +58 -0
  159. package/dist/src/tmux-exact-target.d.ts +36 -0
  160. package/dist/src/tmux-format.d.ts +20 -0
  161. package/dist/src/tmux-pane-prompt.d.ts +22 -0
  162. package/dist/src/tmux.d.ts +44 -0
  163. package/dist/src/token-cli.d.ts +13 -0
  164. package/dist/src/tool-allowlist.d.ts +28 -0
  165. package/dist/src/unsafe-package-path-reason.d.ts +31 -0
  166. package/dist/src/upgrade-channel.d.ts +31 -0
  167. package/dist/src/win-launcher.d.ts +20 -0
  168. package/dist/src/windows-codex-copresence.d.ts +60 -0
  169. package/package.json +14 -7
@@ -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,21 @@
1
+ /** SSE event types that mean "there is something new in your inbox". */
2
+ export declare const INBOX_WAKE_EVENTS: ReadonlySet<string>;
3
+ export declare function isInboxWakeEvent(type: unknown): boolean;
4
+ /**
5
+ * Single-flight runner: at most one drain runs at a time, and wakeups that
6
+ * arrive mid-drain collapse into exactly one rerun. Two concurrent drains
7
+ * would both fetch the same unacked rows and inject each task twice.
8
+ */
9
+ export declare function createSingleFlight(run: () => Promise<void>): () => Promise<void>;
10
+ export declare const DEFAULT_INBOX_POLL_MS = 60000;
11
+ /** ANET_CHANNEL_INBOX_POLL_MS: poll period in ms; "0" disables the safety net. */
12
+ export declare function inboxPollIntervalMs(raw: string | undefined): number;
13
+ /**
14
+ * Periodically run the drain so a missed push costs at most one period.
15
+ * Returns a stop function. The timer never keeps the process alive.
16
+ */
17
+ export declare function startInboxSafetyNet(opts: {
18
+ intervalMs: number;
19
+ drain: () => Promise<void>;
20
+ onError?: (error: unknown) => void;
21
+ }): () => void;
@@ -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,41 @@
1
+ export declare const PEER_REPLY_TOOL_NAME = "commhub_send_peer_reply";
2
+ export interface ChannelPeerReplyInput {
3
+ task_id?: unknown;
4
+ text?: unknown;
5
+ status?: unknown;
6
+ alias?: unknown;
7
+ }
8
+ export interface ChannelPeerReplyDeps {
9
+ /** One Hub MCP tool call. Returns the parsed tool payload (ok:false on rejection); may throw on transport failure. */
10
+ call: (tool: string, args: Record<string, unknown>) => Promise<any>;
11
+ fromAlias: string;
12
+ /** Sender alias the channel recorded when it injected this task_id (in-memory; may be unknown after a restart). */
13
+ originatorOf?: (taskId: string) => string | undefined;
14
+ /** channel meta task_id is the inbox ROW id; map it to the logical tasks.task_id when known. */
15
+ logicalTaskIdOf?: (taskId: string) => string | undefined;
16
+ }
17
+ export type ChannelPeerReplyRoute = "atomic" | "wake-then-close" | "reply-only";
18
+ export interface ChannelPeerReplyResult {
19
+ ok: boolean;
20
+ route?: ChannelPeerReplyRoute;
21
+ /** The original task is now terminal. */
22
+ closed: boolean;
23
+ /** A wake was delivered to the peer (atomic result row or fallback send_task). */
24
+ woke: boolean;
25
+ task_id?: string;
26
+ error?: string;
27
+ message?: string;
28
+ wake_task_id?: string | null;
29
+ fallback_reason?: string;
30
+ upstream?: unknown;
31
+ }
32
+ /** The Hub rejected the ATOMIC route for a capability reason and wrote nothing. */
33
+ export declare function peerReplyFallbackReason(payload: any): string | null;
34
+ export declare function validatePeerReplyInput(input: ChannelPeerReplyInput): {
35
+ ok: true;
36
+ taskId: string;
37
+ text: string;
38
+ status: "completed" | "failed";
39
+ alias?: string;
40
+ } | ChannelPeerReplyResult;
41
+ export declare function sendChannelPeerReply(input: ChannelPeerReplyInput, deps: ChannelPeerReplyDeps): Promise<ChannelPeerReplyResult>;
@@ -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,47 @@
1
+ export type RevokeOutcome =
2
+ /** 服务端已撤销 */
3
+ {
4
+ kind: "revoked";
5
+ tokenId: string;
6
+ }
7
+ /** Hub 回 401:这个 token 在服务端本来就无效了(过期/已撤/改过密码),没东西可撤 */
8
+ | {
9
+ kind: "already_invalid";
10
+ }
11
+ /** 不是登录会话(显式 API 令牌 / 节点令牌):按设计不撤,仍有效 */
12
+ | {
13
+ kind: "not_a_session";
14
+ tokenId?: string;
15
+ }
16
+ /** Hub 没有 /api/auth/sessions(早于 #2114 的旧版本 → 404) */
17
+ | {
18
+ kind: "unsupported";
19
+ status: number;
20
+ }
21
+ /** 连不上 Hub(DNS / 拒绝连接 / 超时) */
22
+ | {
23
+ kind: "unreachable";
24
+ error: string;
25
+ }
26
+ /** 其他意外响应 */
27
+ | {
28
+ kind: "failed";
29
+ status?: number;
30
+ error: string;
31
+ };
32
+ export type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
33
+ export declare function normalizeHubUrl(url: string): string;
34
+ export declare function sameHub(a?: string | null, b?: string | null): boolean;
35
+ /** 本地登录态字段。hub 不在里面:退出登录不等于忘掉 Hub 地址。 */
36
+ export declare const LOCAL_CREDENTIAL_KEYS: readonly ["token", "user", "network_id", "network_name"];
37
+ export declare function clearLocalCredentials(gc: Record<string, any>): Record<string, any>;
38
+ /** 在 `hub` 上撤销 `token` 所代表的登录会话。只把 token 发给 `hub` 本身。 */
39
+ export declare function revokeCurrentLoginSession(hub: string, token: string, opts?: {
40
+ fetchImpl?: FetchLike;
41
+ timeoutMs?: number;
42
+ }): Promise<RevokeOutcome>;
43
+ /** 把撤销结果翻成给人看的行。`ok=false` 表示服务端令牌**仍然有效**,调用方按警告打印。 */
44
+ export declare function describeRevokeOutcome(o: RevokeOutcome, hub: string): {
45
+ ok: boolean;
46
+ lines: string[];
47
+ };
@@ -0,0 +1,41 @@
1
+ /**
2
+ * 把一个密钥变成 `<前缀>…<末 4 位>`。
3
+ * utok_abcdef…(40 字符)…wxyz → utok_…wxyz
4
+ * 太短(去掉前缀后不足 12 个字符)时连末 4 位也不给:短密钥露 4 位等于露了一大半。
5
+ */
6
+ export declare function maskSecret(value: unknown): string;
7
+ /** 把任意文本里看得出的密钥都换成掩码。用在一切「把别处来的字符串打出来」的地方。 */
8
+ export declare function redactSecrets(text: string): string;
9
+ /** 深拷贝一个对象,键名像密钥的字符串值换成掩码,其余字符串值走 redactSecrets。 */
10
+ export declare function redactSecretFields<T>(value: T): T;
11
+ /** 任意「错误」值 → 一句可读文本。对象取 message / error.message / code,实在没有就 JSON。 */
12
+ export declare function errorText(x: unknown): string;
13
+ /**
14
+ * Hub 的失败响应体 → 一句话。hub 的 REST 路由回 `{ ok:false, error:"<字符串>" }`,
15
+ * 但 500 兜底(server/src/serve-error.ts)回 `{ error:{ code, message }, message }` ——
16
+ * 直接 `${res.error}` 就是 `[object Object]`。
17
+ */
18
+ export declare function hubErrorText(res: unknown): string;
19
+ /** Doctor must not suggest retrying an implicit ownership claim. */
20
+ export declare function nodeTokenReissueError(res: unknown): string;
21
+ export interface CliErrorReport {
22
+ /** 第一行:出了什么事。 */
23
+ summary: string;
24
+ /** 下一步该敲的命令(每条一行)。 */
25
+ next: string[];
26
+ /** 为日志解析保留的 `FATAL: Error: CODE` 形状(只在消息本身是错误码时)。 */
27
+ fatalCode?: string;
28
+ }
29
+ export declare function isDebugEnabled(env?: Record<string, string | undefined>): boolean;
30
+ export declare function isNetworkError(err: any): boolean;
31
+ export declare function describeCliError(err: any, ctx?: {
32
+ hub?: string;
33
+ configPath?: string;
34
+ }): CliErrorReport;
35
+ /** 顶层 catch 用:产出要打到 stderr 的全部行(已脱敏)。stack 只在 ANET_DEBUG=1 时附上。 */
36
+ export declare function formatTopLevelError(err: any, opts?: {
37
+ hub?: string;
38
+ env?: Record<string, string | undefined>;
39
+ }): string[];
40
+ /** 「连 hub 失败」的原因,一句短语。用在已经写了 `Cannot reach <hub>:` 的地方。 */
41
+ export declare function hubReachReason(err: any): string;
@@ -0,0 +1,11 @@
1
+ export declare const ANET_EXIT: {
2
+ readonly OK: 0;
3
+ readonly FAILURE: 1;
4
+ readonly USAGE: 2;
5
+ };
6
+ /** 命令打印了错误、不再继续 —— 记下失败码,让 main() 的终结器用它退出。 */
7
+ export declare function markFailed(): void;
8
+ /** 用法错误(缺参数 / 未知子命令 / 非法取值)。 */
9
+ export declare function markUsageError(): void;
10
+ /** main() 正常返回后的退出码:命令记下过的码,没记过就是 0。 */
11
+ export declare function finalExitCode(): number;
@@ -0,0 +1,10 @@
1
+ export declare const NODE_DELETE_USAGE = "Usage: anet node delete <node-id|node-name> [--force]\n anet node delete <node_id> --hub-only [--hub <url>]\n\nStop the node, delete its local config (.anet/nodes/<id>/), then remove its\nrow on the Hub so it no longer shows as offline.\n\n --force Required to actually delete (without it, prints what would go)\n --hub-only Only remove the Hub row (the retry command printed when the Hub\n could not be reached); takes the node_id from that warning\n --hub <url> Hub to use with --hub-only (default: your login's Hub)\n\nThe Hub row is matched by node_id only \u2014 never by name \u2014 so a node elsewhere\nthat reuses the same name is left untouched.\nIf the Hub is unreachable or refuses, the local files are still deleted, a\nwarning prints the exact retry command, and the exit code is 1.";
2
+ /** path (space-joined) → usage text. `{cmd}` is replaced by the word the user typed (hub/server). */
3
+ export declare const COMMAND_HELP: Record<string, string>;
4
+ /**
5
+ * The most specific help entry for argv (e.g. ["node","delete","x","--help"]).
6
+ * Only the leading positional words are the command path; the longest prefix
7
+ * with an entry wins. `minDepth` lets the caller skip bare group entries when a
8
+ * richer group printer exists in bin/cli.ts.
9
+ */
10
+ export declare function lookupCommandHelp(argv: string[], minDepth?: number): string | null;
@@ -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
- function a0_0x3a8a(_0xbf97b2,_0x1b0d8b){_0xbf97b2=_0xbf97b2-0xcc;const _0x1ead6b=a0_0x1ead();let _0x3a8a84=_0x1ead6b[_0xbf97b2];return _0x3a8a84;}const a0_0x5aa207=a0_0x3a8a;(function(_0xd6e14f,_0x212c4a){const _0x2d861c=a0_0x3a8a,_0x33513c=_0xd6e14f();while(!![]){try{const _0x25926b=-parseInt(_0x2d861c(0xfe))/0x1*(-parseInt(_0x2d861c(0x10c))/0x2)+parseInt(_0x2d861c(0xcc))/0x3+-parseInt(_0x2d861c(0xd2))/0x4+parseInt(_0x2d861c(0xf1))/0x5+-parseInt(_0x2d861c(0x101))/0x6+parseInt(_0x2d861c(0xd7))/0x7+parseInt(_0x2d861c(0xf8))/0x8*(-parseInt(_0x2d861c(0x11b))/0x9);if(_0x25926b===_0x212c4a)break;else _0x33513c['push'](_0x33513c['shift']());}catch(_0x177805){_0x33513c['push'](_0x33513c['shift']());}}}(a0_0x1ead,0xc6cad));function a0_0x1ead(){const _0x2627eb=['now','send_reply','inbox\x20error:\x20','token','error','data:\x20','application/json','task','read','body','reply','type','getReader','completed','sseAbort','disconnected','sdk-','toString','text','7438645HSevlt','match','status','/events/','log','application/json,\x20text/event-stream','message','8JSJtRn','Authorization','reconnectDelay','heartbeat\x20failed:\x20','heartbeatTimer','Bearer\x20','221077ssreUs','idle','sdk','1867512LPzeik','sleep','tools/call','new_message','connect','replace','url','alias','resumeId','content','messages','14GwWeVF','call','parse','SSE\x20error:\x20','autoConnect','result','min','getAllStatus','stringify','split','connectSSE','disconnect','broadcast','catch','POST','37381941xaArGT','name','decode','running','abort','3374694yHCTbU','connected','emit',']\x20[commhub:','2.0','startsWith','1593356MtueIW','send_task','new_task','get_all_status','text/event-stream','10620589IiTBss','heartbeatInterval','agent','from_session','registered','send','processInbox'];a0_0x1ead=function(){return _0x2627eb;};return a0_0x1ead();}import{EventEmitter as a0_0x91c43c}from'events';import{hostname as a0_0x6b38b3}from'os';class T extends a0_0x91c43c{[a0_0x5aa207(0x107)];['alias'];['token'];[a0_0x5aa207(0xd9)];[a0_0x5aa207(0x109)];[a0_0x5aa207(0xd8)];[a0_0x5aa207(0xfa)];['heartbeatTimer'];[a0_0x5aa207(0xec)];[a0_0x5aa207(0x11e)]=!0x1;constructor(_0x47ad2f){const _0x5595b9=a0_0x5aa207;super();if(this[_0x5595b9(0x107)]=_0x47ad2f[_0x5595b9(0x107)][_0x5595b9(0x106)](/\/$/,''),this['alias']=_0x47ad2f[_0x5595b9(0x108)],this['token']=_0x47ad2f['token'],this[_0x5595b9(0xd9)]=_0x47ad2f[_0x5595b9(0xd9)]||_0x5595b9(0x100),this[_0x5595b9(0x109)]=_0x5595b9(0xee)+_0x47ad2f[_0x5595b9(0x108)]+'-'+Date['now']()[_0x5595b9(0xef)](0x24),this[_0x5595b9(0xd8)]=_0x47ad2f[_0x5595b9(0xd8)]??0x2bf20,this[_0x5595b9(0xfa)]=_0x47ad2f[_0x5595b9(0xfa)]??0xbb8,_0x47ad2f[_0x5595b9(0x110)]!==!0x1)this[_0x5595b9(0x105)]();}[a0_0x5aa207(0xf5)](_0x5fdeb3){const _0x2d8ca9=a0_0x5aa207;console[_0x2d8ca9(0xf5)]('['+new Date()['toTimeString']()['slice'](0x0,0x8)+_0x2d8ca9(0xcf)+this[_0x2d8ca9(0x108)]+']\x20'+_0x5fdeb3);}async[a0_0x5aa207(0x10d)](_0x45979e,_0x67f4c2){const _0x16d5cf=a0_0x5aa207;let _0x374bc2={'Content-Type':_0x16d5cf(0xe4),'Accept':_0x16d5cf(0xf6)};if(this[_0x16d5cf(0xe1)])_0x374bc2[_0x16d5cf(0xf9)]=_0x16d5cf(0xfd)+this[_0x16d5cf(0xe1)];let _0x22adec=await(await fetch(this['url']+'/mcp',{'method':_0x16d5cf(0x11a),'headers':_0x374bc2,'body':JSON[_0x16d5cf(0x114)]({'jsonrpc':_0x16d5cf(0xd0),'id':Date[_0x16d5cf(0xde)](),'method':_0x16d5cf(0x103),'params':{'name':_0x45979e,'arguments':_0x67f4c2}})}))[_0x16d5cf(0xf0)](),_0x3347e1=_0x22adec[_0x16d5cf(0xf2)](/data: (.+)/),_0xdefda1=_0x3347e1?JSON[_0x16d5cf(0x10e)](_0x3347e1[0x1]):JSON[_0x16d5cf(0x10e)](_0x22adec),_0x3a1676=_0xdefda1?.[_0x16d5cf(0x111)]?.[_0x16d5cf(0x10a)]?.[0x0]?.[_0x16d5cf(0xf0)];return _0x3a1676?JSON['parse'](_0x3a1676):_0xdefda1;}async[a0_0x5aa207(0x105)](){const _0x5f85e5=a0_0x5aa207;if(this[_0x5f85e5(0x11e)])return;this[_0x5f85e5(0x11e)]=!0x0,await this[_0x5f85e5(0xf3)]('idle'),this[_0x5f85e5(0xf5)](_0x5f85e5(0xdb)),this[_0x5f85e5(0xfc)]=setInterval(()=>{const _0x5eb5ea=_0x5f85e5;this[_0x5eb5ea(0xf3)](_0x5eb5ea(0xff))[_0x5eb5ea(0x119)](_0x13203a=>this['log'](_0x5eb5ea(0xfb)+_0x13203a[_0x5eb5ea(0xf7)]));},this[_0x5f85e5(0xd8)]),this[_0x5f85e5(0x116)]();}async[a0_0x5aa207(0x117)](){const _0x49f25e=a0_0x5aa207;if(this[_0x49f25e(0x11e)]=!0x1,this[_0x49f25e(0xec)]?.[_0x49f25e(0x11f)](),this[_0x49f25e(0xfc)])clearInterval(this['heartbeatTimer']);await this[_0x49f25e(0xf3)]('offline')[_0x49f25e(0x119)](()=>{}),this['log'](_0x49f25e(0xed));}async[a0_0x5aa207(0xdc)](_0x4d1e04,_0x422be9,_0x33f24d='normal'){const _0x58ff90=a0_0x5aa207;return this[_0x58ff90(0x10d)](_0x58ff90(0xd3),{'alias':_0x4d1e04,'task':_0x422be9,'priority':_0x33f24d,'from_session':this[_0x58ff90(0x108)]});}async[a0_0x5aa207(0xf7)](_0x2de477,_0x3fd06a){const _0x5cc294=a0_0x5aa207;return this[_0x5cc294(0x10d)]('send_message',{'alias':_0x2de477,'message':_0x3fd06a,'from_session':this[_0x5cc294(0x108)]});}async[a0_0x5aa207(0xe8)](_0x3b3fed,_0x184d4b,_0x4848ea=a0_0x5aa207(0xeb)){const _0x14bcfc=a0_0x5aa207;return this[_0x14bcfc(0x10d)](_0x14bcfc(0xdf),{'in_reply_to':_0x3b3fed,'text':_0x184d4b,'status':_0x4848ea});}async[a0_0x5aa207(0xf3)](_0x930c31,_0x51a838){const _0x519971=a0_0x5aa207;return this['call']('report_status',{'resume_id':this[_0x519971(0x109)],'alias':this[_0x519971(0x108)],'status':_0x930c31,'server':a0_0x6b38b3(),'hostname':a0_0x6b38b3(),'agent':this[_0x519971(0xd9)],'project_dir':process['cwd'](),..._0x51a838});}async[a0_0x5aa207(0x113)](){const _0x68d16f=a0_0x5aa207;return this[_0x68d16f(0x10d)](_0x68d16f(0xd5),{});}async[a0_0x5aa207(0x118)](_0xe805e0,_0x2e4b2e){const _0x1911cc=a0_0x5aa207;return this[_0x1911cc(0x10d)](_0x1911cc(0x118),{'message':_0xe805e0,'filter_server':_0x2e4b2e?.['server'],'filter_status':_0x2e4b2e?.[_0x1911cc(0xf3)]});}async[a0_0x5aa207(0x116)](){const _0x34f5e5=a0_0x5aa207;let _0x44fca8=encodeURIComponent(this['alias']),_0x376b8f=this[_0x34f5e5(0x107)]+_0x34f5e5(0xf4)+_0x44fca8,_0x15a433=this[_0x34f5e5(0xfa)];while(this[_0x34f5e5(0x11e)]){try{this[_0x34f5e5(0xec)]=new AbortController();let _0x8d52a9={'Accept':_0x34f5e5(0xd6)};if(this[_0x34f5e5(0xe1)])_0x8d52a9['Authorization']=_0x34f5e5(0xfd)+this[_0x34f5e5(0xe1)];let _0xf1718=await fetch(_0x376b8f,{'headers':_0x8d52a9,'signal':this[_0x34f5e5(0xec)]['signal']});if(!_0xf1718['ok']||!_0xf1718[_0x34f5e5(0xe7)]){this[_0x34f5e5(0xf5)]('SSE\x20failed:\x20'+_0xf1718[_0x34f5e5(0xf3)]),await this[_0x34f5e5(0x102)](_0x15a433),_0x15a433=Math[_0x34f5e5(0x112)](_0x15a433*1.5,0xea60);continue;}_0x15a433=this[_0x34f5e5(0xfa)];let _0x2fc049=_0xf1718[_0x34f5e5(0xe7)][_0x34f5e5(0xea)](),_0x3d6c41=new TextDecoder(),_0x3d7d38='';while(this[_0x34f5e5(0x11e)]){let {done:_0x4c9277,value:_0x1cf8ca}=await _0x2fc049[_0x34f5e5(0xe6)]();if(_0x4c9277)break;_0x3d7d38+=_0x3d6c41[_0x34f5e5(0x11d)](_0x1cf8ca,{'stream':!0x0});let _0x1b850d=_0x3d7d38[_0x34f5e5(0x115)]('\x0a');_0x3d7d38=_0x1b850d['pop']()||'';for(let _0x25a619 of _0x1b850d){if(!_0x25a619[_0x34f5e5(0xd1)](_0x34f5e5(0xe3)))continue;try{let _0x3ba9fb=JSON[_0x34f5e5(0x10e)](_0x25a619['slice'](0x6));if(_0x3ba9fb[_0x34f5e5(0xe9)]===_0x34f5e5(0xcd)){this['log']('SSE\x20connected'),this[_0x34f5e5(0xce)](_0x34f5e5(0xcd));continue;}if(_0x3ba9fb[_0x34f5e5(0xe9)]===_0x34f5e5(0xd4)||_0x3ba9fb[_0x34f5e5(0xe9)]===_0x34f5e5(0x104)||_0x3ba9fb[_0x34f5e5(0xe9)]===_0x34f5e5(0x118))await this[_0x34f5e5(0xdd)]();}catch{}}}}catch(_0x198ae9){if(_0x198ae9[_0x34f5e5(0x11c)]==='AbortError')break;this[_0x34f5e5(0xce)](_0x34f5e5(0xe2),_0x198ae9),this[_0x34f5e5(0xf5)](_0x34f5e5(0x10f)+_0x198ae9['message']);}if(this[_0x34f5e5(0x11e)])this[_0x34f5e5(0xce)](_0x34f5e5(0xed)),this[_0x34f5e5(0xf5)]('SSE\x20reconnecting\x20in\x20'+_0x15a433/0x3e8+'s...'),await this[_0x34f5e5(0x102)](_0x15a433),_0x15a433=Math[_0x34f5e5(0x112)](_0x15a433*1.5,0xea60);}}async[a0_0x5aa207(0xdd)](){const _0x3d456e=a0_0x5aa207;try{let _0x12d9d9=(await this['call']('get_inbox',{'alias':this[_0x3d456e(0x108)],'limit':0xa}))?.[_0x3d456e(0x10b)]||[];for(let _0x297550 of _0x12d9d9)await this[_0x3d456e(0x10d)]('ack_inbox',{'alias':this[_0x3d456e(0x108)],'message_id':_0x297550['id']}),this['log']('←\x20'+_0x297550[_0x3d456e(0xda)]+':\x20'+_0x297550[_0x3d456e(0x10a)]['slice'](0x0,0x3c)),this['emit'](_0x3d456e(0xe5),_0x297550),this['emit']('message',_0x297550);}catch(_0x4476fa){this[_0x3d456e(0xf5)](_0x3d456e(0xe0)+_0x4476fa['message']);}}[a0_0x5aa207(0x102)](_0x3443b1){return new Promise(_0x5e965d=>setTimeout(_0x5e965d,_0x3443b1));}}var $=T;export{$ as default,T as CommHub};
1
+ const a0_0x5a5516=a0_0x4198;(function(_0x15269c,_0x25b536){const _0x3d0014=a0_0x4198,_0x209bca=_0x15269c();while(!![]){try{const _0x147e93=-parseInt(_0x3d0014(0x1aa))/0x1+-parseInt(_0x3d0014(0x139))/0x2+-parseInt(_0x3d0014(0x162))/0x3*(-parseInt(_0x3d0014(0x179))/0x4)+parseInt(_0x3d0014(0x152))/0x5*(parseInt(_0x3d0014(0x15e))/0x6)+-parseInt(_0x3d0014(0x168))/0x7*(-parseInt(_0x3d0014(0x157))/0x8)+-parseInt(_0x3d0014(0x13b))/0x9*(parseInt(_0x3d0014(0x136))/0xa)+parseInt(_0x3d0014(0x16f))/0xb*(parseInt(_0x3d0014(0x191))/0xc);if(_0x147e93===_0x25b536)break;else _0x209bca['push'](_0x209bca['shift']());}catch(_0xaa0b58){_0x209bca['push'](_0x209bca['shift']());}}}(a0_0x2c3d,0xd2bcf));import{EventEmitter as a0_0x565181}from'events';import{hostname as a0_0x306861}from'os';function a0_0x2c3d(){const _0x2f395d=['unknown\x20error','emit','normal','task.send.delivered','message','[REDACTED]','task.expired','\x20task_id=','startsWith','string','new_task','reconnectDelay','20afJnby','application/json,\x20text/event-stream','ack_inbox','3359310IWOhOb','json','5524317fYZPef','slice','pop','2.0','disconnect','content','replace','status','token','idle','SSE\x20reconnecting\x20in\x20','lifecycleTracking','toString','error','alias','toTimeString','heartbeatTimer','task.replied','SSE\x20connected','data:\x20',']\x20[commhub:','toAlias','messages','8292275rgDvdw','connected','mcp_http','send_message','\x20network_id=','40cjKPKC','application/json','parent_task_id','send_task','fromAlias','min','send','6zBlvIO','SSE\x20error:\x20','sseAbort','heartbeatInterval','801GzinQh','text','missing_task_id','inbox\x20error:\x20','task.ack','heartbeat\x20failed:\x20','1139495tCNznW','now','\x20parent_task_id=','error_message','[commhub:task]\x20','catch','split','44pvPVUA','cwd','to_alias','getAllStatus','from_session','name','resumeId','abort','Authorization','POST','23140JEeewP','send_failed','\x20error=','duration_ms','autoConnect','s...','call','SSE\x20failed:\x20','network_id','delivered','running','disconnected','\x20from=','sdk-','url','registered','\x20lifecycle=','processInbox','parentTaskId','log','<unknown>','decode','\x20to=','networkId','1013016YTOusd','completed','connectSSE','task','message_id','AbortError','\x20transport=','failed','connect','get_all_status','body','new_message','sdk','agent','sleep','<missing>','server','\x20duration_ms=','tools/call','task.send.start','/events/','broadcast','read','/mcp','type','584183JRZNyd','task_id','send_reply','parse','getReader','CommHub\x20rejected\x20task','offline','Bearer\x20','error_code','CommHub\x20response\x20omitted\x20task_id'];a0_0x2c3d=function(){return _0x2f395d;};return a0_0x2c3d();}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x1ed4d3,_0x47f3fc)=>(_0x1ed4d3??_0x47f3fc)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x5a5516(0x13c)](0x0,0xf0);function N(_0x2313aa){const _0x4acbe2=a0_0x5a5516;return(_0x2313aa instanceof Error?_0x2313aa[_0x4acbe2(0x12e)]:String(_0x2313aa??_0x4acbe2(0x1b4)))[_0x4acbe2(0x141)](K,_0x4acbe2(0x12f))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x37b722,_0x401aaf=process.env.ANET_TASK_TRACE_FORMAT===a0_0x5a5516(0x13a)){const _0x18922e=a0_0x5a5516;if(_0x401aaf)return JSON['stringify'](_0x37b722);let _0x2c1e5f=L(_0x37b722[_0x18922e(0x159)],_0x18922e(0x1a0)),_0x32bf89=L(_0x37b722['task_id'],'<pending>'),_0x281243=_0x37b722[_0x18922e(0x1b2)]?_0x18922e(0x17b)+_0x37b722[_0x18922e(0x1b2)]+':'+(_0x37b722[_0x18922e(0x16b)]??''):'';return _0x18922e(0x16c)+_0x37b722[_0x18922e(0x142)]+_0x18922e(0x185)+L(_0x37b722['from_alias'],_0x18922e(0x18d))+_0x18922e(0x18f)+L(_0x37b722[_0x18922e(0x171)],_0x18922e(0x18d))+_0x18922e(0x131)+_0x32bf89+_0x18922e(0x16a)+_0x2c1e5f+_0x18922e(0x156)+L(_0x37b722[_0x18922e(0x181)],_0x18922e(0x18d))+_0x18922e(0x197)+_0x37b722['transport']+_0x18922e(0x1a2)+_0x37b722[_0x18922e(0x17c)]+_0x18922e(0x189)+_0x37b722['lifecycle_tracking']+_0x281243;}function U(_0x8421bc){const _0x33ad58=a0_0x5a5516;return{'event':{'sending':_0x33ad58(0x1a4),'delivered':_0x33ad58(0x12d),'failed':'task.send.failed','acked':_0x33ad58(0x166),'started':'task.started','replied':_0x33ad58(0x14c),'expired':_0x33ad58(0x130)}[_0x8421bc['status']],..._0x8421bc};}function j(_0x41655c){const _0x49fe83=a0_0x5a5516;let _0x354c8b=_0x41655c?.[_0x49fe83(0x1ab)]||_0x41655c?.[_0x49fe83(0x195)]||_0x41655c?.['id'];if(_0x354c8b)return String(_0x354c8b);let _0x560801=_0x41655c?.[_0x49fe83(0x140)]?.[0x0]?.['text'];if(typeof _0x560801!==_0x49fe83(0x133))return null;try{let _0x412e47=JSON[_0x49fe83(0x1ad)](_0x560801);return _0x412e47?.[_0x49fe83(0x1ab)]||_0x412e47?.[_0x49fe83(0x195)]||_0x412e47?.['id']||null;}catch{return null;}}async function X(_0x46318a,_0x592390){const _0x58baf8=a0_0x5a5516;let _0x64a703=_0x592390[_0x58baf8(0x169)]??Date['now'],_0x33ee73=_0x64a703(),_0x5481e4=(_0x504d4f,_0x37e6ae,_0x354112,_0x102374)=>{const _0x4d48bd=_0x58baf8;_0x592390['log'](O(U({'from_alias':_0x46318a[_0x4d48bd(0x15b)],'to_alias':_0x46318a[_0x4d48bd(0x150)],'task_id':_0x37e6ae,'parent_task_id':_0x46318a[_0x4d48bd(0x18b)],'network_id':_0x46318a[_0x4d48bd(0x190)],'transport':_0x46318a['transport'],'status':_0x504d4f,'duration_ms':_0x64a703()-_0x33ee73,'lifecycle_tracking':_0x46318a[_0x4d48bd(0x146)],..._0x354112!==void 0x0?{'error_code':_0x102374||_0x4d48bd(0x17a),'error_message':N(_0x354112)}:{}})));};_0x5481e4('sending',null);try{let _0x11bd81=await _0x592390[_0x58baf8(0x15d)](),_0x58bbdb=j(_0x11bd81);if(_0x58bbdb)_0x5481e4(_0x58baf8(0x182),_0x58bbdb);else{if(_0x11bd81?.['ok']===!0x1||_0x11bd81?.[_0x58baf8(0x148)])_0x5481e4(_0x58baf8(0x198),_0x58bbdb,_0x11bd81?.[_0x58baf8(0x148)]||_0x58baf8(0x1af),'send_rejected');else _0x5481e4(_0x58baf8(0x198),null,_0x58baf8(0x1b3),_0x58baf8(0x164));}return _0x11bd81;}catch(_0xbbc7e){throw _0x5481e4(_0x58baf8(0x198),null,_0xbbc7e,_0x58baf8(0x17a)),_0xbbc7e;}}async function Y(_0x33feb8,_0x262940){const _0x356648=a0_0x5a5516;return X({'fromAlias':_0x33feb8[_0x356648(0x15b)],'toAlias':_0x33feb8[_0x356648(0x149)],'parentTaskId':_0x33feb8[_0x356648(0x18b)]||null,'networkId':_0x33feb8['networkId']||null,'transport':_0x356648(0x154),'lifecycleTracking':'not_tracked'},_0x262940);}class $ extends a0_0x565181{[a0_0x5a5516(0x187)];[a0_0x5a5516(0x149)];[a0_0x5a5516(0x143)];[a0_0x5a5516(0x19e)];[a0_0x5a5516(0x175)];[a0_0x5a5516(0x161)];[a0_0x5a5516(0x135)];[a0_0x5a5516(0x14b)];['sseAbort'];[a0_0x5a5516(0x183)]=!0x1;constructor(_0x5c19a3){const _0x387564=a0_0x5a5516;super();if(this[_0x387564(0x187)]=_0x5c19a3[_0x387564(0x187)]['replace'](/\/$/,''),this['alias']=_0x5c19a3[_0x387564(0x149)],this[_0x387564(0x143)]=_0x5c19a3[_0x387564(0x143)],this['agent']=_0x5c19a3['agent']||_0x387564(0x19d),this[_0x387564(0x175)]=_0x387564(0x186)+_0x5c19a3['alias']+'-'+Date[_0x387564(0x169)]()[_0x387564(0x147)](0x24),this['heartbeatInterval']=_0x5c19a3[_0x387564(0x161)]??0x2bf20,this['reconnectDelay']=_0x5c19a3[_0x387564(0x135)]??0xbb8,_0x5c19a3[_0x387564(0x17d)]!==!0x1)this[_0x387564(0x199)]();}['log'](_0x3c1486){const _0x523fbe=a0_0x5a5516;console[_0x523fbe(0x18c)]('['+new Date()[_0x523fbe(0x14a)]()[_0x523fbe(0x13c)](0x0,0x8)+_0x523fbe(0x14f)+this[_0x523fbe(0x149)]+']\x20'+_0x3c1486);}async[a0_0x5a5516(0x17f)](_0x498d11,_0x282c3d){const _0x38a0eb=a0_0x5a5516;let _0xd40574={'Content-Type':_0x38a0eb(0x158),'Accept':_0x38a0eb(0x137)};if(this[_0x38a0eb(0x143)])_0xd40574[_0x38a0eb(0x177)]=_0x38a0eb(0x1b1)+this[_0x38a0eb(0x143)];let _0x49312b=await(await fetch(this['url']+_0x38a0eb(0x1a8),{'method':_0x38a0eb(0x178),'headers':_0xd40574,'body':JSON['stringify']({'jsonrpc':_0x38a0eb(0x13e),'id':Date[_0x38a0eb(0x169)](),'method':_0x38a0eb(0x1a3),'params':{'name':_0x498d11,'arguments':_0x282c3d}})}))[_0x38a0eb(0x163)](),_0x29a284=_0x49312b['match'](/data: (.+)/),_0x1c00e6=_0x29a284?JSON[_0x38a0eb(0x1ad)](_0x29a284[0x1]):JSON['parse'](_0x49312b),_0x4911b5=_0x1c00e6?.['result']?.[_0x38a0eb(0x140)]?.[0x0]?.[_0x38a0eb(0x163)];return _0x4911b5?JSON[_0x38a0eb(0x1ad)](_0x4911b5):_0x1c00e6;}async[a0_0x5a5516(0x199)](){const _0x165f93=a0_0x5a5516;if(this[_0x165f93(0x183)])return;this[_0x165f93(0x183)]=!0x0,await this[_0x165f93(0x142)](_0x165f93(0x144)),this[_0x165f93(0x18c)](_0x165f93(0x188)),this['heartbeatTimer']=setInterval(()=>{const _0x177994=_0x165f93;this['status']('idle')[_0x177994(0x16d)](_0x49208b=>this[_0x177994(0x18c)](_0x177994(0x167)+_0x49208b['message']));},this[_0x165f93(0x161)]),this[_0x165f93(0x193)]();}async[a0_0x5a5516(0x13f)](){const _0xfdaeb=a0_0x5a5516;if(this['running']=!0x1,this[_0xfdaeb(0x160)]?.[_0xfdaeb(0x176)](),this['heartbeatTimer'])clearInterval(this[_0xfdaeb(0x14b)]);await this[_0xfdaeb(0x142)](_0xfdaeb(0x1b0))[_0xfdaeb(0x16d)](()=>{}),this[_0xfdaeb(0x18c)](_0xfdaeb(0x184));}async[a0_0x5a5516(0x15d)](_0x1f82cc,_0x140295,_0x40ed1a=a0_0x5a5516(0x1b6)){const _0x50fac1=a0_0x5a5516;return Y({'alias':_0x1f82cc,'fromAlias':this[_0x50fac1(0x149)]},{'log':_0x546a99=>console[_0x50fac1(0x18c)](_0x546a99),'send':()=>this[_0x50fac1(0x17f)](_0x50fac1(0x15a),{'alias':_0x1f82cc,'task':_0x140295,'priority':_0x40ed1a,'from_session':this['alias']})});}async[a0_0x5a5516(0x12e)](_0x5deeef,_0x5162de){const _0x34fc6e=a0_0x5a5516;return this[_0x34fc6e(0x17f)](_0x34fc6e(0x155),{'alias':_0x5deeef,'message':_0x5162de,'from_session':this['alias']});}async['reply'](_0x3fc241,_0x1f652c,_0x4da5ad=a0_0x5a5516(0x192)){const _0x13bb9b=a0_0x5a5516;return this[_0x13bb9b(0x17f)](_0x13bb9b(0x1ac),{'in_reply_to':_0x3fc241,'text':_0x1f652c,'status':_0x4da5ad});}async['status'](_0x37b660,_0x1a6a11){const _0x123901=a0_0x5a5516;return this[_0x123901(0x17f)]('report_status',{'resume_id':this[_0x123901(0x175)],'alias':this[_0x123901(0x149)],'status':_0x37b660,'server':a0_0x306861(),'hostname':a0_0x306861(),'agent':this['agent'],'project_dir':process[_0x123901(0x170)](),..._0x1a6a11});}async[a0_0x5a5516(0x172)](){const _0xf55ceb=a0_0x5a5516;return this[_0xf55ceb(0x17f)](_0xf55ceb(0x19a),{});}async[a0_0x5a5516(0x1a6)](_0x481e76,_0x3ffe61){const _0x4f610e=a0_0x5a5516;return this[_0x4f610e(0x17f)](_0x4f610e(0x1a6),{'message':_0x481e76,'filter_server':_0x3ffe61?.[_0x4f610e(0x1a1)],'filter_status':_0x3ffe61?.[_0x4f610e(0x142)]});}async[a0_0x5a5516(0x193)](){const _0x5b8ae3=a0_0x5a5516;let _0x57f0f1=encodeURIComponent(this[_0x5b8ae3(0x149)]),_0x19c48b=this[_0x5b8ae3(0x187)]+_0x5b8ae3(0x1a5)+_0x57f0f1,_0x482ae9=this['reconnectDelay'];while(this[_0x5b8ae3(0x183)]){try{this[_0x5b8ae3(0x160)]=new AbortController();let _0x26c04e={'Accept':'text/event-stream'};if(this['token'])_0x26c04e[_0x5b8ae3(0x177)]=_0x5b8ae3(0x1b1)+this[_0x5b8ae3(0x143)];let _0x311cb6=await fetch(_0x19c48b,{'headers':_0x26c04e,'signal':this[_0x5b8ae3(0x160)]['signal']});if(!_0x311cb6['ok']||!_0x311cb6[_0x5b8ae3(0x19b)]){this['log'](_0x5b8ae3(0x180)+_0x311cb6[_0x5b8ae3(0x142)]),await this[_0x5b8ae3(0x19f)](_0x482ae9),_0x482ae9=Math[_0x5b8ae3(0x15c)](_0x482ae9*1.5,0xea60);continue;}_0x482ae9=this[_0x5b8ae3(0x135)];let _0x25af85=_0x311cb6[_0x5b8ae3(0x19b)][_0x5b8ae3(0x1ae)](),_0x286fe5=new TextDecoder(),_0x460ef1='';while(this[_0x5b8ae3(0x183)]){let {done:_0x4ef2f2,value:_0x4ff49a}=await _0x25af85[_0x5b8ae3(0x1a7)]();if(_0x4ef2f2)break;_0x460ef1+=_0x286fe5[_0x5b8ae3(0x18e)](_0x4ff49a,{'stream':!0x0});let _0x2d7a63=_0x460ef1[_0x5b8ae3(0x16e)]('\x0a');_0x460ef1=_0x2d7a63[_0x5b8ae3(0x13d)]()||'';for(let _0x28853c of _0x2d7a63){if(!_0x28853c[_0x5b8ae3(0x132)](_0x5b8ae3(0x14e)))continue;try{let _0x446300=JSON['parse'](_0x28853c['slice'](0x6));if(_0x446300[_0x5b8ae3(0x1a9)]===_0x5b8ae3(0x153)){this['log'](_0x5b8ae3(0x14d)),this[_0x5b8ae3(0x1b5)]('connected');continue;}if(_0x446300[_0x5b8ae3(0x1a9)]===_0x5b8ae3(0x134)||_0x446300[_0x5b8ae3(0x1a9)]===_0x5b8ae3(0x19c)||_0x446300[_0x5b8ae3(0x1a9)]===_0x5b8ae3(0x1a6))await this[_0x5b8ae3(0x18a)]();}catch{}}}}catch(_0xd1bcf1){if(_0xd1bcf1[_0x5b8ae3(0x174)]===_0x5b8ae3(0x196))break;this['emit'](_0x5b8ae3(0x148),_0xd1bcf1),this[_0x5b8ae3(0x18c)](_0x5b8ae3(0x15f)+_0xd1bcf1['message']);}if(this[_0x5b8ae3(0x183)])this['emit'](_0x5b8ae3(0x184)),this[_0x5b8ae3(0x18c)](_0x5b8ae3(0x145)+_0x482ae9/0x3e8+_0x5b8ae3(0x17e)),await this[_0x5b8ae3(0x19f)](_0x482ae9),_0x482ae9=Math[_0x5b8ae3(0x15c)](_0x482ae9*1.5,0xea60);}}async[a0_0x5a5516(0x18a)](){const _0x98342c=a0_0x5a5516;try{let _0x1bd209=(await this['call']('get_inbox',{'alias':this[_0x98342c(0x149)],'limit':0xa}))?.[_0x98342c(0x151)]||[];for(let _0x199389 of _0x1bd209)await this['call'](_0x98342c(0x138),{'alias':this['alias'],'message_id':_0x199389['id']}),this[_0x98342c(0x18c)]('←\x20'+_0x199389[_0x98342c(0x173)]+':\x20'+_0x199389[_0x98342c(0x140)]['slice'](0x0,0x3c)),this[_0x98342c(0x1b5)](_0x98342c(0x194),_0x199389),this[_0x98342c(0x1b5)](_0x98342c(0x12e),_0x199389);}catch(_0x32ce2f){this[_0x98342c(0x18c)](_0x98342c(0x165)+_0x32ce2f[_0x98342c(0x12e)]);}}[a0_0x5a5516(0x19f)](_0x23e0e2){return new Promise(_0x4d0fc0=>setTimeout(_0x4d0fc0,_0x23e0e2));}}var F=$;function a0_0x4198(_0x16563b,_0x21cbac){_0x16563b=_0x16563b-0x12d;const _0x2c3d4d=a0_0x2c3d();let _0x4198b1=_0x2c3d4d[_0x16563b];return _0x4198b1;}export{F as default,$ as CommHub};
@@ -0,0 +1,46 @@
1
+ /** A prefix is hex digits and dashes. Shorter than this matches too much to be a deliberate choice. */
2
+ export declare const MIN_THREAD_PREFIX = 4;
3
+ export interface ExternalThread {
4
+ readonly threadId: string;
5
+ readonly path: string;
6
+ readonly bytes: number;
7
+ readonly inode: number | bigint;
8
+ readonly mtimeMs: number;
9
+ /** session_meta timestamp (falls back to the file's mtime when missing). */
10
+ readonly startedAt: string;
11
+ readonly cwd: string | null;
12
+ readonly firstPrompt: string | null;
13
+ }
14
+ /** The first thing the human typed: event_msg user_message, else a user message item that is not injected context. */
15
+ export declare function firstPromptOf(lines: readonly string[]): string | null;
16
+ export declare function threadFactsOf(path: string, threadId: string, mtimeMs: number, headBytes?: number): {
17
+ startedAt: string;
18
+ cwd: string | null;
19
+ firstPrompt: string | null;
20
+ };
21
+ /** Every rollout under `<codexHome>/sessions` (read-only), newest first. */
22
+ export declare function listExternalThreads(codexHome: string): ExternalThread[];
23
+ export type ThreadResolution = {
24
+ kind: "ok";
25
+ thread: ExternalThread;
26
+ } | {
27
+ kind: "invalid";
28
+ reason: string;
29
+ } | {
30
+ kind: "none";
31
+ }
32
+ /** The prefix names more than one thread. */
33
+ | {
34
+ kind: "ambiguous";
35
+ matches: readonly ExternalThread[];
36
+ }
37
+ /** One thread id, but more than one rollout file carries it — which one is the conversation is a guess. */
38
+ | {
39
+ kind: "duplicate";
40
+ matches: readonly ExternalThread[];
41
+ };
42
+ export declare function resolveExternalThread(threads: readonly ExternalThread[], query: string): ThreadResolution;
43
+ /** Shortest prefix (≥ minLen) of each id that no other id in the list shares. */
44
+ export declare function shortIds(ids: readonly string[], minLen?: number): Map<string, string>;
45
+ /** Numbered table for the picker / the non-TTY listing. Local time is not used: the stamp is the UTC one codex wrote. */
46
+ export declare function formatThreadList(threads: readonly ExternalThread[], limit?: number): string[];