@sleep2agi/agent-network 2.3.0-preview.15 → 2.3.0-preview.151

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 (157) 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 +39 -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-copresence-bridge-log.d.ts +44 -0
  26. package/dist/src/codex-copresence-login-gate.d.ts +16 -0
  27. package/dist/src/codex-copresence-model.d.ts +23 -0
  28. package/dist/src/codex-copresence-preflight.d.ts +65 -0
  29. package/dist/src/codex-copresence-profile.d.ts +125 -0
  30. package/dist/src/codex-copresence-recovery.d.ts +58 -0
  31. package/dist/src/codex-copresence-thread.d.ts +13 -0
  32. package/dist/src/codex-external-appserver.d.ts +120 -0
  33. package/dist/src/codex-home-enforce.d.ts +88 -0
  34. package/dist/src/codex-lifecycle-account.d.ts +104 -0
  35. package/dist/src/codex-lifecycle-canary.d.ts +20 -0
  36. package/dist/src/codex-lifecycle-facts.d.ts +53 -0
  37. package/dist/src/codex-lifecycle-fork.d.ts +91 -0
  38. package/dist/src/codex-lifecycle-preflight.d.ts +77 -0
  39. package/dist/src/codex-lifecycle-receipt.d.ts +53 -0
  40. package/dist/src/codex-lifecycle-restart.d.ts +88 -0
  41. package/dist/src/codex-login-share-guard.d.ts +146 -0
  42. package/dist/src/codex-menu.d.ts +99 -0
  43. package/dist/src/codex-model-default.d.ts +6 -0
  44. package/dist/src/codex-node-login.d.ts +98 -0
  45. package/dist/src/codex-pending-thread-restart.d.ts +55 -0
  46. package/dist/src/codex-resume.d.ts +89 -0
  47. package/dist/src/codex-tui-client-health.d.ts +30 -0
  48. package/dist/src/commhub-response.d.ts +1 -0
  49. package/dist/src/controlled-upload.d.ts +83 -0
  50. package/dist/src/copresence-deps.d.ts +22 -0
  51. package/dist/src/copresence-identity.d.ts +363 -0
  52. package/dist/src/copresence-startup-diagnosis.d.ts +17 -0
  53. package/dist/src/daemon-adopt.d.ts +14 -0
  54. package/dist/src/daemon-anet-bin.d.ts +32 -0
  55. package/dist/src/daemon-capability-display.d.ts +110 -0
  56. package/dist/src/daemon-capability-display.js +21 -0
  57. package/dist/src/daemon-inherited-env.d.ts +9 -0
  58. package/dist/src/daemon-runtime-path-preflight.d.ts +22 -0
  59. package/dist/src/daemon-runtime-staleness.d.ts +13 -0
  60. package/dist/src/dashboard-managed-process.d.ts +35 -0
  61. package/dist/src/display-width.d.ts +27 -0
  62. package/dist/src/doctor-node-count.d.ts +28 -0
  63. package/dist/src/environ-alias.d.ts +14 -0
  64. package/dist/src/grok-attach-client.d.ts +129 -0
  65. package/dist/src/grok-build-drift.d.ts +15 -0
  66. package/dist/src/grok-copresence-disclosure.d.ts +11 -0
  67. package/dist/src/grok-copresence-orchestration.d.ts +75 -0
  68. package/dist/src/grok-copresence-profile.d.ts +65 -0
  69. package/dist/src/grok-create-mode.d.ts +19 -0
  70. package/dist/src/host-telemetry.d.ts +14 -0
  71. package/dist/src/hub-health-timeout.d.ts +4 -0
  72. package/dist/src/hub-server-version.d.ts +64 -0
  73. package/dist/src/hub-stop.d.ts +74 -0
  74. package/dist/src/hub-time-display.d.ts +20 -0
  75. package/dist/src/hub-version-skew.d.ts +19 -0
  76. package/dist/src/im/correlation-store.d.ts +34 -0
  77. package/dist/src/im/feishu/adapter.d.ts +54 -0
  78. package/dist/src/im/feishu/bridge.d.ts +78 -14
  79. package/dist/src/im/feishu/hub-upload.d.ts +88 -0
  80. package/dist/src/im/feishu/outbound-route.d.ts +62 -0
  81. package/dist/src/im/feishu/worker-lifecycle.d.ts +13 -0
  82. package/dist/src/im/feishu/worker.js +182 -143
  83. package/dist/src/im/types.d.ts +30 -1
  84. package/dist/src/inbox-drain.d.ts +20 -0
  85. package/dist/src/local-process-state.d.ts +12 -0
  86. package/dist/src/locale-diagnostic.d.ts +12 -0
  87. package/dist/src/login-client-label.d.ts +6 -0
  88. package/dist/src/ls-columns.d.ts +15 -0
  89. package/dist/src/mock-llm.d.ts +12 -0
  90. package/dist/src/node-activity-log.d.ts +4 -0
  91. package/dist/src/node-clone.d.ts +134 -0
  92. package/dist/src/node-delete-hub.d.ts +42 -0
  93. package/dist/src/node-files.d.ts +62 -0
  94. package/dist/src/node-locate.d.ts +60 -0
  95. package/dist/src/node-ls-all.d.ts +80 -0
  96. package/dist/src/node-menu.d.ts +40 -0
  97. package/dist/src/node-not-found.d.ts +1 -0
  98. package/dist/src/node-remote.d.ts +180 -0
  99. package/dist/src/node-running-guard.d.ts +9 -0
  100. package/dist/src/node-server-identity.d.ts +35 -0
  101. package/dist/src/node-server-payload.d.ts +66 -0
  102. package/dist/src/node-server-rules-file.d.ts +14 -0
  103. package/dist/src/node-server-version.d.ts +39 -0
  104. package/dist/src/node-server.js +8 -1
  105. package/dist/src/node-skills.d.ts +32 -0
  106. package/dist/src/normalize-runtime.d.ts +29 -2
  107. package/dist/src/offline-age.d.ts +29 -0
  108. package/dist/src/one-line-cell.d.ts +20 -0
  109. package/dist/src/opencode-agent-node-pair.d.ts +25 -0
  110. package/dist/src/opencode-auth-login.d.ts +43 -0
  111. package/dist/src/opencode-free-tier.d.ts +27 -0
  112. package/dist/src/opencode-generation-create.d.ts +27 -0
  113. package/dist/src/opencode-generation-record.d.ts +24 -0
  114. package/dist/src/opencode-launch-env.d.ts +13 -0
  115. package/dist/src/opencode-owner-mode.d.ts +6 -0
  116. package/dist/src/opencode-package-binary.d.ts +44 -0
  117. package/dist/src/opencode-pin.d.ts +61 -0
  118. package/dist/src/opencode-preset.d.ts +73 -0
  119. package/dist/src/opencode-runtime-binding.d.ts +30 -0
  120. package/dist/src/opencode-safe-root.d.ts +36 -0
  121. package/dist/src/opencode-smoke-env.d.ts +1 -0
  122. package/dist/src/opencode-versions.d.ts +44 -0
  123. package/dist/src/outbound-attachments.d.ts +60 -0
  124. package/dist/src/outbound-tool-names.d.ts +1 -0
  125. package/dist/src/owned-roots.d.ts +58 -0
  126. package/dist/src/owner-env-file.d.ts +2 -0
  127. package/dist/src/package-mode-preflight.d.ts +41 -0
  128. package/dist/src/posix-codex-copresence.d.ts +35 -0
  129. package/dist/src/posix-modes.d.ts +36 -0
  130. package/dist/src/primary-network.d.ts +23 -0
  131. package/dist/src/private-state.d.ts +10 -0
  132. package/dist/src/process-telemetry.d.ts +12 -0
  133. package/dist/src/profile-serialize.d.ts +1 -0
  134. package/dist/src/project-key.d.ts +1 -0
  135. package/dist/src/reply-local-links.d.ts +47 -0
  136. package/dist/src/reply-originator.d.ts +20 -0
  137. package/dist/src/resume-runtime-infer.d.ts +18 -0
  138. package/dist/src/rules-file.d.ts +53 -0
  139. package/dist/src/secret-shell-guidance.d.ts +4 -0
  140. package/dist/src/session-status-class.d.ts +48 -0
  141. package/dist/src/sibling-agent-node.d.ts +23 -0
  142. package/dist/src/stale-socket.d.ts +118 -0
  143. package/dist/src/subcommand-redirect.d.ts +26 -0
  144. package/dist/src/task-trace.d.ts +33 -0
  145. package/dist/src/tmux-attach.d.ts +11 -0
  146. package/dist/src/tmux-capability.d.ts +58 -0
  147. package/dist/src/tmux-exact-target.d.ts +36 -0
  148. package/dist/src/tmux-format.d.ts +20 -0
  149. package/dist/src/tmux-pane-prompt.d.ts +22 -0
  150. package/dist/src/tmux.d.ts +44 -0
  151. package/dist/src/token-cli.d.ts +13 -0
  152. package/dist/src/tool-allowlist.d.ts +28 -0
  153. package/dist/src/unsafe-package-path-reason.d.ts +31 -0
  154. package/dist/src/upgrade-channel.d.ts +31 -0
  155. package/dist/src/win-launcher.d.ts +20 -0
  156. package/dist/src/windows-codex-copresence.d.ts +60 -0
  157. package/package.json +11 -6
