@hyperwindmill/caretaker-cli 0.22.0 → 0.24.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.
Files changed (61) hide show
  1. package/dist/cli/web/scheduler/locks.d.ts +3 -3
  2. package/dist/cli/web/scheduler/memory_extract.d.ts +55 -0
  3. package/dist/cli/web/scheduler/memory_extract.d.ts.map +1 -0
  4. package/dist/cli/web/scheduler/memory_extract.js +112 -0
  5. package/dist/cli/web/scheduler/memory_sweep.d.ts +68 -0
  6. package/dist/cli/web/scheduler/memory_sweep.d.ts.map +1 -0
  7. package/dist/cli/web/scheduler/memory_sweep.js +329 -0
  8. package/dist/cli/web/scheduler/task_review.d.ts +3 -0
  9. package/dist/cli/web/scheduler/task_review.d.ts.map +1 -1
  10. package/dist/cli/web/scheduler/task_review.js +1 -0
  11. package/dist/cli/web/scheduler/task_roles.js +1 -1
  12. package/dist/cli/web/scheduler/task_strategy.d.ts.map +1 -1
  13. package/dist/cli/web/scheduler/task_strategy.js +8 -4
  14. package/dist/cli/web/scheduler.d.ts.map +1 -1
  15. package/dist/cli/web/scheduler.js +5 -0
  16. package/dist/cli/web/server.d.ts.map +1 -1
  17. package/dist/cli/web/server.js +67 -27
  18. package/dist/harness/claude_code_runner.d.ts.map +1 -1
  19. package/dist/harness/claude_code_runner.js +5 -0
  20. package/dist/harness/loop.d.ts +9 -0
  21. package/dist/harness/loop.d.ts.map +1 -1
  22. package/dist/harness/loop.js +10 -0
  23. package/dist/harness/memory_recall.d.ts +23 -0
  24. package/dist/harness/memory_recall.d.ts.map +1 -0
  25. package/dist/harness/memory_recall.js +70 -0
  26. package/dist/harness/tools/builtin/index.d.ts +2 -1
  27. package/dist/harness/tools/builtin/index.d.ts.map +1 -1
  28. package/dist/harness/tools/builtin/index.js +4 -1
  29. package/dist/harness/tools/builtin/memory_tools.d.ts +3 -0
  30. package/dist/harness/tools/builtin/memory_tools.d.ts.map +1 -0
  31. package/dist/harness/tools/builtin/memory_tools.js +60 -0
  32. package/dist/harness/tools/builtin/task_tools.js +37 -37
  33. package/dist/harness/tools/resolve.d.ts.map +1 -1
  34. package/dist/harness/tools/resolve.js +15 -0
  35. package/dist/harness/tools/types.d.ts +6 -0
  36. package/dist/harness/tools/types.d.ts.map +1 -1
  37. package/dist/lib/docker.d.ts +1 -1
  38. package/dist/lib/docker.d.ts.map +1 -1
  39. package/dist/lib/docker.js +2 -2
  40. package/dist/lib/project_resolve.d.ts +5 -0
  41. package/dist/lib/project_resolve.d.ts.map +1 -0
  42. package/dist/lib/project_resolve.js +23 -0
  43. package/dist/lib/project_slug.d.ts +29 -0
  44. package/dist/lib/project_slug.d.ts.map +1 -0
  45. package/dist/lib/project_slug.js +41 -0
  46. package/dist/lib/task_git.d.ts +5 -5
  47. package/dist/lib/task_git.d.ts.map +1 -1
  48. package/dist/lib/task_git.js +8 -6
  49. package/dist/mcp/builtin_server.d.ts +1 -0
  50. package/dist/mcp/builtin_server.d.ts.map +1 -1
  51. package/dist/mcp/builtin_server.js +6 -5
  52. package/dist/store/db.d.ts +78 -7
  53. package/dist/store/db.d.ts.map +1 -1
  54. package/dist/store/db.js +127 -15
  55. package/dist/store/json.d.ts +1 -0
  56. package/dist/store/json.d.ts.map +1 -1
  57. package/dist/store/json.js +6 -1
  58. package/dist/tui/agents.js +5 -2
  59. package/dist/webview/standalone.js +602 -434
  60. package/dist/webview/standalone.js.map +4 -4
  61. package/package.json +3 -3
