@sleep2agi/agent-network 2.3.0-preview.17 → 2.3.0-preview.171

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 +3 -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,180 @@
1
+ /**
2
+ * #562 step 2 — remote lifecycle: act on a node that lives on ANOTHER machine.
3
+ *
4
+ * anet node start <alias> --remote [--network <id|name>] [--yes] [--wait <s>]
5
+ * anet node stop <alias> --remote [--network <id|name>] [--yes] [--wait <s>] [--force]
6
+ * anet node restart <alias> --remote [--network <id|name>] [--yes] [--wait <s>]
7
+ * anet node edit <alias> --model <id> --remote [--network <id|name>] [--yes] [--wait <s>]
8
+ *
9
+ * Nothing new on the Hub: these are the same MCP tools the app calls (POST /mcp tools/call):
10
+ * start → start_node Hub → that machine's daemon (host_supervisor) spawns the child
11
+ * stop → stop_node Hub → that machine's daemon stops the child
12
+ * restart → restart_node Hub → the node itself drains + exits 75; its `anet node start`
13
+ * wrapper respawns it (whoever ran that wrapper: a daemon or a person)
14
+ * edit → update_node_config same doorbell; a model change is restart-tier
15
+ * Permission checks are the Hub's (canWrite: member+, not viewer, not agent-restricted); this
16
+ * module never decides who may do what — it only refuses what cannot work, BEFORE dispatching:
17
+ * start/stop (need the machine's daemon):
18
+ * - no online daemon on the node's machine → "this machine can't be managed remotely"
19
+ * - the node was not created by a daemon → the Hub keeps no daemon for it
20
+ * - the daemon that created it is offline
21
+ * restart/edit (#570 — no daemon involved, the Hub pushes to the node itself):
22
+ * - the node is not running → nothing would receive the doorbell
23
+ * - it does not report config_update_capable → no exit-75 supervisor: it would just die
24
+ *
25
+ * Pure functions here; the HTTP calls live in bin/cli.ts (nodeRemoteCommand).
26
+ */
27
+ import type { PlannedCommand } from "./codex-menu";
28
+ export type RemoteVerb = "start" | "stop" | "restart" | "edit";
29
+ export declare const REMOTE_VERBS: readonly RemoteVerb[];
30
+ export declare const DEFAULT_WAIT_SECONDS = 60;
31
+ export declare const MAX_WAIT_SECONDS = 600;
32
+ export type RemoteArgs = {
33
+ verb: RemoteVerb;
34
+ alias: string | null;
35
+ network: string | null;
36
+ model: string | null;
37
+ yes: boolean;
38
+ force: boolean;
39
+ waitSeconds: number;
40
+ error: string | null;
41
+ };
42
+ /** True when this `anet node <verb> …` invocation is the remote form. */
43
+ export declare function isRemoteInvocation(argv: string[]): boolean;
44
+ /**
45
+ * @param argv everything after `anet node <verb>` (the verb itself excluded).
46
+ * Unknown flags are refused: a local-only flag (`--tmux`, `--copresence`, `--runtime` …) silently
47
+ * ignored on a remote node would be a lie about what was done.
48
+ */
49
+ export declare function parseRemoteArgs(verb: RemoteVerb, argv: string[]): RemoteArgs;
50
+ export type HubNodeRow = {
51
+ node_id: string;
52
+ alias: string;
53
+ hostname?: string | null;
54
+ role?: string | null;
55
+ lifecycle_state?: string | null;
56
+ lifecycle_controllable?: boolean;
57
+ lifecycle_daemon_node_id?: string | null;
58
+ model?: string | null;
59
+ };
60
+ export type HubSession = {
61
+ alias?: string;
62
+ node_id?: string | null;
63
+ status?: string | null;
64
+ hostname?: string | null;
65
+ host?: {
66
+ hostname?: string | null;
67
+ } | null;
68
+ last_seen_at?: string | null;
69
+ updated_at?: string | null;
70
+ model?: string | null;
71
+ };
72
+ /** GET /api/host-supervisors row: the daemon's node id is `daemon_node_id` (not `node_id`). */
73
+ export type HubDaemon = {
74
+ daemon_node_id?: string;
75
+ alias?: string;
76
+ hostname?: string | null;
77
+ online?: boolean;
78
+ last_seen_at?: string | null;
79
+ };
80
+ export type RemoteTarget = {
81
+ node_id: string;
82
+ alias: string;
83
+ hostname: string | null;
84
+ lifecycle_state: string;
85
+ session_status: string | null;
86
+ session_seen: string | null;
87
+ model: string | null;
88
+ /** The daemon that created the node (start/stop go through it). null = not daemon-managed: only
89
+ * restart/edit resolve without one. `online` is false only for restart/edit (they don't need it). */
90
+ daemon: {
91
+ node_id: string;
92
+ alias: string;
93
+ online: boolean;
94
+ } | null;
95
+ };
96
+ export type ResolveResult = {
97
+ ok: true;
98
+ target: RemoteTarget;
99
+ } | {
100
+ ok: false;
101
+ code: "not_found" | "is_daemon" | "daemons_not_visible" | "no_daemon_on_host" | "not_daemon_managed" | "creator_daemon_offline";
102
+ message: string;
103
+ };
104
+ /**
105
+ * @param nodes GET /api/nodes?alias=<alias>&network_id=<net> (rows; newest first)
106
+ * @param sessions GET /api/status?network_id=<net> (sessions)
107
+ * @param daemons GET /api/host-supervisors?network_id=<net> (daemons; [] = none visible)
108
+ */
109
+ export declare function resolveRemoteTarget(verb: RemoteVerb, alias: string, nodes: HubNodeRow[], sessions: HubSession[], daemons: HubDaemon[]): ResolveResult;
110
+ export type Precheck = {
111
+ kind: "go";
112
+ } | {
113
+ kind: "noop";
114
+ message: string;
115
+ } | {
116
+ kind: "refuse";
117
+ message: string;
118
+ };
119
+ export declare function isRunning(t: RemoteTarget): boolean;
120
+ export declare function precheck(verb: RemoteVerb, t: RemoteTarget, cfg?: {
121
+ config_update_capable?: boolean;
122
+ } | null): Precheck;
123
+ export declare function remoteCommandArgv(a: {
124
+ verb: RemoteVerb;
125
+ alias: string;
126
+ networkId: string;
127
+ model?: string | null;
128
+ force?: boolean;
129
+ }): string[];
130
+ export declare function describePlan(verb: RemoteVerb, t: RemoteTarget, model?: string | null): string;
131
+ /** The one-line "where/what" header printed before the plan. */
132
+ export declare function describeTarget(verb: RemoteVerb, t: RemoteTarget): string;
133
+ export declare function planRemote(a: {
134
+ verb: RemoteVerb;
135
+ target: RemoteTarget;
136
+ networkId: string;
137
+ model?: string | null;
138
+ force?: boolean;
139
+ }): PlannedCommand;
140
+ export declare function toolCall(verb: RemoteVerb, t: RemoteTarget, networkId: string, opts?: {
141
+ model?: string | null;
142
+ force?: boolean;
143
+ baseRevision?: number;
144
+ }): {
145
+ name: string;
146
+ arguments: Record<string, unknown>;
147
+ };
148
+ export declare function explainHubRefusal(verb: RemoteVerb, alias: string, r: any): string;
149
+ export type Observation = {
150
+ lifecycle_state: string | null;
151
+ session_status: string | null;
152
+ session_seen: string | null;
153
+ config_revision: number | null;
154
+ model: string | null;
155
+ };
156
+ export type Outcome = {
157
+ state: "pending";
158
+ } | {
159
+ state: "done";
160
+ message: string;
161
+ } | {
162
+ state: "failed";
163
+ message: string;
164
+ };
165
+ /**
166
+ * @param before what the hub showed right before dispatch
167
+ * @param now what it shows now
168
+ * Seen-times are compared as the hub's own strings (changed or not), never against this machine's
169
+ * clock: the node is on another machine and the hub on a third.
170
+ */
171
+ export declare function evaluateOutcome(verb: RemoteVerb, t: RemoteTarget, before: Observation, now: Observation, want?: {
172
+ model?: string | null;
173
+ baseRevision?: number;
174
+ }): Outcome;
175
+ /**
176
+ * @param last the last observation before the deadline (null = none could be read). For restart/edit it
177
+ * tells "went down and never came back" (the supervisor did not respawn it — a real failure
178
+ * worth a different next step) apart from "still finishing its turn".
179
+ */
180
+ export declare function timeoutMessage(verb: RemoteVerb, alias: string, seconds: number, last?: Observation | null, host?: string | null): string;
@@ -0,0 +1,9 @@
1
+ export declare const isAgentNodeCommand: (cmdline: string) => boolean;
2
+ export interface RunningNodeProbe {
3
+ pidFileContent: string | null;
4
+ isAlive: (pid: number) => boolean;
5
+ commandOf: (pid: number) => string | null;
6
+ }
7
+ /** 返回还活着且确实是 agent-node 的 pid;否则 null(不存在 / 死了 / pid 被别的进程复用)。 */
8
+ export declare const runningNodePid: (probe: RunningNodeProbe) => number | null;
9
+ export declare const alreadyRunningMessage: (displayName: string, pid: number) => string[];
@@ -0,0 +1,35 @@
1
+ export interface NodeIdentityFromConfig {
2
+ node_id?: string;
3
+ node_name?: string;
4
+ model?: string;
5
+ }
6
+ export declare function nodeIdentityFromConfig(path: string | undefined): NodeIdentityFromConfig;
7
+ export interface NodeRowLike {
8
+ node_id?: string | null;
9
+ alias?: string | null;
10
+ runtime?: string | null;
11
+ config_path?: string | null;
12
+ }
13
+ export type NodeIdClaimVerdict = {
14
+ claim: true;
15
+ } | {
16
+ claim: false;
17
+ owner: string;
18
+ runtime: string | null;
19
+ config_path: string | null;
20
+ };
21
+ export declare function nodeIdClaimVerdict(nodeId: string, rows: readonly NodeRowLike[], alias: string): NodeIdClaimVerdict;
22
+ export type NodeIdClaimState = "ok" | "conflict" | "unknown";
23
+ /** 取 hub 上这个 node_id 的行并下结论;任何失败都是 "unknown"(调用方这次不报 node_id)。 */
24
+ export declare function checkNodeIdClaim(opts: {
25
+ hubUrl: string;
26
+ token: string;
27
+ nodeId: string;
28
+ alias: string;
29
+ fetchImpl?: typeof fetch;
30
+ timeoutMs?: number;
31
+ }): Promise<{
32
+ state: NodeIdClaimState;
33
+ verdict?: NodeIdClaimVerdict;
34
+ error?: string;
35
+ }>;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * What gets written to `<project>/.anet/node-server.js` (issue #1216).
3
+ *
4
+ * The target name is not negotiable: `agent-node`'s grok co-presence spawn
5
+ * gate pins the CommHub MCP payload to exactly that path, so whatever the
6
+ * source is, the file that lands there is called `.js`.
7
+ *
8
+ * 🔴 The bug this module exists to remove: the old code copied the source
9
+ * verbatim and justified it with a comment claiming
10
+ *
11
+ * "bun runs .ts content under a .js extension fine"
12
+ *
13
+ * which is false — bun selects its parser from the extension:
14
+ *
15
+ * $ printf 'function f(x: string): void {}\nf("hi");\n' > probe.ts
16
+ * $ cp probe.ts probe.js
17
+ * $ bun probe.ts → runs
18
+ * $ bun probe.js → error: Expected ")" but found ":"
19
+ *
20
+ * An installed npm package never hit it, because its first resolver candidate
21
+ * (`dist/src/node-server.js`) is compiled. Only a source checkout fell through
22
+ * to `src/node-server.ts` — i.e. every local run and every hand-verified PR.
23
+ *
24
+ * And the symptom was three layers from the cause: the node died on
25
+ * `grok copresence CommHub MCP readiness preflight failed (1)`, which names
26
+ * neither a file nor a parse error.
27
+ */
28
+ /** Injected so the decision is testable without spawning anything. */
29
+ export interface TypeScriptBundler {
30
+ /** Returns the self-contained JavaScript for `entryPath`, or throws. */
31
+ bundleSync(entryPath: string): string;
32
+ }
33
+ export declare class NodeServerPayloadError extends Error {
34
+ constructor(message: string);
35
+ }
36
+ /**
37
+ * Decide what bytes belong at the `.js` target for a given source path.
38
+ *
39
+ * A `.js` source is passed through untouched — the published package ships a
40
+ * compiled bundle there, and re-processing it risks changing bytes for no gain.
41
+ *
42
+ * 🔴 A `.ts` source must be **bundled, not merely transpiled**. Stripping types
43
+ * fixes the parse error but leaves the file's relative imports pointing at
44
+ * siblings that do not exist beside the destination:
45
+ *
46
+ * import { inboundChannelMeta } from "./channel-meta.js";
47
+ * → Cannot find module './channel-meta.js' from '<project>/.anet/node-server.js'
48
+ *
49
+ * That second failure is why transpiling alone still ended at
50
+ * "CommHub MCP readiness preflight failed (1)". The published
51
+ * `dist/src/node-server.js` works precisely because it is a self-contained
52
+ * bundle, so a source checkout has to produce the same shape.
53
+ */
54
+ export declare function nodeServerPayloadFor(source: string, sourcePath: string, bundler: TypeScriptBundler | null): string;
55
+ /**
56
+ * The bundler available on this runtime, or null.
57
+ *
58
+ * bun can bundle; the published CLI runs under node and cannot — but it also
59
+ * never resolves a `.ts` candidate (its `dist/` copy wins), so null there is
60
+ * correct rather than a gap.
61
+ *
62
+ * `spawnSync` rather than `Bun.build()` because both call sites are
63
+ * synchronous, and making them async would change the ordering of the file
64
+ * writes around them.
65
+ */
66
+ export declare function ambientTypeScriptTranspiler(): TypeScriptBundler | null;
@@ -0,0 +1,14 @@
1
+ export declare const CLAUDE_CODE_RULES_RUNTIME = "claude";
2
+ export interface RulesDoorbellDeps {
3
+ callCommHub: (method: string, params: Record<string, unknown>) => Promise<any>;
4
+ workDir: string;
5
+ log: (msg: string) => void;
6
+ /** 技能的用户级根目录(~/.claude/skills)取自这里;缺省 os.homedir()。测试注入临时目录。 */
7
+ home?: string;
8
+ }
9
+ /** SSE 事件分派:是 rules_file 门铃就处理并返回 true;其它事件原样返回 false。 */
10
+ export declare function handleRulesFileEvent(event: {
11
+ type?: unknown;
12
+ } | null | undefined, deps: RulesDoorbellDeps): Promise<boolean>;
13
+ /** 连上 / 重连后补拉一次:断线期间桌面端可能已发起请求(hub 侧 60s 内仍 pending)。 */
14
+ export declare function drainRulesFileRequests(deps: RulesDoorbellDeps, why: string): Promise<number>;
@@ -0,0 +1,39 @@
1
+ export declare const NODE_SERVER_VERSION_MARKER_PREFIX = "// anet-node-server-version: ";
2
+ /** The version carried by a node-server payload, or null if it has no valid marker. */
3
+ export declare function readNodeServerVersion(text: string | null | undefined): string | null;
4
+ /**
5
+ * Add the marker if the payload has none. A leading `#!` line stays first so
6
+ * the file is still directly executable.
7
+ */
8
+ export declare function stampNodeServerVersion(payload: string, version: string): string;
9
+ /**
10
+ * Version of the agent-network package that owns `sourcePath`, found by walking
11
+ * up (dist/src/node-server.js → package root is two levels up; src/node-server.ts
12
+ * one level). Null when no agent-network package.json is found.
13
+ */
14
+ export declare function owningAgentNetworkVersion(sourcePath: string): string | null;
15
+ /** Ensure the payload carries a marker, deriving the version from its source package when needed. */
16
+ export declare function ensureNodeServerVersionMarker(payload: string, sourcePath: string): string;
17
+ export type NodeServerWriteDecision = {
18
+ action: "write";
19
+ existingVersion: string | null;
20
+ incomingVersion: string | null;
21
+ } | {
22
+ action: "keep-newer";
23
+ existingVersion: string;
24
+ incomingVersion: string;
25
+ };
26
+ /**
27
+ * Keep the existing file only when BOTH sides carry a valid marker and the
28
+ * existing one is strictly newer. Everything else behaves as before (#549).
29
+ */
30
+ export declare function decideNodeServerWrite(existing: string | null, incoming: string): NodeServerWriteDecision;
31
+ /** The one-line warning printed when a newer file is kept. */
32
+ export declare function nodeServerKeptNewerWarning(existingVersion: string, incomingVersion: string): string;
33
+ export type NodeServerApplyResult = "wrote" | "unchanged" | "kept-newer";
34
+ /**
35
+ * The single write path both cli.ts writers use: stamp the payload, refuse to
36
+ * downgrade a newer existing file (warning once via `warn`), otherwise write
37
+ * when the bytes differ.
38
+ */
39
+ export declare function applyNodeServerPayload(targetPath: string, payload: string, sourcePath: string, warn?: (line: string) => void): NodeServerApplyResult;