@sleep2agi/agent-network 2.3.0-preview.67 → 2.3.0-preview.69

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.67";
2
- export declare const PAIRED_AGENT_NODE_VERSION = "2.5.0-preview.52";
3
- export declare const PAIRED_AGENT_NODE_SPEC = "@sleep2agi/agent-node@2.5.0-preview.52";
4
- export declare const OPENCODE_AGENT_NETWORK_VERSION = "2.3.0-preview.67";
5
- export declare const OPENCODE_AGENT_NODE_VERSION = "2.5.0-preview.52";
6
- export declare const OPENCODE_AGENT_NODE_SPEC = "@sleep2agi/agent-node@2.5.0-preview.52";
1
+ export declare const PAIRED_AGENT_NETWORK_VERSION = "2.3.0-preview.69";
2
+ export declare const PAIRED_AGENT_NODE_VERSION = "2.5.0-preview.54";
3
+ export declare const PAIRED_AGENT_NODE_SPEC = "@sleep2agi/agent-node@2.5.0-preview.54";
4
+ export declare const OPENCODE_AGENT_NETWORK_VERSION = "2.3.0-preview.69";
5
+ export declare const OPENCODE_AGENT_NODE_VERSION = "2.5.0-preview.54";
6
+ export declare const OPENCODE_AGENT_NODE_SPEC = "@sleep2agi/agent-node@2.5.0-preview.54";
7
7
  export type PairedAgentNodeResolution = {
8
8
  spec: string;
9
9
  args: string[];
@@ -0,0 +1,118 @@
1
+ export interface StaleSocketProbes {
2
+ /** 读 /proc/net/unix 全文;读不到就 throw(调用方按 fail-closed 处理)。 */
3
+ procNetUnix(): string;
4
+ /** 路径不存在返回 null。 */
5
+ lstat(path: string): {
6
+ dev: number;
7
+ ino: number;
8
+ uid: number;
9
+ isSocket: boolean;
10
+ } | null;
11
+ unlink(path: string): void;
12
+ /** 当前进程 uid —— 只回收自己拥有的 socket。 */
13
+ currentUid(): number;
14
+ }
15
+ export interface ReapScope {
16
+ /**
17
+ * 只允许回收这个目录**之下**的路径。
18
+ * 🔴 这一格防的不是文件系统竞态,是**被污染的 identity**:socket 路径来自
19
+ * profile,如果 profile 被写坏成 `/run/systemd/private` 之类,前面所有
20
+ * "无监听者"检查都会照常通过,然后 unlink 掉一个不属于这个节点的东西。
21
+ * 删除不可逆,所以范围校验必须在**所有**其它检查之前。
22
+ */
23
+ allowedRoot: string;
24
+ }
25
+ export type ReapOutcome =
26
+ /** 路径已经不在了 —— 正常的成功拆卸,无事可做。 */
27
+ {
28
+ kind: "absent";
29
+ }
30
+ /** 确认无人引用,已删除。 */
31
+ | {
32
+ kind: "removed";
33
+ }
34
+ /** /proc/net/unix 里仍能找到这个路径 ⇒ 有人在用,**不删**,调用方应判红。 */
35
+ | {
36
+ kind: "in-use";
37
+ }
38
+ /** /proc/net/unix 读不到 ⇒ fail-closed,不删。 */
39
+ | {
40
+ kind: "unreadable";
41
+ detail: string;
42
+ }
43
+ /** 检查与删除之间文件身份变了(dev/ino/uid),或已不是 socket ⇒ 不删。 */
44
+ | {
45
+ kind: "changed";
46
+ }
47
+ /** 路径不在该节点自己的 runtime 目录之下 ⇒ 一律不删。 */
48
+ | {
49
+ kind: "out-of-scope";
50
+ detail: string;
51
+ };
52
+ /**
53
+ * `/proc/net/unix` 的每一行以路径结尾(没有绑定路径的行就没有这一列)。
54
+ * 这里只问「这个路径出现过没有」,不解释 flags/type/state。
55
+ */
56
+ export declare function unixSocketPathInUse(procNetUnix: string, path: string): boolean;
57
+ /**
58
+ * 属主进程**已被证明消失之后**,回收一个陈旧的 socket 路径名。
59
+ * 任何一种不确定都不删 —— 删文件不可逆,而留下一个 socket 只是让 stop 判红,
60
+ * 那正是本函数之前的行为。
61
+ */
62
+ export declare function reapStaleSocket(path: string, probes: StaleSocketProbes, scope: ReapScope): ReapOutcome;
63
+ /**
64
+ * 从「本次 stop 看到的残留路径」里挑出**允许回收**的那些。
65
+ *
66
+ * 🔴 判据是「与重新算出来的规范路径**完全相等**」,不是前缀、不是包含。
67
+ * profile 里存的 socket 路径是**被写坏就会跟着坏**的数据;
68
+ * grokCopresenceSocketPaths 是纯函数,同样的 nodeId + home 永远算出同一个值。
69
+ * 所以这里不问「这条路径看起来对不对」,只问「它是不是我自己算出来的那两个之一」。
70
+ * ——一个被污染的 profile 因此一条都带不进来。
71
+ */
72
+ export declare function planReapableSockets(canonical: {
73
+ leaderSocket: string;
74
+ attachSocket: string;
75
+ }, residualPaths: readonly (string | undefined)[]): string[];
76
+ export interface CanonicalSocketProfile {
77
+ node_id?: string;
78
+ grokLeaderSocket?: string;
79
+ grokAttachSocket?: string;
80
+ }
81
+ export type CanonicalSocketsOutcome = {
82
+ kind: "ok";
83
+ leaderSocket: string;
84
+ attachSocket: string;
85
+ }
86
+ /** profile 里没有 node_id —— 算不出来,不动手。 */
87
+ | {
88
+ kind: "no-node-id";
89
+ }
90
+ /** 重新算出来的与 profile 存的不一致 —— profile 被写坏、HOME 变了、或**调用方喂错了 id**。 */
91
+ | {
92
+ kind: "mismatch";
93
+ recomputedLeader: string;
94
+ storedLeader: string;
95
+ }
96
+ /** 路径算不出来(grokCopresenceSocketPaths 抛错)—— 不动手,但也不该把 stop 整个弄失败。 */
97
+ | {
98
+ kind: "uncomputable";
99
+ detail: string;
100
+ };
101
+ /**
102
+ * 从 profile 推出规范 socket 路径,并**与 profile 里存的那份交叉校验**。
103
+ *
104
+ * 🔴 这个交叉校验是一次真实缺陷催生的,不是补全性写的:
105
+ * 我第一版在 cli.ts 里写的是 `grokCopresenceSocketPaths(resolved.id)`,而
106
+ * `resolveNodeRef` 返回的 `id` 是**目录名(别名)**,socket 路径却是
107
+ * `anet node create` 用 **node_id** 算的。两者哈希不同 ⇒ 算出的路径永远对不上 ⇒
108
+ * 可回收集合恒为空 ⇒ **一条都回收不了,而且完全静默**(循环体一次都不进)。
109
+ * 12 轮验收里 4 次红、0 次回收,红话与修复前逐字相同 —— 从外面看,
110
+ * 「守卫拒绝了一切」和「这个修复不存在」是同一个样子。
111
+ *
112
+ * 所以判据不能只是「算一个路径出来」,必须是「算出来的和存着的对得上」。
113
+ * 对不上就说出来,别静默跳过。
114
+ */
115
+ export declare function canonicalSocketsForProfile(profile: CanonicalSocketProfile, compute: (nodeId: string) => {
116
+ leaderSocket: string;
117
+ attachSocket: string;
118
+ }): CanonicalSocketsOutcome;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sleep2agi/agent-network",
3
- "version": "2.3.0-preview.67",
3
+ "version": "2.3.0-preview.69",
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",