@hyperwindmill/caretaker-cli 0.25.1 → 0.26.1
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/web/scheduler/cycle_events.d.ts +32 -0
- package/dist/cli/web/scheduler/cycle_events.d.ts.map +1 -0
- package/dist/cli/web/scheduler/cycle_events.js +42 -0
- package/dist/cli/web/scheduler/memory_sweep.d.ts.map +1 -1
- package/dist/cli/web/scheduler/memory_sweep.js +11 -4
- package/dist/cli/web/scheduler/task_cycle.d.ts +33 -0
- package/dist/cli/web/scheduler/task_cycle.d.ts.map +1 -0
- package/dist/cli/web/scheduler/task_cycle.js +137 -0
- package/dist/cli/web/scheduler/task_review.d.ts +5 -0
- package/dist/cli/web/scheduler/task_review.d.ts.map +1 -1
- package/dist/cli/web/scheduler/task_review.js +10 -1
- package/dist/cli/web/scheduler/task_strategy.d.ts.map +1 -1
- package/dist/cli/web/scheduler/task_strategy.js +47 -54
- package/dist/cli/web/server.d.ts.map +1 -1
- package/dist/cli/web/server.js +75 -11
- package/dist/harness/memory_recall.d.ts.map +1 -1
- package/dist/harness/memory_recall.js +5 -0
- package/dist/harness/tools/builtin/task_tools.d.ts.map +1 -1
- package/dist/harness/tools/builtin/task_tools.js +10 -4
- package/dist/session/store.d.ts +4 -0
- package/dist/session/store.d.ts.map +1 -1
- package/dist/session/store.js +6 -0
- package/dist/session/types.d.ts +8 -0
- package/dist/session/types.d.ts.map +1 -1
- package/dist/store/db.d.ts +13 -1
- package/dist/store/db.d.ts.map +1 -1
- package/dist/store/db.js +23 -0
- package/dist/store/json.d.ts +10 -0
- package/dist/store/json.d.ts.map +1 -1
- package/dist/store/json.js +9 -0
- package/dist/webview/standalone.css +80 -25
- package/dist/webview/standalone.css.map +2 -2
- package/dist/webview/standalone.js +983 -850
- package/dist/webview/standalone.js.map +4 -4
- package/package.json +3 -3
package/dist/cli/web/server.js
CHANGED
|
@@ -8,18 +8,19 @@ import { stream } from 'hono/streaming';
|
|
|
8
8
|
import { serve } from '@hono/node-server';
|
|
9
9
|
import { WebSocketServer, WebSocket } from 'ws';
|
|
10
10
|
import * as harness from '../../harness/index.js';
|
|
11
|
-
import { getDb, getTaskById, saveTask, createTask, addTaskMessage, deleteTask, runQuery, tryNormalizeChecklistStatus } from '../../store/db.js';
|
|
11
|
+
import { getDb, getTaskById, saveTask, createTask, addTaskMessage, deleteTask, deleteTaskSessions, runQuery, tryNormalizeChecklistStatus } from '../../store/db.js';
|
|
12
12
|
import { discardWorktree, syncProjectRepo, projectRepoStatus, managedRepoDir } from '../../lib/task_git.js';
|
|
13
13
|
import { removeContainer } from '../../lib/docker.js';
|
|
14
14
|
import { validateRepositoryUrl } from '../../lib/repo_url.js';
|
|
15
15
|
import { validateProjectSlug, validateProjectIds } from '../../lib/project_slug.js';
|
|
16
16
|
import { runningTasks, abortRunningTask, syncingProjects } from './scheduler/locks.js';
|
|
17
17
|
import { registerTaskBridge, setTaskBridgeUrl } from './mcp_bridge.js';
|
|
18
|
-
import { loadAgents, loadConfig, dataDir, saveAgents, saveConfig, loadPlugins, loadMcpServers, } from '../../store/json.js';
|
|
18
|
+
import { loadAgents, loadConfig, dataDir, saveAgents, saveConfig, loadPlugins, loadMcpServers, loadUiState, saveUiState, } from '../../store/json.js';
|
|
19
19
|
import { createSource, deleteSource, patchSource, refreshSource, } from '../../plugins/source_manager.js';
|
|
20
20
|
import { createMcpServer, deleteMcpServer, patchMcpServer, readOAuthBlob } from '../../mcp/server_manager.js';
|
|
21
21
|
import { authenticateMcpServer, revokeMcpAuth } from '../../mcp/oauth.js';
|
|
22
22
|
import { listForAgent, readSession, deleteSession, computeContextUsage, createSession, userMessage, appendMessage, saveAttachment, attachmentsDir, } from '../../session/index.js';
|
|
23
|
+
import { watchCycleStream } from './scheduler/cycle_events.js';
|
|
23
24
|
import { startBackgroundScheduler, loadTaskRuns } from './scheduler.js';
|
|
24
25
|
import { fsRouter } from './fs.js';
|
|
25
26
|
import { activationStatus, resolvePlanningEnabled } from './scheduler/task_roles.js';
|
|
@@ -33,6 +34,18 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
33
34
|
const bundledWebviewDist = path.resolve(__dirname, '../../webview');
|
|
34
35
|
const devWebviewDist = path.resolve(__dirname, '../../../../webview-ui/dist');
|
|
35
36
|
const webviewDistPath = fs.existsSync(bundledWebviewDist) ? bundledWebviewDist : devWebviewDist;
|
|
37
|
+
/** Session record → webview chat message. Shared by the chat and cycle loaders. */
|
|
38
|
+
function toChatMessage(m) {
|
|
39
|
+
return {
|
|
40
|
+
id: m.id,
|
|
41
|
+
role: m.role,
|
|
42
|
+
content: m.content,
|
|
43
|
+
parts: m.parts,
|
|
44
|
+
toolCallId: m.toolCallId,
|
|
45
|
+
...(m.recap ? { recap: true } : {}),
|
|
46
|
+
createdAt: m.createdAt,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
36
49
|
export class WebSessionController {
|
|
37
50
|
opts;
|
|
38
51
|
metaRecord = null;
|
|
@@ -218,6 +231,22 @@ export async function startServer(port, host) {
|
|
|
218
231
|
});
|
|
219
232
|
const db = getDb();
|
|
220
233
|
// Projects REST endpoints
|
|
234
|
+
// Last project picked in the Projects screen (ui-state.json, see store/json.ts).
|
|
235
|
+
app.get('/api/ui-state', async (c) => c.json(await loadUiState()));
|
|
236
|
+
app.put('/api/ui-state', async (c) => {
|
|
237
|
+
const body = await c.req.json().catch(() => null);
|
|
238
|
+
const id = body?.lastProjectId;
|
|
239
|
+
if (id !== undefined && id !== null && typeof id !== 'string') {
|
|
240
|
+
return c.json({ error: 'lastProjectId must be a string' }, 400);
|
|
241
|
+
}
|
|
242
|
+
const state = await loadUiState();
|
|
243
|
+
if (id)
|
|
244
|
+
state.lastProjectId = id;
|
|
245
|
+
else
|
|
246
|
+
delete state.lastProjectId;
|
|
247
|
+
await saveUiState(state);
|
|
248
|
+
return c.json(state);
|
|
249
|
+
});
|
|
221
250
|
app.get('/api/projects', async (c) => {
|
|
222
251
|
try {
|
|
223
252
|
const config = await loadConfig();
|
|
@@ -292,7 +321,11 @@ export async function startServer(port, host) {
|
|
|
292
321
|
const managed = project ? managedRepoDir(project) : null;
|
|
293
322
|
if (managed)
|
|
294
323
|
await fs.promises.rm(managed, { recursive: true, force: true });
|
|
295
|
-
//
|
|
324
|
+
// Cycle sessions first (they are referenced from the task messages), then
|
|
325
|
+
// task messages, then tasks — avoids orphaned rows.
|
|
326
|
+
const projectTasks = (await runQuery(`SELECT * FROM tasks WHERE projectId = '${id}'`));
|
|
327
|
+
for (const t of projectTasks)
|
|
328
|
+
await deleteTaskSessions(t.id);
|
|
296
329
|
await runQuery(`DELETE FROM task_messages WHERE taskId IN (SELECT id FROM tasks WHERE projectId = '${id}')`);
|
|
297
330
|
await runQuery(`DELETE FROM tasks WHERE projectId = '${id}'`);
|
|
298
331
|
return c.json({ ok: true });
|
|
@@ -749,6 +782,12 @@ export async function startServer(port, host) {
|
|
|
749
782
|
let currentSessionId = null;
|
|
750
783
|
let agents = [];
|
|
751
784
|
const pendingConfirms = new Map();
|
|
785
|
+
// Task cycles this socket is following, by session id (see scheduler/cycle_events.ts).
|
|
786
|
+
const cycleWatchers = new Map();
|
|
787
|
+
const unwatchCycle = (sessionId) => {
|
|
788
|
+
cycleWatchers.get(sessionId)?.();
|
|
789
|
+
cycleWatchers.delete(sessionId);
|
|
790
|
+
};
|
|
752
791
|
const post = (msg) => {
|
|
753
792
|
if (ws.readyState === WebSocket.OPEN) {
|
|
754
793
|
ws.send(JSON.stringify(msg));
|
|
@@ -836,14 +875,7 @@ export async function startServer(port, host) {
|
|
|
836
875
|
const loadSessionMessagesAndSend = async (agentId, sessionId) => {
|
|
837
876
|
try {
|
|
838
877
|
const sessionData = await readSession(agentId, sessionId);
|
|
839
|
-
const messages = sessionData.messages.map(
|
|
840
|
-
id: m.id,
|
|
841
|
-
role: m.role,
|
|
842
|
-
content: m.content,
|
|
843
|
-
parts: m.parts,
|
|
844
|
-
toolCallId: m.toolCallId,
|
|
845
|
-
createdAt: m.createdAt,
|
|
846
|
-
}));
|
|
878
|
+
const messages = sessionData.messages.map(toChatMessage);
|
|
847
879
|
post({ type: 'sessionLoaded', messages });
|
|
848
880
|
const usage = computeContextUsage(sessionData.messages, currentAgent?.model ?? null);
|
|
849
881
|
post({ type: 'contextUsage', usage });
|
|
@@ -917,6 +949,8 @@ export async function startServer(port, host) {
|
|
|
917
949
|
resolveAllPending('reject');
|
|
918
950
|
controller?.abort();
|
|
919
951
|
watcher.close();
|
|
952
|
+
for (const sessionId of [...cycleWatchers.keys()])
|
|
953
|
+
unwatchCycle(sessionId);
|
|
920
954
|
});
|
|
921
955
|
ws.on('message', async (data) => {
|
|
922
956
|
try {
|
|
@@ -1240,6 +1274,36 @@ export async function startServer(port, host) {
|
|
|
1240
1274
|
post({ type: 'voiceModelsFetched', result: { ok: false, error: String(err) }, target: msg.target });
|
|
1241
1275
|
}
|
|
1242
1276
|
return;
|
|
1277
|
+
case 'watchCycle': {
|
|
1278
|
+
// Ids name files on disk; the same rule as the bridge parser.
|
|
1279
|
+
if (!/^[A-Za-z0-9_-]+$/.test(msg.agentId) || !/^[A-Za-z0-9_-]+$/.test(msg.sessionId))
|
|
1280
|
+
return;
|
|
1281
|
+
const { sessionId } = msg;
|
|
1282
|
+
unwatchCycle(sessionId);
|
|
1283
|
+
const live = watchCycleStream(sessionId, (event) => post({ type: 'cycleEvent', sessionId, event }));
|
|
1284
|
+
if (live) {
|
|
1285
|
+
// Running: the prompt, then every event so far, then the tail — all
|
|
1286
|
+
// synchronously, so nothing is lost between snapshot and listener.
|
|
1287
|
+
cycleWatchers.set(sessionId, live.unwatch);
|
|
1288
|
+
post({ type: 'cycleLoaded', sessionId, messages: [toChatMessage(live.prompt)], running: true });
|
|
1289
|
+
for (const event of live.events)
|
|
1290
|
+
post({ type: 'cycleEvent', sessionId, event });
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1293
|
+
try {
|
|
1294
|
+
const data = await readSession(msg.agentId, sessionId);
|
|
1295
|
+
post({ type: 'cycleLoaded', sessionId, messages: data.messages.map(toChatMessage), running: false });
|
|
1296
|
+
}
|
|
1297
|
+
catch (err) {
|
|
1298
|
+
console.warn('[web] failed to load task cycle:', err);
|
|
1299
|
+
post({ type: 'cycleEvent', sessionId, event: { type: 'error', message: 'Cycle session not found' } });
|
|
1300
|
+
}
|
|
1301
|
+
return;
|
|
1302
|
+
}
|
|
1303
|
+
case 'unwatchCycle':
|
|
1304
|
+
if (/^[A-Za-z0-9_-]+$/.test(msg.sessionId))
|
|
1305
|
+
unwatchCycle(msg.sessionId);
|
|
1306
|
+
return;
|
|
1243
1307
|
case 'getTaskRuns':
|
|
1244
1308
|
try {
|
|
1245
1309
|
const runs = await loadTaskRuns(msg.taskId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory_recall.d.ts","sourceRoot":"","sources":["../../src/harness/memory_recall.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAK7C,eAAO,MAAM,YAAY,IAAI,CAAC;AAC9B,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAOpC;;;;;;;;;6EAS6E;AAC7E,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAqB1E;AAED;;qEAEqE;AACrE,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"memory_recall.d.ts","sourceRoot":"","sources":["../../src/harness/memory_recall.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAK7C,eAAO,MAAM,YAAY,IAAI,CAAC;AAC9B,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAOpC;;;;;;;;;6EAS6E;AAC7E,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAqB1E;AAED;;qEAEqE;AACrE,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAc7D;AAED;;;;;;;iDAOiD;AACjD,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,iBAAiB,CAAC,EAAE,MAAM,GACzB,OAAO,CAAC,MAAM,CAAC,CAajB"}
|
|
@@ -47,6 +47,11 @@ export function formatMemoriesBlock(matches) {
|
|
|
47
47
|
'<memories>',
|
|
48
48
|
'Stored memories that may be relevant to the current message:',
|
|
49
49
|
...matches.map((m) => `- ${m.id} — ${m.title} (${m.kind}, ${m.importance})`),
|
|
50
|
+
// ponytail: "(when available)" papers over a gap — external runners (acp,
|
|
51
|
+
// claude-code) never get memory_read in ordinary chat, so they see titles
|
|
52
|
+
// they cannot open. Suspended 2026-10-05. Upgrade path, cheapest first:
|
|
53
|
+
// inline bodies for external runners; or inject `caretaker-cli mcp` as a
|
|
54
|
+
// stdio MCP server into interactive ACP sessions behind a namespace filter.
|
|
50
55
|
'To read their full content, call the memory_read tool with the ids (when available).',
|
|
51
56
|
'</memories>',
|
|
52
57
|
].join('\n');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task_tools.d.ts","sourceRoot":"","sources":["../../../../src/harness/tools/builtin/task_tools.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"task_tools.d.ts","sourceRoot":"","sources":["../../../../src/harness/tools/builtin/task_tools.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,aAAa,CAAC;AAepD,eAAO,MAAM,gBAAgB,EAAE,IAmD9B,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,IAqCrC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,IAoDjC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,IAmEnC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,IAiC5B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,IAgD9B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,IAoC3B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,IA2C3B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,IA4B7B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,IAgG5B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,IA+B5B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,IAwC7B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,IAoC9B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,IAwC7B,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,IA+CrC,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,IAkC7B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,IA8B/B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,IA0D5B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,IAgD9B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,IAuC5B,CAAC"}
|
|
@@ -5,6 +5,7 @@ import { discardWorktree, projectWorkingDir } from '../../../lib/task_git.js';
|
|
|
5
5
|
import { removeContainer } from '../../../lib/docker.js';
|
|
6
6
|
import { runningTasks } from '../../../cli/web/scheduler/locks.js';
|
|
7
7
|
import { resolveReviewEnabled, resolvePlanningEnabled, activationStatus } from '../../../cli/web/scheduler/task_roles.js';
|
|
8
|
+
import { filterHandoffMessages } from '../../../cli/web/scheduler/task_cycle.js';
|
|
8
9
|
function ok(data = {}) {
|
|
9
10
|
return { content: JSON.stringify({ ok: true, ...data }) };
|
|
10
11
|
}
|
|
@@ -55,7 +56,7 @@ export const getTaskStateTool = {
|
|
|
55
56
|
workingDir: projectWorkingDir(project),
|
|
56
57
|
}
|
|
57
58
|
: null,
|
|
58
|
-
recentMessages: messages.slice(-20),
|
|
59
|
+
recentMessages: filterHandoffMessages(messages).slice(-20),
|
|
59
60
|
}),
|
|
60
61
|
};
|
|
61
62
|
},
|
|
@@ -241,7 +242,7 @@ export const addMessageTool = {
|
|
|
241
242
|
};
|
|
242
243
|
export const completeTaskTool = {
|
|
243
244
|
name: 'mcp__task__task_complete',
|
|
244
|
-
description: 'Mark the task as done.
|
|
245
|
+
description: 'Mark the task as done. Call it as soon as the objective is fully achieved and every checklist item is done, in the same invocation that finishes the work. Do not task_yield a finished task: it would stay active and run again.',
|
|
245
246
|
parameters: {
|
|
246
247
|
type: 'object',
|
|
247
248
|
properties: {
|
|
@@ -316,7 +317,7 @@ export const blockTaskTool = {
|
|
|
316
317
|
};
|
|
317
318
|
export const yieldTaskTool = {
|
|
318
319
|
name: 'mcp__task__task_yield',
|
|
319
|
-
description: '
|
|
320
|
+
description: 'End this invocation while work still REMAINS: the task stays active and the next cycle continues it. Never use it to finish — when the objective is met, call task_complete instead.',
|
|
320
321
|
parameters: {
|
|
321
322
|
type: 'object',
|
|
322
323
|
properties: {
|
|
@@ -344,7 +345,12 @@ export const yieldTaskTool = {
|
|
|
344
345
|
agentId: null,
|
|
345
346
|
});
|
|
346
347
|
}
|
|
347
|
-
|
|
348
|
+
// Flash-class models often yield a finished task instead of completing it.
|
|
349
|
+
// Not auto-completed: a done checklist does not prove the objective is met.
|
|
350
|
+
const allDone = task.checklist.length > 0 && task.checklist.every((c) => c.status === 'done');
|
|
351
|
+
return ok(allDone
|
|
352
|
+
? { reminder: 'Every checklist item is done. If the objective is met, call task_complete now: a yielded task stays active and runs another cycle.' }
|
|
353
|
+
: {});
|
|
348
354
|
},
|
|
349
355
|
};
|
|
350
356
|
export const projectListTool = {
|
package/dist/session/store.d.ts
CHANGED
|
@@ -10,6 +10,10 @@ export interface CreateSessionInput {
|
|
|
10
10
|
id?: string;
|
|
11
11
|
/** Optional explicit createdAt (ISO). Defaults to now. Useful for tests. */
|
|
12
12
|
createdAt?: string;
|
|
13
|
+
/** Task cycle sessions only; written into the meta line when set. */
|
|
14
|
+
taskId?: string;
|
|
15
|
+
projectId?: string;
|
|
16
|
+
taskRole?: SessionMetaRecord['taskRole'];
|
|
13
17
|
}
|
|
14
18
|
/** Create a new session: writes the initial meta line. Returns the meta. */
|
|
15
19
|
export declare function createSession(input: CreateSessionInput): Promise<SessionMetaRecord>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/session/store.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,aAAa,EACb,OAAO,EACP,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,OAAO,IAAI,MAAM,CAEhC;AAED,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED,iBAAS,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED,iBAAS,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE/D;AAmDD,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/session/store.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,aAAa,EACb,OAAO,EACP,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,OAAO,IAAI,MAAM,CAEhC;AAED,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED,iBAAS,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,C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AE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,oBAAoB,EAAE,EACpC,IAAI,CAAC,EAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GACzC,aAAa,CAWf;AAID,eAAO,MAAM,YAAY;;;;CAA2C,CAAC"}
|
package/dist/session/store.js
CHANGED
|
@@ -77,6 +77,9 @@ export async function createSession(input) {
|
|
|
77
77
|
agentId: input.agentId,
|
|
78
78
|
title: input.title,
|
|
79
79
|
createdAt: input.createdAt ?? nowIso(),
|
|
80
|
+
...(input.taskId !== undefined ? { taskId: input.taskId } : {}),
|
|
81
|
+
...(input.projectId !== undefined ? { projectId: input.projectId } : {}),
|
|
82
|
+
...(input.taskRole !== undefined ? { taskRole: input.taskRole } : {}),
|
|
80
83
|
};
|
|
81
84
|
await ensureDir(agentDir(input.agentId));
|
|
82
85
|
const path = sessionPath(input.agentId, meta.id);
|
|
@@ -137,6 +140,9 @@ export async function listForAgent(agentId) {
|
|
|
137
140
|
const meta = await readFirstMeta(path);
|
|
138
141
|
if (!meta)
|
|
139
142
|
continue;
|
|
143
|
+
// Task cycle sessions are reached through their task, never the chat list.
|
|
144
|
+
if (meta.taskId)
|
|
145
|
+
continue;
|
|
140
146
|
const st = await stat(path);
|
|
141
147
|
entries.push({ meta, updatedAt: st.mtime });
|
|
142
148
|
}
|
package/dist/session/types.d.ts
CHANGED
|
@@ -30,6 +30,11 @@ export interface SessionMetaRecord {
|
|
|
30
30
|
/** ACP session id for acp runner agents; reused across turns and offered
|
|
31
31
|
* to session/load when the agent supports it. */
|
|
32
32
|
acpSessionId?: string;
|
|
33
|
+
/** Autonomous task cycle sessions only. Cycle sessions are hidden from chat
|
|
34
|
+
* lists (`listForAgent`) and deleted with their task. */
|
|
35
|
+
taskId?: string;
|
|
36
|
+
projectId?: string;
|
|
37
|
+
taskRole?: 'developer' | 'planner' | 'reviewer';
|
|
33
38
|
}
|
|
34
39
|
export type Role = 'user' | 'assistant' | 'tool';
|
|
35
40
|
export interface ToolAttachmentRecord {
|
|
@@ -53,6 +58,9 @@ export interface MessageRecord {
|
|
|
53
58
|
/** Assistant only, openai-style only. */
|
|
54
59
|
usage?: AssistantUsage;
|
|
55
60
|
attachments?: ToolAttachmentRecord[];
|
|
61
|
+
/** Task cycle closing notice (handoff recap). Feeds the memory sweep for
|
|
62
|
+
* task sessions; rendered as a notice in the cycle viewer. */
|
|
63
|
+
recap?: true;
|
|
56
64
|
createdAt: string;
|
|
57
65
|
}
|
|
58
66
|
export type SessionRecord = SessionMetaRecord | MessageRecord;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/session/types.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAElE,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,CAAC,EAAE,CAAC,CAAC;IACL,IAAI,EAAE,cAAc,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB;yDACqD;IACr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IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,CAAC,EAAE,CAAC,CAAC;IACL,IAAI,EAAE,SAAS,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,IAAI,CAAC;IACX;;2DAEuD;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,gFAAgF;IAChF,KAAK,CAAC,EAAE,aAAa,EAAE,CAAC;IACxB,sEAAsE;IACtE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,WAAW,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACrC;mEAC+D;IAC/D,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAAG,aAAa,CAAC;AAE9D,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,iBAAiB,CAAC;IACxB,QAAQ,EAAE,aAAa,EAAE,CAAC;CAC3B"}
|
package/dist/store/db.d.ts
CHANGED
|
@@ -51,17 +51,24 @@ export interface Task {
|
|
|
51
51
|
createdAt: string;
|
|
52
52
|
updatedAt: string;
|
|
53
53
|
}
|
|
54
|
+
/** How a task cycle ended. `running` until the cycle closes. */
|
|
55
|
+
export type CycleOutcome = 'running' | 'handoff' | 'completed' | 'blocked' | 'plan' | 'review-pass' | 'review-changes' | 'aborted' | 'failed';
|
|
54
56
|
export interface TaskMessage {
|
|
55
57
|
id: number;
|
|
56
58
|
taskId: string;
|
|
57
59
|
role: 'user' | 'assistant' | 'tool';
|
|
58
|
-
messageType: 'chat' | 'heartbeat' | 'heartbeat_live' | 'system' | 'block' | 'tool_call' | 'yield' | 'review' | 'plan';
|
|
60
|
+
messageType: 'chat' | 'heartbeat' | 'heartbeat_live' | 'system' | 'block' | 'tool_call' | 'yield' | 'review' | 'plan' | 'cycle';
|
|
59
61
|
content: string;
|
|
60
62
|
toolCallId?: string | null;
|
|
61
63
|
agentId?: string | null;
|
|
62
64
|
/** Identity of the agent that produced this message, captured at creation as
|
|
63
65
|
* `name · model` text (of that moment — survives later agent reconfig/rename). */
|
|
64
66
|
agentLabel?: string | null;
|
|
67
|
+
/** `cycle` messages only: the cycle's chat session, the agent that owns it. */
|
|
68
|
+
sessionId?: string | null;
|
|
69
|
+
sessionAgentId?: string | null;
|
|
70
|
+
cycleRole?: 'developer' | 'planner' | 'reviewer' | null;
|
|
71
|
+
cycleOutcome?: CycleOutcome | null;
|
|
65
72
|
createdAt: string;
|
|
66
73
|
}
|
|
67
74
|
export declare function dataDir(): string;
|
|
@@ -74,6 +81,11 @@ export declare function saveTask(task: Task): Promise<void>;
|
|
|
74
81
|
export declare function createTask(task: Omit<Task, 'id' | 'seq' | 'createdAt' | 'updatedAt'>): Promise<Task>;
|
|
75
82
|
export declare function addTaskMessage(msg: Omit<TaskMessage, 'id' | 'createdAt'>): Promise<TaskMessage>;
|
|
76
83
|
export declare function updateTaskMessageContent(id: number, content: string, type?: TaskMessage['messageType']): Promise<void>;
|
|
84
|
+
/** Close a `cycle` message with its outcome. Only the outcome changes. */
|
|
85
|
+
export declare function setCycleOutcome(messageId: number, outcome: CycleOutcome): Promise<void>;
|
|
86
|
+
/** Delete the chat session behind every `cycle` message of a task. A missing
|
|
87
|
+
* file or agent directory is not an error: the session may already be gone. */
|
|
88
|
+
export declare function deleteTaskSessions(taskId: string): Promise<void>;
|
|
77
89
|
export declare function deleteTask(taskId: string): Promise<void>;
|
|
78
90
|
/** Per-session memory digest: cursor + rolling summary maintained by the
|
|
79
91
|
* memory sweep daemon. The whole collection is a regenerable cache — never
|
package/dist/store/db.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/store/db.ts"],"names":[],"mappings":"AAGA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vC,UAAU,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,wEAAwE;IACxE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAGnB,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sDAAsD;IACtD,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,eAAe,EAAE,MAAM,CAAC;IACxB;4BACwB;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,wBAAwB;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAIzD;AAED,wBAAsB,YAAY,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAMtD;AAED,wBAAsB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG5D;AAED;;kEAEkE;AAClE,wBAAsB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAahE"}
|
package/dist/store/db.js
CHANGED
|
@@ -4,6 +4,7 @@ import { existsSync, mkdirSync } from 'node:fs';
|
|
|
4
4
|
import { Store } from '@morphql/store';
|
|
5
5
|
import { FolderAdapter } from '@morphql/store/node';
|
|
6
6
|
import { loadConfig, saveConfig } from './json.js';
|
|
7
|
+
import { deleteSession } from '../session/store.js';
|
|
7
8
|
export function dataDir() {
|
|
8
9
|
return process.env.CARETAKER_HOME ?? join(homedir(), '.caretaker');
|
|
9
10
|
}
|
|
@@ -141,11 +142,33 @@ export async function updateTaskMessageContent(id, content, type) {
|
|
|
141
142
|
await runQuery(`UPDATE task_messages SET content = '${cleaned}' WHERE id = ${id}`);
|
|
142
143
|
}
|
|
143
144
|
}
|
|
145
|
+
/** Close a `cycle` message with its outcome. Only the outcome changes. */
|
|
146
|
+
export async function setCycleOutcome(messageId, outcome) {
|
|
147
|
+
await runQuery(`UPDATE task_messages SET cycleOutcome = '${outcome}' WHERE id = ${messageId}`);
|
|
148
|
+
}
|
|
149
|
+
/** Delete the chat session behind every `cycle` message of a task. A missing
|
|
150
|
+
* file or agent directory is not an error: the session may already be gone. */
|
|
151
|
+
export async function deleteTaskSessions(taskId) {
|
|
152
|
+
if (!safeId(taskId))
|
|
153
|
+
return;
|
|
154
|
+
const rows = (await runQuery(`SELECT * FROM task_messages WHERE taskId = '${taskId}'`));
|
|
155
|
+
for (const m of rows) {
|
|
156
|
+
if (m.messageType !== 'cycle' || !m.sessionId || !m.sessionAgentId)
|
|
157
|
+
continue;
|
|
158
|
+
try {
|
|
159
|
+
await deleteSession(m.sessionAgentId, m.sessionId);
|
|
160
|
+
}
|
|
161
|
+
catch (err) {
|
|
162
|
+
console.warn(`[store/db] failed to delete cycle session ${m.sessionId}:`, err);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
144
166
|
// Permanently delete a task and all of its messages. Used by the delete
|
|
145
167
|
// action (real deletion from the store); archiving is a soft flag, not this.
|
|
146
168
|
export async function deleteTask(taskId) {
|
|
147
169
|
if (!safeId(taskId))
|
|
148
170
|
return;
|
|
171
|
+
await deleteTaskSessions(taskId);
|
|
149
172
|
await runQuery(`DELETE FROM task_messages WHERE taskId = '${taskId}'`);
|
|
150
173
|
await runQuery(`DELETE FROM tasks WHERE id = '${taskId}'`);
|
|
151
174
|
}
|
package/dist/store/json.d.ts
CHANGED
|
@@ -6,9 +6,19 @@ export declare function configPath(): string;
|
|
|
6
6
|
export declare function agentsPath(): string;
|
|
7
7
|
export declare function pluginsPath(): string;
|
|
8
8
|
export declare function mcpServersPath(): string;
|
|
9
|
+
export declare function uiStatePath(): string;
|
|
9
10
|
export declare const defaultConfig: CaretakerConfig;
|
|
10
11
|
export declare function loadConfig(): Promise<CaretakerConfig>;
|
|
11
12
|
export declare function saveConfig(c: CaretakerConfig): Promise<void>;
|
|
13
|
+
/** UI preferences that must survive the desktop app, whose per-launch port
|
|
14
|
+
* gives every launch a fresh origin (and so a fresh localStorage). Kept out of
|
|
15
|
+
* caretaker.json on purpose: the settings form saves that file whole from the
|
|
16
|
+
* copy it loaded, which would put back a stale value. */
|
|
17
|
+
export interface UiState {
|
|
18
|
+
lastProjectId?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function loadUiState(): Promise<UiState>;
|
|
21
|
+
export declare function saveUiState(s: UiState): Promise<void>;
|
|
12
22
|
export declare function loadAgents(): Promise<AgentConfig[]>;
|
|
13
23
|
export declare function saveAgents(a: AgentConfig[]): Promise<void>;
|
|
14
24
|
export declare function loadPlugins(): Promise<PluginsFile>;
|
package/dist/store/json.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/store/json.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAM7F,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAIlG,wBAAgB,OAAO,IAAI,MAAM,CAEhC;AACD,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AACD,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AACD,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AACD,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,eAAO,MAAM,aAAa,EAAE,eAG3B,CAAC;AAqDF,wBAAsB,UAAU,IAAI,OAAO,CAAC,eAAe,CAAC,CAK3D;AAED,wBAAsB,UAAU,CAAC,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CA4BlE;AAED,wBAAsB,UAAU,IAAI,OAAO,C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CA4BlE;AAED;;;0DAG0D;AAC1D,MAAM,WAAW,OAAO;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,wBAAsB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CAEpD;AAED,wBAAsB,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAE3D;AAED,wBAAsB,UAAU,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,CAEzD;AAED,wBAAsB,UAAU,CAAC,CAAC,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhE;AAED,wBAAsB,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,CASxD;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAElE;AAMD,wBAAsB,cAAc,IAAI,OAAO,CAAC,cAAc,CAAC,CAO9D;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAExE;AAID;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAO5E"}
|
package/dist/store/json.js
CHANGED
|
@@ -25,6 +25,9 @@ export function pluginsPath() {
|
|
|
25
25
|
export function mcpServersPath() {
|
|
26
26
|
return join(dataDir(), 'mcp.json');
|
|
27
27
|
}
|
|
28
|
+
export function uiStatePath() {
|
|
29
|
+
return join(dataDir(), 'ui-state.json');
|
|
30
|
+
}
|
|
28
31
|
export const defaultConfig = {
|
|
29
32
|
port: 17777,
|
|
30
33
|
providers: [],
|
|
@@ -116,6 +119,12 @@ export async function saveConfig(c) {
|
|
|
116
119
|
}
|
|
117
120
|
await writeJson(configPath(), c);
|
|
118
121
|
}
|
|
122
|
+
export async function loadUiState() {
|
|
123
|
+
return readJsonOrDefault(uiStatePath(), {});
|
|
124
|
+
}
|
|
125
|
+
export async function saveUiState(s) {
|
|
126
|
+
await writeJson(uiStatePath(), s);
|
|
127
|
+
}
|
|
119
128
|
export async function loadAgents() {
|
|
120
129
|
return readJsonOrDefault(agentsPath(), []);
|
|
121
130
|
}
|
|
@@ -329,6 +329,15 @@ body {
|
|
|
329
329
|
text-align: center;
|
|
330
330
|
flex: 1;
|
|
331
331
|
}
|
|
332
|
+
.app__link-btn {
|
|
333
|
+
padding: 0;
|
|
334
|
+
font: inherit;
|
|
335
|
+
background: none;
|
|
336
|
+
border: none;
|
|
337
|
+
color: var(--accent-cyan);
|
|
338
|
+
text-decoration: underline;
|
|
339
|
+
cursor: pointer;
|
|
340
|
+
}
|
|
332
341
|
.app__empty-state::before {
|
|
333
342
|
content: "";
|
|
334
343
|
width: 48px;
|
|
@@ -1217,6 +1226,42 @@ body.vscode-light .thinking__content {
|
|
|
1217
1226
|
border: 1px solid rgba(127, 127, 127, 0.16);
|
|
1218
1227
|
text-align: center;
|
|
1219
1228
|
}
|
|
1229
|
+
.cycle-card {
|
|
1230
|
+
align-self: stretch;
|
|
1231
|
+
display: flex;
|
|
1232
|
+
flex-wrap: wrap;
|
|
1233
|
+
align-items: center;
|
|
1234
|
+
gap: 8px;
|
|
1235
|
+
margin: 4px 0;
|
|
1236
|
+
padding: 8px 12px;
|
|
1237
|
+
border-radius: 6px;
|
|
1238
|
+
font-size: 12px;
|
|
1239
|
+
background: rgba(127, 127, 127, 0.08);
|
|
1240
|
+
border: 1px solid rgba(127, 127, 127, 0.16);
|
|
1241
|
+
}
|
|
1242
|
+
.cycle-card--clickable {
|
|
1243
|
+
cursor: pointer;
|
|
1244
|
+
}
|
|
1245
|
+
.cycle-card--clickable:hover,
|
|
1246
|
+
.cycle-card--clickable:focus-visible {
|
|
1247
|
+
border-color: var(--accent-cyan);
|
|
1248
|
+
outline: none;
|
|
1249
|
+
}
|
|
1250
|
+
.cycle-card__role {
|
|
1251
|
+
font-weight: 600;
|
|
1252
|
+
}
|
|
1253
|
+
.cycle-card__label {
|
|
1254
|
+
color: var(--vscode-descriptionForeground);
|
|
1255
|
+
font-size: 11px;
|
|
1256
|
+
}
|
|
1257
|
+
.cycle-card__outcome {
|
|
1258
|
+
margin-left: auto;
|
|
1259
|
+
font-size: 11px;
|
|
1260
|
+
}
|
|
1261
|
+
.cycle-card__time {
|
|
1262
|
+
font-size: 11px;
|
|
1263
|
+
color: var(--vscode-descriptionForeground);
|
|
1264
|
+
}
|
|
1220
1265
|
.notice .markdown-body {
|
|
1221
1266
|
font-size: 11px;
|
|
1222
1267
|
}
|
|
@@ -2033,12 +2078,6 @@ body.vscode-light .settings-panel__tab-btn--active {
|
|
|
2033
2078
|
-webkit-backdrop-filter: blur(20px);
|
|
2034
2079
|
z-index: 15;
|
|
2035
2080
|
}
|
|
2036
|
-
.app__sidebar-header {
|
|
2037
|
-
padding: 16px 20px;
|
|
2038
|
-
border-bottom: 1px solid var(--vscode-panel-border, oklch(1 0 0 / 0.05));
|
|
2039
|
-
display: flex;
|
|
2040
|
-
align-items: center;
|
|
2041
|
-
}
|
|
2042
2081
|
.app__sidebar-content {
|
|
2043
2082
|
flex: 1;
|
|
2044
2083
|
overflow-y: auto;
|
|
@@ -2178,37 +2217,53 @@ body.vscode-light .settings-panel__tab-btn--active {
|
|
|
2178
2217
|
padding: 8px 12px;
|
|
2179
2218
|
text-align: center;
|
|
2180
2219
|
}
|
|
2181
|
-
.
|
|
2182
|
-
|
|
2183
|
-
|
|
2220
|
+
.app__nav {
|
|
2221
|
+
width: 68px;
|
|
2222
|
+
min-width: 68px;
|
|
2223
|
+
display: flex;
|
|
2224
|
+
flex-direction: column;
|
|
2225
|
+
align-items: center;
|
|
2226
|
+
gap: 4px;
|
|
2227
|
+
padding: 14px 0;
|
|
2228
|
+
background: var(--vscode-sideBar-background, oklch(0.15 0.01 240 / 0.9));
|
|
2229
|
+
border-right: 1px solid var(--vscode-panel-border, oklch(1 0 0 / 0.08));
|
|
2230
|
+
z-index: 16;
|
|
2184
2231
|
}
|
|
2185
|
-
.
|
|
2186
|
-
width:
|
|
2232
|
+
.app__nav-logo {
|
|
2233
|
+
width: 24px;
|
|
2234
|
+
height: 24px;
|
|
2235
|
+
margin-bottom: 14px;
|
|
2236
|
+
}
|
|
2237
|
+
.app__nav-btn {
|
|
2238
|
+
width: 56px;
|
|
2187
2239
|
display: flex;
|
|
2240
|
+
flex-direction: column;
|
|
2188
2241
|
align-items: center;
|
|
2189
|
-
gap:
|
|
2190
|
-
padding: 8px
|
|
2242
|
+
gap: 4px;
|
|
2243
|
+
padding: 8px 0;
|
|
2191
2244
|
font-family: var(--font-sans);
|
|
2192
|
-
font-size:
|
|
2245
|
+
font-size: 10px;
|
|
2193
2246
|
font-weight: 600;
|
|
2194
2247
|
background: transparent;
|
|
2195
|
-
border:
|
|
2248
|
+
border: none;
|
|
2196
2249
|
border-radius: var(--radius-md);
|
|
2197
|
-
color: var(--vscode-
|
|
2250
|
+
color: var(--vscode-descriptionForeground, oklch(1 0 0 / 0.55));
|
|
2198
2251
|
cursor: pointer;
|
|
2199
2252
|
transition: var(--transition-smooth);
|
|
2200
2253
|
}
|
|
2201
|
-
.
|
|
2202
|
-
background: oklch(
|
|
2203
|
-
color: #
|
|
2204
|
-
box-shadow: 0 0 10px oklch(0.78 0.16 200 / 0.1);
|
|
2254
|
+
.app__nav-btn:hover {
|
|
2255
|
+
background: oklch(0.5 0 0 / 0.08);
|
|
2256
|
+
color: var(--vscode-foreground, #cbd5e1);
|
|
2205
2257
|
}
|
|
2206
|
-
.
|
|
2207
|
-
|
|
2208
|
-
|
|
2258
|
+
.app__nav-btn--active,
|
|
2259
|
+
.app__nav-btn--active:hover {
|
|
2260
|
+
background: oklch(0.78 0.16 200 / 0.12);
|
|
2261
|
+
color: var(--accent-cyan);
|
|
2209
2262
|
}
|
|
2210
|
-
.
|
|
2211
|
-
|
|
2263
|
+
.app__screen {
|
|
2264
|
+
flex: 1;
|
|
2265
|
+
min-width: 0;
|
|
2266
|
+
height: 100%;
|
|
2212
2267
|
}
|
|
2213
2268
|
.agent-status-dot {
|
|
2214
2269
|
width: 8px;
|