@xzzpig/pi-subagents 0.25.0 → 0.25.1

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.
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var package_default = {
3
3
  name: "@xzzpig/pi-subagents",
4
- version: "0.25.0",
4
+ version: "0.25.1",
5
5
  description: "Pi extension for single-agent delegation and scripted multi-agent workflows",
6
6
  author: "Nico Bailon",
7
7
  license: "MIT",
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-JWFLPSTP.js";
8
8
  import {
9
9
  package_default
10
- } from "./chunk-YWXILP5N.js";
10
+ } from "./chunk-TM2K53NX.js";
11
11
  import {
12
12
  ensureSupervisorChannelDir
13
13
  } from "./chunk-34TUUBRN.js";
package/bundle/index.js CHANGED
@@ -17,7 +17,7 @@ function readInstalledPackageVersion() {
17
17
  var loadedPackageVersion = readInstalledPackageVersion();
18
18
 
19
19
  // index.ts
20
- var registerExtension = process.env[HERDR_PI_MODE_ENV] === "1" ? (await import("./chunk-6MNRKUHY.js")).default : process.env.PI_SUBAGENT_CHILD === "1" ? void 0 : (await import("./chunk-KCJFGKVK.js")).default;
20
+ var registerExtension = process.env[HERDR_PI_MODE_ENV] === "1" ? (await import("./chunk-SNDCIJMK.js")).default : process.env.PI_SUBAGENT_CHILD === "1" ? void 0 : (await import("./chunk-JUYNN63E.js")).default;
21
21
  function registerSubagentExtension(pi) {
22
22
  const installedVersion = readInstalledPackageVersion();
23
23
  if (installedVersion !== loadedPackageVersion) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@xzzpig/pi-subagents",
4
- "version": "0.25.0",
4
+ "version": "0.25.1",
5
5
  "description": "Pi extension for single-agent delegation and scripted multi-agent workflows",
6
6
  "author": "Nico Bailon",
7
7
  "license": "MIT",
@@ -11,6 +11,7 @@ import { DEFAULT_CONTROL_CONFIG, buildControlEvent, claimControlNotification, de
11
11
  import { getFinalOutput, findLatestSessionFile, detectSubagentError, hasEmptyTerminalAssistantResponse, formatEmptyTerminalAssistantResponseError, getTerminalAssistantStopReason, TRUNCATED_RESPONSE_ERROR, extractToolArgsPreview, assistantMessageError, extractTextFromContent, MAX_STREAMED_RECENT_TOOLS, boundStreamedRecentTools, boundStreamedRecentOutput, boundStreamedToolCalls, } from "../../shared/utils.js";
12
12
  import { resolveSkillsWithFallback } from "../../agents/skills.js";
13
13
  import { createPartialOutputTracker, formatPartialOutput } from "../shared/partial-output.js";
14
+ import { createToolResultHandler } from "./fork-tool-result-handler.js";
14
15
  import { effectiveToolTimeoutMs, formatToolTimeoutMessage, resolveToolTimeoutMs, toolTimeoutCallKey, toolTimeoutFromEnv } from "../shared/tool-timeout.js";
15
16
  import { preflightLaunchCwd } from "../shared/launch-cwd.js";
16
17
  import { createJsonlWriter } from "../../shared/jsonl-writer.js";
@@ -31,11 +32,11 @@ import { planAbortRecovery } from "../shared/abort-recovery.js";
31
32
  import { buildTimeoutRecoverySummary, collectTrackedMutationEvidence, snapshotTrackedMutations } from "../shared/mutation-evidence.js";
32
33
  import { captureSingleOutputSnapshot, extractChildWrittenOutput, finalizeSingleOutput, formatSavedOutputReference, hasSingleOutputChangedSinceSnapshot, isSettlementFatalOutputError, resolveSingleOutput, validateFileOnlyOutputMode } from "../shared/single-output.js";
33
34
  import { formatSubagentModelVerificationError, isContextOverflow, resolveModelSelection, } from "../shared/model-resolution.js";
34
- import { createMutatingFailureState, didMutatingToolFail, isMutatingTool, nextLongRunningTrigger, recordMutatingFailure, resetMutatingFailureState, resolveCurrentPath, shouldEscalateMutatingFailures, summarizeRecentMutatingFailures, } from "../shared/long-running-guard.js";
35
+ import { createMutatingFailureState, isMutatingTool, nextLongRunningTrigger, resolveCurrentPath, } from "../shared/long-running-guard.js";
35
36
  import { acceptanceFailureMessage, buildSkippedAcceptanceLedger, captureStagedIndexBaseline, evaluateAcceptance, formatAcceptancePrompt, resolveEffectiveAcceptance, stripAcceptanceReport, validateAcceptanceInput, typedVerifyOutput } from "../shared/acceptance.js";
36
37
  import { PROMPT_REDACTED } from "../../shared/utils.js";
37
38
  import { attachContractProjections, isAgentContract } from "../shared/agent-contract.js";
38
- import { initialToolBudgetState, isToolBudgetBlockedMessage, toolBudgetState } from "../shared/tool-budget.js";
39
+ import { initialToolBudgetState, toolBudgetState } from "../shared/tool-budget.js";
39
40
  import { resolveWatchdogConfig } from "../../watchdog/settings.js";
40
41
  import { resolveLaunchBinding } from "../../shared/launch-contract.js";
41
42
  import { consumeWorkflowChildPermit } from "../../shared/workflow-child-permit.js";
@@ -756,12 +757,11 @@ async function runSingleAttempt(runtimeCwd, agent, task, model, options, shared)
756
757
  // Pi's parallel tool execution emits every tool_execution_start before the first result message,
757
758
  // so results are matched to their call by toolCallId; the last-started slot covers events without one.
758
759
  const pendingToolResultsByCallId = new Map();
759
- let pendingToolResult;
760
+ const pendingToolState = { current: undefined };
760
761
  // Pi host versions may represent one tool result as either a dedicated
761
762
  // tool_result_end event or a message_end whose message role is toolResult.
762
763
  // Remember correlated ids so normalizing both forms cannot duplicate output.
763
764
  const handledToolResultIds = new Set();
764
- const MAX_HANDLED_TOOL_RESULT_IDS = 1024;
765
765
  let activeToolSequence = 0;
766
766
  const activeToolCalls = new Map();
767
767
  const activeToolKeysByName = new Map();
@@ -966,69 +966,21 @@ async function runSingleAttempt(runtimeCwd, agent, task, model, options, shared)
966
966
  // deliver the same result either as a tool_result_end event or as a
967
967
  // message_end whose message role is toolResult; both funnel through here
968
968
  // so one result updates budget, output, and mutating-failure state once.
969
- const handleToolResult = (message, completion, now) => {
970
- const rawCallId = completion.toolCallId ?? message.toolCallId;
971
- const callId = typeof rawCallId === "string" && rawCallId.length > 0 ? rawCallId : undefined;
972
- if (callId) {
973
- if (handledToolResultIds.has(callId))
974
- return;
975
- if (handledToolResultIds.size >= MAX_HANDLED_TOOL_RESULT_IDS) {
976
- const oldest = handledToolResultIds.values().next().value;
977
- if (typeof oldest === "string")
978
- handledToolResultIds.delete(oldest);
979
- }
980
- handledToolResultIds.add(callId);
981
- }
982
- result.messages.push(message);
983
- const resultText = extractTextFromContent(message.content);
984
- const keyedSnapshot = callId ? pendingToolResultsByCallId.get(callId) : undefined;
985
- if (callId && keyedSnapshot)
986
- pendingToolResultsByCallId.delete(callId);
987
- const toolSnapshot = keyedSnapshot ?? pendingToolResult;
988
- if (!keyedSnapshot || pendingToolResult === keyedSnapshot)
989
- pendingToolResult = undefined;
990
- // The result event's own tool name is authoritative; the snapshot is a fallback.
991
- const resultToolName = completion.toolName ?? message.toolName;
992
- const blockedTool = (typeof resultToolName === "string" && resultToolName.length > 0
993
- ? resultToolName
994
- : undefined) ?? toolSnapshot?.tool;
995
- const budgetBlocked = Boolean(options.toolBudget && isToolBudgetBlockedMessage(options.toolBudget, resultText, blockedTool));
996
- if (options.toolBudget && budgetBlocked) {
997
- result.toolBudgetBlocked = true;
998
- result.toolBudget = toolBudgetState(options.toolBudget, Math.max(progress.toolCount, options.toolBudget.hard + 1), blockedTool);
999
- }
1000
- appendRecentOutput(progress, resultText.split("\n").slice(-10));
1001
- // Pi 1.2+: a successful contact_supervisor progress_update call carries
1002
- // its text back through the result message. Publish the matching
1003
- // snapshot's text so the widget shows the latest successful update.
1004
- const messageToolName = message.toolName;
1005
- if (message.isError !== true && messageToolName === toolSnapshot?.tool && toolSnapshot?.progressText) {
1006
- progress.progressText = toolSnapshot.progressText;
1007
- progress.progressUpdatedAt = now;
1008
- }
1009
- if (toolSnapshot?.mutates && !budgetBlocked && message.role === "toolResult" && didMutatingToolFail(message)) {
1010
- recordMutatingFailure(mutatingFailures, {
1011
- tool: toolSnapshot.tool,
1012
- path: toolSnapshot.path,
1013
- error: resultText.split("\n").find((line) => line.trim())?.trim().slice(0, 180) ?? "mutating tool failed",
1014
- ts: now,
1015
- }, mutatingFailureWindowMs);
1016
- if (shouldEscalateMutatingFailures(mutatingFailures, controlConfig.failedToolAttemptsBeforeAttention)) {
1017
- emitNeedsAttention(now, {
1018
- message: `${agent.name} needs attention after repeated mutating tool failures`,
1019
- reason: "tool_failures",
1020
- currentTool: toolSnapshot.tool,
1021
- currentPath: toolSnapshot.path,
1022
- currentToolDurationMs: toolSnapshot.startedAt ? Math.max(0, now - toolSnapshot.startedAt) : undefined,
1023
- recentFailureSummary: summarizeRecentMutatingFailures(mutatingFailures),
1024
- });
1025
- }
1026
- }
1027
- else if (toolSnapshot?.mutates) {
1028
- resetMutatingFailureState(mutatingFailures);
1029
- }
1030
- fireUpdate();
1031
- };
969
+ const handleToolResult = createToolResultHandler({
970
+ result,
971
+ progress,
972
+ options,
973
+ agentName: agent.name,
974
+ handledToolResultIds,
975
+ pendingToolResultsByCallId,
976
+ pendingToolState,
977
+ mutatingFailures,
978
+ mutatingFailureWindowMs,
979
+ controlConfig,
980
+ appendRecentOutput,
981
+ fireUpdate,
982
+ emitNeedsAttention,
983
+ });
1032
984
  const processEvent = (evt) => {
1033
985
  if (lifecycleFinished)
1034
986
  return;
@@ -1136,9 +1088,9 @@ async function runSingleAttempt(runtimeCwd, agent, task, model, options, shared)
1136
1088
  result.toolBudget = toolBudgetState(options.toolBudget, progress.toolCount, result.toolBudget?.blockedTool);
1137
1089
  }
1138
1090
  const mutates = isMutatingTool(evt.toolName, toolArgs, agent.mutationTools);
1139
- pendingToolResult = { tool: evt.toolName ?? "tool", path: activeTool?.path, mutates, startedAt: now, progressText: extractReportedProgress(evt.toolName ?? "", evt.args) };
1091
+ pendingToolState.current = { tool: evt.toolName ?? "tool", path: activeTool?.path, mutates, startedAt: now, progressText: extractReportedProgress(evt.toolName ?? "", evt.args) };
1140
1092
  if (typeof evt.toolCallId === "string" && evt.toolCallId)
1141
- pendingToolResultsByCallId.set(evt.toolCallId, pendingToolResult);
1093
+ pendingToolResultsByCallId.set(evt.toolCallId, pendingToolState.current);
1142
1094
  fireUpdate();
1143
1095
  }
1144
1096
  if (evt.type === "tool_execution_end") {
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Fork-only tool-result handler for a foreground subagent run.
3
+ *
4
+ * Why this file exists: upstream `execution.ts` has no `handleToolResult`; the
5
+ * fork added ~60 lines of tool-result bookkeeping (budget blocking, mutating
6
+ * failure escalation, supervisor progress publication) inside the run closure.
7
+ * It only reads/writes state the run already owns, so the handler lives here and
8
+ * the upstream run keeps one factory call.
9
+ *
10
+ * `handledToolResultIds` is bounded so a long run cannot grow it without limit;
11
+ * the oldest id is evicted first, which only risks re-processing results the
12
+ * child itself re-sends, never dropping a live one.
13
+ */
14
+ import type { Message } from "@earendil-works/pi-ai";
15
+ import type { AgentProgress, RunSyncOptions, SingleResult } from "../../shared/types.ts";
16
+ import { createMutatingFailureState } from "../shared/long-running-guard.ts";
17
+ import type { ControlEvent } from "../../shared/types.ts";
18
+ export type PendingToolResult = {
19
+ tool: string;
20
+ path?: string;
21
+ mutates: boolean;
22
+ startedAt?: number;
23
+ progressText?: string;
24
+ };
25
+ type MutatingFailureState = ReturnType<typeof createMutatingFailureState>;
26
+ export interface ToolResultHandlerDeps {
27
+ result: SingleResult;
28
+ progress: AgentProgress;
29
+ options: RunSyncOptions;
30
+ /** Name used in the needs-attention message. */
31
+ agentName: string;
32
+ handledToolResultIds: Set<string>;
33
+ pendingToolResultsByCallId: Map<string, PendingToolResult>;
34
+ /** Unkeyed snapshot taken at `tool_call`; the handler consumes it. */
35
+ pendingToolState: {
36
+ current: PendingToolResult | undefined;
37
+ };
38
+ mutatingFailures: MutatingFailureState;
39
+ mutatingFailureWindowMs: number;
40
+ controlConfig: {
41
+ failedToolAttemptsBeforeAttention: number;
42
+ };
43
+ appendRecentOutput(progress: AgentProgress, lines: string[]): void;
44
+ fireUpdate(): void;
45
+ emitNeedsAttention(now: number, input: {
46
+ message?: string;
47
+ reason?: ControlEvent["reason"];
48
+ recentFailureSummary?: string;
49
+ currentTool?: string;
50
+ toolCallId?: string;
51
+ hasCommandController?: boolean;
52
+ currentPath?: string;
53
+ currentToolDurationMs?: number;
54
+ }): boolean;
55
+ }
56
+ export declare function createToolResultHandler(deps: ToolResultHandlerDeps): (message: Message, completion: {
57
+ toolCallId?: unknown;
58
+ toolName?: unknown;
59
+ }, now: number) => void;
60
+ export {};
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Fork-only tool-result handler for a foreground subagent run.
3
+ *
4
+ * Why this file exists: upstream `execution.ts` has no `handleToolResult`; the
5
+ * fork added ~60 lines of tool-result bookkeeping (budget blocking, mutating
6
+ * failure escalation, supervisor progress publication) inside the run closure.
7
+ * It only reads/writes state the run already owns, so the handler lives here and
8
+ * the upstream run keeps one factory call.
9
+ *
10
+ * `handledToolResultIds` is bounded so a long run cannot grow it without limit;
11
+ * the oldest id is evicted first, which only risks re-processing results the
12
+ * child itself re-sends, never dropping a live one.
13
+ */
14
+ import { extractTextFromContent } from "../../shared/utils.js";
15
+ import { didMutatingToolFail, recordMutatingFailure, resetMutatingFailureState, shouldEscalateMutatingFailures, summarizeRecentMutatingFailures, } from "../shared/long-running-guard.js";
16
+ import { isToolBudgetBlockedMessage, toolBudgetState } from "../shared/tool-budget.js";
17
+ const MAX_HANDLED_TOOL_RESULT_IDS = 1024;
18
+ export function createToolResultHandler(deps) {
19
+ const { result, progress, options, agentName, handledToolResultIds, pendingToolResultsByCallId, pendingToolState, mutatingFailures, mutatingFailureWindowMs, controlConfig, appendRecentOutput, fireUpdate, emitNeedsAttention, } = deps;
20
+ return (message, completion, now) => {
21
+ const rawCallId = completion.toolCallId ?? message.toolCallId;
22
+ const callId = typeof rawCallId === "string" && rawCallId.length > 0 ? rawCallId : undefined;
23
+ if (callId) {
24
+ if (handledToolResultIds.has(callId))
25
+ return;
26
+ if (handledToolResultIds.size >= MAX_HANDLED_TOOL_RESULT_IDS) {
27
+ const oldest = handledToolResultIds.values().next().value;
28
+ if (typeof oldest === "string")
29
+ handledToolResultIds.delete(oldest);
30
+ }
31
+ handledToolResultIds.add(callId);
32
+ }
33
+ result.messages.push(message);
34
+ const resultText = extractTextFromContent(message.content);
35
+ const keyedSnapshot = callId ? pendingToolResultsByCallId.get(callId) : undefined;
36
+ if (callId && keyedSnapshot)
37
+ pendingToolResultsByCallId.delete(callId);
38
+ const toolSnapshot = keyedSnapshot ?? pendingToolState.current;
39
+ if (!keyedSnapshot || pendingToolState.current === keyedSnapshot)
40
+ pendingToolState.current = undefined;
41
+ // The result event's own tool name is authoritative; the snapshot is a fallback.
42
+ const resultToolName = completion.toolName ?? message.toolName;
43
+ const blockedTool = (typeof resultToolName === "string" && resultToolName.length > 0
44
+ ? resultToolName
45
+ : undefined) ?? toolSnapshot?.tool;
46
+ const budgetBlocked = Boolean(options.toolBudget && isToolBudgetBlockedMessage(options.toolBudget, resultText, blockedTool));
47
+ if (options.toolBudget && budgetBlocked) {
48
+ result.toolBudgetBlocked = true;
49
+ result.toolBudget = toolBudgetState(options.toolBudget, Math.max(progress.toolCount, options.toolBudget.hard + 1), blockedTool);
50
+ }
51
+ appendRecentOutput(progress, resultText.split("\n").slice(-10));
52
+ // Pi 1.2+: a successful contact_supervisor progress_update call carries
53
+ // its text back through the result message. Publish the matching
54
+ // snapshot's text so the widget shows the latest successful update.
55
+ const messageToolName = message.toolName;
56
+ if (message.isError !== true && messageToolName === toolSnapshot?.tool && toolSnapshot?.progressText) {
57
+ progress.progressText = toolSnapshot.progressText;
58
+ progress.progressUpdatedAt = now;
59
+ }
60
+ if (toolSnapshot?.mutates && !budgetBlocked && message.role === "toolResult" && didMutatingToolFail(message)) {
61
+ recordMutatingFailure(mutatingFailures, {
62
+ tool: toolSnapshot.tool,
63
+ path: toolSnapshot.path,
64
+ error: resultText.split("\n").find((line) => line.trim())?.trim().slice(0, 180) ?? "mutating tool failed",
65
+ ts: now,
66
+ }, mutatingFailureWindowMs);
67
+ if (shouldEscalateMutatingFailures(mutatingFailures, controlConfig.failedToolAttemptsBeforeAttention)) {
68
+ emitNeedsAttention(now, {
69
+ message: `${agentName} needs attention after repeated mutating tool failures`,
70
+ reason: "tool_failures",
71
+ currentTool: toolSnapshot.tool,
72
+ currentPath: toolSnapshot.path,
73
+ currentToolDurationMs: toolSnapshot.startedAt ? Math.max(0, now - toolSnapshot.startedAt) : undefined,
74
+ recentFailureSummary: summarizeRecentMutatingFailures(mutatingFailures),
75
+ });
76
+ }
77
+ }
78
+ else if (toolSnapshot?.mutates) {
79
+ resetMutatingFailureState(mutatingFailures);
80
+ }
81
+ fireUpdate();
82
+ };
83
+ }
@@ -49,3 +49,16 @@ export interface FleetTranscriptReadOptions {
49
49
  export declare function objectValue(value: unknown): Record<string, unknown> | undefined;
50
50
  export declare function safeTranscriptEvent(event: FleetTranscriptEvent): FleetTranscriptEvent;
51
51
  export declare function readFleetTranscript(filePath: string, options: FleetTranscriptReadOptions): FleetTranscript;
52
+ export interface TranscriptRecordRead {
53
+ readFailed?: true;
54
+ records: Array<Record<string, unknown>>;
55
+ truncated: boolean;
56
+ warning?: string;
57
+ }
58
+ /**
59
+ * Shared trusted-root-guarded tail reader that returns raw parsed JSONL
60
+ * records instead of fleet events. Both the legacy rail renderer and the
61
+ * native-component renderer ingest through this single validation path, so
62
+ * symlink refusal and path-escape rejection cannot diverge between them.
63
+ */
64
+ export declare function readTranscriptRecords(filePath: string, options: FleetTranscriptReadOptions): TranscriptRecordRead;
@@ -331,3 +331,46 @@ export function readFleetTranscript(filePath, options) {
331
331
  ...(warnings.length ? { warning: safeDisplayText(warnings.join(" ")) } : {}),
332
332
  };
333
333
  }
334
+ /**
335
+ * Shared trusted-root-guarded tail reader that returns raw parsed JSONL
336
+ * records instead of fleet events. Both the legacy rail renderer and the
337
+ * native-component renderer ingest through this single validation path, so
338
+ * symlink refusal and path-escape rejection cannot diverge between them.
339
+ */
340
+ export function readTranscriptRecords(filePath, options) {
341
+ const validated = validateTranscriptPath(filePath, options.trustedRoots);
342
+ if (!validated.resolvedPath) {
343
+ return { records: [], truncated: false, readFailed: true, ...(validated.warning ? { warning: safeDisplayText(validated.warning) } : {}) };
344
+ }
345
+ const maxRecords = Math.max(1, options.maxRecords ?? DEFAULT_MAX_RECORDS);
346
+ const tail = readTailLines(validated.resolvedPath, Math.max(1024, options.maxBytes ?? DEFAULT_MAX_BYTES));
347
+ const selected = tail.lines.slice(-maxRecords);
348
+ const records = [];
349
+ let malformed = 0;
350
+ for (const line of selected) {
351
+ if (!line.trim())
352
+ continue;
353
+ try {
354
+ const parsed = JSON.parse(line);
355
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
356
+ records.push(parsed);
357
+ }
358
+ else {
359
+ malformed++;
360
+ }
361
+ }
362
+ catch {
363
+ malformed++;
364
+ }
365
+ }
366
+ const warnings = [
367
+ tail.warning,
368
+ malformed > 0 ? `Skipped ${malformed} malformed transcript record${malformed === 1 ? "" : "s"}.` : undefined,
369
+ ].filter((value) => Boolean(value));
370
+ return {
371
+ records,
372
+ ...(tail.warning ? { readFailed: true } : {}),
373
+ truncated: tail.truncated || tail.lines.length > maxRecords,
374
+ ...(warnings.length ? { warning: safeDisplayText(warnings.join(" ")) } : {}),
375
+ };
376
+ }
@@ -1,4 +1,4 @@
1
- import { readTranscriptRecords } from "./fleet-transcript.js";
1
+ import { readTranscriptRecords } from "../shared/fleet-transcript-reader.js";
2
2
  const REQUIRED_NATIVE_EXPORTS = [
3
3
  "createTranscriptState",
4
4
  "appendEntry",
@@ -1,63 +1,7 @@
1
1
  import { type ExtensionContext } from "@earendil-works/pi-coding-agent";
2
2
  import { type MarkdownTheme } from "@earendil-works/pi-tui";
3
+ import { type FleetTranscript } from "../shared/fleet-transcript-reader.ts";
3
4
  type Theme = ExtensionContext["ui"]["theme"];
4
- export type FleetTranscriptEvent = {
5
- kind: "assistant";
6
- text: string;
7
- model?: string;
8
- timestamp?: number;
9
- } | {
10
- kind: "user";
11
- text: string;
12
- timestamp?: number;
13
- } | {
14
- kind: "tool";
15
- toolCallId?: string;
16
- name: string;
17
- args?: string;
18
- argsPayload?: string;
19
- output?: string;
20
- outputTruncated?: boolean;
21
- status: "running" | "complete" | "error";
22
- error?: string;
23
- startedAt?: number;
24
- endedAt?: number;
25
- timestamp?: number;
26
- } | {
27
- kind: "notice";
28
- text: string;
29
- tone: "muted" | "warning" | "error";
30
- timestamp?: number;
31
- };
32
- export interface FleetTranscript {
33
- path: string;
34
- events: FleetTranscriptEvent[];
35
- truncated: boolean;
36
- warning?: string;
37
- /** The path was refused or the file could not be read, as opposed to a read that only skipped records. */
38
- readFailed?: true;
39
- }
40
- export interface FleetTranscriptReadOptions {
41
- trustedRoots: string[];
42
- trustedFiles?: string[];
43
- trustedFileRoot?: string;
44
- maxRecords?: number;
45
- maxBytes?: number;
46
- }
47
- export declare function readFleetTranscript(filePath: string, options: FleetTranscriptReadOptions): FleetTranscript;
48
- export interface TranscriptRecordRead {
49
- readFailed?: true;
50
- records: Array<Record<string, unknown>>;
51
- truncated: boolean;
52
- warning?: string;
53
- }
54
- /**
55
- * Shared trusted-root-guarded tail reader that returns raw parsed JSONL
56
- * records instead of fleet events. Both the legacy rail renderer and the
57
- * native-component renderer ingest through this single validation path, so
58
- * symlink refusal and path-escape rejection cannot diverge between them.
59
- */
60
- export declare function readTranscriptRecords(filePath: string, options: FleetTranscriptReadOptions): TranscriptRecordRead;
61
5
  export declare function renderFleetTranscript(transcript: FleetTranscript, width: number, theme: Theme, markdownTheme: MarkdownTheme, options?: {
62
6
  expandedTools?: boolean;
63
7
  }): string[];