@@ -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,39 @@
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
+ export interface CliErrorReport {
20
+ /** 第一行:出了什么事。 */
21
+ summary: string;
22
+ /** 下一步该敲的命令(每条一行)。 */
23
+ next: string[];
24
+ /** 为日志解析保留的 `FATAL: Error: CODE` 形状(只在消息本身是错误码时)。 */
25
+ fatalCode?: string;
26
+ }
27
+ export declare function isDebugEnabled(env?: Record<string, string | undefined>): boolean;
28
+ export declare function isNetworkError(err: any): boolean;
29
+ export declare function describeCliError(err: any, ctx?: {
30
+ hub?: string;
31
+ configPath?: string;
32
+ }): CliErrorReport;
33
+ /** 顶层 catch 用:产出要打到 stderr 的全部行(已脱敏)。stack 只在 ANET_DEBUG=1 时附上。 */
34
+ export declare function formatTopLevelError(err: any, opts?: {
35
+ hub?: string;
36
+ env?: Record<string, string | undefined>;
37
+ }): string[];
38
+ /** 「连 hub 失败」的原因,一句短语。用在已经写了 `Cannot reach <hub>:` 的地方。 */
39
+ 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
- const a0_0x57f1ff=a0_0x101e;function a0_0x101e(_0x54fed8,_0x2dad15){_0x54fed8=_0x54fed8-0x1f2;const _0x748cb4=a0_0x748c();let _0x101e72=_0x748cb4[_0x54fed8];return _0x101e72;}(function(_0x3d6ecb,_0x4654e8){const _0x2f9768=a0_0x101e,_0x565f3a=_0x3d6ecb();while(!![]){try{const _0x5d10f4=-parseInt(_0x2f9768(0x236))/0x1+parseInt(_0x2f9768(0x212))/0x2+-parseInt(_0x2f9768(0x221))/0x3+parseInt(_0x2f9768(0x1f8))/0x4+parseInt(_0x2f9768(0x203))/0x5+parseInt(_0x2f9768(0x219))/0x6+parseInt(_0x2f9768(0x237))/0x7;if(_0x5d10f4===_0x4654e8)break;else _0x565f3a['push'](_0x565f3a['shift']());}catch(_0x17c87d){_0x565f3a['push'](_0x565f3a['shift']());}}}(a0_0x748c,0xe5fe4));import{EventEmitter as a0_0x364783}from'events';import{hostname as a0_0x257b58}from'os';class T extends a0_0x364783{[a0_0x57f1ff(0x22e)];[a0_0x57f1ff(0x201)];[a0_0x57f1ff(0x20d)];['agent'];[a0_0x57f1ff(0x21b)];[a0_0x57f1ff(0x213)];[a0_0x57f1ff(0x231)];[a0_0x57f1ff(0x1f9)];[a0_0x57f1ff(0x1fa)];[a0_0x57f1ff(0x20b)]=!0x1;constructor(_0x7e9fc6){const _0xd27749=a0_0x57f1ff;super();if(this['url']=_0x7e9fc6['url'][_0xd27749(0x244)](/\/$/,''),this[_0xd27749(0x201)]=_0x7e9fc6[_0xd27749(0x201)],this[_0xd27749(0x20d)]=_0x7e9fc6['token'],this['agent']=_0x7e9fc6[_0xd27749(0x21d)]||_0xd27749(0x248),this[_0xd27749(0x21b)]=_0xd27749(0x1fc)+_0x7e9fc6[_0xd27749(0x201)]+'-'+Date['now']()[_0xd27749(0x218)](0x24),this['heartbeatInterval']=_0x7e9fc6[_0xd27749(0x213)]??0x2bf20,this[_0xd27749(0x231)]=_0x7e9fc6[_0xd27749(0x231)]??0xbb8,_0x7e9fc6[_0xd27749(0x23b)]!==!0x1)this['connect']();}['log'](_0x4b3a02){const _0x82dcbb=a0_0x57f1ff;console[_0x82dcbb(0x22f)]('['+new Date()[_0x82dcbb(0x20f)]()[_0x82dcbb(0x1f6)](0x0,0x8)+']\x20[commhub:'+this['alias']+']\x20'+_0x4b3a02);}async['call'](_0x317f8b,_0x4ea8d6){const _0x3d188e=a0_0x57f1ff;let _0x5a1afd={'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream'};if(this['token'])_0x5a1afd['Authorization']='Bearer\x20'+this[_0x3d188e(0x20d)];let _0x153bee=await(await fetch(this[_0x3d188e(0x22e)]+_0x3d188e(0x1f5),{'method':_0x3d188e(0x228),'headers':_0x5a1afd,'body':JSON[_0x3d188e(0x22b)]({'jsonrpc':_0x3d188e(0x210),'id':Date[_0x3d188e(0x245)](),'method':'tools/call','params':{'name':_0x317f8b,'arguments':_0x4ea8d6}})}))[_0x3d188e(0x239)](),_0x30b6ca=_0x153bee[_0x3d188e(0x247)](/data: (.+)/),_0xf47e6f=_0x30b6ca?JSON['parse'](_0x30b6ca[0x1]):JSON[_0x3d188e(0x214)](_0x153bee),_0x362790=_0xf47e6f?.[_0x3d188e(0x21a)]?.[_0x3d188e(0x216)]?.[0x0]?.[_0x3d188e(0x239)];return _0x362790?JSON[_0x3d188e(0x214)](_0x362790):_0xf47e6f;}async[a0_0x57f1ff(0x232)](){const _0x2b9a59=a0_0x57f1ff;if(this[_0x2b9a59(0x20b)])return;this['running']=!0x0,await this['status'](_0x2b9a59(0x21f)),this['log'](_0x2b9a59(0x22a)),this[_0x2b9a59(0x1f9)]=setInterval(()=>{const _0x3fdc0b=_0x2b9a59;this[_0x3fdc0b(0x23c)](_0x3fdc0b(0x21f))[_0x3fdc0b(0x211)](_0x399825=>this[_0x3fdc0b(0x22f)]('heartbeat\x20failed:\x20'+_0x399825[_0x3fdc0b(0x200)]));},this['heartbeatInterval']),this[_0x2b9a59(0x1fd)]();}async['disconnect'](){const _0x44a6d0=a0_0x57f1ff;if(this[_0x44a6d0(0x20b)]=!0x1,this[_0x44a6d0(0x1fa)]?.[_0x44a6d0(0x204)](),this[_0x44a6d0(0x1f9)])clearInterval(this[_0x44a6d0(0x1f9)]);await this[_0x44a6d0(0x23c)](_0x44a6d0(0x1f7))['catch'](()=>{}),this[_0x44a6d0(0x22f)](_0x44a6d0(0x206));}async[a0_0x57f1ff(0x22d)](_0x3858c9,_0x4ed4d8,_0x294b99=a0_0x57f1ff(0x233)){const _0x589252=a0_0x57f1ff;return this[_0x589252(0x23f)]('send_task',{'alias':_0x3858c9,'task':_0x4ed4d8,'priority':_0x294b99,'from_session':this[_0x589252(0x201)]});}async[a0_0x57f1ff(0x200)](_0x539fd7,_0x176a28){const _0x88635=a0_0x57f1ff;return this[_0x88635(0x23f)](_0x88635(0x20e),{'alias':_0x539fd7,'message':_0x176a28,'from_session':this[_0x88635(0x201)]});}async[a0_0x57f1ff(0x217)](_0x2d9386,_0x415560,_0x425cd6=a0_0x57f1ff(0x220)){const _0x3132ee=a0_0x57f1ff;return this[_0x3132ee(0x23f)](_0x3132ee(0x1ff),{'in_reply_to':_0x2d9386,'text':_0x415560,'status':_0x425cd6});}async[a0_0x57f1ff(0x23c)](_0x28243d,_0x7e6cf2){const _0x443c45=a0_0x57f1ff;return this[_0x443c45(0x23f)](_0x443c45(0x240),{'resume_id':this['resumeId'],'alias':this['alias'],'status':_0x28243d,'server':a0_0x257b58(),'hostname':a0_0x257b58(),'agent':this[_0x443c45(0x21d)],'project_dir':process['cwd'](),..._0x7e6cf2});}async['getAllStatus'](){const _0x20a559=a0_0x57f1ff;return this[_0x20a559(0x23f)]('get_all_status',{});}async[a0_0x57f1ff(0x225)](_0x307972,_0x21c6ce){const _0x3f35ec=a0_0x57f1ff;return this[_0x3f35ec(0x23f)](_0x3f35ec(0x225),{'message':_0x307972,'filter_server':_0x21c6ce?.[_0x3f35ec(0x208)],'filter_status':_0x21c6ce?.[_0x3f35ec(0x23c)]});}async[a0_0x57f1ff(0x1fd)](){const _0x2536bc=a0_0x57f1ff;let _0x2901c9=encodeURIComponent(this[_0x2536bc(0x201)]),_0x1cad20=this[_0x2536bc(0x22e)]+'/events/'+_0x2901c9,_0x3c4ca0=this[_0x2536bc(0x231)];while(this['running']){try{this[_0x2536bc(0x1fa)]=new AbortController();let _0x5f0c75={'Accept':_0x2536bc(0x23e)};if(this[_0x2536bc(0x20d)])_0x5f0c75['Authorization']=_0x2536bc(0x202)+this['token'];let _0xa6ae1f=await fetch(_0x1cad20,{'headers':_0x5f0c75,'signal':this[_0x2536bc(0x1fa)][_0x2536bc(0x241)]});if(!_0xa6ae1f['ok']||!_0xa6ae1f[_0x2536bc(0x227)]){this[_0x2536bc(0x22f)](_0x2536bc(0x1fb)+_0xa6ae1f[_0x2536bc(0x23c)]),await this['sleep'](_0x3c4ca0),_0x3c4ca0=Math[_0x2536bc(0x23a)](_0x3c4ca0*1.5,0xea60);continue;}_0x3c4ca0=this[_0x2536bc(0x231)];let _0x15d782=_0xa6ae1f['body'][_0x2536bc(0x205)](),_0x3b2994=new TextDecoder(),_0x5719cd='';while(this[_0x2536bc(0x20b)]){let {done:_0x61e56a,value:_0x46bff0}=await _0x15d782['read']();if(_0x61e56a)break;_0x5719cd+=_0x3b2994[_0x2536bc(0x230)](_0x46bff0,{'stream':!0x0});let _0xef2cec=_0x5719cd[_0x2536bc(0x226)]('\x0a');_0x5719cd=_0xef2cec[_0x2536bc(0x1fe)]()||'';for(let _0x3b7359 of _0xef2cec){if(!_0x3b7359[_0x2536bc(0x224)](_0x2536bc(0x222)))continue;try{let _0x165e54=JSON[_0x2536bc(0x214)](_0x3b7359[_0x2536bc(0x1f6)](0x6));if(_0x165e54[_0x2536bc(0x234)]===_0x2536bc(0x22c)){this[_0x2536bc(0x22f)](_0x2536bc(0x1f3)),this[_0x2536bc(0x1f4)]('connected');continue;}if(_0x165e54['type']===_0x2536bc(0x235)||_0x165e54[_0x2536bc(0x234)]===_0x2536bc(0x20c)||_0x165e54[_0x2536bc(0x234)]===_0x2536bc(0x225))await this[_0x2536bc(0x207)]();}catch{}}}}catch(_0x269680){if(_0x269680[_0x2536bc(0x229)]===_0x2536bc(0x215))break;this[_0x2536bc(0x1f4)](_0x2536bc(0x23d),_0x269680),this[_0x2536bc(0x22f)](_0x2536bc(0x238)+_0x269680[_0x2536bc(0x200)]);}if(this[_0x2536bc(0x20b)])this['emit'](_0x2536bc(0x206)),this['log'](_0x2536bc(0x21c)+_0x3c4ca0/0x3e8+_0x2536bc(0x209)),await this['sleep'](_0x3c4ca0),_0x3c4ca0=Math[_0x2536bc(0x23a)](_0x3c4ca0*1.5,0xea60);}}async[a0_0x57f1ff(0x207)](){const _0x248cc7=a0_0x57f1ff;try{let _0x12827d=(await this['call'](_0x248cc7(0x20a),{'alias':this[_0x248cc7(0x201)],'limit':0xa}))?.[_0x248cc7(0x242)]||[];for(let _0x2cc4c9 of _0x12827d)await this[_0x248cc7(0x23f)](_0x248cc7(0x243),{'alias':this[_0x248cc7(0x201)],'message_id':_0x2cc4c9['id']}),this[_0x248cc7(0x22f)]('←\x20'+_0x2cc4c9[_0x248cc7(0x1f2)]+':\x20'+_0x2cc4c9[_0x248cc7(0x216)][_0x248cc7(0x1f6)](0x0,0x3c)),this[_0x248cc7(0x1f4)](_0x248cc7(0x21e),_0x2cc4c9),this[_0x248cc7(0x1f4)](_0x248cc7(0x200),_0x2cc4c9);}catch(_0x2d0577){this[_0x248cc7(0x22f)](_0x248cc7(0x246)+_0x2d0577['message']);}}[a0_0x57f1ff(0x223)](_0x1f3f87){return new Promise(_0xf1fa84=>setTimeout(_0xf1fa84,_0x1f3f87));}}var $=T;function a0_0x748c(){const _0xe4972d=['autoConnect','status','error','text/event-stream','call','report_status','signal','messages','ack_inbox','replace','now','inbox\x20error:\x20','match','sdk','from_session','SSE\x20connected','emit','/mcp','slice','offline','5667020RNCYmH','heartbeatTimer','sseAbort','SSE\x20failed:\x20','sdk-','connectSSE','pop','send_reply','message','alias','Bearer\x20','1455210fYJmFf','abort','getReader','disconnected','processInbox','server','s...','get_inbox','running','new_message','token','send_message','toTimeString','2.0','catch','749774OjJRIK','heartbeatInterval','parse','AbortError','content','reply','toString','1412286bwWKGN','result','resumeId','SSE\x20reconnecting\x20in\x20','agent','task','idle','completed','4672041vjJjbT','data:\x20','sleep','startsWith','broadcast','split','body','POST','name','registered','stringify','connected','send','url','log','decode','reconnectDelay','connect','normal','type','new_task','358874HzVAkD','3781456xzcCLB','SSE\x20error:\x20','text','min'];a0_0x748c=function(){return _0xe4972d;};return a0_0x748c();}export{$ as default,T as CommHub};
1
+ const a0_0x1d401e=a0_0x4987;function a0_0x4987(_0x160b1e,_0x400ab9){_0x160b1e=_0x160b1e-0x169;const _0x3647a6=a0_0x3647();let _0x498707=_0x3647a6[_0x160b1e];return _0x498707;}(function(_0x575bf9,_0x379bd1){const _0x5b5aa7=a0_0x4987,_0x37a9f2=_0x575bf9();while(!![]){try{const _0x300d21=parseInt(_0x5b5aa7(0x19d))/0x1*(-parseInt(_0x5b5aa7(0x1db))/0x2)+parseInt(_0x5b5aa7(0x193))/0x3+parseInt(_0x5b5aa7(0x19a))/0x4+parseInt(_0x5b5aa7(0x1a4))/0x5*(-parseInt(_0x5b5aa7(0x1cc))/0x6)+parseInt(_0x5b5aa7(0x1b2))/0x7*(parseInt(_0x5b5aa7(0x174))/0x8)+-parseInt(_0x5b5aa7(0x1cd))/0x9+-parseInt(_0x5b5aa7(0x1df))/0xa*(parseInt(_0x5b5aa7(0x1b0))/0xb);if(_0x300d21===_0x379bd1)break;else _0x37a9f2['push'](_0x37a9f2['shift']());}catch(_0x215802){_0x37a9f2['push'](_0x37a9f2['shift']());}}}(a0_0x3647,0xb49d9));import{EventEmitter as a0_0x5e81d5}from'events';import{hostname as a0_0x2f41ef}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x3977dd,_0x63c961)=>(_0x3977dd??_0x63c961)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x1d401e(0x19b)](0x0,0xf0);function N(_0x400a5f){const _0x11d8b9=a0_0x1d401e;return(_0x400a5f instanceof Error?_0x400a5f['message']:String(_0x400a5f??'unknown\x20error'))[_0x11d8b9(0x18e)](K,_0x11d8b9(0x194))[_0x11d8b9(0x18e)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x11d8b9(0x19b)](0x0,0xf0);}function O(_0x43d353,_0x4ce024=process.env.ANET_TASK_TRACE_FORMAT===a0_0x1d401e(0x17e)){const _0x282ad8=a0_0x1d401e;if(_0x4ce024)return JSON[_0x282ad8(0x1b1)](_0x43d353);let _0x3a4cc6=L(_0x43d353['parent_task_id'],'<missing>'),_0x48511c=L(_0x43d353['task_id'],_0x282ad8(0x189)),_0x2f6a23=_0x43d353[_0x282ad8(0x1a9)]?_0x282ad8(0x1b8)+_0x43d353['error_code']+':'+(_0x43d353[_0x282ad8(0x1ad)]??''):'';return _0x282ad8(0x171)+_0x43d353[_0x282ad8(0x1b5)]+_0x282ad8(0x1c3)+L(_0x43d353[_0x282ad8(0x1e4)],'<unknown>')+_0x282ad8(0x1dd)+L(_0x43d353[_0x282ad8(0x16a)],_0x282ad8(0x183))+_0x282ad8(0x16d)+_0x48511c+_0x282ad8(0x17f)+_0x3a4cc6+_0x282ad8(0x1d1)+L(_0x43d353[_0x282ad8(0x1e9)],'<unknown>')+_0x282ad8(0x1de)+_0x43d353['transport']+_0x282ad8(0x1d5)+_0x43d353[_0x282ad8(0x1e0)]+'\x20lifecycle='+_0x43d353[_0x282ad8(0x19e)]+_0x2f6a23;}function U(_0xcacd06){const _0x1f4490=a0_0x1d401e;return{'event':{'sending':_0x1f4490(0x187),'delivered':_0x1f4490(0x1ce),'failed':_0x1f4490(0x17d),'acked':_0x1f4490(0x196),'started':'task.started','replied':_0x1f4490(0x1a6),'expired':_0x1f4490(0x17b)}[_0xcacd06[_0x1f4490(0x1b5)]],..._0xcacd06};}function j(_0x547c8d){const _0x51d84c=a0_0x1d401e;let _0xb90c01=_0x547c8d?.[_0x51d84c(0x185)]||_0x547c8d?.[_0x51d84c(0x177)]||_0x547c8d?.['id'];if(_0xb90c01)return String(_0xb90c01);let _0x22295d=_0x547c8d?.[_0x51d84c(0x1b9)]?.[0x0]?.[_0x51d84c(0x18f)];if(typeof _0x22295d!==_0x51d84c(0x1d0))return null;try{let _0x1beb36=JSON[_0x51d84c(0x1c7)](_0x22295d);return _0x1beb36?.[_0x51d84c(0x185)]||_0x1beb36?.['message_id']||_0x1beb36?.['id']||null;}catch{return null;}}async function X(_0x5ebd87,_0x1c3bfe){const _0x15c7a5=a0_0x1d401e;let _0xde9a55=_0x1c3bfe['now']??Date[_0x15c7a5(0x1d4)],_0x26d8f0=_0xde9a55(),_0x477c8b=(_0x12ad27,_0x3b6c8a,_0x144f60,_0x3fc815)=>{const _0x41d230=_0x15c7a5;_0x1c3bfe[_0x41d230(0x182)](O(U({'from_alias':_0x5ebd87['fromAlias'],'to_alias':_0x5ebd87[_0x41d230(0x1a5)],'task_id':_0x3b6c8a,'parent_task_id':_0x5ebd87['parentTaskId'],'network_id':_0x5ebd87[_0x41d230(0x1c1)],'transport':_0x5ebd87[_0x41d230(0x1ac)],'status':_0x12ad27,'duration_ms':_0xde9a55()-_0x26d8f0,'lifecycle_tracking':_0x5ebd87[_0x41d230(0x1ea)],..._0x144f60!==void 0x0?{'error_code':_0x3fc815||_0x41d230(0x1be),'error_message':N(_0x144f60)}:{}})));};_0x477c8b(_0x15c7a5(0x197),null);try{let _0x38cf28=await _0x1c3bfe[_0x15c7a5(0x1ec)](),_0x18faeb=j(_0x38cf28);if(_0x18faeb)_0x477c8b('delivered',_0x18faeb);else{if(_0x38cf28?.['ok']===!0x1||_0x38cf28?.[_0x15c7a5(0x1c2)])_0x477c8b(_0x15c7a5(0x1a2),_0x18faeb,_0x38cf28?.['error']||_0x15c7a5(0x1d3),'send_rejected');else _0x477c8b('failed',null,_0x15c7a5(0x1af),_0x15c7a5(0x16e));}return _0x38cf28;}catch(_0x280e46){throw _0x477c8b(_0x15c7a5(0x1a2),null,_0x280e46,_0x15c7a5(0x1be)),_0x280e46;}}async function Y(_0x2f803b,_0x4032a4){const _0x47b089=a0_0x1d401e;return X({'fromAlias':_0x2f803b[_0x47b089(0x1ab)],'toAlias':_0x2f803b['alias'],'parentTaskId':_0x2f803b[_0x47b089(0x1d8)]||null,'networkId':_0x2f803b[_0x47b089(0x1c1)]||null,'transport':_0x47b089(0x169),'lifecycleTracking':_0x47b089(0x1e8)},_0x4032a4);}function a0_0x3647(){const _0x45adca=['normal','min','parentTaskId','tools/call','ack_inbox','26214sfnWTY','body','\x20to=','\x20transport=','2606270dxklYU','duration_ms','reconnectDelay','emit','abort','from_alias','POST','disconnect','sdk-','not_tracked','network_id','lifecycleTracking','Bearer\x20','send','AbortError','toString','mcp_http','to_alias','text/event-stream','call','\x20task_id=','missing_task_id','SSE\x20connected','heartbeatInterval','[commhub:task]\x20','offline','connected','32dOZqmv','cwd','result','message_id','SSE\x20failed:\x20','completed','type','task.expired','report_status','task.send.failed','json','\x20parent_task_id=','disconnected','idle','log','<unknown>','/events/','task_id','heartbeatTimer','task.send.start','agent','<pending>','SSE\x20error:\x20','data:\x20','send_message','processInbox','replace','text','new_task','new_message','catch','3140886hOYfCX','[REDACTED]','send_reply','task.ack','sending','getReader','Authorization','4874640tzXAZd','slice','running','28zHdeTl','lifecycle_tracking','connectSSE','startsWith','pop','failed','toTimeString','1971045bAttWc','toAlias','task.replied','match','split','error_code','task','fromAlias','transport','error_message','alias','CommHub\x20response\x20omitted\x20task_id','44OfySXK','stringify','2187409chhRXL','name','2.0','status','getAllStatus','connect','\x20error=','content','autoConnect','messages','broadcast','sleep','send_failed','read','message','networkId','error','\x20from=','inbox\x20error:\x20','reply','url','parse','token','resumeId',']\x20[commhub:','application/json,\x20text/event-stream','18hcMBgd','1652742LEIhxv','task.send.delivered','sseAbort','string','\x20network_id=','get_all_status','CommHub\x20rejected\x20task','now','\x20duration_ms='];a0_0x3647=function(){return _0x45adca;};return a0_0x3647();}class $ extends a0_0x5e81d5{[a0_0x1d401e(0x1c6)];[a0_0x1d401e(0x1ae)];[a0_0x1d401e(0x1c8)];[a0_0x1d401e(0x188)];['resumeId'];[a0_0x1d401e(0x170)];[a0_0x1d401e(0x1e1)];[a0_0x1d401e(0x186)];[a0_0x1d401e(0x1cf)];[a0_0x1d401e(0x19c)]=!0x1;constructor(_0x5220f1){const _0x3a90fb=a0_0x1d401e;super();if(this[_0x3a90fb(0x1c6)]=_0x5220f1[_0x3a90fb(0x1c6)][_0x3a90fb(0x18e)](/\/$/,''),this[_0x3a90fb(0x1ae)]=_0x5220f1[_0x3a90fb(0x1ae)],this[_0x3a90fb(0x1c8)]=_0x5220f1['token'],this['agent']=_0x5220f1[_0x3a90fb(0x188)]||'sdk',this[_0x3a90fb(0x1c9)]=_0x3a90fb(0x1e7)+_0x5220f1[_0x3a90fb(0x1ae)]+'-'+Date[_0x3a90fb(0x1d4)]()[_0x3a90fb(0x1ee)](0x24),this[_0x3a90fb(0x170)]=_0x5220f1[_0x3a90fb(0x170)]??0x2bf20,this['reconnectDelay']=_0x5220f1[_0x3a90fb(0x1e1)]??0xbb8,_0x5220f1[_0x3a90fb(0x1ba)]!==!0x1)this['connect']();}[a0_0x1d401e(0x182)](_0x3224d3){const _0x1e6eec=a0_0x1d401e;console[_0x1e6eec(0x182)]('['+new Date()[_0x1e6eec(0x1a3)]()[_0x1e6eec(0x19b)](0x0,0x8)+_0x1e6eec(0x1ca)+this['alias']+']\x20'+_0x3224d3);}async[a0_0x1d401e(0x16c)](_0x3638c8,_0x1c2c43){const _0x3c94f3=a0_0x1d401e;let _0x26751f={'Content-Type':'application/json','Accept':_0x3c94f3(0x1cb)};if(this[_0x3c94f3(0x1c8)])_0x26751f[_0x3c94f3(0x199)]=_0x3c94f3(0x1eb)+this[_0x3c94f3(0x1c8)];let _0x19d871=await(await fetch(this['url']+'/mcp',{'method':_0x3c94f3(0x1e5),'headers':_0x26751f,'body':JSON[_0x3c94f3(0x1b1)]({'jsonrpc':_0x3c94f3(0x1b4),'id':Date[_0x3c94f3(0x1d4)](),'method':_0x3c94f3(0x1d9),'params':{'name':_0x3638c8,'arguments':_0x1c2c43}})}))[_0x3c94f3(0x18f)](),_0x55b44e=_0x19d871[_0x3c94f3(0x1a7)](/data: (.+)/),_0x13f34b=_0x55b44e?JSON[_0x3c94f3(0x1c7)](_0x55b44e[0x1]):JSON['parse'](_0x19d871),_0x564a36=_0x13f34b?.[_0x3c94f3(0x176)]?.['content']?.[0x0]?.[_0x3c94f3(0x18f)];return _0x564a36?JSON[_0x3c94f3(0x1c7)](_0x564a36):_0x13f34b;}async[a0_0x1d401e(0x1b7)](){const _0x4d8a80=a0_0x1d401e;if(this[_0x4d8a80(0x19c)])return;this[_0x4d8a80(0x19c)]=!0x0,await this['status'](_0x4d8a80(0x181)),this[_0x4d8a80(0x182)]('registered'),this[_0x4d8a80(0x186)]=setInterval(()=>{const _0x3caf1b=_0x4d8a80;this[_0x3caf1b(0x1b5)](_0x3caf1b(0x181))[_0x3caf1b(0x192)](_0x4cb315=>this[_0x3caf1b(0x182)]('heartbeat\x20failed:\x20'+_0x4cb315[_0x3caf1b(0x1c0)]));},this['heartbeatInterval']),this[_0x4d8a80(0x19f)]();}async[a0_0x1d401e(0x1e6)](){const _0xa6bb61=a0_0x1d401e;if(this[_0xa6bb61(0x19c)]=!0x1,this[_0xa6bb61(0x1cf)]?.[_0xa6bb61(0x1e3)](),this['heartbeatTimer'])clearInterval(this['heartbeatTimer']);await this[_0xa6bb61(0x1b5)](_0xa6bb61(0x172))['catch'](()=>{}),this[_0xa6bb61(0x182)]('disconnected');}async[a0_0x1d401e(0x1ec)](_0xfe2449,_0x5e682d,_0x38c6ec=a0_0x1d401e(0x1d6)){const _0x13cbad=a0_0x1d401e;return Y({'alias':_0xfe2449,'fromAlias':this[_0x13cbad(0x1ae)]},{'log':_0x2ba205=>console['log'](_0x2ba205),'send':()=>this[_0x13cbad(0x16c)]('send_task',{'alias':_0xfe2449,'task':_0x5e682d,'priority':_0x38c6ec,'from_session':this['alias']})});}async[a0_0x1d401e(0x1c0)](_0x38ec9c,_0x3fdb6c){const _0x14d35f=a0_0x1d401e;return this['call'](_0x14d35f(0x18c),{'alias':_0x38ec9c,'message':_0x3fdb6c,'from_session':this['alias']});}async[a0_0x1d401e(0x1c5)](_0xd61ba0,_0x55d85d,_0x4aa19a=a0_0x1d401e(0x179)){const _0x48291e=a0_0x1d401e;return this['call'](_0x48291e(0x195),{'in_reply_to':_0xd61ba0,'text':_0x55d85d,'status':_0x4aa19a});}async[a0_0x1d401e(0x1b5)](_0x43cb09,_0x432e08){const _0x4af6f0=a0_0x1d401e;return this[_0x4af6f0(0x16c)](_0x4af6f0(0x17c),{'resume_id':this['resumeId'],'alias':this[_0x4af6f0(0x1ae)],'status':_0x43cb09,'server':a0_0x2f41ef(),'hostname':a0_0x2f41ef(),'agent':this[_0x4af6f0(0x188)],'project_dir':process[_0x4af6f0(0x175)](),..._0x432e08});}async[a0_0x1d401e(0x1b6)](){const _0x1093ee=a0_0x1d401e;return this['call'](_0x1093ee(0x1d2),{});}async[a0_0x1d401e(0x1bc)](_0x39633a,_0x232079){const _0x4a1dff=a0_0x1d401e;return this[_0x4a1dff(0x16c)](_0x4a1dff(0x1bc),{'message':_0x39633a,'filter_server':_0x232079?.['server'],'filter_status':_0x232079?.[_0x4a1dff(0x1b5)]});}async[a0_0x1d401e(0x19f)](){const _0x3a057f=a0_0x1d401e;let _0x448ca5=encodeURIComponent(this[_0x3a057f(0x1ae)]),_0x2d12fb=this['url']+_0x3a057f(0x184)+_0x448ca5,_0x4ec0b6=this[_0x3a057f(0x1e1)];while(this['running']){try{this[_0x3a057f(0x1cf)]=new AbortController();let _0x309078={'Accept':_0x3a057f(0x16b)};if(this[_0x3a057f(0x1c8)])_0x309078['Authorization']=_0x3a057f(0x1eb)+this[_0x3a057f(0x1c8)];let _0x191b51=await fetch(_0x2d12fb,{'headers':_0x309078,'signal':this[_0x3a057f(0x1cf)]['signal']});if(!_0x191b51['ok']||!_0x191b51['body']){this[_0x3a057f(0x182)](_0x3a057f(0x178)+_0x191b51[_0x3a057f(0x1b5)]),await this['sleep'](_0x4ec0b6),_0x4ec0b6=Math[_0x3a057f(0x1d7)](_0x4ec0b6*1.5,0xea60);continue;}_0x4ec0b6=this[_0x3a057f(0x1e1)];let _0x7a85d2=_0x191b51[_0x3a057f(0x1dc)][_0x3a057f(0x198)](),_0x279e7b=new TextDecoder(),_0x5c6769='';while(this[_0x3a057f(0x19c)]){let {done:_0x44c186,value:_0x1dc1da}=await _0x7a85d2[_0x3a057f(0x1bf)]();if(_0x44c186)break;_0x5c6769+=_0x279e7b['decode'](_0x1dc1da,{'stream':!0x0});let _0x383225=_0x5c6769[_0x3a057f(0x1a8)]('\x0a');_0x5c6769=_0x383225[_0x3a057f(0x1a1)]()||'';for(let _0x3e7ae2 of _0x383225){if(!_0x3e7ae2[_0x3a057f(0x1a0)](_0x3a057f(0x18b)))continue;try{let _0x12436f=JSON[_0x3a057f(0x1c7)](_0x3e7ae2[_0x3a057f(0x19b)](0x6));if(_0x12436f[_0x3a057f(0x17a)]===_0x3a057f(0x173)){this[_0x3a057f(0x182)](_0x3a057f(0x16f)),this[_0x3a057f(0x1e2)]('connected');continue;}if(_0x12436f[_0x3a057f(0x17a)]===_0x3a057f(0x190)||_0x12436f[_0x3a057f(0x17a)]===_0x3a057f(0x191)||_0x12436f[_0x3a057f(0x17a)]==='broadcast')await this['processInbox']();}catch{}}}}catch(_0x50cbad){if(_0x50cbad[_0x3a057f(0x1b3)]===_0x3a057f(0x1ed))break;this['emit'](_0x3a057f(0x1c2),_0x50cbad),this['log'](_0x3a057f(0x18a)+_0x50cbad[_0x3a057f(0x1c0)]);}if(this['running'])this['emit'](_0x3a057f(0x180)),this[_0x3a057f(0x182)]('SSE\x20reconnecting\x20in\x20'+_0x4ec0b6/0x3e8+'s...'),await this[_0x3a057f(0x1bd)](_0x4ec0b6),_0x4ec0b6=Math[_0x3a057f(0x1d7)](_0x4ec0b6*1.5,0xea60);}}async[a0_0x1d401e(0x18d)](){const _0x1d87bd=a0_0x1d401e;try{let _0x117632=(await this[_0x1d87bd(0x16c)]('get_inbox',{'alias':this[_0x1d87bd(0x1ae)],'limit':0xa}))?.[_0x1d87bd(0x1bb)]||[];for(let _0x35173b of _0x117632)await this[_0x1d87bd(0x16c)](_0x1d87bd(0x1da),{'alias':this[_0x1d87bd(0x1ae)],'message_id':_0x35173b['id']}),this[_0x1d87bd(0x182)]('←\x20'+_0x35173b['from_session']+':\x20'+_0x35173b[_0x1d87bd(0x1b9)]['slice'](0x0,0x3c)),this[_0x1d87bd(0x1e2)](_0x1d87bd(0x1aa),_0x35173b),this[_0x1d87bd(0x1e2)]('message',_0x35173b);}catch(_0x5d85ad){this['log'](_0x1d87bd(0x1c4)+_0x5d85ad[_0x1d87bd(0x1c0)]);}}['sleep'](_0x43b7cd){return new Promise(_0x4dfc57=>setTimeout(_0x4dfc57,_0x43b7cd));}}var F=$;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[];