@indigoai-us/hq-cli 5.345.161 → 5.345.162

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 +1 @@
1
- {"name":"hq-cli-daemon-sync-runner","type":"module","version":"6.18.99","bundleSha256":"05ece85b87c743511d74111934f420f24a47677e9e90a18dd45e6d3d1d8d0375","formatVersion":1}
1
+ {"name":"hq-cli-daemon-sync-runner","type":"module","version":"6.18.100","bundleSha256":"75a1828c5307937f67a1435a11ad08a0db16a30a3e3701d2a4d0fced3540cb33","formatVersion":1}
@@ -77,11 +77,12 @@ export interface MergedInbox {
77
77
  note?: string;
78
78
  /**
79
79
  * Machine-readable origin of the answer. `server` means the server inbox was
80
- * read (merged with the mirror); `local-mirror` means the server could not be
81
- * consulted and the entries may be stale. Lets an automated consumer tell a
82
- * stale fallback from a verified empty inbox without parsing `note`.
80
+ * read with a valid messages array (merged with the mirror); `server-partial`
81
+ * keeps usable server rows when invalid items were dropped, but does not
82
+ * certify completeness. `local-mirror` means no valid server response was
83
+ * available and entries may be stale. Only `server` certifies an empty read.
83
84
  */
84
- source: "server" | "local-mirror";
85
+ source: "server" | "server-partial" | "local-mirror";
85
86
  }
86
87
  export declare function mergeAgentInbox(paths: Pick<AgentKitPaths, "inboxDir">, fetchServerInbox: () => Promise<{
87
88
  status: number;
@@ -143,29 +143,50 @@ export async function mergeAgentInbox(paths, fetchServerInbox) {
143
143
  for (const e of readMirroredInbox(paths))
144
144
  byId.set(e.id, e);
145
145
  let note;
146
+ let source = "server";
146
147
  try {
147
148
  const res = await fetchServerInbox();
148
149
  if (res.status === 200) {
149
150
  const messages = res.body?.messages;
151
+ // A successful HTTP status alone cannot certify an inbox read. An error
152
+ // envelope or an undecodable body must remain visibly unverified; never
153
+ // include response bytes or parser errors in this diagnostic.
154
+ if (!Array.isArray(messages)) {
155
+ source = "local-mirror";
156
+ note = "server inbox returned an invalid response; showing the local mirror only, which may be stale";
157
+ }
158
+ let invalidItems = 0;
150
159
  for (const m of Array.isArray(messages) ? messages : []) {
151
- if (!m || typeof m !== "object")
160
+ if (!m || typeof m !== "object") {
161
+ invalidItems += 1;
152
162
  continue;
163
+ }
153
164
  const raw = m;
154
165
  const id = typeof raw.id === "string" ? raw.id : typeof raw.messageId === "string" ? raw.messageId : null;
155
- if (id && !byId.has(id))
166
+ if (!id) {
167
+ invalidItems += 1;
168
+ continue;
169
+ }
170
+ if (!byId.has(id))
156
171
  byId.set(id, redactAgentInboxItem({ ...raw, id }));
157
172
  }
173
+ if (invalidItems > 0) {
174
+ source = "server-partial";
175
+ note = "server inbox contained invalid messages; showing valid server messages and the local mirror, which may be incomplete";
176
+ }
158
177
  }
159
178
  else {
179
+ source = "local-mirror";
160
180
  note = `server inbox answered ${res.status}; showing the local mirror only, which may be stale`;
161
181
  }
162
182
  }
163
183
  catch (err) {
184
+ source = "local-mirror";
164
185
  note = `server inbox unavailable (${err instanceof Error ? err.message : String(err)}); showing the local mirror only, which may be stale`;
165
186
  }
166
187
  return {
167
188
  entries: [...byId.values()],
168
- source: note ? "local-mirror" : "server",
189
+ source,
169
190
  ...(note ? { note } : {}),
170
191
  };
171
192
  }