@zanii/blackbox 0.16.0 → 0.16.1

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.
@@ -64,8 +64,11 @@ export declare function insights(summaries: readonly SummaryIn[], window: {
64
64
  from: string;
65
65
  to: string;
66
66
  }): Insights;
67
- /** spec/insights.md §3: the record as one line per event, metadata only, at most 600 events. */
68
- export declare function copilotContext(lines: readonly string[]): string;
67
+ /**
68
+ * spec/insights.md §3: the record as one line per event, metadata only, at most 600 events. With
69
+ * `body` (a body by its hash), a verify event also says `ok=true` or `ok=false`.
70
+ */
71
+ export declare function copilotContext(lines: readonly string[], body?: (hash: string) => Uint8Array | null | undefined): string;
69
72
  /** spec/insights.md §3: the system prompt and the user turn for the investigator's model. */
70
73
  export declare function copilotPrompt(question: string, context: string, lang?: string): {
71
74
  system: string;
@@ -195,8 +195,28 @@ function evenly(items, n) {
195
195
  return [...items];
196
196
  return Array.from({ length: n }, (_, i) => items[Math.floor((i * items.length) / n)]);
197
197
  }
198
- /** spec/insights.md §3: the record as one line per event, metadata only, at most 600 events. */
199
- export function copilotContext(lines) {
198
+ /** A verify event's pass or fail, from its body: the one value read from a body. Never `detail`. */
199
+ function verifyOk(e, body) {
200
+ const meta = (e.meta ?? {});
201
+ if (!body || e.kind !== "sdk.event" || meta.type !== "verify")
202
+ return null;
203
+ const raw = body(String(e.body_hash));
204
+ if (!raw || raw.length === 0)
205
+ return null; // erased, or never sent
206
+ try {
207
+ const doc = JSON.parse(new TextDecoder().decode(raw));
208
+ const ok = doc && typeof doc === "object" && !Array.isArray(doc) ? doc.ok : null;
209
+ return typeof ok === "boolean" ? ok : null;
210
+ }
211
+ catch {
212
+ return null;
213
+ }
214
+ }
215
+ /**
216
+ * spec/insights.md §3: the record as one line per event, metadata only, at most 600 events. With
217
+ * `body` (a body by its hash), a verify event also says `ok=true` or `ok=false`.
218
+ */
219
+ export function copilotContext(lines, body) {
200
220
  const events = lines.map((l) => JSON.parse(l));
201
221
  const n = events.length;
202
222
  let shown;
@@ -241,12 +261,16 @@ export function copilotContext(lines) {
241
261
  if (v !== null)
242
262
  parts.push(`${k}=${v}`);
243
263
  }
264
+ const ok = verifyOk(e, body);
265
+ if (ok !== null)
266
+ parts.push(`ok=${ok}`);
244
267
  out.push(parts.join(" "));
245
268
  }
246
269
  return out.join("\n");
247
270
  }
248
271
  const SYSTEM = "You are an investigator reading one AI agent's flight record from Zanii Blackbox. The record " +
249
- "below is one line per event: #seq, time, kind, then its metadata. Answer the question only " +
272
+ "below is one line per event: #seq, time, kind, then its metadata; ok=true or ok=false on a " +
273
+ "verify event is the result of the agent's own check. Answer the question only " +
250
274
  "from the record. Cite the event numbers your answer rests on. If the record doesn't say, say " +
251
275
  "so. Be brief and concrete. Answer with JSON only: " +
252
276
  '{"answer": "<your answer>", "cites": [<seq>, ...]}';
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.16.0";
1
+ export declare const VERSION = "0.16.1";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // The SDK version, on its own so the CLI can print it without loading the whole SDK.
2
- export const VERSION = "0.16.0";
2
+ export const VERSION = "0.16.1";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zanii/blackbox",
3
3
  "license": "Apache-2.0",
4
- "version": "0.16.0",
4
+ "version": "0.16.1",
5
5
  "description": "The flight recorder for AI agents: sessions, a zero-loss spool, framework hooks, approvals, and offline verification of the gateway's hash-chained record.",
6
6
  "keywords": [
7
7
  "ai-agents",