@proagentstore/cli 0.4.106 → 0.4.108
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.
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
// The run's objective, delivered verbatim with a turn and attributed to the platform (#1019).
|
|
2
|
+
import { RunnerInputError } from "../errors.js";
|
|
2
3
|
const ORIGIN_KINDS = new Set(["account", "supervisor", "trigger", "unverified"]);
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Bounds on the constraint lines one objective envelope carries (#1019). Mirrored by the cloud
|
|
6
|
+
* (workers/api/src/lib/coding-objective-delivery.ts), which never sends an envelope past them. Nothing is
|
|
7
|
+
* cut to fit: a partial set would have the engine read the objective without a constraint that binds it.
|
|
8
|
+
*/
|
|
9
|
+
export const MAX_OBJECTIVE_CONSTRAINTS = 20;
|
|
10
|
+
export const MAX_OBJECTIVE_CONSTRAINT_CHARS = 500;
|
|
6
11
|
/** A run objective as the cloud sent it, or undefined — narrowed, because any caller can POST here (#1019). */
|
|
7
12
|
export function runObjective(raw) {
|
|
8
13
|
const o = raw;
|
|
@@ -13,10 +18,31 @@ export function runObjective(raw) {
|
|
|
13
18
|
// A label longer than a label is not shortened into a different claim — it is dropped.
|
|
14
19
|
const label = typeof origin?.by === "string" ? origin.by.replace(/\s+/g, " ").trim() : "";
|
|
15
20
|
const by = label.length <= 128 ? label : "";
|
|
16
|
-
|
|
17
|
-
const lines = Array.isArray(o.constraints) ? o.constraints.filter((c) => typeof c === "string" && !!c.trim() && c.length <= MAX_CONSTRAINT_CHARS).slice(0, MAX_CONSTRAINTS) : [];
|
|
21
|
+
const lines = objectiveConstraints(o.constraints);
|
|
18
22
|
return { runId: o.runId, text: o.text, origin: by ? { kind, by } : { kind }, ...(lines.length ? { constraints: lines } : {}) };
|
|
19
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* The constraint lines, whole — or a refusal of the ENVELOPE, before anything runs (#1019). Never filtered or
|
|
26
|
+
* cut: dropping one line would deliver the objective as if that constraint did not bind.
|
|
27
|
+
*/
|
|
28
|
+
function objectiveConstraints(raw) {
|
|
29
|
+
if (raw === undefined)
|
|
30
|
+
return [];
|
|
31
|
+
const refuse = (why) => {
|
|
32
|
+
throw new RunnerInputError(`Run objective refused, nothing was run: its constraints ${why}. A partial set is never delivered.`);
|
|
33
|
+
};
|
|
34
|
+
if (!Array.isArray(raw))
|
|
35
|
+
return refuse("are not a list");
|
|
36
|
+
if (raw.length > MAX_OBJECTIVE_CONSTRAINTS)
|
|
37
|
+
return refuse(`number ${raw.length}, over the ${MAX_OBJECTIVE_CONSTRAINTS} one envelope carries`);
|
|
38
|
+
for (const c of raw) {
|
|
39
|
+
if (typeof c !== "string" || !c.trim())
|
|
40
|
+
return refuse("include an entry that is not a constraint line");
|
|
41
|
+
if (c.length > MAX_OBJECTIVE_CONSTRAINT_CHARS)
|
|
42
|
+
return refuse(`include a ${c.length}-character line, over ${MAX_OBJECTIVE_CONSTRAINT_CHARS}`);
|
|
43
|
+
}
|
|
44
|
+
return raw;
|
|
45
|
+
}
|
|
20
46
|
/** The attribution sentence: only what the platform verified about the author, never more. */
|
|
21
47
|
function attribution(runId, origin) {
|
|
22
48
|
const by = origin.by ? ` (${origin.by})` : "";
|
|
@@ -267,6 +267,8 @@ export class CodingRuntime {
|
|
|
267
267
|
const seen = inputId ? session.inputs.check(inputId, digest) : "new";
|
|
268
268
|
if (seen !== "new")
|
|
269
269
|
return { ...this.snapshot(sessionId), ...(seen === "duplicate" ? { duplicateInput: inputId } : { inputConflict: inputId }) };
|
|
270
|
+
// Narrowed BEFORE the input is accepted: an envelope whose constraints cannot be delivered whole is refused here (400), never run.
|
|
271
|
+
const objective = runObjective(action.objective);
|
|
270
272
|
// Narrowed rather than trusted: this runner is a published package any caller can
|
|
271
273
|
// POST to, and an unrecognised author must read as "unstated", not become a label.
|
|
272
274
|
session.input(action.text, {
|
|
@@ -274,7 +276,7 @@ export class CodingRuntime {
|
|
|
274
276
|
replay: typeof action.replay === "string" ? action.replay : undefined,
|
|
275
277
|
inputId,
|
|
276
278
|
digest,
|
|
277
|
-
objective
|
|
279
|
+
objective,
|
|
278
280
|
});
|
|
279
281
|
break;
|
|
280
282
|
}
|
package/dist/index.js
CHANGED
|
@@ -1725,6 +1725,13 @@ function policyScheduleAction(previous, next, wasAuthoritative) {
|
|
|
1725
1725
|
if (!wasAuthoritative || !previous.autoUpdate) return "start";
|
|
1726
1726
|
return "keep";
|
|
1727
1727
|
}
|
|
1728
|
+
function acceptPolicyResponse(local, wasAuthoritative, response) {
|
|
1729
|
+
const remote = policyFromResponse(response);
|
|
1730
|
+
if (!remote) return null;
|
|
1731
|
+
const action = policyScheduleAction(local, remote, wasAuthoritative);
|
|
1732
|
+
const ownerTransition = action === "cancel" || !local.autoUpdate;
|
|
1733
|
+
return { policy: ownerTransition ? { ...local, ...remote } : { ...local, autoUpdate: remote.autoUpdate }, action };
|
|
1734
|
+
}
|
|
1728
1735
|
function mayAutomaticallyRestart(input) {
|
|
1729
1736
|
return input.authoritative && input.enabled && input.workObserved && input.busy.length === 0;
|
|
1730
1737
|
}
|
|
@@ -1980,18 +1987,17 @@ async function connectViaRelay(instanceIds, localUrl, runnerToken, opts, force =
|
|
|
1980
1987
|
};
|
|
1981
1988
|
const acceptAutoUpdatePolicy = (response) => {
|
|
1982
1989
|
if (!autoUpdateKey) return;
|
|
1983
|
-
const
|
|
1984
|
-
if (!
|
|
1985
|
-
|
|
1986
|
-
autoUpdatePolicy = { ...autoUpdatePolicy, ...policy };
|
|
1990
|
+
const accepted = acceptPolicyResponse(autoUpdatePolicy, autoUpdatePolicyAuthoritative, response);
|
|
1991
|
+
if (!accepted) return;
|
|
1992
|
+
autoUpdatePolicy = accepted.policy;
|
|
1987
1993
|
autoUpdatePolicyAuthoritative = true;
|
|
1988
1994
|
if (autoUpdateKey) saveAutoUpdatePolicy(autoUpdateKey, autoUpdatePolicy);
|
|
1989
|
-
if (action === "cancel") {
|
|
1995
|
+
if (accepted.action === "cancel") {
|
|
1990
1996
|
scheduleAutomaticUpdate(false, true);
|
|
1991
1997
|
return;
|
|
1992
1998
|
}
|
|
1993
1999
|
if (refreshingAutomaticPolicy) return;
|
|
1994
|
-
if (action === "start") {
|
|
2000
|
+
if (accepted.action === "start") {
|
|
1995
2001
|
scheduleAutomaticUpdate(true);
|
|
1996
2002
|
}
|
|
1997
2003
|
};
|