agent-afk 5.307.13 → 5.308.0
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 +1 -1
- package/dist/agent/awareness/index.d.ts +1 -1
- package/dist/agent/awareness/runtime-snapshot.d.ts +5 -0
- package/dist/agent/awareness/types.d.ts +4 -0
- package/dist/agent/daemon/schedule-store.d.ts +2 -0
- package/dist/agent/daemon/scheduler.d.ts +3 -0
- package/dist/agent/daemon/scheduler.execute-agent-task.d.ts +3 -0
- package/dist/agent/daemon/task-retry.d.ts +41 -0
- package/dist/agent/daemon/triggers.d.ts +2 -0
- package/dist/agent/plugins/tool-injector.d.ts +2 -0
- package/dist/agent/provider.d.ts +2 -0
- package/dist/agent/providers/anthropic-direct/cache-policy.d.ts +3 -4
- package/dist/agent/providers/anthropic-direct/loop/tool-results.d.ts +1 -1
- package/dist/agent/providers/anthropic-direct/query/live-client.d.ts +6 -0
- package/dist/agent/providers/anthropic-direct/query/retry-context.d.ts +1 -0
- package/dist/agent/providers/anthropic-direct/query/usage-limit-catch-up.d.ts +3 -0
- package/dist/agent/providers/anthropic-direct/query/usage-limit-pause.d.ts +2 -1
- package/dist/agent/providers/openai-compatible/query/dispatch-append.d.ts +2 -1
- package/dist/agent/providers/shared/transient-retry.d.ts +1 -0
- package/dist/agent/providers/shared/vitals.d.ts +24 -0
- package/dist/agent/tools/skill-bridge.d.ts +2 -0
- package/dist/cli/slash/_lib/flag-harvest.d.ts +1 -9
- package/dist/cli/slash/plugin-skills/state.d.ts +1 -0
- package/dist/cli.mjs +384 -382
- package/dist/config/env.browser.d.ts +1 -0
- package/dist/config/env.d.ts +13 -1
- package/dist/config/env.daemon.d.ts +3 -1
- package/dist/config/env.mcp.d.ts +1 -0
- package/dist/config/env.vitals.d.ts +9 -0
- package/dist/index.mjs +168 -165
- package/dist/telegram.mjs +201 -198
- package/dist/utils/errors.d.ts +1 -0
- package/dist/utils/skill-md.d.ts +11 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ Open source. Runs locally. Works with any model provider, including local models
|
|
|
22
22
|
## Quick Start
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
|
-
npm install -g agent-afk # Node 22.22.2
|
|
25
|
+
npm install -g agent-afk # Node 22.22.2–22.x, 24.15–24.x, or 26+ (23.x and 25.x excluded)
|
|
26
26
|
afk login # authenticate (auto-detects Claude Code / Codex creds)
|
|
27
27
|
afk doctor # verify everything works
|
|
28
28
|
afk chat "hello" # first real conversation
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { Surface, PhaseRole, SubagentStatusLite, SubagentStatusLiteValue, BgJobLite, BgJobStatus, McpServerSummary, McpFailedServer, RuntimeSelf, RuntimeTools, RuntimeSubagents, RuntimeWorkspace, RuntimeSnapshot, RuntimeView, RuntimeStateSource, } from './types.js';
|
|
2
|
-
export { buildRuntimeSnapshot, parseView, formatEnvironmentFragment, formatEnvironmentDateLine, } from './runtime-snapshot.js';
|
|
2
|
+
export { buildRuntimeSnapshot, parseView, formatEnvironmentFragment, formatEnvironmentDateLine, formatClock, snapshotClock, } from './runtime-snapshot.js';
|
|
3
3
|
export { buildRuntimeStateSource, type RuntimeSourceDeps, } from './runtime-source.js';
|
|
4
4
|
export { getRuntimeStateTool, AWARENESS_TOOL_NAMES, createGetRuntimeStateHandler, wrapDispatcherWithRuntimeState, } from './tool.js';
|
|
5
5
|
export { gatherWorkspace } from './workspace-source.js';
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { RuntimeStateSource, RuntimeSnapshot, RuntimeView, RuntimeWorkspace } from './types.js';
|
|
2
2
|
export declare function buildRuntimeSnapshot(source: RuntimeStateSource, view?: RuntimeView): Partial<RuntimeSnapshot>;
|
|
3
|
+
export declare function snapshotClock(epochMs: number): {
|
|
4
|
+
iso: string;
|
|
5
|
+
local: string;
|
|
6
|
+
};
|
|
3
7
|
export declare function parseView(raw: unknown): RuntimeView;
|
|
4
8
|
export declare function formatEnvironmentFragment(args: {
|
|
5
9
|
cwd: string;
|
|
@@ -12,3 +16,4 @@ export declare function formatEnvironmentFragment(args: {
|
|
|
12
16
|
timeZone?: string;
|
|
13
17
|
}): string;
|
|
14
18
|
export declare function formatEnvironmentDateLine(now: Date, timeZone?: string): string;
|
|
19
|
+
export declare function formatClock(epochMs: number, timeZone?: string): string;
|
|
@@ -59,6 +59,10 @@ export interface RuntimeSnapshot {
|
|
|
59
59
|
subagents: RuntimeSubagents;
|
|
60
60
|
workspace: RuntimeWorkspace;
|
|
61
61
|
usage?: RuntimeUsageEntry[];
|
|
62
|
+
clock?: {
|
|
63
|
+
iso: string;
|
|
64
|
+
local: string;
|
|
65
|
+
};
|
|
62
66
|
subagentOutcomeSummary?: SubagentOutcomeSummaryEntry[];
|
|
63
67
|
}
|
|
64
68
|
export type { SubagentOutcomeSummaryEntry } from '../../insights/aggregators/subagent-outcomes.js';
|
|
@@ -26,6 +26,7 @@ export interface SchedulerOptions {
|
|
|
26
26
|
primaryChatId?: number;
|
|
27
27
|
primaryThreadId?: number;
|
|
28
28
|
budgetGate?: () => Promise<import('./budget-gate.js').BudgetGateResult>;
|
|
29
|
+
retrySleep?: (ms: number, signal: AbortSignal) => Promise<void>;
|
|
29
30
|
}
|
|
30
31
|
export type TelemetryTrigger = 'cron' | 'sessionstart' | 'pull';
|
|
31
32
|
type TelemetryStatus = 'success' | 'error' | 'skipped';
|
|
@@ -42,6 +43,7 @@ export interface TelemetryRecord {
|
|
|
42
43
|
skipReason?: SessionStartSkipReason;
|
|
43
44
|
name?: string;
|
|
44
45
|
doneUnverified?: boolean;
|
|
46
|
+
attempts?: number;
|
|
45
47
|
}
|
|
46
48
|
export interface TaskCompletionDetails {
|
|
47
49
|
responseText?: string;
|
|
@@ -61,6 +63,7 @@ export declare class CronScheduler {
|
|
|
61
63
|
private readonly budgetAlerts;
|
|
62
64
|
private readonly overlapAlerts;
|
|
63
65
|
private readonly telemetryAlerts;
|
|
66
|
+
private shutdownController;
|
|
64
67
|
constructor(options?: SchedulerOptions);
|
|
65
68
|
register(task: ScheduledTask): void;
|
|
66
69
|
unregister(taskId: string): void;
|
|
@@ -37,6 +37,9 @@ export interface AgentTaskContext {
|
|
|
37
37
|
dispose: () => void;
|
|
38
38
|
}>;
|
|
39
39
|
writeTelemetry: (record: TelemetryRecord, task: ScheduledTask, details?: TaskCompletionDetails) => void;
|
|
40
|
+
shutdownSignal?: AbortSignal;
|
|
41
|
+
isCancelled?: () => boolean;
|
|
42
|
+
retrySleep?: (ms: number, signal: AbortSignal) => Promise<void>;
|
|
40
43
|
}
|
|
41
44
|
export declare function executeAgentTask(ctx: AgentTaskContext, task: ScheduledTask, trigger: TelemetryTrigger): Promise<TelemetryRecord>;
|
|
42
45
|
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export declare const TASK_MAX_ATTEMPTS_LIMIT = 5;
|
|
2
|
+
export declare const TASK_RETRY_DELAY_MIN_MS = 1000;
|
|
3
|
+
export declare const TASK_RETRY_DELAY_MAX_MS: number;
|
|
4
|
+
export declare const DEFAULT_TASK_RETRY_DELAY_MS: number;
|
|
5
|
+
export interface TaskRetryFields {
|
|
6
|
+
maxAttempts?: number;
|
|
7
|
+
retryDelayMs?: number;
|
|
8
|
+
}
|
|
9
|
+
export type ParseTaskRetryResult = {
|
|
10
|
+
ok: true;
|
|
11
|
+
value: TaskRetryFields;
|
|
12
|
+
} | {
|
|
13
|
+
ok: false;
|
|
14
|
+
error: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function parseTaskRetryFields(obj: Record<string, unknown>): ParseTaskRetryResult;
|
|
17
|
+
export interface ResolvedTaskRetry {
|
|
18
|
+
maxAttempts: number;
|
|
19
|
+
retryDelayMs: number;
|
|
20
|
+
}
|
|
21
|
+
export declare function resolveTaskRetryPolicy(task: TaskRetryFields): ResolvedTaskRetry;
|
|
22
|
+
export interface TaskRetryRunOptions extends ResolvedTaskRetry {
|
|
23
|
+
signal: AbortSignal;
|
|
24
|
+
isCancelled?: () => boolean;
|
|
25
|
+
sleep?: (ms: number, signal: AbortSignal) => Promise<void>;
|
|
26
|
+
onRetry?: (info: {
|
|
27
|
+
attempt: number;
|
|
28
|
+
error: unknown;
|
|
29
|
+
delayMs: number;
|
|
30
|
+
}) => void;
|
|
31
|
+
}
|
|
32
|
+
export type TaskRetryOutcome<T> = {
|
|
33
|
+
ok: true;
|
|
34
|
+
value: T;
|
|
35
|
+
attempts: number;
|
|
36
|
+
} | {
|
|
37
|
+
ok: false;
|
|
38
|
+
error: unknown;
|
|
39
|
+
attempts: number;
|
|
40
|
+
};
|
|
41
|
+
export declare function runWithTaskRetry<T>(attempt: (attemptNumber: number) => Promise<T>, opts: TaskRetryRunOptions): Promise<TaskRetryOutcome<T>>;
|
package/dist/agent/provider.d.ts
CHANGED
|
@@ -197,6 +197,8 @@ export interface ProviderCommandInfo {
|
|
|
197
197
|
description?: string;
|
|
198
198
|
argumentHint?: string;
|
|
199
199
|
whenToUse?: string;
|
|
200
|
+
flags?: readonly string[];
|
|
201
|
+
category?: string;
|
|
200
202
|
source?: 'builtin' | 'user' | 'project' | 'plugin' | 'imported' | 'command';
|
|
201
203
|
}
|
|
202
204
|
export interface ProviderModelInfo {
|
|
@@ -19,14 +19,13 @@ export interface CacheableToolLike {
|
|
|
19
19
|
cache_control?: {
|
|
20
20
|
type: string;
|
|
21
21
|
} | null;
|
|
22
|
-
[k: string]: unknown;
|
|
23
22
|
}
|
|
24
|
-
export declare function clampBreakpoints(params: {
|
|
23
|
+
export declare function clampBreakpoints<T extends CacheableToolLike>(params: {
|
|
25
24
|
system?: readonly ContentBlockParam[];
|
|
26
|
-
tools?: readonly
|
|
25
|
+
tools?: readonly T[];
|
|
27
26
|
messages: readonly MessageParam[];
|
|
28
27
|
}): {
|
|
29
28
|
system?: readonly ContentBlockParam[];
|
|
30
|
-
tools?: readonly
|
|
29
|
+
tools?: readonly T[];
|
|
31
30
|
messages: readonly MessageParam[];
|
|
32
31
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ProviderEvent } from '../../../provider.js';
|
|
2
2
|
import type { RunTurnInput, ToolCall, ToolResult } from '../types.js';
|
|
3
3
|
export type ToolResultsOutcome = 'committed' | 'denial-tripped';
|
|
4
|
-
export declare function emitAndCommitToolResults(calls: ToolCall[], results: ToolResult[], startTimes: Map<string, number>, input: RunTurnInput): AsyncGenerator<ProviderEvent, ToolResultsOutcome, void>;
|
|
4
|
+
export declare function emitAndCommitToolResults(calls: ToolCall[], results: ToolResult[], startTimes: Map<string, number>, input: RunTurnInput, vitalsNote?: string): AsyncGenerator<ProviderEvent, ToolResultsOutcome, void>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RunTurnInput } from '../types.js';
|
|
2
|
+
import type { RetryTierContext } from './retry-context.js';
|
|
3
|
+
type RefreshResult = Awaited<ReturnType<RetryTierContext['forceClientRefresh']>>;
|
|
4
|
+
export declare function adoptFreshClient(ctx: Pick<RetryTierContext, 'forceClientRefresh' | 'getClient' | 'rotateHeaders'>, runInput: RunTurnInput): Promise<RefreshResult>;
|
|
5
|
+
export declare function liveAccountId(ctx: Pick<RetryTierContext, 'getClientToken'>): string;
|
|
6
|
+
export {};
|
|
@@ -9,6 +9,7 @@ export interface RetryTierContext {
|
|
|
9
9
|
readonly autoResumeOnUsageLimit: boolean;
|
|
10
10
|
readonly tokenRefresher: (() => Promise<Anthropic | null>) | undefined;
|
|
11
11
|
getClient(): Anthropic;
|
|
12
|
+
getClientToken(): string | undefined;
|
|
12
13
|
rotateHeaders(runInput: Pick<RunTurnInput, 'effort' | 'fastMode'>): Record<string, string>;
|
|
13
14
|
forceClientRefresh(): Promise<{
|
|
14
15
|
accountId: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ProviderEvent } from '../../../provider.js';
|
|
2
2
|
import type { RunTurnInput } from '../types.js';
|
|
3
|
-
import type { RetryTierContext, TierGenerator } from './retry-context.js';
|
|
3
|
+
import type { RetryTierContext, TierGenerator, UsageLimitWaitResult } from './retry-context.js';
|
|
4
|
+
export declare function joinUsageLimitWait(shared: Promise<UsageLimitWaitResult>, signal: AbortSignal): Promise<UsageLimitWaitResult>;
|
|
4
5
|
export declare function usageLimitNoTimestampPause(ctx: RetryTierContext, runInput: RunTurnInput, isClosed: () => boolean, next: TierGenerator, pendingErrorEvent: ProviderEvent): AsyncGenerator<ProviderEvent, void, void>;
|
|
5
6
|
export declare function usageLimitResetPause(ctx: RetryTierContext, runInput: RunTurnInput, isClosed: () => boolean, next: TierGenerator, pendingErrorEvent: ProviderEvent, resetsAt: Date): AsyncGenerator<ProviderEvent, void, void>;
|
|
@@ -13,5 +13,6 @@ export interface DispatchAndAppendInput {
|
|
|
13
13
|
priorTurns: OpenAIMessage[];
|
|
14
14
|
sessionId: string;
|
|
15
15
|
subagentId?: string | undefined;
|
|
16
|
+
vitalsNote?: string | undefined;
|
|
16
17
|
}
|
|
17
|
-
export declare function dispatchAndAppendToolCalls({ state, signal, vision, toolDispatcher, traceWriter, priorTurns, sessionId, subagentId, }: DispatchAndAppendInput): AsyncGenerator<ProviderEvent, ToolResult | undefined>;
|
|
18
|
+
export declare function dispatchAndAppendToolCalls({ state, signal, vision, toolDispatcher, traceWriter, priorTurns, sessionId, subagentId, vitalsNote, }: DispatchAndAppendInput): AsyncGenerator<ProviderEvent, ToolResult | undefined>;
|
|
@@ -16,4 +16,5 @@ export interface TransientRetryOpts {
|
|
|
16
16
|
onExhausted?: (info: RetryInfo) => void;
|
|
17
17
|
sleep?: (ms: number, signal: AbortSignal) => Promise<void>;
|
|
18
18
|
}
|
|
19
|
+
export declare function isTransientError(err: unknown): boolean;
|
|
19
20
|
export declare function withTransientRetry<T>(attempt: () => Promise<T>, opts?: TransientRetryOpts): Promise<T>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { UsageRecord } from '../../usage/usage-record.js';
|
|
2
|
+
export declare const VITALS_PREFIX = "[vitals]";
|
|
3
|
+
export declare const CONTEXT_SHOW_PCT = 50;
|
|
4
|
+
export declare const USAGE_SHOW_PCT = 80;
|
|
5
|
+
export declare const HIGH_PCT = 90;
|
|
6
|
+
export declare const USAGE_CACHE_TTL_MS = 60000;
|
|
7
|
+
export interface VitalsInput {
|
|
8
|
+
readonly turnStartedAt: number;
|
|
9
|
+
readonly softDeadlineMs?: number | undefined;
|
|
10
|
+
readonly contextTokens?: number | undefined;
|
|
11
|
+
readonly model?: string | undefined;
|
|
12
|
+
readonly subagentId?: string | undefined;
|
|
13
|
+
readonly claudeUsage?: boolean | undefined;
|
|
14
|
+
}
|
|
15
|
+
export interface VitalsDeps {
|
|
16
|
+
readonly now?: () => number;
|
|
17
|
+
readonly timeZone?: string;
|
|
18
|
+
readonly readClaudeUsage?: () => UsageRecord | undefined;
|
|
19
|
+
readonly contextLimit?: (model: string) => number;
|
|
20
|
+
}
|
|
21
|
+
export declare function vitalsEnabled(): boolean;
|
|
22
|
+
export declare function buildVitalsNote(input: VitalsInput, deps?: VitalsDeps): string | undefined;
|
|
23
|
+
export declare function resetVitalsUsageCacheForTests(): void;
|
|
24
|
+
export declare function formatDuration(ms: number, seconds?: boolean): string;
|
|
@@ -7,6 +7,8 @@ export interface SkillManifestEntry {
|
|
|
7
7
|
source: 'builtin' | 'user' | 'project' | 'plugin' | 'imported' | 'command';
|
|
8
8
|
argumentHint?: string;
|
|
9
9
|
whenToUse?: string;
|
|
10
|
+
flags?: readonly string[];
|
|
11
|
+
category?: string;
|
|
10
12
|
disableModelInvocation?: boolean;
|
|
11
13
|
}
|
|
12
14
|
export declare function buildSkillManifest(pluginConfigs?: SdkPluginConfig[], opts?: BuildSkillManifestOptions): string;
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export declare function extractFlagsFromBody(body: string): string[];
|
|
3
|
-
export interface ParsedSkillMd {
|
|
4
|
-
frontmatter: Record<string, string> | null;
|
|
5
|
-
frontmatterFlags: string[] | null;
|
|
6
|
-
body: string;
|
|
7
|
-
}
|
|
8
|
-
export declare function parseSkillMd(content: string): ParsedSkillMd;
|
|
9
|
-
export declare function harvestFlagsFromSkillMd(content: string): string[];
|
|
1
|
+
export { normalizeFlag, extractFlagsFromBody, parseFlagsField, resolveSkillFlags, parseSkillMd, harvestFlagsFromSkillMd, type ParsedSkillMd, } from '../../../utils/skill-md.js';
|