aglio-worker 0.98.0 → 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 +203 -113
- 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",
|
|
@@ -71616,7 +71599,7 @@ var MAX_INVITE_EXPIRY_DAYS = 90;
|
|
|
71616
71599
|
// ../../packages/shared/src/image-upload-quality.ts
|
|
71617
71600
|
var IMAGE_UPLOAD_QUALITY_LEVELS = ["lowest", "low", "medium", "high"];
|
|
71618
71601
|
var imageUploadQualitySchema = external_exports.enum(IMAGE_UPLOAD_QUALITY_LEVELS);
|
|
71619
|
-
var DEFAULT_IMAGE_UPLOAD_QUALITY = "
|
|
71602
|
+
var DEFAULT_IMAGE_UPLOAD_QUALITY = "medium";
|
|
71620
71603
|
|
|
71621
71604
|
// ../../packages/shared/src/workspace-settings.ts
|
|
71622
71605
|
var WORKSPACE_SETTINGS_DEFAULTS = {
|
|
@@ -71624,7 +71607,7 @@ var WORKSPACE_SETTINGS_DEFAULTS = {
|
|
|
71624
71607
|
defaultAgentConfigId: null,
|
|
71625
71608
|
/** 0 means keep artifacts forever. */
|
|
71626
71609
|
artifactRetentionDays: 0,
|
|
71627
|
-
/** Uploaded pictures are always re-encoded.
|
|
71610
|
+
/** Uploaded pictures are always re-encoded. Everyone starts at Medium. */
|
|
71628
71611
|
imageUploadQuality: DEFAULT_IMAGE_UPLOAD_QUALITY,
|
|
71629
71612
|
/** The shared workspace consultant is opt-out. Disabled hides every entry point. */
|
|
71630
71613
|
consultantEnabled: true,
|
|
@@ -73281,7 +73264,7 @@ function driverThinkingArgs(driver, thinking) {
|
|
|
73281
73264
|
function hermesProvider(provider) {
|
|
73282
73265
|
const normalized = provider.toLowerCase();
|
|
73283
73266
|
if (normalized === "openai") return "openai-api";
|
|
73284
|
-
if (normalized === "google"
|
|
73267
|
+
if (normalized === "google") return "gemini";
|
|
73285
73268
|
return normalized;
|
|
73286
73269
|
}
|
|
73287
73270
|
function buildDriverCommand(input2) {
|
|
@@ -73343,26 +73326,6 @@ function buildDriverCommand(input2) {
|
|
|
73343
73326
|
args2.push(prompt);
|
|
73344
73327
|
return args2;
|
|
73345
73328
|
}
|
|
73346
|
-
if (input2.driver === "gemini") {
|
|
73347
|
-
const args2 = [
|
|
73348
|
-
"gemini",
|
|
73349
|
-
"-p",
|
|
73350
|
-
prompt,
|
|
73351
|
-
"-m",
|
|
73352
|
-
input2.model,
|
|
73353
|
-
"--output-format",
|
|
73354
|
-
"stream-json",
|
|
73355
|
-
"--yolo",
|
|
73356
|
-
"--skip-trust"
|
|
73357
|
-
];
|
|
73358
|
-
if (input2.resume && input2.sessionId) {
|
|
73359
|
-
args2.push("--resume", input2.sessionId);
|
|
73360
|
-
} else if (input2.sessionId) {
|
|
73361
|
-
args2.push("--session-id", input2.sessionId);
|
|
73362
|
-
}
|
|
73363
|
-
if (input2.workingDirectory) args2.push("--include-directories", input2.workingDirectory);
|
|
73364
|
-
return args2;
|
|
73365
|
-
}
|
|
73366
73329
|
if (input2.driver === "cursor") {
|
|
73367
73330
|
const args2 = [
|
|
73368
73331
|
"cursor-agent",
|
|
@@ -73577,23 +73540,11 @@ function driverSetupCommands(driver, url2, extraServers = []) {
|
|
|
73577
73540
|
}
|
|
73578
73541
|
return [["bash", "-lc", parts.join("; ")]];
|
|
73579
73542
|
}
|
|
73580
|
-
if (driver === "gemini") {
|
|
73581
|
-
const parts = [
|
|
73582
|
-
`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`
|
|
73583
|
-
];
|
|
73584
|
-
for (const server of extraServers) {
|
|
73585
|
-
const headers = server.headers.map((header) => `--header ${shellQuote(`${header.name}: ${header.value}`)}`).join(" ");
|
|
73586
|
-
parts.push(
|
|
73587
|
-
`gemini mcp remove ${server.name} >/dev/null 2>&1 || true; gemini mcp add ${server.name} ${shellQuote(server.url)} --transport http ${headers} --trust --scope user`
|
|
73588
|
-
);
|
|
73589
|
-
}
|
|
73590
|
-
return [["bash", "-lc", parts.join("; ")]];
|
|
73591
|
-
}
|
|
73592
73543
|
return [];
|
|
73593
73544
|
}
|
|
73594
73545
|
function providerEnv(provider, apiKey2) {
|
|
73595
73546
|
const normalized = provider.toLowerCase();
|
|
73596
|
-
if (normalized === "google"
|
|
73547
|
+
if (normalized === "google") {
|
|
73597
73548
|
return { GEMINI_API_KEY: apiKey2, GOOGLE_API_KEY: apiKey2 };
|
|
73598
73549
|
}
|
|
73599
73550
|
if (normalized === "antigravity") return { GEMINI_API_KEY: apiKey2 };
|
|
@@ -73892,60 +73843,6 @@ function parseCursorLine(raw) {
|
|
|
73892
73843
|
}
|
|
73893
73844
|
return { type, at: at3 };
|
|
73894
73845
|
}
|
|
73895
|
-
function parseGeminiLine(raw) {
|
|
73896
|
-
const type = String(raw.type ?? "");
|
|
73897
|
-
const at3 = timestampOf(raw.timestamp);
|
|
73898
|
-
if (type === "init") {
|
|
73899
|
-
return { type, sessionId: raw.session_id ? String(raw.session_id) : void 0, at: at3 };
|
|
73900
|
-
}
|
|
73901
|
-
if (type === "message") {
|
|
73902
|
-
const role = String(raw.role ?? "");
|
|
73903
|
-
if (role !== "assistant") return { type, at: at3 };
|
|
73904
|
-
const text = typeof raw.content === "string" ? raw.content : void 0;
|
|
73905
|
-
return { type, assistantText: text || void 0, assistantDelta: raw.delta === true, at: at3 };
|
|
73906
|
-
}
|
|
73907
|
-
if (type === "tool_use") {
|
|
73908
|
-
return {
|
|
73909
|
-
type,
|
|
73910
|
-
toolName: typeof raw.tool_name === "string" ? raw.tool_name : "tool",
|
|
73911
|
-
toolArgs: raw.parameters,
|
|
73912
|
-
toolCallId: typeof raw.tool_id === "string" ? raw.tool_id : void 0,
|
|
73913
|
-
toolStart: true,
|
|
73914
|
-
toolPartial: false,
|
|
73915
|
-
at: at3
|
|
73916
|
-
};
|
|
73917
|
-
}
|
|
73918
|
-
if (type === "result") {
|
|
73919
|
-
const stats = asRecord(raw.stats);
|
|
73920
|
-
const status = String(raw.status ?? "");
|
|
73921
|
-
const error63 = asRecord(raw.error);
|
|
73922
|
-
const number4 = (value) => {
|
|
73923
|
-
const parsed = Number(value);
|
|
73924
|
-
return Number.isFinite(parsed) && parsed > 0 ? parsed : void 0;
|
|
73925
|
-
};
|
|
73926
|
-
const input2 = number4(stats?.input_tokens);
|
|
73927
|
-
const output2 = number4(stats?.output_tokens);
|
|
73928
|
-
const cacheRead = number4(stats?.cached);
|
|
73929
|
-
return {
|
|
73930
|
-
type,
|
|
73931
|
-
sessionId: raw.session_id ? String(raw.session_id) : void 0,
|
|
73932
|
-
error: status === "error" ? typeof error63?.message === "string" ? error63.message : "Gemini run ended with an error" : void 0,
|
|
73933
|
-
usage: input2 || output2 || cacheRead ? { input: input2, output: output2, cacheRead } : void 0,
|
|
73934
|
-
done: true,
|
|
73935
|
-
final: status === "success",
|
|
73936
|
-
at: at3
|
|
73937
|
-
};
|
|
73938
|
-
}
|
|
73939
|
-
if (type === "error") {
|
|
73940
|
-
if (String(raw.severity ?? "error") !== "error") return { type, at: at3 };
|
|
73941
|
-
return {
|
|
73942
|
-
type,
|
|
73943
|
-
error: typeof raw.message === "string" ? raw.message : "Gemini run ended with an error",
|
|
73944
|
-
at: at3
|
|
73945
|
-
};
|
|
73946
|
-
}
|
|
73947
|
-
return { type, at: at3 };
|
|
73948
|
-
}
|
|
73949
73846
|
function codexTool(item) {
|
|
73950
73847
|
const itemType = String(item.type ?? "");
|
|
73951
73848
|
const names = {
|
|
@@ -74301,7 +74198,6 @@ function parseDriverLine(driver, line) {
|
|
|
74301
74198
|
if (driver === "pi") return parsePiLine(raw);
|
|
74302
74199
|
if (driver === "claude") return parseClaudeLine(raw);
|
|
74303
74200
|
if (driver === "cursor") return parseCursorLine(raw);
|
|
74304
|
-
if (driver === "gemini") return parseGeminiLine(raw);
|
|
74305
74201
|
if (driver === "codex") return parseCodexLine(raw);
|
|
74306
74202
|
if (driver === "opencode") return parseOpencodeLine(raw);
|
|
74307
74203
|
if (driver === "antigravity") return parseAntigravityLine(raw);
|
|
@@ -86169,6 +86065,7 @@ async function runRemoteCardJob(deps) {
|
|
|
86169
86065
|
log: (message) => deps.log?.(message)
|
|
86170
86066
|
});
|
|
86171
86067
|
const repoPaths = await cloneRepos();
|
|
86068
|
+
await restoreRunContext(repoPaths, context);
|
|
86172
86069
|
if (context.run.kind === "workspace_consult") {
|
|
86173
86070
|
await rm3(gitConfigPath, { force: true }).catch(() => void 0);
|
|
86174
86071
|
}
|
|
@@ -86192,6 +86089,10 @@ async function runRemoteCardJob(deps) {
|
|
|
86192
86089
|
systemPromptAppend: context.systemPromptAppend
|
|
86193
86090
|
});
|
|
86194
86091
|
const exit = await runAgent(command, env);
|
|
86092
|
+
await uploadRunContext(repoPaths, context).catch((error63) => {
|
|
86093
|
+
write(`[aglio] context snapshot failed: ${errorText2(error63)}
|
|
86094
|
+
`);
|
|
86095
|
+
});
|
|
86195
86096
|
if (deps.cancelled()) return { state: "cancelled", error: "Cancelled from the board" };
|
|
86196
86097
|
await status({ finalMessage: exit.finalMessage });
|
|
86197
86098
|
if (exit.error) return { state: "failed", error: exit.error };
|
|
@@ -86541,6 +86442,194 @@ async function runRemoteCardJob(deps) {
|
|
|
86541
86442
|
}
|
|
86542
86443
|
}
|
|
86543
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
|
+
}
|
|
86544
86633
|
async function gitOutput(args) {
|
|
86545
86634
|
let output2 = "";
|
|
86546
86635
|
const code = await deps.runCommand({
|
|
@@ -87480,7 +87569,8 @@ function jobApi(config2, fetchImpl, signal) {
|
|
|
87480
87569
|
"x-aglio-lease-id": input2.leaseId,
|
|
87481
87570
|
"x-aglio-name": encodeURIComponent(input2.name),
|
|
87482
87571
|
"x-aglio-label": input2.label,
|
|
87483
|
-
"x-aglio-mime": input2.mime
|
|
87572
|
+
"x-aglio-mime": input2.mime,
|
|
87573
|
+
...input2.kind ? { "x-aglio-kind": input2.kind } : {}
|
|
87484
87574
|
},
|
|
87485
87575
|
body: input2.data,
|
|
87486
87576
|
signal
|