zelio-cli 0.1.0-beta.5 → 0.1.0-beta.6
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/dist/cli.js +5 -1
- package/dist/cli.js.map +1 -1
- package/dist/db/db.js +31 -0
- package/dist/db/db.js.map +1 -1
- package/dist/orchestrator/area-notes.js +87 -0
- package/dist/orchestrator/area-notes.js.map +1 -0
- package/dist/orchestrator/codex-session.js +10 -9
- package/dist/orchestrator/codex-session.js.map +1 -1
- package/dist/orchestrator/new-task-prompt.js +3 -3
- package/dist/orchestrator/research.js +27 -12
- package/dist/orchestrator/research.js.map +1 -1
- package/dist/orchestrator/retrieval.js +333 -0
- package/dist/orchestrator/retrieval.js.map +1 -0
- package/dist/orchestrator/runtime.js +11 -9
- package/dist/orchestrator/runtime.js.map +1 -1
- package/dist/repo/code-map.js +152 -0
- package/dist/repo/code-map.js.map +1 -0
- package/dist/run/codex-planner-config.js +26 -0
- package/dist/run/codex-planner-config.js.map +1 -0
- package/dist/run/codex-runtime.js +9 -0
- package/dist/run/codex-runtime.js.map +1 -1
- package/dist/run/harnesses.js +5 -0
- package/dist/run/harnesses.js.map +1 -1
- package/dist/run/settings.js +1 -1
- package/dist/run/settings.js.map +1 -1
- package/dist/server/app.js +242 -33
- package/dist/server/app.js.map +1 -1
- package/dist/server/provider-auth.js +206 -0
- package/dist/server/provider-auth.js.map +1 -0
- package/dist/server/terminal.js +2 -2
- package/dist/server/terminal.js.map +1 -1
- package/dist/setup/onboarding.js +7 -12
- package/dist/setup/onboarding.js.map +1 -1
- package/dist/web/assets/index-cF8zhiLs.css +1 -0
- package/dist/web/assets/index-xdwxQJd_.js +255 -0
- package/dist/web/index.html +2 -2
- package/dist/web/sw.js +1 -1
- package/package.json +1 -1
- package/dist/web/assets/index-Bua_eeem.js +0 -255
- package/dist/web/assets/index-Iz1ACqw-.css +0 -1
package/dist/server/app.js
CHANGED
|
@@ -10,9 +10,13 @@ import { checkSkillName, checkSkillText, fetchSkillText, githubSkillLink } from
|
|
|
10
10
|
import { AttachmentError, absoluteAttachments, attachmentPaths, deleteAttachments, imageMime, readAttachmentImages, saveAttachment, sniffImage, } from "../attachments.js";
|
|
11
11
|
import { MAX_IMAGE_BYTES, MAX_MESSAGE_CHARS, PLAN_TURN_DEADLINE_MS } from "../limits.js";
|
|
12
12
|
import { newTaskTurns, summariseTurns } from "../metrics.js";
|
|
13
|
+
import { ProviderKeyError, ProviderSignIns, SignInBusyError, isKeyId, isSignInId, saveProviderKey, } from "./provider-auth.js";
|
|
13
14
|
import { TransitionError, canTransition, checkSpec, describeRefusal, reviewEvidence, } from "../db/lifecycle.js";
|
|
14
15
|
import { MAX_CARDS, OrchestratorError, EMPTY_TURN_STATS, INTAKE_THINKING_CAP, assignIds, cardVerify, fallbackHandoff, keepListedModels, normaliseCard, normaliseQuestions, runOrchestrator, summarizeConversation, } from "../orchestrator/runtime.js";
|
|
15
|
-
import { linkedBoardQuestion, runResearch
|
|
16
|
+
import { linkedBoardQuestion, runResearch } from "../orchestrator/research.js";
|
|
17
|
+
import { SEARCH_QUESTIONS, searchRepo } from "../orchestrator/retrieval.js";
|
|
18
|
+
import { areaQuestion, areasOf, noteFindings, staleArea, } from "../orchestrator/area-notes.js";
|
|
19
|
+
import { buildCodeMap } from "../repo/code-map.js";
|
|
16
20
|
import { describeRepo } from "../repo/linked-boards.js";
|
|
17
21
|
import { ProjectRepoError, validateRepoFolder } from "../repo/project-repos.js";
|
|
18
22
|
import { pickRepoFolder } from "./repo-picker.js";
|
|
@@ -33,7 +37,7 @@ import { consultWatchdog } from "../run/watchdog.js";
|
|
|
33
37
|
import { consultReviewer } from "../run/auto-review.js";
|
|
34
38
|
import { buildCheckFixPrompt, buildCommentPrompt, buildConflictPrompt, buildReviewPrompt, COMMENT_AGENT_PROMPT, CONFLICT_AGENT_PROMPT, REVIEW_AGENT_PROMPT, VERIFIED_CODING_AGENT_PROMPT, } from "../run/prompt.js";
|
|
35
39
|
import { listCodexModels } from "../run/codex-client.js";
|
|
36
|
-
import { HARNESSES, listHarnessModels } from "../run/harnesses.js";
|
|
40
|
+
import { HARNESSES, checkHarnessAuth, checkPiModelAuth, detectHarnesses, installHarness, listHarnessModels, } from "../run/harnesses.js";
|
|
37
41
|
import { profileFor } from "../run/profiles.js";
|
|
38
42
|
import { readSkills, skillBriefs, skillStoreOf } from "../run/skills.js";
|
|
39
43
|
import { asMaxAgents, asPlannerThinking } from "../run/settings.js";
|
|
@@ -136,6 +140,10 @@ class UnknownConversationError extends Error {
|
|
|
136
140
|
const EMPTY_ANSWERS = { decided: [], block: "" };
|
|
137
141
|
/** Repos one intake may send a scout into; more than this is a project, not a card set. */
|
|
138
142
|
const MAX_REPO_SCOUTS = 2;
|
|
143
|
+
/** How often an idle board checks whether HEAD moved and the code map needs the new files. */
|
|
144
|
+
const CODE_MAP_POLL_MS = 30_000;
|
|
145
|
+
/** How long a folder whose note could not be written waits before another try. */
|
|
146
|
+
const NOTE_RETRY_MS = 60 * 60_000;
|
|
139
147
|
/** Answers as they arrive from the panel: anything unreadable is simply not an answer. */
|
|
140
148
|
function asAnswers(value) {
|
|
141
149
|
if (!Array.isArray(value))
|
|
@@ -208,7 +216,7 @@ function applyDecided(cards, decided) {
|
|
|
208
216
|
}
|
|
209
217
|
return out;
|
|
210
218
|
}
|
|
211
|
-
export function createApp({ db, token, port, webRoot, repoRoot, accountAvatarUrl, plan, summarize, harness, setup, listModels, skills: skillStore, plannerThinking, plannerToolBudget, summaryTimeoutMs, runtime, runTimeoutMs, retro, lead, leadEnabled, watchdog, watchdogEnabled, watchdogTickMs, watchdogBackstopMs, autoReview, autoReviewEnabled, redCheckEnabled, testsFirstEnabled, research, researchEnabled, maxRunning, prepare, prepareTicket, agentPath, ghCommand, factsPollMs, retryPolicy, tokenPublishMs, mergePollMs, index: indexOverride, indexOnStart, onRunsChange, voice: voiceOverride, build: buildOption, phone, terminals: terminalOverride, onLiveChange, repoRegistryFile, repoPicker = { available: process.platform === "darwin", pick: pickRepoFolder }, }) {
|
|
219
|
+
export function createApp({ db, token, port, webRoot, repoRoot, accountAvatarUrl, providerAuth, plan, summarize, harness, setup, listModels, skills: skillStore, plannerThinking, plannerToolBudget, summaryTimeoutMs, runtime, runTimeoutMs, retro, lead, leadEnabled, watchdog, watchdogEnabled, watchdogTickMs, watchdogBackstopMs, autoReview, autoReviewEnabled, redCheckEnabled, testsFirstEnabled, research, search, areaNote, areaNotesEnabled, researchEnabled, maxRunning, prepare, prepareTicket, agentPath, ghCommand, factsPollMs, retryPolicy, tokenPublishMs, mergePollMs, index: indexOverride, indexOnStart, onRunsChange, voice: voiceOverride, build: buildOption, phone, terminals: terminalOverride, onLiveChange, repoRegistryFile, repoPicker = { available: process.platform === "darwin", pick: pickRepoFolder }, }) {
|
|
212
220
|
const app = new Hono();
|
|
213
221
|
const auth = createAuth({ token, port });
|
|
214
222
|
const idempotency = createIdempotency(db);
|
|
@@ -296,26 +304,111 @@ export function createApp({ db, token, port, webRoot, repoRoot, accountAvatarUrl
|
|
|
296
304
|
// `researchEnabled`; otherwise an intake never has research to start.
|
|
297
305
|
const researchRunner = research ??
|
|
298
306
|
(researchEnabled
|
|
299
|
-
? (questions, onFinding) => runResearch(questions, {
|
|
307
|
+
? (questions, onFinding, choice) => runResearch(questions, {
|
|
300
308
|
runtime: agentRuntime,
|
|
301
309
|
cwd: root,
|
|
302
310
|
cwdFor: (name) => linkedBoards().find((board) => board.name === name)?.root,
|
|
303
|
-
command: effectiveHarness(),
|
|
304
|
-
model: effectiveDeveloperModel() || undefined,
|
|
311
|
+
command: choice?.command || effectiveHarness(),
|
|
312
|
+
model: choice ? choice.model || undefined : effectiveDeveloperModel() || undefined,
|
|
305
313
|
onFinding,
|
|
306
314
|
})
|
|
307
315
|
: undefined);
|
|
316
|
+
/**
|
|
317
|
+
* The code map, kept against `git HEAD` the way the repo index is. Built when
|
|
318
|
+
* the board starts and refreshed between turns, so a new task's search reads
|
|
319
|
+
* a warm map; a turn that finds HEAD moved waits only for the files that did.
|
|
320
|
+
*/
|
|
321
|
+
let codeMap = null;
|
|
322
|
+
let mapping = null;
|
|
323
|
+
const ensureCodeMap = () => {
|
|
324
|
+
mapping ??= (async () => {
|
|
325
|
+
try {
|
|
326
|
+
if (!codeMap || codeMap.head !== (await readHead(root))) {
|
|
327
|
+
codeMap = await buildCodeMap(root, codeMap);
|
|
328
|
+
}
|
|
329
|
+
return codeMap;
|
|
330
|
+
}
|
|
331
|
+
finally {
|
|
332
|
+
mapping = null;
|
|
333
|
+
}
|
|
334
|
+
})();
|
|
335
|
+
return mapping;
|
|
336
|
+
};
|
|
337
|
+
const searcher = search ??
|
|
338
|
+
(researchEnabled
|
|
339
|
+
? async (description) => searchRepo(description, { root, map: await ensureCodeMap() })
|
|
340
|
+
: undefined);
|
|
341
|
+
const noteWriter = areaNote ??
|
|
342
|
+
(areaNotesEnabled && researchRunner
|
|
343
|
+
? async (area) => {
|
|
344
|
+
const [finding] = await researchRunner([areaQuestion(area)], () => { });
|
|
345
|
+
const note = finding?.error === null ? finding.answer.trim() : "";
|
|
346
|
+
return note || null;
|
|
347
|
+
}
|
|
348
|
+
: undefined);
|
|
349
|
+
// A folder whose scout failed waits this long before it is tried again.
|
|
350
|
+
const noteFailedAt = new Map();
|
|
351
|
+
let noting = false;
|
|
352
|
+
/** At most one note at a time, and never while a person is waiting on a plan. */
|
|
353
|
+
const refreshAreaNote = async (map) => {
|
|
354
|
+
if (!noteWriter || noting || planning)
|
|
355
|
+
return;
|
|
356
|
+
const now = Date.now();
|
|
357
|
+
const areas = areasOf(map).filter((area) => now - (noteFailedAt.get(area.path) ?? 0) >= NOTE_RETRY_MS);
|
|
358
|
+
const area = staleArea(areas, db.listAreaNotes(), now);
|
|
359
|
+
if (!area)
|
|
360
|
+
return;
|
|
361
|
+
noting = true;
|
|
362
|
+
try {
|
|
363
|
+
const note = await noteWriter(area);
|
|
364
|
+
if (note) {
|
|
365
|
+
db.saveAreaNote({
|
|
366
|
+
path: area.path,
|
|
367
|
+
hash: area.hash,
|
|
368
|
+
head: map.head,
|
|
369
|
+
note,
|
|
370
|
+
written_at: new Date().toISOString(),
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
noteFailedAt.set(area.path, Date.now());
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
catch {
|
|
378
|
+
noteFailedAt.set(area.path, Date.now());
|
|
379
|
+
}
|
|
380
|
+
finally {
|
|
381
|
+
noting = false;
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
if (researchEnabled && !search && indexOnStart) {
|
|
385
|
+
void ensureCodeMap().catch(() => undefined);
|
|
386
|
+
// One git call while idle, a rebuild only when an agent's commit moved HEAD,
|
|
387
|
+
// and at most one folder note per tick.
|
|
388
|
+
setInterval(() => {
|
|
389
|
+
if (planning)
|
|
390
|
+
return;
|
|
391
|
+
void ensureCodeMap()
|
|
392
|
+
.then(refreshAreaNote)
|
|
393
|
+
.catch(() => undefined);
|
|
394
|
+
}, CODE_MAP_POLL_MS).unref();
|
|
395
|
+
}
|
|
396
|
+
/** The reading, plus the notes for the folders its search placed the change in. */
|
|
397
|
+
const withNotes = (findings) => findings && [
|
|
398
|
+
...findings,
|
|
399
|
+
...noteFindings(findings.find((finding) => finding.question === SEARCH_QUESTIONS.where), db.listAreaNotes()),
|
|
400
|
+
];
|
|
308
401
|
// Readings started by an intake, keyed by the conversation they belong to. The
|
|
309
402
|
// answer turn takes its own; a reading nobody asks for is dropped after a while.
|
|
310
403
|
const pendingResearch = new Map();
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
return undefined;
|
|
404
|
+
/** One row per reading, like a planner turn, and a TTL so an unanswered one is dropped. */
|
|
405
|
+
const startReading = (conversationId, total, read, choice) => {
|
|
314
406
|
const startedAt = Date.now();
|
|
315
407
|
const reading = {
|
|
316
408
|
promise: Promise.resolve([]),
|
|
317
409
|
done: 0,
|
|
318
|
-
total
|
|
410
|
+
total,
|
|
411
|
+
choice,
|
|
319
412
|
};
|
|
320
413
|
// One row per reading, like a planner turn. It never throws.
|
|
321
414
|
const record = (ok, error) => {
|
|
@@ -336,7 +429,7 @@ export function createApp({ db, token, port, webRoot, repoRoot, accountAvatarUrl
|
|
|
336
429
|
capped: null,
|
|
337
430
|
prompt_chars: 0,
|
|
338
431
|
output_chars: 0,
|
|
339
|
-
questions:
|
|
432
|
+
questions: total,
|
|
340
433
|
cards: 0,
|
|
341
434
|
started_at: new Date(startedAt).toISOString(),
|
|
342
435
|
});
|
|
@@ -345,7 +438,9 @@ export function createApp({ db, token, port, webRoot, repoRoot, accountAvatarUrl
|
|
|
345
438
|
// The log is diagnostics only.
|
|
346
439
|
}
|
|
347
440
|
};
|
|
348
|
-
reading.promise =
|
|
441
|
+
reading.promise = Promise.resolve()
|
|
442
|
+
.then(() => read(reading))
|
|
443
|
+
.then((findings) => {
|
|
349
444
|
record(true, null);
|
|
350
445
|
return findings;
|
|
351
446
|
}, (cause) => {
|
|
@@ -363,23 +458,39 @@ export function createApp({ db, token, port, webRoot, repoRoot, accountAvatarUrl
|
|
|
363
458
|
});
|
|
364
459
|
return reading;
|
|
365
460
|
};
|
|
461
|
+
const startResearch = (conversationId, questions, choice) => researchRunner && questions.length > 0
|
|
462
|
+
? startReading(conversationId, questions.length, (reading) => runReading(reading, questions), choice)
|
|
463
|
+
: undefined;
|
|
464
|
+
/**
|
|
465
|
+
* A new task's reading of this repo: one code search, counted as the three
|
|
466
|
+
* findings it returns. `choice` rides along for the linked-repo scouts an
|
|
467
|
+
* intake may add to the same reading.
|
|
468
|
+
*/
|
|
469
|
+
const startSearch = (conversationId, description, choice) => searcher
|
|
470
|
+
? startReading(conversationId, Object.keys(SEARCH_QUESTIONS).length, async (reading) => {
|
|
471
|
+
const findings = await searcher(description);
|
|
472
|
+
reading.done += findings.length;
|
|
473
|
+
reading.listener?.(reading.done, reading.total);
|
|
474
|
+
return findings;
|
|
475
|
+
}, choice)
|
|
476
|
+
: undefined;
|
|
366
477
|
/** One batch of scouts on a reading; `done` counts across every batch it has. */
|
|
367
478
|
function runReading(reading, questions) {
|
|
368
479
|
return Promise.resolve().then(() => researchRunner(questions, () => {
|
|
369
480
|
reading.done += 1;
|
|
370
481
|
reading.listener?.(reading.done, reading.total);
|
|
371
|
-
}));
|
|
482
|
+
}, reading.choice));
|
|
372
483
|
}
|
|
373
484
|
/**
|
|
374
485
|
* Adds scouts to a reading already under way, for the linked boards the
|
|
375
486
|
* intake named. The answer turn waits for both batches as one reading.
|
|
376
487
|
*/
|
|
377
|
-
const extendResearch = (conversationId, questions) => {
|
|
488
|
+
const extendResearch = (conversationId, questions, choice) => {
|
|
378
489
|
if (!researchRunner || questions.length === 0)
|
|
379
490
|
return;
|
|
380
491
|
const reading = pendingResearch.get(conversationId);
|
|
381
492
|
if (!reading) {
|
|
382
|
-
startResearch(conversationId, questions);
|
|
493
|
+
startResearch(conversationId, questions, choice);
|
|
383
494
|
return;
|
|
384
495
|
}
|
|
385
496
|
reading.total += questions.length;
|
|
@@ -1074,6 +1185,47 @@ export function createApp({ db, token, port, webRoot, repoRoot, accountAvatarUrl
|
|
|
1074
1185
|
effectiveDeveloperModel: effectiveDeveloperModel(),
|
|
1075
1186
|
});
|
|
1076
1187
|
app.get("/api/setup", (c) => c.json({ setup: setupResponse() }));
|
|
1188
|
+
const providerSignIns = new ProviderSignIns(providerAuth?.signIn);
|
|
1189
|
+
const keyDeps = providerAuth?.keys ?? {};
|
|
1190
|
+
app.get("/api/providers", async (c) => {
|
|
1191
|
+
const detected = await detectHarnesses();
|
|
1192
|
+
const installed = Object.fromEntries(detected.map((item) => [item.id, item.installed]));
|
|
1193
|
+
const [claude, openai, piOpenAISubscription, piOpenAIKey, deepseek, googleSubscription, googleApiKey,] = await Promise.all([
|
|
1194
|
+
checkHarnessAuth("claude"),
|
|
1195
|
+
checkHarnessAuth("codex"),
|
|
1196
|
+
checkPiModelAuth("openai-codex/gpt-5"),
|
|
1197
|
+
checkPiModelAuth("openai/gpt-5"),
|
|
1198
|
+
checkPiModelAuth("deepseek/deepseek-chat"),
|
|
1199
|
+
checkPiModelAuth("google-gemini-cli/gemini-2.5-pro"),
|
|
1200
|
+
checkPiModelAuth("google/gemini-2.5-pro"),
|
|
1201
|
+
]);
|
|
1202
|
+
return c.json({
|
|
1203
|
+
providers: {
|
|
1204
|
+
installed,
|
|
1205
|
+
signIns: providerSignIns.snapshot(),
|
|
1206
|
+
claude,
|
|
1207
|
+
openai,
|
|
1208
|
+
piOpenAISubscription,
|
|
1209
|
+
piOpenAIKey,
|
|
1210
|
+
deepseek,
|
|
1211
|
+
googleSubscription,
|
|
1212
|
+
googleApiKey,
|
|
1213
|
+
},
|
|
1214
|
+
});
|
|
1215
|
+
});
|
|
1216
|
+
app.post("/api/providers/pi/install", async (c) => {
|
|
1217
|
+
if (c.get("principal").kind !== "local") {
|
|
1218
|
+
return c.json({ error: "Pi can only be installed from the local board" }, 403);
|
|
1219
|
+
}
|
|
1220
|
+
try {
|
|
1221
|
+
await installHarness("pi");
|
|
1222
|
+
return c.json({ installed: true });
|
|
1223
|
+
}
|
|
1224
|
+
catch (cause) {
|
|
1225
|
+
const message = cause instanceof Error ? cause.message : "Pi installation failed";
|
|
1226
|
+
return c.json({ error: message }, 500);
|
|
1227
|
+
}
|
|
1228
|
+
});
|
|
1077
1229
|
app.put("/api/setup", async (c) => {
|
|
1078
1230
|
const body = await c.req
|
|
1079
1231
|
.json()
|
|
@@ -1322,6 +1474,52 @@ export function createApp({ db, token, port, webRoot, repoRoot, accountAvatarUrl
|
|
|
1322
1474
|
return c.json({ comment }, 201);
|
|
1323
1475
|
});
|
|
1324
1476
|
app.use("/api/*", auth, idempotency);
|
|
1477
|
+
/**
|
|
1478
|
+
* Sign-in and key saves change this machine's credentials, so both are local
|
|
1479
|
+
* only. They sit below the auth registration on purpose: Hono runs handlers in
|
|
1480
|
+
* registration order, so a route above it would never see the principal.
|
|
1481
|
+
*/
|
|
1482
|
+
app.post("/api/providers/:provider/sign-in", async (c) => {
|
|
1483
|
+
if (c.get("principal").kind !== "local") {
|
|
1484
|
+
return c.json({ error: "Sign-in is available from the local board only" }, 403);
|
|
1485
|
+
}
|
|
1486
|
+
const provider = c.req.param("provider");
|
|
1487
|
+
if (!isSignInId(provider))
|
|
1488
|
+
return c.json({ error: "This provider has no sign-in" }, 404);
|
|
1489
|
+
try {
|
|
1490
|
+
return c.json({ signIn: await providerSignIns.start(provider) });
|
|
1491
|
+
}
|
|
1492
|
+
catch (cause) {
|
|
1493
|
+
if (cause instanceof SignInBusyError) {
|
|
1494
|
+
return c.json({ error: cause.message, code: "busy" }, 409);
|
|
1495
|
+
}
|
|
1496
|
+
throw cause;
|
|
1497
|
+
}
|
|
1498
|
+
});
|
|
1499
|
+
app.post("/api/providers/:provider/key", async (c) => {
|
|
1500
|
+
if (c.get("principal").kind !== "local") {
|
|
1501
|
+
return c.json({ error: "API keys are saved from the local board only" }, 403);
|
|
1502
|
+
}
|
|
1503
|
+
const provider = c.req.param("provider");
|
|
1504
|
+
if (!isKeyId(provider))
|
|
1505
|
+
return c.json({ error: "This provider does not take a key" }, 404);
|
|
1506
|
+
const body = await c.req.json().catch(() => ({}));
|
|
1507
|
+
const key = typeof body.key === "string" ? body.key.trim() : "";
|
|
1508
|
+
if (!key)
|
|
1509
|
+
return c.json({ error: "Enter an API key" }, 400);
|
|
1510
|
+
if (key.length > 500 || /\s/.test(key)) {
|
|
1511
|
+
return c.json({ error: "That does not look like an API key. Paste the whole key." }, 400);
|
|
1512
|
+
}
|
|
1513
|
+
try {
|
|
1514
|
+
await saveProviderKey(provider, key, keyDeps);
|
|
1515
|
+
return c.json({ saved: true });
|
|
1516
|
+
}
|
|
1517
|
+
catch (cause) {
|
|
1518
|
+
if (cause instanceof ProviderKeyError)
|
|
1519
|
+
return c.json({ error: cause.message }, cause.status);
|
|
1520
|
+
return c.json({ error: "Could not save the key" }, 500);
|
|
1521
|
+
}
|
|
1522
|
+
});
|
|
1325
1523
|
/**
|
|
1326
1524
|
* Who the caller is and what it may do. The phone uses this to hide controls
|
|
1327
1525
|
* the tunnel allowlist would refuse anyway; the server stays the authority.
|
|
@@ -2230,8 +2428,14 @@ export function createApp({ db, token, port, webRoot, repoRoot, accountAvatarUrl
|
|
|
2230
2428
|
else {
|
|
2231
2429
|
conversation = db.appendMessage("user", said, "message", conversation.id);
|
|
2232
2430
|
}
|
|
2233
|
-
//
|
|
2234
|
-
|
|
2431
|
+
// The reading starts with the request, from the original description only:
|
|
2432
|
+
// a code search here, and scouts for any linked repo the intake names.
|
|
2433
|
+
const intakeReading = mode === "intake"
|
|
2434
|
+
? startSearch(conversation.id, text, plannerChoice(options.harness, options.model))
|
|
2435
|
+
: undefined;
|
|
2436
|
+
// With no linked repo there is nothing for the intake to decide that the
|
|
2437
|
+
// draft cannot: the search has already read, so the first pass is the draft.
|
|
2438
|
+
const merged = mode === "intake" && candidates.length === 0;
|
|
2235
2439
|
// Waiting here is usually free: the index is built at startup and the
|
|
2236
2440
|
// head check is one git call. When it is not free — a first run, or a
|
|
2237
2441
|
// checkout that just changed — the build is minutes of silence with no
|
|
@@ -2288,17 +2492,20 @@ export function createApp({ db, token, port, webRoot, repoRoot, accountAvatarUrl
|
|
|
2288
2492
|
}, conversation.id);
|
|
2289
2493
|
return { saved, questions: next.questions.length, cards: cards.length };
|
|
2290
2494
|
};
|
|
2291
|
-
//
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2495
|
+
// A draft reads what the request started: the merged first pass its own
|
|
2496
|
+
// search, an answer turn what its intake began. The reading stays until it
|
|
2497
|
+
// expires, so a second round of answers or a comment on the draft reads it too.
|
|
2498
|
+
const pass = merged ? "new-task" : mode;
|
|
2499
|
+
if (merged)
|
|
2500
|
+
door = "new-task";
|
|
2501
|
+
const reading = merged
|
|
2502
|
+
? intakeReading
|
|
2503
|
+
: mode === "new-task"
|
|
2504
|
+
? pendingResearch.get(target.id)
|
|
2505
|
+
: undefined;
|
|
2506
|
+
const findings = reading ? withNotes(forDraft(await awaitReading(reading))) : undefined;
|
|
2507
|
+
const drafted = await planOnce(pass, findings);
|
|
2508
|
+
if (pass === "intake") {
|
|
2302
2509
|
// The intake names the repos the work may touch. A scout starts reading
|
|
2303
2510
|
// each one now, so the draft has its findings without asking the person.
|
|
2304
2511
|
const onBoard = new Set(candidates.map((repo) => repo.name));
|
|
@@ -2307,14 +2514,14 @@ export function createApp({ db, token, port, webRoot, repoRoot, accountAvatarUrl
|
|
|
2307
2514
|
const named = [...new Set(drafted.boards ?? [])]
|
|
2308
2515
|
.filter((name) => onBoard.has(name))
|
|
2309
2516
|
.slice(0, MAX_REPO_SCOUTS);
|
|
2310
|
-
extendResearch(conversation.id, named.map((name) => linkedBoardQuestion(name, text)));
|
|
2517
|
+
extendResearch(conversation.id, named.map((name) => linkedBoardQuestion(name, text)), plannerChoice(options.harness, options.model));
|
|
2311
2518
|
}
|
|
2312
2519
|
let outcome;
|
|
2313
|
-
if (
|
|
2520
|
+
if (pass !== "intake") {
|
|
2314
2521
|
outcome = store(drafted);
|
|
2315
2522
|
}
|
|
2316
2523
|
else {
|
|
2317
|
-
//
|
|
2524
|
+
// The reading has been running since the request arrived.
|
|
2318
2525
|
if (normaliseQuestions(drafted.questions).length > 0) {
|
|
2319
2526
|
outcome = store({ ...drafted, cards: [] });
|
|
2320
2527
|
}
|
|
@@ -2322,8 +2529,10 @@ export function createApp({ db, token, port, webRoot, repoRoot, accountAvatarUrl
|
|
|
2322
2529
|
// Nothing to ask and nothing drafted: the intake's row is recorded, then
|
|
2323
2530
|
// the draft waits for the reading in this same request.
|
|
2324
2531
|
measure({ ok: true });
|
|
2325
|
-
|
|
2326
|
-
|
|
2532
|
+
// The map, not `intakeReading`: linked-repo scouts may have started a
|
|
2533
|
+
// reading of their own when this board searches nothing.
|
|
2534
|
+
const started = pendingResearch.get(conversation.id);
|
|
2535
|
+
const readFirst = started ? withNotes(forDraft(await awaitReading(started))) : undefined;
|
|
2327
2536
|
door = "new-task";
|
|
2328
2537
|
rowStartedAt = Date.now();
|
|
2329
2538
|
indexMs = 0;
|