@akagilnc/pi-workflow-roles 0.1.4956 → 0.1.4977

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.
@@ -8,7 +8,9 @@ import type {
8
8
  AnyCanonicalSkillBinding,
9
9
  CanonicalSkillBinding,
10
10
  } from "./canonical-skill-binding.ts";
11
- import { packagedRoleAcceptedText } from "./packaged-role-registry.ts";
11
+ import { readableGateItem } from "./readable-gate-item.ts";
12
+ import { projectAuditEscalation } from "./audit-escalation.ts";
13
+ import { GatekeeperDecisionError } from "./submission-errors.ts";
12
14
  import {
13
15
  CODER_OUTPUT_TOOL_NAME,
14
16
  FIXER_OUTPUT_TOOL_NAME,
@@ -282,20 +284,28 @@ export function createFixerRoleRuntime(
282
284
  ctx,
283
285
  toolCallId,
284
286
  );
285
- if (WORKER_DONE_STATUSES.has(workerStatusOf(output))) {
286
- await pi.requireGatekeeperPass!({
287
- context: ctx,
288
- subject: { kind: "worker_completion" },
289
- ...(_signal === undefined ? {} : { signal: _signal }),
290
- hostActions,
291
- toolCallId,
292
- // #879: this-turn typed payload — identity-bound at submit site.
293
- submission: output,
294
- });
287
+ let pass;
288
+ try {
289
+ pass = WORKER_DONE_STATUSES.has(workerStatusOf(output))
290
+ ? await pi.requireGatekeeperPass!({
291
+ context: ctx,
292
+ subject: { kind: "worker_completion" },
293
+ ...(_signal === undefined ? {} : { signal: _signal }),
294
+ hostActions,
295
+ toolCallId,
296
+ // #879: this-turn typed payload — identity-bound at submit site.
297
+ submission: output,
298
+ })
299
+ : undefined;
300
+ } catch (error) {
301
+ if (error instanceof GatekeeperDecisionError && error.result.status === "escalate") {
302
+ return projectAuditEscalation({ status: "escalate", conflicts: error.result.receipt }, output);
303
+ }
304
+ throw error;
295
305
  }
296
306
  const acceptedDetails = output;
297
307
  return {
298
- content: [{ type: "text" as const, text: packagedRoleAcceptedText("fixer") }],
308
+ content: pass === undefined ? [] : [{ type: "text" as const, text: readableGateItem(pass.receipt) }],
299
309
  details: acceptedDetails,
300
310
  terminate: true as const,
301
311
  };
@@ -407,7 +417,7 @@ export function createCoderRoleRuntime(
407
417
  description: "提交将作监终局回执;本工具无 escalate 通道。",
408
418
  promptSnippet: "提交将作监终局回执",
409
419
  parameters: coderOutputSchema,
410
- async execute(toolCallId: string, parameters: unknown, _signal: AbortSignal | undefined, _onUpdate: unknown, ctx: HostContext) {
420
+ async execute(toolCallId: string, parameters: unknown, _signal: AbortSignal | undefined, _onUpdate: unknown, ctx: HostContext): Promise<HostToolResult<unknown>> {
411
421
  if (task === undefined || phase === undefined) {
412
422
  throw new Error("将作监任务与阶段未装载");
413
423
  }
@@ -422,20 +432,28 @@ export function createCoderRoleRuntime(
422
432
  ctx,
423
433
  toolCallId,
424
434
  );
425
- if (WORKER_DONE_STATUSES.has(workerStatusOf(output))) {
426
- await pi.requireGatekeeperPass!({
427
- context: ctx,
428
- subject: { kind: "worker_completion" },
429
- ...(_signal === undefined ? {} : { signal: _signal }),
430
- hostActions,
431
- toolCallId,
432
- // #879: this-turn typed payload — identity-bound at submit site.
433
- submission: output,
434
- });
435
+ let pass;
436
+ try {
437
+ pass = WORKER_DONE_STATUSES.has(workerStatusOf(output))
438
+ ? await pi.requireGatekeeperPass!({
439
+ context: ctx,
440
+ subject: { kind: "worker_completion" },
441
+ ...(_signal === undefined ? {} : { signal: _signal }),
442
+ hostActions,
443
+ toolCallId,
444
+ // #879: this-turn typed payload — identity-bound at submit site.
445
+ submission: output,
446
+ })
447
+ : undefined;
448
+ } catch (error) {
449
+ if (error instanceof GatekeeperDecisionError && error.result.status === "escalate") {
450
+ return projectAuditEscalation({ status: "escalate", conflicts: error.result.receipt }, output);
451
+ }
452
+ throw error;
435
453
  }
436
454
  const acceptedDetails = output;
437
455
  return {
438
- content: [{ type: "text" as const, text: packagedRoleAcceptedText("coder") }],
456
+ content: pass === undefined ? [] : [{ type: "text" as const, text: readableGateItem(pass.receipt) }],
439
457
  details: acceptedDetails,
440
458
  terminate: true as const,
441
459
  };