aglio-worker 0.97.1 → 0.101.0
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/agent.js +209 -111
- package/package.json +1 -1
package/agent.js
CHANGED
|
@@ -50184,10 +50184,10 @@ var RUN_STATUSES_FOR_SCHEMA = [
|
|
|
50184
50184
|
"skipped"
|
|
50185
50185
|
];
|
|
50186
50186
|
var RUN_KINDS = ["planning", "build", "consult", "review", "workspace_consult", "job"];
|
|
50187
|
-
var AGENT_DRIVERS = ["pi", "claude", "codex", "
|
|
50187
|
+
var AGENT_DRIVERS = ["pi", "claude", "codex", "cursor", "opencode", "antigravity", "hermes"];
|
|
50188
50188
|
var QUESTION_TYPES = ["single", "multi", "text"];
|
|
50189
50189
|
var VERIFICATION_KINDS = ["test_output", "screenshot", "recording", "not_applicable"];
|
|
50190
|
-
var ARTIFACT_KINDS = ["image", "log", "file", "recording", "canvas"];
|
|
50190
|
+
var ARTIFACT_KINDS = ["image", "log", "file", "recording", "canvas", "context"];
|
|
50191
50191
|
var WORK_LOG_TYPES = [
|
|
50192
50192
|
"summary",
|
|
50193
50193
|
"decision",
|
|
@@ -71166,27 +71166,10 @@ var PROVIDERS = [
|
|
|
71166
71166
|
{
|
|
71167
71167
|
id: "google",
|
|
71168
71168
|
label: "Google Gemini",
|
|
71169
|
-
drivers: ["
|
|
71169
|
+
drivers: ["pi", "hermes"],
|
|
71170
71170
|
models: ["gemini-2.5-pro", "gemini-2.5-flash", "gemini-2.0-flash"],
|
|
71171
71171
|
connection: { baseUrl: "https://generativelanguage.googleapis.com/v1beta/openai" },
|
|
71172
|
-
authOptions: [
|
|
71173
|
-
apiKey("GEMINI_API_KEY", ["gemini", "pi", "hermes"]),
|
|
71174
|
-
sessionBundle(
|
|
71175
|
-
".gemini/oauth_creds.json",
|
|
71176
|
-
"Sign in with the Google account that has a Gemini subscription.",
|
|
71177
|
-
["gemini"],
|
|
71178
|
-
[
|
|
71179
|
-
{
|
|
71180
|
-
id: "google",
|
|
71181
|
-
label: "Google account",
|
|
71182
|
-
command: ["gemini", "--skip-trust"],
|
|
71183
|
-
env: { NO_BROWSER: "true", GOOGLE_GENAI_USE_GCA: "true" },
|
|
71184
|
-
kickoff: "hi\r",
|
|
71185
|
-
code: true
|
|
71186
|
-
}
|
|
71187
|
-
]
|
|
71188
|
-
)
|
|
71189
|
-
]
|
|
71172
|
+
authOptions: [apiKey("GEMINI_API_KEY", ["pi", "hermes"])]
|
|
71190
71173
|
},
|
|
71191
71174
|
{
|
|
71192
71175
|
id: "cursor",
|
|
@@ -71613,12 +71596,19 @@ var INVITE_TTL_MS = INVITE_TTL_DAYS * 24 * 60 * 60 * 1e3;
|
|
|
71613
71596
|
var DEFAULT_INVITE_EXPIRY_DAYS = INVITE_TTL_DAYS;
|
|
71614
71597
|
var MAX_INVITE_EXPIRY_DAYS = 90;
|
|
71615
71598
|
|
|
71599
|
+
// ../../packages/shared/src/image-upload-quality.ts
|
|
71600
|
+
var IMAGE_UPLOAD_QUALITY_LEVELS = ["lowest", "low", "medium", "high"];
|
|
71601
|
+
var imageUploadQualitySchema = external_exports.enum(IMAGE_UPLOAD_QUALITY_LEVELS);
|
|
71602
|
+
var DEFAULT_IMAGE_UPLOAD_QUALITY = "medium";
|
|
71603
|
+
|
|
71616
71604
|
// ../../packages/shared/src/workspace-settings.ts
|
|
71617
71605
|
var WORKSPACE_SETTINGS_DEFAULTS = {
|
|
71618
71606
|
allowMemberInvites: true,
|
|
71619
71607
|
defaultAgentConfigId: null,
|
|
71620
71608
|
/** 0 means keep artifacts forever. */
|
|
71621
71609
|
artifactRetentionDays: 0,
|
|
71610
|
+
/** Uploaded pictures are always re-encoded. Everyone starts at Medium. */
|
|
71611
|
+
imageUploadQuality: DEFAULT_IMAGE_UPLOAD_QUALITY,
|
|
71622
71612
|
/** The shared workspace consultant is opt-out. Disabled hides every entry point. */
|
|
71623
71613
|
consultantEnabled: true,
|
|
71624
71614
|
/** Workspace consultant reasoning budget. Independent of every project. */
|
|
@@ -71632,6 +71622,7 @@ var workspaceSettingsSchema = external_exports.object({
|
|
|
71632
71622
|
allowMemberInvites: external_exports.boolean().catch(WORKSPACE_SETTINGS_DEFAULTS.allowMemberInvites),
|
|
71633
71623
|
defaultAgentConfigId: external_exports.string().trim().min(1).nullable().catch(null),
|
|
71634
71624
|
artifactRetentionDays: external_exports.number().int().min(0).max(3650).catch(WORKSPACE_SETTINGS_DEFAULTS.artifactRetentionDays),
|
|
71625
|
+
imageUploadQuality: imageUploadQualitySchema.catch(WORKSPACE_SETTINGS_DEFAULTS.imageUploadQuality),
|
|
71635
71626
|
consultantEnabled: external_exports.boolean().catch(WORKSPACE_SETTINGS_DEFAULTS.consultantEnabled),
|
|
71636
71627
|
consultantThinking: thinkingLevelSchema.catch(WORKSPACE_SETTINGS_DEFAULTS.consultantThinking),
|
|
71637
71628
|
consultantVerbosity: verbositySchema.catch(WORKSPACE_SETTINGS_DEFAULTS.consultantVerbosity),
|
|
@@ -73273,7 +73264,7 @@ function driverThinkingArgs(driver, thinking) {
|
|
|
73273
73264
|
function hermesProvider(provider) {
|
|
73274
73265
|
const normalized = provider.toLowerCase();
|
|
73275
73266
|
if (normalized === "openai") return "openai-api";
|
|
73276
|
-
if (normalized === "google"
|
|
73267
|
+
if (normalized === "google") return "gemini";
|
|
73277
73268
|
return normalized;
|
|
73278
73269
|
}
|
|
73279
73270
|
function buildDriverCommand(input2) {
|
|
@@ -73335,26 +73326,6 @@ function buildDriverCommand(input2) {
|
|
|
73335
73326
|
args2.push(prompt);
|
|
73336
73327
|
return args2;
|
|
73337
73328
|
}
|
|
73338
|
-
if (input2.driver === "gemini") {
|
|
73339
|
-
const args2 = [
|
|
73340
|
-
"gemini",
|
|
73341
|
-
"-p",
|
|
73342
|
-
prompt,
|
|
73343
|
-
"-m",
|
|
73344
|
-
input2.model,
|
|
73345
|
-
"--output-format",
|
|
73346
|
-
"stream-json",
|
|
73347
|
-
"--yolo",
|
|
73348
|
-
"--skip-trust"
|
|
73349
|
-
];
|
|
73350
|
-
if (input2.resume && input2.sessionId) {
|
|
73351
|
-
args2.push("--resume", input2.sessionId);
|
|
73352
|
-
} else if (input2.sessionId) {
|
|
73353
|
-
args2.push("--session-id", input2.sessionId);
|
|
73354
|
-
}
|
|
73355
|
-
if (input2.workingDirectory) args2.push("--include-directories", input2.workingDirectory);
|
|
73356
|
-
return args2;
|
|
73357
|
-
}
|
|
73358
73329
|
if (input2.driver === "cursor") {
|
|
73359
73330
|
const args2 = [
|
|
73360
73331
|
"cursor-agent",
|
|
@@ -73569,23 +73540,11 @@ function driverSetupCommands(driver, url2, extraServers = []) {
|
|
|
73569
73540
|
}
|
|
73570
73541
|
return [["bash", "-lc", parts.join("; ")]];
|
|
73571
73542
|
}
|
|
73572
|
-
if (driver === "gemini") {
|
|
73573
|
-
const parts = [
|
|
73574
|
-
`gemini mcp remove aglio >/dev/null 2>&1 || true; gemini mcp add aglio ${url2} --transport http --header "Authorization: Bearer $AGLIO_MCP_TOKEN" --trust --scope user`
|
|
73575
|
-
];
|
|
73576
|
-
for (const server of extraServers) {
|
|
73577
|
-
const headers = server.headers.map((header) => `--header ${shellQuote(`${header.name}: ${header.value}`)}`).join(" ");
|
|
73578
|
-
parts.push(
|
|
73579
|
-
`gemini mcp remove ${server.name} >/dev/null 2>&1 || true; gemini mcp add ${server.name} ${shellQuote(server.url)} --transport http ${headers} --trust --scope user`
|
|
73580
|
-
);
|
|
73581
|
-
}
|
|
73582
|
-
return [["bash", "-lc", parts.join("; ")]];
|
|
73583
|
-
}
|
|
73584
73543
|
return [];
|
|
73585
73544
|
}
|
|
73586
73545
|
function providerEnv(provider, apiKey2) {
|
|
73587
73546
|
const normalized = provider.toLowerCase();
|
|
73588
|
-
if (normalized === "google"
|
|
73547
|
+
if (normalized === "google") {
|
|
73589
73548
|
return { GEMINI_API_KEY: apiKey2, GOOGLE_API_KEY: apiKey2 };
|
|
73590
73549
|
}
|
|
73591
73550
|
if (normalized === "antigravity") return { GEMINI_API_KEY: apiKey2 };
|
|
@@ -73884,60 +73843,6 @@ function parseCursorLine(raw) {
|
|
|
73884
73843
|
}
|
|
73885
73844
|
return { type, at: at3 };
|
|
73886
73845
|
}
|
|
73887
|
-
function parseGeminiLine(raw) {
|
|
73888
|
-
const type = String(raw.type ?? "");
|
|
73889
|
-
const at3 = timestampOf(raw.timestamp);
|
|
73890
|
-
if (type === "init") {
|
|
73891
|
-
return { type, sessionId: raw.session_id ? String(raw.session_id) : void 0, at: at3 };
|
|
73892
|
-
}
|
|
73893
|
-
if (type === "message") {
|
|
73894
|
-
const role = String(raw.role ?? "");
|
|
73895
|
-
if (role !== "assistant") return { type, at: at3 };
|
|
73896
|
-
const text = typeof raw.content === "string" ? raw.content : void 0;
|
|
73897
|
-
return { type, assistantText: text || void 0, assistantDelta: raw.delta === true, at: at3 };
|
|
73898
|
-
}
|
|
73899
|
-
if (type === "tool_use") {
|
|
73900
|
-
return {
|
|
73901
|
-
type,
|
|
73902
|
-
toolName: typeof raw.tool_name === "string" ? raw.tool_name : "tool",
|
|
73903
|
-
toolArgs: raw.parameters,
|
|
73904
|
-
toolCallId: typeof raw.tool_id === "string" ? raw.tool_id : void 0,
|
|
73905
|
-
toolStart: true,
|
|
73906
|
-
toolPartial: false,
|
|
73907
|
-
at: at3
|
|
73908
|
-
};
|
|
73909
|
-
}
|
|
73910
|
-
if (type === "result") {
|
|
73911
|
-
const stats = asRecord(raw.stats);
|
|
73912
|
-
const status = String(raw.status ?? "");
|
|
73913
|
-
const error63 = asRecord(raw.error);
|
|
73914
|
-
const number4 = (value) => {
|
|
73915
|
-
const parsed = Number(value);
|
|
73916
|
-
return Number.isFinite(parsed) && parsed > 0 ? parsed : void 0;
|
|
73917
|
-
};
|
|
73918
|
-
const input2 = number4(stats?.input_tokens);
|
|
73919
|
-
const output2 = number4(stats?.output_tokens);
|
|
73920
|
-
const cacheRead = number4(stats?.cached);
|
|
73921
|
-
return {
|
|
73922
|
-
type,
|
|
73923
|
-
sessionId: raw.session_id ? String(raw.session_id) : void 0,
|
|
73924
|
-
error: status === "error" ? typeof error63?.message === "string" ? error63.message : "Gemini run ended with an error" : void 0,
|
|
73925
|
-
usage: input2 || output2 || cacheRead ? { input: input2, output: output2, cacheRead } : void 0,
|
|
73926
|
-
done: true,
|
|
73927
|
-
final: status === "success",
|
|
73928
|
-
at: at3
|
|
73929
|
-
};
|
|
73930
|
-
}
|
|
73931
|
-
if (type === "error") {
|
|
73932
|
-
if (String(raw.severity ?? "error") !== "error") return { type, at: at3 };
|
|
73933
|
-
return {
|
|
73934
|
-
type,
|
|
73935
|
-
error: typeof raw.message === "string" ? raw.message : "Gemini run ended with an error",
|
|
73936
|
-
at: at3
|
|
73937
|
-
};
|
|
73938
|
-
}
|
|
73939
|
-
return { type, at: at3 };
|
|
73940
|
-
}
|
|
73941
73846
|
function codexTool(item) {
|
|
73942
73847
|
const itemType = String(item.type ?? "");
|
|
73943
73848
|
const names = {
|
|
@@ -74293,7 +74198,6 @@ function parseDriverLine(driver, line) {
|
|
|
74293
74198
|
if (driver === "pi") return parsePiLine(raw);
|
|
74294
74199
|
if (driver === "claude") return parseClaudeLine(raw);
|
|
74295
74200
|
if (driver === "cursor") return parseCursorLine(raw);
|
|
74296
|
-
if (driver === "gemini") return parseGeminiLine(raw);
|
|
74297
74201
|
if (driver === "codex") return parseCodexLine(raw);
|
|
74298
74202
|
if (driver === "opencode") return parseOpencodeLine(raw);
|
|
74299
74203
|
if (driver === "antigravity") return parseAntigravityLine(raw);
|
|
@@ -86161,6 +86065,7 @@ async function runRemoteCardJob(deps) {
|
|
|
86161
86065
|
log: (message) => deps.log?.(message)
|
|
86162
86066
|
});
|
|
86163
86067
|
const repoPaths = await cloneRepos();
|
|
86068
|
+
await restoreRunContext(repoPaths, context);
|
|
86164
86069
|
if (context.run.kind === "workspace_consult") {
|
|
86165
86070
|
await rm3(gitConfigPath, { force: true }).catch(() => void 0);
|
|
86166
86071
|
}
|
|
@@ -86184,6 +86089,10 @@ async function runRemoteCardJob(deps) {
|
|
|
86184
86089
|
systemPromptAppend: context.systemPromptAppend
|
|
86185
86090
|
});
|
|
86186
86091
|
const exit = await runAgent(command, env);
|
|
86092
|
+
await uploadRunContext(repoPaths, context).catch((error63) => {
|
|
86093
|
+
write(`[aglio] context snapshot failed: ${errorText2(error63)}
|
|
86094
|
+
`);
|
|
86095
|
+
});
|
|
86187
86096
|
if (deps.cancelled()) return { state: "cancelled", error: "Cancelled from the board" };
|
|
86188
86097
|
await status({ finalMessage: exit.finalMessage });
|
|
86189
86098
|
if (exit.error) return { state: "failed", error: exit.error };
|
|
@@ -86533,6 +86442,194 @@ async function runRemoteCardJob(deps) {
|
|
|
86533
86442
|
}
|
|
86534
86443
|
}
|
|
86535
86444
|
}
|
|
86445
|
+
function sessionDirsForDriver(driver) {
|
|
86446
|
+
if (driver === "pi") return ["sessions"];
|
|
86447
|
+
if (driver === "claude") return ["projects"];
|
|
86448
|
+
if (driver === "codex") return ["home/.codex/sessions"];
|
|
86449
|
+
if (driver === "cursor") return ["home/.cursor/chats"];
|
|
86450
|
+
if (driver === "opencode") return ["home/.local/share/opencode/storage"];
|
|
86451
|
+
if (driver === "antigravity") return ["home/.gemini/tmp"];
|
|
86452
|
+
if (driver === "hermes") return ["sessions"];
|
|
86453
|
+
return [];
|
|
86454
|
+
}
|
|
86455
|
+
async function uploadRunContext(repoPaths, current) {
|
|
86456
|
+
if (!current.card || current.run.kind === "workspace_consult") return;
|
|
86457
|
+
const staging = join5(workspace, ".aglio", "context");
|
|
86458
|
+
const archivePath = join5(workspace, ".aglio", `run-context-${current.run.id}.tar.gz`);
|
|
86459
|
+
await rm3(staging, { recursive: true, force: true }).catch(() => void 0);
|
|
86460
|
+
await rm3(archivePath, { force: true }).catch(() => void 0);
|
|
86461
|
+
await mkdir2(staging, { recursive: true });
|
|
86462
|
+
const manifest = {
|
|
86463
|
+
version: 1,
|
|
86464
|
+
runId: current.run.id,
|
|
86465
|
+
driver: current.agent.driver,
|
|
86466
|
+
sessionId: current.run.sessionId,
|
|
86467
|
+
sessionDirs: [],
|
|
86468
|
+
repos: [],
|
|
86469
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
86470
|
+
};
|
|
86471
|
+
for (const [index3, target] of repoPaths.entries()) {
|
|
86472
|
+
const repo = current.repos[index3];
|
|
86473
|
+
if (!repo) continue;
|
|
86474
|
+
const targetRun = containerPath(runRoot, workspace, target);
|
|
86475
|
+
const base = repo.baseBranch || "main";
|
|
86476
|
+
const baseRef = (await runGit(workspace, ["-C", targetRun, "rev-parse", "--verify", `origin/${base}`])).code === 0 ? `origin/${base}` : base;
|
|
86477
|
+
const patchRel = `repo-${index3}.patch`;
|
|
86478
|
+
const patchPath = join5(staging, patchRel);
|
|
86479
|
+
const indexFile = join5(staging, `index-${index3}`);
|
|
86480
|
+
const indexFileRun = containerPath(runRoot, workspace, indexFile);
|
|
86481
|
+
const patchPathRun = containerPath(runRoot, workspace, patchPath);
|
|
86482
|
+
const command = [
|
|
86483
|
+
`GIT_INDEX_FILE=${shellArg2(indexFileRun)} git -C ${shellArg2(targetRun)} read-tree ${shellArg2(baseRef)}`,
|
|
86484
|
+
`GIT_INDEX_FILE=${shellArg2(indexFileRun)} git -C ${shellArg2(targetRun)} add -A`,
|
|
86485
|
+
`GIT_INDEX_FILE=${shellArg2(indexFileRun)} git -C ${shellArg2(targetRun)} diff --cached --binary ${shellArg2(baseRef)} > ${shellArg2(patchPathRun)}`
|
|
86486
|
+
].join(" && ");
|
|
86487
|
+
const code = await deps.runCommand({
|
|
86488
|
+
command,
|
|
86489
|
+
cwd: workspace,
|
|
86490
|
+
env: { GIT_TERMINAL_PROMPT: "0" },
|
|
86491
|
+
signal: deps.signal,
|
|
86492
|
+
onOutput: () => void 0
|
|
86493
|
+
});
|
|
86494
|
+
if (code === 0) {
|
|
86495
|
+
manifest.repos.push({ name: repo.name, baseBranch: base, patch: patchRel });
|
|
86496
|
+
} else {
|
|
86497
|
+
write(`[aglio] context patch skipped for ${repo.name}
|
|
86498
|
+
`);
|
|
86499
|
+
}
|
|
86500
|
+
}
|
|
86501
|
+
for (const [index3, relative6] of sessionDirsForDriver(current.agent.driver).entries()) {
|
|
86502
|
+
const source = join5(toolDir, relative6);
|
|
86503
|
+
const info = await stat3(source).catch(() => null);
|
|
86504
|
+
if (!info?.isDirectory()) continue;
|
|
86505
|
+
const archiveName = `session-${index3}`;
|
|
86506
|
+
await mkdir2(join5(staging, archiveName), { recursive: true });
|
|
86507
|
+
const copied = await deps.runCommand({
|
|
86508
|
+
command: `cp -a ${shellArg2(`${containerPath(runRoot, workspace, source)}/.`)} ${shellArg2(`${containerPath(runRoot, workspace, join5(staging, archiveName))}/`)}`,
|
|
86509
|
+
cwd: workspace,
|
|
86510
|
+
env: {},
|
|
86511
|
+
signal: deps.signal,
|
|
86512
|
+
onOutput: () => void 0
|
|
86513
|
+
});
|
|
86514
|
+
if (copied === 0) manifest.sessionDirs.push({ path: relative6, archive: archiveName });
|
|
86515
|
+
}
|
|
86516
|
+
await writeFile(join5(staging, "manifest.json"), JSON.stringify(manifest, null, 2), "utf8");
|
|
86517
|
+
const tarArgs = [
|
|
86518
|
+
"-czf",
|
|
86519
|
+
containerPath(runRoot, workspace, archivePath),
|
|
86520
|
+
"-C",
|
|
86521
|
+
containerPath(runRoot, workspace, staging),
|
|
86522
|
+
"manifest.json"
|
|
86523
|
+
];
|
|
86524
|
+
for (const repo of manifest.repos) tarArgs.push(repo.patch);
|
|
86525
|
+
for (const session of manifest.sessionDirs) tarArgs.push(session.archive);
|
|
86526
|
+
const tarCode = await deps.runCommand({
|
|
86527
|
+
command: ["tar", ...tarArgs].map(shellArg2).join(" "),
|
|
86528
|
+
cwd: workspace,
|
|
86529
|
+
env: {},
|
|
86530
|
+
signal: deps.signal,
|
|
86531
|
+
onOutput: () => void 0
|
|
86532
|
+
});
|
|
86533
|
+
if (tarCode !== 0) {
|
|
86534
|
+
write("[aglio] context archive failed\n");
|
|
86535
|
+
return;
|
|
86536
|
+
}
|
|
86537
|
+
const data = await readFile2(archivePath).catch(() => null);
|
|
86538
|
+
if (!data?.length) return;
|
|
86539
|
+
if (data.length > 10 * 1024 * 1024) {
|
|
86540
|
+
write("[aglio] context archive exceeds 10MB, skipped\n");
|
|
86541
|
+
return;
|
|
86542
|
+
}
|
|
86543
|
+
try {
|
|
86544
|
+
const artifactId = await deps.jobApi.uploadArtifact({
|
|
86545
|
+
...lease,
|
|
86546
|
+
name: `run-context-${current.run.id}.tar.gz`,
|
|
86547
|
+
label: `Run context ${current.run.id.slice(0, 8)}`,
|
|
86548
|
+
mime: "application/gzip",
|
|
86549
|
+
data,
|
|
86550
|
+
kind: "context"
|
|
86551
|
+
});
|
|
86552
|
+
if (artifactId) write(`[aglio] context snapshot uploaded (${data.length} bytes)
|
|
86553
|
+
`);
|
|
86554
|
+
} catch (error63) {
|
|
86555
|
+
write(`[aglio] context snapshot upload failed: ${errorText2(error63)}
|
|
86556
|
+
`);
|
|
86557
|
+
} finally {
|
|
86558
|
+
await rm3(staging, { recursive: true, force: true }).catch(() => void 0);
|
|
86559
|
+
await rm3(archivePath, { force: true }).catch(() => void 0);
|
|
86560
|
+
}
|
|
86561
|
+
}
|
|
86562
|
+
async function restoreRunContext(repoPaths, current) {
|
|
86563
|
+
const artifactId = current.run.restoreContextArtifactId;
|
|
86564
|
+
if (!artifactId) return;
|
|
86565
|
+
const restoreDir = join5(workspace, ".aglio", "context-restore");
|
|
86566
|
+
const archivePath = join5(restoreDir, "context.tar.gz");
|
|
86567
|
+
await rm3(restoreDir, { recursive: true, force: true }).catch(() => void 0);
|
|
86568
|
+
await mkdir2(restoreDir, { recursive: true });
|
|
86569
|
+
let data;
|
|
86570
|
+
try {
|
|
86571
|
+
data = await deps.api.fetchAttachment({ ...lease, artifactId });
|
|
86572
|
+
} catch (error63) {
|
|
86573
|
+
write(`[aglio] context restore download failed: ${errorText2(error63)}
|
|
86574
|
+
`);
|
|
86575
|
+
return;
|
|
86576
|
+
}
|
|
86577
|
+
await writeFile(archivePath, data);
|
|
86578
|
+
const unpacked = await deps.runCommand({
|
|
86579
|
+
command: `tar -xzf ${shellArg2(containerPath(runRoot, workspace, archivePath))} -C ${shellArg2(containerPath(runRoot, workspace, restoreDir))}`,
|
|
86580
|
+
cwd: workspace,
|
|
86581
|
+
env: {},
|
|
86582
|
+
signal: deps.signal,
|
|
86583
|
+
onOutput: () => void 0
|
|
86584
|
+
});
|
|
86585
|
+
if (unpacked !== 0) {
|
|
86586
|
+
write("[aglio] context restore unpack failed\n");
|
|
86587
|
+
return;
|
|
86588
|
+
}
|
|
86589
|
+
const manifest = await readFile2(join5(restoreDir, "manifest.json"), "utf8").then((text) => JSON.parse(text)).catch(() => null);
|
|
86590
|
+
if (!manifest) {
|
|
86591
|
+
write("[aglio] context restore manifest missing\n");
|
|
86592
|
+
return;
|
|
86593
|
+
}
|
|
86594
|
+
for (const [index3, repo] of (manifest.repos ?? []).entries()) {
|
|
86595
|
+
if (!repo.patch) continue;
|
|
86596
|
+
const target = repoPaths[index3];
|
|
86597
|
+
const repoConfig = current.repos[index3];
|
|
86598
|
+
if (!target || !repoConfig) continue;
|
|
86599
|
+
const targetRun = containerPath(runRoot, workspace, target);
|
|
86600
|
+
const patchPath = resolve4(restoreDir, repo.patch);
|
|
86601
|
+
if (!patchPath.startsWith(resolve4(restoreDir))) continue;
|
|
86602
|
+
const patchPathRun = containerPath(runRoot, workspace, patchPath);
|
|
86603
|
+
const apply = await runGit(workspace, ["-C", targetRun, "apply", "--binary", "--3way", "--whitespace=nowarn", patchPathRun]);
|
|
86604
|
+
if (apply.code !== 0) {
|
|
86605
|
+
const reverse = await runGit(workspace, ["-C", targetRun, "apply", "--reverse", "--check", "--binary", patchPathRun]);
|
|
86606
|
+
if (reverse.code === 0) {
|
|
86607
|
+
write(`[aglio] context patch already present in ${repoConfig.name}
|
|
86608
|
+
`);
|
|
86609
|
+
} else {
|
|
86610
|
+
write(`[aglio] context patch did not apply in ${repoConfig.name}
|
|
86611
|
+
`);
|
|
86612
|
+
}
|
|
86613
|
+
}
|
|
86614
|
+
}
|
|
86615
|
+
for (const session of manifest.sessionDirs ?? []) {
|
|
86616
|
+
if (!session.path || !session.archive) continue;
|
|
86617
|
+
const target = resolve4(toolDir, session.path);
|
|
86618
|
+
if (!target.startsWith(resolve4(toolDir))) continue;
|
|
86619
|
+
await rm3(target, { recursive: true, force: true }).catch(() => void 0);
|
|
86620
|
+
await mkdir2(target, { recursive: true });
|
|
86621
|
+
const restored = await deps.runCommand({
|
|
86622
|
+
command: `tar -xzf ${shellArg2(containerPath(runRoot, workspace, archivePath))} -C ${shellArg2(containerPath(runRoot, workspace, target))} --strip-components=1 ${shellArg2(session.archive)}`,
|
|
86623
|
+
cwd: workspace,
|
|
86624
|
+
env: {},
|
|
86625
|
+
signal: deps.signal,
|
|
86626
|
+
onOutput: () => void 0
|
|
86627
|
+
});
|
|
86628
|
+
if (restored === 0) write(`[aglio] restored session ${session.path}
|
|
86629
|
+
`);
|
|
86630
|
+
}
|
|
86631
|
+
await rm3(restoreDir, { recursive: true, force: true }).catch(() => void 0);
|
|
86632
|
+
}
|
|
86536
86633
|
async function gitOutput(args) {
|
|
86537
86634
|
let output2 = "";
|
|
86538
86635
|
const code = await deps.runCommand({
|
|
@@ -87472,7 +87569,8 @@ function jobApi(config2, fetchImpl, signal) {
|
|
|
87472
87569
|
"x-aglio-lease-id": input2.leaseId,
|
|
87473
87570
|
"x-aglio-name": encodeURIComponent(input2.name),
|
|
87474
87571
|
"x-aglio-label": input2.label,
|
|
87475
|
-
"x-aglio-mime": input2.mime
|
|
87572
|
+
"x-aglio-mime": input2.mime,
|
|
87573
|
+
...input2.kind ? { "x-aglio-kind": input2.kind } : {}
|
|
87476
87574
|
},
|
|
87477
87575
|
body: input2.data,
|
|
87478
87576
|
signal
|