rushes 0.10.1 → 0.12.0
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/.claude-plugin/plugin.json +1 -1
- package/AGENTS.md +14 -4
- package/README.md +14 -8
- package/dist/cli/demo.js +3 -2
- package/dist/cli/main.js +33 -1
- package/dist/core/agentRules.js +7 -0
- package/dist/core/balance.js +238 -0
- package/dist/core/batches.js +29 -11
- package/dist/core/exportNotes.js +4 -2
- package/dist/core/films.js +114 -0
- package/dist/core/log.js +35 -3
- package/dist/core/logEvents.js +7 -7
- package/dist/core/notes.js +19 -1
- package/dist/core/schema.js +69 -14
- package/dist/core/script.js +67 -0
- package/dist/core/tabs.js +15 -7
- package/dist/core/takes.js +1 -1
- package/dist/mcp/tools.js +90 -23
- package/dist/server/agent/adapters.js +39 -8
- package/dist/server/agent/rules.js +106 -9
- package/dist/server/agent/runner.js +135 -35
- package/dist/server/agent/setupOnce.js +44 -0
- package/dist/server/app.js +348 -65
- package/dist/server/assets.js +40 -14
- package/dist/server/balance.js +103 -0
- package/dist/server/brief.js +9 -7
- package/dist/server/files.js +3 -2
- package/dist/server/films.js +43 -0
- package/dist/server/found.js +2 -1
- package/dist/server/logbook.js +28 -2
- package/dist/server/plans.js +68 -0
- package/dist/server/record.js +31 -13
- package/dist/server/start.js +15 -7
- package/dist/server/storyboard.js +8 -6
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/skills/rushes/SKILL.md +4 -4
- package/web-dist/assets/{index-BIJlv6zN.css → index-BCYA0Awp.css} +1 -1
- package/web-dist/assets/index-LPvsS2vO.js +70 -0
- package/web-dist/index.html +2 -2
- package/web-dist/assets/index-D430jOsg.js +0 -70
|
@@ -17,16 +17,17 @@ import { alwaysLabel, decide } from "../../core/agentRules.js";
|
|
|
17
17
|
import { NotFoundError, RushesError } from "../../core/errors.js";
|
|
18
18
|
import { oneLine } from "../../core/labels.js";
|
|
19
19
|
import { lineEvent } from "../../core/logEvents.js";
|
|
20
|
+
import { byFilm } from "../../core/notes.js";
|
|
20
21
|
import { needsYou, noteState, recallNote, recallNotes } from "../../core/noteState.js";
|
|
21
22
|
import { logBookFor } from "../logbook.js";
|
|
22
23
|
import { AcpConnection } from "./acp.js";
|
|
23
|
-
import {
|
|
24
|
+
import { AUTO_FALLBACK, adapterSpec, clientMeta, modeFor, rushesMcp, sessionSetup } from "./adapters.js";
|
|
24
25
|
import { noteToolCall, withSeen } from "./seenCalls.js";
|
|
25
26
|
import { isOwnRushesTool, noteMcpCall } from "./ownTools.js";
|
|
26
27
|
import { PermissionBroker, addRule, allowOutcome, dropRule, toRequest } from "./broker.js";
|
|
27
28
|
import { detectAgents } from "./detect.js";
|
|
28
29
|
import { agentRulesFor } from "./rules.js";
|
|
29
|
-
import { batchJob, followUpFor } from "./followUp.js";
|
|
30
|
+
import { batchJob, batchLabel, followUpFor } from "./followUp.js";
|
|
30
31
|
/** How long the adapter stays up after its last turn (§5.2). */
|
|
31
32
|
export const AGENT_IDLE_MS = 600_000;
|
|
32
33
|
/** How long an adapter may take to start, from spawn to a ready session (a first `npx -y` fetch included). */
|
|
@@ -108,6 +109,8 @@ export class AgentRunner {
|
|
|
108
109
|
* last reported (round 2, item 3).
|
|
109
110
|
*/
|
|
110
111
|
adapters = new WeakMap();
|
|
112
|
+
/** §33: the row the last batch was sent under. A follow-up that has to start the agent again starts it in this one. */
|
|
113
|
+
lastLevel = null;
|
|
111
114
|
mcp;
|
|
112
115
|
idleMs;
|
|
113
116
|
startMs;
|
|
@@ -116,8 +119,6 @@ export class AgentRunner {
|
|
|
116
119
|
/** The user's rules for this project, kept outside it (R10). `rules` is the last read, for the status. */
|
|
117
120
|
rulesFile;
|
|
118
121
|
rules = { permissions: "project-edits", always: [], setUp: false, agent: null };
|
|
119
|
-
/** I3: batches whose hand-over was refused while Send to AI was on (not signed in, not set up…); resend takes each once. */
|
|
120
|
-
refused = new Set();
|
|
121
122
|
ruleReads = 0;
|
|
122
123
|
rulesApplied = 0;
|
|
123
124
|
/** agent.json reads started, and the newest one applied (a write counts as one). */
|
|
@@ -223,24 +224,43 @@ export class AgentRunner {
|
|
|
223
224
|
return this.noteRefusal(batch.id, "park" in r ? { handedTo: null, why: r.why } : r);
|
|
224
225
|
}
|
|
225
226
|
/**
|
|
226
|
-
* I3: hands over a batch whose hand-over was refused, once (the copy dialog's Set up
|
|
227
|
-
* is taken
|
|
228
|
-
* has gone already.
|
|
227
|
+
* I3: hands over a batch whose hand-over was refused, once (Send again, or the copy dialog's Set up through the setup
|
|
228
|
+
* route). The mark is taken off the batch in batches.json under the send lock, so two at once hand it over once, and a
|
|
229
|
+
* restart in between loses nothing. Null when it wasn't refused, or has gone already.
|
|
229
230
|
*/
|
|
230
231
|
async resend(batch) {
|
|
231
|
-
const r = await this.hand(async () =>
|
|
232
|
+
const r = await this.hand(async () => {
|
|
233
|
+
const { result: took } = await this.store.update("batches", (f) => {
|
|
234
|
+
const b = f.batches.find((x) => x.id === batch.id);
|
|
235
|
+
if (!b?.undelivered)
|
|
236
|
+
return false;
|
|
237
|
+
b.undelivered = null;
|
|
238
|
+
return true;
|
|
239
|
+
});
|
|
240
|
+
return took ? batchJob(batch) : null;
|
|
241
|
+
});
|
|
232
242
|
if (r === null)
|
|
233
243
|
return null;
|
|
234
244
|
return this.noteRefusal(batch.id, "park" in r ? { handedTo: null, why: r.why } : r);
|
|
235
245
|
}
|
|
236
246
|
/**
|
|
237
|
-
*
|
|
238
|
-
* still waiting with it (not signed in, not installed), for
|
|
239
|
-
* up, no agent chosen) or was off: the desk offers no Set up for those, and the user may have copied the prompt.
|
|
247
|
+
* Marks a batch refused while Send to AI really was on (the user's agent, switched on) and nothing started, its notes
|
|
248
|
+
* still waiting with it (not signed in, not installed), for Send again. Not one refused because it only looked on (not
|
|
249
|
+
* set up, no agent chosen) or was off: the desk offers no Set up for those, and the user may have copied the prompt.
|
|
250
|
+
* The mark is written to batches.json, so it outlives this server. A failed write is logged, not thrown: the answer to
|
|
251
|
+
* the desk still says why the batch didn't go.
|
|
240
252
|
*/
|
|
241
|
-
noteRefusal(id, r) {
|
|
242
|
-
if (r.handedTo === null && !r.stopped && !r.recalled && r.why !== CLOSING && this.switchedOn(this.settings, this.rules))
|
|
243
|
-
this.
|
|
253
|
+
async noteRefusal(id, r) {
|
|
254
|
+
if (r.handedTo === null && !r.stopped && !r.recalled && r.why !== CLOSING && this.switchedOn(this.settings, this.rules)) {
|
|
255
|
+
const at = this.now().toISOString();
|
|
256
|
+
await this.store
|
|
257
|
+
.update("batches", (f) => {
|
|
258
|
+
const b = f.batches.find((x) => x.id === id);
|
|
259
|
+
if (b)
|
|
260
|
+
b.undelivered = { at, why: r.why };
|
|
261
|
+
})
|
|
262
|
+
.catch((e) => console.error(`Rushes: couldn't mark batch ${id} for Send again: ${messageOf(e)}`));
|
|
263
|
+
}
|
|
244
264
|
return r;
|
|
245
265
|
}
|
|
246
266
|
/**
|
|
@@ -354,6 +374,9 @@ export class AgentRunner {
|
|
|
354
374
|
}
|
|
355
375
|
if (!agent)
|
|
356
376
|
return { why: "No agent chosen" };
|
|
377
|
+
// §33: a Send runs in the row chosen when it was sent. One already running keeps its own.
|
|
378
|
+
if (job.kind === "batch")
|
|
379
|
+
job.level = rules.permissions;
|
|
357
380
|
const info = (await this.detect()).find((a) => a.id === agent);
|
|
358
381
|
if (!info?.installed)
|
|
359
382
|
return park(`${info?.name ?? NAMES[agent]} is not installed`, info?.name ?? NAMES[agent]);
|
|
@@ -374,7 +397,7 @@ export class AgentRunner {
|
|
|
374
397
|
if (!queued && this.conn) {
|
|
375
398
|
// An idle adapter for another agent or another conversation is replaced.
|
|
376
399
|
const kept = settings.session?.id ?? null;
|
|
377
|
-
if (this.info?.id !== info.id || this.sessionId !== kept)
|
|
400
|
+
if (this.info?.id !== info.id || this.sessionId !== kept || this.levelChanged(this.conn, job))
|
|
378
401
|
this.dropConn();
|
|
379
402
|
}
|
|
380
403
|
if (!queued)
|
|
@@ -422,8 +445,9 @@ export class AgentRunner {
|
|
|
422
445
|
let timedOut = false;
|
|
423
446
|
let timer;
|
|
424
447
|
try {
|
|
425
|
-
|
|
426
|
-
this.
|
|
448
|
+
const level = this.startLevel();
|
|
449
|
+
conn = AcpConnection.start(this.specFor(info, root, level));
|
|
450
|
+
this.attach(conn, info.id, level);
|
|
427
451
|
const c = conn;
|
|
428
452
|
const deadline = new Promise((_, reject) => {
|
|
429
453
|
timer = setTimeout(() => {
|
|
@@ -466,7 +490,8 @@ export class AgentRunner {
|
|
|
466
490
|
const settings = await this.loadSettings();
|
|
467
491
|
check();
|
|
468
492
|
const mcp = [this.mcp(root)];
|
|
469
|
-
const
|
|
493
|
+
const level = this.adapters.get(c)?.level ?? "project-edits";
|
|
494
|
+
const setup = sessionSetup(info.id, level);
|
|
470
495
|
const kept = settings.session;
|
|
471
496
|
let sessionId = null;
|
|
472
497
|
let modes = [];
|
|
@@ -498,23 +523,26 @@ export class AgentRunner {
|
|
|
498
523
|
this.applySettings(data);
|
|
499
524
|
}
|
|
500
525
|
check();
|
|
501
|
-
await this.
|
|
526
|
+
await this.agentMode(c, info, sessionId, modes, current, level);
|
|
502
527
|
check();
|
|
503
528
|
if (c.hasExited)
|
|
504
529
|
throw new Error("the adapter exited as it started");
|
|
505
530
|
this.sessionId = sessionId;
|
|
506
531
|
}
|
|
507
532
|
/**
|
|
508
|
-
* R14/R15: every opened or loaded session goes into the mode
|
|
509
|
-
*
|
|
533
|
+
* R14/R15: every opened or loaded session goes into the mode for the row it was started under (§33: ASK_MODE for
|
|
534
|
+
* Manual and Accept edits, in which the agent asks Rushes before it acts; the agent's own for Auto and Bypass), before
|
|
535
|
+
* the first prompt. Fails closed (round 2, item 3): the start fails with a ModeError, and its
|
|
510
536
|
* notes go back, when the mode isn't offered (or no modes are reported), when set_mode throws, or when the
|
|
511
537
|
* session's mode isn't the ask mode afterwards. That mode is the setup response's currentModeId, then the
|
|
512
538
|
* ask mode once set_mode succeeds, unless a current_mode_update during set_mode reports another one (as
|
|
513
539
|
* claude-agent-acp's setSessionMode does when it falls back).
|
|
514
540
|
*/
|
|
515
|
-
async
|
|
516
|
-
const want =
|
|
517
|
-
const refused = new ModeError(`${info.name} could not be put in
|
|
541
|
+
async agentMode(c, info, sessionId, modes, current, level) {
|
|
542
|
+
const want = modeFor(info.id, level);
|
|
543
|
+
const refused = new ModeError(level === "auto" ? `${info.name} could not be put in Auto mode`
|
|
544
|
+
: level === "bypass" ? `${info.name} could not be put in Bypass mode`
|
|
545
|
+
: `${info.name} could not be put in a mode where Rushes approves actions`);
|
|
518
546
|
const adapter = this.adapters.get(c);
|
|
519
547
|
if (!adapter || !modes.includes(want))
|
|
520
548
|
throw refused;
|
|
@@ -530,11 +558,47 @@ export class AgentRunner {
|
|
|
530
558
|
}
|
|
531
559
|
if (!adapter.modeReported)
|
|
532
560
|
adapter.mode = want;
|
|
561
|
+
// Claude's adapter falls back from auto to acceptEdits for a model that can't run auto: commands still ask Rushes.
|
|
562
|
+
const fallback = level === "auto" ? AUTO_FALLBACK[info.id] : undefined;
|
|
563
|
+
if (fallback !== undefined && adapter.mode === fallback) {
|
|
564
|
+
this.addLine(`${info.name} can't use Auto with this model: file edits go through, commands ask here`, null);
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
533
567
|
if (adapter.mode !== want)
|
|
534
568
|
throw refused;
|
|
535
569
|
}
|
|
570
|
+
/**
|
|
571
|
+
* §33: the row the agent starts in: the next batch's (its row when it was sent), else the last batch's, else the rules'
|
|
572
|
+
* row now. A follow-up never starts the agent in Auto or Bypass on its own: only a Send made under that row does.
|
|
573
|
+
*/
|
|
574
|
+
startLevel() {
|
|
575
|
+
const batch = [...(this.turn ? [this.turn.job] : []), ...this.queue].find((j) => j.kind === "batch" && j.level);
|
|
576
|
+
const level = batch?.level ?? this.lastLevel ?? this.rules.permissions;
|
|
577
|
+
if (batch?.level === undefined && this.lastLevel === null && (level === "auto" || level === "bypass"))
|
|
578
|
+
return "project-edits";
|
|
579
|
+
return level;
|
|
580
|
+
}
|
|
581
|
+
/** §33: `job` is a Send made under another row than the one `conn` runs in. */
|
|
582
|
+
levelChanged(conn, job) {
|
|
583
|
+
if (!conn || job?.kind !== "batch" || job.level === undefined)
|
|
584
|
+
return false;
|
|
585
|
+
const running = this.adapters.get(conn)?.level;
|
|
586
|
+
return running !== undefined && running !== job.level;
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* §33: the row an ask is decided by. A batch keeps the row it started in: in Auto or Bypass the agent's own mode
|
|
590
|
+
* already decided, so that row holds. In Manual or Accept edits the row now holds (so a switch to Manual asks at once),
|
|
591
|
+
* except a switch to Auto or Bypass, which applies from the next Send.
|
|
592
|
+
*/
|
|
593
|
+
askLevel(running, now) {
|
|
594
|
+
if (running === "auto" || running === "bypass")
|
|
595
|
+
return running;
|
|
596
|
+
if (now === "auto" || now === "bypass")
|
|
597
|
+
return running ?? "project-edits";
|
|
598
|
+
return now;
|
|
599
|
+
}
|
|
536
600
|
/** Makes `conn` the runner's adapter and listens to it. */
|
|
537
|
-
attach(conn, agent) {
|
|
601
|
+
attach(conn, agent, level) {
|
|
538
602
|
this.conn = conn;
|
|
539
603
|
this.sessionId = null;
|
|
540
604
|
this.live.add(conn);
|
|
@@ -543,7 +607,7 @@ export class AgentRunner {
|
|
|
543
607
|
// Task 10 (3): each adapter's tool calls are followed from announced to run, so a command says it ran only then.
|
|
544
608
|
// Task 10 round 2 (1): every tool call's kind, input and paths, so an ask that lacks them (Codex under AIR) gets them.
|
|
545
609
|
const seen = new Map();
|
|
546
|
-
const adapter = { agent, calls, seen, mode: null, modeReported: false, activity: new ActivityTracker(this.store.root) };
|
|
610
|
+
const adapter = { agent, level, calls, seen, mode: null, modeReported: false, activity: new ActivityTracker(this.store.root) };
|
|
547
611
|
this.adapters.set(conn, adapter);
|
|
548
612
|
conn.on("update", (u) => {
|
|
549
613
|
if (agent === "codex")
|
|
@@ -587,7 +651,8 @@ export class AgentRunner {
|
|
|
587
651
|
const rules = await this.loadRules();
|
|
588
652
|
if (!live())
|
|
589
653
|
return CANCELLED;
|
|
590
|
-
|
|
654
|
+
const level = this.askLevel(adapter?.level, rules.permissions);
|
|
655
|
+
if (decide(toRequest(p, this.store.root), { permissions: level, always: rules.always }, this.store.root) === "allow")
|
|
591
656
|
return allowOutcome(p.options);
|
|
592
657
|
return this.broker.ask(p);
|
|
593
658
|
}
|
|
@@ -636,7 +701,16 @@ export class AgentRunner {
|
|
|
636
701
|
this.ensureStarted().then(() => this.pump(), () => undefined);
|
|
637
702
|
return;
|
|
638
703
|
}
|
|
704
|
+
if (this.levelChanged(conn, this.queue[0])) {
|
|
705
|
+
// §33: the next Send was made under another row. Its mode is set as a session opens, so the agent starts again
|
|
706
|
+
// (the conversation is loaded, as after any restart) before it begins.
|
|
707
|
+
this.dropConn();
|
|
708
|
+
this.ensureStarted().then(() => this.pump(), () => undefined);
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
639
711
|
const job = this.queue.shift();
|
|
712
|
+
if (job.kind === "batch" && job.level)
|
|
713
|
+
this.lastLevel = job.level;
|
|
640
714
|
const gen = this.gen;
|
|
641
715
|
const name = this.info?.name ?? "The agent";
|
|
642
716
|
this.clearIdle();
|
|
@@ -645,7 +719,7 @@ export class AgentRunner {
|
|
|
645
719
|
this.phase = "working";
|
|
646
720
|
this.error = null;
|
|
647
721
|
this.current = { note: null, doing: null };
|
|
648
|
-
this.milestone(job.kind === "batch" ? `${name} started on ${job.label}` : `${name} picked up ${job.label}`);
|
|
722
|
+
this.milestone(job.kind === "batch" ? `${name} started on ${job.label}` : `${name} picked up ${job.label}`, job, (label) => `${name} started on ${label}`);
|
|
649
723
|
this.announce();
|
|
650
724
|
this.track(conn.prompt(sessionId, job.prompt).then((r) => {
|
|
651
725
|
done();
|
|
@@ -662,7 +736,8 @@ export class AgentRunner {
|
|
|
662
736
|
const name = this.info?.name ?? "The agent";
|
|
663
737
|
this.turn = null;
|
|
664
738
|
this.ending = true;
|
|
665
|
-
|
|
739
|
+
const ended = (label) => (stopReason === "end_turn" ? `${name} finished ${label}` : `${name} ended ${label} (${stopReason})`);
|
|
740
|
+
this.milestone(ended(job.label), job, ended);
|
|
666
741
|
this.announce();
|
|
667
742
|
// Still busy while the notes are read, so a send now queues and is picked up below. The phase follows
|
|
668
743
|
// the batch this turn worked on: a question on one of its notes makes it "question".
|
|
@@ -731,7 +806,7 @@ export class AgentRunner {
|
|
|
731
806
|
this.ending = true;
|
|
732
807
|
const queued = this.queue;
|
|
733
808
|
this.queue = [];
|
|
734
|
-
this.milestone(`${name} couldn't finish: ${why}
|
|
809
|
+
this.milestone(`${name} couldn't finish: ${why}`, job);
|
|
735
810
|
this.announce();
|
|
736
811
|
let back = 0;
|
|
737
812
|
try {
|
|
@@ -1004,14 +1079,39 @@ export class AgentRunner {
|
|
|
1004
1079
|
})
|
|
1005
1080
|
.then(() => undefined, (e) => console.error(`Rushes: couldn't give back the notes of ${[...back.batches, ...back.notes.map((n) => n.id)].join(", ")}: ${messageOf(e)}`));
|
|
1006
1081
|
}
|
|
1007
|
-
/**
|
|
1008
|
-
|
|
1082
|
+
/**
|
|
1083
|
+
* An Activity line and a Change Log line, for a run starting, finishing, stopping or failing. §30: with the run's
|
|
1084
|
+
* `job`, the Change Log line is written once per film its notes are on, each with that film, so a film's Activity
|
|
1085
|
+
* never tells another film's work; `say` words a batch's line from that film's own count ("2 notes").
|
|
1086
|
+
*/
|
|
1087
|
+
milestone(text, job, say) {
|
|
1009
1088
|
this.addLine(text, null);
|
|
1010
|
-
this.track(this.writeMilestone(text));
|
|
1089
|
+
this.track(this.writeMilestone(text, job, say));
|
|
1011
1090
|
}
|
|
1012
|
-
writeMilestone(text) {
|
|
1091
|
+
async writeMilestone(text, job, say) {
|
|
1092
|
+
const at = this.now();
|
|
1013
1093
|
// LogBook.add never throws: a line it can't write is reported and counted.
|
|
1014
|
-
|
|
1094
|
+
const book = logBookFor(this.store);
|
|
1095
|
+
const parts = job ? await this.filmParts(job).catch(() => []) : [];
|
|
1096
|
+
if (parts.length === 0)
|
|
1097
|
+
return book.add(lineEvent(text, "notes"), "rushes", at);
|
|
1098
|
+
for (const p of parts)
|
|
1099
|
+
await book.add(lineEvent(say && job?.kind === "batch" ? say(p.label) : text, "notes", { video: p.film }), "rushes", at);
|
|
1100
|
+
return undefined;
|
|
1101
|
+
}
|
|
1102
|
+
/** §30: the films a turn's notes are on, each with the label of its own share of them ("2 notes"). */
|
|
1103
|
+
async filmParts(job) {
|
|
1104
|
+
const notes = await this.store.read("notes");
|
|
1105
|
+
if (job.kind === "followUp")
|
|
1106
|
+
return [{ film: notes.notes.find((n) => n.id === job.note)?.video ?? null, label: job.label }];
|
|
1107
|
+
const b = (await this.store.read("batches")).batches.find((x) => x.id === job.batchId);
|
|
1108
|
+
if (!b)
|
|
1109
|
+
return [];
|
|
1110
|
+
const filmOf = new Map(notes.notes.map((n) => [n.id, n.video ?? null]));
|
|
1111
|
+
const groups = byFilm(b.noteIds, (id) => filmOf.get(id));
|
|
1112
|
+
if (groups.length === 0 || (b.sectionIds.length > 0 && !groups.some(([f]) => f === null)))
|
|
1113
|
+
groups.push([null, []]);
|
|
1114
|
+
return groups.map(([film, ids]) => ({ film, label: batchLabel({ noteIds: ids, sectionIds: film === null ? b.sectionIds : [] }) }));
|
|
1015
1115
|
}
|
|
1016
1116
|
addLine(text, note) {
|
|
1017
1117
|
this.lines.push({ at: this.now().toISOString(), text, note });
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { agentDefaultsFile, agentRulesFor } from "./rules.js";
|
|
2
|
+
const adopted = new WeakMap();
|
|
3
|
+
/**
|
|
4
|
+
* Starts a new project from the Mac-wide default, once per store. Resolves to the rules it wrote, or null when the
|
|
5
|
+
* project had rules already, or there is no default. Never rejects: a failure is logged and the sheet asks as before.
|
|
6
|
+
*/
|
|
7
|
+
export function adoptAgentDefaultsOnce(store) {
|
|
8
|
+
let run = adopted.get(store);
|
|
9
|
+
if (!run) {
|
|
10
|
+
run = adopt(store).catch((e) => {
|
|
11
|
+
console.error(`Rushes: couldn't start Send to AI from your default: ${e.message}`);
|
|
12
|
+
return null;
|
|
13
|
+
});
|
|
14
|
+
adopted.set(store, run);
|
|
15
|
+
}
|
|
16
|
+
return run;
|
|
17
|
+
}
|
|
18
|
+
async function adopt(store) {
|
|
19
|
+
const rules = await agentRulesFor(store).adopt(await agentDefaultsFile().read());
|
|
20
|
+
const id = rules?.agent;
|
|
21
|
+
if (!id)
|
|
22
|
+
return rules;
|
|
23
|
+
await store.update("agent", (f) => {
|
|
24
|
+
// Another agent can't continue this one's conversation.
|
|
25
|
+
if (f.agent !== id) {
|
|
26
|
+
f.agent = id;
|
|
27
|
+
f.session = null;
|
|
28
|
+
}
|
|
29
|
+
f.on = true;
|
|
30
|
+
});
|
|
31
|
+
return rules;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* §32: keeps the user's choice as the Mac-wide default (last choice wins). Never fails the change it follows: the
|
|
35
|
+
* project's own rules are already written, so a default that can't be saved only means the next new project asks.
|
|
36
|
+
*/
|
|
37
|
+
export async function rememberDefault(change, now) {
|
|
38
|
+
try {
|
|
39
|
+
await agentDefaultsFile().set(change, { agent: now.agent, permissions: now.permissions });
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
console.error(`Rushes: couldn't save Send to AI as your default for new projects: ${e.message}`);
|
|
43
|
+
}
|
|
44
|
+
}
|