@proagentstore/cli 0.4.141 → 0.4.143
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.
|
@@ -262,9 +262,11 @@ export function parseLocalApplyResult(raw) {
|
|
|
262
262
|
const gateId = str(s.gateId, 100);
|
|
263
263
|
if (mode !== "auto_submit")
|
|
264
264
|
return { error: "a submitted outcome requires a run in auto_submit mode" };
|
|
265
|
-
if (!url || !isHttpUrl(url) || !at || Number.isNaN(Date.parse(at)) || !gateId)
|
|
265
|
+
if (!url || !isHttpUrl(url) || !traceUrl(url) || !at || Number.isNaN(Date.parse(at)) || !gateId)
|
|
266
266
|
return { error: "a submitted outcome needs the confirmed url, its time and the gateId" };
|
|
267
|
-
|
|
267
|
+
// A page URL kept as a fact keeps origin and path only, as a trace's does (#1069): a confirmation
|
|
268
|
+
// page's query can carry session or application tokens, and the receipt is the page, not its query.
|
|
269
|
+
out.submitted = { url: traceUrl(url), at, gateId };
|
|
268
270
|
out.submitAttempted = true;
|
|
269
271
|
}
|
|
270
272
|
// #975 — accepted ONLY as the closed vocabulary it declares. A runner that sends prose here gets
|
|
@@ -296,10 +298,10 @@ export function parseLocalApplyResult(raw) {
|
|
|
296
298
|
const reason = oneOf(LOCAL_APPLY_UNAVAILABLE_REASONS, evidence.reason);
|
|
297
299
|
const url = str(evidence.url, 2000);
|
|
298
300
|
const observedAt = str(evidence.observedAt, 40);
|
|
299
|
-
if (!reason || !url || !isHttpUrl(url) || !observedAt || Number.isNaN(Date.parse(observedAt)) || evidence.source !== "page_notice") {
|
|
301
|
+
if (!reason || !url || !isHttpUrl(url) || !traceUrl(url) || !observedAt || Number.isNaN(Date.parse(observedAt)) || evidence.source !== "page_notice") {
|
|
300
302
|
return { error: "a job_unavailable result needs runner-verified unavailable evidence (reason, url, observedAt, source)" };
|
|
301
303
|
}
|
|
302
|
-
out.unavailable = { reason, url, observedAt, source: "page_notice" };
|
|
304
|
+
out.unavailable = { reason, url: traceUrl(url), observedAt, source: "page_notice" };
|
|
303
305
|
}
|
|
304
306
|
else if (o.unavailable !== undefined)
|
|
305
307
|
return { error: "unavailable evidence is only valid for a job_unavailable result" };
|
|
@@ -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"));
|
|
@@ -122,6 +122,20 @@ export function redactDetail(detail, depth = 0, secrets = []) {
|
|
|
122
122
|
const str = (v, max) => (typeof v === "string" && v.trim() ? v.trim().slice(0, max) : null);
|
|
123
123
|
const isHttpUrl = (v) => /^https?:\/\/[^\s/]+/i.test(v);
|
|
124
124
|
const oneOf = (list, v) => (list.includes(v) ? v : null);
|
|
125
|
+
/**
|
|
126
|
+
* A page URL as a trace may keep it (#1069): origin and path — no query, no fragment, no credentials
|
|
127
|
+
* (`origin` never carries a `user:pass@`). The same rule as the local-apply contract's `traceUrl`;
|
|
128
|
+
* restated here because each vendored contract imports nothing. Empty when it is not an http(s) URL.
|
|
129
|
+
*/
|
|
130
|
+
export function traceUrl(raw) {
|
|
131
|
+
try {
|
|
132
|
+
const u = new URL(raw);
|
|
133
|
+
return u.protocol === "http:" || u.protocol === "https:" ? `${u.origin}${u.pathname}` : "";
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
return "";
|
|
137
|
+
}
|
|
138
|
+
}
|
|
125
139
|
/** A validated event, or null. */
|
|
126
140
|
export function parseLocalBrowserEvent(raw) {
|
|
127
141
|
if (!raw || typeof raw !== "object")
|
|
@@ -132,9 +146,14 @@ export function parseLocalBrowserEvent(raw) {
|
|
|
132
146
|
if (!type || !at || Number.isNaN(Date.parse(at)))
|
|
133
147
|
return null;
|
|
134
148
|
const event = { type, at };
|
|
149
|
+
// Origin and path only (#1069): a research trace keeps where the browser went, never a page's query
|
|
150
|
+
// or fragment — a sign-in page's OAuth state/nonce/PKCE values or a session id ride there.
|
|
135
151
|
const url = str(o.url, 2000);
|
|
136
|
-
if (url && isHttpUrl(url))
|
|
137
|
-
|
|
152
|
+
if (url && isHttpUrl(url)) {
|
|
153
|
+
const kept = traceUrl(url);
|
|
154
|
+
if (kept)
|
|
155
|
+
event.url = kept;
|
|
156
|
+
}
|
|
138
157
|
const domain = str(o.domain, 253);
|
|
139
158
|
if (domain)
|
|
140
159
|
event.domain = domain.toLowerCase();
|
|
@@ -27,7 +27,7 @@ import { RunnerInputError } from "../errors.js";
|
|
|
27
27
|
import { BrowserBridge, domainWithin } from "./bridge.js";
|
|
28
28
|
import { SCOUT_SHOT_CAP, ShotRecorder } from "./replay.js";
|
|
29
29
|
import { BRIDGE_ENV } from "./bridge-stdio.js";
|
|
30
|
-
import { LOCAL_BROWSER_AUTH_MODES, LOCAL_BROWSER_ENGINES, LOCAL_BROWSER_TASK_TYPE, redactDetail, redactFinding, redactSourceFailure, redactText, secretEnvValues, } from "./contract.js";
|
|
30
|
+
import { LOCAL_BROWSER_AUTH_MODES, LOCAL_BROWSER_ENGINES, LOCAL_BROWSER_TASK_TYPE, redactDetail, redactFinding, redactSourceFailure, redactText, secretEnvValues, traceUrl, } from "./contract.js";
|
|
31
31
|
import { bridgeUnused, buildEngineSpec, finalText, missingLogin, observedEngineAuth, researchPrompt, signInHelp } from "./engine.js";
|
|
32
32
|
/**
|
|
33
33
|
* Why the run could not be launched, in words the owner can act on (#944).
|
|
@@ -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();
|
|
@@ -301,9 +303,11 @@ export class LocalBrowserRuntime {
|
|
|
301
303
|
emit(run, ev) {
|
|
302
304
|
if (run.events.length >= MAX_EVENTS)
|
|
303
305
|
return;
|
|
304
|
-
|
|
306
|
+
// Origin and path only, before anything leaves the machine (#1069) — the cloud reduces it again.
|
|
307
|
+
const { detail: raw, url: rawUrl, ...rest } = ev;
|
|
308
|
+
const url = rawUrl ? traceUrl(rawUrl) : "";
|
|
305
309
|
const detail = redactDetail(raw, 0, run.secrets);
|
|
306
|
-
run.events.push({ ...rest, ...(detail && Object.keys(detail).length ? { detail } : {}), at: new Date(this.now()).toISOString(), seq: ++run.seq });
|
|
310
|
+
run.events.push({ ...rest, ...(url ? { url } : {}), ...(detail && Object.keys(detail).length ? { detail } : {}), at: new Date(this.now()).toISOString(), seq: ++run.seq });
|
|
307
311
|
}
|
|
308
312
|
pause(run, reason, detail) {
|
|
309
313
|
if (run.state === "ended" || run.cancelled)
|