agent-afk 5.302.7 → 5.302.8
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/agent/awareness/presence.d.ts +2 -5
- package/dist/agent/background-summarizer.d.ts +3 -0
- package/dist/agent/journal/index.d.ts +1 -1
- package/dist/agent/journal/reader.async.d.ts +1 -0
- package/dist/agent/memory/memory-store.schema.d.ts +0 -1
- package/dist/agent/providers/anthropic-direct/overload-pause.d.ts +1 -7
- package/dist/agent/providers/shared/compaction.d.ts +1 -0
- package/dist/agent/providers/shared/overload-pause-shared.d.ts +7 -0
- package/dist/agent/providers/shared/transient-retry.d.ts +1 -0
- package/dist/agent/providers/shared/transient-retry.trace.d.ts +1 -0
- package/dist/agent/trace/events.d.ts +2 -0
- package/dist/agent/trace/events.session-phase.d.ts +2 -0
- package/dist/agent/trace/types.session-phase.d.ts +1 -1
- package/dist/cli/commands/interactive/loop-iteration.injections.d.ts +3 -1
- package/dist/cli.mjs +341 -339
- package/dist/index.mjs +141 -139
- package/dist/telegram.mjs +165 -163
- package/dist/utils/atomic-write.d.ts +1 -1
- package/dist/utils/sleep-sync.d.ts +1 -0
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import type { RuntimeWorkspace } from './types.js';
|
|
|
2
2
|
import type { TraceActor } from '../session/session-identity.js';
|
|
3
3
|
import { type ProcessLiveness } from '../process-liveness.js';
|
|
4
4
|
import { type StartTimeProbe } from './presence.liveness.js';
|
|
5
|
+
import type { PresenceActivity } from './presence.activity.js';
|
|
5
6
|
export declare const PRESENCE_SCHEMA_VERSION = 1;
|
|
6
7
|
export interface PresenceFileInfo {
|
|
7
8
|
sessionId: string;
|
|
@@ -25,11 +26,7 @@ export interface PresenceFileInfo {
|
|
|
25
26
|
turnState?: 'idle' | 'busy' | 'blocked';
|
|
26
27
|
turnStateSince?: string;
|
|
27
28
|
peerInbox?: boolean;
|
|
28
|
-
activity?:
|
|
29
|
-
promptHead?: string;
|
|
30
|
-
turns: number;
|
|
31
|
-
lastTurnEndedAt?: string;
|
|
32
|
-
};
|
|
29
|
+
activity?: PresenceActivity;
|
|
33
30
|
}
|
|
34
31
|
export type PresenceLiveness = ProcessLiveness;
|
|
35
32
|
export interface PresenceRecord extends PresenceFileInfo {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BackgroundAgentRegistry } from './background-registry.js';
|
|
2
2
|
import { redactSecrets } from './redact-secrets.js';
|
|
3
|
+
import type { TraceSink } from './trace/index.js';
|
|
3
4
|
export interface SummaryEntry {
|
|
4
5
|
text: string;
|
|
5
6
|
refreshedAt: number;
|
|
@@ -13,6 +14,7 @@ export interface BackgroundSummarizerOptions {
|
|
|
13
14
|
maxInputTokens?: number;
|
|
14
15
|
maxOutputTokens?: number;
|
|
15
16
|
maxCallsPerSession?: number;
|
|
17
|
+
traceWriter?: TraceSink;
|
|
16
18
|
callLLM?: (prompt: string, signal?: AbortSignal) => Promise<string>;
|
|
17
19
|
getTranscript?: (jobId: string) => string | undefined;
|
|
18
20
|
}
|
|
@@ -27,6 +29,7 @@ export declare class BackgroundSummarizer {
|
|
|
27
29
|
private readonly maxCallsPerSession;
|
|
28
30
|
private readonly callLLM;
|
|
29
31
|
private readonly getTranscriptFn;
|
|
32
|
+
private readonly traceWriter;
|
|
30
33
|
private readonly summaries;
|
|
31
34
|
private readonly jobIndexMap;
|
|
32
35
|
private jobIndexCounter;
|
|
@@ -3,7 +3,7 @@ export { JournalSync, type SyncOptions } from './sync.js';
|
|
|
3
3
|
export { JournalProvenance } from './provenance.js';
|
|
4
4
|
export { createMessageJournal, isMessageJournalDisabled, type CreateMessageJournalOptions } from './writer.js';
|
|
5
5
|
export { findToolResult, foldJournal, hydrateMessages, journalExists, listSubagentJournals, loadJournalFold, loadJournalMessages, readJournalRecords, type FoldResult, type JournalLocator, } from './reader.js';
|
|
6
|
-
export { findToolResultAsync } from './reader.async.js';
|
|
6
|
+
export { findToolResultAsync, journalExistsAsync } from './reader.async.js';
|
|
7
7
|
export { forkJournal } from './fork.js';
|
|
8
8
|
export { foldForDisplay, loadDisplayMessages } from './display-fold.js';
|
|
9
9
|
export { pickResultFlags, readResultFlags, tagResultFlags, type JournalResultFlags } from './result-flags.js';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { ToolResultLookup } from './types.js';
|
|
2
2
|
export type { ToolResultLookup } from './types.js';
|
|
3
|
+
export declare function journalExistsAsync(sessionId: string): Promise<boolean>;
|
|
3
4
|
export declare function findToolResultAsync(sessionId: string, toolUseId: string): Promise<ToolResultLookup | null>;
|
|
@@ -3,4 +3,3 @@ export declare const SCHEMA_VERSION = 4;
|
|
|
3
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
4
|
export declare function runMigrations(db: BetterSqlite3.Database, existingVersion: number): void;
|
|
5
5
|
export declare function enableWalMode(db: BetterSqlite3.Database): void;
|
|
6
|
-
export declare function sleepSync(ms: number): void;
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import type { ProviderEvent } from '../../provider.js';
|
|
2
2
|
export { OVERLOAD_EXHAUSTED } from '../shared/overload-sentinel.js';
|
|
3
|
+
export { OVERLOAD_PAUSE_CEILING_MS, OVERLOAD_PAUSE_MAX_MS, OVERLOAD_PROBE_MIN_MS, OVERLOAD_PROBE_MAX_MS, jitterBackoff, nextProbeDelayMs, resolveOverloadPauseCeilingMs, } from '../shared/overload-pause-shared.js';
|
|
3
4
|
export declare const OVERLOAD_EXHAUSTED_NOTICE: string;
|
|
4
|
-
export declare const OVERLOAD_PAUSE_CEILING_MS: number;
|
|
5
|
-
export declare const OVERLOAD_PAUSE_MAX_MS: number;
|
|
6
|
-
export declare const OVERLOAD_PROBE_MIN_MS: number;
|
|
7
|
-
export declare const OVERLOAD_PROBE_MAX_MS: number;
|
|
8
|
-
export declare function jitterBackoff(baseMs: number, random?: () => number): number;
|
|
9
|
-
export declare function nextProbeDelayMs(random?: () => number): number;
|
|
10
5
|
export declare function classifyOverloadExhaustion(event: ProviderEvent): boolean;
|
|
11
|
-
export declare function resolveOverloadPauseCeilingMs(surface: string | undefined): number;
|
|
@@ -72,6 +72,7 @@ export interface CompactionCoreDeps<M> {
|
|
|
72
72
|
timeoutMs?: number;
|
|
73
73
|
onSuccess?(info: CompactionSuccess<M>): void;
|
|
74
74
|
onRetry?(info: RetryInfo): void;
|
|
75
|
+
onExhausted?(info: RetryInfo): void;
|
|
75
76
|
retrySleep?: (ms: number, signal: AbortSignal) => Promise<void>;
|
|
76
77
|
signal?: AbortSignal;
|
|
77
78
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const OVERLOAD_PAUSE_CEILING_MS: number;
|
|
2
|
+
export declare const OVERLOAD_PAUSE_MAX_MS: number;
|
|
3
|
+
export declare const OVERLOAD_PROBE_MIN_MS: number;
|
|
4
|
+
export declare const OVERLOAD_PROBE_MAX_MS: number;
|
|
5
|
+
export declare function jitterBackoff(baseMs: number, random?: () => number): number;
|
|
6
|
+
export declare function nextProbeDelayMs(random?: () => number): number;
|
|
7
|
+
export declare function resolveOverloadPauseCeilingMs(surface: string | undefined): number;
|
|
@@ -13,6 +13,7 @@ export interface TransientRetryOpts {
|
|
|
13
13
|
shouldStop?: () => boolean;
|
|
14
14
|
signal?: AbortSignal;
|
|
15
15
|
onRetry?: (info: RetryInfo) => void;
|
|
16
|
+
onExhausted?: (info: RetryInfo) => void;
|
|
16
17
|
sleep?: (ms: number, signal: AbortSignal) => Promise<void>;
|
|
17
18
|
}
|
|
18
19
|
export declare function withTransientRetry<T>(attempt: () => Promise<T>, opts?: TransientRetryOpts): Promise<T>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { TraceSink } from '../../trace/index.js';
|
|
2
2
|
import type { RetryInfo } from './transient-retry.js';
|
|
3
3
|
export declare function traceTransientRetry(traceWriter: TraceSink | undefined, source: string, maxRetries: number): (info: RetryInfo) => void;
|
|
4
|
+
export declare function traceExhaustedRetry(traceWriter: TraceSink | undefined, source: string, maxRetries: number): (info: RetryInfo) => void;
|
|
@@ -632,6 +632,7 @@ export declare const TraceEventInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
632
632
|
many_image_degraded: "many_image_degraded";
|
|
633
633
|
stream_accepted_after_drop: "stream_accepted_after_drop";
|
|
634
634
|
connection_retry: "connection_retry";
|
|
635
|
+
connection_retry_exhausted: "connection_retry_exhausted";
|
|
635
636
|
usage_notice: "usage_notice";
|
|
636
637
|
tool_degraded: "tool_degraded";
|
|
637
638
|
strategy_nudge_fired: "strategy_nudge_fired";
|
|
@@ -1044,6 +1045,7 @@ export declare const TraceEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1044
1045
|
many_image_degraded: "many_image_degraded";
|
|
1045
1046
|
stream_accepted_after_drop: "stream_accepted_after_drop";
|
|
1046
1047
|
connection_retry: "connection_retry";
|
|
1048
|
+
connection_retry_exhausted: "connection_retry_exhausted";
|
|
1047
1049
|
usage_notice: "usage_notice";
|
|
1048
1050
|
tool_degraded: "tool_degraded";
|
|
1049
1051
|
strategy_nudge_fired: "strategy_nudge_fired";
|
|
@@ -30,6 +30,7 @@ export declare const SessionPhaseNameSchema: z.ZodEnum<{
|
|
|
30
30
|
many_image_degraded: "many_image_degraded";
|
|
31
31
|
stream_accepted_after_drop: "stream_accepted_after_drop";
|
|
32
32
|
connection_retry: "connection_retry";
|
|
33
|
+
connection_retry_exhausted: "connection_retry_exhausted";
|
|
33
34
|
usage_notice: "usage_notice";
|
|
34
35
|
tool_degraded: "tool_degraded";
|
|
35
36
|
strategy_nudge_fired: "strategy_nudge_fired";
|
|
@@ -72,6 +73,7 @@ export declare const SessionPhasePayloadSchema: z.ZodObject<{
|
|
|
72
73
|
many_image_degraded: "many_image_degraded";
|
|
73
74
|
stream_accepted_after_drop: "stream_accepted_after_drop";
|
|
74
75
|
connection_retry: "connection_retry";
|
|
76
|
+
connection_retry_exhausted: "connection_retry_exhausted";
|
|
75
77
|
usage_notice: "usage_notice";
|
|
76
78
|
tool_degraded: "tool_degraded";
|
|
77
79
|
strategy_nudge_fired: "strategy_nudge_fired";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type SessionPhaseName = 'bootstrap_start' | 'bootstrap_done' | 'session_init_start' | 'session_init_done' | 'mcp_connect_start' | 'mcp_connect_done' | 'mcp_server_start' | 'mcp_server_done' | 'loop_start' | 'loop_end' | 'model_ttfb' | 'interrupt_halt' | 'rate_limit' | 'ttfb_timeout' | 'usage_limit_pause' | 'usage_limit_resume' | 'overload_pause' | 'overload_resume' | 'idle_watchdog_fired' | 'pause_extension_granted' | 'suspected_loop' | 'compaction_disabled' | 'boot_warning' | 'workspace_subscribed' | 'workspace_delivery' | 'gate_shape' | 'session_id_assigned' | 'many_image_degraded' | 'stream_accepted_after_drop' | 'connection_retry' | 'usage_notice' | 'tool_degraded' | 'strategy_nudge_fired' | 'stop_inject_dropped' | 'stop_hook_continuation' | 'stop_hook_cap_reached' | 'orphan_repair' | 'background_process_started' | 'background_process_settled';
|
|
1
|
+
export type SessionPhaseName = 'bootstrap_start' | 'bootstrap_done' | 'session_init_start' | 'session_init_done' | 'mcp_connect_start' | 'mcp_connect_done' | 'mcp_server_start' | 'mcp_server_done' | 'loop_start' | 'loop_end' | 'model_ttfb' | 'interrupt_halt' | 'rate_limit' | 'ttfb_timeout' | 'usage_limit_pause' | 'usage_limit_resume' | 'overload_pause' | 'overload_resume' | 'idle_watchdog_fired' | 'pause_extension_granted' | 'suspected_loop' | 'compaction_disabled' | 'boot_warning' | 'workspace_subscribed' | 'workspace_delivery' | 'gate_shape' | 'session_id_assigned' | 'many_image_degraded' | 'stream_accepted_after_drop' | 'connection_retry' | 'connection_retry_exhausted' | 'usage_notice' | 'tool_degraded' | 'strategy_nudge_fired' | 'stop_inject_dropped' | 'stop_hook_continuation' | 'stop_hook_cap_reached' | 'orphan_repair' | 'background_process_started' | 'background_process_settled';
|
|
2
2
|
export interface SessionPhasePayload {
|
|
3
3
|
phase: SessionPhaseName;
|
|
4
4
|
durationMs?: number;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export declare function autoResumeDirective(bgResultPending: boolean): string;
|
|
2
|
+
export declare const AUTO_RESUME_PREFIX = "[auto-resume]";
|
|
2
3
|
export interface InjectionSource {
|
|
3
4
|
drainInjections(): string;
|
|
4
5
|
}
|
|
5
6
|
export declare function prependTurnInjections(runText: string, sources: readonly InjectionSource[]): string;
|
|
6
|
-
export declare function markPresenceTurn(sessionId: string | undefined, state: '
|
|
7
|
+
export declare function markPresenceTurn(sessionId: string | undefined, state: 'busy', rawUserText?: string): void;
|
|
8
|
+
export declare function markPresenceTurn(sessionId: string | undefined, state: 'idle', rawUserText: string | undefined, totalTurns: number): void;
|