@@ -98,7 +98,7 @@ export function projectWorkingDir(project) {
98
98
  // Remote-backed with no explicit dir: managed clone under the data dir.
99
99
  // Resolved at call time (dataDir() follows CARETAKER_HOME), never persisted.
100
100
  if ((project.repositoryUrl || '').trim())
101
- return join(dataDir(), 'repos', String(project.id));
101
+ return join(dataDir(), 'repos', project.id);
102
102
  return '';
103
103
  }
104
104
  /**
@@ -218,8 +218,8 @@ function slug(title) {
218
218
  .replace(/^-+|-+$/g, '')
219
219
  .slice(0, 40) || 'task');
220
220
  }
221
- function worktreePathFor(projectId, taskId) {
222
- return join(dataDir(), 'worktrees', `${projectId}-${taskId}`);
221
+ function worktreePathFor(taskId) {
222
+ return join(dataDir(), 'worktrees', taskId); // task id is already <projectId>-<seq>
223
223
  }
224
224
  /**
225
225
  * Absolute git common dir for a (linked) worktree — the main repo's shared
@@ -242,10 +242,12 @@ export async function agentDirIn(worktreePath, projectWorkingDir) {
242
242
  const rel = relative(repoRoot, projectWorkingDir);
243
243
  return rel ? join(worktreePath, rel) : worktreePath;
244
244
  }
245
- export async function ensureWorktree(projectWorkingDir, projectId, taskId, title) {
245
+ export async function ensureWorktree(projectWorkingDir, taskId, title, existingBranch) {
246
246
  const repoRoot = await git(projectWorkingDir, ['rev-parse', '--show-toplevel']);
247
- const branch = `caretaker/task-${taskId}-${slug(title)}`;
248
- const worktreePath = worktreePathFor(projectId, taskId);
247
+ // The persisted branch is authoritative: re-deriving under the new id scheme
248
+ // would produce a different name and orphan a lost-path task's commits.
249
+ const branch = existingBranch || `caretaker/task-${taskId}-${slug(title)}`;
250
+ const worktreePath = worktreePathFor(taskId);
249
251
  try {
250
252
  await git(repoRoot, ['worktree', 'add', '-b', branch, worktreePath, 'HEAD']);
251
253
  }
@@ -3,6 +3,7 @@ import type { Tool } from '../harness/tools/index.js';
3
3
  import type { AgentConfig } from '../types.js';
4
4
  export declare const TASK_PREFIX = "mcp__task__";
5
5
  export declare const EMAIL_PREFIX = "mcp__email__";
6
+ export declare const MEMORY_PREFIX = "mcp__memory__";
6
7
  export declare function builtinMcpTools(): Tool[];
7
8
  export declare function buildBuiltinMcpServer(info?: {
8
9
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"builtin_server.d.ts","sourceRoot":"","sources":["../../src/mcp/builtin_server.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAGnE,OAAO,KAAK,EAAE,IAAI,EAAe,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,WAAW,gBAAgB,CAAC;AACzC,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAQ3C,wBAAgB,eAAe,IAAI,IAAI,EAAE,CAExC;AAED,wBAAgB,qBAAqB,CACnC,IAAI,GAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAiD,EACtF,IAAI,GAAE;IAAE,WAAW,CAAC,EAAE,WAAW,CAAA;CAAO,GACvC,MAAM,CAoCR"}
1
+ {"version":3,"file":"builtin_server.d.ts","sourceRoot":"","sources":["../../src/mcp/builtin_server.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAGnE,OAAO,KAAK,EAAE,IAAI,EAAe,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,WAAW,gBAAgB,CAAC;AACzC,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAC3C,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAQ7C,wBAAgB,eAAe,IAAI,IAAI,EAAE,CAExC;AAED,wBAAgB,qBAAqB,CACnC,IAAI,GAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAiD,EACtF,IAAI,GAAE;IAAE,WAAW,CAAC,EAAE,WAAW,CAAA;CAAO,GACvC,MAAM,CAoCR"}
@@ -1,10 +1,10 @@
1
1
  // Shared builder: wraps the built-in `mcp__<ns>__*` registry tools as an MCP
2
2
  // Server. Used by BOTH the per-task HTTP bridge (cli/web/mcp_bridge.ts) and the
3
3
  // general stdio subcommand (cli/mcp.ts) so this surface has one definition and
4
- // one wrapping. Two namespaces today — `task` (drive the autonomous task state
5
- // machine) and `email` (send mail through a configured account); a new tool in
6
- // either is picked up by both consumers through the prefix filter, never a
7
- // second allowlist.
4
+ // one wrapping. Three namespaces today — `task` (drive the autonomous task state
5
+ // machine), `email` (send mail through a configured account), and `memory`
6
+ // (read stored memories, bumping recall accounting); a new tool in either is
7
+ // picked up by both consumers through the prefix filter, never a second allowlist.
8
8
  //
9
9
  // The tools are context-free (they take task_id / account by argument), so a
10
10
  // stub ToolContext is sufficient — except for the caller's identity, which the
@@ -17,7 +17,8 @@ import { ListToolsRequestSchema, CallToolRequestSchema } from '@modelcontextprot
17
17
  import { tools as registry } from '../harness/tools/instance.js';
18
18
  export const TASK_PREFIX = 'mcp__task__';
19
19
  export const EMAIL_PREFIX = 'mcp__email__';
20
- const SERVED_PREFIXES = [TASK_PREFIX, EMAIL_PREFIX];
20
+ export const MEMORY_PREFIX = 'mcp__memory__';
21
+ const SERVED_PREFIXES = [TASK_PREFIX, EMAIL_PREFIX, MEMORY_PREFIX];
21
22
  /** `mcp__task__task_complete` → `task_complete`, `mcp__email__email_send` → `email_send`. */
