@sleep2agi/agent-network 2.3.0-preview.155 → 2.3.0-preview.157

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.
@@ -1,9 +1,9 @@
1
- export declare const PAIRED_AGENT_NETWORK_VERSION = "2.3.0-preview.155";
2
- export declare const PAIRED_AGENT_NODE_VERSION = "2.5.0-preview.123";
3
- export declare const PAIRED_AGENT_NODE_SPEC = "@sleep2agi/agent-node@2.5.0-preview.123";
4
- export declare const OPENCODE_AGENT_NETWORK_VERSION = "2.3.0-preview.155";
5
- export declare const OPENCODE_AGENT_NODE_VERSION = "2.5.0-preview.123";
6
- export declare const OPENCODE_AGENT_NODE_SPEC = "@sleep2agi/agent-node@2.5.0-preview.123";
1
+ export declare const PAIRED_AGENT_NETWORK_VERSION = "2.3.0-preview.157";
2
+ export declare const PAIRED_AGENT_NODE_VERSION = "2.5.0-preview.125";
3
+ export declare const PAIRED_AGENT_NODE_SPEC = "@sleep2agi/agent-node@2.5.0-preview.125";
4
+ export declare const OPENCODE_AGENT_NETWORK_VERSION = "2.3.0-preview.157";
5
+ export declare const OPENCODE_AGENT_NODE_VERSION = "2.5.0-preview.125";
6
+ export declare const OPENCODE_AGENT_NODE_SPEC = "@sleep2agi/agent-node@2.5.0-preview.125";
7
7
  export type PairedAgentNodeResolution = {
8
8
  spec: string;
9
9
  args: string[];
@@ -15,8 +15,6 @@ export declare function probePosixOwnedLoopbackConnection(rootPid: number, port:
15
15
  * 每 intervalMs 探一次,直到:探到(connected)/ TUI 退了(tui-exited,不再白等)/ 到点(deadline)。
16
16
  * 判据本身不变:仍是 probePosixOwnedLoopbackConnection 的 fail-closed 归属,只是不再只给一次机会。
17
17
  */
18
- /** 与 Windows 路径的 TUI_HEALTH_MS 同一个预算(cli.ts):TUI 活着却 25 s 都没连上,才判失败。 */
19
- export declare const POSIX_TUI_ATTRIBUTION_MS = 25000;
20
18
  export type PosixAttributionResult = {
21
19
  outcome: "connected" | "tui-exited" | "deadline";
22
20
  probes: number;
@@ -0,0 +1,3 @@
1
+ export declare const RESERVED_ENV_KEYS_EXACT: Set<string>;
2
+ export declare const RESERVED_ENV_PREFIXES: ReadonlyArray<string>;
3
+ export declare function isReservedEnvKey(k: string): boolean;
@@ -0,0 +1,146 @@
1
+ export declare const START_GATE_DEFAULT_MIN_MEM_MB = 4096;
2
+ export declare const START_GATE_DEFAULT_MEM_FRACTION = 0.15;
3
+ export declare const START_GATE_DEFAULT_MAX_LOAD_PER_CPU = 4;
4
+ export declare const START_GATE_DEFAULT_MAX_WAIT_SEC = 600;
5
+ export declare const START_GATE_DEFAULT_MAX_CONCURRENT = 2;
6
+ export declare const START_GATE_SINGLE_LANE_CONCURRENT = 1;
7
+ export declare const START_GATE_RECHECK_MS = 15000;
8
+ /** Jitter added to each re-check while still inside the max wait: uniform [0, RECHECK_JITTER_MS). */
9
+ export declare const START_GATE_RECHECK_JITTER_MS = 5000;
10
+ export declare const START_GATE_WAITING_MEMORY_STATUS = "\u7B49\u5F85\u5185\u5B58";
11
+ export declare const START_GATE_WAITING_LOAD_STATUS = "\u7B49\u5F85\u8D1F\u8F7D";
12
+ export declare const START_GATE_WAITING_BOTH_STATUS = "\u7B49\u5F85\u5185\u5B58\u548C\u8D1F\u8F7D";
13
+ export declare const START_GATE_WAITING_PROBE_STATUS = "\u7B49\u5F85\u8D44\u6E90\u63A2\u6D4B";
14
+ /** #686 compatibility alias for callers that used the original memory-only status. */
15
+ export declare const START_GATE_WAITING_STATUS = "\u7B49\u5F85\u5185\u5B58";
16
+ export declare const START_GATE_SINGLE_LANE_STATUS = "\u5DF2\u8D85\u65F6\uFF0C\u6309\u5355\u8DEF\u653E\u884C";
17
+ /** Logged when one waiter atomically replaces a stuck lease. The wait cap must not admit without this. */
18
+ export declare const START_GATE_TAKEOVER_STATUS = "\u63A5\u7BA1\u5361\u6B7B\u79DF\u7EA6";
19
+ /** Startup leases older than this are not live. ANET_START_LEASE_TTL_SEC overrides it. */
20
+ export declare const START_GATE_LEASE_TTL_MS: number;
21
+ /** A healthy holder renews well before the default lease expiry. */
22
+ export declare const START_GATE_LEASE_HEARTBEAT_MS = 30000;
23
+ /** An empty or unreadable lock younger than this is still being published, not dead. */
24
+ export declare const START_GATE_LOCK_STALE_MS = 30000;
25
+ /**
26
+ * A live matching lock is an orphan when the monotonic timestamp stored in
27
+ * the lock is older than this. Legacy locks with no stamp still use wall
28
+ * mtime, which a clock step can age out. The critical section only renames
29
+ * and writes a few files, so a live holder past this window is stuck.
30
+ */
31
+ export declare const START_GATE_LOCK_ORPHAN_MS = 60000;
32
+ export interface StartGateDeps {
33
+ env?: NodeJS.ProcessEnv;
34
+ platform?: string;
35
+ /** Returns file contents, or null when unreadable. */
36
+ readFile?: (path: string) => string | null;
37
+ cpuCount?: () => number;
38
+ sleep?: (ms: number) => Promise<void>;
39
+ now?: () => number;
40
+ random?: () => number;
41
+ log?: (msg: string) => void;
42
+ warn?: (msg: string) => void;
43
+ /** Hub/task text. Errors are swallowed so a report failure cannot block a start. */
44
+ report?: (text: string) => void;
45
+ /** Host lease directory. Tests must inject this; the default is ~/.anet/run/start-slots. */
46
+ slotsDir?: string;
47
+ /** Lease key. Alias is not unique across workspaces; pass the node id. */
48
+ nodeId?: string;
49
+ /** Pid written into the lease. Default: this process. */
50
+ holderPid?: number;
51
+ /** ESRCH = dead, EPERM = alive. Injected so tests never signal a real pid. */
52
+ isPidAlive?: (pid: number) => boolean;
53
+ /** /proc/<pid>/stat field 22. null means unknown — do not treat that as a mismatch. */
54
+ readProcessStartTicks?: (pid: number) => string | null;
55
+ /** Override the 15s re-check. With jitterMs 0 the single-lane retry uses this as-is. */
56
+ recheckMs?: number;
57
+ /** Override the 0–5s jitter span. 0 keeps the sleep exactly recheckMs. */
58
+ jitterMs?: number;
59
+ /** Lease lifetime. Default 10 minutes, or ANET_START_LEASE_TTL_SEC. */
60
+ leaseTtlMs?: number;
61
+ /** @internal deterministic short-TTL seam. Defaults to min(30s, TTL/3). */
62
+ leaseHeartbeatMs?: number;
63
+ /** Empty/unreadable locks younger than this are held, not dead. */
64
+ lockStaleMs?: number;
65
+ /** A live matching lock older than this is an orphan. Default 60s. */
66
+ lockOrphanMs?: number;
67
+ /**
68
+ * Monotonic milliseconds shared by every process on this host.
69
+ * Default reads /proc/uptime. null means unknown: a stamped lock is kept.
70
+ */
71
+ monotonicNow?: () => number | null;
72
+ }
73
+ export type StartGateOutcome = "disabled" | "unsupported" | "ok" | "waited" | "single-lane";
74
+ export interface StartGateResult {
75
+ outcome: StartGateOutcome;
76
+ waitedMs: number;
77
+ checks: number;
78
+ /** Always callable and idempotent. Drops the lease only if this call created it. */
79
+ release: () => void;
80
+ }
81
+ export interface HostSample {
82
+ /** Effective free MiB: min(MemAvailable, cgroup free) when a real cgroup limit exists. */
83
+ memAvailableMb: number;
84
+ /** /proc MemAvailable, before the cgroup min. */
85
+ procAvailableMb: number;
86
+ /** Cgroup free MiB, or null when there is no real limit. */
87
+ cgroupFreeMb: number | null;
88
+ /** Cgroup limit MiB, or null when there is no real limit. The floor uses this, not the host alone. */
89
+ cgroupLimitMb: number | null;
90
+ /** 0 when MemTotal could not be read (the floor then falls back to 4096). */
91
+ memTotalMb: number;
92
+ load1: number;
93
+ cpuCount: number;
94
+ }
95
+ export interface StartGateStatusSnapshot {
96
+ status: string;
97
+ task?: string;
98
+ }
99
+ /** True only for blocked text owned by this gate, including single-lane wait. */
100
+ export declare function isStartGateBlockedStatus(task: string | undefined): boolean;
101
+ /**
102
+ * Once admission returns, restore the pre-gate status only if the live status
103
+ * is still ours. A concurrent task/status update must win over stale restore.
104
+ */
105
+ export declare function startGateStatusToRestore(live: StartGateStatusSnapshot, previous: StartGateStatusSnapshot): StartGateStatusSnapshot | null;
106
+ /** MemAvailable in MiB from /proc/meminfo text, or null. */
107
+ export declare function parseMemAvailableMb(meminfo: string): number | null;
108
+ /** MemTotal in MiB from /proc/meminfo text, or null. */
109
+ export declare function parseMemTotalMb(meminfo: string): number | null;
110
+ /** 1-minute load average from /proc/loadavg text, or null. */
111
+ export declare function parseLoad1(loadavg: string): number | null;
112
+ /**
113
+ * Field 22 of /proc/<pid>/stat (starttime, clock ticks since boot).
114
+ * The comm field is in parentheses and may contain spaces; everything after the
115
+ * last ")" is field 3 onward, so field 22 is index 19 of that tail.
116
+ */
117
+ export declare function parseProcStartTicks(statText: string): string | null;
118
+ /**
119
+ * Default free-memory floor. A fixed 4 GiB is too high for a small machine
120
+ * or a small container, so the floor is min(4 GiB, 15% of the effective total).
121
+ * The effective total is min(MemTotal, cgroup limit) when a real cgroup limit
122
+ * exists — a container must not be judged against the host's MemTotal.
123
+ * Missing/invalid numbers fall back to 4 GiB. ANET_START_MIN_MEM_MB replaces
124
+ * this when set.
125
+ */
126
+ export declare function defaultStartMinMemMb(memTotalMb: number, cgroupLimitMb?: number | null): number;
127
+ /** Reasons the host is too busy to start, empty when it is fine. */
128
+ export declare function startGateReasons(s: HostSample, minMemMb: number, maxLoadPerCpu: number): string[];
129
+ /** User-facing blocked status. Keep this structured instead of parsing the diagnostic reasons. */
130
+ export declare function startGateWaitingStatus(s: HostSample | null, minMemMb: number, maxLoadPerCpu: number): string | null;
131
+ /**
132
+ * Free MiB inside a real cgroup limit, or null when the limit is missing/unlimited.
133
+ * `memory.current` counts page cache; inactive_file (v1: total_inactive_file) is subtracted.
134
+ * statText null keeps the old arithmetic so existing fixtures stay valid.
135
+ */
136
+ export declare function cgroupFreeMb(maxText: string, currentText: string, memTotalMb: number, statText?: string | null, v1?: boolean): number | null;
137
+ /** Real cgroup limit in MiB, or null when the limit is missing/unlimited. */
138
+ export declare function cgroupLimitMb(maxText: string, memTotalMb: number): number | null;
139
+ /**
140
+ * Block until this host may start one heavy process.
141
+ * Returns a release() the caller must invoke once that process is up or has failed.
142
+ * Never throws (except when the injected sleep rejects — tests use that to stop a wait).
143
+ */
144
+ export declare function waitForStartResources(label: string, deps?: StartGateDeps): Promise<StartGateResult>;
145
+ /** Run `fn` while holding one start lease. Release runs on success and on failure. */
146
+ export declare function withHeavyStartAdmission<T>(label: string, deps: StartGateDeps, fn: () => Promise<T>): Promise<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sleep2agi/agent-network",
3
- "version": "2.3.0-preview.155",
3
+ "version": "2.3.0-preview.157",
4
4
  "description": "AI Agent Network CLI — Local-first multi-agent orchestration across 6 runtimes (Claude Code CLI / Claude Agent SDK / Codex SDK / Codex app-server / Grok Build ACP / OpenCode CLI) and 8+ LLM providers. Apache 2.0.",
5
5
  "type": "module",
6
6
  "main": "dist/src/client.js",
@@ -72,12 +72,14 @@
72
72
  "@inquirer/prompts": "^8.4.3",
73
73
  "@larksuiteoapi/node-sdk": "^1.42.0",
74
74
  "markdown-it": "^14.1.0",
75
- "puppeteer-core": "^24.10.2"
75
+ "puppeteer-core": "^24.10.2",
76
+ "ws": "^8.22.0"
76
77
  },
77
78
  "devDependencies": {
78
79
  "@modelcontextprotocol/sdk": "1.32.0",
79
80
  "@types/markdown-it": "^14.1.2",
80
81
  "@types/node": "^25.0.0",
82
+ "@types/ws": "^8.18.2",
81
83
  "javascript-obfuscator": "^5.4.1",
82
84
  "node-pty": "^1.1.0",
83
85
  "typescript": "^5.0.0"