@nelsonlongxiang/dsh-open-a2a-net 0.6.31 → 0.6.32

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 (88) hide show
  1. package/README.md +4 -1
  2. package/README_zh.md +3 -0
  3. package/assets/nexusDist/assets/index-D5H8R8de.js +9 -0
  4. package/assets/nexusDist/assets/index-D9GYZyGZ.css +1 -0
  5. package/assets/nexusDist/index.html +2 -2
  6. package/cli/a2a.mjs +445 -57
  7. package/lib/a2a-client.js +9 -4
  8. package/lib/auth-observer.js +254 -0
  9. package/lib/blob-store.js +210 -0
  10. package/lib/card.js +4 -2
  11. package/lib/cli-deposit.js +122 -7
  12. package/lib/client.js +64 -64
  13. package/lib/client.js.map +1 -1
  14. package/lib/faces/admin.js +133 -43
  15. package/lib/faces/canvas-notify.js +12 -3
  16. package/lib/faces/files.js +155 -0
  17. package/lib/faces/nodes.js +171 -0
  18. package/lib/faces/session-log.js +162 -0
  19. package/lib/faces/wire.js +206 -39
  20. package/lib/index.js +809 -1720
  21. package/lib/joined-store.js +23 -0
  22. package/lib/ledger-conservation.js +97 -0
  23. package/lib/legacy/teams-bridge-inbound.js +156 -0
  24. package/lib/node-bind.js +534 -0
  25. package/lib/node-github.js +72 -0
  26. package/lib/node-self.js +453 -0
  27. package/lib/node-store.js +484 -0
  28. package/lib/node-tasks.js +342 -0
  29. package/lib/origin-claim.js +246 -0
  30. package/lib/peer-directory.js +134 -0
  31. package/lib/receipt.js +26 -1
  32. package/lib/skill/SKILL.md +3 -1
  33. package/lib/skill/references/cli.md +82 -3
  34. package/lib/skill/references/collaboration.md +126 -74
  35. package/lib/skill/references/discovery.md +29 -0
  36. package/lib/skill/references/intake.md +107 -0
  37. package/lib/skill/references/router.md +96 -0
  38. package/lib/skill/references/setup.md +2 -1
  39. package/lib/task-auth.js +483 -0
  40. package/lib/task-ledger.js +324 -12
  41. package/lib/team-store.js +24 -1
  42. package/lib/tools/act.js +383 -0
  43. package/lib/tools/files.js +201 -0
  44. package/lib/tools/info.js +684 -0
  45. package/lib/types/a2a-client.d.ts +10 -4
  46. package/lib/types/auth-observer.d.ts +110 -0
  47. package/lib/types/blob-store.d.ts +83 -0
  48. package/lib/types/cli-deposit.d.ts +38 -0
  49. package/lib/types/faces/admin.d.ts +14 -2
  50. package/lib/types/faces/canvas-notify.d.ts +4 -1
  51. package/lib/types/faces/files.d.ts +53 -0
  52. package/lib/types/faces/nodes.d.ts +69 -0
  53. package/lib/types/faces/session-log.d.ts +44 -0
  54. package/lib/types/faces/wire.d.ts +50 -5
  55. package/lib/types/index.d.ts +27 -0
  56. package/lib/types/joined-store.d.ts +9 -0
  57. package/lib/types/ledger-conservation.d.ts +77 -0
  58. package/lib/types/legacy/teams-bridge-inbound.d.ts +94 -0
  59. package/lib/types/node-bind.d.ts +220 -0
  60. package/lib/types/node-github.d.ts +35 -0
  61. package/lib/types/node-self.d.ts +178 -0
  62. package/lib/types/node-store.d.ts +180 -0
  63. package/lib/types/node-tasks.d.ts +121 -0
  64. package/lib/types/origin-claim.d.ts +119 -0
  65. package/lib/types/peer-directory.d.ts +39 -0
  66. package/lib/types/receipt.d.ts +12 -0
  67. package/lib/types/task-auth.d.ts +271 -0
  68. package/lib/types/task-ledger.d.ts +143 -6
  69. package/lib/types/team-store.d.ts +9 -0
  70. package/lib/types/tools/act.d.ts +52 -0
  71. package/lib/types/tools/files.d.ts +38 -0
  72. package/lib/types/tools/info.d.ts +102 -0
  73. package/lib/types/types.d.ts +6 -0
  74. package/nexus-stage/src/canvas-ops.ts +1 -1
  75. package/nexus-stage/src/federation.ts +1 -0
  76. package/nexus-stage/src/main.ts +41 -18
  77. package/nexus-stage/src/planning-member-handles.ts +34 -0
  78. package/nexus-stage/src/planning-mirror.ts +47 -3
  79. package/nexus-stage/src/planning-reachability.ts +28 -0
  80. package/nexus-stage/src/planning-types.ts +1 -1
  81. package/nexus-stage/src/planning-view.ts +29 -26
  82. package/nexus-stage/src/planning.css +4 -0
  83. package/nexus-stage/src/wb-directory.ts +13 -0
  84. package/nexus-stage/src/workbench.css +3 -0
  85. package/nexus-stage/src/workbench.ts +5 -1
  86. package/package.json +1 -1
  87. package/assets/nexusDist/assets/index-Dz8N80tI.css +0 -1
  88. package/assets/nexusDist/assets/index-jm-cFAhB.js +0 -9
