@akagilnc/pi-workflow-roles 0.1.3403 → 0.1.3407

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.
@@ -47,20 +47,7 @@ async function buildEvidenceChildSystemPrompt(engineMaterial) {
47
47
  }
48
48
  return appendEngineSessionMaterial(materials, engineMaterial).join("\n");
49
49
  }
50
- const AUDITOR_TURN_LIMIT = 32;
51
50
  const DEFAULT_COMPLIANCE_IDLE_MAX_RETRIES = 2;
52
- class AuditorTurnLimitError extends Error {
53
- constructor(limit, observedTurns, lastResponse) {
54
- super(observedTurns === void 0 ? `Auditor exceeded ${limit} turns` : `Auditor exhausted its ${limit}-turn limit after ${observedTurns} provider turns`);
55
- this.limit = limit;
56
- this.observedTurns = observedTurns;
57
- this.lastResponse = lastResponse;
58
- this.name = "AuditorTurnLimitError";
59
- }
60
- limit;
61
- observedTurns;
62
- lastResponse;
63
- }
64
51
  async function withInProcessScratch(options, run) {
65
52
  const scratch = await mkdtemp(join(options.parentDirectory ?? tmpdir(), options.prefix));
66
53
  let failure;
@@ -426,7 +413,6 @@ async function executeAuditorChild(options) {
426
413
  });
427
414
  } catch {
428
415
  }
429
- let turns = 0;
430
416
  const sessionUsage = emptyUsage();
431
417
  let boundaryResponse;
432
418
  let retentionFailure;
@@ -460,7 +446,6 @@ async function executeAuditorChild(options) {
460
446
  evidenceToolFailures.set(event.toolCallId, failure);
461
447
  }
462
448
  if (event.type === "message_end" && event.role === "assistant" && boundaryResponse === void 0) {
463
- turns += 1;
464
449
  if (event.usage) addUsage(sessionUsage, event.usage);
465
450
  const msg = event.message;
466
451
  retainedResponse = msg;
@@ -483,7 +468,7 @@ async function executeAuditorChild(options) {
483
468
  }
484
469
  }
485
470
  }
486
- if (turns >= AUDITOR_TURN_LIMIT || msg.stopReason === "error") boundaryResponse = msg;
471
+ if (msg.stopReason === "error") boundaryResponse = msg;
487
472
  }
488
473
  }
