poe-code 3.0.268 → 3.0.270

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.
@@ -38316,6 +38316,7 @@ var init_src19 = __esm({
38316
38316
  init_spawn_interactive();
38317
38317
  init_autonomous();
38318
38318
  init_renderer2();
38319
+ init_session_update_converter();
38319
38320
  init_replay();
38320
38321
  init_spawn();
38321
38322
  init_spawn_acp();
@@ -44455,6 +44456,246 @@ init_src9();
44455
44456
  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
44457
  import { homedir as homedir4 } from "node:os";
44457
44458
 
44459
+ // packages/agent-code-review/src/document-schemas.ts
44460
+ import { basename as basename2 } from "node:path";
44461
+ import { parse as load, stringify as stringify3 } from "yaml";
44462
+ var CODE_REVIEW_PROMPT_ROLES = [
44463
+ "orchestrator",
44464
+ "subagent",
44465
+ "agent",
44466
+ "profile-synthesis"
44467
+ ];
44468
+ var FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/;
44469
+ var SAFE_SEGMENT_RE = /^[A-Za-z0-9._-]+$/;
44470
+ var SAFE_GITHUB_ACTOR_RE = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/;
44471
+ function requireSafeDocumentSegment(value, field) {
44472
+ if (typeof value !== "string" || value.trim() !== value || value.normalize("NFKC") !== value || !SAFE_SEGMENT_RE.test(value) || value.startsWith(".") || value === "." || value === "..") {
44473
+ throw new Error(`${field} must be a safe path segment.`);
44474
+ }
44475
+ return value;
44476
+ }
44477
+ function requireGitHubActorName(value, field) {
44478
+ if (typeof value !== "string" || !SAFE_GITHUB_ACTOR_RE.test(value)) {
44479
+ throw new Error(`${field} must be a safe GitHub actor name.`);
44480
+ }
44481
+ return value;
44482
+ }
44483
+ function parseCodeReviewProfileMarkdown(content, filePath) {
44484
+ const parsed = parseOptionalFrontmatter(content, filePath);
44485
+ if (!parsed.frontmatter) {
44486
+ return { content: parsed.body };
44487
+ }
44488
+ const metadata = requireMapping(parsed.frontmatter, filePath, "frontmatter");
44489
+ requireOnlyFields(metadata, filePath, "frontmatter", ["version", "name"]);
44490
+ requireVersion(metadata.version, filePath, "frontmatter.version");
44491
+ const name = requireSafeDocumentSegment(metadata.name, `${filePath}: frontmatter.name`);
44492
+ if (basename2(filePath, ".md") !== name) {
44493
+ throw invalidField(filePath, "frontmatter.name", "must match the filename");
44494
+ }
44495
+ return { content: parsed.body, metadata: { version: 1, name } };
44496
+ }
44497
+ function parseCodeReviewPromptMarkdown(content, filePath, role) {
44498
+ const parsed = parseOptionalFrontmatter(content, filePath);
44499
+ if (!parsed.frontmatter) {
44500
+ return { content: parsed.body };
44501
+ }
44502
+ const metadata = requireMapping(parsed.frontmatter, filePath, "frontmatter");
44503
+ requireOnlyFields(metadata, filePath, "frontmatter", ["version", "role"]);
44504
+ requireVersion(metadata.version, filePath, "frontmatter.version");
44505
+ if (!CODE_REVIEW_PROMPT_ROLES.includes(metadata.role)) {
44506
+ throw invalidField(filePath, "frontmatter.role", "is not a supported role");
44507
+ }
44508
+ const promptRole = metadata.role;
44509
+ if (role !== void 0 && promptRole !== role) {
44510
+ throw invalidField(filePath, "frontmatter.role", `must equal ${role}`);
44511
+ }
44512
+ return { content: parsed.body, metadata: { version: 1, role: promptRole } };
44513
+ }
44514
+ function parseCodeReviewIngestSource(content, filePath = "code-review ingest source.yaml") {
44515
+ try {
44516
+ const source = requireMapping(load(content), filePath, "document");
44517
+ requireOnlyFields(source, filePath, "document", [
44518
+ "version",
44519
+ "username",
44520
+ "repos",
44521
+ "fetched_at",
44522
+ "output_profile_path",
44523
+ "pagination",
44524
+ "rate_limit"
44525
+ ]);
44526
+ requireVersion(source.version, filePath, "version");
44527
+ const username = requireGitHubActorName(source.username, `${filePath}: username`);
44528
+ if (!Array.isArray(source.repos) || source.repos.length === 0) {
44529
+ throw invalidField(filePath, "repos", "must be a non-empty array");
44530
+ }
44531
+ const repos = source.repos.map((repo, index) => requireRepo(repo, filePath, `repos[${index}]`));
44532
+ const fetchedAt = requireDate(source.fetched_at, filePath, "fetched_at");
44533
+ if (typeof source.output_profile_path !== "string" || !source.output_profile_path) {
44534
+ throw invalidField(filePath, "output_profile_path", "must be a non-empty string");
44535
+ }
44536
+ const pagination = requireMapping(source.pagination, filePath, "pagination");
44537
+ requireOnlyFields(pagination, filePath, "pagination", [
44538
+ "partial",
44539
+ "comments_written",
44540
+ "resume_endpoint"
44541
+ ]);
44542
+ if (typeof pagination.partial !== "boolean") {
44543
+ throw invalidField(filePath, "pagination.partial", "must be a boolean");
44544
+ }
44545
+ const commentsWritten = requireNonNegativeInteger(
44546
+ pagination.comments_written,
44547
+ filePath,
44548
+ "pagination.comments_written"
44549
+ );
44550
+ const resumeEndpoint = optionalString(
44551
+ pagination.resume_endpoint,
44552
+ filePath,
44553
+ "pagination.resume_endpoint"
44554
+ );
44555
+ let rateLimit = null;
44556
+ if (source.rate_limit !== null) {
44557
+ const rate = requireMapping(source.rate_limit, filePath, "rate_limit");
44558
+ requireOnlyFields(rate, filePath, "rate_limit", [
44559
+ "repo",
44560
+ "limit",
44561
+ "remaining",
44562
+ "reset_at",
44563
+ "retry_after",
44564
+ "partial_results",
44565
+ "reason"
44566
+ ]);
44567
+ const reason = optionalString(rate.reason, filePath, "rate_limit.reason");
44568
+ if (reason !== void 0 && !["low_remaining", "primary", "secondary"].includes(
44569
+ reason
44570
+ )) {
44571
+ throw invalidField(filePath, "rate_limit.reason", "is not supported");
44572
+ }
44573
+ rateLimit = {
44574
+ repo: requireRepo(rate.repo, filePath, "rate_limit.repo"),
44575
+ limit: rate.limit === null || rate.limit === void 0 ? null : requireNonNegativeInteger(rate.limit, filePath, "rate_limit.limit"),
44576
+ remaining: rate.remaining === null ? null : requireNonNegativeInteger(rate.remaining, filePath, "rate_limit.remaining"),
44577
+ resetAt: rate.reset_at === null ? null : requireDate(rate.reset_at, filePath, "rate_limit.reset_at"),
44578
+ retryAfter: rate.retry_after === null || rate.retry_after === void 0 ? null : optionalString(rate.retry_after, filePath, "rate_limit.retry_after") ?? null,
44579
+ partialResults: requireNonNegativeInteger(
44580
+ rate.partial_results,
44581
+ filePath,
44582
+ "rate_limit.partial_results"
44583
+ ),
44584
+ reason: reason ?? "low_remaining"
44585
+ };
44586
+ }
44587
+ return {
44588
+ version: 1,
44589
+ username,
44590
+ repos,
44591
+ fetchedAt,
44592
+ outputProfilePath: source.output_profile_path,
44593
+ pagination: {
44594
+ partial: pagination.partial,
44595
+ commentsWritten,
44596
+ ...resumeEndpoint === void 0 ? {} : { resumeEndpoint }
44597
+ },
44598
+ rateLimit
44599
+ };
44600
+ } catch (error2) {
44601
+ if (error2 instanceof Error && error2.message.startsWith(`${filePath}:`)) {
44602
+ throw error2;
44603
+ }
44604
+ throw new Error(`${filePath}: invalid YAML: ${errorMessage(error2)}`);
44605
+ }
44606
+ }
44607
+ function serializeCodeReviewIngestSource(source, filePath = "code-review ingest source.yaml") {
44608
+ const content = stringify3(
44609
+ {
44610
+ version: source.version,
44611
+ username: source.username,
44612
+ repos: source.repos,
44613
+ fetched_at: source.fetchedAt,
44614
+ pagination: {
44615
+ partial: source.pagination.partial,
44616
+ comments_written: source.pagination.commentsWritten,
44617
+ ...source.pagination.resumeEndpoint === void 0 ? {} : { resume_endpoint: source.pagination.resumeEndpoint }
44618
+ },
44619
+ rate_limit: source.rateLimit === null ? null : {
44620
+ repo: source.rateLimit.repo,
44621
+ limit: source.rateLimit.limit,
44622
+ remaining: source.rateLimit.remaining,
44623
+ reset_at: source.rateLimit.resetAt,
44624
+ retry_after: source.rateLimit.retryAfter,
44625
+ partial_results: source.rateLimit.partialResults,
44626
+ reason: source.rateLimit.reason
44627
+ },
44628
+ output_profile_path: source.outputProfilePath
44629
+ },
44630
+ { aliasDuplicateObjects: false, lineWidth: 0 }
44631
+ );
44632
+ parseCodeReviewIngestSource(content, filePath);
44633
+ return content;
44634
+ }
44635
+ function parseOptionalFrontmatter(content, filePath) {
44636
+ const match = content.match(FRONTMATTER_RE);
44637
+ if (!match) {
44638
+ return { body: content };
44639
+ }
44640
+ try {
44641
+ return { frontmatter: load(match[1]), body: match[2] };
44642
+ } catch (error2) {
44643
+ throw new Error(`${filePath}: invalid frontmatter YAML: ${errorMessage(error2)}`);
44644
+ }
44645
+ }
44646
+ function requireMapping(value, filePath, field) {
44647
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
44648
+ throw invalidField(filePath, field, "must be a YAML mapping");
44649
+ }
44650
+ return value;
44651
+ }
44652
+ function requireVersion(value, filePath, field) {
44653
+ if (value !== 1) {
44654
+ throw invalidField(filePath, field, "must equal 1");
44655
+ }
44656
+ }
44657
+ function requireOnlyFields(value, filePath, field, allowedFields) {
44658
+ const allowed = new Set(allowedFields);
44659
+ for (const key2 of Object.keys(value)) {
44660
+ if (!allowed.has(key2)) {
44661
+ throw invalidField(filePath, `${field}.${key2}`, "is not supported");
44662
+ }
44663
+ }
44664
+ }
44665
+ function requireRepo(value, filePath, field) {
44666
+ if (typeof value !== "string" || !/^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/.test(value)) {
44667
+ throw invalidField(filePath, field, "must be a safe owner/repository name");
44668
+ }
44669
+ return value;
44670
+ }
44671
+ function requireDate(value, filePath, field) {
44672
+ if (typeof value !== "string" || Number.isNaN(Date.parse(value))) {
44673
+ throw invalidField(filePath, field, "must be a valid timestamp");
44674
+ }
44675
+ return value;
44676
+ }
44677
+ function requireNonNegativeInteger(value, filePath, field) {
44678
+ if (!Number.isSafeInteger(value) || value < 0) {
44679
+ throw invalidField(filePath, field, "must be a non-negative integer");
44680
+ }
44681
+ return value;
44682
+ }
44683
+ function optionalString(value, filePath, field) {
44684
+ if (value === void 0) {
44685
+ return void 0;
44686
+ }
44687
+ if (typeof value !== "string" || value.length === 0) {
44688
+ throw invalidField(filePath, field, "must be a non-empty string");
44689
+ }
44690
+ return value;
44691
+ }
44692
+ function invalidField(filePath, field, reason) {
44693
+ return new Error(`${filePath}: ${field} ${reason}.`);
44694
+ }
44695
+ function errorMessage(error2) {
44696
+ return error2 instanceof Error ? error2.message : String(error2);
44697
+ }
44698
+
44458
44699
  // packages/agent-code-review/src/error-codes.ts
44459
44700
  function hasOwnErrorCode14(error2, code) {
44460
44701
  return error2 instanceof Error && Object.prototype.hasOwnProperty.call(error2, "code") && error2.code === code;
@@ -45529,249 +45770,6 @@ async function* fetchReviewHistory(options) {
45529
45770
  }
45530
45771
  }
45531
45772
 
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
45773
  // packages/agent-code-review/src/review-state.ts
45776
45774
  import { parse as load2, stringify as stringify4 } from "yaml";
45777
45775
  function parseCodeReviewState(content, filePath = "code-review review YAML") {
@@ -46583,8 +46581,8 @@ async function withFileLock2(lockPath, lockTimeoutMs, operation) {
46583
46581
  }
46584
46582
  async function isStaleLock(lockPath, lockTimeoutMs) {
46585
46583
  try {
46586
- const ownerPid = Number.parseInt((await readFile10(lockPath, "utf8")).trim(), 10);
46587
- if (Number.isSafeInteger(ownerPid) && ownerPid > 0) {
46584
+ const ownerPid = parseLockOwnerPid((await readFile10(lockPath, "utf8")).trim());
46585
+ if (ownerPid !== void 0) {
46588
46586
  return !isRunningProcess(ownerPid);
46589
46587
  }
46590
46588
  return Date.now() - (await stat6(lockPath)).mtimeMs >= lockTimeoutMs;
@@ -46595,6 +46593,13 @@ async function isStaleLock(lockPath, lockTimeoutMs) {
46595
46593
  throw error2;
46596
46594
  }
46597
46595
  }
46596
+ function parseLockOwnerPid(value) {
46597
+ const processId = Number(value);
46598
+ if (!Number.isSafeInteger(processId) || processId <= 0) {
46599
+ return void 0;
46600
+ }
46601
+ return String(processId) === value ? processId : void 0;
46602
+ }
46598
46603
  function isRunningProcess(processId) {
46599
46604
  try {
46600
46605
  process.kill(processId, 0);
@@ -46839,7 +46844,7 @@ async function resolveCodeReviewRunOptions(input, configOptions) {
46839
46844
  ),
46840
46845
  ...inputProfilePath === void 0 ? {} : { profilePath: inputProfilePath },
46841
46846
  ...inputPromptPath === void 0 ? {} : { promptPath: inputPromptPath },
46842
- ...inputProfiles === void 0 ? {} : { profiles: inputProfiles },
46847
+ ...inputProfiles === void 0 ? {} : { profiles: requireProfileFilters(inputProfiles) },
46843
46848
  ...inputAdditionalFeedback === void 0 ? {} : { additionalFeedback: inputAdditionalFeedback }
46844
46849
  };
46845
46850
  }
@@ -46892,6 +46897,18 @@ function requireNonEmptyString(value, field) {
46892
46897
  }
46893
46898
  return normalized;
46894
46899
  }
46900
+ function requireProfileFilters(value) {
46901
+ if (!Array.isArray(value)) {
46902
+ throw new Error("profiles must be an array of safe profile names.");
46903
+ }
46904
+ return value.map((profile) => {
46905
+ try {
46906
+ return requireSafeDocumentSegment(profile, "profiles");
46907
+ } catch {
46908
+ throw new Error("profiles must be an array of safe profile names.");
46909
+ }
46910
+ });
46911
+ }
46895
46912
  function isMissingFileError5(error2) {
46896
46913
  return hasOwnErrorCode14(error2, "ENOENT");
46897
46914
  }
@@ -52506,11 +52523,17 @@ function shouldUseTextStdinForCodeReview(agent2) {
52506
52523
  var CODE_REVIEW_AGENT_MCP_ROLES = ["agent", "orchestrator", "subagent"];
52507
52524
  var inlineCommentSchema = S.Object({
52508
52525
  path: S.String({ description: "Repository-relative path in the PR diff." }),
52509
- line: S.Number({ description: "Right-side line number in the PR diff." }),
52526
+ line: S.Number({
52527
+ description: "Right-side line number in the PR diff.",
52528
+ jsonType: "integer",
52529
+ minimum: 1
52530
+ }),
52510
52531
  body: S.String({ description: "Inline review comment body." })
52511
52532
  });
52512
52533
  var inlineCommentIndexSchema = S.Number({
52513
- description: "Zero-based merged review inline comment index."
52534
+ description: "Zero-based merged review inline comment index.",
52535
+ jsonType: "integer",
52536
+ minimum: 0
52514
52537
  });
52515
52538
  var prParam = S.String({ description: "GitHub pull request URL." });
52516
52539
  function parseCodeReviewAgentMcpArgs(argv) {
@@ -52632,7 +52655,7 @@ function createCodeReviewAgentMcpGroup(context, dependencies = {}) {
52632
52655
  handler: async ({ params }) => {
52633
52656
  const pr = canonicalPullRequestUrl(params.pr);
52634
52657
  const draft = validateDraft2(params);
52635
- const currentState = await ensureState(store, context, pr);
52658
+ const currentState = context.role === "orchestrator" ? await ensureState(store, context, pr) : await requireState(store, context, pr);
52636
52659
  if (context.role === "orchestrator") {
52637
52660
  const unfinishedProfiles = Object.values(currentState.subagents).filter(({ status }) => status === "pending" || status === "running").map(({ profile }) => profile);
52638
52661
  if (unfinishedProfiles.length > 0) {
@@ -52827,7 +52850,11 @@ function createCodeReviewAgentMcpGroup(context, dependencies = {}) {
52827
52850
  pr: prParam,
52828
52851
  index: inlineCommentIndexSchema,
52829
52852
  path: S.String({ description: "Repository-relative path in the PR diff." }),
52830
- line: S.Number({ description: "Right-side line number in the PR diff." }),
52853
+ line: S.Number({
52854
+ description: "Right-side line number in the PR diff.",
52855
+ jsonType: "integer",
52856
+ minimum: 1
52857
+ }),
52831
52858
  body: S.String({ description: "Inline review comment body." })
52832
52859
  }),
52833
52860
  handler: async ({ params }) => {