@@ -0,0 +1,102 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import type { Agent } from '@deepseek-ai/dsh-agent';
3
+ import type { Config } from '../index.ts';
4
+ import type { CardCacheEntry, InFlightRoute, RouteActivityEntry } from '../runtime.ts';
5
+ import type { A2aPeerCard } from '../types.ts';
6
+ import type { ZoneCardFetch } from '../zone.ts';
7
+ import type { A2aClient, CardFetchOutcome } from '../a2a-client.ts';
8
+ import type { CanvasStore } from '../canvas-store.ts';
9
+ import type { ExposureStore } from '../exposure-store.ts';
10
+ import type { IdempotencyStore } from '../idempotency-store.ts';
11
+ import type { JoinedSessions } from '../joined-store.ts';
12
+ import type { PeerStore } from '../peer-store.ts';
13
+ import type { TaskLedger } from '../task-ledger.ts';
14
+ import type { TeamMembershipStore } from '../team-store.ts';
15
+ /** One directory row shared with listDirectoryTeams (which stays in index.ts). */
16
+ export type DirectoryTeamRow = {
17
+ team: string;
18
+ session: string;
19
+ name: string;
20
+ description: string;
21
+ local?: boolean;
22
+ origin?: string;
23
+ workspace?: string;
24
+ via?: string;
25
+ legacy?: boolean; /** gh#106: the peer's last card fetch missed — this row is its kept card, not a live answer. */
26
+ unreachable?: boolean;
27
+ teams?: string[]; /** Internal S5 scope hint, stripped before the tool's public output. */
28
+ canvasMembers?: readonly string[];
29
+ };
30
+ /** Everything the information-plane tools capture from apply(). */
31
+ export interface InfoToolsDeps {
32
+ readonly ctx: Context;
33
+ readonly config: Config;
34
+ readonly logger: ReturnType<Context['logger']>;
35
+ readonly session: string;
36
+ readonly lanIp: string;
37
+ readonly ownCardUrl: string;
38
+ readonly peerStore: PeerStore;
39
+ readonly taskLedger: TaskLedger;
40
+ readonly joinedSessions: JoinedSessions;
41
+ readonly teamMemberships: TeamMembershipStore;
42
+ readonly canvasStore: CanvasStore;
43
+ readonly exposureStore: ExposureStore;
44
+ readonly idempotencyStore: IdempotencyStore;
45
+ readonly cardCache: Map<string, CardCacheEntry>;
46
+ readonly inFlightRoutes: Map<number, InFlightRoute>;
47
+ readonly recentActivity: RouteActivityEntry[];
48
+ readonly teamAuditRing: {
49
+ at: number;
50
+ action: 'join' | 'leave' | 'archive-prune' | 'agent-less';
51
+ team: string;
52
+ id: string;
53
+ ok: boolean;
54
+ reason?: string;
55
+ }[];
56
+ readonly reportRing: {
57
+ at: number;
58
+ level: 'info' | 'warning' | 'error';
59
+ message: string;
60
+ session: string;
61
+ task?: string;
62
+ }[];
63
+ readonly sessionNodes: Map<string, Agent>;
64
+ readonly ownerAllowlist: readonly string[];
65
+ readonly ownerTeamScopeInfo: boolean;
66
+ readonly id8: (id: string) => string;
67
+ readonly sessionTeamOf: (agent: Agent) => string;
68
+ readonly nodeMetadataOf: (agent: Agent) => {
69
+ name: string;
70
+ description: string;
71
+ workspace?: string;
72
+ };
73
+ readonly canvasTeamOf: (name: string) => string;
74
+ /** gh#152: the session's canvas teams read through the local lens — a handle-stored membership of this session counts. */
75
+ readonly canvasTeamsOfSession: (id: string) => string[];
76
+ /** Resolve a handle against the current local/seeded-peer collision snapshot. */
77
+ readonly localHandleResolver: () => (ref: string) => string | undefined;
78
+ readonly memoizedCardFetch: () => ZoneCardFetch;
79
+ readonly mapBounded: <T, R>(items: readonly T[], limit: number, task: (item: T) => Promise<R>) => Promise<R[]>;
80
+ readonly SWEEP_CONCURRENCY: number;
81
+ readonly a2aJoinGateRefusal: (exec: {
82
+ agent?: {
83
+ id: unknown;
84
+ };
85
+ } | undefined) => void;
86
+ readonly observeAuthorization: (cause: string) => void;
87
+ readonly settlePeerCard: (peer: string, outcome: CardFetchOutcome) => A2aPeerCard | undefined;
88
+ readonly client: A2aClient;
89
+ readonly listDirectoryTeams: (expand: boolean, includeCanvas?: boolean) => Promise<DirectoryTeamRow[]>;
90
+ }
91
+ /**
92
+ * Build the five registrars. Call createInfoTools after its deps exist, then
93
+ * invoke each registrar at the tool's original registration position — the
94
+ * registry order the model sees must not change.
95
+ */
96
+ export declare function createInfoTools(deps: InfoToolsDeps): {
97
+ registerWhoami: () => void;
98
+ registerTeams: () => void;
99
+ registerStatus: () => void;
100
+ registerTasks: () => void;
101
+ registerProbe: () => void;
102
+ };
@@ -129,6 +129,12 @@ export interface A2aRouteOk {
129
129
  * receipt-owed (`trackOwedTask` skips it).
130
130
  */
131
131
  readonly bridge?: 'native-teams';
132
+ /**
133
+ * gh#141: the peer refused the settlement the delivered message carried
134
+ * (its enforce verdict, `settlement: {status: 'refused'}` on the wire,
135
+ * #139) — the delivery landed, the debt it named stays owed there.
136
+ */
137
+ readonly settlementRefused?: true;
132
138
  }
133
139
  /** Canonical `a2a_route` failure value. */
