@dougbots/avenor-core 0.16.1 → 0.17.0

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.
package/dist/index.d.ts CHANGED
@@ -207,6 +207,12 @@ interface MessagePeer {
207
207
  interface MessagePeersResult {
208
208
  peers: MessagePeer[];
209
209
  generation?: string;
210
+ /**
211
+ * Set when the listing read only part of the peer set. The peers beside it
212
+ * are the ones that were read, so a partial list is never read as a
213
+ * complete one.
214
+ */
215
+ peers_error?: string;
210
216
  }
211
217
  interface MessagePreflightResult {
212
218
  protocol: number;
@@ -1166,7 +1172,10 @@ declare function installAskClaims(provider: MessageProvider, claims: AskClaims,
1166
1172
  /**
1167
1173
  * Build the bound host provider: one supervisor, one generation, one control
1168
1174
  * client. It never reads an ambient singleton or retargets, and it never
1169
- * preflights per call.
1175
+ * preflights per call. Listing-backed lookups fail fast: an incomplete
1176
+ * listing refuses every resolution and state read, even for a peer the
1177
+ * partial set contains, so a wire `peers_error` resolves the same way the Go
1178
+ * providers do. Self and public-ID resolution bypass the listing.
1170
1179
  */
1171
1180
  declare function createHostMessageProvider(options: HostProviderOptions): MessageProvider;
1172
1181
  interface ChildProviderOptions {
@@ -1181,7 +1190,10 @@ interface ChildProviderOptions {
1181
1190
  /**
1182
1191
  * Build a child provider over the surface's inherited broker. A child never
1183
1192
  * learns a public run id, and it cannot read a sentinel, so it is never
1184
- * resumable from here: the supervisor owns a resume.
1193
+ * resumable from here: the supervisor owns a resume. Listing-backed lookups
1194
+ * fail fast: an incomplete listing refuses every resolution and state read,
1195
+ * even for a peer the partial set contains, so a wire `peers_error` resolves
1196
+ * the same way the Go providers do. Self resolution bypasses the listing.
1185
1197
  */
1186
1198
  declare function createChildMessageProvider(options: ChildProviderOptions): MessageProvider;
1187
1199
  //#endregion
package/dist/index.js CHANGED
@@ -9480,13 +9480,20 @@ function installAskClaims(provider, claims, pendingAsks, pollGeneration) {
9480
9480
  /**
9481
9481
  * Build the bound host provider: one supervisor, one generation, one control
9482
9482
  * client. It never reads an ambient singleton or retargets, and it never
9483
- * preflights per call.
9483
+ * preflights per call. Listing-backed lookups fail fast: an incomplete
9484
+ * listing refuses every resolution and state read, even for a peer the
9485
+ * partial set contains, so a wire `peers_error` resolves the same way the Go
9486
+ * providers do. Self and public-ID resolution bypass the listing.
9484
9487
  */
9485
9488
  function createHostMessageProvider(options) {
9486
9489
  const { surface, supervisorId, generation, client, pendingAsks, pollGeneration } = options;
9487
9490
  const claims = /* @__PURE__ */ new Map();
9488
9491
  async function listedPeers() {
9489
- return peerRecords(await client.messagePeers({ generation }));
9492
+ const result = await client.messagePeers({ generation });
9493
+ return {
9494
+ peers: peerRecords(result),
9495
+ detail: result.peers_error || void 0
9496
+ };
9490
9497
  }
9491
9498
  async function retractAsk(messageId) {
9492
9499
  try {
@@ -9533,7 +9540,8 @@ function createHostMessageProvider(options) {
9533
9540
  const external = findExternalRunById(supervisorId, ref);
9534
9541
  if (external?.runtimeId) return unique(external);
9535
9542
  }
9536
- const peers = await listedPeers();
9543
+ const { peers, detail } = await listedPeers();
9544
+ if (detail) throw new Error(`the peer listing is incomplete: ${detail}`);
9537
9545
  const exact = peers.find((peer) => peer.run_id === ref);
9538
9546
  if (exact) return {
9539
9547
  runId: exact.run_id,
@@ -9560,7 +9568,9 @@ function createHostMessageProvider(options) {
9560
9568
  },
9561
9569
  async state(runId) {
9562
9570
  if (runId === "supervisor") {
9563
- const translation = translateRunFacts((await listedPeers()).find((entry) => entry.run_id === "supervisor")?.status ?? "", "");
9571
+ const { peers, detail } = await listedPeers();
9572
+ if (detail) throw new Error(`the peer listing is incomplete: ${detail}`);
9573
+ const translation = translateRunFacts(peers.find((entry) => entry.run_id === "supervisor")?.status ?? "", "");
9564
9574
  return {
9565
9575
  live: translation.live,
9566
9576
  resumable: false,
@@ -9771,7 +9781,11 @@ function createHostMessageProvider(options) {
9771
9781
  };
9772
9782
  },
9773
9783
  async peers() {
9774
- return { peers: await listedPeers() };
9784
+ const { peers, detail } = await listedPeers();
9785
+ return {
9786
+ peers,
9787
+ detail
9788
+ };
9775
9789
  },
9776
9790
  async recordLastTurn(text, stopReason, truncated) {
9777
9791
  await client.sessionLastSet(SUPERVISOR_RUN_ID, text, stopReason, truncated);
@@ -9842,13 +9856,20 @@ function renderReply(reply) {
9842
9856
  /**
9843
9857
  * Build a child provider over the surface's inherited broker. A child never
9844
9858
  * learns a public run id, and it cannot read a sentinel, so it is never
9845
- * resumable from here: the supervisor owns a resume.
9859
+ * resumable from here: the supervisor owns a resume. Listing-backed lookups
9860
+ * fail fast: an incomplete listing refuses every resolution and state read,
9861
+ * even for a peer the partial set contains, so a wire `peers_error` resolves
9862
+ * the same way the Go providers do. Self resolution bypasses the listing.
9846
9863
  */
9847
9864
  function createChildMessageProvider(options) {
9848
9865
  const { surface, runId, broker, pendingAsks, pollGeneration } = options;
9849
9866
  const claims = /* @__PURE__ */ new Map();
9850
9867
  async function listedPeers() {
9851
- return (await broker.peers()).peers;
9868
+ const result = await broker.peers();
9869
+ return {
9870
+ peers: result.peers,
9871
+ detail: result.detail
9872
+ };
9852
9873
  }
9853
9874
  const provider = {
9854
9875
  caller: () => ({
@@ -9867,7 +9888,8 @@ function createChildMessageProvider(options) {
9867
9888
  label: ref,
9868
9889
  match: "unique"
9869
9890
  };
9870
- const peers = await listedPeers();
9891
+ const { peers, detail } = await listedPeers();
9892
+ if (detail) throw new Error(`the peer listing is incomplete: ${detail}`);
9871
9893
  const exact = peers.find((peer) => peer.run_id === ref);
9872
9894
  if (exact) return {
9873
9895
  runId: exact.run_id,
@@ -9891,7 +9913,9 @@ function createChildMessageProvider(options) {
9891
9913
  };
9892
9914
  },
9893
9915
  async state(targetRunId) {
9894
- const peer = (await listedPeers()).find((entry) => entry.run_id === targetRunId);
9916
+ const { peers, detail } = await listedPeers();
9917
+ if (detail) throw new Error(`the peer listing is incomplete: ${detail}`);
9918
+ const peer = peers.find((entry) => entry.run_id === targetRunId);
9895
9919
  if (!peer) throw new Error(`run ${targetRunId} is not visible`);
9896
9920
  const translation = translateRunFacts(peer.status ?? "", "");
9897
9921
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dougbots/avenor-core",
3
- "version": "0.16.1",
3
+ "version": "0.17.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",