poe-code 3.0.268 → 3.0.269

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.
@@ -44455,6 +44455,246 @@ init_src9();
44455
44455
  import { lstat as lstat8, mkdir as mkdir10, readFile as readFile11, readdir as readdir9, rename as rename6, stat as stat7, unlink as unlink6, writeFile as writeFile6 } from "node:fs/promises";
44456
44456
  import { homedir as homedir4 } from "node:os";
44457
44457
 
44458
+ // packages/agent-code-review/src/document-schemas.ts
44459
+ import { basename as basename2 } from "node:path";
44460
+ import { parse as load, stringify as stringify3 } from "yaml";
44461
+ var CODE_REVIEW_PROMPT_ROLES = [
44462
+ "orchestrator",
44463
+ "subagent",
44464
+ "agent",
44465
+ "profile-synthesis"
44466
+ ];
44467
+ var FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/;
44468
+ var SAFE_SEGMENT_RE = /^[A-Za-z0-9._-]+$/;
44469
+ var SAFE_GITHUB_ACTOR_RE = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/;
44470
+ function requireSafeDocumentSegment(value, field) {
44471
+ if (typeof value !== "string" || value.trim() !== value || value.normalize("NFKC") !== value || !SAFE_SEGMENT_RE.test(value) || value.startsWith(".") || value === "." || value === "..") {
44472
+ throw new Error(`${field} must be a safe path segment.`);
44473
+ }
44474
+ return value;
44475
+ }
44476
+ function requireGitHubActorName(value, field) {
44477
+ if (typeof value !== "string" || !SAFE_GITHUB_ACTOR_RE.test(value)) {
44478
+ throw new Error(`${field} must be a safe GitHub actor name.`);
44479
+ }
44480
+ return value;
44481
+ }
44482
+ function parseCodeReviewProfileMarkdown(content, filePath) {
44483
+ const parsed = parseOptionalFrontmatter(content, filePath);
44484
+ if (!parsed.frontmatter) {
44485
+ return { content: parsed.body };
44486
+ }
44487
+ const metadata = requireMapping(parsed.frontmatter, filePath, "frontmatter");
44488
+ requireOnlyFields(metadata, filePath, "frontmatter", ["version", "name"]);
44489
+ requireVersion(metadata.version, filePath, "frontmatter.version");
44490
+ const name = requireSafeDocumentSegment(metadata.name, `${filePath}: frontmatter.name`);
44491
+ if (basename2(filePath, ".md") !== name) {
44492
+ throw invalidField(filePath, "frontmatter.name", "must match the filename");
44493
+ }
44494
+ return { content: parsed.body, metadata: { version: 1, name } };
44495
+ }
44496
+ function parseCodeReviewPromptMarkdown(content, filePath, role) {
44497
+ const parsed = parseOptionalFrontmatter(content, filePath);
44498
+ if (!parsed.frontmatter) {
44499
+ return { content: parsed.body };
44500
+ }
44501
+ const metadata = requireMapping(parsed.frontmatter, filePath, "frontmatter");
44502
+ requireOnlyFields(metadata, filePath, "frontmatter", ["version", "role"]);
44503
+ requireVersion(metadata.version, filePath, "frontmatter.version");
44504
+ if (!CODE_REVIEW_PROMPT_ROLES.includes(metadata.role)) {
44505
+ throw invalidField(filePath, "frontmatter.role", "is not a supported role");
44506
+ }
44507
+ const promptRole = metadata.role;
44508
+ if (role !== void 0 && promptRole !== role) {
44509
+ throw invalidField(filePath, "frontmatter.role", `must equal ${role}`);
44510
+ }
44511
+ return { content: parsed.body, metadata: { version: 1, role: promptRole } };
44512
+ }
44513
+ function parseCodeReviewIngestSource(content, filePath = "code-review ingest source.yaml") {
44514
+ try {
44515
+ const source = requireMapping(load(content), filePath, "document");
44516
+ requireOnlyFields(source, filePath, "document", [
44517
+ "version",
44518
+ "username",
44519
+ "repos",
44520
+ "fetched_at",
44521
+ "output_profile_path",
44522
+ "pagination",
44523
+ "rate_limit"
44524
+ ]);
44525
+ requireVersion(source.version, filePath, "version");
44526
+ const username = requireGitHubActorName(source.username, `${filePath}: username`);
44527
+ if (!Array.isArray(source.repos) || source.repos.length === 0) {
44528
+ throw invalidField(filePath, "repos", "must be a non-empty array");
44529
+ }
44530
+ const repos = source.repos.map((repo, index) => requireRepo(repo, filePath, `repos[${index}]`));
44531
+ const fetchedAt = requireDate(source.fetched_at, filePath, "fetched_at");
44532
+ if (typeof source.output_profile_path !== "string" || !source.output_profile_path) {
44533
+ throw invalidField(filePath, "output_profile_path", "must be a non-empty string");
44534
+ }
44535
+ const pagination = requireMapping(source.pagination, filePath, "pagination");
44536
+ requireOnlyFields(pagination, filePath, "pagination", [
44537
+ "partial",
44538
+ "comments_written",
44539
+ "resume_endpoint"
44540
+ ]);
44541
+ if (typeof pagination.partial !== "boolean") {
44542
+ throw invalidField(filePath, "pagination.partial", "must be a boolean");
44543
+ }
44544
+ const commentsWritten = requireNonNegativeInteger(
44545
+ pagination.comments_written,
44546
+ filePath,
44547
+ "pagination.comments_written"
44548
+ );
44549
+ const resumeEndpoint = optionalString(
44550
+ pagination.resume_endpoint,
44551
+ filePath,
44552
+ "pagination.resume_endpoint"
44553
+ );
44554
+ let rateLimit = null;
44555
+ if (source.rate_limit !== null) {
44556
+ const rate = requireMapping(source.rate_limit, filePath, "rate_limit");
44557
+ requireOnlyFields(rate, filePath, "rate_limit", [
44558
+ "repo",
44559
+ "limit",
44560
+ "remaining",
44561
+ "reset_at",
44562
+ "retry_after",
44563
+ "partial_results",
44564
+ "reason"
44565
+ ]);
44566
+ const reason = optionalString(rate.reason, filePath, "rate_limit.reason");
44567
+ if (reason !== void 0 && !["low_remaining", "primary", "secondary"].includes(
44568
+ reason
44569
+ )) {
44570
+ throw invalidField(filePath, "rate_limit.reason", "is not supported");
44571
+ }
44572
+ rateLimit = {
44573
+ repo: requireRepo(rate.repo, filePath, "rate_limit.repo"),
44574
+ limit: rate.limit === null || rate.limit === void 0 ? null : requireNonNegativeInteger(rate.limit, filePath, "rate_limit.limit"),
44575
+ remaining: rate.remaining === null ? null : requireNonNegativeInteger(rate.remaining, filePath, "rate_limit.remaining"),
44576
+ resetAt: rate.reset_at === null ? null : requireDate(rate.reset_at, filePath, "rate_limit.reset_at"),
44577
+ retryAfter: rate.retry_after === null || rate.retry_after === void 0 ? null : optionalString(rate.retry_after, filePath, "rate_limit.retry_after") ?? null,
44578
+ partialResults: requireNonNegativeInteger(
44579
+ rate.partial_results,
44580
+ filePath,
44581
+ "rate_limit.partial_results"
44582
+ ),
44583
+ reason: reason ?? "low_remaining"
44584
+ };
44585
+ }
44586
+ return {
44587
+ version: 1,
44588
+ username,
44589
+ repos,
44590
+ fetchedAt,
44591
+ outputProfilePath: source.output_profile_path,
44592
+ pagination: {
44593
+ partial: pagination.partial,
44594
+ commentsWritten,
44595
+ ...resumeEndpoint === void 0 ? {} : { resumeEndpoint }
44596
+ },
44597
+ rateLimit
44598
+ };
44599
+ } catch (error2) {
44600
+ if (error2 instanceof Error && error2.message.startsWith(`${filePath}:`)) {
44601
+ throw error2;
44602
+ }
44603
+ throw new Error(`${filePath}: invalid YAML: ${errorMessage(error2)}`);
44604
+ }
44605
+ }
44606
+ function serializeCodeReviewIngestSource(source, filePath = "code-review ingest source.yaml") {
44607
+ const content = stringify3(
44608
+ {
44609
+ version: source.version,
44610
+ username: source.username,
44611
+ repos: source.repos,
44612
+ fetched_at: source.fetchedAt,
44613
+ pagination: {
44614
+ partial: source.pagination.partial,
44615
+ comments_written: source.pagination.commentsWritten,
44616
+ ...source.pagination.resumeEndpoint === void 0 ? {} : { resume_endpoint: source.pagination.resumeEndpoint }
44617
+ },
44618
+ rate_limit: source.rateLimit === null ? null : {
44619
+ repo: source.rateLimit.repo,
44620
+ limit: source.rateLimit.limit,
44621
+ remaining: source.rateLimit.remaining,
44622
+ reset_at: source.rateLimit.resetAt,
44623
+ retry_after: source.rateLimit.retryAfter,
44624
+ partial_results: source.rateLimit.partialResults,
44625
+ reason: source.rateLimit.reason
44626
+ },
44627
+ output_profile_path: source.outputProfilePath
44628
+ },
44629
+ { aliasDuplicateObjects: false, lineWidth: 0 }
44630
+ );
44631
+ parseCodeReviewIngestSource(content, filePath);
44632
+ return content;
44633
+ }
44634
+ function parseOptionalFrontmatter(content, filePath) {
44635
+ const match = content.match(FRONTMATTER_RE);
44636
+ if (!match) {
44637
+ return { body: content };
44638
+ }
44639
+ try {
44640
+ return { frontmatter: load(match[1]), body: match[2] };
44641
+ } catch (error2) {
44642
+ throw new Error(`${filePath}: invalid frontmatter YAML: ${errorMessage(error2)}`);
44643
+ }
44644
+ }
44645
+ function requireMapping(value, filePath, field) {
44646
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
44647
+ throw invalidField(filePath, field, "must be a YAML mapping");
44648
+ }
44649
+ return value;
44650
+ }
44651
+ function requireVersion(value, filePath, field) {
44652
+ if (value !== 1) {
44653
+ throw invalidField(filePath, field, "must equal 1");
44654
+ }
44655
+ }
44656
+ function requireOnlyFields(value, filePath, field, allowedFields) {
44657
+ const allowed = new Set(allowedFields);
44658
+ for (const key2 of Object.keys(value)) {
44659
+ if (!allowed.has(key2)) {
44660
+ throw invalidField(filePath, `${field}.${key2}`, "is not supported");
44661
+ }
44662
+ }
44663
+ }
44664
+ function requireRepo(value, filePath, field) {
44665
+ if (typeof value !== "string" || !/^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/.test(value)) {
44666
+ throw invalidField(filePath, field, "must be a safe owner/repository name");
44667
+ }
44668
+ return value;
44669
+ }
44670
+ function requireDate(value, filePath, field) {
44671
+ if (typeof value !== "string" || Number.isNaN(Date.parse(value))) {
44672
+ throw invalidField(filePath, field, "must be a valid timestamp");
44673
+ }
44674
+ return value;
44675
+ }
44676
+ function requireNonNegativeInteger(value, filePath, field) {
44677
+ if (!Number.isSafeInteger(value) || value < 0) {
44678
+ throw invalidField(filePath, field, "must be a non-negative integer");
44679
+ }
44680
+ return value;
44681
+ }
44682
+ function optionalString(value, filePath, field) {
44683
+ if (value === void 0) {
44684
+ return void 0;
44685
+ }
44686
+ if (typeof value !== "string" || value.length === 0) {
44687
+ throw invalidField(filePath, field, "must be a non-empty string");
44688
+ }
44689
+ return value;
44690
+ }
44691
+ function invalidField(filePath, field, reason) {
44692
+ return new Error(`${filePath}: ${field} ${reason}.`);
44693
+ }
44694
+ function errorMessage(error2) {
44695
+ return error2 instanceof Error ? error2.message : String(error2);
44696
+ }
44697
+
44458
44698
  // packages/agent-code-review/src/error-codes.ts
