@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.
Files changed (193) hide show
  1. package/README.md +35 -324
  2. package/dist/bin/anet.cjs +101 -0
  3. package/dist/bin/cli.d.ts +1 -0
  4. package/dist/bin/cli.js +20 -1
  5. package/dist/bin/goal-wake-log-render.d.ts +31 -0
  6. package/dist/src/active-network-task.d.ts +28 -0
  7. package/dist/src/batch-workdir.d.ts +9 -0
  8. package/dist/src/bootstrap-password-db.d.ts +13 -0
  9. package/dist/src/channel-attachments.d.ts +29 -0
  10. package/dist/src/channel-inbox-wake.d.ts +21 -0
  11. package/dist/src/channel-meta.d.ts +10 -0
  12. package/dist/src/channel-peer-reply.d.ts +41 -0
  13. package/dist/src/channel-task-trace.d.ts +14 -0
  14. package/dist/src/claude-vendor-env.d.ts +28 -0
  15. package/dist/src/cli-args.d.ts +8 -0
  16. package/dist/src/cli-auth-session.d.ts +47 -0
  17. package/dist/src/cli-errors.d.ts +41 -0
  18. package/dist/src/cli-exit.d.ts +11 -0
  19. package/dist/src/cli-help.d.ts +10 -0
  20. package/dist/src/cli-version-display.d.ts +16 -0
  21. package/dist/src/client-task-trace.d.ts +9 -0
  22. package/dist/src/client.js +1 -1
  23. package/dist/src/codex-adopt.d.ts +46 -0
  24. package/dist/src/codex-auth-fingerprint.d.ts +211 -0
  25. package/dist/src/codex-bin-pin.d.ts +23 -0
  26. package/dist/src/codex-commhub-mcp.d.ts +22 -0
  27. package/dist/src/codex-copresence-bridge-log.d.ts +44 -0
  28. package/dist/src/codex-copresence-env.d.ts +5 -0
  29. package/dist/src/codex-copresence-login-gate.d.ts +18 -0
  30. package/dist/src/codex-copresence-model.d.ts +23 -0
  31. package/dist/src/codex-copresence-preflight.d.ts +78 -0
  32. package/dist/src/codex-copresence-profile.d.ts +126 -0
  33. package/dist/src/codex-copresence-recovery.d.ts +70 -0
  34. package/dist/src/codex-copresence-resume-timeout.d.ts +28 -0
  35. package/dist/src/codex-copresence-rollout-guard.d.ts +36 -0
  36. package/dist/src/codex-copresence-rpc.d.ts +17 -0
  37. package/dist/src/codex-copresence-thread.d.ts +13 -0
  38. package/dist/src/codex-copresence-yolo.d.ts +16 -0
  39. package/dist/src/codex-external-appserver.d.ts +130 -0
  40. package/dist/src/codex-fork-recovery.d.ts +52 -0
  41. package/dist/src/codex-home-enforce.d.ts +88 -0
  42. package/dist/src/codex-lifecycle-account.d.ts +104 -0
  43. package/dist/src/codex-lifecycle-canary.d.ts +20 -0
  44. package/dist/src/codex-lifecycle-facts.d.ts +53 -0
  45. package/dist/src/codex-lifecycle-fork.d.ts +91 -0
  46. package/dist/src/codex-lifecycle-preflight.d.ts +79 -0
  47. package/dist/src/codex-lifecycle-receipt.d.ts +53 -0
  48. package/dist/src/codex-lifecycle-restart.d.ts +88 -0
  49. package/dist/src/codex-login-share-guard.d.ts +146 -0
  50. package/dist/src/codex-menu.d.ts +99 -0
  51. package/dist/src/codex-model-default.d.ts +6 -0
  52. package/dist/src/codex-node-login.d.ts +98 -0
  53. package/dist/src/codex-pending-thread-restart.d.ts +69 -0
  54. package/dist/src/codex-reasoning-effort.d.ts +17 -0
  55. package/dist/src/codex-recovery-lease.d.ts +39 -0
  56. package/dist/src/codex-recovery-resource-gate.d.ts +15 -0
  57. package/dist/src/codex-resume.d.ts +89 -0
  58. package/dist/src/codex-rollout-history-guard.d.ts +84 -0
  59. package/dist/src/codex-tui-client-health.d.ts +30 -0
  60. package/dist/src/commhub-response.d.ts +1 -0
  61. package/dist/src/controlled-upload.d.ts +83 -0
  62. package/dist/src/copresence-deps.d.ts +22 -0
  63. package/dist/src/copresence-identity.d.ts +363 -0
  64. package/dist/src/copresence-startup-diagnosis.d.ts +17 -0
  65. package/dist/src/daemon-adopt.d.ts +14 -0
  66. package/dist/src/daemon-anet-bin.d.ts +32 -0
  67. package/dist/src/daemon-capability-display.d.ts +110 -0
  68. package/dist/src/daemon-capability-display.js +21 -0
  69. package/dist/src/daemon-codex-inventory.d.ts +65 -0
  70. package/dist/src/daemon-inherited-env.d.ts +9 -0
  71. package/dist/src/daemon-provider-account-custody.d.ts +28 -0
  72. package/dist/src/daemon-provider-account-readback.d.ts +3 -0
  73. package/dist/src/daemon-provider-application.d.ts +36 -0
  74. package/dist/src/daemon-provider-apply-command.d.ts +9 -0
  75. package/dist/src/daemon-provider-collect.d.ts +29 -0
  76. package/dist/src/daemon-provider-command.d.ts +7 -0
  77. package/dist/src/daemon-provider-initialize.d.ts +27 -0
  78. package/dist/src/daemon-provider-lifecycle.d.ts +4 -0
  79. package/dist/src/daemon-provider-store.d.ts +104 -0
  80. package/dist/src/daemon-runtime-path-preflight.d.ts +22 -0
  81. package/dist/src/daemon-runtime-staleness.d.ts +13 -0
  82. package/dist/src/dashboard-managed-process.d.ts +35 -0
  83. package/dist/src/display-width.d.ts +27 -0
  84. package/dist/src/doctor-node-count.d.ts +28 -0
  85. package/dist/src/environ-alias.d.ts +14 -0
  86. package/dist/src/grok-attach-client.d.ts +129 -0
  87. package/dist/src/grok-build-drift.d.ts +15 -0
  88. package/dist/src/grok-copresence-disclosure.d.ts +11 -0
  89. package/dist/src/grok-copresence-orchestration.d.ts +75 -0
  90. package/dist/src/grok-copresence-profile.d.ts +65 -0
  91. package/dist/src/grok-create-mode.d.ts +19 -0
  92. package/dist/src/host-telemetry.d.ts +14 -0
  93. package/dist/src/hub-health-timeout.d.ts +4 -0
  94. package/dist/src/hub-server-version.d.ts +64 -0
  95. package/dist/src/hub-stop.d.ts +74 -0
  96. package/dist/src/hub-time-display.d.ts +20 -0
  97. package/dist/src/hub-version-skew.d.ts +19 -0
  98. package/dist/src/im/correlation-store.d.ts +34 -0
  99. package/dist/src/im/feishu/adapter.d.ts +43 -0
  100. package/dist/src/im/feishu/bridge.d.ts +78 -14
  101. package/dist/src/im/feishu/hub-upload.d.ts +1 -1
  102. package/dist/src/im/feishu/worker-lifecycle.d.ts +13 -0
  103. package/dist/src/im/feishu/worker.js +174 -161
  104. package/dist/src/inbox-drain.d.ts +20 -0
  105. package/dist/src/local-process-state.d.ts +12 -0
  106. package/dist/src/locale-diagnostic.d.ts +12 -0
  107. package/dist/src/login-client-label.d.ts +6 -0
  108. package/dist/src/ls-columns.d.ts +15 -0
  109. package/dist/src/mock-llm.d.ts +12 -0
  110. package/dist/src/node-activity-log.d.ts +4 -0
  111. package/dist/src/node-clone.d.ts +134 -0
  112. package/dist/src/node-delete-hub.d.ts +42 -0
  113. package/dist/src/node-files.d.ts +62 -0
  114. package/dist/src/node-locate.d.ts +60 -0
  115. package/dist/src/node-ls-all.d.ts +80 -0
  116. package/dist/src/node-menu.d.ts +40 -0
  117. package/dist/src/node-not-found.d.ts +1 -0
  118. package/dist/src/node-remote.d.ts +180 -0
  119. package/dist/src/node-running-guard.d.ts +9 -0
  120. package/dist/src/node-server-identity.d.ts +35 -0
  121. package/dist/src/node-server-payload.d.ts +66 -0
  122. package/dist/src/node-server-rules-file.d.ts +14 -0
  123. package/dist/src/node-server-version.d.ts +39 -0
  124. package/dist/src/node-server.js +8 -1
  125. package/dist/src/node-skills.d.ts +57 -0
  126. package/dist/src/normalize-runtime.d.ts +29 -2
  127. package/dist/src/offline-age.d.ts +29 -0
  128. package/dist/src/one-line-cell.d.ts +20 -0
  129. package/dist/src/opencode-agent-node-pair.d.ts +28 -0
  130. package/dist/src/opencode-auth-login.d.ts +43 -0
  131. package/dist/src/opencode-free-tier.d.ts +27 -0
  132. package/dist/src/opencode-generation-create.d.ts +27 -0
  133. package/dist/src/opencode-generation-record.d.ts +24 -0
  134. package/dist/src/opencode-launch-env.d.ts +13 -0
  135. package/dist/src/opencode-owner-mode.d.ts +6 -0
  136. package/dist/src/opencode-package-binary.d.ts +44 -0
  137. package/dist/src/opencode-pin.d.ts +61 -0
  138. package/dist/src/opencode-preset.d.ts +77 -0
  139. package/dist/src/opencode-runtime-binding.d.ts +30 -0
  140. package/dist/src/opencode-safe-root.d.ts +36 -0
  141. package/dist/src/opencode-smoke-env.d.ts +1 -0
  142. package/dist/src/opencode-start-mode.d.ts +8 -0
  143. package/dist/src/opencode-v2-configured-model.d.ts +34 -0
  144. package/dist/src/opencode-v2-create-align.d.ts +18 -0
  145. package/dist/src/opencode-versions.d.ts +44 -0
  146. package/dist/src/outbound-attachments.d.ts +60 -0
  147. package/dist/src/outbound-tool-names.d.ts +1 -0
  148. package/dist/src/owned-roots.d.ts +58 -0
  149. package/dist/src/owner-env-file.d.ts +2 -0
  150. package/dist/src/package-mode-preflight.d.ts +41 -0
  151. package/dist/src/posix-codex-copresence.d.ts +33 -0
  152. package/dist/src/posix-modes.d.ts +36 -0
  153. package/dist/src/primary-network.d.ts +23 -0
  154. package/dist/src/private-state.d.ts +10 -0
  155. package/dist/src/process-telemetry.d.ts +12 -0
  156. package/dist/src/profile-serialize.d.ts +1 -0
  157. package/dist/src/project-key.d.ts +1 -0
  158. package/dist/src/provider-application-contract.d.ts +11 -0
  159. package/dist/src/provider-apply.d.ts +28 -0
  160. package/dist/src/provider-presets.d.ts +76 -0
  161. package/dist/src/reply-local-links.d.ts +47 -0
  162. package/dist/src/reply-originator.d.ts +20 -0
  163. package/dist/src/resume-runtime-infer.d.ts +18 -0
  164. package/dist/src/rules-file.d.ts +53 -0
  165. package/dist/src/scoped-secrets.d.ts +33 -0
  166. package/dist/src/secret-shell-guidance.d.ts +4 -0
  167. package/dist/src/session-status-class.d.ts +48 -0
  168. package/dist/src/shared/provider-collection.d.ts +9 -0
  169. package/dist/src/shared/provider-initialization.d.ts +7 -0
  170. package/dist/src/shared/reserved-env.d.ts +3 -0
  171. package/dist/src/shared/scoped-secret-contract.d.ts +1 -0
  172. package/dist/src/shared/scoped-secret-env.d.ts +2 -0
  173. package/dist/src/sibling-agent-node.d.ts +23 -0
  174. package/dist/src/stale-socket.d.ts +118 -0
  175. package/dist/src/standalone-bin.d.ts +101 -0
  176. package/dist/src/standalone-build-stamp.d.ts +33 -0
  177. package/dist/src/start-resource-gate.d.ts +146 -0
  178. package/dist/src/stopped-receipt.d.ts +8 -0
  179. package/dist/src/subcommand-redirect.d.ts +26 -0
  180. package/dist/src/task-trace.d.ts +33 -0
  181. package/dist/src/tmux-attach.d.ts +11 -0
  182. package/dist/src/tmux-capability.d.ts +58 -0
  183. package/dist/src/tmux-exact-target.d.ts +36 -0
  184. package/dist/src/tmux-format.d.ts +20 -0
  185. package/dist/src/tmux-pane-prompt.d.ts +22 -0
  186. package/dist/src/tmux.d.ts +44 -0
  187. package/dist/src/token-cli.d.ts +13 -0
  188. package/dist/src/tool-allowlist.d.ts +28 -0
  189. package/dist/src/unsafe-package-path-reason.d.ts +31 -0
  190. package/dist/src/upgrade-channel.d.ts +31 -0
  191. package/dist/src/win-launcher.d.ts +20 -0
  192. package/dist/src/windows-codex-copresence.d.ts +60 -0
  193. package/package.json +15 -7
