@arhen/pi-core-subagent 1.3.64 → 1.3.65

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.
@@ -0,0 +1,30 @@
1
+ import { createHash } from "node:crypto";
2
+ import type { TaskSnapshot } from "./types.ts";
3
+
4
+ export function textFingerprint(text: string): string {
5
+ return createHash("sha256").update(text.trim()).digest("hex");
6
+ }
7
+
8
+ export function matchesFinalText(task: TaskSnapshot, text: string): boolean {
9
+ return textFingerprint(text) === (task.finalTextFingerprint ?? textFingerprint(task.finalText ?? ""));
10
+ }
11
+
12
+ export function artifactFingerprint(task: TaskSnapshot): string | undefined {
13
+ if (!task.changedFiles?.length && !task.diffStat?.trim() && !task.worktreeError) return undefined;
14
+ return textFingerprint(
15
+ JSON.stringify([task.branch, [...(task.changedFiles ?? [])].sort(), task.diffStat, task.worktreeError]),
16
+ );
17
+ }
18
+
19
+ export function outcomeFingerprint(task: TaskSnapshot): string {
20
+ return textFingerprint(
21
+ JSON.stringify([
22
+ task.startedAt,
23
+ task.status,
24
+ task.toolCalls,
25
+ task.finalTextFingerprint ?? textFingerprint(task.finalText ?? ""),
26
+ task.error,
27
+ artifactFingerprint(task),
28
+ ]),
29
+ );
30
+ }
package/src/types.ts CHANGED
@@ -30,7 +30,16 @@ export interface TaskSnapshot {
30
30
  toolCalls: number;
31
31
  lastActivity?: string;
32
32
  finalText?: string;
33
+ finalTextFingerprint?: string;
33
34
  notifiedParent?: boolean;
35
+ finalParentReport?: {
36
+ body: string;
37
+ message: string;
38
+ toolCalls: number;
39
+ fingerprint?: string;
40
+ artifacts?: string;
41
+ delivery: "pending" | "message" | "parked" | "lost" | "awaited";
42
+ };
34
43
  error?: string;
35
44
  model?: string;
36
45
  provider?: string;
@@ -62,6 +71,7 @@ export interface RunSnapshot {
62
71
  tasks: TaskSnapshot[];
63
72
  aggregateUsage: UsageStats;
64
73
  awaited?: boolean;
74
+ completionAwaited?: boolean;
65
75
  }
66
76
 
67
77
  export interface RunDetails {