hinacode 0.2.0-alpha.5 → 0.2.0-alpha.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/out/server/daemon.js +273 -45
- package/package.json +1 -1
package/out/server/daemon.js
CHANGED
|
@@ -13318,6 +13318,9 @@ const unwrap$2 = (channel2) => fromTransform$1((upstream, scope2) => {
|
|
|
13318
13318
|
return channel2.pipe(provide$4(scope2), flatMap$1((channel3) => toTransform(channel3)(upstream, scope2)), flatMap$1((pull_) => pull = pull_));
|
|
13319
13319
|
}));
|
|
13320
13320
|
});
|
|
13321
|
+
const interruptWhen$1 = /* @__PURE__ */ dual(2, (self2, effect2) => merge$3(self2, fromPull$1(succeed$3(flatMap$1(effect2, done$1))), {
|
|
13322
|
+
haltStrategy: "either"
|
|
13323
|
+
}));
|
|
13321
13324
|
const onExit = /* @__PURE__ */ dual(2, (self2, finalizer) => fromTransformBracket((upstream, scope2, forkedScope) => addFinalizerExit(forkedScope, finalizer).pipe(andThen(toTransform(self2)(upstream, scope2)))));
|
|
13322
13325
|
const onEnd$1 = /* @__PURE__ */ dual(2, (self2, onEnd2) => transformPull$1(self2, (pull) => succeed$3(catchDone(pull, (leftover) => flatMap$1(onEnd2, () => done$1(leftover))))));
|
|
13323
13326
|
const ensuring$1 = /* @__PURE__ */ dual(2, (self2, finalizer) => onExit(self2, (_) => finalizer));
|
|
@@ -13812,6 +13815,7 @@ const decodeText$1 = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self2,
|
|
|
13812
13815
|
}));
|
|
13813
13816
|
}));
|
|
13814
13817
|
const splitLines = (self2) => self2.channel.pipe(pipeTo(splitLines$1()), fromChannel);
|
|
13818
|
+
const interruptWhen = /* @__PURE__ */ dual(2, (self2, effect2) => fromChannel(interruptWhen$1(self2.channel, effect2)));
|
|
13815
13819
|
const onEnd = /* @__PURE__ */ dual(2, (self2, onEnd2) => fromChannel(onEnd$1(self2.channel, onEnd2)));
|
|
13816
13820
|
const ensuring = /* @__PURE__ */ dual(2, (self2, finalizer) => fromChannel(ensuring$1(self2.channel, finalizer)));
|
|
13817
13821
|
const provideContext = /* @__PURE__ */ dual(2, (self2, context2) => fromChannel(provideContext$1(self2.channel, context2)));
|
|
@@ -20843,6 +20847,7 @@ const Project = Struct({
|
|
|
20843
20847
|
});
|
|
20844
20848
|
const chatFolder = (chatsRoot, threadId) => `${chatsRoot.replace(/[\\/]+$/, "")}${chatsRoot.includes("\\") ? "\\" : "/"}${threadId}`;
|
|
20845
20849
|
const WorktreeStatus = Literals(["preparing", "ready", "failed", "removed"]);
|
|
20850
|
+
const SetupNotice = Literals(["backgroundOutput", "timedOut"]);
|
|
20846
20851
|
const Worktree = Struct({
|
|
20847
20852
|
id: String$1,
|
|
20848
20853
|
projectId: String$1,
|
|
@@ -21082,6 +21087,7 @@ const Thread = Struct({
|
|
|
21082
21087
|
accountId: NullOr(String$1),
|
|
21083
21088
|
providerSessionId: NullOr(String$1),
|
|
21084
21089
|
forkedFrom: NullOr(ForkPoint).pipe(withDecodingDefaultKey(succeed$3(null))),
|
|
21090
|
+
sideOf: NullOr(String$1).pipe(withDecodingDefaultKey(succeed$3(null))),
|
|
21085
21091
|
status: ThreadStatus,
|
|
21086
21092
|
usageLimit: NullOr(UsageLimit),
|
|
21087
21093
|
sortIndex: Number$1,
|
|
@@ -21778,11 +21784,13 @@ const RpcMethods = {
|
|
|
21778
21784
|
Worktree
|
|
21779
21785
|
),
|
|
21780
21786
|
"worktrees.checkouts": rpc$1(Void2, ArraySchema(WorktreeCheckout)),
|
|
21787
|
+
"worktrees.checkoutState": rpc$1(Struct({ id: String$1 }), CheckoutState),
|
|
21781
21788
|
"worktrees.setupLog": rpc$1(Struct({ id: String$1 }), String$1),
|
|
21782
21789
|
"worktrees.stopSetup": rpc$1(Struct({ id: String$1 }), Void2),
|
|
21783
21790
|
"worktrees.pullRequest": rpc$1(Struct({ id: String$1 }), NullOr(PullRequest)),
|
|
21784
21791
|
"threads.changes": rpc$1(Struct({ threadId: String$1, scope: ChangesScope }), NullOr(Changes)),
|
|
21785
21792
|
"threads.fork": rpc$1(Struct({ threadId: String$1, messageId: String$1 }), Thread),
|
|
21793
|
+
"threads.sidechat": rpc$1(Struct({ threadId: String$1 }), Thread),
|
|
21786
21794
|
"threads.archive": rpc$1(Struct({ threadId: String$1 }), Thread),
|
|
21787
21795
|
"threads.unarchive": rpc$1(Struct({ threadId: String$1 }), Thread),
|
|
21788
21796
|
"projects.currentBranch": rpc$1(Struct({ id: String$1 }), String$1),
|
|
@@ -22077,11 +22085,13 @@ const methodKind = {
|
|
|
22077
22085
|
"worktrees.create": "mutation",
|
|
22078
22086
|
"worktrees.remove": "mutation",
|
|
22079
22087
|
"worktrees.checkouts": "read",
|
|
22088
|
+
"worktrees.checkoutState": "read",
|
|
22080
22089
|
"worktrees.setupLog": "read",
|
|
22081
22090
|
"worktrees.stopSetup": "mutation",
|
|
22082
22091
|
"worktrees.pullRequest": "read",
|
|
22083
22092
|
"threads.changes": "read",
|
|
22084
22093
|
"threads.fork": "mutation",
|
|
22094
|
+
"threads.sidechat": "mutation",
|
|
22085
22095
|
"threads.archive": "mutation",
|
|
22086
22096
|
"threads.unarchive": "mutation",
|
|
22087
22097
|
"projects.currentBranch": "read",
|
|
@@ -22286,6 +22296,12 @@ const PushEvent = Union2([
|
|
|
22286
22296
|
Struct({ type: Literal2("thread.removed"), id: String$1 }),
|
|
22287
22297
|
Struct({ type: Literal2("worktree.updated"), worktree: Worktree }),
|
|
22288
22298
|
Struct({ type: Literal2("worktree.setupLog"), id: String$1, chunk: String$1 }),
|
|
22299
|
+
Struct({
|
|
22300
|
+
type: Literal2("worktree.setupNotice"),
|
|
22301
|
+
id: String$1,
|
|
22302
|
+
branch: String$1,
|
|
22303
|
+
notice: SetupNotice
|
|
22304
|
+
}),
|
|
22289
22305
|
Struct({
|
|
22290
22306
|
type: Literal2("thread.pullRequests"),
|
|
22291
22307
|
threadId: String$1,
|
|
@@ -43294,7 +43310,8 @@ const ActiveWorkspace = Struct({
|
|
|
43294
43310
|
});
|
|
43295
43311
|
const WorkspaceRow = Struct({
|
|
43296
43312
|
...ActiveWorkspace.fields,
|
|
43297
|
-
kind: ProjectKind
|
|
43313
|
+
kind: ProjectKind,
|
|
43314
|
+
folderOwner: String$1
|
|
43298
43315
|
});
|
|
43299
43316
|
const makeActiveWorkspace = gen(function* () {
|
|
43300
43317
|
const sql = yield* SqlClient;
|
|
@@ -43302,7 +43319,8 @@ const makeActiveWorkspace = gen(function* () {
|
|
|
43302
43319
|
Request: String$1,
|
|
43303
43320
|
Result: WorkspaceRow,
|
|
43304
43321
|
execute: (threadId) => sql`
|
|
43305
|
-
SELECT COALESCE(worktree.path, project.root_path) AS cwd, project.root_path, project.kind, worktree.id AS worktree_id, worktree.base_ref
|
|
43322
|
+
SELECT COALESCE(worktree.path, project.root_path) AS cwd, project.root_path, project.kind, worktree.id AS worktree_id, worktree.base_ref,
|
|
43323
|
+
COALESCE(thread.side_of, thread.id) AS folder_owner
|
|
43306
43324
|
FROM thread
|
|
43307
43325
|
JOIN project ON project.id = thread.project_id
|
|
43308
43326
|
LEFT JOIN worktree ON worktree.id = thread.worktree_id AND worktree.status != 'removed'
|
|
@@ -43314,8 +43332,8 @@ const makeActiveWorkspace = gen(function* () {
|
|
|
43314
43332
|
flatMap$1(
|
|
43315
43333
|
match$4({
|
|
43316
43334
|
onNone: () => fail$2(new NotFoundError({ entity: "thread", id: threadId })),
|
|
43317
|
-
onSome: ({ kind, ...workspace }) => {
|
|
43318
|
-
const folder = chatFolder(workspace.rootPath,
|
|
43335
|
+
onSome: ({ kind, folderOwner, ...workspace }) => {
|
|
43336
|
+
const folder = chatFolder(workspace.rootPath, folderOwner);
|
|
43319
43337
|
return succeed$3(kind === "chats" ? { ...workspace, cwd: folder, rootPath: folder } : workspace);
|
|
43320
43338
|
}
|
|
43321
43339
|
})
|
|
@@ -54113,7 +54131,8 @@ const mockScenarios = [
|
|
|
54113
54131
|
"markdown",
|
|
54114
54132
|
"stream",
|
|
54115
54133
|
"activity",
|
|
54116
|
-
"approvals"
|
|
54134
|
+
"approvals",
|
|
54135
|
+
"long-turn"
|
|
54117
54136
|
];
|
|
54118
54137
|
const commands = [
|
|
54119
54138
|
{
|
|
@@ -54217,6 +54236,18 @@ const activityTurn = () => [
|
|
|
54217
54236
|
"Command running in background with ID: shell-2"
|
|
54218
54237
|
)
|
|
54219
54238
|
];
|
|
54239
|
+
const longTurn = () => Array.from({ length: 400 }, (_, index) => [
|
|
54240
|
+
{ type: "reasoning_delta", text: `Step ${index}. ${markdownFixture.slice(0, 400)}` },
|
|
54241
|
+
...toolCall(
|
|
54242
|
+
`long-bash-${index}`,
|
|
54243
|
+
"Bash",
|
|
54244
|
+
{ command: `pnpm vitest run step-${index}.test.ts`, description: `Run step ${index}` },
|
|
54245
|
+
markdownFixture.repeat(3).slice(0, 4e3)
|
|
54246
|
+
),
|
|
54247
|
+
...index % 16 === 0 ? [{ type: "text_delta", text: `Step ${index} passes.
|
|
54248
|
+
|
|
54249
|
+
` }] : []
|
|
54250
|
+
]).flat();
|
|
54220
54251
|
const activityShells = () => [
|
|
54221
54252
|
{ id: "shell-1", kind: "shell", label: "Start the dev server", startedAt: (/* @__PURE__ */ new Date()).toISOString() },
|
|
54222
54253
|
{ id: "shell-2", kind: "shell", label: "Watch the unit tests", startedAt: (/* @__PURE__ */ new Date()).toISOString() }
|
|
@@ -54282,6 +54313,16 @@ const usageLimitLayer = (scenario = "usage-limit", resetAfterMs = 6e4) => effect
|
|
|
54282
54313
|
fromEffect(_await(interrupted).pipe(as$1(ended)))
|
|
54283
54314
|
);
|
|
54284
54315
|
}
|
|
54316
|
+
if (scenario === "long-turn") {
|
|
54317
|
+
const interrupted = makeUnsafe$9();
|
|
54318
|
+
heldTurns.set(input.threadId, interrupted);
|
|
54319
|
+
const ended = { type: "turn_failed", message: "Interrupted" };
|
|
54320
|
+
const streaming = tick("100 millis").pipe(
|
|
54321
|
+
map(() => ({ type: "text_delta", text: "streaming " })),
|
|
54322
|
+
interruptWhen(_await(interrupted))
|
|
54323
|
+
);
|
|
54324
|
+
return fromIterable(longTurn()).pipe(concat(streaming), concat(make$1k(ended)));
|
|
54325
|
+
}
|
|
54285
54326
|
if (scenario === "approvals") {
|
|
54286
54327
|
const approval = (title, command) => {
|
|
54287
54328
|
const id2 = `mock-approval-${++requestCount}`;
|
|
@@ -58278,6 +58319,11 @@ const migrate = (tailscale) => gen(function* () {
|
|
|
58278
58319
|
renameSync(temp, path2);
|
|
58279
58320
|
});
|
|
58280
58321
|
const listenersPickInterface = suspend$2(() => migrate(tailscaleAddress()));
|
|
58322
|
+
const sideChat = gen(function* () {
|
|
58323
|
+
const sql = yield* SqlClient;
|
|
58324
|
+
yield* sql`ALTER TABLE thread ADD COLUMN side_of TEXT REFERENCES thread(id) ON DELETE CASCADE`;
|
|
58325
|
+
yield* sql`CREATE UNIQUE INDEX thread_side_of ON thread (side_of)`;
|
|
58326
|
+
});
|
|
58281
58327
|
const archiveSharedChats = gen(function* () {
|
|
58282
58328
|
const sql = yield* SqlClient;
|
|
58283
58329
|
yield* sql`
|
|
@@ -58315,7 +58361,8 @@ const runMigrations = run$2({
|
|
|
58315
58361
|
"26_fork": fork,
|
|
58316
58362
|
"27_settings_files": settingsFiles,
|
|
58317
58363
|
"28_thread_device": threadDevice,
|
|
58318
|
-
"29_listeners_pick_interface": listenersPickInterface
|
|
58364
|
+
"29_listeners_pick_interface": listenersPickInterface,
|
|
58365
|
+
"30_side_chat": sideChat
|
|
58319
58366
|
})
|
|
58320
58367
|
}).pipe(
|
|
58321
58368
|
tap$2(
|
|
@@ -58452,6 +58499,7 @@ const routes = {
|
|
|
58452
58499
|
"threads.switchAccount": owner("thread", "id"),
|
|
58453
58500
|
"threads.changes": thread,
|
|
58454
58501
|
"threads.fork": thread,
|
|
58502
|
+
"threads.sidechat": thread,
|
|
58455
58503
|
"threads.archive": thread,
|
|
58456
58504
|
"threads.unarchive": thread,
|
|
58457
58505
|
"threads.transcript": thread,
|
|
@@ -58493,6 +58541,7 @@ const routes = {
|
|
|
58493
58541
|
"attachments.stage": thread,
|
|
58494
58542
|
"attachments.read": named,
|
|
58495
58543
|
"worktrees.remove": owner("worktree", "id"),
|
|
58544
|
+
"worktrees.checkoutState": owner("worktree", "id"),
|
|
58496
58545
|
"worktrees.setupLog": owner("worktree", "id"),
|
|
58497
58546
|
"worktrees.stopSetup": owner("worktree", "id"),
|
|
58498
58547
|
"worktrees.pullRequest": owner("worktree", "id"),
|
|
@@ -59043,16 +59092,15 @@ const renderMessage$1 = (message2, room) => {
|
|
|
59043
59092
|
if (dropped > 0) lines.unshift(`[${dropped} earlier tool calls and edits left out]`);
|
|
59044
59093
|
return lines.length === 0 ? null : { text: [`## ${message2.role}`, ...lines].join("\n"), activityTokens };
|
|
59045
59094
|
};
|
|
59046
|
-
function
|
|
59047
|
-
const
|
|
59048
|
-
const opening = input.messages.find((message2) => message2.role === "user");
|
|
59095
|
+
function renderTranscript(messages, budget = HANDOFF_TOKENS) {
|
|
59096
|
+
const opening = messages.find((message2) => message2.role === "user");
|
|
59049
59097
|
const openingText = opening === void 0 ? null : renderMessage$1(opening, 0)?.text ?? null;
|
|
59050
59098
|
const openingKept = openingText === null || estimateTokens(openingText) <= budget / 8 ? openingText : `${head(openingText, budget / 8)}…`;
|
|
59051
59099
|
const kept = [];
|
|
59052
59100
|
let used = openingKept === null ? 0 : estimateTokens(openingKept);
|
|
59053
59101
|
let activityUsed = 0;
|
|
59054
59102
|
let omitted = 0;
|
|
59055
|
-
for (const message2 of
|
|
59103
|
+
for (const message2 of messages.toReversed()) {
|
|
59056
59104
|
if (message2 === opening) continue;
|
|
59057
59105
|
const rendered = renderMessage$1(message2, budget / 4 - activityUsed);
|
|
59058
59106
|
if (rendered === null) continue;
|
|
@@ -59068,12 +59116,14 @@ function handoffPrompt(input) {
|
|
|
59068
59116
|
used += tokens;
|
|
59069
59117
|
activityUsed += rendered.activityTokens;
|
|
59070
59118
|
}
|
|
59071
|
-
|
|
59072
|
-
const transcript = [
|
|
59119
|
+
return [
|
|
59073
59120
|
...openingKept === null ? [] : [openingKept],
|
|
59074
59121
|
...omitted > 0 ? [`[${omitted} messages left out here to fit]`] : [],
|
|
59075
59122
|
...kept
|
|
59076
|
-
];
|
|
59123
|
+
].join("\n\n");
|
|
59124
|
+
}
|
|
59125
|
+
function handoffPrompt(input) {
|
|
59126
|
+
const origin = input.from === input.to ? `This conversation ran in an earlier ${agentName[input.to]} session that you cannot resume.` : `This conversation started with ${agentName[input.from]} and continues with you. Tool names below are ${agentName[input.from]}'s and may differ from yours.`;
|
|
59077
59127
|
return [
|
|
59078
59128
|
"<conversation_handoff>",
|
|
59079
59129
|
[
|
|
@@ -59081,12 +59131,32 @@ function handoffPrompt(input) {
|
|
|
59081
59131
|
"Here is the transcript so far, oldest first. It is context, not a new request. Tool output is left out, so read files again before you rely on them."
|
|
59082
59132
|
].join(" "),
|
|
59083
59133
|
"",
|
|
59084
|
-
|
|
59134
|
+
renderTranscript(input.messages, input.budget),
|
|
59085
59135
|
"</conversation_handoff>",
|
|
59086
59136
|
"",
|
|
59087
59137
|
input.prompt
|
|
59088
59138
|
].join("\n");
|
|
59089
59139
|
}
|
|
59140
|
+
const latestForkPoint = (provider, history) => history.findLast(
|
|
59141
|
+
(message2) => message2.forkPoint !== null && (message2.forkPoint.owner?.provider ?? provider) === provider
|
|
59142
|
+
)?.forkPoint ?? null;
|
|
59143
|
+
const isAt = (forkedFrom) => (message2) => message2.forkPoint?.sessionId === forkedFrom.sessionId && message2.forkPoint.checkpoint === forkedFrom.checkpoint;
|
|
59144
|
+
const unseenSince = (history, forkedFrom) => forkedFrom === null ? history : history.slice(history.findIndex(isAt(forkedFrom)) + 1);
|
|
59145
|
+
function sidechatPrompt(input) {
|
|
59146
|
+
const transcript = renderTranscript(input.unseen);
|
|
59147
|
+
return [
|
|
59148
|
+
"<side_chat>",
|
|
59149
|
+
"This is a side chat. The developer asks you something while the main agent keeps working on this conversation in the same workspace. Answer it, and do not edit files or run commands that change anything.",
|
|
59150
|
+
...transcript === "" ? [] : [
|
|
59151
|
+
"The main conversation went on after your history ends. Here is the rest, oldest first. Tool output is left out, and the last message may still be in progress.",
|
|
59152
|
+
"",
|
|
59153
|
+
transcript
|
|
59154
|
+
],
|
|
59155
|
+
"</side_chat>",
|
|
59156
|
+
"",
|
|
59157
|
+
input.prompt
|
|
59158
|
+
].join("\n");
|
|
59159
|
+
}
|
|
59090
59160
|
const threadMention = (threadId) => `@thread:${threadId}`;
|
|
59091
59161
|
const AGENT_INSTRUCTIONS = `<hinacode>
|
|
59092
59162
|
You are running inside HinaCode, which shows the pull requests linked to each thread next to it.
|
|
@@ -60691,6 +60761,8 @@ const make$T = gen(function* () {
|
|
|
60691
60761
|
return Terminals.of({ open: open2, write, resize, attach, close: close2, list, closeThread });
|
|
60692
60762
|
});
|
|
60693
60763
|
const layer$z = effect(Terminals, make$T);
|
|
60764
|
+
const SETUP_TIMEOUT = "60 seconds";
|
|
60765
|
+
const SETUP_OUTPUT_DRAIN_TIMEOUT = "1 second";
|
|
60694
60766
|
class Worktrees extends Service$1()("hinacode/Worktrees") {
|
|
60695
60767
|
}
|
|
60696
60768
|
const checkoutsDir = (rootPath, worktreeRoot) => join$3(worktreeRoot ?? join$3(dirname$1(rootPath), ".hinacode-worktrees"), basename$1(rootPath));
|
|
@@ -60702,7 +60774,7 @@ const parseCheckouts = (output) => output.split("\0\0").map((record2) => {
|
|
|
60702
60774
|
const value2 = (key2) => fields.find((field2) => field2.startsWith(`${key2} `))?.slice(key2.length + 1);
|
|
60703
60775
|
return { path: value2("worktree") ?? "", ref: value2("branch") ?? null };
|
|
60704
60776
|
}).filter((checkout) => checkout.path !== "");
|
|
60705
|
-
const make$S =
|
|
60777
|
+
const make$S = fnUntraced(function* (setupTimeout) {
|
|
60706
60778
|
const sql = yield* SqlClient;
|
|
60707
60779
|
const projects = yield* Projects;
|
|
60708
60780
|
const git2 = yield* Git;
|
|
@@ -60740,8 +60812,8 @@ const make$S = gen(function* () {
|
|
|
60740
60812
|
});
|
|
60741
60813
|
const findUsers = findAll({
|
|
60742
60814
|
Request: String$1,
|
|
60743
|
-
Result: Struct({ id: String$1, status: ThreadStatus }),
|
|
60744
|
-
execute: (worktreeId) => sql`SELECT id, status FROM thread WHERE worktree_id = ${worktreeId}`
|
|
60815
|
+
Result: Struct({ id: String$1, status: ThreadStatus, sideOf: NullOr(String$1) }),
|
|
60816
|
+
execute: (worktreeId) => sql`SELECT id, status, side_of FROM thread WHERE worktree_id = ${worktreeId}`
|
|
60745
60817
|
});
|
|
60746
60818
|
yield* sql`
|
|
60747
60819
|
UPDATE worktree SET status = 'failed', setup_log = setup_log || ${"\nSetup was interrupted when HinaCode quit.\n"}
|
|
@@ -60767,6 +60839,11 @@ const make$S = gen(function* () {
|
|
|
60767
60839
|
mapError(persistence("worktrees.appendLog")),
|
|
60768
60840
|
andThen(events.publish({ type: "worktree.setupLog", id: id2, chunk }))
|
|
60769
60841
|
);
|
|
60842
|
+
const reportSetup = (worktree, notice, log2) => appendLog(worktree.id, log2).pipe(
|
|
60843
|
+
andThen(
|
|
60844
|
+
events.publish({ type: "worktree.setupNotice", id: worktree.id, branch: worktree.branch, notice })
|
|
60845
|
+
)
|
|
60846
|
+
);
|
|
60770
60847
|
const registeredCheckouts = (rootPath) => git2.run(rootPath, ["worktree", "list", "--porcelain", "-z"]).pipe(map$3(parseCheckouts));
|
|
60771
60848
|
const branchExists = (rootPath, branch) => git2.run(rootPath, ["rev-parse", "--verify", "--quiet", `refs/heads/${branch}`], { okExitCodes: [1] }).pipe(map$3((output) => output.trim() !== ""));
|
|
60772
60849
|
const isMerged = (rootPath, branch, baseRef) => git2.run(rootPath, ["branch", "--merged", baseRef, "--format=%(refname:short)"]).pipe(
|
|
@@ -60787,11 +60864,21 @@ const make$S = gen(function* () {
|
|
|
60787
60864
|
forceKillAfter: "3 seconds"
|
|
60788
60865
|
})
|
|
60789
60866
|
);
|
|
60790
|
-
yield* handle.all.pipe(
|
|
60867
|
+
const logging2 = yield* handle.all.pipe(
|
|
60791
60868
|
decodeText$1(),
|
|
60792
|
-
runForEach((chunk) => appendLog(worktree.id, chunk))
|
|
60869
|
+
runForEach((chunk) => appendLog(worktree.id, chunk)),
|
|
60870
|
+
forkScoped
|
|
60793
60871
|
);
|
|
60794
|
-
|
|
60872
|
+
const exitCode = yield* handle.exitCode;
|
|
60873
|
+
const drained = yield* join$1(logging2).pipe(timeoutOption(SETUP_OUTPUT_DRAIN_TIMEOUT));
|
|
60874
|
+
if (isNone(drained)) {
|
|
60875
|
+
yield* reportSetup(
|
|
60876
|
+
worktree,
|
|
60877
|
+
"backgroundOutput",
|
|
60878
|
+
"\nSetup script exited, but a background process it started still held the output open. HinaCode stopped that process.\n"
|
|
60879
|
+
);
|
|
60880
|
+
}
|
|
60881
|
+
return exitCode;
|
|
60795
60882
|
}).pipe(
|
|
60796
60883
|
scoped,
|
|
60797
60884
|
catchTag("PlatformError", (error2) => appendLog(worktree.id, `${error2.message}
|
|
@@ -60800,7 +60887,15 @@ const make$S = gen(function* () {
|
|
|
60800
60887
|
const setup2 = (worktree, project2) => gen(function* () {
|
|
60801
60888
|
const script = project2.setupScript?.trim();
|
|
60802
60889
|
if (!script) return yield* setStatus(worktree.id, "ready");
|
|
60803
|
-
const
|
|
60890
|
+
const finished = yield* runSetupScript(worktree, project2, script).pipe(timeoutOption(setupTimeout));
|
|
60891
|
+
if (isNone(finished)) {
|
|
60892
|
+
const after = format(fromInputUnsafe$1(setupTimeout));
|
|
60893
|
+
yield* reportSetup(worktree, "timedOut", `
|
|
60894
|
+
Setup script timed out after ${after} and was stopped.
|
|
60895
|
+
`);
|
|
60896
|
+
return yield* setStatus(worktree.id, "failed");
|
|
60897
|
+
}
|
|
60898
|
+
const exitCode = finished.value;
|
|
60804
60899
|
if (exitCode === 0) return yield* setStatus(worktree.id, "ready");
|
|
60805
60900
|
yield* appendLog(worktree.id, `
|
|
60806
60901
|
Setup script exited with code ${exitCode}
|
|
@@ -60864,6 +60959,10 @@ Setup script exited with code ${exitCode}
|
|
|
60864
60959
|
["worktree", "add", "--no-track", "-b", input.branch, path2, input.baseRef]
|
|
60865
60960
|
) : ["worktree", "add", "-b", input.branch, path2, input.startPoint];
|
|
60866
60961
|
yield* git2.run(rootPath, args2);
|
|
60962
|
+
if (input.workingTree !== void 0) {
|
|
60963
|
+
yield* git2.run(path2, ["read-tree", "-m", "-u", "HEAD", input.workingTree]);
|
|
60964
|
+
yield* git2.run(path2, ["reset", "--quiet"]);
|
|
60965
|
+
}
|
|
60867
60966
|
}
|
|
60868
60967
|
const worktree = {
|
|
60869
60968
|
id: id2,
|
|
@@ -60922,7 +61021,9 @@ Setup script exited with code ${exitCode}
|
|
|
60922
61021
|
if (users.some((thread2) => isThreadBusy(thread2.status))) {
|
|
60923
61022
|
return yield* new WorktreeBusyError({ path: worktree.path, reason: "turn" });
|
|
60924
61023
|
}
|
|
60925
|
-
const othersOpen = users.some(
|
|
61024
|
+
const othersOpen = users.some(
|
|
61025
|
+
(thread2) => thread2.id !== owner2 && thread2.sideOf !== owner2 && thread2.status !== "archived"
|
|
61026
|
+
);
|
|
60926
61027
|
if (owner2 !== void 0 && othersOpen) {
|
|
60927
61028
|
return yield* new WorktreeBusyError({ path: worktree.path, reason: "shared" });
|
|
60928
61029
|
}
|
|
@@ -60982,12 +61083,16 @@ Setup script exited with code ${exitCode}
|
|
|
60982
61083
|
return removed;
|
|
60983
61084
|
});
|
|
60984
61085
|
const remove2 = (id2, deleteBranch, owner2) => exclusive(removeWhileExclusive(id2, deleteBranch, owner2));
|
|
60985
|
-
const
|
|
60986
|
-
if (!(yield* fs2.exists(worktree.path)))
|
|
60987
|
-
return some({ id: worktree.id, state: "missing" });
|
|
61086
|
+
const stateOf = (worktree) => gen(function* () {
|
|
61087
|
+
if (!(yield* fs2.exists(worktree.path))) return "missing";
|
|
60988
61088
|
const status = yield* git2.run(worktree.path, ["status", "--porcelain"]);
|
|
60989
|
-
return
|
|
60990
|
-
})
|
|
61089
|
+
return status.trim() === "" ? "clean" : "dirty";
|
|
61090
|
+
});
|
|
61091
|
+
const checkoutOf = (worktree) => stateOf(worktree).pipe(
|
|
61092
|
+
map$3((state) => some({ id: worktree.id, state })),
|
|
61093
|
+
orElseSucceed(none)
|
|
61094
|
+
);
|
|
61095
|
+
const checkoutState = (id2) => flatMap$1(get2(id2), stateOf);
|
|
60991
61096
|
const checkouts = findAll$1(void 0).pipe(
|
|
60992
61097
|
mapError(persistence("worktrees.checkouts")),
|
|
60993
61098
|
flatMap$1(
|
|
@@ -61049,6 +61154,7 @@ Setup script exited with code ${exitCode}
|
|
|
61049
61154
|
return Worktrees.of({
|
|
61050
61155
|
list: findAll$1(void 0).pipe(mapError(persistence("worktrees.list"))),
|
|
61051
61156
|
checkouts,
|
|
61157
|
+
checkoutState,
|
|
61052
61158
|
get: get2,
|
|
61053
61159
|
create,
|
|
61054
61160
|
createFromPullRequest,
|
|
@@ -61068,7 +61174,8 @@ Setup script exited with code ${exitCode}
|
|
|
61068
61174
|
stopSetup
|
|
61069
61175
|
});
|
|
61070
61176
|
});
|
|
61071
|
-
const
|
|
61177
|
+
const layerWithSetupTimeout = (setupTimeout) => effect(Worktrees, make$S(setupTimeout));
|
|
61178
|
+
const layer$y = layerWithSetupTimeout(SETUP_TIMEOUT);
|
|
61072
61179
|
const MAX_LISTED_FILES = 5e4;
|
|
61073
61180
|
const randomName = () => `thread-${randomUUID$1().slice(0, 5)}`;
|
|
61074
61181
|
const ThreadRow$1 = Struct({
|
|
@@ -61100,13 +61207,18 @@ const make$R = gen(function* () {
|
|
|
61100
61207
|
const findAll$1 = findAll({
|
|
61101
61208
|
Request: Void2,
|
|
61102
61209
|
Result: ThreadRow$1,
|
|
61103
|
-
execute: () => sql`SELECT * FROM thread WHERE ${sql.in("provider", [...ProviderId.literals])} ORDER BY project_id, sort_index`
|
|
61210
|
+
execute: () => sql`SELECT * FROM thread WHERE side_of IS NULL AND ${sql.in("provider", [...ProviderId.literals])} ORDER BY project_id, sort_index`
|
|
61104
61211
|
});
|
|
61105
61212
|
const findById = findOneOption({
|
|
61106
61213
|
Request: String$1,
|
|
61107
61214
|
Result: ThreadRow$1,
|
|
61108
61215
|
execute: (id2) => sql`SELECT * FROM thread WHERE id = ${id2}`
|
|
61109
61216
|
});
|
|
61217
|
+
const findSidechat = findOneOption({
|
|
61218
|
+
Request: String$1,
|
|
61219
|
+
Result: ThreadRow$1,
|
|
61220
|
+
execute: (parentId) => sql`SELECT * FROM thread WHERE side_of = ${parentId}`
|
|
61221
|
+
});
|
|
61110
61222
|
const nextSortIndex = findOne({
|
|
61111
61223
|
Request: String$1,
|
|
61112
61224
|
Result: Struct({ next: Number$1 }),
|
|
@@ -61169,6 +61281,7 @@ const make$R = gen(function* () {
|
|
|
61169
61281
|
accountId: defaultAccount[input.provider],
|
|
61170
61282
|
providerSessionId: null,
|
|
61171
61283
|
forkedFrom: null,
|
|
61284
|
+
sideOf: null,
|
|
61172
61285
|
status: "idle",
|
|
61173
61286
|
usageLimit: null,
|
|
61174
61287
|
sortIndex: next,
|
|
@@ -61184,6 +61297,20 @@ const make$R = gen(function* () {
|
|
|
61184
61297
|
yield* syncChatFolder(thread2, true);
|
|
61185
61298
|
return thread2;
|
|
61186
61299
|
});
|
|
61300
|
+
const forkWorktree = (source) => gen(function* () {
|
|
61301
|
+
if (source.worktreeId === null) return null;
|
|
61302
|
+
const worktree = yield* worktrees.get(source.worktreeId);
|
|
61303
|
+
if (worktree.status === "removed") return worktree.id;
|
|
61304
|
+
const workingTree = yield* snapshotWorkingTree(worktree.path).pipe(provideContext$2(gitContext));
|
|
61305
|
+
const forked = yield* worktrees.create({
|
|
61306
|
+
projectId: source.projectId,
|
|
61307
|
+
branch: `${worktree.branch}-fork-${randomUUID$1().slice(0, 5)}`,
|
|
61308
|
+
baseRef: worktree.baseRef,
|
|
61309
|
+
startPoint: worktree.branch,
|
|
61310
|
+
workingTree
|
|
61311
|
+
});
|
|
61312
|
+
return forked.id;
|
|
61313
|
+
});
|
|
61187
61314
|
const fork2 = (threadId, messageId) => gen(function* () {
|
|
61188
61315
|
const source = yield* get2(threadId);
|
|
61189
61316
|
const found2 = yield* findForkPoint({ threadId, messageId }).pipe(mapError(persistence("threads.fork")));
|
|
@@ -61193,14 +61320,17 @@ const make$R = gen(function* () {
|
|
|
61193
61320
|
if (provider !== source.provider) return yield* new NotFoundError({ entity: "fork point", id: messageId });
|
|
61194
61321
|
if (accountId !== null) yield* accounts.get(accountId);
|
|
61195
61322
|
const { next } = yield* nextSortIndex(source.projectId).pipe(mapError(persistence("threads.fork")));
|
|
61323
|
+
const worktreeId = yield* forkWorktree(source);
|
|
61196
61324
|
const now2 = yield* nowIso;
|
|
61197
61325
|
const thread2 = {
|
|
61198
61326
|
...source,
|
|
61199
61327
|
id: randomUUID$1(),
|
|
61200
61328
|
title: `${source.title} (fork)`,
|
|
61329
|
+
worktreeId,
|
|
61201
61330
|
accountId,
|
|
61202
61331
|
providerSessionId: null,
|
|
61203
61332
|
forkedFrom,
|
|
61333
|
+
sideOf: null,
|
|
61204
61334
|
status: "idle",
|
|
61205
61335
|
usageLimit: null,
|
|
61206
61336
|
sortIndex: next,
|
|
@@ -61228,6 +61358,59 @@ const make$R = gen(function* () {
|
|
|
61228
61358
|
yield* syncChatFolder(thread2, true);
|
|
61229
61359
|
return thread2;
|
|
61230
61360
|
});
|
|
61361
|
+
const sidechat = (parentId) => gen(function* () {
|
|
61362
|
+
const existing = yield* findSidechat(parentId).pipe(mapError(persistence("threads.sidechat")));
|
|
61363
|
+
if (isSome(existing)) return existing.value;
|
|
61364
|
+
const parent = yield* get2(parentId);
|
|
61365
|
+
const now2 = yield* nowIso;
|
|
61366
|
+
const thread2 = {
|
|
61367
|
+
...parent,
|
|
61368
|
+
id: randomUUID$1(),
|
|
61369
|
+
accessMode: "supervised",
|
|
61370
|
+
providerSessionId: null,
|
|
61371
|
+
forkedFrom: null,
|
|
61372
|
+
sideOf: parent.id,
|
|
61373
|
+
status: "idle",
|
|
61374
|
+
usageLimit: null,
|
|
61375
|
+
pinnedAt: null,
|
|
61376
|
+
snoozedUntil: null,
|
|
61377
|
+
queue: [],
|
|
61378
|
+
createdBy: "user",
|
|
61379
|
+
createdAt: now2,
|
|
61380
|
+
updatedAt: now2
|
|
61381
|
+
};
|
|
61382
|
+
const row = yield* encodeRow(thread2).pipe(mapError(persistence("threads.sidechat")));
|
|
61383
|
+
yield* sql`INSERT INTO thread ${sql.insert(row)} ON CONFLICT (side_of) DO NOTHING`.pipe(
|
|
61384
|
+
mapError(persistence("threads.sidechat"))
|
|
61385
|
+
);
|
|
61386
|
+
const created = yield* findSidechat(parentId).pipe(mapError(persistence("threads.sidechat")));
|
|
61387
|
+
return getOrElse(created, () => thread2);
|
|
61388
|
+
});
|
|
61389
|
+
const rebaseSidechat = (id2, parent, forkPoint) => gen(function* () {
|
|
61390
|
+
const current = yield* get2(id2);
|
|
61391
|
+
const next = {
|
|
61392
|
+
...current,
|
|
61393
|
+
...current.provider !== parent.provider && {
|
|
61394
|
+
provider: parent.provider,
|
|
61395
|
+
model: parent.model,
|
|
61396
|
+
effort: parent.effort,
|
|
61397
|
+
fastMode: parent.fastMode
|
|
61398
|
+
},
|
|
61399
|
+
worktreeId: parent.worktreeId,
|
|
61400
|
+
userSkills: parent.userSkills,
|
|
61401
|
+
accountId: forkPoint?.owner?.accountId ?? parent.accountId,
|
|
61402
|
+
forkedFrom: forkPoint === null ? null : { sessionId: forkPoint.sessionId, checkpoint: forkPoint.checkpoint },
|
|
61403
|
+
updatedAt: yield* nowIso
|
|
61404
|
+
};
|
|
61405
|
+
yield* sql`
|
|
61406
|
+
UPDATE thread
|
|
61407
|
+
SET worktree_id = ${next.worktreeId}, provider = ${next.provider}, model = ${next.model}, effort = ${next.effort},
|
|
61408
|
+
fast_mode = ${next.fastMode ? 1 : 0}, user_skills = ${next.userSkills ? 1 : 0}, account_id = ${next.accountId},
|
|
61409
|
+
forked_from = ${next.forkedFrom === null ? null : JSON.stringify(next.forkedFrom)}, updated_at = ${next.updatedAt}
|
|
61410
|
+
WHERE id = ${id2}
|
|
61411
|
+
`.pipe(mapError(persistence("threads.rebaseSidechat")));
|
|
61412
|
+
return next;
|
|
61413
|
+
});
|
|
61231
61414
|
const update2 = (input) => gen(function* () {
|
|
61232
61415
|
const current = yield* get2(input.id);
|
|
61233
61416
|
const switchesAgent = input.provider !== void 0 && input.provider !== current.provider;
|
|
@@ -61385,6 +61568,9 @@ const make$R = gen(function* () {
|
|
|
61385
61568
|
create,
|
|
61386
61569
|
update: update2,
|
|
61387
61570
|
fork: fork2,
|
|
61571
|
+
sidechat,
|
|
61572
|
+
sidechatOf: (parentId) => findSidechat(parentId).pipe(mapError(persistence("threads.sidechatOf"))),
|
|
61573
|
+
rebaseSidechat,
|
|
61388
61574
|
started,
|
|
61389
61575
|
prepareWorkspace,
|
|
61390
61576
|
listFiles,
|
|
@@ -61821,12 +62007,22 @@ const make$O = gen(function* () {
|
|
|
61821
62007
|
return true;
|
|
61822
62008
|
}).pipe(exclusive(thread2.id));
|
|
61823
62009
|
let next;
|
|
62010
|
+
const withdraw = (event) => publishTranscript({ type: "thread.event", threadId: thread2.id, event });
|
|
61824
62011
|
const finish = gen(function* () {
|
|
61825
|
-
for (const [id2, request] of approvals)
|
|
61826
|
-
|
|
62012
|
+
for (const [id2, request] of approvals) {
|
|
62013
|
+
if (request.threadId !== thread2.id) continue;
|
|
62014
|
+
approvals.delete(id2);
|
|
62015
|
+
yield* withdraw({ type: "approval_resolved", requestId: id2 });
|
|
62016
|
+
}
|
|
62017
|
+
for (const [id2, request] of questions) {
|
|
62018
|
+
if (request.threadId !== thread2.id) continue;
|
|
62019
|
+
questions.delete(id2);
|
|
62020
|
+
yield* withdraw({ type: "question_resolved", requestId: id2 });
|
|
62021
|
+
}
|
|
61827
62022
|
for (const [id2, { request, answer }] of secretRequests) {
|
|
61828
62023
|
if (request.threadId !== thread2.id) continue;
|
|
61829
62024
|
secretRequests.delete(id2);
|
|
62025
|
+
yield* withdraw({ type: "secret_resolved", requestId: id2 });
|
|
61830
62026
|
yield* fail$3(
|
|
61831
62027
|
answer,
|
|
61832
62028
|
new AgentError({ provider: "hinacode", message: "The turn ended before the user answered." })
|
|
@@ -61834,8 +62030,10 @@ const make$O = gen(function* () {
|
|
|
61834
62030
|
}
|
|
61835
62031
|
yield* stopSubagents(thread2.id, yield* nowIso);
|
|
61836
62032
|
const last = turnMessages.at(-1);
|
|
61837
|
-
|
|
62033
|
+
const closed = last.completedAt === null ? { ...last, completedAt: yield* nowIso } : last;
|
|
62034
|
+
setTurnMessages(replaceLast(turnMessages, closed));
|
|
61838
62035
|
yield* persist;
|
|
62036
|
+
if (closed !== last) yield* publishTranscript({ type: "message.updated", message: closed });
|
|
61839
62037
|
if (isThreadBusy(status)) yield* updateThread({ id: thread2.id, status: "idle" });
|
|
61840
62038
|
if (!completed || (yield* isDone(stop))) return;
|
|
61841
62039
|
const [first, ...rest] = (yield* threads.get(thread2.id)).queue;
|
|
@@ -61896,8 +62094,21 @@ const make$O = gen(function* () {
|
|
|
61896
62094
|
});
|
|
61897
62095
|
return { provider, steer, run: run2, follow, handle, interrupt: interrupt2, messages: () => turnMessages };
|
|
61898
62096
|
};
|
|
62097
|
+
const liveMessages = (threadId) => messages.list(threadId).pipe(
|
|
62098
|
+
map$3((persisted2) => {
|
|
62099
|
+
const live = new Map(
|
|
62100
|
+
activeTurns.get(threadId)?.messages().map((message2) => [message2.id, message2])
|
|
62101
|
+
);
|
|
62102
|
+
return persisted2.map((message2) => live.get(message2.id) ?? message2);
|
|
62103
|
+
})
|
|
62104
|
+
);
|
|
61899
62105
|
const promptForSession = (thread2, prompt) => gen(function* () {
|
|
61900
|
-
if (thread2.providerSessionId !== null
|
|
62106
|
+
if (thread2.providerSessionId !== null) return prompt;
|
|
62107
|
+
if (thread2.sideOf !== null) {
|
|
62108
|
+
const unseen = unseenSince(yield* liveMessages(thread2.sideOf), thread2.forkedFrom);
|
|
62109
|
+
return sidechatPrompt({ unseen, prompt });
|
|
62110
|
+
}
|
|
62111
|
+
if (thread2.forkedFrom !== null) return prompt;
|
|
61901
62112
|
const history = yield* messages.list(thread2.id);
|
|
61902
62113
|
if (history.length === 0) return prompt;
|
|
61903
62114
|
const lastSwitch = history.flatMap((message2) => message2.parts).findLast((part) => part.type === "agent_switch");
|
|
@@ -61917,6 +62128,12 @@ const make$O = gen(function* () {
|
|
|
61917
62128
|
if (!(yield* when2)) return null;
|
|
61918
62129
|
let thread2 = yield* threads.get(threadId);
|
|
61919
62130
|
const first = !(yield* threads.started(threadId));
|
|
62131
|
+
if (first && thread2.sideOf !== null) {
|
|
62132
|
+
const parent = yield* threads.get(thread2.sideOf);
|
|
62133
|
+
const forkPoint = latestForkPoint(parent.provider, yield* liveMessages(parent.id));
|
|
62134
|
+
thread2 = yield* threads.rebaseSidechat(threadId, parent, forkPoint);
|
|
62135
|
+
yield* push.publish({ type: "thread.updated", thread: thread2 });
|
|
62136
|
+
}
|
|
61920
62137
|
if (options.workspace) {
|
|
61921
62138
|
const prepared = yield* threads.prepareWorkspace(threadId, options.workspace);
|
|
61922
62139
|
thread2 = prepared.thread;
|
|
@@ -61974,7 +62191,7 @@ const make$O = gen(function* () {
|
|
|
61974
62191
|
activeTurns.set(threadId, turn);
|
|
61975
62192
|
pendingSends.delete(threadId);
|
|
61976
62193
|
yield* run$3(turns, threadId, turn.run(agentPrompt, attachments, environment2));
|
|
61977
|
-
if (pending.first && currentThread.createdBy === "user" && prompt.trim() !== "")
|
|
62194
|
+
if (pending.first && currentThread.createdBy === "user" && currentThread.sideOf === null && prompt.trim() !== "")
|
|
61978
62195
|
yield* forkDetach(nameThreadWithPullRequestScope(currentThread, prompt));
|
|
61979
62196
|
return true;
|
|
61980
62197
|
}).pipe(exclusive(threadId));
|
|
@@ -62242,12 +62459,8 @@ const make$O = gen(function* () {
|
|
|
62242
62459
|
requestSecret,
|
|
62243
62460
|
respondSecret,
|
|
62244
62461
|
transcript: (threadId) => gen(function* () {
|
|
62245
|
-
const persisted2 = yield* messages.list(threadId);
|
|
62246
|
-
const live = new Map(
|
|
62247
|
-
activeTurns.get(threadId)?.messages().map((message2) => [message2.id, message2])
|
|
62248
|
-
);
|
|
62249
62462
|
return {
|
|
62250
|
-
messages:
|
|
62463
|
+
messages: yield* liveMessages(threadId),
|
|
62251
62464
|
approvals: [...approvals.values()].filter((request) => request.threadId === threadId),
|
|
62252
62465
|
questions: [...questions.values()].filter((request) => request.threadId === threadId),
|
|
62253
62466
|
secretRequests: [...secretRequests.values()].map(({ request }) => request).filter((request) => request.threadId === threadId),
|
|
@@ -67451,6 +67664,7 @@ const learnFromAnswer = (owners, environmentId, method2, payload, result2) => {
|
|
|
67451
67664
|
case "threads.update":
|
|
67452
67665
|
case "threads.archive":
|
|
67453
67666
|
case "threads.unarchive":
|
|
67667
|
+
case "threads.sidechat":
|
|
67454
67668
|
return each(result2, learnId(teach, "thread"));
|
|
67455
67669
|
case "worktrees.list":
|
|
67456
67670
|
case "worktrees.create":
|
|
@@ -89218,7 +89432,7 @@ const make$6 = (ripgrep) => gen(function* () {
|
|
|
89218
89432
|
FROM message_fts f
|
|
89219
89433
|
JOIN message m ON m.rowid = f.rowid
|
|
89220
89434
|
JOIN thread t ON t.id = m.thread_id
|
|
89221
|
-
WHERE f.body LIKE ${pattern} ${sql.literal(escaped ? "ESCAPE '\\'" : "")}
|
|
89435
|
+
WHERE f.body LIKE ${pattern} ${sql.literal(escaped ? "ESCAPE '\\'" : "")} AND t.side_of IS NULL
|
|
89222
89436
|
ORDER BY f.rowid DESC
|
|
89223
89437
|
LIMIT ${limit}
|
|
89224
89438
|
`;
|
|
@@ -90310,12 +90524,13 @@ const handlers = {
|
|
|
90310
90524
|
"projects.clone": (input) => Projects.use((projects) => projects.clone(input)),
|
|
90311
90525
|
"projects.update": (input) => Projects.use((projects) => projects.update(input)),
|
|
90312
90526
|
"projects.delete": ({ id: id2 }) => gen(function* () {
|
|
90313
|
-
const threads = yield* Threads.use((service2) => service2.list);
|
|
90527
|
+
const threads = (yield* Threads.use((service2) => service2.list)).filter((thread2) => thread2.projectId === id2);
|
|
90528
|
+
yield* forEach$1(threads, (thread2) => closeTerminals(thread2.id));
|
|
90529
|
+
yield* Projects.use((projects) => projects.remove(id2));
|
|
90314
90530
|
yield* forEach$1(
|
|
90315
|
-
threads
|
|
90316
|
-
(thread2) =>
|
|
90531
|
+
threads,
|
|
90532
|
+
(thread2) => Events.use((events) => events.publish({ type: "thread.removed", id: thread2.id }))
|
|
90317
90533
|
);
|
|
90318
|
-
yield* Projects.use((projects) => projects.remove(id2));
|
|
90319
90534
|
}),
|
|
90320
90535
|
"threads.list": () => Threads.use((threads) => threads.list),
|
|
90321
90536
|
"threads.create": ({ projectId, title, provider: chosenProvider, model, effort, worktree, createdBy }) => gen(function* () {
|
|
@@ -90353,7 +90568,14 @@ const handlers = {
|
|
|
90353
90568
|
yield* Events.use((events) => events.publish({ type: "thread.updated", thread: thread2 }));
|
|
90354
90569
|
return thread2;
|
|
90355
90570
|
}),
|
|
90356
|
-
"threads.delete": ({ id: id2, removeWorktree }) =>
|
|
90571
|
+
"threads.delete": ({ id: id2, removeWorktree }) => Threads.use((threads) => threads.sidechatOf(id2)).pipe(
|
|
90572
|
+
flatMap$1(
|
|
90573
|
+
match$4({
|
|
90574
|
+
onNone: () => void_$1,
|
|
90575
|
+
onSome: (sidechat) => AgentRunner.use((runner) => runner.interrupt(sidechat.id))
|
|
90576
|
+
})
|
|
90577
|
+
),
|
|
90578
|
+
andThen(closeTerminals(id2)),
|
|
90357
90579
|
andThen(Threads.use((threads) => threads.remove(id2, { removeWorktree }))),
|
|
90358
90580
|
andThen(Events.use((events) => events.publish({ type: "thread.removed", id: id2 })))
|
|
90359
90581
|
),
|
|
@@ -90365,6 +90587,7 @@ const handlers = {
|
|
|
90365
90587
|
"worktrees.create": (input) => Worktrees.use((worktrees) => worktrees.create(input)),
|
|
90366
90588
|
"worktrees.remove": ({ id: id2, deleteBranch }) => Worktrees.use((worktrees) => worktrees.remove(id2, deleteBranch)),
|
|
90367
90589
|
"worktrees.checkouts": () => Worktrees.use((worktrees) => worktrees.checkouts),
|
|
90590
|
+
"worktrees.checkoutState": ({ id: id2 }) => Worktrees.use((worktrees) => worktrees.checkoutState(id2)),
|
|
90368
90591
|
"worktrees.setupLog": ({ id: id2 }) => Worktrees.use((worktrees) => map$3(worktrees.get(id2), (w) => w.setupLog)),
|
|
90369
90592
|
"worktrees.stopSetup": ({ id: id2 }) => Worktrees.use((worktrees) => worktrees.stopSetup(id2)),
|
|
90370
90593
|
"worktrees.pullRequest": ({ id: id2 }) => Worktrees.use((worktrees) => worktrees.pullRequest(id2)),
|
|
@@ -90374,6 +90597,7 @@ const handlers = {
|
|
|
90374
90597
|
"threads.fork": ({ threadId, messageId }) => Threads.use((threads) => threads.fork(threadId, messageId)).pipe(
|
|
90375
90598
|
tap$2((thread2) => Events.use((events) => events.publish({ type: "thread.updated", thread: thread2 })))
|
|
90376
90599
|
),
|
|
90600
|
+
"threads.sidechat": ({ threadId }) => Threads.use((threads) => threads.sidechat(threadId)),
|
|
90377
90601
|
"projects.currentBranch": ({ id: id2 }) => Worktrees.use((worktrees) => worktrees.currentBranch(id2)),
|
|
90378
90602
|
"projects.defaultBranch": ({ id: id2 }) => Worktrees.use((worktrees) => worktrees.defaultBranch(id2)),
|
|
90379
90603
|
"projects.branches": ({ id: id2 }) => Worktrees.use((worktrees) => worktrees.branches(id2)),
|
|
@@ -90457,6 +90681,10 @@ const handlers = {
|
|
|
90457
90681
|
),
|
|
90458
90682
|
"threads.send": ({ threadId, prompt, attachments = [], workspace }) => gen(function* () {
|
|
90459
90683
|
const remember = yield* rememberWorkspaceMode(threadId, workspace?.mode ?? "local");
|
|
90684
|
+
if ((yield* Threads.use((threads) => threads.get(threadId))).status === "archived") {
|
|
90685
|
+
const thread2 = yield* Threads.use((threads) => threads.unarchive(threadId));
|
|
90686
|
+
yield* Events.use((events) => events.publish({ type: "thread.updated", thread: thread2 }));
|
|
90687
|
+
}
|
|
90460
90688
|
yield* AgentRunner.use((runner) => runner.send(threadId, prompt, attachments, { workspace }));
|
|
90461
90689
|
yield* remember;
|
|
90462
90690
|
}),
|