@@ -0,0 +1,28 @@
1
+ import { DaemonProviderStore } from './daemon-provider-store';
2
+ export declare function chatgptCredentialFingerprint(raw: string): string;
3
+ export declare class ProviderAccountCustody {
4
+ private nodeId;
5
+ private authPath;
6
+ private readAuth;
7
+ private previous?;
8
+ private selected?;
9
+ private before;
10
+ private next;
11
+ private installed;
12
+ private prepared;
13
+ constructor(store: DaemonProviderStore, nodeId: string, authPath: string, previousId: string | undefined, selectedId: string | undefined, readAuth: () => string | null);
14
+ get fingerprint(): string | undefined;
15
+ get previousFingerprint(): string | undefined;
16
+ get accountId(): string | undefined;
17
+ /** Capture AFTER verified stop: Codex may have refreshed auth since preflight. */
18
+ prepare(): {
19
+ previous_id: string | null;
20
+ selected_id: string | null;
21
+ before_auth: string | null;
22
+ };
23
+ private park;
24
+ install(): void;
25
+ /** No saved copy is used for an active account. Preserve refreshed credentials
26
+ * before restoring the old login, including a failed same-account model edit. */
27
+ rollback(): void;
28
+ }
@@ -0,0 +1,3 @@
1
+ /** Read only the exact owned node's loopback app-server. No logout/login or
2
+ * token refresh request, and no account details are returned to the Hub. */
3
+ export declare function verifyChatgptAppserver(endpoint: string, timeoutMs?: number, webSocketCtor?: any): Promise<void>;
@@ -0,0 +1,36 @@
1
+ import { DaemonProviderStore } from './daemon-provider-store';
2
+ export declare function providerNodeRevision(nodeDir: string): string;
3
+ export declare function readProviderNodeConfig(nodeDir: string): Record<string, any>;
4
+ export declare function readProviderNodeToml(nodeDir: string): import("smol-toml").TomlTable;
5
+ /** Private, local configured credentials only. Never inherit the caller's env. */
6
+ export declare function readProviderNodeEnv(nodeDir: string): Record<string, string>;
7
+ export type ProviderApplicationRequest = {
8
+ requestId: string;
9
+ networkId: string;
10
+ daemonId: string;
11
+ nodeId: string;
12
+ alias: string;
13
+ nodeRevision: string;
14
+ revision: number;
15
+ providerId: string;
16
+ authId: string;
17
+ model: string;
18
+ accountId?: string;
19
+ confirmRestart: true;
20
+ };
21
+ export type ProviderActivation = {
22
+ nodeId: string;
23
+ model: string;
24
+ runtimeProvider: string;
25
+ nodeRevision: string;
26
+ };
27
+ export type ProviderApplicationLifecycle = {
28
+ preflight?: () => Promise<void>;
29
+ stopVerified: () => Promise<void>;
30
+ activate: (expected: ProviderActivation) => Promise<ProviderActivation>;
31
+ verifyChatgpt?: () => Promise<void>;
32
+ restore: () => Promise<void>;
33
+ };
34
+ /** Stop → private writes → verified activation. A crash leaves an explicit
35
+ * private recovery journal; reconnect must NOT blindly replay the mutation. */
36
+ export declare function applyDaemonProvider(nodeDir: string, store: DaemonProviderStore, request: ProviderApplicationRequest, lifecycle: ProviderApplicationLifecycle): Promise<any>;
@@ -0,0 +1,9 @@
1
+ import { type ProviderApplicationRequest } from './daemon-provider-application';
2
+ import { type ProviderCliRunner } from './daemon-provider-lifecycle';
3
+ export declare function runDaemonProviderApply(args: string[], deps: {
4
+ nodesDir: string;
5
+ readInput: () => string;
6
+ print: (text: string) => void;
7
+ run?: ProviderCliRunner;
8
+ authorizeIdle?: (daemonDir: string, request: ProviderApplicationRequest) => Promise<void>;
9
+ }): Promise<number>;
@@ -0,0 +1,29 @@
1
+ import { DaemonProviderStore } from './daemon-provider-store';
2
+ import { type ProviderCollection } from './shared/provider-collection';
3
+ export { validProviderCollection, type ProviderCollection } from './shared/provider-collection';
4
+ /** Hub transport must authorize/revalidate binding before invoking this local
5
+ * operation. Local CLI users explicitly select an owned registry identity. */
6
+ export declare function collectDaemonProvider(nodesDir: string, store: DaemonProviderStore, selection: ProviderCollection, revision: number, requestId?: string): {
7
+ revision: number;
8
+ source: "daemon";
9
+ providers: {
10
+ id: string;
11
+ label: string;
12
+ enabled: boolean;
13
+ runtimes: {
14
+ runtime: "codex-tui";
15
+ auth: {
16
+ credential_present: boolean;
17
+ verification: "not_checked";
18
+ application: "not_applied";
19
+ account_id?: string | undefined;
20
+ baseUrl?: string | undefined;
21
+ id: string;
22
+ kind: import("./daemon-provider-store").ProviderAuthKind;
23
+ models: string[];
24
+ }[];
25
+ }[];
26
+ }[];
27
+ network_id: string;
28
+ daemon_node_id: string;
29
+ };
@@ -0,0 +1,7 @@
1
+ export declare const DAEMON_PROVIDER_USAGE = "anet daemon provider <list|scan|put|collect|apply|initialize> <daemon> [--revision N] [--request dps_UUID] (put/collect/scan/apply/initialize read private JSON from stdin; no key in argv)";
2
+ export declare function readProviderInput(fd?: number): string;
3
+ export declare function runDaemonProvider(args: string[], deps: {
4
+ nodesDir: string;
5
+ readInput: () => string;
6
+ print: (text: string) => void;
7
+ }): number;
@@ -0,0 +1,27 @@
1
+ import { DaemonProviderStore } from './daemon-provider-store';
2
+ import { type ProviderInitialization } from './shared/provider-initialization';
3
+ type Request = {
4
+ request_id: string;
5
+ alias: string;
6
+ network_id: string;
7
+ daemon_node_id: string;
8
+ selection: ProviderInitialization;
9
+ };
10
+ export declare function initializeDaemonProvider(nodesDir: string, store: DaemonProviderStore, request: Request): Promise<{
11
+ status: string;
12
+ request_id: string;
13
+ node_id: string;
14
+ provider_revision: number;
15
+ provider_id: string;
16
+ auth_id: string;
17
+ model: string;
18
+ runtime_provider: string;
19
+ node_revision: string;
20
+ verification: string;
21
+ }>;
22
+ export declare function runDaemonProviderInitialize(args: string[], deps: {
23
+ nodesDir: string;
24
+ readInput: () => string;
25
+ print: (text: string) => void;
26
+ }): Promise<number>;
27
+ export {};
@@ -0,0 +1,4 @@
1
+ import { type ProviderApplicationLifecycle, type ProviderApplicationRequest } from './daemon-provider-application';
2
+ export type ProviderCliRunner = (argv: string[], cwd: string, timeout: number) => Promise<string>;
3
+ export declare function providerCliRunner(binary: string, script: string, env: NodeJS.ProcessEnv): ProviderCliRunner;
4
+ export declare function providerApplicationLifecycle(nodeDir: string, request: ProviderApplicationRequest, run: ProviderCliRunner, authorizeIdle: () => Promise<void>): ProviderApplicationLifecycle;
@@ -0,0 +1,104 @@
1
+ export type ProviderAuthKind = "chatgpt" | "api_key";
2
+ export type ApplicationProfile = {
3
+ providerId: string;
4
+ authId: string;
5
+ model: string;
6
+ } & ({
7
+ kind: 'api_key';
8
+ baseUrl: string;
9
+ key: string;
10
+ } | {
11
+ kind: 'chatgpt';
12
+ accountId: string;
13
+ });
14
+ export declare class DaemonProviderError extends Error {
15
+ readonly code: string;
16
+ constructor(code: string);
17
+ }
18
+ export declare function readPrivateJson(path: string): unknown;
19
+ export declare class DaemonProviderStore {
20
+ private readonly root;
21
+ private readonly scope;
22
+ constructor(daemonDir: string);
23
+ private checkRoot;
24
+ private read;
25
+ private publicState;
26
+ list(): {
27
+ revision: number;
28
+ source: "daemon";
29
+ providers: {
30
+ id: string;
31
+ label: string;
32
+ enabled: boolean;
33
+ runtimes: {
34
+ runtime: "codex-tui";
35
+ auth: {
36
+ credential_present: boolean;
37
+ verification: "not_checked";
38
+ application: "not_applied";
39
+ account_id?: string | undefined;
40
+ baseUrl?: string | undefined;
41
+ id: string;
42
+ kind: ProviderAuthKind;
43
+ models: string[];
44
+ }[];
45
+ }[];
46
+ }[];
47
+ network_id: string;
48
+ daemon_node_id: string;
49
+ };
50
+ /** Presence only, never entitlement. Resolve an opaque saved-login ID solely
51
+ * inside this daemon's owned directory; callers cannot supply a credential path. */
52
+ private savedAccountPresent;
53
+ /** Local-only resolver. Never serialize this credential directory into a receipt. */
54
+ savedAccountHome(id: string): string | null;
55
+ /** Internal daemon bootstrap; this private path must never enter Hub replies. */
56
+ prepareLoginDirectory(): {
57
+ root: string;
58
+ network_id: string;
59
+ daemon_node_id: string;
60
+ };
61
+ /** Local application lease. Secrets stay inside the daemon callback, never in list/scan. */
62
+ withApiKey<T>(selection: {
63
+ revision: number;
64
+ providerId: string;
65
+ authId: string;
66
+ model: string;
67
+ }, apply: (profile: {
68
+ providerId: string;
69
+ authId: string;
70
+ model: string;
71
+ baseUrl: string;
72
+ key: string;
73
+ }) => Promise<T>): Promise<T>;
74
+ withApplicationProfile<T>(selection: {
75
+ revision: number;
76
+ providerId: string;
77
+ authId: string;
78
+ model: string;
79
+ }, apply: (profile: ApplicationProfile) => Promise<T>): Promise<T>;
80
+ upsert(value: unknown, expectedRevision: number, requestId?: string): {
81
+ revision: number;
82
+ source: "daemon";
83
+ providers: {
84
+ id: string;
85
+ label: string;
86
+ enabled: boolean;
87
+ runtimes: {
88
+ runtime: "codex-tui";
89
+ auth: {
90
+ credential_present: boolean;
91
+ verification: "not_checked";
92
+ application: "not_applied";
93
+ account_id?: string | undefined;
94
+ baseUrl?: string | undefined;
95
+ id: string;
96
+ kind: ProviderAuthKind;
97
+ models: string[];
98
+ }[];
99
+ }[];
100
+ }[];
101
+ network_id: string;
102
+ daemon_node_id: string;
103
+ };
104
+ }
@@ -0,0 +1,22 @@
1
+ /** 一个 runtime 依赖的外部二进制,以及它**有据可查**的安装位置。 */
2
+ export type RuntimeBinaryHint = {
3
+ /** 哪些 runtime 名需要这个二进制 */
4
+ readonly runtimes: readonly string[];
5
+ /** 在 PATH 上查的裸名 */
6
+ readonly binary: string;
7
+ /** 官方安装位置(相对 $HOME) */
8
+ readonly homeRelativeDir: string;
9
+ /** 🔴 这一条的出处 —— 没有出处就不许进这张表 */
10
+ readonly evidence: string;
11
+ };
12
+ export declare const RUNTIME_BINARY_HINTS: readonly RuntimeBinaryHint[];
13
+ export type PathPreflightInput = {
14
+ /** 这台 daemon 声称支持的 runtime */
15
+ readonly runtimes: readonly string[];
16
+ /** 二进制在 daemon 的 PATH 上能不能找到 */
17
+ readonly resolvesOnPath: (binary: string) => boolean;
18
+ /** 二进制在那个已知位置存不存在 */
19
+ readonly existsInHomeDir: (homeRelativeDir: string, binary: string) => boolean;
20
+ };
21
+ /** 返回要打给用户的警告。**没问题时返回空数组** —— 空是常态,不是失败。 */
22
+ export declare function daemonPathWarnings(input: PathPreflightInput): string[];
@@ -0,0 +1,13 @@
1
+ /**
2
+ * daemon 的 `runtimes_supported` 是**写配置那一刻**的支持集快照,之后不会自愈。
3
+ *
4
+ * 🔴 这不是假想的:#1298 (2026-08-28) 把新建 daemon 的默认清单从 3 个放开到
5
+ * `SUPPORTED_RUNTIME_NAMES` 全体,但**它只改了写入路径**。在那之前 init 过的
6
+ * daemon,配置里仍然只有那 3 个,而且没有任何东西会说出这件事 ——
7
+ * 用户在客户端「选服务器」里看到某台机器少几个 runtime,
8
+ * 既不知道为什么,也不知道该做什么。
9
+ *
10
+ * 判据从**分发处**取(`SUPPORTED_RUNTIME_NAMES`),不在这里手写一份清单:
11
+ * 抄一份就意味着它会再漂一次(同 #1728 的教训)。
12
+ */
13
+ export declare function describeStaleRuntimeSupport(declared: readonly string[] | undefined | null, supported: readonly string[], nameHint?: string): string | null;
@@ -0,0 +1,35 @@
1
+ export type DashboardLaunchSource = "npx" | "global";
2
+ export interface DashboardLaunchRecord {
3
+ schema: 1;
4
+ port: number;
5
+ listener_pid: number;
6
+ listener_birth: string;
7
+ source: DashboardLaunchSource;
8
+ source_key: string;
9
+ recorded_at: string;
10
+ }
11
+ export type DashboardListenerDecision = {
12
+ action: "start";
13
+ } | {
14
+ action: "already_running";
15
+ pid: number;
16
+ } | {
17
+ action: "terminate_owned_stale";
18
+ pid: number;
19
+ reason: "unhealthy" | "version_changed";
20
+ } | {
21
+ action: "refuse";
22
+ reason: string;
23
+ };
24
+ export declare function isDashboardProcessCommand(command: string): boolean;
25
+ export declare function decideDashboardListener(input: {
26
+ port: number;
27
+ listenerPids: number[];
28
+ record: DashboardLaunchRecord | null;
29
+ listenerBirth: string | null;
30
+ listenerCommand: string | null;
31
+ desiredSource: DashboardLaunchSource;
32
+ desiredSourceKey: string;
33
+ healthy: boolean;
34
+ }): DashboardListenerDecision;
35
+ export declare function parseDashboardLaunchRecord(value: unknown): DashboardLaunchRecord | null;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * 终端里的**显示列宽** —— CJK 字符占 2 列,而 `String.length` / `padEnd` 只数码元。
3
+ *
4
+ * 🔴 这份知识仓里本来就有,但它只活在**一个测试文件**里
5
+ * (`daemon-capability-display.test.ts` 的 `displayWidth`,2026-08-30 由 macOS 真机
6
+ * 上「合成首行约 99 列、80 列终端折行且折点落在句子中间」催生)。
7
+ * 生产代码没有它,于是所有用 `padEnd` 对齐的表在中文别名下都是歪的。
8
+ *
9
+ * 实测(2026-08-31,`anet node ls` 对着一支全中文别名的军团):
10
+ *
11
+ * NAME RUNTIME STATUS
12
+ * ──────────────────── ────────────── ────────
13
+ * 通信工程马 claude-code-cli idle ← RUNTIME 列起点
14
+ * 通信IM马 claude-code-cli idle ← 不一样
15
+ * 通信SDK牛 codex-sdk idle ← 又不一样
16
+ *
17
+ * `通信工程马`.length 是 5,`padEnd(20)` 补 15 个空格 —— 但它渲染出来是 10 列,
18
+ * 于是这一行实际占 25 列而不是 20。**别名里 CJK 越多,歪得越远。**
19
+ */
20
+ export declare function displayWidth(s: unknown): number;
21
+ /**
22
+ * 按**显示列**右补空格。已经不短于目标宽度时原样返回(与 `padEnd` 一致,不截断)。
23
+ *
24
+ * 🔴 不截断是有意的:截断会引出「截到一半的宽字符」这个新问题,
25
+ * 而调用方要的只是对齐。**一个修对齐的改动不该顺手引入截断语义。**
26
+ */
27
+ export declare function padDisplayEnd(s: unknown, width: number): string;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * `anet doctor` 原先对「本机配置了几个节点」的判定是:
3
+ *
4
+ * check("Nodes configured", ids.length > 0, `${ids.length} node(s)`);
5
+ *
6
+ * 于是 **0 个节点 → ❌**。而一个刚装好、还没建节点的人跑 `anet doctor`,
7
+ * 看到的是:
8
+ *
9
+ * ❌ Nodes configured — 0 node(s)
10
+ * Result: 9 ok, 3 warnings, 2 errors
11
+ *
12
+ * 🔴 「还没有节点」是**全新安装的预期状态**,不是故障。把它报成 error,
13
+ * 等于在新用户的第一次诊断里制造一个假警报 —— 而这条命令存在的意义
14
+ * 正是告诉他「你这台机器现在好不好」。
15
+ *
16
+ * 🔴 但也不能反过来直接判成「一切正常」:同一个 0 对一个**本来有节点**的人
17
+ * 意味着配置目录不见了。doctor 手上只有一个数字,**分不出这两种现实**。
18
+ * 所以这里既不报错也不报好 —— 把两种都说出来,让读的人自己对号,
19
+ * 并给出各自的下一步。
20
+ */
21
+ export type NodeCountLine = {
22
+ ok: true;
23
+ detail: string;
24
+ } | {
25
+ ok: false;
26
+ info: string;
27
+ };
28
+ export declare function nodeCountLine(count: number): NodeCountLine;
@@ -0,0 +1,14 @@
1
+ /** Parse the environ blob (NUL-separated key=val) and return the
2
+ * COMMHUB_ALIAS value if present, else null. Exported for testing. */
3
+ export declare function parseEnvironAlias(environBlob: string): string | null;
4
+ /** Read /proc/<pid>/environ and return the COMMHUB_ALIAS value.
5
+ * Any file-read error (not-a-Linux, permission denied, race with
6
+ * process exit) returns null — caller must not fail-closed on that
7
+ * (the process is stale/gone/inaccessible, not our problem). */
8
+ export declare function readEnvironAlias(pid: number): string | null;
9
+ /** Scan /proc for pids whose COMMHUB_ALIAS env matches any of the
10
+ * target aliases. Linux-only (procfs); returns null on non-Linux or
11
+ * when /proc is unreadable — caller MUST fail-closed on null per
12
+ * the same #180 R2 fail-closed contract as findNodeProcessesByAlias.
13
+ * Self-pid + init (PID 1) are excluded. */
14
+ export declare function findEnvironAliasMatches(aliases: Iterable<string>, selfPid: number): number[] | null;
@@ -0,0 +1,129 @@
1
+ import type { Duplex } from "node:stream";
2
+ export declare const GROK_ATTACH_PROTOCOL = "anet-grok-copresence-attach";
3
+ export declare const GROK_ATTACH_PROTOCOL_VERSION = 1;
4
+ export declare const GROK_ATTACH_DEFAULT_MAX_FRAME_BYTES: number;
5
+ export declare const GROK_ATTACH_DEFAULT_MAX_BUFFER_BYTES: number;
6
+ export declare const GROK_ATTACH_DEFAULT_HANDSHAKE_TIMEOUT_MS = 5000;
7
+ export declare const GROK_ATTACH_DEFAULT_CLOSE_TIMEOUT_MS = 1000;
8
+ export type GrokAttachJsonValue = null | boolean | number | string | GrokAttachJsonValue[] | {
9
+ [key: string]: GrokAttachJsonValue;
10
+ };
11
+ export interface GrokAttachHelloFrame {
12
+ type: "hello";
13
+ protocol: typeof GROK_ATTACH_PROTOCOL;
14
+ version: typeof GROK_ATTACH_PROTOCOL_VERSION;
15
+ alias: string;
16
+ sessionId: string;
17
+ [key: string]: unknown;
18
+ }
19
+ export interface GrokAttachOutputFrame {
20
+ type: "output";
21
+ data: string;
22
+ encoding: "base64";
23
+ }
24
+ export interface GrokAttachStatusFrame {
25
+ type: "status";
26
+ status: GrokAttachJsonValue;
27
+ }
28
+ export interface GrokAttachErrorFrame {
29
+ type: "error";
30
+ code: string;
31
+ message: string;
32
+ fatal: boolean;
33
+ }
34
+ export interface GrokAttachDetachFrame {
35
+ type: "detach";
36
+ }
37
+ export type GrokAttachServerFrame = GrokAttachHelloFrame | GrokAttachOutputFrame | GrokAttachStatusFrame | GrokAttachErrorFrame | GrokAttachDetachFrame;
38
+ export interface GrokAttachInputFrame {
39
+ type: "input";
40
+ data: string;
41
+ encoding: "base64";
42
+ }
43
+ export interface GrokAttachResizeFrame {
44
+ type: "resize";
45
+ cols: number;
46
+ rows: number;
47
+ }
48
+ /** Asks the node to switch models (issue #879); allowed on control connections. */
49
+ export interface GrokAttachSetModelFrame {
50
+ type: "set-model";
51
+ model: string;
52
+ }
53
+ export type GrokAttachClientFrame = GrokAttachInputFrame | GrokAttachResizeFrame | GrokAttachSetModelFrame | GrokAttachDetachFrame;
54
+ export interface GrokAttachInputSource {
55
+ on(event: "data", listener: (chunk: unknown) => void): unknown;
56
+ on(event: "end", listener: () => void): unknown;
57
+ off?(event: "data" | "end", listener: (...args: any[]) => void): unknown;
58
+ removeListener?(event: "data" | "end", listener: (...args: any[]) => void): unknown;
59
+ pause?(): unknown;
60
+ resume?(): unknown;
61
+ }
62
+ export interface GrokAttachOutputSink {
63
+ write(chunk: Uint8Array): boolean | void;
64
+ columns?: number;
65
+ rows?: number;
66
+ once?(event: "drain", listener: () => void): unknown;
67
+ }
68
+ export interface GrokAttachSignalSource {
69
+ on(event: "SIGWINCH", listener: () => void): unknown;
70
+ off?(event: "SIGWINCH", listener: () => void): unknown;
71
+ removeListener?(event: "SIGWINCH", listener: () => void): unknown;
72
+ }
73
+ export interface GrokAttachSocketStat {
74
+ uid: number;
75
+ isSocket(): boolean;
76
+ isSymbolicLink(): boolean;
77
+ }
78
+ export interface GrokAttachDependencies {
79
+ lstat?: (socketPath: string) => Promise<GrokAttachSocketStat>;
80
+ getuid?: () => number | undefined;
81
+ connect?: (socketPath: string) => Duplex;
82
+ }
83
+ export interface GrokAttachClientOptions {
84
+ socketPath: string;
85
+ input: GrokAttachInputSource;
86
+ output: GrokAttachOutputSink;
87
+ signalSource?: GrokAttachSignalSource;
88
+ terminalSize?: () => {
89
+ cols: number | undefined;
90
+ rows: number | undefined;
91
+ };
92
+ maxFrameBytes?: number;
93
+ maxBufferBytes?: number;
94
+ handshakeTimeoutMs?: number;
95
+ closeTimeoutMs?: number;
96
+ detachOnInputEnd?: boolean;
97
+ onHello?: (frame: GrokAttachHelloFrame) => void;
98
+ onStatus?: (frame: GrokAttachStatusFrame) => void;
99
+ onError?: (error: Error, frame?: GrokAttachErrorFrame) => void;
100
+ onDetach?: (frame: GrokAttachDetachFrame) => void;
101
+ dependencies?: GrokAttachDependencies;
102
+ }
103
+ export type GrokAttachCloseReason = "local-detach" | "input-end" | "remote-detach" | "socket-close" | "socket-error" | "protocol-error";
104
+ export interface GrokAttachCloseInfo {
105
+ reason: GrokAttachCloseReason;
106
+ error?: Error;
107
+ }
108
+ export interface GrokAttachSession {
109
+ readonly socketPath: string;
110
+ readonly closed: Promise<GrokAttachCloseInfo>;
111
+ detach(): void;
112
+ resize(cols?: number, rows?: number): void;
113
+ /**
114
+ * Ask the node to switch models (issue #879).
115
+ *
116
+ * The outcome does not come back from this call — it arrives as a `status`
117
+ * frame carrying `modelSwitch`, because the node may accept, refuse
118
+ * (busy / unchanged / invalid), or fail while re-spawning. Callers read it
119
+ * through `onStatus`.
120
+ */
121
+ setModel(model: string): void;
122
+ }
123
+ export declare class GrokAttachRemoteError extends Error {
124
+ readonly code: string;
125
+ readonly fatal: boolean;
126
+ constructor(frame: GrokAttachErrorFrame);
127
+ }
128
+ export declare function validateGrokAttachSocket(socketPath: string, dependencies?: GrokAttachDependencies): Promise<void>;
129
+ export declare function connectGrokAttach(options: GrokAttachClientOptions): Promise<GrokAttachSession>;
@@ -0,0 +1,15 @@
1
+ /** 从一段日志文本里取出**最后一次**出现的 grok 版本串。
2
+ * 🔴 取最后一次,不是第一次:日志按时间追加,最后一次才是这个进程最近一次
3
+ * 启动时用的那个。取第一次会在日志轮转/多次重启后指向历史。 */
4
+ export declare function parseGrokBuildFromLog(text: string): string | undefined;
5
+ /** 从 `grok --version` 的输出里取版本串(同一形状)。 */
6
+ export declare function parseGrokBuildFromVersionOutput(out: string): string | undefined;
7
+ export type GrokBuildDriftKind = "match" | "drift" | "unknown-current" | "unknown-started";
8
+ export interface GrokBuildDrift {
9
+ readonly kind: GrokBuildDriftKind;
10
+ readonly started?: string;
11
+ readonly current?: string;
12
+ /** 一句人读的话。四种 kind 四句不同的话 —— 含糊化等于把这一格的功能删掉。 */
13
+ readonly line: string;
14
+ }
15
+ export declare function describeGrokBuildDrift(started: string | undefined, current: string | undefined): GrokBuildDrift;
@@ -0,0 +1,11 @@
1
+ export type GrokCopresenceSessionDisclosure = "configured" | "new" | "resume";
2
+ export type GrokCopresenceDisclosure = {
3
+ profile: "commhub-only" | "x-search" | "repo-read" | "invalid";
4
+ lines: readonly string[];
5
+ };
6
+ /**
7
+ * Describe only the exact tool profiles accepted by the pinned Grok TUI
8
+ * runtime. This is deliberately exact: a near-miss must never be presented as
9
+ * either reviewed capability set.
10
+ */
11
+ export declare function grokCopresenceDisclosure(tools: unknown, session?: GrokCopresenceSessionDisclosure): GrokCopresenceDisclosure;
@@ -0,0 +1,75 @@
1
+ /** tmux session names. The attachable TUI owns the bare alias so that
2
+ * `tmux attach -t '=<alias>'` lands a human on the TUI, matching the codex
3
+ * lane exactly — an operator should not have to remember which runtime a node
4
+ * uses in order to know where to attach. */
5
+ export declare function grokCopresenceSessions(displayName: string): {
6
+ node: string;
7
+ tui: string;
8
+ };
9
+ export type GrokAttachSocketState = "missing" | "not_a_socket" | "ready";
10
+ /** Readiness is "the attach socket exists AND is a socket", never "the child
11
+ * process started". A grok leader that dies during startup leaves either no
12
+ * socket at all or a stale regular file from an aborted run; both used to read
13
+ * as ready because nothing looked. */
14
+ export declare function grokAttachSocketState(entry: {
15
+ isSocket(): boolean;
16
+ } | null | undefined): GrokAttachSocketState;
17
+ /** Set on the node child so that `anet node start` inside the tmux session does
18
+ * not re-enter this orchestration and fork bomb. The codex lane guards on the
19
+ * same variable (cli.ts: `process.env.ANET_COPRESENCE_BRIDGE !== "1"`); using a
20
+ * second name would leave two guards that must be kept in sync by hand. */
21
+ export declare const GROK_COPRESENCE_CHILD_ENV = "ANET_COPRESENCE_BRIDGE";
22
+ export interface GrokCopresenceDiagnosis {
23
+ readonly ok: boolean;
24
+ readonly lines: readonly string[];
25
+ /** #1768 —— 非阻断提示:平台能跑,但 agent-node 的能力表说它少了内核层保证。
26
+ * ok=true 时也可能非空;调用方打印它,不退出。 */
27
+ readonly notices: readonly string[];
28
+ }
29
+ /** One block naming every reason this node cannot run the shared TUI, not one
30
+ * exit per reason. A node that is both the wrong runtime AND missing its
31
+ * attach socket should learn both in one run. */
32
+ /** Platforms whose PTY / IPC / isolation primitives the grok co-presence lane
33
+ * has actually been validated on. agent-node refuses anywhere else, and it does
34
+ * so only after the node has been created and started once:
35
+ *
36
+ * [agent-node] grok-build-cli co-presence 无法在 darwin 上运行,缺少:
37
+ * 平台 darwin 尚未验证过共存所需的 PTY / IPC / 隔离原语
38
+ *
39
+ * Learned the expensive way on a Mac mini: install anet, install agent-node,
40
+ * create the node, start it — and only then find out the platform is refused.
41
+ * A one-command launcher that lets someone get that far has not saved them
42
+ * anything, so say it in the same breath as every other gap. */
43
+ export declare const GROK_COPRESENCE_PLATFORMS: readonly NodeJS.Platform[];
44
+ /** 能跑但没有内核层强制的平台 —— agent-node 启动时逐条打印 reducedGuarantees,这里只提前说一句。 */
45
+ export declare const GROK_COPRESENCE_REDUCED_GUARANTEE_PLATFORMS: readonly NodeJS.Platform[];
46
+ export declare function diagnoseGrokCopresence(input: {
47
+ runtime: string;
48
+ displayName: string;
49
+ grokCopresence?: boolean;
50
+ grokAttachSocket?: string;
51
+ platform?: NodeJS.Platform;
52
+ }): GrokCopresenceDiagnosis;
53
+ /** True when a plain `anet node start <name>` (no flag) should bring the shared
54
+ * TUI up by itself.
55
+ *
56
+ * 🔴 Deliberately NOT keyed on `grokCopresence`. That field is set to true at
57
+ * CREATE time for every grok-build-cli node, so reading it here would silently
58
+ * change what `anet node start` does for every grok node that already exists —
59
+ * they would stop running in the foreground and fork into tmux, unasked. Caught
60
+ * exactly that way: a start without the flag entered the orchestration.
61
+ *
62
+ * The codex lane looks the same but is not: `codexCopresence` is written only
63
+ * when the operator passes the flag. So grok needs its own record of the
64
+ * operator's choice, and `grokCopresenceAuto` is it. */
65
+ export declare function grokCopresenceRequested(flagPassed: boolean, profile: {
66
+ runtime?: unknown;
67
+ grokCopresence?: unknown;
68
+ grokCopresenceAuto?: unknown;
69
+ }): boolean;
70
+ /** Record the operator's opt-in so the NEXT start needs no flag — and only then.
71
+ * Never infer it from `grokCopresence`, which create sets by default. */
72
+ export declare function shouldPersistGrokCopresence(flagPassed: boolean, profile: {
73
+ runtime?: unknown;
74
+ grokCopresenceAuto?: unknown;
75
+ }): boolean;