agent-afk 5.296.7 → 5.296.9

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.
@@ -0,0 +1,4 @@
1
+ export declare const DEAD_LETTER_SUBDIR = "dead-letter";
2
+ export declare const MAX_CLAIM_REREAD_FAILURES = 3;
3
+ export declare const claimRereadFailures: Map<string, number>;
4
+ export declare function deadLetterHandoffFile(handoffsDir: string, srcPath: string, displayName: string, reason: string): Promise<void>;
@@ -1,9 +1,3 @@
1
- import type { JournalBlock } from './types.js';
2
- type ToolResultBlock = Extract<JournalBlock, {
3
- type: 'tool_result';
4
- }>;
5
- export declare function findToolResultAsync(sessionId: string, toolUseId: string): Promise<{
6
- block: ToolResultBlock;
7
- subagentId?: string;
8
- } | null>;
9
- export {};
1
+ import type { ToolResultLookup } from './types.js';
2
+ export type { ToolResultLookup } from './types.js';
3
+ export declare function findToolResultAsync(sessionId: string, toolUseId: string): Promise<ToolResultLookup | null>;
@@ -1,4 +1,4 @@
1
- import type { JournalBlock, JournalMessage, JournalRecord } from './types.js';
1
+ import type { JournalMessage, JournalRecord, ToolResultLookup } from './types.js';
2
2
  export interface JournalLocator {
3
3
  subagentId?: string;
4
4
  }
@@ -15,10 +15,5 @@ export declare function foldJournal(records: readonly JournalRecord[]): FoldResu
15
15
  export declare function loadJournalFold(sessionId: string, loc?: JournalLocator): FoldResult | null;
16
16
  export declare function hydrateMessages(messages: readonly JournalMessage[]): JournalMessage[];
17
17
  export declare function loadJournalMessages(sessionId: string, loc?: JournalLocator): JournalMessage[] | null;
18
- export declare function findToolResult(sessionId: string, toolUseId: string): {
19
- block: Extract<JournalBlock, {
20
- type: 'tool_result';
21
- }>;
22
- subagentId?: string;
23
- } | null;
18
+ export declare function findToolResult(sessionId: string, toolUseId: string): ToolResultLookup | null;
24
19
  export declare function listSubagentJournals(sessionId: string): string[];
@@ -66,6 +66,12 @@ export type JournalBlock = {
66
66
  source: JournalBinary;
67
67
  title?: string;
68
68
  };
