@hasna/todos 0.9.69 → 0.9.71
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/dashboard/dist/assets/index-DWpVlvWb.css +1 -0
- package/dashboard/dist/index.html +2 -2
- package/dist/cli/index.js +376 -126
- package/dist/db/agents.d.ts +11 -4
- package/dist/db/agents.d.ts.map +1 -1
- package/dist/db/database.d.ts.map +1 -1
- package/dist/db/tasks.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +241 -86
- package/dist/lib/search.d.ts.map +1 -1
- package/dist/mcp/index.js +376 -126
- package/dist/server/index.js +207 -93
- package/dist/types/index.d.ts +20 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/dashboard/dist/assets/index-BXQ39iMX.css +0 -1
- /package/dashboard/dist/assets/{index-B-w1tUlm.js → index-DVzieYOj.js} +0 -0
package/dist/db/agents.d.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import type { Database } from "bun:sqlite";
|
|
2
|
-
import type { Agent, RegisterAgentInput } from "../types/index.js";
|
|
2
|
+
import type { Agent, AgentConflictError, RegisterAgentInput } from "../types/index.js";
|
|
3
3
|
/**
|
|
4
|
-
* Register an agent.
|
|
5
|
-
*
|
|
4
|
+
* Register an agent. Returns the agent or a conflict descriptor.
|
|
5
|
+
*
|
|
6
|
+
* Conflict rules:
|
|
7
|
+
* - Name free → create, bind session_id if provided
|
|
8
|
+
* - Name taken, same session_id → heartbeat, return agent ✓
|
|
9
|
+
* - Name taken, different session_id, agent ACTIVE (<30min) → CONFLICT error
|
|
10
|
+
* - Name taken, different session_id, agent STALE (>30min) → takeover, update session_id
|
|
11
|
+
* - Name taken, no session_id provided → heartbeat + return (backward compat, no block)
|
|
6
12
|
*/
|
|
7
|
-
export declare function registerAgent(input: RegisterAgentInput, db?: Database): Agent;
|
|
13
|
+
export declare function registerAgent(input: RegisterAgentInput, db?: Database): Agent | AgentConflictError;
|
|
14
|
+
export declare function isAgentConflict(result: Agent | AgentConflictError): result is AgentConflictError;
|
|
8
15
|
export declare function getAgent(id: string, db?: Database): Agent | null;
|
|
9
16
|
export declare function getAgentByName(name: string, db?: Database): Agent | null;
|
|
10
17
|
export declare function listAgents(db?: Database): Agent[];
|
package/dist/db/agents.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/db/agents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAY,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/db/agents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,kBAAkB,EAAY,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAkBjG;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,kBAAkB,CA2DlG;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,KAAK,GAAG,kBAAkB,GAAG,MAAM,IAAI,kBAAkB,CAEhG;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,IAAI,CAIhE;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,IAAI,CAKxE;AAED,wBAAgB,UAAU,CAAC,EAAE,CAAC,EAAE,QAAQ,GAAG,KAAK,EAAE,CAGjD;AAED,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,IAAI,CAGnE;AAED,wBAAgB,WAAW,CACzB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,EAC7M,EAAE,CAAC,EAAE,QAAQ,GACZ,KAAK,CAgDP;AAED,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,OAAO,CAG9D;AAED,sCAAsC;AACtC,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,KAAK,EAAE,CAGxE;AAED,iFAAiF;AACjF,wBAAgB,WAAW,CAAC,EAAE,CAAC,EAAE,QAAQ,GAAG,OAAO,EAAE,CAepD;AAED,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/db/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAItC,eAAO,MAAM,mBAAmB,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/db/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAItC,eAAO,MAAM,mBAAmB,KAAK,CAAC;AA0XtC,wBAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,CAkBrD;AAkND,wBAAgB,aAAa,IAAI,IAAI,CAKpC;AAED,wBAAgB,aAAa,IAAI,IAAI,CAEpC;AAED,wBAAgB,GAAG,IAAI,MAAM,CAE5B;AAED,wBAAgB,IAAI,IAAI,MAAM,CAE7B;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAK9D;AAED,wBAAgB,gBAAgB,CAAC,KAAK,SAAa,GAAG,MAAM,CAG3D;AAED,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAGpD;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA0B9F"}
|
package/dist/db/tasks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../src/db/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAoB,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,EACV,eAAe,EACf,UAAU,EACV,IAAI,EACJ,cAAc,EACd,UAAU,EACV,YAAY,EAEZ,UAAU,EACV,iBAAiB,EACjB,eAAe,EAChB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../src/db/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAoB,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,EACV,eAAe,EACf,UAAU,EACV,IAAI,EACJ,cAAc,EACd,UAAU,EACV,YAAY,EAEZ,UAAU,EACV,iBA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C;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;CAChC;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,mBAAmB,EAAE,EAC7B,EAAE,CAAC,EAAE,QAAQ,GACZ;IAAE,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAAE,CA+B/F;AAED,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE;IAAE,MAAM,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,EACxG,EAAE,CAAC,EAAE,QAAQ,GACZ;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAAE,CAuB9D"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export type { TaskGraphNode, TaskGraph, BulkCreateTaskInput, ActiveWorkItem, Sta
|
|
|
6
6
|
export { createProject, getProject, getProjectByPath, listProjects, updateProject, deleteProject, ensureProject, nextTaskShortId, slugify, } from "./db/projects.js";
|
|
7
7
|
export { createPlan, getPlan, listPlans, updatePlan, deletePlan, } from "./db/plans.js";
|
|
8
8
|
export { addComment, getComment, listComments, deleteComment, logProgress, } from "./db/comments.js";
|
|
9
|
-
export { registerAgent, getAgent, getAgentByName, listAgents, updateAgent, updateAgentActivity, deleteAgent, getDirectReports, getOrgChart, } from "./db/agents.js";
|
|
9
|
+
export { registerAgent, isAgentConflict, getAgent, getAgentByName, listAgents, updateAgent, updateAgentActivity, deleteAgent, getDirectReports, getOrgChart, } from "./db/agents.js";
|
|
10
10
|
export type { OrgNode } from "./db/agents.js";
|
|
11
11
|
export { createTaskList, getTaskList, getTaskListBySlug, listTaskLists, updateTaskList, deleteTaskList, ensureTaskList, } from "./db/task-lists.js";
|
|
12
12
|
export { createSession, getSession, listSessions, updateSessionActivity, deleteSession, } from "./db/sessions.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACrD,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAGnD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAG1G,OAAO,EACL,UAAU,EACV,OAAO,EACP,oBAAoB,EACpB,SAAS,EACT,UAAU,EACV,UAAU,EACV,UAAU,EACV,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,eAAe,EACf,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,aAAa,EACb,aAAa,EACb,QAAQ,EACR,oBAAoB,EACpB,aAAa,EACb,SAAS,EACT,cAAc,EAC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AoB,GACrB,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACrD,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAGnD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAG1G,OAAO,EACL,UAAU,EACV,OAAO,EACP,oBAAoB,EACpB,SAAS,EACT,UAAU,EACV,UAAU,EACV,UAAU,EACV,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,eAAe,EACf,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,aAAa,EACb,aAAa,EACb,QAAQ,EACR,oBAAoB,EACpB,aAAa,EACb,SAAS,EACT,cAAc,EACd,aAAa,EACb,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,mBAAmB,EAAE,cAAc,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAGzI,OAAO,EACL,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,aAAa,EACb,aAAa,EACb,eAAe,EACf,OAAO,GACR,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,UAAU,EACV,OAAO,EACP,SAAS,EACT,UAAU,EACV,UAAU,GACX,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,UAAU,EACV,UAAU,EACV,YAAY,EACZ,aAAa,EACb,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,aAAa,EACb,eAAe,EACf,QAAQ,EACR,cA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cAAc,EAAE,MAAM,qBAAqB,CAAC;AACjG,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtD,YAAY,EACV,IAAI,EACJ,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,UAAU,EACV,UAAU,EACV,YAAY,EACZ,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,OAAO,EACP,kBAAkB,EAClB,IAAI,EACJ,eAAe,EACf,eAAe,EACf,UAAU,EACV,OAAO,EACP,kBAAkB,EAClB,KAAK,EACL,QAAQ,EACR,kBAAkB,EAClB,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EACnB,UAAU,EACV,OAAO,EACP,UAAU,EACV,WAAW,EACX,OAAO,EACP,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,GAAG,EACH,cAAc,GACf,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,aAAa,EACb,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,SAAS,EACT,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -510,6 +510,63 @@ var MIGRATIONS = [
|
|
|
510
510
|
ALTER TABLE task_comments ADD COLUMN type TEXT DEFAULT 'comment' CHECK(type IN ('comment', 'progress', 'note'));
|
|
511
511
|
ALTER TABLE task_comments ADD COLUMN progress_pct INTEGER CHECK(progress_pct IS NULL OR (progress_pct >= 0 AND progress_pct <= 100));
|
|
512
512
|
INSERT OR IGNORE INTO _migrations (id) VALUES (14);
|
|
513
|
+
`,
|
|
514
|
+
`
|
|
515
|
+
CREATE VIRTUAL TABLE IF NOT EXISTS tasks_fts USING fts5(
|
|
516
|
+
task_id UNINDEXED,
|
|
517
|
+
title,
|
|
518
|
+
description,
|
|
519
|
+
tags,
|
|
520
|
+
tokenize='unicode61 remove_diacritics 2'
|
|
521
|
+
);
|
|
522
|
+
|
|
523
|
+
INSERT INTO tasks_fts(rowid, task_id, title, description, tags)
|
|
524
|
+
SELECT t.rowid, t.id, t.title, COALESCE(t.description, ''),
|
|
525
|
+
COALESCE((SELECT GROUP_CONCAT(tag, ' ') FROM task_tags WHERE task_id = t.id), '')
|
|
526
|
+
FROM tasks t;
|
|
527
|
+
|
|
528
|
+
CREATE TRIGGER IF NOT EXISTS tasks_fts_ai AFTER INSERT ON tasks BEGIN
|
|
529
|
+
INSERT INTO tasks_fts(rowid, task_id, title, description, tags)
|
|
530
|
+
VALUES (new.rowid, new.id, new.title, COALESCE(new.description, ''), '');
|
|
531
|
+
END;
|
|
532
|
+
|
|
533
|
+
CREATE TRIGGER IF NOT EXISTS tasks_fts_ad AFTER DELETE ON tasks BEGIN
|
|
534
|
+
DELETE FROM tasks_fts WHERE rowid = old.rowid;
|
|
535
|
+
END;
|
|
536
|
+
|
|
537
|
+
CREATE TRIGGER IF NOT EXISTS tasks_fts_au AFTER UPDATE OF title, description ON tasks BEGIN
|
|
538
|
+
DELETE FROM tasks_fts WHERE rowid = old.rowid;
|
|
539
|
+
INSERT INTO tasks_fts(rowid, task_id, title, description, tags)
|
|
540
|
+
SELECT new.rowid, new.id, new.title, COALESCE(new.description, ''),
|
|
541
|
+
COALESCE((SELECT GROUP_CONCAT(tag, ' ') FROM task_tags WHERE task_id = new.id), '');
|
|
542
|
+
END;
|
|
543
|
+
|
|
544
|
+
CREATE TRIGGER IF NOT EXISTS task_tags_fts_ai AFTER INSERT ON task_tags BEGIN
|
|
545
|
+
DELETE FROM tasks_fts WHERE rowid = (SELECT rowid FROM tasks WHERE id = new.task_id);
|
|
546
|
+
INSERT INTO tasks_fts(rowid, task_id, title, description, tags)
|
|
547
|
+
SELECT t.rowid, t.id, t.title, COALESCE(t.description, ''),
|
|
548
|
+
COALESCE((SELECT GROUP_CONCAT(tag, ' ') FROM task_tags WHERE task_id = t.id), '')
|
|
549
|
+
FROM tasks t WHERE t.id = new.task_id;
|
|
550
|
+
END;
|
|
551
|
+
|
|
552
|
+
CREATE TRIGGER IF NOT EXISTS task_tags_fts_ad AFTER DELETE ON task_tags BEGIN
|
|
553
|
+
DELETE FROM tasks_fts WHERE rowid = (SELECT rowid FROM tasks WHERE id = old.task_id);
|
|
554
|
+
INSERT INTO tasks_fts(rowid, task_id, title, description, tags)
|
|
555
|
+
SELECT t.rowid, t.id, t.title, COALESCE(t.description, ''),
|
|
556
|
+
COALESCE((SELECT GROUP_CONCAT(tag, ' ') FROM task_tags WHERE task_id = t.id), '')
|
|
557
|
+
FROM tasks t WHERE t.id = old.task_id;
|
|
558
|
+
END;
|
|
559
|
+
|
|
560
|
+
INSERT OR IGNORE INTO _migrations (id) VALUES (15);
|
|
561
|
+
`,
|
|
562
|
+
`
|
|
563
|
+
ALTER TABLE tasks ADD COLUMN spawns_template_id TEXT REFERENCES task_templates(id) ON DELETE SET NULL;
|
|
564
|
+
INSERT OR IGNORE INTO _migrations (id) VALUES (16);
|
|
565
|
+
`,
|
|
566
|
+
`
|
|
567
|
+
ALTER TABLE agents ADD COLUMN session_id TEXT;
|
|
568
|
+
ALTER TABLE agents ADD COLUMN working_dir TEXT;
|
|
569
|
+
INSERT OR IGNORE INTO _migrations (id) VALUES (17);
|
|
513
570
|
`
|
|
514
571
|
];
|
|
515
572
|
var _db = null;
|
|
@@ -1279,6 +1336,62 @@ async function dispatchWebhook(event, payload, db) {
|
|
|
1279
1336
|
}
|
|
1280
1337
|
}
|
|
1281
1338
|
|
|
1339
|
+
// src/db/templates.ts
|
|
1340
|
+
function rowToTemplate(row) {
|
|
1341
|
+
return {
|
|
1342
|
+
...row,
|
|
1343
|
+
tags: JSON.parse(row.tags || "[]"),
|
|
1344
|
+
metadata: JSON.parse(row.metadata || "{}"),
|
|
1345
|
+
priority: row.priority || "medium"
|
|
1346
|
+
};
|
|
1347
|
+
}
|
|
1348
|
+
function createTemplate(input, db) {
|
|
1349
|
+
const d = db || getDatabase();
|
|
1350
|
+
const id = uuid();
|
|
1351
|
+
d.run(`INSERT INTO task_templates (id, name, title_pattern, description, priority, tags, project_id, plan_id, metadata, created_at)
|
|
1352
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
|
|
1353
|
+
id,
|
|
1354
|
+
input.name,
|
|
1355
|
+
input.title_pattern,
|
|
1356
|
+
input.description || null,
|
|
1357
|
+
input.priority || "medium",
|
|
1358
|
+
JSON.stringify(input.tags || []),
|
|
1359
|
+
input.project_id || null,
|
|
1360
|
+
input.plan_id || null,
|
|
1361
|
+
JSON.stringify(input.metadata || {}),
|
|
1362
|
+
now()
|
|
1363
|
+
]);
|
|
1364
|
+
return getTemplate(id, d);
|
|
1365
|
+
}
|
|
1366
|
+
function getTemplate(id, db) {
|
|
1367
|
+
const d = db || getDatabase();
|
|
1368
|
+
const row = d.query("SELECT * FROM task_templates WHERE id = ?").get(id);
|
|
1369
|
+
return row ? rowToTemplate(row) : null;
|
|
1370
|
+
}
|
|
1371
|
+
function listTemplates(db) {
|
|
1372
|
+
const d = db || getDatabase();
|
|
1373
|
+
return d.query("SELECT * FROM task_templates ORDER BY name").all().map(rowToTemplate);
|
|
1374
|
+
}
|
|
1375
|
+
function deleteTemplate(id, db) {
|
|
1376
|
+
const d = db || getDatabase();
|
|
1377
|
+
return d.run("DELETE FROM task_templates WHERE id = ?", [id]).changes > 0;
|
|
1378
|
+
}
|
|
1379
|
+
function taskFromTemplate(templateId, overrides = {}, db) {
|
|
1380
|
+
const t = getTemplate(templateId, db);
|
|
1381
|
+
if (!t)
|
|
1382
|
+
throw new Error(`Template not found: ${templateId}`);
|
|
1383
|
+
return {
|
|
1384
|
+
title: overrides.title || t.title_pattern,
|
|
1385
|
+
description: overrides.description ?? t.description ?? undefined,
|
|
1386
|
+
priority: overrides.priority ?? t.priority,
|
|
1387
|
+
tags: overrides.tags ?? t.tags,
|
|
1388
|
+
project_id: overrides.project_id ?? t.project_id ?? undefined,
|
|
1389
|
+
plan_id: overrides.plan_id ?? t.plan_id ?? undefined,
|
|
1390
|
+
metadata: overrides.metadata ?? t.metadata,
|
|
1391
|
+
...overrides
|
|
1392
|
+
};
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1282
1395
|
// src/db/tasks.ts
|
|
1283
1396
|
function rowToTask(row) {
|
|
1284
1397
|
return {
|
|
@@ -1310,8 +1423,8 @@ function createTask(input, db) {
|
|
|
1310
1423
|
const tags = input.tags || [];
|
|
1311
1424
|
const shortId = input.project_id ? nextTaskShortId(input.project_id, d) : null;
|
|
1312
1425
|
const title = shortId ? `${shortId}: ${input.title}` : input.title;
|
|
1313
|
-
d.run(`INSERT INTO tasks (id, short_id, project_id, parent_id, plan_id, task_list_id, title, description, status, priority, agent_id, assigned_to, session_id, working_dir, tags, metadata, version, created_at, updated_at, due_at, estimated_minutes, requires_approval, approved_by, approved_at, recurrence_rule, recurrence_parent_id)
|
|
1314
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
|
|
1426
|
+
d.run(`INSERT INTO tasks (id, short_id, project_id, parent_id, plan_id, task_list_id, title, description, status, priority, agent_id, assigned_to, session_id, working_dir, tags, metadata, version, created_at, updated_at, due_at, estimated_minutes, requires_approval, approved_by, approved_at, recurrence_rule, recurrence_parent_id, spawns_template_id)
|
|
1427
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
|
|
1315
1428
|
id,
|
|
1316
1429
|
shortId,
|
|
1317
1430
|
input.project_id || null,
|
|
@@ -1336,7 +1449,8 @@ function createTask(input, db) {
|
|
|
1336
1449
|
null,
|
|
1337
1450
|
null,
|
|
1338
1451
|
input.recurrence_rule || null,
|
|
1339
|
-
input.recurrence_parent_id || null
|
|
1452
|
+
input.recurrence_parent_id || null,
|
|
1453
|
+
input.spawns_template_id || null
|
|
1340
1454
|
]);
|
|
1341
1455
|
if (tags.length > 0) {
|
|
1342
1456
|
insertTaskTags(id, tags, d);
|
|
@@ -1443,19 +1557,25 @@ function listTasks(filter = {}, db) {
|
|
|
1443
1557
|
} else if (filter.has_recurrence === false) {
|
|
1444
1558
|
conditions.push("recurrence_rule IS NULL");
|
|
1445
1559
|
}
|
|
1560
|
+
const PRIORITY_RANK = `CASE priority WHEN 'critical' THEN 0 WHEN 'high' THEN 1 WHEN 'medium' THEN 2 WHEN 'low' THEN 3 END`;
|
|
1561
|
+
if (filter.cursor) {
|
|
1562
|
+
try {
|
|
1563
|
+
const decoded = JSON.parse(Buffer.from(filter.cursor, "base64").toString("utf8"));
|
|
1564
|
+
conditions.push(`(${PRIORITY_RANK} > ? OR (${PRIORITY_RANK} = ? AND created_at < ?) OR (${PRIORITY_RANK} = ? AND created_at = ? AND id > ?))`);
|
|
1565
|
+
params.push(decoded.p, decoded.p, decoded.c, decoded.p, decoded.c, decoded.i);
|
|
1566
|
+
} catch {}
|
|
1567
|
+
}
|
|
1446
1568
|
const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
1447
1569
|
let limitClause = "";
|
|
1448
1570
|
if (filter.limit) {
|
|
1449
1571
|
limitClause = " LIMIT ?";
|
|
1450
1572
|
params.push(filter.limit);
|
|
1451
|
-
if (filter.offset) {
|
|
1573
|
+
if (!filter.cursor && filter.offset) {
|
|
1452
1574
|
limitClause += " OFFSET ?";
|
|
1453
1575
|
params.push(filter.offset);
|
|
1454
1576
|
}
|
|
1455
1577
|
}
|
|
1456
|
-
const rows = d.query(`SELECT * FROM tasks ${where} ORDER BY
|
|
1457
|
-
CASE priority WHEN 'critical' THEN 0 WHEN 'high' THEN 1 WHEN 'medium' THEN 2 WHEN 'low' THEN 3 END,
|
|
1458
|
-
created_at DESC${limitClause}`).all(...params);
|
|
1578
|
+
const rows = d.query(`SELECT * FROM tasks ${where} ORDER BY ${PRIORITY_RANK}, created_at DESC${limitClause}`).all(...params);
|
|
1459
1579
|
return rows.map(rowToTask);
|
|
1460
1580
|
}
|
|
1461
1581
|
function countTasks(filter = {}, db) {
|
|
@@ -1700,10 +1820,25 @@ function completeTask(id, agentId, db, options) {
|
|
|
1700
1820
|
if (task.recurrence_rule && !options?.skip_recurrence) {
|
|
1701
1821
|
spawnedTask = spawnNextRecurrence(task, d);
|
|
1702
1822
|
}
|
|
1823
|
+
let spawnedFromTemplate = null;
|
|
1824
|
+
if (task.spawns_template_id) {
|
|
1825
|
+
try {
|
|
1826
|
+
const input = taskFromTemplate(task.spawns_template_id, {
|
|
1827
|
+
project_id: task.project_id ?? undefined,
|
|
1828
|
+
plan_id: task.plan_id ?? undefined,
|
|
1829
|
+
task_list_id: task.task_list_id ?? undefined,
|
|
1830
|
+
assigned_to: task.assigned_to ?? undefined
|
|
1831
|
+
}, d);
|
|
1832
|
+
spawnedFromTemplate = createTask(input, d);
|
|
1833
|
+
} catch {}
|
|
1834
|
+
}
|
|
1703
1835
|
const meta = hasEvidence ? { ...task.metadata, _evidence: evidence } : task.metadata;
|
|
1704
1836
|
if (spawnedTask) {
|
|
1705
1837
|
meta._next_recurrence = { id: spawnedTask.id, short_id: spawnedTask.short_id, due_at: spawnedTask.due_at };
|
|
1706
1838
|
}
|
|
1839
|
+
if (spawnedFromTemplate) {
|
|
1840
|
+
meta._spawned_task = { id: spawnedFromTemplate.id, short_id: spawnedFromTemplate.short_id, title: spawnedFromTemplate.title };
|
|
1841
|
+
}
|
|
1707
1842
|
return { ...task, status: "completed", locked_by: null, locked_at: null, completed_at: timestamp, version: task.version + 1, updated_at: timestamp, metadata: meta };
|
|
1708
1843
|
}
|
|
1709
1844
|
function lockTask(id, agentId, db) {
|
|
@@ -1915,11 +2050,21 @@ function getNextTask(agentId, filters, db) {
|
|
|
1915
2050
|
}
|
|
1916
2051
|
conditions.push("id NOT IN (SELECT td.task_id FROM task_dependencies td JOIN tasks dep ON dep.id = td.depends_on WHERE dep.status != 'completed')");
|
|
1917
2052
|
const where = conditions.join(" AND ");
|
|
2053
|
+
let recentProjectIds = [];
|
|
2054
|
+
if (agentId) {
|
|
2055
|
+
const recentRows = d.query(`SELECT DISTINCT project_id FROM tasks WHERE assigned_to = ? AND status = 'completed' AND project_id IS NOT NULL ORDER BY completed_at DESC LIMIT 3`).all(agentId);
|
|
2056
|
+
recentProjectIds = recentRows.map((r) => r.project_id);
|
|
2057
|
+
}
|
|
1918
2058
|
let sql = `SELECT * FROM tasks WHERE ${where} ORDER BY `;
|
|
1919
2059
|
if (agentId) {
|
|
1920
2060
|
sql += `CASE WHEN assigned_to = ? THEN 0 WHEN assigned_to IS NULL THEN 1 ELSE 2 END, `;
|
|
1921
2061
|
params.push(agentId);
|
|
1922
2062
|
}
|
|
2063
|
+
if (recentProjectIds.length > 0) {
|
|
2064
|
+
const placeholders = recentProjectIds.map(() => "?").join(",");
|
|
2065
|
+
sql += `CASE WHEN project_id IN (${placeholders}) THEN 0 ELSE 1 END, `;
|
|
2066
|
+
params.push(...recentProjectIds);
|
|
2067
|
+
}
|
|
1923
2068
|
sql += `CASE priority WHEN 'critical' THEN 0 WHEN 'high' THEN 1 WHEN 'medium' THEN 2 WHEN 'low' THEN 3 END, created_at ASC LIMIT 1`;
|
|
1924
2069
|
const row = d.query(sql).get(...params);
|
|
1925
2070
|
return row ? rowToTask(row) : null;
|
|
@@ -2352,6 +2497,7 @@ function deleteComment(id, db) {
|
|
|
2352
2497
|
return result.changes > 0;
|
|
2353
2498
|
}
|
|
2354
2499
|
// src/db/agents.ts
|
|
2500
|
+
var AGENT_ACTIVE_WINDOW_MS = 30 * 60 * 1000;
|
|
2355
2501
|
function shortUuid() {
|
|
2356
2502
|
return crypto.randomUUID().slice(0, 8);
|
|
2357
2503
|
}
|
|
@@ -2367,13 +2513,44 @@ function registerAgent(input, db) {
|
|
|
2367
2513
|
const normalizedName = input.name.trim().toLowerCase();
|
|
2368
2514
|
const existing = getAgentByName(normalizedName, d);
|
|
2369
2515
|
if (existing) {
|
|
2370
|
-
|
|
2516
|
+
const lastSeenMs = new Date(existing.last_seen_at).getTime();
|
|
2517
|
+
const isActive = Date.now() - lastSeenMs < AGENT_ACTIVE_WINDOW_MS;
|
|
2518
|
+
const sameSession = input.session_id && existing.session_id && input.session_id === existing.session_id;
|
|
2519
|
+
const differentSession = input.session_id && existing.session_id && input.session_id !== existing.session_id;
|
|
2520
|
+
if (isActive && differentSession) {
|
|
2521
|
+
const minutesAgo = Math.round((Date.now() - lastSeenMs) / 60000);
|
|
2522
|
+
return {
|
|
2523
|
+
conflict: true,
|
|
2524
|
+
existing_id: existing.id,
|
|
2525
|
+
existing_name: existing.name,
|
|
2526
|
+
last_seen_at: existing.last_seen_at,
|
|
2527
|
+
session_hint: existing.session_id ? existing.session_id.slice(0, 8) : null,
|
|
2528
|
+
working_dir: existing.working_dir,
|
|
2529
|
+
message: `Agent "${normalizedName}" is already active (last seen ${minutesAgo}m ago, session ${existing.session_id?.slice(0, 8)}\u2026, dir: ${existing.working_dir ?? "unknown"}). Are you that agent? If so, pass session_id="${existing.session_id}" to reclaim it. Otherwise choose a different name.`
|
|
2530
|
+
};
|
|
2531
|
+
}
|
|
2532
|
+
const updates = ["last_seen_at = ?"];
|
|
2533
|
+
const params = [now()];
|
|
2534
|
+
if (input.session_id && !sameSession) {
|
|
2535
|
+
updates.push("session_id = ?");
|
|
2536
|
+
params.push(input.session_id);
|
|
2537
|
+
}
|
|
2538
|
+
if (input.working_dir) {
|
|
2539
|
+
updates.push("working_dir = ?");
|
|
2540
|
+
params.push(input.working_dir);
|
|
2541
|
+
}
|
|
2542
|
+
if (input.description) {
|
|
2543
|
+
updates.push("description = ?");
|
|
2544
|
+
params.push(input.description);
|
|
2545
|
+
}
|
|
2546
|
+
params.push(existing.id);
|
|
2547
|
+
d.run(`UPDATE agents SET ${updates.join(", ")} WHERE id = ?`, params);
|
|
2371
2548
|
return getAgent(existing.id, d);
|
|
2372
2549
|
}
|
|
2373
2550
|
const id = shortUuid();
|
|
2374
2551
|
const timestamp = now();
|
|
2375
|
-
d.run(`INSERT INTO agents (id, name, description, role, title, level, permissions, reports_to, org_id, metadata, created_at, last_seen_at)
|
|
2376
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
|
|
2552
|
+
d.run(`INSERT INTO agents (id, name, description, role, title, level, permissions, reports_to, org_id, metadata, created_at, last_seen_at, session_id, working_dir)
|
|
2553
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
|
|
2377
2554
|
id,
|
|
2378
2555
|
normalizedName,
|
|
2379
2556
|
input.description || null,
|
|
@@ -2385,10 +2562,15 @@ function registerAgent(input, db) {
|
|
|
2385
2562
|
input.org_id || null,
|
|
2386
2563
|
JSON.stringify(input.metadata || {}),
|
|
2387
2564
|
timestamp,
|
|
2388
|
-
timestamp
|
|
2565
|
+
timestamp,
|
|
2566
|
+
input.session_id || null,
|
|
2567
|
+
input.working_dir || null
|
|
2389
2568
|
]);
|
|
2390
2569
|
return getAgent(id, d);
|
|
2391
2570
|
}
|
|
2571
|
+
function isAgentConflict(result) {
|
|
2572
|
+
return result.conflict === true;
|
|
2573
|
+
}
|
|
2392
2574
|
function getAgent(id, db) {
|
|
2393
2575
|
const d = db || getDatabase();
|
|
2394
2576
|
const row = d.query("SELECT * FROM agents WHERE id = ?").get(id);
|
|
@@ -2600,61 +2782,6 @@ function deleteSession(id, db) {
|
|
|
2600
2782
|
const result = d.run("DELETE FROM sessions WHERE id = ?", [id]);
|
|
2601
2783
|
return result.changes > 0;
|
|
2602
2784
|
}
|
|
2603
|
-
// src/db/templates.ts
|
|
2604
|
-
function rowToTemplate(row) {
|
|
2605
|
-
return {
|
|
2606
|
-
...row,
|
|
2607
|
-
tags: JSON.parse(row.tags || "[]"),
|
|
2608
|
-
metadata: JSON.parse(row.metadata || "{}"),
|
|
2609
|
-
priority: row.priority || "medium"
|
|
2610
|
-
};
|
|
2611
|
-
}
|
|
2612
|
-
function createTemplate(input, db) {
|
|
2613
|
-
const d = db || getDatabase();
|
|
2614
|
-
const id = uuid();
|
|
2615
|
-
d.run(`INSERT INTO task_templates (id, name, title_pattern, description, priority, tags, project_id, plan_id, metadata, created_at)
|
|
2616
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
|
|
2617
|
-
id,
|
|
2618
|
-
input.name,
|
|
2619
|
-
input.title_pattern,
|
|
2620
|
-
input.description || null,
|
|
2621
|
-
input.priority || "medium",
|
|
2622
|
-
JSON.stringify(input.tags || []),
|
|
2623
|
-
input.project_id || null,
|
|
2624
|
-
input.plan_id || null,
|
|
2625
|
-
JSON.stringify(input.metadata || {}),
|
|
2626
|
-
now()
|
|
2627
|
-
]);
|
|
2628
|
-
return getTemplate(id, d);
|
|
2629
|
-
}
|
|
2630
|
-
function getTemplate(id, db) {
|
|
2631
|
-
const d = db || getDatabase();
|
|
2632
|
-
const row = d.query("SELECT * FROM task_templates WHERE id = ?").get(id);
|
|
2633
|
-
return row ? rowToTemplate(row) : null;
|
|
2634
|
-
}
|
|
2635
|
-
function listTemplates(db) {
|
|
2636
|
-
const d = db || getDatabase();
|
|
2637
|
-
return d.query("SELECT * FROM task_templates ORDER BY name").all().map(rowToTemplate);
|
|
2638
|
-
}
|
|
2639
|
-
function deleteTemplate(id, db) {
|
|
2640
|
-
const d = db || getDatabase();
|
|
2641
|
-
return d.run("DELETE FROM task_templates WHERE id = ?", [id]).changes > 0;
|
|
2642
|
-
}
|
|
2643
|
-
function taskFromTemplate(templateId, overrides = {}, db) {
|
|
2644
|
-
const t = getTemplate(templateId, db);
|
|
2645
|
-
if (!t)
|
|
2646
|
-
throw new Error(`Template not found: ${templateId}`);
|
|
2647
|
-
return {
|
|
2648
|
-
title: overrides.title || t.title_pattern,
|
|
2649
|
-
description: overrides.description ?? t.description ?? undefined,
|
|
2650
|
-
priority: overrides.priority ?? t.priority,
|
|
2651
|
-
tags: overrides.tags ?? t.tags,
|
|
2652
|
-
project_id: overrides.project_id ?? t.project_id ?? undefined,
|
|
2653
|
-
plan_id: overrides.plan_id ?? t.plan_id ?? undefined,
|
|
2654
|
-
metadata: overrides.metadata ?? t.metadata,
|
|
2655
|
-
...overrides
|
|
2656
|
-
};
|
|
2657
|
-
}
|
|
2658
2785
|
// src/db/orgs.ts
|
|
2659
2786
|
function rowToOrg(row) {
|
|
2660
2787
|
return { ...row, metadata: JSON.parse(row.metadata || "{}") };
|
|
@@ -2718,68 +2845,95 @@ function rowToTask2(row) {
|
|
|
2718
2845
|
requires_approval: Boolean(row.requires_approval)
|
|
2719
2846
|
};
|
|
2720
2847
|
}
|
|
2848
|
+
function hasFts(db) {
|
|
2849
|
+
try {
|
|
2850
|
+
const result = db.query("SELECT 1 FROM sqlite_master WHERE type='table' AND name='tasks_fts'").get();
|
|
2851
|
+
return result !== null;
|
|
2852
|
+
} catch {
|
|
2853
|
+
return false;
|
|
2854
|
+
}
|
|
2855
|
+
}
|
|
2856
|
+
function escapeFtsQuery(q) {
|
|
2857
|
+
return q.replace(/["*^()]/g, " ").trim().split(/\s+/).filter(Boolean).map((token) => `"${token}"*`).join(" ");
|
|
2858
|
+
}
|
|
2721
2859
|
function searchTasks(options, projectId, taskListId, db) {
|
|
2722
2860
|
const opts = typeof options === "string" ? { query: options, project_id: projectId, task_list_id: taskListId } : options;
|
|
2723
2861
|
const d = db || getDatabase();
|
|
2724
2862
|
clearExpiredLocks(d);
|
|
2725
|
-
const
|
|
2726
|
-
let sql
|
|
2727
|
-
|
|
2863
|
+
const params = [];
|
|
2864
|
+
let sql;
|
|
2865
|
+
if (hasFts(d) && opts.query.trim()) {
|
|
2866
|
+
const ftsQuery = escapeFtsQuery(opts.query);
|
|
2867
|
+
sql = `SELECT t.* FROM tasks t
|
|
2868
|
+
INNER JOIN tasks_fts fts ON fts.rowid = t.rowid
|
|
2869
|
+
WHERE tasks_fts MATCH ?`;
|
|
2870
|
+
params.push(ftsQuery);
|
|
2871
|
+
} else {
|
|
2872
|
+
const pattern = `%${opts.query}%`;
|
|
2873
|
+
sql = `SELECT * FROM tasks t WHERE (t.title LIKE ? OR t.description LIKE ? OR EXISTS (SELECT 1 FROM task_tags WHERE task_tags.task_id = t.id AND tag LIKE ?))`;
|
|
2874
|
+
params.push(pattern, pattern, pattern);
|
|
2875
|
+
}
|
|
2728
2876
|
if (opts.project_id) {
|
|
2729
|
-
sql += " AND project_id = ?";
|
|
2877
|
+
sql += " AND t.project_id = ?";
|
|
2730
2878
|
params.push(opts.project_id);
|
|
2731
2879
|
}
|
|
2732
2880
|
if (opts.task_list_id) {
|
|
2733
|
-
sql += " AND task_list_id = ?";
|
|
2881
|
+
sql += " AND t.task_list_id = ?";
|
|
2734
2882
|
params.push(opts.task_list_id);
|
|
2735
2883
|
}
|
|
2736
2884
|
if (opts.status) {
|
|
2737
2885
|
if (Array.isArray(opts.status)) {
|
|
2738
|
-
sql += ` AND status IN (${opts.status.map(() => "?").join(",")})`;
|
|
2886
|
+
sql += ` AND t.status IN (${opts.status.map(() => "?").join(",")})`;
|
|
2739
2887
|
params.push(...opts.status);
|
|
2740
2888
|
} else {
|
|
2741
|
-
sql += " AND status = ?";
|
|
2889
|
+
sql += " AND t.status = ?";
|
|
2742
2890
|
params.push(opts.status);
|
|
2743
2891
|
}
|
|
2744
2892
|
}
|
|
2745
2893
|
if (opts.priority) {
|
|
2746
2894
|
if (Array.isArray(opts.priority)) {
|
|
2747
|
-
sql += ` AND priority IN (${opts.priority.map(() => "?").join(",")})`;
|
|
2895
|
+
sql += ` AND t.priority IN (${opts.priority.map(() => "?").join(",")})`;
|
|
2748
2896
|
params.push(...opts.priority);
|
|
2749
2897
|
} else {
|
|
2750
|
-
sql += " AND priority = ?";
|
|
2898
|
+
sql += " AND t.priority = ?";
|
|
2751
2899
|
params.push(opts.priority);
|
|
2752
2900
|
}
|
|
2753
2901
|
}
|
|
2754
2902
|
if (opts.assigned_to) {
|
|
2755
|
-
sql += " AND assigned_to = ?";
|
|
2903
|
+
sql += " AND t.assigned_to = ?";
|
|
2756
2904
|
params.push(opts.assigned_to);
|
|
2757
2905
|
}
|
|
2758
2906
|
if (opts.agent_id) {
|
|
2759
|
-
sql += " AND agent_id = ?";
|
|
2907
|
+
sql += " AND t.agent_id = ?";
|
|
2760
2908
|
params.push(opts.agent_id);
|
|
2761
2909
|
}
|
|
2762
2910
|
if (opts.created_after) {
|
|
2763
|
-
sql += " AND created_at > ?";
|
|
2911
|
+
sql += " AND t.created_at > ?";
|
|
2764
2912
|
params.push(opts.created_after);
|
|
2765
2913
|
}
|
|
2766
2914
|
if (opts.updated_after) {
|
|
2767
|
-
sql += " AND updated_at > ?";
|
|
2915
|
+
sql += " AND t.updated_at > ?";
|
|
2768
2916
|
params.push(opts.updated_after);
|
|
2769
2917
|
}
|
|
2770
2918
|
if (opts.has_dependencies === true) {
|
|
2771
|
-
sql += " AND id IN (SELECT task_id FROM task_dependencies)";
|
|
2919
|
+
sql += " AND t.id IN (SELECT task_id FROM task_dependencies)";
|
|
2772
2920
|
} else if (opts.has_dependencies === false) {
|
|
2773
|
-
sql += " AND id NOT IN (SELECT task_id FROM task_dependencies)";
|
|
2921
|
+
sql += " AND t.id NOT IN (SELECT task_id FROM task_dependencies)";
|
|
2774
2922
|
}
|
|
2775
2923
|
if (opts.is_blocked === true) {
|
|
2776
|
-
sql += " AND id IN (SELECT td.task_id FROM task_dependencies td JOIN tasks dep ON dep.id = td.depends_on WHERE dep.status != 'completed')";
|
|
2924
|
+
sql += " AND t.id IN (SELECT td.task_id FROM task_dependencies td JOIN tasks dep ON dep.id = td.depends_on WHERE dep.status != 'completed')";
|
|
2777
2925
|
} else if (opts.is_blocked === false) {
|
|
2778
|
-
sql += " AND id NOT IN (SELECT td.task_id FROM task_dependencies td JOIN tasks dep ON dep.id = td.depends_on WHERE dep.status != 'completed')";
|
|
2926
|
+
sql += " AND t.id NOT IN (SELECT td.task_id FROM task_dependencies td JOIN tasks dep ON dep.id = td.depends_on WHERE dep.status != 'completed')";
|
|
2927
|
+
}
|
|
2928
|
+
if (hasFts(d) && opts.query.trim()) {
|
|
2929
|
+
sql += ` ORDER BY bm25(tasks_fts),
|
|
2930
|
+
CASE t.priority WHEN 'critical' THEN 0 WHEN 'high' THEN 1 WHEN 'medium' THEN 2 WHEN 'low' THEN 3 END,
|
|
2931
|
+
t.created_at DESC`;
|
|
2932
|
+
} else {
|
|
2933
|
+
sql += ` ORDER BY
|
|
2934
|
+
CASE t.priority WHEN 'critical' THEN 0 WHEN 'high' THEN 1 WHEN 'medium' THEN 2 WHEN 'low' THEN 3 END,
|
|
2935
|
+
t.created_at DESC`;
|
|
2779
2936
|
}
|
|
2780
|
-
sql += ` ORDER BY
|
|
2781
|
-
CASE priority WHEN 'critical' THEN 0 WHEN 'high' THEN 1 WHEN 'medium' THEN 2 WHEN 'low' THEN 3 END,
|
|
2782
|
-
created_at DESC`;
|
|
2783
2937
|
const rows = d.query(sql).all(...params);
|
|
2784
2938
|
return rows.map(rowToTask2);
|
|
2785
2939
|
}
|
|
@@ -3342,6 +3496,7 @@ export {
|
|
|
3342
3496
|
listComments,
|
|
3343
3497
|
listAgents,
|
|
3344
3498
|
isValidRecurrenceRule,
|
|
3499
|
+
isAgentConflict,
|
|
3345
3500
|
getWebhook,
|
|
3346
3501
|
getTemplate,
|
|
3347
3502
|
getTasksChangedSince,
|
package/dist/lib/search.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/lib/search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAoB,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,EAAE,IAAI,EAAW,MAAM,mBAAmB,CAAC;AAcvD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAA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