@nelsonlongxiang/dsh-open-a2a-net 0.6.38 → 0.6.40

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 (48) hide show
  1. package/README.md +342 -335
  2. package/README_zh.md +243 -236
  3. package/assets/nexusDist/assets/index-C7HagaGy.css +1 -1
  4. package/assets/nexusDist/assets/index-NkNSeIx6.js +9 -9
  5. package/cli/a2a.mjs +20 -5
  6. package/cli/serve.mjs +132 -0
  7. package/cordis.patch.yml +21 -21
  8. package/lib/a2a-client.js +1 -0
  9. package/lib/canvas-id.js +27 -0
  10. package/lib/canvas-store.js +7 -1
  11. package/lib/cli-deposit.js +2 -2
  12. package/lib/client.js +63 -63
  13. package/lib/config.js +125 -0
  14. package/lib/direct-forward.js +64 -18
  15. package/lib/faces/admin.js +4 -1
  16. package/lib/faces/wire.js +77 -7
  17. package/lib/flood-guard.js +3 -1
  18. package/lib/index.js +84 -172
  19. package/lib/lan-ip.js +20 -0
  20. package/lib/live-roots.js +39 -0
  21. package/lib/origin-claim.js +3 -2
  22. package/lib/peer-link-display.js +3 -2
  23. package/lib/queue-guard.js +3 -1
  24. package/lib/skill/references/cli.md +215 -203
  25. package/lib/skill/references/routing.md +4 -0
  26. package/lib/skill/references/setup.md +156 -153
  27. package/lib/task-auth.js +14 -10
  28. package/lib/types/canvas-id.d.ts +9 -0
  29. package/lib/types/cli-deposit.d.ts +6 -1
  30. package/lib/types/config.d.ts +278 -0
  31. package/lib/types/direct-forward.d.ts +25 -3
  32. package/lib/types/faces/admin.d.ts +2 -0
  33. package/lib/types/faces/wire.d.ts +26 -0
  34. package/lib/types/index.d.ts +3 -277
  35. package/lib/types/lan-ip.d.ts +7 -0
  36. package/lib/types/live-roots.d.ts +35 -0
  37. package/lib/types/origin-claim.d.ts +1 -0
  38. package/lib/types/peer-link-display.d.ts +2 -0
  39. package/lib/types/queue-guard.d.ts +2 -0
  40. package/lib/types/task-auth.d.ts +3 -0
  41. package/lib/types/types.d.ts +7 -0
  42. package/nexus-stage/package-lock.json +2262 -2262
  43. package/nexus-stage/src/edges.ts +72 -72
  44. package/nexus-stage/src/layout-wire.ts +158 -158
  45. package/nexus-stage/src/seat.ts +35 -35
  46. package/nexus-stage/src/stage-name.ts +13 -13
  47. package/nexus-stage/src/tokens.ts +31 -31
  48. package/package.json +219 -218