69
+ export interface ToolResultLookup {
70
+ block: Extract<JournalBlock, {
71
+ type: 'tool_result';
72
+ }>;
73
+ subagentId?: string;
74
+ }
69
75
  export interface JournalMessage {
70
76
  role: 'user' | 'assistant';
71
77
  content: JournalBlock[];
@@ -12,7 +12,6 @@ export declare class MemoryStore {
12
12
  private readonly dir;
13
13
  private readonly db;
14
14
  constructor(memoryDir?: string);
15
- private enableWalMode;
16
15
  loadHot(): string | null;
17
16
  saveHot(content: string): HotUsage;
18
17
  hotUsage(): HotUsage;
@@ -34,5 +33,4 @@ export declare class MemoryStore {
34
33
  search(query: string, opts?: SearchOpts): MemorySearchResult[];
35
34
  replayWAL(): number;
36
35
  close(): void;
37
- private appendWAL;
38
36
  }
@@ -0,0 +1,2 @@
1
+ import type BetterSqlite3 from 'better-sqlite3';
2
+ export declare function supersedeFact(db: BetterSqlite3.Database, dir: string, factId: number, newContent: string, category?: string, evidence?: string | null): number;
@@ -0,0 +1,6 @@
1
+ import type { Procedure } from './types.js';
2
+ export declare const PROCEDURES_DIR = "procedures";
3
+ export declare function validateProcedureName(name: string): string;
4
+ export declare function writeProcedure(dir: string, name: string, content: string, sessionId?: string): void;
5
+ export declare function loadProcedure(dir: string, name: string): Procedure | null;
6
+ export declare function searchProcedures(dir: string, query: string): Procedure[];
@@ -0,0 +1,6 @@
1
+ import type BetterSqlite3 from 'better-sqlite3';
2
+ export declare const SCHEMA_VERSION = 4;
3
+ export declare const SCHEMA_SQL = "\nCREATE TABLE IF NOT EXISTS sessions (\n session_id TEXT PRIMARY KEY,\n surface TEXT NOT NULL,\n started_at TEXT NOT NULL,\n ended_at TEXT,\n summary TEXT,\n tools_used TEXT NOT NULL DEFAULT '[]',\n outcome TEXT,\n token_count INTEGER,\n cost_usd REAL,\n -- v3: execution role 'main' | 'subagent'. Nullable (NULL on pre-v3 rows).\n -- Listed last to match the position ALTER TABLE ADD COLUMN appends it on\n -- migrated databases, so fresh and migrated DBs share one column order.\n actor TEXT\n);\n\nCREATE TABLE IF NOT EXISTS facts (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n session_id TEXT,\n created_at TEXT NOT NULL,\n category TEXT NOT NULL CHECK(category IN ('preference', 'convention', 'decision', 'learning')),\n content TEXT NOT NULL,\n source_surface TEXT NOT NULL DEFAULT 'cli',\n superseded_by INTEGER REFERENCES facts(id),\n confidence REAL NOT NULL DEFAULT 1.0,\n access_count INTEGER NOT NULL DEFAULT 0,\n last_accessed TEXT,\n -- v4: provenance citation backing a codebase fact (file:line, commit SHA,\n -- trace-event id). Nullable (NULL on pre-v4 rows and uncited writes).\n -- Listed last to match the position ALTER TABLE ADD COLUMN appends it on\n -- migrated databases, so fresh and migrated DBs share one column order.\n evidence TEXT\n);\n\nCREATE VIRTUAL TABLE IF NOT EXISTS facts_fts USING fts5(\n content,\n category,\n content=facts,\n content_rowid=id,\n tokenize='porter'\n);\n\nCREATE TRIGGER IF NOT EXISTS facts_ai AFTER INSERT ON facts BEGIN\n INSERT INTO facts_fts(rowid, content, category) VALUES (new.id, new.content, new.category);\nEND;\n\nCREATE TRIGGER IF NOT EXISTS facts_ad AFTER DELETE ON facts BEGIN\n INSERT INTO facts_fts(facts_fts, rowid, content, category) VALUES ('delete', old.id, old.content, old.category);\nEND;\n\nCREATE TRIGGER IF NOT EXISTS facts_au AFTER UPDATE ON facts BEGIN\n INSERT INTO facts_fts(facts_fts, rowid, content, category) VALUES ('delete', old.id, old.content, old.category);\n INSERT INTO facts_fts(rowid, content, category) VALUES (new.id, new.content, new.category);\nEND;\n\nCREATE INDEX IF NOT EXISTS idx_sessions_started_at ON sessions(started_at DESC);\nCREATE INDEX IF NOT EXISTS idx_facts_session_id ON facts(session_id);\n\n-- v2: Fingerprint uniqueness for WAL replay. The four-field key (content,\n-- created_at, session_id, category) is the stable identity used by supersede\n-- WAL entries to locate rows across crash+restart cycles. Without a UNIQUE\n-- constraint, same-ms duplicate inserts make .get() return an arbitrary row.\n-- NULL session_id is coerced to the empty string so it participates in the\n-- uniqueness check (SQLite treats NULLs as distinct in UNIQUE indexes).\nCREATE UNIQUE INDEX IF NOT EXISTS idx_facts_fingerprint\n ON facts(content, created_at, COALESCE(session_id, ''), category);\n";
4
+ export declare function runMigrations(db: BetterSqlite3.Database, existingVersion: number): void;
5
+ export declare function enableWalMode(db: BetterSqlite3.Database): void;
6
+ export declare function sleepSync(ms: number): void;
@@ -0,0 +1,5 @@
1
+ import type BetterSqlite3 from 'better-sqlite3';
2
+ import type { WALEntry } from './types.js';
3
+ export declare function isValidWALEntry(entry: unknown): entry is WALEntry;
4
+ export declare function appendWAL(dir: string, entry: WALEntry): void;
5
+ export declare function replayWAL(db: BetterSqlite3.Database, dir: string): number;
@@ -0,0 +1,23 @@
1
+ import type { FactCategory, MemoryUpdateAction, MemoryUpdateTarget } from './types.js';
2
+ export interface MemorySearchInput {
3
+ query: string;
4
+ category?: FactCategory;
5
+ since?: string;
6
+ limit?: number;
7
+ }
8
+ export declare function parseMemorySearchInput(input: unknown): MemorySearchInput;
9
+ export interface MemoryUpdateInput {
10
+ target: MemoryUpdateTarget;
11
+ action: MemoryUpdateAction;
12
+ content?: string;
13
+ category?: FactCategory;
14
+ evidence?: string;
15
+ supersedes?: number;
16
+ id?: number;
17
+ }
18
+ export declare function parseMemoryUpdateInput(input: unknown): MemoryUpdateInput;
19
+ export interface ProcedureWriteInput {
20
+ name: string;
21
+ content: string;
22
+ }
23
+ export declare function parseProcedureWriteInput(input: unknown): ProcedureWriteInput;