@ordewell/core 0.13.0 → 0.13.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/index.js +36 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -30396,6 +30396,18 @@ function renderCarriedOver(from, work) {
|
|
|
30396
30396
|
const body = work?.outcome === "fallback" ? `${moved} The work its previous attempt on ${from} left could not be applied on top of the integration tip, so your working tree starts fresh at the integration tip. ${keptWorkLines(work.preserved, "the previous attempt's work")} It may be unfinished.` : `${moved} The files in your working tree come from a previous attempt on ${from} and may be unfinished: check what is already there before building on it. That attempt's session is not continued.`;
|
|
30397
30397
|
return ["## Work carried over", "", body].join("\n");
|
|
30398
30398
|
}
|
|
30399
|
+
function renderLoopVerdict(loop, round) {
|
|
30400
|
+
const ahead = "A `failed` round with rounds left runs the fix, then this check again; a `failed` last round ends the loop, and the tasks after it wait for the user.";
|
|
30401
|
+
const rounds = round === void 0 ? `It runs at most ${loop.maxRounds} rounds. ${ahead}` : round >= loop.maxRounds ? `This is round ${round} of ${loop.maxRounds}, the last: a \`failed\` now ends the loop, and the tasks after it wait for the user.` : `This is round ${round} of ${loop.maxRounds}. ${ahead}`;
|
|
30402
|
+
return [
|
|
30403
|
+
"## You are this loop's check",
|
|
30404
|
+
"",
|
|
30405
|
+
"Ordewell reads your `task_complete` status as this check's verdict. If you confirm any problem, call `task_complete` with status `failed` and put each confirmed problem in `findings`: that starts the fix. Call it with status `done` only when you confirm none; finishing the check is not a pass. Use `blocked` only when you could not do the check: it starts no fix.",
|
|
30406
|
+
"",
|
|
30407
|
+
rounds
|
|
30408
|
+
].join("\n");
|
|
30409
|
+
}
|
|
30410
|
+
var LOOP_VERDICT_REMINDER = "You are this loop's check: your `task_complete` status is its verdict, `failed` when you confirm any problem and `done` only when you confirm none.";
|
|
30399
30411
|
var CHECKPOINT_INSTRUCTION = [
|
|
30400
30412
|
"## Human-in-the-loop checkpoints",
|
|
30401
30413
|
"",
|
|
@@ -30427,6 +30439,7 @@ function composeAugmentedPrompt(task2, allTasks, opts) {
|
|
|
30427
30439
|
if (opts?.skills?.length) blocks.push(renderTaskSkills(opts.skills));
|
|
30428
30440
|
if (opts?.readOnly) blocks.push(READ_ONLY_PATCH_NOTE, READ_ONLY_WEB_NOTE);
|
|
30429
30441
|
if (isHitlTask(task2)) blocks.push(CHECKPOINT_INSTRUCTION);
|
|
30442
|
+
if (task2.type === "ai" && task2.loop) blocks.push(renderLoopVerdict(task2.loop, opts?.loop?.round));
|
|
30430
30443
|
if (blocks.length === 0) return basePrompt;
|
|
30431
30444
|
return `${blocks.join("\n\n")}
|
|
30432
30445
|
|
|
@@ -30436,6 +30449,9 @@ function composeContinuationPrompt(task2, message, opts = {}) {
|
|
|
30436
30449
|
const reminder = [
|
|
30437
30450
|
opts.ops ? "(Ordewell) You are continuing this task in the same session, in the same checkout. What your earlier attempt did outside the repository was not undone: check what already exists before acting again." : "(Ordewell) You are continuing this task in the same session. Check the working tree before relying on the files remembered from your earlier attempt."
|
|
30438
30451
|
];
|
|
30452
|
+
if (task2.type === "ai" && task2.loop) {
|
|
30453
|
+
reminder.push(LOOP_VERDICT_REMINDER);
|
|
30454
|
+
}
|
|
30439
30455
|
if (isHitlTask(task2)) {
|
|
30440
30456
|
reminder.push("If you reach a decision that needs human judgment, call the `checkpoint` tool: its result is `continue` or `rejected: <why>`.");
|
|
30441
30457
|
}
|
|
@@ -32306,11 +32322,11 @@ function attemptPrompt(kind, src) {
|
|
|
32306
32322
|
const { task: task2, plan, planMapEnabled } = src;
|
|
32307
32323
|
const between = betweenRounds(task2);
|
|
32308
32324
|
const round = loopRoundOf(task2) + (between ? 1 : 0);
|
|
32309
|
-
const loop = task2.type === "ai" && task2.loop && round > 1
|
|
32325
|
+
const loop = task2.type === "ai" && task2.loop && takesSkills(kind) ? round > 1 ? {
|
|
32310
32326
|
round,
|
|
32311
32327
|
previousHandoff: src.previousHandoff(task2.id),
|
|
32312
32328
|
previousReport: between ? task2.outputSummary?.report : src.previousRound?.round === round - 1 ? src.previousRound.report : void 0
|
|
32313
|
-
} : void 0;
|
|
32329
|
+
} : { round } : void 0;
|
|
32314
32330
|
switch (kind.kind) {
|
|
32315
32331
|
case "continuation": {
|
|
32316
32332
|
const where = kind.work === "readOnly" ? READ_ONLY_CONTINUED_NOTE : continuedWorkNote(src.previousWork);
|
|
@@ -32319,7 +32335,7 @@ function attemptPrompt(kind, src) {
|
|
|
32319
32335
|
${where}`, { ops: kind.work === "ops" });
|
|
32320
32336
|
}
|
|
32321
32337
|
case "repair":
|
|
32322
|
-
return composeAugmentedPrompt({ ...task2, prompt: src.repairPrompt(task2) }, plan, { planMapEnabled });
|
|
32338
|
+
return composeAugmentedPrompt({ ...task2, prompt: src.repairPrompt(task2), loop: void 0 }, plan, { planMapEnabled });
|
|
32323
32339
|
case "ops":
|
|
32324
32340
|
return composeAugmentedPrompt(task2, plan, { planMapEnabled, skills: src.skills, previousAttempt: src.previousAttempt(task2.id), loop });
|
|
32325
32341
|
case "change":
|
|
@@ -47764,9 +47780,7 @@ var CGROUP_V1 = "Boot the host with cgroup v2, by adding `systemd.unified_cgroup
|
|
|
47764
47780
|
async function inspectEngine({ cli, platform = process.platform }) {
|
|
47765
47781
|
const install = INSTALL[platform];
|
|
47766
47782
|
const start = START[platform];
|
|
47767
|
-
if (install === void 0 || start === void 0) {
|
|
47768
|
-
return refused5("platform-unsupported", `Containers have only been proven on Linux and macOS, and this host is ${platform}.`, "Run Ordewell on Linux, or on a Mac with Docker Desktop or Colima.");
|
|
47769
|
-
}
|
|
47783
|
+
if (install === void 0 || start === void 0) return { problems: platformProblems(platform) };
|
|
47770
47784
|
const ask = (args) => cli.call(args, { timeoutMs: ASK_MS });
|
|
47771
47785
|
const context = await ask(["context", "inspect", "--format", "{{.Endpoints.docker.Host}}"]);
|
|
47772
47786
|
if (context.code === -1) return refused5("docker-missing", "The docker command was not found.", install);
|
|
@@ -47790,6 +47804,13 @@ async function inspectEngine({ cli, platform = process.platform }) {
|
|
|
47790
47804
|
if (cgroup === "1") return refused5("cgroup-v1", "This engine uses cgroup v1, and the memory limit can only be proven on cgroup v2.", CGROUP_V1);
|
|
47791
47805
|
return { problems: [], engine: { version: version.stdout.trim(), endpoint, memoryBytes } };
|
|
47792
47806
|
}
|
|
47807
|
+
function platformProblems(platform) {
|
|
47808
|
+
if (INSTALL[platform] !== void 0 && START[platform] !== void 0) return [];
|
|
47809
|
+
return [problem("platform-unsupported", `Containers have only been proven on Linux and macOS, and this host is ${platform}.`, "Run Ordewell on Linux, or on a Mac with Docker Desktop or Colima.")];
|
|
47810
|
+
}
|
|
47811
|
+
function standingProblems(raw, platform = process.platform) {
|
|
47812
|
+
return [...platformProblems(platform), ...readSetting(raw).problems];
|
|
47813
|
+
}
|
|
47793
47814
|
var CONTAINER_ASSUMPTIONS = [
|
|
47794
47815
|
"The engine behind a unix:// socket is on this machine: a socket forwarded from elsewhere looks the same.",
|
|
47795
47816
|
"Containers on an engine share one kernel, this host's on Linux and the VM's on a Mac. kernel.separate means separate from this host, never from another task: a kernel flaw reaches every task on the engine.",
|
|
@@ -48758,6 +48779,8 @@ var DockerExecutionBackend = class {
|
|
|
48758
48779
|
const agent = request.role === "task";
|
|
48759
48780
|
const runner = agent && containerRunner(request.runner) || null;
|
|
48760
48781
|
if (agent && !runner) throw new Error(`This session runs tasks in containers, and ${request.runner ?? "this runner"} has not been proven in one: assign the task to ${CONTAINER_RUNNER_IDS.join(", ")}.`);
|
|
48782
|
+
const standing = this.standing();
|
|
48783
|
+
if (standing.length > 0) throw new Error(cannotStart(describeProblems(standing)));
|
|
48761
48784
|
if (spec.task) await this.collect(spec.task.id).catch((err) => {
|
|
48762
48785
|
if (err instanceof KeptWorkError) throw err;
|
|
48763
48786
|
});
|
|
@@ -48792,11 +48815,14 @@ var DockerExecutionBackend = class {
|
|
|
48792
48815
|
async preflight(runner, model) {
|
|
48793
48816
|
const setupCommand = this.options.setupCommand?.();
|
|
48794
48817
|
const { problems, settings } = await inspectReadiness(this.options.settings, { cli: this.cli, broker: this.broker, ...this.options.platform ? { platform: this.options.platform } : {}, agent: runner !== null, ...runner ? { runner } : {}, ...setupCommand ? { setupCommand } : {} });
|
|
48795
|
-
if (!settings) throw new Error(
|
|
48818
|
+
if (!settings) throw new Error(cannotStart(describeProblems(problems)));
|
|
48796
48819
|
const refusal4 = runner && settings.login.kind === "broker" ? brokerRefusal(runner, model) : null;
|
|
48797
|
-
if (refusal4) throw new Error(
|
|
48820
|
+
if (refusal4) throw new Error(cannotStart(refusal4));
|
|
48798
48821
|
return settings;
|
|
48799
48822
|
}
|
|
48823
|
+
standing() {
|
|
48824
|
+
return standingProblems(this.options.settings, this.options.platform);
|
|
48825
|
+
}
|
|
48800
48826
|
/**
|
|
48801
48827
|
* What a container is seeded from. A script with no worktree of its own runs
|
|
48802
48828
|
* where a script always does, at the workspace root (ADR-0035), so it gets what
|
|
@@ -49219,7 +49245,7 @@ var DockerExecutionBackend = class {
|
|
|
49219
49245
|
if (how.keep && !box.landsNothing) await this.bringBack(box).catch((err) => this.options.tell("warn", errorText3(err)));
|
|
49220
49246
|
if (this.boxes.get(taskId) === box) this.boxes.delete(taskId);
|
|
49221
49247
|
}
|
|
49222
|
-
if (!how.keep) {
|
|
49248
|
+
if (!how.keep && this.standing().length === 0) {
|
|
49223
49249
|
await this.dropVolume(`ordewell-task-${this.taskKey(taskId)}`);
|
|
49224
49250
|
await this.dropVolume(this.heldVolume(taskId));
|
|
49225
49251
|
}
|
|
@@ -49248,6 +49274,7 @@ var DockerExecutionBackend = class {
|
|
|
49248
49274
|
await reclaimTree(this.tree(), this.cli, "refused" in settings ? null : settings, (text4) => this.options.tell("warn", text4));
|
|
49249
49275
|
}
|
|
49250
49276
|
};
|
|
49277
|
+
var cannotStart = (why) => `This session runs tasks in containers, and this task cannot start in one. ${why}`;
|
|
49251
49278
|
function heldBack(taskId, why) {
|
|
49252
49279
|
return `The work of task ${taskId} stays in its container's volume: ${why.replace(/\.$/, "")}. Nothing starts over it until you retry the task, which gives that work up.`;
|
|
49253
49280
|
}
|