44459
44699
  function hasOwnErrorCode14(error2, code) {
44460
44700
  return error2 instanceof Error && Object.prototype.hasOwnProperty.call(error2, "code") && error2.code === code;
@@ -45529,249 +45769,6 @@ async function* fetchReviewHistory(options) {
45529
45769
  }
45530
45770
  }
45531
45771
 
45532
- // packages/agent-code-review/src/document-schemas.ts
45533
- import { basename as basename2 } from "node:path";
45534
- import { parse as load, stringify as stringify3 } from "yaml";
45535
- var CODE_REVIEW_PROMPT_ROLES = [
45536
- "orchestrator",
45537
- "subagent",
45538
- "agent",
45539
- "profile-synthesis"
45540
- ];
45541
- var FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/;
45542
- var SAFE_SEGMENT_RE = /^[A-Za-z0-9._-]+$/;
45543
- var SAFE_GITHUB_ACTOR_RE = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$/;
45544
- function requireSafeDocumentSegment(value, field) {
45545
- if (typeof value !== "string" || value.trim() !== value || value.normalize("NFKC") !== value || !SAFE_SEGMENT_RE.test(value) || value.startsWith(".") || value === "." || value === "..") {
45546
- throw new Error(`${field} must be a safe path segment.`);
45547
- }
45548
- return value;
45549
- }
45550
- function requireGitHubActorName(value, field) {
45551
- if (typeof value !== "string" || !SAFE_GITHUB_ACTOR_RE.test(value)) {
45552
- throw new Error(`${field} must be a safe GitHub actor name.`);
45553
- }
45554
- return value;
45555
- }
45556
- function parseCodeReviewProfileMarkdown(content, filePath) {
45557
- const parsed = parseOptionalFrontmatter(content, filePath);
45558
- if (!parsed.frontmatter) {
45559
- return { content: parsed.body };
45560
- }
45561
- const metadata = requireMapping(parsed.frontmatter, filePath, "frontmatter");
45562
- requireOnlyFields(metadata, filePath, "frontmatter", ["version", "name"]);
45563
- requireVersion(metadata.version, filePath, "frontmatter.version");
45564
- const name = requireSafeDocumentSegment(metadata.name, `${filePath}: frontmatter.name`);
45565
- if (basename2(filePath, ".md") !== name) {
45566
- throw invalidField(filePath, "frontmatter.name", "must match the filename");
45567
- }
45568
- return { content: parsed.body, metadata: { version: 1, name } };
45569
- }
45570
- function parseCodeReviewPromptMarkdown(content, filePath, role) {
45571
- const parsed = parseOptionalFrontmatter(content, filePath);
45572
- if (!parsed.frontmatter) {
45573
- return { content: parsed.body };
45574
- }
45575
- const metadata = requireMapping(parsed.frontmatter, filePath, "frontmatter");
45576
- requireOnlyFields(metadata, filePath, "frontmatter", ["version", "role"]);
45577
- requireVersion(metadata.version, filePath, "frontmatter.version");
45578
- if (!CODE_REVIEW_PROMPT_ROLES.includes(metadata.role)) {
45579
- throw invalidField(filePath, "frontmatter.role", "is not a supported role");
45580
- }
45581
- const promptRole = metadata.role;
45582
- if (role !== void 0 && promptRole !== role) {
45583
- throw invalidField(filePath, "frontmatter.role", `must equal ${role}`);
45584
- }
45585
- return { content: parsed.body, metadata: { version: 1, role: promptRole } };
45586
- }
45587
- function parseCodeReviewIngestSource(content, filePath = "code-review ingest source.yaml") {
45588
- try {
45589
- const source = requireMapping(load(content), filePath, "document");
45590
- requireOnlyFields(source, filePath, "document", [
45591
- "version",
45592
- "username",
45593
- "repos",
45594
- "fetched_at",
45595
- "output_profile_path",
45596
- "pagination",
45597
- "rate_limit"
45598
- ]);
45599
- requireVersion(source.version, filePath, "version");
45600
- const username = requireGitHubActorName(source.username, `${filePath}: username`);
45601
- if (!Array.isArray(source.repos) || source.repos.length === 0) {
45602
- throw invalidField(filePath, "repos", "must be a non-empty array");
45603
- }
45604
- const repos = source.repos.map((repo, index) => requireRepo(repo, filePath, `repos[${index}]`));
45605
- const fetchedAt = requireDate(source.fetched_at, filePath, "fetched_at");
45606
- if (typeof source.output_profile_path !== "string" || !source.output_profile_path) {
45607
- throw invalidField(filePath, "output_profile_path", "must be a non-empty string");
45608
- }
45609
- const pagination = requireMapping(source.pagination, filePath, "pagination");
45610
- requireOnlyFields(pagination, filePath, "pagination", [
45611
- "partial",
45612
- "comments_written",
45613
- "resume_endpoint"
45614
- ]);
45615
- if (typeof pagination.partial !== "boolean") {
45616
- throw invalidField(filePath, "pagination.partial", "must be a boolean");
45617
- }
45618
- const commentsWritten = requireNonNegativeInteger(
45619
- pagination.comments_written,
45620
- filePath,
45621
- "pagination.comments_written"
45622
- );
45623
- const resumeEndpoint = optionalString(
45624
- pagination.resume_endpoint,
45625
- filePath,
45626
- "pagination.resume_endpoint"
45627
- );
45628
- let rateLimit = null;
45629
- if (source.rate_limit !== null) {
45630
- const rate = requireMapping(source.rate_limit, filePath, "rate_limit");
45631
- requireOnlyFields(rate, filePath, "rate_limit", [
45632
- "repo",
45633
- "limit",
45634
- "remaining",
45635
- "reset_at",
45636
- "retry_after",
45637
- "partial_results",
45638
- "reason"
45639
- ]);
45640
- const reason = optionalString(rate.reason, filePath, "rate_limit.reason");
45641
- if (reason !== void 0 && !["low_remaining", "primary", "secondary"].includes(
45642
- reason
45643
- )) {
45644
- throw invalidField(filePath, "rate_limit.reason", "is not supported");
45645
- }
45646
- rateLimit = {
45647
- repo: requireRepo(rate.repo, filePath, "rate_limit.repo"),
45648
- limit: rate.limit === null || rate.limit === void 0 ? null : requireNonNegativeInteger(rate.limit, filePath, "rate_limit.limit"),
45649
- remaining: rate.remaining === null ? null : requireNonNegativeInteger(rate.remaining, filePath, "rate_limit.remaining"),
45650
- resetAt: rate.reset_at === null ? null : requireDate(rate.reset_at, filePath, "rate_limit.reset_at"),
45651
- retryAfter: rate.retry_after === null || rate.retry_after === void 0 ? null : optionalString(rate.retry_after, filePath, "rate_limit.retry_after") ?? null,
45652
- partialResults: requireNonNegativeInteger(
45653
- rate.partial_results,
45654
- filePath,
45655
- "rate_limit.partial_results"
45656
- ),
45657
- reason: reason ?? "low_remaining"
45658
- };
45659
- }
45660
- return {
45661
- version: 1,
45662
- username,
45663
- repos,
45664
- fetchedAt,
45665
- outputProfilePath: source.output_profile_path,
45666
- pagination: {
45667
- partial: pagination.partial,
45668
- commentsWritten,
45669
- ...resumeEndpoint === void 0 ? {} : { resumeEndpoint }
45670
- },
45671
- rateLimit
45672
- };
45673
- } catch (error2) {
45674
- if (error2 instanceof Error && error2.message.startsWith(`${filePath}:`)) {
45675
- throw error2;
45676
- }
45677
- throw new Error(`${filePath}: invalid YAML: ${errorMessage(error2)}`);
45678
- }
45679
- }
45680
- function serializeCodeReviewIngestSource(source, filePath = "code-review ingest source.yaml") {
45681
- const content = stringify3(
45682
- {
45683
- version: source.version,
45684
- username: source.username,
45685
- repos: source.repos,
45686
- fetched_at: source.fetchedAt,
45687
- pagination: {
45688
- partial: source.pagination.partial,
45689
- comments_written: source.pagination.commentsWritten,
45690
- ...source.pagination.resumeEndpoint === void 0 ? {} : { resume_endpoint: source.pagination.resumeEndpoint }
45691
- },
45692
- rate_limit: source.rateLimit === null ? null : {
45693
- repo: source.rateLimit.repo,
45694
- limit: source.rateLimit.limit,
45695
- remaining: source.rateLimit.remaining,
45696
- reset_at: source.rateLimit.resetAt,
45697
- retry_after: source.rateLimit.retryAfter,
45698
- partial_results: source.rateLimit.partialResults,
45699
- reason: source.rateLimit.reason
45700
- },
45701
- output_profile_path: source.outputProfilePath
45702
- },
45703
- { aliasDuplicateObjects: false, lineWidth: 0 }
45704
- );
45705
- parseCodeReviewIngestSource(content, filePath);
45706
- return content;
45707
- }
45708
- function parseOptionalFrontmatter(content, filePath) {
45709
- const match = content.match(FRONTMATTER_RE);
45710
- if (!match) {
45711
- if (/^---\r?\n/.test(content)) {
45712
- throw new Error(`${filePath}: frontmatter is missing a closing --- delimiter.`);
45713
- }
45714
- return { body: content };
45715
- }
45716
- try {
45717
- return { frontmatter: load(match[1]), body: match[2] };
45718
- } catch (error2) {
45719
- throw new Error(`${filePath}: invalid frontmatter YAML: ${errorMessage(error2)}`);
45720
- }
45721
- }
45722
- function requireMapping(value, filePath, field) {
45723
- if (typeof value !== "object" || value === null || Array.isArray(value)) {
45724
- throw invalidField(filePath, field, "must be a YAML mapping");
45725
- }
45726
- return value;
45727
- }
45728
- function requireVersion(value, filePath, field) {
45729
- if (value !== 1) {
45730
- throw invalidField(filePath, field, "must equal 1");
45731
- }
45732
- }
45733
- function requireOnlyFields(value, filePath, field, allowedFields) {
45734
- const allowed = new Set(allowedFields);
45735
- for (const key2 of Object.keys(value)) {
45736
- if (!allowed.has(key2)) {
45737
- throw invalidField(filePath, `${field}.${key2}`, "is not supported");
45738
- }
45739
- }
45740
- }
45741
- function requireRepo(value, filePath, field) {
45742
- if (typeof value !== "string" || !/^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/.test(value)) {
45743
- throw invalidField(filePath, field, "must be a safe owner/repository name");
45744
- }
45745
- return value;
45746
- }
45747
- function requireDate(value, filePath, field) {
45748
- if (typeof value !== "string" || Number.isNaN(Date.parse(value))) {
45749
- throw invalidField(filePath, field, "must be a valid timestamp");
45750
- }
45751
- return value;
45752
- }
45753
- function requireNonNegativeInteger(value, filePath, field) {
45754
- if (!Number.isSafeInteger(value) || value < 0) {
45755
- throw invalidField(filePath, field, "must be a non-negative integer");
45756
- }
45757
- return value;
45758
- }
45759
- function optionalString(value, filePath, field) {
45760
- if (value === void 0) {
45761
- return void 0;
45762
- }
45763
- if (typeof value !== "string" || value.length === 0) {
45764
- throw invalidField(filePath, field, "must be a non-empty string");
45765
- }
45766
- return value;
45767
- }
45768
- function invalidField(filePath, field, reason) {
45769
- return new Error(`${filePath}: ${field} ${reason}.`);
45770
- }
45771
- function errorMessage(error2) {
45772
- return error2 instanceof Error ? error2.message : String(error2);
45773
- }
45774
-
45775
45772
  // packages/agent-code-review/src/review-state.ts