@@ -0,0 +1,278 @@
1
+ /** The plugin row's configuration: the `Config` interface and its Schemastery schema (moved out of index.ts, #77). */
2
+ import s from '@deepseek-ai/schemastery';
3
+ import type { SettlementMode } from './task-auth.ts';
4
+ /** One signed zone delegation published on this node's agent card. */
5
+ export interface DelegateConfig {
6
+ /** The delegated name; resolves zone-relatively at route time. */
7
+ readonly name: string;
8
+ /** Base URL of the zone the name resolves in. */
9
+ readonly url: string;
10
+ /** Base64 SPKI DER binding to the target zone's card key; `''` leaves the delegation unbound. */
11
+ readonly publicKey: string;
12
+ }
13
+ /** Deployment-varying A2A node facts; every field has a declared default. */
14
+ export interface Config {
15
+ /** `X-API-Key` value sent on peer requests and required by the control routes; empty disables the header. */
16
+ readonly apiKey: string;
17
+ /**
18
+ * This node's caller label. `''` (the default) derives `dsh-host-<8 hex>`
19
+ * from a per-home node id created on first use, so two deployments mounting
20
+ * defaults do not collide while a persisted home keeps the label stable
21
+ * across restarts.
22
+ */
23
+ readonly session: string;
24
+ /** Team name this node exposes for direct routing. */
25
+ readonly team: string;
26
+ /** S4 fix 3: audit (default) or refuse host-side (agent-less) routing calls. */
27
+ readonly gateAgentLessCalls: 'audit' | 'refuse';
28
+ /** #114 S4: settlement authorization — off, observe (record would-refuse, settle as before), enforce. */
29
+ readonly settlementAuth: SettlementMode;
30
+ /**
31
+ * Publish this node's `/.well-known/agent-card.json` on the shared web
32
+ * server (peer discovery). Requires the web server in the composition;
33
+ * the card carries this node's team, capabilities, referral list, and
34
+ * joined session teams so peers find it without a central directory.
35
+ */
36
+ readonly announce: boolean;
37
+ /**
38
+ * gh#193: send nothing to any peer. Every outbound peer request — card
39
+ * reads, directory sweeps, routes, log reads, canvas pings and canvas-op
40
+ * relays — goes through one fetch that refuses while this is on, so a
41
+ * test host stays dark even with learned peers in `a2a/peers.json`
42
+ * (which is left untouched). Inbound faces keep answering. Default false.
43
+ */
44
+ readonly isolated: boolean;
45
+ /** Forward online local CLI deliveries one hop after a local miss. Default on from 0.6.38; explicit false opts out. */
46
+ readonly forwardDirect: boolean;
47
+ /** Human-facing name published on the agent card. */
48
+ readonly agentName: string;
49
+ /**
50
+ * Base URLs of seed peer nodes. `a2a_teams` lists teams discovered from
51
+ * the peers' agent cards and `a2a_route` connects to the owning peer's
52
+ * `/a2a/direct` endpoint. The list is a seed set: referral URLs learned
53
+ * from fetched cards join a bounded, quality-scored peer store persisted
54
+ * at `<dsh-home>/a2a/peers.json`.
55
+ */
56
+ readonly peers: string[];
57
+ /**
58
+ * Zone delegation records published (signed) on this node's agent card:
59
+ * each entry publishes `name` as resolvable in the zone at `url`, so a
60
+ * route for `name` walks the delegation chain (at most 5 hops, cycles
61
+ * fail closed).
62
+ */
63
+ readonly delegates: DelegateConfig[];
64
+ /**
65
+ * gh#9+gh#10 OriginClaim window (docs/protocol/delivery-origin-auth.md §4):
66
+ * while true (default), a delivery/log request with NO envelope still
67
+ * walks N3 admission and increments the legacyInbound warn metric; when
68
+ * the operator closes it (post fleet flip), an absent envelope rejects
69
+ * `untrusted-origin` — same code as a failed signature (M1: a
70
+ * self-asserted already-linked name must not pass on shape alone).
71
+ */
72
+ readonly originClaimWindow: boolean;
73
+ /**
74
+ * OriginClaim unbound window (docs/protocol/delivery-origin-auth.md §2.1):
75
+ * while true (default), this host also signs the legacy unbound form and
76
+ * accepts a peer's unbound-only envelope (counted as unboundInbound);
77
+ * closed, it signs and accepts the audience-bound form only.
78
+ */
79
+ readonly originClaimUnboundWindow: boolean;
80
+ /**
81
+ * Extra origins this host answers to as an OriginClaim audience, beyond
82
+ * its card URL and the address a request arrives on (port-mapped or
83
+ * proxied hosts name the URL peers dial).
84
+ */
85
+ readonly originClaimAudiences: string[];
86
+ /**
87
+ * #19 D2: card-face sessionTeams excerpt exposure — 'full' | 'masked'
88
+ * | 'off' (owner-level; default full). See the schema comment.
89
+ */
90
+ readonly exposureExcerpt: 'full' | 'masked' | 'off';
91
+ /**
92
+ * Override for the OriginClaim callerUrl anchor. Loopback-bound hosts
93
+ * behind a pocket tunnel must name the card URL peers can actually
94
+ * fetch (e.g. http://192.168.3.157:13080); empty uses the web server's
95
+ * own address.
96
+ */
97
+ readonly originClaimUrl: string;
98
+ /**
99
+ * gh#8 (N9) escape hatch: when true, team-name resolution also considers
100
+ * the referral-learned peer tail (the legacy whole-store basis) instead
101
+ * of the seeded/delegate subset only. Default false — a team name binds
102
+ * to hosts the operator linked; fleets relying on referral discovery for
103
+ * routing migrate by adding explicit seeds, then leave this off.
104
+ */
105
+ readonly referralTeamResolution: boolean;
106
+ /**
107
+ * Harness home slice for the node keypair and peer store; `''` (the
108
+ * default) uses the process DSH home. The Ed25519 key lives at
109
+ * `<home>/a2a/node-key.pem` and is generated on first announce; a
110
+ * persisted key keeps the node's card identity stable across restarts.
111
+ */
112
+ readonly dshHome: string;
113
+ /**
114
+ * Agent-card validity. Announce re-signs at TTL/4 so three lost refreshes
115
+ * still leave a live card; a node silent for one TTL disappears from every
116
+ * peer's discovery without manual eviction.
117
+ */
118
+ readonly cardTtlMs: number;
119
+ /**
120
+ * Enable per-session A2A nodes: each live top-level session can join the
121
+ * network explicitly — label `<session>-<agentId8>`, team
122
+ * `<team>/<agentId8>`, node facts carrying the session title and a
123
+ * recent-activity excerpt. Joining is opt-in through the sidebar control's
124
+ * host routes; joined teams ride this node's card and dispatch through
125
+ * its `/a2a/direct` endpoint.
126
+ */
127
+ readonly sessionNodes: boolean;
128
+ /**
129
+ * Prewarm every cold joined session's agent after the plugin mounts (dev
130
+ * boxes and always-on collaboration hosts that restart often: the network
131
+ * state returns without opening each session). Each wake materializes a
132
+ * full agent — a main-thread log replay — so the prewarm is deferred,
133
+ * foreground-yielding, and cancellable (see `wakePrewarmDelayMs` /
134
+ * `wakePrewarmQuietMs`); the default stays off for deployments that would
135
+ * rather pay on demand (wake-on-route and the sidebar's wake button remain
136
+ * available either way).
137
+ */
138
+ readonly wakeJoinedOnBoot: boolean;
139
+ /**
140
+ * Idle delay between loader settlement and the first boot prewarm wake:
141
+ * boot traffic gets a clear window before any log replay starts. `0`
142
+ * restores the old fire-at-settle behavior.
143
+ */
144
+ readonly wakePrewarmDelayMs: number;
145
+ /**
146
+ * Foreground quiet window: a wake/route demand inside this window (or any
147
+ * outbound route still in flight) postpones the next prewarm step. Panel
148
+ * polls never count. `0` disables the yield.
149
+ */
150
+ readonly wakePrewarmQuietMs: number;
151
+ /**
152
+ * Pause between consecutive boot prewarm wakes. Each wake replays a full
153
+ * session log — the zstd decode yields the event loop only every 500ms —
154
+ * so unbounded concurrent wakes of several huge logs starve every request
155
+ * for tens of seconds after a restart. The serial queue with this pause
156
+ * keeps the preheat while capping decode saturation, and wake-on-route
157
+ * never waits on this queue.
158
+ */
159
+ readonly wakeBootStaggerMs: number;
160
+ /**
161
+ * F8: continuous desired-state reconciliation. The boot prewarm is a
162
+ * one-shot queue; the reconciler re-derives the due set every tick and
163
+ * wakes one cold intent per pass — covering post-boot drift, failed
164
+ * wakes, and gateways that mounted late. Default on.
165
+ */
166
+ readonly wakeReconcile: boolean;
167
+ /** Cadence between reconciliation ticks (floored at 50ms). */
168
+ readonly wakeReconcileIntervalMs: number;
169
+ /** First-retry delay after a failed reconcile wake; doubles per attempt. */
170
+ readonly wakeReconcileBackoffBaseMs: number;
171
+ /** Backoff ceiling; corrupt-log rows park as needs-repair and never retry. */
172
+ readonly wakeReconcileMaxBackoffMs: number;
173
+ /**
174
+ * S4 (gh#11 N7, operator directive: team creation is a human act): the
175
+ * joinable-team curation list for a2a_team_join. ONLY an EXACT entry
176
+ * authorizes a join; trailing-`*` pattern entries stay readable here
177
+ * (whoami shows them) but carry no mint rights — a pattern that
178
+ * pre-authorized every future name under it would let a model mint teams
179
+ * nobody created. Empty list denies every join (default).
180
+ */
181
+ readonly teamJoinAllowlist: string[];
182
+ /** Human-owned stable display labels keyed by full local session id; never a routing identity. */
183
+ readonly seatNames: Record<string, unknown>;
184
+ /**
185
+ * S3 (phase-2 default-ON, owner ruling 2026-09-01): route dispatch checks
186
+ * caller↔target shared team membership before addressing; set false to
187
+ * restore the open outbound seam. (Kept in sync with the schema comment.)
188
+ */
189
+ readonly teamScopeRouting: boolean;
190
+ /**
191
+ * S5 (owner directive 2026-10-20): information-plane scoping — the
192
+ * read-only fleet tools (a2a_teams / a2a_status / a2a_probe) disclose
193
+ * only teams joined by this host's nodes (the union of local roster
194
+ * declarations). [this host] rows stay visible; a2a_tasks (this host's
195
+ * own ledger) stays unscoped. Set false for the open plane.
196
+ */
197
+ readonly teamScopeInfo: boolean;
198
+ /**
199
+ * Peer boundary model (docs/design/peer-boundary-model.md) — connection
200
+ * layer: an empty list keeps the historical open-referral posture; a
201
+ * non-empty list admits a referral only when its host matches an entry
202
+ * (exact host[:port], bare domain suffix, or full URL). Seeds from
203
+ * `peers` are owner-configured and unaffected.
204
+ */
205
+ readonly peerAllowlist: string[];
206
+ /**
207
+ * Peer boundary model — connection layer: when false, referral URLs are
208
+ * neither learned nor offered; the tracked set stays the configured seed
209
+ * set for the lifetime of the config that named them.
210
+ */
211
+ readonly referralLearning: boolean;
212
+ /**
213
+ * v0.5.23 (async-stall): see the schema comment on asyncNudgeDelayMs.
214
+ */
215
+ readonly asyncNudgeDelayMs: number;
216
+ /** gh#224: receipt-owing tasks one target may queue on this host before new deliveries are refused (0 = off). */
217
+ readonly targetQueueCap: number;
218
+ /**
219
+ * How long the state route serves the cold-row id set from cache before
220
+ * re-enumerating the persistence layer. The panel polls every 2s; the
221
+ * default keeps one full enumeration per 5s instead of one per poll.
222
+ */
223
+ readonly stateColdRowsTtlMs: number;
224
+ /**
225
+ * Serve window for a verified peer card from the shared cache. Cards are
226
+ * signed for days and re-signed at TTL/4, so 60s is semantically safe; a
227
+ * peer that restarts with a fresh card is picked up on the next window.
228
+ */
229
+ readonly cardCacheTtlMs: number;
230
+ /** Shorter window for unreachable/invalid cards, so a revived peer reappears quickly. */
231
+ readonly cardCacheNegativeTtlMs: number;
232
+ /**
233
+ * Serve window for the panel\x27s remote rows. The refresh itself rides the
234
+ * shared card cache, so this is pure sweep cadence: how often real
235
+ * network activity happens while the panel polls every 2s.
236
+ */
237
+ readonly remoteRowsTtlMs: number;
238
+ /**
239
+ * `final` reply budget: how long an inbound direct route waits for the
240
+ * session's next assistant message before answering with a timeout
241
+ * notice. Without it a session that never idles (or never produces text)
242
+ * leaves the caller hanging until `routeTimeoutMs` expires.
243
+ */
244
+ readonly flushTimeoutMs: number;
245
+ /**
246
+ * `a2a_route` execution budget: how long a call may plausibly wait for a
247
+ * remote session's reply (default 30 minutes).
248
+ */
249
+ readonly routeTimeoutMs: number;
250
+ /**
251
+ * Age at which an unsettled async task auto-dead-letters (exits the owed
252
+ * view, disarms the nudge, still settles on a late receipt). Default
253
+ * 24h; the mesh anomaly suite injects sub-second windows to exercise the
254
+ * dead-letter → revival lifecycle without wall-clock waits.
255
+ */
256
+ readonly taskStaleTtlMs: number;
257
+ /**
258
+ * Opt-in native-teams inbound bridge: when composed with
259
+ * `@nelsonlongxiang/dsh-native-teams`, a routed team name that its
260
+ * registry classifies as an unambiguous local claim dispatches through
261
+ * its authoritative routing seam (`/a2a/direct`, the outbound A2A tools,
262
+ * and the directory listing). Off by default — exposing every registered
263
+ * team to the network is an operator decision (exposure-grants
264
+ * governance: grants are deliberate, never ambient). Dispatcher-level
265
+ * only: inbound callers address the team, never its individual members
266
+ * (members stay visible-not-addressable).
267
+ */
268
+ readonly nativeTeamsInbound?: boolean;
269
+ /**
270
+ * Reply-wait budget for one native-teams round (the bridge's answer
271
+ * deadline, mirroring the steer path's 180s deadline). A round still
272
+ * running past it answers the honest delivered-unsettled shape instead
273
+ * of parking the caller; the round itself keeps going.
274
+ */
275
+ readonly nativeRoundWaitMs?: number;
276
+ }
277
+ /** Schemastery configuration for the A2A client plugin row. */
278
+ export declare const Config: s<Config>;
@@ -1,5 +1,5 @@
1
- import { type TaskLedger } from './task-ledger.ts';
2
- import type { TaskAuthorization } from './task-auth.ts';
1
+ import { type TaskLedger, type TaskRecord } from './task-ledger.ts';
2
+ import { type TaskAuthorization } from './task-auth.ts';
3
3
  import type { A2aPeerCard, A2aRouteResult } from './types.ts';
