@hasna/todos 0.11.34 → 0.11.36
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/README.md +12 -0
- package/dist/cli/commands/agent-commands.d.ts.map +1 -1
- package/dist/cli/commands/api-key-commands.d.ts +3 -0
- package/dist/cli/commands/api-key-commands.d.ts.map +1 -0
- package/dist/cli/commands/config-serve-commands.d.ts.map +1 -1
- package/dist/cli/index.js +543 -41
- package/dist/db/agent-names.d.ts +23 -0
- package/dist/db/agent-names.d.ts.map +1 -0
- package/dist/db/agents.d.ts +2 -0
- package/dist/db/agents.d.ts.map +1 -1
- package/dist/db/api-keys.d.ts +28 -0
- package/dist/db/api-keys.d.ts.map +1 -0
- package/dist/db/migrations.d.ts.map +1 -1
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +355 -5
- package/dist/mcp/index.js +296 -8
- package/dist/mcp/tools/agents.d.ts.map +1 -1
- package/dist/server/index.js +306 -33
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/serve.d.ts.map +1 -1
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Database } from "bun:sqlite";
|
|
2
|
+
export declare class InvalidAgentNameError extends Error {
|
|
3
|
+
readonly suggestions: string[];
|
|
4
|
+
constructor(name: string, reason: string, suggestions?: string[]);
|
|
5
|
+
}
|
|
6
|
+
export declare const ROMAN_AGENT_NAMES: readonly ["caesar", "augustus", "marcus", "brutus", "cicero", "cato", "nero", "claudius", "tiberius", "hadrian", "trajan", "vespasian", "domitian", "caligula", "commodus", "livia", "julia", "octavia", "claudia", "agrippina", "cornelia", "valeria", "fulvia", "hortensia", "fabia"];
|
|
7
|
+
export declare const GREEK_AGENT_NAMES: readonly ["athena", "apollo", "artemis", "hera", "iris", "hector", "achilles", "odysseus", "theseus", "pericles", "solon", "sophia", "thalia", "calliope", "clio", "phoebe", "daphne", "leonidas", "andromeda", "cassander"];
|
|
8
|
+
export declare const NICE_AGENT_NAMES: readonly ["atlas", "aurora", "ember", "nova", "orion", "rhea", "selene", "sirius", "vesper", "zephyr"];
|
|
9
|
+
export declare const PREFERRED_AGENT_NAMES: readonly ["caesar", "augustus", "marcus", "brutus", "cicero", "cato", "nero", "claudius", "tiberius", "hadrian", "trajan", "vespasian", "domitian", "caligula", "commodus", "livia", "julia", "octavia", "claudia", "agrippina", "cornelia", "valeria", "fulvia", "hortensia", "fabia", "athena", "apollo", "artemis", "hera", "iris", "hector", "achilles", "odysseus", "theseus", "pericles", "solon", "sophia", "thalia", "calliope", "clio", "phoebe", "daphne", "leonidas", "andromeda", "cassander", "atlas", "aurora", "ember", "nova", "orion", "rhea", "selene", "sirius", "vesper", "zephyr"];
|
|
10
|
+
export declare function normalizeAgentNameInput(name: string): string;
|
|
11
|
+
export declare function hasGeneratedNumericSuffix(name: string): boolean;
|
|
12
|
+
export declare function isGenericAgentName(name: string): boolean;
|
|
13
|
+
export declare function isBlockedAgentName(name: string): boolean;
|
|
14
|
+
export declare function suggestAgentNames(existingNames?: Iterable<string>): string[];
|
|
15
|
+
export declare function validateAgentName(name: string, existingNames?: Iterable<string>): string;
|
|
16
|
+
export interface AgentNameNormalization {
|
|
17
|
+
id: string;
|
|
18
|
+
old_name: string;
|
|
19
|
+
new_name: string;
|
|
20
|
+
reference_updates: number;
|
|
21
|
+
}
|
|
22
|
+
export declare function normalizeGeneratedAgentNames(db: Database): AgentNameNormalization[];
|
|
23
|
+
//# sourceMappingURL=agent-names.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-names.d.ts","sourceRoot":"","sources":["../../src/db/agent-names.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAI3C,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC;gBAEnB,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAE,MAAM,EAAO;CAKrE;AAED,eAAO,MAAM,iBAAiB,yRA0BpB,CAAC;AAEX,eAAO,MAAM,iBAAiB,8NAqBpB,CAAC;AAEX,eAAO,MAAM,gBAAgB,wGAWnB,CAAC;AAEX,eAAO,MAAM,qBAAqB,ykBAIxB,CAAC;AAoBX,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE/D;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CASxD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGxD;AAaD,wBAAgB,iBAAiB,CAAC,aAAa,GAAE,QAAQ,CAAC,MAAM,CAAM,GAAG,MAAM,EAAE,CAahF;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,GAAE,QAAQ,CAAC,MAAM,CAAM,GAAG,MAAM,CAwB5F;AAyCD,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,QAAQ,GAAG,sBAAsB,EAAE,CA6BnF"}
|
package/dist/db/agents.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Database } from "bun:sqlite";
|
|
2
2
|
import type { Agent, AgentConflictError, RegisterAgentInput } from "../types/index.js";
|
|
3
|
+
import { InvalidAgentNameError, normalizeGeneratedAgentNames, suggestAgentNames } from "./agent-names.js";
|
|
4
|
+
export { InvalidAgentNameError, normalizeGeneratedAgentNames, suggestAgentNames };
|
|
3
5
|
/**
|
|
4
6
|
* Auto-release stale agents: clears session_id for agents whose last_seen_at
|
|
5
7
|
* is beyond the active window. Enabled via TODOS_AGENT_AUTO_RELEASE=true.
|
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,EAAE,kBAAkB,EAAyB,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,EAAyB,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE9G,OAAO,EACL,qBAAqB,EAErB,4BAA4B,EAC5B,iBAAiB,EAElB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,qBAAqB,EAAE,4BAA4B,EAAE,iBAAiB,EAAE,CAAC;AAalF;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,CAAC,EAAE,QAAQ,GAAG,MAAM,CAS5D;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,QAAQ,GAAG,MAAM,EAAE,CAUhF;AAgBD;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,kBAAkB,CA6ElG;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,KAAK,GAAG,kBAAkB,GAAG,MAAM,IAAI,kBAAkB,CAEhG;AA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,QAAQ,GAAG,OAAO,CAG9D;AAED,sCAAsC;AACtC,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,IAAI,CAIpE;AAED,iCAAiC;AACjC,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,IAAI,CAItE;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;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,iBAAiB,EAAE,MAAM,EAAE,EAAE,oBAAoB,EAAE,MAAM,EAAE,GAAG,MAAM,CAUrG;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,MAAM,EAAE,EACtB,IAAI,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EAC7C,EAAE,CAAC,EAAE,QAAQ,GACZ;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,CAanC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Database } from "bun:sqlite";
|
|
2
|
+
export interface ApiKeyRecord {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
prefix: string;
|
|
6
|
+
permissions: string[];
|
|
7
|
+
created_at: string;
|
|
8
|
+
last_used_at: string | null;
|
|
9
|
+
expires_at: string | null;
|
|
10
|
+
revoked_at: string | null;
|
|
11
|
+
}
|
|
12
|
+
export interface CreateApiKeyInput {
|
|
13
|
+
name: string;
|
|
14
|
+
permissions?: string[];
|
|
15
|
+
expires_at?: string | null;
|
|
16
|
+
}
|
|
17
|
+
export interface CreatedApiKey {
|
|
18
|
+
key: string;
|
|
19
|
+
record: ApiKeyRecord;
|
|
20
|
+
}
|
|
21
|
+
export declare function createApiKey(input: CreateApiKeyInput, db?: Database): CreatedApiKey;
|
|
22
|
+
export declare function listApiKeys(opts?: {
|
|
23
|
+
include_revoked?: boolean;
|
|
24
|
+
}, db?: Database): ApiKeyRecord[];
|
|
25
|
+
export declare function hasActiveApiKeys(db?: Database): boolean;
|
|
26
|
+
export declare function verifyApiKey(key: string, db?: Database): ApiKeyRecord | null;
|
|
27
|
+
export declare function revokeApiKey(idOrPrefix: string, db?: Database): ApiKeyRecord | null;
|
|
28
|
+
//# sourceMappingURL=api-keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-keys.d.ts","sourceRoot":"","sources":["../../src/db/api-keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAI3C,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAcD,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,YAAY,CAAC;CACtB;AA4BD,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,aAAa,CAwBnF;AAED,wBAAgB,WAAW,CAAC,IAAI,CAAC,EAAE;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,YAAY,EAAE,CAO/F;AAED,wBAAgB,gBAAgB,CAAC,EAAE,CAAC,EAAE,QAAQ,GAAG,OAAO,CAMvD;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,YAAY,GAAG,IAAI,CAY5E;AAED,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,YAAY,GAAG,IAAI,CAUnF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../src/db/migrations.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../src/db/migrations.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,UAy1BtB,CAAC"}
|
package/dist/db/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/db/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,wBAAgB,aAAa,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CA8BhD;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/db/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,wBAAgB,aAAa,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CA8BhD;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAkc/C;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CA4BnD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,8 +9,10 @@ export { createProject, getProject, getProjectByPath, getProjectWithSources, lis
|
|
|
9
9
|
export type { ProjectMachinePath } from "./db/projects.js";
|
|
10
10
|
export { createPlan, getPlan, listPlans, updatePlan, deletePlan, } from "./db/plans.js";
|
|
11
11
|
export { addComment, getComment, listComments, deleteComment, logProgress, } from "./db/comments.js";
|
|
12
|
-
export { registerAgent, isAgentConflict, releaseAgent, autoReleaseStaleAgents, getAgent, getAgentByName, listAgents, updateAgent, updateAgentActivity, deleteAgent, archiveAgent, unarchiveAgent, getDirectReports, getOrgChart, matchCapabilities, getCapableAgents, } from "./db/agents.js";
|
|
12
|
+
export { registerAgent, isAgentConflict, releaseAgent, autoReleaseStaleAgents, getAgent, getAgentByName, listAgents, updateAgent, updateAgentActivity, deleteAgent, archiveAgent, unarchiveAgent, getDirectReports, getOrgChart, matchCapabilities, getCapableAgents, normalizeGeneratedAgentNames, suggestAgentNames, } from "./db/agents.js";
|
|
13
13
|
export type { OrgNode } from "./db/agents.js";
|
|
14
|
+
export { createApiKey, listApiKeys, hasActiveApiKeys, verifyApiKey, revokeApiKey, } from "./db/api-keys.js";
|
|
15
|
+
export type { ApiKeyRecord, CreateApiKeyInput, CreatedApiKey } from "./db/api-keys.js";
|
|
14
16
|
export { createTaskList, getTaskList, getTaskListBySlug, listTaskLists, updateTaskList, deleteTaskList, ensureTaskList, } from "./db/task-lists.js";
|
|
15
17
|
export { createSession, getSession, listSessions, updateSessionActivity, deleteSession, } from "./db/sessions.js";
|
|
16
18
|
export { logTaskChange, getTaskHistory, getRecentActivity, getRecap } from "./db/audit.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,SAAS,EACT,YAAY,EACZ,OAAO,EACP,aAAa,EACb,QAAQ,EACR,oBAAoB,EACpB,aAAa,EACb,SAAS,EACT,cAAc,EACd,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,eAAe,EACf,YAAY,EACZ,aAAa,GACd,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,mBAAmB,EAAE,cAAc,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAGzI,OAAO,EACL,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,WAAW,EACX,cAAc,EACd,eAAe,EACf,YAAY,EACZ,aAAa,EACb,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGnH,OAAO,EACL,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACZ,aAAa,EACb,aAAa,EACb,aAAa,EACb,eAAe,EACf,OAAO,EACP,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAG3D,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,YAAY,EACZ,sBAAsB,EACtB,QAAQ,EACR,cAAc,EACd,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,gBAAgB,
|
|
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,EAC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,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,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,GAAG,EACH,cAAc,GACf,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,aAAa,EACb,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,SAAS,EACT,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EACV,QAAQ,EACR,cAAc,EACd,WAAW,EACX,UAAU,EACV,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,cAAc,EACd,WAAW,EACX,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAG1F,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACtF,YAAY,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAG9D,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,UAAU,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -828,6 +828,22 @@ var init_migrations = __esm(() => {
|
|
|
828
828
|
ALTER TABLE tasks ADD COLUMN cycle_id TEXT REFERENCES cycles(id) ON DELETE SET NULL;
|
|
829
829
|
CREATE INDEX IF NOT EXISTS idx_tasks_cycle ON tasks(cycle_id) WHERE cycle_id IS NOT NULL;
|
|
830
830
|
INSERT OR IGNORE INTO _migrations (id) VALUES (49);
|
|
831
|
+
`,
|
|
832
|
+
`
|
|
833
|
+
CREATE TABLE IF NOT EXISTS api_keys (
|
|
834
|
+
id TEXT PRIMARY KEY,
|
|
835
|
+
name TEXT NOT NULL,
|
|
836
|
+
key_hash TEXT NOT NULL UNIQUE,
|
|
837
|
+
prefix TEXT NOT NULL UNIQUE,
|
|
838
|
+
permissions TEXT NOT NULL DEFAULT '["*"]',
|
|
839
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
840
|
+
last_used_at TEXT,
|
|
841
|
+
expires_at TEXT,
|
|
842
|
+
revoked_at TEXT
|
|
843
|
+
);
|
|
844
|
+
CREATE INDEX IF NOT EXISTS idx_api_keys_prefix ON api_keys(prefix);
|
|
845
|
+
CREATE INDEX IF NOT EXISTS idx_api_keys_active ON api_keys(revoked_at, expires_at);
|
|
846
|
+
INSERT OR IGNORE INTO _migrations (id) VALUES (50);
|
|
831
847
|
`
|
|
832
848
|
];
|
|
833
849
|
});
|
|
@@ -1226,6 +1242,20 @@ function ensureSchema(db) {
|
|
|
1226
1242
|
ensureIndex("CREATE INDEX IF NOT EXISTS idx_cycles_dates ON cycles(start_date, end_date)");
|
|
1227
1243
|
ensureColumn("tasks", "cycle_id", "TEXT REFERENCES cycles(id) ON DELETE SET NULL");
|
|
1228
1244
|
ensureIndex("CREATE INDEX IF NOT EXISTS idx_tasks_cycle ON tasks(cycle_id) WHERE cycle_id IS NOT NULL");
|
|
1245
|
+
ensureTable("api_keys", `
|
|
1246
|
+
CREATE TABLE api_keys (
|
|
1247
|
+
id TEXT PRIMARY KEY,
|
|
1248
|
+
name TEXT NOT NULL,
|
|
1249
|
+
key_hash TEXT NOT NULL UNIQUE,
|
|
1250
|
+
prefix TEXT NOT NULL UNIQUE,
|
|
1251
|
+
permissions TEXT NOT NULL DEFAULT '["*"]',
|
|
1252
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
1253
|
+
last_used_at TEXT,
|
|
1254
|
+
expires_at TEXT,
|
|
1255
|
+
revoked_at TEXT
|
|
1256
|
+
)`);
|
|
1257
|
+
ensureIndex("CREATE INDEX IF NOT EXISTS idx_api_keys_prefix ON api_keys(prefix)");
|
|
1258
|
+
ensureIndex("CREATE INDEX IF NOT EXISTS idx_api_keys_active ON api_keys(revoked_at, expires_at)");
|
|
1229
1259
|
}
|
|
1230
1260
|
function backfillTaskTags(db) {
|
|
1231
1261
|
try {
|
|
@@ -5036,6 +5066,236 @@ function deleteComment(id, db) {
|
|
|
5036
5066
|
}
|
|
5037
5067
|
// src/db/agents.ts
|
|
5038
5068
|
init_database();
|
|
5069
|
+
|
|
5070
|
+
// src/db/agent-names.ts
|
|
5071
|
+
init_database();
|
|
5072
|
+
|
|
5073
|
+
class InvalidAgentNameError extends Error {
|
|
5074
|
+
suggestions;
|
|
5075
|
+
constructor(name, reason, suggestions = []) {
|
|
5076
|
+
super(`Invalid agent name "${name}": ${reason}${suggestions.length > 0 ? `. Try: ${suggestions.join(", ")}` : ""}`);
|
|
5077
|
+
this.name = "InvalidAgentNameError";
|
|
5078
|
+
this.suggestions = suggestions;
|
|
5079
|
+
}
|
|
5080
|
+
}
|
|
5081
|
+
var ROMAN_AGENT_NAMES = [
|
|
5082
|
+
"caesar",
|
|
5083
|
+
"augustus",
|
|
5084
|
+
"marcus",
|
|
5085
|
+
"brutus",
|
|
5086
|
+
"cicero",
|
|
5087
|
+
"cato",
|
|
5088
|
+
"nero",
|
|
5089
|
+
"claudius",
|
|
5090
|
+
"tiberius",
|
|
5091
|
+
"hadrian",
|
|
5092
|
+
"trajan",
|
|
5093
|
+
"vespasian",
|
|
5094
|
+
"domitian",
|
|
5095
|
+
"caligula",
|
|
5096
|
+
"commodus",
|
|
5097
|
+
"livia",
|
|
5098
|
+
"julia",
|
|
5099
|
+
"octavia",
|
|
5100
|
+
"claudia",
|
|
5101
|
+
"agrippina",
|
|
5102
|
+
"cornelia",
|
|
5103
|
+
"valeria",
|
|
5104
|
+
"fulvia",
|
|
5105
|
+
"hortensia",
|
|
5106
|
+
"fabia"
|
|
5107
|
+
];
|
|
5108
|
+
var GREEK_AGENT_NAMES = [
|
|
5109
|
+
"athena",
|
|
5110
|
+
"apollo",
|
|
5111
|
+
"artemis",
|
|
5112
|
+
"hera",
|
|
5113
|
+
"iris",
|
|
5114
|
+
"hector",
|
|
5115
|
+
"achilles",
|
|
5116
|
+
"odysseus",
|
|
5117
|
+
"theseus",
|
|
5118
|
+
"pericles",
|
|
5119
|
+
"solon",
|
|
5120
|
+
"sophia",
|
|
5121
|
+
"thalia",
|
|
5122
|
+
"calliope",
|
|
5123
|
+
"clio",
|
|
5124
|
+
"phoebe",
|
|
5125
|
+
"daphne",
|
|
5126
|
+
"leonidas",
|
|
5127
|
+
"andromeda",
|
|
5128
|
+
"cassander"
|
|
5129
|
+
];
|
|
5130
|
+
var NICE_AGENT_NAMES = [
|
|
5131
|
+
"atlas",
|
|
5132
|
+
"aurora",
|
|
5133
|
+
"ember",
|
|
5134
|
+
"nova",
|
|
5135
|
+
"orion",
|
|
5136
|
+
"rhea",
|
|
5137
|
+
"selene",
|
|
5138
|
+
"sirius",
|
|
5139
|
+
"vesper",
|
|
5140
|
+
"zephyr"
|
|
5141
|
+
];
|
|
5142
|
+
var PREFERRED_AGENT_NAMES = [
|
|
5143
|
+
...ROMAN_AGENT_NAMES,
|
|
5144
|
+
...GREEK_AGENT_NAMES,
|
|
5145
|
+
...NICE_AGENT_NAMES
|
|
5146
|
+
];
|
|
5147
|
+
var RESERVED_GENERIC_NAMES = new Set([
|
|
5148
|
+
"agent",
|
|
5149
|
+
"agents",
|
|
5150
|
+
"ai",
|
|
5151
|
+
"assistant",
|
|
5152
|
+
"bot",
|
|
5153
|
+
"coder",
|
|
5154
|
+
"default",
|
|
5155
|
+
"helper",
|
|
5156
|
+
"model",
|
|
5157
|
+
"system",
|
|
5158
|
+
"user",
|
|
5159
|
+
"worker"
|
|
5160
|
+
]);
|
|
5161
|
+
var NUMERIC_SUFFIX_RE = /[-_]\d+$/;
|
|
5162
|
+
var ONE_WORD_NAME_RE = /^[a-z]+$/;
|
|
5163
|
+
function normalizeAgentNameInput(name) {
|
|
5164
|
+
return name.trim().toLowerCase();
|
|
5165
|
+
}
|
|
5166
|
+
function hasGeneratedNumericSuffix(name) {
|
|
5167
|
+
return NUMERIC_SUFFIX_RE.test(normalizeAgentNameInput(name));
|
|
5168
|
+
}
|
|
5169
|
+
function isGenericAgentName(name) {
|
|
5170
|
+
const normalized = normalizeAgentNameInput(name);
|
|
5171
|
+
if (RESERVED_GENERIC_NAMES.has(normalized))
|
|
5172
|
+
return true;
|
|
5173
|
+
for (const generic of RESERVED_GENERIC_NAMES) {
|
|
5174
|
+
if (normalized === `${generic}s`)
|
|
5175
|
+
return true;
|
|
5176
|
+
if (normalized.match(new RegExp(`^${generic}\\d+$`)))
|
|
5177
|
+
return true;
|
|
5178
|
+
if (normalized.match(new RegExp(`^${generic}[-_]\\d+$`)))
|
|
5179
|
+
return true;
|
|
5180
|
+
}
|
|
5181
|
+
return false;
|
|
5182
|
+
}
|
|
5183
|
+
function isBlockedAgentName(name) {
|
|
5184
|
+
const normalized = normalizeAgentNameInput(name);
|
|
5185
|
+
return isGenericAgentName(normalized) || hasGeneratedNumericSuffix(normalized) || !ONE_WORD_NAME_RE.test(normalized);
|
|
5186
|
+
}
|
|
5187
|
+
function alphabeticSuffix(index) {
|
|
5188
|
+
const letters = "abcdefghijklmnopqrstuvwxyz";
|
|
5189
|
+
let value = index;
|
|
5190
|
+
let suffix = "";
|
|
5191
|
+
do {
|
|
5192
|
+
suffix = letters[value % letters.length] + suffix;
|
|
5193
|
+
value = Math.floor(value / letters.length) - 1;
|
|
5194
|
+
} while (value >= 0);
|
|
5195
|
+
return suffix;
|
|
5196
|
+
}
|
|
5197
|
+
function suggestAgentNames(existingNames = []) {
|
|
5198
|
+
const existing = new Set([...existingNames].map(normalizeAgentNameInput));
|
|
5199
|
+
const suggestions = PREFERRED_AGENT_NAMES.filter((name) => !existing.has(name));
|
|
5200
|
+
for (let suffixIndex = 0;suggestions.length < 20 && suffixIndex < 1000; suffixIndex++) {
|
|
5201
|
+
const suffix = alphabeticSuffix(suffixIndex);
|
|
5202
|
+
for (const base of PREFERRED_AGENT_NAMES) {
|
|
5203
|
+
const candidate = `${base}${suffix}`;
|
|
5204
|
+
if (existing.has(candidate) || suggestions.includes(candidate))
|
|
5205
|
+
continue;
|
|
5206
|
+
suggestions.push(candidate);
|
|
5207
|
+
if (suggestions.length >= 20)
|
|
5208
|
+
break;
|
|
5209
|
+
}
|
|
5210
|
+
}
|
|
5211
|
+
return suggestions;
|
|
5212
|
+
}
|
|
5213
|
+
function validateAgentName(name, existingNames = []) {
|
|
5214
|
+
const normalized = normalizeAgentNameInput(name);
|
|
5215
|
+
const suggestions = suggestAgentNames(existingNames).slice(0, 5);
|
|
5216
|
+
if (!normalized) {
|
|
5217
|
+
throw new InvalidAgentNameError(name, "choose a real one-word name instead of an empty value", suggestions);
|
|
5218
|
+
}
|
|
5219
|
+
if (/\s/.test(normalized)) {
|
|
5220
|
+
throw new InvalidAgentNameError(name, "use a single word, preferably a Roman or Greek name", suggestions);
|
|
5221
|
+
}
|
|
5222
|
+
if (normalized.length < 3) {
|
|
5223
|
+
throw new InvalidAgentNameError(name, "use a more distinctive name with at least three characters", suggestions);
|
|
5224
|
+
}
|
|
5225
|
+
if (isGenericAgentName(normalized)) {
|
|
5226
|
+
throw new InvalidAgentNameError(name, "generic names like agent, agent-1, assistant, or worker-2 are reserved", suggestions);
|
|
5227
|
+
}
|
|
5228
|
+
if (hasGeneratedNumericSuffix(normalized)) {
|
|
5229
|
+
throw new InvalidAgentNameError(name, "numbered suffix names are not allowed; pick a distinct human-readable name", suggestions);
|
|
5230
|
+
}
|
|
5231
|
+
if (!ONE_WORD_NAME_RE.test(normalized)) {
|
|
5232
|
+
throw new InvalidAgentNameError(name, "use one word made of letters only, preferably a Roman or Greek name", suggestions);
|
|
5233
|
+
}
|
|
5234
|
+
return normalized;
|
|
5235
|
+
}
|
|
5236
|
+
function tableHasColumn(db, table, column) {
|
|
5237
|
+
try {
|
|
5238
|
+
return db.query(`PRAGMA table_info(${table})`).all().some((row) => row.name === column);
|
|
5239
|
+
} catch {
|
|
5240
|
+
return false;
|
|
5241
|
+
}
|
|
5242
|
+
}
|
|
5243
|
+
function updateReferences(db, oldName, newName) {
|
|
5244
|
+
const refs = [
|
|
5245
|
+
["tasks", "assigned_to"],
|
|
5246
|
+
["tasks", "agent_id"],
|
|
5247
|
+
["tasks", "locked_by"],
|
|
5248
|
+
["tasks", "assigned_by"],
|
|
5249
|
+
["plans", "agent_id"],
|
|
5250
|
+
["sessions", "agent_id"],
|
|
5251
|
+
["task_comments", "agent_id"],
|
|
5252
|
+
["task_history", "agent_id"],
|
|
5253
|
+
["webhooks", "agent_id"],
|
|
5254
|
+
["task_files", "agent_id"],
|
|
5255
|
+
["task_time_logs", "agent_id"],
|
|
5256
|
+
["task_watchers", "agent_id"],
|
|
5257
|
+
["task_checkpoints", "agent_id"],
|
|
5258
|
+
["task_heartbeats", "agent_id"],
|
|
5259
|
+
["project_agent_roles", "agent_id"]
|
|
5260
|
+
];
|
|
5261
|
+
let changed = 0;
|
|
5262
|
+
for (const [table, column] of refs) {
|
|
5263
|
+
if (!tableHasColumn(db, table, column))
|
|
5264
|
+
continue;
|
|
5265
|
+
try {
|
|
5266
|
+
changed += db.run(`UPDATE ${table} SET ${column} = ? WHERE LOWER(${column}) = ?`, [newName, oldName]).changes;
|
|
5267
|
+
} catch {}
|
|
5268
|
+
}
|
|
5269
|
+
return changed;
|
|
5270
|
+
}
|
|
5271
|
+
function normalizeGeneratedAgentNames(db) {
|
|
5272
|
+
const rows = db.query("SELECT * FROM agents ORDER BY created_at, id").all();
|
|
5273
|
+
const existing = new Set(rows.map((agent) => normalizeAgentNameInput(agent.name)));
|
|
5274
|
+
const renamed = [];
|
|
5275
|
+
for (const agent of rows) {
|
|
5276
|
+
const oldName = normalizeAgentNameInput(agent.name);
|
|
5277
|
+
if (!isBlockedAgentName(oldName))
|
|
5278
|
+
continue;
|
|
5279
|
+
const candidates = suggestAgentNames(existing);
|
|
5280
|
+
const replacement = candidates[0];
|
|
5281
|
+
if (!replacement) {
|
|
5282
|
+
throw new Error("No safe agent names are available for normalization");
|
|
5283
|
+
}
|
|
5284
|
+
existing.delete(oldName);
|
|
5285
|
+
existing.add(replacement);
|
|
5286
|
+
db.run("UPDATE agents SET name = ?, last_seen_at = ? WHERE id = ?", [replacement, now(), agent.id]);
|
|
5287
|
+
const referenceUpdates = updateReferences(db, oldName, replacement);
|
|
5288
|
+
renamed.push({
|
|
5289
|
+
id: agent.id,
|
|
5290
|
+
old_name: oldName,
|
|
5291
|
+
new_name: replacement,
|
|
5292
|
+
reference_updates: referenceUpdates
|
|
5293
|
+
});
|
|
5294
|
+
}
|
|
5295
|
+
return renamed;
|
|
5296
|
+
}
|
|
5297
|
+
|
|
5298
|
+
// src/db/agents.ts
|
|
5039
5299
|
function getActiveWindowMs() {
|
|
5040
5300
|
const env = process.env["TODOS_AGENT_TIMEOUT_MS"];
|
|
5041
5301
|
if (env) {
|
|
@@ -5057,7 +5317,7 @@ function getAvailableNamesFromPool(pool, db) {
|
|
|
5057
5317
|
autoReleaseStaleAgents(db);
|
|
5058
5318
|
const cutoff = new Date(Date.now() - getActiveWindowMs()).toISOString();
|
|
5059
5319
|
const activeNames = new Set(db.query("SELECT name FROM agents WHERE status = 'active' AND last_seen_at > ?").all(cutoff).map((r) => r.name.toLowerCase()));
|
|
5060
|
-
return pool.filter((name) => !activeNames.has(name
|
|
5320
|
+
return pool.map(normalizeAgentNameInput).filter((name) => !activeNames.has(name));
|
|
5061
5321
|
}
|
|
5062
5322
|
function shortUuid() {
|
|
5063
5323
|
return crypto.randomUUID().slice(0, 8);
|
|
@@ -5073,7 +5333,8 @@ function rowToAgent(row) {
|
|
|
5073
5333
|
}
|
|
5074
5334
|
function registerAgent(input, db) {
|
|
5075
5335
|
const d = db || getDatabase();
|
|
5076
|
-
const
|
|
5336
|
+
const existingNames = d.query("SELECT name FROM agents").all().map((row) => row.name);
|
|
5337
|
+
const normalizedName = validateAgentName(input.name, existingNames);
|
|
5077
5338
|
const existing = getAgentByName(normalizedName, d);
|
|
5078
5339
|
if (existing) {
|
|
5079
5340
|
const lastSeenMs = new Date(existing.last_seen_at).getTime();
|
|
@@ -5206,7 +5467,8 @@ function updateAgent(id, input, db) {
|
|
|
5206
5467
|
const sets = ["last_seen_at = ?"];
|
|
5207
5468
|
const params = [now()];
|
|
5208
5469
|
if (input.name !== undefined) {
|
|
5209
|
-
const
|
|
5470
|
+
const existingNames = d.query("SELECT name FROM agents WHERE id != ?").all(id).map((row) => row.name);
|
|
5471
|
+
const newName = validateAgentName(input.name, existingNames);
|
|
5210
5472
|
const holder = getAgentByName(newName, d);
|
|
5211
5473
|
if (holder && holder.id !== id) {
|
|
5212
5474
|
const lastSeenMs = new Date(holder.last_seen_at).getTime();
|
|
@@ -5315,6 +5577,87 @@ function getCapableAgents(capabilities, opts, db) {
|
|
|
5315
5577
|
})).filter((entry) => entry.score >= minScore).sort((a, b) => b.score - a.score);
|
|
5316
5578
|
return opts?.limit ? scored.slice(0, opts.limit) : scored;
|
|
5317
5579
|
}
|
|
5580
|
+
// src/db/api-keys.ts
|
|
5581
|
+
init_database();
|
|
5582
|
+
import { createHash, randomBytes, timingSafeEqual } from "crypto";
|
|
5583
|
+
function rowToRecord(row) {
|
|
5584
|
+
return {
|
|
5585
|
+
id: row.id,
|
|
5586
|
+
name: row.name,
|
|
5587
|
+
prefix: row.prefix,
|
|
5588
|
+
permissions: JSON.parse(row.permissions || '["*"]'),
|
|
5589
|
+
created_at: row.created_at,
|
|
5590
|
+
last_used_at: row.last_used_at,
|
|
5591
|
+
expires_at: row.expires_at,
|
|
5592
|
+
revoked_at: row.revoked_at
|
|
5593
|
+
};
|
|
5594
|
+
}
|
|
5595
|
+
function hashApiKey(key) {
|
|
5596
|
+
return createHash("sha256").update(key).digest("hex");
|
|
5597
|
+
}
|
|
5598
|
+
function safeEqualHex(a, b) {
|
|
5599
|
+
if (a.length !== b.length)
|
|
5600
|
+
return false;
|
|
5601
|
+
return timingSafeEqual(Buffer.from(a, "hex"), Buffer.from(b, "hex"));
|
|
5602
|
+
}
|
|
5603
|
+
function generatePlaintextKey() {
|
|
5604
|
+
return `tdos_${randomBytes(32).toString("base64url")}`;
|
|
5605
|
+
}
|
|
5606
|
+
function createApiKey(input, db) {
|
|
5607
|
+
const d = db || getDatabase();
|
|
5608
|
+
const name = input.name.trim();
|
|
5609
|
+
if (!name)
|
|
5610
|
+
throw new Error("API key name is required");
|
|
5611
|
+
const key = generatePlaintextKey();
|
|
5612
|
+
const timestamp = now();
|
|
5613
|
+
const id = uuid();
|
|
5614
|
+
const prefix = key.slice(0, 12);
|
|
5615
|
+
d.run(`INSERT INTO api_keys (id, name, key_hash, prefix, permissions, created_at, expires_at)
|
|
5616
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)`, [
|
|
5617
|
+
id,
|
|
5618
|
+
name,
|
|
5619
|
+
hashApiKey(key),
|
|
5620
|
+
prefix,
|
|
5621
|
+
JSON.stringify(input.permissions?.length ? input.permissions : ["*"]),
|
|
5622
|
+
timestamp,
|
|
5623
|
+
input.expires_at || null
|
|
5624
|
+
]);
|
|
5625
|
+
const row = d.query("SELECT * FROM api_keys WHERE id = ?").get(id);
|
|
5626
|
+
return { key, record: rowToRecord(row) };
|
|
5627
|
+
}
|
|
5628
|
+
function listApiKeys(opts, db) {
|
|
5629
|
+
const d = db || getDatabase();
|
|
5630
|
+
const includeRevoked = opts?.include_revoked ?? false;
|
|
5631
|
+
const sql = includeRevoked ? "SELECT * FROM api_keys ORDER BY created_at DESC" : "SELECT * FROM api_keys WHERE revoked_at IS NULL ORDER BY created_at DESC";
|
|
5632
|
+
return d.query(sql).all().map(rowToRecord);
|
|
5633
|
+
}
|
|
5634
|
+
function hasActiveApiKeys(db) {
|
|
5635
|
+
const d = db || getDatabase();
|
|
5636
|
+
const row = d.query("SELECT COUNT(*) AS count FROM api_keys WHERE revoked_at IS NULL AND (expires_at IS NULL OR expires_at > ?)").get(now());
|
|
5637
|
+
return (row?.count ?? 0) > 0;
|
|
5638
|
+
}
|
|
5639
|
+
function verifyApiKey(key, db) {
|
|
5640
|
+
const d = db || getDatabase();
|
|
5641
|
+
const candidateHash = hashApiKey(key);
|
|
5642
|
+
const rows = d.query("SELECT * FROM api_keys WHERE revoked_at IS NULL AND (expires_at IS NULL OR expires_at > ?)").all(now());
|
|
5643
|
+
for (const row of rows) {
|
|
5644
|
+
if (!safeEqualHex(candidateHash, row.key_hash))
|
|
5645
|
+
continue;
|
|
5646
|
+
d.run("UPDATE api_keys SET last_used_at = ? WHERE id = ?", [now(), row.id]);
|
|
5647
|
+
return rowToRecord({ ...row, last_used_at: now() });
|
|
5648
|
+
}
|
|
5649
|
+
return null;
|
|
5650
|
+
}
|
|
5651
|
+
function revokeApiKey(idOrPrefix, db) {
|
|
5652
|
+
const d = db || getDatabase();
|
|
5653
|
+
const identifier = idOrPrefix.trim();
|
|
5654
|
+
const row = d.query("SELECT * FROM api_keys WHERE id = ? OR prefix = ?").get(identifier, identifier);
|
|
5655
|
+
if (!row)
|
|
5656
|
+
return null;
|
|
5657
|
+
d.run("UPDATE api_keys SET revoked_at = ? WHERE id = ?", [now(), row.id]);
|
|
5658
|
+
const updated = d.query("SELECT * FROM api_keys WHERE id = ?").get(row.id);
|
|
5659
|
+
return rowToRecord(updated);
|
|
5660
|
+
}
|
|
5318
5661
|
// src/db/task-lists.ts
|
|
5319
5662
|
init_types();
|
|
5320
5663
|
init_database();
|
|
@@ -8235,7 +8578,7 @@ var require_utils_webcrypto = __commonJS((exports, module) => {
|
|
|
8235
8578
|
var nodeCrypto = __require("crypto");
|
|
8236
8579
|
module.exports = {
|
|
8237
8580
|
postgresMd5PasswordHash,
|
|
8238
|
-
randomBytes,
|
|
8581
|
+
randomBytes: randomBytes2,
|
|
8239
8582
|
deriveKey,
|
|
8240
8583
|
sha256,
|
|
8241
8584
|
hashByName,
|
|
@@ -8245,7 +8588,7 @@ var require_utils_webcrypto = __commonJS((exports, module) => {
|
|
|
8245
8588
|
var webCrypto = nodeCrypto.webcrypto || globalThis.crypto;
|
|
8246
8589
|
var subtleCrypto = webCrypto.subtle;
|
|
8247
8590
|
var textEncoder = new TextEncoder;
|
|
8248
|
-
function
|
|
8591
|
+
function randomBytes2(length) {
|
|
8249
8592
|
return webCrypto.getRandomValues(Buffer.alloc(length));
|
|
8250
8593
|
}
|
|
8251
8594
|
async function md5(string) {
|
|
@@ -18044,6 +18387,7 @@ async function dispatchToMultiple(input, opts = {}, db) {
|
|
|
18044
18387
|
return dispatches;
|
|
18045
18388
|
}
|
|
18046
18389
|
export {
|
|
18390
|
+
verifyApiKey,
|
|
18047
18391
|
validateTmuxTarget,
|
|
18048
18392
|
uuid,
|
|
18049
18393
|
updateTemplate,
|
|
@@ -18068,6 +18412,7 @@ export {
|
|
|
18068
18412
|
syncWithAgents,
|
|
18069
18413
|
syncWithAgent,
|
|
18070
18414
|
syncKgEdges,
|
|
18415
|
+
suggestAgentNames,
|
|
18071
18416
|
stealTask,
|
|
18072
18417
|
startTask,
|
|
18073
18418
|
slugify,
|
|
@@ -18081,6 +18426,7 @@ export {
|
|
|
18081
18426
|
scoreTask,
|
|
18082
18427
|
saveSnapshot,
|
|
18083
18428
|
runDueDispatches,
|
|
18429
|
+
revokeApiKey,
|
|
18084
18430
|
resolveVariables,
|
|
18085
18431
|
resolvePartialId,
|
|
18086
18432
|
resetMachineId,
|
|
@@ -18104,6 +18450,7 @@ export {
|
|
|
18104
18450
|
parseRecurrenceRule,
|
|
18105
18451
|
parseGitHubUrl,
|
|
18106
18452
|
now,
|
|
18453
|
+
normalizeGeneratedAgentNames,
|
|
18107
18454
|
nextTaskShortId,
|
|
18108
18455
|
nextOccurrence,
|
|
18109
18456
|
moveTask,
|
|
@@ -18135,12 +18482,14 @@ export {
|
|
|
18135
18482
|
listCyclesWithStats,
|
|
18136
18483
|
listCycles,
|
|
18137
18484
|
listComments,
|
|
18485
|
+
listApiKeys,
|
|
18138
18486
|
listAgents,
|
|
18139
18487
|
issueToTask,
|
|
18140
18488
|
isValidRecurrenceRule,
|
|
18141
18489
|
isAgentConflict,
|
|
18142
18490
|
initBuiltinTemplates,
|
|
18143
18491
|
importTemplate,
|
|
18492
|
+
hasActiveApiKeys,
|
|
18144
18493
|
getWebhook,
|
|
18145
18494
|
getTraceStats,
|
|
18146
18495
|
getTemplateWithTasks,
|
|
@@ -18255,6 +18604,7 @@ export {
|
|
|
18255
18604
|
createDispatch,
|
|
18256
18605
|
createCycle,
|
|
18257
18606
|
createClient,
|
|
18607
|
+
createApiKey,
|
|
18258
18608
|
countTasks,
|
|
18259
18609
|
completeTask,
|
|
18260
18610
|
closeDatabase,
|