toolroll 0.9.108 → 0.9.109
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 +34 -0
- package/dist/advanced-view.js +0 -1
- package/dist/agent-fence.js +35 -4
- package/dist/agent-state.js +5 -2
- package/dist/assignment-ui.js +5 -5
- package/dist/assignment.js +5 -2
- package/dist/browser/terminal.js +1 -1
- package/dist/browser/workspace.css +1 -1
- package/dist/browser/workspace.js +37 -34
- package/dist/browser-crew.js +4 -4
- package/dist/browser-workspace.js +4 -11
- package/dist/builder.js +9 -1
- package/dist/chat-controls.js +6 -5
- package/dist/chat-decide.js +1 -1
- package/dist/chat-quiet.js +3 -3
- package/dist/chat-voice.js +2 -2
- package/dist/cli-help.js +12 -13
- package/dist/cli.js +4 -3
- package/dist/console-chrome.js +10 -3
- package/dist/contracts/console-api.js +4 -3
- package/dist/contracts/handoff.js +4 -0
- package/dist/decision.js +17 -0
- package/dist/demo-chat.js +1 -1
- package/dist/demo.js +6 -0
- package/dist/design/kit.js +4 -3
- package/dist/dispatch.js +3 -8
- package/dist/flexible-available.js +1 -0
- package/dist/flexible-schema.js +32 -0
- package/dist/flexible-thread-schema.js +30 -0
- package/dist/flexible-thread.js +526 -0
- package/dist/flexible-ui.js +44 -0
- package/dist/flexible.js +359 -0
- package/dist/git-views.js +38 -38
- package/dist/guides.js +11 -10
- package/dist/keymap.js +1 -1
- package/dist/lead-context.js +1 -1
- package/dist/limits-ui.js +1 -1
- package/dist/live-bus.js +70 -13
- package/dist/needs-you.js +3 -3
- package/dist/nightly-github.js +2 -2
- package/dist/operate.js +111 -3
- package/dist/project-delete-ui.js +2 -1
- package/dist/project-delete.js +1 -0
- package/dist/provider-auth.js +1 -1
- package/dist/release.js +1 -0
- package/dist/result-actions.js +3 -0
- package/dist/result-evidence-readers.js +8 -2
- package/dist/result-review.js +20 -9
- package/dist/serve.js +32 -29
- package/dist/server/chat.js +9 -9
- package/dist/server/chrome.js +16 -16
- package/dist/server/guards.js +10 -4
- package/dist/server/home.js +37 -5
- package/dist/server/http.js +4 -2
- package/dist/server/in-place.js +5 -4
- package/dist/server/kit.js +2 -2
- package/dist/server/live.js +100 -10
- package/dist/server/pages.js +79 -53
- package/dist/server/render-chat.js +1 -1
- package/dist/server/render-history.js +18 -4
- package/dist/server/render-new-task.js +2 -2
- package/dist/server/render-pages.js +21 -39
- package/dist/server/render-people.js +2 -2
- package/dist/server/render-projects.js +5 -5
- package/dist/server/render-results.js +26 -10
- package/dist/server/render-tasks.js +26 -17
- package/dist/server/retired-routes.js +37 -4
- package/dist/server/route-policy.js +8 -0
- package/dist/server/route-table.js +13 -4
- package/dist/server/settings-computers.js +140 -0
- package/dist/server/settings-scripts.js +15 -0
- package/dist/server/settings-section-table.js +56 -0
- package/dist/server/settings-sections.js +258 -0
- package/dist/server/settings.js +164 -19
- package/dist/server/task-views.js +47 -13
- package/dist/server/tasks.js +143 -90
- package/dist/server/welcome.js +6 -5
- package/dist/settings-groups-ui.js +24 -105
- package/dist/settings-proofs.js +5 -2
- package/dist/sqlite-telemetry.js +70 -21
- package/dist/store.js +108 -9
- package/dist/task-link.js +64 -0
- package/dist/tui.js +1 -1
- package/dist/typed-words-schema.js +18 -0
- package/dist/welcome-facts.js +3 -2
- package/dist/work-index.js +126 -29
- package/dist/work-reads.js +279 -0
- package/package.json +4 -2
package/dist/server/settings.js
CHANGED
|
@@ -36,19 +36,28 @@ import { authenticateAccount } from "../scope.js";
|
|
|
36
36
|
import { budgetLabel, monthOf } from "../spend.js";
|
|
37
37
|
import { PACKAGE_VERSION } from "../version.js";
|
|
38
38
|
import { handlersOf } from './handler-registry.js';
|
|
39
|
-
import { refuse, screen, when } from "./chrome.js";
|
|
39
|
+
import { refuse, relativeAge, screen, when } from "./chrome.js";
|
|
40
40
|
import { requestContext } from "./request-context.js";
|
|
41
|
-
import { btn, empty, infoLine, settingsSection } from "./kit.js";
|
|
41
|
+
import { btn, empty, infoLine, settingsSection, settingsShell } from "./kit.js";
|
|
42
42
|
import { shortPathOf } from "./render-projects.js";
|
|
43
|
-
import { approvalGroup, projectPicker, GROUP_PATHS, groupTitle, modeCeremonyHtml, modePageHtml, passwordlessHtml, HUB_ANCHOR_SCRIPT, pushScriptOf, settingsGroupPage, settingsSubPage } from "../settings-groups-ui.js";
|
|
43
|
+
import { approvalGroup, flagsOf, needsByGroup, projectPicker, GROUP_PATHS, groupTitle, modeCeremonyHtml, modePageHtml, passwordlessHtml, HUB_ANCHOR_SCRIPT, pushScriptOf, settingsGroupPage, settingsNeeds, settingsSubPage } from "../settings-groups-ui.js";
|
|
44
|
+
import { routePrincipalOf } from "./route-policy.js";
|
|
45
|
+
import { areaBody, askedSection, changeDocument, generalBody, generalSections, resolveSettingsProject } from "./settings-sections.js";
|
|
46
|
+
import { computersSections, RUNNER_REGISTER } from "./settings-computers.js";
|
|
47
|
+
import { computersOf } from "./agents-computers.js";
|
|
48
|
+
import { buildersFor } from "../dispatch.js";
|
|
49
|
+
import { CHANGE_DOCUMENTS } from "./settings-section-table.js";
|
|
50
|
+
import { retiredRedirect } from "./retired-routes.js";
|
|
44
51
|
import { HANDOFF_STYLE, redirect, respond, safeReturn, sayTo, signInSpent, startedHere } from "./http.js";
|
|
45
52
|
import { html, htmlString, joinHtml, postForm, reauth } from "../html.js";
|
|
46
|
-
import { browserCaller, sessionWithinLifetime } from "./session.js";
|
|
53
|
+
import { authorityOfWho, browserCaller, sessionWithinLifetime } from "./session.js";
|
|
47
54
|
import { DEFAULT_ACCENT, normalHex } from "../accent-colors.js";
|
|
48
55
|
import { resolvePhaseAgent } from "../agentconfig.js";
|
|
49
56
|
import { parseProtectedPaths } from "../approval-policy.js";
|
|
50
57
|
import { approvalRulesHtml, releaseApprovalHtml } from "../approval-rules-ui.js";
|
|
51
58
|
import { releaseApprovalSetting, setReleaseApproval } from "../release-auto.js";
|
|
59
|
+
import { FLEXIBLE_AVAILABLE } from "../flexible-available.js";
|
|
60
|
+
import { enableFlexible, FLEXIBLE_LEVEL_WORDS, FLEXIBLE_UNAVAILABLE, flexibleSettingsView, isFlexibleLevel, lowerFlexible, turnFlexibleOff } from "../flexible.js";
|
|
52
61
|
import { backupHtml } from "../backup-ui.js";
|
|
53
62
|
import { BACKUP_EVERY_HOURS, backupFolderOf, backupNow, checkBackupFolder, defaultBackupFolder, MAX_KEEP } from "../backup.js";
|
|
54
63
|
import { projectBatchChecks, setProjectBatchChecks } from '../batch-policy.js';
|
|
@@ -338,7 +347,8 @@ ${connectionHtml(asked, connection, task)}${command === null ? "" : html `<p>On
|
|
|
338
347
|
return refuse(response, who, 403, "That project is outside your access.", "/settings/project");
|
|
339
348
|
const selector = projectPicker("/settings/project", projects.map(repo => ({ repo, name: projectName(repo) })), chosen);
|
|
340
349
|
const notice = { said: url.searchParams.get("said"), problem: url.searchParams.get("problem") };
|
|
341
|
-
const content = chosen === "" ? html `${notice.said ? infoLine(notice.said) : ""}${empty({ title: "No projects yet.", action: btn("Add a project", { sm: true, href: "/projects" }) })}` : (projectSettingsHtml({ ...projectViewOf(chosen, who), remoteUrl: store.projectRemote(chosen), codeMap: codeMapView(chosen, who, ctx.now)
|
|
350
|
+
const content = chosen === "" ? html `${notice.said ? infoLine(notice.said) : ""}${empty({ title: "No projects yet.", action: btn("Add a project", { sm: true, href: "/projects" }) })}` : (projectSettingsHtml({ ...projectViewOf(chosen, who), remoteUrl: store.projectRemote(chosen), codeMap: codeMapView(chosen, who, ctx.now),
|
|
351
|
+
flexible: flexibleSettingsView(store, chosen, { name: who.name, canChange: who.via === "cookie" && who.role === "approver" && !store.isDemo() && store.accountCanAccess(who.name, chosen) }) }, notice));
|
|
342
352
|
return sendScreen(response, 200, screen("Project", settingsSubPage("projects", "Project", html `${selector}${content}`), { chrome: chromeFor(chosen || null, "settings") }));
|
|
343
353
|
}
|
|
344
354
|
function codeMapView(repo, who, now) {
|
|
@@ -772,9 +782,7 @@ ${restoreHtml(chosen, retired, undoableMerges(store, chosen), disabledLessons(st
|
|
|
772
782
|
advanced: { on: requestContext.getStore()?.advanced !== false, canChange: who.via === "cookie" },
|
|
773
783
|
projectsFolder: restricted() || runtime.unscopedMode ? null
|
|
774
784
|
: { folders: runtime.ceiling.roots.map(path => ({ path, shown: shortPathOf(path) })) },
|
|
775
|
-
backup: lastBackup
|
|
776
|
-
? { failed: true, words: `Failed ${when(lastBackup.startedAt)}${lastBackup.error === null ? "" : `: ${lastBackup.error}`}` }
|
|
777
|
-
: { failed: false, words: lastBackup.finishedAt === null ? "Backing up now" : `Backed up ${when(lastBackup.finishedAt)}` },
|
|
785
|
+
backup: backupFacts(lastBackup),
|
|
778
786
|
};
|
|
779
787
|
const pushScript = pushScriptOf(facts);
|
|
780
788
|
const script = group === "hub" ? HUB_ANCHOR_SCRIPT : group === "alerts" && pushScript !== null ? pushScript : null;
|
|
@@ -787,11 +795,11 @@ ${restoreHtml(chosen, retired, undoableMerges(store, chosen), disabledLessons(st
|
|
|
787
795
|
const { url, who, response } = ctx;
|
|
788
796
|
const provider = url.pathname.split("/")[2];
|
|
789
797
|
if (!isProviderId(provider))
|
|
790
|
-
return refuse(response, who, 400, "unknown provider", "/
|
|
798
|
+
return refuse(response, who, 400, "unknown provider", "/");
|
|
791
799
|
if (who.role !== "approver")
|
|
792
|
-
return refuse(response, who, 403, "Only an operator can resume an agent's work.", "/
|
|
800
|
+
return refuse(response, who, 403, "Only an operator can resume an agent's work.", "/");
|
|
793
801
|
liftAuthPause(store, provider, "person", who.name, clock());
|
|
794
|
-
return redirect(response, "/
|
|
802
|
+
return redirect(response, "/");
|
|
795
803
|
}
|
|
796
804
|
async function forgetPassword(ctx) {
|
|
797
805
|
const { who, response, posted } = ctx;
|
|
@@ -2179,7 +2187,7 @@ ${postForm("/settings/chat-approval/save", html `\
|
|
|
2179
2187
|
return refuse(response, who, 400, "that project isn't one you can see", "/settings");
|
|
2180
2188
|
const muted = body.get("pings") !== "on";
|
|
2181
2189
|
store.setProjectMuted(who.name, repo, muted, now);
|
|
2182
|
-
return redirect(response, `/settings/alerts?said=${encodeURIComponent(muted ? `${project.name} muted. It still shows in
|
|
2190
|
+
return redirect(response, `/settings/alerts?said=${encodeURIComponent(muted ? `${project.name} muted. It still shows in Work and your evening digest.` : `${project.name} pings you again.`)}#notifications`);
|
|
2183
2191
|
}
|
|
2184
2192
|
async function telegramDigestSave(ctx) {
|
|
2185
2193
|
const { who, response, now, posted } = ctx;
|
|
@@ -2602,6 +2610,7 @@ ${postForm("/settings/chat-approval/save", html `\
|
|
|
2602
2610
|
"settings.passwordless-send": passwordlessSave,
|
|
2603
2611
|
"settings.local-mode-off": localModeOff,
|
|
2604
2612
|
"settings.release-approval-send": releaseApprovalSave,
|
|
2613
|
+
"settings.project-flexible": projectFlexible,
|
|
2605
2614
|
"settings.lead": leadPage,
|
|
2606
2615
|
"settings.teams": teamsPage,
|
|
2607
2616
|
"settings.discord": discordPage,
|
|
@@ -2613,13 +2622,15 @@ ${postForm("/settings/chat-approval/save", html `\
|
|
|
2613
2622
|
"settings.learning": learningPage,
|
|
2614
2623
|
"settings.telegram": telegramPage,
|
|
2615
2624
|
"settings.page": settingsHome,
|
|
2616
|
-
"settings.group-general":
|
|
2625
|
+
"settings.group-general": generalPage,
|
|
2626
|
+
"settings.group-computers": computersPage,
|
|
2617
2627
|
"settings.group-agents": settingsHome.bind(null),
|
|
2618
2628
|
"settings.group-alerts": settingsHome.bind(null),
|
|
2619
2629
|
"settings.group-projects": settingsHome.bind(null),
|
|
2620
2630
|
"settings.group-access": settingsHome.bind(null),
|
|
2621
2631
|
"settings.group-system": settingsHome.bind(null),
|
|
2622
|
-
"settings.group-advanced":
|
|
2632
|
+
"settings.group-advanced": advancedRetired,
|
|
2633
|
+
...changeDocumentHandlers(),
|
|
2623
2634
|
"provider.resume": providerResume,
|
|
2624
2635
|
"settings.updates-dismiss": updatesDismiss,
|
|
2625
2636
|
"session.forget-password": forgetPassword,
|
|
@@ -2905,7 +2916,8 @@ ${postForm("/settings/chat-approval/save", html `\
|
|
|
2905
2916
|
const { response, now, posted } = ctx;
|
|
2906
2917
|
const who = browserCaller(ctx.who);
|
|
2907
2918
|
const body = readForm(posted, CONSOLE_FORMS.localModeOff);
|
|
2908
|
-
const
|
|
2919
|
+
const done = sayTo(response, "/settings/general?section=local-mode");
|
|
2920
|
+
const back = sayTo(response, "/settings/change/local-mode");
|
|
2909
2921
|
if (body.sent.getAll("password").length > 1)
|
|
2910
2922
|
return back("problem", "That form was sent twice over. Nothing changed.");
|
|
2911
2923
|
if (who.authority !== "full")
|
|
@@ -2919,7 +2931,7 @@ ${postForm("/settings/chat-approval/save", html `\
|
|
|
2919
2931
|
return back("problem", "Enter your Toolroll password to turn off local mode.");
|
|
2920
2932
|
if (!turned.ok)
|
|
2921
2933
|
return back("problem", turned.reason === "not-on" ? "Local mode is already off." : "Only an instance operator can turn off local mode.");
|
|
2922
|
-
return
|
|
2934
|
+
return done("said", "Local mode is off. This computer's browser signs in with your password now.");
|
|
2923
2935
|
}
|
|
2924
2936
|
function suggestedView(repo, projects, asked, now) {
|
|
2925
2937
|
const repos = repo === null ? projects : [repo];
|
|
@@ -3017,12 +3029,12 @@ ${postForm("/settings/chat-approval/save", html `\
|
|
|
3017
3029
|
async function advancedAct(ctx) {
|
|
3018
3030
|
const { who, response, now, posted } = ctx;
|
|
3019
3031
|
const body = readForm(posted, CONSOLE_FORMS.advancedView);
|
|
3020
|
-
const back = sayTo(response, "/settings/advanced");
|
|
3032
|
+
const back = sayTo(response, "/settings/general?section=advanced");
|
|
3021
3033
|
if (who.via !== "cookie")
|
|
3022
3034
|
return refuse(response, who, 403, "This address needs a browser sign-in.", "/settings");
|
|
3023
3035
|
const values = body.getAll("advanced");
|
|
3024
3036
|
if (values.length !== 1 || (values[0] !== "on" && values[0] !== "off"))
|
|
3025
|
-
return refuse(response, who, 400, "Choose on or off.", "/settings/advanced");
|
|
3037
|
+
return refuse(response, who, 400, "Choose on or off.", "/settings/general?section=advanced");
|
|
3026
3038
|
const on = values[0] === "on";
|
|
3027
3039
|
const session = who.session;
|
|
3028
3040
|
const door = who.authority === "full"
|
|
@@ -3030,8 +3042,141 @@ ${postForm("/settings/chat-approval/save", html `\
|
|
|
3030
3042
|
: { kind: "local-owner", actor: who.name };
|
|
3031
3043
|
const done = setAdvancedPreference(store, door, on, now);
|
|
3032
3044
|
if (!done.ok)
|
|
3033
|
-
return refuse(response, who, 403, done.problem, "/settings/advanced");
|
|
3045
|
+
return refuse(response, who, 403, done.problem, "/settings/general?section=advanced");
|
|
3034
3046
|
return back("said", on ? "Advanced features show in your menus." : "Advanced features are out of your menus. They still open from here.");
|
|
3035
3047
|
}
|
|
3048
|
+
async function projectFlexible(ctx) {
|
|
3049
|
+
const { response, now, posted } = ctx;
|
|
3050
|
+
const who = browserCaller(ctx.who);
|
|
3051
|
+
if (!FLEXIBLE_AVAILABLE)
|
|
3052
|
+
return refuse(response, who, 403, FLEXIBLE_UNAVAILABLE, "/settings/project");
|
|
3053
|
+
const body = readForm(posted, CONSOLE_FORMS.projectFlexible);
|
|
3054
|
+
const repo = body.get("repo") ?? "";
|
|
3055
|
+
if (!consoleProjects().includes(repo) || !visible(repo))
|
|
3056
|
+
return refuse(response, who, 403, "That project is outside your access.", "/settings/project");
|
|
3057
|
+
const back = sayTo(response, `/settings/project?repo=${encodeURIComponent(repo)}`, "#flexible");
|
|
3058
|
+
if (who.role !== "approver" || store.isDemo() || !store.accountCanAccess(who.name, repo))
|
|
3059
|
+
return back("problem", "An approver for this project changes how its work starts.");
|
|
3060
|
+
const action = body.get("action");
|
|
3061
|
+
if (action === "off") {
|
|
3062
|
+
const done = turnFlexibleOff(store, { repo, by: who.name, now });
|
|
3063
|
+
return back(done.ok ? "said" : "problem", done.ok ? "Secure again. No new Flexible threads start." : done.message);
|
|
3064
|
+
}
|
|
3065
|
+
if (action === "lower") {
|
|
3066
|
+
const max = body.get("max");
|
|
3067
|
+
if (!isFlexibleLevel(max))
|
|
3068
|
+
return back("problem", "Choose Supervised, Auto or Full access. Nothing changed.");
|
|
3069
|
+
const done = lowerFlexible(store, { repo, by: who.name, max, now });
|
|
3070
|
+
return back(done.ok ? "said" : "problem", !done.ok ? done.message : done.changed ? `Lowered to ${FLEXIBLE_LEVEL_WORDS[done.terms.max]}. New threads start under these terms only.` : "Nothing changed.");
|
|
3071
|
+
}
|
|
3072
|
+
if (action !== "enable")
|
|
3073
|
+
return back("problem", "Choose to turn Flexible on, lower it or turn it off. Nothing changed.");
|
|
3074
|
+
const proved = authenticateCredential(who, body.get("password") ?? "", repo);
|
|
3075
|
+
if (!proved.ok)
|
|
3076
|
+
return back("problem", "Enter your Toolroll password to turn on Flexible.");
|
|
3077
|
+
const done = enableFlexible(store, { repo, by: who.name, proof: proved.method, shownDigest: body.get("digest") ?? "", now });
|
|
3078
|
+
return back(done.ok ? "said" : "problem", done.ok ? "Flexible is on." : done.message);
|
|
3079
|
+
}
|
|
3080
|
+
function sectionPersonOf(who) {
|
|
3081
|
+
return { name: who.name, via: who.via, role: who.role, authority: authorityOfWho(who), operator: store.isInstanceOperator(who.name),
|
|
3082
|
+
restricted: restricted(), installation: options.telegramTokenFile !== undefined && !restricted(), passwordSet: store.accountOf(who.name)?.passwordSet === true,
|
|
3083
|
+
principal: routePrincipalOf(who),
|
|
3084
|
+
unscopedConsole: runtime.unscopedMode, demo: store.isDemo() };
|
|
3085
|
+
}
|
|
3086
|
+
const generalImpls = generalSections({
|
|
3087
|
+
updatesVersion: name => settingsUpdates(name, "")?.current ?? null,
|
|
3088
|
+
packageVersion: PACKAGE_VERSION,
|
|
3089
|
+
firstResult: now => { const at = store.firstSuccessAt(now), since = store.installationStartedAt(); return at === null || since === null ? null : firstResultWords(since, at); },
|
|
3090
|
+
passwordless: () => passwordlessSetting(store).on,
|
|
3091
|
+
localModeOn: () => localModeOf(store)?.enabled === true,
|
|
3092
|
+
});
|
|
3093
|
+
const computersDeps = {
|
|
3094
|
+
computers: (now, manage) => computersOf(store, now, visible, manage),
|
|
3095
|
+
connected: (repo, now, runner) => buildersFor(store, repo, now, runner).alive.length > 0,
|
|
3096
|
+
projectName,
|
|
3097
|
+
registerNonce: (name) => mintApprovalNonce(name, RUNNER_REGISTER, ""),
|
|
3098
|
+
ago: (iso, now) => now.getTime() - Date.parse(iso) < 60_000 ? "just now" : relativeAge(iso, now),
|
|
3099
|
+
};
|
|
3100
|
+
const sectionImplsFor = (subject) => ({ ...generalImpls, ...computersSections(computersDeps, subject) });
|
|
3101
|
+
const NO_SUBJECT = { task: null, computer: null, drafts: {} };
|
|
3102
|
+
function computersSubjectOf(url) {
|
|
3103
|
+
const one = (key) => { const all = url.searchParams.getAll(key); return all.length === 0 ? null : all.length === 1 ? all[0] : undefined; };
|
|
3104
|
+
const taskId = one("task"), computer = one("computer");
|
|
3105
|
+
if (taskId === undefined || computer === undefined)
|
|
3106
|
+
return { ok: false, status: 400, message: "Name one task and one computer at most." };
|
|
3107
|
+
let task = null;
|
|
3108
|
+
if (taskId !== null) {
|
|
3109
|
+
const ref = taskId.length <= 200 ? store.lookupRef(taskId) : null;
|
|
3110
|
+
if (ref === null || ref.repo === null || !visible(ref.repo))
|
|
3111
|
+
return { ok: false, status: 404, message: "That task is not available." };
|
|
3112
|
+
task = { id: taskId, repo: ref.repo, runner: ref.assignedRunner ?? null };
|
|
3113
|
+
}
|
|
3114
|
+
const drafts = {};
|
|
3115
|
+
for (const key of ["name", "capacity", "field"]) {
|
|
3116
|
+
const value = one(key);
|
|
3117
|
+
if (typeof value === "string" && value.length <= 60)
|
|
3118
|
+
drafts[key] = value;
|
|
3119
|
+
}
|
|
3120
|
+
return { ok: true, subject: { task, computer: computer !== null && computer.length <= 60 ? computer : null, drafts } };
|
|
3121
|
+
}
|
|
3122
|
+
function backupFacts(last) {
|
|
3123
|
+
return last === null ? null : last.ok === false
|
|
3124
|
+
? { failed: true, words: `Failed ${when(last.startedAt)}${last.error === null ? "" : `: ${last.error}`}` }
|
|
3125
|
+
: { failed: false, words: last.finishedAt === null ? "Backing up now" : `Backed up ${when(last.finishedAt)}` };
|
|
3126
|
+
}
|
|
3127
|
+
function navFlagsFor(who, now) {
|
|
3128
|
+
const minimal = options.telegramTokenFile === undefined || restricted();
|
|
3129
|
+
const operator = who.via === "cookie" && store.isInstanceOperator(who.name);
|
|
3130
|
+
const bot = minimal ? null : loadBotToken(process.env, options.telegramTokenFile);
|
|
3131
|
+
return flagsOf(needsByGroup(settingsNeeds({
|
|
3132
|
+
approver: who.role === "approver", workers: minimal ? null : settingsWorkers(store, now), backup: operator ? backupFacts(store.backupRuns(1)[0] ?? null) : null,
|
|
3133
|
+
telegram: { failing: !minimal && telegramTrouble(store, bot), delivery: minimal ? null : telegramDeliveryWords(store, bot) },
|
|
3134
|
+
})));
|
|
3135
|
+
}
|
|
3136
|
+
function sectionBase(who, project, now) {
|
|
3137
|
+
const facts = requestContext.getStore();
|
|
3138
|
+
const theme = facts?.theme === "light" || facts?.theme === "dark" ? facts.theme : "system";
|
|
3139
|
+
return { person: sectionPersonOf(who), project, now, prefs: { theme, accent: facts?.accent ?? DEFAULT_ACCENT, advanced: facts?.advanced !== false } };
|
|
3140
|
+
}
|
|
3141
|
+
async function generalPage(ctx) {
|
|
3142
|
+
const { url, who, response, now, project } = ctx;
|
|
3143
|
+
const resolved = resolveSettingsProject(url, project, { projects: consoleProjects, canOpen: repo => visible(repo) });
|
|
3144
|
+
if (!resolved.ok)
|
|
3145
|
+
return refuse(response, who, resolved.status, resolved.message, "/settings");
|
|
3146
|
+
const drawn = generalBody(sectionImplsFor(NO_SUBJECT), sectionBase(who, resolved.project, now), askedSection(url), { said: url.searchParams.get("said"), problem: url.searchParams.get("problem") });
|
|
3147
|
+
return sendScreen(response, 200, screen("General", settingsShell({ group: "general", title: "General", lead: "How Toolroll looks and behaves in this browser.", flags: navFlagsFor(who, now), body: drawn.body }), { chrome: chromeFor(project, "settings") }));
|
|
3148
|
+
}
|
|
3149
|
+
async function computersPage(ctx) {
|
|
3150
|
+
const { url, who, response, now, project } = ctx;
|
|
3151
|
+
const resolved = resolveSettingsProject(url, project, { projects: consoleProjects, canOpen: repo => visible(repo) });
|
|
3152
|
+
if (!resolved.ok)
|
|
3153
|
+
return refuse(response, who, resolved.status, resolved.message, "/settings");
|
|
3154
|
+
const subject = computersSubjectOf(url);
|
|
3155
|
+
if (!subject.ok)
|
|
3156
|
+
return refuse(response, who, subject.status, subject.message, "/settings/computers");
|
|
3157
|
+
const drawn = areaBody("computers", sectionImplsFor(subject.subject), sectionBase(who, resolved.project, now), askedSection(url), { said: url.searchParams.get("said"), problem: url.searchParams.get("problem") });
|
|
3158
|
+
return sendScreen(response, 200, screen("Computers", settingsShell({ group: "computers", title: "Computers", lead: "The computers that build approved work.", flags: navFlagsFor(who, now), body: drawn.body }), { chrome: chromeFor(project, "settings") }));
|
|
3159
|
+
}
|
|
3160
|
+
async function advancedRetired(ctx) {
|
|
3161
|
+
return retiredRedirect("settings.group-advanced", ctx.url, ctx.response);
|
|
3162
|
+
}
|
|
3163
|
+
function changeDocumentHandlers() {
|
|
3164
|
+
return Object.fromEntries(CHANGE_DOCUMENTS.map(one => [`settings.change.${one.id}`, changePage(one.id)]));
|
|
3165
|
+
}
|
|
3166
|
+
function changePage(id) {
|
|
3167
|
+
return async (ctx) => {
|
|
3168
|
+
const { url, who, response, now, project } = ctx;
|
|
3169
|
+
const resolved = resolveSettingsProject(url, project, { projects: consoleProjects, canOpen: repo => visible(repo) });
|
|
3170
|
+
if (!resolved.ok)
|
|
3171
|
+
return refuse(response, who, resolved.status, resolved.message, "/settings");
|
|
3172
|
+
const subject = computersSubjectOf(url);
|
|
3173
|
+
if (!subject.ok)
|
|
3174
|
+
return refuse(response, who, subject.status, subject.message, "/settings/computers");
|
|
3175
|
+
const answer = changeDocument(id, sectionImplsFor(subject.subject), sectionBase(who, resolved.project, now), url.searchParams.get("problem"));
|
|
3176
|
+
if (!answer.ok)
|
|
3177
|
+
return refuse(response, who, answer.status, answer.message, "/settings");
|
|
3178
|
+
return sendScreen(response, 200, screen(answer.title, answer.body, { chrome: chromeFor(project, "settings"), forceSensitive: true }));
|
|
3179
|
+
};
|
|
3180
|
+
}
|
|
3036
3181
|
return { registrations, modelsView };
|
|
3037
3182
|
}
|
|
@@ -19,7 +19,7 @@ import { liveAttemptOf, steerControlsFor } from "../steer-controls.js";
|
|
|
19
19
|
import { originOf } from "../task-source.js";
|
|
20
20
|
import { recentGitReads, taskBaseOf } from "../task-base.js";
|
|
21
21
|
import { assignmentPresentationOf, historicalAssessmentReason } from '../assignment-presentation.js';
|
|
22
|
-
import { html, joinHtml } from "../html.js";
|
|
22
|
+
import { html, htmlString, joinHtml } from "../html.js";
|
|
23
23
|
import { assignmentStatusOf, assignmentWithEvidence } from '../assignment-ui.js';
|
|
24
24
|
import { assignmentOf, personCompletionRefusal } from '../assignment.js';
|
|
25
25
|
import { knowledgeContextHtml } from "../knowledge-ui.js";
|
|
@@ -71,6 +71,7 @@ import { reviewEvidenceScript } from "./render-results.js";
|
|
|
71
71
|
import { budgetHoldWords, budgetLabel, monthOf } from "../spend.js";
|
|
72
72
|
import {} from "../store.js";
|
|
73
73
|
import { taskControlOf } from "../task-control.js";
|
|
74
|
+
import { taskLinkFromLegacy, taskLinkOf } from "../task-link.js";
|
|
74
75
|
import { lastErrorLineOf, missedRequirementOf, workStatusOf } from "../workspace-ui.js";
|
|
75
76
|
export function createTaskViews(runtime) {
|
|
76
77
|
const baseGit = recentGitReads();
|
|
@@ -604,7 +605,7 @@ export function createTaskViews(runtime) {
|
|
|
604
605
|
}
|
|
605
606
|
function explainAttempt(run, receipt, readLog = true) {
|
|
606
607
|
const taskId = runtime.store.externalIdFor(run.taskRef) ?? "";
|
|
607
|
-
const page =
|
|
608
|
+
const page = taskLinkOf({ task: taskId, run: run.id });
|
|
608
609
|
const see = taskId === "" ? null : { label: `See build #${run.id}`, href: page };
|
|
609
610
|
const artifacts = runtime.store.artifactsFor(run.id);
|
|
610
611
|
const logArtifact = !readLog ? null : receipt?.checks.status === "failed" && receipt.checks.logArtifactId !== null
|
|
@@ -625,7 +626,7 @@ export function createTaskViews(runtime) {
|
|
|
625
626
|
if (found !== null) {
|
|
626
627
|
const line = oneLineOf(found.text, 140);
|
|
627
628
|
return { kind: "check", line: `The check failed: ${line}`, evidence: null, suggestion: failingCheckSuggestion(line),
|
|
628
|
-
link: taskId === "" ? null : { label: `Check output, line ${found.line}`, href:
|
|
629
|
+
link: taskId === "" ? null : { label: `Check output, line ${found.line}`, href: taskLinkOf({ task: taskId, run: run.id, section: "checks", anchor: `check-log-L${found.line}` }) } };
|
|
629
630
|
}
|
|
630
631
|
}
|
|
631
632
|
const verdict = runtime.store.proofVerdictFor(run.id);
|
|
@@ -654,11 +655,14 @@ export function createTaskViews(runtime) {
|
|
|
654
655
|
const results = new Map(runs.filter(run => runIsTaskResult(run) && (extras.admissible === undefined || extras.admissible.has(run.id))).map(run => [run.id, run.taskId]));
|
|
655
656
|
const tabHref = (taskId, run, section, hash) => `${taskHref(root)}?${taskId !== current ? `version=${encodeURIComponent(taskId)}&` : ""}tab=result${run === null ? "" : `&run=${run}`}${section === null || section === "summary" ? "" : `§ion=${section}`}${hash}`;
|
|
656
657
|
const toTab = (href) => {
|
|
657
|
-
const
|
|
658
|
-
|
|
659
|
-
|
|
658
|
+
const canonical = taskLinkFromLegacy(href) ?? href;
|
|
659
|
+
const result = /^\/t\/([A-Za-z0-9._~%-]{1,200})\?tab=result(?:&run=([0-9]{1,15}))?(?:§ion=(summary|changes|checks))?(#[A-Za-z0-9_.:-]{1,160})?$/.exec(canonical);
|
|
660
|
+
if (result !== null) {
|
|
661
|
+
const named = decodeURIComponent(result[1]);
|
|
662
|
+
const run = result[2] === undefined ? null : Number(result[2]);
|
|
663
|
+
const taskId = run !== null && named === root && results.has(run) ? results.get(run) : named;
|
|
660
664
|
if (versions.has(taskId))
|
|
661
|
-
return tabHref(taskId,
|
|
665
|
+
return tabHref(taskId, run, result[3] ?? null, result[4] ?? "");
|
|
662
666
|
}
|
|
663
667
|
const record = /^\/r\/([0-9]{1,15})$/.exec(href);
|
|
664
668
|
if (record !== null && results.has(Number(record[1])))
|
|
@@ -689,10 +693,10 @@ export function createTaskViews(runtime) {
|
|
|
689
693
|
function taskScreen(response, who, taskId, problem, status, scopeDraft, cancelDraft, editPlan = false, extras = {}) {
|
|
690
694
|
const admittedFamily = runtime.familyOf(taskId);
|
|
691
695
|
if (admittedFamily?.problem != null)
|
|
692
|
-
return runtime.sendScreen(response, status, screen(admittedFamily.root.title, html `<h1>${admittedFamily.root.title}</h1><p>${admittedFamily.current.state}</p><p class="problem" data-history-problem>${admittedFamily.problem}</p
|
|
696
|
+
return runtime.sendScreen(response, status, screen(admittedFamily.root.title, html `<h1>${admittedFamily.root.title}</h1><p>${admittedFamily.current.state}</p><p class="problem" data-history-problem>${admittedFamily.problem}</p>${extras.result == null ? "" : html `<section class="task-result-tab" id="task-result" aria-label="Result" data-result-task="${extras.result.selected.taskId}">${extras.result.html}</section>`}`, { chrome: runtime.chromeFor(admittedFamily.root.repo, "tasks"), ...(extras.result == null ? {} : { functional: { script: `${reviewEvidenceScript()}${RESULT_REVIEW_SCRIPT}` } }) }));
|
|
693
697
|
const data = taskViewData(taskId, who, problem, { mintNonce: requestContext.getStore()?.readPurpose !== "prefetch" });
|
|
694
698
|
if (data === null)
|
|
695
|
-
return refuse(response, who, 404, "no such task", "/
|
|
699
|
+
return refuse(response, who, 404, "no such task", "/");
|
|
696
700
|
const family = runtime.familyOf(taskId);
|
|
697
701
|
const presentedData = { ...data, rootId: family?.root.id ?? taskId, rootTitle: family?.root.title ?? data.task.title,
|
|
698
702
|
...(family === null || data.assignment != null ? {} : { history: familyHistory(family) }),
|
|
@@ -706,6 +710,10 @@ export function createTaskViews(runtime) {
|
|
|
706
710
|
presentedData.cancelDraft = cancelDraft;
|
|
707
711
|
if (editPlan)
|
|
708
712
|
presentedData.editPlan = true;
|
|
713
|
+
const resultSection = extras.result == null ? null
|
|
714
|
+
: html `<section class="task-result-tab" id="task-result" aria-label="Result" data-result-task="${extras.result.selected.taskId}">${extras.result.html}</section>`;
|
|
715
|
+
if (resultSection !== null && extras.result.current)
|
|
716
|
+
presentedData.resultSection = resultSection;
|
|
709
717
|
presentedData.pullRequest = taskPullRequestOf(taskId, who);
|
|
710
718
|
if (family !== null && family.problem === null) {
|
|
711
719
|
presentedData.family = { root: { id: family.root.id, title: family.root.title, createdAt: family.root.createdAt, goal: runtime.store.getScope(family.root.id)?.goal ?? null },
|
|
@@ -749,14 +757,40 @@ export function createTaskViews(runtime) {
|
|
|
749
757
|
}
|
|
750
758
|
if (oneTaskView?.kind === "task")
|
|
751
759
|
oneTaskView.steps = stepRowsOf(oneTaskView);
|
|
752
|
-
if (extras.result != null) {
|
|
753
|
-
|
|
760
|
+
if (oneTaskView?.kind === "task" && extras.result != null && resultSection !== null && !extras.result.current) {
|
|
761
|
+
const rootId = family?.root.id ?? taskId;
|
|
762
|
+
const build = extras.result.selected.build;
|
|
763
|
+
const historical = { label: build === null ? "The task has moved on since." : `Build #${build}. The task has moved on since.`, href: taskHref(rootId) };
|
|
764
|
+
const view = { kind: "task", id: oneTaskView.id, title: oneTaskView.title, project: oneTaskView.project, scout: oneTaskView.scout, tabs: [],
|
|
765
|
+
version: oneTaskView.version, status: null, statusHtml: "", approval: "", lead: [], questions: "", facts: [], sections: [], manage: [], cancel: null, thread: [],
|
|
766
|
+
tab: "result", result: oneTaskView.result ?? null, historical, more: [{ group: "share", label: "Copy link", kind: "copy" }] };
|
|
767
|
+
const top = html `<h1 class="task-main-title">${view.title}</h1><div class="task-historical" data-task-historical><h2>Earlier result</h2><p>${historical.label}</p><p><a class="button-link" href="${historical.href}" data-open-current>Open current work</a></p></div>`;
|
|
768
|
+
page.body = html `${top}${resultSection}`;
|
|
769
|
+
page.functional = { script: `${reviewEvidenceScript()}${RESULT_REVIEW_SCRIPT}`, app: [{ kind: "result" }] };
|
|
770
|
+
page.workspace = { view, pageHtml: top };
|
|
771
|
+
page.refreshSeconds = runtime.liveRefreshSeconds();
|
|
772
|
+
return runtime.sendScreen(response, status, page);
|
|
773
|
+
}
|
|
774
|
+
if (extras.record != null) {
|
|
775
|
+
if (oneTaskView?.kind === "task")
|
|
776
|
+
oneTaskView.sections = [...oneTaskView.sections.filter(one => one.id !== "record"), { id: "record", title: "Record", html: htmlString(extras.record), open: true, count: null }];
|
|
777
|
+
const recordSection = html `<section class="task-record" id="record" aria-label="Record"><h2>Record</h2>${extras.record}</section>`;
|
|
778
|
+
page.body = html `${page.body}${recordSection}`;
|
|
779
|
+
if (page.workspace?.pageHtml != null)
|
|
780
|
+
page.workspace = { ...page.workspace, pageHtml: html `${page.workspace.pageHtml}${recordSection}` };
|
|
781
|
+
}
|
|
782
|
+
const composed = resultSection !== null && page.workspace?.pageHtml != null;
|
|
783
|
+
const taskBody = composed ? page.workspace.pageHtml : page.body;
|
|
784
|
+
if (extras.result != null && resultSection !== null) {
|
|
785
|
+
if (!composed)
|
|
786
|
+
page.body = html `${page.body}${resultSection}`;
|
|
754
787
|
page.functional = withScript(page.functional, { script: `${reviewEvidenceScript()}${RESULT_REVIEW_SCRIPT}`, app: [{ kind: "result" }] });
|
|
755
788
|
}
|
|
789
|
+
const pageHtml = oneTaskView?.kind === "task" && oneTaskView.result != null ? taskBody : page.body;
|
|
756
790
|
if (docked !== null)
|
|
757
|
-
page.workspace = { ...page.workspace, ...(oneTaskView === undefined ? {} : { view: oneTaskView }), conversation: docked, pageHtml
|
|
791
|
+
page.workspace = { ...page.workspace, ...(oneTaskView === undefined ? {} : { view: oneTaskView }), conversation: docked, pageHtml };
|
|
758
792
|
else if (oneTaskView !== undefined && page.workspace !== undefined)
|
|
759
|
-
page.workspace = { ...page.workspace, view: oneTaskView };
|
|
793
|
+
page.workspace = { ...page.workspace, view: oneTaskView, ...(pageHtml === page.body ? {} : { pageHtml }) };
|
|
760
794
|
page.refreshSeconds = runtime.liveRefreshSeconds();
|
|
761
795
|
return runtime.sendScreen(response, status, page);
|
|
762
796
|
}
|