@outerlayer/cli 0.41.1 → 0.42.0-next.20261119011332
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/README.md +1 -1
- package/dist/{agent-setup-BJRTAU3H.js → agent-setup-RWS247BZ.js} +1 -1
- package/dist/build-info.json +1 -1
- package/dist/{caller-ZUQVRQMY.js → caller-WLYRCJKR.js} +1 -1
- package/dist/{check-YN3NMNHB.js → check-HABHY27Y.js} +7 -7
- package/dist/{chunk-7TDLQUJ5.js → chunk-BWDUZJ4K.js} +1 -1
- package/dist/chunk-CBSURJ2P.js +88 -0
- package/dist/{chunk-B2TOGQHU.js → chunk-CUPEP5D2.js} +3 -2
- package/dist/{chunk-F2FZG6FG.js → chunk-H7L6XTQQ.js} +1 -1
- package/dist/{chunk-ND6R4UHO.js → chunk-HNWNJ6QK.js} +1 -1
- package/dist/{chunk-QLHEU44A.js → chunk-HT6HMUC3.js} +1 -1
- package/dist/chunk-IMGBXZUX.js +41 -0
- package/dist/{chunk-UE6OJBU6.js → chunk-IOWXXJUM.js} +1 -1
- package/dist/{chunk-6XSVJ7O7.js → chunk-K476DEC7.js} +2 -2
- package/dist/{chunk-MI3YC7JL.js → chunk-M4V46N7A.js} +66 -9
- package/dist/{chunk-7CMRGY4Z.js → chunk-QHZZUINX.js} +1 -1
- package/dist/{chunk-SVALMZJU.js → chunk-UE6ZEQAL.js} +14 -10
- package/dist/{chunk-S3VUP7LF.js → chunk-V3T36H4O.js} +2 -2
- package/dist/{chunk-U74IJMMN.js → chunk-WXGEDDUO.js} +114 -30
- package/dist/{chunk-4JVYALPL.js → chunk-YPS6YOYK.js} +12 -8
- package/dist/{chunk-4GXROH35.js → chunk-ZN3RUNOZ.js} +5 -87
- package/dist/{cli-B7VPNSJB.js → cli-KDLYNUNH.js} +55 -38
- package/dist/{command-23WALNEO.js → command-GZJHU5QD.js} +4 -4
- package/dist/{container-start-ZWE4BSMK.js → container-start-R2C2UNL6.js} +5 -5
- package/dist/{doctor-N4USOXZL.js → doctor-D7B4Z7Y7.js} +5 -5
- package/dist/{fleet-readiness-6WFZ6DSU.js → fleet-readiness-452TASWD.js} +2 -1
- package/dist/{host-checks-QYSWXJHF.js → host-checks-SMVSA55L.js} +3 -3
- package/dist/index.js +1 -1
- package/dist/{init-OFLW5CQN.js → init-RWDQWHCW.js} +3 -3
- package/dist/{init-5XO6SUSS.js → init-ZCNI5SFB.js} +3 -3
- package/dist/{init-agent-K7GN7NAJ.js → init-agent-YGLQSRVI.js} +3 -3
- package/dist/{init-cmd-OEPA6SZX.js → init-cmd-N35UZUCM.js} +4 -3
- package/dist/{init-update-ZBCOQJEX.js → init-update-TKH2L4VO.js} +3 -2
- package/dist/{loop-6CVDHR4M.js → loop-YMGQKGIS.js} +7 -7
- package/dist/{machine-7SELY76I.js → machine-AFXMDA56.js} +3 -3
- package/dist/{runner-key-ZT6HBAUY.js → runner-key-H3CKD4UB.js} +3 -3
- package/dist/{setup-cmd-VFKTGD52.js → setup-cmd-IBGMGFMJ.js} +97 -13
- package/dist/{setup-wiring-MF3FYG4U.js → setup-wiring-O5SJZBTP.js} +19 -12
- package/dist/{status-XSXYRYU6.js → status-GC2RXFMJ.js} +3 -3
- package/dist/{update-steps-U6LUOXPF.js → update-steps-U7JDUYLU.js} +4 -4
- package/dist/{work-claim-cmd-BZ5RFKVN.js → work-claim-cmd-2WWN4XB7.js} +1 -1
- package/dist/{work-proofs-cmd-UXBOOBIG.js → work-proofs-cmd-EJPH5GY3.js} +1 -1
- package/dist/{work-proofs-record-BQOPO3NI.js → work-proofs-record-B25ZFR2P.js} +1 -1
- package/package.json +1 -1
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
3
|
import { readHousekeepingRecord, writeHousekeepingRecord } from './chunk-6YBI24YT.js';
|
|
4
4
|
import { fetchVersionMeta, npmVersion, npmSupportsProvenance, fetchTarballDigest, fetchProvenance, installVersion, auditSignatures } from './chunk-E7R2GIAW.js';
|
|
5
|
-
import { reportFailedStart, fitImageBuildMemory } from './chunk-
|
|
6
|
-
import { renderUpdateSteps } from './chunk-
|
|
5
|
+
import { reportFailedStart, fitImageBuildMemory } from './chunk-HNWNJ6QK.js';
|
|
6
|
+
import { renderUpdateSteps } from './chunk-IOWXXJUM.js';
|
|
7
7
|
import { decideInstalledSwitch } from './chunk-TXKHD4Q6.js';
|
|
8
8
|
import { writeFleetState } from './chunk-GFXXAXPF.js';
|
|
9
9
|
import { writePendingUpdate } from './chunk-AVYR5USX.js';
|
|
10
|
-
import { fleetConfigProblem, realBlockedProbes, checkBlockedWithSlots, askFleetMachine } from './chunk-
|
|
10
|
+
import { fleetConfigProblem, realBlockedProbes, checkBlockedWithSlots, askFleetMachine } from './chunk-QHZZUINX.js';
|
|
11
11
|
import { writeMarker, readMarker, currentVersion, removeMarker, isInLayout, startedThroughCurrent, entryIn, versionDir, switchCurrent, cleanVersions, stagingDir } from './chunk-CYQSTT5N.js';
|
|
12
|
-
import { leaseTimeLeftMs, createContainerRuntime, heldSandboxClaimsOf, unfinishedJobs, withTunnelLog, itemTag, releaseLease, runDecision, claimRun, LEASE_SECONDS, isUnfinished, prepareResume, restoreSessionIntoMicroVm, restoreSessionIntoContainer, restoreSessionIntoSandbox, restoreWork, keptSessionDir, workRestoredEnv, sessionGuestOfMicroVm, sessionGuestOfContainer, sessionGuestOfSandbox, recordsProofsOnly, itemScope, attemptNote, noteMissingCredential, fetchManagedBuildSettings, holdManagedBuildSettings, setStage, jobEnv, runHook, describeHookEnd, needsBuildSkill, provisionContainer, leaseExpiresAtMs, withJobTimeLimit, deliverContainerHooks, provisionSandbox, deliverSandboxHooks, provisionMicroVm, deliverCommitHooks, provisionEnvironment, readProvisionOut, resolveHostBuild, workdirProblem, listenOnBroker, hostEnvironment, deliverExecMaven, runWithSpawn, hostCommandEnvironment, lifecycleSteps, execArgv, lifecycleFailureReason, decideHostBuildSkill, prepareBranch, keptCommitsLine, runCommandFor, currentSkillCommand, formerSkillProblem, commandLogOffset, startSandboxCommand, MICROVM_COMMAND_DIR, startMicroVmCommand, microVmCommandLine, runCommand, containerCommandExec, execCommandLine, startSender, commandEndReasonOf, holdManagedKey, startHostServices, finishJob, sampleGuest, foldSample, isSandboxTracked, isContainerTracked, isMicroVmTracked, probeSandboxCommand, probeMicroVmCommand, probeCommand, appendCommandLog, judgeProbe, SandboxGoneError, SandboxContainerStoppedError, EXIT_CODE_FILE, isTracked, isGroupAlive, outcomeFromExitCode, isIsolatedJob, jobTimeLimitMinutes, isTimedOut, readCpuUsec, isIdle, HELPER_ENV, setUpRunnerCgroup, stopOrphanedMicroVms, sweepImageBuilders, listUnreadableJobs, listAdoptableJobs, retryFailedReleases, recoverLostJobs, GUEST_USAGE_INTERVAL_MS, vmAlive, filesAreCopied, inSandbox, listItemDisks, hookLimitsFor,
|
|
13
|
-
import { RUNNER_PROTOCOL } from './chunk-
|
|
12
|
+
import { leaseTimeLeftMs, createContainerRuntime, heldSandboxClaimsOf, unfinishedJobs, withTunnelLog, itemTag, releaseLease, runCommandOf, runDecision, claimRun, LEASE_SECONDS, isUnfinished, prepareResume, restoreSessionIntoMicroVm, restoreSessionIntoContainer, restoreSessionIntoSandbox, restoreWork, keptSessionDir, workRestoredEnv, sessionGuestOfMicroVm, sessionGuestOfContainer, sessionGuestOfSandbox, recordsProofsOnly, itemScope, attemptNote, noteMissingCredential, fetchManagedBuildSettings, holdManagedBuildSettings, setStage, jobEnv, runHook, describeHookEnd, needsBuildSkill, provisionContainer, leaseExpiresAtMs, withJobTimeLimit, deliverContainerHooks, provisionSandbox, deliverSandboxHooks, provisionMicroVm, deliverCommitHooks, provisionEnvironment, readProvisionOut, resolveHostBuild, workdirProblem, listenOnBroker, hostEnvironment, deliverExecMaven, runWithSpawn, hostCommandEnvironment, lifecycleSteps, execArgv, lifecycleFailureReason, decideHostBuildSkill, prepareBranch, keptCommitsLine, runCommandFor, currentSkillCommand, formerSkillProblem, commandLogOffset, startSandboxCommand, MICROVM_COMMAND_DIR, startMicroVmCommand, microVmCommandLine, runCommand, containerCommandExec, execCommandLine, startSender, commandEndReasonOf, holdManagedKey, startHostServices, finishJob, sampleGuest, foldSample, isSandboxTracked, isContainerTracked, isMicroVmTracked, probeSandboxCommand, probeMicroVmCommand, probeCommand, appendCommandLog, judgeProbe, SandboxGoneError, SandboxContainerStoppedError, EXIT_CODE_FILE, isTracked, isGroupAlive, outcomeFromExitCode, isIsolatedJob, jobTimeLimitMinutes, isTimedOut, readCpuUsec, isIdle, HELPER_ENV, setUpRunnerCgroup, stopOrphanedMicroVms, sweepImageBuilders, listUnreadableJobs, listAdoptableJobs, retryFailedReleases, recoverLostJobs, GUEST_USAGE_INTERVAL_MS, vmAlive, filesAreCopied, inSandbox, releaseRun, listItemDisks, hookLimitsFor, AttemptLogBook, fetchManagedModelKey, environmentFor, builtOf, judgeCredential, missingJudgeCredential, reviewFiles, readWorkItem, issueText, storedProblemsText, territories, territoryBrief, dropNonProblems, mergeAnswers, carriedProblems, unreviewedItem, makeRecorder, microVmOomKills, needsRenew, renewRun, renewLease, RENEW_INTERVAL_SECONDS, stoppedHelperReason, measureDisk, listTrackedJobs, sweepSandboxes, keptSandboxIds, parseCpuList, ensureTunnel, keepGhConfigCurrent, restartSender, rejoinSandboxBuild, createHousekeepingDocker, housekeepingDockerIfReachable, runHousekeeping, shellQuote, jobRecordsClaim, freeItemDisksUntil, savedStatesDir, readRecords, holdsHostDisk, removeOldestUntil, treeFileText, scrubReason, superviseRuns, NO_LOG, timeoutAfter, unreviewedFiles, markdownSection, ensureNetworkReady, ADOPTED_FETCH_RETRY_WINDOW_MS, managedBuildSettingsFor, gitRemoteFor, startServicesFor, installTrust, createLeaseChannel, serveLease, writeGuestGhConfig, deliverJobFiles, parseRunClaim, inTeardown } from './chunk-UE6ZEQAL.js';
|
|
13
|
+
import { RUNNER_PROTOCOL } from './chunk-BWDUZJ4K.js';
|
|
14
14
|
import { criteriaOf, diffLines, loadCitationFinder, wholeItems, itemsSentence, oneLineReason, treePath, parseJudgeAnswer, wholeEntries, lineInDiff } from './chunk-2QK7L3WV.js';
|
|
15
15
|
import { RepoFilter } from './chunk-AFU6UF34.js';
|
|
16
16
|
import { JOB_STATE_FORMAT, readsJobState, jobStateFormatOf } from './chunk-B4XB5QFD.js';
|
|
17
17
|
import { imageTag, writeUpdateStatus, pullInstruction, tagToPull } from './chunk-NXYTICCS.js';
|
|
18
18
|
import { isVersion, compareVersions, satisfiesRange } from './chunk-TQMI335S.js';
|
|
19
|
-
import { claimCalls, claimItem, spoolHomeFor, leftByRunnerKey, runnerCalls, itemCalls, configForJob } from './chunk-
|
|
19
|
+
import { claimCalls, claimItem, spoolHomeFor, leftByRunnerKey, runnerCalls, itemCalls, configForJob } from './chunk-V3T36H4O.js';
|
|
20
20
|
import { fetchCommit, readBranchHead, diffBetween, readDefaultBranchFiles } from './chunk-XETFYRKD.js';
|
|
21
21
|
import { claimPidFile, releasePidFile, writePidFile, readPidFile } from './chunk-NRR4YLHI.js';
|
|
22
22
|
import { startTimeOf, isSameProcess } from './chunk-JBJTC3UU.js';
|
|
@@ -146,6 +146,19 @@ function parseClaim(value) {
|
|
|
146
146
|
}
|
|
147
147
|
return { data, id, kind, workItemId, number, appId, organizationId, size };
|
|
148
148
|
}
|
|
149
|
+
function parseRun(value, runKey) {
|
|
150
|
+
if (value === null || value === void 0) return void 0;
|
|
151
|
+
if (typeof value !== "object" || Array.isArray(value)) return { malformed: true };
|
|
152
|
+
const data = value;
|
|
153
|
+
const { id, appId, organizationId } = data;
|
|
154
|
+
const named = {
|
|
155
|
+
...typeof id === "string" && id !== "" ? { id } : {},
|
|
156
|
+
...typeof appId === "string" && appId !== "" ? { appId } : {}
|
|
157
|
+
};
|
|
158
|
+
const parsed = parseRunClaim(value, runKey);
|
|
159
|
+
if (parsed.kind !== "claimed" || typeof appId !== "string" || appId === "" || typeof organizationId !== "string" || organizationId === "") return { malformed: true, ...named };
|
|
160
|
+
return { run: parsed.run, runKey: parsed.runKey, appId, organizationId };
|
|
161
|
+
}
|
|
149
162
|
function parseStops(value) {
|
|
150
163
|
if (!Array.isArray(value)) return [];
|
|
151
164
|
const stops = [];
|
|
@@ -158,8 +171,10 @@ function parseStops(value) {
|
|
|
158
171
|
}
|
|
159
172
|
function parseAnswer(data) {
|
|
160
173
|
const reservation = Object(data.reservation);
|
|
174
|
+
const run = Object(data.run);
|
|
161
175
|
return {
|
|
162
176
|
claim: parseClaim(data.claim),
|
|
177
|
+
run: parseRun(data.run, run.runKey),
|
|
163
178
|
stops: parseStops(data.stops),
|
|
164
179
|
reservation: typeof reservation.workItemId === "string" && (reservation.size === "small" || reservation.size === "large") ? { workItemId: reservation.workItemId, size: reservation.size } : null,
|
|
165
180
|
...typeof data.reason === "string" ? { reason: data.reason } : {},
|
|
@@ -217,6 +232,25 @@ function noteReason(ports, memory, answer) {
|
|
|
217
232
|
memory.loggedReasons.add(key);
|
|
218
233
|
ports.log.error(`the gateway did not claim work item ${answer.reasonWorkItemId ?? "(not named)"} for this machine: ${answer.reason}`);
|
|
219
234
|
}
|
|
235
|
+
async function takeRun(ports, answer) {
|
|
236
|
+
const end = async (id, appId) => {
|
|
237
|
+
const ended = id !== void 0 && appId !== void 0 ? await ports.endRun({ id, appId }) : false;
|
|
238
|
+
return ended ? "the run was ended as failed" : "the run could not be ended, so it stays held until its lease lapses";
|
|
239
|
+
};
|
|
240
|
+
if ("malformed" in answer) {
|
|
241
|
+
ports.log.error(`the gateway's run lacked what a fleet runner needs (its id, factory, organization, key and limits); update the runner \xB7 ${await end(answer.id, answer.appId)}`);
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
if (ports.draining()) {
|
|
245
|
+
ports.log.line(`the runner is draining; ${await end(answer.run.id, answer.appId)} (run ${answer.run.id})`);
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
if (ports.waitsAfterProvision()) {
|
|
249
|
+
ports.log.line(`the runner takes no work after a provision that failed; ${await end(answer.run.id, answer.appId)} (run ${answer.run.id})`);
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
return ports.startRun(answer);
|
|
253
|
+
}
|
|
220
254
|
async function runFleetTick(ports, memory) {
|
|
221
255
|
ports.reload();
|
|
222
256
|
if (!await checkFleet(ports, memory)) return;
|
|
@@ -231,7 +265,7 @@ async function runFleetTick(ports, memory) {
|
|
|
231
265
|
if (answer === void 0) return;
|
|
232
266
|
memory.last = {
|
|
233
267
|
calledAt: ports.now().toISOString(),
|
|
234
|
-
claimId: answer.claim !== void 0 && "id" in answer.claim ? answer.claim.id : null,
|
|
268
|
+
claimId: answer.claim !== void 0 && "id" in answer.claim ? answer.claim.id : answer.run !== void 0 && "run" in answer.run ? answer.run.run.id : null,
|
|
235
269
|
reservation: answer.reservation,
|
|
236
270
|
stops: answer.stops.length,
|
|
237
271
|
...answer.reason === void 0 ? {} : { reason: answer.reason }
|
|
@@ -239,6 +273,12 @@ async function runFleetTick(ports, memory) {
|
|
|
239
273
|
record(ports, memory);
|
|
240
274
|
if (answer.stops.length > 0) ports.applyStops(answer.stops);
|
|
241
275
|
noteReason(ports, memory, answer);
|
|
276
|
+
if (answer.claim === void 0 && answer.run !== void 0) {
|
|
277
|
+
const started2 = await takeRun(ports, answer.run);
|
|
278
|
+
if (!started2 || held || ports.draining()) return;
|
|
279
|
+
if (ports.provisionEnds() > provisionEnds) return;
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
242
282
|
if (answer.claim === void 0) return;
|
|
243
283
|
if ("malformed" in answer.claim) {
|
|
244
284
|
const { workItemId, appId } = answer.claim;
|
|
@@ -284,6 +324,14 @@ async function runFleetKeepalive(ports, memory, minGapMs) {
|
|
|
284
324
|
record(ports, memory);
|
|
285
325
|
if (answer.stops.length > 0) ports.applyStops(answer.stops);
|
|
286
326
|
noteReason(ports, memory, answer);
|
|
327
|
+
if (answer.claim === void 0 && answer.run !== void 0) {
|
|
328
|
+
const run = "malformed" in answer.run ? answer.run : { id: answer.run.run.id, appId: answer.run.appId };
|
|
329
|
+
const ended = run.id !== void 0 && run.appId !== void 0 ? await ports.endRun({ id: run.id, appId: run.appId }) : false;
|
|
330
|
+
ports.log.error(
|
|
331
|
+
`the gateway handed out run ${run.id ?? "(not named)"} to a call that reported no free room \xB7 ` + (ended ? "the run was ended as failed" : "the run could not be ended, so it stays held until its lease lapses")
|
|
332
|
+
);
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
287
335
|
if (answer.claim === void 0) return;
|
|
288
336
|
const { workItemId, appId } = answer.claim;
|
|
289
337
|
const released = workItemId !== void 0 && appId !== void 0 ? await ports.release({ workItemId, appId }) : false;
|
|
@@ -3040,6 +3088,13 @@ async function fleetHeld(state) {
|
|
|
3040
3088
|
return holdAfterProvisionRetry(state);
|
|
3041
3089
|
}
|
|
3042
3090
|
var CLAIM_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
3091
|
+
async function endFleetRun(state, run) {
|
|
3092
|
+
const ended = await retrySend(() => releaseRun(claimCalls(state.config, { appId: run.appId, queue: "run" }), run.id, "failed", state.deps.fetchImpl), {
|
|
3093
|
+
now: state.deps.now,
|
|
3094
|
+
sleep: state.deps.sleep
|
|
3095
|
+
});
|
|
3096
|
+
return ended.ok;
|
|
3097
|
+
}
|
|
3043
3098
|
function fleetClaimIds(ids) {
|
|
3044
3099
|
return ids.filter((id) => CLAIM_ID.test(id));
|
|
3045
3100
|
}
|
|
@@ -3071,6 +3126,17 @@ function fleetPortsOf(state) {
|
|
|
3071
3126
|
});
|
|
3072
3127
|
return attempt.kind === "started" && attempt.provisionFailed !== true;
|
|
3073
3128
|
},
|
|
3129
|
+
startRun: async (answer) => {
|
|
3130
|
+
if (runCommandOf(state.config, state.deps.agents) === void 0) {
|
|
3131
|
+
reportRepeating(state, "the run command", "takes no run of a schedule automation: the agent that runner.commands.implement starts has no command for a run \xB7 set runner.commands.run in the config file");
|
|
3132
|
+
await endFleetRun(state, { id: answer.run.id, appId: answer.appId });
|
|
3133
|
+
return false;
|
|
3134
|
+
}
|
|
3135
|
+
reportRepeating(state, "the run command", void 0);
|
|
3136
|
+
const started = await startClaimedRun(state, answer.run, answer.runKey, { workItemId: answer.run.id, appId: answer.appId, organizationId: answer.organizationId, size: "small" });
|
|
3137
|
+
return started === "started";
|
|
3138
|
+
},
|
|
3139
|
+
endRun: (run) => endFleetRun(state, run),
|
|
3074
3140
|
release: async (claim) => {
|
|
3075
3141
|
const released = await retrySend(() => releaseLease(claimCalls(state.config, { appId: claim.appId }), claim.workItemId, void 0, {}, state.deps.fetchImpl), {
|
|
3076
3142
|
now: state.deps.now,
|
|
@@ -3326,7 +3392,6 @@ async function tryClaimAndStartRun(state) {
|
|
|
3326
3392
|
}
|
|
3327
3393
|
const { isolation } = decision;
|
|
3328
3394
|
reportRepeating(state, "the run command", void 0);
|
|
3329
|
-
const log = logOf(state);
|
|
3330
3395
|
const hostKey = await loadHostKey(state.config.configPath);
|
|
3331
3396
|
const cliVersion = state.deps.cliVersion ?? resolveVersion();
|
|
3332
3397
|
const claim = await retrySend(() => claimRun({ config: state.config, isolation, cliVersion, ...hostKey === void 0 ? {} : { hostKey: hostKey.hostKey, signer: hostKey.signer }, fetchImpl: state.deps.fetchImpl }), {
|
|
@@ -3350,7 +3415,10 @@ async function tryClaimAndStartRun(state) {
|
|
|
3350
3415
|
reportRepeating(state, "the run claim", answer.reason);
|
|
3351
3416
|
return "stop";
|
|
3352
3417
|
}
|
|
3353
|
-
|
|
3418
|
+
return await startClaimedRun(state, answer.run, answer.runKey) === "none" ? "none" : "started";
|
|
3419
|
+
}
|
|
3420
|
+
async function startClaimedRun(state, run, runKey, fleet) {
|
|
3421
|
+
const log = logOf(state);
|
|
3354
3422
|
if (claimIsAlreadyRunning(state, run.id)) {
|
|
3355
3423
|
log.line(`#${run.id} skipped: the run is already running here`);
|
|
3356
3424
|
return "none";
|
|
@@ -3358,30 +3426,40 @@ async function tryClaimAndStartRun(state) {
|
|
|
3358
3426
|
const branch = `outerlayer/run-${run.id.slice(0, 8)}`;
|
|
3359
3427
|
const item = { id: run.id, number: run.id, trackerKey: run.id, specRepository: run.repository };
|
|
3360
3428
|
const tag = itemTag({ item: run.id, claimId: run.id });
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
} catch (err) {
|
|
3429
|
+
const starting = startJob(
|
|
3430
|
+
state,
|
|
3431
|
+
item,
|
|
3432
|
+
"run",
|
|
3433
|
+
run.id,
|
|
3434
|
+
runKey,
|
|
3435
|
+
branch,
|
|
3436
|
+
void 0,
|
|
3437
|
+
[{ repository: run.repository.toLowerCase(), branch, primary: true }],
|
|
3438
|
+
fleet,
|
|
3439
|
+
void 0,
|
|
3440
|
+
void 0,
|
|
3441
|
+
void 0,
|
|
3442
|
+
{ instructions: run.instructions, issuesLeft: run.issuesLeft, timeLimitSeconds: run.timeLimitSeconds }
|
|
3443
|
+
);
|
|
3444
|
+
const endStranded = async (err) => {
|
|
3378
3445
|
const stranded = [...state.jobs.values()].find((active) => active.job.claimId === run.id);
|
|
3379
|
-
if (stranded === void 0)
|
|
3446
|
+
if (stranded === void 0) return false;
|
|
3380
3447
|
const reason = `provision failed: ${describeCallFailure(err)}`;
|
|
3381
3448
|
log.error(`${tag} ${reason} \xB7 ending job as failed`);
|
|
3382
3449
|
await endJob(state, stranded, "failed", { stage: "provision", reason });
|
|
3450
|
+
return true;
|
|
3451
|
+
};
|
|
3452
|
+
if (provisionsBesideOthers(state.config)) {
|
|
3453
|
+
endWhenStartFails(starting, endStranded, (line) => log.error(`${tag} ${line}`));
|
|
3454
|
+
return "started";
|
|
3383
3455
|
}
|
|
3384
|
-
|
|
3456
|
+
try {
|
|
3457
|
+
await starting;
|
|
3458
|
+
} catch (err) {
|
|
3459
|
+
if (!await endStranded(err)) throw err;
|
|
3460
|
+
return "provision_failed";
|
|
3461
|
+
}
|
|
3462
|
+
return [...state.jobs.values()].some((active) => active.job.claimId === run.id) ? "started" : "provision_failed";
|
|
3385
3463
|
}
|
|
3386
3464
|
var CLAIM_REFUSAL_CODES = new Set(
|
|
3387
3465
|
"pull_request_from_fork pull_request_on_default_branch pull_request_ambiguous pull_request_repository_not_connected repository_not_reachable branch_claimed_elsewhere".split(" ")
|
|
@@ -3751,7 +3829,12 @@ async function startJob(state, item, queue, claimId, itemKey, branch, identity,
|
|
|
3751
3829
|
await endOnManagedRefusal(state, active, held.refused, { what: held.what, was: "was" });
|
|
3752
3830
|
return;
|
|
3753
3831
|
}
|
|
3754
|
-
const settings = await fetchManagedBuildSettings(claimCalls(state.config, active.job), claimItem(state.config, active.job), {
|
|
3832
|
+
const settings = await fetchManagedBuildSettings(claimCalls(state.config, active.job), claimItem(state.config, active.job), {
|
|
3833
|
+
run: active.job.queue === "run",
|
|
3834
|
+
fetchImpl: state.deps.fetchImpl,
|
|
3835
|
+
now: state.deps.now,
|
|
3836
|
+
sleep: state.deps.sleep
|
|
3837
|
+
});
|
|
3755
3838
|
if (active.ending) return;
|
|
3756
3839
|
if (!settings.ok) {
|
|
3757
3840
|
await endOnManagedRefusal(state, active, settings, { what: "settings", was: "were" });
|
|
@@ -4253,6 +4336,7 @@ async function holdManagedKeys(state, job, dirPath, options) {
|
|
|
4253
4336
|
const labelOf = (provider) => PROVIDERS[provider]?.label ?? provider;
|
|
4254
4337
|
const ask = (provider) => fetchManagedModelKey(claimCalls(state.config, job), claimItem(state.config, job), {
|
|
4255
4338
|
provider,
|
|
4339
|
+
run: job.queue === "run",
|
|
4256
4340
|
fetchImpl: state.deps.fetchImpl,
|
|
4257
4341
|
now: state.deps.now,
|
|
4258
4342
|
sleep: state.deps.sleep,
|
|
@@ -5091,7 +5175,7 @@ async function startRunner(configPath, deps, startup) {
|
|
|
5091
5175
|
check: update.check ? () => update.check(configPath) : async () => {
|
|
5092
5176
|
const held = runnerAgents(deps.agents).flatMap((agent) => heldAgentCredential(agent.descriptor.id) ?? []);
|
|
5093
5177
|
const env = { ...process.env, ...Object.fromEntries(held.map((credential) => [credential.variable, credential.value])) };
|
|
5094
|
-
return (await import('./check-
|
|
5178
|
+
return (await import('./check-HABHY27Y.js')).runRunnerCheck(configPath, { fetchImpl: deps.fetchImpl, env });
|
|
5095
5179
|
},
|
|
5096
5180
|
now: () => (deps.now ?? (() => /* @__PURE__ */ new Date()))().getTime(),
|
|
5097
5181
|
log
|
|
@@ -4,7 +4,7 @@ import { installStarterPack } from './chunk-ZMXG7DQ5.js';
|
|
|
4
4
|
import { runEmit } from './chunk-DPS4OOL5.js';
|
|
5
5
|
import { addStdioMcpEntryIfAbsent, addDocsMcpEntryIfAbsent, DOCS_MCP_SERVER_NAME } from './chunk-WHXF2MLU.js';
|
|
6
6
|
import { listWithAnd } from './chunk-7O37CF6M.js';
|
|
7
|
-
import {
|
|
7
|
+
import { mcpFiles, AGENTS_MD_LAYOUT, declareAgentsMdLayout, linkAgentSkills, describeSkillsLink, isAgentsMdLayout, holdsTodaysLayoutSources, discoverOuterlayerPaths } from './chunk-IEVG36GC.js';
|
|
8
8
|
import { C } from './chunk-2AM6Z5BP.js';
|
|
9
9
|
import { resolveGitCommonDir, defaultGitRunner } from './chunk-25SFFAJ5.js';
|
|
10
10
|
import { cliInvocation } from './chunk-FZKNTIOJ.js';
|
|
@@ -18,10 +18,13 @@ import { join, dirname } from 'path';
|
|
|
18
18
|
|
|
19
19
|
createRequire(import.meta.url);
|
|
20
20
|
var CONFIG_PATH = ".outerlayer/config.json";
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
function newConfig(agent, layout) {
|
|
22
|
+
const doc = { targets: [agent] };
|
|
23
|
+
if (layout !== void 0) doc.layout = layout;
|
|
24
|
+
if (agent !== LEGACY_AGENT) doc.agent = agent;
|
|
25
|
+
return `${JSON.stringify(doc, null, 2)}
|
|
24
26
|
`;
|
|
27
|
+
}
|
|
25
28
|
var starterAgentsMd = (agents) => `# Agent instructions
|
|
26
29
|
|
|
27
30
|
Write here what an agent needs to work in this repository: how to build and test it, the rules it follows, and what to check before it opens a pull request.
|
|
@@ -80,6 +83,7 @@ function keepHandWritten(createdSources) {
|
|
|
80
83
|
}
|
|
81
84
|
function runAgentSetup(opts) {
|
|
82
85
|
const agents = opts.agents ?? defaultAgents();
|
|
86
|
+
const configAgent = opts.configAgent ?? LEGACY_AGENT;
|
|
83
87
|
let repoRoot;
|
|
84
88
|
try {
|
|
85
89
|
repoRoot = gitTopLevel(opts.cwd);
|
|
@@ -90,7 +94,7 @@ function runAgentSetup(opts) {
|
|
|
90
94
|
} catch (err) {
|
|
91
95
|
return failed(errorMessage(err), /* @__PURE__ */ new Set(), []);
|
|
92
96
|
}
|
|
93
|
-
if (!inTodaysLayout(repoRoot)) return runAgentsMdSetup(repoRoot, opts.skillsLink !== false, agents);
|
|
97
|
+
if (!inTodaysLayout(repoRoot)) return runAgentsMdSetup(repoRoot, opts.skillsLink !== false, agents, configAgent);
|
|
94
98
|
const written = /* @__PURE__ */ new Set();
|
|
95
99
|
const kept = [];
|
|
96
100
|
const problems = [];
|
|
@@ -108,7 +112,7 @@ function runAgentSetup(opts) {
|
|
|
108
112
|
kept.push(CONFIG_PATH);
|
|
109
113
|
} else {
|
|
110
114
|
mkdirSync(dirname(join(repoRoot, CONFIG_PATH)), { recursive: true });
|
|
111
|
-
writeFileSync(join(repoRoot, CONFIG_PATH),
|
|
115
|
+
writeFileSync(join(repoRoot, CONFIG_PATH), newConfig(configAgent, void 0));
|
|
112
116
|
written.add(CONFIG_PATH);
|
|
113
117
|
}
|
|
114
118
|
} catch (err) {
|
|
@@ -156,7 +160,7 @@ function runAgentSetup(opts) {
|
|
|
156
160
|
kept: keptPaths
|
|
157
161
|
};
|
|
158
162
|
}
|
|
159
|
-
function runAgentsMdSetup(repoRoot, skillsLink, agents) {
|
|
163
|
+
function runAgentsMdSetup(repoRoot, skillsLink, agents, configAgent) {
|
|
160
164
|
const written = /* @__PURE__ */ new Set();
|
|
161
165
|
const kept = [];
|
|
162
166
|
const problems = [];
|
|
@@ -177,7 +181,7 @@ function runAgentsMdSetup(repoRoot, skillsLink, agents) {
|
|
|
177
181
|
kept.push(CONFIG_PATH);
|
|
178
182
|
} else {
|
|
179
183
|
mkdirSync(dirname(join(repoRoot, CONFIG_PATH)), { recursive: true });
|
|
180
|
-
writeFileSync(join(repoRoot, CONFIG_PATH),
|
|
184
|
+
writeFileSync(join(repoRoot, CONFIG_PATH), newConfig(configAgent, AGENTS_MD_LAYOUT));
|
|
181
185
|
written.add(CONFIG_PATH);
|
|
182
186
|
}
|
|
183
187
|
declareAgentsMdLayout(repoRoot);
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
3
|
import { machineSkillsState, staleAgentSkills } from './chunk-B5ENFQHF.js';
|
|
4
|
-
import { sanitizeTerminal } from './chunk-V3NMSDOC.js';
|
|
5
4
|
import { isAgentsMdLayout } from './chunk-IEVG36GC.js';
|
|
6
|
-
import { resolveGatewayCredentials, defaultFetch } from './chunk-E7HPIXAM.js';
|
|
7
|
-
import { versionAtLeast } from './chunk-LIPSGE6C.js';
|
|
8
|
-
import { findGitDirs } from './chunk-BJ3KTMDH.js';
|
|
9
5
|
import { cliInvocation } from './chunk-FZKNTIOJ.js';
|
|
10
6
|
import { hasSymlinkComponent } from './chunk-DZOOVU5A.js';
|
|
11
7
|
import { skillDir, emitTree, targetIds, classifyTree, emitBuilders, AGENTS_SKILLS_BASE, defaultAgents, namesCore, MACHINE_SKILL_PATH, skillBases, isMaintainedCopy, contextAgents, loadTemplateFiles, splitRawFile } from './chunk-V3ZIIURQ.js';
|
|
12
8
|
import { MAINTAINED_SKILLS } from './chunk-VSBG7MMU.js';
|
|
13
|
-
import { execFileSync } from 'child_process';
|
|
14
9
|
import { existsSync, readFileSync, writeFileSync, realpathSync, readdirSync } from 'fs';
|
|
15
10
|
import { join, dirname, posix, basename, isAbsolute, relative } from 'path';
|
|
11
|
+
import { execFileSync } from 'child_process';
|
|
16
12
|
|
|
17
13
|
createRequire(import.meta.url);
|
|
18
14
|
var PROSE_FILE = /\.mdc?$/;
|
|
@@ -22,7 +18,7 @@ var RELATIVE_NOTE = ", relative to this skill's folder";
|
|
|
22
18
|
var escape = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
23
19
|
function withMachinePaths(text, fileDir, skills) {
|
|
24
20
|
let out = text;
|
|
25
|
-
const
|
|
21
|
+
const named = [];
|
|
26
22
|
for (const skill of skills) {
|
|
27
23
|
const spellings = /* @__PURE__ */ new Set();
|
|
28
24
|
for (const base of skillFolders()) {
|
|
@@ -34,10 +30,10 @@ function withMachinePaths(text, fileDir, skills) {
|
|
|
34
30
|
const alternatives = [...spellings].map(escape);
|
|
35
31
|
const pattern = new RegExp(`(?<![\\w~./-])(?:${alternatives.join("|")})/([\\w./-]*)(?:${escape(RELATIVE_NOTE)},?)?`, "g");
|
|
36
32
|
const next = out.replace(pattern, (_match, rest) => `${MACHINE_SKILL_PATH}/${skill}/${rest}`);
|
|
37
|
-
if (next !== out)
|
|
33
|
+
if (next !== out) named.push(skill);
|
|
38
34
|
out = next;
|
|
39
35
|
}
|
|
40
|
-
return { text: out, skills:
|
|
36
|
+
return { text: out, skills: named };
|
|
41
37
|
}
|
|
42
38
|
function filesUnder(root, rel) {
|
|
43
39
|
const found = [];
|
|
@@ -71,8 +67,6 @@ function maintainedReferenceRewrites(root, removing) {
|
|
|
71
67
|
function applyReferenceRewrites(root, rewrites) {
|
|
72
68
|
for (const rewrite of rewrites) writeFileSync(join(root, rewrite.path), rewrite.text);
|
|
73
69
|
}
|
|
74
|
-
|
|
75
|
-
// src/build-skill.ts
|
|
76
70
|
var BUILD_PHASES = ["Intake", "Criteria", "Implement", "Pull request", "Evidence"];
|
|
77
71
|
var SPEC_STEPS = ["Scope", "Draft", "Verdict", "Size", "Reader pass", "Checkpoint", "File", "Build"];
|
|
78
72
|
var MACHINE_CORE = `${MACHINE_SKILL_PATH}/outerlayer-build/SKILL.md`;
|
|
@@ -316,80 +310,4 @@ function checkIgnoredSkillFolders(repoRoot, agents = defaultAgents()) {
|
|
|
316
310
|
}));
|
|
317
311
|
}
|
|
318
312
|
|
|
319
|
-
|
|
320
|
-
var FIRST_VERSION_WITH_MACHINE_SKILLS = "0.27.0";
|
|
321
|
-
var HOSTS_TIMEOUT_MS = 1e4;
|
|
322
|
-
function shortVersion(host) {
|
|
323
|
-
return host.cliVersion === null ? "no version" : /\d+\.\d+\.\d+\S*/.exec(host.cliVersion)?.[0] ?? host.cliVersion;
|
|
324
|
-
}
|
|
325
|
-
function judgeFleet(hosts) {
|
|
326
|
-
const old = (h) => !versionAtLeast(h.cliVersion ?? "", FIRST_VERSION_WITH_MACHINE_SKILLS);
|
|
327
|
-
const staleBehind = hosts.filter((h) => h.stale && old(h));
|
|
328
|
-
const behind = hosts.filter((h) => !h.stale && old(h));
|
|
329
|
-
if (behind.length > 0) return { state: "behind", behind, staleBehind };
|
|
330
|
-
return { state: "ready", current: hosts.filter((h) => !old(h)), staleBehind };
|
|
331
|
-
}
|
|
332
|
-
function parseHosts(body) {
|
|
333
|
-
const data = body?.data;
|
|
334
|
-
if (!Array.isArray(data)) return void 0;
|
|
335
|
-
const hosts = [];
|
|
336
|
-
for (const row of data) {
|
|
337
|
-
if (typeof row?.host !== "string") return void 0;
|
|
338
|
-
hosts.push({
|
|
339
|
-
host: row.host,
|
|
340
|
-
cliVersion: typeof row.cliVersion === "string" ? row.cliVersion : null,
|
|
341
|
-
lastHeartbeatAt: typeof row.lastHeartbeatAt === "string" ? row.lastHeartbeatAt : null,
|
|
342
|
-
stale: row.status === "stale"
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
return hosts;
|
|
346
|
-
}
|
|
347
|
-
async function fleetReadiness(opts = {}) {
|
|
348
|
-
const resolved = resolveGatewayCredentials(opts);
|
|
349
|
-
if (!resolved.ok) return { state: "unknown", reason: sanitizeTerminal(resolved.message) };
|
|
350
|
-
const fetchImpl = opts.fetchImpl ?? defaultFetch;
|
|
351
|
-
let status;
|
|
352
|
-
let body;
|
|
353
|
-
try {
|
|
354
|
-
const res = await fetchImpl(`${resolved.url.replace(/\/+$/, "")}/v1/hosts`, {
|
|
355
|
-
method: "GET",
|
|
356
|
-
headers: { authorization: `Bearer ${resolved.credential}`, "x-outerlayer-app-id": resolved.appId },
|
|
357
|
-
signal: AbortSignal.timeout(HOSTS_TIMEOUT_MS)
|
|
358
|
-
});
|
|
359
|
-
status = res.status;
|
|
360
|
-
body = await res.json().catch(() => void 0);
|
|
361
|
-
} catch (err) {
|
|
362
|
-
return { state: "unknown", reason: `the gateway did not answer: ${sanitizeTerminal(err instanceof Error ? err.message : String(err))}` };
|
|
363
|
-
}
|
|
364
|
-
if (status === 401) return { state: "unknown", reason: `the gateway refused the credential (HTTP 401); run \`${cliInvocation()} login\`` };
|
|
365
|
-
if (status === 403) return { state: "unknown", reason: "the credential cannot list the factory's runner hosts (HTTP 403); it needs the hosts.read permission" };
|
|
366
|
-
if (status >= 300) return { state: "unknown", reason: `the gateway did not list the runner hosts (HTTP ${status})` };
|
|
367
|
-
const hosts = parseHosts(body);
|
|
368
|
-
if (hosts === void 0) return { state: "unknown", reason: "the gateway's list of runner hosts was not in the expected shape" };
|
|
369
|
-
return judgeFleet(hosts);
|
|
370
|
-
}
|
|
371
|
-
var named = (hosts) => hosts.map((h) => `${sanitizeTerminal(h.host)} (${sanitizeTerminal(shortVersion(h))})`).join(", ");
|
|
372
|
-
var lastSeen = (hosts) => hosts.map((h) => `${sanitizeTerminal(h.host)} (${sanitizeTerminal(shortVersion(h))}, last heartbeat ${h.lastHeartbeatAt?.slice(0, 10) ?? "never"})`).join(", ");
|
|
373
|
-
function describeFleet(fleet) {
|
|
374
|
-
const minimum = FIRST_VERSION_WITH_MACHINE_SKILLS;
|
|
375
|
-
if (fleet.state === "unknown") return [`The runner hosts were not checked: ${fleet.reason}.`];
|
|
376
|
-
const lines = fleet.state === "behind" ? [`These runner hosts run a CLI older than ${minimum}: ${named(fleet.behind)}. Do not commit the removal until each one updates.`] : fleet.current.length === 0 ? ["No runner host has reported to this factory."] : [`Every runner host that is sending heartbeats runs ${minimum} or later: ${named(fleet.current)}.`];
|
|
377
|
-
if (fleet.staleBehind.length > 0) {
|
|
378
|
-
lines.push(`These runner hosts stopped sending heartbeats on an older CLI: ${lastSeen(fleet.staleBehind)}. Update each one before it builds again.`);
|
|
379
|
-
}
|
|
380
|
-
return lines;
|
|
381
|
-
}
|
|
382
|
-
var CHECK_NAME = "Runner hosts for the maintained skills";
|
|
383
|
-
async function fleetCheck(opts = {}) {
|
|
384
|
-
const dirs = findGitDirs(opts.cwd ?? process.cwd());
|
|
385
|
-
if (dirs === void 0 || checkCommittedMaintainedSkills(dirs.repoRoot).length === 0) return [];
|
|
386
|
-
const fleet = await fleetReadiness(opts);
|
|
387
|
-
const detail = describeFleet(fleet).join(" ");
|
|
388
|
-
if (fleet.state === "unknown") return [{ name: CHECK_NAME, status: "skipped", detail }];
|
|
389
|
-
if (fleet.state === "behind") {
|
|
390
|
-
return [{ name: CHECK_NAME, status: "warn", detail, fix: `Wait for each host to update, or run \`${cliInvocation()} runner status\` on it to see why it has not.` }];
|
|
391
|
-
}
|
|
392
|
-
return [{ name: CHECK_NAME, status: "pass", detail }];
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
export { applyReferenceRewrites, checkBuildSkill, checkCommittedMaintainedSkills, checkIgnoredSkillFolders, checkMachineSkills, checkMaintainedReferences, checkSpecSkill, committedMaintainedFolders, describeFleet, fleetCheck, fleetReadiness, maintainedReferenceRewrites, skillsFolders };
|
|
313
|
+
export { applyReferenceRewrites, checkBuildSkill, checkCommittedMaintainedSkills, checkIgnoredSkillFolders, checkMachineSkills, checkMaintainedReferences, checkSpecSkill, committedMaintainedFolders, ignoreRuleFor, maintainedReferenceRewrites, skillsFolders };
|