4
4
  export interface ForwardRequest {
5
5
  team: string;
@@ -12,9 +12,17 @@ export interface ForwardRequest {
12
12
  guarded: boolean;
13
13
  auth?: TaskAuthorization;
14
14
  }
15
+ /** An early receipt waits at most this long for its forward row to be born (#298). */
16
+ export declare const BIRTH_WAIT_CAP_MS = 60000;
15
17
  /** Birth barrier exists only for eligible, actively dispatched tasks; receipts never reserve a slot. */
16
18
  export declare class ForwardBirths {
19
+ private readonly waitCapMs;
17
20
  private readonly pending;
21
+ constructor(waitCapMs?: number);
22
+ /**
23
+ * Resolves when the birth is released or after the cap, whichever is first. After the cap the receipt
24
+ * is judged by the normal rules against whatever row exists then — never accepted in advance (#298).
25
+ */
18
26
  wait(taskId: string): Promise<void> | undefined;
19
27
  begin(taskId: string): (() => void) | undefined;
20
28
  }
@@ -23,7 +31,6 @@ export interface DirectForwardDeps {
23
31
  enabled(): boolean;
24
32
  isolated(): boolean;
25
33
  deposited(handle: string): boolean;
26
- memberLinked(handle: string): boolean;
27
34
  scope(handle: string, team: string): Promise<{
28
35
  ok: true;
29
36
  } | {
@@ -39,3 +46,18 @@ export interface DirectForwardDeps {
39
46
  activity(team: string, peer: string, ok: boolean): void;
40
47
  }
41
48
  export declare function createDirectForward(d: DirectForwardDeps): (request: ForwardRequest) => Promise<A2aRouteResult>;
49
+ /**
50
+ * #282 S3 (same team authorizes): the admission basis for a receipt delivered to a local CLI mailbox
51
+ * from a member the home never linked — only for that CLI's own pending forward, only from a receiver
52
+ * frozen at birth, only when the body-bound (Sig3) claim's card key is the frozen peer key. Anything else:
53
+ * undefined. Trust assumption (design D2): the selected owner host is honest about its own canvas — it may
54
+ * list any label as a receiver, including one of this host's session labels in the same zone.
55
+ */
56
+ export declare function forwardReceiptBasis(row: TaskRecord | undefined, caller: string, cliHandle: string, claim: {
57
+ readonly caller: string;
58
+ readonly bound: boolean;
59
+ readonly bodyBound?: true;
60
+ readonly card: {
61
+ readonly publicKey: string;
62
+ };
63
+ }): string | undefined;
@@ -151,6 +151,8 @@ export interface AdminFaceDeps extends Pick<CanvasNotifyDeps, 'verifyOriginClaim
151
151
  lastAt: number;
152
152
  }>;
153
153
  readonly ownCardUrl: string;
154
+ /** #282 S2: this host's canvas owner fingerprint. */
155
+ readonly ownCanvasFingerprint: string;
154
156
  ownerSeatNames: Record<string, string>;
155
157
  ownerAllowlist: string[];
156
158
  ownerTeamScopeInfo: boolean;
@@ -49,6 +49,7 @@ export type RouteOutcome = {
49
49
  status?: string;
50
50
  bridge?: 'native-teams';
51
51
  placeholder?: boolean;
52
+ ownTurn?: true;
52
53
  } | {
53
54
  ok: false;
54
55
  error: string;
@@ -111,6 +112,7 @@ export type OriginClaimResult = {
111
112
  card: A2aPeerCard;
112
113
  bound: boolean;
113
114
  cli?: true;
115
+ bodyBound?: true;
114
116
  } | {
115
117
  ok: false;
116
118
  reason: string;
@@ -131,10 +133,16 @@ export interface WireDeps {
131
133
  readonly rawBody?: Uint8Array;
132
134
  }) => Promise<OriginClaimResult>;
133
135
  readonly forwardDirect: (request: ForwardRequest) => Promise<A2aRouteResult>;
136
+ /** #282 S2: this host's canvas owner fingerprint. */
137
+ readonly ownCanvasFingerprint: string;
134
138
  readonly diagnoseCanvas: (team: string, reason: string, caller?: string) => Promise<string>;
135
139
  readonly remoteCliProof: (handle: string, claim: Extract<OriginClaimResult, {
136
140
  ok: true;
137
141
  }>) => Promise<RemoteCliProof | undefined>;
142
+ /** #282 S3: the basis for a receipt to a local CLI from a member frozen on this host's own forward, else undefined. */
143
+ readonly forwardReceiptBasis: (taskId: string, caller: string, cliHandle: string, claim: Extract<OriginClaimResult, {
144
+ ok: true;
145
+ }>) => string | undefined;
138
146
  readonly callerLinkedToThisHost: (caller: string, callerUrl: string, callerCard: A2aPeerCard | undefined) => boolean;
139
147
  /** This host's own card URL (read when a request lands; set once the web server settles). */
140
148
  readonly ownCardUrl: string;
@@ -224,5 +232,23 @@ export declare function settlerClaimFields(claim: {
224
232
  * @param webServer - the settled host web server.
225
233
  * @param d - the captures listed on {@link WireDeps}.
226
234
  */
235
+ /** #298: how long, and how many, sync-answered forwards are remembered for marking their duplicate receipt. */
236
+ export declare const SYNC_ANSWERED_TTL_MS = 3600000;
237
+ export declare const SYNC_ANSWERED_CAP = 256;
238
+ /**
239
+ * #298: forwards whose final sync answer — the member's own reply, not a delivered/mailbox placeholder — was
240
+ * fully written back to the CLI that sent them. That member's receipt for the same task, landing in that CLI's
241
+ * mailbox unrefused, is marked a duplicate — never dropped. In memory only: after a restart the receipt arrives
242
+ * unmarked, which is today's behaviour.
243
+ */
244
+ export declare class SyncAnswered {
245
+ private readonly now;
246
+ private readonly rows;
247
+ constructor(now?: () => number);
248
+ note(taskId: string, handle: string, answeredBy: string): void;
249
+ /** True once for a task answered to exactly this handle by exactly this sender; the row is consumed. */
250
+ take(taskId: string, handle: string, sender: string): boolean;
251
+ private sweep;
252
+ }
227
253
  export declare function registerWireFaces(webServer: WebServer, d: WireDeps): void;
228
254
  export {};