@sleep2agi/agent-network 2.3.0-preview.16 → 2.3.0-preview.161
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 -0
- package/dist/bin/cli.js +20 -1
- package/dist/bin/goal-wake-log-render.d.ts +31 -0
- 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 +16 -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 +125 -0
- package/dist/src/codex-copresence-recovery.d.ts +67 -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 +15 -0
- package/dist/src/codex-copresence-thread.d.ts +13 -0
- package/dist/src/codex-external-appserver.d.ts +128 -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 +77 -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-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-inherited-env.d.ts +9 -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/environ-alias.d.ts +14 -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 +54 -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/outbound-route.d.ts +62 -0
- package/dist/src/im/feishu/worker-lifecycle.d.ts +13 -0
- package/dist/src/im/feishu/worker.js +180 -153
- 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-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.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 +61 -0
- package/dist/src/opencode-preset.d.ts +73 -0
- package/dist/src/opencode-runtime-binding.d.ts +30 -0
- package/dist/src/opencode-safe-root.d.ts +36 -0
- package/dist/src/opencode-smoke-env.d.ts +1 -0
- package/dist/src/opencode-versions.d.ts +44 -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 +10 -0
- package/dist/src/process-telemetry.d.ts +12 -0
- package/dist/src/profile-serialize.d.ts +1 -0
- package/dist/src/project-key.d.ts +1 -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/secret-shell-guidance.d.ts +4 -0
- package/dist/src/session-status-class.d.ts +48 -0
- package/dist/src/shared/reserved-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/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 +60 -0
- package/package.json +14 -7
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface InboxPage<T> {
|
|
2
|
+
ok?: boolean;
|
|
3
|
+
messages?: T[];
|
|
4
|
+
}
|
|
5
|
+
export interface DrainOptions<T extends {
|
|
6
|
+
id: string;
|
|
7
|
+
}> {
|
|
8
|
+
fetchPage: (limit: number) => Promise<InboxPage<T> | undefined | null>;
|
|
9
|
+
handle: (msg: T) => Promise<void>;
|
|
10
|
+
pageSize?: number;
|
|
11
|
+
maxPages?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface DrainResult {
|
|
14
|
+
delivered: number;
|
|
15
|
+
pages: number;
|
|
16
|
+
stoppedBy: "empty" | "short-page" | "max-pages" | "no-progress" | "fetch-error";
|
|
17
|
+
}
|
|
18
|
+
export declare function drainInbox<T extends {
|
|
19
|
+
id: string;
|
|
20
|
+
}>(opts: DrainOptions<T>): Promise<DrainResult>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type LocalProcessState = {
|
|
2
|
+
kind: "alive";
|
|
3
|
+
pid: number;
|
|
4
|
+
} | {
|
|
5
|
+
kind: "stale";
|
|
6
|
+
pid: number;
|
|
7
|
+
} | {
|
|
8
|
+
kind: "none";
|
|
9
|
+
};
|
|
10
|
+
export declare function describeLocalProcess(state: LocalProcessState): string;
|
|
11
|
+
/** doctor 印完节点清单后的那一句:说清这一列量的是本机,不是 hub。 */
|
|
12
|
+
export declare const LOCAL_VS_HUB_NOTE: string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface LocaleDiagnostic {
|
|
2
|
+
effectiveVariable: "LC_ALL" | "LC_CTYPE" | "LANG" | null;
|
|
3
|
+
effectiveValue: string | null;
|
|
4
|
+
shouldWarn: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Resolve the locale with the same precedence used by POSIX libc. Windows
|
|
8
|
+
* does not use these variables as its process Unicode boundary, so prescribing
|
|
9
|
+
* a POSIX locale there would be misleading.
|
|
10
|
+
*/
|
|
11
|
+
export declare function diagnoseLocale(env: Readonly<Record<string, string | undefined>>, platform: string): LocaleDiagnostic;
|
|
12
|
+
export declare function formatLocaleSource(diagnostic: LocaleDiagnostic): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 一列该多宽:装得下表头,也装得下这一列里最长的那个值。
|
|
3
|
+
*
|
|
4
|
+
* 🔴 两处用它的地方来源不同,但问题一样:
|
|
5
|
+
* - `anet node ls` 的 RUNTIME 列:值域来自 `SUPPORTED_RUNTIME_NAMES`(唯一真源);
|
|
6
|
+
* - `anet status` / `anet tasks` 的 STATUS 列:值域散在 server/ 里(另一个包),
|
|
7
|
+
* CLI 没法 import —— 但**要打印的那些行就在手上**,直接从数据算。
|
|
8
|
+
*
|
|
9
|
+
* 两种情况都不该写死一个数:写死的那个,下一次加 runtime / 加状态时就漂了。
|
|
10
|
+
*/
|
|
11
|
+
export declare function columnWidth(values: readonly unknown[], header: string): number;
|
|
12
|
+
/** RUNTIME 列的专用入口 —— 保留原名,调用点不用改。 */
|
|
13
|
+
export declare function runtimeColumnWidth(names: readonly string[], header?: string): number;
|
|
14
|
+
export declare function lsHeaderRow(runtimeWidth: number): string;
|
|
15
|
+
export declare function lsSeparatorRow(runtimeWidth: number): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const MOCK_LLM_FALLBACK = "(mock LLM: no rule matched)";
|
|
2
|
+
export type MockLlmRule = Readonly<{
|
|
3
|
+
in_substring: string;
|
|
4
|
+
out: string;
|
|
5
|
+
}>;
|
|
6
|
+
export type MockLlmResolution = Readonly<{
|
|
7
|
+
reply: string;
|
|
8
|
+
matched: boolean;
|
|
9
|
+
ruleIndex: number | null;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function loadMockLlmRules(path: string): readonly MockLlmRule[];
|
|
12
|
+
export declare function resolveMockLlmReply(rules: readonly MockLlmRule[], prompt: string, warn?: (message: string) => void): MockLlmResolution;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
export interface CloneArgs {
|
|
2
|
+
source: string;
|
|
3
|
+
target: string;
|
|
4
|
+
/** Raw --workdir as typed (resolved later against cwd). */
|
|
5
|
+
workdir?: string;
|
|
6
|
+
model?: string;
|
|
7
|
+
start: boolean;
|
|
8
|
+
}
|
|
9
|
+
export type CloneArgsResult = {
|
|
10
|
+
ok: true;
|
|
11
|
+
args: CloneArgs;
|
|
12
|
+
} | {
|
|
13
|
+
ok: false;
|
|
14
|
+
error: string;
|
|
15
|
+
} | {
|
|
16
|
+
ok: false;
|
|
17
|
+
help: true;
|
|
18
|
+
};
|
|
19
|
+
export declare const NODE_CLONE_USAGE = "anet node clone <source> <new-name> [--workdir <dir>] [--model <id>] [--start]\nanet node create <new-name> --from <source> [--workdir <dir>] [--model <id>] [--start]\n\n Make a new node with the same settings as <source>, under a NEW identity.\n The clone is registered with the Hub as its own node (new node_id + token);\n it never shares the source's identity, session, login or logs.\n\n Copied: runtime, model, tools, permission flags, prompts, non-secret env,\n rules file / skills / .mcp.json (with --workdir)\n Regenerated: node_id, token, session id, co-presence sockets\n Not copied: token, sessions/threads, logs, inbox, channel bot credentials,\n codex auth.json, secret env values (key names are kept)\n\n --workdir <dir> Put the clone in another project directory (created if\n missing; path must be ASCII). Default: the source's project\n directory (the current one), sharing its rules file/skills.\n --model <id> Use a different model than the source.\n --start Start the clone right after creating it.\n\n Never copy a node directory with cp -r: the copy keeps the same node_id and\n token, so the Hub delivers every task to both processes and it runs twice.";
|
|
20
|
+
/**
|
|
21
|
+
* Parse the tokens after the verb.
|
|
22
|
+
* mode "clone": [<source>, <new>, ...flags]
|
|
23
|
+
* mode "create-from": [<new>, ...flags] with a required --from <source>
|
|
24
|
+
*/
|
|
25
|
+
export declare function parseCloneArgs(tokens: readonly string[], mode: "clone" | "create-from"): CloneArgsResult;
|
|
26
|
+
/** Project rule: node working directories are ASCII (aliases may be Chinese, directories not). */
|
|
27
|
+
export declare function isAsciiPath(p: string): boolean;
|
|
28
|
+
export interface RefusalInput {
|
|
29
|
+
sourceId: string;
|
|
30
|
+
sourceProfile: Record<string, any>;
|
|
31
|
+
target: string;
|
|
32
|
+
sourceNodeDir: string;
|
|
33
|
+
targetNodeDir: string;
|
|
34
|
+
/** Present only when --workdir was given; absolute. */
|
|
35
|
+
explicitWorkdir?: string;
|
|
36
|
+
}
|
|
37
|
+
/** Every reason to stop before touching the Hub or the disk. null = go. */
|
|
38
|
+
export declare function cloneRefusal(i: RefusalInput): string | null;
|
|
39
|
+
export interface LedgerItem {
|
|
40
|
+
item: string;
|
|
41
|
+
note?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface CloneLedger {
|
|
44
|
+
copied: LedgerItem[];
|
|
45
|
+
regenerated: LedgerItem[];
|
|
46
|
+
skipped: LedgerItem[];
|
|
47
|
+
/** env keys whose value is a secret: the clone references `ref`, which the user must set. */
|
|
48
|
+
secrets: {
|
|
49
|
+
key: string;
|
|
50
|
+
ref: string;
|
|
51
|
+
}[];
|
|
52
|
+
}
|
|
53
|
+
export declare function emptyLedger(): CloneLedger;
|
|
54
|
+
export interface PlanInput {
|
|
55
|
+
sourceProfile: Record<string, any>;
|
|
56
|
+
target: string;
|
|
57
|
+
newNodeId: string;
|
|
58
|
+
/** Absolute project directory the clone will live in. */
|
|
59
|
+
targetWorkdir: string;
|
|
60
|
+
modelOverride?: string;
|
|
61
|
+
/** New claude-code-cli session id. */
|
|
62
|
+
newSession: () => string;
|
|
63
|
+
/** grok co-presence socket fields for the new node id (grokBuildCliCreationFields). */
|
|
64
|
+
grokFields?: (nodeId: string) => Record<string, unknown>;
|
|
65
|
+
}
|
|
66
|
+
/** Build the clone's profile (no token yet) and the ledger of what happened to each field. */
|
|
67
|
+
export declare function planCloneProfile(p: PlanInput, ledger?: CloneLedger): {
|
|
68
|
+
profile: Record<string, any>;
|
|
69
|
+
ledger: CloneLedger;
|
|
70
|
+
};
|
|
71
|
+
/** Files a codex-home may carry to the clone. Never auth.json, never .anet-copresence.env. */
|
|
72
|
+
export declare const CODEX_HOME_COPY: readonly ["config.toml", "AGENTS.md", "version.json"];
|
|
73
|
+
export declare const CODEX_HOME_COPY_DIRS: readonly ["skills"];
|
|
74
|
+
/** Workdir-level settings copied only when the clone gets its own --workdir. */
|
|
75
|
+
export declare const WORKDIR_COPY_FILES: readonly ["CLAUDE.md", "AGENTS.md"];
|
|
76
|
+
export declare const WORKDIR_COPY_DIRS: readonly [".claude/skills", ".agents/skills", ".grok/skills", ".opencode/skill", ".opencode/skills"];
|
|
77
|
+
/** Recursive copy that never follows symlinks and never copies credential-looking files. Returns files copied. */
|
|
78
|
+
export declare function copyTreeSafe(from: string, to: string, skipped: LedgerItem[], label: string): number;
|
|
79
|
+
/** Strip values from env/headers of every MCP server; drop the commhub entry (regenerated at start). */
|
|
80
|
+
export declare function sanitizeMcpJson(raw: string): {
|
|
81
|
+
text: string;
|
|
82
|
+
blanked: string[];
|
|
83
|
+
};
|
|
84
|
+
export interface CopyFilesInput {
|
|
85
|
+
sourceNodeDir: string;
|
|
86
|
+
targetNodeDir: string;
|
|
87
|
+
sourceWorkdir: string;
|
|
88
|
+
targetWorkdir: string;
|
|
89
|
+
}
|
|
90
|
+
/** Copy the whitelisted on-disk settings. The target node dir must already exist. */
|
|
91
|
+
export declare function copyCloneFiles(i: CopyFilesInput, ledger: CloneLedger): void;
|
|
92
|
+
export interface RunCloneInput {
|
|
93
|
+
sourceId: string;
|
|
94
|
+
/** Raw source config.json (as stored, before normalisation). */
|
|
95
|
+
sourceProfile: Record<string, any>;
|
|
96
|
+
target: string;
|
|
97
|
+
sourceNodeDir: string;
|
|
98
|
+
sourceWorkdir: string;
|
|
99
|
+
targetWorkdir: string;
|
|
100
|
+
/** True when the user passed --workdir. */
|
|
101
|
+
explicitWorkdir: boolean;
|
|
102
|
+
modelOverride?: string;
|
|
103
|
+
newNodeId: () => string;
|
|
104
|
+
newSession: () => string;
|
|
105
|
+
grokFields?: (nodeId: string) => Record<string, unknown>;
|
|
106
|
+
/** Hub registration — returns the new node's ntok_. Same endpoint `anet node create` uses. */
|
|
107
|
+
register: (profile: Record<string, any>) => Promise<string>;
|
|
108
|
+
/** Write config.json into targetNodeDir (the CLI passes its create writer). */
|
|
109
|
+
persist: (profile: Record<string, any>, targetNodeDir: string) => void;
|
|
110
|
+
}
|
|
111
|
+
export type RunCloneResult = {
|
|
112
|
+
ok: true;
|
|
113
|
+
profile: Record<string, any>;
|
|
114
|
+
ledger: CloneLedger;
|
|
115
|
+
targetNodeDir: string;
|
|
116
|
+
} | {
|
|
117
|
+
ok: false;
|
|
118
|
+
stage: "refused" | "register" | "write";
|
|
119
|
+
error: string;
|
|
120
|
+
};
|
|
121
|
+
export declare function runNodeClone(i: RunCloneInput): Promise<RunCloneResult>;
|
|
122
|
+
/** Test/default writer: the same config.json whitelist `anet node create` persists, mode 0600. */
|
|
123
|
+
export declare function defaultClonePersist(profile: Record<string, any>, targetNodeDir: string): void;
|
|
124
|
+
/** The summary table printed after a clone. Never prints a token or a secret value. */
|
|
125
|
+
export declare function formatCloneSummary(r: {
|
|
126
|
+
source: string;
|
|
127
|
+
target: string;
|
|
128
|
+
profile: Record<string, any>;
|
|
129
|
+
ledger: CloneLedger;
|
|
130
|
+
targetNodeDir: string;
|
|
131
|
+
sourceNodeId?: string;
|
|
132
|
+
}): string;
|
|
133
|
+
/** realpath that tolerates a missing path (resolves the nearest existing parent). */
|
|
134
|
+
export declare function realpathLoose(p: string): string;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type HubRemoval =
|
|
2
|
+
/** The Hub had a row with exactly this node_id and deleted it. */
|
|
3
|
+
{
|
|
4
|
+
kind: "removed";
|
|
5
|
+
nodeId: string;
|
|
6
|
+
}
|
|
7
|
+
/** No row with this node_id. `otherRows` share the alias but belong to other nodes — untouched. */
|
|
8
|
+
| {
|
|
9
|
+
kind: "absent";
|
|
10
|
+
nodeId: string;
|
|
11
|
+
otherRows: string[];
|
|
12
|
+
}
|
|
13
|
+
/** Nothing to do on a Hub: no Hub configured, or a legacy config without node_id. */
|
|
14
|
+
| {
|
|
15
|
+
kind: "skipped";
|
|
16
|
+
reason: "no-hub" | "no-node-id";
|
|
17
|
+
}
|
|
18
|
+
/** Unreachable / HTTP error / not logged in. Local deletion still happens; caller exits non-zero. */
|
|
19
|
+
| {
|
|
20
|
+
kind: "failed";
|
|
21
|
+
nodeId: string;
|
|
22
|
+
reason: string;
|
|
23
|
+
};
|
|
24
|
+
export type HubRemovalInput = {
|
|
25
|
+
hub?: string;
|
|
26
|
+
token?: string;
|
|
27
|
+
nodeId?: string;
|
|
28
|
+
alias?: string;
|
|
29
|
+
fetchImpl?: typeof fetch;
|
|
30
|
+
timeoutMs?: number;
|
|
31
|
+
};
|
|
32
|
+
export declare function removeNodeFromHub(input: HubRemovalInput): Promise<HubRemoval>;
|
|
33
|
+
/** The exact command that retries only the Hub half once the local files are gone. */
|
|
34
|
+
export declare function hubRetryCommand(nodeId: string, hub?: string): string;
|
|
35
|
+
/** Lines to print for a removal result. `warn` lines go to stderr. */
|
|
36
|
+
export declare function describeHubRemoval(r: HubRemoval, ctx: {
|
|
37
|
+
displayName: string;
|
|
38
|
+
hub?: string;
|
|
39
|
+
}): {
|
|
40
|
+
info: string[];
|
|
41
|
+
warn: string[];
|
|
42
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export declare const NODE_FILE_READ_MAX_BYTES: number;
|
|
2
|
+
export declare const NODE_FILES_LIST_MAX = 1000;
|
|
3
|
+
export declare const NODE_FILE_PATH_MAX = 1024;
|
|
4
|
+
/** 回给 hub 的 JSON 最长这么多字符(hub 端 ack 上限相同)。 */
|
|
5
|
+
export declare const NODE_FILES_RESULT_MAX_CHARS: number;
|
|
6
|
+
export type NodeFileType = "dir" | "file" | "symlink" | "other";
|
|
7
|
+
export type HiddenReason = "secret" | "skipped";
|
|
8
|
+
export interface NodeFileEntry {
|
|
9
|
+
name: string;
|
|
10
|
+
type: NodeFileType;
|
|
11
|
+
/** 普通文件的字节数;凭据文件不给。 */
|
|
12
|
+
size?: number;
|
|
13
|
+
/** 毫秒时间戳。 */
|
|
14
|
+
mtime?: number;
|
|
15
|
+
hidden_reason?: HiddenReason;
|
|
16
|
+
/** 目录(或指向目录的软链接)不允许进入。 */
|
|
17
|
+
no_descend?: boolean;
|
|
18
|
+
/** 软链接:指向工作目录内的什么;指向外面或断链为 null(不透露目标)。 */
|
|
19
|
+
link_type?: "dir" | "file" | null;
|
|
20
|
+
}
|
|
21
|
+
export interface NodeFilesListResult {
|
|
22
|
+
path: string;
|
|
23
|
+
entries: NodeFileEntry[];
|
|
24
|
+
truncated: boolean;
|
|
25
|
+
total: number;
|
|
26
|
+
}
|
|
27
|
+
export type NodeFileReadKind = "text" | "binary" | "too_large" | "secret";
|
|
28
|
+
export interface NodeFileReadResult {
|
|
29
|
+
path: string;
|
|
30
|
+
name: string;
|
|
31
|
+
kind: NodeFileReadKind;
|
|
32
|
+
size?: number;
|
|
33
|
+
mtime?: number;
|
|
34
|
+
content?: string;
|
|
35
|
+
hidden_reason?: HiddenReason;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 纯函数:一个路径是否属于凭据。
|
|
39
|
+
* relPosix —— 相对工作目录(请求的路径,或 realpath 之后相对工作目录的路径)。
|
|
40
|
+
* rootAbs —— 工作目录自身的绝对路径(posix);只作为「祖先目录」参与判定:工作目录本身
|
|
41
|
+
* 就在 .claude/ .codex/ 之类里面时,里面的一切都算凭据;在 .anet/ 里面时
|
|
42
|
+
* config.json* 算凭据。工作目录自己的名字不参与文件名规则。
|
|
43
|
+
* 任一祖先段(含末段)是凭据目录 → secret;末段按文件名规则判。大小写不敏感(macOS 默认不分大小写)。
|
|
44
|
+
*/
|
|
45
|
+
export declare function secretReasonFor(relPosix: string, rootAbs?: string): "secret" | null;
|
|
46
|
+
/** 纯函数:这个目录能不能进入。凭据目录 → secret;node_modules → skipped;路径上任一段命中同样不行。 */
|
|
47
|
+
export declare function noDescendReasonFor(relPosix: string, rootAbs?: string): HiddenReason | null;
|
|
48
|
+
/** 客户端给的路径 → 规范化相对路径("" = 根)。不合法抛错,错误信息不回显输入。 */
|
|
49
|
+
export declare function normalizeNodeRelPath(raw: unknown): string;
|
|
50
|
+
export interface ResolvedNodePath {
|
|
51
|
+
rootReal: string;
|
|
52
|
+
real: string;
|
|
53
|
+
/** realpath 之后相对根的路径(posix)。 */
|
|
54
|
+
relReal: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 解析并收在工作目录里:realpath(根) + realpath(根/rel),后者必须在前者之内。
|
|
58
|
+
* 不存在抛 `not found`;逃出去抛 `outside the work dir`。
|
|
59
|
+
*/
|
|
60
|
+
export declare function resolveInsideWorkDir(workDir: string, rel: string): Promise<ResolvedNodePath>;
|
|
61
|
+
export declare function listNodeFiles(workDir: string, rawPath: unknown): Promise<NodeFilesListResult>;
|
|
62
|
+
export declare function readNodeFile(workDir: string, rawPath: unknown): Promise<NodeFileReadResult>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export declare const CHILD_WORKDIRS_FILE = "child-workdirs.json";
|
|
2
|
+
export declare function childWorkdirsPath(root: string): string;
|
|
3
|
+
/** Same reader as agent-node's readChildWorkdirs: only absolute string values count. */
|
|
4
|
+
export declare function readChildWorkdirs(root: string): Record<string, string>;
|
|
5
|
+
/**
|
|
6
|
+
* Record that `alias`, created from `root`, lives in `workdir`.
|
|
7
|
+
* Not recorded when `workdir` is `root` itself, or when `aliasTakenHere` — the
|
|
8
|
+
* host daemon resolves a registered alias to the registered workdir, so an
|
|
9
|
+
* entry for a name that also exists in `root` would hide the local node from it.
|
|
10
|
+
*/
|
|
11
|
+
export declare function recordChildWorkdir(root: string, alias: string, workdir: string, aliasTakenHere: boolean): boolean;
|
|
12
|
+
/** `<root>/.anet/nodes/<id>` → `<root>`; anything else → null. */
|
|
13
|
+
export declare function rootOfNodeDir(nodeDir: string): string | null;
|
|
14
|
+
/** `node_dir` of every record in the codex login index directory. */
|
|
15
|
+
export declare function codexIndexNodeDirs(indexDir: string): string[];
|
|
16
|
+
/** Every other .anet root the indexes point at, canonical, deduplicated, existing, excluding `cwdRoot`. */
|
|
17
|
+
export declare function otherNodeRoots(cwdRoot: string, codexIndexDir: string): string[];
|
|
18
|
+
export interface NodeMatch {
|
|
19
|
+
/** Canonical .anet root (the directory to `cd` into). */
|
|
20
|
+
root: string;
|
|
21
|
+
/** Directory name under .anet/nodes/. */
|
|
22
|
+
id: string;
|
|
23
|
+
nodeId?: string;
|
|
24
|
+
/** How the ref matched: the directory name, the node_id, or a name/alias field. */
|
|
25
|
+
how: "dir" | "node_id" | "name";
|
|
26
|
+
}
|
|
27
|
+
export interface ProfileLike {
|
|
28
|
+
node_id?: string;
|
|
29
|
+
node_name?: string;
|
|
30
|
+
name?: string;
|
|
31
|
+
alias?: string;
|
|
32
|
+
}
|
|
33
|
+
/** All nodes in one root that `ref` names, one entry per node with its strongest match. */
|
|
34
|
+
export declare function matchNodesInRoot(root: string, ref: string, profiles: Array<{
|
|
35
|
+
id: string;
|
|
36
|
+
profile: ProfileLike | null;
|
|
37
|
+
}>): NodeMatch[];
|
|
38
|
+
export type DeleteTarget = {
|
|
39
|
+
kind: "here";
|
|
40
|
+
match: NodeMatch;
|
|
41
|
+
} | {
|
|
42
|
+
kind: "elsewhere";
|
|
43
|
+
match: NodeMatch;
|
|
44
|
+
} | {
|
|
45
|
+
kind: "ambiguous";
|
|
46
|
+
matches: NodeMatch[];
|
|
47
|
+
} | {
|
|
48
|
+
kind: "none";
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Which node `anet node delete <ref>` means.
|
|
52
|
+
* - a directory named `ref` in the current root wins outright (the long-standing
|
|
53
|
+
* behaviour: the node you are standing next to);
|
|
54
|
+
* - otherwise an exact node_id match, if exactly one node has it;
|
|
55
|
+
* - otherwise every match across all roots: one ⇒ that node, several ⇒ ambiguous.
|
|
56
|
+
*/
|
|
57
|
+
export declare function decideDeleteTarget(cwdRoot: string, matches: NodeMatch[]): DeleteTarget;
|
|
58
|
+
export declare function deleteCommandFor(m: NodeMatch, force: boolean, quote: (s: string) => string): string;
|
|
59
|
+
export declare function formatDeleteElsewhere(ref: string, m: NodeMatch, force: boolean, quote: (s: string) => string): string[];
|
|
60
|
+
export declare function formatDeleteAmbiguous(ref: string, matches: NodeMatch[], quote: (s: string) => string): string[];
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { type SessionClass } from "./session-status-class";
|
|
2
|
+
export declare const UNKNOWN_HOST = "(unknown host)";
|
|
3
|
+
export type NodeLsAllArgs = {
|
|
4
|
+
all: boolean;
|
|
5
|
+
json: boolean;
|
|
6
|
+
network: string | null;
|
|
7
|
+
error: string | null;
|
|
8
|
+
};
|
|
9
|
+
/** `--all`, `--json`, `--network <id|name>` (also `--network=<v>`). */
|
|
10
|
+
export declare function parseNodeLsAllArgs(argv: string[]): NodeLsAllArgs;
|
|
11
|
+
export type HubNetwork = {
|
|
12
|
+
network_id: string;
|
|
13
|
+
network_name?: string | null;
|
|
14
|
+
member_role?: string | null;
|
|
15
|
+
};
|
|
16
|
+
export type NetworkPick = {
|
|
17
|
+
ok: true;
|
|
18
|
+
network: HubNetwork;
|
|
19
|
+
} | {
|
|
20
|
+
ok: false;
|
|
21
|
+
error: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Same matching as `anet network use <name>` (exact id or exact name), plus a unique id prefix
|
|
25
|
+
* because `anet network ls` prints 12-character id prefixes. Ambiguity is refused, never guessed.
|
|
26
|
+
*/
|
|
27
|
+
export declare function pickNetwork(networks: HubNetwork[], ref: string | null, currentId: string | null | undefined): NetworkPick;
|
|
28
|
+
export type DaemonState = "online" | "offline" | "none-visible" | "unknown";
|
|
29
|
+
export type MachineNode = {
|
|
30
|
+
alias: string;
|
|
31
|
+
node_id: string | null;
|
|
32
|
+
runtime: string | null;
|
|
33
|
+
status: string | null;
|
|
34
|
+
status_class: SessionClass;
|
|
35
|
+
last_seen_at: string | null;
|
|
36
|
+
model: string | null;
|
|
37
|
+
};
|
|
38
|
+
export type MachineDaemon = {
|
|
39
|
+
alias: string;
|
|
40
|
+
online: boolean;
|
|
41
|
+
last_seen_at: string | null;
|
|
42
|
+
};
|
|
43
|
+
export type MachineGroup = {
|
|
44
|
+
hostname: string | null;
|
|
45
|
+
/** online = at least one daemon on this host is online (remote management possible). */
|
|
46
|
+
daemon: DaemonState;
|
|
47
|
+
daemons: MachineDaemon[];
|
|
48
|
+
nodes: MachineNode[];
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* @param daemons the Hub's daemon list, or null when it could not be read (state "unknown").
|
|
52
|
+
* An empty array means "the Hub showed you none" (state "none-visible").
|
|
53
|
+
*/
|
|
54
|
+
export declare function groupNodesByMachine(sessions: any[], daemons: any[] | null): MachineGroup[];
|
|
55
|
+
/** Compact English age for a table cell. Unparseable → "?", future → "in Ns (clock skew?)". */
|
|
56
|
+
export declare function shortAgo(raw: string | null, nowMs: number): string;
|
|
57
|
+
export type FormatOpts = {
|
|
58
|
+
network: HubNetwork;
|
|
59
|
+
nowMs: number;
|
|
60
|
+
/** why the daemon list could not be read (daemons === null) */
|
|
61
|
+
daemonsError?: string | null;
|
|
62
|
+
};
|
|
63
|
+
export declare function formatMachineGroups(groups: MachineGroup[], opts: FormatOpts): string[];
|
|
64
|
+
export declare function machineGroupsJson(groups: MachineGroup[], opts: {
|
|
65
|
+
network: HubNetwork;
|
|
66
|
+
daemonsError?: string | null;
|
|
67
|
+
}): {
|
|
68
|
+
machines: {
|
|
69
|
+
hostname: string | null;
|
|
70
|
+
daemon: DaemonState;
|
|
71
|
+
daemons: MachineDaemon[];
|
|
72
|
+
nodes: MachineNode[];
|
|
73
|
+
}[];
|
|
74
|
+
daemons_error?: string | undefined;
|
|
75
|
+
network: {
|
|
76
|
+
network_id: string;
|
|
77
|
+
network_name: string | null;
|
|
78
|
+
};
|
|
79
|
+
daemons_readable: boolean;
|
|
80
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type CodexMenuNode, type CodexNodeRow, type CollectEnv, type MenuIO, type PlannedCommand, type Runner } from "./codex-menu";
|
|
2
|
+
import { type RuntimeName } from "./normalize-runtime";
|
|
3
|
+
export interface NodeRow {
|
|
4
|
+
id: string;
|
|
5
|
+
alias: string;
|
|
6
|
+
runtime: RuntimeName;
|
|
7
|
+
/** "running" | "stopped" (codex co-presence may say "partial 1/3"). */
|
|
8
|
+
state: string;
|
|
9
|
+
running: boolean;
|
|
10
|
+
model: string;
|
|
11
|
+
modelIsDefault: boolean;
|
|
12
|
+
/** Shared human + agent TUI (grok-build-cli / opencode-cli co-presence, codex-app-server). */
|
|
13
|
+
copresence: boolean;
|
|
14
|
+
/** The runtime has a TUI to enter (claude-code-cli, or any co-presence node). */
|
|
15
|
+
hasTui: boolean;
|
|
16
|
+
/** Set for codex-sdk / codex-app-server: these go to the #532 codex actions. */
|
|
17
|
+
codex: CodexNodeRow | null;
|
|
18
|
+
}
|
|
19
|
+
export declare function collectNodeRows(nodes: CodexMenuNode[], env: CollectEnv): NodeRow[];
|
|
20
|
+
export declare function renderNodeTable(rows: NodeRow[], cwd: string): string;
|
|
21
|
+
export declare const NODE_CHEAT_SHEET: string;
|
|
22
|
+
export type NodeAction = "start" | "stop" | "restart" | "attach" | "log" | "model" | "delete";
|
|
23
|
+
export declare function nodeActions(row: NodeRow): {
|
|
24
|
+
key: NodeAction;
|
|
25
|
+
label: string;
|
|
26
|
+
}[];
|
|
27
|
+
export declare function planNodeAction(row: NodeRow, action: NodeAction, input?: {
|
|
28
|
+
model?: string;
|
|
29
|
+
}): PlannedCommand;
|
|
30
|
+
/** Returns the process exit code. Runs at most one command. */
|
|
31
|
+
export declare function nodeMenu(rows: NodeRow[], io: MenuIO, run: Runner, ctx: {
|
|
32
|
+
cwd: string;
|
|
33
|
+
}): Promise<number>;
|
|
34
|
+
/** Entry from cli.ts (bare `anet node`). Returns the exit code. */
|
|
35
|
+
export declare function runNodeMenu(nodes: CodexMenuNode[], opts: {
|
|
36
|
+
nodesDir: string;
|
|
37
|
+
home: string;
|
|
38
|
+
cwd?: string;
|
|
39
|
+
usageLine?: string;
|
|
40
|
+
}): Promise<number>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function nodeNotFoundMessage(ref: string, knownNames: string[], suggestion: string | null): string;
|