agent-afk 5.296.3 → 5.296.5
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/daemon/tool-health-task.d.ts +1 -0
- package/dist/agent/tools/hooks/path-approval-hook.d.ts +13 -1
- package/dist/agent/tools/hooks/path-approval-hook.prompt.d.ts +18 -0
- package/dist/agent/tools/readonly-bash.d.ts +1 -0
- package/dist/agent/tools/readonly-bash.tokenizer.d.ts +10 -0
- package/dist/agent/trace/receipt.d.ts +1 -1
- package/dist/agent/trace/receipt.render.d.ts +2 -0
- package/dist/agent/worktree/worktree-sweep.classify.d.ts +43 -0
- package/dist/agent/worktree/worktree-sweep.d.ts +2 -3
- package/dist/agent/worktree/worktree-sweep.lock.d.ts +5 -0
- package/dist/cli/commands/chat.mcp-setup.d.ts +8 -0
- package/dist/cli/commands/chat.response-output.d.ts +24 -0
- package/dist/cli/commands/chat.session-setup.d.ts +46 -0
- package/dist/cli/commands/chat.stdin-stream.d.ts +3 -0
- package/dist/cli/commands/farm.d.ts +4 -5
- package/dist/cli/commands/farm.escape-check.d.ts +4 -0
- package/dist/cli/commands/farm.run-record.d.ts +4 -0
- package/dist/cli/commands/farm.summary.d.ts +11 -0
- package/dist/cli/commands/interactive/worktree.cleanup.d.ts +11 -0
- package/dist/cli/commands/interactive/worktree.errors.d.ts +5 -0
- package/dist/cli/commands/interactive/worktree.refs.d.ts +5 -0
- package/dist/cli.mjs +659 -658
- package/dist/index.mjs +154 -154
- package/dist/telegram.mjs +199 -199
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TelemetryRecord, TelemetryTrigger } from './scheduler.js';
|
|
2
|
+
export declare function _resetToolHealthAlertCooldownForTests(): void;
|
|
2
3
|
export declare const TOOL_HEALTH_LOOKBACK_MS: number;
|
|
3
4
|
export declare const TOOL_HEALTH_MIN_SESSIONS = 2;
|
|
4
5
|
export declare const TOOL_HEALTH_COOLDOWN_MS: number;
|
|
@@ -1,9 +1,21 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { GrantManager } from '../grant-manager.js';
|
|
2
|
+
import type { HookDecision, HookHandler } from '../../hooks.js';
|
|
3
|
+
export { extractCandidatePath, extractAllPaths } from './path-approval-hook.prompt.js';
|
|
2
4
|
export type PathApprovalSurface = 'repl' | 'telegram' | 'web' | 'unknown';
|
|
3
5
|
export interface PathApprovalHookOptions {
|
|
4
6
|
getCwd: () => string | undefined;
|
|
5
7
|
surface: PathApprovalSurface;
|
|
6
8
|
}
|
|
9
|
+
export interface PathApprovalState {
|
|
10
|
+
sessionApproved: Set<string>;
|
|
11
|
+
onceApproved: Map<string, {
|
|
12
|
+
resolvedPath: string;
|
|
13
|
+
mode: 'read' | 'write';
|
|
14
|
+
capturedCwd: string | undefined;
|
|
15
|
+
}>;
|
|
16
|
+
inFlight: Map<string, Promise<HookDecision>>;
|
|
17
|
+
lastSeenGrantManager: GrantManager | undefined;
|
|
18
|
+
}
|
|
7
19
|
export interface PathApprovalHookHandlers {
|
|
8
20
|
preToolUse: HookHandler;
|
|
9
21
|
postToolUse: HookHandler;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { GrantManager } from '../grant-manager.js';
|
|
2
|
+
import type { HookDecision } from '../../hooks.js';
|
|
3
|
+
import type { PathApprovalState, PathApprovalSurface } from './path-approval-hook.js';
|
|
4
|
+
export declare function extractCandidatePath(toolName: string, input: Record<string, unknown>): string | undefined;
|
|
5
|
+
export declare function extractAllPaths(toolName: string, input: Record<string, unknown>): string[];
|
|
6
|
+
export declare function pathApprovalKey(mode: 'read' | 'write', resolvedPath: string): string;
|
|
7
|
+
export declare function promptForApproval(args: {
|
|
8
|
+
toolName: string;
|
|
9
|
+
resolvedPath: string;
|
|
10
|
+
allPaths?: string[];
|
|
11
|
+
capturedCwd: string | undefined;
|
|
12
|
+
mode: 'read' | 'write';
|
|
13
|
+
grantManager: GrantManager;
|
|
14
|
+
state: PathApprovalState;
|
|
15
|
+
surface: PathApprovalSurface;
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
sessionId?: string;
|
|
18
|
+
}): Promise<HookDecision>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface CmdSegment {
|
|
2
|
+
readonly command: string;
|
|
3
|
+
readonly argv: readonly string[];
|
|
4
|
+
}
|
|
5
|
+
export declare function baseName(cmd: string): string;
|
|
6
|
+
export declare function tokenizeSegments(command: string): string[][];
|
|
7
|
+
export declare function resolveSegment(rawTokens: readonly string[], vars: Map<string, string>): CmdSegment | null;
|
|
8
|
+
export declare function gitSegmentReason(argv: readonly string[]): string | null;
|
|
9
|
+
export declare function curlSegmentMutating(seg: CmdSegment): boolean;
|
|
10
|
+
export declare function tokenizedSegmentReason(command: string): string | null;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { renderReceiptMarkdown } from './receipt.render.js';
|
|
1
2
|
import type { HookHandler } from '../hooks.js';
|
|
2
3
|
import { type ClosureReason, type ToolFailureClass, type TraceEvent, type TraceEventKind } from './types.js';
|
|
3
4
|
export declare const RECEIPT_SCHEMA_VERSION: 1;
|
|
@@ -78,7 +79,6 @@ export declare function receiptPathsFor(tracePath: string): {
|
|
|
78
79
|
mdPath: string;
|
|
79
80
|
};
|
|
80
81
|
export declare function generateReceipt(events: TraceEvent[], meta: ReceiptMeta): RunReceipt;
|
|
81
|
-
export declare function renderReceiptMarkdown(r: RunReceipt): string;
|
|
82
82
|
export interface WriteRunReceiptOptions {
|
|
83
83
|
tracePath: string;
|
|
84
84
|
sessionId?: string;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export declare const MIN_EMPTY_AGE_MS = 3600000;
|
|
2
|
+
export type DirtyReason = 'clean' | 'uncommitted changes' | 'git status failed' | `non-rebuildable ignored files: ${string}` | 'ignored-file probe failed';
|
|
3
|
+
export interface WorktreeMeta {
|
|
4
|
+
owner: 'interactive' | 'diagnose' | string;
|
|
5
|
+
pid?: number;
|
|
6
|
+
createdAt: string;
|
|
7
|
+
baseSha?: string;
|
|
8
|
+
baseBranch?: string;
|
|
9
|
+
preservedReason?: 'dirty' | 'commits-ahead' | 'ignored-local-state';
|
|
10
|
+
preservedAt?: string;
|
|
11
|
+
commitsAheadAtPreserve?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface WorktreeCandidate {
|
|
14
|
+
path: string;
|
|
15
|
+
head?: string;
|
|
16
|
+
branch?: string;
|
|
17
|
+
locked: boolean;
|
|
18
|
+
prunable: boolean;
|
|
19
|
+
meta?: WorktreeMeta;
|
|
20
|
+
ageMs: number;
|
|
21
|
+
isDirty: boolean;
|
|
22
|
+
dirtyReason: DirtyReason;
|
|
23
|
+
commitsAhead: number;
|
|
24
|
+
commitsUnpushed: number;
|
|
25
|
+
ownerLiveness: 'alive' | 'dead' | 'unknown';
|
|
26
|
+
}
|
|
27
|
+
export type WorktreeVerdict = 'empty' | 'stale-clean' | 'stale-dirty' | 'locked' | 'active' | 'orphaned-dir' | 'orphaned-dir-preserved' | 'orphaned-registration' | 'dead-owner';
|
|
28
|
+
export declare const MAX_TRUSTED_PID_AGE_MS: number;
|
|
29
|
+
export { isProcessAlive } from '../process-liveness.js';
|
|
30
|
+
export declare function realpathSafe(p: string): string;
|
|
31
|
+
export declare function isPathWithin(child: string, parent: string): boolean;
|
|
32
|
+
export declare function shortBranchName(branch: string): string;
|
|
33
|
+
export interface ParsedWorktree {
|
|
34
|
+
path: string;
|
|
35
|
+
head: string;
|
|
36
|
+
branch: string;
|
|
37
|
+
locked: boolean;
|
|
38
|
+
lockReason?: string;
|
|
39
|
+
prunable: boolean;
|
|
40
|
+
isBare: boolean;
|
|
41
|
+
}
|
|
42
|
+
export declare function parseWorktreeList(stdout: string): ParsedWorktree[];
|
|
43
|
+
export declare function classifyCandidate(candidate: WorktreeCandidate, maxAgeDaysClean: number, maxAgeDaysDirty: number): WorktreeVerdict;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type PresenceRecord } from '../awareness/presence.js';
|
|
2
|
+
import { type WorktreeVerdict } from './worktree-sweep.classify.js';
|
|
3
|
+
export { MIN_EMPTY_AGE_MS } from './worktree-sweep.classify.js';
|
|
2
4
|
export type ExecFileFn = (file: string, args: string[], opts?: {
|
|
3
5
|
cwd?: string;
|
|
4
6
|
maxBuffer?: number;
|
|
@@ -7,7 +9,6 @@ export type ExecFileFn = (file: string, args: string[], opts?: {
|
|
|
7
9
|
stdout: string;
|
|
8
10
|
stderr: string;
|
|
9
11
|
}>;
|
|
10
|
-
type WorktreeVerdict = 'empty' | 'stale-clean' | 'stale-dirty' | 'locked' | 'active' | 'orphaned-dir' | 'orphaned-dir-preserved' | 'orphaned-registration' | 'dead-owner';
|
|
11
12
|
export interface SweepOptions {
|
|
12
13
|
execFile: ExecFileFn;
|
|
13
14
|
repoRoot: string;
|
|
@@ -33,6 +34,4 @@ export interface SweepResult {
|
|
|
33
34
|
candidates: SweepCandidateSummary[];
|
|
34
35
|
contested?: boolean;
|
|
35
36
|
}
|
|
36
|
-
export declare const MIN_EMPTY_AGE_MS = 3600000;
|
|
37
37
|
export declare function runSweep(options: SweepOptions): Promise<SweepResult>;
|
|
38
|
-
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { McpManager } from '../../agent/mcp/index.js';
|
|
2
|
+
import type { TraceWriter } from '../../agent/trace/writer.js';
|
|
3
|
+
export interface ChatMcpSetupParams {
|
|
4
|
+
worktreeCwd: string | undefined;
|
|
5
|
+
mcpConfigOverride: string | undefined;
|
|
6
|
+
traceWriter: TraceWriter | undefined;
|
|
7
|
+
}
|
|
8
|
+
export declare function connectMcpForChat(params: ChatMcpSetupParams): Promise<McpManager | undefined>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AgentSession } from '../../agent/session.js';
|
|
2
|
+
import type { SessionStats } from '../slash/types.js';
|
|
3
|
+
import type { AgentModelInput } from '../../agent/types.js';
|
|
4
|
+
import type { Ora } from 'ora';
|
|
5
|
+
export interface StreamJsonPathParams {
|
|
6
|
+
session: AgentSession;
|
|
7
|
+
message: string;
|
|
8
|
+
stats: SessionStats;
|
|
9
|
+
maybePublish: (reviewText: string, errored: boolean) => Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export declare function runStreamJsonPath(params: StreamJsonPathParams): Promise<void>;
|
|
12
|
+
export interface TextResponseParams {
|
|
13
|
+
session: AgentSession;
|
|
14
|
+
message: string;
|
|
15
|
+
stats: SessionStats;
|
|
16
|
+
sessionModel: AgentModelInput;
|
|
17
|
+
format: string;
|
|
18
|
+
streamFlag: boolean;
|
|
19
|
+
receiptSessionLabel: string | undefined;
|
|
20
|
+
receiptTracePath: string | undefined;
|
|
21
|
+
maybePublish: (reviewText: string, errored: boolean) => Promise<void>;
|
|
22
|
+
spinner: Ora;
|
|
23
|
+
}
|
|
24
|
+
export declare function renderTextResponse(params: TextResponseParams): Promise<void>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { AgentSession } from '../../agent/session.js';
|
|
2
|
+
import { wireExecutors } from '../../agent/session/wire-executors.js';
|
|
3
|
+
import { MemoryStore } from '../../agent/memory/index.js';
|
|
4
|
+
import { StateStore } from '../../agent/state/state-store.js';
|
|
5
|
+
import { WorkspaceStore } from '../../agent/workspace/workspace-store.js';
|
|
6
|
+
import type { AgentModelInput, ThinkingConfig, EffortLevel } from '../../agent/types.js';
|
|
7
|
+
import type { TraceWriter } from '../../agent/trace/writer.js';
|
|
8
|
+
import type { McpManager } from '../../agent/mcp/index.js';
|
|
9
|
+
import type { PermissionMode } from '../../agent/types/sdk-types.js';
|
|
10
|
+
import type { ProviderRouteHints } from '../../agent/providers/index.js';
|
|
11
|
+
export interface ChatSessionSetupParams {
|
|
12
|
+
model: AgentModelInput;
|
|
13
|
+
sessionModel: AgentModelInput;
|
|
14
|
+
apiKey: string | undefined;
|
|
15
|
+
systemPrompt: string | undefined;
|
|
16
|
+
systemPromptSource: string | undefined;
|
|
17
|
+
basePrompt: string | undefined;
|
|
18
|
+
providerHints: ProviderRouteHints | undefined;
|
|
19
|
+
providerRaw: string | undefined;
|
|
20
|
+
thinking: ThinkingConfig | undefined;
|
|
21
|
+
effort: EffortLevel | undefined;
|
|
22
|
+
maxBudgetUsd: number | undefined;
|
|
23
|
+
taskBudget: number | undefined;
|
|
24
|
+
maxOutputTokens: number | undefined;
|
|
25
|
+
maxToolUseIterations: number | undefined;
|
|
26
|
+
worktreeCwd: string | undefined;
|
|
27
|
+
traceWriter: TraceWriter | undefined;
|
|
28
|
+
mcpManager: McpManager | undefined;
|
|
29
|
+
resumeConfig: Record<string, unknown>;
|
|
30
|
+
permissionMode: PermissionMode | undefined;
|
|
31
|
+
dangerouslySkipPermissions: boolean | undefined;
|
|
32
|
+
maxTurns: number;
|
|
33
|
+
temperature: number | undefined;
|
|
34
|
+
baseUrl: string | undefined;
|
|
35
|
+
openaiBaseUrl: string | undefined;
|
|
36
|
+
autoResumeOnUsageLimit: boolean | undefined;
|
|
37
|
+
}
|
|
38
|
+
export interface ChatSessionSetupResult {
|
|
39
|
+
session: AgentSession;
|
|
40
|
+
rootManager: ReturnType<typeof wireExecutors>['rootManager'];
|
|
41
|
+
composeExecutor: ReturnType<typeof wireExecutors>['composeExecutor'];
|
|
42
|
+
sharedMemoryStore: MemoryStore;
|
|
43
|
+
sharedStateStore: StateStore;
|
|
44
|
+
workspaceStore: WorkspaceStore | undefined;
|
|
45
|
+
}
|
|
46
|
+
export declare function buildChatSession(params: ChatSessionSetupParams): Promise<ChatSessionSetupResult>;
|
|
@@ -5,12 +5,12 @@ import { scoreBranch, writeScore } from '../../skills/score/index.js';
|
|
|
5
5
|
import { writeFarmFact } from '../../skills/score/memory-write.js';
|
|
6
6
|
import { sendFarmDigest } from '../../skills/score/digest.js';
|
|
7
7
|
import { createDefaultTraceWriter } from '../../agent/trace/factory.js';
|
|
8
|
+
import { printSummary, formatScore } from './farm.summary.js';
|
|
9
|
+
export { FarmIsolationViolation } from './farm.escape-check.js';
|
|
10
|
+
export type { BranchResult } from './farm.summary.js';
|
|
11
|
+
export { formatScore, printSummary };
|
|
8
12
|
declare function getCommitCount(worktreePath: string, baseSha: string): Promise<number>;
|
|
9
13
|
declare function getSourceRepoDirtyFiles(sourceCwd: string): Promise<string[]>;
|
|
10
|
-
export declare class FarmIsolationViolation extends Error {
|
|
11
|
-
readonly dirtyFiles: string[];
|
|
12
|
-
constructor(dirtyFiles: string[]);
|
|
13
|
-
}
|
|
14
14
|
export interface RunFarmOptions {
|
|
15
15
|
task: string;
|
|
16
16
|
branches: number;
|
|
@@ -37,4 +37,3 @@ export interface RunFarmOptions {
|
|
|
37
37
|
}
|
|
38
38
|
export declare function runFarm(opts: RunFarmOptions): Promise<void>;
|
|
39
39
|
export declare function registerFarmCommand(program: Command): void;
|
|
40
|
-
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { FarmRunRecord } from '../../skills/score/farm-run-record.js';
|
|
2
|
+
import type { FarmManifest } from '../../agent/worktree.js';
|
|
3
|
+
import type { BranchResult } from './farm.summary.js';
|
|
4
|
+
export declare function buildFarmRunRecord(manifest: FarmManifest, branchResults: BranchResult[], startedAt: string): FarmRunRecord;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type BranchScore } from '../../skills/score/index.js';
|
|
2
|
+
import type { CreatedBranch } from '../../agent/worktree.js';
|
|
3
|
+
export interface BranchResult {
|
|
4
|
+
index: number;
|
|
5
|
+
ok: boolean;
|
|
6
|
+
commitCount: number;
|
|
7
|
+
error?: string;
|
|
8
|
+
score?: BranchScore | null;
|
|
9
|
+
}
|
|
10
|
+
export declare function formatScore(score: BranchScore | null | undefined): string;
|
|
11
|
+
export declare function printSummary(taskName: string, taskSlug: string, branches: CreatedBranch[], branchResults: BranchResult[]): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ExecFileFn } from './worktree.js';
|
|
2
|
+
import type { WorktreeDisposition } from './worktree-disposition.js';
|
|
3
|
+
export interface WorktreeCleanupParams {
|
|
4
|
+
worktreePath: string;
|
|
5
|
+
branch: string;
|
|
6
|
+
repoRoot: string;
|
|
7
|
+
execFile: ExecFileFn;
|
|
8
|
+
force?: boolean;
|
|
9
|
+
disposition?: WorktreeDisposition;
|
|
10
|
+
}
|
|
11
|
+
export declare function runWorktreeCleanup(params: WorktreeCleanupParams): Promise<void>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ExecFileFn } from './worktree.js';
|
|
2
|
+
export declare function fetchIfRemoteRef(repoRoot: string, ref: string, execFile: ExecFileFn): Promise<void>;
|
|
3
|
+
export declare function resolveRefToSha(repoRoot: string, ref: string, execFile: ExecFileFn): Promise<string>;
|
|
4
|
+
export declare function resolveRefToShaOrUndefined(repoRoot: string, ref: string, execFile: ExecFileFn): Promise<string | undefined>;
|
|
5
|
+
export declare function detectDefaultBaseRef(repoRoot: string, execFile: ExecFileFn): Promise<string | undefined>;
|