toolroll 0.9.111 → 0.9.113
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/CHANGELOG.md +62 -0
- package/README.md +28 -29
- package/dist/action-ledger.js +13 -0
- package/dist/agent-said.js +60 -6
- package/dist/bin.js +5 -1
- package/dist/browser/terminal.js +1 -1
- package/dist/browser/workspace.js +1 -1
- package/dist/chat-channel.js +10 -0
- package/dist/cli-help.js +6 -0
- package/dist/cli.js +2 -0
- package/dist/contracts/console-api.js +2 -1
- package/dist/contracts/engine-api.js +12 -0
- package/dist/contracts/lead-tools.js +28 -0
- package/dist/easy-start.js +8 -3
- package/dist/engine-reads.js +15 -0
- package/dist/evidence.js +6 -6
- package/dist/fast-terms.js +8 -4
- package/dist/flexible-agents.js +2 -8
- package/dist/flexible-answers.js +4 -26
- package/dist/flexible-available.js +31 -1
- package/dist/flexible-import.js +2 -14
- package/dist/flexible-launch.js +15 -3
- package/dist/flexible-launcher.js +0 -5
- package/dist/flexible-relay.js +7 -4
- package/dist/flexible-session.js +123 -32
- package/dist/flexible-setting-schema.js +10 -0
- package/dist/flexible-ship.js +8 -18
- package/dist/flexible-start.js +2 -2
- package/dist/flexible-thread.js +21 -27
- package/dist/flexible-turns.js +7 -17
- package/dist/flexible.js +9 -11
- package/dist/flow-triggers.js +4 -1
- package/dist/lead-tools.js +107 -1
- package/dist/lead.js +1 -1
- package/dist/ledger-view.js +2 -1
- package/dist/live-terminal.js +28 -0
- package/dist/local-owner.js +1 -0
- package/dist/needs-you.js +10 -2
- package/dist/operate.js +62 -5
- package/dist/outbound-privacy.js +6 -1
- package/dist/plain-words.js +1 -1
- package/dist/release.js +2 -0
- package/dist/serve.js +10 -1
- package/dist/server/chat.js +6 -1
- package/dist/server/engine-api.js +91 -27
- package/dist/server/mutation-key.js +6 -0
- package/dist/server/render-history.js +2 -1
- package/dist/server/route-table.js +3 -0
- package/dist/server/settings-section-table.js +3 -0
- package/dist/server/settings-sections.js +23 -0
- package/dist/server/settings.js +36 -3
- package/dist/server/terminals.js +3 -3
- package/dist/settings-proofs.js +2 -0
- package/dist/store.js +18 -4
- package/dist/tui/darwin-arm64/toolroll-tui +0 -0
- package/dist/tui/darwin-x64/toolroll-tui +0 -0
- package/dist/tui/linux-arm64/toolroll-tui +0 -0
- package/dist/tui/linux-x64/toolroll-tui +0 -0
- package/dist/view-tools.js +94 -0
- package/dist/work-index.js +6 -2
- package/package.json +2 -1
package/dist/chat-channel.js
CHANGED
|
@@ -671,6 +671,16 @@ export const CHAT_ACTION_PARITY = {
|
|
|
671
671
|
how: "The door refuses cancel from any card; the card links the exact task's Cancel control when a trusted https console-url is configured, and the cancel is armed there.",
|
|
672
672
|
gap: "Incomplete phone action: no phone path to cancel by design; the button only opens the task.",
|
|
673
673
|
},
|
|
674
|
+
toolroll_view_read: {
|
|
675
|
+
support: "missing",
|
|
676
|
+
how: "Refused on the phone by design: the workbench's look is the person's own conversation in the console on this computer (view-tools.ts); the tool answers in words and nothing is read or written.",
|
|
677
|
+
gap: "No phone path by design: restyle from the console on this computer, or edit tui.toml.",
|
|
678
|
+
},
|
|
679
|
+
toolroll_view_set: {
|
|
680
|
+
support: "missing",
|
|
681
|
+
how: "Refused on the phone by design: the workbench's look is the person's own conversation in the console on this computer (view-tools.ts); the tool answers in words and nothing is read or written.",
|
|
682
|
+
gap: "No phone path by design: restyle from the console on this computer, or edit tui.toml.",
|
|
683
|
+
},
|
|
674
684
|
};
|
|
675
685
|
export function parityGaps() {
|
|
676
686
|
return LEAD_TOOL_SCHEMAS.map((tool) => tool.name).filter((name) => CHAT_ACTION_PARITY[name] === undefined);
|
package/dist/cli-help.js
CHANGED
|
@@ -65,6 +65,12 @@ Reports
|
|
|
65
65
|
toolroll graph report which work graph is already here
|
|
66
66
|
toolroll integrations which integrations work, and what to do about the ones that don't (--json)
|
|
67
67
|
|
|
68
|
+
Workbench look
|
|
69
|
+
toolroll view the terminal workbench's theme and saved themes
|
|
70
|
+
toolroll view theme set <name>
|
|
71
|
+
switch the workbench's theme (built in, or one your lead saved)
|
|
72
|
+
toolroll view reset put the workbench's settings back to the defaults (keeps tui.toml.bak)
|
|
73
|
+
|
|
68
74
|
Projects
|
|
69
75
|
toolroll repos list connected repositories, and how to adjust
|
|
70
76
|
toolroll repos remove <path>
|
package/dist/cli.js
CHANGED
|
@@ -331,6 +331,8 @@ async function dispatch(argv, write, mainOptions) {
|
|
|
331
331
|
return runReposCommand(rest, write, mainOptions.onboard);
|
|
332
332
|
if (first === "pulls")
|
|
333
333
|
return runPullsCommand(rest, write);
|
|
334
|
+
if (first === "view")
|
|
335
|
+
return (await import("./view-tools.js")).runViewCommand(rest, write, mainOptions.viewRunner);
|
|
334
336
|
if (first === "graph")
|
|
335
337
|
return runGraphCommand(rest, write);
|
|
336
338
|
if (first !== undefined && OPERATE_COMMANDS.has(first)) {
|
|
@@ -51,10 +51,11 @@ export const CONSOLE_FORMS = {
|
|
|
51
51
|
localModeOff: formContract("POST /settings/local-mode/off", ["password"]),
|
|
52
52
|
justMe: formContract("POST /settings/install-mode/solo", ["password"]),
|
|
53
53
|
taskSizing: formContract("POST /settings/task-sizing", ["password", "enabled", "sizer"]),
|
|
54
|
+
flexibleSwitch: formContract("POST /settings/flexible", ["password", "enabled"]),
|
|
54
55
|
releaseApproval: formContract("POST /settings/release-approval", ["repo", "action", "password"]),
|
|
55
56
|
projectFlexible: formContract("POST /settings/project/flexible", ["repo", "action", "max", "digest", "password"]),
|
|
56
57
|
threadAnswer: formContract("POST /agents/live/thread/<id>/answer", ["request", "card", "decision", "question", "answer"]),
|
|
57
|
-
threadStart: formContract("POST /agents/live/thread", ["repo", "message", "model", "terms", "password"]),
|
|
58
|
+
threadStart: formContract("POST /agents/live/thread", ["repo", "message", "model", "terms", "password", "agent"]),
|
|
58
59
|
term: formContract("POST /term/start, /term/<terminal>/close, /term/<terminal>/remove", ["repo", "program", "password", "task", "run"]),
|
|
59
60
|
termAgent: formContract("POST /term/agent/sign-in, /term/agent/install", ["agent", "password", "confirm"]),
|
|
60
61
|
agentsCheck: formContract("POST /engine/agents/check", []),
|
|
@@ -59,6 +59,7 @@ export const liveSessionWindowSchema = z.object({
|
|
|
59
59
|
});
|
|
60
60
|
export const liveThreadsSchema = z.object({
|
|
61
61
|
version,
|
|
62
|
+
on: z.boolean().optional(),
|
|
62
63
|
threads: z.array(z.object({ id: hex32, title: z.string(), project: z.string().nullable(), level: flexibleLevelSchema.nullable(), live: z.boolean(), waiting: z.number().int(),
|
|
63
64
|
costUsd: z.number().nullable() })),
|
|
64
65
|
});
|
|
@@ -136,6 +137,7 @@ export const stepCardsSchema = z.object({
|
|
|
136
137
|
review: z.object({ run: z.number().int(), receipt: z.string().regex(/^[0-9a-f]{64}$/), source: z.string(),
|
|
137
138
|
accept: z.object({ owed: z.enum(["person-check", "exception"]).nullable(), blockers: z.array(z.string()), needs: z.string().nullable() }),
|
|
138
139
|
}).nullable(),
|
|
140
|
+
shell: z.object({ run: z.number().int(), why: z.string().nullable() }).nullable(),
|
|
139
141
|
failure: z.object({ line: z.string(), failedInARow: z.number().int(), suggestion: z.string().nullable(),
|
|
140
142
|
agentSaid: z.array(z.string()).max(8).nullable() }).nullable(),
|
|
141
143
|
waiting: waitingSchema.extend({ agentSaid: z.array(z.string()).max(8).nullable() }).nullable(),
|
|
@@ -144,6 +146,15 @@ export const stepCardsSchema = z.object({
|
|
|
144
146
|
approval: z.object({ by: z.string(), you: z.boolean(), automatic: z.boolean() }).nullable(),
|
|
145
147
|
room: z.string(),
|
|
146
148
|
});
|
|
149
|
+
export const approvalCardSchema = z.object({
|
|
150
|
+
version,
|
|
151
|
+
task: z.string(),
|
|
152
|
+
key: z.string().nullable(),
|
|
153
|
+
digest: z.string().regex(/^[0-9a-f]{64}$/).nullable(),
|
|
154
|
+
nonce: z.string().regex(/^[0-9a-f]{32}$/).nullable(),
|
|
155
|
+
terms: z.array(z.object({ label: z.string(), words: z.string() })),
|
|
156
|
+
problem: z.string().nullable(),
|
|
157
|
+
});
|
|
147
158
|
const diffProblemSchema = z.string().nullable();
|
|
148
159
|
export const resultDiffSchema = z.object({
|
|
149
160
|
version,
|
|
@@ -252,6 +263,7 @@ export const ENGINE_RESPONSES = {
|
|
|
252
263
|
liveThreads: { route: "GET /agents/live/threads", schema: liveThreadsSchema },
|
|
253
264
|
workRows: { route: "GET /work/rows", schema: workRowsSchema },
|
|
254
265
|
stepCards: { route: "GET /t/<task>/steps", schema: stepCardsSchema },
|
|
266
|
+
approvalCard: { route: "GET /t/<task>/approval", schema: approvalCardSchema },
|
|
255
267
|
resultDiff: { route: "GET /t/<task>/diff", schema: resultDiffSchema },
|
|
256
268
|
resultDiffFile: { route: "GET /t/<task>/diff?run=&file=", schema: resultDiffFileSchema },
|
|
257
269
|
resultDiffContext: { route: "GET /t/<task>/diff?run=&file=&from=&count=", schema: resultDiffContextSchema },
|
|
@@ -32,6 +32,13 @@ export const touches = z.array(text("taskTouch")).max(50);
|
|
|
32
32
|
export const acceptance = z.array(acceptanceCriterionSchema).min(1).max(ACCEPTANCE_LIMITS.criteria);
|
|
33
33
|
const note = z.string().max(LIMITS.note, { error: issue => overBy(LIMITS.note, issue.input) }).describe(`At most ${LIMITS.note} characters; longer is refused with its length, not cut.`);
|
|
34
34
|
export const CODE_MAP_VIEWS = ["overview", "area", "file", "search"];
|
|
35
|
+
const VIEW_THEME_NAME = /^[a-z][a-z0-9-]{0,31}$/;
|
|
36
|
+
export const VIEW_ROLES = ["paper", "ink", "muted", "line", "selection", "selection-ink", "ground", "raised", "fill"];
|
|
37
|
+
const viewHex = z.string().regex(/^#[0-9a-fA-F]{6}$/);
|
|
38
|
+
const viewColors = z.strictObject({
|
|
39
|
+
paper: viewHex.optional(), ink: viewHex.optional(), muted: viewHex.optional(), line: viewHex.optional(), selection: viewHex.optional(),
|
|
40
|
+
"selection-ink": viewHex.optional(), ground: viewHex.optional(), raised: viewHex.optional(), fill: viewHex.optional(),
|
|
41
|
+
});
|
|
35
42
|
export const LISTED_TASK_STATES = ["queued", "running", "done", "failed", "cancelled"];
|
|
36
43
|
const ACTION_OPERATIONS = Object.keys(CHAT_ACTIONS).filter(one => !one.startsWith("flow_") && !one.startsWith("subagent_") && one !== "task_start");
|
|
37
44
|
const cardProps = z.strictObject({
|
|
@@ -149,6 +156,25 @@ export const LEAD_TOOL_INPUTS = {
|
|
|
149
156
|
}),
|
|
150
157
|
propose_answer: z.strictObject({ decision: id, option: text("answerOption").min(1), rationale: text("answerRationale") }),
|
|
151
158
|
propose_cancel: z.strictObject({ task: taskRef, reason: text("proposalReason") }),
|
|
159
|
+
toolroll_view_read: z.strictObject({}),
|
|
160
|
+
toolroll_view_set: z.strictObject({
|
|
161
|
+
theme: z.string().regex(VIEW_THEME_NAME).optional().describe("A built-in theme (terminal, light, dark, high-contrast) or a saved theme's name."),
|
|
162
|
+
save_theme: z.strictObject({
|
|
163
|
+
name: z.string().regex(VIEW_THEME_NAME).describe("Lowercase letters, digits and dashes, at most 32; not a built-in theme's name."),
|
|
164
|
+
base: z.enum(["terminal", "light", "dark", "high-contrast"]),
|
|
165
|
+
colors: viewColors.optional(),
|
|
166
|
+
use: z.boolean().optional().describe("true: switch to it now."),
|
|
167
|
+
}).optional(),
|
|
168
|
+
colors: viewColors.optional().describe("Role colours laid over the theme."),
|
|
169
|
+
density: z.enum(["compact", "comfortable"]).optional(),
|
|
170
|
+
glyphs: z.enum(["unicode", "ascii", "nerd"]).optional(),
|
|
171
|
+
columns: z.array(z.enum(["agent", "step", "age", "cost", "project"])).max(5).optional(),
|
|
172
|
+
list_side: z.enum(["left", "right"]).optional(),
|
|
173
|
+
reduced_motion: z.boolean().optional(),
|
|
174
|
+
key_bar: z.boolean().optional(),
|
|
175
|
+
show_costs: z.boolean().optional(),
|
|
176
|
+
notifications: z.strictObject({ asks: z.boolean().optional(), finished: z.boolean().optional(), failed: z.boolean().optional() }).optional(),
|
|
177
|
+
}),
|
|
152
178
|
};
|
|
153
179
|
export const LEAD_TOOL_READ_INPUTS = {
|
|
154
180
|
...LEAD_TOOL_INPUTS,
|
|
@@ -257,6 +283,8 @@ export const LEAD_TOOL_OUTPUTS = {
|
|
|
257
283
|
propose_agents: proposed("agents", { task: str }),
|
|
258
284
|
propose_answer: proposed("answer", { decision: int, option: str }),
|
|
259
285
|
propose_cancel: proposed("cancel", { task: str }),
|
|
286
|
+
toolroll_view_read: z.looseObject({ settings: z.looseObject({}), allowed: z.looseObject({}), roles: list, themes: z.looseObject({}), guide: str }),
|
|
287
|
+
toolroll_view_set: z.looseObject({ changed: z.array(str), said: str }),
|
|
260
288
|
};
|
|
261
289
|
export function reportToolOutput(surface, tool, schema, body) {
|
|
262
290
|
const read = parseContract(schema, body);
|
package/dist/easy-start.js
CHANGED
|
@@ -8,6 +8,7 @@ import { proveConsoleReadOnly } from "./quick-start.js";
|
|
|
8
8
|
import { backgroundAsked, installationCreatedBy, localModeCandidate, localModeOf, openStore, openStoreReadOnly, recordBackgroundAsked } from "./store.js";
|
|
9
9
|
import { underAgent } from "./prompt.js";
|
|
10
10
|
import { savedLoginFile } from "./login-secrets.js";
|
|
11
|
+
const PROVE_EVERY_MS = 50;
|
|
11
12
|
export { easyStartApplies, easyStartArgs } from "./easy-start-args.js";
|
|
12
13
|
export const SIGN_IN_HANDOFF_MS = 60_000;
|
|
13
14
|
const EXIT = { ok: 0, failed: 1, usage: 2, refused: 3 };
|
|
@@ -116,12 +117,13 @@ export async function runEasyStart(mode, args, seams) {
|
|
|
116
117
|
stopOwned(child);
|
|
117
118
|
return { ok: false, state: "refused", message: "it didn't answer in time" };
|
|
118
119
|
}
|
|
119
|
-
await sleep(
|
|
120
|
+
await sleep(PROVE_EVERY_MS);
|
|
120
121
|
}
|
|
121
122
|
};
|
|
122
123
|
let proof = first;
|
|
123
124
|
if (!proof.ok) {
|
|
124
|
-
|
|
125
|
+
if (globalThis[Symbol.for("toolroll.starting-said")] !== true)
|
|
126
|
+
write("Starting Toolroll…");
|
|
125
127
|
proof = seams.serviceInstalled() ? await seams.startService() : await startOwned();
|
|
126
128
|
if (!proof.ok) {
|
|
127
129
|
write(`Toolroll didn't start: ${proof.message}.`);
|
|
@@ -213,14 +215,17 @@ export async function runEasyStart(mode, args, seams) {
|
|
|
213
215
|
if (exit === "keep") {
|
|
214
216
|
const said = await handoff();
|
|
215
217
|
write(said);
|
|
216
|
-
if (ownedNow() === null)
|
|
218
|
+
if (ownedNow() === null) {
|
|
219
|
+
write("Reopen with: toolroll");
|
|
217
220
|
return EXIT.ok;
|
|
221
|
+
}
|
|
218
222
|
}
|
|
219
223
|
write("Stopping Toolroll… (running work is saved)");
|
|
220
224
|
stopOwned(child);
|
|
221
225
|
await child.exited;
|
|
222
226
|
write("Toolroll stopped.");
|
|
223
227
|
}
|
|
228
|
+
write("Reopen with: toolroll");
|
|
224
229
|
return EXIT.ok;
|
|
225
230
|
}
|
|
226
231
|
export function spawnOwnedUp(args, options) {
|
package/dist/engine-reads.js
CHANGED
|
@@ -88,6 +88,8 @@ export function stepCardsOf({ store, family, now, access, evidenceRoot, viewer =
|
|
|
88
88
|
review: assignment !== null && assignment.state === "ready-to-check" && assignment.receipt !== null && assignment.receipt.taskId === current.id
|
|
89
89
|
? { run: assignment.receipt.runId, receipt: assignment.receipt.digest, source: revisionSourceOf(scope?.digest ?? null),
|
|
90
90
|
accept: acceptFactsOf(store, assignment, viewer, evidenceRoot) } : null,
|
|
91
|
+
shell: shellOf(store, family, assignment !== null && assignment.state === "ready-to-check" && assignment.receipt !== null && assignment.receipt.taskId === current.id
|
|
92
|
+
? assignment.receipt.runId : builds[0]?.id ?? null),
|
|
91
93
|
failure: current.state === "failed" ? failureOf(store, ref?.id ?? null, builds) : null,
|
|
92
94
|
waiting: (() => {
|
|
93
95
|
const waiting = waitingOf(store, current.id, now);
|
|
@@ -103,6 +105,19 @@ export function stepCardsOf({ store, family, now, access, evidenceRoot, viewer =
|
|
|
103
105
|
room: `task:${encodeURIComponent(root.id)}`,
|
|
104
106
|
};
|
|
105
107
|
}
|
|
108
|
+
export const SHELL_NO_RESULT = "This build has no saved result yet. Wait for it to finish (or stop it), then open the build shell.";
|
|
109
|
+
export const SHELL_NO_COMMIT = "This build has no saved commit to open a terminal on.";
|
|
110
|
+
function shellOf(store, family, runId) {
|
|
111
|
+
if (runId === null)
|
|
112
|
+
return null;
|
|
113
|
+
const run = resultRunsOf(store, family).find(one => one.id === runId) ?? null;
|
|
114
|
+
if (run === null)
|
|
115
|
+
return { run: runId, why: SHELL_NO_RESULT };
|
|
116
|
+
const revision = run.headRevision;
|
|
117
|
+
if (revision === null || !/^[0-9a-f]{40}(?:[0-9a-f]{24})?$/.test(revision))
|
|
118
|
+
return { run: runId, why: SHELL_NO_COMMIT };
|
|
119
|
+
return { run: runId, why: null };
|
|
120
|
+
}
|
|
106
121
|
function failureOf(store, taskRef, builds) {
|
|
107
122
|
const last = latestFinishedAttempt(builds);
|
|
108
123
|
const failedInARow = taskRef === null ? 0
|
package/dist/evidence.js
CHANGED
|
@@ -499,14 +499,14 @@ export const SECRET_PATTERNS = [
|
|
|
499
499
|
{ name: "private-key", pattern: /-----BEGIN [A-Z ]*PRIVATE KEY-----/ },
|
|
500
500
|
{ name: "aws-access-key", pattern: /\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/ },
|
|
501
501
|
{ name: "github-token", pattern: /\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{36}\b|github_pat_[A-Za-z0-9_]{22,}/ },
|
|
502
|
-
{ name: "slack-token", pattern: /\bxox[baprs]-[A-Za-z0-9-]{10,}\
|
|
502
|
+
{ name: "slack-token", pattern: /\bxox[baprs]-[A-Za-z0-9-]{10,}(?:\b|(?![\w-]))/ },
|
|
503
503
|
{ name: "npm-auth-token", pattern: /_authToken\s*=\s*[^\s$][^\s]*/ },
|
|
504
|
-
{ name: "openai-key", pattern: /\bsk-[A-Za-z0-9_-]{32,}\
|
|
504
|
+
{ name: "openai-key", pattern: /\bsk-[A-Za-z0-9_-]{32,}(?:\b|(?![\w-]))/ },
|
|
505
505
|
{ name: "stripe-key", pattern: /\b(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{24,}\b|\bwhsec_[A-Za-z0-9]{24,}\b/ },
|
|
506
|
-
{ name: "google-api-key", pattern: /\bAIza[0-9A-Za-z_-]{35}\
|
|
507
|
-
{ name: "gitlab-token", pattern: /\bglpat-[A-Za-z0-9_-]{20,}\
|
|
508
|
-
{ name: "telegram-bot-token", pattern: /\b\d{8,10}:AA[A-Za-z0-9_-]{33}\
|
|
509
|
-
{ name: "discord-bot-token", pattern: /\b[MN][A-Za-z\d]{23,25}\.[\w-]{6}\.[\w-]{27,}\
|
|
506
|
+
{ name: "google-api-key", pattern: /\bAIza[0-9A-Za-z_-]{35}(?:\b|(?![\w-]))/ },
|
|
507
|
+
{ name: "gitlab-token", pattern: /\bglpat-[A-Za-z0-9_-]{20,}(?:\b|(?![\w-]))/ },
|
|
508
|
+
{ name: "telegram-bot-token", pattern: /\b\d{8,10}:AA[A-Za-z0-9_-]{33}(?:\b|(?![\w-]))/ },
|
|
509
|
+
{ name: "discord-bot-token", pattern: /\b[MN][A-Za-z\d]{23,25}\.[\w-]{6}\.[\w-]{27,}(?:\b|(?![\w-]))/ },
|
|
510
510
|
{ name: "password-in-url", pattern: /\b[a-z][a-z0-9+.-]*:\/\/[^\s:@/]+:[^\s:@/]{3,}@[^\s/]/i },
|
|
511
511
|
{ name: "putty-private-key", pattern: /PuTTY-User-Key-File-\d+:/ },
|
|
512
512
|
{ name: "aws-secret-key", pattern: /\b(?:aws_secret_access_key|SecretAccessKey)\b["']?\s*[=:]\s*["']?[A-Za-z0-9/+]{40}/i },
|
package/dist/fast-terms.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { describeScope, summaryContextOf } from "./approval-summary.js";
|
|
2
2
|
const LABELS = { goal: "Goal", "not this": "Not this", files: "Files", budget: "Budget", network: "Network", writes: "Writes", reads: "Reads", checks: "Checks", services: "Services" };
|
|
3
3
|
export function fastTermsLines(store, scope, repo) {
|
|
4
|
+
const lines = termsOfLines(describeScope(scope, undefined, null, summaryContextOf(store, scope.taskId, scope, new Date(), null, repo)));
|
|
5
|
+
const tools = store.projectTools(repo).map(one => one.name);
|
|
6
|
+
lines.push({ label: "Project tools", words: tools.length === 0 ? "None" : tools.join(", ") });
|
|
7
|
+
return lines;
|
|
8
|
+
}
|
|
9
|
+
export function termsOfLines(raw) {
|
|
4
10
|
const lines = [];
|
|
5
|
-
for (const
|
|
6
|
-
const line =
|
|
11
|
+
for (const one of raw) {
|
|
12
|
+
const line = one.trimEnd();
|
|
7
13
|
const named = /^ {2}(\S+(?: \S+)?) {2,}(.*)$/.exec(line);
|
|
8
14
|
if (named !== null && (named[1] === "version" || named[1] === "approved"))
|
|
9
15
|
continue;
|
|
@@ -14,7 +20,5 @@ export function fastTermsLines(store, scope, repo) {
|
|
|
14
20
|
else
|
|
15
21
|
lines.push({ label: "Plan", words: line.trim() });
|
|
16
22
|
}
|
|
17
|
-
const tools = store.projectTools(repo).map(one => one.name);
|
|
18
|
-
lines.push({ label: "Project tools", words: tools.length === 0 ? "None" : tools.join(", ") });
|
|
19
23
|
return lines;
|
|
20
24
|
}
|
package/dist/flexible-agents.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
-
import {
|
|
2
|
+
import { flexibleAvailable } from "./flexible-available.js";
|
|
3
3
|
import { flexibleDelegationAtUse, FLEXIBLE_LEVEL_WORDS, FLEXIBLE_LEVELS, FLEXIBLE_UNAVAILABLE, isFlexibleLevel } from "./flexible.js";
|
|
4
4
|
import { threadLevelAllowed, FLEXIBLE_PROVEN } from "./flexible-levels.js";
|
|
5
5
|
import { defaultCustodyIO, flexibleLaunch, freshProviderFolder, onLaunchStopped, unsettledLaunch, watchLaunch } from "./flexible-launch.js";
|
|
@@ -22,8 +22,6 @@ const refuse = (reason, message = WORDS[reason]) => ({ ok: false, reason, messag
|
|
|
22
22
|
const MODEL = /^[A-Za-z0-9._:/@+-]{1,200}$/;
|
|
23
23
|
const EMPTY_MCP = '{"mcpServers":{}}';
|
|
24
24
|
export function flexibleAgentLaunch(provider, level, input) {
|
|
25
|
-
if (!FLEXIBLE_AVAILABLE)
|
|
26
|
-
return refuse("not-available");
|
|
27
25
|
if (typeof input.model !== "string" || !MODEL.test(input.model) || !isFlexibleLevel(level))
|
|
28
26
|
return refuse("invalid-request");
|
|
29
27
|
if (provider === "codex" || provider === "openrouter")
|
|
@@ -63,7 +61,7 @@ function stillMayStart(store, turnId, holder) {
|
|
|
63
61
|
return allowed.ok ? null : allowed.message;
|
|
64
62
|
}
|
|
65
63
|
export async function startFlexibleTurn(store, input) {
|
|
66
|
-
if (!
|
|
64
|
+
if (!flexibleAvailable(store))
|
|
67
65
|
return refuse("not-available");
|
|
68
66
|
const first = flexibleTurn(store, input.turn);
|
|
69
67
|
if (first === null)
|
|
@@ -163,8 +161,6 @@ async function startLocked(store, input) {
|
|
|
163
161
|
return { ok: true, launched: "started", launchId: spawned.launchId, pid: spawned.pid, child: spawned.child, stopWatching };
|
|
164
162
|
}
|
|
165
163
|
export async function lowerFlexibleThreadLevel(store, input) {
|
|
166
|
-
if (!FLEXIBLE_AVAILABLE)
|
|
167
|
-
return refuse("not-available");
|
|
168
164
|
if (!isFlexibleLevel(input.level) || typeof input.by?.name !== "string" || !Number.isSafeInteger(input.by.generation))
|
|
169
165
|
return refuse("invalid-request");
|
|
170
166
|
return withFlexibleThreadLock(input.thread, () => lowerLocked(store, input)).then(result => result);
|
|
@@ -210,8 +206,6 @@ async function lowerLocked(store, input) {
|
|
|
210
206
|
: { ok: true, level: input.level, stopped: "pending", message: `Lowered to ${words}. Some of the agent's processes are still running, so no new turn starts until they stop (${stopped.why}).` };
|
|
211
207
|
}
|
|
212
208
|
export async function recoverFlexibleLaunchesOf(store, input) {
|
|
213
|
-
if (!FLEXIBLE_AVAILABLE)
|
|
214
|
-
return refuse("not-available");
|
|
215
209
|
if (typeof input.holder !== "string" || !/^[A-Za-z0-9._:-]{1,128}$/.test(input.holder))
|
|
216
210
|
return refuse("invalid-request");
|
|
217
211
|
const launches = store.handle.prepare("SELECT thread, id FROM flexible_thread_launch WHERE holder = ? AND state <> 'exited' ORDER BY started_at, id").all(input.holder)
|
package/dist/flexible-answers.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
|
2
2
|
import { closeSync, constants as fsConstants, lstatSync, openSync, realpathSync } from "node:fs";
|
|
3
3
|
import { basename, dirname, join, relative, isAbsolute } from "node:path";
|
|
4
|
-
import {
|
|
4
|
+
import { flexibleAvailable } from "./flexible-available.js";
|
|
5
5
|
import { flexibleDelegationAtUse, FLEXIBLE_LEVELS, FLEXIBLE_UNAVAILABLE, isFlexibleLevel } from "./flexible.js";
|
|
6
6
|
import { flexibleLaunch } from "./flexible-launch.js";
|
|
7
7
|
import { flexibleTurn } from "./flexible-turns.js";
|
|
@@ -38,8 +38,6 @@ const WORDS = Object.freeze({
|
|
|
38
38
|
const refuse = (reason, state, message = WORDS[reason]) => state === undefined ? { ok: false, reason, message } : { ok: false, reason, message, state };
|
|
39
39
|
export const FLEXIBLE_ANSWER_UNCERTAIN = WORDS["uncertain"];
|
|
40
40
|
export function streamAnswerSender(stream) {
|
|
41
|
-
if (!FLEXIBLE_AVAILABLE)
|
|
42
|
-
return refuse("not-available");
|
|
43
41
|
return (bytes, { deadlineMs, signal }) => new Promise(resolve => {
|
|
44
42
|
if (stream.destroyed || !stream.writable || signal.aborted) {
|
|
45
43
|
resolve({ written: 0, complete: false });
|
|
@@ -187,8 +185,6 @@ function fileProblem(path) {
|
|
|
187
185
|
return null;
|
|
188
186
|
}
|
|
189
187
|
export function openFlexibleAnswerCatalog(store) {
|
|
190
|
-
if (!FLEXIBLE_AVAILABLE)
|
|
191
|
-
return refuse("not-available");
|
|
192
188
|
const database = store.databaseFile();
|
|
193
189
|
if (database === null || !isAbsolute(database))
|
|
194
190
|
return refuse("catalog-unsafe");
|
|
@@ -401,7 +397,7 @@ function answerFor(kind, card, decision, answers) {
|
|
|
401
397
|
return { answers: Object.fromEntries(entries) };
|
|
402
398
|
}
|
|
403
399
|
export function recordFlexibleRequest(store, catalog, input) {
|
|
404
|
-
if (!
|
|
400
|
+
if (!flexibleAvailable(store))
|
|
405
401
|
return refuse("not-available");
|
|
406
402
|
if (![input.thread, input.turn, input.connection].every(id => typeof id === "string" && ID.test(id)) || typeof input.holder !== "string" || !HOLDER.test(input.holder)
|
|
407
403
|
|| typeof input.requestRef !== "string" || !REF.test(input.requestRef) || cardProblem(input.kind, input.card) !== null
|
|
@@ -474,7 +470,7 @@ function decide(store, catalog, input, who, decision, answers) {
|
|
|
474
470
|
return { ok: true, decisionId: made.decisionId, state: "decided" };
|
|
475
471
|
}
|
|
476
472
|
export function decideFlexibleAnswer(store, catalog, input) {
|
|
477
|
-
if (!
|
|
473
|
+
if (!flexibleAvailable(store))
|
|
478
474
|
return refuse("not-available");
|
|
479
475
|
if (input.by?.kind !== "person")
|
|
480
476
|
return refuse("not-a-person");
|
|
@@ -486,8 +482,6 @@ export function decideFlexibleAnswer(store, catalog, input) {
|
|
|
486
482
|
...(input.held === undefined ? {} : { held: input.held }) }, input.decision, input.answers);
|
|
487
483
|
}
|
|
488
484
|
export function decideFlexibleAnswerByPolicy(store, catalog, input) {
|
|
489
|
-
if (!FLEXIBLE_AVAILABLE)
|
|
490
|
-
return refuse("not-available");
|
|
491
485
|
if (typeof input.request !== "string" || !ID.test(input.request) || !Object.hasOwn(FLEXIBLE_ANSWER_RULES, input.rule))
|
|
492
486
|
return refuse("invalid-request");
|
|
493
487
|
return decide(store, catalog, input, { source: "policy", rule: input.rule }, FLEXIBLE_ANSWER_RULES[input.rule], undefined);
|
|
@@ -501,7 +495,7 @@ function agreeing(store, catalog, request) {
|
|
|
501
495
|
return agree ? { row, decision } : { row, decision, problem: true };
|
|
502
496
|
}
|
|
503
497
|
export async function sendFlexibleAnswer(store, catalog, input) {
|
|
504
|
-
if (!
|
|
498
|
+
if (!flexibleAvailable(store))
|
|
505
499
|
return refuse("not-available");
|
|
506
500
|
if (typeof input.request !== "string" || !ID.test(input.request) || typeof input.holder !== "string" || !HOLDER.test(input.holder)
|
|
507
501
|
|| typeof input.connection?.id !== "string" || typeof input.connection.frame !== "function" || typeof input.connection.send !== "function"
|
|
@@ -672,8 +666,6 @@ function markUncertain(store, catalog, request, clock, detail) {
|
|
|
672
666
|
const stoppable = (decision, row) => decision !== null && row !== null && (decision.state === "decided" || decision.state === "sending") && (row.state === "decided" || row.state === "sending")
|
|
673
667
|
&& decision.attemptId === null && row.attemptId === null && !attempted.has(decision.decisionId);
|
|
674
668
|
export function cancelFlexibleAnswer(store, catalog, input) {
|
|
675
|
-
if (!FLEXIBLE_AVAILABLE)
|
|
676
|
-
return refuse("not-available");
|
|
677
669
|
if (input.by?.kind !== "person")
|
|
678
670
|
return refuse("not-a-person");
|
|
679
671
|
if (typeof input.request !== "string" || !ID.test(input.request) || typeof input.by.name !== "string" || !Number.isSafeInteger(input.by.generation))
|
|
@@ -696,8 +688,6 @@ export function cancelFlexibleAnswer(store, catalog, input) {
|
|
|
696
688
|
});
|
|
697
689
|
}
|
|
698
690
|
export function revokeFlexibleAnswers(store, catalog, input) {
|
|
699
|
-
if (!FLEXIBLE_AVAILABLE)
|
|
700
|
-
return refuse("not-available");
|
|
701
691
|
if (![input.thread, ...(input.turn === undefined ? [] : [input.turn]), ...(input.connection === undefined ? [] : [input.connection])].every(id => typeof id === "string" && ID.test(id))
|
|
702
692
|
|| typeof input.reason !== "string" || input.reason.length < 1 || input.reason.length > 200)
|
|
703
693
|
return refuse("invalid-request");
|
|
@@ -723,8 +713,6 @@ export function revokeFlexibleAnswers(store, catalog, input) {
|
|
|
723
713
|
});
|
|
724
714
|
}
|
|
725
715
|
export function ackFlexibleAnswer(store, catalog, input) {
|
|
726
|
-
if (!FLEXIBLE_AVAILABLE)
|
|
727
|
-
return refuse("not-available");
|
|
728
716
|
if (typeof input.connection !== "string" || !ID.test(input.connection) || typeof input.requestRef !== "string" || !REF.test(input.requestRef))
|
|
729
717
|
return refuse("invalid-request");
|
|
730
718
|
return store.transact(() => {
|
|
@@ -740,8 +728,6 @@ export function ackFlexibleAnswer(store, catalog, input) {
|
|
|
740
728
|
});
|
|
741
729
|
}
|
|
742
730
|
export function noteFlexibleToolActivity(store, catalog, input) {
|
|
743
|
-
if (!FLEXIBLE_AVAILABLE)
|
|
744
|
-
return refuse("not-available");
|
|
745
731
|
if (![input.connection, input.turn].every(id => typeof id === "string" && ID.test(id)) || typeof input.correlation !== "string" || !REF.test(input.correlation))
|
|
746
732
|
return refuse("invalid-request");
|
|
747
733
|
return store.transact(() => {
|
|
@@ -758,8 +744,6 @@ export function noteFlexibleToolActivity(store, catalog, input) {
|
|
|
758
744
|
});
|
|
759
745
|
}
|
|
760
746
|
export function expireFlexibleAnswers(store, catalog, input = {}) {
|
|
761
|
-
if (!FLEXIBLE_AVAILABLE)
|
|
762
|
-
return refuse("not-available");
|
|
763
747
|
const ackMs = input.ackMs ?? FLEXIBLE_ANSWER_ACK_MS, writeMs = input.writeMs ?? FLEXIBLE_ANSWER_WRITE_MS;
|
|
764
748
|
if (!Number.isSafeInteger(ackMs) || ackMs < 0 || !Number.isSafeInteger(writeMs) || writeMs < 0)
|
|
765
749
|
return refuse("invalid-request");
|
|
@@ -809,8 +793,6 @@ export function expireFlexibleAnswers(store, catalog, input = {}) {
|
|
|
809
793
|
});
|
|
810
794
|
}
|
|
811
795
|
export function recoverFlexibleAnswersOf(store, catalog, input) {
|
|
812
|
-
if (!FLEXIBLE_AVAILABLE)
|
|
813
|
-
return refuse("not-available");
|
|
814
796
|
if (typeof input.holder !== "string" || !HOLDER.test(input.holder))
|
|
815
797
|
return refuse("invalid-request");
|
|
816
798
|
return store.transact(() => {
|
|
@@ -851,8 +833,6 @@ export function recoverFlexibleAnswersOf(store, catalog, input) {
|
|
|
851
833
|
});
|
|
852
834
|
}
|
|
853
835
|
export function recordFlexibleProviderDecision(store, input) {
|
|
854
|
-
if (!FLEXIBLE_AVAILABLE)
|
|
855
|
-
return refuse("not-available");
|
|
856
836
|
if (![input.thread, input.turn, input.connection].every(id => typeof id === "string" && ID.test(id)) || typeof input.holder !== "string" || !HOLDER.test(input.holder)
|
|
857
837
|
|| typeof input.requestRef !== "string" || !REF.test(input.requestRef) || (input.decision !== "accept" && input.decision !== "decline")
|
|
858
838
|
|| typeof input.provider !== "string" || !/^[a-z][a-z0-9-]{0,39}$/.test(input.provider))
|
|
@@ -872,8 +852,6 @@ export function recordFlexibleProviderDecision(store, input) {
|
|
|
872
852
|
});
|
|
873
853
|
}
|
|
874
854
|
export function flexibleRequestsOf(catalog, input) {
|
|
875
|
-
if (!FLEXIBLE_AVAILABLE)
|
|
876
|
-
return refuse("not-available");
|
|
877
855
|
const limit = input.limit ?? 20;
|
|
878
856
|
if (typeof input.thread !== "string" || !ID.test(input.thread) || (input.turn !== undefined && (typeof input.turn !== "string" || !ID.test(input.turn)))
|
|
879
857
|
|| !Number.isSafeInteger(limit) || limit < 1 || limit > 100)
|
|
@@ -1 +1,31 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const FLEXIBLE_SETTING_ACTION = "interactive agent threads";
|
|
2
|
+
export function flexibleAvailable(store) {
|
|
3
|
+
let row;
|
|
4
|
+
try {
|
|
5
|
+
row = store.handle.prepare("SELECT enabled FROM flexible_setting WHERE id = 1").get();
|
|
6
|
+
}
|
|
7
|
+
catch {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
return row !== undefined && row["enabled"] === 1;
|
|
11
|
+
}
|
|
12
|
+
export function flexibleSetting(store) {
|
|
13
|
+
let row;
|
|
14
|
+
try {
|
|
15
|
+
row = store.handle.prepare("SELECT enabled, updated_by, updated_at FROM flexible_setting WHERE id = 1").get();
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
row = undefined;
|
|
19
|
+
}
|
|
20
|
+
if (row === undefined)
|
|
21
|
+
return { on: false, by: null, at: null };
|
|
22
|
+
return { on: row["enabled"] === 1, by: String(row["updated_by"]), at: String(row["updated_at"]) };
|
|
23
|
+
}
|
|
24
|
+
export function setFlexibleSetting(store, on, by, now) {
|
|
25
|
+
const was = flexibleAvailable(store);
|
|
26
|
+
store.handle.prepare(`INSERT INTO flexible_setting (id, enabled, updated_by, updated_at) VALUES (1, ?, ?, ?)
|
|
27
|
+
ON CONFLICT(id) DO UPDATE SET enabled = excluded.enabled, updated_by = excluded.updated_by, updated_at = excluded.updated_at`).run(on ? 1 : 0, by, now.toISOString());
|
|
28
|
+
store.recordAction({ at: now.toISOString(), actor: by, repo: null, taskId: null, runId: null, action: FLEXIBLE_SETTING_ACTION, outcome: on ? "on" : "off", source: "policy",
|
|
29
|
+
detail: was === on ? "unchanged" : null });
|
|
30
|
+
return { changed: was !== on };
|
|
31
|
+
}
|
package/dist/flexible-import.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { closeSync, constants as fsConstants, existsSync, fstatSync, lstatSync, mkdirSync, mkdtempSync, opendirSync, openSync, readFileSync, readSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { basename, dirname, isAbsolute, join } from "node:path";
|
|
4
|
-
import { FLEXIBLE_AVAILABLE } from "./flexible-available.js";
|
|
5
4
|
import { FLEXIBLE_UNAVAILABLE } from "./flexible.js";
|
|
6
|
-
import { flexibleThread, flexibleThreadBranch, flexibleThreadPaths, withFlexibleThreadLock } from "./flexible-thread.js";
|
|
5
|
+
import { flexibleProjectKnown, flexibleThread, flexibleThreadBranch, flexibleThreadPaths, withFlexibleThreadLock } from "./flexible-thread.js";
|
|
7
6
|
import { readProjectRefs, refsChangedOutside, refSnapshotOf, saveRefSnapshot } from "./flexible-refs.js";
|
|
8
7
|
import { PROTECTED_FILES, protectedChanges, protectedLinks } from "./agent-fence.js";
|
|
9
8
|
import { scanPatchForSecrets } from "./evidence.js";
|
|
10
9
|
import { PROOF_LIMITS } from "./proof.js";
|
|
11
10
|
import { run } from "./exec.js";
|
|
12
11
|
import { hardenedGit, recordedCommonDir } from "./teardown-git.js";
|
|
13
|
-
import { projectRowKnown } from "./store.js";
|
|
14
12
|
const NOTHING = "Nothing was imported.";
|
|
15
13
|
const PRE_WORDS = {
|
|
16
14
|
"not-available": FLEXIBLE_UNAVAILABLE,
|
|
@@ -246,7 +244,7 @@ function sourceOf(store, id, limits, deadline) {
|
|
|
246
244
|
return pre("thread-unknown");
|
|
247
245
|
if (thread.state !== "ready")
|
|
248
246
|
return pre("thread-not-ready");
|
|
249
|
-
if (!
|
|
247
|
+
if (!flexibleProjectKnown(store, thread.repo))
|
|
250
248
|
return pre("not-a-project");
|
|
251
249
|
const state = stateFolderOf(store);
|
|
252
250
|
if (state === null)
|
|
@@ -333,8 +331,6 @@ async function changedEntries(read, repo, base, candidate) {
|
|
|
333
331
|
return entries;
|
|
334
332
|
}
|
|
335
333
|
export async function readFlexibleCandidate(store, input) {
|
|
336
|
-
if (!FLEXIBLE_AVAILABLE)
|
|
337
|
-
return pre("not-available");
|
|
338
334
|
const limits = limitsOf(input.limits);
|
|
339
335
|
const deadline = Date.now() + limits.importMs;
|
|
340
336
|
const source = sourceOf(store, input.thread, limits, deadline);
|
|
@@ -612,8 +608,6 @@ async function quarantineChecks(read, repo, source, candidate, limits) {
|
|
|
612
608
|
return null;
|
|
613
609
|
}
|
|
614
610
|
export async function importFlexibleCandidate(store, input) {
|
|
615
|
-
if (!FLEXIBLE_AVAILABLE)
|
|
616
|
-
return pre("not-available");
|
|
617
611
|
const locked = await withFlexibleThreadLock(input.thread, () => guarded(() => importLocked(store, input)));
|
|
618
612
|
if (locked.ok === false && (locked.reason === "not-available" || locked.reason === "thread-unknown"))
|
|
619
613
|
return pre(locked.reason);
|
|
@@ -692,8 +686,6 @@ async function importLocked(store, input) {
|
|
|
692
686
|
});
|
|
693
687
|
}
|
|
694
688
|
export async function removeFlexibleImportRefs(store, input) {
|
|
695
|
-
if (!FLEXIBLE_AVAILABLE)
|
|
696
|
-
return pre("not-available");
|
|
697
689
|
const locked = await withFlexibleThreadLock(input.thread, async () => {
|
|
698
690
|
const thread = flexibleThread(store, input.thread);
|
|
699
691
|
if (thread === null)
|
|
@@ -726,8 +718,6 @@ export async function removeFlexibleImportRefs(store, input) {
|
|
|
726
718
|
return locked;
|
|
727
719
|
}
|
|
728
720
|
export async function flexibleTaskBranch(store, input) {
|
|
729
|
-
if (!FLEXIBLE_AVAILABLE)
|
|
730
|
-
return false;
|
|
731
721
|
const thread = flexibleThread(store, input.thread);
|
|
732
722
|
if (thread === null || !SHA.test(input.at) || !/^toolroll\/flexible-[0-9a-f]{32}$/.test(input.branch))
|
|
733
723
|
return false;
|
|
@@ -746,8 +736,6 @@ export async function flexibleTaskBranch(store, input) {
|
|
|
746
736
|
return done.code === 0;
|
|
747
737
|
}
|
|
748
738
|
export async function settleInterruptedImport(store, input) {
|
|
749
|
-
if (!FLEXIBLE_AVAILABLE)
|
|
750
|
-
return pre("not-available");
|
|
751
739
|
const thread = flexibleThread(store, input.thread);
|
|
752
740
|
if (thread === null)
|
|
753
741
|
return pre("thread-unknown");
|
package/dist/flexible-launch.js
CHANGED
|
@@ -7,6 +7,7 @@ import { observeCustody, realCustodyIO, stopCustody, custodySettled } from "./fl
|
|
|
7
7
|
import { interruptFlexibleThreadTurns } from "./flexible-turns.js";
|
|
8
8
|
import { currentMachineId } from "./machine-identity.js";
|
|
9
9
|
import { relayCancel } from "./flexible-relay-cancel.js";
|
|
10
|
+
import { flexibleAvailable } from "./flexible-available.js";
|
|
10
11
|
export const FLEXIBLE_AGENT_PROVIDERS = ["claude", "codex", "gemini", "openrouter"];
|
|
11
12
|
const LAUNCH_ID = /^[0-9a-f]{32}$/;
|
|
12
13
|
const text = (value) => value === null || value === undefined ? null : String(value);
|
|
@@ -73,9 +74,20 @@ export function recordGateShut(store, input) {
|
|
|
73
74
|
});
|
|
74
75
|
}
|
|
75
76
|
const LAUNCHED = "flexible agent launched";
|
|
76
|
-
export function
|
|
77
|
-
store.
|
|
78
|
-
|
|
77
|
+
export function reserveLaunchOpen(store, input) {
|
|
78
|
+
return store.transact(() => {
|
|
79
|
+
if (!flexibleAvailable(store))
|
|
80
|
+
return "interactive agent threads were turned off";
|
|
81
|
+
const why = input.check();
|
|
82
|
+
if (why !== null)
|
|
83
|
+
return why;
|
|
84
|
+
const live = store.handle.prepare("SELECT 1 AS live FROM flexible_thread_launch WHERE id = ? AND thread = ? AND state = 'live'").get(input.launch, input.thread);
|
|
85
|
+
if (live === undefined)
|
|
86
|
+
return "its launch is no longer live";
|
|
87
|
+
store.recordAction({ at: (input.clock ?? (() => new Date()))().toISOString(), actor: "toolroll", repo: null, taskId: null, runId: null, source: "policy", action: LAUNCHED, outcome: "launched",
|
|
88
|
+
detail: `turn ${input.turn ?? "none"} · thread ${input.thread} · launch ${input.launch}` });
|
|
89
|
+
return null;
|
|
90
|
+
});
|
|
79
91
|
}
|
|
80
92
|
export function flexibleTurnLaunched(store, turn) {
|
|
81
93
|
if (!/^[0-9a-f]{32}$/.test(turn))
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
|
-
import { FLEXIBLE_AVAILABLE } from "./flexible-available.js";
|
|
4
3
|
import { FLEXIBLE_UNAVAILABLE } from "./flexible.js";
|
|
5
4
|
import { NETWORK_POLICY_VERSION, proxyEnv, REGISTRY_HOSTS, repositoryEcosystems, startEgressProxy } from "./egress.js";
|
|
6
5
|
import { prepareProtectedStorage, storageRefusalOf } from "./protected-storage.js";
|
|
@@ -12,8 +11,6 @@ const WORDS = Object.freeze({
|
|
|
12
11
|
});
|
|
13
12
|
const refuse = (reason, message = WORDS[reason]) => ({ ok: false, reason, message });
|
|
14
13
|
export function flexibleThreadNetwork(store, repo) {
|
|
15
|
-
if (!FLEXIBLE_AVAILABLE)
|
|
16
|
-
return refuse("not-available");
|
|
17
14
|
const project = store.projectNetwork(repo);
|
|
18
15
|
if (project.mode === "open")
|
|
19
16
|
return { version: NETWORK_POLICY_VERSION, mode: "open", hosts: [], loopback: "proxy-only" };
|
|
@@ -24,8 +21,6 @@ export function flexibleNetworkDigest(network) {
|
|
|
24
21
|
return createHash("sha256").update(`standing-orders:flexible-network:${JSON.stringify({ mode: network.mode, hosts: network.hosts, loopback: network.loopback })}`, "utf8").digest("hex").slice(0, 32);
|
|
25
22
|
}
|
|
26
23
|
export function createFlexibleLauncher(store, seams = {}) {
|
|
27
|
-
if (!FLEXIBLE_AVAILABLE)
|
|
28
|
-
return refuse("not-available");
|
|
29
24
|
const startProxy = seams.startProxy ?? ((options) => startEgressProxy(options));
|
|
30
25
|
const storageNow = seams.storage ?? (() => prepareProtectedStorage(homedir()));
|
|
31
26
|
const live = new Map();
|