pi-herdsman 0.40.0 → 0.41.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.
@@ -10,7 +10,7 @@ import {
10
10
  openSync as openSync4,
11
11
  readFileSync as readFileSync6,
12
12
  renameSync as renameSync5,
13
- rmSync as rmSync2,
13
+ rmSync,
14
14
  writeSync as writeSync2,
15
15
  writeFileSync as writeFileSync4
16
16
  } from "node:fs";
@@ -483,7 +483,7 @@ function nodeOnlyAgentDir() {
483
483
  if (directory2 === "~") return homedir();
484
484
  if (directory2.startsWith("~/") || process.platform === "win32" && directory2.startsWith("~\\"))
485
485
  return join2(homedir(), directory2.slice(2));
486
- if (/^file:\/\//.test(directory2)) return fileURLToPath(directory2);
486
+ if (directory2.startsWith("file://")) return fileURLToPath(directory2);
487
487
  return directory2;
488
488
  }
489
489
  function validateResultId(requestId) {
@@ -839,7 +839,7 @@ function withChiefMessageLock(path, operation) {
839
839
  function writeChiefMessage(record, runtime2 = supervisionRuntime(), clearQuarantine = true) {
840
840
  if (!record.build)
841
841
  throw new Error("Coordination message build identity is required");
842
- if (!validMessage(record) || record.bodyRef !== void 0)
842
+ if (!validMessage(record) || Reflect.get(record, "bodyRef") !== void 0)
843
843
  throw new Error("Invalid Chief message record");
844
844
  return withChiefMessageLock(
845
845
  chiefMessagePath(runtime2, record.toSessionId, record.id),
@@ -1162,7 +1162,9 @@ function validProjectAssignment(value) {
1162
1162
  ];
1163
1163
  return required.every((key) => Object.hasOwn(r, key)) && Object.keys(r).every(
1164
1164
  (key) => required.includes(key) || optional.includes(key)
1165
- ) && Object.keys(r).length >= required.length && r.version === 2 && UUID2.test(String(r.id)) && validNativeIdentity(r.repoKey) && validNativeIdentity(r.branch) && typeof r.text === "string" && r.text.length > 0 && (r.gitBaselineSha === void 0 || typeof r.gitBaselineSha === "string" && /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u.test(r.gitBaselineSha)) && (r.checkoutPath === void 0 || typeof r.checkoutPath === "string" && isAbsolute(r.checkoutPath) && normalize(r.checkoutPath) === r.checkoutPath && !/[\u0000-\u001f]/.test(r.checkoutPath)) && (r.piSessionFile === void 0 || typeof r.piSessionFile === "string" && r.piSessionFile.length > 0) && (r.resultBindings === void 0 || Array.isArray(r.resultBindings) && r.resultBindings.every(isResultBinding)) && (r.requiredEvidence === void 0 || Array.isArray(r.requiredEvidence) && r.requiredEvidence.every(isRequiredEvidence) && r.requiredEvidence.every(
1165
+ ) && Object.keys(r).length >= required.length && r.version === 2 && UUID2.test(String(r.id)) && validNativeIdentity(r.repoKey) && validNativeIdentity(r.branch) && typeof r.text === "string" && r.text.length > 0 && (r.gitBaselineSha === void 0 || typeof r.gitBaselineSha === "string" && /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u.test(r.gitBaselineSha)) && (r.checkoutPath === void 0 || typeof r.checkoutPath === "string" && isAbsolute(r.checkoutPath) && normalize(r.checkoutPath) === r.checkoutPath && ![...r.checkoutPath].some(
1166
+ (character) => character.charCodeAt(0) <= 31
1167
+ )) && (r.piSessionFile === void 0 || typeof r.piSessionFile === "string" && r.piSessionFile.length > 0) && (r.resultBindings === void 0 || Array.isArray(r.resultBindings) && r.resultBindings.every(isResultBinding)) && (r.requiredEvidence === void 0 || Array.isArray(r.requiredEvidence) && r.requiredEvidence.every(isRequiredEvidence) && r.requiredEvidence.every(
1166
1168
  (evidence) => "result" in evidence || evidence.sourceAssignmentId === r.id
1167
1169
  ) && new Set(r.requiredEvidence.map((evidence) => evidence.id)).size === r.requiredEvidence.length) && (r.currentEvidenceIds === void 0 || Array.isArray(r.currentEvidenceIds) && new Set(r.currentEvidenceIds).size === r.currentEvidenceIds.length && r.currentEvidenceIds.every(
1168
1170
  (id) => typeof id === "string" && r.requiredEvidence?.some(
@@ -1350,9 +1352,14 @@ function peerPayloadDigest(value) {
1350
1352
 
1351
1353
  // extension/peer-correspondence.ts
1352
1354
  function validPeerDisplayText(value) {
1353
- return typeof value === "string" && value.trim().length > 0 && value.length <= 512 && !/[\u0000-\u001f\u007f-\u009f\u061c\u200e\u200f\u2028-\u202e\u2066-\u2069]/u.test(
1354
- value
1355
- );
1355
+ if (typeof value !== "string" || value.trim().length === 0 || value.length > 512)
1356
+ return false;
1357
+ for (const character of value) {
1358
+ const code = character.codePointAt(0);
1359
+ if (code >= 0 && code <= 31 || code >= 127 && code <= 159 || code === 1564 || code === 8206 || code === 8207 || code >= 8232 && code <= 8238 || code >= 8294 && code <= 8297)
1360
+ return false;
1361
+ }
1362
+ return true;
1356
1363
  }
1357
1364
  function validOriginDisplay(value) {
1358
1365
  if (!value || typeof value !== "object" || Array.isArray(value)) return false;
@@ -1953,10 +1960,13 @@ if (action === "probe") {
1953
1960
  }
1954
1961
  } finally {
1955
1962
  if (fd !== void 0) closeSync4(fd);
1956
- rmSync2(temp, { force: true });
1963
+ rmSync(temp, { force: true });
1957
1964
  }
1958
1965
  if (!acceptedRace) afterDurablePeerAcceptanceStep("pending-marker-durable");
1959
1966
  }
1967
+ if (!Array.isArray(envelope.attachments) || envelope.attachments.length > 32)
1968
+ throw new Error("invalid peer transfer evidence");
1969
+ const attachments = envelope.attachments;
1960
1970
  acceptTransfer: {
1961
1971
  if (acceptedRace) {
1962
1972
  console.log(JSON.stringify({ accepted: true, id: record.id }));
@@ -1966,7 +1976,7 @@ if (action === "probe") {
1966
1976
  throw new Error("peer correspondence does not match message route");
1967
1977
  const receivedRefs = [];
1968
1978
  let receivedText = record.text;
1969
- for (const attachment of envelope.attachments) {
1979
+ for (const attachment of attachments) {
1970
1980
  if (typeof attachment.name !== "string" || typeof attachment.marker !== "string" || typeof attachment.text !== "string" || typeof attachment.sha256 !== "string" || !/^[0-9a-f]{64}$/u.test(attachment.sha256))
1971
1981
  throw new Error("invalid peer attachment metadata");
1972
1982
  const contentDigest = createHash7("sha256").update(attachment.text, "utf8").digest("hex");
@@ -2044,11 +2054,11 @@ ${receivedRefs.join("\n")}`
2044
2054
  );
2045
2055
  renameSync5(pendingTemp, marker);
2046
2056
  } finally {
2047
- rmSync2(pendingTemp, { force: true });
2057
+ rmSync(pendingTemp, { force: true });
2048
2058
  }
2049
2059
  syncDirectory(markerDir);
2050
2060
  }
2051
- for (const attachment of envelope.attachments) {
2061
+ for (const attachment of attachments) {
2052
2062
  const binding = record.resultBindings?.find(
2053
2063
  (item) => item.ref === attachment.ref
2054
2064
  );
@@ -2064,7 +2074,7 @@ ${receivedRefs.join("\n")}`
2064
2074
  );
2065
2075
  }
2066
2076
  } else {
2067
- for (const attachment of envelope.attachments) {
2077
+ for (const attachment of attachments) {
2068
2078
  const binding = record.resultBindings?.find(
2069
2079
  (item) => item.ref === attachment.ref
2070
2080
  );
@@ -2146,7 +2156,7 @@ ${receivedRefs.join("\n")}`
2146
2156
  afterAcceptedMarkerTempWriteForTests(markerTemp, marker);
2147
2157
  renameSync5(markerTemp, marker);
2148
2158
  } finally {
2149
- rmSync2(markerTemp, { force: true });
2159
+ rmSync(markerTemp, { force: true });
2150
2160
  }
2151
2161
  syncDirectory(markerDir);
2152
2162
  console.log(