22
23
  function externalName(name) {
23
24
  return name.replace(/^mcp__[a-z]+__/, '');
@@ -6,7 +6,7 @@ export interface ChecklistItem {
6
6
  order: number;
7
7
  }
8
8
  export interface Project {
9
- id: number;
9
+ id: string;
10
10
  name: string;
11
11
  description: string;
12
12
  workingDir: string;
@@ -19,8 +19,13 @@ export interface Project {
19
19
  sddEnabled?: boolean | null;
20
20
  }
21
21
  export interface Task {
22
- id: number;
23
- projectId: number;
22
+ /** `<projectId>-<seq>`. OPAQUE — never parse it; projectId and seq below
23
+ * are the source of truth. Embedded verbatim in the worktree dir name
24
+ * (~/.caretaker/worktrees/<id>) and container name (caretaker-task-<id>). */
25
+ id: string;
26
+ projectId: string;
27
+ /** Per-project sequence number; stored, never derived from id. */
28
+ seq: number;
24
29
  title: string;
25
30
  objective: string;
26
31
  checklist: ChecklistItem[];
@@ -48,7 +53,7 @@ export interface Task {
48
53
  }
49
54
  export interface TaskMessage {
50
55
  id: number;
51
- taskId: number;
56
+ taskId: string;
52
57
  role: 'user' | 'assistant' | 'tool';
53
58
  messageType: 'chat' | 'heartbeat' | 'heartbeat_live' | 'system' | 'block' | 'tool_call' | 'yield' | 'review' | 'plan';
54
59
  content: string;
@@ -64,10 +69,76 @@ export declare function dbStoreDir(): string;
64
69
  export declare function getDb(): Store;
65
70
  export declare function tryNormalizeChecklistStatus(status: any): 'pending' | 'in_progress' | 'done' | 'skipped' | null;
66
71
  export declare function runQuery(sql: string): Promise<any>;
67
- export declare function getTaskById(id: number): Promise<Task | null>;
72
+ export declare function getTaskById(id: string): Promise<Task | null>;
68
73
  export declare function saveTask(task: Task): Promise<void>;
69
- export declare function createTask(task: Omit<Task, 'id' | 'createdAt' | 'updatedAt'>): Promise<Task>;
74
+ export declare function createTask(task: Omit<Task, 'id' | 'seq' | 'createdAt' | 'updatedAt'>): Promise<Task>;
70
75
  export declare function addTaskMessage(msg: Omit<TaskMessage, 'id' | 'createdAt'>): Promise<TaskMessage>;
71
76
  export declare function updateTaskMessageContent(id: number, content: string, type?: TaskMessage['messageType']): Promise<void>;
72
- export declare function deleteTask(taskId: number): Promise<void>;
77
+ export declare function deleteTask(taskId: string): Promise<void>;
78
+ /** Per-session memory digest: cursor + rolling summary maintained by the
79
+ * memory sweep daemon. The whole collection is a regenerable cache — never
80
+ * a source of truth; deleting it costs one full re-scan.
81
+ * See docs/superpowers/specs/2026-08-24-memory-daemon-step1-design.md */
82
+ export interface SessionDigest {
83
+ /** = sessionId (uuid of the JSONL session file). */
84
+ id: string;
85
+ agentId: string;
86
+ /** Cursor: last processed MessageRecord.id. '' = nothing processed yet. */
87
+ lastMessageId: string;
88
+ /** Messages processed so far (O(1) "how many new?" check). */
89
+ messageCount: number;
90
+ /** Rolling summary, standalone text. '' until the first summarize call. */
91
+ summary: string;
92
+ /** Model that produced the current summary. '' until then. */
93
+ model: string;
94
+ /** Start of the last *fully caught-up* scan. INVARIANT: written only when
95
+ * the digest covers everything read at this timestamp; the sweep's mtime
96
+ * gate (skip when file mtime < scannedAt) is only sound because of that. */
97
+ scannedAt: string;
98
+ updatedAt: string;
99
+ }
100
+ export declare function getSessionDigest(sessionId: string): Promise<SessionDigest | null>;
101
+ export declare function listSessionDigests(): Promise<SessionDigest[]>;
102
+ export declare function saveSessionDigest(d: SessionDigest): Promise<void>;
103
+ export declare function deleteSessionDigest(sessionId: string): Promise<void>;
104
+ /** One durable memory extracted by the sweep's combined call. Unlike the
105
+ * digests this is NOT a regenerable cache — it is the first durable store
106
+ * of the memory subsystem. Append-only at write time; merge/supersede/decay
107
+ * are the future consolidation's job.
108
+ * See docs/superpowers/specs/2026-08-24-memory-daemon-step2-extraction-design.md */
109
+ export interface Memory {
110
+ /** crypto.randomUUID() — passes safeId. */
111
+ id: string;
112
+ /** '' = global (user/machine level). Resolved host-side, never by the model. */
113
+ projectId: string;
114
+ /** Semantic/episodic split: timeless knowledge vs a dated event. */
115
+ kind: 'fact' | 'episode';
116
+ /** Initial strength, derived from the tone of the conversation at write
117
+ * time (the tone is unrecoverable later). Ordinal on purpose — models
118
+ * calibrate numeric scales poorly. */
119
+ importance: 'low' | 'normal' | 'high';
120
+ title: string;
121
+ /** Markdown, self-contained. */
122
+ body: string;
123
+ /** Associative base for the future read path, emitted at write time. */
124
+ keywords: string[];
125
+ /** Times delivered by memory_read. Absent on pre-step-3 records = 0. */
126
+ recallCount?: number;
127
+ /** ISO timestamp of the last memory_read delivery. */
128
+ lastRecalledAt?: string;
129
+ sourceSessionId: string;
130
+ /** The session's agent directory — NOT a scope; mined by a future
131
+ * personality step. */
132
+ sourceAgentId: string;
133
+ /** Extraction model. */
134
+ model: string;
135
+ createdAt: string;
136
+ }
137
+ export declare function saveMemory(m: Memory): Promise<void>;
138
+ export declare function listMemories(): Promise<Memory[]>;
139
+ export declare function deleteMemory(id: string): Promise<void>;
140
+ /** Recall event: memory_read delivered this memory to an agent. Delete +
141
+ * insert (saveSessionDigest pattern — the store has no UPDATE). No-op on
142
+ * unknown ids: a stale id in a prelude block is not an error. */
143
+ export declare function bumpMemoryRecall(id: string): Promise<void>;
73
144
  //# source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M,WAAW,MAAM;IACrB,2CAA2C;IAC3C,EAAE,EAAE,MAAM,CAAC;IACX,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB;;2CAEuC;IACvC,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
@@ -3,6 +3,7 @@ import { homedir } from 'node:os';
3
3
  import { existsSync, mkdirSync } from 'node:fs';
4
4
  import { Store } from '@morphql/store';
5
5
  import { FolderAdapter } from '@morphql/store/node';
6
+ import { loadConfig, saveConfig } from './json.js';
6
7
  export function dataDir() {
7
8
  return process.env.CARETAKER_HOME ?? join(homedir(), '.caretaker');
8
9
  }
@@ -21,6 +22,25 @@ export function getDb() {
21
22
  return dbInstance;
22
23
  }
23
24
  let queryQueue = Promise.resolve();
25
+ let migrationPromise = null;
26
+ /** One-time, idempotent rewrite of numeric ids to their string composites:
27
+ * project 3 → "3", task 17 in project 3 → "3-17". Chosen so every derived
28
+ * artifact name (worktrees/3-17, caretaker-task-3-17, repos/3) is
29
+ * byte-identical to what is already on disk — nothing moves. Runs as the
30
+ * first operation on the query queue, so every surface waits for it. */
31
+ async function migrateNumericIds() {
32
+ const store = getDb();
33
+ const tasks = (await store.query('SELECT * FROM tasks'));
34
+ const legacy = tasks.filter((t) => typeof t.id === 'number');
35
+ for (const t of legacy) {
36
+ const oldId = t.id;
37
+ const projectId = String(t.projectId);
38
+ const newId = `${projectId}-${oldId}`;
39
+ await store.query(`DELETE FROM tasks WHERE id = ${oldId}`);
40
+ await store.query(`INSERT INTO tasks ${JSON.stringify({ ...t, id: newId, projectId, seq: oldId })}`);
41
+ await store.query(`UPDATE task_messages SET taskId = '${newId}' WHERE taskId = ${oldId}`);
42
+ }
43
+ }
24
44
  export function tryNormalizeChecklistStatus(status) {
25
45
  const s = String(status || '').trim().toLowerCase();
26
46
  if (s === 'completed' || s === 'complete' || s === 'done') {
@@ -37,15 +57,27 @@ export function tryNormalizeChecklistStatus(status) {
37
57
  }
38
58
  return null;
39
59
  }
60
+ /** Ids are validated slugs/composites; anything else never matches a record.
61
+ * Also keeps quotes/backslashes out of interpolated queries. */
62
+ function safeId(id) {
63
+ return /^[a-z0-9][a-z0-9-]*$/.test(id);
64
+ }
40
65
  export async function runQuery(sql) {
41
- const op = () => getDb().query(sql);
66
+ if (!migrationPromise)
67
+ migrationPromise = migrateNumericIds();
68
+ const op = async () => {
69
+ await migrationPromise;
70
+ return getDb().query(sql);
71
+ };
42
72
  const resultPromise = queryQueue.then(op);
43
73
  queryQueue = resultPromise.catch(() => { });
44
74
  return resultPromise;
45
75
  }
46
76
  export async function getTaskById(id) {
77
+ if (!safeId(id))
78
+ return null;
47
79
  try {
48
- const taskRows = (await runQuery(`SELECT * FROM tasks WHERE id = ${id}`));
80
+ const taskRows = (await runQuery(`SELECT * FROM tasks WHERE id = '${id}'`));
49
81
  return taskRows[0] || null;
50
82
  }
51
83
  catch (err) {
@@ -53,26 +85,36 @@ export async function getTaskById(id) {
53
85
  }
54
86
  }
55
87
  export async function saveTask(task) {
56
- await runQuery(`DELETE FROM tasks WHERE id = ${task.id}`);
88
+ await runQuery(`DELETE FROM tasks WHERE id = '${task.id}'`);
57
89
  await runQuery(`INSERT INTO tasks ${JSON.stringify(task)}`);
58
90
  }
59
91
  export async function createTask(task) {
60
- const payload = {
92
+ if (!safeId(task.projectId))
93
+ throw new Error(`Invalid project id: ${task.projectId}`);
94
+ const config = await loadConfig();
95
+ const project = (config.projects || []).find((p) => p.id === task.projectId);
96
+ const existing = (await runQuery(`SELECT * FROM tasks WHERE projectId = '${task.projectId}'`));
97
+ const seq = Math.max(project?.nextTaskSeq ?? 0, 0, ...existing.map((t) => t.seq ?? 0)) + 1;
98
+ const record = {
61
99
  ...task,
62
- id: '$auto',
100
+ id: `${task.projectId}-${seq}`,
101
+ seq,
63
102
  createdAt: new Date().toISOString(),
64
103
  updatedAt: new Date().toISOString(),
65
104
  };
66
- await runQuery(`INSERT INTO tasks ${JSON.stringify(payload)}`);
67
- // Retrieve the created task to get its auto-assigned ID
68
- const allTasks = (await runQuery(`SELECT * FROM tasks`));
69
- const created = allTasks.find((t) => t.projectId === task.projectId && t.title === task.title && t.objective === task.objective);
70
- if (!created) {
71
- throw new Error('Failed to retrieve newly created task');
105
+ await runQuery(`INSERT INTO tasks ${JSON.stringify(record)}`);
106
+ if (project) {
107
+ // ponytail: unlocked read-modify-write on nextTaskSeq; the max() over
108
+ // existing seqs above heals races and stale-config rollbacks. Move the
109
+ // counter into the folder DB behind runQuery's queue if it ever matters.
110
+ project.nextTaskSeq = seq;
111
+ await saveConfig(config);
72
112
  }
73
- return created;
113
+ return record;
74
114
  }
75
115
  export async function addTaskMessage(msg) {
116
+ if (!safeId(msg.taskId))
117
+ throw new Error(`Invalid task id: ${msg.taskId}`);
76
118
  const payload = {
77
119
  ...msg,
78
120
  id: '$auto',
@@ -80,7 +122,7 @@ export async function addTaskMessage(msg) {
80
122
  };
81
123
  await runQuery(`INSERT INTO task_messages ${JSON.stringify(payload)}`);
82
124
  // Find the inserted message to get its auto-increment ID
83
- const messages = (await runQuery(`SELECT * FROM task_messages WHERE taskId = ${msg.taskId}`));
125
+ const messages = (await runQuery(`SELECT * FROM task_messages WHERE taskId = '${msg.taskId}'`));
84
126
  const created = messages[messages.length - 1];
85
127
  if (!created) {
86
128
  throw new Error('Failed to retrieve newly created task message');
@@ -102,6 +144,76 @@ export async function updateTaskMessageContent(id, content, type) {
102
144
  // Permanently delete a task and all of its messages. Used by the delete
103
145
  // action (real deletion from the store); archiving is a soft flag, not this.
104
146
  export async function deleteTask(taskId) {
105
- await runQuery(`DELETE FROM task_messages WHERE taskId = ${taskId}`);
106
- await runQuery(`DELETE FROM tasks WHERE id = ${taskId}`);
147
+ if (!safeId(taskId))
148
+ return;
149
+ await runQuery(`DELETE FROM task_messages WHERE taskId = '${taskId}'`);
150
+ await runQuery(`DELETE FROM tasks WHERE id = '${taskId}'`);
151
+ }
152
+ export async function getSessionDigest(sessionId) {
153
+ if (!safeId(sessionId))
154
+ return null;
155
+ try {
156
+ const rows = (await runQuery(`SELECT * FROM session_digests WHERE id = '${sessionId}'`));
157
+ return rows[0] || null;
158
+ }
159
+ catch {
160
+ return null;
161
+ }
162
+ }
163
+ export async function listSessionDigests() {
164
+ try {
165
+ return (await runQuery('SELECT * FROM session_digests'));
166
+ }
167
+ catch {
168
+ return [];
169
+ }
170
+ }
171
+ export async function saveSessionDigest(d) {
172
+ if (!safeId(d.id))
173
+ throw new Error(`Invalid session id: ${d.id}`);
174
+ // Delete + insert = upsert; summary goes through JSON.stringify, so quotes
175
+ // and newlines never touch the interpolated SQL string.
176
+ await runQuery(`DELETE FROM session_digests WHERE id = '${d.id}'`);
177
+ await runQuery(`INSERT INTO session_digests ${JSON.stringify({ ...d, updatedAt: new Date().toISOString() })}`);
178
+ }
179
+ export async function deleteSessionDigest(sessionId) {
180
+ if (!safeId(sessionId))
181
+ return;
182
+ await runQuery(`DELETE FROM session_digests WHERE id = '${sessionId}'`);
183
+ }
184
+ export async function saveMemory(m) {
185
+ if (!safeId(m.id))
186
+ throw new Error(`Invalid memory id: ${m.id}`);
187
+ // Insert-only: memories are append-only; there is deliberately no upsert.
188
+ await runQuery(`INSERT INTO memories ${JSON.stringify(m)}`);
189
+ }
190
+ export async function listMemories() {
191
+ try {
192
+ return (await runQuery('SELECT * FROM memories'));
193
+ }
194
+ catch {
195
+ return [];
196
+ }
197
+ }
198
+ export async function deleteMemory(id) {
199
+ if (!safeId(id))
200
+ return;
201
+ await runQuery(`DELETE FROM memories WHERE id = '${id}'`);
202
+ }
203
+ /** Recall event: memory_read delivered this memory to an agent. Delete +
204
+ * insert (saveSessionDigest pattern — the store has no UPDATE). No-op on
205
+ * unknown ids: a stale id in a prelude block is not an error. */
206
+ export async function bumpMemoryRecall(id) {
207
+ if (!safeId(id))
208
+ return;
209
+ const rows = (await runQuery(`SELECT * FROM memories WHERE id = '${id}'`));
210
+ const m = rows[0];
211
+ if (!m)
212
+ return;
213
+ await runQuery(`DELETE FROM memories WHERE id = '${id}'`);
214
+ await runQuery(`INSERT INTO memories ${JSON.stringify({
215
+ ...m,
216
+ recallCount: (m.recallCount ?? 0) + 1,
217
+ lastRecalledAt: new Date().toISOString(),
218
+ })}`);
107
219
  }
@@ -1,5 +1,6 @@
1
1
  import type { AgentConfig, CaretakerConfig, McpServersFile, PluginsFile } from '../types.js';
2
2
  export { validateRepositoryUrl } from '../lib/repo_url.js';
3
+ export { validateProjectSlug, validateProjectIds, PROJECT_SLUG_RE } from '../lib/project_slug.js';
3
4
  export declare function dataDir(): string;
4
5
  export declare function configPath(): string;
5
6
  export declare function agentsPath(): string;
@@ -1 +1 @@
1
- {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/store/json.ts"],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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,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"}
@@ -7,6 +7,7 @@ import { encrypt, isEncrypted } from '../lib/encryption.js';
7
7
  // persists config (web server, VSCode extension) enforces the same rule on
8
8
  // `projects[].repositoryUrl` before calling saveConfig.
9
9
  export { validateRepositoryUrl } from '../lib/repo_url.js';
10
+ export { validateProjectSlug, validateProjectIds, PROJECT_SLUG_RE } from '../lib/project_slug.js';
10
11
  // Path accessors are resolved at call time, not import time, so test runs
11
12
  // that share a process can switch CARETAKER_HOME between suites.
12
13
  export function dataDir() {
@@ -80,7 +81,11 @@ async function writeJson(path, data) {
80
81
  throw lastErr;
81
82
  }
82
83
  export async function loadConfig() {
83
- return readJsonOrDefault(configPath(), defaultConfig);
84
+ const cfg = await readJsonOrDefault(configPath(), defaultConfig);
85
+ // Numeric project ids from older versions become their string slugs ("3").
86
+ for (const p of cfg.projects || [])
87
+ p.id = String(p.id);
88
+ return cfg;
84
89
  }
85
90
  export async function saveConfig(c) {
86
91
  if (c.scheduler?.tasks) {
@@ -257,8 +257,11 @@ const NAMESPACE_DESCRIPTIONS = {
257
257
  mcp__email__: 'List the configured email accounts and send mail',
258
258
  };
259
259
  /** The picker's tool list: one synthetic entry per `mcp__<ns>__` namespace in
260
- * place of its individual tools, everything else as-is. */
261
- function namespacedToolList(tools) {
260
+ * place of its individual tools, everything else as-is. Hidden tools
261
+ * (memory_read) are harness infrastructure, auto-included by
262
+ * resolveAgentTools behind their own gate — never a picker choice. */
263
+ function namespacedToolList(allTools) {
264
+ const tools = allTools.filter((t) => !t.hidden);
262
265
  const namespaces = [
263
266
  ...new Set(tools.map((t) => /^mcp__[a-z]+__/.exec(t.name)?.[0]).filter((p) => !!p)),
264
267
  ];