134
140
  export interface A2aRouteError {
@@ -23,7 +23,7 @@ export type CanvasAction =
23
23
  | { type: 'create-team'; name: string; ids: readonly string[]; /** true when the model had no such team before this action; NOT server creation provenance and never authority to delete on failure. */ created?: boolean }
24
24
  | { type: 'add-member'; team: string; ids: readonly string[]; /** gh#41: set when the target frame is a REMOTE peer's team — the wire routes the op through the host fleet relay. */ fleetPeer?: string }
25
25
  | { type: 'remove-member'; team: string; ids: readonly string[]; /** gh#41: see add-member. */ fleetPeer?: string }
26
- | { type: 'remove-team'; name: string }
26
+ | { type: 'remove-team'; name: string; /** set when the frame is a REMOTE peer's team: the owner dissolves it, through the relay. */ fleetPeer?: string }
27
27
  /** `ops` comes from reorderOps() at emit time; the wire stays model-free. */
28
28
  | { type: 'reorder'; team: string; ops: ReadonlyArray<RosterOp> }
29
29
  /** Network-level join/leave (the session joins the A2A mesh) — distinct from canvas-team membership. */
@@ -70,6 +70,7 @@ export function peerHostOf(url: string): string {
70
70
  /** One remote team row as the directory reports it (state.remote). */
71
71
  export interface RemoteTeamRow {
72
72
  team: string
73
+ unreachable?: boolean
73
74
  name?: string
74
75
  via?: string
75
76
  workspace?: string
@@ -154,28 +154,34 @@ const canvasWire = createCanvasWire({
154
154
  onNotice: (kind, text) => planning.notice(kind, text),
155
155
  })
156
156
 
157
+ /** One relayed op on a REMOTE peer's team. THIS host signs the envelope
158
+ * and forwards; the peer's link gate authorizes the write. */
159
+ async function fleetOp(peer: string, op: 'add-member' | 'remove-member' | 'remove', name: string, id?: string): Promise<boolean> {
160
+ const r = await controlFetch('/__dsh_a2a/fleet-canvas-op', {
161
+ method: 'POST',
162
+ headers: { 'Content-Type': 'application/json' },
163
+ body: JSON.stringify({ peer, op, name, ...(id !== undefined ? { id } : {}) }),
164
+ cache: 'no-store',
165
+ }).catch(() => undefined)
166
+ const body = r !== undefined ? await r.json().catch(() => undefined) : undefined
167
+ if (body?.ok === true && op === 'remove' && body.removed === false) planning.notice('info', `属主那边已没有「${name}」,无需解散`)
168
+ if (body?.ok === true) return true
169
+ // Say WHY the peer refused (not linked, untrusted origin, unknown member…), not just that it did.
170
+ planning.notice('error', `跨主机团队操作失败:${String(body?.error ?? '对端无响应')}`)
171
+ return false
172
+ }
173
+
157
174
  function runCanvasAction(a: CanvasAction): Promise<boolean> {
158
- // gh#41: a remote-frame drop forks to the fleet relay — THIS host signs
159
- // the envelope and forwards; the peer's link gate authorizes the write.
175
+ // gh#41: a remote-frame drop forks to the fleet relay; so does dissolving
176
+ // a mirror frame (single owner + mirror: the owner's store is the truth).
160
177
  if ((a.type === 'add-member' || a.type === 'remove-member') && a.fleetPeer !== undefined) {
178
+ const peer = a.fleetPeer
161
179
  return (async () => {
162
- for (const id of a.ids) {
163
- const r = await controlFetch('/__dsh_a2a/fleet-canvas-op', {
164
- method: 'POST',
165
- headers: { 'Content-Type': 'application/json' },
166
- body: JSON.stringify({ peer: a.fleetPeer, op: a.type === 'add-member' ? 'add-member' : 'remove-member', name: a.team, id }),
167
- cache: 'no-store',
168
- }).catch(() => undefined)
169
- const body = r !== undefined ? await r.json().catch(() => undefined) : undefined
170
- if (body?.ok !== true) {
171
- // Say WHY the peer refused (not linked, untrusted origin, unknown member…), not just that it did.
172
- planning.notice('error', `跨主机团队操作失败:${String(body?.error ?? '对端无响应')}`)
173
- return false
174
- }
175
- }
180
+ for (const id of a.ids) if (!(await fleetOp(peer, a.type, a.team, id))) return false
176
181
  return true
177
182
  })()
178
183
  }
184
+ if (a.type === 'remove-team' && a.fleetPeer !== undefined) return fleetOp(a.fleetPeer, 'remove', a.name)
179
185
  switch (a.type) {
180
186
  case 'create-team': return canvasWire.createTeam(a.name, a.ids, a.created)
181
187
  case 'add-member': return canvasWire.addMembers(a.team, a.ids)
@@ -200,6 +206,9 @@ async function postNetworkJoin(action: 'join' | 'leave', id: string): Promise<bo
200
206
  }
201
207
 
202
208
  let lampState: LampState = 'idle'
209
+ // The nodes face reports effective scoped assemblies; a mounted registration alone does not prove visibility.
210
+ let nodePromptMissing = new Set<string>()
211
+ let nodePromptCheckedAt = 0
203
212
  let canvasFace = false
204
213
  let lastLayoutJson: string | undefined
205
214
  /** True once any layout answer (saved doc or an explicit null) has been
@@ -375,13 +384,25 @@ async function poll(): Promise<void> {
375
384
  const res = await controlFetch('/__dsh_a2a/state', { cache: 'no-store' })
376
385
  if (!res.ok) throw new Error(`/__dsh_a2a/state ${res.status}`)
377
386
  const body = (await res.json()) as StateBody
387
+ if (Date.now() - nodePromptCheckedAt >= 15_000) {
388
+ nodePromptCheckedAt = Date.now()
389
+ try {
390
+ const nodes = await controlFetch('/__dsh_a2a/nodes', { cache: 'no-store' })
391
+ if (!nodes.ok) throw new Error(`nodes ${nodes.status}`)
392
+ const view = await nodes.json() as { bindings?: Array<{ session: string; mounted: unknown; effective: { core: boolean; mutable: boolean } | null }> }
393
+ nodePromptMissing = new Set((view.bindings ?? [])
394
+ .filter(b => b.mounted !== null && b.effective !== null && (b.effective.core === false || b.effective.mutable === false))
395
+ .map(b => b.session))
396
+ } catch { nodePromptMissing.clear() } // unavailable is unknown, not confirmed missing
397
+ }
398
+ const shown = { ...body, sessions: (body.sessions ?? []).map(s => ({ ...s, ...(nodePromptMissing.has(s.id) ? { nodePromptMissing: true } : {}) })) }
378
399
  clearFault()
379
400
  // canvasFace first: bench.update reads board.available() to pick the
380
401
  // mode, so assigning it afterwards held the very first paint in data
381
402
  // mode (board display:none, 0px wide) until the next 3s poll — and the
382
403
  // board's first reconcile measured a zero-width view.
383
404
  canvasFace = body.canvas !== undefined
384
- bench.update(body)
405
+ bench.update(shown)
385
406
 
386
407
  // ── The layout answer precedes the first reconcile on purpose ──
387
408
  // The board's first build reads `layoutDoc` for saved positions and
@@ -429,15 +450,17 @@ async function poll(): Promise<void> {
429
450
  name: r.name,
430
451
  via: r.via,
431
452
  workspace: r.workspace,
453
+ ...(r.unreachable === true ? { unreachable: true } : {}),
432
454
  ...(typeof r.origin === 'string' && r.origin !== '' ? { origin: r.origin } : {}),
433
455
  ...(Array.isArray(r.teams) && r.teams.length > 0 ? { teams: r.teams.filter((t): t is string => typeof t === 'string' && t !== '') } : {}),
434
456
  }))
435
457
  // gh#41: the peers' published canvas org rides the board (remote frames).
436
458
  const peerOrg = (body.peerOrg as unknown[] ?? [])
437
- .filter((r): r is { url?: unknown; org?: unknown } => r !== null && typeof r === 'object')
459
+ .filter((r): r is { url?: unknown; org?: unknown; unreachable?: unknown } => r !== null && typeof r === 'object')
438
460
  .filter(r => typeof r.url === 'string' && Array.isArray(r.org))
439
461
  .map(r => ({
440
462
  url: r.url as string,
463
+ ...(r.unreachable === true ? { unreachable: true } : {}),
441
464
  org: (r.org as unknown[])
442
465
  .filter((e): e is { name?: unknown; team?: unknown; members?: unknown } => e !== null && typeof e === 'object')
443
466
  .filter(e => typeof e.team === 'string' && e.team !== '')
@@ -0,0 +1,34 @@
1
+ /** Pure joined-local-handle projection for remote organization members. */
2
+ import type { RemoteTeamRow } from './federation'
3
+ import type { SessionLite } from './world'
4
+
5
+ type HandleSession = Pick<SessionLite, 'id' | 'team' | 'joined'>
6
+
7
+ /** Map only unique joined id8 handles that no remote directory row already owns. */
8
+ export function joinedLocalIdsByHandle(sessions: ReadonlyArray<HandleSession>, publishedHandles: ReadonlySet<string>): Map<string, string> {
9
+ const localIds = new Map<string, string>()
10
+ const ambiguous = new Set<string>()
11
+ for (const session of sessions) {
12
+ if (session.joined !== true) continue
13
+ const slash = session.team.lastIndexOf('/')
14
+ if (slash <= 0 || session.team.slice(slash + 1) !== session.id.replace(/^session-/, '').slice(0, 8)) continue
15
+ const handle = session.team
16
+ if (publishedHandles.has(handle) || ambiguous.has(handle)) continue
17
+ if (localIds.has(handle)) {
18
+ localIds.delete(handle)
19
+ ambiguous.add(handle)
20
+ } else {
21
+ localIds.set(handle, session.id)
22
+ }
23
+ }
24
+ return localIds
25
+ }
26
+
27
+ /** Project a remote canvas member to its local card or stable synthetic card id. */
28
+ export function remoteMemberBoardId(member: string, localIdsByHandle: ReadonlyMap<string, string>, remoteTeams: ReadonlyArray<RemoteTeamRow> | undefined, peerUrl: string): string {
29
+ const localId = localIdsByHandle.get(member)
30
+ if (localId !== undefined) return localId
31
+ if (member.includes('/')) return `member-${member.replace(/[^a-z0-9-]/gi, '-')}`
32
+ const peerZone = remoteTeams?.find(row => row.via === peerUrl)?.team.split('/')[0] ?? 'dsh'
33
+ return `member-${peerZone}-${member.replace(/^session-/, '').slice(0, 8)}`
34
+ }
@@ -4,9 +4,9 @@
4
4
  * other host renders it as a MIRROR of that host's published card and edits
5
5
  * it through the fleet relay. The frame head says so: 「镜像 · <owner host>」,
6
6
  * and 「同步中…」 from the moment a relayed edit is sent until the owner
7
- * answers (the relay refreshes the owner's card before replying, so the next
8
- * poll already shows the result). Local frames carry no marker — this host
9
- * is their owner.
7
+ * answers (the relay then re-reads the owner's card in the background, and
8
+ * the owner's own change ping backs it up). Local frames carry no marker —
9
+ * this host is their owner.
10
10
  * @module nexus-stage/planning-mirror
11
11
  */
12
12
  import { peerHostOf } from './federation'
@@ -29,3 +29,47 @@ export function mirrorRoute(ownerUrl: string | undefined, syncing: boolean): Mir
29
29
  syncing,
30
30
  }
31
31
  }
32
+
33
+ type MirrorOrg = ReadonlyArray<{ readonly url: string; readonly org: ReadonlyArray<{ readonly name: string }> }>
34
+
35
+ /** After the owner accepted a dissolve, hide its team at most this long: a
36
+ * peer's late add-member re-creates the team on the owner, and then it is
37
+ * real again even though the owner's org never stopped listing it. */
38
+ export const DISSOLVE_HIDE_MS = 10_000
39
+
40
+ /**
41
+ * 解散 on a mirror frame: the frame stays gone from the moment the dissolve
42
+ * is sent until the owner's published org stops listing the team (or
43
+ * DISSOLVE_HIDE_MS after the owner accepted). Without this, a poll that lands
44
+ * while the relay is in flight — or before the owner's card is re-read —
45
+ * draws the frame again (and keeps its saved rect for a later team of the
46
+ * same name). Keyed by owner AND name: two owners may both have a team X.
47
+ */
48
+ export function createDissolveGuard(now: () => number = Date.now) {
49
+ const key = (ownerUrl: string, name: string): string => `${ownerUrl}\u0000${name}`
50
+ const dissolving = new Map<string, { url: string; name: string; acceptedAt?: number }>()
51
+ return {
52
+ /** Mark the dissolve and return the action carrying its owner (the relay fork). */
53
+ fork<A extends { type: 'remove-team'; name: string }>(act: A, ownerUrl: string): A & { fleetPeer: string } {
54
+ dissolving.set(key(ownerUrl, act.name), { url: ownerUrl, name: act.name })
55
+ return { ...act, fleetPeer: ownerUrl }
56
+ },
57
+ /** The owner answered: a refusal (or a failed channel) lets the frame back now, an acceptance starts the clock. */
58
+ settled(act: { type: string; name?: string; fleetPeer?: string }, ok: boolean): void {
59
+ if (act.type !== 'remove-team' || act.name === undefined || act.fleetPeer === undefined) return
60
+ const entry = dissolving.get(key(act.fleetPeer, act.name))
61
+ if (entry === undefined) return
62
+ if (ok) entry.acceptedAt = now()
63
+ else dissolving.delete(key(act.fleetPeer, act.name))
64
+ },
65
+ /** True while this owner's team is being (or has just been) dissolved here. */
66
+ hides(name: string, ownerUrl: string): boolean { return dissolving.has(key(ownerUrl, name)) },
67
+ /** Forget a dissolve once its owner's org no longer lists the team, or once its time is up. */
68
+ sweep(peerOrg: MirrorOrg): void {
69
+ for (const [k, e] of dissolving) {
70
+ const listed = peerOrg.find(row => row.url === e.url)?.org.some(t => t.name === e.name) === true
71
+ if (!listed || (e.acceptedAt !== undefined && now() - e.acceptedAt > DISSOLVE_HIDE_MS)) dissolving.delete(k)
72
+ }
73
+ },
74
+ }
75
+ }
@@ -0,0 +1,28 @@
1
+ /** Project the peer's last missed card read onto existing remote cards and frames. */
2
+ import { peerHostOf, type RemoteTeamRow } from './federation'
3
+
4
+ export const UNREACHABLE_HINT = '对端未应答(显示的是最后已知状态)'
5
+
6
+ export function unreachableRefs(input: {
7
+ remoteTeams?: ReadonlyArray<RemoteTeamRow>
8
+ peerOrg?: ReadonlyArray<{ url: string; unreachable?: boolean }>
9
+ }): { hosts: ReadonlySet<string>; members: ReadonlySet<string> } {
10
+ const hosts = new Set<string>()
11
+ for (const row of input.remoteTeams ?? []) if (row.unreachable === true && row.via) hosts.add(peerHostOf(row.via))
12
+ for (const row of input.peerOrg ?? []) if (row.unreachable === true) hosts.add(peerHostOf(row.url))
13
+ const members = new Set<string>()
14
+ for (const row of input.remoteTeams ?? []) if (row.via && hosts.has(peerHostOf(row.via))) members.add(`member-${row.team.replace(/[^a-z0-9-]/gi, '-')}`)
15
+ return { hosts, members }
16
+ }
17
+
18
+ /** A mirror keeps its last known contents visible but warns until its owner responds again. */
19
+ export function showFrameReachability(frame: HTMLElement, lost: boolean): void {
20
+ frame.classList.toggle('is-unreachable', lost)
21
+ const existing = frame.querySelector('.p-frame-unreachable')
22
+ if (lost && existing === null) {
23
+ const hint = document.createElement('span')
24
+ hint.className = 'p-frame-unreachable'
25
+ hint.textContent = UNREACHABLE_HINT
26
+ frame.appendChild(hint)
27
+ } else if (!lost) existing?.remove()
28
+ }
@@ -26,7 +26,7 @@ export interface PlanningInput {
26
26
  remoteTeams?: ReadonlyArray<RemoteTeamRow>
27
27
  /** gh#41 fleet planning: each tracked peer's published canvas org —
28
28
  * rendered as REMOTE team frames (read + cross-host regulation). */
29
- peerOrg?: ReadonlyArray<{ url: string; org: ReadonlyArray<{ name: string; team: string; members: readonly string[] }> }>
29
+ peerOrg?: ReadonlyArray<{ url: string; unreachable?: boolean; org: ReadonlyArray<{ name: string; team: string; members: readonly string[] }> }>
30
30
  }
31
31
 
32
32
  /** Screen-width class a viewport is remembered under (window width, not board width — collapsing the rail must not switch buckets). */
@@ -30,6 +30,7 @@ import { buildLayoutDoc, clampDoc, type LayoutDoc, type LayoutRect } from './lay
30
30
  import { FRAME_HEAD_LIFT } from './edges'
31
31
  import { drawMemberEdges } from './planning-edges'
32
32
  import { createFederationOverlay } from './federation-overlay'
33
+ import { joinedLocalIdsByHandle, remoteMemberBoardId } from './planning-member-handles'
33
34
  import { displayName } from './stage-name'
34
35
  import {
35
36
  activityEdges, federalEdges, flyBounds, groupRemoteTeams, peerNodeId, peerHostOf, placePeers,
@@ -44,12 +45,13 @@ import { FRAME_HUES } from './tokens'
44
45
  import { createPlanningMenus } from './planning-menus'
45
46
  import { createNodeFlyer, mountBoardSearch } from './planning-search'
46
47
  import { applyBoardRelayout } from './planning-relayout'
47
- import { mirrorRoute } from './planning-mirror'
48
+ import { createDissolveGuard, mirrorRoute } from './planning-mirror'
48
49
  import { settleBoard, tidyMembers } from './planning-overlap'
49
50
  import { createLayoutUndo, type LayoutSnap } from './planning-undo'
50
51
  import { createNodeList } from './planning-nodelist'
51
52
  import { cardText } from './planning-card-text'
52
53
  import { createLegend } from './planning-legend'
54
+ import { UNREACHABLE_HINT, showFrameReachability, unreachableRefs } from './planning-reachability'
53
55
  import { viewportBucket, type PlanningDeps, type PlanningInput, type PlanningSession, type PlanningTeam, type PlanningView, type SeamKey, type SeamPointer, type ViewportBucket } from './planning-types'
54
56
  import './planning.css'
55
57
 
@@ -382,12 +384,14 @@ export function createPlanningView(deps: PlanningDeps): PlanningView {
382
384
  const cntText = `${members} 成员` + (cross > 0 ? ` +${cross} 跨队` : '')
383
385
  if (cnt.textContent !== cntText) cnt.textContent = cntText
384
386
  const mirror = mirrorRoute(remoteFramesRef.get(name), pendingTeams.has(name)) // PR#96 single owner + mirror
387
+ const unavailable = mirror !== undefined && reachability.hosts.has(peerHostOf(remoteFramesRef.get(name)!))
385
388
  const routeText0 = mirror?.text ?? routeText(name)
386
389
  if (route.textContent !== routeText0) route.textContent = routeText0
387
- route.title = mirror?.title ?? ''
390
+ route.title = `${mirror?.title ?? ''}${unavailable ? ` · ${UNREACHABLE_HINT}` : ''}`
391
+ showFrameReachability(el, unavailable)
388
392
  el.classList.toggle('is-mirror', mirror !== undefined)
389
393
  el.classList.toggle('is-syncing', mirror?.syncing === true)
390
- const label = `团队框 ${name}${mirror !== undefined ? `(${mirror.text})` : ''}(拖动整组,回车菜单)`
394
+ const label = `团队框 ${name}${mirror !== undefined ? `(${mirror.text})` : ''}${unavailable ? `(${UNREACHABLE_HINT})` : ''}(拖动整组,回车菜单)`
391
395
  const headEl = el.querySelector('.p-frame-head')!
392
396
  if (headEl.getAttribute('aria-label') !== label) headEl.setAttribute('aria-label', label) // a rewrite re-announces
393
397
  }
@@ -438,11 +442,15 @@ export function createPlanningView(deps: PlanningDeps): PlanningView {
438
442
  const host = n.id.slice('peer-'.length)
439
443
  // Title / second line / tooltip rules: planning-card-text.
440
444
  const txt = cardText(n, n.remote === true ? lastRemoteTeams.get(host) ?? [] : [], peerScoreByText.get(host))
445
+ const unavailable = n.remote === true && (n.id.startsWith('member-') ? reachability.members.has(n.id) : reachability.hosts.has(host))
446
+ el.classList.toggle('is-unreachable', unavailable)
441
447
  const nmEl = el.querySelector<HTMLElement>('.nm-text')!
442
448
  if (nmEl.textContent !== txt.title) nmEl.textContent = txt.title
443
449
  const subEl = el.querySelector<HTMLElement>('.sub')!
444
- if (subEl.textContent !== txt.sub) subEl.textContent = txt.sub
445
- if (el.title !== txt.tip) el.title = txt.tip
450
+ const subText = unavailable ? `未应答 · ${txt.sub}` : txt.sub
451
+ if (subEl.textContent !== subText) subEl.textContent = subText
452
+ const tip = unavailable ? `${txt.tip} · ${UNREACHABLE_HINT}` : txt.tip
453
+ if (el.title !== tip) el.title = tip
446
454
  const prioEl = el.querySelector<HTMLElement>('.prio')!
447
455
  if (n.remote === true) {
448
456
  // gh#20 W-A: the peer badge — link class colors the chip (linked
@@ -526,6 +534,8 @@ export function createPlanningView(deps: PlanningDeps): PlanningView {
526
534
  // gh#41: remote-frame registry (frame name → peer URL), refreshed by
527
535
  // reconcile and read by emitAction's serverAction to fork remote drops.
528
536
  let remoteFramesRef = new Map<string, string>()
537
+ let reachability = unreachableRefs({})
538
+ const dissolving = createDissolveGuard(deps.now)
529
539
 
530
540
  function emitAction(a: CanvasAction): void {
531
541
  // gh#20 W-B: the SERVER sees zone/id8 remote handles where the model
@@ -555,7 +565,8 @@ export function createPlanningView(deps: PlanningDeps): PlanningView {
555
565
  ? { ...act, ids, ...(fleetPeer !== undefined ? { fleetPeer } : {}) }
556
566
  : act
557
567
  }
558
- return act
568
+ // Dissolving a mirror frame is the owner's write as well (relay op 'remove').
569
+ return act.type === 'remove-team' && remoteFramesRef.has(act.name) ? dissolving.fork(act, remoteFramesRef.get(act.name)!) : act
559
570
  }
560
571
 
561
572
  // Optimistic seats: a write may reference a session the teamed gate
@@ -583,10 +594,11 @@ export function createPlanningView(deps: PlanningDeps): PlanningView {
583
594
  const team = actionTeam(a)
584
595
  pendingAdd(team)
585
596
  render()
586
- void deps.onCanvasAction(serverAction(a)).then(
597
+ const sent = serverAction(a)
598
+ void deps.onCanvasAction(sent).then(
587
599
  ok => {
588
600
  pendingRelease(team)
589
- layoutDoc = settleAction(model, a, ok, undo, layoutDoc); markDirty()
601
+ layoutDoc = settleAction(model, a, ok, undo, layoutDoc); markDirty(); dissolving.settled(sent, ok)
590
602
  render()
591
603
  },
592
604
  () => {
@@ -594,7 +606,7 @@ export function createPlanningView(deps: PlanningDeps): PlanningView {
594
606
  // team's guard (and its optimistic state) forever — and per §3.4
595
607
  // 不吞错, the rollback surfaces to the user.
596
608
  pendingRelease(team)
597
- layoutDoc = settleAction(model, a, false, undo, layoutDoc); markDirty()
609
+ layoutDoc = settleAction(model, a, false, undo, layoutDoc); markDirty(); dissolving.settled(sent, false)
598
610
  notice('error', '操作通道异常,已回滚')
599
611
  render()
600
612
  },
@@ -1207,6 +1219,7 @@ export function createPlanningView(deps: PlanningDeps): PlanningView {
1207
1219
  // excluded from bounds, so the column cannot feed back into itself).
1208
1220
  const peerSeen = new Set<string>()
1209
1221
  lastRemoteTeams = groupRemoteTeams(input.remoteTeams ?? [])
1222
+ reachability = unreachableRefs(input)
1210
1223
  peerScoreByText.clear()
1211
1224
  for (const p of input.peers ?? []) {
1212
1225
  peerScoreByText.set(peerHostOf(p.url), p.score)
@@ -1247,6 +1260,7 @@ export function createPlanningView(deps: PlanningDeps): PlanningView {
1247
1260
  // peer card — pulling a specific remote member into a local team is a
1248
1261
  // plain drag (no picker, no hand-typed handle). Host cards stay for
1249
1262
  // federation context; the member cards carry the actual join gesture.
1263
+
1250
1264
  const memberSeen = new Set<string>()
1251
1265
  for (const [host, rows] of lastRemoteTeams) {
1252
1266
  const hostNode = model.allNodes().find(n => n.remote === true && peerHostOf(n.peerUrl ?? '') === host && !n.id.startsWith('member-'))
@@ -1306,25 +1320,14 @@ export function createPlanningView(deps: PlanningDeps): PlanningView {
1306
1320
  if (input.peerOrg !== undefined) {
1307
1321
  let slot = 0
1308
1322
  const localNames = new Set(input.teams.map(t => t.name))
1323
+ dissolving.sweep(input.peerOrg)
1309
1324
  for (const row of input.peerOrg) {
1310
- // The peer's zone comes from its directory rows ('dsh/xxxx' →
1311
- // 'dsh'); the org's members are stored verbatim — LOCAL members as
1312
- // session ids, remote members as zone/id8 handles. Both must
1313
- // resolve onto that host's session cards: id-form members become
1314
- // `member-<zone>-<id8>` (id8 = strip 'session-' prefix, first 8
1315
- // chars — the repo's id8 derivation), handle members sanitize
1316
- // directly. The old sanitize-only pass misresolved every local
1317
- // member (owner: 数据对不上).
1318
- const peerZone = input.remoteTeams?.find(r => r.via === row.url)?.team.split('/')[0] ?? 'dsh'
1319
- const id8of = (id: string): string => id.replace(/^session-/, '').slice(0, 8)
1320
- // The server now canonicalizes org members to handles (gh#41 wire
1321
- // form); the id-form branch stays as the defensive path for peers
1322
- // on an older build that still publish raw session ids.
1323
- const memberBoardId = (m: string): string =>
1324
- m.includes('/') ? `member-${m.replace(/[^a-z0-9-]/gi, '-')}` : `member-${peerZone}-${id8of(m)}`
1325
+ // Resolve joined local handles and id-form legacy members through the pure projection helper.
1326
+ const publishedHandles = new Set((input.remoteTeams ?? []).map(session => session.team))
1327
+ const localIdsByHandle = joinedLocalIdsByHandle(input.sessions, publishedHandles)
1325
1328
  for (const team of row.org) {
1326
- if (team.name === '' || localNames.has(team.name)) continue
1327
- const memberIds = team.members.map(memberBoardId).filter(id => model.getNode(id) !== undefined)
1329
+ if (team.name === '' || localNames.has(team.name) || dissolving.hides(team.name, row.url)) continue
1330
+ const memberIds = team.members.map(member => remoteMemberBoardId(member, localIdsByHandle, input.remoteTeams, row.url)).filter(id => model.getNode(id) !== undefined)
1328
1331
  const saved = layoutDoc?.frames?.[team.name]
1329
1332
  // gh#44 (owner: frame position/size never sticks): the LOCAL-team
1330
1333
  // path keeps an existing frame's live rect ("live rect wins" — a
@@ -84,6 +84,10 @@
84
84
  #dsh-plan .p-frame-head .route{font-size:10.5px; color:var(--ink-muted)}
85
85
  #dsh-plan .p-frame.is-mirror{border-style:dashed}
86
86
  #dsh-plan .p-frame.is-syncing .p-frame-head .route{color:var(--accent)}
87
+ #dsh-plan .p-frame.is-unreachable{opacity:.76;border-style:dashed}
88
+ #dsh-plan .p-frame-unreachable{position:absolute;left:8px;top:20px;max-width:calc(100% - 16px);color:var(--uupm-error);font-size:11px;pointer-events:none}
89
+ #dsh-plan .p-node.remote.is-unreachable{opacity:.72;border-left-color:var(--uupm-error)}
90
+ #dsh-plan .p-node.remote.is-unreachable .sub{color:var(--uupm-error)}
87
91
 
88
92
  /* ── node card (fixed 56px border-box height = world.NODE_H) ── */
89
93
  #dsh-plan .p-node{position:absolute; width:172px; height:56px; padding:8px 26px 8px 14px;
@@ -130,8 +130,15 @@ export function renderDirectory(box: HTMLElement, ctx: DirectoryContext): string
130
130
  const g = group('本机会话', sessions.length, cold.length > 0 ? `${live.length} 在线 · ${cold.length} 冷` : undefined)
131
131
  for (const s of [...live, ...cold]) {
132
132
  const isLive = s.live === true
133
+ const missing = s.nodePromptMissing === true
133
134
  const item = row(g, isLive ? 'wb-dot-live' : 'wb-dot-cold', isLive ? '●' : '○', displayName(s), isLive ? s.team : `冷 · ${s.team}`,
134
135
  () => ctx.openChat({ kind: 'session', id: s.id, title: displayName(s), sub: s.team, team: s.team, live: s.live }), s.id)
136
+ if (missing) {
137
+ item.classList.add('is-node-prompt-missing')
138
+ const note = el('span', 'wb-node-warning')
139
+ note.textContent = '本会话的组装不含节点段'
140
+ item.querySelector('.wb-item-text')?.appendChild(note)
141
+ }
135
142
  badges(item, s.canvasTeams)
136
143
  }
137
144
  }
@@ -153,6 +160,12 @@ export function renderDirectory(box: HTMLElement, ctx: DirectoryContext): string
153
160
  for (const r of remote) {
154
161
  const item = row(g, 'wb-dot-remote', '◇', displayName(r), r.origin !== undefined && r.origin !== '' ? r.origin : r.team,
155
162
  () => ctx.openChat({ kind: 'remote', team: r.team, title: displayName(r), sub: r.team, row: r }), r.team)
163
+ if (r.unreachable === true) {
164
+ item.classList.add('is-unreachable')
165
+ const note = el('span', 'wb-unreachable-note')
166
+ note.textContent = '对端未应答(显示的是最后已知状态)'
167
+ item.querySelector('.wb-item-text')?.appendChild(note)
168
+ }
156
169
  badges(item, r.canvasTeams)
157
170
  }
158
171
  }
@@ -321,6 +321,9 @@ body{background:var(--n-bg);color:var(--n-ink);font:13px/1.45 system-ui,"Segoe U
321
321
  .wb-item-sub{font:11px/1.35 ui-monospace,Consolas,monospace;color:var(--n-ink-muted);
322
322
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
323
323
  .wb-item.is-untitled .wb-item-label{color:var(--n-ink-muted);font-family:ui-monospace,Consolas,monospace;font-size:12px}
324
+ .wb-directory .wb-item.is-unreachable{opacity:.78}
325
+ .wb-unreachable-note{font-size:11px;line-height:1.35;color:var(--n-danger);white-space:normal;overflow-wrap:anywhere}
326
+ .wb-node-warning{font-size:11px;line-height:1.35;color:var(--n-danger);white-space:normal;overflow-wrap:anywhere}
324
327
  .wb-dot-log{color:var(--n-ink-muted)}
325
328
 
326
329
  /* ── 台账 (wb-ledger) ── */
@@ -84,6 +84,7 @@ export interface ArchivedRow {
84
84
  * canvasOrg) — the board renders REMOTE team frames from these rows. */
85
85
  export interface PeerOrgRow {
86
86
  readonly url: string
87
+ readonly unreachable?: boolean
87
88
  readonly org: ReadonlyArray<{ name: string; team: string; members: readonly string[] }>
88
89
  }
89
90
 
@@ -97,6 +98,8 @@ export interface SessionRow {
97
98
  readonly workspace?: string
98
99
  readonly joined?: boolean
99
100
  readonly live?: boolean
101
+ /** Final scoped assembly lacks at least one registered node section (#174). */
102
+ readonly nodePromptMissing?: boolean
100
103
  readonly teams?: readonly string[]
101
104
  /** Canvas teams this session is a member of (0.6.6 roster annotation). */
102
105
  readonly canvasTeams?: readonly string[]
@@ -107,6 +110,7 @@ export interface SessionRow {
107
110
  /** One remote team row from /state `remote`. */
108
111
  export interface RemoteRow {
109
112
  readonly team: string
113
+ readonly unreachable?: boolean
110
114
  readonly name?: string
111
115
  readonly origin?: string
112
116
  readonly via?: string
@@ -201,7 +205,7 @@ export interface WorkbenchDeps {
201
205
  ownerSettingsWrite?(changes: { teamJoinAllowlist?: string[]; teamScopeInfo?: boolean; announce?: boolean }): Promise<{ ok: boolean; restartNeeded?: boolean; error?: string }>
202
206
  /** gh#41 fleet planning: regulate a REMOTE peer's canvas team (this host
203
207
  * signs the envelope and forwards; the peer's link gate authorizes). */
204
- fleetCanvasOp?(peer: string, op: 'create' | 'add-member' | 'remove-member', name: string, id?: string): Promise<{ ok: boolean; members?: string[]; error?: string }>
208
+ fleetCanvasOp?(peer: string, op: 'create' | 'add-member' | 'remove-member' | 'remove', name: string, id?: string): Promise<{ ok: boolean; members?: string[]; error?: string }>
205
209
  /** Abandon one dead-lettered task via the control route. True on success. */
206
210
  abandon(taskId: string, reason: string): Promise<boolean>
207
211
  /** Canvas team member change via the control route (0.6.6): `id` is a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nelsonlongxiang/dsh-open-a2a-net",
3
- "version": "0.6.31",
3
+ "version": "0.6.32",
4
4
  "description": "Open A2A network plugin for DeepSeek Harness: signed agent cards, decentralized peer/zone discovery, direct routing model tools, and joinable session nodes with a sidebar control",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",