489
474
  if (event.type === "turn_end") {
@@ -589,13 +574,6 @@ async function executeAuditorChild(options) {
589
574
  }
590
575
  const assistants = [...retainedAssistants].reverse();
591
576
  const response = !decisionSubmitted ? assistants[0] : assistants.find((message) => message.content.some((part) => part.type === "toolCall" && part.name === tool.name));
592
- if (boundaryResponse !== void 0 && boundaryResponse.stopReason !== "error" && !decisionSubmitted && noReceiptLifecycle === void 0) {
593
- const toolNames = boundaryResponse.content.flatMap((part) => part.type === "toolCall" ? [part.name] : []);
594
- throw new AuditorTurnLimitError(AUDITOR_TURN_LIMIT, turns, {
595
- stopReason: boundaryResponse.stopReason,
596
- toolNames
597
- });
598
- }
599
577
  if (response !== void 0) {
600
578
  try {
601
579
  if (retentionFailure !== void 0) throw retentionFailure;
@@ -849,8 +827,6 @@ function createNativeNavigatorSessionFactory(defaultModelSettingPath = navigator
849
827
  };
850
828
  }
851
829
  export {
852
- AUDITOR_TURN_LIMIT,
853
- AuditorTurnLimitError,
854
830
  DEFAULT_COMPLIANCE_IDLE_MAX_RETRIES,
855
831
  createNativeNavigatorSessionFactory,
856
832
  executeAuditorChild,
@@ -4043,19 +4043,6 @@ async function buildEvidenceChildSystemPrompt(engineMaterial) {
4043
4043
  }
4044
4044
  return appendEngineSessionMaterial(materials, engineMaterial).join("\n");
4045
4045
  }
4046
- var AUDITOR_TURN_LIMIT = 32;
4047
- var AuditorTurnLimitError = class extends Error {
4048
- constructor(limit, observedTurns, lastResponse) {
4049
- super(observedTurns === void 0 ? `Auditor exceeded ${limit} turns` : `Auditor exhausted its ${limit}-turn limit after ${observedTurns} provider turns`);
4050
- this.limit = limit;
4051
- this.observedTurns = observedTurns;
4052
- this.lastResponse = lastResponse;
4053
- this.name = "AuditorTurnLimitError";
4054
- }
4055
- limit;
4056
- observedTurns;
4057
- lastResponse;
4058
- };
4059
4046
  async function withInProcessScratch(options, run) {
4060
4047
  const scratch = await mkdtemp3(join12(options.parentDirectory ?? tmpdir3(), options.prefix));
4061
4048
  let failure2;
@@ -4388,7 +4375,6 @@ async function executeAuditorChild(options) {
4388
4375
  });
4389
4376
  } catch {
4390
4377
  }
4391
- let turns = 0;
4392
4378
  const sessionUsage = emptyUsage2();
4393
4379
  let boundaryResponse;
4394
4380
  let retentionFailure;
@@ -4422,7 +4408,6 @@ async function executeAuditorChild(options) {
4422
4408
  evidenceToolFailures.set(event.toolCallId, failure2);
4423
4409
  }
4424
4410
  if (event.type === "message_end" && event.role === "assistant" && boundaryResponse === void 0) {
4425
- turns += 1;
4426
4411
  if (event.usage) addUsage2(sessionUsage, event.usage);
4427
4412
  const msg = event.message;
4428
4413
  retainedResponse = msg;
@@ -4445,7 +4430,7 @@ async function executeAuditorChild(options) {
4445
4430
  }
4446
4431
  }
4447
4432
  }
4448
- if (turns >= AUDITOR_TURN_LIMIT || msg.stopReason === "error") boundaryResponse = msg;
4433
+ if (msg.stopReason === "error") boundaryResponse = msg;
4449
4434
  }
4450
4435
  }