45776
45773
  import { parse as load2, stringify as stringify4 } from "yaml";
45777
45774
  function parseCodeReviewState(content, filePath = "code-review review YAML") {
@@ -46583,8 +46580,8 @@ async function withFileLock2(lockPath, lockTimeoutMs, operation) {
46583
46580
  }
46584
46581
  async function isStaleLock(lockPath, lockTimeoutMs) {
46585
46582
  try {
46586
- const ownerPid = Number.parseInt((await readFile10(lockPath, "utf8")).trim(), 10);
46587
- if (Number.isSafeInteger(ownerPid) && ownerPid > 0) {
46583
+ const ownerPid = parseLockOwnerPid((await readFile10(lockPath, "utf8")).trim());
46584
+ if (ownerPid !== void 0) {
46588
46585
  return !isRunningProcess(ownerPid);
46589
46586
  }
46590
46587
  return Date.now() - (await stat6(lockPath)).mtimeMs >= lockTimeoutMs;
@@ -46595,6 +46592,13 @@ async function isStaleLock(lockPath, lockTimeoutMs) {
46595
46592
  throw error2;
46596
46593
  }
46597
46594
  }
46595
+ function parseLockOwnerPid(value) {
46596
+ const processId = Number(value);
46597
+ if (!Number.isSafeInteger(processId) || processId <= 0) {
46598
+ return void 0;
46599
+ }
46600
+ return String(processId) === value ? processId : void 0;
46601
+ }
46598
46602
  function isRunningProcess(processId) {
46599
46603
  try {
46600
46604
  process.kill(processId, 0);
@@ -46839,7 +46843,7 @@ async function resolveCodeReviewRunOptions(input, configOptions) {
46839
46843
  ),
46840
46844
  ...inputProfilePath === void 0 ? {} : { profilePath: inputProfilePath },
46841
46845
  ...inputPromptPath === void 0 ? {} : { promptPath: inputPromptPath },
46842
- ...inputProfiles === void 0 ? {} : { profiles: inputProfiles },
46846
+ ...inputProfiles === void 0 ? {} : { profiles: requireProfileFilters(inputProfiles) },
46843
46847
  ...inputAdditionalFeedback === void 0 ? {} : { additionalFeedback: inputAdditionalFeedback }
46844
46848
  };
46845
46849
  }
@@ -46892,6 +46896,18 @@ function requireNonEmptyString(value, field) {
46892
46896
  }
46893
46897
  return normalized;
46894
46898
  }
46899
+ function requireProfileFilters(value) {
46900
+ if (!Array.isArray(value)) {
46901
+ throw new Error("profiles must be an array of safe profile names.");
46902
+ }
46903
+ return value.map((profile) => {
46904
+ try {
46905
+ return requireSafeDocumentSegment(profile, "profiles");
46906
+ } catch {
46907
+ throw new Error("profiles must be an array of safe profile names.");
46908
+ }
46909
+ });
46910
+ }
46895
46911
  function isMissingFileError5(error2) {
46896
46912
  return hasOwnErrorCode14(error2, "ENOENT");
46897
46913
  }
@@ -52506,11 +52522,17 @@ function shouldUseTextStdinForCodeReview(agent2) {
52506
52522
  var CODE_REVIEW_AGENT_MCP_ROLES = ["agent", "orchestrator", "subagent"];
52507
52523
  var inlineCommentSchema = S.Object({
52508
52524
  path: S.String({ description: "Repository-relative path in the PR diff." }),
52509
- line: S.Number({ description: "Right-side line number in the PR diff." }),
52525
+ line: S.Number({
52526
+ description: "Right-side line number in the PR diff.",
52527
+ jsonType: "integer",
52528
+ minimum: 1
52529
+ }),
52510
52530
  body: S.String({ description: "Inline review comment body." })
52511
52531
  });
52512
52532
  var inlineCommentIndexSchema = S.Number({
52513
- description: "Zero-based merged review inline comment index."
52533
+ description: "Zero-based merged review inline comment index.",
52534
+ jsonType: "integer",
52535
+ minimum: 0
52514
52536
  });
52515
52537
  var prParam = S.String({ description: "GitHub pull request URL." });
52516
52538
  function parseCodeReviewAgentMcpArgs(argv) {
@@ -52632,7 +52654,7 @@ function createCodeReviewAgentMcpGroup(context, dependencies = {}) {
52632
52654
  handler: async ({ params }) => {
52633
52655
  const pr = canonicalPullRequestUrl(params.pr);
52634
52656
  const draft = validateDraft2(params);
52635
- const currentState = await ensureState(store, context, pr);
52657
+ const currentState = context.role === "orchestrator" ? await ensureState(store, context, pr) : await requireState(store, context, pr);
52636
52658
  if (context.role === "orchestrator") {
52637
52659
  const unfinishedProfiles = Object.values(currentState.subagents).filter(({ status }) => status === "pending" || status === "running").map(({ profile }) => profile);
52638
52660
  if (unfinishedProfiles.length > 0) {
@@ -52827,7 +52849,11 @@ function createCodeReviewAgentMcpGroup(context, dependencies = {}) {
52827
52849
  pr: prParam,
52828
52850
  index: inlineCommentIndexSchema,
52829
52851
  path: S.String({ description: "Repository-relative path in the PR diff." }),
52830
- line: S.Number({ description: "Right-side line number in the PR diff." }),
52852
+ line: S.Number({
52853
+ description: "Right-side line number in the PR diff.",
52854
+ jsonType: "integer",
52855
+ minimum: 1
52856
+ }),
52831
52857
  body: S.String({ description: "Inline review comment body." })
52832
52858
  }),
52833
52859
  handler: async ({ params }) => {