@yagni-app/code-staging 1.2.15-staging.2666.1 → 1.2.15-staging.2671.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.
- package/dist/extension/config.d.ts +3 -0
- package/dist/extension/config.js +1 -1
- package/dist/extension/index.d.ts +2 -0
- package/dist/extension/index.js +9 -2
- package/dist/extension/pipeline/changeScan.js +3 -1
- package/dist/extension/pipeline/cloud.d.ts +6 -0
- package/dist/extension/pipeline/sessionLane.js +51 -0
- package/dist/extension/pipeline/sessionRetry.d.ts +38 -0
- package/dist/extension/pipeline/sessionRetry.js +126 -0
- package/dist/extension/resilientFetch.d.ts +8 -0
- package/dist/extension/resilientFetch.js +14 -0
- package/package.json +2 -2
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* a token-free body excerpt); off by default and never required.
|
|
9
9
|
*/
|
|
10
10
|
import { type ChosenModelEntry } from "./modelChoice.js";
|
|
11
|
+
import { type ResilientFetchPolicy } from "./resilientFetch.js";
|
|
11
12
|
/** A single model entry as returned by the YAGNI backend catalog endpoint. */
|
|
12
13
|
export interface ModelEntry {
|
|
13
14
|
id: string;
|
|
@@ -72,6 +73,8 @@ export interface FetchCatalogOptions {
|
|
|
72
73
|
baseUrl: string;
|
|
73
74
|
getToken: () => string | undefined;
|
|
74
75
|
fetchImpl?: typeof fetch;
|
|
76
|
+
/** The fetch's retry policy; absent, `resilientFetch`'s default. */
|
|
77
|
+
policy?: ResilientFetchPolicy;
|
|
75
78
|
}
|
|
76
79
|
/** Guardian storage tier for this workspace (YAG-510). */
|
|
77
80
|
export type GuardianStorageTier = "off" | "hash" | "raw";
|
package/dist/extension/config.js
CHANGED
|
@@ -91,7 +91,7 @@ async function serverMessage(res) {
|
|
|
91
91
|
* response so the launcher can surface a clear re-authentication prompt.
|
|
92
92
|
*/
|
|
93
93
|
export async function fetchCatalog(opts) {
|
|
94
|
-
const res = await resilientFetch(`${opts.baseUrl}/api/yagni-code/models`, { method: "GET", headers: { authorization: `Bearer ${opts.getToken() ?? ""}` } }, { fetchImpl: opts.fetchImpl });
|
|
94
|
+
const res = await resilientFetch(`${opts.baseUrl}/api/yagni-code/models`, { method: "GET", headers: { authorization: `Bearer ${opts.getToken() ?? ""}` } }, { fetchImpl: opts.fetchImpl, ...(opts.policy ? { policy: opts.policy } : {}) });
|
|
95
95
|
if (!res.ok) {
|
|
96
96
|
// A 409 is the workspace's settings, not the login: say the server's words.
|
|
97
97
|
const conflict = res.status === 409 ? await serverMessage(res) : null;
|
|
@@ -7,6 +7,7 @@ import { type GuardianGateEvent } from "./permission/gate.js";
|
|
|
7
7
|
import { registerTelemetry as defaultRegisterTelemetry } from "./telemetry/register.js";
|
|
8
8
|
import { type PluginCliRunner } from "./plugins/panel.js";
|
|
9
9
|
import { type AttributionSettings } from "./attribution.js";
|
|
10
|
+
import { type ResilientFetchPolicy } from "./resilientFetch.js";
|
|
10
11
|
import { type FlushOutcome, type SpoolClientOpts } from "./spool.js";
|
|
11
12
|
import { type TokenProvider } from "./tokenProvider.js";
|
|
12
13
|
import { type CatalogResult, type ContextBrief } from "./config.js";
|
|
@@ -39,6 +40,7 @@ export interface RegisterYagniDeps {
|
|
|
39
40
|
baseUrl: string;
|
|
40
41
|
getToken: () => string | undefined;
|
|
41
42
|
fetchImpl?: typeof fetch;
|
|
43
|
+
policy?: ResilientFetchPolicy;
|
|
42
44
|
}) => Promise<CatalogResult>;
|
|
43
45
|
fetchContextBrief?: (opts: {
|
|
44
46
|
baseUrl: string;
|
package/dist/extension/index.js
CHANGED
|
@@ -65,7 +65,8 @@ import { loadGroundingEnabled } from "./grounding.js";
|
|
|
65
65
|
import { attributionPromptSection, loadAttributionSettings, } from "./attribution.js";
|
|
66
66
|
import { makePlacedValuesSpawnHook, openPlacedValues, registerPlacedValueRedaction, } from "./placedValues.js";
|
|
67
67
|
import { registerAmbientRecall } from "./recall.js";
|
|
68
|
-
import { resilientFetch } from "./resilientFetch.js";
|
|
68
|
+
import { CLOUD_SESSION_CATALOG_FETCH_POLICY, resilientFetch, } from "./resilientFetch.js";
|
|
69
|
+
import { SESSION_LONG_RETRY_ENV } from "./pipeline/sessionRetry.js";
|
|
69
70
|
import { installNonZeroExitReporter, installUncaughtExceptionMonitor, makeCrashReporter, runningUnderTest, } from "./crashReport.js";
|
|
70
71
|
import { createToolOutcomeBatcher } from "./toolOutcomes.js";
|
|
71
72
|
import { flushSpool as defaultFlushSpool, } from "./spool.js";
|
|
@@ -336,7 +337,13 @@ export async function registerYagni(pi, deps = {}) {
|
|
|
336
337
|
// after_provider_response event does NOT fire on a 401 (the OpenAI SDK throws
|
|
337
338
|
// before onResponse is reached), so message_end is the only seam.
|
|
338
339
|
let lastAuthRecovery = null;
|
|
339
|
-
const { models: fullCatalog, guardianEnabled: workspaceGuardianEnabled, judgmentLoopEnabled: workspaceJudgmentLoopEnabled, guardianStorage: guardianStorageTier, guardianTimeoutMs: guardianTimeoutAdvertisedMs, guardianMaxAttempts: guardianMaxAttemptsAdvertised, chosenModels: advertisedChosenModels, } = await fetchCatalog({
|
|
340
|
+
const { models: fullCatalog, guardianEnabled: workspaceGuardianEnabled, judgmentLoopEnabled: workspaceJudgmentLoopEnabled, guardianStorage: guardianStorageTier, guardianTimeoutMs: guardianTimeoutAdvertisedMs, guardianMaxAttempts: guardianMaxAttemptsAdvertised, chosenModels: advertisedChosenModels, } = await fetchCatalog({
|
|
341
|
+
baseUrl,
|
|
342
|
+
getToken: getTokenFn,
|
|
343
|
+
fetchImpl: authedFetch,
|
|
344
|
+
// A yak's writing turn waits out a back end that is down.
|
|
345
|
+
...(env[SESSION_LONG_RETRY_ENV] === "1" ? { policy: CLOUD_SESSION_CATALOG_FETCH_POLICY } : {}),
|
|
346
|
+
});
|
|
340
347
|
// The judgment loop runs only when BOTH halves allow it: the developer's
|
|
341
348
|
// user-tier config AND the workspace's admin-flipped flag. Either side off
|
|
342
349
|
// severs the loop in both directions through the one `grounding` gate
|
|
@@ -142,7 +142,9 @@ function finding(path, line, kind) {
|
|
|
142
142
|
file: path,
|
|
143
143
|
line,
|
|
144
144
|
message: `secret scan: this adds ${describeKind(kind)}, and YAGNI will not publish a change that holds one. ` +
|
|
145
|
-
|
|
145
|
+
// No "credential:" here: the scrub reads the word after it as the
|
|
146
|
+
// credential's value, and the line a later session reads lost its advice.
|
|
147
|
+
"Take it out (read it from the environment or a secret store instead). A test value must not look like a real credential, so build it when the test runs or use an obvious fake such as `test-token`.",
|
|
146
148
|
};
|
|
147
149
|
}
|
|
148
150
|
/**
|
|
@@ -162,6 +162,12 @@ export interface AttemptResult extends CloudIdentity {
|
|
|
162
162
|
* Absent on every other turn: the host then drafts the preview itself.
|
|
163
163
|
*/
|
|
164
164
|
uiPreview?: "drawn" | "none" | "not_drawn";
|
|
165
|
+
/**
|
|
166
|
+
* Whole seconds the session lane's turn spent waiting to retry a failed
|
|
167
|
+
* model call (`sessionRetry.ts`); absent when it waited none. The host
|
|
168
|
+
* does not bill them.
|
|
169
|
+
*/
|
|
170
|
+
retryWaitSeconds?: number;
|
|
165
171
|
/** The session lane's ask on a `needs_person` stop (`needsPerson.ts`). */
|
|
166
172
|
ask?: AttemptAsk;
|
|
167
173
|
/** A turn that committed nothing: why nothing needed to change (`sessionLane.ts`, YAG-1598). */
|
|
@@ -71,6 +71,7 @@ import { runStage as defaultRunStage } from "./runner.js";
|
|
|
71
71
|
import { scrubSecrets } from "./scrubSecrets.js";
|
|
72
72
|
import { DECISIONS_READ_TOOL, PIECES_RULE, YAK_FOLLOW_UPS_RULE, PLAN_JSON_CONTRACT, YAK_PLAN_JSON_CONTRACT, } from "./stages.js";
|
|
73
73
|
import { planReviewRoundsFor, planSizeOf, sessionTicketPathOf, TICKET_PATH_FILE_NAME, } from "./ticketPath.js";
|
|
74
|
+
import { agentDirFailure, prepareSessionAgentDir, RetryWaitClock, SESSION_LONG_RETRY_ENV, } from "./sessionRetry.js";
|
|
74
75
|
import { SESSION_PLAN_MINUTES, STAGE_WRAP_UP_GRACE_MS } from "./stageClock.js";
|
|
75
76
|
import { findPullRequestTemplate, changeForQaSteps, FETCHED_BASE_REF, pullRequestBaseOf, findRepositorySkill, listRepositorySkills, QA_STEPS_FILE_NAME, qaStepsMessage, qaStepsOf, repositorySkillsTrusted, TRACKER_WORKFLOW_FILE_NAME, templateRule, trackerWorkflowOf, } from "./trackerWorkflow.js";
|
|
76
77
|
import { editsMostlyFailed } from "./events.js";
|
|
@@ -916,6 +917,44 @@ function processMemory() {
|
|
|
916
917
|
return null;
|
|
917
918
|
}
|
|
918
919
|
}
|
|
920
|
+
/**
|
|
921
|
+
* The env a writing turn's children run with to wait out a failed model
|
|
922
|
+
* call: the run's own agent folder beside its session
|
|
923
|
+
* (`sessionRetry.ts`), and the marker the start-up fetch reads. Empty when
|
|
924
|
+
* the launcher named no profile folder, or the folder could not be made, so
|
|
925
|
+
* the turn runs on the profile's settings as before; the latter says so.
|
|
926
|
+
*/
|
|
927
|
+
function longRetryEnv(input, laneDir) {
|
|
928
|
+
const profileDir = input.childEnv.PI_CODING_AGENT_DIR?.trim();
|
|
929
|
+
if (!profileDir)
|
|
930
|
+
return {};
|
|
931
|
+
try {
|
|
932
|
+
const runDir = prepareSessionAgentDir(profileDir, join(laneDir, "pi-agent"));
|
|
933
|
+
return {
|
|
934
|
+
PI_CODING_AGENT_DIR: runDir,
|
|
935
|
+
YAGNI_CODING_AGENT_DIR: runDir,
|
|
936
|
+
[SESSION_LONG_RETRY_ENV]: "1",
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
catch (err) {
|
|
940
|
+
const why = agentDirFailure(err);
|
|
941
|
+
input.writeErr(`This turn retries a failed model call as briefly as before: its agent folder could not be made (${why}).`);
|
|
942
|
+
// Counted apart from a long retry that ran and still lost the call.
|
|
943
|
+
logEvent({
|
|
944
|
+
source: "session_lane",
|
|
945
|
+
level: "warn",
|
|
946
|
+
event: "long_retry_unavailable",
|
|
947
|
+
sessionId: input.childEnv.YAGNI_SESSION_ID?.trim(),
|
|
948
|
+
fields: {
|
|
949
|
+
reason: why,
|
|
950
|
+
attemptId: input.identity.attemptId,
|
|
951
|
+
executionId: input.identity.executionId,
|
|
952
|
+
stage: input.stage,
|
|
953
|
+
},
|
|
954
|
+
});
|
|
955
|
+
return {};
|
|
956
|
+
}
|
|
957
|
+
}
|
|
919
958
|
/**
|
|
920
959
|
* Run one turn of the run's session and write what the host reads, beating
|
|
921
960
|
* on the stream every {@link HEARTBEAT_EVERY_MS} from its start to its end.
|
|
@@ -1104,6 +1143,11 @@ async function runTurn(input, deps, pulse, tally) {
|
|
|
1104
1143
|
};
|
|
1105
1144
|
let decisionsRecorded = 0;
|
|
1106
1145
|
const inboxDir = sessionInboxDir(input.inputDir, input.identity.executionId);
|
|
1146
|
+
// A writing turn waits out a failed model call: its own agent
|
|
1147
|
+
// folder, with pi's long retry settings, in place of the profile's. A plan
|
|
1148
|
+
// turn keeps the profile's, under its own clock.
|
|
1149
|
+
const longRetry = writes ? longRetryEnv(input, laneDir) : {};
|
|
1150
|
+
const retryWait = new RetryWaitClock();
|
|
1107
1151
|
const runDeps = {
|
|
1108
1152
|
cwd: input.cwd,
|
|
1109
1153
|
// The input folder, for the turn's own compaction to pin its facts from
|
|
@@ -1118,6 +1162,7 @@ async function runTurn(input, deps, pulse, tally) {
|
|
|
1118
1162
|
: {}),
|
|
1119
1163
|
...(inboxDir ? { [SESSION_INBOX_DIR_ENV]: inboxDir } : {}),
|
|
1120
1164
|
...(helpersDir ? { [HELPER_SESSIONS_DIR_ENV]: helpersDir } : {}),
|
|
1165
|
+
...longRetry,
|
|
1121
1166
|
},
|
|
1122
1167
|
sessionFile: paths.sessionFile,
|
|
1123
1168
|
callerLabel: SESSION_CALLER_LABEL,
|
|
@@ -1130,6 +1175,7 @@ async function runTurn(input, deps, pulse, tally) {
|
|
|
1130
1175
|
writePrompt: async () => ({ filePath: paths.skillFile, cleanup: () => undefined }),
|
|
1131
1176
|
onEvent: (event) => {
|
|
1132
1177
|
notePulse(pulse, event, now());
|
|
1178
|
+
retryWait.note(event, now());
|
|
1133
1179
|
if (event.type === "tool_execution_end" &&
|
|
1134
1180
|
event.toolName === "record_decision" &&
|
|
1135
1181
|
!event.isError) {
|
|
@@ -1157,6 +1203,7 @@ async function runTurn(input, deps, pulse, tally) {
|
|
|
1157
1203
|
...(EXECUTION_ID.test(input.identity.executionId)
|
|
1158
1204
|
? { [EXECUTION_ID_ENV]: input.identity.executionId }
|
|
1159
1205
|
: {}),
|
|
1206
|
+
...longRetry,
|
|
1160
1207
|
},
|
|
1161
1208
|
sessionFile: paths.sessionFile,
|
|
1162
1209
|
callerLabel: SESSION_CALLER_LABEL,
|
|
@@ -1168,6 +1215,7 @@ async function runTurn(input, deps, pulse, tally) {
|
|
|
1168
1215
|
writePrompt: async () => ({ filePath: paths.skillFile, cleanup: () => undefined }),
|
|
1169
1216
|
onEvent: (event) => {
|
|
1170
1217
|
notePulse(pulse, event, now());
|
|
1218
|
+
retryWait.note(event, now());
|
|
1171
1219
|
input.emit({ ...event, yagni: { stage: stageId } });
|
|
1172
1220
|
},
|
|
1173
1221
|
now,
|
|
@@ -1499,6 +1547,9 @@ async function runTurn(input, deps, pulse, tally) {
|
|
|
1499
1547
|
usage: resultUsage({ stages: "result" in ran ? ran.result.stages : ran.partial, rounds: [] }),
|
|
1500
1548
|
notes: [...notes, ...done.attempt.notes],
|
|
1501
1549
|
...turnPromptFacts(input.childEnv),
|
|
1550
|
+
// The turn's minutes spent waiting to retry a failed model call, which
|
|
1551
|
+
// the host does not bill.
|
|
1552
|
+
...(retryWait.seconds(now()) > 0 ? { retryWaitSeconds: retryWait.seconds(now()) } : {}),
|
|
1502
1553
|
};
|
|
1503
1554
|
const accounted = accountOf(noted);
|
|
1504
1555
|
// The template the description was written in, and the QA steps
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { JsonEvent } from "./types.js";
|
|
2
|
+
/** pi's retry settings for a yak's writing turn: about 16 minutes of waiting per call. */
|
|
3
|
+
export declare const SESSION_RETRY_SETTINGS: {
|
|
4
|
+
readonly maxRetries: 6;
|
|
5
|
+
readonly baseDelayMs: 15000;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* The child's env: this turn waits out failures. The extension's
|
|
9
|
+
* start-up catalog fetch waits longer under it (`CLOUD_SESSION_CATALOG_FETCH_POLICY`).
|
|
10
|
+
*/
|
|
11
|
+
export declare const SESSION_LONG_RETRY_ENV = "YAGNI_SESSION_LONG_RETRY";
|
|
12
|
+
/**
|
|
13
|
+
* Why the run's folder could not be made, in words of ours: never the
|
|
14
|
+
* error's own message, which for a malformed file quotes its text back.
|
|
15
|
+
*/
|
|
16
|
+
export declare function agentDirFailure(err: unknown): string;
|
|
17
|
+
/**
|
|
18
|
+
* The run's agent folder at `runDir`, made from the profile's at
|
|
19
|
+
* `profileDir`: its settings with ours over `retry`, and a link to each of
|
|
20
|
+
* its other entries. Made again at every turn, so a later change to the
|
|
21
|
+
* profile's settings reaches the next turn; an entry already in the run's
|
|
22
|
+
* folder stays. Throws when it cannot be made: the turn then runs on the
|
|
23
|
+
* profile's folder, as every turn did before.
|
|
24
|
+
*/
|
|
25
|
+
export declare function prepareSessionAgentDir(profileDir: string, runDir: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* The time a turn's child spent waiting to retry a failed model call: from
|
|
28
|
+
* each `auto_retry_start` to the child's next event (the retried call's
|
|
29
|
+
* start), or to the turn's end when none came.
|
|
30
|
+
*/
|
|
31
|
+
export declare class RetryWaitClock {
|
|
32
|
+
private waitingSince;
|
|
33
|
+
private waitedMs;
|
|
34
|
+
note(event: JsonEvent, at: number): void;
|
|
35
|
+
/** Whole seconds waited so far, an open wait counted up to `at`. */
|
|
36
|
+
seconds(at: number): number;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=sessionRetry.d.ts.map
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How long a yak's writing turn waits out a failed model call.
|
|
3
|
+
*
|
|
4
|
+
* pi retries a failed call `retry.maxRetries` times, waiting
|
|
5
|
+
* `retry.baseDelayMs * 2 ** (n - 1)` before the n-th, and reads both only
|
|
6
|
+
* from `<agentDir>/settings.json` (pi 0.84.1 defaults: 3 and 2 s, so about
|
|
7
|
+
* 14 s in all). A writing turn of a yak's cloud session waits 15 s, 30 s,
|
|
8
|
+
* 1, 2, 4 and 8 minutes instead, on the same machine and conversation, so a
|
|
9
|
+
* provider or back-end failure of a few minutes leaves no stop.
|
|
10
|
+
*
|
|
11
|
+
* The settings go into a folder of the run's own, beside its session: the
|
|
12
|
+
* profile's settings with ours over `retry`, and every other entry of the
|
|
13
|
+
* profile's folder linked in, so nothing else pi or the extension reads
|
|
14
|
+
* there moves. The profile's own `settings.json`, which a developer's
|
|
15
|
+
* interactive `yagni` reads, is never written.
|
|
16
|
+
*/
|
|
17
|
+
import { existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, renameSync, symlinkSync, writeFileSync, } from "node:fs";
|
|
18
|
+
import { join } from "node:path";
|
|
19
|
+
/** pi's retry settings for a yak's writing turn: about 16 minutes of waiting per call. */
|
|
20
|
+
export const SESSION_RETRY_SETTINGS = { maxRetries: 6, baseDelayMs: 15_000 };
|
|
21
|
+
/**
|
|
22
|
+
* The child's env: this turn waits out failures. The extension's
|
|
23
|
+
* start-up catalog fetch waits longer under it (`CLOUD_SESSION_CATALOG_FETCH_POLICY`).
|
|
24
|
+
*/
|
|
25
|
+
export const SESSION_LONG_RETRY_ENV = "YAGNI_SESSION_LONG_RETRY";
|
|
26
|
+
const SETTINGS_FILE = "settings.json";
|
|
27
|
+
/** An entry is there, a link whose target is gone included. */
|
|
28
|
+
function present(path) {
|
|
29
|
+
try {
|
|
30
|
+
lstatSync(path);
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function settingsOf(text) {
|
|
38
|
+
if (text === null)
|
|
39
|
+
return {};
|
|
40
|
+
const parsed = JSON.parse(text);
|
|
41
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
42
|
+
throw new NotAnObjectError("its settings.json is not a JSON object");
|
|
43
|
+
}
|
|
44
|
+
return parsed;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Why the run's folder could not be made, in words of ours: never the
|
|
48
|
+
* error's own message, which for a malformed file quotes its text back.
|
|
49
|
+
*/
|
|
50
|
+
export function agentDirFailure(err) {
|
|
51
|
+
if (err instanceof SyntaxError)
|
|
52
|
+
return "the profile's settings.json is not valid JSON";
|
|
53
|
+
if (err instanceof NotAnObjectError)
|
|
54
|
+
return "the profile's settings.json is not a JSON object";
|
|
55
|
+
const code = err?.code;
|
|
56
|
+
if (typeof code === "string" && /^[A-Z0-9_]{1,32}$/.test(code))
|
|
57
|
+
return `a file operation failed (${code})`;
|
|
58
|
+
return "an unexpected error";
|
|
59
|
+
}
|
|
60
|
+
class NotAnObjectError extends Error {
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The run's agent folder at `runDir`, made from the profile's at
|
|
64
|
+
* `profileDir`: its settings with ours over `retry`, and a link to each of
|
|
65
|
+
* its other entries. Made again at every turn, so a later change to the
|
|
66
|
+
* profile's settings reaches the next turn; an entry already in the run's
|
|
67
|
+
* folder stays. Throws when it cannot be made: the turn then runs on the
|
|
68
|
+
* profile's folder, as every turn did before.
|
|
69
|
+
*/
|
|
70
|
+
export function prepareSessionAgentDir(profileDir, runDir) {
|
|
71
|
+
mkdirSync(runDir, { recursive: true, mode: 0o700 });
|
|
72
|
+
const profileSettings = join(profileDir, SETTINGS_FILE);
|
|
73
|
+
const current = settingsOf(existsSync(profileSettings) ? readFileSync(profileSettings, "utf8") : null);
|
|
74
|
+
const retry = current.retry && typeof current.retry === "object" && !Array.isArray(current.retry)
|
|
75
|
+
? current.retry
|
|
76
|
+
: {};
|
|
77
|
+
const settings = { ...current, retry: { ...retry, ...SESSION_RETRY_SETTINGS } };
|
|
78
|
+
const file = join(runDir, SETTINGS_FILE);
|
|
79
|
+
const tmp = `${file}.tmp-${process.pid}`;
|
|
80
|
+
writeFileSync(tmp, `${JSON.stringify(settings, null, 2)}\n`);
|
|
81
|
+
renameSync(tmp, file);
|
|
82
|
+
if (!existsSync(profileDir))
|
|
83
|
+
return runDir;
|
|
84
|
+
for (const entry of readdirSync(profileDir)) {
|
|
85
|
+
if (entry !== SETTINGS_FILE)
|
|
86
|
+
linkEntry(profileDir, runDir, entry);
|
|
87
|
+
}
|
|
88
|
+
return runDir;
|
|
89
|
+
}
|
|
90
|
+
/** One entry of the profile's folder linked into the run's, unless the run's already has it. */
|
|
91
|
+
function linkEntry(profileDir, runDir, entry) {
|
|
92
|
+
const link = join(runDir, entry);
|
|
93
|
+
if (present(link))
|
|
94
|
+
return;
|
|
95
|
+
try {
|
|
96
|
+
symlinkSync(join(profileDir, entry), link);
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
// Another prepare of the same folder linked it first: that link stands.
|
|
100
|
+
if (err.code !== "EEXIST")
|
|
101
|
+
throw err;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The time a turn's child spent waiting to retry a failed model call: from
|
|
106
|
+
* each `auto_retry_start` to the child's next event (the retried call's
|
|
107
|
+
* start), or to the turn's end when none came.
|
|
108
|
+
*/
|
|
109
|
+
export class RetryWaitClock {
|
|
110
|
+
waitingSince = null;
|
|
111
|
+
waitedMs = 0;
|
|
112
|
+
note(event, at) {
|
|
113
|
+
if (this.waitingSince !== null) {
|
|
114
|
+
this.waitedMs += Math.max(0, at - this.waitingSince);
|
|
115
|
+
this.waitingSince = null;
|
|
116
|
+
}
|
|
117
|
+
if (event.type === "auto_retry_start")
|
|
118
|
+
this.waitingSince = at;
|
|
119
|
+
}
|
|
120
|
+
/** Whole seconds waited so far, an open wait counted up to `at`. */
|
|
121
|
+
seconds(at) {
|
|
122
|
+
const open = this.waitingSince === null ? 0 : Math.max(0, at - this.waitingSince);
|
|
123
|
+
return Math.floor((this.waitedMs + open) / 1000);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=sessionRetry.js.map
|
|
@@ -28,6 +28,14 @@ export interface ResilientFetchPolicy {
|
|
|
28
28
|
}
|
|
29
29
|
/** Generous defaults: a few quick retries, a 30s per-attempt cap. */
|
|
30
30
|
export declare const DEFAULT_FETCH_POLICY: ResilientFetchPolicy;
|
|
31
|
+
/**
|
|
32
|
+
* The model catalog fetch at the start of a yak's writing turn,
|
|
33
|
+
* which waits out a back end that is down for minutes rather than failing
|
|
34
|
+
* the turn: up to 7 tries, about 9 minutes at most in all (6 waits of
|
|
35
|
+
* 5 s to 2 min, with jitter, plus each try's 30 s cap). Every other fetch
|
|
36
|
+
* keeps {@link DEFAULT_FETCH_POLICY}.
|
|
37
|
+
*/
|
|
38
|
+
export declare const CLOUD_SESSION_CATALOG_FETCH_POLICY: ResilientFetchPolicy;
|
|
31
39
|
/**
|
|
32
40
|
* POSTs that trigger LLM work or write YAGNI records must not be replayed by the
|
|
33
41
|
* client. Server-side idempotency is the right fix for retries; until then, make
|
|
@@ -24,6 +24,20 @@ export const DEFAULT_FETCH_POLICY = {
|
|
|
24
24
|
timeoutMs: 30_000,
|
|
25
25
|
jitterRatio: 0.25,
|
|
26
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* The model catalog fetch at the start of a yak's writing turn,
|
|
29
|
+
* which waits out a back end that is down for minutes rather than failing
|
|
30
|
+
* the turn: up to 7 tries, about 9 minutes at most in all (6 waits of
|
|
31
|
+
* 5 s to 2 min, with jitter, plus each try's 30 s cap). Every other fetch
|
|
32
|
+
* keeps {@link DEFAULT_FETCH_POLICY}.
|
|
33
|
+
*/
|
|
34
|
+
export const CLOUD_SESSION_CATALOG_FETCH_POLICY = {
|
|
35
|
+
maxAttempts: 7,
|
|
36
|
+
backoffBaseMs: 5_000,
|
|
37
|
+
backoffMaxMs: 120_000,
|
|
38
|
+
timeoutMs: 30_000,
|
|
39
|
+
jitterRatio: 0.25,
|
|
40
|
+
};
|
|
27
41
|
/**
|
|
28
42
|
* POSTs that trigger LLM work or write YAGNI records must not be replayed by the
|
|
29
43
|
* client. Server-side idempotency is the right fix for retries; until then, make
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yagni-app/code-staging",
|
|
3
|
-
"version": "1.2.15-staging.
|
|
3
|
+
"version": "1.2.15-staging.2671.1",
|
|
4
4
|
"description": "YAGNI Code: a terminal coding agent that already knows your company. One YAGNI login routes the model and grounds the agent in your team's context.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"author": "YAGNI, Inc. <jack@yagni.app> (https://yagni.app)",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"turndown": "^7.2.4",
|
|
59
59
|
"typebox": "^1.3.15"
|
|
60
60
|
},
|
|
61
|
-
"yagniSourceSha": "
|
|
61
|
+
"yagniSourceSha": "741d84f123ee8b147784d87e35c8c3c6471e5fb1"
|
|
62
62
|
}
|