toolroll 0.9.116 → 0.9.117
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 +36 -0
- package/README.md +43 -26
- package/dist/acp-agents.js +14 -1
- package/dist/acp-client.js +19 -1
- package/dist/agent-change-check.js +60 -0
- package/dist/agent-change-schema.js +19 -0
- package/dist/agent-detect.js +11 -1
- package/dist/agent-fence.js +39 -10
- package/dist/agent-network-request.js +108 -0
- package/dist/agent-requests.js +105 -0
- package/dist/approval-summary.js +3 -3
- package/dist/backup.js +17 -1
- package/dist/batch-checks.js +81 -18
- package/dist/browser/terminal.js +41 -41
- package/dist/browser/workspace.css +2 -2
- package/dist/browser/workspace.js +36 -36
- package/dist/builder.js +3 -1
- package/dist/candidate-materialize.js +119 -0
- package/dist/central-enrollment-contract.js +156 -0
- package/dist/central-recovery-stage.js +329 -0
- package/dist/chat-actions.js +101 -2
- package/dist/chat-channel.js +40 -0
- package/dist/check-only-standing.js +13 -0
- package/dist/check-only.js +25 -13
- package/dist/check-recovery-hold.js +199 -0
- package/dist/check-recovery-index-schema.js +3 -0
- package/dist/check-screenshots.js +83 -0
- package/dist/cli.js +125 -6
- package/dist/codex-limits.js +4 -0
- package/dist/connect-cli.js +257 -11
- package/dist/contracts/chat-actions.js +4 -0
- package/dist/contracts/console-api.js +14 -3
- package/dist/contracts/engine-api.js +331 -2
- package/dist/contracts/lead-tools.js +56 -2
- package/dist/contracts/provider.js +1 -1
- package/dist/contracts/route.js +1 -1
- package/dist/contracts/terminal-connection.js +50 -0
- package/dist/converse.js +80 -4
- package/dist/device-pair.js +280 -0
- package/dist/direct-chat-artifacts.js +347 -0
- package/dist/direct-chat-catalog.js +311 -0
- package/dist/direct-chat-fence.js +96 -0
- package/dist/direct-chat-git.js +343 -0
- package/dist/direct-chat-laptop.js +19 -0
- package/dist/direct-chat-schema.js +181 -0
- package/dist/direct-chat-ship.js +861 -0
- package/dist/direct-chat-workspace.js +389 -0
- package/dist/direct-chat.js +2107 -0
- package/dist/doctor.js +1 -1
- package/dist/easy-start.js +18 -0
- package/dist/egress.js +25 -4
- package/dist/engine-chat.js +454 -0
- package/dist/engine-reads.js +141 -13
- package/dist/exec.js +4 -3
- package/dist/flexible-agents.js +8 -16
- package/dist/flexible-session.js +91 -47
- package/dist/flexible-ship.js +87 -7
- package/dist/flexible-start.js +4 -1
- package/dist/flexible-thread.js +2 -3
- package/dist/flexible-turns.js +26 -5
- package/dist/flow-triggers.js +13 -4
- package/dist/flows-ui.js +54 -20
- package/dist/handoff-cli.js +630 -0
- package/dist/invoke.js +55 -13
- package/dist/lead-contract.js +5 -4
- package/dist/lead-doors.js +80 -1
- package/dist/lead-progress.js +9 -0
- package/dist/lead-tools.js +681 -10
- package/dist/lead.js +37 -9
- package/dist/live-bus.js +11 -0
- package/dist/live-terminal.js +132 -12
- package/dist/local-handoff.js +363 -0
- package/dist/local-owner-acts.js +264 -2
- package/dist/local-owner.js +16 -1
- package/dist/multiplayer-handoff.js +528 -0
- package/dist/multiplayer-presence.js +471 -0
- package/dist/names.js +17 -4
- package/dist/needs-you.js +10 -0
- package/dist/operate.js +280 -19
- package/dist/policy.js +2 -2
- package/dist/project-delete-ui.js +18 -11
- package/dist/project-delete.js +65 -4
- package/dist/project-tools.js +1 -1
- package/dist/prompt.js +1 -1
- package/dist/provider-connection.js +2 -0
- package/dist/provider-home.js +251 -8
- package/dist/provider.js +3 -2
- package/dist/publish.js +119 -64
- package/dist/pull-request-flow.js +35 -14
- package/dist/read-executor-worker.js +1 -1
- package/dist/read-executor.js +95 -1
- package/dist/restore-retirement.js +152 -0
- package/dist/result-follow-ups.js +116 -37
- package/dist/route-change.js +44 -4
- package/dist/scope.js +62 -5
- package/dist/serve.js +49 -5
- package/dist/server/chat.js +94 -13
- package/dist/server/direct-chat.js +583 -0
- package/dist/server/engine-api.js +219 -21
- package/dist/server/flows.js +43 -10
- package/dist/server/found-repos.js +25 -0
- package/dist/server/guards.js +20 -6
- package/dist/server/live.js +81 -23
- package/dist/server/pages.js +67 -13
- package/dist/server/people-tokens.js +47 -6
- package/dist/server/remote.js +29 -0
- package/dist/server/render-results.js +6 -2
- package/dist/server/render-settings.js +4 -2
- package/dist/server/render-tasks.js +18 -17
- package/dist/server/route-table.js +69 -2
- package/dist/server/settings.js +22 -7
- package/dist/server/task-views.js +15 -3
- package/dist/server/tasks.js +39 -2
- package/dist/server/terminals.js +185 -11
- package/dist/settings-proofs.js +1 -1
- package/dist/store.js +499 -56
- package/dist/subscription-chat.js +33 -6
- package/dist/subscription-usage.js +233 -0
- package/dist/task-live.js +2 -1
- package/dist/teardown-git.js +34 -4
- package/dist/terminal-connection.js +159 -0
- 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/tui-contract.js +1 -1
- package/dist/tui-launch.js +32 -1
- package/dist/workspace-identity-schema.js +21 -0
- package/package.json +3 -1
package/dist/doctor.js
CHANGED
|
@@ -82,7 +82,7 @@ function reinstallCommand(args) {
|
|
|
82
82
|
const freeform = new Set(["--runner", "--repo", "--token-file", "--pool", "--model", "--repair-model", "--plan-model"]);
|
|
83
83
|
const numeric = new Set(["--max", "--turns", "--tick-every", "--bridge-every", "--reconcile-every", "--max-open-decisions"]);
|
|
84
84
|
const enums = {
|
|
85
|
-
"--provider": ["claude", "codex", "gemini", "openrouter", "opencode", "cursor", "cline", "qwen", "goose"],
|
|
85
|
+
"--provider": ["claude", "codex", "gemini", "openrouter", "opencode", "cursor", "cline", "qwen", "goose", "antigravity"],
|
|
86
86
|
"--plan-provider": ["claude", "codex", "gemini", "openrouter"],
|
|
87
87
|
"--containment": ["observed", "preferred", "required"],
|
|
88
88
|
};
|
package/dist/easy-start.js
CHANGED
|
@@ -188,7 +188,23 @@ export async function runEasyStart(mode, args, seams) {
|
|
|
188
188
|
const session = {
|
|
189
189
|
owned: () => ownedNow() !== null,
|
|
190
190
|
stopped: stoppedOnItsOwn,
|
|
191
|
+
openBuilderPassword: async (task, setup) => {
|
|
192
|
+
const page = `/t/${encodeURIComponent(task)}`;
|
|
193
|
+
const target = new URL(setup ? "/password/set" : `${page}#agents`, url);
|
|
194
|
+
if (setup)
|
|
195
|
+
target.searchParams.set("next", page);
|
|
196
|
+
await seams.openBrowser(target.href);
|
|
197
|
+
return "In the browser, open Agents → Change agents and save the new builder.";
|
|
198
|
+
},
|
|
191
199
|
openBrowser: async (page) => {
|
|
200
|
+
if (page === "projects") {
|
|
201
|
+
await seams.openBrowser(new URL("/projects", url).href);
|
|
202
|
+
return "Opened Projects in your browser.";
|
|
203
|
+
}
|
|
204
|
+
if (page === "lead-providers") {
|
|
205
|
+
await seams.openBrowser(new URL("/settings/lead#lead-config", url).href);
|
|
206
|
+
return "Opened Lead settings in your browser.";
|
|
207
|
+
}
|
|
192
208
|
const opened = await seams.openSignedIn(page);
|
|
193
209
|
return opened.ok ? "Opened in your browser." : `The browser couldn't be opened: ${opened.message}.`;
|
|
194
210
|
},
|
|
@@ -335,6 +351,8 @@ export function defaultEasyStartSeams(options) {
|
|
|
335
351
|
continue;
|
|
336
352
|
return "leave";
|
|
337
353
|
}
|
|
354
|
+
if (end === "central-unavailable")
|
|
355
|
+
return "leave";
|
|
338
356
|
if (end === "changed")
|
|
339
357
|
why = "the terminal workbench changed after it was checked";
|
|
340
358
|
else if (end !== "classic")
|
package/dist/egress.js
CHANGED
|
@@ -69,6 +69,7 @@ export const PROVIDER_HOSTS = {
|
|
|
69
69
|
cline: ["api.cline.bot"],
|
|
70
70
|
qwen: ["chat.qwen.ai", "dashscope.aliyuncs.com", "dashscope-intl.aliyuncs.com"],
|
|
71
71
|
goose: [],
|
|
72
|
+
antigravity: ["daily-cloudcode-pa.googleapis.com", "cloudcode-pa.googleapis.com", "generativelanguage.googleapis.com", "oauth2.googleapis.com", "accounts.google.com"],
|
|
72
73
|
};
|
|
73
74
|
export const REGISTRY_HOSTS = {
|
|
74
75
|
npm: ["registry.npmjs.org", "registry.yarnpkg.com", "repo.yarnpkg.com", "nodejs.org"],
|
|
@@ -135,6 +136,15 @@ export function resolveNetwork(provider, project, ecosystems) {
|
|
|
135
136
|
export function providerOnlyNetwork(provider) {
|
|
136
137
|
return { version: NETWORK_POLICY_VERSION, mode: "allowlist", hosts: [...new Set(PROVIDER_HOSTS[provider] ?? [])].sort(), loopback: "proxy-only" };
|
|
137
138
|
}
|
|
139
|
+
const NEEDS_LOCAL_SERVICES = { antigravity: "Antigravity" };
|
|
140
|
+
export function localServicesRefusal(provider, network, platform = process.platform) {
|
|
141
|
+
const name = NEEDS_LOCAL_SERVICES[provider];
|
|
142
|
+
if (name === undefined || platform !== "darwin")
|
|
143
|
+
return null;
|
|
144
|
+
if (network !== undefined && (network.mode === "open" || network.loopback === "any"))
|
|
145
|
+
return null;
|
|
146
|
+
return `${name} needs to reach its own helper on this Mac, and this project doesn't let builds reach local services, so nothing was started. To use ${name} here, allow local services in the project's network settings, or choose another agent.`;
|
|
147
|
+
}
|
|
138
148
|
export function legacyNetwork(provider, ecosystems) {
|
|
139
149
|
return { ...resolveNetwork(provider, { mode: "allowlist", hosts: [], loopback: "proxy-only" }, ecosystems) };
|
|
140
150
|
}
|
|
@@ -184,11 +194,21 @@ export function unaccountedHosts(network, provider) {
|
|
|
184
194
|
const known = new Set([...(own.length > 0 && own.every(one => network.hosts.includes(one)) ? own : []), ...full.flat()]);
|
|
185
195
|
return network.hosts.filter(one => !known.has(one));
|
|
186
196
|
}
|
|
187
|
-
export function
|
|
197
|
+
export function codexCommandsOffline(profile, platform = process.platform) {
|
|
198
|
+
if (profile.provider !== "codex" && profile.provider !== "openrouter")
|
|
199
|
+
return false;
|
|
200
|
+
if (platform === "darwin")
|
|
201
|
+
return false;
|
|
202
|
+
return !(profile.sandboxMode === "danger-full-access" && profile.network?.mode === "open");
|
|
203
|
+
}
|
|
204
|
+
export function networkWords(network, provider, options) {
|
|
205
|
+
const offlineSuffix = options?.commandsOffline !== true ? ""
|
|
206
|
+
: network?.mode === "open" ? " (Codex commands run offline until Full access is on)"
|
|
207
|
+
: " (Codex commands run offline — set a worktree setup command for dependencies)";
|
|
188
208
|
if (network === null)
|
|
189
|
-
return
|
|
209
|
+
return `Network: approved before network rules (provider and package registries only)${offlineSuffix}`;
|
|
190
210
|
if (network.mode === "open")
|
|
191
|
-
return `Network: open — any host${network.loopback === "proxy-only" ? "" : ", and every local service on this Mac"}`;
|
|
211
|
+
return `Network: open — any host${network.loopback === "proxy-only" ? "" : ", and every local service on this Mac"}${offlineSuffix}`;
|
|
192
212
|
const full = Object.entries(REGISTRY_HOSTS).filter(([, hosts]) => hosts.every(one => network.hosts.includes(one)));
|
|
193
213
|
const own = PROVIDER_HOSTS[provider] ?? [];
|
|
194
214
|
const named = own.length > 0 && own.every(one => network.hosts.includes(one));
|
|
@@ -196,7 +216,8 @@ export function networkWords(network, provider) {
|
|
|
196
216
|
const added = network.hosts.filter(one => !known.has(one));
|
|
197
217
|
const parts = [...(named ? ["the agent's provider"] : []), ...full.map(([name]) => REGISTRY_NAMES[name])];
|
|
198
218
|
return `Network: ${parts.length === 0 && added.length === 0 ? "no hosts" : [parts.join(", "), added.length === 0 ? "" : `${parts.length === 0 ? "" : "and "}${added.join(", ")}`].filter(Boolean).join(", ")}`
|
|
199
|
-
+ (network.loopback === "any" ? "; and every local service on this Mac" : "")
|
|
219
|
+
+ (network.loopback === "any" ? "; and every local service on this Mac" : "")
|
|
220
|
+
+ offlineSuffix;
|
|
200
221
|
}
|
|
201
222
|
const REGISTRY_NAMES = { npm: "npm", python: "PyPI", rust: "crates.io", go: "the Go proxy", ruby: "RubyGems", jvm: "Maven and Gradle" };
|
|
202
223
|
const HOST_LIMIT = 50;
|
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
import { CHAT_ACTIONS, sharedActionNeedsReview, sharedActionPayload, sharedActionReviewPath } from "./chat-actions.js";
|
|
2
|
+
import { cardOfProposal, cardPlainOf, cardsFirst, isCardProposal } from "./chat-card.js";
|
|
3
|
+
import { CHAT_CONTROLS, chatControlHref, isChatControl } from "./chat-controls.js";
|
|
4
|
+
import { CHAT_TASK_ACTIONS, isChatTaskAction } from "./chat-task-actions.js";
|
|
5
|
+
import { isCheckLevel } from "./check-levels.js";
|
|
6
|
+
import { ENGINE_API_VERSION } from "./contracts/engine-api.js";
|
|
7
|
+
import { closedQuestionReason } from "./decision.js";
|
|
8
|
+
import { FLOW_HREF } from "./flow-engine.js";
|
|
9
|
+
import { PROPOSAL_WAIT_REASON } from "./lead-doors.js";
|
|
10
|
+
import { parseFeedbackImage } from "./result-review.js";
|
|
11
|
+
import { shapeReply } from "./reply-shape.js";
|
|
12
|
+
import { taskHref } from "./server/http.js";
|
|
13
|
+
const TASK_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
14
|
+
export function parseLeadLink(label, href) {
|
|
15
|
+
const clean = href.split("#")[0] ?? href;
|
|
16
|
+
const [pathname = "", query = ""] = clean.split("?");
|
|
17
|
+
const params = new URLSearchParams(query);
|
|
18
|
+
if (pathname.startsWith("/t/")) {
|
|
19
|
+
const parts = pathname.slice(3).split("/").filter(Boolean);
|
|
20
|
+
const id = parts[0] ? decodeSafe(parts[0]) : null;
|
|
21
|
+
if (id !== null && TASK_ID_RE.test(id)) {
|
|
22
|
+
const sub = parts[1] ?? null;
|
|
23
|
+
const tab = sub === "diff" ? "diff" : sub === "steps" ? "steps" : null;
|
|
24
|
+
return { label, href, task: id, tab };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (pathname === "/chat") {
|
|
28
|
+
const id = params.get("task");
|
|
29
|
+
if (id !== null && TASK_ID_RE.test(id)) {
|
|
30
|
+
const tab = params.has("result") ? "diff" : null;
|
|
31
|
+
return { label, href, task: id, tab };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return { label, href, task: null, tab: null };
|
|
35
|
+
}
|
|
36
|
+
function decodeSafe(segment) {
|
|
37
|
+
try {
|
|
38
|
+
return decodeURIComponent(segment);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const sentence = (words) => (words === "" ? "" : words.charAt(0).toUpperCase() + words.slice(1));
|
|
45
|
+
function proposalLinesOf(proposal, decision) {
|
|
46
|
+
const payload = proposal.payload;
|
|
47
|
+
const text = (key) => (typeof payload[key] === "string" ? payload[key] : "");
|
|
48
|
+
const task = text("task");
|
|
49
|
+
const repoId = text("repoId");
|
|
50
|
+
const lines = [];
|
|
51
|
+
const push = (value) => {
|
|
52
|
+
const trimmed = value.trim();
|
|
53
|
+
if (trimmed !== "")
|
|
54
|
+
lines.push(trimmed);
|
|
55
|
+
};
|
|
56
|
+
const fact = (key, value) => {
|
|
57
|
+
const trimmed = value.trim();
|
|
58
|
+
if (trimmed !== "")
|
|
59
|
+
lines.push(`${key}: ${trimmed}`);
|
|
60
|
+
};
|
|
61
|
+
const presentations = {
|
|
62
|
+
task: { label: payload["report"] === true ? "Scout investigation" : "New task", action: "File task" },
|
|
63
|
+
next: { label: "Queue priority", action: "Move to front" },
|
|
64
|
+
reserve: { label: "Worker assignment", action: payload["worker"] === null ? "Release" : "Reserve" },
|
|
65
|
+
hold: { label: "Pause work", action: "Hold" },
|
|
66
|
+
unhold: { label: "Resume work", action: "Release hold" },
|
|
67
|
+
steer: { label: "Guidance for the agent", action: "Add guidance" },
|
|
68
|
+
scope: { label: "Plan change", action: "Save plan" },
|
|
69
|
+
answer: { label: "Decision answer", action: "Confirm answer" },
|
|
70
|
+
cancel: { label: "Cancel task", action: "Open task" },
|
|
71
|
+
repair: {
|
|
72
|
+
label: "Task is waiting",
|
|
73
|
+
action: text("operation") === "retry" ? "Try again" : text("operation") === "replace" ? "Wait for another task" : "Continue without it",
|
|
74
|
+
},
|
|
75
|
+
agents: { label: "Agents change", action: "Change agents" },
|
|
76
|
+
review: { label: text("operation") === "revise" ? "Changes to make" : "Note for later", action: text("operation") === "revise" ? "Send back" : "Save for later" },
|
|
77
|
+
control: { label: "Open control", action: "Open" },
|
|
78
|
+
action: { label: text("title") || "Review action", action: sharedActionPayload(payload) ? sentence(CHAT_ACTIONS[sharedActionPayload(payload).operation].label) : "Unavailable" },
|
|
79
|
+
task_action: {
|
|
80
|
+
label: payload["operation"] === "stop" ? "Stop task?" : payload["operation"] === "resume" ? "Resume task?" : "Task update",
|
|
81
|
+
action: isChatTaskAction(payload["operation"]) ? sentence(CHAT_TASK_ACTIONS[payload["operation"]].label) : "Unavailable",
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
const presentation = presentations[proposal.kind];
|
|
85
|
+
let irreversible = false;
|
|
86
|
+
if (proposal.kind === "task") {
|
|
87
|
+
push(text("title"));
|
|
88
|
+
push(text("goal"));
|
|
89
|
+
fact("project", repoId);
|
|
90
|
+
fact("deliverable", payload["report"] === true ? "report only" : "branch");
|
|
91
|
+
const checks = payload["checks"];
|
|
92
|
+
if (isCheckLevel(checks)) {
|
|
93
|
+
fact("checks", { quick: "Quick checks", full: "Full checks", off: "Off — built, not checked" }[checks]);
|
|
94
|
+
}
|
|
95
|
+
fact("out of scope", text("not"));
|
|
96
|
+
if (Array.isArray(payload["touches"]) && payload["touches"].length > 0) {
|
|
97
|
+
fact("may touch", payload["touches"].map(String).join(", "));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else if (proposal.kind === "action") {
|
|
101
|
+
const action = sharedActionPayload(payload);
|
|
102
|
+
if (action === null)
|
|
103
|
+
push("This action is unavailable.");
|
|
104
|
+
else if (action.operation === "task_start") {
|
|
105
|
+
push(action.title);
|
|
106
|
+
fact("project", action.repo.split(/[\\/]/).filter(Boolean).at(-1) ?? action.repo);
|
|
107
|
+
}
|
|
108
|
+
else if (!sharedActionNeedsReview(action)) {
|
|
109
|
+
for (const term of action.terms)
|
|
110
|
+
push(term);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
push("Full terms and confirmation are shown on the review screen.");
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else if (proposal.kind === "task_action") {
|
|
117
|
+
const op = payload["operation"];
|
|
118
|
+
push(text("taskTitle") || task);
|
|
119
|
+
if (op === "stop" || op === "resume")
|
|
120
|
+
push(`${task} · Run #${String(payload["run"] ?? "?")}`);
|
|
121
|
+
push(isChatTaskAction(op) ? CHAT_TASK_ACTIONS[op].detail : "Action unavailable.");
|
|
122
|
+
push(text("dependencyTitle"));
|
|
123
|
+
}
|
|
124
|
+
else if (proposal.kind === "control") {
|
|
125
|
+
const control = payload["control"];
|
|
126
|
+
push(isChatControl(control) ? CHAT_CONTROLS[control].label : "Control unavailable");
|
|
127
|
+
push(text("taskTitle"));
|
|
128
|
+
}
|
|
129
|
+
else if (proposal.kind === "review") {
|
|
130
|
+
push(text("taskTitle") || task);
|
|
131
|
+
const snapshot = payload["snapshot"];
|
|
132
|
+
const ids = Array.isArray(payload["notes"]) ? payload["notes"] : [];
|
|
133
|
+
const selected = snapshot?.notes.filter(one => ids.includes(one.id)) ?? [];
|
|
134
|
+
const notes = [
|
|
135
|
+
...selected,
|
|
136
|
+
...(text("note") === ""
|
|
137
|
+
? []
|
|
138
|
+
: [{ note: text("note"), path: text("path") || null, line: typeof payload["line"] === "number" ? payload["line"] : null, image: parseFeedbackImage(payload["image"]) || null }]),
|
|
139
|
+
];
|
|
140
|
+
for (const one of notes) {
|
|
141
|
+
const where = one.path === null ? "" : `${one.path}${one.line === null ? "" : `:${one.line}`} — `;
|
|
142
|
+
push(`${where}${one.note}`);
|
|
143
|
+
}
|
|
144
|
+
push(text("operation") === "revise" ? "Updates this task. Your approval settings apply." : "No work starts.");
|
|
145
|
+
}
|
|
146
|
+
else if (proposal.kind === "next") {
|
|
147
|
+
push(`Move ${task} to the front`);
|
|
148
|
+
fact("position", `${String(payload["position"] ?? "?")} of ${String(payload["of"] ?? "?")}`);
|
|
149
|
+
fact("project", repoId);
|
|
150
|
+
}
|
|
151
|
+
else if (proposal.kind === "reserve") {
|
|
152
|
+
push(`${payload["worker"] === null ? "Release" : "Reserve"} ${task}`);
|
|
153
|
+
fact("destination", payload["worker"] === null ? "shared queue" : text("worker"));
|
|
154
|
+
fact("project", repoId);
|
|
155
|
+
}
|
|
156
|
+
else if (proposal.kind === "hold") {
|
|
157
|
+
push(`Hold ${task}`);
|
|
158
|
+
push(text("reason"));
|
|
159
|
+
fact("project", repoId);
|
|
160
|
+
}
|
|
161
|
+
else if (proposal.kind === "unhold") {
|
|
162
|
+
push(`Release ${task} from its hold`);
|
|
163
|
+
fact("project", repoId);
|
|
164
|
+
}
|
|
165
|
+
else if (proposal.kind === "steer") {
|
|
166
|
+
const title = text("taskTitle") || task;
|
|
167
|
+
const mode = payload["mode"];
|
|
168
|
+
if (mode === "pause")
|
|
169
|
+
push(`Pause ${title}`);
|
|
170
|
+
else if (mode === "resume")
|
|
171
|
+
push(`Resume ${title}`);
|
|
172
|
+
else if (mode === "pause-and-steer") {
|
|
173
|
+
push(`Pause ${title} and send a note`);
|
|
174
|
+
push(text("note"));
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
push(`Guidance for ${title}`);
|
|
178
|
+
push(text("note"));
|
|
179
|
+
}
|
|
180
|
+
fact("project", repoId);
|
|
181
|
+
}
|
|
182
|
+
else if (proposal.kind === "agents") {
|
|
183
|
+
const title = text("taskTitle") || task;
|
|
184
|
+
const role = text("role");
|
|
185
|
+
const clear = payload["clear"] === true;
|
|
186
|
+
const agentWords = text("provider") === "" ? "" : `${text("provider")} · ${text("model")}`;
|
|
187
|
+
push(role !== "" && !clear ? `Run ${title}'s ${role} on ${agentWords}` : `Change agents for ${title}`);
|
|
188
|
+
push(text("why"));
|
|
189
|
+
fact("agents now", text("before"));
|
|
190
|
+
fact("project", repoId);
|
|
191
|
+
}
|
|
192
|
+
else if (proposal.kind === "scope") {
|
|
193
|
+
push(`Rewrite ${task}`);
|
|
194
|
+
push(text("goal"));
|
|
195
|
+
fact("out of scope", text("not"));
|
|
196
|
+
if (Array.isArray(payload["touches"]) && payload["touches"].length > 0) {
|
|
197
|
+
fact("may touch", payload["touches"].map(String).join(", "));
|
|
198
|
+
}
|
|
199
|
+
fact("project", repoId);
|
|
200
|
+
}
|
|
201
|
+
else if (proposal.kind === "repair") {
|
|
202
|
+
const op = text("operation");
|
|
203
|
+
const title = text("taskTitle") || task;
|
|
204
|
+
const blocker = text("blockerTitle") || text("blocker");
|
|
205
|
+
const replacement = text("replacementTitle") || text("replacement");
|
|
206
|
+
if (op === "retry")
|
|
207
|
+
push(`Try ${blocker} again`);
|
|
208
|
+
else if (op === "replace")
|
|
209
|
+
push(`Have ${title} wait for ${replacement} instead`);
|
|
210
|
+
else
|
|
211
|
+
push(`Let ${title} continue without ${blocker}`);
|
|
212
|
+
fact("project", repoId);
|
|
213
|
+
}
|
|
214
|
+
else if (proposal.kind === "answer") {
|
|
215
|
+
irreversible = payload["reversible"] === false;
|
|
216
|
+
const decisionId = typeof payload["decision"] === "number" ? payload["decision"] : 0;
|
|
217
|
+
push(`Answer decision #${decisionId} on ${task}`);
|
|
218
|
+
if (decision !== null) {
|
|
219
|
+
push(decision.question);
|
|
220
|
+
const pick = text("option");
|
|
221
|
+
for (const opt of decision.options) {
|
|
222
|
+
const tags = [
|
|
223
|
+
opt.reversible ? "" : "irreversible",
|
|
224
|
+
opt.id === decision.recommendation ? "builder recommends" : "",
|
|
225
|
+
opt.id === pick ? "proposed" : "",
|
|
226
|
+
].filter(Boolean);
|
|
227
|
+
push(`• ${opt.label}${tags.length === 0 ? "" : ` (${tags.join(", ")})`} — ${opt.consequence}`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
push("The decision is gone.");
|
|
232
|
+
}
|
|
233
|
+
fact("proposed answer", text("optionLabel"));
|
|
234
|
+
push(text("rationale"));
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
push(`Cancel ${task}`);
|
|
238
|
+
push(text("reason"));
|
|
239
|
+
fact("project", repoId);
|
|
240
|
+
}
|
|
241
|
+
return { label: presentation.label, action: presentation.action, lines, irreversible };
|
|
242
|
+
}
|
|
243
|
+
function projectLeadCard(proposal, inert, decision) {
|
|
244
|
+
const payload = proposal.payload;
|
|
245
|
+
const text = (key) => (typeof payload[key] === "string" ? payload[key] : "");
|
|
246
|
+
const task = text("task");
|
|
247
|
+
if (proposal.kind === "answer" && decision?.supersededReason != null) {
|
|
248
|
+
return {
|
|
249
|
+
id: proposal.id,
|
|
250
|
+
kind: proposal.kind,
|
|
251
|
+
label: "Question closed",
|
|
252
|
+
state: proposal.state,
|
|
253
|
+
data: false,
|
|
254
|
+
lines: [decision.question, closedQuestionReason(decision.supersededReason)],
|
|
255
|
+
card: null,
|
|
256
|
+
said: null,
|
|
257
|
+
note: null,
|
|
258
|
+
primary: null,
|
|
259
|
+
dismissable: false,
|
|
260
|
+
links: [],
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
if (isCardProposal(proposal)) {
|
|
264
|
+
const shown = cardOfProposal(proposal);
|
|
265
|
+
const links = shown?.buttons.map(one => parseLeadLink(one.label, one.path)) ?? [];
|
|
266
|
+
return {
|
|
267
|
+
id: proposal.id,
|
|
268
|
+
kind: proposal.kind,
|
|
269
|
+
label: shown?.title ?? "Card",
|
|
270
|
+
state: "pending",
|
|
271
|
+
data: true,
|
|
272
|
+
lines: shown === null ? [cardPlainOf(proposal)] : [],
|
|
273
|
+
card: shown,
|
|
274
|
+
said: null,
|
|
275
|
+
note: null,
|
|
276
|
+
primary: null,
|
|
277
|
+
dismissable: false,
|
|
278
|
+
links,
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
if (proposal.kind === "control") {
|
|
282
|
+
const control = payload["control"];
|
|
283
|
+
if (isChatControl(control) && proposal.state === "pending" && !inert) {
|
|
284
|
+
const title = text("taskTitle");
|
|
285
|
+
const label = CHAT_CONTROLS[control].label;
|
|
286
|
+
const href = chatControlHref(control, task, payload["run"], payload["project"]);
|
|
287
|
+
const parsed = parseLeadLink(label, href);
|
|
288
|
+
return {
|
|
289
|
+
id: proposal.id,
|
|
290
|
+
kind: proposal.kind,
|
|
291
|
+
label: title === "" ? label : title,
|
|
292
|
+
state: "pending",
|
|
293
|
+
data: false,
|
|
294
|
+
lines: title === "" ? [] : [title],
|
|
295
|
+
card: null,
|
|
296
|
+
said: null,
|
|
297
|
+
note: null,
|
|
298
|
+
primary: { kind: "link", label, href, task: parsed.task, tab: parsed.tab },
|
|
299
|
+
dismissable: false,
|
|
300
|
+
links: [parsed],
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
const { label, action, lines, irreversible } = proposalLinesOf(proposal, decision);
|
|
305
|
+
const outcome = proposal.outcome;
|
|
306
|
+
const said = outcome !== null && typeof outcome.said === "string" ? outcome.said : null;
|
|
307
|
+
const filedTask = outcome !== null && typeof outcome.taskId === "string" ? outcome.taskId : null;
|
|
308
|
+
const flowHref = proposal.state === "confirmed" && outcome !== null && typeof outcome.href === "string" && FLOW_HREF.test(outcome.href) ? outcome.href : null;
|
|
309
|
+
const reviewAction = proposal.kind === "action" ? sharedActionPayload(payload) : null;
|
|
310
|
+
const pending = proposal.state === "pending" && !inert;
|
|
311
|
+
let primary = null;
|
|
312
|
+
if (pending) {
|
|
313
|
+
if (reviewAction !== null && sharedActionNeedsReview(reviewAction)) {
|
|
314
|
+
const href = sharedActionReviewPath(proposal.id);
|
|
315
|
+
const parsed = parseLeadLink(reviewAction.operation === "task_start" ? "Review and start" : "Review action", href);
|
|
316
|
+
primary = { kind: "link", label: parsed.label, href: parsed.href, task: parsed.task, tab: parsed.tab };
|
|
317
|
+
}
|
|
318
|
+
else if (proposal.kind === "control") {
|
|
319
|
+
if (isChatControl(payload["control"])) {
|
|
320
|
+
const href = chatControlHref(payload["control"], task, payload["run"], payload["project"]);
|
|
321
|
+
const parsed = parseLeadLink(CHAT_CONTROLS[payload["control"]].label, href);
|
|
322
|
+
primary = { kind: "link", label: parsed.label, href: parsed.href, task: parsed.task, tab: parsed.tab };
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
else if (proposal.kind === "cancel") {
|
|
326
|
+
const href = taskHref(task);
|
|
327
|
+
const parsed = parseLeadLink("Open task", href);
|
|
328
|
+
primary = { kind: "link", label: parsed.label, href: parsed.href, task: parsed.task, tab: parsed.tab };
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
primary = {
|
|
332
|
+
kind: "confirm",
|
|
333
|
+
label: sentence(action),
|
|
334
|
+
irreversible,
|
|
335
|
+
native: proposal.kind === "task_action" && payload["operation"] === "resume",
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
const links = [];
|
|
340
|
+
if (proposal.state === "confirmed") {
|
|
341
|
+
if (filedTask !== null) {
|
|
342
|
+
links.push(parseLeadLink(proposal.kind === "task" ? "Open the new task" : "Open the task", taskHref(filedTask)));
|
|
343
|
+
}
|
|
344
|
+
if (flowHref !== null) {
|
|
345
|
+
links.push(parseLeadLink("Open the flow", flowHref));
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
else if (task !== "" && TASK_ID_RE.test(task)) {
|
|
349
|
+
links.push(parseLeadLink(`Peek ${task}`, taskHref(task)));
|
|
350
|
+
}
|
|
351
|
+
const note = proposal.state === "pending" && inert
|
|
352
|
+
? PROPOSAL_WAIT_REASON
|
|
353
|
+
: pending && proposal.kind === "cancel"
|
|
354
|
+
? "Cancelling is confirmed on the task itself."
|
|
355
|
+
: proposal.state === "dismissed"
|
|
356
|
+
? "Dismissed."
|
|
357
|
+
: proposal.state === "expired"
|
|
358
|
+
? "Expired — this conversation moved on."
|
|
359
|
+
: null;
|
|
360
|
+
return {
|
|
361
|
+
id: proposal.id,
|
|
362
|
+
kind: proposal.kind,
|
|
363
|
+
label,
|
|
364
|
+
state: proposal.state,
|
|
365
|
+
data: false,
|
|
366
|
+
lines,
|
|
367
|
+
card: null,
|
|
368
|
+
said: proposal.state === "confirmed" || proposal.state === "refused" ? said : null,
|
|
369
|
+
note,
|
|
370
|
+
primary,
|
|
371
|
+
dismissable: pending && proposal.kind !== "control",
|
|
372
|
+
links,
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
export function leadChatOf(input) {
|
|
376
|
+
const inert = input.pending !== null;
|
|
377
|
+
const openAskTurn = inert ? null : input.ask?.turn ?? null;
|
|
378
|
+
const askedBy = new Map();
|
|
379
|
+
let lastAsked;
|
|
380
|
+
for (const m of input.messages) {
|
|
381
|
+
if (m.role === "operator")
|
|
382
|
+
lastAsked = m.text;
|
|
383
|
+
else if (lastAsked !== undefined)
|
|
384
|
+
askedBy.set(m.id, lastAsked);
|
|
385
|
+
}
|
|
386
|
+
let pendingProposals = 0;
|
|
387
|
+
const messages = input.messages.map(m => {
|
|
388
|
+
const cards = m.role === "operator" || m.turn === null
|
|
389
|
+
? []
|
|
390
|
+
: cardsFirst(input.proposals.filter(p => p.turn === m.turn)).map(p => {
|
|
391
|
+
const decision = typeof p.payload["decision"] === "number" ? input.decisions.get(p.payload["decision"]) ?? null : null;
|
|
392
|
+
const card = projectLeadCard(p, inert, decision);
|
|
393
|
+
if (!card.data && card.state === "pending" && card.primary?.kind === "confirm") {
|
|
394
|
+
pendingProposals += 1;
|
|
395
|
+
}
|
|
396
|
+
return card;
|
|
397
|
+
});
|
|
398
|
+
const rawAsk = m.role === "assistant" && m.turn !== null ? input.asks.get(m.turn) ?? null : null;
|
|
399
|
+
const ask = rawAsk === null
|
|
400
|
+
? null
|
|
401
|
+
: {
|
|
402
|
+
turn: rawAsk.turn,
|
|
403
|
+
question: rawAsk.question,
|
|
404
|
+
options: [...rawAsk.options],
|
|
405
|
+
open: rawAsk.turn === openAskTurn,
|
|
406
|
+
stale: rawAsk.turn === input.staleAsk,
|
|
407
|
+
};
|
|
408
|
+
const text = m.role === "assistant"
|
|
409
|
+
? shapeReply(m.text, askedBy.has(m.id) ? { asked: askedBy.get(m.id) } : {})
|
|
410
|
+
: m.text;
|
|
411
|
+
return {
|
|
412
|
+
id: m.id,
|
|
413
|
+
role: m.role,
|
|
414
|
+
text,
|
|
415
|
+
activity: m.activity,
|
|
416
|
+
createdAt: m.createdAt,
|
|
417
|
+
cards,
|
|
418
|
+
ask,
|
|
419
|
+
};
|
|
420
|
+
});
|
|
421
|
+
const queued = [];
|
|
422
|
+
if (input.queue !== undefined) {
|
|
423
|
+
const textById = new Map(input.messages.map(m => [m.id, m.text]));
|
|
424
|
+
for (const row of input.queue.values()) {
|
|
425
|
+
const status = row.status === "queued" ? "queued"
|
|
426
|
+
: row.status === "running" && row.turnId === null ? "starting"
|
|
427
|
+
: row.status === "cancelled" ? "cancelled"
|
|
428
|
+
: row.status === "failed" ? "failed"
|
|
429
|
+
: row.status === "uncertain" ? "uncertain"
|
|
430
|
+
: null;
|
|
431
|
+
if (status === null)
|
|
432
|
+
continue;
|
|
433
|
+
const detail = status === "queued"
|
|
434
|
+
? (row.error?.startsWith("Waiting: ") ? row.error.slice("Waiting: ".length) : "Waiting for your earlier messages…")
|
|
435
|
+
: status === "starting"
|
|
436
|
+
? null
|
|
437
|
+
: row.error ?? (status === "uncertain" ? "Delivery could not be confirmed. Nothing was sent again." : "It was not sent.");
|
|
438
|
+
queued.push({ id: row.message, text: textById.get(row.message) ?? "", status, detail });
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
return {
|
|
442
|
+
version: ENGINE_API_VERSION,
|
|
443
|
+
room: input.room,
|
|
444
|
+
session: input.session,
|
|
445
|
+
leadName: input.leadName,
|
|
446
|
+
canSend: input.canSend,
|
|
447
|
+
problem: input.problem,
|
|
448
|
+
project: input.project,
|
|
449
|
+
busy: inert,
|
|
450
|
+
pendingProposals,
|
|
451
|
+
queued,
|
|
452
|
+
messages,
|
|
453
|
+
};
|
|
454
|
+
}
|