@hasna/todos 0.11.34 → 0.11.35
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 +521 -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 +333 -5
- package/dist/mcp/index.js +274 -8
- package/dist/mcp/tools/agents.d.ts.map +1 -1
- package/dist/server/index.js +284 -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;AAED,wBAAgB,iBAAiB,CAAC,aAAa,GAAE,QAAQ,CAAC,MAAM,CAAM,GAAG,MAAM,EAAE,CAGhF;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,214 @@ 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 suggestAgentNames(existingNames = []) {
|
|
5188
|
+
const existing = new Set([...existingNames].map(normalizeAgentNameInput));
|
|
5189
|
+
return PREFERRED_AGENT_NAMES.filter((name) => !existing.has(name));
|
|
5190
|
+
}
|
|
5191
|
+
function validateAgentName(name, existingNames = []) {
|
|
5192
|
+
const normalized = normalizeAgentNameInput(name);
|
|
5193
|
+
const suggestions = suggestAgentNames(existingNames).slice(0, 5);
|
|
5194
|
+
if (!normalized) {
|
|
5195
|
+
throw new InvalidAgentNameError(name, "choose a real one-word name instead of an empty value", suggestions);
|
|
5196
|
+
}
|
|
5197
|
+
if (/\s/.test(normalized)) {
|
|
5198
|
+
throw new InvalidAgentNameError(name, "use a single word, preferably a Roman or Greek name", suggestions);
|
|
5199
|
+
}
|
|
5200
|
+
if (normalized.length < 3) {
|
|
5201
|
+
throw new InvalidAgentNameError(name, "use a more distinctive name with at least three characters", suggestions);
|
|
5202
|
+
}
|
|
5203
|
+
if (isGenericAgentName(normalized)) {
|
|
5204
|
+
throw new InvalidAgentNameError(name, "generic names like agent, agent-1, assistant, or worker-2 are reserved", suggestions);
|
|
5205
|
+
}
|
|
5206
|
+
if (hasGeneratedNumericSuffix(normalized)) {
|
|
5207
|
+
throw new InvalidAgentNameError(name, "numbered suffix names are not allowed; pick a distinct human-readable name", suggestions);
|
|
5208
|
+
}
|
|
5209
|
+
if (!ONE_WORD_NAME_RE.test(normalized)) {
|
|
5210
|
+
throw new InvalidAgentNameError(name, "use one word made of letters only, preferably a Roman or Greek name", suggestions);
|
|
5211
|
+
}
|
|
5212
|
+
return normalized;
|
|
5213
|
+
}
|
|
5214
|
+
function tableHasColumn(db, table, column) {
|
|
5215
|
+
try {
|
|
5216
|
+
return db.query(`PRAGMA table_info(${table})`).all().some((row) => row.name === column);
|
|
5217
|
+
} catch {
|
|
5218
|
+
return false;
|
|
5219
|
+
}
|
|
5220
|
+
}
|
|
5221
|
+
function updateReferences(db, oldName, newName) {
|
|
5222
|
+
const refs = [
|
|
5223
|
+
["tasks", "assigned_to"],
|
|
5224
|
+
["tasks", "agent_id"],
|
|
5225
|
+
["tasks", "locked_by"],
|
|
5226
|
+
["tasks", "assigned_by"],
|
|
5227
|
+
["plans", "agent_id"],
|
|
5228
|
+
["sessions", "agent_id"],
|
|
5229
|
+
["task_comments", "agent_id"],
|
|
5230
|
+
["task_history", "agent_id"],
|
|
5231
|
+
["webhooks", "agent_id"],
|
|
5232
|
+
["task_files", "agent_id"],
|
|
5233
|
+
["task_time_logs", "agent_id"],
|
|
5234
|
+
["task_watchers", "agent_id"],
|
|
5235
|
+
["task_checkpoints", "agent_id"],
|
|
5236
|
+
["task_heartbeats", "agent_id"],
|
|
5237
|
+
["project_agent_roles", "agent_id"]
|
|
5238
|
+
];
|
|
5239
|
+
let changed = 0;
|
|
5240
|
+
for (const [table, column] of refs) {
|
|
5241
|
+
if (!tableHasColumn(db, table, column))
|
|
5242
|
+
continue;
|
|
5243
|
+
try {
|
|
5244
|
+
changed += db.run(`UPDATE ${table} SET ${column} = ? WHERE LOWER(${column}) = ?`, [newName, oldName]).changes;
|
|
5245
|
+
} catch {}
|
|
5246
|
+
}
|
|
5247
|
+
return changed;
|
|
5248
|
+
}
|
|
5249
|
+
function normalizeGeneratedAgentNames(db) {
|
|
5250
|
+
const rows = db.query("SELECT * FROM agents ORDER BY created_at, id").all();
|
|
5251
|
+
const existing = new Set(rows.map((agent) => normalizeAgentNameInput(agent.name)));
|
|
5252
|
+
const renamed = [];
|
|
5253
|
+
for (const agent of rows) {
|
|
5254
|
+
const oldName = normalizeAgentNameInput(agent.name);
|
|
5255
|
+
if (!isBlockedAgentName(oldName))
|
|
5256
|
+
continue;
|
|
5257
|
+
const candidates = suggestAgentNames(existing);
|
|
5258
|
+
const replacement = candidates[0];
|
|
5259
|
+
if (!replacement) {
|
|
5260
|
+
throw new Error("No safe agent names are available for normalization");
|
|
5261
|
+
}
|
|
5262
|
+
existing.delete(oldName);
|
|
5263
|
+
existing.add(replacement);
|
|
5264
|
+
db.run("UPDATE agents SET name = ?, last_seen_at = ? WHERE id = ?", [replacement, now(), agent.id]);
|
|
5265
|
+
const referenceUpdates = updateReferences(db, oldName, replacement);
|
|
5266
|
+
renamed.push({
|
|
5267
|
+
id: agent.id,
|
|
5268
|
+
old_name: oldName,
|
|
5269
|
+
new_name: replacement,
|
|
5270
|
+
reference_updates: referenceUpdates
|
|
5271
|
+
});
|
|
5272
|
+
}
|
|
5273
|
+
return renamed;
|
|
5274
|
+
}
|
|
5275
|
+
|
|
5276
|
+
// src/db/agents.ts
|
|
5039
5277
|
function getActiveWindowMs() {
|
|
5040
5278
|
const env = process.env["TODOS_AGENT_TIMEOUT_MS"];
|
|
5041
5279
|
if (env) {
|
|
@@ -5057,7 +5295,7 @@ function getAvailableNamesFromPool(pool, db) {
|
|
|
5057
5295
|
autoReleaseStaleAgents(db);
|
|
5058
5296
|
const cutoff = new Date(Date.now() - getActiveWindowMs()).toISOString();
|
|
5059
5297
|
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
|
|
5298
|
+
return pool.map(normalizeAgentNameInput).filter((name) => !activeNames.has(name));
|
|
5061
5299
|
}
|
|
5062
5300
|
function shortUuid() {
|
|
5063
5301
|
return crypto.randomUUID().slice(0, 8);
|
|
@@ -5073,7 +5311,8 @@ function rowToAgent(row) {
|
|
|
5073
5311
|
}
|
|
5074
5312
|
function registerAgent(input, db) {
|
|
5075
5313
|
const d = db || getDatabase();
|
|
5076
|
-
const
|
|
5314
|
+
const existingNames = d.query("SELECT name FROM agents").all().map((row) => row.name);
|
|
5315
|
+
const normalizedName = validateAgentName(input.name, existingNames);
|
|
5077
5316
|
const existing = getAgentByName(normalizedName, d);
|
|
5078
5317
|
if (existing) {
|
|
5079
5318
|
const lastSeenMs = new Date(existing.last_seen_at).getTime();
|
|
@@ -5206,7 +5445,8 @@ function updateAgent(id, input, db) {
|
|
|
5206
5445
|
const sets = ["last_seen_at = ?"];
|
|
5207
5446
|
const params = [now()];
|
|
5208
5447
|
if (input.name !== undefined) {
|
|
5209
|
-
const
|
|
5448
|
+
const existingNames = d.query("SELECT name FROM agents WHERE id != ?").all(id).map((row) => row.name);
|
|
5449
|
+
const newName = validateAgentName(input.name, existingNames);
|
|
5210
5450
|
const holder = getAgentByName(newName, d);
|
|
5211
5451
|
if (holder && holder.id !== id) {
|
|
5212
5452
|
const lastSeenMs = new Date(holder.last_seen_at).getTime();
|
|
@@ -5315,6 +5555,87 @@ function getCapableAgents(capabilities, opts, db) {
|
|
|
5315
5555
|
})).filter((entry) => entry.score >= minScore).sort((a, b) => b.score - a.score);
|
|
5316
5556
|
return opts?.limit ? scored.slice(0, opts.limit) : scored;
|
|
5317
5557
|
}
|
|
5558
|
+
// src/db/api-keys.ts
|
|
5559
|
+
init_database();
|
|
5560
|
+
import { createHash, randomBytes, timingSafeEqual } from "crypto";
|
|
5561
|
+
function rowToRecord(row) {
|
|
5562
|
+
return {
|
|
5563
|
+
id: row.id,
|
|
5564
|
+
name: row.name,
|
|
5565
|
+
prefix: row.prefix,
|
|
5566
|
+
permissions: JSON.parse(row.permissions || '["*"]'),
|
|
5567
|
+
created_at: row.created_at,
|
|
5568
|
+
last_used_at: row.last_used_at,
|
|
5569
|
+
expires_at: row.expires_at,
|
|
5570
|
+
revoked_at: row.revoked_at
|
|
5571
|
+
};
|
|
5572
|
+
}
|
|
5573
|
+
function hashApiKey(key) {
|
|
5574
|
+
return createHash("sha256").update(key).digest("hex");
|
|
5575
|
+
}
|
|
5576
|
+
function safeEqualHex(a, b) {
|
|
5577
|
+
if (a.length !== b.length)
|
|
5578
|
+
return false;
|
|
5579
|
+
return timingSafeEqual(Buffer.from(a, "hex"), Buffer.from(b, "hex"));
|
|
5580
|
+
}
|
|
5581
|
+
function generatePlaintextKey() {
|
|
5582
|
+
return `tdos_${randomBytes(32).toString("base64url")}`;
|
|
5583
|
+
}
|
|
5584
|
+
function createApiKey(input, db) {
|
|
5585
|
+
const d = db || getDatabase();
|
|
5586
|
+
const name = input.name.trim();
|
|
5587
|
+
if (!name)
|
|
5588
|
+
throw new Error("API key name is required");
|
|
5589
|
+
const key = generatePlaintextKey();
|
|
5590
|
+
const timestamp = now();
|
|
5591
|
+
const id = uuid();
|
|
5592
|
+
const prefix = key.slice(0, 12);
|
|
5593
|
+
d.run(`INSERT INTO api_keys (id, name, key_hash, prefix, permissions, created_at, expires_at)
|
|
5594
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)`, [
|
|
5595
|
+
id,
|
|
5596
|
+
name,
|
|
5597
|
+
hashApiKey(key),
|
|
5598
|
+
prefix,
|
|
5599
|
+
JSON.stringify(input.permissions?.length ? input.permissions : ["*"]),
|
|
5600
|
+
timestamp,
|
|
5601
|
+
input.expires_at || null
|
|
5602
|
+
]);
|
|
5603
|
+
const row = d.query("SELECT * FROM api_keys WHERE id = ?").get(id);
|
|
5604
|
+
return { key, record: rowToRecord(row) };
|
|
5605
|
+
}
|
|
5606
|
+
function listApiKeys(opts, db) {
|
|
5607
|
+
const d = db || getDatabase();
|
|
5608
|
+
const includeRevoked = opts?.include_revoked ?? false;
|
|
5609
|
+
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";
|
|
5610
|
+
return d.query(sql).all().map(rowToRecord);
|
|
5611
|
+
}
|
|
5612
|
+
function hasActiveApiKeys(db) {
|
|
5613
|
+
const d = db || getDatabase();
|
|
5614
|
+
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());
|
|
5615
|
+
return (row?.count ?? 0) > 0;
|
|
5616
|
+
}
|
|
5617
|
+
function verifyApiKey(key, db) {
|
|
5618
|
+
const d = db || getDatabase();
|
|
5619
|
+
const candidateHash = hashApiKey(key);
|
|
5620
|
+
const rows = d.query("SELECT * FROM api_keys WHERE revoked_at IS NULL AND (expires_at IS NULL OR expires_at > ?)").all(now());
|
|
5621
|
+
for (const row of rows) {
|
|
5622
|
+
if (!safeEqualHex(candidateHash, row.key_hash))
|
|
5623
|
+
continue;
|
|
5624
|
+
d.run("UPDATE api_keys SET last_used_at = ? WHERE id = ?", [now(), row.id]);
|
|
5625
|
+
return rowToRecord({ ...row, last_used_at: now() });
|
|
5626
|
+
}
|
|
5627
|
+
return null;
|
|
5628
|
+
}
|
|
5629
|
+
function revokeApiKey(idOrPrefix, db) {
|
|
5630
|
+
const d = db || getDatabase();
|
|
5631
|
+
const identifier = idOrPrefix.trim();
|
|
5632
|
+
const row = d.query("SELECT * FROM api_keys WHERE id = ? OR prefix = ?").get(identifier, identifier);
|
|
5633
|
+
if (!row)
|
|
5634
|
+
return null;
|
|
5635
|
+
d.run("UPDATE api_keys SET revoked_at = ? WHERE id = ?", [now(), row.id]);
|
|
5636
|
+
const updated = d.query("SELECT * FROM api_keys WHERE id = ?").get(row.id);
|
|
5637
|
+
return rowToRecord(updated);
|
|
5638
|
+
}
|
|
5318
5639
|
// src/db/task-lists.ts
|
|
5319
5640
|
init_types();
|
|
5320
5641
|
init_database();
|
|
@@ -8235,7 +8556,7 @@ var require_utils_webcrypto = __commonJS((exports, module) => {
|
|
|
8235
8556
|
var nodeCrypto = __require("crypto");
|
|
8236
8557
|
module.exports = {
|
|
8237
8558
|
postgresMd5PasswordHash,
|
|
8238
|
-
randomBytes,
|
|
8559
|
+
randomBytes: randomBytes2,
|
|
8239
8560
|
deriveKey,
|
|
8240
8561
|
sha256,
|
|
8241
8562
|
hashByName,
|
|
@@ -8245,7 +8566,7 @@ var require_utils_webcrypto = __commonJS((exports, module) => {
|
|
|
8245
8566
|
var webCrypto = nodeCrypto.webcrypto || globalThis.crypto;
|
|
8246
8567
|
var subtleCrypto = webCrypto.subtle;
|
|
8247
8568
|
var textEncoder = new TextEncoder;
|
|
8248
|
-
function
|
|
8569
|
+
function randomBytes2(length) {
|
|
8249
8570
|
return webCrypto.getRandomValues(Buffer.alloc(length));
|
|
8250
8571
|
}
|
|
8251
8572
|
async function md5(string) {
|
|
@@ -18044,6 +18365,7 @@ async function dispatchToMultiple(input, opts = {}, db) {
|
|
|
18044
18365
|
return dispatches;
|
|
18045
18366
|
}
|
|
18046
18367
|
export {
|
|
18368
|
+
verifyApiKey,
|
|
18047
18369
|
validateTmuxTarget,
|
|
18048
18370
|
uuid,
|
|
18049
18371
|
updateTemplate,
|
|
@@ -18068,6 +18390,7 @@ export {
|
|
|
18068
18390
|
syncWithAgents,
|
|
18069
18391
|
syncWithAgent,
|
|
18070
18392
|
syncKgEdges,
|
|
18393
|
+
suggestAgentNames,
|
|
18071
18394
|
stealTask,
|
|
18072
18395
|
startTask,
|
|
18073
18396
|
slugify,
|
|
@@ -18081,6 +18404,7 @@ export {
|
|
|
18081
18404
|
scoreTask,
|
|
18082
18405
|
saveSnapshot,
|
|
18083
18406
|
runDueDispatches,
|
|
18407
|
+
revokeApiKey,
|
|
18084
18408
|
resolveVariables,
|
|
18085
18409
|
resolvePartialId,
|
|
18086
18410
|
resetMachineId,
|
|
@@ -18104,6 +18428,7 @@ export {
|
|
|
18104
18428
|
parseRecurrenceRule,
|
|
18105
18429
|
parseGitHubUrl,
|
|
18106
18430
|
now,
|
|
18431
|
+
normalizeGeneratedAgentNames,
|
|
18107
18432
|
nextTaskShortId,
|
|
18108
18433
|
nextOccurrence,
|
|
18109
18434
|
moveTask,
|
|
@@ -18135,12 +18460,14 @@ export {
|
|
|
18135
18460
|
listCyclesWithStats,
|
|
18136
18461
|
listCycles,
|
|
18137
18462
|
listComments,
|
|
18463
|
+
listApiKeys,
|
|
18138
18464
|
listAgents,
|
|
18139
18465
|
issueToTask,
|
|
18140
18466
|
isValidRecurrenceRule,
|
|
18141
18467
|
isAgentConflict,
|
|
18142
18468
|
initBuiltinTemplates,
|
|
18143
18469
|
importTemplate,
|
|
18470
|
+
hasActiveApiKeys,
|
|
18144
18471
|
getWebhook,
|
|
18145
18472
|
getTraceStats,
|
|
18146
18473
|
getTemplateWithTasks,
|
|
@@ -18255,6 +18582,7 @@ export {
|
|
|
18255
18582
|
createDispatch,
|
|
18256
18583
|
createCycle,
|
|
18257
18584
|
createClient,
|
|
18585
|
+
createApiKey,
|
|
18258
18586
|
countTasks,
|
|
18259
18587
|
completeTask,
|
|
18260
18588
|
closeDatabase,
|