@sleep2agi/agent-network 2.3.0-preview.20 → 2.3.0-preview.201
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -324
- package/dist/bin/anet.cjs +101 -0
- package/dist/bin/cli.d.ts +1 -1
- package/dist/bin/cli.js +20 -1
- package/dist/src/active-network-task.d.ts +28 -0
- package/dist/src/batch-workdir.d.ts +9 -0
- package/dist/src/bootstrap-password-db.d.ts +13 -0
- package/dist/src/channel-attachments.d.ts +29 -0
- package/dist/src/channel-inbox-wake.d.ts +21 -0
- package/dist/src/channel-meta.d.ts +10 -0
- package/dist/src/channel-peer-reply.d.ts +41 -0
- package/dist/src/channel-task-trace.d.ts +14 -0
- package/dist/src/claude-vendor-env.d.ts +28 -0
- package/dist/src/cli-args.d.ts +8 -0
- package/dist/src/cli-auth-session.d.ts +47 -0
- package/dist/src/cli-errors.d.ts +41 -0
- package/dist/src/cli-exit.d.ts +11 -0
- package/dist/src/cli-help.d.ts +10 -0
- package/dist/src/cli-version-display.d.ts +16 -0
- package/dist/src/client-task-trace.d.ts +9 -0
- package/dist/src/client.js +1 -1
- package/dist/src/codex-adopt.d.ts +46 -0
- package/dist/src/codex-auth-fingerprint.d.ts +211 -0
- package/dist/src/codex-bin-pin.d.ts +23 -0
- package/dist/src/codex-commhub-mcp.d.ts +22 -0
- package/dist/src/codex-copresence-bridge-log.d.ts +44 -0
- package/dist/src/codex-copresence-env.d.ts +5 -0
- package/dist/src/codex-copresence-login-gate.d.ts +18 -0
- package/dist/src/codex-copresence-model.d.ts +23 -0
- package/dist/src/codex-copresence-preflight.d.ts +78 -0
- package/dist/src/codex-copresence-profile.d.ts +126 -0
- package/dist/src/codex-copresence-recovery.d.ts +70 -0
- package/dist/src/codex-copresence-resume-timeout.d.ts +28 -0
- package/dist/src/codex-copresence-rollout-guard.d.ts +36 -0
- package/dist/src/codex-copresence-rpc.d.ts +17 -0
- package/dist/src/codex-copresence-thread.d.ts +13 -0
- package/dist/src/codex-copresence-yolo.d.ts +16 -0
- package/dist/src/codex-external-appserver.d.ts +130 -0
- package/dist/src/codex-fork-recovery.d.ts +52 -0
- package/dist/src/codex-home-enforce.d.ts +88 -0
- package/dist/src/codex-lifecycle-account.d.ts +104 -0
- package/dist/src/codex-lifecycle-canary.d.ts +20 -0
- package/dist/src/codex-lifecycle-facts.d.ts +53 -0
- package/dist/src/codex-lifecycle-fork.d.ts +91 -0
- package/dist/src/codex-lifecycle-preflight.d.ts +79 -0
- package/dist/src/codex-lifecycle-receipt.d.ts +53 -0
- package/dist/src/codex-lifecycle-restart.d.ts +88 -0
- package/dist/src/codex-login-share-guard.d.ts +146 -0
- package/dist/src/codex-menu.d.ts +99 -0
- package/dist/src/codex-model-default.d.ts +6 -0
- package/dist/src/codex-node-login.d.ts +98 -0
- package/dist/src/codex-pending-thread-restart.d.ts +69 -0
- package/dist/src/codex-reasoning-effort.d.ts +17 -0
- package/dist/src/codex-recovery-lease.d.ts +39 -0
- package/dist/src/codex-recovery-resource-gate.d.ts +15 -0
- package/dist/src/codex-resume.d.ts +89 -0
- package/dist/src/codex-rollout-history-guard.d.ts +84 -0
- package/dist/src/codex-tui-client-health.d.ts +30 -0
- package/dist/src/commhub-response.d.ts +1 -0
- package/dist/src/controlled-upload.d.ts +83 -0
- package/dist/src/copresence-deps.d.ts +22 -0
- package/dist/src/copresence-identity.d.ts +363 -0
- package/dist/src/copresence-startup-diagnosis.d.ts +17 -0
- package/dist/src/daemon-adopt.d.ts +14 -0
- package/dist/src/daemon-anet-bin.d.ts +32 -0
- package/dist/src/daemon-capability-display.d.ts +110 -0
- package/dist/src/daemon-capability-display.js +21 -0
- package/dist/src/daemon-codex-inventory.d.ts +65 -0
- package/dist/src/daemon-inherited-env.d.ts +9 -0
- package/dist/src/daemon-provider-account-custody.d.ts +28 -0
- package/dist/src/daemon-provider-account-readback.d.ts +3 -0
- package/dist/src/daemon-provider-application.d.ts +36 -0
- package/dist/src/daemon-provider-apply-command.d.ts +9 -0
- package/dist/src/daemon-provider-collect.d.ts +29 -0
- package/dist/src/daemon-provider-command.d.ts +7 -0
- package/dist/src/daemon-provider-initialize.d.ts +27 -0
- package/dist/src/daemon-provider-lifecycle.d.ts +4 -0
- package/dist/src/daemon-provider-store.d.ts +104 -0
- package/dist/src/daemon-runtime-path-preflight.d.ts +22 -0
- package/dist/src/daemon-runtime-staleness.d.ts +13 -0
- package/dist/src/dashboard-managed-process.d.ts +35 -0
- package/dist/src/display-width.d.ts +27 -0
- package/dist/src/doctor-node-count.d.ts +28 -0
- package/dist/src/grok-attach-client.d.ts +129 -0
- package/dist/src/grok-build-drift.d.ts +15 -0
- package/dist/src/grok-copresence-disclosure.d.ts +11 -0
- package/dist/src/grok-copresence-orchestration.d.ts +75 -0
- package/dist/src/grok-copresence-profile.d.ts +65 -0
- package/dist/src/grok-create-mode.d.ts +19 -0
- package/dist/src/host-telemetry.d.ts +14 -0
- package/dist/src/hub-health-timeout.d.ts +4 -0
- package/dist/src/hub-server-version.d.ts +64 -0
- package/dist/src/hub-stop.d.ts +74 -0
- package/dist/src/hub-time-display.d.ts +20 -0
- package/dist/src/hub-version-skew.d.ts +19 -0
- package/dist/src/im/correlation-store.d.ts +34 -0
- package/dist/src/im/feishu/adapter.d.ts +43 -0
- package/dist/src/im/feishu/bridge.d.ts +78 -14
- package/dist/src/im/feishu/hub-upload.d.ts +1 -1
- package/dist/src/im/feishu/worker-lifecycle.d.ts +13 -0
- package/dist/src/im/feishu/worker.js +174 -161
- package/dist/src/inbox-drain.d.ts +20 -0
- package/dist/src/local-process-state.d.ts +12 -0
- package/dist/src/locale-diagnostic.d.ts +12 -0
- package/dist/src/login-client-label.d.ts +6 -0
- package/dist/src/ls-columns.d.ts +15 -0
- package/dist/src/mock-llm.d.ts +12 -0
- package/dist/src/node-activity-log.d.ts +4 -0
- package/dist/src/node-clone.d.ts +134 -0
- package/dist/src/node-delete-hub.d.ts +42 -0
- package/dist/src/node-files.d.ts +62 -0
- package/dist/src/node-locate.d.ts +60 -0
- package/dist/src/node-ls-all.d.ts +80 -0
- package/dist/src/node-menu.d.ts +40 -0
- package/dist/src/node-not-found.d.ts +1 -0
- package/dist/src/node-remote.d.ts +180 -0
- package/dist/src/node-running-guard.d.ts +9 -0
- package/dist/src/node-secret-file.d.ts +32 -0
- package/dist/src/node-server-identity.d.ts +35 -0
- package/dist/src/node-server-payload.d.ts +66 -0
- package/dist/src/node-server-rules-file.d.ts +14 -0
- package/dist/src/node-server-version.d.ts +39 -0
- package/dist/src/node-server.d.ts +0 -12
- package/dist/src/node-server.js +8 -1
- package/dist/src/node-skills.d.ts +57 -0
- package/dist/src/normalize-runtime.d.ts +29 -2
- package/dist/src/offline-age.d.ts +29 -0
- package/dist/src/one-line-cell.d.ts +20 -0
- package/dist/src/opencode-agent-node-pair.d.ts +28 -0
- package/dist/src/opencode-auth-login.d.ts +43 -0
- package/dist/src/opencode-free-tier.d.ts +27 -0
- package/dist/src/opencode-generation-create.d.ts +27 -0
- package/dist/src/opencode-generation-record.d.ts +24 -0
- package/dist/src/opencode-launch-env.d.ts +13 -0
- package/dist/src/opencode-owner-mode.d.ts +6 -0
- package/dist/src/opencode-package-binary.d.ts +44 -0
- package/dist/src/opencode-pin.d.ts +28 -8
- package/dist/src/opencode-preset.d.ts +42 -8
- package/dist/src/opencode-runtime-binding.d.ts +30 -0
- package/dist/src/opencode-safe-root.d.ts +36 -0
- package/dist/src/opencode-shared-server-create.d.ts +5 -0
- package/dist/src/opencode-smoke-env.d.ts +1 -0
- package/dist/src/opencode-start-mode.d.ts +8 -0
- package/dist/src/opencode-v2-configured-model.d.ts +34 -0
- package/dist/src/opencode-v2-create-align.d.ts +18 -0
- package/dist/src/opencode-versions.d.ts +44 -0
- package/dist/src/os-user.d.ts +4 -0
- package/dist/src/outbound-attachments.d.ts +60 -0
- package/dist/src/outbound-tool-names.d.ts +1 -0
- package/dist/src/owned-roots.d.ts +58 -0
- package/dist/src/owner-env-file.d.ts +2 -0
- package/dist/src/package-mode-preflight.d.ts +41 -0
- package/dist/src/posix-codex-copresence.d.ts +33 -0
- package/dist/src/posix-modes.d.ts +36 -0
- package/dist/src/primary-network.d.ts +23 -0
- package/dist/src/private-state.d.ts +18 -0
- package/dist/src/process-telemetry.d.ts +12 -0
- package/dist/src/profile-serialize.d.ts +1 -0
- package/dist/src/provider-application-contract.d.ts +11 -0
- package/dist/src/provider-apply.d.ts +28 -0
- package/dist/src/provider-presets.d.ts +76 -0
- package/dist/src/reply-local-links.d.ts +47 -0
- package/dist/src/reply-originator.d.ts +20 -0
- package/dist/src/resume-runtime-infer.d.ts +18 -0
- package/dist/src/rules-file.d.ts +53 -0
- package/dist/src/scoped-secrets.d.ts +56 -0
- package/dist/src/secret-shell-guidance.d.ts +4 -0
- package/dist/src/session-status-class.d.ts +48 -0
- package/dist/src/shared/opencode-borrowed-launch-health.d.ts +29 -0
- package/dist/src/shared/provider-collection.d.ts +9 -0
- package/dist/src/shared/provider-initialization.d.ts +7 -0
- package/dist/src/shared/reserved-env.d.ts +3 -0
- package/dist/src/shared/scoped-secret-contract.d.ts +1 -0
- package/dist/src/shared/scoped-secret-env.d.ts +3 -0
- package/dist/src/sibling-agent-node.d.ts +23 -0
- package/dist/src/stale-socket.d.ts +118 -0
- package/dist/src/standalone-bin.d.ts +101 -0
- package/dist/src/standalone-build-stamp.d.ts +33 -0
- package/dist/src/start-resource-gate.d.ts +146 -0
- package/dist/src/stopped-receipt.d.ts +8 -0
- package/dist/src/subcommand-redirect.d.ts +26 -0
- package/dist/src/task-trace.d.ts +33 -0
- package/dist/src/tmux-attach.d.ts +11 -0
- package/dist/src/tmux-capability.d.ts +58 -0
- package/dist/src/tmux-exact-target.d.ts +36 -0
- package/dist/src/tmux-format.d.ts +20 -0
- package/dist/src/tmux-pane-prompt.d.ts +22 -0
- package/dist/src/tmux.d.ts +44 -0
- package/dist/src/token-cli.d.ts +13 -0
- package/dist/src/tool-allowlist.d.ts +28 -0
- package/dist/src/unsafe-package-path-reason.d.ts +31 -0
- package/dist/src/upgrade-channel.d.ts +31 -0
- package/dist/src/win-launcher.d.ts +20 -0
- package/dist/src/windows-codex-copresence.d.ts +238 -0
- package/dist/src/windows-rename-retry.d.ts +13 -0
- package/package.json +15 -7
|
@@ -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;
|
package/dist/src/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a0_0x55cde3=a0_0x589e;(function(_0x34ab43,_0x4d699b){const _0x179371=a0_0x589e,_0x1e9ffb=_0x34ab43();while(!![]){try{const _0x22f423=-parseInt(_0x179371(0x118))/0x1*(parseInt(_0x179371(0x11a))/0x2)+parseInt(_0x179371(0xe6))/0x3+-parseInt(_0x179371(0x122))/0x4+parseInt(_0x179371(0xe5))/0x5*(-parseInt(_0x179371(0xe8))/0x6)+parseInt(_0x179371(0x105))/0x7+-parseInt(_0x179371(0xf6))/0x8*(-parseInt(_0x179371(0x111))/0x9)+-parseInt(_0x179371(0x120))/0xa*(-parseInt(_0x179371(0xf8))/0xb);if(_0x22f423===_0x4d699b)break;else _0x1e9ffb['push'](_0x1e9ffb['shift']());}catch(_0x3042d0){_0x1e9ffb['push'](_0x1e9ffb['shift']());}}}(a0_0x580f,0x1fb82));import{EventEmitter as a0_0x110646}from'events';function a0_0x589e(_0x8845a1,_0x7706fc){_0x8845a1=_0x8845a1-0xd9;const _0x580f6f=a0_0x580f();let _0x589e4e=_0x580f6f[_0x8845a1];return _0x589e4e;}import{hostname as a0_0x516d2b}from'os';class T extends a0_0x110646{[a0_0x55cde3(0xe4)];['alias'];['token'];[a0_0x55cde3(0x11c)];[a0_0x55cde3(0x128)];['heartbeatInterval'];[a0_0x55cde3(0x113)];[a0_0x55cde3(0x112)];[a0_0x55cde3(0xde)];[a0_0x55cde3(0x11f)]=!0x1;constructor(_0x20d196){const _0x97b7f2=a0_0x55cde3;super();if(this[_0x97b7f2(0xe4)]=_0x20d196[_0x97b7f2(0xe4)][_0x97b7f2(0xec)](/\/$/,''),this[_0x97b7f2(0xda)]=_0x20d196['alias'],this[_0x97b7f2(0x12f)]=_0x20d196[_0x97b7f2(0x12f)],this[_0x97b7f2(0x11c)]=_0x20d196[_0x97b7f2(0x11c)]||'sdk',this['resumeId']=_0x97b7f2(0xfb)+_0x20d196[_0x97b7f2(0xda)]+'-'+Date[_0x97b7f2(0x108)]()[_0x97b7f2(0x110)](0x24),this[_0x97b7f2(0xe7)]=_0x20d196['heartbeatInterval']??0x2bf20,this[_0x97b7f2(0x113)]=_0x20d196['reconnectDelay']??0xbb8,_0x20d196[_0x97b7f2(0x10e)]!==!0x1)this[_0x97b7f2(0xff)]();}[a0_0x55cde3(0xea)](_0x4d400b){const _0x2a060a=a0_0x55cde3;console['log']('['+new Date()[_0x2a060a(0x130)]()[_0x2a060a(0x10b)](0x0,0x8)+_0x2a060a(0xdf)+this['alias']+']\x20'+_0x4d400b);}async[a0_0x55cde3(0xf2)](_0x50263e,_0x3d5af2){const _0x2c6380=a0_0x55cde3;let _0x574dd1={'Content-Type':_0x2c6380(0xfc),'Accept':'application/json,\x20text/event-stream'};if(this[_0x2c6380(0x12f)])_0x574dd1[_0x2c6380(0x106)]=_0x2c6380(0x11e)+this[_0x2c6380(0x12f)];let _0x14cd17=await(await fetch(this['url']+'/mcp',{'method':_0x2c6380(0xdb),'headers':_0x574dd1,'body':JSON[_0x2c6380(0x12d)]({'jsonrpc':'2.0','id':Date['now'](),'method':_0x2c6380(0x126),'params':{'name':_0x50263e,'arguments':_0x3d5af2}})}))[_0x2c6380(0x10c)](),_0x58e80b=_0x14cd17[_0x2c6380(0x119)](/data: (.+)/),_0xa3fc2a=_0x58e80b?JSON[_0x2c6380(0x100)](_0x58e80b[0x1]):JSON[_0x2c6380(0x100)](_0x14cd17),_0xb93a77=_0xa3fc2a?.[_0x2c6380(0xd9)]?.[_0x2c6380(0xfd)]?.[0x0]?.[_0x2c6380(0x10c)];return _0xb93a77?JSON['parse'](_0xb93a77):_0xa3fc2a;}async[a0_0x55cde3(0xff)](){const _0x4ccc1b=a0_0x55cde3;if(this['running'])return;this[_0x4ccc1b(0x11f)]=!0x0,await this[_0x4ccc1b(0x116)](_0x4ccc1b(0xdc)),this['log'](_0x4ccc1b(0xe0)),this[_0x4ccc1b(0x112)]=setInterval(()=>{const _0x4c4899=_0x4ccc1b;this[_0x4c4899(0x116)](_0x4c4899(0xdc))[_0x4c4899(0x101)](_0x51f1f8=>this['log'](_0x4c4899(0x12b)+_0x51f1f8['message']));},this['heartbeatInterval']),this['connectSSE']();}async[a0_0x55cde3(0xe3)](){const _0x106350=a0_0x55cde3;if(this[_0x106350(0x11f)]=!0x1,this['sseAbort']?.[_0x106350(0x124)](),this[_0x106350(0x112)])clearInterval(this[_0x106350(0x112)]);await this[_0x106350(0x116)](_0x106350(0xfa))[_0x106350(0x101)](()=>{}),this[_0x106350(0xea)](_0x106350(0xef));}async[a0_0x55cde3(0x114)](_0x15ca60,_0x28fbe6,_0x708890=a0_0x55cde3(0xf0)){const _0x542bed=a0_0x55cde3;return this[_0x542bed(0xf2)](_0x542bed(0xeb),{'alias':_0x15ca60,'task':_0x28fbe6,'priority':_0x708890,'from_session':this[_0x542bed(0xda)]});}async['message'](_0x37aaa4,_0x18879a){const _0x45a738=a0_0x55cde3;return this[_0x45a738(0xf2)](_0x45a738(0xe1),{'alias':_0x37aaa4,'message':_0x18879a,'from_session':this[_0x45a738(0xda)]});}async[a0_0x55cde3(0x11b)](_0x1e9792,_0x30acd6,_0x30e135=a0_0x55cde3(0x121)){const _0x452690=a0_0x55cde3;return this[_0x452690(0xf2)]('send_reply',{'in_reply_to':_0x1e9792,'text':_0x30acd6,'status':_0x30e135});}async[a0_0x55cde3(0x116)](_0x183a43,_0x285b1b){const _0x2f5ce3=a0_0x55cde3;return this[_0x2f5ce3(0xf2)](_0x2f5ce3(0xe9),{'resume_id':this[_0x2f5ce3(0x128)],'alias':this[_0x2f5ce3(0xda)],'status':_0x183a43,'server':a0_0x516d2b(),'hostname':a0_0x516d2b(),'agent':this[_0x2f5ce3(0x11c)],'project_dir':process[_0x2f5ce3(0x109)](),..._0x285b1b});}async[a0_0x55cde3(0xe2)](){const _0x277278=a0_0x55cde3;return this[_0x277278(0xf2)](_0x277278(0x12e),{});}async['broadcast'](_0x310472,_0x4dbcde){const _0x2af210=a0_0x55cde3;return this['call']('broadcast',{'message':_0x310472,'filter_server':_0x4dbcde?.[_0x2af210(0x104)],'filter_status':_0x4dbcde?.['status']});}async['connectSSE'](){const _0x206796=a0_0x55cde3;let _0x18fb45=encodeURIComponent(this['alias']),_0xd86e98=this[_0x206796(0xe4)]+_0x206796(0x107)+_0x18fb45,_0x6fce87=this[_0x206796(0x113)];while(this[_0x206796(0x11f)]){try{this['sseAbort']=new AbortController();let _0x49c727={'Accept':'text/event-stream'};if(this[_0x206796(0x12f)])_0x49c727[_0x206796(0x106)]=_0x206796(0x11e)+this[_0x206796(0x12f)];let _0x9bea0=await fetch(_0xd86e98,{'headers':_0x49c727,'signal':this[_0x206796(0xde)][_0x206796(0xf7)]});if(!_0x9bea0['ok']||!_0x9bea0['body']){this['log'](_0x206796(0xf4)+_0x9bea0[_0x206796(0x116)]),await this['sleep'](_0x6fce87),_0x6fce87=Math[_0x206796(0x12a)](_0x6fce87*1.5,0xea60);continue;}_0x6fce87=this[_0x206796(0x113)];let _0x296aa3=_0x9bea0['body'][_0x206796(0x10f)](),_0x38afe7=new TextDecoder(),_0x5b9cee='';while(this[_0x206796(0x11f)]){let {done:_0x90a0b8,value:_0x504e6d}=await _0x296aa3['read']();if(_0x90a0b8)break;_0x5b9cee+=_0x38afe7['decode'](_0x504e6d,{'stream':!0x0});let _0x461f6a=_0x5b9cee[_0x206796(0x11d)]('\x0a');_0x5b9cee=_0x461f6a[_0x206796(0x125)]()||'';for(let _0x551549 of _0x461f6a){if(!_0x551549[_0x206796(0x102)](_0x206796(0x123)))continue;try{let _0x2bcfd4=JSON[_0x206796(0x100)](_0x551549[_0x206796(0x10b)](0x6));if(_0x2bcfd4[_0x206796(0xee)]===_0x206796(0x10a)){this[_0x206796(0xea)]('SSE\x20connected'),this['emit']('connected');continue;}if(_0x2bcfd4[_0x206796(0xee)]===_0x206796(0xed)||_0x2bcfd4[_0x206796(0xee)]===_0x206796(0xf1)||_0x2bcfd4[_0x206796(0xee)]==='broadcast')await this[_0x206796(0x129)]();}catch{}}}}catch(_0x416da7){if(_0x416da7[_0x206796(0x115)]===_0x206796(0xf9))break;this[_0x206796(0xfe)]('error',_0x416da7),this[_0x206796(0xea)](_0x206796(0x10d)+_0x416da7[_0x206796(0xf3)]);}if(this[_0x206796(0x11f)])this[_0x206796(0xfe)](_0x206796(0xef)),this[_0x206796(0xea)](_0x206796(0x103)+_0x6fce87/0x3e8+_0x206796(0x117)),await this[_0x206796(0x12c)](_0x6fce87),_0x6fce87=Math[_0x206796(0x12a)](_0x6fce87*1.5,0xea60);}}async[a0_0x55cde3(0x129)](){const _0x2f4501=a0_0x55cde3;try{let _0x1519e7=(await this['call'](_0x2f4501(0x127),{'alias':this[_0x2f4501(0xda)],'limit':0xa}))?.['messages']||[];for(let _0x143a67 of _0x1519e7)await this['call'](_0x2f4501(0xf5),{'alias':this[_0x2f4501(0xda)],'message_id':_0x143a67['id']}),this[_0x2f4501(0xea)]('←\x20'+_0x143a67[_0x2f4501(0xdd)]+':\x20'+_0x143a67['content']['slice'](0x0,0x3c)),this[_0x2f4501(0xfe)]('task',_0x143a67),this[_0x2f4501(0xfe)]('message',_0x143a67);}catch(_0x1ab703){this[_0x2f4501(0xea)]('inbox\x20error:\x20'+_0x1ab703[_0x2f4501(0xf3)]);}}['sleep'](_0x191799){return new Promise(_0x509928=>setTimeout(_0x509928,_0x191799));}}var $=T;function a0_0x580f(){const _0x3cd159=['toString','1997019XsCKrI','heartbeatTimer','reconnectDelay','send','name','status','s...','12916ngSRCu','match','12ltcYJm','reply','agent','split','Bearer\x20','running','30WhPICY','completed','999016nKrBZf','data:\x20','abort','pop','tools/call','get_inbox','resumeId','processInbox','min','heartbeat\x20failed:\x20','sleep','stringify','get_all_status','token','toTimeString','result','alias','POST','idle','from_session','sseAbort',']\x20[commhub:','registered','send_message','getAllStatus','disconnect','url','265QDIvPn','495633cDTNhN','heartbeatInterval','10002CRzHdr','report_status','log','send_task','replace','new_task','type','disconnected','normal','new_message','call','message','SSE\x20failed:\x20','ack_inbox','8kiBdUi','signal','340648nUdqUP','AbortError','offline','sdk-','application/json','content','emit','connect','parse','catch','startsWith','SSE\x20reconnecting\x20in\x20','server','458619qXnxOw','Authorization','/events/','now','cwd','connected','slice','text','SSE\x20error:\x20','autoConnect','getReader'];a0_0x580f=function(){return _0x3cd159;};return a0_0x580f();}export{$ as default,T as CommHub};
|
|
1
|
+
const a0_0x5ec272=a0_0x5870;(function(_0xfdbf93,_0xe25e3b){const _0x149a27=a0_0x5870,_0x1735d9=_0xfdbf93();while(!![]){try{const _0x31e076=-parseInt(_0x149a27(0xec))/0x1+-parseInt(_0x149a27(0x94))/0x2*(-parseInt(_0x149a27(0x100))/0x3)+-parseInt(_0x149a27(0x9f))/0x4*(parseInt(_0x149a27(0xa3))/0x5)+parseInt(_0x149a27(0xb2))/0x6*(-parseInt(_0x149a27(0x8c))/0x7)+-parseInt(_0x149a27(0xdb))/0x8*(-parseInt(_0x149a27(0xc2))/0x9)+parseInt(_0x149a27(0xad))/0xa+-parseInt(_0x149a27(0xfe))/0xb*(parseInt(_0x149a27(0xf4))/0xc);if(_0x31e076===_0xe25e3b)break;else _0x1735d9['push'](_0x1735d9['shift']());}catch(_0x2b5b39){_0x1735d9['push'](_0x1735d9['shift']());}}}(a0_0x554b,0x26127));import{EventEmitter as a0_0x5be294}from'events';import{hostname as a0_0x46b32d}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x2fc60a,_0x56a94b)=>(_0x2fc60a??_0x56a94b)[a0_0x5ec272(0xd6)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x5ec272(0xfc)](0x0,0xf0);function N(_0x36881d){const _0x31638b=a0_0x5ec272;return(_0x36881d instanceof Error?_0x36881d[_0x31638b(0xe2)]:String(_0x36881d??_0x31638b(0xe1)))[_0x31638b(0xd6)](K,_0x31638b(0xcd))[_0x31638b(0xd6)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x5d8a0b,_0x339b7c=process.env.ANET_TASK_TRACE_FORMAT===a0_0x5ec272(0xca)){const _0x539c72=a0_0x5ec272;if(_0x339b7c)return JSON[_0x539c72(0xd1)](_0x5d8a0b);let _0x4608ac=L(_0x5d8a0b[_0x539c72(0xb0)],_0x539c72(0xa7)),_0x328e94=L(_0x5d8a0b[_0x539c72(0xb9)],'<pending>'),_0x4c7cf3=_0x5d8a0b[_0x539c72(0xd9)]?_0x539c72(0xdf)+_0x5d8a0b['error_code']+':'+(_0x5d8a0b[_0x539c72(0x8b)]??''):'';return _0x539c72(0x9e)+_0x5d8a0b['status']+_0x539c72(0xa1)+L(_0x5d8a0b[_0x539c72(0xe0)],_0x539c72(0x103))+_0x539c72(0x9a)+L(_0x5d8a0b['to_alias'],'<unknown>')+_0x539c72(0x102)+_0x328e94+_0x539c72(0xab)+_0x4608ac+_0x539c72(0xd0)+L(_0x5d8a0b[_0x539c72(0xbf)],'<unknown>')+_0x539c72(0xd7)+_0x5d8a0b[_0x539c72(0xe8)]+'\x20duration_ms='+_0x5d8a0b['duration_ms']+'\x20lifecycle='+_0x5d8a0b['lifecycle_tracking']+_0x4c7cf3;}function U(_0x142a7d){const _0x4913bf=a0_0x5ec272;return{'event':{'sending':_0x4913bf(0xc7),'delivered':_0x4913bf(0xf3),'failed':'task.send.failed','acked':_0x4913bf(0x8d),'started':_0x4913bf(0x98),'replied':'task.replied','expired':'task.expired'}[_0x142a7d[_0x4913bf(0xa4)]],..._0x142a7d};}function j(_0x1c5541){const _0x108d1a=a0_0x5ec272;let _0x408326=_0x1c5541?.[_0x108d1a(0xb9)]||_0x1c5541?.[_0x108d1a(0xef)]||_0x1c5541?.['id'];if(_0x408326)return String(_0x408326);let _0x8fd15f=_0x1c5541?.[_0x108d1a(0xff)]?.[0x0]?.[_0x108d1a(0xc8)];if(typeof _0x8fd15f!==_0x108d1a(0xbb))return null;try{let _0x4e8abe=JSON[_0x108d1a(0xf8)](_0x8fd15f);return _0x4e8abe?.[_0x108d1a(0xb9)]||_0x4e8abe?.[_0x108d1a(0xef)]||_0x4e8abe?.['id']||null;}catch{return null;}}async function X(_0x18a707,_0x796787){const _0x378e45=a0_0x5ec272;let _0xc257a9=_0x796787[_0x378e45(0xa0)]??Date[_0x378e45(0xa0)],_0x8e1d97=_0xc257a9(),_0x591daa=(_0x235864,_0x1274cf,_0x1b3b91,_0x14b6aa)=>{const _0x7c3f7=_0x378e45;_0x796787[_0x7c3f7(0x95)](O(U({'from_alias':_0x18a707[_0x7c3f7(0xe9)],'to_alias':_0x18a707[_0x7c3f7(0xbc)],'task_id':_0x1274cf,'parent_task_id':_0x18a707[_0x7c3f7(0xac)],'network_id':_0x18a707[_0x7c3f7(0x88)],'transport':_0x18a707[_0x7c3f7(0xe8)],'status':_0x235864,'duration_ms':_0xc257a9()-_0x8e1d97,'lifecycle_tracking':_0x18a707[_0x7c3f7(0x86)],..._0x1b3b91!==void 0x0?{'error_code':_0x14b6aa||_0x7c3f7(0xc5),'error_message':N(_0x1b3b91)}:{}})));};_0x591daa(_0x378e45(0xa8),null);try{let _0x413eaf=await _0x796787['send'](),_0x19c974=j(_0x413eaf);if(_0x19c974)_0x591daa(_0x378e45(0x89),_0x19c974);else{if(_0x413eaf?.['ok']===!0x1||_0x413eaf?.[_0x378e45(0xd8)])_0x591daa(_0x378e45(0xcc),_0x19c974,_0x413eaf?.[_0x378e45(0xd8)]||_0x378e45(0xa5),_0x378e45(0xe6));else _0x591daa('failed',null,_0x378e45(0xb4),_0x378e45(0xf5));}return _0x413eaf;}catch(_0xe472ab){throw _0x591daa(_0x378e45(0xcc),null,_0xe472ab,_0x378e45(0xc5)),_0xe472ab;}}async function Y(_0x42a1f4,_0xb46013){const _0x4de3d0=a0_0x5ec272;return X({'fromAlias':_0x42a1f4[_0x4de3d0(0xe9)],'toAlias':_0x42a1f4[_0x4de3d0(0x93)],'parentTaskId':_0x42a1f4['parentTaskId']||null,'networkId':_0x42a1f4[_0x4de3d0(0x88)]||null,'transport':_0x4de3d0(0xeb),'lifecycleTracking':_0x4de3d0(0xb6)},_0xb46013);}class $ extends a0_0x5be294{['url'];[a0_0x5ec272(0x93)];['token'];[a0_0x5ec272(0xf2)];[a0_0x5ec272(0xf0)];['heartbeatInterval'];['reconnectDelay'];[a0_0x5ec272(0x104)];[a0_0x5ec272(0x8a)];[a0_0x5ec272(0xcf)]=!0x1;constructor(_0x2781b0){const _0x19ee23=a0_0x5ec272;super();if(this['url']=_0x2781b0[_0x19ee23(0xf7)][_0x19ee23(0xd6)](/\/$/,''),this[_0x19ee23(0x93)]=_0x2781b0['alias'],this[_0x19ee23(0xb8)]=_0x2781b0['token'],this[_0x19ee23(0xf2)]=_0x2781b0['agent']||_0x19ee23(0xb3),this[_0x19ee23(0xf0)]=_0x19ee23(0xda)+_0x2781b0[_0x19ee23(0x93)]+'-'+Date['now']()[_0x19ee23(0xaf)](0x24),this[_0x19ee23(0xd4)]=_0x2781b0[_0x19ee23(0xd4)]??0x2bf20,this[_0x19ee23(0xfd)]=_0x2781b0['reconnectDelay']??0xbb8,_0x2781b0[_0x19ee23(0xd5)]!==!0x1)this['connect']();}[a0_0x5ec272(0x95)](_0x56f6b9){const _0x30e268=a0_0x5ec272;console['log']('['+new Date()['toTimeString']()['slice'](0x0,0x8)+_0x30e268(0xc3)+this[_0x30e268(0x93)]+']\x20'+_0x56f6b9);}async[a0_0x5ec272(0xde)](_0x4396af,_0x500efc){const _0x29872f=a0_0x5ec272;let _0x3bcdfd={'Content-Type':'application/json','Accept':_0x29872f(0xe7)};if(this[_0x29872f(0xb8)])_0x3bcdfd[_0x29872f(0xcb)]=_0x29872f(0xfb)+this[_0x29872f(0xb8)];let _0x1a0a25=await(await fetch(this['url']+_0x29872f(0x106),{'method':_0x29872f(0xa9),'headers':_0x3bcdfd,'body':JSON[_0x29872f(0xd1)]({'jsonrpc':_0x29872f(0xe5),'id':Date[_0x29872f(0xa0)](),'method':'tools/call','params':{'name':_0x4396af,'arguments':_0x500efc}})}))['text'](),_0x228e59=_0x1a0a25['match'](/data: (.+)/),_0x41bdd2=_0x228e59?JSON[_0x29872f(0xf8)](_0x228e59[0x1]):JSON[_0x29872f(0xf8)](_0x1a0a25),_0x55dc38=_0x41bdd2?.['result']?.[_0x29872f(0xff)]?.[0x0]?.[_0x29872f(0xc8)];return _0x55dc38?JSON[_0x29872f(0xf8)](_0x55dc38):_0x41bdd2;}async[a0_0x5ec272(0xb5)](){const _0x5113a9=a0_0x5ec272;if(this[_0x5113a9(0xcf)])return;this[_0x5113a9(0xcf)]=!0x0,await this[_0x5113a9(0xa4)](_0x5113a9(0x9d)),this[_0x5113a9(0x95)](_0x5113a9(0xee)),this['heartbeatTimer']=setInterval(()=>{const _0x3bf35b=_0x5113a9;this[_0x3bf35b(0xa4)](_0x3bf35b(0x9d))['catch'](_0x26ef42=>this[_0x3bf35b(0x95)](_0x3bf35b(0xc4)+_0x26ef42[_0x3bf35b(0xe2)]));},this[_0x5113a9(0xd4)]),this[_0x5113a9(0xbd)]();}async[a0_0x5ec272(0xfa)](){const _0x11d220=a0_0x5ec272;if(this['running']=!0x1,this[_0x11d220(0x8a)]?.[_0x11d220(0x99)](),this[_0x11d220(0x104)])clearInterval(this[_0x11d220(0x104)]);await this[_0x11d220(0xa4)](_0x11d220(0xc0))['catch'](()=>{}),this['log']('disconnected');}async[a0_0x5ec272(0xae)](_0x1eebf5,_0xcd0787,_0x3e97f4=a0_0x5ec272(0x91)){const _0x45c51f=a0_0x5ec272;return Y({'alias':_0x1eebf5,'fromAlias':this[_0x45c51f(0x93)]},{'log':_0x40fb12=>console[_0x45c51f(0x95)](_0x40fb12),'send':()=>this[_0x45c51f(0xde)](_0x45c51f(0xb1),{'alias':_0x1eebf5,'task':_0xcd0787,'priority':_0x3e97f4,'from_session':this[_0x45c51f(0x93)]})});}async['message'](_0x8fcbaf,_0x159910){const _0x491270=a0_0x5ec272;return this[_0x491270(0xde)](_0x491270(0xa2),{'alias':_0x8fcbaf,'message':_0x159910,'from_session':this[_0x491270(0x93)]});}async[a0_0x5ec272(0xdc)](_0x2f4384,_0x2dbbaa,_0x46b5ca=a0_0x5ec272(0x101)){const _0x39ed41=a0_0x5ec272;return this[_0x39ed41(0xde)]('send_reply',{'in_reply_to':_0x2f4384,'text':_0x2dbbaa,'status':_0x46b5ca});}async[a0_0x5ec272(0xa4)](_0x3d4567,_0x5577b7){const _0x5d8173=a0_0x5ec272;return this[_0x5d8173(0xde)](_0x5d8173(0x92),{'resume_id':this[_0x5d8173(0xf0)],'alias':this[_0x5d8173(0x93)],'status':_0x3d4567,'server':a0_0x46b32d(),'hostname':a0_0x46b32d(),'agent':this[_0x5d8173(0xf2)],'project_dir':process['cwd'](),..._0x5577b7});}async[a0_0x5ec272(0xed)](){const _0x3fc00c=a0_0x5ec272;return this[_0x3fc00c(0xde)]('get_all_status',{});}async['broadcast'](_0x22c3e2,_0x294d83){const _0x241fd7=a0_0x5ec272;return this['call'](_0x241fd7(0x9b),{'message':_0x22c3e2,'filter_server':_0x294d83?.[_0x241fd7(0x87)],'filter_status':_0x294d83?.['status']});}async[a0_0x5ec272(0xbd)](){const _0x4065e6=a0_0x5ec272;let _0x4852ae=encodeURIComponent(this['alias']),_0x5e05cd=this[_0x4065e6(0xf7)]+'/events/'+_0x4852ae,_0x332108=this[_0x4065e6(0xfd)];while(this[_0x4065e6(0xcf)]){try{this[_0x4065e6(0x8a)]=new AbortController();let _0x152751={'Accept':_0x4065e6(0x105)};if(this[_0x4065e6(0xb8)])_0x152751[_0x4065e6(0xcb)]=_0x4065e6(0xfb)+this[_0x4065e6(0xb8)];let _0x332e97=await fetch(_0x5e05cd,{'headers':_0x152751,'signal':this[_0x4065e6(0x8a)][_0x4065e6(0xc6)]});if(!_0x332e97['ok']||!_0x332e97[_0x4065e6(0xc1)]){this[_0x4065e6(0x95)](_0x4065e6(0x96)+_0x332e97[_0x4065e6(0xa4)]),await this[_0x4065e6(0x97)](_0x332108),_0x332108=Math['min'](_0x332108*1.5,0xea60);continue;}_0x332108=this[_0x4065e6(0xfd)];let _0x3c429c=_0x332e97[_0x4065e6(0xc1)][_0x4065e6(0xa6)](),_0x3d84ac=new TextDecoder(),_0x525df9='';while(this[_0x4065e6(0xcf)]){let {done:_0x1e63bf,value:_0x2cac0f}=await _0x3c429c['read']();if(_0x1e63bf)break;_0x525df9+=_0x3d84ac[_0x4065e6(0x8e)](_0x2cac0f,{'stream':!0x0});let _0x153dea=_0x525df9[_0x4065e6(0xbe)]('\x0a');_0x525df9=_0x153dea['pop']()||'';for(let _0x2ed117 of _0x153dea){if(!_0x2ed117['startsWith']('data:\x20'))continue;try{let _0x3dd6fd=JSON[_0x4065e6(0xf8)](_0x2ed117[_0x4065e6(0xfc)](0x6));if(_0x3dd6fd[_0x4065e6(0xc9)]==='connected'){this[_0x4065e6(0x95)](_0x4065e6(0xce)),this[_0x4065e6(0x90)]('connected');continue;}if(_0x3dd6fd['type']==='new_task'||_0x3dd6fd['type']===_0x4065e6(0x8f)||_0x3dd6fd[_0x4065e6(0xc9)]==='broadcast')await this[_0x4065e6(0xd2)]();}catch{}}}}catch(_0x2faecf){if(_0x2faecf[_0x4065e6(0xf1)]==='AbortError')break;this[_0x4065e6(0x90)]('error',_0x2faecf),this[_0x4065e6(0x95)](_0x4065e6(0xdd)+_0x2faecf[_0x4065e6(0xe2)]);}if(this[_0x4065e6(0xcf)])this[_0x4065e6(0x90)](_0x4065e6(0x9c)),this[_0x4065e6(0x95)](_0x4065e6(0xd3)+_0x332108/0x3e8+_0x4065e6(0xf9)),await this[_0x4065e6(0x97)](_0x332108),_0x332108=Math[_0x4065e6(0xe4)](_0x332108*1.5,0xea60);}}async[a0_0x5ec272(0xd2)](){const _0x12024b=a0_0x5ec272;try{let _0x5f45dd=(await this[_0x12024b(0xde)](_0x12024b(0xf6),{'alias':this['alias'],'limit':0xa}))?.[_0x12024b(0xb7)]||[];for(let _0x42cf26 of _0x5f45dd)await this[_0x12024b(0xde)](_0x12024b(0xba),{'alias':this[_0x12024b(0x93)],'message_id':_0x42cf26['id']}),this[_0x12024b(0x95)]('←\x20'+_0x42cf26[_0x12024b(0xea)]+':\x20'+_0x42cf26[_0x12024b(0xff)]['slice'](0x0,0x3c)),this[_0x12024b(0x90)](_0x12024b(0xe3),_0x42cf26),this['emit'](_0x12024b(0xe2),_0x42cf26);}catch(_0x12a0f5){this['log'](_0x12024b(0xaa)+_0x12a0f5[_0x12024b(0xe2)]);}}[a0_0x5ec272(0x97)](_0x2966ce){return new Promise(_0x1ffb37=>setTimeout(_0x1ffb37,_0x2966ce));}}var F=$;export{F as default,$ as CommHub};function a0_0x5870(_0x4d8925,_0x1ab951){_0x4d8925=_0x4d8925-0x86;const _0x554bde=a0_0x554b();let _0x587029=_0x554bde[_0x4d8925];return _0x587029;}function a0_0x554b(){const _0x150e06=['\x20task_id=','<unknown>','heartbeatTimer','text/event-stream','/mcp','lifecycleTracking','server','networkId','delivered','sseAbort','error_message','22449QHvGeY','task.ack','decode','new_message','emit','normal','report_status','alias','4208zzbKwR','log','SSE\x20failed:\x20','sleep','task.started','abort','\x20to=','broadcast','disconnected','idle','[commhub:task]\x20','16gePiDu','now','\x20from=','send_message','28850VBgVld','status','CommHub\x20rejected\x20task','getReader','<missing>','sending','POST','inbox\x20error:\x20','\x20parent_task_id=','parentTaskId','1300210bwrKnh','send','toString','parent_task_id','send_task','174TkRmgN','sdk','CommHub\x20response\x20omitted\x20task_id','connect','not_tracked','messages','token','task_id','ack_inbox','string','toAlias','connectSSE','split','network_id','offline','body','342BXBnnc',']\x20[commhub:','heartbeat\x20failed:\x20','send_failed','signal','task.send.start','text','type','json','Authorization','failed','[REDACTED]','SSE\x20connected','running','\x20network_id=','stringify','processInbox','SSE\x20reconnecting\x20in\x20','heartbeatInterval','autoConnect','replace','\x20transport=','error','error_code','sdk-','62232UaJwAA','reply','SSE\x20error:\x20','call','\x20error=','from_alias','unknown\x20error','message','task','min','2.0','send_rejected','application/json,\x20text/event-stream','transport','fromAlias','from_session','mcp_http','70057tGoBYt','getAllStatus','registered','message_id','resumeId','name','agent','task.send.delivered','12iZSEVR','missing_task_id','get_inbox','url','parse','s...','disconnect','Bearer\x20','slice','reconnectDelay','3094476UrVbFl','content','282wPDNHw','completed'];a0_0x554b=function(){return _0x150e06;};return a0_0x554b();}
|
|
@@ -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[];
|