@hasna/todos 0.13.5 → 0.13.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/contracts.js CHANGED
@@ -2331,6 +2331,7 @@ function ensureSchema(db) {
2331
2331
  ensureColumn("tasks", "reason", "TEXT");
2332
2332
  ensureColumn("tasks", "spawned_from_session", "TEXT");
2333
2333
  ensureColumn("tasks", "assigned_by", "TEXT");
2334
+ ensureColumn("tasks", "created_by", "TEXT");
2334
2335
  ensureColumn("tasks", "assigned_from_project", "TEXT");
2335
2336
  ensureColumn("tasks", "started_at", "TEXT");
2336
2337
  ensureColumn("tasks", "task_type", "TEXT");
@@ -2493,6 +2494,8 @@ function ensureSchema(db) {
2493
2494
  ensureIndex("CREATE INDEX IF NOT EXISTS idx_project_sources_project ON project_sources(project_id)");
2494
2495
  ensureIndex("CREATE INDEX IF NOT EXISTS idx_project_sources_type ON project_sources(type)");
2495
2496
  ensureIndex("CREATE INDEX IF NOT EXISTS idx_tasks_assigned_by ON tasks(assigned_by)");
2497
+ ensureIndex("CREATE INDEX IF NOT EXISTS idx_tasks_created_by ON tasks(created_by)");
2498
+ ensureIndex("CREATE INDEX IF NOT EXISTS idx_tasks_assigned_created ON tasks(assigned_to, created_by)");
2496
2499
  ensureIndex("CREATE INDEX IF NOT EXISTS idx_task_rel_source ON task_relationships(source_task_id)");
2497
2500
  ensureIndex("CREATE INDEX IF NOT EXISTS idx_task_rel_target ON task_relationships(target_task_id)");
2498
2501
  ensureIndex("CREATE INDEX IF NOT EXISTS idx_task_rel_type ON task_relationships(relationship_type)");
@@ -8792,13 +8795,14 @@ function createTask(input, db) {
8792
8795
  const timestamp2 = now();
8793
8796
  const tags = input.tags || [];
8794
8797
  const machineId = currentStorageMachineId(d);
8798
+ const createdBy = input.created_by || input.agent_id || null;
8795
8799
  const assignedBy = input.assigned_by || input.agent_id;
8796
8800
  const assignedFromProject = input.assigned_from_project || null;
8797
8801
  let id = uuid();
8798
8802
  for (let attempt = 0;attempt < 3; attempt++) {
8799
8803
  try {
8800
- d.run(`INSERT INTO tasks (id, short_id, project_id, parent_id, plan_id, task_list_id, cycle_id, title, description, status, priority, agent_id, assigned_to, session_id, working_dir, tags, metadata, version, created_at, updated_at, due_at, estimated_minutes, sla_minutes, confidence, retry_count, max_retries, retry_after, requires_approval, approved_by, approved_at, recurrence_rule, recurrence_parent_id, spawns_template_id, reason, spawned_from_session, assigned_by, assigned_from_project, task_type, machine_id)
8801
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
8804
+ d.run(`INSERT INTO tasks (id, short_id, project_id, parent_id, plan_id, task_list_id, cycle_id, title, description, status, priority, agent_id, assigned_to, session_id, working_dir, tags, metadata, version, created_at, updated_at, due_at, estimated_minutes, sla_minutes, confidence, retry_count, max_retries, retry_after, requires_approval, approved_by, approved_at, recurrence_rule, recurrence_parent_id, spawns_template_id, reason, spawned_from_session, assigned_by, created_by, assigned_from_project, task_type, machine_id)
8805
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
8802
8806
  id,
8803
8807
  null,
8804
8808
  input.project_id || null,
@@ -8834,6 +8838,7 @@ function createTask(input, db) {
8834
8838
  input.reason || null,
8835
8839
  input.spawned_from_session || null,
8836
8840
  assignedBy || null,
8841
+ createdBy,
8837
8842
  assignedFromProject || null,
8838
8843
  input.task_type || null,
8839
8844
  machineId
@@ -8943,6 +8948,14 @@ function listTasks(filter = {}, db) {
8943
8948
  conditions.push("agent_id = ?");
8944
8949
  params.push(filter.agent_id);
8945
8950
  }
8951
+ if (filter.created_by) {
8952
+ conditions.push("LOWER(created_by) = LOWER(?)");
8953
+ params.push(filter.created_by);
8954
+ }
8955
+ if (filter.not_created_by) {
8956
+ conditions.push("(created_by IS NULL OR LOWER(created_by) != LOWER(?))");
8957
+ params.push(filter.not_created_by);
8958
+ }
8946
8959
  if (filter.session_id) {
8947
8960
  conditions.push("session_id = ?");
8948
8961
  params.push(filter.session_id);
@@ -9096,6 +9109,14 @@ function countTasks(filter = {}, db) {
9096
9109
  conditions.push("agent_id = ?");
9097
9110
  params.push(filter.agent_id);
9098
9111
  }
9112
+ if (filter.created_by) {
9113
+ conditions.push("LOWER(created_by) = LOWER(?)");
9114
+ params.push(filter.created_by);
9115
+ }
9116
+ if (filter.not_created_by) {
9117
+ conditions.push("(created_by IS NULL OR LOWER(created_by) != LOWER(?))");
9118
+ params.push(filter.not_created_by);
9119
+ }
9099
9120
  if (filter.session_id) {
9100
9121
  conditions.push("session_id = ?");
9101
9122
  params.push(filter.session_id);
@@ -11900,7 +11921,7 @@ var init_tasks = __esm(() => {
11900
11921
  // package.json
11901
11922
  var package_default = {
11902
11923
  name: "@hasna/todos",
11903
- version: "0.13.5",
11924
+ version: "0.13.6",
11904
11925
  description: "Universal task management for AI coding agents - CLI + MCP server + interactive TUI",
11905
11926
  type: "module",
11906
11927
  main: "dist/index.js",
@@ -15332,6 +15353,7 @@ function task(input) {
15332
15353
  reason: "Bundled deterministic onboarding fixture",
15333
15354
  spawned_from_session: null,
15334
15355
  assigned_by: null,
15356
+ created_by: null,
15335
15357
  assigned_from_project: null,
15336
15358
  task_type: "onboarding",
15337
15359
  cost_tokens: 0,
@@ -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,CAoChD;AA8BD,wBAAgB,YAAY,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAy+C/C;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CA4BnD"}
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,CAoChD;AA8BD,wBAAgB,YAAY,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAi/C/C;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CA4BnD"}
@@ -1 +1 @@
1
- {"version":3,"file":"task-crud.d.ts","sourceRoot":"","sources":["../../src/db/task-crud.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAoB,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,EACV,eAAe,EACf,IAAI,EACJ,UAAU,EACV,OAAO,EACP,iBAAiB,EACjB,eAAe,EACf,4BAA4B,EAC5B,6BAA6B,EAC9B,MAAM,mBAAmB,CAAC;AAkB3B,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAS5C;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,QAAQ,GAAG,IAAI,CAMjF;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,QAAQ,GAAG,IAAI,CAGlF;AAwCD,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,IAAI,CAkFtE;AAED,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,IAAI,GAAG,IAAI,CAK9D;AAED,wBAAgB,oBAAoB,CAClC,EA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AAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,QAAQ,GAAG,IAAI,CAGlF;AAwCD,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,IAAI,CAwFtE;AAED,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,IAAI,GAAG,IAAI,CAK9D;AAED,wBAAgB,oBAAoB,CAClC,EAAE,EAAE,MAAM,EACV,EAAE,CAAC,EAAE,QAAQ,GACZ,iBAAiB,GAAG,IAAI,CA4D1B;AAED,wBAAgB,SAAS,CAAC,MAAM,GAAE,UAAe,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,IAAI,EAAE,CA2JxE;AAED,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,EACnB,EAAE,CAAC,EAAE,QAAQ,GACZ,IAAI,GAAG,IAAI,CAKb;AAcD,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,4BAA4B,EACnC,EAAE,CAAC,EAAE,QAAQ,GACZ,6BAA6B,CAmD/B;AAED,wBAAgB,UAAU,CAAC,MAAM,GAAE,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,QAAQ,CAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,MAAM,CA2HnG;AAED,wBAAgB,UAAU,CACxB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,eAAe,EACtB,EAAE,CAAC,EAAE,QAAQ,GACZ,IAAI,CA2ON;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,OAAO,CAY7D"}
package/dist/index.js CHANGED
@@ -2331,6 +2331,7 @@ function ensureSchema(db) {
2331
2331
  ensureColumn("tasks", "reason", "TEXT");
2332
2332
  ensureColumn("tasks", "spawned_from_session", "TEXT");
2333
2333
  ensureColumn("tasks", "assigned_by", "TEXT");
2334
+ ensureColumn("tasks", "created_by", "TEXT");
2334
2335
  ensureColumn("tasks", "assigned_from_project", "TEXT");
2335
2336
  ensureColumn("tasks", "started_at", "TEXT");
2336
2337
  ensureColumn("tasks", "task_type", "TEXT");
@@ -2493,6 +2494,8 @@ function ensureSchema(db) {
2493
2494
  ensureIndex("CREATE INDEX IF NOT EXISTS idx_project_sources_project ON project_sources(project_id)");
2494
2495
  ensureIndex("CREATE INDEX IF NOT EXISTS idx_project_sources_type ON project_sources(type)");
2495
2496
  ensureIndex("CREATE INDEX IF NOT EXISTS idx_tasks_assigned_by ON tasks(assigned_by)");
2497
+ ensureIndex("CREATE INDEX IF NOT EXISTS idx_tasks_created_by ON tasks(created_by)");
2498
+ ensureIndex("CREATE INDEX IF NOT EXISTS idx_tasks_assigned_created ON tasks(assigned_to, created_by)");
2496
2499
  ensureIndex("CREATE INDEX IF NOT EXISTS idx_task_rel_source ON task_relationships(source_task_id)");
2497
2500
  ensureIndex("CREATE INDEX IF NOT EXISTS idx_task_rel_target ON task_relationships(target_task_id)");
2498
2501
  ensureIndex("CREATE INDEX IF NOT EXISTS idx_task_rel_type ON task_relationships(relationship_type)");
@@ -8792,13 +8795,14 @@ function createTask(input, db) {
8792
8795
  const timestamp2 = now();
8793
8796
  const tags = input.tags || [];
8794
8797
  const machineId = currentStorageMachineId(d);
8798
+ const createdBy = input.created_by || input.agent_id || null;
8795
8799
  const assignedBy = input.assigned_by || input.agent_id;
8796
8800
  const assignedFromProject = input.assigned_from_project || null;
8797
8801
  let id = uuid();
8798
8802
  for (let attempt = 0;attempt < 3; attempt++) {
8799
8803
  try {
8800
- d.run(`INSERT INTO tasks (id, short_id, project_id, parent_id, plan_id, task_list_id, cycle_id, title, description, status, priority, agent_id, assigned_to, session_id, working_dir, tags, metadata, version, created_at, updated_at, due_at, estimated_minutes, sla_minutes, confidence, retry_count, max_retries, retry_after, requires_approval, approved_by, approved_at, recurrence_rule, recurrence_parent_id, spawns_template_id, reason, spawned_from_session, assigned_by, assigned_from_project, task_type, machine_id)
8801
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
8804
+ d.run(`INSERT INTO tasks (id, short_id, project_id, parent_id, plan_id, task_list_id, cycle_id, title, description, status, priority, agent_id, assigned_to, session_id, working_dir, tags, metadata, version, created_at, updated_at, due_at, estimated_minutes, sla_minutes, confidence, retry_count, max_retries, retry_after, requires_approval, approved_by, approved_at, recurrence_rule, recurrence_parent_id, spawns_template_id, reason, spawned_from_session, assigned_by, created_by, assigned_from_project, task_type, machine_id)
8805
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
8802
8806
  id,
8803
8807
  null,
8804
8808
  input.project_id || null,
@@ -8834,6 +8838,7 @@ function createTask(input, db) {
8834
8838
  input.reason || null,
8835
8839
  input.spawned_from_session || null,
8836
8840
  assignedBy || null,
8841
+ createdBy,
8837
8842
  assignedFromProject || null,
8838
8843
  input.task_type || null,
8839
8844
  machineId
@@ -8943,6 +8948,14 @@ function listTasks(filter = {}, db) {
8943
8948
  conditions.push("agent_id = ?");
8944
8949
  params.push(filter.agent_id);
8945
8950
  }
8951
+ if (filter.created_by) {
8952
+ conditions.push("LOWER(created_by) = LOWER(?)");
8953
+ params.push(filter.created_by);
8954
+ }
8955
+ if (filter.not_created_by) {
8956
+ conditions.push("(created_by IS NULL OR LOWER(created_by) != LOWER(?))");
8957
+ params.push(filter.not_created_by);
8958
+ }
8946
8959
  if (filter.session_id) {
8947
8960
  conditions.push("session_id = ?");
8948
8961
  params.push(filter.session_id);
@@ -9096,6 +9109,14 @@ function countTasks(filter = {}, db) {
9096
9109
  conditions.push("agent_id = ?");
9097
9110
  params.push(filter.agent_id);
9098
9111
  }
9112
+ if (filter.created_by) {
9113
+ conditions.push("LOWER(created_by) = LOWER(?)");
9114
+ params.push(filter.created_by);
9115
+ }
9116
+ if (filter.not_created_by) {
9117
+ conditions.push("(created_by IS NULL OR LOWER(created_by) != LOWER(?))");
9118
+ params.push(filter.not_created_by);
9119
+ }
9099
9120
  if (filter.session_id) {
9100
9121
  conditions.push("session_id = ?");
9101
9122
  params.push(filter.session_id);
@@ -12013,7 +12034,7 @@ var init_dispatches = __esm(() => {
12013
12034
  // package.json
12014
12035
  var package_default = {
12015
12036
  name: "@hasna/todos",
12016
- version: "0.13.5",
12037
+ version: "0.13.6",
12017
12038
  description: "Universal task management for AI coding agents - CLI + MCP server + interactive TUI",
12018
12039
  type: "module",
12019
12040
  main: "dist/index.js",
@@ -15445,6 +15466,7 @@ function task(input) {
15445
15466
  reason: "Bundled deterministic onboarding fixture",
15446
15467
  spawned_from_session: null,
15447
15468
  assigned_by: null,
15469
+ created_by: null,
15448
15470
  assigned_from_project: null,
15449
15471
  task_type: "onboarding",
15450
15472
  cost_tokens: 0,
@@ -25274,7 +25296,11 @@ function createLocalSqliteTodosStorageAdapter(options = {}) {
25274
25296
  sync: true
25275
25297
  },
25276
25298
  tasks: {
25277
- create: (input) => createTask(input, database()),
25299
+ create: (input, context) => createTask({
25300
+ ...input,
25301
+ agent_id: input.agent_id ?? context?.agentId,
25302
+ created_by: input.created_by ?? input.agent_id ?? context?.agentId
25303
+ }, database()),
25278
25304
  get: (id) => getTask(id, database()),
25279
25305
  resolveRef: (ref) => resolveTaskRefLocal(database(), ref),
25280
25306
  list: (filter = {}) => listTasksMaybeSearch(filter, database()),
@@ -25997,6 +26023,10 @@ class PostgresJsonRecordStore {
25997
26023
  conds.push(`payload->>'assigned_to' = ${p(filter.assigned_to)}`);
25998
26024
  if (filter.agent_id !== undefined)
25999
26025
  conds.push(`payload->>'agent_id' = ${p(filter.agent_id)}`);
26026
+ if (filter.created_by !== undefined)
26027
+ conds.push(`LOWER(payload->>'created_by') = LOWER(${p(filter.created_by)})`);
26028
+ if (filter.not_created_by !== undefined)
26029
+ conds.push(`(payload->>'created_by' IS NULL OR LOWER(payload->>'created_by') <> LOWER(${p(filter.not_created_by)}))`);
26000
26030
  if (filter.session_id !== undefined)
26001
26031
  conds.push(`payload->>'session_id' = ${p(filter.session_id)}`);
26002
26032
  if (filter.tags?.length) {
@@ -26510,7 +26540,7 @@ async function createTask2(input, store, context) {
26510
26540
  description: input.description ?? null,
26511
26541
  status: input.status ?? "pending",
26512
26542
  priority: input.priority ?? "medium",
26513
- agent_id: input.agent_id ?? null,
26543
+ agent_id: input.agent_id ?? context?.agentId ?? null,
26514
26544
  assigned_to: input.assigned_to ?? null,
26515
26545
  session_id: input.session_id ?? context?.sessionId ?? null,
26516
26546
  working_dir: input.working_dir ?? null,
@@ -26535,7 +26565,8 @@ async function createTask2(input, store, context) {
26535
26565
  confidence: input.confidence ?? null,
26536
26566
  reason: input.reason ?? null,
26537
26567
  spawned_from_session: input.spawned_from_session ?? null,
26538
- assigned_by: input.assigned_by ?? null,
26568
+ assigned_by: input.assigned_by ?? input.agent_id ?? context?.agentId ?? null,
26569
+ created_by: input.created_by ?? input.agent_id ?? context?.agentId ?? null,
26539
26570
  assigned_from_project: input.assigned_from_project ?? null,
26540
26571
  task_type: input.task_type ?? null,
26541
26572
  cost_tokens: 0,
@@ -26572,7 +26603,8 @@ async function updateTask2(id, input, store) {
26572
26603
  tags: input.tags ?? existing.tags,
26573
26604
  metadata: input.metadata ?? existing.metadata,
26574
26605
  requires_approval: input.requires_approval ?? existing.requires_approval,
26575
- task_list_id: input.task_list_id !== undefined ? input.task_list_id : existing.task_list_id
26606
+ task_list_id: input.task_list_id !== undefined ? input.task_list_id : existing.task_list_id,
26607
+ created_by: existing.created_by
26576
26608
  };
26577
26609
  await store.upsert("tasks", task2);
26578
26610
  return task2;
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Ambient creator identity.
3
+ *
4
+ * The defect this closes: `todos init <name>` registered an agent and printed
5
+ * "Use --agent <id> on future commands", but persisted that identity NOWHERE.
6
+ * Every later command therefore had to re-supply `--agent` by hand, and in
7
+ * practice nothing did — so `todos add` recorded who a task was FOR
8
+ * (`assigned_to`) and never who FILED it. Measured on project 931835c7:
9
+ * agent_id populated on 35/436 tasks, assigned_by on 0/436.
10
+ *
11
+ * Resolution order, most explicit first:
12
+ * 1. an explicit value (the `--agent` flag)
13
+ * 2. TODOS_AGENT_ID
14
+ * 3. HASNA_TODOS_AGENT_ID
15
+ * 4. the identity persisted by `todos init`
16
+ *
17
+ * Returns null when no identity can be established. Callers must treat null as
18
+ * "unattributable" and say so — never as "attributable to nobody in particular".
19
+ */
20
+ export interface PersistedIdentity {
21
+ agent_id: string;
22
+ agent_name?: string;
23
+ session_id?: string;
24
+ registered_at: string;
25
+ }
26
+ export type CreatorIdentitySource = "explicit" | "env" | "persisted" | "none";
27
+ export interface ResolvedCreatorIdentity {
28
+ agent_id: string | null;
29
+ source: CreatorIdentitySource;
30
+ }
31
+ export declare function identityFilePath(): string;
32
+ export declare function readPersistedIdentity(): PersistedIdentity | null;
33
+ export interface IdentityCollision {
34
+ /** The identity already on disk that a new `init` would have overwritten. */
35
+ existing: PersistedIdentity;
36
+ }
37
+ /**
38
+ * The file is keyed on $HOME, and this fleet runs many named agent sessions per
39
+ * station under one HOME. Two sessions each running `todos init` would silently
40
+ * leave the loser attributing its tasks to the winner — and a WRONG author is
41
+ * worse than a missing one, because a null is visibly absent while a name is
42
+ * simply believed. So a second, different identity is refused rather than
43
+ * clobbered; the per-session escape hatch is the TODOS_AGENT_ID environment
44
+ * variable, which outranks this file and cannot collide between processes.
45
+ */
46
+ export declare function detectIdentityCollision(agentId: string, agentName?: string): IdentityCollision | null;
47
+ /** Persist the identity established by `todos init` so later commands inherit it. */
48
+ export declare function persistIdentity(identity: {
49
+ agent_id: string;
50
+ agent_name?: string;
51
+ session_id?: string;
52
+ }): PersistedIdentity;
53
+ /** Drop the persisted identity — used by `todos release` so the seat does not leak into the next session. */
54
+ export declare function clearPersistedIdentity(): boolean;
55
+ /**
56
+ * Canonicalise exactly as `registerAgent` does (src/db/agents.ts: trim + lower-case).
57
+ *
58
+ * Without this the three sources disagree about the SAME agent: the persisted file
59
+ * returns the registered name, which is already lower-cased, while the flag and the
60
+ * environment variable were taken verbatim. An agent that registered with `todos init`
61
+ * in one session and `TODOS_AGENT_ID=Cassius` in another — both sanctioned, and the
62
+ * env var is the very escape hatch this module recommends for concurrent sessions —
63
+ * would file some tasks as "cassius" and others as "Cassius". The comparison is a SQL
64
+ * string inequality, so `not_created_by` would fail to exclude half of the agent's own
65
+ * filings and leak them back into its own inbox: exactly the self-noise the filter
66
+ * exists to remove.
67
+ */
68
+ export declare function canonicalAgentRef(value: string): string;
69
+ export declare function resolveCreatorIdentity(explicit?: string | null): ResolvedCreatorIdentity;
70
+ //# sourceMappingURL=creator-identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"creator-identity.d.ts","sourceRoot":"","sources":["../../src/lib/creator-identity.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,qBAAqB,GAAG,UAAU,GAAG,KAAK,GAAG,WAAW,GAAG,MAAM,CAAC;AAE9E,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,qBAAqB,CAAC;CAC/B;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,qBAAqB,IAAI,iBAAiB,GAAG,IAAI,CAMhE;AAED,MAAM,WAAW,iBAAiB;IAChC,6EAA6E;IAC7E,QAA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