@proagentstore/cli 0.4.140 → 0.4.142
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.
|
@@ -72,6 +72,16 @@ export function parkSnapshot(workDir, runId) {
|
|
|
72
72
|
git(workDir, ["update-ref", ref, snapshot]);
|
|
73
73
|
return { snapshot, files: before.length, clean: changes(workDir).length === 0, ref };
|
|
74
74
|
}
|
|
75
|
+
/** The paths `git apply --check` names when it refuses — "patch failed: <path>:<line>", "<path>: does not match index", … */
|
|
76
|
+
export function applyConflicts(stderr) {
|
|
77
|
+
const out = new Set();
|
|
78
|
+
for (const line of stderr.split("\n")) {
|
|
79
|
+
const m = line.match(/^error: patch failed: (.+):\d+$/) ?? line.match(/^error: (.+): (?:does not match index|already exists in working directory|does not exist in index|No such file or directory)$/);
|
|
80
|
+
if (m?.[1])
|
|
81
|
+
out.add(m[1]);
|
|
82
|
+
}
|
|
83
|
+
return [...out];
|
|
84
|
+
}
|
|
75
85
|
/** Put a parked run's work back by its exact id — only onto a clean tree, only if it applies cleanly. */
|
|
76
86
|
export function parkRestore(workDir, runId, snapshot) {
|
|
77
87
|
checkout(workDir, runId);
|
|
@@ -96,8 +106,9 @@ export function parkRestore(workDir, runId, snapshot) {
|
|
|
96
106
|
try {
|
|
97
107
|
git(workDir, ["apply", "--check"], patch);
|
|
98
108
|
}
|
|
99
|
-
catch {
|
|
100
|
-
|
|
109
|
+
catch (e) {
|
|
110
|
+
const conflicts = applyConflicts(String(e.stderr ?? ""));
|
|
111
|
+
return { restored: false, refused: "the saved work no longer applies cleanly to this checkout (it changed underneath while the run was parked)", conflicts };
|
|
101
112
|
}
|
|
102
113
|
}
|
|
103
114
|
// Untracked files: the stash's third parent. Any that already exists would be refused by git mid-apply.
|
|
@@ -110,7 +121,7 @@ export function parkRestore(workDir, runId, snapshot) {
|
|
|
110
121
|
}
|
|
111
122
|
const clash = untracked.filter((p) => existsSync(join(workDir, p)));
|
|
112
123
|
if (clash.length)
|
|
113
|
-
return { restored: false, refused: `${clash.length} file${clash.length === 1 ? "" : "s"} the saved work would create already exist${clash.length === 1 ? "s" : ""}
|
|
124
|
+
return { restored: false, refused: `${clash.length} file${clash.length === 1 ? "" : "s"} the saved work would create already exist${clash.length === 1 ? "s" : ""}`, conflicts: clash };
|
|
114
125
|
git(workDir, ["stash", "apply", snapshot]);
|
|
115
126
|
git(workDir, ["update-ref", "-d", ref, snapshot]);
|
|
116
127
|
return { restored: true };
|
|
@@ -116,6 +116,18 @@ export function parseApplyEnvelope(raw) {
|
|
|
116
116
|
if (Object.values(limits).some((v) => !v))
|
|
117
117
|
throw bad("limits are out of range");
|
|
118
118
|
const opt = (v) => (typeof v === "string" && v.trim() ? v.trim().slice(0, 300) : undefined);
|
|
119
|
+
// #1079: the owner's kept answers, within a resume's bounds — never an instruction. One over a bound is
|
|
120
|
+
// dropped, never cut: a shortened answer would be grounding the owner never wrote.
|
|
121
|
+
const ownerAnswers = [];
|
|
122
|
+
for (const a of Array.isArray(o.ownerAnswers) ? o.ownerAnswers : []) {
|
|
123
|
+
if (ownerAnswers.length >= LOCAL_APPLY_CAPS.answers)
|
|
124
|
+
break;
|
|
125
|
+
const r = (a && typeof a === "object" ? a : {});
|
|
126
|
+
const question = typeof r.question === "string" ? r.question.trim() : "";
|
|
127
|
+
const answer = typeof r.answer === "string" ? r.answer.trim() : "";
|
|
128
|
+
if (question && answer && question.length <= LOCAL_APPLY_CAPS.questionChars && answer.length <= LOCAL_APPLY_CAPS.answerChars)
|
|
129
|
+
ownerAnswers.push({ question, answer });
|
|
130
|
+
}
|
|
119
131
|
return {
|
|
120
132
|
type: LOCAL_APPLY_TASK_TYPE,
|
|
121
133
|
runId: o.runId,
|
|
@@ -132,6 +144,7 @@ export function parseApplyEnvelope(raw) {
|
|
|
132
144
|
artifacts,
|
|
133
145
|
policy: { mode: p.mode, allowDomains, ...(p.mode === "auto_submit" && gateId ? { submitGate: { gateId } } : {}), ...(p.screenshots === false ? { screenshots: false } : {}) },
|
|
134
146
|
limits,
|
|
147
|
+
...(ownerAnswers.length ? { ownerAnswers } : {}),
|
|
135
148
|
};
|
|
136
149
|
}
|
|
137
150
|
/**
|
|
@@ -371,6 +384,9 @@ export class LocalApplyRuntime {
|
|
|
371
384
|
throw new Blocked("artifact_changed", [`${v.error} Re-run tailoring for this application.`]);
|
|
372
385
|
blocks.push({ label: a.kind, text: v.text });
|
|
373
386
|
}
|
|
387
|
+
// #1079: answers the owner already gave this application, as a source — the same shape a resume's answers take.
|
|
388
|
+
if (e.ownerAnswers?.length)
|
|
389
|
+
blocks.push({ label: "owner answers", text: e.ownerAnswers.map((a) => `Q: ${a.question}\nA: ${a.answer}`).join("\n\n") });
|
|
374
390
|
run.grounding = blocks.map((b) => b.text);
|
|
375
391
|
const bridgeScript = this.deps.bridgeScript ?? fileURLToPath(new URL("../local-browser/bridge-stdio.js", import.meta.url));
|
|
376
392
|
const spec = buildApplyEngineSpec(e, applyPrompt(e, blocks), { command: process.execPath, args: [bridgeScript], env: { [BRIDGE_ENV.url]: selfUrl, [BRIDGE_ENV.runId]: e.runId, [BRIDGE_ENV.token]: run.token } }, join(run.dir, "mcp.json"));
|
|
@@ -174,7 +174,9 @@ export class LocalBrowserRuntime {
|
|
|
174
174
|
return { runId: same.envelope.runId, taskId: same.envelope.runId, status: same.state, existing: true };
|
|
175
175
|
if (this.runs.has(envelope.runId))
|
|
176
176
|
throw new RunnerInputError(`Run ${envelope.runId} already exists with another requestId`, 409);
|
|
177
|
-
|
|
177
|
+
// A PAUSED run waits on a person and holds no slot (#1079) — the cloud counts the same way. Its own
|
|
178
|
+
// resume is the owner's act and is not refused, so the cap bounds STARTS; research is read-only.
|
|
179
|
+
const active = [...this.runs.values()].filter((r) => r.envelope.instanceId === envelope.instanceId && r.state === "running").length;
|
|
178
180
|
if (active >= envelope.limits.maxConcurrent)
|
|
179
181
|
throw new RunnerInputError(`This machine is already running ${active} research run(s) for this agent (limit ${envelope.limits.maxConcurrent}).`, 409);
|
|
180
182
|
const selfUrl = this.deps.selfUrl();
|