4451
4436
  if (event.type === "turn_end") {
@@ -4551,13 +4536,6 @@ async function executeAuditorChild(options) {
4551
4536
  }
4552
4537
  const assistants = [...retainedAssistants].reverse();
4553
4538
  const response = !decisionSubmitted ? assistants[0] : assistants.find((message) => message.content.some((part) => part.type === "toolCall" && part.name === tool2.name));
4554
- if (boundaryResponse !== void 0 && boundaryResponse.stopReason !== "error" && !decisionSubmitted && noReceiptLifecycle === void 0) {
4555
- const toolNames = boundaryResponse.content.flatMap((part) => part.type === "toolCall" ? [part.name] : []);
4556
- throw new AuditorTurnLimitError(AUDITOR_TURN_LIMIT, turns, {
4557
- stopReason: boundaryResponse.stopReason,
4558
- toolNames
4559
- });
4560
- }
4561
4539
  if (response !== void 0) {
4562
4540
  try {
4563
4541
  if (retentionFailure !== void 0) throw retentionFailure;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akagilnc/pi-workflow-roles",
3
- "version": "0.1.3403",
3
+ "version": "0.1.3407",
4
4
  "description": "Soul-bound workflow roles for Pi",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -8,8 +8,6 @@
8
8
 
9
9
  取舍位次:过测试 → 显意图 → 无重复 → 最少元素。
10
10
 
11
- 尺子锚定仓内已接受的现状:与紧邻已并入代码同款的写法,不单独判新增行为缺陷;要判就按类判全仓。
12
-
13
11
  ## 测试对行为负责
14
12
 
15
13
  测试只保**调用输入正确**的最短确定性案:从真实入口进入,在外部可见的结构化结果上断言,秒级完成。涉真实宿主、真实 LLM、真实并发、真实网络的行为,不写测试;以真跑为证。
@@ -88,25 +88,8 @@ async function buildEvidenceChildSystemPrompt(
88
88
 
89
89
  // ── shared constants / types ──────────────────────────────────────────────
90
90
 
91
- export const AUDITOR_TURN_LIMIT = 32;
92
91
  export const DEFAULT_COMPLIANCE_IDLE_MAX_RETRIES = 2;
93
92
 
94
- export type AuditorLastResponseFacts = {
95
- readonly stopReason: AssistantMessage["stopReason"];
96
- readonly toolNames: readonly string[];
97
- };
98
- export class AuditorTurnLimitError extends Error {
99
- constructor(
100
- readonly limit: number,
101
- readonly observedTurns?: number,
102
- readonly lastResponse?: AuditorLastResponseFacts,
103
- ) {
104
- super(observedTurns === undefined
105
- ? `Auditor exceeded ${limit} turns`
106
- : `Auditor exhausted its ${limit}-turn limit after ${observedTurns} provider turns`);
107
- this.name = "AuditorTurnLimitError";
108
- }
109
- }
110
93
  export type AuditorDecisionTool = {
111
94
  name: string;
112
95
  description: string;
@@ -640,7 +623,6 @@ export async function executeAuditorChild(
640
623
  });
641
624
  } catch {}
642
625
 
643
- let turns = 0;
644
626
  const sessionUsage = emptyUsage();
645
627
  let boundaryResponse: AssistantMessage | undefined;
646
628
  let retentionFailure: unknown;
@@ -682,8 +664,8 @@ export async function executeAuditorChild(
682
664
  // A native unknown-tool receipt ("Tool <name> not found") is not an
683
665
  // evidence-tool failure: the child session has no such tool registered,
684
666
  // so its errored toolResult must not short-circuit the auditor (it keeps
685
- // prompting to the turn limit, mirroring the pre-migration
686
- // registeredToolNames exclusion in findToolFailure).
667
+ // prompting, mirroring the pre-migration registeredToolNames exclusion
668
+ // in findToolFailure).
687
669
  if (detailText !== undefined && /^Tool\s+.+ not found$/.test(detailText.trim())) return;
688
670
  const failure = detailText === undefined
689
671
  ? new Error(event.toolName ?? "evidence tool failed")
@@ -696,7 +678,6 @@ export async function executeAuditorChild(
696
678
  evidenceToolFailures.set(event.toolCallId, failure);
697
679
  }
698
680
  if (event.type === "message_end" && event.role === "assistant" && boundaryResponse === undefined) {
699
- turns += 1;
700
681
  if (event.usage) addUsage(sessionUsage, event.usage);
701
682
  const msg = event.message as AssistantMessage | undefined;
702
683
  retainedResponse = msg;
@@ -730,7 +711,7 @@ export async function executeAuditorChild(
730
711
  }
731
712
  }
732
713
  }
733
- if (turns >= AUDITOR_TURN_LIMIT || msg.stopReason === "error") boundaryResponse = msg;
714
+ if (msg.stopReason === "error") boundaryResponse = msg;
734
715
  }
735
716
  }
736
717
  if (event.type === "turn_end") {
@@ -861,14 +842,6 @@ export async function executeAuditorChild(
861
842
  : assistants.find((message) =>
862
843
  message.content.some((part) => part.type === "toolCall" && part.name === tool.name));
863
844
 
864
- if (boundaryResponse !== undefined && boundaryResponse.stopReason !== "error" && !decisionSubmitted && noReceiptLifecycle === undefined) {
865
- const toolNames = boundaryResponse.content.flatMap((part) => part.type === "toolCall" ? [part.name] : []);
866
- throw new AuditorTurnLimitError(AUDITOR_TURN_LIMIT, turns, {
867
- stopReason: boundaryResponse.stopReason,
868
- toolNames,
869
- });
870
- }
871
-
872
845
  if (response !== undefined) {
873
846
  try {
874
847
  if (retentionFailure !== undefined) throw retentionFailure;