@narumitw/pi-goal 0.54.15 → 0.54.17
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.
- package/CHANGELOG.md +15 -0
- package/README.md +25 -7
- package/dist/chunks/{chunk-SL6SIIVB.ts → chunk-MHW7VEET.ts} +41 -21
- package/dist/chunks/chunk-MHW7VEET.ts.map +7 -0
- package/dist/chunks/{chunk-RNWM7MOG.ts → chunk-ZLKWPYIF.ts} +2 -13
- package/dist/chunks/chunk-ZLKWPYIF.ts.map +7 -0
- package/dist/chunks/{menu-H43NPYIW.ts → menu-3AYWQ637.ts} +3 -3
- package/dist/chunks/{settings-ui-T77VFPTK.ts → settings-ui-RVQTWGJ5.ts} +2 -2
- package/dist/index.ts +76 -43
- package/dist/index.ts.map +2 -2
- package/docs/continuation-lifecycle.md +62 -15
- package/package.json +2 -2
- package/src/errors.ts +2 -16
- package/src/lifecycle.ts +91 -41
- package/src/persistence.ts +2 -1
- package/src/runtime.ts +70 -21
- package/dist/chunks/chunk-RNWM7MOG.ts.map +0 -7
- package/dist/chunks/chunk-SL6SIIVB.ts.map +0 -7
- /package/dist/chunks/{menu-H43NPYIW.ts.map → menu-3AYWQ637.ts.map} +0 -0
- /package/dist/chunks/{settings-ui-T77VFPTK.ts.map → settings-ui-RVQTWGJ5.ts.map} +0 -0
package/src/runtime.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
2
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
3
3
|
import { checkpointGoalActiveTime, formatDuration, formatTokenCount, updateGoalUsage } from "./accounting.js";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
formatError,
|
|
6
|
+
isStaleContextError,
|
|
7
|
+
isUsageLimitedGoalInterruption,
|
|
8
|
+
notifyTerminal,
|
|
9
|
+
safeGoalMenuText,
|
|
10
|
+
truncateNotification,
|
|
11
|
+
} from "./errors.js";
|
|
5
12
|
import {
|
|
6
13
|
createGoalContextContract,
|
|
7
14
|
createInactiveGoalContextContract,
|
|
@@ -47,7 +54,7 @@ export interface BudgetWrapUp {
|
|
|
47
54
|
delivered: boolean;
|
|
48
55
|
}
|
|
49
56
|
|
|
50
|
-
export type GoalRecoveryKind = "provider_retry" | "compaction_retry";
|
|
57
|
+
export type GoalRecoveryKind = "provider_retry" | "provider_error" | "compaction_retry";
|
|
51
58
|
|
|
52
59
|
export type GoalRunOrigin = "manual" | "automatic";
|
|
53
60
|
|
|
@@ -76,7 +83,12 @@ export type GoalStopRequest =
|
|
|
76
83
|
abortTurn: boolean;
|
|
77
84
|
reason: string;
|
|
78
85
|
}
|
|
79
|
-
| {
|
|
86
|
+
| {
|
|
87
|
+
kind: "recovery_ended";
|
|
88
|
+
expectedGoalId: string;
|
|
89
|
+
status: "paused" | "blocked" | "usage_limited";
|
|
90
|
+
reason: string;
|
|
91
|
+
}
|
|
80
92
|
| {
|
|
81
93
|
kind: "tools_unavailable";
|
|
82
94
|
expectedGoalId: string;
|
|
@@ -158,6 +170,7 @@ export interface GoalSettingsRuntimeSnapshot {
|
|
|
158
170
|
continuationDelivery?: ContinuationTicket;
|
|
159
171
|
goalRecovery?: GoalRecovery;
|
|
160
172
|
budgetWrapUp?: BudgetWrapUp;
|
|
173
|
+
pendingLengthRecovery?: GoalRecovery;
|
|
161
174
|
guardAbortGoalId?: string;
|
|
162
175
|
staleGoalToolCallsBlocked: boolean;
|
|
163
176
|
cancelledContinuationMarkers: [string, string][];
|
|
@@ -226,6 +239,9 @@ export class GoalRuntime {
|
|
|
226
239
|
continuationIntent?: ContinuationTicket;
|
|
227
240
|
continuationDelivery?: ContinuationTicket;
|
|
228
241
|
goalRecovery?: GoalRecovery;
|
|
242
|
+
// Unconfirmed length recovery is invalidated by the same runtime transitions
|
|
243
|
+
// as provider errors, including a later accepted goal_wait.
|
|
244
|
+
pendingLengthRecovery?: GoalRecovery;
|
|
229
245
|
budgetWrapUp?: BudgetWrapUp;
|
|
230
246
|
/** `null` marks a run that must not be charged to the active goal. */
|
|
231
247
|
agentRunGoalId?: string | null;
|
|
@@ -622,12 +638,12 @@ export class GoalRuntime {
|
|
|
622
638
|
status = "paused";
|
|
623
639
|
terminalReason = request.reason;
|
|
624
640
|
break;
|
|
625
|
-
case "
|
|
641
|
+
case "recovery_ended":
|
|
626
642
|
this.clearGoalRecoveryForGoal(goal.id);
|
|
627
643
|
this.cancelContinuationWork();
|
|
628
644
|
this.clearBudgetWrapUp();
|
|
629
645
|
this.blockStaleGoalToolCalls();
|
|
630
|
-
status =
|
|
646
|
+
status = request.status;
|
|
631
647
|
terminalReason = request.reason;
|
|
632
648
|
break;
|
|
633
649
|
case "tools_unavailable":
|
|
@@ -690,6 +706,7 @@ export class GoalRuntime {
|
|
|
690
706
|
|
|
691
707
|
clearGoalRecovery() {
|
|
692
708
|
this.goalRecovery = undefined;
|
|
709
|
+
this.pendingLengthRecovery = undefined;
|
|
693
710
|
}
|
|
694
711
|
|
|
695
712
|
clearBudgetWrapUp() {
|
|
@@ -797,9 +814,11 @@ export class GoalRuntime {
|
|
|
797
814
|
goal.toolFreeRepeatCount = next.toolFreeRepeatCount;
|
|
798
815
|
goal.lastToolFreeOutputFingerprint = next.lastToolFreeOutputFingerprint;
|
|
799
816
|
this.persistGoal(goal);
|
|
800
|
-
this.
|
|
817
|
+
const currentGoal = this.activeGoal;
|
|
818
|
+
if (currentGoal?.id !== goalId || !this.ownsWorkflow(currentGoal)) return true;
|
|
819
|
+
this.updateStatus(ctx, currentGoal);
|
|
801
820
|
const limit = this.settings.continuationLimits.noProgressTurns;
|
|
802
|
-
if (limit === null ||
|
|
821
|
+
if (limit === null || currentGoal.toolFreeRepeatCount < limit) return false;
|
|
803
822
|
return this.pauseGoalForSafety(ctx, "no_progress", false);
|
|
804
823
|
}
|
|
805
824
|
|
|
@@ -857,38 +876,63 @@ export class GoalRuntime {
|
|
|
857
876
|
return true;
|
|
858
877
|
}
|
|
859
878
|
|
|
860
|
-
finalizeSettledRecovery(ctx: StatusContext) {
|
|
879
|
+
finalizeSettledRecovery(ctx: StatusContext, aborted: boolean, settledGoalId: string | undefined) {
|
|
861
880
|
const recovery = this.goalRecovery;
|
|
862
|
-
if (!recovery) return false;
|
|
881
|
+
if (!recovery && !aborted) return false;
|
|
863
882
|
this.goalRecovery = undefined;
|
|
864
883
|
const goal = this.activeGoal;
|
|
865
|
-
if (goal
|
|
884
|
+
if (!goal || goal.id !== (recovery?.goalId ?? settledGoalId) || !this.ownsWorkflow(goal)) {
|
|
866
885
|
return false;
|
|
867
886
|
}
|
|
868
|
-
const details = recovery
|
|
869
|
-
|
|
887
|
+
const details = recovery?.errorMessage ? `: ${truncateNotification(recovery.errorMessage)}` : "";
|
|
888
|
+
const usageLimited = isUsageLimitedGoalInterruption({
|
|
889
|
+
role: "assistant",
|
|
890
|
+
stopReason: "error",
|
|
891
|
+
errorMessage: recovery?.errorMessage,
|
|
892
|
+
});
|
|
893
|
+
if (!aborted && !usageLimited && recovery && recovery.kind !== "compaction_retry") {
|
|
894
|
+
// Native post-run work can change limits or tool availability after agent_end.
|
|
895
|
+
if (
|
|
896
|
+
this.enforceAutomaticTurnLimit(ctx, false) ||
|
|
897
|
+
this.enforceNoProgressLimit(ctx) ||
|
|
898
|
+
this.limitActiveGoalForBudget(ctx, false)
|
|
899
|
+
) {
|
|
900
|
+
return true;
|
|
901
|
+
}
|
|
902
|
+
if (!this.goalToolsAvailable()) return this.pauseGoalForUnavailableTools(ctx, false);
|
|
903
|
+
// A parallel tool batch can continue after accepting goal_wait. Preserve
|
|
904
|
+
// its arranged wake source and deadline instead of replacing that wait.
|
|
905
|
+
if (goal.waiting) return true;
|
|
906
|
+
const nativeRetry = recovery.kind === "provider_retry";
|
|
870
907
|
const waitingGoal = this.enterGoalWait(ctx, goal.id, {
|
|
871
|
-
reason:
|
|
908
|
+
reason: `${nativeRetry ? "Provider retries exhausted" : "Provider error"}${details}`,
|
|
872
909
|
});
|
|
873
910
|
if (!waitingGoal) return false;
|
|
874
911
|
notifyTerminal(
|
|
875
912
|
ctx.ui,
|
|
876
|
-
|
|
913
|
+
nativeRetry
|
|
914
|
+
? `Goal waiting after provider retries were exhausted${details}. Send a follow-up or run /goal resume to retry.`
|
|
915
|
+
: `Goal waiting after a provider error${details}. No automatic retry was added. Send a follow-up or run /goal resume to continue.`,
|
|
877
916
|
"warning",
|
|
878
917
|
);
|
|
879
918
|
return true;
|
|
880
919
|
}
|
|
920
|
+
// Cancellation during backoff or after agent_end need not produce another
|
|
921
|
+
// assistant or compaction event. Keep the ended Goal identity as a fallback.
|
|
922
|
+
const status = aborted ? "paused" : usageLimited ? "usage_limited" : "blocked";
|
|
881
923
|
const stoppedGoal = this.stopActiveGoal(ctx, {
|
|
882
|
-
kind: "
|
|
924
|
+
kind: "recovery_ended",
|
|
883
925
|
expectedGoalId: goal.id,
|
|
884
|
-
|
|
926
|
+
status,
|
|
927
|
+
reason: aborted ? "goal paused after agent interruption" : `agent error after retries${details}`,
|
|
885
928
|
});
|
|
886
929
|
if (!stoppedGoal) return false;
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
930
|
+
const message = aborted
|
|
931
|
+
? "Goal paused after interruption. Run /goal resume to continue."
|
|
932
|
+
: usageLimited
|
|
933
|
+
? `Goal stopped after provider usage limit${details}. Run /goal resume when usage is available.`
|
|
934
|
+
: `Goal blocked after agent error retries were exhausted${details}. Resolve the blocker or run /goal resume to retry.`;
|
|
935
|
+
notifyTerminal(ctx.ui, message, "warning");
|
|
892
936
|
return true;
|
|
893
937
|
}
|
|
894
938
|
|
|
@@ -902,6 +946,7 @@ export class GoalRuntime {
|
|
|
902
946
|
|
|
903
947
|
clearGoalRecoveryForGoal(goalId: string) {
|
|
904
948
|
if (this.goalRecovery?.goalId === goalId) this.goalRecovery = undefined;
|
|
949
|
+
if (this.pendingLengthRecovery?.goalId === goalId) this.pendingLengthRecovery = undefined;
|
|
905
950
|
}
|
|
906
951
|
|
|
907
952
|
isPiOwnedCompactionRetry(event: unknown, goalId: string) {
|
|
@@ -1252,6 +1297,7 @@ export class GoalRuntime {
|
|
|
1252
1297
|
continuationIntent: this.continuationIntent ? structuredClone(this.continuationIntent) : undefined,
|
|
1253
1298
|
continuationDelivery: this.continuationDelivery ? structuredClone(this.continuationDelivery) : undefined,
|
|
1254
1299
|
goalRecovery: this.goalRecovery ? structuredClone(this.goalRecovery) : undefined,
|
|
1300
|
+
pendingLengthRecovery: this.pendingLengthRecovery ? structuredClone(this.pendingLengthRecovery) : undefined,
|
|
1255
1301
|
budgetWrapUp: this.budgetWrapUp ? structuredClone(this.budgetWrapUp) : undefined,
|
|
1256
1302
|
guardAbortGoalId: this.guardAbortGoalId,
|
|
1257
1303
|
staleGoalToolCallsBlocked: this.staleGoalToolCallsBlocked,
|
|
@@ -1273,6 +1319,9 @@ export class GoalRuntime {
|
|
|
1273
1319
|
? structuredClone(snapshot.continuationDelivery)
|
|
1274
1320
|
: undefined;
|
|
1275
1321
|
this.goalRecovery = snapshot.goalRecovery ? structuredClone(snapshot.goalRecovery) : undefined;
|
|
1322
|
+
this.pendingLengthRecovery = snapshot.pendingLengthRecovery
|
|
1323
|
+
? structuredClone(snapshot.pendingLengthRecovery)
|
|
1324
|
+
: undefined;
|
|
1276
1325
|
this.budgetWrapUp = snapshot.budgetWrapUp ? structuredClone(snapshot.budgetWrapUp) : undefined;
|
|
1277
1326
|
this.guardAbortGoalId = snapshot.guardAbortGoalId;
|
|
1278
1327
|
this.staleGoalToolCallsBlocked = snapshot.staleGoalToolCallsBlocked;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/accounting.ts", "../../src/errors.ts", "../../src/settings.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Usage } from \"@earendil-works/pi-ai\";\n\nexport interface GoalAccountingState {\n status: string;\n baselineTokens: number;\n tokensUsed: number;\n timeUsedSeconds: number;\n activeStartedAt?: number;\n updatedAt: number;\n}\n\ninterface AssistantUsageEntryLike {\n type?: unknown;\n message?: unknown;\n}\n\ninterface UsageContext {\n sessionManager?: unknown;\n}\n\nexport function checkpointGoalActiveTime(goal: GoalAccountingState, now: number, continueClock: boolean) {\n const accumulated = nonNegativeFiniteNumber(goal.timeUsedSeconds);\n const startedAt = goal.activeStartedAt;\n if (typeof startedAt === \"number\" && Number.isFinite(startedAt)) {\n goal.timeUsedSeconds = accumulated + Math.max(0, now - startedAt) / 1000;\n } else {\n goal.timeUsedSeconds = accumulated;\n }\n goal.activeStartedAt = continueClock ? now : undefined;\n}\n\nexport function updateGoalUsage(\n goal: GoalAccountingState,\n ctx: UsageContext,\n continueClock = goal.status === \"active\",\n) {\n const now = Date.now();\n const baselineTokens = nonNegativeFiniteNumber(goal.baselineTokens);\n goal.baselineTokens = baselineTokens;\n goal.tokensUsed = Math.max(0, currentTokenTotal(ctx) - baselineTokens);\n checkpointGoalActiveTime(goal, now, continueClock);\n goal.updatedAt = now;\n}\n\nexport function formatDuration(seconds: number) {\n const wholeSeconds = Math.max(0, Math.floor(nonNegativeFiniteNumber(seconds)));\n if (wholeSeconds < 60) return `${wholeSeconds}s`;\n const minutes = Math.floor(wholeSeconds / 60);\n if (minutes < 60) return `${minutes}m`;\n const hours = Math.floor(minutes / 60);\n return `${hours}h${minutes % 60}m`;\n}\n\nexport function formatTokenCount(value: number) {\n if (value < 1_000) return `${value}`;\n if (value < 1_000_000) {\n return `${Number.isInteger(value / 1_000) ? value / 1_000 : (value / 1_000).toFixed(1)}k`;\n }\n return `${Number.isInteger(value / 1_000_000) ? value / 1_000_000 : (value / 1_000_000).toFixed(1)}m`;\n}\n\nexport function isNonNegativeFiniteNumber(value: unknown): value is number {\n return typeof value === \"number\" && Number.isFinite(value) && value >= 0;\n}\n\nexport function nonNegativeFiniteNumber(value: unknown) {\n return isNonNegativeFiniteNumber(value) ? value : 0;\n}\n\nexport function normalizeTokenBudget(value: unknown) {\n return typeof value === \"number\" && Number.isSafeInteger(value) && value > 0 ? value : undefined;\n}\n\nexport function assistantUsageTokens(value: unknown) {\n if (!value || typeof value !== \"object\") return 0;\n const usage = value as Partial<Usage>;\n if (isNonNegativeFiniteNumber(usage.totalTokens)) return usage.totalTokens;\n return Math.min(\n Number.MAX_SAFE_INTEGER,\n nonNegativeFiniteNumber(usage.input) +\n nonNegativeFiniteNumber(usage.output) +\n nonNegativeFiniteNumber(usage.cacheRead) +\n nonNegativeFiniteNumber(usage.cacheWrite),\n );\n}\n\nexport function cumulativeAssistantTokens(entries: unknown[]) {\n let total = 0;\n for (const entry of entries) {\n const candidate = entry as AssistantUsageEntryLike;\n if (candidate?.type !== \"message\") continue;\n const message = candidate.message as { role?: unknown; usage?: unknown } | undefined;\n if (message?.role !== \"assistant\") continue;\n total = Math.min(Number.MAX_SAFE_INTEGER, total + assistantUsageTokens(message.usage));\n }\n return total;\n}\n\nexport function currentTokenTotal(ctx: UsageContext): number {\n const sessionManager = ctx.sessionManager as { getBranch?: () => unknown[] } | undefined;\n return cumulativeAssistantTokens(sessionManager?.getBranch?.() ?? []);\n}\n", "import {\n isContextOverflow,\n isRetryableAssistantError,\n type AssistantMessage as PiAssistantMessage,\n type Usage,\n} from \"@earendil-works/pi-ai\";\nimport { stripTerminalSequences } from \"@earendil-works/pi-tui\";\nimport { assistantUsageTokens, nonNegativeFiniteNumber } from \"./accounting.js\";\n\nexport type AgentStopReason = \"stop\" | \"length\" | \"toolUse\" | \"error\" | \"aborted\";\n\nexport interface AssistantMessageLike {\n role: \"assistant\";\n stopReason?: AgentStopReason;\n errorMessage?: string;\n content?: PiAssistantMessage[\"content\"];\n api?: PiAssistantMessage[\"api\"];\n provider?: PiAssistantMessage[\"provider\"];\n model?: string;\n usage?: Usage;\n timestamp?: number;\n}\n\nconst USAGE_LIMIT_GOAL_ERROR_PATTERNS = [\n /usage[_\\s-]*(?:limit|cap)|chatgpt.{0,32}usage/i,\n /quota.{0,32}(?:reached|exceeded|exhausted|depleted)|(?:reached|exceeded|exhausted|depleted).{0,32}quota/i,\n /insufficient[_\\s-]*(?:quota|credits?)|out of credits|out of budget|available balance|payment required/i,\n /(?:credit|balance).{0,32}(?:low|exhausted|depleted)|billing/i,\n] as const;\nconst NON_RETRYABLE_GOAL_ERROR_RE = /multi-auth rotation failed|credentials tried|unauthori[sz]ed|invalid api key/i;\nconst RETRYABLE_GOAL_ERROR_PATTERNS = [\n /overloaded|rate.?limit|too many requests|\\b(?:429|500|502|503|504)\\b|service.?unavailable|server.?error|internal.?error/i,\n /provider.?returned.?error|you can retry your request|try your request again|please retry your request/i,\n /network.?error|connection.?(?:error|refused|lost)|other side closed|fetch failed|upstream.?connect|reset before headers|socket hang up/i,\n /timed? out|timeout|terminated|websocket.?(?:closed|error)|ended without|stream (?:ended|closed|terminated) before|premature (?:close|end)|incomplete (?:stream|response)|unexpected end of (?:stream|response)|http2 request did not get a response|retry delay/i,\n /context[_\\s-]*length[_\\s-]*exceeded|input exceeds the context window/i,\n] as const;\n\nexport function safeTerminalText(value: string) {\n return [...stripTerminalSequences(value)]\n .map((character) => {\n const codePoint = character.codePointAt(0) ?? 0;\n if (character === \"\\n\") return character;\n return codePoint <= 0x1f || (codePoint >= 0x7f && codePoint <= 0x9f) ? \" \" : character;\n })\n .join(\"\")\n .trim();\n}\n\nexport function safeGoalMenuText(value: string, maxCharacters = 120) {\n const sanitized = safeTerminalText(value).replace(/\\s+/gu, \" \").trim();\n const characters = [...sanitized];\n return characters.length <= maxCharacters ? sanitized : `${characters.slice(0, maxCharacters).join(\"\")}\u2026`;\n}\n\nexport function notifyTerminal(\n ui: { notify: (message: string, level?: \"info\" | \"warning\" | \"error\") => void },\n message: string,\n level?: \"info\" | \"warning\" | \"error\",\n) {\n ui.notify(safeTerminalText(message), level);\n}\n\n/**\n * True when an error came from an ExtensionContext invalidated by session\n * replacement or reload. Pi throws this from every ctx getter and pi method on\n * the stale runner, so deferred callbacks must treat it as cancellation.\n */\nexport function isStaleContextError(error: unknown): boolean {\n return (\n error instanceof Error && error.message.includes(\"This extension ctx is stale after session replacement or reload\")\n );\n}\n\nexport function formatError(error: unknown) {\n return truncateNotification(error instanceof Error ? error.message : String(error));\n}\n\nexport function truncateNotification(value: string) {\n const safe = [...safeTerminalText(value)];\n return safe.length > 160 ? `${safe.slice(0, 157).join(\"\")}...` : safe.join(\"\");\n}\n\nexport function isUsageLimitedGoalInterruption(assistant: AssistantMessageLike) {\n const errorMessage = assistant.errorMessage;\n return (\n assistant.stopReason === \"error\" &&\n typeof errorMessage === \"string\" &&\n USAGE_LIMIT_GOAL_ERROR_PATTERNS.some((pattern) => pattern.test(errorMessage))\n );\n}\n\nexport function isRetryableGoalInterruption(assistant: AssistantMessageLike) {\n if (assistant.stopReason !== \"error\" || !assistant.errorMessage) return false;\n if (isUsageLimitedGoalInterruption(assistant) || NON_RETRYABLE_GOAL_ERROR_RE.test(assistant.errorMessage)) {\n return false;\n }\n return (\n isGoalContextOverflow(assistant) ||\n isRetryableAssistantError(toPiAssistantMessage(assistant)) ||\n RETRYABLE_GOAL_ERROR_PATTERNS.some((pattern) => pattern.test(assistant.errorMessage ?? \"\"))\n );\n}\n\nexport function isGoalContextOverflow(assistant: AssistantMessageLike) {\n return isContextOverflow(toPiAssistantMessage(assistant));\n}\n\nexport function findFinalAssistantMessage(messages: unknown[]): AssistantMessageLike | undefined {\n for (let index = messages.length - 1; index >= 0; index--) {\n const message = messages[index];\n if (!message || typeof message !== \"object\") continue;\n const candidate = message as Record<string, unknown>;\n if (candidate.role !== \"assistant\") continue;\n const assistant: AssistantMessageLike = {\n role: \"assistant\",\n stopReason: isAgentStopReason(candidate.stopReason) ? candidate.stopReason : undefined,\n errorMessage: typeof candidate.errorMessage === \"string\" ? candidate.errorMessage : undefined,\n };\n if (Array.isArray(candidate.content)) {\n assistant.content = candidate.content as PiAssistantMessage[\"content\"];\n }\n if (typeof candidate.api === \"string\") assistant.api = candidate.api;\n if (typeof candidate.provider === \"string\") assistant.provider = candidate.provider;\n if (typeof candidate.model === \"string\") assistant.model = candidate.model;\n if (typeof candidate.timestamp === \"number\") assistant.timestamp = candidate.timestamp;\n const usage = normalizeUsage(candidate.usage);\n if (usage) assistant.usage = usage;\n return assistant;\n }\n return undefined;\n}\n\nfunction toPiAssistantMessage(assistant: AssistantMessageLike): PiAssistantMessage {\n return {\n role: \"assistant\",\n content: assistant.content ?? [],\n api: assistant.api ?? \"openai-responses\",\n provider: assistant.provider ?? \"unknown\",\n model: assistant.model ?? \"unknown\",\n usage: assistant.usage ?? zeroUsage(),\n stopReason: assistant.stopReason ?? \"error\",\n errorMessage: assistant.errorMessage,\n timestamp: assistant.timestamp ?? Date.now(),\n };\n}\n\nfunction zeroUsage(): Usage {\n return {\n input: 0,\n output: 0,\n cacheRead: 0,\n cacheWrite: 0,\n totalTokens: 0,\n cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },\n };\n}\n\nfunction isAgentStopReason(value: unknown): value is AgentStopReason {\n return [\"stop\", \"length\", \"toolUse\", \"error\", \"aborted\"].includes(String(value));\n}\n\nfunction normalizeUsage(value: unknown): Usage | undefined {\n if (!value || typeof value !== \"object\") return undefined;\n const usage = value as Partial<Usage>;\n if (typeof usage.input !== \"number\" || typeof usage.output !== \"number\") return undefined;\n return {\n input: nonNegativeFiniteNumber(usage.input),\n output: nonNegativeFiniteNumber(usage.output),\n cacheRead: nonNegativeFiniteNumber(usage.cacheRead),\n cacheWrite: nonNegativeFiniteNumber(usage.cacheWrite),\n totalTokens: assistantUsageTokens(usage),\n cost: {\n input: usage.cost?.input ?? 0,\n output: usage.cost?.output ?? 0,\n cacheRead: usage.cost?.cacheRead ?? 0,\n cacheWrite: usage.cost?.cacheWrite ?? 0,\n total: usage.cost?.total ?? 0,\n },\n };\n}\n", "import { randomUUID } from \"node:crypto\";\nimport { mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from \"node:fs\";\nimport { basename, dirname, join } from \"node:path\";\nimport { getAgentDir } from \"@earendil-works/pi-coding-agent\";\n\nexport const GOAL_SETTINGS_FILE = \"pi-goal.json\";\n\nexport type ContinuationLimit = number | null;\n\nexport interface GoalSettings {\n rpc: {\n enabled: boolean;\n };\n continuationLimits: {\n automaticTurns: ContinuationLimit;\n noProgressTurns: ContinuationLimit;\n };\n}\n\nexport const DEFAULT_GOAL_SETTINGS: GoalSettings = {\n rpc: { enabled: false },\n continuationLimits: { automaticTurns: 25, noProgressTurns: 3 },\n};\n\nexport type GoalSettingsLoadResult =\n | { kind: \"missing\"; legacyExperimentalGoals: false }\n | { kind: \"invalid\"; reason: string }\n | { kind: \"loaded\"; settings: GoalSettings; legacyExperimentalGoals: boolean };\n\nexport type GoalSettingsLoadIssue = Extract<GoalSettingsLoadResult, { kind: \"invalid\" }>;\n\ninterface GoalSettingsSaveFileSystem {\n mkdirSync: typeof mkdirSync;\n writeFileSync: typeof writeFileSync;\n renameSync: typeof renameSync;\n rmSync: typeof rmSync;\n}\n\nexport function normalizeGoalSettings(value: unknown): GoalSettings | undefined {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) return undefined;\n\n const rpcValue = Object.hasOwn(value, \"rpc\") ? Reflect.get(value, \"rpc\") : undefined;\n if (rpcValue !== undefined && (typeof rpcValue !== \"object\" || rpcValue === null || Array.isArray(rpcValue))) {\n return undefined;\n }\n const rpcEnabled =\n rpcValue && Object.hasOwn(rpcValue, \"enabled\")\n ? Reflect.get(rpcValue, \"enabled\")\n : DEFAULT_GOAL_SETTINGS.rpc.enabled;\n if (typeof rpcEnabled !== \"boolean\") return undefined;\n\n const continuationLimitsValue = Object.hasOwn(value, \"continuationLimits\")\n ? Reflect.get(value, \"continuationLimits\")\n : undefined;\n if (\n continuationLimitsValue !== undefined &&\n (typeof continuationLimitsValue !== \"object\" ||\n continuationLimitsValue === null ||\n Array.isArray(continuationLimitsValue))\n ) {\n return undefined;\n }\n const automaticTurns = continuationLimitsValue\n ? normalizeContinuationLimit(\n Reflect.get(continuationLimitsValue, \"automaticTurns\"),\n DEFAULT_GOAL_SETTINGS.continuationLimits.automaticTurns,\n )\n : DEFAULT_GOAL_SETTINGS.continuationLimits.automaticTurns;\n const noProgressTurns = continuationLimitsValue\n ? normalizeContinuationLimit(\n Reflect.get(continuationLimitsValue, \"noProgressTurns\"),\n DEFAULT_GOAL_SETTINGS.continuationLimits.noProgressTurns,\n )\n : DEFAULT_GOAL_SETTINGS.continuationLimits.noProgressTurns;\n if (automaticTurns === undefined || noProgressTurns === undefined) return undefined;\n\n return {\n rpc: { enabled: rpcEnabled },\n continuationLimits: { automaticTurns, noProgressTurns },\n };\n}\n\nfunction normalizeContinuationLimit(value: unknown, fallback: ContinuationLimit): ContinuationLimit | undefined {\n if (value === undefined) return fallback;\n if (value === null) return null;\n return typeof value === \"number\" && Number.isSafeInteger(value) && value > 0 ? value : undefined;\n}\n\nexport function saveGoalSettings(\n settings: GoalSettings,\n settingsPath = join(getAgentDir(), GOAL_SETTINGS_FILE),\n overrides: Partial<GoalSettingsSaveFileSystem> = {},\n) {\n const normalized = normalizeGoalSettings(settings);\n if (!normalized) throw new Error(\"Refusing to save invalid pi-goal settings.\");\n\n let raw: Record<string, unknown> = {};\n try {\n const contents = readFileSync(settingsPath, \"utf8\");\n const parsed = JSON.parse(contents) as unknown;\n if (!normalizeGoalSettings(parsed)) {\n throw new Error(`${settingsPath}: invalid settings shape`);\n }\n raw = ownRecord(parsed) ?? {};\n } catch (error) {\n if (!isNodeError(error) || error.code !== \"ENOENT\") {\n throw new Error(`Cannot save invalid settings file: ${formatError(error)}`);\n }\n }\n\n const rpc = ownRecord(raw.rpc) ?? {};\n const continuationLimits = ownRecord(raw.continuationLimits) ?? {};\n const document = `${JSON.stringify(\n {\n ...raw,\n rpc: { ...rpc, enabled: normalized.rpc.enabled },\n continuationLimits: {\n ...continuationLimits,\n automaticTurns: normalized.continuationLimits.automaticTurns,\n noProgressTurns: normalized.continuationLimits.noProgressTurns,\n },\n },\n null,\n 2,\n )}\\n`;\n const fs = { mkdirSync, writeFileSync, renameSync, rmSync, ...overrides };\n const temporaryPath = join(dirname(settingsPath), `.${basename(settingsPath)}.${randomUUID()}.tmp`);\n try {\n fs.mkdirSync(dirname(settingsPath), { recursive: true });\n fs.writeFileSync(temporaryPath, document, { encoding: \"utf8\", flag: \"wx\" });\n fs.renameSync(temporaryPath, settingsPath);\n } finally {\n try {\n fs.rmSync(temporaryPath, { force: true });\n } catch {\n // Best-effort cleanup must not replace the save result.\n }\n }\n}\n\nexport function readGoalSettings(settingsPath = join(getAgentDir(), GOAL_SETTINGS_FILE)): GoalSettingsLoadResult {\n let contents: string;\n try {\n contents = readFileSync(settingsPath, \"utf8\");\n } catch (error: unknown) {\n if (isNodeError(error) && error.code === \"ENOENT\") {\n return { kind: \"missing\", legacyExperimentalGoals: false };\n }\n return { kind: \"invalid\", reason: `${settingsPath}: ${formatError(error)}` };\n }\n\n try {\n const parsed = JSON.parse(contents) as unknown;\n const settings = normalizeGoalSettings(parsed);\n return settings\n ? { kind: \"loaded\", settings, legacyExperimentalGoals: hasLegacyExperimentalGoals(parsed) }\n : { kind: \"invalid\", reason: `${settingsPath}: invalid settings shape` };\n } catch (error: unknown) {\n return { kind: \"invalid\", reason: `${settingsPath}: ${formatError(error)}` };\n }\n}\n\nfunction hasLegacyExperimentalGoals(value: unknown) {\n const experimental = ownRecord(ownRecord(value)?.experimental);\n return experimental?.goals === true;\n}\n\nfunction ownRecord(value: unknown): Record<string, unknown> | undefined {\n return value && typeof value === \"object\" && !Array.isArray(value) ? (value as Record<string, unknown>) : undefined;\n}\n\nfunction isNodeError(error: unknown): error is NodeJS.ErrnoException {\n return error instanceof Error && \"code\" in error;\n}\n\nfunction formatError(error: unknown) {\n return error instanceof Error ? error.message : String(error);\n}\n"],
|
|
5
|
-
"mappings": ";;;;AAoBO,SAAS,yBAAyB,MAA2B,KAAa,eAAwB;AACvG,QAAM,cAAc,wBAAwB,KAAK,eAAe;AAChE,QAAM,YA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