@sleep2agi/agent-network 2.3.0-preview.17 → 2.3.0-preview.170
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 +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/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 +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-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 +77 -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-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/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/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 +33 -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/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 +2 -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 +60 -0
- package/package.json +15 -7
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { ReceiptCheck } from "./codex-lifecycle-receipt";
|
|
2
|
+
export interface RolloutFact {
|
|
3
|
+
readonly path: string;
|
|
4
|
+
readonly inode: number | bigint;
|
|
5
|
+
readonly bytes: number;
|
|
6
|
+
readonly mtimeMs: number;
|
|
7
|
+
}
|
|
8
|
+
export interface ProcessFact {
|
|
9
|
+
readonly pid: number;
|
|
10
|
+
readonly cwd: string | null;
|
|
11
|
+
/** 子进程实际环境里的 CODEX_HOME(不是 wrapper 继承的那份 —— wrapper 环境不能作承重证据)。 */
|
|
12
|
+
readonly codexHome: string | null;
|
|
13
|
+
/** 子进程实际环境里 CommHub token 的短指纹;null = 没读到或该进程不该持有。 */
|
|
14
|
+
readonly tokenFingerprint: string | null;
|
|
15
|
+
/** 子进程环境里的 ANET_NODE_MARKER(copresence-identity 的身份 uuid);null = 没有。 */
|
|
16
|
+
readonly markerUuid: string | null;
|
|
17
|
+
readonly argv: readonly string[];
|
|
18
|
+
}
|
|
19
|
+
export interface PreflightFacts {
|
|
20
|
+
readonly alias: string;
|
|
21
|
+
readonly configNodeId: string | null;
|
|
22
|
+
/** hub 名册按 alias 精确查到的 node_id;null = hub 不可达或没这个 alias。 */
|
|
23
|
+
readonly hubNodeId: string | null;
|
|
24
|
+
readonly home: {
|
|
25
|
+
readonly dir: string;
|
|
26
|
+
readonly dirMode: number | null;
|
|
27
|
+
readonly authMode: number | null;
|
|
28
|
+
readonly authBytes: number | null;
|
|
29
|
+
/** Selected custom env_key observed identically in owned Codex TUI/app-server. */
|
|
30
|
+
readonly providerEnvAttested?: boolean;
|
|
31
|
+
readonly configTokenFingerprint: string | null;
|
|
32
|
+
readonly envFileTokenFingerprint: string | null;
|
|
33
|
+
};
|
|
34
|
+
readonly workdir: {
|
|
35
|
+
readonly configProjectDir: string | null;
|
|
36
|
+
readonly tuiCwd: string | null;
|
|
37
|
+
readonly tuiArgvDir: string | null;
|
|
38
|
+
readonly bridgeProjectDir: string | null;
|
|
39
|
+
readonly statusBarDir: string | null;
|
|
40
|
+
};
|
|
41
|
+
readonly session: {
|
|
42
|
+
readonly threadId: string | null;
|
|
43
|
+
/** CODEX_HOME 里文件名以 <threadId>.jsonl 结尾的 rollout 全集。 */
|
|
44
|
+
readonly rolloutMatches: readonly RolloutFact[];
|
|
45
|
+
};
|
|
46
|
+
readonly port: {
|
|
47
|
+
readonly port: number | null;
|
|
48
|
+
readonly owner: ProcessFact | null;
|
|
49
|
+
};
|
|
50
|
+
readonly topology: {
|
|
51
|
+
/** copresence-identity.json 里的身份 uuid;null = 没有 marker 文件。 */
|
|
52
|
+
readonly markerUuid: string | null;
|
|
53
|
+
/** marker 里记的 pid(采集时的观测提示,**不是**身份来源)与现在 tmux pane 的 pid。 */
|
|
54
|
+
readonly recorded: Readonly<Record<"appsrv" | "bridge" | "tui", number | null>>;
|
|
55
|
+
readonly live: Readonly<Record<"appsrv" | "bridge" | "tui", number | null>>;
|
|
56
|
+
/** 每个 tmux 段下带环境的子进程各自的 ANET_NODE_MARKER。 */
|
|
57
|
+
readonly liveMarkers: Readonly<Record<"appsrv" | "bridge" | "tui", readonly (string | null)[]>>;
|
|
58
|
+
/** 每个 tmux 段下带环境的子进程各自的 CODEX_HOME(realpath)。 */
|
|
59
|
+
readonly liveHomes: Readonly<Record<"appsrv" | "bridge" | "tui", readonly (string | null)[]>>;
|
|
60
|
+
};
|
|
61
|
+
readonly goal: {
|
|
62
|
+
readonly state: "active" | "stalled" | "paused" | "achieved" | "none" | "unknown";
|
|
63
|
+
};
|
|
64
|
+
readonly children: readonly ProcessFact[];
|
|
65
|
+
readonly expectedTokenFingerprint: string | null;
|
|
66
|
+
}
|
|
67
|
+
export declare function checkIdentity(f: PreflightFacts): ReceiptCheck;
|
|
68
|
+
export declare function checkHome(f: PreflightFacts): ReceiptCheck;
|
|
69
|
+
export declare function checkWorkdir(f: PreflightFacts): ReceiptCheck;
|
|
70
|
+
export declare function checkSession(f: PreflightFacts): ReceiptCheck;
|
|
71
|
+
export declare function rolloutSnapshot(f: PreflightFacts): ReceiptCheck;
|
|
72
|
+
export declare function compareRollout(before: RolloutFact, after: RolloutFact | null): ReceiptCheck;
|
|
73
|
+
export declare function checkPortOwner(f: PreflightFacts): ReceiptCheck;
|
|
74
|
+
export declare function checkChildEnv(f: PreflightFacts): ReceiptCheck;
|
|
75
|
+
export declare function checkGoalState(f: PreflightFacts): ReceiptCheck;
|
|
76
|
+
export declare function checkTopology(f: PreflightFacts): ReceiptCheck;
|
|
77
|
+
export declare function evaluateCodexPreflight(f: PreflightFacts): ReceiptCheck[];
|
|
78
|
+
/** verify = preflight + 子进程环境 + 跨节点身份验收(identity_attested 由调用方注入;PR-A 里没有探针时给 unknown)。 */
|
|
79
|
+
export declare function evaluateCodexVerify(f: PreflightFacts, identityAttested: ReceiptCheck): ReceiptCheck[];
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export type CheckStatus = "pass" | "fail" | "unknown" | "n/a";
|
|
2
|
+
export interface ReceiptCheck {
|
|
3
|
+
readonly key: string;
|
|
4
|
+
readonly status: CheckStatus;
|
|
5
|
+
/** 一句人话:pass 说核到了什么,fail 说差在哪,unknown 说为什么量不到。 */
|
|
6
|
+
readonly detail: string;
|
|
7
|
+
/** 可复核的证据(路径、inode、字节数、短指纹……);不得含凭据。 */
|
|
8
|
+
readonly evidence?: Readonly<Record<string, unknown>>;
|
|
9
|
+
}
|
|
10
|
+
export type LifecycleVerb = "preflight" | "verify" | "start" | "restart" | "resume" | "fork" | "adopt" | "account-install" | "rollback";
|
|
11
|
+
export interface LifecycleReceipt {
|
|
12
|
+
readonly format: "anet-codex-lifecycle-receipt/1";
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly verb: LifecycleVerb;
|
|
15
|
+
readonly alias: string;
|
|
16
|
+
readonly nodeId: string | null;
|
|
17
|
+
readonly startedAt: string;
|
|
18
|
+
readonly finishedAt: string;
|
|
19
|
+
readonly verdict: "PASS" | "FAIL";
|
|
20
|
+
/** FAIL 时阻塞的 check key(fail 与 unknown 都算)。 */
|
|
21
|
+
readonly blocking: readonly string[];
|
|
22
|
+
readonly checks: readonly ReceiptCheck[];
|
|
23
|
+
}
|
|
24
|
+
/** 每个动词要求哪些 check 必须 pass。preflight 只读,不要求 identity_attested(那是 verify 的活)。 */
|
|
25
|
+
export declare const REQUIRED_CHECKS: Readonly<Record<LifecycleVerb, readonly string[]>>;
|
|
26
|
+
export declare function shortFingerprint(value: string | undefined | null, length?: number): string | null;
|
|
27
|
+
export declare function redactReceipt<T>(value: T, key?: string): T;
|
|
28
|
+
/**
|
|
29
|
+
* #535 — required checks that may be "n/a" instead of "pass". identity_attested needs a second
|
|
30
|
+
* local node to send the nonce; a user with one node has no peer, and a verdict that can never be
|
|
31
|
+
* PASS for them is a verdict nobody can act on (audit: verify/canary/restart rc=2 on a healthy node).
|
|
32
|
+
* "n/a" stays visible in the receipt and in the summary line; it never turns into "pass".
|
|
33
|
+
*/
|
|
34
|
+
export declare const NOT_APPLICABLE_OK: ReadonlySet<string>;
|
|
35
|
+
export declare const INFORMATIONAL_PREFIXES: readonly string[];
|
|
36
|
+
/** before:home_isolated → home_isolated; rollout_before (restart's renamed snapshot) → rollout_intact. */
|
|
37
|
+
export declare function unprefixedCheckKey(key: string): string;
|
|
38
|
+
export declare function receiptVerdict(verb: LifecycleVerb, checks: readonly ReceiptCheck[]): {
|
|
39
|
+
verdict: "PASS" | "FAIL";
|
|
40
|
+
blocking: string[];
|
|
41
|
+
};
|
|
42
|
+
export declare function buildReceipt(opts: {
|
|
43
|
+
verb: LifecycleVerb;
|
|
44
|
+
alias: string;
|
|
45
|
+
nodeId: string | null;
|
|
46
|
+
startedAt: Date;
|
|
47
|
+
finishedAt?: Date;
|
|
48
|
+
checks: readonly ReceiptCheck[];
|
|
49
|
+
}): LifecycleReceipt;
|
|
50
|
+
/** receipts 落在节点目录下 receipts/<id>.json,0600,先写临时文件再 rename(原子)。返回绝对路径。 */
|
|
51
|
+
export declare function writeReceipt(nodeDir: string, receipt: LifecycleReceipt): string;
|
|
52
|
+
/** 终端摘要:一行一 check,PASS/FAIL 在最后;不打印 evidence 里的长值。 */
|
|
53
|
+
export declare function formatReceiptSummary(receipt: LifecycleReceipt): string;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #1856 PR-B — `anet node codex start|restart|resume` 的确定性状态机。
|
|
3
|
+
*
|
|
4
|
+
* 零 LLM:每一步是「读事实 → 判 → 动作 → 写 receipt check」,顺序固定;所有副作用都经 `RestartActions`
|
|
5
|
+
* 注入,所以这个文件可以在纯单测里跑完整个流程(含失败与回滚分支)。
|
|
6
|
+
*
|
|
7
|
+
* 停:Bridge → TUI → App Server(反向于依赖:先断任务入口,再让 TUI 把 rollout 刷完,最后放掉端口)。
|
|
8
|
+
* 起:交给 `anet node start <alias> --copresence --tui-first`(App Server → 端口就绪 → exact-session
|
|
9
|
+
* TUI 完全恢复 → Bridge),再用 preflight/verify 复核 —— 起的顺序由启动器保证,这里只验证结果。
|
|
10
|
+
* 任一步 fail → 不再往下;若已停掉进程则尝试一次「回滚」= 按原配置再起一次;仍失败就留在已停状态,
|
|
11
|
+
* receipt 记录到哪一步、为什么,exit 2。绝不猜、绝不 fallback 到别的线程。
|
|
12
|
+
*/
|
|
13
|
+
import type { ReceiptCheck } from "./codex-lifecycle-receipt.js";
|
|
14
|
+
import type { RolloutFact } from "./codex-lifecycle-preflight.js";
|
|
15
|
+
export type RestartVerb = "start" | "restart" | "resume";
|
|
16
|
+
export type GoalState = "active" | "paused" | "stalled" | "achieved" | "none" | "unknown";
|
|
17
|
+
export type CopresenceRole = "bridge" | "tui" | "appsrv";
|
|
18
|
+
export interface GateResult {
|
|
19
|
+
/** 该阶段所有 check(preflight 或 verify 的输出)。 */
|
|
20
|
+
readonly checks: readonly ReceiptCheck[];
|
|
21
|
+
/** 该阶段 rollout 快照(session_exact 通过时才有)。 */
|
|
22
|
+
readonly rollout: RolloutFact | null;
|
|
23
|
+
/** 端口占用者(null = 空闲)。 */
|
|
24
|
+
readonly port: {
|
|
25
|
+
readonly port: number | null;
|
|
26
|
+
readonly ownerPid: number | null;
|
|
27
|
+
readonly ownerIsOurs: boolean | null;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export interface RestartActions {
|
|
31
|
+
/** 只读核对(PR-A 的 preflight;`after` 阶段可带 identity_attested 变 verify)。 */
|
|
32
|
+
gate(phase: "before" | "after"): Promise<GateResult>;
|
|
33
|
+
/** goals.json 的状态摘要 + 内容指纹(unknown = 读不到/不认识的 schema)。 */
|
|
34
|
+
goalState(): Promise<{
|
|
35
|
+
state: GoalState;
|
|
36
|
+
fingerprint: string | null;
|
|
37
|
+
}>;
|
|
38
|
+
/** 三个 tmux 会话谁还活着。 */
|
|
39
|
+
liveSessions(): Promise<Readonly<Record<CopresenceRole, boolean>>>;
|
|
40
|
+
/** 杀掉一个角色的 tmux 会话并等它消失;ok=false 时 detail 说为什么。 */
|
|
41
|
+
stopSession(role: CopresenceRole): Promise<{
|
|
42
|
+
ok: boolean;
|
|
43
|
+
detail: string;
|
|
44
|
+
}>;
|
|
45
|
+
/** 等 rollout 文件字节数稳定(TUI 退出后大 rollout 还在刷盘);返回最终快照。 */
|
|
46
|
+
waitRolloutSettled(before: RolloutFact | null): Promise<RolloutFact | null>;
|
|
47
|
+
/** 等端口空闲;超时仍被占用时给出占用者 pid 与「是不是我们自己的 app-server」。 */
|
|
48
|
+
waitPortFree(): Promise<{
|
|
49
|
+
free: boolean;
|
|
50
|
+
ownerPid: number | null;
|
|
51
|
+
ownerIsOurs: boolean | null;
|
|
52
|
+
}>;
|
|
53
|
+
/** 对已核实属于本节点的残留 pid 发 TERM(定向,绝不 pkill -f)。 */
|
|
54
|
+
termOwnedPid(pid: number): Promise<{
|
|
55
|
+
ok: boolean;
|
|
56
|
+
detail: string;
|
|
57
|
+
}>;
|
|
58
|
+
/** 跑启动器(`anet node start --copresence --tui-first`);ok=false 时 detail 是它的尾部输出。 */
|
|
59
|
+
start(): Promise<{
|
|
60
|
+
ok: boolean;
|
|
61
|
+
detail: string;
|
|
62
|
+
}>;
|
|
63
|
+
/** hub 上该 node_id 是否在超时内回到 online/idle。 */
|
|
64
|
+
waitHubOnline(): Promise<{
|
|
65
|
+
ok: boolean;
|
|
66
|
+
detail: string;
|
|
67
|
+
}>;
|
|
68
|
+
/** 跨节点 nonce 探针;未配置时为 undefined(check 记 n/a,#535:单节点不阻塞)。 */
|
|
69
|
+
nonceProbe?: () => Promise<{
|
|
70
|
+
ok: boolean;
|
|
71
|
+
detail: string;
|
|
72
|
+
evidence?: Record<string, unknown>;
|
|
73
|
+
}>;
|
|
74
|
+
}
|
|
75
|
+
export interface RestartOutcome {
|
|
76
|
+
readonly verb: RestartVerb;
|
|
77
|
+
readonly checks: readonly ReceiptCheck[];
|
|
78
|
+
/** 走到哪一步停下(PASS 时 = "done")。 */
|
|
79
|
+
readonly stoppedAt: string;
|
|
80
|
+
readonly rolledBack: boolean;
|
|
81
|
+
}
|
|
82
|
+
/** #535 — shared with the CLI's verify/canary so every verb says the same thing. */
|
|
83
|
+
export declare const SINGLE_NODE_UNATTESTED_DETAIL = "not applicable: no --probe-from <peer> given (single node) \u2014 cross-node nonce attestation skipped; pass --probe-from <alias> to attest";
|
|
84
|
+
/** before 阶段的门:required 里不许有 fail;unknown 允许(要重启的节点常常就是缺了一截进程)。 */
|
|
85
|
+
export declare function beforeGateBlocks(checks: readonly ReceiptCheck[]): string[];
|
|
86
|
+
/** 三个角色按依赖反向停;返回 stop_order check(顺序本身就是证据)。 */
|
|
87
|
+
export declare function orderedStop(actions: RestartActions, live: Readonly<Record<CopresenceRole, boolean>>): Promise<ReceiptCheck>;
|
|
88
|
+
export declare function runCodexRestart(verb: RestartVerb, actions: RestartActions): Promise<RestartOutcome>;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/** The explicit, documented-as-unsafe override. Spelled once so help, messages and tests agree. */
|
|
2
|
+
export declare const ALLOW_SHARED_CODEX_LOGIN_FLAG = "--allow-shared-codex-login";
|
|
3
|
+
/** Per-node record of where the node's codex credential came from. */
|
|
4
|
+
export declare const CODEX_AUTH_ORIGIN_FILE = ".codex-auth-origin.json";
|
|
5
|
+
/** Host-index filename for a node's origin record: same directory-derived key as
|
|
6
|
+
* #1918's record, different suffix, so neither overwrites the other. */
|
|
7
|
+
export declare function codexOriginIndexFile(nodeDir: string): string;
|
|
8
|
+
export type CodexLoginSource = {
|
|
9
|
+
kind: "host";
|
|
10
|
+
path: string;
|
|
11
|
+
} | {
|
|
12
|
+
kind: "fork";
|
|
13
|
+
sourceAlias: string;
|
|
14
|
+
} | {
|
|
15
|
+
kind: "account";
|
|
16
|
+
profileId: string;
|
|
17
|
+
};
|
|
18
|
+
export interface CodexLoginHolder {
|
|
19
|
+
readonly alias: string;
|
|
20
|
+
/** Canonical node directory — the identity. */
|
|
21
|
+
readonly nodeDir: string;
|
|
22
|
+
/** "current": its last published fingerprint; "origin": the credential it was given. */
|
|
23
|
+
readonly via: "current" | "origin";
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Fingerprint of an auth.json on disk, or null when there is none or it carries
|
|
27
|
+
* no refresh token (an API-key login does not rotate, so sharing it is not this
|
|
28
|
+
* failure). The text is hashed and dropped; nothing here returns or logs it.
|
|
29
|
+
*/
|
|
30
|
+
export declare function codexLoginFingerprintOfFile(authJsonPath: string): string | null;
|
|
31
|
+
export interface FindHoldersOptions {
|
|
32
|
+
readonly fingerprint: string;
|
|
33
|
+
/** The node being given the credential — excluded from the result. */
|
|
34
|
+
readonly selfNodeDir: string;
|
|
35
|
+
/** Injected for tests; production uses the host index under ~/.anet. */
|
|
36
|
+
readonly indexDir?: string;
|
|
37
|
+
/** `.anet/nodes` roots to scan besides the host index. Default: the parent of selfNodeDir. */
|
|
38
|
+
readonly siblingRoots?: readonly string[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Every OTHER node on this host whose published fingerprint, or recorded
|
|
42
|
+
* credential origin, equals `fingerprint`. Read-only: it never deletes, never
|
|
43
|
+
* writes, and never opens another node's auth.json.
|
|
44
|
+
*
|
|
45
|
+
* A record whose node directory no longer exists describes a node that is
|
|
46
|
+
* gone and is ignored (#1918's liveness rule: existence, not age).
|
|
47
|
+
*/
|
|
48
|
+
export declare function findCodexLoginHolders(opts: FindHoldersOptions): CodexLoginHolder[];
|
|
49
|
+
export interface StagingDecisionInput {
|
|
50
|
+
/** The node that would receive the credential. */
|
|
51
|
+
readonly alias: string;
|
|
52
|
+
/** Its codex-home — named in the fix instruction. */
|
|
53
|
+
readonly targetCodexHome: string;
|
|
54
|
+
/** Fingerprint of the credential about to be handed over; null = not a rotating login. */
|
|
55
|
+
readonly fingerprint: string | null;
|
|
56
|
+
readonly holders: readonly CodexLoginHolder[];
|
|
57
|
+
readonly source: CodexLoginSource;
|
|
58
|
+
readonly allowShared: boolean;
|
|
59
|
+
/** Extra "how to fix" line for this command (e.g. fork's --no-codex-login). */
|
|
60
|
+
readonly extraFix?: readonly string[];
|
|
61
|
+
}
|
|
62
|
+
export type StagingDecision = {
|
|
63
|
+
readonly kind: "ok";
|
|
64
|
+
readonly lines: string[];
|
|
65
|
+
} | {
|
|
66
|
+
readonly kind: "refuse";
|
|
67
|
+
readonly lines: string[];
|
|
68
|
+
} | {
|
|
69
|
+
readonly kind: "override";
|
|
70
|
+
readonly lines: string[];
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Decide whether handing this credential to this node is allowed, and the exact
|
|
74
|
+
* text to print. Pure — the callers own the I/O and the exit code (1, per #2321).
|
|
75
|
+
*/
|
|
76
|
+
export declare function decideCodexLoginStaging(i: StagingDecisionInput): StagingDecision;
|
|
77
|
+
export interface RecordOriginOptions {
|
|
78
|
+
readonly nodeDir: string;
|
|
79
|
+
readonly alias: string;
|
|
80
|
+
readonly fingerprint: string;
|
|
81
|
+
readonly source: CodexLoginSource;
|
|
82
|
+
readonly indexDir?: string;
|
|
83
|
+
readonly now?: Date;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Record which credential a node was handed (8-hex fingerprint + where from).
|
|
87
|
+
* Best effort: a failure is returned as a message, never thrown — a node must
|
|
88
|
+
* not fail to start because bookkeeping failed.
|
|
89
|
+
*/
|
|
90
|
+
export declare function recordCodexLoginOrigin(o: RecordOriginOptions): string | null;
|
|
91
|
+
export interface SharedLoginGroup {
|
|
92
|
+
/** 8-hex refresh fingerprint — not a credential. */
|
|
93
|
+
readonly fingerprint: string;
|
|
94
|
+
readonly aliases: string[];
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* For `anet doctor`: groups of ≥2 live nodes whose CURRENT published
|
|
98
|
+
* fingerprint is the same. Read-only; aliases only.
|
|
99
|
+
*/
|
|
100
|
+
export declare function sharedCodexLoginGroups(opts?: {
|
|
101
|
+
indexDir?: string;
|
|
102
|
+
nodeRoots?: readonly string[];
|
|
103
|
+
}): SharedLoginGroup[];
|
|
104
|
+
export interface EvaluateStagingOptions {
|
|
105
|
+
/** The node that would receive the credential (may not exist yet, e.g. a fork target). */
|
|
106
|
+
readonly nodeDir: string;
|
|
107
|
+
readonly alias: string;
|
|
108
|
+
readonly targetCodexHome: string;
|
|
109
|
+
/** The auth.json about to be copied. Read only to hash it. */
|
|
110
|
+
readonly sourceAuthPath: string;
|
|
111
|
+
readonly source: CodexLoginSource;
|
|
112
|
+
readonly allowShared: boolean;
|
|
113
|
+
readonly extraFix?: readonly string[];
|
|
114
|
+
/** Holders known without any record — a fork's source node always holds its own login. */
|
|
115
|
+
readonly knownHolders?: readonly CodexLoginHolder[];
|
|
116
|
+
readonly indexDir?: string;
|
|
117
|
+
readonly siblingRoots?: readonly string[];
|
|
118
|
+
}
|
|
119
|
+
export type EvaluatedStaging = StagingDecision & {
|
|
120
|
+
readonly fingerprint: string | null;
|
|
121
|
+
readonly holders: readonly CodexLoginHolder[];
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Fingerprint → holders → decision, in one call, for every staging path.
|
|
125
|
+
* Writes nothing; the caller records the origin once the credential has
|
|
126
|
+
* actually been handed over (see recordCodexLoginOrigin).
|
|
127
|
+
*/
|
|
128
|
+
export declare function evaluateCodexLoginStaging(o: EvaluateStagingOptions): EvaluatedStaging;
|
|
129
|
+
/**
|
|
130
|
+
* `anet node codex fork --no-codex-login` deliberately leaves the target without
|
|
131
|
+
* a credential, and home_isolated would fail on exactly that. The caller runs
|
|
132
|
+
* the real check with the credential treated as present (so every OTHER rule —
|
|
133
|
+
* directory mode, CommHub token, env-file token — is still evaluated) and passes
|
|
134
|
+
* the result here: a pass is re-worded to say what is still owed, a failure
|
|
135
|
+
* stays the failure it is.
|
|
136
|
+
*/
|
|
137
|
+
export declare function homeCheckPendingOwnLogin<C extends {
|
|
138
|
+
status: string;
|
|
139
|
+
detail: string;
|
|
140
|
+
}>(checkAssumingLogin: C, codexHome: string): C;
|
|
141
|
+
/** The step of a host stage plan that newly hands a node a login: auth.json where the node has none.
|
|
142
|
+
* A "host-newer" re-stage is an existing node and is not gated (it still gets the #1918 warning). */
|
|
143
|
+
export declare function newLoginStep<T extends {
|
|
144
|
+
name: string;
|
|
145
|
+
reason: string;
|
|
146
|
+
}>(plan: readonly T[]): T | undefined;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export type CodexKind = "co-presence" | "codex-sdk";
|
|
2
|
+
export interface CodexMenuNode {
|
|
3
|
+
id: string;
|
|
4
|
+
alias: string;
|
|
5
|
+
profile: Record<string, any> | null;
|
|
6
|
+
}
|
|
7
|
+
export interface CodexNodeRow {
|
|
8
|
+
id: string;
|
|
9
|
+
alias: string;
|
|
10
|
+
kind: CodexKind;
|
|
11
|
+
/** "running" | "stopped" | "partial 1/3" … */
|
|
12
|
+
state: string;
|
|
13
|
+
running: boolean;
|
|
14
|
+
loggedIn: boolean;
|
|
15
|
+
/** Where the login lives: the node's own CODEX_HOME, or the host's ~/.codex. */
|
|
16
|
+
loginWhere: "node" | "host";
|
|
17
|
+
/** Absolute CODEX_HOME for `codex login`; null = codex's own default (~/.codex). */
|
|
18
|
+
codexHome: string | null;
|
|
19
|
+
threadId: string | null;
|
|
20
|
+
model: string;
|
|
21
|
+
modelIsDefault: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface CollectEnv {
|
|
24
|
+
nodesDir: string;
|
|
25
|
+
/** $HOME — only used to locate the host's ~/.codex/auth.json. */
|
|
26
|
+
home: string;
|
|
27
|
+
/** The environment a start would inherit (CODEX_HOME); defaults to process.env. */
|
|
28
|
+
env?: Record<string, string | undefined>;
|
|
29
|
+
/** Exact tmux session names on the server anet uses (empty when none). */
|
|
30
|
+
tmuxSessions?: () => Set<string>;
|
|
31
|
+
pidAlive?: (pid: number) => boolean;
|
|
32
|
+
}
|
|
33
|
+
export declare function realTmuxSessions(): Set<string>;
|
|
34
|
+
export declare function realPidAlive(pid: number): boolean;
|
|
35
|
+
/** Only codex nodes: co-presence (codex-app-server) and codex-sdk. */
|
|
36
|
+
export declare function collectCodexRows(nodes: CodexMenuNode[], env: CollectEnv): CodexNodeRow[];
|
|
37
|
+
export declare function renderCodexTable(rows: CodexNodeRow[], cwd: string): string;
|
|
38
|
+
export declare const CODEX_CHEAT_SHEET: string;
|
|
39
|
+
export type MenuAction = "start" | "stop" | "restart" | "verify" | "login" | "continue" | "pick" | "model" | "copy" | "delete";
|
|
40
|
+
export declare const MENU_ACTIONS: {
|
|
41
|
+
key: MenuAction;
|
|
42
|
+
label: string;
|
|
43
|
+
}[];
|
|
44
|
+
export interface PlannedCommand {
|
|
45
|
+
/** argv[0] is "anet" (re-invoke this CLI) or "codex". */
|
|
46
|
+
argv: string[];
|
|
47
|
+
/** Extra env for the child (only CODEX_HOME for login). */
|
|
48
|
+
env?: Record<string, string>;
|
|
49
|
+
/** Shown before the confirm prompt, after the command. */
|
|
50
|
+
note?: string;
|
|
51
|
+
/** Shown after the command succeeded. */
|
|
52
|
+
after?: string;
|
|
53
|
+
}
|
|
54
|
+
export declare function displayQuote(v: string): string;
|
|
55
|
+
export declare function commandLine(cmd: PlannedCommand): string;
|
|
56
|
+
export interface ActionInput {
|
|
57
|
+
model?: string;
|
|
58
|
+
newName?: string;
|
|
59
|
+
workdir?: string;
|
|
60
|
+
}
|
|
61
|
+
/** #528 — not about an existing node: turn a codex conversation started outside anet into a new one. */
|
|
62
|
+
export declare const ADOPT_KEY = "a";
|
|
63
|
+
export declare function planAdopt(newName: string): PlannedCommand;
|
|
64
|
+
export declare function planAction(row: CodexNodeRow, action: MenuAction, input?: ActionInput): PlannedCommand;
|
|
65
|
+
export interface MenuIO {
|
|
66
|
+
write(s: string): void;
|
|
67
|
+
/** Resolves to the next line, or null at end of input. */
|
|
68
|
+
readLine(prompt: string): Promise<string | null>;
|
|
69
|
+
}
|
|
70
|
+
export type Runner = (cmd: PlannedCommand) => Promise<number>;
|
|
71
|
+
export declare function pick(io: MenuIO, prompt: string, max: number, allowAdopt?: boolean): Promise<number | "adopt" | null>;
|
|
72
|
+
/** Returns the process exit code. Runs at most one command. */
|
|
73
|
+
export declare function codexMenu(rows: CodexNodeRow[], io: MenuIO, run: Runner, ctx: {
|
|
74
|
+
cwd: string;
|
|
75
|
+
}): Promise<number>;
|
|
76
|
+
/** The action step for one codex node. #561: `anet node` (all runtimes) hands codex nodes off to this. */
|
|
77
|
+
export declare function codexNodeActions(row: CodexNodeRow, io: MenuIO, run: Runner, ctx: {
|
|
78
|
+
cwd: string;
|
|
79
|
+
}): Promise<number>;
|
|
80
|
+
/** Ask for a model id; null (and a message) when none / not a plain id. Shared with node-menu.ts (#561). */
|
|
81
|
+
export declare function askModel(io: MenuIO, current: string): Promise<string | null>;
|
|
82
|
+
/**
|
|
83
|
+
* Print the exact command, then ask: y/N, or (typedName) the node's name. Run it only then.
|
|
84
|
+
* The one gate both menus go through (#532 codex, #561 every runtime).
|
|
85
|
+
*/
|
|
86
|
+
export declare function confirmAndRun(io: MenuIO, run: Runner, cmd: PlannedCommand, row: {
|
|
87
|
+
alias: string;
|
|
88
|
+
}, typedName: boolean): Promise<number>;
|
|
89
|
+
/** A line queue over one readline: scripted input that arrives in one chunk is not lost between prompts. */
|
|
90
|
+
export declare function readlineIO(): MenuIO & {
|
|
91
|
+
close(): void;
|
|
92
|
+
};
|
|
93
|
+
export declare function realRunner(beforeRun: () => void): Runner;
|
|
94
|
+
/** Entry from cli.ts (`anet node codex` with no arguments). Returns the exit code. */
|
|
95
|
+
export declare function runCodexMenu(nodes: CodexMenuNode[], opts: {
|
|
96
|
+
nodesDir: string;
|
|
97
|
+
home: string;
|
|
98
|
+
cwd?: string;
|
|
99
|
+
}): Promise<number>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export type CodexLoginKind = "chatgpt" | "api-key" | "none" | "unreadable";
|
|
2
|
+
export interface CodexLoginFacts {
|
|
3
|
+
readonly loggedIn: boolean;
|
|
4
|
+
readonly kind: CodexLoginKind;
|
|
5
|
+
/** #1918 refresh-chain fingerprint (8 hex) — what actually collides. */
|
|
6
|
+
readonly loginFingerprint: string | null;
|
|
7
|
+
/** #1856 account fingerprint (sha256(account_id), 16 hex). */
|
|
8
|
+
readonly accountFingerprint: string | null;
|
|
9
|
+
/** `email` claim of the id_token, when present. Not a credential. */
|
|
10
|
+
readonly email: string | null;
|
|
11
|
+
}
|
|
12
|
+
/** What an auth.json says about a login — without ever returning a token. */
|
|
13
|
+
export declare function codexLoginFactsFromText(text: string | null): CodexLoginFacts;
|
|
14
|
+
export declare function codexLoginFactsOfHome(codexHome: string): CodexLoginFacts;
|
|
15
|
+
export interface NodeConfigLike {
|
|
16
|
+
runtime?: unknown;
|
|
17
|
+
codexCopresence?: unknown;
|
|
18
|
+
codexHome?: unknown;
|
|
19
|
+
env?: unknown;
|
|
20
|
+
alias?: unknown;
|
|
21
|
+
node_name?: unknown;
|
|
22
|
+
name?: unknown;
|
|
23
|
+
}
|
|
24
|
+
/** A node whose runtime runs codex. */
|
|
25
|
+
export declare function isCodexNodeConfig(cfg: NodeConfigLike | null | undefined): boolean;
|
|
26
|
+
export type EffectiveCodexHomeSource = "config.codexHome" | "node-codex-home" | "config.env" | "environment" | "default";
|
|
27
|
+
/**
|
|
28
|
+
* The CODEX_HOME this node's codex process will get — the same decision
|
|
29
|
+
* `applyNodeCodexHome` makes on start: the node's own value; otherwise an
|
|
30
|
+
* inherited CODEX_HOME unless it is another node's codex-home; otherwise
|
|
31
|
+
* codex's default `~/.codex`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function effectiveCodexHome(nodeDir: string, cfg: NodeConfigLike | null, env: Record<string, string | undefined>, home: string): {
|
|
34
|
+
codexHome: string;
|
|
35
|
+
source: EffectiveCodexHomeSource;
|
|
36
|
+
};
|
|
37
|
+
export interface LoginNextStepInput {
|
|
38
|
+
readonly alias: string;
|
|
39
|
+
readonly codexHome: string;
|
|
40
|
+
/** Does the codex-home directory exist yet? codex 0.133 refuses a CODEX_HOME that does not. */
|
|
41
|
+
readonly homeExists: boolean;
|
|
42
|
+
/** e.g. `anet node start <alias>`; printed as what comes after the login. */
|
|
43
|
+
readonly then?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The one next step for a codex node without a login. Plain text, no token,
|
|
47
|
+
* nothing executed. `--device-auth` is in `codex login --help` of the pinned
|
|
48
|
+
* codex (agent-node depends on @openai/codex ^0.133; checked on 0.133.0).
|
|
49
|
+
*/
|
|
50
|
+
export declare function codexLoginNextStepLines(i: LoginNextStepInput): string[];
|
|
51
|
+
export interface CreateLoginGapInput {
|
|
52
|
+
readonly nodeDir: string;
|
|
53
|
+
readonly config: NodeConfigLike | null;
|
|
54
|
+
readonly env: Record<string, string | undefined>;
|
|
55
|
+
readonly home: string;
|
|
56
|
+
/**
|
|
57
|
+
* For a co-presence node whose own codex-home has no login: would its first
|
|
58
|
+
* start be allowed to stage the host login (#514 gate says "ok")? Injected so
|
|
59
|
+
* this stays a pure decision; the CLI passes evaluateCodexLoginStaging.
|
|
60
|
+
*/
|
|
61
|
+
readonly hostLoginWouldBeStaged: (hostAuthPath: string) => boolean;
|
|
62
|
+
}
|
|
63
|
+
/** null = the node will have a usable login; otherwise the CODEX_HOME to log in. */
|
|
64
|
+
export declare function codexCreateLoginGap(i: CreateLoginGapInput): {
|
|
65
|
+
codexHome: string;
|
|
66
|
+
homeExists: boolean;
|
|
67
|
+
} | null;
|
|
68
|
+
export interface CodexLoginStatusRow {
|
|
69
|
+
alias: string;
|
|
70
|
+
node_id: string | null;
|
|
71
|
+
runtime: string;
|
|
72
|
+
copresence: boolean;
|
|
73
|
+
codex_home: string;
|
|
74
|
+
codex_home_source: EffectiveCodexHomeSource;
|
|
75
|
+
logged_in: boolean;
|
|
76
|
+
login_kind: CodexLoginKind;
|
|
77
|
+
/** #1918 refresh-chain fingerprint (8 hex). */
|
|
78
|
+
login_fingerprint: string | null;
|
|
79
|
+
/** #1856 account fingerprint (16 hex). */
|
|
80
|
+
account_fingerprint: string | null;
|
|
81
|
+
email: string | null;
|
|
82
|
+
/** Other nodes holding the SAME refresh chain — they log each other out. */
|
|
83
|
+
shared_with: string[];
|
|
84
|
+
/** Other nodes logged in to the same account with their OWN login — fine. */
|
|
85
|
+
same_account_as: string[];
|
|
86
|
+
}
|
|
87
|
+
export interface LoginStatusOptions {
|
|
88
|
+
/** `<workspace>/.anet/nodes` */
|
|
89
|
+
readonly nodesRoot: string;
|
|
90
|
+
readonly env: Record<string, string | undefined>;
|
|
91
|
+
readonly home: string;
|
|
92
|
+
/** Host index of published fingerprints (#1918); default under `home`. */
|
|
93
|
+
readonly indexDir?: string;
|
|
94
|
+
}
|
|
95
|
+
/** One row per codex node under `nodesRoot`. Read-only. */
|
|
96
|
+
export declare function codexNodeLoginStatus(o: LoginStatusOptions): CodexLoginStatusRow[];
|
|
97
|
+
/** Human table. Never contains a token: rows carry none. */
|
|
98
|
+
export declare function formatCodexLoginStatus(rows: readonly CodexLoginStatusRow[], workspace: string): string[];
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #602 — what `anet node start` does with a `codexPendingThread` it finds in
|
|
3
|
+
* the node config before launching a new co-presence generation.
|
|
4
|
+
*
|
|
5
|
+
* The candidate is written by the bridge when the TUI opens a thread that has
|
|
6
|
+
* not had a conversation yet (codex only writes a rollout on the first turn).
|
|
7
|
+
* It is bound to the identity marker of the generation that saw it, so a
|
|
8
|
+
* restart after a crash can carry it over to the next generation without
|
|
9
|
+
* guessing (`migrateCodexPendingThread`) once its exact rollout exists. A
|
|
10
|
+
* candidate acknowledged by RPC but never materialized remains pending and
|
|
11
|
+
* is dropped on the next start, even if the old marker file survived.
|
|
12
|
+
*
|
|
13
|
+
* A clean `anet node stop` reaps that generation and removes its marker, but
|
|
14
|
+
* the candidate stays in the config. Before #602 the next start then refused
|
|
15
|
+
* for good: "pending Codex thread is not bound to the exact private
|
|
16
|
+
* previous-generation marker" — every node whose TUI was never used could be
|
|
17
|
+
* stopped once and never started again.
|
|
18
|
+
*
|
|
19
|
+
* A candidate whose marker file is gone AND whose thread has no rollout under
|
|
20
|
+
* this node's CODEX_HOME holds nothing: codex never persisted the thread, its
|
|
21
|
+
* app-server generation is gone, and no app-server can resume it. Dropping it
|
|
22
|
+
* adopts nothing and loses nothing; the new generation starts a fresh thread
|
|
23
|
+
* exactly like a first start. Everything else keeps the old fail-closed
|
|
24
|
+
* answer — in particular a candidate whose thread HAS a rollout while the
|
|
25
|
+
* marker that bound it is gone is never adopted, because nothing proves the
|
|
26
|
+
* binding was ours.
|
|
27
|
+
*/
|
|
28
|
+
export type PendingThreadAtStart = {
|
|
29
|
+
kind: "none";
|
|
30
|
+
} | {
|
|
31
|
+
kind: "migrate";
|
|
32
|
+
oldMarker: string;
|
|
33
|
+
} | {
|
|
34
|
+
kind: "drop-unmaterialized";
|
|
35
|
+
threadId: string;
|
|
36
|
+
} | {
|
|
37
|
+
kind: "refuse";
|
|
38
|
+
reason: string;
|
|
39
|
+
};
|
|
40
|
+
export type PendingMarkerFact = {
|
|
41
|
+
kind: "ok";
|
|
42
|
+
marker: string;
|
|
43
|
+
} | {
|
|
44
|
+
kind: "missing";
|
|
45
|
+
} | {
|
|
46
|
+
kind: "unreadable";
|
|
47
|
+
cause: string;
|
|
48
|
+
};
|
|
49
|
+
/** Rollout files for exactly this thread id (suffix match, no prefix guessing), or `null` if the search itself failed. */
|
|
50
|
+
export type RolloutLookup = (threadId: string) => string[] | null;
|
|
51
|
+
export declare function decidePendingThreadAtStart(pending: unknown, marker: PendingMarkerFact, rollouts: RolloutLookup): PendingThreadAtStart;
|
|
52
|
+
/**
|
|
53
|
+
* Apply the decision to an in-memory node config without platform-specific
|
|
54
|
+
* shortcuts. Both launchers persist `config` before quiescing the old
|
|
55
|
+
* generation. Keeping the deletion here makes the Windows stop -> start
|
|
56
|
+
* behavior executable in the Linux Docker gate instead of relying only on a
|
|
57
|
+
* source-shape assertion (the native Windows smoke remains the end-to-end
|
|
58
|
+
* proof).
|
|
59
|
+
*/
|
|
60
|
+
export declare function reconcilePendingThreadAtStart<T extends Record<string, unknown>>(config: T, marker: PendingMarkerFact, rollouts: RolloutLookup): PendingThreadAtStart & {
|
|
61
|
+
config: T;
|
|
62
|
+
changed: boolean;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Every `*-<threadId>.jsonl` under `<codexHome>/sessions` and
|
|
66
|
+
* `<codexHome>/archived_sessions`. A missing directory is "no rollouts"; any
|
|
67
|
+
* other read error makes the whole lookup `null` (the caller then refuses).
|
|
68
|
+
*/
|
|
69
|
+
export declare function findThreadRollouts(codexHome: string, threadId: string): string[] | null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Codex `config.toml` + `-c` override for thinking / reasoning effort.
|
|
2
|
+
* Wire name matches app-server JSON (`reasoningEffort`) and client patch field. */
|
|
3
|
+
export declare const CODEX_MODEL_REASONING_EFFORT_KEY = "model_reasoning_effort";
|
|
4
|
+
/** Matches agent-node `types/codex/ReasoningEffort.ts` and models_cache gate. */
|
|
5
|
+
export declare const REASONING_EFFORT_VALUES: readonly ["none", "minimal", "low", "medium", "high", "xhigh"];
|
|
6
|
+
export type ReasoningEffortValue = (typeof REASONING_EFFORT_VALUES)[number];
|
|
7
|
+
export declare function isReasoningEffortValue(v: unknown): v is ReasoningEffortValue;
|
|
8
|
+
export declare function reasoningEffortValidationReason(): string;
|
|
9
|
+
/** `-c` fragment value (no shell quoting). */
|
|
10
|
+
export declare function codexReasoningEffortConfigOverride(effort: ReasoningEffortValue): string;
|
|
11
|
+
/**
|
|
12
|
+
* Idempotent merge of top-level `model_reasoning_effort` in codex config.toml.
|
|
13
|
+
* Other tables and keys are preserved byte-for-byte except the managed line.
|
|
14
|
+
*/
|
|
15
|
+
export declare function mergeModelReasoningEffortIntoToml(existing: string, effort: ReasoningEffortValue): string;
|
|
16
|
+
/** Persist `model_reasoning_effort` under a node's `codex-home/`. */
|
|
17
|
+
export declare function writeReasoningEffortToCodexHome(codexHome: string, effort: ReasoningEffortValue): void;
|