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
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { existsSync, lstatSync, readFileSync } from "node:fs";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
export const DIRECT_CHAT_EFFORTS = Object.freeze(["low", "medium", "high", "xhigh", "max", "ultra"]);
|
|
6
|
+
const CLAUDE_EFFORTS = ["low", "medium", "high", "xhigh", "max"];
|
|
7
|
+
const CODEX_DEFAULT_EFFORTS = ["low", "medium", "high", "xhigh", "max"];
|
|
8
|
+
const GEMINI_DEFAULT_EFFORTS = ["low", "medium", "high", "xhigh"];
|
|
9
|
+
export function normalizeDirectChatEffort(raw, provider) {
|
|
10
|
+
if (typeof raw !== "string")
|
|
11
|
+
return null;
|
|
12
|
+
const lower = raw.trim().toLowerCase();
|
|
13
|
+
if (!DIRECT_CHAT_EFFORTS.includes(lower))
|
|
14
|
+
return null;
|
|
15
|
+
const effort = lower;
|
|
16
|
+
if (provider === "claude" && effort === "ultra")
|
|
17
|
+
return "max";
|
|
18
|
+
if (provider === "gemini" && effort === "ultra")
|
|
19
|
+
return "max";
|
|
20
|
+
return effort;
|
|
21
|
+
}
|
|
22
|
+
function prettyCodexLabel(slug, displayName) {
|
|
23
|
+
if (typeof displayName === "string" && displayName.trim() !== "") {
|
|
24
|
+
const trimmed = displayName.trim();
|
|
25
|
+
if (/[A-Z]/.test(trimmed))
|
|
26
|
+
return trimmed.slice(0, 80);
|
|
27
|
+
}
|
|
28
|
+
return slug
|
|
29
|
+
.split("-")
|
|
30
|
+
.map(part => {
|
|
31
|
+
if (part.toLowerCase() === "gpt")
|
|
32
|
+
return "GPT";
|
|
33
|
+
if (/^[0-9]/.test(part))
|
|
34
|
+
return part;
|
|
35
|
+
return part.charAt(0).toUpperCase() + part.slice(1);
|
|
36
|
+
})
|
|
37
|
+
.join(" ")
|
|
38
|
+
.replace(/^GPT /, "GPT-");
|
|
39
|
+
}
|
|
40
|
+
function prettyClaudeLabel(id) {
|
|
41
|
+
switch (id) {
|
|
42
|
+
case "opus": return "Claude Opus 5.5";
|
|
43
|
+
case "sonnet": return "Claude Sonnet 5.5";
|
|
44
|
+
case "haiku": return "Claude Haiku 5.5";
|
|
45
|
+
case "fable": return "Claude Fable";
|
|
46
|
+
default:
|
|
47
|
+
return id
|
|
48
|
+
.replace(/^claude-/, "Claude ")
|
|
49
|
+
.replace(/-([0-9]+)-([0-9]+)$/, " $1.$2")
|
|
50
|
+
.replace(/-/g, " ")
|
|
51
|
+
.replace(/\b[a-z]/g, c => c.toUpperCase());
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export function readCodexSubscriptionModels(homeDir = homedir()) {
|
|
55
|
+
const path = join(homeDir, ".codex", "models_cache.json");
|
|
56
|
+
try {
|
|
57
|
+
if (!existsSync(path))
|
|
58
|
+
return [];
|
|
59
|
+
if (lstatSync(path).size >= 2_000_000)
|
|
60
|
+
return [];
|
|
61
|
+
const parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
62
|
+
const rawModels = Array.isArray(parsed)
|
|
63
|
+
? parsed
|
|
64
|
+
: (parsed && typeof parsed === "object" && Array.isArray(parsed["models"])
|
|
65
|
+
? parsed["models"]
|
|
66
|
+
: []);
|
|
67
|
+
const out = [];
|
|
68
|
+
const seen = new Set();
|
|
69
|
+
for (const raw of rawModels) {
|
|
70
|
+
if (!raw || typeof raw !== "object")
|
|
71
|
+
continue;
|
|
72
|
+
const entry = raw;
|
|
73
|
+
const slug = typeof entry["slug"] === "string" ? entry["slug"].trim() : "";
|
|
74
|
+
if (slug === "" || seen.has(slug))
|
|
75
|
+
continue;
|
|
76
|
+
if (slug === "codex-auto-review" || entry["visibility"] === "hide")
|
|
77
|
+
continue;
|
|
78
|
+
seen.add(slug);
|
|
79
|
+
const rawLevels = Array.isArray(entry["supported_reasoning_levels"])
|
|
80
|
+
? entry["supported_reasoning_levels"]
|
|
81
|
+
: [];
|
|
82
|
+
const efforts = [];
|
|
83
|
+
for (const lvl of rawLevels) {
|
|
84
|
+
const eff = typeof lvl === "string"
|
|
85
|
+
? lvl
|
|
86
|
+
: (lvl && typeof lvl === "object" && typeof lvl["effort"] === "string"
|
|
87
|
+
? String(lvl["effort"])
|
|
88
|
+
: "");
|
|
89
|
+
const norm = normalizeDirectChatEffort(eff, "codex");
|
|
90
|
+
if (norm && !efforts.includes(norm))
|
|
91
|
+
efforts.push(norm);
|
|
92
|
+
}
|
|
93
|
+
const effectiveEfforts = efforts.length > 0 ? efforts : [...CODEX_DEFAULT_EFFORTS];
|
|
94
|
+
const rawDefault = normalizeDirectChatEffort(typeof entry["default_reasoning_level"] === "string" ? entry["default_reasoning_level"] : null, "codex");
|
|
95
|
+
const defaultEffort = (rawDefault && effectiveEfforts.includes(rawDefault))
|
|
96
|
+
? rawDefault
|
|
97
|
+
: (effectiveEfforts.includes("high") ? "high" : effectiveEfforts[0] ?? null);
|
|
98
|
+
const ctxRaw = entry["context_window"];
|
|
99
|
+
const contextWindow = typeof ctxRaw === "number" && Number.isFinite(ctxRaw) && ctxRaw > 0
|
|
100
|
+
? Math.round(ctxRaw)
|
|
101
|
+
: null;
|
|
102
|
+
const displayName = typeof entry["display_name"] === "string" ? entry["display_name"] : undefined;
|
|
103
|
+
out.push({
|
|
104
|
+
slug,
|
|
105
|
+
label: prettyCodexLabel(slug, displayName),
|
|
106
|
+
efforts: effectiveEfforts,
|
|
107
|
+
defaultEffort,
|
|
108
|
+
contextWindow,
|
|
109
|
+
});
|
|
110
|
+
if (out.length >= 24)
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
return out;
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return [];
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const AGY_EFFORT_ORDER = ["low", "medium", "high", "xhigh", "max"];
|
|
120
|
+
export function parseAgyModelsOutput(stdout) {
|
|
121
|
+
const variantMap = new Map();
|
|
122
|
+
const grouped = new Map();
|
|
123
|
+
const order = [];
|
|
124
|
+
for (const rawLine of stdout.split(/\r?\n/)) {
|
|
125
|
+
const line = rawLine.trim();
|
|
126
|
+
if (line === "" || line.toLowerCase().startsWith("fetching "))
|
|
127
|
+
continue;
|
|
128
|
+
const parts = line.split(/\t+/);
|
|
129
|
+
const rawId = (parts[0] ?? "").trim();
|
|
130
|
+
const rawLabel = (parts[1] ?? "").trim();
|
|
131
|
+
if (rawId === "" || /\s/.test(rawId))
|
|
132
|
+
continue;
|
|
133
|
+
if (rawId.startsWith("claude-"))
|
|
134
|
+
continue;
|
|
135
|
+
const suffixMatch = /^(.+)-(low|medium|high|xhigh|max)$/.exec(rawId);
|
|
136
|
+
if (suffixMatch) {
|
|
137
|
+
const baseId = suffixMatch[1];
|
|
138
|
+
const eff = suffixMatch[2];
|
|
139
|
+
variantMap.set(`${baseId}:${eff}`, rawId);
|
|
140
|
+
const cleanLabel = (rawLabel !== "" ? rawLabel : baseId)
|
|
141
|
+
.replace(/\s*\((?:Low|Medium|High|XHigh|Max)\)\s*$/i, "")
|
|
142
|
+
.trim();
|
|
143
|
+
let entry = grouped.get(baseId);
|
|
144
|
+
if (!entry) {
|
|
145
|
+
entry = {
|
|
146
|
+
id: baseId,
|
|
147
|
+
label: cleanLabel || baseId,
|
|
148
|
+
efforts: [],
|
|
149
|
+
contextWindow: baseId.startsWith("gemini-") ? 1_000_000 : null,
|
|
150
|
+
};
|
|
151
|
+
grouped.set(baseId, entry);
|
|
152
|
+
order.push(baseId);
|
|
153
|
+
}
|
|
154
|
+
if (!entry.efforts.includes(eff))
|
|
155
|
+
entry.efforts.push(eff);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
if (!grouped.has(rawId)) {
|
|
159
|
+
grouped.set(rawId, {
|
|
160
|
+
id: rawId,
|
|
161
|
+
label: rawLabel || rawId,
|
|
162
|
+
efforts: [...GEMINI_DEFAULT_EFFORTS],
|
|
163
|
+
contextWindow: rawId.startsWith("gemini-") ? 1_000_000 : null,
|
|
164
|
+
});
|
|
165
|
+
order.push(rawId);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const models = order.map(id => {
|
|
170
|
+
const g = grouped.get(id);
|
|
171
|
+
const sortedEfforts = [...g.efforts].sort((a, b) => AGY_EFFORT_ORDER.indexOf(a) - AGY_EFFORT_ORDER.indexOf(b));
|
|
172
|
+
const defaultEffort = sortedEfforts.includes("high") ? "high" : (sortedEfforts[0] ?? null);
|
|
173
|
+
return {
|
|
174
|
+
provider: "gemini",
|
|
175
|
+
id: g.id,
|
|
176
|
+
label: g.label,
|
|
177
|
+
efforts: sortedEfforts,
|
|
178
|
+
defaultEffort,
|
|
179
|
+
contextWindow: g.contextWindow,
|
|
180
|
+
};
|
|
181
|
+
});
|
|
182
|
+
return { models, variantMap };
|
|
183
|
+
}
|
|
184
|
+
let cachedAgy = null;
|
|
185
|
+
let agyFetchInFlight = false;
|
|
186
|
+
const AGY_CACHE_TTL_MS = 10 * 60 * 1_000;
|
|
187
|
+
function locateAgyBinary(homeDir = homedir()) {
|
|
188
|
+
for (const candidate of [`${homeDir}/.local/bin/agy`, `${homeDir}/.gemini/bin/agy`, "/opt/homebrew/bin/agy", "/usr/local/bin/agy"]) {
|
|
189
|
+
if (existsSync(candidate))
|
|
190
|
+
return candidate;
|
|
191
|
+
}
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
export function warmAgyCatalog(homeDir = homedir()) {
|
|
195
|
+
if (agyFetchInFlight)
|
|
196
|
+
return;
|
|
197
|
+
if (cachedAgy !== null && Date.now() - cachedAgy.fetchedAt < AGY_CACHE_TTL_MS)
|
|
198
|
+
return;
|
|
199
|
+
const bin = locateAgyBinary(homeDir);
|
|
200
|
+
if (bin === null)
|
|
201
|
+
return;
|
|
202
|
+
agyFetchInFlight = true;
|
|
203
|
+
execFile(bin, ["models"], { timeout: 6_000, maxBuffer: 256 * 1024 }, (err, stdout) => {
|
|
204
|
+
agyFetchInFlight = false;
|
|
205
|
+
if (err || typeof stdout !== "string" || stdout.trim() === "")
|
|
206
|
+
return;
|
|
207
|
+
const parsed = parseAgyModelsOutput(stdout);
|
|
208
|
+
if (parsed.models.length > 0) {
|
|
209
|
+
cachedAgy = { fetchedAt: Date.now(), parsed };
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
export function resolveAgyModelForEffort(modelId, effort) {
|
|
214
|
+
const trimmed = modelId.trim();
|
|
215
|
+
if (trimmed === "")
|
|
216
|
+
return trimmed;
|
|
217
|
+
const eff = effort ?? "high";
|
|
218
|
+
const baseMatch = /^(.+)-(low|medium|high|xhigh|max)$/.exec(trimmed);
|
|
219
|
+
const baseId = baseMatch ? baseMatch[1] : trimmed;
|
|
220
|
+
const variant = cachedAgy?.parsed.variantMap.get(`${baseId}:${eff}`);
|
|
221
|
+
if (variant)
|
|
222
|
+
return variant;
|
|
223
|
+
if (baseId === "gemini-4-neon" || baseId === "gemini-4-hydrogen") {
|
|
224
|
+
const allowed = eff === "max" ? "xhigh" : eff;
|
|
225
|
+
return `${baseId}-${allowed}`;
|
|
226
|
+
}
|
|
227
|
+
if (baseId === "gemini-4-carbon" || baseId === "gemini-4-argon" || baseId === "gemini-3.8-flash") {
|
|
228
|
+
const allowed = (eff === "xhigh" || eff === "max") ? "high" : eff;
|
|
229
|
+
return `${baseId}-${allowed}`;
|
|
230
|
+
}
|
|
231
|
+
return trimmed;
|
|
232
|
+
}
|
|
233
|
+
export function listDirectChatSubscriptionModels(store, homeDir = homedir()) {
|
|
234
|
+
warmAgyCatalog(homeDir);
|
|
235
|
+
const claudeModels = [
|
|
236
|
+
{ provider: "claude", id: "opus", label: "Claude Opus 5.5", efforts: [...CLAUDE_EFFORTS], defaultEffort: "high", contextWindow: 1_000_000 },
|
|
237
|
+
{ provider: "claude", id: "sonnet", label: "Claude Sonnet 5.5", efforts: [...CLAUDE_EFFORTS], defaultEffort: "high", contextWindow: 1_000_000 },
|
|
238
|
+
{ provider: "claude", id: "haiku", label: "Claude Haiku 5.5", efforts: ["low", "medium", "high"], defaultEffort: "medium", contextWindow: 200_000 },
|
|
239
|
+
{ provider: "claude", id: "fable", label: "Claude Fable", efforts: [...CLAUDE_EFFORTS], defaultEffort: "high", contextWindow: 1_000_000 },
|
|
240
|
+
];
|
|
241
|
+
if (store) {
|
|
242
|
+
try {
|
|
243
|
+
const rows = store.handle
|
|
244
|
+
.prepare(`SELECT id, name, context FROM model_seen WHERE source = 'claude' ORDER BY last_seen_at DESC LIMIT 12`)
|
|
245
|
+
.all();
|
|
246
|
+
const seenClaude = new Set(["opus", "sonnet", "haiku", "fable", "claude-opus-5-5", "claude-sonnet-5-5", "claude-haiku-5-5"]);
|
|
247
|
+
for (const row of rows) {
|
|
248
|
+
if (!row.id || seenClaude.has(row.id))
|
|
249
|
+
continue;
|
|
250
|
+
seenClaude.add(row.id);
|
|
251
|
+
claudeModels.push({
|
|
252
|
+
provider: "claude",
|
|
253
|
+
id: row.id,
|
|
254
|
+
label: row.name && row.name.trim() !== "" ? row.name.trim() : prettyClaudeLabel(row.id),
|
|
255
|
+
efforts: [...CLAUDE_EFFORTS],
|
|
256
|
+
defaultEffort: "high",
|
|
257
|
+
contextWindow: typeof row.context === "number" && row.context > 0 ? row.context : 200_000,
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
catch {
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
const codexCache = readCodexSubscriptionModels(homeDir);
|
|
265
|
+
const codexModels = codexCache.length > 0
|
|
266
|
+
? codexCache.map(one => ({
|
|
267
|
+
provider: "codex",
|
|
268
|
+
id: one.slug,
|
|
269
|
+
label: one.label,
|
|
270
|
+
efforts: one.efforts,
|
|
271
|
+
defaultEffort: one.defaultEffort,
|
|
272
|
+
contextWindow: one.contextWindow,
|
|
273
|
+
}))
|
|
274
|
+
: [
|
|
275
|
+
{ provider: "codex", id: "gpt-6.2-sol", label: "GPT-6.2 Sol", efforts: [...CODEX_DEFAULT_EFFORTS, "ultra"], defaultEffort: "high", contextWindow: 500_000 },
|
|
276
|
+
{ provider: "codex", id: "gpt-6.2-astra", label: "GPT-6.2 Astra", efforts: [...CODEX_DEFAULT_EFFORTS, "ultra"], defaultEffort: "high", contextWindow: 272_000 },
|
|
277
|
+
{ provider: "codex", id: "gpt-6-astra", label: "GPT-6 Astra", efforts: [...CODEX_DEFAULT_EFFORTS, "ultra"], defaultEffort: "high", contextWindow: 272_000 },
|
|
278
|
+
{ provider: "codex", id: "gpt-6-sol", label: "GPT-6 Sol", efforts: [...CODEX_DEFAULT_EFFORTS, "ultra"], defaultEffort: "high", contextWindow: 272_000 },
|
|
279
|
+
{ provider: "codex", id: "gpt-6-luna", label: "GPT-6 Luna", efforts: [...CODEX_DEFAULT_EFFORTS], defaultEffort: "high", contextWindow: 272_000 },
|
|
280
|
+
];
|
|
281
|
+
const geminiModels = cachedAgy && cachedAgy.parsed.models.length > 0
|
|
282
|
+
? cachedAgy.parsed.models
|
|
283
|
+
: [
|
|
284
|
+
{ provider: "gemini", id: "gemini-4-neon", label: "Gemini 4 Neon", efforts: ["low", "medium", "high", "xhigh"], defaultEffort: "high", contextWindow: 1_000_000 },
|
|
285
|
+
{ provider: "gemini", id: "gemini-4-carbon", label: "Gemini 4 Carbon", efforts: ["low", "medium", "high"], defaultEffort: "high", contextWindow: 1_000_000 },
|
|
286
|
+
{ provider: "gemini", id: "gemini-4-argon", label: "Gemini 4 Argon", efforts: ["low", "medium", "high"], defaultEffort: "high", contextWindow: 1_000_000 },
|
|
287
|
+
{ provider: "gemini", id: "gemini-4-hydrogen", label: "Gemini 4 Hydrogen", efforts: ["low", "medium", "high", "xhigh"], defaultEffort: "high", contextWindow: 1_000_000 },
|
|
288
|
+
{ provider: "gemini", id: "gemini-3.8-flash", label: "Gemini 3.8 Flash", efforts: ["low", "medium", "high"], defaultEffort: "high", contextWindow: 1_000_000 },
|
|
289
|
+
];
|
|
290
|
+
return [...claudeModels, ...codexModels, ...geminiModels];
|
|
291
|
+
}
|
|
292
|
+
export function defaultContextWindowFor(provider, modelId, homeDir = homedir()) {
|
|
293
|
+
const lower = modelId.trim().toLowerCase();
|
|
294
|
+
if (provider === "claude") {
|
|
295
|
+
if (lower.includes("haiku"))
|
|
296
|
+
return 200_000;
|
|
297
|
+
return 1_000_000;
|
|
298
|
+
}
|
|
299
|
+
if (provider === "codex") {
|
|
300
|
+
const fromCache = readCodexSubscriptionModels(homeDir).find(m => m.slug.toLowerCase() === lower);
|
|
301
|
+
if (fromCache?.contextWindow)
|
|
302
|
+
return fromCache.contextWindow;
|
|
303
|
+
if (lower.includes("6.2-sol") || lower.includes("6.1-sol") || lower.includes("6.1-terra"))
|
|
304
|
+
return 500_000;
|
|
305
|
+
return 272_000;
|
|
306
|
+
}
|
|
307
|
+
if (provider === "gemini") {
|
|
308
|
+
return 1_000_000;
|
|
309
|
+
}
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { mkdtempSync, realpathSync, rmSync } from "node:fs";
|
|
2
|
+
import { homedir, tmpdir } from "node:os";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { fenceFor, FENCE_POLICY_CURRENT, linuxFenceAvailable, macosFenceAvailable, runFolders, taskBoundary, writeAllowlist } from "./agent-fence.js";
|
|
5
|
+
import { proxyEnv, repositoryEcosystems, resolveNetwork, startEgressProxy } from "./egress.js";
|
|
6
|
+
import { readDenyPath } from "./project-sandbox.js";
|
|
7
|
+
import { prepareProtectedStorage, storageRefusalOf } from "./protected-storage.js";
|
|
8
|
+
import { poolRootOf } from "./worktree.js";
|
|
9
|
+
const real = (path) => { try {
|
|
10
|
+
return realpathSync(path);
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return path;
|
|
14
|
+
} };
|
|
15
|
+
export function directChatFence(store) {
|
|
16
|
+
return async (input) => {
|
|
17
|
+
if (!macosFenceAvailable() && !linuxFenceAvailable()) {
|
|
18
|
+
return store.unfencedAgentsAllowed() ? { unfenced: true }
|
|
19
|
+
: { problem: "This computer can't confine the chat's agent (no macOS sandbox, no working bubblewrap), so nothing was started." };
|
|
20
|
+
}
|
|
21
|
+
const databaseFile = store.databaseFile();
|
|
22
|
+
if (databaseFile === null || databaseFile === "" || databaseFile === ":memory:")
|
|
23
|
+
return { problem: "Direct Chat has no state folder to fence, so nothing was started." };
|
|
24
|
+
let clone, gitDir, repo;
|
|
25
|
+
try {
|
|
26
|
+
clone = realpathSync(input.clone);
|
|
27
|
+
gitDir = realpathSync(input.gitDir);
|
|
28
|
+
repo = realpathSync(input.repo);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return { problem: "The chat's workspace couldn't be found, so nothing was started." };
|
|
32
|
+
}
|
|
33
|
+
let storage;
|
|
34
|
+
try {
|
|
35
|
+
storage = await prepareProtectedStorage();
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
return { problem: storageRefusalOf(error)?.message ?? "Toolroll couldn't finish checking other apps' data, so nothing was started." };
|
|
39
|
+
}
|
|
40
|
+
const chats = real(join(input.stateRoot, "direct-chat"));
|
|
41
|
+
const policy = resolveNetwork("claude", store.projectNetwork(input.repo), repositoryEcosystems(input.repo));
|
|
42
|
+
let proxy;
|
|
43
|
+
try {
|
|
44
|
+
proxy = await startEgressProxy(policy.mode === "open" ? { hosts: [], open: true } : { hosts: policy.hosts });
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return { problem: "The chat's network proxy couldn't be started, so nothing was started." };
|
|
48
|
+
}
|
|
49
|
+
let temp = null;
|
|
50
|
+
let closed = null;
|
|
51
|
+
const close = () => closed ??= (async () => {
|
|
52
|
+
const failures = [];
|
|
53
|
+
try {
|
|
54
|
+
await proxy.close();
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
failures.push(`its network proxy didn't close (${error instanceof Error ? error.message : String(error)})`);
|
|
58
|
+
}
|
|
59
|
+
if (temp !== null) {
|
|
60
|
+
try {
|
|
61
|
+
rmSync(temp, { recursive: true, force: true });
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
failures.push(`its temp folder wasn't removed (${error instanceof Error ? error.message : String(error)})`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (failures.length > 0)
|
|
68
|
+
throw new Error(failures.join("; "));
|
|
69
|
+
})();
|
|
70
|
+
try {
|
|
71
|
+
temp = realpathSync(mkdtempSync(join(tmpdir(), "so-net-")));
|
|
72
|
+
const home = homedir();
|
|
73
|
+
const poolRoots = [join(dirname(databaseFile), "worktrees"), ...store.listWorktrees().map(record => poolRootOf(record.path, record.repo))];
|
|
74
|
+
const boundary = taskBoundary({ worktree: clone, provider: "claude", binding: null, policy: FENCE_POLICY_CURRENT, storage });
|
|
75
|
+
const allowed = writeAllowlist({ provider: "claude", home, worktree: clone, binding: null, launchFolder: temp, cache: null });
|
|
76
|
+
const gitReadOnly = ["config", "hooks", "info"].map(name => join(gitDir, name));
|
|
77
|
+
const made = fenceFor("build", {
|
|
78
|
+
databaseFile, worktree: clone, boundary, binding: null, runFolders: runFolders(temp), poolRoots, storage, policy: FENCE_POLICY_CURRENT, provider: "claude",
|
|
79
|
+
extra: [repo, ...allowed.deny],
|
|
80
|
+
readDeny: store.projectSandbox(input.repo).readDeny.map(one => readDenyPath(one, home)),
|
|
81
|
+
writes: { writes: { subpaths: [...allowed.writes.subpaths, gitDir], prefixes: allowed.writes.prefixes }, readOnly: [...allowed.readOnly, ...gitReadOnly] },
|
|
82
|
+
network: { mode: "allowlist", proxyPort: proxy.port, brokerPorts: [], loopback: policy.loopback, socketRoots: [clone, temp], token: proxy.secret },
|
|
83
|
+
});
|
|
84
|
+
const grants = { ...made.fenceGrants, readDenyOnly: [...made.fenceGrants.readDenyOnly ?? [], chats],
|
|
85
|
+
readable: [...made.fenceGrants.readable, clone, gitDir], exactFiles: [...made.fenceGrants.exactFiles ?? [], clone, gitDir] };
|
|
86
|
+
return { launch: { ...made, fenceGrants: grants }, temp, env: { ...proxyEnv(proxy, policy.loopback), TMPDIR: temp, TMP: temp, TEMP: temp, CLAUDE_CODE_TMPDIR: temp }, close };
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
try {
|
|
90
|
+
await close();
|
|
91
|
+
}
|
|
92
|
+
catch { }
|
|
93
|
+
return { problem: `The chat's fence couldn't be made, so nothing was started: ${error instanceof Error ? error.message : String(error)}` };
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|