robisie 0.5.53 → 0.6.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.
@@ -37652,7 +37652,7 @@ var init_constants = __esm({
37652
37652
  "packages/client/src/constants.ts"() {
37653
37653
  "use strict";
37654
37654
  PACKAGE_NAME = "robisie";
37655
- PACKAGE_VERSION = "0.5.53";
37655
+ PACKAGE_VERSION = "0.6.1";
37656
37656
  SUPPORTED_CONTRACT_MAJOR = 1;
37657
37657
  DEFAULT_ORIGIN = "https://robisie.app";
37658
37658
  MCP_SERVER_NAME = "robisie";
@@ -48218,6 +48218,30 @@ function classifyAuthority(card) {
48218
48218
  }
48219
48219
  return { kind: "auto" };
48220
48220
  }
48221
+ function taskBriefHash(card) {
48222
+ const d = card.details ?? {};
48223
+ const dutyDetails = d;
48224
+ return (0, import_node_crypto2.createHash)("sha256").update(JSON.stringify([
48225
+ card.title,
48226
+ card.specRef,
48227
+ d.seed_brief,
48228
+ d.seed_spec,
48229
+ d.seed_scope,
48230
+ d.scope,
48231
+ d.done_when ?? d.doneWhen ?? d.acceptance,
48232
+ d.boundaries,
48233
+ d.outcome,
48234
+ d.out,
48235
+ asRecord(asRecord(dutyDetails.unblock).verdict).note
48236
+ ])).digest("hex");
48237
+ }
48238
+ function taskInputHash(card, effort) {
48239
+ const brief2 = hasDutyNote(card.details) ? card : { ...card, details: { ...card.details, unblock: void 0 } };
48240
+ return (0, import_node_crypto2.createHash)("sha256").update(JSON.stringify([taskBriefHash(brief2), effort, card.details?.codex_model ?? null])).digest("hex");
48241
+ }
48242
+ function changedBlockerInput(last2, fingerprint) {
48243
+ return last2.outcome === "ACTIONABLE_BLOCKER" && typeof last2.input_sha256 === "string" && /^[a-f0-9]{64}$/.test(last2.input_sha256) && fingerprint !== void 0 && last2.input_sha256 !== fingerprint;
48244
+ }
48221
48245
  function buildBrief(card, northStar, opts) {
48222
48246
  const details2 = card.details ?? {};
48223
48247
  const doneWhen = details2["done_when"] ?? details2["doneWhen"] ?? details2["acceptance"] ?? null;
@@ -48232,12 +48256,40 @@ function buildBrief(card, northStar, opts) {
48232
48256
  const terminalAt = typeof workerAt === "string" ? Date.parse(workerAt) : NaN;
48233
48257
  const noteAt = typeof dutyVerdict.at === "string" ? Date.parse(dutyVerdict.at) : NaN;
48234
48258
  const dutyHeading = noteAt > terminalAt ? "Aktualna odpowied\u017A CR \u2014 obowi\u0105zuje w tej rundzie" : "Historyczny dopisek \u2014 nie stanowi odpowiedzi CR; wymaga jawnej readmisji";
48259
+ const authorFields = ["boundaries", "input_source", "outcome", "first_deliverable_value"];
48260
+ const handledFields = /* @__PURE__ */ new Set([
48261
+ ...authorFields,
48262
+ ...seeds,
48263
+ "scope",
48264
+ "codex_effort",
48265
+ "done_when",
48266
+ "doneWhen",
48267
+ "acceptance",
48268
+ "review",
48269
+ "unblock",
48270
+ "maszynista",
48271
+ "obligations",
48272
+ "bench_obligation",
48273
+ "hold",
48274
+ "seed_obligation",
48275
+ "decision_queue",
48276
+ "scope_blocked_at",
48277
+ "seed_scope_sha256",
48278
+ "seed_spec_sha256",
48279
+ "seed_brief_sha256",
48280
+ "reksio_withheld",
48281
+ "admission",
48282
+ "qualification",
48283
+ "base_sha"
48284
+ ]);
48285
+ const omittedFields = Object.entries(details2).filter(([key, value]) => value !== void 0 && !handledFields.has(key)).map(([key]) => key).sort();
48235
48286
  const lines2 = [
48236
48287
  `# Zadanie z tablicy Robisie \u2014 karta ${card.id}`,
48237
48288
  ``,
48238
48289
  `## Tytu\u0142`,
48239
48290
  card.title,
48240
48291
  ``,
48292
+ ...changedBlockerInput(asRecord(details2.maszynista), opts.inputFingerprint) ? ["Kryterium uko\u0144czenia i Zakres z karty maj\u0105 pierwsze\u0144stwo przed Done When i zakresem zapisanymi w pakiecie z zasiewu."] : [],
48241
48293
  chosen ? `## Aktualny pakiet (${chosen})
48242
48294
  ${details2[chosen]}` : ``,
48243
48295
  details2.scope !== void 0 ? `## Zakres
@@ -48253,12 +48305,16 @@ ${JSON.stringify({ verdict: review.verdict ?? null, round: review.round ?? null,
48253
48305
  hasDutyNote(details2) ? `
48254
48306
  ## ${dutyHeading}
48255
48307
  ${String(dutyVerdict.note)}` : ``,
48308
+ ...authorFields.flatMap((key) => details2[key] === void 0 ? [] : [`## ${key}
48309
+ ${JSON.stringify(details2[key])}`]),
48310
+ ...omittedFields.length ? [`## Pomini\u0119te pola autora (tylko nazwy)
48311
+ ${JSON.stringify(omittedFields)}`] : [],
48256
48312
  ``,
48257
48313
  `## Kontekst (skr\xF3t \u2014 tylko po to, by\u015B rozpozna\u0142 "ju\u017C zrobione" i "wymaga cz\u0142owieka")`,
48258
48314
  northStar.trim(),
48259
48315
  ``,
48260
48316
  `## Zasady pracy`,
48261
- `- Nie wo\u0142aj MCP Planera (get_task, update_task i pokrewnych). Pe\u0142na karta jest w tym briefie; jobId, pr\xF3b\u0119 i raport dopisuje Maszynista. Brak jobId w Twoim raporcie nie jest blokerem.`,
48317
+ `- Nie wo\u0142aj MCP Planera (get_task, update_task i pokrewnych). ${omittedFields.length ? "" : "Pe\u0142na karta jest w tym briefie; "}jobId, pr\xF3b\u0119 i raport dopisuje Maszynista. Brak jobId w Twoim raporcie nie jest blokerem.`,
48262
48318
  `- Pracujesz w worktree \`${opts.worktree}\` na ga\u0142\u0119zi \`${opts.branch}\`. Nie commituj; pozostaw zmiany silnikowi. Nie deklaruj SHA ani HEAD w raporcie. NIE pushuj ani nie merge\u2019uj main; poza zakresem zapisuj wy\u0142\u0105cznie istniej\u0105ce pliki test\xF3w, danych testowych i pliki wyliczane z kodu, kt\xF3re Twoja zmiana uniewa\u017Cnia.`,
48263
48319
  `- Je\u015Bli karta opisuje co\u015B, co JU\u017B jest zrobione w repo/produkcji \u2014 nie r\xF3b drugi raz: ZBIERZ DOW\xD3D (\u015Bcie\u017Cki, commity, wynik komendy) i zaraportuj "ju\u017C zrobione" z dowodem. Przed ALREADY_DONE rozlicz ka\u017Cde finding bie\u017C\u0105cej recenzji FAIL: napraw lub wyka\u017C konkretnym dowodem, \u017Ce nie wyst\u0119puje; sam brak nowego commita nie rozlicza FAIL.`,
48264
48320
  `- Je\u015Bli zadanie wymaga pieni\u0119dzy, skutku nieodwracalnego, konta/klucza lub zmiany kierunku \u2014 ZATRZYMAJ SI\u0118 i zaraportuj "WYMAGA CZ\u0141OWIEKA: <co>" zamiast robi\u0107.`,
@@ -71820,9 +71876,9 @@ var require_discriminator = __commonJS({
71820
71876
  function validateMapping() {
71821
71877
  const mapping = getMapping();
71822
71878
  gen.if(false);
71823
- for (const tagValue in mapping) {
71824
- gen.elseIf((0, codegen_1._)`${tag} === ${tagValue}`);
71825
- gen.assign(valid, applyTagSchema(mapping[tagValue]));
71879
+ for (const tagValue2 in mapping) {
71880
+ gen.elseIf((0, codegen_1._)`${tag} === ${tagValue2}`);
71881
+ gen.assign(valid, applyTagSchema(mapping[tagValue2]));
71826
71882
  }
71827
71883
  gen.else();
71828
71884
  cxt.error(false, { discrError: types_1.DiscrError.Mapping, tag, tagName });
@@ -71866,18 +71922,18 @@ var require_discriminator = __commonJS({
71866
71922
  if (sch.const) {
71867
71923
  addMapping(sch.const, i3);
71868
71924
  } else if (sch.enum) {
71869
- for (const tagValue of sch.enum) {
71870
- addMapping(tagValue, i3);
71925
+ for (const tagValue2 of sch.enum) {
71926
+ addMapping(tagValue2, i3);
71871
71927
  }
71872
71928
  } else {
71873
71929
  throw new Error(`discriminator: "properties/${tagName}" must have "const" or "enum"`);
71874
71930
  }
71875
71931
  }
71876
- function addMapping(tagValue, i3) {
71877
- if (typeof tagValue != "string" || tagValue in oneOfMapping) {
71932
+ function addMapping(tagValue2, i3) {
71933
+ if (typeof tagValue2 != "string" || tagValue2 in oneOfMapping) {
71878
71934
  throw new Error(`discriminator: "${tagName}" values must be unique strings`);
71879
71935
  }
71880
- oneOfMapping[tagValue] = i3;
71936
+ oneOfMapping[tagValue2] = i3;
71881
71937
  }
71882
71938
  }
71883
71939
  }
@@ -90167,6 +90223,148 @@ var init_wrapper = __esm({
90167
90223
  }
90168
90224
  });
90169
90225
 
90226
+ // services/buzz-wake/protocol.ts
90227
+ function redactDiagnosticSecrets(text9) {
90228
+ return text9.replace(HEX_SECRET, "[redacted]").replace(/\bAuthorization\s*[:=]\s*[^\r\n]+/gi, "Authorization: [redacted]").replace(BEARER_SECRET, "Bearer [redacted]").replace(/\b(?:token|api[_-]?key|password)\s*[:=]\s*(?:"[^"]*"|'[^']*'|[^\s,;]+)/gi, "credential=[redacted]").replace(URL_USERINFO, "$1[redacted]@");
90229
+ }
90230
+ function redactAssignment(_match, name3, value) {
90231
+ const quote = value[0] === '"' || value[0] === "'" ? value[0] : "";
90232
+ return `${name3}${quote}[redacted]${quote}`;
90233
+ }
90234
+ function redactCopySecrets(text9) {
90235
+ return text9.slice(0, 16384).replace(/-----BEGIN [^-\r\n]*PRIVATE KEY-----[\s\S]*?(?:-----END [^-\r\n]*-----|$)/g, "[redacted]").replace(/\bnsec1[02-9ac-hj-np-z]{50,}/gi, "[redacted]").replace(/(\bAuthorization["']?\s*[:=]\s*)(?:(?:Bearer|Basic)\s+)?(\[redacted\]|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[^\s,;}\]]+)/gi, redactAssignment).replace(BEARER_SECRET, "Bearer [redacted]").replace(
90236
+ /((?:["']?[\w-]{0,64}(?:token|secret|password|passwd|api[_-]?key|private[_-]?key|credential|_SEC|_KEY)[\w-]{0,64}["']?)\s*[:=]\s*)(\[redacted\]|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[^\s,;}\]]+)/gi,
90237
+ redactAssignment
90238
+ ).replace(/(?<![a-z0-9+.-])([a-z][a-z0-9+.-]*:\/\/)[^\s/]*@/gi, "$1[redacted]@").replace(/\b(?:sk-(?:ant-)?[A-Za-z0-9_-]{16,}|xai-[A-Za-z0-9_-]+|gh[pousr]_[A-Za-z0-9_]+|github_pat_[A-Za-z0-9_]+|AKIA[0-9A-Z]{16}|AIza[0-9A-Za-z_-]{30,}|xox[abprs]-[A-Za-z0-9-]+|eyJ[A-Za-z0-9_-]{1,512}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+|npm_[A-Za-z0-9_]+|sbp_[A-Za-z0-9_]+|[MNO][A-Za-z0-9_-]{23,128}\.[A-Za-z0-9_-]{6}\.[A-Za-z0-9_-]{27,})/g, "[redacted]").replace(HEX_SECRET, "[redacted]");
90239
+ }
90240
+ function redactCopyPayload(value) {
90241
+ function redact(item, topLevel) {
90242
+ if (typeof item === "string") return redactCopySecrets(item);
90243
+ if (Array.isArray(item)) return item.map((entry2) => redact(entry2, false));
90244
+ if (typeof item === "object" && item !== null) {
90245
+ return Object.fromEntries(Object.entries(item).map(([key, entry2]) => {
90246
+ const sensitive = entry2 !== null && typeof entry2 !== "boolean" && /token|secret|password|passwd|api[_-]?key|private[_-]?key|credential|_SEC|_KEY|^Authorization$/i.test(key);
90247
+ const identifier = topLevel && typeof entry2 === "string" && (key === "in_reply_to" && /^[a-f0-9]{8,64}$/i.test(entry2) || key === "source_event_id" && /^[a-f0-9]{64}$/.test(entry2));
90248
+ return [redactCopySecrets(key), sensitive ? "[redacted]" : identifier ? entry2 : redact(entry2, false)];
90249
+ }));
90250
+ }
90251
+ return item;
90252
+ }
90253
+ return redact(value, true);
90254
+ }
90255
+ function limitCopyText(text9) {
90256
+ const suffix = " [\u2026uci\u0119to]";
90257
+ if (text9.length <= 4e3) return text9;
90258
+ let cut3 = 4e3 - suffix.length;
90259
+ if (/[\uD800-\uDBFF]/.test(text9[cut3 - 1])) cut3--;
90260
+ return text9.slice(0, cut3) + suffix;
90261
+ }
90262
+ function isCopyableJarvisMessage(payload) {
90263
+ return payload.v === 1 && payload.from_role === "jarvis" && payload.to_role === "reksio" && typeof payload.text === "string" && (payload.kind === "chat" || payload.kind === "pointer" || payload.kind === "decision" || payload.kind === "block");
90264
+ }
90265
+ function isEvent(value) {
90266
+ if (typeof value !== "object" || value === null) return false;
90267
+ const record20 = value;
90268
+ return typeof record20.id === "string" && typeof record20.pubkey === "string" && typeof record20.kind === "number" && typeof record20.created_at === "number" && typeof record20.content === "string" && Array.isArray(record20.tags) && typeof record20.sig === "string";
90269
+ }
90270
+ function shortEventId(value) {
90271
+ if (typeof value !== "object" || value === null) return "unknown";
90272
+ const id2 = value.id;
90273
+ return typeof id2 === "string" && /^[a-f0-9]{64}$/i.test(id2) ? id2.slice(0, 8) : "unknown";
90274
+ }
90275
+ function tagValue(event, name3) {
90276
+ return event.tags.find((tag) => tag[0] === name3 && typeof tag[1] === "string")?.[1];
90277
+ }
90278
+ function isJarvisReksioCopy(event, jarvisPublicKey, hermesPublicKey) {
90279
+ if (jarvisPublicKey === void 0 || event.pubkey !== jarvisPublicKey || event.kind !== 9 || tagValue(event, "t") !== JARVIS_COPY_TAG || tagValue(event, "p") !== hermesPublicKey || tagValue(event, "role") !== "hermes") return false;
90280
+ try {
90281
+ const payload = JSON.parse(event.content);
90282
+ if (typeof payload !== "object" || payload === null) return false;
90283
+ const body = payload;
90284
+ return body.v === 1 && body.from_role === "jarvis" && body.to_role === "hermes" && typeof body.source_event_id === "string" && /^[a-f0-9]{64}$/.test(body.source_event_id) && tagValue(event, "e") === body.source_event_id && typeof body.text === "string" && body.text.startsWith("[KOPIA od jarvis do reksio] ");
90285
+ } catch {
90286
+ return false;
90287
+ }
90288
+ }
90289
+ function isCompleteVersionedEnvelope(payload) {
90290
+ return payload.v === 1 && typeof payload.from_role === "string" && typeof payload.kind === "string" && typeof payload.text === "string" && (typeof payload.to_role === "string" || typeof payload.channel === "string");
90291
+ }
90292
+ function isReplyAck(event, context) {
90293
+ try {
90294
+ const payload = JSON.parse(event.content);
90295
+ if (typeof payload !== "object" || payload === null) return false;
90296
+ const envelope = payload;
90297
+ return isCompleteVersionedEnvelope(envelope) && envelope.kind === "ack" && context.channelRole !== void 0 && envelope.from_role === context.channelRole && typeof envelope.to_role === "string" && tagValue(event, "role") === envelope.to_role && /^[a-f0-9]{64}$/i.test(tagValue(event, "p") ?? "") && tagValue(event, "p") !== context.recipientPublicKey;
90298
+ } catch {
90299
+ return false;
90300
+ }
90301
+ }
90302
+ function addressedRole(event, context) {
90303
+ let payload = null;
90304
+ try {
90305
+ const parsed = JSON.parse(event.content);
90306
+ if (typeof parsed === "object" && parsed !== null) payload = parsed;
90307
+ } catch {
90308
+ payload = null;
90309
+ }
90310
+ if (payload?.v === 1 && !isCompleteVersionedEnvelope(payload)) return null;
90311
+ const declaredRole = typeof payload?.to_role === "string" ? payload.to_role : void 0;
90312
+ const taggedRole = tagValue(event, "role");
90313
+ if (isReplyAck(event, context) && context.channelRole === "jarvis" && event.pubkey === context.jarvisPublicKey && declaredRole === "reksio" && context.reksioPublicKey !== void 0 && tagValue(event, "p") === context.reksioPublicKey) return "reksio";
90314
+ if (declaredRole !== void 0) {
90315
+ const expectedPublicKey = context.recipientPublicKey ?? context.ownPublicKey;
90316
+ const channelMatches = context.channelRole === void 0 || context.channelRole === declaredRole;
90317
+ return taggedRole === declaredRole && tagValue(event, "p") === expectedPublicKey && channelMatches ? declaredRole : null;
90318
+ }
90319
+ if (typeof payload?.channel === "string") {
90320
+ return context.shared === true && context.channelRole === payload.channel ? context.channelRole : null;
90321
+ }
90322
+ if (context.channelRole !== void 0 && context.shared === true) return context.channelRole;
90323
+ if (context.channelRole !== void 0 && taggedRole === context.channelRole && tagValue(event, "p") === context.recipientPublicKey) {
90324
+ return context.channelRole;
90325
+ }
90326
+ return null;
90327
+ }
90328
+ function admitChannelEvent(value, context) {
90329
+ const eventId = shortEventId(value);
90330
+ const candidate = typeof value === "object" && value !== null && (value.kind === 9 || value.kind === 40002);
90331
+ const rejected = (reason) => ({ accepted: false, candidate, reason, eventId });
90332
+ if (!isEvent(value)) return rejected("malformed-event");
90333
+ if (!verifyEvent(value)) return rejected("invalid-signature");
90334
+ if (value.kind !== 9 && value.kind !== 40002) return rejected("unsupported-kind");
90335
+ if (value.pubkey === (context.recipientPublicKey ?? context.ownPublicKey) && !isReplyAck(value, context)) return rejected("own-sender");
90336
+ if (!context.allowedSenders.has(value.pubkey)) return rejected("sender-not-in-roster");
90337
+ const now = Math.floor(Date.now() / 1e3);
90338
+ const historicalCopy = context.channelRole === "hermes" && isJarvisReksioCopy(value, context.jarvisPublicKey, context.recipientPublicKey ?? context.ownPublicKey);
90339
+ if (value.created_at < now - MAX_EVENT_AGE_SECONDS && !historicalCopy) return rejected("expired");
90340
+ if (value.created_at > now + MAX_EVENT_AGE_SECONDS) return rejected("future");
90341
+ if (!value.tags.some((tag) => tag[0] === "h" && tag[1] === context.channelId)) return rejected("wrong-channel");
90342
+ return { accepted: true, message: { id: value.id, from: value.pubkey, text: value.content, receivedAt: value.created_at, recipientRole: addressedRole(value, context) } };
90343
+ }
90344
+ function decodeChannelEvent(value, context) {
90345
+ const result = admitChannelEvent(value, context);
90346
+ return result.accepted ? result.message : null;
90347
+ }
90348
+ function channelMembers(value, channelId, relayAuthorityPublicKey) {
90349
+ if (!isEvent(value) || !verifyEvent(value) || value.kind !== 39002) return null;
90350
+ if (value.pubkey !== relayAuthorityPublicKey) return null;
90351
+ if (!value.tags.some((tag) => tag[0] === "d" && tag[1] === channelId)) return null;
90352
+ const members = value.tags.filter((tag) => tag[0] === "p" && /^[a-f0-9]{64}$/i.test(tag[1] ?? "")).map((tag) => tag[1]);
90353
+ return new Set(members);
90354
+ }
90355
+ var HEX_SECRET, BEARER_SECRET, URL_USERINFO, MAX_EVENT_AGE_SECONDS, JARVIS_COPY_TAG;
90356
+ var init_protocol2 = __esm({
90357
+ "services/buzz-wake/protocol.ts"() {
90358
+ "use strict";
90359
+ init_pure();
90360
+ HEX_SECRET = /[a-f0-9]{64}/gi;
90361
+ BEARER_SECRET = /\bBearer\s+[^\s,;]+/gi;
90362
+ URL_USERINFO = /([a-z][a-z0-9+.-]*:\/\/)[^\s/]*@/gi;
90363
+ MAX_EVENT_AGE_SECONDS = 300;
90364
+ JARVIS_COPY_TAG = "jarvis-reksio-copy";
90365
+ }
90366
+ });
90367
+
90170
90368
  // services/buzz-mcp/src/bridge.ts
90171
90369
  var bridge_exports = {};
90172
90370
  __export2(bridge_exports, {
@@ -90340,6 +90538,7 @@ var init_bridge = __esm({
90340
90538
  init_pure();
90341
90539
  init_relay();
90342
90540
  init_wrapper();
90541
+ init_protocol2();
90343
90542
  PAGE_EOSE_DEADLINE_MS = 1e4;
90344
90543
  ZERO_EVENT_ID = "0".repeat(64);
90345
90544
  BuzzToolError = class extends Error {
@@ -90457,6 +90656,23 @@ var init_bridge = __esm({
90457
90656
  const tags = await this.tagsFor(payload);
90458
90657
  return this.publish(payload, tags);
90459
90658
  }
90659
+ /** Internal wake outbox only: stable source timestamp/content produce the same Nostr ID on every retry. */
90660
+ async copyJarvisToHermes(message3) {
90661
+ const parsed = parseContent(message3.text);
90662
+ if (this.options.role !== "jarvis" || message3.from !== this.publicKey || !/^jarvis-copy:[a-f0-9]{64}$/.test(message3.id) || parsed.kind !== "envelope" || parsed.payload.from_role !== "jarvis" || parsed.payload.to_role !== "hermes" || parsed.payload.source_event_id !== message3.id.slice("jarvis-copy:".length)) {
90663
+ throw new BuzzToolError("Invalid Jarvis copy outbox message");
90664
+ }
90665
+ const safe = redactCopyPayload(parsed.payload);
90666
+ const payload = { ...safe, text: limitCopyText(safe.text), source_event_id: message3.id.slice("jarvis-copy:".length) };
90667
+ const event = finalizeEvent({
90668
+ kind: this.options.config.protocol.messageKind,
90669
+ content: JSON.stringify(payload),
90670
+ tags: [...await this.tagsFor(payload), ["t", JARVIS_COPY_TAG], ["e", payload.source_event_id]],
90671
+ created_at: message3.receivedAt
90672
+ }, this.secret);
90673
+ await this.withRelay(async (relay) => relay.publish(event));
90674
+ return { event_id: event.id };
90675
+ }
90460
90676
  async inbox(input = {}) {
90461
90677
  const limit = input.limit ?? 50;
90462
90678
  if (!Number.isInteger(limit) || limit < 1 || limit > 100) throw new BuzzToolError("limit must be an integer from 1 to 100");
@@ -90561,11 +90777,22 @@ var init_bridge = __esm({
90561
90777
  if (!channelId) throw new BuzzToolError("Buzz event has no return channel for acknowledgement");
90562
90778
  return [["p", pubkey], ["role", payload.to_role ?? ""], ["h", channelId]];
90563
90779
  }
90564
- inboxFilters() {
90780
+ inboxFilters(identities) {
90565
90781
  const filters = [{ kinds: [this.options.config.protocol.messageKind], "#p": [this.publicKey] }];
90566
90782
  for (const channelId of this.accessibleChannelIds()) {
90567
90783
  filters.push({ kinds: [this.options.config.protocol.messageKind], "#h": [channelId] });
90568
90784
  }
90785
+ const jarvisField = this.options.config.roles.jarvis?.pubkeyField;
90786
+ const jarvisKey = jarvisField === void 0 ? void 0 : identities.get(jarvisField);
90787
+ if (this.options.role === "hermes" && jarvisKey && this.options.config.roles.hermes?.inboxChannelId) {
90788
+ filters.push({
90789
+ kinds: [this.options.config.protocol.messageKind],
90790
+ authors: [jarvisKey],
90791
+ "#p": [this.publicKey],
90792
+ "#h": [this.options.config.roles.hermes.inboxChannelId],
90793
+ "#t": [JARVIS_COPY_TAG]
90794
+ });
90795
+ }
90569
90796
  return filters;
90570
90797
  }
90571
90798
  isAddressedToMe(payload, event) {
@@ -90632,7 +90859,7 @@ var init_bridge = __esm({
90632
90859
  async collectInbox(relay, limit, sinceCursor, identities) {
90633
90860
  const basePageSize = limit * 3;
90634
90861
  const scanFloor = sinceCursor === void 0 ? 0 : Math.max(0, sinceCursor.seconds - 300);
90635
- const pages = this.inboxFilters().map((filter) => ({ filter, queryLimit: basePageSize, exhausted: false }));
90862
+ const pages = this.inboxFilters(identities).map((filter) => ({ historicalCopy: filter["#t"] !== void 0, filter, queryLimit: basePageSize, exhausted: false }));
90636
90863
  const visited = /* @__PURE__ */ new Set();
90637
90864
  const events = [];
90638
90865
  const errors = [];
@@ -90643,14 +90870,16 @@ var init_bridge = __esm({
90643
90870
  const filters = [{
90644
90871
  ...page.filter,
90645
90872
  limit: page.queryLimit,
90646
- ...scanFloor === void 0 ? {} : { since: scanFloor },
90873
+ ...page.historicalCopy ? {} : { since: scanFloor },
90647
90874
  ...page.until === void 0 ? {} : { until: page.until }
90648
90875
  }];
90649
90876
  const relayEvents = await this.collect(relay, filters);
90650
90877
  for (const event of relayEvents) {
90651
90878
  if (visited.has(event.id)) continue;
90879
+ const jarvisField = this.options.config.roles.jarvis?.pubkeyField;
90880
+ const historicalCopy = page.historicalCopy && this.options.role === "hermes" && isJarvisReksioCopy(event, jarvisField === void 0 ? void 0 : identities.get(jarvisField), this.publicKey);
90881
+ if (event.created_at < scanFloor && !historicalCopy) continue;
90652
90882
  visited.add(event.id);
90653
- if (scanFloor !== void 0 && event.created_at < scanFloor) continue;
90654
90883
  scanned = maxInboxCursor(scanned, { seconds: event.created_at, eventId: event.id, value: `${event.created_at}:${event.id}` });
90655
90884
  if (this.store.has(event.id)) continue;
90656
90885
  const parsed = parseContent(event.content);
@@ -90895,6 +91124,7 @@ var init_store = __esm({
90895
91124
  import_node_sqlite2 = require("node:sqlite");
90896
91125
  import_node_crypto22 = require("node:crypto");
90897
91126
  init_contract();
91127
+ init_protocol2();
90898
91128
  GBOT_COPY_MARKER = /\n\[\[BUZZ_GBOT_REPLY:([a-f0-9]{64}):([^\]\r\n]+)\]\]$/;
90899
91129
  MAX_QUEUE_ATTEMPTS = 10;
90900
91130
  QUEUE_RETRY_DELAYS_MS = [1e3, 5e3, 3e4, 6e4, 3e5];
@@ -91001,7 +91231,44 @@ var init_store = __esm({
91001
91231
  if (!(error48 instanceof Error) || !/duplicate column name/i.test(error48.message)) throw error48;
91002
91232
  }
91003
91233
  }
91004
- enqueue(message3, now, gbotPublicKey) {
91234
+ enqueue(message3, now, gbotPublicKey, jarvisPublicKey) {
91235
+ if (jarvisPublicKey !== void 0 && message3.from === jarvisPublicKey && message3.recipientRole === "reksio" && /^[a-f0-9]{64}$/.test(message3.id)) {
91236
+ let payload;
91237
+ try {
91238
+ const parsed = JSON.parse(message3.text);
91239
+ payload = typeof parsed === "object" && parsed !== null ? parsed : {};
91240
+ } catch {
91241
+ payload = {};
91242
+ }
91243
+ if (isCopyableJarvisMessage(payload)) {
91244
+ const safe = redactCopyPayload(payload);
91245
+ const copy = {
91246
+ ...safe,
91247
+ v: 1,
91248
+ from_role: "jarvis",
91249
+ to_role: "hermes",
91250
+ channel: void 0,
91251
+ kind: safe.kind,
91252
+ mode: "queue",
91253
+ text: limitCopyText(`[KOPIA od jarvis do reksio] ${safe.text}`),
91254
+ source_event_id: message3.id
91255
+ };
91256
+ try {
91257
+ this.database.exec("BEGIN IMMEDIATE");
91258
+ try {
91259
+ this.enqueue(message3, now, gbotPublicKey);
91260
+ this.enqueue({ ...message3, id: `jarvis-copy:${message3.id}`, recipientRole: "hermes", text: JSON.stringify(copy) }, now);
91261
+ this.database.exec("COMMIT");
91262
+ } catch (error48) {
91263
+ this.database.exec("ROLLBACK");
91264
+ throw error48;
91265
+ }
91266
+ } catch (error48) {
91267
+ throw new Error("Jarvis copy durable admission failed", { cause: error48 });
91268
+ }
91269
+ return;
91270
+ }
91271
+ }
91005
91272
  if (gbotPublicKey !== void 0 && message3.from === gbotPublicKey && message3.recipientRole === "control-room") {
91006
91273
  let payload;
91007
91274
  try {
@@ -92138,7 +92405,7 @@ function codexHome() {
92138
92405
  function safeStderr(value, external = false) {
92139
92406
  const source = value instanceof Error ? value.message : typeof value === "string" ? value : "";
92140
92407
  if (!external && source === "") return "";
92141
- const redacted = source.replace(/[a-f0-9]{64}/gi, "[redacted]").replace(/\bAuthorization\s*[:=]\s*[^\r\n]+/gi, "Authorization: [redacted]").replace(/\bBearer\s+[^\s,;]+/gi, "Bearer [redacted]").replace(/\b(?:token|api[_-]?key|password)\s*[:=]\s*(?:"[^"]*"|'[^']*'|[^\s,;]+)/gi, "credential=[redacted]").replace(/([a-z][a-z0-9+.-]*:\/\/)[^\s/]*@/gi, "$1[redacted]@").replace(/\s+/g, " ");
92408
+ const redacted = redactDiagnosticSecrets(source).replace(/\s+/g, " ");
92142
92409
  const internal = /^(?:queue unavailable|ACK refusal notification failed|codex queue could not be started|Buzz mode: (?:invalid mode \(expected queue or steer\)|steer is unsupported for ACK|steer is only supported for Hermes)|(?:ping-window|speedy-send): [A-Z_]+(?: \[redacted\])?|brak trasy wybudzenia dla roli [a-z0-9-]+: rola nie ma skonfigurowanej trasy|(?:permission_denied|authentication_failed|not_found|timeout|connection_refused|symlink_refused|session_queue_full|cli_usage|route_unavailable|diagnostic_unclassified) \[redacted\])$/;
92143
92410
  if (external || !internal.test(source)) {
92144
92411
  const guard2 = source.match(/(?:(ping-window|speedy-send):\s*)?\b((?:[A-Z][A-Z0-9]*_)*(?:MODAL|INPUT)_DEFERRED)\b/);
@@ -92202,6 +92469,7 @@ async function writeFailureTraces(message3, attempt, rc, stderr, dependencies) {
92202
92469
  }
92203
92470
  await appendSecure(dependencies.inboxPath, visible);
92204
92471
  await appendSecure(dependencies.errorPath, visible);
92472
+ if (/^jarvis-copy:[a-f0-9]{64}$/.test(message3.id)) return;
92205
92473
  const payload = parsedJson(message3.text);
92206
92474
  const roles = Object.entries(dependencies.rolePublicKeys ?? {}).filter(([, key]) => key === message3.from).map(([role3]) => role3);
92207
92475
  const sender = roles.length === 1 && payload?.v === 1 && payload.from_role === roles[0] ? roles[0] : void 0;
@@ -92299,6 +92567,23 @@ async function processPending(message3, dependencies) {
92299
92567
  dependencies.store.completeFailureTrace(message3.id, Date.now());
92300
92568
  return;
92301
92569
  }
92570
+ if (/^jarvis-copy:[a-f0-9]{64}$/.test(message3.id)) {
92571
+ dependencies.store.beginQueueAttempt(message3.id, Date.now());
92572
+ let rc = 0, stderr2 = "";
92573
+ try {
92574
+ if (dependencies.publishJarvisCopy === void 0) throw new Error("Jarvis copy publisher unavailable");
92575
+ await dependencies.publishJarvisCopy(message3);
92576
+ } catch (error48) {
92577
+ rc = 1;
92578
+ stderr2 = safeStderr(error48, true);
92579
+ }
92580
+ const attempt2 = dependencies.store.finishQueueAttempt(message3.id, rc, stderr2, Date.now());
92581
+ if (rc !== 0) {
92582
+ await writeFailureTraces(message3, attempt2.attempt, rc, stderr2, dependencies);
92583
+ dependencies.store.completeFailureTrace(message3.id, Date.now());
92584
+ }
92585
+ return;
92586
+ }
92302
92587
  if (message3.queuePickup !== void 0) {
92303
92588
  await checkQueuePickup(message3, dependencies);
92304
92589
  return;
@@ -92626,7 +92911,12 @@ async function retryPending(dependencies) {
92626
92911
  if (pending !== void 0) await processPending(pending, dependencies);
92627
92912
  }
92628
92913
  async function deliver2(message3, dependencies) {
92629
- dependencies.store.enqueue(message3, Date.now(), dependencies.gbotPublicKey);
92914
+ dependencies.store.enqueue(
92915
+ message3,
92916
+ Date.now(),
92917
+ dependencies.gbotPublicKey,
92918
+ dependencies.publishJarvisCopy === void 0 ? void 0 : dependencies.rolePublicKeys?.jarvis
92919
+ );
92630
92920
  await retryPending(dependencies);
92631
92921
  }
92632
92922
  function exactKeys(record20, keys2) {
@@ -92917,6 +93207,7 @@ var init_delivery = __esm({
92917
93207
  import_node_path36 = require("node:path");
92918
93208
  init_store();
92919
93209
  init_agent_route();
93210
+ init_protocol2();
92920
93211
  init_lead_admission();
92921
93212
  SAFE_DIAGNOSTIC_CATEGORY = /^(permission_denied|authentication_failed|not_found|timeout|connection_refused|symlink_refused|session_queue_full|cli_usage|route_unavailable|queue_item_id_missing|queue_not_picked_up|diagnostic_unclassified)(?: \[redacted\])?$/;
92922
93213
  GBOT_READ_INTERVAL_MS = 5e3;
@@ -317074,23 +317365,6 @@ function createWorkerTmpdir(worktree, cardId) {
317074
317365
  throw Object.assign(new Error(`TMPDIR zadania ${cardId}: ${errorText5(error48)}`), { errorCode: "TMPDIR" });
317075
317366
  }
317076
317367
  }
317077
- function taskBriefHash(card) {
317078
- const d = card.details ?? {};
317079
- const dutyDetails = d;
317080
- return (0, import_node_crypto32.createHash)("sha256").update(JSON.stringify([
317081
- card.title,
317082
- card.specRef,
317083
- d.seed_brief,
317084
- d.seed_spec,
317085
- d.seed_scope,
317086
- d.scope,
317087
- d.done_when ?? d.doneWhen ?? d.acceptance,
317088
- d.boundaries,
317089
- d.outcome,
317090
- d.out,
317091
- asRecord3(asRecord3(dutyDetails.unblock).verdict).note
317092
- ])).digest("hex");
317093
- }
317094
317368
  function seedBriefIdentity(card) {
317095
317369
  const declared = card.details?.seed_brief_sha256;
317096
317370
  return typeof declared === "string" && /^[a-f0-9]{64}$/i.test(declared) ? declared : briefSha(card.details, card.seedBriefDigest);
@@ -317151,15 +317425,16 @@ function actionableBlockerRecovery(card, predecessors) {
317151
317425
  const previous = prior.blocker_depends_on;
317152
317426
  return card.dependsOn.some((id2) => predecessors.get(id2)?.id === id2 && (!previous.includes(id2) || isStringArray(prior.blocker_resolved_depends_on) && !prior.blocker_resolved_depends_on.includes(id2) && factoryDependenciesReady({ ...card, dependsOn: [id2] }, predecessors)));
317153
317427
  }
317154
- function actionableBlockerHold(card, predecessors) {
317428
+ function actionableBlockerHold(card, predecessors, fingerprint) {
317155
317429
  const details2 = card.details ?? {};
317156
317430
  const prior = asRecord3(details2.maszynista);
317157
317431
  if (prior.outcome !== "ACTIONABLE_BLOCKER" || !("blocker_seed_brief_sha256" in prior)) return null;
317158
317432
  const declared = details2.seed_brief_sha256, calculated = briefSha(card.details, card.seedBriefDigest);
317159
317433
  if (typeof declared === "string" && /^[a-f0-9]{64}$/i.test(declared) && calculated !== null && declared.toLowerCase() !== calculated)
317160
317434
  return `ACTIONABLE_BLOCKER: niezgodny seed_brief_sha256; zapisany ${declared}, obliczony ${calculated}`;
317435
+ if ((card.status === "ready" || card.status === "in_progress") && typeof declared === "string" && /^[a-f0-9]{64}$/i.test(declared) && calculated !== null && declared.toLowerCase() === calculated && changedBlockerInput(prior, fingerprint)) return null;
317161
317436
  if (actionableBlockerRecovery(card, predecessors)) return null;
317162
- return "ACTIONABLE_BLOCKER: seed_brief_sha256 bez zmian; wymagany nowy brief albo depends_on na nierozwi\u0105zan\u0105 kart\u0119-przeszkod\u0119";
317437
+ return "ACTIONABLE_BLOCKER: seed_brief_sha256 bez zmian; wymagany nowy brief albo depends_on na nierozwi\u0105zan\u0105 kart\u0119-przeszkod\u0119 albo zmiana tre\u015Bci karty (done_when, scope, boundaries, outcome)";
317163
317438
  }
317164
317439
  async function recoverBlockedWorkers(s, uid, projectId2, dry = DRY2, pending) {
317165
317440
  if (dry) return;
@@ -317272,10 +317547,6 @@ function ringDraftChanges(cards, dry = DRY2) {
317272
317547
  log2(`zasiew bell: ${errorText5(error48)}`);
317273
317548
  }
317274
317549
  }
317275
- function taskInputHash(card, effort) {
317276
- const brief2 = hasDutyNote(card.details) ? card : { ...card, details: { ...card.details, unblock: void 0 } };
317277
- return (0, import_node_crypto32.createHash)("sha256").update(JSON.stringify([taskBriefHash(brief2), effort, card.details?.codex_model ?? null])).digest("hex");
317278
- }
317279
317550
  function defaultNpmCacheCleanup() {
317280
317551
  const result = (0, import_node_child_process21.spawnSync)("npm", ["cache", "clean", "--force"], { cwd: REPO, encoding: "utf8", timeout: remainingTickMs(12e4) });
317281
317552
  if (result.error) throw result.error;
@@ -325293,13 +325564,13 @@ async function dispatchCard(s, uid, projectId2, c, selection, installation, clie
325293
325564
  log2(`dispatch ${c.id}: zmiana to\u017Csamo\u015Bci przy CAS; zachowuj\u0119 nowsz\u0105 pr\xF3b\u0119`);
325294
325565
  return false;
325295
325566
  }
325296
- c = { ...c, ...reserved2 };
325297
- const blockerHold = actionableBlockerHold(c, evidence2 ?? /* @__PURE__ */ new Map());
325567
+ c = { ...c, ...reserved2, seedBriefDigest: void 0 };
325568
+ const qualification = qualifyCard({ ...c, trackName: c.targetTrackName });
325569
+ const inputFingerprint = taskInputHash(c, qualifiedEffort(c, qualification));
325570
+ const blockerHold = actionableBlockerHold(c, evidence2 ?? /* @__PURE__ */ new Map(), inputFingerprint);
325298
325571
  if (blockerHold) throw new DispatchHold(blockerHold);
325299
325572
  if (malformedStreak) throw new DispatchHold("ACTIONABLE: wadliwy details.maszynista.dispatch_failure_streak; zachowano dane, wymagana korekta CR");
325300
- const qualification = c.qualification;
325301
- if (!qualification?.effort || !qualification.trackName || !c.targetTrackName) throw new Error("karta bez poprawnej kwalifikacji");
325302
- const inputFingerprint = taskInputHash(c, qualifiedEffort(c, qualification));
325573
+ if (!qualification.effort || !qualification.trackName || !c.targetTrackName) throw new Error("karta bez poprawnej kwalifikacji");
325303
325574
  const hold2 = actionableBlockerRecovery(c, evidence2 ?? /* @__PURE__ */ new Map()) ? null : redispatchHold(asRecord3(c.details?.maszynista), inputFingerprint, Date.now());
325304
325575
  if (hold2) {
325305
325576
  unchangedInputHold = true;
@@ -325459,7 +325730,7 @@ Pliki konfliktu: ${markers2.join(", ")}. usu\u0144 markery zachowuj\u0105c obie
325459
325730
  const northStar = await loadNorthStar2(uid, installation);
325460
325731
  let builtBrief;
325461
325732
  try {
325462
- builtBrief = buildBrief(c, northStar, { worktree, branch, env: workerEnv2, installationBrief: installation?.installationBrief });
325733
+ builtBrief = buildBrief(c, northStar, { worktree, branch, inputFingerprint, env: workerEnv2, installationBrief: installation?.installationBrief });
325463
325734
  } catch (error48) {
325464
325735
  if (error48 instanceof Error && (error48.message === `ACTIONABLE: karta ${c.id}: brak rozstrzygalnego pakietu seed_*` || error48.message.startsWith(`ACTIONABLE: brief karty ${c.id} ma `) && / bajtów, limit 32768;/.test(error48.message)))
325465
325736
  throw new DispatchHold(error48.message);
@@ -327245,7 +327516,24 @@ async function dispatchNext(s, uid, projectId2, diskDependencies, cards = /* @__
327245
327516
  const candidates2 = freshRows.filter((card) => card.status === "ready").map((card) => ({ ...card, details: card.details }));
327246
327517
  const predecessors = await factoryPredecessors(uid, candidates2, new Map([...cards, ...freshRows.map((row) => [row.id, row])]));
327247
327518
  const ready = [];
327248
- for (const card of candidates2) {
327519
+ for (let card of candidates2) {
327520
+ const prior = asRecord3(card.details?.maszynista);
327521
+ let inputFingerprint;
327522
+ if (prior.outcome === "ACTIONABLE_BLOCKER" && typeof prior.input_sha256 === "string" && /^[a-f0-9]{64}$/.test(prior.input_sha256)) {
327523
+ try {
327524
+ const full = await getTask2(uid, card.id);
327525
+ if (!full || full.status !== "ready") {
327526
+ skipReady(card, "ACTIONABLE_BLOCKER: pe\u0142na karta nie jest ready lub brak odczytu");
327527
+ continue;
327528
+ }
327529
+ card = { ...card, ...full, seedBriefDigest: void 0 };
327530
+ const qualification2 = qualifyCard({ ...card, trackName: card.trackId ? labels.get(card.trackId) ?? null : null });
327531
+ inputFingerprint = taskInputHash(card, qualifiedEffort(card, qualification2));
327532
+ } catch (error48) {
327533
+ skipReady(card, `ACTIONABLE_BLOCKER: odczyt pe\u0142nego wej\u015Bcia: ${errorText5(error48)}`);
327534
+ continue;
327535
+ }
327536
+ }
327249
327537
  if (card.details?.reksio_withheld === true) {
327250
327538
  skipReady(card, "wstrzymany przez Reksia: reksio_withheld=true");
327251
327539
  continue;
@@ -327255,7 +327543,7 @@ async function dispatchNext(s, uid, projectId2, diskDependencies, cards = /* @__
327255
327543
  skipReady(card, "wybrany model zaj\u0119ty; odroczenie 10 min");
327256
327544
  continue;
327257
327545
  }
327258
- const blockerHold = actionableBlockerHold(card, predecessors);
327546
+ const blockerHold = actionableBlockerHold(card, predecessors, inputFingerprint);
327259
327547
  if (blockerHold) {
327260
327548
  skipReady(card, blockerHold);
327261
327549
  continue;